@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
@@ -0,0 +1,18 @@
1
+ import { NATIVE_ADAPTER_POLICY as policy } from "./native-adapter-policy.ts";
2
+ import type { NativeCliDispatchEntry, NativeCliEntryContext } from "./native-cli-entry-types.ts";
3
+
4
+ function entry(
5
+ kind: "claude" | "codex" | "jcode",
6
+ execute: (context: NativeCliEntryContext) => Promise<void>,
7
+ ): NativeCliDispatchEntry {
8
+ const { metadata, cli } = policy[kind];
9
+ return Object.freeze({ command: cli.command, lifecycleAdmission: true, execute,
10
+ definition: Object.freeze({ transport: metadata.transport, cli, session: {} }),
11
+ });
12
+ }
13
+
14
+ export const LIGHT_NATIVE_CLI_ENTRIES = Object.freeze({
15
+ claude: entry("claude", async context => (await import("./native-cli-entry-claude.ts")).runClaudeEntry(context)),
16
+ codex: entry("codex", async context => (await import("./native-cli-entry-codex.ts")).runCodexEntry(context)),
17
+ jcode: entry("jcode", async context => (await import("./native-cli-entry-jcode.ts")).runJcodeEntry(context)),
18
+ });
@@ -0,0 +1,10 @@
1
+ import { previewClaude } from "./native-cli-preview-claude.ts";
2
+ import { previewCodex } from "./native-cli-preview-codex.ts";
3
+ import { previewJcode } from "./native-cli-preview-jcode.ts";
4
+ import type { NativePreviewBuilder } from "./native-cli-preview-common.ts";
5
+
6
+ const lightPreviews: Readonly<Partial<Record<string, NativePreviewBuilder>>> = Object.freeze({ claude: previewClaude, codex: previewCodex, jcode: previewJcode });
7
+
8
+ export function lightNativePreview(tool: string): NativePreviewBuilder | undefined {
9
+ return Object.hasOwn(lightPreviews, tool) ? lightPreviews[tool] : undefined;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { claudeNativeLaunch } from "./native-cli-claude-launch.ts";
2
+ import { codexNativeLaunch } from "./native-cli-codex-launch.ts";
3
+ import type { LaunchContext, LaunchPlan } from "../registry-types.ts";
4
+
5
+ const launchers = { claude: claudeNativeLaunch, codex: codexNativeLaunch };
6
+
7
+ export function nativeWrapperLaunch(kind: keyof typeof launchers, context: LaunchContext): LaunchPlan {
8
+ if (!Object.hasOwn(launchers, kind)) throw new Error("native launch definition unavailable");
9
+ return launchers[kind](context);
10
+ }
@@ -1,4 +1,4 @@
1
- import { describe } from "../compat.ts";
1
+ import { NATIVE_WATCH_CAPABILITIES, NATIVE_ADAPTER_POLICY } from "./native-adapter-policy.ts";
2
2
  import { runQwenEntry } from "./native-cli-entry-qwen.ts";
3
3
  import { previewQwen } from "./native-cli-preview-qwen.ts";
4
4
  import { QWEN_DISPLAY } from "./native-display.ts";
@@ -11,25 +11,11 @@ import { createQwenDual } from "./native-factories.ts";
11
11
 
12
12
  /** Production Qwen policy. Legacy AcpPeer callers opt in separately through qwen025. */
13
13
  export const QWEN_DEFINITION: AdapterDefinition = {
14
- api: 1,
15
- kind: "qwen",
16
- projection: { roleRank: 5, helpRank: 5, plannerEligible: true, conductorEligible: false, reviewerEligible: true },
17
- displayName: "Qwen Code",
18
- family: "qwen",
19
- transport: "acp",
20
- roles: ["implementer", "verifier"],
21
- optional: true,
14
+ ...NATIVE_ADAPTER_POLICY.qwen.metadata,
22
15
  defaultOnRoster: false,
23
- trust: { onPrem: false, hubSandboxed: false },
16
+
24
17
  start: {
25
- daemonPort: "acp",
26
- forms: ["headless"],
27
- defaultForm: "headless",
28
- conductorStartable: true,
29
- // #608: the TUI is explicit only, so `ahub up` never starts Qwen from the start set; the text names why.
30
- upStart: { allowed: false, refusal: "the hub never opens its TUI, and a Qwen is started only by ahub qwen" },
31
- hubSwitches: [],
32
- ownedFlags: [],
18
+ ...NATIVE_ADAPTER_POLICY.qwen.start,
33
19
  // The TUI (#286 Part 3) is explicit only: forms stays headless, so Qwen never becomes a start-mode peer and the hub never opens it by itself.
34
20
  preflight: request => request.form !== undefined && request.form !== "headless" && request.form !== "tui"
35
21
  ? "unknown Qwen mode; usage: ahub qwen [--mode headless|tui]" : undefined,
@@ -47,15 +33,6 @@ export const QWEN_DEFINITION: AdapterDefinition = {
47
33
  },
48
34
  conductorStartArgs: args => args.length ? new Error("conductor starts accept no launch overrides; use ahub qwen") : {},
49
35
  },
50
- identity: { mcp: "acp-session" },
51
- instances: { mode: "headless" },
52
- permission: {
53
- grants: {
54
- ask: "every write, edit and shell command asks",
55
- "ask-when-needed": "Qwen auto-edit approves file edits; shell commands ask; NO hub sandbox",
56
- "never-ask": "Qwen yolo approves every tool; NO hub sandbox",
57
- },
58
- },
59
36
  session: {
60
37
  idField: "sessionId",
61
38
  currentId: peer => {
@@ -73,8 +50,8 @@ export const QWEN_DEFINITION: AdapterDefinition = {
73
50
  turnEnd: "adapter",
74
51
  settle: { signal: "message-stop" },
75
52
  budget: { account: "qwen" },
76
- capabilities: { watch: true },
77
- cli: { command: "qwen", entry: { lifecycleAdmission: true, execute: runQwenEntry }, preview: previewQwen, usage: [["ahub qwen [--mode headless|tui] [--model <alias>] [--session-id <id>] [--print-command]", `start optional Qwen Code ACP (${describe("qwen")}; roster.qwen, default off); --mode tui runs Qwen's own TUI in this terminal, driven through its dual-output files (${describe("qwen-dual")}); a hub deny ends the turn without an answer and a stalled turn is stopped with Esc in the Qwen terminal`, "start optional Qwen Code, headless or in its TUI"]], launchConfigKeys: ["qwen_cmd"], startWords: () => ["qwen"] },
53
+ capabilities: NATIVE_WATCH_CAPABILITIES,
54
+ cli: { ...NATIVE_ADAPTER_POLICY.qwen.cli, entry: { lifecycleAdmission: true, execute: runQwenEntry }, preview: previewQwen },
78
55
  display: QWEN_DISPLAY,
79
56
  hooks: { recallPlatform: "qwen" },
80
57
  };
@@ -1,3 +1,4 @@
1
+ import { freshReviewerPolicy, NATIVE_FRESH_REVIEWER_FACTORY } from "./native-adapter-policy.ts";
1
2
  import type { AdapterDefinition } from "../registry-types.ts";
2
3
  import { claudeReviewerBackend } from "../claude-print.ts";
3
4
  import { codexReviewerBackend } from "../codex-review-isolation.ts";
@@ -6,19 +7,17 @@ import { createReviewer, createCodexReviewer } from "./native-factories.ts";
6
7
  import { CODEX_DISPLAY, KIMI_DISPLAY } from "./native-display.ts";
7
8
 
8
9
  export { claudeReviewerBackend };
9
- function reviewerVariant(kind: string, displayName: string, reviewer: NonNullable<AdapterDefinition["reviewer"]>, display: AdapterDefinition["display"]): AdapterDefinition {
10
+ function reviewerVariant(kind: keyof typeof NATIVE_FRESH_REVIEWER_FACTORY, displayName: string, reviewer: NonNullable<AdapterDefinition["reviewer"]>, display: AdapterDefinition["display"]): AdapterDefinition {
11
+ const hasFactory = NATIVE_FRESH_REVIEWER_FACTORY[kind];
12
+ const policy = freshReviewerPolicy(kind, displayName, hasFactory);
10
13
  return {
11
- api: 1, kind, family: kind, displayName, transport: "hub-native", roles: ["reviewer"],
12
- defaultOnRoster: false, trust: { onPrem: false, hubSandboxed: false },
13
- start: { ...(reviewer.backend ? { create: createReviewer, daemonPort: "reviewer-print" as const } : {}), forms: ["headless"], defaultForm: "headless",
14
- conductorStartable: true, hubSwitches: [], ownedFlags: [] },
15
- identity: { mcp: "env" }, instances: { mode: "headless" },
16
- permission: { unmanaged: "fresh read-only reviewer; an isolation receipt is required before startup" },
14
+ ...policy,
15
+ start: { ...policy.start, ...(hasFactory ? { create: createReviewer } : {}) },
17
16
  session: { idField: "sessionId", currentId: () => undefined, freshOnRestore: true, launchKind: "reviewer-print", crashPlan: () => ({ resume: {}, how: "starts a fresh isolated review session" }) },
18
17
  turnEnd: "adapter", budget: { account: kind }, routing: { reviewOnly: true },
19
18
  // A fresh reviewer never inherits a long-lived ACP setter through a base/variant merge.
20
19
  modelOverride: undefined,
21
- reviewer, cli: { command: kind, startWords: () => [] }, display,
20
+ reviewer, display,
22
21
  };
23
22
  }
24
23
  const codexVariant = reviewerVariant("codex", "Codex reviewer", { backend: codexReviewerBackend, defaultPool: true, declaration: "explicit", scope: "code" }, CODEX_DISPLAY);
@@ -0,0 +1,31 @@
1
+ import { moduleDataObject as dataObject, moduleText as text, moduleArray as array } from "./external-metadata.ts";
2
+ import { configRefusal } from "../hub/config-trust.ts";
3
+
4
+ export interface AdapterModuleDeclaration { readonly path: string; readonly sha256: string }
5
+ export interface ModuleConfigLayer { name: string; raw: Record<string, unknown> }
6
+ const MAX_MODULES = 16;
7
+ export class ExternalAdapterRefusal extends Error {}
8
+ export const refuseExternalAdapter = (reason: string): never => { throw new ExternalAdapterRefusal(`external adapter: ${reason}`); };
9
+ export function adapterModuleDeclarations(raw: unknown): readonly AdapterModuleDeclaration[] {
10
+ if (raw === undefined) return Object.freeze([]);
11
+ return Object.freeze(array(raw, MAX_MODULES).map(value => {
12
+ const row = dataObject(value);
13
+ if (Object.keys(row).some(key => !["path", "sha256"].includes(key))) return refuseExternalAdapter("unknown module declaration field");
14
+ const path = text(row.path, 4096), hash = row.sha256;
15
+ if (typeof hash !== "string" || !/^[a-f0-9]{64}$/i.test(hash)) return refuseExternalAdapter("a SHA-256 content pin is required");
16
+ return Object.freeze({ path, sha256: hash.toLowerCase() });
17
+ }));
18
+ }
19
+
20
+ /** This reads declarations only. It never imports code, including for reloads and CLI reads. */
21
+ export function readAdapterModuleDeclarations(cwd: string, layers: readonly ModuleConfigLayer[]) {
22
+ const ignored: string[] = [];
23
+ let modules: readonly AdapterModuleDeclaration[] = Object.freeze([]);
24
+ for (const { name, raw } of layers) {
25
+ if (raw.adapter_modules === undefined) continue;
26
+ const refusal = name !== "config.local.json" ? "modules are machine-local config.local.json values" : configRefusal(cwd, name);
27
+ if (refusal) { ignored.push(`adapter_modules in .agenthub/${name} ignored: ${refusal}`); continue; }
28
+ modules = adapterModuleDeclarations(raw.adapter_modules);
29
+ }
30
+ return { modules, ignored };
31
+ }
@@ -11,12 +11,11 @@ import { configRefusal } from "../hub/config-trust.ts";
11
11
  import { realPath } from "../hub/project.ts";
12
12
  import { scanModuleSource } from "./external-module-scan.ts";
13
13
 
14
- export interface AdapterModuleDeclaration { readonly path: string; readonly sha256: string }
15
- interface ModuleConfigLayer { name: string; raw: Record<string, unknown> }
16
- const MAX_MODULES = 16, MAX_MODULE_BYTES = 2 * 1024 * 1024;
14
+ import { readAdapterModuleDeclarations, ExternalAdapterRefusal, refuseExternalAdapter as fail, type AdapterModuleDeclaration, type ModuleConfigLayer } from "./external-declarations.ts";
15
+ export { adapterModuleDeclarations, readAdapterModuleDeclarations, type AdapterModuleDeclaration } from "./external-declarations.ts";
16
+
17
+ const MAX_MODULE_BYTES = 2 * 1024 * 1024;
17
18
  const ADAPTER_IMPORT = "@staix/agent-hub/adapter";
18
- class ExternalAdapterRefusal extends Error {}
19
- const fail = (reason: string): never => { throw new ExternalAdapterRefusal(`external adapter: ${reason}`); };
20
19
  const digest = (bytes: Uint8Array) => createHash("sha256").update(bytes).digest("hex");
21
20
  export interface ExternalModuleIdentity {
22
21
  readonly projectRoot: string;
@@ -50,30 +49,6 @@ export function externalModuleIdentityCurrent(definition: AdapterDefinition): bo
50
49
  && (current.mode & 0o002) === 0 && readFileSync(file, "utf8") === source && !configRefusal(root, "config.local.json");
51
50
  } catch { return false; }
52
51
  }
53
- export function adapterModuleDeclarations(raw: unknown): readonly AdapterModuleDeclaration[] {
54
- if (raw === undefined) return Object.freeze([]);
55
- return Object.freeze(array(raw, MAX_MODULES).map(value => {
56
- const row = dataObject(value);
57
- if (Object.keys(row).some(key => !["path", "sha256"].includes(key))) return fail("unknown module declaration field");
58
- const path = text(row.path, 4096), hash = row.sha256;
59
- if (typeof hash !== "string" || !/^[a-f0-9]{64}$/i.test(hash)) return fail("a SHA-256 content pin is required");
60
- return Object.freeze({ path, sha256: hash.toLowerCase() });
61
- }));
62
- }
63
-
64
- /** This reads declarations only. It never imports code, including for reloads and CLI reads. */
65
- export function readAdapterModuleDeclarations(cwd: string, layers: readonly ModuleConfigLayer[]) {
66
- const ignored: string[] = [];
67
- let modules: readonly AdapterModuleDeclaration[] = Object.freeze([]);
68
- for (const { name, raw } of layers) {
69
- if (raw.adapter_modules === undefined) continue;
70
- const refusal = name !== "config.local.json" ? "modules are machine-local config.local.json values" : configRefusal(cwd, name);
71
- if (refusal) { ignored.push(`adapter_modules in .agenthub/${name} ignored: ${refusal}`); continue; }
72
- modules = adapterModuleDeclarations(raw.adapter_modules);
73
- }
74
- return { modules, ignored };
75
- }
76
-
77
52
  const inside = (root: string, file: string) => { const part = relative(root, file); return part !== "" && part !== ".." && !part.startsWith(`..${sep}`) && !isAbsolute(part); };
78
53
  function regularPath(root: string, file: string) {
79
54
  if (!inside(root, file)) return fail("module must be inside the project root");
@@ -1,3 +1,5 @@
1
+ import { jcodeCommand, jcodeTuiCommand, JCODE_HEADLESS_AFTER_RECOVERY } from "./definitions/jcode-launch.ts";
2
+ export { jcodeCommand, jcodeTuiCommand, JCODE_HEADLESS_AFTER_RECOVERY } from "./definitions/jcode-launch.ts";
1
3
  import type { ActivityTable } from "./definitions/native-activity.ts";
2
4
  import { spawn, spawnSync, type ChildProcess } from "node:child_process";
3
5
  import { assessVersion, COMPAT, type CompatVerdict } from "./compat.ts";
@@ -23,11 +25,6 @@ export interface JcodeOptions extends Omit<AcpOptions, "cmd" | "qwen025" | "expe
23
25
  /** #1085: what the hub knows that the adapter does not, asked when status is built: is this peer's start mode tui, and did this hub run start after a crash report. */
24
26
  tuiHintContext?: () => { tui: boolean; afterCrash: boolean };
25
27
  }
26
- export function jcodeCommand(command: string[], kind: "serve" | "acp", socket: string, cwd: string, model?: string, profile?: string, provider?: string, peer = "jcode"): string[] {
27
- if (!command.length || command.some(word => typeof word !== "string" || !word)) throw new Error("jcode_cmd must name an executable argv");
28
- return [...command, kind, "--socket", socket, "--cwd", cwd, "--no-update", "--no-selfdev", ...(provider ? ["-p", provider] : []), ...(model ? ["--model", model] : []), ...(profile ? ["--provider-profile", profile] : []),
29
- ...(kind === "serve" ? ["--temporary-server", "--owner-pid", String(process.pid), "--server-name", `agent-hub-${peer}`] : ["--mcp-tools", "eager"])];
30
- }
31
28
  /**
32
29
  * #1601: the one host sentence a configured Jcode may write to hub.log, because the daemon replaces every line this adapter's
33
30
  * own `log` port would carry with "Jcode native diagnostic: details withheld". It names the cause class, the ceiling's minutes,
@@ -46,12 +43,6 @@ export interface JcodeTuiBinding { launchId: string; sessionId: string }
46
43
  export type JcodeTuiState = { state: "waiting"; binding: JcodeTuiBinding } |
47
44
  { state: "ready"; binding: JcodeTuiBinding; launch: { cmd: string; args: string[]; env: NodeJS.ProcessEnv } };
48
45
 
49
- export function jcodeTuiCommand(command: string[], socket: string, sessionId: string, model?: string, profile?: string, provider?: string): string[] {
50
- if (!command.length || command.some(word => typeof word !== "string" || !word)) throw new Error("jcode_cmd must name an executable argv");
51
- return [...command, "--socket", socket, "--resume", sessionId, "--no-update", "--no-selfdev", ...(provider ? ["-p", provider] : []),
52
- ...(model ? ["--model", model] : []), ...(profile ? ["--provider-profile", profile] : [])];
53
- }
54
-
55
46
  /** Read native persistence only. Never synthesize a native session or send a save-inducing prompt. */
56
47
  function savedSession(home: string, id: string): boolean {
57
48
  if (!/^[A-Za-z0-9_-]{1,128}$/.test(id)) throw new Error("invalid native session identity");
@@ -95,7 +86,7 @@ export class JcodeTuiRefusal extends Error {
95
86
  constructor(readonly code: JcodeTuiRefusalCode) { super(`owned Jcode TUI launch refused: ${code}`); }
96
87
  }
97
88
  /** #1085: said by `ahub status` while a recovered headless Jcode has not yet opened its TUI, and by the launcher when `ahub jcode` finds it running headless. */
98
- export const JCODE_HEADLESS_AFTER_RECOVERY = "jcode is running headless after recovery; run ahub stop jcode, then ahub jcode to get its TUI back";
89
+
99
90
  /**
100
91
  * #1668: what `ahub status` says while a rostered Jcode peer's socket is served by a server the hub did not start, handed to the daemon by the hello that
101
92
  * admission refused. It names the cause class and the launch that puts the peer back under the hub, and carries no launch id, socket or path.
@@ -1,15 +1,25 @@
1
1
  // #445 C1: what the hub can read of a native peer's own skills and commands, and the only versions it was probed on (C0 receipt, 2026-10-30).
2
2
  // Vendor identities and listing shapes live here, in the adapter layer, never in the core rules of `src/hub/capabilities.ts` (the #451 registry guard).
3
+ import { COMPAT, assessVersion } from "./compat.ts";
3
4
  import { buildManifest, type Candidate, type CapabilityManifest, type FlatSchema } from "../hub/capabilities.ts";
4
5
 
5
6
  const object = (value: unknown): value is Record<string, unknown> => !!value && typeof value === "object" && !Array.isArray(value);
6
7
 
7
- /** The only native versions whose listings were probed (C0 receipt, 2026-10-30). Any other version lists nothing until a new receipt covers it. */
8
+ // used-by: src/adapters/native-capabilities.ts
9
+ /** The vendor names of the three listings and the version their C0 receipt probed, read from the `COMPAT` entry (`verified[0]`), never held here (#1808). */
8
10
  export const NATIVE_PINS = Object.freeze({
9
- kimi: { agent: "Kimi Code CLI", version: "2.3.2" },
10
- qwen: { agent: "qwen-code", version: "0.26.1" },
11
- codex: { agent: "codex", version: "0.166.0" },
11
+ kimi: { agent: "Kimi Code CLI", version: COMPAT["kimi-capabilities"].verified[0] },
12
+ qwen: { agent: "qwen-code", version: COMPAT["qwen-capabilities"].verified[0] },
13
+ codex: { agent: "codex", version: COMPAT["codex-capabilities"].verified[0] },
12
14
  } as const);
15
+ /**
16
+ * The one decision whether a capability listing of this version may be shown (#1808, owner choice): a verified version, or an exact version this machine's person trusted
17
+ * with `ahub agents trust`. The trust record is read on every call and never cached, so a revoke works without a restart; an unreadable record trusts nothing, and a
18
+ * version that is refused or cannot be read lists nothing.
19
+ */
20
+ export function listable(id: "kimi-capabilities" | "qwen-capabilities" | "codex-capabilities", version: unknown): boolean {
21
+ return assessVersion(id, version).ok;
22
+ }
13
23
  const STRING_INPUT: FlatSchema = { type: "object", properties: { input: { type: "string" } }, additionalProperties: false };
14
24
  const QWEN_SKILL_SOURCES = ["bundled-skill", "skill-dir-command"];
15
25
 
@@ -21,8 +31,8 @@ const QWEN_SKILL_SOURCES = ["bundled-skill", "skill-dir-command"];
21
31
  */
22
32
  export function acpManifest(agent: unknown, version: unknown, update: unknown, observedAt: number): CapabilityManifest {
23
33
  const empty: CapabilityManifest = { capabilities: [], observedAt };
24
- const kind = agent === NATIVE_PINS.kimi.agent && version === NATIVE_PINS.kimi.version ? "kimi"
25
- : agent === NATIVE_PINS.qwen.agent && version === NATIVE_PINS.qwen.version ? "qwen" : undefined;
34
+ const kind = agent === NATIVE_PINS.kimi.agent && listable("kimi-capabilities", version) ? "kimi"
35
+ : agent === NATIVE_PINS.qwen.agent && listable("qwen-capabilities", version) ? "qwen" : undefined;
26
36
  if (!kind || !object(update) || !Array.isArray(update.availableCommands)) return empty;
27
37
  const candidates: Candidate[] = [];
28
38
  for (const command of update.availableCommands) {
@@ -34,10 +44,10 @@ export function acpManifest(agent: unknown, version: unknown, update: unknown, o
34
44
  return buildManifest(candidates, observedAt);
35
45
  }
36
46
 
37
- /** A Codex `skills/list` answer as capabilities, on the probed version only. Only a skill that says `enabled: true` is listed: a flag that is missing or unreadable is not consent. */
47
+ /** A Codex `skills/list` answer as capabilities, on a verified version, or an exact version the person trusted with `ahub agents trust`, only. Only a skill that says `enabled: true` is listed: a flag that is missing or unreadable is not consent. */
38
48
  export function codexSkillsManifest(version: unknown, result: unknown, observedAt: number): CapabilityManifest {
39
49
  const candidates: Candidate[] = [];
40
- if (version === NATIVE_PINS.codex.version && object(result) && Array.isArray(result.data)) {
50
+ if (listable("codex-capabilities", version) && object(result) && Array.isArray(result.data)) {
41
51
  for (const entry of result.data) {
42
52
  if (!object(entry) || !Array.isArray(entry.skills)) continue;
43
53
  for (const skill of entry.skills) {
@@ -4,7 +4,7 @@ import { isFixedBuiltinDefinition, type AdapterDefinition } from "./registry.ts"
4
4
  /** Presence is forbidden on a foreign runtime, including a member whose value is undefined. */
5
5
  export function assertNativeProofPorts(definition: AdapterDefinition | undefined, product: PeerAdapter): void {
6
6
  if (isFixedBuiltinDefinition(definition)) return;
7
- for (const port of ["frontendProxy", "statusNotice", "revertTurn"] as const) {
7
+ for (const port of ["frontendProxy", "statusNotice", "revertTurn", "compareQuotaHome", "readQuotaNow"] as const) {
8
8
  if (port in product) throw new Error(`${definition?.kind ?? product.id}: ${port} is restricted to fixed builtin adapter products`);
9
9
  }
10
10
  }
@@ -0,0 +1,136 @@
1
+ import { existsSync, readFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { shellQuote } from "../cli/shell-quote.ts";
5
+ import presetsJson from "../../templates/presets/agents.json";
6
+
7
+ /** #1809 T1: a known agent CLI as data. A preset names no code; `ahub agents add` turns it into the same declaration a person could write by hand. */
8
+ export interface AgentPreset {
9
+ id: string;
10
+ displayName: string;
11
+ executable: string;
12
+ acp?: { args: string[]; identity: { name: string } };
13
+ versionArgs: string[];
14
+ mcp: { add: string[] | null; check: { file: string; key: string } };
15
+ recorded: string;
16
+ status: "verified" | "untested";
17
+ receipt: string | null;
18
+ }
19
+ interface PresetRow { id: string; displayName: string; executable: string; acp: boolean; status: "verified" | "untested"; receipt: string | null; recorded: string }
20
+
21
+ const REPOSITORY_ROOT = new URL("../../", import.meta.url);
22
+ const KIND = /^[a-z][a-z0-9-]{0,31}$/;
23
+
24
+ function text(value: unknown, at: string): string {
25
+ if (typeof value !== "string" || !value || value.length > 512) throw new Error(`presets: ${at} must be a short nonempty string`);
26
+ return value;
27
+ }
28
+ function words(value: unknown, at: string): string[] {
29
+ if (!Array.isArray(value) || value.length > 32) throw new Error(`presets: ${at} must be a short list`);
30
+ return value.map((item, index) => text(item, `${at}[${index}]`));
31
+ }
32
+
33
+ /** The presets file read strictly: an unknown field or a wrong type refuses the whole file, so a typo never becomes a launch line. */
34
+ export function loadPresets(raw: unknown = presetsJson): readonly AgentPreset[] {
35
+ const file = raw as { schemaVersion?: unknown; presets?: unknown };
36
+ if (file?.schemaVersion !== 1 || !Array.isArray(file.presets)) throw new Error("presets: unsupported file");
37
+ const seen = new Set<string>();
38
+ return Object.freeze(file.presets.map((entry: Record<string, unknown>, index): AgentPreset => {
39
+ const at = `presets[${index}]`;
40
+ const unknown = Object.keys(entry).filter(key => !["id", "displayName", "executable", "acp", "versionArgs", "mcp", "recorded", "status", "receipt"].includes(key));
41
+ if (unknown.length) throw new Error(`presets: ${at} has unknown field ${unknown[0]}`);
42
+ const id = text(entry.id, `${at}.id`);
43
+ if (!KIND.test(id) || seen.has(id)) throw new Error(`presets: ${at}.id is invalid or repeated`);
44
+ seen.add(id);
45
+ const acp = entry.acp as { args?: unknown; identity?: { name?: unknown } } | undefined;
46
+ const mcp = entry.mcp as { add?: unknown; check?: { file?: unknown; key?: unknown } };
47
+ if (entry.status !== "verified" && entry.status !== "untested") throw new Error(`presets: ${at}.status must be verified or untested`);
48
+ if (entry.receipt !== null && typeof entry.receipt !== "string") throw new Error(`presets: ${at}.receipt must be a path or null`);
49
+ return {
50
+ id, displayName: text(entry.displayName, `${at}.displayName`), executable: text(entry.executable, `${at}.executable`),
51
+ ...(acp ? { acp: { args: words(acp.args, `${at}.acp.args`), identity: { name: text(acp.identity?.name, `${at}.acp.identity.name`) } } } : {}),
52
+ versionArgs: words(entry.versionArgs, `${at}.versionArgs`),
53
+ mcp: { add: mcp?.add === null ? null : words(mcp?.add, `${at}.mcp.add`), check: { file: text(mcp?.check?.file, `${at}.mcp.check.file`), key: text(mcp?.check?.key, `${at}.mcp.check.key`) } },
54
+ recorded: text(entry.recorded, `${at}.recorded`), status: entry.status, receipt: entry.receipt as string | null,
55
+ };
56
+ }));
57
+ }
58
+
59
+ /** `verified` only when the row says so and its receipt file is there; every other preset is `untested`, whatever the row claims. */
60
+ function presetStatus(preset: AgentPreset, root: URL = REPOSITORY_ROOT): "verified" | "untested" {
61
+ return preset.status === "verified" && preset.receipt !== null && preset.receipt.startsWith("docs/verification/") && !preset.receipt.includes("..") && existsSync(new URL(preset.receipt, root)) ? "verified" : "untested";
62
+ }
63
+
64
+ /** The status word of a preset id; an id the presets file does not know is `untested`, never an error. */
65
+ export function presetStatusById(id: string, presets: readonly AgentPreset[] = loadPresets()): "verified" | "untested" {
66
+ const row = presets.find(preset => preset.id === id);
67
+ return row ? presetStatus(row) : "untested";
68
+ }
69
+
70
+ export function presetRows(presets: readonly AgentPreset[] = loadPresets(), root?: URL): PresetRow[] {
71
+ return presets.map(preset => ({ id: preset.id, displayName: preset.displayName, executable: preset.executable, acp: preset.acp !== undefined, status: presetStatus(preset, root), receipt: preset.receipt, recorded: preset.recorded }));
72
+ }
73
+
74
+ /** The first dotted-number token of a version probe's output, or undefined: the pin a start checks `initialize` against. */
75
+ export function parseProbeVersion(output: string): string | undefined {
76
+ return /\b\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.-]+)?\b/.exec(output)?.[0];
77
+ }
78
+
79
+ /** The `adapters.<kind>` declaration for a preset: exactly the fields a hand-written ACP declaration has, so it passes the same validation. */
80
+ export function presetDeclaration(preset: AgentPreset, resolvedExecutable: string, version: string): Record<string, unknown> {
81
+ if (!preset.acp) throw new Error(`${preset.id} has no headless launch line`);
82
+ return {
83
+ transport: "acp", command: resolvedExecutable, args: [...preset.acp.args], displayName: preset.displayName,
84
+ roles: ["implementer", "verifier"], identity: { name: preset.acp.identity.name, version }, preset: preset.id,
85
+ };
86
+ }
87
+
88
+ /** The bridge bundle a pull CLI registers, in the installed package; `agents add --pull` and `ahub doctor` print the same path. */
89
+ export const BRIDGE_BUNDLE = fileURLToPath(new URL("../../plugins/agent-hub/server.js", import.meta.url));
90
+
91
+ /** The name the hub's bridge is registered under in a pull CLI's MCP settings. */
92
+ const BRIDGE_NAME = "agent-hub";
93
+
94
+ /** The `adapters.<kind>` declaration of a pull kind for a preset: the person's own TUI, `tasks: false`, the same fields a hand-written one has. */
95
+ export function presetPullDeclaration(preset: AgentPreset, resolvedExecutable: string): Record<string, unknown> {
96
+ return { transport: "pull", command: resolvedExecutable, args: [], displayName: preset.displayName, roles: ["implementer", "verifier"], versionArgs: [...preset.versionArgs], tasks: false, preset: preset.id };
97
+ }
98
+
99
+ /**
100
+ * What the person runs to register the hub's bridge in the CLI, printed and never run. `{name}`, `{command}` and `{args}` of the preset's template take
101
+ * the bridge name, the Bun that runs it and the bundle path; a preset with no scripted form (`add: null`) says where to put the entry instead.
102
+ */
103
+ export function registrationText(preset: AgentPreset, bun: string, bridge: string): string {
104
+ if (preset.mcp.add === null) return `${preset.displayName} has no scripted registration: add an MCP server named ${BRIDGE_NAME} that runs ${shellQuote(bun)} ${shellQuote(bridge)} to ${preset.mcp.check.file} under ${preset.mcp.check.key}`;
105
+ const words = preset.mcp.add.flatMap(word => word === "{args}" ? [bridge] : [word.replace("{name}", BRIDGE_NAME).replace("{command}", bun)]);
106
+ return words.map(shellQuote).join(" ");
107
+ }
108
+
109
+ /** Whether the CLI's settings file names the bridge: `present`, `missing` (a readable file without it, or no file) or `unknown` (a file this check cannot read). Reads one file, writes nothing. */
110
+ function registrationState(preset: AgentPreset, home: string): "present" | "missing" | "unknown" {
111
+ const file = preset.mcp.check.file.startsWith("~/") ? join(home, preset.mcp.check.file.slice(2)) : preset.mcp.check.file;
112
+ if (!existsSync(file)) return "missing";
113
+ try {
114
+ const parsed = JSON.parse(readFileSync(file, "utf8")) as Record<string, unknown>;
115
+ const block = parsed?.[preset.mcp.check.key];
116
+ return block && typeof block === "object" && !Array.isArray(block) ? (Object.hasOwn(block, BRIDGE_NAME) ? "present" : "missing") : "missing";
117
+ } catch { return "unknown"; }
118
+ }
119
+
120
+ /** One doctor row for each configured pull kind written from a known preset. */
121
+ export function pullRegistrationChecks(adapters: unknown, home: string, presets: readonly AgentPreset[] = loadPresets()): { kind: string; preset: string; state: "present" | "missing" | "unknown"; command: string }[] {
122
+ if (!adapters || typeof adapters !== "object") return [];
123
+ return Object.entries(adapters as Record<string, unknown>).flatMap(([kind, raw]) => {
124
+ const declared = raw as { transport?: unknown; preset?: unknown } | null;
125
+ const preset = declared?.transport === "pull" && typeof declared.preset === "string" ? presets.find(row => row.id === declared.preset) : undefined;
126
+ return preset ? [{ kind, preset: preset.id, state: registrationState(preset, home), command: registrationText(preset, process.execPath, BRIDGE_BUNDLE) }] : [];
127
+ });
128
+ }
129
+
130
+ /** Reads a JSON file that may not exist: absent is undefined; a file that is not valid JSON throws, so a write never replaces what it cannot read. */
131
+ export function readJsonFile(file: string): Record<string, unknown> | undefined {
132
+ if (!existsSync(file)) return undefined;
133
+ const value = JSON.parse(readFileSync(file, "utf8")) as unknown;
134
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error(`${file} is not a JSON object`);
135
+ return value as Record<string, unknown>;
136
+ }
@@ -106,10 +106,10 @@ const NOTIFICATION_CAP = 64 * 1024;
106
106
  export function isQwenTaskNotification(text: string): boolean { return text.length <= NOTIFICATION_CAP && QWEN_TASK_NOTIFICATIONS.test(text); }
107
107
 
108
108
  /** `qwen --version` against the dual-output compat entry. Never throws: a refusal is a reason. */
109
- export async function qwenDualVersionAsync(cmd: readonly string[], cwd: string): Promise<{ ok: true; version: string; note?: string } | { ok: false; reason: string }> {
109
+ export async function qwenDualVersionAsync(cmd: readonly string[], cwd: string, env: NodeJS.ProcessEnv = process.env): Promise<{ ok: true; version: string; note?: string } | { ok: false; reason: string }> {
110
110
  const [bin, ...prefix] = cmd.filter(word => word !== "--acp");
111
111
  try {
112
- const child = Bun.spawn([bin ?? "qwen", ...prefix, "--version"], { cwd, stdout: "pipe", stderr: "ignore", stdin: "ignore", env: withoutOrcaEnv(childEnv(process.env)) });
112
+ const child = Bun.spawn([bin ?? "qwen", ...prefix, "--version"], { cwd, stdout: "pipe", stderr: "ignore", stdin: "ignore", env: withoutOrcaEnv(childEnv(env)) });
113
113
  const timer = setTimeout(() => child.kill("SIGKILL"), 10_000);
114
114
  const out = await new Response(child.stdout).text(); await child.exited; clearTimeout(timer);
115
115
  const verdict = assessVersion("qwen-dual", out.trim());
@@ -209,6 +209,8 @@ export interface AdapterDefinition {
209
209
  family: string;
210
210
  transport: "acp" | "codex-appserver" | "claude-channel" | "ws-pull" | "hub-native";
211
211
  roles: readonly string[];
212
+ /** #1809: `false` means the kind owns no task. Every ownership view reads this field, never the transport; only a configured pull kind sets it, and nothing sets it to `true` yet. */
213
+ tasks?: false;
212
214
  optional?: boolean;
213
215
  defaultOnRoster?: boolean;
214
216
  /** A legacy enable switch gates new starts, not retained sockets or queues. */
@@ -381,6 +383,7 @@ export type KindMap = Readonly<Record<string, { readonly kind: string; readonly
381
383
  export interface ProjectAdapterCatalog {
382
384
  readonly definitions: readonly AdapterDefinition[];
383
385
  readonly externalDefinitions: readonly AdapterDefinition[];
386
+ declaredHeadlessFactory?(definition: AdapterDefinition): boolean | undefined;
384
387
  definitionOf(id: string, instances?: KindMap): AdapterDefinition | undefined;
385
388
  kindOf(id: string, instances?: KindMap): string | undefined;
386
389
  familyOf(id: string, instances?: KindMap): string | undefined;