@staix/agent-hub 0.52.0 → 0.54.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/CHANGELOG.md +37 -0
- package/README.md +4 -3
- package/docs/addons/open-code-review.md +3 -6
- package/docs/agent-notes/README.md +1 -1
- package/docs/agent-notes/adapters.md +5 -4
- package/docs/agent-notes/budget.md +2 -2
- package/docs/agent-notes/bus.md +1 -0
- package/docs/agent-notes/daemon.md +6 -5
- package/docs/agent-notes/models.md +1 -1
- package/docs/agent-notes/tasks.md +3 -3
- package/docs/agent-notes/tests.md +4 -4
- package/docs/contracts/companion-cli-v2.json +90 -0
- package/docs/contracts/companion-cli-v3.json +348 -0
- package/docs/design/adapters.md +1 -1
- package/docs/design/agent-hub-architecture.md +8 -5
- package/docs/design/bus.md +1 -1
- package/docs/design/cli-output-inventory.md +4 -2
- package/docs/design/execution-reference.md +1 -1
- package/docs/design/guidance-experiments.md +1 -0
- package/docs/design/guidance-probes.md +1 -0
- package/docs/design/model-routes.md +20 -5
- package/docs/design/roadmap.md +6 -4
- package/docs/design/task-board.md +21 -2
- package/docs/dogfood.md +13 -6
- package/docs/events.md +1 -1
- package/docs/memory.md +2 -2
- package/docs/operations.md +158 -50
- package/docs/quickstart.md +14 -2
- package/docs/security.md +17 -9
- package/docs/specs/2026-09-19-agent-hub-design.md +5 -3
- package/docs/specs/2026-09-19-multi-project-design.md +1 -1
- package/docs/specs/2026-09-20-upgrade-recovery-design.md +24 -0
- package/docs/specs/2026-12-04-arev-adoption-design.md +84 -0
- package/docs/specs/mcp-endpoint.md +15 -4
- package/docs/specs/relay-contract.md +38 -0
- package/docs/verification/2026-12-04-host-shared-receipts.md +43 -0
- package/docs/verification/2026-12-05-0.53.0.md +101 -0
- package/docs/verification/2026-12-05-agy-1.5.24.md +55 -0
- package/docs/verification/2026-12-05-claude-implementer-2.1.337.md +43 -0
- package/docs/verification/2026-12-06-0.54.0.md +76 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-isolation.md +43 -0
- package/docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md +34 -0
- package/docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md +25 -0
- package/docs/verification/2026-12-06-compat-pi-1.8.0.md +23 -0
- package/docs/verified.json +38 -29
- package/package.json +9 -3
- package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
- package/plugins/agent-hub/.mcp.json +1 -1
- package/plugins/agent-hub/compat.json +9 -5
- package/plugins/agent-hub/kimi-hook.js +892 -874
- package/plugins/agent-hub/relay-launcher.js +24 -0
- package/plugins/agent-hub/server.js +27271 -25146
- package/src/adapters/acp-session-model.ts +1 -1
- package/src/adapters/acp.ts +5 -4
- package/src/adapters/agy/definition.ts +1 -1
- package/src/adapters/agy/hooks.ts +1 -1
- package/src/adapters/channel-peer.ts +3 -1
- package/src/adapters/claude-channel-evidence.ts +26 -1
- package/src/adapters/claude-channel.ts +27 -30
- package/src/adapters/claude-connection-policy.ts +62 -0
- package/src/adapters/claude-relay.ts +255 -0
- package/src/adapters/codex-review-isolation.ts +1 -2
- package/src/adapters/compat.ts +28 -18
- package/src/adapters/definitions/native-cli-preview-pi.ts +2 -1
- package/src/adapters/definitions/native-config-defaults.ts +1 -1
- package/src/adapters/definitions/native-context.ts +1 -2
- package/src/adapters/definitions/native-factories.ts +4 -1
- package/src/adapters/definitions/native-quota.ts +1 -1
- package/src/adapters/definitions/native-recovery.ts +3 -1
- package/src/adapters/external-modules.ts +2 -2
- package/src/adapters/kimi-review.ts +1 -1
- package/src/adapters/kimi-tui-facts.ts +1 -1
- package/src/adapters/local-worker.ts +3 -3
- package/src/adapters/native-capabilities.ts +1 -1
- package/src/adapters/pi.ts +26 -7
- package/src/adapters/registry-types.ts +2 -0
- package/src/adapters/relay-launcher.ts +27 -0
- package/src/adapters/reviewer-mcp.ts +1 -1
- package/src/cli/agents.ts +20 -8
- package/src/cli/agy-mcp.ts +1 -1
- package/src/cli/claude-profile-hook.ts +1 -1
- package/src/cli/command-table.ts +1 -0
- package/src/cli/commands/agents.ts +18 -1
- package/src/cli/commands/doctor.ts +18 -4
- package/src/cli/commands/launch-line.ts +32 -0
- package/src/cli/commands/status.ts +14 -3
- package/src/cli/help.ts +7 -4
- package/src/cli/identity.ts +1 -1
- package/src/cli/init-roles.ts +1 -1
- package/src/cli/init-settings.ts +1 -1
- package/src/cli/launch-line-plan.ts +82 -0
- package/src/cli/launch-line-project.ts +13 -0
- package/src/cli/main.ts +10 -9
- package/src/cli/pi-steps-warning.ts +14 -0
- package/src/cli/recovery-package.ts +60 -6
- package/src/cli/reset.ts +1 -1
- package/src/cli/shell-quote.ts +1 -3
- package/src/cli/upgrade-interactive.ts +7 -2
- package/src/cli/upgrade-keep-plan.ts +47 -0
- package/src/cli/upgrade-restore-state.ts +1 -1
- package/src/cli/upgrade-runtime.ts +119 -18
- package/src/cli/upgrade.ts +17 -2
- package/src/hub/accounts.ts +8 -4
- package/src/hub/action-class.ts +1 -3
- package/src/hub/adec-triage.ts +105 -0
- package/src/hub/autonomy.ts +1 -1
- package/src/hub/board.ts +3 -27
- package/src/hub/bus.ts +39 -6
- package/src/hub/capabilities.ts +1 -1
- package/src/hub/channel-project-base.ts +46 -0
- package/src/hub/channel-project.ts +21 -46
- package/src/hub/config-apply.ts +1 -1
- package/src/hub/config-edit.ts +1 -1
- package/src/hub/config-tier.ts +1 -1
- package/src/hub/config.ts +2 -2
- package/src/hub/confirmation-matrix.ts +1 -1
- package/src/hub/control/board-messages.ts +415 -0
- package/src/hub/control/dashboard-messages.ts +221 -0
- package/src/hub/control/delivery-messages.ts +356 -0
- package/src/hub/control/dispatch.ts +114 -0
- package/src/hub/control/hub-tool-helpers.ts +243 -0
- package/src/hub/control/hub-tools.ts +147 -0
- package/src/hub/control/native-messages.ts +665 -0
- package/src/hub/control/operations-messages.ts +269 -0
- package/src/hub/control/peer-messages.ts +126 -0
- package/src/hub/control/recovery-messages.ts +391 -0
- package/src/hub/control/recovery-operation.ts +480 -0
- package/src/hub/control/scope.ts +460 -0
- package/src/hub/control/sdlc-messages.ts +373 -0
- package/src/hub/control/task-ops-more.ts +245 -0
- package/src/hub/control/task-ops.ts +553 -0
- package/src/hub/control/ui-actions.ts +241 -0
- package/src/hub/control-write-trace.ts +1 -4
- package/src/hub/daemon.ts +485 -4324
- package/src/hub/delivery-hints.ts +2 -0
- package/src/hub/delivery-journal.ts +17 -6
- package/src/hub/events.ts +2 -1
- package/src/hub/execution-reference.ts +1 -1
- package/src/hub/host.ts +41 -9
- package/src/hub/hub-tools.ts +3 -4
- package/src/hub/invocations.ts +1 -1
- package/src/hub/lifecycle.ts +4 -3
- package/src/hub/mcp-endpoint-serve.ts +4 -3
- package/src/hub/mcp-endpoint.ts +15 -6
- package/src/hub/memory-profile-check.ts +1 -1
- package/src/hub/no-writes.ts +1 -1
- package/src/hub/peers.ts +2 -0
- package/src/hub/pi-exit-policy.ts +27 -0
- package/src/hub/progress.ts +1 -1
- package/src/hub/project-runtime-state.ts +17 -4
- package/src/hub/project-runtime.ts +3 -1
- package/src/hub/protocol-window.ts +1 -1
- package/src/hub/recovery-continuity.ts +3 -3
- package/src/hub/recovery-kept-roster.ts +50 -0
- package/src/hub/review-anchor.ts +13 -181
- package/src/hub/review-brief.ts +78 -28
- package/src/hub/review-findings.ts +15 -193
- package/src/hub/review-ledger.ts +162 -0
- package/src/hub/review-material.ts +3 -3
- package/src/hub/reviewer-pool.ts +4 -2
- package/src/hub/roadmap-issue-states.ts +65 -14
- package/src/hub/roadmap-sync.ts +39 -14
- package/src/hub/routing.ts +9 -0
- package/src/hub/runtime-capture-prune.ts +8 -2
- package/src/hub/runtime-package-assets.ts +3 -0
- package/src/hub/sdlc-release-policy.ts +1 -2
- package/src/hub/settings.ts +1 -1
- package/src/hub/spec-ack-tool.ts +4 -0
- package/src/hub/spec-report-history.ts +36 -0
- package/src/hub/specs.ts +1 -4
- package/src/hub/supervision.ts +33 -6
- package/src/hub/tasks-audit.ts +390 -0
- package/src/hub/tasks-backlog.ts +522 -0
- package/src/hub/tasks-handoff.ts +208 -0
- package/src/hub/tasks-release.ts +257 -0
- package/src/hub/tasks-roadmap.ts +17 -3
- package/src/hub/tasks-specs.ts +672 -0
- package/src/hub/tasks-types.ts +334 -0
- package/src/hub/tasks.ts +286 -1961
- package/src/hub/upgrade-session-contract.ts +11 -0
- package/src/local/probe-sandbox.ts +1 -2
- package/src/local/probe-workspace.ts +1 -1
- package/src/models/route/config.ts +4 -4
- package/src/models/route/decision.ts +18 -10
- package/src/models/route/observation-signals.ts +1 -2
- package/src/models/route/runtime.ts +8 -5
- package/src/npm-artifact.ts +76 -0
- package/src/omniroute/client.ts +6 -0
- package/src/pi/extension.ts +5 -2
- package/src/pi/install.ts +77 -0
- package/src/pi/pin.ts +49 -0
- package/src/primitives.ts +14 -0
- package/src/version.ts +2 -0
- package/templates/adec/README.md +10 -6
- package/templates/config.json +1 -1
- package/templates/specs.block.md +1 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { runtimePruneHealth } from "../../hub/runtime-prune-health.ts";
|
|
2
2
|
import { kimiSourceRow } from "../../hub/budget-notes.ts";
|
|
3
|
-
import { agentVersions } from "../agents.ts";
|
|
3
|
+
import { agentVersions, piInstallReport } from "../agents.ts";
|
|
4
4
|
import { assessVersion, COMPAT, configuredCommands } from "../../adapters/compat.ts";
|
|
5
5
|
import { readInstanceRoleConfig, readInstanceConfigLayers } from "../../hub/instance-config.ts";
|
|
6
6
|
import { rosterAllows } from "../../hub/roster.ts";
|
|
@@ -20,6 +20,7 @@ import { homedir } from "node:os";
|
|
|
20
20
|
import { join, resolve } from "node:path";
|
|
21
21
|
import { readControl } from "../../hub/control-client.ts";
|
|
22
22
|
import { loadConfig } from "../../hub/config.ts";
|
|
23
|
+
import { piMaxStepsWarning } from "../pi-steps-warning.ts";
|
|
23
24
|
import { pullRegistrationChecks } from "../../adapters/presets.ts";
|
|
24
25
|
import { Registry } from "../../hub/registry.ts";
|
|
25
26
|
import { OmniRoute } from "../../omniroute/client.ts";
|
|
@@ -107,10 +108,17 @@ export async function run(context: CommandContext) {
|
|
|
107
108
|
.filter(peer => roster(peer) && ((config.roles[peer] ?? []).includes("implementer") || [...(definitionOf(peer, scope.instances)?.roles ?? [])].includes("implementer")))
|
|
108
109
|
.sort();
|
|
109
110
|
const file = join(cwd, ".agenthub", "routing.toml");
|
|
110
|
-
const
|
|
111
|
+
const routing = loadRouting(cwd);
|
|
112
|
+
const result = classListRow(implementers, routing, file, existsSync(file));
|
|
113
|
+
for (const [id, route] of Object.entries(routing.hub_routes ?? {})) {
|
|
114
|
+
if (route.decision_mode === "enforce") row(true, "adec route", `${JSON.stringify(id)}: enforce`);
|
|
115
|
+
}
|
|
111
116
|
// An advisory row, so it warns rather than failing: only a row the person must repair is a fail.
|
|
112
117
|
checks.push({ name: "routing classes", section: "Config", level: result.ok === undefined ? "warn" : result.ok ? "ok" : "fail", detail: result.detail });
|
|
113
118
|
} catch (error) { row(undefined, "routing classes", `could not be checked: ${error instanceof Error ? error.message : "unknown error"}`); }
|
|
119
|
+
// #1967 T3: a warning, never a failure, like the rows above.
|
|
120
|
+
const stepsWarning = piMaxStepsWarning(cwd);
|
|
121
|
+
if (stepsWarning) row(undefined, "pi max_steps", stepsWarning);
|
|
114
122
|
for (const bin of DOCTOR_TOOL_PROBES) {
|
|
115
123
|
const v = version(bin);
|
|
116
124
|
row(!!v, bin, v ?? "not found on PATH");
|
|
@@ -202,6 +210,9 @@ export async function run(context: CommandContext) {
|
|
|
202
210
|
for (const agent of agentVersions(configuredCommands(config))) {
|
|
203
211
|
if (agent.executable && !(agent.verdict.ok && agent.verdict.state === "verified")) row(agent.verdict.ok ? undefined : false, `${agent.id} version`, agent.verdict.ok ? agent.verdict.note ?? agent.verdict.state : agent.verdict.reason);
|
|
204
212
|
}
|
|
213
|
+
const piInstall = piInstallReport();
|
|
214
|
+
row(true, "Pi install", piInstall.detail);
|
|
215
|
+
if (piInstall.command) row(undefined, "Pi install command", piInstall.command);
|
|
205
216
|
// #1808 T4: when Orca is installed, a read-only shape check of the answers the upgrade recovery reads (names and types, never a value); it never refuses anything.
|
|
206
217
|
const orca = Bun.which(orcaExecutable());
|
|
207
218
|
if (orca) { const found = orcaDoctorRow(await readOrcaProbe(orcaProbeRunner(orca))); row(found.ok, found.name, found.detail); }
|
|
@@ -215,8 +226,11 @@ export async function run(context: CommandContext) {
|
|
|
215
226
|
row(undefined, "routing models", "routing could not be read");
|
|
216
227
|
} else if (gateway && omni.apiKey()) {
|
|
217
228
|
try {
|
|
218
|
-
const
|
|
219
|
-
|
|
229
|
+
const routeAliases = Object.values(routing.hub_routes ?? {}).flatMap(route => [
|
|
230
|
+
route.efficient ?? "fast", route.capable ?? "coding", ...(route.judge ? [route.judge] : []),
|
|
231
|
+
...(route.type === "decision" && route.decision_mode === "enforce" ? route.candidates?.map(candidate => candidate.alias) ?? [] : []),
|
|
232
|
+
]);
|
|
233
|
+
const aliases = new Set([routing.local.fixed_model, ...Object.values(routing.classes).flatMap(policy => policy.fixed_model ? [policy.fixed_model] : []), ...routeAliases]);
|
|
220
234
|
const served = new Set(await omni.models());
|
|
221
235
|
const missing = [...aliases].filter(alias => !served.has(alias)).sort();
|
|
222
236
|
for (const alias of missing) row(false, "routing model", `${alias} is not served by the gateway`);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { builtinDeclarationOf } from "../../adapters/declaration-catalog.ts";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { projectChildEnv } from "../../hub/project.ts";
|
|
4
|
+
import type { CommandContext } from "../command-context.ts";
|
|
5
|
+
import { LAUNCH_LINE_MIN_DAEMON, buildLaunchLineCommand, daemonMeetsContract, parseLaunchLineArgs, resolveLaunchExecutable } from "../launch-line-plan.ts";
|
|
6
|
+
|
|
7
|
+
export async function run({ args, caller, cwd, stateDir, connect, fail, outputOptions }: CommandContext): Promise<void> {
|
|
8
|
+
const split = args.indexOf("--"), head = split < 0 ? args : args.slice(0, split);
|
|
9
|
+
const options = outputOptions(head);
|
|
10
|
+
const request = parseLaunchLineArgs(args);
|
|
11
|
+
if ("refusal" in request) return fail(`${request.refusal}; see ahub help launch-line`);
|
|
12
|
+
if (!options.json) return fail("usage: ahub launch-line <kind> --json [--exec <absolute-path|self>] [-- <launch arguments>]");
|
|
13
|
+
const { kind } = request;
|
|
14
|
+
if (caller.role !== "console") return fail("launch-line is person-only; run ahub launch-line <kind> --json from your terminal");
|
|
15
|
+
const definition = kind && builtinDeclarationOf(kind);
|
|
16
|
+
if (!kind || !definition || !definition.session.launchRecord || !["claude-channel", "codex-appserver"].includes(definition.transport)) return fail("no companion launch for this kind; use ahub launch-line claude --json or ahub launch-line codex --json");
|
|
17
|
+
const executable = resolveLaunchExecutable(request.exec, { runtime: process.execPath, entry: join(import.meta.dir, "..", "main.js") });
|
|
18
|
+
if ("refusal" in executable) return fail(`${executable.refusal}; see ahub help launch-line`);
|
|
19
|
+
const hub = await connect();
|
|
20
|
+
try {
|
|
21
|
+
const { status } = await hub.request({ t: "status" });
|
|
22
|
+
// A daemon older than this contract never yields a join line: nothing is printed (#1963).
|
|
23
|
+
if (!daemonMeetsContract(status?.version)) return fail(`running hub is older than ${LAUNCH_LINE_MIN_DAEMON} or does not report its version; run ahub upgrade, then retry`);
|
|
24
|
+
if (status?.cwd !== cwd) return fail("project status is unavailable; inspect ahub status before requesting a launch line");
|
|
25
|
+
if (status.peers?.[kind]?.rostered === false) return fail(`${kind} is off roster; check ahub status before retrying`);
|
|
26
|
+
// The normal terminal entry applies the selected home, permissions and native handshakes when Orca actually launches it.
|
|
27
|
+
if (options.json) console.log(JSON.stringify({
|
|
28
|
+
command: buildLaunchLineCommand(cwd, kind, executable, request.launchArgs),
|
|
29
|
+
env: projectChildEnv({ root: cwd, stateDir }),
|
|
30
|
+
}));
|
|
31
|
+
} finally { hub.close(); }
|
|
32
|
+
}
|
|
@@ -6,15 +6,26 @@ import { goalCommand } from "../memory.ts";
|
|
|
6
6
|
import { memoryIndexExists } from "../../hub/memory-profile.ts";
|
|
7
7
|
import { asciiMarkers } from "../console-state.ts";
|
|
8
8
|
import { renderStatus, renderStatusDefault } from "../output.ts";
|
|
9
|
+
import { launcherOf } from "../terminal-recovery.ts";
|
|
9
10
|
import type { CommandContext } from "../command-context.ts";
|
|
10
11
|
|
|
11
|
-
export async function run({ args, connect, cwd, outputOptions, printOutput, printProjects }: CommandContext) {
|
|
12
|
+
export async function run({ args, caller, connect, cwd, stateDir, outputOptions, printOutput, printProjects }: CommandContext) {
|
|
12
13
|
const options = outputOptions();
|
|
13
14
|
if (args.includes("--all")) return printProjects(options);
|
|
14
15
|
const hub = await connect();
|
|
15
16
|
try {
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
const companion = options.json && caller.role === "console";
|
|
18
|
+
const { status } = await hub.request({ t: "status", specs: true, ...(companion ? { companion: true } : {}) });
|
|
19
|
+
if (options.json) {
|
|
20
|
+
if (companion && typeof status.instanceId === "string") {
|
|
21
|
+
await Promise.all(Object.entries(status.peers ?? {}).map(async ([peer, row]) => {
|
|
22
|
+
if (!row || typeof row !== "object" || !("state" in row) || row.state === "offline") return;
|
|
23
|
+
const launch = await launcherOf(peer, cwd, { stateDir, instanceId: status.instanceId }).catch(() => undefined);
|
|
24
|
+
if (launch?.state === "live" && launch.record?.paneKey) Object.assign(row, { orcaPaneKey: launch.record.paneKey });
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
return console.log(JSON.stringify(status, null, 2));
|
|
28
|
+
}
|
|
18
29
|
const quota = await hub.request({ t: "budget" });
|
|
19
30
|
// CLI output standard v1: the default view answers "is it OK, and what do I do next"; every detail the older view printed stays behind --verbose (and --full, which adds the long ids).
|
|
20
31
|
const data = { ...status, budget: quota.budget ?? {} };
|
package/src/cli/help.ts
CHANGED
|
@@ -73,12 +73,14 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
|
|
|
73
73
|
["ahub backlog groom | return <task> <revision> <reason...> [--reserved <peer> | --unreserve] [--json] [--color=auto|always|never]", "read grooming findings or return accepted untouched work to backlog (planner/person); --reserved names the peer the card is reserved for as it goes back, --unreserve clears the reservation (a person's reservation needs the person)"],
|
|
74
74
|
["ahub status [--json] [--full] [--verbose] [--ascii] [--color=auto|always|never]", "is the hub OK, and what to do next: an Attention list (each item with its next command), then the hub, peers and tasks; --verbose or --full prints every detail (model backends, specs, queue pressure, schedules, per-peer notes)"],
|
|
75
75
|
["ahub status --all [--json] [--color=auto|always|never]", "show every registered project"],
|
|
76
|
+
["ahub launch-line <kind> --json [--exec <absolute-path|self>] [-- <launch arguments>]", "person: print a Claude or Codex terminal join command (keeping the launch arguments) and project environment for a running hub; start nothing"],
|
|
76
77
|
["ahub logs [-f]", "person: last 100 hub.log lines (-f starts at 10); conductor: bounded public lines and follow while authority remains"],
|
|
77
78
|
["ahub doctor [--json] [--full] [--ascii] [--color=auto|always|never]", "check the tools, daemon, plugin, gateway, models, memory library and memory capture setup (read from `amem setup <tool> --json`, a preview) this project uses, the runtime capture pruning ledger, whether the shared config.json tracking matches the AGENTS.md roles sentence, and who holds conductor, planner and reviewer as the loader settled them (a warning, never a failure), the hub skills of the Claude plugin and every other agent host (installed, stale, missing, modified, foreign or linked, with a repair command), and any rostered implementer that no routing class lists (a warning); warn when the CLI or plugin is older than its running daemon"],
|
|
78
79
|
["ahub doctor --stale-anchors [--json]", "read-only bounded report of public memory symbol anchors at current HEAD; private or unavailable evidence stays unknown"],
|
|
79
80
|
["ahub doctor --orphans [--kill] [--json] [--color=auto|always|never]", "person: inspect missing-root registrations; conductor --kill: selected project only; signed hub ownership is required before any stop"],
|
|
80
81
|
["ahub accounts import --from orca", "person only: print an `accounts` block for config.local.json from `orca account list --json`, labels only, nothing written"],
|
|
81
82
|
["ahub agents [--json]", "show each gated agent CLI's installed version and verdict (verified, in-line, trusted, refused or unknown)"],
|
|
83
|
+
["ahub agents install pi [<version>]", "person only: pin a verified Pi release in the hub home, newest verified by default"],
|
|
82
84
|
["ahub agents --latest [--json]", "person only, reads the network: say, for each refused or trusted agent CLI, which release verifies the version installed here, read from the newest published release's compat.json (advice only, writes nothing, admits nothing; the hub never reads the network for it)"],
|
|
83
85
|
["ahub agents trust <id> <version> [--revoke]", "accept an untested agent CLI version on this machine (person only; runtime proofs still run)"],
|
|
84
86
|
["ahub agents presets [--json]", "person only: list the shipped agent presets (gemini, opencode, kiro, copilot) with the recorded CLI version and whether a verification receipt backs each (verified) or not (untested)"],
|
|
@@ -88,7 +90,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
|
|
|
88
90
|
["ahub down", "stop this project's hub, the counterpart of ahub up (same as ahub kill)"],
|
|
89
91
|
["ahub reset [--all] [--yes]", "list, then with --yes stop the hub and discard every queued and needs_review delivery, clear holds and pauses and drop session pointers; --all moves the state directory to .agenthub/archive instead"],
|
|
90
92
|
["ahub restart [--dry-run] [--yes] [--json] [--verbose] [--color=auto|always|never]", "recover this project's runtime; a configured conductor's --yes requires a same-project, source-issued continuation proof, otherwise run it as the person"],
|
|
91
|
-
["ahub upgrade [--project <path|id> | --all-stopped] [--to <version>] [--dry-run] [--yes] [--json] [--verbose] [--color=auto|always|never]", "review and upgrade this selected project (default: current directory; --project selects another); a project whose hub is stopped has only its runtime selection retargeted: no hub, terminal, peer or recovery operation is started; --all-stopped does that for every registered stopped project, each independently (rows: retarget, already at <v>, skipped: running with its per-project command, refused: <cause> with its next step), exits nonzero when a planned retarget fails, and conflicts with --project; global CLI/plugin updates are separate; --to defaults to latest for interactive review or dry-run, while --yes requires --to <exact-version>, and for a running hub waits through a pipe until its recovery operation ends and exits nonzero unless it completed; conductor apply needs the same project's supported proof (a stopped-project retarget is person-only), and a newer-coordinator handoff is person-only"],
|
|
93
|
+
["ahub upgrade [--project <path|id> | --all-stopped] [--to <version>] [--recreate] [--dry-run] [--yes] [--json] [--verbose] [--color=auto|always|never]", "review and upgrade this selected project (default: current directory; --project selects another); a project whose hub is stopped has only its runtime selection retargeted: no hub, terminal, peer or recovery operation is started; --all-stopped does that for every registered stopped project, each independently (rows: retarget, already at <v>, skipped: running with its per-project command, refused: <cause> with its next step), exits nonzero when a planned retarget fails, and conflicts with --project; global CLI/plugin updates are separate; --to defaults to latest for interactive review or dry-run, while --yes requires --to <exact-version>, --recreate uses the existing restart plan for all peers, and for a running hub waits through a pipe until its recovery operation ends and exits nonzero unless it completed; conductor apply needs the same project's supported proof (a stopped-project retarget is person-only), and a newer-coordinator handoff is person-only"],
|
|
92
94
|
["ahub recovery [status|resume|abort] [<operation-id>] [--json] [--color=auto|always|never]", "inspect a preflight; without an id, resume/abort select this project's hold or a retained legacy machine hold; a bare terminal opens the person's screen; only its initiating conductor may continue its own supported restart/upgrade with fresh proof"],
|
|
93
95
|
["ahub recovery reattach <operation-id> codex|claude|pi", "person only: repair that blocked peer with its recorded session; leaves the rest for recovery resume"],
|
|
94
96
|
["ahub recovery dispose [<operation-id>] --fresh-session codex|claude --reason <text>", "end a partial operation by starting that peer as a new session, recording the lost conversation"],
|
|
@@ -162,7 +164,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
|
|
|
162
164
|
["ahub source add <path|url> | list [--json] [--color=auto|always|never]", "list is person only, add the person's or the configured conductor's: register an input as a content-hashed source (src:<16 hex of the SHA-256>) under the hub state dir sources/<id>/ (meta.json, raw, text); a URL is fetched once by this command, https only, at most 5 redirects; up to 16 MiB, never truncated; a path under pii.paths or text matching signals.pii_patterns is private, and private is never downgraded"],
|
|
163
165
|
["ahub schedule list | run <id> | pause <id> | resume <id> [--json] [--color=auto|always|never]", "list is person only; run, pause and resume are the person's or the configured conductor's: the machine-local schedules (`schedules` in .agenthub/config.local.json); list shows each one's next run, run proposes one now through the same hold, open-task and PII path as the timer and restarts its period, pause stops the timer proposing it without counting a skip, resume starts a fresh period so a pause is never replayed as a run"],
|
|
164
166
|
["ahub intake \"<text>\" [--source <id>...] | approve <id> | discard <id> [--json] [--color=auto|always|never]", "person only, except approve (person or configured conductor): turn a plain request into a draft backlog card that nothing offers or pulls until you approve it; the configured planner is asked to split it with hub_backlog_split, or the hub model proposes the split (a PII request only on an on-prem model, never to a planner); each --source must be a registered src: id; approve clears the draft on it and its parts, discard cancels them through task cancel"],
|
|
165
|
-
["ahub capabilities [--json] [--color=auto|always|never]", "person only, never a conductor or an agent shell: list the skills and commands each attached peer offers (Kimi 2.3.2 and Qwen 0.26.1 sessions, Codex 0.166.0 skills; other versions
|
|
167
|
+
["ahub capabilities [--json] [--color=auto|always|never]", "person only, never a conductor or an agent shell: list the skills and commands each attached peer offers (Kimi 2.3.2 and Qwen 0.26.1 sessions, Codex 0.166.0 and 0.174.0 skills; other versions need exact trust), whether you share each one, its digest and the class a call would count as; sharing is invocation.share in .agenthub/config.local.json, this machine only; it only lists and never calls anything"],
|
|
166
168
|
["ahub learn list [--all] [--accepted] | accept <id> | reject <id> [--json] [--color=auto|always|never]", "person only, never a conductor or an agent shell: review a recurring-unmet-criterion candidate the hub filed (#514a) or a followed checklist line; accept writes its one review checklist line, added to your current checklist, to .agenthub/config.local.json through the settings writer (this machine only, never a tracked file, ahub settings undo puts it back, applies after a restart) and closes the card, or on a removal card takes just that line out again; reject only closes it; list --all includes decided candidates, and list --accepted shows each followed line, its status since acceptance and the checklist size"],
|
|
167
169
|
["ahub study draft <parent> <contract.json> | revise <id> <revision> <contract.json> | approve <id> <revision> | close <id> <revision> --reason <text> | approve-protocol <hash> [--json] [--color=auto|always|never]", "person only: store a research campaign contract as a draft, revise it, approve it (the only step that creates the unit tasks and lets work start) or close it; approve-protocol binds approval to the exact protocol and evaluator hashes; a planner drafts through hub_study_draft and hub_study_revise and can never approve"],
|
|
168
170
|
["ahub study evidence <ev-id> [--revision <n>] | evidence --task <task> | check <task> <manifest.json> [--json] [--color=auto|always|never]", "explicit evidence provenance and offline synthesis readiness: single-link reads reuse research scope/privacy; task inventory and check are person-only. Complete claim/link inventories and registered deliverable hashes bind the manifest. Separate citation, locator, person judgment, contradiction and artifact statuses never certify truth; a non-ready check exits nonzero"],
|
|
@@ -340,7 +342,7 @@ export const EXAMPLES: Readonly<Record<string, readonly string[]>> = {
|
|
|
340
342
|
up: ["ahub up --no-console"], console: ["ahub console --panels"], pet: ["ahub pet --short"],
|
|
341
343
|
structure: ["ahub structure check", "ahub structure baseline --write"],
|
|
342
344
|
sdlc: ["ahub sdlc status 12", "ahub sdlc explain 12 --json"], backlog: ["ahub backlog list --full", "ahub backlog return 12 3 waiting on a spec"],
|
|
343
|
-
status: ["ahub status --verbose"], logs: ["ahub logs -f"], doctor: ["ahub doctor --json"], agents: ["ahub agents --json"],
|
|
345
|
+
status: ["ahub status --verbose"], "launch-line": ["ahub launch-line claude --json"], logs: ["ahub logs -f"], doctor: ["ahub doctor --json"], agents: ["ahub agents --json"],
|
|
344
346
|
kill: ["ahub kill"], down: ["ahub down"], tail: ["ahub tail"],
|
|
345
347
|
reset: ["ahub reset"], restart: ["ahub restart --dry-run"], upgrade: ["ahub upgrade --dry-run"], recovery: ["ahub recovery status"],
|
|
346
348
|
role: ["ahub role list"], stop: ["ahub stop pi"], peer: ["ahub peer takeover codex"], models: ["ahub models status"],
|
|
@@ -413,12 +415,13 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
|
|
|
413
415
|
// setup, init and sdlc
|
|
414
416
|
"--require-fresh": "also fail on stale documents", "--base": "compare against this git ref", "--agents": "agents ahub up starts", "--research": "turn research records on", "--no-research": "turn research records off",
|
|
415
417
|
"--undo": "remove only the hub's unmodified skill trees",
|
|
418
|
+
"--exec": "executable to print: absolute path or self",
|
|
416
419
|
"--profile": "role profile or pack", "--sdlc": "SDLC mode: off, advise or enforce", "--required-checks": "CI check names that must pass", "--coordination": "advisory or turn-free", "--memory": "turn shared memory on",
|
|
417
420
|
"--no-memory": "turn shared memory off", "--snapshots": "turn per-turn snapshots on", "--no-snapshots": "turn per-turn snapshots off", "--pi": "turn the Pi peer on", "--no-pi": "turn the Pi peer off",
|
|
418
421
|
"--specs": "turn design specs on", "--no-specs": "turn design specs off", "--no-jcode-home": "init: do not create the hub-owned jcode home", "--spec-review": "how covering specs are reviewed", "--conductor": "the peer that conducts, or none", "--planner": "peers that plan",
|
|
419
422
|
"--reviewer": "peers that review, or person", "--track-config": "share config.json through git", "--no-track-config": "keep config.json out of git", "--autonomy": "inherit the machine preset, or not",
|
|
420
423
|
"--shadow": "hub-owned snapshots for a non-git folder", "--release-guard": "install the tag pre-push hook", "--focus": "area the survey looks at", "--review": "review scope: full, delta or none",
|
|
421
|
-
"--reviewers": "number of reviewers", "--ci": "CI scope: full, focused or reuse", "--reserved": "reserve the card for this peer", "--unreserve": "clear the card's reservation", "--to": "version to upgrade to", "--all-stopped": "retarget every stopped project's runtime",
|
|
424
|
+
"--reviewers": "number of reviewers", "--ci": "CI scope: full, focused or reuse", "--reserved": "reserve the card for this peer", "--unreserve": "clear the card's reservation", "--to": "version to upgrade to", "--all-stopped": "retarget every stopped project's runtime", "--recreate": "use the previous restart plan for all peers",
|
|
422
425
|
"--version": "print the installed version",
|
|
423
426
|
"--write-roadmap": "also refresh tracked roadmap files here", "--close-settled-issues": "also close settled issues (authority needed)",
|
|
424
427
|
// daemon, agents and recovery
|
package/src/cli/identity.ts
CHANGED
|
@@ -289,7 +289,7 @@ export function cliCommandLabel(command: string, args: readonly string[], catalo
|
|
|
289
289
|
if (command === "specs") return ["list", "check", "covers", "stamp"].includes(args[0] ?? "") ? `specs ${args[0]}` : "specs";
|
|
290
290
|
// #1057: the audit names the subcommand and whether it confirms, never a path, a branch or a fingerprint.
|
|
291
291
|
if (command === "worktrees") return args[0] === "tidy" ? (args.some(arg => arg === "--confirm" || arg.startsWith("--confirm=")) ? "worktrees tidy confirm" : "worktrees tidy") : "worktrees";
|
|
292
|
-
if (!(catalog?.definitionOf(command) ?? builtinCliPolicy(command)) && !["accounts", "upgrade", "restart", "recovery", "recovery-run", "help", "--help", "--version", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "host", "up", "console", "stop", "roles", "models", "say", "queue", "tail", "watch", "budget", "board", "task", "review", "remember", "ask", "route", "pause", "resume", "permit", "answer", "permission", "results", "settings", "roster", "status", "pet", "logs", "export", "report", "research", "memory", "goal", "bench", "sdlc", "role", "facts", "instruction-hook", "instructed", "check-path", "turns", "undo", "kill", "down", "reset", "doctor", "agents", "source", "releases", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
|
|
292
|
+
if (!(catalog?.definitionOf(command) ?? builtinCliPolicy(command)) && !["accounts", "launch-line", "upgrade", "restart", "recovery", "recovery-run", "help", "--help", "--version", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "host", "up", "console", "stop", "roles", "models", "say", "queue", "tail", "watch", "budget", "board", "task", "review", "remember", "ask", "route", "pause", "resume", "permit", "answer", "permission", "results", "settings", "roster", "status", "pet", "logs", "export", "report", "research", "memory", "goal", "bench", "sdlc", "role", "facts", "instruction-hook", "instructed", "check-path", "turns", "undo", "kill", "down", "reset", "doctor", "agents", "source", "releases", "broker", "schedule", "intake", "learn", "study"].includes(command)) return "unknown";
|
|
293
293
|
if (["task", "queue", "budget", "route", "recovery", "models", "projects", "research", "memory", "goal", "bench", "agents", "roster", "settings"].includes(command)) {
|
|
294
294
|
const sub = command === "bench" || command === "memory" || command === "goal" ? args.find((arg) => arg !== "--json") : args[0];
|
|
295
295
|
if (sub && ["propose", "show", "assign", "unassign", "escalate", "cancel", "claim", "label", "list", "add", "resolve", "resume", "set", "execution", "explain", "status", "abort", "dispose", "reattach", "setup", "start", "stop", "remove", "discard", "export", "backfill", "addons", "run", "report", "compare", "search", "graph", "promote", "demote", "forget", "supersede", "dedupe", "decay", "rebuild", "sync", "machine", "import", "suggestions", "confirm", "reject", "new", "link", "state", "done", "take", "trust"].includes(sub)) return `${command} ${sub}`;
|
package/src/cli/init-roles.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { SUPPORTED_PEERS, defaultPeerRoles, definitionOf } from "../adapters/registry.ts";
|
|
11
11
|
import { roleEligibility, type EligibleRole } from "../adapters/role-eligibility.ts";
|
|
12
12
|
import { START_MODES, type StartMode } from "../hub/start-mode.ts";
|
|
13
|
+
import { isRecord as isObject } from "../primitives.ts";
|
|
13
14
|
|
|
14
15
|
export const ROLE_FLAGS = { "--conductor": "conductor", "--planner": "planner", "--reviewer": "reviewer" } as const satisfies Record<string, EligibleRole>;
|
|
15
16
|
export type RoleFlag = keyof typeof ROLE_FLAGS;
|
|
@@ -72,7 +73,6 @@ export function installedPeers(which: (binary: string) => string | null | undefi
|
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
|
|
75
|
-
const isObject = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
76
76
|
const listOf = (value: unknown): string[] | undefined => Array.isArray(value) && value.every(item => typeof item === "string") ? [...value] : undefined;
|
|
77
77
|
/** The effective start mode of a peer in the two files: `config.local.json` wins over the shared file, as the loader reads them. */
|
|
78
78
|
export function startModeIn(peer: string, shared: Record<string, unknown>, local: Record<string, unknown>): StartMode | undefined {
|
package/src/cli/init-settings.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { checkStartAgents, START_AGENTS_ALLOWED } from "../hub/start-agents.ts";
|
|
|
11
11
|
import { editSdlcText } from "../hub/config-edit.ts";
|
|
12
12
|
import { ADAPTERS } from "../adapters/registry.ts";
|
|
13
13
|
import { ROLE_ALLOWED, ROLE_FLAGS, ROLE_KEYS, parseRoleFlag, planRoles, roleKeyOf, type RoleFlag } from "./init-roles.ts";
|
|
14
|
+
import { isRecord as isObject } from "../primitives.ts";
|
|
14
15
|
|
|
15
16
|
export type InitSettingFile = "config.json" | "config.local.json" | "sdlc.toml";
|
|
16
17
|
export const SDLC_MODES = ["off", "advise", "enforce"] as const;
|
|
@@ -140,7 +141,6 @@ export function parseInitSettings(args: readonly string[]): { request: InitSetti
|
|
|
140
141
|
return { request, rest };
|
|
141
142
|
}
|
|
142
143
|
|
|
143
|
-
const isObject = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
|
|
144
144
|
const valueAt = (doc: Record<string, unknown>, path: readonly string[]): unknown => path.reduce<unknown>((at, key) => isObject(at) ? at[key] : undefined, doc);
|
|
145
145
|
|
|
146
146
|
const indentOf = (text: string, at: number): string => { const lineStart = text.lastIndexOf("\n", at - 1) + 1; return /^[ \t]*/.exec(text.slice(lineStart))![0]; };
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { accessSync, constants, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { definitionOf } from "../adapters/registry.ts";
|
|
4
|
+
import { shellQuote } from "./shell-quote.ts";
|
|
5
|
+
|
|
6
|
+
/** The oldest daemon whose `status` a launch line may rest on: companion CLI contract v2 shipped in 0.53.0 (#1963). */
|
|
7
|
+
export const LAUNCH_LINE_MIN_DAEMON = "0.53.0";
|
|
8
|
+
|
|
9
|
+
/** ahub's own control flags: a companion's launch may not carry them through to `ahub <kind>` (#1963). The native flags the hub owns come from each adapter's launch policy, the list `nativeLaunchArguments` rejects with. */
|
|
10
|
+
const HUB_OWNED = new Set(["--as", "--project", "--live-test", "--print-command", "--dry-run"]);
|
|
11
|
+
|
|
12
|
+
interface LaunchLineRequest { kind: string; exec?: string; launchArgs: string[] }
|
|
13
|
+
|
|
14
|
+
const USAGE = "usage: ahub launch-line <kind> --json [--exec <absolute-path|self>] [-- <launch arguments>]";
|
|
15
|
+
|
|
16
|
+
/** `args` is everything after `launch-line`. Returns the request, or the fixed refusal text. */
|
|
17
|
+
export function parseLaunchLineArgs(args: readonly string[]): LaunchLineRequest | { refusal: string } {
|
|
18
|
+
const [kind, format, ...tail] = args;
|
|
19
|
+
if (!kind || format !== "--json") return { refusal: USAGE };
|
|
20
|
+
let exec: string | undefined, launchArgs: string[] = [];
|
|
21
|
+
for (let index = 0; index < tail.length; index++) {
|
|
22
|
+
const arg = tail[index]!;
|
|
23
|
+
if (arg === "--") { launchArgs = tail.slice(index + 1); break; }
|
|
24
|
+
if (arg !== "--exec" || exec !== undefined) return { refusal: USAGE };
|
|
25
|
+
exec = tail[++index];
|
|
26
|
+
if (!exec) return { refusal: USAGE };
|
|
27
|
+
}
|
|
28
|
+
const refused = refuseLaunchArgs(kind, launchArgs);
|
|
29
|
+
return refused ? { refusal: refused } : { kind, ...(exec !== undefined ? { exec } : {}), launchArgs };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** A launch whose options cannot be kept is refused, never shortened. */
|
|
33
|
+
function refuseLaunchArgs(kind: string, launchArgs: readonly string[]): string | undefined {
|
|
34
|
+
const owned = definitionOf(kind)?.start.ownedFlags ?? [];
|
|
35
|
+
for (const arg of launchArgs) {
|
|
36
|
+
if (/[\x00-\x1f\x7f-\x9f]/.test(arg)) return "launch options cannot be kept: an argument contains a control character";
|
|
37
|
+
const nativeOwned = owned.find(flag => arg === flag || arg.startsWith(`${flag}=`));
|
|
38
|
+
if (nativeOwned) return `launch options cannot be kept: ${nativeOwned} is owned by ahub; remove it from the launch`;
|
|
39
|
+
const name = arg.startsWith("--") ? arg.split("=", 1)[0]! : arg;
|
|
40
|
+
if (HUB_OWNED.has(name)) return `launch options cannot be kept: ${name} is owned by ahub; remove it from the launch`;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** The executable words of the printed command. `self` is this process's runtime and entry file, which runs without `ahub` on PATH. */
|
|
46
|
+
export function resolveLaunchExecutable(exec: string | undefined, self: { runtime: string; entry: string }): string[] | { refusal: string } {
|
|
47
|
+
if (exec === undefined) return ["ahub"];
|
|
48
|
+
const target = exec === "self" ? [self.runtime, self.entry] : [exec];
|
|
49
|
+
for (const path of target) {
|
|
50
|
+
if (!path.trim() || !isAbsolute(path)) return { refusal: "--exec must be an absolute path or self" };
|
|
51
|
+
try {
|
|
52
|
+
if (!statSync(path).isFile()) return { refusal: `--exec ${path} is not a file` };
|
|
53
|
+
if (path === target[0]) accessSync(path, constants.X_OK);
|
|
54
|
+
else accessSync(path, constants.R_OK);
|
|
55
|
+
} catch { return { refusal: `--exec ${path} is not runnable` }; }
|
|
56
|
+
}
|
|
57
|
+
return target;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const core = (version: string): { parts: [number, number, number]; pre: boolean } | undefined => {
|
|
61
|
+
const match = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(version);
|
|
62
|
+
return match ? { parts: [Number(match[1]), Number(match[2]), Number(match[3])], pre: match[4] !== undefined } : undefined;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** The daemon reports its version in `status`; an unreadable or older one never yields a join line. A prerelease sorts below its release, so 0.53.0-rc.1 does not meet 0.53.0; build metadata is ignored. */
|
|
66
|
+
export function daemonMeetsContract(daemonVersion: unknown, minimum: string = LAUNCH_LINE_MIN_DAEMON): boolean {
|
|
67
|
+
const have = typeof daemonVersion === "string" ? core(daemonVersion) : undefined, need = core(minimum);
|
|
68
|
+
if (!have || !need) return false;
|
|
69
|
+
for (let index = 0; index < 3; index++) if (have.parts[index]! !== need.parts[index]!) return have.parts[index]! > need.parts[index]!;
|
|
70
|
+
return !have.pre || need.pre; // ponytail: a prerelease floor compares equal to any prerelease of itself; the floor is a plain release, so the case never arises. Upgrade: compare prerelease identifiers per semver if a prerelease floor is ever set.
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A word that starts with `=` is quoted: zsh expands `=word` to a command's path.
|
|
74
|
+
const plain = (value: string): string => /^[A-Za-z0-9_@%+:,./-][A-Za-z0-9_@%+=:,./-]*$/.test(value) ? value : shellQuote(value);
|
|
75
|
+
|
|
76
|
+
/** The command a terminal runs. Throws rather than ever returning a blank one. */
|
|
77
|
+
export function buildLaunchLineCommand(project: string, kind: string, executable: readonly string[], launchArgs: readonly string[]): string {
|
|
78
|
+
if (!executable.length || executable.some(word => !word.trim())) throw new Error("launch line would be blank");
|
|
79
|
+
const command = [...executable.map(plain), "--project", shellQuote(project), kind, ...launchArgs.map(plain)].join(" ");
|
|
80
|
+
if (!command.trim()) throw new Error("launch line would be blank");
|
|
81
|
+
return command;
|
|
82
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { realPath, type ProjectContext } from "../hub/project.ts";
|
|
2
|
+
import { registeredProjects } from "../hub/registry.ts";
|
|
3
|
+
|
|
4
|
+
// A companion passes the workspace root. Resolve only exact registry entries, without invoking Git.
|
|
5
|
+
export function launchLineProject(selector?: string): ProjectContext {
|
|
6
|
+
const projects = registeredProjects();
|
|
7
|
+
const byId = selector && projects.find(project => project.id === selector);
|
|
8
|
+
if (byId) return byId;
|
|
9
|
+
const root = realPath(selector ?? process.cwd());
|
|
10
|
+
const project = projects.find(entry => entry.root === root);
|
|
11
|
+
if (!project) throw new Error("workspace is not a registered hub project; run ahub up from its root before requesting a launch line");
|
|
12
|
+
return project;
|
|
13
|
+
}
|
package/src/cli/main.ts
CHANGED
|
@@ -114,7 +114,8 @@ if (argv[0] === "upgrade") {
|
|
|
114
114
|
const [, ...rest] = argv;
|
|
115
115
|
let selected: { root: string; stateDir: string };
|
|
116
116
|
try {
|
|
117
|
-
if (selector)
|
|
117
|
+
if (argv[0] === "launch-line") selected = (await import("./launch-line-project.ts")).launchLineProject(selector);
|
|
118
|
+
else if (selector) {
|
|
118
119
|
const projects = registeredProjects();
|
|
119
120
|
{
|
|
120
121
|
const known = projects.find((p) => p.id === selector);
|
|
@@ -702,13 +703,13 @@ async function onTerminal(screens: (io: ScreenIO) => Promise<void>, presentation
|
|
|
702
703
|
} finally { process.off("SIGINT", onInterrupt); rl.close(); }
|
|
703
704
|
}
|
|
704
705
|
|
|
705
|
-
function upgradeHost(kind: "restart" | "upgrade", version: string): UpgradeHost {
|
|
706
|
+
function upgradeHost(kind: "restart" | "upgrade", version: string, recreate = false): UpgradeHost {
|
|
706
707
|
const scope = cwd;
|
|
707
708
|
return {
|
|
708
|
-
plan: () => makeUpgradePlan(kind, version, scope),
|
|
709
|
+
plan: () => makeUpgradePlan(kind, version, scope, undefined, undefined, recreate),
|
|
709
710
|
apply: async (plan, interrupted) => {
|
|
710
711
|
assertLifecycleAvailable(cwd);
|
|
711
|
-
const current = await makeUpgradePlan(kind, plan.version, scope);
|
|
712
|
+
const current = await makeUpgradePlan(kind, plan.version, scope, undefined, undefined, recreate);
|
|
712
713
|
if (current.fingerprint !== plan.fingerprint) throw new Error("the plan changed during review; review it again");
|
|
713
714
|
// The check above takes seconds: a Ctrl+C in that time is still a no.
|
|
714
715
|
if (interrupted()) throw new Error("interrupted; nothing was started");
|
|
@@ -784,9 +785,9 @@ async function stoppedUpgrade(to: string, all: boolean, display: ReturnType<type
|
|
|
784
785
|
async function upgrade(kind: "restart" | "upgrade"): Promise<void> {
|
|
785
786
|
const display = recoveryDisplay();
|
|
786
787
|
const { one, rest } = takeFlags(display.args, ["--to"], []);
|
|
787
|
-
if (rest.some((a) => !["--dry-run", "--yes", ...(kind === "upgrade" ? ["--all-stopped"] : [])].includes(a)) || (kind === "restart" && one["--to"])) fail("usage: ahub upgrade [--project <path|id> | --all-stopped] [--to <version>] [--dry-run] [--yes] | ahub restart [--dry-run] [--yes]");
|
|
788
|
+
if (rest.some((a) => !["--dry-run", "--yes", ...(kind === "upgrade" ? ["--all-stopped", "--recreate"] : [])].includes(a)) || (kind === "restart" && one["--to"])) fail("usage: ahub upgrade [--project <path|id> | --all-stopped] [--to <version>] [--recreate] [--dry-run] [--yes] | ahub restart [--dry-run] [--yes]");
|
|
788
789
|
const yes = rest.includes("--yes"), dry = rest.includes("--dry-run") || (display.json && !yes);
|
|
789
|
-
const allStopped = rest.includes("--all-stopped");
|
|
790
|
+
const allStopped = rest.includes("--all-stopped"), recreate = rest.includes("--recreate");
|
|
790
791
|
if (allStopped && selector !== undefined) fail("--all-stopped and --project are conflicting selectors: --all-stopped covers every registered stopped project");
|
|
791
792
|
// #272: on a terminal, with neither flag, the plan is reviewed, applied and followed in one session.
|
|
792
793
|
const interactive = !dry && !yes && humanRecovery(display.json);
|
|
@@ -819,8 +820,8 @@ async function upgrade(kind: "restart" | "upgrade"): Promise<void> {
|
|
|
819
820
|
}
|
|
820
821
|
if (kind === "upgrade" && await stoppedUpgrade(to!, allStopped, display, yes, dry)) return;
|
|
821
822
|
if (kind === "upgrade") warn("Kimi now defaults to its own TUI (pull-only) in projects without peers.kimi.start_mode; to keep ACP, run the next command", "ahub settings set peers.kimi.start_mode headless");
|
|
822
|
-
if (interactive) return onTerminal((io) => planScreen(upgradeHost(kind, to ?? VERSION), io), display.options);
|
|
823
|
-
const plan = await makeUpgradePlan(kind, to ?? VERSION, cwd, undefined, conductorPeer);
|
|
823
|
+
if (interactive) return onTerminal((io) => planScreen(upgradeHost(kind, to ?? VERSION, recreate), io), display.options);
|
|
824
|
+
const plan = await makeUpgradePlan(kind, to ?? VERSION, cwd, undefined, conductorPeer, recreate);
|
|
824
825
|
if (conductorPeer) await preflightConductorRecovery(plan, conductorPeer);
|
|
825
826
|
const jsonApply = display.json && yes && !dry;
|
|
826
827
|
// #814: a person reading a pipe or a dry run gets the plan screen's rows, with every blocker, reconnect-only session and
|
|
@@ -842,7 +843,7 @@ async function upgrade(kind: "restart" | "upgrade"): Promise<void> {
|
|
|
842
843
|
if (!/^(y|yes)$/i.test((await rl.question("Apply this project list and restore its sessions? [y/N] ")).trim())) return;
|
|
843
844
|
} finally { rl.close(); }
|
|
844
845
|
}
|
|
845
|
-
const current = await makeUpgradePlan(kind, plan.version, cwd, undefined, conductorPeer);
|
|
846
|
+
const current = await makeUpgradePlan(kind, plan.version, cwd, undefined, conductorPeer, recreate);
|
|
846
847
|
if (current.fingerprint !== plan.fingerprint) fail("plan changed during review; run the command again");
|
|
847
848
|
const routingDefaults = conductorPeer ? await preflightConductorRecovery(plan, conductorPeer) : undefined;
|
|
848
849
|
const sourceRoot = preserveSource(plan);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { CONFIG_FILES, DEFAULT_CONFIG } from "../hub/config.ts";
|
|
4
|
+
|
|
5
|
+
/** #1967 T3: a project file that sets `pi.max_steps` below the default stops real Pi tasks early (measured: 28% of turns use 30 steps or more). Names each file and the key. */
|
|
6
|
+
export function piMaxStepsWarning(cwd: string, read: (path: string) => string = path => readFileSync(path, "utf8")): string | undefined {
|
|
7
|
+
const floor = DEFAULT_CONFIG.pi.max_steps, found: string[] = [];
|
|
8
|
+
for (const name of CONFIG_FILES) {
|
|
9
|
+
let value: unknown;
|
|
10
|
+
try { value = (JSON.parse(read(join(cwd, ".agenthub", name))) as { pi?: { max_steps?: unknown } })?.pi?.max_steps; } catch { continue; }
|
|
11
|
+
if (typeof value === "number" && Number.isFinite(value) && value < floor) found.push(`.agenthub/${name} key pi.max_steps = ${value}`);
|
|
12
|
+
}
|
|
13
|
+
return found.length ? `${found.join("; ")} is below the default ${floor}; remove the key or raise it so a real task is not stopped early` : undefined;
|
|
14
|
+
}
|
|
@@ -6,7 +6,8 @@ import { createRequire } from "node:module";
|
|
|
6
6
|
import { hubHome, realPath } from "../hub/project.ts";
|
|
7
7
|
import { Registry } from "../hub/registry.ts";
|
|
8
8
|
import { AGENT_MEM_HOST_API_RANGE, agentMemHostApiOk, agentMemVersionInRange, isAgentMemFloorRange, readHostApiConstants } from "../hub/agent-mem-range.ts";
|
|
9
|
-
import { MEMORY_RUNTIME_LAYOUTS } from "../hub/runtime-package-assets.ts";
|
|
9
|
+
import { MEMORY_RUNTIME_LAYOUTS, REVIEW_RUNTIME_LAYOUT } from "../hub/runtime-package-assets.ts";
|
|
10
|
+
import { parseSessionContract, type SessionContract } from "../hub/upgrade-session-contract.ts";
|
|
10
11
|
|
|
11
12
|
export type CommandResult = { code: number; stdout: string; stderr: string };
|
|
12
13
|
export type RunCommand = (args: string[], options?: { cwd?: string; env?: NodeJS.ProcessEnv; timeoutMs?: number; input?: string; pipeExitGraceMs?: number }) => Promise<CommandResult>;
|
|
@@ -98,7 +99,7 @@ function memoryRuntime(root: string, dependencyRoot?: string): RuntimePackage[]
|
|
|
98
99
|
const declared = deps["@staix/agent-mem"];
|
|
99
100
|
// #1611: a current package declares a floor range `>=X.Y.Z <M.0.0`; a package staged under #1605 declares `~X.Y.Z` and one before it an exact
|
|
100
101
|
// version, so a cached release still verifies (legacy forms need no host API); compound ranges, `^`, `*` and prereleases stay refused.
|
|
101
|
-
if (Object.keys(deps).some(name => !["@staix/agent-mem", "@staix/cli-output"].includes(name)) || typeof declared !== "string" || !(/^~?\d+\.\d+\.\d+$/.test(declared) || isAgentMemFloorRange(declared))) throw new Error("unsupported runtime dependencies in recovery package");
|
|
102
|
+
if (Object.keys(deps).some(name => !["@staix/agent-mem", "@staix/agent-review", "@staix/cli-output"].includes(name)) || typeof declared !== "string" || !(/^~?\d+\.\d+\.\d+$/.test(declared) || isAgentMemFloorRange(declared))) throw new Error("unsupported runtime dependencies in recovery package");
|
|
102
103
|
let dir = dependencyRoot ? join(dependencyRoot, "node_modules/@staix/agent-mem")
|
|
103
104
|
: dirname(createRequire(join(root, "package.json")).resolve("@staix/agent-mem"));
|
|
104
105
|
if (dependencyRoot && !existsSync(dir)) throw new Error("memory runtime dependency is unavailable");
|
|
@@ -162,6 +163,55 @@ function outputRuntime(root: string, dependencyRoot?: string): string | undefine
|
|
|
162
163
|
}
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
/** Bind the core to the same reviewed siblings used by this recovery package. */
|
|
167
|
+
function reviewRuntime(root: string, memory: RuntimePackage | undefined, output: string | undefined): RuntimePackage | undefined {
|
|
168
|
+
const name = "@staix/agent-review";
|
|
169
|
+
const deps = JSON.parse(readFileSync(join(root, "package.json"), "utf8")).dependencies ?? {};
|
|
170
|
+
const pin: unknown = deps[name];
|
|
171
|
+
if (pin === undefined) return undefined;
|
|
172
|
+
const refuse = (cause: string): never => {
|
|
173
|
+
throw new Error(`AREV recovery dependency: ${cause}; reinstall the reviewed agent-hub package with its runtime dependencies, then retry`);
|
|
174
|
+
};
|
|
175
|
+
if (typeof pin !== "string" || !/^\d+\.\d+\.\d+$/.test(pin)) return refuse("@staix/agent-review must use an exact version");
|
|
176
|
+
if (!memory || !output) return refuse("agent-mem and cli-output are required siblings");
|
|
177
|
+
const scope = dirname(memory.source), modules = dirname(scope), source = join(scope, "agent-review");
|
|
178
|
+
if (basename(scope) !== "@staix" || basename(modules) !== "node_modules" || dirname(output) !== scope)
|
|
179
|
+
return refuse("agent-review, agent-mem and cli-output must share one node_modules/@staix directory");
|
|
180
|
+
const manifest = join(source, "package.json"), entry = join(source, "src/core.ts");
|
|
181
|
+
let installed;
|
|
182
|
+
try {
|
|
183
|
+
if ([modules, scope, source, join(source, "src")].some(path => !lstatSync(path).isDirectory())
|
|
184
|
+
|| !lstatSync(manifest).isFile() || !lstatSync(entry).isFile()) throw new Error("invalid AREV runtime layout");
|
|
185
|
+
installed = JSON.parse(readFileSync(manifest, "utf8"));
|
|
186
|
+
} catch { return refuse("agent-review has no readable, regular sibling manifest or core entry"); }
|
|
187
|
+
if (installed?.name !== name || installed.version !== pin || installed.exports?.["./core"] !== "./src/core.ts")
|
|
188
|
+
return refuse("the agent-review manifest name, version or core entry does not match the reviewed package");
|
|
189
|
+
const required = installed.dependencies;
|
|
190
|
+
if (!required || typeof required !== "object" || Array.isArray(required)
|
|
191
|
+
|| Object.keys(required).some(key => !["@staix/agent-mem", "@staix/cli-output", "@staix/mcp-stdio"].includes(key))
|
|
192
|
+
|| [installed.optionalDependencies, installed.peerDependencies].some(value => value !== undefined
|
|
193
|
+
&& (!value || typeof value !== "object" || Array.isArray(value) || Object.keys(value).length)))
|
|
194
|
+
return refuse("agent-review declares an unsupported dependency");
|
|
195
|
+
const memoryVersion: unknown = JSON.parse(readFileSync(join(memory.source, "package.json"), "utf8")).version;
|
|
196
|
+
if (typeof required["@staix/agent-mem"] !== "string" || !agentMemVersionInRange(memoryVersion, required["@staix/agent-mem"]))
|
|
197
|
+
return refuse("the reviewed agent-mem sibling does not satisfy agent-review's range");
|
|
198
|
+
if (required["@staix/cli-output"] !== deps["@staix/cli-output"])
|
|
199
|
+
return refuse("agent-review and the hub require different cli-output pins");
|
|
200
|
+
// The AREV CLI uses mcp-stdio. Its core does not, so never copy that nested installation.
|
|
201
|
+
if (required["@staix/mcp-stdio"] !== undefined &&
|
|
202
|
+
(typeof required["@staix/mcp-stdio"] !== "string" || !/^\d+\.\d+\.\d+$/.test(required["@staix/mcp-stdio"])))
|
|
203
|
+
return refuse("agent-review's unused mcp-stdio dependency must have an exact pin");
|
|
204
|
+
const inspect = (dir: string): void => {
|
|
205
|
+
for (const item of readdirSync(dir, { withFileTypes: true })) {
|
|
206
|
+
if (item.name === "node_modules" || item.isSymbolicLink() || !item.isFile() && !item.isDirectory())
|
|
207
|
+
return refuse("agent-review src contains a symlink, special file or nested node_modules");
|
|
208
|
+
if (item.isDirectory()) inspect(join(dir, item.name));
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
inspect(join(source, "src"));
|
|
212
|
+
return { source, name, assets: [...REVIEW_RUNTIME_LAYOUT.directories, ...REVIEW_RUNTIME_LAYOUT.files] };
|
|
213
|
+
}
|
|
214
|
+
|
|
165
215
|
/** Preserve the historical digest order, hashing shared cli-output only once. */
|
|
166
216
|
function runtimeDependencies(root: string, dependencyRoot?: string): RuntimePackage[] {
|
|
167
217
|
const [memory, ...pinned] = memoryRuntime(root, dependencyRoot);
|
|
@@ -173,7 +223,10 @@ function runtimeDependencies(root: string, dependencyRoot?: string): RuntimePack
|
|
|
173
223
|
}
|
|
174
224
|
const packages = memory ? [memory] : [];
|
|
175
225
|
if (output) packages.push({ source: output, name: "@staix/cli-output", assets: memoryRuntimeAssets("@staix/cli-output") });
|
|
176
|
-
|
|
226
|
+
packages.push(...pinned.filter(pkg => pkg.name !== "@staix/cli-output"));
|
|
227
|
+
const review = reviewRuntime(root, memory, output);
|
|
228
|
+
if (review) packages.push(review);
|
|
229
|
+
return packages;
|
|
177
230
|
}
|
|
178
231
|
|
|
179
232
|
export function preserveRuntimeDependencies(root: string, destination: string): void {
|
|
@@ -333,16 +386,17 @@ function npmViewJson(stdout: string): unknown {
|
|
|
333
386
|
return value.length === 1 ? value[0] : undefined;
|
|
334
387
|
}
|
|
335
388
|
|
|
336
|
-
export async function registryRelease(version: string, run: RunCommand = runCommand): Promise<{ version: string; integrity: string }> {
|
|
389
|
+
export async function registryRelease(version: string, run: RunCommand = runCommand, includeSessionContract = false): Promise<{ version: string; integrity: string; sessionContract?: SessionContract }> {
|
|
337
390
|
exactVersion(version);
|
|
338
|
-
const result = await run(["npm", "view", `@staix/agent-hub@${version}`, "version", "dist.integrity", "--json"], { timeoutMs: 30_000 });
|
|
391
|
+
const result = await run(["npm", "view", `@staix/agent-hub@${version}`, "version", "dist.integrity", ...(includeSessionContract ? ["sessionContract"] : []), "--json"], { timeoutMs: 30_000 });
|
|
339
392
|
if (result.code !== 0) throw new Error(`registry metadata unavailable for @staix/agent-hub@${version}`);
|
|
340
393
|
const data = npmViewJson(result.stdout) as Record<string, unknown> | undefined;
|
|
341
394
|
const integrity = data?.["dist.integrity"];
|
|
342
395
|
if (data?.version !== version || typeof integrity !== "string" || !integrity.startsWith("sha512-")) {
|
|
343
396
|
throw new Error(`registry returned an unexpected release identity for @staix/agent-hub@${version} (expected one release with a sha512 integrity from \`npm view --json\`); check \`npm view @staix/agent-hub@${version} version dist.integrity --json\` and your npm version`);
|
|
344
397
|
}
|
|
345
|
-
|
|
398
|
+
const sessionContract = includeSessionContract ? parseSessionContract(data.sessionContract) : undefined;
|
|
399
|
+
return { version, integrity, ...(sessionContract ? { sessionContract } : {}) };
|
|
346
400
|
}
|
|
347
401
|
|
|
348
402
|
/** #272: the registry's latest release, the target when `--to` is left out. */
|
package/src/cli/reset.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { DeliveryJournal } from "../hub/delivery-journal.ts";
|
|
|
8
8
|
import { validateDeferredHub } from "../hub/deferred-hub.ts";
|
|
9
9
|
import type { Project } from "../hub/registry.ts";
|
|
10
10
|
import { HUB_DB_BUSY_TIMEOUT_MS } from "../hub/db-timeout.ts";
|
|
11
|
+
import { isRecord as isObject } from "../primitives.ts";
|
|
11
12
|
|
|
12
13
|
/** Agent session resume pointers. `pi-sessions/` holds Pi transcripts, history rather than pointers, and stays. */
|
|
13
14
|
export const SESSION_POINTERS = ["sessions.json", "claude-session.json", "claude-context.json"];
|
|
@@ -46,7 +47,6 @@ export interface ResetPlan {
|
|
|
46
47
|
|
|
47
48
|
const isList = (value: unknown, item: (v: unknown) => boolean) => Array.isArray(value) && value.every(item);
|
|
48
49
|
const isText = (v: unknown) => typeof v === "string";
|
|
49
|
-
const isObject = (v: unknown): v is Record<string, unknown> => !!v && typeof v === "object" && !Array.isArray(v);
|
|
50
50
|
const isEnvelope = (v: unknown) => isObject(v) && typeof v.id === "string";
|
|
51
51
|
/** Valid JSON of the wrong shape is damage as well: the journal refuses it on every open, so the message says so. */
|
|
52
52
|
const shaped = (ok: boolean, what: string) => { if (!ok) throw new Error(`invalid delivery journal: ${what} has the wrong shape`); };
|
package/src/cli/shell-quote.ts
CHANGED
|
@@ -111,6 +111,8 @@ export function peerKind(planned: PlannedProject, peer: RecoveryPeer): "tui" | "
|
|
|
111
111
|
|
|
112
112
|
function peerAction(planned: PlannedProject, peer: RecoveryPeer): string {
|
|
113
113
|
if (peer.state === "offline") return "offline, left as it is";
|
|
114
|
+
const plannedAction = planned.peerActions?.find(row => row.peerId === peer.id);
|
|
115
|
+
if (plannedAction) return `${plannedAction.action}: ${plannedAction.reason}`;
|
|
114
116
|
if (planned.unrecordedTerminals?.includes(peer.id)) return planned.reconnectOnly?.includes(peer.id)
|
|
115
117
|
? "attached, launcher unrecorded; reconnects by itself (its terminal is left alone)"
|
|
116
118
|
: "attached, launcher unrecorded; end it in its terminal or resume the original conversation, then press [r] refresh";
|
|
@@ -127,7 +129,10 @@ function peerAction(planned: PlannedProject, peer: RecoveryPeer): string {
|
|
|
127
129
|
const KINDS = { tui: "TUI", headless: "headless", unmanaged: "own", offline: "-" } as const;
|
|
128
130
|
|
|
129
131
|
/** What the source says keeps it from being quiet; an older hub names only its busy peers. */
|
|
130
|
-
const inProgress = (source: Inspection): string[] =>
|
|
132
|
+
const inProgress = (source: Inspection, kept: PlannedProject["keptRoster"]): string[] => {
|
|
133
|
+
const waiting = source.recovery?.waiting ?? source.peers.filter(peer => peer.state === "busy").map(peer => `${peer.id} is busy`);
|
|
134
|
+
return waiting.filter(line => !kept?.some(row => line === `${row.peerId} is busy`));
|
|
135
|
+
};
|
|
131
136
|
|
|
132
137
|
export function planLines(plan: UpgradePlan, current: string): string[] {
|
|
133
138
|
const lines = [plan.kind === "upgrade" ? `upgrade to ${plan.version} (coordinator ${current})` : `restart on ${plan.version}`];
|
|
@@ -135,7 +140,7 @@ export function planLines(plan: UpgradePlan, current: string): string[] {
|
|
|
135
140
|
lines.push("", `${p.project.id} ${p.project.root} hub ${p.source.version ?? "unknown"} (${p.source.state})`);
|
|
136
141
|
const width = Math.max(0, ...p.source.peers.map((peer) => peer.id.length));
|
|
137
142
|
for (const peer of p.source.peers) lines.push(` ${peer.id.padEnd(width)} ${peer.state.padEnd(7)} ${KINDS[peerKind(p, peer)].padEnd(8)} ${peerAction(p, peer)}`);
|
|
138
|
-
const waiting = inProgress(p.source);
|
|
143
|
+
const waiting = inProgress(p.source, p.keptRoster);
|
|
139
144
|
if (waiting.length) lines.push(` in progress: ${waiting.join(", ")} (apply waits up to 10 minutes for it, then leaves this hub running)`);
|
|
140
145
|
for (const blocker of p.blockers) lines.push(` blocker: ${blocker}`);
|
|
141
146
|
}
|