sessionpipe 0.4.1 → 0.6.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/README.md +54 -0
- package/dist/cli.js +3767 -2360
- package/dist/cli.js.map +4 -4
- package/dist/connect.d.ts +22 -0
- package/dist/connect.d.ts.map +1 -0
- package/dist/control/autoupdate.d.ts +156 -0
- package/dist/control/autoupdate.d.ts.map +1 -0
- package/dist/control/cli.d.ts +10 -1
- package/dist/control/cli.d.ts.map +1 -1
- package/dist/control/daemon.d.ts +75 -1
- package/dist/control/daemon.d.ts.map +1 -1
- package/dist/control/local.d.ts +4 -0
- package/dist/control/local.d.ts.map +1 -1
- package/dist/control/pair.d.ts +14 -0
- package/dist/control/pair.d.ts.map +1 -1
- package/dist/control/route.d.ts +6 -0
- package/dist/control/route.d.ts.map +1 -1
- package/dist/control/store.d.ts +22 -2
- package/dist/control/store.d.ts.map +1 -1
- package/dist/hook.js +1 -1
- package/dist/hook.js.map +2 -2
- package/dist/index.js +45 -7
- package/dist/index.js.map +4 -4
- package/dist/launcher.d.ts +31 -0
- package/dist/launcher.d.ts.map +1 -0
- package/dist/run.d.ts +3 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/runtime.d.ts +6 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/secrets.d.ts +39 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/update.d.ts +70 -0
- package/dist/update.d.ts.map +1 -0
- package/dist/worker.js +45 -7
- package/dist/worker.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// sessionpipe 0.
|
|
1
|
+
// sessionpipe 0.6.0 · Apache-2.0 · https://sessionpipe.org
|
|
2
2
|
|
|
3
3
|
// src/http-sink.ts
|
|
4
4
|
import { createHash, createHmac } from "node:crypto";
|
|
@@ -342,7 +342,7 @@ function readAntigravity(lines, from) {
|
|
|
342
342
|
// ../core/src/adapters/claude-shaped.ts
|
|
343
343
|
import { existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
344
344
|
import path3 from "node:path";
|
|
345
|
-
var OURS = /sessionpipe[^"\n]*[\\/]hook\.js"?\s+[a-z][a-z-]*\s+[A-Za-z]+\s*$/;
|
|
345
|
+
var OURS = /(?:sessionpipe[^"\n]*[\\/]hook\.js|[\\/]sessionpipe-hook)"?\s+[a-z][a-z-]*\s+[A-Za-z]+\s*$/;
|
|
346
346
|
var isOurs = (h) => Array.isArray(h?.hooks) && h.hooks.some((x) => typeof x.command === "string" && OURS.test(x.command));
|
|
347
347
|
function readJsonFile(file) {
|
|
348
348
|
let raw;
|
|
@@ -1309,7 +1309,7 @@ import path6 from "node:path";
|
|
|
1309
1309
|
// ../core/src/adapters/codex-config.ts
|
|
1310
1310
|
var NOTIFY_LINE = /^[ \t]*notify[ \t]*=[ \t]*(\[.*\])[ \t]*(?:#.*)?$/m;
|
|
1311
1311
|
var NOTIFY_KEY = /^[ \t]*notify[ \t]*=/m;
|
|
1312
|
-
var OURS2 = /hook\.js",\s*"codex",\s*"notify"/;
|
|
1312
|
+
var OURS2 = /(?:hook\.js|sessionpipe-hook)",\s*"codex",\s*"notify"/;
|
|
1313
1313
|
function scan(line, st) {
|
|
1314
1314
|
let i = 0;
|
|
1315
1315
|
while (i < line.length) {
|
|
@@ -2614,6 +2614,37 @@ function ask(sock, req, timeoutMs) {
|
|
|
2614
2614
|
});
|
|
2615
2615
|
}
|
|
2616
2616
|
|
|
2617
|
+
// src/secrets.ts
|
|
2618
|
+
import { spawnSync } from "node:child_process";
|
|
2619
|
+
import { createHash as createHash4, randomBytes as randomBytes2 } from "node:crypto";
|
|
2620
|
+
var SERVICE = "sessionpipe";
|
|
2621
|
+
var defaultRunner = (cmd, args, input) => {
|
|
2622
|
+
const r = spawnSync(cmd, args, {
|
|
2623
|
+
input: input ?? "",
|
|
2624
|
+
encoding: "utf8",
|
|
2625
|
+
timeout: 8e3,
|
|
2626
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
2627
|
+
});
|
|
2628
|
+
return { status: r.error ? null : r.status, stdout: r.stdout ?? "" };
|
|
2629
|
+
};
|
|
2630
|
+
var sinkAccount = (name, what = "token") => {
|
|
2631
|
+
const scope = process.env.SESSIONPIPE_CONFIG ? `@${createHash4("sha256").update(configFile()).digest("hex").slice(0, 8)}` : "";
|
|
2632
|
+
return `sink:${name}:${what}${scope}`;
|
|
2633
|
+
};
|
|
2634
|
+
function secretGet(store, account, run = defaultRunner) {
|
|
2635
|
+
const r = store === "keychain" ? run("security", ["find-generic-password", "-s", SERVICE, "-a", account, "-w"]) : run("secret-tool", ["lookup", "service", SERVICE, "account", account]);
|
|
2636
|
+
if (r.status !== 0) return null;
|
|
2637
|
+
const v = r.stdout.replace(/\r?\n$/, "");
|
|
2638
|
+
return v || null;
|
|
2639
|
+
}
|
|
2640
|
+
function sinkWithSecrets(s, run = defaultRunner) {
|
|
2641
|
+
if (!s.token_in) return s;
|
|
2642
|
+
const token = secretGet(s.token_in, sinkAccount(s.name), run);
|
|
2643
|
+
if (!token) return null;
|
|
2644
|
+
const secret = secretGet(s.token_in, sinkAccount(s.name, "secret"), run);
|
|
2645
|
+
return { ...s, token, ...secret ? { secret } : {} };
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2617
2648
|
// src/run.ts
|
|
2618
2649
|
async function tellDaemon(state, job, session, transcript) {
|
|
2619
2650
|
const sock = socketPath(state);
|
|
@@ -2669,10 +2700,15 @@ function factsState(state) {
|
|
|
2669
2700
|
}
|
|
2670
2701
|
};
|
|
2671
2702
|
}
|
|
2672
|
-
function buildSinks(sinks) {
|
|
2703
|
+
function buildSinks(sinks, o = {}) {
|
|
2673
2704
|
const out = [];
|
|
2674
|
-
for (const
|
|
2675
|
-
if (
|
|
2705
|
+
for (const raw of sinks) {
|
|
2706
|
+
if (raw.paused) continue;
|
|
2707
|
+
const s = sinkWithSecrets(raw);
|
|
2708
|
+
if (!s) {
|
|
2709
|
+
o.locked?.(raw.name);
|
|
2710
|
+
continue;
|
|
2711
|
+
}
|
|
2676
2712
|
const tier = Math.min(s.tier, s.max_tier ?? 3);
|
|
2677
2713
|
if (s.url === "stdout") out.push(new StdoutSink(s.name, tier, !!s.pii));
|
|
2678
2714
|
else if (s.url.startsWith("file:"))
|
|
@@ -2781,7 +2817,9 @@ var BATCH = 50;
|
|
|
2781
2817
|
var MAX_PER_RUN = 500;
|
|
2782
2818
|
async function flush(state, sinkConfigs, outbox, first) {
|
|
2783
2819
|
const delivered = {};
|
|
2784
|
-
const sinks = buildSinks(sinkConfigs
|
|
2820
|
+
const sinks = buildSinks(sinkConfigs, {
|
|
2821
|
+
locked: (name) => log(state, `sink ${name}: its token is in a keychain this process can't read; left for later`)
|
|
2822
|
+
});
|
|
2785
2823
|
const refs = outbox.sessions();
|
|
2786
2824
|
if (first) {
|
|
2787
2825
|
const k = `${first.harness}/${safeId(first.session)}`;
|