@bastani/atomic 0.9.3-alpha.3 → 0.9.3-alpha.5

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 (332) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/dist/builtin/cursor/CHANGELOG.md +19 -0
  3. package/dist/builtin/cursor/README.md +2 -1
  4. package/dist/builtin/cursor/package.json +4 -3
  5. package/dist/builtin/cursor/src/auth.ts +1 -1
  6. package/dist/builtin/cursor/src/config.ts +1 -1
  7. package/dist/builtin/cursor/src/cursor-models-raw.json +82 -246
  8. package/dist/builtin/cursor/src/model-mapper.ts +97 -12
  9. package/dist/builtin/cursor/src/model-reference.ts +282 -0
  10. package/dist/builtin/cursor/src/proto/README.md +2 -2
  11. package/dist/builtin/cursor/src/proto/protobuf-codec-request.ts +1 -1
  12. package/dist/builtin/cursor/src/provider.ts +1 -1
  13. package/dist/builtin/cursor/src/stream.ts +1 -1
  14. package/dist/builtin/cursor/src/transport-types.ts +1 -1
  15. package/dist/builtin/intercom/CHANGELOG.md +12 -0
  16. package/dist/builtin/intercom/package.json +2 -2
  17. package/dist/builtin/mcp/CHANGELOG.md +12 -0
  18. package/dist/builtin/mcp/package.json +3 -3
  19. package/dist/builtin/mcp/sampling-handler.ts +1 -1
  20. package/dist/builtin/mcp/types.ts +1 -1
  21. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  22. package/dist/builtin/subagents/package.json +4 -4
  23. package/dist/builtin/subagents/src/runs/background/subagent-runner-streaming.ts +1 -1
  24. package/dist/builtin/subagents/src/runs/background/subagent-runner-types.ts +1 -1
  25. package/dist/builtin/subagents/src/runs/foreground/execution-attempt.ts +1 -1
  26. package/dist/builtin/subagents/src/runs/shared/structured-output.ts +1 -1
  27. package/dist/builtin/subagents/src/shared/types-results.ts +1 -1
  28. package/dist/builtin/subagents/src/shared/utils.ts +1 -1
  29. package/dist/builtin/subagents/src/slash/slash-live-state.ts +1 -1
  30. package/dist/builtin/web-access/CHANGELOG.md +12 -0
  31. package/dist/builtin/web-access/package.json +2 -2
  32. package/dist/builtin/web-access/summary-review.ts +1 -1
  33. package/dist/builtin/web-access/web-search-summary.ts +1 -1
  34. package/dist/builtin/web-access/web-search-tool.ts +1 -1
  35. package/dist/builtin/workflows/CHANGELOG.md +12 -0
  36. package/dist/builtin/workflows/README.md +2 -0
  37. package/dist/builtin/workflows/package.json +2 -2
  38. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +6 -3
  39. package/dist/bun/register-bedrock.d.ts.map +1 -1
  40. package/dist/bun/register-bedrock.js +1 -1
  41. package/dist/bun/register-bedrock.js.map +1 -1
  42. package/dist/cli/file-processor.d.ts +1 -1
  43. package/dist/cli/file-processor.d.ts.map +1 -1
  44. package/dist/cli/file-processor.js.map +1 -1
  45. package/dist/cli/initial-message.d.ts +1 -1
  46. package/dist/cli/initial-message.d.ts.map +1 -1
  47. package/dist/cli/initial-message.js.map +1 -1
  48. package/dist/cli/list-models.d.ts.map +1 -1
  49. package/dist/cli/list-models.js.map +1 -1
  50. package/dist/core/agent-session-auto-compaction.d.ts +1 -1
  51. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  52. package/dist/core/agent-session-auto-compaction.js +1 -1
  53. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  54. package/dist/core/agent-session-events.d.ts +1 -1
  55. package/dist/core/agent-session-events.d.ts.map +1 -1
  56. package/dist/core/agent-session-events.js +1 -1
  57. package/dist/core/agent-session-events.js.map +1 -1
  58. package/dist/core/agent-session-export.d.ts.map +1 -1
  59. package/dist/core/agent-session-export.js.map +1 -1
  60. package/dist/core/agent-session-extension-bindings.d.ts.map +1 -1
  61. package/dist/core/agent-session-extension-bindings.js +1 -1
  62. package/dist/core/agent-session-extension-bindings.js.map +1 -1
  63. package/dist/core/agent-session-message-queue.d.ts +1 -1
  64. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  65. package/dist/core/agent-session-message-queue.js.map +1 -1
  66. package/dist/core/agent-session-methods.d.ts +1 -1
  67. package/dist/core/agent-session-methods.d.ts.map +1 -1
  68. package/dist/core/agent-session-methods.js.map +1 -1
  69. package/dist/core/agent-session-models.d.ts +1 -1
  70. package/dist/core/agent-session-models.d.ts.map +1 -1
  71. package/dist/core/agent-session-models.js +1 -1
  72. package/dist/core/agent-session-models.js.map +1 -1
  73. package/dist/core/agent-session-prompt.d.ts +1 -1
  74. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  75. package/dist/core/agent-session-prompt.js.map +1 -1
  76. package/dist/core/agent-session-retry.d.ts +1 -1
  77. package/dist/core/agent-session-retry.d.ts.map +1 -1
  78. package/dist/core/agent-session-retry.js +1 -1
  79. package/dist/core/agent-session-retry.js.map +1 -1
  80. package/dist/core/agent-session-services.d.ts +1 -1
  81. package/dist/core/agent-session-services.d.ts.map +1 -1
  82. package/dist/core/agent-session-services.js.map +1 -1
  83. package/dist/core/agent-session-state.d.ts +1 -1
  84. package/dist/core/agent-session-state.d.ts.map +1 -1
  85. package/dist/core/agent-session-state.js.map +1 -1
  86. package/dist/core/agent-session-types.d.ts +1 -1
  87. package/dist/core/agent-session-types.d.ts.map +1 -1
  88. package/dist/core/agent-session-types.js.map +1 -1
  89. package/dist/core/agent-session.d.ts +1 -1
  90. package/dist/core/agent-session.d.ts.map +1 -1
  91. package/dist/core/agent-session.js.map +1 -1
  92. package/dist/core/anthropic-thinking-guard.d.ts +1 -1
  93. package/dist/core/anthropic-thinking-guard.d.ts.map +1 -1
  94. package/dist/core/anthropic-thinking-guard.js.map +1 -1
  95. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  96. package/dist/core/atomic-guide-command.js +15 -11
  97. package/dist/core/atomic-guide-command.js.map +1 -1
  98. package/dist/core/auth-storage.d.ts +2 -2
  99. package/dist/core/auth-storage.d.ts.map +1 -1
  100. package/dist/core/auth-storage.js +1 -1
  101. package/dist/core/auth-storage.js.map +1 -1
  102. package/dist/core/codex-fast-mode.d.ts +1 -1
  103. package/dist/core/codex-fast-mode.d.ts.map +1 -1
  104. package/dist/core/codex-fast-mode.js +1 -1
  105. package/dist/core/codex-fast-mode.js.map +1 -1
  106. package/dist/core/compaction/branch-summarization.d.ts +1 -1
  107. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  108. package/dist/core/compaction/branch-summarization.js +1 -1
  109. package/dist/core/compaction/branch-summarization.js.map +1 -1
  110. package/dist/core/compaction/compaction.d.ts +1 -1
  111. package/dist/core/compaction/compaction.d.ts.map +1 -1
  112. package/dist/core/compaction/compaction.js.map +1 -1
  113. package/dist/core/compaction/context-compaction-runner.d.ts +1 -1
  114. package/dist/core/compaction/context-compaction-runner.d.ts.map +1 -1
  115. package/dist/core/compaction/context-compaction-runner.js +1 -1
  116. package/dist/core/compaction/context-compaction-runner.js.map +1 -1
  117. package/dist/core/compaction/context-deletion-tool-definitions.d.ts.map +1 -1
  118. package/dist/core/compaction/context-deletion-tool-definitions.js +1 -1
  119. package/dist/core/compaction/context-deletion-tool-definitions.js.map +1 -1
  120. package/dist/core/compaction/context-transcript-analysis.d.ts.map +1 -1
  121. package/dist/core/compaction/context-transcript-analysis.js.map +1 -1
  122. package/dist/core/compaction/utils.d.ts +1 -1
  123. package/dist/core/compaction/utils.d.ts.map +1 -1
  124. package/dist/core/compaction/utils.js.map +1 -1
  125. package/dist/core/context-window.d.ts +2 -2
  126. package/dist/core/context-window.d.ts.map +1 -1
  127. package/dist/core/context-window.js.map +1 -1
  128. package/dist/core/copilot-gemini-payload-sanitizer.d.ts +1 -1
  129. package/dist/core/copilot-gemini-payload-sanitizer.d.ts.map +1 -1
  130. package/dist/core/copilot-gemini-payload-sanitizer.js.map +1 -1
  131. package/dist/core/copilot-gemini-reasoning.d.ts +1 -1
  132. package/dist/core/copilot-gemini-reasoning.d.ts.map +1 -1
  133. package/dist/core/copilot-gemini-reasoning.js.map +1 -1
  134. package/dist/core/copilot-gemini-tool-arguments.d.ts +1 -1
  135. package/dist/core/copilot-gemini-tool-arguments.d.ts.map +1 -1
  136. package/dist/core/copilot-gemini-tool-arguments.js.map +1 -1
  137. package/dist/core/export-html/tool-renderer.d.ts.map +1 -1
  138. package/dist/core/export-html/tool-renderer.js.map +1 -1
  139. package/dist/core/extensions/agent-events.d.ts +1 -1
  140. package/dist/core/extensions/agent-events.d.ts.map +1 -1
  141. package/dist/core/extensions/agent-events.js.map +1 -1
  142. package/dist/core/extensions/api-types.d.ts +1 -1
  143. package/dist/core/extensions/api-types.d.ts.map +1 -1
  144. package/dist/core/extensions/api-types.js.map +1 -1
  145. package/dist/core/extensions/context-types.d.ts +1 -1
  146. package/dist/core/extensions/context-types.d.ts.map +1 -1
  147. package/dist/core/extensions/context-types.js.map +1 -1
  148. package/dist/core/extensions/event-results.d.ts +1 -1
  149. package/dist/core/extensions/event-results.d.ts.map +1 -1
  150. package/dist/core/extensions/event-results.js.map +1 -1
  151. package/dist/core/extensions/loader-virtual-modules.d.ts +12 -0
  152. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  153. package/dist/core/extensions/loader-virtual-modules.js +18 -2
  154. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  155. package/dist/core/extensions/provider-types.d.ts +1 -1
  156. package/dist/core/extensions/provider-types.d.ts.map +1 -1
  157. package/dist/core/extensions/provider-types.js.map +1 -1
  158. package/dist/core/extensions/runner-context.d.ts +1 -1
  159. package/dist/core/extensions/runner-context.d.ts.map +1 -1
  160. package/dist/core/extensions/runner-context.js.map +1 -1
  161. package/dist/core/extensions/runner-events.d.ts +1 -1
  162. package/dist/core/extensions/runner-events.d.ts.map +1 -1
  163. package/dist/core/extensions/runner-events.js.map +1 -1
  164. package/dist/core/extensions/runner.d.ts +1 -1
  165. package/dist/core/extensions/runner.d.ts.map +1 -1
  166. package/dist/core/extensions/runner.js.map +1 -1
  167. package/dist/core/extensions/runtime-types.d.ts +1 -1
  168. package/dist/core/extensions/runtime-types.d.ts.map +1 -1
  169. package/dist/core/extensions/runtime-types.js.map +1 -1
  170. package/dist/core/extensions/tool-events.d.ts +1 -1
  171. package/dist/core/extensions/tool-events.d.ts.map +1 -1
  172. package/dist/core/extensions/tool-events.js.map +1 -1
  173. package/dist/core/footer-data-provider.d.ts +5 -0
  174. package/dist/core/footer-data-provider.d.ts.map +1 -1
  175. package/dist/core/footer-data-provider.js +46 -12
  176. package/dist/core/footer-data-provider.js.map +1 -1
  177. package/dist/core/http-dispatcher.d.ts +3 -1
  178. package/dist/core/http-dispatcher.d.ts.map +1 -1
  179. package/dist/core/http-dispatcher.js +4 -1
  180. package/dist/core/http-dispatcher.js.map +1 -1
  181. package/dist/core/keybindings.d.ts +1 -1
  182. package/dist/core/messages.d.ts +1 -1
  183. package/dist/core/messages.d.ts.map +1 -1
  184. package/dist/core/messages.js.map +1 -1
  185. package/dist/core/model-registry-auth.d.ts +1 -1
  186. package/dist/core/model-registry-auth.d.ts.map +1 -1
  187. package/dist/core/model-registry-auth.js.map +1 -1
  188. package/dist/core/model-registry-builtins.d.ts +1 -1
  189. package/dist/core/model-registry-builtins.d.ts.map +1 -1
  190. package/dist/core/model-registry-builtins.js +1 -1
  191. package/dist/core/model-registry-builtins.js.map +1 -1
  192. package/dist/core/model-registry-custom-loader.d.ts.map +1 -1
  193. package/dist/core/model-registry-custom-loader.js +1 -1
  194. package/dist/core/model-registry-custom-loader.js.map +1 -1
  195. package/dist/core/model-registry-dynamic.d.ts +1 -1
  196. package/dist/core/model-registry-dynamic.d.ts.map +1 -1
  197. package/dist/core/model-registry-dynamic.js +1 -1
  198. package/dist/core/model-registry-dynamic.js.map +1 -1
  199. package/dist/core/model-registry-loader.d.ts.map +1 -1
  200. package/dist/core/model-registry-loader.js.map +1 -1
  201. package/dist/core/model-registry-types.d.ts +1 -1
  202. package/dist/core/model-registry-types.d.ts.map +1 -1
  203. package/dist/core/model-registry-types.js.map +1 -1
  204. package/dist/core/model-registry.d.ts +1 -1
  205. package/dist/core/model-registry.d.ts.map +1 -1
  206. package/dist/core/model-registry.js +1 -1
  207. package/dist/core/model-registry.js.map +1 -1
  208. package/dist/core/model-resolver-cli.d.ts.map +1 -1
  209. package/dist/core/model-resolver-cli.js.map +1 -1
  210. package/dist/core/model-resolver-defaults.d.ts +1 -1
  211. package/dist/core/model-resolver-defaults.d.ts.map +1 -1
  212. package/dist/core/model-resolver-defaults.js.map +1 -1
  213. package/dist/core/model-resolver-initial.d.ts +1 -1
  214. package/dist/core/model-resolver-initial.d.ts.map +1 -1
  215. package/dist/core/model-resolver-initial.js.map +1 -1
  216. package/dist/core/model-resolver-patterns.d.ts +1 -1
  217. package/dist/core/model-resolver-patterns.d.ts.map +1 -1
  218. package/dist/core/model-resolver-patterns.js.map +1 -1
  219. package/dist/core/model-resolver-scope.d.ts.map +1 -1
  220. package/dist/core/model-resolver-scope.js +1 -1
  221. package/dist/core/model-resolver-scope.js.map +1 -1
  222. package/dist/core/model-resolver-types.d.ts +1 -1
  223. package/dist/core/model-resolver-types.d.ts.map +1 -1
  224. package/dist/core/model-resolver-types.js.map +1 -1
  225. package/dist/core/provider-attribution.d.ts +2 -2
  226. package/dist/core/provider-attribution.d.ts.map +1 -1
  227. package/dist/core/provider-attribution.js +4 -0
  228. package/dist/core/provider-attribution.js.map +1 -1
  229. package/dist/core/sdk-types.d.ts +1 -1
  230. package/dist/core/sdk-types.d.ts.map +1 -1
  231. package/dist/core/sdk-types.js.map +1 -1
  232. package/dist/core/sdk.d.ts +1 -1
  233. package/dist/core/sdk.d.ts.map +1 -1
  234. package/dist/core/sdk.js +2 -2
  235. package/dist/core/sdk.js.map +1 -1
  236. package/dist/core/session-manager-core.d.ts +1 -1
  237. package/dist/core/session-manager-core.d.ts.map +1 -1
  238. package/dist/core/session-manager-core.js.map +1 -1
  239. package/dist/core/session-manager-entries.d.ts +1 -1
  240. package/dist/core/session-manager-entries.d.ts.map +1 -1
  241. package/dist/core/session-manager-entries.js.map +1 -1
  242. package/dist/core/session-manager-list.d.ts.map +1 -1
  243. package/dist/core/session-manager-list.js.map +1 -1
  244. package/dist/core/session-manager-types.d.ts +1 -1
  245. package/dist/core/session-manager-types.d.ts.map +1 -1
  246. package/dist/core/session-manager-types.js.map +1 -1
  247. package/dist/core/settings-types.d.ts +1 -1
  248. package/dist/core/settings-types.d.ts.map +1 -1
  249. package/dist/core/settings-types.js.map +1 -1
  250. package/dist/core/tools/oversized-tool-result.d.ts +1 -1
  251. package/dist/core/tools/oversized-tool-result.d.ts.map +1 -1
  252. package/dist/core/tools/oversized-tool-result.js.map +1 -1
  253. package/dist/core/tools/read-url.d.ts +1 -1
  254. package/dist/core/tools/read-url.d.ts.map +1 -1
  255. package/dist/core/tools/read-url.js.map +1 -1
  256. package/dist/core/tools/read.d.ts.map +1 -1
  257. package/dist/core/tools/read.js.map +1 -1
  258. package/dist/core/tools/render-utils.d.ts +1 -1
  259. package/dist/core/tools/render-utils.d.ts.map +1 -1
  260. package/dist/core/tools/render-utils.js.map +1 -1
  261. package/dist/core/tools/todos-types.d.ts.map +1 -1
  262. package/dist/core/tools/todos-types.js +1 -1
  263. package/dist/core/tools/todos-types.js.map +1 -1
  264. package/dist/main-app-mode.d.ts +1 -1
  265. package/dist/main-app-mode.d.ts.map +1 -1
  266. package/dist/main-app-mode.js.map +1 -1
  267. package/dist/main-session-options.d.ts.map +1 -1
  268. package/dist/main-session-options.js +1 -1
  269. package/dist/main-session-options.js.map +1 -1
  270. package/dist/modes/interactive/components/assistant-message.d.ts +1 -1
  271. package/dist/modes/interactive/components/assistant-message.d.ts.map +1 -1
  272. package/dist/modes/interactive/components/assistant-message.js.map +1 -1
  273. package/dist/modes/interactive/components/chat-message-renderer.d.ts +1 -1
  274. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  275. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  276. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  277. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  278. package/dist/modes/interactive/components/model-selector.d.ts +1 -1
  279. package/dist/modes/interactive/components/model-selector.d.ts.map +1 -1
  280. package/dist/modes/interactive/components/model-selector.js +1 -1
  281. package/dist/modes/interactive/components/model-selector.js.map +1 -1
  282. package/dist/modes/interactive/components/scoped-models-selector.d.ts +1 -1
  283. package/dist/modes/interactive/components/scoped-models-selector.d.ts.map +1 -1
  284. package/dist/modes/interactive/components/scoped-models-selector.js.map +1 -1
  285. package/dist/modes/interactive/components/settings-selector-handlers.d.ts.map +1 -1
  286. package/dist/modes/interactive/components/settings-selector-handlers.js +2 -2
  287. package/dist/modes/interactive/components/settings-selector-handlers.js.map +1 -1
  288. package/dist/modes/interactive/components/settings-selector-types.d.ts +1 -1
  289. package/dist/modes/interactive/components/settings-selector-types.d.ts.map +1 -1
  290. package/dist/modes/interactive/components/settings-selector-types.js.map +1 -1
  291. package/dist/modes/interactive/interactive-mode-deps.d.ts +1 -1
  292. package/dist/modes/interactive/interactive-mode-deps.d.ts.map +1 -1
  293. package/dist/modes/interactive/interactive-mode-deps.js +1 -1
  294. package/dist/modes/interactive/interactive-mode-deps.js.map +1 -1
  295. package/dist/modes/print-mode.d.ts +1 -1
  296. package/dist/modes/print-mode.d.ts.map +1 -1
  297. package/dist/modes/print-mode.js.map +1 -1
  298. package/dist/modes/rpc/rpc-client.d.ts +1 -1
  299. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  300. package/dist/modes/rpc/rpc-client.js.map +1 -1
  301. package/dist/modes/rpc/rpc-types.d.ts +1 -1
  302. package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
  303. package/dist/modes/rpc/rpc-types.js.map +1 -1
  304. package/docs/changelog.mdx +15 -0
  305. package/docs/custom-provider.md +2 -1
  306. package/docs/models.md +2 -0
  307. package/docs/providers.md +3 -1
  308. package/docs/quickstart.md +6 -4
  309. package/docs/sdk.md +2 -2
  310. package/docs/settings.md +4 -4
  311. package/docs/workflows.md +11 -6
  312. package/examples/extensions/custom-footer.ts +1 -1
  313. package/examples/extensions/custom-provider-anthropic/index.ts +1 -1
  314. package/examples/extensions/custom-provider-gitlab-duo/index.ts +1 -1
  315. package/examples/extensions/custom-provider-gitlab-duo/test.ts +1 -1
  316. package/examples/extensions/handoff.ts +1 -1
  317. package/examples/extensions/hello.ts +1 -1
  318. package/examples/extensions/plan-mode/index.ts +1 -1
  319. package/examples/extensions/preset.ts +1 -1
  320. package/examples/extensions/qna.ts +1 -1
  321. package/examples/extensions/subagent/display.ts +1 -1
  322. package/examples/extensions/subagent/runner.ts +1 -1
  323. package/examples/extensions/subagent/schemas.ts +1 -1
  324. package/examples/extensions/subagent/types.ts +1 -1
  325. package/examples/extensions/summarize.ts +1 -1
  326. package/examples/extensions/tic-tac-toe.ts +1 -1
  327. package/examples/extensions/todo.ts +1 -1
  328. package/examples/extensions/tool-override.ts +1 -1
  329. package/examples/sdk/02-custom-model.ts +1 -1
  330. package/examples/sdk/12-full-control.ts +1 -1
  331. package/examples/sdk/README.md +1 -1
  332. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-message-queue.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAe,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAA+G,KAAK,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEzM,wBAAsB,WAAW,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAe1G;AAED;;GAEG;AAEH,wBAAsB,cAAc,C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gB,yBAAyB,CAAC,IAAI,EAAE,YAAY,GAAG,kBAAkB,CAShF;AAGD,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAOhG;AAED;;;;;;GAMG;AAEH,wBAAgB,UAAU,CAAC,IAAI,EAAE,YAAY,GAAG;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAYzF;AAED,wEAAwE;AAExE,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAEzE;AAED,iDAAiD;AAEjD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,GAAG,SAAS,MAAM,EAAE,CAEzE;AAGD,wBAAsB,KAAK,CAAC,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAI7D;AAOD,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAED;;;GAGG;AAEH,wBAAgB,eAAe,CAAC,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAMD;;;GAGG;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;CAmB3C,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content,\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
1
+ {"version":3,"file":"agent-session-message-queue.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CA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EAAE,IAAI,EAAE,KAAK,GAAG,eAAe,GAAG,IAAI,CAGvF;AAMD;;;GAGG;AAEH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;;;;;;;;CAmB3C,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content,\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,8BAA8B,EAA2E,MAAM,0BAA0B,CAAC;AAEzM,MAAM,CAAC,KAAK,UAAU,WAAW,CAAqB,IAAY,EAAE,MAAuB;IAC1F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,MAAM,OAAO,GAAmC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,kBAAkB,CACtB;QACC,IAAI,EAAE,MAAM;QACZ,OAAO;QACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;KACrB,EACD,OAAO,CACP,CAAC;AACH,CAAC;AAED;;GAEG;AAEH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAqB,IAAY,EAAE,MAAuB;IAC7F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,MAAM,OA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AAC,YAAY,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,4EAA4E;AAC5E,aAAa;AACb,4EAA4E;AAE5E;;;GAGG;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,WAAW;IACX,cAAc;IACd,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,wCAAwC;IACxC,kBAAkB;IAClB,yBAAyB;IACzB,2BAA2B;IAC3B,UAAU;IACV,mBAAmB;IACnB,mBAAmB;IACnB,KAAK;IACL,eAAe;IACf,eAAe;CACf,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content,\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
1
+ {"version":3,"file":"agent-session-message-queue.js","sourceRoot":"","sources":["../../src/core/agent-session-message-queue.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,4BAA4B,EAAE,sBAAsB,EAAE,8BAA8B,EAA2E,MAAM,0BAA0B,CAAC;AAEzM,MAAM,CAAC,KAAK,UAAU,WAAW,CAAqB,IAAY,EAAE,MAAuB;IAC1F,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxB,MAAM,OAAO,GAAmC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;IACzE,IAAI,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IACD,IAAI,CAAC,kBAAkB,CACtB;Q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AC;AAChC,CAAC;AAED,4EAA4E;AAC5E,mBAAmB;AACnB,4EAA4E;AAG5E,MAAM,UAAU,eAAe,CAAqB,IAA6B;IAChF,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED;;;GAGG;AAEH,MAAM,UAAU,eAAe,CAAqB,IAA6B;IAChF,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;AAC5C,CAAC;AAED,4EAA4E;AAC5E,aAAa;AACb,4EAA4E;AAE5E;;;GAGG;AAEH,MAAM,CAAC,MAAM,+BAA+B,GAAG;IAC9C,WAAW;IACX,cAAc;IACd,wBAAwB;IACxB,iBAAiB;IACjB,oBAAoB;IACpB,8BAA8B;IAC9B,8BAA8B;IAC9B,+BAA+B;IAC/B,wCAAwC;IACxC,kBAAkB;IAClB,yBAAyB;IACzB,2BAA2B;IAC3B,UAAU;IACV,mBAAmB;IACnB,mBAAmB;IACnB,KAAK;IACL,eAAe;IACf,eAAe;CACf,CAAC","sourcesContent":["import type { AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { ImageContent, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { CustomMessage } from \"./messages.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { customMessageExcludesContext, drainAgentMessageQueue, normalizeInterruptAbortMessage, type AgentQueueAccess, type DrainedAgentQueues, type InterruptQueueHold } from \"./agent-session-types.ts\";\n\nexport async function _queueSteer(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._steeringMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"steer\",\n\t);\n}\n\n/**\n * Internal: Queue a follow-up message (already expanded, no extension command check).\n */\n\nexport async function _queueFollowUp(this: AgentSession, text: string, images?: ImageContent[]): Promise<void> {\n\tthis._followUpMessages.push(text);\n\tthis._emitQueueUpdate();\n\tconst content: (TextContent | ImageContent)[] = [{ type: \"text\", text }];\n\tif (images) {\n\t\tcontent.push(...images);\n\t}\n\tthis._queueAgentMessage(\n\t\t{\n\t\t\trole: \"user\",\n\t\t\tcontent,\n\t\t\ttimestamp: Date.now(),\n\t\t},\n\t\t\"followUp\",\n\t);\n}\n\n/**\n * Throw an error if the text is an extension command.\n */\n\nexport function _throwIfExtensionCommand(this: AgentSession, text: string): void {\n\tconst spaceIndex = text.indexOf(\" \");\n\tconst commandName = spaceIndex === -1 ? text.slice(1) : text.slice(1, spaceIndex);\n\tconst command = this._extensionRunner.getCommand(commandName);\n\n\tif (command) {\n\t\tthrow new Error(\n\t\t\t`Extension command \"/${commandName}\" cannot be queued. Use prompt() or execute the command when not streaming.`,\n\t\t);\n\t}\n}\n\n/**\n * Send a custom message to the session. Creates a CustomMessageEntry.\n *\n * Handles five cases:\n * - Streaming + interrupt trigger: aborts the active run and starts an immediate custom-message turn\n * - Streaming + explicit display-only context exclusion: appends to state/session, no turn and no queue\n * - Streaming otherwise: queues message, processed when loop pulls from queue\n * - Not streaming + triggerTurn: appends to state/session, starts new turn\n * - Not streaming + no trigger: appends to state/session, no turn\n *\n * @param message Custom message with customType, content, display, details\n * @param options.triggerTurn If true and not streaming, triggers a new LLM turn\n * @param options.deliverAs Delivery mode: \"steer\", \"followUp\", \"nextTurn\", or \"interrupt\"\n */\n\nexport async function sendCustomMessage<T = unknown>(this: AgentSession, \n\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tconst appMessage = {\n\t\trole: \"custom\" as const,\n\t\tcustomType: message.customType,\n\t\tcontent: message.content,\n\t\tdisplay: message.display,\n\t\tdetails: message.details,\n\t\ttimestamp: Date.now(),\n\t\t...(options?.excludeFromContext === true ? { excludeFromContext: true } : {}),\n\t} satisfies CustomMessage<T>;\n\tif (options?.deliverAs === \"nextTurn\") {\n\t\tthis._pendingNextTurnMessages.push(appMessage);\n\t} else if (options?.deliverAs === \"interrupt\" && options.triggerTurn) {\n\t\tawait this._enqueueInterruptCustomMessage(appMessage, options);\n\t} else if (this.isStreaming && options?.excludeFromContext === true && options.triggerTurn !== true && options.deliverAs === undefined) {\n\t\tthis._appendCustomMessage(appMessage);\n\t} else if (this.isStreaming) {\n\t\tthis._queueAgentMessage(appMessage, options?.deliverAs === \"followUp\" ? \"followUp\" : \"steer\");\n\t} else if (options?.triggerTurn) {\n\t\tawait this._runAgentPrompt(appMessage);\n\t} else {\n\t\tthis._appendCustomMessage(appMessage);\n\t}\n}\n\n\nexport function _appendCustomMessage<T>(this: AgentSession, message: CustomMessage<T>): void {\n\tthis.agent.state.messages.push(message);\n\tthis.sessionManager.appendCustomMessageEntry(\n\t\tmessage.customType,\n\t\tmessage.content,\n\t\tmessage.display,\n\t\tmessage.details,\n\t\tcustomMessageExcludesContext(message),\n\t);\n\tthis._emit({ type: \"message_start\", message });\n\tthis._emit({ type: \"message_end\", message });\n}\n\n\nexport function _enqueueInterruptCustomMessage<T>(this: AgentSession, message: CustomMessage<T>, options?: SendMessageOptions): Promise<void> {\n\tthis._pendingInterruptDeliveries += 1;\n\t// Establish the hold synchronously when the interrupt is enqueued, not when\n\t// the serialized delivery callback later starts. Callers commonly fire and\n\t// forget sendCustomMessage(), then queue additional steer/follow-up messages\n\t// before the promise chain gets a microtask; those messages must be captured\n\t// in the active interrupt hold instead of pi-agent-core's live queues.\n\tthis._ensureActiveInterruptQueueHold();\n\tconst delivery = this._interruptDeliveryQueue.then(async () => {\n\t\ttry {\n\t\t\tawait this._sendInterruptCustomMessageNow(message, options);\n\t\t} finally {\n\t\t\tthis._pendingInterruptDeliveries -= 1;\n\t\t\tif (this._pendingInterruptDeliveries === 0) {\n\t\t\t\tthis._restoreAndClearActiveInterruptQueueHold();\n\t\t\t}\n\t\t}\n\t});\n\tthis._interruptDeliveryQueue = delivery.catch(() => undefined);\n\treturn delivery;\n}\n\n\nexport async function _sendInterruptCustomMessageNow<T>(this: AgentSession, \n\tmessage: CustomMessage<T>,\n\toptions?: SendMessageOptions,\n): Promise<void> {\n\tthis.abortRetry();\n\tthis._ensureActiveInterruptQueueHold();\n\tif (this.isStreaming) {\n\t\tconst previousAbortMessage = this._activeInterruptAbortMessage;\n\t\tthis._activeInterruptAbortMessage = normalizeInterruptAbortMessage(options?.interruptAbortMessage);\n\t\ttry {\n\t\t\tthis.agent.abort();\n\t\t\tawait this.agent.waitForIdle();\n\t\t\tawait this._agentEventQueue;\n\t\t} finally {\n\t\t\tthis._activeInterruptAbortMessage = previousAbortMessage;\n\t\t}\n\t}\n\tawait this.agent.prompt(message);\n}\n\n\nexport function _ensureActiveInterruptQueueHold(this: AgentSession): InterruptQueueHold {\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\treturn this._activeInterruptQueueHold;\n\t}\n\tconst drained = this._drainQueuedAgentMessages();\n\tthis._activeInterruptQueueHold = {\n\t\tsteering: [...drained.steering],\n\t\tfollowUp: [...drained.followUp],\n\t};\n\treturn this._activeInterruptQueueHold;\n}\n\n\nexport function _restoreAndClearActiveInterruptQueueHold(this: AgentSession): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold === undefined) {\n\t\treturn;\n\t}\n\tconst currentCoreQueues = this._drainQueuedAgentMessages();\n\tthis._restoreQueuedAgentMessages({\n\t\tsteering: [...hold.steering, ...currentCoreQueues.steering],\n\t\tfollowUp: [...hold.followUp, ...currentCoreQueues.followUp],\n\t});\n\tthis._activeInterruptQueueHold = undefined;\n}\n\n\nexport function _queueAgentMessage(this: AgentSession, message: AgentMessage, delivery: \"steer\" | \"followUp\"): void {\n\tconst hold = this._activeInterruptQueueHold;\n\tif (hold !== undefined) {\n\t\tif (delivery === \"followUp\") {\n\t\t\thold.followUp.push(message);\n\t\t} else {\n\t\t\thold.steering.push(message);\n\t\t}\n\t\treturn;\n\t}\n\tif (delivery === \"followUp\") {\n\t\tthis.agent.followUp(message);\n\t} else {\n\t\tthis.agent.steer(message);\n\t}\n}\n\n\nexport function _drainQueuedAgentMessages(this: AgentSession): DrainedAgentQueues {\n\t// pi-agent-core exposes public clear methods but no public drain/restore pair.\n\t// Interrupts need to prevent the aborting run from consuming queued steer/follow-up\n\t// messages while still preserving those queues for a later turn.\n\tconst agentWithQueues = this.agent as unknown as AgentQueueAccess;\n\treturn {\n\t\tsteering: drainAgentMessageQueue(agentWithQueues.steeringQueue),\n\t\tfollowUp: drainAgentMessageQueue(agentWithQueues.followUpQueue),\n\t};\n}\n\n\nexport function _restoreQueuedAgentMessages(this: AgentSession, queues: DrainedAgentQueues): void {\n\tfor (const message of queues.steering) {\n\t\tthis.agent.steer(message);\n\t}\n\tfor (const message of queues.followUp) {\n\t\tthis.agent.followUp(message);\n\t}\n}\n\n/**\n * Send a user message to the agent. Always triggers a turn.\n * When the agent is streaming, use deliverAs to specify how to queue the message.\n *\n * @param content User message content (string or content array)\n * @param options.deliverAs Delivery mode when streaming: \"steer\" or \"followUp\"\n */\n\nexport function clearQueue(this: AgentSession): { steering: string[]; followUp: string[] } {\n\tconst steering = [...this._steeringMessages];\n\tconst followUp = [...this._followUpMessages];\n\tthis._steeringMessages = [];\n\tthis._followUpMessages = [];\n\tthis.agent.clearAllQueues();\n\tif (this._activeInterruptQueueHold !== undefined) {\n\t\tthis._activeInterruptQueueHold.steering.length = 0;\n\t\tthis._activeInterruptQueueHold.followUp.length = 0;\n\t}\n\tthis._emitQueueUpdate();\n\treturn { steering, followUp };\n}\n\n/** Number of pending messages (includes both steering and follow-up) */\n\nexport function getSteeringMessages(this: AgentSession): readonly string[] {\n\treturn this._steeringMessages;\n}\n\n/** Get pending follow-up messages (read-only) */\n\nexport function getFollowUpMessages(this: AgentSession): readonly string[] {\n\treturn this._followUpMessages;\n}\n\n\nexport async function abort(this: AgentSession): Promise<void> {\n\tthis.abortRetry();\n\tthis.agent.abort();\n\tawait this.agent.waitForIdle();\n}\n\n// =========================================================================\n// Model Management\n// =========================================================================\n\n\nexport function setSteeringMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.steeringMode = mode;\n\tthis.settingsManager.setSteeringMode(mode);\n}\n\n/**\n * Set follow-up message mode.\n * Saves to settings.\n */\n\nexport function setFollowUpMode(this: AgentSession, mode: \"all\" | \"one-at-a-time\"): void {\n\tthis.agent.followUpMode = mode;\n\tthis.settingsManager.setFollowUpMode(mode);\n}\n\n// =========================================================================\n// Compaction\n// =========================================================================\n\n/**\n * Apply validated logical deletions and rebuild active agent context.\n * Retained transcript entries/content blocks stay verbatim.\n */\n\nexport const agentSessionMessageQueueMethods = {\n\t_queueSteer,\n\t_queueFollowUp,\n\t_throwIfExtensionCommand,\n\tsendCustomMessage,\n\t_appendCustomMessage,\n\t_enqueueInterruptCustomMessage,\n\t_sendInterruptCustomMessageNow,\n\t_ensureActiveInterruptQueueHold,\n\t_restoreAndClearActiveInterruptQueueHold,\n\t_queueAgentMessage,\n\t_drainQueuedAgentMessages,\n\t_restoreQueuedAgentMessages,\n\tclearQueue,\n\tgetSteeringMessages,\n\tgetFollowUpMessages,\n\tabort,\n\tsetSteeringMode,\n\tsetFollowUpMode,\n};\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from "@earendil-works/pi-agent-core";
2
- import type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from "@earendil-works/pi-ai";
2
+ import type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from "@earendil-works/pi-ai/compat";
3
3
  import type { BashResult } from "./bash-executor.ts";
4
4
  import type { ContextCompactionParameters, ContextCompactionResult } from "./compaction/index.ts";
5
5
  import type { ContextUsage, ExtensionCommandContextActions, ExtensionErrorListener, ExtensionMode, ExtensionRunner, ExtensionUIContext, OrchestrationContext, ReplacedSessionContext, SessionStartEvent, ToolDefinition, ToolInfo } from "./extensions/index.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9G,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CA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@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
1
+ {"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAC3H,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AACrH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,2BAA2B,EAC3B,uBAAuB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EACX,YAAY,EACZ,8BAA8B,EAC9B,sBAAsB,EACtB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,oBAAoB,EACpB,sBAAsB,EACtB,iBAAiB,EACjB,cAAc,EACd,QAAQ,EACR,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,oBAAoB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAA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C/B,oBAAoB,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,mBAAmB,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,eAAe,CAAA;KAAE,CAAC;IACpD,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAC;IACnC,iBAAiB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAChC,kBAAkB,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC/C,kBAAkB,EAAE,iBAAiB,CAAC;IACtC,qBAAqB,CAAC,EAAE,oBAAoB,CAAC;IAC7C,mBAAmB,CAAC,EAAE,kBAAkB,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,+BAA+B,CAAC,EAAE,8BAA8B,CAAC;IACjE,yBAAyB,CAAC,EAAE,MAAM,IAAI,CAAC;IACvC,uBAAuB,CAAC,EAAE,sBAAsB,CAAC;IACjD,2BAA2B,CAAC,EAAE,MAAM,IAAI,CAAC;IACzC,cAAc,EAAE,aAAa,CAAC;IAC9B,aAAa,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IACtC,gBAAgB,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IACnD,mBAAmB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7C,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,wBAAwB,CAAC;IACnD,qBAAqB,EAAE,gBAAgB,GAAG,SAAS,CAAC;CACpD","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
1
+ {"version":3,"file":"agent-session-methods.js","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"","sourcesContent":["import type { Agent, AgentEvent, AgentMessage, AgentState, AgentTool, ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, AssistantMessage, ImageContent, Message, Model, TextContent } from \"@earendil-works/pi-ai/compat\";\nimport type { BashResult } from \"./bash-executor.ts\";\nimport type {\n\tContextCompactionParameters,\n\tContextCompactionResult,\n} from \"./compaction/index.ts\";\nimport type {\n\tContextUsage,\n\tExtensionCommandContextActions,\n\tExtensionErrorListener,\n\tExtensionMode,\n\tExtensionRunner,\n\tExtensionUIContext,\n\tOrchestrationContext,\n\tReplacedSessionContext,\n\tSessionStartEvent,\n\tToolDefinition,\n\tToolInfo,\n} from \"./extensions/index.ts\";\nimport type { BashExecutionMessage, CustomMessage } from \"./messages.ts\";\nimport type { ModelRegistry } from \"./model-registry.ts\";\nimport type { PromptTemplate } from \"./prompt-templates.ts\";\nimport type { ResourceLoader } from \"./resource-loader.ts\";\nimport type { BranchSummaryEntry, SessionManager } from \"./session-manager.ts\";\nimport type { SettingsManager } from \"./settings-manager.ts\";\nimport type { BuildSystemPromptOptions } from \"./system-prompt.ts\";\nimport type { BashOperations } from \"./tools/bash.ts\";\nimport type {\n\tAgentSessionEvent,\n\tAgentSessionEventListener,\n\tContextWindowReplayRequest,\n\tContextWindowReplaySource,\n\tDrainedAgentQueues,\n\tExtensionBindings,\n\tInterruptQueueHold,\n\tModelCycleResult,\n\tPromptOptions,\n\tSessionStats,\n\tToolDefinitionEntry,\n} from \"./agent-session-types.ts\";\nimport type { SendMessageOptions } from \"./extensions/index.ts\";\n\nexport interface ContextCompactionApplyOptions {\n\tresolvePlannerAuth: () => Promise<{ apiKey: string; headers?: Record<string, string> } | undefined>;\n\tabortController: AbortController;\n\tbackupLabel: string;\n\tcompression_ratio?: number;\n\tpreserve_recent?: number;\n\tquery?: string;\n\treason: \"manual\" | \"threshold\" | \"overflow\";\n}\n\nexport interface ExtensionResourcePathEntry {\n\tpath: string;\n\textensionPath: string;\n}\n\nexport interface ExtensionResourcePathResult {\n\tpath: string;\n\tmetadata: { source: string; scope: \"temporary\"; origin: \"top-level\"; baseDir?: string };\n}\n\nexport interface RuntimeBuildOptions {\n\tactiveToolNames?: string[];\n\tflagValues?: Map<string, boolean | string>;\n\tincludeAllExtensionTools?: boolean;\n}\n\nexport interface ContextWindowReplayResult {\n\tmodel: Model<Api>;\n\tcontextWindow: number;\n\twouldWarn: boolean;\n}\n\nexport interface AgentSessionMethodSurface {\n\treadonly orchestrationContext: import(\"./extensions/index.ts\").OrchestrationContext | undefined;\n\treadonly modelRegistry: ModelRegistry;\n\treadonly state: AgentState;\n\treadonly model: Model<Api> | undefined;\n\treadonly thinkingLevel: ThinkingLevel;\n\treadonly isStreaming: boolean;\n\treadonly systemPrompt: string;\n\treadonly retryAttempt: number;\n\treadonly isCompacting: boolean;\n\treadonly messages: AgentMessage[];\n\treadonly steeringMode: \"all\" | \"one-at-a-time\";\n\treadonly followUpMode: \"all\" | \"one-at-a-time\";\n\treadonly sessionFile: string | undefined;\n\treadonly sessionId: string;\n\treadonly sessionName: string | undefined;\n\treadonly scopedModels: ReadonlyArray<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\treadonly promptTemplates: ReadonlyArray<PromptTemplate>;\n\treadonly pendingMessageCount: number;\n\treadonly resourceLoader: ResourceLoader;\n\treadonly autoCompactionEnabled: boolean;\n\treadonly isRetrying: boolean;\n\treadonly autoRetryEnabled: boolean;\n\treadonly isBashRunning: boolean;\n\treadonly hasPendingBashMessages: boolean;\n\treadonly extensionRunner: ExtensionRunner;\n\n\t_handleAgentEvent(event: AgentEvent): void;\n\t_getRequiredRequestAuth(model: Model<Api>): Promise<{ apiKey: string; headers?: Record<string, string> }>;\n\t_installAgentToolHooks(): void;\n\t_emit(event: AgentSessionEvent): void;\n\t_emitQueueUpdate(): void;\n\t_createRetryPromiseForAgentEnd(event: AgentEvent): void;\n\t_findLastAssistantInMessages(messages: AgentMessage[]): AssistantMessage | undefined;\n\t_processAgentEvent(event: AgentEvent): Promise<void>;\n\t_applyInterruptAbortMessage(event: AgentEvent): void;\n\t_applyProviderErrorGuidance(event: AgentEvent): void;\n\t_resolveRetry(): void;\n\t_getUserMessageText(message: Message): string;\n\t_findLastAssistantMessage(): AssistantMessage | undefined;\n\t_replaceMessageInPlace(target: AgentMessage, replacement: AgentMessage): void;\n\t_emitExtensionEvent(event: AgentEvent): Promise<void>;\n\tsubscribe(listener: AgentSessionEventListener): () => void;\n\t_disconnectFromAgent(): void;\n\t_reconnectToAgent(): void;\n\tdispose(): void;\n\n\tgetActiveToolNames(): string[];\n\tgetAllTools(): ToolInfo[];\n\tgetToolDefinition(name: string): ToolDefinition | undefined;\n\tsetActiveToolsByName(toolNames: string[]): void;\n\tsetScopedModels(scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>): void;\n\t_normalizePromptSnippet(text: string | undefined): string | undefined;\n\t_normalizePromptGuidelines(guidelines: string[] | undefined): string[];\n\t_rebuildSystemPrompt(toolNames: string[]): string;\n\t_refreshBaseSystemPromptFromActiveTools(): void;\n\n\tprompt(text: string, options?: PromptOptions): Promise<void>;\n\t_runAgentPrompt(messages: AgentMessage | AgentMessage[]): Promise<void>;\n\t_continueQueuedAgentMessages(): Promise<void>;\n\t_tryExecuteBuiltinSlashCommand(text: string): Promise<boolean>;\n\t_tryExecuteExtensionCommand(text: string): Promise<boolean>;\n\t_expandSkillCommand(text: string): string;\n\tsteer(text: string, images?: ImageContent[]): Promise<void>;\n\tfollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\tsendUserMessage(\n\t\tcontent: string | (TextContent | ImageContent)[],\n\t\toptions?: { deliverAs?: \"steer\" | \"followUp\" },\n\t): Promise<void>;\n\n\t_queueSteer(text: string, images?: ImageContent[]): Promise<void>;\n\t_queueFollowUp(text: string, images?: ImageContent[]): Promise<void>;\n\t_throwIfExtensionCommand(text: string): void;\n\tsendCustomMessage<T = unknown>(\n\t\tmessage: Pick<CustomMessage<T>, \"customType\" | \"content\" | \"display\" | \"details\">,\n\t\toptions?: SendMessageOptions,\n\t): Promise<void>;\n\t_appendCustomMessage<T>(message: CustomMessage<T>): void;\n\t_enqueueInterruptCustomMessage<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_sendInterruptCustomMessageNow<T>(message: CustomMessage<T>, options?: SendMessageOptions): Promise<void>;\n\t_ensureActiveInterruptQueueHold(): InterruptQueueHold;\n\t_restoreAndClearActiveInterruptQueueHold(): void;\n\t_queueAgentMessage(message: AgentMessage, delivery: \"steer\" | \"followUp\"): void;\n\t_drainQueuedAgentMessages(): DrainedAgentQueues;\n\t_restoreQueuedAgentMessages(queues: DrainedAgentQueues): void;\n\tclearQueue(): { steering: string[]; followUp: string[] };\n\tgetSteeringMessages(): readonly string[];\n\tgetFollowUpMessages(): readonly string[];\n\tabort(): Promise<void>;\n\tsetSteeringMode(mode: \"all\" | \"one-at-a-time\"): void;\n\tsetFollowUpMode(mode: \"all\" | \"one-at-a-time\"): void;\n\n\t_emitModelChanged(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): void;\n\t_emitModelSelect(nextModel: Model<Api>, previousModel: Model<Api> | undefined, source: \"set\" | \"cycle\" | \"restore\"): Promise<void>;\n\tsetModel(model: Model<Api>): Promise<void>;\n\tcycleModel(direction?: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleScopedModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\t_cycleAvailableModel(direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined>;\n\tsetThinkingLevel(level: ThinkingLevel): void;\n\tcycleThinkingLevel(): ThinkingLevel | undefined;\n\tgetAvailableThinkingLevels(): ThinkingLevel[];\n\tsupportsThinking(): boolean;\n\t_getThinkingLevelForModelSwitch(explicitLevel?: ThinkingLevel): ThinkingLevel;\n\t_clampThinkingLevel(level: ThinkingLevel, availableLevels: ThinkingLevel[]): ThinkingLevel;\n\tgetAvailableContextWindows(): number[];\n\tsupportsContextWindowSelection(): boolean;\n\tsetContextWindow(contextWindow: number, options?: { persistDefault?: boolean }): void;\n\t_withContextWindowForModelSwitch(model: Model<Api>): Model<Api>;\n\t_shouldCarryCurrentContextWindowForModelSwitch(currentModel: Model<Api>, settingsDefaultContextWindow: number | undefined): boolean;\n\t_getSettingsContextWindowRequestForModel(model: Model<Api>): ContextWindowReplayRequest | undefined;\n\t_getContextWindowReplayForModel(model: Model<Api>, requestedContextWindow: number | undefined, source: ContextWindowReplaySource | undefined): ContextWindowReplayResult;\n\t_getDefaultContextWindowReplayForModel(model: Model<Api>, wouldWarn: boolean): ContextWindowReplayResult;\n\t_getResumeContextWindowReplayForModel(model: Model<Api>): ContextWindowReplayResult;\n\t_applyContextWindowReplay(contextWindow: number | undefined): void;\n\t_appendContextWindowChangeIfChanged(previousModel: Model<Api> | undefined, nextModel: Model<Api>): void;\n\n\t_applyContextVerbatimCompaction(options: ContextCompactionApplyOptions): Promise<ContextCompactionResult | undefined>;\n\tcompact(options?: Partial<ContextCompactionParameters>): Promise<ContextCompactionResult>;\n\tcontextCompact(): Promise<ContextCompactionResult>;\n\tabortCompaction(): void;\n\tabortBranchSummary(): void;\n\t_checkCompaction(assistantMessage: AssistantMessage, skipAbortedCheck?: boolean): Promise<void>;\n\t_isCopilotServerCapBelowSelectedContextWindow(assistantMessage: AssistantMessage): boolean;\n\t_dropTrailingOverflowAssistantErrorIfPresent(): void;\n\t_schedulePostAutoCompactionContinuationProbe(reason: \"overflow\" | \"threshold\", willRetry: boolean): void;\n\t_resumeAfterAutoCompaction(): void;\n\t_runAutoCompaction(reason: \"overflow\" | \"threshold\", willRetry: boolean): Promise<void>;\n\tsetAutoCompactionEnabled(enabled: boolean): void;\n\n\tbindExtensions(bindings: ExtensionBindings): Promise<void>;\n\textendResourcesFromExtensions(reason: \"startup\" | \"reload\"): Promise<void>;\n\tbuildExtensionResourcePaths(entries: ExtensionResourcePathEntry[]): ExtensionResourcePathResult[];\n\tgetExtensionSourceLabel(extensionPath: string): string;\n\t_applyExtensionBindings(runner: ExtensionRunner): void;\n\t_refreshCurrentModelFromRegistry(): void;\n\t_bindExtensionCore(runner: ExtensionRunner): void;\n\t_refreshToolRegistry(options?: { activeToolNames?: string[]; includeAllExtensionTools?: boolean }): void;\n\t_buildRuntime(options: RuntimeBuildOptions): void;\n\treload(): Promise<void>;\n\n\t_isRetryableError(message: AssistantMessage): boolean;\n\t_normalizePersistedGeminiToolArgs(message: AssistantMessage): void;\n\t_isEmptyCompletion(message: AssistantMessage): boolean;\n\t_handleRetryableError(message: AssistantMessage): Promise<boolean>;\n\tabortRetry(): void;\n\twaitForRetry(): Promise<void>;\n\tsetAutoRetryEnabled(enabled: boolean): void;\n\n\texecuteBash(command: string, onChunk?: (chunk: string) => void, options?: { excludeFromContext?: boolean; operations?: BashOperations }): Promise<BashResult>;\n\trecordBashResult(command: string, result: BashResult, options?: { excludeFromContext?: boolean }): void;\n\tabortBash(): void;\n\t_flushPendingBashMessages(): void;\n\n\tsetSessionName(name: string): void;\n\tnavigateTree(targetId: string, options?: { summarize?: boolean; customInstructions?: string; replaceInstructions?: boolean; label?: string }): Promise<{ editorText?: string; cancelled: boolean; aborted?: boolean; summaryEntry?: BranchSummaryEntry }>;\n\tgetUserMessagesForForking(): Array<{ entryId: string; text: string }>;\n\t_extractUserMessageText(content: string | Array<{ type: string; text?: string }>): string;\n\n\tgetSessionStats(): SessionStats;\n\tgetContextUsage(): ContextUsage | undefined;\n\texportToHtml(outputPath?: string): Promise<string>;\n\texportToJsonl(outputPath?: string): string;\n\tgetLastAssistantText(): string | undefined;\n\tcreateReplacedSessionContext(): ReplacedSessionContext;\n\thasExtensionHandlers(eventType: string): boolean;\n}\n\nexport interface AgentSessionPublicSurface extends Pick<AgentSessionMethodSurface,\n\t| \"orchestrationContext\"\n\t| \"modelRegistry\"\n\t| \"state\"\n\t| \"model\"\n\t| \"thinkingLevel\"\n\t| \"isStreaming\"\n\t| \"systemPrompt\"\n\t| \"retryAttempt\"\n\t| \"isCompacting\"\n\t| \"messages\"\n\t| \"steeringMode\"\n\t| \"followUpMode\"\n\t| \"sessionFile\"\n\t| \"sessionId\"\n\t| \"sessionName\"\n\t| \"scopedModels\"\n\t| \"promptTemplates\"\n\t| \"pendingMessageCount\"\n\t| \"resourceLoader\"\n\t| \"autoCompactionEnabled\"\n\t| \"isRetrying\"\n\t| \"autoRetryEnabled\"\n\t| \"isBashRunning\"\n\t| \"hasPendingBashMessages\"\n\t| \"extensionRunner\"\n\t| \"subscribe\"\n\t| \"dispose\"\n\t| \"getActiveToolNames\"\n\t| \"getAllTools\"\n\t| \"getToolDefinition\"\n\t| \"setActiveToolsByName\"\n\t| \"setScopedModels\"\n\t| \"prompt\"\n\t| \"steer\"\n\t| \"followUp\"\n\t| \"sendCustomMessage\"\n\t| \"sendUserMessage\"\n\t| \"clearQueue\"\n\t| \"getSteeringMessages\"\n\t| \"getFollowUpMessages\"\n\t| \"abort\"\n\t| \"setModel\"\n\t| \"cycleModel\"\n\t| \"setThinkingLevel\"\n\t| \"cycleThinkingLevel\"\n\t| \"getAvailableThinkingLevels\"\n\t| \"supportsThinking\"\n\t| \"getAvailableContextWindows\"\n\t| \"supportsContextWindowSelection\"\n\t| \"setContextWindow\"\n\t| \"setSteeringMode\"\n\t| \"setFollowUpMode\"\n\t| \"compact\"\n\t| \"contextCompact\"\n\t| \"abortCompaction\"\n\t| \"abortBranchSummary\"\n\t| \"setAutoCompactionEnabled\"\n\t| \"bindExtensions\"\n\t| \"reload\"\n\t| \"abortRetry\"\n\t| \"setAutoRetryEnabled\"\n\t| \"executeBash\"\n\t| \"recordBashResult\"\n\t| \"abortBash\"\n\t| \"setSessionName\"\n\t| \"navigateTree\"\n\t| \"getUserMessagesForForking\"\n\t| \"getSessionStats\"\n\t| \"getContextUsage\"\n\t| \"exportToHtml\"\n\t| \"exportToJsonl\"\n\t| \"getLastAssistantText\"\n\t| \"createReplacedSessionContext\"\n\t| \"hasExtensionHandlers\"\n> {\n\treadonly agent: Agent;\n\treadonly sessionManager: SessionManager;\n\treadonly settingsManager: SettingsManager;\n}\n\nexport interface AgentSessionInternalSurface extends AgentSessionMethodSurface, AgentSessionPublicSurface {\n\t_scopedModels: Array<{ model: Model<Api>; thinkingLevel?: ThinkingLevel }>;\n\t_unsubscribeAgent?: () => void;\n\t_eventListeners: AgentSessionEventListener[];\n\t_agentEventQueue: Promise<void>;\n\t_steeringMessages: string[];\n\t_followUpMessages: string[];\n\t_interruptDeliveryQueue: Promise<void>;\n\t_pendingInterruptDeliveries: number;\n\t_activeInterruptQueueHold: InterruptQueueHold | undefined;\n\t_activeInterruptAbortMessage: string | undefined;\n\t_pendingNextTurnMessages: CustomMessage[];\n\t_compactionAbortController: AbortController | undefined;\n\t_autoCompactionAbortController: AbortController | undefined;\n\t_overflowRecoveryAttempted: boolean;\n\t_branchSummaryAbortController: AbortController | undefined;\n\t_retryAbortController: AbortController | undefined;\n\t_retryAttempt: number;\n\t_retryPromise: Promise<void> | undefined;\n\t_retryResolve: (() => void) | undefined;\n\t_bashAbortController: AbortController | undefined;\n\t_pendingBashMessages: BashExecutionMessage[];\n\t_extensionRunner: ExtensionRunner;\n\t_turnIndex: number;\n\t_resourceLoader: ResourceLoader;\n\t_customTools: ToolDefinition[];\n\t_baseToolDefinitions: Map<string, ToolDefinition>;\n\t_cwd: string;\n\t_extensionRunnerRef?: { current?: ExtensionRunner };\n\t_initialActiveToolNames?: string[];\n\t_allowedToolNames?: Set<string>;\n\t_excludedToolNames?: Set<string>;\n\t_baseToolsOverride?: Record<string, AgentTool>;\n\t_sessionStartEvent: SessionStartEvent;\n\t_orchestrationContext?: OrchestrationContext;\n\t_extensionUIContext?: ExtensionUIContext;\n\t_extensionMode: ExtensionMode;\n\t_extensionCommandContextActions?: ExtensionCommandContextActions;\n\t_extensionShutdownHandler?: () => void;\n\t_extensionErrorListener?: ExtensionErrorListener;\n\t_extensionErrorUnsubscriber?: () => void;\n\t_modelRegistry: ModelRegistry;\n\t_toolRegistry: Map<string, AgentTool>;\n\t_toolDefinitions: Map<string, ToolDefinitionEntry>;\n\t_toolPromptSnippets: Map<string, string>;\n\t_toolPromptGuidelines: Map<string, string[]>;\n\t_baseSystemPrompt: string;\n\t_baseSystemPromptOptions: BuildSystemPromptOptions;\n\t_lastAssistantMessage: AssistantMessage | undefined;\n}\n\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { ThinkingLevel } from "@earendil-works/pi-agent-core";
2
- import type { Api, Model } from "@earendil-works/pi-ai";
2
+ import type { Api, Model } from "@earendil-works/pi-ai/compat";
3
3
  import type { AgentSessionInternalSurface as AgentSession } from "./agent-session-methods.ts";
4
4
  import { type ContextWindowReplayRequest, type ContextWindowReplaySource, type ModelCycleResult } from "./agent-session-types.ts";
5
5
  export declare function _getRequiredRequestAuth(this: AgentSession, model: Model<Api>): Promise<{
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-models.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EA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AK,CAAC,GAAG,CAAC,GAAG,SAAS,EACrC,SAAS,EAAE,KAAK,CAAC,GAAG,CAAC,GACnB,IAAI,CAON;AAMD;;;GAGG;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;CAyBrC,CAAC","sourcesContent":["import type { ThinkingLevel } from \"@earendil-works/pi-agent-core\";\nimport type { Api, Model } from \"@earendil-works/pi-ai\";\nimport { clampThinkingLevel, getSupportedThinkingLevels, modelsAreEqual } from \"@earendil-works/pi-ai\";\nimport { getModelDefaultContextWindow, getSupportedContextWindows, selectContextWindow } from \"./context-window.ts\";\nimport { formatNoApiKeyFoundMessage } from \"./auth-guidance.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS, THINKING_LEVELS, type ContextWindowReplayRequest, type ContextWindowReplaySource, type ModelCycleResult } from \"./agent-session-types.ts\";\n\nexport async function _getRequiredRequestAuth(this: AgentSession, model: Model<Api>): Promise<{\n\tapiKey: string;\n\theaders?: Record<string, string>;\n}> {\n\tconst result = await this._modelRegistry.getApiKeyAndHeaders(model);\n\tif (!result.ok) {\n\t\tif (result.error.startsWith(\"No API key found\")) {\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t}\n\t\tthrow new Error(result.error);\n\t}\n\tif (result.apiKey) {\n\t\treturn { apiKey: result.apiKey, headers: result.headers };\n\t}\n\n\tconst isOAuth = this._modelRegistry.isUsingOAuth(model);\n\tif (isOAuth) {\n\t\tthrow new Error(\n\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t`Run '/login ${model.provider}' to re-authenticate.`,\n\t\t);\n\t}\n\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n}\n\n/**\n * Install tool hooks once on the Agent instance.\n *\n * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the\n * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt\n * registered tool execution to the extension context. Tool call and tool result interception now\n * happens here instead of in wrappers.\n */\n\nexport function _emitModelChanged(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\",\n): void {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tthis._emit({\n\t\ttype: \"model_changed\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n\nexport async function _emitModelSelect(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\",\n): Promise<void> {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tawait this._extensionRunner.emit({\n\t\ttype: \"model_select\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n/**\n * Set model directly.\n * Validates that auth is configured, saves to session and settings.\n * @throws Error if no auth is configured for the model\n */\n\nexport async function setModel(this: AgentSession, model: Model<Api>): Promise<void> {\n\tif (!this._modelRegistry.hasConfiguredAuth(model)) {\n\t\tthrow new Error(`No API key for ${model.provider}/${model.id}`);\n\t}\n\n\tconst previousModel = this.model;\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tconst nextModel = this._withContextWindowForModelSwitch(model);\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(previousModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, previousModel, \"set\");\n\tawait this._emitModelSelect(nextModel, previousModel, \"set\");\n}\n\n/**\n * Cycle to next/previous model.\n * Uses scoped models (from --models flag) if available, otherwise all available models.\n * @param direction - \"forward\" (default) or \"backward\"\n * @returns The new model info, or undefined if only one model available\n */\n\nexport async function cycleModel(this: AgentSession, direction: \"forward\" | \"backward\" = \"forward\"): Promise<ModelCycleResult | undefined> {\n\tif (this._scopedModels.length > 0) {\n\t\treturn this._cycleScopedModel(direction);\n\t}\n\treturn this._cycleAvailableModel(direction);\n}\n\n\nexport async function _cycleScopedModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst scopedModels = this._scopedModels.filter((scoped) => this._modelRegistry.hasConfiguredAuth(scoped.model));\n\tif (scopedModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = scopedModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst next = scopedModels[nextIndex];\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch(next.thinkingLevel);\n\tconst nextModel = this._withContextWindowForModelSwitch(next.model);\n\n\t// Apply model\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Apply thinking level.\n\t// - Explicit scoped model thinking level overrides current session level\n\t// - Undefined scoped model thinking level inherits the current session preference\n\t// setThinkingLevel clamps to model capabilities.\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(nextModel, currentModel, \"cycle\");\n\n\treturn { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: true };\n}\n\n\nexport async function _cycleAvailableModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst availableModels = await this._modelRegistry.getAvailable();\n\tif (availableModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = availableModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst selectedModel = this._withContextWindowForModelSwitch(availableModels[nextIndex]);\n\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tthis.agent.state.model = selectedModel;\n\tthis.sessionManager.appendModelChange(selectedModel.provider, selectedModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, selectedModel);\n\tthis.settingsManager.setDefaultModelAndProvider(selectedModel.provider, selectedModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(selectedModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(selectedModel, currentModel, \"cycle\");\n\n\treturn { model: selectedModel, thinkingLevel: this.thinkingLevel, isScoped: false };\n}\n\n// =========================================================================\n// Thinking Level Management\n// =========================================================================\n\n/**\n * Set thinking level.\n * Clamps to model capabilities based on available thinking levels.\n * Saves to session and settings only if the level actually changes.\n */\n\nexport function setThinkingLevel(this: AgentSession, level: ThinkingLevel): void {\n\tconst availableLevels = this.getAvailableThinkingLevels();\n\tconst effectiveLevel = availableLevels.includes(level) ? level : this._clampThinkingLevel(level, availableLevels);\n\n\t// Only persist if actually changing\n\tconst previousLevel = this.agent.state.thinkingLevel;\n\tconst isChanging = effectiveLevel !== previousLevel;\n\n\tthis.agent.state.thinkingLevel = effectiveLevel;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendThinkingLevelChange(effectiveLevel);\n\t\tthis._refreshBaseSystemPromptFromActiveTools();\n\t\tif (this.supportsThinking() || effectiveLevel !== \"off\") {\n\t\t\tthis.settingsManager.setDefaultThinkingLevel(effectiveLevel);\n\t\t}\n\t\tthis._emit({ type: \"thinking_level_changed\", level: effectiveLevel });\n\t\tvoid this._extensionRunner.emit({\n\t\t\ttype: \"thinking_level_select\",\n\t\t\tlevel: effectiveLevel,\n\t\t\tpreviousLevel,\n\t\t});\n\t}\n}\n\n/**\n * Cycle to next thinking level.\n * @returns New level, or undefined if model doesn't support thinking\n */\n\nexport function cycleThinkingLevel(this: AgentSession): ThinkingLevel | undefined {\n\tif (!this.supportsThinking()) return undefined;\n\n\tconst levels = this.getAvailableThinkingLevels();\n\tconst currentIndex = levels.indexOf(this.thinkingLevel);\n\tconst nextIndex = (currentIndex + 1) % levels.length;\n\tconst nextLevel = levels[nextIndex];\n\n\tthis.setThinkingLevel(nextLevel);\n\treturn nextLevel;\n}\n\n/**\n * Get available thinking levels for current model.\n * The provider will clamp to what the specific model supports internally.\n */\n\nexport function getAvailableThinkingLevels(this: AgentSession): ThinkingLevel[] {\n\tif (!this.model) return THINKING_LEVELS;\n\treturn getSupportedThinkingLevels(this.model) as ThinkingLevel[];\n}\n\n/**\n * Check if current model supports thinking/reasoning.\n */\n\nexport function supportsThinking(this: AgentSession): boolean {\n\treturn !!this.model?.reasoning;\n}\n\n\nexport function _getThinkingLevelForModelSwitch(this: AgentSession, explicitLevel?: ThinkingLevel): ThinkingLevel {\n\tif (explicitLevel !== undefined) {\n\t\treturn explicitLevel;\n\t}\n\tif (!this.supportsThinking()) {\n\t\treturn this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;\n\t}\n\treturn this.thinkingLevel;\n}\n\n\nexport function _clampThinkingLevel(this: AgentSession, level: ThinkingLevel, _availableLevels: ThinkingLevel[]): ThinkingLevel {\n\treturn this.model ? (clampThinkingLevel(this.model, level) as ThinkingLevel) : \"off\";\n}\n\n// =========================================================================\n// Context Window Management\n// =========================================================================\n\n\nexport function getAvailableContextWindows(this: AgentSession): number[] {\n\treturn this.model ? getSupportedContextWindows(this.model) : [];\n}\n\n\nexport function supportsContextWindowSelection(this: AgentSession): boolean {\n\treturn this.getAvailableContextWindows().length > 1;\n}\n\n\nexport function setContextWindow(this: AgentSession, contextWindow: number, options: { persistDefault?: boolean } = {}): void {\n\tif (!this.model) {\n\t\tthrow new Error(\"No model selected\");\n\t}\n\tconst selected = selectContextWindow(this.model, contextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (\"error\" in selected) {\n\t\tthrow new Error(selected.error);\n\t}\n\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst isChanging = previousContextWindow !== selected.contextWindow;\n\tthis.agent.state.model = selected.model;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendContextWindowChange(selected.contextWindow);\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: selected.contextWindow });\n\t}\n\tif (options.persistDefault === true) {\n\t\tthis.settingsManager.setDefaultContextWindowForModel(selected.model.provider, selected.model.id, selected.contextWindow);\n\t}\n}\n\n\nexport function _withContextWindowForModelSwitch(this: AgentSession, model: Model<Api>): Model<Api> {\n\t// A source model's scalar contextWindow can be its natural default (for example a 1m-default\n\t// model). Do not treat that alone as an opt-in to larger windows on a 400k-default target.\n\tconst settingsDefaultContextWindow = this._getSettingsContextWindowRequestForModel(model)?.contextWindow;\n\tconst candidates: number[] = [];\n\tconst targetDefaultContextWindow = getModelDefaultContextWindow(model);\n\tif (model.contextWindow !== targetDefaultContextWindow) {\n\t\t// Preserve an explicit context-window selection already applied to the target model\n\t\t// (for example a caller passing selectContextWindow(target, 1m).model).\n\t\tcandidates.push(model.contextWindow);\n\t}\n\tconst currentModel = this.model;\n\tif (currentModel && this._shouldCarryCurrentContextWindowForModelSwitch(currentModel, settingsDefaultContextWindow)) {\n\t\tcandidates.push(currentModel.contextWindow);\n\t}\n\tif (settingsDefaultContextWindow !== undefined) {\n\t\tcandidates.push(settingsDefaultContextWindow);\n\t}\n\tcandidates.push(targetDefaultContextWindow);\n\n\tfor (const candidate of candidates) {\n\t\tconst selected = selectContextWindow(model, candidate, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) return selected.model;\n\t}\n\treturn model;\n}\n\n\nexport function _shouldCarryCurrentContextWindowForModelSwitch(this: AgentSession, \n\tcurrentModel: Model<Api>,\n\tsettingsDefaultContextWindow: number | undefined,\n): boolean {\n\tif (currentModel.contextWindow !== getModelDefaultContextWindow(currentModel)) {\n\t\treturn true;\n\t}\n\tif (this.sessionManager.getBranch().some((entry) => entry.type === \"context_window_change\")) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tsettingsDefaultContextWindow !== undefined &&\n\t\tcurrentModel.contextWindow === settingsDefaultContextWindow &&\n\t\tgetSupportedContextWindows(currentModel).includes(settingsDefaultContextWindow)\n\t);\n}\n\n\nexport function _getSettingsContextWindowRequestForModel(this: AgentSession, model: Model<Api>): ContextWindowReplayRequest | undefined {\n\tconst modelContextWindow = this.settingsManager.getDefaultContextWindowForModel(model.provider, model.id);\n\tif (modelContextWindow !== undefined) {\n\t\treturn { contextWindow: modelContextWindow, source: \"model-settings\" };\n\t}\n\tconst globalContextWindow = this.settingsManager.getDefaultContextWindow();\n\treturn globalContextWindow === undefined\n\t\t? undefined\n\t\t: { contextWindow: globalContextWindow, source: \"global-settings\" };\n}\n\n\nexport function _getContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\trequestedContextWindow: number | undefined,\n\tsource: ContextWindowReplaySource | undefined,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tif (requestedContextWindow !== undefined) {\n\t\tconst selected = selectContextWindow(model, requestedContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) {\n\t\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn: false };\n\t\t}\n\t\treturn this._getDefaultContextWindowReplayForModel(model, source !== \"global-settings\");\n\t}\n\n\treturn this._getDefaultContextWindowReplayForModel(model, false);\n}\n\n\nexport function _getDefaultContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\twouldWarn: boolean,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst defaultContextWindow = getModelDefaultContextWindow(model);\n\tconst selected = selectContextWindow(model, defaultContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (!(\"error\" in selected)) {\n\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn };\n\t}\n\treturn {\n\t\tmodel: { ...model, contextWindow: defaultContextWindow, defaultContextWindow },\n\t\tcontextWindow: defaultContextWindow,\n\t\twouldWarn,\n\t};\n}\n\n\nexport function _getResumeContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst sessionContext = this.sessionManager.buildSessionContext();\n\tif (sessionContext.contextWindow !== undefined) {\n\t\treturn this._getContextWindowReplayForModel(model, sessionContext.contextWindow, \"session\");\n\t}\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(model);\n\treturn this._getContextWindowReplayForModel(model, settingsContextWindow?.contextWindow, settingsContextWindow?.source);\n}\n\n\nexport function _applyContextWindowReplay(this: AgentSession, contextWindow: number | undefined): void {\n\tif (!this.model) return;\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(this.model);\n\tconst requestedContextWindow = contextWindow ?? settingsContextWindow?.contextWindow;\n\tconst source: ContextWindowReplaySource | undefined = contextWindow !== undefined ? \"session\" : settingsContextWindow?.source;\n\tconst replay = this._getContextWindowReplayForModel(this.model, requestedContextWindow, source);\n\tthis.agent.state.model = replay.model;\n\tif (previousContextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n}\n\n\nexport function _appendContextWindowChangeIfChanged(this: AgentSession, \n\tpreviousModel: Model<Api> | undefined,\n\tnextModel: Model<Api>,\n): void {\n\tconst replay = this._getResumeContextWindowReplayForModel(nextModel);\n\tif (!replay.wouldWarn && nextModel.contextWindow === replay.contextWindow) return;\n\tthis.sessionManager.appendContextWindowChange(nextModel.contextWindow);\n\tif (previousModel?.contextWindow !== nextModel.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: nextModel.contextWindow });\n\t}\n}\n\n// =========================================================================\n// Queue Mode Management\n// =========================================================================\n\n/**\n * Set steering message mode.\n * Saves to settings.\n */\n\nexport const agentSessionModelsMethods = {\n\t_getRequiredRequestAuth,\n\t_emitModelChanged,\n\t_emitModelSelect,\n\tsetModel,\n\tcycleModel,\n\t_cycleScopedModel,\n\t_cycleAvailableModel,\n\tsetThinkingLevel,\n\tcycleThinkingLevel,\n\tgetAvailableThinkingLevels,\n\tsupportsThinking,\n\t_getThinkingLevelForModelSwitch,\n\t_clampThinkingLevel,\n\tgetAvailableContextWindows,\n\tsupportsContextWindowSelection,\n\tsetContextWindow,\n\t_withContextWindowForModelSwitch,\n\t_shouldCarryCurrentContextWindowForModelSwitch,\n\t_getSettingsContextWindowRequestForModel,\n\t_getContextWindowReplayForModel,\n\t_getDefaultContextWindowReplayForModel,\n\t_getResumeContextWindowReplayForModel,\n\t_applyContextWindowReplay,\n\t_appendContextWindowChangeIfChanged,\n};\n"]}
1
+ {"version":3,"file":"agent-session-models.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,8BAA8B,CAAC;AAK/D,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC9F,OAAO,EAA6D,KAAK,0BAA0B,EAAE,KAAK,yBAAyB,EAAE,KAAK,gBAAgB,EAAE,MA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/pi-ai/compat\";\nimport { clampThinkingLevel, getSupportedThinkingLevels, modelsAreEqual } from \"@earendil-works/pi-ai/compat\";\nimport { getModelDefaultContextWindow, getSupportedContextWindows, selectContextWindow } from \"./context-window.ts\";\nimport { formatNoApiKeyFoundMessage } from \"./auth-guidance.ts\";\nimport { DEFAULT_THINKING_LEVEL } from \"./defaults.ts\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport { COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS, THINKING_LEVELS, type ContextWindowReplayRequest, type ContextWindowReplaySource, type ModelCycleResult } from \"./agent-session-types.ts\";\n\nexport async function _getRequiredRequestAuth(this: AgentSession, model: Model<Api>): Promise<{\n\tapiKey: string;\n\theaders?: Record<string, string>;\n}> {\n\tconst result = await this._modelRegistry.getApiKeyAndHeaders(model);\n\tif (!result.ok) {\n\t\tif (result.error.startsWith(\"No API key found\")) {\n\t\t\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n\t\t}\n\t\tthrow new Error(result.error);\n\t}\n\tif (result.apiKey) {\n\t\treturn { apiKey: result.apiKey, headers: result.headers };\n\t}\n\n\tconst isOAuth = this._modelRegistry.isUsingOAuth(model);\n\tif (isOAuth) {\n\t\tthrow new Error(\n\t\t\t`Authentication failed for \"${model.provider}\". ` +\n\t\t\t\t`Credentials may have expired or network is unavailable. ` +\n\t\t\t\t`Run '/login ${model.provider}' to re-authenticate.`,\n\t\t);\n\t}\n\tthrow new Error(formatNoApiKeyFoundMessage(model.provider));\n}\n\n/**\n * Install tool hooks once on the Agent instance.\n *\n * The callbacks read `this._extensionRunner` at execution time, so extension reload swaps in the\n * new runner without reinstalling hooks. Extension-specific tool wrappers are still used to adapt\n * registered tool execution to the extension context. Tool call and tool result interception now\n * happens here instead of in wrappers.\n */\n\nexport function _emitModelChanged(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\",\n): void {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tthis._emit({\n\t\ttype: \"model_changed\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n\nexport async function _emitModelSelect(this: AgentSession, \n\tnextModel: Model<Api>,\n\tpreviousModel: Model<Api> | undefined,\n\tsource: \"set\" | \"cycle\" | \"restore\",\n): Promise<void> {\n\tif (modelsAreEqual(previousModel, nextModel)) return;\n\tawait this._extensionRunner.emit({\n\t\ttype: \"model_select\",\n\t\tmodel: nextModel,\n\t\tpreviousModel,\n\t\tsource,\n\t});\n}\n\n/**\n * Set model directly.\n * Validates that auth is configured, saves to session and settings.\n * @throws Error if no auth is configured for the model\n */\n\nexport async function setModel(this: AgentSession, model: Model<Api>): Promise<void> {\n\tif (!this._modelRegistry.hasConfiguredAuth(model)) {\n\t\tthrow new Error(`No API key for ${model.provider}/${model.id}`);\n\t}\n\n\tconst previousModel = this.model;\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tconst nextModel = this._withContextWindowForModelSwitch(model);\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(previousModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, previousModel, \"set\");\n\tawait this._emitModelSelect(nextModel, previousModel, \"set\");\n}\n\n/**\n * Cycle to next/previous model.\n * Uses scoped models (from --models flag) if available, otherwise all available models.\n * @param direction - \"forward\" (default) or \"backward\"\n * @returns The new model info, or undefined if only one model available\n */\n\nexport async function cycleModel(this: AgentSession, direction: \"forward\" | \"backward\" = \"forward\"): Promise<ModelCycleResult | undefined> {\n\tif (this._scopedModels.length > 0) {\n\t\treturn this._cycleScopedModel(direction);\n\t}\n\treturn this._cycleAvailableModel(direction);\n}\n\n\nexport async function _cycleScopedModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst scopedModels = this._scopedModels.filter((scoped) => this._modelRegistry.hasConfiguredAuth(scoped.model));\n\tif (scopedModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = scopedModels.findIndex((sm) => modelsAreEqual(sm.model, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = scopedModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst next = scopedModels[nextIndex];\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch(next.thinkingLevel);\n\tconst nextModel = this._withContextWindowForModelSwitch(next.model);\n\n\t// Apply model\n\tthis.agent.state.model = nextModel;\n\tthis.sessionManager.appendModelChange(nextModel.provider, nextModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, nextModel);\n\tthis.settingsManager.setDefaultModelAndProvider(nextModel.provider, nextModel.id);\n\n\t// Apply thinking level.\n\t// - Explicit scoped model thinking level overrides current session level\n\t// - Undefined scoped model thinking level inherits the current session preference\n\t// setThinkingLevel clamps to model capabilities.\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(nextModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(nextModel, currentModel, \"cycle\");\n\n\treturn { model: nextModel, thinkingLevel: this.thinkingLevel, isScoped: true };\n}\n\n\nexport async function _cycleAvailableModel(this: AgentSession, direction: \"forward\" | \"backward\"): Promise<ModelCycleResult | undefined> {\n\tconst availableModels = await this._modelRegistry.getAvailable();\n\tif (availableModels.length <= 1) return undefined;\n\n\tconst currentModel = this.model;\n\tlet currentIndex = availableModels.findIndex((m) => modelsAreEqual(m, currentModel));\n\n\tif (currentIndex === -1) currentIndex = 0;\n\tconst len = availableModels.length;\n\tconst nextIndex = direction === \"forward\" ? (currentIndex + 1) % len : (currentIndex - 1 + len) % len;\n\tconst selectedModel = this._withContextWindowForModelSwitch(availableModels[nextIndex]);\n\n\tconst thinkingLevel = this._getThinkingLevelForModelSwitch();\n\tthis.agent.state.model = selectedModel;\n\tthis.sessionManager.appendModelChange(selectedModel.provider, selectedModel.id);\n\tthis._appendContextWindowChangeIfChanged(currentModel, selectedModel);\n\tthis.settingsManager.setDefaultModelAndProvider(selectedModel.provider, selectedModel.id);\n\n\t// Re-clamp thinking level for new model's capabilities\n\tthis.setThinkingLevel(thinkingLevel);\n\tthis._refreshBaseSystemPromptFromActiveTools();\n\n\tthis._emitModelChanged(selectedModel, currentModel, \"cycle\");\n\tawait this._emitModelSelect(selectedModel, currentModel, \"cycle\");\n\n\treturn { model: selectedModel, thinkingLevel: this.thinkingLevel, isScoped: false };\n}\n\n// =========================================================================\n// Thinking Level Management\n// =========================================================================\n\n/**\n * Set thinking level.\n * Clamps to model capabilities based on available thinking levels.\n * Saves to session and settings only if the level actually changes.\n */\n\nexport function setThinkingLevel(this: AgentSession, level: ThinkingLevel): void {\n\tconst availableLevels = this.getAvailableThinkingLevels();\n\tconst effectiveLevel = availableLevels.includes(level) ? level : this._clampThinkingLevel(level, availableLevels);\n\n\t// Only persist if actually changing\n\tconst previousLevel = this.agent.state.thinkingLevel;\n\tconst isChanging = effectiveLevel !== previousLevel;\n\n\tthis.agent.state.thinkingLevel = effectiveLevel;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendThinkingLevelChange(effectiveLevel);\n\t\tthis._refreshBaseSystemPromptFromActiveTools();\n\t\tif (this.supportsThinking() || effectiveLevel !== \"off\") {\n\t\t\tthis.settingsManager.setDefaultThinkingLevel(effectiveLevel);\n\t\t}\n\t\tthis._emit({ type: \"thinking_level_changed\", level: effectiveLevel });\n\t\tvoid this._extensionRunner.emit({\n\t\t\ttype: \"thinking_level_select\",\n\t\t\tlevel: effectiveLevel,\n\t\t\tpreviousLevel,\n\t\t});\n\t}\n}\n\n/**\n * Cycle to next thinking level.\n * @returns New level, or undefined if model doesn't support thinking\n */\n\nexport function cycleThinkingLevel(this: AgentSession): ThinkingLevel | undefined {\n\tif (!this.supportsThinking()) return undefined;\n\n\tconst levels = this.getAvailableThinkingLevels();\n\tconst currentIndex = levels.indexOf(this.thinkingLevel);\n\tconst nextIndex = (currentIndex + 1) % levels.length;\n\tconst nextLevel = levels[nextIndex];\n\n\tthis.setThinkingLevel(nextLevel);\n\treturn nextLevel;\n}\n\n/**\n * Get available thinking levels for current model.\n * The provider will clamp to what the specific model supports internally.\n */\n\nexport function getAvailableThinkingLevels(this: AgentSession): ThinkingLevel[] {\n\tif (!this.model) return THINKING_LEVELS;\n\treturn getSupportedThinkingLevels(this.model) as ThinkingLevel[];\n}\n\n/**\n * Check if current model supports thinking/reasoning.\n */\n\nexport function supportsThinking(this: AgentSession): boolean {\n\treturn !!this.model?.reasoning;\n}\n\n\nexport function _getThinkingLevelForModelSwitch(this: AgentSession, explicitLevel?: ThinkingLevel): ThinkingLevel {\n\tif (explicitLevel !== undefined) {\n\t\treturn explicitLevel;\n\t}\n\tif (!this.supportsThinking()) {\n\t\treturn this.settingsManager.getDefaultThinkingLevel() ?? DEFAULT_THINKING_LEVEL;\n\t}\n\treturn this.thinkingLevel;\n}\n\n\nexport function _clampThinkingLevel(this: AgentSession, level: ThinkingLevel, _availableLevels: ThinkingLevel[]): ThinkingLevel {\n\treturn this.model ? (clampThinkingLevel(this.model, level) as ThinkingLevel) : \"off\";\n}\n\n// =========================================================================\n// Context Window Management\n// =========================================================================\n\n\nexport function getAvailableContextWindows(this: AgentSession): number[] {\n\treturn this.model ? getSupportedContextWindows(this.model) : [];\n}\n\n\nexport function supportsContextWindowSelection(this: AgentSession): boolean {\n\treturn this.getAvailableContextWindows().length > 1;\n}\n\n\nexport function setContextWindow(this: AgentSession, contextWindow: number, options: { persistDefault?: boolean } = {}): void {\n\tif (!this.model) {\n\t\tthrow new Error(\"No model selected\");\n\t}\n\tconst selected = selectContextWindow(this.model, contextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (\"error\" in selected) {\n\t\tthrow new Error(selected.error);\n\t}\n\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst isChanging = previousContextWindow !== selected.contextWindow;\n\tthis.agent.state.model = selected.model;\n\n\tif (isChanging) {\n\t\tthis.sessionManager.appendContextWindowChange(selected.contextWindow);\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: selected.contextWindow });\n\t}\n\tif (options.persistDefault === true) {\n\t\tthis.settingsManager.setDefaultContextWindowForModel(selected.model.provider, selected.model.id, selected.contextWindow);\n\t}\n}\n\n\nexport function _withContextWindowForModelSwitch(this: AgentSession, model: Model<Api>): Model<Api> {\n\t// A source model's scalar contextWindow can be its natural default (for example a 1m-default\n\t// model). Do not treat that alone as an opt-in to larger windows on a 400k-default target.\n\tconst settingsDefaultContextWindow = this._getSettingsContextWindowRequestForModel(model)?.contextWindow;\n\tconst candidates: number[] = [];\n\tconst targetDefaultContextWindow = getModelDefaultContextWindow(model);\n\tif (model.contextWindow !== targetDefaultContextWindow) {\n\t\t// Preserve an explicit context-window selection already applied to the target model\n\t\t// (for example a caller passing selectContextWindow(target, 1m).model).\n\t\tcandidates.push(model.contextWindow);\n\t}\n\tconst currentModel = this.model;\n\tif (currentModel && this._shouldCarryCurrentContextWindowForModelSwitch(currentModel, settingsDefaultContextWindow)) {\n\t\tcandidates.push(currentModel.contextWindow);\n\t}\n\tif (settingsDefaultContextWindow !== undefined) {\n\t\tcandidates.push(settingsDefaultContextWindow);\n\t}\n\tcandidates.push(targetDefaultContextWindow);\n\n\tfor (const candidate of candidates) {\n\t\tconst selected = selectContextWindow(model, candidate, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) return selected.model;\n\t}\n\treturn model;\n}\n\n\nexport function _shouldCarryCurrentContextWindowForModelSwitch(this: AgentSession, \n\tcurrentModel: Model<Api>,\n\tsettingsDefaultContextWindow: number | undefined,\n): boolean {\n\tif (currentModel.contextWindow !== getModelDefaultContextWindow(currentModel)) {\n\t\treturn true;\n\t}\n\tif (this.sessionManager.getBranch().some((entry) => entry.type === \"context_window_change\")) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tsettingsDefaultContextWindow !== undefined &&\n\t\tcurrentModel.contextWindow === settingsDefaultContextWindow &&\n\t\tgetSupportedContextWindows(currentModel).includes(settingsDefaultContextWindow)\n\t);\n}\n\n\nexport function _getSettingsContextWindowRequestForModel(this: AgentSession, model: Model<Api>): ContextWindowReplayRequest | undefined {\n\tconst modelContextWindow = this.settingsManager.getDefaultContextWindowForModel(model.provider, model.id);\n\tif (modelContextWindow !== undefined) {\n\t\treturn { contextWindow: modelContextWindow, source: \"model-settings\" };\n\t}\n\tconst globalContextWindow = this.settingsManager.getDefaultContextWindow();\n\treturn globalContextWindow === undefined\n\t\t? undefined\n\t\t: { contextWindow: globalContextWindow, source: \"global-settings\" };\n}\n\n\nexport function _getContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\trequestedContextWindow: number | undefined,\n\tsource: ContextWindowReplaySource | undefined,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tif (requestedContextWindow !== undefined) {\n\t\tconst selected = selectContextWindow(model, requestedContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\t\tif (!(\"error\" in selected)) {\n\t\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn: false };\n\t\t}\n\t\treturn this._getDefaultContextWindowReplayForModel(model, source !== \"global-settings\");\n\t}\n\n\treturn this._getDefaultContextWindowReplayForModel(model, false);\n}\n\n\nexport function _getDefaultContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n\twouldWarn: boolean,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst defaultContextWindow = getModelDefaultContextWindow(model);\n\tconst selected = selectContextWindow(model, defaultContextWindow, COPILOT_CONTEXT_WINDOW_SELECTION_OPTIONS);\n\tif (!(\"error\" in selected)) {\n\t\treturn { model: selected.model, contextWindow: selected.contextWindow, wouldWarn };\n\t}\n\treturn {\n\t\tmodel: { ...model, contextWindow: defaultContextWindow, defaultContextWindow },\n\t\tcontextWindow: defaultContextWindow,\n\t\twouldWarn,\n\t};\n}\n\n\nexport function _getResumeContextWindowReplayForModel(this: AgentSession, \n\tmodel: Model<Api>,\n): { model: Model<Api>; contextWindow: number; wouldWarn: boolean } {\n\tconst sessionContext = this.sessionManager.buildSessionContext();\n\tif (sessionContext.contextWindow !== undefined) {\n\t\treturn this._getContextWindowReplayForModel(model, sessionContext.contextWindow, \"session\");\n\t}\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(model);\n\treturn this._getContextWindowReplayForModel(model, settingsContextWindow?.contextWindow, settingsContextWindow?.source);\n}\n\n\nexport function _applyContextWindowReplay(this: AgentSession, contextWindow: number | undefined): void {\n\tif (!this.model) return;\n\tconst previousContextWindow = this.model.contextWindow;\n\tconst settingsContextWindow = this._getSettingsContextWindowRequestForModel(this.model);\n\tconst requestedContextWindow = contextWindow ?? settingsContextWindow?.contextWindow;\n\tconst source: ContextWindowReplaySource | undefined = contextWindow !== undefined ? \"session\" : settingsContextWindow?.source;\n\tconst replay = this._getContextWindowReplayForModel(this.model, requestedContextWindow, source);\n\tthis.agent.state.model = replay.model;\n\tif (previousContextWindow !== replay.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: replay.contextWindow });\n\t}\n}\n\n\nexport function _appendContextWindowChangeIfChanged(this: AgentSession, \n\tpreviousModel: Model<Api> | undefined,\n\tnextModel: Model<Api>,\n): void {\n\tconst replay = this._getResumeContextWindowReplayForModel(nextModel);\n\tif (!replay.wouldWarn && nextModel.contextWindow === replay.contextWindow) return;\n\tthis.sessionManager.appendContextWindowChange(nextModel.contextWindow);\n\tif (previousModel?.contextWindow !== nextModel.contextWindow) {\n\t\tthis._emit({ type: \"context_window_changed\", contextWindow: nextModel.contextWindow });\n\t}\n}\n\n// =========================================================================\n// Queue Mode Management\n// =========================================================================\n\n/**\n * Set steering message mode.\n * Saves to settings.\n */\n\nexport const agentSessionModelsMethods = {\n\t_getRequiredRequestAuth,\n\t_emitModelChanged,\n\t_emitModelSelect,\n\tsetModel,\n\tcycleModel,\n\t_cycleScopedModel,\n\t_cycleAvailableModel,\n\tsetThinkingLevel,\n\tcycleThinkingLevel,\n\tgetAvailableThinkingLevels,\n\tsupportsThinking,\n\t_getThinkingLevelForModelSwitch,\n\t_clampThinkingLevel,\n\tgetAvailableContextWindows,\n\tsupportsContextWindowSelection,\n\tsetContextWindow,\n\t_withContextWindowForModelSwitch,\n\t_shouldCarryCurrentContextWindowForModelSwitch,\n\t_getSettingsContextWindowRequestForModel,\n\t_getContextWindowReplayForModel,\n\t_getDefaultContextWindowReplayForModel,\n\t_getResumeContextWindowReplayForModel,\n\t_applyContextWindowReplay,\n\t_appendContextWindowChangeIfChanged,\n};\n"]}
@@ -1,4 +1,4 @@
1
- import { clampThinkingLevel, getSupportedThinkingLevels, modelsAreEqual } from "@earendil-works/pi-ai";
1
+ import { clampThinkingLevel, getSupportedThinkingLevels, modelsAreEqual } from "@earendil-works/pi-ai/compat";
2
2
  import { getModelDefaultContextWindow, getSupportedContextWindows, selectContextWindow } from "./context-window.js";
3
3
  import { formatNoApiKeyFoundMessage } from "./auth-guidance.js";
4
4
  import { DEFAULT_THINKING_LEVEL } from "./defaults.js";