@delt/claude-alarm 1.4.0 → 1.4.1
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/cli.js +154 -55
- package/dist/cli.js.map +1 -1
- package/dist/codex/main.js +104 -59
- package/dist/codex/main.js.map +1 -1
- package/dist/hub/server.js +27 -9
- package/dist/hub/server.js.map +1 -1
- package/dist/index.js +27 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -846,6 +846,11 @@ ${bodyLines.join("\n")}`;
|
|
|
846
846
|
import { spawn } from "child_process";
|
|
847
847
|
import fs2 from "fs";
|
|
848
848
|
import path3 from "path";
|
|
849
|
+
|
|
850
|
+
// src/codex/shutdown.ts
|
|
851
|
+
var SUPERVISOR_STOP_GRACE_MS = 3e4;
|
|
852
|
+
|
|
853
|
+
// src/hub/codex-supervisor.ts
|
|
849
854
|
var HEALTHY_RUN_MS = 6e4;
|
|
850
855
|
function resolveAdapterScript(baseDir) {
|
|
851
856
|
return [path3.join(baseDir, "..", "codex", "main.js"), path3.join(baseDir, "codex", "main.js")].find((p) => fs2.existsSync(p));
|
|
@@ -861,7 +866,7 @@ var CodexSupervisor = class {
|
|
|
861
866
|
this.spawnFn = opts.spawnFn ?? spawn;
|
|
862
867
|
this.minDelayMs = opts.minDelayMs ?? 2e3;
|
|
863
868
|
this.maxDelayMs = opts.maxDelayMs ?? 6e4;
|
|
864
|
-
this.stopGraceMs = opts.stopGraceMs ??
|
|
869
|
+
this.stopGraceMs = opts.stopGraceMs ?? SUPERVISOR_STOP_GRACE_MS;
|
|
865
870
|
this.env = opts.env;
|
|
866
871
|
this.delay = this.minDelayMs;
|
|
867
872
|
}
|
|
@@ -884,11 +889,22 @@ var CodexSupervisor = class {
|
|
|
884
889
|
this.timer = void 0;
|
|
885
890
|
const child = this.child;
|
|
886
891
|
this.child = void 0;
|
|
887
|
-
if (!child) return;
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
+
if (!child) return Promise.resolve();
|
|
893
|
+
return new Promise((resolve) => {
|
|
894
|
+
const done = () => {
|
|
895
|
+
clearTimeout(force);
|
|
896
|
+
child.removeListener("exit", done);
|
|
897
|
+
resolve();
|
|
898
|
+
};
|
|
899
|
+
const force = setTimeout(() => {
|
|
900
|
+
logger.warn(`Codex adapter did not exit within ${this.stopGraceMs}ms of stop; killing it`);
|
|
901
|
+
child.kill();
|
|
902
|
+
done();
|
|
903
|
+
}, this.stopGraceMs);
|
|
904
|
+
force.unref();
|
|
905
|
+
child.once("exit", done);
|
|
906
|
+
child.stdin?.end();
|
|
907
|
+
});
|
|
892
908
|
}
|
|
893
909
|
launch() {
|
|
894
910
|
const startedAt = Date.now();
|
|
@@ -1222,9 +1238,9 @@ var HubServer = class {
|
|
|
1222
1238
|
});
|
|
1223
1239
|
}
|
|
1224
1240
|
stop() {
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1241
|
+
const adapterStopped = this.codexSupervisor?.stop();
|
|
1242
|
+
this.codexSupervisor = void 0;
|
|
1243
|
+
const serverStopped = new Promise((resolve) => {
|
|
1228
1244
|
if (this.heartbeatInterval) clearInterval(this.heartbeatInterval);
|
|
1229
1245
|
if (this.telegramBot) this.telegramBot.stopPolling();
|
|
1230
1246
|
for (const ws of this.channelSockets.values()) ws.terminate();
|
|
@@ -1244,6 +1260,8 @@ var HubServer = class {
|
|
|
1244
1260
|
resolve();
|
|
1245
1261
|
}, 3e3);
|
|
1246
1262
|
});
|
|
1263
|
+
return Promise.all([serverStopped, adapterStopped]).then(() => {
|
|
1264
|
+
});
|
|
1247
1265
|
}
|
|
1248
1266
|
// --- HTTP Handler ---
|
|
1249
1267
|
handleHttp(req, res) {
|