agent-relay 17.2.0 → 18.0.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.
- package/README.md +45 -270
- package/dist/cli/agent-relay-mcp.d.ts.map +1 -1
- package/dist/cli/agent-relay-mcp.js +6 -5
- package/dist/cli/agent-relay-mcp.js.map +1 -1
- package/dist/cli/bootstrap.d.ts +1 -1
- package/dist/cli/bootstrap.d.ts.map +1 -1
- package/dist/cli/bootstrap.js +11 -29
- package/dist/cli/bootstrap.js.map +1 -1
- package/dist/cli/commands/agent.d.ts.map +1 -1
- package/dist/cli/commands/agent.js +3 -2
- package/dist/cli/commands/agent.js.map +1 -1
- package/dist/cli/commands/cloud-integration.d.ts.map +1 -1
- package/dist/cli/commands/cloud-integration.js +2 -1
- package/dist/cli/commands/cloud-integration.js.map +1 -1
- package/dist/cli/commands/cloud-room.d.ts.map +1 -1
- package/dist/cli/commands/cloud-room.js +2 -1
- package/dist/cli/commands/cloud-room.js.map +1 -1
- package/dist/cli/commands/cloud-v1-deprecations.d.ts +4 -6
- package/dist/cli/commands/cloud-v1-deprecations.d.ts.map +1 -1
- package/dist/cli/commands/cloud-v1-deprecations.js +4 -6
- package/dist/cli/commands/cloud-v1-deprecations.js.map +1 -1
- package/dist/cli/commands/cloud-worker.d.ts +1 -1
- package/dist/cli/commands/cloud-worker.d.ts.map +1 -1
- package/dist/cli/commands/cloud-worker.js +42 -31
- package/dist/cli/commands/cloud-worker.js.map +1 -1
- package/dist/cli/commands/cloud.d.ts.map +1 -1
- package/dist/cli/commands/cloud.js +6 -7
- package/dist/cli/commands/cloud.js.map +1 -1
- package/dist/cli/commands/core.d.ts +3 -91
- package/dist/cli/commands/core.d.ts.map +1 -1
- package/dist/cli/commands/core.js +5 -254
- package/dist/cli/commands/core.js.map +1 -1
- package/dist/cli/commands/fleet-agent.d.ts +9 -54
- package/dist/cli/commands/fleet-agent.d.ts.map +1 -1
- package/dist/cli/commands/fleet-agent.js +105 -314
- package/dist/cli/commands/fleet-agent.js.map +1 -1
- package/dist/cli/commands/fleet.d.ts +0 -3
- package/dist/cli/commands/fleet.d.ts.map +1 -1
- package/dist/cli/commands/fleet.js +48 -267
- package/dist/cli/commands/fleet.js.map +1 -1
- package/dist/cli/commands/init.js +1 -1
- package/dist/cli/commands/init.js.map +1 -1
- package/dist/cli/commands/integration-cleanup-journal.d.ts +6 -2
- package/dist/cli/commands/integration-cleanup-journal.d.ts.map +1 -1
- package/dist/cli/commands/integration-cleanup-journal.js +611 -134
- package/dist/cli/commands/integration-cleanup-journal.js.map +1 -1
- package/dist/cli/commands/integration-recipient.d.ts +0 -17
- package/dist/cli/commands/integration-recipient.d.ts.map +1 -1
- package/dist/cli/commands/integration-recipient.js +1 -104
- package/dist/cli/commands/integration-recipient.js.map +1 -1
- package/dist/cli/commands/integration.d.ts +7 -3
- package/dist/cli/commands/integration.d.ts.map +1 -1
- package/dist/cli/commands/integration.js +37 -82
- package/dist/cli/commands/integration.js.map +1 -1
- package/dist/cli/commands/local-workflow.d.ts +1 -1
- package/dist/cli/commands/local-workflow.d.ts.map +1 -1
- package/dist/cli/commands/local-workflow.js +20 -6
- package/dist/cli/commands/local-workflow.js.map +1 -1
- package/dist/cli/commands/node.d.ts +18 -20
- package/dist/cli/commands/node.d.ts.map +1 -1
- package/dist/cli/commands/node.js +42 -272
- package/dist/cli/commands/node.js.map +1 -1
- package/dist/cli/commands/product-surfaces.js +4 -4
- package/dist/cli/commands/product-surfaces.js.map +1 -1
- package/dist/cli/commands/session.d.ts.map +1 -1
- package/dist/cli/commands/session.js +2 -1
- package/dist/cli/commands/session.js.map +1 -1
- package/dist/cli/commands/skills.d.ts.map +1 -1
- package/dist/cli/commands/skills.js +2 -1
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/status.d.ts +1 -7
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +2 -28
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/workspace.d.ts.map +1 -1
- package/dist/cli/commands/workspace.js +2 -2
- package/dist/cli/commands/workspace.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +1 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/lib/agent-relay-cli-reentry.d.ts +37 -0
- package/dist/cli/lib/agent-relay-cli-reentry.d.ts.map +1 -0
- package/dist/cli/lib/agent-relay-cli-reentry.js +40 -0
- package/dist/cli/lib/agent-relay-cli-reentry.js.map +1 -0
- package/dist/cli/lib/agent-tools-mcp.d.ts.map +1 -1
- package/dist/cli/lib/agent-tools-mcp.js +3 -2
- package/dist/cli/lib/agent-tools-mcp.js.map +1 -1
- package/dist/cli/lib/core-maintenance.d.ts +2 -3
- package/dist/cli/lib/core-maintenance.d.ts.map +1 -1
- package/dist/cli/lib/core-maintenance.js +3 -37
- package/dist/cli/lib/core-maintenance.js.map +1 -1
- package/dist/cli/lib/desktop-presence.js +1 -1
- package/dist/cli/lib/desktop-presence.js.map +1 -1
- package/dist/cli/lib/install-paths.d.ts +100 -0
- package/dist/cli/lib/install-paths.d.ts.map +1 -0
- package/dist/cli/lib/install-paths.js +157 -0
- package/dist/cli/lib/install-paths.js.map +1 -0
- package/dist/cli/lib/product-surface-store.d.ts.map +1 -1
- package/dist/cli/lib/product-surface-store.js +4 -1
- package/dist/cli/lib/product-surface-store.js.map +1 -1
- package/dist/cli/lib/relay-node.d.ts +7 -34
- package/dist/cli/lib/relay-node.d.ts.map +1 -1
- package/dist/cli/lib/relay-node.js +7 -182
- package/dist/cli/lib/relay-node.js.map +1 -1
- package/dist/cli/lib/removed-broker-command.d.ts +7 -0
- package/dist/cli/lib/removed-broker-command.d.ts.map +1 -0
- package/dist/cli/lib/removed-broker-command.js +13 -0
- package/dist/cli/lib/removed-broker-command.js.map +1 -0
- package/dist/cli/lib/sdk-client.d.ts +4 -4
- package/dist/cli/lib/sdk-client.js +4 -4
- package/dist/cli/lib/self-update.d.ts +8 -19
- package/dist/cli/lib/self-update.d.ts.map +1 -1
- package/dist/cli/lib/self-update.js +14 -28
- package/dist/cli/lib/self-update.js.map +1 -1
- package/dist/cli/lib/skills-install.d.ts.map +1 -1
- package/dist/cli/lib/skills-install.js +3 -2
- package/dist/cli/lib/skills-install.js.map +1 -1
- package/dist/cli/telemetry/events.d.ts +4 -1
- package/dist/cli/telemetry/events.d.ts.map +1 -1
- package/package.json +10 -15
- package/dist/auto/classifier.d.ts +0 -29
- package/dist/auto/classifier.d.ts.map +0 -1
- package/dist/auto/classifier.js +0 -126
- package/dist/auto/classifier.js.map +0 -1
- package/dist/auto/composer.d.ts +0 -105
- package/dist/auto/composer.d.ts.map +0 -1
- package/dist/auto/composer.js +0 -454
- package/dist/auto/composer.js.map +0 -1
- package/dist/auto/director-prompt.d.ts +0 -25
- package/dist/auto/director-prompt.d.ts.map +0 -1
- package/dist/auto/director-prompt.js +0 -53
- package/dist/auto/director-prompt.js.map +0 -1
- package/dist/auto/index.d.ts +0 -15
- package/dist/auto/index.d.ts.map +0 -1
- package/dist/auto/index.js +0 -13
- package/dist/auto/index.js.map +0 -1
- package/dist/cli/commands/local-agent.d.ts +0 -74
- package/dist/cli/commands/local-agent.d.ts.map +0 -1
- package/dist/cli/commands/local-agent.js +0 -969
- package/dist/cli/commands/local-agent.js.map +0 -1
- package/dist/cli/lib/attach-broker.d.ts +0 -17
- package/dist/cli/lib/attach-broker.d.ts.map +0 -1
- package/dist/cli/lib/attach-broker.js +0 -27
- package/dist/cli/lib/attach-broker.js.map +0 -1
- package/dist/cli/lib/attach-drive.d.ts +0 -376
- package/dist/cli/lib/attach-drive.d.ts.map +0 -1
- package/dist/cli/lib/attach-drive.js +0 -1212
- package/dist/cli/lib/attach-drive.js.map +0 -1
- package/dist/cli/lib/attach-fleet-node.d.ts +0 -85
- package/dist/cli/lib/attach-fleet-node.d.ts.map +0 -1
- package/dist/cli/lib/attach-fleet-node.js +0 -1347
- package/dist/cli/lib/attach-fleet-node.js.map +0 -1
- package/dist/cli/lib/attach-input-recovery.d.ts +0 -190
- package/dist/cli/lib/attach-input-recovery.d.ts.map +0 -1
- package/dist/cli/lib/attach-input-recovery.js +0 -559
- package/dist/cli/lib/attach-input-recovery.js.map +0 -1
- package/dist/cli/lib/attach-mode.d.ts +0 -2
- package/dist/cli/lib/attach-mode.d.ts.map +0 -1
- package/dist/cli/lib/attach-mode.js +0 -2
- package/dist/cli/lib/attach-mode.js.map +0 -1
- package/dist/cli/lib/attach-native.d.ts +0 -27
- package/dist/cli/lib/attach-native.d.ts.map +0 -1
- package/dist/cli/lib/attach-native.js +0 -267
- package/dist/cli/lib/attach-native.js.map +0 -1
- package/dist/cli/lib/attach-passthrough.d.ts +0 -193
- package/dist/cli/lib/attach-passthrough.d.ts.map +0 -1
- package/dist/cli/lib/attach-passthrough.js +0 -778
- package/dist/cli/lib/attach-passthrough.js.map +0 -1
- package/dist/cli/lib/attach-remote-node.d.ts +0 -21
- package/dist/cli/lib/attach-remote-node.d.ts.map +0 -1
- package/dist/cli/lib/attach-remote-node.js +0 -133
- package/dist/cli/lib/attach-remote-node.js.map +0 -1
- package/dist/cli/lib/attach-view.d.ts +0 -177
- package/dist/cli/lib/attach-view.d.ts.map +0 -1
- package/dist/cli/lib/attach-view.js +0 -455
- package/dist/cli/lib/attach-view.js.map +0 -1
- package/dist/cli/lib/attach.d.ts +0 -555
- package/dist/cli/lib/attach.d.ts.map +0 -1
- package/dist/cli/lib/attach.js +0 -1180
- package/dist/cli/lib/attach.js.map +0 -1
- package/dist/cli/lib/broker-connection.d.ts +0 -65
- package/dist/cli/lib/broker-connection.d.ts.map +0 -1
- package/dist/cli/lib/broker-connection.js +0 -144
- package/dist/cli/lib/broker-connection.js.map +0 -1
- package/dist/cli/lib/broker-lifecycle.d.ts +0 -220
- package/dist/cli/lib/broker-lifecycle.d.ts.map +0 -1
- package/dist/cli/lib/broker-lifecycle.js +0 -2290
- package/dist/cli/lib/broker-lifecycle.js.map +0 -1
- package/dist/cli/lib/broker-process-identity.d.ts +0 -38
- package/dist/cli/lib/broker-process-identity.d.ts.map +0 -1
- package/dist/cli/lib/broker-process-identity.js +0 -304
- package/dist/cli/lib/broker-process-identity.js.map +0 -1
- package/dist/cli/lib/client-factory.d.ts +0 -44
- package/dist/cli/lib/client-factory.d.ts.map +0 -1
- package/dist/cli/lib/client-factory.js +0 -64
- package/dist/cli/lib/client-factory.js.map +0 -1
- package/dist/cli/lib/collect-with-retry.d.ts +0 -24
- package/dist/cli/lib/collect-with-retry.d.ts.map +0 -1
- package/dist/cli/lib/collect-with-retry.js +0 -33
- package/dist/cli/lib/collect-with-retry.js.map +0 -1
- package/dist/cli/lib/fleet-attach-target.d.ts +0 -18
- package/dist/cli/lib/fleet-attach-target.d.ts.map +0 -1
- package/dist/cli/lib/fleet-attach-target.js +0 -57
- package/dist/cli/lib/fleet-attach-target.js.map +0 -1
- package/dist/cli/lib/fleet-hint.d.ts +0 -49
- package/dist/cli/lib/fleet-hint.d.ts.map +0 -1
- package/dist/cli/lib/fleet-hint.js +0 -113
- package/dist/cli/lib/fleet-hint.js.map +0 -1
- package/dist/cli/lib/fleet-sidecar.d.ts +0 -43
- package/dist/cli/lib/fleet-sidecar.d.ts.map +0 -1
- package/dist/cli/lib/fleet-sidecar.js +0 -84
- package/dist/cli/lib/fleet-sidecar.js.map +0 -1
- package/dist/cli/lib/join-ticket.d.ts +0 -22
- package/dist/cli/lib/join-ticket.d.ts.map +0 -1
- package/dist/cli/lib/join-ticket.js +0 -96
- package/dist/cli/lib/join-ticket.js.map +0 -1
- package/dist/cli/lib/node-claim.d.ts +0 -468
- package/dist/cli/lib/node-claim.d.ts.map +0 -1
- package/dist/cli/lib/node-claim.js +0 -1349
- package/dist/cli/lib/node-claim.js.map +0 -1
- package/dist/cli/lib/node-definition-loader.d.ts +0 -19
- package/dist/cli/lib/node-definition-loader.d.ts.map +0 -1
- package/dist/cli/lib/node-definition-loader.js +0 -143
- package/dist/cli/lib/node-definition-loader.js.map +0 -1
- package/dist/cli/lib/node-provider-child.d.ts +0 -129
- package/dist/cli/lib/node-provider-child.d.ts.map +0 -1
- package/dist/cli/lib/node-provider-child.js +0 -755
- package/dist/cli/lib/node-provider-child.js.map +0 -1
- package/dist/cli/lib/predictive-echo-screen.d.ts +0 -48
- package/dist/cli/lib/predictive-echo-screen.d.ts.map +0 -1
- package/dist/cli/lib/predictive-echo-screen.js +0 -74
- package/dist/cli/lib/predictive-echo-screen.js.map +0 -1
- package/dist/cli/lib/project-broker-client.d.ts +0 -4
- package/dist/cli/lib/project-broker-client.d.ts.map +0 -1
- package/dist/cli/lib/project-broker-client.js +0 -12
- package/dist/cli/lib/project-broker-client.js.map +0 -1
- package/dist/cli/lib/reflex-capture.d.ts +0 -41
- package/dist/cli/lib/reflex-capture.d.ts.map +0 -1
- package/dist/cli/lib/reflex-capture.js +0 -128
- package/dist/cli/lib/reflex-capture.js.map +0 -1
- package/dist/cli/lib/workspace-env.d.ts +0 -8
- package/dist/cli/lib/workspace-env.d.ts.map +0 -1
- package/dist/cli/lib/workspace-env.js +0 -16
- package/dist/cli/lib/workspace-env.js.map +0 -1
|
@@ -1,559 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Recovery for a lost PTY input stream, shared by `attach --mode drive` and
|
|
3
|
-
* `attach --mode passthrough`.
|
|
4
|
-
*
|
|
5
|
-
* The SDK's `PtyInputStream` never reopens itself. Once its socket closes the
|
|
6
|
-
* `closed` flag latches and every later `send()` rejects immediately with
|
|
7
|
-
* `PTY input stream is closed`. That close is easy to hit and easy to miss: the
|
|
8
|
-
* broker pings the *events* WebSocket every 30s but never pings the *input*
|
|
9
|
-
* WebSocket, so an idle input socket is silent on the wire and any idle timeout
|
|
10
|
-
* between client and broker kills it alone — the screen keeps updating while
|
|
11
|
-
* input is permanently dead. A broker-side write error (PTY worker restart)
|
|
12
|
-
* closes it the same way.
|
|
13
|
-
*
|
|
14
|
-
* Before this, both attach modes caught that rejection per keystroke, logged
|
|
15
|
-
* it, and returned. Nothing tore the session down, so the line repeated for as
|
|
16
|
-
* long as stdin produced bytes. There was no retry loop — the repetition was
|
|
17
|
-
* 1:1 with inbound chunks, and since the keybind parser forwards every byte
|
|
18
|
-
* except Ctrl+C / Ctrl+], a source TUI with mouse tracking enabled flooded the
|
|
19
|
-
* terminal on pointer movement alone, with the human never touching a key.
|
|
20
|
-
*
|
|
21
|
-
* This turns that into one liveness event: report once, reopen with bounded
|
|
22
|
-
* exponential backoff, and on exhaustion hand control back to the caller so the
|
|
23
|
-
* session exits non-zero. A dead seat that looks alive is the defect; a
|
|
24
|
-
* readable exit a supervisor can act on is the contract (#1419).
|
|
25
|
-
*/
|
|
26
|
-
import { Buffer } from 'node:buffer';
|
|
27
|
-
/** Default number of reopen attempts before a lost input stream ends the session. */
|
|
28
|
-
export const INPUT_REOPEN_MAX_ATTEMPTS = 5;
|
|
29
|
-
/** Default base delay for the reopen backoff; doubles per attempt. */
|
|
30
|
-
export const INPUT_REOPEN_BASE_DELAY_MS = 250;
|
|
31
|
-
/** Ceiling on the doubled reopen delay. */
|
|
32
|
-
export const INPUT_REOPEN_MAX_DELAY_MS = 4_000;
|
|
33
|
-
/** Ceiling on one attempt's open wait and identity check. */
|
|
34
|
-
export const INPUT_REOPEN_ATTEMPT_TIMEOUT_MS = 15_000;
|
|
35
|
-
/**
|
|
36
|
-
* Maximum input retained during one outage. A human can type comfortably for
|
|
37
|
-
* the complete retry window, while a runaway paste or mouse-report stream
|
|
38
|
-
* cannot grow memory without bound.
|
|
39
|
-
*/
|
|
40
|
-
export const INPUT_REPLAY_BUFFER_MAX_BYTES = 64 * 1024;
|
|
41
|
-
/**
|
|
42
|
-
* `PtyInputStream.send()` rejects with `input_backpressure` when queued bytes
|
|
43
|
-
* would exceed its high-water mark — **while the stream is open and healthy**
|
|
44
|
-
* (`transport.ts:206-214`, `retryable: true`). That is flow control, not
|
|
45
|
-
* transport death: tearing the socket down and reopening it would drop every
|
|
46
|
-
* outstanding keystroke and re-run the identity gate, turning a slow broker
|
|
47
|
-
* into a detach. See {@link isWriteTimeoutRejection} for the other rejection
|
|
48
|
-
* that must not trigger a teardown; every remaining rejection means the
|
|
49
|
-
* stream is gone or unusable.
|
|
50
|
-
*/
|
|
51
|
-
export function isBackpressureRejection(error) {
|
|
52
|
-
return (typeof error === 'object' && error !== null && error.code === 'input_backpressure');
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* `PtyInputStream.send()` rejects with `worker_timeout` when the broker's
|
|
56
|
-
* `write_pty` ack for THAT ONE keystroke didn't arrive before
|
|
57
|
-
* `PTY_INPUT_ACK_TIMEOUT` (broker `api.rs`). That does not mean the worker is
|
|
58
|
-
* dead: a confirmed-dead worker is reaped independently and surfaces as
|
|
59
|
-
* `worker_disappeared`, and the broker keeps this WebSocket open for
|
|
60
|
-
* `worker_timeout` specifically (`pty_input_error_is_connection_fatal`,
|
|
61
|
-
* `listen_api.rs`) because a busy-but-alive coding agent that hasn't drained
|
|
62
|
-
* its stdin yet produces the exact same "no ack yet" as a wedged one — the
|
|
63
|
-
* broker has no other liveness signal to tell them apart. Tearing the whole
|
|
64
|
-
* input stream down and reconnecting over one slow ack is what produced the
|
|
65
|
-
* self-healing "input stream lost / reconnected after 1 attempt(s)" flap
|
|
66
|
-
* reported in relay#1544.
|
|
67
|
-
*
|
|
68
|
-
* Critically, a late ack is not a failed write: the broker's `write_all()`
|
|
69
|
-
* onto the PTY master is still blocking and pending when the ack times out,
|
|
70
|
-
* and it very likely completes once the busy child drains its stdin — the
|
|
71
|
-
* keystroke lands anyway. Rolling back the optimistic echo here would show
|
|
72
|
-
* the operator input vanishing right before it executes, a UI lie that is
|
|
73
|
-
* worse than the flap this module exists to fix and that the operator cannot
|
|
74
|
-
* recover from (they cannot tell whether it is safe to retype). So this code
|
|
75
|
-
* must NOT roll back the echo. Only a *confirmed* write failure — a different
|
|
76
|
-
* error code entirely — may roll it back, and that already falls through to
|
|
77
|
-
* {@link createInputStreamRecovery}'s default `recover()` path below.
|
|
78
|
-
*/
|
|
79
|
-
export function isWriteTimeoutRejection(error) {
|
|
80
|
-
return (typeof error === 'object' && error !== null && error.code === 'worker_timeout');
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* `PtyInputStream.send()` rejects with `pty_write_queue_full` when the worker
|
|
84
|
-
* refused THAT ONE write because relay-pty's bounded drainer queue is full
|
|
85
|
-
* (`WRITE_QUEUE_DEPTH`, `crates/relay-pty/src/pty.rs`). The child is alive and
|
|
86
|
-
* the socket is healthy — the drainer is parked in `write_all` behind a child
|
|
87
|
-
* that has momentarily stopped reading its stdin, which is the normal state of
|
|
88
|
-
* a TUI harness mid-tool-call.
|
|
89
|
-
*
|
|
90
|
-
* This must not enter recovery. Reconnecting cannot drain the queue — it
|
|
91
|
-
* empties when the child resumes reading, not when a new socket opens — so a
|
|
92
|
-
* teardown here produced exactly one flap per keystroke for as long as the
|
|
93
|
-
* agent stayed busy (`input stream lost … / reconnected after 1 attempt(s)`,
|
|
94
|
-
* relay#1597). The broker keeps the connection open for this code for the same
|
|
95
|
-
* reason (`pty_input_error_is_connection_fatal`, `listen_api.rs`).
|
|
96
|
-
*
|
|
97
|
-
* Unlike {@link isWriteTimeoutRejection} this IS a confirmed refusal: the byte
|
|
98
|
-
* was never enqueued and will never reach the child, so the optimistic echo has
|
|
99
|
-
* to come back off the screen. Note the queue is shared with terminal-query
|
|
100
|
-
* replies, injected messages and auto-responder writes, so the operator whose
|
|
101
|
-
* keystroke is refused is usually not the one who filled it — the message must
|
|
102
|
-
* not blame their typing speed.
|
|
103
|
-
*/
|
|
104
|
-
export function isWriteRefusedRejection(error) {
|
|
105
|
-
return (typeof error === 'object' &&
|
|
106
|
-
error !== null &&
|
|
107
|
-
error.code === 'pty_write_queue_full');
|
|
108
|
-
}
|
|
109
|
-
function describeSendError(error) {
|
|
110
|
-
if (error instanceof Error)
|
|
111
|
-
return error.message;
|
|
112
|
-
return String(error);
|
|
113
|
-
}
|
|
114
|
-
class InputRecoveryDeadlineError extends Error {
|
|
115
|
-
operation;
|
|
116
|
-
constructor(operation, timeoutMs) {
|
|
117
|
-
super(`${operation} timed out after ${timeoutMs}ms`);
|
|
118
|
-
this.operation = operation;
|
|
119
|
-
this.name = 'InputRecoveryDeadlineError';
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
export function createInputStreamRecovery(options) {
|
|
123
|
-
const { label, name, maxAttempts, baseDelayMs, log, error, isSettled, getStream, setStream, openStream, onRollback, onExhausted, verifyIdentity, } = options;
|
|
124
|
-
const onBufferedInputDiscarded = options.onBufferedInputDiscarded ?? (() => undefined);
|
|
125
|
-
const attemptTimeoutMs = options.attemptTimeoutMs ?? INPUT_REOPEN_ATTEMPT_TIMEOUT_MS;
|
|
126
|
-
const bufferLimitBytes = Math.max(0, options.bufferLimitBytes ?? INPUT_REPLAY_BUFFER_MAX_BYTES);
|
|
127
|
-
let inFlight = null;
|
|
128
|
-
let timer = null;
|
|
129
|
-
/**
|
|
130
|
-
* Resolves the pending backoff wait on cancel. Clearing the timer alone left
|
|
131
|
-
* that promise permanently unresolved, so the recovery loop never finished,
|
|
132
|
-
* `inFlight` never cleared, and `isRecovering()` stayed true forever — detach
|
|
133
|
-
* cleanup could not complete.
|
|
134
|
-
*/
|
|
135
|
-
let releaseBackoff = null;
|
|
136
|
-
/** True once a backpressure episode has been reported; reset on the next good send. */
|
|
137
|
-
let backpressureReported = false;
|
|
138
|
-
/** True once a write-timeout episode has been reported; reset on the next good send. */
|
|
139
|
-
let writeTimeoutReported = false;
|
|
140
|
-
/** True once a write-refused episode has been reported; reset on the next good send. */
|
|
141
|
-
let writeRefusedReported = false;
|
|
142
|
-
let bufferedInput = [];
|
|
143
|
-
let bufferedBytes = 0;
|
|
144
|
-
let overflowDiscardedBytes = 0;
|
|
145
|
-
let bufferOverflowed = false;
|
|
146
|
-
let candidateStream = null;
|
|
147
|
-
const resetBufferedInput = () => {
|
|
148
|
-
bufferedInput = [];
|
|
149
|
-
bufferedBytes = 0;
|
|
150
|
-
overflowDiscardedBytes = 0;
|
|
151
|
-
bufferOverflowed = false;
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Clear everything retained for this outage and return the byte count for an
|
|
155
|
-
* operator-facing diagnostic. Overflow deliberately poisons all not-yet-sent
|
|
156
|
-
* input: replaying only a prefix of a paste could execute a different,
|
|
157
|
-
* truncated command.
|
|
158
|
-
*/
|
|
159
|
-
const discardBufferedInput = () => {
|
|
160
|
-
const discarded = bufferedBytes + overflowDiscardedBytes;
|
|
161
|
-
resetBufferedInput();
|
|
162
|
-
onBufferedInputDiscarded();
|
|
163
|
-
return discarded;
|
|
164
|
-
};
|
|
165
|
-
const discardedMessage = (discarded) => discarded > 0 ? ` Discarded ${discarded} buffered bytes; none were forwarded.` : '';
|
|
166
|
-
const appendBufferedInput = (input) => {
|
|
167
|
-
if (input.length === 0)
|
|
168
|
-
return;
|
|
169
|
-
const bytes = Buffer.byteLength(input, 'utf8');
|
|
170
|
-
if (bufferOverflowed) {
|
|
171
|
-
overflowDiscardedBytes += bytes;
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (bufferedBytes + bytes > bufferLimitBytes) {
|
|
175
|
-
overflowDiscardedBytes = bufferedBytes + bytes;
|
|
176
|
-
bufferedInput = [];
|
|
177
|
-
bufferedBytes = 0;
|
|
178
|
-
bufferOverflowed = true;
|
|
179
|
-
log(`[${label}] outage input exceeded the ${bufferLimitBytes}-byte safety limit; ` +
|
|
180
|
-
`all input still buffered will be discarded rather than replaying a truncated command.`);
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
bufferedInput.push(input);
|
|
184
|
-
bufferedBytes += bytes;
|
|
185
|
-
};
|
|
186
|
-
const bufferInput = (input) => {
|
|
187
|
-
if (inFlight === null || isSettled())
|
|
188
|
-
return;
|
|
189
|
-
appendBufferedInput(input);
|
|
190
|
-
};
|
|
191
|
-
const cancel = () => {
|
|
192
|
-
if (timer) {
|
|
193
|
-
clearTimeout(timer);
|
|
194
|
-
timer = null;
|
|
195
|
-
}
|
|
196
|
-
// Wake the loop so it observes `isSettled()` and unwinds, rather than
|
|
197
|
-
// parking on a timer that will never fire.
|
|
198
|
-
releaseBackoff?.();
|
|
199
|
-
releaseBackoff = null;
|
|
200
|
-
resetBufferedInput();
|
|
201
|
-
try {
|
|
202
|
-
candidateStream?.close(1000, `${label} client exiting`);
|
|
203
|
-
}
|
|
204
|
-
catch {
|
|
205
|
-
// best effort
|
|
206
|
-
}
|
|
207
|
-
candidateStream = null;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* Rejects with a timeout rather than waiting forever. `waitUntilOpen()` and
|
|
211
|
-
* the identity check both cross the network; neither is bounded by this
|
|
212
|
-
* helper otherwise, and an unbounded await makes `maxAttempts` a fiction.
|
|
213
|
-
*/
|
|
214
|
-
const withDeadline = async (work, what) => {
|
|
215
|
-
let handle;
|
|
216
|
-
try {
|
|
217
|
-
return await Promise.race([
|
|
218
|
-
work,
|
|
219
|
-
new Promise((_resolve, reject) => {
|
|
220
|
-
handle = setTimeout(() => reject(new InputRecoveryDeadlineError(what, attemptTimeoutMs)), attemptTimeoutMs);
|
|
221
|
-
handle.unref?.();
|
|
222
|
-
}),
|
|
223
|
-
]);
|
|
224
|
-
}
|
|
225
|
-
finally {
|
|
226
|
-
if (handle !== undefined)
|
|
227
|
-
clearTimeout(handle);
|
|
228
|
-
}
|
|
229
|
-
};
|
|
230
|
-
const isUsable = (stream) => stream !== null && stream.closed !== true;
|
|
231
|
-
const closeQuietly = (stream, why) => {
|
|
232
|
-
try {
|
|
233
|
-
stream.close(1000, why);
|
|
234
|
-
}
|
|
235
|
-
catch {
|
|
236
|
-
// best effort
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
/** Replay only after identity verification, preserving byte order and buffer safety. */
|
|
240
|
-
const replayBufferedInput = async (replacement) => {
|
|
241
|
-
let replayedBytes = 0;
|
|
242
|
-
let uncertainBytes = 0;
|
|
243
|
-
let discardedBytes = 0;
|
|
244
|
-
while (!bufferOverflowed && bufferedInput.length > 0) {
|
|
245
|
-
if (isSettled()) {
|
|
246
|
-
resetBufferedInput();
|
|
247
|
-
return { outcome: 'settled', replayedBytes, uncertainBytes, discardedBytes };
|
|
248
|
-
}
|
|
249
|
-
// Send one snapshot so input appended while this await is in flight
|
|
250
|
-
// remains queued behind it. This preserves the human's byte order.
|
|
251
|
-
const replayCount = bufferedInput.length;
|
|
252
|
-
const replayPayload = bufferedInput.slice(0, replayCount).join('');
|
|
253
|
-
const replayBytes = Buffer.byteLength(replayPayload, 'utf8');
|
|
254
|
-
// Move this complete snapshot out of the live queue before awaiting.
|
|
255
|
-
// New stdin can then append independently without corrupting counts.
|
|
256
|
-
bufferedInput.splice(0, replayCount);
|
|
257
|
-
bufferedBytes -= replayBytes;
|
|
258
|
-
try {
|
|
259
|
-
await withDeadline(replacement.send(replayPayload), 'buffered input replay');
|
|
260
|
-
}
|
|
261
|
-
catch (replayError) {
|
|
262
|
-
if (isSettled()) {
|
|
263
|
-
resetBufferedInput();
|
|
264
|
-
return { outcome: 'settled', replayedBytes, uncertainBytes, discardedBytes };
|
|
265
|
-
}
|
|
266
|
-
if (isWriteTimeoutRejection(replayError)) {
|
|
267
|
-
// The broker may still deliver this write. Retrying it would risk a
|
|
268
|
-
// duplicate command, so treat the uncertain write as consumed just
|
|
269
|
-
// as the live-input path does.
|
|
270
|
-
uncertainBytes += replayBytes;
|
|
271
|
-
continue;
|
|
272
|
-
}
|
|
273
|
-
else if (replayError instanceof InputRecoveryDeadlineError) {
|
|
274
|
-
// The local deadline cannot tell whether the stream accepted this
|
|
275
|
-
// payload. Never retry it, and discard everything behind it so a
|
|
276
|
-
// command suffix cannot execute without its prefix.
|
|
277
|
-
uncertainBytes += replayBytes;
|
|
278
|
-
discardedBytes += discardBufferedInput();
|
|
279
|
-
break;
|
|
280
|
-
}
|
|
281
|
-
else if (isBackpressureRejection(replayError) || isWriteRefusedRejection(replayError)) {
|
|
282
|
-
// Both codes prove the socket is healthy but this payload was not
|
|
283
|
-
// accepted. Discard it and everything queued behind it as one
|
|
284
|
-
// unit: replaying only the suffix could execute a different,
|
|
285
|
-
// truncated command.
|
|
286
|
-
discardedBytes += replayBytes + discardBufferedInput();
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
// A fatal send error can arrive after transmission began. Retry the
|
|
291
|
-
// connection, but never these bytes: the current payload may still
|
|
292
|
-
// land, and replaying it could execute the command twice. Discard
|
|
293
|
-
// everything behind it so no suffix executes without its prefix.
|
|
294
|
-
uncertainBytes += replayBytes;
|
|
295
|
-
discardedBytes += discardBufferedInput();
|
|
296
|
-
return { outcome: 'retry', replayedBytes, uncertainBytes, discardedBytes };
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
replayedBytes += replayBytes;
|
|
300
|
-
}
|
|
301
|
-
if (bufferOverflowed)
|
|
302
|
-
discardedBytes += discardBufferedInput();
|
|
303
|
-
else
|
|
304
|
-
resetBufferedInput();
|
|
305
|
-
return { outcome: 'ready', replayedBytes, uncertainBytes, discardedBytes };
|
|
306
|
-
};
|
|
307
|
-
const noteSendSuccess = () => {
|
|
308
|
-
backpressureReported = false;
|
|
309
|
-
writeTimeoutReported = false;
|
|
310
|
-
writeRefusedReported = false;
|
|
311
|
-
};
|
|
312
|
-
const handleSendFailure = (sendError) => {
|
|
313
|
-
if (isBackpressureRejection(sendError)) {
|
|
314
|
-
// Flow control on a healthy stream. The keystroke did not reach the PTY,
|
|
315
|
-
// so the optimistic echo still has to come off the screen — but the
|
|
316
|
-
// socket is fine and must not be torn down. Report once per episode:
|
|
317
|
-
// per-keystroke reporting here would rebuild the exact flood this module
|
|
318
|
-
// exists to remove.
|
|
319
|
-
onRollback();
|
|
320
|
-
if (!backpressureReported) {
|
|
321
|
-
backpressureReported = true;
|
|
322
|
-
log(`[${label}] input is arriving faster than ${name} can accept it; dropping keystrokes until it catches up.`);
|
|
323
|
-
}
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
if (isWriteRefusedRejection(sendError)) {
|
|
327
|
-
// Confirmed refusal on a healthy stream: roll the optimistic echo back
|
|
328
|
-
// (the byte will never reach the child) but keep the socket. Report once
|
|
329
|
-
// per episode — the cause persists for as long as the agent is busy, so
|
|
330
|
-
// per-keystroke reporting would rebuild the flood this module removes.
|
|
331
|
-
onRollback();
|
|
332
|
-
if (!writeRefusedReported) {
|
|
333
|
-
writeRefusedReported = true;
|
|
334
|
-
log(`[${label}] ${name} is not reading input right now (busy); that keystroke was dropped. ` +
|
|
335
|
-
`The session is still attached — retry once it is idle.`);
|
|
336
|
-
}
|
|
337
|
-
return;
|
|
338
|
-
}
|
|
339
|
-
if (isWriteTimeoutRejection(sendError)) {
|
|
340
|
-
// This one write's ack didn't arrive in time — the worker may just be
|
|
341
|
-
// busy, not dead (relay#1544). The transport already kept the socket
|
|
342
|
-
// open for this exact code, so recovering here would manufacture the
|
|
343
|
-
// reconnect this module exists to avoid. A late ack is not a failed
|
|
344
|
-
// write either: the broker's write to the PTY is still pending and
|
|
345
|
-
// very likely lands once the worker drains its stdin, so do NOT roll
|
|
346
|
-
// back the optimistic echo — doing so would erase input right before
|
|
347
|
-
// it executes, with no way for the operator to tell it happened. Only
|
|
348
|
-
// a confirmed write failure (a distinct error code) may roll it back,
|
|
349
|
-
// and that already falls through to `recover()` below.
|
|
350
|
-
if (!writeTimeoutReported) {
|
|
351
|
-
writeTimeoutReported = true;
|
|
352
|
-
log(`[${label}] ${name} did not confirm a keystroke in time (worker busy); it may still land.`);
|
|
353
|
-
}
|
|
354
|
-
return;
|
|
355
|
-
}
|
|
356
|
-
// This rejected write is delivery-ambiguous: it may already have crossed
|
|
357
|
-
// the socket before the fatal error arrived. Do not put it in the replay
|
|
358
|
-
// buffer and risk executing it twice. Only input observed after recovery
|
|
359
|
-
// begins is known not to have been sent and is eligible for replay.
|
|
360
|
-
recover(describeSendError(sendError));
|
|
361
|
-
};
|
|
362
|
-
const recover = (reason, input) => {
|
|
363
|
-
if (isSettled())
|
|
364
|
-
return;
|
|
365
|
-
if (inFlight) {
|
|
366
|
-
if (input !== undefined)
|
|
367
|
-
appendBufferedInput(input);
|
|
368
|
-
return;
|
|
369
|
-
}
|
|
370
|
-
// Drop the dead handle first: `isUsable()` then short-circuits every chunk
|
|
371
|
-
// that arrives mid-recovery, which is what actually silences the flood.
|
|
372
|
-
const dead = getStream();
|
|
373
|
-
setStream(null);
|
|
374
|
-
try {
|
|
375
|
-
dead?.close(1000, `${label} client replacing input stream`);
|
|
376
|
-
}
|
|
377
|
-
catch {
|
|
378
|
-
// best effort — already closed in the common case
|
|
379
|
-
}
|
|
380
|
-
onRollback();
|
|
381
|
-
if (input !== undefined)
|
|
382
|
-
appendBufferedInput(input);
|
|
383
|
-
if (maxAttempts <= 0) {
|
|
384
|
-
error(`[${label}] input stream lost (${reason}); reconnect is disabled. ` +
|
|
385
|
-
`Detaching — ${name} is still running; reattach to resume.` +
|
|
386
|
-
discardedMessage(discardBufferedInput()));
|
|
387
|
-
onExhausted();
|
|
388
|
-
return;
|
|
389
|
-
}
|
|
390
|
-
// One line for the outage, not one per keystroke.
|
|
391
|
-
log(`[${label}] input stream lost (${reason}); reconnecting…`);
|
|
392
|
-
let replayedAcrossAttempts = 0;
|
|
393
|
-
let uncertainAcrossAttempts = 0;
|
|
394
|
-
let discardedAcrossAttempts = 0;
|
|
395
|
-
const uncertainMessage = () => uncertainAcrossAttempts > 0
|
|
396
|
-
? ` ${uncertainAcrossAttempts} buffered bytes were sent once but not confirmed; they may still land.`
|
|
397
|
-
: '';
|
|
398
|
-
/**
|
|
399
|
-
* One reopen attempt. `'settled'` means the session went away mid-attempt,
|
|
400
|
-
* `'retry'` a transport failure worth another go, and `'rejected'` a
|
|
401
|
-
* replacement that opened but could not be vouched for — which must not be
|
|
402
|
-
* retried, because a replaced worker does not become the original one on a
|
|
403
|
-
* later attempt.
|
|
404
|
-
*
|
|
405
|
-
* `attemptReopen` owns `replacement` on **every** exit path. `openStream()`
|
|
406
|
-
* creates the socket eagerly, so any return that does not hand it to
|
|
407
|
-
* `setStream` must close it or leak a live WebSocket with no owner — which
|
|
408
|
-
* can also keep the process alive after a clean detach.
|
|
409
|
-
*/
|
|
410
|
-
const attemptReopen = async (attempt) => {
|
|
411
|
-
let replacement = null;
|
|
412
|
-
try {
|
|
413
|
-
replacement = openStream();
|
|
414
|
-
candidateStream = replacement;
|
|
415
|
-
await withDeadline(replacement.waitUntilOpen(), 'input stream open');
|
|
416
|
-
}
|
|
417
|
-
catch {
|
|
418
|
-
// Stay quiet between attempts. The human saw one line when the outage
|
|
419
|
-
// started and sees exactly one more when it resolves either way;
|
|
420
|
-
// narrating each failed retry would rebuild the flood.
|
|
421
|
-
if (replacement)
|
|
422
|
-
closeQuietly(replacement, `${label} client abandoning attempt`);
|
|
423
|
-
candidateStream = null;
|
|
424
|
-
return 'retry';
|
|
425
|
-
}
|
|
426
|
-
if (isSettled()) {
|
|
427
|
-
closeQuietly(replacement, `${label} client exiting`);
|
|
428
|
-
candidateStream = null;
|
|
429
|
-
resetBufferedInput();
|
|
430
|
-
return 'settled';
|
|
431
|
-
}
|
|
432
|
-
// The socket is open, but "open" only proves the name resolved. Do not
|
|
433
|
-
// hand the human's keystrokes to it until it is the same worker.
|
|
434
|
-
//
|
|
435
|
-
// The type makes `verifyIdentity` mandatory; this enforces it at runtime
|
|
436
|
-
// too. A JS caller, a partial test double, or a future refactor that
|
|
437
|
-
// drops the field must not silently reach the unguarded path — the whole
|
|
438
|
-
// point is that reattaching by name is unsafe without a check.
|
|
439
|
-
if (typeof verifyIdentity !== 'function') {
|
|
440
|
-
closeQuietly(replacement, `${label} client rejected replacement`);
|
|
441
|
-
candidateStream = null;
|
|
442
|
-
const discarded = discardedAcrossAttempts + discardBufferedInput();
|
|
443
|
-
error(`[${label}] input stream reopened but no worker identity verifier was supplied, ` +
|
|
444
|
-
`so it cannot be shown to be the same worker. Refusing to forward input. ` +
|
|
445
|
-
`Detaching; reattach to ${name} to continue.` +
|
|
446
|
-
discardedMessage(discarded) +
|
|
447
|
-
uncertainMessage());
|
|
448
|
-
return 'rejected';
|
|
449
|
-
}
|
|
450
|
-
// A verifier that throws or stalls has not said yes, so both collapse
|
|
451
|
-
// into the same refusal rather than escaping and stranding the session
|
|
452
|
-
// with no stream and no exit.
|
|
453
|
-
//
|
|
454
|
-
// `verifyIdentity()` is invoked inside the promise chain, not as an
|
|
455
|
-
// argument to it: the type permits a non-`async` function, and a
|
|
456
|
-
// synchronous throw evaluated in the argument position would escape
|
|
457
|
-
// before `.catch()` was ever attached — skipping the refusal, the
|
|
458
|
-
// exhaustion exit, and the close below.
|
|
459
|
-
const verdict = await withDeadline(Promise.resolve().then(() => verifyIdentity()), 'worker identity check').catch((verifyError) => ({
|
|
460
|
-
ok: false,
|
|
461
|
-
reason: verifyError instanceof Error
|
|
462
|
-
? `identity check failed: ${verifyError.message}`
|
|
463
|
-
: `identity check failed: ${String(verifyError)}`,
|
|
464
|
-
}));
|
|
465
|
-
if (isSettled()) {
|
|
466
|
-
closeQuietly(replacement, `${label} client exiting`);
|
|
467
|
-
candidateStream = null;
|
|
468
|
-
resetBufferedInput();
|
|
469
|
-
return 'settled';
|
|
470
|
-
}
|
|
471
|
-
if (!verdict.ok) {
|
|
472
|
-
closeQuietly(replacement, `${label} client rejected replacement`);
|
|
473
|
-
candidateStream = null;
|
|
474
|
-
const discarded = discardedAcrossAttempts + discardBufferedInput();
|
|
475
|
-
error(`[${label}] input stream reopened but it is not the same worker (${verdict.reason}). ` +
|
|
476
|
-
`Refusing to forward input — your keystrokes would go somewhere you did not attach to. ` +
|
|
477
|
-
`Detaching; reattach to ${name} to continue.` +
|
|
478
|
-
discardedMessage(discarded) +
|
|
479
|
-
uncertainMessage());
|
|
480
|
-
return 'rejected';
|
|
481
|
-
}
|
|
482
|
-
// A positive identity verdict is the hard safety gate. Nothing buffered
|
|
483
|
-
// during the outage may reach `replacement.send()` above this point.
|
|
484
|
-
const replay = await replayBufferedInput(replacement);
|
|
485
|
-
replayedAcrossAttempts += replay.replayedBytes;
|
|
486
|
-
uncertainAcrossAttempts += replay.uncertainBytes;
|
|
487
|
-
discardedAcrossAttempts += replay.discardedBytes;
|
|
488
|
-
if (replay.outcome === 'settled' || isSettled()) {
|
|
489
|
-
closeQuietly(replacement, `${label} client exiting`);
|
|
490
|
-
candidateStream = null;
|
|
491
|
-
resetBufferedInput();
|
|
492
|
-
return 'settled';
|
|
493
|
-
}
|
|
494
|
-
if (replay.outcome === 'retry') {
|
|
495
|
-
closeQuietly(replacement, `${label} client abandoning failed replay`);
|
|
496
|
-
candidateStream = null;
|
|
497
|
-
return 'retry';
|
|
498
|
-
}
|
|
499
|
-
setStream(replacement);
|
|
500
|
-
candidateStream = null;
|
|
501
|
-
// Say plainly that the session survived. A recovered flap and a fatal
|
|
502
|
-
// disconnect previously read the same to a human — both were red lines
|
|
503
|
-
// that named a failure and stopped — so operators read a working session
|
|
504
|
-
// as a crash (relay#1597).
|
|
505
|
-
log(`[${label}] input stream reconnected after ${attempt} attempt(s) — ${name} is still attached ` +
|
|
506
|
-
`and usable.` +
|
|
507
|
-
(replayedAcrossAttempts > 0
|
|
508
|
-
? ` Replayed ${replayedAcrossAttempts} buffered bytes after verifying the worker identity.`
|
|
509
|
-
: '') +
|
|
510
|
-
uncertainMessage() +
|
|
511
|
-
(discardedAcrossAttempts > 0
|
|
512
|
-
? ` Discarded ${discardedAcrossAttempts} buffered bytes that could not be replayed safely.`
|
|
513
|
-
: ''));
|
|
514
|
-
return 'opened';
|
|
515
|
-
};
|
|
516
|
-
inFlight = (async () => {
|
|
517
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
518
|
-
if (isSettled())
|
|
519
|
-
return;
|
|
520
|
-
const delay = Math.min(baseDelayMs * 2 ** (attempt - 1), INPUT_REOPEN_MAX_DELAY_MS);
|
|
521
|
-
await new Promise((resolve) => {
|
|
522
|
-
releaseBackoff = resolve;
|
|
523
|
-
timer = setTimeout(resolve, delay);
|
|
524
|
-
timer.unref?.();
|
|
525
|
-
});
|
|
526
|
-
timer = null;
|
|
527
|
-
releaseBackoff = null;
|
|
528
|
-
if (isSettled())
|
|
529
|
-
return;
|
|
530
|
-
const outcome = await attemptReopen(attempt);
|
|
531
|
-
if (outcome === 'opened' || outcome === 'settled')
|
|
532
|
-
return;
|
|
533
|
-
if (outcome === 'rejected') {
|
|
534
|
-
onExhausted();
|
|
535
|
-
return;
|
|
536
|
-
}
|
|
537
|
-
}
|
|
538
|
-
if (isSettled())
|
|
539
|
-
return;
|
|
540
|
-
error(`[${label}] input stream could not be reopened after ${maxAttempts} attempts (${reason}). ` +
|
|
541
|
-
`Detaching — ${name} is still running; reattach to resume.` +
|
|
542
|
-
discardedMessage(discardedAcrossAttempts + discardBufferedInput()) +
|
|
543
|
-
uncertainMessage());
|
|
544
|
-
onExhausted();
|
|
545
|
-
})().finally(() => {
|
|
546
|
-
inFlight = null;
|
|
547
|
-
});
|
|
548
|
-
};
|
|
549
|
-
return {
|
|
550
|
-
isUsable,
|
|
551
|
-
isRecovering: () => inFlight !== null,
|
|
552
|
-
recover,
|
|
553
|
-
handleSendFailure,
|
|
554
|
-
bufferInput,
|
|
555
|
-
noteSendSuccess,
|
|
556
|
-
cancel,
|
|
557
|
-
};
|
|
558
|
-
}
|
|
559
|
-
//# sourceMappingURL=attach-input-recovery.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach-input-recovery.js","sourceRoot":"","sources":["../../../src/cli/lib/attach-input-recovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAIrC,qFAAqF;AACrF,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC;AAC3C,sEAAsE;AACtE,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC;AAC9C,2CAA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,cAAc,GAAG,IAAI,CAAC;gBACtB,IAAI,SAAS,EAAE;oBAAE,OAAO;gBAExB,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,OAAO,CAAC,CAAC;gBAC7C,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,SAAS;oBAAE,OAAO;gBAC1D,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;oBAC3B,WAAW,EAAE,CAAC;oBACd,OAAO;gBACT,CAAC;YACH,CAAC;YACD,IAAI,SAAS,EAAE;gBAAE,OAAO;YACxB,KAAK,CACH,IAAI,KAAK,8CAA8C,WAAW,cAAc,MAAM,KAAK;gBACzF,eAAe,IAAI,wCAAwC;gBAC3D,gBAAgB,CAAC,uBAAuB,GAAG,oBAAoB,EAAE,CAAC;gBAClE,gBAAgB,EAAE,CACrB,CAAC;YACF,WAAW,EAAE,CAAC;QAChB,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;YAChB,QAAQ,GAAG,IAAI,CAAC;QAClB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF,OAAO;QACL,QAAQ;QACR,YAAY,EAAE,GAAG,EAAE,CAAC,QAAQ,KAAK,IAAI;QACrC,OAAO;QACP,iBAAiB;QACjB,WAAW;QACX,eAAe;QACf,MAAM;KACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach-mode.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/attach-mode.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach-mode.js","sourceRoot":"","sources":["../../../src/cli/lib/attach-mode.ts"],"names":[],"mappings":""}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { type Interface as ReadlineInterface } from 'node:readline';
|
|
2
|
-
import { HarnessDriverClient, type NativeHarnessDiagnosticEnvelope, type AgentEventEnvelope } from '@agent-relay/harness-driver';
|
|
3
|
-
import { type BrokerConnection } from './broker-connection.js';
|
|
4
|
-
export type NativeAttachMode = 'view' | 'drive' | 'passthrough';
|
|
5
|
-
export interface NativeAttachOptions {
|
|
6
|
-
brokerUrl?: string;
|
|
7
|
-
apiKey?: string;
|
|
8
|
-
stateDir?: string;
|
|
9
|
-
json?: boolean;
|
|
10
|
-
reasoning?: boolean;
|
|
11
|
-
diagnostics?: boolean;
|
|
12
|
-
}
|
|
13
|
-
export interface NativeAttachOutput {
|
|
14
|
-
stdout(text: string): void;
|
|
15
|
-
stderr(text: string): void;
|
|
16
|
-
}
|
|
17
|
-
export declare function renderAgentEvent(envelope: AgentEventEnvelope, options?: Pick<NativeAttachOptions, 'json' | 'reasoning'>): string | null;
|
|
18
|
-
export declare function renderNativeHarnessDiagnostic(envelope: NativeHarnessDiagnosticEnvelope, options?: Pick<NativeAttachOptions, 'json' | 'diagnostics'>): string | null;
|
|
19
|
-
export interface NativeAttachDependencies {
|
|
20
|
-
connect(connection: BrokerConnection): HarnessDriverClient;
|
|
21
|
-
output: NativeAttachOutput;
|
|
22
|
-
createReadline(): ReadlineInterface;
|
|
23
|
-
onSignal(handler: () => void): () => void;
|
|
24
|
-
}
|
|
25
|
-
export declare function attachNative(name: string, mode: NativeAttachMode, options: NativeAttachOptions, overrides?: Partial<NativeAttachDependencies>): Promise<number>;
|
|
26
|
-
export declare function isNativeHarness(name: string, options: NativeAttachOptions, fetchFn?: typeof globalThis.fetch): Promise<boolean>;
|
|
27
|
-
//# sourceMappingURL=attach-native.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach-native.d.ts","sourceRoot":"","sources":["../../../src/cli/lib/attach-native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGrF,OAAO,EACL,mBAAmB,EAGnB,KAAK,+BAA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