@standardagents/code 0.11.8 → 0.11.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/dist/index.js +21 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6491,7 +6491,7 @@ function readVersion() {
|
|
|
6491
6491
|
if (typeof pkg.version === "string" && pkg.version) return pkg.version;
|
|
6492
6492
|
} catch {
|
|
6493
6493
|
}
|
|
6494
|
-
return "0.11.
|
|
6494
|
+
return "0.11.9" ;
|
|
6495
6495
|
}
|
|
6496
6496
|
function isLocalHost(host) {
|
|
6497
6497
|
return host === "localhost" || host === "127.0.0.1" || host === "::1" || host.endsWith(".local") || host.endsWith(".localhost") || /^10\./.test(host) || /^192\.168\./.test(host) || /^172\.(1[6-9]|2\d|3[01])\./.test(host);
|
|
@@ -6606,6 +6606,13 @@ async function readFsResponse(api, machineId) {
|
|
|
6606
6606
|
async function readFsRequest(api, machineId) {
|
|
6607
6607
|
return parseFsRequest(await api.userKvGet(fsRequestKey(machineId)));
|
|
6608
6608
|
}
|
|
6609
|
+
var FS_POLL_HOT_MS = 1e3;
|
|
6610
|
+
var FS_POLL_IDLE_MS = 5e3;
|
|
6611
|
+
var FS_HOT_WINDOW_MS = 5 * 6e4;
|
|
6612
|
+
function fsPollDelay(lastRequestSeenAt, now) {
|
|
6613
|
+
if (lastRequestSeenAt !== null && now - lastRequestSeenAt < FS_HOT_WINDOW_MS) return FS_POLL_HOT_MS;
|
|
6614
|
+
return FS_POLL_IDLE_MS;
|
|
6615
|
+
}
|
|
6609
6616
|
async function writeFsResponse(api, machineId, res) {
|
|
6610
6617
|
await api.userKvSet(fsResponseKey(machineId), { ...res, responded_at: Date.now() });
|
|
6611
6618
|
}
|
|
@@ -7517,7 +7524,6 @@ function runUpdate(pm) {
|
|
|
7517
7524
|
// src/daemon.ts
|
|
7518
7525
|
var HEARTBEAT_MS = 3e4;
|
|
7519
7526
|
var COMMAND_POLL_MS = 8e3;
|
|
7520
|
-
var FS_POLL_MS = 1e3;
|
|
7521
7527
|
var RECLAIM_PROBE_MS = 2 * 6e4;
|
|
7522
7528
|
var UPDATE_CHECK_MS = 6 * 60 * 6e4;
|
|
7523
7529
|
var SWEEP_MS = 10 * 6e4;
|
|
@@ -7868,12 +7874,14 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
7868
7874
|
void drainCommands();
|
|
7869
7875
|
const commandTimer = setInterval(() => void drainCommands(), COMMAND_POLL_MS);
|
|
7870
7876
|
let lastFsNonce = null;
|
|
7877
|
+
let lastFsRequestSeenAt = null;
|
|
7871
7878
|
let fsBusy = false;
|
|
7872
7879
|
const drainFsRequests = async () => {
|
|
7873
7880
|
if (fsBusy) return;
|
|
7874
7881
|
fsBusy = true;
|
|
7875
7882
|
try {
|
|
7876
7883
|
const req = await readFsRequest(api, identity.machine_id).catch(() => null);
|
|
7884
|
+
if (req) lastFsRequestSeenAt = Math.max(lastFsRequestSeenAt ?? 0, req.requested_at);
|
|
7877
7885
|
if (!req || req.nonce === lastFsNonce) return;
|
|
7878
7886
|
lastFsNonce = req.nonce;
|
|
7879
7887
|
let ok = true;
|
|
@@ -7891,7 +7899,15 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
7891
7899
|
fsBusy = false;
|
|
7892
7900
|
}
|
|
7893
7901
|
};
|
|
7894
|
-
|
|
7902
|
+
let fsTimer = null;
|
|
7903
|
+
let fsStopped = false;
|
|
7904
|
+
const scheduleFsPoll = () => {
|
|
7905
|
+
if (fsStopped) return;
|
|
7906
|
+
fsTimer = setTimeout(() => {
|
|
7907
|
+
void drainFsRequests().finally(scheduleFsPoll);
|
|
7908
|
+
}, fsPollDelay(lastFsRequestSeenAt, Date.now()));
|
|
7909
|
+
};
|
|
7910
|
+
scheduleFsPoll();
|
|
7895
7911
|
const sweeper = setInterval(() => {
|
|
7896
7912
|
if (updateReady && ![...workers.values()].some((w) => w.busy)) {
|
|
7897
7913
|
daemonLog("restarting to apply the installed update");
|
|
@@ -7905,7 +7921,8 @@ Run \`standardcode daemon install\` (or plain \`standardcode\`) once to sign in.
|
|
|
7905
7921
|
clearInterval(reclaim);
|
|
7906
7922
|
clearInterval(updateTimer);
|
|
7907
7923
|
clearInterval(commandTimer);
|
|
7908
|
-
|
|
7924
|
+
fsStopped = true;
|
|
7925
|
+
if (fsTimer) clearTimeout(fsTimer);
|
|
7909
7926
|
clearInterval(sweeper);
|
|
7910
7927
|
for (const worker of workers.values()) worker.stop();
|
|
7911
7928
|
events.close();
|