agentlegatus 0.1.0__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.
- agentlegatus-0.1.0/PKG-INFO +245 -0
- agentlegatus-0.1.0/README.md +178 -0
- agentlegatus-0.1.0/agentlegatus/__init__.py +33 -0
- agentlegatus-0.1.0/agentlegatus/cli/__init__.py +5 -0
- agentlegatus-0.1.0/agentlegatus/cli/main.py +580 -0
- agentlegatus-0.1.0/agentlegatus/config/__init__.py +33 -0
- agentlegatus-0.1.0/agentlegatus/config/loader.py +299 -0
- agentlegatus-0.1.0/agentlegatus/config/models.py +191 -0
- agentlegatus-0.1.0/agentlegatus/core/__init__.py +35 -0
- agentlegatus-0.1.0/agentlegatus/core/event_bus.py +229 -0
- agentlegatus-0.1.0/agentlegatus/core/executor.py +484 -0
- agentlegatus-0.1.0/agentlegatus/core/graph.py +310 -0
- agentlegatus-0.1.0/agentlegatus/core/models.py +172 -0
- agentlegatus-0.1.0/agentlegatus/core/postgres_backend.py +265 -0
- agentlegatus-0.1.0/agentlegatus/core/recovery.py +319 -0
- agentlegatus-0.1.0/agentlegatus/core/redis_backend.py +201 -0
- agentlegatus-0.1.0/agentlegatus/core/state.py +506 -0
- agentlegatus-0.1.0/agentlegatus/core/workflow.py +206 -0
- agentlegatus-0.1.0/agentlegatus/exceptions.py +170 -0
- agentlegatus-0.1.0/agentlegatus/hierarchy/__init__.py +15 -0
- agentlegatus-0.1.0/agentlegatus/hierarchy/agent.py +255 -0
- agentlegatus-0.1.0/agentlegatus/hierarchy/centurion.py +459 -0
- agentlegatus-0.1.0/agentlegatus/hierarchy/cohort.py +309 -0
- agentlegatus-0.1.0/agentlegatus/hierarchy/legatus.py +472 -0
- agentlegatus-0.1.0/agentlegatus/memory/__init__.py +15 -0
- agentlegatus-0.1.0/agentlegatus/memory/base.py +111 -0
- agentlegatus-0.1.0/agentlegatus/memory/manager.py +140 -0
- agentlegatus-0.1.0/agentlegatus/memory/redis_backend.py +142 -0
- agentlegatus-0.1.0/agentlegatus/memory/vector_backend.py +166 -0
- agentlegatus-0.1.0/agentlegatus/observability/__init__.py +28 -0
- agentlegatus-0.1.0/agentlegatus/observability/benchmark.py +315 -0
- agentlegatus-0.1.0/agentlegatus/observability/metrics.py +483 -0
- agentlegatus-0.1.0/agentlegatus/observability/prometheus.py +213 -0
- agentlegatus-0.1.0/agentlegatus/observability/tracing.py +464 -0
- agentlegatus-0.1.0/agentlegatus/providers/__init__.py +14 -0
- agentlegatus-0.1.0/agentlegatus/providers/base.py +169 -0
- agentlegatus-0.1.0/agentlegatus/providers/langgraph.py +210 -0
- agentlegatus-0.1.0/agentlegatus/providers/mock.py +175 -0
- agentlegatus-0.1.0/agentlegatus/providers/registry.py +155 -0
- agentlegatus-0.1.0/agentlegatus/security/__init__.py +66 -0
- agentlegatus-0.1.0/agentlegatus/security/access_control.py +70 -0
- agentlegatus-0.1.0/agentlegatus/security/audit.py +79 -0
- agentlegatus-0.1.0/agentlegatus/security/http_client.py +159 -0
- agentlegatus-0.1.0/agentlegatus/security/pii.py +39 -0
- agentlegatus-0.1.0/agentlegatus/security/rate_limiter.py +70 -0
- agentlegatus-0.1.0/agentlegatus/security/sanitization.py +149 -0
- agentlegatus-0.1.0/agentlegatus/security/validation.py +176 -0
- agentlegatus-0.1.0/agentlegatus/tools/__init__.py +10 -0
- agentlegatus-0.1.0/agentlegatus/tools/registry.py +99 -0
- agentlegatus-0.1.0/agentlegatus/tools/tool.py +138 -0
- agentlegatus-0.1.0/agentlegatus/utils/__init__.py +22 -0
- agentlegatus-0.1.0/agentlegatus/utils/logging.py +235 -0
- agentlegatus-0.1.0/agentlegatus/utils/retry.py +178 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/PKG-INFO +245 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/SOURCES.txt +59 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/dependency_links.txt +1 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/entry_points.txt +2 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/requires.txt +54 -0
- agentlegatus-0.1.0/agentlegatus.egg-info/top_level.txt +1 -0
- agentlegatus-0.1.0/pyproject.toml +155 -0
- agentlegatus-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: agentlegatus
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Vendor-agnostic agent framework abstraction layer - Terraform for AI Agents
|
|
5
|
+
Author: AgentLegatus Contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/agentlegatus/agentlegatus
|
|
8
|
+
Project-URL: Documentation, https://agentlegatus.readthedocs.io
|
|
9
|
+
Project-URL: Repository, https://github.com/agentlegatus/agentlegatus
|
|
10
|
+
Project-URL: Issues, https://github.com/agentlegatus/agentlegatus/issues
|
|
11
|
+
Keywords: ai,agents,framework,orchestration,multi-agent
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
Requires-Dist: click>=8.1.0
|
|
22
|
+
Requires-Dist: pydantic>=2.0.0
|
|
23
|
+
Requires-Dist: httpx>=0.24.0
|
|
24
|
+
Requires-Dist: rich>=13.0.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Provides-Extra: all
|
|
27
|
+
Requires-Dist: langgraph>=0.1.0; extra == "all"
|
|
28
|
+
Requires-Dist: langchain>=0.1.0; extra == "all"
|
|
29
|
+
Requires-Dist: redis>=5.0.0; extra == "all"
|
|
30
|
+
Requires-Dist: aioredis>=2.0.0; extra == "all"
|
|
31
|
+
Requires-Dist: asyncpg>=0.28.0; extra == "all"
|
|
32
|
+
Requires-Dist: chromadb>=0.4.0; extra == "all"
|
|
33
|
+
Requires-Dist: opentelemetry-api>=1.20.0; extra == "all"
|
|
34
|
+
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "all"
|
|
35
|
+
Requires-Dist: prometheus-client>=0.17.0; extra == "all"
|
|
36
|
+
Requires-Dist: structlog>=23.1.0; extra == "all"
|
|
37
|
+
Provides-Extra: langgraph
|
|
38
|
+
Requires-Dist: langgraph>=0.1.0; extra == "langgraph"
|
|
39
|
+
Requires-Dist: langchain>=0.1.0; extra == "langgraph"
|
|
40
|
+
Provides-Extra: redis
|
|
41
|
+
Requires-Dist: redis>=5.0.0; extra == "redis"
|
|
42
|
+
Requires-Dist: aioredis>=2.0.0; extra == "redis"
|
|
43
|
+
Provides-Extra: postgres
|
|
44
|
+
Requires-Dist: asyncpg>=0.28.0; extra == "postgres"
|
|
45
|
+
Provides-Extra: vector
|
|
46
|
+
Requires-Dist: chromadb>=0.4.0; extra == "vector"
|
|
47
|
+
Provides-Extra: observability
|
|
48
|
+
Requires-Dist: opentelemetry-api>=1.20.0; extra == "observability"
|
|
49
|
+
Requires-Dist: opentelemetry-sdk>=1.20.0; extra == "observability"
|
|
50
|
+
Requires-Dist: prometheus-client>=0.17.0; extra == "observability"
|
|
51
|
+
Requires-Dist: structlog>=23.1.0; extra == "observability"
|
|
52
|
+
Provides-Extra: dev
|
|
53
|
+
Requires-Dist: pytest>=7.4.0; extra == "dev"
|
|
54
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
55
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "dev"
|
|
56
|
+
Requires-Dist: pytest-mock>=3.11.0; extra == "dev"
|
|
57
|
+
Requires-Dist: black>=23.9.0; extra == "dev"
|
|
58
|
+
Requires-Dist: ruff>=0.0.292; extra == "dev"
|
|
59
|
+
Requires-Dist: mypy>=1.5.0; extra == "dev"
|
|
60
|
+
Requires-Dist: isort>=5.12.0; extra == "dev"
|
|
61
|
+
Provides-Extra: test
|
|
62
|
+
Requires-Dist: pytest>=7.4.0; extra == "test"
|
|
63
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "test"
|
|
64
|
+
Requires-Dist: pytest-cov>=4.1.0; extra == "test"
|
|
65
|
+
Requires-Dist: pytest-mock>=3.11.0; extra == "test"
|
|
66
|
+
Requires-Dist: hypothesis>=6.88.0; extra == "test"
|
|
67
|
+
|
|
68
|
+
# AgentLegatus
|
|
69
|
+
|
|
70
|
+
Vendor-agnostic agent framework abstraction layer — Terraform for AI Agents.
|
|
71
|
+
|
|
72
|
+
Switch between AI agent frameworks (LangGraph, AutoGen, CrewAI, Google ADK, AWS Strands, Microsoft Agent Framework) with minimal configuration changes. AgentLegatus provides a unified API, a Roman military hierarchy for orchestrating multi-agent workflows, and built-in benchmarking to compare providers side by side.
|
|
73
|
+
|
|
74
|
+
## Quick Start
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Install core
|
|
78
|
+
pip install -e .
|
|
79
|
+
|
|
80
|
+
# Install with all optional backends
|
|
81
|
+
pip install -e ".[all]"
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Define and run a workflow
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
import asyncio
|
|
88
|
+
from agentlegatus.core.event_bus import EventBus
|
|
89
|
+
from agentlegatus.core.executor import WorkflowExecutor
|
|
90
|
+
from agentlegatus.core.state import InMemoryStateBackend, StateManager
|
|
91
|
+
from agentlegatus.core.workflow import (
|
|
92
|
+
ExecutionStrategy, WorkflowDefinition, WorkflowStep,
|
|
93
|
+
)
|
|
94
|
+
from agentlegatus.hierarchy.legatus import Legatus
|
|
95
|
+
from agentlegatus.providers.mock import MockProvider
|
|
96
|
+
from agentlegatus.tools.registry import ToolRegistry
|
|
97
|
+
|
|
98
|
+
async def main():
|
|
99
|
+
event_bus = EventBus()
|
|
100
|
+
state_manager = StateManager(InMemoryStateBackend(), event_bus=event_bus)
|
|
101
|
+
provider = MockProvider(config={})
|
|
102
|
+
executor = WorkflowExecutor(provider, state_manager, ToolRegistry(), event_bus)
|
|
103
|
+
|
|
104
|
+
workflow = WorkflowDefinition(
|
|
105
|
+
workflow_id="hello",
|
|
106
|
+
name="Hello Workflow",
|
|
107
|
+
version="1.0.0",
|
|
108
|
+
provider="mock",
|
|
109
|
+
execution_strategy=ExecutionStrategy.SEQUENTIAL,
|
|
110
|
+
steps=[
|
|
111
|
+
WorkflowStep(step_id="greet", step_type="agent", config={"agent_id": "greeter"}),
|
|
112
|
+
],
|
|
113
|
+
)
|
|
114
|
+
|
|
115
|
+
legatus = Legatus(config={}, event_bus=event_bus)
|
|
116
|
+
result = await legatus.execute_workflow(workflow, executor=executor, state_manager=state_manager)
|
|
117
|
+
print(f"Status: {result.status.value}, Time: {result.execution_time:.3f}s")
|
|
118
|
+
|
|
119
|
+
asyncio.run(main())
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### CLI
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
legatus init --provider mock
|
|
126
|
+
legatus apply workflow.yaml
|
|
127
|
+
legatus apply workflow.yaml --dry-run
|
|
128
|
+
legatus plan workflow.yaml
|
|
129
|
+
legatus benchmark workflow.yaml --providers mock,langgraph --iterations 5
|
|
130
|
+
legatus switch langgraph
|
|
131
|
+
legatus providers
|
|
132
|
+
legatus status <workflow-id>
|
|
133
|
+
legatus cancel <workflow-id>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Architecture
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
CLI (legatus)
|
|
140
|
+
└── Legatus (Orchestrator)
|
|
141
|
+
├── EventBus ──► Observability (OpenTelemetry, Prometheus)
|
|
142
|
+
├── StateManager (in-memory / Redis / Postgres)
|
|
143
|
+
└── Centurion (Workflow Controller)
|
|
144
|
+
├── Sequential / Parallel / Conditional execution
|
|
145
|
+
└── Cohort (Agent Group)
|
|
146
|
+
└── Agent (Worker)
|
|
147
|
+
├── ToolRegistry
|
|
148
|
+
└── MemoryManager
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Features
|
|
152
|
+
|
|
153
|
+
- **Provider Abstraction** — `BaseProvider` interface with runtime switching and state migration via Portable Execution Graphs
|
|
154
|
+
- **Roman Hierarchy** — Legatus → Centurion → Cohort → Agent, with sequential, parallel, and conditional execution strategies
|
|
155
|
+
- **Event-Driven** — Unified `EventBus` with subscription, history, correlation/trace ID propagation
|
|
156
|
+
- **State Management** — Scoped state (workflow/step/agent/global) with snapshot/restore, backed by in-memory, Redis, or Postgres
|
|
157
|
+
- **Tool Registry** — Register tools once, auto-convert to OpenAI/Anthropic formats, cached per provider
|
|
158
|
+
- **Memory Abstraction** — Short-term (TTL), long-term, episodic, and semantic memory types with Redis and vector store backends
|
|
159
|
+
- **Benchmark Engine** — Run identical workflows across providers, compare latency (p50/p95/p99), cost, tokens, and success rate
|
|
160
|
+
- **Observability** — OpenTelemetry tracing, Prometheus metrics export, structured logging via structlog
|
|
161
|
+
- **Security** — Input sanitization, path traversal prevention, PII detection/redaction, rate limiting, audit logging, HTTPS with cert validation
|
|
162
|
+
- **Checkpoint & Recovery** — Checkpoint workflow state for resumption after failures or timeouts
|
|
163
|
+
- **Retry Logic** — Configurable exponential backoff with max delay capping
|
|
164
|
+
|
|
165
|
+
## Optional Dependencies
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
pip install -e ".[langgraph]" # LangGraph provider
|
|
169
|
+
pip install -e ".[redis]" # Redis state/memory backend
|
|
170
|
+
pip install -e ".[postgres]" # Postgres state backend
|
|
171
|
+
pip install -e ".[vector]" # ChromaDB vector memory
|
|
172
|
+
pip install -e ".[observability]" # OpenTelemetry + Prometheus + structlog
|
|
173
|
+
pip install -e ".[dev]" # black, ruff, mypy, isort
|
|
174
|
+
pip install -e ".[test]" # pytest, hypothesis, coverage
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Configuration
|
|
178
|
+
|
|
179
|
+
AgentLegatus supports YAML/JSON config files with environment variable overrides:
|
|
180
|
+
|
|
181
|
+
```yaml
|
|
182
|
+
default_provider: mock
|
|
183
|
+
providers:
|
|
184
|
+
- name: mock
|
|
185
|
+
- name: openai
|
|
186
|
+
api_key: ${OPENAI_API_KEY}
|
|
187
|
+
state:
|
|
188
|
+
backend: memory
|
|
189
|
+
memory:
|
|
190
|
+
backend: memory
|
|
191
|
+
observability:
|
|
192
|
+
enable_tracing: false
|
|
193
|
+
enable_prometheus: false
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Load via code or CLI:
|
|
197
|
+
|
|
198
|
+
```python
|
|
199
|
+
from agentlegatus.config.loader import ConfigLoader
|
|
200
|
+
config = ConfigLoader.load("agentlegatus.yaml")
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## Examples
|
|
204
|
+
|
|
205
|
+
See the `examples/` directory:
|
|
206
|
+
|
|
207
|
+
| File | Description |
|
|
208
|
+
|------|-------------|
|
|
209
|
+
| `basic_workflow.py` | Sequential workflow execution |
|
|
210
|
+
| `provider_switching.py` | Runtime provider switching with state preservation |
|
|
211
|
+
| `benchmark.py` | Cross-provider benchmarking |
|
|
212
|
+
| `event_monitoring.py` | Event subscription and real-time monitoring |
|
|
213
|
+
| `custom_tools.py` | Tool creation and registration |
|
|
214
|
+
| `state_management.py` | State operations, snapshots, and restore |
|
|
215
|
+
|
|
216
|
+
## Development
|
|
217
|
+
|
|
218
|
+
```bash
|
|
219
|
+
# Install dev + test dependencies
|
|
220
|
+
pip install -e ".[dev,test]"
|
|
221
|
+
|
|
222
|
+
# Run all tests (936 tests, 88% coverage)
|
|
223
|
+
pytest
|
|
224
|
+
|
|
225
|
+
# Run by category
|
|
226
|
+
pytest tests/unit/
|
|
227
|
+
pytest tests/integration/
|
|
228
|
+
pytest tests/property/
|
|
229
|
+
|
|
230
|
+
# Coverage report
|
|
231
|
+
pytest --cov=agentlegatus --cov-report=html
|
|
232
|
+
|
|
233
|
+
# Linting
|
|
234
|
+
ruff check agentlegatus/
|
|
235
|
+
black --check agentlegatus/
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## Requirements
|
|
239
|
+
|
|
240
|
+
- Python 3.10+
|
|
241
|
+
- Core: click, pydantic, httpx, rich, pyyaml
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# AgentLegatus
|
|
2
|
+
|
|
3
|
+
Vendor-agnostic agent framework abstraction layer — Terraform for AI Agents.
|
|
4
|
+
|
|
5
|
+
Switch between AI agent frameworks (LangGraph, AutoGen, CrewAI, Google ADK, AWS Strands, Microsoft Agent Framework) with minimal configuration changes. AgentLegatus provides a unified API, a Roman military hierarchy for orchestrating multi-agent workflows, and built-in benchmarking to compare providers side by side.
|
|
6
|
+
|
|
7
|
+
## Quick Start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Install core
|
|
11
|
+
pip install -e .
|
|
12
|
+
|
|
13
|
+
# Install with all optional backends
|
|
14
|
+
pip install -e ".[all]"
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Define and run a workflow
|
|
18
|
+
|
|
19
|
+
```python
|
|
20
|
+
import asyncio
|
|
21
|
+
from agentlegatus.core.event_bus import EventBus
|
|
22
|
+
from agentlegatus.core.executor import WorkflowExecutor
|
|
23
|
+
from agentlegatus.core.state import InMemoryStateBackend, StateManager
|
|
24
|
+
from agentlegatus.core.workflow import (
|
|
25
|
+
ExecutionStrategy, WorkflowDefinition, WorkflowStep,
|
|
26
|
+
)
|
|
27
|
+
from agentlegatus.hierarchy.legatus import Legatus
|
|
28
|
+
from agentlegatus.providers.mock import MockProvider
|
|
29
|
+
from agentlegatus.tools.registry import ToolRegistry
|
|
30
|
+
|
|
31
|
+
async def main():
|
|
32
|
+
event_bus = EventBus()
|
|
33
|
+
state_manager = StateManager(InMemoryStateBackend(), event_bus=event_bus)
|
|
34
|
+
provider = MockProvider(config={})
|
|
35
|
+
executor = WorkflowExecutor(provider, state_manager, ToolRegistry(), event_bus)
|
|
36
|
+
|
|
37
|
+
workflow = WorkflowDefinition(
|
|
38
|
+
workflow_id="hello",
|
|
39
|
+
name="Hello Workflow",
|
|
40
|
+
version="1.0.0",
|
|
41
|
+
provider="mock",
|
|
42
|
+
execution_strategy=ExecutionStrategy.SEQUENTIAL,
|
|
43
|
+
steps=[
|
|
44
|
+
WorkflowStep(step_id="greet", step_type="agent", config={"agent_id": "greeter"}),
|
|
45
|
+
],
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
legatus = Legatus(config={}, event_bus=event_bus)
|
|
49
|
+
result = await legatus.execute_workflow(workflow, executor=executor, state_manager=state_manager)
|
|
50
|
+
print(f"Status: {result.status.value}, Time: {result.execution_time:.3f}s")
|
|
51
|
+
|
|
52
|
+
asyncio.run(main())
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### CLI
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
legatus init --provider mock
|
|
59
|
+
legatus apply workflow.yaml
|
|
60
|
+
legatus apply workflow.yaml --dry-run
|
|
61
|
+
legatus plan workflow.yaml
|
|
62
|
+
legatus benchmark workflow.yaml --providers mock,langgraph --iterations 5
|
|
63
|
+
legatus switch langgraph
|
|
64
|
+
legatus providers
|
|
65
|
+
legatus status <workflow-id>
|
|
66
|
+
legatus cancel <workflow-id>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Architecture
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
CLI (legatus)
|
|
73
|
+
└── Legatus (Orchestrator)
|
|
74
|
+
├── EventBus ──► Observability (OpenTelemetry, Prometheus)
|
|
75
|
+
├── StateManager (in-memory / Redis / Postgres)
|
|
76
|
+
└── Centurion (Workflow Controller)
|
|
77
|
+
├── Sequential / Parallel / Conditional execution
|
|
78
|
+
└── Cohort (Agent Group)
|
|
79
|
+
└── Agent (Worker)
|
|
80
|
+
├── ToolRegistry
|
|
81
|
+
└── MemoryManager
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Features
|
|
85
|
+
|
|
86
|
+
- **Provider Abstraction** — `BaseProvider` interface with runtime switching and state migration via Portable Execution Graphs
|
|
87
|
+
- **Roman Hierarchy** — Legatus → Centurion → Cohort → Agent, with sequential, parallel, and conditional execution strategies
|
|
88
|
+
- **Event-Driven** — Unified `EventBus` with subscription, history, correlation/trace ID propagation
|
|
89
|
+
- **State Management** — Scoped state (workflow/step/agent/global) with snapshot/restore, backed by in-memory, Redis, or Postgres
|
|
90
|
+
- **Tool Registry** — Register tools once, auto-convert to OpenAI/Anthropic formats, cached per provider
|
|
91
|
+
- **Memory Abstraction** — Short-term (TTL), long-term, episodic, and semantic memory types with Redis and vector store backends
|
|
92
|
+
- **Benchmark Engine** — Run identical workflows across providers, compare latency (p50/p95/p99), cost, tokens, and success rate
|
|
93
|
+
- **Observability** — OpenTelemetry tracing, Prometheus metrics export, structured logging via structlog
|
|
94
|
+
- **Security** — Input sanitization, path traversal prevention, PII detection/redaction, rate limiting, audit logging, HTTPS with cert validation
|
|
95
|
+
- **Checkpoint & Recovery** — Checkpoint workflow state for resumption after failures or timeouts
|
|
96
|
+
- **Retry Logic** — Configurable exponential backoff with max delay capping
|
|
97
|
+
|
|
98
|
+
## Optional Dependencies
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
pip install -e ".[langgraph]" # LangGraph provider
|
|
102
|
+
pip install -e ".[redis]" # Redis state/memory backend
|
|
103
|
+
pip install -e ".[postgres]" # Postgres state backend
|
|
104
|
+
pip install -e ".[vector]" # ChromaDB vector memory
|
|
105
|
+
pip install -e ".[observability]" # OpenTelemetry + Prometheus + structlog
|
|
106
|
+
pip install -e ".[dev]" # black, ruff, mypy, isort
|
|
107
|
+
pip install -e ".[test]" # pytest, hypothesis, coverage
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Configuration
|
|
111
|
+
|
|
112
|
+
AgentLegatus supports YAML/JSON config files with environment variable overrides:
|
|
113
|
+
|
|
114
|
+
```yaml
|
|
115
|
+
default_provider: mock
|
|
116
|
+
providers:
|
|
117
|
+
- name: mock
|
|
118
|
+
- name: openai
|
|
119
|
+
api_key: ${OPENAI_API_KEY}
|
|
120
|
+
state:
|
|
121
|
+
backend: memory
|
|
122
|
+
memory:
|
|
123
|
+
backend: memory
|
|
124
|
+
observability:
|
|
125
|
+
enable_tracing: false
|
|
126
|
+
enable_prometheus: false
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Load via code or CLI:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
from agentlegatus.config.loader import ConfigLoader
|
|
133
|
+
config = ConfigLoader.load("agentlegatus.yaml")
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Examples
|
|
137
|
+
|
|
138
|
+
See the `examples/` directory:
|
|
139
|
+
|
|
140
|
+
| File | Description |
|
|
141
|
+
|------|-------------|
|
|
142
|
+
| `basic_workflow.py` | Sequential workflow execution |
|
|
143
|
+
| `provider_switching.py` | Runtime provider switching with state preservation |
|
|
144
|
+
| `benchmark.py` | Cross-provider benchmarking |
|
|
145
|
+
| `event_monitoring.py` | Event subscription and real-time monitoring |
|
|
146
|
+
| `custom_tools.py` | Tool creation and registration |
|
|
147
|
+
| `state_management.py` | State operations, snapshots, and restore |
|
|
148
|
+
|
|
149
|
+
## Development
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Install dev + test dependencies
|
|
153
|
+
pip install -e ".[dev,test]"
|
|
154
|
+
|
|
155
|
+
# Run all tests (936 tests, 88% coverage)
|
|
156
|
+
pytest
|
|
157
|
+
|
|
158
|
+
# Run by category
|
|
159
|
+
pytest tests/unit/
|
|
160
|
+
pytest tests/integration/
|
|
161
|
+
pytest tests/property/
|
|
162
|
+
|
|
163
|
+
# Coverage report
|
|
164
|
+
pytest --cov=agentlegatus --cov-report=html
|
|
165
|
+
|
|
166
|
+
# Linting
|
|
167
|
+
ruff check agentlegatus/
|
|
168
|
+
black --check agentlegatus/
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Requirements
|
|
172
|
+
|
|
173
|
+
- Python 3.10+
|
|
174
|
+
- Core: click, pydantic, httpx, rich, pyyaml
|
|
175
|
+
|
|
176
|
+
## License
|
|
177
|
+
|
|
178
|
+
MIT
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"""
|
|
2
|
+
AgentLegatus - Vendor-agnostic agent framework abstraction layer.
|
|
3
|
+
|
|
4
|
+
Terraform for AI Agents: Switch between different agent frameworks with a single line of code.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__version__ = "0.1.0"
|
|
8
|
+
|
|
9
|
+
from agentlegatus.core.workflow import WorkflowDefinition, WorkflowStatus, WorkflowStep
|
|
10
|
+
from agentlegatus.exceptions import (
|
|
11
|
+
AgentLegatusError,
|
|
12
|
+
CapabilityNotSupportedError,
|
|
13
|
+
MemoryOperationError,
|
|
14
|
+
ProviderNotFoundError,
|
|
15
|
+
ProviderSwitchError,
|
|
16
|
+
StateBackendUnavailableError,
|
|
17
|
+
WorkflowTimeoutError,
|
|
18
|
+
WorkflowValidationError,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__all__ = [
|
|
22
|
+
"AgentLegatusError",
|
|
23
|
+
"CapabilityNotSupportedError",
|
|
24
|
+
"MemoryOperationError",
|
|
25
|
+
"ProviderNotFoundError",
|
|
26
|
+
"ProviderSwitchError",
|
|
27
|
+
"StateBackendUnavailableError",
|
|
28
|
+
"WorkflowDefinition",
|
|
29
|
+
"WorkflowStep",
|
|
30
|
+
"WorkflowStatus",
|
|
31
|
+
"WorkflowTimeoutError",
|
|
32
|
+
"WorkflowValidationError",
|
|
33
|
+
]
|