@bastani/atomic 0.10.0-alpha.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CHANGELOG.md +260 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +22 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +41 -0
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +33 -3
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/core/agent-session-events.d.ts.map +1 -1
  10. package/dist/core/agent-session-events.js +21 -6
  11. package/dist/core/agent-session-events.js.map +1 -1
  12. package/dist/core/lifecycle-timings.d.ts +6 -0
  13. package/dist/core/lifecycle-timings.d.ts.map +1 -1
  14. package/dist/core/lifecycle-timings.js +12 -0
  15. package/dist/core/lifecycle-timings.js.map +1 -1
  16. package/dist/core/queued-message-delivery.d.ts +41 -0
  17. package/dist/core/queued-message-delivery.d.ts.map +1 -0
  18. package/dist/core/queued-message-delivery.js +48 -0
  19. package/dist/core/queued-message-delivery.js.map +1 -0
  20. package/dist/core/storage/node-sqlite-thread.d.ts +64 -0
  21. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -0
  22. package/dist/core/storage/node-sqlite-thread.js +326 -0
  23. package/dist/core/storage/node-sqlite-thread.js.map +1 -0
  24. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  25. package/dist/core/storage/node-sqlite.js +230 -104
  26. package/dist/core/storage/node-sqlite.js.map +1 -1
  27. package/dist/core/tasks/agent-panel-source.d.ts +5 -0
  28. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  29. package/dist/core/tasks/agent-panel-source.js +1 -1
  30. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  31. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +8 -1
  32. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  33. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  34. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +11 -5
  35. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  36. package/dist/modes/interactive/agent-view/agent-view-switcher.js +17 -5
  37. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  38. package/dist/modes/interactive/agent-view/contracts.d.ts +5 -0
  39. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  40. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  41. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  42. package/dist/modes/interactive/agent-view/install.js +6 -3
  43. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  44. package/dist/modes/interactive/agent-view/local-port.d.ts +5 -0
  45. package/dist/modes/interactive/agent-view/local-port.d.ts.map +1 -1
  46. package/dist/modes/interactive/agent-view/local-port.js +8 -0
  47. package/dist/modes/interactive/agent-view/local-port.js.map +1 -1
  48. package/dist/modes/interactive/agent-view/remote-port.d.ts +4 -1
  49. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  50. package/dist/modes/interactive/agent-view/remote-port.js +22 -8
  51. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  52. package/dist/modes/interactive/agent-view/transcript-slot.d.ts +9 -0
  53. package/dist/modes/interactive/agent-view/transcript-slot.d.ts.map +1 -1
  54. package/dist/modes/interactive/agent-view/transcript-slot.js +141 -1
  55. package/dist/modes/interactive/agent-view/transcript-slot.js.map +1 -1
  56. package/dist/modes/interactive/components/agent-panel.d.ts +6 -0
  57. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/agent-panel.js +40 -10
  59. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  60. package/dist/modes/interactive/components/atomic-working-status.d.ts +15 -0
  61. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/atomic-working-status.js +51 -3
  63. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  64. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  65. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/bash-execution.js +5 -1
  67. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  68. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -0
  69. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/branch-summary-message.js +5 -1
  71. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  72. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  73. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  74. package/dist/modes/interactive/components/chat-message-renderer.js +17 -6
  75. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  76. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  77. package/dist/modes/interactive/components/chat-session-host-events.js +35 -4
  78. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  80. package/dist/modes/interactive/components/chat-session-host-rendering.js +70 -13
  81. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  82. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +7 -0
  83. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/chat-session-host-runtime.js +25 -4
  85. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  86. package/dist/modes/interactive/components/chat-session-host-state.d.ts +41 -1
  87. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host-state.js +24 -3
  89. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-steering.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/chat-session-host-steering.js +2 -1
  92. package/dist/modes/interactive/components/chat-session-host-steering.js.map +1 -1
  93. package/dist/modes/interactive/components/chat-session-host.d.ts +13 -1
  94. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/chat-session-host.js +20 -2
  96. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  97. package/dist/modes/interactive/components/chat-transcript.d.ts +15 -0
  98. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/chat-transcript.js +14 -1
  100. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  101. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  102. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/compaction-boundary-message.js +5 -1
  104. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  105. package/dist/modes/interactive/components/custom-entry.d.ts +2 -0
  106. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/custom-entry.js +5 -1
  108. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  109. package/dist/modes/interactive/components/custom-message.d.ts +2 -0
  110. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/custom-message.js +5 -1
  112. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  113. package/dist/modes/interactive/components/model-column.d.ts +96 -0
  114. package/dist/modes/interactive/components/model-column.d.ts.map +1 -0
  115. package/dist/modes/interactive/components/model-column.js +207 -0
  116. package/dist/modes/interactive/components/model-column.js.map +1 -0
  117. package/dist/modes/interactive/components/prompt-slot.d.ts +73 -0
  118. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -0
  119. package/dist/modes/interactive/components/prompt-slot.js +201 -0
  120. package/dist/modes/interactive/components/prompt-slot.js.map +1 -0
  121. package/dist/modes/interactive/components/queued-messages-view.d.ts +6 -3
  122. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/queued-messages-view.js +7 -4
  124. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  125. package/dist/modes/interactive/components/session-selector.d.ts +2 -0
  126. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/session-selector.js +4 -0
  128. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  129. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -0
  130. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  131. package/dist/modes/interactive/components/skill-invocation-message.js +5 -1
  132. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  133. package/dist/modes/interactive/components/task-board.d.ts +12 -3
  134. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  135. package/dist/modes/interactive/components/task-board.js +33 -17
  136. package/dist/modes/interactive/components/task-board.js.map +1 -1
  137. package/dist/modes/interactive/components/task-inspector.d.ts +6 -1
  138. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  139. package/dist/modes/interactive/components/task-inspector.js +27 -7
  140. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  141. package/dist/modes/interactive/components/task-row.d.ts +4 -0
  142. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  143. package/dist/modes/interactive/components/task-row.js +7 -1
  144. package/dist/modes/interactive/components/task-row.js.map +1 -1
  145. package/dist/modes/interactive/components/task-transcript-page.d.ts +5 -0
  146. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/task-transcript-page.js +25 -0
  148. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  149. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  150. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  151. package/dist/modes/interactive/components/tool-execution.js +19 -2
  152. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  153. package/dist/modes/interactive/components/tool-group-tracker.d.ts +20 -3
  154. package/dist/modes/interactive/components/tool-group-tracker.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/tool-group-tracker.js +34 -7
  156. package/dist/modes/interactive/components/tool-group-tracker.js.map +1 -1
  157. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +14 -2
  158. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/transcript-block-clicks.js +23 -2
  160. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  161. package/dist/modes/interactive/interactive-agent-events.js +10 -2
  162. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  163. package/dist/modes/interactive/interactive-extension-runtime.d.ts +12 -1
  164. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  165. package/dist/modes/interactive/interactive-extension-runtime.js +37 -5
  166. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  167. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  168. package/dist/modes/interactive/interactive-input-handling.js +70 -46
  169. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  171. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  172. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  173. package/dist/modes/interactive/interactive-prompt-turn.js +17 -9
  174. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  175. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  176. package/dist/modes/interactive/interactive-queueing.js +2 -1
  177. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  178. package/dist/modes/interactive/interactive-render-chat.d.ts +18 -1
  179. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  180. package/dist/modes/interactive/interactive-render-chat.js +90 -10
  181. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  182. package/dist/modes/interactive/interactive-session-routing.js +2 -0
  183. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  184. package/dist/modes/interactive/interactive-task-projection.js +2 -2
  185. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  186. package/dist/modes/interactive/screen-hold.d.ts +41 -0
  187. package/dist/modes/interactive/screen-hold.d.ts.map +1 -0
  188. package/dist/modes/interactive/screen-hold.js +80 -0
  189. package/dist/modes/interactive/screen-hold.js.map +1 -0
  190. package/dist/modes/interactive/started-run-echo.d.ts +66 -0
  191. package/dist/modes/interactive/started-run-echo.d.ts.map +1 -0
  192. package/dist/modes/interactive/started-run-echo.js +75 -0
  193. package/dist/modes/interactive/started-run-echo.js.map +1 -0
  194. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -0
  195. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  196. package/dist/modes/interactive-engine/engine-custom-ui.js +25 -1
  197. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  198. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  199. package/dist/modes/interactive-engine/engine-quit-intent.js +3 -0
  200. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  201. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  202. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  203. package/dist/modes/interactive-engine/protocol.js +7 -1
  204. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  205. package/dist/modes/interactive-engine/remote-component.d.ts +10 -2
  206. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  207. package/dist/modes/interactive-engine/remote-component.js +19 -2
  208. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  209. package/dist/modes/interactive-engine/remote-renderer.d.ts +10 -0
  210. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  211. package/dist/modes/interactive-engine/remote-renderer.js +24 -4
  212. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  213. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts +50 -0
  214. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts.map +1 -0
  215. package/dist/modes/interactive-engine/transcript-frame-layout.js +95 -0
  216. package/dist/modes/interactive-engine/transcript-frame-layout.js.map +1 -0
  217. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  218. package/dist/modes/rpc/agent-panel-bridge.js +16 -0
  219. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  220. package/dist/modes/rpc/agent-view-engine-registry.d.ts.map +1 -1
  221. package/dist/modes/rpc/agent-view-engine-registry.js +36 -1
  222. package/dist/modes/rpc/agent-view-engine-registry.js.map +1 -1
  223. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  224. package/dist/modes/rpc/agent-view-rpc-panel.js +5 -1
  225. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  226. package/dist/modes/rpc/task-ui-bridge.js +1 -1
  227. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  228. package/docs/background-tasks.md +1 -1
  229. package/docs/development.md +2 -0
  230. package/docs/extensions/authoring.md +1 -1
  231. package/docs/keybindings.md +2 -2
  232. package/docs/storage.md +1 -0
  233. package/npm-shrinkwrap.json +49 -49
  234. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,GAClC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OA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Q,EAAE,EAAE;QAC5D,MAAM,KAAK,GAAG,WAAW,CAAC;QAC1B,WAAW,GAAG,SAAS,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,KAAK,CAAC,KAAK,IAAI,EAAE;YAChB,IAAI,SAAS,GAAa,EAAE,CAAC;YAC7B,IAAI,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC;oBACJ,SAAS,GAAG,WAAW,CAAC,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,wFAAwF;gBACzF,CAAC;YACF,CAAC;YACD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO;YACnC,gFAAgF;YAChF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;YACnF,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { PromptDisposition, UserMessageWithRawText } from \"../../core/agent-session-types.js\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport {\n\tclearInteractiveEngineQueue,\n\tgetInteractiveEngineRemoteCommands,\n} from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { viewedSteering } from \"./agent-view/viewed-submit.ts\";\nimport { combineQueuedMessagesForEditor } from \"./chat-input-actions.ts\";\nimport { QueuedMessagesView, queuedMessageRows } from \"./components/queued-messages-view.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\nimport {\n\trestoredQueue,\n\ttype SteeringEditorQueue,\n\tSteeringQueueController,\n\ttype SteeringQueueLists,\n\ttype SteeringTarget,\n} from \"./steering-queue-controller.ts\";\n\n/** Typing order of messages handed to the session, so one it refuses returns to its own place. */\nconst handOffOrder = new WeakMap<CompactionQueuedMessage, number>();\nlet nextHandOff = 0;\n\n/**\n * The main chat's steering controller. Messages handed to the session that it has not confirmed yet stay shown as\n * queued until the session reports it took them; from then on the session lists them itself. They are the session's\n * from the moment they are sent, so a restore takes them from the session's own answer and never from this copy.\n */\nconst mainControllers = new WeakMap<InteractiveModeBase, SteeringQueueController>();\n\nexport function mainSteering(mode: InteractiveModeBase): SteeringQueueController {\n\tlet controller = mainControllers.get(mode);\n\tif (controller === undefined) {\n\t\tcontroller = new SteeringQueueController(mainSteeringTarget(mode), mainEditorQueue(mode));\n\t\tmainControllers.set(mode, controller);\n\t}\n\treturn controller;\n}\n\n/** The main chat's session, read at each call, so a session the chat switched to is the one steered. */\nfunction mainSteeringTarget(mode: InteractiveModeBase): SteeringTarget {\n\treturn {\n\t\tget busy() {\n\t\t\treturn mode.session.isStreaming || mode.promptTurn !== undefined;\n\t\t},\n\t\tget paused() {\n\t\t\treturn mode.session.queuedMessagesPaused;\n\t\t},\n\t\t// An isolated engine can crash with what it queued; the chat then gives those messages back.\n\t\tcanBeLost: true,\n\t\tqueued: () => ({\n\t\t\tsteering: mode.session.getSteeringMessages(),\n\t\t\tfollowUp: mode.session.getFollowUpMessages(),\n\t\t}),\n\t\tprompt: (text, options) => mode.session.prompt(text, options),\n\t\tclearQueue: (options) =>\n\t\t\tclearInteractiveEngineQueue(mode.runtimeHost) ?? Promise.resolve(mode.session.clearQueue(options)),\n\t};\n}\n\n/** The messages the main editor holds while compaction runs, listed after the session's own. */\nfunction mainEditorQueue(mode: InteractiveModeBase): SteeringEditorQueue {\n\treturn {\n\t\theld: () => mode.compactionQueuedMessages,\n\t\ttakeHeld: () => {\n\t\t\tconst held = mode.compactionQueuedMessages;\n\t\t\tconst heldSendFailed = mode.compactionSendFailed;\n\t\t\tmode.compactionQueuedMessages = [];\n\t\t\tmode.compactionSendFailed = false;\n\t\t\treturn {\n\t\t\t\tmessages: held,\n\t\t\t\tputBack: () => {\n\t\t\t\t\tmode.compactionQueuedMessages = [...held, ...mode.compactionQueuedMessages];\n\t\t\t\t\t// If compaction ended meanwhile, its flush found the queue empty and nothing else will send these.\n\t\t\t\t\t// Marked as unsent, they go out in order ahead of the next submission, as a batch whose first send\n\t\t\t\t\t// failed does.\n\t\t\t\t\tmode.compactionSendFailed ||= heldSendFailed || (held.length > 0 && !mode.compactionActive);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tchanged: () => mode.updatePendingMessagesDisplay(),\n\t\trequestRender: () => mode.ui.requestRender(),\n\t};\n}\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn mainSteering(this).allQueued();\n};\n\n/**\n * Take every queued message back from the session and this editor, so the caller can restore them.\n *\n * What the session removed is its own answer, not this editor's copy of its queue. An engine child lists its queue\n * by `queue_update` events that trail it by a round trip, so a message it queued meanwhile is missing from the copy\n * and one it already took into a turn is still in it (#4257). The messages only this editor holds follow them.\n * When the session cannot be reached nothing is removed and the held messages stay queued.\n */\nInteractiveModeBase.prototype.clearAllQueues = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): Promise<{\n\tsteering: string[];\n\tfollowUp: string[];\n}> {\n\treturn mainSteering(this).clearAll(options);\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\t// While a subagent is shown, the rows above the prompt are its queue, drawn as the main chat draws its own.\n\tconst viewed = viewedSteering(this);\n\tif (viewed !== undefined) {\n\t\tconst rows = queuedMessageRows(viewed.allQueued());\n\t\tif (rows.length === 0) return;\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t\treturn;\n\t}\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.addChild(component);\n\t}\n\tconst rows = queuedMessageRows(this.getAllQueuedMessages());\n\tif (rows.length > 0) {\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): Promise<number> {\n\t// Main's prompt, also once the screen shows a subagent before the session answers.\n\tconst prompt = promptHandle(this, \"main\");\n\tconst restored = restoredQueue(\n\t\tawait this.clearAllQueues(options),\n\t\t() => options?.currentText ?? prompt.getExpandedText(),\n\t);\n\tif (restored !== undefined) prompt.setText(restored.text);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn restored?.messages.length ?? 0;\n};\n\n/** Report a restore the session could not answer; nothing was removed, so every message is still queued. */\nexport function showQueueRestoreFailure(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to restore queued messages: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst commandName = parseSlashCommand(text).name;\n\tif (extensionRunner.getCommand(commandName)) return true;\n\treturn getInteractiveEngineRemoteCommands(this.runtimeHost).some(\n\t\t(command) => command.source === \"extension\" && command.name === commandName,\n\t);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction returnHandedOffMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tconst rank = handOffOrder.get(message) ?? -1;\n\tconst queue = mode.compactionQueuedMessages;\n\tconst index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);\n\tmode.compactionQueuedMessages =\n\t\tindex === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction confirmHandOff(mode: InteractiveModeBase, message: CompactionQueuedMessage): boolean {\n\treturn mainSteering(mode).settle(message);\n}\n\n/**\n * Show a message sent while the agent works as queued at once, before the session confirms it (#4696). Delivery waits\n * on the session: in an isolated engine that is a round trip through a process whose event loop the agent's own work,\n * such as a running subagent, shares. The editor shows the message until `settleSubmission()` or a `queue_update` that\n * lists it, whichever comes first.\n */\nexport function showSubmissionAsQueued(\n\tmode: InteractiveModeBase,\n\ttext: string,\n\tlane: CompactionQueuedMessage[\"mode\"],\n): CompactionQueuedMessage {\n\treturn mainSteering(mode).showAsQueued({ text, mode: lane });\n}\n\n/**\n * Stop showing a submission once the session answered it: queued, it lists the message itself; started or handled, it\n * is no longer queued; refused, the caller gives it back to the editor and reports why.\n */\nexport function settleSubmission(mode: InteractiveModeBase, message: CompactionQueuedMessage): void {\n\tif (confirmHandOff(mode, message)) mode.ui.requestRender();\n}\n\n/**\n * The session saved a user message: a message sent while the chat showed the turn running, which the session started\n * its next turn with, is delivered from here on, so an engine crash no longer gives it back.\n */\nexport function noteSteeringSaved(mode: InteractiveModeBase, message: UserMessageWithRawText): void {\n\tconst text = mode.getUserMessageText(message);\n\tmainSteering(mode).noteSaved(message.rawText === undefined ? [text] : [text, message.rawText]);\n}\n\n/**\n * Stop showing editor copies of messages the session's queue now lists, so a confirmed message is never shown twice\n * (#4696). Only a message this update added confirms a copy, oldest copy first, so an identical message queued\n * earlier does not.\n */\nexport function reconcileQueuedSubmissions(mode: InteractiveModeBase, queue: SteeringQueueLists): void {\n\tmainSteering(mode).reconcile(queue);\n}\n\n/**\n * Hand the editor's held messages to the session before an extension command runs during compaction (#4251).\n * The session registers input as it arrives and holds it until compaction ends, so a message the command sends\n * goes out after them, in typing order. Each message stays shown here until the session confirms it took it, and\n * from then on the session lists it as queued. The session's clearQueue() returns it for Alt+Up and Ctrl+C, also\n * when the confirmation is still on its way. A message the session refuses returns to the editor queue.\n */\nexport function handOffCompactionQueue(mode: InteractiveModeBase): void {\n\tconst messages = mode.compactionQueuedMessages;\n\tif (messages.length === 0) return;\n\tmode.compactionQueuedMessages = [];\n\tmainSteering(mode).track(messages);\n\tfor (const message of messages) {\n\t\thandOffOrder.set(message, nextHandOff++);\n\t\tlet accepted = false;\n\t\tvoid mode.session\n\t\t\t.prompt(message.text, {\n\t\t\t\tstreamingBehavior: message.mode,\n\t\t\t\tpreflightResult: (success) => {\n\t\t\t\t\taccepted = success;\n\t\t\t\t\tif (success) confirmHandOff(mode, message);\n\t\t\t\t},\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (accepted || isRpcRequestAcceptedFailure(error)) {\n\t\t\t\t\tconfirmHandOff(mode, message);\n\t\t\t\t\tshowCompactionQueueError(mode, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.\n\t\t\t\tif (confirmHandOff(mode, message)) returnHandedOffMessage(mode, message, error);\n\t\t\t});\n\t}\n\tmode.updatePendingMessagesDisplay();\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonAccepted?: (disposition: PromptDisposition | undefined) => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success) onAccepted?.(disposition);\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst shownBefore = mode.userMessagesShownBySession;\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed\n\t\t\t\t? (disposition) => {\n\t\t\t\t\t\tif (disposition === \"queued\" || disposition === \"handled\")\n\t\t\t\t\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t\t\t\t\t\tif (disposition === \"started\") mode.expectStartedUserInput(message.text, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t\t// #5135: a run that repeats input the chat already shows as unsaved shows no message of its own.\n\t\tif (\n\t\t\techoed &&\n\t\t\tmode.startedDeferredUserInput === message.text &&\n\t\t\tmode.deferredRenderedUserInputs?.includes(message.text) === true\n\t\t)\n\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n\n/** `count` queued message(s), with the verb agreeing. */\nfunction queuedMessagesPhrase(count: number): string {\n\treturn count === 1 ? \"1 queued message\" : `${count} queued messages`;\n}\n\n/** The notice the main chat shows when a lost engine's queued messages come back to its editor. */\nexport function engineLossRestoredNotice(count: number): string {\n\treturn `Engine restarted; ${queuedMessagesPhrase(count)} ${count === 1 ? \"wasn't\" : \"weren't\"} sent and ${count === 1 ? \"is\" : \"are\"} back in the editor`;\n}\n\n/** What a subagent had queued, or had on its way, when the engine that runs it was lost. */\nexport interface LostSubagentQueue {\n\treadonly agent: string;\n\treadonly steering: readonly string[];\n\treadonly followUp: readonly string[];\n}\n\n/** The notice listing, in full and in order, what a subagent had queued when the engine was lost. */\nexport function engineLossSubagentNotice(queue: LostSubagentQueue): string | undefined {\n\tconst messages = [...queue.steering, ...queue.followUp];\n\tif (messages.length === 0) return undefined;\n\tconst verb = messages.length === 1 ? \"wasn't\" : \"weren't\";\n\treturn [\n\t\t`Engine restarted; ${queuedMessagesPhrase(messages.length)} to ${queue.agent} ${verb} sent:`,\n\t\t...messages,\n\t].join(\"\\n\");\n}\n\nfunction textOfUserMessage(content: unknown): string | undefined {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn content\n\t\t.flatMap((part: { type?: unknown; text?: unknown }) =>\n\t\t\tpart.type === \"text\" && typeof part.text === \"string\" ? [part.text] : [],\n\t\t)\n\t\t.join(\"\");\n}\n\n/** The user messages `messages` holds, as text. */\nfunction userMessageTexts(messages: readonly { readonly role: string; readonly content?: unknown }[]): string[] {\n\treturn messages.flatMap((message) => {\n\t\tconst text = message.role === \"user\" ? textOfUserMessage(message.content) : undefined;\n\t\treturn text === undefined ? [] : [text];\n\t});\n}\n\n/** `after` without one copy of each text of `before`: what was added. */\nfunction withoutEach(after: readonly string[], before: readonly string[]): string[] {\n\tconst remaining = new Map<string, number>();\n\tfor (const text of before) remaining.set(text, (remaining.get(text) ?? 0) + 1);\n\treturn after.filter((text) => {\n\t\tconst count = remaining.get(text) ?? 0;\n\t\tif (count === 0) return true;\n\t\tremaining.set(text, count - 1);\n\t\treturn false;\n\t});\n}\n\n/**\n * An isolated engine that is lost and replaced takes its queue with it. The messages the main chat showed as queued\n * come back to its editor, as Alt+Up would restore them, with a notice, unless the replacement's history shows the\n * lost engine delivered them. (What a shown subagent had queued is listed by `attachLostAgentQueueNotices`.) Nothing is\n * sent again. A deliberate replacement or stop changes nothing.\n */\nInteractiveModeBase.prototype.attachSteeringEngineRecovery = function (this: InteractiveModeBase): () => void {\n\tconst runtime = this.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\t/** The user messages the chat knew when the engine was lost, while its replacement is pending. */\n\tlet knownAtLoss: string[] | undefined;\n\tconst stopEnded = runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tmainSteering(this).loseTarget();\n\t\truntime.discardLostQueue();\n\t\tknownAtLoss ??= userMessageTexts(this.session.messages);\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.ui.requestRender();\n\t});\n\tconst stopRecovered = runtime.onEngineRecovered((replaced) => {\n\t\tconst known = knownAtLoss;\n\t\tknownAtLoss = undefined;\n\t\tif (known === undefined) return;\n\t\tvoid (async () => {\n\t\t\tlet delivered: string[] = [];\n\t\t\tif (replaced) {\n\t\t\t\ttry {\n\t\t\t\t\tdelivered = withoutEach(await runtime.engineUserMessages(), known);\n\t\t\t\t} catch {\n\t\t\t\t\t// The replacement could not say what it holds: give everything back, nothing is resent.\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst messages = mainSteering(this).recoverTarget(delivered);\n\t\t\tif (messages === undefined) return;\n\t\t\t// Main's prompt, whatever the screen shows by the time the replacement answers.\n\t\t\tconst prompt = promptHandle(this, \"main\");\n\t\t\tprompt.setText(combineQueuedMessagesForEditor(messages, prompt.getExpandedText()));\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.showWarning(engineLossRestoredNotice(messages.length));\n\t\t\tthis.ui.requestRender();\n\t\t})();\n\t});\n\treturn () => {\n\t\tstopEnded();\n\t\tstopRecovered();\n\t};\n};\n"]}
1
+ {"version":3,"file":"interactive-queueing.js","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-queueing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACN,2BAA2B,EAC3B,kCAAkC,GAClC,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,0BAA0B,EAAE,MAAM,2CAA2C,CAAC;AACvF,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC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CAAC,CAAC;IACH,MAAM,aAAa,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC,QAAQ,EAAE,EAAE;QAC5D,MAAM,KAAK,GAAG,WAAW,CAAC;QAC1B,WAAW,GAAG,SAAS,CAAC;QACxB,IAAI,KAAK,KAAK,SAAS;YAAE,OAAO;QAChC,KAAK,CAAC,KAAK,IAAI,EAAE;YAChB,IAAI,SAAS,GAAa,EAAE,CAAC;YAC7B,IAAI,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC;oBACJ,SAAS,GAAG,WAAW,CAAC,MAAM,OAAO,CAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACR,wFAAwF;gBACzF,CAAC;YACF,CAAC;YACD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC;YAC7D,IAAI,QAAQ,KAAK,SAAS;gBAAE,OAAO;YACnC,gFAAgF;YAChF,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YAC1C,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,QAAQ,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;YACnF,IAAI,CAAC,4BAA4B,EAAE,CAAC;YACpC,IAAI,CAAC,WAAW,CAAC,wBAAwB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;YAC5D,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC,CAAC,EAAE,CAAC;IACN,CAAC,CAAC,CAAC;IACH,OAAO,GAAG,EAAE;QACX,SAAS,EAAE,CAAC;QACZ,aAAa,EAAE,CAAC;IACjB,CAAC,CAAC;AACH,CAAC,CAAC","sourcesContent":["import type { PromptDisposition, UserMessageWithRawText } from \"../../core/agent-session-types.js\";\nimport { parseSlashCommand } from \"../../core/slash-commands.js\";\nimport {\n\tclearInteractiveEngineQueue,\n\tgetInteractiveEngineRemoteCommands,\n} from \"../interactive-engine/extension-ui-bridge.ts\";\nimport { IsolatedInteractiveRuntime } from \"../interactive-engine/isolated-runtime.js\";\nimport { isRpcRequestAcceptedFailure } from \"../rpc/rpc-transport-error.ts\";\nimport { promptHandle } from \"./agent-view/agent-drafts.ts\";\nimport { viewedSteering } from \"./agent-view/viewed-submit.ts\";\nimport { combineQueuedMessagesForEditor } from \"./chat-input-actions.ts\";\nimport { QueuedMessagesView, queuedMessageRows } from \"./components/queued-messages-view.ts\";\nimport { InteractiveModeBase } from \"./interactive-mode-base.ts\";\nimport { theme } from \"./interactive-mode-deps.ts\";\nimport type { CompactionQueuedMessage } from \"./interactive-mode-types.ts\";\nimport {\n\trestoredQueue,\n\ttype SteeringEditorQueue,\n\tSteeringQueueController,\n\ttype SteeringQueueLists,\n\ttype SteeringTarget,\n} from \"./steering-queue-controller.ts\";\n\n/** Typing order of messages handed to the session, so one it refuses returns to its own place. */\nconst handOffOrder = new WeakMap<CompactionQueuedMessage, number>();\nlet nextHandOff = 0;\n\n/**\n * The main chat's steering controller. Messages handed to the session that it has not confirmed yet stay shown as\n * queued until the session reports it took them; from then on the session lists them itself. They are the session's\n * from the moment they are sent, so a restore takes them from the session's own answer and never from this copy.\n */\nconst mainControllers = new WeakMap<InteractiveModeBase, SteeringQueueController>();\n\nexport function mainSteering(mode: InteractiveModeBase): SteeringQueueController {\n\tlet controller = mainControllers.get(mode);\n\tif (controller === undefined) {\n\t\tcontroller = new SteeringQueueController(mainSteeringTarget(mode), mainEditorQueue(mode));\n\t\tmainControllers.set(mode, controller);\n\t}\n\treturn controller;\n}\n\n/** The main chat's session, read at each call, so a session the chat switched to is the one steered. */\nfunction mainSteeringTarget(mode: InteractiveModeBase): SteeringTarget {\n\treturn {\n\t\tget busy() {\n\t\t\treturn mode.session.isStreaming || mode.promptTurn !== undefined;\n\t\t},\n\t\tget paused() {\n\t\t\treturn mode.session.queuedMessagesPaused;\n\t\t},\n\t\t// An isolated engine can crash with what it queued; the chat then gives those messages back.\n\t\tcanBeLost: true,\n\t\tqueued: () => ({\n\t\t\tsteering: mode.session.getSteeringMessages(),\n\t\t\tfollowUp: mode.session.getFollowUpMessages(),\n\t\t}),\n\t\tprompt: (text, options) => mode.session.prompt(text, options),\n\t\tclearQueue: (options) =>\n\t\t\tclearInteractiveEngineQueue(mode.runtimeHost) ?? Promise.resolve(mode.session.clearQueue(options)),\n\t};\n}\n\n/** The messages the main editor holds while compaction runs, listed after the session's own. */\nfunction mainEditorQueue(mode: InteractiveModeBase): SteeringEditorQueue {\n\treturn {\n\t\theld: () => mode.compactionQueuedMessages,\n\t\ttakeHeld: () => {\n\t\t\tconst held = mode.compactionQueuedMessages;\n\t\t\tconst heldSendFailed = mode.compactionSendFailed;\n\t\t\tmode.compactionQueuedMessages = [];\n\t\t\tmode.compactionSendFailed = false;\n\t\t\treturn {\n\t\t\t\tmessages: held,\n\t\t\t\tputBack: () => {\n\t\t\t\t\tmode.compactionQueuedMessages = [...held, ...mode.compactionQueuedMessages];\n\t\t\t\t\t// If compaction ended meanwhile, its flush found the queue empty and nothing else will send these.\n\t\t\t\t\t// Marked as unsent, they go out in order ahead of the next submission, as a batch whose first send\n\t\t\t\t\t// failed does.\n\t\t\t\t\tmode.compactionSendFailed ||= heldSendFailed || (held.length > 0 && !mode.compactionActive);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t\tchanged: () => mode.updatePendingMessagesDisplay(),\n\t\trequestRender: () => mode.ui.requestRender(),\n\t};\n}\n\nInteractiveModeBase.prototype.getAllQueuedMessages = function (this: InteractiveModeBase): {\n\tsteering: string[];\n\tfollowUp: string[];\n} {\n\treturn mainSteering(this).allQueued();\n};\n\n/**\n * Take every queued message back from the session and this editor, so the caller can restore them.\n *\n * What the session removed is its own answer, not this editor's copy of its queue. An engine child lists its queue\n * by `queue_update` events that trail it by a round trip, so a message it queued meanwhile is missing from the copy\n * and one it already took into a turn is still in it (#4257). The messages only this editor holds follow them.\n * When the session cannot be reached nothing is removed and the held messages stay queued.\n */\nInteractiveModeBase.prototype.clearAllQueues = async function (\n\tthis: InteractiveModeBase,\n\toptions?: { preserveUnprotectedCustomMessages?: boolean },\n): Promise<{\n\tsteering: string[];\n\tfollowUp: string[];\n}> {\n\treturn mainSteering(this).clearAll(options);\n};\n\nInteractiveModeBase.prototype.updatePendingMessagesDisplay = function (this: InteractiveModeBase): void {\n\tthis.pendingMessagesContainer.clear();\n\t// While a subagent is shown, the rows above the prompt are its queue, drawn as the main chat draws its own.\n\tconst viewed = viewedSteering(this);\n\tif (viewed !== undefined) {\n\t\tconst shown = this.agentView?.viewed;\n\t\tconst rows = queuedMessageRows(\n\t\t\tviewed.allQueued(),\n\t\t\tshown?.kind === \"agent\" ? shown.port.status().delivering : undefined,\n\t\t);\n\t\tif (rows.length === 0) return;\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t\treturn;\n\t}\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.addChild(component);\n\t}\n\tconst rows = queuedMessageRows(this.getAllQueuedMessages());\n\tif (rows.length > 0) {\n\t\tconst dequeueKey = this.getAppKeyDisplay(\"app.message.dequeue\");\n\t\tthis.pendingMessagesContainer.addChild(new QueuedMessagesView(rows, dequeueKey, (text) => theme.fg(\"dim\", text)));\n\t}\n};\n\nInteractiveModeBase.prototype.restoreQueuedMessagesToEditor = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\tabort?: boolean;\n\t\tcurrentText?: string;\n\t\tpreserveUnprotectedCustomMessages?: boolean;\n\t},\n): Promise<number> {\n\t// Main's prompt, also once the screen shows a subagent before the session answers.\n\tconst prompt = promptHandle(this, \"main\");\n\tconst restored = restoredQueue(\n\t\tawait this.clearAllQueues(options),\n\t\t() => options?.currentText ?? prompt.getExpandedText(),\n\t);\n\tif (restored !== undefined) prompt.setText(restored.text);\n\tthis.updatePendingMessagesDisplay();\n\tif (options?.abort) {\n\t\tvoid this.session.abort();\n\t}\n\treturn restored?.messages.length ?? 0;\n};\n\n/** Report a restore the session could not answer; nothing was removed, so every message is still queued. */\nexport function showQueueRestoreFailure(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to restore queued messages: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nInteractiveModeBase.prototype.queueCompactionMessage = function (\n\tthis: InteractiveModeBase,\n\ttext: string,\n\tmode: \"steer\" | \"followUp\",\n): void {\n\tthis.compactionQueuedMessages.push({ text, mode });\n\tthis.editor.addToHistory?.(text);\n\tthis.editor.setText(\"\");\n\tthis.updatePendingMessagesDisplay();\n\tif (this.compactionActive) {\n\t\tthis.showStatus(\"Queued message for after compaction\");\n\t\treturn;\n\t}\n\tif (!this.compactionFlushPending) void this.flushCompactionQueue({ willRetry: false });\n};\n\nInteractiveModeBase.prototype.isExtensionCommand = function (this: InteractiveModeBase, text: string): boolean {\n\tif (!text.startsWith(\"/\")) return false;\n\n\tconst extensionRunner = this.session.extensionRunner;\n\n\tconst commandName = parseSlashCommand(text).name;\n\tif (extensionRunner.getCommand(commandName)) return true;\n\treturn getInteractiveEngineRemoteCommands(this.runtimeHost).some(\n\t\t(command) => command.source === \"extension\" && command.name === commandName,\n\t);\n};\n\nInteractiveModeBase.prototype.flushCompactionQueue = async function (\n\tthis: InteractiveModeBase,\n\toptions?: {\n\t\twillRetry?: boolean;\n\t\tafterPrompt?: boolean;\n\t},\n): Promise<void> {\n\tif (this.compactionFlushPending || this.compactionQueuedMessages.length === 0) return;\n\tif (this.promptTurn?.dispatched === false) return;\n\tthis.compactionFlushPending = true;\n\tthis.compactionSendFailed = false;\n\ttry {\n\t\tif (options?.afterPrompt === true) await sendHeldInput(this);\n\t\telse await sendCompactionQueue(this, options?.willRetry === true);\n\t} finally {\n\t\tthis.compactionFlushPending = false;\n\t\tthis.updatePendingMessagesDisplay();\n\t}\n\tconst arrivedAfterDrain =\n\t\tthis.compactionQueuedMessages.length > 0 && !this.compactionSendFailed && !this.compactionActive;\n\tif (arrivedAfterDrain) await this.flushCompactionQueue(options);\n};\n\nasync function sendCompactionQueue(mode: InteractiveModeBase, willRetry: boolean): Promise<void> {\n\tconst queueOnly = !willRetry && (mode.session.isStreaming || mode.session.queuedMessagesPaused);\n\tif (queueOnly) {\n\t\tawait drainCompactionQueue(mode, (message) =>\n\t\t\tmode.session.prompt(message.text, { streamingBehavior: message.mode }),\n\t\t);\n\t\treturn;\n\t}\n\tif (!willRetry && !(await startCompactionQueuePrompt(mode))) return;\n\tawait drainCompactionQueue(mode, (message) => {\n\t\tif (mode.isExtensionCommand(message.text)) return mode.session.prompt(message.text);\n\t\tif (message.mode === \"followUp\") return mode.session.followUp(message.text);\n\t\treturn mode.session.steer(message.text);\n\t});\n}\n\nfunction showCompactionQueueError(mode: InteractiveModeBase, error: unknown): void {\n\tmode.showError(`Failed to send queued message: ${error instanceof Error ? error.message : String(error)}`);\n}\n\nfunction takeNextCompactionMessage(mode: InteractiveModeBase): CompactionQueuedMessage | undefined {\n\tconst [next, ...rest] = mode.compactionQueuedMessages;\n\tmode.compactionQueuedMessages = rest;\n\tmode.updatePendingMessagesDisplay();\n\treturn next;\n}\n\nfunction returnCompactionMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tmode.compactionQueuedMessages = [message, ...mode.compactionQueuedMessages];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction returnHandedOffMessage(mode: InteractiveModeBase, message: CompactionQueuedMessage, error: unknown): void {\n\tconst rank = handOffOrder.get(message) ?? -1;\n\tconst queue = mode.compactionQueuedMessages;\n\tconst index = queue.findIndex((queued) => (handOffOrder.get(queued) ?? Number.POSITIVE_INFINITY) > rank);\n\tmode.compactionQueuedMessages =\n\t\tindex === -1 ? [...queue, message] : [...queue.slice(0, index), message, ...queue.slice(index)];\n\tmode.compactionSendFailed = true;\n\tmode.updatePendingMessagesDisplay();\n\tshowCompactionQueueError(mode, error);\n}\n\nfunction confirmHandOff(mode: InteractiveModeBase, message: CompactionQueuedMessage): boolean {\n\treturn mainSteering(mode).settle(message);\n}\n\n/**\n * Show a message sent while the agent works as queued at once, before the session confirms it (#4696). Delivery waits\n * on the session: in an isolated engine that is a round trip through a process whose event loop the agent's own work,\n * such as a running subagent, shares. The editor shows the message until `settleSubmission()` or a `queue_update` that\n * lists it, whichever comes first.\n */\nexport function showSubmissionAsQueued(\n\tmode: InteractiveModeBase,\n\ttext: string,\n\tlane: CompactionQueuedMessage[\"mode\"],\n): CompactionQueuedMessage {\n\treturn mainSteering(mode).showAsQueued({ text, mode: lane });\n}\n\n/**\n * Stop showing a submission once the session answered it: queued, it lists the message itself; started or handled, it\n * is no longer queued; refused, the caller gives it back to the editor and reports why.\n */\nexport function settleSubmission(mode: InteractiveModeBase, message: CompactionQueuedMessage): void {\n\tif (confirmHandOff(mode, message)) mode.ui.requestRender();\n}\n\n/**\n * The session saved a user message: a message sent while the chat showed the turn running, which the session started\n * its next turn with, is delivered from here on, so an engine crash no longer gives it back.\n */\nexport function noteSteeringSaved(mode: InteractiveModeBase, message: UserMessageWithRawText): void {\n\tconst text = mode.getUserMessageText(message);\n\tmainSteering(mode).noteSaved(message.rawText === undefined ? [text] : [text, message.rawText]);\n}\n\n/**\n * Stop showing editor copies of messages the session's queue now lists, so a confirmed message is never shown twice\n * (#4696). Only a message this update added confirms a copy, oldest copy first, so an identical message queued\n * earlier does not.\n */\nexport function reconcileQueuedSubmissions(mode: InteractiveModeBase, queue: SteeringQueueLists): void {\n\tmainSteering(mode).reconcile(queue);\n}\n\n/**\n * Hand the editor's held messages to the session before an extension command runs during compaction (#4251).\n * The session registers input as it arrives and holds it until compaction ends, so a message the command sends\n * goes out after them, in typing order. Each message stays shown here until the session confirms it took it, and\n * from then on the session lists it as queued. The session's clearQueue() returns it for Alt+Up and Ctrl+C, also\n * when the confirmation is still on its way. A message the session refuses returns to the editor queue.\n */\nexport function handOffCompactionQueue(mode: InteractiveModeBase): void {\n\tconst messages = mode.compactionQueuedMessages;\n\tif (messages.length === 0) return;\n\tmode.compactionQueuedMessages = [];\n\tmainSteering(mode).track(messages);\n\tfor (const message of messages) {\n\t\thandOffOrder.set(message, nextHandOff++);\n\t\tlet accepted = false;\n\t\tvoid mode.session\n\t\t\t.prompt(message.text, {\n\t\t\t\tstreamingBehavior: message.mode,\n\t\t\t\tpreflightResult: (success) => {\n\t\t\t\t\taccepted = success;\n\t\t\t\t\tif (success) confirmHandOff(mode, message);\n\t\t\t\t},\n\t\t\t})\n\t\t\t.catch((error: unknown) => {\n\t\t\t\tif (accepted || isRpcRequestAcceptedFailure(error)) {\n\t\t\t\t\tconfirmHandOff(mode, message);\n\t\t\t\t\tshowCompactionQueueError(mode, error);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Alt+Up may already have returned it to the editor; only an unconfirmed message goes back.\n\t\t\t\tif (confirmHandOff(mode, message)) returnHandedOffMessage(mode, message, error);\n\t\t\t});\n\t}\n\tmode.updatePendingMessagesDisplay();\n}\n\n/**\n * Deliver messages one at a time from the front of the compaction queue. Input submitted meanwhile\n * joins the back of that queue, so a failed message returns to the front ahead of everything after it.\n */\nasync function drainCompactionQueue(\n\tmode: InteractiveModeBase,\n\tdeliver: (message: CompactionQueuedMessage) => Promise<unknown>,\n\tlimit = Number.POSITIVE_INFINITY,\n): Promise<boolean> {\n\tfor (let delivered = 0; delivered < limit; delivered++) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) break;\n\t\ttry {\n\t\t\tawait deliver(message);\n\t\t} catch (error) {\n\t\t\treturnCompactionMessage(mode, message, error);\n\t\t\treturn false;\n\t\t}\n\t}\n\treturn true;\n}\n\n/**\n * Run leading extension commands, then start the first prompt. The rest of the batch stays in the\n * compaction queue until that prompt is accepted, so a rejected prompt is restored ahead of it.\n */\nasync function startCompactionQueuePrompt(mode: InteractiveModeBase): Promise<boolean> {\n\tconst firstPromptIndex = mode.compactionQueuedMessages.findIndex(\n\t\t(message) => !mode.isExtensionCommand(message.text),\n\t);\n\tconst leadingCommands = firstPromptIndex === -1 ? mode.compactionQueuedMessages.length : firstPromptIndex;\n\tconst ranCommands = await drainCompactionQueue(\n\t\tmode,\n\t\t(message) => mode.session.prompt(message.text),\n\t\tleadingCommands,\n\t);\n\tif (!ranCommands) return false;\n\tconst first = takeNextCompactionMessage(mode);\n\tif (!first) return false;\n\tconst refused = await promptUntilAccepted(mode, first);\n\tif (refused === undefined) return true;\n\treturnCompactionMessage(mode, first, refused.error);\n\treturn false;\n}\n\nasync function promptUntilAccepted(\n\tmode: InteractiveModeBase,\n\tmessage: CompactionQueuedMessage,\n\tonAccepted?: (disposition: PromptDisposition | undefined) => void,\n): Promise<{ error: unknown } | undefined> {\n\tlet accept!: (accepted: boolean) => void;\n\tconst accepted = new Promise<boolean>((resolve) => {\n\t\taccept = resolve;\n\t});\n\tconst prompt = mode.session.prompt(message.text, {\n\t\tstreamingBehavior: message.mode,\n\t\tpreflightResult: (success, disposition) => {\n\t\t\tif (success) onAccepted?.(disposition);\n\t\t\taccept(success);\n\t\t},\n\t});\n\tprompt.then(\n\t\t() => accept(true),\n\t\t(error: unknown) => accept(isRpcRequestAcceptedFailure(error)),\n\t);\n\tif (await accepted) {\n\t\tprompt.catch((error) => showCompactionQueueError(mode, error));\n\t\treturn undefined;\n\t}\n\treturn {\n\t\terror: await prompt.then(\n\t\t\t() => undefined,\n\t\t\t(error: unknown) => error,\n\t\t),\n\t};\n}\n\nasync function sendHeldInput(mode: InteractiveModeBase): Promise<void> {\n\twhile (mode.compactionQueuedMessages.length > 0) {\n\t\tconst message = takeNextCompactionMessage(mode);\n\t\tif (!message) return;\n\t\tconst echoed = !message.text.startsWith(\"/\");\n\t\tif (echoed) mode.renderDeferredUserInput(message.text);\n\t\tconst shownBefore = mode.userMessagesShownBySession;\n\t\tconst refused = await promptUntilAccepted(\n\t\t\tmode,\n\t\t\tmessage,\n\t\t\techoed\n\t\t\t\t? (disposition) => {\n\t\t\t\t\t\tif (disposition === \"queued\" || disposition === \"handled\")\n\t\t\t\t\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t\t\t\t\t\tif (disposition === \"started\") mode.expectStartedUserInput(message.text, shownBefore);\n\t\t\t\t\t}\n\t\t\t\t: undefined,\n\t\t);\n\t\tif (refused !== undefined) {\n\t\t\tif (echoed) mode.discardDeferredRenderedUserInput(message.text);\n\t\t\treturnCompactionMessage(mode, message, refused.error);\n\t\t\treturn;\n\t\t}\n\t\t// #5135: a run that repeats input the chat already shows as unsaved shows no message of its own.\n\t\tif (\n\t\t\techoed &&\n\t\t\tmode.startedDeferredUserInput === message.text &&\n\t\t\tmode.deferredRenderedUserInputs?.includes(message.text) === true\n\t\t)\n\t\t\tmode.discardDeferredRenderedUserInput(message.text);\n\t}\n}\n\nInteractiveModeBase.prototype.flushPendingBashComponents = function (this: InteractiveModeBase): void {\n\tfor (const component of this.pendingBashComponents) {\n\t\tthis.pendingMessagesContainer.removeChild(component);\n\t\tthis.chatContainer.addChild(component);\n\t}\n\tthis.pendingBashComponents = [];\n};\n\n/** `count` queued message(s), with the verb agreeing. */\nfunction queuedMessagesPhrase(count: number): string {\n\treturn count === 1 ? \"1 queued message\" : `${count} queued messages`;\n}\n\n/** The notice the main chat shows when a lost engine's queued messages come back to its editor. */\nexport function engineLossRestoredNotice(count: number): string {\n\treturn `Engine restarted; ${queuedMessagesPhrase(count)} ${count === 1 ? \"wasn't\" : \"weren't\"} sent and ${count === 1 ? \"is\" : \"are\"} back in the editor`;\n}\n\n/** What a subagent had queued, or had on its way, when the engine that runs it was lost. */\nexport interface LostSubagentQueue {\n\treadonly agent: string;\n\treadonly steering: readonly string[];\n\treadonly followUp: readonly string[];\n}\n\n/** The notice listing, in full and in order, what a subagent had queued when the engine was lost. */\nexport function engineLossSubagentNotice(queue: LostSubagentQueue): string | undefined {\n\tconst messages = [...queue.steering, ...queue.followUp];\n\tif (messages.length === 0) return undefined;\n\tconst verb = messages.length === 1 ? \"wasn't\" : \"weren't\";\n\treturn [\n\t\t`Engine restarted; ${queuedMessagesPhrase(messages.length)} to ${queue.agent} ${verb} sent:`,\n\t\t...messages,\n\t].join(\"\\n\");\n}\n\nfunction textOfUserMessage(content: unknown): string | undefined {\n\tif (typeof content === \"string\") return content;\n\tif (!Array.isArray(content)) return undefined;\n\treturn content\n\t\t.flatMap((part: { type?: unknown; text?: unknown }) =>\n\t\t\tpart.type === \"text\" && typeof part.text === \"string\" ? [part.text] : [],\n\t\t)\n\t\t.join(\"\");\n}\n\n/** The user messages `messages` holds, as text. */\nfunction userMessageTexts(messages: readonly { readonly role: string; readonly content?: unknown }[]): string[] {\n\treturn messages.flatMap((message) => {\n\t\tconst text = message.role === \"user\" ? textOfUserMessage(message.content) : undefined;\n\t\treturn text === undefined ? [] : [text];\n\t});\n}\n\n/** `after` without one copy of each text of `before`: what was added. */\nfunction withoutEach(after: readonly string[], before: readonly string[]): string[] {\n\tconst remaining = new Map<string, number>();\n\tfor (const text of before) remaining.set(text, (remaining.get(text) ?? 0) + 1);\n\treturn after.filter((text) => {\n\t\tconst count = remaining.get(text) ?? 0;\n\t\tif (count === 0) return true;\n\t\tremaining.set(text, count - 1);\n\t\treturn false;\n\t});\n}\n\n/**\n * An isolated engine that is lost and replaced takes its queue with it. The messages the main chat showed as queued\n * come back to its editor, as Alt+Up would restore them, with a notice, unless the replacement's history shows the\n * lost engine delivered them. (What a shown subagent had queued is listed by `attachLostAgentQueueNotices`.) Nothing is\n * sent again. A deliberate replacement or stop changes nothing.\n */\nInteractiveModeBase.prototype.attachSteeringEngineRecovery = function (this: InteractiveModeBase): () => void {\n\tconst runtime = this.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\t/** The user messages the chat knew when the engine was lost, while its replacement is pending. */\n\tlet knownAtLoss: string[] | undefined;\n\tconst stopEnded = runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tmainSteering(this).loseTarget();\n\t\truntime.discardLostQueue();\n\t\tknownAtLoss ??= userMessageTexts(this.session.messages);\n\t\tthis.updatePendingMessagesDisplay();\n\t\tthis.ui.requestRender();\n\t});\n\tconst stopRecovered = runtime.onEngineRecovered((replaced) => {\n\t\tconst known = knownAtLoss;\n\t\tknownAtLoss = undefined;\n\t\tif (known === undefined) return;\n\t\tvoid (async () => {\n\t\t\tlet delivered: string[] = [];\n\t\t\tif (replaced) {\n\t\t\t\ttry {\n\t\t\t\t\tdelivered = withoutEach(await runtime.engineUserMessages(), known);\n\t\t\t\t} catch {\n\t\t\t\t\t// The replacement could not say what it holds: give everything back, nothing is resent.\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst messages = mainSteering(this).recoverTarget(delivered);\n\t\t\tif (messages === undefined) return;\n\t\t\t// Main's prompt, whatever the screen shows by the time the replacement answers.\n\t\t\tconst prompt = promptHandle(this, \"main\");\n\t\t\tprompt.setText(combineQueuedMessagesForEditor(messages, prompt.getExpandedText()));\n\t\t\tthis.updatePendingMessagesDisplay();\n\t\t\tthis.showWarning(engineLossRestoredNotice(messages.length));\n\t\t\tthis.ui.requestRender();\n\t\t})();\n\t});\n\treturn () => {\n\t\tstopEnded();\n\t\tstopRecovered();\n\t};\n};\n"]}
@@ -1,10 +1,11 @@
1
1
  import type { AssistantMessage } from "@bastani/atomic-ai/compat";
2
2
  import type { ToolGroupRole } from "./components/tool-block.ts";
3
- import { type ToolGroupMemberState } from "./components/tool-group-tracker.ts";
3
+ import { type ToolGroupHead, type ToolGroupMemberState } from "./components/tool-group-tracker.ts";
4
4
  import { InteractiveModeBase } from "./interactive-mode-base.ts";
5
5
  import { type Component } from "./interactive-mode-deps.ts";
6
6
  interface GroupedToolComponent {
7
7
  setGroupRole(role: ToolGroupRole): void;
8
+ setGroupHead?(head: ToolGroupHead | undefined): void;
8
9
  }
9
10
  export declare function breakMainToolGroup(mode: InteractiveModeBase): void;
10
11
  export declare function endMainToolTurn(mode: InteractiveModeBase): void;
@@ -13,6 +14,22 @@ export declare function endMainAssistantMessage(mode: InteractiveModeBase, messa
13
14
  export declare function trackMainToolComponent(mode: InteractiveModeBase, toolCallId: string, toolName: string, component: Component & GroupedToolComponent, breakBefore?: boolean): void;
14
15
  export declare function settleMainTool(mode: InteractiveModeBase, toolCallId: string, state: ToolGroupMemberState): void;
15
16
  export declare function observeMainToolStart(mode: InteractiveModeBase, toolCallId: string): number;
17
+ /** Follows one sent message's echo through `StartedRunEcho` (see there). */
18
+ export interface StartedRunEchoFollower {
19
+ /** The session answered the prompt: `started` when it started a run for this message. */
20
+ answer(started: boolean): void;
21
+ /** The send ended without a run to wait for (failed, or not sent): stop following, leaving the echo alone. */
22
+ close(): void;
23
+ }
24
+ /**
25
+ * Follow the echo of `text` from just before it is sent until the run it started shows the message (the echo stays as
26
+ * that message) or gets past it without one (the echo goes, #5135), whichever order the answer and the run's events
27
+ * arrive in. A run that settles or loses its engine before it starts drops the echo, and the working row the send
28
+ * showed when `sendShowsWorkingRow`, as the answer alone used to.
29
+ */
30
+ export declare function followStartedRunEcho(mode: InteractiveModeBase, text: string, options: {
31
+ readonly sendShowsWorkingRow: boolean;
32
+ }): StartedRunEchoFollower;
16
33
  export declare function clearChatForRerender(mode: InteractiveModeBase): void;
17
34
  export {};
18
35
  //# sourceMappingURL=interactive-render-chat.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,2BAA2B,CAAC;AAyDzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAuB,KAAK,oBAAoB,EAAoB,MAAM,oCAAoC,CAAC;AAEtH,OAAO,EAAqB,mBAAmB,EAA0B,MAAM,4BAA4B,CAAC;AAC5G,OAAO,EAUN,KAAK,SAAS,EAsBd,MAAM,4BAA4B,CAAC;AAoHpC,UAAU,oBAAoB;IAC7B,YAAY,CAAC,IAAI,EAAE,aAAa,GAAG,IAAI,CAAC;CACxC;AAwCD,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAKlE;AASD,wBAAgB,eAAe,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAG/D;AAED,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,WAAW,CAAC,MAAM,CAAC,CAE5G;AAED,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAGlG;AAED,wBAAgB,sBAAsB,CACrC,IAAI,EAAE,mBAAmB,EACzB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,SAAS,GAAG,oBAAoB,EAC3C,WAAW,UAAQ,GACjB,IAAI,CASN;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,oBAAoB,GAAG,IAAI,CAI/G;AAED,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAK1F;AA6qCD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAOpE"}
1
+ {"version":3,"file":"interactive-render-chat.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive/interactive-render-chat.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAS,MAAM,2BAA2B,CAAC;AAyDzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAEN,KAAK,aAAa,EAClB,KAAK,oBAAoB,EAGzB,MAAM,oCAAoC,CAA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,EAAE,MAAM,EACZ,OAAO,EAAE;IAAE,QAAQ,CAAC,mBAAmB,EAAE,OAAO,CAAA;CAAE,GAChD,sBAAsB,CAuDxB;AAgiCD,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,GAAG,IAAI,CAOpE"}
@@ -26,7 +26,8 @@ import { CustomEntryComponent } from "./components/custom-entry.js";
26
26
  import { createMarkdownTransform } from "./components/markdown-transform.js";
27
27
  import { createMermaidMarkdownTransformer } from "./components/mermaid.js";
28
28
  import { ThemedText } from "./components/themed-text.js";
29
- import { assistantCallBreaks, ToolGroupTracker } from "./components/tool-group-tracker.js";
29
+ import { assistantCallBreaks, ToolGroupTracker, } from "./components/tool-group-tracker.js";
30
+ import { isClickExpandableBlock } from "./components/transcript-block-clicks.js";
30
31
  import { appendNewChildrenBeforeAttachedChild } from "./interactive-child-ordering.js";
31
32
  import { countChatMessages, InteractiveModeBase, isChatMessageComponent } from "./interactive-mode-base.js";
32
33
  import { APP_NAME, AssistantMessageComponent, addChatTranscriptEntry, BashExecutionComponent, BranchSummaryMessageComponent, CompactionBoundaryMessageComponent, Container, CustomMessageComponent, chatEntriesFromAgentMessages, getChangelogPath, hasTrustRequiringProjectResourcesAsync, Markdown, parseSkillBlock, preloadChangelog, recordTimeSinceReset, renderChatMessageEntry, SkillInvocationMessageComponent, Spacer, Text, ToolExecutionComponent, theme, UserMessageComponent, } from "./interactive-mode-deps.js";
@@ -34,6 +35,7 @@ import { holdCompactionWidgets, installSavedChatHistory, noteShownContext, parkV
34
35
  import { followChosenExpansion, SavedPageCallsBuilder } from "./interactive-saved-tool-calls.js";
35
36
  import { StartupChatContainer, trackChatHistoryBuild } from "./interactive-startup-chat-container.js";
36
37
  import { refreshInteractiveTasks } from "./interactive-task-projection.js";
38
+ import { nextStartedRunEcho, STARTED_RUN_ECHO_SENT, startedRunEchoEvent, } from "./started-run-echo.js";
37
39
  function countDroppedThinkingBlocks(message) {
38
40
  return (message.diagnostics ?? []).reduce((count, diagnostic) => {
39
41
  if (diagnostic.type !== "anthropic_input_transformations")
@@ -117,6 +119,25 @@ InteractiveModeBase.prototype.showStatus = function (message, persist = false) {
117
119
  this.ui.requestRender();
118
120
  };
119
121
  const echoReadEpochs = new WeakMap();
122
+ /**
123
+ * Gives `component`, and `entry` when the row draws one, its place in a group of calls. A call folded into a group is
124
+ * told the group's first row too, without keeping it alive, so that it is drawn on its own while a click has left
125
+ * the two at different expansions.
126
+ */
127
+ function groupedRowSink(component, entry) {
128
+ return (role, head) => {
129
+ if (entry)
130
+ entry.groupRole = role;
131
+ component.setGroupRole(role);
132
+ const headRow = head;
133
+ if (role.kind !== "hidden" || !isClickExpandableBlock(headRow)) {
134
+ component.setGroupHead?.(undefined);
135
+ return;
136
+ }
137
+ const row = new WeakRef(headRow);
138
+ component.setGroupHead?.({ isExpanded: () => row.deref()?.isExpanded() });
139
+ };
140
+ }
120
141
  const mainToolGroupings = new WeakMap();
121
142
  function mainToolGrouping(mode) {
122
143
  let grouping = mainToolGroupings.get(mode);
@@ -172,7 +193,7 @@ export function trackMainToolComponent(mode, toolCallId, toolName, component, br
172
193
  if (breakBefore ||
173
194
  (grouping.lastMember !== undefined && hasRowsSinceLastMember(mode.chatContainer, grouping.lastMember, component)))
174
195
  grouping.tracker.break();
175
- grouping.tracker.append(toolCallId, toolName, "pending", (role) => component.setGroupRole(role));
196
+ grouping.tracker.append(toolCallId, toolName, "pending", groupedRowSink(component), component);
176
197
  grouping.lastMember = component;
177
198
  }
178
199
  export function settleMainTool(mode, toolCallId, state) {
@@ -204,10 +225,7 @@ function renderGroupedChatEntries(mode, entries, onEntry) {
204
225
  grouping.carriedBreak = false;
205
226
  const component = mode.addRenderedChatEntry(entry);
206
227
  if (entry.kind === "tool" && isGroupedToolComponent(component)) {
207
- grouping.tracker.bind(entry.toolCallId, (role) => {
208
- entry.groupRole = role;
209
- component.setGroupRole(role);
210
- });
228
+ grouping.tracker.bind(entry.toolCallId, groupedRowSink(component, entry), component);
211
229
  grouping.lastMember = component;
212
230
  }
213
231
  onEntry(entry, component);
@@ -312,6 +330,71 @@ InteractiveModeBase.prototype.expectStartedUserInput = function (text, shownBefo
312
330
  else
313
331
  this.startedDeferredUserInput = text;
314
332
  };
333
+ /**
334
+ * Follow the echo of `text` from just before it is sent until the run it started shows the message (the echo stays as
335
+ * that message) or gets past it without one (the echo goes, #5135), whichever order the answer and the run's events
336
+ * arrive in. A run that settles or loses its engine before it starts drops the echo, and the working row the send
337
+ * showed when `sendShowsWorkingRow`, as the answer alone used to.
338
+ */
339
+ export function followStartedRunEcho(mode, text, options) {
340
+ let state = STARTED_RUN_ECHO_SENT;
341
+ const stops = [];
342
+ const stop = () => {
343
+ for (const release of stops.splice(0))
344
+ release();
345
+ };
346
+ let watchingEngine = false;
347
+ const apply = (event) => {
348
+ if (state.kind === "settled")
349
+ return;
350
+ state = nextStartedRunEcho(state, event);
351
+ if (state.kind === "awaiting-run-message" && !watchingEngine) {
352
+ // Only a run answered as started waits on its engine, and is lost with it.
353
+ watchingEngine = true;
354
+ const runtime = mode.runtimeHost;
355
+ if (runtime instanceof IsolatedInteractiveRuntime)
356
+ stops.push(runtime.onGenerationEnded(() => apply({ type: "lost" })));
357
+ }
358
+ if (state.kind !== "settled")
359
+ return;
360
+ stop();
361
+ if (state.echo === "left")
362
+ return;
363
+ if (mode.deferredRenderedUserInputs?.includes(text) === true)
364
+ mode.discardDeferredRenderedUserInput(text);
365
+ // What the send's own end does when no run started: the working row it showed has no run to end it.
366
+ if (state.echo === "never-ran" &&
367
+ options.sendShowsWorkingRow &&
368
+ !mode.session.isStreaming &&
369
+ mode.workingRunMeter.snapshot() === undefined) {
370
+ mode.workingRunMeter.stop();
371
+ mode.stopWorkingLoader();
372
+ }
373
+ };
374
+ // A run the host saw start and not settle before the send ends before this message's run can start: until it
375
+ // settles, its events are not this run's. A user message shown meanwhile still counts, as it always did.
376
+ let earlierRun = mode.session.turnStartedAt !== undefined;
377
+ stops.push(mode.session.subscribe((event) => {
378
+ if (earlierRun && (event.type === "agent_settled" || event.type === "session_released")) {
379
+ earlierRun = false;
380
+ return;
381
+ }
382
+ const echoEvent = startedRunEchoEvent(event);
383
+ if (echoEvent && (!earlierRun || echoEvent.type === "user-message"))
384
+ apply(echoEvent);
385
+ }));
386
+ return {
387
+ answer: (started) => {
388
+ // Everything of an earlier run came before this answer.
389
+ earlierRun = false;
390
+ apply({ type: "answer", started });
391
+ },
392
+ close: () => {
393
+ if (state.kind === "awaiting-answer")
394
+ stop();
395
+ },
396
+ };
397
+ }
315
398
  /** Show a user message from the session: in place of its echo, or of the echo of the run it started, or as new. */
316
399
  InteractiveModeBase.prototype.showSessionUserMessage = function (message) {
317
400
  const text = this.getUserMessageText(message);
@@ -868,10 +951,7 @@ function addTranscriptStep(mode, step, latest = true, saved = false) {
868
951
  const component = adopted ?? kept ?? mode.addRenderedChatEntry(entry);
869
952
  if (!saved && entry.kind === "tool" && isGroupedToolComponent(component)) {
870
953
  const grouping = mainToolGrouping(mode);
871
- grouping.tracker.bind(entry.toolCallId, (role) => {
872
- entry.groupRole = role;
873
- component.setGroupRole(role);
874
- });
954
+ grouping.tracker.bind(entry.toolCallId, groupedRowSink(component, entry), component);
875
955
  if (latest)
876
956
  grouping.lastMember = component;
877
957
  }