@aiwg/cli 2026.10.15 → 2026.10.18
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/agentic/code/providers/pi/aiwg-bridge.ts +45 -7
- package/dist/src/artifacts/citation-parser.js +7 -6
- package/dist/src/artifacts/corpus-tools/citation-densify.js +4 -2
- package/dist/src/artifacts/corpus-tools/cli.js +8 -3
- package/dist/src/artifacts/corpus-tools/discovery-log.js +26 -24
- package/dist/src/artifacts/corpus-tools/expand-cli.js +3 -2
- package/dist/src/artifacts/corpus-tools/expand-dates.js +107 -0
- package/dist/src/artifacts/corpus-tools/expand-queue.js +4 -1
- package/dist/src/artifacts/corpus-tools/expand-review.js +104 -0
- package/dist/src/artifacts/corpus-tools/expand-state.js +17 -1
- package/dist/src/artifacts/corpus-tools/expand.js +16 -17
- package/dist/src/artifacts/corpus-tools/induction-audit.js +7 -6
- package/dist/src/artifacts/corpus-tools/integrity-scan.js +3 -3
- package/dist/src/artifacts/corpus-tools/radar-shared.js +7 -9
- package/dist/src/artifacts/corpus-tools/ref-files.js +11 -0
- package/dist/src/artifacts/corpus-tools/resolve-cli.js +11 -3
- package/dist/src/artifacts/corpus-tools/resolve.js +42 -11
- package/dist/src/artifacts/corpus-tools/retrieval-lab.js +2 -1
- package/dist/src/artifacts/corpus-tools/sidecar-lint.js +4 -4
- package/dist/src/artifacts/corpus-tools/sidecar-repair.js +2 -1
- package/dist/src/artifacts/corpus-views/ref-parser.js +3 -17
- package/dist/src/artifacts/graph-query.js +5 -3
- package/dist/src/artifacts/hybrid-query.js +11 -2
- package/dist/src/artifacts/index-refresh.js +2 -0
- package/dist/src/artifacts/query-engine-corpus.js +217 -0
- package/dist/src/artifacts/query-engine-discover-output.js +229 -0
- package/dist/src/artifacts/query-engine-discover.js +285 -0
- package/dist/src/artifacts/query-engine-entries.js +188 -0
- package/dist/src/artifacts/query-engine-index.js +249 -0
- package/dist/src/artifacts/query-engine-matching.js +143 -0
- package/dist/src/artifacts/query-engine-options.js +2 -0
- package/dist/src/artifacts/query-engine-rules.js +202 -0
- package/dist/src/artifacts/query-engine-scoring.js +436 -0
- package/dist/src/artifacts/query-engine-show-card.js +194 -0
- package/dist/src/artifacts/query-engine-show-load.js +211 -0
- package/dist/src/artifacts/query-engine-show.js +300 -0
- package/dist/src/artifacts/query-engine.js +7 -2576
- package/dist/src/cli/handlers/daemon.js +17 -1
- package/dist/src/cli/handlers/doctor-args.js +10 -5
- package/dist/src/cli/handlers/doctor-help.js +4 -1
- package/dist/src/cli/handlers/index.js +2 -2
- package/dist/src/cli/handlers/mc-agents.js +111 -0
- package/dist/src/cli/handlers/mc-args.js +54 -0
- package/dist/src/cli/handlers/mc-control.js +227 -0
- package/dist/src/cli/handlers/mc-dispatch.js +203 -0
- package/dist/src/cli/handlers/mc-help.js +171 -0
- package/dist/src/cli/handlers/mc-run.js +343 -0
- package/dist/src/cli/handlers/mc-session.js +138 -0
- package/dist/src/cli/handlers/mc-status.js +258 -0
- package/dist/src/cli/handlers/mc-summary.js +43 -0
- package/dist/src/cli/handlers/mc-types.js +3 -0
- package/dist/src/cli/handlers/mc-worker.js +205 -0
- package/dist/src/cli/handlers/mc.js +12 -1665
- package/dist/src/cli/handlers/models-refusal.js +13 -0
- package/dist/src/cli/handlers/models-resource-sample.js +10 -0
- package/dist/src/cli/handlers/models.js +5 -3
- package/dist/src/cli/handlers/regenerate.js +8 -16
- package/dist/src/cli/handlers/remove-bundled.js +133 -0
- package/dist/src/cli/handlers/remove-options.js +31 -0
- package/dist/src/cli/handlers/remove-user.js +174 -0
- package/dist/src/cli/handlers/remove.js +201 -0
- package/dist/src/cli/handlers/sessions.js +7 -7
- package/dist/src/cli/handlers/subcommands-bundles.js +257 -0
- package/dist/src/cli/handlers/subcommands-discovery.js +165 -0
- package/dist/src/cli/handlers/subcommands-list-format.js +129 -0
- package/dist/src/cli/handlers/subcommands-list.js +250 -0
- package/dist/src/cli/handlers/subcommands-plugins.js +213 -0
- package/dist/src/cli/handlers/subcommands-quickref.js +58 -0
- package/dist/src/cli/handlers/subcommands-rlm.js +113 -0
- package/dist/src/cli/handlers/subcommands-services.js +66 -0
- package/dist/src/cli/handlers/subcommands-storage.js +259 -0
- package/dist/src/cli/handlers/subcommands.js +18 -1976
- package/dist/src/cli/handlers/update.js +157 -0
- package/dist/src/cli/handlers/use.js +14 -4
- package/dist/src/cli/handlers/utilities.js +3 -560
- package/dist/src/cli/handlers/utility-doctor.js +412 -0
- package/dist/src/cli/scope-resolver.js +1 -142
- package/dist/src/cli/services/deployment-verification.js +0 -1
- package/dist/src/cli/user-scope-mirror.js +173 -0
- package/dist/src/config/aiwg-config.js +2 -1
- package/dist/src/config/authorization-cli.js +7 -3
- package/dist/src/config/dispatch-host-thresholds.js +2 -0
- package/dist/src/config/dispatch-thresholds-runtime.d.mts +3 -2
- package/dist/src/config/dispatch-thresholds-runtime.mjs +21 -7
- package/dist/src/config/framework-aliases.js +12 -0
- package/dist/src/config/host-resource-report.d.mts +24 -0
- package/dist/src/config/host-resource-report.mjs +110 -0
- package/dist/src/config/host-resource-runtime.d.mts +37 -0
- package/dist/src/config/host-resource-runtime.mjs +296 -0
- package/dist/src/config/installed-selection.js +22 -0
- package/dist/src/config/worker-invocation-marker.d.mts +1 -0
- package/dist/src/config/worker-invocation-marker.mjs +2 -0
- package/dist/src/decision/ensemble-study/artifacts.js +7 -0
- package/dist/src/decision/ensemble-study/gate-policy.js +58 -0
- package/dist/src/decision/ensemble-study/gates.js +78 -0
- package/dist/src/decision/ensemble-study/protocol.js +18 -21
- package/dist/src/decision/ensemble-study/score.js +3 -2
- package/dist/src/decision/ensemble-study/statistics.js +7 -26
- package/dist/src/decision/heldout/access.js +74 -0
- package/dist/src/decision/heldout/calibration.js +1 -0
- package/dist/src/decision/heldout/collector.js +8 -1
- package/dist/src/decision/sensitivity/comparative-gates.js +135 -0
- package/dist/src/decision/sensitivity/comparative.js +18 -41
- package/dist/src/effects/verifiers/file.js +22 -5
- package/dist/src/extensions/claude-attribution.js +82 -0
- package/dist/src/extensions/claude-hooks-installer.js +133 -69
- package/dist/src/extensions/commands/daemon.js +109 -0
- package/dist/src/extensions/commands/definitions.js +5 -89
- package/dist/src/gates/evaluate.js +2 -358
- package/dist/src/gates/heldout.js +17 -7
- package/dist/src/gates/observations.js +363 -0
- package/dist/src/gates/pack-composition.js +270 -0
- package/dist/src/gates/pack-tightening.js +197 -0
- package/dist/src/gates/pack-validation.js +262 -0
- package/dist/src/gates/registry-error.js +5 -0
- package/dist/src/gates/registry.js +13 -685
- package/dist/src/lint/check-patterns.js +163 -0
- package/dist/src/lint/checks.js +268 -0
- package/dist/src/lint/reference-resolution.js +54 -0
- package/dist/src/lint/runner.js +3 -465
- package/dist/src/mcp/helpers.mjs +11 -1
- package/dist/src/mcp/json-document.mjs +29 -0
- package/dist/src/mcp/muse-native-config.mjs +1 -28
- package/dist/src/memory/project-registry.js +44 -4
- package/dist/src/mission-protocol/worker-review-gate.js +7 -0
- package/dist/src/models/worker-plan.js +36 -5
- package/dist/src/models/wrapper-deployment.js +25 -12
- package/dist/src/models/wrapper-enforcement.js +47 -7
- package/dist/src/network-analysis/research.js +2 -1
- package/dist/src/plugin/command-ownership.js +34 -0
- package/dist/src/plugin/skill-command-frontmatter.js +197 -0
- package/dist/src/plugin/skill-command-translator.js +6 -232
- package/dist/src/policy/hitl-check.js +14 -4
- package/dist/src/policy/hitl-consume.js +54 -0
- package/dist/src/policy/hitl-receipt.js +2 -0
- package/dist/src/policy/hitl.js +11 -3
- package/dist/src/providers/context-output-ownership.js +26 -0
- package/dist/src/providers/deployment-ownership.d.mts +19 -0
- package/dist/src/providers/deployment-ownership.mjs +226 -0
- package/dist/src/providers/deployment-removal.js +200 -0
- package/dist/src/providers/provider-context-contracts.js +162 -0
- package/dist/src/providers/provider-definition-schema.js +136 -0
- package/dist/src/providers/provider-definitions.js +8 -1298
- package/dist/src/providers/provider-seeds-1.js +360 -0
- package/dist/src/providers/provider-seeds-2.js +387 -0
- package/dist/src/providers/provider-seeds-3.js +262 -0
- package/dist/src/providers/removal-transaction.js +86 -0
- package/dist/src/providers/settings-document.d.mts +3 -0
- package/dist/src/providers/settings-document.mjs +47 -0
- package/dist/src/providers/settings-removal.js +190 -0
- package/dist/src/providers/skill-ownership.d.mts +19 -2
- package/dist/src/providers/skill-ownership.mjs +12 -4
- package/dist/src/providers/transformation-receipt-integration.js +15 -271
- package/dist/src/providers/transformation-receipt-outputs.js +99 -0
- package/dist/src/providers/transformation-receipt-source.js +194 -0
- package/dist/src/research/clients/arxiv.js +4 -30
- package/dist/src/research/clients/base.js +48 -22
- package/dist/src/research/identity.js +42 -4
- package/dist/src/research/query-cli.js +3 -87
- package/dist/src/research/query-options.js +87 -0
- package/dist/src/research/reference-match.js +105 -24
- package/dist/src/research/services/acquisition.js +9 -7
- package/dist/src/research/services/citation.js +5 -2
- package/dist/src/research/types.js +2 -0
- package/dist/src/rules/activation.mjs +15 -6
- package/dist/src/rules/core-startup.mjs +2 -2
- package/dist/src/serve/mission-conductor.js +52 -4
- package/dist/src/serve/mission-summary.js +56 -0
- package/dist/src/sessions/adapters/grok-build-native.js +23 -0
- package/dist/src/sessions/adapters/grok-build.js +14 -7
- package/dist/src/sessions/workspace-discovery.js +5 -5
- package/dist/src/smiths/context-pipeline/aiwg-md.js +39 -46
- package/dist/src/smiths/context-pipeline/claude-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/code-regions.js +28 -0
- package/dist/src/smiths/context-pipeline/context-file-safety.js +3 -0
- package/dist/src/smiths/context-pipeline/finalization.js +81 -51
- package/dist/src/smiths/context-pipeline/generator.js +10 -11
- package/dist/src/smiths/context-pipeline/managed-hook.js +1 -1
- package/dist/src/smiths/context-pipeline/muse-bridge.js +2 -2
- package/dist/src/smiths/context-pipeline/provider-policy.js +6 -12
- package/dist/src/smiths/context-pipeline/workspace-audit.js +299 -0
- package/dist/src/smiths/context-pipeline/workspace-bootstrap.js +148 -0
- package/dist/src/smiths/context-pipeline/workspace-context-shared.js +111 -0
- package/dist/src/smiths/context-pipeline/workspace-context.js +8 -1373
- package/dist/src/smiths/context-pipeline/workspace-doctor.js +192 -0
- package/dist/src/smiths/context-pipeline/workspace-document.js +201 -0
- package/dist/src/smiths/context-pipeline/workspace-extraction.js +205 -0
- package/dist/src/smiths/context-pipeline/workspace-migration.js +250 -0
- package/dist/src/smiths/hook-bridge/index.js +9 -0
- package/package.json +13 -1
- package/schemas/decision/D17StudyProtocol.v1.schema.json +39 -67
- package/schemas/decision/D29Study.v10.schema.json +65 -0
- package/tools/agents/deploy-agents.mjs +24 -675
- package/tools/agents/deploy-command-mirrors.mjs +229 -0
- package/tools/agents/deploy-options.mjs +258 -0
- package/tools/agents/deploy-support.mjs +165 -0
- package/tools/agents/providers/base-addon-discovery.mjs +139 -0
- package/tools/agents/providers/base-behaviors.mjs +168 -0
- package/tools/agents/providers/base-context.mjs +205 -0
- package/tools/agents/providers/base-contract.mjs +116 -0
- package/tools/agents/providers/base-files.mjs +252 -0
- package/tools/agents/providers/base-flat-artifacts.mjs +233 -0
- package/tools/agents/providers/base-framework-discovery.mjs +309 -0
- package/tools/agents/providers/base-frontmatter.mjs +196 -0
- package/tools/agents/providers/base-inventory.mjs +269 -0
- package/tools/agents/providers/base-kernel-skills.mjs +354 -0
- package/tools/agents/providers/base-migrations.mjs +258 -0
- package/tools/agents/providers/base-models-platforms.mjs +273 -0
- package/tools/agents/providers/base-rule-index.mjs +450 -0
- package/tools/agents/providers/base-runtime.mjs +60 -0
- package/tools/agents/providers/base-skill-copy.mjs +273 -0
- package/tools/agents/providers/base.mjs +16 -3364
- package/tools/agents/providers/claude-post-deploy.mjs +20 -1
- package/tools/agents/providers/context-write.mjs +4 -0
- package/tools/agents/providers/hermes-startup.mjs +0 -5
- package/tools/agents/providers/muse.mjs +7 -2
- package/tools/agents/providers/pi.mjs +3 -1
- package/tools/agents/providers/rule-delivery-surface.mjs +359 -0
- package/tools/agents/providers/rule-delivery.mjs +20 -1144
- package/tools/agents/providers/rule-deployment-commit.mjs +148 -0
- package/tools/agents/providers/rule-deployment-prepare.mjs +461 -0
- package/tools/agents/providers/rule-deployment-state.mjs +300 -0
- package/tools/agents/providers/rule-projection.mjs +3 -0
- package/tools/daemon/README.md +511 -0
- package/tools/daemon/adapters/base-adapter.mjs +84 -0
- package/tools/daemon/adapters/webhook-adapter.mjs +107 -0
- package/tools/daemon/agent-supervisor.mjs +299 -0
- package/tools/daemon/automation-engine.mjs +310 -0
- package/tools/daemon/autonomous-engine.mjs +346 -0
- package/tools/daemon/behavior-loader.mjs +316 -0
- package/tools/daemon/behavior.mjs +174 -0
- package/tools/daemon/concierge/intent-router.mjs +401 -0
- package/tools/daemon/concierge/orchestrator.mjs +272 -0
- package/tools/daemon/concierge/response-translator.mjs +462 -0
- package/tools/daemon/config.mjs +377 -0
- package/tools/daemon/cron-scheduler.mjs +178 -0
- package/tools/daemon/daemon-main.mjs +1169 -0
- package/tools/daemon/event-router.mjs +84 -0
- package/tools/daemon/file-watcher.mjs +383 -0
- package/tools/daemon/index.mjs +1181 -0
- package/tools/daemon/init-profile.mjs +124 -0
- package/tools/daemon/ipc-client.mjs +197 -0
- package/tools/daemon/ipc-ops-handlers.mjs +236 -0
- package/tools/daemon/ipc-server.mjs +275 -0
- package/tools/daemon/maintenance-owner.mjs +79 -0
- package/tools/daemon/memory-manager.mjs +386 -0
- package/tools/daemon/message-router.mjs +194 -0
- package/tools/daemon/provider-watcher.mjs +585 -0
- package/tools/daemon/pty-adapter.mjs +420 -0
- package/tools/daemon/repl-chat.mjs +359 -0
- package/tools/daemon/resource-bounds.mjs +88 -0
- package/tools/daemon/sandbox-transport.mjs +295 -0
- package/tools/daemon/scheduled-task-runner.mjs +535 -0
- package/tools/daemon/task-store.mjs +450 -0
- package/tools/daemon/tmux-manager.mjs +324 -0
- package/tools/daemon/update-policy.mjs +517 -0
- package/tools/daemon/web-server.mjs +399 -0
- package/tools/daemon/web-ui/index.html +585 -0
- package/tools/daemon/web-ui/styles.css +156 -0
- package/tools/docker/Dockerfile.daemon +35 -0
- package/tools/docker/container-manager.mjs +291 -0
- package/tools/messaging/adapter-registry.mjs +230 -0
- package/tools/messaging/adapters/base.mjs +326 -0
- package/tools/messaging/adapters/discord.mjs +462 -0
- package/tools/messaging/adapters/slack.mjs +402 -0
- package/tools/messaging/adapters/telegram.mjs +552 -0
- package/tools/messaging/chat-handler.mjs +297 -0
- package/tools/messaging/command-router.mjs +269 -0
- package/tools/messaging/event-bus.mjs +199 -0
- package/tools/messaging/index.mjs +456 -0
- package/tools/messaging/message-formatter.mjs +320 -0
- package/tools/messaging/room-manager.mjs +277 -0
- package/tools/messaging/types.mjs +94 -0
- package/tools/providers/pi-bridge-policy.mjs +4 -0
- package/tools/ralph-external/daemon-supervisor.mjs +394 -0
- package/tools/ralph-external/lib/behavior-registry.mjs +270 -0
- package/tools/ralph-external/lib/worker-invocation-processes.mjs +7 -4
- package/tools/ralph-external/lib/worker-isolation-args.mjs +217 -0
- package/tools/ralph-external/lib/worker-isolation-status.mjs +19 -0
- package/tools/ralph-external/lib/worker-isolation.mjs +11 -237
- package/tools/ralph-external/lib/worker-overflow.mjs +10 -2
- package/tools/ralph-external/lib/worker-termination.mjs +15 -8
- package/tools/ralph-external/lib/worker-unit-cleanup.mjs +72 -0
- package/tools/ralph-external/session-launcher.mjs +7 -7
- package/tools/scripts/resource-preflight.mjs +3 -242
- package/vscode-extension/schemas/aiwg.config.v1.json +2 -4
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import * as ui from '../ui.js';
|
|
2
|
+
import { isAbsolute, relative } from 'node:path';
|
|
3
|
+
import { createHash } from 'node:crypto';
|
|
4
|
+
import { assertMissionWorkerHandoff } from '../../mission-protocol/codecs.js';
|
|
5
|
+
import { genId, writeSession, appendLog, mutateSession, mutationFlags, mutationFailure, findActiveSession } from './mc-session.js';
|
|
6
|
+
import { parseFlag, parseNumberFlag, getPositionalArgs } from './mc-args.js';
|
|
7
|
+
import { readAdmissionConfig, mcWorkerSupport, readWorkerJson, resolveMcWorker } from './mc-worker.js';
|
|
8
|
+
import { managedControlFailure } from './mc-control.js';
|
|
9
|
+
// ── Subcommand handlers ──────────────────────────────────────
|
|
10
|
+
export async function mcStart(ctx) {
|
|
11
|
+
const name = parseFlag(ctx.args, '--name') || `Mission ${new Date().toISOString().slice(0, 10)}`;
|
|
12
|
+
const maxMissions = parseInt(parseFlag(ctx.args, '--max-missions') || '10', 10);
|
|
13
|
+
const session = {
|
|
14
|
+
id: genId('mc'),
|
|
15
|
+
name,
|
|
16
|
+
state: 'active',
|
|
17
|
+
maxMissions,
|
|
18
|
+
createdAt: new Date().toISOString(),
|
|
19
|
+
updatedAt: new Date().toISOString(),
|
|
20
|
+
missions: [],
|
|
21
|
+
};
|
|
22
|
+
await writeSession(session);
|
|
23
|
+
await appendLog(session.id, { event: 'session_started', name, maxMissions });
|
|
24
|
+
ui.blank();
|
|
25
|
+
console.log(` ${ui.brandMark()} ${ui.bold('Mission Control')} — ${ui.accent(name)}`);
|
|
26
|
+
ui.rule();
|
|
27
|
+
ui.success(`Session started: ${session.id}`);
|
|
28
|
+
ui.info(`Max missions: ${maxMissions}`);
|
|
29
|
+
// #1439: the lifecycle is start → dispatch → run → status. State this
|
|
30
|
+
// up-front so users don't get stuck wondering why missions never execute.
|
|
31
|
+
ui.info(`Next: \`aiwg mc dispatch ${session.id} "<objective>" --completion "<criteria>"\``);
|
|
32
|
+
ui.info(`Then: \`aiwg mc run ${session.id}\` to drain the queue (missions stay 'queued' until you do).`);
|
|
33
|
+
ui.blank();
|
|
34
|
+
return { exitCode: 0, message: session.id };
|
|
35
|
+
}
|
|
36
|
+
export async function mcDispatch(ctx) {
|
|
37
|
+
const positional = getPositionalArgs(ctx.args);
|
|
38
|
+
const sessionId = positional[0];
|
|
39
|
+
const objective = positional.slice(1).join(' ') || parseFlag(ctx.args, '--objective');
|
|
40
|
+
const completion = parseFlag(ctx.args, '--completion');
|
|
41
|
+
const priority = parseFlag(ctx.args, '--priority') || 'normal';
|
|
42
|
+
const invalidFlags = [];
|
|
43
|
+
const maxIterations = parseNumberFlag(ctx.args, '--max-iterations', invalidFlags, true) ?? 10;
|
|
44
|
+
const maxTotalTokens = parseNumberFlag(ctx.args, '--max-total-tokens', invalidFlags, true);
|
|
45
|
+
const maxOutputTokens = parseNumberFlag(ctx.args, '--max-output-tokens', invalidFlags, true);
|
|
46
|
+
const maxToolCalls = parseNumberFlag(ctx.args, '--max-tool-calls', invalidFlags, true);
|
|
47
|
+
const maxTotalCost = parseNumberFlag(ctx.args, '--max-total-cost', invalidFlags);
|
|
48
|
+
const maxWallClockMinutes = parseNumberFlag(ctx.args, '--max-wall-clock-minutes', invalidFlags);
|
|
49
|
+
const explorationQuota = parseNumberFlag(ctx.args, '--exploration-quota', invalidFlags, true);
|
|
50
|
+
const budgetStopPolicyRaw = parseFlag(ctx.args, '--budget-stop-policy');
|
|
51
|
+
let budgetStopPolicy;
|
|
52
|
+
if (budgetStopPolicyRaw !== undefined) {
|
|
53
|
+
if (budgetStopPolicyRaw === 'completion-wins' || budgetStopPolicyRaw === 'budget-wins') {
|
|
54
|
+
budgetStopPolicy = budgetStopPolicyRaw;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
invalidFlags.push(`--budget-stop-policy (got '${budgetStopPolicyRaw}', expected completion-wins|budget-wins)`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const modeRaw = parseFlag(ctx.args, '--mode') || 'direct';
|
|
61
|
+
const mode = modeRaw === 'pty-orchestrator' ? 'pty-orchestrator' : 'direct';
|
|
62
|
+
const targetAgent = parseFlag(ctx.args, '--target-agent');
|
|
63
|
+
if (!objective) {
|
|
64
|
+
// #1438: keep this in sync with subcommandUsage.dispatch above so 'mc
|
|
65
|
+
// dispatch' with bad args and 'mc dispatch --help' agree on flags.
|
|
66
|
+
ui.error('Usage: aiwg mc dispatch <session-id> "<objective>" [--completion "<criteria>"] [--max-iterations N] [--priority <level>] [--mode pty-orchestrator] [--target-agent <agent-id>]');
|
|
67
|
+
return { exitCode: 1 };
|
|
68
|
+
}
|
|
69
|
+
if (invalidFlags.length > 0) {
|
|
70
|
+
ui.error(`Invalid numeric flag value(s): ${invalidFlags.join(', ')}. Budget/quota flags require positive numbers. Mission not dispatched.`);
|
|
71
|
+
return { exitCode: 1 };
|
|
72
|
+
}
|
|
73
|
+
if (mode === 'pty-orchestrator' && !targetAgent) {
|
|
74
|
+
ui.error('--mode pty-orchestrator requires --target-agent <agent-id>');
|
|
75
|
+
return { exitCode: 1 };
|
|
76
|
+
}
|
|
77
|
+
const selected = await findActiveSession(sessionId);
|
|
78
|
+
if (!selected) {
|
|
79
|
+
ui.error(sessionId ? `Session not found: ${sessionId}` : 'No active session. Run `aiwg mc start` first.');
|
|
80
|
+
return { exitCode: 1 };
|
|
81
|
+
}
|
|
82
|
+
// mission-dispatch accepts only the frozen objective envelope. Worker
|
|
83
|
+
// bindings can arrive through its existing session, so inspect that payload.
|
|
84
|
+
try {
|
|
85
|
+
const cfg = await readAdmissionConfig(ctx.cwd || process.cwd());
|
|
86
|
+
const support = cfg?.parallelism?.worker_dispatch && cfg.parallelism.worker_mode === 'managed' ? mcWorkerSupport() : undefined;
|
|
87
|
+
assertMissionWorkerHandoff(selected, 'mc-cli', support);
|
|
88
|
+
for (const mission of selected.missions)
|
|
89
|
+
assertMissionWorkerHandoff(mission, 'mc-cli', support);
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
93
|
+
ui.error(message);
|
|
94
|
+
return { exitCode: 1, message };
|
|
95
|
+
}
|
|
96
|
+
// #1361: Check project-level parallelism cap. Active missions = running or
|
|
97
|
+
// queued; if at cap, warn but still queue (FIFO behavior — the mission goes
|
|
98
|
+
// into the session as 'queued' and will run when a slot frees up).
|
|
99
|
+
let capWarning;
|
|
100
|
+
try {
|
|
101
|
+
const { readAiwgConfig, resolveParallelism } = await import('../../config/aiwg-config.js');
|
|
102
|
+
const cfg = await readAiwgConfig(ctx.cwd || process.cwd());
|
|
103
|
+
if (cfg) {
|
|
104
|
+
const resolved = resolveParallelism(cfg.parallelism, cfg.providers[0]);
|
|
105
|
+
const activeCount = selected.missions.filter(m => m.status === 'running' || m.status === 'queued' || m.status === 'paused').length;
|
|
106
|
+
if (activeCount >= resolved.max_parallel_mc_missions) {
|
|
107
|
+
capWarning = `Active missions (${activeCount}) at or above project parallelism cap (${resolved.max_parallel_mc_missions}). Mission will queue; bump via 'aiwg config set --project parallelism.max_parallel_mc_missions N'.`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// Non-fatal — config read failure doesn't block dispatch
|
|
113
|
+
}
|
|
114
|
+
const flags = mutationFlags(ctx.args);
|
|
115
|
+
const mission = {
|
|
116
|
+
id: flags.requestId
|
|
117
|
+
? `m-${createHash('sha256').update(flags.requestId).digest('hex').slice(0, 16)}`
|
|
118
|
+
: genId('m'),
|
|
119
|
+
objective,
|
|
120
|
+
completion,
|
|
121
|
+
status: 'queued',
|
|
122
|
+
loop: 0,
|
|
123
|
+
maxIterations,
|
|
124
|
+
maxTotalTokens,
|
|
125
|
+
maxOutputTokens,
|
|
126
|
+
maxToolCalls,
|
|
127
|
+
maxTotalCost,
|
|
128
|
+
maxWallClockMinutes,
|
|
129
|
+
explorationQuota,
|
|
130
|
+
budgetStopPolicy,
|
|
131
|
+
priority,
|
|
132
|
+
mode,
|
|
133
|
+
targetAgent: targetAgent || undefined,
|
|
134
|
+
};
|
|
135
|
+
const dispatchPath = parseFlag(ctx.args, '--worker-dispatch');
|
|
136
|
+
if (dispatchPath) {
|
|
137
|
+
try {
|
|
138
|
+
const cfg = await readAdmissionConfig(ctx.cwd || process.cwd());
|
|
139
|
+
if (!cfg?.parallelism?.worker_dispatch || cfg.parallelism.worker_mode !== 'managed' || mode !== 'direct') {
|
|
140
|
+
throw new Error('OG_CONTRACT_UNSUPPORTED: worker dispatch requires the managed MC caller');
|
|
141
|
+
}
|
|
142
|
+
if (!isAbsolute(dispatchPath) || relative(ctx.cwd, dispatchPath).startsWith('..'))
|
|
143
|
+
throw new Error('Worker dispatch path must be inside the project');
|
|
144
|
+
const dispatch = await readWorkerJson(dispatchPath);
|
|
145
|
+
mission.extensions = { 'aiwg.worker-dispatch': dispatch };
|
|
146
|
+
assertMissionWorkerHandoff(mission, 'mc-cli', mcWorkerSupport());
|
|
147
|
+
await resolveMcWorker(ctx, selected, mission);
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return managedControlFailure(error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
const result = await mutateSession(selected.id, 'dispatch', mission.id, flags.expectedUpdatedAt, flags.requestId, session => {
|
|
154
|
+
if (session.state !== 'active')
|
|
155
|
+
return 'invalid_state';
|
|
156
|
+
if (session.missions.length >= session.maxMissions)
|
|
157
|
+
return 'capacity';
|
|
158
|
+
session.missions.push(mission);
|
|
159
|
+
return undefined;
|
|
160
|
+
});
|
|
161
|
+
if (!result.ok)
|
|
162
|
+
return mutationFailure(result);
|
|
163
|
+
if (!result.replayed) {
|
|
164
|
+
await appendLog(selected.id, {
|
|
165
|
+
event: 'mission_dispatched',
|
|
166
|
+
missionId: mission.id,
|
|
167
|
+
objective,
|
|
168
|
+
priority,
|
|
169
|
+
mode,
|
|
170
|
+
targetAgent,
|
|
171
|
+
requestId: flags.requestId ?? null,
|
|
172
|
+
lfdBudgets: {
|
|
173
|
+
maxTotalTokens,
|
|
174
|
+
maxOutputTokens,
|
|
175
|
+
maxToolCalls,
|
|
176
|
+
maxTotalCost,
|
|
177
|
+
maxWallClockMinutes,
|
|
178
|
+
explorationQuota,
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
if (capWarning)
|
|
183
|
+
ui.warn(capWarning);
|
|
184
|
+
ui.success(`${result.replayed ? 'Replayed dispatch for' : 'Dispatched mission'} ${mission.id}: ${objective}`);
|
|
185
|
+
const modeLabel = mode === 'pty-orchestrator' ? ` | Mode: PTY orchestrator → ${targetAgent}` : '';
|
|
186
|
+
ui.info(`Priority: ${priority} | Max iterations: ${maxIterations}${modeLabel}`);
|
|
187
|
+
const lfdLimits = [
|
|
188
|
+
maxTotalTokens ? `total tokens ${maxTotalTokens}` : null,
|
|
189
|
+
maxOutputTokens ? `output tokens ${maxOutputTokens}` : null,
|
|
190
|
+
maxToolCalls ? `tool calls ${maxToolCalls}` : null,
|
|
191
|
+
maxTotalCost ? `total cost $${maxTotalCost}` : null,
|
|
192
|
+
maxWallClockMinutes ? `wall clock ${maxWallClockMinutes}m` : null,
|
|
193
|
+
explorationQuota ? `exploration quota ${explorationQuota}` : null,
|
|
194
|
+
].filter(Boolean);
|
|
195
|
+
if (lfdLimits.length > 0) {
|
|
196
|
+
ui.info(`LFD limits: ${lfdLimits.join(' | ')}`);
|
|
197
|
+
}
|
|
198
|
+
// #1439: dispatch alone does NOT execute the mission. Surface the next step
|
|
199
|
+
// so the user knows the queue won't drain on its own.
|
|
200
|
+
ui.info(`Next: run \`aiwg mc run ${selected.id}\` to launch queued missions as ralph loops.`);
|
|
201
|
+
return { exitCode: 0, message: mission.id };
|
|
202
|
+
}
|
|
203
|
+
//# sourceMappingURL=mc-dispatch.js.map
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
// Mission Control help operations, extracted from the shared handler.
|
|
2
|
+
import * as ui from '../ui.js';
|
|
3
|
+
/**
|
|
4
|
+
* Per-subcommand usage strings (#1440).
|
|
5
|
+
*
|
|
6
|
+
* `aiwg mc <subcommand> --help` MUST print this text and exit before any
|
|
7
|
+
* side-effecting logic. The previous behavior — running `aiwg mc start --help`
|
|
8
|
+
* actually created a session — violated the universal `--help` convention.
|
|
9
|
+
*/
|
|
10
|
+
export const subcommandUsage = {
|
|
11
|
+
summary: `Usage: aiwg mc summary --ledger <path> [--json]
|
|
12
|
+
|
|
13
|
+
Read an existing Mission conductor ledger without syncing or writing it.
|
|
14
|
+
Accepted requires an independent review result with evidence references.
|
|
15
|
+
Completed means worker execution finished without independent acceptance.
|
|
16
|
+
Routed, plan-only and unmeasured work remain unknown.
|
|
17
|
+
|
|
18
|
+
--ledger <path> Existing conductor ledger JSON (relative to the working directory)
|
|
19
|
+
--json Emit cycle classifications, reasons, evidence and counts`,
|
|
20
|
+
start: `Usage: aiwg mc start [--name "<label>"] [--max-missions N]
|
|
21
|
+
|
|
22
|
+
Create a new Mission Control session for tracking background missions.
|
|
23
|
+
|
|
24
|
+
--name <label> Human-readable session name (default: "Mission YYYY-MM-DD")
|
|
25
|
+
--max-missions N Capacity limit for queued missions (default: 10)
|
|
26
|
+
|
|
27
|
+
Note: 'start' only creates the session. Use 'dispatch' to queue missions and
|
|
28
|
+
'run' to drain the queue.`,
|
|
29
|
+
dispatch: `Usage: aiwg mc dispatch <session-id> "<objective>" [options]
|
|
30
|
+
|
|
31
|
+
Queue a mission onto a session. Does NOT execute — use 'aiwg mc run' to launch.
|
|
32
|
+
|
|
33
|
+
--completion "<criteria>" Verifiable completion criteria (required for 'mc run')
|
|
34
|
+
--priority <level> Priority hint (default: normal)
|
|
35
|
+
--max-iterations N Ralph iteration cap when launched (default: 10)
|
|
36
|
+
--max-total-tokens N Hard cumulative token ceiling when observable
|
|
37
|
+
--max-output-tokens N Hard cumulative output-token ceiling
|
|
38
|
+
--max-tool-calls N Hard cumulative tool-call ceiling
|
|
39
|
+
--max-total-cost USD Hard cumulative provider-reported spend ceiling
|
|
40
|
+
--max-wall-clock-minutes N Hard cumulative runtime ceiling
|
|
41
|
+
--exploration-quota K Require structural variant after K flat cycles
|
|
42
|
+
(off unless declared; no default K)
|
|
43
|
+
--budget-stop-policy P completion-wins (default) | budget-wins
|
|
44
|
+
--mode pty-orchestrator PTY-orchestrator mode (requires --target-agent)
|
|
45
|
+
--target-agent <id> Required for --mode pty-orchestrator
|
|
46
|
+
--worker-dispatch <path> Prepared managed worker dispatch JSON (queues only)
|
|
47
|
+
--expected-updated-at <time> Reject stale state with exit 3
|
|
48
|
+
--request-id <id> Idempotent dispatch key`,
|
|
49
|
+
run: `Usage: aiwg mc run [<session-id>] [--accept-cost]
|
|
50
|
+
|
|
51
|
+
Drain queued missions in a session by launching each as a ralph loop. Missions
|
|
52
|
+
without --completion criteria are skipped with a warning.
|
|
53
|
+
|
|
54
|
+
--accept-cost Skip the cost-warning gate (required for non-TTY contexts
|
|
55
|
+
when estimated cumulative cost exceeds $5). See #1450.
|
|
56
|
+
|
|
57
|
+
The estimate is the cumulative iteration floor (missions x max-iterations x
|
|
58
|
+
~$1.60 cache cost per headless iteration). A mission's --max-total-cost caps its
|
|
59
|
+
share of that estimate only on a provider that reports spend; on a provider that
|
|
60
|
+
reports none the ceiling is inert (#1766), so it is reported but not subtracted.
|
|
61
|
+
See #2522.`,
|
|
62
|
+
status: `Usage: aiwg mc status [<session-id>] [--json]
|
|
63
|
+
|
|
64
|
+
Show mission status for a session. Auto-syncs from ralph loop state files.
|
|
65
|
+
|
|
66
|
+
--json Emit JSON instead of human-readable table`,
|
|
67
|
+
watch: `Usage: aiwg mc watch [<session-id>]
|
|
68
|
+
|
|
69
|
+
Live-monitor mission progress (non-interactive context prints status once).`,
|
|
70
|
+
abort: `Usage: aiwg mc abort <session-id> <mission-id>
|
|
71
|
+
|
|
72
|
+
Mark a specific mission as aborted.
|
|
73
|
+
|
|
74
|
+
--expected-updated-at <timestamp> Reject stale state with exit 3
|
|
75
|
+
--request-id <id> Idempotent mutation key`,
|
|
76
|
+
pause: `Usage: aiwg mc pause [<session-id>]
|
|
77
|
+
|
|
78
|
+
Pause an active session; running missions transition to 'paused' status.
|
|
79
|
+
|
|
80
|
+
--expected-updated-at <timestamp> Reject stale state with exit 3
|
|
81
|
+
--request-id <id> Idempotent mutation key`,
|
|
82
|
+
resume: `Usage: aiwg mc resume [<session-id>]
|
|
83
|
+
|
|
84
|
+
Resume a paused session; paused missions transition back to 'running'.
|
|
85
|
+
|
|
86
|
+
--expected-updated-at <timestamp> Reject stale state with exit 3
|
|
87
|
+
--request-id <id> Idempotent mutation key`,
|
|
88
|
+
stop: `Usage: aiwg mc stop [<session-id>] [--drain]
|
|
89
|
+
|
|
90
|
+
Shut down a session.
|
|
91
|
+
|
|
92
|
+
--drain Cancel queued, let running finish (default: abort all non-completed)`,
|
|
93
|
+
list: `Usage: aiwg mc list [--json]
|
|
94
|
+
|
|
95
|
+
List all Mission Control sessions.`,
|
|
96
|
+
agents: `Usage: aiwg mc agents [filters] [--json]
|
|
97
|
+
|
|
98
|
+
Query routable agents from a local 'aiwg serve' instance.
|
|
99
|
+
|
|
100
|
+
--framework <name> Require an AIWG framework (repeatable)
|
|
101
|
+
--sandbox <id> Restrict to a sandbox
|
|
102
|
+
--agent <id> Restrict to a specific agent ID
|
|
103
|
+
--name <n> Match by logical name
|
|
104
|
+
--max-cpu <pct> Reject agents above this CPU %
|
|
105
|
+
--min-memory <gb> Reject agents below this memory threshold
|
|
106
|
+
--json Output raw JSON`,
|
|
107
|
+
};
|
|
108
|
+
export function printSubcommandHelp(name) {
|
|
109
|
+
const text = subcommandUsage[name];
|
|
110
|
+
ui.blank();
|
|
111
|
+
if (text) {
|
|
112
|
+
console.log(` ${text}`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.log(` No detailed help for 'aiwg mc ${name}'. Run 'aiwg mc --help' for the full reference.`);
|
|
116
|
+
}
|
|
117
|
+
ui.blank();
|
|
118
|
+
}
|
|
119
|
+
export function showMcHelp() {
|
|
120
|
+
ui.blank();
|
|
121
|
+
console.log(` ${ui.brandMark()} ${ui.bold('Mission Control')} — multi-loop background orchestration`);
|
|
122
|
+
ui.rule();
|
|
123
|
+
console.log(`
|
|
124
|
+
${ui.bold('Usage:')} aiwg mc <subcommand> [options]
|
|
125
|
+
|
|
126
|
+
${ui.bold('Lifecycle:')}
|
|
127
|
+
1. start — create a session (state-tracking only)
|
|
128
|
+
2. dispatch — queue one or more missions onto a session
|
|
129
|
+
3. run — drain the queue by launching each mission as a ralph loop
|
|
130
|
+
4. status — view progress (auto-syncs from ralph loop state)
|
|
131
|
+
5. watch — live tail of progress
|
|
132
|
+
6. stop — shut down the session
|
|
133
|
+
|
|
134
|
+
${ui.bold('Subcommands:')}
|
|
135
|
+
start Start a new Mission Control session
|
|
136
|
+
dispatch <id> "<objective>" Queue a mission on the session (does NOT execute)
|
|
137
|
+
[--completion "<criteria>"] [--max-iterations N]
|
|
138
|
+
[--max-total-tokens N] [--max-output-tokens N]
|
|
139
|
+
[--max-tool-calls N] [--max-total-cost USD]
|
|
140
|
+
[--max-wall-clock-minutes N] [--exploration-quota N]
|
|
141
|
+
[--mode pty-orchestrator] [--target-agent <id>]
|
|
142
|
+
run <id> [--accept-cost] Launch queued missions as ralph loops (#1439)
|
|
143
|
+
Cost gate warns/refuses above ~$5 estimate
|
|
144
|
+
status [<id>] [--json] View mission status dashboard
|
|
145
|
+
summary --ledger <path> [--json] Read accepted, completed, failed and unknown work
|
|
146
|
+
watch [<id>] Live monitor (streaming)
|
|
147
|
+
abort|cancel <session> <mission> Abort a specific mission
|
|
148
|
+
pause [<id>] Pause active session
|
|
149
|
+
resume [<id>] Resume paused session
|
|
150
|
+
stop [<id>] [--drain] Shut down session
|
|
151
|
+
list [--json] List all sessions
|
|
152
|
+
agents [--filter] [--json] Query routable agents from aiwg serve (#916)
|
|
153
|
+
${ui.bold('Examples:')}
|
|
154
|
+
aiwg mc start --name "Sprint 4"
|
|
155
|
+
aiwg mc dispatch mc-abc123 "Fix auth" --completion "tests pass"
|
|
156
|
+
aiwg mc dispatch mc-abc123 "Fix auth" --completion "tests pass" --max-total-tokens 5000 --exploration-quota 2
|
|
157
|
+
aiwg mc dispatch mc-abc123 "Refactor users" --completion "npm test passes"
|
|
158
|
+
aiwg mc run mc-abc123 # launches queued missions
|
|
159
|
+
aiwg mc status mc-abc123 # syncs progress from ralph loops
|
|
160
|
+
aiwg mc dispatch mc-abc123 "Supervise agent-01" --mode pty-orchestrator --target-agent agent-01 --completion "migration complete"
|
|
161
|
+
aiwg mc stop mc-abc123 --drain
|
|
162
|
+
aiwg mc agents --framework sdlc-complete --max-cpu 80
|
|
163
|
+
|
|
164
|
+
${ui.bold('A2A route for new sandbox work:')}
|
|
165
|
+
GET /api/v2/admin/instances
|
|
166
|
+
GET /agents/{instance_id}/.well-known/agent-card.json
|
|
167
|
+
GET /agents/{instance_id}/v1/extendedAgentCard
|
|
168
|
+
POST /agents/{instance_id}/v1/messages:send
|
|
169
|
+
`);
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=mc-help.js.map
|