@draht/coding-agent 2026.11.5-1 → 2026.11.14-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (306) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/bundle/chunks/anthropic-messages-C5ZJVCKX.js +6 -0
  3. package/dist/bundle/chunks/{azure-openai-responses-NCMJPZVJ.js → azure-openai-responses-TNRID5YC.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +2 -2
  5. package/dist/bundle/chunks/chunk-2CHTECAU.js +2 -0
  6. package/dist/bundle/chunks/{chunk-DWOGGNWY.js → chunk-2IQVBLH6.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-P7O36UDU.js → chunk-4FPBO5KP.js} +5 -1
  8. package/dist/bundle/chunks/{chunk-Q2QKCYPU.js → chunk-5C4MAPF6.js} +1 -1
  9. package/dist/bundle/chunks/chunk-5WEOWREV.js +82 -0
  10. package/dist/bundle/chunks/{chunk-DN7SM3LX.js → chunk-ATYP3OSV.js} +3 -1
  11. package/dist/bundle/chunks/chunk-B6S2UR4T.js +2 -0
  12. package/dist/bundle/chunks/chunk-EBTEI43G.js +20 -0
  13. package/dist/bundle/chunks/{chunk-F5TDVH26.js → chunk-GAABJAG4.js} +12 -15
  14. package/dist/bundle/chunks/{chunk-PMINB7UH.js → chunk-JHKMYVPC.js} +169 -130
  15. package/dist/bundle/chunks/{chunk-EOXOMUKR.js → chunk-LCTFXH4P.js} +1 -1
  16. package/dist/bundle/chunks/{chunk-UFACUBF2.js → chunk-MPJIXESS.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-PZKD35UB.js → chunk-MXA4WY3C.js} +1 -1
  18. package/dist/bundle/chunks/chunk-O2XYFH2E.js +30 -0
  19. package/dist/bundle/chunks/{chunk-CA23BDNK.js → chunk-OUXJRC2W.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-3BJ462DN.js → chunk-RI7HJ6AF.js} +1 -1
  21. package/dist/bundle/chunks/chunk-RVXTPNXQ.js +44 -0
  22. package/dist/bundle/chunks/{chunk-QBUTRTYN.js → chunk-SXHVGWCU.js} +1 -1
  23. package/dist/bundle/chunks/chunk-WNZ64GW3.js +2 -0
  24. package/dist/bundle/chunks/chunk-XWZLYE4L.js +9 -0
  25. package/dist/bundle/chunks/{chunk-HJ3PS7QP.js → chunk-YSE3VKKB.js} +2 -2
  26. package/dist/bundle/chunks/{cli-4SUT6MJ6.js → cli-2QKCAPPD.js} +3 -3
  27. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-BJVMNETD.js → cloudflare-workers-ai-system-one-UCG6T3XP.js} +1 -1
  28. package/dist/bundle/chunks/codemode-worker.js +2 -0
  29. package/dist/bundle/chunks/{execute-ZI7T2SUH.js → execute-KGJOWTPG.js} +2 -2
  30. package/dist/bundle/chunks/github-copilot.js +1 -1
  31. package/dist/bundle/chunks/google-generative-ai-GPBKPOXA.js +2 -0
  32. package/dist/bundle/chunks/google-vertex-USZY53NF.js +2 -0
  33. package/dist/bundle/chunks/{llama-cpp-classify-L4URPZ4F.js → llama-cpp-classify-7DEQ4ZUF.js} +1 -1
  34. package/dist/bundle/chunks/{mistral-conversations-CK2BS74V.js → mistral-conversations-UOGXPDZ3.js} +1 -1
  35. package/dist/bundle/chunks/{openai-codex-responses-XGVNKP4D.js → openai-codex-responses-VUDXQ3EU.js} +1 -1
  36. package/dist/bundle/chunks/{openai-completions-72XZO4Q3.js → openai-completions-UQOOS7NM.js} +3 -3
  37. package/dist/bundle/chunks/{openai-decisions-P5OCXLLD.js → openai-decisions-24WNXO2R.js} +1 -1
  38. package/dist/bundle/chunks/{openai-responses-RGLZ4E3Q.js → openai-responses-5AF6MZ5L.js} +1 -1
  39. package/dist/bundle/chunks/{openrouter-images-LSBWMZDK.js → openrouter-images-OUXVVTYQ.js} +1 -1
  40. package/dist/bundle/chunks/{pi-messages-CL4MEVNS.js → pi-messages-DRMOEO6B.js} +1 -1
  41. package/dist/bundle/chunks/{runtime-FJYRBK3O.js → runtime-FZKS2BWI.js} +1 -1
  42. package/dist/bundle/chunks/{runtime-F4362CZF.js → runtime-L23MZBKL.js} +1 -1
  43. package/dist/bundle/chunks/{settings-manager-T6G6KKY3.js → settings-manager-CWRQW6PZ.js} +1 -1
  44. package/dist/bundle/chunks/{typesafe-system-one-BFYS6AEA.js → typesafe-system-one-K63EBJDD.js} +1 -1
  45. package/dist/bundle/chunks/virtual-modules-JZV35VDE.js +2 -0
  46. package/dist/bundle/cli-runtime.js +1 -1
  47. package/dist/bundle/index.js +1 -1
  48. package/dist/bundle/rpc-entry.js +1 -1
  49. package/dist/cli/args.d.ts.map +1 -1
  50. package/dist/cli/args.js +5 -3
  51. package/dist/cli/args.js.map +1 -1
  52. package/dist/cli/auth-command.d.ts.map +1 -1
  53. package/dist/cli/auth-command.js +30 -6
  54. package/dist/cli/auth-command.js.map +1 -1
  55. package/dist/cli/auth-login.d.ts +15 -0
  56. package/dist/cli/auth-login.d.ts.map +1 -0
  57. package/dist/cli/auth-login.js +232 -0
  58. package/dist/cli/auth-login.js.map +1 -0
  59. package/dist/cli/auth-logout.d.ts +14 -0
  60. package/dist/cli/auth-logout.d.ts.map +1 -0
  61. package/dist/cli/auth-logout.js +57 -0
  62. package/dist/cli/auth-logout.js.map +1 -0
  63. package/dist/cli/auth-terminal.d.ts +17 -0
  64. package/dist/cli/auth-terminal.d.ts.map +1 -0
  65. package/dist/cli/auth-terminal.js +63 -0
  66. package/dist/cli/auth-terminal.js.map +1 -0
  67. package/dist/core/agent-session-runtime.d.ts +5 -0
  68. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  69. package/dist/core/agent-session-runtime.js +16 -2
  70. package/dist/core/agent-session-runtime.js.map +1 -1
  71. package/dist/core/agent-session.d.ts +20 -9
  72. package/dist/core/agent-session.d.ts.map +1 -1
  73. package/dist/core/agent-session.js +71 -29
  74. package/dist/core/agent-session.js.map +1 -1
  75. package/dist/core/ai-schemas.d.ts +1 -0
  76. package/dist/core/ai-schemas.d.ts.map +1 -1
  77. package/dist/core/builtins/budgets.d.ts.map +1 -1
  78. package/dist/core/builtins/budgets.js +6 -3
  79. package/dist/core/builtins/budgets.js.map +1 -1
  80. package/dist/core/cache-warmer.d.ts +4 -37
  81. package/dist/core/cache-warmer.d.ts.map +1 -1
  82. package/dist/core/cache-warmer.js +11 -91
  83. package/dist/core/cache-warmer.js.map +1 -1
  84. package/dist/core/compaction/utils.d.ts.map +1 -1
  85. package/dist/core/compaction/utils.js +2 -1
  86. package/dist/core/compaction/utils.js.map +1 -1
  87. package/dist/core/exec.d.ts +1 -0
  88. package/dist/core/exec.d.ts.map +1 -1
  89. package/dist/core/exec.js +4 -1
  90. package/dist/core/exec.js.map +1 -1
  91. package/dist/core/export-html/ansi-to-html.d.ts +5 -0
  92. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  93. package/dist/core/export-html/ansi-to-html.js +57 -20
  94. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  95. package/dist/core/export-html/template.js +1 -1
  96. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  97. package/dist/core/export-html/tool-renderer.js +2 -3
  98. package/dist/core/export-html/tool-renderer.js.map +1 -1
  99. package/dist/core/extensions/types.d.ts +3 -2
  100. package/dist/core/extensions/types.d.ts.map +1 -1
  101. package/dist/core/extensions/types.js.map +1 -1
  102. package/dist/core/model-config.d.ts +13 -0
  103. package/dist/core/model-config.d.ts.map +1 -1
  104. package/dist/core/model-resolver.d.ts +0 -1
  105. package/dist/core/model-resolver.d.ts.map +1 -1
  106. package/dist/core/model-resolver.js +17 -24
  107. package/dist/core/model-resolver.js.map +1 -1
  108. package/dist/core/model-runtime.d.ts +5 -0
  109. package/dist/core/model-runtime.d.ts.map +1 -1
  110. package/dist/core/model-runtime.js +7 -0
  111. package/dist/core/model-runtime.js.map +1 -1
  112. package/dist/core/polyphase/render/format.d.ts +2 -0
  113. package/dist/core/polyphase/render/format.d.ts.map +1 -1
  114. package/dist/core/polyphase/render/format.js +6 -0
  115. package/dist/core/polyphase/render/format.js.map +1 -1
  116. package/dist/core/polyphase/render/run-block.d.ts +4 -0
  117. package/dist/core/polyphase/render/run-block.d.ts.map +1 -1
  118. package/dist/core/polyphase/render/run-block.js +71 -12
  119. package/dist/core/polyphase/render/run-block.js.map +1 -1
  120. package/dist/core/polyphase/render/snapshot.d.ts +1 -1
  121. package/dist/core/polyphase/render/snapshot.d.ts.map +1 -1
  122. package/dist/core/polyphase/render/snapshot.js +22 -7
  123. package/dist/core/polyphase/render/snapshot.js.map +1 -1
  124. package/dist/core/polyphase/ui/dock.d.ts.map +1 -1
  125. package/dist/core/polyphase/ui/dock.js +34 -2
  126. package/dist/core/polyphase/ui/dock.js.map +1 -1
  127. package/dist/core/polyphase/ui/inspector.d.ts +18 -6
  128. package/dist/core/polyphase/ui/inspector.d.ts.map +1 -1
  129. package/dist/core/polyphase/ui/inspector.js +125 -44
  130. package/dist/core/polyphase/ui/inspector.js.map +1 -1
  131. package/dist/core/polyphase/ui/transcript-layout.d.ts.map +1 -1
  132. package/dist/core/polyphase/ui/transcript-layout.js +5 -1
  133. package/dist/core/polyphase/ui/transcript-layout.js.map +1 -1
  134. package/dist/core/preferred-providers.d.ts +17 -0
  135. package/dist/core/preferred-providers.d.ts.map +1 -0
  136. package/dist/core/preferred-providers.js +24 -0
  137. package/dist/core/preferred-providers.js.map +1 -0
  138. package/dist/core/prompt-templates.d.ts.map +1 -1
  139. package/dist/core/prompt-templates.js +18 -2
  140. package/dist/core/prompt-templates.js.map +1 -1
  141. package/dist/core/provider-composer.d.ts.map +1 -1
  142. package/dist/core/provider-composer.js +2 -0
  143. package/dist/core/provider-composer.js.map +1 -1
  144. package/dist/core/provider-matching.d.ts +6 -0
  145. package/dist/core/provider-matching.d.ts.map +1 -0
  146. package/dist/core/provider-matching.js +8 -0
  147. package/dist/core/provider-matching.js.map +1 -0
  148. package/dist/core/radius-mcp.d.ts +13 -0
  149. package/dist/core/radius-mcp.d.ts.map +1 -0
  150. package/dist/core/radius-mcp.js +29 -0
  151. package/dist/core/radius-mcp.js.map +1 -0
  152. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  153. package/dist/core/remote-catalog-provider.js +2 -0
  154. package/dist/core/remote-catalog-provider.js.map +1 -1
  155. package/dist/core/runtime-credentials.d.ts +8 -0
  156. package/dist/core/runtime-credentials.d.ts.map +1 -1
  157. package/dist/core/runtime-credentials.js +15 -1
  158. package/dist/core/runtime-credentials.js.map +1 -1
  159. package/dist/core/session-cwd.d.ts +7 -0
  160. package/dist/core/session-cwd.d.ts.map +1 -1
  161. package/dist/core/session-cwd.js +9 -1
  162. package/dist/core/session-cwd.js.map +1 -1
  163. package/dist/core/session-manager.d.ts.map +1 -1
  164. package/dist/core/session-manager.js +45 -36
  165. package/dist/core/session-manager.js.map +1 -1
  166. package/dist/core/settings-defaults.d.ts +1 -1
  167. package/dist/core/settings-defaults.d.ts.map +1 -1
  168. package/dist/core/settings-defaults.js +1 -1
  169. package/dist/core/settings-defaults.js.map +1 -1
  170. package/dist/core/tools/bash.d.ts.map +1 -1
  171. package/dist/core/tools/bash.js +35 -5
  172. package/dist/core/tools/bash.js.map +1 -1
  173. package/dist/core/tools/edit-diff.d.ts +23 -14
  174. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  175. package/dist/core/tools/edit-diff.js +182 -41
  176. package/dist/core/tools/edit-diff.js.map +1 -1
  177. package/dist/core/tools/edit.d.ts.map +1 -1
  178. package/dist/core/tools/edit.js +8 -7
  179. package/dist/core/tools/edit.js.map +1 -1
  180. package/dist/core/tools/find.d.ts.map +1 -1
  181. package/dist/core/tools/find.js +57 -16
  182. package/dist/core/tools/find.js.map +1 -1
  183. package/dist/core/tools/grep.d.ts +4 -0
  184. package/dist/core/tools/grep.d.ts.map +1 -1
  185. package/dist/core/tools/grep.js +20 -8
  186. package/dist/core/tools/grep.js.map +1 -1
  187. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  188. package/dist/core/tools/output-accumulator.js +4 -1
  189. package/dist/core/tools/output-accumulator.js.map +1 -1
  190. package/dist/core/tools/powershell.d.ts.map +1 -1
  191. package/dist/core/tools/powershell.js +15 -2
  192. package/dist/core/tools/powershell.js.map +1 -1
  193. package/dist/core/tools/read.d.ts +13 -0
  194. package/dist/core/tools/read.d.ts.map +1 -1
  195. package/dist/core/tools/read.js +146 -35
  196. package/dist/core/tools/read.js.map +1 -1
  197. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  198. package/dist/core/tools/renderers/read.js +6 -2
  199. package/dist/core/tools/renderers/read.js.map +1 -1
  200. package/dist/core/tools/truncate.d.ts +4 -0
  201. package/dist/core/tools/truncate.d.ts.map +1 -1
  202. package/dist/core/tools/truncate.js +24 -1
  203. package/dist/core/tools/truncate.js.map +1 -1
  204. package/dist/extensions/codemode/execute.js +4 -4
  205. package/dist/extensions/codemode/execute.js.map +1 -1
  206. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  207. package/dist/extensions/codemode/tool.js +34 -12
  208. package/dist/extensions/codemode/tool.js.map +1 -1
  209. package/dist/extensions/llama/provider.d.ts +1 -1
  210. package/dist/extensions/llama/provider.js +1 -1
  211. package/dist/extensions/llama/provider.js.map +1 -1
  212. package/dist/extensions/llama/ui.d.ts.map +1 -1
  213. package/dist/extensions/llama/ui.js +15 -3
  214. package/dist/extensions/llama/ui.js.map +1 -1
  215. package/dist/extensions/mcp/cli.js +5 -8
  216. package/dist/extensions/mcp/cli.js.map +1 -1
  217. package/dist/extensions/mcp/index.d.ts.map +1 -1
  218. package/dist/extensions/mcp/index.js +2 -1
  219. package/dist/extensions/mcp/index.js.map +1 -1
  220. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  221. package/dist/extensions/mcp/runtime.js +3 -2
  222. package/dist/extensions/mcp/runtime.js.map +1 -1
  223. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  224. package/dist/extensions/tool-search/tool.js +18 -6
  225. package/dist/extensions/tool-search/tool.js.map +1 -1
  226. package/dist/main.d.ts.map +1 -1
  227. package/dist/main.js +67 -15
  228. package/dist/main.js.map +1 -1
  229. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  230. package/dist/modes/interactive/components/login-dialog.js +2 -19
  231. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  232. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  233. package/dist/modes/interactive/components/model-selector.js +14 -6
  234. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  235. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  236. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  237. package/dist/modes/interactive/components/oauth-selector.js +32 -5
  238. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  239. package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
  240. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  241. package/dist/modes/interactive/components/provider-brand.js +66 -0
  242. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  243. package/dist/modes/interactive/components/radius-login-selector.d.ts +1 -2
  244. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  245. package/dist/modes/interactive/components/radius-login-selector.js +6 -37
  246. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  247. package/dist/modes/interactive/components/session-selector.d.ts +6 -1
  248. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  249. package/dist/modes/interactive/components/session-selector.js +23 -5
  250. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  251. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  252. package/dist/modes/interactive/components/tool-execution.js +3 -1
  253. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  254. package/dist/modes/interactive/interactive-mode.d.ts +11 -1
  255. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  256. package/dist/modes/interactive/interactive-mode.js +133 -78
  257. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  258. package/dist/modes/interactive/session-share.js +2 -0
  259. package/dist/modes/interactive/session-share.js.map +1 -1
  260. package/dist/package-manager-cli.d.ts.map +1 -1
  261. package/dist/package-manager-cli.js +27 -4
  262. package/dist/package-manager-cli.js.map +1 -1
  263. package/dist/prompts/commands/test-audit.md +84 -0
  264. package/dist/utils/image-resize.d.ts.map +1 -1
  265. package/dist/utils/image-resize.js +3 -1
  266. package/dist/utils/image-resize.js.map +1 -1
  267. package/dist/utils/terminal-question.d.ts +8 -0
  268. package/dist/utils/terminal-question.d.ts.map +1 -0
  269. package/dist/utils/terminal-question.js +24 -0
  270. package/dist/utils/terminal-question.js.map +1 -0
  271. package/dist/utils/web-url.d.ts +12 -0
  272. package/dist/utils/web-url.d.ts.map +1 -0
  273. package/dist/utils/web-url.js +20 -0
  274. package/dist/utils/web-url.js.map +1 -0
  275. package/docs/cli.md +14 -1
  276. package/docs/extensions.md +6 -4
  277. package/docs/llama-cpp.md +5 -5
  278. package/docs/models-configuration.md +2 -1
  279. package/docs/nvidia-rtx-llama-cpp.md +5 -5
  280. package/docs/polyphase.md +13 -1
  281. package/docs/prompt-templates.md +1 -1
  282. package/docs/providers.md +4 -2
  283. package/docs/quickstart.md +1 -1
  284. package/docs/rpc-commands.md +1 -1
  285. package/docs/rpc.md +1 -1
  286. package/docs/sessions.md +7 -1
  287. package/docs/settings.md +1 -1
  288. package/docs/tui.md +1 -1
  289. package/examples/extensions/gondolin/index.ts +4 -7
  290. package/examples/extensions/subagent/index.ts +5 -1
  291. package/package.json +10 -10
  292. package/prompts/commands/test-audit.md +84 -0
  293. package/schemas/models.schema.json +5 -1
  294. package/schemas/settings.schema.json +1 -1
  295. package/dist/bundle/chunks/anthropic-messages-UJZ4SGHU.js +0 -6
  296. package/dist/bundle/chunks/chunk-AOCWORXE.js +0 -2
  297. package/dist/bundle/chunks/chunk-BK5LXGIH.js +0 -2
  298. package/dist/bundle/chunks/chunk-DQ4G4IS4.js +0 -20
  299. package/dist/bundle/chunks/chunk-SUVMF4W5.js +0 -2
  300. package/dist/bundle/chunks/chunk-VXO6B72D.js +0 -9
  301. package/dist/bundle/chunks/chunk-WXASQQBZ.js +0 -44
  302. package/dist/bundle/chunks/chunk-YD5VPPI4.js +0 -30
  303. package/dist/bundle/chunks/chunk-YWRWN7ZB.js +0 -82
  304. package/dist/bundle/chunks/google-generative-ai-N5IPPKQY.js +0 -2
  305. package/dist/bundle/chunks/google-vertex-A4BKUE4H.js +0 -2
  306. package/dist/bundle/chunks/virtual-modules-BPZIVXNK.js +0 -2
@@ -113,6 +113,20 @@ const LOCAL_SURFACE_BY_MODE = Object.freeze({
113
113
  // ============================================================================
114
114
  // AgentSession Class
115
115
  // ============================================================================
116
+ /**
117
+ * Index of the model to cycle to, or undefined when there is nothing to switch to.
118
+ * When the current model is not in the list (currentIndex -1), forward picks the first
119
+ * entry and backward the last, so a one-entry list still selects its only model.
120
+ */
121
+ function getNextCycleIndex(currentIndex, length, direction) {
122
+ if (length === 0)
123
+ return undefined;
124
+ if (currentIndex === -1)
125
+ return direction === "forward" ? 0 : length - 1;
126
+ if (length === 1)
127
+ return undefined;
128
+ return direction === "forward" ? (currentIndex + 1) % length : (currentIndex - 1 + length) % length;
129
+ }
116
130
  export class AgentSession {
117
131
  agent;
118
132
  sessionManager;
@@ -174,9 +188,11 @@ export class AgentSession {
174
188
  /**
175
189
  * Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
176
190
  * servers that are still connecting. They are activated when they are registered, and dropped when
177
- * `setActiveToolsByName()` deactivates a tool or the next agent run starts.
191
+ * `setActiveToolsByName()` deactivates a tool of that loadout or the next agent run starts.
178
192
  */
179
193
  _pendingToolNames = new Set();
194
+ /** The restored or reloaded loadout that `_pendingToolNames` belongs to. */
195
+ _restoredToolNames = new Set();
180
196
  _usesDefaultTools;
181
197
  _defaultToolModifiers;
182
198
  /** Matches the `--tools` entries: tool names or patterns. */
@@ -328,19 +344,25 @@ export class AgentSession {
328
344
  return this._modelRuntime.getPhysicalModel(message.provider, message.model);
329
345
  return model?.provider === message.provider && model.id === message.model ? model : undefined;
330
346
  }
347
+ /** Record the live model and thinking level on the current branch, so a resume restores them. */
348
+ _recordSelection() {
349
+ const branch = this.sessionManager.getBranch();
350
+ this._recordModelSelection(branch);
351
+ this._recordThinkingLevel(branch);
352
+ }
331
353
  /**
332
- * Record the selection on the current branch when the branch implies another one, so a resume
333
- * restores it. Tree navigation can leave the latest `model_change` on another branch; responses
334
- * cannot record a virtual selection because they name physical models. Responses do record a
335
- * physical selection unless the branch holds a virtual one; checking a physical selection against
336
- * responses would record it on every prompt while `prepareRequest` redirects to another model.
354
+ * Record the model on the current branch when the branch implies another one. Tree navigation
355
+ * can leave the latest `model_change` on another branch; responses cannot record a virtual
356
+ * selection because they name physical models. Responses do record a physical selection unless
357
+ * the branch holds a virtual one; checking a physical selection against responses would record
358
+ * it on every prompt while `prepareRequest` redirects to another model.
337
359
  */
338
- _recordSelection() {
360
+ _recordModelSelection(branch) {
339
361
  const model = this.model;
340
362
  if (!model)
341
363
  return;
342
364
  const getModel = (provider, modelId) => this._modelRuntime.getModel(provider, modelId);
343
- const recorded = getBranchSelection(this.sessionManager.getBranch(), getModel);
365
+ const recorded = getBranchSelection(branch, getModel);
344
366
  if (!recorded || (recorded.provider === model.provider && recorded.modelId === model.id))
345
367
  return;
346
368
  const recordedModel = getModel(recorded.provider, recorded.modelId);
@@ -348,6 +370,25 @@ export class AgentSession {
348
370
  return;
349
371
  this.sessionManager.appendModelChange(model.provider, model.id);
350
372
  }
373
+ /**
374
+ * Record the thinking level on the current branch when the branch implies another one (#11451).
375
+ * Tree navigation can leave the latest `thinking_level_change` on another branch. The recorded
376
+ * level is compared after clamping to the current model, so a level clamped on resume (e.g.
377
+ * `xhigh` running as `high`) is not recorded over the requested one.
378
+ */
379
+ _recordThinkingLevel(branch) {
380
+ const recorded = branch.findLast((entry) => entry.type === "thinking_level_change");
381
+ if (!recorded)
382
+ return;
383
+ const recordedLevel = recorded.thinkingLevel;
384
+ const availableLevels = this.getAvailableThinkingLevels();
385
+ const effective = availableLevels.includes(recordedLevel)
386
+ ? recordedLevel
387
+ : this._clampThinkingLevel(recordedLevel, availableLevels);
388
+ if (effective === this.thinkingLevel)
389
+ return;
390
+ this.sessionManager.appendThinkingLevelChange(this.thinkingLevel);
391
+ }
351
392
  /** The model whose limits apply to the conversation. */
352
393
  _limitsModel() {
353
394
  return this.routedModel?.model ?? this.model;
@@ -1171,11 +1212,14 @@ export class AgentSession {
1171
1212
  setActiveToolsByName(toolNames) {
1172
1213
  const previous = this.getActiveToolNames();
1173
1214
  this._setActiveTools(toolNames);
1174
- // A loadout that deactivates a tool replaces the restored one, whose pending tools are dropped.
1175
- // One that only adds tools, like activating tool_search, keeps them.
1215
+ // A loadout that deactivates a tool of the restored one replaces it, and its pending tools are
1216
+ // dropped. One that only adds tools, like activating tool_search, keeps them, and so does one
1217
+ // that only deactivates tools outside the restored loadout, such as an extension's own tool that
1218
+ // the restore or reload activated as newly registered.
1176
1219
  const active = new Set(this.getActiveToolNames());
1177
- if (previous.some((name) => !active.has(name)))
1220
+ if (previous.some((name) => !active.has(name) && this._restoredToolNames.has(name))) {
1178
1221
  this._pendingToolNames.clear();
1222
+ }
1179
1223
  }
1180
1224
  _setActiveTools(toolNames) {
1181
1225
  const tools = this._applyToolLoadout(toolNames);
@@ -1445,6 +1489,7 @@ export class AgentSession {
1445
1489
  */
1446
1490
  _restoreToolsFromTranscript(modifiers = []) {
1447
1491
  this._pendingToolNames.clear();
1492
+ this._restoredToolNames.clear();
1448
1493
  // All system messages on the branch, including those before a compaction. Compaction snapshots
1449
1494
  // are derived from these, so replaying them gives the current loadout.
1450
1495
  const systemMessages = this.sessionManager
@@ -1465,6 +1510,7 @@ export class AgentSession {
1465
1510
  // Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
1466
1511
  // activated when they register. Excluded tools never register, so they are not kept pending.
1467
1512
  this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
1513
+ this._restoredToolNames = new Set(applyToolModifiers(getCurrentTools(systemMessages).map((tool) => tool.name), modifiers));
1468
1514
  // Ignores names that are not registered.
1469
1515
  this._setActiveTools(names);
1470
1516
  }
@@ -2150,14 +2196,11 @@ export class AgentSession {
2150
2196
  async _cycleScopedModel(direction, options) {
2151
2197
  const availableIds = new Set(this._modelRuntime.getAvailableSnapshot().map((model) => `${model.provider}\0${model.id}`));
2152
2198
  const scopedModels = this._scopedModels.filter((scoped) => availableIds.has(`${scoped.model.provider}\0${scoped.model.id}`));
2153
- if (scopedModels.length <= 1)
2154
- return undefined;
2155
2199
  const currentModel = this.model;
2156
- let currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
2157
- if (currentIndex === -1)
2158
- currentIndex = 0;
2159
- const len = scopedModels.length;
2160
- const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
2200
+ const currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
2201
+ const nextIndex = getNextCycleIndex(currentIndex, scopedModels.length, direction);
2202
+ if (nextIndex === undefined)
2203
+ return undefined;
2161
2204
  const next = scopedModels[nextIndex];
2162
2205
  const thinkingLevel = this._getThinkingLevelForModelSwitch(next.model, next.thinkingLevel);
2163
2206
  // Apply model
@@ -2178,14 +2221,11 @@ export class AgentSession {
2178
2221
  }
2179
2222
  async _cycleAvailableModel(direction, options) {
2180
2223
  const availableModels = this._modelRuntime.getAvailableSnapshot();
2181
- if (availableModels.length <= 1)
2182
- return undefined;
2183
2224
  const currentModel = this.model;
2184
- let currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
2185
- if (currentIndex === -1)
2186
- currentIndex = 0;
2187
- const len = availableModels.length;
2188
- const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
2225
+ const currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
2226
+ const nextIndex = getNextCycleIndex(currentIndex, availableModels.length, direction);
2227
+ if (nextIndex === undefined)
2228
+ return undefined;
2189
2229
  const nextModel = availableModels[nextIndex];
2190
2230
  const thinkingLevel = this._getThinkingLevelForModelSwitch(nextModel);
2191
2231
  this.agent.state.model = nextModel;
@@ -3198,6 +3238,7 @@ export class AgentSession {
3198
3238
  // Tools the new extensions register later, such as MCP tools, are pending until then.
3199
3239
  for (const name of this.getActiveToolNames())
3200
3240
  this._pendingToolNames.add(name);
3241
+ this._restoredToolNames = new Set(this.getActiveToolNames());
3201
3242
  this._buildRuntime({
3202
3243
  activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
3203
3244
  flagValues: previousFlagValues,
@@ -3773,9 +3814,9 @@ export class AgentSession {
3773
3814
  // Utilities
3774
3815
  // =========================================================================
3775
3816
  /**
3776
- * Get text content of last assistant message.
3817
+ * Get text content of the last assistant reply.
3777
3818
  * Useful for /copy command.
3778
- * @returns Text content, or undefined if no assistant message exists
3819
+ * @returns Text content, or undefined if no assistant message exists or the last reply has no text
3779
3820
  */
3780
3821
  getLastAssistantText() {
3781
3822
  const lastAssistant = this.messages
@@ -3785,8 +3826,9 @@ export class AgentSession {
3785
3826
  if (m.role !== "assistant")
3786
3827
  return false;
3787
3828
  const msg = m;
3788
- // Skip aborted messages with no content
3789
- if (msg.stopReason === "aborted" && msg.content.length === 0)
3829
+ // Skip messages without text from a turn that did not end normally: aborted, failed or only
3830
+ // calling tools (#12119). A reply that ended normally stays the last reply even without text.
3831
+ if (msg.stopReason !== "stop" && !msg.content.some((c) => c.type === "text" && c.text.trim()))
3790
3832
  return false;
3791
3833
  return true;
3792
3834
  });