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.0a4

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.0a4
File Size Uploaded
ai37_agent_sdk-0.1.0a4.tar.gz 23.0 kB Details

Built distribution (wheel)

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

Total release size: 55.0 kB

Release files / ai37_agent_sdk-0.1.0a4.tar.gz

Download URL ai37_agent_sdk-0.1.0a4.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d39184a460f2a775ed95431ad06597acb17b50316c94300ce4a8b82d05b41e01
BLAKE2b-256 checksum
How to use checksums
535982770fa01f67177e13f3ea11c4f96edcaec205c1c8eb4994ab6f4bdda2fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1020-azure

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

Download URL ai37_agent_sdk-0.1.0a4-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a46fdadd1cfb704dd259fb525aa2428e25e731b90cab49b0253bc3b92d79ea82
BLAKE2b-256 checksum
How to use checksums
02ef5ab359367180e3e4fdfb00351d0ea097ae04bf9ac2212cebcf5fda3a30bf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.3 Linux/6.17.0-1020-azure
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