@sma1lboy/kobe 0.9.19 → 0.9.21
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/index.js +350 -350
- package/dist/cli/kobe-run.js +350 -350
- package/dist/cli/pty-host-node.mjs +17 -11
- package/dist/cli/rove-run.js +350 -350
- package/dist/skills/rove/SKILL.md +6 -3
- package/package.json +1 -1
|
@@ -383,18 +383,22 @@ function recordPtyExit(info, path = defaultPtyExitsPath()) {
|
|
|
383
383
|
return;
|
|
384
384
|
if (info.exit.code === 0 && info.exit.signal === null)
|
|
385
385
|
return;
|
|
386
|
-
|
|
387
|
-
records[info.key] = {
|
|
386
|
+
writeRecord(info.key, {
|
|
388
387
|
key: info.key,
|
|
389
388
|
pid: info.pid,
|
|
390
389
|
code: info.exit.code,
|
|
391
390
|
signal: info.exit.signal,
|
|
392
391
|
at: info.exit.at,
|
|
393
|
-
tail: plainTail(info.tail)
|
|
394
|
-
|
|
395
|
-
|
|
392
|
+
tail: plainTail(info.tail),
|
|
393
|
+
layer: "pty"
|
|
394
|
+
}, path);
|
|
395
|
+
}
|
|
396
|
+
function writeRecord(storeKey, record, path) {
|
|
397
|
+
const records = readPtyExitRecords(path);
|
|
398
|
+
records[storeKey] = record;
|
|
399
|
+
const newest = Object.entries(records).sort(([, a], [, b]) => a.at < b.at ? 1 : -1).slice(0, MAX_RECORDS);
|
|
396
400
|
mkdirSync(dirname2(path), { recursive: true });
|
|
397
|
-
writeFileSync(path, JSON.stringify(Object.fromEntries(newest
|
|
401
|
+
writeFileSync(path, JSON.stringify(Object.fromEntries(newest), null, 2), "utf8");
|
|
398
402
|
}
|
|
399
403
|
|
|
400
404
|
// ../kobe-daemon/src/daemon/pty-freeze-store.ts
|
|
@@ -788,22 +792,24 @@ async function settledWithin(exited, ms) {
|
|
|
788
792
|
clearTimeout(timer);
|
|
789
793
|
return settled;
|
|
790
794
|
}
|
|
791
|
-
function signalProcessGroup(pid, signal, fallback, platform = process.platform) {
|
|
795
|
+
function signalProcessGroup(pid, signal, fallback, platform = process.platform, onSignal) {
|
|
792
796
|
if (platform !== "win32" && pid > 1) {
|
|
793
797
|
try {
|
|
794
798
|
process.kill(-pid, signal);
|
|
799
|
+
onSignal?.(`sent ${signal} to process group -${pid}`);
|
|
795
800
|
return;
|
|
796
801
|
} catch {}
|
|
797
802
|
}
|
|
798
803
|
try {
|
|
799
804
|
fallback();
|
|
805
|
+
onSignal?.(`sent ${signal} to pid ${pid} (per-process fallback)`);
|
|
800
806
|
} catch {}
|
|
801
807
|
}
|
|
802
808
|
var TERMINATION_GRACE_MS = 500;
|
|
803
|
-
async function terminatePtyChild(proc, onSettled) {
|
|
804
|
-
signalProcessGroup(proc.pid, "SIGTERM", () => proc.kill("SIGTERM"));
|
|
809
|
+
async function terminatePtyChild(proc, onSettled, onSignal) {
|
|
810
|
+
signalProcessGroup(proc.pid, "SIGTERM", () => proc.kill("SIGTERM"), process.platform, onSignal);
|
|
805
811
|
if (!await settledWithin(proc.exited, TERMINATION_GRACE_MS)) {
|
|
806
|
-
signalProcessGroup(proc.pid, "SIGKILL", () => proc.kill("SIGKILL"));
|
|
812
|
+
signalProcessGroup(proc.pid, "SIGKILL", () => proc.kill("SIGKILL"), process.platform, onSignal);
|
|
807
813
|
await settledWithin(proc.exited, TERMINATION_GRACE_MS);
|
|
808
814
|
}
|
|
809
815
|
onSettled();
|
|
@@ -856,7 +862,7 @@ class PtyChildController {
|
|
|
856
862
|
this.markExited(session);
|
|
857
863
|
return;
|
|
858
864
|
}
|
|
859
|
-
await terminatePtyChild(proc, () => this.markExited(session));
|
|
865
|
+
await terminatePtyChild(proc, () => this.markExited(session), (line) => this.deps.log?.("pty-signal", `${session.key}: ${line}`));
|
|
860
866
|
}
|
|
861
867
|
markExited(session, exit) {
|
|
862
868
|
if (!session.alive)
|