@ashx-j/lunr 0.2.26 → 0.2.27

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 (639) hide show
  1. package/CHANGELOG.md +16 -1
  2. package/LICENSE +22 -0
  3. package/dist/builtin-extensions/ashxj-thinking.d.ts +1 -1
  4. package/dist/builtin-extensions/ashxj-thinking.d.ts.map +1 -1
  5. package/dist/builtin-extensions/ashxj-thinking.js +1 -1
  6. package/dist/builtin-extensions/ashxj-thinking.js.map +1 -1
  7. package/dist/builtin-extensions/ashxj-tui.d.ts +11 -1
  8. package/dist/builtin-extensions/ashxj-tui.d.ts.map +1 -1
  9. package/dist/builtin-extensions/ashxj-tui.js +6 -10
  10. package/dist/builtin-extensions/ashxj-tui.js.map +1 -1
  11. package/dist/builtin-extensions/lunr-cron.d.ts +4 -5
  12. package/dist/builtin-extensions/lunr-cron.d.ts.map +1 -1
  13. package/dist/builtin-extensions/lunr-cron.js +94 -108
  14. package/dist/builtin-extensions/lunr-cron.js.map +1 -1
  15. package/dist/builtin-extensions/lunr-local-providers/local-servers.d.ts.map +1 -1
  16. package/dist/builtin-extensions/lunr-local-providers/local-servers.js +3 -1
  17. package/dist/builtin-extensions/lunr-local-providers/local-servers.js.map +1 -1
  18. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.d.ts.map +1 -1
  19. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js +2 -2
  20. package/dist/builtin-extensions/narumiruna-pi-goal/src/commands.js.map +1 -1
  21. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.d.ts.map +1 -1
  22. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js +1 -1
  23. package/dist/builtin-extensions/narumiruna-pi-goal/src/goal.js.map +1 -1
  24. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.d.ts.map +1 -1
  25. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js +1 -1
  26. package/dist/builtin-extensions/narumiruna-pi-goal/src/runtime.js.map +1 -1
  27. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  28. package/dist/builtin-extensions/pi-intercom/index.js +2 -2
  29. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  30. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts +1 -1
  31. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.d.ts.map +1 -1
  32. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js +1 -1
  33. package/dist/builtin-extensions/pi-lsp-extension/bemol-extension/index.js.map +1 -1
  34. package/dist/builtin-extensions/pi-lsp-extension/src/index.d.ts.map +1 -1
  35. package/dist/builtin-extensions/pi-lsp-extension/src/index.js +1 -15
  36. package/dist/builtin-extensions/pi-lsp-extension/src/index.js.map +1 -1
  37. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts +6 -0
  38. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.d.ts.map +1 -1
  39. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js +187 -132
  40. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-client.js.map +1 -1
  41. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts +8 -0
  42. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.d.ts.map +1 -1
  43. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js +142 -112
  44. package/dist/builtin-extensions/pi-lsp-extension/src/lsp-manager.js.map +1 -1
  45. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts +12 -1
  46. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.d.ts.map +1 -1
  47. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js +14 -7
  48. package/dist/builtin-extensions/pi-lsp-extension/src/tools/code-rewrite.js.map +1 -1
  49. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts +11 -3
  50. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.d.ts.map +1 -1
  51. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js +67 -41
  52. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/rewrite-engine.js.map +1 -1
  53. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts +4 -2
  54. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.d.ts.map +1 -1
  55. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js +3 -0
  56. package/dist/builtin-extensions/pi-lsp-extension/src/tree-sitter/search-engine.js.map +1 -1
  57. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts +2 -1
  58. package/dist/builtin-extensions/pi-mcp-adapter/commands.d.ts.map +1 -1
  59. package/dist/builtin-extensions/pi-mcp-adapter/commands.js +6 -6
  60. package/dist/builtin-extensions/pi-mcp-adapter/commands.js.map +1 -1
  61. package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts +1 -1
  62. package/dist/builtin-extensions/pi-mcp-adapter/config.d.ts.map +1 -1
  63. package/dist/builtin-extensions/pi-mcp-adapter/config.js +11 -5
  64. package/dist/builtin-extensions/pi-mcp-adapter/config.js.map +1 -1
  65. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.d.ts.map +1 -1
  66. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js +2 -2
  67. package/dist/builtin-extensions/pi-mcp-adapter/direct-tool-executor.js.map +1 -1
  68. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.d.ts.map +1 -1
  69. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js +1 -1
  70. package/dist/builtin-extensions/pi-mcp-adapter/host-html-template.js.map +1 -1
  71. package/dist/builtin-extensions/pi-mcp-adapter/index.d.ts.map +1 -1
  72. package/dist/builtin-extensions/pi-mcp-adapter/index.js +48 -40
  73. package/dist/builtin-extensions/pi-mcp-adapter/index.js.map +1 -1
  74. package/dist/builtin-extensions/pi-mcp-adapter/init.d.ts.map +1 -1
  75. package/dist/builtin-extensions/pi-mcp-adapter/init.js +3 -1
  76. package/dist/builtin-extensions/pi-mcp-adapter/init.js.map +1 -1
  77. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts +12 -40
  78. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.d.ts.map +1 -1
  79. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js +166 -235
  80. package/dist/builtin-extensions/pi-mcp-adapter/mcp-auth-flow.js.map +1 -1
  81. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts +5 -0
  82. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.d.ts.map +1 -1
  83. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js +43 -13
  84. package/dist/builtin-extensions/pi-mcp-adapter/mcp-callback-server.js.map +1 -1
  85. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts +14 -3
  86. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.d.ts.map +1 -1
  87. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js +73 -21
  88. package/dist/builtin-extensions/pi-mcp-adapter/mcp-oauth-provider.js.map +1 -1
  89. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.d.ts.map +1 -1
  90. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js +4 -4
  91. package/dist/builtin-extensions/pi-mcp-adapter/proxy-modes.js.map +1 -1
  92. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.d.ts.map +1 -1
  93. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js +2 -2
  94. package/dist/builtin-extensions/pi-mcp-adapter/server-manager.js.map +1 -1
  95. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts +2 -0
  96. package/dist/builtin-extensions/pi-mcp-adapter/state.d.ts.map +1 -1
  97. package/dist/builtin-extensions/pi-mcp-adapter/state.js.map +1 -1
  98. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts +1 -1
  99. package/dist/builtin-extensions/pi-ollama-cloud/index.d.ts.map +1 -1
  100. package/dist/builtin-extensions/pi-ollama-cloud/index.js +1 -1
  101. package/dist/builtin-extensions/pi-ollama-cloud/index.js.map +1 -1
  102. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts +11 -5
  103. package/dist/builtin-extensions/pi-ollama-cloud/models.d.ts.map +1 -1
  104. package/dist/builtin-extensions/pi-ollama-cloud/models.js +12 -32
  105. package/dist/builtin-extensions/pi-ollama-cloud/models.js.map +1 -1
  106. package/dist/builtin-extensions/pi-prompt-template-model/index.d.ts.map +1 -1
  107. package/dist/builtin-extensions/pi-prompt-template-model/index.js +5 -3
  108. package/dist/builtin-extensions/pi-prompt-template-model/index.js.map +1 -1
  109. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts +2 -1
  110. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.d.ts.map +1 -1
  111. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js +21 -12
  112. package/dist/builtin-extensions/pi-prompt-template-model/prompt-loader.js.map +1 -1
  113. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.d.ts.map +1 -1
  114. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js +7 -24
  115. package/dist/builtin-extensions/pi-prompt-template-model/tool-manager.js.map +1 -1
  116. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  117. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +39 -77
  118. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  119. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts +1 -1
  120. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.d.ts.map +1 -1
  121. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js +15 -31
  122. package/dist/builtin-extensions/pi-subagents/src/runs/background/notify.js.map +1 -1
  123. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.d.ts.map +1 -1
  124. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js +7 -2
  125. package/dist/builtin-extensions/pi-subagents/src/runs/background/result-watcher.js.map +1 -1
  126. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.d.ts.map +1 -1
  127. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js +10 -2
  128. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-runner.js.map +1 -1
  129. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.d.ts.map +1 -1
  130. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js +8 -1
  131. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/chain-execution.js.map +1 -1
  132. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.d.ts.map +1 -1
  133. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js +106 -24
  134. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/execution.js.map +1 -1
  135. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  136. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +25 -5
  137. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  138. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts +1 -1
  139. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.d.ts.map +1 -1
  140. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js +1 -1
  141. package/dist/builtin-extensions/pi-subagents/src/runs/shared/model-fallback.js.map +1 -1
  142. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts +7 -8
  143. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.d.ts.map +1 -1
  144. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js +60 -32
  145. package/dist/builtin-extensions/pi-subagents/src/runs/shared/parallel-utils.js.map +1 -1
  146. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts +1 -1
  147. package/dist/builtin-extensions/pi-subagents/src/shared/utils.d.ts.map +1 -1
  148. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js +15 -5
  149. package/dist/builtin-extensions/pi-subagents/src/shared/utils.js.map +1 -1
  150. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.d.ts.map +1 -1
  151. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js +4 -3
  152. package/dist/builtin-extensions/pi-subagents/src/slash/prompt-workflows.js.map +1 -1
  153. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts +1 -1
  154. package/dist/builtin-extensions/pi-subagents/src/tui/render.d.ts.map +1 -1
  155. package/dist/builtin-extensions/pi-subagents/src/tui/render.js +17 -8
  156. package/dist/builtin-extensions/pi-subagents/src/tui/render.js.map +1 -1
  157. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.d.ts.map +1 -1
  158. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js +3 -3
  159. package/dist/builtin-extensions/pi-subagents/src/watchdog/review.js.map +1 -1
  160. package/dist/builtin-extensions/pi-tps.d.ts.map +1 -1
  161. package/dist/builtin-extensions/pi-tps.js +20 -17
  162. package/dist/builtin-extensions/pi-tps.js.map +1 -1
  163. package/dist/builtin-extensions/pi-web-access/activity.d.ts +1 -0
  164. package/dist/builtin-extensions/pi-web-access/activity.d.ts.map +1 -1
  165. package/dist/builtin-extensions/pi-web-access/activity.js +27 -5
  166. package/dist/builtin-extensions/pi-web-access/activity.js.map +1 -1
  167. package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts +3 -0
  168. package/dist/builtin-extensions/pi-web-access/bounded-body.d.ts.map +1 -0
  169. package/dist/builtin-extensions/pi-web-access/bounded-body.js +43 -0
  170. package/dist/builtin-extensions/pi-web-access/bounded-body.js.map +1 -0
  171. package/dist/builtin-extensions/pi-web-access/content-page.d.ts +24 -0
  172. package/dist/builtin-extensions/pi-web-access/content-page.d.ts.map +1 -0
  173. package/dist/builtin-extensions/pi-web-access/content-page.js +57 -0
  174. package/dist/builtin-extensions/pi-web-access/content-page.js.map +1 -0
  175. package/dist/builtin-extensions/pi-web-access/extract.d.ts.map +1 -1
  176. package/dist/builtin-extensions/pi-web-access/extract.js +7 -2
  177. package/dist/builtin-extensions/pi-web-access/extract.js.map +1 -1
  178. package/dist/builtin-extensions/pi-web-access/github-extract.d.ts +0 -1
  179. package/dist/builtin-extensions/pi-web-access/github-extract.d.ts.map +1 -1
  180. package/dist/builtin-extensions/pi-web-access/github-extract.js +147 -36
  181. package/dist/builtin-extensions/pi-web-access/github-extract.js.map +1 -1
  182. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  183. package/dist/builtin-extensions/pi-web-access/index.js +48 -73
  184. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  185. package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts +12 -4
  186. package/dist/builtin-extensions/pi-web-access/session-cleanup.d.ts.map +1 -1
  187. package/dist/builtin-extensions/pi-web-access/session-cleanup.js +35 -12
  188. package/dist/builtin-extensions/pi-web-access/session-cleanup.js.map +1 -1
  189. package/dist/builtin-extensions/pi-web-access/storage.d.ts +9 -6
  190. package/dist/builtin-extensions/pi-web-access/storage.d.ts.map +1 -1
  191. package/dist/builtin-extensions/pi-web-access/storage.js +36 -24
  192. package/dist/builtin-extensions/pi-web-access/storage.js.map +1 -1
  193. package/dist/builtin-extensions/simple-pi-memory.d.ts +1 -1
  194. package/dist/builtin-extensions/simple-pi-memory.d.ts.map +1 -1
  195. package/dist/builtin-extensions/simple-pi-memory.js +1 -1
  196. package/dist/builtin-extensions/simple-pi-memory.js.map +1 -1
  197. package/dist/cli/install-cli.d.ts.map +1 -1
  198. package/dist/cli/install-cli.js +38 -30
  199. package/dist/cli/install-cli.js.map +1 -1
  200. package/dist/core/agent-session-runtime.d.ts +13 -0
  201. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  202. package/dist/core/agent-session-runtime.js +75 -11
  203. package/dist/core/agent-session-runtime.js.map +1 -1
  204. package/dist/core/agent-session-services.d.ts +1 -0
  205. package/dist/core/agent-session-services.d.ts.map +1 -1
  206. package/dist/core/agent-session-services.js +1 -0
  207. package/dist/core/agent-session-services.js.map +1 -1
  208. package/dist/core/agent-session.d.ts +40 -6
  209. package/dist/core/agent-session.d.ts.map +1 -1
  210. package/dist/core/agent-session.js +309 -76
  211. package/dist/core/agent-session.js.map +1 -1
  212. package/dist/core/browser/runtime.d.ts +2 -0
  213. package/dist/core/browser/runtime.d.ts.map +1 -1
  214. package/dist/core/browser/runtime.js +80 -45
  215. package/dist/core/browser/runtime.js.map +1 -1
  216. package/dist/core/browser/setup.d.ts.map +1 -1
  217. package/dist/core/browser/setup.js +12 -1
  218. package/dist/core/browser/setup.js.map +1 -1
  219. package/dist/core/computer-use/adapter.d.ts.map +1 -1
  220. package/dist/core/computer-use/adapter.js +7 -2
  221. package/dist/core/computer-use/adapter.js.map +1 -1
  222. package/dist/core/computer-use/image.d.ts.map +1 -1
  223. package/dist/core/computer-use/image.js +17 -5
  224. package/dist/core/computer-use/image.js.map +1 -1
  225. package/dist/core/computer-use/schemas.d.ts.map +1 -1
  226. package/dist/core/computer-use/schemas.js +23 -6
  227. package/dist/core/computer-use/schemas.js.map +1 -1
  228. package/dist/core/computer-use/workflow.d.ts.map +1 -1
  229. package/dist/core/computer-use/workflow.js +459 -119
  230. package/dist/core/computer-use/workflow.js.map +1 -1
  231. package/dist/core/cron/jobs.d.ts +26 -8
  232. package/dist/core/cron/jobs.d.ts.map +1 -1
  233. package/dist/core/cron/jobs.js +357 -232
  234. package/dist/core/cron/jobs.js.map +1 -1
  235. package/dist/core/cron/origin-context.d.ts +1 -0
  236. package/dist/core/cron/origin-context.d.ts.map +1 -1
  237. package/dist/core/cron/origin-context.js.map +1 -1
  238. package/dist/core/cron/scheduler.d.ts +22 -17
  239. package/dist/core/cron/scheduler.d.ts.map +1 -1
  240. package/dist/core/cron/scheduler.js +153 -73
  241. package/dist/core/cron/scheduler.js.map +1 -1
  242. package/dist/core/extensions/index.d.ts +1 -1
  243. package/dist/core/extensions/index.d.ts.map +1 -1
  244. package/dist/core/extensions/index.js.map +1 -1
  245. package/dist/core/extensions/runner.d.ts +1 -0
  246. package/dist/core/extensions/runner.d.ts.map +1 -1
  247. package/dist/core/extensions/runner.js +8 -0
  248. package/dist/core/extensions/runner.js.map +1 -1
  249. package/dist/core/extensions/types.d.ts +8 -0
  250. package/dist/core/extensions/types.d.ts.map +1 -1
  251. package/dist/core/extensions/types.js.map +1 -1
  252. package/dist/core/footer-data-provider.d.ts +4 -0
  253. package/dist/core/footer-data-provider.d.ts.map +1 -1
  254. package/dist/core/footer-data-provider.js +22 -1
  255. package/dist/core/footer-data-provider.js.map +1 -1
  256. package/dist/core/large-subagent-launch.d.ts +1 -1
  257. package/dist/core/large-subagent-launch.d.ts.map +1 -1
  258. package/dist/core/large-subagent-launch.js +7 -7
  259. package/dist/core/large-subagent-launch.js.map +1 -1
  260. package/dist/core/model-registry.d.ts +2 -0
  261. package/dist/core/model-registry.d.ts.map +1 -1
  262. package/dist/core/model-registry.js +5 -0
  263. package/dist/core/model-registry.js.map +1 -1
  264. package/dist/core/model-runtime.d.ts +4 -1
  265. package/dist/core/model-runtime.d.ts.map +1 -1
  266. package/dist/core/model-runtime.js +40 -4
  267. package/dist/core/model-runtime.js.map +1 -1
  268. package/dist/core/package-manager.d.ts.map +1 -1
  269. package/dist/core/package-manager.js.map +1 -1
  270. package/dist/core/permissions.d.ts +3 -3
  271. package/dist/core/permissions.d.ts.map +1 -1
  272. package/dist/core/permissions.js +11 -35
  273. package/dist/core/permissions.js.map +1 -1
  274. package/dist/core/plan-mode.d.ts +5 -13
  275. package/dist/core/plan-mode.d.ts.map +1 -1
  276. package/dist/core/plan-mode.js +126 -116
  277. package/dist/core/plan-mode.js.map +1 -1
  278. package/dist/core/project-trust.d.ts.map +1 -1
  279. package/dist/core/project-trust.js +1 -1
  280. package/dist/core/project-trust.js.map +1 -1
  281. package/dist/core/prompt-resource-bridge.d.ts +12 -0
  282. package/dist/core/prompt-resource-bridge.d.ts.map +1 -0
  283. package/dist/core/prompt-resource-bridge.js +9 -0
  284. package/dist/core/prompt-resource-bridge.js.map +1 -0
  285. package/dist/core/protected-targets.d.ts +6 -0
  286. package/dist/core/protected-targets.d.ts.map +1 -0
  287. package/dist/core/protected-targets.js +45 -0
  288. package/dist/core/protected-targets.js.map +1 -0
  289. package/dist/core/resource-loader.d.ts.map +1 -1
  290. package/dist/core/resource-loader.js +7 -0
  291. package/dist/core/resource-loader.js.map +1 -1
  292. package/dist/core/rollback.d.ts +19 -3
  293. package/dist/core/rollback.d.ts.map +1 -1
  294. package/dist/core/rollback.js +172 -56
  295. package/dist/core/rollback.js.map +1 -1
  296. package/dist/core/runtime-credentials.d.ts +3 -0
  297. package/dist/core/runtime-credentials.d.ts.map +1 -1
  298. package/dist/core/runtime-credentials.js +14 -1
  299. package/dist/core/runtime-credentials.js.map +1 -1
  300. package/dist/core/sdk.d.ts +3 -0
  301. package/dist/core/sdk.d.ts.map +1 -1
  302. package/dist/core/sdk.js +1 -0
  303. package/dist/core/sdk.js.map +1 -1
  304. package/dist/core/session-manager.d.ts +6 -0
  305. package/dist/core/session-manager.d.ts.map +1 -1
  306. package/dist/core/session-manager.js +95 -32
  307. package/dist/core/session-manager.js.map +1 -1
  308. package/dist/core/session-ownership.d.ts.map +1 -1
  309. package/dist/core/session-ownership.js +8 -3
  310. package/dist/core/session-ownership.js.map +1 -1
  311. package/dist/core/session-retention.d.ts.map +1 -1
  312. package/dist/core/session-retention.js +18 -7
  313. package/dist/core/session-retention.js.map +1 -1
  314. package/dist/core/session-startup-settings.d.ts +10 -0
  315. package/dist/core/session-startup-settings.d.ts.map +1 -0
  316. package/dist/core/session-startup-settings.js +70 -0
  317. package/dist/core/session-startup-settings.js.map +1 -0
  318. package/dist/core/subscriptions.d.ts +16 -7
  319. package/dist/core/subscriptions.d.ts.map +1 -1
  320. package/dist/core/subscriptions.js +96 -55
  321. package/dist/core/subscriptions.js.map +1 -1
  322. package/dist/core/trust-manager.d.ts +2 -1
  323. package/dist/core/trust-manager.d.ts.map +1 -1
  324. package/dist/core/trust-manager.js +6 -1
  325. package/dist/core/trust-manager.js.map +1 -1
  326. package/dist/core/update-check.d.ts.map +1 -1
  327. package/dist/core/update-check.js.map +1 -1
  328. package/dist/core/usage-adapters/kimi-coding.d.ts +2 -2
  329. package/dist/core/usage-adapters/kimi-coding.d.ts.map +1 -1
  330. package/dist/core/usage-adapters/kimi-coding.js +2 -2
  331. package/dist/core/usage-adapters/kimi-coding.js.map +1 -1
  332. package/dist/core/usage-adapters/openai-codex.d.ts +3 -2
  333. package/dist/core/usage-adapters/openai-codex.d.ts.map +1 -1
  334. package/dist/core/usage-adapters/openai-codex.js +3 -3
  335. package/dist/core/usage-adapters/openai-codex.js.map +1 -1
  336. package/dist/core/usage-adapters/xai.d.ts +2 -2
  337. package/dist/core/usage-adapters/xai.d.ts.map +1 -1
  338. package/dist/core/usage-adapters/xai.js +3 -3
  339. package/dist/core/usage-adapters/xai.js.map +1 -1
  340. package/dist/core/usage-adapters/zai.d.ts +2 -2
  341. package/dist/core/usage-adapters/zai.d.ts.map +1 -1
  342. package/dist/core/usage-adapters/zai.js +2 -2
  343. package/dist/core/usage-adapters/zai.js.map +1 -1
  344. package/dist/core/usage-service.d.ts +9 -2
  345. package/dist/core/usage-service.d.ts.map +1 -1
  346. package/dist/core/usage-service.js +95 -50
  347. package/dist/core/usage-service.js.map +1 -1
  348. package/dist/gateway/agent-bridge.d.ts +9 -1
  349. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  350. package/dist/gateway/agent-bridge.js +91 -37
  351. package/dist/gateway/agent-bridge.js.map +1 -1
  352. package/dist/gateway/buttons.d.ts +8 -1
  353. package/dist/gateway/buttons.d.ts.map +1 -1
  354. package/dist/gateway/buttons.js +76 -18
  355. package/dist/gateway/buttons.js.map +1 -1
  356. package/dist/gateway/commands.d.ts +1 -0
  357. package/dist/gateway/commands.d.ts.map +1 -1
  358. package/dist/gateway/commands.js +10 -4
  359. package/dist/gateway/commands.js.map +1 -1
  360. package/dist/gateway/cron.d.ts +12 -11
  361. package/dist/gateway/cron.d.ts.map +1 -1
  362. package/dist/gateway/cron.js +65 -56
  363. package/dist/gateway/cron.js.map +1 -1
  364. package/dist/gateway/index.d.ts.map +1 -1
  365. package/dist/gateway/index.js +2 -1
  366. package/dist/gateway/index.js.map +1 -1
  367. package/dist/gateway/mobile-commands.d.ts +1 -0
  368. package/dist/gateway/mobile-commands.d.ts.map +1 -1
  369. package/dist/gateway/mobile-commands.js +56 -14
  370. package/dist/gateway/mobile-commands.js.map +1 -1
  371. package/dist/gateway/presenter.d.ts +12 -2
  372. package/dist/gateway/presenter.d.ts.map +1 -1
  373. package/dist/gateway/presenter.js +73 -38
  374. package/dist/gateway/presenter.js.map +1 -1
  375. package/dist/gateway/router.d.ts +2 -2
  376. package/dist/gateway/router.d.ts.map +1 -1
  377. package/dist/gateway/router.js +17 -2
  378. package/dist/gateway/router.js.map +1 -1
  379. package/dist/gateway/service.d.ts +2 -0
  380. package/dist/gateway/service.d.ts.map +1 -1
  381. package/dist/gateway/service.js +153 -0
  382. package/dist/gateway/service.js.map +1 -1
  383. package/dist/main.d.ts.map +1 -1
  384. package/dist/main.js +86 -33
  385. package/dist/main.js.map +1 -1
  386. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  387. package/dist/modes/interactive/components/assistant-message.js +6 -4
  388. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  389. package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -1
  390. package/dist/modes/interactive/components/copyable-text.js +3 -2
  391. package/dist/modes/interactive/components/copyable-text.js.map +1 -1
  392. package/dist/modes/interactive/components/extension-editor.d.ts.map +1 -1
  393. package/dist/modes/interactive/components/extension-editor.js +1 -1
  394. package/dist/modes/interactive/components/extension-editor.js.map +1 -1
  395. package/dist/modes/interactive/interactive-mode.d.ts +2 -2
  396. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  397. package/dist/modes/interactive/interactive-mode.js +96 -109
  398. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  399. package/dist/modes/interactive/smooth-streaming.d.ts.map +1 -1
  400. package/dist/modes/interactive/smooth-streaming.js.map +1 -1
  401. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  402. package/dist/modes/rpc/rpc-mode.js +2 -1
  403. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  404. package/dist/node-runtime/{adapter-VFG7WNPX.js → adapter-247RTYLS.js} +4 -5
  405. package/dist/node-runtime/agent-session-services-KDMSPQDY.js +53 -0
  406. package/dist/node-runtime/{brave-UWDA3I22.js → brave-2AFFAXNN.js} +1 -1
  407. package/dist/node-runtime/{builtin-extensions-I2HIFEMY.js → builtin-extensions-OX6KELNX.js} +8 -7
  408. package/dist/node-runtime/{chunk-QH6YL7VK.js → chunk-252ZVPPF.js} +3 -3
  409. package/dist/node-runtime/{chunk-PCEW76PM.js → chunk-2OIPYKLZ.js} +6 -6
  410. package/dist/node-runtime/{chunk-XBWPBZBN.js → chunk-2SWW7KMW.js} +1 -1
  411. package/dist/node-runtime/{chunk-UQUCFAJ3.js → chunk-2VIW3IMF.js} +40 -7
  412. package/dist/node-runtime/{chunk-UOEDI7RP.js → chunk-4KNKQGHM.js} +2 -2
  413. package/dist/node-runtime/{chunk-FQMM2EZ2.js → chunk-64XTQNLA.js} +29 -7
  414. package/dist/node-runtime/{chunk-SPVDBUOS.js → chunk-6O3IW3IA.js} +2 -2
  415. package/dist/node-runtime/{chunk-5ZQXRPMC.js → chunk-6ZZHGUSA.js} +2 -2
  416. package/dist/node-runtime/chunk-A2WO6WIN.js +1197 -0
  417. package/dist/node-runtime/{chunk-WIF24I7G.js → chunk-APVM5NEU.js} +149 -144
  418. package/dist/node-runtime/{chunk-RCR3XAQY.js → chunk-AYHH7YSD.js} +177 -144
  419. package/dist/node-runtime/{chunk-LWYIVUGV.js → chunk-B2IBAXNX.js} +48 -31
  420. package/dist/node-runtime/{chunk-M3LZLQW2.js → chunk-BDRGN3L2.js} +1 -0
  421. package/dist/node-runtime/{chunk-GJ2RDBRL.js → chunk-BYC6RKCN.js} +4 -2
  422. package/dist/node-runtime/{chunk-UVWCDQYF.js → chunk-C3P6Q3B2.js} +455 -278
  423. package/dist/node-runtime/{chunk-SN2KSMPQ.js → chunk-DQSCFU7R.js} +13 -7
  424. package/dist/node-runtime/{chunk-4SBQAI4T.js → chunk-EBLAZVSA.js} +2058 -73
  425. package/dist/node-runtime/{chunk-2KIPT4HJ.js → chunk-EPR2F3GU.js} +68 -20
  426. package/dist/node-runtime/{chunk-CSFI6YXL.js → chunk-ES6PBSIE.js} +1 -1
  427. package/dist/node-runtime/{chunk-IF24A3FH.js → chunk-EVM653DD.js} +4 -4
  428. package/dist/node-runtime/{chunk-HTFRRDSF.js → chunk-F2SMQ6ES.js} +3 -2
  429. package/dist/node-runtime/chunk-F2V2F4ZG.js +114 -0
  430. package/dist/node-runtime/{chunk-IKU6Y7DL.js → chunk-FE3WZI7F.js} +9 -6
  431. package/dist/node-runtime/{chunk-GYIXXQAO.js → chunk-FIRA54AC.js} +2 -5
  432. package/dist/node-runtime/{chunk-6VYZ5UFP.js → chunk-FLGEEH27.js} +1 -1
  433. package/dist/node-runtime/{chunk-5EFIU3OM.js → chunk-FTKEZL27.js} +1 -1
  434. package/dist/node-runtime/{chunk-RGQAEOM5.js → chunk-FYIFPFXE.js} +23 -6
  435. package/dist/node-runtime/{chunk-HMBGROQK.js → chunk-GLDXBBL6.js} +3 -3
  436. package/dist/node-runtime/{chunk-KWA4OC2J.js → chunk-H6YBCWKG.js} +1 -1
  437. package/dist/node-runtime/{chunk-2MI5OPMN.js → chunk-HNNHHJAB.js} +68 -50
  438. package/dist/node-runtime/{chunk-I74LN5JG.js → chunk-HUD2RFJW.js} +2 -2
  439. package/dist/node-runtime/{chunk-I54LGHWM.js → chunk-I2H5QMWW.js} +3 -3
  440. package/dist/node-runtime/{chunk-XHIRAZ26.js → chunk-IAZSK7KK.js} +1 -1
  441. package/dist/node-runtime/{chunk-X3PGBLQ7.js → chunk-IHHTWSXN.js} +9 -9
  442. package/dist/node-runtime/{chunk-DAPBPCBP.js → chunk-IPP5BIV5.js} +25 -3
  443. package/dist/node-runtime/{chunk-QFWG2RVL.js → chunk-IXG6F4NT.js} +11 -0
  444. package/dist/node-runtime/{chunk-RDDAZOMU.js → chunk-JL4HYQXK.js} +1 -1
  445. package/dist/node-runtime/{chunk-CDVHZOOK.js → chunk-JQYNHAKX.js} +1 -1
  446. package/dist/node-runtime/{chunk-L24TPBS4.js → chunk-JWEVT363.js} +37 -29
  447. package/dist/node-runtime/{chunk-2HMIRK7W.js → chunk-LHV3V67B.js} +5 -5
  448. package/dist/node-runtime/{chunk-UAEOTO52.js → chunk-MNQXDFPV.js} +6 -2
  449. package/dist/node-runtime/{chunk-T4DA4XE7.js → chunk-MQPKUHRN.js} +162 -82
  450. package/dist/node-runtime/{chunk-MPKSOJBT.js → chunk-NHATCSOI.js} +4 -7
  451. package/dist/node-runtime/{chunk-RMQZU2YU.js → chunk-NNNR3QIY.js} +1 -1
  452. package/dist/node-runtime/{chunk-RWTKOC3B.js → chunk-QBTJG3UM.js} +1 -1
  453. package/dist/node-runtime/{chunk-P7XBVXGT.js → chunk-QNVMKNNN.js} +18 -14
  454. package/dist/node-runtime/{chunk-GS42T6MX.js → chunk-QW3AAHWN.js} +1 -1
  455. package/dist/node-runtime/{chunk-DVQSHCVP.js → chunk-R4WSB2MQ.js} +5 -5
  456. package/dist/node-runtime/{chunk-B4HP6ZWM.js → chunk-RHCGYWO7.js} +1 -1
  457. package/dist/node-runtime/{chunk-2CFDTH5B.js → chunk-RLGY2QIL.js} +45 -59
  458. package/dist/node-runtime/{chunk-KKUTQQV7.js → chunk-RYRGL7P4.js} +1 -1
  459. package/dist/node-runtime/{chunk-5Q4A37RB.js → chunk-TCT6PCUR.js} +32 -11
  460. package/dist/node-runtime/{chunk-D5UCKPBQ.js → chunk-UBWW2PID.js} +1 -1
  461. package/dist/node-runtime/{chunk-E75WFZ33.js → chunk-UNUZICC4.js} +3 -3
  462. package/dist/node-runtime/{chunk-RAK2QA2B.js → chunk-UYRKUKFE.js} +4 -4
  463. package/dist/node-runtime/{chunk-LWJXTA6Z.js → chunk-VSUEAI7O.js} +1377 -45
  464. package/dist/node-runtime/{chunk-NAY6UUQZ.js → chunk-WDIVLMOH.js} +1 -1
  465. package/dist/node-runtime/{chunk-E24EO34J.js → chunk-WPXUR3HE.js} +1 -1
  466. package/dist/node-runtime/{chunk-SLVOAQOY.js → chunk-WXYNALHD.js} +113 -1
  467. package/dist/node-runtime/{chunk-KJ6DWS3K.js → chunk-XEOCUEUJ.js} +121 -60
  468. package/dist/node-runtime/chunk-YD3IZAZ7.js +47 -0
  469. package/dist/node-runtime/chunk-YSB6URMT.js +41 -0
  470. package/dist/node-runtime/{chunk-LJTIVM7I.js → chunk-ZDJUR45D.js} +427 -126
  471. package/dist/node-runtime/{chunk-YWOJIGFY.js → chunk-ZEVFBFNF.js} +95 -142
  472. package/dist/node-runtime/{chunk-5B6VKFEV.js → chunk-ZIQUS5QO.js} +1 -1
  473. package/dist/node-runtime/cli-runtime.js +4 -4
  474. package/dist/node-runtime/{command-FSBU2EVZ.js → command-3HMSY6W2.js} +5 -5
  475. package/dist/node-runtime/{commands-EMBQQVVT.js → commands-D6A6H4TS.js} +11 -18
  476. package/dist/node-runtime/{commands-NAAL7KNT.js → commands-OCSSEEWJ.js} +16 -16
  477. package/dist/node-runtime/{config-QDD5PUE2.js → config-CU7M7BTK.js} +1 -1
  478. package/dist/node-runtime/{config-D4QUPAHX.js → config-DS7XLMEM.js} +2 -2
  479. package/dist/node-runtime/{direct-tool-executor-4D7UXYU4.js → direct-tool-executor-2QJXVQD2.js} +6 -11
  480. package/dist/node-runtime/{exa-LL64QZR2.js → exa-6VBZNPGE.js} +1 -1
  481. package/dist/node-runtime/{export-html-VM4J2MNR.js → export-html-BRWF5AHI.js} +4 -4
  482. package/dist/node-runtime/{extension-input-E7BJZ35H.js → extension-input-VBBMX7YV.js} +5 -5
  483. package/dist/node-runtime/{extension-selector-WU42XDTU.js → extension-selector-T5AOG5XB.js} +5 -5
  484. package/dist/node-runtime/{extract-EQJE7FZZ.js → extract-BFX2N35A.js} +3 -3
  485. package/dist/node-runtime/{gateway-DQM333YV.js → gateway-6623C2U3.js} +51 -42
  486. package/dist/node-runtime/{gemini-search-35OCRFLN.js → gemini-search-C66QHDT6.js} +2 -2
  487. package/dist/node-runtime/{gemini-url-context-UQY3PHHW.js → gemini-url-context-T7DEK73R.js} +3 -3
  488. package/dist/node-runtime/{github-extract-F64RZOEA.js → github-extract-HOGE3D6F.js} +107 -38
  489. package/dist/node-runtime/{goal-NJEE5CTU.js → goal-AIHEDUYA.js} +5 -5
  490. package/dist/node-runtime/index.js +50 -48
  491. package/dist/node-runtime/{init-P5AUV77I.js → init-JBQJIPYI.js} +3 -6
  492. package/dist/node-runtime/{install-cli-NN4YAU44.js → install-cli-INGHIVBY.js} +30 -25
  493. package/dist/node-runtime/interactive-mode-FM5DNUSW.js +74 -0
  494. package/dist/node-runtime/{interactive-view-NGFAMHPW.js → interactive-view-K33PM4OS.js} +8 -8
  495. package/dist/node-runtime/{lsp-manager-3ASUSO4T.js → lsp-manager-S554V5HR.js} +240 -155
  496. package/dist/node-runtime/{lunr-browser-IR7TL3J7.js → lunr-browser-H4FDOR3C.js} +7 -7
  497. package/dist/node-runtime/{lunr-computer-use-Y23CCDIJ.js → lunr-computer-use-VDP2QNRQ.js} +9 -9
  498. package/dist/node-runtime/{lunr-cron-USHC4LXH.js → lunr-cron-LKVA5CZZ.js} +93 -80
  499. package/dist/node-runtime/main.js +42 -41
  500. package/dist/node-runtime/{mobile-commands-O5LCHL32.js → mobile-commands-XT3NQXLD.js} +12 -12
  501. package/dist/node-runtime/{model-runtime-OO5HFLWE.js → model-runtime-MZ2JMDV4.js} +4 -4
  502. package/dist/node-runtime/{openai-search-B3MSNCQA.js → openai-search-K72LJDYN.js} +1 -1
  503. package/dist/node-runtime/{package-manager-cli-Q7BL6KZO.js → package-manager-cli-CYM262SI.js} +20 -20
  504. package/dist/node-runtime/{parallel-AI2MNSCU.js → parallel-X724NCNU.js} +1 -1
  505. package/dist/node-runtime/{perplexity-QVJW3I35.js → perplexity-RDHQHVMK.js} +2 -2
  506. package/dist/node-runtime/{pi-intercom-QM53RLTS.js → pi-intercom-NHHEPBMI.js} +2 -2
  507. package/dist/node-runtime/{pi-mcp-adapter-3PHF4KZ4.js → pi-mcp-adapter-PP3GQJQ2.js} +98 -94
  508. package/dist/node-runtime/{pi-ollama-cloud-2F3Y2QNM.js → pi-ollama-cloud-4MNWIMFN.js} +11 -24
  509. package/dist/node-runtime/{pi-prompt-template-model-QWTCGLJU.js → pi-prompt-template-model-FTGELLS5.js} +32 -36
  510. package/dist/node-runtime/{pi-subagents-7IBSSGEW.js → pi-subagents-LT3CTO4E.js} +98 -106
  511. package/dist/node-runtime/{pi-web-access-WTGMNZ32.js → pi-web-access-Z3LP246C.js} +144 -108
  512. package/dist/node-runtime/{print-mode-XQ76CYMT.js → print-mode-2XHN5SUA.js} +3 -3
  513. package/dist/node-runtime/{process-registry-4FAKZQOL.js → process-registry-Q4QWIU33.js} +3 -3
  514. package/dist/node-runtime/{proxy-modes-5FAPSZEZ.js → proxy-modes-VEGC6QG5.js} +8 -15
  515. package/dist/node-runtime/rpc-entry.js +42 -41
  516. package/dist/node-runtime/{rpc-mode-O3XV4SID.js → rpc-mode-32DHJPEJ.js} +4 -4
  517. package/dist/node-runtime/{runtime-4VA6JKNF.js → runtime-EDUUGAQD.js} +56 -46
  518. package/dist/node-runtime/{runtime-EFPPD2UW.js → runtime-UGXM4NPQ.js} +2 -2
  519. package/dist/node-runtime/{runtime-bridges-7WVCLI76.js → runtime-bridges-DNKMNJCF.js} +7 -7
  520. package/dist/node-runtime/{service-MDQIPQ26.js → service-IHLGFLBT.js} +6 -4
  521. package/dist/node-runtime/{session-handoff-GWARVEWT.js → session-handoff-LNSPDTKY.js} +4 -4
  522. package/dist/node-runtime/{session-manager-JB5J6XBN.js → session-manager-YIFIAVGC.js} +3 -3
  523. package/dist/node-runtime/{session-selector-GIM4DHQ2.js → session-selector-I73U3EIO.js} +7 -7
  524. package/dist/node-runtime/{settings-manager-DJDM5AHM.js → settings-manager-P2TKGYTR.js} +5 -5
  525. package/dist/node-runtime/{setup-JBKOLJ6F.js → setup-H7CCELIL.js} +15 -1
  526. package/dist/node-runtime/{setup-PFBWRNUI.js → setup-OLQ4GXWS.js} +17 -17
  527. package/dist/node-runtime/{src-IVPNZ2BX.js → src-6RV4PXKJ.js} +64 -36
  528. package/dist/node-runtime/{subagent-executor-LPZ4BHWE.js → subagent-executor-Q5F7DBVM.js} +119 -58
  529. package/dist/node-runtime/{tavily-WEZFVFP7.js → tavily-KZBFYQB6.js} +1 -1
  530. package/dist/node-runtime/{theme-UOO5RVFN.js → theme-YLVZKKZD.js} +2 -2
  531. package/dist/node-runtime/{trust-manager-MMISNCYO.js → trust-manager-ZCU76D23.js} +2 -2
  532. package/dist/node-runtime/{update-cli-HNMOTNGX.js → update-cli-F3XXJANQ.js} +6 -6
  533. package/dist/node-runtime/{usage-service-LFB2SWYV.js → usage-service-CPAGBED5.js} +1 -1
  534. package/dist/node-runtime/{video-extract-OOZHR7SU.js → video-extract-UPKYIBW3.js} +3 -3
  535. package/dist/node-runtime/{workflow-OHPBEFO4.js → workflow-ICDI4N3J.js} +208 -78
  536. package/dist/node-runtime/{youtube-extract-FNPAUNHU.js → youtube-extract-77NT7FWH.js} +4 -4
  537. package/dist/utils/clipboard-image.d.ts.map +1 -1
  538. package/dist/utils/clipboard-image.js.map +1 -1
  539. package/dist/utils/exif-orientation.d.ts.map +1 -1
  540. package/dist/utils/exif-orientation.js +25 -10
  541. package/dist/utils/exif-orientation.js.map +1 -1
  542. package/dist/utils/image-resize-core.d.ts.map +1 -1
  543. package/dist/utils/image-resize-core.js +2 -0
  544. package/dist/utils/image-resize-core.js.map +1 -1
  545. package/dist/utils/paths.d.ts +4 -0
  546. package/dist/utils/paths.d.ts.map +1 -1
  547. package/dist/utils/paths.js +33 -2
  548. package/dist/utils/paths.js.map +1 -1
  549. package/dist/utils/sanitize-terminal-text.d.ts +7 -0
  550. package/dist/utils/sanitize-terminal-text.d.ts.map +1 -0
  551. package/dist/utils/sanitize-terminal-text.js +67 -0
  552. package/dist/utils/sanitize-terminal-text.js.map +1 -0
  553. package/docs/browser.md +1 -1
  554. package/docs/custom-provider.md +3 -3
  555. package/docs/extensions.md +8 -4
  556. package/docs/features.md +15 -7
  557. package/docs/keybindings.md +1 -1
  558. package/docs/models.md +5 -5
  559. package/docs/packages.md +1 -1
  560. package/docs/providers.md +2 -2
  561. package/docs/rpc.md +7 -7
  562. package/docs/security.md +10 -5
  563. package/docs/sessions.md +2 -2
  564. package/docs/skills.md +1 -1
  565. package/docs/terminal-setup.md +7 -7
  566. package/docs/themes.md +1 -1
  567. package/docs/usage.md +1 -1
  568. package/examples/extensions/auto-commit-on-exit.ts +1 -1
  569. package/examples/extensions/bash-spawn-hook.ts +1 -1
  570. package/examples/extensions/built-in-tool-renderer.ts +1 -1
  571. package/examples/extensions/claude-rules.ts +1 -1
  572. package/examples/extensions/commands.ts +1 -1
  573. package/examples/extensions/custom-compaction.ts +1 -1
  574. package/examples/extensions/custom-provider-anthropic/index.ts +3 -3
  575. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  576. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  577. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  578. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  579. package/examples/extensions/doom-overlay/index.ts +1 -1
  580. package/examples/extensions/git-merge-and-resolve.ts +2 -2
  581. package/examples/extensions/gondolin/index.ts +1 -1
  582. package/examples/extensions/gondolin/package-lock.json +2 -2
  583. package/examples/extensions/gondolin/package.json +1 -1
  584. package/examples/extensions/hidden-thinking-label.ts +1 -1
  585. package/examples/extensions/inline-bash.ts +2 -2
  586. package/examples/extensions/input-transform-streaming.ts +2 -2
  587. package/examples/extensions/input-transform.ts +2 -2
  588. package/examples/extensions/interactive-shell.ts +1 -1
  589. package/examples/extensions/kimi-deferred-tools.ts +1 -1
  590. package/examples/extensions/mac-system-theme.ts +1 -1
  591. package/examples/extensions/minimal-mode.ts +1 -1
  592. package/examples/extensions/modal-editor.ts +1 -1
  593. package/examples/extensions/model-status.ts +1 -1
  594. package/examples/extensions/notify.ts +3 -3
  595. package/examples/extensions/overlay-qa-tests.ts +1 -1
  596. package/examples/extensions/overlay-test.ts +1 -1
  597. package/examples/extensions/pirate.ts +1 -1
  598. package/examples/extensions/preset.ts +3 -3
  599. package/examples/extensions/project-trust.ts +4 -4
  600. package/examples/extensions/prompt-customizer.ts +1 -1
  601. package/examples/extensions/rainbow-editor.ts +1 -1
  602. package/examples/extensions/rpc-demo.ts +1 -1
  603. package/examples/extensions/sandbox/index.ts +7 -7
  604. package/examples/extensions/sandbox/package-lock.json +2 -2
  605. package/examples/extensions/sandbox/package.json +1 -1
  606. package/examples/extensions/shutdown-command.ts +5 -5
  607. package/examples/extensions/ssh.ts +2 -2
  608. package/examples/extensions/subagent/README.md +3 -3
  609. package/examples/extensions/subagent/index.ts +2 -2
  610. package/examples/extensions/titlebar-spinner.ts +1 -1
  611. package/examples/extensions/tool-override.ts +1 -1
  612. package/examples/extensions/tools.ts +1 -1
  613. package/examples/extensions/with-deps/package-lock.json +2 -2
  614. package/examples/extensions/with-deps/package.json +1 -1
  615. package/examples/extensions/working-indicator.ts +1 -1
  616. package/examples/extensions/working-message-test.ts +1 -1
  617. package/examples/sdk/01-minimal.ts +1 -1
  618. package/examples/sdk/03-custom-prompt.ts +1 -1
  619. package/examples/sdk/04-skills.ts +1 -1
  620. package/examples/sdk/06-extensions.ts +2 -2
  621. package/examples/sdk/08-prompt-templates.ts +1 -1
  622. package/install-lock/package-lock.json +24 -24
  623. package/install-lock/package.json +2 -2
  624. package/npm-shrinkwrap.json +60 -24
  625. package/package.json +9 -9
  626. package/dist/modes/interactive/components/exit-card.d.ts +0 -22
  627. package/dist/modes/interactive/components/exit-card.d.ts.map +0 -1
  628. package/dist/modes/interactive/components/exit-card.js +0 -69
  629. package/dist/modes/interactive/components/exit-card.js.map +0 -1
  630. package/dist/node-runtime/agent-session-services-5YXS2PLF.js +0 -51
  631. package/dist/node-runtime/chunk-2IDTZAG5.js +0 -1415
  632. package/dist/node-runtime/chunk-3MISGG4S.js +0 -769
  633. package/dist/node-runtime/chunk-4HXHDDCF.js +0 -16
  634. package/dist/node-runtime/chunk-5B5QN3ZQ.js +0 -356
  635. package/dist/node-runtime/chunk-7IQGBKBJ.js +0 -2033
  636. package/dist/node-runtime/chunk-AUXVGBO4.js +0 -19
  637. package/dist/node-runtime/chunk-PTFBPO3C.js +0 -50
  638. package/dist/node-runtime/interactive-mode-YOHZVMKX.js +0 -74
  639. package/dist/node-runtime/mcp-auth-flow-QVLFVLEO.js +0 -33
@@ -4,34 +4,37 @@ import {
4
4
  createSyntheticSourceInfo,
5
5
  expandPromptTemplate,
6
6
  formatSkillsForPrompt
7
- } from "./chunk-SN2KSMPQ.js";
7
+ } from "./chunk-DQSCFU7R.js";
8
8
  import {
9
9
  TODO_TOOL_NAMES
10
10
  } from "./chunk-CCCN2UCX.js";
11
11
  import {
12
12
  stripFrontmatter
13
- } from "./chunk-QFWG2RVL.js";
13
+ } from "./chunk-IXG6F4NT.js";
14
14
  import {
15
+ SUBAGENT_CHILD_PERMISSION_ENV,
15
16
  createAllToolDefinitions,
16
17
  createLocalBashOperations,
17
18
  createToolDefinitionFromAgentTool,
19
+ isSubagentChildProcess,
20
+ resolveChildRuntimePermissionMode,
18
21
  wrapToolDefinition
19
- } from "./chunk-YWOJIGFY.js";
22
+ } from "./chunk-ZEVFBFNF.js";
23
+ import {
24
+ stripAnsi
25
+ } from "./chunk-6ZZHGUSA.js";
20
26
  import {
21
27
  DEFAULT_MAX_BYTES,
22
28
  truncateTail
23
29
  } from "./chunk-53YJI7JU.js";
24
- import {
25
- stripAnsi
26
- } from "./chunk-5ZQXRPMC.js";
27
30
  import {
28
31
  ModelRuntime,
29
32
  isAuthInvalidError,
30
33
  isUsageLimitError
31
- } from "./chunk-KJ6DWS3K.js";
34
+ } from "./chunk-XEOCUEUJ.js";
32
35
  import {
33
36
  SettingsManager
34
- } from "./chunk-I74LN5JG.js";
37
+ } from "./chunk-HUD2RFJW.js";
35
38
  import {
36
39
  DEFAULT_THINKING_LEVEL,
37
40
  calculateContextTokens,
@@ -43,46 +46,56 @@ import {
43
46
  generateBranchSummary,
44
47
  prepareCompaction,
45
48
  shouldCompact
46
- } from "./chunk-GYIXXQAO.js";
49
+ } from "./chunk-FIRA54AC.js";
47
50
  import {
48
51
  ExtensionRunner,
49
52
  emitSessionShutdownEvent
50
- } from "./chunk-GJ2RDBRL.js";
53
+ } from "./chunk-BYC6RKCN.js";
51
54
  import {
52
55
  getSubagentCancellation
53
56
  } from "./chunk-BBUVIEZB.js";
54
57
  import {
55
- gateToolCall
56
- } from "./chunk-WIF24I7G.js";
58
+ AUTO_MODE_ADDENDUM,
59
+ READ_ONLY_MODE_ADDENDUM,
60
+ deletePermissionContext,
61
+ gateToolCall,
62
+ getPermissionMode,
63
+ initializePermissionContext,
64
+ setPermissionMode
65
+ } from "./chunk-APVM5NEU.js";
57
66
  import {
58
67
  isUserInstructionsPath,
59
68
  loadSelectedUserInstructions
60
- } from "./chunk-M3LZLQW2.js";
69
+ } from "./chunk-BDRGN3L2.js";
61
70
  import {
62
71
  list
63
- } from "./chunk-KKUTQQV7.js";
72
+ } from "./chunk-RYRGL7P4.js";
64
73
  import {
65
74
  sanitizeBinaryOutput
66
- } from "./chunk-CSFI6YXL.js";
75
+ } from "./chunk-ES6PBSIE.js";
67
76
  import {
68
77
  SessionTransferError
69
- } from "./chunk-I54LGHWM.js";
78
+ } from "./chunk-I2H5QMWW.js";
70
79
  import {
71
80
  CURRENT_SESSION_VERSION,
72
81
  SessionManager,
73
82
  getDefaultSessionDir,
74
83
  getLatestCompactionEntry
75
- } from "./chunk-2KIPT4HJ.js";
84
+ } from "./chunk-EPR2F3GU.js";
76
85
  import {
77
86
  convertToLlm
78
87
  } from "./chunk-FVDOXRUD.js";
79
88
  import {
80
89
  MEMORY_TOOL_NAMES
81
90
  } from "./chunk-UJOCPOMX.js";
91
+ import {
92
+ getUsageServiceBridge
93
+ } from "./chunk-HNNHHJAB.js";
82
94
  import {
83
95
  SessionOwnership,
84
- canonicalSessionPath
85
- } from "./chunk-UAEOTO52.js";
96
+ canonicalSessionPath,
97
+ writeSessionJson
98
+ } from "./chunk-MNQXDFPV.js";
86
99
  import {
87
100
  measureStartup,
88
101
  time
@@ -90,7 +103,7 @@ import {
90
103
  import {
91
104
  getThemeByName,
92
105
  theme
93
- } from "./chunk-RDDAZOMU.js";
106
+ } from "./chunk-JL4HYQXK.js";
94
107
  import {
95
108
  CONFIG_DIR_NAME,
96
109
  getAgentDir,
@@ -98,7 +111,7 @@ import {
98
111
  getExamplesPath,
99
112
  getReadmePath,
100
113
  resolvePath
101
- } from "./chunk-FQMM2EZ2.js";
114
+ } from "./chunk-64XTQNLA.js";
102
115
 
103
116
  // packages/coding-agent/dist/core/agent-session-services.js
104
117
  import { join as join7 } from "node:path";
@@ -232,6 +245,10 @@ var ModelRegistry = class {
232
245
  constructor(runtime) {
233
246
  this.runtime = runtime;
234
247
  }
248
+ /** Owner-bound usage bridge for deferred footer rendering. */
249
+ getUsageServiceBridge() {
250
+ return getUsageServiceBridge(this.runtime);
251
+ }
235
252
  /** Reload models.json asynchronously. Await before making synchronous registry reads. */
236
253
  refresh() {
237
254
  return this.runtime.reloadConfig();
@@ -343,15 +360,20 @@ function disableRollbackForSession(sessionId) {
343
360
  }
344
361
  function pruneTurns(ctx) {
345
362
  let maxTurns = ctx.settingsManager?.getRollbackTurns() ?? 2;
346
- for (; ctx.turns.length > maxTurns; ) {
347
- let old = ctx.turns.shift();
348
- old && cleanupTurnFiles(ctx, old);
363
+ for (; ctx.turns.filter((turn) => !turn.recovery).length > maxTurns; ) {
364
+ let index = ctx.turns.findIndex((turn) => !turn.recovery);
365
+ if (index < 0)
366
+ break;
367
+ let [old] = ctx.turns.splice(index, 1);
368
+ cleanupTurnFiles(ctx, old);
349
369
  }
350
370
  }
351
371
  function beginTurn(cwd, sessionId) {
352
372
  let ctx = getContext(sessionId);
353
373
  if (!isRollbackEnabled(ctx.sessionId))
354
374
  return;
375
+ for (let pending of ctx.turns.filter((turn2) => turn2.recovery))
376
+ pending.recovery.newerTurnStarted = !0, persistRecoveryProgress(ctx, pending);
355
377
  cwd && (ctx.lastCwd = cwd), ctx.currentTurnIndex++;
356
378
  let turn = { turnIndex: ctx.currentTurnIndex, cwd, files: /* @__PURE__ */ new Map() };
357
379
  ctx.turns.push(turn), pruneTurns(ctx), cwd && ctx.settingsManager?.getRollbackScope() === "tree" && captureTreeBaseline(ctx, cwd);
@@ -496,6 +518,7 @@ function readManifest(path) {
496
518
  let files = parsed.files;
497
519
  return {
498
520
  cwd: typeof parsed.cwd == "string" ? parsed.cwd : void 0,
521
+ recovery: parseRecoveryProgress(parsed.recovery),
499
522
  files: files && typeof files == "object" && !Array.isArray(files) ? files : {}
500
523
  };
501
524
  }
@@ -504,6 +527,31 @@ function readManifest(path) {
504
527
  return { files: {} };
505
528
  }
506
529
  }
530
+ function parseRecoveryProgress(value) {
531
+ if (!value || typeof value != "object")
532
+ return;
533
+ let progress = value;
534
+ if (!(typeof progress.turnsToConsume != "number" || !Number.isInteger(progress.turnsToConsume) || progress.turnsToConsume < 1 || !Array.isArray(progress.completed) || !progress.completed.every((path) => typeof path == "string")))
535
+ return {
536
+ targetUserId: typeof progress.targetUserId == "string" ? progress.targetUserId : void 0,
537
+ turnsToConsume: progress.turnsToConsume,
538
+ completed: progress.completed,
539
+ pending: typeof progress.pending == "string" ? progress.pending : void 0,
540
+ newerTurnStarted: progress.newerTurnStarted === !0
541
+ };
542
+ }
543
+ function persistRecoveryProgress(ctx, turn) {
544
+ let turnDir = getTurnDir(ctx, turn.turnIndex);
545
+ mkdirSync(turnDir, { recursive: !0 });
546
+ let manifest = { cwd: turn.cwd, recovery: turn.recovery, files: {} };
547
+ for (let [path, snap] of turn.files)
548
+ manifest.files[path] = {
549
+ existed: snap.existed,
550
+ createdByTool: snap.createdByTool,
551
+ snapFile: snap.existed ? snapFileName(path) : void 0
552
+ };
553
+ writeSessionJson(join3(turnDir, "manifest.json"), manifest);
554
+ }
507
555
  function loadPersistedTurns(ctx) {
508
556
  try {
509
557
  let sessionDir = join3(ROLLBACK_BASE, ctx.sessionId);
@@ -525,7 +573,7 @@ function loadPersistedTurns(ctx) {
525
573
  }
526
574
  files.set(absPath, { existed: meta.existed, content, createdByTool: meta.createdByTool });
527
575
  }
528
- loaded.push({ turnIndex, cwd: manifest.cwd, files });
576
+ loaded.push({ turnIndex, cwd: manifest.cwd, files, recovery: manifest.recovery });
529
577
  }
530
578
  loaded.sort((a, b) => a.turnIndex - b.turnIndex), ctx.turns = loaded, ctx.currentTurnIndex = loaded.length > 0 ? loaded[loaded.length - 1].turnIndex : -1, pruneTurns(ctx);
531
579
  } catch {
@@ -564,42 +612,99 @@ function warnExternalModification(ctx, message) {
564
612
  }
565
613
  }
566
614
  }
615
+ function recoveryTurn(ctx) {
616
+ return ctx.turns.find((turn) => turn.recovery) ?? [...ctx.turns].reverse().find((turn) => turn.files.size > 0);
617
+ }
618
+ function getRollbackTargetUserId(sessionId) {
619
+ return recoveryTurn(getContext(sessionId))?.recovery?.targetUserId;
620
+ }
621
+ function getRollbackRecoveryBlockReason(sessionId) {
622
+ let ctx = getContext(sessionId), pending = ctx.turns.find((turn) => turn.recovery);
623
+ if (pending?.recovery && (pending.recovery.newerTurnStarted || ctx.turns.some((turn) => turn.turnIndex > pending.turnIndex + pending.recovery.turnsToConsume - 1)))
624
+ return "Automatic rollback retry is unavailable after newer turns. Chat and files are unchanged. Use /new to continue in a separate chat; this does not repair the retained recovery. Snapshots remain available for manual recovery.";
625
+ }
567
626
  function peekRollbackTurnsConsumed(sessionId) {
568
627
  let ctx = getContext(sessionId);
569
- if (!isRollbackEnabled(ctx.sessionId) || ctx.turns.length === 0)
628
+ if (!isRollbackEnabled(ctx.sessionId))
570
629
  return 0;
571
- let consumed = 0;
572
- for (let i = ctx.turns.length - 1; i >= 0 && (consumed++, !(ctx.turns[i].files.size > 0)); i--)
573
- ;
574
- return consumed;
630
+ let turn = recoveryTurn(ctx);
631
+ return turn?.recovery?.turnsToConsume ?? (turn ? ctx.turns.length - ctx.turns.indexOf(turn) : ctx.turns.length);
632
+ }
633
+ function commitRollbackTurn(sessionId, turnIndex) {
634
+ let ctx = getContext(sessionId), blocked = getRollbackRecoveryBlockReason(sessionId);
635
+ if (blocked)
636
+ throw new Error(blocked);
637
+ let index = ctx.turns.findIndex((turn2) => turn2.turnIndex === turnIndex);
638
+ if (index < 0)
639
+ return;
640
+ let turn = ctx.turns[index];
641
+ if (!turn.recovery || [...turn.files.keys()].some((path) => !turn.recovery?.completed.includes(path)))
642
+ throw new Error("Rollback still has unrestored files.");
643
+ let count = 1;
644
+ for (; index + count < ctx.turns.length && ctx.turns[index + count].files.size === 0; )
645
+ count++;
646
+ for (let removed of ctx.turns.splice(index, count))
647
+ cleanupTurnFiles(ctx, removed);
575
648
  }
576
- function rollbackLastTurn(sessionId) {
577
- let ctx = getContext(sessionId), empty = { restored: [], deleted: [], turnsConsumed: 0 };
649
+ function rollbackLastTurn(sessionId, options = {}) {
650
+ let ctx = getContext(sessionId), result = { restored: [], deleted: [], failed: [], complete: !0, turnsConsumed: 0 };
578
651
  if (!isRollbackEnabled(ctx.sessionId))
579
- return empty;
580
- let turnsConsumed = 0;
581
- for (; ctx.turns.length > 0 && ctx.turns[ctx.turns.length - 1].files.size === 0; ) {
582
- let skipped = ctx.turns.pop();
583
- skipped && (cleanupTurnFiles(ctx, skipped), turnsConsumed++);
584
- }
585
- if (ctx.turns.length === 0)
586
- return empty;
587
- turnsConsumed++;
588
- let turn = ctx.turns[ctx.turns.length - 1], capture = ctx.settingsManager?.getRollbackCapture() ?? "copies", restored = [], deleted = [];
589
- for (let [absPath, snap] of turn.files)
652
+ return result;
653
+ let blocked = getRollbackRecoveryBlockReason(ctx.sessionId);
654
+ if (blocked)
655
+ throw new Error(blocked);
656
+ let turn = recoveryTurn(ctx) ?? (options.deferCommit ? ctx.turns[0] : void 0);
657
+ if (!turn) {
658
+ for (let empty of ctx.turns.splice(0))
659
+ cleanupTurnFiles(ctx, empty);
660
+ return result;
661
+ }
662
+ result.turnIndex = turn.turnIndex, turn.recovery ??= {
663
+ turnsToConsume: peekRollbackTurnsConsumed(ctx.sessionId),
664
+ completed: [],
665
+ targetUserId: options.targetUserId
666
+ }, turn.recovery.targetUserId ??= options.targetUserId, persistRecoveryProgress(ctx, turn);
667
+ let capture = ctx.settingsManager?.getRollbackCapture() ?? "copies";
668
+ for (let [absPath, snap] of turn.files) {
669
+ if (turn.recovery.completed.includes(absPath))
670
+ continue;
671
+ let wasPending = turn.recovery.pending === absPath;
590
672
  try {
591
- if (!isWithinAllowedRoots(absPath, turn)) {
592
- warnExternalModification(ctx, `Rollback skipped ${absPath}: outside the session working directory or lunR config dir.`);
673
+ if (turn.recovery.pending === absPath) {
674
+ if (!(snap.existed ? snap.content && existsSync(absPath) && readFileSync(absPath).equals(snap.content) : !existsSync(absPath))) {
675
+ result.failed.push({
676
+ path: absPath,
677
+ error: "Previous recovery outcome is uncertain. Restore this path from its retained snapshot before retrying."
678
+ });
679
+ continue;
680
+ }
681
+ turn.recovery.completed.push(absPath), turn.recovery.pending = void 0, persistRecoveryProgress(ctx, turn);
593
682
  continue;
594
683
  }
595
- if (snap.existed && snap.content) {
596
- if (!snap.createdByTool && existsSync(absPath) && readFileSync(absPath).equals(snap.content))
597
- continue;
598
- mkdirSync(dirname(absPath), { recursive: !0 }), writeFileSync(absPath, snap.content), restored.push(absPath);
599
- } else snap.existed || (snap.createdByTool || capture === "hybrid" || capture === "shadow-git") && existsSync(absPath) && (unlinkSync(absPath), deleted.push(absPath));
600
- } catch {
684
+ if (!isWithinAllowedRoots(absPath, turn))
685
+ throw warnExternalModification(ctx, `Rollback skipped ${absPath}: outside the session working directory or lunR config dir.`), new Error("Outside the allowed rollback roots.");
686
+ if (turn.recovery.pending) {
687
+ result.failed.push({
688
+ path: absPath,
689
+ error: "Resolve the uncertain recovery path before continuing this turn."
690
+ });
691
+ continue;
692
+ }
693
+ if (snap.existed && !snap.content)
694
+ throw new Error("Snapshot content is unavailable.");
695
+ turn.recovery.pending = absPath, persistRecoveryProgress(ctx, turn), snap.existed && snap.content ? !snap.createdByTool && existsSync(absPath) && readFileSync(absPath).equals(snap.content) || (mkdirSync(dirname(absPath), { recursive: !0 }), writeFileSync(absPath, snap.content), result.restored.push(absPath)) : (snap.createdByTool || capture === "hybrid" || capture === "shadow-git") && existsSync(absPath) && (unlinkSync(absPath), result.deleted.push(absPath)), turn.recovery.completed.push(absPath), turn.recovery.pending = void 0, persistRecoveryProgress(ctx, turn);
696
+ } catch (error) {
697
+ if (!wasPending && turn.recovery.pending === absPath) {
698
+ turn.recovery.pending = void 0;
699
+ try {
700
+ persistRecoveryProgress(ctx, turn);
701
+ } catch {
702
+ }
703
+ }
704
+ result.failed.push({ path: absPath, error: error instanceof Error ? error.message : String(error) });
601
705
  }
602
- return cleanupTurnFiles(ctx, turn), ctx.turns.pop(), { restored, deleted, turnsConsumed };
706
+ }
707
+ return result.complete = result.failed.length === 0, result.complete && !options.deferCommit && (result.turnsConsumed = turn.recovery.turnsToConsume, commitRollbackTurn(ctx.sessionId, turn.turnIndex)), result;
603
708
  }
604
709
  function migrateRollbackSession(oldSessionId, newSessionId) {
605
710
  if (oldSessionId === newSessionId)
@@ -805,7 +910,12 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
805
910
  _retryAbortController = void 0;
806
911
  _retryAttempt = 0;
807
912
  // Bash execution state
808
- _bashAbortController = void 0;
913
+ _bashOperations = /* @__PURE__ */ new Map();
914
+ _operations = /* @__PURE__ */ new Set();
915
+ _closing = !1;
916
+ _disposed = !1;
917
+ _drainPromise;
918
+ _shutdownPromise;
809
919
  _pendingBashMessages = [];
810
920
  // Extension system
811
921
  _extensionRunner;
@@ -838,12 +948,14 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
838
948
  _baseSystemPrompt = "";
839
949
  _baseSystemPromptOptions;
840
950
  _systemPromptOverride;
841
- // lunr: core-owned system-prompt append (read-only mode addendum) applied on top of base/override
951
+ // Optional host-owned prompt append, separate from session permission guidance.
842
952
  _systemPromptAppend;
843
953
  // lunr: core-owned tool-call gates (read-only mode) checked before extension tool_call handlers
844
954
  _toolCallGates = [];
845
955
  constructor(config) {
846
- this.agent = config.agent, this.sessionManager = config.sessionManager, this.settingsManager = config.settingsManager, this._scopedModels = config.scopedModels ?? [], this._resourceLoader = config.resourceLoader, this._customTools = config.customTools ?? [], this._cwd = config.cwd, this._agentDir = config.agentDir ?? getAgentDir(), this._modelRuntime = config.modelRuntime, this._syncOpenAIServiceTier(), this._extensionRunnerRef = config.extensionRunnerRef, this._initialActiveToolNames = config.initialActiveToolNames, this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : void 0, this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : void 0, this._baseToolsOverride = config.baseToolsOverride, this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
956
+ this.agent = config.agent, this.sessionManager = config.sessionManager, this.settingsManager = config.settingsManager;
957
+ let permissionMode = config.permissionMode ?? (isSubagentChildProcess() ? resolveChildRuntimePermissionMode(process.env[SUBAGENT_CHILD_PERMISSION_ENV]) : void 0) ?? this.sessionManager.getPermissionMode() ?? this.settingsManager.getDefaultPermissionMode();
958
+ initializePermissionContext(this.sessionId, permissionMode, config.permissionMode), this._scopedModels = config.scopedModels ?? [], this._resourceLoader = config.resourceLoader, this._customTools = config.customTools ?? [], this._cwd = config.cwd, this._agentDir = config.agentDir ?? getAgentDir(), this._modelRuntime = config.modelRuntime, this._syncOpenAIServiceTier(), this._extensionRunnerRef = config.extensionRunnerRef, this._initialActiveToolNames = config.initialActiveToolNames, this._allowedToolNames = config.allowedToolNames ? new Set(config.allowedToolNames) : void 0, this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : void 0, this._baseToolsOverride = config.baseToolsOverride, this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
847
959
  let waitInterruptionOwner = { register: () => this._registerSubagentWaitInterruption() };
848
960
  for (let identity of new Set([this.sessionId, this.sessionFile].filter((value) => !!value)))
849
961
  this._unregisterSubagentWaitInterruptionOwners.push(registerSubagentWaitInterruptionOwner(identity, waitInterruptionOwner));
@@ -1031,7 +1143,7 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
1031
1143
  }
1032
1144
  }
1033
1145
  }
1034
- if (await this._emitExtensionEvent(event), this._emit(event.type === "agent_end" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event), event.type === "message_end" && (event.message.role === "custom" ? this.sessionManager.appendCustomMessageEntry(event.message.customType, event.message.content, event.message.display, event.message.details) : (event.message.role === "user" || event.message.role === "assistant" || event.message.role === "toolResult") && this.sessionManager.appendMessage(event.message), event.message.role === "assistant")) {
1146
+ if (event.type === "message_end" && this._activePromptRun?.completion?.messages.push(event.message), await this._emitExtensionEvent(event), this._emit(event.type === "agent_end" ? { ...event, willRetry: this._willRetryAfterAgentEnd(event) } : event), event.type === "message_end" && (event.message.role === "custom" ? this.sessionManager.appendCustomMessageEntry(event.message.customType, event.message.content, event.message.display, event.message.details) : (event.message.role === "user" || event.message.role === "assistant" || event.message.role === "toolResult") && this.sessionManager.appendMessage(event.message), event.message.role === "assistant")) {
1035
1147
  this._lastAssistantMessage = event.message;
1036
1148
  let assistantMsg = event.message;
1037
1149
  assistantMsg.stopReason !== "error" && (this._overflowRecoveryAttempted = !1), assistantMsg.stopReason !== "error" && this._retryAttempt > 0 && (this._emit({
@@ -1182,18 +1294,53 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
1182
1294
  this.transferring = value, value && this._invalidateWaitPromptHandoffs("Session transfer interrupted the pending prompt.");
1183
1295
  }
1184
1296
  assertCanStartWork() {
1185
- if (this.sessionManager.assertWritable(), this.transferring)
1297
+ if (this.sessionManager.assertWritable(), this._closing)
1298
+ throw new Error("Session is closing. New work is not accepted.");
1299
+ if (this.transferring)
1186
1300
  throw new Error("Session transfer is in progress. Wait or reclaim the session.");
1187
1301
  }
1188
- dispose() {
1189
- this._invalidateWaitPromptHandoffs("Session closed before the pending prompt could run.");
1190
- for (let unregister of this._unregisterSubagentWaitInterruptionOwners.splice(0))
1191
- unregister();
1302
+ /** Stop admission synchronously, retaining listeners and session ownership. */
1303
+ stopAdmission() {
1304
+ this._closing = !0, this._invalidateWaitPromptHandoffs("Session closed before the pending prompt could run.");
1305
+ }
1306
+ async _trackOperation(operation) {
1307
+ let settle = () => {
1308
+ }, completion = new Promise((resolve3) => {
1309
+ settle = resolve3;
1310
+ });
1311
+ this._operations.add(completion);
1192
1312
  try {
1193
- this.abortRetry(), this.abortCompaction(), this.abortBranchSummary(), this.abortBash(), this.agent.abort();
1194
- } catch {
1313
+ return await operation();
1314
+ } finally {
1315
+ this._operations.delete(completion), settle();
1316
+ }
1317
+ }
1318
+ /** Cancel owned work and wait for final persistence before extension shutdown. */
1319
+ drain() {
1320
+ return this._drainPromise ? this._drainPromise : (this.stopAdmission(), this._activePromptRun && (this._activePromptRun.gracefulStopRequested = !0), this.abortRetry(), this.abortCompaction(), this.abortBranchSummary(), this.abortBash(), this.clearQueue(), this.agent.abort(), this._drainPromise = (async () => {
1321
+ await Promise.all([...this._operations]), await this.waitForIdle(), await this.agent.waitForIdle(), this._flushPendingBashMessages();
1322
+ })(), this._drainPromise);
1323
+ }
1324
+ /** Await cancellation and persistence, then release listeners and ownership. */
1325
+ shutdown() {
1326
+ return this._shutdownPromise || (this._shutdownPromise = this.drain().then(() => this._disposeSettled())), this._shutdownPromise;
1327
+ }
1328
+ /** Compatibility wrapper. Use await shutdown() when release must be complete. */
1329
+ dispose() {
1330
+ if (this._operations.size === 0 && !this._isAgentRunActive && !this.agent.state.isStreaming) {
1331
+ this.stopAdmission(), this._disposeSettled();
1332
+ return;
1333
+ }
1334
+ this.shutdown().catch(() => {
1335
+ });
1336
+ }
1337
+ _disposeSettled() {
1338
+ if (!this._disposed) {
1339
+ this._disposed = !0;
1340
+ for (let unregister of this._unregisterSubagentWaitInterruptionOwners.splice(0))
1341
+ unregister();
1342
+ this._extensionRunner.invalidate("This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload()."), this._disconnectFromAgent(), this._eventListeners = [], cleanupSessionResources(this.sessionId), deletePermissionContext(this.sessionId), this.sessionManager.dispose();
1195
1343
  }
1196
- this._extensionRunner.invalidate("This extension ctx is stale after session replacement or reload. Do not use a captured pi or command ctx after ctx.newSession(), ctx.fork(), ctx.switchSession(), or ctx.reload(). For newSession, fork, and switchSession, move post-replacement work into withSession and use the ctx passed to withSession. For reload, do not use the old ctx after await ctx.reload()."), this._disconnectFromAgent(), this._eventListeners = [], cleanupSessionResources(this.sessionId), this.sessionManager.dispose();
1197
1344
  }
1198
1345
  // =========================================================================
1199
1346
  // Read-only State Access
@@ -1245,10 +1392,20 @@ var THINKING_LEVELS = ["off", "minimal", "low", "medium", "high", "xhigh", "max"
1245
1392
  let next = text && text.trim().length > 0 ? text : void 0;
1246
1393
  next !== this._systemPromptAppend && (this._systemPromptAppend = next, this.agent.state.systemPrompt = this._withSystemPromptAppend(this._systemPromptOverride ?? this._baseSystemPrompt));
1247
1394
  }
1395
+ get permissionMode() {
1396
+ return getPermissionMode(this.sessionId);
1397
+ }
1398
+ _permissionAddendum(mode) {
1399
+ return mode === "read-only" ? READ_ONLY_MODE_ADDENDUM : mode === "auto" ? AUTO_MODE_ADDENDUM : void 0;
1400
+ }
1401
+ /** Update the same permission context consulted by headless and interactive tools. */
1402
+ setPermissionMode(mode) {
1403
+ this.assertCanStartWork(), setPermissionMode(mode, this.sessionId), this.sessionManager.setPermissionMode(mode), this.agent.state.systemPrompt = this._withSystemPromptAppend(this._systemPromptOverride ?? this._baseSystemPrompt);
1404
+ }
1248
1405
  _withSystemPromptAppend(prompt) {
1249
- return this._systemPromptAppend ? `${prompt}
1406
+ return [prompt, this._permissionAddendum(this.permissionMode), this._systemPromptAppend].filter(Boolean).join(`
1250
1407
 
1251
- ${this._systemPromptAppend}` : prompt;
1408
+ `);
1252
1409
  }
1253
1410
  /** Current retry attempt (0 if not retrying) */
1254
1411
  get retryAttempt() {
@@ -1410,24 +1567,46 @@ ${this._systemPromptAppend}` : prompt;
1410
1567
  for (let reservation of handoff.reservations.splice(0))
1411
1568
  reservation.reject(error);
1412
1569
  }
1413
- async _runAgentPrompt(messages) {
1570
+ _reservePromptRun() {
1571
+ if (this.assertCanStartWork(), this._isAgentRunActive || this._manualCompactionPromise)
1572
+ throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
1414
1573
  let run = { waits: /* @__PURE__ */ new Set(), gracefulStopRequested: !1 };
1415
- this._activePromptRun = run, this._isAgentRunActive = !0;
1416
- try {
1417
- for (await this.agent.prompt(messages); await this._handlePostAgentRun(run); )
1418
- await this.agent.continue();
1419
- } finally {
1420
- this._activePromptRun === run && (this._activePromptRun = void 0), this._systemPromptOverride = void 0, this._flushPendingBashMessages(), await this._emitAgentSettled();
1421
- }
1574
+ return this._activePromptRun = run, this._isAgentRunActive = !0, run;
1575
+ }
1576
+ async _releasePromptRun(run) {
1577
+ this._activePromptRun === run && (this._activePromptRun = void 0, this._systemPromptOverride = void 0, this._flushPendingBashMessages(), await this._emitAgentSettled());
1578
+ }
1579
+ async _runAgentPrompt(messages, owner) {
1580
+ let run = owner ?? this._reservePromptRun();
1581
+ await this._trackOperation(async () => {
1582
+ try {
1583
+ if (this.assertCanStartWork(), run.gracefulStopRequested)
1584
+ throw new Error("Prompt was cancelled during preparation.");
1585
+ for (await this.agent.prompt(Array.isArray(messages) ? messages : [messages], {
1586
+ consumeFollowUps: !run.completion
1587
+ }); await this._handlePostAgentRun(run) && !(run.gracefulStopRequested || this._closing || run.completion?.cancelled); )
1588
+ await this.agent.continue({ consumeFollowUps: !run.completion });
1589
+ if (run.completion) {
1590
+ let completion = run.completion;
1591
+ run.completion = void 0, completion.detach?.();
1592
+ let hasQueuedWork = !run.gracefulStopRequested && !this._closing && this.agent.hasQueuedMessages();
1593
+ if (hasQueuedWork || await this._releasePromptRun(run), completion.settle(), hasQueuedWork)
1594
+ for (await this.agent.continueQueued(); await this._handlePostAgentRun(run) && !(run.gracefulStopRequested || this._closing); )
1595
+ await this.agent.continue();
1596
+ }
1597
+ } finally {
1598
+ await this._releasePromptRun(run);
1599
+ }
1600
+ });
1422
1601
  }
1423
1602
  async _handlePostAgentRun(run) {
1424
1603
  let msg = this._lastAssistantMessage;
1425
- return this._lastAssistantMessage = void 0, !msg || run.gracefulStopRequested ? !1 : msg.stopReason === "error" && this._isRotationError(msg) && await this._tryRotateSubscriptionKey(msg) || this._isRetryableError(msg) && await this._prepareRetry(msg) || msg.stopReason === "error" && this._isRetryableError(msg) && await this._tryRotateSubscriptionKey(msg) || (msg.stopReason === "error" && this._retryAttempt > 0 && (this._emit({
1604
+ return this._lastAssistantMessage = void 0, !msg || run.gracefulStopRequested || run.completion?.signal?.aborted ? !1 : msg.stopReason === "error" && this._isRotationError(msg) && await this._tryRotateSubscriptionKey(msg) || this._isRetryableError(msg) && await this._prepareRetry(msg) || msg.stopReason === "error" && this._isRetryableError(msg) && await this._tryRotateSubscriptionKey(msg) || (msg.stopReason === "error" && this._retryAttempt > 0 && (this._emit({
1426
1605
  type: "auto_retry_end",
1427
1606
  success: !1,
1428
1607
  attempt: this._retryAttempt,
1429
1608
  finalError: msg.errorMessage
1430
- }), this._retryAttempt = 0), await this._checkCompaction(msg)) ? !0 : this.agent.hasQueuedMessages();
1609
+ }), this._retryAttempt = 0), await this._checkCompaction(msg)) ? !0 : !run.completion && this.agent.hasQueuedMessages();
1431
1610
  }
1432
1611
  /**
1433
1612
  * Send a prompt to the agent.
@@ -1440,23 +1619,72 @@ ${this._systemPromptAppend}` : prompt;
1440
1619
  */
1441
1620
  async prompt(text, options) {
1442
1621
  this.assertCanStartWork();
1443
- let preflightResult = options?.preflightResult, prepared, messages;
1444
- try {
1445
- if (prepared = await this._preparePromptInput(text, options, this.isStreaming ? options?.streamingBehavior : void 0), !prepared) {
1446
- preflightResult?.(!0);
1447
- return;
1622
+ let commandName = text.startsWith("/") ? text.slice(1).split(" ")[0] : void 0;
1623
+ if ((options?.expandPromptTemplates ?? !0) && commandName && this._extensionRunner.getCommand(commandName)) {
1624
+ try {
1625
+ await this._tryExecuteExtensionCommand(text), options?.preflightResult?.(!0);
1626
+ } catch (error) {
1627
+ throw options?.preflightResult?.(!1), error;
1448
1628
  }
1449
- if (this.isStreaming) {
1629
+ return;
1630
+ }
1631
+ return this._trackOperation(() => this._prompt(text, options));
1632
+ }
1633
+ async _prompt(text, options, completion) {
1634
+ let run, accepted = !1;
1635
+ try {
1636
+ this.assertCanStartWork();
1637
+ let wasStreaming = this.isStreaming;
1638
+ if (wasStreaming) {
1450
1639
  if (!options?.streamingBehavior)
1451
1640
  throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
1452
- options.streamingBehavior === "followUp" ? await this._queueFollowUp(prepared.text, prepared.images) : await this._queueSteer(prepared.text, prepared.images), preflightResult?.(!0);
1641
+ } else if (run = this._reservePromptRun(), run.completion = completion, completion?.signal) {
1642
+ let owner = run, cancel = () => {
1643
+ this._activePromptRun !== owner || owner.completion !== completion || (completion.cancelled = !0, this.agent.abort(), this.abortRetry(), this._autoCompactionAbortController?.abort());
1644
+ };
1645
+ completion.signal.addEventListener("abort", cancel, { once: !0 }), completion.detach = () => completion.signal?.removeEventListener("abort", cancel), completion.signal.throwIfAborted();
1646
+ }
1647
+ let prepared = await this._preparePromptInput(text, options, wasStreaming ? options?.streamingBehavior : void 0);
1648
+ if (this.assertCanStartWork(), run?.completion?.signal?.throwIfAborted(), run?.gracefulStopRequested)
1649
+ throw new Error("Prompt was cancelled during preparation.");
1650
+ if (!prepared) {
1651
+ accepted = !0, options?.preflightResult?.(!0);
1652
+ return;
1653
+ }
1654
+ if (wasStreaming && this.isStreaming) {
1655
+ options?.streamingBehavior === "followUp" ? await this._queueFollowUp(prepared.text, prepared.images) : await this._queueSteer(prepared.text, prepared.images), accepted = !0, options?.preflightResult?.(!0);
1453
1656
  return;
1454
1657
  }
1455
- messages = await this._createPromptMessages(prepared);
1658
+ run ??= this._reservePromptRun(), run.completion = completion;
1659
+ let messages = await this._createPromptMessages(prepared);
1660
+ if (this.assertCanStartWork(), run.completion?.signal?.throwIfAborted(), run.gracefulStopRequested)
1661
+ throw new Error("Prompt was cancelled during preparation.");
1662
+ accepted = !0, options?.preflightResult?.(!0), await this._runAgentPrompt(messages, run);
1456
1663
  } catch (error) {
1457
- throw preflightResult?.(!1), error;
1664
+ throw accepted || options?.preflightResult?.(!1), error;
1665
+ } finally {
1666
+ completion?.detach?.(), run && await this._releasePromptRun(run);
1458
1667
  }
1459
- preflightResult?.(!0), await this._runAgentPrompt(messages);
1668
+ }
1669
+ /**
1670
+ * Admit one scheduled request, including steering, retries and compaction.
1671
+ * Completes before later follow-ups; signal cancellation belongs only to this request.
1672
+ */
1673
+ async promptWithCompletion(text, options) {
1674
+ if (this.assertCanStartWork(), !this.isIdle || this.isBashRunning || this.isCompacting || this.pendingMessageCount > 0)
1675
+ throw new Error("Session is busy. Retry the scheduled prompt after its work settles.");
1676
+ text.startsWith("/") && (options?.expandPromptTemplates ?? !0) && this._throwIfExtensionCommand(text), options?.signal?.throwIfAborted();
1677
+ let messages = [];
1678
+ return new Promise((resolve3, reject) => {
1679
+ let completion = {
1680
+ messages,
1681
+ signal: options?.signal,
1682
+ settle: () => {
1683
+ completion.cancelled ? reject(completion.signal?.reason) : resolve3({ messages });
1684
+ }
1685
+ };
1686
+ this._trackOperation(() => this._prompt(text, options, completion)).then(completion.settle, reject);
1687
+ });
1460
1688
  }
1461
1689
  async _preparePromptInput(text, options, streamingBehavior) {
1462
1690
  let expandPromptTemplates = options?.expandPromptTemplates ?? !0;
@@ -1503,7 +1731,8 @@ ${this._systemPromptAppend}` : prompt;
1503
1731
  return result?.systemPrompt !== void 0 ? (this._systemPromptOverride = result.systemPrompt, this.agent.state.systemPrompt = this._withSystemPromptAppend(result.systemPrompt)) : (this._systemPromptOverride = void 0, this.agent.state.systemPrompt = this._withSystemPromptAppend(this._baseSystemPrompt)), messages;
1504
1732
  }
1505
1733
  async interruptSubagentWaitWithPrompt(text, options) {
1506
- let acceptance = this._waitPromptAcceptance.then(() => this._reserveWaitPrompt(text, options));
1734
+ this.assertCanStartWork();
1735
+ let previousAcceptance = this._waitPromptAcceptance, acceptance = this._trackOperation(() => previousAcceptance.then(() => this._reserveWaitPrompt(text, options)));
1507
1736
  return this._waitPromptAcceptance = acceptance.then(() => {
1508
1737
  }, () => {
1509
1738
  }), acceptance;
@@ -1528,6 +1757,8 @@ ${this._systemPromptAppend}` : prompt;
1528
1757
  } catch (error) {
1529
1758
  throw handoff.reservations.length === 0 && this._waitPromptHandoff === handoff && (this._waitPromptHandoff = void 0), error;
1530
1759
  }
1760
+ if (this.assertCanStartWork(), handoff.generation !== this._waitPromptGeneration)
1761
+ throw new Error("Pending prompt was cancelled during preparation.");
1531
1762
  if (!prepared)
1532
1763
  return handoff.reservations.length === 0 && this._waitPromptHandoff === handoff && (this._waitPromptHandoff = void 0), { completion: Promise.resolve() };
1533
1764
  let resolveCompletion = () => {
@@ -1539,15 +1770,15 @@ ${this._systemPromptAppend}` : prompt;
1539
1770
  }
1540
1771
  async _drainWaitPromptHandoff(handoff) {
1541
1772
  for (await this.waitForIdle(); this._waitPromptHandoff === handoff && handoff.generation === this._waitPromptGeneration && handoff.reservations.length > 0; ) {
1542
- let reservation = handoff.reservations[0];
1773
+ let reservation = handoff.reservations[0], run;
1543
1774
  try {
1544
- this.assertCanStartWork();
1775
+ this.assertCanStartWork(), run = this._reservePromptRun();
1545
1776
  let messages = await this._createPromptMessages(reservation.input);
1546
- handoff.accepting = !1, await this._runAgentPrompt(messages), reservation.resolve();
1777
+ handoff.accepting = !1, await this._runAgentPrompt(messages, run), reservation.resolve();
1547
1778
  } catch (error) {
1548
1779
  reservation.reject(error);
1549
1780
  } finally {
1550
- handoff.reservations[0] === reservation && handoff.reservations.shift();
1781
+ run && await this._releasePromptRun(run), handoff.reservations[0] === reservation && handoff.reservations.shift();
1551
1782
  }
1552
1783
  }
1553
1784
  handoff.accepting = !1, this._waitPromptHandoff === handoff && (this._waitPromptHandoff = void 0);
@@ -1734,7 +1965,9 @@ ${args}` : skillBlock;
1734
1965
  * Abort current operation and wait for agent to become idle.
1735
1966
  */
1736
1967
  async abort() {
1737
- this._invalidateWaitPromptHandoffs("The active run was aborted before the pending prompt could run."), this.abortRetry(), this.agent.abort(), await this.waitForIdle();
1968
+ this._invalidateWaitPromptHandoffs("The active run was aborted before the pending prompt could run."), this.abortRetry(), this._activePromptRun && !this.agent.signal && (this._activePromptRun.gracefulStopRequested = !0);
1969
+ let bash = [...this._bashOperations.values()];
1970
+ this.abortBash(), this.agent.abort(), await this.waitForIdle(), await Promise.all(bash);
1738
1971
  }
1739
1972
  async waitForIdle() {
1740
1973
  this.isIdle || await this._getIdleWaitPromise();
@@ -1896,12 +2129,13 @@ ${args}` : skillBlock;
1896
2129
  * @param customInstructions Optional instructions for the compaction summary
1897
2130
  */
1898
2131
  async compact(customInstructions) {
2132
+ this.assertCanStartWork();
1899
2133
  let existing = this._latestCompactionResult();
1900
2134
  if (existing)
1901
2135
  return existing;
1902
2136
  if (this._manualCompactionPromise)
1903
2137
  return this._manualCompactionPromise;
1904
- let promise = this._compact(customInstructions);
2138
+ let promise = this._trackOperation(() => this._compact(customInstructions));
1905
2139
  this._manualCompactionPromise = promise;
1906
2140
  try {
1907
2141
  return await promise;
@@ -1910,13 +2144,13 @@ ${args}` : skillBlock;
1910
2144
  }
1911
2145
  }
1912
2146
  async _compact(customInstructions) {
1913
- this._disconnectFromAgent(), await this.abort();
2147
+ await this.abort(), this.assertCanStartWork();
1914
2148
  let existing = this._latestCompactionResult();
1915
2149
  if (existing)
1916
- return this._reconnectToAgent(), existing;
1917
- this._compactionAbortController = new AbortController(), this._emit({ type: "compaction_start", reason: "manual" });
2150
+ return existing;
2151
+ this._disconnectFromAgent(), this._compactionAbortController = new AbortController();
1918
2152
  try {
1919
- if (!this.model)
2153
+ if (this._emit({ type: "compaction_start", reason: "manual" }), !this.model)
1920
2154
  throw new Error(formatNoModelSelectedMessage());
1921
2155
  let { apiKey, headers, env } = await this._getSummarizationRequestAuth(this.model), pathEntries = this.sessionManager.getBranch(), settings = this.settingsManager.getCompactionSettings(), preparation = prepareCompaction(pathEntries, settings);
1922
2156
  if (!preparation)
@@ -2122,7 +2356,7 @@ ${args}` : skillBlock;
2122
2356
  let messages = this.agent.state.messages, lastMsg = messages[messages.length - 1];
2123
2357
  return lastMsg?.role === "assistant" && lastMsg.stopReason === "error" && (this.agent.state.messages = messages.slice(0, -1)), !0;
2124
2358
  }
2125
- return this.agent.hasQueuedMessages();
2359
+ return !this._activePromptRun?.completion && this.agent.hasQueuedMessages();
2126
2360
  } catch (error) {
2127
2361
  let errorMessage = error instanceof Error ? error.message : "compaction failed";
2128
2362
  return started && this._emit({
@@ -2303,6 +2537,7 @@ ${args}` : skillBlock;
2303
2537
  }, {
2304
2538
  getModel: () => this.resolvedCatalogModel(),
2305
2539
  isIdle: () => this.isIdle,
2540
+ promptWithCompletion: (text, options) => this.promptWithCompletion(text, options),
2306
2541
  isProjectTrusted: () => this.settingsManager.isProjectTrusted(),
2307
2542
  getSignal: () => this.agent.signal,
2308
2543
  abort: () => {
@@ -2476,16 +2711,13 @@ ${args}` : skillBlock;
2476
2711
  * false when rotation is impossible, leaving the error as the final message.
2477
2712
  */
2478
2713
  async _tryRotateSubscriptionKey(message) {
2479
- let model = this.model;
2480
- if (!model)
2714
+ let requestKey = this._modelRuntime.getRequestSubscriptionKey(message);
2715
+ if (!requestKey)
2481
2716
  return !1;
2482
- let providerId = model.provider;
2717
+ let providerId = requestKey.providerId;
2483
2718
  if (this._modelRuntime.hasRuntimeApiKey(providerId))
2484
2719
  return !1;
2485
- let manager = this._modelRuntime.subscriptionManager;
2486
- if ((await manager.list(providerId)).length < 2)
2487
- return !1;
2488
- let errorMessage = message.errorMessage ?? "Unknown error", entry = await manager.rotateOnFailure(providerId, errorMessage);
2720
+ let manager = this._modelRuntime.subscriptionManager, errorMessage = message.errorMessage ?? "Unknown error", entry = await manager.rotateOnFailure(providerId, errorMessage, requestKey.fingerprint);
2489
2721
  if (!entry)
2490
2722
  return !1;
2491
2723
  this._retryAttempt > 0 && this._emit({ type: "auto_retry_end", success: !0, attempt: this._retryAttempt }), this._retryAttempt = 0;
@@ -2523,17 +2755,21 @@ ${args}` : skillBlock;
2523
2755
  * @param options.operations Custom BashOperations for remote execution
2524
2756
  */
2525
2757
  async executeBash(command, onChunk, options) {
2526
- this.assertCanStartWork(), this._bashAbortController = new AbortController();
2527
- let prefix = this.settingsManager.getShellCommandPrefix(), shellPath = this.settingsManager.getShellPath(), resolvedCommand = prefix ? `${prefix}
2528
- ${command}` : command;
2758
+ this.assertCanStartWork();
2759
+ let controller = new AbortController(), settle = () => {
2760
+ }, completion = new Promise((resolve3) => {
2761
+ settle = resolve3;
2762
+ });
2763
+ this._bashOperations.set(controller, completion), this._operations.add(completion);
2529
2764
  try {
2530
- let result = await executeBashWithOperations(resolvedCommand, this.sessionManager.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath, sessionId: this.sessionId }), {
2765
+ let prefix = this.settingsManager.getShellCommandPrefix(), shellPath = this.settingsManager.getShellPath(), resolvedCommand = prefix ? `${prefix}
2766
+ ${command}` : command, result = await executeBashWithOperations(resolvedCommand, this.sessionManager.getCwd(), options?.operations ?? createLocalBashOperations({ shellPath, sessionId: this.sessionId }), {
2531
2767
  onChunk,
2532
- signal: this._bashAbortController.signal
2768
+ signal: controller.signal
2533
2769
  });
2534
2770
  return this.recordBashResult(command, result, options), result;
2535
2771
  } finally {
2536
- this._bashAbortController = void 0;
2772
+ this._bashOperations.delete(controller), this._operations.delete(completion), settle();
2537
2773
  }
2538
2774
  }
2539
2775
  /**
@@ -2555,14 +2791,15 @@ ${command}` : command;
2555
2791
  this.isStreaming ? this._pendingBashMessages.push(bashMessage) : (this.agent.state.messages.push(bashMessage), this.sessionManager.appendMessage(bashMessage));
2556
2792
  }
2557
2793
  /**
2558
- * Cancel running bash command.
2794
+ * Cancel every running direct bash operation.
2559
2795
  */
2560
2796
  abortBash() {
2561
- this._bashAbortController?.abort();
2797
+ for (let controller of this._bashOperations.keys())
2798
+ controller.abort();
2562
2799
  }
2563
2800
  /** Whether a bash command is currently running */
2564
2801
  get isBashRunning() {
2565
- return this._bashAbortController !== void 0;
2802
+ return this._bashOperations.size > 0;
2566
2803
  }
2567
2804
  /** Whether there are pending bash messages waiting to be flushed */
2568
2805
  get hasPendingBashMessages() {
@@ -2605,6 +2842,11 @@ ${command}` : command;
2605
2842
  * @returns Result with editorText (if user message) and cancelled status
2606
2843
  */
2607
2844
  async navigateTree(targetId, options = {}) {
2845
+ if (this.assertCanStartWork(), this._branchSummaryAbortController)
2846
+ throw new Error("Tree navigation is already in progress.");
2847
+ return this._trackOperation(() => this._navigateTree(targetId, options));
2848
+ }
2849
+ async _navigateTree(targetId, options = {}) {
2608
2850
  let oldLeafId = this.sessionManager.getLeafId();
2609
2851
  if (targetId === oldLeafId)
2610
2852
  return { cancelled: !1 };
@@ -2658,6 +2900,8 @@ ${command}` : command;
2658
2900
  modifiedFiles: result.modifiedFiles || []
2659
2901
  };
2660
2902
  } else extensionSummary && (summaryText = extensionSummary.summary, summaryDetails = extensionSummary.details);
2903
+ if (this._branchSummaryAbortController.signal.aborted)
2904
+ return { cancelled: !0, aborted: !0 };
2661
2905
  let newLeafId, editorText, editorImages;
2662
2906
  targetEntry.type === "message" && targetEntry.message.role === "user" ? (newLeafId = targetEntry.parentId, editorText = this._extractUserMessageText(targetEntry.message.content), editorImages = this._extractUserMessageImages(targetEntry.message.content)) : targetEntry.type === "custom_message" ? (newLeafId = targetEntry.parentId, editorText = typeof targetEntry.content == "string" ? targetEntry.content : targetEntry.content.filter((c) => c.type === "text").map((c) => c.text).join("")) : newLeafId = targetId;
2663
2907
  let summaryEntry;
@@ -2780,7 +3024,7 @@ ${command}` : command;
2780
3024
  */
2781
3025
  async exportToHtml(outputPath) {
2782
3026
  let [{ exportSessionToHtml }, { createToolHtmlRenderer }] = await Promise.all([
2783
- import("./export-html-VM4J2MNR.js"),
3027
+ import("./export-html-BRWF5AHI.js"),
2784
3028
  import("./tool-renderer-MV5O452K.js")
2785
3029
  ]), configuredThemeName = this.settingsManager.getTheme(), themeName = configuredThemeName && getThemeByName(configuredThemeName) ? configuredThemeName : void 0, toolRenderer = createToolHtmlRenderer({
2786
3030
  getToolDefinition: (name) => this.getToolDefinition(name),
@@ -2946,13 +3190,36 @@ var AgentSessionRuntime = class {
2946
3190
  _modelFallbackMessage;
2947
3191
  detached = !1;
2948
3192
  transferring = !1;
3193
+ replacement;
3194
+ teardown;
3195
+ closing = !1;
3196
+ async withReplacement(operation) {
3197
+ if (this.closing || this.replacement || this.transferring)
3198
+ throw new Error("Session lifecycle change is already in progress.");
3199
+ let promise = Promise.resolve().then(operation);
3200
+ this.replacement = promise;
3201
+ try {
3202
+ return await promise;
3203
+ } finally {
3204
+ this.replacement === promise && (this.replacement = void 0);
3205
+ }
3206
+ }
2949
3207
  get isDetached() {
2950
3208
  return this.detached;
2951
3209
  }
3210
+ /** Correlated prompt entry for scheduled hosts; never queues across a lifecycle change. */
3211
+ promptWithCompletion(text, options) {
3212
+ return this.detached || this.closing || this.replacement || this.transferring ? Promise.reject(new Error("Session lifecycle change is in progress. Retry the scheduled prompt later.")) : this.session.promptWithCompletion(text, options);
3213
+ }
2952
3214
  async releaseForTransfer(options = {}) {
3215
+ if (this.closing || this.replacement || this.transferring)
3216
+ throw new SessionTransferError("Session transfer is already in progress.", "busy");
3217
+ return this.withReplacement(() => this.releaseForTransferOwned(options));
3218
+ }
3219
+ async releaseForTransferOwned(options) {
2953
3220
  if (options.signal?.throwIfAborted(), this.detached)
2954
3221
  return;
2955
- if (this.transferring)
3222
+ if (this.closing || this.transferring)
2956
3223
  throw new SessionTransferError("Session transfer is already in progress.", "busy");
2957
3224
  this.transferring = !0, this.session.setTransferring(!0);
2958
3225
  let hasAttachedWork = () => getSubagentCancellation(this.session.sessionId)?.hasActiveRuns() || getSubagentCancellation(this.session.sessionFile ?? "")?.hasActiveRuns() || list().some((entry) => entry.status !== "exited" && (!entry.sessionId || entry.sessionId === this.session.sessionId)), busy = () => this.session.isStreaming || this.session.isCompacting || this.session.isBashRunning || this.session.isRetrying || this.session.pendingMessageCount > 0;
@@ -3023,12 +3290,28 @@ var AgentSessionRuntime = class {
3023
3290
  ...options
3024
3291
  }))?.cancel === !0 } : { cancelled: !1 };
3025
3292
  }
3026
- async teardownCurrent(reason, targetSessionFile) {
3027
- this.detached || (await emitSessionShutdownEvent(this.session.extensionRunner, {
3028
- type: "session_shutdown",
3029
- reason,
3030
- targetSessionFile
3031
- }), this.beforeSessionInvalidate?.(reason), this.session.dispose(), this.detached = !0);
3293
+ teardownCurrent(reason, targetSessionFile) {
3294
+ if (this.teardown)
3295
+ return this.teardown;
3296
+ if (this.detached)
3297
+ return Promise.resolve();
3298
+ let session = this.session;
3299
+ return session.stopAdmission(), this.teardown = (async () => {
3300
+ await session.drain();
3301
+ try {
3302
+ await emitSessionShutdownEvent(session.extensionRunner, {
3303
+ type: "session_shutdown",
3304
+ reason,
3305
+ targetSessionFile
3306
+ });
3307
+ } finally {
3308
+ try {
3309
+ this.beforeSessionInvalidate?.(reason);
3310
+ } finally {
3311
+ await session.shutdown(), this.detached = !0;
3312
+ }
3313
+ }
3314
+ })(), this.teardown;
3032
3315
  }
3033
3316
  async teardownForReplacement(reason, sessionManager) {
3034
3317
  try {
@@ -3038,12 +3321,15 @@ var AgentSessionRuntime = class {
3038
3321
  }
3039
3322
  }
3040
3323
  apply(result) {
3041
- this.detached = !1, this._session = result.session, this._services = result.services, this._diagnostics = result.diagnostics, this._modelFallbackMessage = result.modelFallbackMessage, this.onRuntimeApplied?.(result);
3324
+ this.detached = !1, this.teardown = void 0, this._session = result.session, this.closing && this._session.stopAdmission(), this._services = result.services, this._diagnostics = result.diagnostics, this._modelFallbackMessage = result.modelFallbackMessage, this.onRuntimeApplied?.(result);
3042
3325
  }
3043
3326
  async finishSessionReplacement(withSession) {
3044
3327
  this.rebindSession && await this.rebindSession(this.session), withSession && await withSession(this.session.createReplacedSessionContext());
3045
3328
  }
3046
3329
  async switchSession(sessionPath, options) {
3330
+ return this.withReplacement(() => this.switchSessionOwned(sessionPath, options));
3331
+ }
3332
+ async switchSessionOwned(sessionPath, options) {
3047
3333
  if (!this.detached && this.session.sessionFile && canonicalSessionPath(sessionPath) === canonicalSessionPath(this.session.sessionFile))
3048
3334
  return { cancelled: !1 };
3049
3335
  let beforeResult = this.detached ? { cancelled: !1 } : await this.emitBeforeSwitch("resume", sessionPath);
@@ -3064,6 +3350,9 @@ var AgentSessionRuntime = class {
3064
3350
  })), await this.finishSessionReplacement(options?.withSession), { cancelled: !1 };
3065
3351
  }
3066
3352
  async newSession(options) {
3353
+ return this.withReplacement(() => this.newSessionOwned(options));
3354
+ }
3355
+ async newSessionOwned(options) {
3067
3356
  let beforeResult = await this.emitBeforeSwitch("new");
3068
3357
  if (beforeResult.cancelled)
3069
3358
  return beforeResult;
@@ -3076,6 +3365,9 @@ var AgentSessionRuntime = class {
3076
3365
  })), options?.setup && (await options.setup(this.session.sessionManager), this.session.agent.state.messages = this.session.sessionManager.buildSessionContext().messages), await this.finishSessionReplacement(options?.withSession), { cancelled: !1 };
3077
3366
  }
3078
3367
  async fork(entryId, options) {
3368
+ return this.withReplacement(() => this.forkOwned(entryId, options));
3369
+ }
3370
+ async forkOwned(entryId, options) {
3079
3371
  let position = options?.position ?? "before";
3080
3372
  if ((await this.emitBeforeFork(entryId, { position })).cancelled)
3081
3373
  return { cancelled: !0 };
@@ -3132,6 +3424,9 @@ var AgentSessionRuntime = class {
3132
3424
  * @throws {MissingSessionCwdError} When the imported session cwd cannot be resolved and no override is provided.
3133
3425
  */
3134
3426
  async importFromJsonl(inputPath, cwdOverride) {
3427
+ return this.withReplacement(() => this.importFromJsonlOwned(inputPath, cwdOverride));
3428
+ }
3429
+ async importFromJsonlOwned(inputPath, cwdOverride) {
3135
3430
  let resolvedPath = resolvePath(inputPath);
3136
3431
  if (!existsSync4(resolvedPath))
3137
3432
  throw new SessionImportFileNotFoundError(resolvedPath);
@@ -3163,7 +3458,8 @@ var AgentSessionRuntime = class {
3163
3458
  })), await this.finishSessionReplacement(), { cancelled: !1 };
3164
3459
  }
3165
3460
  async dispose() {
3166
- await this.teardownCurrent("quit");
3461
+ this.closing = !0, this.session.stopAdmission(), this.replacement && await this.replacement.catch(() => {
3462
+ }), await this.teardownCurrent("quit");
3167
3463
  }
3168
3464
  };
3169
3465
  async function createAgentSessionRuntime(createRuntime, options) {
@@ -3285,7 +3581,8 @@ async function createOwnedAgentSession(options) {
3285
3581
  allowedToolNames,
3286
3582
  excludedToolNames,
3287
3583
  extensionRunnerRef,
3288
- sessionStartEvent: options.sessionStartEvent
3584
+ sessionStartEvent: options.sessionStartEvent,
3585
+ permissionMode: options.permissionMode
3289
3586
  }), extensionsResult = resourceLoader.getExtensions();
3290
3587
  return {
3291
3588
  session,
@@ -3377,7 +3674,8 @@ async function createAgentSessionFromServices(options) {
3377
3674
  excludeTools: options.excludeTools,
3378
3675
  noTools: options.noTools,
3379
3676
  customTools: options.customTools,
3380
- sessionStartEvent: options.sessionStartEvent
3677
+ sessionStartEvent: options.sessionStartEvent,
3678
+ permissionMode: options.permissionMode
3381
3679
  });
3382
3680
  }
3383
3681
 
@@ -3394,7 +3692,10 @@ export {
3394
3692
  disableRollbackForSession,
3395
3693
  beginTurn,
3396
3694
  captureTreeChanges,
3695
+ getRollbackTargetUserId,
3696
+ getRollbackRecoveryBlockReason,
3397
3697
  peekRollbackTurnsConsumed,
3698
+ commitRollbackTurn,
3398
3699
  rollbackLastTurn,
3399
3700
  migrateRollbackSession,
3400
3701
  clearRollback,