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.0a5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ai37_agent_sdk-0.1.0a5.tar.gz | 23.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ai37_agent_sdk-0.1.0a5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.2 kB
Release files / ai37_agent_sdk-0.1.0a5.tar.gz
| Download URL | ai37_agent_sdk-0.1.0a5.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad98dcc5076692a6f323bdc1c73fac1715e695c19c559319e4b6619d1ea3f147
|
|
BLAKE2b-256 checksum How to use checksums |
e6b8cb71d856b1b9f0895905ea7f6f11ade60df9904dfb24430ad4869b41257c
|
| 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.0a5-py3-none-any.whl
| Download URL | ai37_agent_sdk-0.1.0a5-py3-none-any.whl |
|---|---|
| Size | 32.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f08739bd7fdebb09404bea242ea3c5f77c074ed111cb58ec25ef96b1c8cf6358
|
|
BLAKE2b-256 checksum How to use checksums |
1bc2caf5e35401fea0a78e69d272b3a4a836c19ffcab9d241b626479cb3a5d11
|
| 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
|