Skip to main content

AI37 agent SDK (Python): JWKS auth + billing + A2A forward for ecosystem agents

Project description

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={...})

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

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 (фейки/фикстуры/тест-токены) — есть.

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

ai37_agent_sdk-0.1.0a2.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

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

ai37_agent_sdk-0.1.0a2-py3-none-any.whl (29.2 kB view details)

Uploaded Python 3

File details

Details for the file ai37_agent_sdk-0.1.0a2.tar.gz.

File metadata

  • Download URL: ai37_agent_sdk-0.1.0a2.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for ai37_agent_sdk-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 62e4f3aa073f8c8e25389806ca192e94e3f1ddd352fb7497cad769a6bbc82a75
MD5 8fe1e05fd7dd1a6f2a6a9c60610454f5
BLAKE2b-256 200ade0c8f316e3338e987631be709743fa9cb2cd04317a915f3b39b8326e0cf

See more details on using hashes here.

File details

Details for the file ai37_agent_sdk-0.1.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for ai37_agent_sdk-0.1.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 4c7bd91bc6d8554df832e2c4ffb320261fa87cede8b9062f7314c5afec77cdc5
MD5 4922254f6fb89d36ac1c6a71bcfc812a
BLAKE2b-256 bb463716bdae19e6b9e2574534d812fb7273ebd25da1e44759f0136a42313e12

See more details on using hashes here.

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