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