shadok-ai 0.16.8 → 0.16.9
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 +13 -10
- package/package.json +1 -1
- package/public/index.html +25 -31
package/README.md
CHANGED
|
@@ -531,16 +531,19 @@ every 25s (tunable with `SHADOK_WS_PING_MS`) to keep the connection warm, so no
|
|
|
531
531
|
proxy change is normally needed; if your proxy still cuts it, raise
|
|
532
532
|
`proxy_read_timeout` above the ping interval.
|
|
533
533
|
|
|
534
|
-
**Sleep / wake
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
534
|
+
**Sleep / wake / network blips.** When the machine comes back (an `online`
|
|
535
|
+
event, the tab becoming visible, a back/forward-cache restore), the cockpit
|
|
536
|
+
revives the links that actually **dropped** — resetting their backoff so a
|
|
537
|
+
genuinely-closed socket reconnects promptly instead of waiting out a delay that
|
|
538
|
+
climbed while you were away. A socket that still reports "open" is left alone:
|
|
539
|
+
`online` fires on every network blip (wifi roam, VPN, interface change), and
|
|
540
|
+
force-reconnecting healthy links on each one reconnected all your agents at
|
|
541
|
+
once — tripping the upstream single-use-token OAuth refresh race so a batch
|
|
542
|
+
stuck on "connecting…". A slept socket that looks "open" but is dead is
|
|
543
|
+
terminated by the server heartbeat (~50s) and reconnects on the resulting
|
|
544
|
+
`close` without that churn. Only a back/forward-cache restore force-replaces an
|
|
545
|
+
"open" socket, because there the restored page's old sockets are dead yet fire
|
|
546
|
+
no `close`.
|
|
544
547
|
|
|
545
548
|
### Cross-instance peers
|
|
546
549
|
|
package/package.json
CHANGED
package/public/index.html
CHANGED
|
@@ -7095,51 +7095,45 @@
|
|
|
7095
7095
|
// off. Bounded so an update that never lands doesn't leave us hammering.
|
|
7096
7096
|
let reloadExpectedUntil = 0;
|
|
7097
7097
|
|
|
7098
|
-
/**
|
|
7099
|
-
*
|
|
7100
|
-
*
|
|
7101
|
-
*
|
|
7102
|
-
*
|
|
7103
|
-
*
|
|
7104
|
-
*
|
|
7105
|
-
*
|
|
7106
|
-
*
|
|
7098
|
+
/** Revive the tabs whose link actually DROPPED — fired when the machine/tab
|
|
7099
|
+
* comes back (online / visible). It resets the backoff and reconnects at
|
|
7100
|
+
* once, so a genuinely-closed socket comes back promptly instead of waiting
|
|
7101
|
+
* out an exponential delay that climbed while we were away.
|
|
7102
|
+
*
|
|
7103
|
+
* It deliberately does NOT touch a socket that still reports OPEN. An earlier
|
|
7104
|
+
* version force-replaced OPEN sockets too (to catch a laptop-sleep "zombie" —
|
|
7105
|
+
* OPEN on the client, dead on the wire). But `online` fires on EVERY network
|
|
7106
|
+
* blip (wifi roam, VPN, interface change), and force-closing every healthy
|
|
7107
|
+
* link on each blip reconnected all N agents at once — tripping the upstream
|
|
7108
|
+
* OAuth refresh-token race (single-use tokens, concurrent `claude --resume`,
|
|
7109
|
+
* biting at ~10–30 agents) so a whole batch stuck on "connecting…". That mass
|
|
7110
|
+
* churn was worse than the zombie it chased: a slept socket is terminated by
|
|
7111
|
+
* the server heartbeat (~50s) and the resulting `close` reconnects it anyway,
|
|
7112
|
+
* no force needed. `force` is kept ONLY for a bfcache `pageshow`, where the
|
|
7113
|
+
* restored page's old sockets are genuinely dead and fire no `close`. */
|
|
7107
7114
|
function reconnectAllNow(force) {
|
|
7108
7115
|
for (const t of tabs) {
|
|
7109
7116
|
if (t.closing || !t.sessionId) continue;
|
|
7110
7117
|
const st = t.ws && t.ws.readyState;
|
|
7111
7118
|
if (st === WebSocket.CONNECTING) continue; // a link is already on its way
|
|
7112
|
-
if (st === WebSocket.OPEN && !force) continue; // healthy
|
|
7119
|
+
if (st === WebSocket.OPEN && !force) continue; // healthy — leave it, a blip is not a death
|
|
7113
7120
|
if (t.reconnectTimer) clearTimeout(t.reconnectTimer);
|
|
7114
|
-
t.reconnectAttempts = 0;
|
|
7121
|
+
t.reconnectAttempts = 0; // reset the backoff: reconnect promptly, not after a climbed delay
|
|
7115
7122
|
const old = t.ws;
|
|
7116
7123
|
openLink(t); // replaces t.ws with the fresh socket
|
|
7117
|
-
// Close
|
|
7124
|
+
// Close a forced (bfcache) zombie only after openLink swapped t.ws, so its
|
|
7118
7125
|
// `close` handler sees `t.ws !== ws` and does not schedule a competing
|
|
7119
7126
|
// reconnect. A no-op when `old` was already closed.
|
|
7120
7127
|
if (old && old !== t.ws) { try { old.close(); } catch {} }
|
|
7121
7128
|
}
|
|
7122
7129
|
}
|
|
7123
7130
|
|
|
7124
|
-
//
|
|
7125
|
-
//
|
|
7126
|
-
//
|
|
7127
|
-
|
|
7128
|
-
|
|
7129
|
-
|
|
7130
|
-
const STALE_WAKE_MS = 10_000;
|
|
7131
|
-
let hiddenAt = 0;
|
|
7132
|
-
function wokeAfterLongAway() {
|
|
7133
|
-
const away = hiddenAt ? Date.now() - hiddenAt : 0;
|
|
7134
|
-
hiddenAt = 0;
|
|
7135
|
-
return away > STALE_WAKE_MS;
|
|
7136
|
-
}
|
|
7137
|
-
window.addEventListener("online", () => reconnectAllNow(true));
|
|
7138
|
-
window.addEventListener("pageshow", (e) => reconnectAllNow(!!e.persisted || wokeAfterLongAway()));
|
|
7139
|
-
document.addEventListener("visibilitychange", () => {
|
|
7140
|
-
if (document.hidden) { hiddenAt = Date.now(); return; }
|
|
7141
|
-
reconnectAllNow(wokeAfterLongAway());
|
|
7142
|
-
});
|
|
7131
|
+
// Reconnect the links that dropped while we were away — but never disturb a
|
|
7132
|
+
// healthy one (see reconnectAllNow). Only a bfcache restore forces, because
|
|
7133
|
+
// there the old sockets are dead yet fire no `close`.
|
|
7134
|
+
window.addEventListener("online", () => reconnectAllNow(false));
|
|
7135
|
+
window.addEventListener("pageshow", (e) => reconnectAllNow(!!e.persisted));
|
|
7136
|
+
document.addEventListener("visibilitychange", () => { if (!document.hidden) reconnectAllNow(false); });
|
|
7143
7137
|
|
|
7144
7138
|
/**
|
|
7145
7139
|
* Lists the agents alive in the server right now — including ones spawned
|