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.0a3.tar.gz (21.3 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.0a3-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai37_agent_sdk-0.1.0a3.tar.gz
  • Upload date:
  • Size: 21.3 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.0a3.tar.gz
Algorithm Hash digest
SHA256 57c3125a4ba1f98d4c56baa588732e2f0a246e2e2c993e1971ca631785988d45
MD5 b49d1e1fae80f32ed5f81aa6bc9dac6d
BLAKE2b-256 839dd140aaf31e2e102296995786dc13b1013583559090a504af2d0600788a91

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ai37_agent_sdk-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 ae4d60db1c65636e8cbf51063e87764581e928672a6eb92a7e81fcfae91bc398
MD5 2d14129e748413d8c29d4788025fc288
BLAKE2b-256 46495101530cdbc3f847759b9c2595d16ea953f0d6eded3df51e1e530f98188e

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