@draht/coding-agent 2026.10.20 → 2026.10.23

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 (726) 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-VEMVBETR.js +6 -0
  24. package/dist/bundle/chunks/anthropic.js +1 -1
  25. package/dist/bundle/chunks/azure-openai-responses-EXUP6SLM.js +2 -0
  26. package/dist/bundle/chunks/bedrock-converse-stream.js +23 -20
  27. package/dist/bundle/chunks/chunk-2MJ6J5N2.js +6 -0
  28. package/dist/bundle/chunks/chunk-2RI4GIFP.js +166 -0
  29. package/dist/bundle/chunks/chunk-57PET6SW.js +82 -0
  30. package/dist/bundle/chunks/chunk-76YNMQ57.js +2 -0
  31. package/dist/bundle/chunks/chunk-AACPRSR2.js +9 -0
  32. package/dist/bundle/chunks/chunk-CHRFWNPF.js +1424 -0
  33. package/dist/bundle/chunks/chunk-CI37W6HM.js +2 -0
  34. package/dist/bundle/chunks/chunk-CMKX4CSI.js +6 -0
  35. package/dist/bundle/chunks/chunk-DHZBWXZK.js +16 -0
  36. package/dist/bundle/chunks/{chunk-D6TMD5Q2.js → chunk-DLVZ3EK7.js} +4 -4
  37. package/dist/bundle/chunks/chunk-DQ4G4IS4.js +20 -0
  38. package/dist/bundle/chunks/chunk-FXCTQRNN.js +2 -0
  39. package/dist/bundle/chunks/chunk-FXLM6UQV.js +2 -0
  40. package/dist/bundle/chunks/chunk-ITP6IDBA.js +20 -0
  41. package/dist/bundle/chunks/chunk-JRHPLIE5.js +11 -0
  42. package/dist/bundle/chunks/chunk-KINQOWAP.js +4 -0
  43. package/dist/bundle/chunks/{chunk-IWTUBX6V.js → chunk-LK54N67E.js} +5 -2
  44. package/dist/bundle/chunks/chunk-MBFTIGLS.js +2 -0
  45. package/dist/bundle/chunks/chunk-QG2WW2SA.js +2 -0
  46. package/dist/bundle/chunks/{chunk-KPO5375S.js → chunk-RCRGGYLW.js} +1 -1
  47. package/dist/bundle/chunks/chunk-RGI7SF5G.js +2 -0
  48. package/dist/bundle/chunks/{chunk-6ZJKIMU7.js → chunk-SYRVFGYE.js} +1 -1
  49. package/dist/bundle/chunks/chunk-UQSONZLL.js +479 -0
  50. package/dist/bundle/chunks/chunk-USCN7R2E.js +2 -0
  51. package/dist/bundle/chunks/chunk-XB4F3WGD.js +132 -0
  52. package/dist/bundle/chunks/chunk-YSIQCH4Z.js +2 -0
  53. package/dist/bundle/chunks/chunk-ZRPAOMVB.js +2 -0
  54. package/dist/bundle/chunks/{cli-PYJB6AQ3.js → cli-LGOE6EXL.js} +6 -6
  55. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-47PK45EQ.js +2 -0
  56. package/dist/bundle/chunks/codemode-worker.js +188 -21
  57. package/dist/bundle/chunks/execute-ZVQ7ITER.js +31 -0
  58. package/dist/bundle/chunks/github-copilot.js +1 -1
  59. package/dist/bundle/chunks/google-generative-ai-PBPH45HB.js +2 -0
  60. package/dist/bundle/chunks/google-vertex-ZPCFQNU6.js +2 -0
  61. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  62. package/dist/bundle/chunks/{llama-cpp-classify-EJ5XMSQL.js → llama-cpp-classify-MWIQKGBR.js} +3 -3
  63. package/dist/bundle/chunks/mistral-conversations-7ODWQ37T.js +5 -0
  64. package/dist/bundle/chunks/node-BZAVEWJ3.js +16 -0
  65. package/dist/bundle/chunks/openai-chatgpt.js +1 -1
  66. package/dist/bundle/chunks/openai-codex-responses-7Y2SP2GS.js +10 -0
  67. package/dist/bundle/chunks/openai-codex.js +1 -1
  68. package/dist/bundle/chunks/openai-completions-QNWYJ4H4.js +7 -0
  69. package/dist/bundle/chunks/openai-decisions-4PKBAPR3.js +5 -0
  70. package/dist/bundle/chunks/openai-responses-73WU3TQM.js +4 -0
  71. package/dist/bundle/chunks/opencode-go.js +1 -1
  72. package/dist/bundle/chunks/openrouter-images-IMWDSQ5F.js +2 -0
  73. package/dist/bundle/chunks/pi-messages-AMNZ7HKZ.js +8 -0
  74. package/dist/bundle/chunks/runtime-7BIFTREJ.js +3 -0
  75. package/dist/bundle/chunks/runtime-MZVF4MP6.js +2 -0
  76. package/dist/bundle/chunks/settings-manager-QF6DRH5C.js +2 -0
  77. package/dist/bundle/chunks/typesafe-system-one-AXQRIVVX.js +2 -0
  78. package/dist/bundle/chunks/virtual-modules-Z4F3ZUX3.js +2 -0
  79. package/dist/bundle/cli-runtime.js +1 -1
  80. package/dist/bundle/index.js +1 -1
  81. package/dist/bundle/rpc-entry.js +1 -1
  82. package/dist/cli/args.d.ts +2 -1
  83. package/dist/cli/args.d.ts.map +1 -1
  84. package/dist/cli/args.js +30 -8
  85. package/dist/cli/args.js.map +1 -1
  86. package/dist/cli/credential-print.d.ts.map +1 -1
  87. package/dist/cli/credential-print.js +4 -4
  88. package/dist/cli/credential-print.js.map +1 -1
  89. package/dist/config.d.ts +18 -1
  90. package/dist/config.d.ts.map +1 -1
  91. package/dist/config.js +44 -6
  92. package/dist/config.js.map +1 -1
  93. package/dist/core/agent-session.d.ts +65 -8
  94. package/dist/core/agent-session.d.ts.map +1 -1
  95. package/dist/core/agent-session.js +240 -102
  96. package/dist/core/agent-session.js.map +1 -1
  97. package/dist/core/auth-storage.d.ts.map +1 -1
  98. package/dist/core/auth-storage.js +20 -13
  99. package/dist/core/auth-storage.js.map +1 -1
  100. package/dist/core/bash-executor.d.ts.map +1 -1
  101. package/dist/core/bash-executor.js +42 -52
  102. package/dist/core/bash-executor.js.map +1 -1
  103. package/dist/core/bug-report.d.ts +9 -1
  104. package/dist/core/bug-report.d.ts.map +1 -1
  105. package/dist/core/builtins/completion-checks.d.ts +3 -0
  106. package/dist/core/builtins/completion-checks.d.ts.map +1 -0
  107. package/dist/core/builtins/completion-checks.js +142 -0
  108. package/dist/core/builtins/completion-checks.js.map +1 -0
  109. package/dist/core/builtins/duet.d.ts.map +1 -1
  110. package/dist/core/builtins/duet.js +7 -5
  111. package/dist/core/builtins/duet.js.map +1 -1
  112. package/dist/core/builtins/git-safety.d.ts +3 -0
  113. package/dist/core/builtins/git-safety.d.ts.map +1 -0
  114. package/dist/core/builtins/git-safety.js +34 -0
  115. package/dist/core/builtins/git-safety.js.map +1 -0
  116. package/dist/core/builtins/index.d.ts.map +1 -1
  117. package/dist/core/builtins/index.js +4 -0
  118. package/dist/core/builtins/index.js.map +1 -1
  119. package/dist/core/client-identity.d.ts +8 -0
  120. package/dist/core/client-identity.d.ts.map +1 -0
  121. package/dist/core/client-identity.js +15 -0
  122. package/dist/core/client-identity.js.map +1 -0
  123. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  124. package/dist/core/compaction/branch-summarization.js +1 -2
  125. package/dist/core/compaction/branch-summarization.js.map +1 -1
  126. package/dist/core/compaction/compaction.d.ts +2 -2
  127. package/dist/core/compaction/compaction.d.ts.map +1 -1
  128. package/dist/core/compaction/compaction.js +20 -15
  129. package/dist/core/compaction/compaction.js.map +1 -1
  130. package/dist/core/compaction/utils.d.ts +6 -0
  131. package/dist/core/compaction/utils.d.ts.map +1 -1
  132. package/dist/core/compaction/utils.js +7 -8
  133. package/dist/core/compaction/utils.js.map +1 -1
  134. package/dist/core/export-html/index.d.ts.map +1 -1
  135. package/dist/core/export-html/index.js +2 -0
  136. package/dist/core/export-html/index.js.map +1 -1
  137. package/dist/core/export-html/template.html +1 -0
  138. package/dist/core/export-html/template.js +23 -17
  139. package/dist/core/export-html/tool-renderer.d.ts +3 -3
  140. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  141. package/dist/core/export-html/tool-renderer.js +5 -3
  142. package/dist/core/export-html/tool-renderer.js.map +1 -1
  143. package/dist/core/export-html/vendor/marked-cjk-friendly.min.js +6 -0
  144. package/dist/core/export-html/vendor/marked.min.js +30 -29
  145. package/dist/core/extensions/index.d.ts +1 -1
  146. package/dist/core/extensions/index.d.ts.map +1 -1
  147. package/dist/core/extensions/index.js.map +1 -1
  148. package/dist/core/extensions/loader.d.ts.map +1 -1
  149. package/dist/core/extensions/loader.js +7 -0
  150. package/dist/core/extensions/loader.js.map +1 -1
  151. package/dist/core/extensions/runner.d.ts +6 -2
  152. package/dist/core/extensions/runner.d.ts.map +1 -1
  153. package/dist/core/extensions/runner.js +16 -4
  154. package/dist/core/extensions/runner.js.map +1 -1
  155. package/dist/core/extensions/types.d.ts +61 -7
  156. package/dist/core/extensions/types.d.ts.map +1 -1
  157. package/dist/core/extensions/types.js.map +1 -1
  158. package/dist/core/extensions/virtual-modules.d.ts.map +1 -1
  159. package/dist/core/extensions/virtual-modules.js +2 -0
  160. package/dist/core/extensions/virtual-modules.js.map +1 -1
  161. package/dist/core/key-id-schema.d.ts +6 -0
  162. package/dist/core/key-id-schema.d.ts.map +1 -0
  163. package/dist/core/key-id-schema.js +16 -0
  164. package/dist/core/key-id-schema.js.map +1 -0
  165. package/dist/core/keybindings-schema.d.ts +4 -0
  166. package/dist/core/keybindings-schema.d.ts.map +1 -0
  167. package/dist/core/keybindings-schema.js +16 -0
  168. package/dist/core/keybindings-schema.js.map +1 -0
  169. package/dist/core/keybindings.d.ts +242 -75
  170. package/dist/core/keybindings.d.ts.map +1 -1
  171. package/dist/core/keybindings.js +30 -23
  172. package/dist/core/keybindings.js.map +1 -1
  173. package/dist/core/mcp-servers.d.ts +22 -0
  174. package/dist/core/mcp-servers.d.ts.map +1 -1
  175. package/dist/core/mcp-servers.js +72 -11
  176. package/dist/core/mcp-servers.js.map +1 -1
  177. package/dist/core/model-config.d.ts +1623 -74
  178. package/dist/core/model-config.d.ts.map +1 -1
  179. package/dist/core/model-config.js +70 -184
  180. package/dist/core/model-config.js.map +1 -1
  181. package/dist/core/model-registry.d.ts +3 -1
  182. package/dist/core/model-registry.d.ts.map +1 -1
  183. package/dist/core/model-registry.js +4 -0
  184. package/dist/core/model-registry.js.map +1 -1
  185. package/dist/core/model-resolver.d.ts +56 -43
  186. package/dist/core/model-resolver.d.ts.map +1 -1
  187. package/dist/core/model-resolver.js +253 -358
  188. package/dist/core/model-resolver.js.map +1 -1
  189. package/dist/core/model-runtime.d.ts.map +1 -1
  190. package/dist/core/model-runtime.js +19 -10
  191. package/dist/core/model-runtime.js.map +1 -1
  192. package/dist/core/nested-tool-calls.d.ts +1 -0
  193. package/dist/core/nested-tool-calls.d.ts.map +1 -1
  194. package/dist/core/nested-tool-calls.js +1 -0
  195. package/dist/core/nested-tool-calls.js.map +1 -1
  196. package/dist/core/package-manager.js +3 -3
  197. package/dist/core/package-manager.js.map +1 -1
  198. package/dist/core/polyphase/keyword.js +1 -1
  199. package/dist/core/polyphase/keyword.js.map +1 -1
  200. package/dist/core/polyphase/model-selection.d.ts.map +1 -1
  201. package/dist/core/polyphase/model-selection.js +15 -7
  202. package/dist/core/polyphase/model-selection.js.map +1 -1
  203. package/dist/core/polyphase/workflow/prelude.d.ts +2 -0
  204. package/dist/core/polyphase/workflow/prelude.d.ts.map +1 -1
  205. package/dist/core/polyphase/workflow/prelude.js +12 -16
  206. package/dist/core/polyphase/workflow/prelude.js.map +1 -1
  207. package/dist/core/polyphase/workflow/runtime.d.ts.map +1 -1
  208. package/dist/core/polyphase/workflow/runtime.js +2 -1
  209. package/dist/core/polyphase/workflow/runtime.js.map +1 -1
  210. package/dist/core/project-trust.d.ts.map +1 -1
  211. package/dist/core/project-trust.js +2 -1
  212. package/dist/core/project-trust.js.map +1 -1
  213. package/dist/core/prompt-templates.d.ts.map +1 -1
  214. package/dist/core/prompt-templates.js +7 -2
  215. package/dist/core/prompt-templates.js.map +1 -1
  216. package/dist/core/provider-composer.d.ts +2 -1
  217. package/dist/core/provider-composer.d.ts.map +1 -1
  218. package/dist/core/provider-composer.js +13 -0
  219. package/dist/core/provider-composer.js.map +1 -1
  220. package/dist/core/radius.d.ts +2 -0
  221. package/dist/core/radius.d.ts.map +1 -1
  222. package/dist/core/radius.js +2 -0
  223. package/dist/core/radius.js.map +1 -1
  224. package/dist/core/remote-catalog-provider.d.ts +12 -1
  225. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  226. package/dist/core/remote-catalog-provider.js +84 -24
  227. package/dist/core/remote-catalog-provider.js.map +1 -1
  228. package/dist/core/resource-loader.d.ts +3 -0
  229. package/dist/core/resource-loader.d.ts.map +1 -1
  230. package/dist/core/resource-loader.js +7 -4
  231. package/dist/core/resource-loader.js.map +1 -1
  232. package/dist/core/sdk.d.ts +13 -4
  233. package/dist/core/sdk.d.ts.map +1 -1
  234. package/dist/core/sdk.js +27 -15
  235. package/dist/core/sdk.js.map +1 -1
  236. package/dist/core/settings-defaults.d.ts +65 -0
  237. package/dist/core/settings-defaults.d.ts.map +1 -0
  238. package/dist/core/settings-defaults.js +66 -0
  239. package/dist/core/settings-defaults.js.map +1 -0
  240. package/dist/core/settings-manager.d.ts +17 -178
  241. package/dist/core/settings-manager.d.ts.map +1 -1
  242. package/dist/core/settings-manager.js +86 -57
  243. package/dist/core/settings-manager.js.map +1 -1
  244. package/dist/core/settings-schema.d.ts +269 -0
  245. package/dist/core/settings-schema.d.ts.map +1 -0
  246. package/dist/core/settings-schema.js +318 -0
  247. package/dist/core/settings-schema.js.map +1 -0
  248. package/dist/core/skills.d.ts +4 -1
  249. package/dist/core/skills.d.ts.map +1 -1
  250. package/dist/core/skills.js +6 -1
  251. package/dist/core/skills.js.map +1 -1
  252. package/dist/core/system-prompt.d.ts +6 -0
  253. package/dist/core/system-prompt.d.ts.map +1 -1
  254. package/dist/core/system-prompt.js +10 -5
  255. package/dist/core/system-prompt.js.map +1 -1
  256. package/dist/core/tools/bash.d.ts.map +1 -1
  257. package/dist/core/tools/bash.js +3 -5
  258. package/dist/core/tools/bash.js.map +1 -1
  259. package/dist/core/tools/grep.d.ts +8 -0
  260. package/dist/core/tools/grep.d.ts.map +1 -1
  261. package/dist/core/tools/grep.js +19 -7
  262. package/dist/core/tools/grep.js.map +1 -1
  263. package/dist/core/tools/index.d.ts +2 -0
  264. package/dist/core/tools/index.d.ts.map +1 -1
  265. package/dist/core/tools/index.js +2 -0
  266. package/dist/core/tools/index.js.map +1 -1
  267. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  268. package/dist/core/tools/output-accumulator.js +4 -10
  269. package/dist/core/tools/output-accumulator.js.map +1 -1
  270. package/dist/core/tools/path-utils.d.ts +1 -1
  271. package/dist/core/tools/path-utils.d.ts.map +1 -1
  272. package/dist/core/tools/path-utils.js +6 -6
  273. package/dist/core/tools/path-utils.js.map +1 -1
  274. package/dist/core/tools/read.d.ts +13 -0
  275. package/dist/core/tools/read.d.ts.map +1 -1
  276. package/dist/core/tools/read.js +32 -2
  277. package/dist/core/tools/read.js.map +1 -1
  278. package/dist/core/tools/render-utils.d.ts +20 -0
  279. package/dist/core/tools/render-utils.d.ts.map +1 -1
  280. package/dist/core/tools/render-utils.js +67 -0
  281. package/dist/core/tools/render-utils.js.map +1 -1
  282. package/dist/core/tools/renderers/bash.d.ts.map +1 -1
  283. package/dist/core/tools/renderers/bash.js +7 -35
  284. package/dist/core/tools/renderers/bash.js.map +1 -1
  285. package/dist/core/tools/renderers/edit.d.ts.map +1 -1
  286. package/dist/core/tools/renderers/edit.js +5 -4
  287. package/dist/core/tools/renderers/edit.js.map +1 -1
  288. package/dist/core/tools/renderers/index.d.ts +2 -2
  289. package/dist/core/tools/renderers/index.d.ts.map +1 -1
  290. package/dist/core/tools/renderers/index.js.map +1 -1
  291. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  292. package/dist/core/tools/renderers/read.js +7 -11
  293. package/dist/core/tools/renderers/read.js.map +1 -1
  294. package/dist/extensions/codemode/execute.d.ts.map +1 -1
  295. package/dist/extensions/codemode/execute.js +391 -80
  296. package/dist/extensions/codemode/execute.js.map +1 -1
  297. package/dist/extensions/codemode/index.d.ts.map +1 -1
  298. package/dist/extensions/codemode/index.js +3 -1
  299. package/dist/extensions/codemode/index.js.map +1 -1
  300. package/dist/extensions/codemode/renderer.d.ts +2 -2
  301. package/dist/extensions/codemode/renderer.d.ts.map +1 -1
  302. package/dist/extensions/codemode/renderer.js +9 -3
  303. package/dist/extensions/codemode/renderer.js.map +1 -1
  304. package/dist/extensions/codemode/tool.d.ts +22 -21
  305. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  306. package/dist/extensions/codemode/tool.js +96 -123
  307. package/dist/extensions/codemode/tool.js.map +1 -1
  308. package/dist/extensions/llama/provider.d.ts.map +1 -1
  309. package/dist/extensions/llama/provider.js +34 -11
  310. package/dist/extensions/llama/provider.js.map +1 -1
  311. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  312. package/dist/extensions/mcp/cli.js +27 -33
  313. package/dist/extensions/mcp/cli.js.map +1 -1
  314. package/dist/extensions/mcp/config.d.ts +15 -3
  315. package/dist/extensions/mcp/config.d.ts.map +1 -1
  316. package/dist/extensions/mcp/config.js +49 -12
  317. package/dist/extensions/mcp/config.js.map +1 -1
  318. package/dist/extensions/mcp/index.d.ts +4 -1
  319. package/dist/extensions/mcp/index.d.ts.map +1 -1
  320. package/dist/extensions/mcp/index.js +279 -129
  321. package/dist/extensions/mcp/index.js.map +1 -1
  322. package/dist/extensions/mcp/oauth.d.ts +21 -11
  323. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  324. package/dist/extensions/mcp/oauth.js +166 -45
  325. package/dist/extensions/mcp/oauth.js.map +1 -1
  326. package/dist/extensions/mcp/resources.d.ts +3 -10
  327. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  328. package/dist/extensions/mcp/resources.js +4 -5
  329. package/dist/extensions/mcp/resources.js.map +1 -1
  330. package/dist/extensions/mcp/runtime.d.ts +7 -7
  331. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  332. package/dist/extensions/mcp/runtime.js +31 -45
  333. package/dist/extensions/mcp/runtime.js.map +1 -1
  334. package/dist/extensions/mcp/tools.d.ts +7 -5
  335. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  336. package/dist/extensions/mcp/tools.js +87 -29
  337. package/dist/extensions/mcp/tools.js.map +1 -1
  338. package/dist/extensions/mcp/ui.d.ts +3 -3
  339. package/dist/extensions/mcp/ui.d.ts.map +1 -1
  340. package/dist/extensions/mcp/ui.js +18 -6
  341. package/dist/extensions/mcp/ui.js.map +1 -1
  342. package/dist/extensions/tool-search/tool.d.ts +0 -2
  343. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  344. package/dist/extensions/tool-search/tool.js +2 -4
  345. package/dist/extensions/tool-search/tool.js.map +1 -1
  346. package/dist/hooks/checks/checks-runtime.cjs +215 -0
  347. package/dist/hooks/checks/git-safety.cjs +198 -0
  348. package/dist/hooks/checks/git-safety.d.cts +1 -0
  349. package/dist/hooks/gsd/draht-post-task.js +78 -39
  350. package/dist/hooks/gsd/draht-quality-gate.js +210 -122
  351. package/dist/hooks/gsd/package.json +3 -0
  352. package/dist/index.d.ts +5 -4
  353. package/dist/index.d.ts.map +1 -1
  354. package/dist/index.js +3 -2
  355. package/dist/index.js.map +1 -1
  356. package/dist/main.d.ts.map +1 -1
  357. package/dist/main.js +11 -3
  358. package/dist/main.js.map +1 -1
  359. package/dist/modes/interactive/components/auth-url.d.ts +14 -0
  360. package/dist/modes/interactive/components/auth-url.d.ts.map +1 -0
  361. package/dist/modes/interactive/components/auth-url.js +37 -0
  362. package/dist/modes/interactive/components/auth-url.js.map +1 -0
  363. package/dist/modes/interactive/components/bash-execution.d.ts +5 -1
  364. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/bash-execution.js +17 -14
  366. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  367. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -1
  368. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  369. package/dist/modes/interactive/components/branch-summary-message.js +5 -2
  370. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  371. package/dist/modes/interactive/components/compaction-summary-message.d.ts +2 -1
  372. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  373. package/dist/modes/interactive/components/compaction-summary-message.js +5 -2
  374. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  375. package/dist/modes/interactive/components/custom-entry.d.ts +3 -1
  376. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  377. package/dist/modes/interactive/components/custom-entry.js +8 -2
  378. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  379. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  380. package/dist/modes/interactive/components/custom-message.js +1 -0
  381. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  382. package/dist/modes/interactive/components/login-dialog.d.ts +3 -0
  383. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  384. package/dist/modes/interactive/components/login-dialog.js +38 -10
  385. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  386. package/dist/modes/interactive/components/oauth-selector.d.ts +8 -2
  387. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  388. package/dist/modes/interactive/components/oauth-selector.js +24 -21
  389. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  390. package/dist/modes/interactive/components/radius-login-selector.d.ts +15 -0
  391. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -0
  392. package/dist/modes/interactive/components/radius-login-selector.js +85 -0
  393. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -0
  394. package/dist/modes/interactive/components/settings-selector.d.ts +3 -3
  395. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  396. package/dist/modes/interactive/components/settings-selector.js +9 -8
  397. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  398. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -1
  399. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  400. package/dist/modes/interactive/components/skill-invocation-message.js +5 -2
  401. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  402. package/dist/modes/interactive/components/status-indicator.d.ts +1 -1
  403. package/dist/modes/interactive/components/status-indicator.d.ts.map +1 -1
  404. package/dist/modes/interactive/components/status-indicator.js +2 -2
  405. package/dist/modes/interactive/components/status-indicator.js.map +1 -1
  406. package/dist/modes/interactive/components/tool-execution.d.ts +12 -13
  407. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  408. package/dist/modes/interactive/components/tool-execution.js +32 -45
  409. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  410. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  411. package/dist/modes/interactive/components/tree-selector.js +2 -9
  412. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  413. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  414. package/dist/modes/interactive/components/user-message.js +5 -4
  415. package/dist/modes/interactive/components/user-message.js.map +1 -1
  416. package/dist/modes/interactive/interactive-mode.d.ts +43 -48
  417. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  418. package/dist/modes/interactive/interactive-mode.js +362 -278
  419. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  420. package/dist/modes/interactive/program-status-reporter.d.ts +34 -0
  421. package/dist/modes/interactive/program-status-reporter.d.ts.map +1 -0
  422. package/dist/modes/interactive/program-status-reporter.js +110 -0
  423. package/dist/modes/interactive/program-status-reporter.js.map +1 -0
  424. package/dist/modes/interactive/theme/dark.json +1 -1
  425. package/dist/modes/interactive/theme/light.json +1 -1
  426. package/dist/modes/interactive/theme/system-theme.d.ts +2 -1
  427. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -1
  428. package/dist/modes/interactive/theme/system-theme.js +16 -5
  429. package/dist/modes/interactive/theme/system-theme.js.map +1 -1
  430. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  431. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  432. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  433. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  434. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  435. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  436. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  437. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  438. package/dist/modes/interactive/theme/theme.d.ts +13 -16
  439. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  440. package/dist/modes/interactive/theme/theme.js +22 -29
  441. package/dist/modes/interactive/theme/theme.js.map +1 -1
  442. package/dist/modes/print-mode.d.ts.map +1 -1
  443. package/dist/modes/print-mode.js +4 -0
  444. package/dist/modes/print-mode.js.map +1 -1
  445. package/dist/package-manager-cli.d.ts.map +1 -1
  446. package/dist/package-manager-cli.js +26 -1
  447. package/dist/package-manager-cli.js.map +1 -1
  448. package/dist/prompts/commands/atomic-commit.md +8 -6
  449. package/dist/prompts/commands/brainstorm.md +5 -149
  450. package/dist/prompts/commands/create-verification-skill.md +8 -48
  451. package/dist/prompts/commands/discuss-phase.md +6 -10
  452. package/dist/prompts/commands/execute-phase.md +18 -45
  453. package/dist/prompts/commands/fix.md +16 -128
  454. package/dist/prompts/commands/grill.md +6 -53
  455. package/dist/prompts/commands/init-project.md +13 -18
  456. package/dist/prompts/commands/map-codebase.md +3 -3
  457. package/dist/prompts/commands/new-project.md +12 -17
  458. package/dist/prompts/commands/next-milestone.md +4 -8
  459. package/dist/prompts/commands/orchestrate-loop.md +12 -12
  460. package/dist/prompts/commands/orchestrate.md +12 -11
  461. package/dist/prompts/commands/pause-work.md +1 -1
  462. package/dist/prompts/commands/plan-phase.md +15 -37
  463. package/dist/prompts/commands/quick.md +11 -64
  464. package/dist/prompts/commands/resolve-conflicts.md +2 -15
  465. package/dist/prompts/commands/triage.md +3 -14
  466. package/dist/prompts/commands/verify-work.md +15 -63
  467. package/dist/prompts/commands/why.md +18 -118
  468. package/dist/skills/atomic-reasoning/SKILL.md +6 -105
  469. package/dist/skills/blast-radius/SKILL.md +1 -1
  470. package/dist/skills/epistemics/SKILL.md +12 -87
  471. package/dist/skills/explainers/SKILL.md +1 -1
  472. package/dist/skills/typescript-discipline/SKILL.md +12 -42
  473. package/dist/skills/typescript-discipline/references/patterns.md +25 -266
  474. package/dist/skills/unslop/SKILL.md +14 -105
  475. package/dist/utils/ansi.d.ts +8 -0
  476. package/dist/utils/ansi.d.ts.map +1 -1
  477. package/dist/utils/ansi.js +30 -11
  478. package/dist/utils/ansi.js.map +1 -1
  479. package/dist/utils/clipboard-command.d.ts.map +1 -1
  480. package/dist/utils/clipboard-command.js +3 -0
  481. package/dist/utils/clipboard-command.js.map +1 -1
  482. package/dist/utils/clipboard.d.ts.map +1 -1
  483. package/dist/utils/clipboard.js +18 -12
  484. package/dist/utils/clipboard.js.map +1 -1
  485. package/dist/utils/draht-user-agent.d.ts +1 -0
  486. package/dist/utils/draht-user-agent.d.ts.map +1 -1
  487. package/dist/utils/draht-user-agent.js +3 -2
  488. package/dist/utils/draht-user-agent.js.map +1 -1
  489. package/dist/utils/image-convert.d.ts +12 -0
  490. package/dist/utils/image-convert.d.ts.map +1 -1
  491. package/dist/utils/image-convert.js +45 -6
  492. package/dist/utils/image-convert.js.map +1 -1
  493. package/dist/utils/image-resize-core.d.ts +12 -0
  494. package/dist/utils/image-resize-core.d.ts.map +1 -1
  495. package/dist/utils/image-resize-core.js +5 -0
  496. package/dist/utils/image-resize-core.js.map +1 -1
  497. package/dist/utils/image-resize-worker.js +3 -2
  498. package/dist/utils/image-resize-worker.js.map +1 -1
  499. package/dist/utils/image-resize.d.ts.map +1 -1
  500. package/dist/utils/image-resize.js +9 -10
  501. package/dist/utils/image-resize.js.map +1 -1
  502. package/dist/utils/output-files.d.ts +15 -0
  503. package/dist/utils/output-files.d.ts.map +1 -0
  504. package/dist/utils/output-files.js +30 -0
  505. package/dist/utils/output-files.js.map +1 -0
  506. package/dist/utils/shell.d.ts.map +1 -1
  507. package/dist/utils/shell.js +43 -13
  508. package/dist/utils/shell.js.map +1 -1
  509. package/dist/utils/syntax-highlight.d.ts.map +1 -1
  510. package/dist/utils/syntax-highlight.js +6 -1
  511. package/dist/utils/syntax-highlight.js.map +1 -1
  512. package/dist/utils/tools-manager.d.ts.map +1 -1
  513. package/dist/utils/tools-manager.js +4 -3
  514. package/dist/utils/tools-manager.js.map +1 -1
  515. package/docs/cli-integration.md +1 -1
  516. package/docs/cli.md +30 -26
  517. package/docs/codemode.md +230 -0
  518. package/docs/compaction.md +5 -5
  519. package/docs/containerization.md +1 -1
  520. package/docs/custom-provider.md +53 -1
  521. package/docs/docs.json +17 -1
  522. package/docs/drahtbank.md +163 -0
  523. package/docs/environment-variables.md +5 -2
  524. package/docs/extensions.md +143 -13
  525. package/docs/index.md +1 -1
  526. package/docs/json.md +3 -3
  527. package/docs/keybindings.md +9 -5
  528. package/docs/llama-cpp.md +9 -2
  529. package/docs/mcp.md +59 -3
  530. package/docs/message-types.md +22 -4
  531. package/docs/models-configuration.md +187 -0
  532. package/docs/models.md +67 -4
  533. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  534. package/docs/providers.md +70 -5
  535. package/docs/sdk.md +1 -1
  536. package/docs/settings.md +10 -8
  537. package/docs/terminal-setup.md +14 -0
  538. package/docs/themes.md +4 -2
  539. package/docs/tui.md +71 -1
  540. package/docs/usage.md +1 -1
  541. package/docs/windows.md +16 -2
  542. package/eval/drahtbank/adapters.d.mts +35 -0
  543. package/eval/drahtbank/adapters.mjs +192 -0
  544. package/eval/drahtbank/bank.d.mts +141 -0
  545. package/eval/drahtbank/bank.mjs +515 -0
  546. package/eval/drahtbank/cases-v2.d.mts +28 -0
  547. package/eval/drahtbank/cases-v2.mjs +164 -0
  548. package/eval/drahtbank/cases.d.mts +17 -0
  549. package/eval/drahtbank/cases.mjs +198 -0
  550. package/eval/drahtbank/cli.mjs +120 -0
  551. package/eval/drahtbank/grading-v2.d.mts +26 -0
  552. package/eval/drahtbank/grading-v2.mjs +227 -0
  553. package/eval/drahtbank/isolated-tools.ts +223 -0
  554. package/eval/drahtbank/isolation-worker.mjs +53 -0
  555. package/eval/drahtbank/isolation.d.mts +52 -0
  556. package/eval/drahtbank/isolation.mjs +345 -0
  557. package/eval/drahtbank/runtime-checks.d.mts +15 -0
  558. package/eval/drahtbank/runtime-checks.mjs +187 -0
  559. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  560. package/examples/extensions/minimal-mode.ts +4 -5
  561. package/examples/extensions/overlay-test.ts +2 -2
  562. package/examples/extensions/plan-mode/index.ts +6 -2
  563. package/examples/extensions/subagent/index.ts +4 -6
  564. package/hooks/checks/checks-runtime.cjs +215 -0
  565. package/hooks/checks/git-safety.cjs +198 -0
  566. package/hooks/checks/git-safety.d.cts +1 -0
  567. package/hooks/gsd/draht-post-task.js +78 -39
  568. package/hooks/gsd/draht-quality-gate.js +210 -122
  569. package/hooks/gsd/package.json +3 -0
  570. package/package.json +21 -16
  571. package/prompts/commands/atomic-commit.md +8 -6
  572. package/prompts/commands/brainstorm.md +5 -149
  573. package/prompts/commands/create-verification-skill.md +8 -48
  574. package/prompts/commands/discuss-phase.md +6 -10
  575. package/prompts/commands/execute-phase.md +18 -45
  576. package/prompts/commands/fix.md +16 -128
  577. package/prompts/commands/grill.md +6 -53
  578. package/prompts/commands/init-project.md +13 -18
  579. package/prompts/commands/map-codebase.md +3 -3
  580. package/prompts/commands/new-project.md +12 -17
  581. package/prompts/commands/next-milestone.md +4 -8
  582. package/prompts/commands/orchestrate-loop.md +12 -12
  583. package/prompts/commands/orchestrate.md +12 -11
  584. package/prompts/commands/pause-work.md +1 -1
  585. package/prompts/commands/plan-phase.md +15 -37
  586. package/prompts/commands/quick.md +11 -64
  587. package/prompts/commands/resolve-conflicts.md +2 -15
  588. package/prompts/commands/triage.md +3 -14
  589. package/prompts/commands/verify-work.md +15 -63
  590. package/prompts/commands/why.md +18 -118
  591. package/schemas/keybindings.schema.json +433 -0
  592. package/schemas/models.schema.json +1190 -0
  593. package/schemas/settings.schema.json +849 -0
  594. package/schemas/theme.schema.json +365 -0
  595. package/skills/atomic-reasoning/SKILL.md +6 -105
  596. package/skills/blast-radius/SKILL.md +1 -1
  597. package/skills/epistemics/SKILL.md +12 -87
  598. package/skills/explainers/SKILL.md +1 -1
  599. package/skills/typescript-discipline/SKILL.md +12 -42
  600. package/skills/typescript-discipline/references/patterns.md +25 -266
  601. package/skills/unslop/SKILL.md +14 -105
  602. package/dist/bundle/chunks/anthropic-messages-GAKYXF65.js +0 -6
  603. package/dist/bundle/chunks/azure-openai-responses-ZIXMK6JO.js +0 -2
  604. package/dist/bundle/chunks/chunk-2E5VODES.js +0 -2
  605. package/dist/bundle/chunks/chunk-2VAF4XJI.js +0 -146
  606. package/dist/bundle/chunks/chunk-4TVQYRQY.js +0 -2
  607. package/dist/bundle/chunks/chunk-7TYCZN4Z.js +0 -137
  608. package/dist/bundle/chunks/chunk-BXSHCX3G.js +0 -11
  609. package/dist/bundle/chunks/chunk-GVXA72ZA.js +0 -2
  610. package/dist/bundle/chunks/chunk-I5OKY6RH.js +0 -11
  611. package/dist/bundle/chunks/chunk-KU5HAKZL.js +0 -4
  612. package/dist/bundle/chunks/chunk-MO3SCGBN.js +0 -18
  613. package/dist/bundle/chunks/chunk-N2QZNJT6.js +0 -65
  614. package/dist/bundle/chunks/chunk-PGJAHC3R.js +0 -107
  615. package/dist/bundle/chunks/chunk-QVFELZW2.js +0 -312
  616. package/dist/bundle/chunks/chunk-RZKPFWMH.js +0 -42
  617. package/dist/bundle/chunks/chunk-SDRCE6OP.js +0 -2
  618. package/dist/bundle/chunks/chunk-SVNWI7EV.js +0 -8
  619. package/dist/bundle/chunks/chunk-TOWVIJ2O.js +0 -1623
  620. package/dist/bundle/chunks/chunk-XBUEMKIY.js +0 -2
  621. package/dist/bundle/chunks/chunk-ZA4QNPJY.js +0 -82
  622. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MJKOAE5S.js +0 -2
  623. package/dist/bundle/chunks/execute-6N7T7VLY.js +0 -18
  624. package/dist/bundle/chunks/google-generative-ai-RPUPQ6PM.js +0 -2
  625. package/dist/bundle/chunks/google-vertex-EZES5QVQ.js +0 -2
  626. package/dist/bundle/chunks/mistral-conversations-AOYGU43Y.js +0 -5
  627. package/dist/bundle/chunks/node-LQ52KV6B.js +0 -16
  628. package/dist/bundle/chunks/openai-codex-responses-M2Y77JEQ.js +0 -10
  629. package/dist/bundle/chunks/openai-completions-A4OKYOYV.js +0 -7
  630. package/dist/bundle/chunks/openai-responses-6IXV53T3.js +0 -3
  631. package/dist/bundle/chunks/openrouter-images-LYV4NKFM.js +0 -2
  632. package/dist/bundle/chunks/pi-messages-KKMEUT3Z.js +0 -8
  633. package/dist/bundle/chunks/runtime-363BOYEO.js +0 -3
  634. package/dist/bundle/chunks/runtime-D3KV73AE.js +0 -2
  635. package/dist/bundle/chunks/settings-manager-GEOZJXFQ.js +0 -2
  636. package/dist/bundle/chunks/typesafe-system-one-YBEEY5XU.js +0 -2
  637. package/dist/bundle/chunks/virtual-modules-RLC4Y5MX.js +0 -2
  638. package/dist/core/provider-attribution.d.ts +0 -4
  639. package/dist/core/provider-attribution.d.ts.map +0 -1
  640. package/dist/core/provider-attribution.js +0 -72
  641. package/dist/core/provider-attribution.js.map +0 -1
  642. package/dist/experimental/micro/api.d.ts +0 -81
  643. package/dist/experimental/micro/api.d.ts.map +0 -1
  644. package/dist/experimental/micro/api.js +0 -2
  645. package/dist/experimental/micro/api.js.map +0 -1
  646. package/dist/experimental/micro/main.d.ts +0 -3
  647. package/dist/experimental/micro/main.d.ts.map +0 -1
  648. package/dist/experimental/micro/main.js +0 -21
  649. package/dist/experimental/micro/main.js.map +0 -1
  650. package/dist/experimental/micro/models.d.ts +0 -11
  651. package/dist/experimental/micro/models.d.ts.map +0 -1
  652. package/dist/experimental/micro/models.js +0 -95
  653. package/dist/experimental/micro/models.js.map +0 -1
  654. package/dist/experimental/micro/runtime.d.ts +0 -12
  655. package/dist/experimental/micro/runtime.d.ts.map +0 -1
  656. package/dist/experimental/micro/runtime.js +0 -465
  657. package/dist/experimental/micro/runtime.js.map +0 -1
  658. package/dist/experimental/micro/sessions.d.ts +0 -10
  659. package/dist/experimental/micro/sessions.d.ts.map +0 -1
  660. package/dist/experimental/micro/sessions.js +0 -41
  661. package/dist/experimental/micro/sessions.js.map +0 -1
  662. package/dist/experimental/micro/tools.d.ts +0 -10
  663. package/dist/experimental/micro/tools.d.ts.map +0 -1
  664. package/dist/experimental/micro/tools.js +0 -96
  665. package/dist/experimental/micro/tools.js.map +0 -1
  666. package/dist/experimental/micro/tui.d.ts +0 -3
  667. package/dist/experimental/micro/tui.d.ts.map +0 -1
  668. package/dist/experimental/micro/tui.js +0 -510
  669. package/dist/experimental/micro/tui.js.map +0 -1
  670. package/dist/experimental/mini/main.d.ts +0 -7
  671. package/dist/experimental/mini/main.d.ts.map +0 -1
  672. package/dist/experimental/mini/main.js +0 -21
  673. package/dist/experimental/mini/main.js.map +0 -1
  674. package/dist/experimental/mini/server/entry.d.ts +0 -3
  675. package/dist/experimental/mini/server/entry.d.ts.map +0 -1
  676. package/dist/experimental/mini/server/entry.js +0 -11
  677. package/dist/experimental/mini/server/entry.js.map +0 -1
  678. package/dist/experimental/mini/server/run.d.ts +0 -13
  679. package/dist/experimental/mini/server/run.d.ts.map +0 -1
  680. package/dist/experimental/mini/server/run.js +0 -150
  681. package/dist/experimental/mini/server/run.js.map +0 -1
  682. package/dist/experimental/mini/shared/protocol.d.ts +0 -127
  683. package/dist/experimental/mini/shared/protocol.d.ts.map +0 -1
  684. package/dist/experimental/mini/shared/protocol.js +0 -13
  685. package/dist/experimental/mini/shared/protocol.js.map +0 -1
  686. package/dist/experimental/mini/shared/rpc.d.ts +0 -49
  687. package/dist/experimental/mini/shared/rpc.d.ts.map +0 -1
  688. package/dist/experimental/mini/shared/rpc.js +0 -171
  689. package/dist/experimental/mini/shared/rpc.js.map +0 -1
  690. package/dist/experimental/mini/shared/transport.d.ts +0 -35
  691. package/dist/experimental/mini/shared/transport.d.ts.map +0 -1
  692. package/dist/experimental/mini/shared/transport.js +0 -94
  693. package/dist/experimental/mini/shared/transport.js.map +0 -1
  694. package/dist/experimental/mini/tui/run.d.ts +0 -9
  695. package/dist/experimental/mini/tui/run.d.ts.map +0 -1
  696. package/dist/experimental/mini/tui/run.js +0 -62
  697. package/dist/experimental/mini/tui/run.js.map +0 -1
  698. package/dist/experimental/mini/tui/session.d.ts +0 -26
  699. package/dist/experimental/mini/tui/session.d.ts.map +0 -1
  700. package/dist/experimental/mini/tui/session.js +0 -94
  701. package/dist/experimental/mini/tui/session.js.map +0 -1
  702. package/dist/experimental/mini/tui/view.d.ts +0 -10
  703. package/dist/experimental/mini/tui/view.d.ts.map +0 -1
  704. package/dist/experimental/mini/tui/view.js +0 -461
  705. package/dist/experimental/mini/tui/view.js.map +0 -1
  706. package/dist/experimental/mini/worker/entry.d.ts +0 -3
  707. package/dist/experimental/mini/worker/entry.d.ts.map +0 -1
  708. package/dist/experimental/mini/worker/entry.js +0 -10
  709. package/dist/experimental/mini/worker/entry.js.map +0 -1
  710. package/dist/experimental/mini/worker/lane-service.d.ts +0 -44
  711. package/dist/experimental/mini/worker/lane-service.d.ts.map +0 -1
  712. package/dist/experimental/mini/worker/lane-service.js +0 -97
  713. package/dist/experimental/mini/worker/lane-service.js.map +0 -1
  714. package/dist/experimental/mini/worker/models-service.d.ts +0 -19
  715. package/dist/experimental/mini/worker/models-service.d.ts.map +0 -1
  716. package/dist/experimental/mini/worker/models-service.js +0 -136
  717. package/dist/experimental/mini/worker/models-service.js.map +0 -1
  718. package/dist/experimental/mini/worker/run.d.ts +0 -14
  719. package/dist/experimental/mini/worker/run.d.ts.map +0 -1
  720. package/dist/experimental/mini/worker/run.js +0 -88
  721. package/dist/experimental/mini/worker/run.js.map +0 -1
  722. package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
  723. package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
  724. package/dist/modes/interactive/theme/theme-json.js +0 -132
  725. package/dist/modes/interactive/theme/theme-json.js.map +0 -1
  726. package/dist/modes/interactive/theme/theme-schema.json +0 -361
@@ -1 +1 @@
1
- {"version":3,"file":"credential-print.js","sourceRoot":"","sources":["../../src/cli/credential-print.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,gBAAgB,EAAwB,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEvH,MAAM,kCAAkC,GAAG,EAAE,GAAG,MAAM,CAAC;AAUvD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;CAAG;AAElD,MAAM,UAAU,qBAAqB,CAAC,IAAc;IACnD,OAAO,CACN,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAC/G,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB;IACvC,OAAO,CAAC,GAAG,CAAC;IACT,QAAQ;IACR,QAAQ;;6PAEiP,CAAC,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redentialInfo, Model } from \"@draht/ai\";\nimport { APP_NAME } from \"../config.ts\";\nimport { resolveCliModel } from \"../core/model-resolver.ts\";\nimport type { ModelRuntime } from \"../core/model-runtime.ts\";\nimport type { Args } from \"./args.ts\";\nimport { AuthCommandError, type AuthCommandKind, getAuthCredential, validateAuthCommandArgs } from \"./auth-command.ts\";\n\nconst DEFAULT_BEARER_TOKEN_MIN_EXPIRY_MS = 30 * 60_000;\n\ntype CredentialPrintKind = Exclude<AuthCommandKind, \"check\">;\n\nexport interface CredentialPrintCommand {\n\tkind: CredentialPrintKind;\n\targs: string[];\n\tminExpiryMs?: number;\n}\n\nexport class CredentialPrintError extends Error {}\n\nexport function isCredentialPrintHelp(args: string[]): boolean {\n\treturn (\n\t\targs[0] === \"auth\" && (args[1] === undefined || args[1] === \"help\" || args[1] === \"--help\" || args[1] === \"-h\")\n\t);\n}\n\nexport function printCredentialPrintHelp(): void {\n\tconsole.log(`Usage:\n ${APP_NAME} auth print-api-key --model <model> [--provider <provider>]\n ${APP_NAME} auth print-bearer-token --model <model> [--provider <provider>] [--min-expiry <duration>]\n\nPrints the configured credential alone on stdout. Provider inference uses configured credentials; specify --provider to select explicitly. Bearer tokens have a 30-minute minimum expiry by default. --min-expiry accepts ms, s, m, or h (for example, 30m).`);\n}\n\n/** Parse the small, extensible `auth` command surface before normal startup. */\nexport function parseCredentialPrintCommand(args: string[]): CredentialPrintCommand | undefined {\n\tif (args[0] !== \"auth\") return undefined;\n\n\tconst kind = args[1] === \"print-api-key\" ? \"api_key\" : args[1] === \"print-bearer-token\" ? \"bearer_token\" : undefined;\n\tif (!kind) {\n\t\tthrow new CredentialPrintError(\n\t\t\t`Unknown auth command \"${args[1] ?? \"\"}\". Use \"${APP_NAME} auth print-api-key\" or \"${APP_NAME} auth print-bearer-token\".`,\n\t\t);\n\t}\n\n\tconst commandArgs: string[] = [];\n\tlet minExpiryMs: number | undefined;\n\tfor (let index = 2; index < args.length; index++) {\n\t\tif (args[index] !== \"--min-expiry\") {\n\t\t\tcommandArgs.push(args[index]);\n\t\t\tcontinue;\n\t\t}\n\t\tif (kind !== \"bearer_token\") {\n\t\t\tthrow new CredentialPrintError(\"--min-expiry is only supported by print-bearer-token\");\n\t\t}\n\t\tconst value = args[++index];\n\t\tconst match = value ? /^(\\d+)(ms|s|m|h)$/iu.exec(value) : undefined;\n\t\tif (!match) {\n\t\t\tthrow new CredentialPrintError(\"--min-expiry must use a duration such as 30m or 1h\");\n\t\t}\n\t\tconst amount = Number(match[1]);\n\t\tconst unit = match[2];\n\t\tminExpiryMs = amount * (unit === \"ms\" ? 1 : unit === \"s\" ? 1_000 : unit === \"m\" ? 60_000 : 3_600_000);\n\t}\n\n\treturn minExpiryMs === undefined ? { kind, args: commandArgs } : { kind, args: commandArgs, minExpiryMs };\n}\n\nexport function validateCredentialPrintArgs(args: Args): void {\n\tif (!args.model?.trim()) {\n\t\tthrow new CredentialPrintError(\"Credential printing requires --model <model>\");\n\t}\n\tif (args.apiKey !== undefined) {\n\t\tthrow new CredentialPrintError(\"Credential printing reads configured credentials; --api-key is not supported\");\n\t}\n\tif (args.messages.length > 0 || args.fileArgs.length > 0 || args.unknownFlags.size > 0) {\n\t\tthrow new CredentialPrintError(\"Credential printing only accepts --provider and --model\");\n\t}\n}\n\n/**\n * Resolve one configured provider credential.\n *\n * This intentionally calls ModelRuntime.getAuth(), which refreshes and persists\n * OAuth credentials with less than five minutes remaining through the normal request-auth path.\n */\nexport async function resolveCredentialForPrint(\n\targs: Args,\n\tmodelRuntime: ModelRuntime,\n\tkind: CredentialPrintKind,\n\tminExpiryMs?: number,\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tconst { provider: cliProvider, model: cliModel } = validateAuthCommandArgs(args, kind);\n\tconst credentialTypes = new Map<string, CredentialInfo[\"type\"]>(\n\t\t(await modelRuntime.listCredentials({ signal })).map((credential) => [credential.providerId, credential.type]),\n\t);\n\tconst providers: Array<{ id: string; model?: Model<Api> }> = [];\n\tif (cliProvider) {\n\t\tconst provider = modelRuntime.getProvider(cliProvider);\n\t\tif (!provider) {\n\t\t\tthrow new AuthCommandError(`Unknown provider \"${cliProvider}\". Use --list-models to see available providers.`);\n\t\t}\n\t\tif (cliModel) {\n\t\t\tconst resolved = resolveCliModel({ cliProvider: provider.id, cliModel, modelRuntime });\n\t\t\tif (resolved.error || !resolved.model) {\n\t\t\t\tthrow new AuthCommandError(resolved.error ?? \"Unable to resolve the requested provider/model\");\n\t\t\t}\n\t\t\tproviders.push({ id: provider.id, model: resolved.model });\n\t\t} else {\n\t\t\tproviders.push({ id: provider.id });\n\t\t}\n\t} else {\n\t\tfor (const provider of modelRuntime.getProviders()) {\n\t\t\tif (!credentialTypes.has(provider.id)) continue;\n\t\t\tconst resolved = resolveCliModel({ cliProvider: provider.id, cliModel: cliModel!, modelRuntime });\n\t\t\tif (resolved.model && !resolved.error && !resolved.warning?.includes(\"Using custom model id\")) {\n\t\t\t\tproviders.push({ id: provider.id, model: resolved.model });\n\t\t\t}\n\t\t}\n\t\tif (providers.length === 0) {\n\t\t\tthrow new AuthCommandError(`Model \"${cliModel}\" not found. Use --list-models to see available models.`);\n\t\t}\n\t}\n\n\tconst credentials: Array<{ providerId: string; value: string }> = [];\n\tfor (const provider of providers) {\n\t\tconst type = credentialTypes.get(provider.id);\n\t\tif (kind === \"api_key\" && type === \"oauth\") continue;\n\t\tif (kind === \"bearer_token\" && type !== \"oauth\") continue;\n\t\tconst authOptions = {\n\t\t\t...(kind === \"bearer_token\" ? { minOAuthValidityMs: minExpiryMs ?? DEFAULT_BEARER_TOKEN_MIN_EXPIRY_MS } : {}),\n\t\t\tsignal,\n\t\t};\n\t\tconst auth = provider.model\n\t\t\t? await modelRuntime.getAuth(provider.model, authOptions)\n\t\t\t: await modelRuntime.getAuth(provider.id, authOptions);\n\t\tconst value = getAuthCredential(auth);\n\t\tif (value) credentials.push({ providerId: provider.id, value });\n\t}\n\n\tif (credentials.length === 1) return credentials[0].value;\n\tif (credentials.length === 0) {\n\t\tconst providerId = providers[0]?.id;\n\t\tconst type = providerId ? credentialTypes.get(providerId) : undefined;\n\t\tif (cliProvider && kind === \"api_key\" && type === \"oauth\") {\n\t\t\tthrow new AuthCommandError(`Provider \"${providerId}\" is configured with OAuth, not an API key`);\n\t\t}\n\t\tif (cliProvider && kind === \"bearer_token\" && type !== \"oauth\") {\n\t\t\tthrow new AuthCommandError(`Provider \"${providerId}\" is not configured with an OAuth bearer token`);\n\t\t}\n\t\tthrow new AuthCommandError(`No usable ${kind === \"api_key\" ? \"API key\" : \"OAuth bearer token\"} is configured`);\n\t}\n\tthrow new AuthCommandError(\n\t\t`Multiple configured providers matched (${credentials.map(({ providerId }) => providerId).join(\", \")}). Specify --provider.`,\n\t);\n}\n"]}
1
+ {"version":3,"file":"credential-print.js","sourceRoot":"","sources":["../../src/cli/credential-print.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGnF,OAAO,EAAE,gBAAgB,EAAwB,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAEvH,MAAM,kCAAkC,GAAG,EAAE,GAAG,MAAM,CAAC;AAUvD,MAAM,OAAO,oBAAqB,SAAQ,KAAK;CAAG;AAElD,MAAM,UAAU,qBAAqB,CAAC,IAAc;IACnD,OAAO,CACN,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAC/G,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB;IACvC,OAAO,CAAC,GAAG,CAAC;IACT,QAAQ;IACR,QAAQ;;6PAEiP,CAAC,CAAC;A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cesContent":["import type { Api, CredentialInfo, Model } from \"@draht/ai\";\nimport { APP_NAME } from \"../config.ts\";\nimport { resolveCliModel, resolveModelReference } from \"../core/model-resolver.ts\";\nimport type { ModelRuntime } from \"../core/model-runtime.ts\";\nimport type { Args } from \"./args.ts\";\nimport { AuthCommandError, type AuthCommandKind, getAuthCredential, validateAuthCommandArgs } from \"./auth-command.ts\";\n\nconst DEFAULT_BEARER_TOKEN_MIN_EXPIRY_MS = 30 * 60_000;\n\ntype CredentialPrintKind = Exclude<AuthCommandKind, \"check\">;\n\nexport interface CredentialPrintCommand {\n\tkind: CredentialPrintKind;\n\targs: string[];\n\tminExpiryMs?: number;\n}\n\nexport class CredentialPrintError extends Error {}\n\nexport function isCredentialPrintHelp(args: string[]): boolean {\n\treturn (\n\t\targs[0] === \"auth\" && (args[1] === undefined || args[1] === \"help\" || args[1] === \"--help\" || args[1] === \"-h\")\n\t);\n}\n\nexport function printCredentialPrintHelp(): void {\n\tconsole.log(`Usage:\n ${APP_NAME} auth print-api-key --model <model> [--provider <provider>]\n ${APP_NAME} auth print-bearer-token --model <model> [--provider <provider>] [--min-expiry <duration>]\n\nPrints the configured credential alone on stdout. Provider inference uses configured credentials; specify --provider to select explicitly. Bearer tokens have a 30-minute minimum expiry by default. --min-expiry accepts ms, s, m, or h (for example, 30m).`);\n}\n\n/** Parse the small, extensible `auth` command surface before normal startup. */\nexport function parseCredentialPrintCommand(args: string[]): CredentialPrintCommand | undefined {\n\tif (args[0] !== \"auth\") return undefined;\n\n\tconst kind = args[1] === \"print-api-key\" ? \"api_key\" : args[1] === \"print-bearer-token\" ? \"bearer_token\" : undefined;\n\tif (!kind) {\n\t\tthrow new CredentialPrintError(\n\t\t\t`Unknown auth command \"${args[1] ?? \"\"}\". Use \"${APP_NAME} auth print-api-key\" or \"${APP_NAME} auth print-bearer-token\".`,\n\t\t);\n\t}\n\n\tconst commandArgs: string[] = [];\n\tlet minExpiryMs: number | undefined;\n\tfor (let index = 2; index < args.length; index++) {\n\t\tif (args[index] !== \"--min-expiry\") {\n\t\t\tcommandArgs.push(args[index]);\n\t\t\tcontinue;\n\t\t}\n\t\tif (kind !== \"bearer_token\") {\n\t\t\tthrow new CredentialPrintError(\"--min-expiry is only supported by print-bearer-token\");\n\t\t}\n\t\tconst value = args[++index];\n\t\tconst match = value ? /^(\\d+)(ms|s|m|h)$/iu.exec(value) : undefined;\n\t\tif (!match) {\n\t\t\tthrow new CredentialPrintError(\"--min-expiry must use a duration such as 30m or 1h\");\n\t\t}\n\t\tconst amount = Number(match[1]);\n\t\tconst unit = match[2];\n\t\tminExpiryMs = amount * (unit === \"ms\" ? 1 : unit === \"s\" ? 1_000 : unit === \"m\" ? 60_000 : 3_600_000);\n\t}\n\n\treturn minExpiryMs === undefined ? { kind, args: commandArgs } : { kind, args: commandArgs, minExpiryMs };\n}\n\nexport function validateCredentialPrintArgs(args: Args): void {\n\tif (!args.model?.trim()) {\n\t\tthrow new CredentialPrintError(\"Credential printing requires --model <model>\");\n\t}\n\tif (args.apiKey !== undefined) {\n\t\tthrow new CredentialPrintError(\"Credential printing reads configured credentials; --api-key is not supported\");\n\t}\n\tif (args.messages.length > 0 || args.fileArgs.length > 0 || args.unknownFlags.size > 0) {\n\t\tthrow new CredentialPrintError(\"Credential printing only accepts --provider and --model\");\n\t}\n}\n\n/**\n * Resolve one configured provider credential.\n *\n * This intentionally calls ModelRuntime.getAuth(), which refreshes and persists\n * OAuth credentials with less than five minutes remaining through the normal request-auth path.\n */\nexport async function resolveCredentialForPrint(\n\targs: Args,\n\tmodelRuntime: ModelRuntime,\n\tkind: CredentialPrintKind,\n\tminExpiryMs?: number,\n\tsignal?: AbortSignal,\n): Promise<string> {\n\tconst { provider: cliProvider, model: cliModel } = validateAuthCommandArgs(args, kind);\n\tconst credentialTypes = new Map<string, CredentialInfo[\"type\"]>(\n\t\t(await modelRuntime.listCredentials({ signal })).map((credential) => [credential.providerId, credential.type]),\n\t);\n\tconst providers: Array<{ id: string; model?: Model<Api> }> = [];\n\tif (cliProvider) {\n\t\tconst provider = modelRuntime.getProvider(cliProvider);\n\t\tif (!provider) {\n\t\t\tthrow new AuthCommandError(`Unknown provider \"${cliProvider}\". Use --list-models to see available providers.`);\n\t\t}\n\t\tif (cliModel) {\n\t\t\tconst resolved = resolveCliModel({ cliProvider: provider.id, cliModel, modelRuntime });\n\t\t\tif (resolved.error || !resolved.model) {\n\t\t\t\tthrow new AuthCommandError(resolved.error ?? \"Unable to resolve the requested provider/model\");\n\t\t\t}\n\t\t\tproviders.push({ id: provider.id, model: resolved.model });\n\t\t} else {\n\t\t\tproviders.push({ id: provider.id });\n\t\t}\n\t} else {\n\t\tconst models = modelRuntime.getModels();\n\t\tfor (const provider of modelRuntime.getProviders()) {\n\t\t\tif (!credentialTypes.has(provider.id)) continue;\n\t\t\tconst resolved = resolveModelReference(\n\t\t\t\t{ text: cliModel!, provider: provider.id, thinkingSuffix: \"strict\", fuzzy: true },\n\t\t\t\tmodels,\n\t\t\t\t() => true,\n\t\t\t);\n\t\t\tif (resolved.status === \"resolved\") providers.push({ id: provider.id, model: resolved.model });\n\t\t}\n\t\tif (providers.length === 0) {\n\t\t\tthrow new AuthCommandError(`Model \"${cliModel}\" not found. Use --list-models to see available models.`);\n\t\t}\n\t}\n\n\tconst credentials: Array<{ providerId: string; value: string }> = [];\n\tfor (const provider of providers) {\n\t\tconst type = credentialTypes.get(provider.id);\n\t\tif (kind === \"api_key\" && type === \"oauth\") continue;\n\t\tif (kind === \"bearer_token\" && type !== \"oauth\") continue;\n\t\tconst authOptions = {\n\t\t\t...(kind === \"bearer_token\" ? { minOAuthValidityMs: minExpiryMs ?? DEFAULT_BEARER_TOKEN_MIN_EXPIRY_MS } : {}),\n\t\t\tsignal,\n\t\t};\n\t\tconst auth = provider.model\n\t\t\t? await modelRuntime.getAuth(provider.model, authOptions)\n\t\t\t: await modelRuntime.getAuth(provider.id, authOptions);\n\t\tconst value = getAuthCredential(auth);\n\t\tif (value) credentials.push({ providerId: provider.id, value });\n\t}\n\n\tif (credentials.length === 1) return credentials[0].value;\n\tif (credentials.length === 0) {\n\t\tconst providerId = providers[0]?.id;\n\t\tconst type = providerId ? credentialTypes.get(providerId) : undefined;\n\t\tif (cliProvider && kind === \"api_key\" && type === \"oauth\") {\n\t\t\tthrow new AuthCommandError(`Provider \"${providerId}\" is configured with OAuth, not an API key`);\n\t\t}\n\t\tif (cliProvider && kind === \"bearer_token\" && type !== \"oauth\") {\n\t\t\tthrow new AuthCommandError(`Provider \"${providerId}\" is not configured with an OAuth bearer token`);\n\t\t}\n\t\tthrow new AuthCommandError(`No usable ${kind === \"api_key\" ? \"API key\" : \"OAuth bearer token\"} is configured`);\n\t}\n\tthrow new AuthCommandError(\n\t\t`Multiple configured providers matched (${credentials.map(({ providerId }) => providerId).join(\", \")}). Specify --provider.`,\n\t);\n}\n"]}
package/dist/config.d.ts CHANGED
@@ -72,7 +72,10 @@ export declare function getInteractiveAssetsDir(): string;
72
72
  export declare function getBundledInteractiveAssetPath(name: string): string;
73
73
  /** Called by the Bun entry with the path of the QuickJS wasm file embedded in the compiled executable. */
74
74
  export declare function setEmbeddedQuickJSWasmPath(path: string): void;
75
- /** Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. */
75
+ /**
76
+ * Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. Resolved once so the
77
+ * compiled module cached per path keeps working after an update removes this install (badlogic/pi-mono#10439).
78
+ */
76
79
  export declare function getQuickJSWasmPath(): string;
77
80
  /** Resolve the codemode worker entry for a release runtime. */
78
81
  export declare function resolveCodemodeWorkerSpecifier(runtime: "bun-binary" | "bundled-node" | "unbundled", moduleUrl: string): string | URL | undefined;
@@ -81,6 +84,20 @@ export declare function resolveCodemodeWorkerSpecifier(runtime: "bun-binary" | "
81
84
  * The Bun and Node release builds both pass the worker as an extra entrypoint.
82
85
  */
83
86
  export declare function getCodemodeWorkerSpecifier(): string | URL | undefined;
87
+ export type InstallChange = {
88
+ kind: "updated";
89
+ version: string;
90
+ } | {
91
+ kind: "removed";
92
+ };
93
+ /**
94
+ * Detect that the package this process runs from changed on disk, for example after `draht update`
95
+ * in another terminal. Code loaded on demand can then be missing or from another version.
96
+ *
97
+ * Checks the package.json read at startup. Resolving it again would walk up past a deleted install
98
+ * and could find an unrelated package.json, such as one in the home directory.
99
+ */
100
+ export declare function detectInstallChange(packageJsonPath?: string | undefined): InstallChange | undefined;
84
101
  export declare const PACKAGE_NAME: string;
85
102
  export declare const APP_NAME: string;
86
103
  export declare const APP_TITLE: string;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAgBA;;;GAGG;AACH,eAAO,MAAM,WAAW,SACqF,CAAC;AAE9G,gEAAgE;AAChE,eAAO,MAAM,YAAY,SAAyB,CAAC;AAInD,eAAO,MAAM,aAAa,SAAkE,CAAC;AAM7F,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,SAAS,CAAC;AAEvF,UAAU,qBAAqB;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAkB,SAAQ,qBAAqB;IAC/D,KAAK,CAAC,EAAE,qBAAqB,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,uBAAuB,GAAG,MAAM,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAgC7F,wBAAgB,mBAAmB,IAAI,aAAa,CAqBnD;AA6ND,wBAAgB,oBAAoB,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE,MAAM,EAAE,EACrB,mBAAmB,GAAE,uBAAqC,GACxD,iBAAiB,GAAG,SAAS,CAO/B;AAED,wBAAgB,mCAAmC,CAClD,WAAW,EA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CHANGED
@@ -404,14 +404,18 @@ export function getInteractiveAssetsDir() {
404
404
  export function getBundledInteractiveAssetPath(name) {
405
405
  return join(getInteractiveAssetsDir(), name);
406
406
  }
407
- let embeddedQuickJSWasmPath;
407
+ let quickJSWasmPath;
408
408
  /** Called by the Bun entry with the path of the QuickJS wasm file embedded in the compiled executable. */
409
409
  export function setEmbeddedQuickJSWasmPath(path) {
410
- embeddedQuickJSWasmPath = path;
410
+ quickJSWasmPath = path;
411
411
  }
412
- /** Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. */
412
+ /**
413
+ * Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. Resolved once so the
414
+ * compiled module cached per path keeps working after an update removes this install (badlogic/pi-mono#10439).
415
+ */
413
416
  export function getQuickJSWasmPath() {
414
- return embeddedQuickJSWasmPath ?? createRequire(import.meta.url).resolve("quickjs-wasi/quickjs.wasm");
417
+ quickJSWasmPath ??= createRequire(import.meta.url).resolve("quickjs-wasi/quickjs.wasm");
418
+ return quickJSWasmPath;
415
419
  }
416
420
  /** Resolve the codemode worker entry for a release runtime. */
417
421
  export function resolveCodemodeWorkerSpecifier(runtime, moduleUrl) {
@@ -424,17 +428,51 @@ export function resolveCodemodeWorkerSpecifier(runtime, moduleUrl) {
424
428
  return new URL("./codemode-worker.js", moduleUrl);
425
429
  return undefined;
426
430
  }
431
+ let codemodeWorkerDataUrl;
427
432
  /**
428
433
  * Get the codemode worker entry, or undefined to use the worker that ships next to @draht/codemode.
429
434
  * The Bun and Node release builds both pass the worker as an extra entrypoint.
430
435
  */
431
436
  export function getCodemodeWorkerSpecifier() {
432
437
  const runtime = isBunBinary ? "bun-binary" : isBundledNode ? "bundled-node" : "unbundled";
433
- return resolveCodemodeWorkerSpecifier(runtime, import.meta.url);
438
+ const specifier = resolveCodemodeWorkerSpecifier(runtime, import.meta.url);
439
+ if (runtime !== "bundled-node" || !(specifier instanceof URL))
440
+ return specifier;
441
+ // Spawn workers from an in-memory copy. An update replaces or deletes the file while this
442
+ // process keeps running (badlogic/pi-mono#10439). The bundle build keeps the worker free of relative imports
443
+ // and import.meta, so it runs from a data: URL.
444
+ codemodeWorkerDataUrl ??= new URL(`data:text/javascript;base64,${readFileSync(specifier).toString("base64")}`);
445
+ return codemodeWorkerDataUrl;
446
+ }
447
+ /**
448
+ * Detect that the package this process runs from changed on disk, for example after `draht update`
449
+ * in another terminal. Code loaded on demand can then be missing or from another version.
450
+ *
451
+ * Checks the package.json read at startup. Resolving it again would walk up past a deleted install
452
+ * and could find an unrelated package.json, such as one in the home directory.
453
+ */
454
+ export function detectInstallChange(packageJsonPath = startupPackageJsonPath) {
455
+ // The Bun binary embeds its code, so replacing the executable does not affect this process.
456
+ if (isBunBinary || !packageJsonPath)
457
+ return undefined;
458
+ let installed;
459
+ try {
460
+ installed = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
461
+ }
462
+ catch (error) {
463
+ return error.code === "ENOENT" ? { kind: "removed" } : undefined;
464
+ }
465
+ return installed.version && installed.version !== VERSION
466
+ ? { kind: "updated", version: installed.version }
467
+ : undefined;
434
468
  }
435
469
  let pkg = {};
470
+ /** The package.json this process started from, if one existed. */
471
+ let startupPackageJsonPath;
436
472
  try {
437
- pkg = JSON.parse(stripBom(readFileSync(getPackageJsonPath(), "utf-8")));
473
+ const packageJsonPath = getPackageJsonPath();
474
+ pkg = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
475
+ startupPackageJsonPath = packageJsonPath;
438
476
  }
439
477
  catch (e) {
440
478
  const err = e;
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAA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AM,UAAU,eAAe;IAC9B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,eAAe,CAAC,CAAC;AAC7C,CAAC;AAED,kCAAkC;AAClC,MAAM,UAAU,WAAW;IAC1B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,OAAO,CAAC,CAAC;AACrC,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,SAAS;IACxB,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,aAAa;IAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,oBAAoB;IACnC,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,mBAAmB;IAClC,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc;IAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe;IAC9B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { accessSync, constants, existsSync, readFileSync, realpathSync } from \"fs\";\nimport { createRequire } from \"module\";\nimport { homedir } from \"os\";\nimport { basename, dirname, join, resolve, sep, win32 } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { spawnProcessSync } from \"./utils/child-process.ts\";\nimport { normalizePath } from \"./utils/paths.ts\";\nimport { stripBom } from \"./utils/text.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n/** Detect the esbuild-bundled Node.js distribution. */\ndeclare const DRAHT_BUNDLED_NODE: boolean;\nexport const isBundledNode = typeof DRAHT_BUNDLED_NODE !== \"undefined\" && DRAHT_BUNDLED_NODE;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\ninterface SelfUpdateCommandStep {\n\tcommand: string;\n\targs: string[];\n\tdisplay: string;\n}\n\nexport interface SelfUpdateCommand extends SelfUpdateCommandStep {\n\tsteps?: SelfUpdateCommandStep[];\n}\n\nexport type SelfUpdatePackageTarget = string | { packageName: string; installSpec?: string };\n\nfunction normalizeSelfUpdatePackageTarget(target: SelfUpdatePackageTarget): {\n\tpackageName: string;\n\tinstallSpec: string;\n} {\n\tif (typeof target === \"string\") {\n\t\treturn { packageName: target, installSpec: target };\n\t}\n\treturn { packageName: target.packageName, installSpec: target.installSpec ?? target.packageName };\n}\n\nfunction makeSelfUpdateCommand(\n\tinstallStep: SelfUpdateCommandStep,\n\tuninstallStep?: SelfUpdateCommandStep,\n): SelfUpdateCommand {\n\tif (!uninstallStep) return installStep;\n\treturn {\n\t\t...installStep,\n\t\tdisplay: `${uninstallStep.display} && ${installStep.display}`,\n\t\tsteps: [uninstallStep, installStep],\n\t};\n}\n\nfunction makeSelfUpdateCommandStep(command: string, args: string[]): SelfUpdateCommandStep {\n\treturn {\n\t\tcommand,\n\t\targs,\n\t\tdisplay: [command, ...args].map((arg) => (/\\s/.test(arg) ? `\"${arg}\"` : arg)).join(\" \"),\n\t};\n}\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase().replace(/\\\\/g, \"/\");\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime || resolvedPath.includes(\"/install/global/node_modules/\")) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nfunction getInferredNpmInstall(): { root: string; prefix: string } | undefined {\n\tconst packageDir = getPackageDir();\n\tconst path = process.platform === \"win32\" || packageDir.includes(\"\\\\\") ? win32 : { basename, dirname };\n\tconst parent = path.dirname(packageDir);\n\tlet root: string | undefined;\n\tif (path.basename(parent).startsWith(\"@\") && path.basename(path.dirname(parent)) === \"node_modules\") {\n\t\troot = path.dirname(parent);\n\t} else if (path.basename(parent) === \"node_modules\") {\n\t\troot = parent;\n\t}\n\tif (!root) return undefined;\n\tconst rootParent = path.dirname(root);\n\tif (path.basename(rootParent) === \"lib\") return { root, prefix: path.dirname(rootParent) };\n\t// Windows global npm prefixes use `<prefix>\\\\node_modules`, which is\n\t// indistinguishable from local project installs by path shape alone. Do not\n\t// infer unsupported Windows custom prefixes without `npm root -g` evidence.\n\treturn undefined;\n}\n\nfunction getSelfUpdateCommandForMethod(\n\tmethod: InstallMethod,\n\tinstalledPackageName: string,\n\tupdatePackageTarget: SelfUpdatePackageTarget = installedPackageName,\n\tnpmCommand?: string[],\n): SelfUpdateCommand | undefined {\n\tconst target = normalizeSelfUpdatePackageTarget(updatePackageTarget);\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn undefined;\n\t\tcase \"pnpm\": {\n\t\t\tconst match = readCommandOutput(\"pnpm\", [\"root\", \"-g\"])\n\t\t\t\t? undefined\n\t\t\t\t: /^(.*[\\\\/]global[\\\\/][^\\\\/]+)[\\\\/]\\.pnpm[\\\\/]/.exec(getPackageDir());\n\t\t\tconst binDirArgs = match\n\t\t\t\t? [`--config.global-bin-dir=${process.env.PNPM_HOME || dirname(dirname(match[1]))}`]\n\t\t\t\t: [];\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"pnpm\", [\n\t\t\t\t\t\"install\",\n\t\t\t\t\t\"-g\",\n\t\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\t\"--config.minimumReleaseAge=0\",\n\t\t\t\t\t...binDirArgs,\n\t\t\t\t\ttarget.installSpec,\n\t\t\t\t]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"pnpm\", [\"remove\", \"-g\", ...binDirArgs, installedPackageName]),\n\t\t\t);\n\t\t}\n\t\tcase \"yarn\":\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"yarn\", [\"global\", \"add\", \"--ignore-scripts\", target.installSpec]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"yarn\", [\"global\", \"remove\", installedPackageName]),\n\t\t\t);\n\t\tcase \"bun\":\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"bun\", [\n\t\t\t\t\t\"install\",\n\t\t\t\t\t\"-g\",\n\t\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\t\"--minimum-release-age=0\",\n\t\t\t\t\ttarget.installSpec,\n\t\t\t\t]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"bun\", [\"uninstall\", \"-g\", installedPackageName]),\n\t\t\t);\n\t\tcase \"npm\": {\n\t\t\tconst [command = \"npm\", ...npmArgs] = npmCommand ?? [];\n\t\t\tconst inferred = npmCommand?.length ? undefined : getInferredNpmInstall();\n\t\t\tconst prefixArgs = [...npmArgs, ...(inferred ? [\"--prefix\", inferred.prefix] : [])];\n\t\t\tconst installStep = makeSelfUpdateCommandStep(command, [\n\t\t\t\t...prefixArgs,\n\t\t\t\t\"install\",\n\t\t\t\t\"-g\",\n\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\"--min-release-age=0\",\n\t\t\t\ttarget.installSpec,\n\t\t\t]);\n\t\t\tconst uninstallStep =\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(command, [...prefixArgs, \"uninstall\", \"-g\", installedPackageName]);\n\t\t\treturn makeSelfUpdateCommand(installStep, uninstallStep);\n\t\t}\n\t\tcase \"unknown\":\n\t\t\treturn undefined;\n\t}\n}\n\nfunction readCommandOutput(\n\tcommand: string,\n\targs: string[],\n\toptions: { requireSuccess?: boolean } = {},\n): string | undefined {\n\tconst result = spawnProcessSync(command, args, {\n\t\tencoding: \"utf-8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\tif (result.status === 0) return result.stdout.trim() || undefined;\n\tif (options.requireSuccess) {\n\t\tconst reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? \"unknown\"}`;\n\t\tthrow new Error(`Failed to run ${[command, ...args].join(\" \")}: ${reason}`);\n\t}\n\treturn undefined;\n}\n\nfunction getGlobalPackageRoots(method: InstallMethod, _packageName: string, npmCommand?: string[]): string[] {\n\tswitch (method) {\n\t\tcase \"npm\": {\n\t\t\tconst configured = !!npmCommand?.length;\n\t\t\tconst [command = \"npm\", ...npmArgs] = npmCommand ?? [];\n\t\t\tif (configured && command === \"bun\") {\n\t\t\t\tconst bunBin = readCommandOutput(command, [...npmArgs, \"pm\", \"bin\", \"-g\"], {\n\t\t\t\t\trequireSuccess: true,\n\t\t\t\t});\n\t\t\t\tconst roots = [join(homedir(), \".bun\", \"install\", \"global\", \"node_modules\")];\n\t\t\t\tif (bunBin) {\n\t\t\t\t\troots.push(join(dirname(bunBin), \"install\", \"global\", \"node_modules\"));\n\t\t\t\t}\n\t\t\t\treturn roots;\n\t\t\t}\n\t\t\tconst root = readCommandOutput(command, [...npmArgs, \"root\", \"-g\"], {\n\t\t\t\trequireSuccess: configured,\n\t\t\t});\n\t\t\tconst inferred = configured ? undefined : getInferredNpmInstall();\n\t\t\treturn [root, inferred?.root].filter((x): x is string => !!x);\n\t\t}\n\t\tcase \"pnpm\": {\n\t\t\tconst root = readCommandOutput(\"pnpm\", [\"root\", \"-g\"]);\n\t\t\tif (root) return [root, dirname(root)];\n\t\t\tconst match = /^(.*[\\\\/]global[\\\\/][^\\\\/]+)[\\\\/]\\.pnpm[\\\\/]/.exec(getPackageDir());\n\t\t\treturn match ? [match[1]] : [];\n\t\t}\n\t\tcase \"yarn\": {\n\t\t\tconst dir = readCommandOutput(\"yarn\", [\"global\", \"dir\"]);\n\t\t\treturn dir ? [dir, join(dir, \"node_modules\")] : [];\n\t\t}\n\t\tcase \"bun\": {\n\t\t\tconst bunBin = readCommandOutput(\"bun\", [\"pm\", \"bin\", \"-g\"]);\n\t\t\tconst roots = [join(homedir(), \".bun\", \"install\", \"global\", \"node_modules\")];\n\t\t\tif (bunBin) {\n\t\t\t\troots.push(join(dirname(bunBin), \"install\", \"global\", \"node_modules\"));\n\t\t\t}\n\t\t\treturn roots;\n\t\t}\n\t\tcase \"bun-binary\":\n\t\tcase \"unknown\":\n\t\t\treturn [];\n\t}\n}\n\nfunction normalizeExistingPathForComparison(path: string, resolveSymlinks: boolean): string | undefined {\n\tconst resolvedPath = resolve(path);\n\tif (!existsSync(resolvedPath)) {\n\t\treturn undefined;\n\t}\n\tlet normalizedPath = resolvedPath;\n\tif (resolveSymlinks) {\n\t\ttry {\n\t\t\tnormalizedPath = realpathSync(resolvedPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\tif (process.platform === \"win32\") {\n\t\tnormalizedPath = normalizedPath.toLowerCase();\n\t}\n\treturn normalizedPath;\n}\n\nfunction getPathComparisonCandidates(path: string): string[] {\n\treturn Array.from(\n\t\tnew Set(\n\t\t\t[normalizeExistingPathForComparison(path, false), normalizeExistingPathForComparison(path, true)].filter(\n\t\t\t\t(candidate): candidate is string => !!candidate,\n\t\t\t),\n\t\t),\n\t);\n}\n\nfunction getEntrypointPackageDir(): string | undefined {\n\tconst entrypoint = process.argv[1];\n\tif (!entrypoint) return undefined;\n\tlet dir = dirname(entrypoint);\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn undefined;\n}\n\nfunction isSelfUpdatePathWritable(): boolean {\n\tconst packageDir = getPackageDir();\n\ttry {\n\t\taccessSync(packageDir, constants.W_OK);\n\t\taccessSync(dirname(packageDir), constants.W_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isManagedByGlobalPackageManager(method: InstallMethod, packageName: string, npmCommand?: string[]): boolean {\n\tconst packageDirs = [getPackageDir(), getEntrypointPackageDir()].filter((dir): dir is string => !!dir);\n\tconst packageDirCandidates = packageDirs.flatMap((dir) => getPathComparisonCandidates(dir));\n\treturn getGlobalPackageRoots(method, packageName, npmCommand).some((root) => {\n\t\treturn getPathComparisonCandidates(root).some((normalizedRoot) => {\n\t\t\tconst rootPrefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\t\treturn packageDirCandidates.some((packageDir) => packageDir.startsWith(rootPrefix));\n\t\t});\n\t});\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = packageName,\n): SelfUpdateCommand | undefined {\n\tconst method = detectInstallMethod();\n\tconst command = getSelfUpdateCommandForMethod(method, packageName, updatePackageTarget, npmCommand);\n\tif (!command || !isManagedByGlobalPackageManager(method, packageName, npmCommand) || !isSelfUpdatePathWritable()) {\n\t\treturn undefined;\n\t}\n\treturn command;\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = packageName,\n): string {\n\tconst method = detectInstallMethod();\n\tconst target = normalizeSelfUpdatePackageTarget(updatePackageTarget);\n\tif (method === \"bun-binary\") {\n\t\treturn `Download from: https://github.com/draht-dev/draht/releases/latest`;\n\t}\n\tconst command = getSelfUpdateCommandForMethod(method, packageName, target, npmCommand);\n\tif (command) {\n\t\tif (isManagedByGlobalPackageManager(method, packageName, npmCommand) && !isSelfUpdatePathWritable()) {\n\t\t\treturn `This installation is managed by a global ${method} install, but the install path is not writable. Update it yourself with: ${command.display}`;\n\t\t}\n\t\treturn `This installation is not managed by a global ${method} install. Update it with the package manager, wrapper, or source checkout that provides it.`;\n\t}\n\treturn `Update ${target.installSpec} using the package manager, wrapper, or source checkout that provides this installation.`;\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tconst command = getSelfUpdateCommandForMethod(method, packageName);\n\tif (command) {\n\t\treturn `Run: ${command.display}`;\n\t}\n\treturn getSelfUpdateUnavailableInstruction(packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js: walks up from `__dirname` to the nearest ancestor with a `package.json`, skipping\n * an emitted `dist/` bundle directory so it resolves to the package root even from the bundled CLI\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\treturn findPackageRoot(__dirname);\n}\n\n/**\n * Is `dir` the emitted `dist/` bundle rather than the package root?\n *\n * `build:binary` copies `package.json` into `dist/` because the compiled binary\n * lives there and resolves its assets relative to itself. That copy is not a\n * package root: the Node entrypoint `dist/cli.js` sits beside it, so a naive\n * upward walk stops one level too low and every asset path gains a phantom\n * `dist/` segment (`dist/dist/modes/interactive/theme/dark.json`). Recognising\n * the copy is what lets `node dist/cli.js` and the compiled `dist/draht` both\n * work from one build tree instead of one invalidating the other.\n */\nfunction isEmittedBundleDir(dir: string): boolean {\n\treturn basename(dir) === \"dist\" && existsSync(join(dirname(dir), \"package.json\"));\n}\n\n/**\n * Nearest ancestor of `startDir` (inclusive) that is a real package root.\n *\n * @param startDir - Directory to start the upward walk from.\n * @returns The package root, or `startDir` when no `package.json` exists above it.\n */\nexport function findPackageRoot(startDir: string): string {\n\tlet dir = startDir;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\")) && !isEmittedBundleDir(dir)) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn startDir;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\nlet embeddedQuickJSWasmPath: string | undefined;\n\n/** Called by the Bun entry with the path of the QuickJS wasm file embedded in the compiled executable. */\nexport function setEmbeddedQuickJSWasmPath(path: string): void {\n\tembeddedQuickJSWasmPath = path;\n}\n\n/** Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. */\nexport function getQuickJSWasmPath(): string {\n\treturn embeddedQuickJSWasmPath ?? createRequire(import.meta.url).resolve(\"quickjs-wasi/quickjs.wasm\");\n}\n\n/** Resolve the codemode worker entry for a release runtime. */\nexport function resolveCodemodeWorkerSpecifier(\n\truntime: \"bun-binary\" | \"bundled-node\" | \"unbundled\",\n\tmoduleUrl: string,\n): string | URL | undefined {\n\t// Bun embeds explicit source entrypoints, but on Windows Bun 1.3 cannot map an absolute\n\t// B:\\~BUN URL back to one. A relative string with the original source extension works on\n\t// every Bun platform.\n\tif (runtime === \"bun-binary\") return \"./src/extensions/codemode/worker.ts\";\n\tif (runtime === \"bundled-node\") return new URL(\"./codemode-worker.js\", moduleUrl);\n\treturn undefined;\n}\n\n/**\n * Get the codemode worker entry, or undefined to use the worker that ships next to @draht/codemode.\n * The Bun and Node release builds both pass the worker as an extra entrypoint.\n */\nexport function getCodemodeWorkerSpecifier(): string | URL | undefined {\n\tconst runtime = isBunBinary ? \"bun-binary\" : isBundledNode ? \"bundled-node\" : \"unbundled\";\n\treturn resolveCodemodeWorkerSpecifier(runtime, import.meta.url);\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\ninterface PackageJson {\n\tname?: string;\n\tversion?: string;\n\tdrahtConfig?: {\n\t\tname?: string;\n\t\tconfigDir?: string;\n\t};\n}\n\nlet pkg: PackageJson = {};\ntry {\n\tpkg = JSON.parse(stripBom(readFileSync(getPackageJsonPath(), \"utf-8\"))) as PackageJson;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nconst drahtConfigName: string | undefined = pkg.drahtConfig?.name;\nexport const PACKAGE_NAME: string = pkg.name || \"@draht/coding-agent\";\nexport const APP_NAME: string = drahtConfigName || \"draht\";\nexport const APP_TITLE: string = drahtConfigName ? APP_NAME : \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const VERSION: string = pkg.version || \"0.0.0\";\n\n/** True when running from source (src/ directory exists), not a compiled/installed build. */\nexport const IS_DEV_MODE: boolean = existsSync(join(getPackageDir(), \"src\"));\n\n/** Version string for display. \"dev\" in dev mode, the package version otherwise. */\nexport const DISPLAY_VERSION: string = IS_DEV_MODE ? \"dev\" : VERSION;\n\n/**\n * Resolve the project config directory. Prefers CONFIG_DIR_NAME (.draht),\n * falls back to LEGACY_CONFIG_DIR_NAME (.pi) if the primary doesn't exist.\n */\nexport function getProjectConfigDir(cwd: string): string {\n\tconst primary = join(cwd, CONFIG_DIR_NAME);\n\tif (existsSync(primary)) return primary;\n\tconst legacy = join(cwd, LEGACY_CONFIG_DIR_NAME);\n\tif (existsSync(legacy)) return legacy;\n\treturn primary;\n}\n\n// e.g., DRAHT_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_SESSION_DIR`;\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\n/**\n * draht has no pi.dev-equivalent share viewer. Returns undefined unless\n * DRAHT_SHARE_VIEWER_URL is set, in which case callers should present the\n * gist URL directly instead.\n */\nexport function getShareViewerUrl(gistId: string): string | undefined {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL?.trim();\n\tif (!baseUrl) return undefined;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to shipped prompts directory (bundled with the package). */\nexport function getShippedPromptsDir(): string {\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/** Get path to shipped skills directory (bundled with the package). */\nexport function getShippedSkillsDir(): string {\n\treturn join(getPackageDir(), \"skills\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAA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;AACnC,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,aAAa;IAC5B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,SAAS,CAAC,CAAC;AACvC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,oBAAoB;IACnC,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,SAAS,CAAC,CAAC;AACzC,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,mBAAmB;IAClC,OAAO,IAAI,CAAC,aAAa,EAAE,EAAE,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,qCAAqC;AACrC,MAAM,UAAU,cAAc;IAC7B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,UAAU,CAAC,CAAC;AACxC,CAAC;AAED,iCAAiC;AACjC,MAAM,UAAU,eAAe;IAC9B,OAAO,IAAI,CAAC,WAAW,EAAE,EAAE,GAAG,QAAQ,YAAY,CAAC,CAAC;AACrD,CAAC","sourcesContent":["import { accessSync, constants, existsSync, readFileSync, realpathSync } from \"fs\";\nimport { createRequire } from \"module\";\nimport { homedir } from \"os\";\nimport { basename, dirname, join, resolve, sep, win32 } from \"path\";\nimport { fileURLToPath } from \"url\";\nimport { spawnProcessSync } from \"./utils/child-process.ts\";\nimport { normalizePath } from \"./utils/paths.ts\";\nimport { stripBom } from \"./utils/text.ts\";\n\n// =============================================================================\n// Package Detection\n// =============================================================================\n\nconst __filename = fileURLToPath(import.meta.url);\nconst __dirname = dirname(__filename);\n\n/**\n * Detect if we're running as a Bun compiled binary.\n * Bun binaries have import.meta.url containing \"$bunfs\", \"~BUN\", or \"%7EBUN\" (Bun's virtual filesystem path)\n */\nexport const isBunBinary =\n\timport.meta.url.includes(\"$bunfs\") || import.meta.url.includes(\"~BUN\") || import.meta.url.includes(\"%7EBUN\");\n\n/** Detect if Bun is the runtime (compiled binary or bun run) */\nexport const isBunRuntime = !!process.versions.bun;\n\n/** Detect the esbuild-bundled Node.js distribution. */\ndeclare const DRAHT_BUNDLED_NODE: boolean;\nexport const isBundledNode = typeof DRAHT_BUNDLED_NODE !== \"undefined\" && DRAHT_BUNDLED_NODE;\n\n// =============================================================================\n// Install Method Detection\n// =============================================================================\n\nexport type InstallMethod = \"bun-binary\" | \"npm\" | \"pnpm\" | \"yarn\" | \"bun\" | \"unknown\";\n\ninterface SelfUpdateCommandStep {\n\tcommand: string;\n\targs: string[];\n\tdisplay: string;\n}\n\nexport interface SelfUpdateCommand extends SelfUpdateCommandStep {\n\tsteps?: SelfUpdateCommandStep[];\n}\n\nexport type SelfUpdatePackageTarget = string | { packageName: string; installSpec?: string };\n\nfunction normalizeSelfUpdatePackageTarget(target: SelfUpdatePackageTarget): {\n\tpackageName: string;\n\tinstallSpec: string;\n} {\n\tif (typeof target === \"string\") {\n\t\treturn { packageName: target, installSpec: target };\n\t}\n\treturn { packageName: target.packageName, installSpec: target.installSpec ?? target.packageName };\n}\n\nfunction makeSelfUpdateCommand(\n\tinstallStep: SelfUpdateCommandStep,\n\tuninstallStep?: SelfUpdateCommandStep,\n): SelfUpdateCommand {\n\tif (!uninstallStep) return installStep;\n\treturn {\n\t\t...installStep,\n\t\tdisplay: `${uninstallStep.display} && ${installStep.display}`,\n\t\tsteps: [uninstallStep, installStep],\n\t};\n}\n\nfunction makeSelfUpdateCommandStep(command: string, args: string[]): SelfUpdateCommandStep {\n\treturn {\n\t\tcommand,\n\t\targs,\n\t\tdisplay: [command, ...args].map((arg) => (/\\s/.test(arg) ? `\"${arg}\"` : arg)).join(\" \"),\n\t};\n}\n\nexport function detectInstallMethod(): InstallMethod {\n\tif (isBunBinary) {\n\t\treturn \"bun-binary\";\n\t}\n\n\tconst resolvedPath = `${__dirname}\\0${process.execPath || \"\"}`.toLowerCase().replace(/\\\\/g, \"/\");\n\n\tif (resolvedPath.includes(\"/pnpm/\") || resolvedPath.includes(\"/.pnpm/\")) {\n\t\treturn \"pnpm\";\n\t}\n\tif (resolvedPath.includes(\"/yarn/\") || resolvedPath.includes(\"/.yarn/\")) {\n\t\treturn \"yarn\";\n\t}\n\tif (isBunRuntime || resolvedPath.includes(\"/install/global/node_modules/\")) {\n\t\treturn \"bun\";\n\t}\n\tif (resolvedPath.includes(\"/npm/\") || resolvedPath.includes(\"/node_modules/\")) {\n\t\treturn \"npm\";\n\t}\n\n\treturn \"unknown\";\n}\n\nfunction getInferredNpmInstall(): { root: string; prefix: string } | undefined {\n\tconst packageDir = getPackageDir();\n\tconst path = process.platform === \"win32\" || packageDir.includes(\"\\\\\") ? win32 : { basename, dirname };\n\tconst parent = path.dirname(packageDir);\n\tlet root: string | undefined;\n\tif (path.basename(parent).startsWith(\"@\") && path.basename(path.dirname(parent)) === \"node_modules\") {\n\t\troot = path.dirname(parent);\n\t} else if (path.basename(parent) === \"node_modules\") {\n\t\troot = parent;\n\t}\n\tif (!root) return undefined;\n\tconst rootParent = path.dirname(root);\n\tif (path.basename(rootParent) === \"lib\") return { root, prefix: path.dirname(rootParent) };\n\t// Windows global npm prefixes use `<prefix>\\\\node_modules`, which is\n\t// indistinguishable from local project installs by path shape alone. Do not\n\t// infer unsupported Windows custom prefixes without `npm root -g` evidence.\n\treturn undefined;\n}\n\nfunction getSelfUpdateCommandForMethod(\n\tmethod: InstallMethod,\n\tinstalledPackageName: string,\n\tupdatePackageTarget: SelfUpdatePackageTarget = installedPackageName,\n\tnpmCommand?: string[],\n): SelfUpdateCommand | undefined {\n\tconst target = normalizeSelfUpdatePackageTarget(updatePackageTarget);\n\tswitch (method) {\n\t\tcase \"bun-binary\":\n\t\t\treturn undefined;\n\t\tcase \"pnpm\": {\n\t\t\tconst match = readCommandOutput(\"pnpm\", [\"root\", \"-g\"])\n\t\t\t\t? undefined\n\t\t\t\t: /^(.*[\\\\/]global[\\\\/][^\\\\/]+)[\\\\/]\\.pnpm[\\\\/]/.exec(getPackageDir());\n\t\t\tconst binDirArgs = match\n\t\t\t\t? [`--config.global-bin-dir=${process.env.PNPM_HOME || dirname(dirname(match[1]))}`]\n\t\t\t\t: [];\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"pnpm\", [\n\t\t\t\t\t\"install\",\n\t\t\t\t\t\"-g\",\n\t\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\t\"--config.minimumReleaseAge=0\",\n\t\t\t\t\t...binDirArgs,\n\t\t\t\t\ttarget.installSpec,\n\t\t\t\t]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"pnpm\", [\"remove\", \"-g\", ...binDirArgs, installedPackageName]),\n\t\t\t);\n\t\t}\n\t\tcase \"yarn\":\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"yarn\", [\"global\", \"add\", \"--ignore-scripts\", target.installSpec]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"yarn\", [\"global\", \"remove\", installedPackageName]),\n\t\t\t);\n\t\tcase \"bun\":\n\t\t\treturn makeSelfUpdateCommand(\n\t\t\t\tmakeSelfUpdateCommandStep(\"bun\", [\n\t\t\t\t\t\"install\",\n\t\t\t\t\t\"-g\",\n\t\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\t\"--minimum-release-age=0\",\n\t\t\t\t\ttarget.installSpec,\n\t\t\t\t]),\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(\"bun\", [\"uninstall\", \"-g\", installedPackageName]),\n\t\t\t);\n\t\tcase \"npm\": {\n\t\t\tconst [command = \"npm\", ...npmArgs] = npmCommand ?? [];\n\t\t\tconst inferred = npmCommand?.length ? undefined : getInferredNpmInstall();\n\t\t\tconst prefixArgs = [...npmArgs, ...(inferred ? [\"--prefix\", inferred.prefix] : [])];\n\t\t\tconst installStep = makeSelfUpdateCommandStep(command, [\n\t\t\t\t...prefixArgs,\n\t\t\t\t\"install\",\n\t\t\t\t\"-g\",\n\t\t\t\t\"--ignore-scripts\",\n\t\t\t\t\"--min-release-age=0\",\n\t\t\t\ttarget.installSpec,\n\t\t\t]);\n\t\t\tconst uninstallStep =\n\t\t\t\ttarget.packageName === installedPackageName\n\t\t\t\t\t? undefined\n\t\t\t\t\t: makeSelfUpdateCommandStep(command, [...prefixArgs, \"uninstall\", \"-g\", installedPackageName]);\n\t\t\treturn makeSelfUpdateCommand(installStep, uninstallStep);\n\t\t}\n\t\tcase \"unknown\":\n\t\t\treturn undefined;\n\t}\n}\n\nfunction readCommandOutput(\n\tcommand: string,\n\targs: string[],\n\toptions: { requireSuccess?: boolean } = {},\n): string | undefined {\n\tconst result = spawnProcessSync(command, args, {\n\t\tencoding: \"utf-8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\tif (result.status === 0) return result.stdout.trim() || undefined;\n\tif (options.requireSuccess) {\n\t\tconst reason = result.error?.message || result.stderr.trim() || `exit code ${result.status ?? \"unknown\"}`;\n\t\tthrow new Error(`Failed to run ${[command, ...args].join(\" \")}: ${reason}`);\n\t}\n\treturn undefined;\n}\n\nfunction getGlobalPackageRoots(method: InstallMethod, _packageName: string, npmCommand?: string[]): string[] {\n\tswitch (method) {\n\t\tcase \"npm\": {\n\t\t\tconst configured = !!npmCommand?.length;\n\t\t\tconst [command = \"npm\", ...npmArgs] = npmCommand ?? [];\n\t\t\tif (configured && command === \"bun\") {\n\t\t\t\tconst bunBin = readCommandOutput(command, [...npmArgs, \"pm\", \"bin\", \"-g\"], {\n\t\t\t\t\trequireSuccess: true,\n\t\t\t\t});\n\t\t\t\tconst roots = [join(homedir(), \".bun\", \"install\", \"global\", \"node_modules\")];\n\t\t\t\tif (bunBin) {\n\t\t\t\t\troots.push(join(dirname(bunBin), \"install\", \"global\", \"node_modules\"));\n\t\t\t\t}\n\t\t\t\treturn roots;\n\t\t\t}\n\t\t\tconst root = readCommandOutput(command, [...npmArgs, \"root\", \"-g\"], {\n\t\t\t\trequireSuccess: configured,\n\t\t\t});\n\t\t\tconst inferred = configured ? undefined : getInferredNpmInstall();\n\t\t\treturn [root, inferred?.root].filter((x): x is string => !!x);\n\t\t}\n\t\tcase \"pnpm\": {\n\t\t\tconst root = readCommandOutput(\"pnpm\", [\"root\", \"-g\"]);\n\t\t\tif (root) return [root, dirname(root)];\n\t\t\tconst match = /^(.*[\\\\/]global[\\\\/][^\\\\/]+)[\\\\/]\\.pnpm[\\\\/]/.exec(getPackageDir());\n\t\t\treturn match ? [match[1]] : [];\n\t\t}\n\t\tcase \"yarn\": {\n\t\t\tconst dir = readCommandOutput(\"yarn\", [\"global\", \"dir\"]);\n\t\t\treturn dir ? [dir, join(dir, \"node_modules\")] : [];\n\t\t}\n\t\tcase \"bun\": {\n\t\t\tconst bunBin = readCommandOutput(\"bun\", [\"pm\", \"bin\", \"-g\"]);\n\t\t\tconst roots = [join(homedir(), \".bun\", \"install\", \"global\", \"node_modules\")];\n\t\t\tif (bunBin) {\n\t\t\t\troots.push(join(dirname(bunBin), \"install\", \"global\", \"node_modules\"));\n\t\t\t}\n\t\t\treturn roots;\n\t\t}\n\t\tcase \"bun-binary\":\n\t\tcase \"unknown\":\n\t\t\treturn [];\n\t}\n}\n\nfunction normalizeExistingPathForComparison(path: string, resolveSymlinks: boolean): string | undefined {\n\tconst resolvedPath = resolve(path);\n\tif (!existsSync(resolvedPath)) {\n\t\treturn undefined;\n\t}\n\tlet normalizedPath = resolvedPath;\n\tif (resolveSymlinks) {\n\t\ttry {\n\t\t\tnormalizedPath = realpathSync(resolvedPath);\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n\tif (process.platform === \"win32\") {\n\t\tnormalizedPath = normalizedPath.toLowerCase();\n\t}\n\treturn normalizedPath;\n}\n\nfunction getPathComparisonCandidates(path: string): string[] {\n\treturn Array.from(\n\t\tnew Set(\n\t\t\t[normalizeExistingPathForComparison(path, false), normalizeExistingPathForComparison(path, true)].filter(\n\t\t\t\t(candidate): candidate is string => !!candidate,\n\t\t\t),\n\t\t),\n\t);\n}\n\nfunction getEntrypointPackageDir(): string | undefined {\n\tconst entrypoint = process.argv[1];\n\tif (!entrypoint) return undefined;\n\tlet dir = dirname(entrypoint);\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\"))) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\treturn undefined;\n}\n\nfunction isSelfUpdatePathWritable(): boolean {\n\tconst packageDir = getPackageDir();\n\ttry {\n\t\taccessSync(packageDir, constants.W_OK);\n\t\taccessSync(dirname(packageDir), constants.W_OK);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nfunction isManagedByGlobalPackageManager(method: InstallMethod, packageName: string, npmCommand?: string[]): boolean {\n\tconst packageDirs = [getPackageDir(), getEntrypointPackageDir()].filter((dir): dir is string => !!dir);\n\tconst packageDirCandidates = packageDirs.flatMap((dir) => getPathComparisonCandidates(dir));\n\treturn getGlobalPackageRoots(method, packageName, npmCommand).some((root) => {\n\t\treturn getPathComparisonCandidates(root).some((normalizedRoot) => {\n\t\t\tconst rootPrefix = normalizedRoot.endsWith(sep) ? normalizedRoot : `${normalizedRoot}${sep}`;\n\t\t\treturn packageDirCandidates.some((packageDir) => packageDir.startsWith(rootPrefix));\n\t\t});\n\t});\n}\n\nexport function getSelfUpdateCommand(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = packageName,\n): SelfUpdateCommand | undefined {\n\tconst method = detectInstallMethod();\n\tconst command = getSelfUpdateCommandForMethod(method, packageName, updatePackageTarget, npmCommand);\n\tif (!command || !isManagedByGlobalPackageManager(method, packageName, npmCommand) || !isSelfUpdatePathWritable()) {\n\t\treturn undefined;\n\t}\n\treturn command;\n}\n\nexport function getSelfUpdateUnavailableInstruction(\n\tpackageName: string,\n\tnpmCommand?: string[],\n\tupdatePackageTarget: SelfUpdatePackageTarget = packageName,\n): string {\n\tconst method = detectInstallMethod();\n\tconst target = normalizeSelfUpdatePackageTarget(updatePackageTarget);\n\tif (method === \"bun-binary\") {\n\t\treturn `Download from: https://github.com/draht-dev/draht/releases/latest`;\n\t}\n\tconst command = getSelfUpdateCommandForMethod(method, packageName, target, npmCommand);\n\tif (command) {\n\t\tif (isManagedByGlobalPackageManager(method, packageName, npmCommand) && !isSelfUpdatePathWritable()) {\n\t\t\treturn `This installation is managed by a global ${method} install, but the install path is not writable. Update it yourself with: ${command.display}`;\n\t\t}\n\t\treturn `This installation is not managed by a global ${method} install. Update it with the package manager, wrapper, or source checkout that provides it.`;\n\t}\n\treturn `Update ${target.installSpec} using the package manager, wrapper, or source checkout that provides this installation.`;\n}\n\nexport function getUpdateInstruction(packageName: string): string {\n\tconst method = detectInstallMethod();\n\tconst command = getSelfUpdateCommandForMethod(method, packageName);\n\tif (command) {\n\t\treturn `Run: ${command.display}`;\n\t}\n\treturn getSelfUpdateUnavailableInstruction(packageName);\n}\n\n// =============================================================================\n// Package Asset Paths (shipped with executable)\n// =============================================================================\n\n/**\n * Get the base directory for resolving package assets (themes, package.json, README.md, CHANGELOG.md).\n * - For Bun binary: returns the directory containing the executable\n * - For Node.js: walks up from `__dirname` to the nearest ancestor with a `package.json`, skipping\n * an emitted `dist/` bundle directory so it resolves to the package root even from the bundled CLI\n */\nexport function getPackageDir(): string {\n\t// Allow override via environment variable (useful for Nix/Guix where store paths tokenize poorly)\n\tconst envDir = process.env.DRAHT_PACKAGE_DIR;\n\tif (envDir) {\n\t\treturn normalizePath(envDir);\n\t}\n\n\tif (isBunBinary) {\n\t\t// Bun binary: process.execPath points to the compiled executable\n\t\treturn dirname(process.execPath);\n\t}\n\t// Node.js: walk up from __dirname until we find package.json\n\treturn findPackageRoot(__dirname);\n}\n\n/**\n * Is `dir` the emitted `dist/` bundle rather than the package root?\n *\n * `build:binary` copies `package.json` into `dist/` because the compiled binary\n * lives there and resolves its assets relative to itself. That copy is not a\n * package root: the Node entrypoint `dist/cli.js` sits beside it, so a naive\n * upward walk stops one level too low and every asset path gains a phantom\n * `dist/` segment (`dist/dist/modes/interactive/theme/dark.json`). Recognising\n * the copy is what lets `node dist/cli.js` and the compiled `dist/draht` both\n * work from one build tree instead of one invalidating the other.\n */\nfunction isEmittedBundleDir(dir: string): boolean {\n\treturn basename(dir) === \"dist\" && existsSync(join(dirname(dir), \"package.json\"));\n}\n\n/**\n * Nearest ancestor of `startDir` (inclusive) that is a real package root.\n *\n * @param startDir - Directory to start the upward walk from.\n * @returns The package root, or `startDir` when no `package.json` exists above it.\n */\nexport function findPackageRoot(startDir: string): string {\n\tlet dir = startDir;\n\twhile (dir !== dirname(dir)) {\n\t\tif (existsSync(join(dir, \"package.json\")) && !isEmittedBundleDir(dir)) {\n\t\t\treturn dir;\n\t\t}\n\t\tdir = dirname(dir);\n\t}\n\t// Fallback (shouldn't happen)\n\treturn startDir;\n}\n\n/**\n * Get path to built-in themes directory (shipped with package)\n * - For Bun binary: theme/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/theme/\n * - For tsx (src/): src/modes/interactive/theme/\n */\nexport function getThemesDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"theme\");\n\t}\n\t// Theme is in modes/interactive/theme/ relative to src/ or dist/\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"theme\");\n}\n\n/**\n * Get path to HTML export template directory (shipped with package)\n * - For Bun binary: export-html/ next to executable\n * - For Node.js (dist/): dist/core/export-html/\n * - For tsx (src/): src/core/export-html/\n */\nexport function getExportTemplateDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"export-html\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"core\", \"export-html\");\n}\n\n/** Get path to package.json */\nexport function getPackageJsonPath(): string {\n\treturn join(getPackageDir(), \"package.json\");\n}\n\n/** Get path to README.md */\nexport function getReadmePath(): string {\n\treturn resolve(join(getPackageDir(), \"README.md\"));\n}\n\n/** Get path to docs directory */\nexport function getDocsPath(): string {\n\treturn resolve(join(getPackageDir(), \"docs\"));\n}\n\n/** Get path to examples directory */\nexport function getExamplesPath(): string {\n\treturn resolve(join(getPackageDir(), \"examples\"));\n}\n\n/** Get path to CHANGELOG.md */\nexport function getChangelogPath(): string {\n\treturn resolve(join(getPackageDir(), \"CHANGELOG.md\"));\n}\n\n/**\n * Get path to built-in interactive assets directory.\n * - For Bun binary: assets/ next to executable\n * - For Node.js (dist/): dist/modes/interactive/assets/\n * - For tsx (src/): src/modes/interactive/assets/\n */\nexport function getInteractiveAssetsDir(): string {\n\tif (isBunBinary) {\n\t\treturn join(getPackageDir(), \"assets\");\n\t}\n\tconst packageDir = getPackageDir();\n\tconst srcOrDist = existsSync(join(packageDir, \"src\")) ? \"src\" : \"dist\";\n\treturn join(packageDir, srcOrDist, \"modes\", \"interactive\", \"assets\");\n}\n\n/** Get path to a bundled interactive asset */\nexport function getBundledInteractiveAssetPath(name: string): string {\n\treturn join(getInteractiveAssetsDir(), name);\n}\n\nlet quickJSWasmPath: string | undefined;\n\n/** Called by the Bun entry with the path of the QuickJS wasm file embedded in the compiled executable. */\nexport function setEmbeddedQuickJSWasmPath(path: string): void {\n\tquickJSWasmPath = path;\n}\n\n/**\n * Get path to `quickjs-wasi/quickjs.wasm`, the VM that runs codemode scripts. Resolved once so the\n * compiled module cached per path keeps working after an update removes this install (badlogic/pi-mono#10439).\n */\nexport function getQuickJSWasmPath(): string {\n\tquickJSWasmPath ??= createRequire(import.meta.url).resolve(\"quickjs-wasi/quickjs.wasm\");\n\treturn quickJSWasmPath;\n}\n\n/** Resolve the codemode worker entry for a release runtime. */\nexport function resolveCodemodeWorkerSpecifier(\n\truntime: \"bun-binary\" | \"bundled-node\" | \"unbundled\",\n\tmoduleUrl: string,\n): string | URL | undefined {\n\t// Bun embeds explicit source entrypoints, but on Windows Bun 1.3 cannot map an absolute\n\t// B:\\~BUN URL back to one. A relative string with the original source extension works on\n\t// every Bun platform.\n\tif (runtime === \"bun-binary\") return \"./src/extensions/codemode/worker.ts\";\n\tif (runtime === \"bundled-node\") return new URL(\"./codemode-worker.js\", moduleUrl);\n\treturn undefined;\n}\n\nlet codemodeWorkerDataUrl: URL | undefined;\n\n/**\n * Get the codemode worker entry, or undefined to use the worker that ships next to @draht/codemode.\n * The Bun and Node release builds both pass the worker as an extra entrypoint.\n */\nexport function getCodemodeWorkerSpecifier(): string | URL | undefined {\n\tconst runtime = isBunBinary ? \"bun-binary\" : isBundledNode ? \"bundled-node\" : \"unbundled\";\n\tconst specifier = resolveCodemodeWorkerSpecifier(runtime, import.meta.url);\n\tif (runtime !== \"bundled-node\" || !(specifier instanceof URL)) return specifier;\n\t// Spawn workers from an in-memory copy. An update replaces or deletes the file while this\n\t// process keeps running (badlogic/pi-mono#10439). The bundle build keeps the worker free of relative imports\n\t// and import.meta, so it runs from a data: URL.\n\tcodemodeWorkerDataUrl ??= new URL(`data:text/javascript;base64,${readFileSync(specifier).toString(\"base64\")}`);\n\treturn codemodeWorkerDataUrl;\n}\n\nexport type InstallChange = { kind: \"updated\"; version: string } | { kind: \"removed\" };\n\n/**\n * Detect that the package this process runs from changed on disk, for example after `draht update`\n * in another terminal. Code loaded on demand can then be missing or from another version.\n *\n * Checks the package.json read at startup. Resolving it again would walk up past a deleted install\n * and could find an unrelated package.json, such as one in the home directory.\n */\nexport function detectInstallChange(packageJsonPath = startupPackageJsonPath): InstallChange | undefined {\n\t// The Bun binary embeds its code, so replacing the executable does not affect this process.\n\tif (isBunBinary || !packageJsonPath) return undefined;\n\tlet installed: PackageJson;\n\ttry {\n\t\tinstalled = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as PackageJson;\n\t} catch (error) {\n\t\treturn (error as NodeJS.ErrnoException).code === \"ENOENT\" ? { kind: \"removed\" } : undefined;\n\t}\n\treturn installed.version && installed.version !== VERSION\n\t\t? { kind: \"updated\", version: installed.version }\n\t\t: undefined;\n}\n\n// =============================================================================\n// App Config (from package.json drahtConfig)\n// =============================================================================\n\ninterface PackageJson {\n\tname?: string;\n\tversion?: string;\n\tdrahtConfig?: {\n\t\tname?: string;\n\t\tconfigDir?: string;\n\t};\n}\n\nlet pkg: PackageJson = {};\n/** The package.json this process started from, if one existed. */\nlet startupPackageJsonPath: string | undefined;\ntry {\n\tconst packageJsonPath = getPackageJsonPath();\n\tpkg = JSON.parse(stripBom(readFileSync(packageJsonPath, \"utf-8\"))) as PackageJson;\n\tstartupPackageJsonPath = packageJsonPath;\n} catch (e: unknown) {\n\tconst err = e as NodeJS.ErrnoException;\n\tif (err.code !== \"ENOENT\") throw e;\n}\n\nconst drahtConfigName: string | undefined = pkg.drahtConfig?.name;\nexport const PACKAGE_NAME: string = pkg.name || \"@draht/coding-agent\";\nexport const APP_NAME: string = drahtConfigName || \"draht\";\nexport const APP_TITLE: string = drahtConfigName ? APP_NAME : \"draht\";\nexport const CONFIG_DIR_NAME: string = pkg.drahtConfig?.configDir || \".draht\";\nexport const LEGACY_CONFIG_DIR_NAME = \".pi\";\nexport const VERSION: string = pkg.version || \"0.0.0\";\n\n/** True when running from source (src/ directory exists), not a compiled/installed build. */\nexport const IS_DEV_MODE: boolean = existsSync(join(getPackageDir(), \"src\"));\n\n/** Version string for display. \"dev\" in dev mode, the package version otherwise. */\nexport const DISPLAY_VERSION: string = IS_DEV_MODE ? \"dev\" : VERSION;\n\n/**\n * Resolve the project config directory. Prefers CONFIG_DIR_NAME (.draht),\n * falls back to LEGACY_CONFIG_DIR_NAME (.pi) if the primary doesn't exist.\n */\nexport function getProjectConfigDir(cwd: string): string {\n\tconst primary = join(cwd, CONFIG_DIR_NAME);\n\tif (existsSync(primary)) return primary;\n\tconst legacy = join(cwd, LEGACY_CONFIG_DIR_NAME);\n\tif (existsSync(legacy)) return legacy;\n\treturn primary;\n}\n\n// e.g., DRAHT_CODING_AGENT_DIR\nexport const ENV_AGENT_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_DIR`;\nexport const ENV_SESSION_DIR = `${APP_NAME.toUpperCase()}_CODING_AGENT_SESSION_DIR`;\n\nexport function expandTildePath(path: string): string {\n\treturn normalizePath(path);\n}\n\n/**\n * draht has no pi.dev-equivalent share viewer. Returns undefined unless\n * DRAHT_SHARE_VIEWER_URL is set, in which case callers should present the\n * gist URL directly instead.\n */\nexport function getShareViewerUrl(gistId: string): string | undefined {\n\tconst baseUrl = process.env.DRAHT_SHARE_VIEWER_URL?.trim();\n\tif (!baseUrl) return undefined;\n\treturn `${baseUrl}#${gistId}`;\n}\n\n// =============================================================================\n// User Config Paths (~/.pi/agent/*)\n// =============================================================================\n\n/** Get the agent config directory (e.g., ~/.pi/agent/) */\nexport function getAgentDir(): string {\n\tconst envDir = process.env[ENV_AGENT_DIR];\n\tif (envDir) {\n\t\treturn expandTildePath(envDir);\n\t}\n\treturn join(homedir(), CONFIG_DIR_NAME, \"agent\");\n}\n\n/** Get path to user's custom themes directory */\nexport function getCustomThemesDir(): string {\n\treturn join(getAgentDir(), \"themes\");\n}\n\n/** Get path to models.json */\nexport function getModelsPath(): string {\n\treturn join(getAgentDir(), \"models.json\");\n}\n\n/** Get path to auth.json */\nexport function getAuthPath(): string {\n\treturn join(getAgentDir(), \"auth.json\");\n}\n\n/** Get path to settings.json */\nexport function getSettingsPath(): string {\n\treturn join(getAgentDir(), \"settings.json\");\n}\n\n/** Get path to tools directory */\nexport function getToolsDir(): string {\n\treturn join(getAgentDir(), \"tools\");\n}\n\n/** Get path to managed binaries directory (fd, rg) */\nexport function getBinDir(): string {\n\treturn join(getAgentDir(), \"bin\");\n}\n\n/** Get path to prompt templates directory */\nexport function getPromptsDir(): string {\n\treturn join(getAgentDir(), \"prompts\");\n}\n\n/** Get path to shipped prompts directory (bundled with the package). */\nexport function getShippedPromptsDir(): string {\n\treturn join(getPackageDir(), \"prompts\");\n}\n\n/** Get path to shipped skills directory (bundled with the package). */\nexport function getShippedSkillsDir(): string {\n\treturn join(getPackageDir(), \"skills\");\n}\n\n/** Get path to sessions directory */\nexport function getSessionsDir(): string {\n\treturn join(getAgentDir(), \"sessions\");\n}\n\n/** Get path to debug log file */\nexport function getDebugLogPath(): string {\n\treturn join(getAgentDir(), `${APP_NAME}-debug.log`);\n}\n"]}
@@ -53,6 +53,7 @@ export type AgentSessionEvent = WithParentToolCallId<Exclude<AgentEvent, {
53
53
  willRetry: boolean;
54
54
  } | {
55
55
  type: "agent_settled";
56
+ aborted: boolean;
56
57
  } | {
57
58
  type: "queue_update";
58
59
  steering: readonly string[];
@@ -134,13 +135,24 @@ export interface AgentSessionConfig {
134
135
  /** Initial active built-in tool names. Default: [read, bash, edit, write] */
135
136
  initialActiveToolNames?: string[];
136
137
  /**
137
- * Whether the initial tools come from the `defaultTools` setting. When true, reload activates
138
- * tools newly added to the setting. Tools removed from it stay active.
138
+ * Whether the initial tools come from the `defaultTools` setting. When true, a resumed session
139
+ * replaces them with the loadout its transcript records, with `defaultToolModifiers` applied, and
140
+ * reload activates tools newly added to the setting. Tools removed from it stay active.
139
141
  */
140
142
  usesDefaultTools?: boolean;
141
- /** Optional allowlist of tool names. When provided, only these tool names are exposed. */
143
+ /**
144
+ * `+name`/`-name` entries applied on top of the `defaultTools` setting, from `--tools`. Reload
145
+ * applies them to the reloaded setting too, so a removed tool stays removed.
146
+ */
147
+ defaultToolModifiers?: string[];
148
+ /**
149
+ * Optional allowlist of tool names or patterns (`*` matches any characters). When provided, only
150
+ * matching tools are exposed. A non-empty list without `mcp__` entries also keeps MCP tools
151
+ * registered for codemode and tool_search; only tool_search can declare them. An empty list
152
+ * exposes no tools.
153
+ */
142
154
  allowedToolNames?: string[];
143
- /** Optional denylist of tool names. When provided, these tool names are not exposed. */
155
+ /** Optional denylist of tool names or patterns. When provided, matching tools are not exposed. */
144
156
  excludedToolNames?: string[];
145
157
  /**
146
158
  * Override base tools (useful for custom runtimes).
@@ -247,10 +259,10 @@ export declare class AgentSession {
247
259
  private readonly _entryIdsByMessage;
248
260
  private readonly _boundaryDispatchedMessages;
249
261
  private _lastAssistantMessage;
250
- private _lastAssistantToolResults;
251
262
  private _lastActivityOutcome;
252
263
  private _isBeforeSettle;
253
264
  private _abortDuringBeforeSettle;
265
+ private _beforeSettleAbortController;
254
266
  private _isEmittingAgentSettled;
255
267
  private readonly _deferredSettledActions;
256
268
  private _resourceLoader;
@@ -259,9 +271,22 @@ export declare class AgentSession {
259
271
  private _cwd;
260
272
  private _extensionRunnerRef?;
261
273
  private _initialActiveToolNames?;
274
+ /**
275
+ * Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
276
+ * servers that are still connecting. They are activated when they are registered, and dropped when
277
+ * `setActiveToolsByName()` deactivates a tool or the next agent run starts.
278
+ */
279
+ private _pendingToolNames;
262
280
  private _usesDefaultTools;
263
- private _allowedToolNames?;
264
- private _excludedToolNames?;
281
+ private _defaultToolModifiers;
282
+ /** Matches the `--tools` entries: tool names or patterns. */
283
+ private _allowedTools?;
284
+ /**
285
+ * Whether the allowlist filters MCP tools: it is empty (`--no-tools`) or names an MCP tool
286
+ * (`mcp__*`). Otherwise it keeps MCP tools registered for codemode and tool_search.
287
+ */
288
+ private _allowlistFiltersMcp;
289
+ private _excludedTools?;
265
290
  private _baseToolsOverride?;
266
291
  private _sessionStartEvent;
267
292
  private _extensionUIContext?;
@@ -347,6 +372,11 @@ export declare class AgentSession {
347
372
  private _handleAgentEvent;
348
373
  private _willRetryAfterAgentEnd;
349
374
  private _findPersistedMessageEntryId;
375
+ /**
376
+ * Persistently omit a failed attempt and its tool results from model context. Results are
377
+ * found in the projected context, so the pair stays together whether the attempt comes from
378
+ * the current run or a resumed session. An unpaired result fails the next request (#11227).
379
+ */
350
380
  private _omitRecoveryAttempt;
351
381
  /** Find the last assistant message in agent state (including aborted ones) */
352
382
  private _findLastAssistantMessage;
@@ -410,6 +440,19 @@ export declare class AgentSession {
410
440
  * Changes take effect on the next agent turn.
411
441
  */
412
442
  setActiveToolsByName(toolNames: string[]): void;
443
+ private _setActiveTools;
444
+ /**
445
+ * Whether `--tools` and `--exclude-tools` keep the tool registered. MCP tools stay registered
446
+ * unless the allowlist filters them (see `_allowlistFiltersMcp`).
447
+ */
448
+ private _isAllowedTool;
449
+ /**
450
+ * Whether the tool may be active, which declares it to the model. MCP tools the allowlist keeps
451
+ * without matching them are only for codemode and tool_search: they may be declared only when
452
+ * tool_search can load them (non-`direct` exposure and tool_search registered). This also applies
453
+ * to tools restored from the transcript or set by extensions.
454
+ */
455
+ private _isActivatable;
413
456
  private _getToolExposure;
414
457
  /**
415
458
  * Tools callable through `ctx.executeTool()`: the active `direct` tools and every registered
@@ -484,9 +527,23 @@ export declare class AgentSession {
484
527
  * Restore the active tool loadout declared by the session transcript, if it declares one.
485
528
  * Tools reachable only from other tools are never declared, but they do not depend on the active
486
529
  * set, so the transcript's declarations are the whole loadout.
530
+ * @param modifiers `+name`/`-name` entries applied to the restored loadout.
487
531
  */
488
532
  private _restoreToolsFromTranscript;
489
- private _runAgentPrompt;
533
+ /**
534
+ * Start a run from a user or custom message. The session counts as busy from here on, so
535
+ * messages sent while before_agent_start handlers run are queued into this run instead of
536
+ * starting another, and an abort requested meanwhile aborts the run as soon as it exists.
537
+ * @param onStarted Called once the run's messages are prepared, before the first request.
538
+ */
539
+ private _startRun;
540
+ /**
541
+ * Prepare a run and return its starting messages: compact first when needed, emit
542
+ * before_agent_start, apply the run's prompt options and tool loadout, and build the starting
543
+ * message followed by pending nextTurn messages (consumed here) and handler messages, with a
544
+ * system patch first when the prompt changed.
545
+ */
546
+ private _prepareRun;
490
547
  private _handlePostAgentRun;
491
548
  private _runBeforeSettleBoundary;
492
549
  private _runInputHandlers;