@draht/coding-agent 2026.7.13 → 2026.9.5-1

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 (614) hide show
  1. package/CHANGELOG.md +241 -0
  2. package/README.md +47 -2
  3. package/agents/debugger.md +12 -1
  4. package/agents/git-committer.md +1 -0
  5. package/agents/implementer.md +20 -0
  6. package/agents/investigator.md +75 -0
  7. package/agents/reviewer.md +7 -0
  8. package/agents/spec-reviewer.md +66 -0
  9. package/agents/verifier.md +4 -3
  10. package/bin/draht-tools.cjs +472 -41
  11. package/dist/agents/debugger.md +12 -1
  12. package/dist/agents/git-committer.md +1 -0
  13. package/dist/agents/implementer.md +20 -0
  14. package/dist/agents/investigator.md +75 -0
  15. package/dist/agents/reviewer.md +7 -0
  16. package/dist/agents/spec-reviewer.md +66 -0
  17. package/dist/agents/verifier.md +4 -3
  18. package/dist/bun/cli.js +2 -0
  19. package/dist/bun/cli.js.map +1 -1
  20. package/dist/cli/args.d.ts +10 -0
  21. package/dist/cli/args.d.ts.map +1 -1
  22. package/dist/cli/args.js +80 -3
  23. package/dist/cli/args.js.map +1 -1
  24. package/dist/cli/attach-mode.d.ts +61 -0
  25. package/dist/cli/attach-mode.d.ts.map +1 -1
  26. package/dist/cli/attach-mode.js +243 -5
  27. package/dist/cli/attach-mode.js.map +1 -1
  28. package/dist/cli/config-selector.js +1 -1
  29. package/dist/cli/config-selector.js.map +1 -1
  30. package/dist/cli/credential-print.d.ts +23 -0
  31. package/dist/cli/credential-print.d.ts.map +1 -0
  32. package/dist/cli/credential-print.js +117 -0
  33. package/dist/cli/credential-print.js.map +1 -0
  34. package/dist/cli/list-models.d.ts +2 -2
  35. package/dist/cli/list-models.d.ts.map +1 -1
  36. package/dist/cli/list-models.js +3 -3
  37. package/dist/cli/list-models.js.map +1 -1
  38. package/dist/cli/startup-ui.js +1 -1
  39. package/dist/cli/startup-ui.js.map +1 -1
  40. package/dist/config.d.ts +9 -0
  41. package/dist/config.d.ts.map +1 -1
  42. package/dist/config.js +31 -4
  43. package/dist/config.js.map +1 -1
  44. package/dist/core/agent-session-runtime.d.ts +17 -1
  45. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  46. package/dist/core/agent-session-runtime.js +90 -30
  47. package/dist/core/agent-session-runtime.js.map +1 -1
  48. package/dist/core/agent-session-services.d.ts +4 -7
  49. package/dist/core/agent-session-services.d.ts.map +1 -1
  50. package/dist/core/agent-session-services.js +24 -9
  51. package/dist/core/agent-session-services.js.map +1 -1
  52. package/dist/core/agent-session.d.ts +87 -27
  53. package/dist/core/agent-session.d.ts.map +1 -1
  54. package/dist/core/agent-session.js +337 -154
  55. package/dist/core/agent-session.js.map +1 -1
  56. package/dist/core/auth-storage.d.ts +20 -104
  57. package/dist/core/auth-storage.d.ts.map +1 -1
  58. package/dist/core/auth-storage.js +104 -260
  59. package/dist/core/auth-storage.js.map +1 -1
  60. package/dist/core/builtins/checkpoints.d.ts +20 -0
  61. package/dist/core/builtins/checkpoints.d.ts.map +1 -0
  62. package/dist/core/builtins/checkpoints.js +161 -0
  63. package/dist/core/builtins/checkpoints.js.map +1 -0
  64. package/dist/core/builtins/duet.d.ts +26 -0
  65. package/dist/core/builtins/duet.d.ts.map +1 -0
  66. package/dist/core/builtins/duet.js +660 -0
  67. package/dist/core/builtins/duet.js.map +1 -0
  68. package/dist/core/builtins/index.d.ts.map +1 -1
  69. package/dist/core/builtins/index.js +7 -1
  70. package/dist/core/builtins/index.js.map +1 -1
  71. package/dist/core/builtins/subagent.d.ts +24 -4
  72. package/dist/core/builtins/subagent.d.ts.map +1 -1
  73. package/dist/core/builtins/subagent.js +278 -35
  74. package/dist/core/builtins/subagent.js.map +1 -1
  75. package/dist/core/cache-stats.d.ts +2 -2
  76. package/dist/core/cache-stats.d.ts.map +1 -1
  77. package/dist/core/cache-stats.js +1 -1
  78. package/dist/core/cache-stats.js.map +1 -1
  79. package/dist/core/checkpoints/checkpoint-cli.d.ts +17 -0
  80. package/dist/core/checkpoints/checkpoint-cli.d.ts.map +1 -0
  81. package/dist/core/checkpoints/checkpoint-cli.js +78 -0
  82. package/dist/core/checkpoints/checkpoint-cli.js.map +1 -0
  83. package/dist/core/checkpoints/checkpoint-manager.d.ts +294 -0
  84. package/dist/core/checkpoints/checkpoint-manager.d.ts.map +1 -0
  85. package/dist/core/checkpoints/checkpoint-manager.js +865 -0
  86. package/dist/core/checkpoints/checkpoint-manager.js.map +1 -0
  87. package/dist/core/checkpoints/rewind.d.ts +141 -0
  88. package/dist/core/checkpoints/rewind.d.ts.map +1 -0
  89. package/dist/core/checkpoints/rewind.js +246 -0
  90. package/dist/core/checkpoints/rewind.js.map +1 -0
  91. package/dist/core/compaction/branch-summarization.d.ts +9 -3
  92. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  93. package/dist/core/compaction/branch-summarization.js +16 -14
  94. package/dist/core/compaction/branch-summarization.js.map +1 -1
  95. package/dist/core/compaction/compaction.d.ts +24 -3
  96. package/dist/core/compaction/compaction.d.ts.map +1 -1
  97. package/dist/core/compaction/compaction.js +96 -30
  98. package/dist/core/compaction/compaction.js.map +1 -1
  99. package/dist/core/compaction/utils.d.ts +1 -1
  100. package/dist/core/compaction/utils.d.ts.map +1 -1
  101. package/dist/core/compaction/utils.js +6 -17
  102. package/dist/core/compaction/utils.js.map +1 -1
  103. package/dist/core/context-windows.d.ts +7 -0
  104. package/dist/core/context-windows.d.ts.map +1 -0
  105. package/dist/core/context-windows.js +35 -0
  106. package/dist/core/context-windows.js.map +1 -0
  107. package/dist/core/extensions/index.d.ts +1 -1
  108. package/dist/core/extensions/index.d.ts.map +1 -1
  109. package/dist/core/extensions/index.js.map +1 -1
  110. package/dist/core/extensions/loader.d.ts.map +1 -1
  111. package/dist/core/extensions/loader.js +101 -23
  112. package/dist/core/extensions/loader.js.map +1 -1
  113. package/dist/core/extensions/runner.d.ts +19 -3
  114. package/dist/core/extensions/runner.d.ts.map +1 -1
  115. package/dist/core/extensions/runner.js +117 -2
  116. package/dist/core/extensions/runner.js.map +1 -1
  117. package/dist/core/extensions/types.d.ts +236 -9
  118. package/dist/core/extensions/types.d.ts.map +1 -1
  119. package/dist/core/extensions/types.js.map +1 -1
  120. package/dist/core/extensions/wrapper.d.ts.map +1 -1
  121. package/dist/core/extensions/wrapper.js +22 -3
  122. package/dist/core/extensions/wrapper.js.map +1 -1
  123. package/dist/core/footer-data-provider.d.ts +10 -0
  124. package/dist/core/footer-data-provider.d.ts.map +1 -1
  125. package/dist/core/footer-data-provider.js +1 -1
  126. package/dist/core/footer-data-provider.js.map +1 -1
  127. package/dist/core/http-dispatcher.d.ts.map +1 -1
  128. package/dist/core/http-dispatcher.js +7 -0
  129. package/dist/core/http-dispatcher.js.map +1 -1
  130. package/dist/core/index.d.ts +1 -1
  131. package/dist/core/index.d.ts.map +1 -1
  132. package/dist/core/index.js.map +1 -1
  133. package/dist/core/keybindings.d.ts +18 -3
  134. package/dist/core/keybindings.d.ts.map +1 -1
  135. package/dist/core/keybindings.js +12 -3
  136. package/dist/core/keybindings.js.map +1 -1
  137. package/dist/core/model-config.d.ts +542 -0
  138. package/dist/core/model-config.d.ts.map +1 -0
  139. package/dist/core/model-config.js +247 -0
  140. package/dist/core/model-config.js.map +1 -0
  141. package/dist/core/model-registry.d.ts +19 -124
  142. package/dist/core/model-registry.d.ts.map +1 -1
  143. package/dist/core/model-registry.js +56 -727
  144. package/dist/core/model-registry.js.map +1 -1
  145. package/dist/core/model-resolver.d.ts +7 -6
  146. package/dist/core/model-resolver.d.ts.map +1 -1
  147. package/dist/core/model-resolver.js +74 -27
  148. package/dist/core/model-resolver.js.map +1 -1
  149. package/dist/core/model-runtime.d.ts +89 -0
  150. package/dist/core/model-runtime.d.ts.map +1 -0
  151. package/dist/core/model-runtime.js +451 -0
  152. package/dist/core/model-runtime.js.map +1 -0
  153. package/dist/core/models-store.d.ts +17 -0
  154. package/dist/core/models-store.d.ts.map +1 -0
  155. package/dist/core/models-store.js +46 -0
  156. package/dist/core/models-store.js.map +1 -0
  157. package/dist/core/multi-agent/permission-gate.d.ts.map +1 -1
  158. package/dist/core/multi-agent/permission-gate.js +4 -3
  159. package/dist/core/multi-agent/permission-gate.js.map +1 -1
  160. package/dist/core/multi-agent/worktree.d.ts +2 -0
  161. package/dist/core/multi-agent/worktree.d.ts.map +1 -1
  162. package/dist/core/multi-agent/worktree.js +2 -2
  163. package/dist/core/multi-agent/worktree.js.map +1 -1
  164. package/dist/core/package-manager.d.ts +7 -1
  165. package/dist/core/package-manager.d.ts.map +1 -1
  166. package/dist/core/package-manager.js +41 -45
  167. package/dist/core/package-manager.js.map +1 -1
  168. package/dist/core/permission-relay/index.d.ts +19 -0
  169. package/dist/core/permission-relay/index.d.ts.map +1 -0
  170. package/dist/core/permission-relay/index.js +49 -0
  171. package/dist/core/permission-relay/index.js.map +1 -0
  172. package/dist/core/permission-relay/relay-ui-context.d.ts +39 -0
  173. package/dist/core/permission-relay/relay-ui-context.d.ts.map +1 -0
  174. package/dist/core/permission-relay/relay-ui-context.js +788 -0
  175. package/dist/core/permission-relay/relay-ui-context.js.map +1 -0
  176. package/dist/core/permission-relay/types.d.ts +222 -0
  177. package/dist/core/permission-relay/types.d.ts.map +1 -0
  178. package/dist/core/permission-relay/types.js +15 -0
  179. package/dist/core/permission-relay/types.js.map +1 -0
  180. package/dist/core/pi-manifest.d.ts +14 -0
  181. package/dist/core/pi-manifest.d.ts.map +1 -0
  182. package/dist/core/pi-manifest.js +35 -0
  183. package/dist/core/pi-manifest.js.map +1 -0
  184. package/dist/core/project-trust.js +2 -2
  185. package/dist/core/project-trust.js.map +1 -1
  186. package/dist/core/prompt-templates.d.ts +1 -0
  187. package/dist/core/prompt-templates.d.ts.map +1 -1
  188. package/dist/core/prompt-templates.js +4 -4
  189. package/dist/core/prompt-templates.js.map +1 -1
  190. package/dist/core/provider-composer.d.ts +55 -0
  191. package/dist/core/provider-composer.d.ts.map +1 -0
  192. package/dist/core/provider-composer.js +375 -0
  193. package/dist/core/provider-composer.js.map +1 -0
  194. package/dist/core/radius.d.ts +2 -0
  195. package/dist/core/radius.d.ts.map +1 -0
  196. package/dist/core/radius.js +2 -0
  197. package/dist/core/radius.js.map +1 -0
  198. package/dist/core/remote-catalog-provider.d.ts +5 -0
  199. package/dist/core/remote-catalog-provider.d.ts.map +1 -0
  200. package/dist/core/remote-catalog-provider.js +115 -0
  201. package/dist/core/remote-catalog-provider.js.map +1 -0
  202. package/dist/core/resource-loader.d.ts +36 -0
  203. package/dist/core/resource-loader.d.ts.map +1 -1
  204. package/dist/core/resource-loader.js +159 -27
  205. package/dist/core/resource-loader.js.map +1 -1
  206. package/dist/core/runtime-credentials.d.ts +15 -0
  207. package/dist/core/runtime-credentials.d.ts.map +1 -0
  208. package/dist/core/runtime-credentials.js +35 -0
  209. package/dist/core/runtime-credentials.js.map +1 -0
  210. package/dist/core/sandbox/bash-operations.d.ts +149 -0
  211. package/dist/core/sandbox/bash-operations.d.ts.map +1 -0
  212. package/dist/core/sandbox/bash-operations.js +163 -0
  213. package/dist/core/sandbox/bash-operations.js.map +1 -0
  214. package/dist/core/sandbox/env.d.ts +83 -0
  215. package/dist/core/sandbox/env.d.ts.map +1 -0
  216. package/dist/core/sandbox/env.js +123 -0
  217. package/dist/core/sandbox/env.js.map +1 -0
  218. package/dist/core/sandbox/executor.d.ts +104 -0
  219. package/dist/core/sandbox/executor.d.ts.map +1 -0
  220. package/dist/core/sandbox/executor.js +92 -0
  221. package/dist/core/sandbox/executor.js.map +1 -0
  222. package/dist/core/sandbox/index.d.ts +36 -0
  223. package/dist/core/sandbox/index.d.ts.map +1 -0
  224. package/dist/core/sandbox/index.js +36 -0
  225. package/dist/core/sandbox/index.js.map +1 -0
  226. package/dist/core/sandbox/linux.d.ts +121 -0
  227. package/dist/core/sandbox/linux.d.ts.map +1 -0
  228. package/dist/core/sandbox/linux.js +260 -0
  229. package/dist/core/sandbox/linux.js.map +1 -0
  230. package/dist/core/sandbox/policy.d.ts +142 -0
  231. package/dist/core/sandbox/policy.d.ts.map +1 -0
  232. package/dist/core/sandbox/policy.js +297 -0
  233. package/dist/core/sandbox/policy.js.map +1 -0
  234. package/dist/core/sandbox/real-path.d.ts +112 -0
  235. package/dist/core/sandbox/real-path.d.ts.map +1 -0
  236. package/dist/core/sandbox/real-path.js +158 -0
  237. package/dist/core/sandbox/real-path.js.map +1 -0
  238. package/dist/core/sandbox/seatbelt-profile.d.ts +95 -0
  239. package/dist/core/sandbox/seatbelt-profile.d.ts.map +1 -0
  240. package/dist/core/sandbox/seatbelt-profile.js +239 -0
  241. package/dist/core/sandbox/seatbelt-profile.js.map +1 -0
  242. package/dist/core/sandbox/seatbelt.d.ts +95 -0
  243. package/dist/core/sandbox/seatbelt.d.ts.map +1 -0
  244. package/dist/core/sandbox/seatbelt.js +154 -0
  245. package/dist/core/sandbox/seatbelt.js.map +1 -0
  246. package/dist/core/sandbox/self-test.d.ts +109 -0
  247. package/dist/core/sandbox/self-test.d.ts.map +1 -0
  248. package/dist/core/sandbox/self-test.js +369 -0
  249. package/dist/core/sandbox/self-test.js.map +1 -0
  250. package/dist/core/sandbox/spawn.d.ts +33 -0
  251. package/dist/core/sandbox/spawn.d.ts.map +1 -0
  252. package/dist/core/sandbox/spawn.js +87 -0
  253. package/dist/core/sandbox/spawn.js.map +1 -0
  254. package/dist/core/sdk.d.ts +3 -6
  255. package/dist/core/sdk.d.ts.map +1 -1
  256. package/dist/core/sdk.js +25 -22
  257. package/dist/core/sdk.js.map +1 -1
  258. package/dist/core/session-manager.d.ts +74 -7
  259. package/dist/core/session-manager.d.ts.map +1 -1
  260. package/dist/core/session-manager.js +169 -34
  261. package/dist/core/session-manager.js.map +1 -1
  262. package/dist/core/settings-manager.d.ts +22 -1
  263. package/dist/core/settings-manager.d.ts.map +1 -1
  264. package/dist/core/settings-manager.js +36 -16
  265. package/dist/core/settings-manager.js.map +1 -1
  266. package/dist/core/skills.d.ts +3 -1
  267. package/dist/core/skills.d.ts.map +1 -1
  268. package/dist/core/skills.js +19 -6
  269. package/dist/core/skills.js.map +1 -1
  270. package/dist/core/slash-commands.d.ts.map +1 -1
  271. package/dist/core/slash-commands.js +1 -0
  272. package/dist/core/slash-commands.js.map +1 -1
  273. package/dist/core/soak/soak-log.d.ts +298 -0
  274. package/dist/core/soak/soak-log.d.ts.map +1 -0
  275. package/dist/core/soak/soak-log.js +660 -0
  276. package/dist/core/soak/soak-log.js.map +1 -0
  277. package/dist/core/soak/soak-reader.d.ts +60 -0
  278. package/dist/core/soak/soak-reader.d.ts.map +1 -0
  279. package/dist/core/soak/soak-reader.js +106 -0
  280. package/dist/core/soak/soak-reader.js.map +1 -0
  281. package/dist/core/socket-server/discovery.d.ts +78 -1
  282. package/dist/core/socket-server/discovery.d.ts.map +1 -1
  283. package/dist/core/socket-server/discovery.js +356 -37
  284. package/dist/core/socket-server/discovery.js.map +1 -1
  285. package/dist/core/socket-server/index.d.ts +10 -4
  286. package/dist/core/socket-server/index.d.ts.map +1 -1
  287. package/dist/core/socket-server/index.js +6 -3
  288. package/dist/core/socket-server/index.js.map +1 -1
  289. package/dist/core/socket-server/permission-delivery.d.ts +125 -0
  290. package/dist/core/socket-server/permission-delivery.d.ts.map +1 -0
  291. package/dist/core/socket-server/permission-delivery.js +152 -0
  292. package/dist/core/socket-server/permission-delivery.js.map +1 -0
  293. package/dist/core/socket-server/permission-registry.d.ts +301 -0
  294. package/dist/core/socket-server/permission-registry.d.ts.map +1 -0
  295. package/dist/core/socket-server/permission-registry.js +410 -0
  296. package/dist/core/socket-server/permission-registry.js.map +1 -0
  297. package/dist/core/socket-server/permission-relay.d.ts +81 -0
  298. package/dist/core/socket-server/permission-relay.d.ts.map +1 -0
  299. package/dist/core/socket-server/permission-relay.js +528 -0
  300. package/dist/core/socket-server/permission-relay.js.map +1 -0
  301. package/dist/core/socket-server/safe-text.d.ts +83 -0
  302. package/dist/core/socket-server/safe-text.d.ts.map +1 -0
  303. package/dist/core/socket-server/safe-text.js +277 -0
  304. package/dist/core/socket-server/safe-text.js.map +1 -0
  305. package/dist/core/socket-server/session-integration.d.ts +65 -2
  306. package/dist/core/socket-server/session-integration.d.ts.map +1 -1
  307. package/dist/core/socket-server/session-integration.js +434 -32
  308. package/dist/core/socket-server/session-integration.js.map +1 -1
  309. package/dist/core/socket-server/socket-client.d.ts +21 -2
  310. package/dist/core/socket-server/socket-client.d.ts.map +1 -1
  311. package/dist/core/socket-server/socket-client.js +52 -1
  312. package/dist/core/socket-server/socket-client.js.map +1 -1
  313. package/dist/core/socket-server/socket-server.d.ts +152 -1
  314. package/dist/core/socket-server/socket-server.d.ts.map +1 -1
  315. package/dist/core/socket-server/socket-server.js +775 -26
  316. package/dist/core/socket-server/socket-server.js.map +1 -1
  317. package/dist/core/socket-server/types.d.ts +106 -2
  318. package/dist/core/socket-server/types.d.ts.map +1 -1
  319. package/dist/core/socket-server/types.js +13 -1
  320. package/dist/core/socket-server/types.js.map +1 -1
  321. package/dist/core/system-prompt.d.ts.map +1 -1
  322. package/dist/core/system-prompt.js +10 -21
  323. package/dist/core/system-prompt.js.map +1 -1
  324. package/dist/core/tools/bash.d.ts +3 -1
  325. package/dist/core/tools/bash.d.ts.map +1 -1
  326. package/dist/core/tools/bash.js +39 -7
  327. package/dist/core/tools/bash.js.map +1 -1
  328. package/dist/core/tools/edit.d.ts.map +1 -1
  329. package/dist/core/tools/edit.js +17 -2
  330. package/dist/core/tools/edit.js.map +1 -1
  331. package/dist/core/tools/find.d.ts +3 -0
  332. package/dist/core/tools/find.d.ts.map +1 -1
  333. package/dist/core/tools/find.js +11 -18
  334. package/dist/core/tools/find.js.map +1 -1
  335. package/dist/core/tools/read.js +1 -1
  336. package/dist/core/tools/read.js.map +1 -1
  337. package/dist/core/tools/tool-definition-wrapper.d.ts.map +1 -1
  338. package/dist/core/tools/tool-definition-wrapper.js +3 -1
  339. package/dist/core/tools/tool-definition-wrapper.js.map +1 -1
  340. package/dist/core/trust-manager.d.ts +6 -4
  341. package/dist/core/trust-manager.d.ts.map +1 -1
  342. package/dist/core/trust-manager.js +55 -21
  343. package/dist/core/trust-manager.js.map +1 -1
  344. package/dist/core/usage-totals.d.ts +19 -0
  345. package/dist/core/usage-totals.d.ts.map +1 -0
  346. package/dist/core/usage-totals.js +52 -0
  347. package/dist/core/usage-totals.js.map +1 -0
  348. package/dist/extensions/index.d.ts +3 -0
  349. package/dist/extensions/index.d.ts.map +1 -0
  350. package/dist/extensions/index.js +7 -0
  351. package/dist/extensions/index.js.map +1 -0
  352. package/dist/extensions/llama/client.d.ts +61 -0
  353. package/dist/extensions/llama/client.d.ts.map +1 -0
  354. package/dist/extensions/llama/client.js +300 -0
  355. package/dist/extensions/llama/client.js.map +1 -0
  356. package/dist/extensions/llama/huggingface.d.ts +23 -0
  357. package/dist/extensions/llama/huggingface.d.ts.map +1 -0
  358. package/dist/extensions/llama/huggingface.js +139 -0
  359. package/dist/extensions/llama/huggingface.js.map +1 -0
  360. package/dist/extensions/llama/index.d.ts +3 -0
  361. package/dist/extensions/llama/index.d.ts.map +1 -0
  362. package/dist/extensions/llama/index.js +208 -0
  363. package/dist/extensions/llama/index.js.map +1 -0
  364. package/dist/extensions/llama/provider.d.ts +10 -0
  365. package/dist/extensions/llama/provider.d.ts.map +1 -0
  366. package/dist/extensions/llama/provider.js +111 -0
  367. package/dist/extensions/llama/provider.js.map +1 -0
  368. package/dist/extensions/llama/ui.d.ts +42 -0
  369. package/dist/extensions/llama/ui.d.ts.map +1 -0
  370. package/dist/extensions/llama/ui.js +400 -0
  371. package/dist/extensions/llama/ui.js.map +1 -0
  372. package/dist/extensions/stub-provider/index.d.ts +9 -0
  373. package/dist/extensions/stub-provider/index.d.ts.map +1 -0
  374. package/dist/extensions/stub-provider/index.js +13 -0
  375. package/dist/extensions/stub-provider/index.js.map +1 -0
  376. package/dist/extensions/stub-provider/provider.d.ts +77 -0
  377. package/dist/extensions/stub-provider/provider.d.ts.map +1 -0
  378. package/dist/extensions/stub-provider/provider.js +193 -0
  379. package/dist/extensions/stub-provider/provider.js.map +1 -0
  380. package/dist/hooks/gsd/draht-quality-gate.js +3 -3
  381. package/dist/index.d.ts +4 -3
  382. package/dist/index.d.ts.map +1 -1
  383. package/dist/index.js +3 -3
  384. package/dist/index.js.map +1 -1
  385. package/dist/main.d.ts.map +1 -1
  386. package/dist/main.js +305 -61
  387. package/dist/main.js.map +1 -1
  388. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  389. package/dist/modes/interactive/components/assistant-message.js +22 -10
  390. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  391. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  392. package/dist/modes/interactive/components/config-selector.js +3 -2
  393. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  394. package/dist/modes/interactive/components/custom-editor.js +1 -1
  395. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  396. package/dist/modes/interactive/components/custom-message.d.ts +3 -1
  397. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  398. package/dist/modes/interactive/components/custom-message.js +9 -2
  399. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  400. package/dist/modes/interactive/components/extension-editor.d.ts +1 -2
  401. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  402. package/dist/modes/interactive/components/extension-editor.js +16 -46
  403. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  404. package/dist/modes/interactive/components/extension-selector.d.ts +49 -0
  405. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/extension-selector.js +202 -5
  407. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  408. package/dist/modes/interactive/components/footer.d.ts.map +1 -1
  409. package/dist/modes/interactive/components/footer.js +24 -23
  410. package/dist/modes/interactive/components/footer.js.map +1 -1
  411. package/dist/modes/interactive/components/login-dialog.d.ts +5 -5
  412. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/login-dialog.js +17 -8
  414. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  415. package/dist/modes/interactive/components/model-selector.d.ts +11 -4
  416. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  417. package/dist/modes/interactive/components/model-selector.js +74 -41
  418. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  419. package/dist/modes/interactive/components/oauth-selector.d.ts +4 -4
  420. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  421. package/dist/modes/interactive/components/oauth-selector.js +14 -25
  422. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  423. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  424. package/dist/modes/interactive/components/scoped-models-selector.js +22 -13
  425. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  426. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  427. package/dist/modes/interactive/components/session-selector.js +10 -2
  428. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  429. package/dist/modes/interactive/components/settings-selector.d.ts +2 -0
  430. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  431. package/dist/modes/interactive/components/settings-selector.js +10 -0
  432. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  433. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  434. package/dist/modes/interactive/components/tool-execution.js +10 -1
  435. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  436. package/dist/modes/interactive/components/tree-selector.d.ts +25 -2
  437. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  438. package/dist/modes/interactive/components/tree-selector.js +68 -17
  439. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  440. package/dist/modes/interactive/external-editor.d.ts +12 -0
  441. package/dist/modes/interactive/external-editor.d.ts.map +1 -0
  442. package/dist/modes/interactive/external-editor.js +37 -0
  443. package/dist/modes/interactive/external-editor.js.map +1 -0
  444. package/dist/modes/interactive/interactive-mode.d.ts +107 -10
  445. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  446. package/dist/modes/interactive/interactive-mode.js +763 -285
  447. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  448. package/dist/modes/rpc/rpc-client.d.ts +4 -0
  449. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  450. package/dist/modes/rpc/rpc-client.js +7 -0
  451. package/dist/modes/rpc/rpc-client.js.map +1 -1
  452. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  453. package/dist/modes/rpc/rpc-mode.js +185 -9
  454. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  455. package/dist/modes/rpc/rpc-types.d.ts +79 -1
  456. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  457. package/dist/modes/rpc/rpc-types.js.map +1 -1
  458. package/dist/package-manager-cli.d.ts.map +1 -1
  459. package/dist/package-manager-cli.js +67 -5
  460. package/dist/package-manager-cli.js.map +1 -1
  461. package/dist/prompts/commands/atomic-commit.md +1 -12
  462. package/dist/prompts/commands/brainstorm.md +12 -15
  463. package/dist/prompts/commands/create-verification-skill.md +108 -0
  464. package/dist/prompts/commands/discuss-phase.md +3 -14
  465. package/dist/prompts/commands/execute-phase.md +3 -11
  466. package/dist/prompts/commands/fix.md +41 -18
  467. package/dist/prompts/commands/grill.md +66 -0
  468. package/dist/prompts/commands/init-project.md +5 -15
  469. package/dist/prompts/commands/map-codebase.md +1 -13
  470. package/dist/prompts/commands/new-project.md +5 -15
  471. package/dist/prompts/commands/next-milestone.md +1 -13
  472. package/dist/prompts/commands/orchestrate.md +1 -1
  473. package/dist/prompts/commands/pause-work.md +1 -13
  474. package/dist/prompts/commands/plan-phase.md +2 -11
  475. package/dist/prompts/commands/progress.md +0 -13
  476. package/dist/prompts/commands/quick.md +3 -11
  477. package/dist/prompts/commands/resolve-conflicts.md +71 -0
  478. package/dist/prompts/commands/resume-work.md +0 -13
  479. package/dist/prompts/commands/review.md +4 -13
  480. package/dist/prompts/commands/triage.md +159 -0
  481. package/dist/prompts/commands/verify-work.md +4 -14
  482. package/dist/prompts/commands/why.md +135 -0
  483. package/dist/skills/atomic-reasoning/SKILL.md +115 -0
  484. package/dist/skills/blast-radius/SKILL.md +55 -0
  485. package/dist/skills/epistemics/SKILL.md +99 -0
  486. package/dist/skills/hexagon-animation/SKILL.md +49 -0
  487. package/dist/skills/hexagon-animation/generate.mjs +81 -0
  488. package/dist/skills/hexagon-animation/template.html +361 -0
  489. package/dist/skills/typescript-discipline/SKILL.md +50 -0
  490. package/dist/skills/typescript-discipline/references/patterns.md +294 -0
  491. package/dist/skills/unslop/SKILL.md +101 -0
  492. package/dist/utils/canonical-path.d.ts +28 -0
  493. package/dist/utils/canonical-path.d.ts.map +1 -0
  494. package/dist/utils/canonical-path.js +90 -0
  495. package/dist/utils/canonical-path.js.map +1 -0
  496. package/dist/utils/child-process.d.ts +12 -1
  497. package/dist/utils/child-process.d.ts.map +1 -1
  498. package/dist/utils/child-process.js +25 -8
  499. package/dist/utils/child-process.js.map +1 -1
  500. package/dist/utils/clipboard-native.d.ts +1 -0
  501. package/dist/utils/clipboard-native.d.ts.map +1 -1
  502. package/dist/utils/clipboard-native.js.map +1 -1
  503. package/dist/utils/clipboard.d.ts +2 -0
  504. package/dist/utils/clipboard.d.ts.map +1 -1
  505. package/dist/utils/clipboard.js +53 -9
  506. package/dist/utils/clipboard.js.map +1 -1
  507. package/dist/utils/exif-orientation.d.ts.map +1 -1
  508. package/dist/utils/exif-orientation.js +2 -3
  509. package/dist/utils/exif-orientation.js.map +1 -1
  510. package/dist/utils/paths.d.ts +2 -7
  511. package/dist/utils/paths.d.ts.map +1 -1
  512. package/dist/utils/paths.js +13 -15
  513. package/dist/utils/paths.js.map +1 -1
  514. package/dist/utils/shell.d.ts.map +1 -1
  515. package/dist/utils/shell.js +6 -4
  516. package/dist/utils/shell.js.map +1 -1
  517. package/dist/utils/tools-manager.d.ts.map +1 -1
  518. package/dist/utils/tools-manager.js +3 -5
  519. package/dist/utils/tools-manager.js.map +1 -1
  520. package/dist/utils/version-check.d.ts.map +1 -1
  521. package/dist/utils/version-check.js +3 -1
  522. package/dist/utils/version-check.js.map +1 -1
  523. package/docs/attachable-sessions.md +79 -0
  524. package/docs/compaction.md +29 -24
  525. package/docs/containerization.md +23 -23
  526. package/docs/custom-provider.md +66 -32
  527. package/docs/development.md +9 -9
  528. package/docs/docs.json +6 -2
  529. package/docs/duet.md +42 -0
  530. package/docs/environment-variables.md +88 -0
  531. package/docs/extensions.md +278 -65
  532. package/docs/index.md +12 -10
  533. package/docs/json.md +12 -8
  534. package/docs/keybindings.md +8 -5
  535. package/docs/llama-cpp.md +99 -0
  536. package/docs/models.md +19 -8
  537. package/docs/packages.md +43 -42
  538. package/docs/prompt-templates.md +5 -4
  539. package/docs/providers.md +45 -11
  540. package/docs/quickstart.md +33 -33
  541. package/docs/rpc.md +190 -19
  542. package/docs/sdk.md +18 -15
  543. package/docs/security.md +18 -18
  544. package/docs/session-format.md +53 -15
  545. package/docs/sessions.md +17 -14
  546. package/docs/settings.md +26 -19
  547. package/docs/shell-aliases.md +2 -2
  548. package/docs/skills.md +12 -11
  549. package/docs/terminal-setup.md +12 -12
  550. package/docs/termux.md +6 -6
  551. package/docs/themes.md +11 -11
  552. package/docs/tmux.md +4 -4
  553. package/docs/tui.md +46 -31
  554. package/docs/usage.md +53 -63
  555. package/docs/windows.md +2 -2
  556. package/examples/extensions/custom-compaction.ts +4 -0
  557. package/examples/extensions/custom-provider-anthropic/index.ts +9 -3
  558. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  559. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  560. package/examples/extensions/custom-provider-qwen-cli/package.json +1 -1
  561. package/examples/extensions/gondolin/package.json +2 -2
  562. package/examples/extensions/handoff.ts +9 -1
  563. package/examples/extensions/kimi-deferred-tools.ts +61 -0
  564. package/examples/extensions/message-renderer.ts +2 -2
  565. package/examples/extensions/overlay-qa-tests.ts +3 -3
  566. package/examples/extensions/sandbox/package.json +1 -1
  567. package/examples/extensions/summarize.ts +3 -0
  568. package/examples/extensions/with-deps/package.json +1 -1
  569. package/examples/sdk/02-custom-model.ts +5 -8
  570. package/examples/sdk/09-api-keys-and-oauth.ts +15 -31
  571. package/examples/sdk/12-full-control.ts +9 -12
  572. package/hooks/gsd/draht-quality-gate.js +3 -3
  573. package/package.json +14 -11
  574. package/prompts/commands/atomic-commit.md +1 -12
  575. package/prompts/commands/brainstorm.md +12 -15
  576. package/prompts/commands/create-verification-skill.md +108 -0
  577. package/prompts/commands/discuss-phase.md +3 -14
  578. package/prompts/commands/execute-phase.md +3 -11
  579. package/prompts/commands/fix.md +41 -18
  580. package/prompts/commands/grill.md +66 -0
  581. package/prompts/commands/init-project.md +5 -15
  582. package/prompts/commands/map-codebase.md +1 -13
  583. package/prompts/commands/new-project.md +5 -15
  584. package/prompts/commands/next-milestone.md +1 -13
  585. package/prompts/commands/orchestrate.md +1 -1
  586. package/prompts/commands/pause-work.md +1 -13
  587. package/prompts/commands/plan-phase.md +2 -11
  588. package/prompts/commands/progress.md +0 -13
  589. package/prompts/commands/quick.md +3 -11
  590. package/prompts/commands/resolve-conflicts.md +71 -0
  591. package/prompts/commands/resume-work.md +0 -13
  592. package/prompts/commands/review.md +4 -13
  593. package/prompts/commands/triage.md +159 -0
  594. package/prompts/commands/verify-work.md +4 -14
  595. package/prompts/commands/why.md +135 -0
  596. package/skills/atomic-reasoning/SKILL.md +115 -0
  597. package/skills/blast-radius/SKILL.md +55 -0
  598. package/skills/epistemics/SKILL.md +99 -0
  599. package/skills/hexagon-animation/SKILL.md +49 -0
  600. package/skills/hexagon-animation/generate.mjs +81 -0
  601. package/skills/hexagon-animation/template.html +361 -0
  602. package/skills/typescript-discipline/SKILL.md +50 -0
  603. package/skills/typescript-discipline/references/patterns.md +294 -0
  604. package/skills/unslop/SKILL.md +101 -0
  605. package/dist/core/provider-display-names.d.ts +0 -2
  606. package/dist/core/provider-display-names.d.ts.map +0 -1
  607. package/dist/core/provider-display-names.js +0 -36
  608. package/dist/core/provider-display-names.js.map +0 -1
  609. package/dist/prompts/agents/build.md +0 -86
  610. package/dist/prompts/agents/plan.md +0 -79
  611. package/dist/prompts/agents/verify.md +0 -69
  612. package/prompts/agents/build.md +0 -86
  613. package/prompts/agents/plan.md +0 -79
  614. package/prompts/agents/verify.md +0 -69
package/dist/main.js CHANGED
@@ -8,27 +8,33 @@ import { createInterface } from "node:readline";
8
8
  import { modelsAreEqual, supportsMax, supportsXhigh } from "@draht/ai";
9
9
  import chalk from "chalk";
10
10
  import { parseArgs, printHelp } from "./cli/args.js";
11
+ import { runAttachMode } from "./cli/attach-mode.js";
12
+ import { CredentialPrintError, isCredentialPrintHelp, parseCredentialPrintCommand, printCredentialPrintHelp, resolveCredentialForPrint, validateCredentialPrintArgs, } from "./cli/credential-print.js";
11
13
  import { processFileArguments } from "./cli/file-processor.js";
12
14
  import { buildInitialMessage } from "./cli/initial-message.js";
13
15
  import { listModels } from "./cli/list-models.js";
16
+ import { listSessions } from "./cli/list-sessions.js";
14
17
  import { createProjectTrustContext } from "./cli/project-trust.js";
15
18
  import { selectSession } from "./cli/session-picker.js";
16
19
  import { shouldRunFirstTimeSetup, showFirstTimeSetup, showStartupSelector } from "./cli/startup-ui.js";
17
- import { DISPLAY_VERSION, ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir } from "./config.js";
20
+ import { APP_NAME, DISPLAY_VERSION, ENV_SESSION_DIR, expandTildePath, getAgentDir, getPackageDir } from "./config.js";
18
21
  import { createAgentSessionRuntime } from "./core/agent-session-runtime.js";
19
22
  import { createAgentSessionFromServices, createAgentSessionServices, } from "./core/agent-session-services.js";
20
23
  import { formatNoModelsAvailableMessage } from "./core/auth-guidance.js";
21
- import { AuthStorage } from "./core/auth-storage.js";
24
+ import { handleCheckpointCommand } from "./core/checkpoints/checkpoint-cli.js";
22
25
  import { exportFromFile } from "./core/export-html/index.js";
23
26
  import { applyHttpProxySettings, configureHttpDispatcher } from "./core/http-dispatcher.js";
24
27
  import { resolveCliModel, resolveModelScope } from "./core/model-resolver.js";
28
+ import { ModelRuntime } from "./core/model-runtime.js";
25
29
  import { restoreStdout, takeOverStdout } from "./core/output-guard.js";
26
30
  import { resolveProjectTrusted } from "./core/project-trust.js";
27
31
  import { formatMissingSessionCwdPrompt, getMissingSessionCwdIssue, MissingSessionCwdError, } from "./core/session-cwd.js";
28
32
  import { assertValidSessionId, SessionManager } from "./core/session-manager.js";
29
33
  import { SettingsManager } from "./core/settings-manager.js";
34
+ import { makeSessionAttachable, registerAttachableSessionCleanup, SocketCapReachedError, SocketDirectoryUnsafeError, SocketSessionBusyError, } from "./core/socket-server/index.js";
30
35
  import { printTimings, resetTimings, time } from "./core/timings.js";
31
36
  import { hasTrustRequiringProjectResources, ProjectTrustStore } from "./core/trust-manager.js";
37
+ import { builtInExtensions } from "./extensions/index.js";
32
38
  import { runMigrations, showDeprecationWarnings } from "./migrations.js";
33
39
  import { InteractiveMode, runPrintMode, runRpcMode } from "./modes/index.js";
34
40
  import { initTheme, stopThemeWatcher } from "./modes/interactive/theme/theme.js";
@@ -76,6 +82,52 @@ function isTruthyEnvFlag(value) {
76
82
  return false;
77
83
  return value === "1" || value.toLowerCase() === "true" || value.toLowerCase() === "yes";
78
84
  }
85
+ /**
86
+ * Opt out of default-on socket registration without editing settings (e.g. DRAHT_NO_ATTACHABLE=1).
87
+ *
88
+ * CI and scripted spawns need a way to say no that survives a fresh container and does not
89
+ * require a writable settings file. Overridden by an explicit `--attachable`.
90
+ */
91
+ const ENV_NO_ATTACHABLE = `${APP_NAME.toUpperCase()}_NO_ATTACHABLE`;
92
+ /**
93
+ * The ONE line an implicit (default-on) registration failure is allowed to print.
94
+ *
95
+ * Exactly one line, on stderr, never stdout — the caller relies on both. It says what was lost
96
+ * (this window is not on the fleet), never what errno said: an `EEXIST` in a startup banner
97
+ * teaches a user nothing they can act on. Three shapes, kept distinct on purpose so a cap
98
+ * refusal is never mistaken for a broken sockets directory and a busy twin is never mistaken
99
+ * for either.
100
+ */
101
+ function describeAttachableDegradation(error) {
102
+ const tail = "This session runs normally but is not reachable from your other devices.";
103
+ if (error instanceof SocketSessionBusyError) {
104
+ const owner = error.ownerPid === null
105
+ ? "another process is claiming it right now"
106
+ : `it is already published by PID ${error.ownerPid}`;
107
+ return `Not registering this session for remote attach: ${owner}. Run \`${APP_NAME} --attach ${error.sessionId}\` to reach that one. ${tail}`;
108
+ }
109
+ if (error instanceof SocketCapReachedError) {
110
+ return `Not registering this session for remote attach: this machine already holds ${error.liveCount} attachable sessions and the limit is ${error.cap}. Close one you are done with. ${tail}`;
111
+ }
112
+ if (error instanceof SocketDirectoryUnsafeError) {
113
+ return `Not registering this session for remote attach: ${error.socketDir} is not a private directory belonging to you. ${tail}`;
114
+ }
115
+ // Node's fs errors carry a `code`. Translate the ones that are actually reachable into a
116
+ // sentence; EINVAL in particular is not exotic — the default socket path is already ~76 of
117
+ // the ~104 bytes a Unix socket address holds, so a long $HOME or a long agent-dir override
118
+ // overflows it.
119
+ const code = typeof error === "object" && error !== null ? error.code : undefined;
120
+ const reason = code === "EACCES" || code === "EPERM"
121
+ ? "permission was denied"
122
+ : code === "EEXIST" || code === "ENOTDIR"
123
+ ? "something that is not a directory is in the way"
124
+ : code === "EINVAL" || code === "ENAMETOOLONG"
125
+ ? "the socket path is too long for this system"
126
+ : code === "ENOENT"
127
+ ? "its directory could not be created"
128
+ : "the control socket could not be created";
129
+ return `Not registering this session for remote attach: ${reason}. ${tail}`;
130
+ }
79
131
  function resolveAppMode(parsed, stdinIsTTY, stdoutIsTTY) {
80
132
  if (parsed.mode === "rpc") {
81
133
  return "rpc";
@@ -94,6 +146,44 @@ function toPrintOutputMode(appMode) {
94
146
  function isPlainRuntimeMetadataCommand(parsed) {
95
147
  return !parsed.print && parsed.mode === undefined && (parsed.help === true || parsed.listModels !== undefined);
96
148
  }
149
+ async function runCredentialPrintCommand(args) {
150
+ if (isCredentialPrintHelp(args)) {
151
+ printCredentialPrintHelp();
152
+ return true;
153
+ }
154
+ let command;
155
+ try {
156
+ command = parseCredentialPrintCommand(args);
157
+ }
158
+ catch (error) {
159
+ const message = error instanceof CredentialPrintError ? error.message : "Failed to parse auth command";
160
+ console.error(chalk.red(`Error: ${message}`));
161
+ process.exitCode = 1;
162
+ return true;
163
+ }
164
+ if (!command)
165
+ return false;
166
+ const parsed = parseArgs(command.args);
167
+ if (parsed.diagnostics.length > 0) {
168
+ for (const diagnostic of parsed.diagnostics) {
169
+ console.error(chalk.red(`Error: ${diagnostic.message}`));
170
+ }
171
+ process.exitCode = 1;
172
+ return true;
173
+ }
174
+ try {
175
+ validateCredentialPrintArgs(parsed);
176
+ const modelRuntime = await ModelRuntime.create({ allowModelNetwork: false });
177
+ const credential = await resolveCredentialForPrint(parsed, modelRuntime, command.kind, command.minExpiryMs);
178
+ process.stdout.write(`${credential}\n`);
179
+ }
180
+ catch (error) {
181
+ const message = error instanceof CredentialPrintError ? error.message : "Failed to resolve credential";
182
+ console.error(chalk.red(`Error: ${message}`));
183
+ process.exitCode = 1;
184
+ }
185
+ return true;
186
+ }
97
187
  async function prepareInitialMessage(parsed, autoResizeImages, stdinContent) {
98
188
  if (parsed.fileArgs.length === 0) {
99
189
  return buildInitialMessage({ parsed, stdinContent });
@@ -135,8 +225,31 @@ async function resolveSessionPath(sessionArg, cwd, sessionDir) {
135
225
  // Not found anywhere
136
226
  return { type: "not_found", arg: sessionArg };
137
227
  }
138
- /** Prompt user for yes/no confirmation */
228
+ /**
229
+ * Prompt user for yes/no confirmation.
230
+ *
231
+ * REFUSES OUTRIGHT WHEN STDIN IS NOT A TTY (R35-ALWAYS.9).
232
+ *
233
+ * `createInterface({ input: process.stdin })` has no TTY check, so with stdin at
234
+ * /dev/null this used to print the question, receive EOF, resolve to `false`,
235
+ * and let its one caller print "Aborted." and EXIT 0 — having started nothing.
236
+ * Exit 0 having done nothing is indistinguishable from success to every
237
+ * programmatic caller there is: a script, a supervisor, and now the geist daemon,
238
+ * which resumes sessions by spawning this binary. A daemon that saw a clean exit
239
+ * would report a resume that never happened.
240
+ *
241
+ * So a non-interactive answer to an interactive question is an ERROR, said on
242
+ * stderr with an exit code, not a silent "no". The caller that would have taken
243
+ * this branch — `--session <bare id>` naming a session in another project — is
244
+ * exactly the shape the daemon avoids by passing an absolute `.jsonl` path
245
+ * instead, which never reaches a prompt at all.
246
+ */
139
247
  async function promptConfirm(message) {
248
+ if (!process.stdin.isTTY) {
249
+ console.error(chalk.red(`Error: "${message}" needs an answer and stdin is not a terminal.\n` +
250
+ "Re-run with a terminal, or name the session by its absolute .jsonl path so no question is asked."));
251
+ process.exit(1);
252
+ }
140
253
  return new Promise((resolve) => {
141
254
  const rl = createInterface({
142
255
  input: process.stdin,
@@ -271,7 +384,7 @@ async function createSessionManager(parsed, cwd, sessionDir, settingsManager) {
271
384
  }
272
385
  return SessionManager.create(cwd, sessionDir, { id: parsed.sessionId });
273
386
  }
274
- function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegistry, settingsManager) {
387
+ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRuntime, settingsManager) {
275
388
  const options = {};
276
389
  const diagnostics = [];
277
390
  let cliThinkingFromModel = false;
@@ -283,7 +396,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
283
396
  cliProvider: parsed.provider,
284
397
  cliModel: parsed.model,
285
398
  cliThinking: parsed.thinking,
286
- modelRegistry,
399
+ modelRuntime,
287
400
  });
288
401
  if (resolved.warning) {
289
402
  diagnostics.push({ type: "warning", message: resolved.warning });
@@ -305,7 +418,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
305
418
  // Check if saved default is in scoped models - use it if so, otherwise first scoped model
306
419
  const savedProvider = settingsManager.getDefaultProvider();
307
420
  const savedModelId = settingsManager.getDefaultModel();
308
- const savedModel = savedProvider && savedModelId ? modelRegistry.find(savedProvider, savedModelId) : undefined;
421
+ const savedModel = savedProvider && savedModelId ? modelRuntime.getModel(savedProvider, savedModelId) : undefined;
309
422
  const savedInScope = savedModel ? scopedModels.find((sm) => modelsAreEqual(sm.model, savedModel)) : undefined;
310
423
  if (savedInScope) {
311
424
  options.model = savedInScope.model;
@@ -335,7 +448,7 @@ function buildSessionOptions(parsed, scopedModels, hasExistingSession, modelRegi
335
448
  thinkingLevel: sm.thinkingLevel,
336
449
  }));
337
450
  }
338
- // API key from CLI - set in authStorage
451
+ // API key from CLI - set as a non-persistent runtime override
339
452
  // (handled by caller before createAgentSession)
340
453
  // Tools
341
454
  if (parsed.noTools) {
@@ -363,6 +476,7 @@ async function promptForMissingSessionCwd(issue, settingsManager) {
363
476
  }
364
477
  export async function main(args, options) {
365
478
  resetTimings();
479
+ const extensionFactories = [...builtInExtensions, ...(options?.extensionFactories ?? [])];
366
480
  const offlineMode = args.includes("--offline") || isTruthyEnvFlag(process.env.DRAHT_OFFLINE);
367
481
  if (offlineMode) {
368
482
  process.env.DRAHT_OFFLINE = "1";
@@ -376,7 +490,7 @@ export async function main(args, options) {
376
490
  const bootstrapSettingsManager = SettingsManager.create(cwd, agentDir, { projectTrusted: false });
377
491
  applyHttpProxySettings(bootstrapSettingsManager.getGlobalSettings().httpProxy);
378
492
  configureHttpDispatcher();
379
- if (await handlePackageCommand(args, { extensionFactories: options?.extensionFactories })) {
493
+ if (await handlePackageCommand(args, { extensionFactories })) {
380
494
  const exitCode = process.exitCode ?? 0;
381
495
  if (process.platform === "win32" && exitCode === 0 && args[0] === "update") {
382
496
  // We normally prefer process.exit(0) for package commands so bad extensions cannot keep
@@ -388,13 +502,20 @@ export async function main(args, options) {
388
502
  process.exit(exitCode);
389
503
  return;
390
504
  }
391
- if (await handleConfigCommand(args, { extensionFactories: options?.extensionFactories })) {
505
+ if (await handleConfigCommand(args, { extensionFactories })) {
392
506
  return;
393
507
  }
394
508
  if (await handleRlmCommand(args)) {
395
509
  process.exit(process.exitCode ?? 0);
396
510
  return;
397
511
  }
512
+ if (await handleCheckpointCommand(args)) {
513
+ process.exit(process.exitCode ?? 0);
514
+ return;
515
+ }
516
+ if (await runCredentialPrintCommand(args)) {
517
+ return;
518
+ }
398
519
  const parsed = parseArgs(args);
399
520
  if (parsed.diagnostics.length > 0) {
400
521
  for (const d of parsed.diagnostics) {
@@ -410,6 +531,17 @@ export async function main(args, options) {
410
531
  console.log(DISPLAY_VERSION);
411
532
  process.exit(0);
412
533
  }
534
+ // Attachable-session commands are pure socket/filesystem operations. They run before any
535
+ // runtime construction so they never pay for provider discovery, extensions, or sessions.
536
+ if (parsed.listSessions) {
537
+ await listSessions();
538
+ process.exit(0);
539
+ }
540
+ if (parsed.attach !== undefined) {
541
+ // runAttachMode owns its own lifetime: it exits the process on detach or error.
542
+ await runAttachMode(parsed.attach);
543
+ return;
544
+ }
413
545
  if (parsed.export) {
414
546
  let result;
415
547
  try {
@@ -490,7 +622,6 @@ export async function main(args, options) {
490
622
  const resolvedSkillPaths = resolveCliPaths(cwd, parsed.skills);
491
623
  const resolvedPromptTemplatePaths = resolveCliPaths(cwd, parsed.promptTemplates);
492
624
  const resolvedThemePaths = resolveCliPaths(cwd, parsed.themes);
493
- const authStorage = AuthStorage.create();
494
625
  const createRuntime = async ({ cwd, agentDir, sessionManager, sessionStartEvent, projectTrustContext, }) => {
495
626
  const isInitialRuntime = sessionStartEvent === undefined;
496
627
  const projectTrustDiagnostics = [];
@@ -506,7 +637,6 @@ export async function main(args, options) {
506
637
  const services = await createAgentSessionServices({
507
638
  cwd,
508
639
  agentDir,
509
- authStorage,
510
640
  settingsManager: runtimeSettingsManager,
511
641
  extensionFlagValues: parsed.unknownFlags,
512
642
  resourceLoaderReloadOptions: shouldResolveProjectTrust
@@ -542,12 +672,13 @@ export async function main(args, options) {
542
672
  noPromptTemplates: parsed.noPromptTemplates,
543
673
  noThemes: parsed.noThemes,
544
674
  noContextFiles: parsed.noContextFiles,
675
+ contextRoot: parsed.contextRoot,
545
676
  systemPrompt: parsed.systemPrompt,
546
677
  appendSystemPrompt: parsed.appendSystemPrompt,
547
- extensionFactories: options?.extensionFactories,
678
+ extensionFactories,
548
679
  },
549
680
  });
550
- const { settingsManager, modelRegistry, resourceLoader } = services;
681
+ const { settingsManager, modelRuntime, resourceLoader } = services;
551
682
  const diagnostics = [
552
683
  ...projectTrustDiagnostics,
553
684
  ...services.diagnostics,
@@ -558,8 +689,8 @@ export async function main(args, options) {
558
689
  })),
559
690
  ];
560
691
  const modelPatterns = parsed.models ?? settingsManager.getEnabledModels();
561
- const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRegistry) : [];
562
- const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0, modelRegistry, settingsManager);
692
+ const scopedModels = modelPatterns && modelPatterns.length > 0 ? await resolveModelScope(modelPatterns, modelRuntime) : [];
693
+ const { options: sessionOptions, cliThinkingFromModel, diagnostics: sessionOptionDiagnostics, } = buildSessionOptions(parsed, scopedModels, sessionManager.buildSessionContext().messages.length > 0, modelRuntime, settingsManager);
563
694
  diagnostics.push(...sessionOptionDiagnostics);
564
695
  if (parsed.apiKey) {
565
696
  if (!sessionOptions.model) {
@@ -569,7 +700,8 @@ export async function main(args, options) {
569
700
  });
570
701
  }
571
702
  else {
572
- authStorage.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey);
703
+ await modelRuntime.setRuntimeApiKey(sessionOptions.model.provider, parsed.apiKey, { allowNetwork: false });
704
+ await services.modelRuntime.getAvailable();
573
705
  }
574
706
  }
575
707
  const created = await createAgentSessionFromServices({
@@ -614,7 +746,7 @@ export async function main(args, options) {
614
746
  });
615
747
  time("createAgentSessionRuntime");
616
748
  const { services, session, modelFallbackMessage } = runtime;
617
- const { settingsManager, modelRegistry, resourceLoader } = services;
749
+ const { settingsManager, modelRuntime, resourceLoader } = services;
618
750
  applyHttpProxySettings(settingsManager.getGlobalSettings().httpProxy);
619
751
  configureHttpDispatcher(settingsManager.getHttpIdleTimeoutMs());
620
752
  if (parsed.help) {
@@ -626,7 +758,7 @@ export async function main(args, options) {
626
758
  }
627
759
  if (parsed.listModels !== undefined) {
628
760
  const searchPattern = typeof parsed.listModels === "string" ? parsed.listModels : undefined;
629
- await listModels(modelRegistry, searchPattern);
761
+ await listModels(modelRuntime, searchPattern);
630
762
  process.exit(0);
631
763
  }
632
764
  // Read piped stdin content (if any) - skip for RPC mode which uses stdin for JSON-RPC
@@ -664,54 +796,166 @@ export async function main(args, options) {
664
796
  console.error(chalk.red("Error: DRAHT_STARTUP_BENCHMARK only supports interactive mode"));
665
797
  process.exit(1);
666
798
  }
667
- if (appMode === "rpc") {
668
- printTimings();
669
- await runRpcMode(runtime);
670
- }
671
- else if (appMode === "interactive") {
672
- const interactiveMode = new InteractiveMode(runtime, {
673
- migratedProviders,
674
- modelFallbackMessage,
675
- autoTrustOnReloadCwd,
676
- initialMessage,
677
- initialImages,
678
- initialMessages: parsed.messages,
679
- verbose: parsed.verbose,
680
- });
681
- if (startupBenchmark) {
682
- await interactiveMode.init();
683
- time("interactiveMode.init");
684
- // Give the TUI's stdin handler a brief chance to consume terminal query replies
685
- // (Kitty keyboard protocol, device attributes, cell size) before restoring the terminal.
686
- await new Promise((resolve) => setTimeout(resolve, 150));
687
- interactiveMode.stop();
688
- stopThemeWatcher();
799
+ // RPC refreshes catalogs here in the background; interactive mode starts its refresh after TUI initialization.
800
+ if (!offlineMode && appMode === "rpc") {
801
+ void modelRuntime.refresh().catch(() => { });
802
+ }
803
+ // ── DEFAULT-ON (R35-ALWAYS.1) ────────────────────────────────────────────────────────────
804
+ // Interactive sessions register a control socket unless something says otherwise. The lock
805
+ // file records the session's resolved cwd (not process.cwd()), which is what identifies the
806
+ // project a session belongs to when --session/--resume selected a session from elsewhere.
807
+ //
808
+ // `parsed.attachable` is a TRI-STATE and the whole split below hangs off it:
809
+ // true the operator typed --attachable → bind, banner, failure is FATAL
810
+ // false the operator typed --no-attachable → never bind
811
+ // undefined nobody said → bind iff interactive, silently,
812
+ // and a failure only degrades
813
+ //
814
+ // Two things about WHERE this sits, both load-bearing:
815
+ // 1. `appMode` is read HERE, not at its first computation ~300 lines up, because piped
816
+ // stdin DOWNGRADES "interactive" to "print" just above. Reading the earlier value
817
+ // would bind a socket for `echo hi | draht`.
818
+ // 2. The gate is what keeps SUBAGENTS unbound — subagent.ts spawns children with
819
+ // ["--mode","json","-p","--no-session"], which is never "interactive". Defaulting
820
+ // inside the argument parser instead would put a socket under every subagent and a
821
+ // parallel wave would be the first thing to hit the socket cap.
822
+ // Precedence flag ?? env ?? setting mirrors `sessionDir` above. The setting is read
823
+ // global-only; see SettingsManager.getAttachableSessions for why.
824
+ const attachableRequestedExplicitly = parsed.attachable === true;
825
+ const attachableEnabled = parsed.attachable ??
826
+ (appMode === "interactive" &&
827
+ !isTruthyEnvFlag(process.env[ENV_NO_ATTACHABLE]) &&
828
+ settingsManager.getAttachableSessions());
829
+ let attachableSession;
830
+ if (attachableEnabled) {
831
+ try {
832
+ attachableSession = await makeSessionAttachable({
833
+ session,
834
+ enabled: true,
835
+ cwd: session.sessionManager.getCwd(),
836
+ // The banner is stdout, and interactive mode never took stdout over, so an
837
+ // implicit bind must not print it into the scrollback.
838
+ announce: attachableRequestedExplicitly,
839
+ });
840
+ }
841
+ catch (error) {
842
+ // ── THE SPLIT CATCH ───────────────────────────────────────────────────────────
843
+ // An EXPLICIT --attachable that fails stays fatal: the operator asked for a
844
+ // reachable session and would otherwise get an unreachable one without being
845
+ // told. An IMPLICIT default that fails must NEVER prevent a session starting —
846
+ // that is the entire point of the requirement. One line on stderr (never stdout,
847
+ // in any mode), then carry on unattached: everything downstream already tolerates
848
+ // `attachableSession === undefined`.
849
+ //
850
+ // TWO CONSEQUENCES, recorded here because they are decisions and not accidents:
851
+ //
852
+ // (i) THE `--continue` TWIN DEGRADES AND IS THEREFORE NOT ON THE PHONE. Under
853
+ // default-on the commonest failure is not environmental at all. `continueRecent`
854
+ // reopens the most recent session FILE, so a second `draht -c` in the same
855
+ // project reuses the header id and therefore the socket name, and loses the
856
+ // race for the lock. It gets the busy notice below and runs normally, but it is
857
+ // invisible to the fleet. Decoupling socket identity from session identity would
858
+ // make both windows reachable; it ripples through the wire, the history join key
859
+ // and resume, and is NAMED DEBT for a later phase, deliberately not attempted
860
+ // here.
861
+ //
862
+ // (ii) REMOVING THE FATAL EXIT REMOVES THE ONLY GUARD ATTACHABLE SESSIONS HAD
863
+ // AGAINST TWO PROCESSES APPENDING TO ONE SESSION JSONL. The `process.exit(1)`
864
+ // this replaces was never designed as that guard, but it was one: the second
865
+ // `draht -c` died before it could write. It now lives, and both processes
866
+ // append to the same file. That hazard predates and outlives this change for
867
+ // every non-attachable session, and the session store is append-only, but it
868
+ // is strictly more reachable now than it was.
869
+ if (attachableRequestedExplicitly) {
870
+ const message = error instanceof Error ? error.message : "Failed to start attachable session";
871
+ console.error(chalk.red(`Error: ${message}`));
872
+ process.exit(1);
873
+ }
874
+ console.error(chalk.yellow(describeAttachableDegradation(error)));
875
+ attachableSession = undefined;
876
+ }
877
+ }
878
+ if (attachableSession) {
879
+ // Hand the session the pending-ask registry, so a dialog raised by the agent reaches every
880
+ // attached client and can be answered from one. This only HANDS THE HANDLE OVER: the wrap
881
+ // itself is installed inside `_applyExtensionBindings`, the one mode-agnostic seam every
882
+ // session passes through. Installing it here instead would be silently overwritten —
883
+ // interactive and rpc bind their own UI context later, and `bindExtensions` re-pushes it.
884
+ session.setPermissionRelay(attachableSession.relay ?? undefined);
885
+ }
886
+ // The mode run loops end in process.exit() and never return here, so the finally below
887
+ // is not enough on its own: exit and signal paths need their own synchronous cleanup.
888
+ const releaseAttachableCleanup = attachableSession ? registerAttachableSessionCleanup(attachableSession) : undefined;
889
+ // /new, /resume, /fork and /import dispose this session object and install a new one.
890
+ // Without following that, the socket would keep advertising a dead session id and route
891
+ // client input into a disposed session.
892
+ const releaseAttachableRebind = attachableSession
893
+ ? runtime.addSessionReplacedListener(async (nextSession) => {
894
+ await attachableSession.rebind(nextSession, nextSession.sessionManager.getCwd());
895
+ // The rebind swept the old session's pending asks fail-closed and built a fresh
896
+ // registry for the new one. Without re-handing it here the relay would silently
897
+ // die on /new, /resume, /fork and /import: the new session would keep an
898
+ // undecorated UI context, `hasUI()` would stop counting attached clients, and a
899
+ // phone would watch a session it can no longer answer.
900
+ nextSession.setPermissionRelay(attachableSession.relay ?? undefined);
901
+ })
902
+ : undefined;
903
+ try {
904
+ if (appMode === "rpc") {
689
905
  printTimings();
690
- if (process.stdout.writableLength > 0) {
691
- await new Promise((resolve) => process.stdout.once("drain", resolve));
906
+ await runRpcMode(runtime);
907
+ }
908
+ else if (appMode === "interactive") {
909
+ const interactiveMode = new InteractiveMode(runtime, {
910
+ migratedProviders,
911
+ modelFallbackMessage,
912
+ autoTrustOnReloadCwd,
913
+ initialMessage,
914
+ initialImages,
915
+ initialMessages: parsed.messages,
916
+ verbose: parsed.verbose,
917
+ });
918
+ if (startupBenchmark) {
919
+ await interactiveMode.init();
920
+ time("interactiveMode.init");
921
+ // Give the TUI's stdin handler a brief chance to consume terminal query replies
922
+ // (Kitty keyboard protocol, device attributes, cell size) before restoring the terminal.
923
+ await new Promise((resolve) => setTimeout(resolve, 150));
924
+ interactiveMode.stop();
925
+ stopThemeWatcher();
926
+ printTimings();
927
+ if (process.stdout.writableLength > 0) {
928
+ await new Promise((resolve) => process.stdout.once("drain", resolve));
929
+ }
930
+ if (process.stderr.writableLength > 0) {
931
+ await new Promise((resolve) => process.stderr.once("drain", resolve));
932
+ }
933
+ return;
692
934
  }
693
- if (process.stderr.writableLength > 0) {
694
- await new Promise((resolve) => process.stderr.once("drain", resolve));
935
+ printTimings();
936
+ await interactiveMode.run();
937
+ }
938
+ else {
939
+ printTimings();
940
+ const exitCode = await runPrintMode(runtime, {
941
+ mode: toPrintOutputMode(appMode),
942
+ messages: parsed.messages,
943
+ initialMessage,
944
+ initialImages,
945
+ });
946
+ stopThemeWatcher();
947
+ restoreStdout();
948
+ if (exitCode !== 0) {
949
+ process.exitCode = exitCode;
695
950
  }
696
951
  return;
697
952
  }
698
- printTimings();
699
- await interactiveMode.run();
700
- }
701
- else {
702
- printTimings();
703
- const exitCode = await runPrintMode(runtime, {
704
- mode: toPrintOutputMode(appMode),
705
- messages: parsed.messages,
706
- initialMessage,
707
- initialImages,
708
- });
709
- stopThemeWatcher();
710
- restoreStdout();
711
- if (exitCode !== 0) {
712
- process.exitCode = exitCode;
713
- }
714
- return;
953
+ }
954
+ finally {
955
+ // Removes the .sock and .lock files so the session stops showing up in --list-sessions.
956
+ releaseAttachableRebind?.();
957
+ releaseAttachableCleanup?.();
958
+ await attachableSession?.stop();
715
959
  }
716
960
  }
717
961
  //# sourceMappingURL=main.js.map