@staix/agent-hub 0.46.1 → 0.47.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 (130) hide show
  1. package/CHANGELOG.md +79 -0
  2. package/README.md +8 -4
  3. package/docs/adding-an-ai-tool.md +20 -4
  4. package/docs/agent-notes/adapters.md +3 -3
  5. package/docs/agent-notes/benchmarks.md +7 -1
  6. package/docs/agent-notes/daemon.md +5 -4
  7. package/docs/agent-notes/tasks.md +4 -2
  8. package/docs/agent-notes/tests.md +3 -0
  9. package/docs/contracts/companion-cli-v1.json +3 -0
  10. package/docs/data-policy.md +9 -0
  11. package/docs/design/adapters.md +14 -0
  12. package/docs/design/cli-output-inventory.md +362 -0
  13. package/docs/design/cli-output.md +42 -1
  14. package/docs/design/execution-reference.md +5 -2
  15. package/docs/design/guidance-probes.md +2 -2
  16. package/docs/design/refusal-inventory.md +26 -0
  17. package/docs/design/roadmap.md +4 -0
  18. package/docs/design/task-board.md +17 -1
  19. package/docs/dogfood.md +26 -10
  20. package/docs/events.md +9 -0
  21. package/docs/friction.md +46 -0
  22. package/docs/memory.md +35 -3
  23. package/docs/operations.md +63 -15
  24. package/docs/profiles.md +1 -0
  25. package/docs/quickstart.md +8 -2
  26. package/docs/roles.md +6 -0
  27. package/docs/sdlc.md +44 -1
  28. package/docs/security.md +16 -7
  29. package/docs/specs/2026-09-19-agent-hub-design.md +17 -0
  30. package/docs/specs/2026-09-19-multi-project-design.md +7 -1
  31. package/docs/verification/2026-11-25-agy-1.5.16.md +31 -0
  32. package/docs/verification/2026-11-25-claude-implementer-2.1.332.md +47 -0
  33. package/docs/verification/2026-11-25-codex-0172-reviewer-isolation.md +47 -0
  34. package/docs/verification/2026-11-25-kimi-272-reviewer-compat.md +38 -0
  35. package/docs/verification/2026-11-25-kimi-tui-272.md +14 -0
  36. package/docs/verification/2026-11-25-pi-160-compat.md +40 -0
  37. package/docs/verification/2026-11-26-0.47.0.md +43 -0
  38. package/docs/verification/2026-11-26-codex-0172-reviewer-tool-call.md +29 -0
  39. package/docs/verification/dogfood/2026-11-24.md +2829 -0
  40. package/docs/verification/pi-160-model-free.ts +57 -0
  41. package/docs/verification/pi-160-native.mjs +21 -0
  42. package/docs/verified.json +43 -31
  43. package/package.json +2 -2
  44. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  45. package/plugins/agent-hub/kimi-hook.js +579 -126
  46. package/plugins/agent-hub/server.js +668 -138
  47. package/src/adapters/acp.ts +5 -0
  48. package/src/adapters/channel-peer.ts +7 -0
  49. package/src/adapters/claude-print-child.ts +27 -5
  50. package/src/adapters/codex-appserver.ts +9 -0
  51. package/src/adapters/compat.ts +12 -11
  52. package/src/adapters/configured-acp.ts +45 -2
  53. package/src/adapters/configured-print.ts +163 -0
  54. package/src/adapters/conformance/index.ts +1 -0
  55. package/src/adapters/conformance/print.ts +57 -0
  56. package/src/adapters/definitions/native-activity.ts +57 -0
  57. package/src/adapters/definitions/native-factories.ts +4 -2
  58. package/src/adapters/jcode.ts +10 -2
  59. package/src/adapters/local-worker.ts +2 -0
  60. package/src/adapters/registry-types.ts +5 -3
  61. package/src/adapters/role-eligibility.ts +5 -0
  62. package/src/cli/bench.ts +2 -1
  63. package/src/cli/broker.ts +2 -1
  64. package/src/cli/capabilities-output.ts +10 -14
  65. package/src/cli/configured-acp-entry.ts +10 -2
  66. package/src/cli/console-state.ts +25 -5
  67. package/src/cli/error-format.ts +2 -0
  68. package/src/cli/guidance.ts +1 -1
  69. package/src/cli/handoff-output.ts +20 -17
  70. package/src/cli/help.ts +78 -40
  71. package/src/cli/init-settings.ts +15 -0
  72. package/src/cli/intake-output.ts +13 -13
  73. package/src/cli/launch.ts +3 -2
  74. package/src/cli/learn-output.ts +40 -21
  75. package/src/cli/main.ts +148 -77
  76. package/src/cli/memory.ts +47 -2
  77. package/src/cli/output.ts +54 -31
  78. package/src/cli/roadmap.ts +2 -2
  79. package/src/cli/room-output.ts +71 -0
  80. package/src/cli/room.ts +19 -33
  81. package/src/cli/schedule-output.ts +20 -19
  82. package/src/cli/sdlc-output.ts +188 -170
  83. package/src/cli/source-output.ts +17 -14
  84. package/src/cli/specs.ts +13 -13
  85. package/src/cli/study-output.ts +66 -69
  86. package/src/cli/task-output.ts +106 -158
  87. package/src/cli/terminal-recovery.ts +2 -1
  88. package/src/cli/upgrade-runtime.ts +2 -1
  89. package/src/cli/warn-line.ts +18 -0
  90. package/src/cli/worktrees-output.ts +25 -23
  91. package/src/hub/audit-source.ts +45 -0
  92. package/src/hub/board.ts +141 -5
  93. package/src/hub/bus.ts +13 -2
  94. package/src/hub/config-apply.ts +14 -1
  95. package/src/hub/config-trust.ts +1 -0
  96. package/src/hub/control-client.ts +1 -1
  97. package/src/hub/daemon.ts +371 -45
  98. package/src/hub/handoff.ts +5 -1
  99. package/src/hub/hub-tools.ts +23 -5
  100. package/src/hub/instance-config.ts +3 -3
  101. package/src/hub/learn-followup.ts +103 -0
  102. package/src/hub/learning.ts +63 -1
  103. package/src/hub/manager.ts +15 -1
  104. package/src/hub/memory-policy.ts +2 -1
  105. package/src/hub/memory-review.ts +217 -0
  106. package/src/hub/peer-activity.ts +37 -0
  107. package/src/hub/peers.ts +3 -0
  108. package/src/hub/project-move.ts +258 -0
  109. package/src/hub/registry.ts +16 -5
  110. package/src/hub/restart.ts +7 -0
  111. package/src/hub/review-brief.ts +8 -4
  112. package/src/hub/review-checkout.ts +26 -0
  113. package/src/hub/review-findings.ts +6 -3
  114. package/src/hub/risk-tier.ts +129 -0
  115. package/src/hub/roadmap-check.ts +1 -0
  116. package/src/hub/routing.ts +3 -1
  117. package/src/hub/sdlc-merge.ts +9 -0
  118. package/src/hub/sdlc-metrics.ts +24 -1
  119. package/src/hub/sdlc-queue.ts +1 -1
  120. package/src/hub/sdlc.ts +15 -6
  121. package/src/hub/settings.ts +2 -0
  122. package/src/hub/spec-readback.ts +136 -0
  123. package/src/hub/specs.ts +1 -1
  124. package/src/hub/task-list-page.ts +1 -1
  125. package/src/hub/tasks.ts +558 -65
  126. package/src/hub/ui.ts +4 -2
  127. package/src/ui/index.html +26 -2
  128. package/src/ui/overview-model.ts +138 -0
  129. package/src/ui/plugin.ts +30 -4
  130. package/templates/roles/ops/project-manager.md +1 -1
@@ -1,3 +1,4 @@
1
+ import { nativeActivity, type ActivityTable } from "./definitions/native-activity.ts";
1
2
  import { activityText, updateActivity, type Activity, type ActivityKind } from "../hub/activity.ts";
2
3
  import { spawn, type ChildProcessWithoutNullStreams } from "node:child_process";
3
4
  import { createInterface } from "node:readline";
@@ -172,6 +173,7 @@ export interface AcpOptions {
172
173
  onToolCeiling?: (info: { ceilingMs: number }) => void;
173
174
  /** Transient person-only stream; no native update escapes through another observer. */
174
175
  onActivity?: (item: Activity) => void;
176
+ activityKinds?: ActivityTable;
175
177
  isPrivateTurn?: () => boolean;
176
178
  log?: (line: string) => void;
177
179
  }
@@ -360,6 +362,7 @@ export class AcpPeer extends BasePeer {
360
362
  constructor(
361
363
  id: PeerId,
362
364
  private readonly opts: AcpOptions,
365
+ private readonly activityKinds = opts.activityKinds,
363
366
  ) {
364
367
  super(id, opts.watchdogMs);
365
368
  this.modelPolicy = opts.modelPolicy ? Object.freeze({ ...opts.modelPolicy, admission: Object.freeze({ ...opts.modelPolicy.admission }) }) : undefined;
@@ -957,6 +960,8 @@ export class AcpPeer extends BasePeer {
957
960
  // console would be asked to approve a bare tool name. Keep what the call said it would run (issue #31).
958
961
  // Kimi 2.1.1 sends no rawInput before the answer either: the argument JSON streams as content text (issue #72).
959
962
  else if ((u?.sessionUpdate === "tool_call" || u?.sessionUpdate === "tool_call_update") && typeof u.toolCallId === "string") {
963
+ if (this.activityKinds && typeof this.sessionId === "string" && msg.params?.sessionId === this.sessionId && u.sessionUpdate === "tool_call" && u.status !== "completed" && u.status !== "failed")
964
+ this.onActivity?.(nativeActivity(this.activityKinds, u.kind));
960
965
  // A new call starts clean, so a reused id can never show the arguments or identity of the call before it.
961
966
  if (u.sessionUpdate === "tool_call") (this.toolInputs.delete(u.toolCallId), this.toolText.delete(u.toolCallId), this.toolTitles.delete(u.toolCallId));
962
967
  if (u.rawInput !== undefined) this.toolInputs.set(u.toolCallId, u.rawInput);
@@ -93,6 +93,13 @@ export class WsPeer extends BasePeer {
93
93
  get channelHeld(): boolean {
94
94
  return (!!this.sock && !this.pullOnly) || (this.claiming && !this.claimedPullOnly);
95
95
  }
96
+ /**
97
+ * #1646: the checkout the attached session reported at its hello (its own cwd), read live from that socket. It says where a
98
+ * session reads, never proves owner isolation or grants any: an absent or detached session reports nothing.
99
+ */
100
+ get sessionCwd(): string | undefined {
101
+ return this.attached && typeof this.sock?.data.cwd === "string" ? this.sock.data.cwd : undefined;
102
+ }
96
103
  /** Status-file observations are advisory; a replaced client cannot evict a live socket or pending claim. */
97
104
  standbyHeld(pullOnly: boolean): boolean {
98
105
  return this.claiming || (!!this.sock && this.sock.readyState === WebSocket.OPEN && (pullOnly || !this.pullOnly));
@@ -27,6 +27,9 @@ export interface OwnedPrintChildOptions {
27
27
  onError?: (error: Error) => void;
28
28
  /** Bounded plain-text frames, for model-free metadata commands as well as NDJSON. */
29
29
  onLine?: (line: string) => void;
30
+ /** Raw stdout prefix, kept separate from line and NDJSON observers. */
31
+ onOutput?: (chunk: Uint8Array) => void;
32
+ captureStderrTail?: true;
30
33
  onFrame?: (event: unknown) => void;
31
34
  onActivity?: () => void;
32
35
  onLimit?: () => void;
@@ -51,8 +54,8 @@ export class OwnedPrintChild {
51
54
  private settled = false;
52
55
  /** Only the current owned child's complete bounded stream after confirmed group settlement is usable. */
53
56
  stderrAfterSettlement(): OwnedStderrReceipt {
54
- if (!this.options.captureStderr || !this.settled || !this.stderrEnded || this.stderrUnknown || this.options.current?.() === false) return { status: "unknown" };
55
- try { return { status: "complete", text: new TextDecoder("utf-8", { fatal: true }).decode(Buffer.concat(this.stderrChunks)) }; }
57
+ if (!(this.options.captureStderr || this.options.captureStderrTail) || !this.settled || !this.stderrEnded || this.stderrUnknown || this.options.current?.() === false) return { status: "unknown" };
58
+ try { return { status: "complete", text: new TextDecoder("utf-8", { fatal: !this.options.captureStderrTail }).decode(Buffer.concat(this.stderrChunks)) }; }
56
59
  catch { return { status: "unknown" }; }
57
60
  }
58
61
 
@@ -62,7 +65,7 @@ export class OwnedPrintChild {
62
65
  const child = this.process = spawn(command, [...prefix, ...options.args], {
63
66
  cwd: options.cwd, detached: true,
64
67
  env: applyTurnAttribution(peerChildEnv(options.peer, options.envMode === "replace" ? options.env : { ...process.env, ...options.env }), options.attribution),
65
- stdio: ["pipe", "pipe", options.captureStderr ? "pipe" : "ignore"],
68
+ stdio: ["pipe", "pipe", options.captureStderr || options.captureStderrTail ? "pipe" : "ignore"],
66
69
  });
67
70
  // ponytail: 256 KiB per NDJSON frame and 4 MiB stdout by default; raise only with native receipts.
68
71
  const frameLimit = options.maxFrameBytes ?? 256 * 1024, outputLimit = options.maxOutputBytes ?? 4 * 1024 * 1024;
@@ -70,9 +73,16 @@ export class OwnedPrintChild {
70
73
  let inputFailed = false;
71
74
  const current = () => !this.limited && options.current?.() !== false;
72
75
  const limit = () => { if (!this.limited) { this.limited = true; options.onLimit?.(); } };
73
- if (options.captureStderr) {
76
+ if (options.captureStderr || options.captureStderrTail) {
74
77
  child.stderr!.on("data", (chunk: Buffer) => {
75
78
  if (this.stderrUnknown) return;
79
+ if (options.captureStderrTail) {
80
+ if (options.current?.() === false) { this.stderrUnknown = true; this.stderrChunks = []; return; }
81
+ const limit = 64 * 1024;
82
+ const tail = Buffer.concat([...this.stderrChunks, chunk.subarray(-limit)]);
83
+ this.stderrChunks = [Buffer.from(tail.subarray(-limit))];
84
+ return;
85
+ }
76
86
  this.stderrBytes += chunk.length;
77
87
  if (options.current?.() === false || this.stderrBytes > 64 * 1024) { this.stderrUnknown = true; this.stderrChunks = []; return; }
78
88
  this.stderrChunks.push(Buffer.from(chunk));
@@ -95,6 +105,14 @@ export class OwnedPrintChild {
95
105
  });
96
106
  child.stdout!.on("data", (chunk: Buffer) => {
97
107
  if (!current()) return;
108
+ if (options.onOutput) {
109
+ const remaining = outputLimit - outputBytes;
110
+ try { if (remaining > 0) options.onOutput(chunk.subarray(0, remaining)); } catch { /* Preserve owned teardown. */ }
111
+ outputBytes += chunk.length;
112
+ if (outputBytes > outputLimit) limit();
113
+ options.onActivity?.();
114
+ return;
115
+ }
98
116
  outputBytes += chunk.length;
99
117
  if (outputBytes > outputLimit) return limit();
100
118
  buffer += chunk.toString("utf8");
@@ -109,9 +127,13 @@ export class OwnedPrintChild {
109
127
  if (Buffer.byteLength(buffer) > frameLimit) return limit();
110
128
  options.onActivity?.();
111
129
  });
130
+ const streamsClosed = options.onOutput ? new Promise<void>(resolveClose => child.once("close", () => resolveClose())) : undefined;
112
131
  child.once("exit", code => {
113
132
  options.onLeaderExit?.();
114
- void this.stop().then(() => { this.settled = true; resolve(code); }, error => reject(new PrintChildCleanupError((error as Error).message)));
133
+ void this.stop().then(async () => {
134
+ await streamsClosed;
135
+ this.settled = true; resolve(code);
136
+ }, error => reject(new PrintChildCleanupError((error as Error).message)));
115
137
  });
116
138
  });
117
139
  }
@@ -1,3 +1,5 @@
1
+ import { codexItemActivity } from "./definitions/native-activity.ts";
2
+ import type { ActivityKind } from "../hub/peer-activity.ts";
1
3
  import { codexAccountUsage, codexQuotaWindowInput } from "./definitions/native-quota.ts";
2
4
  import type { QuotaAccountUsage } from "../hub/quota-account.ts";
3
5
  import type { ModelOverrideSelection } from "./registry-types.ts";
@@ -33,6 +35,7 @@ function confirmsReadOnlySandbox(value: unknown): boolean {
33
35
  /** A counter Codex reported: a finite non-negative number, otherwise 0 (an absent kind is not a negative delta). */
34
36
  const counter = (value: unknown): number => { const n = Number(value); return Number.isFinite(n) && n >= 0 ? n : 0; };
35
37
  export interface CodexOptions {
38
+ activityServers?: ReadonlyMap<string, ActivityKind>;
36
39
  /** Host-only choice sampled once at the next turn/review boundary. */
37
40
  getModelOverride?: () => ModelOverrideSelection;
38
41
  /** Successful explicit native-client choice; never acknowledgement of a hub override revision. */
@@ -1019,6 +1022,7 @@ export class CodexPeer extends BasePeer {
1019
1022
  return;
1020
1023
  }
1021
1024
  if (method === "turn/started") {
1025
+ this.onActivity?.(undefined);
1022
1026
  this.reroutedModel = undefined; // a reroute whose turn end was never read cannot carry into another turn
1023
1027
  link.rejectedModelSelection = undefined;
1024
1028
  // The notification has no request id. Conservatively protect every outstanding capture on
@@ -1031,6 +1035,10 @@ export class CodexPeer extends BasePeer {
1031
1035
  this.lastAnswer = "";
1032
1036
  this.setState("busy");
1033
1037
  if (params.turn?.id) this.opts.onTurn?.(params.turn.id);
1038
+ } else if (method === "item/started") {
1039
+ if (typeof params.turnId !== "string" || !this.activeTurns.has(params.turnId)) return;
1040
+ const kind = this.opts.activityServers && codexItemActivity(params.item?.type, params.item?.server, this.opts.activityServers);
1041
+ if (kind !== undefined) this.onActivity?.(kind);
1034
1042
  } else if (method === "item/agentMessage/delta") {
1035
1043
  if (!this.activeTurns.size || typeof params.turnId === "string" && !this.activeTurns.has(params.turnId) && !unknownTurn()) return;
1036
1044
  const buf = this.deltas.get(params.itemId) ?? [];
@@ -1052,6 +1060,7 @@ export class CodexPeer extends BasePeer {
1052
1060
  // Conclusions only: skip commentary, keep the last answer of the turn (phase may be absent).
1053
1061
  if (item.phase !== "commentary" && text.trim()) this.lastAnswer = text.trim();
1054
1062
  } else if (method === "turn/completed") {
1063
+ if (typeof nativeId === "string" && this.activeTurns.has(nativeId)) this.onActivity?.(undefined);
1055
1064
  const nativeTurn = params.turn?.id;
1056
1065
  this.abortActionWaits(link, typeof nativeTurn === "string" ? nativeTurn : undefined);
1057
1066
  // A watchdog or a newer turn has invalidated this completion. Unknown-id legacy starts retain their fallback.
@@ -29,27 +29,28 @@ export interface CompatPolicy {
29
29
 
30
30
  const plain = (text: string) => text.length <= 64 && /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(text) ? text : undefined;
31
31
  export const COMPAT = {
32
- // 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)
33
- pi: { label: "Pi", verified: ["1.4.0", "1.5.0", "1.5.2"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
32
+ // 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)
33
+ pi: { label: "Pi", verified: ["1.4.0", "1.5.0", "1.5.2", "1.6.0"], gate: "contract", probe: ["pi", "--version"], config: "pi.cmd",
34
34
  parse: out => plain(out.trim()),
35
- trustNote: "The model-free extension load, RPC session identity and managed tool receipt path were checked on 1.4.0, 1.5.0 and 1.5.2. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
36
- receipt: "docs/verification/2026-11-14-pi-152-compat.md" },
37
- // 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; host-wrapper receipt below repeats with them.
38
- "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"], gate: "contract", probe: ["claude", "--version"],
35
+ 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 and 1.6.0. Permissions remain host-owned; account-backed inference and another version's extension contract are unverified.",
36
+ receipt: "docs/verification/2026-11-25-pi-160-compat.md" },
37
+ // 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; host-wrapper receipt below repeats with them.
38
+ "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"], gate: "contract", probe: ["claude", "--version"],
39
39
  parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
40
40
  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.",
41
- receipt: "docs/verification/2026-11-20-claude-implementer-2.1.329.md" },
42
- // 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
41
+ receipt: "docs/verification/2026-11-25-claude-implementer-2.1.332.md" },
42
+ // 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
43
43
  "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",
44
44
  parse: out => plain(out.trim().replace(/^codex-cli /, "")),
45
45
  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).",
46
46
  receipt: "docs/verification/2026-11-14-codex-0169-reviewer-isolation.md" },
47
- // Kimi 2.3.0 / Qwen 0.26.0 receipt: docs/verification/2026-10-22-kimi-qwen-compat.md; Kimi 2.3.1: docs/verification/2026-10-25-kimi-231-reviewer-compat.md; Kimi 2.3.2: docs/verification/2026-10-26-kimi-232-reviewer-compat.md; Kimi 2.4.1: docs/verification/2026-10-31-kimi-241-reviewer-compat.md; Kimi 2.5.1: docs/verification/2026-11-06-kimi-251-reviewer-compat.md
48
- "kimi-review": { label: "Kimi reviewer (kimi-code)", verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1"], gate: "isolation", probe: ["kimi", "--version"],
47
+ // Kimi 2.3.0 / Qwen 0.26.0 receipt: docs/verification/2026-10-22-kimi-qwen-compat.md; Kimi 2.3.1: docs/verification/2026-10-25-kimi-231-reviewer-compat.md; Kimi 2.3.2: docs/verification/2026-10-26-kimi-232-reviewer-compat.md; Kimi 2.4.1: docs/verification/2026-10-31-kimi-241-reviewer-compat.md; Kimi 2.5.1: docs/verification/2026-11-06-kimi-251-reviewer-compat.md; 2.7.2: docs/verification/2026-11-25-kimi-272-reviewer-compat.md
48
+ "kimi-review": { label: "Kimi reviewer (kimi-code)", verified: ["2.2.0", "2.3.0", "2.3.1", "2.3.2", "2.4.1", "2.5.1", "2.7.2"], gate: "isolation", probe: ["kimi", "--version"],
49
49
  parse: out => plain(out.trim()),
50
50
  trustNote: "Every launch still builds the private config, exact two-tool agent file and task-bound MCP; the native tool allowlist behaviour of an untested version is not re-proven.",
51
- receipt: "docs/verification/2026-11-06-kimi-251-reviewer-compat.md" },
51
+ receipt: "docs/verification/2026-11-25-kimi-272-reviewer-compat.md" },
52
52
  // The interactive TUI's native-turn and background readbacks are a separate contract from headless ACP and reviewer isolation.
53
+ // 2.7.2 model-free checks and pending live TUI legs: docs/verification/2026-11-25-kimi-tui-272.md
53
54
  "kimi-tui": { label: "Kimi TUI completion facts", verified: ["2.5.2"], gate: "contract", probe: ["kimi", "--version"],
54
55
  parse: out => plain(out.trim()),
55
56
  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.",
@@ -1,11 +1,13 @@
1
+ import { ACP_ACTIVITY } from "./definitions/native-activity.ts";
1
2
  import { basename } from "node:path";
2
3
  import { types } from "node:util";
3
4
  import { AcpPeer } from "./acp.ts";
5
+ import { ConfiguredPrintPeer, type ConfiguredPrintAdapterConfig } from "./configured-print.ts";
4
6
  import type { AdapterDefinition } from "./registry-types.ts";
5
7
  import type { PermissionMode } from "../hub/permission-mode.ts";
6
8
  import { shellQuote } from "../cli/shell-quote.ts";
7
9
 
8
- export interface ConfiguredAcpAdapterConfig {
10
+ interface ConfiguredAcpAdapterConfig {
9
11
  transport: "acp";
10
12
  command: string;
11
13
  args?: readonly string[];
@@ -15,6 +17,8 @@ export interface ConfiguredAcpAdapterConfig {
15
17
  permission?: Partial<Record<PermissionMode, string>>;
16
18
  readOnly?: string;
17
19
  }
20
+ export type ConfiguredAdapterConfig = ConfiguredAcpAdapterConfig | ConfiguredPrintAdapterConfig;
21
+
18
22
  const fail = (field: string, reason: string): never => { throw new Error(`${field}: ${reason}`); };
19
23
  /** Core command namespace is reserved; configured kinds cannot shadow operational CLI actions. */
20
24
  export const CONFIGURED_ACP_RESERVED_COMMANDS = Object.freeze(["help", "version", "completion", "projects", "ui", "manager", "setup", "init", "daemon", "up", "console", "recovery-run", "upgrade", "restart", "recovery", "models", "say", "queue", "watch", "tail", "budget", "backlog", "release", "board", "sdlc", "task", "review", "remember", "ask", "route", "pause", "resume", "stop", "permission", "roster", "settings", "permit", "pet", "status", "logs", "export", "bench", "memory", "goal", "research", "report", "facts", "check-path", "turns", "undo", "kill", "reset", "role", "doctor"]);
@@ -46,6 +50,43 @@ function freeze<T>(value: T): T {
46
50
  return value;
47
51
  }
48
52
 
53
+ function configuredPrintDefinition(kind: string, input: Record<string, PropertyDescriptor>, at: string): AdapterDefinition {
54
+ if (Object.keys(input).some(key => !["transport", "command", "args", "stdin", "versionArgs", "versionPin", "timeoutS", "displayName", "roles"].includes(key)))
55
+ return fail(at, "unknown or privileged print field");
56
+ const command = text(input.command?.value, `${at}.command`);
57
+ const args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
58
+ const stdin = input.stdin?.value;
59
+ const placeholders = args.reduce((count, arg) => count + arg.split("{prompt}").length - 1, 0);
60
+ if (input.stdin && stdin !== true || (stdin === true ? placeholders !== 0 : placeholders !== 1))
61
+ return fail(at, "choose stdin: true or exactly one {prompt} placeholder");
62
+ const versionArgs = list(input.versionArgs?.value, `${at}.versionArgs`, 128);
63
+ if (!versionArgs.length || versionArgs.some(arg => arg.includes("{prompt}"))) return fail(`${at}.versionArgs`, "requires fixed version probe arguments");
64
+ const versionPin = text(input.versionPin?.value, `${at}.versionPin`, 256).trim();
65
+ const timeoutS = input.timeoutS?.value;
66
+ if (!Number.isInteger(timeoutS) || timeoutS < 1 || timeoutS > 300) return fail(`${at}.timeoutS`, "must be an integer from 1 to 300");
67
+ const displayName = text(input.displayName?.value, `${at}.displayName`, 256);
68
+ const roles = list(input.roles?.value, `${at}.roles`, 2);
69
+ const advisory = roles.filter((role): role is "reviewer" | "advisor" => role === "reviewer" || role === "advisor");
70
+ if (!roles.length || advisory.length !== roles.length || new Set(roles).size !== roles.length) return fail(`${at}.roles`, "only unique reviewer and advisor roles are supported");
71
+ const declaration: ConfiguredPrintAdapterConfig = freeze({ transport: "print", command, args, ...(stdin === true ? { stdin } : {}), versionArgs, versionPin, timeoutS, displayName, roles: advisory });
72
+ return freeze<AdapterDefinition>({
73
+ api: 1, kind, family: kind, displayName, roles: advisory, transport: "hub-native", optional: true, defaultOnRoster: false,
74
+ trust: { onPrem: false, hubSandboxed: true }, identity: { mcp: "none" },
75
+ start: {
76
+ daemonPort: "configured-print", forms: ["headless"], defaultForm: "headless", conductorStartable: false, hubSwitches: [], ownedFlags: [],
77
+ preflight: request => request.form && request.form !== "headless" ? "configured print supports headless only" : undefined,
78
+ create: context => {
79
+ if (!("configuredPrint" in context.daemon)) throw new Error("configured print transport options required");
80
+ return new ConfiguredPrintPeer(context.instance, { ...context.daemon.configuredPrint, declaration });
81
+ },
82
+ },
83
+ permission: { unmanaged: "configured print has no native approval channel; read-only sandbox applies" },
84
+ session: { idField: "sessionId", currentId: () => undefined, recoveryRefusal: () => "configured print has no retained session; stop it before recovery and start it again afterwards" },
85
+ turnEnd: "adapter", cli: { command: kind, launchConfigKeys: [`adapters.${kind}.command`, `adapters.${kind}.args`], startWords: () => [kind] },
86
+ display: { palette: { fg: "white", bg: "black" } },
87
+ });
88
+ }
89
+
49
90
  /** Pure local declaration compiler; file provenance and runtime process ownership remain host checks. */
50
91
  export function configuredAcpDefinitions(raw: unknown, builtinKinds: readonly string[]): readonly AdapterDefinition[] {
51
92
  if (raw === undefined) return Object.freeze([]);
@@ -56,8 +97,9 @@ export function configuredAcpDefinitions(raw: unknown, builtinKinds: readonly st
56
97
  const at = `adapters.${kind}`;
57
98
  if (!/^[a-z][a-z0-9-]{0,31}$/.test(kind) || reserved.has(kind)) return fail(at, "kind is invalid, reserved or collides with a builtin");
58
99
  const input = fields(descriptor.value, at);
100
+ if (input.transport?.value === "print") return configuredPrintDefinition(kind, input, at);
59
101
  if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "identity", "permission", "readOnly"].includes(key))) return fail(at, "unknown or privileged field");
60
- if (input.transport?.value !== "acp") return fail(`${at}.transport`, "must be acp");
102
+ if (input.transport?.value !== "acp") return fail(`${at}.transport`, "must be acp or print");
61
103
  const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
62
104
  // The supported contract is a foreground owned stdio process, never an attachment/proxy selector.
63
105
  if ([command, ...args].some(arg => /^--(?:leader|attach|connect|remote)(?:-|=|$)/.test(arg))) return fail(`${at}.args`, "attach/leader selectors are unsupported; command must run foreground owned ACP stdio");
@@ -107,6 +149,7 @@ export function configuredAcpDefinitions(raw: unknown, builtinKinds: readonly st
107
149
  if (!identity) throw new Error(`${kind}: native identity is unverified; configure the observed name/version pin before starting`);
108
150
  return new AcpPeer(context.instance, { ...context.daemon.acp, kind, cmd: [...argv], qwen025: false,
109
151
  expectedAgent: identity, requireLoadSessionEcho: true, requireOwnedGroup: true,
152
+ activityKinds: ACP_ACTIVITY,
110
153
  permissionMode: context.permission === "read-only" ? "ask" : context.permission,
111
154
  nativePolicy: { ...nativePolicy, lockedReadOnly: context.permission === "read-only" }, mcpServers: context.mcpServers });
112
155
  },
@@ -0,0 +1,163 @@
1
+ import { statSync } from "node:fs";
2
+ import { isAbsolute } from "node:path";
3
+ import { OwnedPrintChild, PrintChildCleanupError } from "./claude-print-child.ts";
4
+ import { renderDigest, replyAudience, replyParent, sanitize, type Envelope } from "../hub/envelope.ts";
5
+ import { BasePeer } from "../hub/peers.ts";
6
+ import { realPath } from "../hub/project.ts";
7
+ import { sbplString } from "../local/deny.ts";
8
+ import { profile, sandboxAvailable } from "../local/sandbox.ts";
9
+
10
+ export interface ConfiguredPrintAdapterConfig {
11
+ transport: "print";
12
+ command: string;
13
+ args: readonly string[];
14
+ stdin?: true;
15
+ versionArgs: readonly string[];
16
+ versionPin: string;
17
+ timeoutS: number;
18
+ displayName: string;
19
+ roles: readonly ("reviewer" | "advisor")[];
20
+ }
21
+
22
+ export interface ConfiguredPrintOptions {
23
+ declaration: ConfiguredPrintAdapterConfig;
24
+ cwd: string;
25
+ deny(): string[];
26
+ stateDir: string;
27
+ privateTurn(envs: readonly Envelope[]): boolean;
28
+ publicText(text: string): boolean;
29
+ }
30
+
31
+ const OUTPUT_LIMIT = 64 * 1024;
32
+ const STDERR_DISPLAY_LIMIT = 2000;
33
+ const SANDBOX = "/usr/bin/sandbox-exec";
34
+
35
+ function executableIdentity(file: string): string {
36
+ const stat = statSync(file);
37
+ if (!stat.isFile()) throw new Error("print command must name an executable file");
38
+ return [stat.dev, stat.ino, stat.size, stat.mtimeMs, stat.ctimeMs].join(":");
39
+ }
40
+
41
+ /** Each process is subject to the same read-only confinement, including the version probe. */
42
+ export class ConfiguredPrintPeer extends BasePeer {
43
+ readonly form = "headless" as const;
44
+ readonly hubOwned = true;
45
+ readonly deliveryOnly = true;
46
+ readonly permissionModeState = "unmanaged" as const;
47
+ private child?: OwnedPrintChild;
48
+ private command?: { path: string; identity: string };
49
+ private stopped = false;
50
+
51
+ constructor(id: string, private readonly options: ConfiguredPrintOptions) {
52
+ super(id);
53
+ }
54
+
55
+ get pendingOwnedProcess(): boolean { return this.child !== undefined; }
56
+
57
+ async start(): Promise<void> {
58
+ if (this.child) throw new Error("print child cleanup is unconfirmed; stop the peer and retry");
59
+ if (!sandboxAvailable()) throw new Error("configured print requires the hub read-only sandbox on this host");
60
+ const config = this.options.declaration;
61
+ const selected = isAbsolute(config.command) ? config.command : Bun.which(config.command);
62
+ if (!selected) throw new Error("configured print command is unavailable");
63
+ const path = realPath(selected);
64
+ const identity = executableIdentity(path);
65
+ this.command = { path, identity };
66
+ this.stopped = false;
67
+ const version = await this.run(config.versionArgs, "");
68
+ if (this.stopped || version.code !== 0 || version.timedOut || version.truncated || version.stdout.trim() !== config.versionPin || executableIdentity(path) !== identity) {
69
+ this.command = undefined;
70
+ throw new Error("configured print version probe did not match versionPin");
71
+ }
72
+ this.setState("idle");
73
+ }
74
+
75
+ async deliver(envs: Envelope[], deliveryId?: string): Promise<void> {
76
+ const receipt = (state: "accepted" | "completed" | "failed_safe" | "needs_review", reason?: string) => {
77
+ if (deliveryId) this.delivery({ id: deliveryId, state, ...(reason ? { reason } : {}) });
78
+ };
79
+ if (this.state !== "idle" || this.child || !envs.length || this.options.privateTurn(envs)
80
+ || envs.some(env => env.private || env.kind === "review" || env.kind === "task" || env.kind === "invocation")) {
81
+ receipt("failed_safe", "configured print accepts public advisory messages only");
82
+ return;
83
+ }
84
+ const prompt = renderDigest(envs, true);
85
+ if (!this.options.publicText(prompt)) { receipt("failed_safe", "print prompt withheld by policy"); return; }
86
+ const reply = { to: replyAudience(envs), inReplyTo: replyParent(envs) };
87
+ const config = this.options.declaration;
88
+ const args = config.stdin ? config.args : config.args.map(arg => arg.replace("{prompt}", () => prompt));
89
+ this.setState("busy");
90
+ try {
91
+ receipt("accepted");
92
+ const result = await this.run(args, config.stdin ? prompt : "");
93
+ if (this.stopped || this.options.privateTurn(envs)) {
94
+ receipt("needs_review", "print delivery stopped or became private");
95
+ return;
96
+ }
97
+ if (result.code !== 0 || result.timedOut) {
98
+ const cause = result.timedOut ? "Configured print timed out" : "Configured print exited unsuccessfully";
99
+ const tail = result.stderr && this.options.publicText(result.stderr) ? sanitize(result.stderr.slice(-STDERR_DISPLAY_LIMIT)) : "";
100
+ this.finalAnswer(tail ? `${cause}\n${tail}` : cause, reply, false);
101
+ receipt("needs_review", cause);
102
+ return;
103
+ }
104
+ const output = result.stdout + (result.truncated ? "\n[print output truncated]" : "");
105
+ if (output && this.options.publicText(output)) this.finalAnswer(output, reply);
106
+ else if (output) { receipt("needs_review", "print answer withheld by policy"); return; }
107
+ receipt("completed");
108
+ } catch (error) {
109
+ receipt(error instanceof PrintChildCleanupError ? "needs_review" : "failed_safe", "configured print failed to run");
110
+ } finally {
111
+ if (!this.child) this.setState(this.stopped ? "offline" : "idle");
112
+ }
113
+ }
114
+
115
+ override onWatchdog(): void {
116
+ // The configured per-process timeout joins the owned child before the next delivery.
117
+ this.touch();
118
+ }
119
+
120
+ async stop(): Promise<void> {
121
+ this.stopped = true;
122
+ const child = this.child;
123
+ if (child) {
124
+ await child.stop();
125
+ await child.done.catch(error => {
126
+ if (error instanceof PrintChildCleanupError) throw error;
127
+ });
128
+ if (this.child === child) this.child = undefined;
129
+ }
130
+ this.setState("offline");
131
+ }
132
+
133
+ private async run(args: readonly string[], input: string) {
134
+ const command = this.command;
135
+ if (!sandboxAvailable() || !command || this.stopped || executableIdentity(command.path) !== command.identity)
136
+ throw new Error("configured print command or sandbox is no longer current");
137
+ const { cwd, deny, stateDir } = this.options;
138
+ // The final deny also closes the ordinary worker profile's loose Git-object write grant.
139
+ const policy = profile(cwd, false, [command.path], deny(), [cwd])
140
+ + `\n(deny file-read* (subpath ${sbplString(stateDir)}))\n(deny file-write*)\n(allow file-write* (literal "/dev/null"))`;
141
+ const chunks: Uint8Array[] = [];
142
+ let timedOut = false, truncated = false;
143
+ const child = this.child = new OwnedPrintChild({ peer: this.id, command: [SANDBOX],
144
+ args: ["-p", policy, command.path, ...args], cwd, input, envMode: "replace",
145
+ env: { PATH: "/usr/bin:/bin", HOME: "/var/empty", LANG: "C", TERM: "dumb" },
146
+ maxOutputBytes: OUTPUT_LIMIT, captureStderrTail: true,
147
+ onOutput: chunk => chunks.push(chunk), onLimit: () => { truncated = true; } });
148
+ const timer = setTimeout(() => {
149
+ timedOut = true;
150
+ void child.stop().catch(() => {});
151
+ }, this.options.declaration.timeoutS * 1000);
152
+ timer.unref();
153
+ try {
154
+ const code = await child.done;
155
+ this.child = undefined;
156
+ const stderr = child.stderrAfterSettlement();
157
+ return { code, timedOut, truncated, stdout: Buffer.concat(chunks).toString("utf8"), stderr: stderr.status === "complete" ? stderr.text : "" };
158
+ } catch (error) {
159
+ if (!(error instanceof PrintChildCleanupError)) this.child = undefined;
160
+ throw error;
161
+ } finally { clearTimeout(timer); }
162
+ }
163
+ }
@@ -2,6 +2,7 @@
2
2
  export { registerConformance, registerExternalChannelConformance, until, type AdapterConformance, type ConformanceFixture } from "./kit.ts";
3
3
  export { registerAcpConformance, type AcpConformanceOptions } from "./acp.ts";
4
4
  export { registerCodexConformance } from "./codex.ts";
5
+ export { registerPrintConformance } from "./print.ts";
5
6
  export { registerOwnedAcpConformance } from "./owned-acp.ts";
6
7
  export { registerLocalConformance, registerPiConformance } from "./local-pi.ts";
7
8
  export { createFromDefinition, expire } from "./factories.ts";
@@ -0,0 +1,57 @@
1
+ import { expect, test } from "bun:test";
2
+ import { mkdtempSync, existsSync, rmSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { newEnvelope, USER } from "../../hub/envelope.ts";
6
+ import { sandboxAvailable } from "../../local/sandbox.ts";
7
+ import { ConfiguredPrintPeer, type ConfiguredPrintAdapterConfig } from "../configured-print.ts";
8
+
9
+ // used-by: src/adapters/conformance/index.ts
10
+ export function registerPrintConformance(): void {
11
+ const run = async (script: string, timeoutS = 2) => {
12
+ const cwd = mkdtempSync(join(tmpdir(), "ahub-print-conformance-"));
13
+ const config: ConfiguredPrintAdapterConfig = { transport: "print", command: "/bin/sh", args: ["-c", script],
14
+ stdin: true, versionArgs: ["-c", "printf fixture-v1"], versionPin: "fixture-v1", displayName: "Print fixture", timeoutS, roles: ["advisor"] };
15
+ const peer = new ConfiguredPrintPeer("print-fixture", { declaration: config, cwd, stateDir: join(cwd, ".agenthub"),
16
+ deny: () => [], privateTurn: () => false, publicText: () => true });
17
+ const answers: { body: string; complete: boolean | undefined }[] = [];
18
+ peer.onFinalAnswer = (body, _opts, complete) => answers.push({ body, complete });
19
+ try {
20
+ await peer.start();
21
+ await peer.deliver([newEnvelope(USER, "fixture request")]);
22
+ return { answers, wrote: existsSync(join(cwd, "write-proof")), state: peer.state };
23
+ } finally {
24
+ await peer.stop();
25
+ rmSync(cwd, { recursive: true, force: true });
26
+ }
27
+ };
28
+
29
+ test.skipIf(!sandboxAvailable())("print transport returns the bounded stdout answer", async () => {
30
+ const result = await run("cat");
31
+ expect(result.answers).toEqual([{ body: expect.stringContaining("fixture request"), complete: true }]);
32
+ expect(result.state).toBe("idle");
33
+ });
34
+
35
+ test.skipIf(!sandboxAvailable())("print transport reports a timeout and joins the child", async () => {
36
+ const result = await run("printf timeout-tail >&2; /bin/sleep 30", 1);
37
+ expect(result.answers).toEqual([{ body: "Configured print timed out\ntimeout-tail", complete: false }]);
38
+ expect(result.state).toBe("idle");
39
+ });
40
+
41
+ test.skipIf(!sandboxAvailable())("print transport reports a nonzero exit with stderr", async () => {
42
+ const result = await run("printf fixture-diagnostic >&2; exit 7");
43
+ expect(result.answers).toEqual([{ body: "Configured print exited unsuccessfully\nfixture-diagnostic", complete: false }]);
44
+ });
45
+
46
+ test.skipIf(!sandboxAvailable())("print transport marks an oversized successful answer", async () => {
47
+ const result = await run("awk 'BEGIN { for(i=0;i<70000;i++) printf \"x\" }'");
48
+ expect(result.answers[0]?.body).toEndWith("\n[print output truncated]");
49
+ expect(result.answers[0]?.complete).toBe(true);
50
+ });
51
+
52
+ test.skipIf(!sandboxAvailable())("print transport cannot write to the project", async () => {
53
+ const result = await run("if (printf unexpected > write-proof) 2>/dev/null; then exit 3; fi; printf blocked");
54
+ expect(result.answers).toEqual([{ body: "blocked", complete: true }]);
55
+ expect(result.wrote).toBe(false);
56
+ });
57
+ }
@@ -0,0 +1,57 @@
1
+ import { closeSync, constants, fstatSync, openSync, readSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import type { ActivityKind } from "../../hub/peer-activity.ts";
4
+
5
+ export type ActivityTable = Readonly<Record<string, ActivityKind>>;
6
+ const CODEX_ACTIVITY: ActivityTable = Object.freeze({
7
+ commandExecution: "shell", fileChange: "files", mcpToolCall: "network", dynamicToolCall: "unknown",
8
+ collabAgentToolCall: "agents", webSearch: "network", imageView: "files", imageGeneration: "model",
9
+ });
10
+ const CODEX_NON_TOOLS = new Set(["userMessage", "agentMessage", "plan", "reasoning", "contextCompaction",
11
+ "enteredReviewMode", "exitedReviewMode"]);
12
+ export const ACP_ACTIVITY: ActivityTable = Object.freeze({
13
+ read: "files", edit: "files", delete: "files", move: "files", search: "files",
14
+ execute: "shell", think: "model", fetch: "network", switch_mode: "agents", other: "unknown",
15
+ });
16
+ export const LOCAL_ACTIVITY: ActivityTable = Object.freeze({
17
+ read: "files", write: "files", edit: "files", doc_read: "files", bash: "shell", git: "shell",
18
+ web_fetch: "network", hub_send: "hub", hub_invoke: "agents", hub_remember: "memory",
19
+ hub_memory_search: "memory", hub_memory_show: "memory", hub_memory_graph: "memory",
20
+ });
21
+
22
+ export function nativeActivity(table: ActivityTable, kind: unknown, fallback: ActivityKind = "unknown"): ActivityKind {
23
+ return typeof kind === "string" && Object.hasOwn(table, kind) ? table[kind]! : fallback;
24
+ }
25
+
26
+ export function codexItemActivity(kind: unknown, server: unknown, servers: ReadonlyMap<string, ActivityKind>): ActivityKind | undefined {
27
+ if (typeof kind !== "string" || CODEX_NON_TOOLS.has(kind)) return undefined;
28
+ if (kind === "mcpToolCall" && typeof server === "string") return servers.get(server) ?? "network";
29
+ return nativeActivity(CODEX_ACTIVITY, kind);
30
+ }
31
+
32
+ const MEMORY_SERVER_NAMES = ["agent-mem", "amem", "claude-mem", "cmem", "vmem"] as const;
33
+ const CONFIG_BYTES = 64 * 1024;
34
+
35
+ /** Only allowlisted names from bounded home and project MCP declarations leave this function. */
36
+ export function codexActivityServers(home: string, cwd: string): ReadonlyMap<string, ActivityKind> {
37
+ const servers = new Map<string, ActivityKind>([["agent-hub", "hub"]]);
38
+ for (const file of [join(home, "config.toml"), join(cwd, ".codex/config.toml")]) {
39
+ let fd: number | undefined;
40
+ try {
41
+ fd = openSync(file, constants.O_RDONLY | constants.O_NONBLOCK);
42
+ if (!fstatSync(fd).isFile()) continue;
43
+ const bytes = Buffer.alloc(CONFIG_BYTES + 1);
44
+ const n = readSync(fd, bytes);
45
+ if (n > CONFIG_BYTES) continue;
46
+ const config = Bun.TOML.parse(bytes.subarray(0, n).toString("utf8")) as { mcp_servers?: Record<string, { enabled?: boolean }> };
47
+ for (const name of MEMORY_SERVER_NAMES) {
48
+ const entry = config.mcp_servers?.[name];
49
+ if (entry && typeof entry === "object" && !Array.isArray(entry)) {
50
+ if (entry.enabled === false) servers.delete(name); else servers.set(name, "memory");
51
+ }
52
+ }
53
+ } catch { /* Unavailable configuration simply provides no memory label. */ }
54
+ finally { if (fd !== undefined) closeSync(fd); }
55
+ }
56
+ return servers;
57
+ }
@@ -1,3 +1,4 @@
1
+ import { ACP_ACTIVITY } from "./native-activity.ts";
1
2
  import type { CreateContext, DaemonEngine, DaemonPorts } from "../registry-types.ts";
2
3
  import type { PeerAdapter } from "../../hub/peers.ts";
3
4
 
@@ -14,14 +15,14 @@ export function createKimi(ctx: CreateContext): PeerAdapter {
14
15
  if (!("acp" in ctx.daemon)) throw new Error("Kimi requires its ACP transport options");
15
16
  if (ctx.permission === "read-only") throw new Error("Kimi has no verified read-only permission mapping");
16
17
  const { AcpPeer } = require("../acp.ts") as typeof import("../acp.ts");
17
- return new AcpPeer(ctx.instance, ctx.daemon.acp);
18
+ return new AcpPeer(ctx.instance, ctx.daemon.acp, ACP_ACTIVITY);
18
19
  }
19
20
 
20
21
  export function createJcode(ctx: CreateContext): PeerAdapter {
21
22
  if (!("jcode" in ctx.daemon)) throw new Error("Jcode requires its Jcode transport options");
22
23
  if (ctx.permission === "read-only") throw new Error("Jcode has no verified read-only permission mapping");
23
24
  const { JcodePeer } = require("../jcode.ts") as typeof import("../jcode.ts");
24
- return new JcodePeer(ctx.daemon.jcode);
25
+ return new JcodePeer(ctx.daemon.jcode, ACP_ACTIVITY);
25
26
  }
26
27
 
27
28
  export function createQwenDual(ctx: CreateContext): PeerAdapter {
@@ -90,4 +91,5 @@ export const DAEMON_PORTS = {
90
91
  "reviewer-print": (options: Extract<DaemonPorts, { reviewerPrint: unknown }>["reviewerPrint"]) => ({ reviewerPrint: options }),
91
92
  "claude-implementer": (options: Extract<DaemonPorts, { claudeImplementer: unknown }>["claudeImplementer"]) => ({ claudeImplementer: options }),
92
93
  "claude-print": (options: Extract<DaemonPorts, { claudePrint: unknown }>["claudePrint"]) => ({ claudePrint: options }),
94
+ "configured-print": (options: Extract<DaemonPorts, { configuredPrint: unknown }>["configuredPrint"]) => ({ configuredPrint: options }),
93
95
  } satisfies Record<DaemonEngine, unknown>;