agent-adapter 1.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- agent_adapter/__init__.py +375 -0
- agent_adapter/__main__.py +5 -0
- agent_adapter/_guide/AGENTS.md +679 -0
- agent_adapter/_guide/llms-full.txt +1973 -0
- agent_adapter/_version.py +3 -0
- agent_adapter/approval/__init__.py +74 -0
- agent_adapter/approval/_records.py +99 -0
- agent_adapter/approval/batch.py +146 -0
- agent_adapter/approval/builtin.py +127 -0
- agent_adapter/approval/deferred.py +185 -0
- agent_adapter/approval/dynamodb_items.py +236 -0
- agent_adapter/approval/dynamodb_store.py +396 -0
- agent_adapter/approval/memory.py +167 -0
- agent_adapter/approval/persist.py +114 -0
- agent_adapter/approval/redis_scripts.py +88 -0
- agent_adapter/approval/redis_store.py +282 -0
- agent_adapter/approval/rules.py +329 -0
- agent_adapter/approval/sqlalchemy_schema.py +103 -0
- agent_adapter/approval/sqlalchemy_store.py +350 -0
- agent_adapter/approval/sqlite_store.py +380 -0
- agent_adapter/approval/store.py +285 -0
- agent_adapter/audit/__init__.py +28 -0
- agent_adapter/audit/_actions.py +148 -0
- agent_adapter/audit/_chain.py +89 -0
- agent_adapter/audit/_check.py +153 -0
- agent_adapter/audit/_files.py +181 -0
- agent_adapter/audit/_scrub.py +71 -0
- agent_adapter/audit/_writer.py +80 -0
- agent_adapter/audit/callable.py +81 -0
- agent_adapter/audit/errors.py +20 -0
- agent_adapter/audit/export.py +125 -0
- agent_adapter/audit/sink.py +178 -0
- agent_adapter/audit/store.py +305 -0
- agent_adapter/audit/verify.py +235 -0
- agent_adapter/cache/__init__.py +38 -0
- agent_adapter/cache/codec.py +63 -0
- agent_adapter/cache/keys.py +101 -0
- agent_adapter/cache/layout.py +55 -0
- agent_adapter/cache/llm_cache.py +95 -0
- agent_adapter/cache/memory.py +82 -0
- agent_adapter/cache/providers/__init__.py +16 -0
- agent_adapter/cache/providers/_base.py +129 -0
- agent_adapter/cache/providers/anthropic.py +158 -0
- agent_adapter/cache/providers/gemini.py +264 -0
- agent_adapter/cache/providers/openai.py +224 -0
- agent_adapter/cache/redis.py +138 -0
- agent_adapter/cache/tool_cache.py +95 -0
- agent_adapter/chat/__init__.py +11 -0
- agent_adapter/chat/contract.py +78 -0
- agent_adapter/cli/__init__.py +3 -0
- agent_adapter/cli/__main__.py +5 -0
- agent_adapter/cli/_migrate_diff.py +230 -0
- agent_adapter/cli/_migrate_rules.py +86 -0
- agent_adapter/cli/_migrate_scan.py +417 -0
- agent_adapter/cli/audit.py +108 -0
- agent_adapter/cli/doctor.py +177 -0
- agent_adapter/cli/doctor_features.py +156 -0
- agent_adapter/cli/eval.py +304 -0
- agent_adapter/cli/findings.py +21 -0
- agent_adapter/cli/guide.py +89 -0
- agent_adapter/cli/main.py +154 -0
- agent_adapter/cli/migrate.py +146 -0
- agent_adapter/cli/pipindex.py +130 -0
- agent_adapter/cli/policy.py +117 -0
- agent_adapter/cli/scaffold.py +102 -0
- agent_adapter/cli/templates/adk.py.tmpl +78 -0
- agent_adapter/cli/templates/agno.py.tmpl +66 -0
- agent_adapter/cli/templates/celery.py.tmpl +37 -0
- agent_adapter/cli/templates/crewai.py.tmpl +70 -0
- agent_adapter/cli/templates/fastapi.py.tmpl +30 -0
- agent_adapter/cli/templates/flask.py.tmpl +30 -0
- agent_adapter/cli/templates/langgraph.py.tmpl +36 -0
- agent_adapter/cli/templates/mcp_server.py.tmpl +29 -0
- agent_adapter/cli/templates/openai_agents.py.tmpl +28 -0
- agent_adapter/cli/templates/pydantic_ai.py.tmpl +68 -0
- agent_adapter/cli/templates/script.py.tmpl +21 -0
- agent_adapter/cli/templates/strands.py.tmpl +63 -0
- agent_adapter/cli/ui.py +298 -0
- agent_adapter/context/__init__.py +70 -0
- agent_adapter/context/compress.py +190 -0
- agent_adapter/context/conversation.py +168 -0
- agent_adapter/context/defaults.py +20 -0
- agent_adapter/context/entries.py +159 -0
- agent_adapter/context/formats/__init__.py +193 -0
- agent_adapter/context/formats/_items.py +164 -0
- agent_adapter/context/formats/_registry.py +77 -0
- agent_adapter/context/formats/_shared.py +287 -0
- agent_adapter/context/formats/anthropic.py +142 -0
- agent_adapter/context/formats/gemini.py +186 -0
- agent_adapter/context/formats/langchain.py +134 -0
- agent_adapter/context/formats/openai.py +234 -0
- agent_adapter/context/guard.py +240 -0
- agent_adapter/context/model.py +288 -0
- agent_adapter/context/neutralise.py +106 -0
- agent_adapter/context/policy.py +142 -0
- agent_adapter/context/recall.py +99 -0
- agent_adapter/context/redaction.py +106 -0
- agent_adapter/context/reference.py +24 -0
- agent_adapter/context/relevant.py +67 -0
- agent_adapter/context/rerank.py +211 -0
- agent_adapter/context/run.py +181 -0
- agent_adapter/context/scorer.py +132 -0
- agent_adapter/context/scoring.py +113 -0
- agent_adapter/context/shrink.py +87 -0
- agent_adapter/context/step.py +222 -0
- agent_adapter/context/steps.py +286 -0
- agent_adapter/context/summarize.py +332 -0
- agent_adapter/context/summary_call.py +136 -0
- agent_adapter/context/summary_prompt.py +157 -0
- agent_adapter/context/tokens.py +90 -0
- agent_adapter/core/__init__.py +1 -0
- agent_adapter/core/_attempt.py +22 -0
- agent_adapter/core/_bounded.py +36 -0
- agent_adapter/core/_default.py +28 -0
- agent_adapter/core/_docstring.py +53 -0
- agent_adapter/core/_nulls.py +101 -0
- agent_adapter/core/_partial_json.py +194 -0
- agent_adapter/core/_policy.py +111 -0
- agent_adapter/core/_signature.py +243 -0
- agent_adapter/core/callables.py +10 -0
- agent_adapter/core/context.py +54 -0
- agent_adapter/core/control.py +57 -0
- agent_adapter/core/error_base.py +47 -0
- agent_adapter/core/errors.py +399 -0
- agent_adapter/core/imported.py +124 -0
- agent_adapter/core/messages.py +185 -0
- agent_adapter/core/model_errors.py +100 -0
- agent_adapter/core/ports.py +90 -0
- agent_adapter/core/registry.py +221 -0
- agent_adapter/core/tool.py +360 -0
- agent_adapter/core/types.py +307 -0
- agent_adapter/cost/__init__.py +21 -0
- agent_adapter/cost/_table.py +233 -0
- agent_adapter/cost/ledger.py +189 -0
- agent_adapter/cost/prices.py +389 -0
- agent_adapter/cost/prices_default.json +153 -0
- agent_adapter/cost/sinks.py +88 -0
- agent_adapter/cost/summary.py +93 -0
- agent_adapter/embeddings/__init__.py +13 -0
- agent_adapter/embeddings/_record.py +215 -0
- agent_adapter/embeddings/cache.py +102 -0
- agent_adapter/embeddings/callable.py +241 -0
- agent_adapter/embeddings/port.py +52 -0
- agent_adapter/errors.py +117 -0
- agent_adapter/evals/__init__.py +175 -0
- agent_adapter/evals/_advisor_report.py +142 -0
- agent_adapter/evals/_calls.py +60 -0
- agent_adapter/evals/_collect.py +74 -0
- agent_adapter/evals/_grading.py +56 -0
- agent_adapter/evals/_render.py +101 -0
- agent_adapter/evals/_run_content.py +167 -0
- agent_adapter/evals/_run_files.py +180 -0
- agent_adapter/evals/_schema_check.py +100 -0
- agent_adapter/evals/_spend.py +224 -0
- agent_adapter/evals/_step_models.py +122 -0
- agent_adapter/evals/_text.py +50 -0
- agent_adapter/evals/advisor.py +399 -0
- agent_adapter/evals/cases.py +122 -0
- agent_adapter/evals/from_runs.py +222 -0
- agent_adapter/evals/graders.py +316 -0
- agent_adapter/evals/judge.py +146 -0
- agent_adapter/evals/model.py +53 -0
- agent_adapter/evals/pytest_plugin.py +64 -0
- agent_adapter/evals/report.py +228 -0
- agent_adapter/evals/runner.py +360 -0
- agent_adapter/evals/store.py +46 -0
- agent_adapter/evals/targets.py +218 -0
- agent_adapter/exec/__init__.py +48 -0
- agent_adapter/exec/_approve.py +211 -0
- agent_adapter/exec/_batches.py +195 -0
- agent_adapter/exec/_call_content.py +32 -0
- agent_adapter/exec/_call_steps.py +107 -0
- agent_adapter/exec/_canon.py +394 -0
- agent_adapter/exec/_durable.py +272 -0
- agent_adapter/exec/_durable_loop.py +228 -0
- agent_adapter/exec/_durable_seal.py +192 -0
- agent_adapter/exec/_journal.py +372 -0
- agent_adapter/exec/_loop_history.py +58 -0
- agent_adapter/exec/_loop_steps.py +261 -0
- agent_adapter/exec/_resume.py +183 -0
- agent_adapter/exec/_settings.py +53 -0
- agent_adapter/exec/_sink_hub.py +55 -0
- agent_adapter/exec/_sugar.py +297 -0
- agent_adapter/exec/_sync_twins.py +121 -0
- agent_adapter/exec/agents.py +249 -0
- agent_adapter/exec/args.py +12 -0
- agent_adapter/exec/checkpoints/__init__.py +31 -0
- agent_adapter/exec/checkpoints/_port.py +239 -0
- agent_adapter/exec/checkpoints/memory.py +104 -0
- agent_adapter/exec/checkpoints/redis_store.py +344 -0
- agent_adapter/exec/checkpoints/sqlalchemy_store.py +368 -0
- agent_adapter/exec/checkpoints/sqlite_store.py +324 -0
- agent_adapter/exec/control.py +5 -0
- agent_adapter/exec/defaults.py +123 -0
- agent_adapter/exec/executor.py +405 -0
- agent_adapter/exec/guards.py +278 -0
- agent_adapter/exec/handoffs.py +118 -0
- agent_adapter/exec/integration.py +52 -0
- agent_adapter/exec/parallel.py +279 -0
- agent_adapter/exec/pipeline.py +419 -0
- agent_adapter/exec/plan.py +134 -0
- agent_adapter/exec/retry.py +108 -0
- agent_adapter/exec/tool_loop.py +336 -0
- agent_adapter/flow/__init__.py +41 -0
- agent_adapter/flow/_cache.py +361 -0
- agent_adapter/flow/_digest.py +100 -0
- agent_adapter/flow/_drive.py +143 -0
- agent_adapter/flow/_durable.py +313 -0
- agent_adapter/flow/_gates.py +188 -0
- agent_adapter/flow/_invoke.py +51 -0
- agent_adapter/flow/_loop.py +181 -0
- agent_adapter/flow/_map.py +199 -0
- agent_adapter/flow/_nested.py +56 -0
- agent_adapter/flow/_nodes.py +425 -0
- agent_adapter/flow/_pause.py +202 -0
- agent_adapter/flow/_recover.py +171 -0
- agent_adapter/flow/_result.py +114 -0
- agent_adapter/flow/_resume.py +196 -0
- agent_adapter/flow/_seal.py +293 -0
- agent_adapter/flow/_step.py +160 -0
- agent_adapter/flow/_subcheck.py +235 -0
- agent_adapter/flow/_subflow.py +161 -0
- agent_adapter/flow/_trace.py +49 -0
- agent_adapter/flow/_updates.py +16 -0
- agent_adapter/flow/_withdraw.py +83 -0
- agent_adapter/flow/actions.py +107 -0
- agent_adapter/flow/diagram.py +226 -0
- agent_adapter/flow/graph.py +340 -0
- agent_adapter/flow/runner.py +383 -0
- agent_adapter/flow/spec.py +187 -0
- agent_adapter/flow/state.py +181 -0
- agent_adapter/flow/visit.py +75 -0
- agent_adapter/handlers/__init__.py +16 -0
- agent_adapter/handlers/consume.py +127 -0
- agent_adapter/handlers/envelope.py +100 -0
- agent_adapter/handlers/serverless.py +165 -0
- agent_adapter/hooks/__init__.py +53 -0
- agent_adapter/hooks/base.py +114 -0
- agent_adapter/hooks/builtin/__init__.py +21 -0
- agent_adapter/hooks/builtin/_content.py +106 -0
- agent_adapter/hooks/builtin/budget.py +410 -0
- agent_adapter/hooks/builtin/budgets/__init__.py +29 -0
- agent_adapter/hooks/builtin/budgets/_holds.py +58 -0
- agent_adapter/hooks/builtin/budgets/_keys.py +69 -0
- agent_adapter/hooks/builtin/budgets/_pricing.py +94 -0
- agent_adapter/hooks/builtin/budgets/_settings.py +56 -0
- agent_adapter/hooks/builtin/budgets/redis_store.py +221 -0
- agent_adapter/hooks/builtin/budgets/sqlalchemy_store.py +301 -0
- agent_adapter/hooks/builtin/budgets/sqlite_store.py +265 -0
- agent_adapter/hooks/builtin/budgets/status.py +41 -0
- agent_adapter/hooks/builtin/budgets/store.py +225 -0
- agent_adapter/hooks/builtin/guardrail.py +80 -0
- agent_adapter/hooks/builtin/guards/__init__.py +41 -0
- agent_adapter/hooks/builtin/guards/_walk.py +191 -0
- agent_adapter/hooks/builtin/guards/base.py +229 -0
- agent_adapter/hooks/builtin/guards/callable.py +61 -0
- agent_adapter/hooks/builtin/guards/nemo.py +59 -0
- agent_adapter/hooks/builtin/guards/pii.py +240 -0
- agent_adapter/hooks/builtin/guards/presidio.py +77 -0
- agent_adapter/hooks/builtin/logging.py +266 -0
- agent_adapter/hooks/builtin/rate_limit.py +105 -0
- agent_adapter/hooks/dispatch.py +111 -0
- agent_adapter/integrations/__init__.py +1 -0
- agent_adapter/integrations/_attach.py +175 -0
- agent_adapter/integrations/_compress_hooks.py +158 -0
- agent_adapter/integrations/_compress_parts.py +109 -0
- agent_adapter/integrations/_default_runner.py +63 -0
- agent_adapter/integrations/_durable_engine.py +71 -0
- agent_adapter/integrations/_durable_flows.py +404 -0
- agent_adapter/integrations/_durable_slice.py +42 -0
- agent_adapter/integrations/_expiring.py +93 -0
- agent_adapter/integrations/_native_approval.py +66 -0
- agent_adapter/integrations/_native_gate.py +373 -0
- agent_adapter/integrations/a2a/__init__.py +61 -0
- agent_adapter/integrations/a2a/_guard.py +198 -0
- agent_adapter/integrations/a2a/_owned.py +126 -0
- agent_adapter/integrations/a2a/_pending.py +76 -0
- agent_adapter/integrations/a2a/_pinned.py +156 -0
- agent_adapter/integrations/a2a/_task_store.py +127 -0
- agent_adapter/integrations/a2a/_wire.py +146 -0
- agent_adapter/integrations/a2a/agent.py +363 -0
- agent_adapter/integrations/a2a/card.py +98 -0
- agent_adapter/integrations/a2a/client.py +408 -0
- agent_adapter/integrations/a2a/server.py +377 -0
- agent_adapter/integrations/adk/__init__.py +25 -0
- agent_adapter/integrations/adk/_driver.py +317 -0
- agent_adapter/integrations/adk/_run.py +200 -0
- agent_adapter/integrations/adk/_steps.py +380 -0
- agent_adapter/integrations/adk/_support.py +98 -0
- agent_adapter/integrations/adk/_tokens.py +215 -0
- agent_adapter/integrations/adk/_workflow.py +179 -0
- agent_adapter/integrations/adk/compile.py +97 -0
- agent_adapter/integrations/adk/tools.py +221 -0
- agent_adapter/integrations/ag2.py +256 -0
- agent_adapter/integrations/ag2_compress.py +218 -0
- agent_adapter/integrations/ag_ui/__init__.py +25 -0
- agent_adapter/integrations/ag_ui/_channel.py +69 -0
- agent_adapter/integrations/ag_ui/_events.py +159 -0
- agent_adapter/integrations/ag_ui/_input.py +130 -0
- agent_adapter/integrations/ag_ui/_interrupts.py +124 -0
- agent_adapter/integrations/ag_ui/_resume.py +153 -0
- agent_adapter/integrations/ag_ui/_support.py +64 -0
- agent_adapter/integrations/ag_ui/bridge.py +169 -0
- agent_adapter/integrations/ag_ui/run.py +88 -0
- agent_adapter/integrations/ag_ui/starlette.py +110 -0
- agent_adapter/integrations/agent_framework.py +302 -0
- agent_adapter/integrations/agno.py +160 -0
- agent_adapter/integrations/agno_compress.py +154 -0
- agent_adapter/integrations/anthropic.py +78 -0
- agent_adapter/integrations/autogen.py +155 -0
- agent_adapter/integrations/autogen_compress.py +188 -0
- agent_adapter/integrations/base.py +185 -0
- agent_adapter/integrations/camel.py +319 -0
- agent_adapter/integrations/claude_agent.py +372 -0
- agent_adapter/integrations/crewai.py +92 -0
- agent_adapter/integrations/dbos.py +255 -0
- agent_adapter/integrations/discovery.py +171 -0
- agent_adapter/integrations/dspy.py +112 -0
- agent_adapter/integrations/gemini.py +398 -0
- agent_adapter/integrations/haystack.py +320 -0
- agent_adapter/integrations/langchain.py +228 -0
- agent_adapter/integrations/langgraph/__init__.py +34 -0
- agent_adapter/integrations/langgraph/_channels.py +177 -0
- agent_adapter/integrations/langgraph/_context.py +39 -0
- agent_adapter/integrations/langgraph/_durable.py +163 -0
- agent_adapter/integrations/langgraph/_gate.py +141 -0
- agent_adapter/integrations/langgraph/_integration.py +44 -0
- agent_adapter/integrations/langgraph/_memo.py +70 -0
- agent_adapter/integrations/langgraph/_node.py +375 -0
- agent_adapter/integrations/langgraph/_run.py +358 -0
- agent_adapter/integrations/langgraph/_spent.py +212 -0
- agent_adapter/integrations/langgraph/_store_decisions.py +86 -0
- agent_adapter/integrations/langgraph/_user_node.py +137 -0
- agent_adapter/integrations/langgraph/approval.py +319 -0
- agent_adapter/integrations/langgraph/compile.py +139 -0
- agent_adapter/integrations/langgraph/compress.py +78 -0
- agent_adapter/integrations/langgraph/tools.py +346 -0
- agent_adapter/integrations/llamaindex.py +188 -0
- agent_adapter/integrations/mcp/__init__.py +91 -0
- agent_adapter/integrations/mcp/_approval.py +246 -0
- agent_adapter/integrations/mcp/_handlers.py +340 -0
- agent_adapter/integrations/mcp/_peer.py +67 -0
- agent_adapter/integrations/mcp/_resume.py +269 -0
- agent_adapter/integrations/mcp/_scope.py +230 -0
- agent_adapter/integrations/mcp/_task_params.py +45 -0
- agent_adapter/integrations/mcp/_task_service.py +381 -0
- agent_adapter/integrations/mcp/_task_store.py +196 -0
- agent_adapter/integrations/mcp/_task_table.py +232 -0
- agent_adapter/integrations/mcp/_tasks_client.py +180 -0
- agent_adapter/integrations/mcp/annotations.py +147 -0
- agent_adapter/integrations/mcp/client.py +357 -0
- agent_adapter/integrations/mcp/oauth.py +160 -0
- agent_adapter/integrations/mcp/server.py +338 -0
- agent_adapter/integrations/mcp/tasks.py +98 -0
- agent_adapter/integrations/openai.py +86 -0
- agent_adapter/integrations/openai_agents.py +366 -0
- agent_adapter/integrations/openapi/__init__.py +150 -0
- agent_adapter/integrations/openapi/_decode.py +128 -0
- agent_adapter/integrations/openapi/_document.py +130 -0
- agent_adapter/integrations/openapi/_http.py +318 -0
- agent_adapter/integrations/openapi/_names.py +30 -0
- agent_adapter/integrations/openapi/_redact.py +56 -0
- agent_adapter/integrations/openapi/_refs.py +264 -0
- agent_adapter/integrations/openapi/_report.py +72 -0
- agent_adapter/integrations/openapi/_schema.py +387 -0
- agent_adapter/integrations/openapi/auth.py +86 -0
- agent_adapter/integrations/pydantic_ai.py +293 -0
- agent_adapter/integrations/pydantic_ai_compress.py +245 -0
- agent_adapter/integrations/semantic_kernel.py +389 -0
- agent_adapter/integrations/smolagents.py +202 -0
- agent_adapter/integrations/smolagents_compress.py +132 -0
- agent_adapter/integrations/strands.py +229 -0
- agent_adapter/integrations/strands_compress.py +178 -0
- agent_adapter/integrations/temporal.py +351 -0
- agent_adapter/memory/__init__.py +35 -0
- agent_adapter/memory/_base.py +333 -0
- agent_adapter/memory/_clients.py +84 -0
- agent_adapter/memory/_sqlite_sql.py +224 -0
- agent_adapter/memory/callable.py +110 -0
- agent_adapter/memory/graphiti.py +131 -0
- agent_adapter/memory/mem0.py +171 -0
- agent_adapter/memory/port.py +47 -0
- agent_adapter/memory/records.py +240 -0
- agent_adapter/memory/sqlite.py +391 -0
- agent_adapter/memory/tools.py +165 -0
- agent_adapter/memory/zep.py +196 -0
- agent_adapter/models/__init__.py +56 -0
- agent_adapter/models/_anthropic_convert.py +252 -0
- agent_adapter/models/_anthropic_schema.py +84 -0
- agent_adapter/models/_convert.py +139 -0
- agent_adapter/models/_gemini_convert.py +265 -0
- agent_adapter/models/_llm_call.py +401 -0
- agent_adapter/models/_openai_chat.py +201 -0
- agent_adapter/models/_openai_common.py +33 -0
- agent_adapter/models/_openai_responses.py +239 -0
- agent_adapter/models/_port.py +394 -0
- agent_adapter/models/anthropic.py +176 -0
- agent_adapter/models/callable.py +199 -0
- agent_adapter/models/entries.py +42 -0
- agent_adapter/models/errors.py +190 -0
- agent_adapter/models/fallback.py +150 -0
- agent_adapter/models/gemini.py +184 -0
- agent_adapter/models/instrument.py +257 -0
- agent_adapter/models/openai.py +210 -0
- agent_adapter/models/usage.py +130 -0
- agent_adapter/optimiser/__init__.py +55 -0
- agent_adapter/optimiser/__main__.py +192 -0
- agent_adapter/optimiser/_budget.py +126 -0
- agent_adapter/optimiser/_fatal.py +119 -0
- agent_adapter/optimiser/_files.py +29 -0
- agent_adapter/optimiser/_hook_surface.py +90 -0
- agent_adapter/optimiser/_outcome.py +99 -0
- agent_adapter/optimiser/_reflection.py +89 -0
- agent_adapter/optimiser/_schema_check.py +3 -0
- agent_adapter/optimiser/_select.py +172 -0
- agent_adapter/optimiser/_stages.py +180 -0
- agent_adapter/optimiser/_state.py +153 -0
- agent_adapter/optimiser/_transcript.py +191 -0
- agent_adapter/optimiser/apply.py +73 -0
- agent_adapter/optimiser/callable_host.py +194 -0
- agent_adapter/optimiser/cases.py +3 -0
- agent_adapter/optimiser/compose.py +348 -0
- agent_adapter/optimiser/evidence.py +117 -0
- agent_adapter/optimiser/graders.py +26 -0
- agent_adapter/optimiser/hosts.py +352 -0
- agent_adapter/optimiser/lessons.py +215 -0
- agent_adapter/optimiser/loop.py +362 -0
- agent_adapter/optimiser/model.py +265 -0
- agent_adapter/optimiser/probe.py +245 -0
- agent_adapter/optimiser/prompts.py +256 -0
- agent_adapter/optimiser/propose.py +164 -0
- agent_adapter/optimiser/report.py +217 -0
- agent_adapter/optimiser/surface.py +172 -0
- agent_adapter/policy/__init__.py +95 -0
- agent_adapter/policy/_build.py +146 -0
- agent_adapter/policy/_hooks.py +143 -0
- agent_adapter/policy/_load.py +249 -0
- agent_adapter/policy/_scope.py +76 -0
- agent_adapter/policy/condition.py +229 -0
- agent_adapter/policy/errors.py +26 -0
- agent_adapter/policy/explain.py +89 -0
- agent_adapter/policy/model.py +198 -0
- agent_adapter/policy/policy.py +303 -0
- agent_adapter/py.typed +0 -0
- agent_adapter/retrieval/__init__.py +34 -0
- agent_adapter/retrieval/_base.py +171 -0
- agent_adapter/retrieval/callable.py +63 -0
- agent_adapter/retrieval/documents.py +171 -0
- agent_adapter/retrieval/embedding.py +158 -0
- agent_adapter/retrieval/langchain.py +79 -0
- agent_adapter/retrieval/llamaindex.py +107 -0
- agent_adapter/retrieval/port.py +22 -0
- agent_adapter/retrieval/tool.py +120 -0
- agent_adapter/runtime/__init__.py +9 -0
- agent_adapter/runtime/_fork.py +46 -0
- agent_adapter/runtime/current.py +38 -0
- agent_adapter/runtime/ids.py +25 -0
- agent_adapter/runtime/loop_local.py +131 -0
- agent_adapter/runtime/loop_runner.py +303 -0
- agent_adapter/runtime/sync.py +102 -0
- agent_adapter/sandbox/__init__.py +35 -0
- agent_adapter/sandbox/_base.py +293 -0
- agent_adapter/sandbox/_bootstrap.py +238 -0
- agent_adapter/sandbox/_checks.py +190 -0
- agent_adapter/sandbox/_process.py +112 -0
- agent_adapter/sandbox/_protocol.py +97 -0
- agent_adapter/sandbox/callable.py +98 -0
- agent_adapter/sandbox/docker.py +232 -0
- agent_adapter/sandbox/local.py +124 -0
- agent_adapter/sandbox/port.py +84 -0
- agent_adapter/sandbox/tool.py +198 -0
- agent_adapter/schema/__init__.py +1 -0
- agent_adapter/schema/_names.py +30 -0
- agent_adapter/schema/models.py +125 -0
- agent_adapter/schema/portable.py +99 -0
- agent_adapter/schema/transforms.py +165 -0
- agent_adapter/server/__init__.py +56 -0
- agent_adapter/server/__main__.py +141 -0
- agent_adapter/server/_approval.py +68 -0
- agent_adapter/server/_budget.py +56 -0
- agent_adapter/server/_calls.py +363 -0
- agent_adapter/server/_health.py +54 -0
- agent_adapter/server/_hosts.py +131 -0
- agent_adapter/server/_idempotency.py +174 -0
- agent_adapter/server/_openapi30.py +333 -0
- agent_adapter/server/_payloads.py +186 -0
- agent_adapter/server/_reads.py +123 -0
- agent_adapter/server/_runs.py +81 -0
- agent_adapter/server/_sse.py +147 -0
- agent_adapter/server/_state.py +164 -0
- agent_adapter/server/asgi.py +361 -0
- agent_adapter/server/auth.py +178 -0
- agent_adapter/server/events.py +120 -0
- agent_adapter/server/idempotency.py +248 -0
- agent_adapter/server/openapi.py +371 -0
- agent_adapter/server/problems.py +93 -0
- agent_adapter/server/service.py +380 -0
- agent_adapter/server/wsgi.py +330 -0
- agent_adapter/tracing/__init__.py +26 -0
- agent_adapter/tracing/_content.py +87 -0
- agent_adapter/tracing/_genai.py +255 -0
- agent_adapter/tracing/events.py +252 -0
- agent_adapter/tracing/otel.py +358 -0
- agent_adapter/tracing/semconv.py +84 -0
- agent_adapter/tracing/sinks.py +184 -0
- agent_adapter/viewer/__init__.py +35 -0
- agent_adapter/viewer/_case_routes.py +133 -0
- agent_adapter/viewer/_drain.py +26 -0
- agent_adapter/viewer/_evals.py +244 -0
- agent_adapter/viewer/_files.py +158 -0
- agent_adapter/viewer/_fold.py +166 -0
- agent_adapter/viewer/_otlp_import.py +162 -0
- agent_adapter/viewer/_otlp_spans.py +184 -0
- agent_adapter/viewer/_runs_routes.py +154 -0
- agent_adapter/viewer/_scrub.py +118 -0
- agent_adapter/viewer/_search.py +112 -0
- agent_adapter/viewer/_segments.py +177 -0
- agent_adapter/viewer/_tags.py +163 -0
- agent_adapter/viewer/approvals.py +112 -0
- agent_adapter/viewer/assets.py +159 -0
- agent_adapter/viewer/chat/__init__.py +19 -0
- agent_adapter/viewer/chat/agent_task.py +30 -0
- agent_adapter/viewer/chat/approval_history.py +83 -0
- agent_adapter/viewer/chat/approvals.py +242 -0
- agent_adapter/viewer/chat/builtin.py +174 -0
- agent_adapter/viewer/chat/contract.py +7 -0
- agent_adapter/viewer/chat/evalcases.py +161 -0
- agent_adapter/viewer/chat/files.py +151 -0
- agent_adapter/viewer/chat/host.py +388 -0
- agent_adapter/viewer/chat/invoke.py +60 -0
- agent_adapter/viewer/chat/live.py +208 -0
- agent_adapter/viewer/chat/memory.py +215 -0
- agent_adapter/viewer/chat/memory_routes.py +60 -0
- agent_adapter/viewer/chat/memory_turns.py +82 -0
- agent_adapter/viewer/chat/records.py +162 -0
- agent_adapter/viewer/chat/routes.py +299 -0
- agent_adapter/viewer/chat/sessions.py +231 -0
- agent_adapter/viewer/chat/settle.py +112 -0
- agent_adapter/viewer/chat/setup.py +199 -0
- agent_adapter/viewer/chat/stream.py +57 -0
- agent_adapter/viewer/chat/targets.py +40 -0
- agent_adapter/viewer/chat/turn_io.py +111 -0
- agent_adapter/viewer/chat/watch.py +102 -0
- agent_adapter/viewer/export.py +47 -0
- agent_adapter/viewer/lanes.py +205 -0
- agent_adapter/viewer/launch.py +74 -0
- agent_adapter/viewer/layout.py +236 -0
- agent_adapter/viewer/recorder.py +339 -0
- agent_adapter/viewer/runs.py +256 -0
- agent_adapter/viewer/server.py +425 -0
- agent_adapter/viewer/serving.py +199 -0
- agent_adapter/viewer/static/app.js +339 -0
- agent_adapter/viewer/static/chat.css +152 -0
- agent_adapter/viewer/static/chat.js +370 -0
- agent_adapter/viewer/static/chatapi.js +229 -0
- agent_adapter/viewer/static/chatcards.js +321 -0
- agent_adapter/viewer/static/chatcomposer.js +150 -0
- agent_adapter/viewer/static/chatdemo.js +323 -0
- agent_adapter/viewer/static/chatextras.js +271 -0
- agent_adapter/viewer/static/chatmemory.js +107 -0
- agent_adapter/viewer/static/chatsessions.js +57 -0
- agent_adapter/viewer/static/compare.js +254 -0
- agent_adapter/viewer/static/data.js +213 -0
- agent_adapter/viewer/static/evals.css +29 -0
- agent_adapter/viewer/static/evals.js +113 -0
- agent_adapter/viewer/static/evalscards.js +136 -0
- agent_adapter/viewer/static/evalsview.js +233 -0
- agent_adapter/viewer/static/events.js +160 -0
- agent_adapter/viewer/static/favicon.svg +1 -0
- agent_adapter/viewer/static/graph.css +109 -0
- agent_adapter/viewer/static/graph.js +271 -0
- agent_adapter/viewer/static/graphbar.js +315 -0
- agent_adapter/viewer/static/graphlive.js +263 -0
- agent_adapter/viewer/static/graphnav.js +237 -0
- agent_adapter/viewer/static/index.html +138 -0
- agent_adapter/viewer/static/inspector.js +245 -0
- agent_adapter/viewer/static/markdown.js +356 -0
- agent_adapter/viewer/static/panels.js +227 -0
- agent_adapter/viewer/static/runcases.js +116 -0
- agent_adapter/viewer/static/runsearch.js +112 -0
- agent_adapter/viewer/static/statepanel.js +154 -0
- agent_adapter/viewer/static/tabs.css +37 -0
- agent_adapter/viewer/static/timeline.js +99 -0
- agent_adapter/viewer/static/viewer.css +159 -0
- agent_adapter/viewer/static/views.js +89 -0
- agent_adapter-1.1.0.dist-info/METADATA +285 -0
- agent_adapter-1.1.0.dist-info/RECORD +591 -0
- agent_adapter-1.1.0.dist-info/WHEEL +4 -0
- agent_adapter-1.1.0.dist-info/entry_points.txt +29 -0
- agent_adapter-1.1.0.dist-info/licenses/LICENSE +202 -0
- agent_adapter-1.1.0.dist-info/licenses/NOTICE +4 -0
|
@@ -0,0 +1,375 @@
|
|
|
1
|
+
"""Agent Adapter: framework-independent tools, parallel execution and flows for LLM agents.
|
|
2
|
+
|
|
3
|
+
Names load on first use (PEP 562), so `import agent_adapter` stays cheap. Every other
|
|
4
|
+
public name lives in its home subpackage: errors in `agent_adapter.errors`, the rest in
|
|
5
|
+
`agent_adapter.exec`, `.approval`, `.hooks`, `.cost`, `.cache`, `.flow` and so on.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from agent_adapter._version import __version__
|
|
9
|
+
|
|
10
|
+
# Not `typing.TYPE_CHECKING`: importing typing would triple the import cost. Type checkers
|
|
11
|
+
# treat any constant named TYPE_CHECKING as true.
|
|
12
|
+
TYPE_CHECKING = False
|
|
13
|
+
|
|
14
|
+
if TYPE_CHECKING:
|
|
15
|
+
from pathlib import Path
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
from agent_adapter.approval.builtin import AutoApprove, AutoDeny, CallbackApproval
|
|
19
|
+
from agent_adapter.approval.deferred import DeferredApproval
|
|
20
|
+
from agent_adapter.approval.redis_store import RedisApprovalStore
|
|
21
|
+
from agent_adapter.approval.sqlite_store import SQLiteApprovalStore
|
|
22
|
+
from agent_adapter.approval.store import MemoryApprovalStore
|
|
23
|
+
from agent_adapter.cache.memory import MemoryCache
|
|
24
|
+
from agent_adapter.core._default import default_registry, tool, wrap
|
|
25
|
+
from agent_adapter.core.context import ToolContext
|
|
26
|
+
from agent_adapter.core.errors import (
|
|
27
|
+
AdapterError,
|
|
28
|
+
ApprovalDenied,
|
|
29
|
+
ApprovalPending,
|
|
30
|
+
MissingDependency,
|
|
31
|
+
ToolError,
|
|
32
|
+
)
|
|
33
|
+
from agent_adapter.core.imported import spec_from_schema
|
|
34
|
+
from agent_adapter.core.messages import LLMRequest, LLMResponse, Message, ToolDef
|
|
35
|
+
from agent_adapter.core.registry import Registry
|
|
36
|
+
from agent_adapter.core.tool import ToolSpec, build_spec
|
|
37
|
+
from agent_adapter.core.types import (
|
|
38
|
+
ApprovalDecision,
|
|
39
|
+
ApprovalRequest,
|
|
40
|
+
Decision,
|
|
41
|
+
Event,
|
|
42
|
+
LedgerEntry,
|
|
43
|
+
ToolCall,
|
|
44
|
+
ToolResult,
|
|
45
|
+
Usage,
|
|
46
|
+
)
|
|
47
|
+
from agent_adapter.cost.ledger import Ledger
|
|
48
|
+
from agent_adapter.cost.prices import Prices
|
|
49
|
+
from agent_adapter.exec.defaults import acall, call, configure, set_default_executor
|
|
50
|
+
from agent_adapter.exec.executor import Executor
|
|
51
|
+
from agent_adapter.exec.guards import RunLimits
|
|
52
|
+
from agent_adapter.exec.plan import Step
|
|
53
|
+
from agent_adapter.exec.tool_loop import run_tool_loop
|
|
54
|
+
from agent_adapter.flow.runner import FlowRunner
|
|
55
|
+
from agent_adapter.flow.spec import Flow
|
|
56
|
+
from agent_adapter.hooks.base import Hook
|
|
57
|
+
from agent_adapter.hooks.builtin.budget import BudgetHook
|
|
58
|
+
from agent_adapter.hooks.builtin.guardrail import GuardrailHook
|
|
59
|
+
from agent_adapter.hooks.builtin.logging import LoggingHook
|
|
60
|
+
from agent_adapter.hooks.builtin.rate_limit import RateLimitHook
|
|
61
|
+
from agent_adapter.integrations._attach import attach
|
|
62
|
+
from agent_adapter.models.callable import CallableModel
|
|
63
|
+
from agent_adapter.models.fallback import FallbackModel
|
|
64
|
+
from agent_adapter.runtime.sync import run_sync
|
|
65
|
+
|
|
66
|
+
# name -> module that defines it; kept in step with the TYPE_CHECKING block by tests.
|
|
67
|
+
_LAZY: dict[str, str] = {
|
|
68
|
+
# Tools
|
|
69
|
+
"Registry": "agent_adapter.core.registry",
|
|
70
|
+
"ToolSpec": "agent_adapter.core.tool",
|
|
71
|
+
"build_spec": "agent_adapter.core.tool",
|
|
72
|
+
"spec_from_schema": "agent_adapter.core.imported",
|
|
73
|
+
"ToolContext": "agent_adapter.core.context",
|
|
74
|
+
"ToolCall": "agent_adapter.core.types",
|
|
75
|
+
"ToolResult": "agent_adapter.core.types",
|
|
76
|
+
"Usage": "agent_adapter.core.types",
|
|
77
|
+
# Running
|
|
78
|
+
"Executor": "agent_adapter.exec.executor",
|
|
79
|
+
"RunLimits": "agent_adapter.exec.guards",
|
|
80
|
+
"Step": "agent_adapter.exec.plan",
|
|
81
|
+
"run_tool_loop": "agent_adapter.exec.tool_loop",
|
|
82
|
+
"run_sync": "agent_adapter.runtime.sync",
|
|
83
|
+
"set_default_executor": "agent_adapter.exec.defaults",
|
|
84
|
+
"configure": "agent_adapter.exec.defaults",
|
|
85
|
+
"call": "agent_adapter.exec.defaults",
|
|
86
|
+
"acall": "agent_adapter.exec.defaults",
|
|
87
|
+
"attach": "agent_adapter.integrations._attach",
|
|
88
|
+
# Approval
|
|
89
|
+
"AutoApprove": "agent_adapter.approval.builtin",
|
|
90
|
+
"AutoDeny": "agent_adapter.approval.builtin",
|
|
91
|
+
"CallbackApproval": "agent_adapter.approval.builtin",
|
|
92
|
+
"DeferredApproval": "agent_adapter.approval.deferred",
|
|
93
|
+
"ApprovalRequest": "agent_adapter.core.types",
|
|
94
|
+
"ApprovalDecision": "agent_adapter.core.types",
|
|
95
|
+
"Decision": "agent_adapter.core.types",
|
|
96
|
+
"MemoryApprovalStore": "agent_adapter.approval.store",
|
|
97
|
+
"SQLiteApprovalStore": "agent_adapter.approval.sqlite_store",
|
|
98
|
+
"RedisApprovalStore": "agent_adapter.approval.redis_store",
|
|
99
|
+
# Hooks, cost, cache
|
|
100
|
+
"Hook": "agent_adapter.hooks.base",
|
|
101
|
+
"LoggingHook": "agent_adapter.hooks.builtin.logging",
|
|
102
|
+
"GuardrailHook": "agent_adapter.hooks.builtin.guardrail",
|
|
103
|
+
"BudgetHook": "agent_adapter.hooks.builtin.budget",
|
|
104
|
+
"RateLimitHook": "agent_adapter.hooks.builtin.rate_limit",
|
|
105
|
+
"Ledger": "agent_adapter.cost.ledger",
|
|
106
|
+
"LedgerEntry": "agent_adapter.core.types",
|
|
107
|
+
"Prices": "agent_adapter.cost.prices",
|
|
108
|
+
"MemoryCache": "agent_adapter.cache.memory",
|
|
109
|
+
# Flows
|
|
110
|
+
"Flow": "agent_adapter.flow.spec",
|
|
111
|
+
"FlowRunner": "agent_adapter.flow.runner",
|
|
112
|
+
# Model messages
|
|
113
|
+
"LLMRequest": "agent_adapter.core.messages",
|
|
114
|
+
"LLMResponse": "agent_adapter.core.messages",
|
|
115
|
+
"Message": "agent_adapter.core.messages",
|
|
116
|
+
"ToolDef": "agent_adapter.core.messages",
|
|
117
|
+
"Event": "agent_adapter.core.types",
|
|
118
|
+
# Model ports that need no extra
|
|
119
|
+
"CallableModel": "agent_adapter.models.callable",
|
|
120
|
+
"FallbackModel": "agent_adapter.models.fallback",
|
|
121
|
+
# Errors (the five most caught; the rest are in agent_adapter.errors)
|
|
122
|
+
"AdapterError": "agent_adapter.core.errors",
|
|
123
|
+
"ToolError": "agent_adapter.core.errors",
|
|
124
|
+
"ApprovalDenied": "agent_adapter.core.errors",
|
|
125
|
+
"ApprovalPending": "agent_adapter.core.errors",
|
|
126
|
+
"MissingDependency": "agent_adapter.core.errors",
|
|
127
|
+
# The default registry, created on first access
|
|
128
|
+
"default_registry": "agent_adapter.core._default",
|
|
129
|
+
"tool": "agent_adapter.core._default",
|
|
130
|
+
"wrap": "agent_adapter.core._default",
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
# Names that left the top level in 1.0 -> their public home.
|
|
134
|
+
_MOVED: dict[str, str] = {
|
|
135
|
+
**dict.fromkeys(
|
|
136
|
+
(
|
|
137
|
+
"ApprovalAlreadyDecided",
|
|
138
|
+
"ApprovalNotFound",
|
|
139
|
+
"AuthError",
|
|
140
|
+
"BudgetExceeded",
|
|
141
|
+
"ConfigError",
|
|
142
|
+
"DuplicateTool",
|
|
143
|
+
"ErrorInfo",
|
|
144
|
+
"FlowCompileError",
|
|
145
|
+
"FlowDefinitionError",
|
|
146
|
+
"FlowError",
|
|
147
|
+
"FlowLoopExceeded",
|
|
148
|
+
"Forbidden",
|
|
149
|
+
"GuardrailBlocked",
|
|
150
|
+
"IntegrationError",
|
|
151
|
+
"ModelAuthError",
|
|
152
|
+
"ModelBadRequest",
|
|
153
|
+
"ModelContentFiltered",
|
|
154
|
+
"ModelContextOverflow",
|
|
155
|
+
"ModelError",
|
|
156
|
+
"ModelOutputInvalid",
|
|
157
|
+
"ModelRateLimited",
|
|
158
|
+
"ModelTimeout",
|
|
159
|
+
"ModelUnavailable",
|
|
160
|
+
"OptimiserError",
|
|
161
|
+
"PlanInvalid",
|
|
162
|
+
"RunLimitExceeded",
|
|
163
|
+
"SchemaNotPortable",
|
|
164
|
+
"ToolArgsInvalid",
|
|
165
|
+
"ToolDefinitionError",
|
|
166
|
+
"ToolFailed",
|
|
167
|
+
"ToolNotFound",
|
|
168
|
+
"ToolTimeout",
|
|
169
|
+
"ToolUsageError",
|
|
170
|
+
"Unauthorized",
|
|
171
|
+
),
|
|
172
|
+
"agent_adapter.errors",
|
|
173
|
+
),
|
|
174
|
+
"ShortCircuit": "agent_adapter.hooks",
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Subpackages reachable as attributes after a bare `import agent_adapter`.
|
|
178
|
+
_SUBPACKAGES = frozenset(
|
|
179
|
+
{
|
|
180
|
+
"approval",
|
|
181
|
+
"audit",
|
|
182
|
+
"cache",
|
|
183
|
+
"chat",
|
|
184
|
+
"cli",
|
|
185
|
+
"context",
|
|
186
|
+
"core",
|
|
187
|
+
"cost",
|
|
188
|
+
"embeddings",
|
|
189
|
+
"evals",
|
|
190
|
+
"handlers",
|
|
191
|
+
"errors",
|
|
192
|
+
"exec",
|
|
193
|
+
"flow",
|
|
194
|
+
"hooks",
|
|
195
|
+
"integrations",
|
|
196
|
+
"memory",
|
|
197
|
+
"models",
|
|
198
|
+
"optimiser",
|
|
199
|
+
"policy",
|
|
200
|
+
"retrieval",
|
|
201
|
+
"runtime",
|
|
202
|
+
"sandbox",
|
|
203
|
+
"schema",
|
|
204
|
+
"server",
|
|
205
|
+
"tracing",
|
|
206
|
+
"viewer",
|
|
207
|
+
}
|
|
208
|
+
)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _getattr(name: str) -> "Any":
|
|
212
|
+
"""Load a public name or a subpackage on first access; explain names that moved."""
|
|
213
|
+
import importlib
|
|
214
|
+
|
|
215
|
+
if name in _LAZY:
|
|
216
|
+
value = getattr(importlib.import_module(_LAZY[name]), name)
|
|
217
|
+
elif name in _SUBPACKAGES:
|
|
218
|
+
value = importlib.import_module(f"{__name__}.{name}")
|
|
219
|
+
elif name in _MOVED:
|
|
220
|
+
message = f"{name} moved: from {_MOVED[name]} import {name}"
|
|
221
|
+
if _in_from_import(): # `from x import y` would replace an AttributeError's text
|
|
222
|
+
raise ImportError(message, name=__name__)
|
|
223
|
+
raise AttributeError(message, name=name)
|
|
224
|
+
else:
|
|
225
|
+
hint = _hint(name)
|
|
226
|
+
if hint and _in_from_import():
|
|
227
|
+
raise ImportError(f"cannot import name {name!r} from {__name__!r}; {hint}", name=name)
|
|
228
|
+
raise AttributeError(
|
|
229
|
+
f"module {__name__!r} has no attribute {name!r}; "
|
|
230
|
+
+ (hint or "see agent_adapter.__all__ for the top-level names"),
|
|
231
|
+
name=name,
|
|
232
|
+
)
|
|
233
|
+
globals()[name] = value # later lookups skip __getattr__
|
|
234
|
+
return value
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
def _hint(name: str) -> str:
|
|
238
|
+
"""Where a missing name lives, or the close top-level name; "" when nothing fits."""
|
|
239
|
+
if name.startswith("_"):
|
|
240
|
+
return "" # dunder probes (copy, pickle, IDEs) stay cheap
|
|
241
|
+
homes = _homes().get(name)
|
|
242
|
+
if homes:
|
|
243
|
+
return f"it lives in {', '.join(homes)}: from {homes[0]} import {name}"
|
|
244
|
+
import difflib
|
|
245
|
+
|
|
246
|
+
close = difflib.get_close_matches(name, [*__all__, *_MOVED], n=1, cutoff=0.8)
|
|
247
|
+
if close:
|
|
248
|
+
return f"did you mean {close[0]!r}? see agent_adapter.__all__ for the top-level names"
|
|
249
|
+
return ""
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
_HOMES: "dict[str, list[str]] | None" = None
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
def _homes() -> "dict[str, list[str]]":
|
|
256
|
+
"""Name -> public modules that export it, read from the package source (no imports)."""
|
|
257
|
+
global _HOMES
|
|
258
|
+
if _HOMES is None:
|
|
259
|
+
from pathlib import Path
|
|
260
|
+
|
|
261
|
+
root = Path(__file__).parent
|
|
262
|
+
files = [*root.glob("*/__init__.py"), *root.glob("integrations/*/__init__.py")]
|
|
263
|
+
files += [p for p in root.glob("integrations/*.py") if not p.name.startswith("_")]
|
|
264
|
+
homes: dict[str, list[str]] = {}
|
|
265
|
+
for path in sorted(files):
|
|
266
|
+
parts = path.relative_to(root.parent).with_suffix("").parts
|
|
267
|
+
module = ".".join(parts[:-1] if parts[-1] == "__init__" else parts)
|
|
268
|
+
for exported in _exports(path):
|
|
269
|
+
if exported not in _LAZY:
|
|
270
|
+
homes.setdefault(exported, []).append(module)
|
|
271
|
+
_HOMES = homes
|
|
272
|
+
return _HOMES
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
def _exports(path: "Path") -> "tuple[str, ...]":
|
|
276
|
+
"""The literal `__all__` of a source file; () when unreadable or not a literal."""
|
|
277
|
+
import ast
|
|
278
|
+
|
|
279
|
+
try:
|
|
280
|
+
tree = ast.parse(path.read_text(encoding="utf-8"))
|
|
281
|
+
except (OSError, SyntaxError, UnicodeDecodeError):
|
|
282
|
+
return ()
|
|
283
|
+
for node in tree.body:
|
|
284
|
+
if isinstance(node, ast.Assign) and any(
|
|
285
|
+
isinstance(target, ast.Name) and target.id == "__all__" for target in node.targets
|
|
286
|
+
):
|
|
287
|
+
try:
|
|
288
|
+
names = ast.literal_eval(node.value)
|
|
289
|
+
except ValueError:
|
|
290
|
+
return ()
|
|
291
|
+
return tuple(n for n in names if isinstance(n, str))
|
|
292
|
+
return ()
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def _in_from_import() -> bool:
|
|
296
|
+
"""True when the code that triggered `__getattr__` runs `from agent_adapter import ...`."""
|
|
297
|
+
import opcode
|
|
298
|
+
import sys
|
|
299
|
+
|
|
300
|
+
try:
|
|
301
|
+
frame = sys._getframe(3) # 0: here, 1: _getattr, 2: __getattr__, 3: the importer
|
|
302
|
+
return frame.f_code.co_code[frame.f_lasti] == opcode.opmap["IMPORT_FROM"]
|
|
303
|
+
except (AttributeError, IndexError, KeyError, ValueError):
|
|
304
|
+
return False # no CPython frames: the AttributeError message still applies
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
if not TYPE_CHECKING: # hidden from type checkers, so an unknown name stays a type error
|
|
308
|
+
|
|
309
|
+
def __getattr__(name: str) -> "Any":
|
|
310
|
+
"""PEP 562 hook: see `_getattr`."""
|
|
311
|
+
return _getattr(name)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
def __dir__() -> list[str]:
|
|
315
|
+
"""The public names plus any subpackage already loaded."""
|
|
316
|
+
return sorted({*__all__, *(name for name in globals() if name in _SUBPACKAGES)})
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
__all__ = [
|
|
320
|
+
"AdapterError",
|
|
321
|
+
"ApprovalDecision",
|
|
322
|
+
"ApprovalDenied",
|
|
323
|
+
"ApprovalPending",
|
|
324
|
+
"ApprovalRequest",
|
|
325
|
+
"AutoApprove",
|
|
326
|
+
"AutoDeny",
|
|
327
|
+
"BudgetHook",
|
|
328
|
+
"CallableModel",
|
|
329
|
+
"CallbackApproval",
|
|
330
|
+
"Decision",
|
|
331
|
+
"DeferredApproval",
|
|
332
|
+
"Event",
|
|
333
|
+
"Executor",
|
|
334
|
+
"FallbackModel",
|
|
335
|
+
"Flow",
|
|
336
|
+
"FlowRunner",
|
|
337
|
+
"GuardrailHook",
|
|
338
|
+
"Hook",
|
|
339
|
+
"LLMRequest",
|
|
340
|
+
"LLMResponse",
|
|
341
|
+
"Ledger",
|
|
342
|
+
"LedgerEntry",
|
|
343
|
+
"LoggingHook",
|
|
344
|
+
"MemoryApprovalStore",
|
|
345
|
+
"MemoryCache",
|
|
346
|
+
"Message",
|
|
347
|
+
"MissingDependency",
|
|
348
|
+
"Prices",
|
|
349
|
+
"RateLimitHook",
|
|
350
|
+
"RedisApprovalStore",
|
|
351
|
+
"Registry",
|
|
352
|
+
"RunLimits",
|
|
353
|
+
"SQLiteApprovalStore",
|
|
354
|
+
"Step",
|
|
355
|
+
"ToolCall",
|
|
356
|
+
"ToolContext",
|
|
357
|
+
"ToolDef",
|
|
358
|
+
"ToolError",
|
|
359
|
+
"ToolResult",
|
|
360
|
+
"ToolSpec",
|
|
361
|
+
"Usage",
|
|
362
|
+
"__version__",
|
|
363
|
+
"acall",
|
|
364
|
+
"attach",
|
|
365
|
+
"build_spec",
|
|
366
|
+
"call",
|
|
367
|
+
"configure",
|
|
368
|
+
"default_registry",
|
|
369
|
+
"run_sync",
|
|
370
|
+
"run_tool_loop",
|
|
371
|
+
"set_default_executor",
|
|
372
|
+
"spec_from_schema",
|
|
373
|
+
"tool",
|
|
374
|
+
"wrap",
|
|
375
|
+
]
|