@maxmo74/pi-coding-agent 1.5.0-max.8 → 1.6.0-max.16

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 (455) hide show
  1. package/CHANGELOG.md +214 -0
  2. package/README.md +1 -1
  3. package/dist/bundle/chunks/anthropic-messages-WAFIHSF7.js +6 -0
  4. package/dist/bundle/chunks/{azure-openai-responses-FSC6BAW3.js → azure-openai-responses-EB4MRIM4.js} +1 -1
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +3 -3
  6. package/dist/bundle/chunks/chunk-E6LJTZYC.js +82 -0
  7. package/dist/bundle/chunks/chunk-EEBRZED2.js +44 -0
  8. package/dist/bundle/chunks/chunk-EVSO24NP.js +2 -0
  9. package/dist/bundle/chunks/chunk-EXXWEFU5.js +1247 -0
  10. package/dist/bundle/chunks/{chunk-EOO47QGR.js → chunk-F7LEMV2T.js} +1 -1
  11. package/dist/bundle/chunks/chunk-I6HYYNH6.js +8 -0
  12. package/dist/bundle/chunks/chunk-IEBK4HQA.js +2 -0
  13. package/dist/bundle/chunks/{chunk-V6KH5QG4.js → chunk-ILDLA2JW.js} +1 -1
  14. package/dist/bundle/chunks/chunk-INODY4DR.js +2 -0
  15. package/dist/bundle/chunks/{chunk-MSIQUO5T.js → chunk-KREOSXD7.js} +1 -1
  16. package/dist/bundle/chunks/chunk-LWG2CUTI.js +31 -0
  17. package/dist/bundle/chunks/{chunk-3TGLJEWK.js → chunk-NRLRGOCX.js} +1 -1
  18. package/dist/bundle/chunks/chunk-NRY4NBZW.js +4 -0
  19. package/dist/bundle/chunks/chunk-NV3NPOPF.js +20 -0
  20. package/dist/bundle/chunks/{chunk-C2WU32PX.js → chunk-RCNEHRMW.js} +1 -1
  21. package/dist/bundle/chunks/{chunk-4EYXVSA5.js → chunk-X26YOAEH.js} +15 -14
  22. package/dist/bundle/chunks/chunk-X6RQRO3L.js +16 -0
  23. package/dist/bundle/chunks/chunk-XGGZYFNG.js +55 -0
  24. package/dist/bundle/chunks/chunk-XJ2YV77J.js +30 -0
  25. package/dist/bundle/chunks/{chunk-YZKQS34S.js → chunk-Y55SJART.js} +5 -1
  26. package/dist/bundle/chunks/chunk-YOWSKVK7.js +2 -0
  27. package/dist/bundle/chunks/chunk-ZG74NES2.js +2 -0
  28. package/dist/bundle/chunks/{cli-MCOUW5WS.js → cli-QMJEURSM.js} +7 -7
  29. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-WLAFJSP6.js → cloudflare-workers-ai-system-one-AMCR7QEI.js} +1 -1
  30. package/dist/bundle/chunks/codemode-worker.js +2 -0
  31. package/dist/bundle/chunks/{easter-egg-3d-WMBNSJ4M.js → easter-egg-3d-7CBVPJQ3.js} +1 -1
  32. package/dist/bundle/chunks/{execute-4CEBORGZ.js → execute-XDNPBEMU.js} +5 -3
  33. package/dist/bundle/chunks/github-copilot.js +1 -1
  34. package/dist/bundle/chunks/google-generative-ai-43M4N5LK.js +2 -0
  35. package/dist/bundle/chunks/google-vertex-2B3PASK2.js +2 -0
  36. package/dist/bundle/chunks/{llama-cpp-classify-V5U3QKXI.js → llama-cpp-classify-XXZYF3RR.js} +1 -1
  37. package/dist/bundle/chunks/{mistral-conversations-S4OWXIXQ.js → mistral-conversations-E3D5ZQKB.js} +2 -2
  38. package/dist/bundle/chunks/{openai-codex-responses-QAWLOQSN.js → openai-codex-responses-MSQDSDUR.js} +2 -2
  39. package/dist/bundle/chunks/openai-completions-4IC6AGTR.js +7 -0
  40. package/dist/bundle/chunks/{openai-decisions-IXI34BYG.js → openai-decisions-LZ2RLVRX.js} +1 -1
  41. package/dist/bundle/chunks/openai-responses-MCO3BHCC.js +4 -0
  42. package/dist/bundle/chunks/{openrouter-images-PISKSFMS.js → openrouter-images-SHUJ3VSG.js} +1 -1
  43. package/dist/bundle/chunks/{pi-messages-NORUKF4E.js → pi-messages-NIKOQ4O7.js} +1 -1
  44. package/dist/bundle/chunks/{runtime-FQB7RU7U.js → runtime-F3SXQONS.js} +1 -1
  45. package/dist/bundle/chunks/{typesafe-system-one-CHVC2UUI.js → typesafe-system-one-R2CDUWNO.js} +1 -1
  46. package/dist/bundle/chunks/virtual-modules-2WYTGPJ3.js +2 -0
  47. package/dist/bundle/cli-runtime.js +1 -1
  48. package/dist/bundle/index.js +1 -1
  49. package/dist/bundle/rpc-entry.js +1 -1
  50. package/dist/cli/args.d.ts.map +1 -1
  51. package/dist/cli/args.js +5 -3
  52. package/dist/cli/args.js.map +1 -1
  53. package/dist/cli/auth-command.d.ts.map +1 -1
  54. package/dist/cli/auth-command.js +26 -2
  55. package/dist/cli/auth-command.js.map +1 -1
  56. package/dist/cli/auth-login.d.ts +15 -0
  57. package/dist/cli/auth-login.d.ts.map +1 -0
  58. package/dist/cli/auth-login.js +232 -0
  59. package/dist/cli/auth-login.js.map +1 -0
  60. package/dist/cli/auth-logout.d.ts +14 -0
  61. package/dist/cli/auth-logout.d.ts.map +1 -0
  62. package/dist/cli/auth-logout.js +57 -0
  63. package/dist/cli/auth-logout.js.map +1 -0
  64. package/dist/cli/auth-terminal.d.ts +17 -0
  65. package/dist/cli/auth-terminal.d.ts.map +1 -0
  66. package/dist/cli/auth-terminal.js +63 -0
  67. package/dist/cli/auth-terminal.js.map +1 -0
  68. package/dist/cli/config-selector.d.ts.map +1 -1
  69. package/dist/cli/config-selector.js +12 -7
  70. package/dist/cli/config-selector.js.map +1 -1
  71. package/dist/cli/session-picker.d.ts.map +1 -1
  72. package/dist/cli/session-picker.js +9 -6
  73. package/dist/cli/session-picker.js.map +1 -1
  74. package/dist/cli/startup-ui.d.ts.map +1 -1
  75. package/dist/cli/startup-ui.js +4 -0
  76. package/dist/cli/startup-ui.js.map +1 -1
  77. package/dist/core/agent-session-runtime.d.ts +16 -0
  78. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  79. package/dist/core/agent-session-runtime.js +40 -3
  80. package/dist/core/agent-session-runtime.js.map +1 -1
  81. package/dist/core/agent-session.d.ts +31 -9
  82. package/dist/core/agent-session.d.ts.map +1 -1
  83. package/dist/core/agent-session.js +160 -63
  84. package/dist/core/agent-session.js.map +1 -1
  85. package/dist/core/auth-storage.d.ts.map +1 -1
  86. package/dist/core/auth-storage.js +3 -2
  87. package/dist/core/auth-storage.js.map +1 -1
  88. package/dist/core/bash-executor.d.ts.map +1 -1
  89. package/dist/core/bash-executor.js +3 -1
  90. package/dist/core/bash-executor.js.map +1 -1
  91. package/dist/core/cache-warmer.d.ts +4 -37
  92. package/dist/core/cache-warmer.d.ts.map +1 -1
  93. package/dist/core/cache-warmer.js +11 -89
  94. package/dist/core/cache-warmer.js.map +1 -1
  95. package/dist/core/compaction/utils.d.ts.map +1 -1
  96. package/dist/core/compaction/utils.js +2 -1
  97. package/dist/core/compaction/utils.js.map +1 -1
  98. package/dist/core/exec.d.ts +1 -0
  99. package/dist/core/exec.d.ts.map +1 -1
  100. package/dist/core/exec.js +4 -1
  101. package/dist/core/exec.js.map +1 -1
  102. package/dist/core/export-html/ansi-to-html.d.ts +6 -1
  103. package/dist/core/export-html/ansi-to-html.d.ts.map +1 -1
  104. package/dist/core/export-html/ansi-to-html.js +57 -20
  105. package/dist/core/export-html/ansi-to-html.js.map +1 -1
  106. package/dist/core/export-html/template.js +1 -1
  107. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  108. package/dist/core/export-html/tool-renderer.js +2 -3
  109. package/dist/core/export-html/tool-renderer.js.map +1 -1
  110. package/dist/core/extensions/index.d.ts +1 -1
  111. package/dist/core/extensions/index.d.ts.map +1 -1
  112. package/dist/core/extensions/index.js.map +1 -1
  113. package/dist/core/extensions/loader.d.ts.map +1 -1
  114. package/dist/core/extensions/loader.js +28 -6
  115. package/dist/core/extensions/loader.js.map +1 -1
  116. package/dist/core/extensions/runner.d.ts +1 -0
  117. package/dist/core/extensions/runner.d.ts.map +1 -1
  118. package/dist/core/extensions/runner.js +14 -1
  119. package/dist/core/extensions/runner.js.map +1 -1
  120. package/dist/core/extensions/types.d.ts +33 -6
  121. package/dist/core/extensions/types.d.ts.map +1 -1
  122. package/dist/core/extensions/types.js.map +1 -1
  123. package/dist/core/keybindings.d.ts +2 -2
  124. package/dist/core/keybindings.js +1 -1
  125. package/dist/core/keybindings.js.map +1 -1
  126. package/dist/core/mcp-servers.d.ts +12 -37
  127. package/dist/core/mcp-servers.d.ts.map +1 -1
  128. package/dist/core/mcp-servers.js +42 -121
  129. package/dist/core/mcp-servers.js.map +1 -1
  130. package/dist/core/model-config.d.ts +52 -0
  131. package/dist/core/model-config.d.ts.map +1 -1
  132. package/dist/core/model-resolver.d.ts +0 -8
  133. package/dist/core/model-resolver.d.ts.map +1 -1
  134. package/dist/core/model-resolver.js +22 -85
  135. package/dist/core/model-resolver.js.map +1 -1
  136. package/dist/core/model-runtime.d.ts +5 -0
  137. package/dist/core/model-runtime.d.ts.map +1 -1
  138. package/dist/core/model-runtime.js +11 -4
  139. package/dist/core/model-runtime.js.map +1 -1
  140. package/dist/core/package-manager.d.ts +26 -1
  141. package/dist/core/package-manager.d.ts.map +1 -1
  142. package/dist/core/package-manager.js +95 -7
  143. package/dist/core/package-manager.js.map +1 -1
  144. package/dist/core/pi-ai-schemas.d.ts +4 -0
  145. package/dist/core/pi-ai-schemas.d.ts.map +1 -1
  146. package/dist/core/preferred-providers.d.ts +17 -0
  147. package/dist/core/preferred-providers.d.ts.map +1 -0
  148. package/dist/core/preferred-providers.js +24 -0
  149. package/dist/core/preferred-providers.js.map +1 -0
  150. package/dist/core/prompt-templates.d.ts.map +1 -1
  151. package/dist/core/prompt-templates.js +18 -2
  152. package/dist/core/prompt-templates.js.map +1 -1
  153. package/dist/core/provider-composer.d.ts.map +1 -1
  154. package/dist/core/provider-composer.js +3 -1
  155. package/dist/core/provider-composer.js.map +1 -1
  156. package/dist/core/provider-matching.d.ts +6 -0
  157. package/dist/core/provider-matching.d.ts.map +1 -0
  158. package/dist/core/provider-matching.js +8 -0
  159. package/dist/core/provider-matching.js.map +1 -0
  160. package/dist/core/radius-mcp.d.ts +13 -0
  161. package/dist/core/radius-mcp.d.ts.map +1 -0
  162. package/dist/core/radius-mcp.js +29 -0
  163. package/dist/core/radius-mcp.js.map +1 -0
  164. package/dist/core/remote-catalog-provider.d.ts.map +1 -1
  165. package/dist/core/remote-catalog-provider.js +9 -0
  166. package/dist/core/remote-catalog-provider.js.map +1 -1
  167. package/dist/core/resource-loader.d.ts +5 -1
  168. package/dist/core/resource-loader.d.ts.map +1 -1
  169. package/dist/core/resource-loader.js +2 -0
  170. package/dist/core/resource-loader.js.map +1 -1
  171. package/dist/core/runtime-credentials.d.ts +8 -0
  172. package/dist/core/runtime-credentials.d.ts.map +1 -1
  173. package/dist/core/runtime-credentials.js +15 -1
  174. package/dist/core/runtime-credentials.js.map +1 -1
  175. package/dist/core/session-cwd.d.ts +7 -0
  176. package/dist/core/session-cwd.d.ts.map +1 -1
  177. package/dist/core/session-cwd.js +9 -1
  178. package/dist/core/session-cwd.js.map +1 -1
  179. package/dist/core/session-manager.d.ts.map +1 -1
  180. package/dist/core/session-manager.js +45 -36
  181. package/dist/core/session-manager.js.map +1 -1
  182. package/dist/core/session-ownership.js +15 -1
  183. package/dist/core/session-ownership.js.map +1 -1
  184. package/dist/core/settings-defaults.d.ts +1 -1
  185. package/dist/core/settings-defaults.d.ts.map +1 -1
  186. package/dist/core/settings-defaults.js +1 -1
  187. package/dist/core/settings-defaults.js.map +1 -1
  188. package/dist/core/tools/bash.d.ts.map +1 -1
  189. package/dist/core/tools/bash.js +35 -5
  190. package/dist/core/tools/bash.js.map +1 -1
  191. package/dist/core/tools/edit-diff.d.ts +23 -14
  192. package/dist/core/tools/edit-diff.d.ts.map +1 -1
  193. package/dist/core/tools/edit-diff.js +182 -41
  194. package/dist/core/tools/edit-diff.js.map +1 -1
  195. package/dist/core/tools/edit.d.ts.map +1 -1
  196. package/dist/core/tools/edit.js +8 -7
  197. package/dist/core/tools/edit.js.map +1 -1
  198. package/dist/core/tools/find.d.ts.map +1 -1
  199. package/dist/core/tools/find.js +96 -39
  200. package/dist/core/tools/find.js.map +1 -1
  201. package/dist/core/tools/grep.d.ts +5 -3
  202. package/dist/core/tools/grep.d.ts.map +1 -1
  203. package/dist/core/tools/grep.js +87 -75
  204. package/dist/core/tools/grep.js.map +1 -1
  205. package/dist/core/tools/ls.d.ts.map +1 -1
  206. package/dist/core/tools/ls.js +2 -1
  207. package/dist/core/tools/ls.js.map +1 -1
  208. package/dist/core/tools/output-accumulator.d.ts.map +1 -1
  209. package/dist/core/tools/output-accumulator.js +4 -1
  210. package/dist/core/tools/output-accumulator.js.map +1 -1
  211. package/dist/core/tools/powershell.d.ts.map +1 -1
  212. package/dist/core/tools/powershell.js +15 -2
  213. package/dist/core/tools/powershell.js.map +1 -1
  214. package/dist/core/tools/read.d.ts +13 -0
  215. package/dist/core/tools/read.d.ts.map +1 -1
  216. package/dist/core/tools/read.js +146 -35
  217. package/dist/core/tools/read.js.map +1 -1
  218. package/dist/core/tools/renderers/read.d.ts.map +1 -1
  219. package/dist/core/tools/renderers/read.js +6 -2
  220. package/dist/core/tools/renderers/read.js.map +1 -1
  221. package/dist/core/tools/truncate.d.ts +4 -14
  222. package/dist/core/tools/truncate.d.ts.map +1 -1
  223. package/dist/core/tools/truncate.js +23 -29
  224. package/dist/core/tools/truncate.js.map +1 -1
  225. package/dist/extensions/codemode/execute.js +4 -4
  226. package/dist/extensions/codemode/execute.js.map +1 -1
  227. package/dist/extensions/codemode/tool.d.ts.map +1 -1
  228. package/dist/extensions/codemode/tool.js +34 -12
  229. package/dist/extensions/codemode/tool.js.map +1 -1
  230. package/dist/extensions/llama/client.d.ts +2 -0
  231. package/dist/extensions/llama/client.d.ts.map +1 -1
  232. package/dist/extensions/llama/client.js +23 -2
  233. package/dist/extensions/llama/client.js.map +1 -1
  234. package/dist/extensions/llama/provider.d.ts +1 -1
  235. package/dist/extensions/llama/provider.d.ts.map +1 -1
  236. package/dist/extensions/llama/provider.js +6 -4
  237. package/dist/extensions/llama/provider.js.map +1 -1
  238. package/dist/extensions/llama/ui.d.ts.map +1 -1
  239. package/dist/extensions/llama/ui.js +15 -3
  240. package/dist/extensions/llama/ui.js.map +1 -1
  241. package/dist/extensions/mcp/cli.d.ts +2 -0
  242. package/dist/extensions/mcp/cli.d.ts.map +1 -1
  243. package/dist/extensions/mcp/cli.js +49 -14
  244. package/dist/extensions/mcp/cli.js.map +1 -1
  245. package/dist/extensions/mcp/config.d.ts.map +1 -1
  246. package/dist/extensions/mcp/config.js +4 -7
  247. package/dist/extensions/mcp/config.js.map +1 -1
  248. package/dist/extensions/mcp/index.d.ts.map +1 -1
  249. package/dist/extensions/mcp/index.js +7 -9
  250. package/dist/extensions/mcp/index.js.map +1 -1
  251. package/dist/extensions/mcp/oauth.d.ts +11 -49
  252. package/dist/extensions/mcp/oauth.d.ts.map +1 -1
  253. package/dist/extensions/mcp/oauth.js +56 -319
  254. package/dist/extensions/mcp/oauth.js.map +1 -1
  255. package/dist/extensions/mcp/resources.d.ts +1 -1
  256. package/dist/extensions/mcp/resources.d.ts.map +1 -1
  257. package/dist/extensions/mcp/resources.js +4 -3
  258. package/dist/extensions/mcp/resources.js.map +1 -1
  259. package/dist/extensions/mcp/runtime.d.ts +4 -3
  260. package/dist/extensions/mcp/runtime.d.ts.map +1 -1
  261. package/dist/extensions/mcp/runtime.js +7 -5
  262. package/dist/extensions/mcp/runtime.js.map +1 -1
  263. package/dist/extensions/mcp/tools.d.ts +2 -23
  264. package/dist/extensions/mcp/tools.d.ts.map +1 -1
  265. package/dist/extensions/mcp/tools.js +6 -58
  266. package/dist/extensions/mcp/tools.js.map +1 -1
  267. package/dist/extensions/tool-search/tool.d.ts.map +1 -1
  268. package/dist/extensions/tool-search/tool.js +18 -6
  269. package/dist/extensions/tool-search/tool.js.map +1 -1
  270. package/dist/index.d.ts +1 -1
  271. package/dist/index.d.ts.map +1 -1
  272. package/dist/index.js.map +1 -1
  273. package/dist/main.d.ts.map +1 -1
  274. package/dist/main.js +98 -27
  275. package/dist/main.js.map +1 -1
  276. package/dist/modes/diagnostics-stderr.d.ts +4 -0
  277. package/dist/modes/diagnostics-stderr.d.ts.map +1 -0
  278. package/dist/modes/diagnostics-stderr.js +11 -0
  279. package/dist/modes/diagnostics-stderr.js.map +1 -0
  280. package/dist/modes/interactive/components/assistant-message.d.ts +2 -1
  281. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  282. package/dist/modes/interactive/components/assistant-message.js +9 -3
  283. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  284. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  285. package/dist/modes/interactive/components/branch-summary-message.d.ts +5 -1
  286. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  287. package/dist/modes/interactive/components/branch-summary-message.js +12 -4
  288. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  289. package/dist/modes/interactive/components/compaction-summary-message.d.ts +5 -1
  290. package/dist/modes/interactive/components/compaction-summary-message.d.ts.map +1 -1
  291. package/dist/modes/interactive/components/compaction-summary-message.js +12 -4
  292. package/dist/modes/interactive/components/compaction-summary-message.js.map +1 -1
  293. package/dist/modes/interactive/components/config-selector.d.ts.map +1 -1
  294. package/dist/modes/interactive/components/config-selector.js +5 -2
  295. package/dist/modes/interactive/components/config-selector.js.map +1 -1
  296. package/dist/modes/interactive/components/custom-message.d.ts +5 -2
  297. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  298. package/dist/modes/interactive/components/custom-message.js +10 -3
  299. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  300. package/dist/modes/interactive/components/diff.d.ts.map +1 -1
  301. package/dist/modes/interactive/components/diff.js +11 -5
  302. package/dist/modes/interactive/components/diff.js.map +1 -1
  303. package/dist/modes/interactive/components/extension-selector.d.ts.map +1 -1
  304. package/dist/modes/interactive/components/extension-selector.js +9 -1
  305. package/dist/modes/interactive/components/extension-selector.js.map +1 -1
  306. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  307. package/dist/modes/interactive/components/login-dialog.js +1 -18
  308. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  309. package/dist/modes/interactive/components/mermaid.d.ts +2 -1
  310. package/dist/modes/interactive/components/mermaid.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/mermaid.js +25 -20
  312. package/dist/modes/interactive/components/mermaid.js.map +1 -1
  313. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  314. package/dist/modes/interactive/components/model-selector.js +19 -8
  315. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  316. package/dist/modes/interactive/components/oauth-selector.d.ts +10 -3
  317. package/dist/modes/interactive/components/oauth-selector.d.ts.map +1 -1
  318. package/dist/modes/interactive/components/oauth-selector.js +39 -8
  319. package/dist/modes/interactive/components/oauth-selector.js.map +1 -1
  320. package/dist/modes/interactive/components/provider-brand.d.ts +14 -0
  321. package/dist/modes/interactive/components/provider-brand.d.ts.map +1 -0
  322. package/dist/modes/interactive/components/provider-brand.js +66 -0
  323. package/dist/modes/interactive/components/provider-brand.js.map +1 -0
  324. package/dist/modes/interactive/components/radius-login-selector.d.ts +1 -2
  325. package/dist/modes/interactive/components/radius-login-selector.d.ts.map +1 -1
  326. package/dist/modes/interactive/components/radius-login-selector.js +8 -38
  327. package/dist/modes/interactive/components/radius-login-selector.js.map +1 -1
  328. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  329. package/dist/modes/interactive/components/scoped-models-selector.js +9 -1
  330. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  331. package/dist/modes/interactive/components/session-selector.d.ts +8 -1
  332. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  333. package/dist/modes/interactive/components/session-selector.js +41 -9
  334. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  335. package/dist/modes/interactive/components/settings-submenu.d.ts +1 -1
  336. package/dist/modes/interactive/components/settings-submenu.d.ts.map +1 -1
  337. package/dist/modes/interactive/components/settings-submenu.js +5 -1
  338. package/dist/modes/interactive/components/settings-submenu.js.map +1 -1
  339. package/dist/modes/interactive/components/skill-invocation-message.d.ts +5 -1
  340. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  341. package/dist/modes/interactive/components/skill-invocation-message.js +12 -4
  342. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  343. package/dist/modes/interactive/components/themed-text.d.ts +1 -1
  344. package/dist/modes/interactive/components/themed-text.d.ts.map +1 -1
  345. package/dist/modes/interactive/components/themed-text.js.map +1 -1
  346. package/dist/modes/interactive/components/thinking-selector.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/thinking-selector.js +5 -1
  348. package/dist/modes/interactive/components/thinking-selector.js.map +1 -1
  349. package/dist/modes/interactive/components/tool-execution.d.ts +1 -1
  350. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  351. package/dist/modes/interactive/components/tool-execution.js +3 -1
  352. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  353. package/dist/modes/interactive/components/tree-selector.d.ts +1 -0
  354. package/dist/modes/interactive/components/tree-selector.d.ts.map +1 -1
  355. package/dist/modes/interactive/components/tree-selector.js +19 -10
  356. package/dist/modes/interactive/components/tree-selector.js.map +1 -1
  357. package/dist/modes/interactive/components/user-message.d.ts +2 -1
  358. package/dist/modes/interactive/components/user-message.d.ts.map +1 -1
  359. package/dist/modes/interactive/components/user-message.js +9 -3
  360. package/dist/modes/interactive/components/user-message.js.map +1 -1
  361. package/dist/modes/interactive/components/visual-truncate.d.ts +2 -2
  362. package/dist/modes/interactive/components/visual-truncate.d.ts.map +1 -1
  363. package/dist/modes/interactive/components/visual-truncate.js.map +1 -1
  364. package/dist/modes/interactive/interactive-mode.d.ts +14 -2
  365. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  366. package/dist/modes/interactive/interactive-mode.js +232 -127
  367. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  368. package/dist/modes/interactive/session-share.js +2 -0
  369. package/dist/modes/interactive/session-share.js.map +1 -1
  370. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  371. package/dist/modes/interactive/theme/theme.js +5 -0
  372. package/dist/modes/interactive/theme/theme.js.map +1 -1
  373. package/dist/modes/print-mode.d.ts.map +1 -1
  374. package/dist/modes/print-mode.js +35 -23
  375. package/dist/modes/print-mode.js.map +1 -1
  376. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  377. package/dist/modes/rpc/rpc-mode.js +67 -45
  378. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  379. package/dist/package-manager-cli.d.ts.map +1 -1
  380. package/dist/package-manager-cli.js +53 -9
  381. package/dist/package-manager-cli.js.map +1 -1
  382. package/dist/utils/changelog.d.ts +2 -2
  383. package/dist/utils/changelog.d.ts.map +1 -1
  384. package/dist/utils/changelog.js +15 -8
  385. package/dist/utils/changelog.js.map +1 -1
  386. package/dist/utils/flush-stdout.d.ts +8 -0
  387. package/dist/utils/flush-stdout.d.ts.map +1 -0
  388. package/dist/utils/flush-stdout.js +23 -0
  389. package/dist/utils/flush-stdout.js.map +1 -0
  390. package/dist/utils/image-resize.d.ts.map +1 -1
  391. package/dist/utils/image-resize.js +3 -1
  392. package/dist/utils/image-resize.js.map +1 -1
  393. package/dist/utils/terminal-question.d.ts +8 -0
  394. package/dist/utils/terminal-question.d.ts.map +1 -0
  395. package/dist/utils/terminal-question.js +24 -0
  396. package/dist/utils/terminal-question.js.map +1 -0
  397. package/dist/utils/version-check.js +1 -1
  398. package/dist/utils/version-check.js.map +1 -1
  399. package/dist/utils/web-url.d.ts +12 -0
  400. package/dist/utils/web-url.d.ts.map +1 -0
  401. package/dist/utils/web-url.js +20 -0
  402. package/dist/utils/web-url.js.map +1 -0
  403. package/docs/cli.md +14 -1
  404. package/docs/extensions.md +31 -11
  405. package/docs/keybindings.md +1 -1
  406. package/docs/llama-cpp.md +5 -8
  407. package/docs/models-configuration.md +9 -3
  408. package/docs/models.md +2 -1
  409. package/docs/nvidia-rtx-llama-cpp.md +5 -5
  410. package/docs/prompt-templates.md +1 -1
  411. package/docs/providers.md +4 -2
  412. package/docs/rpc-commands.md +1 -1
  413. package/docs/rpc.md +4 -2
  414. package/docs/sessions.md +7 -1
  415. package/docs/settings.md +1 -1
  416. package/docs/tui.md +3 -1
  417. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  418. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  419. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  420. package/examples/extensions/gondolin/index.ts +4 -7
  421. package/examples/extensions/gondolin/package-lock.json +2 -2
  422. package/examples/extensions/gondolin/package.json +1 -1
  423. package/examples/extensions/plan-mode/index.ts +23 -13
  424. package/examples/extensions/plan-mode/utils.ts +42 -16
  425. package/examples/extensions/subagent/README.md +14 -11
  426. package/examples/extensions/subagent/index.ts +392 -171
  427. package/examples/extensions/with-deps/package-lock.json +2 -2
  428. package/examples/extensions/with-deps/package.json +1 -1
  429. package/examples/tsconfig.json +63 -35
  430. package/package.json +11 -11
  431. package/schemas/models.schema.json +30 -1
  432. package/schemas/settings.schema.json +1 -1
  433. package/dist/bundle/chunks/anthropic-messages-BWGCKOF4.js +0 -6
  434. package/dist/bundle/chunks/chunk-62VOPMLK.js +0 -65
  435. package/dist/bundle/chunks/chunk-7O7QKK6A.js +0 -2
  436. package/dist/bundle/chunks/chunk-B46VJEHW.js +0 -44
  437. package/dist/bundle/chunks/chunk-CF5GWZHW.js +0 -31
  438. package/dist/bundle/chunks/chunk-CHWNPHIS.js +0 -82
  439. package/dist/bundle/chunks/chunk-FGCQRPD5.js +0 -1239
  440. package/dist/bundle/chunks/chunk-GN3QYODH.js +0 -16
  441. package/dist/bundle/chunks/chunk-NL4X6LBY.js +0 -4
  442. package/dist/bundle/chunks/chunk-NZY7EIPA.js +0 -4
  443. package/dist/bundle/chunks/chunk-R2EGYMOO.js +0 -7
  444. package/dist/bundle/chunks/chunk-UKVNB6C4.js +0 -2
  445. package/dist/bundle/chunks/chunk-USJZMAIR.js +0 -2
  446. package/dist/bundle/chunks/chunk-VOLAXWGI.js +0 -2
  447. package/dist/bundle/chunks/google-generative-ai-INGKNW72.js +0 -2
  448. package/dist/bundle/chunks/google-vertex-IBTX6MBF.js +0 -2
  449. package/dist/bundle/chunks/openai-completions-EJNYB6IX.js +0 -7
  450. package/dist/bundle/chunks/openai-responses-MD3562FB.js +0 -4
  451. package/dist/bundle/chunks/virtual-modules-CLD44EYP.js +0 -2
  452. package/dist/utils/deprecation.d.ts +0 -4
  453. package/dist/utils/deprecation.d.ts.map +0 -1
  454. package/dist/utils/deprecation.js +0 -13
  455. package/dist/utils/deprecation.js.map +0 -1
@@ -89,6 +89,20 @@ function estimateMessagesTokens(messages) {
89
89
  // ============================================================================
90
90
  // AgentSession Class
91
91
  // ============================================================================
92
+ /**
93
+ * Index of the model to cycle to, or undefined when there is nothing to switch to.
94
+ * When the current model is not in the list (currentIndex -1), forward picks the first
95
+ * entry and backward the last, so a one-entry list still selects its only model.
96
+ */
97
+ function getNextCycleIndex(currentIndex, length, direction) {
98
+ if (length === 0)
99
+ return undefined;
100
+ if (currentIndex === -1)
101
+ return direction === "forward" ? 0 : length - 1;
102
+ if (length === 1)
103
+ return undefined;
104
+ return direction === "forward" ? (currentIndex + 1) % length : (currentIndex - 1 + length) % length;
105
+ }
92
106
  export class AgentSession {
93
107
  agent;
94
108
  sessionManager;
@@ -98,6 +112,7 @@ export class AgentSession {
98
112
  _unsubscribeAgent;
99
113
  _eventListeners = [];
100
114
  _isAgentRunActive = false;
115
+ _promptPreflightCount = 0;
101
116
  _agentRunAbortRequested = false;
102
117
  _idleWaitPromise;
103
118
  _resolveIdleWait;
@@ -105,6 +120,8 @@ export class AgentSession {
105
120
  _steeringMessages = [];
106
121
  /** Tracks pending follow-up messages for UI display. Removed when delivered. */
107
122
  _followUpMessages = [];
123
+ /** Queued user messages whose images are normalized when they are delivered. */
124
+ _queuedMessagesWithImages = new WeakSet();
108
125
  /** Messages queued to be included with the next user prompt as context ("asides"). */
109
126
  _pendingNextTurnMessages = [];
110
127
  /** Context-only custom messages queued during a run, flushed once the current turn's tool results are in. */
@@ -146,9 +163,11 @@ export class AgentSession {
146
163
  /**
147
164
  * Tools of the restored or reloaded loadout that are not registered yet, such as tools of MCP
148
165
  * servers that are still connecting. They are activated when they are registered, and dropped when
149
- * `setActiveToolsByName()` deactivates a tool or the next agent run starts.
166
+ * `setActiveToolsByName()` deactivates a tool of that loadout or the next agent run starts.
150
167
  */
151
168
  _pendingToolNames = new Set();
169
+ /** The restored or reloaded loadout that `_pendingToolNames` belongs to. */
170
+ _restoredToolNames = new Set();
152
171
  _usesDefaultTools;
153
172
  _defaultToolModifiers;
154
173
  /** Matches the `--tools` entries: tool names or patterns. */
@@ -168,6 +187,8 @@ export class AgentSession {
168
187
  _extensionShutdownHandler;
169
188
  _extensionErrorListener;
170
189
  _extensionErrorUnsubscriber;
190
+ // Set by bindExtensions(): reload() restarts extensions only if the host started them.
191
+ _extensionsBound = false;
171
192
  _modelRuntime;
172
193
  _cacheWarmer;
173
194
  // Tool registry for extension getTools/setTools
@@ -299,19 +320,25 @@ export class AgentSession {
299
320
  return this._modelRuntime.getPhysicalModel(message.provider, message.model);
300
321
  return model?.provider === message.provider && model.id === message.model ? model : undefined;
301
322
  }
323
+ /** Record the live model and thinking level on the current branch, so a resume restores them. */
324
+ _recordSelection() {
325
+ const branch = this.sessionManager.getBranch();
326
+ this._recordModelSelection(branch);
327
+ this._recordThinkingLevel(branch);
328
+ }
302
329
  /**
303
- * Record the selection on the current branch when the branch implies another one, so a resume
304
- * restores it. Tree navigation can leave the latest `model_change` on another branch; responses
305
- * cannot record a virtual selection because they name physical models. Responses do record a
306
- * physical selection unless the branch holds a virtual one; checking a physical selection against
307
- * responses would record it on every prompt while `prepareRequest` redirects to another model.
330
+ * Record the model on the current branch when the branch implies another one. Tree navigation
331
+ * can leave the latest `model_change` on another branch; responses cannot record a virtual
332
+ * selection because they name physical models. Responses do record a physical selection unless
333
+ * the branch holds a virtual one; checking a physical selection against responses would record
334
+ * it on every prompt while `prepareRequest` redirects to another model.
308
335
  */
309
- _recordSelection() {
336
+ _recordModelSelection(branch) {
310
337
  const model = this.model;
311
338
  if (!model)
312
339
  return;
313
340
  const getModel = (provider, modelId) => this._modelRuntime.getModel(provider, modelId);
314
- const recorded = getBranchSelection(this.sessionManager.getBranch(), getModel);
341
+ const recorded = getBranchSelection(branch, getModel);
315
342
  if (!recorded || (recorded.provider === model.provider && recorded.modelId === model.id))
316
343
  return;
317
344
  const recordedModel = getModel(recorded.provider, recorded.modelId);
@@ -319,6 +346,25 @@ export class AgentSession {
319
346
  return;
320
347
  this.sessionManager.appendModelChange(model.provider, model.id);
321
348
  }
349
+ /**
350
+ * Record the thinking level on the current branch when the branch implies another one (#11451).
351
+ * Tree navigation can leave the latest `thinking_level_change` on another branch. The recorded
352
+ * level is compared after clamping to the current model, so a level clamped on resume (e.g.
353
+ * `xhigh` running as `high`) is not recorded over the requested one.
354
+ */
355
+ _recordThinkingLevel(branch) {
356
+ const recorded = branch.findLast((entry) => entry.type === "thinking_level_change");
357
+ if (!recorded)
358
+ return;
359
+ const recordedLevel = recorded.thinkingLevel;
360
+ const availableLevels = this.getAvailableThinkingLevels();
361
+ const effective = availableLevels.includes(recordedLevel)
362
+ ? recordedLevel
363
+ : this._clampThinkingLevel(recordedLevel, availableLevels);
364
+ if (effective === this.thinkingLevel)
365
+ return;
366
+ this.sessionManager.appendThinkingLevelChange(this.thinkingLevel);
367
+ }
322
368
  /** The model whose limits apply to the conversation. */
323
369
  _limitsModel() {
324
370
  return this.routedModel?.model ?? this.model;
@@ -744,21 +790,25 @@ export class AgentSession {
744
790
  if (event.type === "message_start" && event.message.role === "user") {
745
791
  this._overflowRecoveryAttempted = false;
746
792
  const messageText = contentText(event.message.content, "");
747
- if (messageText) {
748
- // Check steering queue first
749
- const steeringIndex = this._steeringMessages.indexOf(messageText);
750
- if (steeringIndex !== -1) {
751
- this._steeringMessages.splice(steeringIndex, 1);
793
+ // Check steering queue first
794
+ const steeringIndex = this._steeringMessages.indexOf(messageText);
795
+ if (steeringIndex !== -1) {
796
+ this._steeringMessages.splice(steeringIndex, 1);
797
+ this._emitQueueUpdate();
798
+ }
799
+ else {
800
+ // Check follow-up queue
801
+ const followUpIndex = this._followUpMessages.indexOf(messageText);
802
+ if (followUpIndex !== -1) {
803
+ this._followUpMessages.splice(followUpIndex, 1);
752
804
  this._emitQueueUpdate();
753
805
  }
754
- else {
755
- // Check follow-up queue
756
- const followUpIndex = this._followUpMessages.indexOf(messageText);
757
- if (followUpIndex !== -1) {
758
- this._followUpMessages.splice(followUpIndex, 1);
759
- this._emitQueueUpdate();
760
- }
761
- }
806
+ }
807
+ // Normalize queued images at delivery, before events and persistence see the message,
808
+ // so they get the same resize as idle prompts with the current model's limits (#11738).
809
+ if (this._queuedMessagesWithImages.has(event.message)) {
810
+ this._queuedMessagesWithImages.delete(event.message);
811
+ await this._normalizeQueuedMessageImages(event.message);
762
812
  }
763
813
  }
764
814
  // Emit to extensions first, then notify public listeners.
@@ -1132,11 +1182,14 @@ export class AgentSession {
1132
1182
  setActiveToolsByName(toolNames) {
1133
1183
  const previous = this.getActiveToolNames();
1134
1184
  this._setActiveTools(toolNames);
1135
- // A loadout that deactivates a tool replaces the restored one, whose pending tools are dropped.
1136
- // One that only adds tools, like activating tool_search, keeps them.
1185
+ // A loadout that deactivates a tool of the restored one replaces it, and its pending tools are
1186
+ // dropped. One that only adds tools, like activating tool_search, keeps them, and so does one
1187
+ // that only deactivates tools outside the restored loadout, such as an extension's own tool that
1188
+ // the restore or reload activated as newly registered.
1137
1189
  const active = new Set(this.getActiveToolNames());
1138
- if (previous.some((name) => !active.has(name)))
1190
+ if (previous.some((name) => !active.has(name) && this._restoredToolNames.has(name))) {
1139
1191
  this._pendingToolNames.clear();
1192
+ }
1140
1193
  }
1141
1194
  _setActiveTools(toolNames) {
1142
1195
  const tools = this._applyToolLoadout(toolNames);
@@ -1406,6 +1459,7 @@ export class AgentSession {
1406
1459
  */
1407
1460
  _restoreToolsFromTranscript(modifiers = []) {
1408
1461
  this._pendingToolNames.clear();
1462
+ this._restoredToolNames.clear();
1409
1463
  // All system messages on the branch, including those before a compaction. Compaction snapshots
1410
1464
  // are derived from these, so replaying them gives the current loadout.
1411
1465
  const systemMessages = this.sessionManager
@@ -1426,6 +1480,7 @@ export class AgentSession {
1426
1480
  // Recorded tools that are not registered yet, such as MCP tools of servers still connecting, are
1427
1481
  // activated when they register. Excluded tools never register, so they are not kept pending.
1428
1482
  this._pendingToolNames = new Set(names.filter((name) => this._isAllowedTool(name)));
1483
+ this._restoredToolNames = new Set(applyToolModifiers(getCurrentTools(systemMessages).map((tool) => tool.name), modifiers));
1429
1484
  // Ignores names that are not registered.
1430
1485
  this._setActiveTools(names);
1431
1486
  }
@@ -1663,14 +1718,34 @@ export class AgentSession {
1663
1718
  return;
1664
1719
  }
1665
1720
  }
1666
- if (this._compactionAbortController !== undefined) {
1721
+ if (this._compactionAbortController !== undefined || this._branchSummaryAbortController !== undefined) {
1667
1722
  throw new Error("Cannot submit a prompt while compaction is in progress. Wait for compaction to finish and retry.");
1668
1723
  }
1724
+ // Reserve the context through async input hooks and auth checks so tree navigation cannot
1725
+ // start meanwhile (#9154). _startRun marks the run active synchronously, so there is no gap.
1726
+ this._promptPreflightCount++;
1727
+ let trigger;
1728
+ try {
1729
+ trigger = await this._preparePrompt(text, options);
1730
+ }
1731
+ finally {
1732
+ this._promptPreflightCount--;
1733
+ }
1734
+ if (trigger)
1735
+ await this._startRun(trigger, () => preflightResult?.("started"));
1736
+ }
1737
+ /**
1738
+ * Run input hooks, expand templates, queue while streaming, and validate model and auth.
1739
+ * Returns the run trigger, or undefined when the prompt was handled or queued.
1740
+ */
1741
+ async _preparePrompt(text, options) {
1742
+ const expandPromptTemplates = options?.expandPromptTemplates ?? true;
1743
+ const preflightResult = options?.preflightResult;
1669
1744
  // Emit input event for extension interception (before skill/template expansion)
1670
1745
  const processedInput = await this._runInputHandlers(text, options?.images, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
1671
1746
  if (!processedInput) {
1672
1747
  preflightResult?.("handled");
1673
- return;
1748
+ return undefined;
1674
1749
  }
1675
1750
  const { text: currentText, images: currentImages } = processedInput;
1676
1751
  // Expand skill commands (/skill:name args) and prompt templates (/template args)
@@ -1691,7 +1766,7 @@ export class AgentSession {
1691
1766
  await this._queueSteer(expandedText, currentImages);
1692
1767
  }
1693
1768
  preflightResult?.("queued");
1694
- return;
1769
+ return undefined;
1695
1770
  }
1696
1771
  // Validate model
1697
1772
  if (!this.model) {
@@ -1708,7 +1783,7 @@ export class AgentSession {
1708
1783
  }
1709
1784
  throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
1710
1785
  }
1711
- await this._startRun({ messageType: "user", prompt: expandedText, images: currentImages }, () => preflightResult?.("started"));
1786
+ return { messageType: "user", prompt: expandedText, images: currentImages };
1712
1787
  }
1713
1788
  /**
1714
1789
  * Try to execute an extension command. Returns true if command was found and executed.
@@ -1817,11 +1892,10 @@ export class AgentSession {
1817
1892
  if (images) {
1818
1893
  content.push(...images);
1819
1894
  }
1820
- this.agent.steer({
1821
- role: "user",
1822
- content,
1823
- timestamp: Date.now(),
1824
- });
1895
+ const message = { role: "user", content, timestamp: Date.now() };
1896
+ if (images?.length)
1897
+ this._queuedMessagesWithImages.add(message);
1898
+ this.agent.steer(message);
1825
1899
  }
1826
1900
  /**
1827
1901
  * Internal: Queue a follow-up message (already expanded, no extension command check).
@@ -1833,7 +1907,26 @@ export class AgentSession {
1833
1907
  if (images) {
1834
1908
  content.push(...images);
1835
1909
  }
1836
- this.agent.followUp({ role: "user", content, timestamp: Date.now() });
1910
+ const message = { role: "user", content, timestamp: Date.now() };
1911
+ if (images?.length)
1912
+ this._queuedMessagesWithImages.add(message);
1913
+ this.agent.followUp(message);
1914
+ }
1915
+ /** Replace a queued user message's images in place with normalized ones, appending hints to its text. */
1916
+ async _normalizeQueuedMessageImages(message) {
1917
+ if (typeof message.content === "string")
1918
+ return;
1919
+ const [first, ...rest] = message.content;
1920
+ if (first?.type !== "text")
1921
+ return;
1922
+ const images = rest.filter((block) => block.type === "image");
1923
+ const normalized = await this._normalizePromptImages(images);
1924
+ const text = normalized.hints.length > 0 ? `${first.text}\n\n${normalized.hints.join("\n")}` : first.text;
1925
+ message.content = [
1926
+ { type: "text", text },
1927
+ ...rest.filter((block) => block.type !== "image"),
1928
+ ...normalized.images,
1929
+ ];
1837
1930
  }
1838
1931
  /**
1839
1932
  * Throw an error if the text is an extension command.
@@ -2070,14 +2163,11 @@ export class AgentSession {
2070
2163
  async _cycleScopedModel(direction, options) {
2071
2164
  const availableIds = new Set(this._modelRuntime.getAvailableSnapshot().map((model) => `${model.provider}\0${model.id}`));
2072
2165
  const scopedModels = this._scopedModels.filter((scoped) => availableIds.has(`${scoped.model.provider}\0${scoped.model.id}`));
2073
- if (scopedModels.length <= 1)
2074
- return undefined;
2075
2166
  const currentModel = this.model;
2076
- let currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
2077
- if (currentIndex === -1)
2078
- currentIndex = 0;
2079
- const len = scopedModels.length;
2080
- const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
2167
+ const currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));
2168
+ const nextIndex = getNextCycleIndex(currentIndex, scopedModels.length, direction);
2169
+ if (nextIndex === undefined)
2170
+ return undefined;
2081
2171
  const next = scopedModels[nextIndex];
2082
2172
  const thinkingLevel = this._getThinkingLevelForModelSwitch(next.model, next.thinkingLevel);
2083
2173
  // Apply model
@@ -2098,14 +2188,11 @@ export class AgentSession {
2098
2188
  }
2099
2189
  async _cycleAvailableModel(direction, options) {
2100
2190
  const availableModels = this._modelRuntime.getAvailableSnapshot();
2101
- if (availableModels.length <= 1)
2102
- return undefined;
2103
2191
  const currentModel = this.model;
2104
- let currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
2105
- if (currentIndex === -1)
2106
- currentIndex = 0;
2107
- const len = availableModels.length;
2108
- const nextIndex = direction === "forward" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;
2192
+ const currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));
2193
+ const nextIndex = getNextCycleIndex(currentIndex, availableModels.length, direction);
2194
+ if (nextIndex === undefined)
2195
+ return undefined;
2109
2196
  const nextModel = availableModels[nextIndex];
2110
2197
  const thinkingLevel = this._getThinkingLevelForModelSwitch(nextModel);
2111
2198
  this.agent.state.model = nextModel;
@@ -2694,6 +2781,7 @@ export class AgentSession {
2694
2781
  if (bindings.onError !== undefined) {
2695
2782
  this._extensionErrorListener = bindings.onError;
2696
2783
  }
2784
+ this._extensionsBound = true;
2697
2785
  this._applyExtensionBindings(this._extensionRunner);
2698
2786
  await this._extensionRunner.emit(this._sessionStartEvent);
2699
2787
  this._extensionRunner.reportUnhandledMcpServers();
@@ -3014,6 +3102,12 @@ export class AgentSession {
3014
3102
  });
3015
3103
  }
3016
3104
  async reload(options) {
3105
+ if (this.isStreaming) {
3106
+ throw new Error("Wait for the current response to finish before reloading.");
3107
+ }
3108
+ if (this.isCompacting) {
3109
+ throw new Error("Wait for compaction to finish before reloading.");
3110
+ }
3017
3111
  const oldRunner = this._extensionRunner;
3018
3112
  const previousFlagValues = oldRunner.getFlagValues();
3019
3113
  await emitSessionShutdownEvent(oldRunner, { type: "session_shutdown", reason: "reload" });
@@ -3032,16 +3126,13 @@ export class AgentSession {
3032
3126
  // Tools the new extensions register later, such as MCP tools, are pending until then.
3033
3127
  for (const name of this.getActiveToolNames())
3034
3128
  this._pendingToolNames.add(name);
3129
+ this._restoredToolNames = new Set(this.getActiveToolNames());
3035
3130
  this._buildRuntime({
3036
3131
  activeToolNames: [...this.getActiveToolNames(), ...addedDefaultTools],
3037
3132
  flagValues: previousFlagValues,
3038
3133
  includeAllExtensionTools: true,
3039
3134
  });
3040
- const hasBindings = this._extensionUIContext ||
3041
- this._extensionCommandContextActions ||
3042
- this._extensionShutdownHandler ||
3043
- this._extensionErrorListener;
3044
- if (hasBindings) {
3135
+ if (this._extensionsBound) {
3045
3136
  await options?.beforeSessionStart?.();
3046
3137
  await this._extensionRunner.emit({ type: "session_start", reason: "reload" });
3047
3138
  this._extensionRunner.reportUnhandledMcpServers();
@@ -3277,7 +3368,7 @@ export class AgentSession {
3277
3368
  * @returns Result with editorText (if user message) and cancelled status
3278
3369
  */
3279
3370
  async navigateTree(targetId, options = {}) {
3280
- if (this.isStreaming) {
3371
+ if (this.isStreaming || this._promptPreflightCount > 0) {
3281
3372
  throw new Error("Wait for the current response to finish before navigating the session tree.");
3282
3373
  }
3283
3374
  if (this.isCompacting) {
@@ -3313,7 +3404,8 @@ export class AgentSession {
3313
3404
  label,
3314
3405
  };
3315
3406
  // Set up abort controller for summarization
3316
- this._branchSummaryAbortController = new AbortController();
3407
+ const abortController = new AbortController();
3408
+ this._branchSummaryAbortController = abortController;
3317
3409
  try {
3318
3410
  let extensionSummary;
3319
3411
  let fromExtension = false;
@@ -3322,7 +3414,7 @@ export class AgentSession {
3322
3414
  const result = (await this._extensionRunner.emit({
3323
3415
  type: "session_before_tree",
3324
3416
  preparation,
3325
- signal: this._branchSummaryAbortController.signal,
3417
+ signal: abortController.signal,
3326
3418
  }));
3327
3419
  if (result?.cancel) {
3328
3420
  return { cancelled: true };
@@ -3347,7 +3439,7 @@ export class AgentSession {
3347
3439
  let summaryDetails;
3348
3440
  let summaryUsage;
3349
3441
  if (options.summarize && entriesToSummarize.length > 0 && !extensionSummary) {
3350
- const signal = this._branchSummaryAbortController.signal;
3442
+ const signal = abortController.signal;
3351
3443
  const branchSummarySettings = this.settingsManager.getBranchSummarySettings();
3352
3444
  const result = await generateBranchSummary(entriesToSummarize, {
3353
3445
  ...(await this._getSummarizationRequestAuth(this.model, signal)),
@@ -3421,7 +3513,8 @@ export class AgentSession {
3421
3513
  // Update finalized context from the canonical session projection.
3422
3514
  this._refreshFinalizedContext();
3423
3515
  this._restoreToolsFromTranscript();
3424
- // Emit session_tree event
3516
+ // The selected context is installed; session_tree handlers may now prompt or navigate again.
3517
+ this._branchSummaryAbortController = undefined;
3425
3518
  await this._extensionRunner.emit({
3426
3519
  type: "session_tree",
3427
3520
  newLeafId: this.sessionManager.getLeafId(),
@@ -3433,7 +3526,10 @@ export class AgentSession {
3433
3526
  return { editorText, cancelled: false, summaryEntry };
3434
3527
  }
3435
3528
  finally {
3436
- this._branchSummaryAbortController = undefined;
3529
+ // A navigation started from session_tree owns the controller now; do not clear it.
3530
+ if (this._branchSummaryAbortController === abortController) {
3531
+ this._branchSummaryAbortController = undefined;
3532
+ }
3437
3533
  this._resolveIdleWaitIfIdle();
3438
3534
  }
3439
3535
  }
@@ -3602,9 +3698,9 @@ export class AgentSession {
3602
3698
  // Utilities
3603
3699
  // =========================================================================
3604
3700
  /**
3605
- * Get text content of last assistant message.
3701
+ * Get text content of the last assistant reply.
3606
3702
  * Useful for /copy command.
3607
- * @returns Text content, or undefined if no assistant message exists
3703
+ * @returns Text content, or undefined if no assistant message exists or the last reply has no text
3608
3704
  */
3609
3705
  getLastAssistantText() {
3610
3706
  const lastAssistant = this.messages
@@ -3614,8 +3710,9 @@ export class AgentSession {
3614
3710
  if (m.role !== "assistant")
3615
3711
  return false;
3616
3712
  const msg = m;
3617
- // Skip aborted messages with no content
3618
- if (msg.stopReason === "aborted" && msg.content.length === 0)
3713
+ // Skip messages without text from a turn that did not end normally: aborted, failed or only
3714
+ // calling tools (#12119). A reply that ended normally stays the last reply even without text.
3715
+ if (msg.stopReason !== "stop" && !msg.content.some((c) => c.type === "text" && c.text.trim()))
3619
3716
  return false;
3620
3717
  return true;
3621
3718
  });