sessionpipe 0.11.0 → 0.12.0
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 +127 -86
- package/dist/cli.js.map +3 -3
- package/dist/hook.d.ts.map +1 -1
- package/dist/hook.js +2 -2
- package/dist/hook.js.map +2 -2
- package/dist/index.js +67 -38
- package/dist/index.js.map +3 -3
- package/dist/worker.js +68 -39
- package/dist/worker.js.map +3 -3
- package/package.json +1 -1
package/dist/worker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// sessionpipe 0.
|
|
2
|
+
// sessionpipe 0.12.0 · Apache-2.0 · https://sessionpipe.org
|
|
3
3
|
|
|
4
4
|
// src/worker.ts
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
@@ -618,13 +618,7 @@ var claudeCode = {
|
|
|
618
618
|
);
|
|
619
619
|
break;
|
|
620
620
|
case "Stop":
|
|
621
|
-
events.push(
|
|
622
|
-
ev("turn.ended", {
|
|
623
|
-
turn_id,
|
|
624
|
-
reason: "stop",
|
|
625
|
-
background: Array.isArray(s.background_tasks) ? s.background_tasks.length : void 0
|
|
626
|
-
})
|
|
627
|
-
);
|
|
621
|
+
events.push(ev("turn.ended", { turn_id, reason: "stop", background: backgroundCount(s.background_tasks) }));
|
|
628
622
|
break;
|
|
629
623
|
case "StopFailure":
|
|
630
624
|
events.push(
|
|
@@ -647,7 +641,8 @@ var claudeCode = {
|
|
|
647
641
|
events.push(
|
|
648
642
|
ev("subagent.ended", {
|
|
649
643
|
agent_id: String(s.agent_id ?? ""),
|
|
650
|
-
agent_type: typeof s.agent_type === "string" ? s.agent_type : void 0
|
|
644
|
+
agent_type: typeof s.agent_type === "string" ? s.agent_type : void 0,
|
|
645
|
+
background: backgroundCount(s.background_tasks, String(s.agent_id ?? ""))
|
|
651
646
|
})
|
|
652
647
|
);
|
|
653
648
|
break;
|
|
@@ -722,6 +717,15 @@ var claudeCode = {
|
|
|
722
717
|
return rows2;
|
|
723
718
|
}
|
|
724
719
|
};
|
|
720
|
+
var WAITER_RE = /(?:^|[\s"'`/\\])sessionpipe(?:\.\w+)?["']?\s+wait(?:\s|$)/;
|
|
721
|
+
function backgroundCount(tasks, ending) {
|
|
722
|
+
if (!Array.isArray(tasks)) return void 0;
|
|
723
|
+
return tasks.filter((t) => {
|
|
724
|
+
const task = t;
|
|
725
|
+
if (ending !== void 0 && task?.id === ending) return false;
|
|
726
|
+
return !(typeof task?.command === "string" && WAITER_RE.test(task.command));
|
|
727
|
+
}).length;
|
|
728
|
+
}
|
|
725
729
|
var LINE_REFRESH_S = 60;
|
|
726
730
|
function statusLine(file, want, cmd) {
|
|
727
731
|
const f = readJsonFile(file);
|
|
@@ -1150,7 +1154,7 @@ async function claudeAiTitle(bridge, token) {
|
|
|
1150
1154
|
}
|
|
1151
1155
|
|
|
1152
1156
|
// ../core/src/adapters/headless.ts
|
|
1153
|
-
import { accessSync, constants, statSync as statSync3 } from "node:fs";
|
|
1157
|
+
import { accessSync, constants, readFileSync as readFileSync3, statSync as statSync3 } from "node:fs";
|
|
1154
1158
|
import path5 from "node:path";
|
|
1155
1159
|
var JOB_TIMEOUT_MS = 30 * 6e4;
|
|
1156
1160
|
var OUT_CAP = 1024 * 1024;
|
|
@@ -1172,13 +1176,38 @@ function findBinary(o) {
|
|
|
1172
1176
|
for (const d of o.dirs) for (const n of o.names) if (isExe(path5.join(d, n))) return path5.join(d, n);
|
|
1173
1177
|
return null;
|
|
1174
1178
|
}
|
|
1179
|
+
function shimTarget(shim) {
|
|
1180
|
+
let text = "";
|
|
1181
|
+
try {
|
|
1182
|
+
text = readFileSync3(shim, "utf8");
|
|
1183
|
+
} catch {
|
|
1184
|
+
return null;
|
|
1185
|
+
}
|
|
1186
|
+
const m = /"%(?:~dp0|dp0%)\\([^"]+)"\s+%\*/.exec(text);
|
|
1187
|
+
if (!m) return null;
|
|
1188
|
+
const target = path5.resolve(path5.dirname(shim), m[1].split("\\").join(path5.sep));
|
|
1189
|
+
try {
|
|
1190
|
+
return statSync3(target).isFile() ? target : null;
|
|
1191
|
+
} catch {
|
|
1192
|
+
return null;
|
|
1193
|
+
}
|
|
1194
|
+
}
|
|
1195
|
+
function spawnable(bin, args) {
|
|
1196
|
+
if (!/\.(cmd|bat)$/i.test(bin)) return { file: bin, args };
|
|
1197
|
+
const target = shimTarget(bin);
|
|
1198
|
+
return target ? { file: process.execPath, args: [target, ...args] } : null;
|
|
1199
|
+
}
|
|
1200
|
+
function probe(bin, args) {
|
|
1201
|
+
const s = spawnable(bin, args);
|
|
1202
|
+
return s ? { ...s, shell: false } : { file: [`"${bin}"`, ...args].join(" "), args: [], shell: true };
|
|
1203
|
+
}
|
|
1175
1204
|
|
|
1176
1205
|
// ../core/src/adapters/antigravity.ts
|
|
1177
1206
|
import {
|
|
1178
1207
|
existsSync as existsSync3,
|
|
1179
1208
|
mkdirSync as mkdirSync2,
|
|
1180
1209
|
readdirSync as readdirSync3,
|
|
1181
|
-
readFileSync as
|
|
1210
|
+
readFileSync as readFileSync4,
|
|
1182
1211
|
realpathSync,
|
|
1183
1212
|
statSync as statSync4,
|
|
1184
1213
|
unlinkSync as unlinkSync2,
|
|
@@ -1307,7 +1336,7 @@ var antigravity = {
|
|
|
1307
1336
|
readTranscript(file, fromLine) {
|
|
1308
1337
|
let text = "";
|
|
1309
1338
|
try {
|
|
1310
|
-
text =
|
|
1339
|
+
text = readFileSync4(file, "utf8");
|
|
1311
1340
|
} catch {
|
|
1312
1341
|
return { turns: [], line: fromLine };
|
|
1313
1342
|
}
|
|
@@ -1386,7 +1415,7 @@ function agProjects(dir) {
|
|
|
1386
1415
|
if (!ID_RE.test(id)) continue;
|
|
1387
1416
|
let j;
|
|
1388
1417
|
try {
|
|
1389
|
-
j = JSON.parse(
|
|
1418
|
+
j = JSON.parse(readFileSync4(path6.join(dir, n), "utf8"));
|
|
1390
1419
|
} catch {
|
|
1391
1420
|
continue;
|
|
1392
1421
|
}
|
|
@@ -1423,7 +1452,7 @@ function antigravityRemoteUrl(transcript, opts) {
|
|
|
1423
1452
|
for (const d of dirs) {
|
|
1424
1453
|
try {
|
|
1425
1454
|
const m = /installation_uuid:\s*"([0-9a-f-]{36})"/i.exec(
|
|
1426
|
-
|
|
1455
|
+
readFileSync4(path6.join(d, "antigravity_state.pbtxt"), "utf8")
|
|
1427
1456
|
);
|
|
1428
1457
|
if (!m) continue;
|
|
1429
1458
|
const base = `https://antigravity.google.com/r/${m[1]}-v2`;
|
|
@@ -1483,7 +1512,7 @@ var enc = new TextEncoder();
|
|
|
1483
1512
|
var dec = new TextDecoder();
|
|
1484
1513
|
|
|
1485
1514
|
// ../core/src/adapters/codex.ts
|
|
1486
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as readdirSync4, readFileSync as
|
|
1515
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync as readdirSync4, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "node:fs";
|
|
1487
1516
|
import path7 from "node:path";
|
|
1488
1517
|
|
|
1489
1518
|
// ../core/src/adapters/codex-config.ts
|
|
@@ -1640,7 +1669,7 @@ function installNotify(cmd, env) {
|
|
|
1640
1669
|
const file = configFile2(env);
|
|
1641
1670
|
let text = "";
|
|
1642
1671
|
try {
|
|
1643
|
-
text =
|
|
1672
|
+
text = readFileSync5(file, "utf8");
|
|
1644
1673
|
} catch {
|
|
1645
1674
|
}
|
|
1646
1675
|
const argv = cmd([NAME3, "notify"]).argv;
|
|
@@ -1686,7 +1715,7 @@ function uninstallNotify(env) {
|
|
|
1686
1715
|
const file = configFile2(env);
|
|
1687
1716
|
let text;
|
|
1688
1717
|
try {
|
|
1689
|
-
text =
|
|
1718
|
+
text = readFileSync5(file, "utf8");
|
|
1690
1719
|
} catch {
|
|
1691
1720
|
return { file, changed: false };
|
|
1692
1721
|
}
|
|
@@ -1758,7 +1787,7 @@ var codex = {
|
|
|
1758
1787
|
];
|
|
1759
1788
|
let text = "";
|
|
1760
1789
|
try {
|
|
1761
|
-
text =
|
|
1790
|
+
text = readFileSync5(configFile2(env), "utf8");
|
|
1762
1791
|
} catch {
|
|
1763
1792
|
}
|
|
1764
1793
|
const n = readNotify(text);
|
|
@@ -1885,7 +1914,7 @@ var codex = {
|
|
|
1885
1914
|
readTranscript(file, fromLine) {
|
|
1886
1915
|
let text = "";
|
|
1887
1916
|
try {
|
|
1888
|
-
text =
|
|
1917
|
+
text = readFileSync5(file, "utf8");
|
|
1889
1918
|
} catch {
|
|
1890
1919
|
return { turns: [], line: fromLine };
|
|
1891
1920
|
}
|
|
@@ -2406,7 +2435,7 @@ function devinAccount(env = process.env) {
|
|
|
2406
2435
|
|
|
2407
2436
|
// ../core/src/adapters/gemini-cli.ts
|
|
2408
2437
|
import { execFileSync as execFileSync4 } from "node:child_process";
|
|
2409
|
-
import { existsSync as existsSync7, readFileSync as
|
|
2438
|
+
import { existsSync as existsSync7, readFileSync as readFileSync6 } from "node:fs";
|
|
2410
2439
|
import path9 from "node:path";
|
|
2411
2440
|
var NAME5 = "gemini-cli";
|
|
2412
2441
|
var GEMINI_EVENTS = [
|
|
@@ -2428,14 +2457,14 @@ function geminiVersion(platform = process.platform, env = process.env) {
|
|
|
2428
2457
|
const win = platform === "win32";
|
|
2429
2458
|
const bin = win ? findBinary({ names: ["gemini.exe", "gemini.cmd"], dirs: [path9.dirname(process.execPath)], env }) : "gemini";
|
|
2430
2459
|
if (!bin) throw new Error("no gemini on PATH");
|
|
2431
|
-
const
|
|
2460
|
+
const c = probe(bin, ["--version"]);
|
|
2461
|
+
return execFileSync4(c.file, c.args, {
|
|
2432
2462
|
encoding: "utf8",
|
|
2433
2463
|
timeout: 4e3,
|
|
2434
2464
|
stdio: ["ignore", "pipe", "ignore"],
|
|
2435
|
-
env
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
return out.trim();
|
|
2465
|
+
env,
|
|
2466
|
+
shell: c.shell
|
|
2467
|
+
}).trim();
|
|
2439
2468
|
}
|
|
2440
2469
|
function geminiHooksActive(settingsFile) {
|
|
2441
2470
|
const tools = readJson(settingsFile).tools;
|
|
@@ -2560,7 +2589,7 @@ var geminiCli = {
|
|
|
2560
2589
|
readTranscript(file, fromLine) {
|
|
2561
2590
|
let text = "";
|
|
2562
2591
|
try {
|
|
2563
|
-
text =
|
|
2592
|
+
text = readFileSync6(file, "utf8");
|
|
2564
2593
|
} catch {
|
|
2565
2594
|
return { turns: [], line: fromLine };
|
|
2566
2595
|
}
|
|
@@ -2600,12 +2629,12 @@ var ADAPTERS = [claudeCode, codex, geminiCli, antigravity, devin];
|
|
|
2600
2629
|
var adapterByName = (name) => ADAPTERS.find((a) => a.name === name);
|
|
2601
2630
|
|
|
2602
2631
|
// ../core/src/config.ts
|
|
2603
|
-
import { chmodSync, existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as
|
|
2632
|
+
import { chmodSync, existsSync as existsSync8, mkdirSync as mkdirSync4, readFileSync as readFileSync7, writeFileSync as writeFileSync5 } from "node:fs";
|
|
2604
2633
|
import path10 from "node:path";
|
|
2605
2634
|
var DEFAULT_CONFIG = { sinks: [], harnesses: {}, update_check: true, keep_days: 30 };
|
|
2606
2635
|
function readConfig(file = configFile()) {
|
|
2607
2636
|
try {
|
|
2608
|
-
const j = JSON.parse(
|
|
2637
|
+
const j = JSON.parse(readFileSync7(file, "utf8"));
|
|
2609
2638
|
return {
|
|
2610
2639
|
...DEFAULT_CONFIG,
|
|
2611
2640
|
...j,
|
|
@@ -2705,7 +2734,7 @@ import {
|
|
|
2705
2734
|
mkdirSync as mkdirSync5,
|
|
2706
2735
|
openSync as openSync2,
|
|
2707
2736
|
readdirSync as readdirSync5,
|
|
2708
|
-
readFileSync as
|
|
2737
|
+
readFileSync as readFileSync8,
|
|
2709
2738
|
readSync as readSync2,
|
|
2710
2739
|
renameSync,
|
|
2711
2740
|
statSync as statSync5,
|
|
@@ -2735,7 +2764,7 @@ var Outbox = class {
|
|
|
2735
2764
|
const f = this.seqFile(ref);
|
|
2736
2765
|
let n = -1;
|
|
2737
2766
|
try {
|
|
2738
|
-
const t =
|
|
2767
|
+
const t = readFileSync8(f, "utf8").trim();
|
|
2739
2768
|
if (/^\d+$/.test(t)) n = Number(t);
|
|
2740
2769
|
} catch {
|
|
2741
2770
|
}
|
|
@@ -2747,7 +2776,7 @@ var Outbox = class {
|
|
|
2747
2776
|
lastSeqInFile(ref) {
|
|
2748
2777
|
const f = this.file(ref);
|
|
2749
2778
|
if (!existsSync9(f)) return -1;
|
|
2750
|
-
const lines =
|
|
2779
|
+
const lines = readFileSync8(f, "utf8").trim().split("\n");
|
|
2751
2780
|
for (let i = lines.length - 1; i >= 0; i--) {
|
|
2752
2781
|
try {
|
|
2753
2782
|
const j = JSON.parse(lines[i]);
|
|
@@ -2870,7 +2899,7 @@ var Cursors = class {
|
|
|
2870
2899
|
}
|
|
2871
2900
|
read() {
|
|
2872
2901
|
try {
|
|
2873
|
-
return JSON.parse(
|
|
2902
|
+
return JSON.parse(readFileSync8(this.file(), "utf8"));
|
|
2874
2903
|
} catch {
|
|
2875
2904
|
return {};
|
|
2876
2905
|
}
|
|
@@ -2894,7 +2923,7 @@ function takeNamedLock(root, name, staleMs = 5 * 6e4) {
|
|
|
2894
2923
|
mkdirSync5(dir, { recursive: true, mode: 448 });
|
|
2895
2924
|
const f = path11.join(dir, `${name}.lock`);
|
|
2896
2925
|
try {
|
|
2897
|
-
if (Date.now() - statSync5(f).mtimeMs > staleMs || !processAlive(Number(
|
|
2926
|
+
if (Date.now() - statSync5(f).mtimeMs > staleMs || !processAlive(Number(readFileSync8(f, "utf8")))) unlinkSync3(f);
|
|
2898
2927
|
else return null;
|
|
2899
2928
|
} catch {
|
|
2900
2929
|
}
|
|
@@ -3287,7 +3316,7 @@ import {
|
|
|
3287
3316
|
existsSync as existsSync10,
|
|
3288
3317
|
mkdirSync as mkdirSync8,
|
|
3289
3318
|
readdirSync as readdirSync6,
|
|
3290
|
-
readFileSync as
|
|
3319
|
+
readFileSync as readFileSync10,
|
|
3291
3320
|
renameSync as renameSync3,
|
|
3292
3321
|
statSync as statSync6,
|
|
3293
3322
|
unlinkSync as unlinkSync4,
|
|
@@ -3297,7 +3326,7 @@ import os3 from "node:os";
|
|
|
3297
3326
|
import path15 from "node:path";
|
|
3298
3327
|
|
|
3299
3328
|
// src/control/aliases.ts
|
|
3300
|
-
import { chmodSync as chmodSync2, mkdirSync as mkdirSync7, readFileSync as
|
|
3329
|
+
import { chmodSync as chmodSync2, mkdirSync as mkdirSync7, readFileSync as readFileSync9, renameSync as renameSync2, writeFileSync as writeFileSync7 } from "node:fs";
|
|
3301
3330
|
import path13 from "node:path";
|
|
3302
3331
|
|
|
3303
3332
|
// src/secrets.ts
|
|
@@ -3345,7 +3374,7 @@ function startOptionsOf(v) {
|
|
|
3345
3374
|
var aliasFile = (controlDir) => path13.join(controlDir, "aliases.json");
|
|
3346
3375
|
function readAliases(file) {
|
|
3347
3376
|
try {
|
|
3348
|
-
const j = JSON.parse(
|
|
3377
|
+
const j = JSON.parse(readFileSync9(file, "utf8"));
|
|
3349
3378
|
if (!j || typeof j !== "object" || Array.isArray(j)) return {};
|
|
3350
3379
|
const out = {};
|
|
3351
3380
|
for (const [k, v] of Object.entries(j)) {
|
|
@@ -3530,7 +3559,7 @@ function claimJob(file) {
|
|
|
3530
3559
|
return null;
|
|
3531
3560
|
}
|
|
3532
3561
|
try {
|
|
3533
|
-
return { job: JSON.parse(
|
|
3562
|
+
return { job: JSON.parse(readFileSync10(claimed, "utf8")), file: claimed };
|
|
3534
3563
|
} catch {
|
|
3535
3564
|
releaseJob(claimed);
|
|
3536
3565
|
return null;
|
|
@@ -3601,7 +3630,7 @@ function factsState(state) {
|
|
|
3601
3630
|
return {
|
|
3602
3631
|
get(h, s) {
|
|
3603
3632
|
try {
|
|
3604
|
-
return JSON.parse(
|
|
3633
|
+
return JSON.parse(readFileSync10(file(h, s), "utf8"));
|
|
3605
3634
|
} catch {
|
|
3606
3635
|
return {};
|
|
3607
3636
|
}
|
|
@@ -3867,7 +3896,7 @@ var BACKOFF_MS = [2e3, 1e4, 6e4, 5 * 6e4, 30 * 6e4];
|
|
|
3867
3896
|
var backoffFile = (state, sink) => path15.join(state, "backoff", `${safeId(sink)}.json`);
|
|
3868
3897
|
function readBackoff(state, sink) {
|
|
3869
3898
|
try {
|
|
3870
|
-
const b = JSON.parse(
|
|
3899
|
+
const b = JSON.parse(readFileSync10(backoffFile(state, sink), "utf8"));
|
|
3871
3900
|
return typeof b.until === "number" ? b : null;
|
|
3872
3901
|
} catch {
|
|
3873
3902
|
return null;
|