imperial-a2a 1.0.1__tar.gz
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.
- imperial_a2a-1.0.1/LICENSE +21 -0
- imperial_a2a-1.0.1/PKG-INFO +224 -0
- imperial_a2a-1.0.1/README.md +160 -0
- imperial_a2a-1.0.1/__init__.py +0 -0
- imperial_a2a-1.0.1/audit.py +321 -0
- imperial_a2a-1.0.1/autonomous_agent.py +397 -0
- imperial_a2a-1.0.1/bridge.py +147 -0
- imperial_a2a-1.0.1/cache.py +316 -0
- imperial_a2a-1.0.1/chaos_injector.py +54 -0
- imperial_a2a-1.0.1/client.py +344 -0
- imperial_a2a-1.0.1/composition.py +355 -0
- imperial_a2a-1.0.1/deploy_example.py +225 -0
- imperial_a2a-1.0.1/event_bus.py +185 -0
- imperial_a2a-1.0.1/execution_ledger.py +131 -0
- imperial_a2a-1.0.1/gateway.py +557 -0
- imperial_a2a-1.0.1/imperial_a2a.egg-info/PKG-INFO +224 -0
- imperial_a2a-1.0.1/imperial_a2a.egg-info/SOURCES.txt +97 -0
- imperial_a2a-1.0.1/imperial_a2a.egg-info/dependency_links.txt +1 -0
- imperial_a2a-1.0.1/imperial_a2a.egg-info/requires.txt +17 -0
- imperial_a2a-1.0.1/imperial_a2a.egg-info/top_level.txt +1 -0
- imperial_a2a-1.0.1/income_routes.py +163 -0
- imperial_a2a-1.0.1/lifecycle.py +347 -0
- imperial_a2a-1.0.1/mesh_transport.py +211 -0
- imperial_a2a-1.0.1/models.py +292 -0
- imperial_a2a-1.0.1/observability.py +299 -0
- imperial_a2a-1.0.1/persistence.py +319 -0
- imperial_a2a-1.0.1/planning/__init__.py +29 -0
- imperial_a2a-1.0.1/planning/compaction_worker.py +143 -0
- imperial_a2a-1.0.1/planning/economic_router.py +99 -0
- imperial_a2a-1.0.1/planning/engine.py +748 -0
- imperial_a2a-1.0.1/planning/integration_test.py +307 -0
- imperial_a2a-1.0.1/planning/proactive_kernel.py +121 -0
- imperial_a2a-1.0.1/planning/reflection_engine.py +400 -0
- imperial_a2a-1.0.1/planning/test_engine.py +517 -0
- imperial_a2a-1.0.1/planning/test_planning_service.py +245 -0
- imperial_a2a-1.0.1/planning/types.py +122 -0
- imperial_a2a-1.0.1/planning_service.py +257 -0
- imperial_a2a-1.0.1/policy.py +349 -0
- imperial_a2a-1.0.1/production_gateway.py +312 -0
- imperial_a2a-1.0.1/pyproject.toml +48 -0
- imperial_a2a-1.0.1/reputation.py +352 -0
- imperial_a2a-1.0.1/router.py +331 -0
- imperial_a2a-1.0.1/routing_receipt.py +59 -0
- imperial_a2a-1.0.1/scheduler.py +528 -0
- imperial_a2a-1.0.1/self_healing_router.py +90 -0
- imperial_a2a-1.0.1/settlement_bridge.py +344 -0
- imperial_a2a-1.0.1/settlement_hook.py +49 -0
- imperial_a2a-1.0.1/setup.cfg +4 -0
- imperial_a2a-1.0.1/setup.py +67 -0
- imperial_a2a-1.0.1/swarm_coordinator.py +149 -0
- imperial_a2a-1.0.1/trust_gated_router.py +121 -0
- imperial_a2a-1.0.1/trust_weighted_router.py +136 -0
- imperial_a2a-1.0.1/vector_memory.py +675 -0
- imperial_a2a-1.0.1/verify_routes.py +167 -0
- imperial_a2a-1.0.1/workspace.py +274 -0
- imperial_a2a-1.0.1/zkml_trust_bridge.py +450 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Robert Lambert / NanoEmpire AI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: imperial-a2a
|
|
3
|
+
Version: 1.0.1
|
|
4
|
+
Summary: Agent-to-Agent (A2A) task routing system with audit trails, policy engine, reputation tracking, and gateway
|
|
5
|
+
Home-page: https://github.com/robertlambertnano/empire
|
|
6
|
+
Author: Robert Lambert
|
|
7
|
+
Author-email: Robert Lambert / NanoEmpire AI <roblambert9@gmail.com>
|
|
8
|
+
License: MIT License
|
|
9
|
+
|
|
10
|
+
Copyright (c) 2026 Robert Lambert / NanoEmpire AI
|
|
11
|
+
|
|
12
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
14
|
+
in the Software without restriction, including without limitation the rights
|
|
15
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
16
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
17
|
+
furnished to do so, subject to the following conditions:
|
|
18
|
+
|
|
19
|
+
The above copyright notice and this permission notice shall be included in all
|
|
20
|
+
copies or substantial portions of the Software.
|
|
21
|
+
|
|
22
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
23
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
24
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
25
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
26
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
27
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
28
|
+
SOFTWARE.
|
|
29
|
+
|
|
30
|
+
Project-URL: Homepage, https://neuralempireai.com
|
|
31
|
+
Project-URL: Repository, https://github.com/roblambert9/nano-empire-ai
|
|
32
|
+
Project-URL: Documentation, https://github.com/roblambert9/nano-empire-ai/blob/master/docs/x402-integration-guide.md
|
|
33
|
+
Project-URL: Bug Tracker, https://github.com/roblambert9/nano-empire-ai/issues
|
|
34
|
+
Keywords: a2a,agent,routing,audit,policy,reputation,gateway,lifecycle
|
|
35
|
+
Classifier: Development Status :: 4 - Beta
|
|
36
|
+
Classifier: Intended Audience :: Developers
|
|
37
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
38
|
+
Classifier: Programming Language :: Python :: 3
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
43
|
+
Requires-Python: >=3.9
|
|
44
|
+
Description-Content-Type: text/markdown
|
|
45
|
+
License-File: LICENSE
|
|
46
|
+
Requires-Dist: fastapi>=0.100.0
|
|
47
|
+
Requires-Dist: pydantic>=2.0.0
|
|
48
|
+
Requires-Dist: pyyaml>=6.0
|
|
49
|
+
Requires-Dist: requests>=2.31.0
|
|
50
|
+
Requires-Dist: croniter>=1.0.0
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
53
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
54
|
+
Requires-Dist: aiohttp>=3.8.0; extra == "dev"
|
|
55
|
+
Requires-Dist: uvicorn>=0.27.0; extra == "dev"
|
|
56
|
+
Provides-Extra: async
|
|
57
|
+
Requires-Dist: aiohttp>=3.8.0; extra == "async"
|
|
58
|
+
Provides-Extra: gateway
|
|
59
|
+
Requires-Dist: uvicorn>=0.27.0; extra == "gateway"
|
|
60
|
+
Dynamic: author
|
|
61
|
+
Dynamic: home-page
|
|
62
|
+
Dynamic: license-file
|
|
63
|
+
Dynamic: requires-python
|
|
64
|
+
|
|
65
|
+
# Empire A2A (Agent-to-Agent) Task Routing System
|
|
66
|
+
|
|
67
|
+
A production-grade Agent-to-Agent (A2A) task routing system with persistent storage, audit trails, policy enforcement, reputation tracking, cross-node transport, task composition, scheduling, caching, multi-tenant isolation, and external SDK/observability.
|
|
68
|
+
|
|
69
|
+
## Features
|
|
70
|
+
|
|
71
|
+
- **Capability-Based Routing**: Route tasks to agents based on capabilities, load, cost, latency, affinity, or round-robin
|
|
72
|
+
- **Persistent Storage**: SQLite-backed task storage with WAL mode for concurrent access
|
|
73
|
+
- **Tamper-Evident Audit Trails**: SHA-256 chained audit logs with integrity verification
|
|
74
|
+
- **Full Lifecycle Tracking**: 10-state task machine with persistence hooks and timeout recovery
|
|
75
|
+
- **Policy Engine**: Hot-reloadable YAML policies with ALLOW/DENY/REQUIRE rules and budget caps
|
|
76
|
+
- **Reputation System**: Exponential decay scoring with sliding window metrics and p50/p95 latency tracking
|
|
77
|
+
- **Mesh Transport**: Cross-node HTTP transport via Tailscale with retry/backoff and circuit breaking
|
|
78
|
+
- **Task Composition**: DAG decomposition with topological sort and 6 aggregation strategies
|
|
79
|
+
- **Scheduler**: Cron expression parser with shortcuts (@hourly, @daily, etc.) and jitter support
|
|
80
|
+
- **Result Cache**: Hash-based cache with per-capability TTLs and automatic invalidation
|
|
81
|
+
- **Multi-Tenant Isolation**: Workspace-based isolation with explicit cross-workspace allowlists
|
|
82
|
+
- **Client SDK**: Sync and async clients with HMAC request signing
|
|
83
|
+
- **Observability**: Prometheus metrics endpoint and deep health checks
|
|
84
|
+
- **Gateway Service**: FastAPI REST/WebSocket service with HMAC authentication and rate limiting
|
|
85
|
+
|
|
86
|
+
## Installation
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
pip install imperial-a2a
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
For development dependencies:
|
|
93
|
+
```bash
|
|
94
|
+
pip install imperial-a2a[dev]
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
For async client:
|
|
98
|
+
```bash
|
|
99
|
+
pip install imperial-a2a[async]
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
For full gateway:
|
|
103
|
+
```bash
|
|
104
|
+
pip install imperial-a2a[gateway]
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Quick Start
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
from imperial_a2a import (
|
|
111
|
+
get_a2a_router,
|
|
112
|
+
get_lifecycle,
|
|
113
|
+
get_audit_trail,
|
|
114
|
+
get_policy_engine,
|
|
115
|
+
get_reputation_engine,
|
|
116
|
+
get_task_store,
|
|
117
|
+
A2AClient,
|
|
118
|
+
sign_request
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Initialize components
|
|
122
|
+
router = get_a2a_router()
|
|
123
|
+
lifecycle = get_lifecycle()
|
|
124
|
+
audit = get_audit_trail()
|
|
125
|
+
policy = get_policy_engine()
|
|
126
|
+
reputation = get_reputation_engine()
|
|
127
|
+
store = get_task_store()
|
|
128
|
+
|
|
129
|
+
# Register an agent capability
|
|
130
|
+
router.register_agent_capability(
|
|
131
|
+
agent_id="agent-001",
|
|
132
|
+
capability=AgentCapability(
|
|
133
|
+
agent_id="agent-001",
|
|
134
|
+
capability_id="text-summarization",
|
|
135
|
+
description="Summarizes text documents",
|
|
136
|
+
input_schema={"type": "object", "properties": {"text": {"type": "string"}}},
|
|
137
|
+
output_schema={"type": "object", "properties": {"summary": {"type": "string"}}},
|
|
138
|
+
cost_per_task=0.001,
|
|
139
|
+
avg_latency_ms=500,
|
|
140
|
+
max_concurrent=5
|
|
141
|
+
)
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
# Submit a task via client
|
|
145
|
+
client = A2AClient(gateway_url="http://localhost:8000")
|
|
146
|
+
result = client.submit_task(
|
|
147
|
+
capability_id="text-summarization",
|
|
148
|
+
input_data={"text": "Long document to summarize..."},
|
|
149
|
+
priority=TaskPriority.NORMAL
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
# Check task status
|
|
153
|
+
status = client.get_task_status(result.task_id)
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## Running the Gateway
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
uvicorn imperial_a2a.gateway:create_gateway --host 0.0.0.0 --port 8000
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Configuration
|
|
163
|
+
|
|
164
|
+
The policy engine loads YAML configuration from `empire/config/a2a_policy.yaml` by default:
|
|
165
|
+
|
|
166
|
+
```yaml
|
|
167
|
+
version: 1
|
|
168
|
+
rules:
|
|
169
|
+
- effect: DENY
|
|
170
|
+
scope: GLOBAL
|
|
171
|
+
when:
|
|
172
|
+
agent_id: "blocked-agent-001"
|
|
173
|
+
description: "Block specific agent"
|
|
174
|
+
- effect: REQUIRE
|
|
175
|
+
scope: CAPABILITY
|
|
176
|
+
when:
|
|
177
|
+
capability_id: "high-risk-operation"
|
|
178
|
+
then:
|
|
179
|
+
- effect: DENY
|
|
180
|
+
when:
|
|
181
|
+
reputation_score: {"<": 0.5}
|
|
182
|
+
description: "Require good reputation for high-risk ops"
|
|
183
|
+
budgets:
|
|
184
|
+
- agent_id: "agent-001"
|
|
185
|
+
capability_id: "premium-service"
|
|
186
|
+
daily_limit: 100.0
|
|
187
|
+
description: "Daily budget for premium service"
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## API Endpoints
|
|
191
|
+
|
|
192
|
+
### Gateway (`/`)
|
|
193
|
+
- `POST /tasks` - Submit a new task
|
|
194
|
+
- `GET /tasks/{task_id}` - Get task status
|
|
195
|
+
- `GET /tasks` - List tasks with filters
|
|
196
|
+
- `POST /tasks/{task_id}/cancel` - Cancel a task
|
|
197
|
+
- `GET /agents/{agent_id}` - Get agent info
|
|
198
|
+
- `GET /capabilities` - List capabilities
|
|
199
|
+
- `GET /health` - Basic health check
|
|
200
|
+
- `GET /health/deep` - Deep health check (503 if unhealthy)
|
|
201
|
+
- `GET /metrics` - Prometheus metrics
|
|
202
|
+
- `WS /ws/{client_id}` - WebSocket for real-time updates
|
|
203
|
+
|
|
204
|
+
### Observability
|
|
205
|
+
- Prometheus metrics available at `/metrics` endpoint
|
|
206
|
+
- Deep health checks at `/health/deep`
|
|
207
|
+
- Structured JSON logging available via `setup_structured_logging()`
|
|
208
|
+
|
|
209
|
+
## Testing
|
|
210
|
+
|
|
211
|
+
Run the test suite:
|
|
212
|
+
```bash
|
|
213
|
+
pytest empire/tests/ -v
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
MIT License - see LICENSE file for details.
|
|
219
|
+
|
|
220
|
+
## Empire Integration
|
|
221
|
+
|
|
222
|
+
This A2A system is designed to integrate with the Nano Empire AI operating system. It exposes metrics and health endpoints that can be scraped by the empire observability system.
|
|
223
|
+
|
|
224
|
+
For integration with the empire dashboard, see `empire/viz/empire_dashboard.py` which includes A2A-specific health checks and metrics.
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Empire A2A (Agent-to-Agent) Task Routing System
|
|
2
|
+
|
|
3
|
+
A production-grade Agent-to-Agent (A2A) task routing system with persistent storage, audit trails, policy enforcement, reputation tracking, cross-node transport, task composition, scheduling, caching, multi-tenant isolation, and external SDK/observability.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Capability-Based Routing**: Route tasks to agents based on capabilities, load, cost, latency, affinity, or round-robin
|
|
8
|
+
- **Persistent Storage**: SQLite-backed task storage with WAL mode for concurrent access
|
|
9
|
+
- **Tamper-Evident Audit Trails**: SHA-256 chained audit logs with integrity verification
|
|
10
|
+
- **Full Lifecycle Tracking**: 10-state task machine with persistence hooks and timeout recovery
|
|
11
|
+
- **Policy Engine**: Hot-reloadable YAML policies with ALLOW/DENY/REQUIRE rules and budget caps
|
|
12
|
+
- **Reputation System**: Exponential decay scoring with sliding window metrics and p50/p95 latency tracking
|
|
13
|
+
- **Mesh Transport**: Cross-node HTTP transport via Tailscale with retry/backoff and circuit breaking
|
|
14
|
+
- **Task Composition**: DAG decomposition with topological sort and 6 aggregation strategies
|
|
15
|
+
- **Scheduler**: Cron expression parser with shortcuts (@hourly, @daily, etc.) and jitter support
|
|
16
|
+
- **Result Cache**: Hash-based cache with per-capability TTLs and automatic invalidation
|
|
17
|
+
- **Multi-Tenant Isolation**: Workspace-based isolation with explicit cross-workspace allowlists
|
|
18
|
+
- **Client SDK**: Sync and async clients with HMAC request signing
|
|
19
|
+
- **Observability**: Prometheus metrics endpoint and deep health checks
|
|
20
|
+
- **Gateway Service**: FastAPI REST/WebSocket service with HMAC authentication and rate limiting
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pip install imperial-a2a
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
For development dependencies:
|
|
29
|
+
```bash
|
|
30
|
+
pip install imperial-a2a[dev]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
For async client:
|
|
34
|
+
```bash
|
|
35
|
+
pip install imperial-a2a[async]
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For full gateway:
|
|
39
|
+
```bash
|
|
40
|
+
pip install imperial-a2a[gateway]
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
```python
|
|
46
|
+
from imperial_a2a import (
|
|
47
|
+
get_a2a_router,
|
|
48
|
+
get_lifecycle,
|
|
49
|
+
get_audit_trail,
|
|
50
|
+
get_policy_engine,
|
|
51
|
+
get_reputation_engine,
|
|
52
|
+
get_task_store,
|
|
53
|
+
A2AClient,
|
|
54
|
+
sign_request
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
# Initialize components
|
|
58
|
+
router = get_a2a_router()
|
|
59
|
+
lifecycle = get_lifecycle()
|
|
60
|
+
audit = get_audit_trail()
|
|
61
|
+
policy = get_policy_engine()
|
|
62
|
+
reputation = get_reputation_engine()
|
|
63
|
+
store = get_task_store()
|
|
64
|
+
|
|
65
|
+
# Register an agent capability
|
|
66
|
+
router.register_agent_capability(
|
|
67
|
+
agent_id="agent-001",
|
|
68
|
+
capability=AgentCapability(
|
|
69
|
+
agent_id="agent-001",
|
|
70
|
+
capability_id="text-summarization",
|
|
71
|
+
description="Summarizes text documents",
|
|
72
|
+
input_schema={"type": "object", "properties": {"text": {"type": "string"}}},
|
|
73
|
+
output_schema={"type": "object", "properties": {"summary": {"type": "string"}}},
|
|
74
|
+
cost_per_task=0.001,
|
|
75
|
+
avg_latency_ms=500,
|
|
76
|
+
max_concurrent=5
|
|
77
|
+
)
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
# Submit a task via client
|
|
81
|
+
client = A2AClient(gateway_url="http://localhost:8000")
|
|
82
|
+
result = client.submit_task(
|
|
83
|
+
capability_id="text-summarization",
|
|
84
|
+
input_data={"text": "Long document to summarize..."},
|
|
85
|
+
priority=TaskPriority.NORMAL
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
# Check task status
|
|
89
|
+
status = client.get_task_status(result.task_id)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Running the Gateway
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uvicorn imperial_a2a.gateway:create_gateway --host 0.0.0.0 --port 8000
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Configuration
|
|
99
|
+
|
|
100
|
+
The policy engine loads YAML configuration from `empire/config/a2a_policy.yaml` by default:
|
|
101
|
+
|
|
102
|
+
```yaml
|
|
103
|
+
version: 1
|
|
104
|
+
rules:
|
|
105
|
+
- effect: DENY
|
|
106
|
+
scope: GLOBAL
|
|
107
|
+
when:
|
|
108
|
+
agent_id: "blocked-agent-001"
|
|
109
|
+
description: "Block specific agent"
|
|
110
|
+
- effect: REQUIRE
|
|
111
|
+
scope: CAPABILITY
|
|
112
|
+
when:
|
|
113
|
+
capability_id: "high-risk-operation"
|
|
114
|
+
then:
|
|
115
|
+
- effect: DENY
|
|
116
|
+
when:
|
|
117
|
+
reputation_score: {"<": 0.5}
|
|
118
|
+
description: "Require good reputation for high-risk ops"
|
|
119
|
+
budgets:
|
|
120
|
+
- agent_id: "agent-001"
|
|
121
|
+
capability_id: "premium-service"
|
|
122
|
+
daily_limit: 100.0
|
|
123
|
+
description: "Daily budget for premium service"
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## API Endpoints
|
|
127
|
+
|
|
128
|
+
### Gateway (`/`)
|
|
129
|
+
- `POST /tasks` - Submit a new task
|
|
130
|
+
- `GET /tasks/{task_id}` - Get task status
|
|
131
|
+
- `GET /tasks` - List tasks with filters
|
|
132
|
+
- `POST /tasks/{task_id}/cancel` - Cancel a task
|
|
133
|
+
- `GET /agents/{agent_id}` - Get agent info
|
|
134
|
+
- `GET /capabilities` - List capabilities
|
|
135
|
+
- `GET /health` - Basic health check
|
|
136
|
+
- `GET /health/deep` - Deep health check (503 if unhealthy)
|
|
137
|
+
- `GET /metrics` - Prometheus metrics
|
|
138
|
+
- `WS /ws/{client_id}` - WebSocket for real-time updates
|
|
139
|
+
|
|
140
|
+
### Observability
|
|
141
|
+
- Prometheus metrics available at `/metrics` endpoint
|
|
142
|
+
- Deep health checks at `/health/deep`
|
|
143
|
+
- Structured JSON logging available via `setup_structured_logging()`
|
|
144
|
+
|
|
145
|
+
## Testing
|
|
146
|
+
|
|
147
|
+
Run the test suite:
|
|
148
|
+
```bash
|
|
149
|
+
pytest empire/tests/ -v
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
## License
|
|
153
|
+
|
|
154
|
+
MIT License - see LICENSE file for details.
|
|
155
|
+
|
|
156
|
+
## Empire Integration
|
|
157
|
+
|
|
158
|
+
This A2A system is designed to integrate with the Nano Empire AI operating system. It exposes metrics and health endpoints that can be scraped by the empire observability system.
|
|
159
|
+
|
|
160
|
+
For integration with the empire dashboard, see `empire/viz/empire_dashboard.py` which includes A2A-specific health checks and metrics.
|
|
File without changes
|