@staix/agent-hub 0.53.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -3
  3. package/docs/agent-notes/README.md +1 -1
  4. package/docs/agent-notes/adapters.md +4 -3
  5. package/docs/agent-notes/budget.md +2 -2
  6. package/docs/agent-notes/bus.md +1 -0
  7. package/docs/agent-notes/daemon.md +1 -1
  8. package/docs/agent-notes/models.md +1 -1
  9. package/docs/agent-notes/tests.md +4 -4
  10. package/docs/contracts/companion-cli-v3.json +348 -0
  11. package/docs/design/adapters.md +1 -1
  12. package/docs/design/agent-hub-architecture.md +8 -5
  13. package/docs/design/bus.md +1 -1
  14. package/docs/design/cli-output-inventory.md +2 -2
  15. package/docs/design/model-routes.md +20 -5
  16. package/docs/dogfood.md +7 -3
  17. package/docs/events.md +1 -1
  18. package/docs/memory.md +2 -2
  19. package/docs/operations.md +122 -45
  20. package/docs/quickstart.md +8 -2
  21. package/docs/security.md +11 -7
  22. package/docs/specs/2026-09-19-agent-hub-design.md +5 -3
  23. package/docs/specs/2026-09-19-multi-project-design.md +1 -1
  24. package/docs/specs/2026-12-04-arev-adoption-design.md +3 -3
  25. package/docs/specs/mcp-endpoint.md +1 -1
  26. package/docs/specs/relay-contract.md +38 -0
  27. package/docs/verification/2026-12-06-0.54.0.md +76 -0
  28. package/docs/verification/2026-12-06-codex-0174-reviewer-isolation.md +43 -0
  29. package/docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md +34 -0
  30. package/docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md +25 -0
  31. package/docs/verification/2026-12-06-compat-pi-1.8.0.md +23 -0
  32. package/docs/verified.json +27 -28
  33. package/package.json +5 -4
  34. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  35. package/plugins/agent-hub/.mcp.json +1 -1
  36. package/plugins/agent-hub/compat.json +5 -3
  37. package/plugins/agent-hub/kimi-hook.js +5 -4
  38. package/plugins/agent-hub/relay-launcher.js +24 -0
  39. package/plugins/agent-hub/server.js +5112 -4737
  40. package/src/adapters/acp.ts +5 -4
  41. package/src/adapters/compat.ts +22 -12
  42. package/src/adapters/definitions/native-cli-preview-pi.ts +2 -1
  43. package/src/adapters/definitions/native-config-defaults.ts +1 -1
  44. package/src/adapters/definitions/native-factories.ts +4 -1
  45. package/src/adapters/local-worker.ts +3 -3
  46. package/src/adapters/pi.ts +26 -7
  47. package/src/adapters/relay-launcher.ts +27 -0
  48. package/src/cli/agents.ts +20 -8
  49. package/src/cli/commands/agents.ts +18 -1
  50. package/src/cli/commands/doctor.ts +18 -4
  51. package/src/cli/commands/launch-line.ts +13 -5
  52. package/src/cli/help.ts +4 -2
  53. package/src/cli/launch-line-plan.ts +82 -0
  54. package/src/cli/pi-steps-warning.ts +14 -0
  55. package/src/hub/accounts.ts +8 -4
  56. package/src/hub/adec-triage.ts +105 -0
  57. package/src/hub/bus.ts +39 -6
  58. package/src/hub/config-apply.ts +1 -1
  59. package/src/hub/config.ts +2 -2
  60. package/src/hub/control/dashboard-messages.ts +221 -0
  61. package/src/hub/control/delivery-messages.ts +356 -0
  62. package/src/hub/control/dispatch.ts +114 -0
  63. package/src/hub/control/operations-messages.ts +269 -0
  64. package/src/hub/control/peer-messages.ts +126 -0
  65. package/src/hub/control/scope.ts +79 -2
  66. package/src/hub/daemon.ts +111 -918
  67. package/src/hub/delivery-hints.ts +2 -0
  68. package/src/hub/delivery-journal.ts +17 -6
  69. package/src/hub/events.ts +2 -1
  70. package/src/hub/host.ts +41 -9
  71. package/src/hub/lifecycle.ts +3 -2
  72. package/src/hub/peers.ts +2 -0
  73. package/src/hub/pi-exit-policy.ts +27 -0
  74. package/src/hub/protocol-window.ts +1 -1
  75. package/src/hub/routing.ts +9 -0
  76. package/src/hub/supervision.ts +33 -6
  77. package/src/hub/tasks-types.ts +4 -1
  78. package/src/hub/tasks.ts +35 -1
  79. package/src/models/route/config.ts +4 -4
  80. package/src/models/route/decision.ts +18 -10
  81. package/src/models/route/runtime.ts +8 -5
  82. package/src/npm-artifact.ts +76 -0
  83. package/src/omniroute/client.ts +6 -0
  84. package/src/pi/extension.ts +5 -2
  85. package/src/pi/install.ts +77 -0
  86. package/src/pi/pin.ts +49 -0
  87. package/templates/adec/README.md +10 -6
  88. package/templates/config.json +1 -1
@@ -12,6 +12,7 @@ export { QwenIdentityError } from "./definitions/qwen-native.ts";
12
12
  import { BasePeer } from "../hub/peers.ts";
13
13
  import type { DeliveryFailureCause } from "../hub/delivery-failure.ts";
14
14
  import { peerChildEnv, stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
15
+ import { ACP_STOPPED_BEFORE_SETTLEMENT } from "../hub/delivery-hints.ts";
15
16
  import { AcpOwnedGroup } from "./acp-owned-group.ts";
16
17
  import type { StartForm, ModelOverrideSelection } from "./registry-types.ts";
17
18
  import { assessVersion, readTrust } from "./compat.ts";
@@ -646,8 +647,8 @@ export class AcpPeer extends BasePeer {
646
647
  // invalidates its generation, while stopping still prevents a drain.
647
648
  if (legacy?.turn === this.turn) this.onFailed?.(legacy.envs);
648
649
  if (reason !== undefined) this.turn++; // a requested stop cannot escalate or complete the cancelled turn
649
- if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? "ACP session stopped before settlement", failureCause: "turn aborted" });
650
- this.settleSteers("needs_review", reason ?? "ACP session stopped before settlement");
650
+ if (this.activeDeliveryId) this.delivery({ id: this.activeDeliveryId, state: "needs_review", reason: reason ?? ACP_STOPPED_BEFORE_SETTLEMENT, failureCause: "turn aborted", ...(reason === undefined ? { holdsSelf: true as const } : {}) }); // #1946: only this host path marks a row self-held; a requested stop keeps its peer-wide hold
651
+ this.settleSteers("needs_review", reason ?? ACP_STOPPED_BEFORE_SETTLEMENT, undefined, reason === undefined); // #1946: an accepted steer is part of the same unrequested stop
651
652
  this.activeDeliveryId = undefined;
652
653
  const proc = this.proc;
653
654
  if (!proc) { this.setState("offline"); return; }
@@ -872,9 +873,9 @@ export class AcpPeer extends BasePeer {
872
873
  if (deliveryId) { this.steerIds.push(deliveryId); this.delivery({ id: deliveryId, state: "accepted" }); }
873
874
  }
874
875
 
875
- private settleSteers(state: "completed" | "needs_review", reason?: string, failureCause?: DeliveryFailureCause): void {
876
+ private settleSteers(state: "completed" | "needs_review", reason?: string, failureCause?: DeliveryFailureCause, holdsSelf = false): void {
876
877
  const ids = this.steerIds; this.steerIds = [];
877
- for (const id of ids) this.delivery({ id, state, ...(state === "needs_review" ? { reason: reason ?? "steered turn did not complete normally", ...(failureCause ? { failureCause } : {}) } : {}) });
878
+ for (const id of ids) this.delivery({ id, state, ...(state === "needs_review" ? { reason: reason ?? "steered turn did not complete normally", ...(failureCause ? { failureCause } : {}), ...(holdsSelf ? { holdsSelf: true as const } : {}) } : {}) });
878
879
  }
879
880
 
880
881
  private acceptDelivery(): void {
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import { closeSync, constants, fstatSync, lstatSync, mkdirSync, openSync, readSync, renameSync, unlinkSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { hubHome } from "../hub/project.ts";
5
+ import { readPiPin } from "../pi/pin.ts";
5
6
 
6
7
  /**
7
8
  * #691: the one version policy for native agent CLIs. Every version gate asks `assessVersion`; no other file holds a
@@ -37,17 +38,17 @@ export interface CompatPolicy {
37
38
 
38
39
  const plain = (text: string) => text.length <= 64 && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(text) ? text : undefined;
39
40
  export const COMPAT = {
40
- // Receipts: docs/verification/2026-10-26-pi-140-compat.md (1.4.0); docs/verification/2026-11-03-pi-150-compat.md (1.5.0); docs/verification/2026-11-14-pi-152-compat.md (1.5.2); docs/verification/2026-11-25-pi-160-compat.md (1.6.0); docs/verification/2026-11-26-compat-pi-1.6.1.md (1.6.1)
41
- pi: { label: "Pi", verified: ["1.4.0", "1.5.0", "1.5.2", "1.6.0", "1.6.1"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
41
+ // Receipts: docs/verification/2026-10-26-pi-140-compat.md (1.4.0); docs/verification/2026-11-03-pi-150-compat.md (1.5.0); docs/verification/2026-11-14-pi-152-compat.md (1.5.2); docs/verification/2026-11-25-pi-160-compat.md (1.6.0); docs/verification/2026-11-26-compat-pi-1.6.1.md (1.6.1); docs/verification/2026-12-06-compat-pi-1.8.0.md (1.8.0)
42
+ pi: { label: "Pi", verified: ["1.4.0", "1.5.0", "1.5.2", "1.6.0", "1.6.1", "1.8.0"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
42
43
  parse: out => plain(out.trim()),
43
- trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0, 1.5.0, 1.5.2, 1.6.0 and 1.6.1. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
44
- receipt: "docs/verification/2026-11-26-compat-pi-1.6.1.md" },
44
+ trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0, 1.5.0, 1.5.2, 1.6.0, 1.6.1 and 1.8.0. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
45
+ receipt: "docs/verification/2026-12-06-compat-pi-1.8.0.md" },
45
46
  // Transport receipts: docs/verification/2026-10-23-headless-claude-permissions.md; 2.1.310: docs/verification/2026-10-26-claude-implementer-2.1.310.md; 2.1.314 (transport and wrapper): docs/verification/2026-10-31-claude-implementer-2.1.314.md; 2.1.316: docs/verification/2026-10-31-claude-implementer-2.1.316.md; 2.1.318: docs/verification/2026-11-05-claude-implementer-2.1.318.md; 2.1.319: docs/verification/2026-11-06-claude-implementer-2.1.319.md; 2.1.322: docs/verification/2026-11-10-claude-implementer-2.1.322.md; 2.1.323: docs/verification/2026-11-13-claude-implementer-2.1.323.md; 2.1.328: docs/verification/2026-11-19-claude-implementer-2.1.328.md; 2.1.329: docs/verification/2026-11-20-claude-implementer-2.1.329.md; 2.1.332: docs/verification/2026-11-25-claude-implementer-2.1.332.md; 2.1.334: docs/verification/2026-12-02-claude-implementer-2.1.334.md; 2.1.337: docs/verification/2026-12-05-claude-implementer-2.1.337.md; host-wrapper receipt below repeats with them.
46
47
  "claude-implementer": { label: "Claude headless implementer", verified: ["2.1.309", "2.1.310", "2.1.314", "2.1.316", "2.1.318", "2.1.319", "2.1.322", "2.1.323", "2.1.328", "2.1.329", "2.1.332", "2.1.334", "2.1.337"], gate: "contract", probe: ["claude", "--version"],
47
48
  parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
48
49
  trustNote: "The native prompt-tool transport and host-wrapper rewrite, environment isolation and replay contract have isolated receipts. No dontAsk/bypass fallback exists; another version's permission or rewrite behavior is unverified.",
49
50
  receipt: "docs/verification/2026-12-05-claude-implementer-2.1.337.md" },
50
- // 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md; 0.167.2 model-free only, not verified until its model-backed run: docs/verification/2026-11-13-codex-01672-reviewer-isolation.md; 0.169.0 (model-free and one model-backed review): docs/verification/2026-11-14-codex-0169-reviewer-isolation.md and docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md; 0.172.0 remains unverified: docs/verification/2026-11-25-codex-0172-reviewer-isolation.md and docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md; 0.173.0 model-free only: docs/verification/2026-12-03-codex-0173-reviewer-isolation.md
51
+ // 0.163.0 receipt: docs/verification/2026-10-22-codex-reviewer-isolation.md; 0.164.0 receipt: docs/verification/2026-10-24-codex-0164-reviewer-isolation.md; 0.166.0: docs/verification/2026-10-31-codex-0166-reviewer-isolation.md; 0.167.0 model-free only, not verified until its model-backed run: docs/verification/2026-11-06-codex-0167-reviewer-isolation.md; 0.167.2 model-free only, not verified until its model-backed run: docs/verification/2026-11-13-codex-01672-reviewer-isolation.md; 0.169.0 (model-free and one model-backed review): docs/verification/2026-11-14-codex-0169-reviewer-isolation.md and docs/verification/2026-11-14-codex-0169-reviewer-tool-call.md; 0.172.0 remains unverified: docs/verification/2026-11-25-codex-0172-reviewer-isolation.md and docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md; 0.173.0 model-free and one model-backed review, failed the served-model check: docs/verification/2026-12-03-codex-0173-reviewer-isolation.md and docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md; 0.174.0 model-free pass outside the harness containment contract (disposable gate bypassed, unauthorized) and one model-backed review that produced no verdict: docs/verification/2026-12-06-codex-0174-reviewer-isolation.md and docs/verification/2026-12-06-codex-0174-reviewer-tool-call.md
51
52
  "codex-review": { label: "Codex reviewer (codex-cli)", verified: ["0.146.0", "0.163.0", "0.164.0", "0.166.0", "0.169.0"], gate: "isolation", probe: ["codex", "--version"], config: "codex_bin",
52
53
  parse: out => plain(out.trim().replace(/^codex-cli /, "")),
53
54
  trustNote: "Every launch still proves the MCP inventory, Apps/plugins/hooks disabled, sandbox read/write denial and the binary fence; a failed leg still refuses. Trust covers only the source-level claims those probes cannot see (docs/verification/2026-10-19-reviewer-isolation.md).",
@@ -64,8 +65,8 @@ export const COMPAT = {
64
65
  parse: out => plain(out.trim()),
65
66
  trustNote: "Only 2.5.2 has a live receipt for turn.prompt/turn.ended/prompt completion rows, background task inventory and launcher-bound plugin hooks. Another version keeps completion receipts disabled.",
66
67
  receipt: "docs/verification/2026-11-08-kimi-tui-completion-1282.md" },
67
- // #1808 T2: the native capability listings (src/adapters/native-capabilities.ts). Probed on one exact version each by docs/verification/2026-10-30-445-capability-probes.md (C0); the shape record is docs/verification/2026-11-30-capability-listing-shape-1808.md.
68
- // No `line` yet: the shape of each listing is shown to hold only for the probed version (Codex's schema comparison to 0.169.0 does not cover these listings), so another version lists nothing unless the person trusts it.
68
+ // #1808 T2: C0 (docs/verification/2026-10-30-445-capability-probes.md) verified one exact listing version per CLI.
69
+ // Codex 0.174.0 adds a hosted live skills/list receipt. Listing admission remains exact-version, with no line.
69
70
  "kimi-capabilities": { label: "Kimi capability listing", verified: ["2.3.2"], gate: "contract", probe: ["kimi", "--version"],
70
71
  parse: out => plain(out.trim()),
71
72
  trustNote: "Only the available_commands_update shape of 2.3.2 was probed (fixture model, no account). Another version lists nothing unless you trust it. An untested listing of this version may miss or misclassify entries. A capability you shared earlier can be invoked again without a new share if its digest still matches, because the digest covers neither the CLI version nor the skill content.",
@@ -74,10 +75,10 @@ export const COMPAT = {
74
75
  parse: out => plain(out.trim()),
75
76
  trustNote: "Only the available_commands_update shape and the _meta.source field of 0.26.1 were probed (fixture auth, no account). Another version lists nothing unless you trust it. An untested listing of this version may miss or misclassify entries. A capability you shared earlier can be invoked again without a new share if its digest still matches, because the digest covers neither the CLI version nor the skill content.",
76
77
  receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
77
- "codex-capabilities": { label: "Codex capability listing", verified: ["0.166.0"], gate: "contract", probe: ["codex", "--version"], config: "codex_bin",
78
+ "codex-capabilities": { label: "Codex capability listing", verified: ["0.166.0", "0.174.0"], gate: "contract", probe: ["codex", "--version"], config: "codex_bin",
78
79
  parse: out => plain(out.trim().replace(/^codex-cli /, "")),
79
- trustNote: "Only the skills/list answer of 0.166.0 was probed live (no account). Another version lists nothing unless you trust it. An untested listing of this version may miss or misclassify entries. A capability you shared earlier can be invoked again without a new share if its digest still matches, because the digest covers neither the CLI version nor the skill content.",
80
- receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
80
+ trustNote: "Only the skills/list answers of 0.166.0 and 0.174.0 were probed live (no account). Another version lists nothing unless you trust it. An untested listing of this version may miss or misclassify entries. A capability you shared earlier can be invoked again without a new share if its digest still matches, because the digest covers neither the CLI version nor the skill content.",
81
+ receipt: "docs/verification/2026-12-06-compat-codex-capabilities-0.174.0.md" },
81
82
  // #1808 T3: surfaces the hub only WATCHES. An `observe` entry never refuses and no launch, start or restore path reads it; the daily watch, `ahub agents` and `ahub doctor` report it.
82
83
  // Receipt: docs/verification/2026-10-30-445-capability-probes.md (C0 `initialize` of Codex 0.166.0 and Kimi 2.3.2). The legs run a handshake without a model and were tested only with fake executables.
83
84
  "codex-appserver": { label: "Codex app-server handshake", verified: ["0.166.0"], gate: "observe", probe: ["codex", "--version"], config: "codex_bin",
@@ -137,13 +138,18 @@ if (referenceOnlyBad.length) throw new Error(`COMPAT referenceOnly needs gate ob
137
138
  export const KIMI_SETTER_VERSION = "2.5.2";
138
139
  /** The Claude versions whose transcript record shape the instruction receipt was probed on. */
139
140
  export const INSTRUCTION_PROBED_VERSIONS: readonly string[] = Object.freeze(["2.1.328", "2.1.329"]);
140
- type CommandConfig = { codex_bin: string; jcode_cmd: string[]; qwen_cmd: string[]; pi?: { cmd: string[] } };
141
+ export function piCommand(explicit?: readonly string[]): string[] {
142
+ if (explicit?.length) return [...explicit];
143
+ const pin = readPiPin(COMPAT.pi.verified);
144
+ return pin ? [pin.command] : ["pi"];
145
+ }
146
+ type CommandConfig = { codex_bin: string; jcode_cmd: string[]; qwen_cmd: string[]; pi?: { cmd?: string[] } };
141
147
  /** The configured executables the native gates use; the rest probe their PATH default. */
142
148
  export function configuredCommands(config: CommandConfig): Partial<Record<CompatId, readonly string[]>> {
143
149
  const out: Partial<Record<CompatId, readonly string[]>> = {};
144
150
  for (const [id, policy] of Object.entries(COMPAT) as [CompatId, CompatPolicy][]) {
145
151
  if (!policy.config) continue;
146
- const value = policy.config === "pi.cmd" ? config.pi?.cmd : config[policy.config];
152
+ const value = policy.config === "pi.cmd" ? config.pi && piCommand(config.pi.cmd) : config[policy.config];
147
153
  if (value !== undefined) out[id] = typeof value === "string" ? [value] : value;
148
154
  }
149
155
  return out;
@@ -156,6 +162,10 @@ export type CompatVerdict =
156
162
 
157
163
  const parts = (v: string) => /^(\d+)\.(\d+)\.(\d+)$/.exec(v)?.slice(1).map(Number);
158
164
  const compare = (a: number[], b: number[]) => a[0]! - b[0]! || a[1]! - b[1]! || a[2]! - b[2]!;
165
+ /** Receipt publication appends entries, including receipts for older versions. */
166
+ export function newestVerifiedPiVersion(): string {
167
+ return COMPAT.pi.verified.reduce((newest, version) => compare(parts(version)!, parts(newest)!) > 0 ? version : newest);
168
+ }
159
169
  function inLine(version: string, line?: { min: string; below: string }): boolean {
160
170
  const v = parts(version);
161
171
  return !!line && !!v && compare(v, parts(line.min)!) >= 0 && compare(v, parts(line.below)!) < 0;
@@ -1,3 +1,4 @@
1
+ import { piCommand } from "../compat.ts";
1
2
  import { join, resolve } from "node:path";
2
3
  import type { Launch } from "../../cli/launch.ts";
3
4
  import { REDACTED, UNRESOLVED, nativeCommand, previewState, finishPreview, type NativePreviewContext } from "./native-cli-preview-common.ts";
@@ -20,7 +21,7 @@ export function previewPi(ctx: NativePreviewContext) {
20
21
  if (args.includes("--replace-session")) unresolved.push({ field: "session replacement", reason: "requires a person, a validated managed file and an offline settled owner at runtime; preview changes nothing" });
21
22
  const models = relayModelIds({ enableHubAuto: true, mlx: config.mlx.enabled === false ? undefined : config.mlx, mlxAlias: "mlx/fast", allowedDGXmodels: { "dgx/coding": config.pi.dgx_coding, "dgx/fast": config.pi.dgx_fast } });
22
23
  const pi = buildPiLaunch({
23
- stateDir, cmd: nativeCommand(config.pi.cmd, ["pi"]), mode: mode as "headless" | "tui", backend: backend as "auto" | "dgx" | "mlx",
24
+ stateDir, cmd: nativeCommand(piCommand(config.pi.cmd), ["pi"]), mode: mode as "headless" | "tui", backend: backend as "auto" | "dgx" | "mlx",
24
25
  ...(value("--model") ? { model: REDACTED } : {}),
25
26
  ...(value("--session-id") ? { sessionId: REDACTED } : {}),
26
27
  ...(value("--session-file") ? { sessionFile: REDACTED } : {}),
@@ -8,7 +8,7 @@ export function nativeConfigurationDefaults(ctx: { home: string; env: Readonly<R
8
8
  return {
9
9
  commands: { kimi_cmd: ["kimi", "acp"], qwen_cmd: ["qwen", "--acp"], jcode_cmd: ["jcode"], jcode_home: ctx.env.JCODE_HOME ?? join(ctx.home, ".jcode"), jcode_provider_profile: "" },
10
10
  proxy: { codex_bin: "codex" },
11
- rpc: { pi: { enabled: false, auto_start: false, cmd: ["pi"], backend: "auto" as const, dgx_coding: "coding", dgx_fast: "fast", max_steps: 100, max_continuations: 2 } },
11
+ rpc: { pi: { enabled: false, auto_start: false, backend: "auto" as const, dgx_coding: "coding", dgx_fast: "fast", max_steps: 100, max_continuations: 2 } },
12
12
  sandbox: { local: { deny: [] as string[], bash_network: false, network_allow: ctx.networkAllow, max_steps: 30, read_allow: [] as string[], doc_read: false, web_fetch: { allow: [] as string[] } } },
13
13
  };
14
14
  }
@@ -1,3 +1,4 @@
1
+ import { piCommand } from "../compat.ts";
1
2
  import { ACP_ACTIVITY } from "./native-activity.ts";
2
3
  import type { CreateContext, DaemonEngine, DaemonPorts } from "../registry-types.ts";
3
4
  import type { PeerAdapter } from "../../hub/peers.ts";
@@ -38,9 +39,11 @@ export function createPi(ctx: CreateContext): PeerAdapter {
38
39
  const { PiPeer, PiVersionRefusal, piVersionAsync } = require("../pi.ts") as typeof import("../pi.ts");
39
40
  const options = ctx.daemon.pi;
40
41
  return new PiPeer(ctx.instance, options, async () => {
41
- const verdict = await piVersionAsync(options.cmd ?? ["pi"], options.cwd);
42
+ const command = piCommand(options.cmd);
43
+ const verdict = await piVersionAsync(command, options.cwd);
42
44
  if (!verdict.ok) throw new PiVersionRefusal(verdict);
43
45
  if (verdict.note) options.log?.(verdict.note);
46
+ return command;
44
47
  });
45
48
  }
46
49
 
@@ -247,7 +247,7 @@ export class LocalPeer extends BasePeer {
247
247
  ) {
248
248
  super(id, opts.watchdogMs);
249
249
  this.routes = new HubRouteRuntime({
250
- execute: async (model, messages, judge, signal, maxTokens) => {
250
+ execute: async (model, messages, judge, signal, maxTokens, decisionChoice) => {
251
251
  if (signal.aborted) throw new Error("turn cancelled before model request");
252
252
  const envs = this.routeEnvs, pii = this.routePii, generation = this.turn, task = this.routeTask;
253
253
  await this.requireBudget(envs, "model_calls");
@@ -255,7 +255,7 @@ export class LocalPeer extends BasePeer {
255
255
  if (signal.aborted) throw new Error("turn cancelled before model request");
256
256
  const tools = judge ? undefined : [...this.toolSchemas(), ...(this.opts.taskTool ? [...profileTaskTools(this.opts.profile, this.opts.sdlcStages, this.opts.sdlcCriteria, this.opts.sdlcAudit, this.opts.sdlcSurvey, this.opts.taskWait).filter(tool => tool.name !== "hub_delivery_retry"), ...CONDUCTOR_TOOLS].concat(SESSION_TITLE_TOOL).map(asFunction) : [])];
257
257
  this.releaseObserverInput(this.currentObserverInputContext, envs);
258
- const result = await this.opts.omni.chat({ model, messages, ...(tools ? { tools } : {}), ...(judge ? { max_tokens: maxTokens ?? 2048 } : {}) }, { signal, ...(pii ? { onCampusOnly: true } : {}) });
258
+ const result = await this.opts.omni.chat({ model, messages, ...(tools ? { tools } : {}), ...(judge ? { max_tokens: maxTokens ?? 2048 } : {}) }, { signal, ...(pii ? { onCampusOnly: true } : {}), decisionChoice });
259
259
  this.recordUsage(result, model, task);
260
260
  if (generation !== this.turn) throw new Error("route belongs to an ended turn");
261
261
  this.lastServedBy = `hub ${model} (provider ${result.provider ?? "?"})`;
@@ -265,7 +265,7 @@ export class LocalPeer extends BasePeer {
265
265
  decisionContext: () => this.decisionContext(),
266
266
  publicDecisionText: text => this.opts.routeEvidencePublic?.(text) === true,
267
267
  admitDecision: () => this.requireBudget(this.routeEnvs, "model_calls"),
268
- onDecisionIssue: reason => this.opts.log?.(`decision route observation ${reason}; using the original heuristic; check adec serve and routing.toml policy settings, then retry`),
268
+ onDecisionIssue: reason => this.opts.log?.(`decision route ${reason}; using the current route; check adec serve and routing.toml`),
269
269
  staySwitch: () => this.opts.staySwitch?.(),
270
270
  onRoute: event => this.opts.onRoute?.(event),
271
271
  onAdvisor: event => this.opts.onAdvisor?.(event),
@@ -19,6 +19,7 @@ import { QuestionWaitDetached } from "../hub/question-detach.ts";
19
19
  import type { StartForm } from "./registry-types.ts";
20
20
  import { stateModelId } from "./pi-state-model.ts";
21
21
  import type { ModelObservation } from "../hub/events.ts";
22
+ import { piExitReason } from "../hub/pi-exit-policy.ts";
22
23
 
23
24
  export interface PiModelDescriptor { id: string; name?: string; contextWindow?: number; maxTokens?: number; reasoning?: boolean; }
24
25
  export interface PiToolSchema { name: string; description?: string; parameters: Record<string, unknown>; }
@@ -32,6 +33,9 @@ export interface PiExit {
32
33
  turnActive: boolean;
33
34
  toolActive: boolean;
34
35
  lastToolName?: string;
36
+ /** #1967: the tail of the owner's stderr, the last native event type it reported and the provider a model_select named, each bounded and free of task text. */
37
+ stderrTail?: string;
38
+ modelProvider?: string;
35
39
  }
36
40
  export interface PiToolContext { userBash: boolean; isCurrent: () => boolean; onApproval: (provenance: ApprovalProvenance) => void; }
37
41
  export interface PiToolResult { text: string; exitCode: number | null; }
@@ -254,7 +258,7 @@ export class PiPeer extends BasePeer {
254
258
  private tuiWaiters: Array<{ resolve: (command: Record<string, unknown> | undefined) => void; timer: ReturnType<typeof setTimeout> }> = [];
255
259
 
256
260
  /** The fixed production factory supplies preflight separately, preserving transport option identity. */
257
- constructor(id: PeerId, private readonly opts: PiOptions, private readonly preflight?: () => Promise<void>) { super(id, opts.watchdogMs); this.baselineRequestedModel = opts.model ?? ""; }
261
+ constructor(id: PeerId, private readonly opts: PiOptions, private readonly preflight?: () => Promise<string[]>) { super(id, opts.watchdogMs); this.baselineRequestedModel = opts.model ?? ""; }
258
262
  get tuiLaunch(): PiTuiLaunch | undefined { return this._tuiLaunch; }
259
263
  get pendingResume(): { sessionId?: string; sessionFile?: string } {
260
264
  if (this.canReuseVerifiedEmptyResume()) return { sessionId: this.verifiedEmptyResume!.sessionId };
@@ -508,7 +512,7 @@ export class PiPeer extends BasePeer {
508
512
  }
509
513
 
510
514
  private async startImpl(): Promise<void> {
511
- if (this.preflight) await this.preflight();
515
+ const cmd = this.preflight ? await this.preflight() : this.opts.cmd;
512
516
  this.terminalOwnerObservation = undefined;
513
517
  this.stopping = false;
514
518
  this.observedTitle = undefined; this.titleRevision = -1; this.nativeTitleEpoch = undefined; this.onDoing?.("reset");
@@ -574,14 +578,14 @@ export class PiPeer extends BasePeer {
574
578
  const extension = resolve(join(import.meta.dir, "../pi/extension.ts"));
575
579
  const inherited: NodeJS.ProcessEnv = {};
576
580
  for (const key of ["PATH", "HOME", "USER", "SHELL", "TMPDIR", "TERM", "TERM_PROGRAM", "LANG", "LC_ALL", "LC_CTYPE", "NO_COLOR", "CODEX_HOME"]) if (process.env[key]) inherited[key] = process.env[key];
577
- this._tuiLaunch = buildPiLaunch({ ...this.opts, instance: this.id }, inherited, extension, bridge.port!, token);
581
+ this._tuiLaunch = buildPiLaunch({ ...this.opts, cmd, instance: this.id }, inherited, extension, bridge.port!, token);
578
582
  const { cmd: bin, args, env } = this._tuiLaunch;
579
583
  if (this.opts.mode === "tui") { return; }
580
584
  // Its own process group, stopped as a whole (#115, as Codex's in #113).
581
585
  this.proc = spawn(bin, args, { cwd: this.opts.cwd, env, stdio: ["pipe", "pipe", "pipe"], detached: true });
582
586
  trackGroup(this.proc);
583
587
  this.proc.stdout.on("data", (chunk) => this.onOutput(String(chunk)));
584
- this.proc.stderr.on("data", (chunk) => this.opts.log?.(`[${this.id}] ${String(chunk).trimEnd()}`));
588
+ this.proc.stderr.on("data", (chunk) => { this.noteStderr(String(chunk)); this.opts.log?.(`[${this.id}] ${String(chunk).trimEnd()}`); });
585
589
  const proc = this.proc;
586
590
  proc.on("error", (error) => {
587
591
  const exit = this.exitMetadata("spawn_error");
@@ -591,7 +595,15 @@ export class PiPeer extends BasePeer {
591
595
  proc.on("exit", (code, signal) => {
592
596
  const exit = { ...(this.shutdownExit ?? this.exitMetadata("process_exit")), code, signal };
593
597
  this.fail(new Error(`pi exited with ${signal ? `signal ${signal}` : `code ${code}`}`));
594
- this.reportExit(exit);
598
+ // #1967: stderr the process wrote just before it died can still be in the pipe; report once it is drained, or after a short bound.
599
+ let reported = false;
600
+ const report = () => {
601
+ if (reported) return; reported = true;
602
+ const tail = this.stderrTail.trim();
603
+ this.reportExit(tail ? { ...exit, stderrTail: tail } : exit);
604
+ };
605
+ if (proc.stderr.destroyed || proc.stderr.readableEnded) report();
606
+ else { proc.stderr.once("close", report); setTimeout(report, 250).unref?.(); }
595
607
  });
596
608
  const titleRevisionBefore = this.titleRevision, titleEpochBefore = this.titleEpoch;
597
609
  const state = await this.waitRpc("get_state", 15_000);
@@ -922,6 +934,9 @@ export class PiPeer extends BasePeer {
922
934
  }
923
935
 
924
936
  private handleBridgeEvent(event: any): void {
937
+ // #1967 T1: the exit line names the last native event and the provider a model_select asked for; neither carries task text.
938
+ if (typeof event?.type === "string" && /^[a-z_]{1,48}$/.test(event.type)) this.lastNativeEvent = event.type;
939
+ if (event?.type === "model_select_foreign" && typeof event.provider === "string" && /^[A-Za-z0-9_.:/-]{1,64}$/.test(event.provider)) this.foreignProvider = event.provider;
925
940
  if (this.fencedPrompt && this.opts.mode === "tui" && !this.rosterUnownedRun && ["agent_start", "agent_end", "agent_settled"].includes(event.type)
926
941
  && typeof event.promptId === "string" && event.promptId !== this.hubPromptId) return;
927
942
  if (this.fencedPrompt && this.opts.mode === "tui" && (this.activeEnvs.length > 0 || this.pendingPromptId || this.hubPromptId) && !this.rosterDetached && !this.rosterUnownedRun && !this.stopping && ["agent_start", "agent_end", "agent_settled"].includes(event.type)) {
@@ -1120,16 +1135,20 @@ export class PiPeer extends BasePeer {
1120
1135
  try { return await Promise.race([this.sendRpc({ type: command }), new Promise<never>((_, reject) => { timer = setTimeout(() => reject(new Error(`Pi ${command} timed out`)), timeout); })]); }
1121
1136
  finally { clearTimeout(timer); }
1122
1137
  }
1138
+ private stderrTail = ""; private lastNativeEvent: string | undefined; private foreignProvider: string | undefined;
1139
+ private noteStderr(chunk: string): void { this.stderrTail = `${this.stderrTail}${chunk}`.replace(/\s+/g, " ").slice(-300); }
1123
1140
  private exitMetadata(cause: PiExit["cause"]): PiExit {
1124
1141
  return { cause, code: null, signal: null, expected: this.stopping, started: this.started,
1125
1142
  turnActive: this.agentRunning || this.activeEnvs.length > 0, toolActive: this.activeTools > 0,
1126
- ...(this.lastToolName ? { lastToolName: this.lastToolName } : {}) };
1143
+ ...(this.lastToolName ? { lastToolName: this.lastToolName } : {}),
1144
+ ...(this.stderrTail.trim() ? { stderrTail: this.stderrTail.trim() } : {}),
1145
+ ...(this.foreignProvider ? { modelProvider: this.foreignProvider } : {}) };
1127
1146
  }
1128
1147
 
1129
1148
  private reportExit(exit: PiExit): void {
1130
1149
  if (this.exitReported) return;
1131
1150
  this.exitReported = true;
1132
- const line = `[${this.id}] Pi exit: cause=${exit.cause} code=${exit.code ?? "unknown"} signal=${exit.signal ?? "unknown"} expected=${exit.expected} started=${exit.started} turnActive=${exit.turnActive} toolActive=${exit.toolActive} lastTool=${exit.lastToolName ?? "none"}`;
1151
+ const line = `[${this.id}] Pi exit: cause=${exit.cause} code=${exit.code ?? "unknown"} signal=${exit.signal ?? "unknown"} expected=${exit.expected} started=${exit.started} turnActive=${exit.turnActive} toolActive=${exit.toolActive} lastTool=${exit.lastToolName ?? "none"} reason=${piExitReason(exit)} lastEvent=${this.lastNativeEvent ?? "none"}${exit.modelProvider ? ` provider=${exit.modelProvider}` : ""}${exit.stderrTail ? ` stderr=${JSON.stringify(exit.stderrTail.slice(-200))}` : ""}`;
1133
1152
  try { this.opts.log?.(line); } catch { /* reporting must not prevent owner settlement */ }
1134
1153
  try { this.opts.onExit?.(exit); } catch { /* the owner is already offline */ }
1135
1154
  }
@@ -0,0 +1,27 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import { join } from "node:path";
3
+
4
+ const CONTRACT_VERSION = "1";
5
+ const PROBE_TIMEOUT_MS = 500;
6
+ const PROBE_OUTPUT_BYTES = 64;
7
+ const relayArgs = ["mcp-shim", "ahub"];
8
+ const asuite = Bun.which("asuite", { PATH: process.env.PATH ?? "" });
9
+
10
+ if (asuite) {
11
+ try {
12
+ const probe = spawnSync(asuite, [...relayArgs, "--contract"], {
13
+ encoding: "utf8",
14
+ stdio: ["ignore", "pipe", "ignore"],
15
+ timeout: PROBE_TIMEOUT_MS,
16
+ maxBuffer: PROBE_OUTPUT_BYTES,
17
+ killSignal: "SIGKILL",
18
+ });
19
+ if (!probe.error && probe.status === 0 && probe.stdout.trim() === CONTRACT_VERSION) {
20
+ process.execve!(asuite, [asuite, ...relayArgs]);
21
+ }
22
+ } catch {
23
+ // An exec can fail even after the probe succeeded, for example during an asuite update.
24
+ }
25
+ }
26
+
27
+ process.execve!(process.execPath, [process.execPath, "run", join(import.meta.dir, "server.js")]);
package/src/cli/agents.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  import { spawnSync } from "node:child_process";
2
- import { assessVersion, COMPAT, describe, isCompatId, readTrust, trustFile, writeTrust, type CompatId, type CompatVerdict } from "../adapters/compat.ts";
2
+ import { assessVersion, COMPAT, describe, isCompatId, newestVerifiedPiVersion, readTrust, trustFile, writeTrust, type CompatId, type CompatVerdict } from "../adapters/compat.ts";
3
3
  import { childEnv } from "../hub/child-process.ts";
4
4
  import { withoutOrcaEnv } from "../hub/orca-env.ts";
5
5
  import { Report, asciiMarkers, resolveColor, streamEnv } from "./console-state.ts";
6
6
  import { outputWidth } from "./output.ts";
7
7
  import { renderAgents } from "./agents-output.ts";
8
+ import { readPiPin } from "../pi/pin.ts";
8
9
 
9
10
  /** #691: what `ahub agents` and `ahub doctor` show for each gated native CLI. */
10
11
  export interface AgentVersionRow { id: CompatId; executable?: string; verdict: CompatVerdict; policy: string }
@@ -24,15 +25,26 @@ function probeRow(id: CompatId, executable: string | undefined, stdout: string |
24
25
  return { id, executable, verdict: assessVersion(id, stdout === undefined ? undefined : COMPAT[id].parse(stdout), trusted), policy: describe(id) };
25
26
  }
26
27
 
28
+ function syncVersion(id: CompatId, commands: Partial<Record<CompatId, readonly string[]>>, trusted: ReturnType<typeof readTrust>, env = process.env): AgentVersionRow {
29
+ const target = probeTarget(id, commands);
30
+ if (!target) return probeRow(id, undefined, undefined, trusted);
31
+ const result = spawnSync(target.executable, target.args, { encoding: "utf8", timeout: 10_000, maxBuffer: 64 * 1024, env: withoutOrcaEnv(childEnv({ ...env, ...PROBE_ENV })) });
32
+ return probeRow(id, target.executable, result.status === 0 ? result.stdout ?? "" : undefined, trusted);
33
+ }
34
+
27
35
  /** `commands` carries the configured argv (including pi.cmd); the probe words follow it. */
28
36
  export function agentVersions(commands: Partial<Record<CompatId, readonly string[]>> = {}): AgentVersionRow[] {
29
37
  const trusted = readTrust();
30
- return (Object.keys(COMPAT) as CompatId[]).map(id => {
31
- const target = probeTarget(id, commands);
32
- if (!target) return probeRow(id, undefined, undefined, trusted);
33
- const result = spawnSync(target.executable, target.args, { encoding: "utf8", timeout: 10_000, maxBuffer: 64 * 1024, env: withoutOrcaEnv(childEnv({ ...process.env, ...PROBE_ENV })) });
34
- return probeRow(id, target.executable, result.status === 0 ? result.stdout ?? "" : undefined, trusted);
35
- });
38
+ return (Object.keys(COMPAT) as CompatId[]).map(id => syncVersion(id, commands, trusted));
39
+ }
40
+
41
+ export function piInstallReport(probePath = true): { detail: string; command?: string } {
42
+ const { HOME, PATH } = process.env;
43
+ const person = probePath ? syncVersion("pi", {}, [], { HOME, PATH }).verdict.version : undefined;
44
+ const pinned = readPiPin(COMPAT.pi.verified)?.version;
45
+ const latest = newestVerifiedPiVersion();
46
+ return { detail: `PATH Pi ${person ?? "unknown"}, hub-pinned Pi ${pinned ?? "none"}, newest verified ${latest}`,
47
+ ...(pinned !== latest ? { command: `ahub agents install pi ${latest}` } : {}) };
36
48
  }
37
49
 
38
50
  const PROBE_OUTPUT_CAP = 64 * 1024;
@@ -106,7 +118,7 @@ export function runAgents(args: string[], commands: Partial<Record<CompatId, rea
106
118
  print(receipt);
107
119
  return;
108
120
  }
109
- if (sub !== undefined) fail("usage: ahub agents [--json] | ahub agents --latest [--json] | ahub agents trust <id> <version> [--revoke] | ahub agents presets [--json] | ahub agents add <preset> [--as <kind>] [--pull]");
121
+ if (sub !== undefined) fail("usage: ahub agents [--json] | ahub agents --latest [--json] | ahub agents install pi [<version>] | ahub agents trust <id> <version> [--revoke] | ahub agents presets [--json] | ahub agents add <preset> [--as <kind>] [--pull]");
110
122
  const rows = agentVersions(commands);
111
123
  if (args.includes("--json")) return console.log(JSON.stringify(rows.map(row => ({ id: row.id, executable: row.executable ?? null, ...row.verdict, policy: row.policy })), null, 2));
112
124
  print(new Report(columns, ascii).append(renderAgents(rows, columns, ascii)));
@@ -1,7 +1,8 @@
1
1
  import { runAgents } from "../agents.ts";
2
+ import { renderLifecycleReceipt } from "../reset-output.ts";
2
3
  import { runAgentsLatest } from "../agents-latest.ts";
3
4
  import { runAgentsAdd, runAgentsPresets } from "../agents-presets.ts";
4
- import { configuredCommands } from "../../adapters/compat.ts";
5
+ import { COMPAT, configuredCommands, newestVerifiedPiVersion } from "../../adapters/compat.ts";
5
6
  import { loadConfig } from "../../hub/config.ts";
6
7
  import type { CommandContext } from "../command-context.ts";
7
8
 
@@ -11,8 +12,24 @@ export function run(context: CommandContext) {
11
12
  // #1809 T1: both forms are person-only through src/cli/identity.ts (any `agents` argument but --json); neither loads the project config.
12
13
  if (args[0] === "presets") return runAgentsPresets(args.slice(1), fail);
13
14
  if (args[0] === "add") return runAgentsAdd(args.slice(1), cwd, fail);
15
+ if (args[0] === "install") return installPi(args.slice(1), context);
14
16
  const commands = configuredCommands(loadConfig(cwd));
15
17
  // #1808 T5: the one network read, person-run (src/cli/identity.ts keeps an agent shell out of every `agents` form but a plain listing).
16
18
  if (args.includes("--latest")) return runAgentsLatest(args, commands, fail);
17
19
  return runAgents(args, commands, fail);
18
20
  }
21
+
22
+ async function installPi(args: string[], { fail, printOutput }: CommandContext): Promise<void> {
23
+ const [kind, requested, ...rest] = args;
24
+ const version = requested ?? newestVerifiedPiVersion();
25
+ if (kind !== COMPAT.pi.probe[0] || rest.length || !(COMPAT.pi.verified as readonly string[]).includes(version)) {
26
+ fail(`usage: ahub agents install pi [<verified-version>] (verified: ${COMPAT.pi.verified.join(", ")})`);
27
+ }
28
+ try {
29
+ const { installPinnedPi } = await import("../../pi/install.ts");
30
+ const pinned = await installPinnedPi(version);
31
+ printOutput(renderLifecycleReceipt({ title: "Pi install", lines: [`Pi ${pinned.version} pinned at ${pinned.command}`] }), false);
32
+ } catch {
33
+ fail(`Pi ${version} install could not be verified. Check the registry and matching install files, then retry with ahub agents install pi ${version}.`);
34
+ }
35
+ }
@@ -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 result = classListRow(implementers, loadRouting(cwd), file, existsSync(file));
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 aliases = new Set([routing.local.fixed_model, ...Object.values(routing.classes).flatMap(policy => policy.fixed_model ? [policy.fixed_model] : []),
219
- ...Object.values(routing.hub_routes ?? {}).flatMap(route => [route.efficient ?? "fast", route.capable ?? "coding", ...(route.judge ? [route.judge] : [])])]);
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`);
@@ -1,23 +1,31 @@
1
1
  import { builtinDeclarationOf } from "../../adapters/declaration-catalog.ts";
2
+ import { join } from "node:path";
2
3
  import { projectChildEnv } from "../../hub/project.ts";
3
4
  import type { CommandContext } from "../command-context.ts";
4
- import { shellQuote } from "../shell-quote.ts";
5
+ import { LAUNCH_LINE_MIN_DAEMON, buildLaunchLineCommand, daemonMeetsContract, parseLaunchLineArgs, resolveLaunchExecutable } from "../launch-line-plan.ts";
5
6
 
6
7
  export async function run({ args, caller, cwd, stateDir, connect, fail, outputOptions }: CommandContext): Promise<void> {
7
- const options = outputOptions();
8
- const [kind, format] = args;
9
- if (!options.json || args.length !== 2 || format !== "--json") return fail("usage: ahub launch-line <kind> --json");
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;
10
14
  if (caller.role !== "console") return fail("launch-line is person-only; run ahub launch-line <kind> --json from your terminal");
11
15
  const definition = kind && builtinDeclarationOf(kind);
12
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`);
13
19
  const hub = await connect();
14
20
  try {
15
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`);
16
24
  if (status?.cwd !== cwd) return fail("project status is unavailable; inspect ahub status before requesting a launch line");
17
25
  if (status.peers?.[kind]?.rostered === false) return fail(`${kind} is off roster; check ahub status before retrying`);
18
26
  // The normal terminal entry applies the selected home, permissions and native handshakes when Orca actually launches it.
19
27
  if (options.json) console.log(JSON.stringify({
20
- command: `ahub --project ${shellQuote(cwd)} ${kind}`,
28
+ command: buildLaunchLineCommand(cwd, kind, executable, request.launchArgs),
21
29
  env: projectChildEnv({ root: cwd, stateDir }),
22
30
  }));
23
31
  } finally { hub.close(); }
package/src/cli/help.ts CHANGED
@@ -73,13 +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", "person: print a Claude or Codex terminal join command and project environment for a running hub; start nothing"],
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"],
77
77
  ["ahub logs [-f]", "person: last 100 hub.log lines (-f starts at 10); conductor: bounded public lines and follow while authority remains"],
78
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"],
79
79
  ["ahub doctor --stale-anchors [--json]", "read-only bounded report of public memory symbol anchors at current HEAD; private or unavailable evidence stays unknown"],
80
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"],
81
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"],
82
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"],
83
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)"],
84
85
  ["ahub agents trust <id> <version> [--revoke]", "accept an untested agent CLI version on this machine (person only; runtime proofs still run)"],
85
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)"],
@@ -163,7 +164,7 @@ const SECTIONS: [string, [usage: string, description: string][]][] = [
163
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"],
164
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"],
165
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"],
166
- ["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 list nothing), 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"],
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"],
167
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"],
168
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"],
169
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"],
@@ -414,6 +415,7 @@ export const FLAG_DESCRIPTIONS: Readonly<Record<string, string>> = {
414
415
  // setup, init and sdlc
415
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",
416
417
  "--undo": "remove only the hub's unmodified skill trees",
418
+ "--exec": "executable to print: absolute path or self",
417
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",
418
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",
419
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",