@bastani/atomic 0.10.2-alpha.1 → 0.10.3-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (499) hide show
  1. package/CHANGELOG.md +112 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +17 -0
  3. package/dist/builtin/intercom/broker/broker-instance.ts +2 -13
  4. package/dist/builtin/intercom/broker/broker.ts +158 -73
  5. package/dist/builtin/intercom/broker/durable-ended-queue.ts +14 -2
  6. package/dist/builtin/intercom/broker/host-command-environment.ts +13 -0
  7. package/dist/builtin/intercom/broker/hosted-session-errors.ts +1 -0
  8. package/dist/builtin/intercom/broker/multinode-router.ts +111 -16
  9. package/dist/builtin/intercom/broker/multinode-state-store.ts +50 -4
  10. package/dist/builtin/intercom/broker/open-broker-state.ts +5 -4
  11. package/dist/builtin/intercom/broker/spawn.ts +144 -25
  12. package/dist/builtin/intercom/broker/sql-add-column.ts +33 -0
  13. package/dist/builtin/intercom/broker/sql-known-session-store.ts +120 -36
  14. package/dist/builtin/intercom/broker/sql-outbox-store.ts +75 -13
  15. package/dist/builtin/intercom/broker/start-announcement.ts +55 -10
  16. package/dist/builtin/intercom/broker/watchdog.ts +10 -7
  17. package/dist/builtin/intercom/index.bundle.mjs +111 -27
  18. package/dist/builtin/intercom/package.json +1 -1
  19. package/dist/builtin/mcp/package.json +1 -1
  20. package/dist/builtin/subagents/CHANGELOG.md +29 -0
  21. package/dist/builtin/subagents/package.json +1 -1
  22. package/dist/builtin/subagents/skills/skill-creator/SKILL.md +30 -52
  23. package/dist/builtin/subagents/skills/skill-creator/eval-viewer/generate_review.py +34 -40
  24. package/dist/builtin/subagents/skills/skill-creator/eval-viewer/viewer.html +2 -2
  25. package/dist/builtin/subagents/skills/skill-creator/scripts/atomic_cli.py +668 -0
  26. package/dist/builtin/subagents/skills/skill-creator/scripts/generate_report.py +3 -3
  27. package/dist/builtin/subagents/skills/skill-creator/scripts/improve_description.py +42 -38
  28. package/dist/builtin/subagents/skills/skill-creator/scripts/run_eval.py +268 -176
  29. package/dist/builtin/subagents/skills/skill-creator/scripts/run_loop.py +20 -11
  30. package/dist/builtin/subagents/skills/skill-creator/scripts/utils.py +1 -1
  31. package/dist/builtin/subagents/src/extension/index.bundle.mjs +163 -97
  32. package/dist/builtin/web-access/CHANGELOG.md +14 -0
  33. package/dist/builtin/web-access/index.bundle.mjs +5 -4
  34. package/dist/builtin/web-access/package.json +1 -1
  35. package/dist/core/agent-session-auto-compaction.d.ts +10 -1
  36. package/dist/core/agent-session-auto-compaction.d.ts.map +1 -1
  37. package/dist/core/agent-session-auto-compaction.js +54 -2
  38. package/dist/core/agent-session-auto-compaction.js.map +1 -1
  39. package/dist/core/agent-session-compaction.d.ts +4 -0
  40. package/dist/core/agent-session-compaction.d.ts.map +1 -1
  41. package/dist/core/agent-session-compaction.js +17 -2
  42. package/dist/core/agent-session-compaction.js.map +1 -1
  43. package/dist/core/agent-session-custom-message-commit.d.ts.map +1 -1
  44. package/dist/core/agent-session-custom-message-commit.js +3 -1
  45. package/dist/core/agent-session-custom-message-commit.js.map +1 -1
  46. package/dist/core/agent-session-events.d.ts +2 -0
  47. package/dist/core/agent-session-events.d.ts.map +1 -1
  48. package/dist/core/agent-session-events.js +34 -13
  49. package/dist/core/agent-session-events.js.map +1 -1
  50. package/dist/core/agent-session-export.d.ts.map +1 -1
  51. package/dist/core/agent-session-export.js +3 -0
  52. package/dist/core/agent-session-export.js.map +1 -1
  53. package/dist/core/agent-session-message-queue.d.ts +27 -0
  54. package/dist/core/agent-session-message-queue.d.ts.map +1 -1
  55. package/dist/core/agent-session-message-queue.js +213 -30
  56. package/dist/core/agent-session-message-queue.js.map +1 -1
  57. package/dist/core/agent-session-methods.d.ts +6 -1
  58. package/dist/core/agent-session-methods.d.ts.map +1 -1
  59. package/dist/core/agent-session-methods.js.map +1 -1
  60. package/dist/core/agent-session-prompt.d.ts.map +1 -1
  61. package/dist/core/agent-session-prompt.js +35 -3
  62. package/dist/core/agent-session-prompt.js.map +1 -1
  63. package/dist/core/agent-session-runtime.d.ts.map +1 -1
  64. package/dist/core/agent-session-runtime.js +2 -2
  65. package/dist/core/agent-session-runtime.js.map +1 -1
  66. package/dist/core/agent-session-state.d.ts.map +1 -1
  67. package/dist/core/agent-session-state.js +6 -1
  68. package/dist/core/agent-session-state.js.map +1 -1
  69. package/dist/core/agent-session-tool-hooks.d.ts.map +1 -1
  70. package/dist/core/agent-session-tool-hooks.js +15 -2
  71. package/dist/core/agent-session-tool-hooks.js.map +1 -1
  72. package/dist/core/agent-session-typed-queue.d.ts +14 -1
  73. package/dist/core/agent-session-typed-queue.d.ts.map +1 -1
  74. package/dist/core/agent-session-typed-queue.js +26 -1
  75. package/dist/core/agent-session-typed-queue.js.map +1 -1
  76. package/dist/core/agent-session-types.d.ts +5 -0
  77. package/dist/core/agent-session-types.d.ts.map +1 -1
  78. package/dist/core/agent-session-types.js.map +1 -1
  79. package/dist/core/agent-session.d.ts.map +1 -1
  80. package/dist/core/agent-session.js +2 -1
  81. package/dist/core/agent-session.js.map +1 -1
  82. package/dist/core/async-scope.d.ts +9 -4
  83. package/dist/core/async-scope.d.ts.map +1 -1
  84. package/dist/core/async-scope.js +13 -5
  85. package/dist/core/async-scope.js.map +1 -1
  86. package/dist/core/builtin-diagnostics.js +2 -2
  87. package/dist/core/builtin-diagnostics.js.map +1 -1
  88. package/dist/core/chat-admission-order.d.ts.map +1 -1
  89. package/dist/core/chat-admission-order.js +2 -1
  90. package/dist/core/chat-admission-order.js.map +1 -1
  91. package/dist/core/chat-record-saves.d.ts +4 -0
  92. package/dist/core/chat-record-saves.d.ts.map +1 -0
  93. package/dist/core/chat-record-saves.js +25 -0
  94. package/dist/core/chat-record-saves.js.map +1 -0
  95. package/dist/core/command-deliveries.d.ts +62 -0
  96. package/dist/core/command-deliveries.d.ts.map +1 -0
  97. package/dist/core/command-deliveries.js +139 -0
  98. package/dist/core/command-deliveries.js.map +1 -0
  99. package/dist/core/diagnostic-writer.d.ts.map +1 -1
  100. package/dist/core/diagnostic-writer.js +5 -4
  101. package/dist/core/diagnostic-writer.js.map +1 -1
  102. package/dist/core/extension-startup-close.d.ts +1 -2
  103. package/dist/core/extension-startup-close.d.ts.map +1 -1
  104. package/dist/core/extension-startup-close.js +2 -2
  105. package/dist/core/extension-startup-close.js.map +1 -1
  106. package/dist/core/extensions/jiti-aliases.d.ts +11 -0
  107. package/dist/core/extensions/jiti-aliases.d.ts.map +1 -0
  108. package/dist/core/extensions/jiti-aliases.js +28 -0
  109. package/dist/core/extensions/jiti-aliases.js.map +1 -0
  110. package/dist/core/extensions/loader-api.js +3 -3
  111. package/dist/core/extensions/loader-api.js.map +1 -1
  112. package/dist/core/extensions/loader-bindings.js +2 -2
  113. package/dist/core/extensions/loader-bindings.js.map +1 -1
  114. package/dist/core/extensions/loader-rollback.d.ts +1 -2
  115. package/dist/core/extensions/loader-rollback.d.ts.map +1 -1
  116. package/dist/core/extensions/loader-rollback.js +2 -2
  117. package/dist/core/extensions/loader-rollback.js.map +1 -1
  118. package/dist/core/extensions/loader-virtual-modules.d.ts.map +1 -1
  119. package/dist/core/extensions/loader-virtual-modules.js +53 -9
  120. package/dist/core/extensions/loader-virtual-modules.js.map +1 -1
  121. package/dist/core/extensions/native-builtin-entries.d.ts +5 -0
  122. package/dist/core/extensions/native-builtin-entries.d.ts.map +1 -1
  123. package/dist/core/extensions/native-builtin-entries.js +8 -1
  124. package/dist/core/extensions/native-builtin-entries.js.map +1 -1
  125. package/dist/core/extensions/reloadable-scripts.d.ts +21 -2
  126. package/dist/core/extensions/reloadable-scripts.d.ts.map +1 -1
  127. package/dist/core/extensions/reloadable-scripts.js +11 -3
  128. package/dist/core/extensions/reloadable-scripts.js.map +1 -1
  129. package/dist/core/extensions/source-builtin-imports.d.ts +40 -0
  130. package/dist/core/extensions/source-builtin-imports.d.ts.map +1 -0
  131. package/dist/core/extensions/source-builtin-imports.js +142 -0
  132. package/dist/core/extensions/source-builtin-imports.js.map +1 -0
  133. package/dist/core/extensions/transform-graph.d.ts +15 -0
  134. package/dist/core/extensions/transform-graph.d.ts.map +1 -0
  135. package/dist/core/extensions/transform-graph.js +85 -0
  136. package/dist/core/extensions/transform-graph.js.map +1 -0
  137. package/dist/core/extensions/ts-source-specifiers.d.ts +2 -0
  138. package/dist/core/extensions/ts-source-specifiers.d.ts.map +1 -1
  139. package/dist/core/extensions/ts-source-specifiers.js +7 -0
  140. package/dist/core/extensions/ts-source-specifiers.js.map +1 -1
  141. package/dist/core/extensions/ts-transform-worker.d.ts +2 -0
  142. package/dist/core/extensions/ts-transform-worker.d.ts.map +1 -0
  143. package/dist/core/extensions/ts-transform-worker.js +43 -0
  144. package/dist/core/extensions/ts-transform-worker.js.map +1 -0
  145. package/dist/core/message-admission.d.ts.map +1 -1
  146. package/dist/core/message-admission.js +4 -4
  147. package/dist/core/message-admission.js.map +1 -1
  148. package/dist/core/messages.d.ts +5 -0
  149. package/dist/core/messages.d.ts.map +1 -1
  150. package/dist/core/messages.js +35 -0
  151. package/dist/core/messages.js.map +1 -1
  152. package/dist/core/model-fallback-failures.d.ts +1 -1
  153. package/dist/core/model-fallback-failures.d.ts.map +1 -1
  154. package/dist/core/model-fallback-failures.js +18 -1
  155. package/dist/core/model-fallback-failures.js.map +1 -1
  156. package/dist/core/process-start-token.d.ts +7 -0
  157. package/dist/core/process-start-token.d.ts.map +1 -1
  158. package/dist/core/process-start-token.js +14 -0
  159. package/dist/core/process-start-token.js.map +1 -1
  160. package/dist/core/project-trust-electorate.d.ts +24 -0
  161. package/dist/core/project-trust-electorate.d.ts.map +1 -0
  162. package/dist/core/project-trust-electorate.js +52 -0
  163. package/dist/core/project-trust-electorate.js.map +1 -0
  164. package/dist/core/project-trust-state.d.ts +15 -0
  165. package/dist/core/project-trust-state.d.ts.map +1 -1
  166. package/dist/core/project-trust-state.js +15 -0
  167. package/dist/core/project-trust-state.js.map +1 -1
  168. package/dist/core/provider-request-admission.d.ts.map +1 -1
  169. package/dist/core/provider-request-admission.js +2 -2
  170. package/dist/core/provider-request-admission.js.map +1 -1
  171. package/dist/core/queued-input-admission.js +2 -2
  172. package/dist/core/queued-input-admission.js.map +1 -1
  173. package/dist/core/queued-message-delivery.d.ts +2 -2
  174. package/dist/core/queued-message-delivery.d.ts.map +1 -1
  175. package/dist/core/queued-message-delivery.js +6 -3
  176. package/dist/core/queued-message-delivery.js.map +1 -1
  177. package/dist/core/resource-admission-scope.js +2 -2
  178. package/dist/core/resource-admission-scope.js.map +1 -1
  179. package/dist/core/resume/blueprint/process.d.ts +3 -4
  180. package/dist/core/resume/blueprint/process.d.ts.map +1 -1
  181. package/dist/core/resume/blueprint/process.js +33 -17
  182. package/dist/core/resume/blueprint/process.js.map +1 -1
  183. package/dist/core/resume/path-mapping.js +4 -4
  184. package/dist/core/resume/path-mapping.js.map +1 -1
  185. package/dist/core/resume/session-resume.d.ts +9 -0
  186. package/dist/core/resume/session-resume.d.ts.map +1 -1
  187. package/dist/core/resume/session-resume.js +27 -2
  188. package/dist/core/resume/session-resume.js.map +1 -1
  189. package/dist/core/resume-cache-checkpoint.d.ts +27 -1
  190. package/dist/core/resume-cache-checkpoint.d.ts.map +1 -1
  191. package/dist/core/resume-cache-checkpoint.js +45 -0
  192. package/dist/core/resume-cache-checkpoint.js.map +1 -1
  193. package/dist/core/sdk.d.ts.map +1 -1
  194. package/dist/core/sdk.js +7 -31
  195. package/dist/core/sdk.js.map +1 -1
  196. package/dist/core/session-lifecycle-scope.d.ts +1 -2
  197. package/dist/core/session-lifecycle-scope.d.ts.map +1 -1
  198. package/dist/core/session-lifecycle-scope.js +2 -2
  199. package/dist/core/session-lifecycle-scope.js.map +1 -1
  200. package/dist/core/session-lifecycle-work.js +2 -2
  201. package/dist/core/session-lifecycle-work.js.map +1 -1
  202. package/dist/core/session-manager-core.d.ts.map +1 -1
  203. package/dist/core/session-manager-core.js +3 -0
  204. package/dist/core/session-manager-core.js.map +1 -1
  205. package/dist/core/session-storage.d.ts +12 -0
  206. package/dist/core/session-storage.d.ts.map +1 -1
  207. package/dist/core/session-storage.js +68 -1
  208. package/dist/core/session-storage.js.map +1 -1
  209. package/dist/core/settings-lock-directory.d.ts.map +1 -1
  210. package/dist/core/settings-lock-directory.js +4 -3
  211. package/dist/core/settings-lock-directory.js.map +1 -1
  212. package/dist/core/settings-write-ownership.d.ts +1 -2
  213. package/dist/core/settings-write-ownership.d.ts.map +1 -1
  214. package/dist/core/settings-write-ownership.js +2 -2
  215. package/dist/core/settings-write-ownership.js.map +1 -1
  216. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -1
  217. package/dist/core/storage/node-sqlite-thread.js +6 -4
  218. package/dist/core/storage/node-sqlite-thread.js.map +1 -1
  219. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  220. package/dist/core/storage/node-sqlite.js +22 -8
  221. package/dist/core/storage/node-sqlite.js.map +1 -1
  222. package/dist/core/system-prompt.d.ts +16 -2
  223. package/dist/core/system-prompt.d.ts.map +1 -1
  224. package/dist/core/system-prompt.js +33 -6
  225. package/dist/core/system-prompt.js.map +1 -1
  226. package/dist/core/tasks/agent-adapter.d.ts.map +1 -1
  227. package/dist/core/tasks/agent-adapter.js +2 -1
  228. package/dist/core/tasks/agent-adapter.js.map +1 -1
  229. package/dist/core/tasks/completion.d.ts +3 -2
  230. package/dist/core/tasks/completion.d.ts.map +1 -1
  231. package/dist/core/tasks/completion.js.map +1 -1
  232. package/dist/core/tasks/execution-scope.js +2 -2
  233. package/dist/core/tasks/execution-scope.js.map +1 -1
  234. package/dist/core/tools/bash.d.ts.map +1 -1
  235. package/dist/core/tools/bash.js +2 -1
  236. package/dist/core/tools/bash.js.map +1 -1
  237. package/dist/core/tools/history-regex-worker.d.ts.map +1 -1
  238. package/dist/core/tools/history-regex-worker.js +3 -2
  239. package/dist/core/tools/history-regex-worker.js.map +1 -1
  240. package/dist/core/tools/shell-task-render.d.ts +3 -2
  241. package/dist/core/tools/shell-task-render.d.ts.map +1 -1
  242. package/dist/core/tools/shell-task-render.js +7 -5
  243. package/dist/core/tools/shell-task-render.js.map +1 -1
  244. package/dist/core/tools/shell-task-status.d.ts +6 -2
  245. package/dist/core/tools/shell-task-status.d.ts.map +1 -1
  246. package/dist/core/tools/shell-task-status.js +13 -8
  247. package/dist/core/tools/shell-task-status.js.map +1 -1
  248. package/dist/core/tools/sqlite-selector-connection.d.ts.map +1 -1
  249. package/dist/core/tools/sqlite-selector-connection.js +4 -3
  250. package/dist/core/tools/sqlite-selector-connection.js.map +1 -1
  251. package/dist/core/tools/windows-directory-security.d.ts.map +1 -1
  252. package/dist/core/tools/windows-directory-security.js +2 -1
  253. package/dist/core/tools/windows-directory-security.js.map +1 -1
  254. package/dist/core/worktree-snapshot/git.js +2 -2
  255. package/dist/core/worktree-snapshot/git.js.map +1 -1
  256. package/dist/extensions/mcp/index.d.ts +6 -1
  257. package/dist/extensions/mcp/index.d.ts.map +1 -1
  258. package/dist/extensions/mcp/index.js +150 -18
  259. package/dist/extensions/mcp/index.js.map +1 -1
  260. package/dist/extensions/mcp/tool-records.d.ts +44 -9
  261. package/dist/extensions/mcp/tool-records.d.ts.map +1 -1
  262. package/dist/extensions/mcp/tool-records.js +58 -16
  263. package/dist/extensions/mcp/tool-records.js.map +1 -1
  264. package/dist/index.d.ts +2 -0
  265. package/dist/index.d.ts.map +1 -1
  266. package/dist/index.js +4 -0
  267. package/dist/index.js.map +1 -1
  268. package/dist/main-session.d.ts +3 -1
  269. package/dist/main-session.d.ts.map +1 -1
  270. package/dist/main-session.js +1 -0
  271. package/dist/main-session.js.map +1 -1
  272. package/dist/main.d.ts.map +1 -1
  273. package/dist/main.js +230 -96
  274. package/dist/main.js.map +1 -1
  275. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +5 -0
  276. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  277. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  278. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +5 -2
  279. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  280. package/dist/modes/interactive/agent-view/agent-view-switcher.js +3 -3
  281. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  282. package/dist/modes/interactive/agent-view/contracts.d.ts +6 -0
  283. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  284. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  285. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  286. package/dist/modes/interactive/agent-view/install.js +2 -1
  287. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  288. package/dist/modes/interactive/agent-view/open-port.d.ts +4 -2
  289. package/dist/modes/interactive/agent-view/open-port.d.ts.map +1 -1
  290. package/dist/modes/interactive/agent-view/open-port.js +4 -3
  291. package/dist/modes/interactive/agent-view/open-port.js.map +1 -1
  292. package/dist/modes/interactive/agent-view/prompt-retarget.d.ts.map +1 -1
  293. package/dist/modes/interactive/agent-view/prompt-retarget.js +18 -5
  294. package/dist/modes/interactive/agent-view/prompt-retarget.js.map +1 -1
  295. package/dist/modes/interactive/agent-view/remote-port.d.ts +10 -1
  296. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  297. package/dist/modes/interactive/agent-view/remote-port.js +36 -4
  298. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  299. package/dist/modes/interactive/agent-view/viewed-keys.d.ts +56 -0
  300. package/dist/modes/interactive/agent-view/viewed-keys.d.ts.map +1 -0
  301. package/dist/modes/interactive/agent-view/viewed-keys.js +63 -0
  302. package/dist/modes/interactive/agent-view/viewed-keys.js.map +1 -0
  303. package/dist/modes/interactive/agent-view/viewed-submit.d.ts +14 -4
  304. package/dist/modes/interactive/agent-view/viewed-submit.d.ts.map +1 -1
  305. package/dist/modes/interactive/agent-view/viewed-submit.js +51 -17
  306. package/dist/modes/interactive/agent-view/viewed-submit.js.map +1 -1
  307. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  308. package/dist/modes/interactive/components/agent-panel.js +8 -21
  309. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  310. package/dist/modes/interactive/components/chat-session-host-actions.d.ts.map +1 -1
  311. package/dist/modes/interactive/components/chat-session-host-actions.js +18 -5
  312. package/dist/modes/interactive/components/chat-session-host-actions.js.map +1 -1
  313. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  314. package/dist/modes/interactive/components/chat-session-host-rendering.js +6 -0
  315. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  316. package/dist/modes/interactive/components/chat-session-host-state.d.ts +1 -0
  317. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  318. package/dist/modes/interactive/components/chat-session-host-state.js +2 -0
  319. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  320. package/dist/modes/interactive/components/chat-session-host-types.d.ts +5 -0
  321. package/dist/modes/interactive/components/chat-session-host-types.d.ts.map +1 -1
  322. package/dist/modes/interactive/components/chat-session-host-types.js.map +1 -1
  323. package/dist/modes/interactive/components/custom-editor.d.ts +33 -2
  324. package/dist/modes/interactive/components/custom-editor.d.ts.map +1 -1
  325. package/dist/modes/interactive/components/custom-editor.js +58 -2
  326. package/dist/modes/interactive/components/custom-editor.js.map +1 -1
  327. package/dist/modes/interactive/components/host-session-picker.js +2 -2
  328. package/dist/modes/interactive/components/host-session-picker.js.map +1 -1
  329. package/dist/modes/interactive/components/main-composer-keys.d.ts +16 -5
  330. package/dist/modes/interactive/components/main-composer-keys.d.ts.map +1 -1
  331. package/dist/modes/interactive/components/main-composer-keys.js +27 -8
  332. package/dist/modes/interactive/components/main-composer-keys.js.map +1 -1
  333. package/dist/modes/interactive/components/notice-line.d.ts +8 -25
  334. package/dist/modes/interactive/components/notice-line.d.ts.map +1 -1
  335. package/dist/modes/interactive/components/notice-line.js +18 -17
  336. package/dist/modes/interactive/components/notice-line.js.map +1 -1
  337. package/dist/modes/interactive/components/prompt-slot.d.ts +20 -3
  338. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -1
  339. package/dist/modes/interactive/components/prompt-slot.js +82 -32
  340. package/dist/modes/interactive/components/prompt-slot.js.map +1 -1
  341. package/dist/modes/interactive/components/queued-messages-view.d.ts +5 -2
  342. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  343. package/dist/modes/interactive/components/queued-messages-view.js +12 -5
  344. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  345. package/dist/modes/interactive/components/task-board.d.ts +5 -8
  346. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  347. package/dist/modes/interactive/components/task-board.js +5 -49
  348. package/dist/modes/interactive/components/task-board.js.map +1 -1
  349. package/dist/modes/interactive/components/task-completion-message.d.ts.map +1 -1
  350. package/dist/modes/interactive/components/task-completion-message.js +9 -2
  351. package/dist/modes/interactive/components/task-completion-message.js.map +1 -1
  352. package/dist/modes/interactive/components/task-marks.d.ts +19 -0
  353. package/dist/modes/interactive/components/task-marks.d.ts.map +1 -0
  354. package/dist/modes/interactive/components/task-marks.js +25 -0
  355. package/dist/modes/interactive/components/task-marks.js.map +1 -0
  356. package/dist/modes/interactive/components/task-row.d.ts +10 -2
  357. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  358. package/dist/modes/interactive/components/task-row.js +39 -32
  359. package/dist/modes/interactive/components/task-row.js.map +1 -1
  360. package/dist/modes/interactive/components/task-transcript-page.d.ts +7 -0
  361. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  362. package/dist/modes/interactive/components/task-transcript-page.js +106 -10
  363. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  364. package/dist/modes/interactive/components/tool-block-families.d.ts.map +1 -1
  365. package/dist/modes/interactive/components/tool-block-families.js +8 -9
  366. package/dist/modes/interactive/components/tool-block-families.js.map +1 -1
  367. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  368. package/dist/modes/interactive/components/tool-execution.js +5 -1
  369. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  370. package/dist/modes/interactive/extension-command-hold.d.ts.map +1 -1
  371. package/dist/modes/interactive/extension-command-hold.js +5 -7
  372. package/dist/modes/interactive/extension-command-hold.js.map +1 -1
  373. package/dist/modes/interactive/interactive-extension-dialogs.js +6 -1
  374. package/dist/modes/interactive/interactive-extension-dialogs.js.map +1 -1
  375. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  376. package/dist/modes/interactive/interactive-extension-runtime.js +21 -7
  377. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  378. package/dist/modes/interactive/interactive-initial-session-binding.d.ts +1 -2
  379. package/dist/modes/interactive/interactive-initial-session-binding.d.ts.map +1 -1
  380. package/dist/modes/interactive/interactive-initial-session-binding.js +2 -2
  381. package/dist/modes/interactive/interactive-initial-session-binding.js.map +1 -1
  382. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  383. package/dist/modes/interactive/interactive-input-handling.js +13 -4
  384. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  385. package/dist/modes/interactive/interactive-mode-base.d.ts +2 -1
  386. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  387. package/dist/modes/interactive/interactive-mode-base.js +6 -1
  388. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  389. package/dist/modes/interactive/interactive-mode-helpers.d.ts +4 -2
  390. package/dist/modes/interactive/interactive-mode-helpers.d.ts.map +1 -1
  391. package/dist/modes/interactive/interactive-mode-helpers.js +6 -0
  392. package/dist/modes/interactive/interactive-mode-helpers.js.map +1 -1
  393. package/dist/modes/interactive/interactive-mode-surface.d.ts +5 -0
  394. package/dist/modes/interactive/interactive-mode-surface.d.ts.map +1 -1
  395. package/dist/modes/interactive/interactive-mode-surface.js.map +1 -1
  396. package/dist/modes/interactive/interactive-process-lifecycle.js +96 -17
  397. package/dist/modes/interactive/interactive-process-lifecycle.js.map +1 -1
  398. package/dist/modes/interactive/interactive-queueing.d.ts +5 -0
  399. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  400. package/dist/modes/interactive/interactive-queueing.js +37 -5
  401. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  402. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  403. package/dist/modes/interactive/interactive-render-chat.js +45 -4
  404. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  405. package/dist/modes/interactive/interactive-resource-disclosure.d.ts +4 -1
  406. package/dist/modes/interactive/interactive-resource-disclosure.d.ts.map +1 -1
  407. package/dist/modes/interactive/interactive-resource-disclosure.js +20 -1
  408. package/dist/modes/interactive/interactive-resource-disclosure.js.map +1 -1
  409. package/dist/modes/interactive/interactive-resource-rendering.js +3 -0
  410. package/dist/modes/interactive/interactive-resource-rendering.js.map +1 -1
  411. package/dist/modes/interactive/interactive-startup.d.ts.map +1 -1
  412. package/dist/modes/interactive/interactive-startup.js +43 -5
  413. package/dist/modes/interactive/interactive-startup.js.map +1 -1
  414. package/dist/modes/interactive-engine/activity-watchdog.d.ts +6 -3
  415. package/dist/modes/interactive-engine/activity-watchdog.d.ts.map +1 -1
  416. package/dist/modes/interactive-engine/activity-watchdog.js +3 -2
  417. package/dist/modes/interactive-engine/activity-watchdog.js.map +1 -1
  418. package/dist/modes/interactive-engine/engine-health.d.ts +2 -0
  419. package/dist/modes/interactive-engine/engine-health.d.ts.map +1 -1
  420. package/dist/modes/interactive-engine/engine-health.js.map +1 -1
  421. package/dist/modes/interactive-engine/engine-quit-intent.d.ts +10 -0
  422. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  423. package/dist/modes/interactive-engine/engine-quit-intent.js +33 -0
  424. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  425. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts +7 -1
  426. package/dist/modes/interactive-engine/extension-ui-bridge.d.ts.map +1 -1
  427. package/dist/modes/interactive-engine/extension-ui-bridge.js +15 -2
  428. package/dist/modes/interactive-engine/extension-ui-bridge.js.map +1 -1
  429. package/dist/modes/interactive-engine/host-listener-failures.d.ts +24 -0
  430. package/dist/modes/interactive-engine/host-listener-failures.d.ts.map +1 -0
  431. package/dist/modes/interactive-engine/host-listener-failures.js +98 -0
  432. package/dist/modes/interactive-engine/host-listener-failures.js.map +1 -0
  433. package/dist/modes/interactive-engine/isolated-runtime.d.ts +16 -0
  434. package/dist/modes/interactive-engine/isolated-runtime.d.ts.map +1 -1
  435. package/dist/modes/interactive-engine/isolated-runtime.js +74 -7
  436. package/dist/modes/interactive-engine/isolated-runtime.js.map +1 -1
  437. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  438. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  439. package/dist/modes/interactive-engine/protocol.js +8 -2
  440. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  441. package/dist/modes/interactive-engine/remote-component.d.ts +13 -0
  442. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  443. package/dist/modes/interactive-engine/remote-component.js +69 -4
  444. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  445. package/dist/modes/print-mode.d.ts.map +1 -1
  446. package/dist/modes/print-mode.js +34 -6
  447. package/dist/modes/print-mode.js.map +1 -1
  448. package/dist/modes/rpc/agent-panel-bridge.d.ts +7 -0
  449. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  450. package/dist/modes/rpc/agent-panel-bridge.js +11 -1
  451. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  452. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  453. package/dist/modes/rpc/agent-view-rpc-panel.js +11 -5
  454. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  455. package/dist/modes/rpc/rpc-client-process.d.ts +8 -1
  456. package/dist/modes/rpc/rpc-client-process.d.ts.map +1 -1
  457. package/dist/modes/rpc/rpc-client-process.js +89 -65
  458. package/dist/modes/rpc/rpc-client-process.js.map +1 -1
  459. package/dist/modes/rpc/rpc-client.d.ts +21 -0
  460. package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
  461. package/dist/modes/rpc/rpc-client.js +77 -33
  462. package/dist/modes/rpc/rpc-client.js.map +1 -1
  463. package/dist/modes/rpc/rpc-event-buffer.d.ts +5 -0
  464. package/dist/modes/rpc/rpc-event-buffer.d.ts.map +1 -1
  465. package/dist/modes/rpc/rpc-event-buffer.js +8 -2
  466. package/dist/modes/rpc/rpc-event-buffer.js.map +1 -1
  467. package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
  468. package/dist/modes/rpc/rpc-mode.js +9 -2
  469. package/dist/modes/rpc/rpc-mode.js.map +1 -1
  470. package/dist/utils/shell.d.ts +5 -1
  471. package/dist/utils/shell.d.ts.map +1 -1
  472. package/dist/utils/shell.js +14 -7
  473. package/dist/utils/shell.js.map +1 -1
  474. package/dist/utils/worker-threads.d.ts +10 -4
  475. package/dist/utils/worker-threads.d.ts.map +1 -1
  476. package/dist/utils/worker-threads.js +10 -4
  477. package/dist/utils/worker-threads.js.map +1 -1
  478. package/docs/background-tasks.md +10 -10
  479. package/docs/compaction.md +1 -0
  480. package/docs/development.md +1 -1
  481. package/docs/environment-variables.md +4 -0
  482. package/docs/extensions/api-reference.md +2 -0
  483. package/docs/extensions/events.md +1 -1
  484. package/docs/getting-started/installation.md +1 -0
  485. package/docs/guides/non-interactive.md +2 -0
  486. package/docs/guides/resume-on-any-machine.md +3 -1
  487. package/docs/intercom/reference.md +1 -1
  488. package/docs/keybindings.md +6 -5
  489. package/docs/libraries/ai.md +2 -1
  490. package/docs/mcp-servers.md +1 -1
  491. package/docs/sdk/reference.md +1 -1
  492. package/docs/sdk.md +6 -0
  493. package/docs/security.md +4 -2
  494. package/docs/settings.md +2 -1
  495. package/docs/storage.md +2 -0
  496. package/docs/subagents.md +2 -2
  497. package/docs/tui/reference.md +3 -1
  498. package/npm-shrinkwrap.json +49 -49
  499. package/package.json +6 -6
@@ -1 +1 @@
1
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E,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YACzG,IAAI,MAAM,KAAK,SAAS;gBAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type Component, decodePrintableKey, isKeyRelease, matchesKey } from \"@bastani/atomic-tui\";\nimport { firstSubagentAttempt } from \"../../../core/tasks/completion.js\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { getOwnerTaskStore } from \"../../../core/tasks/owner-store.js\";\nimport { IsolatedInteractiveRuntime } from \"../../interactive-engine/isolated-runtime.js\";\nimport { promptHistoryFor } from \"../components/agent-prompt-history.ts\";\nimport { AtomicWorkedStatusComponent, watchAtomicWorkingClock } from \"../components/atomic-working-status.ts\";\nimport { keyText } from \"../components/keybinding-hints.js\";\nimport { clickableKeyTextHint } from \"../components/nav-keys.ts\";\nimport { WorkingStatusComponent } from \"../components/working-status.ts\";\nimport { isPhysicalCtrlC, isPhysicalEscape } from \"../interactive-key-identity.ts\";\nimport type { InteractiveModeBase } from \"../interactive-mode-base.ts\";\nimport { mergeRestoredDraft } from \"../interactive-prompt-restore.ts\";\nimport { engineLossSubagentNotice } from \"../interactive-queueing.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport {\n\tappendPromptText,\n\tmarkMovedDraft,\n\trewritePromptOwnText,\n\tswitchPrompt,\n\ttakePromptText,\n} from \"./agent-drafts.ts\";\nimport type { AgentViewSwitcher, PendingOutcome } from \"./agent-view-switcher.ts\";\nimport type { AgentViewChange, AgentViewPort, AgentWorkingLine, ViewedTarget } from \"./contracts.ts\";\nimport { notifyViewed } from \"./viewed-notices.ts\";\nimport { forgetIfIdle, goneAgentNotice, liveAgentSteering } from \"./viewed-submit.ts\";\n\n/**\n * Retarget the main prompt to the agent the screen shows. While main is shown nothing here changes what the\n * main chat does or draws. While a subagent is shown, the same prompt writes to it: its own prompt (draft, cursor,\n * pastes, undo, Up history) is in the editor, the placeholder reads `Message @<name>…` and the top rule its title, the\n * rows above the prompt are its queue, the working line and the footer's stop key are its own, and what was typed\n * while it was being opened goes to it.\n */\nexport function installPromptRetarget(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tconst undo: (() => void)[] = [];\n\t// What only a shown subagent needs is set up the first time one is shown or opened: a session that only ever shows\n\t// main runs exactly as before, with nothing added to its keys or its status row.\n\tlet active = false;\n\tconst activate = () => {\n\t\tif (active) return;\n\t\tactive = true;\n\t\tundo.push(drawViewedWorkingLine(mode));\n\t\tundo.push(keepBashModeMain(mode));\n\t\tundo.push(swallowReadOnlyTyping(mode));\n\t};\n\tundo.push(retargetOnSwitch(mode, switcher, activate));\n\tundo.push(holdWhileOpening(mode, switcher));\n\tundo.push(reportLostAgentQueues(mode));\n\treturn () => {\n\t\tfor (const step of undo.splice(0).reverse()) step();\n\t};\n}\n\nfunction viewedPort(mode: InteractiveModeBase): AgentViewPort | undefined {\n\tconst viewed = mode.agentView?.viewed;\n\treturn viewed?.kind === \"agent\" ? viewed.port : undefined;\n}\n\nfunction ownerOf(target: ViewedTarget) {\n\treturn target.kind === \"agent\"\n\t\t? ({ kind: \"agent\", agentKey: target.port.agentKey } as const)\n\t\t: ({ kind: \"main\" } as const);\n}\n\n/** Swap the prompt, its history, placeholder, rule, rows and footer when the screen switches. */\nfunction retargetOnSwitch(mode: InteractiveModeBase, switcher: AgentViewSwitcher, activate: () => void): () => void {\n\tconst editor = mode.defaultEditor;\n\tconst history = promptHistoryFor(editor);\n\tlet unwatch: (() => void) | undefined;\n\tconst onChange = ({ from, to }: AgentViewChange) => {\n\t\tif (to.kind === \"agent\") activate();\n\t\tunwatch?.();\n\t\tunwatch = undefined;\n\t\t// The leaving prompt is kept before the history changes: replacing the history ends Up browsing.\n\t\tswitchPrompt(mode, ownerOf(to), () => {\n\t\t\tif (to.kind === \"agent\") history.viewAgent(to.port.agentKey, to.port.prompts());\n\t\t\telse history.viewMain();\n\t\t});\n\t\tif (to.kind === \"agent\") {\n\t\t\tconst port = to.port;\n\t\t\teditor.setPlaceholder(() => {\n\t\t\t\tconst status = port.status();\n\t\t\t\treturn status.readOnlyReason ?? status.placeholder;\n\t\t\t});\n\t\t\teditor.setTopRuleLabel(() => port.status().ruleLabel);\n\t\t\tmode.footer.setViewedWork(() => ({ working: port.status().busy, stopVerb: \"pause\" }));\n\t\t\tunwatch = port.subscribe(() => {\n\t\t\t\tmode.updatePendingMessagesDisplay();\n\t\t\t\tmode.ui.requestRender();\n\t\t\t});\n\t\t} else {\n\t\t\teditor.setPlaceholder(undefined);\n\t\t\teditor.setTopRuleLabel(() => mode.sessionManager.getSessionName());\n\t\t\tmode.footer.setViewedWork(undefined);\n\t\t}\n\t\tif (from.kind === \"agent\") {\n\t\t\tif (from.port.status().gone) moveGoneDraftToMain(mode, from.port);\n\t\t\tforgetIfIdle(mode, from.port);\n\t\t}\n\t\tmode.updatePendingMessagesDisplay();\n\t\tmode.ui.requestRender();\n\t};\n\tconst stop = switcher.onChange(onChange);\n\treturn () => {\n\t\tstop();\n\t\tunwatch?.();\n\t};\n}\n\n/** What was typed for a subagent that is gone goes in front of main's prompt, with the notice. */\nfunction moveGoneDraftToMain(mode: InteractiveModeBase, port: AgentViewPort): void {\n\tconst text = takePromptText(mode, { kind: \"agent\", agentKey: port.agentKey });\n\tif (!text.trim()) return;\n\t// It joins what the reader typed into main's prompt, never a history entry main's prompt was showing.\n\tconst moved = rewritePromptOwnText(mode, { kind: \"main\" }, (own) => mergeRestoredDraft(text, own));\n\tmarkMovedDraft(mode, port.status().name, moved);\n\tmode.showWarning(goneAgentNotice(port.status().name));\n}\n\n/** The viewed subagent's working line, drawn as its chat drew it; nothing when it shows none. */\nexport function renderAgentWorkingLine(line: AgentWorkingLine | undefined, width: number): string[] {\n\tif (line === undefined) return [];\n\tconst messageColor = (text: string) => theme.fg(\"muted\", text);\n\tswitch (line.kind) {\n\t\tcase \"worked\":\n\t\t\treturn new AtomicWorkedStatusComponent({\n\t\t\t\t...(line.message ? { message: line.message } : {}),\n\t\t\t\tsnapshot: {\n\t\t\t\t\telapsedMs: line.worked?.elapsedMs ?? line.elapsedMs ?? 0,\n\t\t\t\t\ttokens: line.worked?.tokens ?? line.tokens ?? 0,\n\t\t\t\t},\n\t\t\t\tcolor: (text) => theme.fg(\"dim\", text),\n\t\t\t}).render(width);\n\t\tcase \"busy\":\n\t\t\treturn new WorkingStatusComponent({ message: line.message, messageColor }).render(width);\n\t\tcase \"compacting\": {\n\t\t\tconst cancelKey = keyText(\"app.interrupt\");\n\t\t\treturn new WorkingStatusComponent({\n\t\t\t\tlogo: true,\n\t\t\t\tmessage: line.message,\n\t\t\t\tmeta: {\n\t\t\t\t\telapsedMs: line.elapsedMs ?? 0,\n\t\t\t\t\ttokens: 0,\n\t\t\t\t\t...(cancelKey ? { note: clickableKeyTextHint(cancelKey, \" to cancel\") } : {}),\n\t\t\t\t},\n\t\t\t\tmessageColor,\n\t\t\t}).render(width);\n\t\t}\n\t\tcase \"working\":\n\t\t\treturn new WorkingStatusComponent({\n\t\t\t\tmessage: line.message,\n\t\t\t\t...(line.elapsedMs === undefined ? {} : { meta: { elapsedMs: line.elapsedMs, tokens: line.tokens ?? 0 } }),\n\t\t\t\tmessageColor,\n\t\t\t}).render(width);\n\t}\n}\n\n/**\n * The status row above the prompt shows the viewed subagent's working line in place of the main chat's, which the\n * main chat keeps updating behind it. With main shown it draws exactly what it always did.\n */\nfunction drawViewedWorkingLine(mode: InteractiveModeBase): () => void {\n\tconst status: Component = mode.statusContainer;\n\tconst mainRender = status.render;\n\tlet stopClock: (() => void) | undefined;\n\tconst animate = (on: boolean) => {\n\t\tif (on && stopClock === undefined) stopClock = watchAtomicWorkingClock(() => mode.ui.requestRender());\n\t\telse if (!on && stopClock !== undefined) {\n\t\t\tstopClock();\n\t\t\tstopClock = undefined;\n\t\t}\n\t};\n\tstatus.render = function (this: Component, width: number): string[] {\n\t\tconst port = viewedPort(mode);\n\t\tif (port === undefined) {\n\t\t\tanimate(false);\n\t\t\treturn mainRender.call(this, width);\n\t\t}\n\t\tconst line = port.status().working;\n\t\tanimate(line !== undefined && line.kind !== \"worked\");\n\t\treturn renderAgentWorkingLine(line, width);\n\t};\n\treturn () => {\n\t\tanimate(false);\n\t\tstatus.render = mainRender;\n\t};\n}\n\n/**\n * `!` makes the main prompt a shell prompt; a subagent's refuses `!` commands, so its prompt never becomes one.\n */\nfunction keepBashModeMain(mode: InteractiveModeBase): () => void {\n\tconst editor = mode.defaultEditor;\n\tconst mainOnChange = editor.onChange;\n\tconst onChange = (text: string) => {\n\t\tif (viewedPort(mode) !== undefined) {\n\t\t\tif (mode.isBashMode) {\n\t\t\t\tmode.isBashMode = false;\n\t\t\t\tmode.updateEditorBorderColor();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tmainOnChange?.(text);\n\t};\n\teditor.onChange = onChange;\n\treturn () => {\n\t\tif (editor.onChange === onChange) editor.onChange = mainOnChange;\n\t};\n}\n\n/** Whether the prompt is what takes the keys now. */\nfunction promptTakesKeys(mode: InteractiveModeBase): boolean {\n\tif (mode.ui.hasOverlay() || !mode.editorContainer.children.includes(mode.editor)) return false;\n\tconst focused = (mode.ui as { getFocusedComponent?(): object | null }).getFocusedComponent?.();\n\treturn focused === undefined || focused === mode.editor;\n}\n\n/** Text the terminal sent as is, without control characters. */\nfunction isPlainText(data: string): boolean {\n\treturn data.length > 0 && [...data].every((ch) => ch >= \" \" && ch !== \"\\x7f\");\n}\n\n/** Printable text, a paste, Enter, Backspace or Delete: keys that type into or send the prompt. */\nfunction isTyping(data: string): boolean {\n\tif (matchesKey(data, \"enter\") || matchesKey(data, \"backspace\") || matchesKey(data, \"delete\")) return true;\n\treturn data.includes(\"\\x1b[200~\") || isPlainText(data) || decodePrintableKey(data) !== undefined;\n}\n\n/** A subagent whose chat is read-only takes no typing; scrolling and every other key still work. */\nfunction swallowReadOnlyTyping(mode: InteractiveModeBase): () => void {\n\treturn mode.addTuiInputListener((data) => {\n\t\tconst port = viewedPort(mode);\n\t\tif (port === undefined || port.status().readOnlyReason === undefined) return undefined;\n\t\tif (isKeyRelease(data) || !promptTakesKeys(mode) || !isTyping(data)) return undefined;\n\t\treturn { consume: true };\n\t});\n}\n\n/** The text that `keys` type: printable keys and pastes, less what Backspace removed. Nothing else is replayed. */\nexport function typedText(keys: readonly string[]): string {\n\tlet text = \"\";\n\tfor (const key of keys) {\n\t\tconst paste = /\\x1b\\[200~([\\s\\S]*?)\\x1b\\[201~/.exec(key);\n\t\tif (paste) text += paste[1];\n\t\telse if (matchesKey(key, \"backspace\")) text = [...text].slice(0, -1).join(\"\");\n\t\telse if (matchesKey(key, \"shift+enter\")) text += \"\\n\";\n\t\telse if (isPlainText(key)) text += key;\n\t\telse {\n\t\t\tconst printable = decodePrintableKey(key);\n\t\t\tif (printable !== undefined) text += printable;\n\t\t}\n\t}\n\treturn text;\n}\n\n/** The subagent `taskId` is an attempt of, as its first attempt's id, where this process holds its tasks. */\nfunction agentKeyOf(mode: InteractiveModeBase, taskId: TaskId): TaskId {\n\tconst tasks = getOwnerTaskStore(mode.session)?.tasks;\n\treturn (tasks === undefined ? undefined : firstSubagentAttempt(tasks, taskId)?.ref.taskId) ?? taskId;\n}\n\n/** Text typed for a subagent that was being opened when the request did not land, kept for when it is shown. */\nconst heldForTask = new WeakMap<InteractiveModeBase, Map<TaskId, string>>();\n\n/**\n * While a subagent is being opened, what the reader types is meant for it. The keys wait, and once it is shown they\n * reach its prompt in order, Enter included. When the request does not land, their text is kept for that subagent\n * (or, when it cannot be opened, shown in a notice) and the keys that send, pause or take back are dropped: nothing\n * typed for one agent reaches another. Esc cancels the request; Ctrl+C and Ctrl+D are never held.\n */\nfunction holdWhileOpening(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tlet held: { readonly taskId: TaskId; readonly keys: string[] } | undefined;\n\tconst keptFor = () => {\n\t\tlet map = heldForTask.get(mode);\n\t\tif (map === undefined) {\n\t\t\tmap = new Map();\n\t\t\theldForTask.set(mode, map);\n\t\t}\n\t\treturn map;\n\t};\n\tconst settle = (taskId: TaskId, outcome: PendingOutcome) => {\n\t\tconst keys = held;\n\t\tif (keys === undefined || keys.taskId !== taskId) return;\n\t\theld = undefined;\n\t\tif (keys.keys.length === 0) return;\n\t\tif (outcome === \"shown\") {\n\t\t\tfor (const key of keys.keys) mode.editor.handleInput(key);\n\t\t\tmode.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\t// Not shown: the keys that send, pause or take back go nowhere; the text stays the subagent's.\n\t\tconst text = typedText(keys.keys);\n\t\tif (!text.trim()) return;\n\t\tif (outcome === \"failed\") {\n\t\t\tmode.showWarning(`The subagent could not be shown; what you typed for it was not sent:\\n${text}`);\n\t\t\treturn;\n\t\t}\n\t\t// Kept under the subagent across its attempts where this process knows them: a resume meanwhile moves its row.\n\t\tconst key = agentKeyOf(mode, taskId);\n\t\tconst kept = keptFor();\n\t\tkept.set(key, `${kept.get(key) ?? \"\"}${text}`);\n\t\tnotifyViewed(mode, \"What you typed for the subagent is kept for it.\", \"info\");\n\t};\n\tconst hold = (data: string) => {\n\t\tconst pending = switcher.pendingTaskId;\n\t\tif (pending === undefined || isKeyRelease(data) || !promptTakesKeys(mode)) return undefined;\n\t\t// Ctrl+C and Ctrl+D act as they always do; Esc cancels the request and the screen stays as it is.\n\t\tif (isPhysicalCtrlC(data) || mode.keybindings.matches(data, \"app.clear\")) return undefined;\n\t\tif (mode.keybindings.matches(data, \"app.exit\")) return undefined;\n\t\tif (isPhysicalEscape(data) || mode.keybindings.matches(data, \"app.interrupt\")) {\n\t\t\tswitcher.cancelPending();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (held === undefined || held.taskId !== pending) held = { taskId: pending, keys: [] };\n\t\theld.keys.push(data);\n\t\treturn { consume: true };\n\t};\n\t// The keys are listened to from the first time a subagent is being opened.\n\tlet stopListening: (() => void) | undefined;\n\tconst stopPending = switcher.onPending((pending, settled) => {\n\t\tif (pending !== undefined) stopListening ??= mode.addTuiInputListener(hold);\n\t\tif (settled !== undefined) settle(settled.taskId, settled.outcome);\n\t});\n\tconst stopChange = switcher.onChange(({ to }) => {\n\t\tconst pending = switcher.pendingTaskId;\n\t\tif (to.kind !== \"agent\") return;\n\t\t// Text kept for this subagent from a request that did not land joins its prompt now.\n\t\tconst kept = heldForTask.get(mode);\n\t\tif (kept === undefined || kept.size === 0) return;\n\t\tfor (const id of new Set([pending, to.port.status().taskId, to.port.agentKey as TaskId])) {\n\t\t\tconst text = id === undefined ? undefined : kept.get(id);\n\t\t\tif (id === undefined || text === undefined) continue;\n\t\t\tkept.delete(id);\n\t\t\tappendPromptText(mode, { kind: \"agent\", agentKey: to.port.agentKey }, text);\n\t\t}\n\t});\n\treturn () => {\n\t\tstopListening?.();\n\t\tstopPending();\n\t\tstopChange();\n\t};\n}\n\n/**\n * The isolated engine was lost, and the subagents' sessions with it. What each shown or still-answering\n * subagent's prompt had queued or on its way is listed in full in a warning per subagent, as origin's subagent chats\n * reported theirs; nothing is sent again. A deliberate replacement changes nothing.\n */\nfunction reportLostAgentQueues(mode: InteractiveModeBase): () => void {\n\tconst runtime = mode.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\treturn attachLostAgentQueueNotices(mode, runtime);\n}\n\n/** Show these notices when `runtime`'s engine generation ends unexpectedly. Answers the detach. */\nexport function attachLostAgentQueueNotices(\n\tmode: InteractiveModeBase,\n\truntime: Pick<IsolatedInteractiveRuntime, \"onGenerationEnded\">,\n): () => void {\n\treturn runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tfor (const { port, controller } of liveAgentSteering(mode)) {\n\t\t\t// Its listed queue, what it took before listing, and what was on its way: steering first, each lane in order.\n\t\t\tcontroller.loseTarget();\n\t\t\tconst messages = controller.recoverTarget() ?? [];\n\t\t\tconst notice = engineLossSubagentNotice({ agent: port.status().name, steering: messages, followUp: [] });\n\t\t\tif (notice !== undefined) mode.showWarning(notice);\n\t\t}\n\t\tmode.updatePendingMessagesDisplay();\n\t\tmode.ui.requestRender();\n\t});\n}\n"]}
1
+ {"version":3,"file":"prompt-retarget.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/prompt-retarget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kBAAkB,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AAEzE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,2BAA2B,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAC9G,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAEnF,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACnG,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EACN,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,cAAc,GACd,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EACN,mBAAmB,EACnB,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,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KAAK,CAAC,QAAQ;YAAE,OAAO;QAC3B,KAAK,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,iBAAiB,CAAC,IAAI,CAAC,EAAE,CAAC;YAC5D,iHAAiH;YACjH,2BAA2B;YAC3B,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAG;gBACb,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;gBAClB,GAAG,CAAC,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,QAAQ,EAAE,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;aACrF,CAAC;YACF,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;gBAAE,IAAI,CAAC,WAAW,CAAC,2BAA2B,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/F,8GAA8G;YAC9G,UAAU,CAAC,UAAU,EAAE,CAAC;YACxB,MAAM,QAAQ,GAAG,UAAU,CAAC,aAAa,EAAE,IAAI,EAAE,CAAC;YAClD,MAAM,MAAM,GAAG,wBAAwB,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;YACzG,IAAI,MAAM,KAAK,SAAS;gBAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QACpD,CAAC;QACD,IAAI,CAAC,4BAA4B,EAAE,CAAC;QACpC,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;IACzB,CAAC,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { type Component, decodePrintableKey, isKeyRelease, matchesKey } from \"@bastani/atomic-tui\";\nimport { firstSubagentAttempt } from \"../../../core/tasks/completion.js\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { getOwnerTaskStore } from \"../../../core/tasks/owner-store.js\";\nimport { IsolatedInteractiveRuntime } from \"../../interactive-engine/isolated-runtime.js\";\nimport { promptHistoryFor } from \"../components/agent-prompt-history.ts\";\nimport { AtomicWorkedStatusComponent, watchAtomicWorkingClock } from \"../components/atomic-working-status.ts\";\nimport { keyText } from \"../components/keybinding-hints.js\";\nimport { clickableKeyTextHint } from \"../components/nav-keys.ts\";\nimport { WorkingStatusComponent } from \"../components/working-status.ts\";\nimport { isPhysicalCtrlC, isPhysicalEscape } from \"../interactive-key-identity.ts\";\nimport type { InteractiveModeBase } from \"../interactive-mode-base.ts\";\nimport { mergeRestoredDraft } from \"../interactive-prompt-restore.ts\";\nimport { engineLossSubagentNotice, engineLossUnconfirmedNotice } from \"../interactive-queueing.ts\";\nimport { theme } from \"../theme/theme.js\";\nimport {\n\tappendPromptText,\n\tmarkMovedDraft,\n\trewritePromptOwnText,\n\tswitchPrompt,\n\ttakePromptText,\n} from \"./agent-drafts.ts\";\nimport type { AgentViewSwitcher, PendingOutcome } from \"./agent-view-switcher.ts\";\nimport type { AgentViewChange, AgentViewPort, AgentWorkingLine, ViewedTarget } from \"./contracts.ts\";\nimport { notifyViewed } from \"./viewed-notices.ts\";\nimport {\n\tbackFromViewedAgent,\n\tforgetIfIdle,\n\tgoneAgentNotice,\n\tliveAgentSteering,\n\treplayToViewedAgent,\n} from \"./viewed-submit.ts\";\n\n/**\n * Retarget the main prompt to the agent the screen shows. While main is shown nothing here changes what the\n * main chat does or draws. While a subagent is shown, the same prompt writes to it: its own prompt (draft, cursor,\n * pastes, undo, Up history) is in the editor, the placeholder reads `Message @<name>…` and the top rule its title, the\n * rows above the prompt are its queue, the working line and the footer's stop key are its own, and what was typed\n * while it was being opened goes to it.\n */\nexport function installPromptRetarget(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tconst undo: (() => void)[] = [];\n\t// What only a shown subagent needs is set up the first time one is shown or opened: a session that only ever shows\n\t// main runs exactly as before, with nothing added to its keys or its status row.\n\tlet active = false;\n\tconst activate = () => {\n\t\tif (active) return;\n\t\tactive = true;\n\t\tundo.push(drawViewedWorkingLine(mode));\n\t\tundo.push(keepBashModeMain(mode));\n\t\tundo.push(swallowReadOnlyTyping(mode));\n\t};\n\tundo.push(retargetOnSwitch(mode, switcher, activate));\n\tundo.push(holdWhileOpening(mode, switcher));\n\tundo.push(reportLostAgentQueues(mode));\n\treturn () => {\n\t\tfor (const step of undo.splice(0).reverse()) step();\n\t};\n}\n\nfunction viewedPort(mode: InteractiveModeBase): AgentViewPort | undefined {\n\tconst viewed = mode.agentView?.viewed;\n\treturn viewed?.kind === \"agent\" ? viewed.port : undefined;\n}\n\nfunction ownerOf(target: ViewedTarget) {\n\treturn target.kind === \"agent\"\n\t\t? ({ kind: \"agent\", agentKey: target.port.agentKey } as const)\n\t\t: ({ kind: \"main\" } as const);\n}\n\n/** Swap the prompt, its history, placeholder, rule, rows and footer when the screen switches. */\nfunction retargetOnSwitch(mode: InteractiveModeBase, switcher: AgentViewSwitcher, activate: () => void): () => void {\n\tconst editor = mode.defaultEditor;\n\tconst history = promptHistoryFor(editor);\n\tlet unwatch: (() => void) | undefined;\n\tconst onChange = ({ from, to }: AgentViewChange) => {\n\t\tif (to.kind === \"agent\") activate();\n\t\tunwatch?.();\n\t\tunwatch = undefined;\n\t\t// The leaving prompt is kept before the history changes: replacing the history ends Up browsing.\n\t\tswitchPrompt(mode, ownerOf(to), () => {\n\t\t\tif (to.kind === \"agent\") history.viewAgent(to.port.agentKey, to.port.prompts());\n\t\t\telse history.viewMain();\n\t\t});\n\t\tif (to.kind === \"agent\") {\n\t\t\tconst port = to.port;\n\t\t\teditor.setPlaceholder(() => {\n\t\t\t\tconst status = port.status();\n\t\t\t\treturn status.readOnlyReason ?? status.placeholder;\n\t\t\t});\n\t\t\teditor.setTopRuleLabel(() => port.status().ruleLabel);\n\t\t\tmode.footer.setViewedWork(() => ({ working: port.status().busy, stopVerb: \"pause\" }));\n\t\t\t// ← on its empty prompt shows main; the main chat's ← stays the editor's.\n\t\t\teditor.onNavBack = (input) => backFromViewedAgent(mode, input);\n\t\t\tunwatch = port.subscribe(() => {\n\t\t\t\tmode.updatePendingMessagesDisplay();\n\t\t\t\tmode.ui.requestRender();\n\t\t\t});\n\t\t} else {\n\t\t\teditor.setPlaceholder(undefined);\n\t\t\teditor.setTopRuleLabel(() => mode.sessionManager.getSessionName());\n\t\t\tmode.footer.setViewedWork(undefined);\n\t\t\teditor.onNavBack = undefined;\n\t\t}\n\t\tif (from.kind === \"agent\") {\n\t\t\tif (from.port.status().gone) moveGoneDraftToMain(mode, from.port);\n\t\t\tforgetIfIdle(mode, from.port);\n\t\t}\n\t\tmode.updatePendingMessagesDisplay();\n\t\tmode.ui.requestRender();\n\t};\n\tconst stop = switcher.onChange(onChange);\n\treturn () => {\n\t\tstop();\n\t\tunwatch?.();\n\t\teditor.onNavBack = undefined;\n\t};\n}\n\n/** What was typed for a subagent that is gone goes in front of main's prompt, with the notice. */\nfunction moveGoneDraftToMain(mode: InteractiveModeBase, port: AgentViewPort): void {\n\tconst text = takePromptText(mode, { kind: \"agent\", agentKey: port.agentKey });\n\tif (!text.trim()) return;\n\t// It joins what the reader typed into main's prompt, never a history entry main's prompt was showing.\n\tconst moved = rewritePromptOwnText(mode, { kind: \"main\" }, (own) => mergeRestoredDraft(text, own));\n\tmarkMovedDraft(mode, port.status().name, moved);\n\tmode.showWarning(goneAgentNotice(port.status().name));\n}\n\n/** The viewed subagent's working line, drawn as its chat drew it; nothing when it shows none. */\nexport function renderAgentWorkingLine(line: AgentWorkingLine | undefined, width: number): string[] {\n\tif (line === undefined) return [];\n\tconst messageColor = (text: string) => theme.fg(\"muted\", text);\n\tswitch (line.kind) {\n\t\tcase \"worked\":\n\t\t\treturn new AtomicWorkedStatusComponent({\n\t\t\t\t...(line.message ? { message: line.message } : {}),\n\t\t\t\tsnapshot: {\n\t\t\t\t\telapsedMs: line.worked?.elapsedMs ?? line.elapsedMs ?? 0,\n\t\t\t\t\ttokens: line.worked?.tokens ?? line.tokens ?? 0,\n\t\t\t\t},\n\t\t\t\tcolor: (text) => theme.fg(\"dim\", text),\n\t\t\t}).render(width);\n\t\tcase \"busy\":\n\t\t\treturn new WorkingStatusComponent({ message: line.message, messageColor }).render(width);\n\t\tcase \"compacting\": {\n\t\t\tconst cancelKey = keyText(\"app.interrupt\");\n\t\t\treturn new WorkingStatusComponent({\n\t\t\t\tlogo: true,\n\t\t\t\tmessage: line.message,\n\t\t\t\tmeta: {\n\t\t\t\t\telapsedMs: line.elapsedMs ?? 0,\n\t\t\t\t\ttokens: 0,\n\t\t\t\t\t...(cancelKey ? { note: clickableKeyTextHint(cancelKey, \" to cancel\") } : {}),\n\t\t\t\t},\n\t\t\t\tmessageColor,\n\t\t\t}).render(width);\n\t\t}\n\t\tcase \"working\":\n\t\t\treturn new WorkingStatusComponent({\n\t\t\t\tmessage: line.message,\n\t\t\t\t...(line.elapsedMs === undefined ? {} : { meta: { elapsedMs: line.elapsedMs, tokens: line.tokens ?? 0 } }),\n\t\t\t\tmessageColor,\n\t\t\t}).render(width);\n\t}\n}\n\n/**\n * The status row above the prompt shows the viewed subagent's working line in place of the main chat's, which the\n * main chat keeps updating behind it. With main shown it draws exactly what it always did.\n */\nfunction drawViewedWorkingLine(mode: InteractiveModeBase): () => void {\n\tconst status: Component = mode.statusContainer;\n\tconst mainRender = status.render;\n\tlet stopClock: (() => void) | undefined;\n\tconst animate = (on: boolean) => {\n\t\tif (on && stopClock === undefined) stopClock = watchAtomicWorkingClock(() => mode.ui.requestRender());\n\t\telse if (!on && stopClock !== undefined) {\n\t\t\tstopClock();\n\t\t\tstopClock = undefined;\n\t\t}\n\t};\n\tstatus.render = function (this: Component, width: number): string[] {\n\t\tconst port = viewedPort(mode);\n\t\tif (port === undefined) {\n\t\t\tanimate(false);\n\t\t\treturn mainRender.call(this, width);\n\t\t}\n\t\tconst line = port.status().working;\n\t\tanimate(line !== undefined && line.kind !== \"worked\");\n\t\treturn renderAgentWorkingLine(line, width);\n\t};\n\treturn () => {\n\t\tanimate(false);\n\t\tstatus.render = mainRender;\n\t};\n}\n\n/**\n * `!` makes the main prompt a shell prompt; a subagent's refuses `!` commands, so its prompt never becomes one.\n */\nfunction keepBashModeMain(mode: InteractiveModeBase): () => void {\n\tconst editor = mode.defaultEditor;\n\tconst mainOnChange = editor.onChange;\n\tconst onChange = (text: string) => {\n\t\tif (viewedPort(mode) !== undefined) {\n\t\t\tif (mode.isBashMode) {\n\t\t\t\tmode.isBashMode = false;\n\t\t\t\tmode.updateEditorBorderColor();\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tmainOnChange?.(text);\n\t};\n\teditor.onChange = onChange;\n\treturn () => {\n\t\tif (editor.onChange === onChange) editor.onChange = mainOnChange;\n\t};\n}\n\n/** Whether the prompt is what takes the keys now. */\nfunction promptTakesKeys(mode: InteractiveModeBase): boolean {\n\tif (mode.ui.hasOverlay() || !mode.editorContainer.children.includes(mode.editor)) return false;\n\tconst focused = (mode.ui as { getFocusedComponent?(): object | null }).getFocusedComponent?.();\n\treturn focused === undefined || focused === mode.editor;\n}\n\n/** Text the terminal sent as is, without control characters. */\nfunction isPlainText(data: string): boolean {\n\treturn data.length > 0 && [...data].every((ch) => ch >= \" \" && ch !== \"\\x7f\");\n}\n\n/** Printable text, a paste, Enter, Backspace or Delete: keys that type into or send the prompt. */\nfunction isTyping(data: string): boolean {\n\tif (matchesKey(data, \"enter\") || matchesKey(data, \"backspace\") || matchesKey(data, \"delete\")) return true;\n\treturn data.includes(\"\\x1b[200~\") || isPlainText(data) || decodePrintableKey(data) !== undefined;\n}\n\n/** A subagent whose chat is read-only takes no typing; scrolling and every other key still work. */\nfunction swallowReadOnlyTyping(mode: InteractiveModeBase): () => void {\n\treturn mode.addTuiInputListener((data) => {\n\t\tconst port = viewedPort(mode);\n\t\tif (port === undefined || port.status().readOnlyReason === undefined) return undefined;\n\t\tif (isKeyRelease(data) || !promptTakesKeys(mode) || !isTyping(data)) return undefined;\n\t\treturn { consume: true };\n\t});\n}\n\n/** The text that `keys` type: printable keys and pastes, less what Backspace removed. Nothing else is replayed. */\nexport function typedText(keys: readonly string[]): string {\n\tlet text = \"\";\n\tfor (const key of keys) {\n\t\tconst paste = /\\x1b\\[200~([\\s\\S]*?)\\x1b\\[201~/.exec(key);\n\t\tif (paste) text += paste[1];\n\t\telse if (matchesKey(key, \"backspace\")) text = [...text].slice(0, -1).join(\"\");\n\t\telse if (matchesKey(key, \"shift+enter\")) text += \"\\n\";\n\t\telse if (isPlainText(key)) text += key;\n\t\telse {\n\t\t\tconst printable = decodePrintableKey(key);\n\t\t\tif (printable !== undefined) text += printable;\n\t\t}\n\t}\n\treturn text;\n}\n\n/** The subagent `taskId` is an attempt of, as its first attempt's id, where this process holds its tasks. */\nfunction agentKeyOf(mode: InteractiveModeBase, taskId: TaskId): TaskId {\n\tconst tasks = getOwnerTaskStore(mode.session)?.tasks;\n\treturn (tasks === undefined ? undefined : firstSubagentAttempt(tasks, taskId)?.ref.taskId) ?? taskId;\n}\n\n/** Text typed for a subagent that was being opened when the request did not land, kept for when it is shown. */\nconst heldForTask = new WeakMap<InteractiveModeBase, Map<TaskId, string>>();\n\n/**\n * While a subagent is being opened, what the reader types is meant for it. The keys wait, and once it is shown they\n * reach its prompt in order, Enter included. When the request does not land, their text is kept for that subagent\n * (or, when it cannot be opened, shown in a notice) and the keys that send, pause or take back are dropped: nothing\n * typed for one agent reaches another. A ← among them moves its cursor and never shows main. Esc cancels the request;\n * Ctrl+C and Ctrl+D are never held.\n */\nfunction holdWhileOpening(mode: InteractiveModeBase, switcher: AgentViewSwitcher): () => void {\n\tlet held: { readonly taskId: TaskId; readonly keys: string[] } | undefined;\n\tconst keptFor = () => {\n\t\tlet map = heldForTask.get(mode);\n\t\tif (map === undefined) {\n\t\t\tmap = new Map();\n\t\t\theldForTask.set(mode, map);\n\t\t}\n\t\treturn map;\n\t};\n\tconst settle = (taskId: TaskId, outcome: PendingOutcome) => {\n\t\tconst keys = held;\n\t\tif (keys === undefined || keys.taskId !== taskId) return;\n\t\theld = undefined;\n\t\tif (keys.keys.length === 0) return;\n\t\tif (outcome === \"shown\") {\n\t\t\treplayToViewedAgent(mode, keys.keys);\n\t\t\tmode.ui.requestRender();\n\t\t\treturn;\n\t\t}\n\t\t// Not shown: the keys that send, pause or take back go nowhere; the text stays the subagent's.\n\t\tconst text = typedText(keys.keys);\n\t\tif (!text.trim()) return;\n\t\tif (outcome === \"failed\") {\n\t\t\tmode.showWarning(`The subagent could not be shown; what you typed for it was not sent:\\n${text}`);\n\t\t\treturn;\n\t\t}\n\t\t// Kept under the subagent across its attempts where this process knows them: a resume meanwhile moves its row.\n\t\tconst key = agentKeyOf(mode, taskId);\n\t\tconst kept = keptFor();\n\t\tkept.set(key, `${kept.get(key) ?? \"\"}${text}`);\n\t\tnotifyViewed(mode, \"What you typed for the subagent is kept for it.\", \"info\");\n\t};\n\tconst hold = (data: string) => {\n\t\tconst pending = switcher.pendingTaskId;\n\t\tif (pending === undefined || isKeyRelease(data) || !promptTakesKeys(mode)) return undefined;\n\t\t// Ctrl+C and Ctrl+D act as they always do; Esc cancels the request and the screen stays as it is.\n\t\tif (isPhysicalCtrlC(data) || mode.keybindings.matches(data, \"app.clear\")) return undefined;\n\t\tif (mode.keybindings.matches(data, \"app.exit\")) return undefined;\n\t\tif (isPhysicalEscape(data) || mode.keybindings.matches(data, \"app.interrupt\")) {\n\t\t\tswitcher.cancelPending();\n\t\t\treturn { consume: true };\n\t\t}\n\t\tif (held === undefined || held.taskId !== pending) held = { taskId: pending, keys: [] };\n\t\theld.keys.push(data);\n\t\treturn { consume: true };\n\t};\n\t// The keys are listened to from the first time a subagent is being opened.\n\tlet stopListening: (() => void) | undefined;\n\tconst stopPending = switcher.onPending((pending, settled) => {\n\t\tif (pending !== undefined) stopListening ??= mode.addTuiInputListener(hold);\n\t\tif (settled !== undefined) settle(settled.taskId, settled.outcome);\n\t});\n\tconst stopChange = switcher.onChange(({ to }) => {\n\t\tconst pending = switcher.pendingTaskId;\n\t\tif (to.kind !== \"agent\") return;\n\t\t// Text kept for this subagent from a request that did not land joins its prompt now.\n\t\tconst kept = heldForTask.get(mode);\n\t\tif (kept === undefined || kept.size === 0) return;\n\t\tfor (const id of new Set([pending, to.port.status().taskId, to.port.agentKey as TaskId])) {\n\t\t\tconst text = id === undefined ? undefined : kept.get(id);\n\t\t\tif (id === undefined || text === undefined) continue;\n\t\t\tkept.delete(id);\n\t\t\tappendPromptText(mode, { kind: \"agent\", agentKey: to.port.agentKey }, text);\n\t\t}\n\t});\n\treturn () => {\n\t\tstopListening?.();\n\t\tstopPending();\n\t\tstopChange();\n\t};\n}\n\n/**\n * The isolated engine was lost, and the subagents' sessions with it. What each shown or still-answering\n * subagent's prompt had queued or on its way is listed in full in a warning per subagent, as origin's subagent chats\n * reported theirs; nothing is sent again. A deliberate replacement changes nothing.\n */\nfunction reportLostAgentQueues(mode: InteractiveModeBase): () => void {\n\tconst runtime = mode.runtimeHost;\n\tif (!(runtime instanceof IsolatedInteractiveRuntime)) return () => {};\n\treturn attachLostAgentQueueNotices(mode, runtime);\n}\n\n/** Show these notices when `runtime`'s engine generation ends unexpectedly. Answers the detach. */\nexport function attachLostAgentQueueNotices(\n\tmode: InteractiveModeBase,\n\truntime: Pick<IsolatedInteractiveRuntime, \"onGenerationEnded\">,\n): () => void {\n\treturn runtime.onGenerationEnded((event) => {\n\t\tif (event.expected) return;\n\t\tfor (const { port, controller } of liveAgentSteering(mode)) {\n\t\t\t// What it had taken and not been seen to save, being delivered or shown, may or may not have been saved with its\n\t\t\t// session: listed in full.\n\t\t\tconst { delivering, unsaved } = port.status();\n\t\t\tconst taken = [\n\t\t\t\t...(unsaved ?? []),\n\t\t\t\t...(delivering === undefined ? [] : [...delivering.steering, ...delivering.followUp]),\n\t\t\t];\n\t\t\tif (taken.length > 0) mode.showWarning(engineLossUnconfirmedNotice(taken, port.status().name));\n\t\t\t// Its listed queue, what it took before listing, and what was on its way: steering first, each lane in order.\n\t\t\tcontroller.loseTarget();\n\t\t\tconst messages = controller.recoverTarget() ?? [];\n\t\t\tconst notice = engineLossSubagentNotice({ agent: port.status().name, steering: messages, followUp: [] });\n\t\t\tif (notice !== undefined) mode.showWarning(notice);\n\t\t}\n\t\tmode.updatePendingMessagesDisplay();\n\t\tmode.ui.requestRender();\n\t});\n}\n"]}
@@ -11,6 +11,11 @@ import { type AgentViewRuntime } from "./agent-steering.ts";
11
11
  import type { AgentSteeringPort, AgentTranscriptComponent, AgentViewCommands, AgentViewPort, AgentViewStatus } from "./contracts.ts";
12
12
  /** How long an open waits for the transcript's first frame before it shows the subagent anyway. */
13
13
  export declare const FIRST_FRAME_TIMEOUT_MS = 2000;
14
+ /**
15
+ * How long an open whose request brings the agent panel back waits, once the transcript can draw, for the panel's first
16
+ * frame: as long as a key in a view the engine draws waits for the engine to answer. Within `FIRST_FRAME_TIMEOUT_MS`.
17
+ */
18
+ export declare const PANEL_FIRST_FRAME_TIMEOUT_MS = 250;
14
19
  /** The engine's transcript component, in the rows the transcript area gives it. */
15
20
  export declare class RemoteAgentTranscript implements AgentTranscriptComponent {
16
21
  private readonly mount;
@@ -57,11 +62,15 @@ export declare class RemoteAgentViewPort implements AgentViewPort {
57
62
  }
58
63
  /**
59
64
  * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or
60
- * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw.
65
+ * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw. With
66
+ * `panel`, the request brings the agent panel back: the panel the engine opens again draws its first frame first (or
67
+ * closes, or `PANEL_FIRST_FRAME_TIMEOUT_MS` passes), so the subagent is shown with the panel's rows.
61
68
  */
62
69
  export declare function openRemoteAgentViewPort(runtime: AgentViewRuntime, taskId: TaskId, frame: {
63
70
  readonly width: number;
64
71
  readonly rows: number;
65
72
  readonly colorDepth?: number;
73
+ }, options?: {
74
+ readonly panel?: boolean;
66
75
  }): Promise<RemoteAgentViewPort | undefined>;
67
76
  //# sourceMappingURL=remote-port.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"remote-port.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/remote-port.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC9E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,8CAA8C,CAAC;AAEjH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAAE,KAAK,gBAAgB,EAA6B,MAAM,qBAAqB,CAAC;AACvF,OAAO,KAAK,EACX,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,MAAM,gBAAgB,CAAC;AAExB,mGAAmG;AACnG,eAAO,MAAM,sBAAsB,OAAQ,CAAC;AAE5C,mFAAmF;AACnF,qBAAa,qBAAsB,YAAW,wBAAwB;IACrE,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAwB;IAC9C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAgB;IAC3C,yFAAyF;IACzF,OAAO,CAAC,SAAS,CAAqC;IACtD,OAAO,CAAC,MAAM,CAAK;IAEnB,YAAY,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,OAAO,EAGlE;IAED,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CASnD;IAED,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAE9B;IAED,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGnC;IAED,aAAa,IAAI,OAAO,CAEvB;IAED,WAAW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Ae,CAExB;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1C;IAED,KAAK,qGAEJ;IAED,OAAO,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAEpC;IAED,QAAQ,IAAI,OAAO,CAAC,iBAAiB,GAAG,SAAS,CAAC,CAEjD;IAEK,oBAAoB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMxD;IAED,MAAM,IAAI,MAAM,IAAI,CAQnB;IAED,OAAO,CAAC,SAAS;IAajB,OAAO,CAAC,OAAO;CAUf;AAED;;;;;GAKG;AACH,wBAAsB,uBAAuB,CAC5C,OAAO,EAAE,gBAAgB,EACzB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;IAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EACtF,OAAO,GAAE;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,GACxC,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAQ1C"}
@@ -1,10 +1,16 @@
1
- import { remoteTranscriptMount } from "../../interactive-engine/remote-component.js";
1
+ import { remoteTranscriptMount, watchWidgetFrames, } from "../../interactive-engine/remote-component.js";
2
2
  import { placeTranscriptFrame } from "../../interactive-engine/transcript-frame-layout.js";
3
+ import { AGENT_PANEL_WIDGET_KEY } from "../../rpc/agent-panel-bridge.js";
3
4
  import { remoteAgentCommands } from "./agent-commands.js";
4
5
  import { remoteAgentPrompts } from "./agent-prompts.js";
5
6
  import { createRemoteAgentSteering } from "./agent-steering.js";
6
7
  /** How long an open waits for the transcript's first frame before it shows the subagent anyway. */
7
8
  export const FIRST_FRAME_TIMEOUT_MS = 2_000;
9
+ /**
10
+ * How long an open whose request brings the agent panel back waits, once the transcript can draw, for the panel's first
11
+ * frame: as long as a key in a view the engine draws waits for the engine to answer. Within `FIRST_FRAME_TIMEOUT_MS`.
12
+ */
13
+ export const PANEL_FIRST_FRAME_TIMEOUT_MS = 250;
8
14
  /** The engine's transcript component, in the rows the transcript area gives it. */
9
15
  export class RemoteAgentTranscript {
10
16
  mount;
@@ -158,9 +164,21 @@ export class RemoteAgentViewPort {
158
164
  }
159
165
  /**
160
166
  * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or
161
- * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw.
167
+ * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw. With
168
+ * `panel`, the request brings the agent panel back: the panel the engine opens again draws its first frame first (or
169
+ * closes, or `PANEL_FIRST_FRAME_TIMEOUT_MS` passes), so the subagent is shown with the panel's rows.
162
170
  */
163
- export async function openRemoteAgentViewPort(runtime, taskId, frame) {
171
+ export async function openRemoteAgentViewPort(runtime, taskId, frame, options = {}) {
172
+ // Watched from the request on: the panel can open before the view does.
173
+ const panel = options.panel === true ? watchWidgetFrames(runtime, AGENT_PANEL_WIDGET_KEY) : undefined;
174
+ try {
175
+ return await openPort(runtime, taskId, frame, panel?.drawn);
176
+ }
177
+ finally {
178
+ panel?.stop();
179
+ }
180
+ }
181
+ async function openPort(runtime, taskId, frame, panelDrawn) {
164
182
  const data = await runtime.requestAgentView({ type: "agent_view_open", taskId });
165
183
  const mount = remoteTranscriptMount(runtime, data.viewId);
166
184
  if (mount === undefined || mount.closed) {
@@ -173,14 +191,28 @@ export async function openRemoteAgentViewPort(runtime, taskId, frame) {
173
191
  mount.rows = Math.max(1, frame.rows);
174
192
  mount.component.prime(Math.max(1, frame.width), mount.rows);
175
193
  let timer;
194
+ let panelTimer;
195
+ let settled = false;
176
196
  const framed = await Promise.race([
177
- mount.firstFrame(),
197
+ mount.firstFrame().then(async (first) => {
198
+ if (first && panelDrawn !== undefined && !settled)
199
+ await Promise.race([
200
+ panelDrawn(),
201
+ new Promise((resolve) => {
202
+ panelTimer = setTimeout(resolve, PANEL_FIRST_FRAME_TIMEOUT_MS);
203
+ panelTimer.unref?.();
204
+ }),
205
+ ]);
206
+ return first;
207
+ }),
178
208
  new Promise((resolve) => {
179
209
  timer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);
180
210
  timer.unref?.();
181
211
  }),
182
212
  ]);
213
+ settled = true;
183
214
  clearTimeout(timer);
215
+ clearTimeout(panelTimer);
184
216
  if (!framed) {
185
217
  port.retain()();
186
218
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"remote-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/remote-port.ts"],"names":[],"mappings":"AAOA,OAAO,EAA8B,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACjH,OAAO,EAA8B,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAEvH,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAyB,yBAAyB,EAAE,MAAM,qBAAqB,CAAC;AASvF,mGAAmG;AACnG,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,OAAO,qBAAqB;IAChB,KAAK,CAAwB;IAC7B,UAAU,CAAgB;IAC3C,yFAAyF;IACjF,SAAS,CAAqC;IAC9C,MAAM,GAAG,CAAC,CAAC;IAEnB,YAAY,KAA4B,EAAE,UAAyB;QAClE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,WAAW,CAAC,KAAa,EAAE,MAAc;QACxC,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,S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AAG,IAAI,mBAAmB,CAAC,OAAO,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;IAC3D,IAAI,KAAK,CAAC,UAAU,KAAK,SAAS;QAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,KAAK,CAAC,UAAU,CAAC;IACtF,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IACrC,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,KAAgD,CAAC;IACrD,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;QACjC,KAAK,CAAC,UAAU,EAAE;QAClB,IAAI,OAAO,CAAU,CAAC,OAAO,EAAE,EAAE;YAChC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;YAChE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,CAAC,CAAC;KACF,CAAC,CAAC;IACH,YAAY,CAAC,KAAK,CAAC,CAAC;IACpB,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the isolated engine, as the host's single chat screen shows it. The engine runs the subagent's port\n * (`LocalAgentViewPort`) and draws its transcript as a remote component the host paints where its main transcript is;\n * this proxy carries the status the engine reports for the view, and the view's commands.\n */\nimport type { TuiMouseEvent, TuiMouseEventResult } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { type RemoteTranscriptMount, remoteTranscriptMount } from \"../../interactive-engine/remote-component.ts\";\nimport { type PlacedTranscriptFrame, placeTranscriptFrame } from \"../../interactive-engine/transcript-frame-layout.ts\";\nimport type { AgentViewOpenData } from \"../../rpc/agent-view-rpc-types.ts\";\nimport { remoteAgentCommands } from \"./agent-commands.ts\";\nimport { remoteAgentPrompts } from \"./agent-prompts.ts\";\nimport { type AgentViewRuntime, createRemoteAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How long an open waits for the transcript's first frame before it shows the subagent anyway. */\nexport const FIRST_FRAME_TIMEOUT_MS = 2_000;\n\n/** The engine's transcript component, in the rows the transcript area gives it. */\nexport class RemoteAgentTranscript implements AgentTranscriptComponent {\n\tprivate readonly mount: RemoteTranscriptMount;\n\tprivate readonly heldPrompt: () => boolean;\n\t/** How the frame painted last was placed in the rows shown (`PlacedTranscriptFrame`). */\n\tprivate frameRows: PlacedTranscriptFrame[\"frameRows\"];\n\tprivate hidden = 0;\n\n\tconstructor(mount: RemoteTranscriptMount, heldPrompt: () => boolean) {\n\t\tthis.mount = mount;\n\t\tthis.heldPrompt = heldPrompt;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.mount.rows = Math.max(1, height);\n\t\tconst component = this.mount.component;\n\t\tconst lines = component.render(width);\n\t\t// A frame drawn for another height until the next one is here: its rows go where that frame will put them.\n\t\tconst placed = placeTranscriptFrame(lines, component.paintedLayout(), width, height);\n\t\tthis.frameRows = placed.frameRows;\n\t\tthis.hidden = placed.hidden;\n\t\treturn placed.lines;\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, this.mount.rows);\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\tvoid this.mount.component.handleInput(data);\n\t\treturn true;\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.heldPrompt();\n\t}\n\n\thandleInput(data: string): void {\n\t\tvoid this.mount.component.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tconst row = this.frameRow(event.y);\n\t\treturn row === undefined ? undefined : this.mount.component.handleMouse({ ...event, y: row });\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\tconst frameRow = this.frameRow(row);\n\t\treturn frameRow === undefined ? undefined : this.mount.component.paintedRowKey(frameRow);\n\t}\n\n\t/** The frame row painted at `row`: a row the host left blank until the next frame takes no click. */\n\tprivate frameRow(row: number): number | undefined {\n\t\tconst frameRows = this.frameRows;\n\t\tif (frameRows === undefined) return row + this.hidden;\n\t\tconst index = Math.floor(row);\n\t\treturn index >= 0 && index < frameRows.length ? frameRows[index] : undefined;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.mount.component.invalidate();\n\t}\n}\n\n/** View `viewId` of the engine: its status as last reported, its transcript, and its steering. */\nexport class RemoteAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly viewId: string;\n\treadonly transcript: RemoteAgentTranscript;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly runtime: AgentViewRuntime;\n\tprivate readonly generation: number;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate readonly unsubscribe: (() => void)[] = [];\n\n\tconstructor(runtime: AgentViewRuntime, data: AgentViewOpenData, mount: RemoteTranscriptMount) {\n\t\tthis.runtime = runtime;\n\t\tthis.viewId = data.viewId;\n\t\tthis.agentKey = data.status.agentKey;\n\t\tthis.current = data.status;\n\t\tthis.generation = runtime.getGeneration();\n\t\tthis.transcript = new RemoteAgentTranscript(mount, () => this.current.heldPrompt);\n\t\tthis.steeringPort = createRemoteAgentSteering({\n\t\t\truntime,\n\t\t\tviewId: data.viewId,\n\t\t\tstatus: () => this.status(),\n\t\t\tonStatus: (listener) => this.subscribe(listener),\n\t\t});\n\t\tthis.steering = this.steeringPort.steering;\n\t\tthis.unsubscribe.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_agent_view_status\" && message.viewId === this.viewId)\n\t\t\t\t\tthis.setStatus(message.status);\n\t\t\t}),\n\t\t\t// The engine is gone, and its subagents with it: the screen shows main.\n\t\t\truntime.onGenerationEnded(() => this.setStatus({ ...this.current, gone: true })),\n\t\t\tmount.onClose(() => this.setStatus({ ...this.current, gone: true })),\n\t\t);\n\t}\n\n\tstatus(): AgentViewStatus {\n\t\treturn this.current;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tpause() {\n\t\treturn this.steeringPort.pause();\n\t}\n\n\tprompts(): Promise<readonly string[]> {\n\t\treturn remoteAgentPrompts(this.runtime, this.current.taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn remoteAgentCommands(this.runtime, this.viewId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\tconst answer = await this.runtime.requestAgentView<{ text?: string }>({\n\t\t\ttype: \"agent_view_last_message\",\n\t\t\tviewId: this.viewId,\n\t\t});\n\t\treturn answer.text;\n\t}\n\n\tretain(): () => void {\n\t\tthis.retained++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tif (--this.retained === 0) this.dispose();\n\t\t};\n\t}\n\n\tprivate setStatus(status: AgentViewStatus): void {\n\t\tif (this.disposed) return;\n\t\t// Once gone, the view stays gone: a late report of the closed view changes nothing.\n\t\tthis.current = this.current.gone ? { ...status, gone: true } : status;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const unsubscribe of this.unsubscribe.splice(0)) unsubscribe();\n\t\tthis.listeners.clear();\n\t\tif (this.runtime.getGeneration() !== this.generation) return;\n\t\tvoid this.runtime.requestAgentView({ type: \"agent_view_close\", viewId: this.viewId }).catch(() => {\n\t\t\t// The engine closes its views with it.\n\t\t});\n\t}\n}\n\n/**\n * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or\n * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw.\n */\nexport async function openRemoteAgentViewPort(\n\truntime: AgentViewRuntime,\n\ttaskId: TaskId,\n\tframe: { readonly width: number; readonly rows: number; readonly colorDepth?: number },\n): Promise<RemoteAgentViewPort | undefined> {\n\tconst data = await runtime.requestAgentView<AgentViewOpenData>({ type: \"agent_view_open\", taskId });\n\tconst mount = remoteTranscriptMount(runtime, data.viewId);\n\tif (mount === undefined || mount.closed) {\n\t\tvoid runtime.requestAgentView({ type: \"agent_view_close\", viewId: data.viewId }).catch(() => {});\n\t\tthrow new Error(\"The subagent's transcript did not open.\");\n\t}\n\tconst port = new RemoteAgentViewPort(runtime, data, mount);\n\tif (frame.colorDepth !== undefined) mount.component.hostColorDepth = frame.colorDepth;\n\tmount.rows = Math.max(1, frame.rows);\n\tmount.component.prime(Math.max(1, frame.width), mount.rows);\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tconst framed = await Promise.race([\n\t\tmount.firstFrame(),\n\t\tnew Promise<boolean>((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t}),\n\t]);\n\tclearTimeout(timer);\n\tif (!framed) {\n\t\tport.retain()();\n\t\treturn undefined;\n\t}\n\treturn port;\n}\n"]}
1
+ {"version":3,"file":"remote-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/remote-port.ts"],"names":[],"mappings":"AAOA,OAAO,EAEN,qBAAqB,EACrB,iBAAiB,GACjB,MAAM,8CAA8C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AAK,CAAC,KAAK,EAAE,EAAE,CAAC;QACjB,CAAC,CAAC;KACF,CAAC,CAAC;IACH,OAAO,GAAG,IAAI,CAAC;IACf,YAAY,CAAC,KAAK,CAAC,CAAC;IACpB,YAAY,CAAC,UAAU,CAAC,CAAC;IACzB,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChB,OAAO,SAAS,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the isolated engine, as the host's single chat screen shows it. The engine runs the subagent's port\n * (`LocalAgentViewPort`) and draws its transcript as a remote component the host paints where its main transcript is;\n * this proxy carries the status the engine reports for the view, and the view's commands.\n */\nimport type { TuiMouseEvent, TuiMouseEventResult } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport {\n\ttype RemoteTranscriptMount,\n\tremoteTranscriptMount,\n\twatchWidgetFrames,\n} from \"../../interactive-engine/remote-component.ts\";\nimport { type PlacedTranscriptFrame, placeTranscriptFrame } from \"../../interactive-engine/transcript-frame-layout.ts\";\nimport { AGENT_PANEL_WIDGET_KEY } from \"../../rpc/agent-panel-bridge.ts\";\nimport type { AgentViewOpenData } from \"../../rpc/agent-view-rpc-types.ts\";\nimport { remoteAgentCommands } from \"./agent-commands.ts\";\nimport { remoteAgentPrompts } from \"./agent-prompts.ts\";\nimport { type AgentViewRuntime, createRemoteAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How long an open waits for the transcript's first frame before it shows the subagent anyway. */\nexport const FIRST_FRAME_TIMEOUT_MS = 2_000;\n/**\n * How long an open whose request brings the agent panel back waits, once the transcript can draw, for the panel's first\n * frame: as long as a key in a view the engine draws waits for the engine to answer. Within `FIRST_FRAME_TIMEOUT_MS`.\n */\nexport const PANEL_FIRST_FRAME_TIMEOUT_MS = 250;\n\n/** The engine's transcript component, in the rows the transcript area gives it. */\nexport class RemoteAgentTranscript implements AgentTranscriptComponent {\n\tprivate readonly mount: RemoteTranscriptMount;\n\tprivate readonly heldPrompt: () => boolean;\n\t/** How the frame painted last was placed in the rows shown (`PlacedTranscriptFrame`). */\n\tprivate frameRows: PlacedTranscriptFrame[\"frameRows\"];\n\tprivate hidden = 0;\n\n\tconstructor(mount: RemoteTranscriptMount, heldPrompt: () => boolean) {\n\t\tthis.mount = mount;\n\t\tthis.heldPrompt = heldPrompt;\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.mount.rows = Math.max(1, height);\n\t\tconst component = this.mount.component;\n\t\tconst lines = component.render(width);\n\t\t// A frame drawn for another height until the next one is here: its rows go where that frame will put them.\n\t\tconst placed = placeTranscriptFrame(lines, component.paintedLayout(), width, height);\n\t\tthis.frameRows = placed.frameRows;\n\t\tthis.hidden = placed.hidden;\n\t\treturn placed.lines;\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, this.mount.rows);\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\tvoid this.mount.component.handleInput(data);\n\t\treturn true;\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.heldPrompt();\n\t}\n\n\thandleInput(data: string): void {\n\t\tvoid this.mount.component.handleInput(data);\n\t}\n\n\thandleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined {\n\t\tconst row = this.frameRow(event.y);\n\t\treturn row === undefined ? undefined : this.mount.component.handleMouse({ ...event, y: row });\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\tconst frameRow = this.frameRow(row);\n\t\treturn frameRow === undefined ? undefined : this.mount.component.paintedRowKey(frameRow);\n\t}\n\n\t/** The frame row painted at `row`: a row the host left blank until the next frame takes no click. */\n\tprivate frameRow(row: number): number | undefined {\n\t\tconst frameRows = this.frameRows;\n\t\tif (frameRows === undefined) return row + this.hidden;\n\t\tconst index = Math.floor(row);\n\t\treturn index >= 0 && index < frameRows.length ? frameRows[index] : undefined;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.mount.component.invalidate();\n\t}\n}\n\n/** View `viewId` of the engine: its status as last reported, its transcript, and its steering. */\nexport class RemoteAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly viewId: string;\n\treadonly transcript: RemoteAgentTranscript;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly runtime: AgentViewRuntime;\n\tprivate readonly generation: number;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate readonly unsubscribe: (() => void)[] = [];\n\n\tconstructor(runtime: AgentViewRuntime, data: AgentViewOpenData, mount: RemoteTranscriptMount) {\n\t\tthis.runtime = runtime;\n\t\tthis.viewId = data.viewId;\n\t\tthis.agentKey = data.status.agentKey;\n\t\tthis.current = data.status;\n\t\tthis.generation = runtime.getGeneration();\n\t\tthis.transcript = new RemoteAgentTranscript(mount, () => this.current.heldPrompt);\n\t\tthis.steeringPort = createRemoteAgentSteering({\n\t\t\truntime,\n\t\t\tviewId: data.viewId,\n\t\t\tstatus: () => this.status(),\n\t\t\tonStatus: (listener) => this.subscribe(listener),\n\t\t});\n\t\tthis.steering = this.steeringPort.steering;\n\t\tthis.unsubscribe.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type === \"engine_agent_view_status\" && message.viewId === this.viewId)\n\t\t\t\t\tthis.setStatus(message.status);\n\t\t\t}),\n\t\t\t// The engine is gone, and its subagents with it: the screen shows main.\n\t\t\truntime.onGenerationEnded(() => this.setStatus({ ...this.current, gone: true })),\n\t\t\tmount.onClose(() => this.setStatus({ ...this.current, gone: true })),\n\t\t);\n\t}\n\n\tstatus(): AgentViewStatus {\n\t\treturn this.current;\n\t}\n\n\tsubscribe(listener: () => void): () => void {\n\t\tthis.listeners.add(listener);\n\t\treturn () => this.listeners.delete(listener);\n\t}\n\n\tpause() {\n\t\treturn this.steeringPort.pause();\n\t}\n\n\tprompts(): Promise<readonly string[]> {\n\t\treturn remoteAgentPrompts(this.runtime, this.current.taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn remoteAgentCommands(this.runtime, this.viewId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\tconst answer = await this.runtime.requestAgentView<{ text?: string }>({\n\t\t\ttype: \"agent_view_last_message\",\n\t\t\tviewId: this.viewId,\n\t\t});\n\t\treturn answer.text;\n\t}\n\n\tretain(): () => void {\n\t\tthis.retained++;\n\t\tlet released = false;\n\t\treturn () => {\n\t\t\tif (released) return;\n\t\t\treleased = true;\n\t\t\tif (--this.retained === 0) this.dispose();\n\t\t};\n\t}\n\n\tprivate setStatus(status: AgentViewStatus): void {\n\t\tif (this.disposed) return;\n\t\t// Once gone, the view stays gone: a late report of the closed view changes nothing.\n\t\tthis.current = this.current.gone ? { ...status, gone: true } : status;\n\t\tfor (const listener of [...this.listeners]) {\n\t\t\ttry {\n\t\t\t\tlistener();\n\t\t\t} catch {\n\t\t\t\t// A listener's failure must not stop the others.\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tfor (const unsubscribe of this.unsubscribe.splice(0)) unsubscribe();\n\t\tthis.listeners.clear();\n\t\tif (this.runtime.getGeneration() !== this.generation) return;\n\t\tvoid this.runtime.requestAgentView({ type: \"agent_view_close\", viewId: this.viewId }).catch(() => {\n\t\t\t// The engine closes its views with it.\n\t\t});\n\t}\n}\n\n/**\n * Open view of the subagent `taskId` is an attempt of in the engine, once its transcript's first frame is here (or\n * after `FIRST_FRAME_TIMEOUT_MS`): the screen never shows the subagent before there is something to draw. With\n * `panel`, the request brings the agent panel back: the panel the engine opens again draws its first frame first (or\n * closes, or `PANEL_FIRST_FRAME_TIMEOUT_MS` passes), so the subagent is shown with the panel's rows.\n */\nexport async function openRemoteAgentViewPort(\n\truntime: AgentViewRuntime,\n\ttaskId: TaskId,\n\tframe: { readonly width: number; readonly rows: number; readonly colorDepth?: number },\n\toptions: { readonly panel?: boolean } = {},\n): Promise<RemoteAgentViewPort | undefined> {\n\t// Watched from the request on: the panel can open before the view does.\n\tconst panel = options.panel === true ? watchWidgetFrames(runtime, AGENT_PANEL_WIDGET_KEY) : undefined;\n\ttry {\n\t\treturn await openPort(runtime, taskId, frame, panel?.drawn);\n\t} finally {\n\t\tpanel?.stop();\n\t}\n}\n\nasync function openPort(\n\truntime: AgentViewRuntime,\n\ttaskId: TaskId,\n\tframe: { readonly width: number; readonly rows: number; readonly colorDepth?: number },\n\tpanelDrawn: (() => Promise<void>) | undefined,\n): Promise<RemoteAgentViewPort | undefined> {\n\tconst data = await runtime.requestAgentView<AgentViewOpenData>({ type: \"agent_view_open\", taskId });\n\tconst mount = remoteTranscriptMount(runtime, data.viewId);\n\tif (mount === undefined || mount.closed) {\n\t\tvoid runtime.requestAgentView({ type: \"agent_view_close\", viewId: data.viewId }).catch(() => {});\n\t\tthrow new Error(\"The subagent's transcript did not open.\");\n\t}\n\tconst port = new RemoteAgentViewPort(runtime, data, mount);\n\tif (frame.colorDepth !== undefined) mount.component.hostColorDepth = frame.colorDepth;\n\tmount.rows = Math.max(1, frame.rows);\n\tmount.component.prime(Math.max(1, frame.width), mount.rows);\n\tlet timer: ReturnType<typeof setTimeout> | undefined;\n\tlet panelTimer: ReturnType<typeof setTimeout> | undefined;\n\tlet settled = false;\n\tconst framed = await Promise.race([\n\t\tmount.firstFrame().then(async (first) => {\n\t\t\tif (first && panelDrawn !== undefined && !settled)\n\t\t\t\tawait Promise.race([\n\t\t\t\t\tpanelDrawn(),\n\t\t\t\t\tnew Promise<void>((resolve) => {\n\t\t\t\t\t\tpanelTimer = setTimeout(resolve, PANEL_FIRST_FRAME_TIMEOUT_MS);\n\t\t\t\t\t\tpanelTimer.unref?.();\n\t\t\t\t\t}),\n\t\t\t\t]);\n\t\t\treturn first;\n\t\t}),\n\t\tnew Promise<boolean>((resolve) => {\n\t\t\ttimer = setTimeout(() => resolve(true), FIRST_FRAME_TIMEOUT_MS);\n\t\t\ttimer.unref?.();\n\t\t}),\n\t]);\n\tsettled = true;\n\tclearTimeout(timer);\n\tclearTimeout(panelTimer);\n\tif (!framed) {\n\t\tport.retain()();\n\t\treturn undefined;\n\t}\n\treturn port;\n}\n"]}
@@ -0,0 +1,56 @@
1
+ import type { NavBackInput } from "../components/custom-editor.ts";
2
+ import type { InteractiveModeBase } from "../interactive-mode-base.ts";
3
+ /**
4
+ * The keys the prompt answers itself while a subagent is shown, with what the screen holds when each arrives. Esc acts
5
+ * on the subagent's turn and never leaves its view. The back key (`app.nav.back`, ← by default) on an empty prompt is
6
+ * the way back to main, and leaves the subagent's run and queue as they are; with text typed, it is the editor's.
7
+ * Ctrl+C on an empty prompt pauses the subagent's work and shows main in one press.
8
+ */
9
+ export type ViewedAgentKey =
10
+ /** Esc. `pausable`: the subagent works, waits to retry, or has messages queued. */
11
+ {
12
+ readonly key: "escape";
13
+ readonly pausable: boolean;
14
+ }
15
+ /** A SIGINT signal from outside the keyboard. */
16
+ | {
17
+ readonly key: "signal";
18
+ readonly pausable: boolean;
19
+ }
20
+ /** Ctrl+C on an empty prompt. */
21
+ | {
22
+ readonly key: "leave";
23
+ readonly pausable: boolean;
24
+ }
25
+ /**
26
+ * The back key. `promptEmpty`: the prompt holds nothing (whitespace, a newline or a paste is text) and shows no
27
+ * completion menu. `clicked`: a click on its hint pressed it. `replayed`: it was pressed while the subagent was
28
+ * being opened, and types into its prompt as every key pressed then does.
29
+ */
30
+ | {
31
+ readonly key: "back";
32
+ readonly promptEmpty: boolean;
33
+ readonly clicked: boolean;
34
+ readonly replayed: boolean;
35
+ };
36
+ /** What the key does: `editor` leaves it to the prompt, which moves its cursor. */
37
+ export type ViewedAgentKeyAction = "pause" | "showMain" | "pauseAndShowMain" | "none" | "editor";
38
+ export declare function viewedAgentKeyAction(input: ViewedAgentKey): ViewedAgentKeyAction;
39
+ /** Where the back key leads, as its hint names it. */
40
+ export declare const VIEWED_AGENT_BACK_LABEL = "main chat";
41
+ type BackHandler = (input: NavBackInput) => boolean;
42
+ /**
43
+ * The back handler for an extension's editor built on the prompt's editor: the prompt's own, whichever it is when the
44
+ * key arrives, so ← on that editor's empty prompt leads back to main as it does on the prompt's.
45
+ */
46
+ export declare function navBackForwarder(mode: InteractiveModeBase): BackHandler;
47
+ /** The keys that lead back to main from the shown subagent's empty prompt, for its key list; empty while main is shown. */
48
+ export declare function viewedAgentBackKeyList(mode: InteractiveModeBase): readonly string[];
49
+ /**
50
+ * The keys that take the screen back to main if pressed now, for the hint by the prompt: while a subagent is shown, its
51
+ * prompt has the keys and is empty, and no other subagent is being opened. They are the keys the prompt itself routes
52
+ * to the back action. Undefined when a press would not go back.
53
+ */
54
+ export declare function viewedAgentBackKeys(mode: InteractiveModeBase): readonly string[] | undefined;
55
+ export {};
56
+ //# sourceMappingURL=viewed-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewed-keys.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/viewed-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE;;;;;GAKG;AACH,MAAM,MAAM,cAAc;AACzB,mFAAmF;AACjF;IAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AACxD,iDAAiD;GAC/C;IAAE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AACxD,iCAAiC;GAC/B;IAAE,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE;AACvD;;;;GAIG;GACD;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAElH,mFAAmF;AACnF,MAAM,MAAM,oBAAoB,GAAG,OAAO,GAAG,UAAU,GAAG,kBAAkB,GAAG,MAAM,GAAG,QAAQ,CAAC;AAEjG,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,GAAG,oBAAoB,CAUhF;AAED,sDAAsD;AACtD,eAAO,MAAM,uBAAuB,cAAc,CAAC;AAEnD,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,YAAY,KAAK,OAAO,CAAC;AAKpD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,WAAW,CAIvE;AAkBD,2HAA2H;AAC3H,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,MAAM,EAAE,CAEnF;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,mBAAmB,GAAG,SAAS,MAAM,EAAE,GAAG,SAAS,CAQ5F"}
@@ -0,0 +1,63 @@
1
+ export function viewedAgentKeyAction(input) {
2
+ switch (input.key) {
3
+ case "escape":
4
+ case "signal":
5
+ return input.pausable ? "pause" : "none";
6
+ case "leave":
7
+ return input.pausable ? "pauseAndShowMain" : "showMain";
8
+ case "back":
9
+ return !input.replayed && (input.promptEmpty || input.clicked) ? "showMain" : "editor";
10
+ }
11
+ }
12
+ /** Where the back key leads, as its hint names it. */
13
+ export const VIEWED_AGENT_BACK_LABEL = "main chat";
14
+ /** Back handlers that hand the key to the prompt's own, given to extension editors built on the prompt. */
15
+ const forwarders = new WeakSet();
16
+ /**
17
+ * The back handler for an extension's editor built on the prompt's editor: the prompt's own, whichever it is when the
18
+ * key arrives, so ← on that editor's empty prompt leads back to main as it does on the prompt's.
19
+ */
20
+ export function navBackForwarder(mode) {
21
+ const forward = (input) => mode.defaultEditor.onNavBack?.(input) ?? false;
22
+ forwarders.add(forward);
23
+ return forward;
24
+ }
25
+ /**
26
+ * The editor in the prompt's place that routes the back key to main while a subagent is shown: the prompt's own, or an
27
+ * extension's editor built on it that left the key to the prompt. Undefined while main is shown or for any other editor.
28
+ */
29
+ function backRoutingEditor(mode) {
30
+ if (mode.agentView?.viewed.kind !== "agent")
31
+ return undefined;
32
+ if (mode.editor === mode.defaultEditor)
33
+ return mode.defaultEditor;
34
+ const editor = mode.editor;
35
+ const { navBackKeys, navBackEmpty, onNavBack } = editor;
36
+ if (onNavBack === undefined || !forwarders.has(onNavBack))
37
+ return undefined;
38
+ if (typeof navBackKeys !== "function" || typeof navBackEmpty !== "function")
39
+ return undefined;
40
+ return editor;
41
+ }
42
+ /** The keys that lead back to main from the shown subagent's empty prompt, for its key list; empty while main is shown. */
43
+ export function viewedAgentBackKeyList(mode) {
44
+ return backRoutingEditor(mode)?.navBackKeys() ?? [];
45
+ }
46
+ /**
47
+ * The keys that take the screen back to main if pressed now, for the hint by the prompt: while a subagent is shown, its
48
+ * prompt has the keys and is empty, and no other subagent is being opened. They are the keys the prompt itself routes
49
+ * to the back action. Undefined when a press would not go back.
50
+ */
51
+ export function viewedAgentBackKeys(mode) {
52
+ const editor = backRoutingEditor(mode);
53
+ if (editor === undefined || mode.agentView?.pendingTaskId !== undefined || !editor.navBackEmpty())
54
+ return undefined;
55
+ if (mode.ui.hasOverlay() || !mode.editorContainer.children.includes(mode.editor))
56
+ return undefined;
57
+ const focused = mode.ui.getFocusedComponent?.();
58
+ if (focused !== undefined && focused !== mode.editor)
59
+ return undefined;
60
+ const keys = editor.navBackKeys();
61
+ return keys.length > 0 ? keys : undefined;
62
+ }
63
+ //# sourceMappingURL=viewed-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"viewed-keys.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/viewed-keys.ts"],"names":[],"mappings":"AA0BA,MAAM,UAAU,oBAAoB,CAAC,KAAqB;IACzD,QAAQ,KAAK,CAAC,GAAG,EAAE,CAAC;QACnB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;QAC1C,KAAK,OAAO;YACX,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,CAAC,UAAU,CAAC;QACzD,KAAK,MAAM;YACV,OAAO,CAAC,KAAK,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC;IACzF,CAAC;AACF,CAAC;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,uBAAuB,GAAG,WAAW,CAAC;AAInD,2GAA2G;AAC3G,MAAM,UAAU,GAAG,IAAI,OAAO,EAAe,CAAC;AAE9C;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAyB;IACzD,MAAM,OAAO,GAAgB,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;IACvF,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,OAAO,CAAC;AAChB,CAAC;AAID;;;GAGG;AACH,SAAS,iBAAiB,CAAC,IAAyB;IACnD,IAAI,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,SAAS,CAAC;IAC9D,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,aAAa;QAAE,O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CAAC,SAAS,CAAC;AAC3C,CAAC","sourcesContent":["import type { CustomEditor, NavBackInput } from \"../components/custom-editor.ts\";\nimport type { InteractiveModeBase } from \"../interactive-mode-base.ts\";\n\n/**\n * The keys the prompt answers itself while a subagent is shown, with what the screen holds when each arrives. Esc acts\n * on the subagent's turn and never leaves its view. The back key (`app.nav.back`, ← by default) on an empty prompt is\n * the way back to main, and leaves the subagent's run and queue as they are; with text typed, it is the editor's.\n * Ctrl+C on an empty prompt pauses the subagent's work and shows main in one press.\n */\nexport type ViewedAgentKey =\n\t/** Esc. `pausable`: the subagent works, waits to retry, or has messages queued. */\n\t| { readonly key: \"escape\"; readonly pausable: boolean }\n\t/** A SIGINT signal from outside the keyboard. */\n\t| { readonly key: \"signal\"; readonly pausable: boolean }\n\t/** Ctrl+C on an empty prompt. */\n\t| { readonly key: \"leave\"; readonly pausable: boolean }\n\t/**\n\t * The back key. `promptEmpty`: the prompt holds nothing (whitespace, a newline or a paste is text) and shows no\n\t * completion menu. `clicked`: a click on its hint pressed it. `replayed`: it was pressed while the subagent was\n\t * being opened, and types into its prompt as every key pressed then does.\n\t */\n\t| { readonly key: \"back\"; readonly promptEmpty: boolean; readonly clicked: boolean; readonly replayed: boolean };\n\n/** What the key does: `editor` leaves it to the prompt, which moves its cursor. */\nexport type ViewedAgentKeyAction = \"pause\" | \"showMain\" | \"pauseAndShowMain\" | \"none\" | \"editor\";\n\nexport function viewedAgentKeyAction(input: ViewedAgentKey): ViewedAgentKeyAction {\n\tswitch (input.key) {\n\t\tcase \"escape\":\n\t\tcase \"signal\":\n\t\t\treturn input.pausable ? \"pause\" : \"none\";\n\t\tcase \"leave\":\n\t\t\treturn input.pausable ? \"pauseAndShowMain\" : \"showMain\";\n\t\tcase \"back\":\n\t\t\treturn !input.replayed && (input.promptEmpty || input.clicked) ? \"showMain\" : \"editor\";\n\t}\n}\n\n/** Where the back key leads, as its hint names it. */\nexport const VIEWED_AGENT_BACK_LABEL = \"main chat\";\n\ntype BackHandler = (input: NavBackInput) => boolean;\n\n/** Back handlers that hand the key to the prompt's own, given to extension editors built on the prompt. */\nconst forwarders = new WeakSet<BackHandler>();\n\n/**\n * The back handler for an extension's editor built on the prompt's editor: the prompt's own, whichever it is when the\n * key arrives, so ← on that editor's empty prompt leads back to main as it does on the prompt's.\n */\nexport function navBackForwarder(mode: InteractiveModeBase): BackHandler {\n\tconst forward: BackHandler = (input) => mode.defaultEditor.onNavBack?.(input) ?? false;\n\tforwarders.add(forward);\n\treturn forward;\n}\n\ntype BackRoutingEditor = Pick<CustomEditor, \"navBackKeys\" | \"navBackEmpty\">;\n\n/**\n * The editor in the prompt's place that routes the back key to main while a subagent is shown: the prompt's own, or an\n * extension's editor built on it that left the key to the prompt. Undefined while main is shown or for any other editor.\n */\nfunction backRoutingEditor(mode: InteractiveModeBase): BackRoutingEditor | undefined {\n\tif (mode.agentView?.viewed.kind !== \"agent\") return undefined;\n\tif (mode.editor === mode.defaultEditor) return mode.defaultEditor;\n\tconst editor = mode.editor as Partial<Pick<CustomEditor, \"navBackKeys\" | \"navBackEmpty\" | \"onNavBack\">>;\n\tconst { navBackKeys, navBackEmpty, onNavBack } = editor;\n\tif (onNavBack === undefined || !forwarders.has(onNavBack)) return undefined;\n\tif (typeof navBackKeys !== \"function\" || typeof navBackEmpty !== \"function\") return undefined;\n\treturn editor as BackRoutingEditor;\n}\n\n/** The keys that lead back to main from the shown subagent's empty prompt, for its key list; empty while main is shown. */\nexport function viewedAgentBackKeyList(mode: InteractiveModeBase): readonly string[] {\n\treturn backRoutingEditor(mode)?.navBackKeys() ?? [];\n}\n\n/**\n * The keys that take the screen back to main if pressed now, for the hint by the prompt: while a subagent is shown, its\n * prompt has the keys and is empty, and no other subagent is being opened. They are the keys the prompt itself routes\n * to the back action. Undefined when a press would not go back.\n */\nexport function viewedAgentBackKeys(mode: InteractiveModeBase): readonly string[] | undefined {\n\tconst editor = backRoutingEditor(mode);\n\tif (editor === undefined || mode.agentView?.pendingTaskId !== undefined || !editor.navBackEmpty()) return undefined;\n\tif (mode.ui.hasOverlay() || !mode.editorContainer.children.includes(mode.editor)) return undefined;\n\tconst focused = (mode.ui as { getFocusedComponent?(): object | null }).getFocusedComponent?.();\n\tif (focused !== undefined && focused !== mode.editor) return undefined;\n\tconst keys = editor.navBackKeys();\n\treturn keys.length > 0 ? keys : undefined;\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import type { NavBackInput } from "../components/custom-editor.ts";
1
2
  import type { InteractiveModeBase } from "../interactive-mode-base.ts";
2
3
  import { SteeringQueueController, type SteeringSubmitLane } from "../steering-queue-controller.ts";
3
4
  import type { AgentViewPort } from "./contracts.ts";
@@ -5,7 +6,8 @@ import type { AgentViewPort } from "./contracts.ts";
5
6
  * What the one prompt does while a subagent is shown: it steers that subagent exactly as it steers the main chat,
6
7
  * through the shared steering controller over the subagent's own session (#6008). Enter steers and Alt+Enter queues a
7
8
  * follow-up while it works, each shown as a queued row until the subagent takes it; Alt+Up takes every queued message
8
- * back; Esc pauses it and its queued messages come back to its prompt; the next message continues it.
9
+ * back; Esc pauses it and its queued messages come back to its prompt; the next message continues it. ← on an empty
10
+ * prompt shows main and leaves it running.
9
11
  */
10
12
  /** `!` commands run in the main chat's shell; a subagent's view refuses them. */
11
13
  export declare const VIEWED_BASH_REFUSED = "`!` commands run in the main chat. Switch to main to run them.";
@@ -34,11 +36,19 @@ export declare function liveAgentSteering(mode: InteractiveModeBase): readonly {
34
36
  */
35
37
  export declare function submitToViewedAgent(mode: InteractiveModeBase, port: AgentViewPort, text: string, draft: string, lane?: SteeringSubmitLane): Promise<void>;
36
38
  /**
37
- * Esc while a subagent is shown: pause it when it works, waits to retry or has messages queued, and stay. On an
38
- * empty prompt while it does not work, Esc shows main; that Esc is not the first press of main's double-Esc. With text
39
- * typed it does nothing. Answers false while main is shown, which keeps the main chat's Esc.
39
+ * Esc while a subagent is shown: pause it when it works, waits to retry or has messages queued. It never shows main,
40
+ * and it is never the first press of main's double-Esc. Answers false while main is shown, which keeps the main chat's
41
+ * Esc.
40
42
  */
41
43
  export declare function escapeViewedAgent(mode: InteractiveModeBase): boolean;
44
+ /** Type `keys`, pressed while the subagent now shown was being opened, into its prompt. None of them shows main. */
45
+ export declare function replayToViewedAgent(mode: InteractiveModeBase, keys: readonly string[]): void;
46
+ /**
47
+ * The back key while a subagent is shown: on an empty prompt, or from a click on its hint, it shows main and leaves the
48
+ * subagent's run, its queue and both prompts as they are. That press is not the first of main's double-Esc. Answers
49
+ * false when the key is the prompt's: text is typed, or another handler has that key.
50
+ */
51
+ export declare function backFromViewedAgent(mode: InteractiveModeBase, input: NavBackInput): boolean;
42
52
  /**
43
53
  * Ctrl+C on an empty prompt while a subagent is shown: it pauses the subagent's running work, as Esc does, and shows
44
54
  * main, in one press. It never counts toward exiting Atomic. Answers false while main is shown.
@@ -1 +1 @@
1
- {"version":3,"file":"viewed-submit.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/viewed-submit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAEN,uBAAuB,EACvB,KAAK,kBAAkB,EACvB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAIpD;;;;;GAKG;AAEH,iFAAiF;AACjF,eAAO,MAAM,mBAAmB,mEAAmE,CAAC;AAEpG,mGAAmG;AACnG,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEpD;AAmDD,2GAA2G;AAC3G,wBAAgB,aAAa,CAAC,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,aAAa,GAAG,uBAAuB,CAErG;AAED,+FAA+F;AAC/F,wBAAgB,cAAc,CAAC,IAAI,EAAE,mBAAmB,GAAG,uBAAuB,GAAG,SAAS,CAG7F;AAkBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,mBAAmB,EAAE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