@bastani/atomic 0.10.0-alpha.1 → 0.10.1-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 (234) hide show
  1. package/CHANGELOG.md +211 -0
  2. package/dist/builtin/intercom/CHANGELOG.md +22 -0
  3. package/dist/builtin/intercom/package.json +1 -1
  4. package/dist/builtin/mcp/package.json +1 -1
  5. package/dist/builtin/subagents/CHANGELOG.md +35 -0
  6. package/dist/builtin/subagents/package.json +1 -1
  7. package/dist/builtin/subagents/skills/tmux/scripts/wait-for-text.sh +33 -3
  8. package/dist/builtin/web-access/package.json +1 -1
  9. package/dist/core/agent-session-events.d.ts.map +1 -1
  10. package/dist/core/agent-session-events.js +21 -6
  11. package/dist/core/agent-session-events.js.map +1 -1
  12. package/dist/core/lifecycle-timings.d.ts +6 -0
  13. package/dist/core/lifecycle-timings.d.ts.map +1 -1
  14. package/dist/core/lifecycle-timings.js +12 -0
  15. package/dist/core/lifecycle-timings.js.map +1 -1
  16. package/dist/core/queued-message-delivery.d.ts +41 -0
  17. package/dist/core/queued-message-delivery.d.ts.map +1 -0
  18. package/dist/core/queued-message-delivery.js +48 -0
  19. package/dist/core/queued-message-delivery.js.map +1 -0
  20. package/dist/core/storage/node-sqlite-thread.d.ts +64 -0
  21. package/dist/core/storage/node-sqlite-thread.d.ts.map +1 -0
  22. package/dist/core/storage/node-sqlite-thread.js +326 -0
  23. package/dist/core/storage/node-sqlite-thread.js.map +1 -0
  24. package/dist/core/storage/node-sqlite.d.ts.map +1 -1
  25. package/dist/core/storage/node-sqlite.js +230 -104
  26. package/dist/core/storage/node-sqlite.js.map +1 -1
  27. package/dist/core/tasks/agent-panel-source.d.ts +5 -0
  28. package/dist/core/tasks/agent-panel-source.d.ts.map +1 -1
  29. package/dist/core/tasks/agent-panel-source.js +1 -1
  30. package/dist/core/tasks/agent-panel-source.js.map +1 -1
  31. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts +8 -1
  32. package/dist/modes/interactive/agent-view/agent-view-bridge.d.ts.map +1 -1
  33. package/dist/modes/interactive/agent-view/agent-view-bridge.js.map +1 -1
  34. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts +11 -5
  35. package/dist/modes/interactive/agent-view/agent-view-switcher.d.ts.map +1 -1
  36. package/dist/modes/interactive/agent-view/agent-view-switcher.js +17 -5
  37. package/dist/modes/interactive/agent-view/agent-view-switcher.js.map +1 -1
  38. package/dist/modes/interactive/agent-view/contracts.d.ts +5 -0
  39. package/dist/modes/interactive/agent-view/contracts.d.ts.map +1 -1
  40. package/dist/modes/interactive/agent-view/contracts.js.map +1 -1
  41. package/dist/modes/interactive/agent-view/install.d.ts.map +1 -1
  42. package/dist/modes/interactive/agent-view/install.js +6 -3
  43. package/dist/modes/interactive/agent-view/install.js.map +1 -1
  44. package/dist/modes/interactive/agent-view/local-port.d.ts +5 -0
  45. package/dist/modes/interactive/agent-view/local-port.d.ts.map +1 -1
  46. package/dist/modes/interactive/agent-view/local-port.js +8 -0
  47. package/dist/modes/interactive/agent-view/local-port.js.map +1 -1
  48. package/dist/modes/interactive/agent-view/remote-port.d.ts +4 -1
  49. package/dist/modes/interactive/agent-view/remote-port.d.ts.map +1 -1
  50. package/dist/modes/interactive/agent-view/remote-port.js +22 -8
  51. package/dist/modes/interactive/agent-view/remote-port.js.map +1 -1
  52. package/dist/modes/interactive/agent-view/transcript-slot.d.ts +9 -0
  53. package/dist/modes/interactive/agent-view/transcript-slot.d.ts.map +1 -1
  54. package/dist/modes/interactive/agent-view/transcript-slot.js +141 -1
  55. package/dist/modes/interactive/agent-view/transcript-slot.js.map +1 -1
  56. package/dist/modes/interactive/components/agent-panel.d.ts +6 -0
  57. package/dist/modes/interactive/components/agent-panel.d.ts.map +1 -1
  58. package/dist/modes/interactive/components/agent-panel.js +40 -10
  59. package/dist/modes/interactive/components/agent-panel.js.map +1 -1
  60. package/dist/modes/interactive/components/atomic-working-status.d.ts +15 -0
  61. package/dist/modes/interactive/components/atomic-working-status.d.ts.map +1 -1
  62. package/dist/modes/interactive/components/atomic-working-status.js +51 -3
  63. package/dist/modes/interactive/components/atomic-working-status.js.map +1 -1
  64. package/dist/modes/interactive/components/bash-execution.d.ts +2 -0
  65. package/dist/modes/interactive/components/bash-execution.d.ts.map +1 -1
  66. package/dist/modes/interactive/components/bash-execution.js +5 -1
  67. package/dist/modes/interactive/components/bash-execution.js.map +1 -1
  68. package/dist/modes/interactive/components/branch-summary-message.d.ts +2 -0
  69. package/dist/modes/interactive/components/branch-summary-message.d.ts.map +1 -1
  70. package/dist/modes/interactive/components/branch-summary-message.js +5 -1
  71. package/dist/modes/interactive/components/branch-summary-message.js.map +1 -1
  72. package/dist/modes/interactive/components/chat-message-renderer.d.ts +2 -0
  73. package/dist/modes/interactive/components/chat-message-renderer.d.ts.map +1 -1
  74. package/dist/modes/interactive/components/chat-message-renderer.js +17 -6
  75. package/dist/modes/interactive/components/chat-message-renderer.js.map +1 -1
  76. package/dist/modes/interactive/components/chat-session-host-events.d.ts.map +1 -1
  77. package/dist/modes/interactive/components/chat-session-host-events.js +35 -4
  78. package/dist/modes/interactive/components/chat-session-host-events.js.map +1 -1
  79. package/dist/modes/interactive/components/chat-session-host-rendering.d.ts.map +1 -1
  80. package/dist/modes/interactive/components/chat-session-host-rendering.js +70 -13
  81. package/dist/modes/interactive/components/chat-session-host-rendering.js.map +1 -1
  82. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts +7 -0
  83. package/dist/modes/interactive/components/chat-session-host-runtime.d.ts.map +1 -1
  84. package/dist/modes/interactive/components/chat-session-host-runtime.js +25 -4
  85. package/dist/modes/interactive/components/chat-session-host-runtime.js.map +1 -1
  86. package/dist/modes/interactive/components/chat-session-host-state.d.ts +41 -1
  87. package/dist/modes/interactive/components/chat-session-host-state.d.ts.map +1 -1
  88. package/dist/modes/interactive/components/chat-session-host-state.js +24 -3
  89. package/dist/modes/interactive/components/chat-session-host-state.js.map +1 -1
  90. package/dist/modes/interactive/components/chat-session-host-steering.d.ts.map +1 -1
  91. package/dist/modes/interactive/components/chat-session-host-steering.js +2 -1
  92. package/dist/modes/interactive/components/chat-session-host-steering.js.map +1 -1
  93. package/dist/modes/interactive/components/chat-session-host.d.ts +13 -1
  94. package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
  95. package/dist/modes/interactive/components/chat-session-host.js +20 -2
  96. package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
  97. package/dist/modes/interactive/components/chat-transcript.d.ts +15 -0
  98. package/dist/modes/interactive/components/chat-transcript.d.ts.map +1 -1
  99. package/dist/modes/interactive/components/chat-transcript.js +14 -1
  100. package/dist/modes/interactive/components/chat-transcript.js.map +1 -1
  101. package/dist/modes/interactive/components/compaction-boundary-message.d.ts +2 -0
  102. package/dist/modes/interactive/components/compaction-boundary-message.d.ts.map +1 -1
  103. package/dist/modes/interactive/components/compaction-boundary-message.js +5 -1
  104. package/dist/modes/interactive/components/compaction-boundary-message.js.map +1 -1
  105. package/dist/modes/interactive/components/custom-entry.d.ts +2 -0
  106. package/dist/modes/interactive/components/custom-entry.d.ts.map +1 -1
  107. package/dist/modes/interactive/components/custom-entry.js +5 -1
  108. package/dist/modes/interactive/components/custom-entry.js.map +1 -1
  109. package/dist/modes/interactive/components/custom-message.d.ts +2 -0
  110. package/dist/modes/interactive/components/custom-message.d.ts.map +1 -1
  111. package/dist/modes/interactive/components/custom-message.js +5 -1
  112. package/dist/modes/interactive/components/custom-message.js.map +1 -1
  113. package/dist/modes/interactive/components/model-column.d.ts +96 -0
  114. package/dist/modes/interactive/components/model-column.d.ts.map +1 -0
  115. package/dist/modes/interactive/components/model-column.js +207 -0
  116. package/dist/modes/interactive/components/model-column.js.map +1 -0
  117. package/dist/modes/interactive/components/prompt-slot.d.ts +73 -0
  118. package/dist/modes/interactive/components/prompt-slot.d.ts.map +1 -0
  119. package/dist/modes/interactive/components/prompt-slot.js +201 -0
  120. package/dist/modes/interactive/components/prompt-slot.js.map +1 -0
  121. package/dist/modes/interactive/components/queued-messages-view.d.ts +6 -3
  122. package/dist/modes/interactive/components/queued-messages-view.d.ts.map +1 -1
  123. package/dist/modes/interactive/components/queued-messages-view.js +7 -4
  124. package/dist/modes/interactive/components/queued-messages-view.js.map +1 -1
  125. package/dist/modes/interactive/components/session-selector.d.ts +2 -0
  126. package/dist/modes/interactive/components/session-selector.d.ts.map +1 -1
  127. package/dist/modes/interactive/components/session-selector.js +4 -0
  128. package/dist/modes/interactive/components/session-selector.js.map +1 -1
  129. package/dist/modes/interactive/components/skill-invocation-message.d.ts +2 -0
  130. package/dist/modes/interactive/components/skill-invocation-message.d.ts.map +1 -1
  131. package/dist/modes/interactive/components/skill-invocation-message.js +5 -1
  132. package/dist/modes/interactive/components/skill-invocation-message.js.map +1 -1
  133. package/dist/modes/interactive/components/task-board.d.ts +12 -3
  134. package/dist/modes/interactive/components/task-board.d.ts.map +1 -1
  135. package/dist/modes/interactive/components/task-board.js +33 -17
  136. package/dist/modes/interactive/components/task-board.js.map +1 -1
  137. package/dist/modes/interactive/components/task-inspector.d.ts +6 -1
  138. package/dist/modes/interactive/components/task-inspector.d.ts.map +1 -1
  139. package/dist/modes/interactive/components/task-inspector.js +27 -7
  140. package/dist/modes/interactive/components/task-inspector.js.map +1 -1
  141. package/dist/modes/interactive/components/task-row.d.ts +4 -0
  142. package/dist/modes/interactive/components/task-row.d.ts.map +1 -1
  143. package/dist/modes/interactive/components/task-row.js +7 -1
  144. package/dist/modes/interactive/components/task-row.js.map +1 -1
  145. package/dist/modes/interactive/components/task-transcript-page.d.ts +5 -0
  146. package/dist/modes/interactive/components/task-transcript-page.d.ts.map +1 -1
  147. package/dist/modes/interactive/components/task-transcript-page.js +25 -0
  148. package/dist/modes/interactive/components/task-transcript-page.js.map +1 -1
  149. package/dist/modes/interactive/components/tool-execution.d.ts +7 -0
  150. package/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  151. package/dist/modes/interactive/components/tool-execution.js +19 -2
  152. package/dist/modes/interactive/components/tool-execution.js.map +1 -1
  153. package/dist/modes/interactive/components/tool-group-tracker.d.ts +20 -3
  154. package/dist/modes/interactive/components/tool-group-tracker.d.ts.map +1 -1
  155. package/dist/modes/interactive/components/tool-group-tracker.js +34 -7
  156. package/dist/modes/interactive/components/tool-group-tracker.js.map +1 -1
  157. package/dist/modes/interactive/components/transcript-block-clicks.d.ts +14 -2
  158. package/dist/modes/interactive/components/transcript-block-clicks.d.ts.map +1 -1
  159. package/dist/modes/interactive/components/transcript-block-clicks.js +23 -2
  160. package/dist/modes/interactive/components/transcript-block-clicks.js.map +1 -1
  161. package/dist/modes/interactive/interactive-agent-events.js +10 -2
  162. package/dist/modes/interactive/interactive-agent-events.js.map +1 -1
  163. package/dist/modes/interactive/interactive-extension-runtime.d.ts +12 -1
  164. package/dist/modes/interactive/interactive-extension-runtime.d.ts.map +1 -1
  165. package/dist/modes/interactive/interactive-extension-runtime.js +37 -5
  166. package/dist/modes/interactive/interactive-extension-runtime.js.map +1 -1
  167. package/dist/modes/interactive/interactive-input-handling.d.ts.map +1 -1
  168. package/dist/modes/interactive/interactive-input-handling.js +70 -46
  169. package/dist/modes/interactive/interactive-input-handling.js.map +1 -1
  170. package/dist/modes/interactive/interactive-mode-base.d.ts.map +1 -1
  171. package/dist/modes/interactive/interactive-mode-base.js +7 -1
  172. package/dist/modes/interactive/interactive-mode-base.js.map +1 -1
  173. package/dist/modes/interactive/interactive-prompt-turn.js +17 -9
  174. package/dist/modes/interactive/interactive-prompt-turn.js.map +1 -1
  175. package/dist/modes/interactive/interactive-queueing.d.ts.map +1 -1
  176. package/dist/modes/interactive/interactive-queueing.js +2 -1
  177. package/dist/modes/interactive/interactive-queueing.js.map +1 -1
  178. package/dist/modes/interactive/interactive-render-chat.d.ts +18 -1
  179. package/dist/modes/interactive/interactive-render-chat.d.ts.map +1 -1
  180. package/dist/modes/interactive/interactive-render-chat.js +90 -10
  181. package/dist/modes/interactive/interactive-render-chat.js.map +1 -1
  182. package/dist/modes/interactive/interactive-session-routing.js +2 -0
  183. package/dist/modes/interactive/interactive-session-routing.js.map +1 -1
  184. package/dist/modes/interactive/interactive-task-projection.js +2 -2
  185. package/dist/modes/interactive/interactive-task-projection.js.map +1 -1
  186. package/dist/modes/interactive/screen-hold.d.ts +41 -0
  187. package/dist/modes/interactive/screen-hold.d.ts.map +1 -0
  188. package/dist/modes/interactive/screen-hold.js +80 -0
  189. package/dist/modes/interactive/screen-hold.js.map +1 -0
  190. package/dist/modes/interactive/started-run-echo.d.ts +66 -0
  191. package/dist/modes/interactive/started-run-echo.d.ts.map +1 -0
  192. package/dist/modes/interactive/started-run-echo.js +75 -0
  193. package/dist/modes/interactive/started-run-echo.js.map +1 -0
  194. package/dist/modes/interactive-engine/engine-custom-ui.d.ts +1 -0
  195. package/dist/modes/interactive-engine/engine-custom-ui.d.ts.map +1 -1
  196. package/dist/modes/interactive-engine/engine-custom-ui.js +25 -1
  197. package/dist/modes/interactive-engine/engine-custom-ui.js.map +1 -1
  198. package/dist/modes/interactive-engine/engine-quit-intent.d.ts.map +1 -1
  199. package/dist/modes/interactive-engine/engine-quit-intent.js +3 -0
  200. package/dist/modes/interactive-engine/engine-quit-intent.js.map +1 -1
  201. package/dist/modes/interactive-engine/protocol.d.ts +5 -0
  202. package/dist/modes/interactive-engine/protocol.d.ts.map +1 -1
  203. package/dist/modes/interactive-engine/protocol.js +7 -1
  204. package/dist/modes/interactive-engine/protocol.js.map +1 -1
  205. package/dist/modes/interactive-engine/remote-component.d.ts +10 -2
  206. package/dist/modes/interactive-engine/remote-component.d.ts.map +1 -1
  207. package/dist/modes/interactive-engine/remote-component.js +19 -2
  208. package/dist/modes/interactive-engine/remote-component.js.map +1 -1
  209. package/dist/modes/interactive-engine/remote-renderer.d.ts +10 -0
  210. package/dist/modes/interactive-engine/remote-renderer.d.ts.map +1 -1
  211. package/dist/modes/interactive-engine/remote-renderer.js +24 -4
  212. package/dist/modes/interactive-engine/remote-renderer.js.map +1 -1
  213. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts +50 -0
  214. package/dist/modes/interactive-engine/transcript-frame-layout.d.ts.map +1 -0
  215. package/dist/modes/interactive-engine/transcript-frame-layout.js +95 -0
  216. package/dist/modes/interactive-engine/transcript-frame-layout.js.map +1 -0
  217. package/dist/modes/rpc/agent-panel-bridge.d.ts.map +1 -1
  218. package/dist/modes/rpc/agent-panel-bridge.js +16 -0
  219. package/dist/modes/rpc/agent-panel-bridge.js.map +1 -1
  220. package/dist/modes/rpc/agent-view-engine-registry.d.ts.map +1 -1
  221. package/dist/modes/rpc/agent-view-engine-registry.js +36 -1
  222. package/dist/modes/rpc/agent-view-engine-registry.js.map +1 -1
  223. package/dist/modes/rpc/agent-view-rpc-panel.d.ts.map +1 -1
  224. package/dist/modes/rpc/agent-view-rpc-panel.js +5 -1
  225. package/dist/modes/rpc/agent-view-rpc-panel.js.map +1 -1
  226. package/dist/modes/rpc/task-ui-bridge.js +1 -1
  227. package/dist/modes/rpc/task-ui-bridge.js.map +1 -1
  228. package/docs/background-tasks.md +1 -1
  229. package/docs/development.md +2 -0
  230. package/docs/extensions/authoring.md +1 -1
  231. package/docs/keybindings.md +2 -2
  232. package/docs/storage.md +1 -0
  233. package/npm-shrinkwrap.json +49 -49
  234. package/package.json +6 -6
@@ -1,5 +1,5 @@
1
1
  import type { TaskId } from "../../../core/tasks/contracts.js";
2
- import type { AgentViewBridge } from "./agent-view-bridge.ts";
2
+ import type { AgentViewBridge, AgentViewRequestOptions } from "./agent-view-bridge.ts";
3
3
  import { type AgentViewChange, type AgentViewPort, type ViewedTarget } from "./contracts.ts";
4
4
  /** How a pending request ended: its subagent was shown, could not be, or another request replaced it. */
5
5
  export type PendingOutcome = "shown" | "failed" | "superseded";
@@ -11,6 +11,8 @@ export type PendingListener = (pending: TaskId | undefined, settled?: {
11
11
  export declare const NOT_SHOWN = "That subagent can no longer be shown.";
12
12
  /** Opens the port of the subagent `taskId` is an attempt of; undefined when there is no such subagent to show. */
13
13
  export type OpenAgentViewPort = (taskId: TaskId) => Promise<AgentViewPort | undefined>;
14
+ /** Keeps what the screen shows below its transcript as painted until the answer runs; answers that release. */
15
+ export type HoldAgentViewScreen = () => () => void;
14
16
  /**
15
17
  * What the single chat screen shows. Every part that differs while a subagent is shown reads `viewed` at the moment it
16
18
  * acts, and listens to `onChange`. While main is shown nothing here runs, so the main chat is exactly as before.
@@ -27,7 +29,10 @@ export declare class AgentViewSwitcher implements AgentViewBridge {
27
29
  private pending;
28
30
  private readonly openPort;
29
31
  private readonly notify;
30
- constructor(openPort: OpenAgentViewPort, notify: (message: string) => void);
32
+ private readonly holdScreen;
33
+ /** Releases the screen held for the pending request, when that request asked to keep it. */
34
+ private releaseScreen;
35
+ constructor(openPort: OpenAgentViewPort, notify: (message: string) => void, holdScreen?: HoldAgentViewScreen);
31
36
  get viewed(): ViewedTarget;
32
37
  /**
33
38
  * The subagent a request is opening, from the request until it is shown or fails. What the reader types meanwhile
@@ -42,13 +47,14 @@ export declare class AgentViewSwitcher implements AgentViewBridge {
42
47
  viewedTaskId(): TaskId | undefined;
43
48
  /**
44
49
  * Show the subagent `taskId` is an attempt of, or main when undefined. The latest request wins: a port opened for
45
- * a request a later one superseded is released unused. Answers whether the screen shows what was asked.
50
+ * a request a later one superseded is released unused. Answers whether the screen shows what was asked. With
51
+ * `keepScreen`, what the screen shows below its transcript stays as painted while the request is pending.
46
52
  */
47
- view(taskId: TaskId | undefined): Promise<boolean>;
53
+ view(taskId: TaskId | undefined, options?: AgentViewRequestOptions): Promise<boolean>;
48
54
  /** Esc while a subagent is opening: it is not shown, and the screen keeps what it shows. */
49
55
  cancelPending(): void;
50
56
  private open;
51
- requestView(taskId: TaskId | undefined): void;
57
+ requestView(taskId: TaskId | undefined, options?: AgentViewRequestOptions): void;
52
58
  /** Listeners run in registration order, synchronously, once `viewed` changed. */
53
59
  onChange(listener: (change: AgentViewChange) => void): () => void;
54
60
  subscribe(listener: () => void): () => void;
@@ -1 +1 @@
1
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AM,IAAI,YAAY,CAEzB;IAED;;;OAGG;IACH,IAAI,aAAa,IAAI,MAAM,GAAG,SAAS,CAEtC;IAED;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,IAAI,CAG/C;IAED,YAAY,IAAI,MAAM,GAAG,SAAS,CAEjC;IAED;;;;OAIG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,OAAO,CAAC,OAAO,CAAC,CAsB1F;IAED,4FAA4F;IAC5F,aAAa,IAAI,IAAI,CAIpB;YAEa,IAAI;IAgClB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,CAAC,EAAE,uBAAuB,GAAG,IAAI,CAI/E;IAED,iFAAiF;IACjF,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,KAAK,IAAI,GAAG,MAAM,IAAI,CAGhE;IAED,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAG1C;IAED,oHAAoH;IACpH,KAAK,CAAC,OAAO,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,UAAU,GAAG,IAAI,CAIxE;IAED,0EAA0E;IAC1E,OAAO,CAAC,UAAU;IAmBlB,OAAO,IAAI,IAAI,CAOd;IAED,OAAO,CAAC,IAAI;CAkCZ"}
@@ -17,9 +17,13 @@ export class AgentViewSwitcher {
17
17
  pending;
18
18
  openPort;
19
19
  notify;
20
- constructor(openPort, notify) {
20
+ holdScreen;
21
+ /** Releases the screen held for the pending request, when that request asked to keep it. */
22
+ releaseScreen;
23
+ constructor(openPort, notify, holdScreen) {
21
24
  this.openPort = openPort;
22
25
  this.notify = notify;
26
+ this.holdScreen = holdScreen;
23
27
  }
24
28
  get viewed() {
25
29
  return this.current;
@@ -44,9 +48,10 @@ export class AgentViewSwitcher {
44
48
  }
45
49
  /**
46
50
  * Show the subagent `taskId` is an attempt of, or main when undefined. The latest request wins: a port opened for
47
- * a request a later one superseded is released unused. Answers whether the screen shows what was asked.
51
+ * a request a later one superseded is released unused. Answers whether the screen shows what was asked. With
52
+ * `keepScreen`, what the screen shows below its transcript stays as painted while the request is pending.
48
53
  */
49
- async view(taskId) {
54
+ async view(taskId, options) {
50
55
  if (this.disposed)
51
56
  return false;
52
57
  const request = ++this.request;
@@ -61,6 +66,8 @@ export class AgentViewSwitcher {
61
66
  return true;
62
67
  }
63
68
  this.setPending(taskId, "superseded");
69
+ if (options?.keepScreen === true && this.releaseScreen === undefined)
70
+ this.releaseScreen = this.holdScreen?.();
64
71
  let landed = false;
65
72
  try {
66
73
  landed = await this.open(request, taskId);
@@ -111,8 +118,8 @@ export class AgentViewSwitcher {
111
118
  this.show({ kind: "agent", port });
112
119
  return true;
113
120
  }
114
- requestView(taskId) {
115
- void this.view(taskId).catch((error) => this.notify(error instanceof Error ? error.message : String(error)));
121
+ requestView(taskId, options) {
122
+ void this.view(taskId, options).catch((error) => this.notify(error instanceof Error ? error.message : String(error)));
116
123
  }
117
124
  /** Listeners run in registration order, synchronously, once `viewed` changed. */
118
125
  onChange(listener) {
@@ -135,6 +142,10 @@ export class AgentViewSwitcher {
135
142
  if (previous === taskId)
136
143
  return;
137
144
  this.pending = taskId;
145
+ // The screen held for the request that stops pending is shown live again once the listeners ran: a request
146
+ // that landed has its subagent laid out by then, so the next paint shows it with its prompt and panel.
147
+ const releaseScreen = this.releaseScreen;
148
+ this.releaseScreen = undefined;
138
149
  const settled = previous === undefined ? undefined : { taskId: previous, outcome };
139
150
  for (const listener of [...this.pendingListeners]) {
140
151
  try {
@@ -144,6 +155,7 @@ export class AgentViewSwitcher {
144
155
  // A listener's failure must not stop the others.
145
156
  }
146
157
  }
158
+ releaseScreen?.();
147
159
  }
148
160
  dispose() {
149
161
  if (this.disposed)
@@ -1 +1 @@
1
- {"version":3,"file":"agent-view-switcher.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/agent-view-switcher.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,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI;oBAAE,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAoB,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;QAC7C,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC;YAClD,IAAI,CAAC;gBACJ,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;QACD,+FAA+F;QAC/F,WAAW,EAAE,EAAE,CAAC;IACjB,CAAC;CACD","sourcesContent":["import type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { AgentViewBridge } from \"./agent-view-bridge.ts\";\nimport { type AgentViewChange, type AgentViewPort, VIEWING_MAIN, type ViewedTarget } from \"./contracts.ts\";\n\n/** How a pending request ended: its subagent was shown, could not be, or another request replaced it. */\nexport type PendingOutcome = \"shown\" | \"failed\" | \"superseded\";\n\nexport type PendingListener = (\n\tpending: TaskId | undefined,\n\tsettled?: { readonly taskId: TaskId; readonly outcome: PendingOutcome },\n) => void;\n\n/** Why the screen still shows what it showed after a request for a subagent. */\nexport const NOT_SHOWN = \"That subagent can no longer be shown.\";\n\n/** Opens the port of the subagent `taskId` is an attempt of; undefined when there is no such subagent to show. */\nexport type OpenAgentViewPort = (taskId: TaskId) => Promise<AgentViewPort | undefined>;\n\n/**\n * What the single chat screen shows. Every part that differs while a subagent is shown reads `viewed` at the moment it\n * acts, and listens to `onChange`. While main is shown nothing here runs, so the main chat is exactly as before.\n */\nexport class AgentViewSwitcher implements AgentViewBridge {\n\tprivate current: ViewedTarget = VIEWING_MAIN;\n\tprivate releaseCurrent: (() => void) | undefined;\n\tprivate unwatchCurrent: (() => void) | undefined;\n\tprivate request = 0;\n\tprivate disposed = false;\n\tprivate readonly changeListeners = new Set<(change: AgentViewChange) => void>();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly pendingListeners = new Set<PendingListener>();\n\tprivate pending: TaskId | undefined;\n\tprivate readonly openPort: OpenAgentViewPort;\n\tprivate readonly notify: (message: string) => void;\n\n\tconstructor(openPort: OpenAgentViewPort, notify: (message: string) => void) {\n\t\tthis.openPort = openPort;\n\t\tthis.notify = notify;\n\t}\n\n\tget viewed(): ViewedTarget {\n\t\treturn this.current;\n\t}\n\n\t/**\n\t * The subagent a request is opening, from the request until it is shown or fails. What the reader types meanwhile\n\t * is meant for it, so the prompt holds it back until then.\n\t */\n\tget pendingTaskId(): TaskId | undefined {\n\t\treturn this.pending;\n\t}\n\n\t/**\n\t * Called whenever the pending request changes: `pending` is the one opening now, and `settled` the one that just\n\t * stopped pending, with how it ended.\n\t */\n\tonPending(listener: PendingListener): () => void {\n\t\tthis.pendingListeners.add(listener);\n\t\treturn () => this.pendingListeners.delete(listener);\n\t}\n\n\tviewedTaskId(): TaskId | undefined {\n\t\treturn this.current.kind === \"agent\" ? this.current.port.status().taskId : undefined;\n\t}\n\n\t/**\n\t * Show the subagent `taskId` is an attempt of, or main when undefined. The latest request wins: a port opened for\n\t * a request a later one superseded is released unused. Answers whether the screen shows what was asked.\n\t */\n\tasync view(taskId: TaskId | undefined): Promise<boolean> {\n\t\tif (this.disposed) return false;\n\t\tconst request = ++this.request;\n\t\tif (taskId === undefined) {\n\t\t\tthis.setPending(undefined, \"superseded\");\n\t\t\tthis.show(VIEWING_MAIN);\n\t\t\treturn true;\n\t\t}\n\t\tconst shown = this.current;\n\t\tif (shown.kind === \"agent\" && shown.port.status().taskId === taskId) {\n\t\t\tthis.setPending(undefined, \"superseded\");\n\t\t\treturn true;\n\t\t}\n\t\tthis.setPending(taskId, \"superseded\");\n\t\tlet landed = false;\n\t\ttry {\n\t\t\tlanded = await this.open(request, taskId);\n\t\t\treturn landed;\n\t\t} finally {\n\t\t\tif (request === this.request) this.setPending(undefined, landed ? \"shown\" : \"failed\");\n\t\t}\n\t}\n\n\t/** Esc while a subagent is opening: it is not shown, and the screen keeps what it shows. */\n\tcancelPending(): void {\n\t\tif (this.pending === undefined) return;\n\t\tthis.request++;\n\t\tthis.setPending(undefined, \"superseded\");\n\t}\n\n\tprivate async open(request: number, taskId: TaskId): Promise<boolean> {\n\t\tlet port: AgentViewPort | undefined;\n\t\ttry {\n\t\t\tport = await this.openPort(taskId);\n\t\t} catch (error) {\n\t\t\tif (request === this.request && !this.disposed)\n\t\t\t\tthis.notify(error instanceof Error ? error.message : String(error));\n\t\t\treturn false;\n\t\t}\n\t\tif (port === undefined) {\n\t\t\tif (request === this.request && !this.disposed) this.notify(NOT_SHOWN);\n\t\t\treturn false;\n\t\t}\n\t\tif (request !== this.request || this.disposed) {\n\t\t\t// Superseded: the port was never shown. Retaining and releasing it once disposes it.\n\t\t\tport.retain()();\n\t\t\treturn false;\n\t\t}\n\t\tconst now = this.current;\n\t\tif (now.kind === \"agent\" && now.port.agentKey === port.agentKey) {\n\t\t\tport.retain()();\n\t\t\treturn true;\n\t\t}\n\t\tif (port.status().gone) {\n\t\t\tport.retain()();\n\t\t\tthis.notify(NOT_SHOWN);\n\t\t\treturn false;\n\t\t}\n\t\tthis.show({ kind: \"agent\", port });\n\t\treturn true;\n\t}\n\n\trequestView(taskId: TaskId | undefined): void {\n\t\tvoid this.view(taskId).catch((error: unknown) =>\n\t\t\tthis.notify(error instanceof Error ? error.message : String(error)),\n\t\t);\n\t}\n\n\t/** Listeners run in registration order, synchronously, once `viewed` changed. */\n\tonChange(listener: (change: AgentViewChange) => void): () => void {\n\t\tthis.changeListeners.add(listener);\n\t\treturn () => this.changeListeners.delete(listener);\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\t/** The engine generation ended, the main session was replaced, or the host shuts down: show main, release ports. */\n\treset(_reason: \"generation-lost\" | \"session-replaced\" | \"shutdown\"): void {\n\t\tthis.request++;\n\t\tthis.setPending(undefined, \"superseded\");\n\t\tthis.show(VIEWING_MAIN);\n\t}\n\n\t/** `outcome` is how the request pending until now ended, when one was. */\n\tprivate setPending(taskId: TaskId | undefined, outcome: PendingOutcome): void {\n\t\tconst previous = this.pending;\n\t\tif (previous === taskId) return;\n\t\tthis.pending = taskId;\n\t\tconst settled = previous === undefined ? undefined : { taskId: previous, outcome };\n\t\tfor (const listener of [...this.pendingListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener(taskId, settled);\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\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.reset(\"shutdown\");\n\t\tthis.disposed = true;\n\t\tthis.changeListeners.clear();\n\t\tthis.listeners.clear();\n\t\tthis.pendingListeners.clear();\n\t}\n\n\tprivate show(to: ViewedTarget): void {\n\t\tconst from = this.current;\n\t\tif (from === to || (from.kind === \"main\" && to.kind === \"main\")) return;\n\t\tconst releaseFrom = this.releaseCurrent;\n\t\tthis.unwatchCurrent?.();\n\t\tthis.unwatchCurrent = undefined;\n\t\tthis.releaseCurrent = undefined;\n\t\tthis.current = to;\n\t\tif (to.kind === \"agent\") {\n\t\t\tthis.releaseCurrent = to.port.retain();\n\t\t\tthis.unwatchCurrent = to.port.subscribe(() => {\n\t\t\t\t// A shown subagent that is gone gives the screen back to main in the same tick. A newer request, still\n\t\t\t\t// opening, is the reader's and still lands.\n\t\t\t\tif (this.current === to && to.port.status().gone) this.show(VIEWING_MAIN);\n\t\t\t});\n\t\t}\n\t\tconst change: AgentViewChange = { from, to };\n\t\tfor (const listener of [...this.changeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener(change);\n\t\t\t} catch (error) {\n\t\t\t\tthis.notify(error instanceof Error ? error.message : String(error));\n\t\t\t}\n\t\t}\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\t// Released after the listeners, so one that still has messages on their way to it can keep it.\n\t\treleaseFrom?.();\n\t}\n}\n"]}
1
+ {"version":3,"file":"agent-view-switcher.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/agent-view-switcher.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4C,YAAY,EAAqB,MAAM,gBAAgB,CAAC;AAU3G,gFAAgF;AAChF,MAAM,CAAC,MAAM,SAAS,GAAG,uCAAuC,CAAC;AAQjE;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACrB,OAAO,GAAiB,YAAY,CAAC;IACrC,cAAc,CAA2B;IACzC,cAAc,CAA2B;IACzC,OAAO,GAAG,CAAC,CAAC;IACZ,QAAQ,GAAG,KAAK,CAAC;IACR,eAAe,GAAG,IAAI,GAAG,EAAqC,CAAC;IAC/D,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAClC,gBAAgB,GAAG,IAAI,GAAG,EAAmB,CAAC;IACvD,OAAO,CAAqB;IACnB,QAAQ,CAAoB;IAC5B,MAAM,CAA4B;IAClC,UAAU,CAAkC;IAC7D,4FAA4F;IACpF,aAAa,CAA2B;IAEhD,YAAY,QAA2B,EAAE,MAAiC,EAAE,UAAgC;QAC3G,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC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,CAAC;YAClD,IAAI,CAAC;gBACJ,QAAQ,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAChB,IAAI,CAAC,MAAM,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;YACrE,CAAC;QACF,CAAC;QACD,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC;gBACJ,QAAQ,EAAE,CAAC;YACZ,CAAC;YAAC,MAAM,CAAC;gBACR,iDAAiD;YAClD,CAAC;QACF,CAAC;QACD,+FAA+F;QAC/F,WAAW,EAAE,EAAE,CAAC;IACjB,CAAC;CACD","sourcesContent":["import type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { AgentViewBridge, AgentViewRequestOptions } from \"./agent-view-bridge.ts\";\nimport { type AgentViewChange, type AgentViewPort, VIEWING_MAIN, type ViewedTarget } from \"./contracts.ts\";\n\n/** How a pending request ended: its subagent was shown, could not be, or another request replaced it. */\nexport type PendingOutcome = \"shown\" | \"failed\" | \"superseded\";\n\nexport type PendingListener = (\n\tpending: TaskId | undefined,\n\tsettled?: { readonly taskId: TaskId; readonly outcome: PendingOutcome },\n) => void;\n\n/** Why the screen still shows what it showed after a request for a subagent. */\nexport const NOT_SHOWN = \"That subagent can no longer be shown.\";\n\n/** Opens the port of the subagent `taskId` is an attempt of; undefined when there is no such subagent to show. */\nexport type OpenAgentViewPort = (taskId: TaskId) => Promise<AgentViewPort | undefined>;\n\n/** Keeps what the screen shows below its transcript as painted until the answer runs; answers that release. */\nexport type HoldAgentViewScreen = () => () => void;\n\n/**\n * What the single chat screen shows. Every part that differs while a subagent is shown reads `viewed` at the moment it\n * acts, and listens to `onChange`. While main is shown nothing here runs, so the main chat is exactly as before.\n */\nexport class AgentViewSwitcher implements AgentViewBridge {\n\tprivate current: ViewedTarget = VIEWING_MAIN;\n\tprivate releaseCurrent: (() => void) | undefined;\n\tprivate unwatchCurrent: (() => void) | undefined;\n\tprivate request = 0;\n\tprivate disposed = false;\n\tprivate readonly changeListeners = new Set<(change: AgentViewChange) => void>();\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate readonly pendingListeners = new Set<PendingListener>();\n\tprivate pending: TaskId | undefined;\n\tprivate readonly openPort: OpenAgentViewPort;\n\tprivate readonly notify: (message: string) => void;\n\tprivate readonly holdScreen: HoldAgentViewScreen | undefined;\n\t/** Releases the screen held for the pending request, when that request asked to keep it. */\n\tprivate releaseScreen: (() => void) | undefined;\n\n\tconstructor(openPort: OpenAgentViewPort, notify: (message: string) => void, holdScreen?: HoldAgentViewScreen) {\n\t\tthis.openPort = openPort;\n\t\tthis.notify = notify;\n\t\tthis.holdScreen = holdScreen;\n\t}\n\n\tget viewed(): ViewedTarget {\n\t\treturn this.current;\n\t}\n\n\t/**\n\t * The subagent a request is opening, from the request until it is shown or fails. What the reader types meanwhile\n\t * is meant for it, so the prompt holds it back until then.\n\t */\n\tget pendingTaskId(): TaskId | undefined {\n\t\treturn this.pending;\n\t}\n\n\t/**\n\t * Called whenever the pending request changes: `pending` is the one opening now, and `settled` the one that just\n\t * stopped pending, with how it ended.\n\t */\n\tonPending(listener: PendingListener): () => void {\n\t\tthis.pendingListeners.add(listener);\n\t\treturn () => this.pendingListeners.delete(listener);\n\t}\n\n\tviewedTaskId(): TaskId | undefined {\n\t\treturn this.current.kind === \"agent\" ? this.current.port.status().taskId : undefined;\n\t}\n\n\t/**\n\t * Show the subagent `taskId` is an attempt of, or main when undefined. The latest request wins: a port opened for\n\t * a request a later one superseded is released unused. Answers whether the screen shows what was asked. With\n\t * `keepScreen`, what the screen shows below its transcript stays as painted while the request is pending.\n\t */\n\tasync view(taskId: TaskId | undefined, options?: AgentViewRequestOptions): Promise<boolean> {\n\t\tif (this.disposed) return false;\n\t\tconst request = ++this.request;\n\t\tif (taskId === undefined) {\n\t\t\tthis.setPending(undefined, \"superseded\");\n\t\t\tthis.show(VIEWING_MAIN);\n\t\t\treturn true;\n\t\t}\n\t\tconst shown = this.current;\n\t\tif (shown.kind === \"agent\" && shown.port.status().taskId === taskId) {\n\t\t\tthis.setPending(undefined, \"superseded\");\n\t\t\treturn true;\n\t\t}\n\t\tthis.setPending(taskId, \"superseded\");\n\t\tif (options?.keepScreen === true && this.releaseScreen === undefined) this.releaseScreen = this.holdScreen?.();\n\t\tlet landed = false;\n\t\ttry {\n\t\t\tlanded = await this.open(request, taskId);\n\t\t\treturn landed;\n\t\t} finally {\n\t\t\tif (request === this.request) this.setPending(undefined, landed ? \"shown\" : \"failed\");\n\t\t}\n\t}\n\n\t/** Esc while a subagent is opening: it is not shown, and the screen keeps what it shows. */\n\tcancelPending(): void {\n\t\tif (this.pending === undefined) return;\n\t\tthis.request++;\n\t\tthis.setPending(undefined, \"superseded\");\n\t}\n\n\tprivate async open(request: number, taskId: TaskId): Promise<boolean> {\n\t\tlet port: AgentViewPort | undefined;\n\t\ttry {\n\t\t\tport = await this.openPort(taskId);\n\t\t} catch (error) {\n\t\t\tif (request === this.request && !this.disposed)\n\t\t\t\tthis.notify(error instanceof Error ? error.message : String(error));\n\t\t\treturn false;\n\t\t}\n\t\tif (port === undefined) {\n\t\t\tif (request === this.request && !this.disposed) this.notify(NOT_SHOWN);\n\t\t\treturn false;\n\t\t}\n\t\tif (request !== this.request || this.disposed) {\n\t\t\t// Superseded: the port was never shown. Retaining and releasing it once disposes it.\n\t\t\tport.retain()();\n\t\t\treturn false;\n\t\t}\n\t\tconst now = this.current;\n\t\tif (now.kind === \"agent\" && now.port.agentKey === port.agentKey) {\n\t\t\tport.retain()();\n\t\t\treturn true;\n\t\t}\n\t\tif (port.status().gone) {\n\t\t\tport.retain()();\n\t\t\tthis.notify(NOT_SHOWN);\n\t\t\treturn false;\n\t\t}\n\t\tthis.show({ kind: \"agent\", port });\n\t\treturn true;\n\t}\n\n\trequestView(taskId: TaskId | undefined, options?: AgentViewRequestOptions): void {\n\t\tvoid this.view(taskId, options).catch((error: unknown) =>\n\t\t\tthis.notify(error instanceof Error ? error.message : String(error)),\n\t\t);\n\t}\n\n\t/** Listeners run in registration order, synchronously, once `viewed` changed. */\n\tonChange(listener: (change: AgentViewChange) => void): () => void {\n\t\tthis.changeListeners.add(listener);\n\t\treturn () => this.changeListeners.delete(listener);\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\t/** The engine generation ended, the main session was replaced, or the host shuts down: show main, release ports. */\n\treset(_reason: \"generation-lost\" | \"session-replaced\" | \"shutdown\"): void {\n\t\tthis.request++;\n\t\tthis.setPending(undefined, \"superseded\");\n\t\tthis.show(VIEWING_MAIN);\n\t}\n\n\t/** `outcome` is how the request pending until now ended, when one was. */\n\tprivate setPending(taskId: TaskId | undefined, outcome: PendingOutcome): void {\n\t\tconst previous = this.pending;\n\t\tif (previous === taskId) return;\n\t\tthis.pending = taskId;\n\t\t// The screen held for the request that stops pending is shown live again once the listeners ran: a request\n\t\t// that landed has its subagent laid out by then, so the next paint shows it with its prompt and panel.\n\t\tconst releaseScreen = this.releaseScreen;\n\t\tthis.releaseScreen = undefined;\n\t\tconst settled = previous === undefined ? undefined : { taskId: previous, outcome };\n\t\tfor (const listener of [...this.pendingListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener(taskId, settled);\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\treleaseScreen?.();\n\t}\n\n\tdispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.reset(\"shutdown\");\n\t\tthis.disposed = true;\n\t\tthis.changeListeners.clear();\n\t\tthis.listeners.clear();\n\t\tthis.pendingListeners.clear();\n\t}\n\n\tprivate show(to: ViewedTarget): void {\n\t\tconst from = this.current;\n\t\tif (from === to || (from.kind === \"main\" && to.kind === \"main\")) return;\n\t\tconst releaseFrom = this.releaseCurrent;\n\t\tthis.unwatchCurrent?.();\n\t\tthis.unwatchCurrent = undefined;\n\t\tthis.releaseCurrent = undefined;\n\t\tthis.current = to;\n\t\tif (to.kind === \"agent\") {\n\t\t\tthis.releaseCurrent = to.port.retain();\n\t\t\tthis.unwatchCurrent = to.port.subscribe(() => {\n\t\t\t\t// A shown subagent that is gone gives the screen back to main in the same tick. A newer request, still\n\t\t\t\t// opening, is the reader's and still lands.\n\t\t\t\tif (this.current === to && to.port.status().gone) this.show(VIEWING_MAIN);\n\t\t\t});\n\t\t}\n\t\tconst change: AgentViewChange = { from, to };\n\t\tfor (const listener of [...this.changeListeners]) {\n\t\t\ttry {\n\t\t\t\tlistener(change);\n\t\t\t} catch (error) {\n\t\t\t\tthis.notify(error instanceof Error ? error.message : String(error));\n\t\t\t}\n\t\t}\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\t// Released after the listeners, so one that still has messages on their way to it can keep it.\n\t\treleaseFrom?.();\n\t}\n}\n"]}
@@ -36,6 +36,11 @@ export interface AgentViewStatus {
36
36
  readonly retrying: boolean;
37
37
  /** The subagent's own queue as it last listed it. */
38
38
  readonly queued: SteeringQueueLists;
39
+ /**
40
+ * Messages it took from its queue whose own row its transcript does not show yet: drawn as queued rows ahead of
41
+ * `queued` until it does, so a message is never off screen. Drawing only; left out when there are none.
42
+ */
43
+ readonly delivering?: SteeringQueueLists;
39
44
  /** Why messages cannot reach it any more; undefined while they can. */
40
45
  readonly readOnlyReason?: string;
41
46
  /** It waits on a question form, drawn in the transcript area, which takes the keys meanwhile. */
@@ -1 +1 @@
1
- {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/contracts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAq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YAAY,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC","sourcesContent":["import type { Component } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { QueuedTaskMessages } from \"../../../core/tasks/supervisor.js\";\nimport type { TaskViewResult } from \"../../../core/tasks/task-view-source.js\";\nimport type { SteeringQueueLists, SteeringTarget } from \"../steering-queue-controller.ts\";\n\n/**\n * The single chat screen shows the main chat or one subagent. While it shows a subagent, its transcript takes the\n * transcript area and the main prompt is retargeted to it; the agent panel and `/tasks` stay as they are.\n */\n\n/** What the screen shows: the main chat, or one subagent through its port. */\nexport type ViewedTarget = { readonly kind: \"main\" } | { readonly kind: \"agent\"; readonly port: AgentViewPort };\n\nexport const VIEWING_MAIN: ViewedTarget = Object.freeze({ kind: \"main\" });\n\nexport type AgentViewState =\n\t| \"running\"\n\t| \"queued\"\n\t| \"input\"\n\t| \"paused\"\n\t| \"stopping\"\n\t| \"waiting\"\n\t| \"done\"\n\t| \"failed\"\n\t| \"stopped\";\n\n/** A viewed subagent as the prompt, its rule, the footer and the panel show it. Plain data: it crosses the engine. */\nexport interface AgentViewStatus {\n\t/** The attempt messages go to now: the latest one, which a resume moves. */\n\treadonly taskId: TaskId;\n\t/** The subagent across resumes: its first attempt's task id. Per-agent prompt state is keyed by it. */\n\treadonly agentKey: string;\n\t/** Display name without \"@\", such as \"worker\". */\n\treadonly name: string;\n\t/** The prompt's top-rule label, such as \"worker · Fix the parser · running\". */\n\treadonly ruleLabel: string;\n\t/** The empty prompt's placeholder, such as \"Message @worker…\", or the paused, stopped, answer or wake text. */\n\treadonly placeholder: string;\n\treadonly state: AgentViewState;\n\t/** Streaming, retrying or running a tool: Enter queues the message. */\n\treadonly busy: boolean;\n\t/** Esc paused it: the next message sent continues it. */\n\treadonly paused: boolean;\n\treadonly retrying: boolean;\n\t/** The subagent's own queue as it last listed it. */\n\treadonly queued: SteeringQueueLists;\n\t/** Why messages cannot reach it any more; undefined while they can. */\n\treadonly readOnlyReason?: string;\n\t/** It waits on a question form, drawn in the transcript area, which takes the keys meanwhile. */\n\treadonly heldPrompt: boolean;\n\t/** The working line under its transcript, as its chat would draw it; undefined when it shows none. */\n\treadonly working?: AgentWorkingLine;\n\t/** The subagent is gone (dismissed, removed, or its engine was lost): the screen shows main again. */\n\treadonly gone: boolean;\n}\n\n/**\n * A subagent's working line as plain data: what it is doing (`working` streams, `busy` waits or retries,\n * `compacting`), or the `worked` row its last turn left. The host draws and animates it as the main chat's.\n */\nexport interface AgentWorkingLine {\n\treadonly kind: \"working\" | \"busy\" | \"compacting\" | \"worked\";\n\treadonly message: string;\n\treadonly elapsedMs?: number;\n\treadonly tokens?: number;\n\treadonly worked?: { readonly elapsedMs: number; readonly tokens?: number };\n}\n\n/** The viewed subagent's transcript, drawn where the main transcript is. */\nexport interface AgentTranscriptComponent extends Component {\n\t/** Scroll and paging keys while it is shown (page keys, wheel, top/bottom, half page, prompt jumps, jump to latest). */\n\thandleViewKey(data: string): boolean;\n\t/** Whether its question form is open and takes the keys; focus moves to the transcript area meanwhile. */\n\tcapturesInput(): boolean;\n\thandleInput(data: string): void;\n\tinvalidate(): void;\n}\n\n/** A slash command the viewed agent's own session runs. */\nexport interface AgentViewCommand {\n\treadonly name: string;\n\treadonly description?: string;\n}\n\n/** The slash commands the viewed agent's own session runs: completion and routing of skills and templates. */\nexport interface AgentViewCommands {\n\treadonly cwd: string;\n\treadonly skillCommands: readonly AgentViewCommand[];\n\treadonly promptTemplates: readonly AgentViewCommand[];\n\treadonly extensionCommands: readonly AgentViewCommand[];\n}\n\n/** What a pause took back from the subagent's queue, and why a restart would not keep the pause, when it would not. */\nexport type PausedTaskMessages = QueuedTaskMessages & { readonly warning?: string };\n\n/** The steering half of a port. */\nexport interface AgentSteeringPort {\n\t/** Where the prompt's messages go: busy, paused and queued follow `status()`; the calls reach the subagent. */\n\treadonly steering: SteeringTarget;\n\t/** Esc: pause the subagent, answering the messages taken back from its queue, steering first. */\n\tpause(): Promise<TaskViewResult<PausedTaskMessages>>;\n}\n\n/** One subagent, reachable from the host whether it runs in this process or in the isolated engine. */\nexport interface AgentViewPort extends AgentSteeringPort {\n\treadonly agentKey: string;\n\tstatus(): AgentViewStatus;\n\tsubscribe(listener: () => void): () => void;\n\treadonly transcript: AgentTranscriptComponent;\n\t/** Its own delivered user messages, oldest first. */\n\tprompts(): Promise<readonly string[]>;\n\tcommands(): Promise<AgentViewCommands | undefined>;\n\t/** The text of its last assistant message, for `/copy` while it is shown. */\n\tlastAgentMessageText(): Promise<string | undefined>;\n\t/** Keep the port alive while it is shown or has messages on their way. The last release disposes it. */\n\tretain(): () => void;\n}\n\nexport interface AgentViewChange {\n\treadonly from: ViewedTarget;\n\treadonly to: ViewedTarget;\n}\n"]}
1
+ {"version":3,"file":"contracts.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/contracts.ts"],"names":[],"mappings":"AAcA,MAAM,CAAC,MAAM,YAAY,GAAiB,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC","sourcesContent":["import type { Component } from \"@bastani/atomic-tui\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { QueuedTaskMessages } from \"../../../core/tasks/supervisor.js\";\nimport type { TaskViewResult } from \"../../../core/tasks/task-view-source.js\";\nimport type { SteeringQueueLists, SteeringTarget } from \"../steering-queue-controller.ts\";\n\n/**\n * The single chat screen shows the main chat or one subagent. While it shows a subagent, its transcript takes the\n * transcript area and the main prompt is retargeted to it; the agent panel and `/tasks` stay as they are.\n */\n\n/** What the screen shows: the main chat, or one subagent through its port. */\nexport type ViewedTarget = { readonly kind: \"main\" } | { readonly kind: \"agent\"; readonly port: AgentViewPort };\n\nexport const VIEWING_MAIN: ViewedTarget = Object.freeze({ kind: \"main\" });\n\nexport type AgentViewState =\n\t| \"running\"\n\t| \"queued\"\n\t| \"input\"\n\t| \"paused\"\n\t| \"stopping\"\n\t| \"waiting\"\n\t| \"done\"\n\t| \"failed\"\n\t| \"stopped\";\n\n/** A viewed subagent as the prompt, its rule, the footer and the panel show it. Plain data: it crosses the engine. */\nexport interface AgentViewStatus {\n\t/** The attempt messages go to now: the latest one, which a resume moves. */\n\treadonly taskId: TaskId;\n\t/** The subagent across resumes: its first attempt's task id. Per-agent prompt state is keyed by it. */\n\treadonly agentKey: string;\n\t/** Display name without \"@\", such as \"worker\". */\n\treadonly name: string;\n\t/** The prompt's top-rule label, such as \"worker · Fix the parser · running\". */\n\treadonly ruleLabel: string;\n\t/** The empty prompt's placeholder, such as \"Message @worker…\", or the paused, stopped, answer or wake text. */\n\treadonly placeholder: string;\n\treadonly state: AgentViewState;\n\t/** Streaming, retrying or running a tool: Enter queues the message. */\n\treadonly busy: boolean;\n\t/** Esc paused it: the next message sent continues it. */\n\treadonly paused: boolean;\n\treadonly retrying: boolean;\n\t/** The subagent's own queue as it last listed it. */\n\treadonly queued: SteeringQueueLists;\n\t/**\n\t * Messages it took from its queue whose own row its transcript does not show yet: drawn as queued rows ahead of\n\t * `queued` until it does, so a message is never off screen. Drawing only; left out when there are none.\n\t */\n\treadonly delivering?: SteeringQueueLists;\n\t/** Why messages cannot reach it any more; undefined while they can. */\n\treadonly readOnlyReason?: string;\n\t/** It waits on a question form, drawn in the transcript area, which takes the keys meanwhile. */\n\treadonly heldPrompt: boolean;\n\t/** The working line under its transcript, as its chat would draw it; undefined when it shows none. */\n\treadonly working?: AgentWorkingLine;\n\t/** The subagent is gone (dismissed, removed, or its engine was lost): the screen shows main again. */\n\treadonly gone: boolean;\n}\n\n/**\n * A subagent's working line as plain data: what it is doing (`working` streams, `busy` waits or retries,\n * `compacting`), or the `worked` row its last turn left. The host draws and animates it as the main chat's.\n */\nexport interface AgentWorkingLine {\n\treadonly kind: \"working\" | \"busy\" | \"compacting\" | \"worked\";\n\treadonly message: string;\n\treadonly elapsedMs?: number;\n\treadonly tokens?: number;\n\treadonly worked?: { readonly elapsedMs: number; readonly tokens?: number };\n}\n\n/** The viewed subagent's transcript, drawn where the main transcript is. */\nexport interface AgentTranscriptComponent extends Component {\n\t/** Scroll and paging keys while it is shown (page keys, wheel, top/bottom, half page, prompt jumps, jump to latest). */\n\thandleViewKey(data: string): boolean;\n\t/** Whether its question form is open and takes the keys; focus moves to the transcript area meanwhile. */\n\tcapturesInput(): boolean;\n\thandleInput(data: string): void;\n\tinvalidate(): void;\n}\n\n/** A slash command the viewed agent's own session runs. */\nexport interface AgentViewCommand {\n\treadonly name: string;\n\treadonly description?: string;\n}\n\n/** The slash commands the viewed agent's own session runs: completion and routing of skills and templates. */\nexport interface AgentViewCommands {\n\treadonly cwd: string;\n\treadonly skillCommands: readonly AgentViewCommand[];\n\treadonly promptTemplates: readonly AgentViewCommand[];\n\treadonly extensionCommands: readonly AgentViewCommand[];\n}\n\n/** What a pause took back from the subagent's queue, and why a restart would not keep the pause, when it would not. */\nexport type PausedTaskMessages = QueuedTaskMessages & { readonly warning?: string };\n\n/** The steering half of a port. */\nexport interface AgentSteeringPort {\n\t/** Where the prompt's messages go: busy, paused and queued follow `status()`; the calls reach the subagent. */\n\treadonly steering: SteeringTarget;\n\t/** Esc: pause the subagent, answering the messages taken back from its queue, steering first. */\n\tpause(): Promise<TaskViewResult<PausedTaskMessages>>;\n}\n\n/** One subagent, reachable from the host whether it runs in this process or in the isolated engine. */\nexport interface AgentViewPort extends AgentSteeringPort {\n\treadonly agentKey: string;\n\tstatus(): AgentViewStatus;\n\tsubscribe(listener: () => void): () => void;\n\treadonly transcript: AgentTranscriptComponent;\n\t/** Its own delivered user messages, oldest first. */\n\tprompts(): Promise<readonly string[]>;\n\tcommands(): Promise<AgentViewCommands | undefined>;\n\t/** The text of its last assistant message, for `/copy` while it is shown. */\n\tlastAgentMessageText(): Promise<string | undefined>;\n\t/** Keep the port alive while it is shown or has messages on their way. The last release disposes it. */\n\tretain(): () => void;\n}\n\nexport interface AgentViewChange {\n\treadonly from: ViewedTarget;\n\treadonly to: ViewedTarget;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAQrF;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,mBAAmB,EACzB,QAAQ,GAAE,iBAA+D,GACvE,iBAAiB,CAQnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,iBAAiB,CAsC7E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAQ3F"}
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/install.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AASrF;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,IAAI,EAAE,mBAAmB,EACzB,QAAQ,GAAE,iBAA+D,GACvE,iBAAiB,CAYnB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,mBAAmB,GAAG,iBAAiB,CAwC7E;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,IAAI,CAQ3F"}
@@ -3,7 +3,8 @@ import { setAgentViewBridge } from "./agent-view-bridge.js";
3
3
  import { AgentViewSwitcher } from "./agent-view-switcher.js";
4
4
  import { openAgentViewPort } from "./open-port.js";
5
5
  import { installPromptRetarget } from "./prompt-retarget.js";
6
- import { installTranscriptSlot } from "./transcript-slot.js";
6
+ import { FIRST_FRAME_TIMEOUT_MS } from "./remote-port.js";
7
+ import { holdTranscriptDock, installTranscriptSlot } from "./transcript-slot.js";
7
8
  import { installViewedCommandGates } from "./viewed-commands.js";
8
9
  const switchers = new WeakMap();
9
10
  /**
@@ -13,7 +14,7 @@ const switchers = new WeakMap();
13
14
  export function agentViewSwitcher(mode, openPort = (taskId) => openAgentViewPort(mode, taskId)) {
14
15
  let switcher = switchers.get(mode);
15
16
  if (switcher === undefined) {
16
- switcher = new AgentViewSwitcher(openPort, (message) => mode.showWarning(message));
17
+ switcher = new AgentViewSwitcher(openPort, (message) => mode.showWarning(message), () => holdTranscriptDock(mode, FIRST_FRAME_TIMEOUT_MS));
17
18
  switchers.set(mode, switcher);
18
19
  mode.agentView = switcher;
19
20
  }
@@ -36,7 +37,9 @@ export function installAgentView(mode) {
36
37
  undo.push(runtime.onEngineMessage((message) => {
37
38
  if (message.type !== "engine_view_agent")
38
39
  return;
39
- switcher.requestView(message.taskId === null ? undefined : message.taskId);
40
+ switcher.requestView(message.taskId === null ? undefined : message.taskId, {
41
+ keepScreen: message.keepScreen === true,
42
+ });
40
43
  }), runtime.onGenerationEnded(() => switcher.reset("generation-lost")), switcher.onChange(({ to }) => {
41
44
  const taskId = to.kind === "agent" ? to.port.status().taskId : undefined;
42
45
  void runtime
@@ -1 +1 @@
1
- {"version":3,"file":"install.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/install.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,MAAM,8CAA8C,CAAC;AAE1F,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAA0B,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,sB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AE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE;QACX,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { IsolatedInteractiveRuntime } from \"../../interactive-engine/isolated-runtime.js\";\nimport type { InteractiveModeBase } from \"../interactive-mode-base.ts\";\nimport { setAgentViewBridge } from \"./agent-view-bridge.ts\";\nimport { AgentViewSwitcher, type OpenAgentViewPort } from \"./agent-view-switcher.ts\";\nimport { openAgentViewPort } from \"./open-port.ts\";\nimport { installPromptRetarget } from \"./prompt-retarget.ts\";\nimport { installTranscriptSlot } from \"./transcript-slot.ts\";\nimport { installViewedCommandGates } from \"./viewed-commands.ts\";\n\nconst switchers = new WeakMap<InteractiveModeBase, AgentViewSwitcher>();\n\n/**\n * The mode's switcher, made on first use: a session can be bound before the screen is set up. `openPort` opens the\n * subagents it shows; the first call decides it.\n */\nexport function agentViewSwitcher(\n\tmode: InteractiveModeBase,\n\topenPort: OpenAgentViewPort = (taskId) => openAgentViewPort(mode, taskId),\n): AgentViewSwitcher {\n\tlet switcher = switchers.get(mode);\n\tif (switcher === undefined) {\n\t\tswitcher = new AgentViewSwitcher(openPort, (message) => mode.showWarning(message));\n\t\tswitchers.set(mode, switcher);\n\t\tmode.agentView = switcher;\n\t}\n\treturn switcher;\n}\n\n/**\n * Set up the single chat screen once the main screen is: the transcript area, the prompt's retargeting and the\n * hotkey gates follow what the switcher shows, in that order. On the isolated host the engine's panel and `/tasks`\n * reach the switcher through `engine_view_agent`, and learn what it shows through `set_viewed_agent`.\n */\nexport function installAgentView(mode: InteractiveModeBase): AgentViewSwitcher {\n\tconst switcher = agentViewSwitcher(mode);\n\tconst undo: (() => void)[] = [\n\t\tinstallTranscriptSlot(mode, switcher),\n\t\tinstallPromptRetarget(mode, switcher),\n\t\tinstallViewedCommandGates(mode, switcher),\n\t];\n\tconst runtime = mode.runtimeHost;\n\tif (runtime instanceof IsolatedInteractiveRuntime) {\n\t\tundo.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type !== \"engine_view_agent\") return;\n\t\t\t\tswitcher.requestView(message.taskId === null ? undefined : (message.taskId as TaskId));\n\t\t\t}),\n\t\t\truntime.onGenerationEnded(() => switcher.reset(\"generation-lost\")),\n\t\t\tswitcher.onChange(({ to }) => {\n\t\t\t\tconst taskId = to.kind === \"agent\" ? to.port.status().taskId : undefined;\n\t\t\t\tvoid runtime\n\t\t\t\t\t.requestAgentView({ type: \"set_viewed_agent\", ...(taskId === undefined ? {} : { taskId }) })\n\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t// A lost engine forgets what was shown; its replacement starts on main.\n\t\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n\tmode.disposeAgentView = () => {\n\t\tmode.disposeAgentView = undefined;\n\t\t// Main is shown again first, while every part still follows the switcher, then each part is taken down.\n\t\tswitcher.dispose();\n\t\tfor (const release of undo.reverse()) {\n\t\t\ttry {\n\t\t\t\trelease();\n\t\t\t} catch {\n\t\t\t\t// One part's failure must not keep the others installed.\n\t\t\t}\n\t\t}\n\t};\n\treturn switcher;\n}\n\n/**\n * Let the panel and `/tasks` of a session bound in this process change what the screen shows. Answers the unbind,\n * which shows main again: the subagents shown belonged to the session left.\n */\nexport function bindAgentViewSession(mode: InteractiveModeBase, session: object): () => void {\n\tif (mode.runtimeHost instanceof IsolatedInteractiveRuntime) return () => {};\n\tconst switcher = agentViewSwitcher(mode);\n\tsetAgentViewBridge(session, switcher);\n\treturn () => {\n\t\tsetAgentViewBridge(session, undefined);\n\t\tswitcher.reset(\"session-replaced\");\n\t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CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CACF,CAAC;IACH,CAAC;IACD,IAAI,CAAC,gBAAgB,GAAG,GAAG,EAAE;QAC5B,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;QAClC,wGAAwG;QACxG,QAAQ,CAAC,OAAO,EAAE,CAAC;QACnB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC;YACtC,IAAI,CAAC;gBACJ,OAAO,EAAE,CAAC;YACX,CAAC;YAAC,MAAM,CAAC;gBACR,yDAAyD;YAC1D,CAAC;QACF,CAAC;IACF,CAAC,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAyB,EAAE,OAAe;IAC9E,IAAI,IAAI,CAAC,WAAW,YAAY,0BAA0B;QAAE,OAAO,GAAG,EAAE,GAAE,CAAC,CAAC;IAC5E,MAAM,QAAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACzC,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE;QACX,kBAAkB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QACvC,QAAQ,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACpC,CAAC,CAAC;AACH,CAAC","sourcesContent":["import type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport { IsolatedInteractiveRuntime } from \"../../interactive-engine/isolated-runtime.js\";\nimport type { InteractiveModeBase } from \"../interactive-mode-base.ts\";\nimport { setAgentViewBridge } from \"./agent-view-bridge.ts\";\nimport { AgentViewSwitcher, type OpenAgentViewPort } from \"./agent-view-switcher.ts\";\nimport { openAgentViewPort } from \"./open-port.ts\";\nimport { installPromptRetarget } from \"./prompt-retarget.ts\";\nimport { FIRST_FRAME_TIMEOUT_MS } from \"./remote-port.ts\";\nimport { holdTranscriptDock, installTranscriptSlot } from \"./transcript-slot.ts\";\nimport { installViewedCommandGates } from \"./viewed-commands.ts\";\n\nconst switchers = new WeakMap<InteractiveModeBase, AgentViewSwitcher>();\n\n/**\n * The mode's switcher, made on first use: a session can be bound before the screen is set up. `openPort` opens the\n * subagents it shows; the first call decides it.\n */\nexport function agentViewSwitcher(\n\tmode: InteractiveModeBase,\n\topenPort: OpenAgentViewPort = (taskId) => openAgentViewPort(mode, taskId),\n): AgentViewSwitcher {\n\tlet switcher = switchers.get(mode);\n\tif (switcher === undefined) {\n\t\tswitcher = new AgentViewSwitcher(\n\t\t\topenPort,\n\t\t\t(message) => mode.showWarning(message),\n\t\t\t() => holdTranscriptDock(mode, FIRST_FRAME_TIMEOUT_MS),\n\t\t);\n\t\tswitchers.set(mode, switcher);\n\t\tmode.agentView = switcher;\n\t}\n\treturn switcher;\n}\n\n/**\n * Set up the single chat screen once the main screen is: the transcript area, the prompt's retargeting and the\n * hotkey gates follow what the switcher shows, in that order. On the isolated host the engine's panel and `/tasks`\n * reach the switcher through `engine_view_agent`, and learn what it shows through `set_viewed_agent`.\n */\nexport function installAgentView(mode: InteractiveModeBase): AgentViewSwitcher {\n\tconst switcher = agentViewSwitcher(mode);\n\tconst undo: (() => void)[] = [\n\t\tinstallTranscriptSlot(mode, switcher),\n\t\tinstallPromptRetarget(mode, switcher),\n\t\tinstallViewedCommandGates(mode, switcher),\n\t];\n\tconst runtime = mode.runtimeHost;\n\tif (runtime instanceof IsolatedInteractiveRuntime) {\n\t\tundo.push(\n\t\t\truntime.onEngineMessage((message) => {\n\t\t\t\tif (message.type !== \"engine_view_agent\") return;\n\t\t\t\tswitcher.requestView(message.taskId === null ? undefined : (message.taskId as TaskId), {\n\t\t\t\t\tkeepScreen: message.keepScreen === true,\n\t\t\t\t});\n\t\t\t}),\n\t\t\truntime.onGenerationEnded(() => switcher.reset(\"generation-lost\")),\n\t\t\tswitcher.onChange(({ to }) => {\n\t\t\t\tconst taskId = to.kind === \"agent\" ? to.port.status().taskId : undefined;\n\t\t\t\tvoid runtime\n\t\t\t\t\t.requestAgentView({ type: \"set_viewed_agent\", ...(taskId === undefined ? {} : { taskId }) })\n\t\t\t\t\t.catch(() => {\n\t\t\t\t\t\t// A lost engine forgets what was shown; its replacement starts on main.\n\t\t\t\t\t});\n\t\t\t}),\n\t\t);\n\t}\n\tmode.disposeAgentView = () => {\n\t\tmode.disposeAgentView = undefined;\n\t\t// Main is shown again first, while every part still follows the switcher, then each part is taken down.\n\t\tswitcher.dispose();\n\t\tfor (const release of undo.reverse()) {\n\t\t\ttry {\n\t\t\t\trelease();\n\t\t\t} catch {\n\t\t\t\t// One part's failure must not keep the others installed.\n\t\t\t}\n\t\t}\n\t};\n\treturn switcher;\n}\n\n/**\n * Let the panel and `/tasks` of a session bound in this process change what the screen shows. Answers the unbind,\n * which shows main again: the subagents shown belonged to the session left.\n */\nexport function bindAgentViewSession(mode: InteractiveModeBase, session: object): () => void {\n\tif (mode.runtimeHost instanceof IsolatedInteractiveRuntime) return () => {};\n\tconst switcher = agentViewSwitcher(mode);\n\tsetAgentViewBridge(session, switcher);\n\treturn () => {\n\t\tsetAgentViewBridge(session, undefined);\n\t\tswitcher.reset(\"session-replaced\");\n\t};\n}\n"]}
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import type { TaskId } from "../../../core/tasks/contracts.js";
7
7
  import type { TaskViewSource } from "../../../core/tasks/task-view-source.js";
8
+ import type { TranscriptFrameLayout } from "../../interactive-engine/transcript-frame-layout.ts";
8
9
  import type { TaskTranscriptEnvironment } from "../components/task-transcript-page.ts";
9
10
  import { TaskAgentTranscriptPage } from "../components/task-transcript-page.ts";
10
11
  import type { AgentSteeringPort, AgentTranscriptComponent, AgentViewCommands, AgentViewPort, AgentViewStatus } from "./contracts.ts";
@@ -46,6 +47,8 @@ export declare class AgentTranscriptView implements AgentTranscriptComponent {
46
47
  handleInput(data: string): boolean;
47
48
  handleMouse(event: Parameters<NonNullable<TaskAgentTranscriptPage["handleMouse"]>>[0]): import("@bastani/atomic-tui").TuiMouseEventResult | undefined;
48
49
  paintedRowKey(row: number): string | undefined;
50
+ /** How the frame rendered last laid out its rows, which the engine sends with it. */
51
+ transcriptLayout(): TranscriptFrameLayout | undefined;
49
52
  invalidate(): void;
50
53
  }
51
54
  /** One subagent of `source`, shown through its own transcript page, which draws only its transcript here. */
@@ -75,6 +78,8 @@ export declare class LocalAgentViewPort implements AgentViewPort {
75
78
  prompts(): Promise<readonly string[]>;
76
79
  commands(): Promise<AgentViewCommands | undefined>;
77
80
  lastAgentMessageText(): Promise<string | undefined>;
81
+ /** How many user messages its transcript received so far: it grows when a delivered message shows. */
82
+ userMessagesShown(): number;
78
83
  retain(): () => void;
79
84
  /** Whether the subagent is an agent task this view lists. */
80
85
  static shows(source: TaskViewSource, taskId: TaskId): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"local-port.d.ts","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/local-port.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAC;AAC9E,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAIhF,OAAO,KAAK,EACX,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,MAAM,gBAAgB,CAAC;AAExB,qGAAqG;AACrG,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAExC,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,gEAAgE;IAChE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,EAAE,yBAAyB,CAAC;IACxC,6CAA6C;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,IAAI,CAAC;IACnC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AAO,CAAC,cAAc;IAStB,4FAA4F;IAC5F,OAAO,CAAC,aAAa;IAiBrB,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,OAAO;CASf;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC,CAUpH"}
@@ -64,6 +64,10 @@ export class AgentTranscriptView {
64
64
  paintedRowKey(row) {
65
65
  return this.page.paintedRowKey(row);
66
66
  }
67
+ /** How the frame rendered last laid out its rows, which the engine sends with it. */
68
+ transcriptLayout() {
69
+ return this.page.viewFrameLayout();
70
+ }
67
71
  invalidate() {
68
72
  this.page.invalidate();
69
73
  }
@@ -155,6 +159,10 @@ export class LocalAgentViewPort {
155
159
  async lastAgentMessageText() {
156
160
  return this.page.chat.lastAgentMessageText();
157
161
  }
162
+ /** How many user messages its transcript received so far: it grows when a delivered message shows. */
163
+ userMessagesShown() {
164
+ return this.page.chat.userMessagesShown();
165
+ }
158
166
  retain() {
159
167
  this.retained++;
160
168
  let released = false;
@@ -1 +1 @@
1
- {"version":3,"file":"local-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/local-port.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAIhG,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAmBxC,SAAS,iBAAiB,CAAC,GAA8B;IACxD,MAAM,QAAQ,GAAG,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC;IAC/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GAGG;AACH,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,OAA8B;IAC1E,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,SAAS,CAAC;IAChF,MAAM,IAAI,GAAG,IAAI,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC7C,IAAI,CAAC;QACJ,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC;IACb,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the task view in this process, as the single chat screen shows it: its transcript where the main\n * transcript is, its status for the prompt, rule, working line and panel, and the steering half the prompt sends\n * through. The isolated engine runs the same port for the views its host opens.\n */\n\nimport { firstSubagentAttempt, latestSubagentAttempt } from \"../../../core/tasks/completion.js\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { TaskViewSource } from \"../../../core/tasks/task-view-source.js\";\nimport type { TaskTranscriptEnvironment } from \"../components/task-transcript-page.ts\";\nimport { TaskAgentTranscriptPage } from \"../components/task-transcript-page.ts\";\nimport { localAgentCommands } from \"./agent-commands.ts\";\nimport { localAgentPrompts } from \"./agent-prompts.ts\";\nimport { createLocalAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How often a shown subagent's status is read again while it runs, so its elapsed time advances. */\nexport const AGENT_VIEW_TICK_MS = 1_000;\n\nexport interface LocalAgentViewOptions {\n\treadonly source: TaskViewSource;\n\t/** Any attempt of the subagent; the port follows its latest. */\n\treadonly taskId: TaskId;\n\treadonly env: TaskTranscriptEnvironment;\n\t/** Repaint where the transcript is drawn. */\n\treadonly requestRender: () => void;\n\t/** The rows the transcript is drawn in when it is rendered by width alone (the engine's frame requests). */\n\treadonly rows?: () => number;\n\t/** A message the reader sent failed after they left the subagent. */\n\treadonly reportLate?: (reason: string) => void;\n\t/** Whether the panel or `/tasks` dismissed the attempt `taskId`: a dismissed subagent is gone from the screen. */\n\treadonly isDismissed?: (taskId: TaskId) => boolean;\n\t/** Changes beyond the task list that can make it gone, such as a dismissal; answers the unsubscribe. */\n\treadonly watch?: (listener: () => void) => () => void;\n}\n\nfunction renderSettingsKey(env: TaskTranscriptEnvironment): string {\n\tconst settings = env.getChatRenderSettings?.();\n\treturn `${settings?.toolOutputExpanded === true}|${settings?.hideThinkingBlock === true}`;\n}\n\n/** The transcript part of the page, as the transcript area draws it. */\nexport class AgentTranscriptView implements AgentTranscriptComponent {\n\tprivate readonly page: TaskAgentTranscriptPage;\n\tprivate readonly env: TaskTranscriptEnvironment;\n\tprivate readonly rows: () => number;\n\tprivate settingsKey: string;\n\n\tconstructor(page: TaskAgentTranscriptPage, env: TaskTranscriptEnvironment, rows: () => number) {\n\t\tthis.page = page;\n\t\tthis.env = env;\n\t\tthis.rows = rows;\n\t\tthis.settingsKey = renderSettingsKey(env);\n\t}\n\n\t/** The main chat's Ctrl+O and thinking toggle reach the transcript shown in its place on its next frame. */\n\tprivate followRenderSettings(): void {\n\t\tconst key = renderSettingsKey(this.env);\n\t\tif (key === this.settingsKey) return;\n\t\tconst toolsToggled = key.split(\"|\")[0] !== this.settingsKey.split(\"|\")[0];\n\t\tthis.settingsKey = key;\n\t\tif (toolsToggled) this.page.toolOutputToggled();\n\t\telse this.page.invalidate();\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.followRenderSettings();\n\t\treturn this.page.renderView(width, height);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, Math.max(1, this.rows()));\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\treturn this.page.handleViewKey(data);\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.page.capturesInput();\n\t}\n\n\t/**\n\t * Keys for the transcript area: its question form's while one is open, else only scroll and paging keys (the engine\n\t * forwards the host's this way). Nothing types into the page's own prompt, which the screen never shows.\n\t */\n\thandleInput(data: string): boolean {\n\t\treturn this.page.capturesInput() ? this.page.handleInput(data) : this.page.handleViewKey(data);\n\t}\n\n\thandleMouse(event: Parameters<NonNullable<TaskAgentTranscriptPage[\"handleMouse\"]>>[0]) {\n\t\treturn this.page.handleMouse(event);\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\treturn this.page.paintedRowKey(row);\n\t}\n\n\tinvalidate(): void {\n\t\tthis.page.invalidate();\n\t}\n}\n\n/** One subagent of `source`, shown through its own transcript page, which draws only its transcript here. */\nexport class LocalAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly transcript: AgentTranscriptView;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly page: TaskAgentTranscriptPage;\n\tprivate readonly source: TaskViewSource;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate currentKey: string;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate scheduled = false;\n\tprivate readonly unsubscribeSource: () => void;\n\tprivate readonly unwatch: () => void;\n\tprivate readonly isDismissed: ((taskId: TaskId) => boolean) | undefined;\n\tprivate readonly tick: ReturnType<typeof setInterval>;\n\n\tconstructor(options: LocalAgentViewOptions) {\n\t\tconst { source, env } = options;\n\t\tthis.source = source;\n\t\tthis.isDismissed = options.isDismissed;\n\t\tconst first = firstSubagentAttempt(source.tasks, options.taskId);\n\t\tthis.agentKey = first?.ref.taskId ?? options.taskId;\n\t\tconst requestRender = () => {\n\t\t\toptions.requestRender();\n\t\t\tthis.scheduleStatus();\n\t\t};\n\t\tthis.page = new TaskAgentTranscriptPage(\n\t\t\tsource,\n\t\t\toptions.taskId,\n\t\t\tenv,\n\t\t\trequestRender,\n\t\t\toptions.reportLate ?? ((reason) => env.notify?.(reason)),\n\t\t);\n\t\tthis.transcript = new AgentTranscriptView(this.page, env, options.rows ?? (() => 24));\n\t\tthis.current = this.readStatus();\n\t\tthis.currentKey = JSON.stringify(this.current);\n\t\tthis.steeringPort = createLocalAgentSteering({\n\t\t\tsource,\n\t\t\tliveTaskId: () => this.status().taskId,\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\t// The task list changed: a resumed attempt, a settled run, a removal. The page follows it as the inspector did.\n\t\tthis.unsubscribeSource = source.subscribe(() => {\n\t\t\tif (this.disposed) return;\n\t\t\tthis.page.refresh();\n\t\t\tthis.scheduleStatus();\n\t\t\toptions.requestRender();\n\t\t});\n\t\tthis.unwatch =\n\t\t\toptions.watch?.(() => {\n\t\t\t\tif (this.disposed) return;\n\t\t\t\tif (this.publishStatus()) options.requestRender();\n\t\t\t}) ?? (() => {});\n\t\tthis.tick = setInterval(() => {\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.publishStatus()) options.requestRender();\n\t\t}, AGENT_VIEW_TICK_MS);\n\t\tthis.tick.unref?.();\n\t}\n\n\t/** Read the latest page; the first one is in before the screen shows the subagent. */\n\tload(): Promise<void> {\n\t\treturn this.page.load().then(() => {\n\t\t\tthis.publishStatus();\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 localAgentPrompts(this.source, this.status().taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn localAgentCommands(this.source, this.status().taskId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\treturn this.page.chat.lastAgentMessageText();\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\t/** Whether the subagent is an agent task this view lists. */\n\tstatic shows(source: TaskViewSource, taskId: TaskId): boolean {\n\t\treturn latestSubagentAttempt(source.tasks, taskId)?.kind === \"agent\";\n\t}\n\n\tprivate scheduleStatus(): void {\n\t\tif (this.scheduled || this.disposed) return;\n\t\tthis.scheduled = true;\n\t\tqueueMicrotask(() => {\n\t\t\tthis.scheduled = false;\n\t\t\tthis.publishStatus();\n\t\t});\n\t}\n\n\t/** Read the status again and tell the listeners when it changed. Answers whether it did. */\n\tprivate publishStatus(): boolean {\n\t\tif (this.disposed) return false;\n\t\tconst next = this.readStatus();\n\t\tconst key = JSON.stringify(next);\n\t\tif (key === this.currentKey) return false;\n\t\tthis.current = next;\n\t\tthis.currentKey = key;\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\treturn true;\n\t}\n\n\tprivate readStatus(): AgentViewStatus {\n\t\tconst status = this.page.viewStatus(this.agentKey);\n\t\treturn !status.gone && this.isDismissed?.(status.taskId) === true ? { ...status, gone: true } : status;\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tclearInterval(this.tick);\n\t\tthis.unsubscribeSource();\n\t\tthis.unwatch();\n\t\tthis.listeners.clear();\n\t\tthis.page.dispose();\n\t}\n}\n\n/**\n * Open a port on the subagent `taskId` is an attempt of, once its first page is read: the screen never shows a\n * subagent before its transcript is there. Undefined when `source` lists no such agent task.\n */\nexport async function openLocalAgentViewPort(options: LocalAgentViewOptions): Promise<LocalAgentViewPort | undefined> {\n\tif (!LocalAgentViewPort.shows(options.source, options.taskId)) return undefined;\n\tconst port = new LocalAgentViewPort(options);\n\ttry {\n\t\tawait port.load();\n\t} catch (error) {\n\t\tport.retain()();\n\t\tthrow error;\n\t}\n\treturn port;\n}\n"]}
1
+ {"version":3,"file":"local-port.js","sourceRoot":"","sources":["../../../../src/modes/interactive/agent-view/local-port.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAKhG,OAAO,EAAE,uBAAuB,EAAE,MAAM,uCAAuC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAS/D,qGAAqG;AACrG,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAmBxC,SAAS,iBAAiB,CAAC,GAA8B;IACxD,MAAM,QAAQ,GAAG,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC;IAC/C,OAAO,GAAG,QAAQ,EAAE,kBAAkB,KAAK,IAAI,IAAI,QAAQ,EAAE,iBAAiB,KAAK,IAAI,EAAE,CAAC;AAC3F,CAAC;AAED,wEAAwE;AACxE,MAAM,OAAO,mBAAmB;IACd,IAAI,CAA0B;IAC9B,GAAG,CAA4B;IAC/B,IAAI,CAAe;IAC5B,WAAW,CAAS;IAE5B,YAAY,IAA6B,EAAE,GAA8B,EAAE,IAAkB;QAC5F,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,iBAAiB,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,4GAA4G;IACpG,oBAAoB;QAC3B,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAA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AAI,CAAC,MAAM,EAAE,EAAE,CAAC;QAChB,MAAM,KAAK,CAAC;IACb,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * A subagent of the task view in this process, as the single chat screen shows it: its transcript where the main\n * transcript is, its status for the prompt, rule, working line and panel, and the steering half the prompt sends\n * through. The isolated engine runs the same port for the views its host opens.\n */\n\nimport { firstSubagentAttempt, latestSubagentAttempt } from \"../../../core/tasks/completion.js\";\nimport type { TaskId } from \"../../../core/tasks/contracts.js\";\nimport type { TaskViewSource } from \"../../../core/tasks/task-view-source.js\";\nimport type { TranscriptFrameLayout } from \"../../interactive-engine/transcript-frame-layout.ts\";\nimport type { TaskTranscriptEnvironment } from \"../components/task-transcript-page.ts\";\nimport { TaskAgentTranscriptPage } from \"../components/task-transcript-page.ts\";\nimport { localAgentCommands } from \"./agent-commands.ts\";\nimport { localAgentPrompts } from \"./agent-prompts.ts\";\nimport { createLocalAgentSteering } from \"./agent-steering.ts\";\nimport type {\n\tAgentSteeringPort,\n\tAgentTranscriptComponent,\n\tAgentViewCommands,\n\tAgentViewPort,\n\tAgentViewStatus,\n} from \"./contracts.ts\";\n\n/** How often a shown subagent's status is read again while it runs, so its elapsed time advances. */\nexport const AGENT_VIEW_TICK_MS = 1_000;\n\nexport interface LocalAgentViewOptions {\n\treadonly source: TaskViewSource;\n\t/** Any attempt of the subagent; the port follows its latest. */\n\treadonly taskId: TaskId;\n\treadonly env: TaskTranscriptEnvironment;\n\t/** Repaint where the transcript is drawn. */\n\treadonly requestRender: () => void;\n\t/** The rows the transcript is drawn in when it is rendered by width alone (the engine's frame requests). */\n\treadonly rows?: () => number;\n\t/** A message the reader sent failed after they left the subagent. */\n\treadonly reportLate?: (reason: string) => void;\n\t/** Whether the panel or `/tasks` dismissed the attempt `taskId`: a dismissed subagent is gone from the screen. */\n\treadonly isDismissed?: (taskId: TaskId) => boolean;\n\t/** Changes beyond the task list that can make it gone, such as a dismissal; answers the unsubscribe. */\n\treadonly watch?: (listener: () => void) => () => void;\n}\n\nfunction renderSettingsKey(env: TaskTranscriptEnvironment): string {\n\tconst settings = env.getChatRenderSettings?.();\n\treturn `${settings?.toolOutputExpanded === true}|${settings?.hideThinkingBlock === true}`;\n}\n\n/** The transcript part of the page, as the transcript area draws it. */\nexport class AgentTranscriptView implements AgentTranscriptComponent {\n\tprivate readonly page: TaskAgentTranscriptPage;\n\tprivate readonly env: TaskTranscriptEnvironment;\n\tprivate readonly rows: () => number;\n\tprivate settingsKey: string;\n\n\tconstructor(page: TaskAgentTranscriptPage, env: TaskTranscriptEnvironment, rows: () => number) {\n\t\tthis.page = page;\n\t\tthis.env = env;\n\t\tthis.rows = rows;\n\t\tthis.settingsKey = renderSettingsKey(env);\n\t}\n\n\t/** The main chat's Ctrl+O and thinking toggle reach the transcript shown in its place on its next frame. */\n\tprivate followRenderSettings(): void {\n\t\tconst key = renderSettingsKey(this.env);\n\t\tif (key === this.settingsKey) return;\n\t\tconst toolsToggled = key.split(\"|\")[0] !== this.settingsKey.split(\"|\")[0];\n\t\tthis.settingsKey = key;\n\t\tif (toolsToggled) this.page.toolOutputToggled();\n\t\telse this.page.invalidate();\n\t}\n\n\trenderSized(width: number, height: number): string[] {\n\t\tthis.followRenderSettings();\n\t\treturn this.page.renderView(width, height);\n\t}\n\n\trender(width: number): string[] {\n\t\treturn this.renderSized(width, Math.max(1, this.rows()));\n\t}\n\n\thandleViewKey(data: string): boolean {\n\t\treturn this.page.handleViewKey(data);\n\t}\n\n\tcapturesInput(): boolean {\n\t\treturn this.page.capturesInput();\n\t}\n\n\t/**\n\t * Keys for the transcript area: its question form's while one is open, else only scroll and paging keys (the engine\n\t * forwards the host's this way). Nothing types into the page's own prompt, which the screen never shows.\n\t */\n\thandleInput(data: string): boolean {\n\t\treturn this.page.capturesInput() ? this.page.handleInput(data) : this.page.handleViewKey(data);\n\t}\n\n\thandleMouse(event: Parameters<NonNullable<TaskAgentTranscriptPage[\"handleMouse\"]>>[0]) {\n\t\treturn this.page.handleMouse(event);\n\t}\n\n\tpaintedRowKey(row: number): string | undefined {\n\t\treturn this.page.paintedRowKey(row);\n\t}\n\n\t/** How the frame rendered last laid out its rows, which the engine sends with it. */\n\ttranscriptLayout(): TranscriptFrameLayout | undefined {\n\t\treturn this.page.viewFrameLayout();\n\t}\n\n\tinvalidate(): void {\n\t\tthis.page.invalidate();\n\t}\n}\n\n/** One subagent of `source`, shown through its own transcript page, which draws only its transcript here. */\nexport class LocalAgentViewPort implements AgentViewPort {\n\treadonly agentKey: string;\n\treadonly transcript: AgentTranscriptView;\n\treadonly steering: AgentSteeringPort[\"steering\"];\n\tprivate readonly steeringPort: AgentSteeringPort;\n\tprivate readonly page: TaskAgentTranscriptPage;\n\tprivate readonly source: TaskViewSource;\n\tprivate readonly listeners = new Set<() => void>();\n\tprivate current: AgentViewStatus;\n\tprivate currentKey: string;\n\tprivate retained = 0;\n\tprivate disposed = false;\n\tprivate scheduled = false;\n\tprivate readonly unsubscribeSource: () => void;\n\tprivate readonly unwatch: () => void;\n\tprivate readonly isDismissed: ((taskId: TaskId) => boolean) | undefined;\n\tprivate readonly tick: ReturnType<typeof setInterval>;\n\n\tconstructor(options: LocalAgentViewOptions) {\n\t\tconst { source, env } = options;\n\t\tthis.source = source;\n\t\tthis.isDismissed = options.isDismissed;\n\t\tconst first = firstSubagentAttempt(source.tasks, options.taskId);\n\t\tthis.agentKey = first?.ref.taskId ?? options.taskId;\n\t\tconst requestRender = () => {\n\t\t\toptions.requestRender();\n\t\t\tthis.scheduleStatus();\n\t\t};\n\t\tthis.page = new TaskAgentTranscriptPage(\n\t\t\tsource,\n\t\t\toptions.taskId,\n\t\t\tenv,\n\t\t\trequestRender,\n\t\t\toptions.reportLate ?? ((reason) => env.notify?.(reason)),\n\t\t);\n\t\tthis.transcript = new AgentTranscriptView(this.page, env, options.rows ?? (() => 24));\n\t\tthis.current = this.readStatus();\n\t\tthis.currentKey = JSON.stringify(this.current);\n\t\tthis.steeringPort = createLocalAgentSteering({\n\t\t\tsource,\n\t\t\tliveTaskId: () => this.status().taskId,\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\t// The task list changed: a resumed attempt, a settled run, a removal. The page follows it as the inspector did.\n\t\tthis.unsubscribeSource = source.subscribe(() => {\n\t\t\tif (this.disposed) return;\n\t\t\tthis.page.refresh();\n\t\t\tthis.scheduleStatus();\n\t\t\toptions.requestRender();\n\t\t});\n\t\tthis.unwatch =\n\t\t\toptions.watch?.(() => {\n\t\t\t\tif (this.disposed) return;\n\t\t\t\tif (this.publishStatus()) options.requestRender();\n\t\t\t}) ?? (() => {});\n\t\tthis.tick = setInterval(() => {\n\t\t\tif (this.disposed) return;\n\t\t\tif (this.publishStatus()) options.requestRender();\n\t\t}, AGENT_VIEW_TICK_MS);\n\t\tthis.tick.unref?.();\n\t}\n\n\t/** Read the latest page; the first one is in before the screen shows the subagent. */\n\tload(): Promise<void> {\n\t\treturn this.page.load().then(() => {\n\t\t\tthis.publishStatus();\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 localAgentPrompts(this.source, this.status().taskId);\n\t}\n\n\tcommands(): Promise<AgentViewCommands | undefined> {\n\t\treturn localAgentCommands(this.source, this.status().taskId);\n\t}\n\n\tasync lastAgentMessageText(): Promise<string | undefined> {\n\t\treturn this.page.chat.lastAgentMessageText();\n\t}\n\n\t/** How many user messages its transcript received so far: it grows when a delivered message shows. */\n\tuserMessagesShown(): number {\n\t\treturn this.page.chat.userMessagesShown();\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\t/** Whether the subagent is an agent task this view lists. */\n\tstatic shows(source: TaskViewSource, taskId: TaskId): boolean {\n\t\treturn latestSubagentAttempt(source.tasks, taskId)?.kind === \"agent\";\n\t}\n\n\tprivate scheduleStatus(): void {\n\t\tif (this.scheduled || this.disposed) return;\n\t\tthis.scheduled = true;\n\t\tqueueMicrotask(() => {\n\t\t\tthis.scheduled = false;\n\t\t\tthis.publishStatus();\n\t\t});\n\t}\n\n\t/** Read the status again and tell the listeners when it changed. Answers whether it did. */\n\tprivate publishStatus(): boolean {\n\t\tif (this.disposed) return false;\n\t\tconst next = this.readStatus();\n\t\tconst key = JSON.stringify(next);\n\t\tif (key === this.currentKey) return false;\n\t\tthis.current = next;\n\t\tthis.currentKey = key;\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\treturn true;\n\t}\n\n\tprivate readStatus(): AgentViewStatus {\n\t\tconst status = this.page.viewStatus(this.agentKey);\n\t\treturn !status.gone && this.isDismissed?.(status.taskId) === true ? { ...status, gone: true } : status;\n\t}\n\n\tprivate dispose(): void {\n\t\tif (this.disposed) return;\n\t\tthis.disposed = true;\n\t\tclearInterval(this.tick);\n\t\tthis.unsubscribeSource();\n\t\tthis.unwatch();\n\t\tthis.listeners.clear();\n\t\tthis.page.dispose();\n\t}\n}\n\n/**\n * Open a port on the subagent `taskId` is an attempt of, once its first page is read: the screen never shows a\n * subagent before its transcript is there. Undefined when `source` lists no such agent task.\n */\nexport async function openLocalAgentViewPort(options: LocalAgentViewOptions): Promise<LocalAgentViewPort | undefined> {\n\tif (!LocalAgentViewPort.shows(options.source, options.taskId)) return undefined;\n\tconst port = new LocalAgentViewPort(options);\n\ttry {\n\t\tawait port.load();\n\t} catch (error) {\n\t\tport.retain()();\n\t\tthrow error;\n\t}\n\treturn port;\n}\n"]}
@@ -15,7 +15,8 @@ export declare const FIRST_FRAME_TIMEOUT_MS = 2000;
15
15
  export declare class RemoteAgentTranscript implements AgentTranscriptComponent {
16
16
  private readonly mount;
17
17
  private readonly heldPrompt;
18
- /** Rows of the engine's last frame above the rows shown, when it was taller than the area. */
18
+ /** How the frame painted last was placed in the rows shown (`PlacedTranscriptFrame`). */
19
+ private frameRows;
19
20
  private hidden;
20
21
  constructor(mount: RemoteTranscriptMount, heldPrompt: () => boolean);
21
22
  renderSized(width: number, height: number): string[];
@@ -25,6 +26,8 @@ export declare class RemoteAgentTranscript implements AgentTranscriptComponent {
25
26
  handleInput(data: string): void;
26
27
  handleMouse(event: TuiMouseEvent): TuiMouseEventResult | undefined;
27
28
  paintedRowKey(row: number): string | undefined;
29
+ /** The frame row painted at `row`: a row the host left blank until the next frame takes no click. */
30
+ private frameRow;
28
31
  invalidate(): void;
29
32
  }
30
33
  /** View `viewId` of the engine: its status as last reported, its transcript, and its steering. */
@@ -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;AACjH,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;AAE5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C,YAAY,CAAoB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmB;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAyB;IACnD,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,QAAQ,CAAK;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;IAElD,YAAY,OAAO,EAAE,gBAAgB,EAAE,IAAI,EAAE,iBAAiB,EAAE,KAAK,EAAE,qBAAqB,EAuB3F;IAED,MAAM,IAAI,eAAe,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;;;GAGG;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,GACpF,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAyB1C"}
@@ -1,4 +1,5 @@
1
1
  import { remoteTranscriptMount } from "../../interactive-engine/remote-component.js";
2
+ import { placeTranscriptFrame } from "../../interactive-engine/transcript-frame-layout.js";
2
3
  import { remoteAgentCommands } from "./agent-commands.js";
3
4
  import { remoteAgentPrompts } from "./agent-prompts.js";
4
5
  import { createRemoteAgentSteering } from "./agent-steering.js";
@@ -8,7 +9,8 @@ export const FIRST_FRAME_TIMEOUT_MS = 2_000;
8
9
  export class RemoteAgentTranscript {
9
10
  mount;
10
11
  heldPrompt;
11
- /** Rows of the engine's last frame above the rows shown, when it was taller than the area. */
12
+ /** How the frame painted last was placed in the rows shown (`PlacedTranscriptFrame`). */
13
+ frameRows;
12
14
  hidden = 0;
13
15
  constructor(mount, heldPrompt) {
14
16
  this.mount = mount;
@@ -16,11 +18,13 @@ export class RemoteAgentTranscript {
16
18
  }
17
19
  renderSized(width, height) {
18
20
  this.mount.rows = Math.max(1, height);
19
- const lines = this.mount.component.render(width);
20
- // A frame drawn for another height until the next one is here: keep its last rows, where the latest are.
21
- this.hidden = Math.max(0, lines.length - height);
22
- const shown = this.hidden > 0 ? lines.slice(this.hidden) : lines;
23
- return shown.length < height ? [...shown, ...Array.from({ length: height - shown.length }, () => "")] : shown;
21
+ const component = this.mount.component;
22
+ const lines = component.render(width);
23
+ // A frame drawn for another height until the next one is here: its rows go where that frame will put them.
24
+ const placed = placeTranscriptFrame(lines, component.paintedLayout(), width, height);
25
+ this.frameRows = placed.frameRows;
26
+ this.hidden = placed.hidden;
27
+ return placed.lines;
24
28
  }
25
29
  render(width) {
26
30
  return this.renderSized(width, this.mount.rows);
@@ -36,10 +40,20 @@ export class RemoteAgentTranscript {
36
40
  void this.mount.component.handleInput(data);
37
41
  }
38
42
  handleMouse(event) {
39
- return this.mount.component.handleMouse({ ...event, y: event.y + this.hidden });
43
+ const row = this.frameRow(event.y);
44
+ return row === undefined ? undefined : this.mount.component.handleMouse({ ...event, y: row });
40
45
  }
41
46
  paintedRowKey(row) {
42
- return this.mount.component.paintedRowKey(row + this.hidden);
47
+ const frameRow = this.frameRow(row);
48
+ return frameRow === undefined ? undefined : this.mount.component.paintedRowKey(frameRow);
49
+ }
50
+ /** The frame row painted at `row`: a row the host left blank until the next frame takes no click. */
51
+ frameRow(row) {
52
+ const frameRows = this.frameRows;
53
+ if (frameRows === undefined)
54
+ return row + this.hidden;
55
+ const index = Math.floor(row);
56
+ return index >= 0 && index < frameRows.length ? frameRows[index] : undefined;
43
57
  }
44
58
  invalidate() {
45
59
  this.mount.component.invalidate();