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.0a1.tar.gz (18.9 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.0a1-py3-none-any.whl (26.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai37_agent_sdk-0.1.0a1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Linux/6.18.0-9-generic

File hashes

Hashes for ai37_agent_sdk-0.1.0a1.tar.gz
Algorithm Hash digest
SHA256 ec85748764438e21ca3df769c7b0f810480ddd1e632c5ca4810da763716d2caa
MD5 40950ccf60480fbea4ea22bac8da1896
BLAKE2b-256 60ce575e8870c831aca608604edc2a23bc501977062c289c1077d588cc65a11f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ai37_agent_sdk-0.1.0a1-py3-none-any.whl
  • Upload date:
  • Size: 26.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.11.14 Linux/6.18.0-9-generic

File hashes

Hashes for ai37_agent_sdk-0.1.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f09b9180605de044a45fd8a1203e0f54f21d88fcac98a326829d1a14785dce8
MD5 6ef34818e488629621d5b9803d65342e
BLAKE2b-256 d2b4cff524fd758ece564e9462701514243b4d694fcf07fcb9913e8c356149e1

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