@staix/agent-hub 0.36.0 → 0.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +6 -2
  3. package/THIRD_PARTY_NOTICES.md +0 -18
  4. package/docs/agent-notes/README.md +13 -3
  5. package/docs/agent-notes/daemon.md +4 -4
  6. package/docs/agent-notes/local-worker.md +1 -0
  7. package/docs/agent-notes/models.md +2 -1
  8. package/docs/agent-notes/tasks.md +1 -1
  9. package/docs/agent-notes/tests.md +1 -2
  10. package/docs/contracts/companion-cli-v1.json +70 -0
  11. package/docs/design/adapters.md +43 -2
  12. package/docs/design/agent-hub-architecture.md +9 -1
  13. package/docs/design/guidance-probes.md +1167 -0
  14. package/docs/design/model-routes.md +437 -12
  15. package/docs/dogfood.md +12 -13
  16. package/docs/events.md +20 -1
  17. package/docs/memory.md +3 -3
  18. package/docs/operations.md +123 -151
  19. package/docs/profiles.md +1 -1
  20. package/docs/quickstart.md +15 -3
  21. package/docs/research.md +1 -1
  22. package/docs/sdlc.md +5 -3
  23. package/docs/security.md +25 -1
  24. package/docs/specs/2026-09-19-agent-hub-design.md +9 -7
  25. package/docs/specs/2026-10-04-switchyard-source-port-design.md +3 -1
  26. package/docs/verification/2026-11-08-qwen-0269-model-setter-1317.md +25 -11
  27. package/docs/verification/2026-11-09-qwen-0270-model-setter-1317.md +21 -6
  28. package/docs/verification/2026-11-11-0.37.0.md +40 -0
  29. package/docs/verification/2026-11-11-0.38.0.md +41 -0
  30. package/docs/verification/2026-11-11-guidance-probe-t2-1226.md +153 -0
  31. package/docs/verification/2026-11-11-guidance-probe-t3-1226.md +85 -0
  32. package/docs/verification/2026-11-11-guidance-probe-t4-1226.md +65 -0
  33. package/docs/verification/2026-11-11-qwen-setter-suggestions-off.md +167 -0
  34. package/docs/verified.json +25 -25
  35. package/package.json +3 -4
  36. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  37. package/plugins/agent-hub/kimi-hook.js +2403 -1444
  38. package/plugins/agent-hub/server.js +2480 -1509
  39. package/src/adapters/channel-peer.ts +7 -1
  40. package/src/adapters/claude-channel.ts +2 -1
  41. package/src/adapters/compat.ts +1 -1
  42. package/src/adapters/local-probe.ts +233 -0
  43. package/src/adapters/local-worker.ts +232 -21
  44. package/src/cli/console-state.ts +25 -6
  45. package/src/cli/console-versions.ts +99 -0
  46. package/src/cli/console.ts +13 -1
  47. package/src/cli/help.ts +2 -1
  48. package/src/cli/init.ts +3 -1
  49. package/src/cli/install-paths.ts +7 -2
  50. package/src/cli/main.ts +78 -7
  51. package/src/cli/output.ts +8 -4
  52. package/src/cli/runtime-version-warning.ts +2 -2
  53. package/src/cli/sdlc-output.ts +9 -5
  54. package/src/cli/upgrade-runtime.ts +1 -1
  55. package/src/hub/bus.ts +2 -2
  56. package/src/hub/config-apply.ts +4 -2
  57. package/src/hub/config-trust.ts +6 -1
  58. package/src/hub/control-client.ts +5 -2
  59. package/src/hub/daemon.ts +195 -13
  60. package/src/hub/envelope.ts +6 -1
  61. package/src/hub/events.ts +3 -2
  62. package/src/hub/guidance-probe-store.ts +1044 -0
  63. package/src/hub/guidance-probes.ts +692 -0
  64. package/src/hub/inference.ts +18 -5
  65. package/src/hub/manager.ts +24 -1
  66. package/src/hub/operational-authority.ts +14 -1
  67. package/src/hub/peers.ts +5 -0
  68. package/src/hub/person-command.ts +25 -0
  69. package/src/hub/ports.ts +1 -1
  70. package/src/hub/progress.ts +23 -16
  71. package/src/hub/report.ts +2 -0
  72. package/src/hub/research.ts +1 -0
  73. package/src/hub/restart.ts +7 -0
  74. package/src/hub/sdlc-release-authorization.ts +139 -17
  75. package/src/hub/sdlc-release-policy.ts +100 -0
  76. package/src/hub/sdlc-release.ts +59 -7
  77. package/src/hub/supervision.ts +3 -2
  78. package/src/hub/tasks.ts +363 -7
  79. package/src/local/probe-errors.ts +28 -0
  80. package/src/local/probe-sandbox.ts +224 -0
  81. package/src/local/probe-types.ts +110 -0
  82. package/src/local/probe-workspace.ts +426 -0
  83. package/src/local/sandbox.ts +71 -2
  84. package/src/local/tools.ts +135 -9
  85. package/src/models/route/advisor-trigger.ts +88 -0
  86. package/src/models/route/config.ts +21 -17
  87. package/src/models/route/conversation-view.ts +179 -0
  88. package/src/models/route/decision-evidence.ts +1 -1
  89. package/src/models/route/decision.ts +114 -19
  90. package/src/models/route/escalation-control.ts +30 -0
  91. package/src/models/route/hub-prompts.ts +97 -0
  92. package/src/models/route/judge-choice.ts +155 -0
  93. package/src/models/route/judge-replies.ts +102 -0
  94. package/src/models/route/labels.ts +14 -70
  95. package/src/models/route/observation-signals.ts +250 -0
  96. package/src/models/route/plan-execute-choice.ts +27 -0
  97. package/src/models/route/relay-selector.ts +2 -2
  98. package/src/models/route/runtime.ts +115 -52
  99. package/src/models/route/turn-state.ts +77 -0
  100. package/src/omniroute/client.ts +3 -0
  101. package/src/ui/guidance-panel.ts +34 -2
  102. package/src/ui/guidance-view.ts +33 -0
  103. package/src/ui/plugin.ts +80 -23
  104. package/src/version.ts +4 -0
  105. package/templates/AGENTS.block.md +14 -14
  106. package/templates/adec/README.md +32 -0
  107. package/templates/adec/ahub.plan-execute.json +23 -0
  108. package/templates/adec/ahub.stage.json +23 -0
  109. package/templates/profiles/general.json +1 -1
  110. package/templates/profiles/research.json +1 -1
  111. package/templates/profiles/writing.json +1 -1
  112. package/LICENSES/Apache-2.0.txt +0 -204
  113. package/src/models/route/advisor.ts +0 -102
  114. package/src/models/route/escalation.ts +0 -82
  115. package/src/models/route/judge.ts +0 -23
  116. package/src/models/route/normalize.ts +0 -103
  117. package/src/models/route/plan-execute.ts +0 -52
  118. package/src/models/route/prompts.ts +0 -8
  119. package/src/models/route/signals.ts +0 -247
  120. package/src/models/route/state.ts +0 -54
  121. package/src/models/route/text.ts +0 -61
@@ -0,0 +1,99 @@
1
+ import { closeSync, fstatSync, openSync, readSync, constants } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { DOCTOR_PLUGIN_PROBE } from "../adapters/registry.ts";
4
+ import { childEnv } from "../hub/child-process.ts";
5
+ import { withoutOrcaEnv } from "../hub/orca-env.ts";
6
+ import { displayVersion } from "../version.ts";
7
+ import { globalCliRoot } from "./install-paths.ts";
8
+ import { runtimeVersionWarnings } from "./runtime-version-warning.ts";
9
+ import { parseList, pluginState, type InstalledPlugin } from "./setup.ts";
10
+
11
+ /** #1385: the agent-hub versions the console shows. Every value is display only; a missing one is unknown, never matching. */
12
+ export interface ConsoleVersions {
13
+ daemon?: string;
14
+ cli: string;
15
+ global?: string;
16
+ plugin?: string;
17
+ /** The ones older than the running daemon, by the comparison `ahub doctor` prints (`runtimeVersionWarnings`), plus a global install older than it. */
18
+ older: ("cli" | "global" | "plugin")[];
19
+ }
20
+
21
+ // Contract: a package.json is a few KiB; a larger file is not an agent-hub manifest.
22
+ const MANIFEST_BYTES = 64 * 1024;
23
+ // Contract: the same bound `ahub doctor` and `ahub upgrade` give the plugin listing.
24
+ const PLUGIN_PROBE_MS = 10_000;
25
+ // Contract: a Claude plugin listing is a few KiB; more is not one.
26
+ const PLUGIN_PROBE_BYTES = 256 * 1024;
27
+
28
+ /** The version in the `package.json` of the `ahub` on PATH, read without running it. Unknown when no `ahub` resolves to a package root or its manifest is unreadable. */
29
+ export function globalCliVersion(env: NodeJS.ProcessEnv = process.env): string | undefined {
30
+ const root = globalCliRoot(env);
31
+ if (!root) return;
32
+ let fd: number | undefined;
33
+ try {
34
+ fd = openSync(join(root, "package.json"), constants.O_RDONLY | constants.O_NOFOLLOW);
35
+ const size = fstatSync(fd).size;
36
+ if (size > MANIFEST_BYTES) return;
37
+ const buffer = Buffer.alloc(size);
38
+ readSync(fd, buffer, 0, size, 0);
39
+ const manifest = JSON.parse(buffer.toString("utf8")) as { name?: unknown; version?: unknown };
40
+ return manifest.name === "@staix/agent-hub" ? displayVersion(manifest.version) : undefined;
41
+ } catch { return; } finally { if (fd !== undefined) closeSync(fd); }
42
+ }
43
+
44
+ /** The installed Claude plugin's version from the `claude plugin list --json` listing `ahub doctor` reads, once, bounded. A missing `claude`, a failure or an unreadable list is unknown. */
45
+ export async function installedPluginVersion(packageRoot: string): Promise<string | undefined> {
46
+ try {
47
+ const child = Bun.spawn([DOCTOR_PLUGIN_PROBE.command, ...DOCTOR_PLUGIN_PROBE.argv], { env: withoutOrcaEnv(childEnv()), stdin: "ignore", stdout: "pipe", stderr: "ignore" });
48
+ const timer = setTimeout(() => child.kill(), PLUGIN_PROBE_MS);
49
+ try {
50
+ const reader = child.stdout.getReader();
51
+ const chunks: Uint8Array[] = [];
52
+ let bytes = 0;
53
+ for (;;) {
54
+ const { done, value } = await reader.read();
55
+ if (done) break;
56
+ bytes += value.byteLength;
57
+ if (bytes > PLUGIN_PROBE_BYTES) { child.kill(); await reader.cancel(); return; }
58
+ chunks.push(value);
59
+ }
60
+ if (await child.exited !== 0) return;
61
+ const state = pluginState(parseList<InstalledPlugin>(Buffer.concat(chunks).toString("utf8")), packageRoot);
62
+ return state.state === "missing" ? undefined : displayVersion(state.version);
63
+ } finally { clearTimeout(timer); }
64
+ } catch { return; }
65
+ }
66
+
67
+ /** Both readings for `ahub console`, started once at launch so no draw waits on them. */
68
+ export async function installedVersions(packageRoot: string): Promise<{ global?: string; plugin?: string }> {
69
+ const global = globalCliVersion(), plugin = await installedPluginVersion(packageRoot);
70
+ return { ...(global ? { global } : {}), ...(plugin ? { plugin } : {}) };
71
+ }
72
+
73
+ export function consoleVersions(daemon: unknown, cli: string, global: string | undefined, plugin: string | undefined): ConsoleVersions {
74
+ const running = displayVersion(daemon);
75
+ const older: ConsoleVersions["older"] = [];
76
+ if (running) {
77
+ const warned = new Set(runtimeVersionWarnings(running, cli, plugin).filter(row => row.level === "warn").map(row => row.name));
78
+ if (warned.has("CLI versus daemon")) older.push("cli");
79
+ try { if (global && Bun.semver.order(global, running) < 0) older.push("global"); } catch { /* not comparable: shown, never flagged */ }
80
+ if (warned.has("plugin versus daemon")) older.push("plugin");
81
+ }
82
+ return { ...(running ? { daemon: running } : {}), cli, ...(global ? { global } : {}), ...(plugin ? { plugin } : {}), older };
83
+ }
84
+
85
+ /** What a peer's AHUB cell and detail say, from its status `ahub`/`ahubTools`; `differs` when any loaded version is not the daemon's. Older hubs send neither: `-`. */
86
+ export function peerHubVersion(row: { ahub?: { runs?: unknown; version?: unknown }; ahubTools?: unknown }, daemon: string | undefined): { cell: string; differs: boolean; unknown?: boolean; detail?: string } {
87
+ const runs = row.ahub?.runs, own = displayVersion(row.ahub?.version);
88
+ const tools = Array.isArray(row.ahubTools) ? row.ahubTools.filter((v): v is string => typeof v === "string" && (v === "unreported" || !!displayVersion(v))) : [];
89
+ const parts = [runs === "daemon" ? "daemon" : runs === "client" ? own ?? "unreported" : undefined, ...(tools.length ? [`tools ${tools.join(",")}`] : [])].filter((p): p is string => !!p);
90
+ if (!parts.length) return { cell: "-", differs: false };
91
+ // An unreported version is unknown, never a difference: only a version someone reported can differ from the daemon's.
92
+ const loaded = [...(runs === "client" && own ? [own] : []), ...tools.filter(v => v !== "unreported")];
93
+ const unknown = runs === "client" && !own || tools.includes("unreported");
94
+ const differs = !!daemon && loaded.some(v => v !== daemon);
95
+ const detail = `${runs === "daemon" ? `runs inside the daemon (${daemon ?? "unknown"})` : runs === "client" ? `client ${own ?? "unreported"}` : "no client attached"}${tools.length ? `; tools connections ${tools.join(", ")}` : ""}`
96
+ + (differs ? `; differs from the daemon ${daemon}: update the global CLI and run ahub setup, then restart that agent's session to load it` : "")
97
+ + (unknown ? "; an unreported version is unknown (a client older than #1385 sends none)" : "");
98
+ return { cell: parts.join(" "), differs, unknown, detail };
99
+ }
@@ -17,6 +17,8 @@ import { pasteFlow, questionRows } from "./console-question.ts";
17
17
  import { characterAttentionLine } from "./attention.ts";
18
18
  import { projectRoomStatus } from "../rooms/status.ts";
19
19
  import { LIVE_TEST_PERSON_REFUSAL } from "./identity.ts";
20
+ import { consoleVersions } from "./console-versions.ts";
21
+ import { VERSION } from "../version.ts";
20
22
 
21
23
  export interface ConsoleTerminal {
22
24
  columns: number; rows: number; isTTY: boolean; isRaw?: boolean;
@@ -40,6 +42,8 @@ export interface ConsoleOptions {
40
42
  /** Injected command runner must use argv, closed stdin, and return a cancellation handle. */
41
43
  runCommand?: (args: string[], output: (text: string) => void, done: (code?: number) => void, columns?: number) => (() => void);
42
44
  pollMs?: number;
45
+ /** #1385: the global CLI and installed plugin versions, read once off the render loop; absent reads as unknown. */
46
+ installed?: Promise<{ global?: string; plugin?: string }>;
43
47
  }
44
48
  /** Exact navigation sequences only (#309, #441); anything else in a multi-character read is a paste. */
45
49
  const NAVIGATION = ["\x1b[A", "\x1b[B", "\x1b[C", "\x1b[D", ...FIRST_KEYS, ...LAST_KEYS].filter(key => key.startsWith("\x1b"));
@@ -107,6 +111,8 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
107
111
  let resolveDone: () => void = () => {}; const done = new Promise<void>(resolve => { resolveDone = resolve; });
108
112
  let pendingStream: ConsoleEvent[] = []; let droppedStream = 0;
109
113
  let presentation = consoleOperationalSnapshot(undefined);
114
+ let installed: { global?: string; plugin?: string } = {};
115
+ options.installed?.then(value => { installed = value; if (state.versions) state.versions = consoleVersions(state.versions.daemon, VERSION, installed.global, installed.plugin); }, () => {});
110
116
  let priorStreamFooterStart: number | undefined;
111
117
  let lastExpandedNotice = "";
112
118
  const notice = (text: string, tone: Tone = "failure") => notify(state, text, Date.now(), tone);
@@ -238,6 +244,10 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
238
244
  if (status.status && status.ok !== false) state.pendingRestart = Array.isArray(status.status.pendingRestart) ? status.status.pendingRestart : [];
239
245
  if (status.status && status.ok !== false) state.retainedConfig = Array.isArray(status.status.retainedConfig) ? status.status.retainedConfig : [];
240
246
  if (status.status) state.features = Array.isArray(status.status.features) ? status.status.features : [];
247
+ if (status.status && status.ok !== false) {
248
+ state.versions = consoleVersions(status.status.version, VERSION, installed.global, installed.plugin);
249
+ state.agentDrift = Array.isArray(status.status.agentDrift) ? status.status.agentDrift : [];
250
+ }
241
251
  if (status.status && status.ok !== false) {
242
252
  const rooms = status.status.rooms;
243
253
  state.rooms = rooms === undefined ? undefined : rooms === null ? null : Array.isArray(rooms) ? projectRoomStatus(rooms).sort((a, b) => a.name.localeCompare(b.name)) : null;
@@ -252,7 +262,9 @@ export async function runConsole(options: ConsoleOptions): Promise<void> {
252
262
  }
253
263
  if (status.status?.peers) state.peers = Object.fromEntries(Object.entries(status.status.peers).map(([peer, value]) => [peer, { ...(value as object), ...status.status.roleInfo?.[peer],
254
264
  ...(typeof status.status.ownerIsolation?.[peer] === "boolean" ? { ownerIsolation: status.status.ownerIsolation[peer] } : {}),
255
- ...(typeof status.status.ownerIsolationNotes?.[peer] === "string" ? { ownerIsolationNote: status.status.ownerIsolationNotes[peer] } : {}) }]));
265
+ ...(typeof status.status.ownerIsolationNotes?.[peer] === "string" ? { ownerIsolationNote: status.status.ownerIsolationNotes[peer] } : {}),
266
+ ...(status.status.peerVersions?.[peer]?.ahub ? { ahub: status.status.peerVersions[peer].ahub } : {}),
267
+ ...(status.status.peerVersions?.[peer]?.ahubTools ? { ahubTools: status.status.peerVersions[peer].ahubTools } : {}) }]));
256
268
  if (status.status && status.ok !== false) {
257
269
  state.taskWip = status.status.taskWip ?? {};
258
270
  state.attentionFacts = attentionFacts(status.status.attentionItems);
package/src/cli/help.ts CHANGED
@@ -29,7 +29,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
29
29
  ["ahub sdlc queue <owner/repo> | release <owner/repo> [live-issue...] [--json] [--color=auto|always|never]", "read-only merge and release evidence; open to any agent as public readback of the checkout's repositories, never an authorization"],
30
30
  ["ahub sdlc adopt-merge <task> --pr <n>", "record an already merged PR at the task's recorded head with green required checks and no open Important finding; approve and release dependents (person or current conductor)"],
31
31
  ["ahub sdlc merge <task> [--dry-run] [--json] [--color=auto|always|never]", "guarded squash merge of an approved task at its approved head after every gate is re-read; follows sdlc.toml auto_merge (off, dry-run, on); --dry-run only reports (person or conductor)"],
32
- ["ahub sdlc authorize-release <version> [--json] [--color=auto|always|never]", "approve this daemon checkout commit, version and fresh docs (person or unique configured conductor on the person's explicit release instruction naming the release in its own session; hub/task/review/file/peer relays never qualify; restart revokes)"],
32
+ ["ahub sdlc authorize-release <version> [--json] [--color=auto|always|never]", "approve this daemon checkout commit, configured version source and docs policy (person or unique configured conductor on the person's explicit release instruction naming the release in its own session; hub/task/review/file/peer relays never qualify; restart revokes)"],
33
33
  ["ahub sdlc release-guard -- <literal git push|gh release create|npm publish argv>", "read-only authorization preflight; init --release-guard installs the tag pre-push hook"],
34
34
  ["ahub sdlc release-guard-hook <remote-name> <remote-url>", "internal pre-push readback; validates version tags and forwards exact stdin on success"],
35
35
  ["ahub sdlc accept <task> --issue <n> [--repo owner/repo]", "accept the task's spec issue at its current body; build entry needs it in enforce (person only)"],
@@ -139,6 +139,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
139
139
  ["ahub budget execution configure <config.json> | disable <id> [--json] [--color=auto|always|never]", "opt-in limits on model calls, tool calls, time and tokens for pi and local"],
140
140
  ]],
141
141
  ["History and reports", [
142
+ ["ahub guidance probe register --file JSON [--json] | start --id HASH --revision N [--variant G1-HASH] [--json] | show --id HASH [--json] | receipts --id HASH [--json] | cancel --id HASH --revision N [--json]", "person or configured conductor only: bounded T1 declaration and fake-only probe lifecycle; receipts reads the sealed receipts, the outcome denominator and the comparability reasons, read-only; production execution is unavailable"],
142
143
  ["ahub guidance create --file JSON [--json]", "record a bounded immutable advisory proposal through current task authority; no activation or probe"],
143
144
  ["ahub guidance list --task N --task-created MS [--cursor TOKEN] [--json]", "bounded guidance metadata pages; withdrawn history and withheld fields remain explicit"],
144
145
  ["ahub guidance show --task N --task-created MS --id HASH [--json]", "screened editable-section diff selected by existing variant id, never a displayed experiment label"],
package/src/cli/init.ts CHANGED
@@ -212,7 +212,9 @@ function changes(cwd: string, requestedName?: string, shadow = false, releaseGua
212
212
  }
213
213
  const agents = join(cwd, "AGENTS.md");
214
214
  const existing = existsSync(agents) ? readFileSync(agents, "utf8") : "";
215
- const hubBlock = upsertBlock(existing, overrides && Object.hasOwn(overrides as object, "agents") ? profile.agents : profile.agents || readFileSync(join(TEMPLATES, "AGENTS.block.md"), "utf8"));
215
+ // #1399: one source for the block. A shipped profile's `agents` is only its addition, appended to the template; a project's own `profile_overrides.agents` still replaces the whole block.
216
+ const template = readFileSync(join(TEMPLATES, "AGENTS.block.md"), "utf8");
217
+ const hubBlock = upsertBlock(existing, overrides && Object.hasOwn(overrides as object, "agents") ? profile.agents : profile.agents ? `${template.trim()}\n\n${profile.agents}` : template);
216
218
  const instructions = specsBlock(hubBlock, specsEnabled(cwd, settings)); // #1064 T3: a project that turned specs off keeps no block
217
219
  write(agents, guarded ? releaseBlock(instructions) : instructions, "refresh hub instructions; preserve surrounding text", existing.includes("<!-- AGENT_HUB:BEGIN") ? "replace" : "insert");
218
220
  const claude = join(cwd, "CLAUDE.md");
@@ -53,11 +53,16 @@ export function stableBunRuntime(options: { runtime?: string; pathRuntime?: stri
53
53
  return candidate && lexicalTarget(candidate) && samePath(candidate, runtime) ? candidate : runtime;
54
54
  }
55
55
 
56
+ /** The package root of the `ahub` on PATH, when it is a proven CLI entry (#1385). */
57
+ export function globalCliRoot(env: NodeJS.ProcessEnv = process.env): string | undefined {
58
+ const invocation = Bun.which("ahub", { PATH: env.PATH ?? "" });
59
+ return invocation ? pathPackageRoot(invocation) : undefined;
60
+ }
61
+
56
62
  /** Advice only; a staged daemon upgrade does not update the person's global CLI installation. */
57
63
  export function globalCliUpdateStep(version?: string, options: InstallPathOptions = {}): string {
58
64
  const env = options.env ?? process.env;
59
- const invocation = Bun.which("ahub", { PATH: env.PATH ?? "" });
60
- const root = invocation ? pathPackageRoot(invocation) : undefined;
65
+ const root = globalCliRoot(env);
61
66
  const generic = `update the global CLI${version ? ` to ${version}` : ""} the way it was installed`;
62
67
  if (!root) return generic;
63
68
  const global = join(env.BUN_INSTALL || join(options.home ?? homedir(), ".bun"), "install/global/node_modules");
package/src/cli/main.ts CHANGED
@@ -129,7 +129,9 @@ import { COMPLETION_SHELLS, completionScript } from "./completion.ts";
129
129
  import { agentShellCause, classifyPeerCommand, cliCommandLabel, detectCliIdentity, LIVE_TEST_PERSON_REFUSAL, liveTestRefusal, peerCommandRefusal } from "./identity.ts";
130
130
  import { recordCliAudit, recordDelegatedCliAudit } from "./identity-audit.ts";
131
131
  import { runConsole } from "./console.ts";
132
+ import { installedVersions } from "./console-versions.ts";
132
133
  import { paint, permissionBoundary, resolveColor, wrap, type Span } from "./console-state.ts";
134
+ import { queueResolveArgsValid } from "../hub/person-command.ts";
133
135
  import { outputWidth, renderRuntimeModels, renderRoster, renderStatus, renderBoard, renderBacklog, renderBoardColumns, boardColumnModel, renderBudget, renderDoctor, renderProjects, renderQueue, renderTurns, renderOrphans, renderOrphanCleanup, renderQueueShow, renderModelsStatus, renderExecutionBudgetStatus, renderReport, renderUsage, renderLimits, renderTotal, type DoctorCheck } from "./output.ts";
134
136
  import { renderHelp, configuredAcpHelp } from "./help.ts";
135
137
  import { renderBacklogResult, renderGroom, renderReleaseChange, renderReleaseList, renderReleaseNew, renderReleaseShow, renderTaskCancel, renderTaskShow } from "./task-output.ts";
@@ -248,12 +250,14 @@ const requireNamedPeerFeature = (hub: ControlClient, peer: string | undefined) =
248
250
  const projectConfig = () => {
249
251
  const config = loadConfig(cwd);
250
252
  for (const line of config.ignored ?? []) console.error(`note: ${line}; only a config file nobody committed may set it`);
253
+ for (const line of config.releasePolicyNotices ?? []) console.error(`note: ${line}`);
251
254
  return config;
252
255
  };
253
256
  const stateDir = selected.stateDir;
254
257
  var operationalAuditReady=false, operationalRefusalRecorded=false;
255
258
  const caller = declaredInstances ? detectCliIdentity(process.env, declaredInstances) : unboundCaller;
256
- const commandLabel = cliCommandLabel(cmd, args, projectCatalog);
259
+ const commandLabel = cmd === "guidance" && args[0] === "probe" && ["register", "start", "show", "receipts", "cancel"].includes(args[1] ?? "")
260
+ ? `guidance probe ${args[1]}` : cliCommandLabel(cmd, args, projectCatalog);
257
261
  let commandAccess = classifyPeerCommand(cmd, args, projectCatalog);
258
262
  const continuationPeer = process.env.AGENTHUB_RECOVERY_CONDUCTOR;
259
263
  const continuationId = process.env.AGENTHUB_RECOVERY_OPERATION;
@@ -275,7 +279,10 @@ if (continuationPeer !== undefined) {
275
279
  }
276
280
  const conductorPeer = !liveTest && caller.role === "tools" && (recoveryRunnerContinuation || ["restart", "upgrade", "recovery"].includes(cmd) && commandAccess === "conductor") ? caller.peer : undefined;
277
281
  // Agent-authored content keeps its peer. Operational starts/holds may borrow console authority for live verification.
278
- const delegationRefused = liveTest && caller.role === "tools" && commandAccess !== "allowed" && liveTestRefusal(cmd, args);
282
+ const guidanceProbeDelegationRefused = liveTest && caller.role === "tools" && cmd === "guidance"
283
+ && args[0] === "probe" && ["register", "start", "show", "receipts", "cancel"].includes(args[1] ?? "");
284
+ const delegationRefused = liveTest && caller.role === "tools" && commandAccess !== "allowed"
285
+ && (liveTestRefusal(cmd, args) || guidanceProbeDelegationRefused);
279
286
  const delegatedPeer = liveTest && caller.role === "tools" && commandAccess !== "allowed" && !delegationRefused ? caller.peer : undefined;
280
287
  const identity = delegatedPeer || recoveryLauncher ? { role: "console" as const } : caller;
281
288
  operationalAuditReady=identity.role==="tools" && commandAccess==="conductor" && conductorOperation(cmd,args)!==undefined;
@@ -872,6 +879,8 @@ const LOCAL_OPERATION_ARGS: Record<string, () => void> = {
872
879
  "source add": () => { const operands = args.filter(arg => arg !== "--json" && arg !== "--full" && !arg.startsWith("--color=")); if (operands[0] !== "add" || operands.length !== 2 || !operands[1]) fail(SOURCE_USAGE); },
873
880
  };
874
881
 
882
+ // Outside the command bodies: test/lifecycle-starting-1232.test.ts runs the `up` body as a plain function, where import.meta does not parse.
883
+ const consoleInstalled = () => installedVersions(join(import.meta.dir, "..", ".."));
875
884
  const commands: Record<string, () => Promise<void> | void> = {
876
885
  upgrade: () => upgrade("upgrade"),
877
886
  restart: () => upgrade("restart"),
@@ -1192,7 +1201,7 @@ const commands: Record<string, () => Promise<void> | void> = {
1192
1201
  if (args.some(arg => arg !== "--panels" && arg !== "--no-pet" && !arg.startsWith("--color=")) || args.filter(arg => arg.startsWith("--color=")).length > 1) fail("usage: ahub console [--panels] [--no-pet] [--color=auto|always|never]");
1193
1202
  const color = resolveColor(args.find(arg => arg.startsWith("--color="))?.slice("--color=".length), { isTTY: !!process.stdin.isTTY && !!process.stdout.isTTY, TERM: process.env.TERM, NO_COLOR: process.env.NO_COLOR });
1194
1203
  if (color instanceof Error) return fail("usage: ahub console [--panels] [--no-pet] [--color=auto|always|never]");
1195
- await runConsole({ client: await connect(), cwd, stateDir, liveTest, panels: args.includes("--panels"), noPet: args.includes("--no-pet"), color });
1204
+ await runConsole({ client: await connect(), cwd, stateDir, liveTest, panels: args.includes("--panels"), noPet: args.includes("--no-pet"), color, installed: consoleInstalled() });
1196
1205
  },
1197
1206
 
1198
1207
  up: async () => {
@@ -1209,7 +1218,7 @@ const commands: Record<string, () => Promise<void> | void> = {
1209
1218
  for (const line of await startProjectAgents({ root: cwd, stateDir }, chosen.agents)) console.log(terminalText(line));
1210
1219
  } catch (error) { console.error(`default agents were not started: ${terminalText((error as Error).message)}`); }
1211
1220
  }
1212
- if (process.stdin.isTTY && process.stdout.isTTY && !args.includes("--no-console")) await runConsole({ client: await connect(), cwd, stateDir, liveTest });
1221
+ if (process.stdin.isTTY && process.stdout.isTTY && !args.includes("--no-console")) await runConsole({ client: await connect(), cwd, stateDir, liveTest, installed: consoleInstalled() });
1213
1222
  },
1214
1223
 
1215
1224
  ...Object.fromEntries(BUILTIN_CLI_ENTRIES.map(entry => [entry.command, async () => {
@@ -1242,6 +1251,61 @@ const commands: Record<string, () => Promise<void> | void> = {
1242
1251
  guidance: async () => {
1243
1252
  const { parseGuidanceCommand, validateGuidancePageReply, validateGuidanceDiffReply, validateGuidanceReceipt, renderGuidance, renderGuidanceReceipt } = await import("./guidance.ts");
1244
1253
  const { parseGuidanceVariantV1, GUIDANCE_RECORD_MAX_BYTES } = await import("../hub/guidance-variants.ts");
1254
+ const { parseGuidanceProbeSubcommand, parseGuidanceProbeRegistration, GUIDANCE_PROBE_REGISTRATION_BYTES,
1255
+ parseGuidanceProbePublicReceipt, parseGuidanceProbePublicStatus, parseGuidanceProbeReceiptExport } = await import("../hub/guidance-probes.ts");
1256
+ const { guidanceProbeStatusLines } = await import("../ui/guidance-view.ts");
1257
+ let probeCommand;
1258
+ try { probeCommand = parseGuidanceProbeSubcommand(args); } catch { return fail("invalid guidance probe command; use probe register, start, show, receipts or cancel with the documented bounded arguments"); }
1259
+ if (probeCommand) {
1260
+ if (liveTest) return fail("live-test cannot perform guidance probe operations as the person; use a current person or configured conductor session");
1261
+ let registration: ReturnType<typeof parseGuidanceProbeRegistration> | undefined;
1262
+ if (probeCommand.op === "register") {
1263
+ try {
1264
+ const fd = openSync(resolve(invokedFrom, probeCommand.file), constants.O_RDONLY | constants.O_NOFOLLOW | constants.O_NONBLOCK);
1265
+ try {
1266
+ if (!fstatSync(fd).isFile()) return fail("the guidance probe file must be a bounded regular JSON file");
1267
+ const bytes = Buffer.alloc(GUIDANCE_PROBE_REGISTRATION_BYTES + 1); let got = 0;
1268
+ while (got < bytes.length) { const read = readSync(fd, bytes, got, bytes.length - got, null); if (!read) break; got += read; }
1269
+ if (got > GUIDANCE_PROBE_REGISTRATION_BYTES) return fail("the guidance probe registration exceeds its derived envelope bound");
1270
+ registration = parseGuidanceProbeRegistration(JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, got))));
1271
+ if (!registration) return fail("invalid guidance probe registration; retain its complete bounded manifest and snapshots without trimming");
1272
+ } finally { closeSync(fd); }
1273
+ } catch { return fail("cannot read a valid bounded guidance probe registration; check its closed V1 manifest and snapshots"); }
1274
+ }
1275
+ const hub = await connect();
1276
+ try {
1277
+ if (!hub.features.includes("guidance_probes")) return fail("running hub lacks guidance_probes; upgrade and restart the hub, then retry ahub guidance");
1278
+ if (probeCommand.op === "receipts" && !hub.features.includes("guidance_probe_receipts")) return fail("running hub lacks guidance_probe_receipts; upgrade and restart the hub, then retry ahub guidance probe receipts");
1279
+ const request = probeCommand.op === "register" ? { t: "guidance_probe_register", registration: registration! }
1280
+ : probeCommand.op === "start" ? { t: "guidance_probe_start", id: probeCommand.id, revision: probeCommand.revision, ...(probeCommand.variantId ? { variantId: probeCommand.variantId } : {}) }
1281
+ : probeCommand.op === "cancel" ? { t: "guidance_probe_cancel", id: probeCommand.id, revision: probeCommand.revision }
1282
+ : probeCommand.op === "receipts" ? { t: "guidance_probe_receipts", id: probeCommand.id }
1283
+ : { t: "guidance_probe_show", id: probeCommand.id };
1284
+ const result = await hub.request(request);
1285
+ if (result.ok !== true) {
1286
+ const detail = terminalText(result.error ?? "guidance probe outcome is unconfirmed").replace(/[\r\n]+/g, " ").slice(0, 512);
1287
+ const nextStep = probeCommand.op === "register" ? "" : `; inspect ahub guidance probe show --id ${probeCommand.id} before any explicit retry`;
1288
+ return fail(`${detail}${nextStep}`);
1289
+ }
1290
+ if (probeCommand.op === "receipts") {
1291
+ const exported = parseGuidanceProbeReceiptExport(result.receipts);
1292
+ if (!exported) return fail("guidance probe receipts are malformed or fail their digest check; inspect retained probe state before relying on them");
1293
+ if (args.includes("--json")) console.log(JSON.stringify(exported, null, 2));
1294
+ else for (const line of guidanceProbeStatusLines(exported)) console.log(terminalText(line));
1295
+ } else if (probeCommand.op === "show") {
1296
+ const status = parseGuidanceProbePublicStatus(result.status);
1297
+ if (!status) return fail("guidance probe status is malformed; refresh its id and current task context");
1298
+ if (args.includes("--json")) console.log(JSON.stringify(status, null, 2));
1299
+ else console.log(`guidance probe ${status.id}: ${status.state}; revision ${status.revision}; evidence ${status.evidence}; workers ${status.counters.workerAttempts}; editors ${status.counters.editorAttempts}; model calls ${status.counters.modelCalls}; tool calls ${status.counters.toolCalls}; token usage ${status.counters.usageUnknown || status.counters.modelCalls === 0 ? "unknown" : status.counters.tokensObservedKnown}; cancelled ${status.cancelRequested ? "yes" : "no"}`);
1300
+ } else {
1301
+ const receipt = parseGuidanceProbePublicReceipt(result.receipt);
1302
+ if (!receipt) return fail("guidance probe receipt is malformed; inspect retained probe state before retrying");
1303
+ if (args.includes("--json")) console.log(JSON.stringify(receipt, null, 2));
1304
+ else console.log(`guidance probe ${receipt.id}: ${receipt.state}; revision ${receipt.revision}; evidence ${receipt.evidence}${receipt.already ? "; already recorded" : ""}`);
1305
+ }
1306
+ } finally { hub.close(); }
1307
+ return;
1308
+ }
1245
1309
  let command; try { command = parseGuidanceCommand(args); } catch (error) { return fail((error as Error).message); }
1246
1310
  if (liveTest && (command.op === "create" || command.op === "withdraw")) return fail("live-test cannot write guidance declarations as the person; use the current task actor without --live-test");
1247
1311
  let variant: ReturnType<typeof parseGuidanceVariantV1> | undefined;
@@ -1416,11 +1480,11 @@ const commands: Record<string, () => Promise<void> | void> = {
1416
1480
  const shown = await hub.request({ t: "queue", op: "show", id });
1417
1481
  if (!shown.ok) fail(shown.error,shown.refusalAudited===true,shown.authorityRefused);
1418
1482
  if (options.json) return console.log(JSON.stringify(shown.delivery, null, 2));
1419
- return printOutput(renderQueueShow(shown.delivery, options.columns, Date.now()), options.color);
1483
+ return printOutput(renderQueueShow(shown.delivery, options.columns, Date.now(), cwd), options.color);
1420
1484
  }
1421
1485
  const { one, rest: extra } = takeFlags(flags, ["--action", "--reason", "--revision"], []);
1422
1486
  const rawRevision = one["--revision"], parsedRevision = rawRevision === undefined ? undefined : Number(rawRevision);
1423
- if (extra.length || !["completed", "retry", "discard"].includes(one["--action"] ?? "") || !one["--reason"]?.trim() || (rawRevision !== undefined && (!/^\d+$/.test(rawRevision) || !Number.isSafeInteger(parsedRevision)))) fail("usage: ahub queue resolve <id> --action completed|retry|discard --reason <text> [--revision N]");
1487
+ if (!queueResolveArgsValid(one["--action"], one["--reason"], rawRevision, extra)) fail("usage: ahub queue resolve <id> --action completed|retry|discard --reason <text> [--revision N]");
1424
1488
  let revision = parsedRevision;
1425
1489
  if (revision === undefined) {
1426
1490
  const shown = await hub.request({ t: "queue", op: "show", id });
@@ -1430,7 +1494,7 @@ const commands: Record<string, () => Promise<void> | void> = {
1430
1494
  const result = await hub.request({ t: "queue", op: "resolve", id, revision, action: one["--action"], reason: one["--reason"] });
1431
1495
  if (!result.ok) fail(result.error,result.refusalAudited===true,result.authorityRefused);
1432
1496
  if (options.json) console.log(JSON.stringify(result.delivery, null, 2));
1433
- else printOutput(renderQueueShow(result.delivery, options.columns, Date.now()), options.color);
1497
+ else printOutput(renderQueueShow(result.delivery, options.columns, Date.now(), cwd), options.color);
1434
1498
  } finally { hub.close(); }
1435
1499
  },
1436
1500
 
@@ -3040,6 +3104,12 @@ const commands: Record<string, () => Promise<void> | void> = {
3040
3104
 
3041
3105
  try {
3042
3106
  for (const check of runtimePruneHealth()) row(check.ok, check.name, check.detail);
3107
+ // #1399: a project initialised by an older ahub keeps that version's instruction block until init runs again; doctor says so with the command.
3108
+ try {
3109
+ const stale = planInit(cwd).some(change => change.path === join(cwd, "AGENTS.md"));
3110
+ row(stale ? undefined : true, "hub instructions", // a warning, never a failure: doctor's exit code stays what it was for a project that has not refreshed yet
3111
+ stale ? `the managed block in AGENTS.md differs from this ahub version; preview with: cd ${cwd} && ahub init --dry-run; apply with: cd ${cwd} && ahub init --yes (text outside the markers is kept), then commit AGENTS.md` : "AGENTS.md managed block matches this ahub version");
3112
+ } catch (error) { row(false, "hub instructions", `AGENTS.md could not be checked: ${error instanceof Error ? error.message : "unknown error"}; run ahub init --dry-run to see why`); }
3043
3113
  const catalog = loadRoleCatalog(cwd);
3044
3114
  for (const error of catalog.errors) row(false, "catalog role", `${error.id}: ${error.reason}`);
3045
3115
  try {
@@ -3094,6 +3164,7 @@ const commands: Record<string, () => Promise<void> | void> = {
3094
3164
 
3095
3165
  const config = loadConfig(cwd);
3096
3166
  row(!config.ignored, "config", config.ignored ? `${config.ignored.join("; ")} (move them to .agenthub/config.local.json)` : "no machine-local field ignored");
3167
+ for (const line of config.releasePolicyNotices ?? []) row(false, "release policy", line);
3097
3168
  for (const line of config.retired ?? []) row(false, "retired setting", line);
3098
3169
  const { routing, errors: routingErrors } = inspectDoctorRouting(cwd);
3099
3170
  for (const error of routingErrors) row(false, "routing", error);
package/src/cli/output.ts CHANGED
@@ -13,6 +13,7 @@ import { schedulePeriodText, scheduleWhen } from "../hub/schedules.ts";
13
13
  import { formatReport, formatTaskReport, type Report, type TaskReport } from "../hub/report.ts";
14
14
  import type { Counter, LimitsResult, TotalResult, UsageResult } from "../hub/usage-rollup.ts";
15
15
  import type { SpecsStatus } from "../hub/specs-task.ts";
16
+ import { queueResolveChoices, queueResolveCommand } from "../hub/person-command.ts";
16
17
 
17
18
  export interface DoctorCheck { section: "Tools" | "Hub" | "Config" | "Models" | "Memory"; level: "ok" | "warn" | "fail" | "unknown"; name: string; detail: string }
18
19
  export interface StatusOutput {
@@ -328,7 +329,7 @@ export function renderStatus(data: StatusOutput, columns?: number, now = Date.no
328
329
  for (const row of p.heldRows) out.push(...detail("held", `${id}: needs_review ${shortId(row.id, columns, full)}; from ${row.senders.join(",")}; kind ${row.kinds.join(",")}; age ${duration(Math.max(0, now - row.createdAt))}${row.context ? `; ${row.context}` : ""}; ahub queue show ${row.id}`, columns, "failure"));
329
330
  } else if (p.heldBy) {
330
331
  const note = flat(p.holdNote ?? "");
331
- const command = `ahub queue resolve ${p.heldBy} --action completed|retry|discard --reason <text>`;
332
+ const command = `${queueResolveCommand({ id: p.heldBy, peer: id, state: "needs_review" })} (${queueResolveChoices("needs_review")})`;
332
333
  const normalized = note.startsWith(`held by needs_review ${p.heldBy}`)
333
334
  ? note.replace(`held by needs_review ${p.heldBy}`, `by needs_review ${shortId(p.heldBy, columns, full)}`)
334
335
  : `${shortId(p.heldBy, columns, full)}${note ? `: ${note}` : ""}`;
@@ -591,14 +592,17 @@ function fields(value: unknown, columns: number | undefined, now: number, prefix
591
592
  visit(value, prefix, prefix);
592
593
  return rows(["FIELD", "VALUE"], leaves, columns);
593
594
  }
594
- export function renderQueueShow(delivery: any, columns?: number, now = Date.now()): Span[][] {
595
+ export function renderQueueShow(delivery: any, columns?: number, now = Date.now(), project?: string): Span[][] {
596
+ // #1399: the resolve line runs as printed: id, revision, a suggested action, a prefilled reason and the project that hosts the hub.
597
+ const messages: any[] = Array.isArray(delivery?.messages) ? delivery.messages : [];
598
+ const hint = () => queueResolveCommand({ id: delivery.id, revision: delivery.revision, state: delivery.state, peer: delivery.peer, senders: messages.map(m => String(m?.from ?? "")), kinds: messages.map(m => String(m?.kind ?? "")) }, project);
595
599
  const out = [...lines("Delivery", columns, "strong"), ...fields(delivery, columns, now)];
596
600
  if (delivery?.state === "failed" && delivery.failureCause === undefined) out.push(...detail("failure cause", "unknown (not recorded by this hub version)", columns, "muted"));
597
- if (delivery?.state === "needs_review" && delivery.id) out.push([], ...detail("resolve", `ahub queue resolve ${delivery.id} --action completed|retry|discard --reason <text>`, columns, "failure"));
601
+ if (delivery?.state === "needs_review" && delivery.id) out.push([], ...detail("resolve", `${hint()} (${queueResolveChoices("needs_review")})`, columns, "failure"));
598
602
  // #1096: a failed row that no one has settled can be cleared by the person or the conductor; one a resolution already settled says what is left (nothing).
599
603
  else if (delivery?.state === "failed" && delivery.id) {
600
604
  if (delivery.resolvedBy) out.push([], ...detail("resolve", `already resolved by ${delivery.resolvedBy}; nothing is left to do for this row${delivery.resolvedBy === "retry" ? " (its redelivery is a separate delivery: ahub queue list)" : ""}`, columns, "muted"));
601
- else out.push([], ...detail("resolve", `ahub queue resolve ${delivery.id} --action discard|completed --reason <text> (discard to drop it, completed to acknowledge it as handled; the person or the conductor)`, columns, "failure"));
605
+ else out.push([], ...detail("resolve", `${hint()} (${queueResolveChoices("failed")}; the person or the conductor)`, columns, "failure"));
602
606
  }
603
607
  return out;
604
608
  }
@@ -1,9 +1,9 @@
1
1
  import { globalCliUpdateStep, type InstallPathOptions } from "./install-paths.ts";
2
2
  import type { DoctorCheck } from "./output.ts";
3
3
  import { parseList, pluginState, type InstalledPlugin } from "./setup.ts";
4
+ import { displayVersion } from "../version.ts";
4
5
 
5
- const VERSION = /^[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/;
6
- const version = (value: unknown): string | undefined => typeof value === "string" && value.length <= 64 && VERSION.exec(value)?.[0] === value ? value : undefined;
6
+ const version = displayVersion;
7
7
 
8
8
  /** Authenticated daemon status and the existing plugin inventory only. Suggestions never run an update. */
9
9
  export function runtimeVersionWarnings(daemonVersion: unknown, cliVersion: unknown, pluginVersion: unknown, install: InstallPathOptions = {}): DoctorCheck[] {
@@ -169,17 +169,21 @@ export function renderSdlcRelease(reply: unknown, columns?: number, now = Date.n
169
169
  const r = (reply as any)?.report ?? {};
170
170
  const out: Line[] = [...heading(`Release readiness ${r.repo ?? "unknown repository"}`, columns)];
171
171
  const w = 12;
172
- out.push(...pair("version", r.version ?? "unknown", columns, w), ...pair("head", short(r.head), columns, w), ...pair("tag", r.tag ? `${r.tag} at ${short(r.tagCommit)}` : "none", columns, w));
172
+ out.push(...pair("version", r.version ?? (r.releasePolicy ? "undetermined" : "unknown"), columns, w), ...pair("head", short(r.head), columns, w), ...pair("tag", r.tag ? `${r.tag} at ${short(r.tagCommit)}` : "none", columns, w));
173
173
  out.push(...pair("source ready", yes(r.sourceReady), columns, w, readyTone(r.sourceReady)), ...pair("native", String(r.native ?? "unverified"), columns, w, "attention"), ...pair("release ready", yes(r.ready), columns, w, readyTone(r.ready)));
174
174
  out.push(...pair("commits", `${plural(list(r.commits).length, "commit")} since the last tag`, columns, w));
175
175
  if (list(r.mergedPrs).length) out.push(...pair("merged PRs", list(r.mergedPrs).map((p: any) => `#${p.pr}`).join(", "), columns, w));
176
176
  const docs = r.documents;
177
- out.push(blank, ...pair("documents", docs ? `${docs.fresh ? "fresh" : "not fresh"}, ${plural(docs.errors ?? 0, "error")}, ${plural(list(docs.documents).length, "document")}` : "not read", columns, w, docs?.fresh ? "success" : "attention"));
178
- for (const d of list(docs?.documents)) if (d.state !== "fresh") out.push(...pair(d.state, `${d.path ?? "(path withheld)"}${d.dirty ? " (uncommitted changes)" : ""}`, columns, w, "attention", " "));
177
+ if (r.releasePolicy?.docsSource === "none") out.push(blank, ...pair("documents", r.releasePolicy.authorization === "matched" ? "none (explicit exemption recorded)" : "none (configured exemption; no matching authorization)", columns, w, "muted"));
178
+ else {
179
+ out.push(blank, ...pair("documents", docs ? `${docs.fresh ? "fresh" : "not fresh"}, ${plural(docs.errors ?? 0, "error")}, ${plural(list(docs.documents).length, "document")}` : "not read", columns, w, docs?.fresh ? "success" : "attention"));
180
+ for (const d of list(docs?.documents)) if (d.state !== "fresh") out.push(...pair(d.state, `${d.path ?? "(path withheld)"}${d.dirty ? " (uncommitted changes)" : ""}`, columns, w, "attention", " "));
181
+ }
182
+ if (r.releasePolicy) out.push(...pair("release policy", `version ${r.releasePolicy.versionSource}, docs ${r.releasePolicy.docsSource}, authorization ${r.releasePolicy.authorization}`, columns, w, r.releasePolicy.authorization === "matched" ? "success" : "attention"));
179
183
  if (list(r.liveIssues).length) out.push(blank, ...grid(["ISSUE", "STATE"], list(r.liveIssues).map((i: any) => [s(`#${i.id}`, "issueRef"), s(i.state, i.state === "closed" ? "success" : "attention")]), columns));
180
184
  const a = r.authorization;
181
185
  if (a) out.push(blank, ...pair("authorization", `${a.state}: version ${a.receipt?.version ?? "unknown"} at ${short(a.receipt?.commit)}, approved ${moment(a.receipt?.at, now)}`, columns, w, a.state === "matched" ? "success" : "attention"));
182
- else out.push(blank, ...pair("authorization", "none recorded: run ahub sdlc authorize-release <version>", columns, w, "muted"));
186
+ else out.push(blank, ...pair("authorization", r.releasePolicy ? `none recorded for ${r.releasePolicy.versionSource}: run ahub sdlc authorize-release <version>` : "none recorded: run ahub sdlc authorize-release <version>", columns, w, "muted"));
183
187
  for (const t of list(r.trains)) out.push(...pair(`train #${t.release?.id ?? "?"}`, `${t.readiness?.trigger ?? "unknown"}${list(t.readiness?.blockers).length ? `, ${list(t.readiness.blockers).join("; ")}` : ""}`, columns, w, list(t.readiness?.blockers).length ? "attention" : undefined));
184
188
  const rm = r.releaseMetrics;
185
189
  if (rm) {
@@ -249,7 +253,7 @@ export function renderAuthorization(authorization: unknown, columns?: number, no
249
253
  const w = 8;
250
254
  return [...heading("Release authorized", columns),
251
255
  ...pair("version", a?.version ?? "unknown", columns, w), ...pair("commit", short(a?.commit), columns, w), ...pair("by", a?.by ?? "unknown", columns, w),
252
- ...pair("at", moment(a?.at, now), columns, w), ...pair("docs", a?.docs ? `${a.docs.fresh ? "fresh" : "not fresh"}, ${plural(a.docs.documents ?? 0, "document")}, digest ${short(a.docs.digest)}` : "unknown", columns, w),
256
+ ...pair("at", moment(a?.at, now), columns, w), ...pair("docs", a?.docs?.source === "none" ? "none (explicit exemption)" : a?.docs ? `${a.docs.fresh ? "fresh" : "not fresh"}, ${plural(a.docs.documents ?? 0, "document")}, digest ${short(a.docs.digest)}` : "unknown", columns, w),
253
257
  ...pair("id", a?.id ?? "unknown", columns, w, "muted"), blank,
254
258
  ...para("A daemon restart revokes this authorization.", columns, "muted")];
255
259
  }
@@ -129,7 +129,7 @@ export async function endPlannedPeer(planned: PlannedProject, peer: RecoveryPeer
129
129
  const now = hub.peers.find((p) => p.id === peer.id && p.state !== "offline");
130
130
  if (!now) return refused("it is no longer attached to its hub");
131
131
  // The hub holds what a peer that goes offline mid-turn was working on (`uncertain` in bus.ts).
132
- if (now.state === "busy") cut = "; its turn was cut: a delivery it had not settled is held as needs_review, and its queue stays held until ahub queue resolve";
132
+ if (now.state === "busy") cut = `; its turn was cut: a delivery it had not settled is held as needs_review, and its queue stays held until it is resolved (ahub queue list --peer ${peer.id} names it; ahub queue show on that id prints the full resolve command)`;
133
133
  if (binding) {
134
134
  if (observedSession(binding.peer, now, binding.projectRoot) !== binding.sessionId) return refused(`the session attached now is not the one the plan bound to terminal ${binding.handle}`);
135
135
  // The same question the plan asked (`makeUpgradePlan`), for this one peer.
package/src/hub/bus.ts CHANGED
@@ -785,7 +785,7 @@ export class Bus {
785
785
  resolveOwnDelivery(peer: string, id: string, revision: number, action: "completed" | "discard", reason: string): void {
786
786
  const refuse = (message: string): never => { throw new PreEffectToolRefusal(message); };
787
787
  // One message per cause class, each naming its next step. An unknown id, another peer's row and a row that is not needs_review share one message so a refusal never confirms another peer's row.
788
- if (peer === USER || peer === HUB || remoteId(peer)) return refuse("hub_delivery_resolve settles a local agent's own held delivery; the person settles any other row with ahub queue resolve <delivery-id>");
788
+ if (peer === USER || peer === HUB || remoteId(peer)) return refuse(`hub_delivery_resolve settles a local agent's own held delivery; the person settles any other row with ahub queue resolve (ahub queue show ${id} prints the full command)`);
789
789
  if (this.closed || this.recoveryHeld || this.storageError || !this.journal) return refuse("the hub is not accepting delivery changes now (recovery, shutdown or delivery storage); run ahub status, then call hub_delivery_resolve again after it recovers");
790
790
  if (this.paused.has(peer) || this.opts.deliveryHeld?.(peer) === true) return refuse("your deliveries are paused or held, so this row cannot be settled now; run ahub status to see which, and call hub_delivery_resolve again once it is released");
791
791
  if (!Number.isSafeInteger(revision) || revision < 0 || (action !== "completed" && action !== "discard") || typeof reason !== "string" || !reason.trim() || reason.trim().length > 1000) return refuse("hub_delivery_resolve needs the revision hub_inbox showed (a whole number), action completed or discard, and a reason of 1 to 1000 characters");
@@ -794,7 +794,7 @@ export class Bus {
794
794
  if (!row || row.peer !== peer) return refuse(notYours);
795
795
  if (this.activeDeliveries.has(id) && this.activeDeliveries.get(id) !== peer) return refuse(notYours);
796
796
  // An uncertain invocation may still be running: a peer claiming it completed would make the caller wait for a result that may never come. Only the person settles it.
797
- if (row.originals.some(env => isInvocationKind(env))) return refuse(`delivery ${id} carries an invocation whose outcome is uncertain; only the person settles it (ahub queue show ${id}, then ahub queue resolve ${id})`);
797
+ if (row.originals.some(env => isInvocationKind(env))) return refuse(`delivery ${id} carries an invocation whose outcome is uncertain; only the person settles it (ahub queue show ${id} prints the full ahub queue resolve ${id} command; pass it on as printed)`);
798
798
  if (row.state === "accepted") {
799
799
  if (this.peers.get(peer)?.acceptedSettlement !== "explicit") return refuse("only an explicit push channel session can settle its accepted delivery; ask the person to resolve it");
800
800
  if (row.revision !== revision) return refuse("held delivery revision changed; read hub_inbox again for the current revision");
@@ -204,6 +204,8 @@ const schema: Record<string, Check> = {
204
204
  text_projection: v => { projectionConfig(v); },
205
205
  corpus: v => { corpusConfig(v); },
206
206
  specs: (v, k) => { block({ enabled: bool, review: words(["off", "report", "require"]), roots: strings, stamps_file: text })(v, k); parseSpecsConfig(v); },
207
+ // S6 owns this closed schema at the committed candidate boundary; config.local is ignored before runtime publication.
208
+ release: () => {},
207
209
  conductor: block({ feed: words(["own", "all", "off"]), approval_wait_s: number(0, 2_147_483_647 / 1000) }),
208
210
  budget: block({ gate: number(0, 1), stale_min: timerMinutes, poll_min: timerMinutes, checkpoint_timeout_s: timerSeconds, kimi_tokens_5h: number(0), wait_max_min: number(0) }),
209
211
  context: block({ gate: number(0, 1), stale_min: timerMinutes, max_assignment_used: number(0, 1) }),
@@ -259,7 +261,7 @@ export function validateRawConfig(raw: unknown, declarations?: InstancesConfig,
259
261
  }
260
262
  export function validateEffectiveConfig(value: unknown, catalog?: ProjectAdapterCatalog): asserts value is HubConfig {
261
263
  const raw = { ...object(value, "config") };
262
- delete raw.ignored; delete raw.retired; delete raw.permission_default_sources;
264
+ delete raw.ignored; delete raw.retired; delete raw.releasePolicyNotices; delete raw.permission_default_sources;
263
265
  validateRawConfig(raw, undefined, catalog);
264
266
  const profile = resolveProfile(raw.profile, raw.profile_overrides);
265
267
  for (const key of Object.keys(object(raw.checks, "checks"))) if (!["timeout_s", "runner", "remote", ...CLASSES, ...Object.keys(profile.classes)].includes(key)) fail(`checks.${key}`, "unknown task class");
@@ -327,7 +329,7 @@ export function configChanges(running: HubConfig, next: HubConfig, scopes: reado
327
329
  changes.push({ key, before, after, ...(stale ? { applies: "live" as const } : configApply(key, scopes)) });
328
330
  }
329
331
  };
330
- const clean = (v: HubConfig) => Object.fromEntries(Object.entries(v).filter(([key]) => !["ignored", "retired", "permission_default_sources"].includes(key)));
332
+ const clean = (v: HubConfig) => Object.fromEntries(Object.entries(v).filter(([key]) => !["ignored", "retired", "releasePolicyNotices", "permission_default_sources"].includes(key)));
331
333
  walk(clean(running), clean(next), ""); return changes.sort((a, b) => a.key.localeCompare(b.key));
332
334
  }
333
335
 
@@ -105,6 +105,8 @@ const drop = (file: Record<string, unknown>, path: string) => {
105
105
  * once resolved to the project root). A committed copy of the template sets them to defaults and asks git nothing.
106
106
  */
107
107
  export function stripUntrusted(file: Record<string, unknown>, defaults: object, cwd: string, name: string): string | undefined {
108
+ const releaseLocal = name === "config.local.json" && Object.hasOwn(file, "release");
109
+ if (releaseLocal) delete file.release;
108
110
  const research = file.research;
109
111
  if (research && typeof research === "object" && Object.hasOwn(research, "runners")) {
110
112
  if (name !== "config.local.json") throw new Error("research.runners requires untracked config.local.json");
@@ -114,7 +116,10 @@ export function stripUntrusted(file: Record<string, unknown>, defaults: object,
114
116
  if (name !== "config.local.json") delete file.rooms;
115
117
  const localOnly = name !== "config.local.json" && file.action_policy !== undefined;
116
118
  if (localOnly) delete file.action_policy;
117
- const originNotice = localOnly ? "action_policy ignored: only .agenthub/config.local.json may set it" : undefined;
119
+ const originNotice = [
120
+ localOnly ? "action_policy ignored: only .agenthub/config.local.json may set it" : undefined,
121
+ releaseLocal ? "release in .agenthub/config.local.json ignored: only committed .agenthub/config.json may set release policy" : undefined,
122
+ ].filter(Boolean).join("; ") || undefined;
118
123
  for (const p of ALL_MACHINE_LOCAL) if (!EMPTY_IS_VALUE.includes(p) && valueAt(file, p) !== undefined && !chooses(valueAt(file, p))) drop(file, p);
119
124
  const set = ALL_MACHINE_LOCAL.filter((p) => {
120
125
  const v = valueAt(file, p);
@@ -5,6 +5,7 @@ import { newToolRequestId, TOOL_WRITE_FEATURE, toolWriteOperation, toolWriteUnkn
5
5
  import { externalAdapterMetadata, externalInstanceCatalog, type ExternalInstanceCatalog, type ExternalAdapterMetadata } from "../adapters/external-metadata.ts";
6
6
  import { negotiateProtocol, protocolWindow, type ProtocolWindow } from "./protocol-window.ts";
7
7
  import { ControlWriteTelemetry, controlWriteMetadata, controlWriteSpan } from "./control-write-trace.ts";
8
+ import { VERSION } from "../version.ts";
8
9
 
9
10
  // The client has no authoritative task privacy view. Keep kind/timing only, never its args or task id.
10
11
  const clientWriteTelemetry = new ControlWriteTelemetry({ emit: line => {
@@ -21,7 +22,7 @@ export const PROTOCOL = 17;
21
22
  /** The descriptor's legacy protocol field remains this floor for previous published clients. */
22
23
  export const PROTOCOL_MIN = 16;
23
24
  // Literal metadata is read without executing a recovery target; consistency is pinned in tests.
24
- export const DAEMON_FEATURES = ["guidance_views", "guidance_variants", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover"] as const;
25
+ export const DAEMON_FEATURES = ["guidance_views", "guidance_variants", "guidance_probes", "guidance_probe_receipts", "execution_lineage", "model_overrides", "visuals", "project_autonomy", "conductor_recovery", "encrypted_rooms", "external_adapter_instances", "external_adapter_modules", "configured_acp", "native_hook_launch", "task_cancel", "invocation", "recovery_deferred_hub", "peer_instances", "role_stages", "task_planners", "release_trains", "reviewer_pool", "native_tui_launch", "terminal_owner", "cli_audit_delegated", "action_policy_floor", "calendar_schedules", "research_records", "research_dispatch", "research_dropped_offers", "research_experiments", "research_comparisons", "research_runners", "task_handoff", "session_identity", "schema_guard", "design_specs", "queue_discard_states", "tool_write_idempotency", "research_evidence", "review_comments", "questions", "accepted_delivery_settlement", "completions", "review_observer_input_state", "task_handoff_key", "task_handoff_seq", "peer_takeover"] as const;
25
26
  /** Protocols a current coordinator may authenticate while upgrading a running source. */
26
27
  export const RECOVERY_SOURCE_PROTOCOLS = [9, 10, 11, 12, 13, 14, 15, 16, PROTOCOL] as const;
27
28
 
@@ -76,6 +77,8 @@ export interface Hello {
76
77
  retainStandby?: true;
77
78
  /** Display-only process id, never native-session or authorization evidence. */
78
79
  clientPid?: number;
80
+ /** #1385: the agent-hub version this client was built from. `connect` always sets it from `VERSION`; display only, never admission, compatibility or authorization evidence. */
81
+ clientVersion?: string;
79
82
  projectId?: string;
80
83
  instanceId?: string;
81
84
  projectRoot?: string;
@@ -230,7 +233,7 @@ export class ControlClient {
230
233
  client.pending.delete(msg.rid);
231
234
  done(msg);
232
235
  };
233
- ws.onopen = () => void client.request({ t: "hello", token: control.token, ...hello, ...expected, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
236
+ ws.onopen = () => void client.request({ t: "hello", token: control.token, ...hello, ...expected, clientVersion: VERSION, v: selected, vMin: remote?.vMin === undefined ? selected : Math.max(local.vMin, remote.vMin) }, timeoutMs).then((reply) => {
234
237
  if (reply.t !== "welcome" || reply.ok === false) return refuse(new Error(reply.error ?? "hub refused handshake"));
235
238
  if ((expected.projectId && reply.projectId !== expected.projectId) ||
236
239
  (expected.instanceId && reply.instanceId !== expected.instanceId) ||