@oh-my-pi/pi-coding-agent 17.0.8 → 17.1.0

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 (340) hide show
  1. package/CHANGELOG.md +87 -1
  2. package/README.md +1 -1
  3. package/dist/cli.js +5495 -5021
  4. package/dist/types/async/job-manager.d.ts +37 -1
  5. package/dist/types/cli/args.d.ts +2 -0
  6. package/dist/types/cli/bench-cli.d.ts +41 -0
  7. package/dist/types/commands/bench.d.ts +15 -3
  8. package/dist/types/commands/launch.d.ts +4 -0
  9. package/dist/types/config/__tests__/model-registry.test.d.ts +1 -0
  10. package/dist/types/config/model-registry.d.ts +30 -1
  11. package/dist/types/config/models-config-schema.d.ts +18 -6
  12. package/dist/types/config/models-config.d.ts +14 -5
  13. package/dist/types/config/provider-globals.d.ts +2 -2
  14. package/dist/types/config/service-tier.d.ts +5 -1
  15. package/dist/types/config/settings-schema.d.ts +350 -50
  16. package/dist/types/config/settings.d.ts +7 -0
  17. package/dist/types/dap/client.d.ts +20 -0
  18. package/dist/types/exec/bash-executor.d.ts +38 -0
  19. package/dist/types/exec/direnv.d.ts +33 -0
  20. package/dist/types/export/html/args.d.ts +15 -0
  21. package/dist/types/export/html/index.d.ts +11 -26
  22. package/dist/types/export/html/web-palette.d.ts +55 -116
  23. package/dist/types/extensibility/extensions/loader.d.ts +3 -0
  24. package/dist/types/extensibility/extensions/types.d.ts +17 -2
  25. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +1 -0
  26. package/dist/types/extensibility/legacy-pi-tui-shim.d.ts +10 -0
  27. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +14 -1
  28. package/dist/types/internal-urls/registry-helpers.d.ts +11 -0
  29. package/dist/types/live/controller.d.ts +40 -0
  30. package/dist/types/live/protocol.d.ts +85 -0
  31. package/dist/types/live/protocol.test.d.ts +1 -0
  32. package/dist/types/live/transport.d.ts +48 -0
  33. package/dist/types/live/visualizer.d.ts +33 -0
  34. package/dist/types/lsp/client.d.ts +18 -1
  35. package/dist/types/mcp/config-writer.test.d.ts +1 -0
  36. package/dist/types/mcp/manager.d.ts +6 -2
  37. package/dist/types/mcp/oauth-discovery.d.ts +2 -0
  38. package/dist/types/mcp/render.d.ts +2 -2
  39. package/dist/types/mcp/smithery-auth.d.ts +1 -1
  40. package/dist/types/mcp/smithery-auth.test.d.ts +1 -0
  41. package/dist/types/mcp/tool-bridge.d.ts +7 -3
  42. package/dist/types/mcp/types.d.ts +6 -0
  43. package/dist/types/memory-backend/tool-names.d.ts +2 -0
  44. package/dist/types/modes/components/login-dialog.d.ts +2 -2
  45. package/dist/types/modes/components/oauth-selector.d.ts +8 -0
  46. package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
  47. package/dist/types/modes/components/settings-defs.d.ts +8 -1
  48. package/dist/types/modes/components/status-line/component.jj-cache.test.d.ts +1 -0
  49. package/dist/types/modes/components/tool-execution.d.ts +9 -1
  50. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  51. package/dist/types/modes/controllers/event-controller.d.ts +6 -1
  52. package/dist/types/modes/controllers/live-command-controller.d.ts +14 -0
  53. package/dist/types/modes/controllers/mcp-command-controller.d.ts +3 -0
  54. package/dist/types/modes/interactive-mode.d.ts +5 -0
  55. package/dist/types/modes/rpc/rpc-client.d.ts +10 -1
  56. package/dist/types/modes/rpc/rpc-frame.d.ts +16 -0
  57. package/dist/types/modes/rpc/rpc-messages.d.ts +26 -0
  58. package/dist/types/modes/rpc/rpc-types.d.ts +40 -0
  59. package/dist/types/modes/setup-wizard/scenes/sign-in.d.ts +1 -1
  60. package/dist/types/modes/setup-wizard/scenes/types.d.ts +9 -1
  61. package/dist/types/modes/setup-wizard/scenes/web-search.d.ts +1 -1
  62. package/dist/types/modes/theme/theme.d.ts +1 -1
  63. package/dist/types/modes/types.d.ts +3 -1
  64. package/dist/types/modes/utils/context-usage.d.ts +12 -2
  65. package/dist/types/plan-mode/plan-files.d.ts +10 -0
  66. package/dist/types/registry/agent-lifecycle.d.ts +21 -9
  67. package/dist/types/registry/agent-registry.d.ts +11 -4
  68. package/dist/types/sdk.d.ts +15 -1
  69. package/dist/types/secrets/index.d.ts +15 -2
  70. package/dist/types/secrets/obfuscator.d.ts +113 -15
  71. package/dist/types/session/acp-permission-gate.d.ts +19 -0
  72. package/dist/types/session/agent-session-events.d.ts +84 -0
  73. package/dist/types/session/agent-session-types.d.ts +314 -0
  74. package/dist/types/session/agent-session.d.ts +120 -750
  75. package/dist/types/session/async-job-delivery.d.ts +28 -0
  76. package/dist/types/session/bash-runner.d.ts +75 -0
  77. package/dist/types/session/blob-store.d.ts +11 -1
  78. package/dist/types/session/blob-store.test.d.ts +1 -0
  79. package/dist/types/session/checkpoint-entries.d.ts +28 -0
  80. package/dist/types/session/eval-runner.d.ts +49 -0
  81. package/dist/types/session/irc-bridge.d.ts +46 -0
  82. package/dist/types/session/messages.d.ts +22 -0
  83. package/dist/types/session/model-controls.d.ts +180 -0
  84. package/dist/types/session/prewalk.d.ts +46 -0
  85. package/dist/types/session/queued-messages.d.ts +22 -0
  86. package/dist/types/session/redis-session-storage.d.ts +1 -0
  87. package/dist/types/session/retry-fallback-chains.d.ts +74 -0
  88. package/dist/types/session/role-models.d.ts +15 -0
  89. package/dist/types/session/session-advisors.d.ts +228 -0
  90. package/dist/types/session/session-entries.d.ts +8 -0
  91. package/dist/types/session/session-handoff.d.ts +70 -0
  92. package/dist/types/session/session-history-format.d.ts +6 -1
  93. package/dist/types/session/session-loader.d.ts +6 -4
  94. package/dist/types/session/session-maintenance.d.ts +246 -0
  95. package/dist/types/session/session-manager.d.ts +41 -0
  96. package/dist/types/session/session-memory.d.ts +56 -0
  97. package/dist/types/session/session-provider-boundary.d.ts +62 -0
  98. package/dist/types/session/session-stats.d.ts +48 -0
  99. package/dist/types/session/session-tools.d.ts +143 -0
  100. package/dist/types/session/session-workspace.d.ts +32 -0
  101. package/dist/types/session/stream-guards.d.ts +44 -0
  102. package/dist/types/session/todo-tracker.d.ts +56 -0
  103. package/dist/types/session/ttsr-coordinator.d.ts +51 -0
  104. package/dist/types/session/turn-recovery.d.ts +225 -0
  105. package/dist/types/system-prompt.d.ts +2 -0
  106. package/dist/types/task/executor.d.ts +4 -1
  107. package/dist/types/task/output-manager.d.ts +3 -1
  108. package/dist/types/task/types.d.ts +14 -0
  109. package/dist/types/tools/approval.d.ts +1 -0
  110. package/dist/types/tools/browser/launch.d.ts +5 -0
  111. package/dist/types/tools/hub/jobs.d.ts +1 -1
  112. package/dist/types/tools/image-gen.d.ts +4 -4
  113. package/dist/types/tools/image-providers.d.ts +38 -0
  114. package/dist/types/tools/index.d.ts +8 -0
  115. package/dist/types/tools/path-utils.d.ts +8 -0
  116. package/dist/types/tools/report-tool-issue.d.ts +24 -9
  117. package/dist/types/tools/todo.d.ts +10 -4
  118. package/dist/types/tools/xdev.d.ts +5 -1
  119. package/dist/types/tts/streaming-player.d.ts +14 -0
  120. package/dist/types/tts/vocalizer.d.ts +5 -0
  121. package/dist/types/utils/jj.d.ts +29 -0
  122. package/dist/types/utils/lang-from-path.d.ts +1 -0
  123. package/dist/types/utils/title-generator.d.ts +30 -0
  124. package/dist/types/vibe/runtime.d.ts +36 -8
  125. package/dist/types/web/search/index.d.ts +1 -1
  126. package/dist/types/web/search/provider.d.ts +15 -5
  127. package/dist/types/web/search/providers/firecrawl.d.ts +9 -0
  128. package/dist/types/web/search/types.d.ts +95 -1
  129. package/package.json +13 -12
  130. package/scripts/generate-share-viewer.ts +4 -6
  131. package/scripts/legacy-pi-virtual-module.ts +1 -1
  132. package/src/advisor/__tests__/advisor.test.ts +643 -0
  133. package/src/advisor/runtime.ts +144 -43
  134. package/src/async/job-manager.ts +90 -2
  135. package/src/cli/args.ts +2 -0
  136. package/src/cli/auth-gateway-cli.ts +18 -3
  137. package/src/cli/bench-cli.ts +395 -29
  138. package/src/cli/flag-tables.ts +3 -0
  139. package/src/cli/gc-cli.ts +2 -2
  140. package/src/cli/grievances-cli.ts +2 -2
  141. package/src/cli/usage-cli.ts +11 -2
  142. package/src/collab/host.ts +3 -2
  143. package/src/commands/bench.ts +18 -4
  144. package/src/commands/launch.ts +4 -0
  145. package/src/config/__tests__/model-registry.test.ts +147 -0
  146. package/src/config/model-registry.ts +50 -2
  147. package/src/config/model-resolver.ts +0 -1
  148. package/src/config/models-config-schema.ts +15 -4
  149. package/src/config/provider-globals.ts +9 -9
  150. package/src/config/service-tier.ts +26 -1
  151. package/src/config/settings-schema.ts +250 -54
  152. package/src/config/settings.ts +81 -2
  153. package/src/dap/client.ts +37 -4
  154. package/src/edit/index.ts +49 -12
  155. package/src/eval/py/executor.ts +103 -33
  156. package/src/exec/bash-executor.ts +89 -6
  157. package/src/exec/direnv.ts +145 -0
  158. package/src/export/html/args.ts +20 -0
  159. package/src/export/html/index.ts +45 -47
  160. package/src/export/html/template.css +19 -1
  161. package/src/export/html/template.html +6 -0
  162. package/src/export/html/template.js +21 -0
  163. package/src/export/html/tool-views.generated.js +31 -31
  164. package/src/export/html/web-palette.ts +116 -132
  165. package/src/export/share.ts +249 -49
  166. package/src/extensibility/extensions/loader.ts +29 -1
  167. package/src/extensibility/extensions/runner.ts +6 -0
  168. package/src/extensibility/extensions/types.ts +33 -2
  169. package/src/extensibility/legacy-pi-coding-agent-shim.ts +1 -0
  170. package/src/extensibility/legacy-pi-tui-shim.ts +10 -0
  171. package/src/extensibility/plugins/legacy-pi-compat.ts +870 -311
  172. package/src/hindsight/state.ts +64 -6
  173. package/src/internal-urls/local-protocol.ts +2 -1
  174. package/src/internal-urls/memory-protocol.ts +2 -2
  175. package/src/internal-urls/registry-helpers.ts +40 -0
  176. package/src/internal-urls/skill-protocol.ts +2 -2
  177. package/src/internal-urls/ssh-protocol.ts +2 -1
  178. package/src/internal-urls/vault-protocol.ts +2 -1
  179. package/src/live/audio-worklet.txt +59 -0
  180. package/src/live/browser-runtime.txt +221 -0
  181. package/src/live/controller.ts +464 -0
  182. package/src/live/prompts/agent-final-message.md +3 -0
  183. package/src/live/prompts/live-instructions.md +23 -0
  184. package/src/live/protocol.test.ts +140 -0
  185. package/src/live/protocol.ts +233 -0
  186. package/src/live/transport.ts +490 -0
  187. package/src/live/visualizer.ts +234 -0
  188. package/src/lsp/client.ts +52 -9
  189. package/src/lsp/clients/biome-client.ts +3 -4
  190. package/src/lsp/index.ts +44 -11
  191. package/src/main.ts +9 -1
  192. package/src/mcp/config-writer.test.ts +43 -0
  193. package/src/mcp/config-writer.ts +109 -82
  194. package/src/mcp/manager.ts +39 -8
  195. package/src/mcp/oauth-discovery.ts +10 -2
  196. package/src/mcp/render.ts +94 -35
  197. package/src/mcp/smithery-auth.test.ts +29 -0
  198. package/src/mcp/smithery-auth.ts +3 -2
  199. package/src/mcp/tool-bridge.ts +107 -11
  200. package/src/mcp/types.ts +7 -0
  201. package/src/memories/index.ts +40 -20
  202. package/src/memory-backend/tool-names.ts +2 -0
  203. package/src/mnemopi/backend.ts +24 -7
  204. package/src/modes/acp/acp-agent.ts +56 -10
  205. package/src/modes/acp/acp-event-mapper.ts +8 -1
  206. package/src/modes/components/agent-hub.ts +27 -10
  207. package/src/modes/components/login-dialog.ts +14 -4
  208. package/src/modes/components/oauth-selector.ts +24 -7
  209. package/src/modes/components/plan-review-overlay.ts +350 -35
  210. package/src/modes/components/settings-defs.ts +28 -3
  211. package/src/modes/components/settings-selector.ts +178 -6
  212. package/src/modes/components/status-line/component.jj-cache.test.ts +229 -0
  213. package/src/modes/components/status-line/component.ts +123 -2
  214. package/src/modes/components/tool-execution.test.ts +63 -2
  215. package/src/modes/components/tool-execution.ts +11 -2
  216. package/src/modes/controllers/command-controller.ts +70 -22
  217. package/src/modes/controllers/event-controller.ts +111 -16
  218. package/src/modes/controllers/extension-ui-controller.test.ts +1 -0
  219. package/src/modes/controllers/extension-ui-controller.ts +20 -4
  220. package/src/modes/controllers/live-command-controller.ts +178 -0
  221. package/src/modes/controllers/mcp-command-controller.ts +80 -41
  222. package/src/modes/controllers/omfg-controller.ts +44 -40
  223. package/src/modes/controllers/selector-controller.ts +18 -10
  224. package/src/modes/controllers/session-focus-controller.ts +6 -1
  225. package/src/modes/interactive-mode.ts +160 -38
  226. package/src/modes/rpc/rpc-client.ts +94 -3
  227. package/src/modes/rpc/rpc-frame.ts +164 -4
  228. package/src/modes/rpc/rpc-messages.ts +127 -0
  229. package/src/modes/rpc/rpc-mode.ts +79 -7
  230. package/src/modes/rpc/rpc-types.ts +34 -2
  231. package/src/modes/runtime-init.ts +2 -0
  232. package/src/modes/setup-wizard/scenes/model.ts +5 -7
  233. package/src/modes/setup-wizard/scenes/providers.ts +3 -2
  234. package/src/modes/setup-wizard/scenes/sign-in.ts +8 -2
  235. package/src/modes/setup-wizard/scenes/theme.ts +13 -3
  236. package/src/modes/setup-wizard/scenes/types.ts +9 -1
  237. package/src/modes/setup-wizard/scenes/web-search.ts +23 -10
  238. package/src/modes/setup-wizard/wizard-overlay.ts +1 -1
  239. package/src/modes/theme/theme.ts +1 -1
  240. package/src/modes/types.ts +3 -1
  241. package/src/modes/utils/context-usage.ts +23 -7
  242. package/src/modes/utils/ui-helpers.ts +10 -5
  243. package/src/plan-mode/plan-files.ts +40 -0
  244. package/src/prompts/bench/cache-prefix-chunk.md +1 -0
  245. package/src/prompts/bench/cache-prefix.md +3 -0
  246. package/src/prompts/bench/cache-suffix.md +1 -0
  247. package/src/prompts/goals/guided-goal-system.md +24 -3
  248. package/src/prompts/system/custom-system-prompt.md +1 -1
  249. package/src/prompts/system/project-prompt.md +8 -1
  250. package/src/prompts/system/subagent-async-pending.md +6 -0
  251. package/src/prompts/system/system-prompt.md +1 -1
  252. package/src/prompts/system/workflow-notice.md +48 -40
  253. package/src/prompts/system/xdev-mount-notice.md +4 -0
  254. package/src/prompts/tools/task.md +12 -2
  255. package/src/prompts/tools/todo.md +3 -1
  256. package/src/registry/agent-lifecycle.ts +116 -46
  257. package/src/registry/agent-registry.ts +35 -8
  258. package/src/registry/persisted-agents.ts +26 -2
  259. package/src/sdk.ts +255 -139
  260. package/src/secrets/index.ts +127 -4
  261. package/src/secrets/obfuscator.ts +2328 -105
  262. package/src/session/acp-permission-gate.ts +165 -0
  263. package/src/session/agent-session-error-log.test.ts +1 -1
  264. package/src/session/agent-session-events.ts +66 -0
  265. package/src/session/agent-session-types.ts +334 -0
  266. package/src/session/agent-session.ts +1910 -12213
  267. package/src/session/artifacts.ts +6 -5
  268. package/src/session/async-job-delivery.ts +74 -0
  269. package/src/session/bash-runner.ts +326 -0
  270. package/src/session/blob-store.test.ts +56 -0
  271. package/src/session/blob-store.ts +18 -2
  272. package/src/session/checkpoint-entries.ts +81 -0
  273. package/src/session/eval-runner.ts +212 -0
  274. package/src/session/indexed-session-storage.ts +9 -2
  275. package/src/session/irc-bridge.ts +203 -0
  276. package/src/session/messages.ts +263 -1
  277. package/src/session/model-controls.ts +714 -0
  278. package/src/session/prewalk.ts +252 -0
  279. package/src/session/queued-messages.ts +93 -0
  280. package/src/session/redis-session-storage.ts +51 -11
  281. package/src/session/retry-fallback-chains.ts +455 -0
  282. package/src/session/role-models.ts +85 -0
  283. package/src/session/session-advisors.ts +1679 -0
  284. package/src/session/session-context.test.ts +224 -1
  285. package/src/session/session-context.ts +47 -5
  286. package/src/session/session-entries.ts +8 -0
  287. package/src/session/session-handoff.ts +308 -0
  288. package/src/session/session-history-format.ts +20 -9
  289. package/src/session/session-loader.ts +10 -51
  290. package/src/session/session-maintenance.ts +2983 -0
  291. package/src/session/session-manager.ts +390 -30
  292. package/src/session/session-memory.ts +222 -0
  293. package/src/session/session-provider-boundary.ts +307 -0
  294. package/src/session/session-stats.ts +293 -0
  295. package/src/session/session-tools.ts +943 -0
  296. package/src/session/session-workspace.ts +53 -0
  297. package/src/session/stream-guards.ts +417 -0
  298. package/src/session/todo-tracker.ts +380 -0
  299. package/src/session/ttsr-coordinator.ts +496 -0
  300. package/src/session/turn-recovery.ts +1629 -0
  301. package/src/slash-commands/builtin-registry.ts +92 -11
  302. package/src/slash-commands/helpers/usage-report.ts +25 -4
  303. package/src/system-prompt.ts +41 -17
  304. package/src/task/executor.ts +288 -70
  305. package/src/task/index.ts +148 -111
  306. package/src/task/output-manager.ts +25 -3
  307. package/src/task/persisted-revive.ts +4 -3
  308. package/src/task/structured-subagent.ts +4 -1
  309. package/src/task/types.ts +16 -0
  310. package/src/tools/approval.ts +55 -10
  311. package/src/tools/bash-interactive.ts +26 -0
  312. package/src/tools/bash-skill-urls.ts +28 -2
  313. package/src/tools/bash.ts +339 -123
  314. package/src/tools/browser/launch.ts +9 -1
  315. package/src/tools/browser/tab-supervisor.ts +8 -5
  316. package/src/tools/browser.ts +94 -47
  317. package/src/tools/hub/index.ts +1 -1
  318. package/src/tools/hub/jobs.ts +67 -8
  319. package/src/tools/image-gen.ts +20 -28
  320. package/src/tools/image-providers.ts +50 -0
  321. package/src/tools/index.ts +12 -0
  322. package/src/tools/path-utils.ts +49 -2
  323. package/src/tools/read.ts +156 -88
  324. package/src/tools/renderers.ts +7 -1
  325. package/src/tools/report-tool-issue.ts +79 -28
  326. package/src/tools/todo.ts +101 -11
  327. package/src/tools/vibe.ts +1 -2
  328. package/src/tools/write.ts +51 -1
  329. package/src/tools/xdev.ts +67 -3
  330. package/src/tts/streaming-player.ts +62 -4
  331. package/src/tts/vocalizer.ts +18 -1
  332. package/src/utils/jj.ts +125 -4
  333. package/src/utils/lang-from-path.ts +7 -0
  334. package/src/utils/title-generator.ts +137 -1
  335. package/src/vibe/runtime.ts +852 -72
  336. package/src/web/search/index.ts +3 -6
  337. package/src/web/search/provider.ts +31 -16
  338. package/src/web/search/providers/firecrawl.ts +46 -13
  339. package/src/web/search/providers/xai.ts +7 -1
  340. package/src/web/search/types.ts +8 -1
@@ -13,33 +13,30 @@
13
13
  * Modes use this class and add their own I/O layer on top.
14
14
  */
15
15
  import type { InMemorySnapshotStore } from "@oh-my-pi/hashline";
16
- import { Agent, type AgentEvent, type AgentMessage, type AgentState, type AgentTool, type AgentToolContext, type AgentToolResult, type StreamFn, ThinkingLevel, type ToolChoiceDirective } from "@oh-my-pi/pi-agent-core";
16
+ import { type Agent, type AgentMessage, type AgentState, type AgentTool, type AgentToolContext, type AgentToolResult, type ThinkingLevel, type ToolChoiceDirective } from "@oh-my-pi/pi-agent-core";
17
17
  import { type CompactionResult, type ShakeConfig } from "@oh-my-pi/pi-agent-core/compaction";
18
- import type { AssistantMessage, Context, ImageContent, Message, MessageAttribution, Model, ProviderSessionState, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, ServiceTier, ServiceTierByFamily, ServiceTierFamily, SimpleStreamOptions, TextContent, ToolChoice, UsageReport } from "@oh-my-pi/pi-ai";
19
- import { Effort } from "@oh-my-pi/pi-ai";
20
- import { postmortem } from "@oh-my-pi/pi-utils";
21
- import { type AdvisorConfig, type AdvisorRuntimeStatus } from "../advisor/index.js";
22
- import { type AsyncJob, type AsyncJobDeliveryState, AsyncJobManager } from "../async/index.js";
23
- import type { Rule } from "../capability/rule.js";
18
+ import type { AssistantMessage, ImageContent, Message, Model, ProviderSessionState, ResetCreditAccountStatus, ResetCreditRedeemOutcome, ResetCreditTarget, ServiceTier, ServiceTierByFamily, ServiceTierFamily, SimpleStreamOptions, TextContent, UsageReport } from "@oh-my-pi/pi-ai";
19
+ import { type Effort } from "@oh-my-pi/pi-ai";
20
+ import type { AdvisorConfig, AdvisorRuntimeStatus } from "../advisor/index.js";
21
+ import { AsyncJobManager } from "../async/index.js";
24
22
  import type { ModelRegistry } from "../config/model-registry.js";
25
23
  import { type ResolvedModelRoleValue } from "../config/model-resolver.js";
26
24
  import { type PromptTemplate } from "../config/prompt-templates.js";
27
25
  import type { Settings, SkillsSettings } from "../config/settings.js";
28
26
  import { RawSseDebugBuffer } from "../debug/raw-sse-buffer.js";
29
- import { type PythonResult } from "../eval/py/executor.js";
30
- import { type BashResult } from "../exec/bash-executor.js";
27
+ import type { PythonResult } from "../eval/py/executor.js";
28
+ import type { BashResult } from "../exec/bash-executor.js";
31
29
  import type { TtsrManager } from "../export/ttsr.js";
32
30
  import type { LoadedCustomCommand } from "../extensibility/custom-commands/index.js";
33
31
  import type { CustomTool } from "../extensibility/custom-tools/types.js";
34
32
  import type { ExtensionRunner, ExtensionUIContext } from "../extensibility/extensions/index.js";
35
33
  import type { CompactOptions, ContextUsage } from "../extensibility/extensions/types.js";
36
- import type { RecoveredRetryError } from "../extensibility/shared-events.js";
37
- import { type Skill, type SkillWarning } from "../extensibility/skills.js";
34
+ import type { Skill, SkillWarning } from "../extensibility/skills.js";
38
35
  import { type FileSlashCommand } from "../extensibility/slash-commands.js";
39
36
  import { GoalRuntime } from "../goals/runtime.js";
40
- import type { Goal, GoalModeState } from "../goals/state.js";
37
+ import type { GoalModeState } from "../goals/state.js";
41
38
  import type { HindsightSessionState } from "../hindsight/state.js";
42
- import { type IrcMessage } from "../irc/bus.js";
39
+ import type { IrcMessage } from "../irc/bus.js";
43
40
  import { type MnemopiSessionState } from "../mnemopi/state.js";
44
41
  import { type PlanApprovalDetails } from "../plan-mode/approved-plan.js";
45
42
  import type { PlanModeState } from "../plan-mode/state.js";
@@ -48,499 +45,22 @@ import { type ConfiguredThinkingLevel } from "../thinking.js";
48
45
  import { type AskToolDetails, type AskToolInput } from "../tools/ask.js";
49
46
  import type { CheckpointState, CompletedRewindState } from "../tools/checkpoint.js";
50
47
  import { type PlanProposalHandler } from "../tools/resolve.js";
51
- import { type TodoItem, type TodoPhase } from "../tools/todo.js";
52
- import { type XdevRegistry } from "../tools/xdev.js";
48
+ import type { TodoPhase } from "../tools/todo.js";
53
49
  import type { VibeModeState } from "../vibe/state.js";
50
+ import type { AgentSessionEventListener } from "./agent-session-events.js";
51
+ import type { AgentSessionConfig, AgentSessionDisposeOptions, AsyncJobSnapshot, CommandMetadataChangedListener, ContextUsageBreakdown, FollowUpOptions, FreshSessionResult, HandoffResult, ModelCycleResult, Prewalk, PromptOptions, ResolvedRoleModel, RestoredQueuedMessage, RoleModelCycle, RoleModelCycleResult, SessionHandoffOptions, SessionStats, UsageFallbackConfirmation } from "./agent-session-types.js";
54
52
  import type { ClientBridge } from "./client-bridge.js";
55
53
  import { type CustomMessage, type CustomMessagePayload } from "./messages.js";
54
+ import { type AdvisorStats } from "./session-advisors.js";
56
55
  import type { BuildSessionContextOptions, SessionContext } from "./session-context.js";
57
56
  import type { BranchSummaryEntry, NewSessionOptions } from "./session-entries.js";
58
57
  import { type SessionManager } from "./session-manager.js";
59
58
  import type { ShakeMode, ShakeResult } from "./shake-types.js";
60
59
  import { ToolChoiceQueue } from "./tool-choice-queue.js";
61
60
  import { YieldQueue } from "./yield-queue.js";
62
- /** Session-specific events that extend the core AgentEvent */
63
- export type AgentSessionEvent = AgentEvent | {
64
- type: "auto_compaction_start";
65
- reason: "threshold" | "overflow" | "idle" | "incomplete";
66
- action: "context-full" | "handoff" | "shake" | "snapcompact";
67
- } | {
68
- type: "auto_compaction_end";
69
- action: "context-full" | "handoff" | "shake" | "snapcompact";
70
- result: CompactionResult | undefined;
71
- aborted: boolean;
72
- willRetry: boolean;
73
- errorMessage?: string;
74
- /** True when compaction was skipped for a benign reason (no model, no candidates, nothing to compact). */
75
- skipped?: boolean;
76
- } | {
77
- type: "auto_retry_start";
78
- attempt: number;
79
- maxAttempts: number;
80
- delayMs: number;
81
- errorMessage: string;
82
- errorId?: number;
83
- } | {
84
- type: "auto_retry_end";
85
- success: boolean;
86
- attempt: number;
87
- finalError?: string;
88
- recoveredErrors?: RecoveredRetryError[];
89
- } | {
90
- type: "retry_fallback_applied";
91
- from: string;
92
- to: string;
93
- role: string;
94
- } | {
95
- type: "retry_fallback_succeeded";
96
- model: string;
97
- role: string;
98
- } | {
99
- type: "ttsr_triggered";
100
- rules: Rule[];
101
- } | {
102
- type: "todo_reminder";
103
- todos: TodoItem[];
104
- attempt: number;
105
- maxAttempts: number;
106
- } | {
107
- type: "todo_auto_clear";
108
- } | {
109
- type: "irc_message";
110
- message: CustomMessage;
111
- } | {
112
- type: "notice";
113
- level: "info" | "warning" | "error";
114
- message: string;
115
- source?: string;
116
- } | {
117
- type: "thinking_level_changed";
118
- thinkingLevel: ThinkingLevel | undefined;
119
- /** The user-configured selector when it differs from the effective level (e.g. `auto`). */
120
- configured?: ConfiguredThinkingLevel;
121
- /** The level `auto` resolved to this turn, once classified. */
122
- resolved?: Effort;
123
- } | {
124
- type: "goal_updated";
125
- goal: Goal | null;
126
- state?: GoalModeState;
127
- };
128
- /** Listener function for agent session events */
129
- export type AgentSessionEventListener = (event: AgentSessionEvent) => void;
130
- /**
131
- * Budget for callers on the user-visible `/quit` / `/exit` shutdown path that
132
- * want to cap how long they wait for `MnemopiSessionState.dispose()` to finish
133
- * its consolidate pass. Consolidate fires fresh LLM fact extractions, each a
134
- * 1–3 s round-trip, so interactive shutdown passes this budget to keep the
135
- * UI responsive. Callers that keep the process/session host alive must omit it
136
- * so dispose still awaits the full consolidate-then-close pipeline.
137
- */
138
- export declare const SHUTDOWN_CONSOLIDATE_BUDGET_MS = 1500;
139
- export interface AgentSessionDisposeOptions {
140
- mnemopiConsolidateTimeoutMs?: number;
141
- /**
142
- * Postmortem reason that triggered this dispose (signal/fatal teardown
143
- * paths). When set, the persisted `session_exit` diagnostic records it
144
- * instead of the generic `"dispose"` used for normal programmatic disposal
145
- * (`/quit`, test teardown, subagent completion).
146
- */
147
- reason?: postmortem.Reason;
148
- }
149
- export type CommandMetadataChangedListener = () => void | Promise<void>;
150
- export type AsyncJobSnapshotItem = Pick<AsyncJob, "id" | "type" | "status" | "label" | "startTime">;
151
- export interface AsyncJobSnapshot {
152
- running: AsyncJobSnapshotItem[];
153
- recent: AsyncJobSnapshotItem[];
154
- delivery: AsyncJobDeliveryState;
155
- }
156
- export type { ShakeMode, ShakeResult };
157
- /**
158
- * Prewalk: switches an active session one-way from its starting model to
159
- * a fast/cheap `target` at the first completed turn that runs an edit/write
160
- * tool once the todo list exists. A hidden plan nudge asks the starting
161
- * model to write a plan, initialize its todo list from it, and start; the
162
- * todo call opens the trigger gate (it never fires the switch itself), so
163
- * the starting model always begins the implementation. A hidden
164
- * checklist nudge asks the target model to verify its work before
165
- * finishing. Both are always on — this is the one mechanism that won out
166
- * over turn-count and ungated variants in testing.
167
- */
168
- export interface Prewalk {
169
- target: Model;
170
- thinkingLevel?: ConfiguredThinkingLevel;
171
- }
172
- /**
173
- * PlanYolo: forces the session into read-only plan mode at start, then
174
- * auto-approves the plan the instant the model calls `resolve({ action:
175
- * "apply" })` for it — no interactive review — and switches to a fast/cheap
176
- * `target` model to implement it. The headless counterpart to interactive
177
- * plan mode's "Approve and execute", for print/non-interactive runs where
178
- * there is no one to click Approve.
179
- */
180
- export interface PlanYolo {
181
- target: Model;
182
- thinkingLevel?: ConfiguredThinkingLevel;
183
- }
184
- /** Identifies a retry fallback chain already entered during startup model resolution. */
185
- export interface InitialRetryFallbackState {
186
- /** Role whose configured primary was unavailable. */
187
- role: string;
188
- /** Configured primary selector retained for restoration when it becomes available. */
189
- originalSelector: string;
190
- /** Thinking selector configured for the unavailable primary. */
191
- originalThinkingLevel: ConfiguredThinkingLevel | undefined;
192
- }
193
- export interface AgentSessionConfig {
194
- agent: Agent;
195
- sessionManager: SessionManager;
196
- settings: Settings;
197
- /** Whether the caller explicitly requested yolo/auto-approve behavior for this session. */
198
- autoApprove?: boolean;
199
- /** Models to cycle through with Ctrl+P (from --models flag) */
200
- scopedModels?: Array<{
201
- model: Model;
202
- thinkingLevel?: ThinkingLevel;
203
- }>;
204
- /** Initial session thinking selector. */
205
- thinkingLevel?: ConfiguredThinkingLevel;
206
- /** Retry chain ownership when startup selected one of its fallback entries. */
207
- initialRetryFallback?: InitialRetryFallbackState;
208
- /** Prewalk from the starting model to a fast/cheap target at the first edit/write once the todo list exists. */
209
- prewalk?: Prewalk;
210
- /** Force read-only plan mode at start, auto-approve on the model's first
211
- * plan proposal (`write xd://propose`), then switch to the target to implement. */
212
- planYolo?: PlanYolo;
213
- /** Initial per-family service tiers (OpenAI / Anthropic / Google) for the live session. */
214
- serviceTierByFamily?: ServiceTierByFamily;
215
- /** Prompt templates for expansion */
216
- promptTemplates?: PromptTemplate[];
217
- /** File-based slash commands for expansion */
218
- slashCommands?: FileSlashCommand[];
219
- /** Extension runner (created in main.ts with wrapped tools) */
220
- extensionRunner?: ExtensionRunner;
221
- /** Loaded skills (already discovered by SDK) */
222
- skills?: Skill[];
223
- /** Skill loading warnings (already captured by SDK) */
224
- skillWarnings?: SkillWarning[];
225
- /** Whether runtime reloads may rediscover disk-backed skills for this session. */
226
- skillsReloadable?: boolean;
227
- /** Custom commands (TypeScript slash commands) */
228
- customCommands?: LoadedCustomCommand[];
229
- skillsSettings?: SkillsSettings;
230
- /** Model registry for API key resolution and model discovery */
231
- modelRegistry: ModelRegistry;
232
- /** Tool registry for LSP and settings */
233
- toolRegistry?: Map<string, AgentTool>;
234
- /** Creates the tools registered only while `/vibe` mode is active. */
235
- createVibeTools?: () => AgentTool[];
236
- /** Tool names whose current registry entry is still the built-in implementation. */
237
- builtInToolNames?: Iterable<string>;
238
- /** Update tool-session predicates that render guidance from the live active tool set. */
239
- setActiveToolNames?: (names: Iterable<string>) => void;
240
- /** Register the write transport lazily when runtime xdev mounts first need it. */
241
- ensureWriteRegistered?: () => Promise<boolean>;
242
- /** Current session pre-LLM message transform pipeline */
243
- transformContext?: (messages: AgentMessage[], signal?: AbortSignal) => AgentMessage[] | Promise<AgentMessage[]>;
244
- /**
245
- * Per-request transform applied after `convertToLlm` and before the
246
- * provider call. Used for snapcompact, secret obfuscation, and image
247
- * clamping. When supplied via {@link createAgentSession}, the advisor agent
248
- * inherits this so its requests undergo the same shaping as the main turn.
249
- */
250
- transformProviderContext?: (context: Context, model: Model) => Context | Promise<Context>;
251
- /**
252
- * Stream wrapper passed to side-channel requests (`/btw`, `/omfg`, IRC
253
- * auto-replies, and handoff generation) so they apply the same provider
254
- * shaping and host-level request wrappers as normal agent turns. Defaults
255
- * to plain `streamSimple` when omitted.
256
- */
257
- sideStreamFn?: StreamFn;
258
- /**
259
- * Stream wrapper passed to the advisor agent so its requests apply the
260
- * session's `providers.openrouterVariant`, `providers.antigravityEndpoint`,
261
- * `providers.maxInFlightRequests`, and `model.loopGuard.*` settings —
262
- * keeping OpenRouter sticky-routing / response caching consistent with the
263
- * main agent. Defaults to plain `streamSimple` when omitted.
264
- */
265
- advisorStreamFn?: StreamFn;
266
- /** Hint that OpenAI Codex requests should prefer websocket transport when supported. */
267
- preferWebsockets?: boolean;
268
- /** Provider payload hook used by the active session request path */
269
- onPayload?: SimpleStreamOptions["onPayload"];
270
- /** Provider response hook used by the active session request path */
271
- onResponse?: SimpleStreamOptions["onResponse"];
272
- /** Raw SSE hook used by the active session request path */
273
- onSseEvent?: SimpleStreamOptions["onSseEvent"];
274
- /** Per-session raw SSE diagnostic buffer */
275
- rawSseDebugBuffer?: RawSseDebugBuffer;
276
- /** Current session message-to-LLM conversion pipeline */
277
- convertToLlm?: (messages: AgentMessage[]) => Message[] | Promise<Message[]>;
278
- /** System prompt builder that can consider tool availability. Returns ordered provider-facing blocks. */
279
- rebuildSystemPrompt?: (toolNames: string[], tools: Map<string, AgentTool>) => Promise<{
280
- systemPrompt: string[];
281
- }>;
282
- /** Local calendar date provider used by prompt-cache invalidation. Defaults to the host local date. */
283
- getLocalCalendarDate?: () => string;
284
- /** Entries of tools mounted under `xd://` (name + one-line summary), for /tools display. */
285
- getXdevToolEntries?: () => Array<{
286
- name: string;
287
- summary: string;
288
- }>;
289
- /** Session-owned `xd://` device registry; reconciled as the active tool set changes. */
290
- xdevRegistry?: XdevRegistry;
291
- /** Discoverable tools mounted under `xd://` in the initial enabled set (startup partition in `sdk.ts`). */
292
- initialMountedXdevToolNames?: string[];
293
- /** Explicit/effective names pinned top-level during runtime repartitioning. */
294
- presentationPinnedToolNames?: ReadonlySet<string>;
295
- /**
296
- * Optional accessor for live MCP server instructions. Read by the session's
297
- * `rebuildSystemPrompt`-skip optimization to detect server-side instruction
298
- * changes (e.g. an MCP server upgrade) that would otherwise pass the tool-set
299
- * signature comparison and silently keep a stale prompt cached.
300
- */
301
- getMcpServerInstructions?: () => Map<string, string> | undefined;
302
- /** TTSR manager for time-traveling stream rules */
303
- ttsrManager?: TtsrManager;
304
- /** Secret obfuscator for deobfuscating streaming edit content */
305
- obfuscator?: SecretObfuscator;
306
- /** Inherited eval executor session id from a parent agent. */
307
- parentEvalSessionId?: string;
308
- /** Logical owner for retained eval kernels created by this session. */
309
- evalKernelOwnerId?: string;
310
- /**
311
- * AsyncJobManager that this session installed as the process-global instance.
312
- * Only set for top-level sessions; subagents inherit the parent's manager and
313
- * **MUST NOT** dispose it on their own teardown.
314
- */
315
- ownedAsyncJobManager?: AsyncJobManager;
316
- /**
317
- * AsyncJobManager reachable by this session for scoped job actions.
318
- *
319
- * Top-level owners receive their own manager, subagents receive the inherited
320
- * parent manager, and secondary in-process top-level sessions receive
321
- * `undefined` so job snapshots and ACP drains cannot observe the primary's
322
- * state.
323
- */
324
- asyncJobManager?: AsyncJobManager;
325
- /** Agent identity (registry id like "Main" or "Alice") used for IRC routing. */
326
- agentId?: string;
327
- /** Whether this session is the top-level agent or a subagent. Drives eager-task
328
- * prelude gating so a top-level session created with a custom `agentId` still
329
- * receives the always-mode reminder. Defaults to "main". */
330
- agentKind?: "main" | "sub";
331
- /**
332
- * Override the provider-facing session ID for all API requests from this session.
333
- * When absent, `sessionManager.getSessionId()` is used. Needed when benchmark or
334
- * SDK callers issue probes / prewarming with an explicit `--provider-session-id`
335
- * so that credential sticky selection is consistent with the session's streaming calls.
336
- */
337
- providerSessionId?: string;
338
- /** Marks `agent.promptCacheKey` as fork-inherited so incompatible route changes can clear it. */
339
- providerPromptCacheKeySource?: "explicit" | "fork";
340
- /**
341
- * Full advisor toolset, pre-built in `createAgentSession` against a distinct,
342
- * advisor-scoped `ToolSession` (its own `-advisor` session/agent id) so the
343
- * advisor's tool state stays isolated from the primary. The advisor is a full
344
- * agent; its config `tools` selects a subset (default read/grep/glob). Undefined
345
- * when the advisor is disabled.
346
- */
347
- advisorTools?: AgentTool[];
348
- /** Preloaded watchdog prompt content for the advisor. */
349
- advisorWatchdogPrompt?: string;
350
- /** Preloaded YAML top-level `instructions` shared baseline, kept separate from
351
- * `advisorWatchdogPrompt` so `/advisor configure` can swap it live. */
352
- advisorSharedInstructions?: string;
353
- /**
354
- * Preloaded project context files (AGENTS.md, etc.) rendered as a system-prompt
355
- * block for the advisor — the same standing instructions the primary agent
356
- * receives, so the reviewer holds the agent to them.
357
- */
358
- advisorContextPrompt?: string;
359
- /**
360
- * Advisors discovered from `WATCHDOG.yml`. Empty/undefined runs a single
361
- * legacy advisor on the `advisor` role (byte-for-byte the pre-config path).
362
- */
363
- advisorConfigs?: AdvisorConfig[];
364
- /**
365
- * Strip tool descriptions from provider-bound tool specs on side requests
366
- * (handoff). Must match the session-start value used to build the system
367
- * prompt so inline descriptors are not also sent through provider schemas.
368
- */
369
- pruneToolDescriptions?: boolean;
370
- /**
371
- * Disconnect this session's OWNED MCP manager on dispose. Provided only when
372
- * the session created the manager (top-level sessions); subagents reuse a
373
- * parent's manager via `options.mcpManager` and omit this so a child's
374
- * teardown never tears down the shared servers.
375
- */
376
- disconnectOwnedMcpManager?: () => Promise<void>;
377
- /**
378
- * Override the bundled system prompt used by automatic session-title
379
- * generation paths (initial title + replan refresh). Source-of-truth is
380
- * `TITLE_SYSTEM.md` discovered via {@link discoverTitleSystemPromptFile} and
381
- * resolved through {@link resolvePromptInput}; refresh after a `/move`-style
382
- * cwd change via {@link AgentSession.setTitleSystemPrompt}.
383
- */
384
- titleSystemPrompt?: string;
385
- }
386
- /** Options for AgentSession.prompt() */
387
- export interface PromptOptions {
388
- /** Whether to expand file-based prompt templates (default: true) */
389
- expandPromptTemplates?: boolean;
390
- /** Image attachments */
391
- images?: ImageContent[];
392
- /** When streaming, how to queue the message: "steer" (interrupt) or "followUp" (wait). */
393
- streamingBehavior?: "steer" | "followUp";
394
- /** Optional tool choice override for the next LLM call. */
395
- toolChoice?: ToolChoice;
396
- /** Send as developer/system message instead of user. Providers that support it use the developer role; others fall back to user. */
397
- synthetic?: boolean;
398
- /** Marks this prompt as a deliberate user action (typed message, `.`/`c`
399
- * continue). Clears advisor auto-resume suppression that a user interrupt set.
400
- * Defaults to `!synthetic`; manual-continue is synthetic yet user-initiated, so
401
- * it sets this explicitly. Agent-initiated synthetic prompts (auto-continue,
402
- * plan re-prime, reminders) leave it unset and keep suppression latched. */
403
- userInitiated?: boolean;
404
- /** Explicit billing/initiator attribution for the prompt. Defaults to user prompts as `user` and synthetic prompts as `agent`. */
405
- attribution?: MessageAttribution;
406
- /** Skip pre-send compaction checks for this prompt (internal use for maintenance flows). */
407
- skipCompactionCheck?: boolean;
408
- }
409
- /** Options for AgentSession.followUp() */
410
- export interface FollowUpOptions {
411
- /** Enqueue as a hidden developer message (agent-attributed by default) instead of a user follow-up. */
412
- synthetic?: boolean;
413
- /** Whether to expand file-based prompt templates (default: true). */
414
- expandPromptTemplates?: boolean;
415
- /** Explicit billing/initiator attribution. Defaults to `agent` for synthetic follow-ups. */
416
- attribution?: MessageAttribution;
417
- }
418
- /** Result from a handoff operation. */
419
- export interface HandoffResult {
420
- document: string;
421
- savedPath?: string;
422
- }
423
- export interface SessionHandoffOptions {
424
- autoTriggered?: boolean;
425
- signal?: AbortSignal;
426
- onSwitchCancelled?: () => void;
427
- }
428
- /** Result from cycleModel() */
429
- export interface ModelCycleResult {
430
- model: Model;
431
- thinkingLevel: ThinkingLevel | undefined;
432
- /** Whether cycling through scoped models (--models flag) or all available */
433
- isScoped: boolean;
434
- }
435
- /** Result from cycleRoleModels() */
436
- export interface RoleModelCycleResult {
437
- model: Model;
438
- thinkingLevel: ThinkingLevel | undefined;
439
- role: string;
440
- }
441
- /** A configured role resolved to a concrete model, used by role cycling and
442
- * the plan-approval model slider. */
443
- export interface ResolvedRoleModel {
444
- role: string;
445
- model: Model;
446
- thinkingLevel?: ConfiguredThinkingLevel;
447
- explicitThinkingLevel: boolean;
448
- }
449
- /** The set of resolvable role models plus the index of the currently active
450
- * one within {@link ResolvedRoleModel.role} order. */
451
- export interface RoleModelCycle {
452
- models: ResolvedRoleModel[];
453
- currentIndex: number;
454
- }
455
- export interface ContextUsageBreakdown {
456
- contextWindow: number;
457
- anchored: boolean;
458
- usedTokens: number;
459
- systemPromptTokens: number;
460
- systemToolsTokens: number;
461
- systemContextTokens: number;
462
- skillsTokens: number;
463
- messagesTokens: number;
464
- }
465
- /** Session statistics for /session command */
466
- export interface SessionStats {
467
- sessionFile: string | undefined;
468
- sessionId: string;
469
- userMessages: number;
470
- assistantMessages: number;
471
- toolCalls: number;
472
- toolResults: number;
473
- totalMessages: number;
474
- tokens: {
475
- input: number;
476
- output: number;
477
- reasoning: number;
478
- cacheRead: number;
479
- cacheWrite: number;
480
- total: number;
481
- };
482
- premiumRequests: number;
483
- cost: number;
484
- contextUsage?: ContextUsage;
485
- }
486
- /** Advisor statistics for /advisor status command. */
487
- export interface AdvisorStats {
488
- configured: boolean;
489
- active: boolean;
490
- model?: Model;
491
- contextWindow: number;
492
- contextTokens: number;
493
- tokens: {
494
- input: number;
495
- output: number;
496
- reasoning: number;
497
- cacheRead: number;
498
- cacheWrite: number;
499
- total: number;
500
- };
501
- cost: number;
502
- messages: {
503
- user: number;
504
- assistant: number;
505
- total: number;
506
- };
507
- /** Per-advisor breakdown; one entry per active advisor (single-advisor sessions have one). */
508
- advisors: PerAdvisorStat[];
509
- }
510
- /** One advisor's slice of {@link AdvisorStats}. Active advisors carry full
511
- * token/cost data; disabled/no-model/quota-exhausted advisors appear with
512
- * just `name` + `status` so the status line can render a dot for every
513
- * configured advisor. */
514
- export interface PerAdvisorStat {
515
- name: string;
516
- status: AdvisorRuntimeStatus;
517
- model?: Model;
518
- contextWindow: number;
519
- contextTokens: number;
520
- tokens: AdvisorStats["tokens"];
521
- cost: number;
522
- messages: AdvisorStats["messages"];
523
- sessionId?: string;
524
- }
525
- export interface FreshSessionResult {
526
- previousSessionId: string;
527
- sessionId: string;
528
- closedProviderSessions: number;
529
- }
530
- /** Entry returned by {@link AgentSession.clearQueue} / {@link AgentSession.popLastQueuedMessage}. */
531
- export type RestoredQueuedMessage = {
532
- text: string;
533
- images?: ImageContent[];
534
- };
535
- /**
536
- * Emit a warn-level log for a turn that ended in a provider error so recurring
537
- * stream failures are diagnosable from the main log alone. The `agent_end`
538
- * routing trace is debug-only and omits the error fields; without this a
539
- * session dying on provider errors leaves only `stopReason:"error"` debug lines
540
- * and the real cause lives solely in the session transcript (issue #6177).
541
- * No-op for any non-error stop reason.
542
- */
543
- export declare function logProviderTurnError(msg: AssistantMessage): void;
61
+ export * from "./agent-session-events.js";
62
+ export * from "./agent-session-types.js";
63
+ export type { AdvisorStats, PerAdvisorStat } from "./session-advisors.js";
544
64
  type SessionNameTrigger = "replan";
545
65
  export declare class AgentSession {
546
66
  #private;
@@ -557,11 +77,7 @@ export declare class AgentSession {
557
77
  readonly configWarnings: string[];
558
78
  readonly rawSseDebugBuffer: RawSseDebugBuffer;
559
79
  /**
560
- * Arm prewalk outside the normal startup path (the `/prewalk` slash
561
- * command): sets the target and immediately steers the plan nudge rather
562
- * than waiting for the next turn boundary, since an explicit manual
563
- * invocation means "start this now." A no-op with a notice if a prewalk
564
- * is already armed and waiting.
80
+ * Arm prewalk outside the normal startup path so an explicit slash command starts immediately.
565
81
  */
566
82
  armPrewalk(target: Model, thinkingLevel?: ConfiguredThinkingLevel): void;
567
83
  /** Validate the active plan artifact and shape an `xd://propose` result for review-mode hosts. */
@@ -599,6 +115,7 @@ export declare class AgentSession {
599
115
  peekQueueInvoker(): ((input: unknown) => Promise<unknown> | unknown) | undefined;
600
116
  peekPlanProposalHandler(): PlanProposalHandler | undefined;
601
117
  setPlanProposalHandler(handler: PlanProposalHandler | null): void;
118
+ setSessionBeforeSwitchReconciler(reconciler: (() => Promise<void>) | null): void;
602
119
  setSessionSwitchReconciler(reconciler: (() => Promise<void>) | null): void;
603
120
  /** Provider-scoped mutable state store for transport/session caches. */
604
121
  get providerSessionState(): Map<string, ProviderSessionState>;
@@ -627,6 +144,23 @@ export declare class AgentSession {
627
144
  getAsyncJobSnapshot(options?: {
628
145
  recentLimit?: number;
629
146
  }): AsyncJobSnapshot | null;
147
+ /**
148
+ * Public view of the pending-async-wake state for run drivers: true while
149
+ * owner-scoped async work can still re-wake this session's run (a running
150
+ * background job with an unsuppressed delivery, or a queued / in-flight
151
+ * delivery). The task executor's quiescence barrier polls this to
152
+ * distinguish a scheduling pause from terminal completion.
153
+ */
154
+ hasPendingAsyncWork(): boolean;
155
+ /**
156
+ * Settle one generation of owner-scoped async work: wait for running owner
157
+ * jobs to finish, deliver their queued results (which enqueue async-result
158
+ * follow-ups on this session's yield queue), and wait for the injected
159
+ * follow-up turn(s) to go idle. Callers loop while
160
+ * {@link hasPendingAsyncWork} still holds — a follow-up turn may start new
161
+ * jobs.
162
+ */
163
+ settleAsyncWork(): Promise<void>;
630
164
  /**
631
165
  * Emit a UI-only notice to the session. Surfaces in interactive mode as a
632
166
  * `showWarning` / `showError` / `showStatus` line; non-interactive modes
@@ -666,6 +200,10 @@ export declare class AgentSession {
666
200
  get state(): AgentState;
667
201
  /** Current model (may be undefined if not yet selected) */
668
202
  get model(): Model | undefined;
203
+ /** Resolved selector while retry routing is using a fallback model. */
204
+ get retryFallbackModel(): string | undefined;
205
+ /** Install the interactive decision surface for reserve-triggered model changes. */
206
+ setUsageFallbackConfirmer(confirmer: ((confirmation: UsageFallbackConfirmation) => Promise<boolean>) | undefined): void;
669
207
  /** Effective thinking level applied to the agent (the resolved level when `auto`). */
670
208
  get thinkingLevel(): ThinkingLevel | undefined;
671
209
  /** The selector the user configured: `auto` when auto mode is active, else the effective level. */
@@ -679,7 +217,7 @@ export declare class AgentSession {
679
217
  /** Whether agent is currently streaming a response */
680
218
  get isStreaming(): boolean;
681
219
  get isAborting(): boolean;
682
- /** Wait until streaming and deferred recovery work are fully settled. */
220
+ /** Wait until streaming, event persistence, and deferred recovery work are fully settled. */
683
221
  waitForIdle(): Promise<void>;
684
222
  /**
685
223
  * Prevent advisor notes from starting hidden primary turns while a headless
@@ -706,84 +244,69 @@ export declare class AgentSession {
706
244
  get systemPrompt(): string[];
707
245
  /** Current retry attempt (0 if not retrying) */
708
246
  get retryAttempt(): number;
709
- /**
710
- * Get the names of currently active tools.
711
- * Returns the names of tools currently set on the agent.
712
- */
247
+ /** Names of tools currently exposed at the top level. */
713
248
  getActiveToolNames(): string[];
714
- /**
715
- * Enabled tool names: top-level active tools plus discoverable tools mounted
716
- * under `xd://`. Reconcile callers (MCP refresh, discovery, plan/goal mode)
717
- * build their next active set from this so a mount survives an active-set
718
- * change; {@link getActiveToolNames} stays the top-level-only view.
719
- */
249
+ /** Enabled top-level and discoverable tool names. */
720
250
  getEnabledToolNames(): string[];
721
- /** Names of discoverable tools currently mounted under `xd://` (dynamic mounts). */
251
+ /** Names of dynamic tools mounted under `xd://`. */
722
252
  getMountedXdevToolNames(): string[];
723
253
  /** Whether the edit tool is registered in this session. */
724
254
  get hasEditTool(): boolean;
725
- /**
726
- * Get a tool by name from the registry.
727
- */
255
+ /** Looks up a registered tool by name. */
728
256
  getToolByName(name: string): AgentTool | undefined;
729
- /** True when the current registry entry for `name` came from a built-in factory. */
257
+ /** Whether a registry entry came from a built-in factory. */
730
258
  hasBuiltInTool(name: string): boolean;
731
- /**
732
- * Get all configured tool names (built-in via --tools or default, plus custom tools).
733
- */
259
+ /** Names of every registered tool. */
734
260
  getAllToolNames(): string[];
735
- /**
736
- * Registers the ephemeral vibe tools and activates them alongside `baseToolNames`.
737
- *
738
- * @throws When this session cannot create vibe tools or the factory returns duplicate names.
739
- */
261
+ /** Installs and activates the ephemeral vibe tool set. */
740
262
  activateVibeTools(baseToolNames: string[]): Promise<void>;
741
- /** Removes tools installed by {@link activateVibeTools} and activates `nextToolNames`. */
263
+ /** Uninstalls vibe tools and activates the replacement set. */
742
264
  deactivateVibeTools(nextToolNames: string[]): Promise<void>;
265
+ /** Removes vibe tools without restoring a source-session snapshot. */
266
+ removeVibeToolsPreservingActive(): Promise<void>;
267
+ /** Enabled MCP tools in their current presentation partition. */
743
268
  getSelectedMCPToolNames(): string[];
744
- /**
745
- * Rediscover disk-backed skills and rebuild prompt-facing state without
746
- * recreating the session. Explicit skill snapshots (`--no-skills`,
747
- * SDK-provided `skills`) remain fixed for the lifetime of the session.
748
- */
269
+ /** Rediscovers reloadable skills and refreshes prompt metadata. */
749
270
  refreshSkills(): Promise<void>;
750
- /**
751
- * Set active tools by name.
752
- * Only tools in the registry can be enabled. Unknown tool names are ignored.
753
- * Also rebuilds the system prompt to reflect the new tool set.
754
- * Changes take effect before the next model call.
755
- */
271
+ /** Selects enabled tools, ignoring names absent from the registry. */
756
272
  setActiveToolsByName(toolNames: string[]): Promise<void>;
757
- /**
758
- * Restore an enabled tool set with its exact top-level versus `xd://` partition.
759
- *
760
- * Both inputs are required because {@link setActiveToolsByName} only receives the
761
- * enabled name list and classifies mounts from the *current* `#mountedXdevToolNames`.
762
- * Rollback/restore callers must pass the snapshotted mounted subset so names that
763
- * were top-level stay pinned (`#runtimeSelectedToolNames`) and names that were under
764
- * `xd://` remain mount-eligible, even when the live mount set has drifted.
765
- *
766
- * Names outside `mountedToolNames` are pinned top-level for this application;
767
- * names in the mounted subset remain eligible for xdev mounting. Delegates the
768
- * actual apply through `#applyActiveToolsByName` and restores the prior runtime
769
- * selection if that apply throws.
770
- */
273
+ /** Restores an exact top-level versus `xd://` tool partition. */
771
274
  setActiveToolPresentation(toolNames: string[], mountedToolNames: string[]): Promise<void>;
772
- /** Rebuild the base system prompt using the current active tool set. */
275
+ /** Cancels the local rollout-memory startup owned by this session. */
276
+ cancelLocalMemoryStartup(): void;
277
+ /** Starts a new local rollout-memory generation and cancels its predecessor. */
278
+ beginLocalMemoryStartup(): AbortSignal;
279
+ /** Releases the local startup slot if `signal` still owns it. */
280
+ endLocalMemoryStartup(signal: AbortSignal): void;
281
+ /** Applies the selected memory backend to runtime state, tools, and prompt. */
282
+ applyMemoryBackend(): Promise<void>;
283
+ /** Rebuilds the stable base prompt for the current tools and model. */
773
284
  refreshBaseSystemPrompt(): Promise<void>;
774
- /**
775
- * Replace MCP tools in the registry and enable them immediately. Every
776
- * connected MCP tool becomes available (mounted under `xd://` when that
777
- * transport is active, else top-level). Lets `/mcp add/remove/reauth` take
778
- * effect without restarting the session.
779
- */
285
+ /** Replaces connected MCP tools and enables them immediately. */
780
286
  refreshMCPTools(mcpTools: CustomTool[]): Promise<void>;
781
- /**
782
- * Replace RPC host-owned tools and refresh the active tool set before the next model call.
783
- */
287
+ /** Replaces host-owned RPC tools before the next model call. */
784
288
  refreshRpcHostTools(rpcTools: AgentTool[]): Promise<void>;
785
289
  /** Whether auto-compaction is currently running */
786
290
  get isCompacting(): boolean;
291
+ /** Strip image content from the current branch and persist the rewrite. */
292
+ dropImages(): Promise<{
293
+ removed: number;
294
+ }>;
295
+ /** Reduce stored context with the selected shake strategy. */
296
+ shake(mode: ShakeMode, opts?: {
297
+ config?: ShakeConfig;
298
+ signal?: AbortSignal;
299
+ }): Promise<ShakeResult>;
300
+ /** Compact the active session history. */
301
+ compact(customInstructions?: string, options?: CompactOptions): Promise<CompactionResult>;
302
+ /** Cancel active manual, automatic, and handoff maintenance. */
303
+ abortCompaction(): void;
304
+ /** Trigger idle compaction through the automatic maintenance flow. */
305
+ runIdleCompaction(): Promise<void>;
306
+ /** Toggle automatic compaction. */
307
+ setAutoCompactionEnabled(enabled: boolean): void;
308
+ /** Whether automatic compaction is enabled. */
309
+ get autoCompactionEnabled(): boolean;
787
310
  /**
788
311
  * Whether idle-flush tasks, auto-continuations, or other short-lived
789
312
  * post-prompt work are pending. True in the brief window after
@@ -808,7 +331,10 @@ export declare class AgentSession {
808
331
  * Transcript for TUI display. Full history is kept for export/resume-style
809
332
  * callers; live chat can collapse compacted history to keep the hot render
810
333
  * surface bounded. Display-only — NEVER feed the result to
811
- * `agent.replaceMessages` or a provider.
334
+ * `agent.replaceMessages` or a provider. Because it is never re-obfuscated,
335
+ * it opts into legacy index-derived alias restoration so pre-keyed sessions
336
+ * still render their secrets; the agent-feeding paths
337
+ * (`buildDisplaySessionContext`) keep the keyed-only default.
812
338
  */
813
339
  buildTranscriptSessionContext(options?: Pick<BuildSessionContextOptions, "collapseCompactedHistory" | "keepDanglingToolCalls">): SessionContext;
814
340
  /** Convert session messages using the same pre-LLM pipeline as the active session. */
@@ -1030,6 +556,8 @@ export declare class AgentSession {
1030
556
  * @returns true if completed, false if cancelled by hook or not persisting
1031
557
  */
1032
558
  fork(): Promise<boolean>;
559
+ /** Move the active session and artifacts after enforcing mode transition invariants. */
560
+ moveSession(newCwd: string, targetSessionDir?: string): Promise<void>;
1033
561
  /**
1034
562
  * Set model directly.
1035
563
  * Validates that a credential source is configured (synchronously, without
@@ -1047,93 +575,35 @@ export declare class AgentSession {
1047
575
  }): Promise<{
1048
576
  switched: boolean;
1049
577
  }>;
1050
- /**
1051
- * Set model temporarily (for this session only).
1052
- * Validates that a credential source is configured (synchronously, without
1053
- * refreshing OAuth or running command-backed key programs), saves to session
1054
- * log but NOT to settings.
1055
- * @throws Error if no API key available for the model
1056
- */
578
+ /** Selects a model for this session without updating persisted model settings. */
1057
579
  setModelTemporary(model: Model, thinkingLevel?: ConfiguredThinkingLevel, options?: {
1058
580
  ephemeral?: boolean;
1059
581
  }): Promise<void>;
1060
- /**
1061
- * Cycle to next/previous model.
1062
- * Uses scoped models (from --models flag) if available, otherwise all available models.
1063
- * @param direction - "forward" (default) or "backward"
1064
- * @returns The new model info, or undefined if only one model available
1065
- */
582
+ /** Cycles the scoped model set, or all available models when no scope exists. */
1066
583
  cycleModel(direction?: "forward" | "backward"): Promise<ModelCycleResult | undefined>;
1067
- /**
1068
- * Resolve the configured role models in the given order plus the index of
1069
- * the currently active one. Roles that have no configured model, or whose
1070
- * configured model is not currently available, are skipped. The `default`
1071
- * role falls back to the active model when no explicit assignment exists.
1072
- *
1073
- * Returns `undefined` only when there is no current model or no available
1074
- * models at all; an empty `models` array is never returned (callers should
1075
- * still guard on `models.length`).
1076
- */
584
+ /** Resolves configured role models and the currently active role index. */
1077
585
  getRoleModelCycle(roleOrder: readonly string[]): RoleModelCycle | undefined;
1078
- /**
1079
- * Apply a resolved role model as the active model without changing global
1080
- * settings. Shared with role cycling and the plan-approval model slider.
1081
- */
586
+ /** Applies a resolved role model without changing global settings. */
1082
587
  applyRoleModel(entry: ResolvedRoleModel): Promise<void>;
1083
- /**
1084
- * Cycle through configured role models in a fixed order.
1085
- * Skips missing roles and changes only the active session model.
1086
- * @param roleOrder - Order of roles to cycle through (e.g., ["slow", "default", "smol"])
1087
- * @param direction - "forward" (default) or "backward"
1088
- */
588
+ /** Cycles the configured role models in the supplied order. */
1089
589
  cycleRoleModels(roleOrder: readonly string[], direction?: "forward" | "backward"): Promise<RoleModelCycleResult | undefined>;
1090
- /**
1091
- * Get all available models with valid API keys, filtered by `enabledModels` when configured.
1092
- * See {@link filterAvailableModelsByEnabledPatterns} for supported pattern forms and limitations.
1093
- */
590
+ /** Lists available models after applying the configured enabled-model filter. */
1094
591
  getAvailableModels(): Model[];
1095
- /**
1096
- * Set the thinking level. `auto` enables per-turn classification. Entering
1097
- * auto writes its provisional level plus `configured: "auto"` immediately,
1098
- * giving external readers an authoritative selection receipt before the next
1099
- * user turn. Later classifications persist only changed concrete resolutions.
1100
- */
592
+ /** Selects the session thinking level and optionally persists it as the default. */
1101
593
  setThinkingLevel(level: ConfiguredThinkingLevel | undefined, persist?: boolean): void;
1102
- /**
1103
- * Cycle to next thinking level: off → auto → minimal..max → off.
1104
- * @returns New selector, or undefined if model doesn't support thinking
1105
- */
594
+ /** Advances through the thinking selectors supported by the active model. */
1106
595
  cycleThinkingLevel(): ConfiguredThinkingLevel | undefined;
1107
- /**
1108
- * True when the currently selected model's family is set to `priority` — the
1109
- * `/fast` on/off state for the active model. Returns false when no model is
1110
- * selected or the model exposes no service-tier family (e.g. Fireworks, which
1111
- * has its own Providers › Fireworks Tier toggle).
1112
- *
1113
- * For "is priority actually applied to the next request?" use
1114
- * {@link isFastModeActive} instead.
1115
- */
596
+ /** Reports whether `/fast` is enabled for the active model family. */
1116
597
  isFastModeEnabled(): boolean;
1117
- /**
1118
- * True when `priority` is actually realized on the wire for the currently
1119
- * selected model (OpenAI/Google `service_tier`, direct Anthropic fast mode,
1120
- * or Fireworks priority). Returns false for tiers the active model can't
1121
- * realize and when no model is selected.
1122
- */
598
+ /** Reports whether priority service is realized by the active model. */
1123
599
  isFastModeActive(): boolean;
1124
- /** Set one family's tier (or clear it with `undefined`); persists the change. */
600
+ /** Sets or clears one model family's live service tier. */
1125
601
  setServiceTierFamily(family: ServiceTierFamily, tier: ServiceTier | undefined): void;
1126
- /**
1127
- * `/fast on|off` targets the family of the currently selected model: it sets
1128
- * (or clears) that family's `priority` tier. Returns `false` when the model
1129
- * has no service-tier family, so callers can report that fast mode is
1130
- * unavailable instead of claiming success.
1131
- */
602
+ /** Enables or disables priority service for the active model family. */
1132
603
  setFastMode(enabled: boolean): boolean;
604
+ /** Toggles priority service for the active model family. */
1133
605
  toggleFastMode(): boolean;
1134
- /**
1135
- * Get available thinking levels for current model.
1136
- */
606
+ /** Lists thinking levels supported by the active model. */
1137
607
  getAvailableThinkingLevels(): ReadonlyArray<Effort>;
1138
608
  /**
1139
609
  * Set steering mode.
@@ -1150,51 +620,6 @@ export declare class AgentSession {
1150
620
  * Saves to settings.
1151
621
  */
1152
622
  setInterruptMode(mode: "immediate" | "wait"): void;
1153
- /**
1154
- * Strip image content blocks from every message on the current branch and
1155
- * persist the rewrite. Walks `SessionManager.getBranch()` in place — both
1156
- * `SessionMessageEntry.message` and `CustomMessageEntry.content` arrays
1157
- * are mutated, then `rewriteEntries` durably commits the new shape. The
1158
- * agent's runtime view is rebuilt from the freshly-mutated entries so any
1159
- * provider sessions caching message identity (Codex Responses) are torn
1160
- * down to force a clean replay on the next turn.
1161
- *
1162
- * No-op when the branch carries no images; returns `{ removed: 0 }` and
1163
- * skips the disk rewrite.
1164
- */
1165
- dropImages(): Promise<{
1166
- removed: number;
1167
- }>;
1168
- /**
1169
- * Surgically reduce context by dropping heavy content ("shake").
1170
- *
1171
- * - `images` delegates to {@link dropImages}.
1172
- * - `elide` replaces whole tool-call results and large fenced/XML blocks
1173
- * with short placeholders that embed an `artifact://` recovery link.
1174
- *
1175
- * Mutates the branch in place, persists via `rewriteEntries`, replays the
1176
- * rebuilt context through the agent, and tears down provider sessions that
1177
- * cache message identity — same rewrite contract as {@link dropImages}.
1178
- *
1179
- * No-op (zero counts) when nothing is eligible.
1180
- */
1181
- shake(mode: ShakeMode, opts?: {
1182
- config?: ShakeConfig;
1183
- signal?: AbortSignal;
1184
- }): Promise<ShakeResult>;
1185
- /**
1186
- * Manually compact the session context.
1187
- * Aborts current agent operation first.
1188
- * @param customInstructions Optional instructions for the compaction summary
1189
- * @param options Optional callbacks for completion/error handling
1190
- */
1191
- compact(customInstructions?: string, options?: CompactOptions): Promise<CompactionResult>;
1192
- /**
1193
- * Cancel in-progress context maintenance (manual compaction, auto-compaction, or auto-handoff).
1194
- */
1195
- abortCompaction(): void;
1196
- /** Trigger idle compaction through the auto-compaction flow (with UI events). */
1197
- runIdleCompaction(): Promise<void>;
1198
623
  /**
1199
624
  * Cancel in-progress branch summarization.
1200
625
  */
@@ -1215,39 +640,15 @@ export declare class AgentSession {
1215
640
  * @returns The handoff document text, or undefined if cancelled/failed
1216
641
  */
1217
642
  handoff(customInstructions?: string, options?: SessionHandoffOptions): Promise<HandoffResult | undefined>;
1218
- /**
1219
- * Toggle auto-compaction setting.
1220
- */
1221
- setAutoCompactionEnabled(enabled: boolean): void;
1222
- /** Whether auto-compaction is enabled */
1223
- get autoCompactionEnabled(): boolean;
1224
- /**
1225
- * Cancel in-progress retry.
1226
- */
643
+ /** Cancel an in-progress retry. */
1227
644
  abortRetry(): void;
1228
- /** Whether auto-retry is currently in progress */
645
+ /** Whether auto-retry is currently in progress. */
1229
646
  get isRetrying(): boolean;
1230
- /** Whether auto-retry is enabled */
647
+ /** Whether auto-retry is enabled. */
1231
648
  get autoRetryEnabled(): boolean;
1232
- /**
1233
- * Toggle auto-retry setting.
1234
- */
649
+ /** Toggle the auto-retry setting. */
1235
650
  setAutoRetryEnabled(enabled: boolean): void;
1236
- /**
1237
- * Manually retry the last failed assistant turn.
1238
- * Removes the error message from agent state and re-attempts with a fresh retry budget.
1239
- *
1240
- * A stream that stalls or aborts mid-tool-call ends the turn with
1241
- * `stopReason: "error" | "aborted"` and then appends one synthetic
1242
- * {@link isSyntheticToolResultMessage tool_result} per emitted tool call to
1243
- * preserve the provider's tool_use/tool_result pairing (see
1244
- * `createAbortedToolResult` in `agent-loop.ts`). Those placeholders trail the
1245
- * failed assistant turn, so the retry lookback walks back over them before
1246
- * checking the assistant message; it strips both the placeholders and the
1247
- * failed turn before re-attempting.
1248
- *
1249
- * @returns true if retry was initiated, false if no failed turn to retry or agent is busy
1250
- */
651
+ /** Retry the last failed assistant turn when the session is idle. */
1251
652
  retry(): Promise<boolean>;
1252
653
  /**
1253
654
  * Execute a bash command and retain the session/branch that owned its start.
@@ -1264,9 +665,7 @@ export declare class AgentSession {
1264
665
  recordBashResult(command: string, result: BashResult, options?: {
1265
666
  excludeFromContext?: boolean;
1266
667
  }): void;
1267
- /**
1268
- * Cancel running bash command.
1269
- */
668
+ /** Cancel running bash commands. */
1270
669
  abortBash(): void;
1271
670
  /** Whether a bash command is currently running */
1272
671
  get isBashRunning(): boolean;
@@ -1302,49 +701,18 @@ export declare class AgentSession {
1302
701
  /** Whether there are pending Python messages waiting to be flushed */
1303
702
  get hasPendingPythonMessages(): boolean;
1304
703
  /**
1305
- * Surfaces and consumes pending IRC incoming records before the next model
1306
- * step can inject them automatically.
1307
- *
1308
- * Tool results already expose the formatted body to the model. Leaving the
1309
- * same record in either pending IRC queue would deliver it a second time at
1310
- * the next step boundary — including on `peek`, which is why inbox peeks
1311
- * also drain here.
704
+ * Flush pending Python messages to agent state and session.
1312
705
  */
706
+ /** Surfaces and consumes pending IRC records before automatic injection. */
1313
707
  drainPendingIrcInboxMessages(agentId: string, opts?: {
1314
708
  from?: string;
1315
709
  limit?: number;
1316
710
  }): IrcMessage[];
1317
- /**
1318
- * Deliver an IRC message into this session (recipient side; called by the
1319
- * IrcBus). Emits the `irc_message` session event for UI cards and injects
1320
- * the rendered message into the model's context as an `irc:incoming`
1321
- * custom message:
1322
- *
1323
- * - mid-turn → queued on the aside channel and folded in at the next step
1324
- * boundary (non-interrupting, like async-result deliveries) → "injected";
1325
- * - idle in plan mode → appended into context without waking an autonomous
1326
- * turn (convergence stays user-driven) → "injected";
1327
- * - idle → starts a real turn with the message so the recipient wakes
1328
- * → "woken".
1329
- *
1330
- * Never blocks on the recipient's turn: the wake turn is fire-and-forget.
1331
- *
1332
- * When the sender expects a reply (`send await:true`) and this session
1333
- * cannot produce a real reply turn in time — mid-turn with async execution
1334
- * disabled (the next step boundary may be gated on the sender's own batch
1335
- * finishing), or idle in plan mode (wake turns are suppressed) — an
1336
- * ephemeral side-channel auto-reply is generated from the current context
1337
- * (the old `respondAsBackground` path) and sent back over the bus on this
1338
- * agent's behalf.
1339
- */
711
+ /** Delivers an IRC message into this recipient session. */
1340
712
  deliverIrcMessage(msg: IrcMessage, opts?: {
1341
713
  expectsReply?: boolean;
1342
714
  }): Promise<"injected" | "woken">;
1343
- /**
1344
- * Emit an IRC relay observation event on this session for UI rendering only.
1345
- * Does not persist the record to history. Called by the IrcBus to surface
1346
- * agent↔agent traffic on the main session.
1347
- */
715
+ /** Emits an IRC relay observation for UI rendering without persisting it. */
1348
716
  emitIrcRelayObservation(record: CustomMessage): void;
1349
717
  /**
1350
718
  * Run a single ephemeral side-channel turn against this session's current
@@ -1494,6 +862,8 @@ export declare class AgentSession {
1494
862
  */
1495
863
  get contextUsageRevision(): number;
1496
864
  fetchUsageReports(signal?: AbortSignal): Promise<UsageReport[] | null>;
865
+ /** Models whose live `/usage` reports map to a quantitative provider scope. */
866
+ getUsageReportingModelSelectors(reports: readonly UsageReport[]): string[];
1497
867
  /**
1498
868
  * Redeem one saved Codex rate-limit reset for a specific account, injecting
1499
869
  * the provider base URL like {@link AgentSession.fetchUsageReports}. Powers
@@ -1509,10 +879,10 @@ export declare class AgentSession {
1509
879
  listResetCredits(signal?: AbortSignal): Promise<ResetCreditAccountStatus[]>;
1510
880
  /**
1511
881
  * Export session to HTML.
1512
- * @param outputPath Optional output path (defaults to session directory)
1513
- * @returns Path to exported file
882
+ * @param outputPath Optional output path
883
+ * @param useUserThemes Bundle the dark and light TUI themes selected in settings
1514
884
  */
1515
- exportToHtml(outputPath?: string): Promise<string>;
885
+ exportToHtml(outputPath?: string, useUserThemes?: boolean): Promise<string>;
1516
886
  /**
1517
887
  * Get text content of last assistant message.
1518
888
  * Useful for /copy command.