@ashx-j/lunr 0.2.21 → 0.2.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/CHANGELOG.md +4 -2
  2. package/README.md +23 -5
  3. package/dist/builtin-extensions/index.d.ts.map +1 -1
  4. package/dist/builtin-extensions/index.js +1 -0
  5. package/dist/builtin-extensions/index.js.map +1 -1
  6. package/dist/builtin-extensions/lunr-browser.d.ts +9 -0
  7. package/dist/builtin-extensions/lunr-browser.d.ts.map +1 -0
  8. package/dist/builtin-extensions/lunr-browser.js +169 -0
  9. package/dist/builtin-extensions/lunr-browser.js.map +1 -0
  10. package/dist/builtin-extensions/lunr-todos.d.ts.map +1 -1
  11. package/dist/builtin-extensions/lunr-todos.js +15 -0
  12. package/dist/builtin-extensions/lunr-todos.js.map +1 -1
  13. package/dist/builtin-extensions/pi-intercom/index.d.ts.map +1 -1
  14. package/dist/builtin-extensions/pi-intercom/index.js +3 -0
  15. package/dist/builtin-extensions/pi-intercom/index.js.map +1 -1
  16. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts +1 -1
  17. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.d.ts.map +1 -1
  18. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js +5 -1
  19. package/dist/builtin-extensions/pi-subagents/src/extension/control-notices.js.map +1 -1
  20. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts +2 -2
  21. package/dist/builtin-extensions/pi-subagents/src/extension/index.d.ts.map +1 -1
  22. package/dist/builtin-extensions/pi-subagents/src/extension/index.js +18 -5
  23. package/dist/builtin-extensions/pi-subagents/src/extension/index.js.map +1 -1
  24. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts +4 -3
  25. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.d.ts.map +1 -1
  26. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js +3 -0
  27. package/dist/builtin-extensions/pi-subagents/src/extension/tool-description.js.map +1 -1
  28. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts +17 -0
  29. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.d.ts.map +1 -0
  30. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js +45 -0
  31. package/dist/builtin-extensions/pi-subagents/src/intercom/communication.js.map +1 -0
  32. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.d.ts.map +1 -1
  33. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js +4 -11
  34. package/dist/builtin-extensions/pi-subagents/src/intercom/intercom-bridge.js.map +1 -1
  35. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts +4 -1
  36. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.d.ts.map +1 -1
  37. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js +160 -51
  38. package/dist/builtin-extensions/pi-subagents/src/intercom/native-supervisor-channel.js.map +1 -1
  39. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.d.ts.map +1 -1
  40. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js +5 -0
  41. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-ask.js.map +1 -1
  42. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts +2 -0
  43. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.d.ts.map +1 -1
  44. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js +3 -2
  45. package/dist/builtin-extensions/pi-subagents/src/intercom/supervisor-questions.js.map +1 -1
  46. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts +1 -0
  47. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.d.ts.map +1 -1
  48. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js +2 -1
  49. package/dist/builtin-extensions/pi-subagents/src/runs/background/auto-drain.js.map +1 -1
  50. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts +3 -0
  51. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.d.ts.map +1 -1
  52. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js +11 -0
  53. package/dist/builtin-extensions/pi-subagents/src/runs/background/subagent-wait.js.map +1 -1
  54. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.d.ts.map +1 -1
  55. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js +41 -3
  56. package/dist/builtin-extensions/pi-subagents/src/runs/background/wait-tool.js.map +1 -1
  57. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.d.ts.map +1 -1
  58. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js +4 -0
  59. package/dist/builtin-extensions/pi-subagents/src/runs/foreground/subagent-executor.js.map +1 -1
  60. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.d.ts.map +1 -1
  61. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js +3 -0
  62. package/dist/builtin-extensions/pi-subagents/src/runs/shared/pi-args.js.map +1 -1
  63. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts +1 -0
  64. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.d.ts.map +1 -1
  65. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js +3 -0
  66. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-control.js.map +1 -1
  67. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.d.ts.map +1 -1
  68. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js +1 -1
  69. package/dist/builtin-extensions/pi-subagents/src/runs/shared/subagent-prompt-runtime.js.map +1 -1
  70. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts +1 -0
  71. package/dist/builtin-extensions/pi-subagents/src/shared/types.d.ts.map +1 -1
  72. package/dist/builtin-extensions/pi-subagents/src/shared/types.js.map +1 -1
  73. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts +18 -0
  74. package/dist/builtin-extensions/pi-subagents/src/tui/communication.d.ts.map +1 -0
  75. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js +48 -0
  76. package/dist/builtin-extensions/pi-subagents/src/tui/communication.js.map +1 -0
  77. package/dist/builtin-extensions/pi-web-access/index.d.ts.map +1 -1
  78. package/dist/builtin-extensions/pi-web-access/index.js +11 -7
  79. package/dist/builtin-extensions/pi-web-access/index.js.map +1 -1
  80. package/dist/cli/args.d.ts.map +1 -1
  81. package/dist/cli/args.js +2 -1
  82. package/dist/cli/args.js.map +1 -1
  83. package/dist/cli/install-cli.d.ts.map +1 -1
  84. package/dist/cli/install-cli.js +15 -45
  85. package/dist/cli/install-cli.js.map +1 -1
  86. package/dist/core/agent-session-runtime.d.ts +9 -0
  87. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  88. package/dist/core/agent-session-runtime.js +126 -29
  89. package/dist/core/agent-session-runtime.js.map +1 -1
  90. package/dist/core/agent-session.d.ts +22 -0
  91. package/dist/core/agent-session.d.ts.map +1 -1
  92. package/dist/core/agent-session.js +250 -105
  93. package/dist/core/agent-session.js.map +1 -1
  94. package/dist/core/browser/network.d.ts +9 -0
  95. package/dist/core/browser/network.d.ts.map +1 -0
  96. package/dist/core/browser/network.js +146 -0
  97. package/dist/core/browser/network.js.map +1 -0
  98. package/dist/core/browser/runtime.d.ts +24 -0
  99. package/dist/core/browser/runtime.d.ts.map +1 -0
  100. package/dist/core/browser/runtime.js +289 -0
  101. package/dist/core/browser/runtime.js.map +1 -0
  102. package/dist/core/browser/schema.d.ts +16 -0
  103. package/dist/core/browser/schema.d.ts.map +1 -0
  104. package/dist/core/browser/schema.js +36 -0
  105. package/dist/core/browser/schema.js.map +1 -0
  106. package/dist/core/browser/settings.d.ts +8 -0
  107. package/dist/core/browser/settings.d.ts.map +1 -0
  108. package/dist/core/browser/settings.js +30 -0
  109. package/dist/core/browser/settings.js.map +1 -0
  110. package/dist/core/browser/setup.d.ts +2 -0
  111. package/dist/core/browser/setup.d.ts.map +1 -0
  112. package/dist/core/browser/setup.js +16 -0
  113. package/dist/core/browser/setup.js.map +1 -0
  114. package/dist/core/customize.d.ts.map +1 -1
  115. package/dist/core/customize.js +15 -14
  116. package/dist/core/customize.js.map +1 -1
  117. package/dist/core/export-html/index.d.ts.map +1 -1
  118. package/dist/core/export-html/index.js +1 -1
  119. package/dist/core/export-html/index.js.map +1 -1
  120. package/dist/core/extensions/runner.d.ts +1 -0
  121. package/dist/core/extensions/runner.d.ts.map +1 -1
  122. package/dist/core/extensions/runner.js +1 -1
  123. package/dist/core/extensions/runner.js.map +1 -1
  124. package/dist/core/extensions/types.d.ts +1 -1
  125. package/dist/core/extensions/types.d.ts.map +1 -1
  126. package/dist/core/extensions/types.js.map +1 -1
  127. package/dist/core/install-features.d.ts.map +1 -1
  128. package/dist/core/install-features.js +10 -8
  129. package/dist/core/install-features.js.map +1 -1
  130. package/dist/core/memory-cap.d.ts.map +1 -1
  131. package/dist/core/memory-cap.js +5 -3
  132. package/dist/core/memory-cap.js.map +1 -1
  133. package/dist/core/model-tiers.d.ts.map +1 -1
  134. package/dist/core/model-tiers.js +9 -6
  135. package/dist/core/model-tiers.js.map +1 -1
  136. package/dist/core/permissions.d.ts.map +1 -1
  137. package/dist/core/permissions.js +9 -0
  138. package/dist/core/permissions.js.map +1 -1
  139. package/dist/core/plan-mode.d.ts.map +1 -1
  140. package/dist/core/plan-mode.js +3 -0
  141. package/dist/core/plan-mode.js.map +1 -1
  142. package/dist/core/process-registry.d.ts.map +1 -1
  143. package/dist/core/process-registry.js +6 -4
  144. package/dist/core/process-registry.js.map +1 -1
  145. package/dist/core/runtime-scope.d.ts +11 -0
  146. package/dist/core/runtime-scope.d.ts.map +1 -0
  147. package/dist/core/runtime-scope.js +3 -0
  148. package/dist/core/runtime-scope.js.map +1 -0
  149. package/dist/core/sdk.d.ts.map +1 -1
  150. package/dist/core/sdk.js +13 -0
  151. package/dist/core/sdk.js.map +1 -1
  152. package/dist/core/session-handoff.d.ts +35 -0
  153. package/dist/core/session-handoff.d.ts.map +1 -0
  154. package/dist/core/session-handoff.js +214 -0
  155. package/dist/core/session-handoff.js.map +1 -0
  156. package/dist/core/session-manager.d.ts +20 -0
  157. package/dist/core/session-manager.d.ts.map +1 -1
  158. package/dist/core/session-manager.js +184 -22
  159. package/dist/core/session-manager.js.map +1 -1
  160. package/dist/core/session-ownership.d.ts +28 -0
  161. package/dist/core/session-ownership.d.ts.map +1 -0
  162. package/dist/core/session-ownership.js +138 -0
  163. package/dist/core/session-ownership.js.map +1 -0
  164. package/dist/core/session-retention.d.ts.map +1 -1
  165. package/dist/core/session-retention.js +11 -2
  166. package/dist/core/session-retention.js.map +1 -1
  167. package/dist/core/settings-manager.d.ts +11 -0
  168. package/dist/core/settings-manager.d.ts.map +1 -1
  169. package/dist/core/settings-manager.js +27 -0
  170. package/dist/core/settings-manager.js.map +1 -1
  171. package/dist/core/slash-commands.d.ts.map +1 -1
  172. package/dist/core/slash-commands.js +2 -0
  173. package/dist/core/slash-commands.js.map +1 -1
  174. package/dist/core/subagent-wait-interruption.d.ts +11 -0
  175. package/dist/core/subagent-wait-interruption.d.ts.map +1 -0
  176. package/dist/core/subagent-wait-interruption.js +19 -0
  177. package/dist/core/subagent-wait-interruption.js.map +1 -0
  178. package/dist/core/system-prompt.d.ts.map +1 -1
  179. package/dist/core/system-prompt.js +7 -2
  180. package/dist/core/system-prompt.js.map +1 -1
  181. package/dist/core/todo-settings.d.ts +5 -0
  182. package/dist/core/todo-settings.d.ts.map +1 -0
  183. package/dist/core/todo-settings.js +7 -0
  184. package/dist/core/todo-settings.js.map +1 -0
  185. package/dist/core/tools/bash.d.ts.map +1 -1
  186. package/dist/core/tools/bash.js +4 -4
  187. package/dist/core/tools/bash.js.map +1 -1
  188. package/dist/core/tools/edit.d.ts.map +1 -1
  189. package/dist/core/tools/edit.js +5 -3
  190. package/dist/core/tools/edit.js.map +1 -1
  191. package/dist/core/tools/find.d.ts.map +1 -1
  192. package/dist/core/tools/find.js +4 -4
  193. package/dist/core/tools/find.js.map +1 -1
  194. package/dist/core/tools/grep.d.ts.map +1 -1
  195. package/dist/core/tools/grep.js +4 -4
  196. package/dist/core/tools/grep.js.map +1 -1
  197. package/dist/core/tools/ls.d.ts.map +1 -1
  198. package/dist/core/tools/ls.js +4 -4
  199. package/dist/core/tools/ls.js.map +1 -1
  200. package/dist/core/tools/read.d.ts.map +1 -1
  201. package/dist/core/tools/read.js +4 -4
  202. package/dist/core/tools/read.js.map +1 -1
  203. package/dist/core/tools/render-utils.d.ts +14 -5
  204. package/dist/core/tools/render-utils.d.ts.map +1 -1
  205. package/dist/core/tools/render-utils.js +34 -7
  206. package/dist/core/tools/render-utils.js.map +1 -1
  207. package/dist/core/tools/write.d.ts.map +1 -1
  208. package/dist/core/tools/write.js +4 -4
  209. package/dist/core/tools/write.js.map +1 -1
  210. package/dist/core/usage-service.d.ts.map +1 -1
  211. package/dist/core/usage-service.js +5 -3
  212. package/dist/core/usage-service.js.map +1 -1
  213. package/dist/gateway/adapters/discord.d.ts +12 -1
  214. package/dist/gateway/adapters/discord.d.ts.map +1 -1
  215. package/dist/gateway/adapters/discord.js +112 -17
  216. package/dist/gateway/adapters/discord.js.map +1 -1
  217. package/dist/gateway/adapters/telegram.d.ts +4 -2
  218. package/dist/gateway/adapters/telegram.d.ts.map +1 -1
  219. package/dist/gateway/adapters/telegram.js +34 -11
  220. package/dist/gateway/adapters/telegram.js.map +1 -1
  221. package/dist/gateway/agent-bridge.d.ts +14 -3
  222. package/dist/gateway/agent-bridge.d.ts.map +1 -1
  223. package/dist/gateway/agent-bridge.js +252 -60
  224. package/dist/gateway/agent-bridge.js.map +1 -1
  225. package/dist/gateway/approval.d.ts +1 -0
  226. package/dist/gateway/approval.d.ts.map +1 -1
  227. package/dist/gateway/approval.js +60 -18
  228. package/dist/gateway/approval.js.map +1 -1
  229. package/dist/gateway/authz.d.ts +2 -0
  230. package/dist/gateway/authz.d.ts.map +1 -1
  231. package/dist/gateway/authz.js +13 -0
  232. package/dist/gateway/authz.js.map +1 -1
  233. package/dist/gateway/buttons.d.ts +3 -1
  234. package/dist/gateway/buttons.d.ts.map +1 -1
  235. package/dist/gateway/buttons.js +18 -3
  236. package/dist/gateway/buttons.js.map +1 -1
  237. package/dist/gateway/command.d.ts.map +1 -1
  238. package/dist/gateway/command.js +49 -4
  239. package/dist/gateway/command.js.map +1 -1
  240. package/dist/gateway/commands.d.ts.map +1 -1
  241. package/dist/gateway/commands.js +18 -3
  242. package/dist/gateway/commands.js.map +1 -1
  243. package/dist/gateway/config.d.ts +5 -0
  244. package/dist/gateway/config.d.ts.map +1 -1
  245. package/dist/gateway/config.js +5 -0
  246. package/dist/gateway/config.js.map +1 -1
  247. package/dist/gateway/conversations.d.ts +14 -0
  248. package/dist/gateway/conversations.d.ts.map +1 -0
  249. package/dist/gateway/conversations.js +30 -0
  250. package/dist/gateway/conversations.js.map +1 -0
  251. package/dist/gateway/download.d.ts +2 -0
  252. package/dist/gateway/download.d.ts.map +1 -0
  253. package/dist/gateway/download.js +36 -0
  254. package/dist/gateway/download.js.map +1 -0
  255. package/dist/gateway/index.d.ts.map +1 -1
  256. package/dist/gateway/index.js +85 -26
  257. package/dist/gateway/index.js.map +1 -1
  258. package/dist/gateway/mobile-commands.d.ts +24 -0
  259. package/dist/gateway/mobile-commands.d.ts.map +1 -0
  260. package/dist/gateway/mobile-commands.js +422 -0
  261. package/dist/gateway/mobile-commands.js.map +1 -0
  262. package/dist/gateway/presenter.d.ts +16 -0
  263. package/dist/gateway/presenter.d.ts.map +1 -0
  264. package/dist/gateway/presenter.js +210 -0
  265. package/dist/gateway/presenter.js.map +1 -0
  266. package/dist/gateway/router.d.ts +1 -0
  267. package/dist/gateway/router.d.ts.map +1 -1
  268. package/dist/gateway/router.js +32 -3
  269. package/dist/gateway/router.js.map +1 -1
  270. package/dist/gateway/service.d.ts +46 -0
  271. package/dist/gateway/service.d.ts.map +1 -0
  272. package/dist/gateway/service.js +395 -0
  273. package/dist/gateway/service.js.map +1 -0
  274. package/dist/gateway/setup.d.ts +4 -0
  275. package/dist/gateway/setup.d.ts.map +1 -0
  276. package/dist/gateway/setup.js +146 -0
  277. package/dist/gateway/setup.js.map +1 -0
  278. package/dist/gateway/types.d.ts +4 -2
  279. package/dist/gateway/types.d.ts.map +1 -1
  280. package/dist/gateway/types.js.map +1 -1
  281. package/dist/index.d.ts +2 -0
  282. package/dist/index.d.ts.map +1 -1
  283. package/dist/index.js +2 -0
  284. package/dist/index.js.map +1 -1
  285. package/dist/main.d.ts.map +1 -1
  286. package/dist/main.js +2 -1
  287. package/dist/main.js.map +1 -1
  288. package/dist/modes/interactive/components/assistant-message.d.ts +19 -2
  289. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  290. package/dist/modes/interactive/components/assistant-message.js +78 -17
  291. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  292. package/dist/modes/interactive/components/copyable-text.d.ts +27 -0
  293. package/dist/modes/interactive/components/copyable-text.d.ts.map +1 -0
  294. package/dist/modes/interactive/components/copyable-text.js +156 -0
  295. package/dist/modes/interactive/components/copyable-text.js.map +1 -0
  296. package/dist/modes/interactive/components/custom-entry.d.ts +1 -0
  297. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  298. package/dist/modes/interactive/components/custom-entry.js +8 -0
  299. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  300. package/dist/modes/interactive/components/custom-message.d.ts +1 -0
  301. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  302. package/dist/modes/interactive/components/custom-message.js +8 -0
  303. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  304. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  305. package/dist/modes/interactive/components/session-selector.js +16 -0
  306. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  307. package/dist/modes/interactive/components/settings-selector.d.ts +8 -1
  308. package/dist/modes/interactive/components/settings-selector.d.ts.map +1 -1
  309. package/dist/modes/interactive/components/settings-selector.js +51 -0
  310. package/dist/modes/interactive/components/settings-selector.js.map +1 -1
  311. package/dist/modes/interactive/components/thinking-tail.d.ts +9 -2
  312. package/dist/modes/interactive/components/thinking-tail.d.ts.map +1 -1
  313. package/dist/modes/interactive/components/thinking-tail.js +43 -1
  314. package/dist/modes/interactive/components/thinking-tail.js.map +1 -1
  315. package/dist/modes/interactive/components/tool-execution.d.ts +4 -3
  316. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  317. package/dist/modes/interactive/components/tool-execution.js +34 -45
  318. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  319. package/dist/modes/interactive/interactive-mode.d.ts +9 -0
  320. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  321. package/dist/modes/interactive/interactive-mode.js +267 -44
  322. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  323. package/dist/modes/interactive/theme/theme.d.ts +1 -0
  324. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  325. package/dist/modes/interactive/theme/theme.js +23 -0
  326. package/dist/modes/interactive/theme/theme.js.map +1 -1
  327. package/dist/node-runtime/agent-session-services-GZVSOGYR.js +49 -0
  328. package/dist/node-runtime/{builtin-extensions-JCOPAAB5.js → builtin-extensions-QVCXNQT4.js} +6 -5
  329. package/dist/node-runtime/{chunk-LTYWTR3V.js → chunk-2MI5OPMN.js} +17 -2
  330. package/dist/node-runtime/{chunk-W3CVH5RX.js → chunk-2TKODGBZ.js} +11 -6
  331. package/dist/node-runtime/chunk-4EULYYR4.js +62 -0
  332. package/dist/node-runtime/{chunk-6N22HULO.js → chunk-5D7LC2ZQ.js} +7 -2
  333. package/dist/node-runtime/{chunk-KBKMCJDU.js → chunk-5ZQXRPMC.js} +19 -4
  334. package/dist/node-runtime/{chunk-BOHIDQT4.js → chunk-6VYZ5UFP.js} +1 -1
  335. package/dist/node-runtime/chunk-AZJHNQKQ.js +205 -0
  336. package/dist/node-runtime/{chunk-A3KMVBZV.js → chunk-BBUVIEZB.js} +1 -10
  337. package/dist/node-runtime/{chunk-IRPJXI6U.js → chunk-BX2RB477.js} +1 -1
  338. package/dist/node-runtime/chunk-CCCN2UCX.js +14 -0
  339. package/dist/node-runtime/{chunk-25I2BHAA.js → chunk-CSUZVNYE.js} +1 -1
  340. package/dist/node-runtime/chunk-DD5YWFSJ.js +708 -0
  341. package/dist/node-runtime/chunk-DQMGU675.js +3409 -0
  342. package/dist/node-runtime/{chunk-QZMODZQ2.js → chunk-E24EO34J.js} +2 -1
  343. package/dist/node-runtime/chunk-EKVFP6YF.js +355 -0
  344. package/dist/node-runtime/chunk-GJ2RDBRL.js +672 -0
  345. package/dist/node-runtime/{chunk-W3SILANP.js → chunk-GMHJCCEN.js} +8 -8
  346. package/dist/node-runtime/{chunk-DDWHZ633.js → chunk-GS42T6MX.js} +1 -1
  347. package/dist/node-runtime/chunk-GS66LV4M.js +2830 -0
  348. package/dist/node-runtime/chunk-H4K3JDRB.js +47 -0
  349. package/dist/node-runtime/{chunk-2SJB2AWP.js → chunk-HMBGROQK.js} +3 -3
  350. package/dist/node-runtime/{chunk-GB2MGFLI.js → chunk-HPUP7E4T.js} +216 -201
  351. package/dist/node-runtime/{chunk-YMEAYRBE.js → chunk-HTFRRDSF.js} +2 -7
  352. package/dist/node-runtime/{chunk-OPEK5RRY.js → chunk-IF24A3FH.js} +1 -1
  353. package/dist/node-runtime/chunk-IMLCWLPI.js +9 -0
  354. package/dist/node-runtime/chunk-KKUTQQV7.js +144 -0
  355. package/dist/node-runtime/chunk-LFZDVKSP.js +521 -0
  356. package/dist/node-runtime/{chunk-2BUAYZ7K.js → chunk-LLUIPGDR.js} +581 -197
  357. package/dist/node-runtime/{chunk-7NBZ5P7I.js → chunk-NAY6UUQZ.js} +1 -1
  358. package/dist/node-runtime/chunk-OAR4TYZE.js +146 -0
  359. package/dist/node-runtime/{chunk-STERBGUB.js → chunk-OFKSVRV7.js} +2 -2
  360. package/dist/node-runtime/{chunk-JZQ7F36T.js → chunk-PCEW76PM.js} +19 -3
  361. package/dist/node-runtime/{chunk-WLLDXJRT.js → chunk-QAZOULTU.js} +29 -1014
  362. package/dist/node-runtime/{chunk-6KDIOJL3.js → chunk-QH6YL7VK.js} +3 -3
  363. package/dist/node-runtime/chunk-R3K2F5GI.js +122 -0
  364. package/dist/node-runtime/{chunk-RNBHABBA.js → chunk-RDDAZOMU.js} +23 -0
  365. package/dist/node-runtime/{chunk-SY2TFMLO.js → chunk-RIR5EDDJ.js} +46 -151
  366. package/dist/node-runtime/chunk-RMQZU2YU.js +117 -0
  367. package/dist/node-runtime/{chunk-6BEIBLQ3.js → chunk-RWTKOC3B.js} +1 -1
  368. package/dist/node-runtime/{chunk-G6LRAP36.js → chunk-TQGPP4SC.js} +1 -1
  369. package/dist/node-runtime/{chunk-Y5KOEMBH.js → chunk-TVJUOJZJ.js} +9 -674
  370. package/dist/node-runtime/chunk-UAEOTO52.js +119 -0
  371. package/dist/node-runtime/{chunk-AY6CAJSL.js → chunk-UJOCPOMX.js} +6 -3
  372. package/dist/node-runtime/chunk-UP2XBVH5.js +40 -0
  373. package/dist/node-runtime/{chunk-WJVFOIB5.js → chunk-UQUCFAJ3.js} +1 -1
  374. package/dist/node-runtime/chunk-URD2SLIT.js +1019 -0
  375. package/dist/node-runtime/chunk-US544NN6.js +13 -0
  376. package/dist/node-runtime/chunk-UWPJL22I.js +341 -0
  377. package/dist/node-runtime/{chunk-4I23VTC4.js → chunk-VWCE2HSZ.js} +21 -124
  378. package/dist/node-runtime/{chunk-VZR3NCM7.js → chunk-W64JC4E7.js} +18 -14
  379. package/dist/node-runtime/{chunk-AWVD5IEY.js → chunk-X3URCYCU.js} +23 -12
  380. package/dist/node-runtime/{chunk-GKLEQ3I4.js → chunk-XLTL257W.js} +126 -27
  381. package/dist/node-runtime/{chunk-WKDK4C5P.js → chunk-YDO2F2IA.js} +38 -164
  382. package/dist/node-runtime/{chunk-PDNXVXMD.js → chunk-YHQ3NBB3.js} +58 -48
  383. package/dist/node-runtime/chunk-YPHAIRZT.js +10 -0
  384. package/dist/node-runtime/cli-runtime.js +2 -2
  385. package/dist/node-runtime/command-PDVTBRWA.js +45 -0
  386. package/dist/node-runtime/{commands-MV5KOZ64.js → commands-KAMO2T6P.js} +10 -10
  387. package/dist/node-runtime/commands-XDCFGIGW.js +36 -0
  388. package/dist/node-runtime/config-RORQUQFG.js +20 -0
  389. package/dist/node-runtime/{customize-LF5VST47.js → customize-VFJV3U6A.js} +2 -1
  390. package/dist/node-runtime/{direct-tool-executor-BK7CLEBX.js → direct-tool-executor-YAVOLDFY.js} +8 -8
  391. package/dist/node-runtime/{export-html-TEXVV5RP.js → export-html-KSOIMVPI.js} +4 -3
  392. package/dist/node-runtime/{extension-input-O4HSAEM4.js → extension-input-E7BJZ35H.js} +4 -4
  393. package/dist/node-runtime/{extension-selector-X5FCX43D.js → extension-selector-WU42XDTU.js} +4 -4
  394. package/dist/node-runtime/{extract-XLQSJN4V.js → extract-EQJE7FZZ.js} +2 -2
  395. package/dist/node-runtime/{gateway-BM6NLOH4.js → gateway-AYWM5DIO.js} +275 -994
  396. package/dist/node-runtime/{gemini-search-U7SUMPQA.js → gemini-search-35OCRFLN.js} +1 -1
  397. package/dist/node-runtime/{gemini-url-context-PXWCBQHK.js → gemini-url-context-UQY3PHHW.js} +2 -2
  398. package/dist/node-runtime/index.js +104 -65
  399. package/dist/node-runtime/{init-3C7Z24OI.js → init-X2LIUB2H.js} +3 -3
  400. package/dist/node-runtime/{install-cli-EXMJQESX.js → install-cli-3BO4MMQ6.js} +21 -82
  401. package/dist/node-runtime/interactive-mode-4MFRKAHG.js +72 -0
  402. package/dist/node-runtime/{interactive-view-ILS6TAN5.js → interactive-view-TUZHCQM3.js} +8 -8
  403. package/dist/node-runtime/lunr-browser-RYFIIVJN.js +174 -0
  404. package/dist/node-runtime/{lunr-cron-4VHP4E4B.js → lunr-cron-YWXEPZMQ.js} +19 -5
  405. package/dist/node-runtime/main.js +44 -31
  406. package/dist/node-runtime/{memory-cap-3S4XRLNP.js → memory-cap-EL3KL4JJ.js} +2 -1
  407. package/dist/node-runtime/mobile-commands-LVHDAUDP.js +32 -0
  408. package/dist/node-runtime/model-runtime-PLQKAG4B.js +16 -0
  409. package/dist/node-runtime/{model-tiers-NJLHUEGK.js → model-tiers-OU3U5CZG.js} +2 -1
  410. package/dist/node-runtime/{package-manager-cli-N37546V5.js → package-manager-cli-6GT3Z3CK.js} +22 -15
  411. package/dist/node-runtime/{pi-intercom-NV2LW6X7.js → pi-intercom-HBPK5HSJ.js} +4 -1
  412. package/dist/node-runtime/{pi-mcp-adapter-GUFZWW54.js → pi-mcp-adapter-E6WULBKF.js} +4 -4
  413. package/dist/node-runtime/{pi-subagents-6MUIFNDM.js → pi-subagents-CDWK2AKY.js} +236 -79
  414. package/dist/node-runtime/{pi-web-access-2CQGFLT2.js → pi-web-access-WTGMNZ32.js} +15 -15
  415. package/dist/node-runtime/process-registry-4FAKZQOL.js +31 -0
  416. package/dist/node-runtime/{proxy-modes-V6YVFH3C.js → proxy-modes-OSQCWRBI.js} +9 -9
  417. package/dist/node-runtime/rpc-entry.js +44 -31
  418. package/dist/node-runtime/{rpc-mode-W5ZTLTMZ.js → rpc-mode-O3XV4SID.js} +2 -2
  419. package/dist/node-runtime/runtime-4VA6JKNF.js +373 -0
  420. package/dist/node-runtime/{runtime-bridges-2VQTLPOZ.js → runtime-bridges-3XUQ46XW.js} +6 -5
  421. package/dist/node-runtime/service-ISSP6VHE.js +36 -0
  422. package/dist/node-runtime/session-handoff-HC7R5E24.js +33 -0
  423. package/dist/node-runtime/{session-manager-E7AREDTV.js → session-manager-CFN4UFM2.js} +2 -1
  424. package/dist/node-runtime/{session-selector-FJ7M2AIX.js → session-selector-GIM4DHQ2.js} +5 -4
  425. package/dist/node-runtime/{settings-manager-CUGAZWAB.js → settings-manager-6VEMXRDL.js} +7 -2
  426. package/dist/node-runtime/setup-5SR2J35A.js +155 -0
  427. package/dist/node-runtime/setup-JBKOLJ6F.js +18 -0
  428. package/dist/node-runtime/{subagent-executor-MH4A7CCF.js → subagent-executor-M5VWB3D3.js} +26 -18
  429. package/dist/node-runtime/theme-UOO5RVFN.js +68 -0
  430. package/dist/node-runtime/trust-manager-MMISNCYO.js +17 -0
  431. package/dist/node-runtime/{update-cli-XTZMZGOL.js → update-cli-UVKJWRRJ.js} +7 -2
  432. package/dist/node-runtime/usage-service-LFB2SWYV.js +37 -0
  433. package/dist/node-runtime/{video-extract-OYT5WKS5.js → video-extract-OOZHR7SU.js} +2 -2
  434. package/dist/node-runtime/{youtube-extract-TQYKGFGS.js → youtube-extract-FNPAUNHU.js} +6 -6
  435. package/docs/browser.md +86 -0
  436. package/docs/extensions.md +2 -0
  437. package/docs/features.md +96 -16
  438. package/docs/interactive-startup.md +2 -1
  439. package/docs/sessions.md +10 -0
  440. package/docs/settings.md +2 -0
  441. package/docs/tui.md +2 -0
  442. package/docs/usage.md +16 -0
  443. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  444. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  445. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  446. package/examples/extensions/gondolin/package-lock.json +2 -2
  447. package/examples/extensions/gondolin/package.json +1 -1
  448. package/examples/extensions/sandbox/package-lock.json +2 -2
  449. package/examples/extensions/sandbox/package.json +1 -1
  450. package/examples/extensions/with-deps/package-lock.json +2 -2
  451. package/examples/extensions/with-deps/package.json +1 -1
  452. package/package.json +7 -4
  453. package/scripts/install-browser.mjs +20 -0
  454. package/dist/node-runtime/agent-session-services-C743TYQE.js +0 -37
  455. package/dist/node-runtime/chunk-VGYZ3APQ.js +0 -59
  456. package/dist/node-runtime/chunk-XI77KVKA.js +0 -6009
  457. package/dist/node-runtime/command-P4NYCJ2M.js +0 -13
  458. package/dist/node-runtime/interactive-mode-EVVBA64D.js +0 -59
  459. package/dist/node-runtime/{chunk-UWQYRSYQ.js → chunk-YJMMG7C6.js} +25 -25
  460. package/dist/node-runtime/{mcp-panel-IIGMXQGP.js → mcp-panel-KTTFXJZ4.js} +3 -3
  461. package/dist/node-runtime/{src-BPQFJR76.js → src-IVPNZ2BX.js} +9 -9
@@ -34,8 +34,10 @@ import { expandPromptTemplate } from "./prompt-templates.js";
34
34
  import { rollbackSnapshotBeforeWrite } from "./rollback.js";
35
35
  import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
36
36
  import { createSyntheticSourceInfo } from "./source-info.js";
37
+ import { registerSubagentWaitInterruptionOwner, } from "./subagent-wait-interruption.js";
37
38
  import { buildSystemPrompt } from "./system-prompt.js";
38
39
  import { measureStartup } from "./timings.js";
40
+ import { TODO_TOOL_NAMES } from "./todo-settings.js";
39
41
  import { createLocalBashOperations } from "./tools/bash.js";
40
42
  import { createAllToolDefinitions } from "./tools/index.js";
41
43
  import { createToolDefinitionFromAgentTool } from "./tools/tool-definition-wrapper.js";
@@ -89,6 +91,11 @@ export class AgentSession {
89
91
  _isAgentRunActive = false;
90
92
  _idleWaitPromise;
91
93
  _resolveIdleWait;
94
+ _activePromptRun;
95
+ _waitPromptHandoff;
96
+ _waitPromptAcceptance = Promise.resolve();
97
+ _waitPromptGeneration = 0;
98
+ _unregisterSubagentWaitInterruptionOwners = [];
92
99
  /** Tracks pending steering messages for UI display. Removed when delivered. */
93
100
  _steeringMessages = [];
94
101
  /** Tracks pending follow-up messages for UI display. Removed when delivered. */
@@ -160,6 +167,10 @@ export class AgentSession {
160
167
  this._excludedToolNames = config.excludedToolNames ? new Set(config.excludedToolNames) : undefined;
161
168
  this._baseToolsOverride = config.baseToolsOverride;
162
169
  this._sessionStartEvent = config.sessionStartEvent ?? { type: "session_start", reason: "startup" };
170
+ const waitInterruptionOwner = { register: () => this._registerSubagentWaitInterruption() };
171
+ for (const identity of new Set([this.sessionId, this.sessionFile].filter((value) => !!value))) {
172
+ this._unregisterSubagentWaitInterruptionOwners.push(registerSubagentWaitInterruptionOwner(identity, waitInterruptionOwner));
173
+ }
163
174
  // Always subscribe to agent events for internal handling
164
175
  // (session persistence, extensions, auto-compaction, retry logic)
165
176
  this._unsubscribeAgent = this.agent.subscribe(this._handleAgentEvent);
@@ -640,7 +651,21 @@ export class AgentSession {
640
651
  * Remove all listeners and disconnect from agent.
641
652
  * Call this when completely done with the session.
642
653
  */
654
+ transferring = false;
655
+ setTransferring(value) {
656
+ this.transferring = value;
657
+ if (value)
658
+ this._invalidateWaitPromptHandoffs("Session transfer interrupted the pending prompt.");
659
+ }
660
+ assertCanStartWork() {
661
+ this.sessionManager.assertWritable();
662
+ if (this.transferring)
663
+ throw new Error("Session transfer is in progress. Wait or reclaim the session.");
664
+ }
643
665
  dispose() {
666
+ this._invalidateWaitPromptHandoffs("Session closed before the pending prompt could run.");
667
+ for (const unregister of this._unregisterSubagentWaitInterruptionOwners.splice(0))
668
+ unregister();
644
669
  try {
645
670
  this.abortRetry();
646
671
  this.abortCompaction();
@@ -655,6 +680,7 @@ export class AgentSession {
655
680
  this._disconnectFromAgent();
656
681
  this._eventListeners = [];
657
682
  cleanupSessionResources(this.sessionId);
683
+ this.sessionManager.dispose();
658
684
  }
659
685
  // =========================================================================
660
686
  // Read-only State Access
@@ -679,6 +705,10 @@ export class AgentSession {
679
705
  get isIdle() {
680
706
  return !this._isAgentRunActive;
681
707
  }
708
+ /** Whether normal Enter is still being reserved for an interrupted wait handoff. */
709
+ get isWaitPromptHandoffActive() {
710
+ return this._waitPromptHandoff?.accepting === true;
711
+ }
682
712
  /** Current effective system prompt (includes any per-turn extension modifications) */
683
713
  get systemPrompt() {
684
714
  return this.agent.state.systemPrompt;
@@ -874,24 +904,67 @@ export class AgentSession {
874
904
  // =========================================================================
875
905
  // Prompting
876
906
  // =========================================================================
907
+ _registerSubagentWaitInterruption() {
908
+ const run = this._activePromptRun;
909
+ const ownerSignal = this.agent.signal;
910
+ const wait = run && ownerSignal ? { controller: new AbortController(), interrupted: false, ownerSignal } : undefined;
911
+ if (run && wait) {
912
+ run.waits.add(wait);
913
+ if (run.gracefulStopRequested) {
914
+ wait.interrupted = true;
915
+ wait.controller.abort();
916
+ }
917
+ }
918
+ const signal = wait?.controller.signal ?? new AbortController().signal;
919
+ return {
920
+ signal,
921
+ wasInterrupted: () => wait?.interrupted === true,
922
+ unregister: () => {
923
+ if (wait)
924
+ run?.waits.delete(wait);
925
+ },
926
+ };
927
+ }
928
+ _interruptSubagentWaits(run, ownerSignal) {
929
+ for (const wait of run.waits) {
930
+ if (wait.ownerSignal !== ownerSignal)
931
+ continue;
932
+ wait.interrupted = true;
933
+ wait.controller.abort();
934
+ }
935
+ }
936
+ _invalidateWaitPromptHandoffs(message) {
937
+ this._waitPromptGeneration++;
938
+ const handoff = this._waitPromptHandoff;
939
+ this._waitPromptHandoff = undefined;
940
+ if (!handoff)
941
+ return;
942
+ const error = new Error(message);
943
+ for (const reservation of handoff.reservations.splice(0))
944
+ reservation.reject(error);
945
+ }
877
946
  async _runAgentPrompt(messages) {
947
+ const run = { waits: new Set(), gracefulStopRequested: false };
948
+ this._activePromptRun = run;
878
949
  this._isAgentRunActive = true;
879
950
  try {
880
951
  await this.agent.prompt(messages);
881
- while (await this._handlePostAgentRun()) {
952
+ while (await this._handlePostAgentRun(run)) {
882
953
  await this.agent.continue();
883
954
  }
884
955
  }
885
956
  finally {
957
+ if (this._activePromptRun === run)
958
+ this._activePromptRun = undefined;
886
959
  this._systemPromptOverride = undefined;
887
960
  this._flushPendingBashMessages();
888
961
  await this._emitAgentSettled();
889
962
  }
890
963
  }
891
- async _handlePostAgentRun() {
964
+ async _handlePostAgentRun(run) {
892
965
  const msg = this._lastAssistantMessage;
893
966
  this._lastAssistantMessage = undefined;
894
- if (!msg) {
967
+ if (!msg || run.gracefulStopRequested) {
895
968
  return false;
896
969
  }
897
970
  // lunr: quota-dead or auth-invalid keys rotate immediately — same-key backoff
@@ -932,130 +1005,194 @@ export class AgentSession {
932
1005
  * @throws Error if no model selected or no API key available (when not streaming)
933
1006
  */
934
1007
  async prompt(text, options) {
935
- const expandPromptTemplates = options?.expandPromptTemplates ?? true;
1008
+ this.assertCanStartWork();
936
1009
  const preflightResult = options?.preflightResult;
1010
+ let prepared;
937
1011
  let messages;
938
1012
  try {
939
- // Handle extension commands first (execute immediately, even during streaming)
940
- // Extension commands manage their own LLM interaction via pi.sendMessage()
941
- if (expandPromptTemplates && text.startsWith("/")) {
942
- const handled = await this._tryExecuteExtensionCommand(text);
943
- if (handled) {
944
- // Extension command executed, no prompt to send
945
- preflightResult?.(true);
946
- return;
947
- }
948
- }
949
- // Emit input event for extension interception (before skill/template expansion)
950
- let currentText = text;
951
- let currentImages = options?.images;
952
- if (this._extensionRunner.hasHandlers("input")) {
953
- const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", this.isStreaming ? options?.streamingBehavior : undefined);
954
- if (inputResult.action === "handled") {
955
- preflightResult?.(true);
956
- return;
957
- }
958
- if (inputResult.action === "transform") {
959
- currentText = inputResult.text;
960
- currentImages = inputResult.images ?? currentImages;
961
- }
962
- }
963
- // Expand skill commands (/skill:name args) and prompt templates (/template args)
964
- let expandedText = currentText;
965
- if (expandPromptTemplates) {
966
- expandedText = this._expandSkillCommand(expandedText);
967
- expandedText = expandPromptTemplate(expandedText, [...this.promptTemplates]);
1013
+ prepared = await this._preparePromptInput(text, options, this.isStreaming ? options?.streamingBehavior : undefined);
1014
+ if (!prepared) {
1015
+ preflightResult?.(true);
1016
+ return;
968
1017
  }
969
- // If streaming, queue via steer() or followUp() based on option
970
1018
  if (this.isStreaming) {
971
1019
  if (!options?.streamingBehavior) {
972
1020
  throw new Error("Agent is already processing. Specify streamingBehavior ('steer' or 'followUp') to queue the message.");
973
1021
  }
974
1022
  if (options.streamingBehavior === "followUp") {
975
- await this._queueFollowUp(expandedText, currentImages);
1023
+ await this._queueFollowUp(prepared.text, prepared.images);
976
1024
  }
977
1025
  else {
978
- await this._queueSteer(expandedText, currentImages);
1026
+ await this._queueSteer(prepared.text, prepared.images);
979
1027
  }
980
1028
  preflightResult?.(true);
981
1029
  return;
982
1030
  }
983
- // Flush any pending bash messages before the new prompt
984
- this._flushPendingBashMessages();
985
- // Validate model
986
- if (!this.model) {
987
- throw new Error(formatNoModelSelectedMessage());
988
- }
989
- const hasConfiguredAuth = this._modelRuntime.hasConfiguredAuth(this.model.provider) ||
990
- (await this._modelRuntime.checkAuth(this.model.provider)) !== undefined;
991
- if (!hasConfiguredAuth) {
992
- const isOAuth = this._modelRuntime.isUsingOAuth(this.model.provider);
993
- if (isOAuth) {
994
- throw new Error(`Authentication failed for "${this.model.provider}". ` +
995
- `Credentials may have expired or network is unavailable. ` +
996
- `Run '/login ${this.model.provider}' to re-authenticate.`);
997
- }
998
- throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
999
- }
1000
- // Check if we need to compact before sending (catches aborted responses).
1001
- // The user's new prompt is sent below, so do not call agent.continue() here.
1002
- const lastAssistant = this._findLastAssistantMessage();
1003
- if (lastAssistant) {
1004
- await this._checkCompaction(lastAssistant, false);
1005
- }
1006
- // Build messages array (custom message if any, then user message)
1007
- messages = [];
1008
- // Add user message
1009
- const userContent = [{ type: "text", text: expandedText }];
1010
- if (currentImages) {
1011
- userContent.push(...currentImages);
1012
- }
1013
- messages.push({
1031
+ messages = await this._createPromptMessages(prepared);
1032
+ }
1033
+ catch (error) {
1034
+ preflightResult?.(false);
1035
+ throw error;
1036
+ }
1037
+ preflightResult?.(true);
1038
+ await this._runAgentPrompt(messages);
1039
+ }
1040
+ async _preparePromptInput(text, options, streamingBehavior) {
1041
+ const expandPromptTemplates = options?.expandPromptTemplates ?? true;
1042
+ if (expandPromptTemplates && text.startsWith("/") && (await this._tryExecuteExtensionCommand(text))) {
1043
+ return undefined;
1044
+ }
1045
+ let currentText = text;
1046
+ let currentImages = options?.images;
1047
+ if (this._extensionRunner.hasHandlers("input")) {
1048
+ const inputResult = await this._extensionRunner.emitInput(currentText, currentImages, options?.source ?? "interactive", streamingBehavior);
1049
+ if (inputResult.action === "handled")
1050
+ return undefined;
1051
+ if (inputResult.action === "transform") {
1052
+ currentText = inputResult.text;
1053
+ currentImages = inputResult.images ?? currentImages;
1054
+ }
1055
+ }
1056
+ if (expandPromptTemplates) {
1057
+ currentText = this._expandSkillCommand(currentText);
1058
+ currentText = expandPromptTemplate(currentText, [...this.promptTemplates]);
1059
+ }
1060
+ return { text: currentText, images: currentImages };
1061
+ }
1062
+ async _createPromptMessages(input) {
1063
+ this._flushPendingBashMessages();
1064
+ if (!this.model)
1065
+ throw new Error(formatNoModelSelectedMessage());
1066
+ const hasConfiguredAuth = this._modelRuntime.hasConfiguredAuth(this.model.provider) ||
1067
+ (await this._modelRuntime.checkAuth(this.model.provider)) !== undefined;
1068
+ if (!hasConfiguredAuth) {
1069
+ if (this._modelRuntime.isUsingOAuth(this.model.provider)) {
1070
+ throw new Error(`Authentication failed for "${this.model.provider}". ` +
1071
+ `Credentials may have expired or network is unavailable. ` +
1072
+ `Run '/login ${this.model.provider}' to re-authenticate.`);
1073
+ }
1074
+ throw new Error(formatNoApiKeyFoundMessage(this.model.provider));
1075
+ }
1076
+ const lastAssistant = this._findLastAssistantMessage();
1077
+ if (lastAssistant)
1078
+ await this._checkCompaction(lastAssistant, false);
1079
+ const userContent = [{ type: "text", text: input.text }];
1080
+ if (input.images)
1081
+ userContent.push(...input.images);
1082
+ const messages = [
1083
+ {
1014
1084
  role: "user",
1015
1085
  content: userContent,
1016
1086
  timestamp: Date.now(),
1017
- });
1018
- // Inject any pending "nextTurn" messages as context alongside the user message
1019
- for (const msg of this._pendingNextTurnMessages) {
1020
- messages.push(msg);
1021
- }
1022
- this._pendingNextTurnMessages = [];
1023
- // Emit before_agent_start extension event
1024
- const result = await this._extensionRunner.emitBeforeAgentStart(expandedText, currentImages, this._baseSystemPrompt, this._baseSystemPromptOptions);
1025
- // Add all custom messages from extensions
1026
- if (result?.messages) {
1027
- for (const msg of result.messages) {
1028
- messages.push({
1029
- role: "custom",
1030
- customType: msg.customType,
1031
- // Untyped extensions can pass null/missing content; normalize at ingestion.
1032
- content: msg.content ?? [],
1033
- display: msg.display,
1034
- details: msg.details,
1035
- timestamp: Date.now(),
1036
- });
1037
- }
1038
- }
1039
- // Apply extension-modified system prompt, or reset to base
1040
- if (result?.systemPrompt !== undefined) {
1041
- this._systemPromptOverride = result.systemPrompt;
1042
- this.agent.state.systemPrompt = this._withSystemPromptAppend(result.systemPrompt);
1043
- }
1044
- else {
1045
- // Ensure we're using the base prompt (in case previous turn had modifications)
1046
- this._systemPromptOverride = undefined;
1047
- this.agent.state.systemPrompt = this._withSystemPromptAppend(this._baseSystemPrompt);
1087
+ },
1088
+ ...this._pendingNextTurnMessages,
1089
+ ];
1090
+ this._pendingNextTurnMessages = [];
1091
+ const result = await this._extensionRunner.emitBeforeAgentStart(input.text, input.images, this._baseSystemPrompt, this._baseSystemPromptOptions);
1092
+ if (result?.messages) {
1093
+ for (const msg of result.messages) {
1094
+ messages.push({
1095
+ role: "custom",
1096
+ customType: msg.customType,
1097
+ content: msg.content ?? [],
1098
+ display: msg.display,
1099
+ details: msg.details,
1100
+ timestamp: Date.now(),
1101
+ });
1048
1102
  }
1049
1103
  }
1104
+ if (result?.systemPrompt !== undefined) {
1105
+ this._systemPromptOverride = result.systemPrompt;
1106
+ this.agent.state.systemPrompt = this._withSystemPromptAppend(result.systemPrompt);
1107
+ }
1108
+ else {
1109
+ this._systemPromptOverride = undefined;
1110
+ this.agent.state.systemPrompt = this._withSystemPromptAppend(this._baseSystemPrompt);
1111
+ }
1112
+ return messages;
1113
+ }
1114
+ async interruptSubagentWaitWithPrompt(text, options) {
1115
+ const acceptance = this._waitPromptAcceptance.then(() => this._reserveWaitPrompt(text, options));
1116
+ this._waitPromptAcceptance = acceptance.then(() => { }, () => { });
1117
+ return acceptance;
1118
+ }
1119
+ async _reserveWaitPrompt(text, options) {
1120
+ this.assertCanStartWork();
1121
+ const activeRun = this._activePromptRun;
1122
+ const existing = this._waitPromptHandoff;
1123
+ const activeWait = activeRun?.waits.values().next().value;
1124
+ const run = existing?.accepting ? existing.run : activeWait ? activeRun : undefined;
1125
+ const ownerSignal = existing?.accepting ? existing.ownerSignal : activeWait?.ownerSignal;
1126
+ if (!run || !ownerSignal)
1127
+ return undefined;
1128
+ const handoff = existing?.run === run && existing.accepting
1129
+ ? existing
1130
+ : {
1131
+ run,
1132
+ ownerSignal,
1133
+ generation: this._waitPromptGeneration,
1134
+ reservations: [],
1135
+ draining: false,
1136
+ accepting: true,
1137
+ };
1138
+ this._waitPromptHandoff = handoff;
1139
+ let prepared;
1140
+ try {
1141
+ prepared = await this._preparePromptInput(text, options, undefined);
1142
+ }
1050
1143
  catch (error) {
1051
- preflightResult?.(false);
1144
+ if (handoff.reservations.length === 0 && this._waitPromptHandoff === handoff) {
1145
+ this._waitPromptHandoff = undefined;
1146
+ }
1052
1147
  throw error;
1053
1148
  }
1054
- if (!messages) {
1055
- return;
1149
+ if (!prepared) {
1150
+ if (handoff.reservations.length === 0 && this._waitPromptHandoff === handoff) {
1151
+ this._waitPromptHandoff = undefined;
1152
+ }
1153
+ return { completion: Promise.resolve() };
1056
1154
  }
1057
- preflightResult?.(true);
1058
- await this._runAgentPrompt(messages);
1155
+ let resolveCompletion = () => { };
1156
+ let rejectCompletion = (_error) => { };
1157
+ const completion = new Promise((resolve, reject) => {
1158
+ resolveCompletion = resolve;
1159
+ rejectCompletion = reject;
1160
+ });
1161
+ handoff.reservations.push({ input: prepared, resolve: resolveCompletion, reject: rejectCompletion });
1162
+ if (!run.gracefulStopRequested && this.agent.requestGracefulStop(handoff.ownerSignal)) {
1163
+ run.gracefulStopRequested = true;
1164
+ }
1165
+ this._interruptSubagentWaits(run, handoff.ownerSignal);
1166
+ if (!handoff.draining) {
1167
+ handoff.draining = true;
1168
+ void this._drainWaitPromptHandoff(handoff);
1169
+ }
1170
+ return { completion };
1171
+ }
1172
+ async _drainWaitPromptHandoff(handoff) {
1173
+ await this.waitForIdle();
1174
+ while (this._waitPromptHandoff === handoff &&
1175
+ handoff.generation === this._waitPromptGeneration &&
1176
+ handoff.reservations.length > 0) {
1177
+ const reservation = handoff.reservations[0];
1178
+ try {
1179
+ this.assertCanStartWork();
1180
+ const messages = await this._createPromptMessages(reservation.input);
1181
+ handoff.accepting = false;
1182
+ await this._runAgentPrompt(messages);
1183
+ reservation.resolve();
1184
+ }
1185
+ catch (error) {
1186
+ reservation.reject(error);
1187
+ }
1188
+ finally {
1189
+ if (handoff.reservations[0] === reservation)
1190
+ handoff.reservations.shift();
1191
+ }
1192
+ }
1193
+ handoff.accepting = false;
1194
+ if (this._waitPromptHandoff === handoff)
1195
+ this._waitPromptHandoff = undefined;
1059
1196
  }
1060
1197
  /**
1061
1198
  * Try to execute an extension command. Returns true if command was found and executed.
@@ -1123,6 +1260,7 @@ export class AgentSession {
1123
1260
  * @throws Error if text is an extension command
1124
1261
  */
1125
1262
  async steer(text, images) {
1263
+ this.assertCanStartWork();
1126
1264
  // Check for extension commands (cannot be queued)
1127
1265
  if (text.startsWith("/")) {
1128
1266
  this._throwIfExtensionCommand(text);
@@ -1140,6 +1278,7 @@ export class AgentSession {
1140
1278
  * @throws Error if text is an extension command
1141
1279
  */
1142
1280
  async followUp(text, images) {
1281
+ this.assertCanStartWork();
1143
1282
  // Check for extension commands (cannot be queued)
1144
1283
  if (text.startsWith("/")) {
1145
1284
  this._throwIfExtensionCommand(text);
@@ -1205,6 +1344,7 @@ export class AgentSession {
1205
1344
  * @param options.deliverAs Delivery mode: "steer", "followUp", or "nextTurn"
1206
1345
  */
1207
1346
  async sendCustomMessage(message, options) {
1347
+ this.assertCanStartWork();
1208
1348
  const appMessage = {
1209
1349
  role: "custom",
1210
1350
  customType: message.customType,
@@ -1305,6 +1445,7 @@ export class AgentSession {
1305
1445
  * Abort current operation and wait for agent to become idle.
1306
1446
  */
1307
1447
  async abort() {
1448
+ this._invalidateWaitPromptHandoffs("The active run was aborted before the pending prompt could run.");
1308
1449
  this.abortRetry();
1309
1450
  this.agent.abort();
1310
1451
  await this.waitForIdle();
@@ -2177,7 +2318,7 @@ export class AgentSession {
2177
2318
  }
2178
2319
  void this.abort();
2179
2320
  },
2180
- hasPendingMessages: () => this.pendingMessageCount > 0,
2321
+ hasPendingMessages: () => this.pendingMessageCount > 0 || this.agent.hasQueuedMessages(),
2181
2322
  shutdown: () => {
2182
2323
  this._extensionShutdownHandler?.();
2183
2324
  },
@@ -2214,7 +2355,9 @@ export class AgentSession {
2214
2355
  const excludedToolNames = this._excludedToolNames;
2215
2356
  const isAllowedTool = (name) => (!allowedToolNames || allowedToolNames.has(name)) &&
2216
2357
  !excludedToolNames?.has(name) &&
2217
- (this.settingsManager.getMemoryEnabled() || !MEMORY_TOOL_NAMES.has(name));
2358
+ (this.settingsManager.getMemoryEnabled() || !MEMORY_TOOL_NAMES.has(name)) &&
2359
+ (this.settingsManager.getTodosEnabled() || !TODO_TOOL_NAMES.has(name)) &&
2360
+ (name !== "browser" || this.settingsManager.getBrowserEnabled());
2218
2361
  const registeredTools = this._extensionRunner.getAllRegisteredTools();
2219
2362
  const allCustomTools = [
2220
2363
  ...registeredTools,
@@ -2322,6 +2465,7 @@ export class AgentSession {
2322
2465
  });
2323
2466
  }
2324
2467
  async reload(options) {
2468
+ this._invalidateWaitPromptHandoffs("Extensions reloaded before the pending prompt could run.");
2325
2469
  const previousFlagValues = this._extensionRunner.getFlagValues();
2326
2470
  await emitSessionShutdownEvent(this._extensionRunner, { type: "session_shutdown", reason: "reload" });
2327
2471
  await this.settingsManager.reload();
@@ -2484,6 +2628,7 @@ export class AgentSession {
2484
2628
  * @param options.operations Custom BashOperations for remote execution
2485
2629
  */
2486
2630
  async executeBash(command, onChunk, options) {
2631
+ this.assertCanStartWork();
2487
2632
  this._bashAbortController = new AbortController();
2488
2633
  // Apply command prefix if configured (e.g., "shopt -s expand_aliases" for alias support)
2489
2634
  const prefix = this.settingsManager.getShellCommandPrefix();