cool-workflow 0.1.98 → 0.2.1

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 (315) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/.codex-plugin/plugin.json +1 -1
  3. package/README.md +18 -7
  4. package/apps/architecture-review/app.json +2 -2
  5. package/apps/architecture-review/workflow.js +12 -12
  6. package/apps/architecture-review-fast/app.json +1 -1
  7. package/apps/end-to-end-golden-path/app.json +1 -1
  8. package/apps/pr-review-fix-ci/app.json +1 -1
  9. package/apps/release-cut/app.json +1 -1
  10. package/apps/research-synthesis/app.json +1 -1
  11. package/dist/cli/dispatch.js +236 -0
  12. package/dist/cli/entry.js +120 -0
  13. package/dist/cli/io.js +21 -4
  14. package/dist/cli/parseargv.js +157 -0
  15. package/dist/cli.js +6 -33
  16. package/dist/core/capability-table.js +3518 -0
  17. package/dist/core/format/help.js +314 -0
  18. package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
  19. package/dist/core/hash.js +137 -0
  20. package/dist/core/multi-agent/candidate-scoring.js +219 -0
  21. package/dist/core/multi-agent/collaboration.js +481 -0
  22. package/dist/core/multi-agent/coordinator.js +515 -0
  23. package/dist/core/multi-agent/eval-replay.js +306 -0
  24. package/dist/core/multi-agent/runtime.js +929 -0
  25. package/dist/core/multi-agent/topology.js +298 -0
  26. package/dist/core/multi-agent/trust-policy.js +197 -0
  27. package/dist/core/pipeline/commit-gate.js +320 -0
  28. package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
  29. package/dist/core/pipeline/dispatch.js +103 -0
  30. package/dist/core/pipeline/drive-decide.js +227 -0
  31. package/dist/core/pipeline/error-feedback.js +161 -0
  32. package/dist/core/pipeline/loop-expansion.js +124 -0
  33. package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
  34. package/dist/core/pipeline/runner.js +230 -0
  35. package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
  36. package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
  37. package/dist/core/state/node-projection.js +95 -0
  38. package/dist/core/state/node-snapshot.js +230 -0
  39. package/dist/core/state/run-paths.js +93 -0
  40. package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
  41. package/dist/core/state/schema.js +50 -0
  42. package/dist/core/state/state-explosion/digest.js +243 -0
  43. package/dist/core/state/state-explosion/graph.js +527 -0
  44. package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
  45. package/dist/core/state/state-explosion/report.js +187 -0
  46. package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
  47. package/dist/{state-node.js → core/state/state-node.js} +90 -113
  48. package/dist/core/state/types.js +19 -0
  49. package/dist/{validation.js → core/state/validation.js} +64 -131
  50. package/dist/core/trust/evidence-grounding.js +134 -0
  51. package/dist/core/trust/ledger.js +199 -0
  52. package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
  53. package/dist/core/trust/telemetry-ledger.js +127 -0
  54. package/dist/core/types.js +20 -0
  55. package/dist/core/version.js +16 -0
  56. package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
  57. package/dist/mcp/dispatch.js +104 -0
  58. package/dist/mcp/server.js +144 -0
  59. package/dist/mcp-server.js +6 -84
  60. package/dist/{agent-config.js → shell/agent-config.js} +118 -71
  61. package/dist/shell/app-run-cli.js +88 -0
  62. package/dist/shell/audit-cli.js +259 -0
  63. package/dist/shell/audit-provenance.js +83 -0
  64. package/dist/shell/candidate-scoring-io.js +459 -0
  65. package/dist/shell/collaboration-io.js +264 -0
  66. package/dist/shell/commit-summary.js +104 -0
  67. package/dist/shell/commit.js +290 -0
  68. package/dist/shell/coordinator-io.js +476 -0
  69. package/dist/shell/demo-cli.js +19 -0
  70. package/dist/shell/dispatch.js +162 -0
  71. package/dist/shell/doctor.js +292 -0
  72. package/dist/shell/drive.js +885 -0
  73. package/dist/shell/error-feedback-io.js +305 -0
  74. package/dist/shell/eval-io.js +473 -0
  75. package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
  76. package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
  77. package/dist/shell/exec-backend-cli.js +88 -0
  78. package/dist/shell/execution-backend/agent.js +507 -0
  79. package/dist/shell/execution-backend/ci.js +15 -0
  80. package/dist/shell/execution-backend/container.js +69 -0
  81. package/dist/shell/execution-backend/envelopes.js +55 -0
  82. package/dist/shell/execution-backend/local.js +113 -0
  83. package/dist/shell/execution-backend/probes.js +175 -0
  84. package/dist/shell/execution-backend/registry.js +402 -0
  85. package/dist/shell/execution-backend/remote.js +128 -0
  86. package/dist/shell/execution-backend/types.js +11 -0
  87. package/dist/shell/feedback-cli.js +81 -0
  88. package/dist/shell/feedback-operations.js +48 -0
  89. package/dist/shell/fs-atomic.js +276 -0
  90. package/dist/shell/harness.js +98 -0
  91. package/dist/shell/ledger-cli.js +212 -0
  92. package/dist/shell/ledger-io.js +169 -0
  93. package/dist/shell/man-cli.js +89 -0
  94. package/dist/shell/metrics-cli.js +100 -0
  95. package/dist/shell/multi-agent-cli.js +1002 -0
  96. package/dist/shell/multi-agent-host.js +563 -0
  97. package/dist/shell/multi-agent-io.js +387 -0
  98. package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
  99. package/dist/shell/node-store.js +124 -0
  100. package/dist/{observability/format.js → shell/observability-format.js} +7 -1
  101. package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
  102. package/dist/{observability.js → shell/observability.js} +159 -332
  103. package/dist/{onramp.js → shell/onramp.js} +11 -0
  104. package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
  105. package/dist/shell/operator-ux.js +431 -0
  106. package/dist/shell/orchestrator.js +231 -0
  107. package/dist/shell/pipeline-cli.js +667 -0
  108. package/dist/shell/pipeline.js +217 -0
  109. package/dist/shell/reclamation-io.js +1366 -0
  110. package/dist/shell/registry-cli.js +344 -0
  111. package/dist/{remote-source.js → shell/remote-source.js} +2 -2
  112. package/dist/shell/report-cli.js +101 -0
  113. package/dist/shell/report-view-cli.js +117 -0
  114. package/dist/{orchestrator → shell}/report.js +289 -282
  115. package/dist/shell/reporter.js +62 -0
  116. package/dist/shell/run-export-cli.js +106 -0
  117. package/dist/shell/run-export.js +680 -0
  118. package/dist/shell/run-registry-io.js +1014 -0
  119. package/dist/shell/run-store.js +164 -0
  120. package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
  121. package/dist/{scheduler.js → shell/scheduler-io.js} +257 -48
  122. package/dist/shell/scheduling-io.js +321 -0
  123. package/dist/shell/state-cli.js +181 -0
  124. package/dist/shell/state-explosion-cli.js +197 -0
  125. package/dist/shell/telemetry-cli.js +85 -0
  126. package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
  127. package/dist/shell/telemetry-ledger-io.js +132 -0
  128. package/dist/{term.js → shell/term.js} +36 -46
  129. package/dist/shell/topology-io.js +361 -0
  130. package/dist/shell/trust-audit.js +472 -0
  131. package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
  132. package/dist/shell/verifier.js +48 -0
  133. package/dist/shell/workbench-host.js +258 -0
  134. package/dist/shell/workbench-text.js +18 -0
  135. package/dist/shell/workbench.js +170 -0
  136. package/dist/shell/worker-cli.js +124 -0
  137. package/dist/shell/worker-isolation.js +852 -0
  138. package/dist/shell/workflow-app-loader.js +650 -0
  139. package/docs/agent-delegation-drive.7.md +4 -0
  140. package/docs/cli-mcp-parity.7.md +282 -219
  141. package/docs/contract-migration-tooling.7.md +4 -0
  142. package/docs/control-plane-scheduling.7.md +4 -0
  143. package/docs/durable-state-and-locking.7.md +4 -0
  144. package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
  145. package/docs/execution-backends.7.md +4 -0
  146. package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
  147. package/docs/multi-agent-eval-replay-harness.7.md +4 -0
  148. package/docs/multi-agent-operator-ux.7.md +4 -0
  149. package/docs/node-snapshot-diff-replay.7.md +4 -0
  150. package/docs/observability-cost-accounting.7.md +6 -1
  151. package/docs/project-index.md +137 -71
  152. package/docs/real-execution-backends.7.md +4 -0
  153. package/docs/release-and-migration.7.md +4 -0
  154. package/docs/release-tooling.7.md +4 -0
  155. package/docs/remote-source-review.7.md +4 -4
  156. package/docs/report-verifiable-bundle.7.md +1 -1
  157. package/docs/run-registry-control-plane.7.md +4 -0
  158. package/docs/run-retention-reclamation.7.md +25 -0
  159. package/docs/security-trust-hardening.7.md +3 -1
  160. package/docs/state-explosion-management.7.md +4 -0
  161. package/docs/team-collaboration.7.md +4 -0
  162. package/docs/web-desktop-workbench.7.md +15 -1
  163. package/manifest/plugin.manifest.json +1 -1
  164. package/manifest/source-context-profiles.json +9 -13
  165. package/package.json +1 -1
  166. package/scripts/agents/agent-adapter-core.js +22 -2
  167. package/scripts/agents/claude-p-agent.js +8 -3
  168. package/scripts/agents/cw-attest-wrap.js +2 -2
  169. package/scripts/agents/gemini-agent.js +5 -1
  170. package/scripts/agents/opencode-agent.js +5 -1
  171. package/scripts/bump-version.js +4 -3
  172. package/scripts/canonical-apps.js +4 -4
  173. package/scripts/dogfood-architecture-review.js +2 -3
  174. package/scripts/dogfood-release.js +3 -3
  175. package/scripts/gen-parity-doc.js +15 -2
  176. package/scripts/golden-path.js +4 -4
  177. package/scripts/onramp-check.js +1 -1
  178. package/scripts/parity-check.js +38 -21
  179. package/scripts/release-flow.js +2 -2
  180. package/scripts/sync-project-index.js +51 -27
  181. package/scripts/validate-run-state-schema.js +2 -2
  182. package/scripts/version-sync-check.js +30 -30
  183. package/dist/candidate-scoring.js +0 -729
  184. package/dist/capability-core.js +0 -1189
  185. package/dist/capability-registry.js +0 -885
  186. package/dist/cli/command-surface.js +0 -494
  187. package/dist/cli/format.js +0 -56
  188. package/dist/cli/handlers/audit.js +0 -82
  189. package/dist/cli/handlers/blackboard.js +0 -81
  190. package/dist/cli/handlers/candidate.js +0 -40
  191. package/dist/cli/handlers/clones.js +0 -34
  192. package/dist/cli/handlers/collaboration.js +0 -61
  193. package/dist/cli/handlers/eval.js +0 -40
  194. package/dist/cli/handlers/ledger.js +0 -169
  195. package/dist/cli/handlers/maintenance.js +0 -107
  196. package/dist/cli/handlers/multi-agent.js +0 -165
  197. package/dist/cli/handlers/node.js +0 -41
  198. package/dist/cli/handlers/operational.js +0 -155
  199. package/dist/cli/handlers/operator.js +0 -146
  200. package/dist/cli/handlers/registry.js +0 -68
  201. package/dist/cli/handlers/run.js +0 -153
  202. package/dist/cli/handlers/scheduling.js +0 -132
  203. package/dist/cli/handlers/workbench.js +0 -41
  204. package/dist/cli/handlers/worker.js +0 -45
  205. package/dist/cli/run-summary.js +0 -45
  206. package/dist/clones.js +0 -162
  207. package/dist/collaboration.js +0 -726
  208. package/dist/commit.js +0 -592
  209. package/dist/compare.js +0 -18
  210. package/dist/coordinator/classify.js +0 -45
  211. package/dist/coordinator/paths.js +0 -42
  212. package/dist/coordinator/util.js +0 -126
  213. package/dist/coordinator.js +0 -990
  214. package/dist/daemon.js +0 -44
  215. package/dist/dispatch.js +0 -250
  216. package/dist/doctor.js +0 -212
  217. package/dist/drive.js +0 -864
  218. package/dist/error-feedback.js +0 -419
  219. package/dist/evidence-grounding.js +0 -184
  220. package/dist/execution-backend/agent.js +0 -354
  221. package/dist/execution-backend/probes.js +0 -112
  222. package/dist/execution-backend/util.js +0 -47
  223. package/dist/execution-backend.js +0 -961
  224. package/dist/gates.js +0 -48
  225. package/dist/harness.js +0 -61
  226. package/dist/ledger.js +0 -313
  227. package/dist/loop-expansion.js +0 -60
  228. package/dist/mcp/tool-call.js +0 -470
  229. package/dist/mcp/tool-definitions.js +0 -1066
  230. package/dist/mcp-surface.js +0 -30
  231. package/dist/multi-agent/graph.js +0 -84
  232. package/dist/multi-agent/helpers.js +0 -141
  233. package/dist/multi-agent/ids.js +0 -20
  234. package/dist/multi-agent/paths.js +0 -22
  235. package/dist/multi-agent-eval/normalize.js +0 -51
  236. package/dist/multi-agent-eval.js +0 -678
  237. package/dist/multi-agent-host.js +0 -777
  238. package/dist/multi-agent.js +0 -984
  239. package/dist/node-projection.js +0 -59
  240. package/dist/node-snapshot.js +0 -260
  241. package/dist/operator-ux.js +0 -631
  242. package/dist/orchestrator/app-operations.js +0 -211
  243. package/dist/orchestrator/audit-operations.js +0 -182
  244. package/dist/orchestrator/candidate-operations.js +0 -117
  245. package/dist/orchestrator/cli-options.js +0 -294
  246. package/dist/orchestrator/collaboration-operations.js +0 -86
  247. package/dist/orchestrator/feedback-operations.js +0 -81
  248. package/dist/orchestrator/host-operations.js +0 -78
  249. package/dist/orchestrator/lifecycle-operations.js +0 -650
  250. package/dist/orchestrator/migration-operations.js +0 -44
  251. package/dist/orchestrator/multi-agent-operations.js +0 -362
  252. package/dist/orchestrator/topology-operations.js +0 -84
  253. package/dist/orchestrator.js +0 -925
  254. package/dist/pipeline-runner.js +0 -285
  255. package/dist/reclamation/hash.js +0 -72
  256. package/dist/reclamation.js +0 -812
  257. package/dist/reporter.js +0 -67
  258. package/dist/run-export.js +0 -815
  259. package/dist/run-registry/derive.js +0 -175
  260. package/dist/run-registry/format.js +0 -124
  261. package/dist/run-registry/gc.js +0 -251
  262. package/dist/run-registry/policy.js +0 -16
  263. package/dist/run-registry/queue.js +0 -115
  264. package/dist/run-registry.js +0 -850
  265. package/dist/run-state-schema.js +0 -68
  266. package/dist/scheduling.js +0 -184
  267. package/dist/state-explosion.js +0 -1014
  268. package/dist/state.js +0 -367
  269. package/dist/telemetry-ledger.js +0 -196
  270. package/dist/topology.js +0 -565
  271. package/dist/triggers.js +0 -184
  272. package/dist/trust-audit.js +0 -644
  273. package/dist/types/blackboard.js +0 -2
  274. package/dist/types/candidate.js +0 -2
  275. package/dist/types/collaboration.js +0 -2
  276. package/dist/types/core.js +0 -2
  277. package/dist/types/drive.js +0 -10
  278. package/dist/types/error-feedback.js +0 -2
  279. package/dist/types/evidence-reasoning.js +0 -2
  280. package/dist/types/execution-backend.js +0 -2
  281. package/dist/types/multi-agent.js +0 -2
  282. package/dist/types/observability.js +0 -2
  283. package/dist/types/pipeline.js +0 -2
  284. package/dist/types/reclamation.js +0 -8
  285. package/dist/types/report-bundle.js +0 -6
  286. package/dist/types/result.js +0 -2
  287. package/dist/types/run-registry.js +0 -2
  288. package/dist/types/run.js +0 -2
  289. package/dist/types/sandbox.js +0 -2
  290. package/dist/types/schedule.js +0 -2
  291. package/dist/types/state-node.js +0 -2
  292. package/dist/types/topology.js +0 -2
  293. package/dist/types/trust.js +0 -2
  294. package/dist/types/workbench.js +0 -2
  295. package/dist/types/worker.js +0 -2
  296. package/dist/types/workflow-app.js +0 -2
  297. package/dist/types.js +0 -44
  298. package/dist/util/fingerprint.js +0 -19
  299. package/dist/util/fingerprint.test.js +0 -27
  300. package/dist/verifier.js +0 -78
  301. package/dist/version.js +0 -8
  302. package/dist/workbench-host.js +0 -192
  303. package/dist/workbench.js +0 -192
  304. package/dist/worker-accept/acceptance.js +0 -114
  305. package/dist/worker-accept/blackboard-fanout.js +0 -80
  306. package/dist/worker-accept/blackboard-linkage.js +0 -19
  307. package/dist/worker-accept/context.js +0 -2
  308. package/dist/worker-accept/telemetry-ledger.js +0 -126
  309. package/dist/worker-accept/validation.js +0 -77
  310. package/dist/worker-accept/verifier-completion.js +0 -73
  311. package/dist/worker-isolation/helpers.js +0 -51
  312. package/dist/worker-isolation/paths.js +0 -46
  313. package/dist/worker-isolation.js +0 -656
  314. package/dist/workflow-api.js +0 -131
  315. /package/dist/{types → core/types}/boundary.js +0 -0
@@ -1,925 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.KNOWN_COMMANDS = exports.CoolWorkflowRunner = void 0;
40
- exports.parseArgv = parseArgv;
41
- exports.suggestCommand = suggestCommand;
42
- exports.formatSearchResults = formatSearchResults;
43
- exports.formatInfo = formatInfo;
44
- exports.formatHelp = formatHelp;
45
- exports.formatCommandHelp = formatCommandHelp;
46
- const node_fs_1 = __importDefault(require("node:fs"));
47
- const node_path_1 = __importDefault(require("node:path"));
48
- const workflow_api_1 = require("./workflow-api");
49
- const capability_registry_1 = require("./capability-registry");
50
- const workflow_app_framework_1 = require("./workflow-app-framework");
51
- const dispatch_1 = require("./dispatch");
52
- const state_1 = require("./state");
53
- const observability_1 = require("./observability");
54
- const pipeline_runner_1 = require("./pipeline-runner");
55
- const worker_isolation_1 = require("./worker-isolation");
56
- const sandbox_profile_1 = require("./sandbox-profile");
57
- const execution_backend_1 = require("./execution-backend");
58
- const operator_ux_1 = require("./operator-ux");
59
- const trust_audit_1 = require("./trust-audit");
60
- const multi_agent_1 = require("./multi-agent");
61
- const multi_agent_operator_ux_1 = require("./multi-agent-operator-ux");
62
- const multi_agent_eval_1 = require("./multi-agent-eval");
63
- const node_snapshot_1 = require("./node-snapshot");
64
- const state_explosion_1 = require("./state-explosion");
65
- const evidence_reasoning_1 = require("./evidence-reasoning");
66
- const report_1 = require("./orchestrator/report");
67
- const cli_options_1 = require("./orchestrator/cli-options");
68
- const appOps = __importStar(require("./orchestrator/app-operations"));
69
- const auditOps = __importStar(require("./orchestrator/audit-operations"));
70
- const candidateOps = __importStar(require("./orchestrator/candidate-operations"));
71
- const collaborationOps = __importStar(require("./orchestrator/collaboration-operations"));
72
- const maOps = __importStar(require("./orchestrator/multi-agent-operations"));
73
- const hostOps = __importStar(require("./orchestrator/host-operations"));
74
- const feedbackOps = __importStar(require("./orchestrator/feedback-operations"));
75
- const topologyOps = __importStar(require("./orchestrator/topology-operations"));
76
- const lifecycleOps = __importStar(require("./orchestrator/lifecycle-operations"));
77
- const migrationOps = __importStar(require("./orchestrator/migration-operations"));
78
- const term_1 = require("./term");
79
- // CoolWorkflowRunner — the single FACADE both surfaces (cli.ts and the MCP server)
80
- // call through. It is deliberately WIDE but THIN: each method either
81
- // (a) loads the run's durable state and delegates to a domain function in
82
- // ./orchestrator/*-operations.ts — the v0.1.40 self-audit "router pattern":
83
- // one thin delegator per capability, NOT a god-object to dismantle; or
84
- // (b) holds a small amount of surface-shared logic (app/worker loaders, report
85
- // composition, read-snapshot-then-op).
86
- // The high method count is INTENTIONAL — it is the union of every both-surface
87
- // capability — and the fail-closed CLI<->MCP parity gate keeps each one honest (a
88
- // method present on one surface but not the other is exactly the drift it forbids).
89
- //
90
- // FreeBSD-audit R3 ("142-method god-facade with no-op passthroughs") was assessed
91
- // and CLOSED as won't-fix: of 141 public methods exactly ONE is a true
92
- // runner->runner forward (collaborationReject -> collaborationApprove(...,"reject")),
93
- // and it is kept on purpose — it is a registered capability `entry` bound to the
94
- // parity gate AND an intent-revealing veto verb, so collapsing it would be a
95
- // behavior-neutral readability LOSS touching both surfaces. Dismantling the facade
96
- // is an explicit anti-goal (small kernel, explicit delegation — see DIRECTION.md).
97
- class CoolWorkflowRunner {
98
- pluginRoot;
99
- workflowsDir;
100
- appsDir;
101
- // F7: the directory a run is resolved against (replaces the former process.chdir
102
- // bracket in capability-core). undefined => fall back to process.cwd(). The runner
103
- // reads runs from disk per call (no in-memory run state), so withBaseDir hands back
104
- // a cheap scoped clone instead of mutating the global process cwd.
105
- baseDir;
106
- // Per-request cache (v0.1.95): when set, loadRun memoizes by runId so the 17
107
- // workbench sub-panels that each call loadRun independently share one read.
108
- _requestCache;
109
- constructor({ pluginRoot, baseDir }) {
110
- this.pluginRoot = resolvePluginRoot(pluginRoot);
111
- this.workflowsDir = node_path_1.default.join(this.pluginRoot, "workflows");
112
- this.appsDir = node_path_1.default.join(this.pluginRoot, "apps");
113
- this.baseDir = baseDir ? node_path_1.default.resolve(baseDir) : undefined;
114
- }
115
- /** Run fn with a per-request loadRun cache. All loadRun calls inside fn share
116
- * the same cached run state, collapsing 18 reads into 1. Returns fn's result
117
- * and clears the cache afterwards (never leaks between requests).
118
- *
119
- * Reentrant: a nested call (e.g. a concurrent drive round whose sub-workflow
120
- * task recursively drives a child run on the SAME runner instance) saves and
121
- * restores the OUTER scope's cache rather than clobbering it to undefined —
122
- * otherwise the inner call's `finally` would wipe the outer round's still-in-
123
- * flight (not yet persisted) mutations, and the outer scope's next loadRun
124
- * would silently fall back to a stale disk read. */
125
- loadWithCache(fn) {
126
- const previousCache = this._requestCache;
127
- this._requestCache = new Map();
128
- (0, trust_audit_1.setAuditEventCache)(new Map());
129
- try {
130
- return fn(this);
131
- }
132
- finally {
133
- this._requestCache = previousCache;
134
- (0, trust_audit_1.clearAuditEventCache)();
135
- }
136
- }
137
- /** Return a runner that resolves runs against `dir` instead of process.cwd(),
138
- * WITHOUT chdir-ing the process (F7). Same instance when the dir is unchanged. */
139
- withBaseDir(dir) {
140
- const resolved = dir ? node_path_1.default.resolve(dir) : undefined;
141
- if (resolved === this.baseDir)
142
- return this;
143
- return new CoolWorkflowRunner({ pluginRoot: this.pluginRoot, baseDir: resolved });
144
- }
145
- listWorkflows() {
146
- return appOps.listWorkflows(this.workflowsDir, this.appsDir);
147
- }
148
- listApps() {
149
- return appOps.listApps(this.workflowsDir, this.appsDir);
150
- }
151
- showApp(appId) {
152
- return appOps.showApp(this.workflowsDir, this.appsDir, appId);
153
- }
154
- validateApp(target) {
155
- return appOps.validateApp(this.workflowsDir, this.appsDir, target, this.resolveFromBase(target));
156
- }
157
- initApp(appId, options) {
158
- return appOps.initApp(this.appsDir, appId, options, (t) => this.resolveFromBase(t), (m) => this.validateApp(m));
159
- }
160
- packageApp(appId, options = {}) {
161
- return appOps.packageApp(this.workflowsDir, this.appsDir, appId, options, (t) => this.resolveFromBase(t));
162
- }
163
- init(workflowId, options) {
164
- const id = (0, workflow_api_1.slugify)(workflowId);
165
- if (!id)
166
- throw new Error("Workflow id must include at least one letter or digit");
167
- const title = String(options.title || titleize(id));
168
- const destination = this.resolveFromBase(String(options.output || node_path_1.default.join(this.workflowsDir, `${id}.workflow.js`)));
169
- if (node_fs_1.default.existsSync(destination) && !options.force) {
170
- throw new Error(`Refusing to overwrite existing workflow: ${destination}`);
171
- }
172
- node_fs_1.default.mkdirSync(node_path_1.default.dirname(destination), { recursive: true });
173
- node_fs_1.default.writeFileSync(destination, (0, workflow_app_framework_1.renderWorkflowAppTemplate)(id, title), "utf8");
174
- return { id, path: destination };
175
- }
176
- // Core run lifecycle — delegated to ./orchestrator/lifecycle-operations. The
177
- // runner resolves the workflow app record (instance-stateful) then hands the
178
- // engine work to the module; the runner is now a pure router.
179
- plan(workflowId, options) {
180
- return lifecycleOps.plan(this.loadWorkflowAppById(workflowId), options);
181
- }
182
- status(runId) {
183
- return (0, report_1.summarizeRun)(this.loadRun(runId));
184
- }
185
- operatorStatus(runId) {
186
- return (0, operator_ux_1.summarizeOperatorRun)(this.loadRun(runId));
187
- }
188
- next(runId, options) {
189
- return (0, dispatch_1.nextDispatchTasks)(this.loadRun(runId), (0, cli_options_1.numberOption)(options.limit));
190
- }
191
- dispatch(runId, options) {
192
- return lifecycleOps.dispatch(this.loadRun(runId), options);
193
- }
194
- recordResult(runId, taskId, resultPath, options = {}) {
195
- return lifecycleOps.recordResult(this.loadRun(runId), taskId, this.resolveFromBase(resultPath), options);
196
- }
197
- listWorkers(runId, options = {}) {
198
- return (0, worker_isolation_1.listWorkerScopes)(this.loadRun(runId), {
199
- status: options.status ? String(options.status) : undefined
200
- });
201
- }
202
- showWorker(runId, workerId) {
203
- const worker = (0, worker_isolation_1.getWorkerScope)(this.loadRun(runId), workerId);
204
- if (!worker)
205
- throw new Error(`Unknown worker id for run ${runId}: ${workerId}`);
206
- return worker;
207
- }
208
- reclaimOrphans(runId, now) {
209
- return (0, worker_isolation_1.reclaimOrphans)(this.loadRun(runId), now);
210
- }
211
- showWorkerManifest(runId, workerId) {
212
- const run = this.loadRun(runId);
213
- const worker = (0, worker_isolation_1.getWorkerScope)(run, workerId);
214
- if (!worker)
215
- throw new Error(`Unknown worker id for run ${runId}: ${workerId}`);
216
- return (0, worker_isolation_1.writeWorkerManifest)(run, worker);
217
- }
218
- recordWorkerOutput(runId, workerId, resultPath, options = {}) {
219
- return lifecycleOps.recordWorkerOutput(this.loadRun(runId), workerId, this.resolveFromBase(resultPath), options);
220
- }
221
- recordWorkerFailure(runId, workerId, message, options = {}) {
222
- return lifecycleOps.recordWorkerFailure(this.loadRun(runId), workerId, message, options);
223
- }
224
- validateWorker(runId, workerId, targetPath) {
225
- return (0, worker_isolation_1.validateWorkerBoundary)(this.loadRun(runId), workerId, targetPath ? { path: this.resolveFromBase(targetPath) } : {});
226
- }
227
- // Audit domain — delegated to ./orchestrator/audit-operations (v0.1.40 P3
228
- // router pattern). The runner stays the routing surface; the logic lives in the
229
- // domain module. Public signatures are unchanged.
230
- auditSummary(runId) {
231
- return auditOps.auditSummary(this.loadRun(runId));
232
- }
233
- auditMultiAgent(runId) {
234
- return auditOps.auditMultiAgent(this.loadRun(runId));
235
- }
236
- auditPolicy(runId) {
237
- return auditOps.auditPolicy(this.loadRun(runId));
238
- }
239
- auditRole(runId, roleId) {
240
- return auditOps.auditRole(this.loadRun(runId), roleId);
241
- }
242
- auditBlackboard(runId) {
243
- return auditOps.auditBlackboard(this.loadRun(runId));
244
- }
245
- auditJudge(runId) {
246
- return auditOps.auditJudge(this.loadRun(runId));
247
- }
248
- workerAudit(runId, workerId) {
249
- return auditOps.workerAudit(this.loadRun(runId), workerId);
250
- }
251
- evidenceProvenance(runId, options = {}) {
252
- return auditOps.auditEvidenceProvenance(this.loadRun(runId), options);
253
- }
254
- recordAuditAttestation(runId, options = {}) {
255
- return auditOps.recordAuditAttestation(this.loadRun(runId), options);
256
- }
257
- recordAuditDecision(runId, workerId, options = {}) {
258
- return auditOps.recordAuditDecision(this.loadRun(runId), workerId, options);
259
- }
260
- listSandboxProfiles(options = {}) {
261
- return (0, sandbox_profile_1.listBundledSandboxProfiles)((0, sandbox_profile_1.sandboxContextForValidation)(String(options.cwd || this.invocationCwd())));
262
- }
263
- showSandboxProfile(profileId, options = {}) {
264
- return (0, sandbox_profile_1.showBundledSandboxProfile)(profileId, (0, sandbox_profile_1.sandboxContextForValidation)(String(options.cwd || this.invocationCwd())));
265
- }
266
- validateSandboxProfile(profileFile, options = {}) {
267
- return (0, sandbox_profile_1.validateSandboxProfileFile)(this.resolveFromBase(profileFile), (0, sandbox_profile_1.sandboxContextForValidation)(String(options.cwd || this.invocationCwd())));
268
- }
269
- listBackends(options = {}) {
270
- void options;
271
- return (0, execution_backend_1.backendListPayload)();
272
- }
273
- showBackend(backendId, options = {}) {
274
- void options;
275
- return (0, execution_backend_1.backendShowPayload)(backendId);
276
- }
277
- probeBackend(backendId, options = {}) {
278
- return (0, execution_backend_1.backendProbePayload)(backendId, { cwd: String(options.cwd || this.invocationCwd()) });
279
- }
280
- // Candidate domain — delegated to ./orchestrator/candidate-operations.
281
- listCandidates(runId, options = {}) {
282
- return candidateOps.listCandidates(this.loadRun(runId), options);
283
- }
284
- showCandidate(runId, candidateId) {
285
- return candidateOps.showCandidate(this.loadRun(runId), candidateId);
286
- }
287
- registerCandidate(runId, options = {}) {
288
- return candidateOps.registerCandidate(this.loadRun(runId), options);
289
- }
290
- scoreCandidate(runId, candidateId, options = {}) {
291
- return candidateOps.scoreCandidate(this.loadRun(runId), candidateId, options);
292
- }
293
- rankCandidates(runId, options = {}) {
294
- return candidateOps.rankCandidates(this.loadRun(runId), options);
295
- }
296
- selectCandidate(runId, candidateId, options = {}) {
297
- return candidateOps.selectCandidate(this.loadRun(runId), candidateId, options);
298
- }
299
- rejectCandidate(runId, candidateId, reason) {
300
- return candidateOps.rejectCandidate(this.loadRun(runId), candidateId, reason);
301
- }
302
- // ---- Team Collaboration (v0.1.32) — delegated to ./orchestrator/collaboration-operations.
303
- // Append-only, host-attested (never authenticated) approvals/comments/handoffs
304
- // + a derived review state. Both CLI and MCP route through these methods, so
305
- // `cw <cmd> --json` is identical to `cw_<tool>` (the parity gate).
306
- collaborationApprove(runId, targetKind, targetId, options = {}, decision = "approve") {
307
- return collaborationOps.collaborationApprove(this.loadRun(runId), targetKind, targetId, options, decision);
308
- }
309
- collaborationReject(runId, targetKind, targetId, options = {}) {
310
- return this.collaborationApprove(runId, targetKind, targetId, options, "reject");
311
- }
312
- collaborationComment(runId, targetKind, targetId, options = {}) {
313
- return collaborationOps.collaborationComment(this.loadRun(runId), targetKind, targetId, options);
314
- }
315
- collaborationCommentList(runId, options = {}) {
316
- return collaborationOps.collaborationCommentList(this.loadRun(runId), options);
317
- }
318
- collaborationHandoff(runId, targetKind, targetId, options = {}) {
319
- return collaborationOps.collaborationHandoff(this.loadRun(runId), targetKind, targetId, options);
320
- }
321
- reviewStatus(runId, options = {}) {
322
- return collaborationOps.reviewStatus(this.loadRun(runId), options);
323
- }
324
- reviewPolicy(runId, options = {}) {
325
- return collaborationOps.reviewPolicy(this.loadRun(runId), options);
326
- }
327
- formatReviewStatus(report) {
328
- return collaborationOps.formatReviewStatus(report);
329
- }
330
- formatCommentList(comments) {
331
- return collaborationOps.formatCommentList(comments);
332
- }
333
- summarizeWorkerRecords(runId) {
334
- return (0, operator_ux_1.summarizeOperatorWorkers)(this.loadRun(runId));
335
- }
336
- summarizeCandidateOperatorRecords(runId) {
337
- return (0, operator_ux_1.summarizeOperatorCandidates)(this.loadRun(runId));
338
- }
339
- summarizeFeedbackRecords(runId) {
340
- return (0, operator_ux_1.summarizeOperatorFeedback)(this.loadRun(runId));
341
- }
342
- summarizeCommitRecords(runId) {
343
- return (0, operator_ux_1.summarizeOperatorCommits)(this.loadRun(runId));
344
- }
345
- report(runId) {
346
- const run = this.loadRun(runId);
347
- return { path: (0, report_1.writeReport)(run) };
348
- }
349
- operatorReport(runId) {
350
- const run = this.loadRun(runId);
351
- (0, report_1.writeReport)(run);
352
- return (0, operator_ux_1.summarizeOperatorRun)(run);
353
- }
354
- showContract(runId, contractId) {
355
- const run = this.loadRun(runId);
356
- return (0, pipeline_runner_1.createPipelineRunner)().getRunContract(run, contractId);
357
- }
358
- listNodes(runId) {
359
- return this.loadRun(runId).nodes || [];
360
- }
361
- showNode(runId, nodeId) {
362
- return (0, pipeline_runner_1.createPipelineRunner)().getRunNode(this.loadRun(runId), nodeId);
363
- }
364
- graphNodes(runId) {
365
- return (this.loadRun(runId).nodes || []).map((node) => ({
366
- id: node.id,
367
- kind: node.kind,
368
- status: node.status,
369
- parents: node.parents,
370
- children: node.children
371
- }));
372
- }
373
- operatorGraph(runId) {
374
- return (0, operator_ux_1.buildOperatorGraph)(this.loadRun(runId));
375
- }
376
- multiAgentSummary(runId) {
377
- return (0, multi_agent_1.summarizeMultiAgent)(this.loadRun(runId));
378
- }
379
- multiAgentGraph(runId) {
380
- return (0, multi_agent_1.buildMultiAgentGraph)(this.loadRun(runId));
381
- }
382
- multiAgentOperatorStatus(runId) {
383
- return (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(this.loadRun(runId));
384
- }
385
- multiAgentOperatorGraph(runId) {
386
- return (0, multi_agent_operator_ux_1.buildMultiAgentOperatorGraph)(this.loadRun(runId));
387
- }
388
- multiAgentDependencies(runId) {
389
- return (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(this.loadRun(runId)).dependencies;
390
- }
391
- multiAgentFailures(runId) {
392
- return (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(this.loadRun(runId)).failures;
393
- }
394
- multiAgentEvidence(runId) {
395
- const run = this.loadRun(runId);
396
- const rows = (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).evidence;
397
- // Additive enrichment: attach the derived rationale status so `multi-agent
398
- // evidence` answers WHAT + whether the WHY is recorded, without changing the
399
- // existing row shape (POLA: old consumers ignore the new optional field).
400
- const report = (0, evidence_reasoning_1.buildEvidenceReasoningReport)(run, { index: (0, evidence_reasoning_1.loadEvidenceReasoningIndex)(run) });
401
- const byId = new Map(report.chains.map((chain) => [chain.id, chain.rationaleStatus]));
402
- for (const row of rows)
403
- row.rationaleStatus = byId.get(row.id);
404
- return rows;
405
- }
406
- multiAgentReasoning(runId, options = {}) {
407
- const run = this.loadRun(runId);
408
- if (options.refresh) {
409
- (0, evidence_reasoning_1.refreshEvidenceReasoning)(run);
410
- (0, state_1.saveCheckpoint)(run);
411
- }
412
- return (0, evidence_reasoning_1.showEvidenceReasoning)(run, { evidenceId: (0, cli_options_1.stringOption)(options.evidence || options.evidenceId || options.id) });
413
- }
414
- multiAgentReasoningRefresh(runId) {
415
- const run = this.loadRun(runId);
416
- const index = (0, evidence_reasoning_1.refreshEvidenceReasoning)(run);
417
- (0, state_1.saveCheckpoint)(run);
418
- return index;
419
- }
420
- summaryRefresh(runId, options = {}) {
421
- const run = this.loadRun(runId);
422
- const index = (0, state_explosion_1.refreshStateExplosionSummaries)(run, { views: (0, cli_options_1.graphViewsOption)(options) });
423
- (0, report_1.writeReport)(run);
424
- (0, state_1.saveCheckpoint)(run);
425
- return index;
426
- }
427
- summaryShow(runId) {
428
- const run = this.loadRun(runId);
429
- const report = (0, state_explosion_1.showStateExplosionSummary)(run);
430
- (0, state_1.saveCheckpoint)(run);
431
- return report;
432
- }
433
- /** Observability + cost report for ONE run (v0.1.31). DERIVED from durable
434
- * state; persists a fingerprinted snapshot under `metrics/` but NEVER mutates
435
- * the run's own state.json (no saveCheckpoint), so the source — and therefore
436
- * the report — is stable across repeated reads. `now` is injectable via
437
- * `args.now` for eval/replay determinism; pricing is POLICY via `--pricing`. */
438
- metricsShow(runId, args = {}) {
439
- const run = this.loadRun(runId);
440
- const policy = (0, observability_1.loadCostPolicy)(args, this.pluginRoot);
441
- const now = typeof args.now === "string" && args.now ? args.now : new Date().toISOString();
442
- return (0, observability_1.showMetricsReport)(run, { now, policy });
443
- }
444
- blackboardSummarize(runId, options = {}) {
445
- return (0, state_explosion_1.summarizeBlackboardDigest)(this.loadRun(runId), (0, cli_options_1.stringOption)(options.blackboard || options.blackboardId));
446
- }
447
- multiAgentSummarize(runId) {
448
- const run = this.loadRun(runId);
449
- const index = (0, state_explosion_1.loadStateExplosionSummaryIndex)(run);
450
- return (0, state_explosion_1.buildStateExplosionReport)(run, { index });
451
- }
452
- multiAgentGraphView(runId, options = {}) {
453
- const view = (0, cli_options_1.graphViewOption)(options.view);
454
- return (0, state_explosion_1.buildCompactGraph)(this.loadRun(runId), view, {
455
- focus: (0, cli_options_1.stringOption)(options.focus),
456
- depth: (0, cli_options_1.numberOption)(options.depth)
457
- });
458
- }
459
- stateExplosionReport(runId) {
460
- const run = this.loadRun(runId);
461
- const index = (0, state_explosion_1.loadStateExplosionSummaryIndex)(run);
462
- return (0, state_explosion_1.buildStateExplosionReport)(run, { index });
463
- }
464
- // Host multi-agent — delegated to ./orchestrator/host-operations. The runner
465
- // keeps the load-or-plan policy here because it owns plan().
466
- hostMultiAgentRun(runId, options = {}) {
467
- const workflowId = (0, cli_options_1.stringOption)(options.app || options.appId || options.workflow || options.workflowId);
468
- const run = runId
469
- ? this.loadRun(runId)
470
- : workflowId
471
- ? this.plan(workflowId, (0, cli_options_1.withoutHostRunKeys)(options))
472
- : undefined;
473
- if (!run)
474
- throw new Error("multi-agent run requires <run-id> or --app <app-id>");
475
- return hostOps.hostMultiAgentRun(run, options);
476
- }
477
- hostMultiAgentStatus(runId) {
478
- return hostOps.hostMultiAgentStatus(this.loadRun(runId));
479
- }
480
- hostMultiAgentStep(runId, options = {}) {
481
- return hostOps.hostMultiAgentStep(this.loadRun(runId), options);
482
- }
483
- hostMultiAgentBlackboard(runId, action, options = {}) {
484
- return hostOps.hostMultiAgentBlackboard(this.loadRun(runId), action, options);
485
- }
486
- hostMultiAgentScore(runId, options = {}) {
487
- return hostOps.hostMultiAgentScore(this.loadRun(runId), options);
488
- }
489
- hostMultiAgentSelect(runId, options = {}) {
490
- return hostOps.hostMultiAgentSelect(this.loadRun(runId), options);
491
- }
492
- evalSnapshot(runId, options = {}) {
493
- return (0, multi_agent_eval_1.createMultiAgentReplaySnapshot)(this.loadRun(runId), options);
494
- }
495
- evalReplay(target, options = {}) {
496
- return (0, multi_agent_eval_1.replayMultiAgentSnapshot)(target, options);
497
- }
498
- evalCompare(baseline, replay) {
499
- return (0, multi_agent_eval_1.compareMultiAgentReplay)(baseline, replay);
500
- }
501
- evalScore(target) {
502
- return (0, multi_agent_eval_1.scoreMultiAgentReplay)(target);
503
- }
504
- evalGate(target) {
505
- return (0, multi_agent_eval_1.gateMultiAgentEval)(target);
506
- }
507
- evalReport(target) {
508
- return (0, multi_agent_eval_1.reportMultiAgentEval)(target);
509
- }
510
- // ---- node snapshot / diff / replay (v0.1.35) ----------------------------
511
- nodeSnapshot(runId, nodeId, options = {}) {
512
- return (0, node_snapshot_1.snapshotNode)(this.loadRun(runId), nodeId, options);
513
- }
514
- nodeDiff(runId, baselineSnapshotId, candidateSnapshotId) {
515
- const run = this.loadRun(runId);
516
- return (0, node_snapshot_1.diffNodeSnapshots)((0, node_snapshot_1.readNodeSnapshot)(run, baselineSnapshotId), (0, node_snapshot_1.readNodeSnapshot)(run, candidateSnapshotId));
517
- }
518
- nodeReplay(runId, snapshotId, options = {}) {
519
- const run = this.loadRun(runId);
520
- return (0, node_snapshot_1.replayNodeSnapshot)(run, (0, node_snapshot_1.readNodeSnapshot)(run, snapshotId), options);
521
- }
522
- nodeReplayVerify(runId, replayId, options = {}) {
523
- const run = this.loadRun(runId);
524
- return (0, node_snapshot_1.verifyNodeReplay)(run, (0, node_snapshot_1.readNodeReplay)(run, replayId), options);
525
- }
526
- // ---- contract migration (v0.1.36) ---------------------------------------
527
- // Contract migration — delegated to ./orchestrator/migration-operations.
528
- migrationList() {
529
- return migrationOps.migrationList();
530
- }
531
- migrationCheck(target, options = {}) {
532
- return migrationOps.migrationCheck(target, options);
533
- }
534
- migrationProve(target, options = {}) {
535
- return migrationOps.migrationProve(target, options);
536
- }
537
- loadMigrationSnapshot(target, options) {
538
- return migrationOps.loadMigrationSnapshot(target, options);
539
- }
540
- // Topology — delegated to ./orchestrator/topology-operations.
541
- listTopologies() {
542
- return topologyOps.listTopologies();
543
- }
544
- showTopology(topologyId) {
545
- return topologyOps.showTopology(topologyId);
546
- }
547
- validateTopology(topologyId) {
548
- return topologyOps.validateTopology(topologyId);
549
- }
550
- applyTopology(runId, topologyId, options = {}) {
551
- return topologyOps.applyTopology(this.loadRun(runId), topologyId, options);
552
- }
553
- showTopologyRun(runId, topologyRunId) {
554
- return topologyOps.showTopologyRun(this.loadRun(runId), topologyRunId);
555
- }
556
- topologySummary(runId) {
557
- return topologyOps.topologySummary(this.loadRun(runId));
558
- }
559
- topologyGraph(runId) {
560
- return topologyOps.topologyGraph(this.loadRun(runId));
561
- }
562
- // Multi-agent lifecycle + blackboard — delegated to ./orchestrator/multi-agent-operations.
563
- createMultiAgentRun(runId, options = {}) {
564
- return maOps.createMultiAgentRun(this.loadRun(runId), options);
565
- }
566
- transitionMultiAgentRun(runId, multiAgentRunId, options = {}) {
567
- return maOps.transitionMultiAgentRun(this.loadRun(runId), multiAgentRunId, options);
568
- }
569
- createAgentRole(runId, options = {}) {
570
- return maOps.createAgentRole(this.loadRun(runId), options);
571
- }
572
- createAgentGroup(runId, options = {}) {
573
- return maOps.createAgentGroup(this.loadRun(runId), options);
574
- }
575
- assignAgentMembership(runId, options = {}) {
576
- return maOps.assignAgentMembership(this.loadRun(runId), options);
577
- }
578
- createAgentFanout(runId, options = {}) {
579
- return maOps.createAgentFanout(this.loadRun(runId), options);
580
- }
581
- collectAgentFanin(runId, options = {}) {
582
- return maOps.collectAgentFanin(this.loadRun(runId), options);
583
- }
584
- showMultiAgentRun(runId, multiAgentRunId) {
585
- return maOps.showMultiAgentRun(this.loadRun(runId), multiAgentRunId);
586
- }
587
- showAgentRole(runId, roleId) {
588
- return maOps.showAgentRole(this.loadRun(runId), roleId);
589
- }
590
- showAgentGroup(runId, groupId) {
591
- return maOps.showAgentGroup(this.loadRun(runId), groupId);
592
- }
593
- showAgentMembership(runId, membershipId) {
594
- return maOps.showAgentMembership(this.loadRun(runId), membershipId);
595
- }
596
- showAgentFanout(runId, fanoutId) {
597
- return maOps.showAgentFanout(this.loadRun(runId), fanoutId);
598
- }
599
- showAgentFanin(runId, faninId) {
600
- return maOps.showAgentFanin(this.loadRun(runId), faninId);
601
- }
602
- blackboardSummary(runId, options = {}) {
603
- return maOps.blackboardSummary(this.loadRun(runId), options);
604
- }
605
- coordinatorSummary(runId, options = {}) {
606
- return maOps.blackboardSummary(this.loadRun(runId), options);
607
- }
608
- blackboardGraph(runId) {
609
- return maOps.blackboardGraph(this.loadRun(runId));
610
- }
611
- resolveRunBlackboard(runId, options = {}) {
612
- return maOps.resolveRunBlackboard(this.loadRun(runId), options);
613
- }
614
- createBlackboardTopic(runId, options = {}) {
615
- return maOps.createBlackboardTopic(this.loadRun(runId), options);
616
- }
617
- postBlackboardMessage(runId, options = {}) {
618
- return maOps.postBlackboardMessage(this.loadRun(runId), options);
619
- }
620
- listBlackboardMessages(runId, options = {}) {
621
- return maOps.listBlackboardMessages(this.loadRun(runId), options);
622
- }
623
- putBlackboardContext(runId, options = {}) {
624
- return maOps.putBlackboardContext(this.loadRun(runId), options);
625
- }
626
- addBlackboardArtifact(runId, options = {}) {
627
- return maOps.addBlackboardArtifact(this.loadRun(runId), options);
628
- }
629
- listBlackboardArtifacts(runId, options = {}) {
630
- return maOps.listBlackboardArtifacts(this.loadRun(runId), options);
631
- }
632
- snapshotBlackboard(runId, options = {}) {
633
- return maOps.snapshotBlackboard(this.loadRun(runId), options);
634
- }
635
- recordCoordinatorDecision(runId, options = {}) {
636
- return maOps.recordCoordinatorDecision(this.loadRun(runId), options);
637
- }
638
- checkState(runId, options = {}) {
639
- return lifecycleOps.checkState(runId, options);
640
- }
641
- commit(runId, input = {}) {
642
- return lifecycleOps.commit(this.loadRun(runId), input);
643
- }
644
- // Feedback — delegated to ./orchestrator/feedback-operations.
645
- collectFeedback(runId) {
646
- return feedbackOps.collectFeedback(this.loadRun(runId));
647
- }
648
- listFeedback(runId, options = {}) {
649
- return feedbackOps.listFeedback(this.loadRun(runId), options);
650
- }
651
- showFeedback(runId, feedbackId) {
652
- return feedbackOps.showFeedback(this.loadRun(runId), feedbackId);
653
- }
654
- createFeedbackTask(runId, feedbackId, options = {}) {
655
- return feedbackOps.createFeedbackTask(this.loadRun(runId), feedbackId, options);
656
- }
657
- resolveFeedback(runId, feedbackId, options = {}) {
658
- return feedbackOps.resolveFeedback(this.loadRun(runId), feedbackId, options);
659
- }
660
- loadRun(runId) {
661
- if (this._requestCache) {
662
- const cached = this._requestCache.get(runId);
663
- if (cached)
664
- return cached;
665
- }
666
- const run = (0, state_1.loadRunFromCwd)(runId, this.baseDir);
667
- this._requestCache?.set(runId, run);
668
- return run;
669
- }
670
- invocationCwd() {
671
- return this.baseDir || process.cwd();
672
- }
673
- resolveFromBase(target) {
674
- return node_path_1.default.resolve(this.invocationCwd(), target);
675
- }
676
- loadWorkflowAppById(appId) {
677
- return appOps.loadWorkflowAppById(this.workflowsDir, this.appsDir, appId);
678
- }
679
- }
680
- exports.CoolWorkflowRunner = CoolWorkflowRunner;
681
- function parseArgv(argv) {
682
- const [command, ...rest] = argv;
683
- const options = {};
684
- const positionals = [];
685
- for (let index = 0; index < rest.length; index += 1) {
686
- const token = rest[index];
687
- if (token === "--") {
688
- // POSIX end-of-options: everything after `--` is a positional, even if it
689
- // begins with `--`. Lets a legitimate value that starts with `--` through.
690
- for (let restIndex = index + 1; restIndex < rest.length; restIndex += 1)
691
- positionals.push(rest[restIndex]);
692
- break;
693
- }
694
- if (!token.startsWith("-")) {
695
- positionals.push(token);
696
- continue;
697
- }
698
- if (!token.startsWith("--")) {
699
- // Single-dash short flag aliases: -q → question, -r → repo, -a → agent-command, -h → help, -v → version
700
- const shortMap = { q: "question", r: "repo", d: "dir", l: "link", a: "agent-command", h: "help", v: "version" };
701
- const flag = token.slice(1);
702
- // Handle combined short flags like -qr (not common but safe to ignore)
703
- const key = shortMap[flag] || flag;
704
- const val = rest[index + 1] && !rest[index + 1].startsWith("-") ? rest[++index] : true;
705
- appendOption(options, key, val);
706
- continue;
707
- }
708
- const withoutPrefix = token.slice(2);
709
- const equalsIndex = withoutPrefix.indexOf("=");
710
- let key;
711
- let value;
712
- if (equalsIndex >= 0) {
713
- key = withoutPrefix.slice(0, equalsIndex);
714
- value = withoutPrefix.slice(equalsIndex + 1);
715
- }
716
- else {
717
- key = withoutPrefix;
718
- // A flag's value is never ANOTHER flag: reject a next token starting with `-`
719
- // (single OR double dash), matching the single-dash branch above. Without this, a
720
- // valueless `--flag` greedily swallowed the following single-dash flag — e.g.
721
- // `run app --drive -dir /p` made `drive="-dir"` and dropped `-dir` entirely. A
722
- // value that legitimately starts with `-` still goes through `--key=-value` or
723
- // after a `--` end-of-options marker (both handled above).
724
- value = rest[index + 1] && !rest[index + 1].startsWith("-") ? rest[++index] : true;
725
- }
726
- appendOption(options, key, value);
727
- }
728
- return { command, positionals, options };
729
- }
730
- /** All known top-level CW commands. Used for "did you mean?" suggestions. */
731
- exports.KNOWN_COMMANDS = new Set([
732
- "help", "list", "doctor", "info", "search", "man", "init", "quickstart", "plan", "status", "next",
733
- "dispatch", "result", "state", "commit", "report", "app", "sandbox",
734
- "backend", "contract", "node", "feedback", "worker", "audit", "candidate",
735
- "review", "loop", "schedule", "routine", "registry", "run", "queue", "clones",
736
- "history", "audit-run", "multi-agent", "topology", "summary", "blackboard",
737
- "coordinator", "metrics", "operator", "sched", "gc", "telemetry",
738
- "migration", "demo", "workbench", "approve", "reject", "comment", "handoff",
739
- "graph", "eval", "version", "update", "fix"
740
- ]);
741
- /** Levenshtein distance between two short strings. */
742
- function levenshtein(a, b) {
743
- const m = a.length;
744
- const n = b.length;
745
- let prev = Array.from({ length: n + 1 }, (_, j) => j);
746
- let curr = new Array(n + 1);
747
- for (let i = 1; i <= m; i++) {
748
- curr[0] = i;
749
- for (let j = 1; j <= n; j++) {
750
- curr[j] = Math.min(prev[j] + 1, curr[j - 1] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
751
- }
752
- [prev, curr] = [curr, prev];
753
- }
754
- return prev[n];
755
- }
756
- /** Suggest the closest known command for a typo. Returns undefined if no match
757
- * within half the length of the input (avoiding wild guesses on short strings). */
758
- function suggestCommand(input) {
759
- if (!input || input.length < 2)
760
- return undefined;
761
- const lower = input.toLowerCase();
762
- let best = "";
763
- let bestDist = Infinity;
764
- for (const cmd of exports.KNOWN_COMMANDS) {
765
- const dist = levenshtein(lower, cmd);
766
- if (dist < bestDist) {
767
- best = cmd;
768
- bestDist = dist;
769
- }
770
- }
771
- // Threshold: distance must be <= half the input length AND <= 3
772
- if (bestDist <= 3 && bestDist <= lower.length / 2)
773
- return best;
774
- return undefined;
775
- }
776
- function formatSearchResults(keyword, results) {
777
- if (!results.length)
778
- return `No workflows matched "${keyword}".\n Tip: cw list for all available workflows.`;
779
- return [
780
- (0, term_1.bold)(`${results.length} workflow${results.length !== 1 ? "s" : ""} matching "${keyword}"`),
781
- ...results.map((r) => ` ${r.id} — ${r.title}\n ${(0, term_1.dim)(r.summary.slice(0, 120))}${r.summary.length > 120 ? "…" : ""}`),
782
- "",
783
- (0, term_1.dim)("Use cw info <id> for full details.")
784
- ].join("\n");
785
- }
786
- function formatInfo(appId, data) {
787
- const app = (data.app || {});
788
- const inputs = (Array.isArray(data.inputs) ? data.inputs : []);
789
- const phases = (Array.isArray(data.phases) ? data.phases : []);
790
- const lines = [(0, term_1.bold)(`cw info ${appId}`)];
791
- if (data.title)
792
- lines.push(` Title: ${data.title}`);
793
- if (data.version)
794
- lines.push(` Version: ${data.version}`);
795
- if (data.summary)
796
- lines.push(` Summary: ${data.summary}`);
797
- if (data.author)
798
- lines.push(` Author: ${typeof data.author === "object" ? data.author.name : data.author}`);
799
- if (data.compatible !== undefined)
800
- lines.push(` Compatible: ${data.compatible ? "yes" : "no"}`);
801
- if (inputs.length > 0) {
802
- lines.push(" Inputs:");
803
- for (const input of inputs) {
804
- const name = input.name || "";
805
- const type = input.type || "string";
806
- const required = input.required ? ", required" : "";
807
- const def = input.default ? `, default: ${input.default}` : "";
808
- const desc = input.description ? ` — ${input.description}` : "";
809
- lines.push(` - ${name} (${type}${required}${def})${desc}`);
810
- }
811
- }
812
- if (Array.isArray(data.sandboxProfiles) && data.sandboxProfiles.length > 0) {
813
- lines.push(` Sandbox: ${data.sandboxProfiles.join(", ")}`);
814
- }
815
- const taskCount = data.taskCount || 0;
816
- if (phases.length > 0) {
817
- lines.push(` Phases: ${phases.length} phase${phases.length !== 1 ? "s" : ""}, ${taskCount} task${taskCount !== 1 ? "s" : ""}`);
818
- }
819
- lines.push(` Run: cw quickstart ${appId} --repo . --question "..."`);
820
- return lines.join("\n");
821
- }
822
- function formatHelp() {
823
- // Help is written to stdout, so color must key off stdout (not the term default).
824
- const out = process.stdout;
825
- const moreCommands = ("list search info init plan status next dispatch result state commit report app " +
826
- "sandbox backend contract node feedback worker audit candidate review loop schedule " +
827
- "routine registry run queue clones history quickstart audit-run multi-agent topology summary " +
828
- "blackboard coordinator metrics operator sched gc telemetry migration demo workbench " +
829
- "approve reject comment handoff ledger graph eval man version update fix").split(" ");
830
- // Wrap the command list into clean, indented, pipe-joined lines (<=76 cols) instead of
831
- // one 400-char line that wraps raggedly and merges with the next shell prompt. Pipe-joined
832
- // (no internal spaces) keeps it parseable by the CLI/MCP parity help-token check.
833
- const wrapped = [];
834
- let line = " ";
835
- for (const cmd of moreCommands) {
836
- const sep = line.length > 2 ? "|" : "";
837
- if (line.length + sep.length + cmd.length > 76) {
838
- wrapped.push(line);
839
- line = " ";
840
- }
841
- line += (line.length > 2 ? "|" : "") + cmd;
842
- }
843
- if (line.length > 2)
844
- wrapped.push(line);
845
- return [
846
- (0, term_1.bold)("Cool Workflow", out),
847
- "",
848
- " -q \"question\" [-claude|-codex|-gemini|-deepseek] Ask a question, get a report",
849
- " -q \"question\" --link <url> Review a remote repo by URL",
850
- " version Show version",
851
- " update Update to latest release",
852
- " doctor Check setup",
853
- " fix Show fix commands for setup issues",
854
- "",
855
- (0, term_1.bold)("Flags", out),
856
- " -q, --question TEXT The task or question to answer",
857
- " -r, --repo PATH Target repository path (default: .)",
858
- " -d, --dir PATH Project folder to review (alias for --repo)",
859
- " -claude Use Claude agent",
860
- " -codex Use Codex agent",
861
- " -gemini Use Gemini (via opencode)",
862
- " -deepseek Use DeepSeek (via opencode)",
863
- " --verbose Show full agent narration live (default: compact)",
864
- " --full Verbose, plus the report printed inline at the end",
865
- " --no-color Disable ANSI color (also honors NO_COLOR / FORCE_COLOR)",
866
- "",
867
- (0, term_1.bold)("More commands", out),
868
- ...wrapped,
869
- "",
870
- // 4-space indent on purpose: the CLI/MCP parity help-token check only parses
871
- // 2-space command lines, so this note never registers as a bogus token.
872
- " Run cw help <command> for one command's subcommands and descriptions."
873
- ].join("\n");
874
- }
875
- /** Per-command help: `cw help <verb>` (and `cw <verb> --help`) lists that verb's
876
- * CLI subcommands with one-line summaries, derived from CAPABILITY_REGISTRY — the
877
- * SAME table the dispatcher and the CLI/MCP parity check use, so there is no
878
- * second source to drift. Additive: formatHelp()'s parity-checked token list is
879
- * untouched. */
880
- function formatCommandHelp(verb) {
881
- const out = process.stdout;
882
- const matches = capability_registry_1.CAPABILITY_REGISTRY.filter((cap) => cap.cli && cap.cli.path[0] === verb);
883
- if (matches.length === 0) {
884
- const lines = [`Unknown command: ${verb}`];
885
- const hint = suggestCommand(verb);
886
- if (hint)
887
- lines.push(` Did you mean: cw ${hint}`);
888
- lines.push(" Try: cw help (list all commands)");
889
- return lines.join("\n");
890
- }
891
- const rows = matches
892
- .map((cap) => ({ cmd: `cw ${cap.cli.path.join(" ")}`, summary: cap.summary }))
893
- .sort((a, b) => (a.cmd < b.cmd ? -1 : a.cmd > b.cmd ? 1 : 0));
894
- const width = Math.min(40, rows.reduce((max, row) => Math.max(max, row.cmd.length), 0));
895
- return [
896
- (0, term_1.bold)(`cw ${verb}`, out),
897
- "",
898
- ...rows.map((row) => ` ${row.cmd.padEnd(width)} ${row.summary}`)
899
- ].join("\n");
900
- }
901
- function appendOption(options, key, value) {
902
- if (Object.prototype.hasOwnProperty.call(options, key)) {
903
- const current = options[key];
904
- options[key] = Array.isArray(current) ? [...current, value] : [current, value];
905
- return;
906
- }
907
- options[key] = value;
908
- }
909
- function resolvePluginRoot(candidate) {
910
- let current = node_path_1.default.resolve(candidate);
911
- for (let depth = 0; depth < 5; depth += 1) {
912
- if (node_fs_1.default.existsSync(node_path_1.default.join(current, "workflows")) && node_fs_1.default.existsSync(node_path_1.default.join(current, "package.json"))) {
913
- return current;
914
- }
915
- current = node_path_1.default.dirname(current);
916
- }
917
- throw new Error("Run cw.js from the cool-workflow plugin directory");
918
- }
919
- function titleize(value) {
920
- return value
921
- .split("-")
922
- .filter(Boolean)
923
- .map((part) => part.charAt(0).toUpperCase() + part.slice(1))
924
- .join(" ");
925
- }