Skip to main content

Shared type definitions, protocols, and error hierarchy for AgentiCraft packages

Project description

CI coverage python license

Shared type definitions, protocols, and error hierarchy for AgentiCraft packages.

The type foundation behind AgentiCraft -- an enterprise-grade platform for building production-ready AI agents and multi-agent systems.

Pydantic v2 models · Protocol classes · Exception hierarchy · Configuration schemas · Zero business logic


Install

With uv (recommended):

uv add agenticraft-types

Or with pip:

pip install agenticraft-types

Quick Start

from agenticraft_types import (
    CompletionRequest,
    CompletionResponse,
    ProviderName,
    ProviderError,
    RateLimitError,
    RetryConfig,
)

# Build a typed request
request = CompletionRequest(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}],
    max_tokens=100,
)

# Use enums for provider selection
provider = ProviderName.OPENAI

# Catch typed exceptions
try:
    response = await some_provider.complete(request)
except RateLimitError as e:
    print(f"Rate limited by {e.provider}, retry after {e.retry_after}s")
except ProviderError as e:
    print(f"Provider {e.provider} failed: {e}")

Protocol-Based Typing

from agenticraft_types import Provider, Router, CircuitBreakerLike

# Structural typing -- implement the protocol, no inheritance needed
class MyProvider:
    async def complete(self, messages, **kwargs) -> CompletionResponse: ...
    async def stream(self, messages, **kwargs): ...

def route(provider: Provider) -> None:
    # Type-safe without coupling to a base class
    ...

What's Inside

  • models -- Pydantic v2 request/response models (CompletionRequest, CompletionResponse, StreamChunk, Usage, Message)
  • enums -- Shared enumerations (ProviderName, FailureType, RoutingStrategy, MessageRole, CircuitBreakerState)
  • errors -- Exception hierarchy (AgentiCraftError, ProviderError, RateLimitError, AuthenticationError, etc.)
  • protocols -- typing.Protocol classes for structural typing (Provider, Router, CircuitBreakerLike, KeyPoolLike)
  • config -- Configuration schemas (RetryConfig, CircuitBreakerConfig, RateLimitConfig)

Design Rules

  • Under 1,000 LOC total
  • Zero business logic
  • Only dependency: pydantic>=2.0
  • Apache 2.0 license

Development

# Install dev dependencies
uv sync --group dev

# Run tests
uv run pytest tests/ -v

# Run with coverage
uv run pytest tests/ --cov=agenticraft_types --cov-report=html

# Lint
uv run ruff check src/ tests/

# Format
uv run ruff format src/ tests/

# Type check
uv run pyright src/

# Pre-commit hooks
uv run pre-commit install

See CONTRIBUTING.md for full guidelines.

License

Apache 2.0

Part of the AgentiCraft platform.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenticraft_types-0.1.0.tar.gz (51.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenticraft_types-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file agenticraft_types-0.1.0.tar.gz.

File metadata

  • Download URL: agenticraft_types-0.1.0.tar.gz
  • Upload date:
  • Size: 51.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for agenticraft_types-0.1.0.tar.gz
Algorithm Hash digest
SHA256 062fadb2d72cfb30317f1b14591631d9d06010bb5317eaf7aa1434e5f9b0a873
MD5 3595fb59d3189451508436cb0c14499f
BLAKE2b-256 239e5be70d4554ad47bcac031f9b970fcf01bb7574e0d8efdd4df87b81bcb64f

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenticraft_types-0.1.0.tar.gz:

Publisher: release.yml on agenticraft/agenticraft-types

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agenticraft_types-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agenticraft_types-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4eb5b89652d55d09b0f8170af6c05225298c509fd3d347ae133f3995dd39bca8
MD5 7010c32f8be9b2884eba0503c867d1a0
BLAKE2b-256 7cc995da4983fd94ed0ab904f8d099359749bcc9314092d062fb3dfb5f1a9bee

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenticraft_types-0.1.0-py3-none-any.whl:

Publisher: release.yml on agenticraft/agenticraft-types

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page