agent-relay-server 0.10.22 → 0.10.24
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/package.json +1 -1
- package/public/index.html +27 -31
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -117763,7 +117763,6 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117763
117763
|
const socketRef = (0, import_react.useRef)(null);
|
|
117764
117764
|
const inFlightRef = (0, import_react.useRef)(false);
|
|
117765
117765
|
const inputQueueRef = (0, import_react.useRef)(Promise.resolve());
|
|
117766
|
-
const lastSnapshotRef = (0, import_react.useRef)(null);
|
|
117767
117766
|
const resizeTimerRef = (0, import_react.useRef)(null);
|
|
117768
117767
|
const lastSentSizeRef = (0, import_react.useRef)(null);
|
|
117769
117768
|
const pausedRef = (0, import_react.useRef)(false);
|
|
@@ -117778,31 +117777,17 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117778
117777
|
(0, import_react.useEffect)(() => {
|
|
117779
117778
|
pausedRef.current = paused;
|
|
117780
117779
|
}, [paused]);
|
|
117781
|
-
const
|
|
117780
|
+
const writeSnapshot = (0, import_react.useCallback)((snapshot) => {
|
|
117782
117781
|
const terminal = terminalRef.current;
|
|
117783
117782
|
if (terminal) {
|
|
117784
117783
|
const content = (snapshot.content || "").replace(/\n$/, "");
|
|
117785
|
-
|
|
117786
|
-
|
|
117787
|
-
terminal.write(`\x1b[H\x1b[2J\x1b[3J${content}`);
|
|
117788
|
-
if (snapshot.cursorX != null && snapshot.cursorY != null) terminal.write(`\x1b[${snapshot.cursorY + 1};${snapshot.cursorX + 1}H`);
|
|
117789
|
-
if (wasAtBottom) terminal.scrollToBottom();
|
|
117790
|
-
lastSnapshotRef.current = {
|
|
117791
|
-
content,
|
|
117792
|
-
cols: snapshot.cols,
|
|
117793
|
-
rows: snapshot.rows
|
|
117794
|
-
};
|
|
117795
|
-
}
|
|
117784
|
+
terminal.write(`\x1b[H\x1b[2J\x1b[3J${content}`);
|
|
117785
|
+
if (snapshot.cursorX != null && snapshot.cursorY != null) terminal.write(`\x1b[${snapshot.cursorY + 1};${snapshot.cursorX + 1}H`);
|
|
117796
117786
|
}
|
|
117797
117787
|
setRunning(snapshot.running);
|
|
117798
117788
|
setCapturedAt(snapshot.capturedAt);
|
|
117799
117789
|
setError(null);
|
|
117800
117790
|
}, []);
|
|
117801
|
-
const renderHeartbeat = (0, import_react.useCallback)((heartbeat) => {
|
|
117802
|
-
setRunning(heartbeat.running);
|
|
117803
|
-
setCapturedAt(heartbeat.capturedAt);
|
|
117804
|
-
setError(null);
|
|
117805
|
-
}, []);
|
|
117806
117791
|
const load = (0, import_react.useCallback)(async () => {
|
|
117807
117792
|
if (paused || inFlightRef.current) return;
|
|
117808
117793
|
const socket = socketRef.current;
|
|
@@ -117812,7 +117797,7 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117812
117797
|
}
|
|
117813
117798
|
inFlightRef.current = true;
|
|
117814
117799
|
try {
|
|
117815
|
-
|
|
117800
|
+
writeSnapshot(await apiCall("GET", `/orchestrators/${encodeURIComponent(orchestratorId)}/terminal/${encodeURIComponent(session)}`));
|
|
117816
117801
|
} catch (e) {
|
|
117817
117802
|
setError(e instanceof Error ? e.message : String(e));
|
|
117818
117803
|
} finally {
|
|
@@ -117823,7 +117808,7 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117823
117808
|
session,
|
|
117824
117809
|
paused,
|
|
117825
117810
|
apiCall,
|
|
117826
|
-
|
|
117811
|
+
writeSnapshot
|
|
117827
117812
|
]);
|
|
117828
117813
|
function sendResize(cols, rows) {
|
|
117829
117814
|
const last = lastSentSizeRef.current;
|
|
@@ -117913,7 +117898,6 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117913
117898
|
terminal.loadAddon(fitAddon);
|
|
117914
117899
|
terminalRef.current = terminal;
|
|
117915
117900
|
fitAddonRef.current = fitAddon;
|
|
117916
|
-
lastSnapshotRef.current = null;
|
|
117917
117901
|
if (containerRef.current) {
|
|
117918
117902
|
terminal.open(containerRef.current);
|
|
117919
117903
|
requestAnimationFrame(() => fitAndResize());
|
|
@@ -117994,6 +117978,7 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
117994
117978
|
let closed = false;
|
|
117995
117979
|
setTransport("connecting");
|
|
117996
117980
|
const socket = openTerminalWebSocket(orchestratorId, session);
|
|
117981
|
+
socket.binaryType = "arraybuffer";
|
|
117997
117982
|
socketRef.current = socket;
|
|
117998
117983
|
socket.onopen = () => {
|
|
117999
117984
|
if (closed) return;
|
|
@@ -118004,6 +117989,9 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
118004
117989
|
paused: pausedRef.current
|
|
118005
117990
|
}));
|
|
118006
117991
|
const terminal = terminalRef.current;
|
|
117992
|
+
try {
|
|
117993
|
+
fitAddonRef.current?.fit();
|
|
117994
|
+
} catch {}
|
|
118007
117995
|
if (terminal) socket.send(JSON.stringify({
|
|
118008
117996
|
type: "resize",
|
|
118009
117997
|
cols: terminal.cols,
|
|
@@ -118011,11 +117999,24 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
118011
117999
|
}));
|
|
118012
118000
|
};
|
|
118013
118001
|
socket.onmessage = (event) => {
|
|
118002
|
+
const terminal = terminalRef.current;
|
|
118003
|
+
if (typeof event.data !== "string") {
|
|
118004
|
+
if (!terminal) return;
|
|
118005
|
+
if (event.data instanceof ArrayBuffer) terminal.write(new Uint8Array(event.data));
|
|
118006
|
+
else if (event.data instanceof Blob) event.data.arrayBuffer().then((b) => terminalRef.current?.write(new Uint8Array(b)));
|
|
118007
|
+
return;
|
|
118008
|
+
}
|
|
118014
118009
|
try {
|
|
118015
|
-
const frame = JSON.parse(
|
|
118016
|
-
if (frame.type === "
|
|
118017
|
-
|
|
118018
|
-
|
|
118010
|
+
const frame = JSON.parse(event.data);
|
|
118011
|
+
if (frame.type === "reset") {
|
|
118012
|
+
if (terminal) terminal.write("\x1B[H\x1B[2J\x1B[3J");
|
|
118013
|
+
if (typeof frame.running === "boolean") setRunning(frame.running);
|
|
118014
|
+
if (typeof frame.capturedAt === "number") setCapturedAt(frame.capturedAt);
|
|
118015
|
+
setError(null);
|
|
118016
|
+
} else if (frame.type === "closed") {
|
|
118017
|
+
setRunning(false);
|
|
118018
|
+
if (frame.reason) setError(frame.reason);
|
|
118019
|
+
} else if (frame.type === "error") setError(frame.error || "terminal stream error");
|
|
118019
118020
|
} catch {
|
|
118020
118021
|
setError("invalid terminal stream frame");
|
|
118021
118022
|
}
|
|
@@ -118033,12 +118034,7 @@ function TerminalViewer({ orchestratorId, session, interactive: initialInteracti
|
|
|
118033
118034
|
if (socketRef.current === socket) socketRef.current = null;
|
|
118034
118035
|
socket.close();
|
|
118035
118036
|
};
|
|
118036
|
-
}, [
|
|
118037
|
-
orchestratorId,
|
|
118038
|
-
session,
|
|
118039
|
-
renderSnapshot,
|
|
118040
|
-
renderHeartbeat
|
|
118041
|
-
]);
|
|
118037
|
+
}, [orchestratorId, session]);
|
|
118042
118038
|
(0, import_react.useEffect)(() => {
|
|
118043
118039
|
const socket = socketRef.current;
|
|
118044
118040
|
if (socket?.readyState === WebSocket.OPEN) socket.send(JSON.stringify({
|