agent-relay 17.2.1 → 18.1.0

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 (251) hide show
  1. package/README.md +74 -266
  2. package/dist/cli/agent-relay-mcp.d.ts.map +1 -1
  3. package/dist/cli/agent-relay-mcp.js +6 -5
  4. package/dist/cli/agent-relay-mcp.js.map +1 -1
  5. package/dist/cli/bootstrap.d.ts +1 -1
  6. package/dist/cli/bootstrap.d.ts.map +1 -1
  7. package/dist/cli/bootstrap.js +11 -29
  8. package/dist/cli/bootstrap.js.map +1 -1
  9. package/dist/cli/commands/agent.d.ts.map +1 -1
  10. package/dist/cli/commands/agent.js +3 -2
  11. package/dist/cli/commands/agent.js.map +1 -1
  12. package/dist/cli/commands/cloud-integration.d.ts.map +1 -1
  13. package/dist/cli/commands/cloud-integration.js +2 -1
  14. package/dist/cli/commands/cloud-integration.js.map +1 -1
  15. package/dist/cli/commands/cloud-room.d.ts.map +1 -1
  16. package/dist/cli/commands/cloud-room.js +2 -1
  17. package/dist/cli/commands/cloud-room.js.map +1 -1
  18. package/dist/cli/commands/cloud-v1-deprecations.d.ts +4 -6
  19. package/dist/cli/commands/cloud-v1-deprecations.d.ts.map +1 -1
  20. package/dist/cli/commands/cloud-v1-deprecations.js +4 -6
  21. package/dist/cli/commands/cloud-v1-deprecations.js.map +1 -1
  22. package/dist/cli/commands/cloud-worker.d.ts +6 -2
  23. package/dist/cli/commands/cloud-worker.d.ts.map +1 -1
  24. package/dist/cli/commands/cloud-worker.js +74 -37
  25. package/dist/cli/commands/cloud-worker.js.map +1 -1
  26. package/dist/cli/commands/cloud.d.ts.map +1 -1
  27. package/dist/cli/commands/cloud.js +20 -18
  28. package/dist/cli/commands/cloud.js.map +1 -1
  29. package/dist/cli/commands/core.d.ts +3 -91
  30. package/dist/cli/commands/core.d.ts.map +1 -1
  31. package/dist/cli/commands/core.js +5 -254
  32. package/dist/cli/commands/core.js.map +1 -1
  33. package/dist/cli/commands/fleet-agent.d.ts +9 -54
  34. package/dist/cli/commands/fleet-agent.d.ts.map +1 -1
  35. package/dist/cli/commands/fleet-agent.js +105 -314
  36. package/dist/cli/commands/fleet-agent.js.map +1 -1
  37. package/dist/cli/commands/fleet.d.ts +0 -3
  38. package/dist/cli/commands/fleet.d.ts.map +1 -1
  39. package/dist/cli/commands/fleet.js +48 -267
  40. package/dist/cli/commands/fleet.js.map +1 -1
  41. package/dist/cli/commands/init.js +1 -1
  42. package/dist/cli/commands/init.js.map +1 -1
  43. package/dist/cli/commands/integration-cleanup-journal.d.ts +6 -2
  44. package/dist/cli/commands/integration-cleanup-journal.d.ts.map +1 -1
  45. package/dist/cli/commands/integration-cleanup-journal.js +611 -134
  46. package/dist/cli/commands/integration-cleanup-journal.js.map +1 -1
  47. package/dist/cli/commands/integration-recipient.d.ts +0 -17
  48. package/dist/cli/commands/integration-recipient.d.ts.map +1 -1
  49. package/dist/cli/commands/integration-recipient.js +1 -104
  50. package/dist/cli/commands/integration-recipient.js.map +1 -1
  51. package/dist/cli/commands/integration.d.ts +7 -3
  52. package/dist/cli/commands/integration.d.ts.map +1 -1
  53. package/dist/cli/commands/integration.js +37 -82
  54. package/dist/cli/commands/integration.js.map +1 -1
  55. package/dist/cli/commands/local-workflow.d.ts +1 -1
  56. package/dist/cli/commands/local-workflow.d.ts.map +1 -1
  57. package/dist/cli/commands/local-workflow.js +20 -6
  58. package/dist/cli/commands/local-workflow.js.map +1 -1
  59. package/dist/cli/commands/node.d.ts +18 -20
  60. package/dist/cli/commands/node.d.ts.map +1 -1
  61. package/dist/cli/commands/node.js +42 -272
  62. package/dist/cli/commands/node.js.map +1 -1
  63. package/dist/cli/commands/product-surfaces.js +2 -2
  64. package/dist/cli/commands/session.d.ts.map +1 -1
  65. package/dist/cli/commands/session.js +2 -1
  66. package/dist/cli/commands/session.js.map +1 -1
  67. package/dist/cli/commands/skills.d.ts.map +1 -1
  68. package/dist/cli/commands/skills.js +2 -1
  69. package/dist/cli/commands/skills.js.map +1 -1
  70. package/dist/cli/commands/status.d.ts +1 -7
  71. package/dist/cli/commands/status.d.ts.map +1 -1
  72. package/dist/cli/commands/status.js +2 -28
  73. package/dist/cli/commands/status.js.map +1 -1
  74. package/dist/cli/commands/workspace.d.ts.map +1 -1
  75. package/dist/cli/commands/workspace.js +2 -2
  76. package/dist/cli/commands/workspace.js.map +1 -1
  77. package/dist/cli/index.d.ts.map +1 -1
  78. package/dist/cli/index.js +1 -3
  79. package/dist/cli/index.js.map +1 -1
  80. package/dist/cli/lib/agent-relay-cli-reentry.d.ts +40 -0
  81. package/dist/cli/lib/agent-relay-cli-reentry.d.ts.map +1 -0
  82. package/dist/cli/lib/agent-relay-cli-reentry.js +47 -0
  83. package/dist/cli/lib/agent-relay-cli-reentry.js.map +1 -0
  84. package/dist/cli/lib/agent-tools-mcp.d.ts.map +1 -1
  85. package/dist/cli/lib/agent-tools-mcp.js +3 -2
  86. package/dist/cli/lib/agent-tools-mcp.js.map +1 -1
  87. package/dist/cli/lib/cloud-worker-authored-runtime.d.ts +3 -0
  88. package/dist/cli/lib/cloud-worker-authored-runtime.d.ts.map +1 -0
  89. package/dist/cli/lib/cloud-worker-authored-runtime.js +67 -0
  90. package/dist/cli/lib/cloud-worker-authored-runtime.js.map +1 -0
  91. package/dist/cli/lib/cloud-worker-enrollment-token.d.ts +13 -0
  92. package/dist/cli/lib/cloud-worker-enrollment-token.d.ts.map +1 -0
  93. package/dist/cli/lib/cloud-worker-enrollment-token.js +88 -0
  94. package/dist/cli/lib/cloud-worker-enrollment-token.js.map +1 -0
  95. package/dist/cli/lib/core-maintenance.d.ts +2 -3
  96. package/dist/cli/lib/core-maintenance.d.ts.map +1 -1
  97. package/dist/cli/lib/core-maintenance.js +3 -37
  98. package/dist/cli/lib/core-maintenance.js.map +1 -1
  99. package/dist/cli/lib/desktop-presence.js +1 -1
  100. package/dist/cli/lib/desktop-presence.js.map +1 -1
  101. package/dist/cli/lib/install-paths.d.ts +100 -0
  102. package/dist/cli/lib/install-paths.d.ts.map +1 -0
  103. package/dist/cli/lib/install-paths.js +157 -0
  104. package/dist/cli/lib/install-paths.js.map +1 -0
  105. package/dist/cli/lib/product-surface-store.d.ts.map +1 -1
  106. package/dist/cli/lib/product-surface-store.js +4 -1
  107. package/dist/cli/lib/product-surface-store.js.map +1 -1
  108. package/dist/cli/lib/relay-node.d.ts +7 -34
  109. package/dist/cli/lib/relay-node.d.ts.map +1 -1
  110. package/dist/cli/lib/relay-node.js +7 -182
  111. package/dist/cli/lib/relay-node.js.map +1 -1
  112. package/dist/cli/lib/removed-broker-command.d.ts +7 -0
  113. package/dist/cli/lib/removed-broker-command.d.ts.map +1 -0
  114. package/dist/cli/lib/removed-broker-command.js +13 -0
  115. package/dist/cli/lib/removed-broker-command.js.map +1 -0
  116. package/dist/cli/lib/sdk-client.d.ts +4 -4
  117. package/dist/cli/lib/sdk-client.js +4 -4
  118. package/dist/cli/lib/self-update.d.ts +8 -19
  119. package/dist/cli/lib/self-update.d.ts.map +1 -1
  120. package/dist/cli/lib/self-update.js +14 -28
  121. package/dist/cli/lib/self-update.js.map +1 -1
  122. package/dist/cli/lib/skills-install.d.ts.map +1 -1
  123. package/dist/cli/lib/skills-install.js +3 -2
  124. package/dist/cli/lib/skills-install.js.map +1 -1
  125. package/dist/cli/telemetry/events.d.ts +4 -1
  126. package/dist/cli/telemetry/events.d.ts.map +1 -1
  127. package/package.json +9 -14
  128. package/dist/auto/classifier.d.ts +0 -29
  129. package/dist/auto/classifier.d.ts.map +0 -1
  130. package/dist/auto/classifier.js +0 -126
  131. package/dist/auto/classifier.js.map +0 -1
  132. package/dist/auto/composer.d.ts +0 -105
  133. package/dist/auto/composer.d.ts.map +0 -1
  134. package/dist/auto/composer.js +0 -454
  135. package/dist/auto/composer.js.map +0 -1
  136. package/dist/auto/director-prompt.d.ts +0 -25
  137. package/dist/auto/director-prompt.d.ts.map +0 -1
  138. package/dist/auto/director-prompt.js +0 -53
  139. package/dist/auto/director-prompt.js.map +0 -1
  140. package/dist/auto/index.d.ts +0 -15
  141. package/dist/auto/index.d.ts.map +0 -1
  142. package/dist/auto/index.js +0 -13
  143. package/dist/auto/index.js.map +0 -1
  144. package/dist/cli/commands/local-agent.d.ts +0 -74
  145. package/dist/cli/commands/local-agent.d.ts.map +0 -1
  146. package/dist/cli/commands/local-agent.js +0 -969
  147. package/dist/cli/commands/local-agent.js.map +0 -1
  148. package/dist/cli/lib/attach-broker.d.ts +0 -17
  149. package/dist/cli/lib/attach-broker.d.ts.map +0 -1
  150. package/dist/cli/lib/attach-broker.js +0 -27
  151. package/dist/cli/lib/attach-broker.js.map +0 -1
  152. package/dist/cli/lib/attach-drive.d.ts +0 -376
  153. package/dist/cli/lib/attach-drive.d.ts.map +0 -1
  154. package/dist/cli/lib/attach-drive.js +0 -1212
  155. package/dist/cli/lib/attach-drive.js.map +0 -1
  156. package/dist/cli/lib/attach-fleet-node.d.ts +0 -85
  157. package/dist/cli/lib/attach-fleet-node.d.ts.map +0 -1
  158. package/dist/cli/lib/attach-fleet-node.js +0 -1347
  159. package/dist/cli/lib/attach-fleet-node.js.map +0 -1
  160. package/dist/cli/lib/attach-input-recovery.d.ts +0 -190
  161. package/dist/cli/lib/attach-input-recovery.d.ts.map +0 -1
  162. package/dist/cli/lib/attach-input-recovery.js +0 -559
  163. package/dist/cli/lib/attach-input-recovery.js.map +0 -1
  164. package/dist/cli/lib/attach-mode.d.ts +0 -2
  165. package/dist/cli/lib/attach-mode.d.ts.map +0 -1
  166. package/dist/cli/lib/attach-mode.js +0 -2
  167. package/dist/cli/lib/attach-mode.js.map +0 -1
  168. package/dist/cli/lib/attach-native.d.ts +0 -27
  169. package/dist/cli/lib/attach-native.d.ts.map +0 -1
  170. package/dist/cli/lib/attach-native.js +0 -267
  171. package/dist/cli/lib/attach-native.js.map +0 -1
  172. package/dist/cli/lib/attach-passthrough.d.ts +0 -193
  173. package/dist/cli/lib/attach-passthrough.d.ts.map +0 -1
  174. package/dist/cli/lib/attach-passthrough.js +0 -778
  175. package/dist/cli/lib/attach-passthrough.js.map +0 -1
  176. package/dist/cli/lib/attach-remote-node.d.ts +0 -21
  177. package/dist/cli/lib/attach-remote-node.d.ts.map +0 -1
  178. package/dist/cli/lib/attach-remote-node.js +0 -133
  179. package/dist/cli/lib/attach-remote-node.js.map +0 -1
  180. package/dist/cli/lib/attach-view.d.ts +0 -177
  181. package/dist/cli/lib/attach-view.d.ts.map +0 -1
  182. package/dist/cli/lib/attach-view.js +0 -455
  183. package/dist/cli/lib/attach-view.js.map +0 -1
  184. package/dist/cli/lib/attach.d.ts +0 -555
  185. package/dist/cli/lib/attach.d.ts.map +0 -1
  186. package/dist/cli/lib/attach.js +0 -1180
  187. package/dist/cli/lib/attach.js.map +0 -1
  188. package/dist/cli/lib/broker-connection.d.ts +0 -65
  189. package/dist/cli/lib/broker-connection.d.ts.map +0 -1
  190. package/dist/cli/lib/broker-connection.js +0 -144
  191. package/dist/cli/lib/broker-connection.js.map +0 -1
  192. package/dist/cli/lib/broker-lifecycle.d.ts +0 -220
  193. package/dist/cli/lib/broker-lifecycle.d.ts.map +0 -1
  194. package/dist/cli/lib/broker-lifecycle.js +0 -2290
  195. package/dist/cli/lib/broker-lifecycle.js.map +0 -1
  196. package/dist/cli/lib/broker-process-identity.d.ts +0 -38
  197. package/dist/cli/lib/broker-process-identity.d.ts.map +0 -1
  198. package/dist/cli/lib/broker-process-identity.js +0 -304
  199. package/dist/cli/lib/broker-process-identity.js.map +0 -1
  200. package/dist/cli/lib/client-factory.d.ts +0 -44
  201. package/dist/cli/lib/client-factory.d.ts.map +0 -1
  202. package/dist/cli/lib/client-factory.js +0 -64
  203. package/dist/cli/lib/client-factory.js.map +0 -1
  204. package/dist/cli/lib/collect-with-retry.d.ts +0 -24
  205. package/dist/cli/lib/collect-with-retry.d.ts.map +0 -1
  206. package/dist/cli/lib/collect-with-retry.js +0 -33
  207. package/dist/cli/lib/collect-with-retry.js.map +0 -1
  208. package/dist/cli/lib/fleet-attach-target.d.ts +0 -18
  209. package/dist/cli/lib/fleet-attach-target.d.ts.map +0 -1
  210. package/dist/cli/lib/fleet-attach-target.js +0 -57
  211. package/dist/cli/lib/fleet-attach-target.js.map +0 -1
  212. package/dist/cli/lib/fleet-hint.d.ts +0 -49
  213. package/dist/cli/lib/fleet-hint.d.ts.map +0 -1
  214. package/dist/cli/lib/fleet-hint.js +0 -113
  215. package/dist/cli/lib/fleet-hint.js.map +0 -1
  216. package/dist/cli/lib/fleet-sidecar.d.ts +0 -43
  217. package/dist/cli/lib/fleet-sidecar.d.ts.map +0 -1
  218. package/dist/cli/lib/fleet-sidecar.js +0 -84
  219. package/dist/cli/lib/fleet-sidecar.js.map +0 -1
  220. package/dist/cli/lib/join-ticket.d.ts +0 -22
  221. package/dist/cli/lib/join-ticket.d.ts.map +0 -1
  222. package/dist/cli/lib/join-ticket.js +0 -96
  223. package/dist/cli/lib/join-ticket.js.map +0 -1
  224. package/dist/cli/lib/node-claim.d.ts +0 -468
  225. package/dist/cli/lib/node-claim.d.ts.map +0 -1
  226. package/dist/cli/lib/node-claim.js +0 -1349
  227. package/dist/cli/lib/node-claim.js.map +0 -1
  228. package/dist/cli/lib/node-definition-loader.d.ts +0 -19
  229. package/dist/cli/lib/node-definition-loader.d.ts.map +0 -1
  230. package/dist/cli/lib/node-definition-loader.js +0 -143
  231. package/dist/cli/lib/node-definition-loader.js.map +0 -1
  232. package/dist/cli/lib/node-provider-child.d.ts +0 -129
  233. package/dist/cli/lib/node-provider-child.d.ts.map +0 -1
  234. package/dist/cli/lib/node-provider-child.js +0 -755
  235. package/dist/cli/lib/node-provider-child.js.map +0 -1
  236. package/dist/cli/lib/predictive-echo-screen.d.ts +0 -48
  237. package/dist/cli/lib/predictive-echo-screen.d.ts.map +0 -1
  238. package/dist/cli/lib/predictive-echo-screen.js +0 -74
  239. package/dist/cli/lib/predictive-echo-screen.js.map +0 -1
  240. package/dist/cli/lib/project-broker-client.d.ts +0 -4
  241. package/dist/cli/lib/project-broker-client.d.ts.map +0 -1
  242. package/dist/cli/lib/project-broker-client.js +0 -12
  243. package/dist/cli/lib/project-broker-client.js.map +0 -1
  244. package/dist/cli/lib/reflex-capture.d.ts +0 -41
  245. package/dist/cli/lib/reflex-capture.d.ts.map +0 -1
  246. package/dist/cli/lib/reflex-capture.js +0 -128
  247. package/dist/cli/lib/reflex-capture.js.map +0 -1
  248. package/dist/cli/lib/workspace-env.d.ts +0 -8
  249. package/dist/cli/lib/workspace-env.d.ts.map +0 -1
  250. package/dist/cli/lib/workspace-env.js +0 -16
  251. package/dist/cli/lib/workspace-env.js.map +0 -1
@@ -1,555 +0,0 @@
1
- /**
2
- * Shared helpers for attach-style CLI commands (`view`, `drive`,
3
- * `passthrough`).
4
- *
5
- * - `captureAndRenderSnapshot` renders the agent's current visible screen
6
- * so the user doesn't attach to a quiet agent and stare at a blank
7
- * terminal until the next output.
8
- * - `prepareAttachTarget` / `pickInitialTerminalRows` / `syncInitialPtySize`
9
- * / `switchInboundDeliveryModeOrAbort` / `captureInitialSnapshot` are
10
- * the take-over prep steps that `drive` and `passthrough` both run on
11
- * attach; centralised here so the two verbs stay in lockstep.
12
- */
13
- import type { InboundDeliveryMode } from '@agent-relay/harness-driver';
14
- import { type BrokerConnection, type BrokerConnectionDeps, type BrokerConnectionOptions } from './broker-connection.js';
15
- /** Connection metadata used to call the broker's snapshot endpoint. */
16
- export interface AttachSnapshotConnection {
17
- /** Broker base URL (no trailing slash). */
18
- url: string;
19
- /** Optional API key — added as an `X-API-Key` header if present. */
20
- apiKey?: string;
21
- /** Optional HTTP deadline propagated to the broker SDK transport. */
22
- requestTimeoutMs?: number;
23
- }
24
- /** Dependencies for `captureAndRenderSnapshot` — injected so tests don't hit
25
- * the network. */
26
- export interface AttachSnapshotDeps {
27
- /** Native `fetch` by default; swapped out by tests. */
28
- fetch: typeof globalThis.fetch;
29
- /** Where the ANSI bytes get written. Typically `process.stdout.write`. */
30
- writeChunk: (chunk: string) => void;
31
- /**
32
- * Optional best-effort workspace lookup. When the local broker returns 404
33
- * for an agent, `fleetHint` is called with the agent name and may return a
34
- * placement description like `"on node 'finn-mini'"` to produce a more
35
- * actionable error message. If it returns `null` or is not provided, the
36
- * original "no agent named 'X'" message is used.
37
- */
38
- fleetHint?: (name: string) => Promise<string | null>;
39
- }
40
- /** Outcome of a snapshot capture. Callers decide whether to bail or continue
41
- * on each variant — `view` aborts on `not_found` / `no_pty`, warns and
42
- * continues on `unavailable` / `transport_error`. */
43
- export interface AttachSnapshotResult {
44
- status: 'ok' | 'not_found' | 'no_pty' | 'unavailable' | 'transport_error';
45
- /** Grid dimensions as reported by the broker, if the call succeeded. */
46
- rows?: number;
47
- cols?: number;
48
- /** Cursor position `[row, col]`, 1-indexed, if the call succeeded. */
49
- cursor?: [number, number];
50
- /**
51
- * Cumulative per-worker byte offset the grid had consumed when the
52
- * snapshot was captured. Used to reconcile the snapshot against buffered
53
- * `worker_stream` chunks (drop `offset <= this`, apply the rest).
54
- * `undefined` on brokers that predate stream-offset support.
55
- */
56
- offset?: number;
57
- /** Human-readable detail for error variants. */
58
- message?: string;
59
- }
60
- /**
61
- * Fetch a worker's current visible screen as ANSI reproduction bytes and
62
- * write them to the caller's output.
63
- *
64
- * The attach clients open and subscribe to the WebSocket event stream
65
- * *first*, buffer incoming `worker_stream` chunks, then call this to paint
66
- * the snapshot, and finally reconcile the buffer against the snapshot's
67
- * `offset` (see {@link StreamSyncBuffer}). That ordering closes the gap
68
- * between the snapshot and the live stream: no output emitted around attach
69
- * time is lost, and the per-worker byte offset lets the client drop exactly
70
- * the chunks the snapshot already reflects so nothing is double-applied.
71
- *
72
- * On brokers that don't report an `offset`, the clients fall back to
73
- * snapshot-authoritative behaviour (paint the snapshot, discard chunks that
74
- * arrived before it), which trades a tiny gap for no duplication — the same
75
- * bias the pre-offset code had.
76
- *
77
- * @returns A status describing the outcome. `ok` means the screen was
78
- * rendered; other variants carry a message the caller can surface. `offset`
79
- * is populated on `ok` when the broker reports one.
80
- */
81
- export declare function captureAndRenderSnapshot(connection: AttachSnapshotConnection, agentName: string, deps: AttachSnapshotDeps): Promise<AttachSnapshotResult>;
82
- /**
83
- * Reconciles a visible-screen snapshot with the live `worker_stream` byte
84
- * stream so an attaching client neither loses nor double-applies output
85
- * around attach time.
86
- *
87
- * Usage (subscribe-first):
88
- *
89
- * 1. Open + subscribe the event WS. Feed every `worker_stream` chunk to
90
- * {@link push} as it arrives, applying the chunk only when `push`
91
- * returns `true`.
92
- * 2. Fetch and paint the snapshot.
93
- * 3. Call {@link reconcile} with the snapshot's `offset`. Apply the
94
- * returned chunks in order. From then on, `push` returns `true` for
95
- * every chunk (live pass-through).
96
- *
97
- * Correlation rule: the snapshot reflects every byte with offset `<=`
98
- * `snapshotOffset`. A buffered chunk carries the cumulative byte offset at
99
- * its *end*; if that end offset is `<=` the snapshot offset the chunk is
100
- * already on screen and is dropped, otherwise it is applied.
101
- *
102
- * The snapshot offset is retained as a post-reconcile *watermark*: once
103
- * buffering ends, {@link push} keeps suppressing any live frame whose end
104
- * offset is `<=` the watermark. This closes a broker-side race — the PTY
105
- * reader advances `consumed_offset` and the grid *before* the decoded chunk
106
- * reaches the broadcast queue, so a chunk with `offset <= snapshotOffset`
107
- * can still arrive *after* the client reconciles. Offsets are cumulative and
108
- * monotonic, so the watermark drops exactly those already-painted stragglers
109
- * without touching genuinely new output.
110
- */
111
- export declare class StreamSyncBuffer {
112
- private buffering;
113
- private readonly buffered;
114
- /**
115
- * Post-reconcile suppression watermark: the snapshot offset the grid had
116
- * already painted. `undefined` until {@link reconcile} runs with a defined
117
- * offset (or forever, on brokers without offset support / after
118
- * {@link flushAll}), in which case no post-reconcile suppression happens.
119
- */
120
- private watermark;
121
- /**
122
- * Record a live `worker_stream` chunk. Returns `true` when the caller
123
- * should apply the chunk immediately, `false` when the chunk must be held
124
- * or dropped. While buffering, the chunk is retained for {@link reconcile}.
125
- * After reconcile, a chunk whose end offset is `<=` the snapshot watermark
126
- * is a late-arriving straggler the snapshot already painted and is
127
- * suppressed (see the class docstring's race note); everything else passes
128
- * through live.
129
- */
130
- push(chunk: string, offset: number | undefined): boolean;
131
- /**
132
- * Reconcile the buffered chunks against the painted snapshot's offset and
133
- * return the chunks to apply, in order. Switches to live pass-through and
134
- * arms the post-reconcile watermark (see {@link push}).
135
- *
136
- * When `snapshotOffset` is `undefined` (broker without offset support) all
137
- * buffered chunks are discarded: they arrived before the snapshot was
138
- * painted, so dropping them matches the snapshot-authoritative fallback
139
- * and avoids double-painting what the snapshot already shows. No watermark
140
- * is armed in that case — there is no offset to compare live frames to.
141
- */
142
- reconcile(snapshotOffset: number | undefined): string[];
143
- /**
144
- * Return every buffered chunk unchanged and switch to live pass-through.
145
- * Used when no snapshot was painted (transient snapshot failure): there is
146
- * nothing to reconcile against, so applying everything preserves output
147
- * rather than dropping the buffered live stream.
148
- */
149
- flushAll(): string[];
150
- /** True while chunks are still being buffered (before reconcile). */
151
- get isBuffering(): boolean;
152
- }
153
- /**
154
- * Conservative terminal-reset control sequence emitted on detach (see #1247).
155
- *
156
- * A drive/view/passthrough session paints the agent's snapshot (which now
157
- * re-emits terminal modes) and then relays the live stream, either of which can
158
- * leave the *local* terminal in application-cursor-keys, mouse-reporting,
159
- * bracketed-paste, or alt-screen mode. Without a reset on detach the user is
160
- * dropped back to their shell with arrows emitting escape codes, mouse clicks
161
- * spewing coordinates, or a blank alt screen.
162
- *
163
- * The sequence is intentionally direction-explicit and idempotent. Ordering is
164
- * load-bearing (see #1251): a few of these controls move the cursor, and
165
- * `\x1b[?1049l` (leave alt screen) *restores* the main-buffer cursor that was
166
- * saved on alt-screen entry. Anything that homes the cursor must therefore run
167
- * *before* the alt-screen leave, or it clobbers that restored position and the
168
- * next shell prompt lands at top-left. Two controls home the cursor:
169
- *
170
- * - `\x1b[r` (DECSTBM scroll-region reset) homes the cursor on xterm/DEC-style
171
- * terminals. The scroll-region margins are shared terminal state, so
172
- * resetting them while still in the alt buffer heals a stale region and the
173
- * homing is harmless (the pending `?1049l` restore supersedes it).
174
- * - `\x1b[?6l` (DECOM origin-mode reset) also moves the cursor to home per the
175
- * DEC spec, so it belongs in the same pre-leave group.
176
- *
177
- * Everything after the alt-screen leave is position-independent (mode flags
178
- * that never move the cursor): show cursor, application cursor keys off,
179
- * autowrap on, every mouse-reporting mode off, bracketed paste off, numeric
180
- * keypad, and a final SGR reset. Only written when stdout is a TTY, consistent
181
- * with how the sessions gate raw-mode restore and the status line.
182
- */
183
- export declare const LOCAL_TERMINAL_RESET_SEQUENCE: string;
184
- /**
185
- * Emit {@link LOCAL_TERMINAL_RESET_SEQUENCE} to the local terminal on detach,
186
- * but only when stdout is a TTY. A no-op for piped/redirected stdout so the
187
- * reset never corrupts a captured log.
188
- */
189
- export declare function resetLocalTerminalOnDetach(write: (chunk: string) => void, isTty: boolean): void;
190
- /** ----- Interactive attach prep helpers ----- */
191
- /** Validated attach target: trimmed agent name + resolved broker connection. */
192
- export interface AttachTarget {
193
- name: string;
194
- connection: BrokerConnection;
195
- }
196
- /** Dependencies for `prepareAttachTarget` — connection lookup + error sink. */
197
- export interface PrepareAttachTargetDeps extends BrokerConnectionDeps {
198
- error: (...args: unknown[]) => void;
199
- }
200
- /**
201
- * Trim the agent name and resolve the broker connection (flag → env →
202
- * `connection.json`). Writes the appropriate error and returns `null` on
203
- * either failure so every interactive attach verb rejects empty or
204
- * unreachable targets consistently.
205
- */
206
- export declare function prepareAttachTarget(agentName: string, options: BrokerConnectionOptions, deps: PrepareAttachTargetDeps): AttachTarget | null;
207
- /**
208
- * Pick the status-line row. Prefers the LOCAL terminal's height (the
209
- * status line must land where the human is looking) and falls back to
210
- * the snapshot's PTY rows, then `undefined` so the renderer applies its
211
- * own default.
212
- */
213
- export declare function pickInitialTerminalRows(localSize: {
214
- rows: number;
215
- cols: number;
216
- } | null, snapshotRows: number | undefined): number | undefined;
217
- /**
218
- * Pick the status-line width. Same precedence as
219
- * {@link pickInitialTerminalRows} — the LOCAL terminal wins, because the
220
- * status line has to fit the pane the human is looking at, not the agent's
221
- * PTY.
222
- */
223
- export declare function pickInitialTerminalCols(localSize: {
224
- rows: number;
225
- cols: number;
226
- } | null, snapshotCols: number | undefined): number | undefined;
227
- /** Width assumed when the local terminal never reported one. */
228
- export declare const DEFAULT_STATUS_LINE_COLS = 80;
229
- /**
230
- * Clamp a status-line label to the terminal width.
231
- *
232
- * The interactive verbs paint their status line at the bottom row inside an
233
- * `ESC 7` / `ESC 8` (DECSC/DECRC) pair. That is only safe while the text
234
- * *fits*: a label wider than the pane wraps past the last row, which scrolls
235
- * the screen. Because the label is painted on the bottom row, every repaint
236
- * then scrolls again — promoting the previous status line into the scrollback
237
- * as content and eating one row of the agent's output each time. A narrow
238
- * pane therefore turns a single status line into a growing stack of them with
239
- * the agent's TUI shredded behind it. The `drive` label is 87 columns, so this
240
- * fired on a standard 80-column terminal too; at 66 columns six repaints cost
241
- * six rows of agent output.
242
- *
243
- * Truncation keeps the paint inside one row, so the wrap — and the scroll
244
- * cascade it triggers — can never happen. Callers painting a terminal row can
245
- * reserve the final column as well, avoiding the emulator's wrap-pending state.
246
- * The tail is the part that carries the key hints, so an over-long label is
247
- * trimmed from the *middle*: the verb and agent name stay readable and the
248
- * `Ctrl+…` hints survive.
249
- *
250
- * Measured in display columns, not UTF-16 code units: an agent name carrying
251
- * CJK or emoji is double-width, so a code-unit count would pass a label that
252
- * still wraps — re-arming the exact cascade this prevents. Slicing is done on
253
- * whole code points so a surrogate pair is never split in half.
254
- */
255
- export declare function clampStatusLineText(text: string, cols: number | undefined, reserveFinalColumn?: boolean): string;
256
- /**
257
- * Reserve the local terminal's final row for an attach status line.
258
- *
259
- * Full-screen CLIs treat every PTY row as application-owned. If the remote PTY
260
- * is resized to the local terminal's full height and Relay then paints a status
261
- * line over its final row, both renderers continually overwrite each other.
262
- * The result is the duplicated status text and torn TUI frames seen in drive
263
- * and passthrough sessions. Give the child one fewer row and column: the row
264
- * prevents cursor-addressed overlap, while the spare column prevents terminal
265
- * autowrap from stepping past the child scroll margin into Relay's row.
266
- */
267
- export declare function reserveStatusLineRow(localSize: {
268
- rows: number;
269
- cols: number;
270
- } | null): {
271
- rows: number;
272
- cols: number;
273
- } | null;
274
- /** Whether a terminal is large enough to dedicate a non-wrapping status row. */
275
- export declare function canReserveStatusLine(localSize: {
276
- rows: number;
277
- cols: number;
278
- } | null): localSize is {
279
- rows: number;
280
- cols: number;
281
- };
282
- /**
283
- * Constrain local scrolling to the child PTY's rows while preserving the
284
- * current cursor. DECSTBM otherwise defaults to the physical terminal height,
285
- * which includes Relay's status row.
286
- */
287
- export declare function renderChildScrollRegion(rows: number): string;
288
- export declare function fitStatusLineText(text: string, columns: number | undefined): string;
289
- /**
290
- * Sync the agent's PTY to the driver's local terminal size. tmux /
291
- * screen / ssh all do this — without it a TUI in the agent renders into
292
- * the size the PTY was spawned with, ignoring the human's viewport.
293
- * Best-effort: a failure is annoying but not fatal. Skipped entirely
294
- * when `localSize` is `null` (stdout isn't a TTY).
295
- */
296
- export declare function syncInitialPtySize(connection: BrokerConnection, name: string, localSize: {
297
- rows: number;
298
- cols: number;
299
- } | null, verb: string, deps: {
300
- fetch: typeof globalThis.fetch;
301
- log: (...args: unknown[]) => void;
302
- }, options?: {
303
- sessionId?: string;
304
- }): Promise<boolean>;
305
- /**
306
- * Read the worker's prior inbound delivery mode and flip it to
307
- * `targetMode`. Returns the previous mode on success so the caller can
308
- * restore it on detach; returns `null` (and writes an error) when the
309
- * request fails or the broker reports that the requested transition did not
310
- * complete, so the caller bails before touching the terminal.
311
- *
312
- * Non-404 errors are surfaced as `Error: could not ${actionPhrase}:
313
- * ${message}` so callers pass verb-appropriate wording (e.g. "switch to
314
- * manual_flush mode" or "ensure passthrough session"). 404s get a
315
- * uniform "no agent named X" message.
316
- */
317
- export declare function switchInboundDeliveryModeOrAbort(connection: BrokerConnection, name: string, targetMode: InboundDeliveryMode, actionPhrase: string, deps: {
318
- fetch: typeof globalThis.fetch;
319
- error: (...args: unknown[]) => void;
320
- /** Optional best-effort fleet placement lookup, same contract as {@link AttachSnapshotDeps.fleetHint}. */
321
- fleetHint?: (name: string) => Promise<string | null>;
322
- }): Promise<{
323
- previousMode: InboundDeliveryMode | null;
324
- sessionRevision: string | null;
325
- } | null>;
326
- /**
327
- * Upper bound (ms) on the best-effort detach teardown — resize-ownership
328
- * release and inbound-delivery-mode restore. Both are HTTP round-trips to the
329
- * broker that can stall if the broker is down; the terminal must still exit
330
- * promptly, so `finish()` resolves the exit code once these settle *or* this
331
- * deadline elapses, whichever comes first. The broker's idle-takeover net
332
- * still frees any ownership left behind.
333
- */
334
- export declare const DETACH_CLEANUP_DEADLINE_MS = 2000;
335
- /**
336
- * Best-effort restore of a worker's inbound delivery mode on detach.
337
- *
338
- * Two hazards this guards against (see #1247):
339
- *
340
- * 1. Concurrent-change race — a second session attaching while this one is
341
- * active would read *this* session's mode as the "previous" one, so blindly
342
- * writing `previousMode` back on detach can clobber a change another
343
- * session/CLI made in the meantime. We restore via the broker's atomic
344
- * compare-and-set (`expectedMode: sessionMode`): the broker applies
345
- * `previousMode` only if the worker's current mode still equals what *this*
346
- * session set, and no-ops (`matched: false`) otherwise. This removes the
347
- * read-then-set TOCTOU a client-side re-read still had (a change landing
348
- * between the read and the restore PUT).
349
- * 2. Failed initial read — when the pre-attach mode was never learned
350
- * (`previousMode === null`), forcing a default (`auto_inject`) would
351
- * silently cancel an explicit `agent message hold`. In that case we leave
352
- * the mode untouched and warn.
353
- *
354
- * The broker's monotonic mode revision closes ABA races where another session
355
- * changes the mode away and back to `sessionMode` before this restore.
356
- */
357
- export declare function restoreInboundDeliveryModeOnDetach(connection: BrokerConnection, name: string, previousMode: InboundDeliveryMode | null, sessionMode: InboundDeliveryMode, sessionRevision: string | null, verb: string, deps: {
358
- fetch: typeof globalThis.fetch;
359
- log: (...args: unknown[]) => void;
360
- }): Promise<void>;
361
- /**
362
- * Streaming scanner that tracks whether a byte stream currently *ends* inside
363
- * an incomplete ANSI escape sequence (ESC, CSI, OSC, or DCS/SOS/PM/APC string).
364
- *
365
- * The attach status line wraps its repaint in cursor save/restore controls;
366
- * splicing that in while the agent is mid-transmission of its own CSI sequence
367
- * corrupts the agent's output. Feeding every server chunk through this scanner
368
- * lets the status painter hold its repaint until the stream is back at a
369
- * sequence boundary. State persists across chunks (a sequence may span several
370
- * `worker_stream` frames).
371
- *
372
- * Only ASCII control bytes drive the state machine; multi-byte UTF-8 payload
373
- * bytes are printable in the ground state and never appear inside a CSI/escape
374
- * sequence, so scanning UTF-16 code units is safe here.
375
- */
376
- export declare class AnsiBoundaryScanner {
377
- private state;
378
- push(chunk: string): void;
379
- reset(): void;
380
- /** True when the stream ends at a safe boundary (not mid-sequence). */
381
- get atBoundary(): boolean;
382
- private step;
383
- }
384
- /**
385
- * Detect terminal controls that can erase or replace Relay's reserved status
386
- * row even though the child PTY itself is one row shorter.
387
- *
388
- * Cursor-addressed TUI drawing stays inside the child grid, but erase-display,
389
- * terminal reset, and alternate-screen switches act on the local terminal as a
390
- * whole. Attach clients reinstall their child scroll region after those
391
- * operations; the status controller separately repaints at a safe ANSI
392
- * boundary. A short carry handles controls split across WS frames.
393
- */
394
- export declare class StatusLineInvalidationScanner {
395
- private carry;
396
- push(chunk: string): boolean;
397
- }
398
- /** Track the child application's active DECSTBM margins across streamed ANSI. */
399
- export declare class TerminalScrollRegionTracker {
400
- private parserState;
401
- private csiParams;
402
- private csiSupported;
403
- private stringAllowsBel;
404
- private rows;
405
- private top;
406
- private bottom;
407
- private originMode;
408
- private alternateActive;
409
- private primaryRegion;
410
- private alternateRegion;
411
- constructor(rows: number);
412
- setRows(rows: number): void;
413
- push(chunk: string): void;
414
- get region(): {
415
- top: number;
416
- bottom: number;
417
- };
418
- get isOriginMode(): boolean;
419
- private consumeCharacter;
420
- private consumeString;
421
- private consumeStringEscape;
422
- private consumeGround;
423
- private consumeEscape;
424
- private beginCsi;
425
- private beginString;
426
- private consumeCsi;
427
- private applyCsi;
428
- private applyPrivateModes;
429
- private resetTrackedState;
430
- private switchScreenBuffer;
431
- }
432
- /** Options for {@link StatusLineController}. Timers are injectable for tests. */
433
- export interface StatusLineControllerOptions {
434
- /** Produce the current status-line ANSI string. */
435
- render: () => string;
436
- /** Write to stdout. */
437
- write: (chunk: string) => void;
438
- /** When false (stdout is not a TTY) the status line is never painted. */
439
- enabled: boolean | (() => boolean);
440
- /**
441
- * Minimum ms between repaints. `0` paints on every request (no coalescing);
442
- * a positive value coalesces bursts of per-chunk repaints into at most one
443
- * paint per window, shrinking the splice/DECSC-clobber window.
444
- */
445
- coalesceMs: number;
446
- setTimer?: (fn: () => void, ms: number) => ReturnType<typeof setTimeout>;
447
- clearTimer?: (t: ReturnType<typeof setTimeout>) => void;
448
- now?: () => number;
449
- }
450
- /**
451
- * Coordinates status-line repaints for the interactive attach clients.
452
- *
453
- * Correctness properties (see #1247):
454
- * - **Non-TTY skip** — when `enabled` is false, nothing is ever written.
455
- * - **Boundary-hold** — a repaint is deferred while the observed output ends
456
- * mid ANSI escape sequence, so the status line never splices into a
457
- * half-transmitted CSI. It paints only after a later chunk returns the
458
- * stream to a real boundary.
459
- * - **Coalescing** — repaints are rate-limited to at most one per
460
- * `coalesceMs`, shrinking the window in which our save/restore-cursor wrap
461
- * can clobber the agent's own pending DECSC.
462
- * - **Teardown-safe** — after {@link dispose} no further writes happen.
463
- *
464
- * Residual risk (documented): ESC 7/ESC 8 (and CSI s/u) share a single
465
- * saved-cursor slot on many terminals, so a repaint landing between the
466
- * agent's DECSC and DECRC can still restore to the wrong spot. Boundary-hold +
467
- * coalescing shrink but do not eliminate that window.
468
- */
469
- export declare class StatusLineController {
470
- private readonly opts;
471
- private readonly scanner;
472
- private timer;
473
- private wantPaint;
474
- private lastPaintAt;
475
- private disposed;
476
- constructor(opts: StatusLineControllerOptions);
477
- private isEnabled;
478
- /** Record server output for boundary tracking; flush a held repaint if the
479
- * stream is now back at a sequence boundary. */
480
- observeOutput(chunk: string): void;
481
- /** Request a repaint (coalesced + boundary-held). */
482
- request(): void;
483
- /** Stop all painting and cancel any pending timer. */
484
- dispose(): void;
485
- private now;
486
- private flush;
487
- private paintNow;
488
- private arm;
489
- private clearTimer;
490
- }
491
- /** Minimal writable surface {@link createBackpressureAwareWriter} needs. */
492
- export interface BackpressureWritable {
493
- write(chunk: string): boolean;
494
- once(event: 'drain', listener: () => void): unknown;
495
- off?(event: 'drain', listener: () => void): unknown;
496
- removeListener?(event: 'drain', listener: () => void): unknown;
497
- }
498
- /**
499
- * A backpressure-aware writer plus teardown hooks. Call the writer with each
500
- * chunk. Interactive attaches call {@link BackpressureAwareWriter.dispose} on
501
- * detach to drop any still-queued terminal bytes; machine-readable callers can
502
- * call {@link BackpressureAwareWriter.flush} first to preserve their records.
503
- */
504
- export interface BackpressureAwareWriter {
505
- /** Write a chunk, respecting backpressure. No-op after {@link dispose}. */
506
- write: (chunk: string) => void;
507
- /**
508
- * Queue every locally buffered chunk to the underlying stream in FIFO order.
509
- * The stream's own buffered writes are drained by the shared CLI exit path.
510
- */
511
- flush: () => void;
512
- /** Drop the pending queue and unhook the `'drain'` listener. Idempotent. */
513
- dispose: () => void;
514
- }
515
- /**
516
- * Default stdout writer that respects backpressure (see #1247, item 7).
517
- *
518
- * When the underlying stream reports saturation (`write()` returns false) we
519
- * hold subsequent chunks in a bounded in-memory queue and flush them on
520
- * `'drain'`, rather than letting Node's stdout buffer grow without limit under
521
- * a fast agent + slow terminal.
522
- *
523
- * FIFO is preserved even when our own queue reaches `maxQueuedBytes`: rather
524
- * than writing the overflow chunk straight through (which would jump it ahead
525
- * of older queued chunks and reorder/split the PTY byte stream), we first flush
526
- * the entire local queue into stdout's internal buffer — `stdout.write` buffers
527
- * internally when saturated, so ignoring its return value here is safe — then
528
- * write the new chunk last. Bounded extra buffering, never dropped or reordered
529
- * output. Documented residual risk: under sustained overload Node's internal
530
- * stdout buffer can still grow.
531
- */
532
- export declare function createBackpressureAwareWriter(stdout: BackpressureWritable, maxQueuedBytes?: number): BackpressureAwareWriter;
533
- /** Dependencies for `captureInitialSnapshot`. `captureAndRenderSnapshot`
534
- * is injectable so tests can substitute a stub. */
535
- export interface CaptureInitialSnapshotDeps extends AttachSnapshotDeps {
536
- log: (...args: unknown[]) => void;
537
- error: (...args: unknown[]) => void;
538
- captureAndRenderSnapshot?: typeof captureAndRenderSnapshot;
539
- }
540
- /**
541
- * Render the agent's current visible screen, then dispatch on the
542
- * outcome. Hard errors (`not_found`, `no_pty`) abort: this helper
543
- * best-effort restores the prior delivery mode and writes the
544
- * appropriate error before returning `null` so the caller bails.
545
- * Transient errors warn and proceed. Returns `{ snapshotRows }` on the
546
- * happy path so the caller can seed the status-line row fallback.
547
- *
548
- * `noPtyAction` is the verb phrase used in the no-PTY message
549
- * (`agent 'X' has no PTY to ${noPtyAction}`) — e.g. "drive" or
550
- * "attach to".
551
- */
552
- export declare function captureInitialSnapshot(connection: BrokerConnection, name: string, previousMode: InboundDeliveryMode | null, verb: string, noPtyAction: string, deps: CaptureInitialSnapshotDeps): Promise<{
553
- snapshotRows?: number;
554
- } | null>;
555
- //# sourceMappingURL=attach.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attach.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/attach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAC;AAEvE,OAAO,EAGL,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC7B,MAAM,wBAAwB,CAAC;AAGhC,uEAAuE;AACvE,MAAM,WAAW,wBAAwB;IACvC,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qEAAqE;IACrE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;mBACmB;AACnB,MAAM,WAAW,kBAAkB;IACjC,uDAAuD;IACvD,KAAK,E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