@bastani/atomic 0.9.16-alpha.1 → 0.9.16-alpha.3

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 (714) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/builtin/intercom/broker/spawn.ts +22 -2
  3. package/dist/builtin/intercom/index.bundle.mjs +61694 -0
  4. package/dist/builtin/intercom/package.json +3 -3
  5. package/dist/builtin/mcp/index.bundle.mjs +64901 -0
  6. package/dist/builtin/mcp/package.json +2 -2
  7. package/dist/builtin/subagents/CHANGELOG.md +13 -0
  8. package/dist/builtin/subagents/README.md +17 -105
  9. package/dist/builtin/subagents/package.json +2 -6
  10. package/dist/builtin/subagents/skills/subagent/SKILL.md +18 -88
  11. package/dist/builtin/subagents/src/extension/index.bundle.mjs +85671 -0
  12. package/dist/builtin/web-access/index.bundle.mjs +67413 -0
  13. package/dist/builtin/web-access/package.json +2 -2
  14. package/dist/builtin/workflows/CHANGELOG.md +6 -0
  15. package/dist/builtin/workflows/package.json +3 -3
  16. package/dist/builtin/workflows/skills/bro/LICENSE.txt +21 -0
  17. package/dist/builtin/workflows/skills/bro/SKILL.md +14 -0
  18. package/dist/builtin/workflows/skills/how/LICENSE.txt +21 -0
  19. package/dist/builtin/workflows/skills/how/SKILL.md +162 -0
  20. package/dist/builtin/workflows/skills/how/references/critic-prompt.md +59 -0
  21. package/dist/builtin/workflows/skills/how/references/critique-rubric.md +58 -0
  22. package/dist/builtin/workflows/skills/how/references/explainer-prompt.md +55 -0
  23. package/dist/builtin/workflows/skills/how/references/explorer-prompt.md +52 -0
  24. package/dist/builtin/workflows/skills/teach/LICENSE.txt +21 -0
  25. package/dist/builtin/workflows/skills/teach/SKILL.md +28 -0
  26. package/dist/builtin/workflows/skills/unslop/LICENSE.txt +21 -0
  27. package/dist/builtin/workflows/skills/unslop/SKILL.md +87 -0
  28. package/dist/builtin/workflows/skills/why/LICENSE.txt +21 -0
  29. package/dist/builtin/workflows/skills/why/SKILL.md +267 -0
  30. package/dist/builtin/workflows/skills/why/references/epistemics.md +144 -0
  31. package/dist/builtin/workflows/skills/why/references/investigator-prompt.md +103 -0
  32. package/dist/builtin/workflows/skills/why/references/source-playbook.md +17 -0
  33. package/dist/builtin/workflows/skills/why/references/sources/code-archaeology.md +88 -0
  34. package/dist/builtin/workflows/skills/why/references/sources/databricks.md +70 -0
  35. package/dist/builtin/workflows/skills/why/references/sources/datadog.md +99 -0
  36. package/dist/builtin/workflows/skills/why/references/sources/incident-postmortem.md +15 -0
  37. package/dist/builtin/workflows/skills/why/references/sources/linear.md +48 -0
  38. package/dist/builtin/workflows/skills/why/references/sources/notion.md +55 -0
  39. package/dist/builtin/workflows/skills/why/references/sources/sentry.md +100 -0
  40. package/dist/builtin/workflows/skills/why/references/sources/slack.md +54 -0
  41. package/dist/builtin/workflows/skills/why/references/synthesizer-prompt.md +135 -0
  42. package/dist/builtin/workflows/src/extension/index.bundle.mjs +76391 -96336
  43. package/dist/builtin/workflows/src/index.bundle.mjs +73244 -0
  44. package/dist/core/agent-session-auto-compaction.js +10 -10
  45. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  46. package/dist/core/agent-session-events.d.ts.map +1 -1
  47. package/dist/core/agent-session-events.js +11 -13
  48. package/dist/core/agent-session-events.js.map +1 -1
  49. package/dist/core/agent-session-methods.d.ts +1 -1
  50. package/dist/core/agent-session-methods.d.ts.map +1 -1
  51. package/dist/core/agent-session-methods.js.map +1 -1
  52. package/dist/core/agent-session-models.d.ts.map +1 -1
  53. package/dist/core/agent-session-models.js +5 -7
  54. package/dist/core/agent-session-models.js.map +1 -1
  55. package/dist/core/agent-session-prompt.js +4 -4
  56. package/dist/core/agent-session-prompt.js.map +1 -1
  57. package/dist/core/agent-session-retry.d.ts +4 -4
  58. package/dist/core/agent-session-retry.d.ts.map +1 -1
  59. package/dist/core/agent-session-retry.js +8 -34
  60. package/dist/core/agent-session-retry.js.map +1 -1
  61. package/dist/core/agent-session-tool-hooks.js +4 -4
  62. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  63. package/dist/core/atomic-guide-command.d.ts.map +1 -1
  64. package/dist/core/atomic-guide-command.js +3 -10
  65. package/dist/core/atomic-guide-command.js.map +1 -1
  66. package/dist/core/builtin-install-layout.d.ts +22 -0
  67. package/dist/core/builtin-install-layout.d.ts.map +1 -0
  68. package/dist/core/builtin-install-layout.js +23 -0
  69. package/dist/core/builtin-install-layout.js.map +1 -0
  70. package/dist/core/builtin-packages.d.ts.map +1 -1
  71. package/dist/core/builtin-packages.js +8 -32
  72. package/dist/core/builtin-packages.js.map +1 -1
  73. package/dist/core/slash-commands.d.ts.map +1 -1
  74. package/dist/core/slash-commands.js +0 -3
  75. package/dist/core/slash-commands.js.map +1 -1
  76. package/dist/core/system-prompt.d.ts.map +1 -1
  77. package/dist/core/system-prompt.js +0 -12
  78. package/dist/core/system-prompt.js.map +1 -1
  79. package/dist/modes/interactive-engine/remote-command-catalog.d.ts +1 -1
  80. package/dist/modes/interactive-engine/remote-command-catalog.js +1 -1
  81. package/dist/modes/interactive-engine/remote-command-catalog.js.map +1 -1
  82. package/docs/intercom.md +1 -1
  83. package/docs/settings.md +2 -2
  84. package/docs/subagents.md +6 -7
  85. package/docs/usage.md +0 -9
  86. package/npm-shrinkwrap.json +32 -32
  87. package/package.json +3 -3
  88. package/dist/builtin/intercom/closed-workflow-stage-message.ts +0 -66
  89. package/dist/builtin/intercom/config.ts +0 -121
  90. package/dist/builtin/intercom/contact-supervisor-tool.ts +0 -328
  91. package/dist/builtin/intercom/foreground-detach-handoff.ts +0 -164
  92. package/dist/builtin/intercom/group.ts +0 -85
  93. package/dist/builtin/intercom/inbound-idle-queue.ts +0 -82
  94. package/dist/builtin/intercom/inbound-message-admission.ts +0 -79
  95. package/dist/builtin/intercom/incoming-message-delivery.ts +0 -49
  96. package/dist/builtin/intercom/index-heavy.ts +0 -539
  97. package/dist/builtin/intercom/index.ts +0 -503
  98. package/dist/builtin/intercom/intercom-test-seams.ts +0 -6
  99. package/dist/builtin/intercom/intercom-tool.ts +0 -602
  100. package/dist/builtin/intercom/intercom-utils.ts +0 -427
  101. package/dist/builtin/intercom/late-stage-message-router.ts +0 -148
  102. package/dist/builtin/intercom/lazy-heavy-proxy.ts +0 -108
  103. package/dist/builtin/intercom/lazy-subagent-ack.ts +0 -25
  104. package/dist/builtin/intercom/lazy-tool-execution.ts +0 -39
  105. package/dist/builtin/intercom/lifecycle-lease.ts +0 -51
  106. package/dist/builtin/intercom/lifecycle.ts +0 -144
  107. package/dist/builtin/intercom/overlay.ts +0 -96
  108. package/dist/builtin/intercom/parent-ask-handoff.ts +0 -72
  109. package/dist/builtin/intercom/reconnect-backoff.ts +0 -6
  110. package/dist/builtin/intercom/reply-routing.ts +0 -17
  111. package/dist/builtin/intercom/reply-tracker.ts +0 -110
  112. package/dist/builtin/intercom/reply-waiter.ts +0 -115
  113. package/dist/builtin/intercom/result-renderers.ts +0 -77
  114. package/dist/builtin/intercom/runtime-group.ts +0 -13
  115. package/dist/builtin/intercom/session-target.ts +0 -54
  116. package/dist/builtin/intercom/source-ownership.ts +0 -31
  117. package/dist/builtin/intercom/stable-delivery-retry.ts +0 -32
  118. package/dist/builtin/intercom/subagent-relay.ts +0 -290
  119. package/dist/builtin/intercom/supervisor-authorization-registry.ts +0 -22
  120. package/dist/builtin/intercom/terminal-ordering-barrier.ts +0 -247
  121. package/dist/builtin/intercom/types.ts +0 -66
  122. package/dist/builtin/intercom/ui/compose.ts +0 -159
  123. package/dist/builtin/intercom/ui/inline-message.ts +0 -78
  124. package/dist/builtin/intercom/ui/session-list.ts +0 -195
  125. package/dist/builtin/intercom/workflow-reply-tracker.ts +0 -19
  126. package/dist/builtin/intercom/workflow-stage-admission.ts +0 -43
  127. package/dist/builtin/intercom/workflow-stage-delivery-failure.ts +0 -77
  128. package/dist/builtin/mcp/agent-dir.ts +0 -30
  129. package/dist/builtin/mcp/apps-cancellation.ts +0 -32
  130. package/dist/builtin/mcp/call-tool-result.ts +0 -9
  131. package/dist/builtin/mcp/caller-wait.ts +0 -50
  132. package/dist/builtin/mcp/cli.js +0 -191
  133. package/dist/builtin/mcp/command-registration.ts +0 -82
  134. package/dist/builtin/mcp/commands.ts +0 -424
  135. package/dist/builtin/mcp/config-write-utils.ts +0 -104
  136. package/dist/builtin/mcp/config.ts +0 -498
  137. package/dist/builtin/mcp/consent-manager.ts +0 -64
  138. package/dist/builtin/mcp/direct-tool-executor.ts +0 -280
  139. package/dist/builtin/mcp/direct-tools.ts +0 -216
  140. package/dist/builtin/mcp/errors.ts +0 -219
  141. package/dist/builtin/mcp/glimpse-ui.ts +0 -81
  142. package/dist/builtin/mcp/host-html-template.ts +0 -426
  143. package/dist/builtin/mcp/index.ts +0 -443
  144. package/dist/builtin/mcp/init.ts +0 -319
  145. package/dist/builtin/mcp/lifecycle.ts +0 -93
  146. package/dist/builtin/mcp/logger.ts +0 -169
  147. package/dist/builtin/mcp/mcp-auth-flow.ts +0 -372
  148. package/dist/builtin/mcp/mcp-auth.ts +0 -297
  149. package/dist/builtin/mcp/mcp-callback-server.ts +0 -306
  150. package/dist/builtin/mcp/mcp-oauth-provider.ts +0 -324
  151. package/dist/builtin/mcp/mcp-panel-renderer.ts +0 -243
  152. package/dist/builtin/mcp/mcp-panel-state.ts +0 -227
  153. package/dist/builtin/mcp/mcp-panel-types.ts +0 -86
  154. package/dist/builtin/mcp/mcp-panel.ts +0 -393
  155. package/dist/builtin/mcp/mcp-setup-panel.ts +0 -502
  156. package/dist/builtin/mcp/metadata-cache.ts +0 -201
  157. package/dist/builtin/mcp/metadata-hydration.ts +0 -52
  158. package/dist/builtin/mcp/npx-resolver.ts +0 -425
  159. package/dist/builtin/mcp/oauth-handler.ts +0 -60
  160. package/dist/builtin/mcp/onboarding-state.ts +0 -68
  161. package/dist/builtin/mcp/proxy-auth.ts +0 -61
  162. package/dist/builtin/mcp/proxy-call.ts +0 -447
  163. package/dist/builtin/mcp/proxy-connect.ts +0 -78
  164. package/dist/builtin/mcp/proxy-info-modes.ts +0 -409
  165. package/dist/builtin/mcp/proxy-modes.ts +0 -3
  166. package/dist/builtin/mcp/proxy-types.ts +0 -3
  167. package/dist/builtin/mcp/resource-tools.ts +0 -17
  168. package/dist/builtin/mcp/sampling-handler.ts +0 -273
  169. package/dist/builtin/mcp/server-manager.ts +0 -372
  170. package/dist/builtin/mcp/session-cleanup-barrier.ts +0 -43
  171. package/dist/builtin/mcp/startup-warmup.ts +0 -110
  172. package/dist/builtin/mcp/state-lease.ts +0 -12
  173. package/dist/builtin/mcp/state.ts +0 -41
  174. package/dist/builtin/mcp/tool-call-timeout.ts +0 -101
  175. package/dist/builtin/mcp/tool-metadata.ts +0 -152
  176. package/dist/builtin/mcp/tool-registrar.ts +0 -46
  177. package/dist/builtin/mcp/tool-result-renderer.ts +0 -66
  178. package/dist/builtin/mcp/types.ts +0 -445
  179. package/dist/builtin/mcp/ui-resource-handler.ts +0 -145
  180. package/dist/builtin/mcp/ui-server-http.ts +0 -81
  181. package/dist/builtin/mcp/ui-server.ts +0 -499
  182. package/dist/builtin/mcp/ui-session.ts +0 -378
  183. package/dist/builtin/mcp/ui-stream-types.ts +0 -89
  184. package/dist/builtin/mcp/utils.ts +0 -165
  185. package/dist/builtin/subagents/prompts/gather-context-and-clarify.md +0 -27
  186. package/dist/builtin/subagents/prompts/parallel-cleanup.md +0 -61
  187. package/dist/builtin/subagents/prompts/parallel-context-build.md +0 -43
  188. package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +0 -47
  189. package/dist/builtin/subagents/prompts/parallel-research.md +0 -34
  190. package/dist/builtin/subagents/prompts/parallel-review.md +0 -47
  191. package/dist/builtin/subagents/prompts/review-loop.md +0 -39
  192. package/dist/builtin/subagents/src/agents/agent-discovery.ts +0 -116
  193. package/dist/builtin/subagents/src/agents/agent-loaders.ts +0 -216
  194. package/dist/builtin/subagents/src/agents/agent-management-helpers.ts +0 -221
  195. package/dist/builtin/subagents/src/agents/agent-management.ts +0 -315
  196. package/dist/builtin/subagents/src/agents/agent-overrides.ts +0 -450
  197. package/dist/builtin/subagents/src/agents/agent-paths.ts +0 -69
  198. package/dist/builtin/subagents/src/agents/agent-scope.ts +0 -6
  199. package/dist/builtin/subagents/src/agents/agent-selection.ts +0 -23
  200. package/dist/builtin/subagents/src/agents/agent-serializer.ts +0 -113
  201. package/dist/builtin/subagents/src/agents/agent-types.ts +0 -97
  202. package/dist/builtin/subagents/src/agents/agents.ts +0 -25
  203. package/dist/builtin/subagents/src/agents/frontmatter.ts +0 -74
  204. package/dist/builtin/subagents/src/agents/identity.ts +0 -37
  205. package/dist/builtin/subagents/src/agents/skills-paths.ts +0 -380
  206. package/dist/builtin/subagents/src/agents/skills.ts +0 -398
  207. package/dist/builtin/subagents/src/extension/api-lifecycle.ts +0 -64
  208. package/dist/builtin/subagents/src/extension/config.ts +0 -16
  209. package/dist/builtin/subagents/src/extension/control-notices.ts +0 -91
  210. package/dist/builtin/subagents/src/extension/doctor.ts +0 -188
  211. package/dist/builtin/subagents/src/extension/index.ts +0 -420
  212. package/dist/builtin/subagents/src/extension/notification-content.ts +0 -85
  213. package/dist/builtin/subagents/src/extension/prompt-guidance.ts +0 -11
  214. package/dist/builtin/subagents/src/extension/schemas.ts +0 -208
  215. package/dist/builtin/subagents/src/extension/startup-maintenance.ts +0 -133
  216. package/dist/builtin/subagents/src/extension/tool-description.ts +0 -19
  217. package/dist/builtin/subagents/src/extension/tool-rendering.ts +0 -53
  218. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +0 -429
  219. package/dist/builtin/subagents/src/intercom/result-intercom.ts +0 -246
  220. package/dist/builtin/subagents/src/intercom/supervisor-authorization.ts +0 -30
  221. package/dist/builtin/subagents/src/runs/foreground/completion-notification.ts +0 -42
  222. package/dist/builtin/subagents/src/runs/foreground/detached-cleanup-barrier.ts +0 -26
  223. package/dist/builtin/subagents/src/runs/foreground/execution-detach-reservations.ts +0 -58
  224. package/dist/builtin/subagents/src/runs/foreground/execution-detach-route.ts +0 -19
  225. package/dist/builtin/subagents/src/runs/foreground/execution-intercom-detach.ts +0 -51
  226. package/dist/builtin/subagents/src/runs/foreground/execution-parent-ask-handoff.ts +0 -78
  227. package/dist/builtin/subagents/src/runs/foreground/execution-run-sync.ts +0 -1
  228. package/dist/builtin/subagents/src/runs/foreground/execution-updates.ts +0 -26
  229. package/dist/builtin/subagents/src/runs/foreground/execution-utils.ts +0 -61
  230. package/dist/builtin/subagents/src/runs/foreground/execution.ts +0 -6
  231. package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +0 -512
  232. package/dist/builtin/subagents/src/runs/foreground/notify.ts +0 -355
  233. package/dist/builtin/subagents/src/runs/foreground/parent-ask-output.ts +0 -48
  234. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst-display.ts +0 -46
  235. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-burst.ts +0 -403
  236. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +0 -223
  237. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-cwd.ts +0 -6
  238. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-input.ts +0 -139
  239. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-live-update.ts +0 -11
  240. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +0 -268
  241. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +0 -327
  242. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parent-ask-projection.ts +0 -11
  243. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +0 -12
  244. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +0 -350
  245. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +0 -246
  246. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -131
  247. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-worktree.ts +0 -102
  248. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +0 -254
  249. package/dist/builtin/subagents/src/runs/inprocess/child-policy.ts +0 -27
  250. package/dist/builtin/subagents/src/runs/inprocess/control-registry.ts +0 -55
  251. package/dist/builtin/subagents/src/runs/inprocess/control-status.ts +0 -72
  252. package/dist/builtin/subagents/src/runs/inprocess/index.ts +0 -27
  253. package/dist/builtin/subagents/src/runs/inprocess/prompt-behavior.ts +0 -168
  254. package/dist/builtin/subagents/src/runs/inprocess/runner.ts +0 -1280
  255. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/temp-cleanup.ts +0 -69
  256. package/dist/builtin/subagents/src/runs/inprocess.ts +0 -1
  257. package/dist/builtin/subagents/src/runs/shared/intercom-group.ts +0 -67
  258. package/dist/builtin/subagents/src/runs/shared/long-running-guard.ts +0 -182
  259. package/dist/builtin/subagents/src/runs/shared/mcp-direct-tool-allowlist.ts +0 -391
  260. package/dist/builtin/subagents/src/runs/shared/model-candidate-filter.ts +0 -56
  261. package/dist/builtin/subagents/src/runs/shared/model-fallback.ts +0 -88
  262. package/dist/builtin/subagents/src/runs/shared/parallel-utils.ts +0 -70
  263. package/dist/builtin/subagents/src/runs/shared/progress-trend.ts +0 -69
  264. package/dist/builtin/subagents/src/runs/shared/run-history.ts +0 -64
  265. package/dist/builtin/subagents/src/runs/shared/single-output.ts +0 -169
  266. package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +0 -234
  267. package/dist/builtin/subagents/src/runs/shared/worktree-post-create.ts +0 -111
  268. package/dist/builtin/subagents/src/runs/shared/worktree-root.ts +0 -67
  269. package/dist/builtin/subagents/src/runs/shared/worktree.ts +0 -552
  270. package/dist/builtin/subagents/src/shared/artifacts.ts +0 -240
  271. package/dist/builtin/subagents/src/shared/atomic-json.ts +0 -16
  272. package/dist/builtin/subagents/src/shared/event-jsonl-writer.ts +0 -330
  273. package/dist/builtin/subagents/src/shared/exclusive-file-publication.ts +0 -44
  274. package/dist/builtin/subagents/src/shared/fast-mode.ts +0 -87
  275. package/dist/builtin/subagents/src/shared/file-coalescer.ts +0 -40
  276. package/dist/builtin/subagents/src/shared/fork-context.ts +0 -79
  277. package/dist/builtin/subagents/src/shared/formatters.ts +0 -89
  278. package/dist/builtin/subagents/src/shared/jsonl-writer.ts +0 -83
  279. package/dist/builtin/subagents/src/shared/model-info.ts +0 -101
  280. package/dist/builtin/subagents/src/shared/model-resolution.ts +0 -78
  281. package/dist/builtin/subagents/src/shared/session-identity.ts +0 -10
  282. package/dist/builtin/subagents/src/shared/session-tokens.ts +0 -45
  283. package/dist/builtin/subagents/src/shared/settings.ts +0 -118
  284. package/dist/builtin/subagents/src/shared/status-format.ts +0 -50
  285. package/dist/builtin/subagents/src/shared/types-config.ts +0 -206
  286. package/dist/builtin/subagents/src/shared/types-depth.ts +0 -46
  287. package/dist/builtin/subagents/src/shared/types-foreground-state.ts +0 -48
  288. package/dist/builtin/subagents/src/shared/types-output.ts +0 -63
  289. package/dist/builtin/subagents/src/shared/types-results.ts +0 -259
  290. package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -115
  291. package/dist/builtin/subagents/src/shared/types.ts +0 -13
  292. package/dist/builtin/subagents/src/shared/utils.ts +0 -342
  293. package/dist/builtin/subagents/src/slash/bridge-settlement.ts +0 -87
  294. package/dist/builtin/subagents/src/slash/prompt-template-bridge.ts +0 -455
  295. package/dist/builtin/subagents/src/slash/slash-bridge.ts +0 -194
  296. package/dist/builtin/subagents/src/slash/slash-commands.ts +0 -469
  297. package/dist/builtin/subagents/src/slash/slash-live-state.ts +0 -259
  298. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +0 -7
  299. package/dist/builtin/subagents/src/tui/render-helpers.ts +0 -90
  300. package/dist/builtin/subagents/src/tui/render-layout.ts +0 -157
  301. package/dist/builtin/subagents/src/tui/render-progress.ts +0 -89
  302. package/dist/builtin/subagents/src/tui/render-result-animation.ts +0 -47
  303. package/dist/builtin/subagents/src/tui/render-result-compact.ts +0 -248
  304. package/dist/builtin/subagents/src/tui/render-result.ts +0 -438
  305. package/dist/builtin/subagents/src/tui/render-stable-output.ts +0 -50
  306. package/dist/builtin/subagents/src/tui/render-status-progress.ts +0 -168
  307. package/dist/builtin/subagents/src/tui/render.ts +0 -23
  308. package/dist/builtin/web-access/activity.ts +0 -101
  309. package/dist/builtin/web-access/chrome-cookies.ts +0 -323
  310. package/dist/builtin/web-access/code-search.ts +0 -107
  311. package/dist/builtin/web-access/config-paths.ts +0 -11
  312. package/dist/builtin/web-access/content-tools.ts +0 -354
  313. package/dist/builtin/web-access/curator-page-assets/script-1.ts +0 -400
  314. package/dist/builtin/web-access/curator-page-assets/script-2.ts +0 -400
  315. package/dist/builtin/web-access/curator-page-assets/script-3.ts +0 -400
  316. package/dist/builtin/web-access/curator-page-assets/script-4.ts +0 -400
  317. package/dist/builtin/web-access/curator-page-assets/script-5.ts +0 -398
  318. package/dist/builtin/web-access/curator-page-assets/styles-1.ts +0 -394
  319. package/dist/builtin/web-access/curator-page-assets/styles-2.ts +0 -394
  320. package/dist/builtin/web-access/curator-page-assets/styles-3.ts +0 -393
  321. package/dist/builtin/web-access/curator-page.ts +0 -196
  322. package/dist/builtin/web-access/curator-server-helpers.ts +0 -115
  323. package/dist/builtin/web-access/curator-server.ts +0 -494
  324. package/dist/builtin/web-access/exa-mcp.ts +0 -218
  325. package/dist/builtin/web-access/exa.ts +0 -317
  326. package/dist/builtin/web-access/extract-frames.ts +0 -229
  327. package/dist/builtin/web-access/extract.ts +0 -500
  328. package/dist/builtin/web-access/flat-string.ts +0 -37
  329. package/dist/builtin/web-access/gemini-api.ts +0 -111
  330. package/dist/builtin/web-access/gemini-search.ts +0 -363
  331. package/dist/builtin/web-access/gemini-url-context.ts +0 -126
  332. package/dist/builtin/web-access/gemini-web-config.ts +0 -53
  333. package/dist/builtin/web-access/gemini-web.ts +0 -397
  334. package/dist/builtin/web-access/github-api.ts +0 -198
  335. package/dist/builtin/web-access/github-config.ts +0 -156
  336. package/dist/builtin/web-access/github-extract.ts +0 -487
  337. package/dist/builtin/web-access/index-heavy.ts +0 -164
  338. package/dist/builtin/web-access/index.ts +0 -401
  339. package/dist/builtin/web-access/lifecycle-lease.ts +0 -38
  340. package/dist/builtin/web-access/pdf-extract.ts +0 -192
  341. package/dist/builtin/web-access/perplexity.ts +0 -194
  342. package/dist/builtin/web-access/result-renderers.ts +0 -366
  343. package/dist/builtin/web-access/rsc-extract.ts +0 -338
  344. package/dist/builtin/web-access/storage.ts +0 -72
  345. package/dist/builtin/web-access/subprocess.ts +0 -102
  346. package/dist/builtin/web-access/summary-review.ts +0 -287
  347. package/dist/builtin/web-access/utils.ts +0 -44
  348. package/dist/builtin/web-access/video-extract.ts +0 -375
  349. package/dist/builtin/web-access/web-search-activity.ts +0 -102
  350. package/dist/builtin/web-access/web-search-browser.ts +0 -124
  351. package/dist/builtin/web-access/web-search-command.ts +0 -242
  352. package/dist/builtin/web-access/web-search-config.ts +0 -157
  353. package/dist/builtin/web-access/web-search-curator.ts +0 -214
  354. package/dist/builtin/web-access/web-search-features.ts +0 -181
  355. package/dist/builtin/web-access/web-search-formatting.ts +0 -117
  356. package/dist/builtin/web-access/web-search-return.ts +0 -143
  357. package/dist/builtin/web-access/web-search-summary.ts +0 -177
  358. package/dist/builtin/web-access/web-search-tool.ts +0 -286
  359. package/dist/builtin/web-access/web-search-types.ts +0 -50
  360. package/dist/builtin/web-access/web-search-workflow.ts +0 -10
  361. package/dist/builtin/web-access/youtube-extract.ts +0 -309
  362. package/dist/builtin/workflows/src/authoring/keep-context.ts +0 -46
  363. package/dist/builtin/workflows/src/authoring/typebox-defaults.d.ts +0 -41
  364. package/dist/builtin/workflows/src/authoring/typebox-defaults.ts +0 -180
  365. package/dist/builtin/workflows/src/authoring/workflow.ts +0 -206
  366. package/dist/builtin/workflows/src/durable/backend.ts +0 -598
  367. package/dist/builtin/workflows/src/durable/boundary-lifecycle.ts +0 -172
  368. package/dist/builtin/workflows/src/durable/boundary-topology.ts +0 -475
  369. package/dist/builtin/workflows/src/durable/child-invocation.ts +0 -14
  370. package/dist/builtin/workflows/src/durable/child-primitive.ts +0 -124
  371. package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +0 -385
  372. package/dist/builtin/workflows/src/durable/completed-catalog.ts +0 -685
  373. package/dist/builtin/workflows/src/durable/completed-inspection.ts +0 -157
  374. package/dist/builtin/workflows/src/durable/completed-subtree.ts +0 -50
  375. package/dist/builtin/workflows/src/durable/dbos-backend.ts +0 -580
  376. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres-root.ts +0 -681
  377. package/dist/builtin/workflows/src/durable/dbos-embedded-postgres.ts +0 -717
  378. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +0 -516
  379. package/dist/builtin/workflows/src/durable/dbos-lifecycle.ts +0 -208
  380. package/dist/builtin/workflows/src/durable/dbos-local-postgres.ts +0 -166
  381. package/dist/builtin/workflows/src/durable/dbos-metadata.ts +0 -196
  382. package/dist/builtin/workflows/src/durable/dbos-process-owner.ts +0 -87
  383. package/dist/builtin/workflows/src/durable/dbos-prompt-reservations.ts +0 -377
  384. package/dist/builtin/workflows/src/durable/dbos-registration-diagnostics.ts +0 -113
  385. package/dist/builtin/workflows/src/durable/dbos-sdk-handle.ts +0 -182
  386. package/dist/builtin/workflows/src/durable/dbos-status-transition.ts +0 -67
  387. package/dist/builtin/workflows/src/durable/dbos-tombstone.ts +0 -27
  388. package/dist/builtin/workflows/src/durable/durable-hash.ts +0 -18
  389. package/dist/builtin/workflows/src/durable/factory.ts +0 -93
  390. package/dist/builtin/workflows/src/durable/format-version.ts +0 -6
  391. package/dist/builtin/workflows/src/durable/index.ts +0 -82
  392. package/dist/builtin/workflows/src/durable/local-command.ts +0 -135
  393. package/dist/builtin/workflows/src/durable/prompt-reservation-state.ts +0 -184
  394. package/dist/builtin/workflows/src/durable/prompt-reservations.ts +0 -36
  395. package/dist/builtin/workflows/src/durable/resume-catalog.ts +0 -20
  396. package/dist/builtin/workflows/src/durable/resume-eligibility.ts +0 -106
  397. package/dist/builtin/workflows/src/durable/resume-runtime.ts +0 -344
  398. package/dist/builtin/workflows/src/durable/retention-policy.ts +0 -43
  399. package/dist/builtin/workflows/src/durable/run-timing.ts +0 -151
  400. package/dist/builtin/workflows/src/durable/scoped-backend.ts +0 -308
  401. package/dist/builtin/workflows/src/durable/stage-primitive.ts +0 -553
  402. package/dist/builtin/workflows/src/durable/stage-topology-validation.ts +0 -247
  403. package/dist/builtin/workflows/src/durable/stage-topology.ts +0 -53
  404. package/dist/builtin/workflows/src/durable/targeted-inspection.ts +0 -110
  405. package/dist/builtin/workflows/src/durable/tool-failure-checkpoint.ts +0 -54
  406. package/dist/builtin/workflows/src/durable/tool-outcome.ts +0 -130
  407. package/dist/builtin/workflows/src/durable/tool-primitive.ts +0 -861
  408. package/dist/builtin/workflows/src/durable/types.ts +0 -343
  409. package/dist/builtin/workflows/src/durable/ui-primitive.ts +0 -263
  410. package/dist/builtin/workflows/src/durable/workflow-child-result.ts +0 -63
  411. package/dist/builtin/workflows/src/durable/workflow-heartbeat-anchor.ts +0 -153
  412. package/dist/builtin/workflows/src/durable/workflow-status-transition.ts +0 -31
  413. package/dist/builtin/workflows/src/engine/graph-inference.ts +0 -100
  414. package/dist/builtin/workflows/src/engine/options.ts +0 -44
  415. package/dist/builtin/workflows/src/engine/primitives/chain.ts +0 -34
  416. package/dist/builtin/workflows/src/engine/primitives/exit.ts +0 -2
  417. package/dist/builtin/workflows/src/engine/primitives/parallel.ts +0 -74
  418. package/dist/builtin/workflows/src/engine/primitives/task.ts +0 -127
  419. package/dist/builtin/workflows/src/engine/primitives/ui.ts +0 -54
  420. package/dist/builtin/workflows/src/engine/primitives/workflow.ts +0 -219
  421. package/dist/builtin/workflows/src/engine/replay.ts +0 -8
  422. package/dist/builtin/workflows/src/engine/run-budget.ts +0 -308
  423. package/dist/builtin/workflows/src/engine/run-durable-admission.ts +0 -50
  424. package/dist/builtin/workflows/src/engine/run-durable-finalize.ts +0 -97
  425. package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +0 -65
  426. package/dist/builtin/workflows/src/engine/run-durable-topology.ts +0 -295
  427. package/dist/builtin/workflows/src/engine/run-returned-status.ts +0 -86
  428. package/dist/builtin/workflows/src/engine/run-terminal-event.ts +0 -39
  429. package/dist/builtin/workflows/src/engine/run-terminal-failure.ts +0 -53
  430. package/dist/builtin/workflows/src/engine/run-tool-admission-boundary.ts +0 -99
  431. package/dist/builtin/workflows/src/engine/run-tool-control-registry.ts +0 -187
  432. package/dist/builtin/workflows/src/engine/run-tool-execution-tracker.ts +0 -164
  433. package/dist/builtin/workflows/src/engine/run-tool-node-lifecycle.ts +0 -158
  434. package/dist/builtin/workflows/src/engine/run.ts +0 -841
  435. package/dist/builtin/workflows/src/engine/runtime.ts +0 -220
  436. package/dist/builtin/workflows/src/engine/workflow-activity.ts +0 -13
  437. package/dist/builtin/workflows/src/engine/workflow-tool-abort.ts +0 -92
  438. package/dist/builtin/workflows/src/extension/adopt-session-run-state.ts +0 -20
  439. package/dist/builtin/workflows/src/extension/atomic-stage-session.ts +0 -168
  440. package/dist/builtin/workflows/src/extension/background-ui-adapter.ts +0 -154
  441. package/dist/builtin/workflows/src/extension/companions.ts +0 -210
  442. package/dist/builtin/workflows/src/extension/completed-stage-intercom-ask.ts +0 -167
  443. package/dist/builtin/workflows/src/extension/config-file-loader.ts +0 -185
  444. package/dist/builtin/workflows/src/extension/config-loader.ts +0 -439
  445. package/dist/builtin/workflows/src/extension/discovery-loaders.ts +0 -112
  446. package/dist/builtin/workflows/src/extension/discovery.ts +0 -424
  447. package/dist/builtin/workflows/src/extension/dispatcher.ts +0 -273
  448. package/dist/builtin/workflows/src/extension/extension-factory.ts +0 -133
  449. package/dist/builtin/workflows/src/extension/extension-lifecycle.ts +0 -174
  450. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +0 -596
  451. package/dist/builtin/workflows/src/extension/hil-answer-notifications.ts +0 -367
  452. package/dist/builtin/workflows/src/extension/index.ts +0 -42
  453. package/dist/builtin/workflows/src/extension/lifecycle-notification-delivery.ts +0 -83
  454. package/dist/builtin/workflows/src/extension/lifecycle-notifications.ts +0 -849
  455. package/dist/builtin/workflows/src/extension/mcp.ts +0 -121
  456. package/dist/builtin/workflows/src/extension/postmortem-deps.ts +0 -70
  457. package/dist/builtin/workflows/src/extension/public-types.ts +0 -234
  458. package/dist/builtin/workflows/src/extension/render-call.ts +0 -115
  459. package/dist/builtin/workflows/src/extension/render-component.ts +0 -12
  460. package/dist/builtin/workflows/src/extension/render-result.ts +0 -558
  461. package/dist/builtin/workflows/src/extension/renderers.ts +0 -89
  462. package/dist/builtin/workflows/src/extension/runtime-active-block-claim.ts +0 -78
  463. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +0 -174
  464. package/dist/builtin/workflows/src/extension/runtime.ts +0 -439
  465. package/dist/builtin/workflows/src/extension/status-writer.ts +0 -182
  466. package/dist/builtin/workflows/src/extension/ui-surface.ts +0 -387
  467. package/dist/builtin/workflows/src/extension/wiring.ts +0 -490
  468. package/dist/builtin/workflows/src/extension/workflow-command-completions.ts +0 -129
  469. package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +0 -296
  470. package/dist/builtin/workflows/src/extension/workflow-command-surfaces.ts +0 -114
  471. package/dist/builtin/workflows/src/extension/workflow-command-utils.ts +0 -175
  472. package/dist/builtin/workflows/src/extension/workflow-durable-resume-command.ts +0 -270
  473. package/dist/builtin/workflows/src/extension/workflow-heartbeat-delivery.ts +0 -241
  474. package/dist/builtin/workflows/src/extension/workflow-heartbeat-notice.ts +0 -115
  475. package/dist/builtin/workflows/src/extension/workflow-heartbeat-scheduler.ts +0 -962
  476. package/dist/builtin/workflows/src/extension/workflow-model-catalog.ts +0 -24
  477. package/dist/builtin/workflows/src/extension/workflow-module-loader.ts +0 -162
  478. package/dist/builtin/workflows/src/extension/workflow-policy.ts +0 -13
  479. package/dist/builtin/workflows/src/extension/workflow-ports.ts +0 -45
  480. package/dist/builtin/workflows/src/extension/workflow-prompts.ts +0 -73
  481. package/dist/builtin/workflows/src/extension/workflow-reload-coordinator.ts +0 -66
  482. package/dist/builtin/workflows/src/extension/workflow-reload-report.ts +0 -42
  483. package/dist/builtin/workflows/src/extension/workflow-request-abort.ts +0 -15
  484. package/dist/builtin/workflows/src/extension/workflow-resume-picker-rows.ts +0 -96
  485. package/dist/builtin/workflows/src/extension/workflow-resume-shadow.ts +0 -53
  486. package/dist/builtin/workflows/src/extension/workflow-run-control-command.ts +0 -562
  487. package/dist/builtin/workflows/src/extension/workflow-schema.ts +0 -192
  488. package/dist/builtin/workflows/src/extension/workflow-stage-results.ts +0 -252
  489. package/dist/builtin/workflows/src/extension/workflow-status-summary.ts +0 -276
  490. package/dist/builtin/workflows/src/extension/workflow-targets.ts +0 -210
  491. package/dist/builtin/workflows/src/extension/workflow-tool-content.ts +0 -265
  492. package/dist/builtin/workflows/src/extension/workflow-tool-control.ts +0 -547
  493. package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +0 -153
  494. package/dist/builtin/workflows/src/extension/workflow-tool-registration.ts +0 -145
  495. package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +0 -488
  496. package/dist/builtin/workflows/src/extension/workflow-tool.ts +0 -188
  497. package/dist/builtin/workflows/src/index.ts +0 -8
  498. package/dist/builtin/workflows/src/intercom/intercom-bridge.ts +0 -90
  499. package/dist/builtin/workflows/src/intercom/intercom-routing.ts +0 -131
  500. package/dist/builtin/workflows/src/intercom/result-intercom.ts +0 -271
  501. package/dist/builtin/workflows/src/runs/background/cancellation-registry.ts +0 -135
  502. package/dist/builtin/workflows/src/runs/background/durable-resume-transition.ts +0 -63
  503. package/dist/builtin/workflows/src/runs/background/job-tracker.ts +0 -125
  504. package/dist/builtin/workflows/src/runs/background/quit-tool-node.ts +0 -71
  505. package/dist/builtin/workflows/src/runs/background/quit.ts +0 -417
  506. package/dist/builtin/workflows/src/runs/background/resume-acknowledgements.ts +0 -99
  507. package/dist/builtin/workflows/src/runs/background/run-inspect.ts +0 -126
  508. package/dist/builtin/workflows/src/runs/background/runner.ts +0 -185
  509. package/dist/builtin/workflows/src/runs/background/startup-admission.ts +0 -73
  510. package/dist/builtin/workflows/src/runs/background/status.ts +0 -511
  511. package/dist/builtin/workflows/src/runs/background/workflow-lifecycle-aggregate.ts +0 -43
  512. package/dist/builtin/workflows/src/runs/foreground/executor-abort.ts +0 -441
  513. package/dist/builtin/workflows/src/runs/foreground/executor-child-boundary.ts +0 -263
  514. package/dist/builtin/workflows/src/runs/foreground/executor-child-helpers.ts +0 -79
  515. package/dist/builtin/workflows/src/runs/foreground/executor-child-workflow.ts +0 -1
  516. package/dist/builtin/workflows/src/runs/foreground/executor-continuation.ts +0 -207
  517. package/dist/builtin/workflows/src/runs/foreground/executor-direct-helpers.ts +0 -321
  518. package/dist/builtin/workflows/src/runs/foreground/executor-exit-manager.ts +0 -224
  519. package/dist/builtin/workflows/src/runs/foreground/executor-hil.ts +0 -403
  520. package/dist/builtin/workflows/src/runs/foreground/executor-inputs.ts +0 -86
  521. package/dist/builtin/workflows/src/runs/foreground/executor-lifecycle.ts +0 -491
  522. package/dist/builtin/workflows/src/runs/foreground/executor-outputs.ts +0 -156
  523. package/dist/builtin/workflows/src/runs/foreground/executor-prompt-nodes.ts +0 -379
  524. package/dist/builtin/workflows/src/runs/foreground/executor-queued-user-message.ts +0 -75
  525. package/dist/builtin/workflows/src/runs/foreground/executor-run-finalizers.ts +0 -144
  526. package/dist/builtin/workflows/src/runs/foreground/executor-run.ts +0 -1
  527. package/dist/builtin/workflows/src/runs/foreground/executor-scheduler.ts +0 -206
  528. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +0 -434
  529. package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +0 -153
  530. package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +0 -225
  531. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +0 -473
  532. package/dist/builtin/workflows/src/runs/foreground/executor-stage-replay.ts +0 -156
  533. package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +0 -72
  534. package/dist/builtin/workflows/src/runs/foreground/executor-task-context.ts +0 -2
  535. package/dist/builtin/workflows/src/runs/foreground/executor-task-prompts.ts +0 -226
  536. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +0 -186
  537. package/dist/builtin/workflows/src/runs/foreground/executor.ts +0 -25
  538. package/dist/builtin/workflows/src/runs/foreground/postmortem-stage-chat.ts +0 -245
  539. package/dist/builtin/workflows/src/runs/foreground/stage-control-registry.ts +0 -466
  540. package/dist/builtin/workflows/src/runs/foreground/stage-delivery-activity.ts +0 -86
  541. package/dist/builtin/workflows/src/runs/foreground/stage-queued-user-messages.ts +0 -95
  542. package/dist/builtin/workflows/src/runs/foreground/stage-runner-candidate.ts +0 -21
  543. package/dist/builtin/workflows/src/runs/foreground/stage-runner-context.ts +0 -330
  544. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +0 -1472
  545. package/dist/builtin/workflows/src/runs/foreground/stage-runner-message-admission.ts +0 -196
  546. package/dist/builtin/workflows/src/runs/foreground/stage-runner-messages.ts +0 -177
  547. package/dist/builtin/workflows/src/runs/foreground/stage-runner-options.ts +0 -97
  548. package/dist/builtin/workflows/src/runs/foreground/stage-runner-output.ts +0 -278
  549. package/dist/builtin/workflows/src/runs/foreground/stage-runner-pause.ts +0 -206
  550. package/dist/builtin/workflows/src/runs/foreground/stage-runner-replacement.ts +0 -41
  551. package/dist/builtin/workflows/src/runs/foreground/stage-runner-send-user-message.ts +0 -134
  552. package/dist/builtin/workflows/src/runs/foreground/stage-runner-session-options.ts +0 -38
  553. package/dist/builtin/workflows/src/runs/foreground/stage-runner-session.ts +0 -66
  554. package/dist/builtin/workflows/src/runs/foreground/stage-runner-structured-output.ts +0 -120
  555. package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +0 -211
  556. package/dist/builtin/workflows/src/runs/foreground/stage-runner-unresolved-overflow.ts +0 -42
  557. package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +0 -22
  558. package/dist/builtin/workflows/src/runs/foreground/stage-session-heartbeat.ts +0 -88
  559. package/dist/builtin/workflows/src/runs/foreground/stage-tool-execution-buffer.ts +0 -49
  560. package/dist/builtin/workflows/src/runs/shared/concurrency.ts +0 -76
  561. package/dist/builtin/workflows/src/runs/shared/graph-inference.ts +0 -2
  562. package/dist/builtin/workflows/src/runs/shared/model-fallback-candidates.ts +0 -325
  563. package/dist/builtin/workflows/src/runs/shared/model-fallback-failures.ts +0 -19
  564. package/dist/builtin/workflows/src/runs/shared/model-fallback.ts +0 -2
  565. package/dist/builtin/workflows/src/runs/shared/prompt-callsite.ts +0 -96
  566. package/dist/builtin/workflows/src/runs/shared/retry.ts +0 -44
  567. package/dist/builtin/workflows/src/runs/shared/validate-inputs.ts +0 -111
  568. package/dist/builtin/workflows/src/runs/shared/worktree-cache-lifecycle.ts +0 -23
  569. package/dist/builtin/workflows/src/runs/shared/worktree-cwd.ts +0 -116
  570. package/dist/builtin/workflows/src/runs/shared/worktree-diff.ts +0 -172
  571. package/dist/builtin/workflows/src/runs/shared/worktree-generation.ts +0 -57
  572. package/dist/builtin/workflows/src/runs/shared/worktree-git-runner.ts +0 -107
  573. package/dist/builtin/workflows/src/runs/shared/worktree-git.ts +0 -407
  574. package/dist/builtin/workflows/src/runs/shared/worktree-post-create.ts +0 -137
  575. package/dist/builtin/workflows/src/runs/shared/worktree-root.ts +0 -84
  576. package/dist/builtin/workflows/src/runs/shared/worktree-setup.ts +0 -372
  577. package/dist/builtin/workflows/src/runs/shared/worktree-types.ts +0 -102
  578. package/dist/builtin/workflows/src/runs/shared/worktree.ts +0 -21
  579. package/dist/builtin/workflows/src/sdk-surface.ts +0 -70
  580. package/dist/builtin/workflows/src/shared/authoring-contract-stage.d.ts +0 -403
  581. package/dist/builtin/workflows/src/shared/authoring-contract-stage.ts +0 -489
  582. package/dist/builtin/workflows/src/shared/authoring-contract-ui.d.ts +0 -327
  583. package/dist/builtin/workflows/src/shared/authoring-contract-ui.ts +0 -437
  584. package/dist/builtin/workflows/src/shared/budget-meter.ts +0 -34
  585. package/dist/builtin/workflows/src/shared/budget.d.ts +0 -67
  586. package/dist/builtin/workflows/src/shared/budget.ts +0 -127
  587. package/dist/builtin/workflows/src/shared/expanded-workflow-graph.ts +0 -434
  588. package/dist/builtin/workflows/src/shared/flat-string.ts +0 -33
  589. package/dist/builtin/workflows/src/shared/graph-store-snapshot.ts +0 -188
  590. package/dist/builtin/workflows/src/shared/intercom-group.ts +0 -58
  591. package/dist/builtin/workflows/src/shared/persistence-compaction-policy.ts +0 -72
  592. package/dist/builtin/workflows/src/shared/persistence-restore-helpers.ts +0 -613
  593. package/dist/builtin/workflows/src/shared/persistence-restore.ts +0 -306
  594. package/dist/builtin/workflows/src/shared/persistence-session-entries.ts +0 -303
  595. package/dist/builtin/workflows/src/shared/prompt-answer.ts +0 -130
  596. package/dist/builtin/workflows/src/shared/prompt-callsite-context.ts +0 -13
  597. package/dist/builtin/workflows/src/shared/render-inputs-schema.ts +0 -161
  598. package/dist/builtin/workflows/src/shared/resume-continuation.ts +0 -2
  599. package/dist/builtin/workflows/src/shared/returned-run-status.ts +0 -164
  600. package/dist/builtin/workflows/src/shared/run-id.ts +0 -36
  601. package/dist/builtin/workflows/src/shared/run-indicator-status.ts +0 -75
  602. package/dist/builtin/workflows/src/shared/run-visibility.ts +0 -9
  603. package/dist/builtin/workflows/src/shared/schema-introspection.ts +0 -111
  604. package/dist/builtin/workflows/src/shared/serializable.ts +0 -118
  605. package/dist/builtin/workflows/src/shared/session-scoped-singleton.ts +0 -98
  606. package/dist/builtin/workflows/src/shared/session-transcript.ts +0 -79
  607. package/dist/builtin/workflows/src/shared/stage-prompt.ts +0 -338
  608. package/dist/builtin/workflows/src/shared/stage-ui-broker.ts +0 -340
  609. package/dist/builtin/workflows/src/shared/store-factory.ts +0 -26
  610. package/dist/builtin/workflows/src/shared/store-internal.ts +0 -252
  611. package/dist/builtin/workflows/src/shared/store-observation.ts +0 -10
  612. package/dist/builtin/workflows/src/shared/store-prompt-methods.ts +0 -215
  613. package/dist/builtin/workflows/src/shared/store-public-types.ts +0 -282
  614. package/dist/builtin/workflows/src/shared/store-run-methods.ts +0 -305
  615. package/dist/builtin/workflows/src/shared/store-stage-methods.ts +0 -331
  616. package/dist/builtin/workflows/src/shared/store-tool-node-methods.ts +0 -60
  617. package/dist/builtin/workflows/src/shared/store-types.ts +0 -439
  618. package/dist/builtin/workflows/src/shared/store.ts +0 -15
  619. package/dist/builtin/workflows/src/shared/timing.ts +0 -71
  620. package/dist/builtin/workflows/src/shared/tool-payload-bounds.ts +0 -576
  621. package/dist/builtin/workflows/src/shared/types.ts +0 -523
  622. package/dist/builtin/workflows/src/shared/workflow-artifact-env.ts +0 -21
  623. package/dist/builtin/workflows/src/shared/workflow-artifacts.ts +0 -259
  624. package/dist/builtin/workflows/src/shared/workflow-authoring-types.d.ts +0 -60
  625. package/dist/builtin/workflows/src/shared/workflow-authoring-types.ts +0 -111
  626. package/dist/builtin/workflows/src/shared/workflow-failures-classifier.ts +0 -292
  627. package/dist/builtin/workflows/src/shared/workflow-failures-contract.ts +0 -74
  628. package/dist/builtin/workflows/src/shared/workflow-failures-decisions.ts +0 -458
  629. package/dist/builtin/workflows/src/shared/workflow-failures-signals.ts +0 -303
  630. package/dist/builtin/workflows/src/shared/workflow-failures.ts +0 -13
  631. package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.d.ts +0 -21
  632. package/dist/builtin/workflows/src/shared/workflow-heartbeat-contract.ts +0 -25
  633. package/dist/builtin/workflows/src/shared/workflow-run-ownership.ts +0 -49
  634. package/dist/builtin/workflows/src/tui/chat-surface-message.ts +0 -319
  635. package/dist/builtin/workflows/src/tui/chat-surface.ts +0 -477
  636. package/dist/builtin/workflows/src/tui/color-utils.ts +0 -55
  637. package/dist/builtin/workflows/src/tui/connectors.ts +0 -84
  638. package/dist/builtin/workflows/src/tui/dispatch-confirm.ts +0 -334
  639. package/dist/builtin/workflows/src/tui/edge.ts +0 -25
  640. package/dist/builtin/workflows/src/tui/graph-canvas.ts +0 -185
  641. package/dist/builtin/workflows/src/tui/graph-theme.ts +0 -292
  642. package/dist/builtin/workflows/src/tui/graph-view-constants.ts +0 -49
  643. package/dist/builtin/workflows/src/tui/graph-view-graph-render.ts +0 -157
  644. package/dist/builtin/workflows/src/tui/graph-view-input.ts +0 -427
  645. package/dist/builtin/workflows/src/tui/graph-view-layout.ts +0 -297
  646. package/dist/builtin/workflows/src/tui/graph-view-render-helpers.ts +0 -294
  647. package/dist/builtin/workflows/src/tui/graph-view-render.ts +0 -361
  648. package/dist/builtin/workflows/src/tui/graph-view-state.ts +0 -547
  649. package/dist/builtin/workflows/src/tui/graph-view-types.ts +0 -79
  650. package/dist/builtin/workflows/src/tui/graph-view.ts +0 -25
  651. package/dist/builtin/workflows/src/tui/header.ts +0 -210
  652. package/dist/builtin/workflows/src/tui/host-input-form.ts +0 -64
  653. package/dist/builtin/workflows/src/tui/inline-form-card.ts +0 -438
  654. package/dist/builtin/workflows/src/tui/inline-form-editor-text.ts +0 -120
  655. package/dist/builtin/workflows/src/tui/inline-form-editor.ts +0 -496
  656. package/dist/builtin/workflows/src/tui/inline-form-overlay.ts +0 -317
  657. package/dist/builtin/workflows/src/tui/inline-form-store.ts +0 -90
  658. package/dist/builtin/workflows/src/tui/inputs-overlay.ts +0 -185
  659. package/dist/builtin/workflows/src/tui/inputs-picker-editing.ts +0 -147
  660. package/dist/builtin/workflows/src/tui/inputs-picker-input.ts +0 -357
  661. package/dist/builtin/workflows/src/tui/inputs-picker-render.ts +0 -312
  662. package/dist/builtin/workflows/src/tui/inputs-picker-types.ts +0 -161
  663. package/dist/builtin/workflows/src/tui/inputs-picker.ts +0 -20
  664. package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +0 -167
  665. package/dist/builtin/workflows/src/tui/layout.ts +0 -150
  666. package/dist/builtin/workflows/src/tui/mouse-input.ts +0 -61
  667. package/dist/builtin/workflows/src/tui/node-card.ts +0 -357
  668. package/dist/builtin/workflows/src/tui/overlay-adapter.ts +0 -449
  669. package/dist/builtin/workflows/src/tui/overlay-terminal-modes.ts +0 -39
  670. package/dist/builtin/workflows/src/tui/prompt-card-input.ts +0 -215
  671. package/dist/builtin/workflows/src/tui/prompt-card-render.ts +0 -584
  672. package/dist/builtin/workflows/src/tui/prompt-card-select.ts +0 -94
  673. package/dist/builtin/workflows/src/tui/prompt-card-state.ts +0 -61
  674. package/dist/builtin/workflows/src/tui/prompt-card-text.ts +0 -122
  675. package/dist/builtin/workflows/src/tui/prompt-card.ts +0 -12
  676. package/dist/builtin/workflows/src/tui/renderers.ts +0 -14
  677. package/dist/builtin/workflows/src/tui/run-detail.ts +0 -438
  678. package/dist/builtin/workflows/src/tui/run-identity-rows.ts +0 -97
  679. package/dist/builtin/workflows/src/tui/session-list.ts +0 -38
  680. package/dist/builtin/workflows/src/tui/session-overlays.ts +0 -161
  681. package/dist/builtin/workflows/src/tui/session-picker.ts +0 -482
  682. package/dist/builtin/workflows/src/tui/stage-chat-composer-drafts.ts +0 -19
  683. package/dist/builtin/workflows/src/tui/stage-chat-layout.ts +0 -81
  684. package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +0 -462
  685. package/dist/builtin/workflows/src/tui/stage-chat-view-custom-ui.ts +0 -115
  686. package/dist/builtin/workflows/src/tui/stage-chat-view-delivery-activity.ts +0 -113
  687. package/dist/builtin/workflows/src/tui/stage-chat-view-footer-status.ts +0 -219
  688. package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +0 -216
  689. package/dist/builtin/workflows/src/tui/stage-chat-view-live-events.ts +0 -65
  690. package/dist/builtin/workflows/src/tui/stage-chat-view-pending-tools.ts +0 -7
  691. package/dist/builtin/workflows/src/tui/stage-chat-view-render-helpers.ts +0 -149
  692. package/dist/builtin/workflows/src/tui/stage-chat-view-render-settings.ts +0 -49
  693. package/dist/builtin/workflows/src/tui/stage-chat-view-state.ts +0 -575
  694. package/dist/builtin/workflows/src/tui/stage-chat-view-status.ts +0 -35
  695. package/dist/builtin/workflows/src/tui/stage-chat-view-transcript.ts +0 -226
  696. package/dist/builtin/workflows/src/tui/stage-chat-view-types.ts +0 -156
  697. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +0 -309
  698. package/dist/builtin/workflows/src/tui/status-helpers.ts +0 -85
  699. package/dist/builtin/workflows/src/tui/status-list.ts +0 -447
  700. package/dist/builtin/workflows/src/tui/store-widget-installer.ts +0 -338
  701. package/dist/builtin/workflows/src/tui/submit-pane.ts +0 -148
  702. package/dist/builtin/workflows/src/tui/switcher.ts +0 -172
  703. package/dist/builtin/workflows/src/tui/text-helpers.ts +0 -208
  704. package/dist/builtin/workflows/src/tui/tool-detail.ts +0 -367
  705. package/dist/builtin/workflows/src/tui/widget.ts +0 -427
  706. package/dist/builtin/workflows/src/tui/workflow-attach-pane-handle.ts +0 -21
  707. package/dist/builtin/workflows/src/tui/workflow-attach-pane-types.ts +0 -77
  708. package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +0 -477
  709. package/dist/builtin/workflows/src/tui/workflow-list.ts +0 -189
  710. package/dist/builtin/workflows/src/tui/workflow-notice-card.ts +0 -167
  711. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +0 -334
  712. package/dist/builtin/workflows/src/tui/workflow-status.ts +0 -12
  713. package/dist/builtin/workflows/src/workflows/identity.ts +0 -39
  714. package/dist/builtin/workflows/src/workflows/registry.ts +0 -115
@@ -287,17 +287,17 @@ export function _schedulePostAutoCompactionContinuationProbe(_reason, willRetry)
287
287
  pending = new Promise((resolve) => {
288
288
  setTimeout(() => {
289
289
  void (async () => {
290
- const restoreIfOwned = async () => {
290
+ const settleIfOwned = async () => {
291
291
  if (fallbackScopeGeneration === undefined ||
292
292
  this._fallbackOriginGeneration !== fallbackScopeGeneration ||
293
- typeof this._restoreFallbackModel !== "function")
293
+ typeof this._settleFallbackModelScope !== "function")
294
294
  return;
295
295
  try {
296
- await this._restoreFallbackModel();
296
+ await this._settleFallbackModelScope();
297
297
  }
298
298
  catch {
299
- // A listener must not strand the continuation waiter. The model
300
- // state was already restored before lifecycle notifications ran.
299
+ // A listener must not strand the continuation waiter. The fallback
300
+ // state was already settled before lifecycle notifications ran.
301
301
  }
302
302
  };
303
303
  try {
@@ -314,12 +314,12 @@ export function _schedulePostAutoCompactionContinuationProbe(_reason, willRetry)
314
314
  if (this.isCompacting || this.isStreaming)
315
315
  return;
316
316
  if (!this.agent.hasQueuedMessages()) {
317
- await restoreIfOwned();
317
+ await settleIfOwned();
318
318
  return;
319
319
  }
320
- // A queued message starts the next user turn. Restore before
321
- // Agent snapshots the next request's model.
322
- await restoreIfOwned();
320
+ // A queued message starts the next user turn. Settle before Agent
321
+ // snapshots the next request's model.
322
+ await settleIfOwned();
323
323
  }
324
324
  if (this._pendingPostCompactionContinuation !== pending)
325
325
  return;
@@ -329,7 +329,7 @@ export function _schedulePostAutoCompactionContinuationProbe(_reason, willRetry)
329
329
  this._pendingPostCompactionContinuation = undefined;
330
330
  await this._resumeAfterAutoCompaction();
331
331
  if (willRetry && this._pendingPostCompactionContinuation === undefined) {
332
- await restoreIfOwned();
332
+ await settleIfOwned();
333
333
  }
334
334
  }
335
335
  finally {
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-auto-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-auto-compaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAEN,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC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D,CAAC;YAAS,CAAC;QACV,IAAI,IAAI,CAAC,8BAA8B,KAAK,UAAU;YAAE,IAAI,CAAC,8BAA8B,GAAG,SAAS,CAAC;QACxG,IAAI,IAAI,CAAC,iBAAiB,KAAK,MAAM;YAAE,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAC1E,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,yBAAyB,KAAK,UAAU,CAAC,OAAO;YAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;IACvG,CAAC;AACF,CAAC;AAED;;GAEG;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAChD,uCAAuC;IACvC,gBAAgB;IAChB,kDAAkD;IAClD,4CAA4C;IAC5C,0BAA0B;IAC1B,4BAA4B;IAC5B,kBAAkB;CAClB,CAAC","sourcesContent":["import type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport { isContextOverflow, isRecoverableLength } from \"@bastani/pi-ai/compat\";\nimport type { AgentSessionInternalSurface as AgentSession, AutoCompactionRunOutcome } from \"./agent-session-methods.ts\";\nimport {\n\ttype CompactionUrgency,\n\tcalculateContextTokens,\n\testimateContextTokens,\n\tshouldCompact,\n} from \"./compaction/index.ts\";\nimport { MIN_RESPONSES_MAX_OUTPUT_TOKENS } from \"./openai-responses-payload-sanitizer.ts\";\nimport { getLatestCompactionBoundaryEntry } from \"./session-manager.ts\";\n\n/**\n * Upper bound on direct continuations after a response reaches its requested\n * output cap. Context-limited truncations use one compact-and-retry attempt\n * instead; this bound preserves Atomic's separate output-cap continuation.\n */\nexport const MAX_LENGTH_CONTINUATION_ATTEMPTS = 3;\n\nexport const MAX_OUTPUT_BUDGET_ERROR_CONTINUATION_ATTEMPTS = 1;\n\ntype JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\ntype ProviderErrorDetails = {\n\tmessage?: string;\n\tcode?: string;\n\tparam?: string;\n};\n\n/** Create the settlement boundary for a regular automatic compaction run. */\nexport function createAutoCompactionCompletion(): {\n\tpromise: Promise<void>;\n\tresolve: () => void;\n} {\n\tlet resolve!: () => void;\n\tconst promise = new Promise<void>((done) => {\n\t\tresolve = done;\n\t});\n\treturn { promise, resolve };\n}\n\nconst OUTPUT_BUDGET_PARAMETER_PATTERN = /\\bmax_output_tokens\\b/;\nconst OUTPUT_BUDGET_UNDERFLOW_PATTERN = new RegExp(\n\t`(?:integer\\\\s+below\\\\s+minimum\\\\s+value|expected\\\\s+(?:a\\\\s+)?value\\\\s*>=\\\\s*${MIN_RESPONSES_MAX_OUTPUT_TOKENS}|got\\\\s+1\\\\s+instead)`,\n);\n\nexport async function _checkCompaction(\n\tthis: AgentSession,\n\tassistantMessage: AssistantMessage,\n\tskipAbortedCheck = true,\n): Promise<void> {\n\tif (this._pendingPostToolCompactionGuard) {\n\t\tconst { result } = this._pendingPostToolCompactionGuard;\n\t\tthis._pendingPostToolCompactionGuard = undefined;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult,\n\t\t\taborted: true,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\t...(hasPendingManualCompactionTakeover.call(this) ? { manualTakeoverPending: true } : {}),\n\t\t});\n\t}\n\tif (\n\t\tthis._postToolCompactionPreflightError !== undefined &&\n\t\tassistantMessage.errorMessage === this._postToolCompactionPreflightError\n\t) {\n\t\tthis._postToolCompactionPreflightError = undefined;\n\t\treturn;\n\t}\n\t// The agent_end path passes skipAbortedCheck=true; the pre-prompt path passes\n\t// false. Only the live turn-completion path may auto-continue a truncated\n\t// response — before a fresh user prompt we must not resume the old turn.\n\tconst isLiveTurnCompletion = skipAbortedCheck;\n\tconst settings = this.settingsManager.getCompactionSettings();\n\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t// Skip overflow handling if the message came from a different model.\n\t// This handles the case where user switched from a smaller-context model (e.g. opus)\n\t// to a larger-context model (e.g. codex) - the overflow error from the old model\n\t// shouldn't trigger compaction for the new model.\n\tconst sameModel =\n\t\tthis.model !== undefined &&\n\t\tassistantMessage.provider === this.model.provider &&\n\t\tassistantMessage.model === this.model.id;\n\tconst contextOverflow = sameModel && isContextOverflow(assistantMessage, contextWindow);\n\tif (!settings.enabled) {\n\t\t// Compaction cannot recover this turn, so a configured fallback chain may\n\t\t// advance to a larger-context candidate instead of dead-ending.\n\t\tif (contextOverflow) this._contextOverflowUnresolved = true;\n\t\treturn;\n\t}\n\n\t// Skip if message was aborted (user cancelled) - unless skipAbortedCheck is false\n\tif (skipAbortedCheck && assistantMessage.stopReason === \"aborted\") return;\n\n\t// Skip compaction checks if this assistant message is older than the latest\n\t// compaction boundary. This prevents a stale pre-compaction usage/error\n\t// from retriggering compaction on the first prompt after compaction.\n\tconst compactionBoundaryEntry = getLatestCompactionBoundaryEntry(this.sessionManager.getBranch());\n\tconst assistantIsFromBeforeCompactionBoundary =\n\t\tcompactionBoundaryEntry !== null &&\n\t\tassistantMessage.timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime();\n\tif (assistantIsFromBeforeCompactionBoundary) {\n\t\treturn;\n\t}\n\n\t// Case 1: Recoverable failure. Explicit/silent context overflow still uses\n\t// context metadata. A length stop below the model's original requested output\n\t// cap instead receives one compact-and-retry independent of context metadata.\n\t// This recovers a chat response; `truncated-range-recovery` separately parses\n\t// deletion records from a compaction planner response and is not involved here.\n\tconst desiredMaxOutput = this.model?.maxTokens ?? 0;\n\tconst recoverableLength =\n\t\tisLiveTurnCompletion && sameModel && isRecoverableLength(assistantMessage, desiredMaxOutput);\n\tif (contextOverflow || recoverableLength) {\n\t\tconst willRetry = assistantMessage.stopReason !== \"stop\";\n\t\tif (!willRetry) {\n\t\t\tawait this._runAutoCompaction(\"overflow\", false);\n\t\t\treturn;\n\t\t}\n\n\t\tconst recoveryAttempted = contextOverflow\n\t\t\t? this._overflowRecoveryAttempted\n\t\t\t: this._recoverableLengthRecoveryAttempted;\n\t\tif (recoveryAttempted) {\n\t\t\t// One recovery of this kind has already been spent on this turn. A real\n\t\t\t// context overflow may now advance to a larger-context fallback; a\n\t\t\t// recoverable output truncation stops without claiming overflow.\n\t\t\tif (contextOverflow) this._contextOverflowUnresolved = true;\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"overflow\",\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\t...(contextOverflow ? { unresolvedOverflow: true } : {}),\n\t\t\t\terrorMessage: contextOverflow\n\t\t\t\t\t? \"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\"\n\t\t\t\t\t: \"Response truncation recovery stopped after one retry.\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (contextOverflow) this._overflowRecoveryAttempted = true;\n\t\telse this._recoverableLengthRecoveryAttempted = true;\n\t\tlet outcome: AutoCompactionRunOutcome;\n\t\ttry {\n\t\t\toutcome = contextOverflow\n\t\t\t\t? await this._runAutoCompaction(\"overflow\", willRetry)\n\t\t\t\t: await this._runAutoCompaction(\"overflow\", willRetry, \"recoverable\");\n\t\t} catch (error) {\n\t\t\tif (contextOverflow) this._overflowRecoveryAttempted = false;\n\t\t\telse this._recoverableLengthRecoveryAttempted = false;\n\t\t\tthrow error;\n\t\t}\n\t\tif (outcome === \"compacted\" || outcome === \"failed\") return;\n\t\t// No boundary means there is no context to free. Keep this recovery\n\t\t// attempt spent while its one direct continuation is pending, so another\n\t\t// below-cap stop cannot start a new compaction cycle.\n\t\tif (\n\t\t\trecoverableLength &&\n\t\t\toutcome === \"not_compactable\" &&\n\t\t\tthis._compactionAbortController === undefined &&\n\t\t\tthis._manualCompactionPromise === undefined\n\t\t) {\n\t\t\tthis._resumeAfterLengthTruncation();\n\t\t\treturn;\n\t\t}\n\t\tif (contextOverflow) this._overflowRecoveryAttempted = false;\n\t\telse this._recoverableLengthRecoveryAttempted = false;\n\t\treturn;\n\t}\n\n\t// Case 2: Threshold - context is getting large\n\t// For error messages (no usage data), estimate from last successful response.\n\t// This ensures sessions that hit persistent API errors (e.g. 529) can still compact.\n\tlet contextTokens: number;\n\tif (assistantMessage.stopReason === \"error\") {\n\t\tconst messages = this.agent.state.messages;\n\t\tconst estimate = estimateContextTokens(messages);\n\t\tif (estimate.lastUsageIndex === null) return; // No usage data at all\n\t\t// Verify the usage source is post-compaction. Kept pre-compaction messages\n\t\t// have stale usage reflecting the old (larger) context and would falsely\n\t\t// trigger compaction right after one just finished.\n\t\tconst usageMsg = messages[estimate.lastUsageIndex];\n\t\tif (\n\t\t\tcompactionBoundaryEntry &&\n\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime()\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tcontextTokens = estimate.tokens;\n\t} else {\n\t\tcontextTokens = calculateContextTokens(assistantMessage.usage, assistantMessage.api);\n\t}\n\tif (shouldCompact(contextTokens, contextWindow, settings)) {\n\t\tconst willRetry = shouldRetryAfterThresholdCompaction(assistantMessage, desiredMaxOutput, isLiveTurnCompletion);\n\t\tif (willRetry && isRetryWorthyOutputBudgetError(assistantMessage)) {\n\t\t\tif (this._outputBudgetErrorContinuationAttempts >= MAX_OUTPUT_BUDGET_ERROR_CONTINUATION_ATTEMPTS) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"threshold\",\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Output-budget recovery stopped after a compact-and-retry attempt. Try reducing context or switching to a larger-context model.\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._outputBudgetErrorContinuationAttempts += 1;\n\t\t}\n\t\tawait this._runAutoCompaction(\"threshold\", willRetry);\n\t\treturn;\n\t}\n\n\t// A length stop that reached its requested output cap is not the\n\t// context-limited truncation recovered above. Preserve Atomic's bounded\n\t// direct-continuation policy for that distinct case.\n\tif (\n\t\tisLiveTurnCompletion &&\n\t\tisOutputCappedLengthStop(assistantMessage, desiredMaxOutput) &&\n\t\tthis._compactionAbortController === undefined &&\n\t\tthis._manualCompactionPromise === undefined\n\t) {\n\t\tthis._resumeAfterLengthTruncation();\n\t}\n}\n\nexport function isRetryWorthyLengthStop(assistantMessage: AssistantMessage): boolean {\n\treturn assistantMessage.stopReason === \"length\" && assistantMessage.usage.output > 0;\n}\n\nexport function isOutputCappedLengthStop(assistantMessage: AssistantMessage, desiredMaxOutput: number): boolean {\n\treturn isRetryWorthyLengthStop(assistantMessage) && !isRecoverableLength(assistantMessage, desiredMaxOutput);\n}\n\nfunction isJsonRecord(value: JsonValue): value is { [key: string]: JsonValue } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stringField(record: { [key: string]: JsonValue }, key: string): string | undefined {\n\tconst value = record[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction parseProviderErrorDetails(errorMessage: string): ProviderErrorDetails | undefined {\n\tconst start = errorMessage.indexOf(\"{\");\n\tconst end = errorMessage.lastIndexOf(\"}\");\n\tif (start === -1 || end <= start) return undefined;\n\n\ttry {\n\t\tconst parsed = JSON.parse(errorMessage.slice(start, end + 1)) as JsonValue;\n\t\tif (!isJsonRecord(parsed)) return undefined;\n\n\t\tconst nestedError = parsed.error;\n\t\tif (nestedError !== undefined && isJsonRecord(nestedError)) {\n\t\t\treturn {\n\t\t\t\tmessage: stringField(nestedError, \"message\"),\n\t\t\t\tcode: stringField(nestedError, \"code\") ?? stringField(parsed, \"code\"),\n\t\t\t\tparam: stringField(nestedError, \"param\") ?? stringField(parsed, \"param\"),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmessage: stringField(parsed, \"message\"),\n\t\t\tcode: stringField(parsed, \"code\"),\n\t\t\tparam: stringField(parsed, \"param\"),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction isOutputBudgetUnderflowText(text: string): boolean {\n\tconst message = text.toLowerCase();\n\treturn OUTPUT_BUDGET_PARAMETER_PATTERN.test(message) && OUTPUT_BUDGET_UNDERFLOW_PATTERN.test(message);\n}\n\nfunction isStructuredOutputBudgetUnderflow(details: ProviderErrorDetails): boolean {\n\tconst message = details.message?.toLowerCase() ?? \"\";\n\tconst param = details.param?.toLowerCase();\n\tif (!OUTPUT_BUDGET_UNDERFLOW_PATTERN.test(message)) return false;\n\treturn param !== undefined\n\t\t? OUTPUT_BUDGET_PARAMETER_PATTERN.test(param)\n\t\t: OUTPUT_BUDGET_PARAMETER_PATTERN.test(message);\n}\n\nexport function isRetryWorthyOutputBudgetError(assistantMessage: AssistantMessage): boolean {\n\tif (assistantMessage.stopReason !== \"error\" || !assistantMessage.errorMessage) return false;\n\tif (assistantMessage.api !== \"openai-responses\") return false;\n\n\tconst structuredDetails = parseProviderErrorDetails(assistantMessage.errorMessage);\n\tif (structuredDetails && isStructuredOutputBudgetUnderflow(structuredDetails)) return true;\n\n\treturn isOutputBudgetUnderflowText(assistantMessage.errorMessage);\n}\n\nexport function shouldRetryAfterThresholdCompaction(\n\tassistantMessage: AssistantMessage,\n\tdesiredMaxOutput: number,\n\tisLiveTurnCompletion: boolean,\n): boolean {\n\treturn (\n\t\tisRetryWorthyOutputBudgetError(assistantMessage) ||\n\t\t(isLiveTurnCompletion && isOutputCappedLengthStop(assistantMessage, desiredMaxOutput))\n\t);\n}\n\n/**\n * Internal: remove an incomplete assistant from retry context before auto-continuing after compaction.\n */\n\nexport function _dropTrailingAutoCompactionRetryAssistantIfPresent(this: AgentSession): void {\n\tconst messages = this.agent.state.messages;\n\tconst lastMsg = messages[messages.length - 1];\n\tif (lastMsg?.role !== \"assistant\") return;\n\tconst stopReason = (lastMsg as AssistantMessage).stopReason;\n\tif (stopReason === \"error\" || stopReason === \"length\") {\n\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t}\n}\n\n/**\n * Internal: schedule a live post-event continuation after compaction_end listeners can flush queues.\n * The grace period preserves listener ordering. Queue-only probes wait for transient work to become\n * idle, while retry probes remain tied to the turn that scheduled them and are abandoned if another\n * turn owns the agent when the grace period ends.\n */\n\nexport function _schedulePostAutoCompactionContinuationProbe(\n\tthis: AgentSession,\n\t_reason: \"overflow\" | \"threshold\",\n\twillRetry: boolean,\n): void {\n\tconst token = this._postCompactionContinuationToken + 1;\n\tthis._postCompactionContinuationToken = token;\n\tconst fallbackScopeGeneration = this._fallbackOriginGeneration;\n\tlet pending: Promise<void>;\n\tpending = new Promise<void>((resolve) => {\n\t\tsetTimeout(() => {\n\t\t\tvoid (async () => {\n\t\t\t\tconst restoreIfOwned = async (): Promise<void> => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tfallbackScopeGeneration === undefined ||\n\t\t\t\t\t\tthis._fallbackOriginGeneration !== fallbackScopeGeneration ||\n\t\t\t\t\t\ttypeof this._restoreFallbackModel !== \"function\"\n\t\t\t\t\t)\n\t\t\t\t\t\treturn;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._restoreFallbackModel();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// A listener must not strand the continuation waiter. The model\n\t\t\t\t\t\t// state was already restored before lifecycle notifications ran.\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tif (willRetry) {\n\t\t\t\t\t\tif (this._postCompactionContinuationToken !== token) return;\n\t\t\t\t\t\tif (this.isCompacting || this.isStreaming) return;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait this.agent.waitForIdle();\n\t\t\t\t\t\tif (this._postCompactionContinuationToken !== token) return;\n\t\t\t\t\t\tif (this.isCompacting || this.isStreaming) return;\n\t\t\t\t\t\tif (!this.agent.hasQueuedMessages()) {\n\t\t\t\t\t\t\tawait restoreIfOwned();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A queued message starts the next user turn. Restore before\n\t\t\t\t\t\t// Agent snapshots the next request's model.\n\t\t\t\t\t\tawait restoreIfOwned();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._pendingPostCompactionContinuation !== pending) return;\n\t\t\t\t\t// Clear this probe before entering the next run. Its promise is\n\t\t\t\t\t// still awaited by _awaitPendingPostCompactionContinuation, but\n\t\t\t\t\t// the nested agent_end must be free to schedule a new probe.\n\t\t\t\t\tthis._pendingPostCompactionContinuation = undefined;\n\t\t\t\t\tawait this._resumeAfterAutoCompaction();\n\t\t\t\t\tif (willRetry && this._pendingPostCompactionContinuation === undefined) {\n\t\t\t\t\t\tawait restoreIfOwned();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this._pendingPostCompactionContinuation === pending) {\n\t\t\t\t\t\tthis._pendingPostCompactionContinuation = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t})();\n\t\t}, 100);\n\t});\n\tthis._pendingPostCompactionContinuation = pending;\n}\n\nexport async function _awaitPendingPostCompactionContinuation(this: AgentSession): Promise<void> {\n\tconst pending = this._pendingPostCompactionContinuation;\n\tif (pending === undefined) return;\n\tawait pending;\n}\n\n/**\n * Internal: resume generation after successful auto-compaction only when active work remains.\n */\n\nexport async function _resumeAfterAutoCompaction(this: AgentSession): Promise<void> {\n\ttry {\n\t\tawait this._runAgentContinue();\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthis._emit({\n\t\t\ttype: \"agent_continue_error\",\n\t\t\tsource: \"post_compaction\",\n\t\t\terrorMessage: `Post-compaction continuation failed: ${message}`,\n\t\t});\n\t}\n}\n\n/**\n * Internal: resume a response that reached its requested output cap when the\n * context does not warrant compaction. Bounded so a model that repeatedly\n * stops at that cap can still terminate.\n */\n\nexport function _resumeAfterLengthTruncation(this: AgentSession): void {\n\tif (this._lengthContinuationAttempts >= MAX_LENGTH_CONTINUATION_ATTEMPTS) return;\n\tthis._lengthContinuationAttempts += 1;\n\t// agent.continue() rejects an assistant tail; drop the incomplete\n\t// length-stopped message so the preceding user/tool-result anchors the\n\t// continuation. It remains persisted in session history.\n\tthis._dropTrailingAutoCompactionRetryAssistantIfPresent();\n\tthis._schedulePostAutoCompactionContinuationProbe(\"threshold\", true);\n}\n\n/**\n * Whether an overflow turn is now unrecoverable by compaction, recording it on\n * the session so a configured fallback chain may advance to another candidate.\n */\nfunction overflowUnresolved(this: AgentSession, loadBearing: boolean, aborted = false): boolean | undefined {\n\tif (!loadBearing || aborted) return undefined;\n\tthis._contextOverflowUnresolved = true;\n\treturn true;\n}\n\nexport function hasPendingManualCompactionTakeover(this: AgentSession): boolean {\n\treturn this._compactionReason === \"manual\" && this._compactionAbortController !== undefined;\n}\n\nexport async function _runAutoCompaction(\n\tthis: AgentSession,\n\treason: \"overflow\" | \"threshold\",\n\twillRetry: boolean,\n\turgency: CompactionUrgency = reason === \"overflow\" ? \"load_bearing\" : \"recoverable\",\n): Promise<AutoCompactionRunOutcome> {\n\tif (\n\t\tthis._compactionAbortController !== undefined ||\n\t\tthis._manualCompactionPromise !== undefined ||\n\t\tthis._autoCompactionAbortController !== undefined\n\t)\n\t\treturn \"deferred\";\n\n\tconst controller = new AbortController();\n\tconst completion = createAutoCompactionCompletion();\n\tthis._autoCompactionAbortController = controller;\n\tthis._autoCompactionCompletion = completion.promise;\n\tthis._compactionReason = reason;\n\ttry {\n\t\tthis._emit({ type: \"compaction_start\", reason });\n\t} catch (error) {\n\t\t// A throwing start listener still propagates, matching current behavior,\n\t\t// but must not leave ownership published with no owner running.\n\t\tif (this._autoCompactionAbortController === controller) this._autoCompactionAbortController = undefined;\n\t\tif (this._compactionReason === reason) this._compactionReason = undefined;\n\t\tcompletion.resolve();\n\t\tif (this._autoCompactionCompletion === completion.promise) this._autoCompactionCompletion = undefined;\n\t\tthrow error;\n\t}\n\n\ttry {\n\t\tif (!this.model) {\n\t\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\"),\n\t\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\t});\n\t\t\treturn manualTakeoverPending ? \"deferred\" : \"failed\";\n\t\t}\n\n\t\t// Resolve auth only after extension hooks have had an opportunity to cancel\n\t\t// compaction or provide compacted text, so local extension compaction does not\n\t\t// require provider credentials. Missing auth then fails model-driven compaction\n\t\t// before persistence or continuation, matching other provider-call failures.\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\tresolvePlannerAuth: async (candidate) => {\n\t\t\t\tconst authResult = await this._getRequiredRequestAuth(candidate);\n\t\t\t\treturn authResult.apiKey || authResult.headers ? authResult : undefined;\n\t\t\t},\n\t\t\tabortController: controller,\n\t\t\tbackupLabel: urgency === \"load_bearing\" ? \"overflow-auto-compact\" : \"auto-compact\",\n\t\t\treason,\n\t\t\turgency,\n\t\t\t// Only an actual context overflow proved the context cannot fit. A\n\t\t\t// recoverable length stop must never reach the fresh-context fallback.\n\t\t\t...(urgency === \"load_bearing\" ? { allowSmallRegion: true } : {}),\n\t\t});\n\t\tif (!result) {\n\t\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\"),\n\t\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\t});\n\t\t\treturn manualTakeoverPending ? \"deferred\" : \"not_compactable\";\n\t\t}\n\n\t\tif (willRetry) {\n\t\t\tthis._dropTrailingAutoCompactionRetryAssistantIfPresent();\n\t\t}\n\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason,\n\t\t\tresult,\n\t\t\taborted: false,\n\t\t\twillRetry,\n\t\t\t...(hasPendingManualCompactionTakeover.call(this) ? { manualTakeoverPending: true } : {}),\n\t\t});\n\t\tif (!hasPendingManualCompactionTakeover.call(this)) {\n\t\t\tthis._schedulePostAutoCompactionContinuationProbe(reason, willRetry);\n\t\t}\n\t\treturn \"compacted\";\n\t} catch (error) {\n\t\tconst errorMessage = error instanceof Error ? error.message : \"compaction failed\";\n\t\tconst aborted =\n\t\t\terrorMessage === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason,\n\t\t\tresult: undefined,\n\t\t\taborted,\n\t\t\twillRetry: false,\n\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\", aborted),\n\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\terrorMessage: aborted\n\t\t\t\t? undefined\n\t\t\t\t: reason === \"overflow\"\n\t\t\t\t\t? urgency === \"recoverable\"\n\t\t\t\t\t\t? `Response truncation recovery failed: ${errorMessage}`\n\t\t\t\t\t\t: `Context overflow recovery failed: ${errorMessage}`\n\t\t\t\t\t: `Auto-compaction failed: ${errorMessage}`,\n\t\t});\n\t\treturn manualTakeoverPending ? \"deferred\" : \"failed\";\n\t} finally {\n\t\tif (this._autoCompactionAbortController === controller) this._autoCompactionAbortController = undefined;\n\t\tif (this._compactionReason === reason) this._compactionReason = undefined;\n\t\tcompletion.resolve();\n\t\tif (this._autoCompactionCompletion === completion.promise) this._autoCompactionCompletion = undefined;\n\t}\n}\n\n/**\n * Toggle auto-compaction setting.\n */\n\nexport const agentSessionAutoCompactionMethods = {\n\t_awaitPendingPostCompactionContinuation,\n\t_checkCompaction,\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent,\n\t_schedulePostAutoCompactionContinuationProbe,\n\t_resumeAfterAutoCompaction,\n\t_resumeAfterLengthTruncation,\n\t_runAutoCompaction,\n};\n"]}
1
+ {"version":3,"file":"agent-session-auto-compaction.js","sourceRoot":"","sources":["../../src/core/agent-session-auto-compaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE/E,OAAO,EAEN,sBAAsB,EACtB,qBAAqB,EACrB,aAAa,GACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,+BAA+B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAC;AAElD,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC;AAS/D,6EAA6E;AAC7E,MAAM,UAAU,8BAA8B;IAI7C,IAAI,OAAoB,CAAC;IACzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAO,CAAC,IAAI,EAAE,EAAE;QAC1C,OAAO,GAAG,IAAI,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC;AAED,MAAM,+BAA+B,GAAG,uBAAuB,CAAC;AAChE,MAAM,+BAA+B,GAAG,IAAI,MAAM,CACjD,gFAAgF,+BAA+B,uBAAuB,CACtI,CAAC;AAEF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAErC,gBAAkC,EAClC,gBAAgB,GAAG,IAAI;IAEvB,IAAI,IAAI,CAAC,+BAA+B,EAAE,CAAC;QAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,+BAA+B,CAAC;QACxD,IAAI,CAAC,+BAA+B,GAAG,SAAS,CAAC;QACjD,IAAI,CAAC,KAAK,CAAC;YACV,IAAI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SAAS;YACjB,OAAO;YACP,SAAS,EAAE,KAAK;YAChB,kBAAkB,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,KAAK,cAAc,EAAE,OAAO,CAAC;YACtF,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAC,EAAE,qBAAqB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;YACjE,YAAY,EAAE,OAAO;gBACpB,CAAC,CAAC,SAAS;gBACX,CAAC,CAAC,MAAM,KAAK,UAAU;oBACtB,CAAC,CAAC,OAAO,KAAK,aAAa;wBAC1B,CAAC,CAAC,wCAAwC,YAAY,EAAE;wBACxD,CAAC,CAAC,qCAAqC,YAAY,EAAE;oBACtD,CAAC,CAAC,2BAA2B,YAAY,EAAE;SAC7C,CAAC,CAAC;QACH,OAAO,qBAAqB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;IACtD,CAAC;YAAS,CAAC;QACV,IAAI,IAAI,CAAC,8BAA8B,KAAK,UAAU;YAAE,IAAI,CAAC,8BAA8B,GAAG,SAAS,CAAC;QACxG,IAAI,IAAI,CAAC,iBAAiB,KAAK,MAAM;YAAE,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QAC1E,UAAU,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,IAAI,CAAC,yBAAyB,KAAK,UAAU,CAAC,OAAO;YAAE,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;IACvG,CAAC;AACF,CAAC;AAED;;GAEG;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAChD,uCAAuC;IACvC,gBAAgB;IAChB,kDAAkD;IAClD,4CAA4C;IAC5C,0BAA0B;IAC1B,4BAA4B;IAC5B,kBAAkB;CAClB,CAAC","sourcesContent":["import type { AssistantMessage } from \"@bastani/pi-ai/compat\";\nimport { isContextOverflow, isRecoverableLength } from \"@bastani/pi-ai/compat\";\nimport type { AgentSessionInternalSurface as AgentSession, AutoCompactionRunOutcome } from \"./agent-session-methods.ts\";\nimport {\n\ttype CompactionUrgency,\n\tcalculateContextTokens,\n\testimateContextTokens,\n\tshouldCompact,\n} from \"./compaction/index.ts\";\nimport { MIN_RESPONSES_MAX_OUTPUT_TOKENS } from \"./openai-responses-payload-sanitizer.ts\";\nimport { getLatestCompactionBoundaryEntry } from \"./session-manager.ts\";\n\n/**\n * Upper bound on direct continuations after a response reaches its requested\n * output cap. Context-limited truncations use one compact-and-retry attempt\n * instead; this bound preserves Atomic's separate output-cap continuation.\n */\nexport const MAX_LENGTH_CONTINUATION_ATTEMPTS = 3;\n\nexport const MAX_OUTPUT_BUDGET_ERROR_CONTINUATION_ATTEMPTS = 1;\n\ntype JsonValue = string | number | boolean | null | JsonValue[] | { [key: string]: JsonValue };\ntype ProviderErrorDetails = {\n\tmessage?: string;\n\tcode?: string;\n\tparam?: string;\n};\n\n/** Create the settlement boundary for a regular automatic compaction run. */\nexport function createAutoCompactionCompletion(): {\n\tpromise: Promise<void>;\n\tresolve: () => void;\n} {\n\tlet resolve!: () => void;\n\tconst promise = new Promise<void>((done) => {\n\t\tresolve = done;\n\t});\n\treturn { promise, resolve };\n}\n\nconst OUTPUT_BUDGET_PARAMETER_PATTERN = /\\bmax_output_tokens\\b/;\nconst OUTPUT_BUDGET_UNDERFLOW_PATTERN = new RegExp(\n\t`(?:integer\\\\s+below\\\\s+minimum\\\\s+value|expected\\\\s+(?:a\\\\s+)?value\\\\s*>=\\\\s*${MIN_RESPONSES_MAX_OUTPUT_TOKENS}|got\\\\s+1\\\\s+instead)`,\n);\n\nexport async function _checkCompaction(\n\tthis: AgentSession,\n\tassistantMessage: AssistantMessage,\n\tskipAbortedCheck = true,\n): Promise<void> {\n\tif (this._pendingPostToolCompactionGuard) {\n\t\tconst { result } = this._pendingPostToolCompactionGuard;\n\t\tthis._pendingPostToolCompactionGuard = undefined;\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason: \"threshold\",\n\t\t\tresult,\n\t\t\taborted: true,\n\t\t\twillRetry: false,\n\t\t\tmidTurn: true,\n\t\t\t...(hasPendingManualCompactionTakeover.call(this) ? { manualTakeoverPending: true } : {}),\n\t\t});\n\t}\n\tif (\n\t\tthis._postToolCompactionPreflightError !== undefined &&\n\t\tassistantMessage.errorMessage === this._postToolCompactionPreflightError\n\t) {\n\t\tthis._postToolCompactionPreflightError = undefined;\n\t\treturn;\n\t}\n\t// The agent_end path passes skipAbortedCheck=true; the pre-prompt path passes\n\t// false. Only the live turn-completion path may auto-continue a truncated\n\t// response — before a fresh user prompt we must not resume the old turn.\n\tconst isLiveTurnCompletion = skipAbortedCheck;\n\tconst settings = this.settingsManager.getCompactionSettings();\n\tconst contextWindow = this.model?.contextWindow ?? 0;\n\t// Skip overflow handling if the message came from a different model.\n\t// This handles the case where user switched from a smaller-context model (e.g. opus)\n\t// to a larger-context model (e.g. codex) - the overflow error from the old model\n\t// shouldn't trigger compaction for the new model.\n\tconst sameModel =\n\t\tthis.model !== undefined &&\n\t\tassistantMessage.provider === this.model.provider &&\n\t\tassistantMessage.model === this.model.id;\n\tconst contextOverflow = sameModel && isContextOverflow(assistantMessage, contextWindow);\n\tif (!settings.enabled) {\n\t\t// Compaction cannot recover this turn, so a configured fallback chain may\n\t\t// advance to a larger-context candidate instead of dead-ending.\n\t\tif (contextOverflow) this._contextOverflowUnresolved = true;\n\t\treturn;\n\t}\n\n\t// Skip if message was aborted (user cancelled) - unless skipAbortedCheck is false\n\tif (skipAbortedCheck && assistantMessage.stopReason === \"aborted\") return;\n\n\t// Skip compaction checks if this assistant message is older than the latest\n\t// compaction boundary. This prevents a stale pre-compaction usage/error\n\t// from retriggering compaction on the first prompt after compaction.\n\tconst compactionBoundaryEntry = getLatestCompactionBoundaryEntry(this.sessionManager.getBranch());\n\tconst assistantIsFromBeforeCompactionBoundary =\n\t\tcompactionBoundaryEntry !== null &&\n\t\tassistantMessage.timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime();\n\tif (assistantIsFromBeforeCompactionBoundary) {\n\t\treturn;\n\t}\n\n\t// Case 1: Recoverable failure. Explicit/silent context overflow still uses\n\t// context metadata. A length stop below the model's original requested output\n\t// cap instead receives one compact-and-retry independent of context metadata.\n\t// This recovers a chat response; `truncated-range-recovery` separately parses\n\t// deletion records from a compaction planner response and is not involved here.\n\tconst desiredMaxOutput = this.model?.maxTokens ?? 0;\n\tconst recoverableLength =\n\t\tisLiveTurnCompletion && sameModel && isRecoverableLength(assistantMessage, desiredMaxOutput);\n\tif (contextOverflow || recoverableLength) {\n\t\tconst willRetry = assistantMessage.stopReason !== \"stop\";\n\t\tif (!willRetry) {\n\t\t\tawait this._runAutoCompaction(\"overflow\", false);\n\t\t\treturn;\n\t\t}\n\n\t\tconst recoveryAttempted = contextOverflow\n\t\t\t? this._overflowRecoveryAttempted\n\t\t\t: this._recoverableLengthRecoveryAttempted;\n\t\tif (recoveryAttempted) {\n\t\t\t// One recovery of this kind has already been spent on this turn. A real\n\t\t\t// context overflow may now advance to a larger-context fallback; a\n\t\t\t// recoverable output truncation stops without claiming overflow.\n\t\t\tif (contextOverflow) this._contextOverflowUnresolved = true;\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason: \"overflow\",\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\t...(contextOverflow ? { unresolvedOverflow: true } : {}),\n\t\t\t\terrorMessage: contextOverflow\n\t\t\t\t\t? \"Context overflow recovery failed after one compact-and-retry attempt. Try reducing context or switching to a larger-context model.\"\n\t\t\t\t\t: \"Response truncation recovery stopped after one retry.\",\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\n\t\tif (contextOverflow) this._overflowRecoveryAttempted = true;\n\t\telse this._recoverableLengthRecoveryAttempted = true;\n\t\tlet outcome: AutoCompactionRunOutcome;\n\t\ttry {\n\t\t\toutcome = contextOverflow\n\t\t\t\t? await this._runAutoCompaction(\"overflow\", willRetry)\n\t\t\t\t: await this._runAutoCompaction(\"overflow\", willRetry, \"recoverable\");\n\t\t} catch (error) {\n\t\t\tif (contextOverflow) this._overflowRecoveryAttempted = false;\n\t\t\telse this._recoverableLengthRecoveryAttempted = false;\n\t\t\tthrow error;\n\t\t}\n\t\tif (outcome === \"compacted\" || outcome === \"failed\") return;\n\t\t// No boundary means there is no context to free. Keep this recovery\n\t\t// attempt spent while its one direct continuation is pending, so another\n\t\t// below-cap stop cannot start a new compaction cycle.\n\t\tif (\n\t\t\trecoverableLength &&\n\t\t\toutcome === \"not_compactable\" &&\n\t\t\tthis._compactionAbortController === undefined &&\n\t\t\tthis._manualCompactionPromise === undefined\n\t\t) {\n\t\t\tthis._resumeAfterLengthTruncation();\n\t\t\treturn;\n\t\t}\n\t\tif (contextOverflow) this._overflowRecoveryAttempted = false;\n\t\telse this._recoverableLengthRecoveryAttempted = false;\n\t\treturn;\n\t}\n\n\t// Case 2: Threshold - context is getting large\n\t// For error messages (no usage data), estimate from last successful response.\n\t// This ensures sessions that hit persistent API errors (e.g. 529) can still compact.\n\tlet contextTokens: number;\n\tif (assistantMessage.stopReason === \"error\") {\n\t\tconst messages = this.agent.state.messages;\n\t\tconst estimate = estimateContextTokens(messages);\n\t\tif (estimate.lastUsageIndex === null) return; // No usage data at all\n\t\t// Verify the usage source is post-compaction. Kept pre-compaction messages\n\t\t// have stale usage reflecting the old (larger) context and would falsely\n\t\t// trigger compaction right after one just finished.\n\t\tconst usageMsg = messages[estimate.lastUsageIndex];\n\t\tif (\n\t\t\tcompactionBoundaryEntry &&\n\t\t\tusageMsg.role === \"assistant\" &&\n\t\t\t(usageMsg as AssistantMessage).timestamp <= new Date(compactionBoundaryEntry.timestamp).getTime()\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tcontextTokens = estimate.tokens;\n\t} else {\n\t\tcontextTokens = calculateContextTokens(assistantMessage.usage, assistantMessage.api);\n\t}\n\tif (shouldCompact(contextTokens, contextWindow, settings)) {\n\t\tconst willRetry = shouldRetryAfterThresholdCompaction(assistantMessage, desiredMaxOutput, isLiveTurnCompletion);\n\t\tif (willRetry && isRetryWorthyOutputBudgetError(assistantMessage)) {\n\t\t\tif (this._outputBudgetErrorContinuationAttempts >= MAX_OUTPUT_BUDGET_ERROR_CONTINUATION_ATTEMPTS) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"compaction_end\",\n\t\t\t\t\treason: \"threshold\",\n\t\t\t\t\tresult: undefined,\n\t\t\t\t\taborted: false,\n\t\t\t\t\twillRetry: false,\n\t\t\t\t\terrorMessage:\n\t\t\t\t\t\t\"Output-budget recovery stopped after a compact-and-retry attempt. Try reducing context or switching to a larger-context model.\",\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis._outputBudgetErrorContinuationAttempts += 1;\n\t\t}\n\t\tawait this._runAutoCompaction(\"threshold\", willRetry);\n\t\treturn;\n\t}\n\n\t// A length stop that reached its requested output cap is not the\n\t// context-limited truncation recovered above. Preserve Atomic's bounded\n\t// direct-continuation policy for that distinct case.\n\tif (\n\t\tisLiveTurnCompletion &&\n\t\tisOutputCappedLengthStop(assistantMessage, desiredMaxOutput) &&\n\t\tthis._compactionAbortController === undefined &&\n\t\tthis._manualCompactionPromise === undefined\n\t) {\n\t\tthis._resumeAfterLengthTruncation();\n\t}\n}\n\nexport function isRetryWorthyLengthStop(assistantMessage: AssistantMessage): boolean {\n\treturn assistantMessage.stopReason === \"length\" && assistantMessage.usage.output > 0;\n}\n\nexport function isOutputCappedLengthStop(assistantMessage: AssistantMessage, desiredMaxOutput: number): boolean {\n\treturn isRetryWorthyLengthStop(assistantMessage) && !isRecoverableLength(assistantMessage, desiredMaxOutput);\n}\n\nfunction isJsonRecord(value: JsonValue): value is { [key: string]: JsonValue } {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction stringField(record: { [key: string]: JsonValue }, key: string): string | undefined {\n\tconst value = record[key];\n\treturn typeof value === \"string\" ? value : undefined;\n}\n\nfunction parseProviderErrorDetails(errorMessage: string): ProviderErrorDetails | undefined {\n\tconst start = errorMessage.indexOf(\"{\");\n\tconst end = errorMessage.lastIndexOf(\"}\");\n\tif (start === -1 || end <= start) return undefined;\n\n\ttry {\n\t\tconst parsed = JSON.parse(errorMessage.slice(start, end + 1)) as JsonValue;\n\t\tif (!isJsonRecord(parsed)) return undefined;\n\n\t\tconst nestedError = parsed.error;\n\t\tif (nestedError !== undefined && isJsonRecord(nestedError)) {\n\t\t\treturn {\n\t\t\t\tmessage: stringField(nestedError, \"message\"),\n\t\t\t\tcode: stringField(nestedError, \"code\") ?? stringField(parsed, \"code\"),\n\t\t\t\tparam: stringField(nestedError, \"param\") ?? stringField(parsed, \"param\"),\n\t\t\t};\n\t\t}\n\n\t\treturn {\n\t\t\tmessage: stringField(parsed, \"message\"),\n\t\t\tcode: stringField(parsed, \"code\"),\n\t\t\tparam: stringField(parsed, \"param\"),\n\t\t};\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction isOutputBudgetUnderflowText(text: string): boolean {\n\tconst message = text.toLowerCase();\n\treturn OUTPUT_BUDGET_PARAMETER_PATTERN.test(message) && OUTPUT_BUDGET_UNDERFLOW_PATTERN.test(message);\n}\n\nfunction isStructuredOutputBudgetUnderflow(details: ProviderErrorDetails): boolean {\n\tconst message = details.message?.toLowerCase() ?? \"\";\n\tconst param = details.param?.toLowerCase();\n\tif (!OUTPUT_BUDGET_UNDERFLOW_PATTERN.test(message)) return false;\n\treturn param !== undefined\n\t\t? OUTPUT_BUDGET_PARAMETER_PATTERN.test(param)\n\t\t: OUTPUT_BUDGET_PARAMETER_PATTERN.test(message);\n}\n\nexport function isRetryWorthyOutputBudgetError(assistantMessage: AssistantMessage): boolean {\n\tif (assistantMessage.stopReason !== \"error\" || !assistantMessage.errorMessage) return false;\n\tif (assistantMessage.api !== \"openai-responses\") return false;\n\n\tconst structuredDetails = parseProviderErrorDetails(assistantMessage.errorMessage);\n\tif (structuredDetails && isStructuredOutputBudgetUnderflow(structuredDetails)) return true;\n\n\treturn isOutputBudgetUnderflowText(assistantMessage.errorMessage);\n}\n\nexport function shouldRetryAfterThresholdCompaction(\n\tassistantMessage: AssistantMessage,\n\tdesiredMaxOutput: number,\n\tisLiveTurnCompletion: boolean,\n): boolean {\n\treturn (\n\t\tisRetryWorthyOutputBudgetError(assistantMessage) ||\n\t\t(isLiveTurnCompletion && isOutputCappedLengthStop(assistantMessage, desiredMaxOutput))\n\t);\n}\n\n/**\n * Internal: remove an incomplete assistant from retry context before auto-continuing after compaction.\n */\n\nexport function _dropTrailingAutoCompactionRetryAssistantIfPresent(this: AgentSession): void {\n\tconst messages = this.agent.state.messages;\n\tconst lastMsg = messages[messages.length - 1];\n\tif (lastMsg?.role !== \"assistant\") return;\n\tconst stopReason = (lastMsg as AssistantMessage).stopReason;\n\tif (stopReason === \"error\" || stopReason === \"length\") {\n\t\tthis.agent.state.messages = messages.slice(0, -1);\n\t}\n}\n\n/**\n * Internal: schedule a live post-event continuation after compaction_end listeners can flush queues.\n * The grace period preserves listener ordering. Queue-only probes wait for transient work to become\n * idle, while retry probes remain tied to the turn that scheduled them and are abandoned if another\n * turn owns the agent when the grace period ends.\n */\n\nexport function _schedulePostAutoCompactionContinuationProbe(\n\tthis: AgentSession,\n\t_reason: \"overflow\" | \"threshold\",\n\twillRetry: boolean,\n): void {\n\tconst token = this._postCompactionContinuationToken + 1;\n\tthis._postCompactionContinuationToken = token;\n\tconst fallbackScopeGeneration = this._fallbackOriginGeneration;\n\tlet pending: Promise<void>;\n\tpending = new Promise<void>((resolve) => {\n\t\tsetTimeout(() => {\n\t\t\tvoid (async () => {\n\t\t\t\tconst settleIfOwned = async (): Promise<void> => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tfallbackScopeGeneration === undefined ||\n\t\t\t\t\t\tthis._fallbackOriginGeneration !== fallbackScopeGeneration ||\n\t\t\t\t\t\ttypeof this._settleFallbackModelScope !== \"function\"\n\t\t\t\t\t)\n\t\t\t\t\t\treturn;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait this._settleFallbackModelScope();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// A listener must not strand the continuation waiter. The fallback\n\t\t\t\t\t\t// state was already settled before lifecycle notifications ran.\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tif (willRetry) {\n\t\t\t\t\t\tif (this._postCompactionContinuationToken !== token) return;\n\t\t\t\t\t\tif (this.isCompacting || this.isStreaming) return;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tawait this.agent.waitForIdle();\n\t\t\t\t\t\tif (this._postCompactionContinuationToken !== token) return;\n\t\t\t\t\t\tif (this.isCompacting || this.isStreaming) return;\n\t\t\t\t\t\tif (!this.agent.hasQueuedMessages()) {\n\t\t\t\t\t\t\tawait settleIfOwned();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// A queued message starts the next user turn. Settle before Agent\n\t\t\t\t\t\t// snapshots the next request's model.\n\t\t\t\t\t\tawait settleIfOwned();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (this._pendingPostCompactionContinuation !== pending) return;\n\t\t\t\t\t// Clear this probe before entering the next run. Its promise is\n\t\t\t\t\t// still awaited by _awaitPendingPostCompactionContinuation, but\n\t\t\t\t\t// the nested agent_end must be free to schedule a new probe.\n\t\t\t\t\tthis._pendingPostCompactionContinuation = undefined;\n\t\t\t\t\tawait this._resumeAfterAutoCompaction();\n\t\t\t\t\tif (willRetry && this._pendingPostCompactionContinuation === undefined) {\n\t\t\t\t\t\tawait settleIfOwned();\n\t\t\t\t\t}\n\t\t\t\t} finally {\n\t\t\t\t\tif (this._pendingPostCompactionContinuation === pending) {\n\t\t\t\t\t\tthis._pendingPostCompactionContinuation = undefined;\n\t\t\t\t\t}\n\t\t\t\t\tresolve();\n\t\t\t\t}\n\t\t\t})();\n\t\t}, 100);\n\t});\n\tthis._pendingPostCompactionContinuation = pending;\n}\n\nexport async function _awaitPendingPostCompactionContinuation(this: AgentSession): Promise<void> {\n\tconst pending = this._pendingPostCompactionContinuation;\n\tif (pending === undefined) return;\n\tawait pending;\n}\n\n/**\n * Internal: resume generation after successful auto-compaction only when active work remains.\n */\n\nexport async function _resumeAfterAutoCompaction(this: AgentSession): Promise<void> {\n\ttry {\n\t\tawait this._runAgentContinue();\n\t} catch (error) {\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthis._emit({\n\t\t\ttype: \"agent_continue_error\",\n\t\t\tsource: \"post_compaction\",\n\t\t\terrorMessage: `Post-compaction continuation failed: ${message}`,\n\t\t});\n\t}\n}\n\n/**\n * Internal: resume a response that reached its requested output cap when the\n * context does not warrant compaction. Bounded so a model that repeatedly\n * stops at that cap can still terminate.\n */\n\nexport function _resumeAfterLengthTruncation(this: AgentSession): void {\n\tif (this._lengthContinuationAttempts >= MAX_LENGTH_CONTINUATION_ATTEMPTS) return;\n\tthis._lengthContinuationAttempts += 1;\n\t// agent.continue() rejects an assistant tail; drop the incomplete\n\t// length-stopped message so the preceding user/tool-result anchors the\n\t// continuation. It remains persisted in session history.\n\tthis._dropTrailingAutoCompactionRetryAssistantIfPresent();\n\tthis._schedulePostAutoCompactionContinuationProbe(\"threshold\", true);\n}\n\n/**\n * Whether an overflow turn is now unrecoverable by compaction, recording it on\n * the session so a configured fallback chain may advance to another candidate.\n */\nfunction overflowUnresolved(this: AgentSession, loadBearing: boolean, aborted = false): boolean | undefined {\n\tif (!loadBearing || aborted) return undefined;\n\tthis._contextOverflowUnresolved = true;\n\treturn true;\n}\n\nexport function hasPendingManualCompactionTakeover(this: AgentSession): boolean {\n\treturn this._compactionReason === \"manual\" && this._compactionAbortController !== undefined;\n}\n\nexport async function _runAutoCompaction(\n\tthis: AgentSession,\n\treason: \"overflow\" | \"threshold\",\n\twillRetry: boolean,\n\turgency: CompactionUrgency = reason === \"overflow\" ? \"load_bearing\" : \"recoverable\",\n): Promise<AutoCompactionRunOutcome> {\n\tif (\n\t\tthis._compactionAbortController !== undefined ||\n\t\tthis._manualCompactionPromise !== undefined ||\n\t\tthis._autoCompactionAbortController !== undefined\n\t)\n\t\treturn \"deferred\";\n\n\tconst controller = new AbortController();\n\tconst completion = createAutoCompactionCompletion();\n\tthis._autoCompactionAbortController = controller;\n\tthis._autoCompactionCompletion = completion.promise;\n\tthis._compactionReason = reason;\n\ttry {\n\t\tthis._emit({ type: \"compaction_start\", reason });\n\t} catch (error) {\n\t\t// A throwing start listener still propagates, matching current behavior,\n\t\t// but must not leave ownership published with no owner running.\n\t\tif (this._autoCompactionAbortController === controller) this._autoCompactionAbortController = undefined;\n\t\tif (this._compactionReason === reason) this._compactionReason = undefined;\n\t\tcompletion.resolve();\n\t\tif (this._autoCompactionCompletion === completion.promise) this._autoCompactionCompletion = undefined;\n\t\tthrow error;\n\t}\n\n\ttry {\n\t\tif (!this.model) {\n\t\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\"),\n\t\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\t});\n\t\t\treturn manualTakeoverPending ? \"deferred\" : \"failed\";\n\t\t}\n\n\t\t// Resolve auth only after extension hooks have had an opportunity to cancel\n\t\t// compaction or provide compacted text, so local extension compaction does not\n\t\t// require provider credentials. Missing auth then fails model-driven compaction\n\t\t// before persistence or continuation, matching other provider-call failures.\n\t\tconst result = await this._applyVerbatimCompaction({\n\t\t\tresolvePlannerAuth: async (candidate) => {\n\t\t\t\tconst authResult = await this._getRequiredRequestAuth(candidate);\n\t\t\t\treturn authResult.apiKey || authResult.headers ? authResult : undefined;\n\t\t\t},\n\t\t\tabortController: controller,\n\t\t\tbackupLabel: urgency === \"load_bearing\" ? \"overflow-auto-compact\" : \"auto-compact\",\n\t\t\treason,\n\t\t\turgency,\n\t\t\t// Only an actual context overflow proved the context cannot fit. A\n\t\t\t// recoverable length stop must never reach the fresh-context fallback.\n\t\t\t...(urgency === \"load_bearing\" ? { allowSmallRegion: true } : {}),\n\t\t});\n\t\tif (!result) {\n\t\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\t\tthis._emit({\n\t\t\t\ttype: \"compaction_end\",\n\t\t\t\treason,\n\t\t\t\tresult: undefined,\n\t\t\t\taborted: false,\n\t\t\t\twillRetry: false,\n\t\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\"),\n\t\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\t});\n\t\t\treturn manualTakeoverPending ? \"deferred\" : \"not_compactable\";\n\t\t}\n\n\t\tif (willRetry) {\n\t\t\tthis._dropTrailingAutoCompactionRetryAssistantIfPresent();\n\t\t}\n\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason,\n\t\t\tresult,\n\t\t\taborted: false,\n\t\t\twillRetry,\n\t\t\t...(hasPendingManualCompactionTakeover.call(this) ? { manualTakeoverPending: true } : {}),\n\t\t});\n\t\tif (!hasPendingManualCompactionTakeover.call(this)) {\n\t\t\tthis._schedulePostAutoCompactionContinuationProbe(reason, willRetry);\n\t\t}\n\t\treturn \"compacted\";\n\t} catch (error) {\n\t\tconst errorMessage = error instanceof Error ? error.message : \"compaction failed\";\n\t\tconst aborted =\n\t\t\terrorMessage === \"Compaction cancelled\" || (error instanceof Error && error.name === \"AbortError\");\n\t\tconst manualTakeoverPending = hasPendingManualCompactionTakeover.call(this);\n\t\tthis._emit({\n\t\t\ttype: \"compaction_end\",\n\t\t\treason,\n\t\t\tresult: undefined,\n\t\t\taborted,\n\t\t\twillRetry: false,\n\t\t\tunresolvedOverflow: overflowUnresolved.call(this, urgency === \"load_bearing\", aborted),\n\t\t\t...(manualTakeoverPending ? { manualTakeoverPending: true } : {}),\n\t\t\terrorMessage: aborted\n\t\t\t\t? undefined\n\t\t\t\t: reason === \"overflow\"\n\t\t\t\t\t? urgency === \"recoverable\"\n\t\t\t\t\t\t? `Response truncation recovery failed: ${errorMessage}`\n\t\t\t\t\t\t: `Context overflow recovery failed: ${errorMessage}`\n\t\t\t\t\t: `Auto-compaction failed: ${errorMessage}`,\n\t\t});\n\t\treturn manualTakeoverPending ? \"deferred\" : \"failed\";\n\t} finally {\n\t\tif (this._autoCompactionAbortController === controller) this._autoCompactionAbortController = undefined;\n\t\tif (this._compactionReason === reason) this._compactionReason = undefined;\n\t\tcompletion.resolve();\n\t\tif (this._autoCompactionCompletion === completion.promise) this._autoCompactionCompletion = undefined;\n\t}\n}\n\n/**\n * Toggle auto-compaction setting.\n */\n\nexport const agentSessionAutoCompactionMethods = {\n\t_awaitPendingPostCompactionContinuation,\n\t_checkCompaction,\n\t_dropTrailingAutoCompactionRetryAssistantIfPresent,\n\t_schedulePostAutoCompactionContinuationProbe,\n\t_resumeAfterAutoCompaction,\n\t_resumeAfterLengthTruncation,\n\t_runAutoCompaction,\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-events.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAe,MAAM,uBAAuB,CAAC;AAEpF,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC9E,OAAO,KAAK,EAAE,2BAA2B,IAAI,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAS9F,OAAO,EACN,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAI9B,MAAM,0BAA0B,CAAC;AAgBlC,wBAAgB,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAIxE;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,Y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AAC,IAAI,CAAC,CAoM7F;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CA0BvF;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,IAAI,CAQvF;AAED,wCAAwC;AAExC,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAMtD;AAED,0CAA0C;AAE1C,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAMhF;AAED,8EAA8E;AAE9E,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,GAAG,SAAS,CAS1F;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAchH;AAED,kDAAkD;AAElD,wBAAsB,mBAAmB,CAAC,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAsE9F;AAED;;;;GAIG;AAEH,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,yBAAyB,GAAG,MAAM,IAAI,CAU7F;AAED,oDAAoD;AACpD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAK7D;AAED;;;GAGG;AAEH,wBAAgB,OAAO,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAmBhD;AAMD,uBAAuB;AAEvB,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;CAiBrC,CAAC"}
@@ -206,7 +206,7 @@ export async function _processAgentEvent(event) {
206
206
  !emptyCompletion &&
207
207
  this._isSafetyRefusal(msg);
208
208
  const modelFailure = retryableError || fallbackableError || emptyCompletion || safetyRefusal;
209
- let restoreAfterTurn = !modelFailure;
209
+ let settleAfterTurn = !modelFailure;
210
210
  if (modelFailure) {
211
211
  if (emptyCompletion && !msg.errorMessage) {
212
212
  // Surface a clear reason in the retry banner; empty completions carry no
@@ -219,7 +219,7 @@ export async function _processAgentEvent(event) {
219
219
  const didRetry = await this._handleRetryableError(msg);
220
220
  if (didRetry)
221
221
  return; // Retry was initiated, don't proceed to compaction
222
- restoreAfterTurn = true;
222
+ settleAfterTurn = true;
223
223
  }
224
224
  this._resolveRetry();
225
225
  this._contextOverflowUnresolved = false;
@@ -231,19 +231,17 @@ export async function _processAgentEvent(event) {
231
231
  this._contextOverflowUnresolved = false;
232
232
  if (typeof this._trySwitchToFallbackModel === "function" && (await this._trySwitchToFallbackModel(msg)))
233
233
  return;
234
- restoreAfterTurn = true;
234
+ settleAfterTurn = true;
235
235
  }
236
- // Keep a fallback active across the compact-and-continue probe that belongs
237
- // to this same user turn. The probe restores it before a queued next turn,
238
- // or after a continuation settles.
239
- if (restoreAfterTurn && this._pendingPostCompactionContinuation === undefined) {
240
- if (typeof this._restoreFallbackModel === "function")
241
- await this._restoreFallbackModel();
236
+ // Keep a fallback lifecycle open across the compact-and-continue probe that
237
+ // belongs to this user turn, then settle it without changing the active model.
238
+ if (settleAfterTurn && this._pendingPostCompactionContinuation === undefined) {
239
+ if (typeof this._settleFallbackModelScope === "function")
240
+ await this._settleFallbackModelScope();
242
241
  }
243
- // Launched last so the fallback lifecycle wins: a switch above returns before this line, and
244
- // the restore has already put `this.model` back to the user's selection, which the launch
245
- // reads synchronously before it parks on waitForIdle(). Guarded like the fallback methods
246
- // above because the fallback suites drive this function on a synthetic session.
242
+ // Launched last so the fallback lifecycle wins: a switch above returns before
243
+ // this line. Guarded like the fallback methods above because fallback suites
244
+ // drive this function on a synthetic session.
247
245
  if (event.type === "agent_end" && typeof this._maybeGenerateSessionSummary === "function")
248
246
  void this._maybeGenerateSessionSummary();
249
247
  }
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-events.js","sourceRoot":"","sources":["../../src/core/agent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AAK;IACL,gBAAgB;IAChB,iBAAiB;IACjB,8BAA8B;IAC9B,4BAA4B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,2BAA2B;IAC3B,aAAa;IACb,mBAAmB;IACnB,yBAAyB;IACzB,sBAAsB;IACtB,mBAAmB;IACnB,SAAS;IACT,oBAAoB;IACpB,OAAO;CACP,CAAC","sourcesContent":["import type { AssistantMessage, Message, TextContent } from \"@bastani/pi-ai/compat\";\nimport { cleanupSessionResources } from \"@bastani/pi-ai/compat\";\nimport type { AgentEvent, AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport {\n\tisProtectedStreamingCustomMessage,\n\tmarkProtectedStreamingCustomMessageConsumed,\n\tmarkProtectedStreamingCustomMessagePersistenceFailed,\n\tpersistProtectedStreamingCustomMessage,\n\tprepareProtectedStreamingCustomMessagesForDisposal,\n\tretryConsumedProtectedStreamingCustomMessages,\n} from \"./agent-session-persistent-custom-messages.ts\";\nimport {\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\tcustomMessageExcludesContext,\n\tisSingleGenericAbortTextContent,\n\treplacementAbortContent,\n} from \"./agent-session-types.ts\";\nimport { formatCodexProviderError } from \"./codex-errors.ts\";\nimport type {\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n} from \"./extensions/index.ts\";\nimport { STALE_EXTENSION_CONTEXT_MESSAGE } from \"./extensions/stale-context.ts\";\nimport type { StageAdmittedCustomMessage } from \"./messages.ts\";\nimport { normalizeMessageContent } from \"./messages.ts\";\n\nexport function _emit(this: AgentSession, event: AgentSessionEvent): void {\n\tfor (const l of this._eventListeners) {\n\t\tl(event);\n\t}\n}\n\nexport function _emitQueueUpdate(this: AgentSession): void {\n\tthis._emit({\n\t\ttype: \"queue_update\",\n\t\tsteering: [...this._steeringMessages],\n\t\tfollowUp: [...this._followUpMessages],\n\t});\n}\n\n/** Internal handler for agent events - shared by subscribe and reconnect */\n\nexport function _handleAgentEvent(this: AgentSession, event: AgentEvent): Promise<void> | void {\n\t// Create retry promise synchronously before queueing async processing.\n\t// Agent.emit() calls this handler synchronously, and prompt() calls waitForRetry()\n\t// as soon as agent.prompt() resolves. If _retryPromise is created only inside\n\t// _processAgentEvent, slow earlier queued events can delay agent_end processing\n\t// and waitForRetry() can miss the in-flight retry.\n\tthis._createRetryPromiseForAgentEnd(event);\n\tconst awaitProtectedPersistence =\n\t\tevent.type === \"message_end\" && event.message.role === \"custom\"\n\t\t\t? markProtectedStreamingCustomMessageConsumed(this, event.message)\n\t\t\t: false;\n\n\tconst processing = this._agentEventQueue.then(\n\t\t() => this._processAgentEvent(event),\n\t\t() => this._processAgentEvent(event),\n\t);\n\tthis._agentEventQueue = processing;\n\n\t// Keep queue alive if an event handler fails. Agent-core must additionally\n\t// await protected persistence and fallback reconciliation before the next\n\t// provider request; other listener work stays nonblocking.\n\tprocessing.catch(() => {});\n\tif (\n\t\tawaitProtectedPersistence ||\n\t\t(event.type === \"agent_end\" && (this._fallbackModels.length > 0 || this._fallbackOriginModel !== undefined))\n\t)\n\t\treturn processing.catch(() => {});\n}\n\nexport function _createRetryPromiseForAgentEnd(this: AgentSession, event: AgentEvent): void {\n\tif (event.type !== \"agent_end\" || this._retryPromise) {\n\t\treturn;\n\t}\n\n\tconst settings = this.settingsManager.getRetrySettings();\n\tif (!settings.enabled && this._fallbackModels.length === 0) {\n\t\treturn;\n\t}\n\n\tconst lastAssistant = this._findLastAssistantInMessages(event.messages);\n\tif (!lastAssistant) {\n\t\treturn;\n\t}\n\n\tconst fallbackable =\n\t\ttypeof this._isFallbackableError === \"function\"\n\t\t\t? this._isFallbackableError(lastAssistant)\n\t\t\t: this._isRetryableError(lastAssistant);\n\tconst retryable = this._isRetryableError(lastAssistant);\n\tconst shouldRetry =\n\t\tretryable || fallbackable || this._isEmptyCompletion(lastAssistant) || this._isSafetyRefusal(lastAssistant);\n\tif (!shouldRetry) {\n\t\treturn;\n\t}\n\n\tthis._retryPromise = new Promise((resolve) => {\n\t\tthis._retryResolve = resolve;\n\t});\n}\n\nexport function _findLastAssistantInMessages(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n): AssistantMessage | undefined {\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst message = messages[i];\n\t\tif (message.role === \"assistant\") {\n\t\t\treturn message as AssistantMessage;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport async function _processAgentEvent(this: AgentSession, event: AgentEvent): Promise<void> {\n\tconst protectedMessage =\n\t\tevent.type === \"message_end\" &&\n\t\tevent.message.role === \"custom\" &&\n\t\tisProtectedStreamingCustomMessage(this, event.message)\n\t\t\t? event.message\n\t\t\t: undefined;\n\t// When a user message starts, check if it's from either queue and remove it BEFORE emitting\n\t// This ensures the UI sees the updated queue state\n\tif (event.type === \"message_start\" && event.message.role === \"user\") {\n\t\tthis._overflowRecoveryAttempted = false;\n\t\tthis._recoverableLengthRecoveryAttempted = false;\n\t\tthis._fallbackAttemptedKeys.clear();\n\t\tthis._fallbackBlockedModels.length = 0;\n\t\tconst messageText = this._getUserMessageText(event.message);\n\t\tif (messageText) {\n\t\t\t// Check steering queue first\n\t\t\tconst steeringIndex = this._steeringMessages.indexOf(messageText);\n\t\t\tif (steeringIndex !== -1) {\n\t\t\t\tthis._steeringMessages.splice(steeringIndex, 1);\n\t\t\t\t// The loop already polled this message out of the agent queue, so the\n\t\t\t\t// pause hold can no longer reach it and Escape can no longer restore it\n\t\t\t\t// to the editor. Record it so an interrupt that kills its reply before\n\t\t\t\t// any output can still schedule that reply (issue #2362).\n\t\t\t\tthis._admittedQueuedMessageAwaitingReply = messageText;\n\t\t\t\tthis._emitQueueUpdate();\n\t\t\t} else {\n\t\t\t\t// Check follow-up queue\n\t\t\t\tconst followUpIndex = this._followUpMessages.indexOf(messageText);\n\t\t\t\tif (followUpIndex !== -1) {\n\t\t\t\t\tthis._followUpMessages.splice(followUpIndex, 1);\n\t\t\t\t\tthis._admittedQueuedMessageAwaitingReply = messageText;\n\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tthis._applyInterruptAbortMessage(event);\n\tthis._applyProviderErrorGuidance(event);\n\n\ttry {\n\t\t// Emit to extensions first, then notify all public listeners.\n\t\tawait this._emitExtensionEvent(event);\n\t\tthis._emit(event);\n\t} finally {\n\t\t// Agent-core has consumed this protected input already. Its durability\n\t\t// boundary cannot be skipped by a fallible extension or session listener.\n\t\tif (protectedMessage !== undefined) {\n\t\t\ttry {\n\t\t\t\tpersistProtectedStreamingCustomMessage(this, protectedMessage);\n\t\t\t} catch {\n\t\t\t\tmarkProtectedStreamingCustomMessagePersistenceFailed(this, protectedMessage);\n\t\t\t}\n\t\t\tretryConsumedProtectedStreamingCustomMessages(this);\n\t\t}\n\t}\n\n\t// Handle session persistence\n\tif (event.type === \"message_end\") {\n\t\t// Check if this is a custom message from extensions\n\t\tif (event.message.role === \"custom\") {\n\t\t\tconst admitted = event.message as StageAdmittedCustomMessage;\n\t\t\tif (protectedMessage === undefined) {\n\t\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\t\tevent.message.customType,\n\t\t\t\t\tevent.message.content,\n\t\t\t\t\tevent.message.display,\n\t\t\t\t\tevent.message.details,\n\t\t\t\t\tcustomMessageExcludesContext(event.message),\n\t\t\t\t\tundefined,\n\t\t\t\t\tadmitted.stageAdmissionKey,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (\n\t\t\tevent.message.role === \"user\" ||\n\t\t\tevent.message.role === \"assistant\" ||\n\t\t\tevent.message.role === \"toolResult\"\n\t\t) {\n\t\t\t// Regular LLM message - persist as SessionMessageEntry\n\t\t\tthis.sessionManager.appendMessage(event.message);\n\t\t}\n\t\t// Other message types (bashExecution, branchSummary) are persisted elsewhere\n\n\t\t// Track assistant message for auto-compaction (checked on agent_end)\n\t\tif (event.message.role === \"assistant\") {\n\t\t\tthis._lastAssistantMessage = event.message;\n\n\t\t\tconst assistantMsg = event.message as AssistantMessage;\n\t\t\t// A length stop preserves its one-shot recovery budget. Reset both\n\t\t\t// recovery kinds only once a non-truncated response completes.\n\t\t\tconst assistantFailed =\n\t\t\t\tassistantMsg.stopReason === \"error\" ||\n\t\t\t\tthis._isEmptyCompletion(assistantMsg) ||\n\t\t\t\tthis._isSafetyRefusal(assistantMsg);\n\t\t\tif (!assistantFailed && assistantMsg.stopReason !== \"length\") {\n\t\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\t\tthis._recoverableLengthRecoveryAttempted = false;\n\t\t\t}\n\t\t\tif (!assistantFailed) {\n\t\t\t\tthis._contextOverflowUnresolved = false;\n\t\t\t\tthis._outputBudgetErrorContinuationAttempts = 0;\n\t\t\t}\n\t\t\tif (!assistantFailed && assistantMsg.stopReason === \"stop\") {\n\t\t\t\tthis._fallbackAttemptedKeys.clear();\n\t\t\t\tthis._fallbackBlockedModels.length = 0;\n\t\t\t}\n\n\t\t\t// A non-truncated assistant response means the length-continuation loop\n\t\t\t// made progress (or the turn completed cleanly), so reset the bounded\n\t\t\t// output-cap continuation counter.\n\t\t\tif (assistantMsg.stopReason !== \"length\") {\n\t\t\t\tthis._lengthContinuationAttempts = 0;\n\t\t\t}\n\n\t\t\t// Reset retry counter immediately on successful assistant response\n\t\t\t// This prevents accumulation across multiple LLM calls within a turn\n\t\t\tif (!assistantFailed && this._retryAttempt > 0) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tattempt: this._retryAttempt,\n\t\t\t\t});\n\t\t\t\tthis._retryAttempt = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\t// A transient hidden-reconciliation write failure retries independently of\n\t// provider/card delivery and can never create another visible lifecycle card.\n\tretryConsumedProtectedStreamingCustomMessages(this);\n\n\t// Check auto-retry and auto-compaction after agent completes\n\tif (event.type === \"agent_end\" && this._lastAssistantMessage) {\n\t\tconst msg = this._lastAssistantMessage;\n\t\tthis._lastAssistantMessage = undefined;\n\t\tconst postToolPreflightFailed =\n\t\t\tthis._postToolCompactionPreflightError !== undefined &&\n\t\t\tmsg.errorMessage === this._postToolCompactionPreflightError;\n\n\t\t// Check provider/model failures before compaction. Fallback eligibility is\n\t\t// broader than same-model retry eligibility: auth and request-incompatible\n\t\t// failures advance without re-requesting the failed model.\n\t\tconst fallbackableError =\n\t\t\t!postToolPreflightFailed &&\n\t\t\t(typeof this._isFallbackableError === \"function\"\n\t\t\t\t? this._isFallbackableError(msg)\n\t\t\t\t: this._isRetryableError(msg));\n\t\tconst retryableError = !postToolPreflightFailed && this._isRetryableError(msg);\n\t\tconst emptyCompletion =\n\t\t\t!postToolPreflightFailed && !retryableError && !fallbackableError && this._isEmptyCompletion(msg);\n\t\tconst safetyRefusal =\n\t\t\t!postToolPreflightFailed &&\n\t\t\t!retryableError &&\n\t\t\t!fallbackableError &&\n\t\t\t!emptyCompletion &&\n\t\t\tthis._isSafetyRefusal(msg);\n\t\tconst modelFailure = retryableError || fallbackableError || emptyCompletion || safetyRefusal;\n\t\tlet restoreAfterTurn = !modelFailure;\n\t\tif (modelFailure) {\n\t\t\tif (emptyCompletion && !msg.errorMessage) {\n\t\t\t\t// Surface a clear reason in the retry banner; empty completions carry no\n\t\t\t\t// provider error message of their own.\n\t\t\t\tmsg.errorMessage = \"Provider returned an empty completion\";\n\t\t\t} else if (safetyRefusal && !msg.errorMessage) {\n\t\t\t\tmsg.errorMessage = \"Provider returned a canned safety refusal\";\n\t\t\t}\n\t\t\tconst didRetry = await this._handleRetryableError(msg);\n\t\t\tif (didRetry) return; // Retry was initiated, don't proceed to compaction\n\t\t\trestoreAfterTurn = true;\n\t\t}\n\n\t\tthis._resolveRetry();\n\t\tthis._contextOverflowUnresolved = false;\n\t\tawait this._checkCompaction(msg);\n\n\t\t// Compaction owns context overflow first. Only once it is disabled, fails,\n\t\t// or reports the overflow unresolved may the chain spend a candidate on a\n\t\t// larger-context model, so a compactable first overflow costs nothing.\n\t\tif (this._contextOverflowUnresolved) {\n\t\t\tthis._contextOverflowUnresolved = false;\n\t\t\tif (typeof this._trySwitchToFallbackModel === \"function\" && (await this._trySwitchToFallbackModel(msg)))\n\t\t\t\treturn;\n\t\t\trestoreAfterTurn = true;\n\t\t}\n\t\t// Keep a fallback active across the compact-and-continue probe that belongs\n\t\t// to this same user turn. The probe restores it before a queued next turn,\n\t\t// or after a continuation settles.\n\t\tif (restoreAfterTurn && this._pendingPostCompactionContinuation === undefined) {\n\t\t\tif (typeof this._restoreFallbackModel === \"function\") await this._restoreFallbackModel();\n\t\t}\n\t\t// Launched last so the fallback lifecycle wins: a switch above returns before this line, and\n\t\t// the restore has already put `this.model` back to the user's selection, which the launch\n\t\t// reads synchronously before it parks on waitForIdle(). Guarded like the fallback methods\n\t\t// above because the fallback suites drive this function on a synthetic session.\n\t\tif (event.type === \"agent_end\" && typeof this._maybeGenerateSessionSummary === \"function\")\n\t\t\tvoid this._maybeGenerateSessionSummary();\n\t}\n}\n\nexport function _applyInterruptAbortMessage(this: AgentSession, event: AgentEvent): void {\n\tconst abortMessage = this._activeInterruptAbortMessage;\n\tif (!abortMessage) return;\n\n\tif (event.type === \"tool_execution_end\" && event.isError && isSingleGenericAbortTextContent(event.result.content)) {\n\t\tevent.result.content = replacementAbortContent(abortMessage);\n\t\treturn;\n\t}\n\n\tif (event.type !== \"message_start\" && event.type !== \"message_end\") return;\n\n\tif (\n\t\tevent.message.role === \"toolResult\" &&\n\t\tevent.message.isError &&\n\t\tisSingleGenericAbortTextContent(event.message.content)\n\t) {\n\t\tevent.message.content = replacementAbortContent(abortMessage);\n\t\treturn;\n\t}\n\n\tif (event.message.role === \"assistant\") {\n\t\tconst assistantMessage = event.message as AssistantMessage;\n\t\tif (assistantMessage.stopReason === \"aborted\") {\n\t\t\tassistantMessage.errorMessage = abortMessage;\n\t\t}\n\t}\n}\n\nexport function _applyProviderErrorGuidance(this: AgentSession, event: AgentEvent): void {\n\tif (event.type !== \"message_start\" && event.type !== \"message_update\" && event.type !== \"message_end\") return;\n\tif (event.message.role !== \"assistant\") return;\n\n\tconst assistantMessage = event.message as AssistantMessage;\n\tif (assistantMessage.stopReason !== \"error\" || !assistantMessage.errorMessage) return;\n\n\tassistantMessage.errorMessage = formatCodexProviderError(assistantMessage.provider, assistantMessage.errorMessage);\n}\n\n/** Resolve the pending retry promise */\n\nexport function _resolveRetry(this: AgentSession): void {\n\tif (this._retryResolve) {\n\t\tthis._retryResolve();\n\t\tthis._retryResolve = undefined;\n\t\tthis._retryPromise = undefined;\n\t}\n}\n\n/** Extract text content from a message */\n\nexport function _getUserMessageText(this: AgentSession, message: Message): string {\n\tif (message.role !== \"user\") return \"\";\n\tconst content = message.content;\n\tif (typeof content === \"string\") return content;\n\tconst textBlocks = content.filter((c) => c.type === \"text\");\n\treturn textBlocks.map((c) => (c as TextContent).text).join(\"\");\n}\n\n/** Find the last assistant message in agent state (including aborted ones) */\n\nexport function _findLastAssistantMessage(this: AgentSession): AssistantMessage | undefined {\n\tconst messages = this.agent.state.messages;\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst msg = messages[i];\n\t\tif (msg.role === \"assistant\") {\n\t\t\treturn msg as AssistantMessage;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function _replaceMessageInPlace(this: AgentSession, target: AgentMessage, replacement: AgentMessage): void {\n\t// Agent-core stores the finalized message object in its state before emitting message_end.\n\t// SessionManager persistence happens later in _processAgentEvent() with event.message.\n\t// Mutating this object in place keeps agent state, later turn/agent events, listeners,\n\t// and the eventual SessionManager.appendMessage(event.message) persistence in sync.\n\tif (target === replacement) {\n\t\treturn;\n\t}\n\n\tconst targetRecord = target as unknown as Record<string, unknown>;\n\tfor (const key of Object.keys(targetRecord)) {\n\t\tdelete targetRecord[key];\n\t}\n\tObject.assign(targetRecord, replacement);\n}\n\n/** Emit extension events based on agent events */\n\nexport async function _emitExtensionEvent(this: AgentSession, event: AgentEvent): Promise<void> {\n\tif (event.type === \"agent_start\") {\n\t\tthis._turnIndex = 0;\n\t\tawait this._extensionRunner.emit({ type: \"agent_start\" });\n\t} else if (event.type === \"agent_end\") {\n\t\tawait this._extensionRunner.emit({ type: \"agent_end\", messages: event.messages });\n\t} else if (event.type === \"turn_start\") {\n\t\tconst extensionEvent: TurnStartEvent = {\n\t\t\ttype: \"turn_start\",\n\t\t\tturnIndex: this._turnIndex,\n\t\t\ttimestamp: Date.now(),\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"turn_end\") {\n\t\tconst extensionEvent: TurnEndEvent = {\n\t\t\ttype: \"turn_end\",\n\t\t\tturnIndex: this._turnIndex,\n\t\t\tmessage: event.message,\n\t\t\ttoolResults: event.toolResults,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\tthis._turnIndex++;\n\t} else if (event.type === \"message_start\") {\n\t\tconst extensionEvent: MessageStartEvent = {\n\t\t\ttype: \"message_start\",\n\t\t\tmessage: event.message,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"message_update\") {\n\t\tconst extensionEvent: MessageUpdateEvent = {\n\t\t\ttype: \"message_update\",\n\t\t\tassistantMessageEvent: event.assistantMessageEvent,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"message_end\") {\n\t\tconst extensionEvent: MessageEndEvent = {\n\t\t\ttype: \"message_end\",\n\t\t\tmessage: event.message,\n\t\t};\n\t\tconst replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);\n\t\tif (replacement) {\n\t\t\tthis._replaceMessageInPlace(event.message, normalizeMessageContent(replacement));\n\t\t}\n\t} else if (event.type === \"tool_execution_start\") {\n\t\tconst extensionEvent: ToolExecutionStartEvent = {\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\targs: event.args,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"tool_execution_update\") {\n\t\tconst extensionEvent: ToolExecutionUpdateEvent = {\n\t\t\ttype: \"tool_execution_update\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\targs: event.args,\n\t\t\tpartialResult: event.partialResult,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"tool_execution_end\") {\n\t\tconst extensionEvent: ToolExecutionEndEvent = {\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\tresult: event.result,\n\t\t\tisError: event.isError,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t}\n}\n\n/**\n * Subscribe to agent events.\n * Session persistence is handled internally (saves messages on message_end).\n * Multiple listeners can be added. Returns unsubscribe function for this listener.\n */\n\nexport function subscribe(this: AgentSession, listener: AgentSessionEventListener): () => void {\n\tthis._eventListeners.push(listener);\n\n\t// Return unsubscribe function for this specific listener\n\treturn () => {\n\t\tconst index = this._eventListeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tthis._eventListeners.splice(index, 1);\n\t\t}\n\t};\n}\n\n/** Disconnect from agent events during disposal. */\nexport function _disconnectFromAgent(this: AgentSession): void {\n\tif (this._unsubscribeAgent) {\n\t\tthis._unsubscribeAgent();\n\t\tthis._unsubscribeAgent = undefined;\n\t}\n}\n\n/**\n * Remove all listeners and disconnect from agent.\n * Call this when completely done with the session.\n */\n\nexport function dispose(this: AgentSession): void {\n\t// Terminal and idempotent: callers legitimately dispose more than once (an explicit dispose\n\t// followed by a harness teardown), and the steps below are not all safe to repeat.\n\tif (this._disposed) return;\n\t// Summary work queued before its AbortController exists cannot be reached by\n\t// abortSessionSummary(), so disposal is recorded as state that every checkpoint consults.\n\tthis._disposed = true;\n\t// A background summary must never keep the process alive past shutdown.\n\tthis.abortSessionSummary();\n\t// Fail closed while protected input remains queued, or flush a consumed\n\t// reconciliation before invalidation can discard its recovery state.\n\tprepareProtectedStreamingCustomMessagesForDisposal(this);\n\tthis._extensionRunner.invalidate(STALE_EXTENSION_CONTEXT_MESSAGE);\n\tthis._disconnectFromAgent();\n\tthis._eventListeners = [];\n\tcleanupSessionResources(this.sessionId);\n\t// Releasing the session lease stops protecting a tree that is no longer in use.\n\tthis._tempStorageLease?.release();\n\tthis._tempStorageLease = undefined;\n}\n\n// =========================================================================\n// Read-only State Access\n// =========================================================================\n\n/** Full agent state */\n\nexport const agentSessionEventsMethods = {\n\t_emit,\n\t_emitQueueUpdate,\n\t_handleAgentEvent,\n\t_createRetryPromiseForAgentEnd,\n\t_findLastAssistantInMessages,\n\t_processAgentEvent,\n\t_applyInterruptAbortMessage,\n\t_applyProviderErrorGuidance,\n\t_resolveRetry,\n\t_getUserMessageText,\n\t_findLastAssistantMessage,\n\t_replaceMessageInPlace,\n\t_emitExtensionEvent,\n\tsubscribe,\n\t_disconnectFromAgent,\n\tdispose,\n};\n"]}
1
+ {"version":3,"file":"agent-session-events.js","sourceRoot":"","sources":["../../src/core/agent-session-events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAGhE,OAAO,EACN,iCAAiC,EACjC,2CAA2C,EAC3C,oDAAoD,EACpD,sCAAsC,EACtC,kDAAkD,EAClD,6CAA6C,GAC7C,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAGN,4BAA4B,EAC5B,+BAA+B,EAC/B,uBAAuB,GACvB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAW7D,OAAO,EAAE,+BAA+B,EAAE,MAAM,+BAA+B,CAAC;AAEhF,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;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AC;AACF,CAAC;AAED;;;GAGG;AAEH,MAAM,UAAU,OAAO;IACtB,4FAA4F;IAC5F,mFAAmF;IACnF,IAAI,IAAI,CAAC,SAAS;QAAE,OAAO;IAC3B,6EAA6E;IAC7E,0FAA0F;IAC1F,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;IACtB,wEAAwE;IACxE,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC3B,wEAAwE;IACxE,qEAAqE;IACrE,kDAAkD,CAAC,IAAI,CAAC,CAAC;IACzD,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,+BAA+B,CAAC,CAAC;IAClE,IAAI,CAAC,oBAAoB,EAAE,CAAC;IAC5B,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;IAC1B,uBAAuB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACxC,gFAAgF;IAChF,IAAI,CAAC,iBAAiB,EAAE,OAAO,EAAE,CAAC;IAClC,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;AACpC,CAAC;AAED,4EAA4E;AAC5E,yBAAyB;AACzB,4EAA4E;AAE5E,uBAAuB;AAEvB,MAAM,CAAC,MAAM,yBAAyB,GAAG;IACxC,KAAK;IACL,gBAAgB;IAChB,iBAAiB;IACjB,8BAA8B;IAC9B,4BAA4B;IAC5B,kBAAkB;IAClB,2BAA2B;IAC3B,2BAA2B;IAC3B,aAAa;IACb,mBAAmB;IACnB,yBAAyB;IACzB,sBAAsB;IACtB,mBAAmB;IACnB,SAAS;IACT,oBAAoB;IACpB,OAAO;CACP,CAAC","sourcesContent":["import type { AssistantMessage, Message, TextContent } from \"@bastani/pi-ai/compat\";\nimport { cleanupSessionResources } from \"@bastani/pi-ai/compat\";\nimport type { AgentEvent, AgentMessage } from \"@earendil-works/pi-agent-core\";\nimport type { AgentSessionInternalSurface as AgentSession } from \"./agent-session-methods.ts\";\nimport {\n\tisProtectedStreamingCustomMessage,\n\tmarkProtectedStreamingCustomMessageConsumed,\n\tmarkProtectedStreamingCustomMessagePersistenceFailed,\n\tpersistProtectedStreamingCustomMessage,\n\tprepareProtectedStreamingCustomMessagesForDisposal,\n\tretryConsumedProtectedStreamingCustomMessages,\n} from \"./agent-session-persistent-custom-messages.ts\";\nimport {\n\ttype AgentSessionEvent,\n\ttype AgentSessionEventListener,\n\tcustomMessageExcludesContext,\n\tisSingleGenericAbortTextContent,\n\treplacementAbortContent,\n} from \"./agent-session-types.ts\";\nimport { formatCodexProviderError } from \"./codex-errors.ts\";\nimport type {\n\tMessageEndEvent,\n\tMessageStartEvent,\n\tMessageUpdateEvent,\n\tToolExecutionEndEvent,\n\tToolExecutionStartEvent,\n\tToolExecutionUpdateEvent,\n\tTurnEndEvent,\n\tTurnStartEvent,\n} from \"./extensions/index.ts\";\nimport { STALE_EXTENSION_CONTEXT_MESSAGE } from \"./extensions/stale-context.ts\";\nimport type { StageAdmittedCustomMessage } from \"./messages.ts\";\nimport { normalizeMessageContent } from \"./messages.ts\";\n\nexport function _emit(this: AgentSession, event: AgentSessionEvent): void {\n\tfor (const l of this._eventListeners) {\n\t\tl(event);\n\t}\n}\n\nexport function _emitQueueUpdate(this: AgentSession): void {\n\tthis._emit({\n\t\ttype: \"queue_update\",\n\t\tsteering: [...this._steeringMessages],\n\t\tfollowUp: [...this._followUpMessages],\n\t});\n}\n\n/** Internal handler for agent events - shared by subscribe and reconnect */\n\nexport function _handleAgentEvent(this: AgentSession, event: AgentEvent): Promise<void> | void {\n\t// Create retry promise synchronously before queueing async processing.\n\t// Agent.emit() calls this handler synchronously, and prompt() calls waitForRetry()\n\t// as soon as agent.prompt() resolves. If _retryPromise is created only inside\n\t// _processAgentEvent, slow earlier queued events can delay agent_end processing\n\t// and waitForRetry() can miss the in-flight retry.\n\tthis._createRetryPromiseForAgentEnd(event);\n\tconst awaitProtectedPersistence =\n\t\tevent.type === \"message_end\" && event.message.role === \"custom\"\n\t\t\t? markProtectedStreamingCustomMessageConsumed(this, event.message)\n\t\t\t: false;\n\n\tconst processing = this._agentEventQueue.then(\n\t\t() => this._processAgentEvent(event),\n\t\t() => this._processAgentEvent(event),\n\t);\n\tthis._agentEventQueue = processing;\n\n\t// Keep queue alive if an event handler fails. Agent-core must additionally\n\t// await protected persistence and fallback reconciliation before the next\n\t// provider request; other listener work stays nonblocking.\n\tprocessing.catch(() => {});\n\tif (\n\t\tawaitProtectedPersistence ||\n\t\t(event.type === \"agent_end\" && (this._fallbackModels.length > 0 || this._fallbackOriginModel !== undefined))\n\t)\n\t\treturn processing.catch(() => {});\n}\n\nexport function _createRetryPromiseForAgentEnd(this: AgentSession, event: AgentEvent): void {\n\tif (event.type !== \"agent_end\" || this._retryPromise) {\n\t\treturn;\n\t}\n\n\tconst settings = this.settingsManager.getRetrySettings();\n\tif (!settings.enabled && this._fallbackModels.length === 0) {\n\t\treturn;\n\t}\n\n\tconst lastAssistant = this._findLastAssistantInMessages(event.messages);\n\tif (!lastAssistant) {\n\t\treturn;\n\t}\n\n\tconst fallbackable =\n\t\ttypeof this._isFallbackableError === \"function\"\n\t\t\t? this._isFallbackableError(lastAssistant)\n\t\t\t: this._isRetryableError(lastAssistant);\n\tconst retryable = this._isRetryableError(lastAssistant);\n\tconst shouldRetry =\n\t\tretryable || fallbackable || this._isEmptyCompletion(lastAssistant) || this._isSafetyRefusal(lastAssistant);\n\tif (!shouldRetry) {\n\t\treturn;\n\t}\n\n\tthis._retryPromise = new Promise((resolve) => {\n\t\tthis._retryResolve = resolve;\n\t});\n}\n\nexport function _findLastAssistantInMessages(\n\tthis: AgentSession,\n\tmessages: AgentMessage[],\n): AssistantMessage | undefined {\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst message = messages[i];\n\t\tif (message.role === \"assistant\") {\n\t\t\treturn message as AssistantMessage;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport async function _processAgentEvent(this: AgentSession, event: AgentEvent): Promise<void> {\n\tconst protectedMessage =\n\t\tevent.type === \"message_end\" &&\n\t\tevent.message.role === \"custom\" &&\n\t\tisProtectedStreamingCustomMessage(this, event.message)\n\t\t\t? event.message\n\t\t\t: undefined;\n\t// When a user message starts, check if it's from either queue and remove it BEFORE emitting\n\t// This ensures the UI sees the updated queue state\n\tif (event.type === \"message_start\" && event.message.role === \"user\") {\n\t\tthis._overflowRecoveryAttempted = false;\n\t\tthis._recoverableLengthRecoveryAttempted = false;\n\t\tthis._fallbackAttemptedKeys.clear();\n\t\tthis._fallbackBlockedModels.length = 0;\n\t\tconst messageText = this._getUserMessageText(event.message);\n\t\tif (messageText) {\n\t\t\t// Check steering queue first\n\t\t\tconst steeringIndex = this._steeringMessages.indexOf(messageText);\n\t\t\tif (steeringIndex !== -1) {\n\t\t\t\tthis._steeringMessages.splice(steeringIndex, 1);\n\t\t\t\t// The loop already polled this message out of the agent queue, so the\n\t\t\t\t// pause hold can no longer reach it and Escape can no longer restore it\n\t\t\t\t// to the editor. Record it so an interrupt that kills its reply before\n\t\t\t\t// any output can still schedule that reply (issue #2362).\n\t\t\t\tthis._admittedQueuedMessageAwaitingReply = messageText;\n\t\t\t\tthis._emitQueueUpdate();\n\t\t\t} else {\n\t\t\t\t// Check follow-up queue\n\t\t\t\tconst followUpIndex = this._followUpMessages.indexOf(messageText);\n\t\t\t\tif (followUpIndex !== -1) {\n\t\t\t\t\tthis._followUpMessages.splice(followUpIndex, 1);\n\t\t\t\t\tthis._admittedQueuedMessageAwaitingReply = messageText;\n\t\t\t\t\tthis._emitQueueUpdate();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tthis._applyInterruptAbortMessage(event);\n\tthis._applyProviderErrorGuidance(event);\n\n\ttry {\n\t\t// Emit to extensions first, then notify all public listeners.\n\t\tawait this._emitExtensionEvent(event);\n\t\tthis._emit(event);\n\t} finally {\n\t\t// Agent-core has consumed this protected input already. Its durability\n\t\t// boundary cannot be skipped by a fallible extension or session listener.\n\t\tif (protectedMessage !== undefined) {\n\t\t\ttry {\n\t\t\t\tpersistProtectedStreamingCustomMessage(this, protectedMessage);\n\t\t\t} catch {\n\t\t\t\tmarkProtectedStreamingCustomMessagePersistenceFailed(this, protectedMessage);\n\t\t\t}\n\t\t\tretryConsumedProtectedStreamingCustomMessages(this);\n\t\t}\n\t}\n\n\t// Handle session persistence\n\tif (event.type === \"message_end\") {\n\t\t// Check if this is a custom message from extensions\n\t\tif (event.message.role === \"custom\") {\n\t\t\tconst admitted = event.message as StageAdmittedCustomMessage;\n\t\t\tif (protectedMessage === undefined) {\n\t\t\t\tthis.sessionManager.appendCustomMessageEntry(\n\t\t\t\t\tevent.message.customType,\n\t\t\t\t\tevent.message.content,\n\t\t\t\t\tevent.message.display,\n\t\t\t\t\tevent.message.details,\n\t\t\t\t\tcustomMessageExcludesContext(event.message),\n\t\t\t\t\tundefined,\n\t\t\t\t\tadmitted.stageAdmissionKey,\n\t\t\t\t);\n\t\t\t}\n\t\t} else if (\n\t\t\tevent.message.role === \"user\" ||\n\t\t\tevent.message.role === \"assistant\" ||\n\t\t\tevent.message.role === \"toolResult\"\n\t\t) {\n\t\t\t// Regular LLM message - persist as SessionMessageEntry\n\t\t\tthis.sessionManager.appendMessage(event.message);\n\t\t}\n\t\t// Other message types (bashExecution, branchSummary) are persisted elsewhere\n\n\t\t// Track assistant message for auto-compaction (checked on agent_end)\n\t\tif (event.message.role === \"assistant\") {\n\t\t\tthis._lastAssistantMessage = event.message;\n\n\t\t\tconst assistantMsg = event.message as AssistantMessage;\n\t\t\t// A length stop preserves its one-shot recovery budget. Reset both\n\t\t\t// recovery kinds only once a non-truncated response completes.\n\t\t\tconst assistantFailed =\n\t\t\t\tassistantMsg.stopReason === \"error\" ||\n\t\t\t\tthis._isEmptyCompletion(assistantMsg) ||\n\t\t\t\tthis._isSafetyRefusal(assistantMsg);\n\t\t\tif (!assistantFailed && assistantMsg.stopReason !== \"length\") {\n\t\t\t\tthis._overflowRecoveryAttempted = false;\n\t\t\t\tthis._recoverableLengthRecoveryAttempted = false;\n\t\t\t}\n\t\t\tif (!assistantFailed) {\n\t\t\t\tthis._contextOverflowUnresolved = false;\n\t\t\t\tthis._outputBudgetErrorContinuationAttempts = 0;\n\t\t\t}\n\t\t\tif (!assistantFailed && assistantMsg.stopReason === \"stop\") {\n\t\t\t\tthis._fallbackAttemptedKeys.clear();\n\t\t\t\tthis._fallbackBlockedModels.length = 0;\n\t\t\t}\n\n\t\t\t// A non-truncated assistant response means the length-continuation loop\n\t\t\t// made progress (or the turn completed cleanly), so reset the bounded\n\t\t\t// output-cap continuation counter.\n\t\t\tif (assistantMsg.stopReason !== \"length\") {\n\t\t\t\tthis._lengthContinuationAttempts = 0;\n\t\t\t}\n\n\t\t\t// Reset retry counter immediately on successful assistant response\n\t\t\t// This prevents accumulation across multiple LLM calls within a turn\n\t\t\tif (!assistantFailed && this._retryAttempt > 0) {\n\t\t\t\tthis._emit({\n\t\t\t\t\ttype: \"auto_retry_end\",\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tattempt: this._retryAttempt,\n\t\t\t\t});\n\t\t\t\tthis._retryAttempt = 0;\n\t\t\t}\n\t\t}\n\t}\n\n\t// A transient hidden-reconciliation write failure retries independently of\n\t// provider/card delivery and can never create another visible lifecycle card.\n\tretryConsumedProtectedStreamingCustomMessages(this);\n\n\t// Check auto-retry and auto-compaction after agent completes\n\tif (event.type === \"agent_end\" && this._lastAssistantMessage) {\n\t\tconst msg = this._lastAssistantMessage;\n\t\tthis._lastAssistantMessage = undefined;\n\t\tconst postToolPreflightFailed =\n\t\t\tthis._postToolCompactionPreflightError !== undefined &&\n\t\t\tmsg.errorMessage === this._postToolCompactionPreflightError;\n\n\t\t// Check provider/model failures before compaction. Fallback eligibility is\n\t\t// broader than same-model retry eligibility: auth and request-incompatible\n\t\t// failures advance without re-requesting the failed model.\n\t\tconst fallbackableError =\n\t\t\t!postToolPreflightFailed &&\n\t\t\t(typeof this._isFallbackableError === \"function\"\n\t\t\t\t? this._isFallbackableError(msg)\n\t\t\t\t: this._isRetryableError(msg));\n\t\tconst retryableError = !postToolPreflightFailed && this._isRetryableError(msg);\n\t\tconst emptyCompletion =\n\t\t\t!postToolPreflightFailed && !retryableError && !fallbackableError && this._isEmptyCompletion(msg);\n\t\tconst safetyRefusal =\n\t\t\t!postToolPreflightFailed &&\n\t\t\t!retryableError &&\n\t\t\t!fallbackableError &&\n\t\t\t!emptyCompletion &&\n\t\t\tthis._isSafetyRefusal(msg);\n\t\tconst modelFailure = retryableError || fallbackableError || emptyCompletion || safetyRefusal;\n\t\tlet settleAfterTurn = !modelFailure;\n\t\tif (modelFailure) {\n\t\t\tif (emptyCompletion && !msg.errorMessage) {\n\t\t\t\t// Surface a clear reason in the retry banner; empty completions carry no\n\t\t\t\t// provider error message of their own.\n\t\t\t\tmsg.errorMessage = \"Provider returned an empty completion\";\n\t\t\t} else if (safetyRefusal && !msg.errorMessage) {\n\t\t\t\tmsg.errorMessage = \"Provider returned a canned safety refusal\";\n\t\t\t}\n\t\t\tconst didRetry = await this._handleRetryableError(msg);\n\t\t\tif (didRetry) return; // Retry was initiated, don't proceed to compaction\n\t\t\tsettleAfterTurn = true;\n\t\t}\n\n\t\tthis._resolveRetry();\n\t\tthis._contextOverflowUnresolved = false;\n\t\tawait this._checkCompaction(msg);\n\n\t\t// Compaction owns context overflow first. Only once it is disabled, fails,\n\t\t// or reports the overflow unresolved may the chain spend a candidate on a\n\t\t// larger-context model, so a compactable first overflow costs nothing.\n\t\tif (this._contextOverflowUnresolved) {\n\t\t\tthis._contextOverflowUnresolved = false;\n\t\t\tif (typeof this._trySwitchToFallbackModel === \"function\" && (await this._trySwitchToFallbackModel(msg)))\n\t\t\t\treturn;\n\t\t\tsettleAfterTurn = true;\n\t\t}\n\t\t// Keep a fallback lifecycle open across the compact-and-continue probe that\n\t\t// belongs to this user turn, then settle it without changing the active model.\n\t\tif (settleAfterTurn && this._pendingPostCompactionContinuation === undefined) {\n\t\t\tif (typeof this._settleFallbackModelScope === \"function\") await this._settleFallbackModelScope();\n\t\t}\n\t\t// Launched last so the fallback lifecycle wins: a switch above returns before\n\t\t// this line. Guarded like the fallback methods above because fallback suites\n\t\t// drive this function on a synthetic session.\n\t\tif (event.type === \"agent_end\" && typeof this._maybeGenerateSessionSummary === \"function\")\n\t\t\tvoid this._maybeGenerateSessionSummary();\n\t}\n}\n\nexport function _applyInterruptAbortMessage(this: AgentSession, event: AgentEvent): void {\n\tconst abortMessage = this._activeInterruptAbortMessage;\n\tif (!abortMessage) return;\n\n\tif (event.type === \"tool_execution_end\" && event.isError && isSingleGenericAbortTextContent(event.result.content)) {\n\t\tevent.result.content = replacementAbortContent(abortMessage);\n\t\treturn;\n\t}\n\n\tif (event.type !== \"message_start\" && event.type !== \"message_end\") return;\n\n\tif (\n\t\tevent.message.role === \"toolResult\" &&\n\t\tevent.message.isError &&\n\t\tisSingleGenericAbortTextContent(event.message.content)\n\t) {\n\t\tevent.message.content = replacementAbortContent(abortMessage);\n\t\treturn;\n\t}\n\n\tif (event.message.role === \"assistant\") {\n\t\tconst assistantMessage = event.message as AssistantMessage;\n\t\tif (assistantMessage.stopReason === \"aborted\") {\n\t\t\tassistantMessage.errorMessage = abortMessage;\n\t\t}\n\t}\n}\n\nexport function _applyProviderErrorGuidance(this: AgentSession, event: AgentEvent): void {\n\tif (event.type !== \"message_start\" && event.type !== \"message_update\" && event.type !== \"message_end\") return;\n\tif (event.message.role !== \"assistant\") return;\n\n\tconst assistantMessage = event.message as AssistantMessage;\n\tif (assistantMessage.stopReason !== \"error\" || !assistantMessage.errorMessage) return;\n\n\tassistantMessage.errorMessage = formatCodexProviderError(assistantMessage.provider, assistantMessage.errorMessage);\n}\n\n/** Resolve the pending retry promise */\n\nexport function _resolveRetry(this: AgentSession): void {\n\tif (this._retryResolve) {\n\t\tthis._retryResolve();\n\t\tthis._retryResolve = undefined;\n\t\tthis._retryPromise = undefined;\n\t}\n}\n\n/** Extract text content from a message */\n\nexport function _getUserMessageText(this: AgentSession, message: Message): string {\n\tif (message.role !== \"user\") return \"\";\n\tconst content = message.content;\n\tif (typeof content === \"string\") return content;\n\tconst textBlocks = content.filter((c) => c.type === \"text\");\n\treturn textBlocks.map((c) => (c as TextContent).text).join(\"\");\n}\n\n/** Find the last assistant message in agent state (including aborted ones) */\n\nexport function _findLastAssistantMessage(this: AgentSession): AssistantMessage | undefined {\n\tconst messages = this.agent.state.messages;\n\tfor (let i = messages.length - 1; i >= 0; i--) {\n\t\tconst msg = messages[i];\n\t\tif (msg.role === \"assistant\") {\n\t\t\treturn msg as AssistantMessage;\n\t\t}\n\t}\n\treturn undefined;\n}\n\nexport function _replaceMessageInPlace(this: AgentSession, target: AgentMessage, replacement: AgentMessage): void {\n\t// Agent-core stores the finalized message object in its state before emitting message_end.\n\t// SessionManager persistence happens later in _processAgentEvent() with event.message.\n\t// Mutating this object in place keeps agent state, later turn/agent events, listeners,\n\t// and the eventual SessionManager.appendMessage(event.message) persistence in sync.\n\tif (target === replacement) {\n\t\treturn;\n\t}\n\n\tconst targetRecord = target as unknown as Record<string, unknown>;\n\tfor (const key of Object.keys(targetRecord)) {\n\t\tdelete targetRecord[key];\n\t}\n\tObject.assign(targetRecord, replacement);\n}\n\n/** Emit extension events based on agent events */\n\nexport async function _emitExtensionEvent(this: AgentSession, event: AgentEvent): Promise<void> {\n\tif (event.type === \"agent_start\") {\n\t\tthis._turnIndex = 0;\n\t\tawait this._extensionRunner.emit({ type: \"agent_start\" });\n\t} else if (event.type === \"agent_end\") {\n\t\tawait this._extensionRunner.emit({ type: \"agent_end\", messages: event.messages });\n\t} else if (event.type === \"turn_start\") {\n\t\tconst extensionEvent: TurnStartEvent = {\n\t\t\ttype: \"turn_start\",\n\t\t\tturnIndex: this._turnIndex,\n\t\t\ttimestamp: Date.now(),\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"turn_end\") {\n\t\tconst extensionEvent: TurnEndEvent = {\n\t\t\ttype: \"turn_end\",\n\t\t\tturnIndex: this._turnIndex,\n\t\t\tmessage: event.message,\n\t\t\ttoolResults: event.toolResults,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t\tthis._turnIndex++;\n\t} else if (event.type === \"message_start\") {\n\t\tconst extensionEvent: MessageStartEvent = {\n\t\t\ttype: \"message_start\",\n\t\t\tmessage: event.message,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"message_update\") {\n\t\tconst extensionEvent: MessageUpdateEvent = {\n\t\t\ttype: \"message_update\",\n\t\t\tassistantMessageEvent: event.assistantMessageEvent,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"message_end\") {\n\t\tconst extensionEvent: MessageEndEvent = {\n\t\t\ttype: \"message_end\",\n\t\t\tmessage: event.message,\n\t\t};\n\t\tconst replacement = await this._extensionRunner.emitMessageEnd(extensionEvent);\n\t\tif (replacement) {\n\t\t\tthis._replaceMessageInPlace(event.message, normalizeMessageContent(replacement));\n\t\t}\n\t} else if (event.type === \"tool_execution_start\") {\n\t\tconst extensionEvent: ToolExecutionStartEvent = {\n\t\t\ttype: \"tool_execution_start\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\targs: event.args,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"tool_execution_update\") {\n\t\tconst extensionEvent: ToolExecutionUpdateEvent = {\n\t\t\ttype: \"tool_execution_update\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\targs: event.args,\n\t\t\tpartialResult: event.partialResult,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t} else if (event.type === \"tool_execution_end\") {\n\t\tconst extensionEvent: ToolExecutionEndEvent = {\n\t\t\ttype: \"tool_execution_end\",\n\t\t\ttoolCallId: event.toolCallId,\n\t\t\ttoolName: event.toolName,\n\t\t\tresult: event.result,\n\t\t\tisError: event.isError,\n\t\t};\n\t\tawait this._extensionRunner.emit(extensionEvent);\n\t}\n}\n\n/**\n * Subscribe to agent events.\n * Session persistence is handled internally (saves messages on message_end).\n * Multiple listeners can be added. Returns unsubscribe function for this listener.\n */\n\nexport function subscribe(this: AgentSession, listener: AgentSessionEventListener): () => void {\n\tthis._eventListeners.push(listener);\n\n\t// Return unsubscribe function for this specific listener\n\treturn () => {\n\t\tconst index = this._eventListeners.indexOf(listener);\n\t\tif (index !== -1) {\n\t\t\tthis._eventListeners.splice(index, 1);\n\t\t}\n\t};\n}\n\n/** Disconnect from agent events during disposal. */\nexport function _disconnectFromAgent(this: AgentSession): void {\n\tif (this._unsubscribeAgent) {\n\t\tthis._unsubscribeAgent();\n\t\tthis._unsubscribeAgent = undefined;\n\t}\n}\n\n/**\n * Remove all listeners and disconnect from agent.\n * Call this when completely done with the session.\n */\n\nexport function dispose(this: AgentSession): void {\n\t// Terminal and idempotent: callers legitimately dispose more than once (an explicit dispose\n\t// followed by a harness teardown), and the steps below are not all safe to repeat.\n\tif (this._disposed) return;\n\t// Summary work queued before its AbortController exists cannot be reached by\n\t// abortSessionSummary(), so disposal is recorded as state that every checkpoint consults.\n\tthis._disposed = true;\n\t// A background summary must never keep the process alive past shutdown.\n\tthis.abortSessionSummary();\n\t// Fail closed while protected input remains queued, or flush a consumed\n\t// reconciliation before invalidation can discard its recovery state.\n\tprepareProtectedStreamingCustomMessagesForDisposal(this);\n\tthis._extensionRunner.invalidate(STALE_EXTENSION_CONTEXT_MESSAGE);\n\tthis._disconnectFromAgent();\n\tthis._eventListeners = [];\n\tcleanupSessionResources(this.sessionId);\n\t// Releasing the session lease stops protecting a tree that is no longer in use.\n\tthis._tempStorageLease?.release();\n\tthis._tempStorageLease = undefined;\n}\n\n// =========================================================================\n// Read-only State Access\n// =========================================================================\n\n/** Full agent state */\n\nexport const agentSessionEventsMethods = {\n\t_emit,\n\t_emitQueueUpdate,\n\t_handleAgentEvent,\n\t_createRetryPromiseForAgentEnd,\n\t_findLastAssistantInMessages,\n\t_processAgentEvent,\n\t_applyInterruptAbortMessage,\n\t_applyProviderErrorGuidance,\n\t_resolveRetry,\n\t_getUserMessageText,\n\t_findLastAssistantMessage,\n\t_replaceMessageInPlace,\n\t_emitExtensionEvent,\n\tsubscribe,\n\t_disconnectFromAgent,\n\tdispose,\n};\n"]}
@@ -210,7 +210,7 @@ export interface AgentSessionMethodSurface extends AgentSessionQueuePauseControl
210
210
  _trySwitchToFallbackModel(message: AssistantMessage): Promise<boolean>;
211
211
  _beginFallbackModelScope(): void;
212
212
  _clearFallbackModelScope(): void;
213
- _restoreFallbackModel(): Promise<boolean>;
213
+ _settleFallbackModelScope(): Promise<boolean>;
214
214
  abortRetry(): void;
215
215
  waitForRetry(): Promise<void>;
216
216
  setAutoRetryEnabled(enabled: boolean): void;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-session-methods.d.ts","sourceRoot":"","sources":["../../src/core/agent-session-methods.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9G,OAAO,KAAK,EACX,KAAK,EACL,UAAU,EACV,YAAY,EACZ,UAAU,EACV,SAAS,EACT,aAAa,EACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yCAAyC,CAAC;AAC9F,OAAO,KAAK,EACX,iBAAiB,EACjB,yBAAyB,EACzB,yBAAyB,EACzB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACX,iBAAiB,EACjB,WAAW,EACX,4BAA4B,EAC5B,wBAAwB,EAC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