zwarm 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.
- zwarm-0.1.0/.gitignore +21 -0
- zwarm-0.1.0/PKG-INFO +382 -0
- zwarm-0.1.0/README.md +370 -0
- zwarm-0.1.0/pyproject.toml +42 -0
- zwarm-0.1.0/src/zwarm/__init__.py +38 -0
- zwarm-0.1.0/src/zwarm/adapters/__init__.py +0 -0
- zwarm-0.1.0/src/zwarm/adapters/base.py +109 -0
- zwarm-0.1.0/src/zwarm/adapters/claude_code.py +303 -0
- zwarm-0.1.0/src/zwarm/adapters/codex_mcp.py +428 -0
- zwarm-0.1.0/src/zwarm/adapters/test_codex_mcp.py +224 -0
- zwarm-0.1.0/src/zwarm/cli/__init__.py +0 -0
- zwarm-0.1.0/src/zwarm/cli/main.py +534 -0
- zwarm-0.1.0/src/zwarm/core/__init__.py +0 -0
- zwarm-0.1.0/src/zwarm/core/config.py +271 -0
- zwarm-0.1.0/src/zwarm/core/environment.py +83 -0
- zwarm-0.1.0/src/zwarm/core/models.py +299 -0
- zwarm-0.1.0/src/zwarm/core/state.py +224 -0
- zwarm-0.1.0/src/zwarm/core/test_config.py +160 -0
- zwarm-0.1.0/src/zwarm/core/test_models.py +265 -0
- zwarm-0.1.0/src/zwarm/orchestrator.py +405 -0
- zwarm-0.1.0/src/zwarm/prompts/__init__.py +10 -0
- zwarm-0.1.0/src/zwarm/prompts/orchestrator.py +214 -0
- zwarm-0.1.0/src/zwarm/tools/__init__.py +17 -0
- zwarm-0.1.0/src/zwarm/tools/delegation.py +357 -0
- zwarm-0.1.0/src/zwarm/watchers/__init__.py +26 -0
- zwarm-0.1.0/src/zwarm/watchers/base.py +131 -0
- zwarm-0.1.0/src/zwarm/watchers/builtin.py +256 -0
- zwarm-0.1.0/src/zwarm/watchers/manager.py +143 -0
- zwarm-0.1.0/src/zwarm/watchers/registry.py +57 -0
- zwarm-0.1.0/src/zwarm/watchers/test_watchers.py +195 -0
zwarm-0.1.0/.gitignore
ADDED
zwarm-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: zwarm
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Multi-Agent CLI Orchestration Research Platform
|
|
5
|
+
Requires-Python: <3.14,>=3.13
|
|
6
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
7
|
+
Requires-Dist: pyyaml>=6.0
|
|
8
|
+
Requires-Dist: rich>=13.0.0
|
|
9
|
+
Requires-Dist: typer>=0.9.0
|
|
10
|
+
Requires-Dist: wbal>=0.4.0
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
|
|
13
|
+
# zwarm
|
|
14
|
+
|
|
15
|
+
Multi-agent CLI orchestration research platform. Coordinate multiple coding agents (Codex, Claude Code) with delegation, conversation, and trajectory alignment.
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# From the workspace (recommended during development)
|
|
21
|
+
cd /path/to/labs
|
|
22
|
+
uv sync
|
|
23
|
+
|
|
24
|
+
# Or install directly
|
|
25
|
+
uv pip install -e ./zwarm
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Requirements:**
|
|
29
|
+
- Python 3.13+
|
|
30
|
+
- `codex` CLI installed (for Codex adapter)
|
|
31
|
+
- `claude` CLI installed (for Claude Code adapter)
|
|
32
|
+
|
|
33
|
+
## Quick Start
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
# 1. Test an executor directly
|
|
37
|
+
zwarm exec --task "What is 2+2?"
|
|
38
|
+
|
|
39
|
+
# 2. Run the orchestrator with a task
|
|
40
|
+
zwarm orchestrate --task "Create a hello world Python function"
|
|
41
|
+
|
|
42
|
+
# 3. Check state after running
|
|
43
|
+
zwarm status
|
|
44
|
+
|
|
45
|
+
# 4. View event history
|
|
46
|
+
zwarm history
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Task Input Options
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
# Direct task
|
|
53
|
+
zwarm orchestrate --task "Build a REST API"
|
|
54
|
+
|
|
55
|
+
# From file
|
|
56
|
+
zwarm orchestrate --task-file task.md
|
|
57
|
+
|
|
58
|
+
# From stdin
|
|
59
|
+
echo "Fix the bug in auth.py" | zwarm orchestrate
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Configuration
|
|
63
|
+
|
|
64
|
+
zwarm looks for configuration in this order:
|
|
65
|
+
1. `--config` flag (YAML file)
|
|
66
|
+
2. `config.toml` in working directory
|
|
67
|
+
3. Default settings
|
|
68
|
+
|
|
69
|
+
### Minimal config.toml
|
|
70
|
+
|
|
71
|
+
```toml
|
|
72
|
+
[weave]
|
|
73
|
+
enabled = true
|
|
74
|
+
project = "your-wandb-entity/zwarm"
|
|
75
|
+
|
|
76
|
+
[executor]
|
|
77
|
+
adapter = "codex_mcp" # or "claude_code"
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Environment Variables
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# Enable Weave tracing (alternative to config.toml)
|
|
84
|
+
export WEAVE_PROJECT="your-entity/zwarm"
|
|
85
|
+
|
|
86
|
+
# Required for adapters
|
|
87
|
+
export OPENAI_API_KEY="..." # for Codex
|
|
88
|
+
export ANTHROPIC_API_KEY="..." # for Claude Code
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Full Configuration Reference
|
|
92
|
+
|
|
93
|
+
```yaml
|
|
94
|
+
# config.yaml
|
|
95
|
+
orchestrator:
|
|
96
|
+
max_steps: 100 # Maximum orchestrator steps
|
|
97
|
+
|
|
98
|
+
executor:
|
|
99
|
+
adapter: codex_mcp # Default adapter: codex_mcp | claude_code
|
|
100
|
+
model: null # Model override (adapter-specific)
|
|
101
|
+
sandbox: workspace-write # Codex sandbox mode
|
|
102
|
+
|
|
103
|
+
weave:
|
|
104
|
+
enabled: true
|
|
105
|
+
project: your-entity/zwarm
|
|
106
|
+
|
|
107
|
+
state_dir: .zwarm # State directory for sessions/events
|
|
108
|
+
|
|
109
|
+
watchers:
|
|
110
|
+
enabled: [] # List of enabled watchers
|
|
111
|
+
config:
|
|
112
|
+
progress:
|
|
113
|
+
stuck_threshold: 5
|
|
114
|
+
budget:
|
|
115
|
+
max_steps: 50
|
|
116
|
+
max_sessions: 10
|
|
117
|
+
scope:
|
|
118
|
+
keywords: []
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## Adapters
|
|
122
|
+
|
|
123
|
+
zwarm supports multiple CLI coding agents through adapters.
|
|
124
|
+
|
|
125
|
+
### Codex MCP (default)
|
|
126
|
+
|
|
127
|
+
Uses Codex via MCP server for true conversational sessions.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
# Sync mode (conversational)
|
|
131
|
+
zwarm exec --adapter codex_mcp --task "Add a login function"
|
|
132
|
+
|
|
133
|
+
# The orchestrator can have back-and-forth conversations
|
|
134
|
+
# using delegate() and converse() tools
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Requires:** `codex` CLI installed, `OPENAI_API_KEY` set
|
|
138
|
+
|
|
139
|
+
### Claude Code
|
|
140
|
+
|
|
141
|
+
Uses Claude Code CLI for execution.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
zwarm exec --adapter claude_code --task "Fix the type errors"
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
**Requires:** `claude` CLI installed, authenticated
|
|
148
|
+
|
|
149
|
+
## Watchers (Trajectory Alignment)
|
|
150
|
+
|
|
151
|
+
Watchers are composable guardrails that monitor agent behavior and can intervene when things go wrong.
|
|
152
|
+
|
|
153
|
+
### Available Watchers
|
|
154
|
+
|
|
155
|
+
| Watcher | Description |
|
|
156
|
+
|---------|-------------|
|
|
157
|
+
| `progress` | Detects stuck/spinning agents |
|
|
158
|
+
| `budget` | Monitors step/session limits |
|
|
159
|
+
| `scope` | Detects scope creep from original task |
|
|
160
|
+
| `pattern` | Custom regex pattern matching |
|
|
161
|
+
| `quality` | Code quality checks |
|
|
162
|
+
|
|
163
|
+
### Enabling Watchers
|
|
164
|
+
|
|
165
|
+
```yaml
|
|
166
|
+
# config.yaml
|
|
167
|
+
watchers:
|
|
168
|
+
enabled:
|
|
169
|
+
- progress
|
|
170
|
+
- budget
|
|
171
|
+
- scope
|
|
172
|
+
config:
|
|
173
|
+
progress:
|
|
174
|
+
stuck_threshold: 5 # Flag after 5 similar steps
|
|
175
|
+
budget:
|
|
176
|
+
max_steps: 50
|
|
177
|
+
max_sessions: 10
|
|
178
|
+
scope:
|
|
179
|
+
keywords:
|
|
180
|
+
- "refactor"
|
|
181
|
+
- "rewrite"
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### Watcher Actions
|
|
185
|
+
|
|
186
|
+
Watchers can return different actions:
|
|
187
|
+
- `continue` - Keep going
|
|
188
|
+
- `warn` - Log warning but continue
|
|
189
|
+
- `pause` - Pause for human review
|
|
190
|
+
- `stop` - Stop the orchestrator
|
|
191
|
+
|
|
192
|
+
## Weave Integration
|
|
193
|
+
|
|
194
|
+
zwarm integrates with [Weave](https://wandb.ai/site/weave) for tracing and observability.
|
|
195
|
+
|
|
196
|
+
### Enabling Weave
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Via environment variable
|
|
200
|
+
export WEAVE_PROJECT="your-entity/zwarm"
|
|
201
|
+
|
|
202
|
+
# Or via config.toml
|
|
203
|
+
[weave]
|
|
204
|
+
enabled = true
|
|
205
|
+
project = "your-entity/zwarm"
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### What Gets Traced
|
|
209
|
+
|
|
210
|
+
- Orchestrator `step()` calls with tool inputs/outputs
|
|
211
|
+
- Individual adapter calls (`_call_codex`, `_call_claude`)
|
|
212
|
+
- Delegation tools (`delegate`, `converse`, `end_session`)
|
|
213
|
+
- All tool executions
|
|
214
|
+
|
|
215
|
+
View traces at: `https://wandb.ai/your-entity/zwarm/weave`
|
|
216
|
+
|
|
217
|
+
## CLI Reference
|
|
218
|
+
|
|
219
|
+
### orchestrate
|
|
220
|
+
|
|
221
|
+
Start an orchestrator session to delegate tasks.
|
|
222
|
+
|
|
223
|
+
```bash
|
|
224
|
+
zwarm orchestrate [OPTIONS]
|
|
225
|
+
|
|
226
|
+
Options:
|
|
227
|
+
-t, --task TEXT Task description
|
|
228
|
+
-f, --task-file PATH Read task from file
|
|
229
|
+
-c, --config PATH Config file (YAML)
|
|
230
|
+
--adapter TEXT Executor adapter override
|
|
231
|
+
--resume Resume from previous state
|
|
232
|
+
--set KEY=VALUE Override config values
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### exec
|
|
236
|
+
|
|
237
|
+
Run a single executor directly (for testing).
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
zwarm exec [OPTIONS]
|
|
241
|
+
|
|
242
|
+
Options:
|
|
243
|
+
-t, --task TEXT Task to execute
|
|
244
|
+
-f, --task-file PATH Read task from file
|
|
245
|
+
--adapter TEXT Adapter to use [default: codex_mcp]
|
|
246
|
+
--model TEXT Model override
|
|
247
|
+
--mode [sync|async] Execution mode [default: sync]
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### status
|
|
251
|
+
|
|
252
|
+
Show current orchestrator state.
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
zwarm status [OPTIONS]
|
|
256
|
+
|
|
257
|
+
Options:
|
|
258
|
+
--sessions Show session details
|
|
259
|
+
--tasks Show task details
|
|
260
|
+
--json Output as JSON
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
### history
|
|
264
|
+
|
|
265
|
+
Show event history.
|
|
266
|
+
|
|
267
|
+
```bash
|
|
268
|
+
zwarm history [OPTIONS]
|
|
269
|
+
|
|
270
|
+
Options:
|
|
271
|
+
-n, --limit INTEGER Number of events [default: 20]
|
|
272
|
+
--session TEXT Filter by session ID
|
|
273
|
+
--json Output as JSON
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### configs
|
|
277
|
+
|
|
278
|
+
Manage configuration files.
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
zwarm configs list # List available configs
|
|
282
|
+
zwarm configs show NAME # Show config contents
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Architecture
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
┌─────────────────────────────────────────────────────────┐
|
|
289
|
+
│ Orchestrator │
|
|
290
|
+
│ (Plans, delegates, supervises - does NOT write code) │
|
|
291
|
+
├─────────────────────────────────────────────────────────┤
|
|
292
|
+
│ Delegation Tools │
|
|
293
|
+
│ delegate() | converse() | check_session() | bash() │
|
|
294
|
+
└───────────────┬─────────────────────┬───────────────────┘
|
|
295
|
+
│ │
|
|
296
|
+
┌───────▼───────┐ ┌───────▼───────┐
|
|
297
|
+
│ Codex MCP │ │ Claude Code │
|
|
298
|
+
│ Adapter │ │ Adapter │
|
|
299
|
+
└───────┬───────┘ └───────┬───────┘
|
|
300
|
+
│ │
|
|
301
|
+
┌───────▼───────┐ ┌───────▼───────┐
|
|
302
|
+
│ codex │ │ claude │
|
|
303
|
+
│ mcp-server │ │ CLI │
|
|
304
|
+
└───────────────┘ └───────────────┘
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
### Key Concepts
|
|
308
|
+
|
|
309
|
+
- **Orchestrator**: Plans and delegates but never writes code directly
|
|
310
|
+
- **Executors**: CLI agents (Codex, Claude) that do the actual coding
|
|
311
|
+
- **Sessions**: Conversations with executors (sync or async)
|
|
312
|
+
- **Watchers**: Trajectory aligners that monitor and intervene
|
|
313
|
+
|
|
314
|
+
### State Management
|
|
315
|
+
|
|
316
|
+
All state is stored in flat files under `.zwarm/`:
|
|
317
|
+
|
|
318
|
+
```
|
|
319
|
+
.zwarm/
|
|
320
|
+
├── state.json # Current state
|
|
321
|
+
├── events.jsonl # Append-only event log
|
|
322
|
+
├── sessions/
|
|
323
|
+
│ └── <session-id>/
|
|
324
|
+
│ ├── messages.json # Conversation history
|
|
325
|
+
│ └── metadata.json # Session info
|
|
326
|
+
└── orchestrator/
|
|
327
|
+
└── messages.json # Orchestrator history (for resume)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Development
|
|
331
|
+
|
|
332
|
+
### Running Tests
|
|
333
|
+
|
|
334
|
+
```bash
|
|
335
|
+
# From workspace root
|
|
336
|
+
uv run pytest wbal/tests/ -v
|
|
337
|
+
|
|
338
|
+
# zwarm doesn't have its own tests yet
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### Project Structure
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
zwarm/
|
|
345
|
+
├── src/zwarm/
|
|
346
|
+
│ ├── adapters/ # Executor adapters
|
|
347
|
+
│ │ ├── base.py # ExecutorAdapter protocol
|
|
348
|
+
│ │ ├── codex_mcp.py # Codex MCP adapter
|
|
349
|
+
│ │ └── claude_code.py # Claude Code adapter
|
|
350
|
+
│ ├── cli/
|
|
351
|
+
│ │ └── main.py # Typer CLI
|
|
352
|
+
│ ├── core/
|
|
353
|
+
│ │ ├── config.py # Configuration loading
|
|
354
|
+
│ │ ├── models.py # ConversationSession, Message, etc.
|
|
355
|
+
│ │ └── state.py # Flat-file state management
|
|
356
|
+
│ ├── tools/
|
|
357
|
+
│ │ └── delegation.py # delegate, converse, etc.
|
|
358
|
+
│ ├── watchers/
|
|
359
|
+
│ │ ├── base.py # Watcher protocol
|
|
360
|
+
│ │ ├── builtin.py # Built-in watchers
|
|
361
|
+
│ │ └── manager.py # WatcherManager
|
|
362
|
+
│ ├── prompts/
|
|
363
|
+
│ │ └── orchestrator.py # Orchestrator system prompt
|
|
364
|
+
│ └── orchestrator.py # Main Orchestrator class
|
|
365
|
+
├── configs/ # Example configurations
|
|
366
|
+
├── README.md
|
|
367
|
+
└── pyproject.toml
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
## Research Context
|
|
371
|
+
|
|
372
|
+
zwarm is a research platform exploring:
|
|
373
|
+
|
|
374
|
+
1. **Agent reliability** - Can orchestrators reliably delegate and verify work?
|
|
375
|
+
2. **Agent meta-capability** - Can agents effectively use other agents?
|
|
376
|
+
3. **Long-running agents** - Can agents run for days, not hours?
|
|
377
|
+
|
|
378
|
+
See [ZWARM_PLAN.md](ZWARM_PLAN.md) for detailed design documentation.
|
|
379
|
+
|
|
380
|
+
## License
|
|
381
|
+
|
|
382
|
+
Research project - see repository license.
|