@platless/axom-cli 0.3.13 → 0.6.36

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 (320) hide show
  1. package/README.md +18 -5
  2. package/dist/axom-patch/cli/README.md +119 -9
  3. package/dist/axom-patch/cli/account-limits/README.md +27 -0
  4. package/dist/axom-patch/cli/account-limits/antigravity-proxy.mjs +47 -0
  5. package/dist/axom-patch/cli/account-limits/antigravity-read.mjs +90 -0
  6. package/dist/axom-patch/cli/account-limits/antigravity.mjs +46 -0
  7. package/dist/axom-patch/cli/account-limits/generate.py +123 -0
  8. package/dist/axom-patch/cli/account-limits/kimi-proxy.mjs +81 -0
  9. package/dist/axom-patch/cli/account-limits/normalize.mjs +151 -0
  10. package/dist/axom-patch/cli/claude-account-limits.json +37 -0
  11. package/dist/axom-patch/cli/codex-account-limits.json +37 -0
  12. package/dist/axom-patch/cli/codex-terminal-output.json +16 -0
  13. package/dist/axom-patch/cli/commandcode-account-limits.json +30 -0
  14. package/dist/axom-patch/cli/kimi-quota.mjs +12 -0
  15. package/dist/axom-patch/cli/kimi-subagents.mjs +173 -0
  16. package/dist/axom-patch/cli/nightly-task.md +194 -0
  17. package/dist/axom-patch/cli/pi-subagent-subwork.json +23 -0
  18. package/dist/axom-patch/cli/probes/claude-late-async-terminal.mjs +5 -1
  19. package/dist/axom-patch/cli/probes/codex-terminal-output.mjs +33 -0
  20. package/dist/axom-patch/cli/probes/kimi-subagent-subwork.mjs +82 -0
  21. package/dist/axom-patch/cli/probes/pi-subagent-subwork.mjs +211 -0
  22. package/dist/axom-patch/cli/probes/zcode-subagent-subwork.mjs +257 -0
  23. package/dist/axom-patch/cli/qoder/dist/axom-acp-compat.mjs +1591 -0
  24. package/dist/axom-patch/cli/qoder/releases/1.1.75.json +360 -0
  25. package/dist/axom-patch/cli/qoder-background-terminal.md +13 -5
  26. package/dist/axom-patch/cli/qoder-foreground-output.md +14 -7
  27. package/dist/axom-patch/cli/qoder-native-acp.json +227 -0
  28. package/dist/axom-patch/cli/qoder-steering.md +20 -25
  29. package/dist/axom-patch/cli/qoder-subagent-subwork.md +17 -68
  30. package/dist/axom-patch/cli/runtime.json +39 -15
  31. package/dist/axom-patch/cli/zcode-account-limits.json +30 -0
  32. package/dist/axom-patch/cli/zcode-models.json +37 -0
  33. package/dist/axom-patch/cli/zcode-subagent-subwork.json +72 -0
  34. package/dist/cli.js +4 -9
  35. package/dist/commands/knowledge.js +47 -0
  36. package/dist/commands/update.js +65 -3
  37. package/dist/commands/workstation.js +73 -7
  38. package/dist/install/claude/commands.js +13 -13
  39. package/dist/keepers/acp/keeper.mjs +3083 -0
  40. package/dist/keepers/acp/manifest.json +9 -0
  41. package/dist/keepers/terminal/keeper.mjs +8469 -0
  42. package/dist/keepers/terminal/manifest.json +9 -0
  43. package/dist/keepers/terminal/node_modules/node-pty/lib/conpty_console_list_agent.js +25 -0
  44. package/dist/keepers/terminal/node_modules/node-pty/lib/eventEmitter2.js +47 -0
  45. package/dist/keepers/terminal/node_modules/node-pty/lib/index.js +52 -0
  46. package/dist/keepers/terminal/node_modules/node-pty/lib/interfaces.js +7 -0
  47. package/dist/keepers/terminal/node_modules/node-pty/lib/shared/conout.js +10 -0
  48. package/dist/keepers/terminal/node_modules/node-pty/lib/terminal.js +190 -0
  49. package/dist/keepers/terminal/node_modules/node-pty/lib/types.js +7 -0
  50. package/dist/keepers/terminal/node_modules/node-pty/lib/unixTerminal.js +351 -0
  51. package/dist/keepers/terminal/node_modules/node-pty/lib/utils.js +38 -0
  52. package/dist/keepers/terminal/node_modules/node-pty/lib/windowsConoutConnection.js +131 -0
  53. package/dist/keepers/terminal/node_modules/node-pty/lib/windowsPtyAgent.js +344 -0
  54. package/dist/keepers/terminal/node_modules/node-pty/lib/windowsTerminal.js +209 -0
  55. package/dist/keepers/terminal/node_modules/node-pty/lib/worker/conoutSocketWorker.js +22 -0
  56. package/dist/keepers/terminal/node_modules/node-pty/package.json +66 -0
  57. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-arm64/pty.node +0 -0
  58. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper +0 -0
  59. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-x64/pty.node +0 -0
  60. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/darwin-x64/spawn-helper +0 -0
  61. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/linux-arm64/pty.node +0 -0
  62. package/dist/keepers/terminal/node_modules/node-pty/prebuilds/linux-x64/pty.node +0 -0
  63. package/dist/mcp.js +1 -1
  64. package/dist/native/darwin-arm64/axom-quic +0 -0
  65. package/dist/test/keeperKit.js +67 -0
  66. package/dist/workstation/acp/acpAgents.js +2192 -636
  67. package/dist/workstation/acp/acpClient.js +84 -495
  68. package/dist/workstation/acp/adoption.js +10 -396
  69. package/dist/workstation/acp/binaryInstall.js +100 -27
  70. package/dist/workstation/acp/builds/gc.js +245 -0
  71. package/dist/workstation/acp/builds/install/binary.js +28 -0
  72. package/dist/workstation/acp/builds/install/npm.js +324 -0
  73. package/dist/workstation/acp/builds/install/uv.js +254 -0
  74. package/dist/workstation/acp/builds/migrate.js +195 -0
  75. package/dist/workstation/acp/builds/model.js +128 -0
  76. package/dist/workstation/acp/builds/nodeGate.js +100 -0
  77. package/dist/workstation/acp/builds/store.js +352 -0
  78. package/dist/workstation/acp/commandTableProbe.js +68 -0
  79. package/dist/workstation/acp/configOptions.js +103 -1
  80. package/dist/workstation/acp/envSecrets.js +27 -0
  81. package/dist/workstation/acp/initializeResponse.js +290 -0
  82. package/dist/workstation/acp/installErrors.js +12 -2
  83. package/dist/workstation/acp/installProbe.js +1 -1
  84. package/dist/workstation/acp/managedPatches.js +239 -159
  85. package/dist/workstation/acp/managedRuntime.js +314 -0
  86. package/dist/workstation/acp/outbox.js +330 -0
  87. package/dist/workstation/acp/patchAssets.js +60 -3
  88. package/dist/workstation/acp/permission.js +42 -10
  89. package/dist/workstation/acp/processor/checkpoint.js +78 -0
  90. package/dist/workstation/acp/processor/commands.js +35 -0
  91. package/dist/workstation/acp/processor/control.js +282 -0
  92. package/dist/workstation/acp/processor/emit.js +26 -0
  93. package/dist/workstation/acp/processor/jsonrpc.js +172 -0
  94. package/dist/workstation/acp/processor/memoryLog.js +49 -0
  95. package/dist/workstation/acp/processor/origins.js +48 -0
  96. package/dist/workstation/acp/processor/output.js +67 -0
  97. package/dist/workstation/acp/processor/projection.js +42 -0
  98. package/dist/workstation/acp/processor/record.js +128 -0
  99. package/dist/workstation/acp/processor/runtime.js +105 -0
  100. package/dist/workstation/acp/processor/sdkSchemas.js +61 -0
  101. package/dist/workstation/acp/processor/session.js +496 -0
  102. package/dist/workstation/acp/processor/state.js +67 -0
  103. package/dist/workstation/acp/processor/step.js +442 -0
  104. package/dist/workstation/acp/processor/test/fixtureLog.js +58 -0
  105. package/dist/workstation/acp/processor/test/harness.js +120 -0
  106. package/dist/workstation/acp/processor/test/largeIdEcho.js +50 -0
  107. package/dist/workstation/acp/processor/test/rawAgent.js +70 -0
  108. package/dist/workstation/acp/processor/transport/generations.js +76 -0
  109. package/dist/workstation/acp/processor/transport/keeper.js +130 -0
  110. package/dist/workstation/acp/processor/transport/local.js +269 -0
  111. package/dist/workstation/acp/processor/transport/types.js +78 -0
  112. package/dist/workstation/acp/processor/updates.js +390 -0
  113. package/dist/workstation/acp/processorSession.js +1348 -0
  114. package/dist/workstation/acp/registry/catalog.js +189 -41
  115. package/dist/workstation/acp/registry/launch.js +76 -119
  116. package/dist/workstation/acp/sessionUpdateMapper.js +18 -7
  117. package/dist/workstation/acp/steering.js +58 -0
  118. package/dist/workstation/acp/switching.js +111 -0
  119. package/dist/workstation/acp/terminalLogin.js +16 -42
  120. package/dist/workstation/acp/terminalLoginSpec.js +41 -0
  121. package/dist/workstation/acp/test/adapterFixtures.js +256 -0
  122. package/dist/workstation/acp/test/daemonLife.js +106 -0
  123. package/dist/workstation/acp/test/fakeAgent.js +13 -0
  124. package/dist/workstation/acp/test/keeperWorld.js +295 -0
  125. package/dist/workstation/acp/test/memoryOutbox.js +55 -0
  126. package/dist/workstation/acp/test/raw/fixtures.js +196 -0
  127. package/dist/workstation/acp/test/raw/sanitize.js +344 -0
  128. package/dist/workstation/acp/test/raw/sources.js +135 -0
  129. package/dist/workstation/acp/test/realAdapter.js +331 -0
  130. package/dist/workstation/acp/test/scriptAgent.js +214 -0
  131. package/dist/workstation/acp/test/sessionFrames.js +42 -0
  132. package/dist/workstation/acp/timedCommand.js +4 -2
  133. package/dist/workstation/acp/uvxInstall.js +72 -122
  134. package/dist/workstation/agentFlow.js +103 -0
  135. package/dist/workstation/agentSessions.js +1289 -544
  136. package/dist/workstation/channels/agent.js +7 -5
  137. package/dist/workstation/channels/computer.js +69 -21
  138. package/dist/workstation/channels/computerExecs.js +200 -0
  139. package/dist/workstation/channels/management.js +172 -8
  140. package/dist/workstation/channels/url.js +1 -1
  141. package/dist/workstation/config.js +16 -4
  142. package/dist/workstation/connection/encryptedChannel.js +4 -1
  143. package/dist/workstation/control/bindingStore.js +200 -0
  144. package/dist/workstation/control/commands.js +124 -0
  145. package/dist/workstation/control/daemonIdentity.js +53 -0
  146. package/dist/workstation/control/enrollment.js +106 -0
  147. package/dist/workstation/control/inspect.js +71 -0
  148. package/dist/workstation/control/locks.js +63 -0
  149. package/dist/workstation/control/protocol.js +40 -0
  150. package/dist/workstation/control/restartGuard.js +46 -0
  151. package/dist/workstation/control/runtimeClient.js +97 -0
  152. package/dist/workstation/control/runtimeHost.js +148 -0
  153. package/dist/workstation/control/serverIdentity.js +35 -0
  154. package/dist/workstation/daemon.js +393 -12
  155. package/dist/workstation/daemonctl.js +103 -14
  156. package/dist/workstation/desktopControl/audio.js +99 -0
  157. package/dist/workstation/desktopControl/capabilities.js +92 -0
  158. package/dist/workstation/desktopControl/captureModes.js +9 -0
  159. package/dist/workstation/desktopControl/captureTargetLabel.js +9 -0
  160. package/dist/workstation/desktopControl/deviceSockets.js +246 -0
  161. package/dist/workstation/desktopControl/helperProcess.js +353 -0
  162. package/dist/workstation/desktopControl/lobby.js +129 -0
  163. package/dist/workstation/desktopControl/macProvider.js +155 -0
  164. package/dist/workstation/desktopControl/media.js +331 -0
  165. package/dist/workstation/desktopControl/nativeProvider.js +1018 -0
  166. package/dist/workstation/desktopControl/networkEvidence.js +43 -0
  167. package/dist/workstation/desktopControl/overview.js +58 -0
  168. package/dist/workstation/desktopControl/protocol.js +302 -0
  169. package/dist/workstation/desktopControl/quicMedia.js +240 -0
  170. package/dist/workstation/desktopControl/rateController.js +226 -0
  171. package/dist/workstation/desktopControl/supervisor.js +1681 -0
  172. package/dist/workstation/desktopControl/transport.js +27 -0
  173. package/dist/workstation/desktopControl/wallpaper.js +78 -0
  174. package/dist/workstation/exec/attach.js +126 -0
  175. package/dist/workstation/exec/command.js +40 -0
  176. package/dist/workstation/exec/durable.js +517 -0
  177. package/dist/workstation/exec/fallback.js +106 -0
  178. package/dist/workstation/exec/policy.js +837 -0
  179. package/dist/workstation/exec/shaping.js +211 -0
  180. package/dist/workstation/exec.js +3 -112
  181. package/dist/workstation/files/adapters/computerFileFrames.js +51 -0
  182. package/dist/workstation/files/adapters/toolRequests.js +121 -0
  183. package/dist/workstation/files/client.js +455 -0
  184. package/dist/workstation/files/credentials.js +142 -0
  185. package/dist/workstation/files/errors.js +28 -0
  186. package/dist/workstation/files/fence.js +350 -0
  187. package/dist/workstation/files/find/fileIndex.js +153 -0
  188. package/dist/workstation/files/find/fuzzy.js +155 -0
  189. package/dist/workstation/files/host.js +122 -0
  190. package/dist/workstation/files/hostProtocol.js +2 -0
  191. package/dist/workstation/files/media/cache.js +620 -0
  192. package/dist/workstation/files/media/encoding.js +308 -0
  193. package/dist/workstation/files/media/estimator.js +100 -0
  194. package/dist/workstation/files/media/media.js +325 -0
  195. package/dist/workstation/files/media/packedAudio.js +23 -0
  196. package/dist/workstation/files/media/scheduler.js +551 -0
  197. package/dist/workstation/files/media/types.js +5 -0
  198. package/dist/workstation/files/scope.js +45 -0
  199. package/dist/workstation/files/structured.js +284 -0
  200. package/dist/workstation/{fileOps.js → files/text.js} +152 -39
  201. package/dist/workstation/files/uploads.js +351 -0
  202. package/dist/workstation/journal.js +65 -236
  203. package/dist/workstation/keepers/acp/client.js +101 -0
  204. package/dist/workstation/keepers/acp/envelope.js +62 -0
  205. package/dist/workstation/keepers/acp/host.js +419 -0
  206. package/dist/workstation/keepers/acp/main.js +18 -0
  207. package/dist/workstation/keepers/acp/memoryStream.js +121 -0
  208. package/dist/workstation/keepers/acp/params.js +137 -0
  209. package/dist/workstation/keepers/acp/protocol.js +66 -0
  210. package/dist/workstation/keepers/acp/recover.js +120 -0
  211. package/dist/workstation/keepers/acp/session.js +584 -0
  212. package/dist/workstation/keepers/acp/stderr.js +154 -0
  213. package/dist/workstation/keepers/kit/activity.js +103 -0
  214. package/dist/workstation/keepers/kit/bootstrap.js +164 -0
  215. package/dist/workstation/keepers/kit/buildVersion.js +51 -0
  216. package/dist/workstation/keepers/kit/bundle.js +124 -0
  217. package/dist/workstation/keepers/kit/client.js +432 -0
  218. package/dist/workstation/keepers/kit/identity.js +21 -0
  219. package/dist/workstation/keepers/kit/ipc.js +112 -0
  220. package/dist/workstation/keepers/kit/launchConfig.js +8 -0
  221. package/dist/workstation/keepers/kit/launcher.js +289 -0
  222. package/dist/workstation/keepers/kit/lock.js +123 -0
  223. package/dist/workstation/keepers/kit/orphanSweep.js +86 -0
  224. package/dist/workstation/keepers/kit/paths.js +76 -0
  225. package/dist/workstation/keepers/kit/protocol.js +43 -0
  226. package/dist/workstation/keepers/kit/server.js +518 -0
  227. package/dist/workstation/keepers/kit/streamLog.js +697 -0
  228. package/dist/workstation/keepers/legacy.js +296 -0
  229. package/dist/workstation/keepers/policy.js +576 -0
  230. package/dist/workstation/keepers/stop.js +34 -0
  231. package/dist/workstation/keepers/terminal/client.js +213 -0
  232. package/dist/workstation/keepers/terminal/exec.js +981 -0
  233. package/dist/workstation/keepers/terminal/generations.js +129 -0
  234. package/dist/workstation/keepers/terminal/keeper.js +62 -0
  235. package/dist/workstation/keepers/terminal/main.js +43 -0
  236. package/dist/workstation/keepers/terminal/orphanSweep.js +3 -0
  237. package/dist/workstation/keepers/terminal/params.js +27 -0
  238. package/dist/workstation/keepers/terminal/protocol.js +56 -0
  239. package/dist/workstation/keepers/terminal/pty.js +330 -0
  240. package/dist/workstation/managedInstall.js +57 -0
  241. package/dist/workstation/protocol/accountLimits.js +47 -0
  242. package/dist/workstation/protocol/agent.js +50 -19
  243. package/dist/workstation/protocol/common.js +30 -0
  244. package/dist/workstation/protocol/computer.js +15 -4
  245. package/dist/workstation/protocol/management.js +141 -4
  246. package/dist/workstation/protocol/runtimeDiagnostics.js +15 -0
  247. package/dist/workstation/rd/artifact.js +119 -0
  248. package/dist/workstation/rd/control.js +119 -0
  249. package/dist/workstation/rd/display.js +29 -0
  250. package/dist/workstation/rd/provider.js +222 -0
  251. package/dist/workstation/rd/sessions.js +391 -0
  252. package/dist/workstation/rd/state.js +45 -0
  253. package/dist/workstation/rd/update.js +171 -0
  254. package/dist/workstation/rd/upkeep.js +38 -0
  255. package/dist/workstation/register.js +27 -37
  256. package/dist/workstation/service/installer.js +104 -13
  257. package/dist/workstation/service/launchd.js +1 -0
  258. package/dist/workstation/storageMetrics.js +118 -0
  259. package/dist/workstation/systemMetrics.js +154 -93
  260. package/dist/workstation/toolchain.js +94 -0
  261. package/dist/workstation/tools/browser.js +28 -4
  262. package/dist/workstation/tools/client.js +9 -1
  263. package/dist/workstation/tools/info.js +50 -0
  264. package/dist/workstation/tools/keeperProcess.js +15 -5
  265. package/dist/workstation/tools/router.js +55 -0
  266. package/dist/workstation/tools/terminalRouter.js +222 -0
  267. package/dist/workstation/tools/validation.js +37 -1
  268. package/dist/workstation/update/artifact.js +2 -1
  269. package/dist/workstation/update/coordinator.js +3 -0
  270. package/dist/workstation/update/globalInstall.js +116 -0
  271. package/dist/workstation/update/npmInstaller.js +49 -23
  272. package/dist/workstation/update/ptyPreflight.js +21 -0
  273. package/dist/workstation/update/rdRollback.js +145 -0
  274. package/dist/workstation/update/runUpdate.js +3 -2
  275. package/dist/workstation/update/taskRegistry.js +105 -11
  276. package/dist/workstation/update/watchdog.js +16790 -334
  277. package/package.json +11 -8
  278. package/skills/axom/SKILL.md +11 -11
  279. package/skills/axom-definition/SKILL.md +3 -3
  280. package/skills/axom-platform/SKILL.md +3 -3
  281. package/dist/axom-patch/cli/probes/qoder-steering.mjs +0 -89
  282. package/dist/axom-patch/cli/probes/qoder-subagent-origin.mjs +0 -49
  283. package/dist/axom-patch/cli/qoder-steering.json +0 -52
  284. package/dist/axom-patch/cli/qoder-subagent-origin.json +0 -73
  285. package/dist/commands/guide.js +0 -38
  286. package/dist/workstation/acp/acpSession.js +0 -1475
  287. package/dist/workstation/acp/contract.js +0 -499
  288. package/dist/workstation/acp/delegationMcp.js +0 -24
  289. package/dist/workstation/acp/draftInterceptor.js +0 -163
  290. package/dist/workstation/acp/qoderStartup.js +0 -45
  291. package/dist/workstation/acp/sessionScope.js +0 -19
  292. package/dist/workstation/filePaths.js +0 -174
  293. package/dist/workstation/fileWorker.js +0 -81
  294. package/dist/workstation/fileWorkerClient.js +0 -121
  295. package/dist/workstation/qoderAdapter/backgroundProcess.js +0 -106
  296. package/dist/workstation/qoderAdapter/backgroundTerminal.js +0 -262
  297. package/dist/workstation/qoderAdapter/completedContinuation.js +0 -139
  298. package/dist/workstation/qoderAdapter/contract.js +0 -78
  299. package/dist/workstation/qoderAdapter/foregroundOutput.js +0 -30
  300. package/dist/workstation/qoderAdapter/history.js +0 -87
  301. package/dist/workstation/qoderAdapter/identityIndex.js +0 -191
  302. package/dist/workstation/qoderAdapter/inputQueue.js +0 -42
  303. package/dist/workstation/qoderAdapter/main.js +0 -93
  304. package/dist/workstation/qoderAdapter/mapper.js +0 -117
  305. package/dist/workstation/qoderAdapter/observerPlugin.js +0 -245
  306. package/dist/workstation/qoderAdapter/observerReceiver.js +0 -187
  307. package/dist/workstation/qoderAdapter/permissions.js +0 -61
  308. package/dist/workstation/qoderAdapter/profile.js +0 -93
  309. package/dist/workstation/qoderAdapter/sdkDriver.js +0 -49
  310. package/dist/workstation/qoderAdapter/session.js +0 -319
  311. package/dist/workstation/qoderAdapter/subagentMeta.js +0 -28
  312. package/dist/workstation/qoderAdapter/subwork.js +0 -77
  313. package/dist/workstation/qoderAdapter/taskControl.js +0 -38
  314. package/dist/workstation/qoderAdapter/taskEvent.js +0 -26
  315. package/dist/workstation/qoderAdapter/taskLedger.js +0 -163
  316. package/dist/workstation/qoderAdapter/usage.js +0 -37
  317. package/dist/workstation/tools/core.js +0 -50
  318. package/dist/workstation/tools/files.js +0 -525
  319. package/dist/workstation/tools/terminal.js +0 -214
  320. /package/dist/workstation/{qoderAdapter/types.js → desktopControl/provider.js} +0 -0
@@ -0,0 +1,290 @@
1
+ /**
2
+ * The `initialize` handshake, as data: the params this client sends and what it reads out of the
3
+ * agent's reply.
4
+ *
5
+ * ## Why this is its own module
6
+ *
7
+ * Two readers must agree on every byte of this: `connectAgent` (the live SDK path) and the
8
+ * deterministic ACP processor (`processor/`, spec 2026-10-11 §5.4), which parses the same reply off
9
+ * the keeper's raw log inside `step`. `step`'s import graph may not reach anything that spawns a
10
+ * process, reads the clock or draws a random id (`processor/guard.test.ts`), and `acpClient.ts` does
11
+ * all three — so the pure half lives here and `acpClient.ts` re-exports every name it used to own.
12
+ * One implementation rather than two kept equal by a test: the equivalence test in
13
+ * `processor/initialize.test.ts` then guards the processor's *wiring* (the right line, the right
14
+ * result), not a second copy of these rules.
15
+ *
16
+ * The runtime profile in `_meta` is deliberately not read here: it belongs to the connection's
17
+ * runtime diagnostics, which the processor takes over in Task 17b/17c.
18
+ */
19
+ import { PROTOCOL_VERSION } from '@agentclientprotocol/sdk';
20
+ import { airCapabilityMeta, asSdkClientCapabilities, AIR_ASYNC_TASKS_CAPABILITY, AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, DRAFT_SUBAGENTS_CAPABILITY, } from './draftSubagents.js';
21
+ import { metaTerminalAuthArgs, terminalLoginSpecOf } from './terminalLoginSpec.js';
22
+ /** The `initialize` params this client sends — the same object on the live path and from the processor. */
23
+ export function initializeRequestParams() {
24
+ return {
25
+ protocolVersion: PROTOCOL_VERSION,
26
+ // Three things are declared here, and they are not interchangeable — see
27
+ // `draftSubagents.ts` for the tier each one sits in.
28
+ //
29
+ // 1. `subagents: {}` is the **canonical** draft field from ACP RFD #1992. Both official
30
+ // adapters gate native subagent sessions on it, and both answer with
31
+ // `agentCapabilities.sessionCapabilities.subagents` (measured against each).
32
+ //
33
+ // 2. The AIR list is sent as well, for two separate reasons. It is the *only* channel for
34
+ // `asyncTasks` — nothing canonical exists for background work — and it is the fallback
35
+ // for `nativeSubagentSessions`, because a released SDK sitting between us and an agent
36
+ // can strip a draft field it has no type for (upstream says so in #1017's compatibility
37
+ // note). Declaring both is not belt-and-braces: they cover different failure modes.
38
+ //
39
+ // 3. `subagent-transcript: true` stays. It is claude-agent-acp's older vendor key
40
+ // (`dist/acp-agent.js:155-158`), and it still governs the **fallback** path taken when
41
+ // native subagent sessions are not negotiated — an older adapter, or a stripped
42
+ // capability. Without it that path strips every subagent's text and thinking
43
+ // (`stripSubagentTextAndThinking`, `:3926`), leaving nothing but tool-call wreckage.
44
+ // Adapters that have never heard of any of these keys are required by the spec to
45
+ // ignore them.
46
+ clientCapabilities: asSdkClientCapabilities({
47
+ [DRAFT_SUBAGENTS_CAPABILITY]: {},
48
+ // `ClientSessionCapabilities.configOptions` (`types.gen.d.ts:4306`), part of the schema
49
+ // proper — unlike `subagents` above, this survives the pinned SDK's `zInitializeRequest`
50
+ // stripping because it's a known field, not a draft one. `{}` for `boolean` tells the
51
+ // agent it may send `type: "boolean"` entries in `SessionConfigOption` and that this
52
+ // client will send `session/set_config_option` with a boolean `value`
53
+ // (`SessionConfigOptionsCapabilities`, `types.gen.d.ts:4333-4353`); without it an agent
54
+ // with a boolean toggle downgrades it to a two-value select.
55
+ session: { configOptions: { boolean: {} } },
56
+ // `ClientCapabilities.elicitation` (`types.gen.d.ts:4479`) is a known field of the schema
57
+ // proper, not a draft one, so it survives `zInitializeRequest` stripping as-is. `{}` for
58
+ // `url` (`ElicitationUrlCapabilities`, `:4616`) means the client can put a URL in front of
59
+ // the user; this is the precondition for the whole device-code login shape to exist at all
60
+ // — Codex's own `getCodexAuthMethods` gates its `chat-gpt-device-code` auth method on
61
+ // `clientCapabilities?.elicitation?.url != null`. Without declaring it, Codex never offers
62
+ // that method and `elicitation/create` with `mode: 'url'` never arrives to answer (see
63
+ // `permission.ts`'s `handleCreateElicitation`).
64
+ //
65
+ // `form` (`ElicitationFormCapabilities`, `types.gen.d.ts:4455`) is what keeps Claude's
66
+ // AskUserQuestion alive: without it the adapter puts the tool in `disallowedTools`
67
+ // (`claude-agent-acp/dist/acp-agent.js:5959`), so the model never has it at all — the
68
+ // symptom is prose questions, not an unrendered card. This is the trigger for the whole
69
+ // elicitation-standardization plan: everything through Task 17 built the machinery to
70
+ // answer `elicitation/create` once it arrives; this line is what makes it arrive at all.
71
+ elicitation: { url: {}, form: {} },
72
+ _meta: {
73
+ // The convention Zed introduced and the ACP adapters adopted: an agent may gate its terminal
74
+ // sign-in methods on this key — claude-agent-acp advertises `claude-ai-login` / `console-login`
75
+ // (each with a `_meta["terminal-auth"]` naming the pipe-friendly invocation) only when the
76
+ // client declares it; pi-acp always returns its method but attaches the same block only then.
77
+ // We DO host those invocations — `terminalLogin.ts` runs them with pipes, sniffs the OAuth URL
78
+ // out of the output and surfaces it as a login link (spec 2026-09-24 D6/D7/D9) — so declaring
79
+ // this is a statement of fact, not an aspiration. Same-machine only: a hosted login's
80
+ // localhost OAuth callback must reach the workstation's own listener, which a browser opened
81
+ // on another machine cannot do; the standard `authenticate` methods (device-code style) are
82
+ // unaffected and never needed this key.
83
+ 'terminal-auth': true,
84
+ terminal_output_delta: true,
85
+ 'subagent-transcript': true,
86
+ ...airCapabilityMeta(AIR_NATIVE_SUBAGENT_SESSIONS_CAPABILITY, AIR_ASYNC_TASKS_CAPABILITY),
87
+ },
88
+ }),
89
+ };
90
+ }
91
+ /**
92
+ * Whether a JSON-RPC error code is one a frame may carry: an integer inside the Kotlin twin's `Int`
93
+ * range. See `acpClient.ts` `jsonRpcErrorCode` for why a malformed code is reported as no code at
94
+ * all. Split out so the processor, which sees the peer's `{code}` as plain JSON rather than as the
95
+ * SDK's `RequestError`, applies the identical rule.
96
+ */
97
+ export function jsonRpcErrorCodeOf(code) {
98
+ if (typeof code !== 'number' || !Number.isInteger(code))
99
+ return undefined;
100
+ return code >= -2_147_483_648 && code <= 2_147_483_647 ? code : undefined;
101
+ }
102
+ /**
103
+ * Read an `initialize` result exactly the way `connectAgent` always has.
104
+ *
105
+ * The protocol version is checked **first** and nothing else is read when it is wrong — Global
106
+ * Constraint 1 is v1-only and a reply for another version is not ours to interpret. Malformed input
107
+ * throws where it always threw (a non-array `authMethods`, a non-object result); callers that must
108
+ * not throw (the processor) catch it themselves, so the live path keeps its exact behaviour.
109
+ */
110
+ export function parseInitializeResult(initResponse) {
111
+ if (initResponse.protocolVersion !== PROTOCOL_VERSION) {
112
+ return { protocolSupported: false, protocolVersion: initResponse.protocolVersion };
113
+ }
114
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
115
+ const axomMeta = isRecord(initResponse._meta) && isRecord(initResponse._meta.axom) ? initResponse._meta.axom : undefined;
116
+ const cachedReconnect = axomMeta?.cachedReconnect === 'resume' ? 'resume' : undefined;
117
+ const sessionCapabilities = initResponse.agentCapabilities?.sessionCapabilities;
118
+ const capabilities = {
119
+ // Capability markers are empty objects (`{ _meta? }`); supplying `{}` means "supported", and
120
+ // omitting the field (or explicit `null`) means "not supported". A truthiness check reads `{}`
121
+ // correctly by accident but reads `null`/`undefined` correctly too, which hides the real bug:
122
+ // this must stay an explicit `!= null`, never `Boolean(...)` or a bare truthy test.
123
+ list: sessionCapabilities?.list != null,
124
+ delete: sessionCapabilities?.delete != null,
125
+ resume: sessionCapabilities?.resume != null,
126
+ loadSession: initResponse.agentCapabilities?.loadSession === true,
127
+ logout: initResponse.agentCapabilities?.auth?.logout != null,
128
+ /**
129
+ * ACP `PromptCapabilities.image` (`types.gen.d.ts:1601`): "Agent supports
130
+ * [`ContentBlock::Image`]". Every field of that type is optional, so an agent that says
131
+ * nothing supports text only -- `=== true` rather than `!== false`.
132
+ *
133
+ * Verified against codex-acp 1.7.0, which declares `{embeddedContext: true, image: true}`.
134
+ * `audio` is deliberately not read: no agent we target declares it, and an unread capability
135
+ * is a field nobody can act on.
136
+ */
137
+ promptImage: initResponse.agentCapabilities?.promptCapabilities?.image === true,
138
+ mcpHttp: initResponse.agentCapabilities?.mcpCapabilities?.http === true,
139
+ };
140
+ // Honour the advertised capability, not what the agent happens to route: some adapters (e.g.
141
+ // codex-acp routing `session/fork`) implement more than they declare in `agentCapabilities`.
142
+ // Reading `capabilities` above off `initResponse` — never probing the agent for what it accepts
143
+ // — is what keeps that distinction intact.
144
+ const advertisedAuthMethods = initResponse.authMethods ?? [];
145
+ const authMethods = advertisedAuthMethods
146
+ .map(toAuthMethodSnapshot)
147
+ .filter((method) => method !== null);
148
+ const terminalLogins = [];
149
+ for (const method of advertisedAuthMethods) {
150
+ const spec = terminalLoginSpecOf(method);
151
+ if (spec && typeof method.id === 'string') {
152
+ // A duplicate id keeps its first position and takes the later spec — exactly `Map.set`.
153
+ const existing = terminalLogins.findIndex(([id]) => id === method.id);
154
+ if (existing >= 0)
155
+ terminalLogins[existing] = [method.id, spec];
156
+ else
157
+ terminalLogins.push([method.id, spec]);
158
+ }
159
+ }
160
+ return {
161
+ protocolSupported: true,
162
+ ...(cachedReconnect ? { cachedReconnect } : {}),
163
+ capabilities,
164
+ authMethods,
165
+ droppedAuthMethods: advertisedAuthMethods.length - authMethods.length,
166
+ terminalLogins,
167
+ ...(initResponse.agentCapabilities?._meta?.['axom/accountRateLimits']?.read === true ? { supportsAccountLimits: true, accountLimitsVersion: initResponse.agentCapabilities?._meta?.['axom/accountRateLimits']?.version ?? 1 } : {}),
168
+ supportsSteering: steeringAdvertised(initResponse._meta),
169
+ steeringTimings: steeringTimings(initResponse._meta),
170
+ agentInfo: initResponse.agentInfo ?? undefined,
171
+ };
172
+ }
173
+ /**
174
+ * Whether an `InitializeResponse._meta` advertises the `_session/steering` extension.
175
+ *
176
+ * ## `_session/steering` is not ACP
177
+ *
178
+ * It is absent from the schema this client is pinned to (`grep steer
179
+ * node_modules/@agentclientprotocol/sdk/dist/schema/types.gen.d.ts` returns nothing). It is an
180
+ * extension `claude-agent-acp` implements: the method constant lives at its `acp-agent.js@0.76.0:164`
181
+ * and its own comment calls it a *"Custom (extension) request method ... Named `_session/steering`
182
+ * per the agreed ACP steering wire protocol"*. The leading underscore is ACP's extension namespace.
183
+ *
184
+ * ## Why the top-level `_meta` specifically
185
+ *
186
+ * The adapter advertises it at `InitializeResponse._meta.steering.supported`, a **sibling of
187
+ * `agentCapabilities`** (`acp-agent.js@0.76.0:944-950`), not a key inside it. `_meta` is typed
188
+ * `{[key: string]: unknown} | null` (`types.gen.d.ts:1498-1500`), so every hop down has to be
189
+ * narrowed rather than indexed through a cast.
190
+ *
191
+ * Strictly `=== true`. An agent that sends `steering: {}` (the shape ACP uses for its *own*
192
+ * capability markers) has not said `supported`, and this extension does not define that spelling —
193
+ * reading it as a yes would be this client inventing a wire contract.
194
+ */
195
+ export function steeringAdvertised(meta) {
196
+ if (typeof meta !== 'object' || meta === null)
197
+ return false;
198
+ const steering = meta.steering;
199
+ if (typeof steering !== 'object' || steering === null)
200
+ return false;
201
+ return steering.supported === true;
202
+ }
203
+ /**
204
+ * The delivery timings the `_session/steering` extension defines — when the agent hands an injected
205
+ * message to the model. `next` is the only lossless one: `now` aborts the running generation and
206
+ * discards whatever tool calls were still outstanding.
207
+ */
208
+ export const STEER_TIMINGS = ['now', 'next', 'later'];
209
+ /**
210
+ * Which delivery timings an `InitializeResponse._meta` says the agent accepts —
211
+ * `_meta.steering.timings`, the sibling of the `supported` flag {@link steeringAdvertised} reads,
212
+ * and read from the **top-level** `_meta` for exactly the same reason.
213
+ *
214
+ * ## Empty is the answer, not the absence of one
215
+ *
216
+ * An agent that declares no timings has told us we may not name one. That is not "assume the
217
+ * default" — the extension ignores an unrecognised `priority` **silently** (the measurement behind
218
+ * ruling N4: sending `next` to today's adapters lands as `now`, which throws away the user's
219
+ * in-flight work). So an empty result must reach the caller as "do not specify a timing at all",
220
+ * and today — before the upstream PR that makes adapters broadcast this — every agent in the wild
221
+ * produces exactly that. Steady state, not a bug.
222
+ *
223
+ * ## Unknown values are dropped, never rejected
224
+ *
225
+ * A timing this build has never heard of is skipped and the known ones beside it survive. This
226
+ * client is deployed on user machines and can be older than both the agent it launches and the
227
+ * server it reports to; throwing (or discarding the whole array) on a value from a future version
228
+ * of the extension would take steering away from an agent that does support it. Non-strings are
229
+ * dropped the same way: `_meta` is typed `{[key: string]: unknown}`, so nothing here is guaranteed.
230
+ *
231
+ * Duplicates collapse — the wire shape is a JSON array but the fact is a set.
232
+ */
233
+ export function steeringTimings(meta) {
234
+ if (typeof meta !== 'object' || meta === null)
235
+ return [];
236
+ const steering = meta.steering;
237
+ if (typeof steering !== 'object' || steering === null)
238
+ return [];
239
+ const declared = steering.timings;
240
+ if (!Array.isArray(declared))
241
+ return [];
242
+ const known = [];
243
+ for (const entry of declared) {
244
+ if (typeof entry !== 'string')
245
+ continue;
246
+ if (!STEER_TIMINGS.includes(entry))
247
+ continue;
248
+ if (known.includes(entry))
249
+ continue;
250
+ known.push(entry);
251
+ }
252
+ return known;
253
+ }
254
+ /**
255
+ * One `initialize` auth method, or `null` when the agent did not advertise a usable one.
256
+ *
257
+ * `initResponse` is another process's JSON that arrived over a pipe; `AuthMethod` is what this
258
+ * client *asked* for, not what it was handed. Both variants of that union make `id` and `name`
259
+ * required (`@agentclientprotocol/sdk` `types.gen.d.ts:2241-2246` for `AuthMethodTerminal`,
260
+ * `:2281-2286` for `AuthMethodAgent`), so an agent that omits them is off-spec -- but nothing
261
+ * between its stdout and here checks, and the snapshot then carries `undefined` in two positions
262
+ * its own type declares non-optional. That lie does not stay local: `JSON.stringify` erases an
263
+ * `undefined` value entirely, so the object passes every `typeof x.id` check in this process and
264
+ * still reaches a peer with the keys missing.
265
+ *
266
+ * `agoragentic-acp` advertises exactly `{type: 'terminal', description: '…'}`. Observing it once
267
+ * put a malformed `AuthMethodInfo` in the roster, which rides in every subsequent
268
+ * `management_hello`, which the server then cannot decode -- and a hello the server cannot decode
269
+ * closes the socket with nothing said, so the workstation retried into a permanent OFFLINE.
270
+ *
271
+ * Dropping rather than repairing: `id` is the value `authenticate` is called with, so inventing
272
+ * one would trade a missing sign-in method for a broken one.
273
+ */
274
+ export function toAuthMethodSnapshot(method) {
275
+ if (typeof method.id !== 'string' || typeof method.name !== 'string')
276
+ return null;
277
+ // Terminal by shape (spec 2026-09-24 D6): a top-level `type: "terminal"`, or a `_meta
278
+ // ["terminal-auth"]` object from an agent that advertises its terminal login only there.
279
+ const terminal = terminalLoginSpecOf(method) !== undefined;
280
+ const args = 'args' in method && Array.isArray(method.args) ? method.args : terminal ? metaTerminalAuthArgs(method) : undefined;
281
+ return {
282
+ id: method.id,
283
+ name: method.name,
284
+ ...(terminal ? { type: 'terminal' } : {}),
285
+ ...(method.description != null ? { description: method.description } : {}),
286
+ // `args` only exists on a terminal method — top-level, or under `_meta["terminal-auth"]` when
287
+ // that is the only place the agent put it. Never the `_meta` command: see `terminalLogins`.
288
+ ...(args ? { args } : {}),
289
+ };
290
+ }
@@ -16,13 +16,13 @@
16
16
  * built.
17
17
  *
18
18
  * Three shapes, matching the three things a failed install can mean (see `acpClient.ts`'s
19
- * `isMissingPackageVersion`/`stderrShowsMissingPackageVersion` — the one predicate every ETARGET
19
+ * `stderrShowsMissingPackageVersion` — the one predicate every ETARGET
20
20
  * check in this codebase reuses rather than re-deriving):
21
21
  *
22
22
  * 1. An ordinary failure with no ETARGET in sight: a network hiccup, a full disk, a missing archive
23
23
  * tool, a timeout. {@link friendlyOrdinaryInstallError}.
24
24
  * 2. The registry pins a version that is not published upstream, and the unpinned retry
25
- * (`unpinnedFallbackFor`, `registry/launch.ts`) that tries to work around it fails too.
25
+ * (`AcpAgents.installPristineWithFallback`) that tries to work around it fails too.
26
26
  * {@link friendlyPinnedVersionUnavailableAndFallbackFailed}.
27
27
  * 3. The same missing pin, but the unpinned retry succeeds — not a failure at all, so it produces no
28
28
  * message here. It produces a {@link PinnedVersionUnavailable} fact instead, which
@@ -87,3 +87,13 @@ export function friendlyPinnedVersionUnavailableAndFallbackFailed(agentId, pinne
87
87
  return (`The registry pins '${agentId}' to version ${pinned}, which is not published. Installing the ` +
88
88
  `latest available version instead failed too: ${shortDetail(fallbackDetail)}.${reassurance(existingVersion)}`);
89
89
  }
90
+ /**
91
+ * A uv-distributed adapter, and `uv` itself is not on this workstation (the spawn failed `ENOENT`). Not a
92
+ * transient failure, so not "try again in a moment": the reader has to install uv first. Raised only by
93
+ * an Install that tried to run `uv` — scanning never checks for it.
94
+ */
95
+ export function friendlyUvMissingError(agentId, existingVersion) {
96
+ return (`Could not install '${agentId}': uv is not installed on this workstation, and this agent is distributed ` +
97
+ `as a Python tool installed with uv. Install uv (https://docs.astral.sh/uv/getting-started/installation/) ` +
98
+ `so the workstation's service can find it on its PATH, then install the agent again.${reassurance(existingVersion)}`);
99
+ }
@@ -312,7 +312,7 @@ export function installNpxPackage(spec, options = {}) {
312
312
  // 都没有时 `npxCacheVersion` 同样是 `undefined` —— 两个 `undefined` 相等,若不单独守住这一条,
313
313
  // 一个从未被任何 npx 调用装过的包名,只要没剥版本前先被查过缓存,就会在这里被判定成"已经装好",
314
314
  // 一次 npx 都不用起。registry 自己从不发不钉版本的 spec(见 `registry/launch.ts` 的说明),这条分支
315
- // 过去因此从没被真正走到过;`unpinnedFallbackFor` 的回退——`AcpAgents.installNpxWithFallback`——
315
+ // 过去因此从没被真正走到过;旧的 npx 安装期回退——
316
316
  // 是第一个会把不带版本的 spec 递进来的调用方,伪装成功比真的失败更糟:界面会说"已安装",磁盘上
317
317
  // 其实什么都没有。
318
318
  const pinnedVersion = npmPackageVersion(spec);