@bastani/atomic 0.9.13-alpha.2 → 0.9.13-alpha.4

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 (317) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/README.md +1 -1
  3. package/dist/builtin/i-have-adhd/package.json +1 -1
  4. package/dist/builtin/intercom/CHANGELOG.md +14 -0
  5. package/dist/builtin/intercom/README.md +12 -12
  6. package/dist/builtin/intercom/incoming-message-delivery.ts +1 -1
  7. package/dist/builtin/intercom/index.ts +1 -1
  8. package/dist/builtin/intercom/intercom-tool.ts +1 -1
  9. package/dist/builtin/intercom/intercom-utils.ts +3 -6
  10. package/dist/builtin/intercom/package.json +1 -1
  11. package/dist/builtin/intercom/result-renderers.ts +1 -1
  12. package/dist/builtin/intercom/session-target.ts +1 -15
  13. package/dist/builtin/intercom/skills/intercom/SKILL.md +6 -6
  14. package/dist/builtin/intercom/terminal-ordering-barrier.ts +2 -2
  15. package/dist/builtin/intercom/ui/inline-message.ts +7 -5
  16. package/dist/builtin/intercom/ui/session-list.ts +23 -10
  17. package/dist/builtin/mcp/package.json +1 -1
  18. package/dist/builtin/subagents/CHANGELOG.md +19 -0
  19. package/dist/builtin/subagents/README.md +29 -73
  20. package/dist/builtin/subagents/package.json +2 -2
  21. package/dist/builtin/subagents/prompts/parallel-cleanup.md +1 -1
  22. package/dist/builtin/subagents/prompts/parallel-review.md +1 -1
  23. package/dist/builtin/subagents/prompts/review-loop.md +2 -2
  24. package/dist/builtin/subagents/skills/subagent/SKILL.md +23 -59
  25. package/dist/builtin/subagents/skills/tmux/SKILL.md +1 -1
  26. package/dist/builtin/subagents/src/extension/control-notices.ts +2 -3
  27. package/dist/builtin/subagents/src/extension/doctor.ts +2 -14
  28. package/dist/builtin/subagents/src/extension/fanout-child.ts +1 -17
  29. package/dist/builtin/subagents/src/extension/index.ts +9 -70
  30. package/dist/builtin/subagents/src/extension/notification-content.ts +1 -1
  31. package/dist/builtin/subagents/src/extension/prompt-guidance.ts +2 -2
  32. package/dist/builtin/subagents/src/extension/schemas.ts +2 -8
  33. package/dist/builtin/subagents/src/extension/tool-description.ts +2 -3
  34. package/dist/builtin/subagents/src/intercom/intercom-bridge.ts +1 -1
  35. package/dist/builtin/subagents/src/intercom/result-intercom.ts +5 -46
  36. package/dist/builtin/subagents/src/runs/{background → foreground}/completion-notification.ts +2 -2
  37. package/dist/builtin/subagents/src/runs/foreground/inprocess-run-sync.ts +25 -88
  38. package/dist/builtin/subagents/src/runs/{background → foreground}/notify.ts +5 -5
  39. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-context.ts +11 -28
  40. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel-task.ts +3 -0
  41. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-parallel.ts +2 -0
  42. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-runtime.ts +0 -5
  43. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-single.ts +30 -20
  44. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-status.ts +4 -4
  45. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-types.ts +0 -13
  46. package/dist/builtin/subagents/src/runs/foreground/subagent-executor.ts +104 -48
  47. package/dist/builtin/subagents/src/runs/inprocess/index.ts +1 -1
  48. package/dist/builtin/subagents/src/runs/inprocess/runner.ts +5 -5
  49. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-api.ts +0 -7
  50. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-core.ts +0 -10
  51. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-projection.ts +3 -108
  52. package/dist/builtin/subagents/src/runs/inprocess/runtime-support/nested-sanitize.ts +0 -4
  53. package/dist/builtin/subagents/src/runs/shared/subagent-control.ts +1 -1
  54. package/dist/builtin/subagents/src/shared/formatters.ts +3 -5
  55. package/dist/builtin/subagents/src/shared/model-resolution.ts +78 -0
  56. package/dist/builtin/subagents/src/shared/status-format.ts +4 -11
  57. package/dist/builtin/subagents/src/shared/types-config.ts +10 -9
  58. package/dist/builtin/subagents/src/shared/types-nested.ts +127 -0
  59. package/dist/builtin/subagents/src/shared/types-results.ts +2 -8
  60. package/dist/builtin/subagents/src/shared/types-runtime.ts +0 -9
  61. package/dist/builtin/subagents/src/shared/types.ts +1 -1
  62. package/dist/builtin/subagents/src/shared/utils.ts +1 -109
  63. package/dist/builtin/subagents/src/slash/slash-commands.ts +7 -17
  64. package/dist/builtin/subagents/src/tui/render-event-formatting.ts +2 -252
  65. package/dist/builtin/subagents/src/tui/render-layout.ts +4 -4
  66. package/dist/builtin/subagents/src/tui/render-result.ts +0 -9
  67. package/dist/builtin/subagents/src/tui/render-stable-output.ts +1 -34
  68. package/dist/builtin/subagents/src/tui/render.ts +0 -2
  69. package/dist/builtin/web-access/package.json +1 -1
  70. package/dist/builtin/workflows/CHANGELOG.md +23 -0
  71. package/dist/builtin/workflows/README.md +3 -3
  72. package/dist/builtin/workflows/package.json +1 -1
  73. package/dist/builtin/workflows/src/durable/backend.ts +11 -0
  74. package/dist/builtin/workflows/src/durable/completed-catalog-stage-groups.ts +63 -25
  75. package/dist/builtin/workflows/src/durable/completed-catalog.ts +166 -25
  76. package/dist/builtin/workflows/src/durable/dbos-backend.ts +42 -24
  77. package/dist/builtin/workflows/src/durable/dbos-envelope.ts +2 -1
  78. package/dist/builtin/workflows/src/durable/run-timing.ts +28 -7
  79. package/dist/builtin/workflows/src/durable/scoped-backend.ts +4 -0
  80. package/dist/builtin/workflows/src/durable/targeted-inspection.ts +110 -0
  81. package/dist/builtin/workflows/src/engine/run-durable-stage-session.ts +2 -2
  82. package/dist/builtin/workflows/src/engine/runtime.ts +19 -2
  83. package/dist/builtin/workflows/src/extension/extension-runtime-state.ts +3 -0
  84. package/dist/builtin/workflows/src/extension/index.bundle.mjs +750 -168
  85. package/dist/builtin/workflows/src/extension/runtime-durable-resume.ts +6 -0
  86. package/dist/builtin/workflows/src/extension/ui-surface.ts +4 -0
  87. package/dist/builtin/workflows/src/extension/workflow-command-registration.ts +6 -1
  88. package/dist/builtin/workflows/src/extension/workflow-targets.ts +18 -10
  89. package/dist/builtin/workflows/src/extension/workflow-tool-inspection.ts +31 -16
  90. package/dist/builtin/workflows/src/extension/workflow-tool-send.ts +75 -3
  91. package/dist/builtin/workflows/src/extension/workflow-tool.ts +53 -6
  92. package/dist/builtin/workflows/src/runs/background/run-inspect.ts +5 -1
  93. package/dist/builtin/workflows/src/runs/foreground/executor-stage-call.ts +94 -60
  94. package/dist/builtin/workflows/src/runs/foreground/executor-stage-context.ts +1 -1
  95. package/dist/builtin/workflows/src/runs/foreground/executor-stage-control.ts +7 -7
  96. package/dist/builtin/workflows/src/runs/foreground/executor-stage-factory.ts +25 -4
  97. package/dist/builtin/workflows/src/runs/foreground/executor-stage-types.ts +4 -1
  98. package/dist/builtin/workflows/src/runs/foreground/executor-types.ts +2 -0
  99. package/dist/builtin/workflows/src/runs/foreground/stage-runner-controller.ts +142 -4
  100. package/dist/builtin/workflows/src/runs/foreground/stage-runner-types.ts +2 -0
  101. package/dist/builtin/workflows/src/runs/foreground/stage-session-heartbeat.ts +88 -0
  102. package/dist/builtin/workflows/src/tui/keybindings-adapter.ts +1 -0
  103. package/dist/builtin/workflows/src/tui/overlay-adapter.ts +1 -0
  104. package/dist/builtin/workflows/src/tui/run-detail.ts +25 -12
  105. package/dist/builtin/workflows/src/tui/stage-chat-view-archive-history.ts +27 -8
  106. package/dist/builtin/workflows/src/tui/stage-chat-view-input.ts +17 -1
  107. package/dist/builtin/workflows/src/tui/stage-chat-view.ts +20 -3
  108. package/dist/builtin/workflows/src/tui/workflow-attach-pane.ts +10 -1
  109. package/dist/builtin/workflows/src/tui/workflow-resume-selector.ts +1 -0
  110. package/dist/core/agent-session-events.d.ts.map +1 -1
  111. package/dist/core/agent-session-events.js +22 -5
  112. package/dist/core/agent-session-events.js.map +1 -1
  113. package/dist/core/agent-session-export.d.ts.map +1 -1
  114. package/dist/core/agent-session-export.js +2 -1
  115. package/dist/core/agent-session-export.js.map +1 -1
  116. package/dist/core/agent-session-methods.d.ts +10 -4
  117. package/dist/core/agent-session-methods.d.ts.map +1 -1
  118. package/dist/core/agent-session-methods.js.map +1 -1
  119. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  120. package/dist/core/agent-session-prompt.js +68 -0
  121. package/dist/core/agent-session-prompt.js.map +1 -1
  122. package/dist/core/agent-session-queue-pause.d.ts.map +1 -1
  123. package/dist/core/agent-session-queue-pause.js +6 -0
  124. package/dist/core/agent-session-queue-pause.js.map +1 -1
  125. package/dist/core/agent-session-summary.d.ts +21 -0
  126. package/dist/core/agent-session-summary.d.ts.map +1 -0
  127. package/dist/core/agent-session-summary.js +156 -0
  128. package/dist/core/agent-session-summary.js.map +1 -0
  129. package/dist/core/agent-session-tool-registry.d.ts.map +1 -1
  130. package/dist/core/agent-session-tool-registry.js +0 -4
  131. package/dist/core/agent-session-tool-registry.js.map +1 -1
  132. package/dist/core/agent-session-transfer.d.ts.map +1 -1
  133. package/dist/core/agent-session-transfer.js +0 -2
  134. package/dist/core/agent-session-transfer.js.map +1 -1
  135. package/dist/core/agent-session-tree.d.ts.map +1 -1
  136. package/dist/core/agent-session-tree.js +6 -0
  137. package/dist/core/agent-session-tree.js.map +1 -1
  138. package/dist/core/agent-session.d.ts +21 -3
  139. package/dist/core/agent-session.d.ts.map +1 -1
  140. package/dist/core/agent-session.js +22 -5
  141. package/dist/core/agent-session.js.map +1 -1
  142. package/dist/core/atomic-guide-command.js +2 -2
  143. package/dist/core/atomic-guide-command.js.map +1 -1
  144. package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
  145. package/dist/core/compaction/branch-summarization.js +1 -0
  146. package/dist/core/compaction/branch-summarization.js.map +1 -1
  147. package/dist/core/compaction/index.d.ts +1 -0
  148. package/dist/core/compaction/index.d.ts.map +1 -1
  149. package/dist/core/compaction/index.js +1 -0
  150. package/dist/core/compaction/index.js.map +1 -1
  151. package/dist/core/compaction/session-summarization.d.ts +41 -0
  152. package/dist/core/compaction/session-summarization.d.ts.map +1 -0
  153. package/dist/core/compaction/session-summarization.js +97 -0
  154. package/dist/core/compaction/session-summarization.js.map +1 -0
  155. package/dist/core/extensions/ui-types.d.ts +4 -0
  156. package/dist/core/extensions/ui-types.d.ts.map +1 -1
  157. package/dist/core/extensions/ui-types.js.map +1 -1
  158. package/dist/core/keybindings.d.ts +0 -5
  159. package/dist/core/keybindings.d.ts.map +1 -1
  160. package/dist/core/keybindings.js +0 -2
  161. package/dist/core/keybindings.js.map +1 -1
  162. package/dist/core/session-manager-core.d.ts +3 -1
  163. package/dist/core/session-manager-core.d.ts.map +1 -1
  164. package/dist/core/session-manager-core.js +9 -1
  165. package/dist/core/session-manager-core.js.map +1 -1
  166. package/dist/core/session-manager-entries.d.ts +24 -1
  167. package/dist/core/session-manager-entries.d.ts.map +1 -1
  168. package/dist/core/session-manager-entries.js +48 -0
  169. package/dist/core/session-manager-entries.js.map +1 -1
  170. package/dist/core/session-manager-list.d.ts.map +1 -1
  171. package/dist/core/session-manager-list.js +10 -0
  172. package/dist/core/session-manager-list.js.map +1 -1
  173. package/dist/core/session-manager-types.d.ts +10 -1
  174. package/dist/core/session-manager-types.d.ts.map +1 -1
  175. package/dist/core/session-manager-types.js.map +1 -1
  176. package/dist/core/settings-manager-basic-accessors.d.ts +3 -0
  177. package/dist/core/settings-manager-basic-accessors.d.ts.map +1 -1
  178. package/dist/core/settings-manager-basic-accessors.js +5 -0
  179. package/dist/core/settings-manager-basic-accessors.js.map +1 -1
  180. package/dist/core/settings-manager.d.ts +1 -1
  181. package/dist/core/settings-manager.d.ts.map +1 -1
  182. package/dist/core/settings-manager.js.map +1 -1
  183. package/dist/core/settings-types.d.ts +4 -0
  184. package/dist/core/settings-types.d.ts.map +1 -1
  185. package/dist/core/settings-types.js.map +1 -1
  186. package/dist/core/slash-commands.js +2 -2
  187. package/dist/core/slash-commands.js.map +1 -1
  188. package/dist/core/tools/bash.d.ts +0 -15
  189. package/dist/core/tools/bash.d.ts.map +1 -1
  190. package/dist/core/tools/bash.js +3 -81
  191. package/dist/core/tools/bash.js.map +1 -1
  192. package/dist/core/tools/fetch-url.d.ts +12 -0
  193. package/dist/core/tools/fetch-url.d.ts.map +1 -1
  194. package/dist/core/tools/fetch-url.js +76 -10
  195. package/dist/core/tools/fetch-url.js.map +1 -1
  196. package/dist/core/tools/index.js +4 -4
  197. package/dist/core/tools/index.js.map +1 -1
  198. package/dist/core/tools/session-temp-dir.d.ts +2 -2
  199. package/dist/core/tools/session-temp-dir.d.ts.map +1 -1
  200. package/dist/core/tools/session-temp-dir.js +6 -7
  201. package/dist/core/tools/session-temp-dir.js.map +1 -1
  202. package/dist/core/usage-totals.js +1 -1
  203. package/dist/core/usage-totals.js.map +1 -1
  204. package/dist/index.d.ts +1 -1
  205. package/dist/index.d.ts.map +1 -1
  206. package/dist/index.js +1 -1
  207. package/dist/index.js.map +1 -1
  208. package/dist/modes/interactive/components/footer.js +1 -1
  209. package/dist/modes/interactive/components/footer.js.map +1 -1
  210. package/dist/modes/interactive/components/host-session-picker.d.ts.map +1 -1
  211. package/dist/modes/interactive/components/host-session-picker.js +1 -0
  212. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  213. package/dist/modes/interactive/components/index.d.ts +1 -0
  214. package/dist/modes/interactive/components/index.d.ts.map +1 -1
  215. package/dist/modes/interactive/components/index.js +1 -0
  216. package/dist/modes/interactive/components/index.js.map +1 -1
  217. package/dist/modes/interactive/components/session-selector-list.d.ts.map +1 -1
  218. package/dist/modes/interactive/components/session-selector-list.js +29 -4
  219. package/dist/modes/interactive/components/session-selector-list.js.map +1 -1
  220. package/dist/modes/interactive/components/session-selector-search.js +1 -1
  221. package/dist/modes/interactive/components/session-selector-search.js.map +1 -1
  222. package/dist/modes/interactive/components/transcript-follow-indicator.d.ts +14 -0
  223. package/dist/modes/interactive/components/transcript-follow-indicator.d.ts.map +1 -0
  224. package/dist/modes/interactive/components/transcript-follow-indicator.js +36 -0
  225. package/dist/modes/interactive/components/transcript-follow-indicator.js.map +1 -0
  226. package/dist/modes/interactive/components/tree-selector-content.d.ts.map +1 -1
  227. package/dist/modes/interactive/components/tree-selector-content.js +6 -0
  228. package/dist/modes/interactive/components/tree-selector-content.js.map +1 -1
  229. package/dist/modes/interactive/interactive-extension-custom-ui.js +3 -0
  230. package/dist/modes/interactive/interactive-extension-custom-ui.js.map +1 -1
  231. package/dist/modes/interactive/interactive-input-handling.js +0 -3
  232. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  233. package/dist/modes/interactive/interactive-mode-base.d.ts +1 -0
  234. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  235. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  236. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  237. package/dist/modes/interactive/interactive-mode-surface.d.ts +3 -3
  238. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  239. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  240. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  241. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  242. package/dist/modes/interactive/interactive-mode.js +1 -0
  243. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  244. package/dist/modes/interactive/interactive-slash-commands.js +2 -5
  245. package/dist/modes/interactive/interactive-slash-commands.js.map +1 -1
  246. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  247. package/dist/modes/interactive/interactive-startup.js +6 -0
  248. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  249. package/dist/modes/interactive/interactive-transcript-follow.d.ts +2 -0
  250. package/dist/modes/interactive/interactive-transcript-follow.d.ts.map +1 -0
  251. package/dist/modes/interactive/interactive-transcript-follow.js +6 -0
  252. package/dist/modes/interactive/interactive-transcript-follow.js.map +1 -0
  253. package/dist/modes/interactive/interactive-tui.d.ts +13 -1
  254. package/dist/modes/interactive/interactive-tui.d.ts.map +1 -1
  255. package/dist/modes/interactive/interactive-tui.js +59 -1
  256. package/dist/modes/interactive/interactive-tui.js.map +1 -1
  257. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +2 -0
  258. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  259. package/dist/modes/interactive-engine/engine-custom-ui.js +1 -0
  260. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  261. package/dist/modes/interactive-engine/protocol.d.ts +1 -0
  262. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  263. package/dist/modes/interactive-engine/protocol.js +5 -1
  264. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  265. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  266. package/dist/modes/interactive-engine/remote-component.js +21 -9
  267. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  268. package/docs/environment-variables.md +1 -1
  269. package/docs/intercom.md +20 -21
  270. package/docs/keybindings.md +2 -5
  271. package/docs/quickstart.md +5 -1
  272. package/docs/sdk.md +1 -1
  273. package/docs/session-format.md +15 -0
  274. package/docs/sessions.md +8 -0
  275. package/docs/settings.md +6 -0
  276. package/docs/subagents.md +19 -31
  277. package/docs/tools.md +3 -5
  278. package/docs/usage.md +3 -1
  279. package/docs/windows.md +1 -1
  280. package/docs/workflows.md +60 -32
  281. package/npm-shrinkwrap.json +29 -29
  282. package/package.json +2 -2
  283. package/dist/builtin/subagents/src/runs/background/async-job-tracker.ts +0 -331
  284. package/dist/builtin/subagents/src/runs/foreground/subagent-executor-async.ts +0 -161
  285. package/dist/builtin/subagents/src/runs/inprocess/background-single.ts +0 -195
  286. package/dist/builtin/subagents/src/runs/inprocess/background.ts +0 -90
  287. package/dist/builtin/subagents/src/shared/types-async.ts +0 -247
  288. package/dist/builtin/subagents/src/tui/render-widget-graph.ts +0 -217
  289. package/dist/builtin/subagents/src/tui/render-widget.ts +0 -366
  290. package/dist/core/async/format.d.ts +0 -3
  291. package/dist/core/async/format.d.ts.map +0 -1
  292. package/dist/core/async/format.js +0 -52
  293. package/dist/core/async/format.js.map +0 -1
  294. package/dist/core/async/job-manager.d.ts +0 -40
  295. package/dist/core/async/job-manager.d.ts.map +0 -1
  296. package/dist/core/async/job-manager.js +0 -293
  297. package/dist/core/async/job-manager.js.map +0 -1
  298. package/dist/core/async/session-manager.d.ts +0 -16
  299. package/dist/core/async/session-manager.d.ts.map +0 -1
  300. package/dist/core/async/session-manager.js +0 -34
  301. package/dist/core/async/session-manager.js.map +0 -1
  302. package/dist/core/async/types.d.ts +0 -23
  303. package/dist/core/async/types.d.ts.map +0 -1
  304. package/dist/core/async/types.js +0 -2
  305. package/dist/core/async/types.js.map +0 -1
  306. package/dist/core/tools/bash-async-execution.d.ts +0 -27
  307. package/dist/core/tools/bash-async-execution.d.ts.map +0 -1
  308. package/dist/core/tools/bash-async-execution.js +0 -81
  309. package/dist/core/tools/bash-async-execution.js.map +0 -1
  310. package/dist/core/tools/bash-async-jobs.d.ts +0 -30
  311. package/dist/core/tools/bash-async-jobs.d.ts.map +0 -1
  312. package/dist/core/tools/bash-async-jobs.js +0 -87
  313. package/dist/core/tools/bash-async-jobs.js.map +0 -1
  314. package/dist/core/tools/bash-async-output.d.ts +0 -13
  315. package/dist/core/tools/bash-async-output.d.ts.map +0 -1
  316. package/dist/core/tools/bash-async-output.js +0 -122
  317. package/dist/core/tools/bash-async-output.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/protocol.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAiIrD,MAAM,cAAc,GAAoC;IACvD,gBAAgB;IAChB,UAAU;IACV,cAAc;IACd,cAAc;IACd,mBAAmB;IACnB,cAAc;IACd,wBAAwB;CACxB,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,KAAgD;IAC3E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,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AE,KAAK,CAAC,SAAS;YAC1B,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,SAAS,EAAE,KAAK,CAAC,SAAS;SAC1B,CAAC;IACH,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,+BAA+B,CAAC,OAA4D;IAC3G,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;AACvC,CAAC;AAED,MAAM,CAAC,MAAM,iCAAiC,GAAG,+BAA+B,CAAC","sourcesContent":["import type { CallbackActivity, CallbackActivityKind } from \"../../core/callback-activity.ts\";\nimport type { HostInputFormField, HostSessionPickerRow } from \"../../core/extensions/ui-types.ts\";\nimport type { KeyId } from \"../../core/keybindings.ts\";\n\n/**\n * Version 3 adds correlated replies for `engine_custom_input`. The host uses\n * those replies to decide whether a matching fullscreen viewport key should be\n * replayed, so a child that cannot send them must not be treated as compatible.\n */\nexport const INTERACTIVE_ENGINE_PROTOCOL_VERSION = 3;\n\nexport interface JsonObject {\n\t[key: string]: JsonValue;\n}\n\nexport type JsonValue = boolean | JsonObject | JsonValue[] | null | number | string;\n\nexport interface SerializableOverlayOptions {\n\tanchor?: string;\n\tcol?: number | string;\n\tmargin?: number | { top?: number; right?: number; bottom?: number; left?: number };\n\tmaxHeight?: number | string;\n\tmaxWidth?: number | string;\n\tminHeight?: number;\n\tminWidth?: number;\n\toffsetX?: number;\n\toffsetY?: number;\n\trow?: number | string;\n\twidth?: number | string;\n}\n\n/**\n * Allowlisted terminal-mode control a remote custom component may ask the host\n * to apply to the real host TTY. Deliberately NOT a raw byte channel: the child\n * names an intent and the host owns the concrete escape sequence, so a buggy or\n * compromised child can only toggle this documented mode.\n */\nexport type EngineTerminalControl = { kind: \"autowrap\"; enabled: boolean };\n\nexport interface EngineExtensionShortcut {\n\tkey: string;\n\tdescription?: string;\n}\n\nexport type SerializableKeybindingsConfig = Record<string, KeyId | KeyId[]>;\n\nexport interface EngineKeybindingState {\n\tuserBindings: SerializableKeybindingsConfig;\n\teffectiveBindings: SerializableKeybindingsConfig;\n\tshortcuts: EngineExtensionShortcut[];\n}\n\nexport type InteractiveEngineMessage =\n\t| { type: \"engine_ready\"; protocolVersion: typeof INTERACTIVE_ENGINE_PROTOCOL_VERSION; pid: number }\n\t| { type: \"engine_bound\" }\n\t| { type: \"engine_keybindings_reloaded\"; state: EngineKeybindingState }\n\t| { type: \"engine_heartbeat\"; at: number }\n\t| { type: \"engine_activity_started\"; activity: CallbackActivity }\n\t| { type: \"engine_activity_finished\"; activityId: string }\n\t/**\n\t * The child took ownership of a correlated RPC request: it has parsed the\n\t * command and is about to run it. Emitted and flushed BEFORE any handler\n\t * work, so a later transport failure can be told apart from a send that\n\t * never landed. Output is not a substitute: a command can run to completion\n\t * with side effects and produce nothing.\n\t */\n\t| { type: \"engine_request_accepted\"; requestId: string; command: string }\n\t| {\n\t\t\ttype: \"engine_custom_open\";\n\t\t\tcomponentId: string;\n\t\t\toverlay: boolean;\n\t\t\tdeferInlineCustomUiFocus?: boolean;\n\t\t\thandlesCtrlC?: boolean;\n\t\t\toverlayOptions?: SerializableOverlayOptions;\n\t\t\twidgetKey?: string;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t }\n\t| { type: \"engine_custom_close\"; componentId: string }\n\t| { type: \"engine_custom_frame\"; componentId: string; requestId: number; lines: string[] }\n\t| { type: \"engine_custom_input_result\"; componentId: string; requestId: number; handled: boolean }\n\t| { type: \"engine_custom_invalidate\"; componentId: string }\n\t| { type: \"engine_custom_done\"; componentId: string; result?: JsonValue }\n\t| { type: \"engine_custom_terminal\"; componentId: string; control: EngineTerminalControl }\n\t| { type: \"engine_custom_control\"; componentId: string; action: \"focus\" | \"hide\" | \"show\" | \"unfocus\" }\n\t| {\n\t\t\ttype: \"engine_session_picker_open\";\n\t\t\tcomponentId: string;\n\t\t\tsessions: HostSessionPickerRow[];\n\t\t\tshowRenameHint?: boolean;\n\t }\n\t| { type: \"engine_session_picker_update\"; componentId: string; sessions: HostSessionPickerRow[] }\n\t| { type: \"engine_session_picker_error\"; componentId: string; message: string }\n\t| { type: \"engine_session_picker_close\"; componentId: string }\n\t| {\n\t\t\ttype: \"engine_input_form_open\";\n\t\t\tcomponentId: string;\n\t\t\ttitle: string;\n\t\t\tfields: HostInputFormField[];\n\t\t\theading?: string;\n\t\t\tsubmitLabel?: string;\n\t }\n\t| { type: \"engine_input_form_close\"; componentId: string };\nexport type InteractiveEngineCommand =\n\t| { type: \"engine_custom_render\"; componentId: string; requestId: number; width: number; rows: number }\n\t| { type: \"engine_custom_input\"; componentId: string; requestId: number; data: string }\n\t| { type: \"engine_custom_dispose\"; componentId: string }\n\t| {\n\t\t\ttype: \"engine_tool_render\";\n\t\t\tcomponentId: string;\n\t\t\trequestId: number;\n\t\t\twidth: number;\n\t\t\ttoolName: string;\n\t\t\ttoolCallId: string;\n\t\t\targs: JsonValue;\n\t\t\tresult?: JsonObject;\n\t\t\texecutionStarted: boolean;\n\t\t\targsComplete: boolean;\n\t\t\tisPartial: boolean;\n\t\t\texpanded: boolean;\n\t\t\tshowImages: boolean;\n\t\t\timageWidthCells: number;\n\t }\n\t| {\n\t\t\ttype: \"engine_message_render\";\n\t\t\tcomponentId: string;\n\t\t\trequestId: number;\n\t\t\twidth: number;\n\t\t\tmessage: JsonObject;\n\t\t\texpanded: boolean;\n\t\t\toutputPad: number;\n\t }\n\t| { type: \"engine_render_dispose\"; componentId: string }\n\t| { type: \"engine_session_picker_select\"; componentId: string; path: string }\n\t| { type: \"engine_session_picker_cancel\"; componentId: string }\n\t| { type: \"engine_session_picker_delete\"; componentId: string; path: string }\n\t| { type: \"engine_input_form_submit\"; componentId: string; values: Record<string, string> }\n\t| { type: \"engine_input_form_cancel\"; componentId: string };\n\nconst ACTIVITY_KINDS: readonly CallbackActivityKind[] = [\n\t\"extension.hook\",\n\t\"renderer\",\n\t\"tool.execute\",\n\t\"tool.prepare\",\n\t\"workflow.ctx_tool\",\n\t\"workflow.run\",\n\t\"workflow.stage_adapter\",\n];\n\nexport function isJsonValue(value: object | boolean | null | number | string): value is JsonValue {\n\tif (value === null || typeof value !== \"object\") return true;\n\tif (Array.isArray(value)) return value.every((item) => isJsonValue(item));\n\treturn Object.values(value).every((item) => item !== undefined && isJsonValue(item));\n}\n\nfunction isJsonObject(value: JsonValue): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isActivityKind(value: JsonValue): value is CallbackActivityKind {\n\treturn typeof value === \"string\" && ACTIVITY_KINDS.includes(value as CallbackActivityKind);\n}\n\nfunction isCallbackActivity(value: JsonValue): value is JsonObject & CallbackActivity {\n\treturn (\n\t\tisJsonObject(value) &&\n\t\ttypeof value.id === \"string\" &&\n\t\tisActivityKind(value.kind) &&\n\t\ttypeof value.name === \"string\" &&\n\t\ttypeof value.startedAt === \"number\"\n\t);\n}\n\nfunction parseEngineTerminalControl(value: JsonValue | undefined): EngineTerminalControl | undefined {\n\tif (value === undefined || !isJsonObject(value) || value.kind !== \"autowrap\" || typeof value.enabled !== \"boolean\") {\n\t\treturn undefined;\n\t}\n\treturn { kind: \"autowrap\", enabled: value.enabled };\n}\n\nconst SESSION_PICKER_MESSAGE_COLORS = [\"success\", \"warning\", \"accent\", \"error\"] as const;\n\nfunction parseSessionPickerRow(value: JsonValue): HostSessionPickerRow | undefined {\n\tif (!isJsonObject(value)) return undefined;\n\tconst { path, id, cwd, createdAt, modifiedAt, messageCount, firstMessage, allMessagesText, name, messageColor } =\n\t\tvalue;\n\tif (\n\t\ttypeof path !== \"string\" ||\n\t\ttypeof id !== \"string\" ||\n\t\ttypeof cwd !== \"string\" ||\n\t\ttypeof createdAt !== \"number\" ||\n\t\ttypeof modifiedAt !== \"number\" ||\n\t\ttypeof messageCount !== \"number\" ||\n\t\ttypeof firstMessage !== \"string\"\n\t)\n\t\treturn undefined;\n\tif (allMessagesText !== undefined && typeof allMessagesText !== \"string\") return undefined;\n\tif (name !== undefined && typeof name !== \"string\") return undefined;\n\tif (\n\t\tmessageColor !== undefined &&\n\t\t!SESSION_PICKER_MESSAGE_COLORS.includes(messageColor as (typeof SESSION_PICKER_MESSAGE_COLORS)[number])\n\t)\n\t\treturn undefined;\n\treturn {\n\t\tpath,\n\t\tid,\n\t\tcwd,\n\t\tcreatedAt,\n\t\tmodifiedAt,\n\t\tmessageCount,\n\t\tfirstMessage,\n\t\t...(allMessagesText !== undefined ? { allMessagesText } : {}),\n\t\t...(name !== undefined ? { name } : {}),\n\t\t...(messageColor !== undefined\n\t\t\t? { messageColor: messageColor as (typeof SESSION_PICKER_MESSAGE_COLORS)[number] }\n\t\t\t: {}),\n\t};\n}\n\nfunction parseSessionPickerRows(value: JsonValue | undefined): HostSessionPickerRow[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst rows: HostSessionPickerRow[] = [];\n\tfor (const entry of value) {\n\t\tconst row = parseSessionPickerRow(entry);\n\t\tif (!row) return undefined;\n\t\trows.push(row);\n\t}\n\treturn rows;\n}\n\nconst INPUT_FORM_FIELD_TYPES = [\"string\", \"text\", \"number\", \"integer\", \"boolean\", \"select\"] as const;\n\nfunction parseInputFormFields(value: JsonValue | undefined): HostInputFormField[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst fields: HostInputFormField[] = [];\n\tfor (const entry of value) {\n\t\tif (!isJsonObject(entry)) return undefined;\n\t\tconst { name, type, description, required, choices, placeholder, initialValue } = entry;\n\t\tif (\n\t\t\ttypeof name !== \"string\" ||\n\t\t\t!INPUT_FORM_FIELD_TYPES.includes(type as HostInputFormField[\"type\"]) ||\n\t\t\ttypeof initialValue !== \"string\"\n\t\t)\n\t\t\treturn undefined;\n\t\tif (description !== undefined && typeof description !== \"string\") return undefined;\n\t\tif (required !== undefined && typeof required !== \"boolean\") return undefined;\n\t\tif (choices !== undefined && (!Array.isArray(choices) || !choices.every((choice) => typeof choice === \"string\")))\n\t\t\treturn undefined;\n\t\tif (placeholder !== undefined && typeof placeholder !== \"string\") return undefined;\n\t\tfields.push({\n\t\t\tname,\n\t\t\ttype: type as HostInputFormField[\"type\"],\n\t\t\tinitialValue,\n\t\t\t...(typeof description === \"string\" ? { description } : {}),\n\t\t\t...(typeof required === \"boolean\" ? { required } : {}),\n\t\t\t...(Array.isArray(choices) ? { choices: choices as string[] } : {}),\n\t\t\t...(typeof placeholder === \"string\" ? { placeholder } : {}),\n\t\t});\n\t}\n\treturn fields;\n}\n\nfunction parseStringRecord(value: JsonValue | undefined): Record<string, string> | undefined {\n\tif (value === undefined || !isJsonObject(value)) return undefined;\n\tconst entries = Object.entries(value);\n\tif (entries.some(([, entry]) => typeof entry !== \"string\")) return undefined;\n\treturn Object.fromEntries(entries) as Record<string, string>;\n}\n\nfunction parseKeybindingsConfig(value: JsonValue | undefined): SerializableKeybindingsConfig | undefined {\n\tif (value === undefined || !isJsonObject(value)) return undefined;\n\tconst config: SerializableKeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(value)) {\n\t\tif (typeof binding === \"string\") config[key] = binding as SerializableKeybindingsConfig[string];\n\t\telse if (Array.isArray(binding) && binding.every((entry) => typeof entry === \"string\")) {\n\t\t\tconfig[key] = binding as SerializableKeybindingsConfig[string];\n\t\t} else return undefined;\n\t}\n\treturn config;\n}\n\nfunction parseKeybindingState(value: JsonValue | undefined): EngineKeybindingState | undefined {\n\tif (value === undefined || !isJsonObject(value) || !Array.isArray(value.shortcuts)) return undefined;\n\tconst userBindings = parseKeybindingsConfig(value.userBindings);\n\tconst effectiveBindings = parseKeybindingsConfig(value.effectiveBindings);\n\tif (!userBindings || !effectiveBindings) return undefined;\n\tconst shortcuts: EngineExtensionShortcut[] = [];\n\tfor (const shortcut of value.shortcuts) {\n\t\tif (\n\t\t\t!isJsonObject(shortcut) ||\n\t\t\ttypeof shortcut.key !== \"string\" ||\n\t\t\t(shortcut.description !== undefined && typeof shortcut.description !== \"string\")\n\t\t)\n\t\t\treturn undefined;\n\t\tshortcuts.push({\n\t\t\tkey: shortcut.key,\n\t\t\t...(typeof shortcut.description === \"string\" ? { description: shortcut.description } : {}),\n\t\t});\n\t}\n\treturn { userBindings, effectiveBindings, shortcuts };\n}\n\nfunction parseJsonObject(line: string): JsonObject | undefined {\n\tlet value: JsonValue;\n\ttry {\n\t\tvalue = JSON.parse(line) as JsonValue;\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn isJsonObject(value) ? value : undefined;\n}\n\nexport function parseInteractiveEngineMessage(line: string): InteractiveEngineMessage | undefined {\n\tconst value = parseJsonObject(line);\n\tif (!value || typeof value.type !== \"string\") return undefined;\n\tswitch (value.type) {\n\t\tcase \"engine_ready\":\n\t\t\treturn value.protocolVersion === INTERACTIVE_ENGINE_PROTOCOL_VERSION && typeof value.pid === \"number\"\n\t\t\t\t? { type: value.type, protocolVersion: INTERACTIVE_ENGINE_PROTOCOL_VERSION, pid: value.pid }\n\t\t\t\t: undefined;\n\t\tcase \"engine_bound\":\n\t\t\treturn { type: value.type };\n\t\tcase \"engine_keybindings_reloaded\": {\n\t\t\tconst state = parseKeybindingState(value.state);\n\t\t\treturn state ? { type: value.type, state } : undefined;\n\t\t}\n\t\tcase \"engine_heartbeat\":\n\t\t\treturn typeof value.at === \"number\" ? { type: value.type, at: value.at } : undefined;\n\t\tcase \"engine_activity_started\":\n\t\t\treturn isCallbackActivity(value.activity) ? { type: value.type, activity: value.activity } : undefined;\n\t\tcase \"engine_activity_finished\":\n\t\t\treturn typeof value.activityId === \"string\" ? { type: value.type, activityId: value.activityId } : undefined;\n\t\tcase \"engine_request_accepted\":\n\t\t\treturn typeof value.requestId === \"string\" && typeof value.command === \"string\"\n\t\t\t\t? { type: value.type, requestId: value.requestId, command: value.command }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_open\":\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.overlay === \"boolean\"\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\toverlay: value.overlay,\n\t\t\t\t\t\tdeferInlineCustomUiFocus: value.deferInlineCustomUiFocus === true,\n\t\t\t\t\t\thandlesCtrlC: value.handlesCtrlC === true,\n\t\t\t\t\t\toverlayOptions: isJsonObject(value.overlayOptions)\n\t\t\t\t\t\t\t? (value.overlayOptions as SerializableOverlayOptions)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\twidgetKey: typeof value.widgetKey === \"string\" ? value.widgetKey : undefined,\n\t\t\t\t\t\twidgetPlacement:\n\t\t\t\t\t\t\tvalue.widgetPlacement === \"belowEditor\"\n\t\t\t\t\t\t\t\t? \"belowEditor\"\n\t\t\t\t\t\t\t\t: value.widgetPlacement === \"aboveEditor\"\n\t\t\t\t\t\t\t\t\t? \"aboveEditor\"\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_close\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_frame\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\ttypeof value.requestId === \"number\" &&\n\t\t\t\tArray.isArray(value.lines) &&\n\t\t\t\tvalue.lines.every((entry) => typeof entry === \"string\")\n\t\t\t\t? { type: value.type, componentId: value.componentId, requestId: value.requestId, lines: value.lines }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_input_result\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\ttypeof value.requestId === \"number\" &&\n\t\t\t\ttypeof value.handled === \"boolean\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, requestId: value.requestId, handled: value.handled }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_invalidate\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_done\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, result: value.result }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_terminal\": {\n\t\t\tconst control = parseEngineTerminalControl(value.control);\n\t\t\treturn typeof value.componentId === \"string\" && control\n\t\t\t\t? { type: value.type, componentId: value.componentId, control }\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_custom_control\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\t[\"focus\", \"hide\", \"show\", \"unfocus\"].includes(String(value.action))\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\taction: value.action as \"focus\" | \"hide\" | \"show\" | \"unfocus\",\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\tcase \"engine_session_picker_open\": {\n\t\t\tconst sessions = parseSessionPickerRows(value.sessions);\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\tsessions &&\n\t\t\t\t(value.showRenameHint === undefined || typeof value.showRenameHint === \"boolean\")\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\tsessions,\n\t\t\t\t\t\t...(typeof value.showRenameHint === \"boolean\" ? { showRenameHint: value.showRenameHint } : {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_session_picker_update\": {\n\t\t\tconst sessions = parseSessionPickerRows(value.sessions);\n\t\t\treturn typeof value.componentId === \"string\" && sessions\n\t\t\t\t? { type: value.type, componentId: value.componentId, sessions }\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_session_picker_error\":\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.message === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, message: value.message }\n\t\t\t\t: undefined;\n\t\tcase \"engine_session_picker_close\":\n\t\tcase \"engine_input_form_close\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_input_form_open\": {\n\t\t\tconst fields = parseInputFormFields(value.fields);\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.title === \"string\" && fields\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\ttitle: value.title,\n\t\t\t\t\t\tfields,\n\t\t\t\t\t\t...(typeof value.heading === \"string\" ? { heading: value.heading } : {}),\n\t\t\t\t\t\t...(typeof value.submitLabel === \"string\" ? { submitLabel: value.submitLabel } : {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function parseInteractiveEngineCommand(line: string): InteractiveEngineCommand | undefined {\n\tconst value = parseJsonObject(line);\n\tif (!value || typeof value.type !== \"string\" || typeof value.componentId !== \"string\") return undefined;\n\tif (\n\t\tvalue.type === \"engine_custom_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\ttypeof value.rows === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\trows: value.rows,\n\t\t};\n\t}\n\tif (value.type === \"engine_custom_input\" && typeof value.requestId === \"number\" && typeof value.data === \"string\")\n\t\treturn { type: value.type, componentId: value.componentId, requestId: value.requestId, data: value.data };\n\tif (value.type === \"engine_custom_dispose\" || value.type === \"engine_render_dispose\")\n\t\treturn { type: value.type, componentId: value.componentId };\n\tif (\n\t\t(value.type === \"engine_session_picker_select\" || value.type === \"engine_session_picker_delete\") &&\n\t\ttypeof value.path === \"string\"\n\t) {\n\t\treturn { type: value.type, componentId: value.componentId, path: value.path };\n\t}\n\tif (value.type === \"engine_session_picker_cancel\") return { type: value.type, componentId: value.componentId };\n\tif (value.type === \"engine_input_form_cancel\") return { type: value.type, componentId: value.componentId };\n\tif (value.type === \"engine_input_form_submit\") {\n\t\tconst values = parseStringRecord(value.values);\n\t\treturn values ? { type: value.type, componentId: value.componentId, values } : undefined;\n\t}\n\tif (\n\t\tvalue.type === \"engine_tool_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\ttypeof value.toolName === \"string\" &&\n\t\ttypeof value.toolCallId === \"string\" &&\n\t\ttypeof value.executionStarted === \"boolean\" &&\n\t\ttypeof value.argsComplete === \"boolean\" &&\n\t\ttypeof value.isPartial === \"boolean\" &&\n\t\ttypeof value.expanded === \"boolean\" &&\n\t\ttypeof value.showImages === \"boolean\" &&\n\t\ttypeof value.imageWidthCells === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\ttoolName: value.toolName,\n\t\t\ttoolCallId: value.toolCallId,\n\t\t\targs: value.args,\n\t\t\tresult: isJsonObject(value.result) ? value.result : undefined,\n\t\t\texecutionStarted: value.executionStarted,\n\t\t\targsComplete: value.argsComplete,\n\t\t\tisPartial: value.isPartial,\n\t\t\texpanded: value.expanded,\n\t\t\tshowImages: value.showImages,\n\t\t\timageWidthCells: value.imageWidthCells,\n\t\t};\n\t}\n\tif (\n\t\tvalue.type === \"engine_message_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\tisJsonObject(value.message) &&\n\t\ttypeof value.expanded === \"boolean\" &&\n\t\ttypeof value.outputPad === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\tmessage: value.message,\n\t\t\texpanded: value.expanded,\n\t\t\toutputPad: value.outputPad,\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function serializeInteractiveEngineFrame(message: InteractiveEngineMessage | InteractiveEngineCommand): string {\n\treturn `${JSON.stringify(message)}\\n`;\n}\n\nexport const serializeInteractiveEngineMessage = serializeInteractiveEngineFrame;\n"]}
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/modes/interactive-engine/protocol.ts"],"names":[],"mappings":"AAIA;;;;GAIG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,CAAC,CAAC;AAkIrD,MAAM,cAAc,GAAoC;IACvD,gBAAgB;IAChB,UAAU;IACV,cAAc;IACd,cAAc;IACd,mBAAmB;IACnB,cAAc;IACd,wBAAwB;CACxB,CAAC;AAEF,MAAM,UAAU,WAAW,CAAC,KAAgD;IAC3E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1E,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AACtF,CAAC;AAED,SAAS,YAAY,CAAC,KAAgB;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC7E,CAAC;AAED,SAAS,cAAc,CAAC,KAAgB;IACvC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,cAAc,CAAC,QAAQ,CAAC,KAA6B,CAAC,CAAC;AAC5F,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAgB;IAC3C,OAAO,CACN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ts\";\nimport type { HostInputFormField, HostSessionPickerRow } from \"../../core/extensions/ui-types.ts\";\nimport type { KeyId } from \"../../core/keybindings.ts\";\n\n/**\n * Version 3 adds correlated replies for `engine_custom_input`. The host uses\n * those replies to decide whether a matching fullscreen viewport key should be\n * replayed, so a child that cannot send them must not be treated as compatible.\n */\nexport const INTERACTIVE_ENGINE_PROTOCOL_VERSION = 3;\n\nexport interface JsonObject {\n\t[key: string]: JsonValue;\n}\n\nexport type JsonValue = boolean | JsonObject | JsonValue[] | null | number | string;\n\nexport interface SerializableOverlayOptions {\n\tanchor?: string;\n\tcol?: number | string;\n\tmargin?: number | { top?: number; right?: number; bottom?: number; left?: number };\n\tmaxHeight?: number | string;\n\tmaxWidth?: number | string;\n\tminHeight?: number;\n\tminWidth?: number;\n\toffsetX?: number;\n\toffsetY?: number;\n\trow?: number | string;\n\twidth?: number | string;\n}\n\n/**\n * Allowlisted terminal-mode control a remote custom component may ask the host\n * to apply to the real host TTY. Deliberately NOT a raw byte channel: the child\n * names an intent and the host owns the concrete escape sequence, so a buggy or\n * compromised child can only toggle this documented mode.\n */\nexport type EngineTerminalControl = { kind: \"autowrap\"; enabled: boolean };\n\nexport interface EngineExtensionShortcut {\n\tkey: string;\n\tdescription?: string;\n}\n\nexport type SerializableKeybindingsConfig = Record<string, KeyId | KeyId[]>;\n\nexport interface EngineKeybindingState {\n\tuserBindings: SerializableKeybindingsConfig;\n\teffectiveBindings: SerializableKeybindingsConfig;\n\tshortcuts: EngineExtensionShortcut[];\n}\n\nexport type InteractiveEngineMessage =\n\t| { type: \"engine_ready\"; protocolVersion: typeof INTERACTIVE_ENGINE_PROTOCOL_VERSION; pid: number }\n\t| { type: \"engine_bound\" }\n\t| { type: \"engine_keybindings_reloaded\"; state: EngineKeybindingState }\n\t| { type: \"engine_heartbeat\"; at: number }\n\t| { type: \"engine_activity_started\"; activity: CallbackActivity }\n\t| { type: \"engine_activity_finished\"; activityId: string }\n\t/**\n\t * The child took ownership of a correlated RPC request: it has parsed the\n\t * command and is about to run it. Emitted and flushed BEFORE any handler\n\t * work, so a later transport failure can be told apart from a send that\n\t * never landed. Output is not a substitute: a command can run to completion\n\t * with side effects and produce nothing.\n\t */\n\t| { type: \"engine_request_accepted\"; requestId: string; command: string }\n\t| {\n\t\t\ttype: \"engine_custom_open\";\n\t\t\tcomponentId: string;\n\t\t\toverlay: boolean;\n\t\t\tdeferInlineCustomUiFocus?: boolean;\n\t\t\thandlesCtrlC?: boolean;\n\t\t\thandlesInternalUiAction?: boolean;\n\t\t\toverlayOptions?: SerializableOverlayOptions;\n\t\t\twidgetKey?: string;\n\t\t\twidgetPlacement?: \"aboveEditor\" | \"belowEditor\";\n\t }\n\t| { type: \"engine_custom_close\"; componentId: string }\n\t| { type: \"engine_custom_frame\"; componentId: string; requestId: number; lines: string[] }\n\t| { type: \"engine_custom_input_result\"; componentId: string; requestId: number; handled: boolean }\n\t| { type: \"engine_custom_invalidate\"; componentId: string }\n\t| { type: \"engine_custom_done\"; componentId: string; result?: JsonValue }\n\t| { type: \"engine_custom_terminal\"; componentId: string; control: EngineTerminalControl }\n\t| { type: \"engine_custom_control\"; componentId: string; action: \"focus\" | \"hide\" | \"show\" | \"unfocus\" }\n\t| {\n\t\t\ttype: \"engine_session_picker_open\";\n\t\t\tcomponentId: string;\n\t\t\tsessions: HostSessionPickerRow[];\n\t\t\tshowRenameHint?: boolean;\n\t }\n\t| { type: \"engine_session_picker_update\"; componentId: string; sessions: HostSessionPickerRow[] }\n\t| { type: \"engine_session_picker_error\"; componentId: string; message: string }\n\t| { type: \"engine_session_picker_close\"; componentId: string }\n\t| {\n\t\t\ttype: \"engine_input_form_open\";\n\t\t\tcomponentId: string;\n\t\t\ttitle: string;\n\t\t\tfields: HostInputFormField[];\n\t\t\theading?: string;\n\t\t\tsubmitLabel?: string;\n\t }\n\t| { type: \"engine_input_form_close\"; componentId: string };\nexport type InteractiveEngineCommand =\n\t| { type: \"engine_custom_render\"; componentId: string; requestId: number; width: number; rows: number }\n\t| { type: \"engine_custom_input\"; componentId: string; requestId: number; data: string }\n\t| { type: \"engine_custom_dispose\"; componentId: string }\n\t| {\n\t\t\ttype: \"engine_tool_render\";\n\t\t\tcomponentId: string;\n\t\t\trequestId: number;\n\t\t\twidth: number;\n\t\t\ttoolName: string;\n\t\t\ttoolCallId: string;\n\t\t\targs: JsonValue;\n\t\t\tresult?: JsonObject;\n\t\t\texecutionStarted: boolean;\n\t\t\targsComplete: boolean;\n\t\t\tisPartial: boolean;\n\t\t\texpanded: boolean;\n\t\t\tshowImages: boolean;\n\t\t\timageWidthCells: number;\n\t }\n\t| {\n\t\t\ttype: \"engine_message_render\";\n\t\t\tcomponentId: string;\n\t\t\trequestId: number;\n\t\t\twidth: number;\n\t\t\tmessage: JsonObject;\n\t\t\texpanded: boolean;\n\t\t\toutputPad: number;\n\t }\n\t| { type: \"engine_render_dispose\"; componentId: string }\n\t| { type: \"engine_session_picker_select\"; componentId: string; path: string }\n\t| { type: \"engine_session_picker_cancel\"; componentId: string }\n\t| { type: \"engine_session_picker_delete\"; componentId: string; path: string }\n\t| { type: \"engine_input_form_submit\"; componentId: string; values: Record<string, string> }\n\t| { type: \"engine_input_form_cancel\"; componentId: string };\n\nconst ACTIVITY_KINDS: readonly CallbackActivityKind[] = [\n\t\"extension.hook\",\n\t\"renderer\",\n\t\"tool.execute\",\n\t\"tool.prepare\",\n\t\"workflow.ctx_tool\",\n\t\"workflow.run\",\n\t\"workflow.stage_adapter\",\n];\n\nexport function isJsonValue(value: object | boolean | null | number | string): value is JsonValue {\n\tif (value === null || typeof value !== \"object\") return true;\n\tif (Array.isArray(value)) return value.every((item) => isJsonValue(item));\n\treturn Object.values(value).every((item) => item !== undefined && isJsonValue(item));\n}\n\nfunction isJsonObject(value: JsonValue): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isActivityKind(value: JsonValue): value is CallbackActivityKind {\n\treturn typeof value === \"string\" && ACTIVITY_KINDS.includes(value as CallbackActivityKind);\n}\n\nfunction isCallbackActivity(value: JsonValue): value is JsonObject & CallbackActivity {\n\treturn (\n\t\tisJsonObject(value) &&\n\t\ttypeof value.id === \"string\" &&\n\t\tisActivityKind(value.kind) &&\n\t\ttypeof value.name === \"string\" &&\n\t\ttypeof value.startedAt === \"number\"\n\t);\n}\n\nfunction parseEngineTerminalControl(value: JsonValue | undefined): EngineTerminalControl | undefined {\n\tif (value === undefined || !isJsonObject(value) || value.kind !== \"autowrap\" || typeof value.enabled !== \"boolean\") {\n\t\treturn undefined;\n\t}\n\treturn { kind: \"autowrap\", enabled: value.enabled };\n}\n\nconst SESSION_PICKER_MESSAGE_COLORS = [\"success\", \"warning\", \"accent\", \"error\"] as const;\n\nfunction parseSessionPickerRow(value: JsonValue): HostSessionPickerRow | undefined {\n\tif (!isJsonObject(value)) return undefined;\n\tconst {\n\t\tpath,\n\t\tid,\n\t\tcwd,\n\t\tcreatedAt,\n\t\tmodifiedAt,\n\t\tmessageCount,\n\t\tfirstMessage,\n\t\tsummary,\n\t\tallMessagesText,\n\t\tname,\n\t\tmessageColor,\n\t} = value;\n\tif (\n\t\ttypeof path !== \"string\" ||\n\t\ttypeof id !== \"string\" ||\n\t\ttypeof cwd !== \"string\" ||\n\t\ttypeof createdAt !== \"number\" ||\n\t\ttypeof modifiedAt !== \"number\" ||\n\t\ttypeof messageCount !== \"number\" ||\n\t\ttypeof firstMessage !== \"string\"\n\t)\n\t\treturn undefined;\n\tif (summary !== undefined && typeof summary !== \"string\") return undefined;\n\tif (allMessagesText !== undefined && typeof allMessagesText !== \"string\") return undefined;\n\tif (name !== undefined && typeof name !== \"string\") return undefined;\n\tif (\n\t\tmessageColor !== undefined &&\n\t\t!SESSION_PICKER_MESSAGE_COLORS.includes(messageColor as (typeof SESSION_PICKER_MESSAGE_COLORS)[number])\n\t)\n\t\treturn undefined;\n\treturn {\n\t\tpath,\n\t\tid,\n\t\tcwd,\n\t\tcreatedAt,\n\t\tmodifiedAt,\n\t\tmessageCount,\n\t\tfirstMessage,\n\t\t...(summary !== undefined ? { summary } : {}),\n\t\t...(allMessagesText !== undefined ? { allMessagesText } : {}),\n\t\t...(name !== undefined ? { name } : {}),\n\t\t...(messageColor !== undefined\n\t\t\t? { messageColor: messageColor as (typeof SESSION_PICKER_MESSAGE_COLORS)[number] }\n\t\t\t: {}),\n\t};\n}\n\nfunction parseSessionPickerRows(value: JsonValue | undefined): HostSessionPickerRow[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst rows: HostSessionPickerRow[] = [];\n\tfor (const entry of value) {\n\t\tconst row = parseSessionPickerRow(entry);\n\t\tif (!row) return undefined;\n\t\trows.push(row);\n\t}\n\treturn rows;\n}\n\nconst INPUT_FORM_FIELD_TYPES = [\"string\", \"text\", \"number\", \"integer\", \"boolean\", \"select\"] as const;\n\nfunction parseInputFormFields(value: JsonValue | undefined): HostInputFormField[] | undefined {\n\tif (!Array.isArray(value)) return undefined;\n\tconst fields: HostInputFormField[] = [];\n\tfor (const entry of value) {\n\t\tif (!isJsonObject(entry)) return undefined;\n\t\tconst { name, type, description, required, choices, placeholder, initialValue } = entry;\n\t\tif (\n\t\t\ttypeof name !== \"string\" ||\n\t\t\t!INPUT_FORM_FIELD_TYPES.includes(type as HostInputFormField[\"type\"]) ||\n\t\t\ttypeof initialValue !== \"string\"\n\t\t)\n\t\t\treturn undefined;\n\t\tif (description !== undefined && typeof description !== \"string\") return undefined;\n\t\tif (required !== undefined && typeof required !== \"boolean\") return undefined;\n\t\tif (choices !== undefined && (!Array.isArray(choices) || !choices.every((choice) => typeof choice === \"string\")))\n\t\t\treturn undefined;\n\t\tif (placeholder !== undefined && typeof placeholder !== \"string\") return undefined;\n\t\tfields.push({\n\t\t\tname,\n\t\t\ttype: type as HostInputFormField[\"type\"],\n\t\t\tinitialValue,\n\t\t\t...(typeof description === \"string\" ? { description } : {}),\n\t\t\t...(typeof required === \"boolean\" ? { required } : {}),\n\t\t\t...(Array.isArray(choices) ? { choices: choices as string[] } : {}),\n\t\t\t...(typeof placeholder === \"string\" ? { placeholder } : {}),\n\t\t});\n\t}\n\treturn fields;\n}\n\nfunction parseStringRecord(value: JsonValue | undefined): Record<string, string> | undefined {\n\tif (value === undefined || !isJsonObject(value)) return undefined;\n\tconst entries = Object.entries(value);\n\tif (entries.some(([, entry]) => typeof entry !== \"string\")) return undefined;\n\treturn Object.fromEntries(entries) as Record<string, string>;\n}\n\nfunction parseKeybindingsConfig(value: JsonValue | undefined): SerializableKeybindingsConfig | undefined {\n\tif (value === undefined || !isJsonObject(value)) return undefined;\n\tconst config: SerializableKeybindingsConfig = {};\n\tfor (const [key, binding] of Object.entries(value)) {\n\t\tif (typeof binding === \"string\") config[key] = binding as SerializableKeybindingsConfig[string];\n\t\telse if (Array.isArray(binding) && binding.every((entry) => typeof entry === \"string\")) {\n\t\t\tconfig[key] = binding as SerializableKeybindingsConfig[string];\n\t\t} else return undefined;\n\t}\n\treturn config;\n}\n\nfunction parseKeybindingState(value: JsonValue | undefined): EngineKeybindingState | undefined {\n\tif (value === undefined || !isJsonObject(value) || !Array.isArray(value.shortcuts)) return undefined;\n\tconst userBindings = parseKeybindingsConfig(value.userBindings);\n\tconst effectiveBindings = parseKeybindingsConfig(value.effectiveBindings);\n\tif (!userBindings || !effectiveBindings) return undefined;\n\tconst shortcuts: EngineExtensionShortcut[] = [];\n\tfor (const shortcut of value.shortcuts) {\n\t\tif (\n\t\t\t!isJsonObject(shortcut) ||\n\t\t\ttypeof shortcut.key !== \"string\" ||\n\t\t\t(shortcut.description !== undefined && typeof shortcut.description !== \"string\")\n\t\t)\n\t\t\treturn undefined;\n\t\tshortcuts.push({\n\t\t\tkey: shortcut.key,\n\t\t\t...(typeof shortcut.description === \"string\" ? { description: shortcut.description } : {}),\n\t\t});\n\t}\n\treturn { userBindings, effectiveBindings, shortcuts };\n}\n\nfunction parseJsonObject(line: string): JsonObject | undefined {\n\tlet value: JsonValue;\n\ttry {\n\t\tvalue = JSON.parse(line) as JsonValue;\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn isJsonObject(value) ? value : undefined;\n}\n\nexport function parseInteractiveEngineMessage(line: string): InteractiveEngineMessage | undefined {\n\tconst value = parseJsonObject(line);\n\tif (!value || typeof value.type !== \"string\") return undefined;\n\tswitch (value.type) {\n\t\tcase \"engine_ready\":\n\t\t\treturn value.protocolVersion === INTERACTIVE_ENGINE_PROTOCOL_VERSION && typeof value.pid === \"number\"\n\t\t\t\t? { type: value.type, protocolVersion: INTERACTIVE_ENGINE_PROTOCOL_VERSION, pid: value.pid }\n\t\t\t\t: undefined;\n\t\tcase \"engine_bound\":\n\t\t\treturn { type: value.type };\n\t\tcase \"engine_keybindings_reloaded\": {\n\t\t\tconst state = parseKeybindingState(value.state);\n\t\t\treturn state ? { type: value.type, state } : undefined;\n\t\t}\n\t\tcase \"engine_heartbeat\":\n\t\t\treturn typeof value.at === \"number\" ? { type: value.type, at: value.at } : undefined;\n\t\tcase \"engine_activity_started\":\n\t\t\treturn isCallbackActivity(value.activity) ? { type: value.type, activity: value.activity } : undefined;\n\t\tcase \"engine_activity_finished\":\n\t\t\treturn typeof value.activityId === \"string\" ? { type: value.type, activityId: value.activityId } : undefined;\n\t\tcase \"engine_request_accepted\":\n\t\t\treturn typeof value.requestId === \"string\" && typeof value.command === \"string\"\n\t\t\t\t? { type: value.type, requestId: value.requestId, command: value.command }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_open\":\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.overlay === \"boolean\"\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\toverlay: value.overlay,\n\t\t\t\t\t\tdeferInlineCustomUiFocus: value.deferInlineCustomUiFocus === true,\n\t\t\t\t\t\thandlesCtrlC: value.handlesCtrlC === true,\n\t\t\t\t\t\thandlesInternalUiAction: value.handlesInternalUiAction === true,\n\t\t\t\t\t\toverlayOptions: isJsonObject(value.overlayOptions)\n\t\t\t\t\t\t\t? (value.overlayOptions as SerializableOverlayOptions)\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\twidgetKey: typeof value.widgetKey === \"string\" ? value.widgetKey : undefined,\n\t\t\t\t\t\twidgetPlacement:\n\t\t\t\t\t\t\tvalue.widgetPlacement === \"belowEditor\"\n\t\t\t\t\t\t\t\t? \"belowEditor\"\n\t\t\t\t\t\t\t\t: value.widgetPlacement === \"aboveEditor\"\n\t\t\t\t\t\t\t\t\t? \"aboveEditor\"\n\t\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_close\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_frame\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\ttypeof value.requestId === \"number\" &&\n\t\t\t\tArray.isArray(value.lines) &&\n\t\t\t\tvalue.lines.every((entry) => typeof entry === \"string\")\n\t\t\t\t? { type: value.type, componentId: value.componentId, requestId: value.requestId, lines: value.lines }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_input_result\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\ttypeof value.requestId === \"number\" &&\n\t\t\t\ttypeof value.handled === \"boolean\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, requestId: value.requestId, handled: value.handled }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_invalidate\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_done\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, result: value.result }\n\t\t\t\t: undefined;\n\t\tcase \"engine_custom_terminal\": {\n\t\t\tconst control = parseEngineTerminalControl(value.control);\n\t\t\treturn typeof value.componentId === \"string\" && control\n\t\t\t\t? { type: value.type, componentId: value.componentId, control }\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_custom_control\":\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\t[\"focus\", \"hide\", \"show\", \"unfocus\"].includes(String(value.action))\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\taction: value.action as \"focus\" | \"hide\" | \"show\" | \"unfocus\",\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\tcase \"engine_session_picker_open\": {\n\t\t\tconst sessions = parseSessionPickerRows(value.sessions);\n\t\t\treturn typeof value.componentId === \"string\" &&\n\t\t\t\tsessions &&\n\t\t\t\t(value.showRenameHint === undefined || typeof value.showRenameHint === \"boolean\")\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\tsessions,\n\t\t\t\t\t\t...(typeof value.showRenameHint === \"boolean\" ? { showRenameHint: value.showRenameHint } : {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_session_picker_update\": {\n\t\t\tconst sessions = parseSessionPickerRows(value.sessions);\n\t\t\treturn typeof value.componentId === \"string\" && sessions\n\t\t\t\t? { type: value.type, componentId: value.componentId, sessions }\n\t\t\t\t: undefined;\n\t\t}\n\t\tcase \"engine_session_picker_error\":\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.message === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId, message: value.message }\n\t\t\t\t: undefined;\n\t\tcase \"engine_session_picker_close\":\n\t\tcase \"engine_input_form_close\":\n\t\t\treturn typeof value.componentId === \"string\"\n\t\t\t\t? { type: value.type, componentId: value.componentId }\n\t\t\t\t: undefined;\n\t\tcase \"engine_input_form_open\": {\n\t\t\tconst fields = parseInputFormFields(value.fields);\n\t\t\treturn typeof value.componentId === \"string\" && typeof value.title === \"string\" && fields\n\t\t\t\t? {\n\t\t\t\t\t\ttype: value.type,\n\t\t\t\t\t\tcomponentId: value.componentId,\n\t\t\t\t\t\ttitle: value.title,\n\t\t\t\t\t\tfields,\n\t\t\t\t\t\t...(typeof value.heading === \"string\" ? { heading: value.heading } : {}),\n\t\t\t\t\t\t...(typeof value.submitLabel === \"string\" ? { submitLabel: value.submitLabel } : {}),\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\t}\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n\nexport function parseInteractiveEngineCommand(line: string): InteractiveEngineCommand | undefined {\n\tconst value = parseJsonObject(line);\n\tif (!value || typeof value.type !== \"string\" || typeof value.componentId !== \"string\") return undefined;\n\tif (\n\t\tvalue.type === \"engine_custom_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\ttypeof value.rows === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\trows: value.rows,\n\t\t};\n\t}\n\tif (value.type === \"engine_custom_input\" && typeof value.requestId === \"number\" && typeof value.data === \"string\")\n\t\treturn { type: value.type, componentId: value.componentId, requestId: value.requestId, data: value.data };\n\tif (value.type === \"engine_custom_dispose\" || value.type === \"engine_render_dispose\")\n\t\treturn { type: value.type, componentId: value.componentId };\n\tif (\n\t\t(value.type === \"engine_session_picker_select\" || value.type === \"engine_session_picker_delete\") &&\n\t\ttypeof value.path === \"string\"\n\t) {\n\t\treturn { type: value.type, componentId: value.componentId, path: value.path };\n\t}\n\tif (value.type === \"engine_session_picker_cancel\") return { type: value.type, componentId: value.componentId };\n\tif (value.type === \"engine_input_form_cancel\") return { type: value.type, componentId: value.componentId };\n\tif (value.type === \"engine_input_form_submit\") {\n\t\tconst values = parseStringRecord(value.values);\n\t\treturn values ? { type: value.type, componentId: value.componentId, values } : undefined;\n\t}\n\tif (\n\t\tvalue.type === \"engine_tool_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\ttypeof value.toolName === \"string\" &&\n\t\ttypeof value.toolCallId === \"string\" &&\n\t\ttypeof value.executionStarted === \"boolean\" &&\n\t\ttypeof value.argsComplete === \"boolean\" &&\n\t\ttypeof value.isPartial === \"boolean\" &&\n\t\ttypeof value.expanded === \"boolean\" &&\n\t\ttypeof value.showImages === \"boolean\" &&\n\t\ttypeof value.imageWidthCells === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\ttoolName: value.toolName,\n\t\t\ttoolCallId: value.toolCallId,\n\t\t\targs: value.args,\n\t\t\tresult: isJsonObject(value.result) ? value.result : undefined,\n\t\t\texecutionStarted: value.executionStarted,\n\t\t\targsComplete: value.argsComplete,\n\t\t\tisPartial: value.isPartial,\n\t\t\texpanded: value.expanded,\n\t\t\tshowImages: value.showImages,\n\t\t\timageWidthCells: value.imageWidthCells,\n\t\t};\n\t}\n\tif (\n\t\tvalue.type === \"engine_message_render\" &&\n\t\ttypeof value.requestId === \"number\" &&\n\t\ttypeof value.width === \"number\" &&\n\t\tisJsonObject(value.message) &&\n\t\ttypeof value.expanded === \"boolean\" &&\n\t\ttypeof value.outputPad === \"number\"\n\t) {\n\t\treturn {\n\t\t\ttype: value.type,\n\t\t\tcomponentId: value.componentId,\n\t\t\trequestId: value.requestId,\n\t\t\twidth: value.width,\n\t\t\tmessage: value.message,\n\t\t\texpanded: value.expanded,\n\t\t\toutputPad: value.outputPad,\n\t\t};\n\t}\n\treturn undefined;\n}\n\nexport function serializeInteractiveEngineFrame(message: InteractiveEngineMessage | InteractiveEngineCommand): string {\n\treturn `${JSON.stringify(message)}\\n`;\n}\n\nexport const serializeInteractiveEngineMessage = serializeInteractiveEngineFrame;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"remote-component.d.ts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AAC,OAAO;CAkBf"}
1
+ {"version":3,"file":"remote-component.d.ts","sourceRoot":"","sources":["../../../src/modes/interactive-engine/remote-component.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAiBxE;;;GAGG;AACH,eAAO,MAAM,6BAA6B,MAAM,CAAC;AA+IjD,MAAM,WAAW,oBAAoB;IACpC,YAAY,IAAI,OAAO,CAAC;IACxB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;CACrD;AAED,qBAAa,yBAAyB;IACrC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6C;IACrE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;IACzC,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAa;IACxD,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IACvD,OAAO,CAAC,QAAQ,CAAC,8BAA8B,CAAa;IAE5D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAqB;IAExC,YACC,OAAO,EAAE,0BAA0B,EACnC,EAAE,EAAE,kBAAkB,EACtB,oBAAoB,EAAE,oBAAoB,EAa1C;IAED,OAAO,IAAI,IAAI,CAKd;IAED,2FAA2F;IAC3F,oBAAoB,IAAI,OAAO,CAK9B;IAED,sFAAsF;IACtF,gBAAgB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAM5C;IAED,iFAAiF;IACjF,uBAAuB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAKnD;IAED;;;;;;;;;;OAUG;IACH,kBAAkB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAQ9C;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,OAAO,CAAC,UAAU;IAalB,OAAO,CAAC,aAAa;IAkDrB,OAAO,CAAC,IAAI;IA6EZ,OAAO,CAAC,KAAK;IASb,OAAO,CAAC,OAAO;CAkBf"}
@@ -6,10 +6,11 @@ import { TerminalModeController } from "./terminal-mode-controller.js";
6
6
  */
7
7
  export const REMOTE_INPUT_REPLY_TIMEOUT_MS = 250;
8
8
  class RemoteComponent {
9
- constructor(componentId, runtime, requestRender, getRows) {
9
+ constructor(componentId, runtime, requestRender, getRows, handlesInternalUiAction = false) {
10
10
  this.wantsKeyRelease = true;
11
11
  this.lines = ["Loading remote component…"];
12
12
  this.width = 0;
13
+ this.rows = 0;
13
14
  this.requestId = 0;
14
15
  this.inputRequestId = 0;
15
16
  this.appliedRequestId = 0;
@@ -21,17 +22,20 @@ class RemoteComponent {
21
22
  this.runtime = runtime;
22
23
  this.requestRender = requestRender;
23
24
  this.getRows = getRows;
25
+ this.handlesInternalUiAction = handlesInternalUiAction;
24
26
  }
25
27
  render(width) {
26
- if (!this.disposed && (this.dirty || width !== this.width)) {
28
+ const rows = this.getRows();
29
+ if (!this.disposed && (this.dirty || width !== this.width || rows !== this.rows)) {
27
30
  this.width = width;
31
+ this.rows = rows;
28
32
  this.dirty = false;
29
33
  this.runtime.sendEngineCommand({
30
34
  type: "engine_custom_render",
31
35
  componentId: this.componentId,
32
36
  requestId: ++this.requestId,
33
37
  width,
34
- rows: this.getRows(),
38
+ rows,
35
39
  });
36
40
  }
37
41
  // The engine child re-renders asynchronously; until the fresh frame
@@ -230,7 +234,7 @@ export class RemoteComponentController {
230
234
  this.disposeAll("generation-lost");
231
235
  break;
232
236
  case "engine_custom_open":
233
- this.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement, message.handlesCtrlC === true);
237
+ this.open(message.componentId, message.overlay, message.deferInlineCustomUiFocus, message.overlayOptions, message.widgetKey, message.widgetPlacement, message.handlesCtrlC === true, message.handlesInternalUiAction === true);
234
238
  break;
235
239
  case "engine_custom_close":
236
240
  this.close(message.componentId);
@@ -260,13 +264,20 @@ export class RemoteComponentController {
260
264
  break;
261
265
  }
262
266
  }
263
- open(componentId, overlay, deferInlineCustomUiFocus, options, widgetKey, widgetPlacement, handlesCtrlC = false) {
267
+ open(componentId, overlay, deferInlineCustomUiFocus, options, widgetKey, widgetPlacement, handlesCtrlC = false, handlesInternalUiAction = false) {
264
268
  if (this.mounted.has(componentId))
265
269
  return;
266
270
  if (widgetKey) {
267
271
  let rows = 24;
268
- const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => rows);
269
- this.mounted.set(componentId, { component, done: () => { }, engineDone: false, handlesCtrlC, widgetKey });
272
+ const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => rows, handlesInternalUiAction);
273
+ this.mounted.set(componentId, {
274
+ component,
275
+ done: () => { },
276
+ engineDone: false,
277
+ handlesCtrlC,
278
+ handlesInternalUiAction,
279
+ widgetKey,
280
+ });
270
281
  this.ui.setWidget(widgetKey, (tui) => {
271
282
  rows = tui.terminal.rows;
272
283
  return component;
@@ -276,8 +287,8 @@ export class RemoteComponentController {
276
287
  let mounted;
277
288
  void this.ui
278
289
  .custom((tui, _theme, _keybindings, done) => {
279
- const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows);
280
- mounted = { component, done, engineDone: false, handlesCtrlC };
290
+ const component = new RemoteComponent(componentId, this.runtime, () => this.ui.requestRender(), () => tui.terminal.rows, handlesInternalUiAction);
291
+ mounted = { component, done, engineDone: false, handlesCtrlC, handlesInternalUiAction };
281
292
  this.mounted.set(componentId, mounted);
282
293
  // Bind this component to the real host terminal so a buffered
283
294
  // autowrap control emitted before the mount frame applies to the host TTY.
@@ -286,6 +297,7 @@ export class RemoteComponentController {
286
297
  }, {
287
298
  overlay,
288
299
  deferInlineCustomUiFocus,
300
+ handlesInternalUiAction,
289
301
  overlayOptions: overlayOptions(options),
290
302
  onHandle: (handle) => {
291
303
  if (mounted)
@@ -1 +1 @@
1
- {"version":3,"file":"remote-component.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,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;QACjC,IAAI,MAAM,CAAC,SAAS;YAAE,IAAI,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACrE,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;IAC5B,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 type { Component, OverlayHandle, OverlayOptions, TUI } from \"@earendil-works/pi-tui\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.ts\";\nimport type { InteractiveEngineMessage, JsonValue, SerializableOverlayOptions } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\nimport { TerminalModeController } from \"./terminal-mode-controller.ts\";\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\thandle?: OverlayHandle;\n\twidgetKey?: string;\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}\n\nclass RemoteComponent implements Component {\n\twantsKeyRelease = true;\n\tprivate lines = [\"Loading remote component…\"];\n\tprivate width = 0;\n\tprivate requestId = 0;\n\tprivate inputRequestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly pendingInputs = new Map<number, PendingInput>();\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\n\tprivate readonly componentId: string;\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly getRows: () => number;\n\n\tconstructor(\n\t\tcomponentId: string,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\tgetRows: () => number,\n\t) {\n\t\tthis.componentId = componentId;\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.getRows = getRows;\n\t}\n\n\trender(width: number): string[] {\n\t\tif (!this.disposed && (this.dirty || width !== this.width)) {\n\t\t\tthis.width = width;\n\t\t\tthis.dirty = false;\n\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\ttype: \"engine_custom_render\",\n\t\t\t\tcomponentId: this.componentId,\n\t\t\t\trequestId: ++this.requestId,\n\t\t\t\twidth,\n\t\t\t\trows: this.getRows(),\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\thandleInput(data: string): Promise<boolean | undefined> {\n\t\tif (this.disposed) return Promise.resolve(undefined);\n\t\tconst requestId = ++this.inputRequestId;\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 });\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});\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. Pipelining\n\t\t// the request keeps keypress latency at a single round trip and repaints\n\t\t// components that never self-invalidate, instead of waiting for a\n\t\t// child-side invalidate (or an unrelated refresh) to trigger a frame.\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t\treturn result;\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\tthis.pendingInputs.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\tapplyFrame(requestId: number, lines: string[]): void {\n\t\tif (this.disposed || requestId < this.appliedRequestId) return;\n\t\tthis.appliedRequestId = requestId;\n\t\tthis.lines = lines;\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\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}\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: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\n\tconstructor(\n\t\truntime: IsolatedInteractiveRuntime,\n\t\tui: ExtensionUIContext,\n\t\ttuiRendererLifecycle: TuiRendererLifecycle,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\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 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) return record.widgetKey === 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) continue;\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\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.component.dispose(reason === \"host-shutdown\" && !record.engineDone);\n\t\t\tif (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);\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.get(message.componentId)?.component.applyFrame(message.requestId, message.lines);\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_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): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tif (widgetKey) {\n\t\t\tlet rows = 24;\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() => rows,\n\t\t\t);\n\t\t\tthis.mounted.set(componentId, { component, done: () => {}, engineDone: false, handlesCtrlC, widgetKey });\n\t\t\tthis.ui.setWidget(\n\t\t\t\twidgetKey,\n\t\t\t\t(tui) => {\n\t\t\t\t\trows = tui.terminal.rows;\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{ placement: widgetPlacement },\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);\n\t\t\t\t\tmounted = { component, done, engineDone: false, handlesCtrlC };\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\tdeferInlineCustomUiFocus,\n\t\t\t\t\toverlayOptions: overlayOptions(options),\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\tif (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\trecord.component.dispose();\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":"AAIA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAcvE;;;GAGG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAOjD,MAAM,eAAe;IAmBpB,YACC,WAAmB,EACnB,OAAmC,EACnC,aAAyB,EACzB,OAAqB,EACrB,uBAAuB,GAAG,KAAK;QAvBhC,oBAAe,GAAG,IAAI,CAAC;QAEf,UAAK,GAAG,CAAC,2BAA2B,CAAC,CAAC;QACtC,UAAK,GAAG,CAAC,CAAC;QACV,SAAI,GAAG,CAAC,CAAC;QACT,cAAS,GAAG,CAAC,CAAC;QACd,mBAAc,GAAG,CAAC,CAAC;QACnB,qBAAgB,GAAG,CAAC,CAAC;QACrB,UAAK,GAAG,IAAI,CAAC;QACb,aAAQ,GAAG,KAAK,CAAC;QACR,kBAAa,GAAG,IAAI,GAAG,EAAwB,CAAC;QAChD,eAAU,GAAG,IAAI,qBAAqB,EAAE,CAAC;QAczD,IAAI,CAAC,WAAW,GAA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M,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 type { Component, OverlayHandle, OverlayOptions, TUI } from \"@earendil-works/pi-tui\";\nimport type { ExtensionUIContext } from \"../../core/extensions/index.ts\";\nimport type { IsolatedInteractiveRuntime } from \"./isolated-runtime.ts\";\nimport type { InteractiveEngineMessage, JsonValue, SerializableOverlayOptions } from \"./protocol.ts\";\nimport { RemoteFrameWidthClamp } from \"./remote-frame-clamp.ts\";\nimport { TerminalModeController } from \"./terminal-mode-controller.ts\";\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}\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}\n\nclass RemoteComponent implements Component {\n\twantsKeyRelease = true;\n\treadonly handlesInternalUiAction: boolean;\n\tprivate lines = [\"Loading remote component…\"];\n\tprivate width = 0;\n\tprivate rows = 0;\n\tprivate requestId = 0;\n\tprivate inputRequestId = 0;\n\tprivate appliedRequestId = 0;\n\tprivate dirty = true;\n\tprivate disposed = false;\n\tprivate readonly pendingInputs = new Map<number, PendingInput>();\n\tprivate readonly frameClamp = new RemoteFrameWidthClamp();\n\n\tprivate readonly componentId: string;\n\tprivate readonly runtime: IsolatedInteractiveRuntime;\n\tprivate readonly requestRender: () => void;\n\tprivate readonly getRows: () => number;\n\n\tconstructor(\n\t\tcomponentId: string,\n\t\truntime: IsolatedInteractiveRuntime,\n\t\trequestRender: () => void,\n\t\tgetRows: () => number,\n\t\thandlesInternalUiAction = false,\n\t) {\n\t\tthis.componentId = componentId;\n\t\tthis.runtime = runtime;\n\t\tthis.requestRender = requestRender;\n\t\tthis.getRows = getRows;\n\t\tthis.handlesInternalUiAction = handlesInternalUiAction;\n\t}\n\n\trender(width: number): string[] {\n\t\tconst rows = this.getRows();\n\t\tif (!this.disposed && (this.dirty || width !== this.width || rows !== this.rows)) {\n\t\t\tthis.width = width;\n\t\t\tthis.rows = rows;\n\t\t\tthis.dirty = false;\n\t\t\tthis.runtime.sendEngineCommand({\n\t\t\t\ttype: \"engine_custom_render\",\n\t\t\t\tcomponentId: this.componentId,\n\t\t\t\trequestId: ++this.requestId,\n\t\t\t\twidth,\n\t\t\t\trows,\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\thandleInput(data: string): Promise<boolean | undefined> {\n\t\tif (this.disposed) return Promise.resolve(undefined);\n\t\tconst requestId = ++this.inputRequestId;\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 });\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});\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. Pipelining\n\t\t// the request keeps keypress latency at a single round trip and repaints\n\t\t// components that never self-invalidate, instead of waiting for a\n\t\t// child-side invalidate (or an unrelated refresh) to trigger a frame.\n\t\tthis.dirty = true;\n\t\tthis.requestRender();\n\t\treturn result;\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\tthis.pendingInputs.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\tapplyFrame(requestId: number, lines: string[]): void {\n\t\tif (this.disposed || requestId < this.appliedRequestId) return;\n\t\tthis.appliedRequestId = requestId;\n\t\tthis.lines = lines;\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\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}\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: IsolatedInteractiveRuntime;\n\tprivate readonly ui: ExtensionUIContext;\n\n\tconstructor(\n\t\truntime: IsolatedInteractiveRuntime,\n\t\tui: ExtensionUIContext,\n\t\ttuiRendererLifecycle: TuiRendererLifecycle,\n\t) {\n\t\tthis.runtime = runtime;\n\t\tthis.ui = ui;\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 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) return record.widgetKey === 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) continue;\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\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.component.dispose(reason === \"host-shutdown\" && !record.engineDone);\n\t\t\tif (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);\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.get(message.componentId)?.component.applyFrame(message.requestId, message.lines);\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_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): void {\n\t\tif (this.mounted.has(componentId)) return;\n\t\tif (widgetKey) {\n\t\t\tlet rows = 24;\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() => rows,\n\t\t\t\thandlesInternalUiAction,\n\t\t\t);\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});\n\t\t\tthis.ui.setWidget(\n\t\t\t\twidgetKey,\n\t\t\t\t(tui) => {\n\t\t\t\t\trows = tui.terminal.rows;\n\t\t\t\t\treturn component;\n\t\t\t\t},\n\t\t\t\t{ placement: widgetPlacement },\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\thandlesInternalUiAction,\n\t\t\t\t\t);\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\tdeferInlineCustomUiFocus,\n\t\t\t\t\thandlesInternalUiAction,\n\t\t\t\t\toverlayOptions: overlayOptions(options),\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\tif (record.widgetKey) this.ui.setWidget(record.widgetKey, undefined);\n\t\trecord.component.dispose();\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"]}
@@ -26,7 +26,7 @@ Provider keys include `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `AZURE_OPENAI_API_K
26
26
 
27
27
  ## Bash session environment
28
28
 
29
- Every built-in, factory-created, direct, foreground/background, workflow-stage, and isolated bash execution receives one execution-time snapshot:
29
+ Every built-in, factory-created, direct, workflow-stage, and isolated bash execution receives one execution-time snapshot:
30
30
 
31
31
  | Atomic variable | Exact Pi alias | Value |
32
32
  |---|---|---|
package/docs/intercom.md CHANGED
@@ -12,18 +12,17 @@ Atomic bundles `@bastani/intercom`, a first-party extension for direct 1:1 messa
12
12
  **Key capabilities:**
13
13
  - **Session messaging** - `send`, `ask` (blocking, 10-minute timeout), `reply`, `pending`, `list`, and `status` via the `intercom` tool
14
14
  - **Runtime groups** - `join` or `leave` named groups without restarting; joined sessions keep their broker IDs and subagents inherit the joined group
15
- - **Session discovery** - List connected sessions with name, short ID, working directory, model, and live status
15
+ - **Session discovery** - List connected sessions with name, full session ID, working directory, model, and live status
16
16
  - **Keyboard overlay** - ALT+M or `/intercom` opens a session picker and compose overlay
17
17
  - **Attachments** - Share `file`, `snippet`, and `context` payloads between sessions
18
18
  - **Subagent escalation** - Delegated children get a `contact_supervisor` tool for decisions, structured interviews, and progress updates
19
- - **Run notifications** - Workflows and subagents deliver async results and control notices to a parent session over Intercom
19
+ - **Run notifications** - Workflows and subagents deliver run results and control notices to a parent session over Intercom
20
20
  - **Bundled skill** - `/skill:intercom` provides planner-worker, group, and escalation-handling patterns
21
21
 
22
22
  **Example use cases:**
23
23
  - Planner–worker splits across two terminals
24
24
  - Research → implementation context handoffs
25
25
  - Supervisor decisions and structured interviews for delegated subagents
26
- - Async workflow/subagent completion and needs-attention notices
27
26
  - Pair debugging between sessions
28
27
 
29
28
  ## Table of Contents
@@ -75,20 +74,20 @@ The agent can list sessions and send messages using the `intercom` tool. Tool ca
75
74
  // List active sessions
76
75
  intercom({ action: "list" })
77
76
  // → **Current session:**
78
- // → • executor (20d43841) — ~/projects/api (claude-sonnet-4) [self, idle]
77
+ // → • executor (20d43841-1111-4222-8333-123456789abc) — ~/projects/api (claude-sonnet-4) [self, idle]
79
78
  // → **Other sessions:**
80
- // → • research (6332faab) — ~/projects/api (claude-sonnet-4) [same cwd, thinking]
79
+ // → • research (6332faab-1111-4222-8333-123456789abc) — ~/projects/api (claude-sonnet-4) [same cwd, thinking]
81
80
 
82
81
  // Send a message
83
82
  intercom({ action: "send", to: "research", message: "Check if UserService.validate() handles null" })
84
83
  // → Message sent to research
85
84
 
86
- // The short ID printed by list is also a valid target
87
- intercom({ action: "ask", to: "6332faab", message: "Which validation path should I use?" })
85
+ // The full session ID printed by list is also a valid target
86
+ intercom({ action: "ask", to: "6332faab-1111-4222-8333-123456789abc", message: "Which validation path should I use?" })
88
87
 
89
88
  // Check connection status
90
89
  intercom({ action: "status" })
91
- // → Connected: Yes, Session ID: abc123, Active sessions: 3
90
+ // → Connected: Yes, Session ID: abc12345-1111-4222-8333-123456789abc, Active sessions: 3
92
91
 
93
92
  // Send with attachments (code snippets, files, or context)
94
93
  intercom({
@@ -132,14 +131,14 @@ A session becomes intercom-connected when all of these are true:
132
131
 
133
132
  The session list only shows intercom-connected sessions, not every open Atomic process on the machine.
134
133
 
135
- Name sessions with `/name` so they can target each other (for example `/name planner` and `/name worker`). If a session is unnamed, Intercom exposes a runtime-only fallback alias like `subagent-chat-1a2b3c4d` so other sessions can still target it. That alias is not persisted as the session title, so resume pickers keep showing the transcript snippet instead of a generic name.
134
+ Name sessions with `/name` so they can target each other (for example `/name planner` and `/name worker`). If a session is unnamed, Intercom exposes a runtime-only fallback alias like `subagent-chat-1a2b3c4d-1111-4222-8333-123456789abc` so other sessions can still target it. That alias is not persisted as the session title, so resume pickers keep showing the transcript snippet instead of a generic name.
136
135
 
137
136
  ## The intercom Tool
138
137
 
139
138
  | Parameter | Type | Description |
140
139
  |-----------|------|-------------|
141
140
  | `action` | string | `"list"`, `"join"`, `"leave"`, `"send"`, `"ask"`, `"reply"`, `"pending"`, or `"status"` |
142
- | `to` | string | Exact session name, exact full ID, or unique ID prefix (for send/ask, or to disambiguate reply) |
141
+ | `to` | string | Exact session name or exact full session ID (for send/ask, or targeted reply) |
143
142
  | `message` | string | Message text (for send/ask/reply) |
144
143
  | `attachments` | array | Optional `file`, `snippet`, or `context` attachments |
145
144
  | `replyTo` | string | Optional message ID for threading or replying to an `ask` |
@@ -151,7 +150,7 @@ Name sessions with `/name` so they can target each other (for example `/name pla
151
150
  |--------|----------|
152
151
  | `join` | Moves the session into a trimmed named group and creates it if needed. The action waits for broker acknowledgement before changing local inheritance state. `default` is the shared group; `true` and `auto` are reserved for subagent auto-groups. |
153
152
  | `leave` | Returns the session to its resolved home group from startup. It takes no `group` parameter. |
154
- | `list` | Returns the current session plus other active intercom-connected sessions with name, short ID, working directory, model, and live status (`idle`, `thinking`, or `tool:<name>`, derived from lifecycle events). Every displayed short ID is a valid target. |
153
+ | `list` | Returns the current session plus other active intercom-connected sessions with name, full session ID, working directory, model, and live status (`idle`, `thinking`, or `tool:<name>`, derived from lifecycle events). Every displayed full session ID is a valid target. |
155
154
  | `send` | Fire-and-forget delivery. Requires `to` and `message`; returns delivery confirmation or the delivery-failure reason. Cannot message the current session. |
156
155
  | `ask` | Sends a message and blocks until the recipient replies (10-minute timeout). The reply is returned as the tool result, so the agent continues in the same turn. |
157
156
  | `reply` | Replies to the intercom-triggered message of the current turn; otherwise falls back to the single unresolved inbound ask. With multiple pending asks, pass `to` or inspect with `pending` first. |
@@ -170,7 +169,7 @@ Sent and received messages are recorded in session history as `intercom_sent` /
170
169
 
171
170
  ### Targeting Sessions
172
171
 
173
- Target lookup resolves an exact full ID first, then an exact case-insensitive name, then a unique session-ID prefix. If a prefix matches multiple sessions, Intercom reports every match and asks for a longer ID or exact name instead of guessing. Resolving a prefix to the current session triggers the normal self-target rejection ("Cannot message the current session"). Targeting is also **group-scoped** — see [Groups](#groups) below.
172
+ Target lookup accepts only an exact full session ID or an exact case-insensitive session name. Targeting is also **group-scoped** — see [Groups](#groups) below.
174
173
 
175
174
  ### Groups
176
175
 
@@ -254,7 +253,7 @@ When Atomic's [subagent runtime](/subagents) admits a delegated child, the child
254
253
 
255
254
  `contact_supervisor` is registered from the typed admission record. The record binds the supervisor target, canonical child identity, child index, session name, and any broker-issued capability to that in-process child session; none of those values are inherited from environment variables. If the parent did not grant supervisor coordination, the session receives only the regular `intercom` tool.
256
255
 
257
- The child identity remains stable across foreground continuation, `async: true`, interruption, and cold resume. Intercom detach uses the same in-process continuation as async work, so the jobs widget and the eventual bounded terminal envelope retain one canonical path.
256
+ The child identity remains stable across foreground continuation, interruption, and cold resume. Intercom detach uses the same in-process continuation as foreground coordination, so the terminal envelope retains one canonical path.
258
257
 
259
258
  | Parameter | Type | Description |
260
259
  |-----------|------|-------------|
@@ -338,16 +337,15 @@ The supervisor can reply with plain JSON or a fenced `json` block. If the reply
338
337
 
339
338
  ## Workflow and Subagent Notifications
340
339
 
341
- Intercom is also the delivery channel for async run results and control notices from [workflows](/workflows) and [subagents](/subagents).
340
+ Intercom is also the delivery channel for workflow run results and subagent control notices from [workflows](/workflows) and [subagents](/subagents).
342
341
 
343
342
  ### Workflow Delivery Modes
344
343
 
345
- Programmatic `workflow()` calls accept an `intercom` option that controls how async direct-run results and control notices reach a parent session:
344
+ Programmatic `workflow()` calls accept an `intercom` option that controls how asynchronous direct-run results and control notices reach a parent session:
346
345
 
347
346
  ```typescript
348
347
  workflow({
349
348
  tasks: [{ agent: "worker", task: "..." }],
350
- async: true,
351
349
  intercom: { delivery: "result" },
352
350
  })
353
351
  ```
@@ -359,17 +357,18 @@ workflow({
359
357
  | `parentSession` | string | Target session for delivery; resolved from args or the Intercom port when omitted |
360
358
  | `notifyOn` | array | Control events to deliver: `"active_long_running"`, `"needs_attention"`, `"completed"`, `"failed"` |
361
359
 
362
- When neither `enabled` nor `delivery` is set, async direct `parallel` runs default to `control-and-result` when Intercom is available; otherwise delivery is off. Treat Intercom payloads from async direct runs as user-visible workflow output.
360
+ When neither `enabled` nor `delivery` is set, direct `parallel` runs default to `control-and-result` when Intercom is available; otherwise delivery is off. Treat Intercom payloads from direct runs as user-visible workflow output.
363
361
 
364
362
  While a workflow stage generation is open, incoming Intercom messages are admitted through the stage session's native steering/follow-up queue. If that stage is busy running a foreground subagent, Atomic synchronously reserves the message in the stage generation before starting the exact child's probe/commit detach handshake. Model-visible queue insertion waits inside that reservation until detach is acknowledged or the owner is unclaimed/disappears, so terminal stage close cannot overtake and silently drop the message. The stage drains the admitted delivery before publishing its terminal snapshot. A destination-side admission failure returns a correlated actionable error to a blocking asker instead of waiting for the 10-minute reply timeout.
363
+
365
364
  ### Subagent Control Notices
366
365
 
367
366
  The `subagent` tool's `control` options select which control events notify the parent and over which channels:
368
367
 
369
368
  - **`notifyOn`** — defaults to `["active_long_running", "needs_attention"]`
370
- - **`notifyChannels`** — defaults to `["event", "async", "intercom"]` (all that are available)
369
+ - **`notifyChannels`** — defaults to `["event", "intercom"]` (all that are available)
371
370
 
372
- Async subagent result delivery over Intercom is confirmation-based and preserves a successful delivery phase across watcher replacement. Each delegated child gets a deterministic Intercom target derived from its run/agent/index identity, and run results report those targets ("Run intercom target" / "Previous intercom target"; targets may be inactive after completion). `subagent({ action: "doctor" })` reports Intercom bridge availability and whether Intercom is enabled in config.
371
+ Detached subagent result delivery over Intercom is confirmation-based and preserves a successful delivery phase across watcher replacement. Each delegated child gets a deterministic Intercom target derived from its run/agent/index identity, and run results report those targets ("Run intercom target" / "Previous intercom target"; targets may be inactive after completion). `subagent({ action: "doctor" })` reports Intercom bridge availability and whether Intercom is enabled in config.
373
372
 
374
373
  If live child-to-parent coordination is needed, invoke `intercom({ action: "status" })` in the parent before launching; the child connects on its first `contact_supervisor` or `intercom` call. Fresh child sessions receive the bundled Intercom wrapper through normal package discovery unless an explicit `extensions` allowlist excludes it.
375
374
 
@@ -377,7 +376,7 @@ If live child-to-parent coordination is needed, invoke `intercom({ action: "stat
377
376
 
378
377
  During a foreground subagent run, Atomic probes for the exact live foreground owner before delivery: the matching child reserves the request, accepts a generation-scoped detach commit, and acknowledges it before messages enter the parent's model-visible steering queue. A commit accepted by one member of a foreground parallel group releases supervision for all active siblings while retaining their in-process session ownership, allowing the aggregate tool call to return. If the owner disappears between probe and commit, a still-current receiver uses its ordinary fallback route rather than dropping the broker-delivered message. Blocking calls stay alive until the exact threaded reply; generation cancellation or replacement invalidates stale handshakes.
379
378
 
380
- For delegated background children, queued messages and terminal lifecycle notices are ordered per child: pre-terminal messages are admitted FIFO and atomically together with the paused, completed, or failed notice, exact terminal-identity deduplication prevents double admission, failed dispatches remain retryable, and correlated ask replies bypass unrelated queued sends. See [Subagents](/subagents) for the full coordination contract.
379
+ For delegated children, queued messages and terminal lifecycle notices are ordered per child: pre-terminal messages are admitted FIFO and atomically together with the paused, completed, or failed notice, exact terminal-identity deduplication prevents double admission, failed dispatches remain retryable, and correlated ask replies bypass unrelated queued sends. See [Subagents](/subagents) for the full coordination contract.
381
380
 
382
381
  ## Configuration
383
382
 
@@ -499,6 +498,6 @@ Use a shared-room messenger for multi-agent swarms working on one shared task. U
499
498
  ## Related Docs
500
499
 
501
500
  - [Subagents](/subagents) for delegated child runs, foreground coordination, and result delivery.
502
- - [Workflows](/workflows) for multi-stage automation and async run notifications.
501
+ - [Workflows](/workflows) for multi-stage automation and run notifications.
503
502
  - [Skills](/skills) for reusable instructions like `/skill:intercom`.
504
503
  - [Usage](/usage) for environment variables and the bundled-extension overview.
@@ -84,7 +84,7 @@ The dedicated history actions always change history entries, regardless of the c
84
84
 
85
85
  ### TUI Fullscreen Viewport
86
86
 
87
- Interactive sessions always use this fullscreen viewport for the primary transcript scroll region. Mouse-wheel input scrolls the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler. Dragging with the primary mouse button selects text and copies it to the clipboard.
87
+ Interactive sessions always use this fullscreen viewport for the primary transcript scroll region. Mouse-wheel input scrolls the region under the pointer, falling back to the transcript over the fixed editor/status/footer dock. Clicking an OSC 8 hyperlink opens it in the default handler; the jump-to-bottom indicator's internal OSC 8 link returns the focused transcript surface to its live end, including an attached workflow stage chat. Dragging with the primary mouse button selects text and copies it to the clipboard.
88
88
 
89
89
 
90
90
  Fullscreen text selection comes from the installed pi-tui 0.84.1 renderer. Drag with the primary button to select characters; double-click selects a word and triple-click selects a line. Focus changes and non-drag clicks clear transient selection state, preventing a stale highlight from appearing. The renderer also reduces mouse tracking in tmux, Zellij, and GNU Screen.
@@ -117,15 +117,12 @@ On Windows, pressing the secondary mouse button in fullscreen pastes text from t
117
117
 
118
118
  | Keybinding id | Default | Description |
119
119
  |--------|---------|-------------|
120
- | `app.interrupt` | `escape` | Abort active or queued work and restore queued steering/follow-up messages to the editor; the session remains paused until an ordinary submission |
120
+ | `app.interrupt` | `escape` | Abort active or queued work and restore still-queued steering/follow-up messages to the editor; the session remains paused until an ordinary submission. A message the agent already picked up is answered instead of restored |
121
121
  | `app.clear` | `ctrl+c` | Interrupt active or queued work, or terminate an unresponsive interactive engine; once idle, clear the editor (press twice while idle to exit) |
122
122
  | `app.exit` | `ctrl+d` | Exit (when editor empty) |
123
123
  | `app.suspend` | `ctrl+z` (none on Windows) | Suspend to background |
124
124
  | `app.editor.external` | `ctrl+g` | Open in external editor (`$VISUAL` or `$EDITOR`) |
125
125
  | `app.clipboard.pasteImage` | `ctrl+v` (`alt+v` on Windows) | Paste image or text from clipboard |
126
- | `app.message.copy` | `ctrl+x` | Copy the last assistant message (or the selected message in `/tree`) |
127
-
128
- In fullscreen mode, a successful `app.message.copy` shortcut shows a short `Copied!` flash without adding a row to the fixed status dock. The `/copy` command keeps its normal status-line confirmation.
129
126
 
130
127
  When `app.clipboard.pasteImage` finds text rather than an image, Atomic inserts that clipboard text into the editor instead of reporting an image-paste failure.
131
128