orchestrating 0.1.17 → 0.1.19
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 +26 -1
- package/package.json +1 -1
package/bin/orch
CHANGED
|
@@ -273,9 +273,13 @@ if (!authToken && !serverUrl.includes("localhost") && !serverUrl.includes("127.0
|
|
|
273
273
|
|
|
274
274
|
// --- WebSocket connection with reconnect ---
|
|
275
275
|
const BUFFER_MAX = 50 * 1024; // 50KB reconnect buffer
|
|
276
|
+
const PING_INTERVAL_MS = 30_000; // 30s keepalive ping
|
|
277
|
+
const PONG_TIMEOUT_MS = 10_000; // 10s to receive pong before assuming dead
|
|
276
278
|
let ws = null;
|
|
277
279
|
let wsReady = false;
|
|
278
280
|
let reconnectTimer = null;
|
|
281
|
+
let pingTimer = null;
|
|
282
|
+
let pongTimer = null;
|
|
279
283
|
let authFailed = false;
|
|
280
284
|
const sendBuffer = [];
|
|
281
285
|
let bufferSize = 0;
|
|
@@ -368,7 +372,7 @@ if (adapter) {
|
|
|
368
372
|
promptParts.push(arg);
|
|
369
373
|
}
|
|
370
374
|
}
|
|
371
|
-
const prompt = promptParts.join(" ") || (adapterFlags.continue ? "
|
|
375
|
+
const prompt = promptParts.join(" ") || (adapterFlags.continue ? "Session resumed via orchestrat.ing. Do not take any action — wait for the next message." : "hello");
|
|
372
376
|
|
|
373
377
|
// Session reuse: persist session ID per cwd so `-c` reconnects the same dashboard session
|
|
374
378
|
const SESSION_FILE = path.join(process.cwd(), ".orch-session");
|
|
@@ -920,6 +924,23 @@ async function connectWs() {
|
|
|
920
924
|
if (adapter) {
|
|
921
925
|
broadcastPermissions();
|
|
922
926
|
}
|
|
927
|
+
|
|
928
|
+
// Keepalive: send WebSocket ping frames every 30s to prevent idle disconnects
|
|
929
|
+
if (pingTimer) clearInterval(pingTimer);
|
|
930
|
+
if (pongTimer) clearTimeout(pongTimer);
|
|
931
|
+
pingTimer = setInterval(() => {
|
|
932
|
+
if (ws && ws.readyState === WebSocket.OPEN) {
|
|
933
|
+
ws.ping();
|
|
934
|
+
pongTimer = setTimeout(() => {
|
|
935
|
+
// No pong received — connection is dead, force reconnect
|
|
936
|
+
if (ws) ws.terminate();
|
|
937
|
+
}, PONG_TIMEOUT_MS);
|
|
938
|
+
}
|
|
939
|
+
}, PING_INTERVAL_MS);
|
|
940
|
+
});
|
|
941
|
+
|
|
942
|
+
ws.on("pong", () => {
|
|
943
|
+
if (pongTimer) { clearTimeout(pongTimer); pongTimer = null; }
|
|
923
944
|
});
|
|
924
945
|
|
|
925
946
|
ws.on("message", (raw) => {
|
|
@@ -950,6 +971,8 @@ async function connectWs() {
|
|
|
950
971
|
ws.on("close", () => {
|
|
951
972
|
wsReady = false;
|
|
952
973
|
ws = null;
|
|
974
|
+
if (pingTimer) { clearInterval(pingTimer); pingTimer = null; }
|
|
975
|
+
if (pongTimer) { clearTimeout(pongTimer); pongTimer = null; }
|
|
953
976
|
if (!authFailed) {
|
|
954
977
|
reconnectTimer = setTimeout(connectWs, 2000);
|
|
955
978
|
}
|
|
@@ -986,6 +1009,8 @@ function revokeSessionPermissions() {
|
|
|
986
1009
|
|
|
987
1010
|
function cleanup() {
|
|
988
1011
|
revokeSessionPermissions();
|
|
1012
|
+
if (pingTimer) clearInterval(pingTimer);
|
|
1013
|
+
if (pongTimer) clearTimeout(pongTimer);
|
|
989
1014
|
if (reconnectTimer) clearTimeout(reconnectTimer);
|
|
990
1015
|
if (ws) ws.close();
|
|
991
1016
|
}
|