orchestrating 0.1.22 → 0.1.23
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/bin/orch +18 -0
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -281,6 +281,7 @@ if (!authToken && !serverUrl.includes("localhost") && !serverUrl.includes("127.0
|
|
|
281
281
|
const BUFFER_MAX = 50 * 1024; // 50KB reconnect buffer
|
|
282
282
|
const PING_INTERVAL_MS = 30_000; // 30s keepalive ping
|
|
283
283
|
const PONG_TIMEOUT_MS = 10_000; // 10s to receive pong before assuming dead
|
|
284
|
+
const MAX_EVENT_HISTORY = 500; // max events to replay on reconnect
|
|
284
285
|
let ws = null;
|
|
285
286
|
let wsReady = false;
|
|
286
287
|
let reconnectTimer = null;
|
|
@@ -289,8 +290,16 @@ let pongTimer = null;
|
|
|
289
290
|
let authFailed = false;
|
|
290
291
|
const sendBuffer = [];
|
|
291
292
|
let bufferSize = 0;
|
|
293
|
+
const eventHistory = []; // all agent events for replay on reconnect
|
|
292
294
|
|
|
293
295
|
function sendToServer(msg) {
|
|
296
|
+
// Track agent events for reconnect replay
|
|
297
|
+
if (msg.type === "agent_event" && msg.event) {
|
|
298
|
+
eventHistory.push(msg.event);
|
|
299
|
+
while (eventHistory.length > MAX_EVENT_HISTORY) {
|
|
300
|
+
eventHistory.shift();
|
|
301
|
+
}
|
|
302
|
+
}
|
|
294
303
|
if (wsReady && ws && ws.readyState === WebSocket.OPEN) {
|
|
295
304
|
ws.send(JSON.stringify(msg));
|
|
296
305
|
} else {
|
|
@@ -938,6 +947,15 @@ async function connectWs() {
|
|
|
938
947
|
broadcastPermissions();
|
|
939
948
|
}
|
|
940
949
|
|
|
950
|
+
// Replay event history so server can rebuild conversation after restarts
|
|
951
|
+
if (eventHistory.length > 0) {
|
|
952
|
+
ws.send(JSON.stringify({
|
|
953
|
+
type: "agent_history_replay",
|
|
954
|
+
sessionId,
|
|
955
|
+
events: eventHistory,
|
|
956
|
+
}));
|
|
957
|
+
}
|
|
958
|
+
|
|
941
959
|
// Keepalive: send WebSocket ping frames every 30s to prevent idle disconnects
|
|
942
960
|
if (pingTimer) clearInterval(pingTimer);
|
|
943
961
|
if (pongTimer) clearTimeout(pongTimer);
|