@staix/agent-hub 0.50.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 (350) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +1 -1
  3. package/docs/adding-an-ai-tool.md +26 -4
  4. package/docs/agent-notes/README.md +1 -0
  5. package/docs/agent-notes/adapters.md +4 -3
  6. package/docs/agent-notes/budget.md +8 -2
  7. package/docs/agent-notes/daemon.md +13 -8
  8. package/docs/agent-notes/local-worker.md +3 -3
  9. package/docs/agent-notes/security-review.md +6 -5
  10. package/docs/agent-notes/tasks.md +10 -3
  11. package/docs/agent-notes/tests.md +4 -3
  12. package/docs/cooperbench.md +1 -1
  13. package/docs/design/adapters.md +21 -0
  14. package/docs/design/cli-output-inventory.md +165 -150
  15. package/docs/design/cli-output.md +4 -3
  16. package/docs/design/guidance-probes.md +1 -0
  17. package/docs/design/roadmap.md +3 -1
  18. package/docs/design/task-board.md +35 -0
  19. package/docs/dogfood.md +21 -3
  20. package/docs/events.md +4 -2
  21. package/docs/memory.md +5 -3
  22. package/docs/operations.md +259 -19
  23. package/docs/quickstart.md +29 -2
  24. package/docs/roadmap.json +20 -20
  25. package/docs/roadmap.md +2 -2
  26. package/docs/roles.md +1 -1
  27. package/docs/sdlc.md +29 -5
  28. package/docs/security.md +11 -5
  29. package/docs/specs/2026-09-19-agent-hub-design.md +44 -0
  30. package/docs/specs/2026-09-19-multi-project-design.md +4 -0
  31. package/docs/specs/2026-09-20-upgrade-recovery-design.md +17 -0
  32. package/docs/specs/mcp-endpoint.md +63 -0
  33. package/docs/verification/2026-11-29-agy-1.5.20.md +33 -0
  34. package/docs/verification/2026-11-29-claude-profile-hook.md +12 -0
  35. package/docs/verification/2026-11-29-idle-daemon-footprint.md +75 -0
  36. package/docs/verification/2026-11-29-kimi-281-reviewer-compat.md +38 -0
  37. package/docs/verification/2026-11-29-kimi-tui-281.md +12 -0
  38. package/docs/verification/2026-11-30-0.51.0.md +91 -0
  39. package/docs/verification/2026-11-30-account-switch-1806.md +445 -0
  40. package/docs/verification/2026-11-30-capability-listing-shape-1808.md +45 -0
  41. package/docs/verification/2026-11-30-upgrade-keep-1807.md +174 -0
  42. package/docs/verification/2026-12-01-1811-confirmation-receipt.md +19 -0
  43. package/docs/verification/2026-12-01-1811-orca-agent-list.md +20 -0
  44. package/docs/verification/2026-12-01-1811-orca-pane-key.md +21 -0
  45. package/docs/verification/2026-12-02-1819-claude-process-after-renewal.md +54 -0
  46. package/docs/verification/2026-12-02-agy-1.5.21.md +74 -0
  47. package/docs/verification/2026-12-02-claude-implementer-2.1.334.md +44 -0
  48. package/docs/verification/2026-12-02-cli-import-graph.md +33 -0
  49. package/docs/verification/2026-12-03-0.52.0.md +150 -0
  50. package/docs/verification/2026-12-03-codex-0173-reviewer-isolation.md +53 -0
  51. package/docs/verification/2026-12-03-codex-0173-reviewer-tool-call.md +34 -0
  52. package/docs/verification/2026-12-03-jcode-1.3.0.md +25 -0
  53. package/docs/verification/agy/README.md +17 -0
  54. package/docs/verification/agy/cli-surface.ts +68 -0
  55. package/docs/verification/agy/interactive-bridge.ts +92 -0
  56. package/docs/verification/agy/interactive-session.ts +131 -0
  57. package/docs/verification/agy/launcher-nonce.ts +215 -0
  58. package/docs/verification/agy/native-hooks.ts +210 -0
  59. package/docs/verification/agy/originals/agent-hub-681/cli-surface.ts +87 -0
  60. package/docs/verification/agy/originals/agent-hub-681/native-hooks-adapted.ts +91 -0
  61. package/docs/verification/agy/originals/agent-hub-681/tui-actual.ts +200 -0
  62. package/docs/verification/agy/originals/agent-hub-684/probe.ts +107 -0
  63. package/docs/verification/agy/originals.json +25 -0
  64. package/docs/verification/agy/permission-new-functions.ts +128 -0
  65. package/docs/verification/agy/run-probe.py +108 -0
  66. package/docs/verification/agy/runtime.ts +171 -0
  67. package/docs/verification/agy/tmux-helper-control.ts +6 -0
  68. package/docs/verification/agy/tmux-session.ts +235 -0
  69. package/docs/verified.json +87 -42
  70. package/package.json +3 -3
  71. package/plugins/agent-hub/.claude-plugin/plugin.json +1 -1
  72. package/plugins/agent-hub/compat.json +157 -0
  73. package/plugins/agent-hub/kimi-hook.js +1416 -24985
  74. package/plugins/agent-hub/server.js +17415 -32755
  75. package/scripts/check-docs.mjs +1 -1
  76. package/src/adapters/acp.ts +13 -13
  77. package/src/adapters/agy/definition.ts +9 -26
  78. package/src/adapters/agy/entry.ts +2 -0
  79. package/src/adapters/channel-peer.ts +3 -1
  80. package/src/adapters/claude-channel-evidence.ts +7 -3
  81. package/src/adapters/claude-channel.ts +38 -257
  82. package/src/adapters/claude-implementer.ts +3 -1
  83. package/src/adapters/codex-appserver.ts +77 -15
  84. package/src/adapters/compat.ts +78 -14
  85. package/src/adapters/configured-acp.ts +23 -163
  86. package/src/adapters/configured-adapter-policy.ts +160 -0
  87. package/src/adapters/configured-pull-entry.ts +53 -0
  88. package/src/adapters/configured-pull.ts +38 -0
  89. package/src/adapters/conformance/fakes/app-server.ts +9 -2
  90. package/src/adapters/declaration-catalog.ts +25 -0
  91. package/src/adapters/declaration-data.ts +342 -0
  92. package/src/adapters/declaration-resolution.ts +53 -0
  93. package/src/adapters/definitions/builtin-metadata.ts +62 -84
  94. package/src/adapters/definitions/jcode-launch.ts +13 -0
  95. package/src/adapters/definitions/native-adapter-policy.ts +390 -0
  96. package/src/adapters/definitions/native-cli-claude-launch.ts +6 -3
  97. package/src/adapters/definitions/native-cli-codex-launch.ts +2 -1
  98. package/src/adapters/definitions/native-cli-entry-claude.ts +17 -2
  99. package/src/adapters/definitions/native-cli-entry-codex.ts +2 -0
  100. package/src/adapters/definitions/native-cli-entry-jcode.ts +6 -2
  101. package/src/adapters/definitions/native-cli-entry-kimi.ts +2 -0
  102. package/src/adapters/definitions/native-cli-entry-pi.ts +2 -0
  103. package/src/adapters/definitions/native-cli-entry-qwen.ts +2 -0
  104. package/src/adapters/definitions/native-cli-entry-types.ts +12 -3
  105. package/src/adapters/definitions/native-cli-jcode-home-init.ts +1 -1
  106. package/src/adapters/definitions/native-cli-launch-common.ts +2 -2
  107. package/src/adapters/definitions/native-cli-preview-common.ts +1 -1
  108. package/src/adapters/definitions/native-cli-retained.ts +1 -1
  109. package/src/adapters/definitions/native-config-defaults.ts +1 -1
  110. package/src/adapters/definitions/native-configuration.ts +18 -0
  111. package/src/adapters/definitions/native-help.ts +24 -0
  112. package/src/adapters/definitions/native-launch-declarations.ts +34 -0
  113. package/src/adapters/definitions/native-launch-policy.ts +4 -0
  114. package/src/adapters/definitions/native-launch-settings.ts +72 -0
  115. package/src/adapters/definitions/native-light-cli.ts +18 -0
  116. package/src/adapters/definitions/native-light-preview.ts +10 -0
  117. package/src/adapters/definitions/native-wrapper-launch.ts +10 -0
  118. package/src/adapters/definitions/qwen.ts +6 -29
  119. package/src/adapters/definitions/reviewer-variants.ts +7 -8
  120. package/src/adapters/external-declarations.ts +31 -0
  121. package/src/adapters/external-modules.ts +4 -29
  122. package/src/adapters/jcode.ts +19 -12
  123. package/src/adapters/native-capabilities.ts +18 -8
  124. package/src/adapters/native-facts-hooks.ts +12 -0
  125. package/src/adapters/native-proof-ports.ts +1 -1
  126. package/src/adapters/presets.ts +136 -0
  127. package/src/adapters/qwen-dual.ts +2 -2
  128. package/src/adapters/registry-types.ts +3 -0
  129. package/src/adapters/registry.ts +20 -81
  130. package/src/adapters/reviewer-print.ts +26 -9
  131. package/src/adapters/role-eligibility.ts +2 -1
  132. package/src/cli/accounts-import.ts +72 -0
  133. package/src/cli/agents-latest-table.ts +88 -0
  134. package/src/cli/agents-latest.ts +22 -0
  135. package/src/cli/agents-output.ts +10 -0
  136. package/src/cli/agents-presets.ts +100 -0
  137. package/src/cli/agents.ts +1 -1
  138. package/src/cli/attention.ts +3 -2
  139. package/src/cli/autonomy-homes.ts +7 -2
  140. package/src/cli/autonomy-offline.ts +1 -1
  141. package/src/cli/bench.ts +1 -1
  142. package/src/cli/budget-renew-guidance.ts +129 -0
  143. package/src/cli/claude-homes.ts +9 -5
  144. package/src/cli/claude-profile-hook.ts +31 -11
  145. package/src/cli/command-context.ts +3 -0
  146. package/src/cli/command-table.ts +123 -0
  147. package/src/cli/commands/accounts.ts +8 -0
  148. package/src/cli/commands/agents.ts +18 -0
  149. package/src/cli/commands/answer.ts +28 -0
  150. package/src/cli/commands/ask.ts +17 -0
  151. package/src/cli/commands/autonomy.ts +83 -0
  152. package/src/cli/commands/backlog.ts +46 -0
  153. package/src/cli/commands/bench.ts +60 -0
  154. package/src/cli/commands/board.ts +48 -0
  155. package/src/cli/commands/broker.ts +9 -0
  156. package/src/cli/commands/budget.ts +96 -0
  157. package/src/cli/commands/capabilities.ts +12 -0
  158. package/src/cli/commands/check-path.ts +55 -0
  159. package/src/cli/commands/completion.ts +8 -0
  160. package/src/cli/commands/console.ts +12 -0
  161. package/src/cli/commands/daemon.ts +8 -0
  162. package/src/cli/commands/deliverables.ts +25 -0
  163. package/src/cli/commands/doctor.ts +249 -0
  164. package/src/cli/commands/down.ts +3 -0
  165. package/src/cli/commands/export.ts +15 -0
  166. package/src/cli/commands/facts.ts +15 -0
  167. package/src/cli/commands/goal.ts +22 -0
  168. package/src/cli/commands/guidance.ts +102 -0
  169. package/src/cli/commands/help.ts +17 -0
  170. package/src/cli/commands/host.ts +45 -0
  171. package/src/cli/commands/init.ts +121 -0
  172. package/src/cli/commands/instructed.ts +19 -0
  173. package/src/cli/commands/instruction-hook.ts +15 -0
  174. package/src/cli/commands/intake.ts +24 -0
  175. package/src/cli/commands/kill.ts +15 -0
  176. package/src/cli/commands/learn.ts +23 -0
  177. package/src/cli/commands/lineage.ts +30 -0
  178. package/src/cli/commands/logs.ts +21 -0
  179. package/src/cli/commands/manager.ts +15 -0
  180. package/src/cli/commands/memory.ts +21 -0
  181. package/src/cli/commands/model.ts +25 -0
  182. package/src/cli/commands/models.ts +40 -0
  183. package/src/cli/commands/native.ts +39 -0
  184. package/src/cli/commands/pause.ts +5 -0
  185. package/src/cli/commands/peer.ts +32 -0
  186. package/src/cli/commands/permission.ts +26 -0
  187. package/src/cli/commands/permit.ts +12 -0
  188. package/src/cli/commands/pet.ts +24 -0
  189. package/src/cli/commands/projects.ts +49 -0
  190. package/src/cli/commands/queue.ts +70 -0
  191. package/src/cli/commands/recovery-run.ts +13 -0
  192. package/src/cli/commands/recovery.ts +130 -0
  193. package/src/cli/commands/release.ts +23 -0
  194. package/src/cli/commands/releases.ts +91 -0
  195. package/src/cli/commands/remember.ts +6 -0
  196. package/src/cli/commands/report.ts +27 -0
  197. package/src/cli/commands/research.ts +53 -0
  198. package/src/cli/commands/reset.ts +89 -0
  199. package/src/cli/commands/restart.ts +5 -0
  200. package/src/cli/commands/results.ts +31 -0
  201. package/src/cli/commands/resume.ts +5 -0
  202. package/src/cli/commands/review.ts +24 -0
  203. package/src/cli/commands/roadmap.ts +21 -0
  204. package/src/cli/commands/role.ts +34 -0
  205. package/src/cli/commands/roles.ts +30 -0
  206. package/src/cli/commands/room.ts +14 -0
  207. package/src/cli/commands/roster.ts +48 -0
  208. package/src/cli/commands/route.ts +9 -0
  209. package/src/cli/commands/say.ts +21 -0
  210. package/src/cli/commands/schedule.ts +17 -0
  211. package/src/cli/commands/sdlc.ts +321 -0
  212. package/src/cli/commands/settings.ts +148 -0
  213. package/src/cli/commands/setup.ts +89 -0
  214. package/src/cli/commands/shared-refusals.ts +25 -0
  215. package/src/cli/commands/smoke.ts +44 -0
  216. package/src/cli/commands/source.ts +64 -0
  217. package/src/cli/commands/specs.ts +13 -0
  218. package/src/cli/commands/status.ts +28 -0
  219. package/src/cli/commands/stop.ts +17 -0
  220. package/src/cli/commands/structure.ts +60 -0
  221. package/src/cli/commands/study.ts +39 -0
  222. package/src/cli/commands/tail.ts +19 -0
  223. package/src/cli/commands/task.ts +114 -0
  224. package/src/cli/commands/title.ts +17 -0
  225. package/src/cli/commands/turns.ts +10 -0
  226. package/src/cli/commands/ui.ts +47 -0
  227. package/src/cli/commands/undo.ts +77 -0
  228. package/src/cli/commands/up.ts +39 -0
  229. package/src/cli/commands/upgrade.ts +5 -0
  230. package/src/cli/commands/usage.ts +33 -0
  231. package/src/cli/commands/version.ts +5 -0
  232. package/src/cli/commands/watch.ts +30 -0
  233. package/src/cli/commands/worktrees.ts +31 -0
  234. package/src/cli/conductor-recovery.ts +1 -1
  235. package/src/cli/console-state.ts +5 -138
  236. package/src/cli/console-versions.ts +1 -1
  237. package/src/cli/facts-hook.ts +11 -4
  238. package/src/cli/help.ts +44 -20
  239. package/src/cli/identity.ts +27 -4
  240. package/src/cli/init-prompt.ts +1 -1
  241. package/src/cli/init-settings.ts +4 -35
  242. package/src/cli/init.ts +1 -1
  243. package/src/cli/json-text-spans.ts +57 -0
  244. package/src/cli/launch-check.ts +156 -0
  245. package/src/cli/launch.ts +19 -70
  246. package/src/cli/light-dispatch.ts +29 -0
  247. package/src/cli/main.js +8 -1
  248. package/src/cli/main.ts +257 -2799
  249. package/src/cli/memory.ts +1 -1
  250. package/src/cli/orca-probe.ts +119 -0
  251. package/src/cli/output.ts +45 -3
  252. package/src/cli/preview.ts +11 -6
  253. package/src/cli/recovery-launch.ts +1 -1
  254. package/src/cli/recovery-version-preflight.ts +28 -9
  255. package/src/cli/replace-process.ts +22 -0
  256. package/src/cli/report-layout.ts +142 -0
  257. package/src/cli/roadmap-usage.ts +16 -0
  258. package/src/cli/roadmap.ts +3 -16
  259. package/src/cli/sdlc-doctor.ts +27 -0
  260. package/src/cli/sdlc-output.ts +55 -1
  261. package/src/cli/setup-homes.ts +2 -2
  262. package/src/cli/start-agents-run.ts +85 -7
  263. package/src/cli/start-check.ts +28 -0
  264. package/src/cli/statusline-tee.ts +25 -4
  265. package/src/cli/terminal-recovery.ts +53 -10
  266. package/src/cli/upgrade-interactive.ts +1 -0
  267. package/src/cli/upgrade-runtime.ts +12 -1
  268. package/src/cli/upgrade.ts +4 -15
  269. package/src/cli/warn-line.ts +1 -1
  270. package/src/hub/accounts.ts +148 -0
  271. package/src/hub/addons.ts +20 -0
  272. package/src/hub/agent-drift.ts +2 -1
  273. package/src/hub/budget-projection.ts +39 -7
  274. package/src/hub/budget.ts +231 -16
  275. package/src/hub/channel-project.ts +3 -3
  276. package/src/hub/ci-watch.ts +311 -79
  277. package/src/hub/conductor-peer.ts +24 -0
  278. package/src/hub/conductor.ts +2 -21
  279. package/src/hub/config-apply.ts +25 -14
  280. package/src/hub/config-edit.ts +1 -1
  281. package/src/hub/config-tier.ts +2 -0
  282. package/src/hub/config.ts +535 -0
  283. package/src/hub/control-client.ts +49 -1
  284. package/src/hub/daemon.ts +492 -569
  285. package/src/hub/delivery-public.ts +11 -0
  286. package/src/hub/events.ts +3 -0
  287. package/src/hub/home-tag.ts +12 -0
  288. package/src/hub/host.ts +217 -0
  289. package/src/hub/hub-check.ts +125 -0
  290. package/src/hub/hub-tools.ts +2 -1
  291. package/src/hub/instance-budget.ts +2 -2
  292. package/src/hub/instance-config.ts +15 -126
  293. package/src/hub/instances.ts +22 -6
  294. package/src/hub/instruction-receipt.ts +2 -2
  295. package/src/hub/kimi-usage.ts +38 -11
  296. package/src/hub/lifecycle.ts +86 -4
  297. package/src/hub/mcp-bridge-core.ts +98 -0
  298. package/src/hub/mcp-channel-push.ts +20 -0
  299. package/src/hub/mcp-endpoint-serve.ts +178 -0
  300. package/src/hub/mcp-endpoint.ts +226 -0
  301. package/src/hub/mcp-tool-call.ts +181 -0
  302. package/src/hub/operational-settings.ts +2 -0
  303. package/src/hub/orca-env.ts +6 -0
  304. package/src/hub/orca-state.ts +84 -0
  305. package/src/hub/path-policy.ts +1 -1
  306. package/src/hub/peers.ts +5 -1
  307. package/src/hub/permission-mode.ts +5 -41
  308. package/src/hub/permission-paths.ts +41 -0
  309. package/src/hub/project.ts +20 -0
  310. package/src/hub/protocol-window.ts +58 -0
  311. package/src/hub/quota-origin.ts +20 -0
  312. package/src/hub/recovery-policy.ts +1 -1
  313. package/src/hub/registry.ts +36 -2
  314. package/src/hub/releases-inventory.ts +198 -0
  315. package/src/hub/report.ts +1 -1
  316. package/src/hub/research.ts +1 -1
  317. package/src/hub/review-brief.ts +47 -2
  318. package/src/hub/roster.ts +6 -3
  319. package/src/hub/routing.ts +9 -2
  320. package/src/hub/runtime-capture-prune.ts +25 -3
  321. package/src/hub/runtime-prune-health.ts +8 -1
  322. package/src/hub/sdlc-check.ts +205 -0
  323. package/src/hub/sdlc-release-authorization.ts +42 -21
  324. package/src/hub/sdlc-release-diagnostics.ts +5 -0
  325. package/src/hub/sdlc-release-policy.ts +21 -7
  326. package/src/hub/sdlc-release.ts +80 -20
  327. package/src/hub/sdlc-sync.ts +146 -0
  328. package/src/hub/sdlc.ts +38 -5
  329. package/src/hub/settings.ts +7 -4
  330. package/src/hub/start-agents.ts +1 -1
  331. package/src/hub/start-mode.ts +11 -4
  332. package/src/hub/structure-budget.ts +131 -0
  333. package/src/hub/structure-scan.ts +149 -0
  334. package/src/hub/tasks-experiment.ts +455 -0
  335. package/src/hub/tasks-guidance.ts +606 -0
  336. package/src/hub/tasks-roadmap-plan.ts +419 -0
  337. package/src/hub/tasks-roadmap.ts +491 -0
  338. package/src/hub/tasks-study.ts +661 -0
  339. package/src/hub/tasks-survey.ts +192 -0
  340. package/src/hub/tasks.ts +457 -2584
  341. package/src/hub/terminal-open.ts +5 -3
  342. package/src/hub/tooling.ts +3 -19
  343. package/src/hub/usage-rollup.ts +9 -3
  344. package/src/local/tools.ts +5 -0
  345. package/src/ui/index.html +1 -1
  346. package/src/ui/needs.ts +17 -5
  347. package/src/ui/peer-palette.ts +2 -4
  348. package/src/ui/plugin.ts +1 -1
  349. package/templates/presets/agents.json +60 -0
  350. package/templates/presets/confirmation-matrix.json +8 -8
@@ -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,35 +42,72 @@ 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).",
46
54
  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; 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"],
55
+ // 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; 2.8.1: docs/verification/2026-11-29-kimi-281-reviewer-compat.md
56
+ "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", "2.8.1"], gate: "isolation", probe: ["kimi", "--version"],
49
57
  parse: out => plain(out.trim()),
50
58
  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-25-kimi-272-reviewer-compat.md" },
59
+ receipt: "docs/verification/2026-11-29-kimi-281-reviewer-compat.md" },
52
60
  // The interactive TUI's native-turn and background readbacks are a separate contract from headless ACP and reviewer isolation.
53
61
  // 2.7.2 model-free checks and pending live TUI legs: docs/verification/2026-11-25-kimi-tui-272.md
62
+ // 2.8.1 host checks and pending live TUI legs: docs/verification/2026-11-29-kimi-tui-281.md
54
63
  "kimi-tui": { label: "Kimi TUI completion facts", verified: ["2.5.2"], gate: "contract", probe: ["kimi", "--version"],
55
64
  parse: out => plain(out.trim()),
56
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.",
57
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" },
58
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",
59
104
  parse: out => { try { const v = JSON.parse(out).semver; return typeof v === "string" ? plain(v) : undefined; } catch { return undefined; } },
60
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.",
61
106
  receipt: "docs/verification/2026-11-22-jcode-1.0.3.md" },
62
- 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"],
63
108
  parse: out => plain(out.trim()),
64
- 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.",
65
- 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" },
66
111
  // Receipt: docs/verification/2026-11-22-qwen-0283-acp.md (0.27.1 and 0.28.3).
67
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",
68
113
  parse: out => plain(out.trim()),
@@ -76,6 +121,22 @@ export const COMPAT = {
76
121
  receipt: "docs/verification/2026-11-22-qwen-0283-dual-output.md" },
77
122
  } as const satisfies Record<string, CompatPolicy>;
78
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"]);
79
140
  type CommandConfig = { codex_bin: string; jcode_cmd: string[]; qwen_cmd: string[]; pi?: { cmd: string[] } };
80
141
  /** The configured executables the native gates use; the rest probe their PATH default. */
81
142
  export function configuredCommands(config: CommandConfig): Partial<Record<CompatId, readonly string[]>> {
@@ -90,7 +151,7 @@ export function configuredCommands(config: CommandConfig): Partial<Record<Compat
90
151
  export const isCompatId = (id: unknown): id is CompatId => typeof id === "string" && Object.hasOwn(COMPAT, id);
91
152
 
92
153
  export type CompatVerdict =
93
- | { ok: true; state: "verified" | "in-line" | "trusted"; version: string; note?: string }
154
+ | { ok: true; state: "verified" | "in-line" | "trusted" | "observed"; version: string; note?: string }
94
155
  | { ok: false; state: "refused" | "unknown"; version?: string; reason: string };
95
156
 
96
157
  const parts = (v: string) => /^(\d+)\.(\d+)\.(\d+)$/.exec(v)?.slice(1).map(Number);
@@ -109,18 +170,21 @@ function lineText(line: { min: string; below: string }): string {
109
170
  }
110
171
  export function describe(id: CompatId): string {
111
172
  const p: CompatPolicy = COMPAT[id];
112
- 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)}` : ""}`;
113
174
  }
114
175
 
115
176
  /** `trusted` defaults to this machine's record; tests and the CLI pass their own. */
116
177
  export function assessVersion(id: CompatId, observed: unknown, trusted: readonly TrustEntry[] = readTrust()): CompatVerdict {
117
178
  const policy: CompatPolicy = COMPAT[id];
118
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` };
119
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` };
120
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` };
121
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` };
122
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` };
123
- 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)` };
124
188
  }
125
189
 
126
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
  }
@@ -0,0 +1,160 @@
1
+ import { basename } from "node:path";
2
+ import { types } from "node:util";
3
+ import type { ConfiguredPrintAdapterConfig } from "./configured-print.ts";
4
+ import type { PermissionMode } from "../hub/permission-mode.ts";
5
+
6
+ interface ConfiguredAcpAdapterConfig {
7
+ transport: "acp";
8
+ command: string;
9
+ args?: readonly string[];
10
+ displayName: string;
11
+ roles: readonly string[];
12
+ identity?: { name: string; version: string };
13
+ /** #1809: the preset this declaration was written from; the status word shown beside the kind comes from it. */
14
+ preset?: string;
15
+ permission?: Partial<Record<PermissionMode, string>>;
16
+ readOnly?: string;
17
+ }
18
+ /** #1809: a pull kind runs the person's own TUI; it reads its inbox through the bridge and is never pushed to. `tasks` only ever reads `false`. */
19
+ export interface ConfiguredPullAdapterConfig {
20
+ transport: "pull";
21
+ command: string;
22
+ args: readonly string[];
23
+ displayName: string;
24
+ roles: readonly string[];
25
+ versionArgs: readonly string[];
26
+ tasks: false;
27
+ preset?: string;
28
+ }
29
+ export type ConfiguredAdapterConfig = ConfiguredAcpAdapterConfig | ConfiguredPrintAdapterConfig | ConfiguredPullAdapterConfig;
30
+
31
+ type ConfiguredPolicy =
32
+ | { type: "print"; kind: string; declaration: ConfiguredPrintAdapterConfig }
33
+ | { type: "pull"; kind: string; declaration: ConfiguredPullAdapterConfig }
34
+ | { type: "acp"; kind: string; command: string; args: string[]; argv: string[]; displayName: string; roles: string[];
35
+ identity: ConfiguredAcpAdapterConfig["identity"]; preset: string | undefined; modes: ConfiguredAcpAdapterConfig["permission"]; readOnly: string | undefined;
36
+ nativePolicy: { modes?: ConfiguredAcpAdapterConfig["permission"]; readOnly?: string } };
37
+
38
+ const fail = (field: string, reason: string): never => { throw new Error(`${field}: ${reason}`); };
39
+ /** Core command namespace is reserved; configured kinds cannot shadow operational CLI actions. */
40
+ 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"]);
41
+ export const MODES = ["ask", "ask-when-needed", "never-ask"];
42
+ const ROLES = ["planner", "implementer", "verifier", "reviewer"];
43
+ function fields(raw: unknown, at: string): Record<string, PropertyDescriptor> {
44
+ 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");
45
+ const result: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
46
+ if (Object.values(result).some(d => !Object.hasOwn(d, "value") || !d.enumerable)) return fail(at, "enumerable data fields required");
47
+ return result;
48
+ }
49
+ function text(raw: unknown, at: string, max = 4096): string {
50
+ 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`);
51
+ return raw;
52
+ }
53
+ function list(raw: unknown, at: string, max: number): string[] {
54
+ if (!Array.isArray(raw) || types.isProxy(raw) || Object.getPrototypeOf(raw) !== Array.prototype || Object.getOwnPropertySymbols(raw).length) return fail(at, "must be a string array");
55
+ const descriptors: Record<string, PropertyDescriptor> = Object.assign(Object.create(null), Object.getOwnPropertyDescriptors(raw));
56
+ const length = descriptors.length?.value;
57
+ if (!Number.isSafeInteger(length) || length > max || Object.keys(descriptors).length !== length + 1) return fail(at, "array is sparse or too large");
58
+ return Array.from({ length }, (_, index) => {
59
+ const d = descriptors[String(index)];
60
+ if (!d || !Object.hasOwn(d, "value") || !d.enumerable) return fail(at, "array data fields required");
61
+ return text(d.value, `${at}.${index}`);
62
+ });
63
+ }
64
+ export function freeze<T>(value: T): T {
65
+ if (value && typeof value === "object") { for (const item of Object.values(value)) freeze(item); Object.freeze(value); }
66
+ return value;
67
+ }
68
+
69
+ function parsePrint(input: Record<string, PropertyDescriptor>, at: string): ConfiguredPrintAdapterConfig {
70
+ if (Object.keys(input).some(key => !["transport", "command", "args", "stdin", "versionArgs", "versionPin", "timeoutS", "displayName", "roles"].includes(key)))
71
+ return fail(at, "unknown or privileged print field");
72
+ const command = text(input.command?.value, `${at}.command`);
73
+ const args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
74
+ const stdin = input.stdin?.value;
75
+ const placeholders = args.reduce((count, arg) => count + arg.split("{prompt}").length - 1, 0);
76
+ if (input.stdin && stdin !== true || (stdin === true ? placeholders !== 0 : placeholders !== 1))
77
+ return fail(at, "choose stdin: true or exactly one {prompt} placeholder");
78
+ const versionArgs = list(input.versionArgs?.value, `${at}.versionArgs`, 128);
79
+ if (!versionArgs.length || versionArgs.some(arg => arg.includes("{prompt}"))) return fail(`${at}.versionArgs`, "requires fixed version probe arguments");
80
+ const versionPin = text(input.versionPin?.value, `${at}.versionPin`, 256).trim();
81
+ const timeoutS = input.timeoutS?.value;
82
+ if (!Number.isInteger(timeoutS) || timeoutS < 1 || timeoutS > 300) return fail(`${at}.timeoutS`, "must be an integer from 1 to 300");
83
+ const displayName = text(input.displayName?.value, `${at}.displayName`, 256);
84
+ const roles = list(input.roles?.value, `${at}.roles`, 2);
85
+ const advisory = roles.filter((role): role is "reviewer" | "advisor" => role === "reviewer" || role === "advisor");
86
+ 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");
87
+ return freeze<ConfiguredPrintAdapterConfig>({ transport: "print", command, args, ...(stdin === true ? { stdin } : {}), versionArgs, versionPin, timeoutS, displayName, roles: advisory });
88
+ }
89
+
90
+ function parsePull(input: Record<string, PropertyDescriptor>, at: string): ConfiguredPullAdapterConfig {
91
+ if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "versionArgs", "tasks", "preset"].includes(key))) return fail(at, "unknown or privileged pull field");
92
+ // The way to let a pull peer own tasks later stays open (#1809): every ownership check reads this field, so allowing it is a validation change.
93
+ if (input.tasks && input.tasks.value !== false) return fail(`${at}.tasks`, "a pull peer cannot own tasks; only false is accepted (spec #1809, decision on pull ownership)");
94
+ const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
95
+ if ([command, ...args].some(arg => /^--(?:leader|attach|connect|remote)(?:-|=|$)/.test(arg))) return fail(`${at}.args`, "attach/leader selectors are unsupported");
96
+ const versionArgs = list(input.versionArgs?.value, `${at}.versionArgs`, 128);
97
+ if (!versionArgs.length) return fail(`${at}.versionArgs`, "requires fixed version probe arguments");
98
+ const displayName = text(input.displayName?.value, `${at}.displayName`, 256), roles = list(input.roles?.value, `${at}.roles`, 3);
99
+ if (roles.includes("reviewer")) return fail(`${at}.roles`, "a pull kind cannot be a reviewer (spec #1809): it reads only when it asks, so it cannot meet a review deadline");
100
+ if (!roles.length || new Set(roles).size !== roles.length || roles.some(role => !["planner", "implementer", "verifier"].includes(role))) return fail(`${at}.roles`, "pull roles must be unique planner, implementer or verifier");
101
+ const preset = input.preset ? text(input.preset.value, `${at}.preset`, 32) : undefined;
102
+ if (preset !== undefined && !/^[a-z][a-z0-9-]{0,31}$/.test(preset)) return fail(`${at}.preset`, "must be a preset id");
103
+ return freeze<ConfiguredPullAdapterConfig>({ transport: "pull", command, args, displayName, roles, versionArgs, tasks: false, ...(preset ? { preset } : {}) });
104
+ }
105
+
106
+ /** Pure local declaration compiler; file provenance and runtime process ownership remain host checks. */
107
+ /** A configured print or ACP declaration can bind a headless factory. Pull declarations never do. */
108
+ export function configuredHeadlessFactory(policy: { type: "acp" | "print" | "pull" }): boolean {
109
+ return policy.type !== "pull";
110
+ }
111
+
112
+ export function readConfiguredAdapters(raw: unknown, builtinKinds: readonly string[]): readonly ConfiguredPolicy[] {
113
+ if (raw === undefined) return Object.freeze([]);
114
+ const declarations = fields(raw, "adapters");
115
+ if (Object.keys(declarations).length > 64) return fail("adapters", "at most 64 configured kinds supported");
116
+ const reserved = new Set([...builtinKinds, ...CONFIGURED_ACP_RESERVED_COMMANDS, "user", "hub", "digest", "constructor", "prototype", "__proto__"]);
117
+ return Object.freeze(Object.entries(declarations).map<ConfiguredPolicy>(([kind, descriptor]) => {
118
+ const at = `adapters.${kind}`;
119
+ 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");
120
+ const input = fields(descriptor.value, at);
121
+ if (input.transport?.value === "print") return { type: "print", kind, declaration: parsePrint(input, at) };
122
+ if (input.transport?.value === "pull") return { type: "pull", kind, declaration: parsePull(input, at) };
123
+ if (Object.keys(input).some(key => !["transport", "command", "args", "displayName", "roles", "identity", "permission", "readOnly", "preset"].includes(key))) return fail(at, "unknown or privileged field");
124
+ if (input.transport?.value !== "acp") return fail(`${at}.transport`, "must be acp, print or pull");
125
+ const command = text(input.command?.value, `${at}.command`), args = input.args ? list(input.args.value, `${at}.args`, 128) : [];
126
+ // The supported contract is a foreground owned stdio process, never an attachment/proxy selector.
127
+ 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");
128
+ const displayName = text(input.displayName?.value, `${at}.displayName`, 256), roles = list(input.roles?.value, `${at}.roles`, ROLES.length);
129
+ if (roles.includes("conductor")) return fail(`${at}.roles`, "conductor requires explicit project role policy, not adapter defaults");
130
+ 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");
131
+ let identity: ConfiguredAcpAdapterConfig["identity"];
132
+ if (input.identity) {
133
+ const value = fields(input.identity.value, `${at}.identity`);
134
+ if (Object.keys(value).some(key => !["name", "version"].includes(key))) return fail(`${at}.identity`, "unknown identity field");
135
+ identity = { name: text(value.name?.value, `${at}.identity.name`, 256), version: text(value.version?.value, `${at}.identity.version`, 256) };
136
+ }
137
+ const grokContract = kind === "grok" || /^grok(?:\.exe)?$/i.test(basename(command)) || identity?.name.toLowerCase() === "grok";
138
+ const noLeader = args.indexOf("--no-leader"), endOptions = args.indexOf("--");
139
+ if (grokContract && (noLeader < 0 || (endOptions >= 0 && noLeader > endOptions) || args.some(arg => arg.startsWith("--no-leader=")))) {
140
+ return fail(`${at}.args`, "Grok requires explicit --no-leader before argv termination; valued opt-outs are unsupported");
141
+ }
142
+ let modes: ConfiguredAcpAdapterConfig["permission"];
143
+ if (input.permission) {
144
+ const value = fields(input.permission.value, `${at}.permission`);
145
+ modes = {};
146
+ for (const [mode, d] of Object.entries(value)) {
147
+ if (!MODES.includes(mode)) return fail(`${at}.permission.${mode}`, "unknown hub mode");
148
+ modes[mode as PermissionMode] = text(d.value, `${at}.permission.${mode}`, 256);
149
+ }
150
+ if (!Object.keys(modes).length) modes = undefined; // `permission: {}` maps nothing: unmanaged, exactly like an omitted map
151
+ }
152
+ const readOnly = input.readOnly ? text(input.readOnly.value, `${at}.readOnly`, 256) : undefined;
153
+ const preset = input.preset ? text(input.preset.value, `${at}.preset`, 32) : undefined;
154
+ if (preset !== undefined && !/^[a-z][a-z0-9-]{0,31}$/.test(preset)) return fail(`${at}.preset`, "must be a preset id");
155
+ const nativePolicy = freeze({ ...(modes ? { modes } : {}), ...(readOnly ? { readOnly } : {}) });
156
+ const argv = freeze([command, ...args]);
157
+ identity = identity && freeze(identity);
158
+ return { type: "acp", kind, command, args, argv, displayName, roles, identity, preset, modes, readOnly, nativePolicy };
159
+ }));
160
+ }
@@ -0,0 +1,53 @@
1
+ import { spawnSync } from "node:child_process";
2
+ import type { ProjectAdapterCatalog } from "./registry.ts";
3
+ import { CONFIGURED_PULL_NOTICE } from "./configured-pull.ts";
4
+ import { peerChildEnv } from "../hub/child-process.ts";
5
+ import { rosterInStatus } from "../hub/status-roster.ts";
6
+
7
+ /** The words `ahub <kind>` passes through to the TUI; everything else is the declaration's. */
8
+ export interface ConfiguredPullLaunch { command: string; args: string[]; preview: boolean }
9
+
10
+ export function parseConfiguredPullArguments(raw: readonly string[], declared: { command: string; args: readonly string[] }): ConfiguredPullLaunch {
11
+ const preview = raw.some(arg => arg === "--print-command" || arg === "--dry-run");
12
+ const extra = raw.filter(arg => arg !== "--print-command" && arg !== "--dry-run");
13
+ if (extra.some(arg => Buffer.byteLength(arg) > 4096 || /[\p{Cc}\p{Cf}]/u.test(arg))) throw new Error("launch arguments must be bounded and control-free");
14
+ return { command: declared.command, args: [...declared.args, ...extra], preview };
15
+ }
16
+
17
+ export interface ConfiguredPullControl { features: readonly string[]; request(message: Record<string, unknown>, timeout?: number): Promise<any>; close(): void }
18
+
19
+ /** The environment of the person's TUI: its own identity, the project, and never a tools socket or another peer's marker. */
20
+ export function configuredPullEnv(kind: string, source: NodeJS.ProcessEnv, stateDir: string, projectRoot: string): NodeJS.ProcessEnv {
21
+ const env: NodeJS.ProcessEnv = { ...peerChildEnv(kind, source, { preserveOrca: true }), AGENTHUB_STATE_DIR: stateDir, AGENTHUB_PROJECT_DIR: projectRoot };
22
+ for (const name of ["AGENTHUB_UNATTENDED", "AGENTHUB_MODE", "AGENTHUB_CHANNEL", "AGENTHUB_RECOVERY_OPERATION"]) delete env[name];
23
+ return env;
24
+ }
25
+
26
+ /**
27
+ * #1809 AC4: `ahub <kind>` for a configured pull kind runs the person's command in their terminal with the kind's peer identity.
28
+ * The TUI reaches the hub through the MCP server the person registered in that CLI; the hub never writes that registration.
29
+ * ponytail: no terminal-launch record yet; a pull session has no recovery driver (its definition refuses recovery), so the record would feed nothing. Add it with the recovery driver.
30
+ */
31
+ export async function runConfiguredPullEntry(context: {
32
+ kind: string; raw: readonly string[]; catalog: ProjectAdapterCatalog; projectRoot: string; stateDir: string; env: NodeJS.ProcessEnv;
33
+ declared: { command: string; args: readonly string[]; versionArgs: readonly string[] };
34
+ connect(): Promise<ConfiguredPullControl>; warn(text: string): void;
35
+ run(command: string, args: string[], env: NodeJS.ProcessEnv): number | Promise<number>;
36
+ }): Promise<number> {
37
+ const launch = parseConfiguredPullArguments(context.raw, context.declared);
38
+ if (launch.preview) {
39
+ console.log(JSON.stringify({ command: launch.command, args: launch.args, mode: "tui", peer: context.kind, env: ["AGENTHUB_PEER_ID", "AGENTHUB_STATE_DIR", "AGENTHUB_PROJECT_DIR"], writes: false }, null, 2));
40
+ return 0;
41
+ }
42
+ const probe = spawnSync(context.declared.command, [...context.declared.versionArgs], { encoding: "utf8", timeout: 5000, maxBuffer: 4096, env: peerChildEnv(context.kind, context.env) });
43
+ if (probe.error || probe.status !== 0) throw new Error(`${context.declared.command} did not answer its version probe; install it or fix adapters.${context.kind}.versionArgs`);
44
+ const hub = await context.connect();
45
+ try {
46
+ const reply = await hub.request({ t: "status" });
47
+ const active = reply.status?.configuredAdapters;
48
+ if (!Array.isArray(active) || !active.includes(context.kind)) throw new Error(`running hub has not loaded ${context.kind}; restart it after declaring the adapter`);
49
+ if (rosterInStatus(reply.status, context.kind) !== true) throw new Error(`${context.kind} is off roster; add it with ahub roster add ${context.kind}`);
50
+ } finally { hub.close(); }
51
+ context.warn(CONFIGURED_PULL_NOTICE);
52
+ return await context.run(launch.command, launch.args, configuredPullEnv(context.kind, context.env, context.stateDir, context.projectRoot));
53
+ }