cool-workflow 0.1.97 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (309) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/README.md +11 -2
  4. package/apps/architecture-review/app.json +1 -1
  5. package/apps/architecture-review-fast/app.json +1 -1
  6. package/apps/end-to-end-golden-path/app.json +1 -1
  7. package/apps/pr-review-fix-ci/app.json +1 -1
  8. package/apps/release-cut/app.json +1 -1
  9. package/apps/research-synthesis/app.json +1 -1
  10. package/dist/cli/dispatch.js +236 -0
  11. package/dist/cli/entry.js +120 -0
  12. package/dist/cli/io.js +21 -4
  13. package/dist/cli/parseargv.js +157 -0
  14. package/dist/cli.js +6 -33
  15. package/dist/core/capability-table.js +3534 -0
  16. package/dist/core/format/help.js +314 -0
  17. package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
  18. package/dist/core/hash.js +137 -0
  19. package/dist/core/multi-agent/candidate-scoring.js +219 -0
  20. package/dist/core/multi-agent/collaboration.js +481 -0
  21. package/dist/core/multi-agent/coordinator.js +515 -0
  22. package/dist/core/multi-agent/eval-replay.js +306 -0
  23. package/dist/core/multi-agent/runtime.js +929 -0
  24. package/dist/core/multi-agent/topology.js +298 -0
  25. package/dist/core/multi-agent/trust-policy.js +197 -0
  26. package/dist/core/pipeline/commit-gate.js +320 -0
  27. package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
  28. package/dist/core/pipeline/dispatch.js +103 -0
  29. package/dist/core/pipeline/drive-decide.js +227 -0
  30. package/dist/core/pipeline/error-feedback.js +161 -0
  31. package/dist/core/pipeline/loop-expansion.js +124 -0
  32. package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
  33. package/dist/core/pipeline/runner.js +230 -0
  34. package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
  35. package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
  36. package/dist/core/state/node-projection.js +95 -0
  37. package/dist/core/state/node-snapshot.js +230 -0
  38. package/dist/core/state/run-paths.js +93 -0
  39. package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
  40. package/dist/core/state/schema.js +50 -0
  41. package/dist/core/state/state-explosion/digest.js +243 -0
  42. package/dist/core/state/state-explosion/graph.js +527 -0
  43. package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
  44. package/dist/core/state/state-explosion/report.js +187 -0
  45. package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
  46. package/dist/{state-node.js → core/state/state-node.js} +90 -113
  47. package/dist/core/state/types.js +19 -0
  48. package/dist/{validation.js → core/state/validation.js} +64 -131
  49. package/dist/core/trust/evidence-grounding.js +134 -0
  50. package/dist/core/trust/ledger.js +199 -0
  51. package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
  52. package/dist/core/trust/telemetry-ledger.js +127 -0
  53. package/dist/core/types.js +20 -0
  54. package/dist/core/version.js +16 -0
  55. package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
  56. package/dist/mcp/dispatch.js +104 -0
  57. package/dist/mcp/server.js +144 -0
  58. package/dist/mcp-server.js +6 -84
  59. package/dist/{agent-config.js → shell/agent-config.js} +118 -71
  60. package/dist/shell/app-run-cli.js +88 -0
  61. package/dist/shell/audit-cli.js +259 -0
  62. package/dist/shell/audit-provenance.js +83 -0
  63. package/dist/shell/candidate-scoring-io.js +459 -0
  64. package/dist/shell/collaboration-io.js +264 -0
  65. package/dist/shell/commit-summary.js +104 -0
  66. package/dist/shell/commit.js +290 -0
  67. package/dist/shell/coordinator-io.js +476 -0
  68. package/dist/shell/demo-cli.js +19 -0
  69. package/dist/shell/dispatch.js +162 -0
  70. package/dist/{doctor.js → shell/doctor.js} +123 -56
  71. package/dist/shell/drive.js +873 -0
  72. package/dist/shell/error-feedback-io.js +305 -0
  73. package/dist/shell/eval-io.js +473 -0
  74. package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
  75. package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
  76. package/dist/shell/exec-backend-cli.js +88 -0
  77. package/dist/shell/execution-backend/agent.js +475 -0
  78. package/dist/shell/execution-backend/ci.js +15 -0
  79. package/dist/shell/execution-backend/container.js +69 -0
  80. package/dist/shell/execution-backend/envelopes.js +55 -0
  81. package/dist/shell/execution-backend/local.js +113 -0
  82. package/dist/shell/execution-backend/probes.js +175 -0
  83. package/dist/shell/execution-backend/registry.js +402 -0
  84. package/dist/shell/execution-backend/remote.js +128 -0
  85. package/dist/shell/execution-backend/types.js +11 -0
  86. package/dist/shell/feedback-cli.js +81 -0
  87. package/dist/shell/feedback-operations.js +48 -0
  88. package/dist/shell/fs-atomic.js +276 -0
  89. package/dist/shell/harness.js +98 -0
  90. package/dist/shell/ledger-cli.js +212 -0
  91. package/dist/shell/ledger-io.js +169 -0
  92. package/dist/shell/man-cli.js +89 -0
  93. package/dist/shell/metrics-cli.js +98 -0
  94. package/dist/shell/multi-agent-cli.js +1002 -0
  95. package/dist/shell/multi-agent-host.js +563 -0
  96. package/dist/shell/multi-agent-io.js +387 -0
  97. package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
  98. package/dist/shell/node-store.js +124 -0
  99. package/dist/{observability/format.js → shell/observability-format.js} +7 -1
  100. package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
  101. package/dist/{observability.js → shell/observability.js} +159 -332
  102. package/dist/{onramp.js → shell/onramp.js} +11 -0
  103. package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
  104. package/dist/shell/operator-ux.js +431 -0
  105. package/dist/shell/orchestrator.js +231 -0
  106. package/dist/shell/pipeline-cli.js +667 -0
  107. package/dist/shell/pipeline.js +217 -0
  108. package/dist/shell/reclamation-io.js +1366 -0
  109. package/dist/shell/registry-cli.js +329 -0
  110. package/dist/{remote-source.js → shell/remote-source.js} +12 -5
  111. package/dist/shell/report-cli.js +101 -0
  112. package/dist/shell/report-view-cli.js +117 -0
  113. package/dist/{orchestrator → shell}/report.js +289 -282
  114. package/dist/shell/reporter.js +62 -0
  115. package/dist/shell/run-export-cli.js +106 -0
  116. package/dist/shell/run-export.js +680 -0
  117. package/dist/shell/run-registry-io.js +1014 -0
  118. package/dist/shell/run-store.js +164 -0
  119. package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
  120. package/dist/{scheduler.js → shell/scheduler-io.js} +248 -48
  121. package/dist/shell/scheduling-io.js +311 -0
  122. package/dist/shell/state-cli.js +181 -0
  123. package/dist/shell/state-explosion-cli.js +197 -0
  124. package/dist/shell/telemetry-cli.js +85 -0
  125. package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
  126. package/dist/shell/telemetry-ledger-io.js +132 -0
  127. package/dist/{term.js → shell/term.js} +36 -46
  128. package/dist/shell/topology-io.js +361 -0
  129. package/dist/shell/trust-audit.js +471 -0
  130. package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
  131. package/dist/shell/verifier.js +48 -0
  132. package/dist/shell/workbench-host.js +250 -0
  133. package/dist/shell/workbench-text.js +18 -0
  134. package/dist/shell/workbench.js +175 -0
  135. package/dist/shell/worker-cli.js +124 -0
  136. package/dist/shell/worker-isolation.js +852 -0
  137. package/dist/shell/workflow-app-loader.js +650 -0
  138. package/docs/agent-delegation-drive.7.md +4 -0
  139. package/docs/cli-mcp-parity.7.md +284 -211
  140. package/docs/contract-migration-tooling.7.md +4 -0
  141. package/docs/control-plane-scheduling.7.md +4 -0
  142. package/docs/cross-agent-ledger.7.md +217 -0
  143. package/docs/designs/handoff-ledger.md +145 -0
  144. package/docs/durable-state-and-locking.7.md +4 -0
  145. package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
  146. package/docs/execution-backends.7.md +4 -0
  147. package/docs/handoff-setup.md +120 -0
  148. package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
  149. package/docs/multi-agent-eval-replay-harness.7.md +4 -0
  150. package/docs/multi-agent-operator-ux.7.md +4 -0
  151. package/docs/node-snapshot-diff-replay.7.md +4 -0
  152. package/docs/observability-cost-accounting.7.md +4 -0
  153. package/docs/project-index.md +143 -71
  154. package/docs/real-execution-backends.7.md +4 -0
  155. package/docs/release-and-migration.7.md +4 -0
  156. package/docs/release-tooling.7.md +4 -0
  157. package/docs/run-registry-control-plane.7.md +4 -0
  158. package/docs/run-retention-reclamation.7.md +25 -0
  159. package/docs/state-explosion-management.7.md +4 -0
  160. package/docs/team-collaboration.7.md +4 -0
  161. package/docs/web-desktop-workbench.7.md +4 -0
  162. package/manifest/plugin.manifest.json +1 -1
  163. package/manifest/source-context-profiles.json +9 -13
  164. package/package.json +1 -1
  165. package/scripts/agents/codex-agent.js +34 -4
  166. package/scripts/agents/cw-attest-wrap.js +2 -2
  167. package/scripts/bump-version.js +4 -3
  168. package/scripts/canonical-apps.js +4 -4
  169. package/scripts/children/batch-delegate-child.js +30 -10
  170. package/scripts/dogfood-architecture-review.js +2 -3
  171. package/scripts/dogfood-release.js +3 -3
  172. package/scripts/gen-parity-doc.js +15 -2
  173. package/scripts/golden-path.js +4 -4
  174. package/scripts/onramp-check.js +1 -1
  175. package/scripts/parity-check.js +38 -21
  176. package/scripts/release-flow.js +9 -3
  177. package/scripts/sync-project-index.js +51 -27
  178. package/scripts/validate-run-state-schema.js +2 -2
  179. package/scripts/version-sync-check.js +30 -30
  180. package/dist/candidate-scoring.js +0 -729
  181. package/dist/capability-core.js +0 -1186
  182. package/dist/capability-registry.js +0 -879
  183. package/dist/cli/command-surface.js +0 -490
  184. package/dist/cli/format.js +0 -56
  185. package/dist/cli/handlers/audit.js +0 -82
  186. package/dist/cli/handlers/blackboard.js +0 -81
  187. package/dist/cli/handlers/candidate.js +0 -40
  188. package/dist/cli/handlers/clones.js +0 -34
  189. package/dist/cli/handlers/collaboration.js +0 -61
  190. package/dist/cli/handlers/eval.js +0 -40
  191. package/dist/cli/handlers/maintenance.js +0 -107
  192. package/dist/cli/handlers/multi-agent.js +0 -165
  193. package/dist/cli/handlers/node.js +0 -41
  194. package/dist/cli/handlers/operational.js +0 -155
  195. package/dist/cli/handlers/operator.js +0 -146
  196. package/dist/cli/handlers/registry.js +0 -68
  197. package/dist/cli/handlers/run.js +0 -153
  198. package/dist/cli/handlers/scheduling.js +0 -132
  199. package/dist/cli/handlers/workbench.js +0 -41
  200. package/dist/cli/handlers/worker.js +0 -45
  201. package/dist/cli/run-summary.js +0 -45
  202. package/dist/clones.js +0 -162
  203. package/dist/collaboration.js +0 -726
  204. package/dist/commit.js +0 -592
  205. package/dist/compare.js +0 -18
  206. package/dist/coordinator/classify.js +0 -45
  207. package/dist/coordinator/paths.js +0 -42
  208. package/dist/coordinator/util.js +0 -126
  209. package/dist/coordinator.js +0 -990
  210. package/dist/daemon.js +0 -44
  211. package/dist/dispatch.js +0 -250
  212. package/dist/drive.js +0 -827
  213. package/dist/error-feedback.js +0 -419
  214. package/dist/evidence-grounding.js +0 -184
  215. package/dist/execution-backend/agent.js +0 -294
  216. package/dist/execution-backend/probes.js +0 -112
  217. package/dist/execution-backend/util.js +0 -47
  218. package/dist/execution-backend.js +0 -961
  219. package/dist/gates.js +0 -48
  220. package/dist/harness.js +0 -61
  221. package/dist/loop-expansion.js +0 -60
  222. package/dist/mcp/tool-call.js +0 -434
  223. package/dist/mcp/tool-definitions.js +0 -1040
  224. package/dist/mcp-surface.js +0 -30
  225. package/dist/multi-agent/graph.js +0 -84
  226. package/dist/multi-agent/helpers.js +0 -141
  227. package/dist/multi-agent/ids.js +0 -20
  228. package/dist/multi-agent/paths.js +0 -22
  229. package/dist/multi-agent-eval/normalize.js +0 -51
  230. package/dist/multi-agent-eval.js +0 -678
  231. package/dist/multi-agent-host.js +0 -777
  232. package/dist/multi-agent.js +0 -984
  233. package/dist/node-projection.js +0 -59
  234. package/dist/node-snapshot.js +0 -260
  235. package/dist/operator-ux.js +0 -631
  236. package/dist/orchestrator/app-operations.js +0 -211
  237. package/dist/orchestrator/audit-operations.js +0 -182
  238. package/dist/orchestrator/candidate-operations.js +0 -117
  239. package/dist/orchestrator/cli-options.js +0 -294
  240. package/dist/orchestrator/collaboration-operations.js +0 -86
  241. package/dist/orchestrator/feedback-operations.js +0 -81
  242. package/dist/orchestrator/host-operations.js +0 -78
  243. package/dist/orchestrator/lifecycle-operations.js +0 -626
  244. package/dist/orchestrator/migration-operations.js +0 -44
  245. package/dist/orchestrator/multi-agent-operations.js +0 -362
  246. package/dist/orchestrator/topology-operations.js +0 -84
  247. package/dist/orchestrator.js +0 -917
  248. package/dist/pipeline-runner.js +0 -285
  249. package/dist/reclamation/hash.js +0 -72
  250. package/dist/reclamation.js +0 -812
  251. package/dist/reporter.js +0 -67
  252. package/dist/run-export.js +0 -784
  253. package/dist/run-registry/derive.js +0 -175
  254. package/dist/run-registry/format.js +0 -124
  255. package/dist/run-registry/gc.js +0 -251
  256. package/dist/run-registry/policy.js +0 -16
  257. package/dist/run-registry/queue.js +0 -115
  258. package/dist/run-registry.js +0 -850
  259. package/dist/run-state-schema.js +0 -68
  260. package/dist/scheduling.js +0 -184
  261. package/dist/state-explosion.js +0 -1014
  262. package/dist/state.js +0 -367
  263. package/dist/telemetry-ledger.js +0 -196
  264. package/dist/topology.js +0 -565
  265. package/dist/triggers.js +0 -184
  266. package/dist/trust-audit.js +0 -644
  267. package/dist/types/blackboard.js +0 -2
  268. package/dist/types/candidate.js +0 -2
  269. package/dist/types/collaboration.js +0 -2
  270. package/dist/types/core.js +0 -2
  271. package/dist/types/drive.js +0 -10
  272. package/dist/types/error-feedback.js +0 -2
  273. package/dist/types/evidence-reasoning.js +0 -2
  274. package/dist/types/execution-backend.js +0 -2
  275. package/dist/types/multi-agent.js +0 -2
  276. package/dist/types/observability.js +0 -2
  277. package/dist/types/pipeline.js +0 -2
  278. package/dist/types/reclamation.js +0 -8
  279. package/dist/types/report-bundle.js +0 -6
  280. package/dist/types/result.js +0 -2
  281. package/dist/types/run-registry.js +0 -2
  282. package/dist/types/run.js +0 -2
  283. package/dist/types/sandbox.js +0 -2
  284. package/dist/types/schedule.js +0 -2
  285. package/dist/types/state-node.js +0 -2
  286. package/dist/types/topology.js +0 -2
  287. package/dist/types/trust.js +0 -2
  288. package/dist/types/workbench.js +0 -2
  289. package/dist/types/worker.js +0 -2
  290. package/dist/types/workflow-app.js +0 -2
  291. package/dist/types.js +0 -44
  292. package/dist/util/fingerprint.js +0 -19
  293. package/dist/util/fingerprint.test.js +0 -27
  294. package/dist/verifier.js +0 -78
  295. package/dist/version.js +0 -8
  296. package/dist/workbench-host.js +0 -182
  297. package/dist/workbench.js +0 -192
  298. package/dist/worker-accept/acceptance.js +0 -114
  299. package/dist/worker-accept/blackboard-fanout.js +0 -80
  300. package/dist/worker-accept/blackboard-linkage.js +0 -19
  301. package/dist/worker-accept/context.js +0 -2
  302. package/dist/worker-accept/telemetry-ledger.js +0 -126
  303. package/dist/worker-accept/validation.js +0 -77
  304. package/dist/worker-accept/verifier-completion.js +0 -73
  305. package/dist/worker-isolation/helpers.js +0 -51
  306. package/dist/worker-isolation/paths.js +0 -46
  307. package/dist/worker-isolation.js +0 -656
  308. package/dist/workflow-api.js +0 -131
  309. /package/dist/{types → core/types}/boundary.js +0 -0
@@ -0,0 +1,473 @@
1
+ "use strict";
2
+ // shell/eval-io.ts — createMultiAgentReplaySnapshot/replayMultiAgentSnapshot/
3
+ // compareMultiAgentReplay/scoreMultiAgentReplay/gateMultiAgentEval/
4
+ // reportMultiAgentEval: the impure disk-orchestrated wrapper around
5
+ // core/multi-agent/eval-replay.ts's pure 31-metric compare/score/gate/
6
+ // report + normalizeRun projection.
7
+ //
8
+ // MILESTONE 9. Byte-exact port of the impure half of the old build's
9
+ // src/multi-agent-eval.ts: snapshot/suite/comparison/score/gate/report
10
+ // file writes, target-path resolution, and — the load-bearing piece —
11
+ // replayMultiAgentSnapshot RE-DERIVING the projection from the raw
12
+ // baseline run state file rather than copying snapshot.normalized.
13
+ //
14
+ // BYTE-COMPAT / REBUILD RISK 5 [load-bearing]: see
15
+ // eval-replay-detects-drift.case.js.
16
+ //
17
+ // Evidence: SPEC/multi-agent.md section I, "Eval harness exact outputs";
18
+ // plugins/cool-workflow/src/multi-agent-eval.ts (byte-exact source for
19
+ // the wiring/resolution sequence).
20
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
21
+ if (k2 === undefined) k2 = k;
22
+ var desc = Object.getOwnPropertyDescriptor(m, k);
23
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24
+ desc = { enumerable: true, get: function() { return m[k]; } };
25
+ }
26
+ Object.defineProperty(o, k2, desc);
27
+ }) : (function(o, m, k, k2) {
28
+ if (k2 === undefined) k2 = k;
29
+ o[k2] = m[k];
30
+ }));
31
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
32
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
33
+ }) : function(o, v) {
34
+ o["default"] = v;
35
+ });
36
+ var __importStar = (this && this.__importStar) || (function () {
37
+ var ownKeys = function(o) {
38
+ ownKeys = Object.getOwnPropertyNames || function (o) {
39
+ var ar = [];
40
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
41
+ return ar;
42
+ };
43
+ return ownKeys(o);
44
+ };
45
+ return function (mod) {
46
+ if (mod && mod.__esModule) return mod;
47
+ var result = {};
48
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
49
+ __setModuleDefault(result, mod);
50
+ return result;
51
+ };
52
+ })();
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.createMultiAgentReplaySnapshot = createMultiAgentReplaySnapshot;
55
+ exports.replayMultiAgentSnapshot = replayMultiAgentSnapshot;
56
+ exports.compareMultiAgentReplay = compareMultiAgentReplay;
57
+ exports.scoreMultiAgentReplay = scoreMultiAgentReplay;
58
+ exports.gateMultiAgentEval = gateMultiAgentEval;
59
+ exports.reportMultiAgentEval = reportMultiAgentEval;
60
+ const fs = __importStar(require("node:fs"));
61
+ const path = __importStar(require("node:path"));
62
+ const fs_atomic_1 = require("./fs-atomic");
63
+ const run_store_1 = require("./run-store");
64
+ const ev = __importStar(require("../core/multi-agent/eval-replay"));
65
+ const trust_policy_io_1 = require("./trust-policy-io");
66
+ const topology_io_1 = require("./topology-io");
67
+ const multi_agent_io_1 = require("./multi-agent-io");
68
+ const evidence_reasoning_1 = require("./evidence-reasoning");
69
+ const state_explosion_cli_1 = require("./state-explosion-cli");
70
+ const multi_agent_operator_ux_1 = require("./multi-agent-operator-ux");
71
+ function now() {
72
+ return new Date().toISOString();
73
+ }
74
+ function evalSuiteDir(cwd, suiteId) {
75
+ return path.join(cwd, ".cw", "evals", (0, fs_atomic_1.safeFileName)(suiteId));
76
+ }
77
+ function resolveTargetPath(target) {
78
+ if (!target)
79
+ throw new Error("Missing eval target");
80
+ return path.isAbsolute(target) ? target : path.resolve(target);
81
+ }
82
+ function resolveSnapshotPath(target) {
83
+ const resolved = resolveTargetPath(target);
84
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory())
85
+ return path.join(resolved, "snapshot.json");
86
+ if (fs.existsSync(resolved))
87
+ return resolved;
88
+ return path.join(process.cwd(), ".cw", "evals", (0, fs_atomic_1.safeFileName)(target), "snapshot.json");
89
+ }
90
+ function resolveReplayPath(target) {
91
+ const resolved = resolveTargetPath(target);
92
+ if (fs.existsSync(resolved) && fs.statSync(resolved).isDirectory())
93
+ return path.join(resolved, "replay-run.json");
94
+ if (fs.existsSync(resolved))
95
+ return resolved;
96
+ return path.join(process.cwd(), ".cw", "evals", (0, fs_atomic_1.safeFileName)(target), "replay-run.json");
97
+ }
98
+ function resolveSuiteDir(target) {
99
+ const resolved = resolveTargetPath(target);
100
+ if (fs.existsSync(resolved)) {
101
+ if (fs.statSync(resolved).isDirectory())
102
+ return resolved;
103
+ const value = (0, fs_atomic_1.readJson)(resolved);
104
+ if (value.paths?.suiteDir)
105
+ return value.paths.suiteDir;
106
+ return path.dirname(resolved);
107
+ }
108
+ return path.join(process.cwd(), ".cw", "evals", (0, fs_atomic_1.safeFileName)(target));
109
+ }
110
+ function writeSuite(suite) {
111
+ (0, fs_atomic_1.writeJson)(path.join(suite.paths.suiteDir, "suite.json"), suite);
112
+ }
113
+ function loadSuiteFromDir(suiteDir) {
114
+ const suitePath = path.join(suiteDir, "suite.json");
115
+ if (fs.existsSync(suitePath))
116
+ return (0, fs_atomic_1.readJson)(suitePath);
117
+ return { schemaVersion: 1, id: path.basename(suiteDir), title: `Multi-Agent Eval Suite ${path.basename(suiteDir)}`, createdAt: now(), cases: [], paths: { suiteDir, snapshotPath: path.join(suiteDir, "snapshot.json") } };
118
+ }
119
+ function reportSections(run) {
120
+ if (!fs.existsSync(run.paths.report))
121
+ return [];
122
+ const text = fs.readFileSync(run.paths.report, "utf8");
123
+ return text
124
+ .split("\n")
125
+ .filter((line) => /^#+\s+/.test(line))
126
+ .map((line) => line.replace(/^#+\s+/, "").trim())
127
+ .sort();
128
+ }
129
+ function collectCandidateScores(run) {
130
+ const scores = [];
131
+ const candidates = run.candidates || [];
132
+ for (const candidate of candidates) {
133
+ for (const scoreId of candidate.scores || []) {
134
+ const scorePath = path.join(run.paths.candidatesDir || path.join(run.paths.runDir, "candidates"), (0, fs_atomic_1.safeFileName)(candidate.id), "scores", `${(0, fs_atomic_1.safeFileName)(scoreId)}.json`);
135
+ if (fs.existsSync(scorePath)) {
136
+ const score = (0, fs_atomic_1.readJson)(scorePath);
137
+ scores.push({ candidateId: candidate.id, scoreId, criteria: score.criteria, total: score.total, maxTotal: score.maxTotal, normalized: score.normalized, verdict: score.verdict, evidenceCount: Array.isArray(score.evidence) ? score.evidence.length : 0, notes: score.notes });
138
+ }
139
+ else {
140
+ scores.push({ candidateId: candidate.id, scoreId, missing: true });
141
+ }
142
+ }
143
+ }
144
+ return scores;
145
+ }
146
+ /** Minimal, real (non-operator-ux) dependency/failure derivation over
147
+ * multi-agent + trust state: one row per membership that has not yet
148
+ * reported, one row per policy violation. See core/multi-agent/eval-
149
+ * replay.ts's file header for why this milestone's normalizeRun scope
150
+ * is reduced from the full operator-ux module. */
151
+ function dependencyRows(run) {
152
+ const multiAgent = run.multiAgent || {};
153
+ return (multiAgent.memberships || []).map((membership) => ({ from: `${run.id}:multi-agent:group:${membership.groupId}`, to: `${run.id}:multi-agent:membership:${membership.id}`, label: "depends-on", status: membership.status }));
154
+ }
155
+ function failureRows(run) {
156
+ const multiAgent = run.multiAgent || {};
157
+ const rows = [];
158
+ for (const membership of multiAgent.memberships || []) {
159
+ if (membership.status === "failed")
160
+ rows.push({ kind: "agent-membership", status: membership.status, owner: membership.id, reason: "failed membership" });
161
+ }
162
+ for (const fanin of multiAgent.fanins || []) {
163
+ for (const reason of fanin.blockedReasons || [])
164
+ rows.push({ kind: "fanin", status: "blocked", owner: fanin.id, reason });
165
+ }
166
+ // Plain single-agent pipeline path: a worker in a terminal non-verified
167
+ // status (failed/rejected) is a failure row too, so a mutated raw
168
+ // baseline state (see eval-replay-detects-drift.case.js) is visible
169
+ // in the re-derived normalized projection, not just in multi-agent
170
+ // state.
171
+ for (const worker of run.workers || []) {
172
+ if (worker.status === "failed" || worker.status === "rejected")
173
+ rows.push({ kind: "worker", status: worker.status, owner: worker.id, reason: `worker ${worker.id} ${worker.status}` });
174
+ }
175
+ return rows;
176
+ }
177
+ /** Evidence adoption rows: one per candidate-selection's evidence
178
+ * (multi-agent path) PLUS one per accepted result node's evidence (the
179
+ * plain single-agent pipeline path, where there is no candidate/
180
+ * selection layer at all — see the file header's scope note: this
181
+ * keeps the section non-trivial for a completed `-q`/`--drive` run,
182
+ * matching the SPEC's own evidence-adoption model of "adopted through
183
+ * acceptance" for every accepted result). */
184
+ function evidenceAdoptionRows(run) {
185
+ const selections = run.candidateSelections || [];
186
+ const rows = [];
187
+ for (const selection of selections) {
188
+ for (const item of selection.evidence || [])
189
+ rows.push({ ref: item.id, status: "adopted", adoptedBy: selection.candidateId });
190
+ }
191
+ for (const node of run.nodes || []) {
192
+ if (node.kind !== "result")
193
+ continue;
194
+ for (const item of node.evidence || [])
195
+ rows.push({ ref: item.id, status: "adopted", adoptedBy: node.id });
196
+ }
197
+ return rows;
198
+ }
199
+ function normalizeRun(run) {
200
+ const trust = (0, trust_policy_io_1.summarizeMultiAgentTrust)(run);
201
+ const blackboard = run.blackboard || {};
202
+ const topologies = (0, topology_io_1.summarizeTopologies)(run);
203
+ const multiAgentSummary = (0, multi_agent_io_1.summarizeMultiAgent)(run);
204
+ const multiAgent = run.multiAgent || {};
205
+ return {
206
+ workflow: ev.normalizeValue({ id: run.workflow.id, appId: run.workflow.app?.id, appVersion: run.workflow.app?.version, taskCount: run.tasks.length }),
207
+ topologyShape: ev.lines([
208
+ topologies.active.map((entry) => ({ topologyId: entry.topologyId, status: entry.status, roleCount: entry.roles.length, groupCount: entry.groups.length, fanoutCount: entry.fanouts.length, faninCount: entry.fanins.length })),
209
+ multiAgentSummary.groupsDetail,
210
+ ]),
211
+ roles: ev.lines(multiAgent.roles || []),
212
+ groups: ev.lines(multiAgent.groups || []),
213
+ memberships: ev.lines(multiAgent.memberships || []),
214
+ fanouts: ev.lines(multiAgent.fanouts || []),
215
+ fanins: ev.lines(multiAgent.fanins || []),
216
+ dependencyEdges: ev.lines(dependencyRows(run)),
217
+ failures: ev.lines(failureRows(run)),
218
+ blackboardRecords: ev.lines([blackboard.boards || [], blackboard.topics || [], blackboard.messages || [], blackboard.contexts || [], blackboard.artifacts || [], blackboard.snapshots || [], blackboard.decisions || []]),
219
+ messageProvenance: ev.lines(trust.messageProvenance || []),
220
+ rolePolicies: ev.lines(trust.rolePolicies || []),
221
+ permissionDecisions: ev.lines(trust.permissionDecisions || []),
222
+ blackboardWriteAudit: ev.lines(trust.blackboardWrites || []),
223
+ judgeRationales: ev.lines(trust.judgeRationales || []),
224
+ panelDecisions: ev.lines(trust.panelDecisions || []),
225
+ policyViolations: ev.lines(trust.policyViolations || []),
226
+ evidenceAdoption: ev.lines(evidenceAdoptionRows(run)),
227
+ candidateScores: ev.lines(collectCandidateScores(run)),
228
+ selectedCandidates: ev.lines((run.candidateSelections || []).map((entry) => ({ candidateId: entry.candidateId, scoreId: entry.scoreId, verifierNodeId: entry.verifierNodeId, reason: entry.reason, evidenceCount: entry.evidence.length }))),
229
+ verifierCommitGate: ev.lines((run.commits || []).map((entry) => ({ verifierGated: Boolean(entry.verifierGated), checkpoint: Boolean(entry.checkpoint), candidateId: entry.candidateId, selectionId: entry.selectionId, verifierNodeId: entry.verifierNodeId, evidenceCount: (entry.evidence || []).length }))),
230
+ reportSections: reportSections(run),
231
+ ...normalizeStateExplosionForEval(run),
232
+ ...(0, evidence_reasoning_1.normalizeEvidenceReasoningForEval)(run),
233
+ };
234
+ }
235
+ /** The v0.1.25/v0.1.26 state-explosion eval sections — a stabilized
236
+ * projection of the state-explosion report (summary freshness, compact
237
+ * graph shape, blackboard digest, critical path, evidence digest,
238
+ * expansion refs). Byte-behavior port of the old build's
239
+ * normalizeStateExplosionForEval. */
240
+ function normalizeStateExplosionForEval(run) {
241
+ const report = (0, state_explosion_cli_1.buildStateExplosionReport)(run, { operator: (0, multi_agent_operator_ux_1.operatorDigestInput)(run) });
242
+ const graph = report.compactGraph;
243
+ const runPrefix = `${run.id}:`;
244
+ const stripRunId = (id) => (id.startsWith(runPrefix) ? id.slice(runPrefix.length) : id);
245
+ return {
246
+ summaryFreshness: ev.lines([
247
+ { compactionRecommended: report.stateSize.compactionRecommended, total: report.stateSize.total, deterministic: graph.deterministic },
248
+ ]),
249
+ compactGraphShape: ev.lines([
250
+ {
251
+ view: graph.view,
252
+ fullNodeCount: graph.fullNodeCount,
253
+ fullEdgeCount: graph.fullEdgeCount,
254
+ compactNodeCount: graph.compactNodeCount,
255
+ compactEdgeCount: graph.compactEdgeCount,
256
+ collapsedNodeCount: graph.collapsedNodeCount,
257
+ syntheticNodes: graph.syntheticNodes.map((s) => ({ kind: s.id.split(":summary:")[1] || s.kind, collapsedNodeCount: s.collapsedNodeCount, collapsedEdgeCount: s.collapsedEdgeCount, dominantStatus: s.dominantStatus })),
258
+ },
259
+ ]),
260
+ blackboardDigest: ev.lines([
261
+ {
262
+ topics: report.blackboardDigest.topicRollups.length,
263
+ threads: report.blackboardDigest.threadSummaries.length,
264
+ unresolved: report.blackboardDigest.unresolvedQuestions.map((q) => q.id),
265
+ conflicts: report.blackboardDigest.conflicts.map((c) => c.id),
266
+ decisions: report.blackboardDigest.decisions.length,
267
+ artifacts: report.blackboardDigest.artifacts.length,
268
+ policyViolations: report.blackboardDigest.policyViolations.map((p) => p.id),
269
+ judgeRationale: report.blackboardDigest.judgeRationale.map((j) => j.id),
270
+ missingEvidence: report.blackboardDigest.missingEvidence.map((m) => m.label),
271
+ },
272
+ ]),
273
+ criticalPath: graph.criticalPath.map(stripRunId).sort(),
274
+ evidenceDigest: ev.lines([
275
+ { adopted: report.operatorDigest.evidenceDigest.adopted, missing: report.operatorDigest.evidenceDigest.missing, rejected: report.operatorDigest.evidenceDigest.rejected },
276
+ ]),
277
+ expansionRefs: report.hiddenSourceRecords.map((h) => `${h.kind}=${h.count}`).sort(),
278
+ };
279
+ }
280
+ function createMultiAgentReplaySnapshot(run, options = {}) {
281
+ const id = (0, fs_atomic_1.safeFileName)(String(options.id || options.snapshot || `${run.id}-snapshot`));
282
+ const suiteDir = evalSuiteDir(run.cwd, id);
283
+ const snapshotPath = path.join(suiteDir, "snapshot.json");
284
+ const snapshot = {
285
+ schemaVersion: 1,
286
+ kind: "multi-agent-replay-snapshot",
287
+ id,
288
+ createdAt: now(),
289
+ runId: run.id,
290
+ workflow: { id: run.workflow.id, appId: run.workflow.app?.id, appVersion: run.workflow.app?.version, title: run.workflow.title },
291
+ inputs: ev.normalizeValue(run.inputs),
292
+ paths: { suiteDir, snapshotPath, baselineStatePath: run.paths.state, reportPath: run.paths.report },
293
+ normalized: normalizeRun(run),
294
+ };
295
+ (0, fs_atomic_1.writeJson)(snapshotPath, snapshot);
296
+ writeSuite({ schemaVersion: 1, id, title: `Multi-Agent Eval Suite ${id}`, createdAt: snapshot.createdAt, cases: [{ id: `${id}-case`, snapshotId: id, baselinePath: snapshotPath, expectedVerdict: "pass" }], paths: { suiteDir, snapshotPath } });
297
+ return snapshot;
298
+ }
299
+ function assertSnapshotShape(snapshot, file) {
300
+ if (!snapshot.id)
301
+ throw new Error(`Replay snapshot missing id: ${file}`);
302
+ if (!snapshot.runId)
303
+ throw new Error(`Replay snapshot missing runId: ${file}`);
304
+ if (!snapshot.paths || !snapshot.paths.suiteDir || !snapshot.paths.snapshotPath)
305
+ throw new Error(`Replay snapshot missing paths.suiteDir or paths.snapshotPath: ${file}`);
306
+ ev.assertNormalizedShape(snapshot.normalized, `Replay snapshot missing normalized section: ${file}`);
307
+ }
308
+ function assertReplayShape(replay, file) {
309
+ if (!replay.id)
310
+ throw new Error(`Replay run missing id: ${file}`);
311
+ if (!replay.snapshotId)
312
+ throw new Error(`Replay run missing snapshotId: ${file}`);
313
+ if (replay.status !== "completed" && replay.status !== "failed")
314
+ throw new Error(`Replay run has unsupported status ${String(replay.status)}: ${file}`);
315
+ if (!replay.paths || !replay.paths.suiteDir || !replay.paths.replayRunPath || !replay.paths.snapshotPath)
316
+ throw new Error(`Replay run missing paths.suiteDir, paths.replayRunPath, or paths.snapshotPath: ${file}`);
317
+ if (!Array.isArray(replay.errors))
318
+ throw new Error(`Replay run errors must be an array: ${file}`);
319
+ ev.assertNormalizedShape(replay.replay, `Replay run missing replay section: ${file}`);
320
+ }
321
+ function loadSnapshot(target) {
322
+ const resolved = resolveSnapshotPath(target);
323
+ if (!fs.existsSync(resolved))
324
+ throw new Error(`File not found: ${resolved}`);
325
+ const snapshot = (0, fs_atomic_1.readJson)(resolved);
326
+ if (snapshot.kind !== "multi-agent-replay-snapshot")
327
+ throw new Error(`Not a replay snapshot: ${resolved}`);
328
+ assertSnapshotShape(snapshot, resolved);
329
+ return snapshot;
330
+ }
331
+ /** RE-DERIVE the normalized projection from the raw captured state file
332
+ * instead of copying snapshot.normalized. Fail-closed: throws when the
333
+ * baseline state cannot be reconstructed. See file header, byte-compat
334
+ * / rebuild risk 5. */
335
+ function rederiveNormalizedFromSnapshot(snapshot) {
336
+ const statePath = snapshot.paths.baselineStatePath;
337
+ if (!statePath || !fs.existsSync(statePath)) {
338
+ throw new Error(`Cannot re-derive replay projection: baseline run state missing at ${statePath || "<unset>"}; re-snapshot from a live run before replaying.`);
339
+ }
340
+ const result = (0, run_store_1.loadRunStateFile)(statePath, { dryRun: true });
341
+ if (result.report.status === "unsupported") {
342
+ throw new Error(`Cannot re-derive replay projection: baseline run state at ${statePath} is unsupported: ${result.report.errors.join("; ")}`);
343
+ }
344
+ return normalizeRun(result.run);
345
+ }
346
+ function replayMultiAgentSnapshot(target, options = {}) {
347
+ if (!target)
348
+ throw new Error("Missing snapshot id or path.");
349
+ const snapshot = loadSnapshot(target);
350
+ const replayId = (0, fs_atomic_1.safeFileName)(String(options.id || options.replay || `${snapshot.id}-replay`));
351
+ const suiteDir = snapshot.paths.suiteDir;
352
+ const replayDir = path.join(suiteDir, "replay");
353
+ const replayRunPath = path.join(suiteDir, "replay-run.json");
354
+ fs.mkdirSync(replayDir, { recursive: true });
355
+ const replayed = rederiveNormalizedFromSnapshot(snapshot);
356
+ const replay = {
357
+ schemaVersion: 1,
358
+ kind: "multi-agent-replay-run",
359
+ id: replayId,
360
+ snapshotId: snapshot.id,
361
+ baselineRunId: snapshot.runId,
362
+ replayedAt: now(),
363
+ status: "completed",
364
+ isolatedWorkspace: replayDir,
365
+ paths: { suiteDir, replayDir, replayRunPath, snapshotPath: snapshot.paths.snapshotPath },
366
+ replay: replayed,
367
+ errors: [],
368
+ };
369
+ (0, fs_atomic_1.writeJson)(replayRunPath, replay);
370
+ const suite = loadSuiteFromDir(suiteDir);
371
+ suite.paths.replayRunPath = replayRunPath;
372
+ suite.cases = suite.cases.map((entry) => (entry.snapshotId === snapshot.id ? { ...entry, replayRunId: replayId, replayPath: replayRunPath } : entry));
373
+ writeSuite(suite);
374
+ return replay;
375
+ }
376
+ function loadReplay(target) {
377
+ const resolved = resolveReplayPath(target);
378
+ if (!fs.existsSync(resolved))
379
+ throw new Error(`File not found: ${resolved}`);
380
+ const replay = (0, fs_atomic_1.readJson)(resolved);
381
+ if (replay.kind !== "multi-agent-replay-run")
382
+ throw new Error(`Not a replay run: ${resolved}`);
383
+ assertReplayShape(replay, resolved);
384
+ return replay;
385
+ }
386
+ function loadBaselineNormalized(target) {
387
+ const snapshotPath = resolveSnapshotPath(target);
388
+ if (!fs.existsSync(snapshotPath))
389
+ throw new Error(`File not found: ${snapshotPath}`);
390
+ const snapshot = (0, fs_atomic_1.readJson)(snapshotPath);
391
+ if (snapshot.kind !== "multi-agent-replay-snapshot")
392
+ throw new Error(`Not a replay snapshot: ${snapshotPath}`);
393
+ assertSnapshotShape(snapshot, snapshotPath);
394
+ return { id: snapshot.id, path: snapshotPath, normalized: snapshot.normalized };
395
+ }
396
+ function compareMultiAgentReplay(baselineTarget, replayTarget) {
397
+ if (!baselineTarget)
398
+ throw new Error("Missing baseline id or path.");
399
+ const baseline = loadBaselineNormalized(baselineTarget);
400
+ const replay = loadReplay(replayTarget);
401
+ const suiteDir = replay.paths.suiteDir;
402
+ const comparisonPath = path.join(suiteDir, "comparison.json");
403
+ const findingsPath = path.join(suiteDir, "findings.json");
404
+ const comparison = ev.compareNormalized(baseline.id, baseline.path, baseline.normalized, replay, now(), comparisonPath, findingsPath, suiteDir);
405
+ (0, fs_atomic_1.writeJson)(comparisonPath, comparison);
406
+ (0, fs_atomic_1.writeJson)(findingsPath, comparison.findings);
407
+ const suite = loadSuiteFromDir(suiteDir);
408
+ suite.paths.comparisonPath = comparisonPath;
409
+ suite.paths.findingsPath = findingsPath;
410
+ writeSuite(suite);
411
+ return comparison;
412
+ }
413
+ function loadOrCompareForTarget(target) {
414
+ const suiteDir = resolveSuiteDir(target);
415
+ const comparisonPath = path.join(suiteDir, "comparison.json");
416
+ const replayPath = resolveReplayPath(target);
417
+ if (fs.existsSync(comparisonPath)) {
418
+ const comparison = (0, fs_atomic_1.readJson)(comparisonPath);
419
+ if (comparison.paths.replayPath === replayPath)
420
+ return comparison;
421
+ }
422
+ return compareMultiAgentReplay(path.join(suiteDir, "snapshot.json"), replayPath);
423
+ }
424
+ function scoreMultiAgentReplay(target) {
425
+ const comparison = loadOrCompareForTarget(target);
426
+ const scorePath = path.join(comparison.paths.suiteDir, "score.json");
427
+ const score = ev.scoreComparison(comparison, now(), scorePath);
428
+ (0, fs_atomic_1.writeJson)(scorePath, score);
429
+ const suite = loadSuiteFromDir(comparison.paths.suiteDir);
430
+ suite.paths.scorePath = scorePath;
431
+ writeSuite(suite);
432
+ return score;
433
+ }
434
+ function loadScoreForTarget(target, scorePath) {
435
+ const replayPath = resolveReplayPath(target);
436
+ if (fs.existsSync(scorePath)) {
437
+ const score = (0, fs_atomic_1.readJson)(scorePath);
438
+ if (fs.existsSync(score.paths.comparisonPath)) {
439
+ const comparison = (0, fs_atomic_1.readJson)(score.paths.comparisonPath);
440
+ if (comparison.replayId === score.replayId && comparison.paths.replayPath === replayPath)
441
+ return score;
442
+ }
443
+ }
444
+ return scoreMultiAgentReplay(target);
445
+ }
446
+ function gateMultiAgentEval(target) {
447
+ const suiteDir = resolveSuiteDir(target);
448
+ const snapshotPath = path.join(suiteDir, "snapshot.json");
449
+ const replayRunPath = path.join(suiteDir, "replay-run.json");
450
+ const comparisonPath = path.join(suiteDir, "comparison.json");
451
+ const scorePath = path.join(suiteDir, "score.json");
452
+ const missing = [snapshotPath, replayRunPath, comparisonPath, scorePath].filter((file) => !fs.existsSync(file));
453
+ if (missing.length)
454
+ throw new Error(`Eval gate missing required artifact(s): ${missing.join(", ")}`);
455
+ const comparison = (0, fs_atomic_1.readJson)(comparisonPath);
456
+ const score = (0, fs_atomic_1.readJson)(scorePath);
457
+ const report = reportMultiAgentEval(comparison.paths.replayPath);
458
+ const gate = ev.buildGate(suiteDir, snapshotPath, replayRunPath, comparisonPath, scorePath, report.reportPath, comparison, score, now(), path.basename(suiteDir));
459
+ (0, fs_atomic_1.writeJson)(path.join(suiteDir, "gate.json"), gate);
460
+ return gate;
461
+ }
462
+ function reportMultiAgentEval(target) {
463
+ const suiteDir = resolveSuiteDir(target);
464
+ const scorePath = path.join(suiteDir, "score.json");
465
+ const score = loadScoreForTarget(target, scorePath);
466
+ const reportPath = path.join(suiteDir, "report.md");
467
+ const lines = ev.buildReportLines(path.basename(suiteDir), score);
468
+ fs.writeFileSync(reportPath, `${lines.join("\n")}\n`, "utf8");
469
+ const suite = loadSuiteFromDir(suiteDir);
470
+ suite.paths.reportPath = reportPath;
471
+ writeSuite(suite);
472
+ return { schemaVersion: 1, replayId: score.replayId, status: score.status, reportPath, score: score.score, maxScore: score.maxScore, findings: score.findings };
473
+ }
@@ -1,20 +1,74 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ // shell/eval-text.ts human render for the multi-agent eval/replay layer
3
+ // (`cw eval snapshot|replay|compare|score|gate|report` text output).
4
+ //
5
+ // Byte-behavior port of the old build's src/multi-agent-eval/format.ts's
6
+ // formatMultiAgentEval + its runtime-discriminating type guards. CLI-only —
7
+ // never affects --json / MCP payloads. Types are imported type-only from the
8
+ // v2 core eval-replay module.
9
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ var desc = Object.getOwnPropertyDescriptor(m, k);
12
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
13
+ desc = { enumerable: true, get: function() { return m[k]; } };
14
+ }
15
+ Object.defineProperty(o, k2, desc);
16
+ }) : (function(o, m, k, k2) {
17
+ if (k2 === undefined) k2 = k;
18
+ o[k2] = m[k];
19
+ }));
20
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
21
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
22
+ }) : function(o, v) {
23
+ o["default"] = v;
24
+ });
25
+ var __importStar = (this && this.__importStar) || (function () {
26
+ var ownKeys = function(o) {
27
+ ownKeys = Object.getOwnPropertyNames || function (o) {
28
+ var ar = [];
29
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
30
+ return ar;
31
+ };
32
+ return ownKeys(o);
33
+ };
34
+ return function (mod) {
35
+ if (mod && mod.__esModule) return mod;
36
+ var result = {};
37
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
38
+ __setModuleDefault(result, mod);
39
+ return result;
40
+ };
41
+ })();
5
42
  Object.defineProperty(exports, "__esModule", { value: true });
6
43
  exports.formatMultiAgentEval = formatMultiAgentEval;
7
- // Human formatting for the multi-agent eval replay layer (CLI-only; never affects
8
- // --json / MCP payloads). Pure functions — a result object in, a string out —
9
- // carved out of multi-agent-eval.ts (FreeBSD-audit god-module split) so the eval
10
- // router no longer bundles the rendering layer. The runtime-discriminating type
11
- // guards travel with the renderer that is their only consumer. Re-exported from
12
- // multi-agent-eval.ts to keep the public surface byte-unchanged.
13
- //
14
- // Types are imported type-only from the parent module: `import type` is fully
15
- // erased at runtime, so there is no import cycle despite the parent re-exporting
16
- // formatMultiAgentEval from here.
17
- const node_path_1 = __importDefault(require("node:path"));
44
+ const path = __importStar(require("node:path"));
45
+ function metricStatus(score, id) {
46
+ const metric = score.metrics.find((entry) => entry.id === id);
47
+ return `${id}=${metric?.status || "missing"}`;
48
+ }
49
+ function sectionStatus(comparison, id) {
50
+ return `${id}=${comparison.sections[id]?.status || "missing"}`;
51
+ }
52
+ function isSnapshot(value) {
53
+ return Boolean(value && typeof value === "object" && value.kind === "multi-agent-replay-snapshot");
54
+ }
55
+ function isReplay(value) {
56
+ return Boolean(value && typeof value === "object" && value.kind === "multi-agent-replay-run");
57
+ }
58
+ function isComparison(value) {
59
+ return Boolean(value && typeof value === "object" && "sections" in value && "findings" in value);
60
+ }
61
+ function isScore(value) {
62
+ return Boolean(value && typeof value === "object" && "metrics" in value && "score" in value);
63
+ }
64
+ function isGate(value) {
65
+ return Boolean(value && typeof value === "object" && "verdict" in value && "requiredArtifacts" in value);
66
+ }
67
+ function isReport(value) {
68
+ return Boolean(value && typeof value === "object" && "reportPath" in value && !("verdict" in value));
69
+ }
70
+ /** Human render for any eval-replay result object. Falls back to pretty JSON
71
+ * for an unrecognized shape (matches the old build's default arm). */
18
72
  function formatMultiAgentEval(value) {
19
73
  if (isGate(value)) {
20
74
  return [
@@ -31,13 +85,13 @@ function formatMultiAgentEval(value) {
31
85
  ` ${value.verdict}`,
32
86
  "",
33
87
  "Next Action",
34
- ` ${value.nextAction}`
88
+ ` ${value.nextAction}`,
35
89
  ].join("\n");
36
90
  }
37
91
  if (isScore(value)) {
38
92
  return [
39
93
  "Eval Suite",
40
- ` ${node_path_1.default.basename(value.paths.suiteDir)}`,
94
+ ` ${path.basename(value.paths.suiteDir)}`,
41
95
  "",
42
96
  "Replay Status",
43
97
  ` ${value.status} (${value.score}/${value.maxScore})`,
@@ -67,13 +121,13 @@ function formatMultiAgentEval(value) {
67
121
  ` ${value.status}`,
68
122
  "",
69
123
  "Next Action",
70
- ` ${value.status === "pass" ? "Run eval gate or include report path as evidence." : "Review findings before release."}`
124
+ ` ${value.status === "pass" ? "Run eval gate or include report path as evidence." : "Review findings before release."}`,
71
125
  ].join("\n");
72
126
  }
73
127
  if (isComparison(value)) {
74
128
  return [
75
129
  "Eval Suite",
76
- ` ${node_path_1.default.basename(value.paths.suiteDir)}`,
130
+ ` ${path.basename(value.paths.suiteDir)}`,
77
131
  "",
78
132
  "Replay Status",
79
133
  ` ${value.status}`,
@@ -100,20 +154,20 @@ function formatMultiAgentEval(value) {
100
154
  ` ${value.status}`,
101
155
  "",
102
156
  "Next Action",
103
- " Score the replay or run the eval gate."
157
+ " Score the replay or run the eval gate.",
104
158
  ].join("\n");
105
159
  }
106
160
  if (isReplay(value)) {
107
161
  return [
108
162
  "Eval Suite",
109
- ` ${node_path_1.default.basename(value.paths.suiteDir)}`,
163
+ ` ${path.basename(value.paths.suiteDir)}`,
110
164
  "",
111
165
  "Replay Status",
112
166
  ` ${value.status}`,
113
167
  ` replay=${value.paths.replayRunPath}`,
114
168
  "",
115
169
  "Next Action",
116
- ` node scripts/cw.js eval compare ${value.paths.snapshotPath} ${value.paths.replayRunPath}`
170
+ ` node scripts/cw.js eval compare ${value.paths.snapshotPath} ${value.paths.replayRunPath}`,
117
171
  ].join("\n");
118
172
  }
119
173
  if (isSnapshot(value)) {
@@ -147,13 +201,13 @@ function formatMultiAgentEval(value) {
147
201
  " snapshot-ready",
148
202
  "",
149
203
  "Next Action",
150
- ` node scripts/cw.js eval replay ${value.paths.snapshotPath}`
204
+ ` node scripts/cw.js eval replay ${value.paths.snapshotPath}`,
151
205
  ].join("\n");
152
206
  }
153
207
  if (isReport(value)) {
154
208
  return [
155
209
  "Eval Suite",
156
- ` ${node_path_1.default.dirname(value.reportPath)}`,
210
+ ` ${path.dirname(value.reportPath)}`,
157
211
  "",
158
212
  "Replay Status",
159
213
  ` ${value.status} (${value.score}/${value.maxScore})`,
@@ -162,33 +216,8 @@ function formatMultiAgentEval(value) {
162
216
  ` report written: ${value.reportPath}`,
163
217
  "",
164
218
  "Next Action",
165
- " Run eval gate if this is release evidence."
219
+ " Run eval gate if this is release evidence.",
166
220
  ].join("\n");
167
221
  }
168
222
  return JSON.stringify(value, null, 2);
169
223
  }
170
- function metricStatus(score, id) {
171
- const metric = score.metrics.find((entry) => entry.id === id);
172
- return `${id}=${metric?.status || "missing"}`;
173
- }
174
- function sectionStatus(comparison, id) {
175
- return `${id}=${comparison.sections[id]?.status || "missing"}`;
176
- }
177
- function isSnapshot(value) {
178
- return Boolean(value && typeof value === "object" && value.kind === "multi-agent-replay-snapshot");
179
- }
180
- function isReplay(value) {
181
- return Boolean(value && typeof value === "object" && value.kind === "multi-agent-replay-run");
182
- }
183
- function isComparison(value) {
184
- return Boolean(value && typeof value === "object" && "sections" in value && "findings" in value);
185
- }
186
- function isScore(value) {
187
- return Boolean(value && typeof value === "object" && "metrics" in value && "score" in value);
188
- }
189
- function isGate(value) {
190
- return Boolean(value && typeof value === "object" && "verdict" in value && "requiredArtifacts" in value);
191
- }
192
- function isReport(value) {
193
- return Boolean(value && typeof value === "object" && "reportPath" in value && !("verdict" in value));
194
- }