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.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/README.md +11 -2
- package/apps/architecture-review/app.json +1 -1
- package/apps/architecture-review-fast/app.json +1 -1
- package/apps/end-to-end-golden-path/app.json +1 -1
- package/apps/pr-review-fix-ci/app.json +1 -1
- package/apps/release-cut/app.json +1 -1
- package/apps/research-synthesis/app.json +1 -1
- package/dist/cli/dispatch.js +236 -0
- package/dist/cli/entry.js +120 -0
- package/dist/cli/io.js +21 -4
- package/dist/cli/parseargv.js +157 -0
- package/dist/cli.js +6 -33
- package/dist/core/capability-table.js +3534 -0
- package/dist/core/format/help.js +314 -0
- package/dist/{state-explosion/format.js → core/format/state-explosion-text.js} +10 -1
- package/dist/core/hash.js +137 -0
- package/dist/core/multi-agent/candidate-scoring.js +219 -0
- package/dist/core/multi-agent/collaboration.js +481 -0
- package/dist/core/multi-agent/coordinator.js +515 -0
- package/dist/core/multi-agent/eval-replay.js +306 -0
- package/dist/core/multi-agent/runtime.js +929 -0
- package/dist/core/multi-agent/topology.js +298 -0
- package/dist/core/multi-agent/trust-policy.js +197 -0
- package/dist/core/pipeline/commit-gate.js +320 -0
- package/dist/{pipeline-contract.js → core/pipeline/contract.js} +24 -37
- package/dist/core/pipeline/dispatch.js +103 -0
- package/dist/core/pipeline/drive-decide.js +227 -0
- package/dist/core/pipeline/error-feedback.js +161 -0
- package/dist/core/pipeline/loop-expansion.js +124 -0
- package/dist/{result-normalize.js → core/pipeline/result-normalize.js} +14 -37
- package/dist/core/pipeline/runner.js +230 -0
- package/dist/{contract-migration.js → core/state/contract-migration.js} +68 -92
- package/dist/{state-migrations.js → core/state/migrations.js} +103 -96
- package/dist/core/state/node-projection.js +95 -0
- package/dist/core/state/node-snapshot.js +230 -0
- package/dist/core/state/run-paths.js +93 -0
- package/dist/{schema-validate.js → core/state/schema-validate.js} +35 -28
- package/dist/core/state/schema.js +50 -0
- package/dist/core/state/state-explosion/digest.js +243 -0
- package/dist/core/state/state-explosion/graph.js +527 -0
- package/dist/{state-explosion → core/state/state-explosion}/helpers.js +34 -3
- package/dist/core/state/state-explosion/report.js +187 -0
- package/dist/{state-explosion → core/state/state-explosion}/size.js +25 -7
- package/dist/{state-node.js → core/state/state-node.js} +90 -113
- package/dist/core/state/types.js +19 -0
- package/dist/{validation.js → core/state/validation.js} +64 -131
- package/dist/core/trust/evidence-grounding.js +134 -0
- package/dist/core/trust/ledger.js +199 -0
- package/dist/{telemetry-attestation.js → core/trust/telemetry-attestation.js} +94 -68
- package/dist/core/trust/telemetry-ledger.js +127 -0
- package/dist/core/types.js +20 -0
- package/dist/core/version.js +16 -0
- package/dist/{workflow-app-framework.js → core/workflow-apps/app-schema.js} +337 -426
- package/dist/mcp/dispatch.js +104 -0
- package/dist/mcp/server.js +144 -0
- package/dist/mcp-server.js +6 -84
- package/dist/{agent-config.js → shell/agent-config.js} +118 -71
- package/dist/shell/app-run-cli.js +88 -0
- package/dist/shell/audit-cli.js +259 -0
- package/dist/shell/audit-provenance.js +83 -0
- package/dist/shell/candidate-scoring-io.js +459 -0
- package/dist/shell/collaboration-io.js +264 -0
- package/dist/shell/commit-summary.js +104 -0
- package/dist/shell/commit.js +290 -0
- package/dist/shell/coordinator-io.js +476 -0
- package/dist/shell/demo-cli.js +19 -0
- package/dist/shell/dispatch.js +162 -0
- package/dist/{doctor.js → shell/doctor.js} +123 -56
- package/dist/shell/drive.js +873 -0
- package/dist/shell/error-feedback-io.js +305 -0
- package/dist/shell/eval-io.js +473 -0
- package/dist/{multi-agent-eval/format.js → shell/eval-text.js} +78 -49
- package/dist/{evidence-reasoning.js → shell/evidence-reasoning.js} +124 -255
- package/dist/shell/exec-backend-cli.js +88 -0
- package/dist/shell/execution-backend/agent.js +475 -0
- package/dist/shell/execution-backend/ci.js +15 -0
- package/dist/shell/execution-backend/container.js +69 -0
- package/dist/shell/execution-backend/envelopes.js +55 -0
- package/dist/shell/execution-backend/local.js +113 -0
- package/dist/shell/execution-backend/probes.js +175 -0
- package/dist/shell/execution-backend/registry.js +402 -0
- package/dist/shell/execution-backend/remote.js +128 -0
- package/dist/shell/execution-backend/types.js +11 -0
- package/dist/shell/feedback-cli.js +81 -0
- package/dist/shell/feedback-operations.js +48 -0
- package/dist/shell/fs-atomic.js +276 -0
- package/dist/shell/harness.js +98 -0
- package/dist/shell/ledger-cli.js +212 -0
- package/dist/shell/ledger-io.js +169 -0
- package/dist/shell/man-cli.js +89 -0
- package/dist/shell/metrics-cli.js +98 -0
- package/dist/shell/multi-agent-cli.js +1002 -0
- package/dist/shell/multi-agent-host.js +563 -0
- package/dist/shell/multi-agent-io.js +387 -0
- package/dist/{multi-agent-operator-ux.js → shell/multi-agent-operator-ux.js} +234 -191
- package/dist/shell/node-store.js +124 -0
- package/dist/{observability/format.js → shell/observability-format.js} +7 -1
- package/dist/{observability/intake.js → shell/observability-intake.js} +79 -56
- package/dist/{observability.js → shell/observability.js} +159 -332
- package/dist/{onramp.js → shell/onramp.js} +11 -0
- package/dist/{operator-ux/format.js → shell/operator-ux-text.js} +250 -239
- package/dist/shell/operator-ux.js +431 -0
- package/dist/shell/orchestrator.js +231 -0
- package/dist/shell/pipeline-cli.js +667 -0
- package/dist/shell/pipeline.js +217 -0
- package/dist/shell/reclamation-io.js +1366 -0
- package/dist/shell/registry-cli.js +329 -0
- package/dist/{remote-source.js → shell/remote-source.js} +12 -5
- package/dist/shell/report-cli.js +101 -0
- package/dist/shell/report-view-cli.js +117 -0
- package/dist/{orchestrator → shell}/report.js +289 -282
- package/dist/shell/reporter.js +62 -0
- package/dist/shell/run-export-cli.js +106 -0
- package/dist/shell/run-export.js +680 -0
- package/dist/shell/run-registry-io.js +1014 -0
- package/dist/shell/run-store.js +164 -0
- package/dist/{sandbox-profile.js → shell/sandbox-profile.js} +134 -95
- package/dist/{scheduler.js → shell/scheduler-io.js} +248 -48
- package/dist/shell/scheduling-io.js +311 -0
- package/dist/shell/state-cli.js +181 -0
- package/dist/shell/state-explosion-cli.js +197 -0
- package/dist/shell/telemetry-cli.js +85 -0
- package/dist/{telemetry-demo.js → shell/telemetry-demo.js} +149 -119
- package/dist/shell/telemetry-ledger-io.js +132 -0
- package/dist/{term.js → shell/term.js} +36 -46
- package/dist/shell/topology-io.js +361 -0
- package/dist/shell/trust-audit.js +471 -0
- package/dist/{multi-agent-trust.js → shell/trust-policy-io.js} +67 -205
- package/dist/shell/verifier.js +48 -0
- package/dist/shell/workbench-host.js +250 -0
- package/dist/shell/workbench-text.js +18 -0
- package/dist/shell/workbench.js +175 -0
- package/dist/shell/worker-cli.js +124 -0
- package/dist/shell/worker-isolation.js +852 -0
- package/dist/shell/workflow-app-loader.js +650 -0
- package/docs/agent-delegation-drive.7.md +4 -0
- package/docs/cli-mcp-parity.7.md +284 -211
- package/docs/contract-migration-tooling.7.md +4 -0
- package/docs/control-plane-scheduling.7.md +4 -0
- package/docs/cross-agent-ledger.7.md +217 -0
- package/docs/designs/handoff-ledger.md +145 -0
- package/docs/durable-state-and-locking.7.md +4 -0
- package/docs/evidence-adoption-reasoning-chain.7.md +4 -0
- package/docs/execution-backends.7.md +4 -0
- package/docs/handoff-setup.md +120 -0
- package/docs/multi-agent-cli-mcp-surface.7.md +4 -0
- package/docs/multi-agent-eval-replay-harness.7.md +4 -0
- package/docs/multi-agent-operator-ux.7.md +4 -0
- package/docs/node-snapshot-diff-replay.7.md +4 -0
- package/docs/observability-cost-accounting.7.md +4 -0
- package/docs/project-index.md +143 -71
- package/docs/real-execution-backends.7.md +4 -0
- package/docs/release-and-migration.7.md +4 -0
- package/docs/release-tooling.7.md +4 -0
- package/docs/run-registry-control-plane.7.md +4 -0
- package/docs/run-retention-reclamation.7.md +25 -0
- package/docs/state-explosion-management.7.md +4 -0
- package/docs/team-collaboration.7.md +4 -0
- package/docs/web-desktop-workbench.7.md +4 -0
- package/manifest/plugin.manifest.json +1 -1
- package/manifest/source-context-profiles.json +9 -13
- package/package.json +1 -1
- package/scripts/agents/codex-agent.js +34 -4
- package/scripts/agents/cw-attest-wrap.js +2 -2
- package/scripts/bump-version.js +4 -3
- package/scripts/canonical-apps.js +4 -4
- package/scripts/children/batch-delegate-child.js +30 -10
- package/scripts/dogfood-architecture-review.js +2 -3
- package/scripts/dogfood-release.js +3 -3
- package/scripts/gen-parity-doc.js +15 -2
- package/scripts/golden-path.js +4 -4
- package/scripts/onramp-check.js +1 -1
- package/scripts/parity-check.js +38 -21
- package/scripts/release-flow.js +9 -3
- package/scripts/sync-project-index.js +51 -27
- package/scripts/validate-run-state-schema.js +2 -2
- package/scripts/version-sync-check.js +30 -30
- package/dist/candidate-scoring.js +0 -729
- package/dist/capability-core.js +0 -1186
- package/dist/capability-registry.js +0 -879
- package/dist/cli/command-surface.js +0 -490
- package/dist/cli/format.js +0 -56
- package/dist/cli/handlers/audit.js +0 -82
- package/dist/cli/handlers/blackboard.js +0 -81
- package/dist/cli/handlers/candidate.js +0 -40
- package/dist/cli/handlers/clones.js +0 -34
- package/dist/cli/handlers/collaboration.js +0 -61
- package/dist/cli/handlers/eval.js +0 -40
- package/dist/cli/handlers/maintenance.js +0 -107
- package/dist/cli/handlers/multi-agent.js +0 -165
- package/dist/cli/handlers/node.js +0 -41
- package/dist/cli/handlers/operational.js +0 -155
- package/dist/cli/handlers/operator.js +0 -146
- package/dist/cli/handlers/registry.js +0 -68
- package/dist/cli/handlers/run.js +0 -153
- package/dist/cli/handlers/scheduling.js +0 -132
- package/dist/cli/handlers/workbench.js +0 -41
- package/dist/cli/handlers/worker.js +0 -45
- package/dist/cli/run-summary.js +0 -45
- package/dist/clones.js +0 -162
- package/dist/collaboration.js +0 -726
- package/dist/commit.js +0 -592
- package/dist/compare.js +0 -18
- package/dist/coordinator/classify.js +0 -45
- package/dist/coordinator/paths.js +0 -42
- package/dist/coordinator/util.js +0 -126
- package/dist/coordinator.js +0 -990
- package/dist/daemon.js +0 -44
- package/dist/dispatch.js +0 -250
- package/dist/drive.js +0 -827
- package/dist/error-feedback.js +0 -419
- package/dist/evidence-grounding.js +0 -184
- package/dist/execution-backend/agent.js +0 -294
- package/dist/execution-backend/probes.js +0 -112
- package/dist/execution-backend/util.js +0 -47
- package/dist/execution-backend.js +0 -961
- package/dist/gates.js +0 -48
- package/dist/harness.js +0 -61
- package/dist/loop-expansion.js +0 -60
- package/dist/mcp/tool-call.js +0 -434
- package/dist/mcp/tool-definitions.js +0 -1040
- package/dist/mcp-surface.js +0 -30
- package/dist/multi-agent/graph.js +0 -84
- package/dist/multi-agent/helpers.js +0 -141
- package/dist/multi-agent/ids.js +0 -20
- package/dist/multi-agent/paths.js +0 -22
- package/dist/multi-agent-eval/normalize.js +0 -51
- package/dist/multi-agent-eval.js +0 -678
- package/dist/multi-agent-host.js +0 -777
- package/dist/multi-agent.js +0 -984
- package/dist/node-projection.js +0 -59
- package/dist/node-snapshot.js +0 -260
- package/dist/operator-ux.js +0 -631
- package/dist/orchestrator/app-operations.js +0 -211
- package/dist/orchestrator/audit-operations.js +0 -182
- package/dist/orchestrator/candidate-operations.js +0 -117
- package/dist/orchestrator/cli-options.js +0 -294
- package/dist/orchestrator/collaboration-operations.js +0 -86
- package/dist/orchestrator/feedback-operations.js +0 -81
- package/dist/orchestrator/host-operations.js +0 -78
- package/dist/orchestrator/lifecycle-operations.js +0 -626
- package/dist/orchestrator/migration-operations.js +0 -44
- package/dist/orchestrator/multi-agent-operations.js +0 -362
- package/dist/orchestrator/topology-operations.js +0 -84
- package/dist/orchestrator.js +0 -917
- package/dist/pipeline-runner.js +0 -285
- package/dist/reclamation/hash.js +0 -72
- package/dist/reclamation.js +0 -812
- package/dist/reporter.js +0 -67
- package/dist/run-export.js +0 -784
- package/dist/run-registry/derive.js +0 -175
- package/dist/run-registry/format.js +0 -124
- package/dist/run-registry/gc.js +0 -251
- package/dist/run-registry/policy.js +0 -16
- package/dist/run-registry/queue.js +0 -115
- package/dist/run-registry.js +0 -850
- package/dist/run-state-schema.js +0 -68
- package/dist/scheduling.js +0 -184
- package/dist/state-explosion.js +0 -1014
- package/dist/state.js +0 -367
- package/dist/telemetry-ledger.js +0 -196
- package/dist/topology.js +0 -565
- package/dist/triggers.js +0 -184
- package/dist/trust-audit.js +0 -644
- package/dist/types/blackboard.js +0 -2
- package/dist/types/candidate.js +0 -2
- package/dist/types/collaboration.js +0 -2
- package/dist/types/core.js +0 -2
- package/dist/types/drive.js +0 -10
- package/dist/types/error-feedback.js +0 -2
- package/dist/types/evidence-reasoning.js +0 -2
- package/dist/types/execution-backend.js +0 -2
- package/dist/types/multi-agent.js +0 -2
- package/dist/types/observability.js +0 -2
- package/dist/types/pipeline.js +0 -2
- package/dist/types/reclamation.js +0 -8
- package/dist/types/report-bundle.js +0 -6
- package/dist/types/result.js +0 -2
- package/dist/types/run-registry.js +0 -2
- package/dist/types/run.js +0 -2
- package/dist/types/sandbox.js +0 -2
- package/dist/types/schedule.js +0 -2
- package/dist/types/state-node.js +0 -2
- package/dist/types/topology.js +0 -2
- package/dist/types/trust.js +0 -2
- package/dist/types/workbench.js +0 -2
- package/dist/types/worker.js +0 -2
- package/dist/types/workflow-app.js +0 -2
- package/dist/types.js +0 -44
- package/dist/util/fingerprint.js +0 -19
- package/dist/util/fingerprint.test.js +0 -27
- package/dist/verifier.js +0 -78
- package/dist/version.js +0 -8
- package/dist/workbench-host.js +0 -182
- package/dist/workbench.js +0 -192
- package/dist/worker-accept/acceptance.js +0 -114
- package/dist/worker-accept/blackboard-fanout.js +0 -80
- package/dist/worker-accept/blackboard-linkage.js +0 -19
- package/dist/worker-accept/context.js +0 -2
- package/dist/worker-accept/telemetry-ledger.js +0 -126
- package/dist/worker-accept/validation.js +0 -77
- package/dist/worker-accept/verifier-completion.js +0 -73
- package/dist/worker-isolation/helpers.js +0 -51
- package/dist/worker-isolation/paths.js +0 -46
- package/dist/worker-isolation.js +0 -656
- package/dist/workflow-api.js +0 -131
- /package/dist/{types → core/types}/boundary.js +0 -0
|
@@ -0,0 +1,1002 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// shell/multi-agent-cli.ts — CLI/MCP-facing entry points for milestone 9's
|
|
3
|
+
// multi-agent/topology/coordinator/candidate/collaboration/eval surface.
|
|
4
|
+
//
|
|
5
|
+
// MILESTONE 9. Wires the pure core/multi-agent/* modules + their shell IO
|
|
6
|
+
// wrappers (multi-agent-io.ts, topology-io.ts, coordinator-io.ts,
|
|
7
|
+
// candidate-scoring-io.ts, collaboration-io.ts, eval-io.ts,
|
|
8
|
+
// multi-agent-host.ts) into the shapes core/capability-table.ts's CLI
|
|
9
|
+
// bindings call, matching shell/pipeline-cli.ts's pattern.
|
|
10
|
+
//
|
|
11
|
+
// Evidence: SPEC/multi-agent.md section J ("CLI verbs and MCP tools").
|
|
12
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
15
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
16
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
17
|
+
}
|
|
18
|
+
Object.defineProperty(o, k2, desc);
|
|
19
|
+
}) : (function(o, m, k, k2) {
|
|
20
|
+
if (k2 === undefined) k2 = k;
|
|
21
|
+
o[k2] = m[k];
|
|
22
|
+
}));
|
|
23
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
24
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
25
|
+
}) : function(o, v) {
|
|
26
|
+
o["default"] = v;
|
|
27
|
+
});
|
|
28
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
29
|
+
var ownKeys = function(o) {
|
|
30
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
31
|
+
var ar = [];
|
|
32
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
33
|
+
return ar;
|
|
34
|
+
};
|
|
35
|
+
return ownKeys(o);
|
|
36
|
+
};
|
|
37
|
+
return function (mod) {
|
|
38
|
+
if (mod && mod.__esModule) return mod;
|
|
39
|
+
var result = {};
|
|
40
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
41
|
+
__setModuleDefault(result, mod);
|
|
42
|
+
return result;
|
|
43
|
+
};
|
|
44
|
+
})();
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.topologyList = topologyList;
|
|
47
|
+
exports.topologyShowCli = topologyShowCli;
|
|
48
|
+
exports.topologyValidateCli = topologyValidateCli;
|
|
49
|
+
exports.topologyApplyCli = topologyApplyCli;
|
|
50
|
+
exports.topologySummaryCli = topologySummaryCli;
|
|
51
|
+
exports.topologyGraphCli = topologyGraphCli;
|
|
52
|
+
exports.topologyRunShowCli = topologyRunShowCli;
|
|
53
|
+
exports.multiAgentRunCli = multiAgentRunCli;
|
|
54
|
+
exports.multiAgentStatusCli = multiAgentStatusCli;
|
|
55
|
+
exports.multiAgentStatusText = multiAgentStatusText;
|
|
56
|
+
exports.multiAgentDependenciesCli = multiAgentDependenciesCli;
|
|
57
|
+
exports.multiAgentDependenciesText = multiAgentDependenciesText;
|
|
58
|
+
exports.multiAgentFailuresCli = multiAgentFailuresCli;
|
|
59
|
+
exports.multiAgentFailuresText = multiAgentFailuresText;
|
|
60
|
+
exports.multiAgentEvidenceCli = multiAgentEvidenceCli;
|
|
61
|
+
exports.multiAgentReasoningCli = multiAgentReasoningCli;
|
|
62
|
+
exports.multiAgentReasoningText = multiAgentReasoningText;
|
|
63
|
+
exports.multiAgentReasoningRefreshCli = multiAgentReasoningRefreshCli;
|
|
64
|
+
exports.multiAgentEvidenceText = multiAgentEvidenceText;
|
|
65
|
+
exports.multiAgentStepCli = multiAgentStepCli;
|
|
66
|
+
exports.multiAgentBlackboardCli = multiAgentBlackboardCli;
|
|
67
|
+
exports.multiAgentScoreCli = multiAgentScoreCli;
|
|
68
|
+
exports.multiAgentSelectCli = multiAgentSelectCli;
|
|
69
|
+
exports.multiAgentRoleCli = multiAgentRoleCli;
|
|
70
|
+
exports.multiAgentGroupCli = multiAgentGroupCli;
|
|
71
|
+
exports.multiAgentMembershipCli = multiAgentMembershipCli;
|
|
72
|
+
exports.multiAgentFanoutCli = multiAgentFanoutCli;
|
|
73
|
+
exports.multiAgentFaninCli = multiAgentFaninCli;
|
|
74
|
+
exports.multiAgentShowCli = multiAgentShowCli;
|
|
75
|
+
exports.multiAgentSummaryCli = multiAgentSummaryCli;
|
|
76
|
+
exports.multiAgentSummarizeCli = multiAgentSummarizeCli;
|
|
77
|
+
exports.multiAgentGraphCompactCli = multiAgentGraphCompactCli;
|
|
78
|
+
exports.blackboardSummarizeCli = blackboardSummarizeCli;
|
|
79
|
+
exports.contractShowCli = contractShowCli;
|
|
80
|
+
exports.multiAgentGraphCli = multiAgentGraphCli;
|
|
81
|
+
exports.multiAgentGraphText = multiAgentGraphText;
|
|
82
|
+
exports.blackboardSummaryCli = blackboardSummaryCli;
|
|
83
|
+
exports.blackboardGraphCli = blackboardGraphCli;
|
|
84
|
+
exports.blackboardResolveCli = blackboardResolveCli;
|
|
85
|
+
exports.blackboardTopicCreateCli = blackboardTopicCreateCli;
|
|
86
|
+
exports.blackboardMessagePostCli = blackboardMessagePostCli;
|
|
87
|
+
exports.blackboardMessageListCli = blackboardMessageListCli;
|
|
88
|
+
exports.blackboardContextPutCli = blackboardContextPutCli;
|
|
89
|
+
exports.blackboardArtifactAddCli = blackboardArtifactAddCli;
|
|
90
|
+
exports.blackboardArtifactListCli = blackboardArtifactListCli;
|
|
91
|
+
exports.blackboardSnapshotCli = blackboardSnapshotCli;
|
|
92
|
+
exports.coordinatorSummaryCli = coordinatorSummaryCli;
|
|
93
|
+
exports.coordinatorDecisionCli = coordinatorDecisionCli;
|
|
94
|
+
exports.candidateListCli = candidateListCli;
|
|
95
|
+
exports.candidateShowCli = candidateShowCli;
|
|
96
|
+
exports.candidateRegisterCli = candidateRegisterCli;
|
|
97
|
+
exports.candidateScoreCli = candidateScoreCli;
|
|
98
|
+
exports.candidateRankCli = candidateRankCli;
|
|
99
|
+
exports.candidateSelectCli = candidateSelectCli;
|
|
100
|
+
exports.candidateRejectCli = candidateRejectCli;
|
|
101
|
+
exports.candidateSummaryCli = candidateSummaryCli;
|
|
102
|
+
exports.approveCli = approveCli;
|
|
103
|
+
exports.rejectCollabCli = rejectCollabCli;
|
|
104
|
+
exports.commentAddCli = commentAddCli;
|
|
105
|
+
exports.commentListCli = commentListCli;
|
|
106
|
+
exports.handoffCli = handoffCli;
|
|
107
|
+
exports.reviewStatusCli = reviewStatusCli;
|
|
108
|
+
exports.reviewPolicyCli = reviewPolicyCli;
|
|
109
|
+
exports.evalSnapshotCli = evalSnapshotCli;
|
|
110
|
+
exports.evalReplayCli = evalReplayCli;
|
|
111
|
+
exports.evalCompareCli = evalCompareCli;
|
|
112
|
+
exports.evalScoreCli = evalScoreCli;
|
|
113
|
+
exports.evalGateCli = evalGateCli;
|
|
114
|
+
exports.evalReportCli = evalReportCli;
|
|
115
|
+
const path = __importStar(require("node:path"));
|
|
116
|
+
const run_store_1 = require("./run-store");
|
|
117
|
+
const report_1 = require("./report");
|
|
118
|
+
const mai = __importStar(require("./multi-agent-io"));
|
|
119
|
+
const topio = __importStar(require("./topology-io"));
|
|
120
|
+
const coord = __importStar(require("./coordinator-io"));
|
|
121
|
+
const cs = __importStar(require("./candidate-scoring-io"));
|
|
122
|
+
const collab = __importStar(require("./collaboration-io"));
|
|
123
|
+
const evalio = __importStar(require("./eval-io"));
|
|
124
|
+
const host = __importStar(require("./multi-agent-host"));
|
|
125
|
+
const runtime_1 = require("../core/multi-agent/runtime");
|
|
126
|
+
const worker_isolation_1 = require("./worker-isolation");
|
|
127
|
+
const topology_1 = require("../core/multi-agent/topology");
|
|
128
|
+
const multi_agent_operator_ux_1 = require("./multi-agent-operator-ux");
|
|
129
|
+
const operator_ux_text_1 = require("./operator-ux-text");
|
|
130
|
+
const report_2 = require("../core/state/state-explosion/report");
|
|
131
|
+
const graph_1 = require("../core/state/state-explosion/graph");
|
|
132
|
+
const digest_1 = require("../core/state/state-explosion/digest");
|
|
133
|
+
const state_explosion_cli_1 = require("./state-explosion-cli");
|
|
134
|
+
const runner_1 = require("../core/pipeline/runner");
|
|
135
|
+
const operator_ux_1 = require("./operator-ux");
|
|
136
|
+
const reasoning = __importStar(require("./evidence-reasoning"));
|
|
137
|
+
function invocationCwd(args) {
|
|
138
|
+
return typeof args.cwd === "string" && args.cwd.trim() ? path.resolve(args.cwd) : process.cwd();
|
|
139
|
+
}
|
|
140
|
+
function loadRun(args, runId) {
|
|
141
|
+
return (0, run_store_1.loadRunFromCwd)(runId, invocationCwd(args));
|
|
142
|
+
}
|
|
143
|
+
function persist(run) {
|
|
144
|
+
(0, run_store_1.saveCheckpoint)(run);
|
|
145
|
+
(0, report_1.writeReport)(run);
|
|
146
|
+
}
|
|
147
|
+
function optionalString(value) {
|
|
148
|
+
return typeof value === "string" && value.trim() ? value.trim() : Array.isArray(value) && typeof value[0] === "string" ? value[0] : undefined;
|
|
149
|
+
}
|
|
150
|
+
function requireArg(value, label) {
|
|
151
|
+
const parsed = optionalString(value);
|
|
152
|
+
if (!parsed)
|
|
153
|
+
throw new Error(`Missing ${label}`);
|
|
154
|
+
return parsed;
|
|
155
|
+
}
|
|
156
|
+
/** Byte-exact to the eval-replay harness's own thrown strings (SPEC/
|
|
157
|
+
* multi-agent.md "Eval harness exact outputs"): these three END with a
|
|
158
|
+
* period, unlike the generic `requireArg` messages elsewhere in this
|
|
159
|
+
* file. */
|
|
160
|
+
function requireArgDot(value, label) {
|
|
161
|
+
const parsed = optionalString(value);
|
|
162
|
+
if (!parsed)
|
|
163
|
+
throw new Error(`Missing ${label}.`);
|
|
164
|
+
return parsed;
|
|
165
|
+
}
|
|
166
|
+
function arrayArg(value) {
|
|
167
|
+
if (value === undefined || value === null || value === true)
|
|
168
|
+
return [];
|
|
169
|
+
return (Array.isArray(value) ? value : [value]).map(String);
|
|
170
|
+
}
|
|
171
|
+
function numberArg(value) {
|
|
172
|
+
if (value === undefined || value === null || value === true)
|
|
173
|
+
return undefined;
|
|
174
|
+
const parsed = Number(value);
|
|
175
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
176
|
+
}
|
|
177
|
+
function boolArg(value) {
|
|
178
|
+
return Boolean(value);
|
|
179
|
+
}
|
|
180
|
+
/** `--multi-agent-run <id>` — parseArgv keeps kebab-case option keys
|
|
181
|
+
* verbatim (no camelCase folding), so this must check the literal
|
|
182
|
+
* `"multi-agent-run"` key alongside the camelCase aliases the MCP
|
|
183
|
+
* surface also accepts. */
|
|
184
|
+
function multiAgentRunArg(args) {
|
|
185
|
+
return optionalString(args.multiAgentRunId ?? args.multiAgentRun ?? args["multi-agent-run"]);
|
|
186
|
+
}
|
|
187
|
+
function groupArg(args) {
|
|
188
|
+
return optionalString(args.groupId ?? args.group ?? args["multi-agent-group"]);
|
|
189
|
+
}
|
|
190
|
+
/** `--blackboard <id>` — byte-exact to the old build's
|
|
191
|
+
* `options.blackboard || options.blackboardId` read
|
|
192
|
+
* (orchestrator/multi-agent-operations.ts). parseArgv keeps `--blackboard`
|
|
193
|
+
* as the literal key `blackboard`; the MCP surface also accepts
|
|
194
|
+
* `blackboardId`. */
|
|
195
|
+
function blackboardIdArg(args) {
|
|
196
|
+
return optionalString(args.blackboard ?? args.blackboardId);
|
|
197
|
+
}
|
|
198
|
+
/** `--topic <id>` (repeatable) — byte-exact to the old build's
|
|
199
|
+
* `options.topic || options.topicId || options.topics` read. */
|
|
200
|
+
function topicIdsArg(args) {
|
|
201
|
+
const raw = args.topic ?? args.topicId ?? args.topics;
|
|
202
|
+
return arrayArg(raw);
|
|
203
|
+
}
|
|
204
|
+
/** `--author-id`/`--author-kind`/`--author-name` (or the `worker`/`role`/
|
|
205
|
+
* `group` fallbacks) — byte-exact port of parseBlackboardAuthor
|
|
206
|
+
* (orchestrator/cli-options.ts). Threaded into every blackboard write so a
|
|
207
|
+
* message/context/artifact carries the posting role, not the default. */
|
|
208
|
+
function parseBlackboardAuthorCli(args) {
|
|
209
|
+
const structured = args.author;
|
|
210
|
+
if (structured && typeof structured === "object" && !Array.isArray(structured))
|
|
211
|
+
return structured;
|
|
212
|
+
const id = optionalString(args.authorId ?? args.author ?? args.worker ?? args.workerId ?? args.role ?? args.roleId ?? args.group ?? args.groupId);
|
|
213
|
+
const kind = optionalString(args.authorKind ?? args.sourceKind ?? args.source);
|
|
214
|
+
const displayName = optionalString(args.authorName ?? args.displayName);
|
|
215
|
+
if (!id && !kind && !displayName)
|
|
216
|
+
return undefined;
|
|
217
|
+
return { kind, id, displayName };
|
|
218
|
+
}
|
|
219
|
+
/** `--scope-kind`/`--scope-id` — byte-exact port of parseBlackboardScope. */
|
|
220
|
+
function parseBlackboardScopeCli(args) {
|
|
221
|
+
const structured = args.scope;
|
|
222
|
+
if (structured && typeof structured === "object" && !Array.isArray(structured))
|
|
223
|
+
return structured;
|
|
224
|
+
const kind = optionalString(args.scopeKind);
|
|
225
|
+
const id = optionalString(args.scopeId);
|
|
226
|
+
if (!kind && !id)
|
|
227
|
+
return undefined;
|
|
228
|
+
return { kind, id };
|
|
229
|
+
}
|
|
230
|
+
/** `--multi-agent-*`/`--task`/`--worker`/`--evidence` etc → BlackboardLinks —
|
|
231
|
+
* byte-exact port of parseBlackboardLinks (orchestrator/cli-options.ts). */
|
|
232
|
+
function parseBlackboardLinksCli(runId, args) {
|
|
233
|
+
const structured = args.provenance ?? args.links;
|
|
234
|
+
if (structured && typeof structured === "object" && !Array.isArray(structured))
|
|
235
|
+
return structured;
|
|
236
|
+
const links = {
|
|
237
|
+
workflowRunId: runId,
|
|
238
|
+
multiAgentRunId: multiAgentRunArg(args),
|
|
239
|
+
agentGroupId: groupArg(args),
|
|
240
|
+
agentRoleId: optionalString(args.role ?? args.roleId ?? args["multi-agent-role"]),
|
|
241
|
+
agentMembershipId: optionalString(args.membership ?? args.membershipId ?? args["multi-agent-membership"]),
|
|
242
|
+
agentFanoutId: optionalString(args.fanout ?? args.fanoutId ?? args["multi-agent-fanout"]),
|
|
243
|
+
agentFaninId: optionalString(args.fanin ?? args.faninId ?? args["multi-agent-fanin"]),
|
|
244
|
+
taskId: optionalString(args.task ?? args.taskId),
|
|
245
|
+
workerId: optionalString(args.worker ?? args.workerId),
|
|
246
|
+
candidateId: optionalString(args.candidate ?? args.candidateId),
|
|
247
|
+
verifierNodeId: optionalString(args.verifier ?? args.verifierNode ?? args.verifierNodeId),
|
|
248
|
+
commitId: optionalString(args.commit ?? args.commitId),
|
|
249
|
+
auditEventIds: arrayArg(args.audit ?? args.auditEvent ?? args.auditEventId ?? args["audit-event"]),
|
|
250
|
+
evidenceRefs: arrayArg(args.evidence ?? args.evidenceRef ?? args["evidence-ref"]),
|
|
251
|
+
};
|
|
252
|
+
const entries = Object.entries(links).filter(([, value]) => value !== undefined && (!Array.isArray(value) || value.length));
|
|
253
|
+
return entries.length > 1 ? Object.fromEntries(entries) : undefined;
|
|
254
|
+
}
|
|
255
|
+
/** `--sandbox-choice role=profile` (repeatable) — byte-exact port of the old
|
|
256
|
+
* build's parseSandboxChoices (orchestrator/cli-options.ts): merges a
|
|
257
|
+
* structured `sandboxChoices`/`sandboxProfileChoices` object with repeated
|
|
258
|
+
* `--sandbox-choice`/`sandboxChoice` `key=value` pairs, then falls back to a
|
|
259
|
+
* bare `--sandbox` as the `default` choice only when no explicit choice was
|
|
260
|
+
* given. */
|
|
261
|
+
function parseSandboxChoicesCli(args) {
|
|
262
|
+
const choices = {};
|
|
263
|
+
const structured = args.sandboxChoices ?? args.sandboxProfileChoices;
|
|
264
|
+
if (structured && typeof structured === "object" && !Array.isArray(structured)) {
|
|
265
|
+
for (const [key, value] of Object.entries(structured))
|
|
266
|
+
choices[key] = String(value);
|
|
267
|
+
}
|
|
268
|
+
for (const entry of arrayArg(args.sandboxChoice ?? args["sandbox-choice"])) {
|
|
269
|
+
const [key, ...rest] = String(entry).split("=");
|
|
270
|
+
if (key && rest.length)
|
|
271
|
+
choices[key] = rest.join("=");
|
|
272
|
+
}
|
|
273
|
+
const sandbox = optionalString(args.sandbox ?? args.sandboxProfile ?? args.sandboxProfileId);
|
|
274
|
+
if (sandbox && !Object.keys(choices).length)
|
|
275
|
+
choices.default = sandbox;
|
|
276
|
+
return Object.keys(choices).length ? choices : undefined;
|
|
277
|
+
}
|
|
278
|
+
// ---------------------------------------------------------------------------
|
|
279
|
+
// Topology (catalog — no run needed)
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
function topologyList() {
|
|
282
|
+
return (0, topology_1.listTopologyDefinitions)();
|
|
283
|
+
}
|
|
284
|
+
function topologyShowCli(topologyId) {
|
|
285
|
+
const definition = (0, topology_1.getTopologyDefinition)(topologyId);
|
|
286
|
+
if (!definition)
|
|
287
|
+
throw new Error(`Unknown topology id: ${topologyId}`);
|
|
288
|
+
return definition;
|
|
289
|
+
}
|
|
290
|
+
function topologyValidateCli(topologyId) {
|
|
291
|
+
const result = (0, topology_1.validateTopologyDefinition)(topologyId);
|
|
292
|
+
return { valid: result.valid, topologyId: result.topologyId, issues: result.issues };
|
|
293
|
+
}
|
|
294
|
+
function topologyApplyCli(args) {
|
|
295
|
+
const runId = requireArg(args.runId, "run id");
|
|
296
|
+
const topologyId = requireArg(args.topologyId ?? args.id, "topology id");
|
|
297
|
+
const run = loadRun(args, runId);
|
|
298
|
+
const record = topio.applyTopology(run, topologyId, {
|
|
299
|
+
// #30: `topology apply <run> <topology> --id <custom>` — the custom
|
|
300
|
+
// topology-run id arrives as `--id` (parseArgv key `id`), NOT `id2`
|
|
301
|
+
// (which no CLI/MCP surface ever emits). On CLI the topology id comes
|
|
302
|
+
// from positional[1] (capability-table), so `args.id` is free for the
|
|
303
|
+
// run-id override; on MCP the handler pre-maps topologyId from
|
|
304
|
+
// `topologyId ?? id`. Byte-exact to the old build's
|
|
305
|
+
// `id: stringOption(options.id)` (orchestrator/topology-operations.ts).
|
|
306
|
+
id: optionalString(args.id),
|
|
307
|
+
task: undefined,
|
|
308
|
+
taskIds: arrayArg(args.task ?? args.taskId),
|
|
309
|
+
mapperCount: numberArg(args.mapperCount ?? args["mapper-count"] ?? args.mappers ?? args.mapper),
|
|
310
|
+
judgeCount: numberArg(args.judgeCount ?? args["judge-count"] ?? args.judges ?? args.judge),
|
|
311
|
+
debateRounds: numberArg(args.debateRounds ?? args["debate-rounds"] ?? args.rounds),
|
|
312
|
+
blackboardId: blackboardIdArg(args),
|
|
313
|
+
multiAgentRunId: multiAgentRunArg(args),
|
|
314
|
+
collectInitialFanin: boolArg(args.collectInitialFanin ?? args["collect-initial-fanin"]),
|
|
315
|
+
});
|
|
316
|
+
persist(run);
|
|
317
|
+
return record;
|
|
318
|
+
}
|
|
319
|
+
function topologySummaryCli(args) {
|
|
320
|
+
const runId = requireArg(args.runId, "run id");
|
|
321
|
+
const run = loadRun(args, runId);
|
|
322
|
+
return topio.summarizeTopologies(run);
|
|
323
|
+
}
|
|
324
|
+
function topologyGraphCli(args) {
|
|
325
|
+
const runId = requireArg(args.runId, "run id");
|
|
326
|
+
const run = loadRun(args, runId);
|
|
327
|
+
return topio.buildTopologyGraph(run);
|
|
328
|
+
}
|
|
329
|
+
function topologyRunShowCli(args, topologyRunId) {
|
|
330
|
+
const runId = requireArg(args.runId, "run id");
|
|
331
|
+
const run = loadRun(args, runId);
|
|
332
|
+
return topio.showTopologyRun(run, topologyRunId);
|
|
333
|
+
}
|
|
334
|
+
// ---------------------------------------------------------------------------
|
|
335
|
+
// Multi-agent kernel (CLI verbs: run/status/step/blackboard/score/select via
|
|
336
|
+
// the host, plus role/group/membership/fanout/fanin/show for direct kernel
|
|
337
|
+
// access, per SPEC/multi-agent.md section J).
|
|
338
|
+
// ---------------------------------------------------------------------------
|
|
339
|
+
function multiAgentRunCli(args) {
|
|
340
|
+
const runId = requireArg(args.runId, "run id");
|
|
341
|
+
const run = loadRun(args, runId);
|
|
342
|
+
const topology = optionalString(args.topology);
|
|
343
|
+
// `multi-agent run <run> <id> --status <status>` — port of the old CLI
|
|
344
|
+
// handler's `id && args.options.status` arm (cli/handlers/multi-agent.ts):
|
|
345
|
+
// transition the MultiAgentRun lifecycle (the core cascades completion to
|
|
346
|
+
// owned roles/groups/fanouts/fanins, or fails closed when a fanin is not
|
|
347
|
+
// verifier-ready). `multiAgentRunId` is the positional entity id the CLI
|
|
348
|
+
// binding forwards (or the `--id`/`--multi-agent-run` alias the MCP peer
|
|
349
|
+
// sends).
|
|
350
|
+
const transitionId = optionalString(args.multiAgentRunId ?? args.id ?? args.multiAgentRun);
|
|
351
|
+
const status = optionalString(args.status);
|
|
352
|
+
const app = optionalString(args.app ?? args.appId);
|
|
353
|
+
const workflow = optionalString(args.workflow ?? args.workflowId);
|
|
354
|
+
const isHostRun = !runId || topology !== undefined || app !== undefined || workflow !== undefined;
|
|
355
|
+
if (!isHostRun && transitionId && status && args.title === undefined && args.objective === undefined) {
|
|
356
|
+
const record = mai.transitionMultiAgentRun(run, transitionId, status, {
|
|
357
|
+
reason: optionalString(args.reason),
|
|
358
|
+
actor: optionalString(args.actor),
|
|
359
|
+
});
|
|
360
|
+
persist(run);
|
|
361
|
+
return record;
|
|
362
|
+
}
|
|
363
|
+
if (!isHostRun && transitionId && !status && args.title === undefined && args.objective === undefined && args.id === undefined) {
|
|
364
|
+
// `multi-agent run <run> <id>` (positional id, no status/create flags) —
|
|
365
|
+
// SHOW the MultiAgentRun record (old handler's showMultiAgentRun arm).
|
|
366
|
+
const record = (0, runtime_1.getMultiAgentRun)(run, transitionId);
|
|
367
|
+
if (!record)
|
|
368
|
+
throw new Error(`Unknown MultiAgentRun id: ${transitionId}`);
|
|
369
|
+
return record;
|
|
370
|
+
}
|
|
371
|
+
let result;
|
|
372
|
+
if (topology === undefined && (args.id !== undefined || args.title !== undefined)) {
|
|
373
|
+
// #28: forward `--blackboard`/`--topic` (plus the old build's
|
|
374
|
+
// objective/parent/phase reads) into the kernel input so a plain
|
|
375
|
+
// `multi-agent run <run> --id ma --blackboard bb --topic t` carries the
|
|
376
|
+
// blackboard linkage. Byte-exact to the old build's createMultiAgentRun
|
|
377
|
+
// option map (orchestrator/multi-agent-operations.ts).
|
|
378
|
+
result = mai.createMultiAgentRun(run, {
|
|
379
|
+
id: optionalString(args.id),
|
|
380
|
+
title: optionalString(args.title),
|
|
381
|
+
objective: optionalString(args.objective ?? args.reason),
|
|
382
|
+
parentMultiAgentRunId: optionalString(args.parent ?? args.parentMultiAgentRunId),
|
|
383
|
+
phase: optionalString(args.phase),
|
|
384
|
+
phaseId: optionalString(args.phaseId),
|
|
385
|
+
blackboardId: blackboardIdArg(args),
|
|
386
|
+
topicIds: topicIdsArg(args),
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
result = host.hostRun(run, args);
|
|
391
|
+
}
|
|
392
|
+
persist(run);
|
|
393
|
+
return result;
|
|
394
|
+
}
|
|
395
|
+
function multiAgentStatusCli(args) {
|
|
396
|
+
const runId = requireArg(args.runId, "run id");
|
|
397
|
+
const run = loadRun(args, runId);
|
|
398
|
+
return host.hostStatus(run);
|
|
399
|
+
}
|
|
400
|
+
/** `cw multi-agent status <run>` human text — the operator-UX status panel
|
|
401
|
+
* (Agent Graph / Dependencies / Failed-Blocked / Adopted-Missing Evidence
|
|
402
|
+
* / Next Action). Port of the old CLI handler's non-`--json` status arm
|
|
403
|
+
* (cli/handlers/multi-agent.ts). */
|
|
404
|
+
function multiAgentStatusText(args) {
|
|
405
|
+
const runId = requireArg(args.runId, "run id");
|
|
406
|
+
const run = loadRun(args, runId);
|
|
407
|
+
return (0, multi_agent_operator_ux_1.formatMultiAgentOperatorStatus)((0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run));
|
|
408
|
+
}
|
|
409
|
+
/** `cw multi-agent dependencies <run>` — derived dependency edges (JSON). */
|
|
410
|
+
function multiAgentDependenciesCli(args) {
|
|
411
|
+
const runId = requireArg(args.runId, "run id");
|
|
412
|
+
const run = loadRun(args, runId);
|
|
413
|
+
return (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).dependencies;
|
|
414
|
+
}
|
|
415
|
+
function multiAgentDependenciesText(args) {
|
|
416
|
+
const runId = requireArg(args.runId, "run id");
|
|
417
|
+
const run = loadRun(args, runId);
|
|
418
|
+
return (0, multi_agent_operator_ux_1.formatMultiAgentDependencies)((0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).dependencies);
|
|
419
|
+
}
|
|
420
|
+
/** `cw multi-agent failures <run>` — failed/blocked/rejected/ambiguous rows. */
|
|
421
|
+
function multiAgentFailuresCli(args) {
|
|
422
|
+
const runId = requireArg(args.runId, "run id");
|
|
423
|
+
const run = loadRun(args, runId);
|
|
424
|
+
return (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).failures;
|
|
425
|
+
}
|
|
426
|
+
function multiAgentFailuresText(args) {
|
|
427
|
+
const runId = requireArg(args.runId, "run id");
|
|
428
|
+
const run = loadRun(args, runId);
|
|
429
|
+
return (0, multi_agent_operator_ux_1.formatMultiAgentFailures)((0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).failures);
|
|
430
|
+
}
|
|
431
|
+
/** `cw multi-agent evidence <run>` — evidence adoption rows, each additively
|
|
432
|
+
* enriched with the derived rationaleStatus (explained|unexplained|
|
|
433
|
+
* not-applicable) from the reasoning report. Port of the old
|
|
434
|
+
* runner.multiAgentEvidence enrichment. */
|
|
435
|
+
function multiAgentEvidenceCli(args) {
|
|
436
|
+
const runId = requireArg(args.runId, "run id");
|
|
437
|
+
const run = loadRun(args, runId);
|
|
438
|
+
const rows = (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).evidence;
|
|
439
|
+
const report = reasoning.buildEvidenceReasoningReport(run, { index: reasoning.loadEvidenceReasoningIndex(run) });
|
|
440
|
+
const byId = new Map(report.chains.map((chain) => [chain.id, chain.rationaleStatus]));
|
|
441
|
+
for (const row of rows)
|
|
442
|
+
row.rationaleStatus = byId.get(row.id) ?? "not-applicable";
|
|
443
|
+
return rows;
|
|
444
|
+
}
|
|
445
|
+
/** `cw multi-agent reasoning <run> [--refresh] [--evidence <id>]` — the
|
|
446
|
+
* evidence adoption reasoning report (or a durable-index refresh). Port of
|
|
447
|
+
* the old runner.multiAgentReasoning / multiAgentReasoningRefresh. */
|
|
448
|
+
function multiAgentReasoningCli(args) {
|
|
449
|
+
const runId = requireArg(args.runId, "run id");
|
|
450
|
+
const run = loadRun(args, runId);
|
|
451
|
+
const evidenceId = optionalString(args.evidence ?? args.evidenceId ?? args.id);
|
|
452
|
+
if (args.refresh && !evidenceId) {
|
|
453
|
+
const index = reasoning.refreshEvidenceReasoning(run);
|
|
454
|
+
persist(run);
|
|
455
|
+
return index;
|
|
456
|
+
}
|
|
457
|
+
return reasoning.showEvidenceReasoning(run, { evidenceId });
|
|
458
|
+
}
|
|
459
|
+
function multiAgentReasoningText(args) {
|
|
460
|
+
const runId = requireArg(args.runId, "run id");
|
|
461
|
+
const run = loadRun(args, runId);
|
|
462
|
+
const evidenceId = optionalString(args.evidence ?? args.evidenceId ?? args.id);
|
|
463
|
+
return reasoning.formatEvidenceReasoningReport(reasoning.showEvidenceReasoning(run, { evidenceId }));
|
|
464
|
+
}
|
|
465
|
+
function multiAgentReasoningRefreshCli(args) {
|
|
466
|
+
const runId = requireArg(args.runId, "run id");
|
|
467
|
+
const run = loadRun(args, runId);
|
|
468
|
+
const index = reasoning.refreshEvidenceReasoning(run);
|
|
469
|
+
persist(run);
|
|
470
|
+
return index;
|
|
471
|
+
}
|
|
472
|
+
function multiAgentEvidenceText(args) {
|
|
473
|
+
const runId = requireArg(args.runId, "run id");
|
|
474
|
+
const run = loadRun(args, runId);
|
|
475
|
+
const rows = (0, multi_agent_operator_ux_1.summarizeMultiAgentOperator)(run).evidence;
|
|
476
|
+
const report = reasoning.buildEvidenceReasoningReport(run, { index: reasoning.loadEvidenceReasoningIndex(run) });
|
|
477
|
+
const byId = new Map(report.chains.map((chain) => [chain.id, chain.rationaleStatus]));
|
|
478
|
+
for (const row of rows)
|
|
479
|
+
row.rationaleStatus = byId.get(row.id) ?? "not-applicable";
|
|
480
|
+
return (0, multi_agent_operator_ux_1.formatMultiAgentEvidence)(rows);
|
|
481
|
+
}
|
|
482
|
+
function multiAgentStepCli(args) {
|
|
483
|
+
const runId = requireArg(args.runId, "run id");
|
|
484
|
+
const run = loadRun(args, runId);
|
|
485
|
+
const result = host.hostStep(run, args);
|
|
486
|
+
persist(run);
|
|
487
|
+
return result;
|
|
488
|
+
}
|
|
489
|
+
function multiAgentBlackboardCli(args, action) {
|
|
490
|
+
const runId = requireArg(args.runId, "run id");
|
|
491
|
+
const run = loadRun(args, runId);
|
|
492
|
+
const result = host.hostBlackboard(run, action, args);
|
|
493
|
+
persist(run);
|
|
494
|
+
return result;
|
|
495
|
+
}
|
|
496
|
+
function multiAgentScoreCli(args) {
|
|
497
|
+
const runId = requireArg(args.runId, "run id");
|
|
498
|
+
const run = loadRun(args, runId);
|
|
499
|
+
const result = host.hostScore(run, args);
|
|
500
|
+
persist(run);
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
function multiAgentSelectCli(args) {
|
|
504
|
+
const runId = requireArg(args.runId, "run id");
|
|
505
|
+
const run = loadRun(args, runId);
|
|
506
|
+
const result = host.hostSelect(run, args);
|
|
507
|
+
persist(run);
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
function multiAgentRoleCli(args) {
|
|
511
|
+
const runId = requireArg(args.runId, "run id");
|
|
512
|
+
const run = loadRun(args, runId);
|
|
513
|
+
const roleId = optionalString(args.roleId);
|
|
514
|
+
const multiAgentRunId = multiAgentRunArg(args);
|
|
515
|
+
if (roleId && !args.id && !multiAgentRunId) {
|
|
516
|
+
const role = (0, runtime_1.getAgentRole)(run, roleId);
|
|
517
|
+
if (!role)
|
|
518
|
+
throw new Error(`Unknown AgentRole id: ${roleId}`);
|
|
519
|
+
return role;
|
|
520
|
+
}
|
|
521
|
+
// #29: parseArgv keeps `--required-evidence` etc. as their literal kebab
|
|
522
|
+
// keys, so the old camelCase-only reads folded to []. Read BOTH the kebab
|
|
523
|
+
// CLI key and the camelCase MCP alias, byte-exact to the old build's
|
|
524
|
+
// createAgentRole option map (orchestrator/multi-agent-operations.ts).
|
|
525
|
+
const role = mai.createAgentRole(run, {
|
|
526
|
+
id: optionalString(args.id) ?? roleId,
|
|
527
|
+
multiAgentRunId: requireArg(multiAgentRunId, "multi-agent run id"),
|
|
528
|
+
title: optionalString(args.title),
|
|
529
|
+
responsibilities: arrayArg(args.responsibility ?? args.responsibilities),
|
|
530
|
+
requiredEvidence: arrayArg(args.requiredEvidence ?? args["required-evidence"]),
|
|
531
|
+
sandboxProfileHints: arrayArg(args.sandbox ?? args.sandboxProfile ?? args.sandboxProfileHint ?? args["sandbox-profile"]),
|
|
532
|
+
expectedArtifacts: arrayArg(args.expectedArtifact ?? args.expectedArtifacts ?? args["expected-artifact"]),
|
|
533
|
+
faninObligations: arrayArg(args.faninObligation ?? args.faninObligations ?? args["fanin-obligation"]),
|
|
534
|
+
parentRoleId: optionalString(args.parent ?? args.parentRoleId),
|
|
535
|
+
blackboardId: blackboardIdArg(args),
|
|
536
|
+
topicIds: topicIdsArg(args),
|
|
537
|
+
});
|
|
538
|
+
persist(run);
|
|
539
|
+
return role;
|
|
540
|
+
}
|
|
541
|
+
function multiAgentGroupCli(args) {
|
|
542
|
+
const runId = requireArg(args.runId, "run id");
|
|
543
|
+
const run = loadRun(args, runId);
|
|
544
|
+
const groupId = optionalString(args.groupId);
|
|
545
|
+
const multiAgentRunId = multiAgentRunArg(args);
|
|
546
|
+
if (groupId && !args.id && !multiAgentRunId) {
|
|
547
|
+
const group = (0, runtime_1.getAgentGroup)(run, groupId);
|
|
548
|
+
if (!group)
|
|
549
|
+
throw new Error(`Unknown AgentGroup id: ${groupId}`);
|
|
550
|
+
return group;
|
|
551
|
+
}
|
|
552
|
+
// #28: forward `--blackboard`/`--topic` (plus phaseId/parent) into the
|
|
553
|
+
// kernel input. Byte-exact to the old createAgentGroup option map.
|
|
554
|
+
const group = mai.createAgentGroup(run, {
|
|
555
|
+
id: optionalString(args.id) ?? groupId,
|
|
556
|
+
multiAgentRunId: requireArg(multiAgentRunId, "multi-agent run id"),
|
|
557
|
+
title: optionalString(args.title),
|
|
558
|
+
phase: optionalString(args.phase),
|
|
559
|
+
phaseId: optionalString(args.phaseId),
|
|
560
|
+
taskIds: arrayArg(args.task ?? args.taskId ?? args.tasks),
|
|
561
|
+
parentGroupId: optionalString(args.parent ?? args.parentGroupId),
|
|
562
|
+
blackboardId: blackboardIdArg(args),
|
|
563
|
+
topicIds: topicIdsArg(args),
|
|
564
|
+
});
|
|
565
|
+
persist(run);
|
|
566
|
+
return group;
|
|
567
|
+
}
|
|
568
|
+
function multiAgentMembershipCli(args) {
|
|
569
|
+
const runId = requireArg(args.runId, "run id");
|
|
570
|
+
const run = loadRun(args, runId);
|
|
571
|
+
const membershipId = optionalString(args.membershipId);
|
|
572
|
+
const groupId = groupArg(args);
|
|
573
|
+
const roleId = optionalString(args.roleId ?? args.role);
|
|
574
|
+
if (membershipId && !args.id && !groupId && !roleId) {
|
|
575
|
+
const membership = (0, runtime_1.getAgentMembership)(run, membershipId);
|
|
576
|
+
if (!membership)
|
|
577
|
+
throw new Error(`Unknown AgentMembership id: ${membershipId}`);
|
|
578
|
+
return membership;
|
|
579
|
+
}
|
|
580
|
+
// #28: forward `--blackboard`/`--topic` (plus multiAgentRunId/status) into
|
|
581
|
+
// the kernel input. Byte-exact to the old assignAgentMembership option map.
|
|
582
|
+
const membership = mai.assignAgentMembership(run, {
|
|
583
|
+
id: optionalString(args.id) ?? membershipId,
|
|
584
|
+
multiAgentRunId: multiAgentRunArg(args),
|
|
585
|
+
groupId: requireArg(groupId, "group id"),
|
|
586
|
+
roleId: requireArg(roleId, "role id"),
|
|
587
|
+
taskId: requireArg(args.taskId ?? args.task, "task id"),
|
|
588
|
+
workerId: optionalString(args.workerId ?? args.worker),
|
|
589
|
+
dispatchId: optionalString(args.dispatchId ?? args.dispatch),
|
|
590
|
+
fanoutId: optionalString(args.fanoutId ?? args.fanout ?? args["multi-agent-fanout"]),
|
|
591
|
+
status: optionalString(args.status),
|
|
592
|
+
blackboardId: blackboardIdArg(args),
|
|
593
|
+
topicIds: topicIdsArg(args),
|
|
594
|
+
});
|
|
595
|
+
persist(run);
|
|
596
|
+
return membership;
|
|
597
|
+
}
|
|
598
|
+
function multiAgentFanoutCli(args) {
|
|
599
|
+
const runId = requireArg(args.runId, "run id");
|
|
600
|
+
const run = loadRun(args, runId);
|
|
601
|
+
const fanoutId = optionalString(args.fanoutId);
|
|
602
|
+
const groupId = groupArg(args);
|
|
603
|
+
if (fanoutId && !args.id && !groupId) {
|
|
604
|
+
const fanout = (0, runtime_1.getAgentFanout)(run, fanoutId);
|
|
605
|
+
if (!fanout)
|
|
606
|
+
throw new Error(`Unknown AgentFanout id: ${fanoutId}`);
|
|
607
|
+
return fanout;
|
|
608
|
+
}
|
|
609
|
+
// #28: forward `--blackboard`/`--topic` so `fanout.blackboardId` inherits
|
|
610
|
+
// the board (kernel: input.blackboardId || group.blackboardId ||
|
|
611
|
+
// multiAgentRun.blackboardId). Also port the old build's fuller fanout
|
|
612
|
+
// reads (multiAgentRunId, workerIds/membershipIds/dispatchIds,
|
|
613
|
+
// sandboxProfileChoices, expectedReturnShape).
|
|
614
|
+
const fanout = mai.createAgentFanout(run, {
|
|
615
|
+
id: optionalString(args.id) ?? fanoutId,
|
|
616
|
+
multiAgentRunId: multiAgentRunArg(args),
|
|
617
|
+
groupId: requireArg(groupId, "group id"),
|
|
618
|
+
reason: requireArg(args.reason, "reason"),
|
|
619
|
+
roleIds: arrayArg(args.role ?? args.roleId ?? args.roles),
|
|
620
|
+
taskIds: arrayArg(args.task ?? args.taskId ?? args.tasks),
|
|
621
|
+
workerIds: arrayArg(args.worker ?? args.workerId ?? args.workers),
|
|
622
|
+
membershipIds: arrayArg(args.membership ?? args.membershipId ?? args.memberships),
|
|
623
|
+
dispatchIds: arrayArg(args.dispatch ?? args.dispatchId ?? args.dispatches),
|
|
624
|
+
concurrencyLimit: numberArg(args.limit ?? args.concurrency ?? args.concurrencyLimit),
|
|
625
|
+
sandboxProfileChoices: parseSandboxChoicesCli(args),
|
|
626
|
+
expectedReturnShape: optionalString(args.expectedReturnShape ?? args["expected-return-shape"]),
|
|
627
|
+
blackboardId: blackboardIdArg(args),
|
|
628
|
+
topicIds: topicIdsArg(args),
|
|
629
|
+
});
|
|
630
|
+
persist(run);
|
|
631
|
+
return fanout;
|
|
632
|
+
}
|
|
633
|
+
function multiAgentFaninCli(args) {
|
|
634
|
+
const runId = requireArg(args.runId, "run id");
|
|
635
|
+
const run = loadRun(args, runId);
|
|
636
|
+
const faninId = optionalString(args.faninId);
|
|
637
|
+
const groupId = groupArg(args);
|
|
638
|
+
const fanoutId = optionalString(args.fanoutId ?? args.fanout);
|
|
639
|
+
if (faninId && !args.id && !groupId && !fanoutId) {
|
|
640
|
+
const fanin = (0, runtime_1.getAgentFanin)(run, faninId);
|
|
641
|
+
if (!fanin)
|
|
642
|
+
throw new Error(`Unknown AgentFanin id: ${faninId}`);
|
|
643
|
+
return fanin;
|
|
644
|
+
}
|
|
645
|
+
// #29: `--required-role` folds to the kebab key `required-role`; read the
|
|
646
|
+
// kebab + camelCase aliases. #28: forward `--blackboard`/`--topic` +
|
|
647
|
+
// multiAgentRunId. Byte-exact to the old collectAgentFanin option map.
|
|
648
|
+
const fanin = mai.collectAgentFanin(run, {
|
|
649
|
+
id: optionalString(args.id) ?? faninId,
|
|
650
|
+
multiAgentRunId: multiAgentRunArg(args),
|
|
651
|
+
groupId,
|
|
652
|
+
fanoutId,
|
|
653
|
+
requiredRoleIds: arrayArg(args.requiredRole ?? args.requiredRoleId ?? args["required-role"]),
|
|
654
|
+
strategy: optionalString(args.strategy),
|
|
655
|
+
blackboardId: blackboardIdArg(args),
|
|
656
|
+
topicIds: topicIdsArg(args),
|
|
657
|
+
});
|
|
658
|
+
persist(run);
|
|
659
|
+
return fanin;
|
|
660
|
+
}
|
|
661
|
+
function multiAgentShowCli(args, id) {
|
|
662
|
+
const runId = requireArg(args.runId, "run id");
|
|
663
|
+
const run = loadRun(args, runId);
|
|
664
|
+
const record = (0, runtime_1.getMultiAgentRun)(run, id);
|
|
665
|
+
if (!record)
|
|
666
|
+
throw new Error(`Unknown MultiAgentRun id: ${id}`);
|
|
667
|
+
return record;
|
|
668
|
+
}
|
|
669
|
+
function multiAgentSummaryCli(args) {
|
|
670
|
+
const runId = requireArg(args.runId, "run id");
|
|
671
|
+
const run = loadRun(args, runId);
|
|
672
|
+
return mai.summarizeMultiAgent(run);
|
|
673
|
+
}
|
|
674
|
+
/** `cw multi-agent summarize <run>` / `cw_multi_agent_summarize` — the
|
|
675
|
+
* combined state-explosion report (loads the persisted summary index when
|
|
676
|
+
* present). Port of the old runner.multiAgentSummarize. */
|
|
677
|
+
function multiAgentSummarizeCli(args) {
|
|
678
|
+
const runId = requireArg(args.runId, "run id");
|
|
679
|
+
const run = loadRun(args, runId);
|
|
680
|
+
return (0, report_2.buildStateExplosionReport)(run, { index: (0, state_explosion_cli_1.loadStateExplosionSummaryIndex)(run), operator: (0, multi_agent_operator_ux_1.operatorDigestInput)(run) });
|
|
681
|
+
}
|
|
682
|
+
/** `cw_multi_agent_graph_compact` — a compact/focused multi-agent graph
|
|
683
|
+
* view. Port of the old runner.multiAgentGraphView. */
|
|
684
|
+
function multiAgentGraphCompactCli(args) {
|
|
685
|
+
const runId = requireArg(args.runId, "run id");
|
|
686
|
+
const run = loadRun(args, runId);
|
|
687
|
+
const view = optionalString(args.view);
|
|
688
|
+
// Protect every reasoning-chain decision-gate node from collapse (the old
|
|
689
|
+
// build fed reasoningCriticalNodeIds into buildCompactGraph so an adopted
|
|
690
|
+
// chain's score/selection/commit/fanin nodes survive compaction).
|
|
691
|
+
return (0, graph_1.buildCompactGraphFromView)(run.id, (0, graph_1.runToGraphViewFromWorkflowRun)(run), view || "compact", {
|
|
692
|
+
focus: optionalString(args.focus),
|
|
693
|
+
depth: numberArg(args.depth),
|
|
694
|
+
reasoningCriticalIds: reasoning.reasoningCriticalNodeIds(run),
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
/** `cw blackboard summarize <run>` / `cw_blackboard_summarize` — a blackboard
|
|
698
|
+
* digest with conflicts/evidence. Port of the old runner.blackboardSummarize. */
|
|
699
|
+
function blackboardSummarizeCli(args) {
|
|
700
|
+
const runId = requireArg(args.runId, "run id");
|
|
701
|
+
const run = loadRun(args, runId);
|
|
702
|
+
return (0, digest_1.summarizeBlackboardDigest)({ id: run.id, blackboard: run.blackboard }, blackboardIdArg(args));
|
|
703
|
+
}
|
|
704
|
+
/** `cw contract show <run> [contract-id]` / `cw_contract_show` — the run's
|
|
705
|
+
* resolved pipeline contract. Port of the old runner.showContract. */
|
|
706
|
+
function contractShowCli(args, contractId) {
|
|
707
|
+
const runId = requireArg(args.runId, "run id");
|
|
708
|
+
const run = loadRun(args, runId);
|
|
709
|
+
return (0, runner_1.getRunContract)(run, contractId ?? optionalString(args.contractId));
|
|
710
|
+
}
|
|
711
|
+
function multiAgentGraphCli(args) {
|
|
712
|
+
const runId = requireArg(args.runId, "run id");
|
|
713
|
+
const run = loadRun(args, runId);
|
|
714
|
+
return (0, multi_agent_operator_ux_1.buildMultiAgentOperatorGraph)(run);
|
|
715
|
+
}
|
|
716
|
+
/** `cw multi-agent graph <run>` human text — the operator graph render
|
|
717
|
+
* (nodes grouped by kind, then edges). Reuses the operator-ux graph
|
|
718
|
+
* formatter so `cw graph` and `cw multi-agent graph` render identically. */
|
|
719
|
+
function multiAgentGraphText(args) {
|
|
720
|
+
const runId = requireArg(args.runId, "run id");
|
|
721
|
+
const run = loadRun(args, runId);
|
|
722
|
+
return (0, operator_ux_text_1.formatOperatorGraph)((0, multi_agent_operator_ux_1.buildMultiAgentOperatorGraph)(run));
|
|
723
|
+
}
|
|
724
|
+
// ---------------------------------------------------------------------------
|
|
725
|
+
// Blackboard / coordinator
|
|
726
|
+
// ---------------------------------------------------------------------------
|
|
727
|
+
function blackboardSummaryCli(args) {
|
|
728
|
+
const runId = requireArg(args.runId, "run id");
|
|
729
|
+
const run = loadRun(args, runId);
|
|
730
|
+
return coord.summarizeBlackboard(run, optionalString(args.blackboardId));
|
|
731
|
+
}
|
|
732
|
+
function blackboardGraphCli(args) {
|
|
733
|
+
const runId = requireArg(args.runId, "run id");
|
|
734
|
+
const run = loadRun(args, runId);
|
|
735
|
+
return coord.buildBlackboardGraph(run);
|
|
736
|
+
}
|
|
737
|
+
function blackboardResolveCli(args) {
|
|
738
|
+
const runId = requireArg(args.runId, "run id");
|
|
739
|
+
const run = loadRun(args, runId);
|
|
740
|
+
const board = coord.resolveBlackboard(run, { id: optionalString(args.id), title: optionalString(args.title), multiAgentRunId: optionalString(args.multiAgentRunId), groupId: optionalString(args.groupId), roleId: optionalString(args.roleId), membershipId: optionalString(args.membershipId) });
|
|
741
|
+
persist(run);
|
|
742
|
+
return board;
|
|
743
|
+
}
|
|
744
|
+
function blackboardTopicCreateCli(args) {
|
|
745
|
+
const runId = requireArg(args.runId, "run id");
|
|
746
|
+
const run = loadRun(args, runId);
|
|
747
|
+
const topic = coord.createBlackboardTopic(run, { id: optionalString(args.id), title: requireArg(args.title, "topic title"), description: optionalString(args.description), blackboardId: optionalString(args.blackboardId), author: parseBlackboardAuthorCli(args), scope: parseBlackboardScopeCli(args), tags: arrayArg(args.tag) });
|
|
748
|
+
persist(run);
|
|
749
|
+
return topic;
|
|
750
|
+
}
|
|
751
|
+
function blackboardMessagePostCli(args) {
|
|
752
|
+
const runId = requireArg(args.runId, "run id");
|
|
753
|
+
const run = loadRun(args, runId);
|
|
754
|
+
const message = coord.postBlackboardMessage(run, { id: optionalString(args.id), topicId: requireArg(args.topic ?? args.topicId, "topic id"), blackboardId: optionalString(args.blackboardId), body: requireArg(args.body, "message body"), replyToId: optionalString(args.replyTo), visibility: optionalString(args.visibility), author: parseBlackboardAuthorCli(args), scope: parseBlackboardScopeCli(args), links: parseBlackboardLinksCli(runId, args), tags: arrayArg(args.tag), evidenceRefs: arrayArg(args.evidence), artifactRefIds: arrayArg(args.artifact) });
|
|
755
|
+
persist(run);
|
|
756
|
+
return message;
|
|
757
|
+
}
|
|
758
|
+
function blackboardMessageListCli(args) {
|
|
759
|
+
const runId = requireArg(args.runId, "run id");
|
|
760
|
+
const run = loadRun(args, runId);
|
|
761
|
+
return coord.listBlackboardMessages(run, { topicId: optionalString(args.topic ?? args.topicId), blackboardId: optionalString(args.blackboardId) });
|
|
762
|
+
}
|
|
763
|
+
function blackboardContextPutCli(args) {
|
|
764
|
+
const runId = requireArg(args.runId, "run id");
|
|
765
|
+
const run = loadRun(args, runId);
|
|
766
|
+
const context = coord.putBlackboardContext(run, { id: optionalString(args.id), topicId: requireArg(args.topic ?? args.topicId, "topic id"), kind: requireArg(args.kind, "context kind"), key: optionalString(args.key), value: requireArg(args.value ?? args.body, "context value"), blackboardId: optionalString(args.blackboardId), supersedesContextIds: arrayArg(args.supersedes), author: parseBlackboardAuthorCli(args), scope: parseBlackboardScopeCli(args), links: parseBlackboardLinksCli(runId, args), tags: arrayArg(args.tag), evidenceRefs: arrayArg(args.evidence), artifactRefIds: arrayArg(args.artifact) });
|
|
767
|
+
persist(run);
|
|
768
|
+
return context;
|
|
769
|
+
}
|
|
770
|
+
function blackboardArtifactAddCli(args) {
|
|
771
|
+
const runId = requireArg(args.runId, "run id");
|
|
772
|
+
const run = loadRun(args, runId);
|
|
773
|
+
const artifact = coord.addBlackboardArtifact(run, { id: optionalString(args.id), topicId: optionalString(args.topic ?? args.topicId), kind: requireArg(args.kind, "artifact kind"), path: optionalString(args.path), locator: optionalString(args.locator), blackboardId: optionalString(args.blackboardId), source: optionalString(args.source), author: parseBlackboardAuthorCli(args), scope: parseBlackboardScopeCli(args), links: parseBlackboardLinksCli(runId, args), tags: arrayArg(args.tag), evidenceRefs: arrayArg(args.evidence) });
|
|
774
|
+
persist(run);
|
|
775
|
+
return artifact;
|
|
776
|
+
}
|
|
777
|
+
function blackboardArtifactListCli(args) {
|
|
778
|
+
const runId = requireArg(args.runId, "run id");
|
|
779
|
+
const run = loadRun(args, runId);
|
|
780
|
+
return coord.listBlackboardArtifacts(run, { topicId: optionalString(args.topic), blackboardId: optionalString(args.blackboardId) });
|
|
781
|
+
}
|
|
782
|
+
function blackboardSnapshotCli(args) {
|
|
783
|
+
const runId = requireArg(args.runId, "run id");
|
|
784
|
+
const run = loadRun(args, runId);
|
|
785
|
+
const snapshot = coord.createBlackboardSnapshot(run, optionalString(args.blackboardId));
|
|
786
|
+
persist(run);
|
|
787
|
+
return snapshot;
|
|
788
|
+
}
|
|
789
|
+
function coordinatorSummaryCli(args) {
|
|
790
|
+
const runId = requireArg(args.runId, "run id");
|
|
791
|
+
const run = loadRun(args, runId);
|
|
792
|
+
return coord.summarizeBlackboard(run, optionalString(args.blackboardId));
|
|
793
|
+
}
|
|
794
|
+
function coordinatorDecisionCli(args) {
|
|
795
|
+
const runId = requireArg(args.runId, "run id");
|
|
796
|
+
const run = loadRun(args, runId);
|
|
797
|
+
const decision = coord.recordCoordinatorDecision(run, { id: optionalString(args.id), blackboardId: optionalString(args.blackboardId), kind: requireArg(args.kind, "decision kind"), outcome: requireArg(args.outcome, "decision outcome"), reason: requireArg(args.reason, "decision reason"), subjectIds: arrayArg(args.subject), evidenceRefs: arrayArg(args.evidence), artifactRefIds: arrayArg(args.artifact), messageIds: arrayArg(args.message) });
|
|
798
|
+
persist(run);
|
|
799
|
+
return decision;
|
|
800
|
+
}
|
|
801
|
+
// ---------------------------------------------------------------------------
|
|
802
|
+
// Candidate scoring
|
|
803
|
+
// ---------------------------------------------------------------------------
|
|
804
|
+
function candidateListCli(args) {
|
|
805
|
+
const runId = requireArg(args.runId, "run id");
|
|
806
|
+
const run = loadRun(args, runId);
|
|
807
|
+
return cs.listCandidates(run, { status: optionalString(args.status), kind: optionalString(args.kind) });
|
|
808
|
+
}
|
|
809
|
+
function candidateShowCli(args, candidateId) {
|
|
810
|
+
const runId = requireArg(args.runId, "run id");
|
|
811
|
+
const run = loadRun(args, runId);
|
|
812
|
+
const candidate = cs.getCandidate(run, candidateId);
|
|
813
|
+
if (!candidate)
|
|
814
|
+
throw new Error(`Unknown candidate for run ${runId}: ${candidateId}`);
|
|
815
|
+
return candidate;
|
|
816
|
+
}
|
|
817
|
+
function candidateRegisterCli(args) {
|
|
818
|
+
const runId = requireArg(args.runId, "run id");
|
|
819
|
+
const run = loadRun(args, runId);
|
|
820
|
+
// `candidate register --worker <id>` — derive the worker's accepted
|
|
821
|
+
// result/verifier state nodes (and result path) from the worker scope +
|
|
822
|
+
// its backing task, so a candidate registered from a verified worker
|
|
823
|
+
// carries the verifier gate the selection gate requires. Port of the old
|
|
824
|
+
// orchestrator/candidate-operations.ts registerCandidate worker read
|
|
825
|
+
// (v2's candidateRegisterCli only forwarded --result-node/--verifier-node).
|
|
826
|
+
const workerId = optionalString(args.worker ?? args.workerId);
|
|
827
|
+
const worker = workerId ? (0, worker_isolation_1.getWorkerScope)(run, workerId) : undefined;
|
|
828
|
+
if (workerId && !worker)
|
|
829
|
+
throw new Error(`Unknown worker id for run ${run.id}: ${workerId}`);
|
|
830
|
+
const workerOutput = worker?.output;
|
|
831
|
+
const task = worker ? run.tasks.find((entry) => entry.id === worker.taskId) : undefined;
|
|
832
|
+
const resultNodeId = optionalString(args.resultNode) || worker?.resultNodeId || task?.resultNodeId;
|
|
833
|
+
const verifierNodeId = optionalString(args.verifierNode) || workerOutput?.verifierNodeId || task?.verifierNodeId;
|
|
834
|
+
const resultPath = optionalString(args.resultPath) || workerOutput?.resultPath || task?.resultPath;
|
|
835
|
+
const candidate = cs.registerCandidate(run, {
|
|
836
|
+
id: optionalString(args.id),
|
|
837
|
+
kind: optionalString(args.kind),
|
|
838
|
+
workerId,
|
|
839
|
+
taskId: optionalString(args.task ?? args.taskId) || worker?.taskId,
|
|
840
|
+
resultNodeId,
|
|
841
|
+
verifierNodeId,
|
|
842
|
+
resultPath,
|
|
843
|
+
});
|
|
844
|
+
persist(run);
|
|
845
|
+
return candidate;
|
|
846
|
+
}
|
|
847
|
+
function parseCriteriaCli(args) {
|
|
848
|
+
const criteria = {};
|
|
849
|
+
const structured = args.criteria;
|
|
850
|
+
if (structured && typeof structured === "object" && !Array.isArray(structured)) {
|
|
851
|
+
for (const [key, value] of Object.entries(structured)) {
|
|
852
|
+
const parsed = Number(value);
|
|
853
|
+
if (key && Number.isFinite(parsed))
|
|
854
|
+
criteria[key] = parsed;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
for (const entry of arrayArg(args.criterion)) {
|
|
858
|
+
const [key, value] = entry.split("=");
|
|
859
|
+
if (!key || value === undefined)
|
|
860
|
+
continue;
|
|
861
|
+
const parsed = Number(value);
|
|
862
|
+
if (Number.isFinite(parsed))
|
|
863
|
+
criteria[key] = parsed;
|
|
864
|
+
}
|
|
865
|
+
if (!Object.keys(criteria).length)
|
|
866
|
+
throw new Error("Missing score criteria. Use --criterion name=value");
|
|
867
|
+
return criteria;
|
|
868
|
+
}
|
|
869
|
+
function candidateScoreCli(args, candidateId) {
|
|
870
|
+
const runId = requireArg(args.runId, "run id");
|
|
871
|
+
const run = loadRun(args, runId);
|
|
872
|
+
const evidence = arrayArg(args.evidence).map((entry, index) => ({ id: `score:${index + 1}`, source: "cli", locator: entry, summary: entry }));
|
|
873
|
+
const score = cs.scoreCandidate(run, candidateId, { id: optionalString(args.id), scorer: optionalString(args.scorer), criteria: parseCriteriaCli(args), maxTotal: numberArg(args.maxTotal ?? args.max), verdict: optionalString(args.verdict), evidence, notes: optionalString(args.notes) });
|
|
874
|
+
persist(run);
|
|
875
|
+
return score;
|
|
876
|
+
}
|
|
877
|
+
function candidateRankCli(args) {
|
|
878
|
+
const runId = requireArg(args.runId, "run id");
|
|
879
|
+
const run = loadRun(args, runId);
|
|
880
|
+
const ranking = cs.rankCandidates(run, { includeRejected: boolArg(args.includeRejected), policy: { minNormalized: numberArg(args.minNormalized), requireEvidence: args.requireEvidence === undefined ? undefined : boolArg(args.requireEvidence), requireVerifierGate: args.requireVerifierGate === undefined ? undefined : boolArg(args.requireVerifierGate), tieBreaker: optionalString(args.tieBreaker) } });
|
|
881
|
+
persist(run);
|
|
882
|
+
return ranking;
|
|
883
|
+
}
|
|
884
|
+
function candidateSelectCli(args, candidateId) {
|
|
885
|
+
const runId = requireArg(args.runId, "run id");
|
|
886
|
+
const run = loadRun(args, runId);
|
|
887
|
+
const selection = cs.selectCandidate(run, candidateId, { selectedBy: optionalString(args.selectedBy ?? args.by), reason: optionalString(args.reason), scoreId: optionalString(args.score), allowUnverified: boolArg(args.allowUnverified) }, { policy: { minNormalized: numberArg(args.minNormalized), requireVerifierGate: args.requireVerifierGate === undefined ? undefined : boolArg(args.requireVerifierGate) } });
|
|
888
|
+
persist(run);
|
|
889
|
+
return selection;
|
|
890
|
+
}
|
|
891
|
+
function candidateRejectCli(args, candidateId) {
|
|
892
|
+
const runId = requireArg(args.runId, "run id");
|
|
893
|
+
const run = loadRun(args, runId);
|
|
894
|
+
const candidate = cs.rejectCandidate(run, candidateId, requireArg(args.reason, "reject reason"));
|
|
895
|
+
persist(run);
|
|
896
|
+
return candidate;
|
|
897
|
+
}
|
|
898
|
+
function candidateSummaryCli(args) {
|
|
899
|
+
const runId = requireArg(args.runId, "run id");
|
|
900
|
+
const run = loadRun(args, runId);
|
|
901
|
+
// `candidate summary` returns the operator candidate summary (with
|
|
902
|
+
// readyForCommit/selected/problems/candidates), matching the old build's
|
|
903
|
+
// summarizeCandidateOperatorRecords — not the bare counts.
|
|
904
|
+
return (0, operator_ux_1.summarizeCandidateOperatorRecords)(run);
|
|
905
|
+
}
|
|
906
|
+
// ---------------------------------------------------------------------------
|
|
907
|
+
// Collaboration
|
|
908
|
+
// ---------------------------------------------------------------------------
|
|
909
|
+
function targetFromArgs(args, positionalKind, positionalId) {
|
|
910
|
+
const kind = optionalString(args.targetKind ?? args.kind ?? positionalKind);
|
|
911
|
+
const id = optionalString(args.targetId ?? args.target ?? positionalId);
|
|
912
|
+
if (!kind || !id)
|
|
913
|
+
throw new Error("Collaboration target requires a kind and id");
|
|
914
|
+
return { kind, id };
|
|
915
|
+
}
|
|
916
|
+
function approveCli(args, positionalKind, positionalId) {
|
|
917
|
+
const runId = requireArg(args.runId, "run id");
|
|
918
|
+
const run = loadRun(args, runId);
|
|
919
|
+
const target = targetFromArgs(args, positionalKind, positionalId);
|
|
920
|
+
const record = collab.recordApproval(run, { target: target, decision: "approve", actor: optionalString(args.actor), actorKind: optionalString(args.actorKind), role: optionalString(args.role), displayName: optionalString(args.displayName), attested: boolArg(args.attested), attestation: optionalString(args.attestation), rationale: optionalString(args.rationale), supersedes: optionalString(args.supersedes) });
|
|
921
|
+
return record;
|
|
922
|
+
}
|
|
923
|
+
function rejectCollabCli(args, positionalKind, positionalId) {
|
|
924
|
+
const runId = requireArg(args.runId, "run id");
|
|
925
|
+
const run = loadRun(args, runId);
|
|
926
|
+
const target = targetFromArgs(args, positionalKind, positionalId);
|
|
927
|
+
const record = collab.recordApproval(run, { target: target, decision: "reject", actor: optionalString(args.actor), actorKind: optionalString(args.actorKind), role: optionalString(args.role), displayName: optionalString(args.displayName), attested: boolArg(args.attested), attestation: optionalString(args.attestation), rationale: optionalString(args.rationale) });
|
|
928
|
+
return record;
|
|
929
|
+
}
|
|
930
|
+
function commentAddCli(args, positionalKind, positionalId) {
|
|
931
|
+
const runId = requireArg(args.runId, "run id");
|
|
932
|
+
const run = loadRun(args, runId);
|
|
933
|
+
const target = targetFromArgs(args, positionalKind, positionalId);
|
|
934
|
+
const record = collab.recordComment(run, { target: target, body: requireArg(args.body ?? args.message ?? args.text, "comment body"), actor: optionalString(args.actor), actorKind: optionalString(args.actorKind), role: optionalString(args.role), threadId: optionalString(args.thread), parentId: optionalString(args.parent) });
|
|
935
|
+
return record;
|
|
936
|
+
}
|
|
937
|
+
function commentListCli(args) {
|
|
938
|
+
const runId = requireArg(args.runId, "run id");
|
|
939
|
+
const run = loadRun(args, runId);
|
|
940
|
+
const targetKind = optionalString(args.targetKind);
|
|
941
|
+
const targetId = optionalString(args.target);
|
|
942
|
+
return collab.listComments(run, targetKind && targetId ? { kind: targetKind, id: targetId } : undefined);
|
|
943
|
+
}
|
|
944
|
+
function handoffCli(args, positionalKind, positionalId) {
|
|
945
|
+
const runId = requireArg(args.runId, "run id");
|
|
946
|
+
const run = loadRun(args, runId);
|
|
947
|
+
const target = targetFromArgs(args, positionalKind, positionalId);
|
|
948
|
+
const record = collab.recordHandoff(run, { target: target, toActor: optionalString(args.to ?? args.toActor), toRole: optionalString(args.toRole), fromActor: optionalString(args.from), reason: requireArg(args.reason, "handoff reason"), actor: optionalString(args.actor), actorKind: optionalString(args.actorKind), role: optionalString(args.role) });
|
|
949
|
+
return record;
|
|
950
|
+
}
|
|
951
|
+
function reviewStatusCli(args) {
|
|
952
|
+
const runId = requireArg(args.runId, "run id");
|
|
953
|
+
const run = loadRun(args, runId);
|
|
954
|
+
const targetKind = optionalString(args.targetKind);
|
|
955
|
+
const targetId = optionalString(args.target);
|
|
956
|
+
return collab.buildReviewStatusReport(run, { now: new Date().toISOString(), target: targetKind && targetId ? { kind: targetKind, id: targetId } : undefined });
|
|
957
|
+
}
|
|
958
|
+
function reviewPolicyCli(args) {
|
|
959
|
+
const runId = requireArg(args.runId, "run id");
|
|
960
|
+
const run = loadRun(args, runId);
|
|
961
|
+
// Read BOTH the MCP camelCase keys and the CLI kebab-case flags: the CLI
|
|
962
|
+
// parser emits `--required-approvals` as `required-approvals`, not
|
|
963
|
+
// `requiredApprovals`, so without the fallback every flag was silently
|
|
964
|
+
// dropped and the CLI wrote the default policy (caught by parity-check's
|
|
965
|
+
// cw --json vs cw_review_policy payload probe).
|
|
966
|
+
const requiredApprovals = args.requiredApprovals ?? args["required-approvals"];
|
|
967
|
+
const authorizedRoles = args.authorizedRoles ?? args["authorized-roles"];
|
|
968
|
+
const allowSelfApproval = args.allowSelfApproval ?? args["allow-self-approval"];
|
|
969
|
+
const requireAttestedActor = args.requireAttestedActor ?? args["require-attested-actor"];
|
|
970
|
+
const appliesTo = args.appliesTo ?? args["applies-to"];
|
|
971
|
+
const policy = collab.setReviewPolicy(run, { requiredApprovals: numberArg(requiredApprovals), authorizedRoles: arrayArg(authorizedRoles).length ? arrayArg(authorizedRoles) : optionalString(authorizedRoles), allowSelfApproval: allowSelfApproval === undefined ? undefined : boolArg(allowSelfApproval), requireAttestedActor: requireAttestedActor === undefined ? undefined : boolArg(requireAttestedActor), appliesTo: arrayArg(appliesTo).length ? arrayArg(appliesTo) : optionalString(appliesTo) });
|
|
972
|
+
return policy;
|
|
973
|
+
}
|
|
974
|
+
// ---------------------------------------------------------------------------
|
|
975
|
+
// Eval replay
|
|
976
|
+
// ---------------------------------------------------------------------------
|
|
977
|
+
function evalSnapshotCli(args) {
|
|
978
|
+
const runId = requireArgDot(args.runId, "run id");
|
|
979
|
+
const run = loadRun(args, runId);
|
|
980
|
+
return evalio.createMultiAgentReplaySnapshot(run, args);
|
|
981
|
+
}
|
|
982
|
+
function evalReplayCli(args) {
|
|
983
|
+
const target = requireArgDot(args.snapshot ?? args.snapshotId ?? args.path, "snapshot id or path");
|
|
984
|
+
return evalio.replayMultiAgentSnapshot(target, args);
|
|
985
|
+
}
|
|
986
|
+
function evalCompareCli(args) {
|
|
987
|
+
const baseline = requireArgDot(args.baseline ?? args.baselinePath, "baseline id or path");
|
|
988
|
+
const replay = requireArgDot(args.replay ?? args.replayPath, "replay id or path");
|
|
989
|
+
return evalio.compareMultiAgentReplay(baseline, replay);
|
|
990
|
+
}
|
|
991
|
+
function evalScoreCli(args) {
|
|
992
|
+
const target = requireArg(args.replay ?? args.replayPath ?? args.path, "replay id or path");
|
|
993
|
+
return evalio.scoreMultiAgentReplay(target);
|
|
994
|
+
}
|
|
995
|
+
function evalGateCli(args) {
|
|
996
|
+
const target = requireArg(args.suite ?? args.suiteId ?? args.path, "suite id or path");
|
|
997
|
+
return evalio.gateMultiAgentEval(target);
|
|
998
|
+
}
|
|
999
|
+
function evalReportCli(args) {
|
|
1000
|
+
const target = requireArg(args.replay ?? args.replayPath ?? args.path, "replay id or path");
|
|
1001
|
+
return evalio.reportMultiAgentEval(target);
|
|
1002
|
+
}
|