@draht/coding-agent 2026.10.20-1 → 2026.10.23-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 (729) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/agents/advisor.md +2 -2
  3. package/agents/architect.md +11 -33
  4. package/agents/debugger.md +13 -54
  5. package/agents/git-committer.md +18 -42
  6. package/agents/implementer.md +14 -36
  7. package/agents/investigator.md +12 -63
  8. package/agents/reviewer.md +16 -44
  9. package/agents/security-auditor.md +22 -56
  10. package/agents/spec-reviewer.md +13 -53
  11. package/agents/verifier.md +14 -33
  12. package/bin/drahtbank.mjs +4 -0
  13. package/dist/agents/advisor.md +2 -2
  14. package/dist/agents/architect.md +11 -33
  15. package/dist/agents/debugger.md +13 -54
  16. package/dist/agents/git-committer.md +18 -42
  17. package/dist/agents/implementer.md +14 -36
  18. package/dist/agents/investigator.md +12 -63
  19. package/dist/agents/reviewer.md +16 -44
  20. package/dist/agents/security-auditor.md +22 -56
  21. package/dist/agents/spec-reviewer.md +13 -53
  22. package/dist/agents/verifier.md +14 -33
  23. package/dist/bundle/chunks/anthropic-messages-G57VPNTF.js +6 -0
  24. package/dist/bundle/chunks/anthropic.js +1 -1
  25. package/dist/bundle/chunks/azure-openai-responses-AYUCZ5WN.js +2 -0
  26. package/dist/bundle/chunks/bedrock-converse-stream.js +23 -20
  27. package/dist/bundle/chunks/chunk-3GDEPGTR.js +16 -0
  28. package/dist/bundle/chunks/chunk-5JW3NSTV.js +2 -0
  29. package/dist/bundle/chunks/{chunk-FHX2S5IG.js → chunk-6WESOD4H.js} +1 -1
  30. package/dist/bundle/chunks/chunk-76YNMQ57.js +2 -0
  31. package/dist/bundle/chunks/chunk-AC3MSTC6.js +2 -0
  32. package/dist/bundle/chunks/chunk-ACLWH5WQ.js +2 -0
  33. package/dist/bundle/chunks/chunk-BL72B6LV.js +82 -0
  34. package/dist/bundle/chunks/{chunk-5QJFWTKA.js → chunk-CLKG6K6Z.js} +5 -2
  35. package/dist/bundle/chunks/chunk-DN7SM3LX.js +479 -0
  36. package/dist/bundle/chunks/{chunk-UTRX2VHB.js → chunk-DOUMZTXH.js} +3 -3
  37. package/dist/bundle/chunks/chunk-DQ4G4IS4.js +20 -0
  38. package/dist/bundle/chunks/chunk-E4VZJRJ2.js +9 -0
  39. package/dist/bundle/chunks/chunk-FOYIPAAD.js +6 -0
  40. package/dist/bundle/chunks/chunk-FXCTQRNN.js +2 -0
  41. package/dist/bundle/chunks/chunk-GQXRTK54.js +20 -0
  42. package/dist/bundle/chunks/chunk-IGO52ZOY.js +132 -0
  43. package/dist/bundle/chunks/{chunk-VXUJMEMO.js → chunk-IT4RIOZD.js} +1 -1
  44. package/dist/bundle/chunks/chunk-JJKPUMH2.js +1424 -0
  45. package/dist/bundle/chunks/chunk-JNWRE5F4.js +2 -0
  46. package/dist/bundle/chunks/chunk-KSGHCBHT.js +2 -0
  47. package/dist/bundle/chunks/chunk-MBFTIGLS.js +2 -0
  48. package/dist/bundle/chunks/chunk-N26RGV3K.js +11 -0
  49. package/dist/bundle/chunks/{chunk-KPO5375S.js → chunk-RCRGGYLW.js} +1 -1
  50. package/dist/bundle/chunks/chunk-UCJ7FLSO.js +166 -0
  51. package/dist/bundle/chunks/chunk-USCN7R2E.js +2 -0
  52. package/dist/bundle/chunks/chunk-WFHH5SX6.js +4 -0
  53. package/dist/bundle/chunks/chunk-WYWBXNDO.js +6 -0
  54. package/dist/bundle/chunks/chunk-ZRPAOMVB.js +2 -0
  55. package/dist/bundle/chunks/{cli-VCHSHNKT.js → cli-HTUB6WOG.js} +6 -6
  56. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-RRSO6OXX.js +2 -0
  57. package/dist/bundle/chunks/codemode-worker.js +188 -21
  58. package/dist/bundle/chunks/execute-UUPNZJJG.js +31 -0
  59. package/dist/bundle/chunks/github-copilot.js +1 -1
  60. package/dist/bundle/chunks/google-generative-ai-VJSS5EBX.js +2 -0
  61. package/dist/bundle/chunks/google-vertex-K23DBWTT.js +2 -0
  62. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  63. package/dist/bundle/chunks/{llama-cpp-classify-EJ5XMSQL.js → llama-cpp-classify-3VDXTYVJ.js} +3 -3
  64. package/dist/bundle/chunks/mistral-conversations-SKVQJGFZ.js +5 -0
  65. package/dist/bundle/chunks/node-DXZFQBEO.js +16 -0
  66. package/dist/bundle/chunks/{node-6IIDYB3K.js → node-LBZLUIBE.js} +1 -1
  67. package/dist/bundle/chunks/openai-chatgpt.js +1 -1
  68. package/dist/bundle/chunks/openai-codex-responses-LV4RIZL3.js +10 -0
  69. package/dist/bundle/chunks/openai-codex.js +1 -1
  70. package/dist/bundle/chunks/openai-completions-PUIR2V25.js +7 -0
  71. package/dist/bundle/chunks/openai-decisions-2DJLSYQF.js +5 -0
  72. package/dist/bundle/chunks/openai-responses-6ESQOXAF.js +4 -0
  73. package/dist/bundle/chunks/opencode-go.js +1 -1
  74. package/dist/bundle/chunks/openrouter-images-TVXBMY3V.js +2 -0
  75. package/dist/bundle/chunks/pi-messages-XS7FDWQI.js +8 -0
  76. package/dist/bundle/chunks/runtime-IB3XQ7E3.js +2 -0
  77. package/dist/bundle/chunks/runtime-LB35PK4J.js +3 -0
  78. package/dist/bundle/chunks/settings-manager-YNY5F4RU.js +2 -0
  79. package/dist/bundle/chunks/typesafe-system-one-67GAWZXE.js +2 -0
  80. package/dist/bundle/chunks/virtual-modules-U4CBGVMI.js +2 -0
  81. package/dist/bundle/cli-runtime.js +1 -1
  82. package/dist/bundle/index.js +1 -1
  83. package/dist/bundle/rpc-entry.js +1 -1
  84. package/dist/cli/args.d.ts +2 -1
  85. package/dist/cli/args.d.ts.map +1 -1
  86. package/dist/cli/args.js +30 -8
  87. package/dist/cli/args.js.map +1 -1
  88. package/dist/cli/credential-print.d.ts.map +1 -1
  89. package/dist/cli/credential-print.js +4 -4
  90. package/dist/cli/credential-print.js.map +1 -1
  91. package/dist/config.d.ts +18 -1
  92. package/dist/config.d.ts.map +1 -1
  93. package/dist/config.js +44 -6
  94. package/dist/config.js.map +1 -1
  95. package/dist/core/agent-session.d.ts +65 -8
  96. package/dist/core/agent-session.d.ts.map +1 -1
  97. package/dist/core/agent-session.js +240 -102
  98. package/dist/core/agent-session.js.map +1 -1
  99. package/dist/core/auth-storage.d.ts.map +1 -1
  100. package/dist/core/auth-storage.js +20 -13
  101. package/dist/core/auth-storage.js.map +1 -1
  102. package/dist/core/bash-executor.d.ts.map +1 -1
  103. package/dist/core/bash-executor.js +42 -52
  104. package/dist/core/bash-executor.js.map +1 -1
  105. package/dist/core/bug-report.d.ts +9 -1
  106. package/dist/core/bug-report.d.ts.map +1 -1
  107. package/dist/core/builtins/completion-checks.d.ts +3 -0
  108. package/dist/core/builtins/completion-checks.d.ts.map +1 -0
  109. package/dist/core/builtins/completion-checks.js +142 -0
  110. package/dist/core/builtins/completion-checks.js.map +1 -0
  111. package/dist/core/builtins/duet.d.ts.map +1 -1
  112. package/dist/core/builtins/duet.js +7 -5
  113. package/dist/core/builtins/duet.js.map +1 -1
  114. package/dist/core/builtins/git-safety.d.ts +3 -0
  115. package/dist/core/builtins/git-safety.d.ts.map +1 -0
  116. package/dist/core/builtins/git-safety.js +34 -0
  117. package/dist/core/builtins/git-safety.js.map +1 -0
  118. package/dist/core/builtins/index.d.ts.map +1 -1
  119. package/dist/core/builtins/index.js +4 -0
  120. package/dist/core/builtins/index.js.map +1 -1
  121. package/dist/core/client-identity.d.ts +8 -0
  122. package/dist/core/client-identity.d.ts.map +1 -0
  123. package/dist/core/client-identity.js +15 -0
  124. package/dist/core/client-identity.js.map +1 -0
  125. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  126. package/dist/core/compaction/branch-summarization.js +1 -2
  127. package/dist/core/compaction/branch-summarization.js.map +1 -1
  128. package/dist/core/compaction/compaction.d.ts +2 -2
  129. package/dist/core/compaction/compaction.d.ts.map +1 -1
  130. package/dist/core/compaction/compaction.js +20 -15
  131. package/dist/core/compaction/compaction.js.map +1 -1
  132. package/dist/core/compaction/utils.d.ts +6 -0
  133. package/dist/core/compaction/utils.d.ts.map +1 -1
  134. package/dist/core/compaction/utils.js +7 -8
  135. package/dist/core/compaction/utils.js.map +1 -1
  136. package/dist/core/export-html/index.d.ts.map +1 -1
  137. package/dist/core/export-html/index.js +2 -0
  138. package/dist/core/export-html/index.js.map +1 -1
  139. package/dist/core/export-html/template.html +1 -0
  140. package/dist/core/export-html/template.js +23 -17
  141. package/dist/core/export-html/tool-renderer.d.ts +3 -3
  142. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  143. package/dist/core/export-html/tool-renderer.js +5 -3
  144. package/dist/core/export-html/tool-renderer.js.map +1 -1
  145. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  146. package/dist/core/export-html/vendor/marked.min.js +30 -29
  147. package/dist/core/extensions/index.d.ts +1 -1
  148. package/dist/core/extensions/index.d.ts.map +1 -1
  149. package/dist/core/extensions/index.js.map +1 -1
  150. package/dist/core/extensions/loader.d.ts.map +1 -1
  151. package/dist/core/extensions/loader.js +7 -0
  152. package/dist/core/extensions/loader.js.map +1 -1
  153. package/dist/core/extensions/runner.d.ts +6 -2
  154. package/dist/core/extensions/runner.d.ts.map +1 -1
  155. package/dist/core/extensions/runner.js +16 -4
  156. package/dist/core/extensions/runner.js.map +1 -1
  157. package/dist/core/extensions/types.d.ts +61 -7
  158. package/dist/core/extensions/types.d.ts.map +1 -1
  159. package/dist/core/extensions/types.js.map +1 -1
  160. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  161. package/dist/core/extensions/virtual-modules.js +2 -0
  162. package/dist/core/extensions/virtual-modules.js.map +1 -1
  163. package/dist/core/key-id-schema.d.ts +6 -0
  164. package/dist/core/key-id-schema.d.ts.map +1 -0
  165. package/dist/core/key-id-schema.js +16 -0
  166. package/dist/core/key-id-schema.js.map +1 -0
  167. package/dist/core/keybindings-schema.d.ts +4 -0
  168. package/dist/core/keybindings-schema.d.ts.map +1 -0
  169. package/dist/core/keybindings-schema.js +16 -0
  170. package/dist/core/keybindings-schema.js.map +1 -0
  171. package/dist/core/keybindings.d.ts +242 -75
  172. package/dist/core/keybindings.d.ts.map +1 -1
  173. package/dist/core/keybindings.js +30 -23
  174. package/dist/core/keybindings.js.map +1 -1
  175. package/dist/core/mcp-servers.d.ts +22 -0
  176. package/dist/core/mcp-servers.d.ts.map +1 -1
  177. package/dist/core/mcp-servers.js +72 -11
  178. package/dist/core/mcp-servers.js.map +1 -1
  179. package/dist/core/model-config.d.ts +1623 -74
  180. package/dist/core/model-config.d.ts.map +1 -1
  181. package/dist/core/model-config.js +70 -184
  182. package/dist/core/model-config.js.map +1 -1
  183. package/dist/core/model-registry.d.ts +3 -1
  184. package/dist/core/model-registry.d.ts.map +1 -1
  185. package/dist/core/model-registry.js +4 -0
  186. package/dist/core/model-registry.js.map +1 -1
  187. package/dist/core/model-resolver.d.ts +56 -43
  188. package/dist/core/model-resolver.d.ts.map +1 -1
  189. package/dist/core/model-resolver.js +253 -358
  190. package/dist/core/model-resolver.js.map +1 -1
  191. package/dist/core/model-runtime.d.ts.map +1 -1
  192. package/dist/core/model-runtime.js +19 -10
  193. package/dist/core/model-runtime.js.map +1 -1
  194. package/dist/core/nested-tool-calls.d.ts +1 -0
  195. package/dist/core/nested-tool-calls.d.ts.map +1 -1
  196. package/dist/core/nested-tool-calls.js +1 -0
  197. package/dist/core/nested-tool-calls.js.map +1 -1
  198. package/dist/core/package-manager.js +3 -3
  199. package/dist/core/package-manager.js.map +1 -1
  200. package/dist/core/polyphase/keyword.js +1 -1
  201. package/dist/core/polyphase/keyword.js.map +1 -1
  202. package/dist/core/polyphase/model-selection.d.ts.map +1 -1
  203. package/dist/core/polyphase/model-selection.js +15 -7
  204. package/dist/core/polyphase/model-selection.js.map +1 -1
  205. package/dist/core/polyphase/workflow/prelude.d.ts +2 -0
  206. package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -1
  207. package/dist/core/polyphase/workflow/prelude.js +12 -16
  208. package/dist/core/polyphase/workflow/prelude.js.map +1 -1
  209. package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
  210. package/dist/core/polyphase/workflow/runtime.js +2 -1
  211. package/dist/core/polyphase/workflow/runtime.js.map +1 -1
  212. package/dist/core/project-trust.d.ts.map +1 -1
  213. package/dist/core/project-trust.js +2 -1
  214. package/dist/core/project-trust.js.map +1 -1
  215. package/dist/core/prompt-templates.d.ts.map +1 -1
  216. package/dist/core/prompt-templates.js +7 -2
  217. package/dist/core/prompt-templates.js.map +1 -1
  218. package/dist/core/provider-composer.d.ts +2 -1
  219. package/dist/core/provider-composer.d.ts.map +1 -1
  220. package/dist/core/provider-composer.js +13 -0
  221. package/dist/core/provider-composer.js.map +1 -1
  222. package/dist/core/radius.d.ts +2 -0
  223. package/dist/core/radius.d.ts.map +1 -1
  224. package/dist/core/radius.js +2 -0
  225. package/dist/core/radius.js.map +1 -1
  226. package/dist/core/remote-catalog-provider.d.ts +12 -1
  227. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  228. package/dist/core/remote-catalog-provider.js +84 -24
  229. package/dist/core/remote-catalog-provider.js.map +1 -1
  230. package/dist/core/resource-loader.d.ts +3 -0
  231. package/dist/core/resource-loader.d.ts.map +1 -1
  232. package/dist/core/resource-loader.js +7 -4
  233. package/dist/core/resource-loader.js.map +1 -1
  234. package/dist/core/sdk.d.ts +13 -4
  235. package/dist/core/sdk.d.ts.map +1 -1
  236. package/dist/core/sdk.js +27 -15
  237. package/dist/core/sdk.js.map +1 -1
  238. package/dist/core/settings-defaults.d.ts +65 -0
  239. package/dist/core/settings-defaults.d.ts.map +1 -0
  240. package/dist/core/settings-defaults.js +66 -0
  241. package/dist/core/settings-defaults.js.map +1 -0
  242. package/dist/core/settings-manager.d.ts +17 -178
  243. package/dist/core/settings-manager.d.ts.map +1 -1
  244. package/dist/core/settings-manager.js +86 -57
  245. package/dist/core/settings-manager.js.map +1 -1
  246. package/dist/core/settings-schema.d.ts +269 -0
  247. package/dist/core/settings-schema.d.ts.map +1 -0
  248. package/dist/core/settings-schema.js +318 -0
  249. package/dist/core/settings-schema.js.map +1 -0
  250. package/dist/core/skills.d.ts +4 -1
  251. package/dist/core/skills.d.ts.map +1 -1
  252. package/dist/core/skills.js +6 -1
  253. package/dist/core/skills.js.map +1 -1
  254. package/dist/core/system-prompt.d.ts +6 -0
  255. package/dist/core/system-prompt.d.ts.map +1 -1
  256. package/dist/core/system-prompt.js +10 -5
  257. package/dist/core/system-prompt.js.map +1 -1
  258. package/dist/core/tools/bash.d.ts.map +1 -1
  259. package/dist/core/tools/bash.js +3 -5
  260. package/dist/core/tools/bash.js.map +1 -1
  261. package/dist/core/tools/grep.d.ts +8 -0
  262. package/dist/core/tools/grep.d.ts.map +1 -1
  263. package/dist/core/tools/grep.js +19 -7
  264. package/dist/core/tools/grep.js.map +1 -1
  265. package/dist/core/tools/index.d.ts +2 -0
  266. package/dist/core/tools/index.d.ts.map +1 -1
  267. package/dist/core/tools/index.js +2 -0
  268. package/dist/core/tools/index.js.map +1 -1
  269. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  270. package/dist/core/tools/output-accumulator.js +4 -10
  271. package/dist/core/tools/output-accumulator.js.map +1 -1
  272. package/dist/core/tools/path-utils.d.ts +1 -1
  273. package/dist/core/tools/path-utils.d.ts.map +1 -1
  274. package/dist/core/tools/path-utils.js +6 -6
  275. package/dist/core/tools/path-utils.js.map +1 -1
  276. package/dist/core/tools/read.d.ts +13 -0
  277. package/dist/core/tools/read.d.ts.map +1 -1
  278. package/dist/core/tools/read.js +32 -2
  279. package/dist/core/tools/read.js.map +1 -1
  280. package/dist/core/tools/render-utils.d.ts +20 -0
  281. package/dist/core/tools/render-utils.d.ts.map +1 -1
  282. package/dist/core/tools/render-utils.js +67 -0
  283. package/dist/core/tools/render-utils.js.map +1 -1
  284. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  285. package/dist/core/tools/renderers/bash.js +7 -35
  286. package/dist/core/tools/renderers/bash.js.map +1 -1
  287. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  288. package/dist/core/tools/renderers/edit.js +5 -4
  289. package/dist/core/tools/renderers/edit.js.map +1 -1
  290. package/dist/core/tools/renderers/index.d.ts +2 -2
  291. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  292. package/dist/core/tools/renderers/index.js.map +1 -1
  293. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  294. package/dist/core/tools/renderers/read.js +7 -11
  295. package/dist/core/tools/renderers/read.js.map +1 -1
  296. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  297. package/dist/extensions/codemode/execute.js +391 -80
  298. package/dist/extensions/codemode/execute.js.map +1 -1
  299. package/dist/extensions/codemode/index.d.ts.map +1 -1
  300. package/dist/extensions/codemode/index.js +3 -1
  301. package/dist/extensions/codemode/index.js.map +1 -1
  302. package/dist/extensions/codemode/renderer.d.ts +2 -2
  303. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  304. package/dist/extensions/codemode/renderer.js +9 -3
  305. package/dist/extensions/codemode/renderer.js.map +1 -1
  306. package/dist/extensions/codemode/tool.d.ts +22 -21
  307. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  308. package/dist/extensions/codemode/tool.js +96 -123
  309. package/dist/extensions/codemode/tool.js.map +1 -1
  310. package/dist/extensions/llama/provider.d.ts.map +1 -1
  311. package/dist/extensions/llama/provider.js +34 -11
  312. package/dist/extensions/llama/provider.js.map +1 -1
  313. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  314. package/dist/extensions/mcp/cli.js +27 -33
  315. package/dist/extensions/mcp/cli.js.map +1 -1
  316. package/dist/extensions/mcp/config.d.ts +15 -3
  317. package/dist/extensions/mcp/config.d.ts.map +1 -1
  318. package/dist/extensions/mcp/config.js +49 -12
  319. package/dist/extensions/mcp/config.js.map +1 -1
  320. package/dist/extensions/mcp/index.d.ts +4 -1
  321. package/dist/extensions/mcp/index.d.ts.map +1 -1
  322. package/dist/extensions/mcp/index.js +279 -129
  323. package/dist/extensions/mcp/index.js.map +1 -1
  324. package/dist/extensions/mcp/oauth.d.ts +21 -11
  325. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  326. package/dist/extensions/mcp/oauth.js +166 -45
  327. package/dist/extensions/mcp/oauth.js.map +1 -1
  328. package/dist/extensions/mcp/resources.d.ts +3 -10
  329. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  330. package/dist/extensions/mcp/resources.js +4 -5
  331. package/dist/extensions/mcp/resources.js.map +1 -1
  332. package/dist/extensions/mcp/runtime.d.ts +7 -7
  333. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  334. package/dist/extensions/mcp/runtime.js +31 -45
  335. package/dist/extensions/mcp/runtime.js.map +1 -1
  336. package/dist/extensions/mcp/tools.d.ts +7 -5
  337. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  338. package/dist/extensions/mcp/tools.js +87 -29
  339. package/dist/extensions/mcp/tools.js.map +1 -1
  340. package/dist/extensions/mcp/ui.d.ts +3 -3
  341. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  342. package/dist/extensions/mcp/ui.js +18 -6
  343. package/dist/extensions/mcp/ui.js.map +1 -1
  344. package/dist/extensions/tool-search/tool.d.ts +0 -2
  345. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  346. package/dist/extensions/tool-search/tool.js +2 -4
  347. package/dist/extensions/tool-search/tool.js.map +1 -1
  348. package/dist/hooks/checks/checks-runtime.cjs +215 -0
  349. package/dist/hooks/checks/git-safety.cjs +198 -0
  350. package/dist/hooks/checks/git-safety.d.cts +1 -0
  351. package/dist/hooks/gsd/draht-post-task.js +78 -39
  352. package/dist/hooks/gsd/draht-quality-gate.js +210 -122
  353. package/dist/hooks/gsd/package.json +3 -0
  354. package/dist/index.d.ts +5 -4
  355. package/dist/index.d.ts.map +1 -1
  356. package/dist/index.js +3 -2
  357. package/dist/index.js.map +1 -1
  358. package/dist/main.d.ts.map +1 -1
  359. package/dist/main.js +11 -3
  360. package/dist/main.js.map +1 -1
  361. package/dist/modes/interactive/components/auth-url.d.ts +14 -0
  362. package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
  363. package/dist/modes/interactive/components/auth-url.js +37 -0
  364. package/dist/modes/interactive/components/auth-url.js.map +1 -0
  365. package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
  366. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  367. package/dist/modes/interactive/components/bash-execution.js +17 -14
  368. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  369. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
  370. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  371. package/dist/modes/interactive/components/branch-summary-message.js +5 -2
  372. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  373. package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
  374. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  375. package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
  376. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  377. package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
  378. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  379. package/dist/modes/interactive/components/custom-entry.js +8 -2
  380. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  381. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  382. package/dist/modes/interactive/components/custom-message.js +1 -0
  383. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  384. package/dist/modes/interactive/components/login-dialog.d.ts +3 -0
  385. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  386. package/dist/modes/interactive/components/login-dialog.js +38 -10
  387. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  388. package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
  389. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  390. package/dist/modes/interactive/components/oauth-selector.js +24 -21
  391. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  392. package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
  393. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  394. package/dist/modes/interactive/components/radius-login-selector.js +85 -0
  395. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  396. package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
  397. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  398. package/dist/modes/interactive/components/settings-selector.js +9 -8
  399. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  400. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
  401. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  402. package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
  403. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  404. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  405. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  406. package/dist/modes/interactive/components/status-indicator.js +2 -2
  407. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  408. package/dist/modes/interactive/components/tool-execution.d.ts +12 -13
  409. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  410. package/dist/modes/interactive/components/tool-execution.js +32 -45
  411. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  412. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  413. package/dist/modes/interactive/components/tree-selector.js +2 -9
  414. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  415. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  416. package/dist/modes/interactive/components/user-message.js +5 -4
  417. package/dist/modes/interactive/components/user-message.js.map +1 -1
  418. package/dist/modes/interactive/interactive-mode.d.ts +43 -48
  419. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  420. package/dist/modes/interactive/interactive-mode.js +362 -278
  421. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  422. package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
  423. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
  424. package/dist/modes/interactive/program-status-reporter.js +110 -0
  425. package/dist/modes/interactive/program-status-reporter.js.map +1 -0
  426. package/dist/modes/interactive/theme/dark.json +1 -1
  427. package/dist/modes/interactive/theme/light.json +1 -1
  428. package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
  429. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  430. package/dist/modes/interactive/theme/system-theme.js +16 -5
  431. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  432. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  433. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  434. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  435. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  436. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  437. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  438. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  439. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  440. package/dist/modes/interactive/theme/theme.d.ts +13 -16
  441. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  442. package/dist/modes/interactive/theme/theme.js +22 -29
  443. package/dist/modes/interactive/theme/theme.js.map +1 -1
  444. package/dist/modes/print-mode.d.ts.map +1 -1
  445. package/dist/modes/print-mode.js +4 -0
  446. package/dist/modes/print-mode.js.map +1 -1
  447. package/dist/package-manager-cli.d.ts.map +1 -1
  448. package/dist/package-manager-cli.js +26 -1
  449. package/dist/package-manager-cli.js.map +1 -1
  450. package/dist/prompts/commands/atomic-commit.md +8 -6
  451. package/dist/prompts/commands/brainstorm.md +5 -149
  452. package/dist/prompts/commands/create-verification-skill.md +8 -48
  453. package/dist/prompts/commands/discuss-phase.md +6 -10
  454. package/dist/prompts/commands/execute-phase.md +18 -45
  455. package/dist/prompts/commands/fix.md +16 -128
  456. package/dist/prompts/commands/grill.md +6 -53
  457. package/dist/prompts/commands/init-project.md +13 -18
  458. package/dist/prompts/commands/map-codebase.md +3 -3
  459. package/dist/prompts/commands/new-project.md +12 -17
  460. package/dist/prompts/commands/next-milestone.md +4 -8
  461. package/dist/prompts/commands/orchestrate-loop.md +12 -12
  462. package/dist/prompts/commands/orchestrate.md +12 -11
  463. package/dist/prompts/commands/pause-work.md +1 -1
  464. package/dist/prompts/commands/plan-phase.md +15 -37
  465. package/dist/prompts/commands/quick.md +11 -64
  466. package/dist/prompts/commands/resolve-conflicts.md +2 -15
  467. package/dist/prompts/commands/triage.md +3 -14
  468. package/dist/prompts/commands/verify-work.md +15 -63
  469. package/dist/prompts/commands/why.md +18 -118
  470. package/dist/skills/atomic-reasoning/SKILL.md +6 -105
  471. package/dist/skills/blast-radius/SKILL.md +1 -1
  472. package/dist/skills/epistemics/SKILL.md +12 -87
  473. package/dist/skills/explainers/SKILL.md +1 -1
  474. package/dist/skills/typescript-discipline/SKILL.md +12 -42
  475. package/dist/skills/typescript-discipline/references/patterns.md +25 -266
  476. package/dist/skills/unslop/SKILL.md +14 -105
  477. package/dist/utils/ansi.d.ts +8 -0
  478. package/dist/utils/ansi.d.ts.map +1 -1
  479. package/dist/utils/ansi.js +30 -11
  480. package/dist/utils/ansi.js.map +1 -1
  481. package/dist/utils/clipboard-command.d.ts.map +1 -1
  482. package/dist/utils/clipboard-command.js +3 -0
  483. package/dist/utils/clipboard-command.js.map +1 -1
  484. package/dist/utils/clipboard.d.ts.map +1 -1
  485. package/dist/utils/clipboard.js +18 -12
  486. package/dist/utils/clipboard.js.map +1 -1
  487. package/dist/utils/draht-user-agent.d.ts +1 -0
  488. package/dist/utils/draht-user-agent.d.ts.map +1 -1
  489. package/dist/utils/draht-user-agent.js +3 -2
  490. package/dist/utils/draht-user-agent.js.map +1 -1
  491. package/dist/utils/image-convert.d.ts +12 -0
  492. package/dist/utils/image-convert.d.ts.map +1 -1
  493. package/dist/utils/image-convert.js +45 -6
  494. package/dist/utils/image-convert.js.map +1 -1
  495. package/dist/utils/image-resize-core.d.ts +12 -0
  496. package/dist/utils/image-resize-core.d.ts.map +1 -1
  497. package/dist/utils/image-resize-core.js +5 -0
  498. package/dist/utils/image-resize-core.js.map +1 -1
  499. package/dist/utils/image-resize-worker.js +3 -2
  500. package/dist/utils/image-resize-worker.js.map +1 -1
  501. package/dist/utils/image-resize.d.ts.map +1 -1
  502. package/dist/utils/image-resize.js +9 -10
  503. package/dist/utils/image-resize.js.map +1 -1
  504. package/dist/utils/output-files.d.ts +15 -0
  505. package/dist/utils/output-files.d.ts.map +1 -0
  506. package/dist/utils/output-files.js +30 -0
  507. package/dist/utils/output-files.js.map +1 -0
  508. package/dist/utils/shell.d.ts.map +1 -1
  509. package/dist/utils/shell.js +43 -13
  510. package/dist/utils/shell.js.map +1 -1
  511. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  512. package/dist/utils/syntax-highlight.js +6 -1
  513. package/dist/utils/syntax-highlight.js.map +1 -1
  514. package/dist/utils/tools-manager.d.ts.map +1 -1
  515. package/dist/utils/tools-manager.js +4 -3
  516. package/dist/utils/tools-manager.js.map +1 -1
  517. package/docs/cli-integration.md +1 -1
  518. package/docs/cli.md +30 -26
  519. package/docs/codemode.md +230 -0
  520. package/docs/compaction.md +5 -5
  521. package/docs/containerization.md +1 -1
  522. package/docs/custom-provider.md +53 -1
  523. package/docs/docs.json +17 -1
  524. package/docs/drahtbank.md +163 -0
  525. package/docs/environment-variables.md +5 -2
  526. package/docs/extensions.md +143 -13
  527. package/docs/index.md +1 -1
  528. package/docs/json.md +3 -3
  529. package/docs/keybindings.md +9 -5
  530. package/docs/llama-cpp.md +9 -2
  531. package/docs/mcp.md +59 -3
  532. package/docs/message-types.md +22 -4
  533. package/docs/models-configuration.md +187 -0
  534. package/docs/models.md +67 -4
  535. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  536. package/docs/providers.md +70 -5
  537. package/docs/sdk.md +1 -1
  538. package/docs/settings.md +10 -8
  539. package/docs/terminal-setup.md +14 -0
  540. package/docs/themes.md +4 -2
  541. package/docs/tui.md +71 -1
  542. package/docs/usage.md +1 -1
  543. package/docs/windows.md +16 -2
  544. package/eval/drahtbank/adapters.d.mts +35 -0
  545. package/eval/drahtbank/adapters.mjs +192 -0
  546. package/eval/drahtbank/bank.d.mts +141 -0
  547. package/eval/drahtbank/bank.mjs +515 -0
  548. package/eval/drahtbank/cases-v2.d.mts +28 -0
  549. package/eval/drahtbank/cases-v2.mjs +164 -0
  550. package/eval/drahtbank/cases.d.mts +17 -0
  551. package/eval/drahtbank/cases.mjs +198 -0
  552. package/eval/drahtbank/cli.mjs +120 -0
  553. package/eval/drahtbank/grading-v2.d.mts +26 -0
  554. package/eval/drahtbank/grading-v2.mjs +227 -0
  555. package/eval/drahtbank/isolated-tools.ts +223 -0
  556. package/eval/drahtbank/isolation-worker.mjs +53 -0
  557. package/eval/drahtbank/isolation.d.mts +52 -0
  558. package/eval/drahtbank/isolation.mjs +345 -0
  559. package/eval/drahtbank/runtime-checks.d.mts +15 -0
  560. package/eval/drahtbank/runtime-checks.mjs +187 -0
  561. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  562. package/examples/extensions/minimal-mode.ts +4 -5
  563. package/examples/extensions/overlay-test.ts +2 -2
  564. package/examples/extensions/plan-mode/index.ts +6 -2
  565. package/examples/extensions/subagent/index.ts +4 -6
  566. package/hooks/checks/checks-runtime.cjs +215 -0
  567. package/hooks/checks/git-safety.cjs +198 -0
  568. package/hooks/checks/git-safety.d.cts +1 -0
  569. package/hooks/gsd/draht-post-task.js +78 -39
  570. package/hooks/gsd/draht-quality-gate.js +210 -122
  571. package/hooks/gsd/package.json +3 -0
  572. package/package.json +21 -16
  573. package/prompts/commands/atomic-commit.md +8 -6
  574. package/prompts/commands/brainstorm.md +5 -149
  575. package/prompts/commands/create-verification-skill.md +8 -48
  576. package/prompts/commands/discuss-phase.md +6 -10
  577. package/prompts/commands/execute-phase.md +18 -45
  578. package/prompts/commands/fix.md +16 -128
  579. package/prompts/commands/grill.md +6 -53
  580. package/prompts/commands/init-project.md +13 -18
  581. package/prompts/commands/map-codebase.md +3 -3
  582. package/prompts/commands/new-project.md +12 -17
  583. package/prompts/commands/next-milestone.md +4 -8
  584. package/prompts/commands/orchestrate-loop.md +12 -12
  585. package/prompts/commands/orchestrate.md +12 -11
  586. package/prompts/commands/pause-work.md +1 -1
  587. package/prompts/commands/plan-phase.md +15 -37
  588. package/prompts/commands/quick.md +11 -64
  589. package/prompts/commands/resolve-conflicts.md +2 -15
  590. package/prompts/commands/triage.md +3 -14
  591. package/prompts/commands/verify-work.md +15 -63
  592. package/prompts/commands/why.md +18 -118
  593. package/schemas/keybindings.schema.json +433 -0
  594. package/schemas/models.schema.json +1190 -0
  595. package/schemas/settings.schema.json +849 -0
  596. package/schemas/theme.schema.json +365 -0
  597. package/skills/atomic-reasoning/SKILL.md +6 -105
  598. package/skills/blast-radius/SKILL.md +1 -1
  599. package/skills/epistemics/SKILL.md +12 -87
  600. package/skills/explainers/SKILL.md +1 -1
  601. package/skills/typescript-discipline/SKILL.md +12 -42
  602. package/skills/typescript-discipline/references/patterns.md +25 -266
  603. package/skills/unslop/SKILL.md +14 -105
  604. package/dist/bundle/chunks/anthropic-messages-E2P6C3P7.js +0 -6
  605. package/dist/bundle/chunks/azure-openai-responses-JZMSTDIM.js +0 -2
  606. package/dist/bundle/chunks/chunk-2E5VODES.js +0 -2
  607. package/dist/bundle/chunks/chunk-3DQNSI5W.js +0 -137
  608. package/dist/bundle/chunks/chunk-4COXSQRQ.js +0 -18
  609. package/dist/bundle/chunks/chunk-D3HO453P.js +0 -42
  610. package/dist/bundle/chunks/chunk-GVXA72ZA.js +0 -2
  611. package/dist/bundle/chunks/chunk-I2SOJ4JN.js +0 -65
  612. package/dist/bundle/chunks/chunk-I5OKY6RH.js +0 -11
  613. package/dist/bundle/chunks/chunk-ILSPVHVH.js +0 -1623
  614. package/dist/bundle/chunks/chunk-KY2BG6BC.js +0 -11
  615. package/dist/bundle/chunks/chunk-PGJAHC3R.js +0 -107
  616. package/dist/bundle/chunks/chunk-QVFELZW2.js +0 -312
  617. package/dist/bundle/chunks/chunk-QVTLBSTH.js +0 -4
  618. package/dist/bundle/chunks/chunk-SDRCE6OP.js +0 -2
  619. package/dist/bundle/chunks/chunk-U6LDZZGM.js +0 -146
  620. package/dist/bundle/chunks/chunk-X3YFUSCK.js +0 -82
  621. package/dist/bundle/chunks/chunk-XBUEMKIY.js +0 -2
  622. package/dist/bundle/chunks/chunk-XHCO4PPH.js +0 -8
  623. package/dist/bundle/chunks/chunk-YH7HNI7D.js +0 -2
  624. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +0 -2
  625. package/dist/bundle/chunks/execute-AGEWJLIO.js +0 -18
  626. package/dist/bundle/chunks/google-generative-ai-HPNDIAZD.js +0 -2
  627. package/dist/bundle/chunks/google-vertex-KPAWJ4SP.js +0 -2
  628. package/dist/bundle/chunks/mistral-conversations-FMSPWQ7A.js +0 -5
  629. package/dist/bundle/chunks/node-4JNG6XQO.js +0 -16
  630. package/dist/bundle/chunks/openai-codex-responses-TU7NGPXE.js +0 -10
  631. package/dist/bundle/chunks/openai-completions-GANCQQO5.js +0 -7
  632. package/dist/bundle/chunks/openai-responses-ASDPAX3E.js +0 -3
  633. package/dist/bundle/chunks/openrouter-images-NROSQXMZ.js +0 -2
  634. package/dist/bundle/chunks/pi-messages-2QEJYOAO.js +0 -8
  635. package/dist/bundle/chunks/runtime-2B56SZM6.js +0 -2
  636. package/dist/bundle/chunks/runtime-TJ3EAMJK.js +0 -3
  637. package/dist/bundle/chunks/settings-manager-HC5RR36T.js +0 -2
  638. package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +0 -2
  639. package/dist/bundle/chunks/virtual-modules-XKLDADFR.js +0 -2
  640. package/dist/core/provider-attribution.d.ts +0 -4
  641. package/dist/core/provider-attribution.d.ts.map +0 -1
  642. package/dist/core/provider-attribution.js +0 -72
  643. package/dist/core/provider-attribution.js.map +0 -1
  644. package/dist/experimental/micro/api.d.ts +0 -81
  645. package/dist/experimental/micro/api.d.ts.map +0 -1
  646. package/dist/experimental/micro/api.js +0 -2
  647. package/dist/experimental/micro/api.js.map +0 -1
  648. package/dist/experimental/micro/main.d.ts +0 -3
  649. package/dist/experimental/micro/main.d.ts.map +0 -1
  650. package/dist/experimental/micro/main.js +0 -21
  651. package/dist/experimental/micro/main.js.map +0 -1
  652. package/dist/experimental/micro/models.d.ts +0 -11
  653. package/dist/experimental/micro/models.d.ts.map +0 -1
  654. package/dist/experimental/micro/models.js +0 -95
  655. package/dist/experimental/micro/models.js.map +0 -1
  656. package/dist/experimental/micro/runtime.d.ts +0 -12
  657. package/dist/experimental/micro/runtime.d.ts.map +0 -1
  658. package/dist/experimental/micro/runtime.js +0 -465
  659. package/dist/experimental/micro/runtime.js.map +0 -1
  660. package/dist/experimental/micro/sessions.d.ts +0 -10
  661. package/dist/experimental/micro/sessions.d.ts.map +0 -1
  662. package/dist/experimental/micro/sessions.js +0 -41
  663. package/dist/experimental/micro/sessions.js.map +0 -1
  664. package/dist/experimental/micro/tools.d.ts +0 -10
  665. package/dist/experimental/micro/tools.d.ts.map +0 -1
  666. package/dist/experimental/micro/tools.js +0 -96
  667. package/dist/experimental/micro/tools.js.map +0 -1
  668. package/dist/experimental/micro/tui.d.ts +0 -3
  669. package/dist/experimental/micro/tui.d.ts.map +0 -1
  670. package/dist/experimental/micro/tui.js +0 -510
  671. package/dist/experimental/micro/tui.js.map +0 -1
  672. package/dist/experimental/mini/main.d.ts +0 -7
  673. package/dist/experimental/mini/main.d.ts.map +0 -1
  674. package/dist/experimental/mini/main.js +0 -21
  675. package/dist/experimental/mini/main.js.map +0 -1
  676. package/dist/experimental/mini/server/entry.d.ts +0 -3
  677. package/dist/experimental/mini/server/entry.d.ts.map +0 -1
  678. package/dist/experimental/mini/server/entry.js +0 -11
  679. package/dist/experimental/mini/server/entry.js.map +0 -1
  680. package/dist/experimental/mini/server/run.d.ts +0 -13
  681. package/dist/experimental/mini/server/run.d.ts.map +0 -1
  682. package/dist/experimental/mini/server/run.js +0 -150
  683. package/dist/experimental/mini/server/run.js.map +0 -1
  684. package/dist/experimental/mini/shared/protocol.d.ts +0 -127
  685. package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
  686. package/dist/experimental/mini/shared/protocol.js +0 -13
  687. package/dist/experimental/mini/shared/protocol.js.map +0 -1
  688. package/dist/experimental/mini/shared/rpc.d.ts +0 -49
  689. package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
  690. package/dist/experimental/mini/shared/rpc.js +0 -171
  691. package/dist/experimental/mini/shared/rpc.js.map +0 -1
  692. package/dist/experimental/mini/shared/transport.d.ts +0 -35
  693. package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
  694. package/dist/experimental/mini/shared/transport.js +0 -94
  695. package/dist/experimental/mini/shared/transport.js.map +0 -1
  696. package/dist/experimental/mini/tui/run.d.ts +0 -9
  697. package/dist/experimental/mini/tui/run.d.ts.map +0 -1
  698. package/dist/experimental/mini/tui/run.js +0 -62
  699. package/dist/experimental/mini/tui/run.js.map +0 -1
  700. package/dist/experimental/mini/tui/session.d.ts +0 -26
  701. package/dist/experimental/mini/tui/session.d.ts.map +0 -1
  702. package/dist/experimental/mini/tui/session.js +0 -94
  703. package/dist/experimental/mini/tui/session.js.map +0 -1
  704. package/dist/experimental/mini/tui/view.d.ts +0 -10
  705. package/dist/experimental/mini/tui/view.d.ts.map +0 -1
  706. package/dist/experimental/mini/tui/view.js +0 -461
  707. package/dist/experimental/mini/tui/view.js.map +0 -1
  708. package/dist/experimental/mini/worker/entry.d.ts +0 -3
  709. package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
  710. package/dist/experimental/mini/worker/entry.js +0 -10
  711. package/dist/experimental/mini/worker/entry.js.map +0 -1
  712. package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
  713. package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
  714. package/dist/experimental/mini/worker/lane-service.js +0 -97
  715. package/dist/experimental/mini/worker/lane-service.js.map +0 -1
  716. package/dist/experimental/mini/worker/models-service.d.ts +0 -19
  717. package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
  718. package/dist/experimental/mini/worker/models-service.js +0 -136
  719. package/dist/experimental/mini/worker/models-service.js.map +0 -1
  720. package/dist/experimental/mini/worker/run.d.ts +0 -14
  721. package/dist/experimental/mini/worker/run.d.ts.map +0 -1
  722. package/dist/experimental/mini/worker/run.js +0 -88
  723. package/dist/experimental/mini/worker/run.js.map +0 -1
  724. package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
  725. package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
  726. package/dist/modes/interactive/theme/theme-json.js +0 -132
  727. package/dist/modes/interactive/theme/theme-json.js.map +0 -1
  728. package/dist/modes/interactive/theme/theme-schema.json +0 -361
  729. /package/dist/bundle/chunks/{chunk-FBU742QF.js → chunk-MOOADNVS.js} +0 -0
@@ -11,7 +11,7 @@ import * as TuiLayouts from "@draht/tui";
11
11
  import { CombinedAutocompleteProvider, Container, fuzzyFilter, getCapabilities, hyperlink, Markdown, matchesKey, Spacer, setCapabilityOverrides, setKeybindings, Text, TruncatedText, TuiAltScreen, TuiMainScreen, visibleWidth, } from "@draht/tui";
12
12
  import chalk from "chalk";
13
13
  import { spawn } from "child_process";
14
- import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, DISPLAY_VERSION, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, VERSION, } from "../../config.js";
14
+ import { APP_NAME, APP_TITLE, CONFIG_DIR_NAME, DISPLAY_VERSION, detectInstallChange, getAgentDir, getAuthPath, getDebugLogPath, getDocsPath, VERSION, } from "../../config.js";
15
15
  import { parseSkillBlock } from "../../core/agent-session.js";
16
16
  import { SessionImportFileNotFoundError } from "../../core/agent-session-runtime.js";
17
17
  import { CACHE_TTL_MS, collectCacheMisses, computeCacheWaste, detectCacheMiss, } from "../../core/cache-stats.js";
@@ -28,6 +28,7 @@ import { createCompactionSummaryMessage, createCustomMessage } from "../../core/
28
28
  import { defaultModelPerProvider, findExactModelReferenceMatch, resolveModelScopeFromModels, } from "../../core/model-resolver.js";
29
29
  import { CredentialSynchronizationError } from "../../core/model-runtime.js";
30
30
  import { DefaultPackageManager } from "../../core/package-manager.js";
31
+ import { RADIUS_MCP_URL, RADIUS_PROVIDER_ID } from "../../core/radius.js";
31
32
  import { formatMissingSessionCwdPrompt, MissingSessionCwdError } from "../../core/session-cwd.js";
32
33
  import { SessionManager, sessionEntryToContextMessages, } from "../../core/session-manager.js";
33
34
  import { BUILTIN_SLASH_COMMANDS } from "../../core/slash-commands.js";
@@ -35,10 +36,12 @@ import { boundedSafeText } from "../../core/socket-server/safe-text.js";
35
36
  import { withBuiltInRenderers } from "../../core/tools/renderers/index.js";
36
37
  import { hasTrustRequiringProjectResources, ProjectTrustStore } from "../../core/trust-manager.js";
37
38
  import { getUsageCostBreakdown } from "../../core/usage-totals.js";
39
+ import { addMcpServerConfig, loadMcpConfig } from "../../extensions/mcp/config.js";
38
40
  import { getChangelogPath, getNewEntries, normalizeChangelogLinks, parseChangelog } from "../../utils/changelog.js";
39
41
  import { copyToClipboard, readClipboardFilePaths, readClipboardText } from "../../utils/clipboard.js";
40
42
  import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
41
43
  import { parseGitUrl } from "../../utils/git.js";
44
+ import { ensurePngTranscoder } from "../../utils/image-convert.js";
42
45
  import { sendTerminalNotification } from "../../utils/notify.js";
43
46
  import { getCwdRelativePath } from "../../utils/paths.js";
44
47
  import { killTrackedDetachedChildren } from "../../utils/shell.js";
@@ -66,7 +69,8 @@ import { formatKeyText, keyDisplayText, keyHint, keyText, rawKeyHint } from "./c
66
69
  import { LoginDialogComponent } from "./components/login-dialog.js";
67
70
  import { createMermaidMarkdownTransformer } from "./components/mermaid.js";
68
71
  import { ModelSelectorComponent } from "./components/model-selector.js";
69
- import { formatAuthSelectorProviderType, OAuthSelectorComponent, } from "./components/oauth-selector.js";
72
+ import { formatAuthSelectorProviderStatus, formatAuthSelectorProviderType, OAuthSelectorComponent, } from "./components/oauth-selector.js";
73
+ import { createLoginMenuSelector } from "./components/radius-login-selector.js";
70
74
  import { ScopedModelsSelectorComponent } from "./components/scoped-models-selector.js";
71
75
  import { SessionSelectorComponent } from "./components/session-selector.js";
72
76
  import { SettingsSelectorComponent } from "./components/settings-selector.js";
@@ -82,12 +86,13 @@ import { UserMessageSelectorComponent } from "./components/user-message-selector
82
86
  import { editInExternalEditor } from "./external-editor.js";
83
87
  import { refreshModelCatalogs } from "./model-catalog-refresh.js";
84
88
  import { getModelSearchText } from "./model-search.js";
89
+ import { ProgramStatusReporter } from "./program-status-reporter.js";
85
90
  import { shareSession } from "./session-share.js";
86
91
  import { getAvailableThemes, getAvailableThemesWithPaths, getEditorTheme, getMarkdownTheme, getThemeByName, onThemeChange, SYSTEM_THEME_NAME, setRegisteredThemes, stopThemeWatcher, Theme, theme, } from "./theme/theme.js";
87
92
  import { InteractiveThemeController } from "./theme/theme-controller.js";
88
93
  import { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
89
94
  export { createInteractiveTui, createInteractiveTuiReference } from "./tui-renderer.js";
90
- function isWorkingStatusEditor(editor) {
95
+ function isEmbeddedStatus(editor) {
91
96
  return ("embedWorkingStatus" in editor &&
92
97
  editor.embedWorkingStatus === true &&
93
98
  "setWorkingStatusIndicator" in editor &&
@@ -117,7 +122,9 @@ function isCompactionCostNotice(item) {
117
122
  function isUsageSessionEntry(item) {
118
123
  return "type" in item && item.type === "usage";
119
124
  }
120
- const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN"]);
125
+ // EIO: tty reads/ioctls from an orphaned background process group, or writes after hangup.
126
+ // ENOTTY: the tty was revoked (macOS) and stdin is no longer a terminal.
127
+ const DEAD_TERMINAL_ERROR_CODES = new Set(["EIO", "EPIPE", "ENOTCONN", "ENOTTY"]);
121
128
  function isDeadTerminalError(error) {
122
129
  if (!error || typeof error !== "object" || !("code" in error)) {
123
130
  return false;
@@ -177,6 +184,7 @@ function llamaCppPostLoginGuidance(actionLabel, loadedModelCount) {
177
184
  ? `${actionLabel}. No llama.cpp models are loaded. Use /llama to load a model, then /model to select it.`
178
185
  : `${actionLabel}. Use /model to select a loaded llama.cpp model, or /llama to manage models.`;
179
186
  }
187
+ const RADIUS_LOGIN_INTRO = "Radius is an AI gateway by Earendil Works.";
180
188
  const AUTH_TYPE_ORDER = { oauth: 0, api_key: 1 };
181
189
  function createFuzzyAutocompleteItems(items, prefix, getSearchText, toAutocompleteItem) {
182
190
  const filtered = fuzzyFilter(items, prefix, getSearchText);
@@ -199,18 +207,21 @@ function getLoginProviderCompletionOptions(providerOptions) {
199
207
  id: provider.id,
200
208
  name: provider.name,
201
209
  authTypes: [provider.authType],
210
+ subscription: provider.subscription,
202
211
  });
203
212
  }
204
213
  return Array.from(byId.values()).sort((a, b) => a.name.localeCompare(b.name));
205
214
  }
206
215
  function getLoginProviderSearchText(provider) {
207
216
  const authTypes = provider.authTypes
208
- .map((authType) => `${authType} ${formatAuthSelectorProviderType(authType)}`)
217
+ .map((authType) => `${authType} ${formatAuthSelectorProviderType(authType, provider.subscription)}`)
209
218
  .join(" ");
210
219
  return `${provider.id} ${provider.name} ${authTypes}`;
211
220
  }
212
221
  function formatLoginProviderCompletionDescription(provider) {
213
- const authTypes = provider.authTypes.map(formatAuthSelectorProviderType).join("/");
222
+ const authTypes = provider.authTypes
223
+ .map((authType) => formatAuthSelectorProviderType(authType, provider.subscription))
224
+ .join("/");
214
225
  return provider.name === provider.id ? authTypes : `${provider.name} · ${authTypes}`;
215
226
  }
216
227
  export class InteractiveMode {
@@ -300,26 +311,23 @@ export class InteractiveMode {
300
311
  compactionQueuedMessages = [];
301
312
  // Shutdown state
302
313
  shutdownRequested = false;
314
+ /** Reports working, blocked, done, and error states to terminals that support OSC 7501. */
315
+ programStatus = new ProgramStatusReporter(() => this.ui.terminal, () => this.sessionManager.getSessionName());
303
316
  /** The `/bug` hint is shown at most once per session so error output stays readable. */
304
317
  bugReportHintShown = false;
318
+ installChangeWarningShown = false;
305
319
  // Extension UI state
306
- extensionSelector = undefined;
307
320
  /**
308
- * Settles the promise of the dialog currently occupying {@link extensionSelector}.
321
+ * Extension dialogs in the editor slot (select, confirm, input, editor, inline custom). The last one is visible.
309
322
  *
310
- * The slot holds at most one dialog, so opening a second one used to overwrite the first without
311
- * settling it — stranding a promise that `beforeToolCall` is awaiting, which wedges the agent
312
- * loop forever. Keeping the settle function beside the component makes the slot non-clobbering.
323
+ * A new dialog stacks on top of the visible one instead of replacing it, and closing it shows the previous one
324
+ * again, so dialogs opened from inside another dialog work. Every entry carries its fail-closed answer:
325
+ * {@link closeAllExtensionDialogs} (session invalidate, `/reload`) settles each one, so no promise
326
+ * `beforeToolCall` awaits is ever stranded and an unanswered permission ask is a denial.
313
327
  */
314
- extensionSelectorSettle = undefined;
328
+ extensionDialogs = [];
315
329
  /** Label of the surface that decided the open ask elsewhere, pending a one-line notice. */
316
330
  extensionDialogDecidedBy = undefined;
317
- extensionInput = undefined;
318
- /** Settles the promise `showExtensionInput` returned. See {@link hideExtensionInput}. */
319
- extensionInputSettle = undefined;
320
- extensionEditor = undefined;
321
- /** Settles the promise `showExtensionEditor` returned. See {@link hideExtensionEditor}. */
322
- extensionEditorSettle = undefined;
323
331
  extensionTerminalInputSubscriptions = new Set();
324
332
  // Extension widgets (components rendered above/below the editor)
325
333
  extensionWidgetsAbove = new Map();
@@ -655,7 +663,7 @@ export class InteractiveMode {
655
663
  this.registerSignalHandlers();
656
664
  // Load changelog (only show new entries, skip for resumed sessions)
657
665
  this.changelogMarkdown = this.getChangelogForDisplay();
658
- if (this.session.scopedModels.length > 0 && (this.options.verbose || !this.settingsManager.getQuietStartup())) {
666
+ if (this.session.scopedModels.length > 0 && this.shouldShowStartupDetails()) {
659
667
  const modelList = this.session.scopedModels
660
668
  .map((sm) => {
661
669
  const thinkingStr = sm.thinkingLevel ? `:${sm.thinkingLevel}` : "";
@@ -701,12 +709,15 @@ export class InteractiveMode {
701
709
  // Start the UI before initializing extensions so session_start handlers can use interactive dialogs
702
710
  this.ui.start();
703
711
  this.isInitialized = true;
712
+ this.programStatus.report();
713
+ this.ensurePngTranscoder();
704
714
  this.themeController.applyFromSettings();
705
715
  // The header and startup notices bake theme colors into their text, so build them once the terminal
706
716
  // reported its colors. This ends at the terminal's DA1 reply, or after 100 ms if it answers nothing.
707
717
  await this.themeController.waitForTerminalColors();
708
718
  // Add header with keybindings from config (unless silenced)
709
- if (this.options.verbose || !this.settingsManager.getQuietStartup()) {
719
+ if (this.shouldShowStartupHeader()) {
720
+ const showDetails = this.shouldShowStartupDetails();
710
721
  // Built on demand so the header follows theme changes.
711
722
  const logo = () => {
712
723
  const asciiArt = [
@@ -757,7 +768,7 @@ export class InteractiveMode {
757
768
  rawKeyHint("!", "bash"),
758
769
  hint("app.tools.expand", "more"),
759
770
  ].join(theme.fg("muted", " · "));
760
- const compactOnboarding = () => theme.fg("dim", `Press ${keyText("app.tools.expand")} to show full startup help and loaded resources.`);
771
+ const compactOnboarding = () => theme.fg("dim", `Press ${keyText("app.tools.expand")} to show full startup help${showDetails ? " and loaded resources" : ""}.`);
761
772
  const onboarding = () => theme.fg("dim", `${APP_NAME} can explain its own features and look up its docs. Ask it how to use or extend ${APP_NAME}.`);
762
773
  this.builtInHeader = new ExpandableText(() => `${withLogo(compactInstructions())}\n${compactOnboarding()}\n\n${onboarding()}`, () => `${withLogo(expandedInstructions())}\n\n${onboarding()}`, this.getStartupExpansionState(), 1, 0);
763
774
  // Setup UI layout
@@ -1040,6 +1051,14 @@ export class InteractiveMode {
1040
1051
  getStartupExpansionState() {
1041
1052
  return this.options.verbose || this.toolOutputExpanded;
1042
1053
  }
1054
+ /** Startup header (logo, version, key hints). Hidden only by quietStartup: true. */
1055
+ shouldShowStartupHeader() {
1056
+ return this.options.verbose === true || this.settingsManager.getQuietStartup() !== true;
1057
+ }
1058
+ /** Startup details (model scope, loaded resources). Hidden by quietStartup: true or "header". */
1059
+ shouldShowStartupDetails() {
1060
+ return this.options.verbose === true || this.settingsManager.getQuietStartup() === false;
1061
+ }
1043
1062
  /**
1044
1063
  * Get a short path relative to the package root for display.
1045
1064
  */
@@ -1301,7 +1320,7 @@ export class InteractiveMode {
1301
1320
  showLoadedResources(options) {
1302
1321
  // Resource rendering is idempotent; chat clears no longer clear this separate container.
1303
1322
  this.loadedResourcesContainer.clear();
1304
- const showListing = options?.force || this.options.verbose || !this.settingsManager.getQuietStartup();
1323
+ const showListing = options?.force || this.shouldShowStartupDetails();
1305
1324
  const showDiagnostics = showListing || options?.showDiagnosticsWhenQuiet === true;
1306
1325
  if (!showListing && !showDiagnostics) {
1307
1326
  return;
@@ -1523,8 +1542,16 @@ export class InteractiveMode {
1523
1542
  applyFullscreenScrollbarSetting() {
1524
1543
  this.transcriptScrollView?.setScrollbar(this.settingsManager.getFullscreenScrollbar());
1525
1544
  }
1545
+ /** Lets extension images use the PNG transcoder; tool results register it themselves. */
1546
+ ensurePngTranscoder() {
1547
+ ensurePngTranscoder(() => {
1548
+ this.ui.invalidate();
1549
+ this.ui.requestRender();
1550
+ });
1551
+ }
1526
1552
  applyRuntimeSettings() {
1527
1553
  setCapabilityOverrides(this.settingsManager.getTerminalCapabilityOverrides());
1554
+ this.ensurePngTranscoder();
1528
1555
  configureHttpDispatcher(this.settingsManager.getHttpIdleTimeoutMs());
1529
1556
  this.applyFullscreenScrollbarSetting();
1530
1557
  if (this.renderer instanceof TuiAltScreen) {
@@ -1555,6 +1582,7 @@ export class InteractiveMode {
1555
1582
  const session = this.session;
1556
1583
  this.unsubscribe?.();
1557
1584
  this.unsubscribe = undefined;
1585
+ this.programStatus.reset();
1558
1586
  this.applyRuntimeSettings();
1559
1587
  if (options.renderBeforeBind) {
1560
1588
  this.renderCurrentSessionState();
@@ -1626,8 +1654,32 @@ export class InteractiveMode {
1626
1654
  return;
1627
1655
  if (/\b(?:abort(?:ed)?|cancel(?:l?ed)?)\b/i.test(message.errorMessage ?? ""))
1628
1656
  return;
1657
+ if (this.maybeShowInstallChangeWarning())
1658
+ return;
1629
1659
  this.suggestBugReport();
1630
1660
  }
1661
+ /**
1662
+ * After an error, check whether an update replaced or removed this install while the session ran.
1663
+ * Code loaded on demand then fails with missing modules until restart (badlogic/pi-mono#10439). Returns true when
1664
+ * the install changed.
1665
+ */
1666
+ maybeShowInstallChangeWarning() {
1667
+ if (this.installChangeWarningShown)
1668
+ return true;
1669
+ const change = detectInstallChange();
1670
+ if (!change)
1671
+ return false;
1672
+ this.installChangeWarningShown = true;
1673
+ const cause = change.kind === "updated"
1674
+ ? `${APP_NAME} was updated to ${change.version} while this session was running (${VERSION})`
1675
+ : `The ${APP_NAME} installation this session runs from was removed or replaced`;
1676
+ const resumeCommand = formatResumeCommand(this.sessionManager);
1677
+ const restart = resumeCommand
1678
+ ? `Restart with \`${resumeCommand}\` to continue this session.`
1679
+ : `Restart ${APP_NAME}.`;
1680
+ this.showWarning(`${cause}. Features that load code on demand can fail until restart. ${restart}`);
1681
+ return true;
1682
+ }
1631
1683
  renderCurrentSessionState() {
1632
1684
  this.loadedResourcesContainer.clear();
1633
1685
  this.chatContainer.clear();
@@ -1646,7 +1698,7 @@ export class InteractiveMode {
1646
1698
  * whatever this returns, so they never reach into the tool registry themselves.
1647
1699
  */
1648
1700
  getRegisteredToolDefinition(toolName) {
1649
- return withBuiltInRenderers(toolName, this.session.getToolDefinition(toolName));
1701
+ return this.session.extensionRunner.resolveToolRenderers(toolName, () => withBuiltInRenderers(toolName, this.session.getToolDefinition(toolName)));
1650
1702
  }
1651
1703
  getMarkdownTransformers() {
1652
1704
  return [this.mermaidMarkdownTransformer, ...this.session.extensionRunner.getMarkdownTransformers()];
@@ -1718,7 +1770,7 @@ export class InteractiveMode {
1718
1770
  }
1719
1771
  setEditorWorkingStatusIndicator(indicator) {
1720
1772
  this.defaultEditor.setWorkingStatusIndicator(undefined);
1721
- if (!isWorkingStatusEditor(this.editor))
1773
+ if (!isEmbeddedStatus(this.editor))
1722
1774
  return false;
1723
1775
  this.editor.setWorkingStatusIndicator(indicator);
1724
1776
  return true;
@@ -1754,7 +1806,7 @@ export class InteractiveMode {
1754
1806
  }
1755
1807
  }
1756
1808
  showWorkingStatusIndicator() {
1757
- const colorFn = isWorkingStatusEditor(this.editor)
1809
+ const colorFn = isEmbeddedStatus(this.editor)
1758
1810
  ? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
1759
1811
  : undefined;
1760
1812
  this.showStatusIndicator(new WorkingStatusIndicator(this.ui, this.workingMessage ?? this.defaultWorkingMessage, this.workingIndicatorOptions, colorFn));
@@ -1839,15 +1891,7 @@ export class InteractiveMode {
1839
1891
  this.renderWidgets();
1840
1892
  }
1841
1893
  resetExtensionUI() {
1842
- if (this.extensionSelector) {
1843
- this.hideExtensionSelector();
1844
- }
1845
- if (this.extensionInput) {
1846
- this.hideExtensionInput();
1847
- }
1848
- if (this.extensionEditor) {
1849
- this.hideExtensionEditor();
1850
- }
1894
+ this.closeAllExtensionDialogs();
1851
1895
  this.ui.hideOverlay();
1852
1896
  this.clearExtensionTerminalInputListeners();
1853
1897
  this.setExtensionFooter(undefined);
@@ -2046,72 +2090,96 @@ export class InteractiveMode {
2046
2090
  setToolsExpanded: (expanded) => this.setToolsExpanded(expanded),
2047
2091
  };
2048
2092
  }
2093
+ /** Show an extension dialog on top of the stack. */
2094
+ pushExtensionDialog(dialog) {
2095
+ this.disposeActiveSelector();
2096
+ this.extensionDialogs.push(dialog);
2097
+ this.showTopExtensionDialog();
2098
+ }
2099
+ /**
2100
+ * Remove a dialog WITHOUT settling it; its owner settles it. If it was visible, the previous dialog or the
2101
+ * editor takes the slot. A hidden dialog leaving (say, its signal aborted) never disturbs the visible one.
2102
+ */
2103
+ removeExtensionDialog(component) {
2104
+ const index = this.extensionDialogs.findIndex((dialog) => dialog.component === component);
2105
+ if (index === -1)
2106
+ return;
2107
+ this.extensionDialogs.splice(index, 1);
2108
+ if (index === this.extensionDialogs.length)
2109
+ this.showTopExtensionDialog();
2110
+ }
2111
+ showTopExtensionDialog() {
2112
+ const top = this.extensionDialogs.at(-1);
2113
+ const component = top?.component ?? this.editor;
2114
+ this.editorContainer.clear();
2115
+ this.editorContainer.addChild(component);
2116
+ this.ui.setFocus(component);
2117
+ // A custom component reports no status of its own; one stacked over a pending ask must not hide it.
2118
+ const blocked = this.extensionDialogs.findLast((dialog) => dialog.blocked !== undefined)?.blocked;
2119
+ this.programStatus.setBlocked("extension-dialog", blocked);
2120
+ this.ui.requestRender();
2121
+ }
2122
+ /**
2123
+ * Tear down every extension dialog, answering each one fail-closed.
2124
+ *
2125
+ * `resetExtensionUI` (reached from `setBeforeSessionInvalidate` and `/reload`) used to drop dialogs
2126
+ * without settling them, which stranded the promise `beforeToolCall` awaits and wedged the agent loop: no
2127
+ * dialog on screen, no tool call, no way out. Hidden dialogs further down the stack need the same treatment.
2128
+ */
2129
+ closeAllExtensionDialogs() {
2130
+ const dialogs = this.extensionDialogs;
2131
+ if (dialogs.length === 0)
2132
+ return;
2133
+ this.extensionDialogs = [];
2134
+ this.showTopExtensionDialog();
2135
+ // Last, so no continuation can observe a half-torn-down slot. Newest first, the order they were stacked.
2136
+ for (const dialog of dialogs.reverse())
2137
+ dialog.failClosed();
2138
+ }
2049
2139
  /**
2050
2140
  * Show a selector for extensions.
2051
2141
  */
2052
- showExtensionSelector(title, options, opts, detailRows) {
2142
+ showExtensionSelector(title, options, opts, detailRows, blocked = { kind: "question", message: title }) {
2053
2143
  return new Promise((resolve) => {
2054
2144
  if (opts?.signal?.aborted) {
2055
2145
  resolve(undefined);
2056
2146
  return;
2057
2147
  }
2058
2148
  let settled = false;
2059
- const settle = (value) => {
2149
+ const finish = (value) => {
2060
2150
  if (settled)
2061
2151
  return;
2062
2152
  settled = true;
2063
2153
  opts?.signal?.removeEventListener("abort", onAbort);
2064
- if (this.extensionSelectorSettle === settle)
2065
- this.extensionSelectorSettle = undefined;
2066
2154
  // A deciding-surface label that nothing flushed belongs to THIS ask and dies with it.
2067
2155
  // Left standing it is sticky: the next, unrelated dialog's teardown would emit
2068
2156
  // "Permission resolved by <whoever>" about an ask that surface never saw.
2069
2157
  this.extensionDialogDecidedBy = undefined;
2158
+ selector.dispose();
2159
+ this.removeExtensionDialog(selector);
2160
+ // Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
2070
2161
  resolve(value);
2071
2162
  };
2072
2163
  const onAbort = () => {
2073
- // A dialog that was already displaced by a newer one must not tear the newer one down.
2074
- if (!settled) {
2075
- // Flush BEFORE settling: `settle` drops the pending label, and `hideExtensionSelector`
2076
- // now settles this dialog fail-closed on its way out.
2164
+ // Flush BEFORE finishing: `finish` drops the pending label.
2165
+ if (!settled)
2077
2166
  this.flushExtensionDialogDecidedNotice();
2078
- this.hideExtensionSelector();
2079
- }
2080
- settle(undefined);
2167
+ finish(undefined);
2081
2168
  };
2082
2169
  opts?.signal?.addEventListener("abort", onAbort, { once: true });
2083
- // Non-clobbering slot. Whatever is already in it is disposed and its promise settled as
2084
- // cancelled BEFORE the replacement takes over; the previous code overwrote the field and
2085
- // left the earlier caller awaiting a promise nothing could ever resolve.
2086
- const displaced = this.extensionSelectorSettle;
2087
- this.extensionSelector?.dispose();
2088
- this.extensionSelector = undefined;
2089
- this.extensionSelectorSettle = undefined;
2090
- this.extensionSelector = new ExtensionSelectorComponent(title, options,
2091
- // Settle BEFORE hiding: `hideExtensionSelector` settles whatever is still in the slot
2092
- // fail-closed, so hiding first would resolve the ask as `undefined` (a denial) and the
2093
- // human's actual choice would be swallowed by the `settled` guard.
2094
- (option) => {
2095
- settle(option);
2096
- this.hideExtensionSelector();
2097
- }, () => {
2098
- settle(undefined);
2099
- this.hideExtensionSelector();
2100
- }, {
2170
+ const selector = new ExtensionSelectorComponent(title, options, (option) => finish(option), () => finish(undefined), {
2101
2171
  tui: this.ui,
2102
2172
  timeout: opts?.timeout,
2103
2173
  detailRows,
2104
2174
  onToggleToolsExpanded: () => this.toggleToolOutputExpansion(),
2105
2175
  });
2106
- this.extensionSelectorSettle = settle;
2107
- this.disposeActiveSelector();
2108
- this.editorContainer.clear();
2109
- this.editorContainer.addChild(this.extensionSelector);
2110
- this.ui.setFocus(this.extensionSelector);
2111
- this.ui.requestRender();
2112
- // Settle the displaced caller only once the replacement is installed, so its continuation
2113
- // cannot observe an empty dialog slot.
2114
- displaced?.(undefined);
2176
+ // `undefined` is the fail-closed answer: `showExtensionConfirm` maps it to `false`, i.e. denial.
2177
+ this.pushExtensionDialog({
2178
+ component: selector,
2179
+ kind: "selector",
2180
+ blocked,
2181
+ failClosed: () => finish(undefined),
2182
+ });
2115
2183
  });
2116
2184
  }
2117
2185
  /**
@@ -2124,7 +2192,7 @@ export class InteractiveMode {
2124
2192
  noteExtensionDialogResolvedElsewhere(label) {
2125
2193
  this.extensionDialogDecidedBy = label;
2126
2194
  // Nothing is open to abort, so no teardown will flush the notice — emit it now.
2127
- if (!this.extensionSelector)
2195
+ if (!this.extensionDialogs.some((dialog) => dialog.kind === "selector"))
2128
2196
  this.flushExtensionDialogDecidedNotice();
2129
2197
  }
2130
2198
  /** Emit the pending deciding-surface notice at most once, then forget it. */
@@ -2135,32 +2203,6 @@ export class InteractiveMode {
2135
2203
  this.extensionDialogDecidedBy = undefined;
2136
2204
  this.showExtensionNotify(`Permission resolved by ${label}`, "info");
2137
2205
  }
2138
- /**
2139
- * Hide the extension selector, settling its promise FAIL-CLOSED if nothing else has.
2140
- *
2141
- * Every teardown path FOR THE SELECTOR funnels through here — {@link hideExtensionInput} and
2142
- * {@link hideExtensionEditor} are the matching, separate ones for the other two dialog types, and
2143
- * they need the same treatment for the same reason. This one used to drop the component on the
2144
- * floor without touching {@link extensionSelectorSettle} when `resetExtensionUI` (reached from
2145
- * `setBeforeSessionInvalidate` and from `/reload`) called it. A session invalidate while a permission ask
2146
- * was open therefore stranded the promise `beforeToolCall` awaits and wedged the agent loop
2147
- * forever: no dialog on screen, no tool call, no way out.
2148
- *
2149
- * `undefined` is the fail-closed answer — `showExtensionConfirm` maps it to `false`, i.e. denial.
2150
- * Callers that carry a real answer must `settle(...)` it BEFORE calling this.
2151
- */
2152
- hideExtensionSelector() {
2153
- const settle = this.extensionSelectorSettle;
2154
- this.extensionSelectorSettle = undefined;
2155
- this.extensionSelector?.dispose();
2156
- this.editorContainer.clear();
2157
- this.editorContainer.addChild(this.editor);
2158
- this.extensionSelector = undefined;
2159
- this.ui.setFocus(this.editor);
2160
- this.ui.requestRender();
2161
- // Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
2162
- settle?.(undefined);
2163
- }
2164
2206
  /**
2165
2207
  * Show a confirmation dialog for extensions.
2166
2208
  *
@@ -2196,14 +2238,20 @@ export class InteractiveMode {
2196
2238
  // it back into `${title}\n${message}` would hand the attacker-influenced command a way to
2197
2239
  // forge rows, and the human would be deciding about a string rather than about a call.
2198
2240
  const rows = this.buildPermissionDetailRows(detail);
2199
- const result = await this.showExtensionSelector(safeTitle, ["Yes", "No"], opts, rows);
2241
+ const result = await this.showExtensionSelector(safeTitle, ["Yes", "No"], opts, rows, {
2242
+ kind: "permission",
2243
+ message: safeTitle,
2244
+ });
2200
2245
  return result === "Yes";
2201
2246
  }
2202
2247
  // Two rows of the header budget are already spoken for: the single-row title above, and the
2203
2248
  // spacer `ExtensionSelectorComponent` draws between the header and the option list when there
2204
2249
  // are no detail rows. Both sit above `Yes`, so both have to come out of the same budget.
2205
2250
  const safeMessage = boundDialogText(message, columns, MAX_DETAIL_ROWS - 2);
2206
- const result = await this.showExtensionSelector(`${safeTitle}\n${safeMessage}`, ["Yes", "No"], opts);
2251
+ const result = await this.showExtensionSelector(`${safeTitle}\n${safeMessage}`, ["Yes", "No"], opts, undefined, {
2252
+ kind: "permission",
2253
+ message: safeTitle,
2254
+ });
2207
2255
  return result === "Yes";
2208
2256
  }
2209
2257
  /**
@@ -2255,127 +2303,48 @@ export class InteractiveMode {
2255
2303
  return;
2256
2304
  }
2257
2305
  let settled = false;
2258
- const settle = (value) => {
2306
+ const finish = (value) => {
2259
2307
  if (settled)
2260
2308
  return;
2261
2309
  settled = true;
2262
2310
  opts?.signal?.removeEventListener("abort", onAbort);
2263
- if (this.extensionInputSettle === settle)
2264
- this.extensionInputSettle = undefined;
2311
+ input.dispose();
2312
+ this.removeExtensionDialog(input);
2265
2313
  resolve(value);
2266
2314
  };
2267
- const onAbort = () => {
2268
- // A dialog already displaced by a newer one must not tear the newer one down.
2269
- if (!settled)
2270
- this.hideExtensionInput();
2271
- settle(undefined);
2272
- };
2315
+ const onAbort = () => finish(undefined);
2273
2316
  opts?.signal?.addEventListener("abort", onAbort, { once: true });
2274
- const displaced = this.extensionInputSettle;
2275
- this.extensionInput?.dispose();
2276
- this.extensionInput = undefined;
2277
- this.extensionInputSettle = undefined;
2278
- this.extensionInput = new ExtensionInputComponent(title, placeholder,
2279
- // Settle BEFORE hiding, for the same reason the selector does: `hideExtensionInput`
2280
- // settles whatever is still in the slot fail-closed, so hiding first would resolve the
2281
- // ask as `undefined` and the human's actual answer would hit the `settled` guard.
2282
- (value) => {
2283
- settle(value);
2284
- this.hideExtensionInput();
2285
- }, () => {
2286
- settle(undefined);
2287
- this.hideExtensionInput();
2288
- }, { tui: this.ui, timeout: opts?.timeout });
2289
- this.extensionInputSettle = settle;
2290
- this.disposeActiveSelector();
2291
- this.editorContainer.clear();
2292
- this.editorContainer.addChild(this.extensionInput);
2293
- this.ui.setFocus(this.extensionInput);
2294
- this.ui.requestRender();
2295
- // Only once the replacement is installed, so the displaced caller's continuation cannot
2296
- // observe an empty dialog slot.
2297
- displaced?.(undefined);
2317
+ const input = new ExtensionInputComponent(title, placeholder, (value) => finish(value), () => finish(undefined), { tui: this.ui, timeout: opts?.timeout });
2318
+ this.pushExtensionDialog({
2319
+ component: input,
2320
+ kind: "input",
2321
+ blocked: { kind: "question", message: title },
2322
+ failClosed: () => finish(undefined),
2323
+ });
2298
2324
  });
2299
2325
  }
2300
- /**
2301
- * Hide the extension input, settling its promise FAIL-CLOSED if nothing else has.
2302
- *
2303
- * Same defect the selector had: this used to dispose and re-focus without touching the `resolve`
2304
- * captured in {@link showExtensionInput}'s closure, so `resetExtensionUI` — a session invalidate
2305
- * or `/reload` — left the extension awaiting `ui.input(...)` hanging forever.
2306
- *
2307
- * Callers that carry a real answer must `settle(...)` it BEFORE calling this.
2308
- */
2309
- hideExtensionInput() {
2310
- const settle = this.extensionInputSettle;
2311
- this.extensionInputSettle = undefined;
2312
- this.extensionInput?.dispose();
2313
- this.editorContainer.clear();
2314
- this.editorContainer.addChild(this.editor);
2315
- this.extensionInput = undefined;
2316
- this.ui.setFocus(this.editor);
2317
- this.ui.requestRender();
2318
- // Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
2319
- settle?.(undefined);
2320
- }
2321
2326
  /**
2322
2327
  * Show a multi-line editor for extensions (with Ctrl+G support).
2323
2328
  */
2324
2329
  showExtensionEditor(title, prefill) {
2325
2330
  return new Promise((resolve) => {
2326
2331
  let settled = false;
2327
- const settle = (value) => {
2332
+ const finish = (value) => {
2328
2333
  if (settled)
2329
2334
  return;
2330
2335
  settled = true;
2331
- if (this.extensionEditorSettle === settle)
2332
- this.extensionEditorSettle = undefined;
2336
+ this.removeExtensionDialog(editor);
2333
2337
  resolve(value);
2334
2338
  };
2335
- const displaced = this.extensionEditorSettle;
2336
- this.extensionEditor = undefined;
2337
- this.extensionEditorSettle = undefined;
2338
- this.extensionEditor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill,
2339
- // Settle BEFORE hiding: `hideExtensionEditor` settles the slot fail-closed.
2340
- (value) => {
2341
- settle(value);
2342
- this.hideExtensionEditor();
2343
- }, () => {
2344
- settle(undefined);
2345
- this.hideExtensionEditor();
2346
- }, undefined, this.settingsManager.getExternalEditorCommand());
2347
- this.extensionEditorSettle = settle;
2348
- this.disposeActiveSelector();
2349
- this.editorContainer.clear();
2350
- this.editorContainer.addChild(this.extensionEditor);
2351
- this.ui.setFocus(this.extensionEditor);
2352
- this.ui.requestRender();
2353
- // Only once the replacement is installed, so the displaced caller's continuation cannot
2354
- // observe an empty dialog slot.
2355
- displaced?.(undefined);
2339
+ const editor = new ExtensionEditorComponent(this.ui, this.keybindings, title, prefill, (value) => finish(value), () => finish(undefined), undefined, this.settingsManager.getExternalEditorCommand());
2340
+ this.pushExtensionDialog({
2341
+ component: editor,
2342
+ kind: "editor",
2343
+ blocked: { kind: "question", message: title },
2344
+ failClosed: () => finish(undefined),
2345
+ });
2356
2346
  });
2357
2347
  }
2358
- /**
2359
- * Hide the extension editor, settling its promise FAIL-CLOSED if nothing else has.
2360
- *
2361
- * Same defect the selector had: this used to clear the container and re-focus without touching
2362
- * the `resolve` captured in {@link showExtensionEditor}'s closure, so `resetExtensionUI` — a
2363
- * session invalidate or `/reload` — stranded whoever was awaiting the editor forever. `/compact`
2364
- * with custom instructions is one such caller.
2365
- *
2366
- * Callers that carry a real answer must `settle(...)` it BEFORE calling this.
2367
- */
2368
- hideExtensionEditor() {
2369
- const settle = this.extensionEditorSettle;
2370
- this.extensionEditorSettle = undefined;
2371
- this.editorContainer.clear();
2372
- this.editorContainer.addChild(this.editor);
2373
- this.extensionEditor = undefined;
2374
- this.ui.setFocus(this.editor);
2375
- this.ui.requestRender();
2376
- // Last, so the caller's continuation cannot observe a half-torn-down dialog slot.
2377
- settle?.(undefined);
2378
- }
2379
2348
  /**
2380
2349
  * Set a custom editor component from an extension.
2381
2350
  * Pass undefined to restore the default editor.
@@ -2465,22 +2434,23 @@ export class InteractiveMode {
2465
2434
  async showExtensionCustom(factory, options) {
2466
2435
  const savedText = this.editor.getText();
2467
2436
  const isOverlay = options?.overlay ?? false;
2468
- const restoreEditor = () => {
2469
- this.editorContainer.clear();
2470
- this.editorContainer.addChild(this.editor);
2471
- this.editor.setText(savedText);
2472
- this.ui.setFocus(this.editor);
2473
- this.ui.requestRender();
2474
- };
2475
2437
  return new Promise((resolve, reject) => {
2476
2438
  let component;
2439
+ let overlayHandle;
2477
2440
  let closed = false;
2441
+ const restoreEditor = () => {
2442
+ if (component)
2443
+ this.removeExtensionDialog(component);
2444
+ this.editor.setText(savedText);
2445
+ this.ui.requestRender();
2446
+ };
2478
2447
  const close = (result) => {
2479
2448
  if (closed)
2480
2449
  return;
2481
2450
  closed = true;
2451
+ // Remove this overlay, not the topmost one: another overlay may have opened above it.
2482
2452
  if (isOverlay)
2483
- this.ui.hideOverlay();
2453
+ overlayHandle?.hide();
2484
2454
  else
2485
2455
  restoreEditor();
2486
2456
  // Note: both branches above already call requestRender
@@ -2507,19 +2477,33 @@ export class InteractiveMode {
2507
2477
  return opts;
2508
2478
  }
2509
2479
  // Fallback: use component's width property if available
2510
- const w = component.width;
2480
+ const w = c.width;
2511
2481
  return w ? { width: w } : undefined;
2512
2482
  };
2513
- const handle = this.ui.showOverlay(component, resolveOptions());
2483
+ overlayHandle = this.ui.showOverlay(c, resolveOptions());
2514
2484
  // Expose handle to caller for visibility control
2515
- options?.onHandle?.(handle);
2485
+ options?.onHandle?.(overlayHandle);
2516
2486
  }
2517
2487
  else {
2518
- this.disposeActiveSelector();
2519
- this.editorContainer.clear();
2520
- this.editorContainer.addChild(component);
2521
- this.ui.setFocus(component);
2522
- this.ui.requestRender();
2488
+ this.pushExtensionDialog({
2489
+ component: c,
2490
+ kind: "custom",
2491
+ blocked: undefined,
2492
+ // A custom component has no neutral answer, so a reset rejects rather than strand the caller.
2493
+ failClosed: () => {
2494
+ if (closed)
2495
+ return;
2496
+ closed = true;
2497
+ this.editor.setText(savedText);
2498
+ try {
2499
+ c.dispose?.();
2500
+ }
2501
+ catch {
2502
+ /* ignore dispose errors */
2503
+ }
2504
+ reject(new Error("Extension UI was reset"));
2505
+ },
2506
+ });
2523
2507
  }
2524
2508
  })
2525
2509
  .catch((err) => {
@@ -2900,6 +2884,7 @@ export class InteractiveMode {
2900
2884
  await this.init();
2901
2885
  }
2902
2886
  this.footer.invalidate();
2887
+ this.programStatus.handleEvent(event);
2903
2888
  switch (event.type) {
2904
2889
  case "agent_start":
2905
2890
  this.pendingTools.clear();
@@ -3009,6 +2994,7 @@ export class InteractiveMode {
3009
2994
  const component = new ToolExecutionComponent(content.name, content.id, content.arguments, {
3010
2995
  showImages: this.settingsManager.getShowImages(),
3011
2996
  imageWidthCells: this.settingsManager.getImageWidthCells(),
2997
+ outputPad: this.outputPad,
3012
2998
  }, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
3013
2999
  component.setExpanded(this.toolOutputExpanded);
3014
3000
  this.chatContainer.addChild(component);
@@ -3079,6 +3065,7 @@ export class InteractiveMode {
3079
3065
  component = new ToolExecutionComponent(event.toolName, event.toolCallId, event.args, {
3080
3066
  showImages: this.settingsManager.getShowImages(),
3081
3067
  imageWidthCells: this.settingsManager.getImageWidthCells(),
3068
+ outputPad: this.outputPad,
3082
3069
  }, this.getRegisteredToolDefinition(event.toolName), this.ui, this.sessionManager.getCwd());
3083
3070
  component.setExpanded(this.toolOutputExpanded);
3084
3071
  this.chatContainer.addChild(component);
@@ -3097,9 +3084,11 @@ export class InteractiveMode {
3097
3084
  break;
3098
3085
  }
3099
3086
  case "tool_execution_end": {
3087
+ if (event.isError)
3088
+ this.maybeShowInstallChangeWarning();
3100
3089
  const component = this.pendingTools.get(event.toolCallId);
3101
3090
  if (component) {
3102
- component.updateResult({ ...event.result, isError: event.isError });
3091
+ component.updateResult({ ...event.result, isError: event.isError, durationMs: event.durationMs });
3103
3092
  this.pendingTools.delete(event.toolCallId);
3104
3093
  this.ui.requestRender();
3105
3094
  }
@@ -3131,7 +3120,10 @@ export class InteractiveMode {
3131
3120
  this.defaultEditor.onEscape = () => {
3132
3121
  this.session.abortCompaction();
3133
3122
  };
3134
- this.showStatusIndicator(new CompactionStatusIndicator(this.ui, event.reason));
3123
+ const colorFn = isEmbeddedStatus(this.editor)
3124
+ ? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
3125
+ : undefined;
3126
+ this.showStatusIndicator(new CompactionStatusIndicator(this.ui, event.reason, colorFn));
3135
3127
  this.ui.requestRender();
3136
3128
  break;
3137
3129
  }
@@ -3220,7 +3212,10 @@ export class InteractiveMode {
3220
3212
  this.showStatusIndicator(new BranchSummaryStatusIndicator(this.ui));
3221
3213
  }
3222
3214
  else {
3223
- this.showStatusIndicator(new CompactionStatusIndicator(this.ui, event.reason));
3215
+ const colorFn = isEmbeddedStatus(this.editor)
3216
+ ? (text) => (this.editor.borderColor ?? theme.getThinkingBorderColor(this.session.thinkingLevel || "off"))(text)
3217
+ : undefined;
3218
+ this.showStatusIndicator(new CompactionStatusIndicator(this.ui, event.reason, colorFn));
3224
3219
  }
3225
3220
  this.ui.requestRender();
3226
3221
  break;
@@ -3284,7 +3279,7 @@ export class InteractiveMode {
3284
3279
  if (!renderer) {
3285
3280
  return;
3286
3281
  }
3287
- const component = new CustomEntryComponent(entry, renderer);
3282
+ const component = new CustomEntryComponent(entry, renderer, this.outputPad);
3288
3283
  component.setExpanded(this.toolOutputExpanded);
3289
3284
  if (!component.hasContent()) {
3290
3285
  return;
@@ -3301,7 +3296,7 @@ export class InteractiveMode {
3301
3296
  addMessageToChat(message, options) {
3302
3297
  switch (message.role) {
3303
3298
  case "bashExecution": {
3304
- const component = new BashExecutionComponent(message.command, this.ui, message.excludeFromContext);
3299
+ const component = new BashExecutionComponent(message.command, this.ui, message.excludeFromContext, this.outputPad);
3305
3300
  if (message.output) {
3306
3301
  component.appendOutput(message.output);
3307
3302
  }
@@ -3320,14 +3315,14 @@ export class InteractiveMode {
3320
3315
  }
3321
3316
  case "compactionSummary": {
3322
3317
  this.chatContainer.addChild(new Spacer(1));
3323
- const component = new CompactionSummaryMessageComponent(message, this.getMarkdownThemeWithSettings());
3318
+ const component = new CompactionSummaryMessageComponent(message, this.getMarkdownThemeWithSettings(), this.outputPad);
3324
3319
  component.setExpanded(this.toolOutputExpanded);
3325
3320
  this.chatContainer.addChild(component);
3326
3321
  break;
3327
3322
  }
3328
3323
  case "branchSummary": {
3329
3324
  this.chatContainer.addChild(new Spacer(1));
3330
- const component = new BranchSummaryMessageComponent(message, this.getMarkdownThemeWithSettings());
3325
+ const component = new BranchSummaryMessageComponent(message, this.getMarkdownThemeWithSettings(), this.outputPad);
3331
3326
  component.setExpanded(this.toolOutputExpanded);
3332
3327
  this.chatContainer.addChild(component);
3333
3328
  break;
@@ -3343,7 +3338,7 @@ export class InteractiveMode {
3343
3338
  const skillBlock = parseSkillBlock(textContent);
3344
3339
  if (skillBlock) {
3345
3340
  // Render skill block (collapsible)
3346
- const component = new SkillInvocationMessageComponent(skillBlock, this.getMarkdownThemeWithSettings());
3341
+ const component = new SkillInvocationMessageComponent(skillBlock, this.getMarkdownThemeWithSettings(), this.outputPad);
3347
3342
  component.setExpanded(this.toolOutputExpanded);
3348
3343
  this.chatContainer.addChild(component);
3349
3344
  // Render user message separately if present
@@ -3412,6 +3407,7 @@ export class InteractiveMode {
3412
3407
  const component = new ToolExecutionComponent(content.name, content.id, content.arguments, {
3413
3408
  showImages: this.settingsManager.getShowImages(),
3414
3409
  imageWidthCells: this.settingsManager.getImageWidthCells(),
3410
+ outputPad: this.outputPad,
3415
3411
  }, this.getRegisteredToolDefinition(content.name), this.ui, this.sessionManager.getCwd());
3416
3412
  component.setExpanded(this.toolOutputExpanded);
3417
3413
  this.chatContainer.addChild(component);
@@ -3465,6 +3461,9 @@ export class InteractiveMode {
3465
3461
  * @param options.populateHistory Add user messages to editor history
3466
3462
  */
3467
3463
  renderSessionEntries(entries, options = {}) {
3464
+ // Selection coordinates point into the transcript being replaced (#9311).
3465
+ if (this.renderer instanceof TuiAltScreen)
3466
+ this.renderer.resetTextSelection();
3468
3467
  const items = entries.flatMap((entry) => {
3469
3468
  if (entry.type === "custom" || (entry.type === "usage" && entry.kind === "cache_warm")) {
3470
3469
  return [entry];
@@ -3682,6 +3681,10 @@ export class InteractiveMode {
3682
3681
  * paste / Kitty / modifyOtherKeys sequences.
3683
3682
  */
3684
3683
  uncaughtCrash(error) {
3684
+ // A dead terminal is not a draht crash. Do not try to restore it or record it.
3685
+ if (isDeadTerminalError(error)) {
3686
+ this.emergencyTerminalExit();
3687
+ }
3685
3688
  if (this.isShuttingDown) {
3686
3689
  process.exit(1);
3687
3690
  }
@@ -3740,10 +3743,13 @@ export class InteractiveMode {
3740
3743
  }
3741
3744
  throw error;
3742
3745
  };
3743
- process.stdout.on("error", terminalErrorHandler);
3744
- process.stderr.on("error", terminalErrorHandler);
3745
- this.signalCleanupHandlers.push(() => process.stdout.off("error", terminalErrorHandler));
3746
- this.signalCleanupHandlers.push(() => process.stderr.off("error", terminalErrorHandler));
3746
+ // stdin needs the handler too: once the terminal is gone, reads and setRawMode
3747
+ // fail with EIO (orphaned background process group) or ENOTTY (revoked tty).
3748
+ // Node emits these as stream errors, which are uncaught without a listener.
3749
+ for (const stream of [process.stdin, process.stdout, process.stderr]) {
3750
+ stream.on("error", terminalErrorHandler);
3751
+ this.signalCleanupHandlers.push(() => stream.off("error", terminalErrorHandler));
3752
+ }
3747
3753
  // Restore the terminal before the process dies on any uncaught throw.
3748
3754
  // Without this, an unhandled exception from extension code (or anywhere
3749
3755
  // in pi) leaves the terminal in raw mode with no cursor.
@@ -4364,8 +4370,8 @@ export class InteractiveMode {
4364
4370
  onEnableInstallTelemetryChange: (enabled) => {
4365
4371
  this.settingsManager.setEnableInstallTelemetry(enabled);
4366
4372
  },
4367
- onQuietStartupChange: (enabled) => {
4368
- this.settingsManager.setQuietStartup(enabled);
4373
+ onQuietStartupChange: (quiet) => {
4374
+ this.settingsManager.setQuietStartup(quiet);
4369
4375
  },
4370
4376
  onAttachableSessionsChange: (enabled) => {
4371
4377
  // Takes effect on the next session start: this one already bound (or did not).
@@ -4394,21 +4400,14 @@ export class InteractiveMode {
4394
4400
  onOutputPadChange: (padding) => {
4395
4401
  this.settingsManager.setOutputPad(padding);
4396
4402
  this.outputPad = padding;
4397
- if (this.streamingComponent || this.session.isStreaming) {
4398
- for (const child of this.chatContainer.children) {
4399
- if (child instanceof AssistantMessageComponent ||
4400
- child instanceof CustomMessageComponent ||
4401
- child instanceof UserMessageComponent) {
4403
+ for (const container of [this.chatContainer, this.pendingMessagesContainer]) {
4404
+ for (const child of container.children) {
4405
+ if ("setOutputPad" in child && typeof child.setOutputPad === "function") {
4402
4406
  child.setOutputPad(padding);
4403
4407
  }
4404
4408
  }
4405
- if (this.streamingComponent) {
4406
- this.streamingComponent.setOutputPad(padding);
4407
- }
4408
- this.ui.requestRender();
4409
- return;
4410
4409
  }
4411
- this.rebuildChatFromMessages();
4410
+ this.ui.requestRender();
4412
4411
  },
4413
4412
  onAutocompleteMaxVisibleChange: (maxVisible) => {
4414
4413
  this.settingsManager.setAutocompleteMaxVisible(maxVisible);
@@ -5147,6 +5146,7 @@ export class InteractiveMode {
5147
5146
  source: authStatus.label ?? authStatus.source,
5148
5147
  }
5149
5148
  : undefined;
5149
+ const subscription = provider.auth.oauth?.isSubscription === true;
5150
5150
  if ((!authType || authType === "oauth") && provider.auth.oauth) {
5151
5151
  options.push({
5152
5152
  id: provider.id,
@@ -5154,6 +5154,7 @@ export class InteractiveMode {
5154
5154
  authType: "oauth",
5155
5155
  method: provider.auth.oauth,
5156
5156
  status,
5157
+ subscription,
5157
5158
  });
5158
5159
  }
5159
5160
  if ((!authType || authType === "api_key") && provider.auth.apiKey) {
@@ -5163,6 +5164,7 @@ export class InteractiveMode {
5163
5164
  authType: "api_key",
5164
5165
  method: provider.auth.apiKey,
5165
5166
  status,
5167
+ subscription,
5166
5168
  });
5167
5169
  }
5168
5170
  }
@@ -5170,12 +5172,16 @@ export class InteractiveMode {
5170
5172
  }
5171
5173
  async getLogoutProviderOptions() {
5172
5174
  return (await this.session.modelRuntime.listCredentials({ signal: AbortSignal.timeout(15_000) }))
5173
- .map(({ providerId, type }) => ({
5174
- id: providerId,
5175
- name: this.session.modelRuntime.getProvider(providerId)?.name ?? providerId,
5176
- authType: type,
5177
- status: { type, source: "stored credential" },
5178
- }))
5175
+ .map(({ providerId, type }) => {
5176
+ const provider = this.session.modelRuntime.getProvider(providerId);
5177
+ return {
5178
+ id: providerId,
5179
+ name: provider?.name ?? providerId,
5180
+ authType: type,
5181
+ status: { type, source: "stored credential" },
5182
+ subscription: provider?.auth.oauth?.isSubscription === true,
5183
+ };
5184
+ })
5179
5185
  .sort((a, b) => a.name.localeCompare(b.name));
5180
5186
  }
5181
5187
  findLoginProviderOptions(providerRef) {
@@ -5205,18 +5211,25 @@ export class InteractiveMode {
5205
5211
  }
5206
5212
  this.showLoginProviderSelector(undefined, providerRef);
5207
5213
  }
5208
- async startProviderLogin(providerOption) {
5214
+ /** `onBack` reopens the selector the login was started from when the user cancels it. */
5215
+ async startProviderLogin(providerOption, onBack) {
5209
5216
  if (providerOption.authType === "oauth") {
5210
- await this.showLoginDialog(providerOption.id, providerOption.name);
5217
+ await this.showLoginDialog(providerOption.id, providerOption.name, onBack);
5211
5218
  }
5212
5219
  else if (providerOption.method?.login) {
5213
- await this.showApiKeyLoginDialog(providerOption.id, providerOption.name);
5220
+ await this.showApiKeyLoginDialog(providerOption.id, providerOption.name, onBack);
5214
5221
  }
5215
5222
  else {
5216
- this.showAmbientAuthDialog(providerOption);
5223
+ this.showAmbientAuthDialog(providerOption, onBack);
5217
5224
  }
5218
5225
  }
5219
5226
  showLoginAuthTypeSelector(providerOptions) {
5227
+ // The top-level selector offers Radius directly, as its last option.
5228
+ const radiusOption = providerOptions
5229
+ ? undefined
5230
+ : this.getLoginProviderOptions("oauth").find((provider) => provider.id === RADIUS_PROVIDER_ID);
5231
+ const radiusText = radiusOption ? `Sign in with ${radiusOption.name}` : undefined;
5232
+ const radiusLabel = radiusOption ? `${radiusText}${formatAuthSelectorProviderStatus(radiusOption)}` : undefined;
5220
5233
  const oauthProvider = providerOptions?.find((provider) => provider.authType === "oauth");
5221
5234
  const oauthLoginLabel = oauthProvider?.method && "loginLabel" in oauthProvider.method ? oauthProvider.method.loginLabel : undefined;
5222
5235
  const subscriptionLabel = oauthLoginLabel ?? "Sign in with an account";
@@ -5231,6 +5244,8 @@ export class InteractiveMode {
5231
5244
  if (availableAuthTypes.has("api_key")) {
5232
5245
  options.push(apiKeyLabel);
5233
5246
  }
5247
+ if (radiusLabel)
5248
+ options.push(radiusLabel);
5234
5249
  if (options.length === 0) {
5235
5250
  this.showStatus("No login methods available.");
5236
5251
  return;
@@ -5246,29 +5261,37 @@ export class InteractiveMode {
5246
5261
  ? `Select authentication method for ${providerOptions[0].name}:`
5247
5262
  : "Select authentication method:";
5248
5263
  this.showSelector((done) => {
5249
- const selector = new ExtensionSelectorComponent(title, options, (option) => {
5264
+ const onSelect = (option) => {
5250
5265
  done();
5266
+ if (radiusOption && option === radiusLabel) {
5267
+ void this.startProviderLogin(radiusOption, () => this.showLoginAuthTypeSelector());
5268
+ return;
5269
+ }
5251
5270
  const authType = option === subscriptionLabel ? "oauth" : "api_key";
5252
5271
  if (providerOptions) {
5253
5272
  const providerOption = providerOptions.find((provider) => provider.authType === authType);
5254
5273
  if (providerOption) {
5255
- void this.startProviderLogin(providerOption);
5274
+ void this.startProviderLogin(providerOption, () => this.showLoginAuthTypeSelector(providerOptions));
5256
5275
  }
5257
5276
  return;
5258
5277
  }
5259
5278
  this.showLoginProviderSelector(authType);
5260
- }, () => {
5279
+ };
5280
+ const onCancel = () => {
5261
5281
  done();
5262
5282
  this.ui.requestRender();
5263
- });
5264
- return { component: selector, focus: selector };
5283
+ };
5284
+ const selector = radiusLabel && radiusText
5285
+ ? createLoginMenuSelector(this.ui, title, options, { label: radiusLabel, text: radiusText }, onSelect, onCancel)
5286
+ : new ExtensionSelectorComponent(title, options, onSelect, onCancel);
5287
+ return { component: selector, focus: selector, dispose: () => selector.dispose() };
5265
5288
  });
5266
5289
  }
5267
5290
  showLoginProviderSelector(authType, initialSearchInput) {
5268
5291
  const providerOptions = this.getLoginProviderOptions(authType);
5269
5292
  if (providerOptions.length === 0) {
5270
5293
  const message = authType === "oauth"
5271
- ? "No subscription providers available."
5294
+ ? "No account providers available."
5272
5295
  : authType === "api_key"
5273
5296
  ? "No API key providers available."
5274
5297
  : "No login providers available.";
@@ -5282,7 +5305,7 @@ export class InteractiveMode {
5282
5305
  if (!providerOption) {
5283
5306
  return;
5284
5307
  }
5285
- await this.startProviderLogin(providerOption);
5308
+ await this.startProviderLogin(providerOption, () => this.showLoginProviderSelector(authType, initialSearchInput));
5286
5309
  }, () => {
5287
5310
  done();
5288
5311
  if (authType) {
@@ -5436,21 +5459,24 @@ export class InteractiveMode {
5436
5459
  })
5437
5460
  .finally(() => clearTimeout(timeout));
5438
5461
  }
5439
- showAmbientAuthDialog(providerOption) {
5462
+ showAmbientAuthDialog(providerOption, onBack) {
5440
5463
  const restoreEditor = () => {
5441
5464
  this.editorContainer.clear();
5442
5465
  this.editorContainer.addChild(this.editor);
5443
5466
  this.ui.setFocus(this.editor);
5444
5467
  this.ui.requestRender();
5445
5468
  };
5446
- const dialog = new LoginDialogComponent(this.ui, providerOption.id, () => restoreEditor(), providerOption.name, `${providerOption.name} setup`);
5469
+ const dialog = new LoginDialogComponent(this.ui, providerOption.id, () => {
5470
+ restoreEditor();
5471
+ onBack?.();
5472
+ }, providerOption.name, `${providerOption.name} setup`);
5447
5473
  dialog.showInfo(`${providerOption.method?.name ?? "Authentication"} is configured outside ${APP_NAME}.`, [], true);
5448
5474
  this.editorContainer.clear();
5449
5475
  this.editorContainer.addChild(dialog);
5450
5476
  this.ui.setFocus(dialog);
5451
5477
  this.ui.requestRender();
5452
5478
  }
5453
- async showApiKeyLoginDialog(providerId, providerName) {
5479
+ async showApiKeyLoginDialog(providerId, providerName, onBack) {
5454
5480
  const previousModel = this.session.model;
5455
5481
  const dialog = new LoginDialogComponent(this.ui, providerId, (_success, _message) => {
5456
5482
  // Completion handled below
@@ -5473,7 +5499,7 @@ export class InteractiveMode {
5473
5499
  this.ui.requestRender();
5474
5500
  };
5475
5501
  try {
5476
- await this.loginProvider(dialog, providerId, "api_key");
5502
+ await this.loginProvider(dialog, providerId, providerName, "api_key");
5477
5503
  restoreEditor();
5478
5504
  await this.completeProviderAuthentication(providerId, providerName, "api_key", previousModel);
5479
5505
  }
@@ -5483,12 +5509,15 @@ export class InteractiveMode {
5483
5509
  if (error instanceof CredentialSynchronizationError) {
5484
5510
  this.showError(`Saved API key for ${providerName}, but local model state could not be synchronized: ${errorMsg}`);
5485
5511
  }
5486
- else if (errorMsg !== "Login cancelled") {
5512
+ else if (errorMsg === "Login cancelled") {
5513
+ onBack?.();
5514
+ }
5515
+ else {
5487
5516
  this.showError(`Failed to save API key for ${providerName}: ${errorMsg}`);
5488
5517
  }
5489
5518
  }
5490
5519
  }
5491
- showAuthSelect(dialog, prompt) {
5520
+ showAuthSelect(dialog, prompt, providerId) {
5492
5521
  return new Promise((resolve, reject) => {
5493
5522
  const restoreDialog = () => {
5494
5523
  this.editorContainer.clear();
@@ -5507,17 +5536,17 @@ export class InteractiveMode {
5507
5536
  }, () => {
5508
5537
  restoreDialog();
5509
5538
  reject(new Error("Login cancelled"));
5510
- });
5539
+ }, { description: providerId === RADIUS_PROVIDER_ID ? RADIUS_LOGIN_INTRO : undefined });
5511
5540
  this.editorContainer.clear();
5512
5541
  this.editorContainer.addChild(selector);
5513
5542
  this.ui.setFocus(selector);
5514
5543
  this.ui.requestRender();
5515
5544
  });
5516
5545
  }
5517
- async showAuthPrompt(dialog, prompt) {
5546
+ async showAuthPrompt(dialog, prompt, providerId) {
5518
5547
  let response;
5519
5548
  if (prompt.type === "select") {
5520
- response = this.showAuthSelect(dialog, prompt);
5549
+ response = this.showAuthSelect(dialog, prompt, providerId);
5521
5550
  }
5522
5551
  else if (prompt.type === "manual_code") {
5523
5552
  response = dialog.showManualInput(prompt.message);
@@ -5558,14 +5587,20 @@ export class InteractiveMode {
5558
5587
  dialog.showProgress(event.message);
5559
5588
  }
5560
5589
  }
5561
- async loginProvider(dialog, providerId, method) {
5562
- await this.session.modelRuntime.login(providerId, method, {
5563
- signal: dialog.signal,
5564
- prompt: (prompt) => this.showAuthPrompt(dialog, prompt),
5565
- notify: (event) => this.notifyAuthDialog(dialog, event),
5566
- }, { getDeviceId: () => this.settingsManager.getOrCreateDeviceId() });
5590
+ async loginProvider(dialog, providerId, providerName, method) {
5591
+ this.programStatus.setBlocked("login", { kind: "auth", message: `Log in to ${providerName}` });
5592
+ try {
5593
+ await this.session.modelRuntime.login(providerId, method, {
5594
+ signal: dialog.signal,
5595
+ prompt: (prompt) => this.showAuthPrompt(dialog, prompt, providerId),
5596
+ notify: (event) => this.notifyAuthDialog(dialog, event),
5597
+ }, { getDeviceId: () => this.settingsManager.getOrCreateDeviceId() });
5598
+ }
5599
+ finally {
5600
+ this.programStatus.setBlocked("login", undefined);
5601
+ }
5567
5602
  }
5568
- async showLoginDialog(providerId, providerName) {
5603
+ async showLoginDialog(providerId, providerName, onBack) {
5569
5604
  const previousModel = this.session.model;
5570
5605
  const dialog = new LoginDialogComponent(this.ui, providerId, (_success, _message) => { }, providerName);
5571
5606
  this.editorContainer.clear();
@@ -5579,9 +5614,11 @@ export class InteractiveMode {
5579
5614
  this.ui.requestRender();
5580
5615
  };
5581
5616
  try {
5582
- await this.loginProvider(dialog, providerId, "oauth");
5617
+ await this.loginProvider(dialog, providerId, providerName, "oauth");
5583
5618
  restoreEditor();
5584
5619
  await this.completeProviderAuthentication(providerId, providerName, "oauth", previousModel);
5620
+ if (providerId === RADIUS_PROVIDER_ID)
5621
+ this.offerRadiusMcpServer(providerId, providerName);
5585
5622
  }
5586
5623
  catch (error) {
5587
5624
  restoreEditor();
@@ -5589,11 +5626,58 @@ export class InteractiveMode {
5589
5626
  if (error instanceof CredentialSynchronizationError) {
5590
5627
  this.showError(`Logged in to ${providerName}, but local model state could not be synchronized: ${errorMsg}`);
5591
5628
  }
5592
- else if (errorMsg !== "Login cancelled") {
5629
+ else if (errorMsg === "Login cancelled") {
5630
+ onBack?.();
5631
+ }
5632
+ else {
5593
5633
  this.showError(`Failed to login to ${providerName}: ${errorMsg}`);
5594
5634
  }
5595
5635
  }
5596
5636
  }
5637
+ /**
5638
+ * Offer to point the Radius MCP server in the global mcp.json at the Radius login, adding the server
5639
+ * when missing. Nothing is asked when a global server already uses this login.
5640
+ */
5641
+ offerRadiusMcpServer(providerId, providerName) {
5642
+ const mcpPath = path.join(getAgentDir(), "mcp.json");
5643
+ const normalizeUrl = (url) => url.replace(/\/+$/u, "");
5644
+ const { servers } = loadMcpConfig({
5645
+ agentDir: getAgentDir(),
5646
+ cwd: this.sessionManager.getCwd(),
5647
+ projectTrusted: false,
5648
+ });
5649
+ const existing = servers.find((server) => "url" in server.config && normalizeUrl(server.config.url) === normalizeUrl(RADIUS_MCP_URL));
5650
+ if (existing && "url" in existing.config && existing.config.auth?.provider === providerId)
5651
+ return;
5652
+ let name = existing?.name ?? "radius";
5653
+ if (!existing && servers.some((server) => server.name === name))
5654
+ name = "radius-mcp";
5655
+ const config = existing && "url" in existing.config
5656
+ ? { ...existing.config, auth: { provider: providerId } }
5657
+ : { url: RADIUS_MCP_URL, auth: { provider: providerId } };
5658
+ // `auth` replaces the MCP OAuth sign-in.
5659
+ delete config.oauth;
5660
+ this.showSelector((done) => {
5661
+ const selector = new ExtensionSelectorComponent(`Configure ${providerName} MCP in ${mcpPath}?`, ["Yes", "No"], (option) => {
5662
+ done();
5663
+ if (option !== "Yes")
5664
+ return;
5665
+ try {
5666
+ addMcpServerConfig(mcpPath, name, config);
5667
+ }
5668
+ catch (error) {
5669
+ this.showError(`Could not update ${mcpPath}: ${error instanceof Error ? error.message : String(error)}`);
5670
+ return;
5671
+ }
5672
+ // The MCP extension reads mcp.json when the session starts.
5673
+ void this.handleReloadCommand();
5674
+ }, () => {
5675
+ done();
5676
+ this.ui.requestRender();
5677
+ });
5678
+ return { component: selector, focus: selector };
5679
+ });
5680
+ }
5597
5681
  // =========================================================================
5598
5682
  // Command handlers
5599
5683
  // =========================================================================
@@ -6130,7 +6214,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
6130
6214
  if (eventResult?.result) {
6131
6215
  const result = eventResult.result;
6132
6216
  // Create UI component for display
6133
- this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext);
6217
+ this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext, this.outputPad);
6134
6218
  if (this.session.isStreaming) {
6135
6219
  this.pendingMessagesContainer.addChild(this.bashComponent);
6136
6220
  this.pendingBashComponents.push(this.bashComponent);
@@ -6151,7 +6235,7 @@ ${cycleContextWindow ? `| \`${cycleContextWindow}\` | Cycle context window |\n`
6151
6235
  }
6152
6236
  // Normal execution path (possibly with custom operations)
6153
6237
  const isDeferred = this.session.isStreaming;
6154
- this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext);
6238
+ this.bashComponent = new BashExecutionComponent(command, this.ui, excludeFromContext, this.outputPad);
6155
6239
  if (isDeferred) {
6156
6240
  // Show in pending area when agent is streaming
6157
6241
  this.pendingMessagesContainer.addChild(this.bashComponent);