zwarm 0.1.0__py3-none-any.whl → 1.0.0__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: zwarm
3
- Version: 0.1.0
3
+ Version: 1.0.0
4
4
  Summary: Multi-Agent CLI Orchestration Research Platform
5
5
  Requires-Python: <3.14,>=3.13
6
6
  Requires-Dist: python-dotenv>=1.0.0
@@ -12,7 +12,17 @@ Description-Content-Type: text/markdown
12
12
 
13
13
  # zwarm
14
14
 
15
- Multi-agent CLI orchestration research platform. Coordinate multiple coding agents (Codex, Claude Code) with delegation, conversation, and trajectory alignment.
15
+ Multi-agent CLI orchestration research platform. Coordinate multiple coding agents (Codex, Claude Code) with delegation, conversation, trajectory alignment, and automatic context management.
16
+
17
+ ## Key Features
18
+
19
+ - **Multi-adapter support**: Codex MCP, Claude Code adapters with unified interface
20
+ - **Sync & async modes**: Conversational (iterative refinement) or fire-and-forget
21
+ - **Token tracking**: Per-session token usage tracked and persisted for cost analysis
22
+ - **Context compaction**: Automatic LRU-style pruning when approaching context limits
23
+ - **Trajectory watchers**: Composable guardrails (progress, budget, scope, pattern, delegation)
24
+ - **State persistence**: Resume sessions, track history, replay events
25
+ - **Weave integration**: Full tracing and observability
16
26
 
17
27
  ## Installation
18
28
 
@@ -33,16 +43,19 @@ uv pip install -e ./zwarm
33
43
  ## Quick Start
34
44
 
35
45
  ```bash
36
- # 1. Test an executor directly
46
+ # 1. Initialize zwarm in your project
47
+ zwarm init
48
+
49
+ # 2. Test an executor directly
37
50
  zwarm exec --task "What is 2+2?"
38
51
 
39
- # 2. Run the orchestrator with a task
52
+ # 3. Run the orchestrator with a task
40
53
  zwarm orchestrate --task "Create a hello world Python function"
41
54
 
42
- # 3. Check state after running
55
+ # 4. Check state after running
43
56
  zwarm status
44
57
 
45
- # 4. View event history
58
+ # 5. View event history
46
59
  zwarm history
47
60
  ```
48
61
 
@@ -80,24 +93,38 @@ adapter = "codex_mcp" # or "claude_code"
80
93
  ### Environment Variables
81
94
 
82
95
  ```bash
83
- # Enable Weave tracing (alternative to config.toml)
96
+ # Weave tracing (optional but recommended)
84
97
  export WEAVE_PROJECT="your-entity/zwarm"
85
98
 
86
- # Required for adapters
87
- export OPENAI_API_KEY="..." # for Codex
88
- export ANTHROPIC_API_KEY="..." # for Claude Code
99
+ # Executor authentication (required - set based on which adapter you use)
100
+ export OPENAI_API_KEY="sk-..." # Required for codex_mcp adapter
101
+ export ANTHROPIC_API_KEY="sk-ant-..." # Required for claude_code adapter
89
102
  ```
90
103
 
104
+ **Important:** The orchestrator agent runs with your credentials, but the executor adapters (Codex, Claude Code) need their own authentication. If executors fail with auth errors, check that the appropriate API key is set in your environment.
105
+
106
+ You can also put these in a `.env` file in your project root - zwarm will load it automatically.
107
+
91
108
  ### Full Configuration Reference
92
109
 
93
110
  ```yaml
94
111
  # config.yaml
95
112
  orchestrator:
113
+ lm: gpt-5-mini # Model for the orchestrator itself
96
114
  max_steps: 100 # Maximum orchestrator steps
115
+ compaction: # Context window management
116
+ enabled: true
117
+ max_tokens: 100000 # Trigger compaction above this
118
+ threshold_pct: 0.85 # Compact at 85% of max
119
+ target_pct: 0.7 # Target 70% after compaction
120
+ keep_first_n: 2 # Always keep system + task
121
+ keep_last_n: 10 # Always keep recent context
97
122
 
98
123
  executor:
99
124
  adapter: codex_mcp # Default adapter: codex_mcp | claude_code
100
- model: null # Model override (adapter-specific)
125
+ model: null # Model override (null = use adapter default)
126
+ # codex_mcp default: gpt-5.1-codex-mini
127
+ # claude_code default: claude-sonnet-4-5-20250514
101
128
  sandbox: workspace-write # Codex sandbox mode
102
129
 
103
130
  weave:
@@ -107,24 +134,25 @@ weave:
107
134
  state_dir: .zwarm # State directory for sessions/events
108
135
 
109
136
  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: []
137
+ enabled: true
138
+ watchers:
139
+ - name: progress
140
+ - name: budget
141
+ config:
142
+ max_steps: 50
143
+ max_sessions: 10
144
+ - name: scope
145
+ config:
146
+ keywords: []
119
147
  ```
120
148
 
121
149
  ## Adapters
122
150
 
123
- zwarm supports multiple CLI coding agents through adapters.
151
+ zwarm supports multiple CLI coding agents through adapters. Each adapter wraps a different coding CLI and handles the mechanics of starting sessions, sending messages, and capturing responses.
124
152
 
125
153
  ### Codex MCP (default)
126
154
 
127
- Uses Codex via MCP server for true conversational sessions.
155
+ Uses Codex via MCP server for true conversational sessions. This is the recommended adapter for iterative work where you need back-and-forth refinement.
128
156
 
129
157
  ```bash
130
158
  # Sync mode (conversational)
@@ -134,17 +162,45 @@ zwarm exec --adapter codex_mcp --task "Add a login function"
134
162
  # using delegate() and converse() tools
135
163
  ```
136
164
 
137
- **Requires:** `codex` CLI installed, `OPENAI_API_KEY` set
165
+ | Setting | Value |
166
+ |---------|-------|
167
+ | Default model | `gpt-5.1-codex-mini` |
168
+ | Requires | `codex` CLI installed |
169
+ | Auth | `OPENAI_API_KEY` environment variable |
138
170
 
139
171
  ### Claude Code
140
172
 
141
- Uses Claude Code CLI for execution.
173
+ Uses Claude Code CLI for execution. Good alternative when you want Claude's capabilities.
142
174
 
143
175
  ```bash
144
176
  zwarm exec --adapter claude_code --task "Fix the type errors"
145
177
  ```
146
178
 
147
- **Requires:** `claude` CLI installed, authenticated
179
+ | Setting | Value |
180
+ |---------|-------|
181
+ | Default model | `claude-sonnet-4-5-20250514` |
182
+ | Requires | `claude` CLI installed and authenticated |
183
+ | Auth | `ANTHROPIC_API_KEY` or `claude` CLI auth |
184
+
185
+ ### Model Selection
186
+
187
+ Models are selected with this precedence (highest to lowest):
188
+
189
+ 1. **Per-delegation override**: `delegate(task="...", model="o3")`
190
+ 2. **Config file**: `executor.model` in config.toml or zwarm.yaml
191
+ 3. **Adapter default**: Each adapter has a sensible default
192
+
193
+ ```yaml
194
+ # config.toml - override the default model
195
+ [executor]
196
+ adapter = "codex_mcp"
197
+ model = "gpt-5.1-codex-max" # Use the more capable model
198
+ ```
199
+
200
+ ```bash
201
+ # Or override per-execution
202
+ zwarm exec --model gpt-5.1-codex-max --task "Complex refactoring"
203
+ ```
148
204
 
149
205
  ## Watchers (Trajectory Alignment)
150
206
 
@@ -155,10 +211,11 @@ Watchers are composable guardrails that monitor agent behavior and can intervene
155
211
  | Watcher | Description |
156
212
  |---------|-------------|
157
213
  | `progress` | Detects stuck/spinning agents |
158
- | `budget` | Monitors step/session limits |
214
+ | `budget` | Monitors step/session limits (counts only active sessions) |
159
215
  | `scope` | Detects scope creep from original task |
160
216
  | `pattern` | Custom regex pattern matching |
161
217
  | `quality` | Code quality checks |
218
+ | `delegation` | Ensures orchestrator delegates instead of writing code directly |
162
219
 
163
220
  ### Enabling Watchers
164
221
 
@@ -216,6 +273,41 @@ View traces at: `https://wandb.ai/your-entity/zwarm/weave`
216
273
 
217
274
  ## CLI Reference
218
275
 
276
+ ### init
277
+
278
+ Initialize zwarm in a project directory.
279
+
280
+ ```bash
281
+ zwarm init [OPTIONS]
282
+
283
+ Options:
284
+ -w, --working-dir PATH Working directory [default: .]
285
+ -y, --yes Accept defaults, no prompts
286
+ --with-project Also create zwarm.yaml project config
287
+ ```
288
+
289
+ **What it creates:**
290
+
291
+ 1. `config.toml` - User settings (Weave project, adapter preferences, watchers)
292
+ 2. `.zwarm/` - State directory for sessions and events
293
+ 3. `zwarm.yaml` (optional) - Project-specific task configuration
294
+
295
+ **Examples:**
296
+
297
+ ```bash
298
+ # Interactive setup with prompts
299
+ zwarm init
300
+
301
+ # Non-interactive with defaults
302
+ zwarm init --yes
303
+
304
+ # Create project config too
305
+ zwarm init --with-project
306
+
307
+ # Initialize in a different directory
308
+ zwarm init --working-dir /path/to/project
309
+ ```
310
+
219
311
  ### orchestrate
220
312
 
221
313
  Start an orchestrator session to delegate tasks.
@@ -234,19 +326,20 @@ Options:
234
326
 
235
327
  ### exec
236
328
 
237
- Run a single executor directly (for testing).
329
+ Run a single executor directly (for testing). This bypasses the orchestrator entirely and hits the adapter (Codex/Claude) immediately with your task - useful for verifying adapters work before running full orchestration.
238
330
 
239
331
  ```bash
240
332
  zwarm exec [OPTIONS]
241
333
 
242
334
  Options:
243
335
  -t, --task TEXT Task to execute
244
- -f, --task-file PATH Read task from file
245
336
  --adapter TEXT Adapter to use [default: codex_mcp]
246
337
  --model TEXT Model override
247
338
  --mode [sync|async] Execution mode [default: sync]
248
339
  ```
249
340
 
341
+ **Note:** Unlike `orchestrate`, this does NOT use watchers, compaction, state persistence, or multi-step planning. It's a single direct call to the executor.
342
+
250
343
  ### status
251
344
 
252
345
  Show current orchestrator state.
@@ -282,6 +375,30 @@ zwarm configs list # List available configs
282
375
  zwarm configs show NAME # Show config contents
283
376
  ```
284
377
 
378
+ ### clean
379
+
380
+ Clean up zwarm state (useful for starting fresh).
381
+
382
+ ```bash
383
+ zwarm clean [OPTIONS]
384
+
385
+ Options:
386
+ --all Remove everything (events, sessions, state)
387
+ --events Remove only events
388
+ --sessions Remove only sessions
389
+ -y, --yes Skip confirmation prompt
390
+ ```
391
+
392
+ **Examples:**
393
+
394
+ ```bash
395
+ # Clean everything and start fresh
396
+ zwarm clean --all --yes
397
+
398
+ # Clean only events log
399
+ zwarm clean --events
400
+ ```
401
+
285
402
  ## Architecture
286
403
 
287
404
  ```
@@ -332,10 +449,16 @@ All state is stored in flat files under `.zwarm/`:
332
449
  ### Running Tests
333
450
 
334
451
  ```bash
335
- # From workspace root
336
- uv run pytest wbal/tests/ -v
452
+ # Run all zwarm tests (68 tests)
453
+ uv run pytest src/zwarm/ -v
454
+
455
+ # Run specific test modules
456
+ uv run pytest src/zwarm/core/test_compact.py -v # Context compaction
457
+ uv run pytest src/zwarm/watchers/test_watchers.py -v # Watchers
458
+ uv run pytest src/zwarm/adapters/test_codex_mcp.py -v # Codex adapter
337
459
 
338
- # zwarm doesn't have its own tests yet
460
+ # Run integration tests (requires codex CLI)
461
+ uv run pytest -m integration
339
462
  ```
340
463
 
341
464
  ### Project Structure
@@ -345,19 +468,22 @@ zwarm/
345
468
  ├── src/zwarm/
346
469
  │ ├── adapters/ # Executor adapters
347
470
  │ │ ├── base.py # ExecutorAdapter protocol
348
- │ │ ├── codex_mcp.py # Codex MCP adapter
349
- │ │ └── claude_code.py # Claude Code adapter
471
+ │ │ ├── codex_mcp.py # Codex MCP adapter (with token tracking)
472
+ │ │ └── claude_code.py # Claude Code adapter (with token tracking)
350
473
  │ ├── cli/
351
474
  │ │ └── main.py # Typer CLI
352
475
  │ ├── core/
476
+ │ │ ├── compact.py # Context window compaction (LRU pruning)
353
477
  │ │ ├── config.py # Configuration loading
354
- │ │ ├── models.py # ConversationSession, Message, etc.
478
+ │ │ ├── environment.py # OrchestratorEnv (progress display)
479
+ │ │ ├── models.py # ConversationSession, Message, Event, etc.
355
480
  │ │ └── state.py # Flat-file state management
356
481
  │ ├── tools/
357
- │ │ └── delegation.py # delegate, converse, etc.
482
+ │ │ └── delegation.py # delegate, converse, check_session, etc.
358
483
  │ ├── watchers/
359
484
  │ │ ├── base.py # Watcher protocol
360
- │ │ ├── builtin.py # Built-in watchers
485
+ │ │ ├── builtin.py # Built-in watchers (progress, budget, scope, etc.)
486
+ │ │ ├── registry.py # Watcher registration
361
487
  │ │ └── manager.py # WatcherManager
362
488
  │ ├── prompts/
363
489
  │ │ └── orchestrator.py # Orchestrator system prompt
@@ -0,0 +1,33 @@
1
+ zwarm/__init__.py,sha256=3i3LMjHwIzE-LFIS2aUrwv3EZmpkvVMe-xj1h97rcSM,837
2
+ zwarm/orchestrator.py,sha256=O3HGjMenQE-HF5xo0WQNMAHRS_vLsUrFfVp6oI_WpKU,19732
3
+ zwarm/test_orchestrator_watchers.py,sha256=QpoaehPU7ekT4XshbTOWnJ2H0wRveV3QOZjxbgyJJLY,807
4
+ zwarm/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ zwarm/adapters/base.py,sha256=fZlQviTgVvOcwnxduTla6WuM6FzQJ_yoHMW5SxwVgQg,2527
6
+ zwarm/adapters/claude_code.py,sha256=Z6f_jydiIUuZiR8fNipvvlcv16rP4BK6jNtkUaH3M4c,11368
7
+ zwarm/adapters/codex_mcp.py,sha256=Wp4PExZlhqfLV5CHxBqmIBOm-pH7k8cJy93fyxRbCgw,27495
8
+ zwarm/adapters/test_codex_mcp.py,sha256=vodQF5VUrM_F1GygUADtXYrA0kvAc7dWpT_Ff-Uoo0A,8383
9
+ zwarm/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
+ zwarm/cli/main.py,sha256=dU_8XLIYzcxikl_MgT6BmChNbqYq94dJ4Ra5STzm_KI,33109
11
+ zwarm/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
12
+ zwarm/core/compact.py,sha256=x3NYHvwDOLjNT7gcOG7mVoL4EDbWsG77rZAbjKZVOgQ,10109
13
+ zwarm/core/config.py,sha256=H8XFsWeEehZnUsMf7nsM_YqjljFYaC43DLs8Xw4sOuQ,10360
14
+ zwarm/core/environment.py,sha256=HVDpDZEpDSfyh9-wHZMzMKVUPKvioBkPVWeiME2JmFo,5435
15
+ zwarm/core/models.py,sha256=PrC3okRBVJxISUa1Fax4KkagqLT6Xub-kTxC9drN0sY,10083
16
+ zwarm/core/state.py,sha256=wMryIvXP-VDLh2b76A5taeL_9dm5k4jk4HnvHWgLqGE,7658
17
+ zwarm/core/test_compact.py,sha256=CbVBkTaLV2VDEn51om0AbY8RgWM2czhxZQQt_U_NggU,10305
18
+ zwarm/core/test_config.py,sha256=26ozyiFOdjFF2c9Q-HDfFM6GOLfgw_5FZ55nTDMNYA8,4888
19
+ zwarm/core/test_models.py,sha256=sWTIhMZvuLP5AooGR6y8OR2EyWydqVfhmGrE7NPBBnk,8450
20
+ zwarm/prompts/__init__.py,sha256=FiaIOniLrIyfD3_osxT6I7FfyKjtctbf8jNs5QTPs_s,213
21
+ zwarm/prompts/orchestrator.py,sha256=R-ym3nlspYNspf085Qwwfi96Yh3K6-Csb6vfBg29K2c,14228
22
+ zwarm/tools/__init__.py,sha256=FpqxwXJA6-fQ7C-oLj30jjK_0qqcE7MbI0dQuaB56kU,290
23
+ zwarm/tools/delegation.py,sha256=wf43jxmGvEy_c8jVx301YQvslIS2F80Qnq4Py2feVvg,11435
24
+ zwarm/watchers/__init__.py,sha256=yYGTbhuImQLESUdtfrYbHYBJNvCNX3B-Ei-vY5BizX8,760
25
+ zwarm/watchers/base.py,sha256=r1GoPlj06nOT2xp4fghfSjxbRyFFFQUB6HpZbEyO2OY,3834
26
+ zwarm/watchers/builtin.py,sha256=52hyRREYYDsSuG-YKElXViSTyMmGySZaFreHc0pz-A4,12482
27
+ zwarm/watchers/manager.py,sha256=XZjBVeHjgCUlkTUeHqdvBvHoBC862U1ik0fG6nlRGog,5587
28
+ zwarm/watchers/registry.py,sha256=A9iBIVIFNtO7KPX0kLpUaP8dAK7ozqWLA44ocJGnOw4,1219
29
+ zwarm/watchers/test_watchers.py,sha256=zOsxumBqKfR5ZVGxrNlxz6KcWjkcdp0QhW9WB0_20zM,7855
30
+ zwarm-1.0.0.dist-info/METADATA,sha256=aIyHVKHhTe8oo8thqCpMMErJo7S2ILWxvEYF3LaJYv8,14995
31
+ zwarm-1.0.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
32
+ zwarm-1.0.0.dist-info/entry_points.txt,sha256=u0OXq4q8d3yJ3EkUXwZfkS-Y8Lcy0F8cWrcQfoRxM6Q,46
33
+ zwarm-1.0.0.dist-info/RECORD,,
@@ -1,30 +0,0 @@
1
- zwarm/__init__.py,sha256=3i3LMjHwIzE-LFIS2aUrwv3EZmpkvVMe-xj1h97rcSM,837
2
- zwarm/orchestrator.py,sha256=za5amtXkgKSImGLWO5TnGIA5Fitlz61cWAmvbfsAx2Q,13422
3
- zwarm/adapters/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- zwarm/adapters/base.py,sha256=fZlQviTgVvOcwnxduTla6WuM6FzQJ_yoHMW5SxwVgQg,2527
5
- zwarm/adapters/claude_code.py,sha256=WAjWlmTSt8QAexl03D2P1iX8qJvOp_t7PYvewda762g,9353
6
- zwarm/adapters/codex_mcp.py,sha256=DFFnA5zX-kyk_GIWpZDB7cUdfVBo5H0NTY72FKBuj_M,13326
7
- zwarm/adapters/test_codex_mcp.py,sha256=qXqpdPT2MZQs7XrO6tVuwxtUgL74CEUFTopjVLuHcHg,8289
8
- zwarm/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
- zwarm/cli/main.py,sha256=rbDWvbJsmfj1dYTOJnNqgiTUdeFSHcO0g6M7TYYiuWw,17201
10
- zwarm/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- zwarm/core/config.py,sha256=b2pRduPbBz84jRorX4VkPFY90et2cnghPQCmIfnMpBM,8254
12
- zwarm/core/environment.py,sha256=aJnCewZt9KTxiisY3lN7R8XpMgZq0V64FEr0h8Wgea8,2521
13
- zwarm/core/models.py,sha256=6EZk8k_JuVmyXAGLniGKlcPvBolwoZ4nHKZyaFp3X7E,9484
14
- zwarm/core/state.py,sha256=wMryIvXP-VDLh2b76A5taeL_9dm5k4jk4HnvHWgLqGE,7658
15
- zwarm/core/test_config.py,sha256=26ozyiFOdjFF2c9Q-HDfFM6GOLfgw_5FZ55nTDMNYA8,4888
16
- zwarm/core/test_models.py,sha256=sWTIhMZvuLP5AooGR6y8OR2EyWydqVfhmGrE7NPBBnk,8450
17
- zwarm/prompts/__init__.py,sha256=FiaIOniLrIyfD3_osxT6I7FfyKjtctbf8jNs5QTPs_s,213
18
- zwarm/prompts/orchestrator.py,sha256=9js2v1QS5XAAUcdsYXOUzyTeIAnPoeODC5Bgjay4Uhc,7142
19
- zwarm/tools/__init__.py,sha256=FpqxwXJA6-fQ7C-oLj30jjK_0qqcE7MbI0dQuaB56kU,290
20
- zwarm/tools/delegation.py,sha256=ZlVbe4SF96qx3YaDjloSY3eh29OY0wvFWwCSBGKMomo,10789
21
- zwarm/watchers/__init__.py,sha256=yYGTbhuImQLESUdtfrYbHYBJNvCNX3B-Ei-vY5BizX8,760
22
- zwarm/watchers/base.py,sha256=r1GoPlj06nOT2xp4fghfSjxbRyFFFQUB6HpZbEyO2OY,3834
23
- zwarm/watchers/builtin.py,sha256=hZD23FR2PGpAArOvf8rzSfXLW1yt5dvHyqGgJv1be74,9000
24
- zwarm/watchers/manager.py,sha256=n4EPVcMz7KQaodShhaqnF3ooeZK8KFLJih63MaaiXTQ,4442
25
- zwarm/watchers/registry.py,sha256=A9iBIVIFNtO7KPX0kLpUaP8dAK7ozqWLA44ocJGnOw4,1219
26
- zwarm/watchers/test_watchers.py,sha256=JVDardNne1BurFyKG7U6vESViFSWj50q23yZq3M94kQ,6219
27
- zwarm-0.1.0.dist-info/METADATA,sha256=yyroWT7zzzjx5ZsRFH7dOUB6HfR89Mc5wwMf68GAGfM,10038
28
- zwarm-0.1.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
29
- zwarm-0.1.0.dist-info/entry_points.txt,sha256=u0OXq4q8d3yJ3EkUXwZfkS-Y8Lcy0F8cWrcQfoRxM6Q,46
30
- zwarm-0.1.0.dist-info/RECORD,,
File without changes