@adamancyzhang/claude-orchestrator 0.3.1 → 0.3.2
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.
- package/README.md +68 -59
- package/dist/cli/commands.d.ts +2 -2
- package/dist/cli/commands.js +51 -24
- package/dist/cli/commands.js.map +1 -1
- package/dist/config.d.ts +8 -2
- package/dist/config.js +6 -2
- package/dist/config.js.map +1 -1
- package/dist/executor/runner.d.ts +19 -0
- package/dist/executor/runner.js +59 -0
- package/dist/executor/runner.js.map +1 -0
- package/dist/executor/template.d.ts +12 -0
- package/dist/executor/template.js +42 -0
- package/dist/executor/template.js.map +1 -0
- package/dist/hooks/engine.d.ts +22 -0
- package/dist/hooks/engine.js +50 -0
- package/dist/hooks/engine.js.map +1 -0
- package/dist/index.js +16 -15
- package/dist/index.js.map +1 -1
- package/dist/leader/chain-router.d.ts +22 -0
- package/dist/leader/chain-router.js +163 -0
- package/dist/leader/chain-router.js.map +1 -0
- package/dist/leader/event-bus.d.ts +1 -1
- package/dist/leader/event-bus.js +1 -1
- package/dist/leader/event-bus.js.map +1 -1
- package/dist/leader/index.d.ts +1 -2
- package/dist/leader/index.js +30 -18
- package/dist/leader/index.js.map +1 -1
- package/dist/leader/state.js +9 -0
- package/dist/leader/state.js.map +1 -1
- package/dist/leader/tui.d.ts +8 -0
- package/dist/leader/tui.js +66 -4
- package/dist/leader/tui.js.map +1 -1
- package/dist/leader/watcher.d.ts +4 -5
- package/dist/leader/watcher.js +8 -25
- package/dist/leader/watcher.js.map +1 -1
- package/dist/models/schemas.d.ts +256 -0
- package/dist/models/schemas.js +25 -0
- package/dist/models/schemas.js.map +1 -1
- package/dist/skills/claude-orchestrator/SKILL.md +124 -60
- package/dist/templates/{leader-decompose.md → worker-decompose.md} +6 -8
- package/dist/templates/worker-evaluate.md +41 -0
- package/dist/utils/exec.js +2 -0
- package/dist/utils/exec.js.map +1 -1
- package/dist/utils/logger.d.ts +10 -0
- package/dist/utils/logger.js +22 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/worker/evaluator.d.ts +13 -0
- package/dist/worker/evaluator.js +112 -0
- package/dist/worker/evaluator.js.map +1 -0
- package/dist/worker/watcher.d.ts +11 -5
- package/dist/worker/watcher.js +98 -84
- package/dist/worker/watcher.js.map +1 -1
- package/package.json +1 -1
- package/dist/leader/decision-engine.d.ts +0 -35
- package/dist/leader/decision-engine.js +0 -102
- package/dist/leader/decision-engine.js.map +0 -1
- package/dist/leader/task-generator.d.ts +0 -34
- package/dist/leader/task-generator.js +0 -93
- package/dist/leader/task-generator.js.map +0 -1
- package/dist/templates/leader-decide.md +0 -59
|
@@ -22,51 +22,88 @@ Every CLI command talks directly to ZooKeeper. Instance discovery is via ephemer
|
|
|
22
22
|
## Setup
|
|
23
23
|
|
|
24
24
|
```bash
|
|
25
|
-
|
|
25
|
+
npm install -g @adamancyzhang/claude-orchestrator
|
|
26
26
|
docker-compose up -d # start ZooKeeper
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
Initialize environment:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
# Leader (team coordinator):
|
|
33
|
+
claude-orchestrator setup --leader --name Tom
|
|
34
|
+
|
|
35
|
+
# Worker (the doers):
|
|
36
|
+
claude-orchestrator setup --name Jerry --role builder
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
This creates:
|
|
40
|
+
- `.claude-orchestrator/agents/` — message templates (7 templates for leader + 5 worker links)
|
|
41
|
+
- `.claude/skills/` — 8 Claude Code skills (responsibility chain + infrastructure)
|
|
42
|
+
- `.claude-orchestrator/config.json` — project config (name, role)
|
|
43
|
+
- `~/.claude-orchestrator/config.json` — global config (ZK hosts, CLI command, cache dir)
|
|
44
|
+
|
|
29
45
|
Verify:
|
|
30
46
|
|
|
31
47
|
```bash
|
|
32
|
-
claude-orchestrator
|
|
33
|
-
#
|
|
48
|
+
claude-orchestrator config
|
|
49
|
+
# Shows current configuration
|
|
34
50
|
```
|
|
35
51
|
|
|
36
52
|
## Global Options
|
|
37
53
|
|
|
38
54
|
| Option | Env var | Default | Description |
|
|
39
55
|
|--------|---------|---------|-------------|
|
|
40
|
-
| `--
|
|
41
|
-
| `--instance-id` | — | auto (from config) | Override stored instance ID |
|
|
56
|
+
| `--zookeeper`, `-z` | `ZK_HOSTS` | `127.0.0.1:2181` | ZooKeeper connection string |
|
|
57
|
+
| `--instance-id`, `-i` | — | auto (from config) | Override stored instance ID |
|
|
42
58
|
|
|
43
59
|
## Commands
|
|
44
60
|
|
|
61
|
+
### Leader
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
claude-orchestrator leader --name Tom
|
|
65
|
+
# Launches read-only TUI: team panel, task board, event log
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Only one Leader at a time (ZK ephemeral node). The TUI shows who's online, what tasks are in each state, and a scrolling event log.
|
|
69
|
+
|
|
45
70
|
### Registration
|
|
46
71
|
|
|
47
|
-
**
|
|
72
|
+
**Setup** — one-time initialization:
|
|
48
73
|
|
|
49
74
|
```bash
|
|
50
|
-
claude-orchestrator
|
|
51
|
-
|
|
75
|
+
claude-orchestrator setup --leader --name Tom # Leader
|
|
76
|
+
claude-orchestrator setup --name Jerry --role builder # Worker
|
|
77
|
+
claude-orchestrator setup --name Lucy --role verifier \
|
|
78
|
+
--cache-dir ~/shared/sessions --command "claude -p" # Custom CLI
|
|
52
79
|
```
|
|
53
80
|
|
|
54
|
-
|
|
81
|
+
Setup options:
|
|
55
82
|
|
|
56
|
-
|
|
83
|
+
| Option | Default | Description |
|
|
84
|
+
|--------|---------|-------------|
|
|
85
|
+
| `--leader` | false | Initialize as Leader environment |
|
|
86
|
+
| `--name <name>` | — | Instance display name |
|
|
87
|
+
| `--role <role>` | builder | Role: planner, builder, verifier, reviewer, accepter |
|
|
88
|
+
| `--cache-dir <path>` | `~/.claude-orchestrator/sessions` | Shared cache directory |
|
|
89
|
+
| `--command <cmd>` | `claude --dangerously-skip-permissions --permission-mode dontAsk` | Claude CLI command |
|
|
90
|
+
| `--global` | false | Write only global config, skip project files |
|
|
91
|
+
|
|
92
|
+
**Register** — join the swarm:
|
|
57
93
|
|
|
58
94
|
```bash
|
|
59
|
-
claude-orchestrator
|
|
60
|
-
claude-orchestrator
|
|
95
|
+
# Connect and listen for messages (reads name/role from .claude-orchestrator/config.json):
|
|
96
|
+
claude-orchestrator register
|
|
97
|
+
# Worker Watcher starts, listens for messages, processes via claude -p
|
|
98
|
+
# Press Ctrl+C to stop and unregister
|
|
61
99
|
```
|
|
62
100
|
|
|
63
|
-
|
|
101
|
+
Registration creates an ephemeral ZK node. The instance auto-deregisters on disconnect (Ctrl+C or timeout). The Worker Watcher listens for messages on `/messages/{instance_id}` and processes them using the template that matches the message's `link` field.
|
|
64
102
|
|
|
65
|
-
**
|
|
103
|
+
**Unregister:**
|
|
66
104
|
|
|
67
105
|
```bash
|
|
68
|
-
claude-orchestrator
|
|
69
|
-
# [{"id": "...", "name": "Jerry-Dev", "role": "developer", "status": "busy", ...}, ...]
|
|
106
|
+
claude-orchestrator unregister
|
|
70
107
|
```
|
|
71
108
|
|
|
72
109
|
### Tasks
|
|
@@ -74,33 +111,66 @@ claude-orchestrator list-instances
|
|
|
74
111
|
**Push a task** to the queue:
|
|
75
112
|
|
|
76
113
|
```bash
|
|
77
|
-
claude-orchestrator push-task --title "
|
|
78
|
-
claude-orchestrator push-task --title "
|
|
114
|
+
claude-orchestrator push-task --title "Implement login endpoint" --priority 0
|
|
115
|
+
claude-orchestrator push-task --title "Verify auth module" --link verify --priority 1
|
|
116
|
+
claude-orchestrator push-task --title "Review PR #42" --link review --assignee <instance-id>
|
|
117
|
+
claude-orchestrator push-task --title "Part 2" --chain-id chain-001 --depends-on task-0000000001
|
|
79
118
|
```
|
|
80
119
|
|
|
81
|
-
|
|
120
|
+
Push options:
|
|
121
|
+
|
|
122
|
+
| Option | Default | Description |
|
|
123
|
+
|--------|---------|-------------|
|
|
124
|
+
| `--title <text>` | required | Task title |
|
|
125
|
+
| `--description <text>` | "" | Task description |
|
|
126
|
+
| `--priority <n>` | 1 | 0=HIGH, 1=MEDIUM, 2=LOW |
|
|
127
|
+
| `--assignee <id>` | — | Target instance ID |
|
|
128
|
+
| `--link <link>` | — | Responsibility chain link: plan, build, verify, review, accept |
|
|
129
|
+
| `--chain-id <id>` | — | Group related tasks under one chain |
|
|
130
|
+
| `--depends-on <ids>` | — | Comma-separated task IDs this task depends on |
|
|
131
|
+
| `--blocked-by <ids>` | — | Comma-separated task IDs blocking this task |
|
|
82
132
|
|
|
83
133
|
**Claim a task** — FIFO, higher priority first, assigned-to-you tasks jump the queue:
|
|
84
134
|
|
|
85
135
|
```bash
|
|
86
136
|
claude-orchestrator claim-task
|
|
87
|
-
# {"id": "task-0000000001", "title": "
|
|
88
|
-
# {"status": "no_tasks", "message": "No pending tasks available."}
|
|
137
|
+
# → { "id": "task-0000000001", "title": "Implement login endpoint", "status": "claimed", ... }
|
|
138
|
+
# → { "status": "no_tasks", "message": "No pending tasks available." }
|
|
89
139
|
```
|
|
90
140
|
|
|
91
141
|
**Complete a task:**
|
|
92
142
|
|
|
93
143
|
```bash
|
|
94
|
-
claude-orchestrator complete-task --task-id task-0000000001 --result "
|
|
144
|
+
claude-orchestrator complete-task --task-id task-0000000001 --result "PR #42 — login endpoint with tests"
|
|
95
145
|
```
|
|
96
146
|
|
|
97
|
-
**
|
|
147
|
+
**Poll tasks:**
|
|
98
148
|
|
|
99
149
|
```bash
|
|
100
|
-
claude-orchestrator
|
|
101
|
-
claude-orchestrator
|
|
102
|
-
claude-orchestrator
|
|
103
|
-
claude-orchestrator
|
|
150
|
+
claude-orchestrator poll-task
|
|
151
|
+
claude-orchestrator poll-task --status pending
|
|
152
|
+
claude-orchestrator poll-task --status claimed
|
|
153
|
+
claude-orchestrator poll-task --status completed
|
|
154
|
+
claude-orchestrator poll-task --status blocked
|
|
155
|
+
claude-orchestrator poll-task --status failed
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
**Task lifecycle commands:**
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
claude-orchestrator task-block --task-id task-0000000001 --reason "Waiting for API key"
|
|
162
|
+
claude-orchestrator task-fail --task-id task-0000000001 --reason "Test environment unavailable"
|
|
163
|
+
claude-orchestrator task-retry --task-id task-0000000001
|
|
164
|
+
# → Re-queued with retry_count + 1 (max 3 retries)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
Task state machine:
|
|
168
|
+
|
|
169
|
+
```
|
|
170
|
+
pending → claimed → in_progress → completed
|
|
171
|
+
→ blocked → pending (retry)
|
|
172
|
+
→ failed → pending (retry, max 3)
|
|
173
|
+
claimed → pending (Worker disconnect, Leader recovers orphan)
|
|
104
174
|
```
|
|
105
175
|
|
|
106
176
|
### Messages
|
|
@@ -108,7 +178,7 @@ claude-orchestrator list-tasks --status completed
|
|
|
108
178
|
**Send a direct message:**
|
|
109
179
|
|
|
110
180
|
```bash
|
|
111
|
-
claude-orchestrator send-message --to
|
|
181
|
+
claude-orchestrator send-message --to-name Jerry --content "Can you review my PR?"
|
|
112
182
|
```
|
|
113
183
|
|
|
114
184
|
**Broadcast to all:**
|
|
@@ -117,64 +187,58 @@ claude-orchestrator send-message --to <instance-id> --content "Can you review my
|
|
|
117
187
|
claude-orchestrator send-message --broadcast --content "CI is down, don't push"
|
|
118
188
|
```
|
|
119
189
|
|
|
120
|
-
**
|
|
190
|
+
**Request help** (broadcasts to all with help flag):
|
|
121
191
|
|
|
122
192
|
```bash
|
|
123
|
-
claude-orchestrator
|
|
124
|
-
# [{"id": "msg-...", "type": "direct", "from_name": "Lucy-Test", "content": "...", "read": true}]
|
|
193
|
+
claude-orchestrator send-message --request-help --broadcast --content "How do I test the auth flow?"
|
|
125
194
|
```
|
|
126
195
|
|
|
127
|
-
**
|
|
196
|
+
**Poll messages:**
|
|
128
197
|
|
|
129
198
|
```bash
|
|
130
|
-
claude-orchestrator
|
|
199
|
+
claude-orchestrator poll-message
|
|
200
|
+
# [{ "id": "msg-...", "type": "direct", "from_name": "Tom", "content": "...", "read": true }]
|
|
131
201
|
```
|
|
132
202
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
**Set:**
|
|
203
|
+
**Delete a message:**
|
|
136
204
|
|
|
137
205
|
```bash
|
|
138
|
-
claude-orchestrator
|
|
206
|
+
claude-orchestrator delete-message --message-id msg-0000000000
|
|
139
207
|
```
|
|
140
208
|
|
|
141
|
-
|
|
209
|
+
### Config
|
|
142
210
|
|
|
143
211
|
```bash
|
|
144
|
-
claude-orchestrator
|
|
145
|
-
#
|
|
212
|
+
claude-orchestrator config
|
|
213
|
+
# Shows global and project configuration
|
|
146
214
|
```
|
|
147
215
|
|
|
148
|
-
|
|
216
|
+
## Roles
|
|
149
217
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
218
|
+
| Role | Value | Typical behavior |
|
|
219
|
+
|------|-------|-----------------|
|
|
220
|
+
| Leader | `leader` | Runs TUI, monitors team, recovers orphaned tasks |
|
|
221
|
+
| Planner | `planner` | Uses `task-planning` + `task-traceability` skills |
|
|
222
|
+
| Builder | `builder` | Uses `task-execution` + `task-traceability` skills |
|
|
223
|
+
| Verifier | `verifier` | Uses `task-verification` + `task-traceability` skills |
|
|
224
|
+
| Reviewer | `reviewer` | Uses `task-review` + `task-traceability` skills |
|
|
225
|
+
| Accepter | `accepter` | Uses `task-acceptance` + `task-traceability` skills |
|
|
154
226
|
|
|
155
227
|
## Workflow
|
|
156
228
|
|
|
157
229
|
A typical agent session:
|
|
158
230
|
|
|
159
231
|
```bash
|
|
160
|
-
# 1.
|
|
161
|
-
claude-orchestrator
|
|
162
|
-
|
|
163
|
-
# 2. Check who's online
|
|
164
|
-
claude-orchestrator list-instances
|
|
232
|
+
# 1. Initialize (first time only)
|
|
233
|
+
claude-orchestrator setup --name Jerry --role builder
|
|
165
234
|
|
|
166
|
-
#
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
task=$(claude-orchestrator claim-task) # grab work
|
|
170
|
-
if [ "$task" = "no_tasks" ]; then break; fi
|
|
171
|
-
# ... execute the task ...
|
|
172
|
-
claude-orchestrator complete-task --task-id <id> --result "Done: ..."
|
|
173
|
-
done
|
|
235
|
+
# 2. Join the team — Worker Watcher auto-processes incoming messages via claude -p
|
|
236
|
+
claude-orchestrator register
|
|
237
|
+
# Press Ctrl+C to stop and unregister
|
|
174
238
|
```
|
|
175
239
|
|
|
176
240
|
## Error recovery
|
|
177
241
|
|
|
178
242
|
- **ZooKeeper not connected**: check `docker-compose ps`, retry. ZK client auto-reconnects.
|
|
179
|
-
- **"No instance_id found"**:
|
|
180
|
-
- **Registration expired**: ephemeral nodes cleaned up on disconnect. Re-register
|
|
243
|
+
- **"No instance_id found"**: run `setup` first, or check `.claude-orchestrator/config.json`
|
|
244
|
+
- **Registration expired**: ephemeral nodes cleaned up on disconnect. Re-register to restore identity.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
You are a task decomposition specialist. Your
|
|
1
|
+
You are {{name}}, a task decomposition specialist. Your role is {{preset_role}}. Break down the requirement below into a chain of tasks following the Plan → Build → Verify → Review → Accept responsibility chain.
|
|
2
2
|
|
|
3
3
|
## Responsibility Chain
|
|
4
4
|
|
|
@@ -8,24 +8,20 @@ You are a task decomposition specialist. Your job is to break down a requirement
|
|
|
8
8
|
4. **Review** — Quality gate. Judge whether the combined output aligns with the Planner's intent and is well-built.
|
|
9
9
|
5. **Accept** — Final acceptance. Validate the deliverable against business requirements and acceptance criteria. Make the Go/No-Go decision.
|
|
10
10
|
|
|
11
|
-
## Current Team
|
|
12
|
-
|
|
13
|
-
{{team_status}}
|
|
14
|
-
|
|
15
11
|
## Requirement
|
|
16
12
|
|
|
17
|
-
{{
|
|
13
|
+
{{task_description}}
|
|
18
14
|
|
|
19
15
|
## Instructions
|
|
20
16
|
|
|
21
17
|
1. Analyze the requirement. Identify how many independent delivery chains are needed (usually one, but complex requirements may need multiple).
|
|
22
18
|
2. For each chain, define five link tasks. Plan is optional — omit it (set to null) when the requirement is already clear enough to start building directly. Build, Verify, Review, and Accept are mandatory.
|
|
23
19
|
3. For each task, specify clear completion criteria — what "done" means for that specific link.
|
|
24
|
-
4. Assign a priority to each task: 0 (urgent
|
|
20
|
+
4. Assign a priority to each task: 0 (urgent), 1 (high), 2 (normal), 3 (low).
|
|
25
21
|
|
|
26
22
|
## Output Format
|
|
27
23
|
|
|
28
|
-
Output exactly one JSON object per chain
|
|
24
|
+
Output exactly one JSON object per chain. Write the result to {{result_path}}.
|
|
29
25
|
|
|
30
26
|
```json
|
|
31
27
|
{
|
|
@@ -67,3 +63,5 @@ Output exactly one JSON object per chain with fixed five slots:
|
|
|
67
63
|
```
|
|
68
64
|
|
|
69
65
|
If plan is not needed, set it to null. Output ONLY the JSON. No explanation.
|
|
66
|
+
|
|
67
|
+
After completing the decomposition, include the full JSON as your completion report so the Leader can mechanically create the tasks.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
You are {{name}}, a self-evaluation specialist. Your role is {{preset_role}}. You just completed a task in the Plan → Build → Verify → Review → Accept responsibility chain. Evaluate your own output and decide the next action.
|
|
2
|
+
|
|
3
|
+
## Your Task
|
|
4
|
+
|
|
5
|
+
- **Link**: {{link}}
|
|
6
|
+
- **Title**: {{task_title}}
|
|
7
|
+
- **Description**: {{task_description}}
|
|
8
|
+
- **Completion Criteria**: {{task_criteria}}
|
|
9
|
+
|
|
10
|
+
## Your Result
|
|
11
|
+
|
|
12
|
+
The result of your work is at {{task_result_path}}. Review it objectively.
|
|
13
|
+
|
|
14
|
+
## Decision Rules
|
|
15
|
+
|
|
16
|
+
1. **Evaluate your output against the completion criteria.**
|
|
17
|
+
- Criteria fully met → `activate_next` (proceed to next link in the chain)
|
|
18
|
+
- Criteria partially met → `feedback` (describe what's missing so you or another worker can fix it)
|
|
19
|
+
- Criteria not met at all → `feedback` with clear explanation of what went wrong
|
|
20
|
+
|
|
21
|
+
2. **Check chain position.**
|
|
22
|
+
- If this was the Accept link and it passes → `close_chain`
|
|
23
|
+
- Otherwise → activate the next link
|
|
24
|
+
|
|
25
|
+
## Output Format
|
|
26
|
+
|
|
27
|
+
Output exactly one JSON decision. Write the result to {{result_path}}.
|
|
28
|
+
|
|
29
|
+
```json
|
|
30
|
+
{
|
|
31
|
+
"decision": "activate_next" | "feedback" | "close_chain",
|
|
32
|
+
"reason": "<one-line explanation of the evaluation>",
|
|
33
|
+
"feedback": "<only if feedback: specific guidance on what to improve>",
|
|
34
|
+
"nextLink": "<the next link to activate, e.g. build|verify|review|accept>",
|
|
35
|
+
"suggestedWorker": null
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Output ONLY the JSON. No explanation.
|
|
40
|
+
|
|
41
|
+
After evaluating, include the full JSON decision as your completion report so the Leader can mechanically execute the decision.
|
package/dist/utils/exec.js
CHANGED
|
@@ -5,6 +5,8 @@ export async function execWithTee(command, message, logPath, cwd) {
|
|
|
5
5
|
await fs.promises.mkdir(path.dirname(logPath), { recursive: true });
|
|
6
6
|
const escapedMsg = message.replace(/'/g, "'\\''");
|
|
7
7
|
const shellCmd = `exec ${command} -p '${escapedMsg}' | tee -a '${logPath}'`;
|
|
8
|
+
const msgPreview = message.length > 100 ? message.slice(0, 100) + "..." : message;
|
|
9
|
+
console.log(`\n[Exec] ${command} -p '${msgPreview}' | tee -a '${logPath}'`);
|
|
8
10
|
return new Promise((resolve) => {
|
|
9
11
|
const child = spawn("sh", ["-c", shellCmd], {
|
|
10
12
|
cwd,
|
package/dist/utils/exec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,WAA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C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
private tag;
|
|
3
|
+
private static debugEnabled;
|
|
4
|
+
static enableDebug(): void;
|
|
5
|
+
static isDebug(): boolean;
|
|
6
|
+
constructor(tag: string);
|
|
7
|
+
info(msg: string): void;
|
|
8
|
+
error(msg: string, err?: unknown): void;
|
|
9
|
+
debug(msg: string): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export class Logger {
|
|
2
|
+
tag;
|
|
3
|
+
static debugEnabled = false;
|
|
4
|
+
static enableDebug() { Logger.debugEnabled = true; }
|
|
5
|
+
static isDebug() { return Logger.debugEnabled; }
|
|
6
|
+
constructor(tag) {
|
|
7
|
+
this.tag = tag;
|
|
8
|
+
}
|
|
9
|
+
info(msg) {
|
|
10
|
+
console.log(`[${this.tag}] ${msg}`);
|
|
11
|
+
}
|
|
12
|
+
error(msg, err) {
|
|
13
|
+
const extra = err instanceof Error ? `: ${err.message}` : err !== undefined ? `: ${err}` : "";
|
|
14
|
+
console.error(`[${this.tag}] ${msg}${extra}`);
|
|
15
|
+
}
|
|
16
|
+
debug(msg) {
|
|
17
|
+
if (Logger.debugEnabled) {
|
|
18
|
+
console.log(`[${this.tag}] [DEBUG] ${msg}`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,MAAM;IAMG;IALZ,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;IAEpC,MAAM,CAAC,WAAW,KAAW,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC;IAC1D,MAAM,CAAC,OAAO,KAAc,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzD,YAAoB,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;IAAG,CAAC;IAEnC,IAAI,CAAC,GAAW;QACd,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,EAAE,CAAC,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,GAAa;QAC9B,MAAM,KAAK,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9F,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG,GAAG,KAAK,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,GAAW;QACf,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;YACxB,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,GAAG,aAAa,GAAG,EAAE,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TemplateEngine } from "../executor/template.js";
|
|
2
|
+
import { ClaudeRunner } from "../executor/runner.js";
|
|
3
|
+
declare const CHAIN_LINKS: string[];
|
|
4
|
+
export declare class SelfEvaluator {
|
|
5
|
+
private templateEngine;
|
|
6
|
+
private runner;
|
|
7
|
+
private instanceName;
|
|
8
|
+
private instanceRole;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(templateEngine: TemplateEngine, runner: ClaudeRunner, instanceName: string, instanceRole: string);
|
|
11
|
+
evaluate(link: string, msgVars: Record<string, string>, taskResultPath: string, uniqueKey: string): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
export { CHAIN_LINKS };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import * as fs from "node:fs";
|
|
2
|
+
import { Logger } from "../utils/logger.js";
|
|
3
|
+
import { EvalDecisionSchema } from "../models/schemas.js";
|
|
4
|
+
const CHAIN_LINKS = ["plan", "build", "verify", "review", "accept"];
|
|
5
|
+
const MAX_RETRIES = 3;
|
|
6
|
+
const NEXT_LINKS = {
|
|
7
|
+
plan: "build", build: "verify", verify: "review",
|
|
8
|
+
review: "accept", accept: null,
|
|
9
|
+
};
|
|
10
|
+
export class SelfEvaluator {
|
|
11
|
+
templateEngine;
|
|
12
|
+
runner;
|
|
13
|
+
instanceName;
|
|
14
|
+
instanceRole;
|
|
15
|
+
logger = new Logger("SelfEvaluator");
|
|
16
|
+
constructor(templateEngine, runner, instanceName, instanceRole) {
|
|
17
|
+
this.templateEngine = templateEngine;
|
|
18
|
+
this.runner = runner;
|
|
19
|
+
this.instanceName = instanceName;
|
|
20
|
+
this.instanceRole = instanceRole;
|
|
21
|
+
}
|
|
22
|
+
async evaluate(link, msgVars, taskResultPath, uniqueKey) {
|
|
23
|
+
let evalTemplate;
|
|
24
|
+
try {
|
|
25
|
+
evalTemplate = await this.templateEngine.loadFile("worker-evaluate.md");
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
evalTemplate = [
|
|
29
|
+
`You are {{name}}, a Worker with role {{preset_role}}.`,
|
|
30
|
+
`Evaluate your own output for the {{link}} task and decide the next step.`,
|
|
31
|
+
``,
|
|
32
|
+
`## Task`,
|
|
33
|
+
`- **Title**: {{task_title}}`,
|
|
34
|
+
`- **Description**: {{task_description}}`,
|
|
35
|
+
`- **Criteria**: {{task_criteria}}`,
|
|
36
|
+
``,
|
|
37
|
+
`## Your Result`,
|
|
38
|
+
`Read the result from {{task_result_path}}.`,
|
|
39
|
+
``,
|
|
40
|
+
`## Output Format`,
|
|
41
|
+
`Write the evaluation result to {{result_path}}. Output exactly one JSON decision:`,
|
|
42
|
+
`\`\`\`json`,
|
|
43
|
+
`{"decision": "activate_next" | "feedback" | "close_chain", "reason": "...", "nextLink": "build|verify|review|accept"}`,
|
|
44
|
+
`\`\`\``,
|
|
45
|
+
`Output ONLY the JSON.`,
|
|
46
|
+
].join("\n");
|
|
47
|
+
}
|
|
48
|
+
const baseVars = {
|
|
49
|
+
name: this.instanceName,
|
|
50
|
+
preset_role: this.instanceRole,
|
|
51
|
+
link,
|
|
52
|
+
task_result_path: taskResultPath,
|
|
53
|
+
work_dir: "",
|
|
54
|
+
time: new Date().toISOString(),
|
|
55
|
+
...msgVars,
|
|
56
|
+
};
|
|
57
|
+
const formatHint = [
|
|
58
|
+
``,
|
|
59
|
+
`## IMPORTANT: Format Correction`,
|
|
60
|
+
`Your previous output was invalid JSON or did not match the required schema.`,
|
|
61
|
+
`You MUST output ONLY valid JSON with exactly these fields:`,
|
|
62
|
+
`\`\`\`json`,
|
|
63
|
+
`{"decision": "activate_next"|"feedback"|"close_chain", "reason": "<string>", "nextLink": "<string>", "feedback": "<string>"}`,
|
|
64
|
+
`\`\`\``,
|
|
65
|
+
`No markdown fences, no extra text, no trailing commas. Pure JSON only.`,
|
|
66
|
+
].join("\n");
|
|
67
|
+
for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
|
|
68
|
+
const attemptKey = `${uniqueKey}-${attempt}`;
|
|
69
|
+
const evalResultPath = this.runner.evalResultPath(attemptKey);
|
|
70
|
+
const evalLogPath = this.runner.evalLogPath(attemptKey);
|
|
71
|
+
let prompt = this.templateEngine.render(evalTemplate, {
|
|
72
|
+
...baseVars,
|
|
73
|
+
result_path: evalResultPath,
|
|
74
|
+
});
|
|
75
|
+
if (attempt > 0) {
|
|
76
|
+
prompt += formatHint;
|
|
77
|
+
}
|
|
78
|
+
this.logger.info(`Self-evaluation attempt ${attempt + 1}/${MAX_RETRIES}...`);
|
|
79
|
+
await this.runner.run(prompt, evalLogPath);
|
|
80
|
+
try {
|
|
81
|
+
const content = await fs.promises.readFile(evalResultPath, "utf-8");
|
|
82
|
+
if (!content.trim())
|
|
83
|
+
continue;
|
|
84
|
+
const cleaned = content.trim()
|
|
85
|
+
.replace(/```json\s*/g, "")
|
|
86
|
+
.replace(/```\s*/g, "")
|
|
87
|
+
.trim();
|
|
88
|
+
const parsed = JSON.parse(cleaned);
|
|
89
|
+
const validated = EvalDecisionSchema.parse(parsed);
|
|
90
|
+
return JSON.stringify(validated);
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
this.logger.error(`Attempt ${attempt + 1} invalid`, err);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
this.logger.error(`All ${MAX_RETRIES} evaluation attempts failed, using fallback`);
|
|
97
|
+
const nextLink = NEXT_LINKS[link];
|
|
98
|
+
if (nextLink) {
|
|
99
|
+
return JSON.stringify({
|
|
100
|
+
decision: "activate_next",
|
|
101
|
+
reason: `Auto-advance from ${link} (after ${MAX_RETRIES} eval failures)`,
|
|
102
|
+
nextLink,
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return JSON.stringify({
|
|
106
|
+
decision: "close_chain",
|
|
107
|
+
reason: `Accept link completed (after ${MAX_RETRIES} eval failures)`,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export { CHAIN_LINKS };
|
|
112
|
+
//# sourceMappingURL=evaluator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/worker/evaluator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AACpE,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,UAAU,GAAkC;IAChD,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ;IAChD,MAAM,EAAE,QAAQ,E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AC,KAAK,CAAC,MAAM,CAAC,CAAC;gBACnD,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;YACnC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,OAAO,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,WAAW,6CAA6C,CAAC,CAAC;QAEnF,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,QAAQ,EAAE,CAAC;YACb,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,QAAQ,EAAE,eAAe;gBACzB,MAAM,EAAE,qBAAqB,IAAI,WAAW,WAAW,iBAAiB;gBACxE,QAAQ;aACT,CAAC,CAAC;QACL,CAAC;QACD,OAAO,IAAI,CAAC,SAAS,CAAC;YACpB,QAAQ,EAAE,aAAa;YACvB,MAAM,EAAE,gCAAgC,WAAW,iBAAiB;SACrE,CAAC,CAAC;IACL,CAAC;CACF;AAED,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/worker/watcher.d.ts
CHANGED
|
@@ -1,19 +1,25 @@
|
|
|
1
1
|
import { ZkClient } from "../zk/client.js";
|
|
2
|
+
import { HookEngine } from "../hooks/engine.js";
|
|
3
|
+
import { TemplateEngine } from "../executor/template.js";
|
|
4
|
+
import { ClaudeRunner } from "../executor/runner.js";
|
|
5
|
+
import { SelfEvaluator } from "./evaluator.js";
|
|
2
6
|
export declare class WorkerWatcher {
|
|
3
7
|
private zk;
|
|
4
8
|
private instanceId;
|
|
5
|
-
private workDir;
|
|
6
|
-
private command;
|
|
7
|
-
private cacheDir;
|
|
8
9
|
private leaderInstanceId;
|
|
10
|
+
private hooks;
|
|
11
|
+
private templateEngine;
|
|
12
|
+
private runner;
|
|
13
|
+
private evaluator;
|
|
9
14
|
private inFlight;
|
|
10
|
-
private templates;
|
|
11
15
|
private instanceName;
|
|
12
16
|
private instanceRole;
|
|
17
|
+
private logger;
|
|
13
18
|
stopped: boolean;
|
|
14
|
-
constructor(zk: ZkClient, instanceId: string,
|
|
19
|
+
constructor(zk: ZkClient, instanceId: string, leaderInstanceId: string, hooks: HookEngine, templateEngine: TemplateEngine, runner: ClaudeRunner, evaluator: SelfEvaluator);
|
|
15
20
|
start(): Promise<void>;
|
|
16
21
|
private watchLoop;
|
|
17
22
|
private processMessage;
|
|
23
|
+
private sendCompletionReport;
|
|
18
24
|
stop(): void;
|
|
19
25
|
}
|