agent_os_kernel 3.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_control_plane/__init__.py +662 -0
- agent_control_plane/a2a_adapter.py +543 -0
- agent_control_plane/adapter.py +417 -0
- agent_control_plane/agent_hibernation.py +394 -0
- agent_control_plane/agent_kernel.py +470 -0
- agent_control_plane/compliance.py +720 -0
- agent_control_plane/constraint_graphs.py +478 -0
- agent_control_plane/control_plane.py +854 -0
- agent_control_plane/example_executors.py +195 -0
- agent_control_plane/execution_engine.py +231 -0
- agent_control_plane/flight_recorder.py +846 -0
- agent_control_plane/governance_layer.py +435 -0
- agent_control_plane/hf_utils.py +563 -0
- agent_control_plane/interfaces/__init__.py +55 -0
- agent_control_plane/interfaces/kernel_interface.py +361 -0
- agent_control_plane/interfaces/plugin_interface.py +497 -0
- agent_control_plane/interfaces/protocol_interfaces.py +387 -0
- agent_control_plane/kernel_space.py +1009 -0
- agent_control_plane/langchain_adapter.py +424 -0
- agent_control_plane/lifecycle.py +3113 -0
- agent_control_plane/mcp_adapter.py +653 -0
- agent_control_plane/ml_safety.py +563 -0
- agent_control_plane/multimodal.py +727 -0
- agent_control_plane/mute_agent.py +422 -0
- agent_control_plane/observability.py +787 -0
- agent_control_plane/orchestrator.py +482 -0
- agent_control_plane/plugin_registry.py +750 -0
- agent_control_plane/policy_engine.py +954 -0
- agent_control_plane/process_isolation.py +777 -0
- agent_control_plane/shadow_mode.py +310 -0
- agent_control_plane/signals.py +493 -0
- agent_control_plane/supervisor_agents.py +430 -0
- agent_control_plane/time_travel_debugger.py +557 -0
- agent_control_plane/tool_registry.py +452 -0
- agent_control_plane/vfs.py +697 -0
- agent_kernel/__init__.py +69 -0
- agent_kernel/analyzer.py +435 -0
- agent_kernel/auditor.py +36 -0
- agent_kernel/completeness_auditor.py +237 -0
- agent_kernel/detector.py +203 -0
- agent_kernel/kernel.py +744 -0
- agent_kernel/memory_manager.py +85 -0
- agent_kernel/models.py +374 -0
- agent_kernel/nudge_mechanism.py +263 -0
- agent_kernel/outcome_analyzer.py +338 -0
- agent_kernel/patcher.py +582 -0
- agent_kernel/semantic_analyzer.py +316 -0
- agent_kernel/semantic_purge.py +349 -0
- agent_kernel/simulator.py +449 -0
- agent_kernel/teacher.py +85 -0
- agent_kernel/triage.py +152 -0
- agent_os/__init__.py +409 -0
- agent_os/_adversarial_impl.py +200 -0
- agent_os/_circuit_breaker_impl.py +232 -0
- agent_os/_mcp_metrics.py +193 -0
- agent_os/adversarial.py +20 -0
- agent_os/agents_compat.py +490 -0
- agent_os/audit_logger.py +135 -0
- agent_os/base_agent.py +651 -0
- agent_os/circuit_breaker.py +34 -0
- agent_os/cli/__init__.py +659 -0
- agent_os/cli/cmd_audit.py +128 -0
- agent_os/cli/cmd_init.py +152 -0
- agent_os/cli/cmd_policy.py +41 -0
- agent_os/cli/cmd_policy_gen.py +180 -0
- agent_os/cli/cmd_validate.py +258 -0
- agent_os/cli/mcp_scan.py +265 -0
- agent_os/cli/output.py +192 -0
- agent_os/cli/policy_checker.py +330 -0
- agent_os/compat.py +74 -0
- agent_os/constraint_graph.py +234 -0
- agent_os/content_governance.py +140 -0
- agent_os/context_budget.py +305 -0
- agent_os/credential_redactor.py +224 -0
- agent_os/diff_policy.py +89 -0
- agent_os/egress_policy.py +159 -0
- agent_os/escalation.py +276 -0
- agent_os/event_bus.py +124 -0
- agent_os/exceptions.py +180 -0
- agent_os/execution_context_policy.py +141 -0
- agent_os/github_enterprise.py +96 -0
- agent_os/health.py +20 -0
- agent_os/integrations/__init__.py +279 -0
- agent_os/integrations/a2a_adapter.py +279 -0
- agent_os/integrations/agent_lightning/__init__.py +30 -0
- agent_os/integrations/anthropic_adapter.py +420 -0
- agent_os/integrations/autogen_adapter.py +620 -0
- agent_os/integrations/base.py +1137 -0
- agent_os/integrations/compat.py +229 -0
- agent_os/integrations/config.py +98 -0
- agent_os/integrations/conversation_guardian.py +957 -0
- agent_os/integrations/crewai_adapter.py +467 -0
- agent_os/integrations/drift_detector.py +425 -0
- agent_os/integrations/dry_run.py +124 -0
- agent_os/integrations/escalation.py +582 -0
- agent_os/integrations/gemini_adapter.py +364 -0
- agent_os/integrations/google_adk_adapter.py +633 -0
- agent_os/integrations/guardrails_adapter.py +394 -0
- agent_os/integrations/health.py +197 -0
- agent_os/integrations/langchain_adapter.py +654 -0
- agent_os/integrations/llamafirewall.py +343 -0
- agent_os/integrations/llamaindex_adapter.py +188 -0
- agent_os/integrations/logging.py +191 -0
- agent_os/integrations/maf_adapter.py +631 -0
- agent_os/integrations/mistral_adapter.py +365 -0
- agent_os/integrations/openai_adapter.py +816 -0
- agent_os/integrations/openai_agents_sdk.py +406 -0
- agent_os/integrations/policy_compose.py +171 -0
- agent_os/integrations/profiling.py +144 -0
- agent_os/integrations/pydantic_ai_adapter.py +420 -0
- agent_os/integrations/rate_limiter.py +130 -0
- agent_os/integrations/rbac.py +143 -0
- agent_os/integrations/registry.py +113 -0
- agent_os/integrations/scope_guard.py +303 -0
- agent_os/integrations/semantic_kernel_adapter.py +769 -0
- agent_os/integrations/smolagents_adapter.py +629 -0
- agent_os/integrations/templates.py +178 -0
- agent_os/integrations/token_budget.py +134 -0
- agent_os/integrations/tool_aliases.py +190 -0
- agent_os/integrations/webhooks.py +177 -0
- agent_os/lite.py +208 -0
- agent_os/mcp_gateway.py +385 -0
- agent_os/mcp_message_signer.py +273 -0
- agent_os/mcp_protocols.py +161 -0
- agent_os/mcp_response_scanner.py +232 -0
- agent_os/mcp_security.py +924 -0
- agent_os/mcp_session_auth.py +231 -0
- agent_os/mcp_sliding_rate_limiter.py +184 -0
- agent_os/memory_guard.py +409 -0
- agent_os/metrics.py +134 -0
- agent_os/mute.py +428 -0
- agent_os/mute_agent.py +209 -0
- agent_os/policies/__init__.py +77 -0
- agent_os/policies/async_evaluator.py +275 -0
- agent_os/policies/backends.py +670 -0
- agent_os/policies/bridge.py +169 -0
- agent_os/policies/budget.py +85 -0
- agent_os/policies/cli.py +294 -0
- agent_os/policies/conflict_resolution.py +270 -0
- agent_os/policies/data_classification.py +252 -0
- agent_os/policies/evaluator.py +239 -0
- agent_os/policies/policy_schema.json +228 -0
- agent_os/policies/rate_limiting.py +145 -0
- agent_os/policies/schema.py +115 -0
- agent_os/policies/shared.py +331 -0
- agent_os/prompt_injection.py +694 -0
- agent_os/providers.py +182 -0
- agent_os/py.typed +0 -0
- agent_os/retry.py +81 -0
- agent_os/reversibility.py +251 -0
- agent_os/sandbox.py +432 -0
- agent_os/sandbox_provider.py +140 -0
- agent_os/secure_codegen.py +525 -0
- agent_os/security_skills.py +538 -0
- agent_os/semantic_policy.py +422 -0
- agent_os/server/__init__.py +15 -0
- agent_os/server/__main__.py +25 -0
- agent_os/server/app.py +277 -0
- agent_os/server/models.py +104 -0
- agent_os/shift_left_metrics.py +130 -0
- agent_os/stateless.py +742 -0
- agent_os/supervisor.py +148 -0
- agent_os/task_outcome.py +148 -0
- agent_os/transparency.py +181 -0
- agent_os/trust_root.py +128 -0
- agent_os_kernel-3.1.0.dist-info/METADATA +1269 -0
- agent_os_kernel-3.1.0.dist-info/RECORD +337 -0
- agent_os_kernel-3.1.0.dist-info/WHEEL +4 -0
- agent_os_kernel-3.1.0.dist-info/entry_points.txt +2 -0
- agent_os_kernel-3.1.0.dist-info/licenses/LICENSE +21 -0
- agent_os_observability/__init__.py +27 -0
- agent_os_observability/dashboards.py +898 -0
- agent_os_observability/metrics.py +398 -0
- agent_os_observability/server.py +223 -0
- agent_os_observability/tracer.py +232 -0
- agent_primitives/__init__.py +24 -0
- agent_primitives/failures.py +84 -0
- agent_primitives/py.typed +0 -0
- amb_core/__init__.py +177 -0
- amb_core/adapters/__init__.py +57 -0
- amb_core/adapters/aws_sqs_broker.py +376 -0
- amb_core/adapters/azure_servicebus_broker.py +340 -0
- amb_core/adapters/kafka_broker.py +260 -0
- amb_core/adapters/nats_broker.py +285 -0
- amb_core/adapters/rabbitmq_broker.py +235 -0
- amb_core/adapters/redis_broker.py +262 -0
- amb_core/broker.py +145 -0
- amb_core/bus.py +481 -0
- amb_core/cloudevents.py +509 -0
- amb_core/dlq.py +345 -0
- amb_core/hf_utils.py +536 -0
- amb_core/memory_broker.py +410 -0
- amb_core/models.py +141 -0
- amb_core/persistence.py +529 -0
- amb_core/schema.py +294 -0
- amb_core/tracing.py +358 -0
- atr/__init__.py +640 -0
- atr/access.py +348 -0
- atr/composition.py +645 -0
- atr/decorator.py +357 -0
- atr/executor.py +384 -0
- atr/health.py +557 -0
- atr/hf_utils.py +449 -0
- atr/injection.py +422 -0
- atr/metrics.py +440 -0
- atr/policies.py +403 -0
- atr/py.typed +2 -0
- atr/registry.py +452 -0
- atr/schema.py +480 -0
- atr/tools/safe/__init__.py +75 -0
- atr/tools/safe/calculator.py +467 -0
- atr/tools/safe/datetime_tool.py +443 -0
- atr/tools/safe/file_reader.py +402 -0
- atr/tools/safe/http_client.py +316 -0
- atr/tools/safe/json_parser.py +374 -0
- atr/tools/safe/text_tool.py +537 -0
- atr/tools/safe/toolkit.py +175 -0
- caas/__init__.py +162 -0
- caas/api/__init__.py +7 -0
- caas/api/server.py +1328 -0
- caas/caching.py +834 -0
- caas/cli.py +210 -0
- caas/conversation.py +223 -0
- caas/decay.py +72 -0
- caas/detection/__init__.py +9 -0
- caas/detection/detector.py +238 -0
- caas/enrichment.py +130 -0
- caas/gateway/__init__.py +27 -0
- caas/gateway/trust_gateway.py +474 -0
- caas/hf_utils.py +479 -0
- caas/ingestion/__init__.py +23 -0
- caas/ingestion/processors.py +253 -0
- caas/ingestion/structure_parser.py +188 -0
- caas/models.py +356 -0
- caas/pragmatic_truth.py +444 -0
- caas/routing/__init__.py +10 -0
- caas/routing/heuristic_router.py +58 -0
- caas/storage/__init__.py +9 -0
- caas/storage/store.py +389 -0
- caas/triad.py +213 -0
- caas/tuning/__init__.py +9 -0
- caas/tuning/tuner.py +329 -0
- caas/vfs/__init__.py +14 -0
- caas/vfs/filesystem.py +452 -0
- cmvk/__init__.py +218 -0
- cmvk/audit.py +402 -0
- cmvk/benchmarks.py +478 -0
- cmvk/constitutional.py +904 -0
- cmvk/hf_utils.py +301 -0
- cmvk/metrics.py +473 -0
- cmvk/profiles.py +300 -0
- cmvk/py.typed +0 -0
- cmvk/types.py +12 -0
- cmvk/verification.py +956 -0
- emk/__init__.py +89 -0
- emk/causal.py +352 -0
- emk/hf_utils.py +421 -0
- emk/indexer.py +83 -0
- emk/py.typed +0 -0
- emk/schema.py +204 -0
- emk/sleep_cycle.py +347 -0
- emk/store.py +281 -0
- iatp/__init__.py +166 -0
- iatp/attestation.py +461 -0
- iatp/cli.py +317 -0
- iatp/hf_utils.py +472 -0
- iatp/ipc_pipes.py +580 -0
- iatp/main.py +412 -0
- iatp/models/__init__.py +447 -0
- iatp/policy_engine.py +337 -0
- iatp/py.typed +2 -0
- iatp/recovery.py +321 -0
- iatp/security/__init__.py +270 -0
- iatp/sidecar/__init__.py +519 -0
- iatp/telemetry/__init__.py +164 -0
- iatp/tests/__init__.py +1 -0
- iatp/tests/test_attestation.py +370 -0
- iatp/tests/test_cli.py +131 -0
- iatp/tests/test_ed25519_attestation.py +211 -0
- iatp/tests/test_models.py +130 -0
- iatp/tests/test_policy_engine.py +347 -0
- iatp/tests/test_recovery.py +281 -0
- iatp/tests/test_security.py +222 -0
- iatp/tests/test_sidecar.py +167 -0
- iatp/tests/test_telemetry.py +175 -0
- mcp_kernel_server/__init__.py +28 -0
- mcp_kernel_server/cli.py +274 -0
- mcp_kernel_server/resources.py +217 -0
- mcp_kernel_server/server.py +564 -0
- mcp_kernel_server/tools.py +1174 -0
- mute_agent/__init__.py +68 -0
- mute_agent/core/__init__.py +1 -0
- mute_agent/core/execution_agent.py +166 -0
- mute_agent/core/handshake_protocol.py +201 -0
- mute_agent/core/reasoning_agent.py +238 -0
- mute_agent/knowledge_graph/__init__.py +1 -0
- mute_agent/knowledge_graph/graph_elements.py +65 -0
- mute_agent/knowledge_graph/multidimensional_graph.py +170 -0
- mute_agent/knowledge_graph/subgraph.py +224 -0
- mute_agent/listener/__init__.py +43 -0
- mute_agent/listener/adapters/__init__.py +31 -0
- mute_agent/listener/adapters/base_adapter.py +189 -0
- mute_agent/listener/adapters/caas_adapter.py +344 -0
- mute_agent/listener/adapters/control_plane_adapter.py +436 -0
- mute_agent/listener/adapters/iatp_adapter.py +332 -0
- mute_agent/listener/adapters/scak_adapter.py +251 -0
- mute_agent/listener/listener.py +610 -0
- mute_agent/listener/state_observer.py +436 -0
- mute_agent/listener/threshold_config.py +313 -0
- mute_agent/super_system/__init__.py +1 -0
- mute_agent/super_system/router.py +204 -0
- mute_agent/visualization/__init__.py +10 -0
- mute_agent/visualization/graph_debugger.py +502 -0
- nexus/README.md +60 -0
- nexus/__init__.py +51 -0
- nexus/arbiter.py +359 -0
- nexus/client.py +466 -0
- nexus/dmz.py +444 -0
- nexus/escrow.py +430 -0
- nexus/exceptions.py +286 -0
- nexus/pyproject.toml +36 -0
- nexus/registry.py +393 -0
- nexus/reputation.py +425 -0
- nexus/schemas/__init__.py +51 -0
- nexus/schemas/compliance.py +276 -0
- nexus/schemas/escrow.py +251 -0
- nexus/schemas/manifest.py +225 -0
- nexus/schemas/receipt.py +208 -0
- nexus/tests/__init__.py +0 -0
- nexus/tests/conftest.py +146 -0
- nexus/tests/test_arbiter.py +192 -0
- nexus/tests/test_dmz.py +194 -0
- nexus/tests/test_escrow.py +276 -0
- nexus/tests/test_exceptions.py +225 -0
- nexus/tests/test_registry.py +232 -0
- nexus/tests/test_reputation.py +328 -0
- nexus/tests/test_schemas.py +295 -0
atr/__init__.py
ADDED
|
@@ -0,0 +1,640 @@
|
|
|
1
|
+
# Copyright (c) Microsoft Corporation.
|
|
2
|
+
# Licensed under the MIT License.
|
|
3
|
+
"""ATR - Agent Tool Registry.
|
|
4
|
+
|
|
5
|
+
A decentralized marketplace for agent capabilities. ATR provides a standardized
|
|
6
|
+
interface for tool discovery, registration, and schema generation compatible with
|
|
7
|
+
OpenAI Function Calling, Anthropic Tool Use, and other LLM function calling formats.
|
|
8
|
+
|
|
9
|
+
Example:
|
|
10
|
+
Basic usage with the global registry::
|
|
11
|
+
|
|
12
|
+
import atr
|
|
13
|
+
|
|
14
|
+
@atr.register(name="calculator", cost="free", tags=["math"])
|
|
15
|
+
def add(a: int, b: int) -> int:
|
|
16
|
+
'''Add two numbers together.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
a: First number to add.
|
|
20
|
+
b: Second number to add.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
The sum of a and b.
|
|
24
|
+
'''
|
|
25
|
+
return a + b
|
|
26
|
+
|
|
27
|
+
# Discover tools
|
|
28
|
+
tools = atr.list_tools(tag="math")
|
|
29
|
+
|
|
30
|
+
# Get OpenAI-compatible schema
|
|
31
|
+
schema = atr.get_tool("calculator").to_openai_function_schema()
|
|
32
|
+
|
|
33
|
+
Advanced usage with versioning and policies::
|
|
34
|
+
|
|
35
|
+
from atr import register, get_tool, RetryPolicy, inject
|
|
36
|
+
|
|
37
|
+
@register(
|
|
38
|
+
name="pdf_parser",
|
|
39
|
+
version="1.0.0",
|
|
40
|
+
async_=True,
|
|
41
|
+
rate_limit="10/minute",
|
|
42
|
+
permissions=["claims-agent"],
|
|
43
|
+
retry_policy=RetryPolicy(max_attempts=3, backoff="exponential")
|
|
44
|
+
)
|
|
45
|
+
async def pdf_parser(file_path: str, config: Config = inject()) -> dict:
|
|
46
|
+
'''Parse a PDF document.'''
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
# Get tool handle for execution
|
|
50
|
+
tool = atr.get_tool("pdf_parser", version=">=1.0.0")
|
|
51
|
+
result = await tool.call_async(file_path="doc.pdf")
|
|
52
|
+
|
|
53
|
+
Note:
|
|
54
|
+
The registry stores tool specifications but does NOT execute them.
|
|
55
|
+
Execution is the responsibility of the Agent Runtime (Control Plane).
|
|
56
|
+
|
|
57
|
+
Attributes:
|
|
58
|
+
__version__: Package version string.
|
|
59
|
+
__author__: Package author.
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
from __future__ import annotations
|
|
63
|
+
|
|
64
|
+
from typing import TYPE_CHECKING, Any, Callable, List, Optional
|
|
65
|
+
|
|
66
|
+
from atr.access import (
|
|
67
|
+
AccessControlManager,
|
|
68
|
+
AccessDeniedError,
|
|
69
|
+
AccessPolicy,
|
|
70
|
+
Permission,
|
|
71
|
+
Principal,
|
|
72
|
+
get_access_manager,
|
|
73
|
+
set_access_manager,
|
|
74
|
+
)
|
|
75
|
+
from atr.composition import (
|
|
76
|
+
CompositionError,
|
|
77
|
+
ConditionalStep,
|
|
78
|
+
FallbackStep,
|
|
79
|
+
FunctionStep,
|
|
80
|
+
ParallelExecution,
|
|
81
|
+
Pipeline,
|
|
82
|
+
ToolChain,
|
|
83
|
+
ToolResult,
|
|
84
|
+
ToolStep,
|
|
85
|
+
compose,
|
|
86
|
+
)
|
|
87
|
+
from atr.decorator import register as register_decorator
|
|
88
|
+
from atr.executor import (
|
|
89
|
+
DockerExecutor,
|
|
90
|
+
ExecutionTimeoutError,
|
|
91
|
+
Executor,
|
|
92
|
+
ExecutorError,
|
|
93
|
+
LocalExecutor,
|
|
94
|
+
)
|
|
95
|
+
from atr.health import (
|
|
96
|
+
CallableHealthCheck,
|
|
97
|
+
HealthCheck,
|
|
98
|
+
HealthCheckRegistry,
|
|
99
|
+
HealthCheckResult,
|
|
100
|
+
HealthStatus,
|
|
101
|
+
HttpHealthCheck,
|
|
102
|
+
TcpHealthCheck,
|
|
103
|
+
get_health_registry,
|
|
104
|
+
set_health_registry,
|
|
105
|
+
)
|
|
106
|
+
from atr.injection import (
|
|
107
|
+
DependencyContainer,
|
|
108
|
+
InjectionError,
|
|
109
|
+
InjectionMarker,
|
|
110
|
+
InjectionResolver,
|
|
111
|
+
InjectionToken,
|
|
112
|
+
get_container,
|
|
113
|
+
inject,
|
|
114
|
+
set_container,
|
|
115
|
+
)
|
|
116
|
+
from atr.metrics import (
|
|
117
|
+
MetricsCollector,
|
|
118
|
+
MetricsContext,
|
|
119
|
+
MetricType,
|
|
120
|
+
ToolMetrics,
|
|
121
|
+
)
|
|
122
|
+
from atr.metrics import (
|
|
123
|
+
get_collector as get_metrics_collector,
|
|
124
|
+
)
|
|
125
|
+
from atr.metrics import (
|
|
126
|
+
set_collector as set_metrics_collector,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
# Import new modules
|
|
130
|
+
from atr.policies import (
|
|
131
|
+
BackoffStrategy,
|
|
132
|
+
RateLimitExceeded,
|
|
133
|
+
RateLimitPolicy,
|
|
134
|
+
RetryExhausted,
|
|
135
|
+
RetryPolicy,
|
|
136
|
+
with_retry,
|
|
137
|
+
with_retry_async,
|
|
138
|
+
)
|
|
139
|
+
from atr.registry import (
|
|
140
|
+
Registry,
|
|
141
|
+
RegistryError,
|
|
142
|
+
ToolAlreadyExistsError,
|
|
143
|
+
ToolNotFoundError,
|
|
144
|
+
VersionConstraintError,
|
|
145
|
+
)
|
|
146
|
+
from atr.schema import (
|
|
147
|
+
CostLevel,
|
|
148
|
+
ParameterSpec,
|
|
149
|
+
ParameterType,
|
|
150
|
+
SideEffect,
|
|
151
|
+
ToolHandle,
|
|
152
|
+
ToolMetadata,
|
|
153
|
+
ToolSpec,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
if TYPE_CHECKING:
|
|
157
|
+
from typing import Any
|
|
158
|
+
|
|
159
|
+
__version__ = "3.1.0"
|
|
160
|
+
__author__ = "Microsoft Corporation"
|
|
161
|
+
|
|
162
|
+
__all__ = [
|
|
163
|
+
# Core classes
|
|
164
|
+
"ToolSpec",
|
|
165
|
+
"ToolMetadata",
|
|
166
|
+
"ToolHandle",
|
|
167
|
+
"ParameterSpec",
|
|
168
|
+
"ParameterType",
|
|
169
|
+
# Enums
|
|
170
|
+
"CostLevel",
|
|
171
|
+
"SideEffect",
|
|
172
|
+
# Registry
|
|
173
|
+
"Registry",
|
|
174
|
+
"RegistryError",
|
|
175
|
+
"ToolNotFoundError",
|
|
176
|
+
"ToolAlreadyExistsError",
|
|
177
|
+
"VersionConstraintError",
|
|
178
|
+
# Executors
|
|
179
|
+
"Executor",
|
|
180
|
+
"LocalExecutor",
|
|
181
|
+
"DockerExecutor",
|
|
182
|
+
"ExecutorError",
|
|
183
|
+
"ExecutionTimeoutError",
|
|
184
|
+
# Functions
|
|
185
|
+
"register",
|
|
186
|
+
"get_tool",
|
|
187
|
+
"get_tool_handle",
|
|
188
|
+
"list_tools",
|
|
189
|
+
"search_tools",
|
|
190
|
+
"get_callable",
|
|
191
|
+
"execute_tool",
|
|
192
|
+
"get_all_versions",
|
|
193
|
+
"deprecate_tool",
|
|
194
|
+
# Policies
|
|
195
|
+
"RetryPolicy",
|
|
196
|
+
"RateLimitPolicy",
|
|
197
|
+
"BackoffStrategy",
|
|
198
|
+
"RateLimitExceeded",
|
|
199
|
+
"RetryExhausted",
|
|
200
|
+
"with_retry",
|
|
201
|
+
"with_retry_async",
|
|
202
|
+
# Dependency Injection
|
|
203
|
+
"inject",
|
|
204
|
+
"InjectionToken",
|
|
205
|
+
"InjectionMarker",
|
|
206
|
+
"DependencyContainer",
|
|
207
|
+
"InjectionResolver",
|
|
208
|
+
"InjectionError",
|
|
209
|
+
"get_container",
|
|
210
|
+
"set_container",
|
|
211
|
+
# Metrics
|
|
212
|
+
"MetricsCollector",
|
|
213
|
+
"ToolMetrics",
|
|
214
|
+
"MetricType",
|
|
215
|
+
"MetricsContext",
|
|
216
|
+
"get_metrics_collector",
|
|
217
|
+
"set_metrics_collector",
|
|
218
|
+
# Health Checks
|
|
219
|
+
"HealthCheck",
|
|
220
|
+
"HealthCheckResult",
|
|
221
|
+
"HealthStatus",
|
|
222
|
+
"HttpHealthCheck",
|
|
223
|
+
"TcpHealthCheck",
|
|
224
|
+
"CallableHealthCheck",
|
|
225
|
+
"HealthCheckRegistry",
|
|
226
|
+
"get_health_registry",
|
|
227
|
+
"set_health_registry",
|
|
228
|
+
# Access Control
|
|
229
|
+
"Principal",
|
|
230
|
+
"AccessPolicy",
|
|
231
|
+
"AccessDeniedError",
|
|
232
|
+
"AccessControlManager",
|
|
233
|
+
"Permission",
|
|
234
|
+
"get_access_manager",
|
|
235
|
+
"set_access_manager",
|
|
236
|
+
# Composition
|
|
237
|
+
"ToolResult",
|
|
238
|
+
"ToolStep",
|
|
239
|
+
"FunctionStep",
|
|
240
|
+
"Pipeline",
|
|
241
|
+
"ParallelExecution",
|
|
242
|
+
"ConditionalStep",
|
|
243
|
+
"FallbackStep",
|
|
244
|
+
"ToolChain",
|
|
245
|
+
"compose",
|
|
246
|
+
"CompositionError",
|
|
247
|
+
"configure_registry",
|
|
248
|
+
"get_registry",
|
|
249
|
+
# Module info
|
|
250
|
+
"__version__",
|
|
251
|
+
"__author__",
|
|
252
|
+
]
|
|
253
|
+
|
|
254
|
+
# ---------------------------------------------------------------------------
|
|
255
|
+
# Global Registry Instance
|
|
256
|
+
# ---------------------------------------------------------------------------
|
|
257
|
+
|
|
258
|
+
_global_registry: Registry = Registry(
|
|
259
|
+
container=get_container(),
|
|
260
|
+
metrics_collector=get_metrics_collector(),
|
|
261
|
+
access_manager=get_access_manager(),
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def register(
|
|
266
|
+
name: Optional[str] = None,
|
|
267
|
+
description: Optional[str] = None,
|
|
268
|
+
version: str = "1.0.0",
|
|
269
|
+
author: Optional[str] = None,
|
|
270
|
+
cost: str = "free",
|
|
271
|
+
side_effects: Optional[List[str]] = None,
|
|
272
|
+
tags: Optional[List[str]] = None,
|
|
273
|
+
registry: Optional[Registry] = None,
|
|
274
|
+
# New parameters for enhanced features
|
|
275
|
+
async_: Optional[bool] = None,
|
|
276
|
+
permissions: Optional[List[str]] = None,
|
|
277
|
+
rate_limit: Optional[str] = None,
|
|
278
|
+
retry_policy: Optional[RetryPolicy] = None,
|
|
279
|
+
health_check: Optional[HealthCheck] = None,
|
|
280
|
+
access_policy: Optional[AccessPolicy] = None,
|
|
281
|
+
deprecated: bool = False,
|
|
282
|
+
deprecated_message: Optional[str] = None,
|
|
283
|
+
) -> Callable[[Callable[..., Any]], Callable[..., Any]]:
|
|
284
|
+
"""Register a function as a tool in the Agent Tool Registry.
|
|
285
|
+
|
|
286
|
+
This decorator transforms a Python function into a discoverable tool by:
|
|
287
|
+
1. Extracting the function signature and type hints
|
|
288
|
+
2. Converting to a standardized ToolSpec schema
|
|
289
|
+
3. Registering in the specified registry (defaults to global)
|
|
290
|
+
|
|
291
|
+
Args:
|
|
292
|
+
name: Unique tool identifier. Defaults to function name if not provided.
|
|
293
|
+
description: Human-readable description. Defaults to function docstring.
|
|
294
|
+
version: Semantic version string for the tool (e.g., "1.0.0").
|
|
295
|
+
author: Tool author name.
|
|
296
|
+
cost: Execution cost level. One of "free", "low", "medium", "high".
|
|
297
|
+
side_effects: List of side effects. Options: "none", "read", "write",
|
|
298
|
+
"delete", "network", "filesystem".
|
|
299
|
+
tags: Searchable tags for tool discovery.
|
|
300
|
+
registry: Custom registry instance. Uses global registry if None.
|
|
301
|
+
async_: Whether tool is async (auto-detected if None).
|
|
302
|
+
permissions: List of roles/agents allowed to access this tool.
|
|
303
|
+
rate_limit: Rate limit string (e.g., "10/minute", "100/hour").
|
|
304
|
+
retry_policy: RetryPolicy instance for automatic retries.
|
|
305
|
+
health_check: HealthCheck instance for verifying tool availability.
|
|
306
|
+
access_policy: AccessPolicy instance for fine-grained access control.
|
|
307
|
+
deprecated: Whether this version is deprecated.
|
|
308
|
+
deprecated_message: Migration guide for deprecated tools.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
A decorator that registers the function and returns it unchanged.
|
|
312
|
+
|
|
313
|
+
Raises:
|
|
314
|
+
ValueError: If function parameters lack type hints.
|
|
315
|
+
ToolAlreadyExistsError: If tool with same name/version already exists.
|
|
316
|
+
|
|
317
|
+
Example:
|
|
318
|
+
Basic usage::
|
|
319
|
+
|
|
320
|
+
@register(name="web_scraper", cost="low", tags=["web"])
|
|
321
|
+
def scrape(url: str, timeout: int = 30) -> str:
|
|
322
|
+
'''Scrape content from a URL.'''
|
|
323
|
+
return requests.get(url, timeout=timeout).text
|
|
324
|
+
|
|
325
|
+
Advanced usage with versioning and policies::
|
|
326
|
+
|
|
327
|
+
@register(
|
|
328
|
+
name="pdf_parser",
|
|
329
|
+
version="1.0.0",
|
|
330
|
+
async_=True,
|
|
331
|
+
rate_limit="10/minute",
|
|
332
|
+
permissions=["claims-agent"],
|
|
333
|
+
retry_policy=RetryPolicy(max_attempts=3, backoff="exponential")
|
|
334
|
+
)
|
|
335
|
+
async def pdf_parser(file_path: str) -> dict:
|
|
336
|
+
'''Parse a PDF document.'''
|
|
337
|
+
...
|
|
338
|
+
"""
|
|
339
|
+
target_registry = registry if registry is not None else _global_registry
|
|
340
|
+
|
|
341
|
+
return register_decorator(
|
|
342
|
+
name=name,
|
|
343
|
+
description=description,
|
|
344
|
+
version=version,
|
|
345
|
+
author=author,
|
|
346
|
+
cost=cost,
|
|
347
|
+
side_effects=side_effects,
|
|
348
|
+
tags=tags,
|
|
349
|
+
registry=target_registry,
|
|
350
|
+
async_=async_,
|
|
351
|
+
permissions=permissions,
|
|
352
|
+
rate_limit=rate_limit,
|
|
353
|
+
retry_policy=retry_policy,
|
|
354
|
+
health_check=health_check,
|
|
355
|
+
access_policy=access_policy,
|
|
356
|
+
deprecated=deprecated,
|
|
357
|
+
deprecated_message=deprecated_message,
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
def get_tool(
|
|
362
|
+
name: str, version: Optional[str] = None, include_deprecated: bool = False
|
|
363
|
+
) -> ToolSpec:
|
|
364
|
+
"""Retrieve a tool specification from the global registry.
|
|
365
|
+
|
|
366
|
+
Args:
|
|
367
|
+
name: The unique tool identifier.
|
|
368
|
+
version: Version constraint (e.g., ">=1.0.0", "^1.0.0", "1.2.3").
|
|
369
|
+
If None, returns the latest version.
|
|
370
|
+
include_deprecated: Whether to include deprecated versions.
|
|
371
|
+
|
|
372
|
+
Returns:
|
|
373
|
+
The complete tool specification including metadata and parameters.
|
|
374
|
+
|
|
375
|
+
Raises:
|
|
376
|
+
ToolNotFoundError: If no tool with the given name exists.
|
|
377
|
+
VersionConstraintError: If no version matches the constraint.
|
|
378
|
+
|
|
379
|
+
Example:
|
|
380
|
+
>>> spec = get_tool("calculator")
|
|
381
|
+
>>> print(spec.metadata.description)
|
|
382
|
+
>>>
|
|
383
|
+
>>> # Get specific version
|
|
384
|
+
>>> spec = get_tool("pdf_parser", version=">=1.0.0")
|
|
385
|
+
"""
|
|
386
|
+
return _global_registry.get_tool(name, version, include_deprecated)
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
def get_tool_handle(
|
|
390
|
+
name: str, version: Optional[str] = None, include_deprecated: bool = False
|
|
391
|
+
) -> ToolHandle:
|
|
392
|
+
"""Get a ToolHandle for executing a tool with all policies applied.
|
|
393
|
+
|
|
394
|
+
The ToolHandle provides a convenient interface for executing tools
|
|
395
|
+
with automatic rate limiting, retries, metrics collection, and
|
|
396
|
+
dependency injection.
|
|
397
|
+
|
|
398
|
+
Args:
|
|
399
|
+
name: The unique tool identifier.
|
|
400
|
+
version: Version constraint (e.g., ">=1.0.0", "^1.0.0", "1.2.3").
|
|
401
|
+
include_deprecated: Whether to include deprecated versions.
|
|
402
|
+
|
|
403
|
+
Returns:
|
|
404
|
+
ToolHandle ready for execution.
|
|
405
|
+
|
|
406
|
+
Raises:
|
|
407
|
+
ToolNotFoundError: If no tool with the given name exists.
|
|
408
|
+
VersionConstraintError: If no version matches the constraint.
|
|
409
|
+
|
|
410
|
+
Example:
|
|
411
|
+
>>> tool = get_tool_handle("pdf_parser", version=">=1.0.0")
|
|
412
|
+
>>> result = await tool.call_async(file_path="doc.pdf")
|
|
413
|
+
>>> # or synchronously
|
|
414
|
+
>>> result = tool.call(file_path="doc.pdf")
|
|
415
|
+
"""
|
|
416
|
+
return _global_registry.get_tool_handle(name, version, include_deprecated)
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def get_all_versions(name: str) -> List[str]:
|
|
420
|
+
"""Get all registered versions of a tool.
|
|
421
|
+
|
|
422
|
+
Args:
|
|
423
|
+
name: The unique tool identifier.
|
|
424
|
+
|
|
425
|
+
Returns:
|
|
426
|
+
List of version strings, sorted newest first.
|
|
427
|
+
|
|
428
|
+
Raises:
|
|
429
|
+
ToolNotFoundError: If no tool with the given name exists.
|
|
430
|
+
|
|
431
|
+
Example:
|
|
432
|
+
>>> versions = get_all_versions("pdf_parser")
|
|
433
|
+
>>> print(versions) # ["2.0.0", "1.1.0", "1.0.0"]
|
|
434
|
+
"""
|
|
435
|
+
return _global_registry.get_all_versions(name)
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
def deprecate_tool(name: str, version: str, message: Optional[str] = None) -> None:
|
|
439
|
+
"""Mark a tool version as deprecated.
|
|
440
|
+
|
|
441
|
+
Args:
|
|
442
|
+
name: Tool name.
|
|
443
|
+
version: Version to deprecate.
|
|
444
|
+
message: Optional deprecation message/migration guide.
|
|
445
|
+
|
|
446
|
+
Raises:
|
|
447
|
+
ToolNotFoundError: If tool/version not found.
|
|
448
|
+
|
|
449
|
+
Example:
|
|
450
|
+
>>> deprecate_tool(
|
|
451
|
+
... "pdf_parser",
|
|
452
|
+
... "1.0.0",
|
|
453
|
+
... "Use version 2.0.0 instead. See migration guide at ..."
|
|
454
|
+
... )
|
|
455
|
+
"""
|
|
456
|
+
_global_registry.deprecate_tool(name, version, message)
|
|
457
|
+
|
|
458
|
+
|
|
459
|
+
def list_tools(
|
|
460
|
+
tag: Optional[str] = None,
|
|
461
|
+
cost: Optional[CostLevel] = None,
|
|
462
|
+
side_effect: Optional[SideEffect] = None,
|
|
463
|
+
include_all_versions: bool = False,
|
|
464
|
+
include_deprecated: bool = False,
|
|
465
|
+
) -> List[ToolSpec]:
|
|
466
|
+
"""List all registered tools with optional filtering.
|
|
467
|
+
|
|
468
|
+
Args:
|
|
469
|
+
tag: Filter by tag (e.g., "math", "web", "file").
|
|
470
|
+
cost: Filter by cost level enum.
|
|
471
|
+
side_effect: Filter by side effect type.
|
|
472
|
+
include_all_versions: If True, return all versions. If False, only latest.
|
|
473
|
+
include_deprecated: Whether to include deprecated tools.
|
|
474
|
+
|
|
475
|
+
Returns:
|
|
476
|
+
List of tool specifications matching the filters.
|
|
477
|
+
|
|
478
|
+
Example:
|
|
479
|
+
>>> # Get all low-cost tools
|
|
480
|
+
>>> cheap_tools = list_tools(cost=CostLevel.LOW)
|
|
481
|
+
>>> # Get all tools tagged "math"
|
|
482
|
+
>>> math_tools = list_tools(tag="math")
|
|
483
|
+
>>> # Get all versions of all tools
|
|
484
|
+
>>> all_tools = list_tools(include_all_versions=True)
|
|
485
|
+
"""
|
|
486
|
+
return _global_registry.list_tools(
|
|
487
|
+
tag=tag,
|
|
488
|
+
cost=cost,
|
|
489
|
+
side_effect=side_effect,
|
|
490
|
+
include_all_versions=include_all_versions,
|
|
491
|
+
include_deprecated=include_deprecated,
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
|
|
495
|
+
def search_tools(query: str, include_all_versions: bool = False) -> List[ToolSpec]:
|
|
496
|
+
"""Search tools by name, description, or tags.
|
|
497
|
+
|
|
498
|
+
Performs a case-insensitive search across tool metadata.
|
|
499
|
+
|
|
500
|
+
Args:
|
|
501
|
+
query: Search query string.
|
|
502
|
+
include_all_versions: Whether to search all versions.
|
|
503
|
+
|
|
504
|
+
Returns:
|
|
505
|
+
List of matching tool specifications.
|
|
506
|
+
|
|
507
|
+
Example:
|
|
508
|
+
>>> results = search_tools("scrape")
|
|
509
|
+
>>> for tool in results:
|
|
510
|
+
... print(tool.metadata.name)
|
|
511
|
+
"""
|
|
512
|
+
return _global_registry.search_tools(query, include_all_versions)
|
|
513
|
+
|
|
514
|
+
|
|
515
|
+
def get_callable(name: str, version: Optional[str] = None) -> Callable[..., Any]:
|
|
516
|
+
"""Get the callable function for a registered tool.
|
|
517
|
+
|
|
518
|
+
This returns the function object but does NOT execute it.
|
|
519
|
+
The caller (Agent Runtime) is responsible for execution.
|
|
520
|
+
|
|
521
|
+
For most use cases, prefer get_tool_handle() which provides
|
|
522
|
+
automatic rate limiting, retries, and metrics collection.
|
|
523
|
+
|
|
524
|
+
Args:
|
|
525
|
+
name: The unique tool identifier.
|
|
526
|
+
version: Optional version constraint.
|
|
527
|
+
|
|
528
|
+
Returns:
|
|
529
|
+
The original callable function.
|
|
530
|
+
|
|
531
|
+
Raises:
|
|
532
|
+
ToolNotFoundError: If no tool with the given name exists.
|
|
533
|
+
ValueError: If the tool has no associated callable.
|
|
534
|
+
|
|
535
|
+
Example:
|
|
536
|
+
>>> func = get_callable("calculator")
|
|
537
|
+
>>> result = func(a=1, b=2) # Caller executes
|
|
538
|
+
"""
|
|
539
|
+
return _global_registry.get_callable(name, version)
|
|
540
|
+
|
|
541
|
+
|
|
542
|
+
def execute_tool(
|
|
543
|
+
name: str,
|
|
544
|
+
args: Optional[dict] = None,
|
|
545
|
+
executor: Optional[Executor] = None,
|
|
546
|
+
timeout: Optional[int] = None,
|
|
547
|
+
) -> Any:
|
|
548
|
+
"""Execute a registered tool with optional sandboxing.
|
|
549
|
+
|
|
550
|
+
This is a convenience function that retrieves a tool and executes it
|
|
551
|
+
using the specified executor. If no executor is provided, uses LocalExecutor
|
|
552
|
+
(direct execution on host - not sandboxed).
|
|
553
|
+
|
|
554
|
+
For production use with untrusted code, always provide a DockerExecutor
|
|
555
|
+
to ensure sandboxed execution.
|
|
556
|
+
|
|
557
|
+
Args:
|
|
558
|
+
name: The unique tool identifier.
|
|
559
|
+
args: Dictionary of arguments to pass to the tool.
|
|
560
|
+
executor: Executor instance to use. Defaults to LocalExecutor if None.
|
|
561
|
+
timeout: Execution timeout in seconds (only applicable for DockerExecutor).
|
|
562
|
+
|
|
563
|
+
Returns:
|
|
564
|
+
The result of the tool execution.
|
|
565
|
+
|
|
566
|
+
Raises:
|
|
567
|
+
ToolNotFoundError: If no tool with the given name exists.
|
|
568
|
+
ValueError: If the tool has no associated callable.
|
|
569
|
+
ExecutorError: If execution fails.
|
|
570
|
+
ExecutionTimeoutError: If execution exceeds timeout.
|
|
571
|
+
|
|
572
|
+
Example:
|
|
573
|
+
>>> # Direct execution (not sandboxed - use only with trusted code)
|
|
574
|
+
>>> result = execute_tool("calculator", {"a": 5, "b": 3})
|
|
575
|
+
|
|
576
|
+
>>> # Sandboxed execution (recommended for untrusted code)
|
|
577
|
+
>>> from atr import DockerExecutor
|
|
578
|
+
>>> docker_exec = DockerExecutor()
|
|
579
|
+
>>> result = execute_tool("calculator", {"a": 5, "b": 3}, executor=docker_exec)
|
|
580
|
+
"""
|
|
581
|
+
if args is None:
|
|
582
|
+
args = {}
|
|
583
|
+
|
|
584
|
+
# Get the callable function
|
|
585
|
+
func = get_callable(name)
|
|
586
|
+
|
|
587
|
+
# Use LocalExecutor if no executor provided
|
|
588
|
+
if executor is None:
|
|
589
|
+
executor = LocalExecutor()
|
|
590
|
+
|
|
591
|
+
# Execute with the specified executor
|
|
592
|
+
return executor.execute(func, args=args, timeout=timeout)
|
|
593
|
+
|
|
594
|
+
|
|
595
|
+
# ---------------------------------------------------------------------------
|
|
596
|
+
# Registry Configuration
|
|
597
|
+
# ---------------------------------------------------------------------------
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def configure_registry(
|
|
601
|
+
container: Optional[DependencyContainer] = None,
|
|
602
|
+
metrics_collector: Optional[MetricsCollector] = None,
|
|
603
|
+
access_manager: Optional[AccessControlManager] = None,
|
|
604
|
+
) -> None:
|
|
605
|
+
"""Configure the global registry with custom components.
|
|
606
|
+
|
|
607
|
+
Args:
|
|
608
|
+
container: Dependency container for injection.
|
|
609
|
+
metrics_collector: Metrics collector for tracking.
|
|
610
|
+
access_manager: Access control manager.
|
|
611
|
+
|
|
612
|
+
Example:
|
|
613
|
+
>>> container = DependencyContainer()
|
|
614
|
+
>>> container.register(Config, Config(api_key="secret"))
|
|
615
|
+
>>> configure_registry(container=container)
|
|
616
|
+
"""
|
|
617
|
+
global _global_registry
|
|
618
|
+
|
|
619
|
+
if container is not None:
|
|
620
|
+
_global_registry._container = container
|
|
621
|
+
if metrics_collector is not None:
|
|
622
|
+
_global_registry._metrics = metrics_collector
|
|
623
|
+
if access_manager is not None:
|
|
624
|
+
_global_registry._access_manager = access_manager
|
|
625
|
+
|
|
626
|
+
|
|
627
|
+
def get_registry() -> Registry:
|
|
628
|
+
"""Get the global registry instance.
|
|
629
|
+
|
|
630
|
+
This is the preferred way to access the registry instead of
|
|
631
|
+
using the private _global_registry directly.
|
|
632
|
+
|
|
633
|
+
Returns:
|
|
634
|
+
The global Registry instance.
|
|
635
|
+
|
|
636
|
+
Example:
|
|
637
|
+
>>> registry = get_registry()
|
|
638
|
+
>>> print(f"Registered tools: {len(registry)}")
|
|
639
|
+
"""
|
|
640
|
+
return _global_registry
|