@adamancyzhang/claude-orchestrator 0.3.1 → 0.3.3
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 +76 -77
- 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.md +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
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { expandHomeDir } from "../config.js";
|
|
4
|
-
import { execAndCapture } from "../utils/exec.js";
|
|
5
|
-
const NEXT_LINKS = {
|
|
6
|
-
plan: "build",
|
|
7
|
-
build: "verify",
|
|
8
|
-
verify: "review",
|
|
9
|
-
review: "accept",
|
|
10
|
-
accept: null,
|
|
11
|
-
};
|
|
12
|
-
export class DecisionEngine {
|
|
13
|
-
zk;
|
|
14
|
-
taskQueue;
|
|
15
|
-
messageRouter;
|
|
16
|
-
command;
|
|
17
|
-
cacheDir;
|
|
18
|
-
leaderInstanceId;
|
|
19
|
-
template = null;
|
|
20
|
-
templatePath;
|
|
21
|
-
constructor(zk, taskQueue, messageRouter, command, cacheDir, leaderInstanceId, templatePath) {
|
|
22
|
-
this.zk = zk;
|
|
23
|
-
this.taskQueue = taskQueue;
|
|
24
|
-
this.messageRouter = messageRouter;
|
|
25
|
-
this.command = command;
|
|
26
|
-
this.cacheDir = cacheDir;
|
|
27
|
-
this.leaderInstanceId = leaderInstanceId;
|
|
28
|
-
this.templatePath = templatePath ?? path.join(process.cwd(), ".claude-orchestrator", "agents", "leader-decide.md");
|
|
29
|
-
}
|
|
30
|
-
async loadTemplate() {
|
|
31
|
-
if (this.template)
|
|
32
|
-
return this.template;
|
|
33
|
-
try {
|
|
34
|
-
this.template = await fs.promises.readFile(this.templatePath, "utf-8");
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
throw new Error(`Decide template not found at ${this.templatePath}. Run setup first.`);
|
|
38
|
-
}
|
|
39
|
-
return this.template;
|
|
40
|
-
}
|
|
41
|
-
async evaluate(report, context) {
|
|
42
|
-
const template = await this.loadTemplate();
|
|
43
|
-
const prompt = template
|
|
44
|
-
.replace("{{team_status}}", JSON.stringify(context.teamStatus, null, 2))
|
|
45
|
-
.replace("{{task_queues}}", JSON.stringify(context.taskQueues, null, 2))
|
|
46
|
-
.replace("{{chain_status}}", JSON.stringify(context.chainStatus, null, 2))
|
|
47
|
-
.replace("{{content}}", report.content);
|
|
48
|
-
const uniqueKey = `decide-${Date.now().toString(36)}`;
|
|
49
|
-
const resolvedCacheDir = expandHomeDir(path.join(this.cacheDir, this.leaderInstanceId));
|
|
50
|
-
const logPath = path.join(resolvedCacheDir, `${uniqueKey}.log`);
|
|
51
|
-
const { stdout } = await execAndCapture(this.command, prompt, logPath);
|
|
52
|
-
const decision = this.parseOutput(stdout);
|
|
53
|
-
await this.executeDecision(decision, report);
|
|
54
|
-
return decision;
|
|
55
|
-
}
|
|
56
|
-
async executeDecision(decision, report) {
|
|
57
|
-
const nextLink = decision.nextAction.nextLink;
|
|
58
|
-
const linkOrder = ["plan", "build", "verify", "review", "accept"];
|
|
59
|
-
switch (decision.nextAction.action) {
|
|
60
|
-
case "activate_next_link": {
|
|
61
|
-
if (!nextLink)
|
|
62
|
-
break;
|
|
63
|
-
const pending = await this.zk.listPendingTasks();
|
|
64
|
-
for (const [taskId, data] of pending) {
|
|
65
|
-
if (data.link === nextLink && data.chain_id === report.chain_id) {
|
|
66
|
-
// Task already exists in pending, no need to create
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
case "close_chain":
|
|
73
|
-
break;
|
|
74
|
-
case "reassign":
|
|
75
|
-
case "broadcast_help":
|
|
76
|
-
case "none":
|
|
77
|
-
break;
|
|
78
|
-
}
|
|
79
|
-
if (decision.decision === "feedback" && decision.feedbackToWorker && report.from_instance) {
|
|
80
|
-
await this.messageRouter.send(this.leaderInstanceId, "Leader", decision.feedbackToWorker, report.from_instance);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
parseOutput(output) {
|
|
84
|
-
const cleaned = output
|
|
85
|
-
.replace(/```json\s*/g, "")
|
|
86
|
-
.replace(/```\s*/g, "")
|
|
87
|
-
.trim();
|
|
88
|
-
const parsed = JSON.parse(cleaned);
|
|
89
|
-
return {
|
|
90
|
-
decision: parsed.decision ?? "pass",
|
|
91
|
-
reason: parsed.reason ?? "",
|
|
92
|
-
feedbackToWorker: parsed.feedback_to_worker,
|
|
93
|
-
nextAction: {
|
|
94
|
-
action: parsed.next_action?.action ?? "none",
|
|
95
|
-
nextLink: parsed.next_action?.next_link ?? null,
|
|
96
|
-
suggestedWorker: parsed.next_action?.suggested_worker ?? null,
|
|
97
|
-
messageToWorker: parsed.next_action?.message_to_worker ?? null,
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
//# sourceMappingURL=decision-engine.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decision-engine.js","sourceRoot":"","sources":["../../src/leader/decision-engine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAKlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,UAAU,GAAkC;IAChD,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,QAAQ;IACf,MAAM,EAAE,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gBAC5C,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,SAAS,IAAI,IAAI;gBAC/C,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,gBAAgB,IAAI,IAAI;gBAC7D,eAAe,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,IAAI,IAAI;aAC/D;SACF,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { ZkClient } from "../zk/client.js";
|
|
2
|
-
import { TaskQueue } from "../modules/task-queue.js";
|
|
3
|
-
interface ChainTaskDef {
|
|
4
|
-
title: string;
|
|
5
|
-
description: string;
|
|
6
|
-
criteria: string;
|
|
7
|
-
priority: number;
|
|
8
|
-
}
|
|
9
|
-
interface ChainDef {
|
|
10
|
-
chain_id: string;
|
|
11
|
-
chain_title: string;
|
|
12
|
-
tasks: {
|
|
13
|
-
plan: ChainTaskDef | null;
|
|
14
|
-
build: ChainTaskDef;
|
|
15
|
-
verify: ChainTaskDef;
|
|
16
|
-
review: ChainTaskDef;
|
|
17
|
-
accept: ChainTaskDef;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
export declare class TaskGenerator {
|
|
21
|
-
private zk;
|
|
22
|
-
private taskQueue;
|
|
23
|
-
private command;
|
|
24
|
-
private cacheDir;
|
|
25
|
-
private leaderInstanceId;
|
|
26
|
-
private template;
|
|
27
|
-
private templatePath;
|
|
28
|
-
constructor(zk: ZkClient, taskQueue: TaskQueue, command: string, cacheDir: string, leaderInstanceId: string, templatePath?: string);
|
|
29
|
-
private loadTemplate;
|
|
30
|
-
decompose(requirement: string, teamStatus: object): Promise<ChainDef[]>;
|
|
31
|
-
private pushChain;
|
|
32
|
-
private parseOutput;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { expandHomeDir } from "../config.js";
|
|
4
|
-
import { execAndCapture } from "../utils/exec.js";
|
|
5
|
-
export class TaskGenerator {
|
|
6
|
-
zk;
|
|
7
|
-
taskQueue;
|
|
8
|
-
command;
|
|
9
|
-
cacheDir;
|
|
10
|
-
leaderInstanceId;
|
|
11
|
-
template = null;
|
|
12
|
-
templatePath;
|
|
13
|
-
constructor(zk, taskQueue, command, cacheDir, leaderInstanceId, templatePath) {
|
|
14
|
-
this.zk = zk;
|
|
15
|
-
this.taskQueue = taskQueue;
|
|
16
|
-
this.command = command;
|
|
17
|
-
this.cacheDir = cacheDir;
|
|
18
|
-
this.leaderInstanceId = leaderInstanceId;
|
|
19
|
-
this.templatePath = templatePath ?? path.join(process.cwd(), ".claude-orchestrator", "agents", "leader-decompose.md");
|
|
20
|
-
}
|
|
21
|
-
async loadTemplate() {
|
|
22
|
-
if (this.template)
|
|
23
|
-
return this.template;
|
|
24
|
-
try {
|
|
25
|
-
this.template = await fs.promises.readFile(this.templatePath, "utf-8");
|
|
26
|
-
}
|
|
27
|
-
catch {
|
|
28
|
-
throw new Error(`Decompose template not found at ${this.templatePath}. Run setup first.`);
|
|
29
|
-
}
|
|
30
|
-
return this.template;
|
|
31
|
-
}
|
|
32
|
-
async decompose(requirement, teamStatus) {
|
|
33
|
-
const template = await this.loadTemplate();
|
|
34
|
-
const prompt = template
|
|
35
|
-
.replace("{{team_status}}", JSON.stringify(teamStatus, null, 2))
|
|
36
|
-
.replace("{{content}}", requirement);
|
|
37
|
-
const uniqueKey = `decompose-${Date.now().toString(36)}`;
|
|
38
|
-
const resolvedCacheDir = expandHomeDir(path.join(this.cacheDir, this.leaderInstanceId));
|
|
39
|
-
const logPath = path.join(resolvedCacheDir, `${uniqueKey}.log`);
|
|
40
|
-
const { stdout } = await execAndCapture(this.command, prompt, logPath);
|
|
41
|
-
const chains = this.parseOutput(stdout);
|
|
42
|
-
for (const chain of chains) {
|
|
43
|
-
await this.pushChain(chain, resolvedCacheDir);
|
|
44
|
-
}
|
|
45
|
-
return chains;
|
|
46
|
-
}
|
|
47
|
-
async pushChain(chain, resolvedCacheDir) {
|
|
48
|
-
const taskLinks = [];
|
|
49
|
-
if (chain.tasks.plan)
|
|
50
|
-
taskLinks.push({ link: "plan", def: chain.tasks.plan });
|
|
51
|
-
taskLinks.push({ link: "build", def: chain.tasks.build });
|
|
52
|
-
taskLinks.push({ link: "verify", def: chain.tasks.verify });
|
|
53
|
-
taskLinks.push({ link: "review", def: chain.tasks.review });
|
|
54
|
-
taskLinks.push({ link: "accept", def: chain.tasks.accept });
|
|
55
|
-
for (const { link, def } of taskLinks) {
|
|
56
|
-
const task = await this.taskQueue.push(def.title, def.description, def.priority, "", undefined, undefined, null, link, chain.chain_id);
|
|
57
|
-
const docPath = path.join(resolvedCacheDir, "tasks", `${task.id}.md`);
|
|
58
|
-
await fs.promises.mkdir(path.dirname(docPath), { recursive: true });
|
|
59
|
-
await fs.promises.writeFile(docPath, `# ${def.title}\n\n` +
|
|
60
|
-
`**Link**: ${link}\n` +
|
|
61
|
-
`**Chain**: ${chain.chain_id}\n` +
|
|
62
|
-
`**Priority**: ${def.priority}\n\n` +
|
|
63
|
-
`## Description\n\n${def.description}\n\n` +
|
|
64
|
-
`## Completion Criteria\n\n${def.criteria}\n`);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
parseOutput(output) {
|
|
68
|
-
let cleaned = output
|
|
69
|
-
.replace(/```json\s*/g, "")
|
|
70
|
-
.replace(/```\s*/g, "")
|
|
71
|
-
.trim();
|
|
72
|
-
try {
|
|
73
|
-
const parsed = JSON.parse(cleaned);
|
|
74
|
-
return Array.isArray(parsed) ? parsed : [parsed];
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
const results = [];
|
|
78
|
-
const matches = cleaned.match(/\{[\s\S]*?\}(?=\s*\{|\s*$)/g);
|
|
79
|
-
if (matches) {
|
|
80
|
-
for (const m of matches) {
|
|
81
|
-
try {
|
|
82
|
-
results.push(JSON.parse(m));
|
|
83
|
-
}
|
|
84
|
-
catch { /* skip */ }
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (results.length === 0)
|
|
88
|
-
throw new Error("Failed to parse Claude output as task chain JSON");
|
|
89
|
-
return results;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//# sourceMappingURL=task-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"task-generator.js","sourceRoot":"","sources":["../../src/leader/task-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAqBlD,MAAM,OAAO,aAAa;IAKd;IACA;IACA;IACA;IACA;IARF,QAAQ,GAAkB,IAAI,CAAC;IAC/B,YAAY,CAAS;IAE7B,YACU,EAAY,EACZ,SAAoB,EACpB,OAAe,EACf,QAAgB,EAChB,gBAAwB,EAChC,YAAqB;QALb,OAAE,GAAF,EAAE,CAAU;QACZ,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAQ;QACf,aAAQ,GAAR,QAAQ,CAAQ;QAChB,qBAAgB,GAAhB,gBAAgB,CAAQ;QAGhC,IAAI,CAAC,YAAY,GAAG,YAAY,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,sBAAsB,EAAE,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IACxH,CAAC;IAEO,KAAK,CAAC,YAAY;QACxB,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC;QACxC,IAAI,CAAC;YACH,IAAI,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;QACzE,CAAC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AG,CAAC,KAAK,MAAM;gBACpB,aAAa,IAAI,IAAI;gBACrB,cAAc,KAAK,CAAC,QAAQ,IAAI;gBAChC,iBAAiB,GAAG,CAAC,QAAQ,MAAM;gBACnC,qBAAqB,GAAG,CAAC,WAAW,MAAM;gBAC1C,6BAA6B,GAAG,CAAC,QAAQ,IAAI,CAC9C,CAAC;QACJ,CAAC;IACH,CAAC;IAEO,WAAW,CAAC,MAAc;QAChC,IAAI,OAAO,GAAG,MAAM;aACjB,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC;aAC1B,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;aACtB,IAAI,EAAE,CAAC;QAEV,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,MAAM,OAAO,GAAe,EAAE,CAAC;YAC/B,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAC;YAC7D,IAAI,OAAO,EAAE,CAAC;gBACZ,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;oBACxB,IAAI,CAAC;wBAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;oBAAC,CAAC;oBAAC,MAAM,CAAC,CAAC,UAAU,CAAC,CAAC;gBAC3D,CAAC;YACH,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;YAC9F,OAAO,OAAO,CAAC;QACjB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
You are the decision engine for a task coordination system. Your job is to evaluate a worker's completion report and decide the next action. You do NOT decompose new requirements — that is handled separately.
|
|
2
|
-
|
|
3
|
-
## Responsibility Chain (for context)
|
|
4
|
-
|
|
5
|
-
Plan → Build → Verify → Review → Accept. A task is only CLOSED after all five links sign off. Each link has completion criteria set when the task was created.
|
|
6
|
-
|
|
7
|
-
## Current State
|
|
8
|
-
|
|
9
|
-
### Team
|
|
10
|
-
{{team_status}}
|
|
11
|
-
|
|
12
|
-
### Task Queues
|
|
13
|
-
{{task_queues}}
|
|
14
|
-
|
|
15
|
-
### Current Chain
|
|
16
|
-
{{chain_status}}
|
|
17
|
-
|
|
18
|
-
## Worker Report
|
|
19
|
-
|
|
20
|
-
{{content}}
|
|
21
|
-
|
|
22
|
-
## Decision Rules
|
|
23
|
-
|
|
24
|
-
1. **Evaluate the report against the task's completion criteria.**
|
|
25
|
-
- Criteria met → the link PASSES
|
|
26
|
-
- Criteria partially met → FEEDBACK (tell worker what's missing)
|
|
27
|
-
- Criteria not met → REJECT (explain why, return for rework)
|
|
28
|
-
|
|
29
|
-
2. **Check chain position.**
|
|
30
|
-
- If this was Accept and it passes → the chain is CLOSED
|
|
31
|
-
- Otherwise → the next link's tasks become unblocked
|
|
32
|
-
|
|
33
|
-
3. **Consider team load when assigning the next task.**
|
|
34
|
-
- Prefer workers whose preset role matches the next link
|
|
35
|
-
- If all role-matched workers are busy, any idle worker can take it
|
|
36
|
-
- If a different link is a bottleneck, suggest cross-role assistance
|
|
37
|
-
|
|
38
|
-
4. **Priority override.**
|
|
39
|
-
- If there is an urgency=0 task in the queue, suggest handling it first
|
|
40
|
-
|
|
41
|
-
## Output Format
|
|
42
|
-
|
|
43
|
-
Output exactly one JSON decision:
|
|
44
|
-
|
|
45
|
-
```json
|
|
46
|
-
{
|
|
47
|
-
"decision": "pass" | "feedback" | "reject",
|
|
48
|
-
"reason": "<one-line explanation>",
|
|
49
|
-
"feedback_to_worker": "<only if feedback or reject: specific guidance>",
|
|
50
|
-
"next_action": {
|
|
51
|
-
"action": "activate_next_link" | "reassign" | "close_chain" | "broadcast_help" | "none",
|
|
52
|
-
"next_link": "build" | "verify" | "review" | "accept" | null,
|
|
53
|
-
"suggested_worker": "<worker name or null>",
|
|
54
|
-
"message_to_worker": "<task assignment message if activating next link>"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Output ONLY the JSON. No explanation.
|