okf-agentbus 0.2.3__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.
- okf_agentbus-0.2.3/.gitignore +7 -0
- okf_agentbus-0.2.3/CHANGELOG.md +60 -0
- okf_agentbus-0.2.3/CONTRIBUTING.md +49 -0
- okf_agentbus-0.2.3/LICENSE +21 -0
- okf_agentbus-0.2.3/PKG-INFO +195 -0
- okf_agentbus-0.2.3/README.md +167 -0
- okf_agentbus-0.2.3/ROADMAP.md +57 -0
- okf_agentbus-0.2.3/docs/AUTH.md +51 -0
- okf_agentbus-0.2.3/docs/MCP_SCHEMA.md +189 -0
- okf_agentbus-0.2.3/examples/mcp-claude-desktop.json +12 -0
- okf_agentbus-0.2.3/examples/mcp-cursor.json +12 -0
- okf_agentbus-0.2.3/examples/mcp-hermes.json +12 -0
- okf_agentbus-0.2.3/pyproject.toml +64 -0
- okf_agentbus-0.2.3/scripts/mcp-serve.sh +23 -0
- okf_agentbus-0.2.3/src/agentbus/__init__.py +3 -0
- okf_agentbus-0.2.3/src/agentbus/auth.py +81 -0
- okf_agentbus-0.2.3/src/agentbus/cli.py +343 -0
- okf_agentbus-0.2.3/src/agentbus/leases.py +202 -0
- okf_agentbus-0.2.3/src/agentbus/project_log.py +117 -0
- okf_agentbus-0.2.3/src/agentbus/schemas.py +85 -0
- okf_agentbus-0.2.3/src/agentbus/server.py +160 -0
- okf_agentbus-0.2.3/src/agentbus/store.py +172 -0
- okf_agentbus-0.2.3/tests/factory_validate.py +298 -0
- okf_agentbus-0.2.3/tests/test_auth.py +86 -0
- okf_agentbus-0.2.3/tests/test_cli.py +48 -0
- okf_agentbus-0.2.3/tests/test_cli_lock.py +85 -0
- okf_agentbus-0.2.3/tests/test_factory_mcp_validation.py +17 -0
- okf_agentbus-0.2.3/tests/test_leases.py +135 -0
- okf_agentbus-0.2.3/tests/test_mcp_stdio.py +103 -0
- okf_agentbus-0.2.3/tests/test_project_log.py +105 -0
- okf_agentbus-0.2.3/tests/test_retention.py +38 -0
- okf_agentbus-0.2.3/tests/test_schemas.py +52 -0
- okf_agentbus-0.2.3/tests/test_store.py +64 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here.
|
|
4
|
+
|
|
5
|
+
## [0.2.3] - 2026-07-07
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- PyPI package renamed to **`okf-agentbus`** — `agentbus-mcp` rejected as too similar to existing `agentbus` project
|
|
10
|
+
|
|
11
|
+
## [0.2.2] - 2026-07-07
|
|
12
|
+
|
|
13
|
+
### Added
|
|
14
|
+
|
|
15
|
+
- `tests/factory_validate.py` — MCP integration validation (Agy event-56 criteria)
|
|
16
|
+
- `tests/test_factory_mcp_validation.py` — pytest `@integration` wrapper
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Integration validation: real TTL wait, 3-client concurrency hammer, MCP-only auth test
|
|
21
|
+
|
|
22
|
+
## [0.2.1] - 2026-07-07
|
|
23
|
+
|
|
24
|
+
### Fixed
|
|
25
|
+
|
|
26
|
+
- MCP auth: workspace token file now wins over stale `AGENTBUS_TOKEN` env in subprocesses
|
|
27
|
+
- `mcp-serve.sh` resolves `agentbus` from `$PATH` (pip install) before repo venv
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
|
|
31
|
+
- PyPI package renamed to **`agentbus-mcp`** (avoids collision with unrelated `agentbus` NATS project)
|
|
32
|
+
- Docs updated to v0.2: lease tools, 40 tests, Hermes MCP example
|
|
33
|
+
- MCP integration tests for lock tools
|
|
34
|
+
|
|
35
|
+
## [0.2.0] - 2026-07-07
|
|
36
|
+
|
|
37
|
+
### Added
|
|
38
|
+
|
|
39
|
+
- Phase 5 advisory lease locks in `events.db` (`leases` table)
|
|
40
|
+
- MCP tools: `agentbus_lock_acquire`, `agentbus_lock_release`, `agentbus_lock_renew`, `agentbus_lock_status`
|
|
41
|
+
- CLI: `agentbus lock acquire|release|renew|status`
|
|
42
|
+
- `tests/test_leases.py` — acquire, conflict, renew, TTL expiry, auth, workspace boundary
|
|
43
|
+
|
|
44
|
+
## [0.1.0] - 2026-07-07
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
|
|
48
|
+
- MCP stdio server with `agentbus_publish`, `agentbus_poll`, `agentbus_status`
|
|
49
|
+
- SQLite event store with idempotency and retention
|
|
50
|
+
- Workspace ephemeral token authentication (`{workspace}/.agentbus/token`)
|
|
51
|
+
- CLI: `serve`, `publish`, `poll`, `status`, `token`, `project-log`
|
|
52
|
+
- `scripts/mcp-serve.sh` wrapper for MCP client token injection
|
|
53
|
+
- Reference topics: `okf/handoff`, `okf/status/<initiative>`
|
|
54
|
+
- 22 tests including MCP stdio round-trip
|
|
55
|
+
|
|
56
|
+
[0.2.3]: https://github.com/onicarps/agentbus/releases/tag/v0.2.3
|
|
57
|
+
[0.2.2]: https://github.com/onicarps/agentbus/releases/tag/v0.2.2
|
|
58
|
+
[0.2.1]: https://github.com/onicarps/agentbus/releases/tag/v0.2.1
|
|
59
|
+
[0.2.0]: https://github.com/onicarps/agentbus/releases/tag/v0.2.0
|
|
60
|
+
[0.1.0]: https://github.com/onicarps/agentbus/releases/tag/v0.1.0
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing to AgentBus
|
|
2
|
+
|
|
3
|
+
Thank you for helping make multi-agent local coordination better for everyone.
|
|
4
|
+
|
|
5
|
+
## Quick start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
git clone https://github.com/onicarps/agentbus.git
|
|
9
|
+
cd agentbus
|
|
10
|
+
python3 -m venv .venv
|
|
11
|
+
.venv/bin/pip install -e ".[dev]"
|
|
12
|
+
.venv/bin/pytest tests/ -q
|
|
13
|
+
python tests/factory_validate.py # MCP integration validation (Agy gate)
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## What to work on
|
|
17
|
+
|
|
18
|
+
See [ROADMAP.md](ROADMAP.md) and [open issues](https://github.com/onicarps/agentbus/issues). High-value contribution areas:
|
|
19
|
+
|
|
20
|
+
1. **New topic schemas** — propose JSON Schema for real-world handoff patterns
|
|
21
|
+
2. **Client recipes** — tested MCP configs for Cursor, Claude Desktop, Windsurf, etc.
|
|
22
|
+
3. **Poll ergonomics** — helpers, SDKs, retry/backoff patterns
|
|
23
|
+
4. **Docs** — architecture notes, deployment guides, comparison with file-based blackboards
|
|
24
|
+
|
|
25
|
+
## Pull request checklist
|
|
26
|
+
|
|
27
|
+
- [ ] Tests pass: `pytest tests/ -q`
|
|
28
|
+
- [ ] New behavior has tests
|
|
29
|
+
- [ ] Public API changes documented in `docs/MCP_SCHEMA.md` or README
|
|
30
|
+
- [ ] No secrets, tokens, or machine-local paths committed
|
|
31
|
+
|
|
32
|
+
## Architecture notes
|
|
33
|
+
|
|
34
|
+
| Module | Role |
|
|
35
|
+
|--------|------|
|
|
36
|
+
| `store.py` | SQLite event log, retention, idempotency |
|
|
37
|
+
| `server.py` | FastMCP tool definitions |
|
|
38
|
+
| `auth.py` | Workspace ephemeral token |
|
|
39
|
+
| `schemas.py` | Topic registry + JSON Schema validation |
|
|
40
|
+
| `leases.py` | Advisory lease store (SQLite `leases` table) |
|
|
41
|
+
| `cli.py` | `serve`, `publish`, `poll`, `status`, `token`, `lock`, `project-log` |
|
|
42
|
+
|
|
43
|
+
## Versioning
|
|
44
|
+
|
|
45
|
+
AgentBus is **0.x** (pre-1.0). Minor releases may add topics and tools; patch releases are bugfixes. Breaking changes will be noted in [CHANGELOG.md](CHANGELOG.md).
|
|
46
|
+
|
|
47
|
+
## Code of conduct
|
|
48
|
+
|
|
49
|
+
See [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md).
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AgentBus Contributors
|
|
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,195 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: okf-agentbus
|
|
3
|
+
Version: 0.2.3
|
|
4
|
+
Summary: Local MCP event log for multi-agent workspaces
|
|
5
|
+
Project-URL: Homepage, https://github.com/onicarps/agentbus
|
|
6
|
+
Project-URL: Repository, https://github.com/onicarps/agentbus
|
|
7
|
+
Project-URL: Issues, https://github.com/onicarps/agentbus/issues
|
|
8
|
+
Project-URL: Documentation, https://github.com/onicarps/agentbus/blob/main/docs/MCP_SCHEMA.md
|
|
9
|
+
Author: onicarps
|
|
10
|
+
License: MIT
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: agents,event-log,mcp,multi-agent,orchestration
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
20
|
+
Requires-Python: >=3.11
|
|
21
|
+
Requires-Dist: click>=8.0
|
|
22
|
+
Requires-Dist: jsonschema>=4.0
|
|
23
|
+
Requires-Dist: mcp>=1.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# AgentBus
|
|
30
|
+
|
|
31
|
+
[](https://github.com/onicarps/agentbus/actions/workflows/test.yml)
|
|
32
|
+
[](https://pypi.org/project/okf-agentbus/)
|
|
33
|
+
[](LICENSE)
|
|
34
|
+
|
|
35
|
+
**Local MCP event log and advisory lease coordinator for multi-agent workspaces.**
|
|
36
|
+
|
|
37
|
+
When Cursor, Claude Code, Antigravity, Hermes, and other agents share a workspace, they usually coordinate through append-only files (`log.md`, sticky notes, Slack). That works until you need ordering, idempotency, cursors, schema validation, or file-edit mutexes.
|
|
38
|
+
|
|
39
|
+
AgentBus is a **localhost sidecar**: a Python MCP server backed by SQLite. Agents publish structured events; peers poll with `since_id` cursors. Advisory lease locks prevent concurrent edits. No orchestrator runtime lock-in.
|
|
40
|
+
|
|
41
|
+
> **v0.2 (July 2026):** Events + advisory lease locks — `publish`, `poll`, `status`, `lock_*`. SSE subscribe and custom topics on the [roadmap](ROADMAP.md).
|
|
42
|
+
|
|
43
|
+
> **Note:** PyPI names `agentbus` (NATS) and `agentbus-mcp` (blocked as too similar) are unavailable. Install as **`okf-agentbus`** (CLI command remains `agentbus`).
|
|
44
|
+
|
|
45
|
+
## Why AgentBus?
|
|
46
|
+
|
|
47
|
+
| Alternative | Limitation | AgentBus |
|
|
48
|
+
|-------------|------------|----------|
|
|
49
|
+
| `log.md` blackboard | No schema, races, manual cursors | Typed topics, monotonic IDs, poll API |
|
|
50
|
+
| `flock` / git mutex | No agent identity, no TTL | Advisory leases with heartbeat renewal |
|
|
51
|
+
| Redis pub/sub | Extra daemon, no MCP path | stdio MCP — works in existing IDEs |
|
|
52
|
+
| LangGraph / AutoGen | Same-runtime only | Heterogeneous out-of-process clients |
|
|
53
|
+
|
|
54
|
+
## Install
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
pip install okf-agentbus
|
|
58
|
+
|
|
59
|
+
# Or from GitHub
|
|
60
|
+
pip install "okf-agentbus @ git+https://github.com/onicarps/agentbus@v0.2.3"
|
|
61
|
+
|
|
62
|
+
# Or clone for development
|
|
63
|
+
git clone https://github.com/onicarps/agentbus.git
|
|
64
|
+
cd agentbus
|
|
65
|
+
python3 -m venv .venv
|
|
66
|
+
.venv/bin/pip install -e ".[dev]"
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Quickstart
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
export AGENTBUS_WORKSPACE=/path/to/workspace
|
|
73
|
+
export AGENTBUS_PRODUCER_ID=my-agent
|
|
74
|
+
|
|
75
|
+
# Terminal A — MCP server (stdio)
|
|
76
|
+
agentbus serve --workspace "$AGENTBUS_WORKSPACE"
|
|
77
|
+
|
|
78
|
+
# Terminal B — publish a handoff
|
|
79
|
+
agentbus publish \
|
|
80
|
+
--topic okf/handoff \
|
|
81
|
+
--payload '{"from":"my-agent","to":"peer","summary":"Hello bus"}'
|
|
82
|
+
|
|
83
|
+
# Poll events
|
|
84
|
+
agentbus poll --topic okf/handoff --since-id 0
|
|
85
|
+
|
|
86
|
+
# Acquire an advisory lease before editing a shared file
|
|
87
|
+
agentbus lock acquire --resource "$AGENTBUS_WORKSPACE/log.md" --owner-id my-agent
|
|
88
|
+
agentbus lock status --resource "$AGENTBUS_WORKSPACE/log.md"
|
|
89
|
+
agentbus lock release --resource "$AGENTBUS_WORKSPACE/log.md" --lease-id <uuid> --owner-id my-agent
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## MCP setup
|
|
93
|
+
|
|
94
|
+
Use `scripts/mcp-serve.sh` so the workspace token is injected automatically:
|
|
95
|
+
|
|
96
|
+
```json
|
|
97
|
+
{
|
|
98
|
+
"mcpServers": {
|
|
99
|
+
"agentbus": {
|
|
100
|
+
"command": "/path/to/agentbus/scripts/mcp-serve.sh",
|
|
101
|
+
"env": {
|
|
102
|
+
"AGENTBUS_WORKSPACE": "/path/to/workspace",
|
|
103
|
+
"AGENTBUS_PRODUCER_ID": "cursor"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Client-specific templates:
|
|
111
|
+
|
|
112
|
+
| Client | Config |
|
|
113
|
+
|--------|--------|
|
|
114
|
+
| Cursor | [examples/mcp-cursor.json](examples/mcp-cursor.json) |
|
|
115
|
+
| Claude Desktop | [examples/mcp-claude-desktop.json](examples/mcp-claude-desktop.json) |
|
|
116
|
+
| Hermes | [examples/mcp-hermes.json](examples/mcp-hermes.json) |
|
|
117
|
+
|
|
118
|
+
### MCP tools
|
|
119
|
+
|
|
120
|
+
| Tool | Auth | Purpose |
|
|
121
|
+
|------|------|---------|
|
|
122
|
+
| `agentbus_publish` | Yes | Append one validated event |
|
|
123
|
+
| `agentbus_poll` | No | Fetch events after `since_id` (at-least-once) |
|
|
124
|
+
| `agentbus_status` | No | Event counts, topics, health |
|
|
125
|
+
| `agentbus_lock_acquire` | Yes | Exclusive advisory lease on a resource path |
|
|
126
|
+
| `agentbus_lock_release` | Yes | Release a held lease |
|
|
127
|
+
| `agentbus_lock_renew` | Yes | Extend TTL (heartbeat) |
|
|
128
|
+
| `agentbus_lock_status` | No | Check lock state without acquiring |
|
|
129
|
+
|
|
130
|
+
Full schema: [docs/MCP_SCHEMA.md](docs/MCP_SCHEMA.md)
|
|
131
|
+
|
|
132
|
+
## Authentication
|
|
133
|
+
|
|
134
|
+
On `serve`, AgentBus writes an ephemeral token to `{workspace}/.agentbus/token` (mode `0600`). Publish and lock mutations require a matching token via:
|
|
135
|
+
|
|
136
|
+
- `scripts/mcp-serve.sh` (recommended for MCP — reads workspace file, not stale env)
|
|
137
|
+
- `AGENTBUS_TOKEN` environment variable
|
|
138
|
+
- `--token` CLI flag
|
|
139
|
+
- `auth_token` MCP tool argument (optional; omit when using `mcp-serve.sh`)
|
|
140
|
+
|
|
141
|
+
Poll, status, and lock_status remain open. Set `AGENTBUS_AUTH=off` to disable during local development.
|
|
142
|
+
|
|
143
|
+
Details: [docs/AUTH.md](docs/AUTH.md)
|
|
144
|
+
|
|
145
|
+
## Topics (v0.2)
|
|
146
|
+
|
|
147
|
+
| Topic | Purpose |
|
|
148
|
+
|-------|---------|
|
|
149
|
+
| `okf/handoff` | Structured agent handoff (`from`, `to`, `summary`) |
|
|
150
|
+
| `okf/status/<name>` | Status ping (`idle`, `active`, `blocked`, `complete`) |
|
|
151
|
+
|
|
152
|
+
Custom topics are planned — [contributions welcome](CONTRIBUTING.md).
|
|
153
|
+
|
|
154
|
+
## CLI reference
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
agentbus serve [--workspace PATH] [--rotate-token]
|
|
158
|
+
agentbus publish --topic TOPIC --payload JSON [--producer-id ID]
|
|
159
|
+
agentbus poll --topic TOPIC [--since-id N] [--limit N]
|
|
160
|
+
agentbus status [--producer-id ID]
|
|
161
|
+
agentbus token show|ensure|rotate
|
|
162
|
+
agentbus lock acquire|release|renew|status
|
|
163
|
+
agentbus project-log [--log-file log.md] # optional markdown projection
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Set `AGENTBUS_WORKSPACE` to avoid repeating `--workspace`.
|
|
167
|
+
|
|
168
|
+
## Development
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
.venv/bin/pytest tests/ -q # 40+ tests
|
|
172
|
+
.venv/bin/pytest tests/ --cov=agentbus --cov-report=term-missing
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Project layout
|
|
176
|
+
|
|
177
|
+
```
|
|
178
|
+
src/agentbus/ # Python package
|
|
179
|
+
tests/ # pytest suite (40 tests)
|
|
180
|
+
docs/ # MCP schema, auth guide
|
|
181
|
+
examples/ # MCP client configs (Cursor, Claude, Hermes)
|
|
182
|
+
scripts/ # mcp-serve.sh wrapper
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Roadmap
|
|
186
|
+
|
|
187
|
+
See [ROADMAP.md](ROADMAP.md). v0.2 ships events + advisory locks; v0.3 targets custom topics and HTTP transport.
|
|
188
|
+
|
|
189
|
+
## Contributing
|
|
190
|
+
|
|
191
|
+
We want real-world use cases from teams running heterogeneous agent stacks. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
192
|
+
|
|
193
|
+
## License
|
|
194
|
+
|
|
195
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# AgentBus
|
|
2
|
+
|
|
3
|
+
[](https://github.com/onicarps/agentbus/actions/workflows/test.yml)
|
|
4
|
+
[](https://pypi.org/project/okf-agentbus/)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
**Local MCP event log and advisory lease coordinator for multi-agent workspaces.**
|
|
8
|
+
|
|
9
|
+
When Cursor, Claude Code, Antigravity, Hermes, and other agents share a workspace, they usually coordinate through append-only files (`log.md`, sticky notes, Slack). That works until you need ordering, idempotency, cursors, schema validation, or file-edit mutexes.
|
|
10
|
+
|
|
11
|
+
AgentBus is a **localhost sidecar**: a Python MCP server backed by SQLite. Agents publish structured events; peers poll with `since_id` cursors. Advisory lease locks prevent concurrent edits. No orchestrator runtime lock-in.
|
|
12
|
+
|
|
13
|
+
> **v0.2 (July 2026):** Events + advisory lease locks — `publish`, `poll`, `status`, `lock_*`. SSE subscribe and custom topics on the [roadmap](ROADMAP.md).
|
|
14
|
+
|
|
15
|
+
> **Note:** PyPI names `agentbus` (NATS) and `agentbus-mcp` (blocked as too similar) are unavailable. Install as **`okf-agentbus`** (CLI command remains `agentbus`).
|
|
16
|
+
|
|
17
|
+
## Why AgentBus?
|
|
18
|
+
|
|
19
|
+
| Alternative | Limitation | AgentBus |
|
|
20
|
+
|-------------|------------|----------|
|
|
21
|
+
| `log.md` blackboard | No schema, races, manual cursors | Typed topics, monotonic IDs, poll API |
|
|
22
|
+
| `flock` / git mutex | No agent identity, no TTL | Advisory leases with heartbeat renewal |
|
|
23
|
+
| Redis pub/sub | Extra daemon, no MCP path | stdio MCP — works in existing IDEs |
|
|
24
|
+
| LangGraph / AutoGen | Same-runtime only | Heterogeneous out-of-process clients |
|
|
25
|
+
|
|
26
|
+
## Install
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install okf-agentbus
|
|
30
|
+
|
|
31
|
+
# Or from GitHub
|
|
32
|
+
pip install "okf-agentbus @ git+https://github.com/onicarps/agentbus@v0.2.3"
|
|
33
|
+
|
|
34
|
+
# Or clone for development
|
|
35
|
+
git clone https://github.com/onicarps/agentbus.git
|
|
36
|
+
cd agentbus
|
|
37
|
+
python3 -m venv .venv
|
|
38
|
+
.venv/bin/pip install -e ".[dev]"
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Quickstart
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
export AGENTBUS_WORKSPACE=/path/to/workspace
|
|
45
|
+
export AGENTBUS_PRODUCER_ID=my-agent
|
|
46
|
+
|
|
47
|
+
# Terminal A — MCP server (stdio)
|
|
48
|
+
agentbus serve --workspace "$AGENTBUS_WORKSPACE"
|
|
49
|
+
|
|
50
|
+
# Terminal B — publish a handoff
|
|
51
|
+
agentbus publish \
|
|
52
|
+
--topic okf/handoff \
|
|
53
|
+
--payload '{"from":"my-agent","to":"peer","summary":"Hello bus"}'
|
|
54
|
+
|
|
55
|
+
# Poll events
|
|
56
|
+
agentbus poll --topic okf/handoff --since-id 0
|
|
57
|
+
|
|
58
|
+
# Acquire an advisory lease before editing a shared file
|
|
59
|
+
agentbus lock acquire --resource "$AGENTBUS_WORKSPACE/log.md" --owner-id my-agent
|
|
60
|
+
agentbus lock status --resource "$AGENTBUS_WORKSPACE/log.md"
|
|
61
|
+
agentbus lock release --resource "$AGENTBUS_WORKSPACE/log.md" --lease-id <uuid> --owner-id my-agent
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## MCP setup
|
|
65
|
+
|
|
66
|
+
Use `scripts/mcp-serve.sh` so the workspace token is injected automatically:
|
|
67
|
+
|
|
68
|
+
```json
|
|
69
|
+
{
|
|
70
|
+
"mcpServers": {
|
|
71
|
+
"agentbus": {
|
|
72
|
+
"command": "/path/to/agentbus/scripts/mcp-serve.sh",
|
|
73
|
+
"env": {
|
|
74
|
+
"AGENTBUS_WORKSPACE": "/path/to/workspace",
|
|
75
|
+
"AGENTBUS_PRODUCER_ID": "cursor"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Client-specific templates:
|
|
83
|
+
|
|
84
|
+
| Client | Config |
|
|
85
|
+
|--------|--------|
|
|
86
|
+
| Cursor | [examples/mcp-cursor.json](examples/mcp-cursor.json) |
|
|
87
|
+
| Claude Desktop | [examples/mcp-claude-desktop.json](examples/mcp-claude-desktop.json) |
|
|
88
|
+
| Hermes | [examples/mcp-hermes.json](examples/mcp-hermes.json) |
|
|
89
|
+
|
|
90
|
+
### MCP tools
|
|
91
|
+
|
|
92
|
+
| Tool | Auth | Purpose |
|
|
93
|
+
|------|------|---------|
|
|
94
|
+
| `agentbus_publish` | Yes | Append one validated event |
|
|
95
|
+
| `agentbus_poll` | No | Fetch events after `since_id` (at-least-once) |
|
|
96
|
+
| `agentbus_status` | No | Event counts, topics, health |
|
|
97
|
+
| `agentbus_lock_acquire` | Yes | Exclusive advisory lease on a resource path |
|
|
98
|
+
| `agentbus_lock_release` | Yes | Release a held lease |
|
|
99
|
+
| `agentbus_lock_renew` | Yes | Extend TTL (heartbeat) |
|
|
100
|
+
| `agentbus_lock_status` | No | Check lock state without acquiring |
|
|
101
|
+
|
|
102
|
+
Full schema: [docs/MCP_SCHEMA.md](docs/MCP_SCHEMA.md)
|
|
103
|
+
|
|
104
|
+
## Authentication
|
|
105
|
+
|
|
106
|
+
On `serve`, AgentBus writes an ephemeral token to `{workspace}/.agentbus/token` (mode `0600`). Publish and lock mutations require a matching token via:
|
|
107
|
+
|
|
108
|
+
- `scripts/mcp-serve.sh` (recommended for MCP — reads workspace file, not stale env)
|
|
109
|
+
- `AGENTBUS_TOKEN` environment variable
|
|
110
|
+
- `--token` CLI flag
|
|
111
|
+
- `auth_token` MCP tool argument (optional; omit when using `mcp-serve.sh`)
|
|
112
|
+
|
|
113
|
+
Poll, status, and lock_status remain open. Set `AGENTBUS_AUTH=off` to disable during local development.
|
|
114
|
+
|
|
115
|
+
Details: [docs/AUTH.md](docs/AUTH.md)
|
|
116
|
+
|
|
117
|
+
## Topics (v0.2)
|
|
118
|
+
|
|
119
|
+
| Topic | Purpose |
|
|
120
|
+
|-------|---------|
|
|
121
|
+
| `okf/handoff` | Structured agent handoff (`from`, `to`, `summary`) |
|
|
122
|
+
| `okf/status/<name>` | Status ping (`idle`, `active`, `blocked`, `complete`) |
|
|
123
|
+
|
|
124
|
+
Custom topics are planned — [contributions welcome](CONTRIBUTING.md).
|
|
125
|
+
|
|
126
|
+
## CLI reference
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
agentbus serve [--workspace PATH] [--rotate-token]
|
|
130
|
+
agentbus publish --topic TOPIC --payload JSON [--producer-id ID]
|
|
131
|
+
agentbus poll --topic TOPIC [--since-id N] [--limit N]
|
|
132
|
+
agentbus status [--producer-id ID]
|
|
133
|
+
agentbus token show|ensure|rotate
|
|
134
|
+
agentbus lock acquire|release|renew|status
|
|
135
|
+
agentbus project-log [--log-file log.md] # optional markdown projection
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Set `AGENTBUS_WORKSPACE` to avoid repeating `--workspace`.
|
|
139
|
+
|
|
140
|
+
## Development
|
|
141
|
+
|
|
142
|
+
```bash
|
|
143
|
+
.venv/bin/pytest tests/ -q # 40+ tests
|
|
144
|
+
.venv/bin/pytest tests/ --cov=agentbus --cov-report=term-missing
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Project layout
|
|
148
|
+
|
|
149
|
+
```
|
|
150
|
+
src/agentbus/ # Python package
|
|
151
|
+
tests/ # pytest suite (40 tests)
|
|
152
|
+
docs/ # MCP schema, auth guide
|
|
153
|
+
examples/ # MCP client configs (Cursor, Claude, Hermes)
|
|
154
|
+
scripts/ # mcp-serve.sh wrapper
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Roadmap
|
|
158
|
+
|
|
159
|
+
See [ROADMAP.md](ROADMAP.md). v0.2 ships events + advisory locks; v0.3 targets custom topics and HTTP transport.
|
|
160
|
+
|
|
161
|
+
## Contributing
|
|
162
|
+
|
|
163
|
+
We want real-world use cases from teams running heterogeneous agent stacks. See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
164
|
+
|
|
165
|
+
## License
|
|
166
|
+
|
|
167
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# AgentBus Roadmap
|
|
2
|
+
|
|
3
|
+
**Status:** v0.2 — events + advisory lease locks (July 2026)
|
|
4
|
+
|
|
5
|
+
## Shipped (v0.1)
|
|
6
|
+
|
|
7
|
+
- [x] MCP stdio server: `publish`, `poll`, `status`
|
|
8
|
+
- [x] SQLite durable event log with monotonic `event_id`
|
|
9
|
+
- [x] Topic JSON Schema validation
|
|
10
|
+
- [x] Idempotency keys + 7-day retention
|
|
11
|
+
- [x] Workspace ephemeral token auth
|
|
12
|
+
- [x] CLI for non-MCP clients
|
|
13
|
+
- [x] `project-log` — optional markdown projection for handoff topics
|
|
14
|
+
|
|
15
|
+
## Shipped (v0.2)
|
|
16
|
+
|
|
17
|
+
- [x] Advisory lease locks in `events.db` (`leases` table)
|
|
18
|
+
- [x] MCP: `agentbus_lock_acquire`, `agentbus_lock_release`, `agentbus_lock_renew`, `agentbus_lock_status`
|
|
19
|
+
- [x] CLI: `agentbus lock acquire|release|renew|status`
|
|
20
|
+
- [x] 40 tests including lease store + MCP stdio round-trip
|
|
21
|
+
- [x] PyPI package name `okf-agentbus` (`agentbus`/`agentbus-mcp` blocked on PyPI)
|
|
22
|
+
|
|
23
|
+
## Next (community-driven)
|
|
24
|
+
|
|
25
|
+
### v0.2.x — Distribution & onboarding
|
|
26
|
+
|
|
27
|
+
- [x] PyPI publish as `okf-agentbus`
|
|
28
|
+
- [ ] GitHub Release assets (wheel/sdist) on tag
|
|
29
|
+
- [ ] End-to-end multi-agent handoff walkthrough in docs
|
|
30
|
+
- [ ] Client capability matrix with tested configs per IDE
|
|
31
|
+
|
|
32
|
+
### v0.3 — Developer experience
|
|
33
|
+
|
|
34
|
+
- [ ] Pluggable topic registry (user-defined schemas)
|
|
35
|
+
- [ ] Generic `workspace/handoff` topic alongside reference `okf/handoff`
|
|
36
|
+
- [ ] Poll ergonomics helpers (backoff, cursor management)
|
|
37
|
+
|
|
38
|
+
### v0.4 — Operations
|
|
39
|
+
|
|
40
|
+
- [ ] HTTP transport (optional, localhost-only)
|
|
41
|
+
- [ ] Topic ACLs
|
|
42
|
+
- [ ] Export / backup commands
|
|
43
|
+
|
|
44
|
+
### v1.0 — Stable API
|
|
45
|
+
|
|
46
|
+
- [ ] SSE subscribe where MCP clients support it
|
|
47
|
+
- [ ] Stable 1.0 API guarantee
|
|
48
|
+
|
|
49
|
+
## How to influence the roadmap
|
|
50
|
+
|
|
51
|
+
Open an issue with:
|
|
52
|
+
|
|
53
|
+
1. **Use case** — what agents/clients you run
|
|
54
|
+
2. **Pain** — what breaks with `log.md`, Redis, or ad-hoc files today
|
|
55
|
+
3. **Proposal** — schema, tool, or behavior change
|
|
56
|
+
|
|
57
|
+
Real-world dogfood reports beat theoretical features.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Authentication
|
|
2
|
+
|
|
3
|
+
AgentBus v0.2 uses **workspace-scoped ephemeral tokens** to prevent unauthorized local processes from publishing events or mutating leases.
|
|
4
|
+
|
|
5
|
+
## How it works
|
|
6
|
+
|
|
7
|
+
1. `agentbus serve` calls `ensure_ephemeral_token(workspace)`
|
|
8
|
+
2. Token is written to `{workspace}/.agentbus/token` with file mode **0600**
|
|
9
|
+
3. `agentbus_publish` and `agentbus_lock_*` (except `lock_status`) must present the same token
|
|
10
|
+
4. `agentbus_poll`, `agentbus_status`, and `agentbus_lock_status` do **not** require a token
|
|
11
|
+
|
|
12
|
+
## Token resolution order
|
|
13
|
+
|
|
14
|
+
When validating publish/lock operations:
|
|
15
|
+
|
|
16
|
+
1. `auth_token` tool argument (if provided)
|
|
17
|
+
2. Workspace token file (`{workspace}/.agentbus/token`)
|
|
18
|
+
3. `AGENTBUS_TOKEN` environment variable
|
|
19
|
+
|
|
20
|
+
The workspace file **wins over** a stale `AGENTBUS_TOKEN` in MCP subprocesses. This is why `scripts/mcp-serve.sh` reads the file and exports a fresh value on each start.
|
|
21
|
+
|
|
22
|
+
## Providing the token
|
|
23
|
+
|
|
24
|
+
| Channel | Mechanism |
|
|
25
|
+
|---------|-----------|
|
|
26
|
+
| MCP (recommended) | `scripts/mcp-serve.sh` exports `AGENTBUS_TOKEN` from workspace file |
|
|
27
|
+
| MCP tool arg | `auth_token` parameter (optional when wrapper injects env) |
|
|
28
|
+
| CLI | Auto-reads workspace token file, or `--token`, or `AGENTBUS_TOKEN` env |
|
|
29
|
+
| Legacy | `AGENTBUS_EXPECTED_TOKEN` env (fallback when no token file) |
|
|
30
|
+
|
|
31
|
+
## Disabling auth
|
|
32
|
+
|
|
33
|
+
For local development only:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
export AGENTBUS_AUTH=off
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Rotating tokens
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
agentbus serve --rotate-token
|
|
43
|
+
# or
|
|
44
|
+
agentbus token rotate --workspace /path/to/workspace
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
All MCP clients must restart to pick up the new token.
|
|
48
|
+
|
|
49
|
+
## Threat model
|
|
50
|
+
|
|
51
|
+
v0.2 assumes a **single-user localhost workspace**. The token file gates who can publish and acquire locks; it is not a multi-tenant identity system. Do not expose AgentBus over a network without additional hardening.
|