@adamancyzhang/claude-orchestrator 0.1.0 → 0.2.0

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.
Files changed (43) hide show
  1. package/README.md +401 -0
  2. package/bin/claude-orchestrator +2 -17
  3. package/dist/cli/commands.d.ts +20 -0
  4. package/dist/cli/commands.js +192 -0
  5. package/dist/cli/commands.js.map +1 -0
  6. package/dist/config.d.ts +17 -0
  7. package/dist/config.js +45 -0
  8. package/dist/config.js.map +1 -0
  9. package/dist/index.d.ts +2 -0
  10. package/dist/index.js +344 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/models/schemas.d.ts +308 -0
  13. package/dist/models/schemas.js +167 -0
  14. package/dist/models/schemas.js.map +1 -0
  15. package/dist/modules/context-store.d.ts +10 -0
  16. package/dist/modules/context-store.js +25 -0
  17. package/dist/modules/context-store.js.map +1 -0
  18. package/dist/modules/message-router.d.ts +12 -0
  19. package/dist/modules/message-router.js +94 -0
  20. package/dist/modules/message-router.js.map +1 -0
  21. package/dist/modules/registry.d.ts +11 -0
  22. package/dist/modules/registry.js +53 -0
  23. package/dist/modules/registry.js.map +1 -0
  24. package/dist/modules/task-queue.d.ts +10 -0
  25. package/dist/modules/task-queue.js +103 -0
  26. package/dist/modules/task-queue.js.map +1 -0
  27. package/dist/server.d.ts +2 -0
  28. package/dist/server.js +425 -0
  29. package/dist/server.js.map +1 -0
  30. package/dist/utils/output.d.ts +1 -0
  31. package/dist/utils/output.js +10 -0
  32. package/dist/utils/output.js.map +1 -0
  33. package/dist/zk/client.d.ts +54 -0
  34. package/dist/zk/client.js +417 -0
  35. package/dist/zk/client.js.map +1 -0
  36. package/dist/zk/paths.d.ts +16 -0
  37. package/dist/zk/paths.js +40 -0
  38. package/dist/zk/paths.js.map +1 -0
  39. package/dist/zk/watcher.d.ts +11 -0
  40. package/dist/zk/watcher.js +16 -0
  41. package/dist/zk/watcher.js.map +1 -0
  42. package/package.json +23 -6
  43. package/scripts/install.js +0 -123
package/README.md ADDED
@@ -0,0 +1,401 @@
1
+ # Claude Orchestrator
2
+
3
+ <p align="center">
4
+ <strong>Turn Claude Code instances into a multi-agent swarm — coordinated through ZooKeeper.</strong>
5
+ <br/>
6
+ <em><a href="README_zh.md">中文文档</a></em>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="https://www.npmjs.com/package/@adamancyzhang/claude-orchestrator"><img src="https://img.shields.io/npm/v/@adamancyzhang/claude-orchestrator?color=blue" alt="npm"></a>
11
+ <a href="https://github.com/adamancyzhang/claude-orchestrator-server"><img src="https://img.shields.io/github/license/adamancyzhang/claude-orchestrator-server" alt="license"></a>
12
+ <a href="https://pypi.org/project/claude-mcp-server/"><img src="https://img.shields.io/pypi/v/claude-mcp-server?color=yellow" alt="PyPI"></a>
13
+ <img src="https://img.shields.io/badge/python-3.12%2B-blue" alt="python">
14
+ <img src="https://img.shields.io/badge/ZooKeeper-3.8%2B-orange" alt="zookeeper">
15
+ </p>
16
+
17
+ ---
18
+
19
+ ## What is this?
20
+
21
+ **Claude Orchestrator** lets you run multiple Claude Code instances that talk to each other — assign tasks, send messages, share context, and collaborate on real work. Think of it as giving each Claude Code instance a walkie-talkie and a shared kanban board, then watching them build together.
22
+
23
+ Behind the scenes, ZooKeeper acts as the coordination backbone: ephemeral nodes for instance heartbeat, sequential nodes for FIFO task ordering, and watches for real-time change notification.
24
+
25
+ ```
26
+ ┌──────────────────────────────────────────────────────────┐
27
+ │ Claude Orchestrator │
28
+ │ (MCP Server :3100) │
29
+ │ │
30
+ │ ┌──────────────┐ ┌──────────┐ ┌──────────────┐ │
31
+ │ │ Registry │ │ Tasks │ │ Messages │ │
32
+ │ │ who's here? │ │ FIFO Q │ │ P2P + cast │ │
33
+ │ └──────┬───────┘ └────┬─────┘ └──────┬───────┘ │
34
+ │ └────────────────┼──────────────┘ │
35
+ │ ┌──────┴──────┐ │
36
+ │ │ ZooKeeper │ │
37
+ │ └──────┬──────┘ │
38
+ │ ┌──────┴──────┐ │
39
+ │ │ Context │ │
40
+ │ │ KV Store │ │
41
+ │ └─────────────┘ │
42
+ └──────────────────────────────────────────────────────────┘
43
+ ▲ ▲ ▲
44
+ │ │ │
45
+ ┌────┴────┐ ┌────┴────┐ ┌────┴────┐
46
+ │ Tom │ │ Jerry │ │ Bob │
47
+ │Architect│ │Developer│ │ Tester │
48
+ └─────────┘ └─────────┘ └─────────┘
49
+ ```
50
+
51
+ ---
52
+
53
+ ## Quick Start
54
+
55
+ ### 1. Install the CLI
56
+
57
+ ```bash
58
+ # One command, all platforms
59
+ npm install -g @adamancyzhang/claude-orchestrator
60
+ ```
61
+
62
+ Post-install downloads the right native binary for your OS (macOS/Linux, arm64/x64). If no prebuilt binary matches, `scripts/build-binary.sh` builds one locally.
63
+
64
+ ### 2. Start ZooKeeper
65
+
66
+ ```bash
67
+ docker-compose up -d
68
+ ```
69
+
70
+ ### 3. Start the MCP Server
71
+
72
+ ```bash
73
+ # From source
74
+ pip install -e ".[dev]"
75
+ python -m src.server
76
+ # → Server listening on http://127.0.0.1:3100
77
+ ```
78
+
79
+ ### 4. Configure Claude Code
80
+
81
+ In your project's `.claude/mcp.json` (or `~/.claude/mcp.json`):
82
+
83
+ ```json
84
+ {
85
+ "mcpServers": {
86
+ "orchestrator": {
87
+ "type": "http",
88
+ "url": "http://127.0.0.1:3100/mcp"
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ ### 5. Register & Go
95
+
96
+ Open Claude Code, then:
97
+
98
+ ```
99
+ I have an MCP tool called orchestrator. Call register_instance
100
+ with name="Tom" and role="architect". Remember my instance_id.
101
+ ```
102
+
103
+ Now open another terminal, start a second Claude Code instance, and register Jerry as a developer. They'll discover each other, pass tasks, and collaborate.
104
+
105
+ ---
106
+
107
+ ## How It Works
108
+
109
+ ### Four Modules, One ZooKeeper
110
+
111
+ | Module | What it does | ZK magic |
112
+ |--------|-------------|----------|
113
+ | **Instance Registry** | Register, heartbeat, discover | Ephemeral nodes → auto-cleanup on disconnect |
114
+ | **Task Queue** | Push → Claim → Complete | Sequential nodes for FIFO, ephemeral claims for atomic locks |
115
+ | **Message Router** | P2P messages, broadcast, help requests | Persistent-sequential nodes, poll-based retrieval |
116
+ | **Context Store** | Shared key-value storage | Persistent nodes, cross-instance visibility |
117
+
118
+ ### The MCP Tools
119
+
120
+ Each Claude Code instance calls these tools to participate in the swarm:
121
+
122
+ | # | Tool | What it does |
123
+ |---|------|-------------|
124
+ | 1 | `register_instance` | Join the swarm with a name and role |
125
+ | 2 | `heartbeat` | Stay alive, optionally report what you're working on |
126
+ | 3 | `list_instances` | See who's online right now |
127
+ | 4 | `push_task` | Create a task (optionally assign to someone specific) |
128
+ | 5 | `claim_task` | Grab the next task — atomic, no two instances can claim the same one |
129
+ | 6 | `complete_task` | Mark a task done with results |
130
+ | 7 | `list_tasks` | View tasks by status (pending / claimed / completed) |
131
+ | 8 | `send_message` | DM another instance or broadcast to everyone |
132
+ | 9 | `poll_messages` | Check your inbox |
133
+ | 10 | `request_help` | Broadcast a question to the whole team |
134
+ | 11 | `set_context` | Write a shared key-value entry |
135
+ | 12 | `get_context` | Read a shared key-value entry |
136
+
137
+ ### Or Use the CLI Directly
138
+
139
+ If you prefer the terminal over Claude Code:
140
+
141
+ ```bash
142
+ # Register
143
+ claude-orchestrator register --name Alice --role developer
144
+
145
+ # See who's around
146
+ claude-orchestrator list-instances
147
+
148
+ # Push a task
149
+ claude-orchestrator push-task --title "Add rate limiting" --priority 0
150
+
151
+ # Claim the next task
152
+ claude-orchestrator claim-task
153
+
154
+ # Send a message
155
+ claude-orchestrator send-message --to <instance-id> --content "How's PR #42 going?"
156
+
157
+ # Check inbox
158
+ claude-orchestrator poll-messages
159
+
160
+ # Share context
161
+ claude-orchestrator set-context --key "api_version" --value "v2.1"
162
+
163
+ # Read shared context
164
+ claude-orchestrator get-context --key "api_version"
165
+
166
+ # Health check
167
+ claude-orchestrator status
168
+ ```
169
+
170
+ All CLI commands return JSON. Every command supports `--zk-hosts` (or `ZK_HOSTS` env var) for pointing at a remote ZooKeeper.
171
+
172
+ ---
173
+
174
+ ## Example Session
175
+
176
+ Here's a real flow with two instances — Tom (Architect) and Jerry (Developer):
177
+
178
+ **Tom registers:**
179
+ ```json
180
+ { "id": "a1b2c3d4...", "name": "Tom", "role": "architect", "status": "idle" }
181
+ ```
182
+
183
+ **Jerry registers:**
184
+ ```json
185
+ { "id": "f6e5d4c3...", "name": "Jerry", "role": "developer", "status": "idle" }
186
+ ```
187
+
188
+ **Tom lists instances:**
189
+ ```
190
+ 2 active instances:
191
+ [architect] Tom (a1b2c3d4...) status=idle
192
+ [developer] Jerry (f6e5d4c3...) status=idle
193
+ ```
194
+
195
+ **Tom assigns work:**
196
+ ```
197
+ push_task:
198
+ title: "Implement POST /api/auth/login"
199
+ description: "Email+password login, return JWT. Handle validation and errors."
200
+ priority: HIGH (0)
201
+ assignee: f6e5d4c3... (Jerry)
202
+ ```
203
+
204
+ **Jerry claims it:**
205
+ ```
206
+ claim_task → Got it! task-0000000000
207
+ heartbeat current_task="task-0000000000"
208
+ ```
209
+
210
+ **Jerry gets stuck and asks for help:**
211
+ ```
212
+ request_help:
213
+ question: "What should the JWT expiry be? Access vs refresh token?"
214
+ context: "FastAPI + python-jose, ~100K DAU"
215
+ ```
216
+
217
+ **Tom checks messages and replies:**
218
+ ```
219
+ poll_messages → 1 new message from Jerry
220
+ send_message to=Jerry: "15min access, 7d refresh. Use Redis blacklist for logout."
221
+ ```
222
+
223
+ **Tom records the decision:**
224
+ ```
225
+ set_context key="jwt_strategy" value="access:15min, refresh:7d, blacklist:redis"
226
+ ```
227
+
228
+ **Jerry finishes:**
229
+ ```
230
+ complete_task task_id="task-0000000000" result="PR #42 — implemented login endpoint with tests"
231
+ ```
232
+
233
+ No polling required for task claiming — the atomic claim mechanism means Jerry always gets the right task. Messages are delivered instantly via ZooKeeper's persistent-sequential nodes.
234
+
235
+ ---
236
+
237
+ ## ZooKeeper Schema
238
+
239
+ ```
240
+ /claude-orchestrator
241
+ ├── instances/
242
+ │ ├── a1b2c3d4... [EPHEMERAL] Tom's registration
243
+ │ └── f6e5d4c3... [EPHEMERAL] Jerry's registration
244
+ ├── tasks/
245
+ │ ├── pending/
246
+ │ │ ├── task-0000000000 [PERSISTENT_SEQUENTIAL]
247
+ │ │ └── task-0000000001 [PERSISTENT_SEQUENTIAL]
248
+ │ ├── claimed/
249
+ │ │ └── f6e5d4c3-task-0000000000 [EPHEMERAL] ← atomic lock!
250
+ │ └── completed/
251
+ │ └── task-0000000000 [PERSISTENT]
252
+ ├── messages/
253
+ │ ├── a1b2c3d4.../
254
+ │ │ └── msg-0000000000 [PERSISTENT_SEQUENTIAL]
255
+ │ └── f6e5d4c3.../
256
+ │ └── msg-0000000000 [PERSISTENT_SEQUENTIAL]
257
+ └── context/
258
+ └── jwt_strategy [PERSISTENT]
259
+ ```
260
+
261
+ **Key insight:** Ephemeral nodes mean crashed instances auto-unregister. Ephemeral claim nodes mean abandoned tasks auto-release. No deadlocks, no orphans. ZooKeeper handles the lifecycle.
262
+
263
+ ---
264
+
265
+ ## Installation & Development
266
+
267
+ ### Prerequisites
268
+
269
+ - Python 3.12+
270
+ - Docker (for ZooKeeper)
271
+ - Node.js 18+ (for the npm CLI wrapper)
272
+ - Claude Code (for the MCP integration)
273
+
274
+ ### From Source
275
+
276
+ ```bash
277
+ git clone https://github.com/adamancyzhang/claude-orchestrator-server.git
278
+ cd claude-orchestrator-server
279
+
280
+ # Install Python dependencies
281
+ pip install -e ".[dev]"
282
+
283
+ # Start ZooKeeper
284
+ docker-compose up -d
285
+
286
+ # Run the server
287
+ python -m src.server
288
+
289
+ # Or use the CLI directly
290
+ claude-orchestrator status
291
+ ```
292
+
293
+ ### Build a Standalone Binary
294
+
295
+ ```bash
296
+ bash scripts/build-binary.sh
297
+ # Output: dist/claude-orchestrator-{platform}-{arch}
298
+ ```
299
+
300
+ The binary is a single file with zero dependencies — Python, ZooKeeper client, and all libraries bundled via PyInstaller.
301
+
302
+ ### Run Tests
303
+
304
+ ```bash
305
+ # End-to-end MCP verification (requires running server + ZK)
306
+ python tests/verify_mvp.py
307
+ ```
308
+
309
+ ---
310
+
311
+ ## Skills for Claude Code
312
+
313
+ The repo includes Claude Code skills that make the orchestrator even easier to use:
314
+
315
+ | Skill | What it does |
316
+ |-------|-------------|
317
+ | `claude-orchestrator` | Full CLI reference — all 12 commands with examples |
318
+ | `orchestrator-register` | Guided registration flow |
319
+ | `orchestrator-status` | Dashboard: health, instances, tasks |
320
+ | `orchestrator-communicate` | Message patterns: poll, DM, broadcast |
321
+ | `orchestrator-help` | Help-request workflow |
322
+ | `orchestrator-agent` | Autonomous agent loop: check → claim → work → complete |
323
+
324
+ ---
325
+
326
+ ## Why ZooKeeper?
327
+
328
+ | Concern | ZooKeeper answer |
329
+ |---------|-----------------|
330
+ | Instance lifecycle | Ephemeral nodes → auto-cleanup. No heartbeat polling needed. |
331
+ | Task ordering | Sequential nodes → guaranteed FIFO. No race conditions. |
332
+ | Claim atomicity | `create(path, ephemeral=True)` is atomic at the ZK level. Only one winner. |
333
+ | Change notification | Built-in watches → push, not poll. |
334
+ | Dependencies | One dependency (ZK) vs. Redis + Postgres combination. |
335
+
336
+ Zero external database. All state lives in ZooKeeper. For archival beyond ZK's data limits, a lightweight SQLite log is the recommended addition.
337
+
338
+ ---
339
+
340
+ ## Roles
341
+
342
+ | Role | Value | Typical behavior |
343
+ |------|-------|-----------------|
344
+ | Architect | `architect` | Sets standards, designs tasks, reviews results |
345
+ | Developer | `developer` | Claims tasks, writes code, submits PRs |
346
+ | Tester | `tester` | Claims test tasks, E2E verification |
347
+ | General | `general` | Any role |
348
+
349
+ ---
350
+
351
+ ## Configuration Reference
352
+
353
+ | Config | Where | Default |
354
+ |--------|-------|---------|
355
+ | ZK hosts | `--zk-hosts` flag or `ZK_HOSTS` env | `127.0.0.1:2181` |
356
+ | Instance ID | `--instance-id` flag or `~/.claude-orchestrator/config.json` | auto-saved after `register` |
357
+ | MCP server host | `src/server.py` | `127.0.0.1:3100` |
358
+
359
+ ---
360
+
361
+ ## Project Structure
362
+
363
+ ```
364
+ ├── src/
365
+ │ ├── server.py # FastMCP server — 12 tools
366
+ │ ├── cli.py # Click CLI — 12 commands
367
+ │ ├── zk_client.py # ZooKeeper CRUD + reconnect
368
+ │ ├── registry.py # Instance registration + heartbeat
369
+ │ ├── task_queue.py # Push → Claim → Complete
370
+ │ ├── message_router.py # Send → Poll → Request Help
371
+ │ ├── context_store.py # Get → Set shared KV
372
+ │ └── models.py # Pydantic data models
373
+ ├── bin/
374
+ │ └── claude-orchestrator # npm CLI entry (Node.js shim)
375
+ ├── scripts/
376
+ │ ├── install.js # npm postinstall — download binary
377
+ │ ├── build-binary.sh # PyInstaller packager
378
+ │ ├── start-zk.sh # Docker ZK launcher
379
+ │ ├── start-server.sh # Server launcher
380
+ │ └── stop-all.sh # Tear down
381
+ ├── skills/ # Claude Code skills
382
+ ├── tests/
383
+ │ └── verify_mvp.py # E2E MCP verification
384
+ ├── docs/
385
+ │ ├── prd/ # Full spec + architecture
386
+ │ └── operations-guide.md # Step-by-step walkthrough (Chinese)
387
+ ├── docker-compose.yml # ZooKeeper
388
+ └── package.json # npm package definition
389
+ ```
390
+
391
+ ---
392
+
393
+ ## License
394
+
395
+ MIT — use it, fork it, ship it.
396
+
397
+ ---
398
+
399
+ <p align="center">
400
+ <sub>Built with Python, ZooKeeper, and the MCP protocol. Orchestrate responsibly.</sub>
401
+ </p>
@@ -1,20 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const { spawnSync } = require("child_process");
3
- const path = require("path");
4
- const fs = require("fs");
5
-
6
- const binary = path.join(__dirname, "orchestrator-binary");
7
-
8
- if (!fs.existsSync(binary)) {
9
- console.error(`Error: orchestrator-binary not found at ${binary}`);
10
- console.error(
11
- "Run 'node scripts/install.js' to download it, or build with 'bash scripts/build-binary.sh'"
12
- );
2
+ import("../dist/index.js").catch((err) => {
3
+ console.error(err);
13
4
  process.exit(1);
14
- }
15
-
16
- const result = spawnSync(binary, process.argv.slice(2), {
17
- stdio: "inherit",
18
5
  });
19
-
20
- process.exit(result.status ?? 1);
@@ -0,0 +1,20 @@
1
+ export declare function cmdStatus(zkHosts: string): Promise<void>;
2
+ export declare function cmdRegister(zkHosts: string, instanceId: string | undefined, name: string, role: string): Promise<void>;
3
+ export declare function cmdHeartbeat(zkHosts: string, cliInstanceId: string | undefined, currentTask?: string): Promise<void>;
4
+ export declare function cmdListInstances(zkHosts: string): Promise<void>;
5
+ export declare function cmdPushTask(zkHosts: string, cliInstanceId: string | undefined, title: string, description: string, priority: number, assignee?: string): Promise<void>;
6
+ export declare function cmdClaimTask(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
7
+ export declare function cmdCompleteTask(zkHosts: string, cliInstanceId: string | undefined, taskId: string, result: string): Promise<void>;
8
+ export declare function cmdListTasks(zkHosts: string, statusFilter?: string): Promise<void>;
9
+ export declare function cmdSendMessage(zkHosts: string, cliInstanceId: string | undefined, content: string, toInstance?: string, broadcast?: boolean): Promise<void>;
10
+ export declare function cmdPollMessages(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
11
+ export declare function cmdWaitForMessage(zkHosts: string, cliInstanceId: string | undefined, timeout: number): Promise<void>;
12
+ export declare function cmdDismissMessage(zkHosts: string, cliInstanceId: string | undefined, messageId: string): Promise<void>;
13
+ export declare function cmdRequestHelp(zkHosts: string, cliInstanceId: string | undefined, question: string, ctx?: string): Promise<void>;
14
+ export declare function cmdSetContext(zkHosts: string, cliInstanceId: string | undefined, key: string, value: string): Promise<void>;
15
+ export declare function cmdGetContext(zkHosts: string, key: string): Promise<void>;
16
+ export declare function cmdDeleteContext(zkHosts: string, key: string): Promise<void>;
17
+ export declare function cmdListContextKeys(zkHosts: string): Promise<void>;
18
+ export declare function cmdWatchContext(zkHosts: string, key: string): Promise<void>;
19
+ export declare function cmdWatchTasks(zkHosts: string): Promise<void>;
20
+ export declare function cmdUnregister(zkHosts: string, cliInstanceId: string | undefined): Promise<void>;
@@ -0,0 +1,192 @@
1
+ import { ZkClient } from "../zk/client.js";
2
+ import { InstanceRegistry } from "../modules/registry.js";
3
+ import { TaskQueue } from "../modules/task-queue.js";
4
+ import { MessageRouter } from "../modules/message-router.js";
5
+ import { ContextStore } from "../modules/context-store.js";
6
+ import { resolveInstanceId, saveInstanceId } from "../config.js";
7
+ import { output } from "../utils/output.js";
8
+ async function withZk(hosts, fn) {
9
+ const zk = new ZkClient(hosts);
10
+ await zk.connect();
11
+ const registry = new InstanceRegistry(zk);
12
+ const taskQueue = new TaskQueue(zk);
13
+ const messageRouter = new MessageRouter(zk);
14
+ const contextStore = new ContextStore(zk);
15
+ try {
16
+ return await fn({ zk, registry, taskQueue, messageRouter, contextStore });
17
+ }
18
+ finally {
19
+ await zk.disconnect();
20
+ }
21
+ }
22
+ export async function cmdStatus(zkHosts) {
23
+ await withZk(zkHosts, async ({ zk, registry }) => {
24
+ const connected = zk.connected;
25
+ const instances = await registry.listAll();
26
+ output({
27
+ status: connected ? "healthy" : "degraded",
28
+ zookeeper: connected ? "connected" : "disconnected",
29
+ instances_online: instances.length,
30
+ });
31
+ });
32
+ }
33
+ export async function cmdRegister(zkHosts, instanceId, name, role) {
34
+ await withZk(zkHosts, async ({ registry }) => {
35
+ const instance = await registry.register(name, role, instanceId);
36
+ saveInstanceId(instance.id);
37
+ output(instance);
38
+ });
39
+ }
40
+ export async function cmdHeartbeat(zkHosts, cliInstanceId, currentTask) {
41
+ await withZk(zkHosts, async ({ registry }) => {
42
+ const instanceId = resolveInstanceId(cliInstanceId);
43
+ await registry.heartbeat(instanceId, currentTask);
44
+ output({ status: "ok", instance_id: instanceId });
45
+ });
46
+ }
47
+ export async function cmdListInstances(zkHosts) {
48
+ await withZk(zkHosts, async ({ registry }) => {
49
+ const instances = await registry.listAll();
50
+ output(instances);
51
+ });
52
+ }
53
+ export async function cmdPushTask(zkHosts, cliInstanceId, title, description, priority, assignee) {
54
+ await withZk(zkHosts, async ({ taskQueue }) => {
55
+ const instanceId = cliInstanceId ?? "";
56
+ const task = await taskQueue.push(title, description, priority, instanceId, assignee);
57
+ output(task);
58
+ });
59
+ }
60
+ export async function cmdClaimTask(zkHosts, cliInstanceId) {
61
+ await withZk(zkHosts, async ({ taskQueue }) => {
62
+ const instanceId = resolveInstanceId(cliInstanceId);
63
+ const task = await taskQueue.claim(instanceId);
64
+ if (!task) {
65
+ output({ status: "no_tasks", message: "No pending tasks available." });
66
+ }
67
+ else {
68
+ output(task);
69
+ }
70
+ });
71
+ }
72
+ export async function cmdCompleteTask(zkHosts, cliInstanceId, taskId, result) {
73
+ await withZk(zkHosts, async ({ taskQueue }) => {
74
+ const instanceId = resolveInstanceId(cliInstanceId);
75
+ const task = await taskQueue.complete(instanceId, taskId, result);
76
+ output(task);
77
+ });
78
+ }
79
+ export async function cmdListTasks(zkHosts, statusFilter) {
80
+ await withZk(zkHosts, async ({ taskQueue }) => {
81
+ const tasks = await taskQueue.listTasks(statusFilter);
82
+ output(tasks);
83
+ });
84
+ }
85
+ export async function cmdSendMessage(zkHosts, cliInstanceId, content, toInstance, broadcast = false) {
86
+ await withZk(zkHosts, async ({ registry, messageRouter }) => {
87
+ const instanceId = resolveInstanceId(cliInstanceId);
88
+ const inst = await registry.get(instanceId);
89
+ const fromName = inst?.name ?? instanceId.slice(0, 8);
90
+ const messages = await messageRouter.send(instanceId, fromName, content, toInstance, broadcast);
91
+ const targets = messages.map((m) => m.to_instance);
92
+ output({ sent_to: targets, message_count: targets.length });
93
+ });
94
+ }
95
+ export async function cmdPollMessages(zkHosts, cliInstanceId) {
96
+ await withZk(zkHosts, async ({ messageRouter }) => {
97
+ const instanceId = resolveInstanceId(cliInstanceId);
98
+ const messages = await messageRouter.poll(instanceId);
99
+ output(messages);
100
+ });
101
+ }
102
+ export async function cmdWaitForMessage(zkHosts, cliInstanceId, timeout) {
103
+ await withZk(zkHosts, async ({ messageRouter }) => {
104
+ const instanceId = resolveInstanceId(cliInstanceId);
105
+ const messages = await messageRouter.waitForMessage(instanceId, timeout);
106
+ output(messages.length > 0 ? messages : { status: "timeout", message: "No messages received." });
107
+ });
108
+ }
109
+ export async function cmdDismissMessage(zkHosts, cliInstanceId, messageId) {
110
+ await withZk(zkHosts, async ({ messageRouter }) => {
111
+ const instanceId = resolveInstanceId(cliInstanceId);
112
+ await messageRouter.dismissMessage(instanceId, messageId);
113
+ output({ status: "dismissed", message_id: messageId });
114
+ });
115
+ }
116
+ export async function cmdRequestHelp(zkHosts, cliInstanceId, question, ctx) {
117
+ await withZk(zkHosts, async ({ registry, messageRouter }) => {
118
+ const instanceId = resolveInstanceId(cliInstanceId);
119
+ const inst = await registry.get(instanceId);
120
+ const fromName = inst?.name ?? instanceId.slice(0, 8);
121
+ const messages = await messageRouter.requestHelp(instanceId, fromName, question, ctx);
122
+ const targets = messages.map((m) => m.to_instance);
123
+ output({ sent_to: targets, message_count: targets.length });
124
+ });
125
+ }
126
+ export async function cmdSetContext(zkHosts, cliInstanceId, key, value) {
127
+ await withZk(zkHosts, async ({ contextStore }) => {
128
+ const instanceId = cliInstanceId ?? "";
129
+ const entry = await contextStore.set(key, value, instanceId);
130
+ output(entry);
131
+ });
132
+ }
133
+ export async function cmdGetContext(zkHosts, key) {
134
+ await withZk(zkHosts, async ({ contextStore }) => {
135
+ const value = await contextStore.get(key);
136
+ if (value === null) {
137
+ output({ key, value: null, status: "not_found" });
138
+ }
139
+ else {
140
+ output({ key, value });
141
+ }
142
+ });
143
+ }
144
+ export async function cmdDeleteContext(zkHosts, key) {
145
+ await withZk(zkHosts, async ({ contextStore }) => {
146
+ await contextStore.delete(key);
147
+ output({ key, status: "deleted" });
148
+ });
149
+ }
150
+ export async function cmdListContextKeys(zkHosts) {
151
+ await withZk(zkHosts, async ({ contextStore }) => {
152
+ const keys = await contextStore.listKeys();
153
+ output({ keys, count: keys.length });
154
+ });
155
+ }
156
+ export async function cmdWatchContext(zkHosts, key) {
157
+ await withZk(zkHosts, async ({ zk }) => {
158
+ const value = await zk.watchContextKey(key, (newData) => {
159
+ output({ key, value: newData?.value ?? null, event: "changed" });
160
+ process.exit(0);
161
+ });
162
+ if (value === null) {
163
+ output({ key, value: null, message: `Watching key '${key}' for changes... (Ctrl+C to stop)` });
164
+ }
165
+ else {
166
+ output({ key, value: value.value, message: `Watching key '${key}' for changes... (Ctrl+C to stop)` });
167
+ }
168
+ // Keep process alive waiting for watch callback
169
+ await new Promise(() => { });
170
+ });
171
+ }
172
+ export async function cmdWatchTasks(zkHosts) {
173
+ await withZk(zkHosts, async ({ zk }) => {
174
+ const children = await zk.watchPendingTasks((newChildren) => {
175
+ output({ event: "tasks_changed", pending_count: newChildren.length, tasks: newChildren });
176
+ process.exit(0);
177
+ });
178
+ output({
179
+ pending_count: children.length,
180
+ message: "Watching for new tasks... (Ctrl+C to stop)",
181
+ });
182
+ await new Promise(() => { });
183
+ });
184
+ }
185
+ export async function cmdUnregister(zkHosts, cliInstanceId) {
186
+ await withZk(zkHosts, async ({ registry }) => {
187
+ const instanceId = resolveInstanceId(cliInstanceId);
188
+ await registry.unregister(instanceId);
189
+ output({ status: "unregistered", instance_id: instanceId });
190
+ });
191
+ }
192
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAG5C,KAAK,UAAU,MAAM,CAC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ts: string;
3
+ port: number;
4
+ host: string;
5
+ instanceId?: string;
6
+ serverMode: boolean;
7
+ }
8
+ export declare function loadConfig(cliOpts: {
9
+ zookeeper?: string;
10
+ port?: string;
11
+ host?: string;
12
+ instanceId?: string;
13
+ server?: boolean;
14
+ }): Config;
15
+ export declare function saveInstanceId(instanceId: string): void;
16
+ export declare function loadInstanceId(): string | null;
17
+ export declare function resolveInstanceId(cliInstanceId?: string): string;