Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

ai37-agent-sdk (Python)

SDK агентов экосистемы AI37 (Python). Зеркало TS-пакета @ai37/agent-sdk (имена snake_case, синхронный API). Модули: auth (JWKS-верификация user-JWT), billing (runtime state + metered usage), a2a (forward user-JWT), AgentContext (sugar) и testing kit.

Контракт (источник истины) — ../../contract/. Спецификация — docs/projects/ai37-agent-sdk/. Host-слой (Express/FastAPI) в Python не реализован (пока не нужен).

Быстрый старт

from ai37_agent_sdk import AgentContext, AgentContextSettings, AuthSettings, BillingSettings

ctx = AgentContext.from_request(
    request_headers,
    AgentContextSettings(
        auth=AuthSettings(
            issuer="https://<issuer>/",
            audience="<client-id>",
            jwks_url="https://<issuer>/jwks/",
            required=True,
        ),
        billing=BillingSettings(base_url="http://billing:8000"),
    ),
)
state = ctx.assert_execution_allowed(feature=..., privilege=...)  # preflight
# LLM-агент:    api_key = ctx.llm_key
# metered-агент: ctx.report_usage(transaction_id=task_id, code="lift_calculation", properties={...})

Routing profile в Agent Card

from ai37_agent_sdk import build_agent_routing_extension

extension = build_agent_routing_extension({
    "domains": ["расчёт лифтов"],
    "intents": ["engineering_calculation", "parameter_selection"],
    "excludes": ["справочные вопросы о нормах"],
})

URI extension скрыт в SDK и служит только versioned идентификатором; HTTP-запрос к нему не нужен.

Тестирование агентов без внешних сервисов

from ai37_agent_sdk.testing import make_test_context, InMemoryBillingClient, fixtures

ctx = make_test_context(
    claims={"sub": "u1", "org_id": "u1", "billing_org_id": "org1", "app_id": "product-a"},
    billing=InMemoryBillingClient(runtime_state=fixtures.runtime_state.no_resources()),
)
# ctx.assert_execution_allowed(...) -> BillingExecutionDeniedError по фикстуре

Разработка

poetry install --with dev
poetry run pytest
poetry run ruff check .
poetry run mypy src

Не реализовано (follow-up): CLI dev-серверы (dev-jwks/dev-billing), режимы AI37_AUTH_MODE=insecure-dev / BILLING_MODE=fake. Основной testing kit (фейки/фикстуры/тест-токены) — есть.

Metadata

Release files for ai37-agent-sdk 0.1.0a6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai37-agent-sdk 0.1.0a6
File Size Uploaded
ai37_agent_sdk-0.1.0a6.tar.gz 24.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ai37-agent-sdk 0.1.0a6
File Interpreter ABI Platform
ai37_agent_sdk-0.1.0a6-py3-none-any.whl Python 3 none any Details

Total release size: 57.2 kB

Release files / ai37_agent_sdk-0.1.0a6.tar.gz

Download URL ai37_agent_sdk-0.1.0a6.tar.gz
Size 24.3 kB
Tags Source
SHA-256 checksum
How to use checksums
00560fb867d6b3d702962518066241c7db77b5d478c898e22f427fde11358d3b
BLAKE2b-256 checksum
How to use checksums
a4163fc8f33ebb55aa952af816d8faac1bf8674b2c6321baad2e44eaa5b82e64
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.11 Linux/6.8.0-136-generic

Release files / ai37_agent_sdk-0.1.0a6-py3-none-any.whl

Download URL ai37_agent_sdk-0.1.0a6-py3-none-any.whl
Size 32.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
31c22a2a9fd9f3739ee36c9ebf49cdf6600a555708200e15d8f7b46d3bc70e1e
BLAKE2b-256 checksum
How to use checksums
8615504d12c453f4d14c091e005e33f97360ea8d5ccce4dc1fa0835c22277c09
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.13.11 Linux/6.8.0-136-generic
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page