cool-workflow 0.1.78

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 (193) hide show
  1. package/.claude-plugin/plugin.json +20 -0
  2. package/.codex-plugin/mcp.json +10 -0
  3. package/.codex-plugin/plugin.json +38 -0
  4. package/.mcp.json +10 -0
  5. package/LICENSE +24 -0
  6. package/README.md +638 -0
  7. package/apps/architecture-review/app.json +51 -0
  8. package/apps/architecture-review/workflow.js +116 -0
  9. package/apps/end-to-end-golden-path/app.json +30 -0
  10. package/apps/end-to-end-golden-path/workflow.js +33 -0
  11. package/apps/pr-review-fix-ci/app.json +59 -0
  12. package/apps/pr-review-fix-ci/workflow.js +90 -0
  13. package/apps/release-cut/app.json +54 -0
  14. package/apps/release-cut/workflow.js +82 -0
  15. package/apps/research-synthesis/app.json +50 -0
  16. package/apps/research-synthesis/workflow.js +76 -0
  17. package/apps/workflow-app-framework-demo/app.json +29 -0
  18. package/apps/workflow-app-framework-demo/workflow.js +44 -0
  19. package/dist/agent-config.js +223 -0
  20. package/dist/candidate-scoring.js +715 -0
  21. package/dist/capability-core.js +630 -0
  22. package/dist/capability-dispatcher.js +86 -0
  23. package/dist/capability-registry.js +523 -0
  24. package/dist/cli.js +1276 -0
  25. package/dist/collaboration.js +727 -0
  26. package/dist/commit.js +570 -0
  27. package/dist/contract-migration.js +234 -0
  28. package/dist/coordinator.js +1163 -0
  29. package/dist/daemon.js +44 -0
  30. package/dist/dispatch.js +201 -0
  31. package/dist/drive.js +503 -0
  32. package/dist/error-feedback.js +415 -0
  33. package/dist/evidence-grounding.js +179 -0
  34. package/dist/evidence-reasoning.js +733 -0
  35. package/dist/execution-backend.js +1279 -0
  36. package/dist/harness.js +61 -0
  37. package/dist/mcp-server.js +1615 -0
  38. package/dist/multi-agent-eval.js +857 -0
  39. package/dist/multi-agent-host.js +764 -0
  40. package/dist/multi-agent-operator-ux.js +537 -0
  41. package/dist/multi-agent-trust.js +366 -0
  42. package/dist/multi-agent.js +1173 -0
  43. package/dist/node-snapshot.js +270 -0
  44. package/dist/observability.js +922 -0
  45. package/dist/operator-ux.js +971 -0
  46. package/dist/orchestrator/audit-operations.js +182 -0
  47. package/dist/orchestrator/candidate-operations.js +117 -0
  48. package/dist/orchestrator/cli-options.js +288 -0
  49. package/dist/orchestrator/collaboration-operations.js +86 -0
  50. package/dist/orchestrator/feedback-operations.js +81 -0
  51. package/dist/orchestrator/host-operations.js +78 -0
  52. package/dist/orchestrator/lifecycle-operations.js +462 -0
  53. package/dist/orchestrator/migration-operations.js +44 -0
  54. package/dist/orchestrator/multi-agent-operations.js +362 -0
  55. package/dist/orchestrator/report.js +369 -0
  56. package/dist/orchestrator/topology-operations.js +84 -0
  57. package/dist/orchestrator.js +874 -0
  58. package/dist/pipeline-contract.js +92 -0
  59. package/dist/pipeline-runner.js +285 -0
  60. package/dist/reclamation.js +882 -0
  61. package/dist/result-normalize.js +194 -0
  62. package/dist/run-export.js +64 -0
  63. package/dist/run-registry.js +1347 -0
  64. package/dist/run-state-schema.js +67 -0
  65. package/dist/sandbox-profile.js +471 -0
  66. package/dist/scheduler.js +266 -0
  67. package/dist/scheduling.js +184 -0
  68. package/dist/schema-validate.js +98 -0
  69. package/dist/state-explosion.js +1213 -0
  70. package/dist/state-migrations.js +463 -0
  71. package/dist/state-node.js +301 -0
  72. package/dist/state.js +308 -0
  73. package/dist/telemetry-attestation.js +156 -0
  74. package/dist/telemetry-ledger.js +145 -0
  75. package/dist/topology.js +527 -0
  76. package/dist/triggers.js +159 -0
  77. package/dist/trust-audit.js +475 -0
  78. package/dist/types/blackboard.js +2 -0
  79. package/dist/types/boundary.js +29 -0
  80. package/dist/types/candidate.js +2 -0
  81. package/dist/types/collaboration.js +2 -0
  82. package/dist/types/core.js +2 -0
  83. package/dist/types/drive.js +10 -0
  84. package/dist/types/error-feedback.js +2 -0
  85. package/dist/types/evidence-reasoning.js +2 -0
  86. package/dist/types/execution-backend.js +2 -0
  87. package/dist/types/multi-agent.js +2 -0
  88. package/dist/types/observability.js +2 -0
  89. package/dist/types/pipeline.js +2 -0
  90. package/dist/types/reclamation.js +8 -0
  91. package/dist/types/result.js +2 -0
  92. package/dist/types/run-registry.js +2 -0
  93. package/dist/types/run.js +2 -0
  94. package/dist/types/sandbox.js +2 -0
  95. package/dist/types/schedule.js +2 -0
  96. package/dist/types/state-node.js +2 -0
  97. package/dist/types/topology.js +2 -0
  98. package/dist/types/trust.js +2 -0
  99. package/dist/types/workbench.js +2 -0
  100. package/dist/types/worker.js +2 -0
  101. package/dist/types/workflow-app.js +2 -0
  102. package/dist/types.js +43 -0
  103. package/dist/verifier-registry.js +46 -0
  104. package/dist/verifier.js +78 -0
  105. package/dist/version.js +8 -0
  106. package/dist/workbench-host.js +172 -0
  107. package/dist/workbench.js +190 -0
  108. package/dist/worker-isolation.js +1028 -0
  109. package/dist/workflow-api.js +98 -0
  110. package/dist/workflow-app-framework.js +626 -0
  111. package/docs/agent-delegation-drive.7.md +190 -0
  112. package/docs/agent-framework.md +176 -0
  113. package/docs/candidate-scoring.7.md +106 -0
  114. package/docs/canonical-workflow-apps.7.md +137 -0
  115. package/docs/capability-topology-registry.7.md +168 -0
  116. package/docs/cli-mcp-parity.7.md +373 -0
  117. package/docs/contract-migration-tooling.7.md +123 -0
  118. package/docs/control-plane-scheduling.7.md +110 -0
  119. package/docs/coordinator-blackboard.7.md +183 -0
  120. package/docs/dogfood/architecture-review-cool-workflow.md +16 -0
  121. package/docs/dogfood-one-real-repo.7.md +168 -0
  122. package/docs/durable-state-and-locking.7.md +107 -0
  123. package/docs/end-to-end-golden-path.7.md +117 -0
  124. package/docs/error-feedback.7.md +153 -0
  125. package/docs/evidence-adoption-reasoning-chain.7.md +270 -0
  126. package/docs/execution-backends.7.md +300 -0
  127. package/docs/getting-started.md +99 -0
  128. package/docs/index.md +41 -0
  129. package/docs/mcp-app-surface.7.md +235 -0
  130. package/docs/multi-agent-cli-mcp-surface.7.md +265 -0
  131. package/docs/multi-agent-eval-replay-harness.7.md +302 -0
  132. package/docs/multi-agent-operator-ux.7.md +314 -0
  133. package/docs/multi-agent-runtime-core.7.md +231 -0
  134. package/docs/multi-agent-topologies.7.md +103 -0
  135. package/docs/multi-agent-trust-policy-audit.7.md +154 -0
  136. package/docs/node-snapshot-diff-replay.7.md +135 -0
  137. package/docs/observability-cost-accounting.7.md +194 -0
  138. package/docs/operator-ux.7.md +180 -0
  139. package/docs/pipeline-runner.7.md +136 -0
  140. package/docs/project-index.md +261 -0
  141. package/docs/real-execution-backends.7.md +142 -0
  142. package/docs/release-and-migration.7.md +280 -0
  143. package/docs/release-tooling.7.md +159 -0
  144. package/docs/routines.md +48 -0
  145. package/docs/run-registry-control-plane.7.md +312 -0
  146. package/docs/run-retention-reclamation.7.md +191 -0
  147. package/docs/sandbox-profiles.7.md +137 -0
  148. package/docs/scheduled-tasks.md +80 -0
  149. package/docs/security-trust-hardening.7.md +117 -0
  150. package/docs/state-explosion-management.7.md +264 -0
  151. package/docs/state-node.7.md +96 -0
  152. package/docs/team-collaboration.7.md +207 -0
  153. package/docs/unix-principles.md +192 -0
  154. package/docs/verifier-gated-commit.7.md +140 -0
  155. package/docs/web-desktop-workbench.7.md +215 -0
  156. package/docs/worker-isolation.7.md +167 -0
  157. package/docs/workflow-app-framework.7.md +274 -0
  158. package/manifest/README.md +43 -0
  159. package/manifest/plugin.manifest.json +316 -0
  160. package/manifest/pricing.policy.json +14 -0
  161. package/package.json +79 -0
  162. package/scripts/agents/claude-p-agent.js +104 -0
  163. package/scripts/agents/claude-p-agent.sh +9 -0
  164. package/scripts/agents/cw-attest-keygen.js +55 -0
  165. package/scripts/agents/cw-attest-wrap.js +143 -0
  166. package/scripts/block-unapproved-tag.sh +39 -0
  167. package/scripts/bump-version.js +249 -0
  168. package/scripts/canonical-apps.js +171 -0
  169. package/scripts/cw.js +4 -0
  170. package/scripts/dist-drift-check.js +79 -0
  171. package/scripts/dogfood-architecture-review.js +237 -0
  172. package/scripts/dogfood-release.js +624 -0
  173. package/scripts/forward-ref-docs.js +73 -0
  174. package/scripts/gen-manifests.js +232 -0
  175. package/scripts/golden-path.js +300 -0
  176. package/scripts/mcp-server.js +4 -0
  177. package/scripts/new-feature.js +121 -0
  178. package/scripts/parity-check.js +213 -0
  179. package/scripts/release-check.js +118 -0
  180. package/scripts/release-flow.js +272 -0
  181. package/scripts/release-gate.sh +85 -0
  182. package/scripts/sync-project-index.js +387 -0
  183. package/scripts/validate-run-state-schema.js +126 -0
  184. package/scripts/verify-container-selfref.js +64 -0
  185. package/scripts/version-sync-check.js +237 -0
  186. package/skills/cool-workflow/SKILL.md +162 -0
  187. package/skills/cool-workflow/references/commands.md +282 -0
  188. package/tsconfig.json +16 -0
  189. package/ui/workbench/app.css +76 -0
  190. package/ui/workbench/app.js +159 -0
  191. package/ui/workbench/index.html +32 -0
  192. package/workflows/architecture-review.workflow.js +84 -0
  193. package/workflows/research-synthesis.workflow.js +47 -0
@@ -0,0 +1,971 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.summarizeOperatorRun = summarizeOperatorRun;
7
+ exports.adviseNoRun = adviseNoRun;
8
+ exports.summarizeOperatorWorkers = summarizeOperatorWorkers;
9
+ exports.summarizeOperatorCandidates = summarizeOperatorCandidates;
10
+ exports.summarizeOperatorFeedback = summarizeOperatorFeedback;
11
+ exports.summarizeOperatorCommits = summarizeOperatorCommits;
12
+ exports.buildOperatorGraph = buildOperatorGraph;
13
+ exports.formatOperatorStatus = formatOperatorStatus;
14
+ exports.formatOperatorReport = formatOperatorReport;
15
+ exports.formatOperatorGraph = formatOperatorGraph;
16
+ exports.formatWorkerSummary = formatWorkerSummary;
17
+ exports.formatCandidateSummary = formatCandidateSummary;
18
+ exports.formatFeedbackSummary = formatFeedbackSummary;
19
+ exports.formatCommitSummary = formatCommitSummary;
20
+ exports.formatMultiAgentSummary = formatMultiAgentSummary;
21
+ exports.formatTopologySummary = formatTopologySummary;
22
+ exports.formatMultiAgentTrustAudit = formatMultiAgentTrustAudit;
23
+ const node_fs_1 = __importDefault(require("node:fs"));
24
+ const node_path_1 = __importDefault(require("node:path"));
25
+ const trust_audit_1 = require("./trust-audit");
26
+ const multi_agent_trust_1 = require("./multi-agent-trust");
27
+ const multi_agent_1 = require("./multi-agent");
28
+ const coordinator_1 = require("./coordinator");
29
+ const topology_1 = require("./topology");
30
+ const multi_agent_operator_ux_1 = require("./multi-agent-operator-ux");
31
+ function summarizeOperatorRun(run) {
32
+ const tasks = summarizeTasks(run.tasks || []);
33
+ const phases = summarizePhases(run);
34
+ const workers = summarizeOperatorWorkers(run);
35
+ const candidates = summarizeOperatorCandidates(run);
36
+ const feedback = summarizeOperatorFeedback(run);
37
+ const commits = summarizeOperatorCommits(run);
38
+ const topologies = (0, topology_1.summarizeTopologies)(run);
39
+ const multiAgent = (0, multi_agent_1.summarizeMultiAgent)(run);
40
+ const multiAgentOperator = (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run);
41
+ const blackboard = (0, coordinator_1.summarizeBlackboard)(run);
42
+ const trust = (0, trust_audit_1.summarizeTrustAudit)(run);
43
+ const multiAgentTrust = (0, multi_agent_trust_1.summarizeMultiAgentTrust)(run);
44
+ const activePhase = phases.find((phase) => phase.status === "running") || phases.find((phase) => phase.status === "pending");
45
+ const blockedReasons = blockedReasonsFor(run, feedback, workers, candidates, topologies, multiAgent, blackboard);
46
+ return {
47
+ runId: run.id,
48
+ workflowId: run.workflow.id,
49
+ workflowTitle: run.workflow.title,
50
+ appId: run.workflow.app?.id,
51
+ appVersion: run.workflow.app?.version,
52
+ loopStage: run.loopStage,
53
+ activePhase: activePhase?.name,
54
+ blocked: blockedReasons.length > 0,
55
+ blockedReasons,
56
+ phases,
57
+ tasks,
58
+ workers,
59
+ candidates,
60
+ feedback,
61
+ commits,
62
+ topologies,
63
+ multiAgent,
64
+ multiAgentOperator,
65
+ blackboard,
66
+ trust,
67
+ multiAgentTrust,
68
+ reportPath: run.paths.report,
69
+ evidencePaths: evidencePathsFor(run),
70
+ nextActions: adviseNextSteps(run, { tasks, workers, candidates, feedback, commits, topologies, blackboard })
71
+ };
72
+ }
73
+ function adviseNoRun() {
74
+ return [
75
+ {
76
+ command: "node scripts/cw.js plan <workflow-id> --repo <path>",
77
+ reason: "No run id is available yet; create a workflow run before dispatching or recording evidence.",
78
+ priority: "high"
79
+ }
80
+ ];
81
+ }
82
+ function summarizeOperatorWorkers(run) {
83
+ const workers = sortedWorkers(run.workers || []);
84
+ return {
85
+ total: workers.length,
86
+ byStatus: countByKnown(workers, (worker) => worker.status, ["allocated", "running", "completed", "failed", "rejected", "verified"]),
87
+ bySandboxProfile: countBy(workers, (worker) => worker.sandboxProfileId || "none"),
88
+ byBackend: countBy(workers, (worker) => worker.backendId || "none"),
89
+ manifestPaths: workers.map(workerManifestPath),
90
+ resultPaths: workers.map((worker) => worker.output?.resultPath || worker.resultPath).filter(Boolean),
91
+ failed: workers
92
+ .filter((worker) => worker.status === "failed" || worker.status === "rejected")
93
+ .map((worker) => ({
94
+ id: worker.id,
95
+ status: worker.status,
96
+ taskId: worker.taskId,
97
+ feedbackIds: worker.feedbackIds || [],
98
+ errors: (worker.errors || []).map((error) => error.message)
99
+ })),
100
+ workers: workers.map((worker) => ({
101
+ id: worker.id,
102
+ taskId: worker.taskId,
103
+ status: worker.status,
104
+ sandboxProfileId: worker.sandboxProfileId,
105
+ backendId: worker.backendId,
106
+ backendAttestationStatus: worker.backendAttestation?.status,
107
+ manifestPath: workerManifestPath(worker),
108
+ resultPath: worker.output?.resultPath || worker.resultPath,
109
+ feedbackIds: worker.feedbackIds || []
110
+ }))
111
+ };
112
+ }
113
+ function summarizeOperatorCandidates(run) {
114
+ const candidates = [...(run.candidates || [])].sort((left, right) => left.id.localeCompare(right.id));
115
+ const selections = [...(run.candidateSelections || [])].sort((left, right) => left.id.localeCompare(right.id));
116
+ const selectedIds = new Set(selections.map((selection) => selection.candidateId));
117
+ const latestRankingPath = run.paths.candidatesDir ? node_path_1.default.join(run.paths.candidatesDir, "ranking.json") : undefined;
118
+ const readyForCommit = selections
119
+ .filter((selection) => {
120
+ const candidate = candidates.find((item) => item.id === selection.candidateId);
121
+ if (!candidate || candidate.status !== "verified" || !selection.scoreId)
122
+ return false;
123
+ return !(run.commits || []).some((commit) => commit.verifierGated && commit.selectionId === selection.id);
124
+ })
125
+ .map((selection) => ({
126
+ candidateId: selection.candidateId,
127
+ selectionId: selection.id,
128
+ scoreId: selection.scoreId,
129
+ verifierNodeId: selection.verifierNodeId
130
+ }));
131
+ return {
132
+ total: candidates.length,
133
+ byStatus: countBy(candidates, (candidate) => candidate.status),
134
+ byKind: countBy(candidates, (candidate) => candidate.kind),
135
+ latestRankingPath: latestRankingPath && node_fs_1.default.existsSync(latestRankingPath) ? latestRankingPath : latestRankingPath,
136
+ selected: selections.map((selection) => ({
137
+ selectionId: selection.id,
138
+ candidateId: selection.candidateId,
139
+ scoreId: selection.scoreId,
140
+ verifierNodeId: selection.verifierNodeId
141
+ })),
142
+ readyForCommit,
143
+ problems: candidateProblems(candidates, selections),
144
+ candidates: candidates.map((candidate) => ({
145
+ id: candidate.id,
146
+ kind: candidate.kind,
147
+ status: candidate.status,
148
+ scoreCount: candidate.scores.length,
149
+ selected: selectedIds.has(candidate.id),
150
+ feedbackIds: candidate.feedbackIds || [],
151
+ resultPath: candidate.resultPath
152
+ }))
153
+ };
154
+ }
155
+ function summarizeOperatorFeedback(run) {
156
+ const feedback = [...(run.feedback || [])].sort((left, right) => left.id.localeCompare(right.id));
157
+ const open = feedback.filter((record) => record.status === "open" || record.status === "tasked");
158
+ return {
159
+ total: feedback.length,
160
+ byStatus: countByKnown(feedback, (record) => record.status, ["open", "tasked", "resolved", "rejected"]),
161
+ bySeverity: countByKnown(feedback, (record) => record.severity, ["critical", "high", "medium", "low", "info"]),
162
+ byClassification: countByKnown(feedback, (record) => record.classification, [
163
+ "contract-violation",
164
+ "verifier-failure",
165
+ "state-transition",
166
+ "missing-artifact",
167
+ "missing-evidence",
168
+ "parse-error",
169
+ "pipeline-failure",
170
+ "sandbox-policy",
171
+ "runtime-error",
172
+ "unknown"
173
+ ]),
174
+ retryable: feedback.filter((record) => record.retryable).length,
175
+ nonRetryable: feedback.filter((record) => !record.retryable).length,
176
+ open: open.map((record) => ({
177
+ id: record.id,
178
+ severity: record.severity,
179
+ classification: record.classification,
180
+ retryable: record.retryable,
181
+ message: record.message,
182
+ taskId: record.taskId,
183
+ nodeId: record.nodeId
184
+ }))
185
+ };
186
+ }
187
+ function summarizeOperatorCommits(run) {
188
+ const commits = [...(run.commits || [])].sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id));
189
+ const rows = commits.map(formatCommitRow);
190
+ return {
191
+ total: rows.length,
192
+ verifierGated: rows.filter((commit) => commit.kind === "verifier-gated").length,
193
+ checkpoints: rows.filter((commit) => commit.kind === "checkpoint").length,
194
+ latest: rows.at(-1),
195
+ commits: rows
196
+ };
197
+ }
198
+ function buildOperatorGraph(run) {
199
+ const nodes = new Map();
200
+ const edges = [];
201
+ const addNode = (id, kind, status, label, pathValue) => {
202
+ nodes.set(id, { id, kind, status, label, path: pathValue });
203
+ };
204
+ const addEdge = (from, to, label) => {
205
+ if (!from || !to)
206
+ return;
207
+ edges.push({ from, to, label });
208
+ };
209
+ addNode(`${run.id}:run`, "run", run.loopStage, run.id, run.paths.state);
210
+ for (const phase of run.phases || []) {
211
+ const status = phaseStatusFromTasks(run, phase.taskIds);
212
+ const phaseId = `${run.id}:phase:${safeId(phase.id)}`;
213
+ addNode(phaseId, "phase", status, phase.name);
214
+ addEdge(`${run.id}:run`, phaseId);
215
+ for (const taskId of phase.taskIds)
216
+ addEdge(phaseId, `${run.id}:task:${taskId}`);
217
+ }
218
+ for (const task of run.tasks || []) {
219
+ addNode(`${run.id}:task:${task.id}`, "task", task.status, task.id, task.taskPath);
220
+ addEdge(`${run.id}:task:${task.id}`, task.dispatchId ? `${run.id}:dispatch:${task.dispatchId}` : undefined);
221
+ addEdge(`${run.id}:task:${task.id}`, task.resultNodeId);
222
+ addEdge(`${run.id}:task:${task.id}`, task.verifierNodeId);
223
+ }
224
+ for (const dispatch of run.dispatches || []) {
225
+ addNode(`${run.id}:dispatch:${dispatch.id}`, "dispatch", "completed", dispatch.id, dispatch.manifestPath);
226
+ for (const workerId of dispatch.workerIds || [])
227
+ addEdge(`${run.id}:dispatch:${dispatch.id}`, `${run.id}:worker:${workerId}`);
228
+ }
229
+ for (const worker of run.workers || []) {
230
+ addNode(`${run.id}:worker:${worker.id}`, "worker", worker.status, worker.id, workerManifestPath(worker));
231
+ addEdge(`${run.id}:worker:${worker.id}`, worker.resultNodeId);
232
+ for (const feedbackId of worker.feedbackIds || [])
233
+ addEdge(`${run.id}:worker:${worker.id}`, `${run.id}:feedback:${feedbackId}`);
234
+ }
235
+ for (const node of run.nodes || []) {
236
+ addNode(node.id, node.kind, operatorNodeStatus(run, node), shortNodeLabel(node), node.artifacts[0]?.path);
237
+ for (const parent of node.parents || [])
238
+ addEdge(parent, node.id);
239
+ }
240
+ for (const candidate of run.candidates || []) {
241
+ addNode(`${run.id}:candidate:${candidate.id}`, "candidate", candidate.status, candidate.id, candidate.resultPath);
242
+ addEdge(candidate.resultNodeId, `${run.id}:candidate:${candidate.id}`);
243
+ addEdge(candidate.verifierNodeId, `${run.id}:candidate:${candidate.id}`, "gate");
244
+ for (const feedbackId of candidate.feedbackIds || [])
245
+ addEdge(`${run.id}:candidate:${candidate.id}`, `${run.id}:feedback:${feedbackId}`);
246
+ }
247
+ for (const selection of run.candidateSelections || []) {
248
+ addNode(`${run.id}:selection:${selection.id}`, "selection", "verified", selection.id, selection.rankingPath);
249
+ addEdge(`${run.id}:candidate:${selection.candidateId}`, `${run.id}:selection:${selection.id}`);
250
+ addEdge(selection.verifierNodeId, `${run.id}:selection:${selection.id}`, "verifier");
251
+ }
252
+ for (const commit of run.commits || []) {
253
+ const commitNodeId = commit.stateNodeId || `${run.id}:commit:${commit.id}`;
254
+ addNode(commitNodeId, "commit", commit.verifierGated ? "committed" : "completed", commit.id, commit.snapshotPath);
255
+ addEdge(commit.verifierNodeId, commitNodeId, "verifier");
256
+ addEdge(commit.selectionId ? `${run.id}:selection:${commit.selectionId}` : undefined, commitNodeId, "selection");
257
+ }
258
+ for (const feedback of run.feedback || []) {
259
+ addNode(`${run.id}:feedback:${feedback.id}`, "feedback", feedback.status, `${feedback.severity} ${feedback.classification}`);
260
+ addEdge(feedback.nodeId, `${run.id}:feedback:${feedback.id}`);
261
+ addEdge(feedback.taskId ? `${run.id}:task:${feedback.taskId}` : undefined, `${run.id}:feedback:${feedback.id}`);
262
+ }
263
+ const multiAgentGraph = (0, multi_agent_1.buildMultiAgentGraph)(run);
264
+ for (const node of multiAgentGraph.nodes)
265
+ addNode(node.id, node.kind, node.status, node.label, node.path);
266
+ for (const edge of multiAgentGraph.edges)
267
+ addEdge(edge.from, edge.to, edge.label);
268
+ const topologyGraph = (0, topology_1.buildTopologyGraph)(run);
269
+ for (const node of topologyGraph.nodes)
270
+ addNode(node.id, node.kind, node.status, node.label, node.path);
271
+ for (const edge of topologyGraph.edges)
272
+ addEdge(edge.from, edge.to, edge.label);
273
+ const blackboardGraph = (0, coordinator_1.buildBlackboardGraph)(run);
274
+ for (const node of blackboardGraph.nodes)
275
+ addNode(node.id, node.kind, node.status, node.label, node.path);
276
+ for (const edge of blackboardGraph.edges)
277
+ addEdge(edge.from, edge.to, edge.label);
278
+ return {
279
+ runId: run.id,
280
+ nodes: [...nodes.values()].sort(compareGraphNodes),
281
+ edges: uniqueEdges(edges).sort(compareEdges)
282
+ };
283
+ }
284
+ function formatOperatorStatus(summary) {
285
+ const operator = summary.multiAgentOperator;
286
+ return [
287
+ `Run: ${summary.runId}`,
288
+ `Workflow: ${summary.workflowId}${summary.appId ? ` (${summary.appId}@${summary.appVersion || "unknown"})` : ""}`,
289
+ `Loop Stage: ${summary.loopStage}`,
290
+ `Active Phase: ${summary.activePhase || "none"}`,
291
+ `Blocked: ${summary.blocked ? summary.blockedReasons.join("; ") : "no"}`,
292
+ `Tasks: ${formatCounts(summary.tasks.byStatus)}; total=${summary.tasks.total}`,
293
+ "",
294
+ "Phases",
295
+ ...summary.phases.map((phase) => ` ${phase.name}: ${phase.status} (${phase.tasks.completed}/${phase.tasks.total} completed)`),
296
+ "",
297
+ formatWorkerPanel(summary.workers),
298
+ "",
299
+ formatCandidatePanel(summary.candidates),
300
+ "",
301
+ formatFeedbackPanel(summary.feedback),
302
+ "",
303
+ formatCommitPanel(summary.commits),
304
+ "",
305
+ formatTopologyPanel(summary.topologies),
306
+ "",
307
+ formatMultiAgentPanel(summary.multiAgent),
308
+ "",
309
+ "Multi-Agent Operator UX",
310
+ ` active=${operator.activeMultiAgentRunIds.join(", ") || "none"}; topologies=${operator.topologyRunIds.join(", ") || "none"}; blocked=${operator.blocked ? "yes" : "no"}`,
311
+ ` dependencies=${operator.dependencies.length}; failures=${operator.failures.length}; adoptedEvidence=${operator.adoptedEvidence.length}; missingEvidence=${operator.missingEvidence.length}${operator.inspectableEvidence.length ? ` (inspectable=${operator.inspectableEvidence.length})` : ""}`,
312
+ ` next=${operator.nextAction}`,
313
+ "",
314
+ formatBlackboardPanel(summary.blackboard),
315
+ "",
316
+ formatTrustPanel(summary.trust),
317
+ "",
318
+ formatMultiAgentTrustAudit(summary.multiAgentTrust),
319
+ "",
320
+ `Report: ${summary.reportPath}`,
321
+ "",
322
+ "Next Action",
323
+ ...formatRecommendations(summary.nextActions)
324
+ ].join("\n");
325
+ }
326
+ function formatOperatorReport(summary) {
327
+ return [
328
+ formatOperatorStatus(summary),
329
+ "",
330
+ "Active and Pending Tasks",
331
+ ...formatTaskList(summary.tasks),
332
+ "",
333
+ "Evidence",
334
+ ...(summary.evidencePaths.length ? summary.evidencePaths.map((entry) => ` ${entry}`) : [" none recorded"]),
335
+ "",
336
+ (0, multi_agent_operator_ux_1.formatMultiAgentDependencies)(summary.multiAgentOperator.dependencies),
337
+ "",
338
+ (0, multi_agent_operator_ux_1.formatMultiAgentFailures)(summary.multiAgentOperator.failures),
339
+ "",
340
+ (0, multi_agent_operator_ux_1.formatMultiAgentEvidence)(summary.multiAgentOperator.evidence),
341
+ "",
342
+ "Resource Commands",
343
+ ` node scripts/cw.js graph ${summary.runId}`,
344
+ ` node scripts/cw.js worker summary ${summary.runId}`,
345
+ ` node scripts/cw.js topology summary ${summary.runId}`,
346
+ ` node scripts/cw.js topology graph ${summary.runId}`,
347
+ ` node scripts/cw.js multi-agent summary ${summary.runId}`,
348
+ ` node scripts/cw.js multi-agent graph ${summary.runId}`,
349
+ ` node scripts/cw.js multi-agent dependencies ${summary.runId}`,
350
+ ` node scripts/cw.js multi-agent failures ${summary.runId}`,
351
+ ` node scripts/cw.js multi-agent evidence ${summary.runId}`,
352
+ ` node scripts/cw.js blackboard summary ${summary.runId}`,
353
+ ` node scripts/cw.js blackboard graph ${summary.runId}`,
354
+ ` node scripts/cw.js coordinator summary ${summary.runId}`,
355
+ ` node scripts/cw.js candidate summary ${summary.runId}`,
356
+ ` node scripts/cw.js feedback summary ${summary.runId}`,
357
+ ` node scripts/cw.js commit summary ${summary.runId}`,
358
+ ` node scripts/cw.js audit summary ${summary.runId}`,
359
+ ` node scripts/cw.js audit provenance ${summary.runId}`,
360
+ ` node scripts/cw.js audit multi-agent ${summary.runId}`,
361
+ ` node scripts/cw.js audit policy ${summary.runId}`,
362
+ ` node scripts/cw.js audit blackboard ${summary.runId}`,
363
+ ` node scripts/cw.js audit judge ${summary.runId}`
364
+ ].join("\n");
365
+ }
366
+ function formatOperatorGraph(graph) {
367
+ const lines = [`Run Graph: ${graph.runId}`, "", "Nodes"];
368
+ const groups = groupBy(graph.nodes, (node) => node.kind);
369
+ for (const kind of Object.keys(groups).sort()) {
370
+ lines.push(` ${kind}`);
371
+ for (const node of groups[kind]) {
372
+ const suffix = node.path ? ` -> ${node.path}` : "";
373
+ lines.push(` [${node.status}] ${node.id} (${node.label})${suffix}`);
374
+ }
375
+ }
376
+ lines.push("", "Edges");
377
+ if (!graph.edges.length)
378
+ lines.push(" none");
379
+ for (const edge of graph.edges) {
380
+ lines.push(` ${edge.from} -> ${edge.to}${edge.label ? ` (${edge.label})` : ""}`);
381
+ }
382
+ return lines.join("\n");
383
+ }
384
+ function formatWorkerSummary(summary) {
385
+ return formatWorkerPanel(summary);
386
+ }
387
+ function formatCandidateSummary(summary) {
388
+ return formatCandidatePanel(summary);
389
+ }
390
+ function formatFeedbackSummary(summary) {
391
+ return formatFeedbackPanel(summary);
392
+ }
393
+ function formatCommitSummary(summary) {
394
+ return formatCommitPanel(summary);
395
+ }
396
+ function formatTrustPanel(summary) {
397
+ const lines = [
398
+ "Trust Audit",
399
+ ` total=${summary.eventCount}; decision=${formatCounts(summary.byDecision)}; source=${formatCounts(summary.bySource)}`,
400
+ ` sandbox=${formatCounts(summary.bySandboxProfile)}`,
401
+ ` multi-agent trust=${summary.multiAgentTrust ? formatCounts(summary.multiAgentTrust) : "none"}`,
402
+ ` events=${summary.eventLogPath}`,
403
+ ` summary=${summary.summaryPath}`
404
+ ];
405
+ for (const worker of summary.workers.slice(0, 6)) {
406
+ lines.push(` worker ${worker.workerId}: sandbox=${worker.sandboxProfileId || "none"}, decisions=${formatCounts(worker.decisions)}, denied=${worker.denied}`);
407
+ }
408
+ return lines.join("\n");
409
+ }
410
+ function formatMultiAgentSummary(summary) {
411
+ return formatMultiAgentPanel(summary);
412
+ }
413
+ function formatTopologySummary(summary) {
414
+ return formatTopologyPanel(summary);
415
+ }
416
+ function formatMultiAgentTrustAudit(view) {
417
+ const rolePolicies = arrayView(view.rolePolicies);
418
+ const permissionDecisions = arrayView(view.permissionDecisions);
419
+ const blackboardWrites = arrayView(view.blackboardWrites);
420
+ const messageProvenance = arrayView(view.messageProvenance);
421
+ const judgeRationales = arrayView(view.judgeRationales);
422
+ const panelDecisions = arrayView(view.panelDecisions);
423
+ const policyViolations = arrayView(view.policyViolations);
424
+ return [
425
+ `Multi-Agent Trust: ${String(view.runId || "unknown")}`,
426
+ "",
427
+ "Role Policies",
428
+ ...formatRolePolicyRows(rolePolicies),
429
+ "",
430
+ "Permission Decisions",
431
+ ...formatAuditRows(permissionDecisions),
432
+ "",
433
+ "Blackboard Write Audit",
434
+ ...formatAuditRows(blackboardWrites),
435
+ "",
436
+ "Message Provenance",
437
+ ...formatAuditRows(messageProvenance),
438
+ "",
439
+ "Judge Rationales",
440
+ ...formatAuditRows([...judgeRationales, ...panelDecisions]),
441
+ "",
442
+ "Policy Violations",
443
+ ...formatAuditRows(policyViolations),
444
+ "",
445
+ "Next Action",
446
+ ` ${String(view.nextAction || `node scripts/cw.js audit multi-agent ${String(view.runId || "<run-id>")} --json`)}`
447
+ ].join("\n");
448
+ }
449
+ function formatTopologyPanel(summary) {
450
+ const lines = [
451
+ "Topologies",
452
+ ` runs=${summary.totalRuns}; status=${formatCounts(summary.runsByStatus)}; official=${summary.officialTopologies.join(", ")}`
453
+ ];
454
+ for (const record of summary.active.slice(0, 6)) {
455
+ lines.push(` ${record.id}: ${record.topologyId}, status=${record.status}, readiness=${record.readiness}`);
456
+ lines.push(` run=${record.multiAgentRunId} board=${record.blackboardId}`);
457
+ lines.push(` roles=${record.roles.join(", ") || "none"} topics=${record.topics.join(", ") || "none"}`);
458
+ lines.push(` fanout=${record.fanouts.join(", ") || "none"} fanin=${record.fanins.join(", ") || "none"}`);
459
+ for (const missing of record.missingEvidence.slice(0, 4))
460
+ lines.push(` missing=${missing}`);
461
+ for (const conflict of record.conflicts.slice(0, 4))
462
+ lines.push(` conflict=${conflict}`);
463
+ if (record.nextActions[0])
464
+ lines.push(` next=${record.nextActions[0]}`);
465
+ }
466
+ if (summary.nextAction)
467
+ lines.push(` next=${summary.nextAction}`);
468
+ return lines.join("\n");
469
+ }
470
+ function formatMultiAgentPanel(summary) {
471
+ const lines = [
472
+ "Multi-Agent",
473
+ ` runs=${summary.totalRuns}; status=${formatCounts(summary.runsByStatus)}`,
474
+ ` roles=${summary.roles}; groups=${summary.groups} (${formatCounts(summary.groupsByStatus)})`,
475
+ ` memberships=${summary.memberships} (${formatCounts(summary.membershipsByStatus)})`,
476
+ ` fanouts=${summary.fanouts}; fanins=${summary.fanins} (${formatCounts(summary.faninsByStatus)})`
477
+ ];
478
+ for (const group of summary.groupsDetail.slice(0, 6)) {
479
+ lines.push(` group ${group.id}: ${group.status}, phase=${group.phase || "none"}, run=${group.multiAgentRunId}`);
480
+ for (const role of group.roles.slice(0, 6)) {
481
+ lines.push(` role ${role.roleId}: memberships=${role.memberships}, reported=${role.reported}, missing=${role.missing}`);
482
+ }
483
+ lines.push(` fanout=${group.fanouts.join(", ") || "none"} fanin=${group.fanins.join(", ") || "none"}`);
484
+ }
485
+ for (const reason of summary.blockedReasons.slice(0, 6))
486
+ lines.push(` blocked: ${reason}`);
487
+ if (summary.nextAction)
488
+ lines.push(` next=${summary.nextAction}`);
489
+ return lines.join("\n");
490
+ }
491
+ function formatBlackboardPanel(summary) {
492
+ const lines = [
493
+ "Blackboard / Coordinator",
494
+ ` board=${summary.blackboardId || "none"}; topics=${summary.topics}; messages=${summary.messages}; contexts=${summary.contexts}; artifacts=${summary.artifacts}`,
495
+ ` open questions=${summary.openQuestions.length}; conflicts=${summary.conflicts.length}; missing evidence=${summary.missingEvidence.length}`,
496
+ ` ready for fanin=${summary.readyForFanin ? "yes" : "no"}`,
497
+ ` index=${summary.indexPath || "none"}`,
498
+ ` latest snapshot=${summary.latestSnapshotPath || "none"}`
499
+ ];
500
+ for (const question of summary.openQuestions.slice(0, 5))
501
+ lines.push(` question ${question.id}: ${question.value}`);
502
+ for (const conflict of summary.conflicts.slice(0, 5))
503
+ lines.push(` conflict ${conflict.id}: ${conflict.key} -> ${conflict.conflictingContextIds.join(", ") || "unindexed"}`);
504
+ for (const missing of summary.missingEvidence.slice(0, 5))
505
+ lines.push(` missing: ${missing}`);
506
+ if (summary.nextAction)
507
+ lines.push(` next=${summary.nextAction}`);
508
+ return lines.join("\n");
509
+ }
510
+ function arrayView(value) {
511
+ return Array.isArray(value) ? value : [];
512
+ }
513
+ function formatRolePolicyRows(rows) {
514
+ if (!rows.length)
515
+ return [" none"];
516
+ return rows.slice(0, 40).map((row) => {
517
+ const writes = Array.isArray(row.allowedWriteOperations) ? row.allowedWriteOperations.join(",") : "none";
518
+ const candidates = Array.isArray(row.allowedCandidateOperations) ? row.allowedCandidateOperations.join(",") : "none";
519
+ const judges = Array.isArray(row.allowedJudgeOperations) ? row.allowedJudgeOperations.join(",") : "none";
520
+ const topics = Array.isArray(row.allowedBlackboardTopicIds) ? row.allowedBlackboardTopicIds.join(",") : "none";
521
+ return ` ${String(row.policyRef || row.id || row.subjectId)} subject=${String(row.subjectKind || "unknown")}:${String(row.subjectId || "unknown")} topics=${topics} writes=${writes} candidates=${candidates} judges=${judges}`;
522
+ });
523
+ }
524
+ function formatAuditRows(rows) {
525
+ if (!rows.length)
526
+ return [" none"];
527
+ return rows.slice(0, 60).map((row) => {
528
+ const metadata = row.metadata && typeof row.metadata === "object" ? row.metadata : {};
529
+ const ids = [
530
+ row.agentRoleId ? `role=${row.agentRoleId}` : "",
531
+ row.agentMembershipId ? `membership=${row.agentMembershipId}` : "",
532
+ row.blackboardMessageId ? `message=${row.blackboardMessageId}` : "",
533
+ row.blackboardContextId ? `context=${row.blackboardContextId}` : "",
534
+ row.blackboardArtifactRefId ? `artifact=${row.blackboardArtifactRefId}` : "",
535
+ row.coordinatorDecisionId ? `decision=${row.coordinatorDecisionId}` : "",
536
+ row.candidateId ? `candidate=${row.candidateId}` : "",
537
+ row.scoreId ? `score=${row.scoreId}` : "",
538
+ row.selectionId ? `selection=${row.selectionId}` : ""
539
+ ].filter(Boolean).join(" ");
540
+ const reason = metadata.reason ? ` reason=${String(metadata.reason)}` : "";
541
+ const operation = metadata.operation ? ` operation=${String(metadata.operation)}` : "";
542
+ return ` [${String(row.decision || "recorded")}] ${String(row.kind || "event")} ${String(row.id || "")}${operation}${ids ? ` ${ids}` : ""}${row.policyRef ? ` policy=${String(row.policyRef)}` : ""}${reason}`;
543
+ });
544
+ }
545
+ function adviseNextSteps(run, summary) {
546
+ const actions = [];
547
+ if (summary.feedback.open.length) {
548
+ const feedback = summary.feedback.open[0];
549
+ actions.push({
550
+ command: `node scripts/cw.js feedback show ${run.id} ${feedback.id}`,
551
+ reason: `Open ${feedback.severity} ${feedback.classification} feedback should be inspected before more dispatch.`,
552
+ priority: "high"
553
+ });
554
+ actions.push({
555
+ command: `node scripts/cw.js feedback task ${run.id} ${feedback.id}`,
556
+ reason: "Create a correction task if the feedback is actionable.",
557
+ priority: "normal"
558
+ });
559
+ return actions;
560
+ }
561
+ const failedWorker = summary.workers.failed[0];
562
+ if (failedWorker) {
563
+ actions.push({
564
+ command: `node scripts/cw.js feedback list ${run.id}`,
565
+ reason: `Worker ${failedWorker.id} is ${failedWorker.status}; inspect linked feedback before retrying.`,
566
+ priority: "high"
567
+ });
568
+ return actions;
569
+ }
570
+ if (summary.tasks.running.length) {
571
+ const worker = summary.workers.workers.find((item) => item.status === "running" || item.status === "allocated");
572
+ actions.push({
573
+ command: worker ? `node scripts/cw.js worker manifest ${run.id} ${worker.id}` : `node scripts/cw.js worker list ${run.id}`,
574
+ reason: "Running workers need their manifests inspected and final output recorded.",
575
+ priority: "high"
576
+ });
577
+ if (worker) {
578
+ actions.push({
579
+ command: `node scripts/cw.js worker output ${run.id} ${worker.id} ${worker.resultPath}`,
580
+ reason: "Record the worker result after its result.md is ready.",
581
+ priority: "normal"
582
+ });
583
+ }
584
+ return actions;
585
+ }
586
+ const activeTopology = summary.topologies.active[0];
587
+ if (activeTopology && activeTopology.status !== "completed" && activeTopology.status !== "failed") {
588
+ actions.push({
589
+ command: `node scripts/cw.js multi-agent status ${run.id}`,
590
+ reason: "Use the high-level multi-agent host surface for topology-backed work.",
591
+ priority: "high"
592
+ });
593
+ actions.push({
594
+ command: `node scripts/cw.js multi-agent step ${run.id}`,
595
+ reason: "Perform the next safe host step without spawning agents implicitly.",
596
+ priority: "normal"
597
+ });
598
+ return actions;
599
+ }
600
+ if (summary.tasks.pending.length) {
601
+ const limit = Math.min(summary.tasks.pending.length, run.workflow.limits.maxConcurrentAgents || 4);
602
+ actions.push({
603
+ command: `node scripts/cw.js dispatch ${run.id} --limit ${limit}`,
604
+ reason: `${summary.tasks.pending.length} pending task(s) are ready for the active phase.`,
605
+ priority: "high"
606
+ });
607
+ return actions;
608
+ }
609
+ if (summary.blackboard.blackboardId && summary.blackboard.nextAction && !summary.blackboard.readyForFanin) {
610
+ actions.push({
611
+ command: summary.blackboard.nextAction,
612
+ reason: "Blackboard shared context is not ready for fanin yet.",
613
+ priority: "high"
614
+ });
615
+ return actions;
616
+ }
617
+ const topologyAction = summary.topologies.active.find((topology) => topology.nextActions.length)?.nextActions[0];
618
+ if (topologyAction) {
619
+ actions.push({
620
+ command: topologyAction,
621
+ reason: "An active topology has a deterministic next action.",
622
+ priority: "high"
623
+ });
624
+ return actions;
625
+ }
626
+ if (summary.tasks.total > 0 && summary.tasks.completed.length === summary.tasks.total && summary.commits.verifierGated > 0) {
627
+ actions.push({
628
+ command: `node scripts/cw.js report ${run.id} --show`,
629
+ reason: "All tracked phases are complete and verifier-gated committed state exists.",
630
+ priority: "normal"
631
+ });
632
+ return actions;
633
+ }
634
+ const completedWithoutCandidate = (run.tasks || []).find((task) => task.status === "completed" && task.workerId && !(run.candidates || []).some((candidate) => candidate.workerId === task.workerId));
635
+ if (completedWithoutCandidate?.workerId) {
636
+ actions.push({
637
+ command: `node scripts/cw.js candidate register ${run.id} --worker ${completedWithoutCandidate.workerId}`,
638
+ reason: "A completed worker result is available but has not been registered as a candidate.",
639
+ priority: "high"
640
+ });
641
+ return actions;
642
+ }
643
+ const unscored = (run.candidates || []).find((candidate) => candidate.status === "registered" && !candidate.scores.length);
644
+ if (unscored) {
645
+ actions.push({
646
+ command: `node scripts/cw.js candidate score ${run.id} ${unscored.id} --criterion correctness=1 --evidence <path-or-locator>`,
647
+ reason: "Registered candidates need score evidence before ranking or selection.",
648
+ priority: "high"
649
+ });
650
+ return actions;
651
+ }
652
+ const scoredWithoutSelection = (run.candidates || []).find((candidate) => candidate.status === "scored" && !(run.candidateSelections || []).some((selection) => selection.candidateId === candidate.id));
653
+ if (scoredWithoutSelection) {
654
+ actions.push({
655
+ command: `node scripts/cw.js candidate rank ${run.id}`,
656
+ reason: "Scored candidates can be ranked before selection.",
657
+ priority: "high"
658
+ });
659
+ actions.push({
660
+ command: `node scripts/cw.js candidate select ${run.id} ${scoredWithoutSelection.id}`,
661
+ reason: "Select the candidate once the ranking supports it.",
662
+ priority: "normal"
663
+ });
664
+ return actions;
665
+ }
666
+ if (summary.candidates.readyForCommit.length) {
667
+ const ready = summary.candidates.readyForCommit[0];
668
+ actions.push({
669
+ command: `node scripts/cw.js commit ${run.id} --selection ${ready.selectionId}`,
670
+ reason: "A verified selected candidate is ready for a verifier-gated commit.",
671
+ priority: "high"
672
+ });
673
+ return actions;
674
+ }
675
+ actions.push({
676
+ command: `node scripts/cw.js report ${run.id} --show`,
677
+ reason: "All tracked phases are complete or no further operator action is currently available.",
678
+ priority: "normal"
679
+ });
680
+ return actions;
681
+ }
682
+ function summarizeTasks(tasks) {
683
+ const byStatus = countByKnown(tasks, (task) => task.status, ["pending", "running", "completed", "failed"]);
684
+ return {
685
+ total: tasks.length,
686
+ byStatus,
687
+ pending: tasks.filter((task) => task.status === "pending").map((task) => task.id).sort(),
688
+ running: tasks.filter((task) => task.status === "running").map((task) => task.id).sort(),
689
+ failed: tasks.filter((task) => task.status === "failed").map((task) => task.id).sort(),
690
+ completed: tasks.filter((task) => task.status === "completed").map((task) => task.id).sort()
691
+ };
692
+ }
693
+ function summarizePhases(run) {
694
+ return (run.phases || []).map((phase) => {
695
+ const tasks = run.tasks.filter((task) => phase.taskIds.includes(task.id));
696
+ return {
697
+ id: phase.id,
698
+ name: phase.name,
699
+ status: phaseStatusFromTasks(run, phase.taskIds),
700
+ tasks: {
701
+ total: tasks.length,
702
+ ...countByKnown(tasks, (task) => task.status, ["pending", "running", "completed", "failed"])
703
+ }
704
+ };
705
+ });
706
+ }
707
+ function phaseStatusFromTasks(run, taskIds) {
708
+ const tasks = run.tasks.filter((task) => taskIds.includes(task.id));
709
+ if (!tasks.length)
710
+ return "pending";
711
+ if (tasks.every((task) => task.status === "completed"))
712
+ return "completed";
713
+ if (tasks.some((task) => task.status === "running" || task.status === "completed"))
714
+ return "running";
715
+ if (tasks.some((task) => task.status === "failed"))
716
+ return "blocked";
717
+ return "pending";
718
+ }
719
+ function blockedReasonsFor(run, feedback, workers, candidates, topologies, multiAgent, blackboard) {
720
+ const reasons = [];
721
+ if (feedback.open.length)
722
+ reasons.push(`${feedback.open.length} open/tasked feedback record(s)`);
723
+ if (workers.failed.length)
724
+ reasons.push(`${workers.failed.length} failed/rejected worker(s)`);
725
+ if (run.tasks.some((task) => task.status === "failed"))
726
+ reasons.push("failed task(s)");
727
+ if (candidates.problems.length)
728
+ reasons.push(...candidates.problems.slice(0, 2));
729
+ for (const topology of topologies.active) {
730
+ if (topology.status === "blocked")
731
+ reasons.push(`topology ${topology.id} blocked: ${topology.missingEvidence[0] || "missing evidence"}`);
732
+ }
733
+ if (multiAgent.blockedReasons.length)
734
+ reasons.push(...multiAgent.blockedReasons.slice(0, 2));
735
+ if (blackboard.conflicts.length)
736
+ reasons.push(`${blackboard.conflicts.length} blackboard conflict(s)`);
737
+ if (blackboard.missingEvidence.length)
738
+ reasons.push(...blackboard.missingEvidence.slice(0, 2));
739
+ return reasons;
740
+ }
741
+ function candidateProblems(candidates, selections) {
742
+ const problems = [];
743
+ for (const candidate of candidates) {
744
+ if ((candidate.status === "registered" || candidate.status === "scored") && !candidate.evidence.length) {
745
+ problems.push(`candidate ${candidate.id} has no evidence`);
746
+ }
747
+ if (candidate.status === "registered" && !candidate.scores.length) {
748
+ problems.push(`candidate ${candidate.id} has not been scored`);
749
+ }
750
+ if ((candidate.status === "selected" || candidate.status === "verified") && !selections.some((selection) => selection.candidateId === candidate.id)) {
751
+ problems.push(`candidate ${candidate.id} status is ${candidate.status} but no selection record exists`);
752
+ }
753
+ }
754
+ return problems.sort();
755
+ }
756
+ function evidencePathsFor(run) {
757
+ const values = new Set();
758
+ for (const task of run.tasks || []) {
759
+ if (task.taskPath)
760
+ values.add(task.taskPath);
761
+ if (task.resultPath)
762
+ values.add(task.resultPath);
763
+ if (task.workerManifestPath)
764
+ values.add(task.workerManifestPath);
765
+ }
766
+ for (const dispatch of run.dispatches || [])
767
+ if (dispatch.manifestPath)
768
+ values.add(dispatch.manifestPath);
769
+ for (const worker of run.workers || []) {
770
+ values.add(workerManifestPath(worker));
771
+ if (worker.output?.resultPath)
772
+ values.add(worker.output.resultPath);
773
+ }
774
+ for (const candidate of run.candidates || []) {
775
+ if (candidate.resultPath)
776
+ values.add(candidate.resultPath);
777
+ for (const artifact of candidate.artifacts || [])
778
+ if (artifact.path)
779
+ values.add(artifact.path);
780
+ }
781
+ for (const commit of run.commits || [])
782
+ values.add(commit.snapshotPath);
783
+ for (const node of run.nodes || []) {
784
+ for (const artifact of node.artifacts || [])
785
+ if (artifact.path)
786
+ values.add(artifact.path);
787
+ for (const evidence of node.evidence || []) {
788
+ if (evidence.path)
789
+ values.add(evidence.path);
790
+ if (evidence.locator)
791
+ values.add(evidence.locator);
792
+ if (!evidence.path && !evidence.locator && evidence.summary)
793
+ values.add(evidence.summary);
794
+ }
795
+ }
796
+ if (run.paths.report)
797
+ values.add(run.paths.report);
798
+ return [...values].sort();
799
+ }
800
+ function formatWorkerPanel(summary) {
801
+ const lines = [
802
+ "Workers",
803
+ ` total=${summary.total}; status=${formatCounts(summary.byStatus)}; sandbox=${formatCounts(summary.bySandboxProfile)}; backend=${formatCounts(summary.byBackend)}`
804
+ ];
805
+ for (const worker of summary.workers.slice(0, 8)) {
806
+ const attestation = worker.backendAttestationStatus ? `/${worker.backendAttestationStatus}` : "";
807
+ lines.push(` ${worker.id}: ${worker.status}, task=${worker.taskId}, sandbox=${worker.sandboxProfileId || "none"}, backend=${worker.backendId || "none"}${attestation}`);
808
+ lines.push(` manifest=${worker.manifestPath}`);
809
+ lines.push(` result=${worker.resultPath}`);
810
+ if (worker.feedbackIds.length)
811
+ lines.push(` feedback=${worker.feedbackIds.join(", ")}`);
812
+ }
813
+ if (summary.workers.length > 8)
814
+ lines.push(` ... ${summary.workers.length - 8} more worker(s)`);
815
+ return lines.join("\n");
816
+ }
817
+ function formatCandidatePanel(summary) {
818
+ const lines = [
819
+ "Candidates",
820
+ ` total=${summary.total}; status=${formatCounts(summary.byStatus)}; kind=${formatCounts(summary.byKind)}`,
821
+ ` latest ranking=${summary.latestRankingPath || "none"}`,
822
+ ` selected=${summary.selected.map((selection) => `${selection.candidateId}/${selection.selectionId}`).join(", ") || "none"}`,
823
+ ` ready for commit=${summary.readyForCommit.map((item) => `${item.candidateId}/${item.selectionId}`).join(", ") || "none"}`
824
+ ];
825
+ for (const problem of summary.problems.slice(0, 5))
826
+ lines.push(` problem: ${problem}`);
827
+ for (const candidate of summary.candidates.slice(0, 8)) {
828
+ lines.push(` ${candidate.id}: ${candidate.status}, scores=${candidate.scoreCount}, selected=${candidate.selected ? "yes" : "no"}`);
829
+ }
830
+ if (summary.candidates.length > 8)
831
+ lines.push(` ... ${summary.candidates.length - 8} more candidate(s)`);
832
+ return lines.join("\n");
833
+ }
834
+ function formatFeedbackPanel(summary) {
835
+ const lines = [
836
+ "Feedback",
837
+ ` total=${summary.total}; status=${formatCounts(summary.byStatus)}`,
838
+ ` severity=${formatCounts(summary.bySeverity)}`,
839
+ ` classification=${formatCounts(summary.byClassification)}`,
840
+ ` retryable=${summary.retryable}; nonRetryable=${summary.nonRetryable}`
841
+ ];
842
+ for (const record of summary.open.slice(0, 6)) {
843
+ lines.push(` ${record.id}: ${record.severity}/${record.classification}, retryable=${record.retryable ? "yes" : "no"}`);
844
+ lines.push(` ${record.message}`);
845
+ }
846
+ return lines.join("\n");
847
+ }
848
+ function formatCommitPanel(summary) {
849
+ const lines = [
850
+ "Commits",
851
+ ` total=${summary.total}; verifier-gated=${summary.verifierGated}; checkpoints=${summary.checkpoints}`,
852
+ ` latest=${summary.latest ? `${summary.latest.id} (${summary.latest.kind}) ${summary.latest.snapshotPath}` : "none"}`
853
+ ];
854
+ for (const commit of summary.commits.slice(-8)) {
855
+ lines.push(` ${commit.id}: ${commit.kind}, reason=${commit.reason}`);
856
+ lines.push(` verifier=${commit.verifierNodeId || "none"} candidate=${commit.candidateId || "none"} selection=${commit.selectionId || "none"} evidence=${commit.evidenceCount}`);
857
+ lines.push(` snapshot=${commit.snapshotPath}`);
858
+ }
859
+ return lines.join("\n");
860
+ }
861
+ function formatTaskList(summary) {
862
+ const lines = [];
863
+ for (const [label, values] of [
864
+ ["pending", summary.pending],
865
+ ["running", summary.running],
866
+ ["failed", summary.failed]
867
+ ]) {
868
+ lines.push(` ${label}: ${values.length ? values.join(", ") : "none"}`);
869
+ }
870
+ return lines;
871
+ }
872
+ function formatRecommendations(actions) {
873
+ return actions.length ? actions.map((action) => ` ${action.command}\n reason: ${action.reason}`) : [" none"];
874
+ }
875
+ function formatCommitRow(commit) {
876
+ return {
877
+ id: commit.id,
878
+ kind: commit.verifierGated ? "verifier-gated" : "checkpoint",
879
+ reason: commit.reason,
880
+ createdAt: commit.createdAt,
881
+ snapshotPath: commit.snapshotPath,
882
+ stateNodeId: commit.stateNodeId,
883
+ verifierNodeId: commit.verifierNodeId,
884
+ candidateId: commit.candidateId,
885
+ selectionId: commit.selectionId,
886
+ evidenceCount: commit.evidence?.length || 0
887
+ };
888
+ }
889
+ function sortedWorkers(workers) {
890
+ return [...workers].sort((left, right) => left.id.localeCompare(right.id));
891
+ }
892
+ function workerManifestPath(worker) {
893
+ return node_path_1.default.join(worker.workerDir, "manifest.json");
894
+ }
895
+ function shortNodeLabel(node) {
896
+ const taskId = typeof node.metadata?.taskId === "string" ? node.metadata.taskId : undefined;
897
+ return taskId || node.id;
898
+ }
899
+ function operatorNodeStatus(run, node) {
900
+ if (node.kind !== "task")
901
+ return node.status;
902
+ const taskId = typeof node.metadata?.taskId === "string" ? node.metadata.taskId : taskIdFromNodeId(node.id);
903
+ return run.tasks.find((task) => task.id === taskId)?.status || node.status;
904
+ }
905
+ function taskIdFromNodeId(nodeId) {
906
+ const marker = ":task:";
907
+ const index = nodeId.indexOf(marker);
908
+ return index >= 0 ? nodeId.slice(index + marker.length) : undefined;
909
+ }
910
+ function compareGraphNodes(left, right) {
911
+ const byKind = left.kind.localeCompare(right.kind);
912
+ if (byKind)
913
+ return byKind;
914
+ return left.id.localeCompare(right.id);
915
+ }
916
+ function compareEdges(left, right) {
917
+ const byFrom = left.from.localeCompare(right.from);
918
+ if (byFrom)
919
+ return byFrom;
920
+ const byTo = left.to.localeCompare(right.to);
921
+ if (byTo)
922
+ return byTo;
923
+ return (left.label || "").localeCompare(right.label || "");
924
+ }
925
+ function uniqueEdges(edges) {
926
+ const seen = new Set();
927
+ const unique = [];
928
+ for (const edge of edges) {
929
+ const key = `${edge.from}\u001f${edge.to}\u001f${edge.label || ""}`;
930
+ if (seen.has(key))
931
+ continue;
932
+ seen.add(key);
933
+ unique.push(edge);
934
+ }
935
+ return unique;
936
+ }
937
+ function countBy(items, getKey) {
938
+ const counts = {};
939
+ for (const item of items) {
940
+ const key = getKey(item);
941
+ counts[key] = (counts[key] || 0) + 1;
942
+ }
943
+ return sortRecord(counts);
944
+ }
945
+ function countByKnown(items, getKey, keys) {
946
+ const counts = Object.fromEntries(keys.map((key) => [key, 0]));
947
+ for (const item of items)
948
+ counts[getKey(item)] += 1;
949
+ return counts;
950
+ }
951
+ function formatCounts(counts) {
952
+ const entries = Object.entries(counts).filter(([, value]) => value > 0).sort(([left], [right]) => left.localeCompare(right));
953
+ if (!entries.length)
954
+ return "none";
955
+ return entries.map(([key, value]) => `${key}=${value}`).join(", ");
956
+ }
957
+ function groupBy(items, getKey) {
958
+ const groups = {};
959
+ for (const item of items) {
960
+ const key = getKey(item);
961
+ groups[key] = groups[key] || [];
962
+ groups[key].push(item);
963
+ }
964
+ return groups;
965
+ }
966
+ function sortRecord(record) {
967
+ return Object.fromEntries(Object.entries(record).sort(([left], [right]) => left.localeCompare(right)));
968
+ }
969
+ function safeId(value) {
970
+ return String(value).replace(/[^a-zA-Z0-9_.:-]+/g, "_");
971
+ }