@oh-my-pi/pi-coding-agent 17.0.9 → 17.1.1

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 (349) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +1 -1
  3. package/dist/cli.js +4685 -4614
  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/model-registry.d.ts +3 -1
  10. package/dist/types/config/models-config-schema.d.ts +18 -6
  11. package/dist/types/config/models-config.d.ts +14 -5
  12. package/dist/types/config/provider-globals.d.ts +2 -2
  13. package/dist/types/config/service-tier.d.ts +5 -1
  14. package/dist/types/config/settings-schema.d.ts +374 -47
  15. package/dist/types/config/settings.d.ts +7 -0
  16. package/dist/types/dap/client.d.ts +20 -0
  17. package/dist/types/exec/bash-executor.d.ts +38 -0
  18. package/dist/types/exec/direnv.d.ts +33 -0
  19. package/dist/types/export/html/args.d.ts +15 -0
  20. package/dist/types/export/html/index.d.ts +11 -26
  21. package/dist/types/export/html/web-palette.d.ts +55 -116
  22. package/dist/types/extensibility/extensions/loader.d.ts +3 -0
  23. package/dist/types/extensibility/extensions/types.d.ts +17 -2
  24. package/dist/types/extensibility/legacy-pi-coding-agent-shim.d.ts +3 -0
  25. package/dist/types/extensibility/plugins/legacy-pi-compat.d.ts +13 -0
  26. package/dist/types/live/attestation.d.ts +2 -0
  27. package/dist/types/live/controller.d.ts +48 -0
  28. package/dist/types/live/protocol.d.ts +85 -0
  29. package/dist/types/live/protocol.test.d.ts +1 -0
  30. package/dist/types/live/transport.d.ts +35 -0
  31. package/dist/types/live/visualizer.d.ts +30 -0
  32. package/dist/types/lsp/client.d.ts +16 -1
  33. package/dist/types/mcp/config-writer.test.d.ts +1 -0
  34. package/dist/types/mcp/oauth-discovery.d.ts +2 -0
  35. package/dist/types/mcp/smithery-auth.d.ts +1 -1
  36. package/dist/types/mcp/smithery-auth.test.d.ts +1 -0
  37. package/dist/types/memory-backend/tool-names.d.ts +2 -0
  38. package/dist/types/modes/components/assistant-message.d.ts +1 -0
  39. package/dist/types/modes/components/custom-message.d.ts +1 -1
  40. package/dist/types/modes/components/login-dialog.d.ts +2 -2
  41. package/dist/types/modes/components/message-frame.d.ts +8 -4
  42. package/dist/types/modes/components/plan-review-overlay.d.ts +26 -0
  43. package/dist/types/modes/components/session-account-selector.d.ts +11 -0
  44. package/dist/types/modes/components/settings-defs.d.ts +7 -1
  45. package/dist/types/modes/components/status-line/component.jj-cache.test.d.ts +1 -0
  46. package/dist/types/modes/components/tool-execution.d.ts +9 -1
  47. package/dist/types/modes/controllers/command-controller.d.ts +1 -1
  48. package/dist/types/modes/controllers/event-controller.d.ts +6 -1
  49. package/dist/types/modes/controllers/live-command-controller.d.ts +14 -0
  50. package/dist/types/modes/controllers/selector-controller.d.ts +1 -0
  51. package/dist/types/modes/interactive-mode.d.ts +6 -0
  52. package/dist/types/modes/theme/theme.d.ts +1 -1
  53. package/dist/types/modes/types.d.ts +4 -1
  54. package/dist/types/modes/utils/context-usage.d.ts +12 -2
  55. package/dist/types/plan-mode/plan-files.d.ts +10 -0
  56. package/dist/types/registry/agent-lifecycle.d.ts +21 -9
  57. package/dist/types/registry/agent-registry.d.ts +11 -4
  58. package/dist/types/sdk.d.ts +15 -1
  59. package/dist/types/secrets/index.d.ts +15 -2
  60. package/dist/types/secrets/obfuscator.d.ts +113 -15
  61. package/dist/types/session/acp-permission-gate.d.ts +19 -0
  62. package/dist/types/session/agent-session-events.d.ts +84 -0
  63. package/dist/types/session/agent-session-types.d.ts +321 -0
  64. package/dist/types/session/agent-session.d.ts +135 -753
  65. package/dist/types/session/async-job-delivery.d.ts +28 -0
  66. package/dist/types/session/auth-storage.d.ts +1 -1
  67. package/dist/types/session/bash-runner.d.ts +75 -0
  68. package/dist/types/session/blob-store.d.ts +11 -1
  69. package/dist/types/session/blob-store.test.d.ts +1 -0
  70. package/dist/types/session/checkpoint-entries.d.ts +28 -0
  71. package/dist/types/session/eval-runner.d.ts +51 -0
  72. package/dist/types/session/irc-bridge.d.ts +46 -0
  73. package/dist/types/session/messages.d.ts +24 -0
  74. package/dist/types/session/model-controls.d.ts +180 -0
  75. package/dist/types/session/prewalk.d.ts +46 -0
  76. package/dist/types/session/queued-messages.d.ts +22 -0
  77. package/dist/types/session/redis-session-storage.d.ts +1 -0
  78. package/dist/types/session/retry-fallback-chains.d.ts +74 -0
  79. package/dist/types/session/role-models.d.ts +15 -0
  80. package/dist/types/session/session-advisors.d.ts +228 -0
  81. package/dist/types/session/session-entries.d.ts +8 -0
  82. package/dist/types/session/session-handoff.d.ts +70 -0
  83. package/dist/types/session/session-history-format.d.ts +6 -1
  84. package/dist/types/session/session-maintenance.d.ts +246 -0
  85. package/dist/types/session/session-manager.d.ts +41 -0
  86. package/dist/types/session/session-memory.d.ts +56 -0
  87. package/dist/types/session/session-provider-boundary.d.ts +62 -0
  88. package/dist/types/session/session-stats.d.ts +48 -0
  89. package/dist/types/session/session-tools.d.ts +158 -0
  90. package/dist/types/session/session-workspace.d.ts +32 -0
  91. package/dist/types/session/stream-guards.d.ts +44 -0
  92. package/dist/types/session/streaming-output.d.ts +8 -0
  93. package/dist/types/session/todo-tracker.d.ts +56 -0
  94. package/dist/types/session/ttsr-coordinator.d.ts +51 -0
  95. package/dist/types/session/turn-recovery.d.ts +225 -0
  96. package/dist/types/slash-commands/helpers/session-pin.d.ts +9 -0
  97. package/dist/types/stt/index.d.ts +0 -2
  98. package/dist/types/stt/stt-controller.d.ts +7 -0
  99. package/dist/types/system-prompt.d.ts +2 -0
  100. package/dist/types/task/executor.d.ts +4 -1
  101. package/dist/types/task/output-manager.d.ts +3 -1
  102. package/dist/types/tiny/title-client.d.ts +10 -0
  103. package/dist/types/tools/approval.d.ts +1 -0
  104. package/dist/types/tools/browser/launch.d.ts +5 -0
  105. package/dist/types/tools/builtin-names.d.ts +1 -1
  106. package/dist/types/tools/computer/protocol.d.ts +43 -0
  107. package/dist/types/tools/computer/supervisor.d.ts +32 -0
  108. package/dist/types/tools/computer/worker-entry.d.ts +1 -0
  109. package/dist/types/tools/computer/worker.d.ts +15 -0
  110. package/dist/types/tools/computer-renderer.d.ts +22 -0
  111. package/dist/types/tools/computer.d.ts +71 -0
  112. package/dist/types/tools/context.d.ts +2 -0
  113. package/dist/types/tools/default-renderer.d.ts +21 -0
  114. package/dist/types/tools/image-gen.d.ts +4 -4
  115. package/dist/types/tools/image-providers.d.ts +38 -0
  116. package/dist/types/tools/index.d.ts +7 -0
  117. package/dist/types/tools/path-utils.d.ts +8 -0
  118. package/dist/types/tools/todo.d.ts +10 -4
  119. package/dist/types/tools/xdev.d.ts +5 -1
  120. package/dist/types/tts/streaming-player.d.ts +10 -29
  121. package/dist/types/tts/vocalizer.d.ts +5 -0
  122. package/dist/types/utils/jj.d.ts +29 -0
  123. package/dist/types/utils/lang-from-path.d.ts +1 -0
  124. package/dist/types/utils/title-generator.d.ts +30 -0
  125. package/dist/types/utils/tools-manager.d.ts +1 -2
  126. package/dist/types/vibe/runtime.d.ts +36 -8
  127. package/dist/types/web/search/index.d.ts +1 -1
  128. package/dist/types/web/search/provider.d.ts +15 -5
  129. package/dist/types/web/search/types.d.ts +94 -0
  130. package/package.json +12 -12
  131. package/scripts/generate-share-viewer.ts +4 -6
  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 +3 -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/setup-cli.ts +2 -14
  141. package/src/cli/usage-cli.ts +10 -1
  142. package/src/cli.ts +8 -0
  143. package/src/collab/host.ts +3 -2
  144. package/src/commands/bench.ts +18 -4
  145. package/src/commands/launch.ts +4 -0
  146. package/src/config/model-registry.ts +16 -2
  147. package/src/config/models-config-schema.ts +15 -4
  148. package/src/config/provider-globals.ts +9 -9
  149. package/src/config/service-tier.ts +26 -1
  150. package/src/config/settings-schema.ts +270 -51
  151. package/src/config/settings.ts +81 -2
  152. package/src/dap/client.ts +37 -4
  153. package/src/edit/index.ts +49 -12
  154. package/src/eval/executor-base.ts +1 -0
  155. package/src/eval/js/executor.ts +2 -0
  156. package/src/eval/py/executor.ts +103 -33
  157. package/src/exec/bash-executor.ts +90 -6
  158. package/src/exec/direnv.ts +145 -0
  159. package/src/export/html/args.ts +20 -0
  160. package/src/export/html/index.ts +45 -47
  161. package/src/export/html/template.css +19 -1
  162. package/src/export/html/template.html +6 -0
  163. package/src/export/html/template.js +21 -0
  164. package/src/export/html/tool-views.generated.js +31 -31
  165. package/src/export/html/web-palette.ts +116 -132
  166. package/src/export/share.ts +249 -49
  167. package/src/extensibility/extensions/loader.ts +29 -1
  168. package/src/extensibility/extensions/runner.ts +6 -0
  169. package/src/extensibility/extensions/types.ts +33 -2
  170. package/src/extensibility/extensions/wrapper.ts +68 -12
  171. package/src/extensibility/legacy-pi-coding-agent-shim.ts +7 -1
  172. package/src/extensibility/plugins/legacy-pi-compat.ts +19 -1
  173. package/src/hindsight/state.ts +64 -6
  174. package/src/internal-urls/local-protocol.ts +2 -1
  175. package/src/internal-urls/memory-protocol.ts +2 -2
  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/attestation.ts +91 -0
  180. package/src/live/controller.ts +517 -0
  181. package/src/live/prompts/agent-final-message.md +3 -0
  182. package/src/live/prompts/live-instructions.md +23 -0
  183. package/src/live/protocol.test.ts +140 -0
  184. package/src/live/protocol.ts +233 -0
  185. package/src/live/transport.ts +422 -0
  186. package/src/live/visualizer.ts +214 -0
  187. package/src/lsp/client.ts +29 -9
  188. package/src/lsp/index.ts +19 -4
  189. package/src/main.ts +8 -1
  190. package/src/mcp/config-writer.test.ts +43 -0
  191. package/src/mcp/config-writer.ts +109 -82
  192. package/src/mcp/oauth-discovery.ts +10 -2
  193. package/src/mcp/smithery-auth.test.ts +29 -0
  194. package/src/mcp/smithery-auth.ts +3 -2
  195. package/src/memories/index.ts +40 -20
  196. package/src/memory-backend/tool-names.ts +2 -0
  197. package/src/mnemopi/backend.ts +24 -7
  198. package/src/modes/acp/acp-agent.ts +56 -10
  199. package/src/modes/acp/acp-event-mapper.ts +8 -1
  200. package/src/modes/components/agent-hub.ts +1 -1
  201. package/src/modes/components/assistant-message.ts +7 -2
  202. package/src/modes/components/custom-message.ts +4 -1
  203. package/src/modes/components/login-dialog.ts +14 -4
  204. package/src/modes/components/message-frame.ts +14 -8
  205. package/src/modes/components/plan-review-overlay.ts +350 -35
  206. package/src/modes/components/session-account-selector.ts +62 -0
  207. package/src/modes/components/settings-defs.ts +23 -1
  208. package/src/modes/components/settings-selector.ts +169 -1
  209. package/src/modes/components/status-line/component.jj-cache.test.ts +229 -0
  210. package/src/modes/components/status-line/component.ts +123 -2
  211. package/src/modes/components/tool-execution.ts +28 -112
  212. package/src/modes/controllers/command-controller.ts +56 -15
  213. package/src/modes/controllers/event-controller.ts +111 -16
  214. package/src/modes/controllers/extension-ui-controller.test.ts +1 -0
  215. package/src/modes/controllers/extension-ui-controller.ts +20 -4
  216. package/src/modes/controllers/input-controller.ts +47 -39
  217. package/src/modes/controllers/live-command-controller.ts +255 -0
  218. package/src/modes/controllers/mcp-command-controller.ts +10 -1
  219. package/src/modes/controllers/omfg-controller.ts +44 -40
  220. package/src/modes/controllers/selector-controller.ts +80 -10
  221. package/src/modes/controllers/session-focus-controller.ts +6 -1
  222. package/src/modes/interactive-mode.ts +176 -38
  223. package/src/modes/runtime-init.ts +2 -0
  224. package/src/modes/setup-wizard/scenes/web-search.ts +17 -9
  225. package/src/modes/theme/theme.ts +1 -1
  226. package/src/modes/types.ts +4 -1
  227. package/src/modes/utils/context-usage.ts +23 -7
  228. package/src/modes/utils/ui-helpers.ts +10 -5
  229. package/src/plan-mode/plan-files.ts +40 -0
  230. package/src/prompts/bench/cache-prefix-chunk.md +1 -0
  231. package/src/prompts/bench/cache-prefix.md +3 -0
  232. package/src/prompts/bench/cache-suffix.md +1 -0
  233. package/src/prompts/system/computer-safety.md +14 -0
  234. package/src/prompts/system/custom-system-prompt.md +1 -1
  235. package/src/prompts/system/project-prompt.md +8 -1
  236. package/src/prompts/system/subagent-async-pending.md +6 -0
  237. package/src/prompts/system/system-prompt.md +1 -1
  238. package/src/prompts/system/workflow-notice.md +48 -40
  239. package/src/prompts/system/xdev-mount-notice.md +4 -0
  240. package/src/prompts/tools/computer.md +26 -0
  241. package/src/prompts/tools/todo.md +3 -1
  242. package/src/registry/agent-lifecycle.ts +116 -46
  243. package/src/registry/agent-registry.ts +35 -8
  244. package/src/registry/persisted-agents.ts +26 -2
  245. package/src/sdk.ts +215 -136
  246. package/src/secrets/index.ts +127 -4
  247. package/src/secrets/obfuscator.ts +2328 -105
  248. package/src/session/acp-permission-gate.ts +165 -0
  249. package/src/session/agent-session-error-log.test.ts +1 -1
  250. package/src/session/agent-session-events.ts +66 -0
  251. package/src/session/agent-session-types.ts +343 -0
  252. package/src/session/agent-session.ts +1940 -12218
  253. package/src/session/artifacts.ts +6 -5
  254. package/src/session/async-job-delivery.ts +74 -0
  255. package/src/session/auth-storage.ts +1 -0
  256. package/src/session/bash-runner.ts +326 -0
  257. package/src/session/blob-store.test.ts +56 -0
  258. package/src/session/blob-store.ts +18 -2
  259. package/src/session/checkpoint-entries.ts +81 -0
  260. package/src/session/eval-runner.ts +217 -0
  261. package/src/session/indexed-session-storage.ts +9 -2
  262. package/src/session/irc-bridge.ts +203 -0
  263. package/src/session/messages.ts +266 -1
  264. package/src/session/model-controls.ts +714 -0
  265. package/src/session/prewalk.ts +252 -0
  266. package/src/session/queued-messages.ts +93 -0
  267. package/src/session/redis-session-storage.ts +51 -11
  268. package/src/session/retry-fallback-chains.ts +455 -0
  269. package/src/session/role-models.ts +85 -0
  270. package/src/session/session-advisors.ts +1679 -0
  271. package/src/session/session-context.ts +6 -3
  272. package/src/session/session-entries.ts +8 -0
  273. package/src/session/session-handoff.ts +308 -0
  274. package/src/session/session-history-format.ts +20 -9
  275. package/src/session/session-loader.ts +0 -46
  276. package/src/session/session-maintenance.ts +2983 -0
  277. package/src/session/session-manager.ts +390 -30
  278. package/src/session/session-memory.ts +222 -0
  279. package/src/session/session-provider-boundary.ts +307 -0
  280. package/src/session/session-stats.ts +293 -0
  281. package/src/session/session-tools.ts +980 -0
  282. package/src/session/session-workspace.ts +53 -0
  283. package/src/session/stream-guards.ts +417 -0
  284. package/src/session/streaming-output.ts +52 -5
  285. package/src/session/todo-tracker.ts +380 -0
  286. package/src/session/ttsr-coordinator.ts +496 -0
  287. package/src/session/turn-recovery.ts +1629 -0
  288. package/src/slash-commands/builtin-registry.ts +257 -20
  289. package/src/slash-commands/helpers/session-pin.ts +44 -0
  290. package/src/slash-commands/helpers/usage-report.ts +22 -3
  291. package/src/stt/downloader.ts +0 -2
  292. package/src/stt/index.ts +0 -2
  293. package/src/stt/stt-controller.ts +57 -146
  294. package/src/system-prompt.ts +45 -17
  295. package/src/task/executor.ts +285 -70
  296. package/src/task/index.ts +98 -105
  297. package/src/task/output-manager.ts +25 -3
  298. package/src/task/persisted-revive.ts +4 -3
  299. package/src/task/structured-subagent.ts +1 -0
  300. package/src/tiny/title-client.ts +22 -0
  301. package/src/tools/approval.ts +55 -10
  302. package/src/tools/bash-interactive.ts +116 -86
  303. package/src/tools/bash-skill-urls.ts +28 -2
  304. package/src/tools/bash.ts +339 -123
  305. package/src/tools/browser/launch.ts +9 -1
  306. package/src/tools/browser/tab-supervisor.ts +8 -5
  307. package/src/tools/browser.ts +94 -47
  308. package/src/tools/builtin-names.ts +1 -0
  309. package/src/tools/computer/protocol.ts +28 -0
  310. package/src/tools/computer/supervisor.ts +258 -0
  311. package/src/tools/computer/worker-entry.ts +25 -0
  312. package/src/tools/computer/worker.ts +135 -0
  313. package/src/tools/computer-renderer.ts +108 -0
  314. package/src/tools/computer.ts +433 -0
  315. package/src/tools/context.ts +2 -0
  316. package/src/tools/default-renderer.ts +139 -0
  317. package/src/tools/essential-tools.ts +1 -0
  318. package/src/tools/image-gen.ts +20 -28
  319. package/src/tools/image-providers.ts +50 -0
  320. package/src/tools/index.ts +14 -0
  321. package/src/tools/path-utils.ts +49 -2
  322. package/src/tools/read.ts +156 -88
  323. package/src/tools/renderers.ts +9 -1
  324. package/src/tools/todo.ts +101 -11
  325. package/src/tools/vibe.ts +1 -2
  326. package/src/tools/write.ts +51 -1
  327. package/src/tools/xdev.ts +121 -29
  328. package/src/tts/streaming-player.ts +82 -283
  329. package/src/tts/vocalizer.ts +18 -1
  330. package/src/utils/clipboard.ts +1 -30
  331. package/src/utils/jj.ts +125 -4
  332. package/src/utils/lang-from-path.ts +7 -0
  333. package/src/utils/mac-file-urls.applescript +37 -0
  334. package/src/utils/title-generator.ts +137 -1
  335. package/src/utils/tool-choice.ts +14 -0
  336. package/src/utils/tools-manager.ts +1 -19
  337. package/src/vibe/runtime.ts +852 -72
  338. package/src/web/search/index.ts +3 -6
  339. package/src/web/search/provider.ts +31 -16
  340. package/src/web/search/providers/xai.ts +7 -1
  341. package/src/web/search/types.ts +3 -0
  342. package/dist/types/stt/recorder.d.ts +0 -30
  343. package/dist/types/stt/transcriber.d.ts +0 -14
  344. package/dist/types/stt/wav.d.ts +0 -29
  345. package/dist/types/tts/player.d.ts +0 -32
  346. package/src/stt/recorder.ts +0 -551
  347. package/src/stt/transcriber.ts +0 -60
  348. package/src/stt/wav.ts +0 -173
  349. package/src/tts/player.ts +0 -137
@@ -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, SessionOAuthAccountList, 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
@@ -668,6 +202,8 @@ export declare class AgentSession {
668
202
  get model(): Model | undefined;
669
203
  /** Resolved selector while retry routing is using a fallback model. */
670
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;
671
207
  /** Effective thinking level applied to the agent (the resolved level when `auto`). */
672
208
  get thinkingLevel(): ThinkingLevel | undefined;
673
209
  /** The selector the user configured: `auto` when auto mode is active, else the effective level. */
@@ -681,7 +217,7 @@ export declare class AgentSession {
681
217
  /** Whether agent is currently streaming a response */
682
218
  get isStreaming(): boolean;
683
219
  get isAborting(): boolean;
684
- /** Wait until streaming and deferred recovery work are fully settled. */
220
+ /** Wait until streaming, event persistence, and deferred recovery work are fully settled. */
685
221
  waitForIdle(): Promise<void>;
686
222
  /**
687
223
  * Prevent advisor notes from starting hidden primary turns while a headless
@@ -708,84 +244,80 @@ export declare class AgentSession {
708
244
  get systemPrompt(): string[];
709
245
  /** Current retry attempt (0 if not retrying) */
710
246
  get retryAttempt(): number;
711
- /**
712
- * Get the names of currently active tools.
713
- * Returns the names of tools currently set on the agent.
714
- */
247
+ /** Names of tools currently exposed at the top level. */
715
248
  getActiveToolNames(): string[];
716
- /**
717
- * Enabled tool names: top-level active tools plus discoverable tools mounted
718
- * under `xd://`. Reconcile callers (MCP refresh, discovery, plan/goal mode)
719
- * build their next active set from this so a mount survives an active-set
720
- * change; {@link getActiveToolNames} stays the top-level-only view.
721
- */
249
+ /** Enabled top-level and discoverable tool names. */
722
250
  getEnabledToolNames(): string[];
723
- /** Names of discoverable tools currently mounted under `xd://` (dynamic mounts). */
251
+ /** Names of dynamic tools mounted under `xd://`. */
724
252
  getMountedXdevToolNames(): string[];
725
253
  /** Whether the edit tool is registered in this session. */
726
254
  get hasEditTool(): boolean;
727
- /**
728
- * Get a tool by name from the registry.
729
- */
255
+ /** Looks up a registered tool by name. */
730
256
  getToolByName(name: string): AgentTool | undefined;
731
- /** 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. */
732
258
  hasBuiltInTool(name: string): boolean;
733
- /**
734
- * Get all configured tool names (built-in via --tools or default, plus custom tools).
735
- */
259
+ /** Names of every registered tool. */
736
260
  getAllToolNames(): string[];
737
- /**
738
- * Registers the ephemeral vibe tools and activates them alongside `baseToolNames`.
739
- *
740
- * @throws When this session cannot create vibe tools or the factory returns duplicate names.
741
- */
261
+ /** Installs and activates the ephemeral vibe tool set. */
742
262
  activateVibeTools(baseToolNames: string[]): Promise<void>;
743
- /** Removes tools installed by {@link activateVibeTools} and activates `nextToolNames`. */
263
+ /** Uninstalls vibe tools and activates the replacement set. */
744
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. */
745
268
  getSelectedMCPToolNames(): string[];
746
- /**
747
- * Rediscover disk-backed skills and rebuild prompt-facing state without
748
- * recreating the session. Explicit skill snapshots (`--no-skills`,
749
- * SDK-provided `skills`) remain fixed for the lifetime of the session.
750
- */
269
+ /** Rediscovers reloadable skills and refreshes prompt metadata. */
751
270
  refreshSkills(): Promise<void>;
752
- /**
753
- * Set active tools by name.
754
- * Only tools in the registry can be enabled. Unknown tool names are ignored.
755
- * Also rebuilds the system prompt to reflect the new tool set.
756
- * Changes take effect before the next model call.
757
- */
271
+ /** Selects enabled tools, ignoring names absent from the registry. */
758
272
  setActiveToolsByName(toolNames: string[]): Promise<void>;
273
+ /** Restores an exact top-level versus `xd://` tool partition. */
274
+ setActiveToolPresentation(toolNames: string[], mountedToolNames: string[]): Promise<void>;
759
275
  /**
760
- * Restore an enabled tool set with its exact top-level versus `xd://` partition.
276
+ * Session-scoped enable/disable for the settings-gated `computer` tool.
761
277
  *
762
- * Both inputs are required because {@link setActiveToolsByName} only receives the
763
- * enabled name list and classifies mounts from the *current* `#mountedXdevToolNames`.
764
- * Rollback/restore callers must pass the snapshotted mounted subset so names that
765
- * were top-level stay pinned (`#runtimeSelectedToolNames`) and names that were under
766
- * `xd://` remain mount-eligible, even when the live mount set has drifted.
278
+ * Enabling builds the tool through {@link AgentSessionConfig.createComputerTool}
279
+ * on first use and activates it; disabling drops it from the active set while
280
+ * keeping the registry entry so repeated toggles reuse one desktop controller.
767
281
  *
768
- * Names outside `mountedToolNames` are pinned top-level for this application;
769
- * names in the mounted subset remain eligible for xdev mounting. Delegates the
770
- * actual apply through `#applyActiveToolsByName` and restores the prior runtime
771
- * selection if that apply throws.
772
- */
773
- setActiveToolPresentation(toolNames: string[], mountedToolNames: string[]): Promise<void>;
774
- /** Rebuild the base system prompt using the current active tool set. */
282
+ * @returns false when enabling was requested but this session cannot build the
283
+ * tool (e.g. restricted child sessions have no factory).
284
+ */
285
+ setComputerToolEnabled(enabled: boolean): Promise<boolean>;
286
+ /** Cancels the local rollout-memory startup owned by this session. */
287
+ cancelLocalMemoryStartup(): void;
288
+ /** Starts a new local rollout-memory generation and cancels its predecessor. */
289
+ beginLocalMemoryStartup(): AbortSignal;
290
+ /** Releases the local startup slot if `signal` still owns it. */
291
+ endLocalMemoryStartup(signal: AbortSignal): void;
292
+ /** Applies the selected memory backend to runtime state, tools, and prompt. */
293
+ applyMemoryBackend(): Promise<void>;
294
+ /** Rebuilds the stable base prompt for the current tools and model. */
775
295
  refreshBaseSystemPrompt(): Promise<void>;
776
- /**
777
- * Replace MCP tools in the registry and enable them immediately. Every
778
- * connected MCP tool becomes available (mounted under `xd://` when that
779
- * transport is active, else top-level). Lets `/mcp add/remove/reauth` take
780
- * effect without restarting the session.
781
- */
296
+ /** Replaces connected MCP tools and enables them immediately. */
782
297
  refreshMCPTools(mcpTools: CustomTool[]): Promise<void>;
783
- /**
784
- * Replace RPC host-owned tools and refresh the active tool set before the next model call.
785
- */
298
+ /** Replaces host-owned RPC tools before the next model call. */
786
299
  refreshRpcHostTools(rpcTools: AgentTool[]): Promise<void>;
787
300
  /** Whether auto-compaction is currently running */
788
301
  get isCompacting(): boolean;
302
+ /** Strip image content from the current branch and persist the rewrite. */
303
+ dropImages(): Promise<{
304
+ removed: number;
305
+ }>;
306
+ /** Reduce stored context with the selected shake strategy. */
307
+ shake(mode: ShakeMode, opts?: {
308
+ config?: ShakeConfig;
309
+ signal?: AbortSignal;
310
+ }): Promise<ShakeResult>;
311
+ /** Compact the active session history. */
312
+ compact(customInstructions?: string, options?: CompactOptions): Promise<CompactionResult>;
313
+ /** Cancel active manual, automatic, and handoff maintenance. */
314
+ abortCompaction(): void;
315
+ /** Trigger idle compaction through the automatic maintenance flow. */
316
+ runIdleCompaction(): Promise<void>;
317
+ /** Toggle automatic compaction. */
318
+ setAutoCompactionEnabled(enabled: boolean): void;
319
+ /** Whether automatic compaction is enabled. */
320
+ get autoCompactionEnabled(): boolean;
789
321
  /**
790
322
  * Whether idle-flush tasks, auto-continuations, or other short-lived
791
323
  * post-prompt work are pending. True in the brief window after
@@ -810,7 +342,10 @@ export declare class AgentSession {
810
342
  * Transcript for TUI display. Full history is kept for export/resume-style
811
343
  * callers; live chat can collapse compacted history to keep the hot render
812
344
  * surface bounded. Display-only — NEVER feed the result to
813
- * `agent.replaceMessages` or a provider.
345
+ * `agent.replaceMessages` or a provider. Because it is never re-obfuscated,
346
+ * it opts into legacy index-derived alias restoration so pre-keyed sessions
347
+ * still render their secrets; the agent-feeding paths
348
+ * (`buildDisplaySessionContext`) keep the keyed-only default.
814
349
  */
815
350
  buildTranscriptSessionContext(options?: Pick<BuildSessionContextOptions, "collapseCompactedHistory" | "keepDanglingToolCalls">): SessionContext;
816
351
  /** Convert session messages using the same pre-LLM pipeline as the active session. */
@@ -828,6 +363,7 @@ export declare class AgentSession {
828
363
  /** Current session ID */
829
364
  get sessionId(): string;
830
365
  getEvalSessionId(): string | null;
366
+ getEvalKernelOwnerId(): string;
831
367
  /** Current session display name, if set */
832
368
  get sessionName(): string | undefined;
833
369
  /** Scoped models for cycling (from --models flag) */
@@ -1032,6 +568,8 @@ export declare class AgentSession {
1032
568
  * @returns true if completed, false if cancelled by hook or not persisting
1033
569
  */
1034
570
  fork(): Promise<boolean>;
571
+ /** Move the active session and artifacts after enforcing mode transition invariants. */
572
+ moveSession(newCwd: string, targetSessionDir?: string): Promise<void>;
1035
573
  /**
1036
574
  * Set model directly.
1037
575
  * Validates that a credential source is configured (synchronously, without
@@ -1049,93 +587,35 @@ export declare class AgentSession {
1049
587
  }): Promise<{
1050
588
  switched: boolean;
1051
589
  }>;
1052
- /**
1053
- * Set model temporarily (for this session only).
1054
- * Validates that a credential source is configured (synchronously, without
1055
- * refreshing OAuth or running command-backed key programs), saves to session
1056
- * log but NOT to settings.
1057
- * @throws Error if no API key available for the model
1058
- */
590
+ /** Selects a model for this session without updating persisted model settings. */
1059
591
  setModelTemporary(model: Model, thinkingLevel?: ConfiguredThinkingLevel, options?: {
1060
592
  ephemeral?: boolean;
1061
593
  }): Promise<void>;
1062
- /**
1063
- * Cycle to next/previous model.
1064
- * Uses scoped models (from --models flag) if available, otherwise all available models.
1065
- * @param direction - "forward" (default) or "backward"
1066
- * @returns The new model info, or undefined if only one model available
1067
- */
594
+ /** Cycles the scoped model set, or all available models when no scope exists. */
1068
595
  cycleModel(direction?: "forward" | "backward"): Promise<ModelCycleResult | undefined>;
1069
- /**
1070
- * Resolve the configured role models in the given order plus the index of
1071
- * the currently active one. Roles that have no configured model, or whose
1072
- * configured model is not currently available, are skipped. The `default`
1073
- * role falls back to the active model when no explicit assignment exists.
1074
- *
1075
- * Returns `undefined` only when there is no current model or no available
1076
- * models at all; an empty `models` array is never returned (callers should
1077
- * still guard on `models.length`).
1078
- */
596
+ /** Resolves configured role models and the currently active role index. */
1079
597
  getRoleModelCycle(roleOrder: readonly string[]): RoleModelCycle | undefined;
1080
- /**
1081
- * Apply a resolved role model as the active model without changing global
1082
- * settings. Shared with role cycling and the plan-approval model slider.
1083
- */
598
+ /** Applies a resolved role model without changing global settings. */
1084
599
  applyRoleModel(entry: ResolvedRoleModel): Promise<void>;
1085
- /**
1086
- * Cycle through configured role models in a fixed order.
1087
- * Skips missing roles and changes only the active session model.
1088
- * @param roleOrder - Order of roles to cycle through (e.g., ["slow", "default", "smol"])
1089
- * @param direction - "forward" (default) or "backward"
1090
- */
600
+ /** Cycles the configured role models in the supplied order. */
1091
601
  cycleRoleModels(roleOrder: readonly string[], direction?: "forward" | "backward"): Promise<RoleModelCycleResult | undefined>;
1092
- /**
1093
- * Get all available models with valid API keys, filtered by `enabledModels` when configured.
1094
- * See {@link filterAvailableModelsByEnabledPatterns} for supported pattern forms and limitations.
1095
- */
602
+ /** Lists available models after applying the configured enabled-model filter. */
1096
603
  getAvailableModels(): Model[];
1097
- /**
1098
- * Set the thinking level. `auto` enables per-turn classification. Entering
1099
- * auto writes its provisional level plus `configured: "auto"` immediately,
1100
- * giving external readers an authoritative selection receipt before the next
1101
- * user turn. Later classifications persist only changed concrete resolutions.
1102
- */
604
+ /** Selects the session thinking level and optionally persists it as the default. */
1103
605
  setThinkingLevel(level: ConfiguredThinkingLevel | undefined, persist?: boolean): void;
1104
- /**
1105
- * Cycle to next thinking level: off → auto → minimal..max → off.
1106
- * @returns New selector, or undefined if model doesn't support thinking
1107
- */
606
+ /** Advances through the thinking selectors supported by the active model. */
1108
607
  cycleThinkingLevel(): ConfiguredThinkingLevel | undefined;
1109
- /**
1110
- * True when the currently selected model's family is set to `priority` — the
1111
- * `/fast` on/off state for the active model. Returns false when no model is
1112
- * selected or the model exposes no service-tier family (e.g. Fireworks, which
1113
- * has its own Providers › Fireworks Tier toggle).
1114
- *
1115
- * For "is priority actually applied to the next request?" use
1116
- * {@link isFastModeActive} instead.
1117
- */
608
+ /** Reports whether `/fast` is enabled for the active model family. */
1118
609
  isFastModeEnabled(): boolean;
1119
- /**
1120
- * True when `priority` is actually realized on the wire for the currently
1121
- * selected model (OpenAI/Google `service_tier`, direct Anthropic fast mode,
1122
- * or Fireworks priority). Returns false for tiers the active model can't
1123
- * realize and when no model is selected.
1124
- */
610
+ /** Reports whether priority service is realized by the active model. */
1125
611
  isFastModeActive(): boolean;
1126
- /** Set one family's tier (or clear it with `undefined`); persists the change. */
612
+ /** Sets or clears one model family's live service tier. */
1127
613
  setServiceTierFamily(family: ServiceTierFamily, tier: ServiceTier | undefined): void;
1128
- /**
1129
- * `/fast on|off` targets the family of the currently selected model: it sets
1130
- * (or clears) that family's `priority` tier. Returns `false` when the model
1131
- * has no service-tier family, so callers can report that fast mode is
1132
- * unavailable instead of claiming success.
1133
- */
614
+ /** Enables or disables priority service for the active model family. */
1134
615
  setFastMode(enabled: boolean): boolean;
616
+ /** Toggles priority service for the active model family. */
1135
617
  toggleFastMode(): boolean;
1136
- /**
1137
- * Get available thinking levels for current model.
1138
- */
618
+ /** Lists thinking levels supported by the active model. */
1139
619
  getAvailableThinkingLevels(): ReadonlyArray<Effort>;
1140
620
  /**
1141
621
  * Set steering mode.
@@ -1152,51 +632,6 @@ export declare class AgentSession {
1152
632
  * Saves to settings.
1153
633
  */
1154
634
  setInterruptMode(mode: "immediate" | "wait"): void;
1155
- /**
1156
- * Strip image content blocks from every message on the current branch and
1157
- * persist the rewrite. Walks `SessionManager.getBranch()` in place — both
1158
- * `SessionMessageEntry.message` and `CustomMessageEntry.content` arrays
1159
- * are mutated, then `rewriteEntries` durably commits the new shape. The
1160
- * agent's runtime view is rebuilt from the freshly-mutated entries so any
1161
- * provider sessions caching message identity (Codex Responses) are torn
1162
- * down to force a clean replay on the next turn.
1163
- *
1164
- * No-op when the branch carries no images; returns `{ removed: 0 }` and
1165
- * skips the disk rewrite.
1166
- */
1167
- dropImages(): Promise<{
1168
- removed: number;
1169
- }>;
1170
- /**
1171
- * Surgically reduce context by dropping heavy content ("shake").
1172
- *
1173
- * - `images` delegates to {@link dropImages}.
1174
- * - `elide` replaces whole tool-call results and large fenced/XML blocks
1175
- * with short placeholders that embed an `artifact://` recovery link.
1176
- *
1177
- * Mutates the branch in place, persists via `rewriteEntries`, replays the
1178
- * rebuilt context through the agent, and tears down provider sessions that
1179
- * cache message identity — same rewrite contract as {@link dropImages}.
1180
- *
1181
- * No-op (zero counts) when nothing is eligible.
1182
- */
1183
- shake(mode: ShakeMode, opts?: {
1184
- config?: ShakeConfig;
1185
- signal?: AbortSignal;
1186
- }): Promise<ShakeResult>;
1187
- /**
1188
- * Manually compact the session context.
1189
- * Aborts current agent operation first.
1190
- * @param customInstructions Optional instructions for the compaction summary
1191
- * @param options Optional callbacks for completion/error handling
1192
- */
1193
- compact(customInstructions?: string, options?: CompactOptions): Promise<CompactionResult>;
1194
- /**
1195
- * Cancel in-progress context maintenance (manual compaction, auto-compaction, or auto-handoff).
1196
- */
1197
- abortCompaction(): void;
1198
- /** Trigger idle compaction through the auto-compaction flow (with UI events). */
1199
- runIdleCompaction(): Promise<void>;
1200
635
  /**
1201
636
  * Cancel in-progress branch summarization.
1202
637
  */
@@ -1217,44 +652,15 @@ export declare class AgentSession {
1217
652
  * @returns The handoff document text, or undefined if cancelled/failed
1218
653
  */
1219
654
  handoff(customInstructions?: string, options?: SessionHandoffOptions): Promise<HandoffResult | undefined>;
1220
- /**
1221
- * Toggle auto-compaction setting.
1222
- */
1223
- setAutoCompactionEnabled(enabled: boolean): void;
1224
- /** Whether auto-compaction is enabled */
1225
- get autoCompactionEnabled(): boolean;
1226
- /**
1227
- * Cancel in-progress retry.
1228
- */
655
+ /** Cancel an in-progress retry. */
1229
656
  abortRetry(): void;
1230
- /** Whether auto-retry is currently in progress */
657
+ /** Whether auto-retry is currently in progress. */
1231
658
  get isRetrying(): boolean;
1232
- /** Whether auto-retry is enabled */
659
+ /** Whether auto-retry is enabled. */
1233
660
  get autoRetryEnabled(): boolean;
1234
- /**
1235
- * Toggle auto-retry setting.
1236
- */
661
+ /** Toggle the auto-retry setting. */
1237
662
  setAutoRetryEnabled(enabled: boolean): void;
1238
- /**
1239
- * Manually retry the last failed assistant turn.
1240
- * Removes the error message from active agent state when present and
1241
- * re-attempts with a fresh retry budget.
1242
- *
1243
- * A stream that stalls or aborts mid-tool-call ends the turn with
1244
- * `stopReason: "error" | "aborted"` and then appends one synthetic
1245
- * {@link isSyntheticToolResultMessage tool_result} per emitted tool call to
1246
- * preserve the provider's tool_use/tool_result pairing (see
1247
- * `createAbortedToolResult` in `agent-loop.ts`). Those placeholders trail the
1248
- * failed assistant turn, so the retry lookback walks back over them before
1249
- * checking the assistant message; it strips both the placeholders and the
1250
- * failed turn before re-attempting.
1251
- *
1252
- * A restored session deliberately omits failed assistant turns from provider
1253
- * context. In that case, the persisted display transcript remains the source
1254
- * of truth for whether the current branch has a retryable failed tail.
1255
- *
1256
- * @returns true if retry was initiated, false if no failed turn to retry or agent is busy
1257
- */
663
+ /** Retry the last failed assistant turn when the session is idle. */
1258
664
  retry(): Promise<boolean>;
1259
665
  /**
1260
666
  * Execute a bash command and retain the session/branch that owned its start.
@@ -1271,9 +677,7 @@ export declare class AgentSession {
1271
677
  recordBashResult(command: string, result: BashResult, options?: {
1272
678
  excludeFromContext?: boolean;
1273
679
  }): void;
1274
- /**
1275
- * Cancel running bash command.
1276
- */
680
+ /** Cancel running bash commands. */
1277
681
  abortBash(): void;
1278
682
  /** Whether a bash command is currently running */
1279
683
  get isBashRunning(): boolean;
@@ -1309,49 +713,18 @@ export declare class AgentSession {
1309
713
  /** Whether there are pending Python messages waiting to be flushed */
1310
714
  get hasPendingPythonMessages(): boolean;
1311
715
  /**
1312
- * Surfaces and consumes pending IRC incoming records before the next model
1313
- * step can inject them automatically.
1314
- *
1315
- * Tool results already expose the formatted body to the model. Leaving the
1316
- * same record in either pending IRC queue would deliver it a second time at
1317
- * the next step boundary — including on `peek`, which is why inbox peeks
1318
- * also drain here.
716
+ * Flush pending Python messages to agent state and session.
1319
717
  */
718
+ /** Surfaces and consumes pending IRC records before automatic injection. */
1320
719
  drainPendingIrcInboxMessages(agentId: string, opts?: {
1321
720
  from?: string;
1322
721
  limit?: number;
1323
722
  }): IrcMessage[];
1324
- /**
1325
- * Deliver an IRC message into this session (recipient side; called by the
1326
- * IrcBus). Emits the `irc_message` session event for UI cards and injects
1327
- * the rendered message into the model's context as an `irc:incoming`
1328
- * custom message:
1329
- *
1330
- * - mid-turn → queued on the aside channel and folded in at the next step
1331
- * boundary (non-interrupting, like async-result deliveries) → "injected";
1332
- * - idle in plan mode → appended into context without waking an autonomous
1333
- * turn (convergence stays user-driven) → "injected";
1334
- * - idle → starts a real turn with the message so the recipient wakes
1335
- * → "woken".
1336
- *
1337
- * Never blocks on the recipient's turn: the wake turn is fire-and-forget.
1338
- *
1339
- * When the sender expects a reply (`send await:true`) and this session
1340
- * cannot produce a real reply turn in time — mid-turn with async execution
1341
- * disabled (the next step boundary may be gated on the sender's own batch
1342
- * finishing), or idle in plan mode (wake turns are suppressed) — an
1343
- * ephemeral side-channel auto-reply is generated from the current context
1344
- * (the old `respondAsBackground` path) and sent back over the bus on this
1345
- * agent's behalf.
1346
- */
723
+ /** Delivers an IRC message into this recipient session. */
1347
724
  deliverIrcMessage(msg: IrcMessage, opts?: {
1348
725
  expectsReply?: boolean;
1349
726
  }): Promise<"injected" | "woken">;
1350
- /**
1351
- * Emit an IRC relay observation event on this session for UI rendering only.
1352
- * Does not persist the record to history. Called by the IrcBus to surface
1353
- * agent↔agent traffic on the main session.
1354
- */
727
+ /** Emits an IRC relay observation for UI rendering without persisting it. */
1355
728
  emitIrcRelayObservation(record: CustomMessage): void;
1356
729
  /**
1357
730
  * Run a single ephemeral side-channel turn against this session's current
@@ -1501,6 +874,15 @@ export declare class AgentSession {
1501
874
  */
1502
875
  get contextUsageRevision(): number;
1503
876
  fetchUsageReports(signal?: AbortSignal): Promise<UsageReport[] | null>;
877
+ /** Models whose live `/usage` reports map to a quantitative provider scope. */
878
+ getUsageReportingModelSelectors(reports: readonly UsageReport[]): string[];
879
+ /** List stored OAuth accounts for the current model provider and mark this session's active account. */
880
+ listCurrentProviderOAuthAccounts(): Promise<SessionOAuthAccountList | undefined>;
881
+ /**
882
+ * Pin a stored OAuth account to the current model provider for this session.
883
+ * Returns false while streaming or when the credential is no longer available.
884
+ */
885
+ pinCurrentProviderOAuthAccount(credentialId: number): boolean;
1504
886
  /**
1505
887
  * Redeem one saved Codex rate-limit reset for a specific account, injecting
1506
888
  * the provider base URL like {@link AgentSession.fetchUsageReports}. Powers
@@ -1516,10 +898,10 @@ export declare class AgentSession {
1516
898
  listResetCredits(signal?: AbortSignal): Promise<ResetCreditAccountStatus[]>;
1517
899
  /**
1518
900
  * Export session to HTML.
1519
- * @param outputPath Optional output path (defaults to session directory)
1520
- * @returns Path to exported file
901
+ * @param outputPath Optional output path
902
+ * @param useUserThemes Bundle the dark and light TUI themes selected in settings
1521
903
  */
1522
- exportToHtml(outputPath?: string): Promise<string>;
904
+ exportToHtml(outputPath?: string, useUserThemes?: boolean): Promise<string>;
1523
905
  /**
1524
906
  * Get text content of last assistant message.
1525
907
  * Useful for /copy command.