@staix/agent-hub 0.51.0 → 0.52.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 (299) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +1 -1
  3. package/docs/adding-an-ai-tool.md +24 -2
  4. package/docs/agent-notes/adapters.md +1 -0
  5. package/docs/agent-notes/budget.md +8 -2
  6. package/docs/agent-notes/daemon.md +13 -8
  7. package/docs/agent-notes/security-review.md +6 -5
  8. package/docs/agent-notes/tasks.md +5 -2
  9. package/docs/agent-notes/tests.md +4 -3
  10. package/docs/cooperbench.md +1 -1
  11. package/docs/design/adapters.md +4 -0
  12. package/docs/design/cli-output-inventory.md +162 -152
  13. package/docs/design/cli-output.md +4 -3
  14. package/docs/design/guidance-probes.md +1 -0
  15. package/docs/design/roadmap.md +2 -0
  16. package/docs/design/task-board.md +1 -0
  17. package/docs/dogfood.md +14 -0
  18. package/docs/events.md +4 -2
  19. package/docs/memory.md +5 -3
  20. package/docs/operations.md +210 -16
  21. package/docs/quickstart.md +12 -2
  22. package/docs/roles.md +1 -1
  23. package/docs/sdlc.md +26 -3
  24. package/docs/security.md +11 -5
  25. package/docs/specs/2026-09-19-agent-hub-design.md +43 -0
  26. package/docs/specs/2026-09-19-multi-project-design.md +4 -0
  27. package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
  28. package/docs/specs/mcp-endpoint.md +63 -0
  29. package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
  30. package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
  31. package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
  32. package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
  33. package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
  34. package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
  35. package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
  36. package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
  37. package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
  38. package/docs/verification/2026-12-03-0.52.0.md +150 -0
  39. package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
  40. package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
  41. package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
  42. package/docs/verification/agy/README.md +17 -0
  43. package/docs/verification/agy/cli-surface.ts +68 -0
  44. package/docs/verification/agy/interactive-bridge.ts +92 -0
  45. package/docs/verification/agy/interactive-session.ts +131 -0
  46. package/docs/verification/agy/launcher-nonce.ts +215 -0
  47. package/docs/verification/agy/native-hooks.ts +210 -0
  48. package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
  49. package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
  50. package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
  51. package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
  52. package/docs/verification/agy/originals.json +25 -0
  53. package/docs/verification/agy/permission-new-functions.ts +128 -0
  54. package/docs/verification/agy/run-probe.py +108 -0
  55. package/docs/verification/agy/runtime.ts +171 -0
  56. package/docs/verification/agy/tmux-helper-control.ts +6 -0
  57. package/docs/verification/agy/tmux-session.ts +235 -0
  58. package/docs/verified.json +82 -41
  59. package/package.json +3 -3
  60. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  61. package/plugins/agent-hub/compat.json +157 -0
  62. package/plugins/agent-hub/kimi-hook.js +621 -865
  63. package/plugins/agent-hub/server.js +17423 -32962
  64. package/src/adapters/agy/definition.ts +7 -24
  65. package/src/adapters/channel-peer.ts +3 -1
  66. package/src/adapters/claude-channel.ts +38 -257
  67. package/src/adapters/claude-implementer.ts +3 -1
  68. package/src/adapters/codex-appserver.ts +77 -15
  69. package/src/adapters/compat.ts +74 -11
  70. package/src/adapters/configured-acp.ts +23 -163
  71. package/src/adapters/configured-adapter-policy.ts +160 -0
  72. package/src/adapters/configured-pull-entry.ts +53 -0
  73. package/src/adapters/configured-pull.ts +38 -0
  74. package/src/adapters/conformance/fakes/app-server.ts +9 -2
  75. package/src/adapters/declaration-catalog.ts +25 -0
  76. package/src/adapters/declaration-data.ts +342 -0
  77. package/src/adapters/declaration-resolution.ts +53 -0
  78. package/src/adapters/definitions/builtin-metadata.ts +61 -83
  79. package/src/adapters/definitions/jcode-launch.ts +13 -0
  80. package/src/adapters/definitions/native-adapter-policy.ts +390 -0
  81. package/src/adapters/definitions/native-cli-claude-launch.ts +3 -2
  82. package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
  83. package/src/adapters/definitions/native-cli-entry-jcode.ts +4 -2
  84. package/src/adapters/definitions/native-cli-entry-types.ts +9 -2
  85. package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
  86. package/src/adapters/definitions/native-cli-retained.ts +1 -1
  87. package/src/adapters/definitions/native-configuration.ts +18 -0
  88. package/src/adapters/definitions/native-help.ts +24 -0
  89. package/src/adapters/definitions/native-launch-declarations.ts +34 -0
  90. package/src/adapters/definitions/native-launch-policy.ts +4 -0
  91. package/src/adapters/definitions/native-launch-settings.ts +72 -0
  92. package/src/adapters/definitions/native-light-cli.ts +18 -0
  93. package/src/adapters/definitions/native-light-preview.ts +10 -0
  94. package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
  95. package/src/adapters/definitions/qwen.ts +6 -29
  96. package/src/adapters/definitions/reviewer-variants.ts +7 -8
  97. package/src/adapters/external-declarations.ts +31 -0
  98. package/src/adapters/external-modules.ts +4 -29
  99. package/src/adapters/jcode.ts +3 -12
  100. package/src/adapters/native-capabilities.ts +18 -8
  101. package/src/adapters/native-proof-ports.ts +1 -1
  102. package/src/adapters/presets.ts +136 -0
  103. package/src/adapters/qwen-dual.ts +2 -2
  104. package/src/adapters/registry-types.ts +3 -0
  105. package/src/adapters/registry.ts +20 -81
  106. package/src/adapters/reviewer-print.ts +26 -9
  107. package/src/adapters/role-eligibility.ts +2 -1
  108. package/src/cli/accounts-import.ts +72 -0
  109. package/src/cli/agents-latest-table.ts +88 -0
  110. package/src/cli/agents-latest.ts +22 -0
  111. package/src/cli/agents-output.ts +10 -0
  112. package/src/cli/agents-presets.ts +100 -0
  113. package/src/cli/agents.ts +1 -1
  114. package/src/cli/attention.ts +3 -2
  115. package/src/cli/autonomy-homes.ts +7 -2
  116. package/src/cli/budget-renew-guidance.ts +129 -0
  117. package/src/cli/claude-homes.ts +9 -5
  118. package/src/cli/command-context.ts +3 -0
  119. package/src/cli/command-table.ts +123 -0
  120. package/src/cli/commands/accounts.ts +8 -0
  121. package/src/cli/commands/agents.ts +18 -0
  122. package/src/cli/commands/answer.ts +28 -0
  123. package/src/cli/commands/ask.ts +17 -0
  124. package/src/cli/commands/autonomy.ts +83 -0
  125. package/src/cli/commands/backlog.ts +46 -0
  126. package/src/cli/commands/bench.ts +60 -0
  127. package/src/cli/commands/board.ts +48 -0
  128. package/src/cli/commands/broker.ts +9 -0
  129. package/src/cli/commands/budget.ts +96 -0
  130. package/src/cli/commands/capabilities.ts +12 -0
  131. package/src/cli/commands/check-path.ts +55 -0
  132. package/src/cli/commands/completion.ts +8 -0
  133. package/src/cli/commands/console.ts +12 -0
  134. package/src/cli/commands/daemon.ts +8 -0
  135. package/src/cli/commands/deliverables.ts +25 -0
  136. package/src/cli/commands/doctor.ts +249 -0
  137. package/src/cli/commands/down.ts +3 -0
  138. package/src/cli/commands/export.ts +15 -0
  139. package/src/cli/commands/facts.ts +15 -0
  140. package/src/cli/commands/goal.ts +22 -0
  141. package/src/cli/commands/guidance.ts +102 -0
  142. package/src/cli/commands/help.ts +17 -0
  143. package/src/cli/commands/host.ts +45 -0
  144. package/src/cli/commands/init.ts +121 -0
  145. package/src/cli/commands/instructed.ts +19 -0
  146. package/src/cli/commands/instruction-hook.ts +15 -0
  147. package/src/cli/commands/intake.ts +24 -0
  148. package/src/cli/commands/kill.ts +15 -0
  149. package/src/cli/commands/learn.ts +23 -0
  150. package/src/cli/commands/lineage.ts +30 -0
  151. package/src/cli/commands/logs.ts +21 -0
  152. package/src/cli/commands/manager.ts +15 -0
  153. package/src/cli/commands/memory.ts +21 -0
  154. package/src/cli/commands/model.ts +25 -0
  155. package/src/cli/commands/models.ts +40 -0
  156. package/src/cli/commands/native.ts +39 -0
  157. package/src/cli/commands/pause.ts +5 -0
  158. package/src/cli/commands/peer.ts +32 -0
  159. package/src/cli/commands/permission.ts +26 -0
  160. package/src/cli/commands/permit.ts +12 -0
  161. package/src/cli/commands/pet.ts +24 -0
  162. package/src/cli/commands/projects.ts +49 -0
  163. package/src/cli/commands/queue.ts +70 -0
  164. package/src/cli/commands/recovery-run.ts +13 -0
  165. package/src/cli/commands/recovery.ts +130 -0
  166. package/src/cli/commands/release.ts +23 -0
  167. package/src/cli/commands/releases.ts +9 -0
  168. package/src/cli/commands/remember.ts +6 -0
  169. package/src/cli/commands/report.ts +27 -0
  170. package/src/cli/commands/research.ts +53 -0
  171. package/src/cli/commands/reset.ts +89 -0
  172. package/src/cli/commands/restart.ts +5 -0
  173. package/src/cli/commands/results.ts +31 -0
  174. package/src/cli/commands/resume.ts +5 -0
  175. package/src/cli/commands/review.ts +24 -0
  176. package/src/cli/commands/roadmap.ts +21 -0
  177. package/src/cli/commands/role.ts +34 -0
  178. package/src/cli/commands/roles.ts +30 -0
  179. package/src/cli/commands/room.ts +14 -0
  180. package/src/cli/commands/roster.ts +48 -0
  181. package/src/cli/commands/route.ts +9 -0
  182. package/src/cli/commands/say.ts +21 -0
  183. package/src/cli/commands/schedule.ts +17 -0
  184. package/src/cli/commands/sdlc.ts +321 -0
  185. package/src/cli/commands/settings.ts +148 -0
  186. package/src/cli/commands/setup.ts +89 -0
  187. package/src/cli/commands/shared-refusals.ts +25 -0
  188. package/src/cli/commands/smoke.ts +44 -0
  189. package/src/cli/commands/source.ts +64 -0
  190. package/src/cli/commands/specs.ts +13 -0
  191. package/src/cli/commands/status.ts +28 -0
  192. package/src/cli/commands/stop.ts +17 -0
  193. package/src/cli/commands/structure.ts +60 -0
  194. package/src/cli/commands/study.ts +39 -0
  195. package/src/cli/commands/tail.ts +19 -0
  196. package/src/cli/commands/task.ts +114 -0
  197. package/src/cli/commands/title.ts +17 -0
  198. package/src/cli/commands/turns.ts +10 -0
  199. package/src/cli/commands/ui.ts +47 -0
  200. package/src/cli/commands/undo.ts +77 -0
  201. package/src/cli/commands/up.ts +39 -0
  202. package/src/cli/commands/upgrade.ts +5 -0
  203. package/src/cli/commands/usage.ts +33 -0
  204. package/src/cli/commands/version.ts +5 -0
  205. package/src/cli/commands/watch.ts +30 -0
  206. package/src/cli/commands/worktrees.ts +31 -0
  207. package/src/cli/console-state.ts +5 -138
  208. package/src/cli/console-versions.ts +1 -1
  209. package/src/cli/help.ts +37 -15
  210. package/src/cli/identity.ts +23 -4
  211. package/src/cli/launch-check.ts +1 -2
  212. package/src/cli/launch.ts +13 -82
  213. package/src/cli/light-dispatch.ts +29 -0
  214. package/src/cli/main.js +8 -1
  215. package/src/cli/main.ts +233 -2816
  216. package/src/cli/orca-probe.ts +119 -0
  217. package/src/cli/output.ts +31 -2
  218. package/src/cli/preview.ts +10 -5
  219. package/src/cli/recovery-version-preflight.ts +28 -9
  220. package/src/cli/replace-process.ts +22 -0
  221. package/src/cli/report-layout.ts +142 -0
  222. package/src/cli/roadmap-usage.ts +16 -0
  223. package/src/cli/roadmap.ts +3 -16
  224. package/src/cli/sdlc-doctor.ts +27 -0
  225. package/src/cli/sdlc-output.ts +55 -1
  226. package/src/cli/setup-homes.ts +1 -1
  227. package/src/cli/start-agents-run.ts +1 -1
  228. package/src/cli/statusline-tee.ts +25 -4
  229. package/src/cli/terminal-recovery.ts +53 -10
  230. package/src/cli/upgrade-interactive.ts +1 -0
  231. package/src/cli/upgrade-runtime.ts +11 -0
  232. package/src/cli/upgrade.ts +4 -15
  233. package/src/hub/accounts.ts +148 -0
  234. package/src/hub/addons.ts +20 -0
  235. package/src/hub/agent-drift.ts +2 -1
  236. package/src/hub/budget-projection.ts +39 -7
  237. package/src/hub/budget.ts +231 -16
  238. package/src/hub/channel-project.ts +3 -3
  239. package/src/hub/conductor-peer.ts +24 -0
  240. package/src/hub/conductor.ts +2 -21
  241. package/src/hub/config-apply.ts +24 -13
  242. package/src/hub/config-edit.ts +1 -1
  243. package/src/hub/config-tier.ts +2 -0
  244. package/src/hub/config.ts +31 -14
  245. package/src/hub/control-client.ts +48 -0
  246. package/src/hub/daemon.ts +421 -61
  247. package/src/hub/events.ts +3 -0
  248. package/src/hub/home-tag.ts +12 -0
  249. package/src/hub/host.ts +217 -0
  250. package/src/hub/hub-tools.ts +2 -1
  251. package/src/hub/instance-budget.ts +2 -2
  252. package/src/hub/instance-config.ts +15 -126
  253. package/src/hub/instances.ts +22 -6
  254. package/src/hub/instruction-receipt.ts +2 -2
  255. package/src/hub/kimi-usage.ts +38 -11
  256. package/src/hub/lifecycle.ts +86 -4
  257. package/src/hub/mcp-bridge-core.ts +98 -0
  258. package/src/hub/mcp-channel-push.ts +20 -0
  259. package/src/hub/mcp-endpoint-serve.ts +178 -0
  260. package/src/hub/mcp-endpoint.ts +226 -0
  261. package/src/hub/mcp-tool-call.ts +181 -0
  262. package/src/hub/operational-settings.ts +2 -0
  263. package/src/hub/orca-env.ts +6 -0
  264. package/src/hub/orca-state.ts +84 -0
  265. package/src/hub/peers.ts +5 -1
  266. package/src/hub/permission-mode.ts +2 -1
  267. package/src/hub/project.ts +20 -0
  268. package/src/hub/protocol-window.ts +58 -0
  269. package/src/hub/quota-origin.ts +20 -0
  270. package/src/hub/registry.ts +36 -2
  271. package/src/hub/report.ts +1 -1
  272. package/src/hub/research.ts +1 -1
  273. package/src/hub/review-brief.ts +47 -2
  274. package/src/hub/roster.ts +6 -3
  275. package/src/hub/routing.ts +9 -2
  276. package/src/hub/sdlc-check.ts +205 -0
  277. package/src/hub/sdlc-sync.ts +146 -0
  278. package/src/hub/sdlc.ts +33 -4
  279. package/src/hub/settings.ts +7 -4
  280. package/src/hub/start-agents.ts +1 -1
  281. package/src/hub/start-mode.ts +11 -4
  282. package/src/hub/structure-budget.ts +131 -0
  283. package/src/hub/structure-scan.ts +149 -0
  284. package/src/hub/tasks-experiment.ts +455 -0
  285. package/src/hub/tasks-guidance.ts +606 -0
  286. package/src/hub/tasks-roadmap-plan.ts +419 -0
  287. package/src/hub/tasks-roadmap.ts +491 -0
  288. package/src/hub/tasks-study.ts +661 -0
  289. package/src/hub/tasks-survey.ts +192 -0
  290. package/src/hub/tasks.ts +319 -2548
  291. package/src/hub/terminal-open.ts +5 -3
  292. package/src/hub/tooling.ts +3 -19
  293. package/src/hub/usage-rollup.ts +9 -3
  294. package/src/local/tools.ts +5 -0
  295. package/src/ui/index.html +1 -1
  296. package/src/ui/needs.ts +17 -5
  297. package/src/ui/peer-palette.ts +2 -4
  298. package/templates/presets/agents.json +60 -0
  299. package/templates/presets/confirmation-matrix.json +8 -8
@@ -1,10 +1,14 @@
1
1
  import { codexItemActivity } from "./definitions/native-activity.ts";
2
2
  import type { ActivityKind } from "../hub/peer-activity.ts";
3
3
  import { codexAccountUsage, codexQuotaWindowInput } from "./definitions/native-quota.ts";
4
+ import { stampQuotaBoundary, type QuotaStamp } from "../hub/quota-origin.ts";
5
+ import type { QuotaOrigin } from "../hub/budget.ts";
4
6
  import type { QuotaAccountUsage } from "../hub/quota-account.ts";
5
7
  import type { ModelOverrideSelection } from "./registry-types.ts";
6
8
  import { isNativeModelToken } from "./model-token.ts";
7
9
  import { spawn, type ChildProcess } from "node:child_process";
10
+ import { isAbsolute, join } from "node:path";
11
+ import { realPath } from "../hub/project.ts";
8
12
  import type { Server, ServerWebSocket } from "bun";
9
13
  import { renderDigest, replyAudience, replyParent, type Envelope, type PeerId } from "../hub/envelope.ts";
10
14
  import type { PermissionMode } from "../hub/permission-mode.ts";
@@ -15,11 +19,29 @@ import { codexContext, type ContextReading } from "../hub/context-window.ts";
15
19
  import { peerChildEnv, stopOwnedProcess, trackGroup } from "../hub/child-process.ts";
16
20
  import type { ContextReader } from "./registry-types.ts";
17
21
  import type { CapabilityManifest } from "../hub/capabilities.ts";
18
- import { codexSkillsManifest, NATIVE_PINS } from "./native-capabilities.ts";
22
+ import { codexSkillsManifest, listable } from "./native-capabilities.ts";
19
23
  import { ACTION_BUDGET_OPTION, type ActionGateVerdict, type PermissionRequest } from "./acp.ts";
20
24
 
25
+ export function effectiveAppServerHome(env: NodeJS.ProcessEnv): string | undefined {
26
+ const configured = env.CODEX_HOME;
27
+ if (configured?.trim()) return isAbsolute(configured) ? configured : undefined;
28
+ return env.HOME && isAbsolute(env.HOME) ? join(env.HOME, ".codex") : undefined;
29
+ }
30
+
31
+ function compareQuotaHomes(callerHome: string | undefined, ownedHome: string | undefined): "same" | "different" | "unknown" {
32
+ if (!callerHome || !isAbsolute(callerHome) || !ownedHome) return "unknown";
33
+ try { return realPath(callerHome) === realPath(ownedHome) ? "same" : "different"; }
34
+ catch { return "unknown"; }
35
+ }
36
+
37
+ /** For an adapter whose next Codex launch uses the hub's own environment. */
38
+ export function compareNextCodexQuotaHome(peer: string, callerHome: string | undefined): "same" | "different" | "unknown" {
39
+ return compareQuotaHomes(callerHome, effectiveAppServerHome(peerChildEnv(peer)));
40
+ }
41
+
21
42
  // ponytail: paused quota reads use a fixed 60s cadence; a validated operational cadence setting is the upgrade path if tuning is needed.
22
43
  const PAUSED_USAGE_POLL_MS = 60_000;
44
+ const QUOTA_TURN_HISTORY = 128;
23
45
 
24
46
  const UNIDENTIFIED_CANCELLATION_NOTICE = "Codex cancelled turn has no verified native id; reattach the native session before further hub delivery";
25
47
  const PLANNER_SANDBOX_REFUSAL = "Codex planner thread requires a confirmed read-only sandbox";
@@ -60,7 +82,7 @@ export interface CodexOptions {
60
82
  /** Appended to the standing instruction of the first delivery (role contract). */
61
83
  preamble?: string;
62
84
  /** Window-only native fields plus allowlisted account diagnostics; hard means a turn was refused for quota. */
63
- onUsage?: (rateLimits: unknown, hard: boolean, accountUsage?: QuotaAccountUsage) => void;
85
+ onUsage?: (rateLimits: unknown, hard: boolean, accountUsage?: QuotaAccountUsage, origin?: QuotaOrigin) => void;
64
86
  /** Host-only observation of the canonical account pause. It grants no resume authority. */
65
87
  usagePause?: { current(): boolean; subscribe(changed: () => void): () => void };
66
88
  /** Tokens the thread used since the previous update (see `tokenTotal` for how they are counted). */
@@ -136,6 +158,8 @@ export class CodexPeer extends BasePeer {
136
158
  private modelStartSequence = 0;
137
159
  private readonly restoringApprovals = new Map<string | number, string>();
138
160
  private proc: ChildProcess | undefined;
161
+ /** In-memory provenance for a successfully spawned app-server. Never part of status or a restart record. */
162
+ private readonly processLaunch = new WeakMap<ChildProcess, { home?: string; startedAt: number; stamp: QuotaStamp }>();
139
163
  private server: Server<Link> | undefined;
140
164
  private link: Link | undefined; // the connection that owns the current thread
141
165
  /** Claimed as soon as a TUI WebSocket opens, before it can start a thread. */
@@ -157,6 +181,7 @@ export class CodexPeer extends BasePeer {
157
181
  private deliveryEpoch = 0;
158
182
  /** Cancellation tombstones last until that exact native completion or session replacement. */
159
183
  private readonly retiredTurns = new Set<string>();
184
+ private readonly quotaTurnStarts = new Map<string, number>();
160
185
  private unidentifiedCancellation = false;
161
186
  /** Fixed operator guidance only; native identifiers and agent text never enter status. */
162
187
  get statusNotice(): { code: "unidentified-cancellation"; message: string } | undefined {
@@ -510,6 +535,19 @@ export class CodexPeer extends BasePeer {
510
535
  return /turn in progress|no active turn|not injectable|rejected|usage limit/i.test(error.message);
511
536
  }
512
537
 
538
+ private appServerEnv(): NodeJS.ProcessEnv {
539
+ return peerChildEnv(this.id, { ...process.env, ...(this.opts.env ?? {}) });
540
+ }
541
+
542
+ /** Path operands stay local to this adapter; the caller receives only a comparison result. */
543
+ compareQuotaHome(callerHome: string | undefined): "same" | "different" | "unknown" {
544
+ if (this.opts.upstreamUrl || !callerHome || !isAbsolute(callerHome)) return "unknown";
545
+ const proc = this.proc;
546
+ const home = proc && proc.exitCode === null && proc.signalCode === null
547
+ ? this.processLaunch.get(proc)?.home : effectiveAppServerHome(this.appServerEnv());
548
+ return compareQuotaHomes(callerHome, home);
549
+ }
550
+
513
551
  private async spawnAppServer(): Promise<string> {
514
552
  const port = this.opts.appPort;
515
553
  const probe = () => fetch(`http://127.0.0.1:${port}/healthz`).then((r) => r.ok, () => false);
@@ -517,14 +555,20 @@ export class CodexPeer extends BasePeer {
517
555
  throw new Error(`port ${port} already answers /healthz: an app-server the hub does not own is running (orphan from a crashed hub?)`);
518
556
  }
519
557
  let gone = "";
520
- const env = peerChildEnv(this.id, { ...process.env, ...(this.opts.env ?? {}) });
558
+ const env = this.appServerEnv();
559
+ // Fence by spawn issuance. A delayed spawn callback is not evidence that the process started after renewal.
560
+ const startedAt = Date.now(), stamp = stampQuotaBoundary();
521
561
  this.proc = spawn(this.opts.bin ?? "codex", ["app-server", "--listen", `ws://127.0.0.1:${port}`, ...(this.opts.extraArgs ?? [])], {
522
562
  cwd: this.opts.cwd,
523
563
  env,
524
564
  stdio: ["ignore", "ignore", "pipe"],
525
565
  detached: true, // its own process group, stopped as a whole (#113): `codex` is a launcher with a native child
526
566
  });
527
- trackGroup(this.proc);
567
+ const launched = this.proc;
568
+ launched.once("spawn", () => {
569
+ this.processLaunch.set(launched, { home: effectiveAppServerHome(env), startedAt, stamp });
570
+ });
571
+ trackGroup(launched);
528
572
  this.proc.stderr?.on("data", (d) => this.opts.log?.(`[${this.id}] ${String(d).trimEnd()}`));
529
573
  this.proc.on("error", (e) => (gone = `cannot run ${this.opts.bin ?? "codex"}: ${e.message}`));
530
574
  this.proc.on("exit", (code) => {
@@ -567,7 +611,7 @@ export class CodexPeer extends BasePeer {
567
611
  this.onDoing?.("reset");
568
612
  this.contextEpoch++;
569
613
  this.deliveryEpoch++;
570
- this.retiredTurns.clear(); this.unidentifiedCancellation = false;
614
+ this.retiredTurns.clear(); this.quotaTurnStarts.clear(); this.unidentifiedCancellation = false;
571
615
  this.activeTurns.clear();
572
616
  this.unboundAccepted = false;
573
617
  for (const p of this.pending.values()) {
@@ -895,7 +939,7 @@ export class CodexPeer extends BasePeer {
895
939
  this.onDoing?.("reset");
896
940
  this.contextEpoch++;
897
941
  this.deliveryEpoch++;
898
- this.retiredTurns.clear(); this.unidentifiedCancellation = false;
942
+ this.retiredTurns.clear(); this.quotaTurnStarts.clear(); this.unidentifiedCancellation = false;
899
943
  this.activeTurns.clear();
900
944
  this.unboundAccepted = false;
901
945
  this.forgetTurn();
@@ -923,11 +967,11 @@ export class CodexPeer extends BasePeer {
923
967
  revertTurn(nativeTurn: string): Promise<void> { return this.revert(nativeTurn); }
924
968
 
925
969
  /**
926
- * #445 C1: `skills/list` through the attached connection with a hub id (the answer never reaches the TUI). Only the probed version lists (C0 proved 0.166.0;
927
- * the pin is older, so a pinned install lists nothing until a receipt covers it). Offline, unattached or unanswered rejects: the caller shows no list, never a stale one.
970
+ * #445 C1: `skills/list` through the attached connection with a hub id (the answer never reaches the TUI). Only a verified version, or an exact version the person trusted with `ahub agents trust`, lists (C0 proved 0.166.0;
971
+ * the pin is older, so a pinned install lists nothing until a receipt covers it or the person trusts it). Offline, unattached or unanswered rejects: the caller shows no list, never a stale one.
928
972
  */
929
973
  capabilityManifest(): Promise<CapabilityManifest> {
930
- if (this.version !== NATIVE_PINS.codex.version) return Promise.resolve({ capabilities: [], observedAt: Date.now() });
974
+ if (!listable("codex-capabilities", this.version)) return Promise.resolve({ capabilities: [], observedAt: Date.now() });
931
975
  const link = this.link;
932
976
  if (this.state === "offline" || !link || link.up.readyState !== WebSocket.OPEN) return Promise.reject(new Error(`${this.id} has no attached app-server`));
933
977
  const id = this.nextId--;
@@ -968,9 +1012,18 @@ export class CodexPeer extends BasePeer {
968
1012
  this.readUsage(); schedule();
969
1013
  }
970
1014
 
1015
+ private quotaOrigin(): QuotaOrigin | undefined {
1016
+ const launch = this.proc && this.processLaunch.get(this.proc);
1017
+ return launch && { processStartedAt: launch.startedAt, processStamp: launch.stamp };
1018
+ }
1019
+
1020
+ readQuotaNow(): void {
1021
+ this.readUsage();
1022
+ }
1023
+
971
1024
  /** account/rateLimits/read through the TUI's connection; late replies never escape or update a replacement input. */
972
1025
  private readUsage(): void {
973
- const link = this.link, epoch = this.usageEpoch;
1026
+ const link = this.link, epoch = this.usageEpoch, proc = this.proc, origin = this.quotaOrigin();
974
1027
  if (this.usageStopped || !this.opts.onUsage || !link || link.up.readyState !== WebSocket.OPEN) return;
975
1028
  const id = this.nextId--;
976
1029
  const finish = () => { clearTimeout(this.usageRequests.get(id)); this.usageRequests.delete(id); };
@@ -978,18 +1031,22 @@ export class CodexPeer extends BasePeer {
978
1031
  timer.unref?.(); this.usageRequests.set(id, timer);
979
1032
  this.pending.set(id, { resolve: result => {
980
1033
  finish();
981
- if (!this.usageStopped && this.link === link && this.usageEpoch === epoch)
982
- this.opts.onUsage?.(codexQuotaWindowInput(result?.rateLimits), false, codexAccountUsage(result));
1034
+ if (!this.usageStopped && this.link === link && this.usageEpoch === epoch && this.proc === proc)
1035
+ this.opts.onUsage?.(codexQuotaWindowInput(result?.rateLimits), false, codexAccountUsage(result), origin);
983
1036
  }, reject: finish });
984
1037
  try { link.up.send(JSON.stringify({ method: "account/rateLimits/read", id })); }
985
1038
  catch { finish(); this.pending.delete(id); }
986
1039
  }
987
1040
 
988
1041
  private onNotification(link: Link, method: string, params: any): void {
989
- // Account-level notifications carry no threadId.
990
- if (link === this.link && method === "account/rateLimits/updated") return void this.opts.onUsage?.(codexQuotaWindowInput(params.rateLimits), false);
1042
+ // Account notifications carry no threadId. An account update is a hint to read quota from the current link.
1043
+ if (link === this.link && method === "account/updated") return this.readUsage();
1044
+ if (link === this.link && method === "account/rateLimits/updated") return void this.opts.onUsage?.(codexQuotaWindowInput(params.rateLimits), false, undefined, this.quotaOrigin());
991
1045
  if (link === this.link && method === "error" && params.error?.codexErrorInfo === "usageLimitExceeded") {
992
- this.opts.onUsage?.({ rateLimitReachedType: "usageLimitExceeded" }, true);
1046
+ const key = typeof params.threadId === "string" && typeof params.turnId === "string" ? `${params.threadId}\0${params.turnId}` : undefined;
1047
+ const turnStartedAt = key ? this.quotaTurnStarts.get(key) : undefined;
1048
+ this.opts.onUsage?.({ rateLimitReachedType: "usageLimitExceeded" }, true, undefined,
1049
+ turnStartedAt === undefined ? undefined : { turnStartedAt, turnStartedAtLatest: turnStartedAt + 999 });
993
1050
  }
994
1051
  if (link !== this.link || params.threadId !== this.threadId) return;
995
1052
  // #878: the bound thread's name and its plan's in-progress step, for the hub's DOING column only.
@@ -1031,6 +1088,11 @@ export class CodexPeer extends BasePeer {
1031
1088
  const nativeTurn = params.turn?.id ?? `unknown:${Date.now()}`;
1032
1089
  this.unboundAccepted = false;
1033
1090
  this.activeTurns.add(nativeTurn);
1091
+ const startedSeconds = params.turn?.startedAt;
1092
+ if (typeof nativeTurn === "string" && typeof startedSeconds === "number" && Number.isSafeInteger(startedSeconds) && startedSeconds > 0) {
1093
+ this.quotaTurnStarts.set(`${this.threadId}\0${nativeTurn}`, startedSeconds * 1000);
1094
+ if (this.quotaTurnStarts.size > QUOTA_TURN_HISTORY) this.quotaTurnStarts.delete(this.quotaTurnStarts.keys().next().value!);
1095
+ }
1034
1096
  for (const id of [...this.unboundDeliveries]) this.addTurnDelivery(nativeTurn, id);
1035
1097
  this.lastAnswer = "";
1036
1098
  this.setState("busy");
@@ -8,8 +8,11 @@ import { hubHome } from "../hub/project.ts";
8
8
  * version constant. `verified` lists versions with a receipt in docs/verification; `line` is a semver window assumed
9
9
  * compatible (contract gates only); a person's trust lets an exact other version through on this machine. An isolation
10
10
  * gate keeps every runtime proof after trust: trust only lifts the version pin.
11
+ * #1808: an `observe` entry is for a surface the hub only watches (a launch flag order, a handshake, an external CLI). It never
12
+ * refuses: no launch decision reads it, the daily watch and `ahub doctor` report a drifted probe, and a version outside `verified`
13
+ * is `observed` with a note.
11
14
  */
12
- export type CompatGate = "contract" | "isolation";
15
+ export type CompatGate = "contract" | "isolation" | "observe";
13
16
  export interface CompatPolicy {
14
17
  label: string;
15
18
  verified: readonly string[];
@@ -23,6 +26,11 @@ export interface CompatPolicy {
23
26
  trustNote: string;
24
27
  /** The last receipt in docs/verification whose model-free procedure a new version repeats (#843). */
25
28
  receipt: string;
29
+ /**
30
+ * #1808: `verified` holds an install reference that no leg proved. The entry must be gate `observe`: `assessVersion` reports every version as `observed`, the reference included,
31
+ * and `describe` says "reference ... (not verified)". The daily watch treats the reference as settled and a newer version as ahead; the publisher never adds a version to it.
32
+ */
33
+ referenceOnly?: true;
26
34
  /** The config key that selects this kind's executable, when one exists. */
27
35
  config?: "codex_bin" | "jcode_cmd" | "qwen_cmd" | "pi.cmd";
28
36
  }
@@ -34,12 +42,12 @@ export const COMPAT = {
34
42
  parse: out => plain(out.trim()),
35
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.",
36
44
  receipt: "docs/verification/2026-11-26-compat-pi-1.6.1.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"],
45
+ // 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; host-wrapper receipt below repeats with them.
46
+ "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"], gate: "contract", probe: ["claude", "--version"],
39
47
  parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
40
48
  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-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
49
+ receipt: "docs/verification/2026-12-02-claude-implementer-2.1.334.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
43
51
  "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
52
  parse: out => plain(out.trim().replace(/^codex-cli /, "")),
45
53
  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).",
@@ -56,14 +64,50 @@ export const COMPAT = {
56
64
  parse: out => plain(out.trim()),
57
65
  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.",
58
66
  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.
69
+ "kimi-capabilities": { label: "Kimi capability listing", verified: ["2.3.2"], gate: "contract", probe: ["kimi", "--version"],
70
+ parse: out => plain(out.trim()),
71
+ 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.",
72
+ receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
73
+ "qwen-capabilities": { label: "Qwen capability listing", verified: ["0.26.1"], gate: "contract", probe: ["qwen", "--version"], config: "qwen_cmd",
74
+ parse: out => plain(out.trim()),
75
+ 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
+ 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
+ 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" },
81
+ // #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
+ // 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
+ "codex-appserver": { label: "Codex app-server handshake", verified: ["0.166.0"], gate: "observe", probe: ["codex", "--version"], config: "codex_bin",
84
+ parse: out => plain(out.trim().replace(/^codex-cli /, "")),
85
+ trustNote: "Only the app-server initialize answer of 0.166.0 was probed (no account). This entry is watched, never a gate: another version is reported and nothing is refused.",
86
+ receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
87
+ "kimi-acp": { label: "Kimi ACP handshake", verified: ["2.3.2"], gate: "observe", probe: ["kimi", "--version"],
88
+ parse: out => plain(out.trim()),
89
+ trustNote: "Only the ACP initialize and session/new answers of 2.3.2 were probed (fixture model, no account). This entry is watched, never a gate: another version is reported and nothing is refused.",
90
+ receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
91
+ // ponytail: for this entry `verified` holds an unproven install reference (2.1.332), not a verified version. The upgrade path is allowing an empty `verified` for observe entries, which needs the
92
+ // step-list and verified-length tests changed with the person's permission (test/compat.test.ts "every gated kind declares its verified set", the publisher patcher test and the watch test).
93
+ "claude-channel": { label: "Claude Code channel flag", verified: ["2.1.332"], referenceOnly: true, gate: "observe", probe: ["claude", "--version"],
94
+ parse: out => plain(out.trim().replace(/ \(Claude Code\)$/, "")),
95
+ trustNote: "Watched only, never a gate, and no version is verified (2.1.332 is only the install reference, not something this leg proved). The leg checks that the installed parser still takes the launcher's development-channel flag (it is not named as an unknown option); it does not prove that a live session accepts channel messages. No real Claude parse error is recorded, so a real candidate may always come back not-run.",
96
+ receipt: "docs/verification/2026-11-30-capability-listing-shape-1808.md" },
97
+ // #1808 T4: the Orca CLI is an external contract the upgrade recovery depends on (src/cli/terminal-recovery.ts). It is watched, never a gate: no start or restore path reads this entry to refuse anything. `ahub doctor` and the upgrade
98
+ // preflight run a local shape probe (src/cli/orca-probe.ts) and the daily watch lists a newer public release. Receipts: docs/verification/2026-11-02-orca-1.4.245-cli-contract.md and docs/verification/2026-11-06-orca-1.4.250-cli-contract.md.
99
+ "orca-cli": { label: "Orca CLI", verified: ["1.4.245", "1.4.250"], gate: "observe", probe: ["orca", "--version"],
100
+ parse: out => plain(out.trim()),
101
+ trustNote: "Only read-only commands were checked on 1.4.245 and 1.4.250: terminal list, show and wait, and worktree current. Create, close and switch commands stay unchecked. This entry is watched, never a gate: another version is reported and nothing is refused.",
102
+ receipt: "docs/verification/2026-11-06-orca-1.4.250-cli-contract.md" },
59
103
  jcode: { label: "Jcode", verified: ["0.98.1", "0.99.0", "0.99.1", "1.0.3"], line: { min: "0.98.0", below: "1.1.0" }, gate: "contract", probe: ["jcode", "--quiet", "version", "--json"], config: "jcode_cmd",
60
104
  parse: out => { try { const v = JSON.parse(out).semver; return typeof v === "string" ? plain(v) : undefined; } catch { return undefined; } },
61
105
  trustNote: "The ACP, serve and MCP contract was verified on 0.98.1, 0.99.1 and 1.0.3, steering on 0.99.0, 0.99.1 and 1.0.3, and a hub delivery was acknowledged on 1.0.3; an untested version inside the line may change them. A real account, provider or model, the TUI form and Linux builds stay unverified.",
62
106
  receipt: "docs/verification/2026-11-22-jcode-1.0.3.md" },
63
- agy: { label: "agy", verified: ["1.4.2", "1.4.7", "1.4.12", "1.5.3"], line: { min: "1.4.0", below: "1.5.0" }, gate: "contract", probe: ["agy", "--version"],
107
+ agy: { label: "agy", verified: ["1.4.2", "1.4.7", "1.4.12", "1.5.3", "1.5.21"], line: { min: "1.4.0", below: "1.5.0" }, gate: "contract", probe: ["agy", "--version"],
64
108
  parse: out => plain(out.trim()),
65
- trustNote: "Exact 1.5.3 repeats the account-free CLI/plugin MCP, hooks, normal close and actual-launcher nonce legs; existing 1.4.x verified receipts remain unchanged. Other 1.5.x versions, real model/account behavior, headless ACP and native permission mappings remain unverified.",
66
- receipt: "docs/verification/2026-11-08-agy-1.5.3.md" },
109
+ trustNote: "Exact 1.5.3 and 1.5.21 repeat the account-free CLI/plugin MCP, hooks, normal close and actual-launcher nonce legs; 1.5.21 also shows that the provider declarations run_workflow, swarm and update_steps reach the PreToolUse hook and are refused natively with no effect. Existing 1.4.x verified receipts remain unchanged. Other 1.5.x versions, real model/account behavior, headless ACP and native permission mappings remain unverified.",
110
+ receipt: "docs/verification/2026-12-02-agy-1.5.21.md" },
67
111
  // Receipt: docs/verification/2026-11-22-qwen-0283-acp.md (0.27.1 and 0.28.3).
68
112
  qwen: { label: "Qwen Code", verified: ["0.25.0", "0.26.0", "0.26.1", "0.26.4", "0.26.5", "0.26.8", "0.26.9", "0.27.0", "0.27.1", "0.28.3"], gate: "contract", probe: ["qwen", "--version"], config: "qwen_cmd",
69
113
  parse: out => plain(out.trim()),
@@ -77,6 +121,22 @@ export const COMPAT = {
77
121
  receipt: "docs/verification/2026-11-22-qwen-0283-dual-output.md" },
78
122
  } as const satisfies Record<string, CompatPolicy>;
79
123
  export type CompatId = keyof typeof COMPAT;
124
+ /** #1808: a `referenceOnly` entry must be gate `observe`. Run once over the table below, and by the test over a bad one. */
125
+ export function referenceOnlyProblems(table: Record<string, CompatPolicy>): string[] {
126
+ return Object.entries(table).filter(([, policy]) => policy.referenceOnly === true && policy.gate !== "observe").map(([id]) => id);
127
+ }
128
+ const referenceOnlyBad = referenceOnlyProblems(COMPAT);
129
+ if (referenceOnlyBad.length) throw new Error(`COMPAT referenceOnly needs gate observe: ${referenceOnlyBad.join(", ")}`);
130
+
131
+ /**
132
+ * #1808: exact versions that decide something other than a launch gate. They live here so no other file holds a native CLI version, and they are
133
+ * deliberately NOT `COMPAT` entries: a person's trust, a `line` or an `observe` gate would widen a model setter and an instruction receipt.
134
+ * Each check is an exact `includes` or `===` on the observed version and never goes through `assessVersion`.
135
+ */
136
+ /** The Kimi version whose `set_config_option` model setter has a receipt (docs/verification/2026-11-08-kimi-252-model-setter-1317.md). */
137
+ export const KIMI_SETTER_VERSION = "2.5.2";
138
+ /** The Claude versions whose transcript record shape the instruction receipt was probed on. */
139
+ export const INSTRUCTION_PROBED_VERSIONS: readonly string[] = Object.freeze(["2.1.328", "2.1.329"]);
80
140
  type CommandConfig = { codex_bin: string; jcode_cmd: string[]; qwen_cmd: string[]; pi?: { cmd: string[] } };
81
141
  /** The configured executables the native gates use; the rest probe their PATH default. */
82
142
  export function configuredCommands(config: CommandConfig): Partial<Record<CompatId, readonly string[]>> {
@@ -91,7 +151,7 @@ export function configuredCommands(config: CommandConfig): Partial<Record<Compat
91
151
  export const isCompatId = (id: unknown): id is CompatId => typeof id === "string" && Object.hasOwn(COMPAT, id);
92
152
 
93
153
  export type CompatVerdict =
94
- | { ok: true; state: "verified" | "in-line" | "trusted"; version: string; note?: string }
154
+ | { ok: true; state: "verified" | "in-line" | "trusted" | "observed"; version: string; note?: string }
95
155
  | { ok: false; state: "refused" | "unknown"; version?: string; reason: string };
96
156
 
97
157
  const parts = (v: string) => /^(\d+)\.(\d+)\.(\d+)$/.exec(v)?.slice(1).map(Number);
@@ -110,18 +170,21 @@ function lineText(line: { min: string; below: string }): string {
110
170
  }
111
171
  export function describe(id: CompatId): string {
112
172
  const p: CompatPolicy = COMPAT[id];
113
- return `verified ${p.verified.join(", ")}${p.line ? `; compatible: ${lineText(p.line)}` : ""}`;
173
+ return `${p.referenceOnly ? `reference ${p.verified.join(", ")} (not verified)` : `verified ${p.verified.join(", ")}`}${p.line ? `; compatible: ${lineText(p.line)}` : ""}`;
114
174
  }
115
175
 
116
176
  /** `trusted` defaults to this machine's record; tests and the CLI pass their own. */
117
177
  export function assessVersion(id: CompatId, observed: unknown, trusted: readonly TrustEntry[] = readTrust()): CompatVerdict {
118
178
  const policy: CompatPolicy = COMPAT[id];
119
179
  const version = typeof observed === "string" ? plain(observed) : undefined;
180
+ if (!version && policy.gate === "observe") return { ok: true, state: "observed", version: "unknown", note: `${policy.label} version could not be read; nothing is refused` };
120
181
  if (!version) return { ok: false, state: "unknown", reason: `${VERSION_REFUSAL}${policy.label} version unknown (${describe(id)}); check that the executable runs` };
182
+ if (policy.referenceOnly) return { ok: true, state: "observed", version, note: `${policy.label} ${version} is watched; ${policy.verified.join(", ")} is only a reference version, not verified; nothing is refused` };
121
183
  if (policy.verified.includes(version)) return { ok: true, state: "verified", version };
184
+ if (policy.gate === "observe") return { ok: true, state: "observed", version, note: `${policy.label} ${version} is watched, not verified (${describe(id)}); nothing is refused` };
122
185
  if (trusted.some(entry => entry.id === id && entry.version === version)) return { ok: true, state: "trusted", version, note: `${policy.label} ${version} is untested; trusted on this machine by the person` };
123
186
  if (policy.gate === "contract" && inLine(version, policy.line)) return { ok: true, state: "in-line", version, note: `${policy.label} ${version} is untested (${describe(id)}); launching on the compatible line` };
124
- return { ok: false, state: "refused", version, reason: `${VERSION_REFUSAL}${policy.label} ${version} (${describe(id)}). Install a verified version, or accept this one on this machine with: ahub agents trust ${id} ${version}` };
187
+ return { ok: false, state: "refused", version, reason: `${VERSION_REFUSAL}${policy.label} ${version} (${describe(id)}). Install a verified version, or accept this one on this machine with: ahub agents trust ${id} ${version} (ahub agents --latest says which release verifies it)` };
125
188
  }
126
189
 
127
190
  export interface TrustEntry { id: CompatId; version: string; at: number }
@@ -1,167 +1,27 @@
1
1
  import { ACP_ACTIVITY } from "./definitions/native-activity.ts";
2
- import { basename } from "node:path";
3
- import { types } from "node:util";
4
- import { AcpPeer } from "./acp.ts";
5
- import { ConfiguredPrintPeer, type ConfiguredPrintAdapterConfig } from "./configured-print.ts";
6
- import type { AdapterDefinition } from "./registry-types.ts";
7
- import type { PermissionMode } from "../hub/permission-mode.ts";
8
- import { shellQuote } from "../cli/shell-quote.ts";
2
+ import { compileConfiguredDefinitions, type ConfiguredRuntimeFactories } from "./declaration-data.ts";
3
+ export { declaredConfiguredFactory } from "./declaration-data.ts";
4
+ export { CONFIGURED_ACP_RESERVED_COMMANDS, type ConfiguredAdapterConfig } from "./configured-adapter-policy.ts";
9
5
 
10
- interface ConfiguredAcpAdapterConfig {
11
- transport: "acp";
12
- command: string;
13
- args?: readonly string[];
14
- displayName: string;
15
- roles: readonly string[];
16
- identity?: { name: string; version: string };
17
- permission?: Partial<Record<PermissionMode, string>>;
18
- readOnly?: string;
19
- }
20
- export type ConfiguredAdapterConfig = ConfiguredAcpAdapterConfig | ConfiguredPrintAdapterConfig;
21
-
22
- const fail = (field: string, reason: string): never => { throw new Error(`${field}: ${reason}`); };
23
- /** Core command namespace is reserved; configured kinds cannot shadow operational CLI actions. */
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"]);
25
- const MODES = ["ask", "ask-when-needed", "never-ask"];
26
- const ROLES = ["planner", "implementer", "verifier", "reviewer"];
27
- function fields(raw: unknown, at: string): Record<string, PropertyDescriptor> {
28
- if (!raw || typeof raw !== "object" || types.isProxy(raw) || Array.isArray(raw) || ![Object.prototype, null].includes(Object.getPrototypeOf(raw)) || Object.getOwnPropertySymbols(raw).length) return fail(at, "must be a plain own-data object");
29
- const result: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
30
- if (Object.values(result).some(d => !Object.hasOwn(d, "value") || !d.enumerable)) return fail(at, "enumerable data fields required");
31
- return result;
32
- }
33
- function text(raw: unknown, at: string, max = 4096): string {
34
- if (typeof raw !== "string" || !raw.trim() || Buffer.byteLength(raw) > max || /[\p{Cc}\p{Cf}]/u.test(raw)) return fail(at, `must be nonempty control-free text of at most ${max} bytes`);
35
- return raw;
36
- }
37
- function list(raw: unknown, at: string, max: number): string[] {
38
- if (!Array.isArray(raw) || types.isProxy(raw) || Object.getPrototypeOf(raw) !== Array.prototype || Object.getOwnPropertySymbols(raw).length) return fail(at, "must be a string array");
39
- const descriptors: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
40
- const length = descriptors.length?.value;
41
- if (!Number.isSafeInteger(length) || length > max || Object.keys(descriptors).length !== length + 1) return fail(at, "array is sparse or too large");
42
- return Array.from({ length }, (_, index) => {
43
- const d = descriptors[String(index)];
44
- if (!d || !Object.hasOwn(d, "value") || !d.enumerable) return fail(at, "array data fields required");
45
- return text(d.value, `${at}.${index}`);
46
- });
47
- }
48
- function freeze<T>(value: T): T {
49
- if (value && typeof value === "object") { for (const item of Object.values(value)) freeze(item); Object.freeze(value); }
50
- return value;
51
- }
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
- }
6
+ const factories: ConfiguredRuntimeFactories = {
7
+ print: declaration => context => {
8
+ if (!("configuredPrint" in context.daemon)) throw new Error("configured print transport options required");
9
+ const { ConfiguredPrintPeer } = require("./configured-print.ts") as typeof import("./configured-print.ts");
10
+ return new ConfiguredPrintPeer(context.instance, { ...context.daemon.configuredPrint, declaration });
11
+ },
12
+ acp: ({ kind, argv, identity, readOnly, nativePolicy }) => context => {
13
+ if (!("acp" in context.daemon)) throw new Error(`${kind}: ACP transport options required`);
14
+ if (context.permission === "read-only" && !readOnly) throw new Error(`${kind}: read-only native mode is not configured`);
15
+ if (!identity) throw new Error(`${kind}: native identity is unverified; configure the observed name/version pin before starting`);
16
+ const { AcpPeer } = require("./acp.ts") as typeof import("./acp.ts");
17
+ return new AcpPeer(context.instance, { ...context.daemon.acp, kind, cmd: [...argv], qwen025: false,
18
+ expectedAgent: identity, requireLoadSessionEcho: true, requireOwnedGroup: true,
19
+ activityKinds: ACP_ACTIVITY,
20
+ permissionMode: context.permission === "read-only" ? "ask" : context.permission,
21
+ nativePolicy: { ...nativePolicy, lockedReadOnly: context.permission === "read-only" }, mcpServers: context.mcpServers });
22
+ },
23
+ };
89
24
 
90
- /** Pure local declaration compiler; file provenance and runtime process ownership remain host checks. */
91
- export function configuredAcpDefinitions(raw: unknown, builtinKinds: readonly string[]): readonly AdapterDefinition[] {
92
- if (raw === undefined) return Object.freeze([]);
93
- const declarations = fields(raw, "adapters");
94
- if (Object.keys(declarations).length > 64) return fail("adapters", "at most 64 configured kinds supported");
95
- const reserved = new Set([...builtinKinds, ...CONFIGURED_ACP_RESERVED_COMMANDS, "user", "hub", "digest", "constructor", "prototype", "__proto__"]);
96
- return Object.freeze(Object.entries(declarations).map(([kind, descriptor]) => {
97
- const at = `adapters.${kind}`;
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");
99
- const input = fields(descriptor.value, at);
100
- if (input.transport?.value === "print") return configuredPrintDefinition(kind, input, at);
101
- if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "identity", "permission", "readOnly"].includes(key))) return fail(at, "unknown or privileged field");
102
- if (input.transport?.value !== "acp") return fail(`${at}.transport`, "must be acp or print");
103
- const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
104
- // The supported contract is a foreground owned stdio process, never an attachment/proxy selector.
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");
106
- const displayName = text(input.displayName?.value, `${at}.displayName`, 256), roles = list(input.roles?.value, `${at}.roles`, ROLES.length);
107
- if (roles.includes("conductor")) return fail(`${at}.roles`, "conductor requires explicit project role policy, not adapter defaults");
108
- if (!roles.length || new Set(roles).size !== roles.length || roles.some(role => !ROLES.includes(role))) return fail(`${at}.roles`, "roles must be nonempty, known and unique");
109
- let identity: ConfiguredAcpAdapterConfig["identity"];
110
- if (input.identity) {
111
- const value = fields(input.identity.value, `${at}.identity`);
112
- if (Object.keys(value).some(key => !["name", "version"].includes(key))) return fail(`${at}.identity`, "unknown identity field");
113
- identity = { name: text(value.name?.value, `${at}.identity.name`, 256), version: text(value.version?.value, `${at}.identity.version`, 256) };
114
- }
115
- const grokContract = kind === "grok" || /^grok(?:\.exe)?$/i.test(basename(command)) || identity?.name.toLowerCase() === "grok";
116
- const noLeader = args.indexOf("--no-leader"), endOptions = args.indexOf("--");
117
- if (grokContract && (noLeader < 0 || (endOptions >= 0 && noLeader > endOptions) || args.some(arg => arg.startsWith("--no-leader=")))) {
118
- return fail(`${at}.args`, "Grok requires explicit --no-leader before argv termination; valued opt-outs are unsupported");
119
- }
120
- let modes: ConfiguredAcpAdapterConfig["permission"];
121
- if (input.permission) {
122
- const value = fields(input.permission.value, `${at}.permission`);
123
- modes = {};
124
- for (const [mode, d] of Object.entries(value)) {
125
- if (!MODES.includes(mode)) return fail(`${at}.permission.${mode}`, "unknown hub mode");
126
- modes[mode as PermissionMode] = text(d.value, `${at}.permission.${mode}`, 256);
127
- }
128
- if (!Object.keys(modes).length) modes = undefined; // `permission: {}` maps nothing: unmanaged, exactly like an omitted map
129
- }
130
- const readOnly = input.readOnly ? text(input.readOnly.value, `${at}.readOnly`, 256) : undefined;
131
- const nativePolicy = freeze({ ...(modes ? { modes } : {}), ...(readOnly ? { readOnly } : {}) });
132
- const argv = freeze([command, ...args]);
133
- identity = identity && freeze(identity);
134
- const definition: AdapterDefinition = {
135
- api: 1, kind, family: kind, displayName, transport: "acp", roles, optional: true, defaultOnRoster: false,
136
- trust: { onPrem: false, hubSandboxed: false }, identity: { mcp: "acp-session" }, instances: { mode: "headless" },
137
- start: {
138
- daemonPort: "acp", forms: ["headless"], defaultForm: "headless", conductorStartable: true, hubSwitches: [], ownedFlags: [],
139
- exclusiveStartRefusal: "configured ACP start already in progress; retry after it settles",
140
- preflight: request => request.form !== undefined && request.form !== "headless" ? `${kind}: configured ACP supports headless only`
141
- : !identity ? `${kind}: native identity is unverified; configure the observed name/version pin before starting` : undefined,
142
- launch: context => {
143
- if (context.form !== "headless") throw new Error(`${kind}: configured ACP supports headless only`);
144
- return { cmd: command, args: [...args], metadata: { packageEntrypoint: context.entrypoint, argv: [...argv], command: argv.map(shellQuote).join(" "), env: {} } };
145
- },
146
- create: context => {
147
- if (!("acp" in context.daemon)) throw new Error(`${kind}: ACP transport options required`);
148
- if (context.permission === "read-only" && !readOnly) throw new Error(`${kind}: read-only native mode is not configured`);
149
- if (!identity) throw new Error(`${kind}: native identity is unverified; configure the observed name/version pin before starting`);
150
- return new AcpPeer(context.instance, { ...context.daemon.acp, kind, cmd: [...argv], qwen025: false,
151
- expectedAgent: identity, requireLoadSessionEcho: true, requireOwnedGroup: true,
152
- activityKinds: ACP_ACTIVITY,
153
- permissionMode: context.permission === "read-only" ? "ask" : context.permission,
154
- nativePolicy: { ...nativePolicy, lockedReadOnly: context.permission === "read-only" }, mcpServers: context.mcpServers });
155
- },
156
- conductorStartArgs: args => args.length ? new Error("configured ACP starts accept no launch overrides") : {},
157
- },
158
- permission: { genericAcp: nativePolicy, grants: Object.fromEntries(MODES.map(mode => [mode, modes?.[mode as PermissionMode] ? `${kind}: asks native ACP to select configured ${mode} mode; native tool policy applies; NO hub sandbox` : `${kind}: no configured native mapping for ${mode}; NO hub sandbox`])), ...(!modes || !Object.keys(modes).length ? { unmanaged: `${kind}: native policy unmanaged; no configured permission map; NO hub sandbox` } : {}) },
159
- // ponytail: configured ACP has no verified controlled-recovery driver. Add catalog-bound restoration
160
- // with native session/group receipts before enabling controlled recovery; explicit/crash load stays fenced.
161
- session: { idField: "sessionId", currentId: peer => { const id = peer.recoveryMetadata?.().sessionId; return typeof id === "string" ? id : undefined; }, launchKind: "acp", resumeById: true, recoveryRefusal: () => "configured ACP has no verified controlled-recovery driver; stop it explicitly and restart with its recorded native session id" },
162
- turnEnd: "adapter", cli: { command: kind, launchConfigKeys: [`adapters.${kind}.command`, `adapters.${kind}.args`], startWords: () => [kind] },
163
- display: { palette: { fg: "white", bg: "black" } },
164
- };
165
- return freeze(definition);
166
- }));
25
+ export function configuredAcpDefinitions(raw: unknown, builtinKinds: readonly string[]) {
26
+ return compileConfiguredDefinitions(raw, builtinKinds, factories);
167
27
  }