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.
- package/README.md +74 -266
- 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 +6 -2
- package/dist/cli/commands/cloud-worker.d.ts.map +1 -1
- package/dist/cli/commands/cloud-worker.js +74 -37
- 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 +20 -18
- 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 +2 -2
- 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 +40 -0
- package/dist/cli/lib/agent-relay-cli-reentry.d.ts.map +1 -0
- package/dist/cli/lib/agent-relay-cli-reentry.js +47 -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/cloud-worker-authored-runtime.d.ts +3 -0
- package/dist/cli/lib/cloud-worker-authored-runtime.d.ts.map +1 -0
- package/dist/cli/lib/cloud-worker-authored-runtime.js +67 -0
- package/dist/cli/lib/cloud-worker-authored-runtime.js.map +1 -0
- package/dist/cli/lib/cloud-worker-enrollment-token.d.ts +13 -0
- package/dist/cli/lib/cloud-worker-enrollment-token.d.ts.map +1 -0
- package/dist/cli/lib/cloud-worker-enrollment-token.js +88 -0
- package/dist/cli/lib/cloud-worker-enrollment-token.js.map +1 -0
- 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 +9 -14
- 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,455 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `agent-relay view <name>` — read-only PTY stream client.
|
|
3
|
-
*
|
|
4
|
-
* Connects to a running broker's `/ws` WebSocket, filters the event stream
|
|
5
|
-
* for `worker_stream` frames matching the requested agent name, and writes
|
|
6
|
-
* each chunk's raw bytes to stdout (preserving ANSI escapes).
|
|
7
|
-
*
|
|
8
|
-
* No keystrokes are forwarded — the broker keeps doing whatever it's doing.
|
|
9
|
-
* Ctrl+C exits the client cleanly; the agent keeps running under the broker.
|
|
10
|
-
*
|
|
11
|
-
* Because nothing is forwarded, DECSET modes that make the *local* terminal
|
|
12
|
-
* generate input reports (mouse tracking, focus events, bracketed paste, …)
|
|
13
|
-
* are stripped from the stream before it reaches stdout — see
|
|
14
|
-
* {@link InputReportModeFilter}. The interactive verbs (`drive`,
|
|
15
|
-
* `passthrough`) keep those modes: they own stdin in raw mode and forward
|
|
16
|
-
* the reports to the agent, where a TUI can actually consume them.
|
|
17
|
-
*/
|
|
18
|
-
import fs from 'node:fs';
|
|
19
|
-
import path from 'node:path';
|
|
20
|
-
import WebSocket from 'ws';
|
|
21
|
-
import { getProjectPaths } from '@agent-relay/config';
|
|
22
|
-
import { captureAndRenderSnapshot, createBackpressureAwareWriter, resetLocalTerminalOnDetach, StreamSyncBuffer, } from '../lib/attach.js';
|
|
23
|
-
import { describeMissingBrokerConnection, resolveBrokerConnection } from '../lib/broker-connection.js';
|
|
24
|
-
import { resolveFleetHint } from '../lib/fleet-hint.js';
|
|
25
|
-
import { defaultExit, runSignalHandler } from '../lib/exit.js';
|
|
26
|
-
function readConnectionFileFromDisk(stateDir) {
|
|
27
|
-
const connPath = path.join(stateDir, 'connection.json');
|
|
28
|
-
try {
|
|
29
|
-
const raw = fs.readFileSync(connPath, 'utf-8');
|
|
30
|
-
return JSON.parse(raw);
|
|
31
|
-
}
|
|
32
|
-
catch {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function defaultStateDir() {
|
|
37
|
-
// Match the Rust broker's discovery convention: `.agentworkforce/relay/` under the
|
|
38
|
-
// project root (resolved the same way the rest of the CLI does it).
|
|
39
|
-
const projectRoot = getProjectPaths().projectRoot;
|
|
40
|
-
return path.join(projectRoot, '.agentworkforce/relay');
|
|
41
|
-
}
|
|
42
|
-
function withDefaults(overrides = {}) {
|
|
43
|
-
const writer = createBackpressureAwareWriter(process.stdout);
|
|
44
|
-
return {
|
|
45
|
-
readConnectionFile: readConnectionFileFromDisk,
|
|
46
|
-
getDefaultStateDir: defaultStateDir,
|
|
47
|
-
env: process.env,
|
|
48
|
-
stdin: process.stdin,
|
|
49
|
-
createWebSocket: (url, headers) => new WebSocket(url, { headers }),
|
|
50
|
-
writeChunk: writer.write,
|
|
51
|
-
disposeWriter: writer.dispose,
|
|
52
|
-
onSignal: (signal, handler) => {
|
|
53
|
-
const listener = () => runSignalHandler(handler);
|
|
54
|
-
process.on(signal, listener);
|
|
55
|
-
return () => process.off(signal, listener);
|
|
56
|
-
},
|
|
57
|
-
log: (...args) => console.error(...args),
|
|
58
|
-
error: (...args) => console.error(...args),
|
|
59
|
-
exit: defaultExit,
|
|
60
|
-
fetch: (input, init) => fetch(input, init),
|
|
61
|
-
captureAndRenderSnapshot,
|
|
62
|
-
fleetHint: resolveFleetHint,
|
|
63
|
-
stdoutIsTty: Boolean(process.stdout.isTTY),
|
|
64
|
-
...overrides,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function isStringObject(value) {
|
|
68
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Resolve the broker connection to use for `view`. Delegates to the shared
|
|
72
|
-
* {@link resolveBrokerConnection} so `view` honours `--state-dir` exactly like
|
|
73
|
-
* every other local broker verb.
|
|
74
|
-
*/
|
|
75
|
-
export function resolveViewBrokerConnection(options, deps) {
|
|
76
|
-
return resolveBrokerConnection(options, deps);
|
|
77
|
-
}
|
|
78
|
-
/** Convert an `http(s)://host:port` base URL to the matching `ws(s)://…/ws`. */
|
|
79
|
-
export function toWsUrl(baseUrl) {
|
|
80
|
-
return `${baseUrl.replace(/^http/, 'ws')}/ws`;
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Inspect a single WebSocket message and, if it's a `worker_stream` event for
|
|
84
|
-
* the requested agent, return the raw chunk string plus its stream offset.
|
|
85
|
-
* Returns `null` for events that don't match (other kinds, other agents,
|
|
86
|
-
* malformed JSON, etc.) so the caller can ignore them.
|
|
87
|
-
*
|
|
88
|
-
* Exported for unit testing the filter in isolation from any WebSocket.
|
|
89
|
-
*/
|
|
90
|
-
export function extractMatchingChunk(rawMessage, agentName) {
|
|
91
|
-
let parsed;
|
|
92
|
-
try {
|
|
93
|
-
parsed = JSON.parse(rawMessage);
|
|
94
|
-
}
|
|
95
|
-
catch {
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
if (!isStringObject(parsed))
|
|
99
|
-
return null;
|
|
100
|
-
if (parsed.kind !== 'worker_stream')
|
|
101
|
-
return null;
|
|
102
|
-
if (parsed.name !== agentName)
|
|
103
|
-
return null;
|
|
104
|
-
const chunk = parsed.chunk;
|
|
105
|
-
if (typeof chunk !== 'string')
|
|
106
|
-
return null;
|
|
107
|
-
const offset = typeof parsed.offset === 'number' ? parsed.offset : undefined;
|
|
108
|
-
return { chunk, offset };
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* DECSET (`CSI ? … h`) modes that instruct the terminal to *send* escape
|
|
112
|
-
* sequences on input events. Enabling any of these on the viewer's local
|
|
113
|
-
* terminal is harmful: `view` never reads stdin (it stays cooked and
|
|
114
|
-
* echoing), so every report the terminal emits — mouse motion like
|
|
115
|
-
* `ESC [<35;22;25M`, focus in/out, paste guards — is echoed straight into
|
|
116
|
-
* the display as garbage instead of being consumed (#1247-adjacent; the
|
|
117
|
-
* on-detach reset already disables them, but that never helped mid-session).
|
|
118
|
-
*
|
|
119
|
-
* - 9, 1000, 1001, 1002, 1003 — X10/normal/highlight/button/any-event mouse
|
|
120
|
-
* - 1004 — focus in/out reporting
|
|
121
|
-
* - 1005, 1006, 1015, 1016 — mouse coordinate encodings
|
|
122
|
-
* - 1007 — alternate scroll (wheel → arrow-key input)
|
|
123
|
-
* - 2004 — bracketed paste
|
|
124
|
-
*/
|
|
125
|
-
const INPUT_REPORT_MODES = new Set([
|
|
126
|
-
9, 1000, 1001, 1002, 1003, 1004, 1005, 1006, 1007, 1015, 1016, 2004,
|
|
127
|
-
]);
|
|
128
|
-
/** Longest escape-sequence prefix the filter will hold across chunk
|
|
129
|
-
* boundaries before giving up on it. Any DECSET we care about is far
|
|
130
|
-
* shorter — even a full private-mode init that batches every mode stays well
|
|
131
|
-
* under this — so the cap only bites on a pathological CSI (an agent that
|
|
132
|
-
* stalls mid-sequence), where it bounds memory and latency. Beyond the cap an
|
|
133
|
-
* incomplete private-mode (`CSI ? …`) prefix is dropped rather than flushed,
|
|
134
|
-
* so a later chunk's final `h` can't re-enable an input-report mode on the
|
|
135
|
-
* local terminal; any other CSI is passed through verbatim. */
|
|
136
|
-
const MAX_HELD_SEQUENCE_LENGTH = 256;
|
|
137
|
-
/** An incomplete private-mode CSI (`CSI ? …`) that is still only parameter
|
|
138
|
-
* bytes — digits and `;` with no final byte yet. Flushing a prefix like this
|
|
139
|
-
* is unsafe: a later chunk's `h` would complete it locally and re-enable the
|
|
140
|
-
* very input-report modes this filter strips, so an over-long one is dropped
|
|
141
|
-
* instead of passed through. */
|
|
142
|
-
// eslint-disable-next-line no-control-regex -- intentionally matching a raw ESC byte in PTY output
|
|
143
|
-
const PARTIAL_PRIVATE_MODE = /^\x1b\[\?[0-9;]*$/;
|
|
144
|
-
/**
|
|
145
|
-
* Streaming filter that removes input-report DECSET *enables* from a PTY
|
|
146
|
-
* byte stream. Everything else — including the matching `CSI ? … l`
|
|
147
|
-
* disables, all other CSIs, OSC/DCS strings, and printable text — passes
|
|
148
|
-
* through byte-for-byte.
|
|
149
|
-
*
|
|
150
|
-
* A CSI sequence may be split across `worker_stream` frames, so the filter
|
|
151
|
-
* holds an incomplete trailing ESC/CSI prefix (bounded by
|
|
152
|
-
* {@link MAX_HELD_SEQUENCE_LENGTH}) until the next chunk completes it.
|
|
153
|
-
* Multi-mode sets like `CSI ? 1002;1006 h` are rewritten to keep only the
|
|
154
|
-
* non-input-report modes (dropped entirely when none remain).
|
|
155
|
-
*
|
|
156
|
-
* Only ASCII control bytes drive the parsing; multi-byte UTF-8 payload
|
|
157
|
-
* characters never appear inside a CSI, so scanning UTF-16 code units is
|
|
158
|
-
* safe (same reasoning as `AnsiBoundaryScanner`).
|
|
159
|
-
*/
|
|
160
|
-
export class InputReportModeFilter {
|
|
161
|
-
/** Incomplete ESC/CSI prefix held from the previous chunk. */
|
|
162
|
-
held = '';
|
|
163
|
-
/** Filter a chunk, returning the bytes safe to write to the local
|
|
164
|
-
* terminal. May return `''` while a split sequence is being held. */
|
|
165
|
-
push(chunk) {
|
|
166
|
-
// Fast path: nothing held and no ESC anywhere — pass through untouched.
|
|
167
|
-
if (this.held === '' && chunk.indexOf('\x1b') === -1)
|
|
168
|
-
return chunk;
|
|
169
|
-
const data = this.held + chunk;
|
|
170
|
-
this.held = '';
|
|
171
|
-
let out = '';
|
|
172
|
-
let i = 0;
|
|
173
|
-
while (i < data.length) {
|
|
174
|
-
const esc = data.indexOf('\x1b', i);
|
|
175
|
-
if (esc === -1) {
|
|
176
|
-
out += data.slice(i);
|
|
177
|
-
break;
|
|
178
|
-
}
|
|
179
|
-
out += data.slice(i, esc);
|
|
180
|
-
if (esc + 1 >= data.length) {
|
|
181
|
-
// Chunk ends on a bare ESC — hold it for the next push.
|
|
182
|
-
this.held = '\x1b';
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
if (data.charCodeAt(esc + 1) !== 0x5b /* [ */) {
|
|
186
|
-
// Not a CSI (2-byte escape, OSC/DCS intro, …) — never a DECSET;
|
|
187
|
-
// emit the ESC and resume scanning right after it.
|
|
188
|
-
out += '\x1b';
|
|
189
|
-
i = esc + 1;
|
|
190
|
-
continue;
|
|
191
|
-
}
|
|
192
|
-
// CSI: find the final byte (0x40–0x7E).
|
|
193
|
-
let j = esc + 2;
|
|
194
|
-
while (j < data.length && !(data.charCodeAt(j) >= 0x40 && data.charCodeAt(j) <= 0x7e)) {
|
|
195
|
-
j += 1;
|
|
196
|
-
}
|
|
197
|
-
if (j >= data.length) {
|
|
198
|
-
const tail = data.slice(esc);
|
|
199
|
-
if (tail.length <= MAX_HELD_SEQUENCE_LENGTH) {
|
|
200
|
-
this.held = tail; // incomplete CSI — hold until the next chunk
|
|
201
|
-
}
|
|
202
|
-
else if (!PARTIAL_PRIVATE_MODE.test(tail)) {
|
|
203
|
-
out += tail; // pathologically long non-private CSI — give up filtering it
|
|
204
|
-
}
|
|
205
|
-
// else: an over-long incomplete private-mode prefix. Drop it — flushing
|
|
206
|
-
// the partial `CSI ? …` would let the next frame's final `h` re-enable
|
|
207
|
-
// an input-report mode locally, the exact spray this filter prevents.
|
|
208
|
-
break;
|
|
209
|
-
}
|
|
210
|
-
out += filterCompleteCsi(data.slice(esc, j + 1));
|
|
211
|
-
i = j + 1;
|
|
212
|
-
}
|
|
213
|
-
return out;
|
|
214
|
-
}
|
|
215
|
-
/** Drop any held partial sequence (detach teardown — an incomplete
|
|
216
|
-
* escape prefix written alone would itself garble the terminal). */
|
|
217
|
-
reset() {
|
|
218
|
-
this.held = '';
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
/** Rewrite one complete CSI sequence: strip input-report modes from a
|
|
222
|
-
* DECSET enable, pass every other CSI through verbatim. */
|
|
223
|
-
function filterCompleteCsi(sequence) {
|
|
224
|
-
// eslint-disable-next-line no-control-regex -- intentionally matching a raw ESC byte in PTY output
|
|
225
|
-
const match = /^\x1b\[\?([0-9;]+)h$/.exec(sequence);
|
|
226
|
-
if (!match)
|
|
227
|
-
return sequence;
|
|
228
|
-
const kept = match[1].split(';').filter((mode) => !INPUT_REPORT_MODES.has(Number(mode)));
|
|
229
|
-
if (kept.length === 0)
|
|
230
|
-
return '';
|
|
231
|
-
return `\x1b[?${kept.join(';')}h`;
|
|
232
|
-
}
|
|
233
|
-
/**
|
|
234
|
-
* Open the read-only view stream and run until the WebSocket closes, the
|
|
235
|
-
* caller signals SIGINT/SIGTERM, or an unrecoverable error occurs. Resolves
|
|
236
|
-
* with the exit code the CLI should propagate.
|
|
237
|
-
*/
|
|
238
|
-
export async function runViewSession(agentName, options, deps) {
|
|
239
|
-
// Normalize once so every downstream lookup, WS-event match, and
|
|
240
|
-
// error message uses the same value. A stray space in the raw input
|
|
241
|
-
// otherwise turns into a silent 404 (broker stores names verbatim).
|
|
242
|
-
const name = agentName.trim();
|
|
243
|
-
if (!name) {
|
|
244
|
-
deps.error('Error: agent name is required');
|
|
245
|
-
return 1;
|
|
246
|
-
}
|
|
247
|
-
const connection = resolveViewBrokerConnection(options, deps);
|
|
248
|
-
if (!connection) {
|
|
249
|
-
deps.error(describeMissingBrokerConnection(options, deps));
|
|
250
|
-
return 1;
|
|
251
|
-
}
|
|
252
|
-
const wsUrl = toWsUrl(connection.url);
|
|
253
|
-
const headers = {};
|
|
254
|
-
if (connection.apiKey) {
|
|
255
|
-
headers['X-API-Key'] = connection.apiKey;
|
|
256
|
-
}
|
|
257
|
-
return new Promise((resolve) => {
|
|
258
|
-
let settled = false;
|
|
259
|
-
let rawModeWasSet = false;
|
|
260
|
-
const cleanupSignals = [];
|
|
261
|
-
// Subscribe-first: buffer live `worker_stream` chunks until the snapshot
|
|
262
|
-
// is painted and reconciled, so no output around attach time is lost and
|
|
263
|
-
// (via per-worker offsets) none is double-applied. See StreamSyncBuffer.
|
|
264
|
-
const sync = new StreamSyncBuffer();
|
|
265
|
-
// Every byte of agent output (snapshot + live) flows through this filter
|
|
266
|
-
// so input-report modes never reach the viewer's terminal — `view` has no
|
|
267
|
-
// one consuming the reports they would trigger. The on-detach reset below
|
|
268
|
-
// bypasses it deliberately (its `?…l` disables must go out verbatim).
|
|
269
|
-
const inputModeFilter = new InputReportModeFilter();
|
|
270
|
-
const writeAgentOutput = (chunk) => {
|
|
271
|
-
const filtered = inputModeFilter.push(chunk);
|
|
272
|
-
if (filtered.length > 0)
|
|
273
|
-
deps.writeChunk(filtered);
|
|
274
|
-
};
|
|
275
|
-
// `view` never forwards stdin. Still consume it in raw mode so mouse,
|
|
276
|
-
// focus, and alternate-scroll reports cannot be cooked-mode echoed into
|
|
277
|
-
// the viewer as visible `^[[0A` / `^[[0B` garbage. Ctrl+C must be handled
|
|
278
|
-
// here because raw mode disables the terminal driver's SIGINT handling.
|
|
279
|
-
const stdinDataHandler = (chunk) => {
|
|
280
|
-
if (chunk.includes(0x03))
|
|
281
|
-
finish(0);
|
|
282
|
-
};
|
|
283
|
-
const teardownStdin = () => {
|
|
284
|
-
try {
|
|
285
|
-
if (deps.stdin.off) {
|
|
286
|
-
deps.stdin.off('data', stdinDataHandler);
|
|
287
|
-
}
|
|
288
|
-
else if (deps.stdin.removeListener) {
|
|
289
|
-
deps.stdin.removeListener('data', stdinDataHandler);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
catch {
|
|
293
|
-
// best effort
|
|
294
|
-
}
|
|
295
|
-
try {
|
|
296
|
-
if (rawModeWasSet && typeof deps.stdin.setRawMode === 'function') {
|
|
297
|
-
deps.stdin.setRawMode(false);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
catch {
|
|
301
|
-
// best effort
|
|
302
|
-
}
|
|
303
|
-
try {
|
|
304
|
-
deps.stdin.pause();
|
|
305
|
-
}
|
|
306
|
-
catch {
|
|
307
|
-
// best effort
|
|
308
|
-
}
|
|
309
|
-
};
|
|
310
|
-
const finish = (code) => {
|
|
311
|
-
if (settled)
|
|
312
|
-
return;
|
|
313
|
-
settled = true;
|
|
314
|
-
for (const cleanup of cleanupSignals.splice(0)) {
|
|
315
|
-
try {
|
|
316
|
-
cleanup();
|
|
317
|
-
}
|
|
318
|
-
catch {
|
|
319
|
-
// best effort
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
try {
|
|
323
|
-
socket.close(1000, 'view client exiting');
|
|
324
|
-
}
|
|
325
|
-
catch {
|
|
326
|
-
// best effort — already closed
|
|
327
|
-
}
|
|
328
|
-
try {
|
|
329
|
-
// A graceful WebSocket close can leave its underlying socket alive
|
|
330
|
-
// while waiting for the broker's close acknowledgement. A local
|
|
331
|
-
// detach has no state to flush, so terminate it immediately rather
|
|
332
|
-
// than requiring another Ctrl-C to make Node leave the event loop.
|
|
333
|
-
socket.terminate?.();
|
|
334
|
-
}
|
|
335
|
-
catch {
|
|
336
|
-
// best effort — already closed
|
|
337
|
-
}
|
|
338
|
-
try {
|
|
339
|
-
// Heal the local terminal: a replayed snapshot re-emits terminal modes
|
|
340
|
-
// (alt-screen, mouse reporting, bracketed paste, ...) that would
|
|
341
|
-
// otherwise linger after the viewer detaches. TTY stdout only.
|
|
342
|
-
// Must run before disposeWriter — the writer no-ops once disposed.
|
|
343
|
-
resetLocalTerminalOnDetach(deps.writeChunk, deps.stdoutIsTty);
|
|
344
|
-
}
|
|
345
|
-
catch {
|
|
346
|
-
// best effort
|
|
347
|
-
}
|
|
348
|
-
teardownStdin();
|
|
349
|
-
// Drop the writer's pending queue and unhook its drain listener so no
|
|
350
|
-
// buffered chunk flushes to stdout after detach.
|
|
351
|
-
deps.disposeWriter?.();
|
|
352
|
-
resolve(code);
|
|
353
|
-
};
|
|
354
|
-
// Render the agent's current screen once the WS is subscribed, then
|
|
355
|
-
// reconcile the buffered live chunks against it. Hard errors
|
|
356
|
-
// (`not_found` / `no_pty`) abort — there's nothing meaningful to view.
|
|
357
|
-
// Transient errors (`unavailable` / `transport_error`) are surfaced as a
|
|
358
|
-
// warning and we fall through to the live stream; the agent may still
|
|
359
|
-
// produce useful output even if the snapshot couldn't be served.
|
|
360
|
-
// Guard every snapshot-path write on `settled` so a Ctrl+C that lands
|
|
361
|
-
// while the snapshot HTTP fetch is in flight can't paint the snapshot
|
|
362
|
-
// after teardown has begun (the snapshot render path runs inside the
|
|
363
|
-
// awaited `captureAndRenderSnapshot`, past the WS `message` guard).
|
|
364
|
-
const guardedWrite = (chunk) => {
|
|
365
|
-
if (!settled)
|
|
366
|
-
writeAgentOutput(chunk);
|
|
367
|
-
};
|
|
368
|
-
const paintSnapshotAndReconcile = async () => {
|
|
369
|
-
const snapshot = await deps.captureAndRenderSnapshot(connection, name, {
|
|
370
|
-
fetch: deps.fetch,
|
|
371
|
-
writeChunk: guardedWrite,
|
|
372
|
-
fleetHint: deps.fleetHint,
|
|
373
|
-
});
|
|
374
|
-
if (settled)
|
|
375
|
-
return;
|
|
376
|
-
switch (snapshot.status) {
|
|
377
|
-
case 'ok':
|
|
378
|
-
for (const chunk of sync.reconcile(snapshot.offset))
|
|
379
|
-
writeAgentOutput(chunk);
|
|
380
|
-
return;
|
|
381
|
-
case 'not_found':
|
|
382
|
-
deps.error(`Error: ${snapshot.message ?? `no agent named '${name}'`}`);
|
|
383
|
-
finish(1);
|
|
384
|
-
return;
|
|
385
|
-
case 'no_pty':
|
|
386
|
-
deps.error(`Error: ${snapshot.message ?? `agent '${name}' has no PTY to view`}`);
|
|
387
|
-
finish(1);
|
|
388
|
-
return;
|
|
389
|
-
case 'unavailable':
|
|
390
|
-
case 'transport_error':
|
|
391
|
-
deps.log(`[view] could not capture initial screen (${snapshot.message ?? snapshot.status}); streaming live output only`);
|
|
392
|
-
// No snapshot painted — apply everything buffered so far rather
|
|
393
|
-
// than dropping live output we already received.
|
|
394
|
-
for (const chunk of sync.flushAll())
|
|
395
|
-
writeAgentOutput(chunk);
|
|
396
|
-
return;
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
-
const socket = deps.createWebSocket(wsUrl, headers);
|
|
400
|
-
// Do this before rendering the snapshot: a source TUI may have enabled
|
|
401
|
-
// mouse or alternate-scroll already, and raw input is the final safeguard
|
|
402
|
-
// even if an unusual escape sequence evades the output filter.
|
|
403
|
-
try {
|
|
404
|
-
if (typeof deps.stdin.setRawMode === 'function' && deps.stdin.isTTY !== false && !deps.stdin.isRaw) {
|
|
405
|
-
deps.stdin.setRawMode(true);
|
|
406
|
-
rawModeWasSet = true;
|
|
407
|
-
}
|
|
408
|
-
deps.stdin.resume();
|
|
409
|
-
deps.stdin.on('data', stdinDataHandler);
|
|
410
|
-
}
|
|
411
|
-
catch {
|
|
412
|
-
// Read-only viewing still works on non-TTY or unusual stdin surfaces.
|
|
413
|
-
}
|
|
414
|
-
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
415
|
-
const cleanup = deps.onSignal(signal, () => finish(0));
|
|
416
|
-
if (typeof cleanup === 'function')
|
|
417
|
-
cleanupSignals.push(cleanup);
|
|
418
|
-
}
|
|
419
|
-
socket.on('open', () => {
|
|
420
|
-
void paintSnapshotAndReconcile();
|
|
421
|
-
});
|
|
422
|
-
socket.on('message', (data) => {
|
|
423
|
-
// Stop writing output once teardown has begun (no spray past detach).
|
|
424
|
-
if (settled)
|
|
425
|
-
return;
|
|
426
|
-
const text = typeof data === 'string' ? data : Buffer.isBuffer(data) ? data.toString('utf-8') : String(data);
|
|
427
|
-
const matched = extractMatchingChunk(text, name);
|
|
428
|
-
if (matched !== null && sync.push(matched.chunk, matched.offset)) {
|
|
429
|
-
writeAgentOutput(matched.chunk);
|
|
430
|
-
}
|
|
431
|
-
});
|
|
432
|
-
socket.on('error', (err) => {
|
|
433
|
-
deps.error(`[view] WebSocket error: ${err.message}`);
|
|
434
|
-
finish(1);
|
|
435
|
-
});
|
|
436
|
-
socket.on('close', (code, reason) => {
|
|
437
|
-
if (settled)
|
|
438
|
-
return;
|
|
439
|
-
const reasonText = reason && reason.length > 0 ? reason.toString('utf-8') : '';
|
|
440
|
-
if (code === 1000 || code === 1005) {
|
|
441
|
-
// Normal closure (server shut down or sent close frame without status)
|
|
442
|
-
finish(0);
|
|
443
|
-
}
|
|
444
|
-
else {
|
|
445
|
-
deps.error(`[view] connection closed (code: ${code}${reasonText ? `, reason: ${reasonText}` : ''})`);
|
|
446
|
-
finish(1);
|
|
447
|
-
}
|
|
448
|
-
});
|
|
449
|
-
});
|
|
450
|
-
}
|
|
451
|
-
/** Run a view session with default dependencies. Used by `runtime agent attach --mode view`. */
|
|
452
|
-
export function attachView(name, options, overrides = {}) {
|
|
453
|
-
return runViewSession(name, options, withDefaults(overrides));
|
|
454
|
-
}
|
|
455
|
-
//# sourceMappingURL=attach-view.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"attach-view.js","sourceRoot":"","sources":["../../../src/cli/lib/attach-view.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,SAAS,MAAM,IAAI,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,wBAAwB,EACxB,6BAA6B,EAC7B,0BAA0B,EAC1B,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,+BAA+B,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAmG/D,SAAS,0BAA0B,CAAC,QAAgB;IAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,iBAAiB,CAAC,CAAC;IACxD,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAY,CAAC;IACpC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,eAAe;IACtB,mFAAmF;IACnF,oEAAoE;IACpE,MAAM,WAAW,GAAG,eAAe,EAAE,CAAC,WAAW,CAAC;IAClD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,YAAY,CAAC,YAAuC,EA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