legio 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.
- legio-0.1.0/PKG-INFO +117 -0
- legio-0.1.0/README.md +102 -0
- legio-0.1.0/pyproject.toml +46 -0
- legio-0.1.0/src/legio/__init__.py +9 -0
- legio-0.1.0/src/legio/__main__.py +6 -0
- legio-0.1.0/src/legio/agents/__init__.py +10 -0
- legio-0.1.0/src/legio/agents/base.py +708 -0
- legio-0.1.0/src/legio/agents/composite_agent.py +529 -0
- legio-0.1.0/src/legio/agents/linguistic_agent.py +109 -0
- legio-0.1.0/src/legio/agents/tool_agent.py +221 -0
- legio-0.1.0/src/legio/api.py +620 -0
- legio-0.1.0/src/legio/cli.py +848 -0
- legio-0.1.0/src/legio/config.py +598 -0
- legio-0.1.0/src/legio/errors.py +90 -0
- legio-0.1.0/src/legio/federation.py +556 -0
- legio-0.1.0/src/legio/flow/__init__.py +48 -0
- legio-0.1.0/src/legio/flow/control.py +196 -0
- legio-0.1.0/src/legio/flow/messages.py +93 -0
- legio-0.1.0/src/legio/flow/payload.py +33 -0
- legio-0.1.0/src/legio/flow/token.py +32 -0
- legio-0.1.0/src/legio/logging.py +52 -0
- legio-0.1.0/src/legio/manager/__init__.py +399 -0
- legio-0.1.0/src/legio/materializer.py +519 -0
- legio-0.1.0/src/legio/naming.py +145 -0
- legio-0.1.0/src/legio/patterns/__init__.py +39 -0
- legio-0.1.0/src/legio/patterns/compile.py +91 -0
- legio-0.1.0/src/legio/patterns/loader.py +472 -0
- legio-0.1.0/src/legio/patterns/schema1.py +290 -0
- legio-0.1.0/src/legio/patterns/sequences.py +41 -0
- legio-0.1.0/src/legio/patterns/template.py +49 -0
- legio-0.1.0/src/legio/py.typed +0 -0
- legio-0.1.0/src/legio/registry/__init__.py +442 -0
- legio-0.1.0/src/legio/runtime/__init__.py +1762 -0
- legio-0.1.0/src/legio/security/__init__.py +110 -0
- legio-0.1.0/src/legio/security/middleware.py +112 -0
- legio-0.1.0/src/legio/tools.py +134 -0
legio-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: legio
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Queue-based agentic orchestration engine (domain-free library).
|
|
5
|
+
Requires-Dist: beaver-db
|
|
6
|
+
Requires-Dist: lingo-ai
|
|
7
|
+
Requires-Dist: pydantic>=2
|
|
8
|
+
Requires-Dist: pyyaml
|
|
9
|
+
Requires-Dist: fastapi
|
|
10
|
+
Requires-Dist: uvicorn
|
|
11
|
+
Requires-Dist: httpx
|
|
12
|
+
Requires-Dist: typer
|
|
13
|
+
Requires-Python: >=3.13
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# legio
|
|
17
|
+
|
|
18
|
+
A queue-based agentic orchestration engine. Independent library, **domain-free**:
|
|
19
|
+
all domain knowledge lives in patterns (YAML as data) and a tool registry
|
|
20
|
+
provided by the consumer. The library never knows about any specific consumer;
|
|
21
|
+
validation happens through the in-repo examples (`examples/`) and external
|
|
22
|
+
consumer repositories kept separate (AGENTS.md rule 7).
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
uv run legio server --config examples/transform/legio.yaml --host 127.0.0.1 --port 8000
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
Then submit and poll status (see `docs/CONSUMER_GUIDE.md` for the full
|
|
31
|
+
walkthrough; the headless `transform` example boots with no LLM needed).
|
|
32
|
+
|
|
33
|
+
## Docs surface
|
|
34
|
+
|
|
35
|
+
- `docs/CONSUMER_GUIDE.md` — executable walkthrough: register a tool → write a
|
|
36
|
+
pattern → configure → boot → submit → status (validated by CI).
|
|
37
|
+
- `docs/GLOSSARY.md` — canonical definitions for the identifiers and
|
|
38
|
+
architecture terms.
|
|
39
|
+
- `docs/ARCHITECTURE.md` — the architecture (read before any work).
|
|
40
|
+
- `docs/AGENT_LIFECYCLE.md` — the class/instance lifecycle (§4.8) and the three
|
|
41
|
+
schemas (§4.11).
|
|
42
|
+
- `docs/CONTRIBUTING.md` — methodology, development flow, review checklist.
|
|
43
|
+
- `docs/PLAN.md` — the plan and issue roadmap; `docs/CONTRACTS/` holds the
|
|
44
|
+
per-issue approved specs.
|
|
45
|
+
- `docs/DEPENDENCIES.md` — the approved dependency list.
|
|
46
|
+
- `docs/JOURNALS/` — turn-by-turn journaling; read the latest before working.
|
|
47
|
+
|
|
48
|
+
## Examples
|
|
49
|
+
|
|
50
|
+
`examples/` ships four self-contained, domain-free example nodes — each with
|
|
51
|
+
its own `patterns/` (Schema 1 YAML), `tools.yaml` (Schema 3) and `legio.yaml`
|
|
52
|
+
(LEG-017): `transform`, `summarize`, `extract-and-summarize` and
|
|
53
|
+
`distribute-summary`. The same files are exercised by the test suite — drift
|
|
54
|
+
breaks the build (LEG-100, no bitrot).
|
|
55
|
+
|
|
56
|
+
## Engine in one breath
|
|
57
|
+
|
|
58
|
+
The public API never pushes (polling only, `next_run_at` scheduling): the host
|
|
59
|
+
drives `runtime.manager.run()` one pass per dispatch; each standing agent polls
|
|
60
|
+
its own beaver queue; the immutable Schema 2 `FlowToken` (`level_route`,
|
|
61
|
+
`current_index`, `end_of_level_queue`, `level`, `launcher_class`,
|
|
62
|
+
`task_id`, `branch_id`, `message_type`, `payload`) travels the routes; the
|
|
63
|
+
final result lands on the agent's shared final-result queue and is collected
|
|
64
|
+
into the task's outbox record that `/status` reads. Errors are typed
|
|
65
|
+
(`legio.errors`) and never silent (rule 9); every module logs structured
|
|
66
|
+
`key=value` events under the `legio.*` tree (rule 11).
|
|
67
|
+
|
|
68
|
+
## Core capabilities (current)
|
|
69
|
+
|
|
70
|
+
- **Schemas**: S1 one-spec-per-pattern YAML with mandatory symmetric contracts;
|
|
71
|
+
S2 the route token; S3 `available_tools` (`implementation` + `policy`).
|
|
72
|
+
- **Standing agents**: atomic `tool` and `linguistic` agents materialized at
|
|
73
|
+
boot, and unified `composite` agents whose branches reference other agents by
|
|
74
|
+
name (the composite's output build is the pattern's model, injected as a
|
|
75
|
+
concrete class); nothing is loaded dynamically at submit time.
|
|
76
|
+
- **Dynamic lifecycle**: class/instance verbs (create/enable/disable/destroy),
|
|
77
|
+
pools as capacity intent, bring-up leaves-first over the served catalog.
|
|
78
|
+
- **Runtime surface**: REST submit/status plus class/instance verb classes over
|
|
79
|
+
beaver queues with a client token store; `legio server` and `legio agent
|
|
80
|
+
<verb>` CLI.
|
|
81
|
+
- **Federation**: per-node catalogs, roster-based step routing over a beaver
|
|
82
|
+
routing proxy — peers never widen scope (rule 9).
|
|
83
|
+
|
|
84
|
+
## State
|
|
85
|
+
|
|
86
|
+
R-0..R-9 core is **shipped** on the three-schema, decoupled polling engine
|
|
87
|
+
(exact per-issue status lives in `docs/CONTRACTS/` and `docs/JOURNALS/`).
|
|
88
|
+
R-10 (Hardening & release) is the current track: the `LEG-103`
|
|
89
|
+
audit-hardening series (contract-first slices, all green) and this session's
|
|
90
|
+
`LEG-100` docs & examples hardening (consumer guide + glossary + example tree)
|
|
91
|
+
await maintainer review; `LEG-101` (semver, packaging, changelog, tags) and
|
|
92
|
+
`LEG-102` come next on the release track.
|
|
93
|
+
|
|
94
|
+
## Development
|
|
95
|
+
|
|
96
|
+
`make ci` mirrors the CI gate exactly: lint (`ruff check`) + format check
|
|
97
|
+
(`ruff format --check`) + typecheck (`pyright`) + full `pytest`. Convenience
|
|
98
|
+
targets: `make sync`, `make lint`, `make format`, `make format-check`,
|
|
99
|
+
`make typecheck`, `make test`, `make build` (LEG-101 wheel/archive), `make
|
|
100
|
+
clean`, `make tag`/`make release` (maintainer only). Two known gates currently
|
|
101
|
+
show the documented baseline debt — `ruff format --check` (56 files, triage
|
|
102
|
+
from Session 108) and the 2 pyright false positives in
|
|
103
|
+
`tests/test_leg103_slice13_hardening.py`; both are tracked in `docs/JOURNALS/`
|
|
104
|
+
and kept separate from per-issue work. Everything in this repo is English
|
|
105
|
+
(AGENTS.md rule 1); work is per-issue, contract-first, and every turn ends
|
|
106
|
+
with a journal commit.
|
|
107
|
+
|
|
108
|
+
## Developed By
|
|
109
|
+
|
|
110
|
+
Legio is a collaborative open-source project co-developed by:
|
|
111
|
+
|
|
112
|
+
- **GIA-UH** — Grupo de Inteligencia Artificial, Universidad de La Habana
|
|
113
|
+
- **Syalia S.R.L.**
|
|
114
|
+
|
|
115
|
+
## License
|
|
116
|
+
|
|
117
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
legio-0.1.0/README.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# legio
|
|
2
|
+
|
|
3
|
+
A queue-based agentic orchestration engine. Independent library, **domain-free**:
|
|
4
|
+
all domain knowledge lives in patterns (YAML as data) and a tool registry
|
|
5
|
+
provided by the consumer. The library never knows about any specific consumer;
|
|
6
|
+
validation happens through the in-repo examples (`examples/`) and external
|
|
7
|
+
consumer repositories kept separate (AGENTS.md rule 7).
|
|
8
|
+
|
|
9
|
+
## Quick start
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
uv run legio server --config examples/transform/legio.yaml --host 127.0.0.1 --port 8000
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Then submit and poll status (see `docs/CONSUMER_GUIDE.md` for the full
|
|
16
|
+
walkthrough; the headless `transform` example boots with no LLM needed).
|
|
17
|
+
|
|
18
|
+
## Docs surface
|
|
19
|
+
|
|
20
|
+
- `docs/CONSUMER_GUIDE.md` — executable walkthrough: register a tool → write a
|
|
21
|
+
pattern → configure → boot → submit → status (validated by CI).
|
|
22
|
+
- `docs/GLOSSARY.md` — canonical definitions for the identifiers and
|
|
23
|
+
architecture terms.
|
|
24
|
+
- `docs/ARCHITECTURE.md` — the architecture (read before any work).
|
|
25
|
+
- `docs/AGENT_LIFECYCLE.md` — the class/instance lifecycle (§4.8) and the three
|
|
26
|
+
schemas (§4.11).
|
|
27
|
+
- `docs/CONTRIBUTING.md` — methodology, development flow, review checklist.
|
|
28
|
+
- `docs/PLAN.md` — the plan and issue roadmap; `docs/CONTRACTS/` holds the
|
|
29
|
+
per-issue approved specs.
|
|
30
|
+
- `docs/DEPENDENCIES.md` — the approved dependency list.
|
|
31
|
+
- `docs/JOURNALS/` — turn-by-turn journaling; read the latest before working.
|
|
32
|
+
|
|
33
|
+
## Examples
|
|
34
|
+
|
|
35
|
+
`examples/` ships four self-contained, domain-free example nodes — each with
|
|
36
|
+
its own `patterns/` (Schema 1 YAML), `tools.yaml` (Schema 3) and `legio.yaml`
|
|
37
|
+
(LEG-017): `transform`, `summarize`, `extract-and-summarize` and
|
|
38
|
+
`distribute-summary`. The same files are exercised by the test suite — drift
|
|
39
|
+
breaks the build (LEG-100, no bitrot).
|
|
40
|
+
|
|
41
|
+
## Engine in one breath
|
|
42
|
+
|
|
43
|
+
The public API never pushes (polling only, `next_run_at` scheduling): the host
|
|
44
|
+
drives `runtime.manager.run()` one pass per dispatch; each standing agent polls
|
|
45
|
+
its own beaver queue; the immutable Schema 2 `FlowToken` (`level_route`,
|
|
46
|
+
`current_index`, `end_of_level_queue`, `level`, `launcher_class`,
|
|
47
|
+
`task_id`, `branch_id`, `message_type`, `payload`) travels the routes; the
|
|
48
|
+
final result lands on the agent's shared final-result queue and is collected
|
|
49
|
+
into the task's outbox record that `/status` reads. Errors are typed
|
|
50
|
+
(`legio.errors`) and never silent (rule 9); every module logs structured
|
|
51
|
+
`key=value` events under the `legio.*` tree (rule 11).
|
|
52
|
+
|
|
53
|
+
## Core capabilities (current)
|
|
54
|
+
|
|
55
|
+
- **Schemas**: S1 one-spec-per-pattern YAML with mandatory symmetric contracts;
|
|
56
|
+
S2 the route token; S3 `available_tools` (`implementation` + `policy`).
|
|
57
|
+
- **Standing agents**: atomic `tool` and `linguistic` agents materialized at
|
|
58
|
+
boot, and unified `composite` agents whose branches reference other agents by
|
|
59
|
+
name (the composite's output build is the pattern's model, injected as a
|
|
60
|
+
concrete class); nothing is loaded dynamically at submit time.
|
|
61
|
+
- **Dynamic lifecycle**: class/instance verbs (create/enable/disable/destroy),
|
|
62
|
+
pools as capacity intent, bring-up leaves-first over the served catalog.
|
|
63
|
+
- **Runtime surface**: REST submit/status plus class/instance verb classes over
|
|
64
|
+
beaver queues with a client token store; `legio server` and `legio agent
|
|
65
|
+
<verb>` CLI.
|
|
66
|
+
- **Federation**: per-node catalogs, roster-based step routing over a beaver
|
|
67
|
+
routing proxy — peers never widen scope (rule 9).
|
|
68
|
+
|
|
69
|
+
## State
|
|
70
|
+
|
|
71
|
+
R-0..R-9 core is **shipped** on the three-schema, decoupled polling engine
|
|
72
|
+
(exact per-issue status lives in `docs/CONTRACTS/` and `docs/JOURNALS/`).
|
|
73
|
+
R-10 (Hardening & release) is the current track: the `LEG-103`
|
|
74
|
+
audit-hardening series (contract-first slices, all green) and this session's
|
|
75
|
+
`LEG-100` docs & examples hardening (consumer guide + glossary + example tree)
|
|
76
|
+
await maintainer review; `LEG-101` (semver, packaging, changelog, tags) and
|
|
77
|
+
`LEG-102` come next on the release track.
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
`make ci` mirrors the CI gate exactly: lint (`ruff check`) + format check
|
|
82
|
+
(`ruff format --check`) + typecheck (`pyright`) + full `pytest`. Convenience
|
|
83
|
+
targets: `make sync`, `make lint`, `make format`, `make format-check`,
|
|
84
|
+
`make typecheck`, `make test`, `make build` (LEG-101 wheel/archive), `make
|
|
85
|
+
clean`, `make tag`/`make release` (maintainer only). Two known gates currently
|
|
86
|
+
show the documented baseline debt — `ruff format --check` (56 files, triage
|
|
87
|
+
from Session 108) and the 2 pyright false positives in
|
|
88
|
+
`tests/test_leg103_slice13_hardening.py`; both are tracked in `docs/JOURNALS/`
|
|
89
|
+
and kept separate from per-issue work. Everything in this repo is English
|
|
90
|
+
(AGENTS.md rule 1); work is per-issue, contract-first, and every turn ends
|
|
91
|
+
with a journal commit.
|
|
92
|
+
|
|
93
|
+
## Developed By
|
|
94
|
+
|
|
95
|
+
Legio is a collaborative open-source project co-developed by:
|
|
96
|
+
|
|
97
|
+
- **GIA-UH** — Grupo de Inteligencia Artificial, Universidad de La Habana
|
|
98
|
+
- **Syalia S.R.L.**
|
|
99
|
+
|
|
100
|
+
## License
|
|
101
|
+
|
|
102
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "legio"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Queue-based agentic orchestration engine (domain-free library)."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.13"
|
|
7
|
+
dependencies = [
|
|
8
|
+
"beaver-db",
|
|
9
|
+
"lingo-ai",
|
|
10
|
+
"pydantic>=2",
|
|
11
|
+
"pyyaml",
|
|
12
|
+
"fastapi",
|
|
13
|
+
"uvicorn",
|
|
14
|
+
"httpx",
|
|
15
|
+
"typer",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[project.scripts]
|
|
19
|
+
legio = "legio.cli:main"
|
|
20
|
+
|
|
21
|
+
[dependency-groups]
|
|
22
|
+
dev = [
|
|
23
|
+
"ruff",
|
|
24
|
+
"pytest",
|
|
25
|
+
"pytest-asyncio",
|
|
26
|
+
"respx",
|
|
27
|
+
"pyright",
|
|
28
|
+
"pypdf>=6.19.0",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["uv_build>=0.11.8,<0.12.0"]
|
|
33
|
+
build-backend = "uv_build"
|
|
34
|
+
|
|
35
|
+
[tool.ruff]
|
|
36
|
+
target-version = "py313"
|
|
37
|
+
line-length = 100
|
|
38
|
+
|
|
39
|
+
[tool.pyright]
|
|
40
|
+
pythonVersion = "3.13"
|
|
41
|
+
typeCheckingMode = "standard"
|
|
42
|
+
venvPath = "."
|
|
43
|
+
venv = ".venv"
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
asyncio_mode = "auto"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""`legio.agents` — agent runners that execute pattern steps."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from .base import AgentBase
|
|
6
|
+
from .composite_agent import CompositeAgent
|
|
7
|
+
from .linguistic_agent import LinguisticAgent
|
|
8
|
+
from .tool_agent import ToolAgent
|
|
9
|
+
|
|
10
|
+
__all__ = ["AgentBase", "CompositeAgent", "LinguisticAgent", "ToolAgent"]
|