@bastani/atomic 0.10.0 → 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 (233) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/dist/builtin/intercom/package.json +1 -1
  3. package/dist/builtin/mcp/package.json +1 -1
  4. package/dist/builtin/subagents/CHANGELOG.md +12 -0
  5. package/dist/builtin/subagents/package.json +1 -1
  6. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +33 -3
  7. package/dist/builtin/web-access/package.json +1 -1
  8. package/dist/core/agent-session-events.d.ts.map +1 -1
  9. package/dist/core/agent-session-events.js +21 -6
  10. package/dist/core/agent-session-events.js.map +1 -1
  11. package/dist/core/lifecycle-timings.d.ts +6 -0
  12. package/dist/core/lifecycle-timings.d.ts.map +1 -1
  13. package/dist/core/lifecycle-timings.js +12 -0
  14. package/dist/core/lifecycle-timings.js.map +1 -1
  15. package/dist/core/queued-message-delivery.d.ts +41 -0
  16. package/dist/core/queued-message-delivery.d.ts.map +1 -0
  17. package/dist/core/queued-message-delivery.js +48 -0
  18. package/dist/core/queued-message-delivery.js.map +1 -0
  19. package/dist/core/storage/node-sqlite-thread.d.ts +64 -0
  20. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -0
  21. package/dist/core/storage/node-sqlite-thread.js +326 -0
  22. package/dist/core/storage/node-sqlite-thread.js.map +1 -0
  23. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  24. package/dist/core/storage/node-sqlite.js +230 -104
  25. package/dist/core/storage/node-sqlite.js.map +1 -1
  26. package/dist/core/tasks/agent-panel-source.d.ts +5 -0
  27. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  28. package/dist/core/tasks/agent-panel-source.js +1 -1
  29. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  30. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +8 -1
  31. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  32. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  33. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +11 -5
  34. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  35. package/dist/modes/interactive/agent-view/agent-view-switcher.js +17 -5
  36. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  37. package/dist/modes/interactive/agent-view/contracts.d.ts +5 -0
  38. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  39. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  40. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  41. package/dist/modes/interactive/agent-view/install.js +6 -3
  42. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  43. package/dist/modes/interactive/agent-view/local-port.d.ts +5 -0
  44. package/dist/modes/interactive/agent-view/local-port.d.ts.map +1 -1
  45. package/dist/modes/interactive/agent-view/local-port.js +8 -0
  46. package/dist/modes/interactive/agent-view/local-port.js.map +1 -1
  47. package/dist/modes/interactive/agent-view/remote-port.d.ts +4 -1
  48. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  49. package/dist/modes/interactive/agent-view/remote-port.js +22 -8
  50. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  51. package/dist/modes/interactive/agent-view/transcript-slot.d.ts +9 -0
  52. package/dist/modes/interactive/agent-view/transcript-slot.d.ts.map +1 -1
  53. package/dist/modes/interactive/agent-view/transcript-slot.js +141 -1
  54. package/dist/modes/interactive/agent-view/transcript-slot.js.map +1 -1
  55. package/dist/modes/interactive/components/agent-panel.d.ts +6 -0
  56. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  57. package/dist/modes/interactive/components/agent-panel.js +40 -10
  58. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  59. package/dist/modes/interactive/components/atomic-working-status.d.ts +15 -0
  60. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  61. package/dist/modes/interactive/components/atomic-working-status.js +51 -3
  62. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  63. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  64. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  65. package/dist/modes/interactive/components/bash-execution.js +5 -1
  66. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  67. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -0
  68. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  69. package/dist/modes/interactive/components/branch-summary-message.js +5 -1
  70. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  71. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  72. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  73. package/dist/modes/interactive/components/chat-message-renderer.js +17 -6
  74. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  75. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  76. package/dist/modes/interactive/components/chat-session-host-events.js +35 -4
  77. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  78. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-rendering.js +70 -13
  80. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  81. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +7 -0
  82. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  83. package/dist/modes/interactive/components/chat-session-host-runtime.js +25 -4
  84. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  85. package/dist/modes/interactive/components/chat-session-host-state.d.ts +41 -1
  86. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  87. package/dist/modes/interactive/components/chat-session-host-state.js +24 -3
  88. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  89. package/dist/modes/interactive/components/chat-session-host-steering.d.ts.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-steering.js +2 -1
  91. package/dist/modes/interactive/components/chat-session-host-steering.js.map +1 -1
  92. package/dist/modes/interactive/components/chat-session-host.d.ts +13 -1
  93. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  94. package/dist/modes/interactive/components/chat-session-host.js +20 -2
  95. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  96. package/dist/modes/interactive/components/chat-transcript.d.ts +15 -0
  97. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  98. package/dist/modes/interactive/components/chat-transcript.js +14 -1
  99. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  100. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  101. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  102. package/dist/modes/interactive/components/compaction-boundary-message.js +5 -1
  103. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  104. package/dist/modes/interactive/components/custom-entry.d.ts +2 -0
  105. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  106. package/dist/modes/interactive/components/custom-entry.js +5 -1
  107. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  108. package/dist/modes/interactive/components/custom-message.d.ts +2 -0
  109. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  110. package/dist/modes/interactive/components/custom-message.js +5 -1
  111. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  112. package/dist/modes/interactive/components/model-column.d.ts +96 -0
  113. package/dist/modes/interactive/components/model-column.d.ts.map +1 -0
  114. package/dist/modes/interactive/components/model-column.js +207 -0
  115. package/dist/modes/interactive/components/model-column.js.map +1 -0
  116. package/dist/modes/interactive/components/prompt-slot.d.ts +73 -0
  117. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -0
  118. package/dist/modes/interactive/components/prompt-slot.js +201 -0
  119. package/dist/modes/interactive/components/prompt-slot.js.map +1 -0
  120. package/dist/modes/interactive/components/queued-messages-view.d.ts +6 -3
  121. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  122. package/dist/modes/interactive/components/queued-messages-view.js +7 -4
  123. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  124. package/dist/modes/interactive/components/session-selector.d.ts +2 -0
  125. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  126. package/dist/modes/interactive/components/session-selector.js +4 -0
  127. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  128. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -0
  129. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  130. package/dist/modes/interactive/components/skill-invocation-message.js +5 -1
  131. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  132. package/dist/modes/interactive/components/task-board.d.ts +12 -3
  133. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  134. package/dist/modes/interactive/components/task-board.js +33 -17
  135. package/dist/modes/interactive/components/task-board.js.map +1 -1
  136. package/dist/modes/interactive/components/task-inspector.d.ts +6 -1
  137. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  138. package/dist/modes/interactive/components/task-inspector.js +27 -7
  139. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  140. package/dist/modes/interactive/components/task-row.d.ts +4 -0
  141. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  142. package/dist/modes/interactive/components/task-row.js +7 -1
  143. package/dist/modes/interactive/components/task-row.js.map +1 -1
  144. package/dist/modes/interactive/components/task-transcript-page.d.ts +5 -0
  145. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  146. package/dist/modes/interactive/components/task-transcript-page.js +25 -0
  147. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  148. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  149. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  150. package/dist/modes/interactive/components/tool-execution.js +19 -2
  151. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  152. package/dist/modes/interactive/components/tool-group-tracker.d.ts +20 -3
  153. package/dist/modes/interactive/components/tool-group-tracker.d.ts.map +1 -1
  154. package/dist/modes/interactive/components/tool-group-tracker.js +34 -7
  155. package/dist/modes/interactive/components/tool-group-tracker.js.map +1 -1
  156. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +14 -2
  157. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  158. package/dist/modes/interactive/components/transcript-block-clicks.js +23 -2
  159. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  160. package/dist/modes/interactive/interactive-agent-events.js +10 -2
  161. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  162. package/dist/modes/interactive/interactive-extension-runtime.d.ts +12 -1
  163. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  164. package/dist/modes/interactive/interactive-extension-runtime.js +37 -5
  165. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  166. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  167. package/dist/modes/interactive/interactive-input-handling.js +70 -46
  168. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  169. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  171. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  172. package/dist/modes/interactive/interactive-prompt-turn.js +17 -9
  173. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  174. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  175. package/dist/modes/interactive/interactive-queueing.js +2 -1
  176. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  177. package/dist/modes/interactive/interactive-render-chat.d.ts +18 -1
  178. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  179. package/dist/modes/interactive/interactive-render-chat.js +90 -10
  180. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  181. package/dist/modes/interactive/interactive-session-routing.js +2 -0
  182. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  183. package/dist/modes/interactive/interactive-task-projection.js +2 -2
  184. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  185. package/dist/modes/interactive/screen-hold.d.ts +41 -0
  186. package/dist/modes/interactive/screen-hold.d.ts.map +1 -0
  187. package/dist/modes/interactive/screen-hold.js +80 -0
  188. package/dist/modes/interactive/screen-hold.js.map +1 -0
  189. package/dist/modes/interactive/started-run-echo.d.ts +66 -0
  190. package/dist/modes/interactive/started-run-echo.d.ts.map +1 -0
  191. package/dist/modes/interactive/started-run-echo.js +75 -0
  192. package/dist/modes/interactive/started-run-echo.js.map +1 -0
  193. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -0
  194. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  195. package/dist/modes/interactive-engine/engine-custom-ui.js +25 -1
  196. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  197. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  198. package/dist/modes/interactive-engine/engine-quit-intent.js +3 -0
  199. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  200. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  201. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  202. package/dist/modes/interactive-engine/protocol.js +7 -1
  203. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  204. package/dist/modes/interactive-engine/remote-component.d.ts +10 -2
  205. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  206. package/dist/modes/interactive-engine/remote-component.js +19 -2
  207. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  208. package/dist/modes/interactive-engine/remote-renderer.d.ts +10 -0
  209. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  210. package/dist/modes/interactive-engine/remote-renderer.js +24 -4
  211. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  212. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts +50 -0
  213. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts.map +1 -0
  214. package/dist/modes/interactive-engine/transcript-frame-layout.js +95 -0
  215. package/dist/modes/interactive-engine/transcript-frame-layout.js.map +1 -0
  216. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  217. package/dist/modes/rpc/agent-panel-bridge.js +16 -0
  218. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  219. package/dist/modes/rpc/agent-view-engine-registry.d.ts.map +1 -1
  220. package/dist/modes/rpc/agent-view-engine-registry.js +36 -1
  221. package/dist/modes/rpc/agent-view-engine-registry.js.map +1 -1
  222. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  223. package/dist/modes/rpc/agent-view-rpc-panel.js +5 -1
  224. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  225. package/dist/modes/rpc/task-ui-bridge.js +1 -1
  226. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  227. package/docs/background-tasks.md +1 -1
  228. package/docs/development.md +2 -0
  229. package/docs/extensions/authoring.md +1 -1
  230. package/docs/keybindings.md +2 -2
  231. package/docs/storage.md +1 -0
  232. package/npm-shrinkwrap.json +49 -49
  233. package/package.json +6 -6
@@ -1 +1 @@
1
- {"version":3,"file":"remote-component.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,gBAAgB,GAOhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAS9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAwBvE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AASjD,MAAM,eAAe;IACpB,cAAc,CAAU;IAChB,aAAa,CAAk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EAAE,MAA6C;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrD,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,QAAQ,MAAM,EAAE,CAAC;YAChB,KAAK,OAAO;gBACX,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM;YACP,KAAK,MAAM;gBACV,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACvB,MAAM;YACP,KAAK,MAAM;gBACV,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACxB,MAAM;YACP,KAAK,SAAS;gBACb,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,MAAM;QACR,CAAC;IACF,CAAC;CACD","sourcesContent":["import {\n\ttype Component,\n\tisHintActivation,\n\ttype OverlayHandle,\n\ttype OverlayOptions,\n\ttype TUI,\n\ttype TuiMode,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n} from \"@bastani/atomic-tui\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { WidgetScrollRequest, WidgetScrollState } from \"../../core/extensions/ui-types.js\";\nimport { copyToClipboard } from \"../../utils/clipboard.js\";\nimport { isSingleLeftClick } from \"../interactive/components/single-click.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type {\n\tEngineBlockedStatus,\n\tEngineHostRenderSettings,\n\tInteractiveEngineMessage,\n\tJsonValue,\n\tSerializableOverlayOptions,\n} from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\nimport { TerminalModeController } from \"./terminal-mode-controller.ts\";\n\nexport type RemoteComponentRuntime = Pick<\n\tIsolatedInteractiveRuntime,\n\t\"onEngineMessage\" | \"onGenerationEnded\" | \"sendEngineCommand\"\n>;\n\nexport type RemoteComponentUI = Pick<ExtensionUIContext, \"custom\" | \"requestRender\" | \"setWidget\" | \"onWidgetRelease\">;\n\ninterface MountedRemoteComponent {\n\tcomponent: RemoteComponent;\n\tdone: (result: JsonValue | undefined) => void;\n\tengineDone: boolean;\n\t/** The extension declared that this component binds Ctrl+C itself. */\n\thandlesCtrlC: boolean;\n\t/** The extension declared that this component claims internal UI actions. */\n\thandlesInternalUiAction: boolean;\n\thandle?: OverlayHandle;\n\twidgetKey?: string;\n\tunsubscribeWidgetRelease?: () => void;\n\t/** A viewed subagent's transcript (`placement: \"transcript\"`), drawn by the host's transcript area. */\n\ttranscript?: RemoteTranscriptMount;\n}\n\n/**\n * A stalled engine must not make fullscreen input wait forever. A timed-out\n * reply is treated as unhandled and lets the viewport process the key.\n */\nexport const REMOTE_INPUT_REPLY_TIMEOUT_MS = 250;\n\ninterface PendingInput {\n\tresolve: (handled: boolean | undefined) => void;\n\ttimer: ReturnType<typeof setTimeout>;\n\t/** The frame requested with the key: a handled key answers once that frame is here, so one paint shows it. */\n\treadonly frameRequestId: number | undefined;\n}\n\nclass RemoteComponent implements Component {\n\thostColorDepth?: number;\n\tprivate scrollRequest: WidgetScrollRequest | undefined;\n\tgetScrollRequest(): WidgetScrollRequest | undefined {\n\t\treturn this.scrollRequest;\n\t}\n\tonScroll(state: WidgetScrollState): void {\n\t\tif (!this.disposed)\n\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_scroll\", componentId: this.componentId, state });\n\t}\n\twantsKeyRelease = true;\n\treadonly handlesInternalUiAction: boolean;\n\tprivate lines: string[] = [];\n\tprivate width = 0;\n\tprivate rows = 0;\n\tprivate hostMode: TuiMode | undefined;\n\tprivate requestId = 0;\n\tprivate inputRequestId = 0;\n\tprivate appliedRequestId = 0;\n\t/** The engine's number for the frame in `lines`, and for the frame the last `render` returned. */\n\tprivate frame: number | undefined;\n\tprivate paintedFrame: number | undefined;\n\t/** What the engine component drew on each row of `lines`, and of the frame the last `render` returned. */\n\tprivate rowKeys: readonly string[] | undefined;\n\tprivate paintedRowKeys: readonly string[] | undefined;\n\t/** The number of the last click forwarded to the engine. */\n\tprivate clickId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly pendingInputs = new Map<number, PendingInput>();\n\t/** Handled keys whose frame has not arrived yet. */\n\tprivate readonly answeredInputs = new Set<number>();\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\n\tprivate readonly componentId: string;\n\tprivate readonly runtime: RemoteComponentRuntime;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly paintNow: () => void;\n\tprivate readonly getRows: () => number;\n\tprivate readonly getHostMode: () => TuiMode;\n\tprivate readonly getRenderSettings: () => EngineHostRenderSettings | undefined;\n\tprivate renderSettingsKey = \"\";\n\t/** The frame request sent with the latest key; the frame answering it paints at once, as a local key does. */\n\tprivate keyFrameRequestId = 0;\n\n\tconstructor(\n\t\tcomponentId: string,\n\t\truntime: RemoteComponentRuntime,\n\t\trequestRender: () => void,\n\t\tgetRows: () => number,\n\t\tgetHostMode: () => TuiMode,\n\t\thandlesInternalUiAction = false,\n\t\tgetRenderSettings: () => EngineHostRenderSettings | undefined = () => undefined,\n\t\tpaintNow: () => void = requestRender,\n\t) {\n\t\tthis.componentId = componentId;\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.paintNow = paintNow;\n\t\tthis.getRows = getRows;\n\t\tthis.getHostMode = getHostMode;\n\t\tthis.handlesInternalUiAction = handlesInternalUiAction;\n\t\tthis.getRenderSettings = getRenderSettings;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst rows = this.getRows();\n\t\t// A renderer switch in the host changes the mode the engine component lays itself out for.\n\t\tconst hostMode = this.getHostMode();\n\t\tconst renderSettings = this.getRenderSettings();\n\t\tconst renderSettingsKey = renderSettingsCacheKey(renderSettings);\n\t\tif (\n\t\t\t!this.disposed &&\n\t\t\t(this.dirty ||\n\t\t\t\twidth !== this.width ||\n\t\t\t\trows !== this.rows ||\n\t\t\t\thostMode !== this.hostMode ||\n\t\t\t\trenderSettingsKey !== this.renderSettingsKey)\n\t\t) {\n\t\t\tthis.requestFrame(width, rows, hostMode, renderSettings, renderSettingsKey);\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\tthis.paintedFrame = this.frame;\n\t\tthis.paintedRowKeys = this.rowKeys;\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\t/** What the engine component drew on `row` of the frame this host painted, when it names its rows. */\n\tpaintedRowKey(row: number): string | undefined {\n\t\treturn this.paintedRowKeys?.[row];\n\t}\n\n\t/**\n\t * Forward a single click to the engine component, at its row and column there. Presses, drags and multi-clicks stay\n\t * with the host's text selection. The click is numbered: once it stays a single click, the host settles that number,\n\t * and what the component left for that moment runs.\n\t */\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tif (this.disposed || !isSingleLeftClick(event) || this.paintedFrame === undefined) return undefined;\n\t\tconst rowKey = this.paintedRowKeys?.[Math.floor(event.y)];\n\t\tconst clickId = ++this.clickId;\n\t\tthis.runtime.sendEngineCommand({\n\t\t\ttype: \"engine_custom_click\",\n\t\t\tcomponentId: this.componentId,\n\t\t\tframe: this.paintedFrame,\n\t\t\t...(rowKey === undefined ? {} : { rowKey }),\n\t\t\tclickId,\n\t\t\tcancelsClicks: true,\n\t\t\tx: Math.max(0, Math.floor(event.x)),\n\t\t\ty: Math.max(0, Math.floor(event.y)),\n\t\t\twidth: Math.max(0, Math.floor(event.width)),\n\t\t\theight: Math.max(0, Math.floor(event.height)),\n\t\t});\n\t\tconst finish = (type: \"engine_custom_click_settle\" | \"engine_custom_click_cancel\") => {\n\t\t\tif (this.disposed) return;\n\t\t\ttry {\n\t\t\t\tthis.runtime.sendEngineCommand({ type, componentId: this.componentId, clickId });\n\t\t\t} catch {\n\t\t\t\t// An engine that went away takes no click; the host keeps its frame.\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\thandled: true,\n\t\t\twhenSingleClick: () => finish(\"engine_custom_click_settle\"),\n\t\t\tonSingleClickCancel: () => finish(\"engine_custom_click_cancel\"),\n\t\t};\n\t}\n\n\thandleInput(data: string): Promise<boolean | undefined> {\n\t\tif (this.disposed) return Promise.resolve(undefined);\n\t\tconst requestId = ++this.inputRequestId;\n\t\tconst frameRequestId = this.width > 0 ? this.requestId + 1 : undefined;\n\t\tconst result = new Promise<boolean | undefined>((resolve) => {\n\t\t\tconst timer = setTimeout(() => this.resolveInput(requestId, false), REMOTE_INPUT_REPLY_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t\tthis.pendingInputs.set(requestId, { resolve, timer, frameRequestId });\n\t\t});\n\t\ttry {\n\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\ttype: \"engine_custom_input\",\n\t\t\t\tcomponentId: this.componentId,\n\t\t\t\trequestId,\n\t\t\t\tdata,\n\t\t\t\t...(isHintActivation() ? { hint: true as const } : {}),\n\t\t\t});\n\t\t} catch {\n\t\t\tthis.resolveInput(requestId, false);\n\t\t}\n\t\t// Engine commands are delivered in order, so a frame requested now is\n\t\t// rendered by the child only AFTER it has applied this input. Asking for\n\t\t// it with the key, rather than on the next paced host render, keeps the\n\t\t// keypress at a single round trip, and repaints components that never\n\t\t// self-invalidate.\n\t\tif (frameRequestId !== undefined) {\n\t\t\tconst renderSettings = this.getRenderSettings();\n\t\t\tthis.keyFrameRequestId = frameRequestId;\n\t\t\tthis.requestFrame(\n\t\t\t\tthis.width,\n\t\t\t\tthis.getRows(),\n\t\t\t\tthis.getHostMode(),\n\t\t\t\trenderSettings,\n\t\t\t\trenderSettingsCacheKey(renderSettings),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.dirty = true;\n\t\t\tthis.requestRender();\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate requestFrame(\n\t\twidth: number,\n\t\trows: number,\n\t\thostMode: TuiMode,\n\t\trenderSettings: EngineHostRenderSettings | undefined,\n\t\trenderSettingsKey: string,\n\t): void {\n\t\tthis.width = width;\n\t\tthis.rows = rows;\n\t\tthis.hostMode = hostMode;\n\t\tthis.renderSettingsKey = renderSettingsKey;\n\t\tthis.dirty = false;\n\t\tthis.runtime.sendEngineCommand({\n\t\t\ttype: \"engine_custom_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\t...(this.requestId === 0 && this.hostColorDepth !== undefined ? { colorDepth: this.hostColorDepth } : {}),\n\t\t\trequestId: ++this.requestId,\n\t\t\twidth,\n\t\t\trows,\n\t\t\thostMode,\n\t\t\t...(renderSettings === undefined ? {} : { renderSettings }),\n\t\t});\n\t}\n\n\tresolveInput(requestId: number, handled: boolean | undefined): void {\n\t\tconst pending = this.pendingInputs.get(requestId);\n\t\tif (!pending) return;\n\t\tclearTimeout(pending.timer);\n\t\t// A handled key answers with the frame that shows it: resolving before it arrives would repaint the frame the\n\t\t// key has not reached, and the key's own frame would wait behind that paint.\n\t\tif (handled === true && pending.frameRequestId !== undefined && this.appliedRequestId < pending.frameRequestId) {\n\t\t\tpending.timer = setTimeout(() => this.settleInput(requestId, true), REMOTE_INPUT_REPLY_TIMEOUT_MS);\n\t\t\tpending.timer.unref?.();\n\t\t\tthis.answeredInputs.add(requestId);\n\t\t\treturn;\n\t\t}\n\t\tthis.settleInput(requestId, handled);\n\t}\n\n\tprivate settleInput(requestId: number, handled: boolean | undefined): void {\n\t\tconst pending = this.pendingInputs.get(requestId);\n\t\tif (!pending) return;\n\t\tthis.pendingInputs.delete(requestId);\n\t\tthis.answeredInputs.delete(requestId);\n\t\tclearTimeout(pending.timer);\n\t\tpending.resolve(handled);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.dirty = true;\n\t}\n\n\t/** Called with each frame the engine sends, once it is the one `render` returns. */\n\tonFrame: (() => void) | undefined;\n\n\t/** Ask for a frame of `width` x `rows` now, before the host lays the component out. */\n\tprime(width: number, rows: number): void {\n\t\tif (this.disposed) return;\n\t\tconst renderSettings = this.getRenderSettings();\n\t\tthis.requestFrame(width, rows, this.getHostMode(), renderSettings, renderSettingsCacheKey(renderSettings));\n\t}\n\n\tapplyFrame(\n\t\trequestId: number,\n\t\tlines: string[],\n\t\tscrollRequest?: WidgetScrollRequest,\n\t\tframe?: number,\n\t\trowKeys?: readonly string[],\n\t): void {\n\t\tif (this.disposed || requestId < this.appliedRequestId) return;\n\t\tthis.appliedRequestId = requestId;\n\t\tthis.lines = lines;\n\t\tthis.frame = frame;\n\t\tthis.rowKeys = rowKeys;\n\t\tthis.scrollRequest = scrollRequest;\n\t\tthis.onFrame?.();\n\t\tlet answeredKey = false;\n\t\tfor (const inputId of [...this.answeredInputs]) {\n\t\t\tconst frameRequestId = this.pendingInputs.get(inputId)?.frameRequestId;\n\t\t\tif (frameRequestId === undefined || frameRequestId > requestId) continue;\n\t\t\tthis.settleInput(inputId, true);\n\t\t\tansweredKey = true;\n\t\t}\n\t\tif (this.keyFrameRequestId !== 0 && requestId >= this.keyFrameRequestId) {\n\t\t\tthis.keyFrameRequestId = 0;\n\t\t\t// A key answered now repaints as its input settles; a frame that overtook its key's answer paints at once.\n\t\t\tif (!answeredKey) this.paintNow();\n\t\t\treturn;\n\t\t}\n\t\tthis.requestRender();\n\t}\n\n\trequestRemoteRender(): void {\n\t\tif (this.disposed) return;\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t}\n\n\t/**\n\t * Tear the proxy down. `notifyEngine` must be false once the writer no longer\n\t * points at the generation that owns this component: component IDs restart at\n\t * `remote_component_1` for every child, so a late dispose would address an\n\t * unrelated component in the replacement engine.\n\t */\n\tdispose(notifyEngine = true): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const requestId of [...this.pendingInputs.keys()]) this.resolveInput(requestId, undefined);\n\t\tif (notifyEngine)\n\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_dispose\", componentId: this.componentId });\n\t}\n}\n\n/** The engine component behind a transcript mount, as the host's transcript area uses it. */\nexport type RemoteTranscriptComponent = Pick<\n\tRemoteComponent,\n\t\"render\" | \"handleInput\" | \"handleMouse\" | \"paintedRowKey\" | \"invalidate\" | \"prime\" | \"hostColorDepth\"\n>;\n\n/**\n * A viewed subagent's transcript the engine opened with `placement: \"transcript\"` for view `viewId`. The host's\n * transcript area draws it in the rows it sets; it is closed by the engine (`engine_custom_close`) or with its engine.\n */\nexport class RemoteTranscriptMount {\n\treadonly componentId: string;\n\treadonly viewId: string;\n\treadonly component: RemoteTranscriptComponent;\n\t/** The rows the transcript area gives it; frames are requested at this height. */\n\trows = 24;\n\tprivate framed = false;\n\tprivate isClosed = false;\n\tprivate readonly waiting = new Set<(framed: boolean) => void>();\n\tprivate readonly closeListeners = new Set<() => void>();\n\n\tconstructor(componentId: string, viewId: string, component: RemoteComponent) {\n\t\tthis.componentId = componentId;\n\t\tthis.viewId = viewId;\n\t\tthis.component = component;\n\t\tcomponent.onFrame = () => {\n\t\t\tif (this.framed) return;\n\t\t\tthis.framed = true;\n\t\t\tfor (const resolve of [...this.waiting]) resolve(true);\n\t\t\tthis.waiting.clear();\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this.isClosed;\n\t}\n\n\t/** Resolves true once the engine's first frame is here, false if the mount closed first. */\n\tfirstFrame(): Promise<boolean> {\n\t\tif (this.framed) return Promise.resolve(true);\n\t\tif (this.isClosed) return Promise.resolve(false);\n\t\treturn new Promise((resolve) => this.waiting.add(resolve));\n\t}\n\n\tonClose(listener: () => void): () => void {\n\t\tif (this.isClosed) {\n\t\t\tlistener();\n\t\t\treturn () => {};\n\t\t}\n\t\tthis.closeListeners.add(listener);\n\t\treturn () => this.closeListeners.delete(listener);\n\t}\n\n\t/** @internal The controller closed it. */\n\tmarkClosed(): void {\n\t\tif (this.isClosed) return;\n\t\tthis.isClosed = true;\n\t\tfor (const resolve of [...this.waiting]) resolve(false);\n\t\tthis.waiting.clear();\n\t\tfor (const listener of [...this.closeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t\tthis.closeListeners.clear();\n\t}\n}\n\nconst transcriptMounts = new WeakMap<object, Map<string, RemoteTranscriptMount>>();\n\n/** The transcript the engine of `runtime` opened for view `viewId`, while it is open. */\nexport function remoteTranscriptMount(runtime: object, viewId: string): RemoteTranscriptMount | undefined {\n\treturn transcriptMounts.get(runtime)?.get(viewId);\n}\n\nfunction renderSettingsCacheKey(renderSettings: EngineHostRenderSettings | undefined): string {\n\treturn renderSettings === undefined\n\t\t? \"\"\n\t\t: `${renderSettings.hideThinkingBlock}|${renderSettings.toolOutputExpanded}|${renderSettings.fullscreenScrollbar}|${renderSettings.fullscreenWheelScrollLines}`;\n}\n\nfunction overlayOptions(options: SerializableOverlayOptions | undefined): OverlayOptions | undefined {\n\treturn options as OverlayOptions | undefined;\n}\n\n/**\n * Resolve the real host terminal from the pi-tui TUI handed to the overlay\n * factory. Optional: some hosts / test seams do not surface `tui.terminal`, in\n * which case terminal-mode controls harmlessly no-op.\n */\nfunction hostTerminal(tui: TUI): { write(data: string): void } {\n\tconst terminal = (tui as { terminal?: { write?(data: string): void } }).terminal;\n\treturn typeof terminal?.write === \"function\" ? (terminal as { write(data: string): void }) : { write: () => {} };\n}\n\nexport interface TuiRendererLifecycle {\n\tisFullscreen(): boolean;\n\tonRendererReplaced(listener: () => void): () => void;\n\t/** What the host's own chat shows; transcripts the engine paints in its overlays and widgets follow it. */\n\tchatRenderSettings?(): EngineHostRenderSettings;\n}\n\nexport class RemoteComponentController {\n\tprivate readonly mounted = new Map<string, MountedRemoteComponent>();\n\tprivate readonly unsubscribe: () => void;\n\tprivate readonly unsubscribeGenerationEnded: () => void;\n\tprivate readonly terminalModes: TerminalModeController;\n\tprivate readonly unsubscribeTuiRendererReplaced: () => void;\n\n\tprivate readonly runtime: RemoteComponentRuntime;\n\tprivate readonly ui: RemoteComponentUI;\n\tprivate readonly copyText: (text: string) => Promise<void>;\n\tprivate readonly tuiRendererLifecycle: TuiRendererLifecycle;\n\n\tconstructor(\n\t\truntime: RemoteComponentRuntime,\n\t\tui: RemoteComponentUI,\n\t\ttuiRendererLifecycle: TuiRendererLifecycle,\n\t\tcopyText: (text: string) => Promise<void> = copyToClipboard,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.copyText = copyText;\n\t\tthis.tuiRendererLifecycle = tuiRendererLifecycle;\n\t\tthis.terminalModes = new TerminalModeController(() => tuiRendererLifecycle.isFullscreen());\n\t\tthis.unsubscribeTuiRendererReplaced = tuiRendererLifecycle.onRendererReplaced(() =>\n\t\t\tthis.terminalModes.rebindTui(),\n\t\t);\n\t\tthis.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));\n\t\t// Teardown is driven by engine death rather than the NEXT generation's\n\t\t// `engine_ready`, so a crash with no restart, or a hung/failed restart,\n\t\t// still releases the host editor, focus, and inline-custom-UI depth.\n\t\tthis.unsubscribeGenerationEnded = runtime.onGenerationEnded(() => this.disposeAll(\"generation-lost\"));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribeTuiRendererReplaced();\n\t\tthis.unsubscribe();\n\t\tthis.unsubscribeGenerationEnded();\n\t\tthis.disposeAll(\"host-shutdown\");\n\t}\n\n\t/** The mode of the host's current renderer, which engine components lay themselves out for. */\n\tprivate hostMode(): TuiMode {\n\t\treturn this.tuiRendererLifecycle.isFullscreen() ? \"fullscreen\" : \"regular\";\n\t}\n\n\t/** The remote overlay proxy that currently holds focus (see remote-input-ownership.ts). */\n\tfocusedRemoteOverlay(): unknown {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.handle?.isFocused() === true) return record.component;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** `component` itself when it is one of this generation's live non-widget proxies. */\n\tremoteProxyOwner(component: unknown): unknown {\n\t\tif (!(component instanceof RemoteComponent)) return undefined;\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component === component)\n\t\t\t\treturn record.widgetKey === undefined && record.transcript === undefined ? component : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** True when the extension that mounted `component` declared it binds Ctrl+C. */\n\tremoteProxyHandlesCtrlC(component: unknown): boolean {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component === component) return record.handlesCtrlC;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Close exactly one live proxy through the ordinary host close path.\n\t *\n\t * The host escape from a component that traps Ctrl+C, and deliberately not\n\t * `disposeAll()`: that is generation-death teardown, which would also close\n\t * unrelated nested components and suppress the child notification. Here the\n\t * record stays registered while `done` runs, so `showExtensionCustom()`\n\t * hides this overlay (or remounts the editor) and its finalizer disposes the\n\t * proxy normally — which tells the healthy child to resolve its own\n\t * `ui.custom()` promise with `undefined`, exactly like a user cancel.\n\t */\n\tdismissRemoteProxy(component: unknown): boolean {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component !== component || record.widgetKey !== undefined || record.transcript !== undefined)\n\t\t\t\tcontinue;\n\t\t\trecord.done(undefined);\n\t\t\tthis.ui.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate releaseWidget(widgetKey: string): void {\n\t\tfor (const [componentId, record] of this.mounted) {\n\t\t\tif (record.widgetKey !== widgetKey) continue;\n\t\t\tthis.mounted.delete(componentId);\n\t\t\trecord.unsubscribeWidgetRelease?.();\n\t\t\trecord.unsubscribeWidgetRelease = undefined;\n\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t}\n\t}\n\t/**\n\t * Close every mounted component.\n\t *\n\t * `\"generation-lost\"` closes through the real host close path: it hides the\n\t * overlay or remounts the editor into `editorContainer`, restores the saved\n\t * draft and focus, releases `blockingInlineCustomUiDepth`, and resolves the\n\t * extension's `ui.custom()` promise. Records are removed BEFORE each `done`\n\t * runs so the settlement path cannot re-enter the controller, and proxy\n\t * disposal is local-only because the writer already points at a replacement\n\t * child whose component IDs restart at `remote_component_1`.\n\t *\n\t * Order is newest-first, matching the TUI's overlay stack. Closing oldest\n\t * first would let an overlay mounted above an inline proxy restore focus to\n\t * that inline proxy after it had already been disposed.\n\t *\n\t * `\"host-shutdown\"` notifies the still-live engine child instead and leaves\n\t * host mounts alone: the TUI is already stopping and must not repaint.\n\t */\n\tprivate disposeAll(reason: \"generation-lost\" | \"host-shutdown\"): void {\n\t\tconst records = [...this.mounted.entries()].reverse();\n\t\tthis.mounted.clear();\n\t\tfor (const [componentId, record] of records) {\n\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t\trecord.unsubscribeWidgetRelease?.();\n\t\t\trecord.component.dispose(reason === \"host-shutdown\" && !record.engineDone);\n\t\t\tif (record.transcript) this.closeTranscript(record.transcript);\n\t\t\telse if (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\t\telse if (reason === \"generation-lost\") record.done(undefined);\n\t\t}\n\t\tthis.terminalModes.resetAll();\n\t\tif (reason === \"generation-lost\" && records.length > 0) this.ui.requestRender();\n\t}\n\n\tprivate handleMessage(message: InteractiveEngineMessage): void {\n\t\tswitch (message.type) {\n\t\t\tcase \"engine_ready\":\n\t\t\t\t// Idempotent fallback for a generation replacement whose death event\n\t\t\t\t// was already handled: stale records must be gone before the new child\n\t\t\t\t// can reuse `remote_component_1`, and any terminal modes the dead\n\t\t\t\t// generation left on are reset here too.\n\t\t\t\tthis.disposeAll(\"generation-lost\");\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_open\":\n\t\t\t\tthis.open(\n\t\t\t\t\tmessage.componentId,\n\t\t\t\t\tmessage.overlay,\n\t\t\t\t\tmessage.deferInlineCustomUiFocus,\n\t\t\t\t\tmessage.overlayOptions,\n\t\t\t\t\tmessage.widgetKey,\n\t\t\t\t\tmessage.widgetPlacement,\n\t\t\t\t\tmessage.handlesCtrlC === true,\n\t\t\t\t\tmessage.handlesInternalUiAction === true,\n\t\t\t\t\tmessage.reserveTranscriptRows === true,\n\t\t\t\t\tmessage.purpose,\n\t\t\t\t\tmessage.widgetScroll,\n\t\t\t\t\tmessage.blocked,\n\t\t\t\t\tmessage.placement === \"transcript\" ? message.viewId : undefined,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_close\":\n\t\t\t\tthis.close(message.componentId);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_frame\":\n\t\t\t\tthis.mounted\n\t\t\t\t\t.get(message.componentId)\n\t\t\t\t\t?.component.applyFrame(\n\t\t\t\t\t\tmessage.requestId,\n\t\t\t\t\t\tmessage.lines,\n\t\t\t\t\t\tmessage.scrollRequest,\n\t\t\t\t\t\tmessage.frame,\n\t\t\t\t\t\tmessage.rowKeys,\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_input_result\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.resolveInput(message.requestId, message.handled);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_invalidate\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.requestRemoteRender();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_copy\":\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tlet error: string | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!this.mounted.has(message.componentId)) throw new Error(\"Sign-in screen is no longer open\");\n\t\t\t\t\t\tawait this.copyText(message.text);\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\terror = cause instanceof Error ? cause.message : String(cause);\n\t\t\t\t\t}\n\t\t\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\t\t\ttype: \"engine_custom_copy_result\",\n\t\t\t\t\t\tcomponentId: message.componentId,\n\t\t\t\t\t\trequestId: message.requestId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t});\n\t\t\t\t})();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_terminal\":\n\t\t\t\tthis.terminalModes.applyControl(message.componentId, message.control);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_done\": {\n\t\t\t\tconst record = this.mounted.get(message.componentId);\n\t\t\t\tif (record) {\n\t\t\t\t\trecord.engineDone = true;\n\t\t\t\t\trecord.done(message.result);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"engine_custom_control\":\n\t\t\t\tthis.control(message.componentId, message.action);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate open(\n\t\tcomponentId: string,\n\t\toverlay: boolean,\n\t\tdeferInlineCustomUiFocus: boolean | undefined,\n\t\toptions: SerializableOverlayOptions | undefined,\n\t\twidgetKey?: string,\n\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\",\n\t\thandlesCtrlC = false,\n\t\thandlesInternalUiAction = false,\n\t\treserveTranscriptRows = false,\n\t\tpurpose?: \"prompt\" | \"navigation\",\n\t\twidgetScroll?: { maxHeight: number; maxHeightFraction?: number },\n\t\tblocked?: EngineBlockedStatus,\n\t\ttranscriptViewId?: string,\n\t): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tif (transcriptViewId !== undefined) {\n\t\t\tthis.openTranscript(componentId, transcriptViewId);\n\t\t\treturn;\n\t\t}\n\t\tif (widgetKey) {\n\t\t\tlet getRows = () => 24;\n\t\t\tlet paintNow = () => this.ui.requestRender();\n\t\t\tconst component = new RemoteComponent(\n\t\t\t\tcomponentId,\n\t\t\t\tthis.runtime,\n\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t() => getRows(),\n\t\t\t\t() => this.hostMode(),\n\t\t\t\thandlesInternalUiAction,\n\t\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t\t\t() => paintNow(),\n\t\t\t);\n\t\t\tconst unsubscribeWidgetRelease = this.ui.onWidgetRelease?.(widgetKey, () => this.releaseWidget(widgetKey));\n\t\t\tthis.mounted.set(componentId, {\n\t\t\t\tcomponent,\n\t\t\t\tdone: () => {},\n\t\t\t\tengineDone: false,\n\t\t\t\thandlesCtrlC,\n\t\t\t\thandlesInternalUiAction,\n\t\t\t\twidgetKey,\n\t\t\t\tunsubscribeWidgetRelease,\n\t\t\t});\n\t\t\tthis.ui.setWidget(\n\t\t\t\twidgetKey,\n\t\t\t\t(tui) => {\n\t\t\t\t\tcomponent.hostColorDepth = tui.terminal?.colorDepth;\n\t\t\t\t\tgetRows = () => tui.terminal.rows;\n\t\t\t\t\tpaintNow = () => tui.requestImmediateRender();\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{ placement: widgetPlacement, ...(widgetScroll ? { scroll: widgetScroll } : {}) },\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlet mounted: MountedRemoteComponent | undefined;\n\t\tvoid this.ui\n\t\t\t.custom<JsonValue | undefined>(\n\t\t\t\t(tui, _theme, _keybindings, done) => {\n\t\t\t\t\tconst component = new RemoteComponent(\n\t\t\t\t\t\tcomponentId,\n\t\t\t\t\t\tthis.runtime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\t() => tui.terminal.rows,\n\t\t\t\t\t\t() => this.hostMode(),\n\t\t\t\t\t\thandlesInternalUiAction,\n\t\t\t\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t\t\t\t\t() => tui.requestImmediateRender(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.hostColorDepth = tui.terminal?.colorDepth;\n\t\t\t\t\tmounted = { component, done, engineDone: false, handlesCtrlC, handlesInternalUiAction };\n\t\t\t\t\tthis.mounted.set(componentId, mounted);\n\t\t\t\t\t// Bind this component to the real host terminal so a buffered\n\t\t\t\t\t// autowrap control emitted before the mount frame applies to the host TTY.\n\t\t\t\t\tthis.terminalModes.onMount(componentId, hostTerminal(tui));\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\toverlay,\n\t\t\t\t\tpurpose,\n\t\t\t\t\tdeferInlineCustomUiFocus,\n\t\t\t\t\thandlesInternalUiAction,\n\t\t\t\t\treserveTranscriptRows,\n\t\t\t\t\toverlayOptions: overlayOptions(options),\n\t\t\t\t\tblocked,\n\t\t\t\t\tonHandle: (handle) => {\n\t\t\t\t\t\tif (mounted) mounted.handle = handle;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t\t\t.finally(() => {\n\t\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t\t\tconst record = this.mounted.get(componentId);\n\t\t\t\tif (!record) return;\n\t\t\t\tthis.mounted.delete(componentId);\n\t\t\t\tif (record.engineDone) record.component.dispose(false);\n\t\t\t\telse record.component.dispose();\n\t\t\t});\n\t}\n\n\tprivate close(componentId: string): void {\n\t\tconst record = this.mounted.get(componentId);\n\t\tif (!record) return;\n\t\tthis.terminalModes.onUnmount(componentId);\n\t\tthis.mounted.delete(componentId);\n\t\trecord.unsubscribeWidgetRelease?.();\n\t\tif (record.transcript) this.closeTranscript(record.transcript);\n\t\telse if (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\trecord.component.dispose();\n\t}\n\n\t/**\n\t * A viewed subagent's transcript: drawn by the host's transcript area at the rows it gives, never mounted as custom\n\t * UI, so it blocks nothing and takes focus only when the area gives it.\n\t */\n\tprivate openTranscript(componentId: string, viewId: string): void {\n\t\tlet mount: RemoteTranscriptMount | undefined;\n\t\tconst component = new RemoteComponent(\n\t\t\tcomponentId,\n\t\t\tthis.runtime,\n\t\t\t() => this.ui.requestRender(),\n\t\t\t() => mount?.rows ?? 24,\n\t\t\t() => this.hostMode(),\n\t\t\tfalse,\n\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t);\n\t\tmount = new RemoteTranscriptMount(componentId, viewId, component);\n\t\tconst views = transcriptMounts.get(this.runtime) ?? new Map<string, RemoteTranscriptMount>();\n\t\ttranscriptMounts.set(this.runtime, views);\n\t\tviews.get(viewId)?.markClosed();\n\t\tviews.set(viewId, mount);\n\t\tthis.mounted.set(componentId, {\n\t\t\tcomponent,\n\t\t\tdone: () => {},\n\t\t\tengineDone: false,\n\t\t\thandlesCtrlC: false,\n\t\t\thandlesInternalUiAction: false,\n\t\t\ttranscript: mount,\n\t\t});\n\t}\n\n\tprivate closeTranscript(mount: RemoteTranscriptMount): void {\n\t\tconst views = transcriptMounts.get(this.runtime);\n\t\tif (views?.get(mount.viewId) === mount) views.delete(mount.viewId);\n\t\tmount.markClosed();\n\t\tthis.ui.requestRender();\n\t}\n\n\tprivate control(componentId: string, action: \"focus\" | \"hide\" | \"show\" | \"unfocus\"): void {\n\t\tconst handle = this.mounted.get(componentId)?.handle;\n\t\tif (!handle) return;\n\t\tswitch (action) {\n\t\t\tcase \"focus\":\n\t\t\t\thandle.focus();\n\t\t\t\tbreak;\n\t\t\tcase \"hide\":\n\t\t\t\thandle.setHidden(true);\n\t\t\t\tbreak;\n\t\t\tcase \"show\":\n\t\t\t\thandle.setHidden(false);\n\t\t\t\tbreak;\n\t\t\tcase \"unfocus\":\n\t\t\t\thandle.unfocus();\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"remote-component.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-component.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,gBAAgB,GAOhB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,2CAA2C,CAAC;AAS9E,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAyBvE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AASjD,MAAM,eAAe;IACpB,cAAc,CAAU;IAChB,aAAa,CAAkC;IACvD,gBAAgB;QACf,OAAO,IAAI,CAAC,aAAa,CAAC;IAC3B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ACjB,YAAY,EAAE,KAAK;YACnB,uBAAuB,EAAE,KAAK;YAC9B,UAAU,EAAE,KAAK;SACjB,CAAC,CAAC;IACJ,CAAC;IAEO,eAAe,CAAC,KAA4B;QACnD,MAAM,KAAK,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,KAAK,EAAE,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,KAAK;YAAE,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACnE,KAAK,CAAC,UAAU,EAAE,CAAC;QACnB,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC;IAEO,OAAO,CAAC,WAAmB,EAAE,MAA6C;QACjF,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QACrD,IAAI,CAAC,MAAM;YAAE,OAAO;QACpB,QAAQ,MAAM,EAAE,CAAC;YAChB,KAAK,OAAO;gBACX,MAAM,CAAC,KAAK,EAAE,CAAC;gBACf,MAAM;YACP,KAAK,MAAM;gBACV,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;gBACvB,MAAM;YACP,KAAK,MAAM;gBACV,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;gBACxB,MAAM;YACP,KAAK,SAAS;gBACb,MAAM,CAAC,OAAO,EAAE,CAAC;gBACjB,MAAM;QACR,CAAC;IACF,CAAC;CACD","sourcesContent":["import {\n\ttype Component,\n\tisHintActivation,\n\ttype OverlayHandle,\n\ttype OverlayOptions,\n\ttype TUI,\n\ttype TuiMode,\n\ttype TuiMouseEvent,\n\ttype TuiMouseEventResult,\n} from \"@bastani/atomic-tui\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.js\";\nimport type { WidgetScrollRequest, WidgetScrollState } from \"../../core/extensions/ui-types.js\";\nimport { copyToClipboard } from \"../../utils/clipboard.js\";\nimport { awaitFirstContent } from \"../interactive/components/prompt-slot.ts\";\nimport { isSingleLeftClick } from \"../interactive/components/single-click.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type {\n\tEngineBlockedStatus,\n\tEngineHostRenderSettings,\n\tInteractiveEngineMessage,\n\tJsonValue,\n\tSerializableOverlayOptions,\n} from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\nimport { TerminalModeController } from \"./terminal-mode-controller.ts\";\nimport type { TranscriptFrameLayout } from \"./transcript-frame-layout.ts\";\n\nexport type RemoteComponentRuntime = Pick<\n\tIsolatedInteractiveRuntime,\n\t\"onEngineMessage\" | \"onGenerationEnded\" | \"sendEngineCommand\"\n>;\n\nexport type RemoteComponentUI = Pick<ExtensionUIContext, \"custom\" | \"requestRender\" | \"setWidget\" | \"onWidgetRelease\">;\n\ninterface MountedRemoteComponent {\n\tcomponent: RemoteComponent;\n\tdone: (result: JsonValue | undefined) => void;\n\tengineDone: boolean;\n\t/** The extension declared that this component binds Ctrl+C itself. */\n\thandlesCtrlC: boolean;\n\t/** The extension declared that this component claims internal UI actions. */\n\thandlesInternalUiAction: boolean;\n\thandle?: OverlayHandle;\n\twidgetKey?: string;\n\tunsubscribeWidgetRelease?: () => void;\n\t/** A viewed subagent's transcript (`placement: \"transcript\"`), drawn by the host's transcript area. */\n\ttranscript?: RemoteTranscriptMount;\n}\n\n/**\n * A stalled engine must not make fullscreen input wait forever. A timed-out\n * reply is treated as unhandled and lets the viewport process the key.\n */\nexport const REMOTE_INPUT_REPLY_TIMEOUT_MS = 250;\n\ninterface PendingInput {\n\tresolve: (handled: boolean | undefined) => void;\n\ttimer: ReturnType<typeof setTimeout>;\n\t/** The frame requested with the key: a handled key answers once that frame is here, so one paint shows it. */\n\treadonly frameRequestId: number | undefined;\n}\n\nclass RemoteComponent implements Component {\n\thostColorDepth?: number;\n\tprivate scrollRequest: WidgetScrollRequest | undefined;\n\tgetScrollRequest(): WidgetScrollRequest | undefined {\n\t\treturn this.scrollRequest;\n\t}\n\tonScroll(state: WidgetScrollState): void {\n\t\tif (!this.disposed)\n\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_scroll\", componentId: this.componentId, state });\n\t}\n\twantsKeyRelease = true;\n\treadonly handlesInternalUiAction: boolean;\n\tprivate lines: string[] = [];\n\tprivate width = 0;\n\tprivate rows = 0;\n\tprivate hostMode: TuiMode | undefined;\n\tprivate requestId = 0;\n\tprivate inputRequestId = 0;\n\tprivate appliedRequestId = 0;\n\t/** The engine's number for the frame in `lines`, and for the frame the last `render` returned. */\n\tprivate frame: number | undefined;\n\tprivate paintedFrame: number | undefined;\n\t/** What the engine component drew on each row of `lines`, and of the frame the last `render` returned. */\n\tprivate rowKeys: readonly string[] | undefined;\n\tprivate paintedRowKeys: readonly string[] | undefined;\n\t/** How a viewed subagent's transcript laid out `lines`, and the frame the last `render` returned. */\n\tprivate layout: TranscriptFrameLayout | undefined;\n\tprivate paintedFrameLayout: TranscriptFrameLayout | undefined;\n\t/** The number of the last click forwarded to the engine. */\n\tprivate clickId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly pendingInputs = new Map<number, PendingInput>();\n\t/** Handled keys whose frame has not arrived yet. */\n\tprivate readonly answeredInputs = new Set<number>();\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\n\tprivate readonly componentId: string;\n\tprivate readonly runtime: RemoteComponentRuntime;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly paintNow: () => void;\n\tprivate readonly getRows: () => number;\n\tprivate readonly getHostMode: () => TuiMode;\n\tprivate readonly getRenderSettings: () => EngineHostRenderSettings | undefined;\n\tprivate renderSettingsKey = \"\";\n\t/** The frame request sent with the latest key; the frame answering it paints at once, as a local key does. */\n\tprivate keyFrameRequestId = 0;\n\n\tconstructor(\n\t\tcomponentId: string,\n\t\truntime: RemoteComponentRuntime,\n\t\trequestRender: () => void,\n\t\tgetRows: () => number,\n\t\tgetHostMode: () => TuiMode,\n\t\thandlesInternalUiAction = false,\n\t\tgetRenderSettings: () => EngineHostRenderSettings | undefined = () => undefined,\n\t\tpaintNow: () => void = requestRender,\n\t) {\n\t\tthis.componentId = componentId;\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.paintNow = paintNow;\n\t\tthis.getRows = getRows;\n\t\tthis.getHostMode = getHostMode;\n\t\tthis.handlesInternalUiAction = handlesInternalUiAction;\n\t\tthis.getRenderSettings = getRenderSettings;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst rows = this.getRows();\n\t\t// A renderer switch in the host changes the mode the engine component lays itself out for.\n\t\tconst hostMode = this.getHostMode();\n\t\tconst renderSettings = this.getRenderSettings();\n\t\tconst renderSettingsKey = renderSettingsCacheKey(renderSettings);\n\t\tif (\n\t\t\t!this.disposed &&\n\t\t\t(this.dirty ||\n\t\t\t\twidth !== this.width ||\n\t\t\t\trows !== this.rows ||\n\t\t\t\thostMode !== this.hostMode ||\n\t\t\t\trenderSettingsKey !== this.renderSettingsKey)\n\t\t) {\n\t\t\tthis.requestFrame(width, rows, hostMode, renderSettings, renderSettingsKey);\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\tthis.paintedFrame = this.frame;\n\t\tthis.paintedRowKeys = this.rowKeys;\n\t\tthis.paintedFrameLayout = this.layout;\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\t/** How the frame the last `render` returned laid out its rows, when the engine said. */\n\tpaintedLayout(): TranscriptFrameLayout | undefined {\n\t\treturn this.paintedFrameLayout;\n\t}\n\n\t/** What the engine component drew on `row` of the frame this host painted, when it names its rows. */\n\tpaintedRowKey(row: number): string | undefined {\n\t\treturn this.paintedRowKeys?.[row];\n\t}\n\n\t/**\n\t * Forward a single click to the engine component, at its row and column there. Presses, drags and multi-clicks stay\n\t * with the host's text selection. The click is numbered: once it stays a single click, the host settles that number,\n\t * and what the component left for that moment runs.\n\t */\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tif (this.disposed || !isSingleLeftClick(event) || this.paintedFrame === undefined) return undefined;\n\t\tconst rowKey = this.paintedRowKeys?.[Math.floor(event.y)];\n\t\tconst clickId = ++this.clickId;\n\t\tthis.runtime.sendEngineCommand({\n\t\t\ttype: \"engine_custom_click\",\n\t\t\tcomponentId: this.componentId,\n\t\t\tframe: this.paintedFrame,\n\t\t\t...(rowKey === undefined ? {} : { rowKey }),\n\t\t\tclickId,\n\t\t\tcancelsClicks: true,\n\t\t\tx: Math.max(0, Math.floor(event.x)),\n\t\t\ty: Math.max(0, Math.floor(event.y)),\n\t\t\twidth: Math.max(0, Math.floor(event.width)),\n\t\t\theight: Math.max(0, Math.floor(event.height)),\n\t\t});\n\t\tconst finish = (type: \"engine_custom_click_settle\" | \"engine_custom_click_cancel\") => {\n\t\t\tif (this.disposed) return;\n\t\t\ttry {\n\t\t\t\tthis.runtime.sendEngineCommand({ type, componentId: this.componentId, clickId });\n\t\t\t} catch {\n\t\t\t\t// An engine that went away takes no click; the host keeps its frame.\n\t\t\t}\n\t\t};\n\t\treturn {\n\t\t\thandled: true,\n\t\t\twhenSingleClick: () => finish(\"engine_custom_click_settle\"),\n\t\t\tonSingleClickCancel: () => finish(\"engine_custom_click_cancel\"),\n\t\t};\n\t}\n\n\thandleInput(data: string): Promise<boolean | undefined> {\n\t\tif (this.disposed) return Promise.resolve(undefined);\n\t\tconst requestId = ++this.inputRequestId;\n\t\tconst frameRequestId = this.width > 0 ? this.requestId + 1 : undefined;\n\t\tconst result = new Promise<boolean | undefined>((resolve) => {\n\t\t\tconst timer = setTimeout(() => this.resolveInput(requestId, false), REMOTE_INPUT_REPLY_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t\tthis.pendingInputs.set(requestId, { resolve, timer, frameRequestId });\n\t\t});\n\t\ttry {\n\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\ttype: \"engine_custom_input\",\n\t\t\t\tcomponentId: this.componentId,\n\t\t\t\trequestId,\n\t\t\t\tdata,\n\t\t\t\t...(isHintActivation() ? { hint: true as const } : {}),\n\t\t\t});\n\t\t} catch {\n\t\t\tthis.resolveInput(requestId, false);\n\t\t}\n\t\t// Engine commands are delivered in order, so a frame requested now is\n\t\t// rendered by the child only AFTER it has applied this input. Asking for\n\t\t// it with the key, rather than on the next paced host render, keeps the\n\t\t// keypress at a single round trip, and repaints components that never\n\t\t// self-invalidate.\n\t\tif (frameRequestId !== undefined) {\n\t\t\tconst renderSettings = this.getRenderSettings();\n\t\t\tthis.keyFrameRequestId = frameRequestId;\n\t\t\tthis.requestFrame(\n\t\t\t\tthis.width,\n\t\t\t\tthis.getRows(),\n\t\t\t\tthis.getHostMode(),\n\t\t\t\trenderSettings,\n\t\t\t\trenderSettingsCacheKey(renderSettings),\n\t\t\t);\n\t\t} else {\n\t\t\tthis.dirty = true;\n\t\t\tthis.requestRender();\n\t\t}\n\t\treturn result;\n\t}\n\n\tprivate requestFrame(\n\t\twidth: number,\n\t\trows: number,\n\t\thostMode: TuiMode,\n\t\trenderSettings: EngineHostRenderSettings | undefined,\n\t\trenderSettingsKey: string,\n\t): void {\n\t\tthis.width = width;\n\t\tthis.rows = rows;\n\t\tthis.hostMode = hostMode;\n\t\tthis.renderSettingsKey = renderSettingsKey;\n\t\tthis.dirty = false;\n\t\tthis.runtime.sendEngineCommand({\n\t\t\ttype: \"engine_custom_render\",\n\t\t\tcomponentId: this.componentId,\n\t\t\t...(this.requestId === 0 && this.hostColorDepth !== undefined ? { colorDepth: this.hostColorDepth } : {}),\n\t\t\trequestId: ++this.requestId,\n\t\t\twidth,\n\t\t\trows,\n\t\t\thostMode,\n\t\t\t...(renderSettings === undefined ? {} : { renderSettings }),\n\t\t});\n\t}\n\n\tresolveInput(requestId: number, handled: boolean | undefined): void {\n\t\tconst pending = this.pendingInputs.get(requestId);\n\t\tif (!pending) return;\n\t\tclearTimeout(pending.timer);\n\t\t// A handled key answers with the frame that shows it: resolving before it arrives would repaint the frame the\n\t\t// key has not reached, and the key's own frame would wait behind that paint.\n\t\tif (handled === true && pending.frameRequestId !== undefined && this.appliedRequestId < pending.frameRequestId) {\n\t\t\tpending.timer = setTimeout(() => this.settleInput(requestId, true), REMOTE_INPUT_REPLY_TIMEOUT_MS);\n\t\t\tpending.timer.unref?.();\n\t\t\tthis.answeredInputs.add(requestId);\n\t\t\treturn;\n\t\t}\n\t\tthis.settleInput(requestId, handled);\n\t}\n\n\tprivate settleInput(requestId: number, handled: boolean | undefined): void {\n\t\tconst pending = this.pendingInputs.get(requestId);\n\t\tif (!pending) return;\n\t\tthis.pendingInputs.delete(requestId);\n\t\tthis.answeredInputs.delete(requestId);\n\t\tclearTimeout(pending.timer);\n\t\tpending.resolve(handled);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.dirty = true;\n\t}\n\n\t/** Nothing to draw yet: the engine has not sent its first frame. */\n\tawaitingFirstContent(): boolean {\n\t\treturn !this.disposed && this.appliedRequestId === 0;\n\t}\n\n\t/** Called with each frame the engine sends, once it is the one `render` returns. */\n\tonFrame: (() => void) | undefined;\n\n\t/** Ask for a frame of `width` x `rows` now, before the host lays the component out. */\n\tprime(width: number, rows: number): void {\n\t\tif (this.disposed) return;\n\t\tconst renderSettings = this.getRenderSettings();\n\t\tthis.requestFrame(width, rows, this.getHostMode(), renderSettings, renderSettingsCacheKey(renderSettings));\n\t}\n\n\tapplyFrame(\n\t\trequestId: number,\n\t\tlines: string[],\n\t\tscrollRequest?: WidgetScrollRequest,\n\t\tframe?: number,\n\t\trowKeys?: readonly string[],\n\t\tlayout?: TranscriptFrameLayout,\n\t): void {\n\t\tif (this.disposed || requestId < this.appliedRequestId) return;\n\t\tthis.appliedRequestId = requestId;\n\t\tthis.lines = lines;\n\t\tthis.frame = frame;\n\t\tthis.rowKeys = rowKeys;\n\t\tthis.layout = layout;\n\t\tthis.scrollRequest = scrollRequest;\n\t\tthis.onFrame?.();\n\t\tlet answeredKey = false;\n\t\tfor (const inputId of [...this.answeredInputs]) {\n\t\t\tconst frameRequestId = this.pendingInputs.get(inputId)?.frameRequestId;\n\t\t\tif (frameRequestId === undefined || frameRequestId > requestId) continue;\n\t\t\tthis.settleInput(inputId, true);\n\t\t\tansweredKey = true;\n\t\t}\n\t\tif (this.keyFrameRequestId !== 0 && requestId >= this.keyFrameRequestId) {\n\t\t\tthis.keyFrameRequestId = 0;\n\t\t\t// A key answered now repaints as its input settles; a frame that overtook its key's answer paints at once.\n\t\t\tif (!answeredKey) this.paintNow();\n\t\t\treturn;\n\t\t}\n\t\tthis.requestRender();\n\t}\n\n\trequestRemoteRender(): void {\n\t\tif (this.disposed) return;\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t}\n\n\t/**\n\t * Tear the proxy down. `notifyEngine` must be false once the writer no longer\n\t * points at the generation that owns this component: component IDs restart at\n\t * `remote_component_1` for every child, so a late dispose would address an\n\t * unrelated component in the replacement engine.\n\t */\n\tdispose(notifyEngine = true): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const requestId of [...this.pendingInputs.keys()]) this.resolveInput(requestId, undefined);\n\t\tif (notifyEngine)\n\t\t\tthis.runtime.sendEngineCommand({ type: \"engine_custom_dispose\", componentId: this.componentId });\n\t}\n}\n\n/** The engine component behind a transcript mount, as the host's transcript area uses it. */\nexport type RemoteTranscriptComponent = Pick<\n\tRemoteComponent,\n\t| \"render\"\n\t| \"handleInput\"\n\t| \"handleMouse\"\n\t| \"paintedRowKey\"\n\t| \"paintedLayout\"\n\t| \"invalidate\"\n\t| \"prime\"\n\t| \"hostColorDepth\"\n>;\n\n/**\n * A viewed subagent's transcript the engine opened with `placement: \"transcript\"` for view `viewId`. The host's\n * transcript area draws it in the rows it sets; it is closed by the engine (`engine_custom_close`) or with its engine.\n */\nexport class RemoteTranscriptMount {\n\treadonly componentId: string;\n\treadonly viewId: string;\n\treadonly component: RemoteTranscriptComponent;\n\t/** The rows the transcript area gives it; frames are requested at this height. */\n\trows = 24;\n\tprivate framed = false;\n\tprivate isClosed = false;\n\tprivate readonly waiting = new Set<(framed: boolean) => void>();\n\tprivate readonly closeListeners = new Set<() => void>();\n\n\tconstructor(componentId: string, viewId: string, component: RemoteComponent) {\n\t\tthis.componentId = componentId;\n\t\tthis.viewId = viewId;\n\t\tthis.component = component;\n\t\tcomponent.onFrame = () => {\n\t\t\tif (this.framed) return;\n\t\t\tthis.framed = true;\n\t\t\tfor (const resolve of [...this.waiting]) resolve(true);\n\t\t\tthis.waiting.clear();\n\t\t};\n\t}\n\n\tget closed(): boolean {\n\t\treturn this.isClosed;\n\t}\n\n\t/** Resolves true once the engine's first frame is here, false if the mount closed first. */\n\tfirstFrame(): Promise<boolean> {\n\t\tif (this.framed) return Promise.resolve(true);\n\t\tif (this.isClosed) return Promise.resolve(false);\n\t\treturn new Promise((resolve) => this.waiting.add(resolve));\n\t}\n\n\tonClose(listener: () => void): () => void {\n\t\tif (this.isClosed) {\n\t\t\tlistener();\n\t\t\treturn () => {};\n\t\t}\n\t\tthis.closeListeners.add(listener);\n\t\treturn () => this.closeListeners.delete(listener);\n\t}\n\n\t/** @internal The controller closed it. */\n\tmarkClosed(): void {\n\t\tif (this.isClosed) return;\n\t\tthis.isClosed = true;\n\t\tfor (const resolve of [...this.waiting]) resolve(false);\n\t\tthis.waiting.clear();\n\t\tfor (const listener of [...this.closeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t\tthis.closeListeners.clear();\n\t}\n}\n\nconst transcriptMounts = new WeakMap<object, Map<string, RemoteTranscriptMount>>();\n\n/** The transcript the engine of `runtime` opened for view `viewId`, while it is open. */\nexport function remoteTranscriptMount(runtime: object, viewId: string): RemoteTranscriptMount | undefined {\n\treturn transcriptMounts.get(runtime)?.get(viewId);\n}\n\nfunction renderSettingsCacheKey(renderSettings: EngineHostRenderSettings | undefined): string {\n\treturn renderSettings === undefined\n\t\t? \"\"\n\t\t: `${renderSettings.hideThinkingBlock}|${renderSettings.toolOutputExpanded}|${renderSettings.fullscreenScrollbar}|${renderSettings.fullscreenWheelScrollLines}`;\n}\n\nfunction overlayOptions(options: SerializableOverlayOptions | undefined): OverlayOptions | undefined {\n\treturn options as OverlayOptions | undefined;\n}\n\n/**\n * Resolve the real host terminal from the pi-tui TUI handed to the overlay\n * factory. Optional: some hosts / test seams do not surface `tui.terminal`, in\n * which case terminal-mode controls harmlessly no-op.\n */\nfunction hostTerminal(tui: TUI): { write(data: string): void } {\n\tconst terminal = (tui as { terminal?: { write?(data: string): void } }).terminal;\n\treturn typeof terminal?.write === \"function\" ? (terminal as { write(data: string): void }) : { write: () => {} };\n}\n\nexport interface TuiRendererLifecycle {\n\tisFullscreen(): boolean;\n\tonRendererReplaced(listener: () => void): () => void;\n\t/** What the host's own chat shows; transcripts the engine paints in its overlays and widgets follow it. */\n\tchatRenderSettings?(): EngineHostRenderSettings;\n}\n\nexport class RemoteComponentController {\n\tprivate readonly mounted = new Map<string, MountedRemoteComponent>();\n\tprivate readonly unsubscribe: () => void;\n\tprivate readonly unsubscribeGenerationEnded: () => void;\n\tprivate readonly terminalModes: TerminalModeController;\n\tprivate readonly unsubscribeTuiRendererReplaced: () => void;\n\n\tprivate readonly runtime: RemoteComponentRuntime;\n\tprivate readonly ui: RemoteComponentUI;\n\tprivate readonly copyText: (text: string) => Promise<void>;\n\tprivate readonly tuiRendererLifecycle: TuiRendererLifecycle;\n\n\tconstructor(\n\t\truntime: RemoteComponentRuntime,\n\t\tui: RemoteComponentUI,\n\t\ttuiRendererLifecycle: TuiRendererLifecycle,\n\t\tcopyText: (text: string) => Promise<void> = copyToClipboard,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\n\t\tthis.copyText = copyText;\n\t\tthis.tuiRendererLifecycle = tuiRendererLifecycle;\n\t\tthis.terminalModes = new TerminalModeController(() => tuiRendererLifecycle.isFullscreen());\n\t\tthis.unsubscribeTuiRendererReplaced = tuiRendererLifecycle.onRendererReplaced(() =>\n\t\t\tthis.terminalModes.rebindTui(),\n\t\t);\n\t\tthis.unsubscribe = runtime.onEngineMessage((message) => this.handleMessage(message));\n\t\t// Teardown is driven by engine death rather than the NEXT generation's\n\t\t// `engine_ready`, so a crash with no restart, or a hung/failed restart,\n\t\t// still releases the host editor, focus, and inline-custom-UI depth.\n\t\tthis.unsubscribeGenerationEnded = runtime.onGenerationEnded(() => this.disposeAll(\"generation-lost\"));\n\t}\n\n\tdispose(): void {\n\t\tthis.unsubscribeTuiRendererReplaced();\n\t\tthis.unsubscribe();\n\t\tthis.unsubscribeGenerationEnded();\n\t\tthis.disposeAll(\"host-shutdown\");\n\t}\n\n\t/** The mode of the host's current renderer, which engine components lay themselves out for. */\n\tprivate hostMode(): TuiMode {\n\t\treturn this.tuiRendererLifecycle.isFullscreen() ? \"fullscreen\" : \"regular\";\n\t}\n\n\t/** The remote overlay proxy that currently holds focus (see remote-input-ownership.ts). */\n\tfocusedRemoteOverlay(): unknown {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.handle?.isFocused() === true) return record.component;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** `component` itself when it is one of this generation's live non-widget proxies. */\n\tremoteProxyOwner(component: unknown): unknown {\n\t\tif (!(component instanceof RemoteComponent)) return undefined;\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component === component)\n\t\t\t\treturn record.widgetKey === undefined && record.transcript === undefined ? component : undefined;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/** True when the extension that mounted `component` declared it binds Ctrl+C. */\n\tremoteProxyHandlesCtrlC(component: unknown): boolean {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component === component) return record.handlesCtrlC;\n\t\t}\n\t\treturn false;\n\t}\n\n\t/**\n\t * Close exactly one live proxy through the ordinary host close path.\n\t *\n\t * The host escape from a component that traps Ctrl+C, and deliberately not\n\t * `disposeAll()`: that is generation-death teardown, which would also close\n\t * unrelated nested components and suppress the child notification. Here the\n\t * record stays registered while `done` runs, so `showExtensionCustom()`\n\t * hides this overlay (or remounts the editor) and its finalizer disposes the\n\t * proxy normally — which tells the healthy child to resolve its own\n\t * `ui.custom()` promise with `undefined`, exactly like a user cancel.\n\t */\n\tdismissRemoteProxy(component: unknown): boolean {\n\t\tfor (const record of this.mounted.values()) {\n\t\t\tif (record.component !== component || record.widgetKey !== undefined || record.transcript !== undefined)\n\t\t\t\tcontinue;\n\t\t\trecord.done(undefined);\n\t\t\tthis.ui.requestRender();\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\n\tprivate releaseWidget(widgetKey: string): void {\n\t\tfor (const [componentId, record] of this.mounted) {\n\t\t\tif (record.widgetKey !== widgetKey) continue;\n\t\t\tthis.mounted.delete(componentId);\n\t\t\trecord.unsubscribeWidgetRelease?.();\n\t\t\trecord.unsubscribeWidgetRelease = undefined;\n\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t}\n\t}\n\t/**\n\t * Close every mounted component.\n\t *\n\t * `\"generation-lost\"` closes through the real host close path: it hides the\n\t * overlay or remounts the editor into `editorContainer`, restores the saved\n\t * draft and focus, releases `blockingInlineCustomUiDepth`, and resolves the\n\t * extension's `ui.custom()` promise. Records are removed BEFORE each `done`\n\t * runs so the settlement path cannot re-enter the controller, and proxy\n\t * disposal is local-only because the writer already points at a replacement\n\t * child whose component IDs restart at `remote_component_1`.\n\t *\n\t * Order is newest-first, matching the TUI's overlay stack. Closing oldest\n\t * first would let an overlay mounted above an inline proxy restore focus to\n\t * that inline proxy after it had already been disposed.\n\t *\n\t * `\"host-shutdown\"` notifies the still-live engine child instead and leaves\n\t * host mounts alone: the TUI is already stopping and must not repaint.\n\t */\n\tprivate disposeAll(reason: \"generation-lost\" | \"host-shutdown\"): void {\n\t\tconst records = [...this.mounted.entries()].reverse();\n\t\tthis.mounted.clear();\n\t\tfor (const [componentId, record] of records) {\n\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t\trecord.unsubscribeWidgetRelease?.();\n\t\t\trecord.component.dispose(reason === \"host-shutdown\" && !record.engineDone);\n\t\t\tif (record.transcript) this.closeTranscript(record.transcript);\n\t\t\telse if (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\t\telse if (reason === \"generation-lost\") record.done(undefined);\n\t\t}\n\t\tthis.terminalModes.resetAll();\n\t\tif (reason === \"generation-lost\" && records.length > 0) this.ui.requestRender();\n\t}\n\n\tprivate handleMessage(message: InteractiveEngineMessage): void {\n\t\tswitch (message.type) {\n\t\t\tcase \"engine_ready\":\n\t\t\t\t// Idempotent fallback for a generation replacement whose death event\n\t\t\t\t// was already handled: stale records must be gone before the new child\n\t\t\t\t// can reuse `remote_component_1`, and any terminal modes the dead\n\t\t\t\t// generation left on are reset here too.\n\t\t\t\tthis.disposeAll(\"generation-lost\");\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_open\":\n\t\t\t\tthis.open(\n\t\t\t\t\tmessage.componentId,\n\t\t\t\t\tmessage.overlay,\n\t\t\t\t\tmessage.deferInlineCustomUiFocus,\n\t\t\t\t\tmessage.overlayOptions,\n\t\t\t\t\tmessage.widgetKey,\n\t\t\t\t\tmessage.widgetPlacement,\n\t\t\t\t\tmessage.handlesCtrlC === true,\n\t\t\t\t\tmessage.handlesInternalUiAction === true,\n\t\t\t\t\tmessage.reserveTranscriptRows === true,\n\t\t\t\t\tmessage.purpose,\n\t\t\t\t\tmessage.widgetScroll,\n\t\t\t\t\tmessage.blocked,\n\t\t\t\t\tmessage.placement === \"transcript\" ? message.viewId : undefined,\n\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_close\":\n\t\t\t\tthis.close(message.componentId);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_frame\":\n\t\t\t\tthis.mounted\n\t\t\t\t\t.get(message.componentId)\n\t\t\t\t\t?.component.applyFrame(\n\t\t\t\t\t\tmessage.requestId,\n\t\t\t\t\t\tmessage.lines,\n\t\t\t\t\t\tmessage.scrollRequest,\n\t\t\t\t\t\tmessage.frame,\n\t\t\t\t\t\tmessage.rowKeys,\n\t\t\t\t\t\tmessage.layout,\n\t\t\t\t\t);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_input_result\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.resolveInput(message.requestId, message.handled);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_invalidate\":\n\t\t\t\tthis.mounted.get(message.componentId)?.component.requestRemoteRender();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_copy\":\n\t\t\t\tvoid (async () => {\n\t\t\t\t\tlet error: string | undefined;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tif (!this.mounted.has(message.componentId)) throw new Error(\"Sign-in screen is no longer open\");\n\t\t\t\t\t\tawait this.copyText(message.text);\n\t\t\t\t\t} catch (cause) {\n\t\t\t\t\t\terror = cause instanceof Error ? cause.message : String(cause);\n\t\t\t\t\t}\n\t\t\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\t\t\ttype: \"engine_custom_copy_result\",\n\t\t\t\t\t\tcomponentId: message.componentId,\n\t\t\t\t\t\trequestId: message.requestId,\n\t\t\t\t\t\terror,\n\t\t\t\t\t});\n\t\t\t\t})();\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_terminal\":\n\t\t\t\tthis.terminalModes.applyControl(message.componentId, message.control);\n\t\t\t\tbreak;\n\t\t\tcase \"engine_custom_done\": {\n\t\t\t\tconst record = this.mounted.get(message.componentId);\n\t\t\t\tif (record) {\n\t\t\t\t\trecord.engineDone = true;\n\t\t\t\t\trecord.done(message.result);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase \"engine_custom_control\":\n\t\t\t\tthis.control(message.componentId, message.action);\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\tprivate open(\n\t\tcomponentId: string,\n\t\toverlay: boolean,\n\t\tdeferInlineCustomUiFocus: boolean | undefined,\n\t\toptions: SerializableOverlayOptions | undefined,\n\t\twidgetKey?: string,\n\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\",\n\t\thandlesCtrlC = false,\n\t\thandlesInternalUiAction = false,\n\t\treserveTranscriptRows = false,\n\t\tpurpose?: \"prompt\" | \"navigation\",\n\t\twidgetScroll?: { maxHeight: number; maxHeightFraction?: number },\n\t\tblocked?: EngineBlockedStatus,\n\t\ttranscriptViewId?: string,\n\t): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tif (transcriptViewId !== undefined) {\n\t\t\tthis.openTranscript(componentId, transcriptViewId);\n\t\t\treturn;\n\t\t}\n\t\tif (widgetKey) {\n\t\t\tlet getRows = () => 24;\n\t\t\tlet paintNow = () => this.ui.requestRender();\n\t\t\tconst component = new RemoteComponent(\n\t\t\t\tcomponentId,\n\t\t\t\tthis.runtime,\n\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t() => getRows(),\n\t\t\t\t() => this.hostMode(),\n\t\t\t\thandlesInternalUiAction,\n\t\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t\t\t() => paintNow(),\n\t\t\t);\n\t\t\tconst unsubscribeWidgetRelease = this.ui.onWidgetRelease?.(widgetKey, () => this.releaseWidget(widgetKey));\n\t\t\tthis.mounted.set(componentId, {\n\t\t\t\tcomponent,\n\t\t\t\tdone: () => {},\n\t\t\t\tengineDone: false,\n\t\t\t\thandlesCtrlC,\n\t\t\t\thandlesInternalUiAction,\n\t\t\t\twidgetKey,\n\t\t\t\tunsubscribeWidgetRelease,\n\t\t\t});\n\t\t\tthis.ui.setWidget(\n\t\t\t\twidgetKey,\n\t\t\t\t(tui) => {\n\t\t\t\t\tcomponent.hostColorDepth = tui.terminal?.colorDepth;\n\t\t\t\t\tgetRows = () => tui.terminal.rows;\n\t\t\t\t\tpaintNow = () => tui.requestImmediateRender();\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{ placement: widgetPlacement, ...(widgetScroll ? { scroll: widgetScroll } : {}) },\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tlet mounted: MountedRemoteComponent | undefined;\n\t\tvoid this.ui\n\t\t\t.custom<JsonValue | undefined>(\n\t\t\t\t(tui, _theme, _keybindings, done) => {\n\t\t\t\t\tconst component = new RemoteComponent(\n\t\t\t\t\t\tcomponentId,\n\t\t\t\t\t\tthis.runtime,\n\t\t\t\t\t\t() => this.ui.requestRender(),\n\t\t\t\t\t\t() => tui.terminal.rows,\n\t\t\t\t\t\t() => this.hostMode(),\n\t\t\t\t\t\thandlesInternalUiAction,\n\t\t\t\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t\t\t\t\t() => tui.requestImmediateRender(),\n\t\t\t\t\t);\n\t\t\t\t\tcomponent.hostColorDepth = tui.terminal?.colorDepth;\n\t\t\t\t\t// In the prompt's place, the rows there stay until its first frame is here.\n\t\t\t\t\tif (!overlay) awaitFirstContent(component, () => component.awaitingFirstContent());\n\t\t\t\t\tmounted = { component, done, engineDone: false, handlesCtrlC, handlesInternalUiAction };\n\t\t\t\t\tthis.mounted.set(componentId, mounted);\n\t\t\t\t\t// Bind this component to the real host terminal so a buffered\n\t\t\t\t\t// autowrap control emitted before the mount frame applies to the host TTY.\n\t\t\t\t\tthis.terminalModes.onMount(componentId, hostTerminal(tui));\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\toverlay,\n\t\t\t\t\tpurpose,\n\t\t\t\t\tdeferInlineCustomUiFocus,\n\t\t\t\t\thandlesInternalUiAction,\n\t\t\t\t\treserveTranscriptRows,\n\t\t\t\t\toverlayOptions: overlayOptions(options),\n\t\t\t\t\tblocked,\n\t\t\t\t\tonHandle: (handle) => {\n\t\t\t\t\t\tif (mounted) mounted.handle = handle;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t)\n\t\t\t.catch(() => undefined)\n\t\t\t.finally(() => {\n\t\t\t\tthis.terminalModes.onUnmount(componentId);\n\t\t\t\tconst record = this.mounted.get(componentId);\n\t\t\t\tif (!record) return;\n\t\t\t\tthis.mounted.delete(componentId);\n\t\t\t\tif (record.engineDone) record.component.dispose(false);\n\t\t\t\telse record.component.dispose();\n\t\t\t});\n\t}\n\n\tprivate close(componentId: string): void {\n\t\tconst record = this.mounted.get(componentId);\n\t\tif (!record) return;\n\t\tthis.terminalModes.onUnmount(componentId);\n\t\tthis.mounted.delete(componentId);\n\t\trecord.unsubscribeWidgetRelease?.();\n\t\tif (record.transcript) this.closeTranscript(record.transcript);\n\t\telse if (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\trecord.component.dispose();\n\t}\n\n\t/**\n\t * A viewed subagent's transcript: drawn by the host's transcript area at the rows it gives, never mounted as custom\n\t * UI, so it blocks nothing and takes focus only when the area gives it.\n\t */\n\tprivate openTranscript(componentId: string, viewId: string): void {\n\t\tlet mount: RemoteTranscriptMount | undefined;\n\t\tconst component = new RemoteComponent(\n\t\t\tcomponentId,\n\t\t\tthis.runtime,\n\t\t\t() => this.ui.requestRender(),\n\t\t\t() => mount?.rows ?? 24,\n\t\t\t() => this.hostMode(),\n\t\t\tfalse,\n\t\t\t() => this.tuiRendererLifecycle.chatRenderSettings?.(),\n\t\t);\n\t\tmount = new RemoteTranscriptMount(componentId, viewId, component);\n\t\tconst views = transcriptMounts.get(this.runtime) ?? new Map<string, RemoteTranscriptMount>();\n\t\ttranscriptMounts.set(this.runtime, views);\n\t\tviews.get(viewId)?.markClosed();\n\t\tviews.set(viewId, mount);\n\t\tthis.mounted.set(componentId, {\n\t\t\tcomponent,\n\t\t\tdone: () => {},\n\t\t\tengineDone: false,\n\t\t\thandlesCtrlC: false,\n\t\t\thandlesInternalUiAction: false,\n\t\t\ttranscript: mount,\n\t\t});\n\t}\n\n\tprivate closeTranscript(mount: RemoteTranscriptMount): void {\n\t\tconst views = transcriptMounts.get(this.runtime);\n\t\tif (views?.get(mount.viewId) === mount) views.delete(mount.viewId);\n\t\tmount.markClosed();\n\t\tthis.ui.requestRender();\n\t}\n\n\tprivate control(componentId: string, action: \"focus\" | \"hide\" | \"show\" | \"unfocus\"): void {\n\t\tconst handle = this.mounted.get(componentId)?.handle;\n\t\tif (!handle) return;\n\t\tswitch (action) {\n\t\t\tcase \"focus\":\n\t\t\t\thandle.focus();\n\t\t\t\tbreak;\n\t\t\tcase \"hide\":\n\t\t\t\thandle.setHidden(true);\n\t\t\t\tbreak;\n\t\t\tcase \"show\":\n\t\t\t\thandle.setHidden(false);\n\t\t\t\tbreak;\n\t\t\tcase \"unfocus\":\n\t\t\t\thandle.unfocus();\n\t\t\t\tbreak;\n\t\t}\n\t}\n}\n"]}
@@ -2,6 +2,7 @@ import type { Component } from "@bastani/atomic-tui";
2
2
  import type { CustomMessage } from "../../core/messages.ts";
3
3
  import type { ToolGroupRole } from "../interactive/components/tool-block.ts";
4
4
  import type { ToolExecutionComponent } from "../interactive/components/tool-execution.ts";
5
+ import { type ToolGroupHead } from "../interactive/components/tool-group-tracker.ts";
5
6
  import { type RowRange } from "../interactive/components/transcript-block-clicks.ts";
6
7
  import type { IsolatedInteractiveRuntime } from "./isolated-runtime.js";
7
8
  import type { InteractiveEngineCommand, InteractiveEngineMessage } from "./protocol.ts";
@@ -83,6 +84,9 @@ export declare class RemoteToolExecutionComponent extends RemoteRenderer {
83
84
  private executionStartedAt;
84
85
  private argsComplete;
85
86
  private groupRole;
87
+ private groupHead;
88
+ /** Whether the last frame asked of the engine draws this call on its own, apart from its group. */
89
+ private requestedApart;
86
90
  private isPartial;
87
91
  private showImages;
88
92
  private imageWidthCells;
@@ -98,6 +102,12 @@ export declare class RemoteToolExecutionComponent extends RemoteRenderer {
98
102
  markExecutionStarted(startedAt?: number): void;
99
103
  setArgsComplete(): void;
100
104
  setGroupRole(role: ToolGroupRole): void;
105
+ /** The first call of the group this call is folded into, which stands for it while both have one expansion. */
106
+ setGroupHead(head: ToolGroupHead | undefined): void;
107
+ /** Whether this call, folded into a group, is drawn and clicked on its own: see `drawsApartFromGroup`. */
108
+ drawsApart(): boolean;
109
+ /** The place in its group the engine draws this call at: on its own while it is drawn apart from its group. */
110
+ private drawnGroupRole;
101
111
  render(width: number): string[];
102
112
  updateResult(result: RenderableToolResult, isPartial?: boolean): void;
103
113
  getGroupRole(): ToolGroupRole;
@@ -1 +1 @@
1
- {"version":3,"file":"remote-renderer.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAG5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AAE1F,OAAO,EAAE,KAAK,QAAQ,EAAsB,MAAM,sDAAsD,CAAC;AACzG,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AACxE,OAAO,KAAK,EAAE,wBAAwB,EAAE,wBAAwB,EAAyB,MAAM,eAAe,CAAC;AAG/G,KAAK,oBAAoB,GAAG,UAAU,CAAC,sBAAsB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClF,KAAK,mBAAmB,GAAG,OAAO,CAAC,wBAAwB,EAAE;IAAE,IAAI,EAAE,oBAAoB,GAAG,uBAAuB,CAAA;CAAE,CAAC,CAAC;AAwBvH;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,OAAQ,CAAC;AA4C9C,0FAA0F;AAC1F,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS,CAEjF;AACD,uBAAe,cAAe,YAAW,SAAS;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G,SAAS,CAE7C;IACD,aAAa,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,CAGjC;IACD,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAGtC;IAED,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAuBvE;IAED,SAAS,CAAC,aAAa,IAAI,MAAM,CAShC;CACD;AAED,qBAAa,4BAA6B,SAAQ,cAAc;IAC/D,QAAQ,CAAC,iBAAiB,QAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAS;IAC3C,OAAO,CAAC,aAAa,CAAqB;IAC1C,OAAO,CAAC,SAAS,CAAS;IAC1B,YACC,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,EAC/B,OAAO,EAAE,0BAA0B,EACnC,aAAa,EAAE,MAAM,IAAI,EACzB,SAAS,SAAI,EAMb;IAED;;;OAGG;IACH,QAAQ,CAAC,cAAc,QAAQ;IAC/B,oFAAoF;IACpF,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE7C;IACD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAGpC;IAED,SAAS,CAAC,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAYvE;IAED,SAAS,CAAC,aAAa,IAAI,MAAM,CAShC;CACD"}
@@ -2,7 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { isProxy } from "node:util/types";
3
3
  import { savedReadLines } from "../../core/storage/session/saved-read-summary.js";
4
4
  import { reopenedCompletionName } from "../../core/tasks/reopened-completion.js";
5
- import { sameToolGroupRole, toolGroupRoleKey } from "../interactive/components/tool-group-tracker.js";
5
+ import { drawsApartFromGroup, sameToolGroupRole, toolGroupRoleKey, } from "../interactive/components/tool-group-tracker.js";
6
6
  import { rowsFrom, sameRows } from "../interactive/components/transcript-block-clicks.js";
7
7
  import { RemoteFrameWidthClamp } from "./remote-frame-clamp.js";
8
8
  let nextRemoteRendererId = 0;
@@ -286,6 +286,9 @@ export class RemoteToolExecutionComponent extends RemoteRenderer {
286
286
  executionStartedAt;
287
287
  argsComplete = false;
288
288
  groupRole = { kind: "standalone" };
289
+ groupHead;
290
+ /** Whether the last frame asked of the engine draws this call on its own, apart from its group. */
291
+ requestedApart = false;
289
292
  isPartial = true;
290
293
  showImages;
291
294
  imageWidthCells;
@@ -327,8 +330,25 @@ export class RemoteToolExecutionComponent extends RemoteRenderer {
327
330
  this.groupRole = role;
328
331
  this.changed();
329
332
  }
333
+ /** The first call of the group this call is folded into, which stands for it while both have one expansion. */
334
+ setGroupHead(head) {
335
+ this.groupHead = head;
336
+ }
337
+ /** Whether this call, folded into a group, is drawn and clicked on its own: see `drawsApartFromGroup`. */
338
+ drawsApart() {
339
+ return drawsApartFromGroup(this.groupRole, this.expanded, this.groupHead);
340
+ }
341
+ /** The place in its group the engine draws this call at: on its own while it is drawn apart from its group. */
342
+ drawnGroupRole() {
343
+ return this.requestedApart ? { kind: "standalone" } : this.groupRole;
344
+ }
330
345
  render(width) {
331
- if (!this.expanded && this.groupRole.kind === "hidden")
346
+ const apart = this.drawsApart();
347
+ if (apart !== this.requestedApart) {
348
+ this.requestedApart = apart;
349
+ this.invalidate();
350
+ }
351
+ if (!this.expanded && this.groupRole.kind === "hidden" && !apart)
332
352
  return [];
333
353
  return super.render(width);
334
354
  }
@@ -373,7 +393,7 @@ export class RemoteToolExecutionComponent extends RemoteRenderer {
373
393
  showImages: this.showImages,
374
394
  imageWidthCells: this.imageWidthCells,
375
395
  outputPad: this.outputPad,
376
- ...(this.groupRole.kind === "standalone" ? {} : { groupRole: this.groupRole }),
396
+ ...(this.drawnGroupRole().kind === "standalone" ? {} : { groupRole: this.drawnGroupRole() }),
377
397
  };
378
398
  }
379
399
  frameIdentity() {
@@ -383,7 +403,7 @@ export class RemoteToolExecutionComponent extends RemoteRenderer {
383
403
  this.toolName,
384
404
  this.toolCallId,
385
405
  this.expanded,
386
- toolGroupRoleKey(this.groupRole),
406
+ toolGroupRoleKey(this.drawnGroupRole()),
387
407
  ]);
388
408
  }
389
409
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remote-renderer.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAGjF,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iDAAiD,CAAC;AACtG,OAAO,EAAiB,QAAQ,EAAE,QAAQ,EAAE,MAAM,sDAAsD,CAAC;AAGzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,IAAI,oBAAoB,GAAG,CAAC,CAAC;AAC7B,IAAI,kBAAkB,GAAG,CAAC,CAAC;AAC3B,MAAM,eAAe,GAAG,IAAI,OAAO,EAAsC,CAAC;AAE1E,SAAS,iBAAiB,CAAC,OAAmC;IAC7D,IAAI,EAAE,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACtB,EAAE,GAAG,EAAE,kBAAkB,CAAC;QAC1B,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,SAA6B,CAAC;IAClC,IAAI,CAAC;QACJ,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,YAAY,EAAE,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACR,SAAS,GAAG,SAAS,CAAC;IACvB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AAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;aAC1E,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACtC,OAAO,OAAO,KAAK,SAAS;YAC3B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzF,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACrG,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isProxy } from \"node:util/types\";\nimport type { Component } from \"@bastani/atomic-tui\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport { savedReadLines } from \"../../core/storage/session/saved-read-summary.js\";\nimport { reopenedCompletionName } from \"../../core/tasks/reopened-completion.js\";\nimport type { ToolGroupRole } from \"../interactive/components/tool-block.ts\";\nimport type { ToolExecutionComponent } from \"../interactive/components/tool-execution.ts\";\nimport { sameToolGroupRole, toolGroupRoleKey } from \"../interactive/components/tool-group-tracker.ts\";\nimport { type RowRange, rowsFrom, sameRows } from \"../interactive/components/transcript-block-clicks.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { InteractiveEngineCommand, InteractiveEngineMessage, JsonObject, JsonValue } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ntype RenderableToolResult = Parameters<ToolExecutionComponent[\"updateResult\"]>[0];\ntype RemoteRenderCommand = Extract<InteractiveEngineCommand, { type: \"engine_tool_render\" | \"engine_message_render\" }>;\n\nlet nextRemoteRendererId = 0;\nlet nextRuntimeScopeId = 0;\nconst runtimeScopeIds = new WeakMap<IsolatedInteractiveRuntime, number>();\n\nfunction runtimeFrameScope(runtime: IsolatedInteractiveRuntime): string {\n\tlet id = runtimeScopeIds.get(runtime);\n\tif (id === undefined) {\n\t\tid = ++nextRuntimeScopeId;\n\t\truntimeScopeIds.set(runtime, id);\n\t}\n\tlet sessionId: string | undefined;\n\ttry {\n\t\tsessionId = runtime.session.sessionManager.getSessionId();\n\t} catch {\n\t\tsessionId = undefined;\n\t}\n\treturn JSON.stringify([id, sessionId]);\n}\n\n/** A row the engine has not rendered yet draws nothing, rather than a placeholder that flickers in and out. */\nconst NOT_RENDERED_YET: string[] = [];\n\n/**\n * How many rows' last frames are kept, by row identity (a tool call, a custom message), to repaint rebuilt rows. A chat\n * rebuild (compaction, `/reload`, a switched session) recreates every row, and each new row waits for the engine to\n * render it. Showing the row's last frame meanwhile keeps the rebuilt chat painted, instead of a screen of placeholders\n * that lasts as long as the engine is busy.\n */\nexport const REMOTE_FRAME_CACHE_LIMIT = 2_000;\nconst recentFrames = new Map<string, string[]>();\n\nfunction rememberFrame(key: string, lines: string[]): void {\n\trecentFrames.delete(key);\n\trecentFrames.set(key, lines);\n\tif (recentFrames.size > REMOTE_FRAME_CACHE_LIMIT) {\n\t\tconst oldest = recentFrames.keys().next().value;\n\t\tif (oldest !== undefined) recentFrames.delete(oldest);\n\t}\n}\n\ninterface RendererRoutes {\n\trows: Map<string, RemoteRenderer>;\n\tclicks: AbortController;\n}\n\n/** One subscription per runtime, routed by component id, however many rows the chat holds. */\nconst routesByRuntime = new WeakMap<IsolatedInteractiveRuntime, RendererRoutes>();\n\nfunction rendererRoutes(runtime: IsolatedInteractiveRuntime): RendererRoutes {\n\tlet routes = routesByRuntime.get(runtime);\n\tif (routes === undefined) {\n\t\tconst created: RendererRoutes = { rows: new Map(), clicks: new AbortController() };\n\t\truntime.onGenerationEnded?.(({ generation }) => {\n\t\t\tif (generation === runtime.getEngineGeneration()) created.clicks.abort();\n\t\t});\n\t\truntime.onEngineMessage((message) => {\n\t\t\tif (message.type === \"engine_bound\" && created.clicks.signal.aborted) created.clicks = new AbortController();\n\t\t\tif (\"componentId\" in message) created.rows.get(message.componentId)?.receive(message);\n\t\t});\n\t\troutesByRuntime.set(runtime, created);\n\t\troutes = created;\n\t}\n\treturn routes;\n}\n\nfunction jsonValue(value: unknown): JsonValue {\n\tif (value === undefined) return null;\n\tconst encoded = JSON.stringify(value);\n\treturn encoded === undefined ? null : (JSON.parse(encoded) as JsonValue);\n}\n\nconst remoteRows = new WeakSet<Component>();\n/** Identify our renderer without walking an opaque extension widget's prototype chain. */\nexport function remoteHistoryRow(component: Component): RemoteRenderer | undefined {\n\treturn remoteRows.has(component) ? (component as RemoteRenderer) : undefined;\n}\nabstract class RemoteRenderer implements Component {\n\treadonly selectionTextMayChangeOnReplay = true;\n\tprivate inspectHistoryReplay = false;\n\tprivate canReplay = false;\n\tprivate releaseIfRetired?: () => void;\n\tget historyReplayable(): boolean {\n\t\tthis.inspectHistoryReplay = true;\n\t\treturn this.canReplay;\n\t}\n\tonReplayabilityChange(release: () => void): void {\n\t\tthis.releaseIfRetired = release;\n\t}\n\tget unrendered(): boolean {\n\t\treturn this.requestId === 0;\n\t}\n\tprotected readonly componentId = `remote_renderer_${++nextRemoteRendererId}`;\n\tprivate lines = NOT_RENDERED_YET;\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\tprivate readonly routes: RendererRoutes;\n\t/**\n\t * What each unanswered request showed (its frame identity, expansion included), by request id. A frame is\n\t * remembered under the identity of the request it answers, not under the row's state when it arrives: a row\n\t * collapsed while its expanded frame was in flight must not have that frame remembered as its collapsed one.\n\t */\n\tprivate readonly requestIdentities = new Map<number, string>();\n\tprivate readonly requestScopes = new Map<number, string>();\n\tprivate lastScope: string | undefined;\n\t/** Each settled click compares both expansions at its own width and data revision. Only the front request is in flight. */\n\tprivate readonly clickChecks: { command: RemoteRenderCommand; baseline?: string[]; changed(): void }[] = [];\n\tprivate toggleAfterChecks = false;\n\tprivate clickCancellation?: AbortSignal;\n\tprotected expanded = false;\n\n\tprotected readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, requestRender: () => void) {\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tremoteRows.add(this);\n\t\tthis.routes = rendererRoutes(runtime);\n\t\tthis.routes.rows.set(this.componentId, this);\n\t}\n\n\t/** An engine message addressed to this row. */\n\treceive(message: InteractiveEngineMessage): void {\n\t\tif (message.type === \"engine_custom_frame\") {\n\t\t\tconst check = this.clickChecks[0];\n\t\t\tif (check && message.requestId === check.command.requestId) {\n\t\t\t\tif (runtimeFrameScope(this.runtime) !== this.lastScope) {\n\t\t\t\t\tthis.clearClickChecks();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// An older engine sends only the requested rows. Ask it for the other expansion of the same snapshot.\n\t\t\t\tif (message.expansionChangesRows === undefined && check.baseline === undefined) {\n\t\t\t\t\tcheck.baseline = message.lines;\n\t\t\t\t\tcheck.command = { ...check.command, requestId: ++this.requestId, expanded: !check.command.expanded };\n\t\t\t\t\tthis.runtime.sendEngineCommand(check.command);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.expansionChangesRows ?? !sameRows(check.baseline!, message.lines)) {\n\t\t\t\t\tthis.toggleAfterChecks = !this.toggleAfterChecks;\n\t\t\t\t}\n\t\t\t\tthis.clickChecks.shift();\n\t\t\t\tconst next = this.clickChecks[0];\n\t\t\t\tif (next) this.runtime.sendEngineCommand(next.command);\n\t\t\t\telse {\n\t\t\t\t\tif (this.toggleAfterChecks) {\n\t\t\t\t\t\tthis.setExpanded(!this.expanded);\n\t\t\t\t\t\tcheck.changed();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.clearClickChecks();\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.requestId < this.appliedRequestId) return;\n\t\t\tconst identity = this.requestIdentities.get(message.requestId);\n\t\t\tconst scope = this.requestScopes.get(message.requestId);\n\t\t\tif (identity === undefined || scope === undefined) return;\n\t\t\tfor (const requestId of this.requestIdentities.keys()) {\n\t\t\t\tif (requestId > message.requestId) continue;\n\t\t\t\tthis.requestIdentities.delete(requestId);\n\t\t\t\tthis.requestScopes.delete(requestId);\n\t\t\t}\n\t\t\trememberFrame(identity, message.lines);\n\t\t\tif (scope !== runtimeFrameScope(this.runtime)) return;\n\t\t\tthis.appliedRequestId = message.requestId;\n\t\t\tthis.canReplay = message.historyReplayable === true;\n\t\t\tthis.lines = message.lines;\n\t\t\tif (this.canReplay) this.releaseIfRetired?.();\n\t\t\tthis.requestRender();\n\t\t} else if (message.type === \"engine_custom_invalidate\") {\n\t\t\tthis.changed();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tconst scope = runtimeFrameScope(this.runtime);\n\t\tif (scope !== this.lastScope) {\n\t\t\tthis.lastScope = scope;\n\t\t\tthis.clearClickChecks();\n\t\t\tthis.lines = NOT_RENDERED_YET;\n\t\t\tthis.dirty = true;\n\t\t}\n\t\tif (width !== this.width) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = true;\n\t\t}\n\t\t// Render requests for the same row are coalesced in transit. Do not overwrite an outstanding click check.\n\t\tif (!this.disposed && !this.routes.clicks.signal.aborted && this.dirty && this.clickChecks.length === 0) {\n\t\t\tthis.dirty = false;\n\t\t\t// A row rebuilt for a row the engine already rendered paints its last frame until the fresh one arrives.\n\t\t\tconst identity = JSON.stringify([scope, this.frameIdentity()]);\n\t\t\tif (this.lines === NOT_RENDERED_YET) this.lines = recentFrames.get(identity) ?? NOT_RENDERED_YET;\n\t\t\tthis.requestIdentities.set(++this.requestId, identity);\n\t\t\tthis.requestScopes.set(this.requestId, scope);\n\t\t\tconst request = this.command(this.requestId, width);\n\t\t\tthis.runtime.sendEngineCommand(\n\t\t\t\tthis.inspectHistoryReplay ? { ...request, inspectHistoryReplay: true } : request,\n\t\t\t);\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markDirty();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.releaseIfRetired = undefined;\n\t\tif (this.routes.rows.get(this.componentId) === this) this.routes.rows.delete(this.componentId);\n\t\tthis.requestIdentities.clear();\n\t\tthis.requestScopes.clear();\n\t\tthis.clearClickChecks();\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_render_dispose\", componentId: this.componentId });\n\t}\n\n\tprotected changed(): void {\n\t\tthis.markDirty();\n\t\tthis.requestRender();\n\t}\n\n\tprivate readonly cancelClickChecks = (): void => {\n\t\tthis.clearClickChecks();\n\t\tthis.requestRender();\n\t};\n\n\tprivate readonly clearClickChecks = (): void => {\n\t\tthis.clickCancellation?.removeEventListener(\"abort\", this.cancelClickChecks);\n\t\tthis.clickCancellation = undefined;\n\t\tthis.clickChecks.length = 0;\n\t\tthis.toggleAfterChecks = false;\n\t\tthis.markDirty();\n\t};\n\n\tisExpanded(): boolean {\n\t\treturn this.expanded;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.clearClickChecks(); // An explicit expansion, e.g. Ctrl+O, supersedes outstanding clicks.\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\n\texpandByClick(expanded: boolean, changed: () => void, width = this.width, signal?: AbortSignal): void {\n\t\tif (this.disposed || signal?.aborted || this.routes.clicks.signal.aborted || expanded === this.expanded) return;\n\t\tconst command = { ...this.command(++this.requestId, width), compareExpansion: true as const };\n\t\tthis.clickChecks.push({ command, changed });\n\t\tif (this.clickChecks.length === 1) {\n\t\t\tthis.clickCancellation = signal\n\t\t\t\t? AbortSignal.any([signal, this.routes.clicks.signal])\n\t\t\t\t: this.routes.clicks.signal;\n\t\t\tthis.clickCancellation.addEventListener(\"abort\", this.cancelClickChecks, { once: true });\n\t\t\tthis.runtime.sendEngineCommand(command);\n\t\t}\n\t}\n\n\tprotected abstract command(requestId: number, width: number): RemoteRenderCommand;\n\n\t/** Names what this row shows, the same for every row recreated for it. */\n\tprotected abstract frameIdentity(): string;\n\n\tprivate markDirty(): void {\n\t\tthis.dirty = true;\n\t}\n}\n\n/**\n * Disposes the rows rendered by the engine among `components`, which a cleared chat no longer shows: each one\n * otherwise keeps its renderer alive in the engine for the rest of the session.\n */\nexport function disposeRemoteRenderers(components: readonly Component[]): void {\n\tfor (const component of components) if (component instanceof RemoteRenderer) component.dispose();\n}\n\nexport class RemoteToolExecutionComponent extends RemoteRenderer {\n\treadonly expandsOnClick = true;\n\tprivate readonly toolName: string;\n\tprivate readonly toolCallId: string;\n\tprivate readonly rendererTaskId: string | undefined;\n\tprivate args: unknown;\n\tprivate result: RenderableToolResult | undefined;\n\tprivate executionStarted = false;\n\tprivate executionStartedAt: number | undefined;\n\tprivate argsComplete = false;\n\tprivate groupRole: ToolGroupRole = { kind: \"standalone\" };\n\tprivate isPartial = true;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate outputPad: number;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: { showImages?: boolean; imageWidthCells?: number; outputPad?: number; rendererTaskId?: string },\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.rendererTaskId = options.rendererTaskId;\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.outputPad = options.outputPad ?? 1;\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.changed();\n\t}\n\tmarkExecutionStarted(startedAt?: number): void {\n\t\tif (this.executionStarted) return;\n\t\tthis.executionStarted = true;\n\t\tthis.executionStartedAt = startedAt ?? Date.now();\n\t\tthis.changed();\n\t}\n\tsetArgsComplete(): void {\n\t\tif (this.argsComplete) return;\n\t\tthis.argsComplete = true;\n\t\tthis.changed();\n\t}\n\tsetGroupRole(role: ToolGroupRole): void {\n\t\tif (sameToolGroupRole(this.groupRole, role)) return;\n\t\tthis.groupRole = role;\n\t\tthis.changed();\n\t}\n\toverride render(width: number): string[] {\n\t\tif (!this.expanded && this.groupRole.kind === \"hidden\") return [];\n\t\treturn super.render(width);\n\t}\n\tupdateResult(result: RenderableToolResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.changed();\n\t}\n\tgetGroupRole(): ToolGroupRole {\n\t\treturn this.groupRole;\n\t}\n\t/** Every row of the block: the engine draws it as `ToolExecutionComponent` does, after a blank row. */\n\tclickArea(width: number): RowRange | undefined {\n\t\treturn rowsFrom(1, this.render(width).length);\n\t}\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.changed();\n\t}\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\tconst lines = savedReadLines(this.result?.content);\n\t\treturn {\n\t\t\ttype: \"engine_tool_render\",\n\t\t\t...(lines === undefined ? {} : { savedReadLines: lines }),\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\ttoolName: this.toolName,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\t...(this.rendererTaskId === undefined ? {} : { rendererTaskId: this.rendererTaskId }),\n\t\t\targs: jsonValue(this.args),\n\t\t\tresult: this.result ? (jsonValue(this.result) as JsonObject) : undefined,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\t...(this.executionStartedAt === undefined ? {} : { executionStartedAt: this.executionStartedAt }),\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\toutputPad: this.outputPad,\n\t\t\t...(this.groupRole.kind === \"standalone\" ? {} : { groupRole: this.groupRole }),\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\treturn JSON.stringify([\n\t\t\t\"tool\",\n\t\t\tthis.rendererTaskId,\n\t\t\tthis.toolName,\n\t\t\tthis.toolCallId,\n\t\t\tthis.expanded,\n\t\t\ttoolGroupRoleKey(this.groupRole),\n\t\t]);\n\t}\n}\n\nexport class RemoteCustomMessageComponent extends RemoteRenderer {\n\treadonly ownsLeadingSpacer = true;\n\tprivate readonly message: CustomMessage<unknown>;\n\tprivate readonly reopenedStopName?: string;\n\tprivate contentDigest: string | undefined;\n\tprivate outputPad: number;\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\toutputPad = 1,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.message = message;\n\t\tthis.reopenedStopName = reopenedCompletionName(message, isProxy);\n\t\tthis.outputPad = outputPad;\n\t}\n\n\t/**\n\t * A message expands on a click, as Ctrl+O expands it: the engine draws its card, and a card with nothing more to\n\t * show stays as it is.\n\t */\n\treadonly expandsOnClick = true;\n\t/** Every row of the card: the engine draws it after the blank row it leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\treturn rowsFrom(1, this.render(width).length);\n\t}\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\tconst stopped = this.reopenedStopName;\n\t\treturn {\n\t\t\ttype: \"engine_message_render\",\n\t\t\t...(stopped === undefined ? {} : { reopenedStopName: stopped }),\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\tmessage: jsonValue(this.message) as JsonObject,\n\t\t\texpanded: this.expanded,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\t// Not the timestamp: a message shown live and the same message restored from the session can differ in it.\n\t\tthis.contentDigest ??= createHash(\"sha1\")\n\t\t\t.update(JSON.stringify([this.message.content, this.message.details]) ?? \"\")\n\t\t\t.digest(\"base64\");\n\t\tconst stopped = this.reopenedStopName;\n\t\treturn stopped === undefined\n\t\t\t? JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded])\n\t\t\t: JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded, stopped]);\n\t}\n}\n"]}
1
+ {"version":3,"file":"remote-renderer.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAG1C,OAAO,EAAE,cAAc,EAAE,MAAM,kDAAkD,CAAC;AAClF,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAGjF,OAAO,EACN,mBAAmB,EACnB,iBAAiB,EAEjB,gBAAgB,GAChB,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAiB,QAAQ,EAAE,QAAQ,EAAE,MAAM,sDAAsD,CAAC;AAGzG,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAKhE,IAAI,oBAAoB,GAAG,CAAC,CAAC;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AO,CAAC,CAAC,IAAI,EAAE,CAAC;aAC1E,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnB,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC;QACtC,OAAO,OAAO,KAAK,SAAS;YAC3B,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;YACzF,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;IACrG,CAAC;CACD","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { isProxy } from \"node:util/types\";\nimport type { Component } from \"@bastani/atomic-tui\";\nimport type { CustomMessage } from \"../../core/messages.ts\";\nimport { savedReadLines } from \"../../core/storage/session/saved-read-summary.js\";\nimport { reopenedCompletionName } from \"../../core/tasks/reopened-completion.js\";\nimport type { ToolGroupRole } from \"../interactive/components/tool-block.ts\";\nimport type { ToolExecutionComponent } from \"../interactive/components/tool-execution.ts\";\nimport {\n\tdrawsApartFromGroup,\n\tsameToolGroupRole,\n\ttype ToolGroupHead,\n\ttoolGroupRoleKey,\n} from \"../interactive/components/tool-group-tracker.ts\";\nimport { type RowRange, rowsFrom, sameRows } from \"../interactive/components/transcript-block-clicks.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.js\";\nimport type { InteractiveEngineCommand, InteractiveEngineMessage, JsonObject, JsonValue } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\n\ntype RenderableToolResult = Parameters<ToolExecutionComponent[\"updateResult\"]>[0];\ntype RemoteRenderCommand = Extract<InteractiveEngineCommand, { type: \"engine_tool_render\" | \"engine_message_render\" }>;\n\nlet nextRemoteRendererId = 0;\nlet nextRuntimeScopeId = 0;\nconst runtimeScopeIds = new WeakMap<IsolatedInteractiveRuntime, number>();\n\nfunction runtimeFrameScope(runtime: IsolatedInteractiveRuntime): string {\n\tlet id = runtimeScopeIds.get(runtime);\n\tif (id === undefined) {\n\t\tid = ++nextRuntimeScopeId;\n\t\truntimeScopeIds.set(runtime, id);\n\t}\n\tlet sessionId: string | undefined;\n\ttry {\n\t\tsessionId = runtime.session.sessionManager.getSessionId();\n\t} catch {\n\t\tsessionId = undefined;\n\t}\n\treturn JSON.stringify([id, sessionId]);\n}\n\n/** A row the engine has not rendered yet draws nothing, rather than a placeholder that flickers in and out. */\nconst NOT_RENDERED_YET: string[] = [];\n\n/**\n * How many rows' last frames are kept, by row identity (a tool call, a custom message), to repaint rebuilt rows. A chat\n * rebuild (compaction, `/reload`, a switched session) recreates every row, and each new row waits for the engine to\n * render it. Showing the row's last frame meanwhile keeps the rebuilt chat painted, instead of a screen of placeholders\n * that lasts as long as the engine is busy.\n */\nexport const REMOTE_FRAME_CACHE_LIMIT = 2_000;\nconst recentFrames = new Map<string, string[]>();\n\nfunction rememberFrame(key: string, lines: string[]): void {\n\trecentFrames.delete(key);\n\trecentFrames.set(key, lines);\n\tif (recentFrames.size > REMOTE_FRAME_CACHE_LIMIT) {\n\t\tconst oldest = recentFrames.keys().next().value;\n\t\tif (oldest !== undefined) recentFrames.delete(oldest);\n\t}\n}\n\ninterface RendererRoutes {\n\trows: Map<string, RemoteRenderer>;\n\tclicks: AbortController;\n}\n\n/** One subscription per runtime, routed by component id, however many rows the chat holds. */\nconst routesByRuntime = new WeakMap<IsolatedInteractiveRuntime, RendererRoutes>();\n\nfunction rendererRoutes(runtime: IsolatedInteractiveRuntime): RendererRoutes {\n\tlet routes = routesByRuntime.get(runtime);\n\tif (routes === undefined) {\n\t\tconst created: RendererRoutes = { rows: new Map(), clicks: new AbortController() };\n\t\truntime.onGenerationEnded?.(({ generation }) => {\n\t\t\tif (generation === runtime.getEngineGeneration()) created.clicks.abort();\n\t\t});\n\t\truntime.onEngineMessage((message) => {\n\t\t\tif (message.type === \"engine_bound\" && created.clicks.signal.aborted) created.clicks = new AbortController();\n\t\t\tif (\"componentId\" in message) created.rows.get(message.componentId)?.receive(message);\n\t\t});\n\t\troutesByRuntime.set(runtime, created);\n\t\troutes = created;\n\t}\n\treturn routes;\n}\n\nfunction jsonValue(value: unknown): JsonValue {\n\tif (value === undefined) return null;\n\tconst encoded = JSON.stringify(value);\n\treturn encoded === undefined ? null : (JSON.parse(encoded) as JsonValue);\n}\n\nconst remoteRows = new WeakSet<Component>();\n/** Identify our renderer without walking an opaque extension widget's prototype chain. */\nexport function remoteHistoryRow(component: Component): RemoteRenderer | undefined {\n\treturn remoteRows.has(component) ? (component as RemoteRenderer) : undefined;\n}\nabstract class RemoteRenderer implements Component {\n\treadonly selectionTextMayChangeOnReplay = true;\n\tprivate inspectHistoryReplay = false;\n\tprivate canReplay = false;\n\tprivate releaseIfRetired?: () => void;\n\tget historyReplayable(): boolean {\n\t\tthis.inspectHistoryReplay = true;\n\t\treturn this.canReplay;\n\t}\n\tonReplayabilityChange(release: () => void): void {\n\t\tthis.releaseIfRetired = release;\n\t}\n\tget unrendered(): boolean {\n\t\treturn this.requestId === 0;\n\t}\n\tprotected readonly componentId = `remote_renderer_${++nextRemoteRendererId}`;\n\tprivate lines = NOT_RENDERED_YET;\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\tprivate readonly routes: RendererRoutes;\n\t/**\n\t * What each unanswered request showed (its frame identity, expansion included), by request id. A frame is\n\t * remembered under the identity of the request it answers, not under the row's state when it arrives: a row\n\t * collapsed while its expanded frame was in flight must not have that frame remembered as its collapsed one.\n\t */\n\tprivate readonly requestIdentities = new Map<number, string>();\n\tprivate readonly requestScopes = new Map<number, string>();\n\tprivate lastScope: string | undefined;\n\t/** Each settled click compares both expansions at its own width and data revision. Only the front request is in flight. */\n\tprivate readonly clickChecks: { command: RemoteRenderCommand; baseline?: string[]; changed(): void }[] = [];\n\tprivate toggleAfterChecks = false;\n\tprivate clickCancellation?: AbortSignal;\n\tprotected expanded = false;\n\n\tprotected readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\n\tconstructor(runtime: IsolatedInteractiveRuntime, requestRender: () => void) {\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tremoteRows.add(this);\n\t\tthis.routes = rendererRoutes(runtime);\n\t\tthis.routes.rows.set(this.componentId, this);\n\t}\n\n\t/** An engine message addressed to this row. */\n\treceive(message: InteractiveEngineMessage): void {\n\t\tif (message.type === \"engine_custom_frame\") {\n\t\t\tconst check = this.clickChecks[0];\n\t\t\tif (check && message.requestId === check.command.requestId) {\n\t\t\t\tif (runtimeFrameScope(this.runtime) !== this.lastScope) {\n\t\t\t\t\tthis.clearClickChecks();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// An older engine sends only the requested rows. Ask it for the other expansion of the same snapshot.\n\t\t\t\tif (message.expansionChangesRows === undefined && check.baseline === undefined) {\n\t\t\t\t\tcheck.baseline = message.lines;\n\t\t\t\t\tcheck.command = { ...check.command, requestId: ++this.requestId, expanded: !check.command.expanded };\n\t\t\t\t\tthis.runtime.sendEngineCommand(check.command);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (message.expansionChangesRows ?? !sameRows(check.baseline!, message.lines)) {\n\t\t\t\t\tthis.toggleAfterChecks = !this.toggleAfterChecks;\n\t\t\t\t}\n\t\t\t\tthis.clickChecks.shift();\n\t\t\t\tconst next = this.clickChecks[0];\n\t\t\t\tif (next) this.runtime.sendEngineCommand(next.command);\n\t\t\t\telse {\n\t\t\t\t\tif (this.toggleAfterChecks) {\n\t\t\t\t\t\tthis.setExpanded(!this.expanded);\n\t\t\t\t\t\tcheck.changed();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.clearClickChecks();\n\t\t\t\t\t\tthis.changed();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (message.requestId < this.appliedRequestId) return;\n\t\t\tconst identity = this.requestIdentities.get(message.requestId);\n\t\t\tconst scope = this.requestScopes.get(message.requestId);\n\t\t\tif (identity === undefined || scope === undefined) return;\n\t\t\tfor (const requestId of this.requestIdentities.keys()) {\n\t\t\t\tif (requestId > message.requestId) continue;\n\t\t\t\tthis.requestIdentities.delete(requestId);\n\t\t\t\tthis.requestScopes.delete(requestId);\n\t\t\t}\n\t\t\trememberFrame(identity, message.lines);\n\t\t\tif (scope !== runtimeFrameScope(this.runtime)) return;\n\t\t\tthis.appliedRequestId = message.requestId;\n\t\t\tthis.canReplay = message.historyReplayable === true;\n\t\t\tthis.lines = message.lines;\n\t\t\tif (this.canReplay) this.releaseIfRetired?.();\n\t\t\tthis.requestRender();\n\t\t} else if (message.type === \"engine_custom_invalidate\") {\n\t\t\tthis.changed();\n\t\t}\n\t}\n\n\trender(width: number): string[] {\n\t\tconst scope = runtimeFrameScope(this.runtime);\n\t\tif (scope !== this.lastScope) {\n\t\t\tthis.lastScope = scope;\n\t\t\tthis.clearClickChecks();\n\t\t\tthis.lines = NOT_RENDERED_YET;\n\t\t\tthis.dirty = true;\n\t\t}\n\t\tif (width !== this.width) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = true;\n\t\t}\n\t\t// Render requests for the same row are coalesced in transit. Do not overwrite an outstanding click check.\n\t\tif (!this.disposed && !this.routes.clicks.signal.aborted && this.dirty && this.clickChecks.length === 0) {\n\t\t\tthis.dirty = false;\n\t\t\t// A row rebuilt for a row the engine already rendered paints its last frame until the fresh one arrives.\n\t\t\tconst identity = JSON.stringify([scope, this.frameIdentity()]);\n\t\t\tif (this.lines === NOT_RENDERED_YET) this.lines = recentFrames.get(identity) ?? NOT_RENDERED_YET;\n\t\t\tthis.requestIdentities.set(++this.requestId, identity);\n\t\t\tthis.requestScopes.set(this.requestId, scope);\n\t\t\tconst request = this.command(this.requestId, width);\n\t\t\tthis.runtime.sendEngineCommand(\n\t\t\t\tthis.inspectHistoryReplay ? { ...request, inspectHistoryReplay: true } : request,\n\t\t\t);\n\t\t}\n\t\t// The engine child re-renders asynchronously; until the fresh frame\n\t\t// arrives, the previous frame may be wrapped for an older terminal\n\t\t// width. Clamp so a resize never replays overflowing lines (pi-tui\n\t\t// crashes on any rendered line wider than the terminal).\n\t\treturn this.frameClamp.clamp(this.lines, width);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.markDirty();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tthis.releaseIfRetired = undefined;\n\t\tif (this.routes.rows.get(this.componentId) === this) this.routes.rows.delete(this.componentId);\n\t\tthis.requestIdentities.clear();\n\t\tthis.requestScopes.clear();\n\t\tthis.clearClickChecks();\n\t\tthis.runtime.sendEngineCommand({ type: \"engine_render_dispose\", componentId: this.componentId });\n\t}\n\n\tprotected changed(): void {\n\t\tthis.markDirty();\n\t\tthis.requestRender();\n\t}\n\n\tprivate readonly cancelClickChecks = (): void => {\n\t\tthis.clearClickChecks();\n\t\tthis.requestRender();\n\t};\n\n\tprivate readonly clearClickChecks = (): void => {\n\t\tthis.clickCancellation?.removeEventListener(\"abort\", this.cancelClickChecks);\n\t\tthis.clickCancellation = undefined;\n\t\tthis.clickChecks.length = 0;\n\t\tthis.toggleAfterChecks = false;\n\t\tthis.markDirty();\n\t};\n\n\tisExpanded(): boolean {\n\t\treturn this.expanded;\n\t}\n\n\tsetExpanded(expanded: boolean): void {\n\t\tthis.clearClickChecks(); // An explicit expansion, e.g. Ctrl+O, supersedes outstanding clicks.\n\t\tthis.expanded = expanded;\n\t\tthis.changed();\n\t}\n\n\texpandByClick(expanded: boolean, changed: () => void, width = this.width, signal?: AbortSignal): void {\n\t\tif (this.disposed || signal?.aborted || this.routes.clicks.signal.aborted || expanded === this.expanded) return;\n\t\tconst command = { ...this.command(++this.requestId, width), compareExpansion: true as const };\n\t\tthis.clickChecks.push({ command, changed });\n\t\tif (this.clickChecks.length === 1) {\n\t\t\tthis.clickCancellation = signal\n\t\t\t\t? AbortSignal.any([signal, this.routes.clicks.signal])\n\t\t\t\t: this.routes.clicks.signal;\n\t\t\tthis.clickCancellation.addEventListener(\"abort\", this.cancelClickChecks, { once: true });\n\t\t\tthis.runtime.sendEngineCommand(command);\n\t\t}\n\t}\n\n\tprotected abstract command(requestId: number, width: number): RemoteRenderCommand;\n\n\t/** Names what this row shows, the same for every row recreated for it. */\n\tprotected abstract frameIdentity(): string;\n\n\tprivate markDirty(): void {\n\t\tthis.dirty = true;\n\t}\n}\n\n/**\n * Disposes the rows rendered by the engine among `components`, which a cleared chat no longer shows: each one\n * otherwise keeps its renderer alive in the engine for the rest of the session.\n */\nexport function disposeRemoteRenderers(components: readonly Component[]): void {\n\tfor (const component of components) if (component instanceof RemoteRenderer) component.dispose();\n}\n\nexport class RemoteToolExecutionComponent extends RemoteRenderer {\n\treadonly expandsOnClick = true;\n\tprivate readonly toolName: string;\n\tprivate readonly toolCallId: string;\n\tprivate readonly rendererTaskId: string | undefined;\n\tprivate args: unknown;\n\tprivate result: RenderableToolResult | undefined;\n\tprivate executionStarted = false;\n\tprivate executionStartedAt: number | undefined;\n\tprivate argsComplete = false;\n\tprivate groupRole: ToolGroupRole = { kind: \"standalone\" };\n\tprivate groupHead: ToolGroupHead | undefined;\n\t/** Whether the last frame asked of the engine draws this call on its own, apart from its group. */\n\tprivate requestedApart = false;\n\tprivate isPartial = true;\n\tprivate showImages: boolean;\n\tprivate imageWidthCells: number;\n\tprivate outputPad: number;\n\n\tconstructor(\n\t\ttoolName: string,\n\t\ttoolCallId: string,\n\t\targs: unknown,\n\t\toptions: { showImages?: boolean; imageWidthCells?: number; outputPad?: number; rendererTaskId?: string },\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.toolName = toolName;\n\t\tthis.toolCallId = toolCallId;\n\t\tthis.rendererTaskId = options.rendererTaskId;\n\t\tthis.args = args;\n\t\tthis.showImages = options.showImages ?? true;\n\t\tthis.imageWidthCells = options.imageWidthCells ?? 60;\n\t\tthis.outputPad = options.outputPad ?? 1;\n\t}\n\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\tupdateArgs(args: unknown): void {\n\t\tthis.args = args;\n\t\tthis.changed();\n\t}\n\tmarkExecutionStarted(startedAt?: number): void {\n\t\tif (this.executionStarted) return;\n\t\tthis.executionStarted = true;\n\t\tthis.executionStartedAt = startedAt ?? Date.now();\n\t\tthis.changed();\n\t}\n\tsetArgsComplete(): void {\n\t\tif (this.argsComplete) return;\n\t\tthis.argsComplete = true;\n\t\tthis.changed();\n\t}\n\tsetGroupRole(role: ToolGroupRole): void {\n\t\tif (sameToolGroupRole(this.groupRole, role)) return;\n\t\tthis.groupRole = role;\n\t\tthis.changed();\n\t}\n\t/** The first call of the group this call is folded into, which stands for it while both have one expansion. */\n\tsetGroupHead(head: ToolGroupHead | undefined): void {\n\t\tthis.groupHead = head;\n\t}\n\t/** Whether this call, folded into a group, is drawn and clicked on its own: see `drawsApartFromGroup`. */\n\tdrawsApart(): boolean {\n\t\treturn drawsApartFromGroup(this.groupRole, this.expanded, this.groupHead);\n\t}\n\t/** The place in its group the engine draws this call at: on its own while it is drawn apart from its group. */\n\tprivate drawnGroupRole(): ToolGroupRole {\n\t\treturn this.requestedApart ? { kind: \"standalone\" } : this.groupRole;\n\t}\n\toverride render(width: number): string[] {\n\t\tconst apart = this.drawsApart();\n\t\tif (apart !== this.requestedApart) {\n\t\t\tthis.requestedApart = apart;\n\t\t\tthis.invalidate();\n\t\t}\n\t\tif (!this.expanded && this.groupRole.kind === \"hidden\" && !apart) return [];\n\t\treturn super.render(width);\n\t}\n\tupdateResult(result: RenderableToolResult, isPartial = false): void {\n\t\tthis.result = result;\n\t\tthis.isPartial = isPartial;\n\t\tthis.changed();\n\t}\n\tgetGroupRole(): ToolGroupRole {\n\t\treturn this.groupRole;\n\t}\n\t/** Every row of the block: the engine draws it as `ToolExecutionComponent` does, after a blank row. */\n\tclickArea(width: number): RowRange | undefined {\n\t\treturn rowsFrom(1, this.render(width).length);\n\t}\n\tsetShowImages(show: boolean): void {\n\t\tthis.showImages = show;\n\t\tthis.changed();\n\t}\n\tsetImageWidthCells(width: number): void {\n\t\tthis.imageWidthCells = Math.max(1, Math.floor(width));\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\tconst lines = savedReadLines(this.result?.content);\n\t\treturn {\n\t\t\ttype: \"engine_tool_render\",\n\t\t\t...(lines === undefined ? {} : { savedReadLines: lines }),\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\ttoolName: this.toolName,\n\t\t\ttoolCallId: this.toolCallId,\n\t\t\t...(this.rendererTaskId === undefined ? {} : { rendererTaskId: this.rendererTaskId }),\n\t\t\targs: jsonValue(this.args),\n\t\t\tresult: this.result ? (jsonValue(this.result) as JsonObject) : undefined,\n\t\t\texecutionStarted: this.executionStarted,\n\t\t\t...(this.executionStartedAt === undefined ? {} : { executionStartedAt: this.executionStartedAt }),\n\t\t\targsComplete: this.argsComplete,\n\t\t\tisPartial: this.isPartial,\n\t\t\texpanded: this.expanded,\n\t\t\tshowImages: this.showImages,\n\t\t\timageWidthCells: this.imageWidthCells,\n\t\t\toutputPad: this.outputPad,\n\t\t\t...(this.drawnGroupRole().kind === \"standalone\" ? {} : { groupRole: this.drawnGroupRole() }),\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\treturn JSON.stringify([\n\t\t\t\"tool\",\n\t\t\tthis.rendererTaskId,\n\t\t\tthis.toolName,\n\t\t\tthis.toolCallId,\n\t\t\tthis.expanded,\n\t\t\ttoolGroupRoleKey(this.drawnGroupRole()),\n\t\t]);\n\t}\n}\n\nexport class RemoteCustomMessageComponent extends RemoteRenderer {\n\treadonly ownsLeadingSpacer = true;\n\tprivate readonly message: CustomMessage<unknown>;\n\tprivate readonly reopenedStopName?: string;\n\tprivate contentDigest: string | undefined;\n\tprivate outputPad: number;\n\tconstructor(\n\t\tmessage: CustomMessage<unknown>,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\toutputPad = 1,\n\t) {\n\t\tsuper(runtime, requestRender);\n\t\tthis.message = message;\n\t\tthis.reopenedStopName = reopenedCompletionName(message, isProxy);\n\t\tthis.outputPad = outputPad;\n\t}\n\n\t/**\n\t * A message expands on a click, as Ctrl+O expands it: the engine draws its card, and a card with nothing more to\n\t * show stays as it is.\n\t */\n\treadonly expandsOnClick = true;\n\t/** Every row of the card: the engine draws it after the blank row it leads with. */\n\tclickArea(width: number): RowRange | undefined {\n\t\treturn rowsFrom(1, this.render(width).length);\n\t}\n\tsetOutputPad(outputPad: number): void {\n\t\tthis.outputPad = outputPad;\n\t\tthis.changed();\n\t}\n\n\tprotected command(requestId: number, width: number): RemoteRenderCommand {\n\t\tconst stopped = this.reopenedStopName;\n\t\treturn {\n\t\t\ttype: \"engine_message_render\",\n\t\t\t...(stopped === undefined ? {} : { reopenedStopName: stopped }),\n\t\t\tcomponentId: this.componentId,\n\t\t\trequestId,\n\t\t\twidth,\n\t\t\tmessage: jsonValue(this.message) as JsonObject,\n\t\t\texpanded: this.expanded,\n\t\t\toutputPad: this.outputPad,\n\t\t};\n\t}\n\n\tprotected frameIdentity(): string {\n\t\t// Not the timestamp: a message shown live and the same message restored from the session can differ in it.\n\t\tthis.contentDigest ??= createHash(\"sha1\")\n\t\t\t.update(JSON.stringify([this.message.content, this.message.details]) ?? \"\")\n\t\t\t.digest(\"base64\");\n\t\tconst stopped = this.reopenedStopName;\n\t\treturn stopped === undefined\n\t\t\t? JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded])\n\t\t\t: JSON.stringify([\"message\", this.message.customType, this.contentDigest, this.expanded, stopped]);\n\t}\n}\n"]}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Placing a viewed subagent's transcript frame in a transcript area of another height.
3
+ *
4
+ * The engine draws the transcript for the rows the host asks for, and the host paints the frame it has until the one
5
+ * for the new height arrives. A frame is the scrolled transcript (its body) with the page's notes and question form
6
+ * below it. With the frame's layout the host puts every row it has where the engine's frame for the new height will
7
+ * put it: rows the reader follows at the end stay at the bottom and earlier rows open above them, a reader scrolled up
8
+ * keeps the rows they read at the top, and the notes and form stay at the bottom. Rows the frame does not have stay
9
+ * blank until that frame is here; nothing painted moves when it arrives.
10
+ */
11
+ /** How a transcript frame laid out its rows, sent with each frame the engine draws for a viewed subagent. */
12
+ export interface TranscriptFrameLayout {
13
+ /** The width the frame was drawn for. */
14
+ readonly width: number;
15
+ /** Rows at the top of the frame that show the scrolled transcript; the rows after them are notes and the form. */
16
+ readonly bodyRows: number;
17
+ /** The transcript row the body shows first. */
18
+ readonly firstRow: number;
19
+ /** Rows the whole transcript has. */
20
+ readonly totalRows: number;
21
+ /** Rows at the top of the body that are not transcript rows: the pinned prompt of a reader scrolled up. */
22
+ readonly headRows: number;
23
+ /** Rows at the bottom of the body that are not transcript rows: the jump to the latest row. */
24
+ readonly footRows: number;
25
+ }
26
+ export interface PlacedTranscriptFrame {
27
+ readonly lines: string[];
28
+ /**
29
+ * The frame row each row shows when the frame was placed by its layout, undefined where the frame has no row for
30
+ * it. Without it, row `r` shows frame row `r + hidden`.
31
+ */
32
+ readonly frameRows?: readonly (number | undefined)[];
33
+ /** Rows of the frame above the first one shown, when it was not placed by its layout. */
34
+ readonly hidden: number;
35
+ }
36
+ /** The layout in `value`, when it is one: whole, non-negative numbers whose rows fit the body. */
37
+ export declare function parseTranscriptFrameLayout(value: unknown): TranscriptFrameLayout | undefined;
38
+ /**
39
+ * `lines`, a frame laid out as `layout` says, in `height` rows of `width`. A frame drawn for this height is shown as
40
+ * it is. One drawn for another height is placed as the engine's frame for this height places the same rows; without a
41
+ * layout that says how, its last rows are shown and blank rows follow.
42
+ */
43
+ export declare function placeTranscriptFrame(lines: string[], layout: TranscriptFrameLayout | undefined, width: number, height: number): PlacedTranscriptFrame;
44
+ /** A component that reports how it laid out the transcript frame it rendered last. */
45
+ export interface TranscriptLayoutSource {
46
+ transcriptLayout?(): TranscriptFrameLayout | undefined;
47
+ }
48
+ /** How `component` laid out the frame it rendered last, when it says. */
49
+ export declare function transcriptLayoutOf(component: object): TranscriptFrameLayout | undefined;
50
+ //# sourceMappingURL=transcript-frame-layout.d.ts.map