claudish 10.4.1 → 10.5.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/index.js +368 -211
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -889,7 +889,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
889
889
|
});
|
|
890
890
|
|
|
891
891
|
// src/version.ts
|
|
892
|
-
var VERSION = "10.
|
|
892
|
+
var VERSION = "10.5.0";
|
|
893
893
|
|
|
894
894
|
// src/logger.ts
|
|
895
895
|
import { appendFile, existsSync as existsSync2, mkdirSync, readdirSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
@@ -62118,6 +62118,64 @@ var init_pane_registry = __esm(() => {
|
|
|
62118
62118
|
sweptRoots = new Set;
|
|
62119
62119
|
});
|
|
62120
62120
|
|
|
62121
|
+
// src/channel/parent-session.ts
|
|
62122
|
+
import { readFile as readFile4 } from "fs/promises";
|
|
62123
|
+
import { join as join42 } from "path";
|
|
62124
|
+
function positiveInt(value) {
|
|
62125
|
+
if (value === undefined || !/^[1-9][0-9]*$/.test(value))
|
|
62126
|
+
return;
|
|
62127
|
+
const n = Number(value);
|
|
62128
|
+
return Number.isSafeInteger(n) ? n : undefined;
|
|
62129
|
+
}
|
|
62130
|
+
function hostPidFrom(env, ppid) {
|
|
62131
|
+
const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
|
|
62132
|
+
if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
|
|
62133
|
+
return { hostPid: launcherPpid, launcherPid: ppid };
|
|
62134
|
+
}
|
|
62135
|
+
return { hostPid: ppid };
|
|
62136
|
+
}
|
|
62137
|
+
function parentSessionIdFrom(env) {
|
|
62138
|
+
const id = env.CLAUDE_CODE_SESSION_ID;
|
|
62139
|
+
if (id === undefined || !CLAUDE_ID_RE.test(id))
|
|
62140
|
+
return;
|
|
62141
|
+
if (env.CLAUDE_CODE_CHILD_SESSION)
|
|
62142
|
+
return;
|
|
62143
|
+
return id;
|
|
62144
|
+
}
|
|
62145
|
+
function claudeConfigDir(env) {
|
|
62146
|
+
const fromEnv = env.CLAUDE_CONFIG_DIR;
|
|
62147
|
+
return fromEnv && fromEnv.length > 0 ? fromEnv : join42(userHomeFrom(env), ".claude");
|
|
62148
|
+
}
|
|
62149
|
+
async function readHostSessionRecord(opts) {
|
|
62150
|
+
try {
|
|
62151
|
+
const raw = await readFile4(join42(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
|
|
62152
|
+
const parsed = JSON.parse(raw);
|
|
62153
|
+
if (!parsed || typeof parsed !== "object")
|
|
62154
|
+
return;
|
|
62155
|
+
const rec = parsed;
|
|
62156
|
+
if (rec.pid !== opts.hostPid)
|
|
62157
|
+
return;
|
|
62158
|
+
if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
|
|
62159
|
+
return;
|
|
62160
|
+
return { sessionId: rec.sessionId };
|
|
62161
|
+
} catch {
|
|
62162
|
+
return;
|
|
62163
|
+
}
|
|
62164
|
+
}
|
|
62165
|
+
async function parentSessionForCall(opts) {
|
|
62166
|
+
const env = opts.env ?? process.env;
|
|
62167
|
+
const record = await readHostSessionRecord({
|
|
62168
|
+
configDir: claudeConfigDir(env),
|
|
62169
|
+
hostPid: opts.hostPid
|
|
62170
|
+
});
|
|
62171
|
+
return record?.sessionId ?? parentSessionIdFrom(env);
|
|
62172
|
+
}
|
|
62173
|
+
var CLAUDE_ID_RE;
|
|
62174
|
+
var init_parent_session = __esm(() => {
|
|
62175
|
+
init_home_dir();
|
|
62176
|
+
CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
|
|
62177
|
+
});
|
|
62178
|
+
|
|
62121
62179
|
// src/process-tree.ts
|
|
62122
62180
|
function waitForExit(proc, ms) {
|
|
62123
62181
|
if (proc.exitCode !== null || proc.signalCode !== null)
|
|
@@ -62157,7 +62215,7 @@ function emptyScreen(cols, rows) {
|
|
|
62157
62215
|
};
|
|
62158
62216
|
}
|
|
62159
62217
|
function isBoxRule(line, cols) {
|
|
62160
|
-
if (!line || !/^\u2500
|
|
62218
|
+
if (!line || !/^\u2500+(?: [^\u2500]+ \u2500+)?$/.test(line))
|
|
62161
62219
|
return false;
|
|
62162
62220
|
return line.length >= Math.max(20, Math.min(cols, 160) - 1);
|
|
62163
62221
|
}
|
|
@@ -62432,6 +62490,104 @@ var init_screen_classifier = __esm(() => {
|
|
|
62432
62490
|
NON_ANSWER_ROW = /^\s+\u23BF|^\s{2}(Ran|Read|Searched|Wrote|Edited|Listed|Updated) \d+ |^\s*[\u00B7\u2722\u2733\u2736\u273B\u273D*\u25CF\u2217]\s|^\s*\(ctrl\+/;
|
|
62433
62491
|
});
|
|
62434
62492
|
|
|
62493
|
+
// src/pane/session-registry.ts
|
|
62494
|
+
import { readFileSync as readFileSync27, readdirSync as readdirSync6 } from "fs";
|
|
62495
|
+
import { join as join43 } from "path";
|
|
62496
|
+
function parseRegistryRecord(raw) {
|
|
62497
|
+
let parsed;
|
|
62498
|
+
try {
|
|
62499
|
+
parsed = JSON.parse(raw);
|
|
62500
|
+
} catch {
|
|
62501
|
+
const trimmed = raw.trimEnd().replace(/\}+$/, "}");
|
|
62502
|
+
try {
|
|
62503
|
+
parsed = JSON.parse(trimmed);
|
|
62504
|
+
} catch {
|
|
62505
|
+
return null;
|
|
62506
|
+
}
|
|
62507
|
+
}
|
|
62508
|
+
if (!parsed || typeof parsed !== "object")
|
|
62509
|
+
return null;
|
|
62510
|
+
const r = parsed;
|
|
62511
|
+
if (typeof r.pid !== "number" || typeof r.sessionId !== "string")
|
|
62512
|
+
return null;
|
|
62513
|
+
return {
|
|
62514
|
+
pid: r.pid,
|
|
62515
|
+
sessionId: r.sessionId,
|
|
62516
|
+
status: typeof r.status === "string" ? r.status : null,
|
|
62517
|
+
statusUpdatedAt: typeof r.statusUpdatedAt === "number" ? r.statusUpdatedAt : null,
|
|
62518
|
+
waitingFor: typeof r.waitingFor === "string" ? r.waitingFor : null,
|
|
62519
|
+
version: typeof r.version === "string" ? r.version : null
|
|
62520
|
+
};
|
|
62521
|
+
}
|
|
62522
|
+
function pidAlive(pid) {
|
|
62523
|
+
try {
|
|
62524
|
+
process.kill(pid, 0);
|
|
62525
|
+
return true;
|
|
62526
|
+
} catch (e) {
|
|
62527
|
+
return e.code === "EPERM";
|
|
62528
|
+
}
|
|
62529
|
+
}
|
|
62530
|
+
|
|
62531
|
+
class SessionRegistry {
|
|
62532
|
+
o;
|
|
62533
|
+
pid = null;
|
|
62534
|
+
lastScanAt = Number.NEGATIVE_INFINITY;
|
|
62535
|
+
dir;
|
|
62536
|
+
now;
|
|
62537
|
+
isAlive;
|
|
62538
|
+
constructor(o) {
|
|
62539
|
+
this.o = o;
|
|
62540
|
+
this.dir = join43(o.configDir, "sessions");
|
|
62541
|
+
this.now = o.now ?? Date.now;
|
|
62542
|
+
this.isAlive = o.isAlive ?? pidAlive;
|
|
62543
|
+
}
|
|
62544
|
+
read() {
|
|
62545
|
+
if (this.pid !== null) {
|
|
62546
|
+
const rec = this.readPid(this.pid);
|
|
62547
|
+
if (rec)
|
|
62548
|
+
return rec;
|
|
62549
|
+
this.pid = null;
|
|
62550
|
+
}
|
|
62551
|
+
const now = this.now();
|
|
62552
|
+
if (now - this.lastScanAt < SCAN_INTERVAL_MS)
|
|
62553
|
+
return null;
|
|
62554
|
+
this.lastScanAt = now;
|
|
62555
|
+
let names;
|
|
62556
|
+
try {
|
|
62557
|
+
names = readdirSync6(this.dir);
|
|
62558
|
+
} catch {
|
|
62559
|
+
return null;
|
|
62560
|
+
}
|
|
62561
|
+
for (const name of names) {
|
|
62562
|
+
const m = /^(\d+)\.json$/.exec(name);
|
|
62563
|
+
if (!m)
|
|
62564
|
+
continue;
|
|
62565
|
+
const rec = this.readPid(Number(m[1]));
|
|
62566
|
+
if (rec) {
|
|
62567
|
+
this.pid = rec.pid;
|
|
62568
|
+
return rec;
|
|
62569
|
+
}
|
|
62570
|
+
}
|
|
62571
|
+
return null;
|
|
62572
|
+
}
|
|
62573
|
+
readPid(pid) {
|
|
62574
|
+
let raw;
|
|
62575
|
+
try {
|
|
62576
|
+
raw = readFileSync27(join43(this.dir, `${pid}.json`), "utf8");
|
|
62577
|
+
} catch {
|
|
62578
|
+
return null;
|
|
62579
|
+
}
|
|
62580
|
+
const rec = parseRegistryRecord(raw);
|
|
62581
|
+
if (!rec || rec.pid !== pid || rec.sessionId !== this.o.sessionUuid)
|
|
62582
|
+
return null;
|
|
62583
|
+
return this.isAlive(pid) ? rec : null;
|
|
62584
|
+
}
|
|
62585
|
+
}
|
|
62586
|
+
var KNOWN_STATUSES, SCAN_INTERVAL_MS = 1000;
|
|
62587
|
+
var init_session_registry = __esm(() => {
|
|
62588
|
+
KNOWN_STATUSES = new Set(["idle", "busy", "waiting", "shell"]);
|
|
62589
|
+
});
|
|
62590
|
+
|
|
62435
62591
|
// src/pane/settle-rule.ts
|
|
62436
62592
|
function agentsBalanced(t) {
|
|
62437
62593
|
return t.agentsLaunched === t.agentsCompleted;
|
|
@@ -62616,11 +62772,11 @@ import {
|
|
|
62616
62772
|
fstatSync,
|
|
62617
62773
|
openSync as openSync7,
|
|
62618
62774
|
readSync as readSync2,
|
|
62619
|
-
readdirSync as
|
|
62775
|
+
readdirSync as readdirSync7,
|
|
62620
62776
|
realpathSync as realpathSync2,
|
|
62621
62777
|
statSync as statSync7
|
|
62622
62778
|
} from "fs";
|
|
62623
|
-
import { join as
|
|
62779
|
+
import { join as join44 } from "path";
|
|
62624
62780
|
function initialFollowerState(resolvePath = safeRealpath) {
|
|
62625
62781
|
return {
|
|
62626
62782
|
turns: [],
|
|
@@ -63116,7 +63272,7 @@ class TranscriptFollower {
|
|
|
63116
63272
|
if (!existsSync29(this.subagentsDir))
|
|
63117
63273
|
return [];
|
|
63118
63274
|
try {
|
|
63119
|
-
return
|
|
63275
|
+
return readdirSync7(this.subagentsDir).filter((f) => f.endsWith(".jsonl"));
|
|
63120
63276
|
} catch {
|
|
63121
63277
|
return [];
|
|
63122
63278
|
}
|
|
@@ -63126,7 +63282,7 @@ class TranscriptFollower {
|
|
|
63126
63282
|
for (const f of this.subagentFiles()) {
|
|
63127
63283
|
let tail = this.subs.get(f);
|
|
63128
63284
|
if (!tail) {
|
|
63129
|
-
tail = new Tail(
|
|
63285
|
+
tail = new Tail(join44(this.subagentsDir, f));
|
|
63130
63286
|
this.subs.set(f, tail);
|
|
63131
63287
|
}
|
|
63132
63288
|
for (const { line } of tail.read()) {
|
|
@@ -63208,8 +63364,8 @@ var init_transcript_follower = __esm(() => {
|
|
|
63208
63364
|
});
|
|
63209
63365
|
|
|
63210
63366
|
// src/pane/pane-session.ts
|
|
63211
|
-
import { readFileSync as
|
|
63212
|
-
import { join as
|
|
63367
|
+
import { readFileSync as readFileSync28, realpathSync as realpathSync3, rmSync as rmSync4, statSync as statSync8, writeFileSync as writeFileSync19 } from "fs";
|
|
63368
|
+
import { join as join45 } from "path";
|
|
63213
63369
|
function iso(ms) {
|
|
63214
63370
|
return new Date(ms).toISOString();
|
|
63215
63371
|
}
|
|
@@ -63272,6 +63428,13 @@ class PaneSessionImpl {
|
|
|
63272
63428
|
claudeCodeVersion = null;
|
|
63273
63429
|
anomalies = new Map;
|
|
63274
63430
|
turnEndMissing = false;
|
|
63431
|
+
registry;
|
|
63432
|
+
registryRec = null;
|
|
63433
|
+
registryEverSeen = false;
|
|
63434
|
+
lastRegistryReadAt = 0;
|
|
63435
|
+
bootReadyAtMs = null;
|
|
63436
|
+
disagreeSince = new Map;
|
|
63437
|
+
disagreeCounted = new Set;
|
|
63275
63438
|
exitScrollback = "";
|
|
63276
63439
|
exitLastLine = "";
|
|
63277
63440
|
bootKind = null;
|
|
@@ -63311,7 +63474,11 @@ class PaneSessionImpl {
|
|
|
63311
63474
|
this.queue.push(o.initialPrompt);
|
|
63312
63475
|
this.secondaryQuietMs = o.timings?.secondaryQuietMs ?? SECONDARY_QUIET_MS;
|
|
63313
63476
|
this.corroborationMs = o.timings?.corroborationMs ?? CORROBORATION_MS;
|
|
63314
|
-
this.follower = new TranscriptFollower(o.transcriptPath,
|
|
63477
|
+
this.follower = new TranscriptFollower(o.transcriptPath, join45(o.transcriptPath.replace(/\.jsonl$/, ""), "subagents"));
|
|
63478
|
+
this.registry = new SessionRegistry({
|
|
63479
|
+
configDir: claudeConfigDir(o.parentEnv ?? process.env),
|
|
63480
|
+
sessionUuid: o.sessionUuid
|
|
63481
|
+
});
|
|
63315
63482
|
this.ready = new Promise((r) => {
|
|
63316
63483
|
this.resolveReady = r;
|
|
63317
63484
|
});
|
|
@@ -63352,7 +63519,7 @@ class PaneSessionImpl {
|
|
|
63352
63519
|
return this.spawnFailed(new Error("magmux did not start"));
|
|
63353
63520
|
this.magmux = proc;
|
|
63354
63521
|
try {
|
|
63355
|
-
writeFileSync19(
|
|
63522
|
+
writeFileSync19(join45(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
63356
63523
|
`, { mode: 384 });
|
|
63357
63524
|
} catch {}
|
|
63358
63525
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -63625,8 +63792,46 @@ class PaneSessionImpl {
|
|
|
63625
63792
|
this.evalIdle(view);
|
|
63626
63793
|
break;
|
|
63627
63794
|
}
|
|
63795
|
+
this.checkRegistry();
|
|
63628
63796
|
this.pump();
|
|
63629
63797
|
}
|
|
63798
|
+
checkRegistry() {
|
|
63799
|
+
const now = Date.now();
|
|
63800
|
+
if (now - this.lastRegistryReadAt < REGISTRY_READ_MS)
|
|
63801
|
+
return;
|
|
63802
|
+
this.lastRegistryReadAt = now;
|
|
63803
|
+
const rec = this.registry.read();
|
|
63804
|
+
this.registryRec = rec;
|
|
63805
|
+
if (rec)
|
|
63806
|
+
this.registryEverSeen = true;
|
|
63807
|
+
if (!this.registryEverSeen && this.bootReadyAtMs !== null && now - this.bootReadyAtMs >= REGISTRY_MISSING_MS) {
|
|
63808
|
+
this.disagree("registry_record_missing", true, now, 0);
|
|
63809
|
+
}
|
|
63810
|
+
const status = rec?.status ?? null;
|
|
63811
|
+
if (status !== null && !KNOWN_STATUSES.has(status))
|
|
63812
|
+
this.disagree(`registry_status_unknown:${status.slice(0, 32)}`, true, now, 0);
|
|
63813
|
+
if (!this.client)
|
|
63814
|
+
return;
|
|
63815
|
+
const idle = status === "idle";
|
|
63816
|
+
const dialog = hasChoiceDialog(this.screen);
|
|
63817
|
+
this.disagree("registry_idle_screen_booting", this.phase === "BOOTING" && idle && readBoot(this.screen).kind !== "repl", now);
|
|
63818
|
+
this.disagree("registry_idle_screen_working", this.phase === "RUNNING" && idle && isWorking(this.screen), now);
|
|
63819
|
+
this.disagree("registry_waiting_no_dialog", status === "waiting" && !dialog, now);
|
|
63820
|
+
this.disagree("screen_dialog_registry_not_waiting", dialog && (status === "idle" || status === "busy"), now);
|
|
63821
|
+
}
|
|
63822
|
+
disagree(key, holds, now, forMs = REGISTRY_DISAGREE_MS) {
|
|
63823
|
+
if (!holds) {
|
|
63824
|
+
this.disagreeSince.delete(key);
|
|
63825
|
+
this.disagreeCounted.delete(key);
|
|
63826
|
+
return;
|
|
63827
|
+
}
|
|
63828
|
+
const since = this.disagreeSince.get(key) ?? now;
|
|
63829
|
+
this.disagreeSince.set(key, since);
|
|
63830
|
+
if (now - since >= forMs && !this.disagreeCounted.has(key)) {
|
|
63831
|
+
this.disagreeCounted.add(key);
|
|
63832
|
+
this.anomaly(key);
|
|
63833
|
+
}
|
|
63834
|
+
}
|
|
63630
63835
|
checkLiveness() {
|
|
63631
63836
|
if (this.client || !this.panePidValue || this.paneExited)
|
|
63632
63837
|
return;
|
|
@@ -63676,6 +63881,7 @@ class PaneSessionImpl {
|
|
|
63676
63881
|
}
|
|
63677
63882
|
}
|
|
63678
63883
|
bootReady() {
|
|
63884
|
+
this.bootReadyAtMs = Date.now();
|
|
63679
63885
|
if (this.queue.length === 0) {
|
|
63680
63886
|
this.fire("boot_ready_idle");
|
|
63681
63887
|
return;
|
|
@@ -64158,7 +64364,7 @@ class PaneSessionImpl {
|
|
|
64158
64364
|
const p = this.errorLogPath();
|
|
64159
64365
|
if (p && this.errorLogSize() > st.errorLogSize) {
|
|
64160
64366
|
try {
|
|
64161
|
-
const text =
|
|
64367
|
+
const text = readFileSync28(p, "utf8").slice(st.errorLogSize).trim();
|
|
64162
64368
|
return { status: null, category: "upstream_error_log", text };
|
|
64163
64369
|
} catch {}
|
|
64164
64370
|
}
|
|
@@ -64322,8 +64528,10 @@ ${screenTailOf(this.screen)}`
|
|
|
64322
64528
|
}
|
|
64323
64529
|
diagnostics() {
|
|
64324
64530
|
const cur = this.follower.view().current;
|
|
64531
|
+
const rec = this.registryRec;
|
|
64325
64532
|
return {
|
|
64326
64533
|
magmuxStderr: this.stderrHead,
|
|
64534
|
+
registry: rec ? { status: rec.status, waitingFor: rec.waitingFor, version: rec.version } : null,
|
|
64327
64535
|
preambleBytes: cur?.preambleBytes ?? 0,
|
|
64328
64536
|
readCoverage: cur?.delivery ? {
|
|
64329
64537
|
linesTotal: cur.delivery.lines,
|
|
@@ -64591,8 +64799,9 @@ async function startPaneSession(o) {
|
|
|
64591
64799
|
await session.start({ magmuxBinary: magmux.binary, env: p.magmuxEnv, cwd: p.cwd });
|
|
64592
64800
|
return session;
|
|
64593
64801
|
}
|
|
64594
|
-
var BOOT_TIMEOUT_MS = 90000, ADMIT_TIMEOUT_MS = 30000, RESEND_AFTER_MS = 1e4, DEGRADED_ENTRY_MS = 1e4, SCREEN_SETTLE_QUIET_MS = 3000, PANEL_SETTLE_MS = 500, REPL_STABLE_MS = 500, BOOT_STATIC_MS = 5000, TICK_MS = 250, WATCH_FPS = 4, POLL_BACKSTOP_MS = 1000, TURN_END_MISSING_FACTOR = 3, MAX_ANOMALY_KEYS = 64, KEPT_ANSWERS = 4, EVENT_REASON, VERDICT_EVENT, PaneStartError;
|
|
64802
|
+
var BOOT_TIMEOUT_MS = 90000, ADMIT_TIMEOUT_MS = 30000, RESEND_AFTER_MS = 1e4, DEGRADED_ENTRY_MS = 1e4, SCREEN_SETTLE_QUIET_MS = 3000, PANEL_SETTLE_MS = 500, REPL_STABLE_MS = 500, BOOT_STATIC_MS = 5000, TICK_MS = 250, WATCH_FPS = 4, POLL_BACKSTOP_MS = 1000, TURN_END_MISSING_FACTOR = 3, REGISTRY_READ_MS = 250, REGISTRY_DISAGREE_MS = 2000, REGISTRY_MISSING_MS = 5000, MAX_ANOMALY_KEYS = 64, KEPT_ANSWERS = 4, EVENT_REASON, VERDICT_EVENT, PaneStartError;
|
|
64595
64803
|
var init_pane_session = __esm(() => {
|
|
64804
|
+
init_parent_session();
|
|
64596
64805
|
init_process_tree();
|
|
64597
64806
|
init_redact();
|
|
64598
64807
|
init_magmux_client();
|
|
@@ -64601,6 +64810,7 @@ var init_pane_session = __esm(() => {
|
|
|
64601
64810
|
init_process_identity();
|
|
64602
64811
|
init_prompt_delivery();
|
|
64603
64812
|
init_screen_classifier();
|
|
64813
|
+
init_session_registry();
|
|
64604
64814
|
init_settle_rule();
|
|
64605
64815
|
init_slot_state();
|
|
64606
64816
|
init_transcript_follower();
|
|
@@ -64637,64 +64847,6 @@ var init_pane = __esm(() => {
|
|
|
64637
64847
|
init_contract();
|
|
64638
64848
|
});
|
|
64639
64849
|
|
|
64640
|
-
// src/channel/parent-session.ts
|
|
64641
|
-
import { readFile as readFile4 } from "fs/promises";
|
|
64642
|
-
import { join as join44 } from "path";
|
|
64643
|
-
function positiveInt(value) {
|
|
64644
|
-
if (value === undefined || !/^[1-9][0-9]*$/.test(value))
|
|
64645
|
-
return;
|
|
64646
|
-
const n = Number(value);
|
|
64647
|
-
return Number.isSafeInteger(n) ? n : undefined;
|
|
64648
|
-
}
|
|
64649
|
-
function hostPidFrom(env, ppid) {
|
|
64650
|
-
const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
|
|
64651
|
-
if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
|
|
64652
|
-
return { hostPid: launcherPpid, launcherPid: ppid };
|
|
64653
|
-
}
|
|
64654
|
-
return { hostPid: ppid };
|
|
64655
|
-
}
|
|
64656
|
-
function parentSessionIdFrom(env) {
|
|
64657
|
-
const id = env.CLAUDE_CODE_SESSION_ID;
|
|
64658
|
-
if (id === undefined || !CLAUDE_ID_RE.test(id))
|
|
64659
|
-
return;
|
|
64660
|
-
if (env.CLAUDE_CODE_CHILD_SESSION)
|
|
64661
|
-
return;
|
|
64662
|
-
return id;
|
|
64663
|
-
}
|
|
64664
|
-
function claudeConfigDir(env) {
|
|
64665
|
-
const fromEnv = env.CLAUDE_CONFIG_DIR;
|
|
64666
|
-
return fromEnv && fromEnv.length > 0 ? fromEnv : join44(userHomeFrom(env), ".claude");
|
|
64667
|
-
}
|
|
64668
|
-
async function readHostSessionRecord(opts) {
|
|
64669
|
-
try {
|
|
64670
|
-
const raw = await readFile4(join44(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
|
|
64671
|
-
const parsed = JSON.parse(raw);
|
|
64672
|
-
if (!parsed || typeof parsed !== "object")
|
|
64673
|
-
return;
|
|
64674
|
-
const rec = parsed;
|
|
64675
|
-
if (rec.pid !== opts.hostPid)
|
|
64676
|
-
return;
|
|
64677
|
-
if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
|
|
64678
|
-
return;
|
|
64679
|
-
return { sessionId: rec.sessionId };
|
|
64680
|
-
} catch {
|
|
64681
|
-
return;
|
|
64682
|
-
}
|
|
64683
|
-
}
|
|
64684
|
-
async function parentSessionForCall(opts) {
|
|
64685
|
-
const env = opts.env ?? process.env;
|
|
64686
|
-
const record = await readHostSessionRecord({
|
|
64687
|
-
configDir: claudeConfigDir(env),
|
|
64688
|
-
hostPid: opts.hostPid
|
|
64689
|
-
});
|
|
64690
|
-
return record?.sessionId ?? parentSessionIdFrom(env);
|
|
64691
|
-
}
|
|
64692
|
-
var CLAUDE_ID_RE;
|
|
64693
|
-
var init_parent_session = __esm(() => {
|
|
64694
|
-
init_home_dir();
|
|
64695
|
-
CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
|
|
64696
|
-
});
|
|
64697
|
-
|
|
64698
64850
|
// src/session/session-discovery.ts
|
|
64699
64851
|
var exports_session_discovery = {};
|
|
64700
64852
|
__export(exports_session_discovery, {
|
|
@@ -64712,10 +64864,10 @@ __export(exports_session_discovery, {
|
|
|
64712
64864
|
transcriptPathFor: () => transcriptPathFor
|
|
64713
64865
|
});
|
|
64714
64866
|
import { execFile as execFile3, execFileSync as execFileSync3 } from "child_process";
|
|
64715
|
-
import { closeSync as closeSync8, openSync as openSync8, readSync as readSync3, readdirSync as
|
|
64716
|
-
import { basename as basename2, join as
|
|
64867
|
+
import { closeSync as closeSync8, openSync as openSync8, readSync as readSync3, readdirSync as readdirSync8, realpathSync as realpathSync4, statSync as statSync9 } from "fs";
|
|
64868
|
+
import { basename as basename2, join as join46 } from "path";
|
|
64717
64869
|
function projectsDir(env = process.env) {
|
|
64718
|
-
return
|
|
64870
|
+
return join46(claudeConfigDir(env), "projects");
|
|
64719
64871
|
}
|
|
64720
64872
|
function slugForPath(absPath) {
|
|
64721
64873
|
return projectDirNameFor(absPath);
|
|
@@ -64725,7 +64877,7 @@ function transcriptPathFor(cwd, sessionUuid, projectsRoot = projectsDir()) {
|
|
|
64725
64877
|
try {
|
|
64726
64878
|
real = realpathSync4(cwd);
|
|
64727
64879
|
} catch {}
|
|
64728
|
-
return
|
|
64880
|
+
return join46(projectsRoot, slugForPath(real), `${sessionUuid}.jsonl`);
|
|
64729
64881
|
}
|
|
64730
64882
|
function isAgentSession(row) {
|
|
64731
64883
|
return row.entrypoint !== undefined && row.entrypoint !== "cli";
|
|
@@ -64766,22 +64918,22 @@ function getRepoContext(cwd = process.cwd()) {
|
|
|
64766
64918
|
}
|
|
64767
64919
|
function projectDirs() {
|
|
64768
64920
|
try {
|
|
64769
|
-
return
|
|
64921
|
+
return readdirSync8(projectsDir(), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
64770
64922
|
} catch {
|
|
64771
64923
|
return [];
|
|
64772
64924
|
}
|
|
64773
64925
|
}
|
|
64774
64926
|
function sessionsIn(dirName) {
|
|
64775
|
-
const dir =
|
|
64927
|
+
const dir = join46(projectsDir(), dirName);
|
|
64776
64928
|
let names;
|
|
64777
64929
|
try {
|
|
64778
|
-
names =
|
|
64930
|
+
names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
|
|
64779
64931
|
} catch {
|
|
64780
64932
|
return [];
|
|
64781
64933
|
}
|
|
64782
64934
|
const rows = [];
|
|
64783
64935
|
for (const n of names) {
|
|
64784
|
-
const file =
|
|
64936
|
+
const file = join46(dir, n);
|
|
64785
64937
|
try {
|
|
64786
64938
|
const st = statSync9(file);
|
|
64787
64939
|
if (st.size === 0)
|
|
@@ -65158,8 +65310,8 @@ var init_session_discovery = __esm(() => {
|
|
|
65158
65310
|
|
|
65159
65311
|
// src/team-orchestrator.ts
|
|
65160
65312
|
import { randomBytes as randomBytes8, randomUUID as randomUUID5 } from "crypto";
|
|
65161
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as
|
|
65162
|
-
import { basename as basename3, join as
|
|
65313
|
+
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as readFileSync29, readdirSync as readdirSync9, statSync as statSync10, writeFileSync as writeFileSync20 } from "fs";
|
|
65314
|
+
import { basename as basename3, join as join47, resolve as resolve4 } from "path";
|
|
65163
65315
|
function slotTerminal(e) {
|
|
65164
65316
|
if (!e.session)
|
|
65165
65317
|
return true;
|
|
@@ -65320,14 +65472,14 @@ function teamRunRowFromDisk(path, status) {
|
|
|
65320
65472
|
}
|
|
65321
65473
|
function statusMtimeMs(path) {
|
|
65322
65474
|
try {
|
|
65323
|
-
return statSync10(
|
|
65475
|
+
return statSync10(join47(path, "status.json")).mtimeMs;
|
|
65324
65476
|
} catch {
|
|
65325
65477
|
return null;
|
|
65326
65478
|
}
|
|
65327
65479
|
}
|
|
65328
65480
|
function readManifestOrNull(path) {
|
|
65329
65481
|
try {
|
|
65330
|
-
return JSON.parse(
|
|
65482
|
+
return JSON.parse(readFileSync29(join47(path, "manifest.json"), "utf-8"));
|
|
65331
65483
|
} catch {
|
|
65332
65484
|
return null;
|
|
65333
65485
|
}
|
|
@@ -65535,7 +65687,7 @@ function readTeamInputFile(inputPath) {
|
|
|
65535
65687
|
if (!existsSync30(resolved)) {
|
|
65536
65688
|
throw new Error(`Input file not found: ${resolved}`);
|
|
65537
65689
|
}
|
|
65538
|
-
const text =
|
|
65690
|
+
const text = readFileSync29(resolved, "utf-8");
|
|
65539
65691
|
if (text.trim().length === 0) {
|
|
65540
65692
|
throw new Error(`Input file is empty: ${resolved}`);
|
|
65541
65693
|
}
|
|
@@ -65545,14 +65697,14 @@ function setupSession(sessionPath, models, input) {
|
|
|
65545
65697
|
if (models.length === 0) {
|
|
65546
65698
|
throw new Error("At least one model is required");
|
|
65547
65699
|
}
|
|
65548
|
-
if (existsSync30(
|
|
65700
|
+
if (existsSync30(join47(sessionPath, "manifest.json"))) {
|
|
65549
65701
|
throw new Error(`Session already exists at ${sessionPath}. Use a new directory path or delete the existing session first.`);
|
|
65550
65702
|
}
|
|
65551
|
-
mkdirSync19(
|
|
65552
|
-
mkdirSync19(
|
|
65703
|
+
mkdirSync19(join47(sessionPath, "work"), { recursive: true });
|
|
65704
|
+
mkdirSync19(join47(sessionPath, "errors"), { recursive: true });
|
|
65553
65705
|
if (input !== undefined) {
|
|
65554
|
-
writeFileSync20(
|
|
65555
|
-
} else if (!existsSync30(
|
|
65706
|
+
writeFileSync20(join47(sessionPath, "input.md"), input, "utf-8");
|
|
65707
|
+
} else if (!existsSync30(join47(sessionPath, "input.md"))) {
|
|
65556
65708
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
65557
65709
|
}
|
|
65558
65710
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -65569,9 +65721,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
65569
65721
|
model: models[i],
|
|
65570
65722
|
assignedAt: now
|
|
65571
65723
|
};
|
|
65572
|
-
mkdirSync19(
|
|
65724
|
+
mkdirSync19(join47(sessionPath, "work", anonId), { recursive: true });
|
|
65573
65725
|
}
|
|
65574
|
-
writeFileSync20(
|
|
65726
|
+
writeFileSync20(join47(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
65575
65727
|
const status = {
|
|
65576
65728
|
startedAt: now,
|
|
65577
65729
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -65586,7 +65738,7 @@ function setupSession(sessionPath, models, input) {
|
|
|
65586
65738
|
}
|
|
65587
65739
|
]))
|
|
65588
65740
|
};
|
|
65589
|
-
writeFileSync20(
|
|
65741
|
+
writeFileSync20(join47(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
65590
65742
|
return manifest;
|
|
65591
65743
|
}
|
|
65592
65744
|
function assertValidRequirePattern(pattern) {
|
|
@@ -65646,9 +65798,9 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65646
65798
|
if (!flagCheck.ok)
|
|
65647
65799
|
throw new Error(`invalid_args: ${flagCheck.message}`);
|
|
65648
65800
|
const path = resolve4(sessionPath);
|
|
65649
|
-
const manifest = JSON.parse(
|
|
65650
|
-
const statusPath =
|
|
65651
|
-
const inputContent =
|
|
65801
|
+
const manifest = JSON.parse(readFileSync29(join47(path, "manifest.json"), "utf-8"));
|
|
65802
|
+
const statusPath = join47(path, "status.json");
|
|
65803
|
+
const inputContent = readFileSync29(join47(path, "input.md"), "utf-8");
|
|
65652
65804
|
const readAvailable = !flagsRemoveRead(claudeFlags);
|
|
65653
65805
|
const refusal = deliveryRefusal(inputContent, readAvailable);
|
|
65654
65806
|
if (refusal)
|
|
@@ -65658,7 +65810,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65658
65810
|
const kind = opts.kind ?? "run";
|
|
65659
65811
|
const spawnPlan = await (opts.spawnPlanner ?? prehydrateCredentialsForSpawn)(Object.values(manifest.models).map((m) => m.model));
|
|
65660
65812
|
await assertMagmuxAvailable();
|
|
65661
|
-
const statusCache = JSON.parse(
|
|
65813
|
+
const statusCache = JSON.parse(readFileSync29(statusPath, "utf-8"));
|
|
65662
65814
|
const startMs = Date.now();
|
|
65663
65815
|
const runId = mintRunId(path, startMs);
|
|
65664
65816
|
statusCache.runId = runId;
|
|
@@ -65686,13 +65838,13 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65686
65838
|
mkdirSync19(statsDir(path), { recursive: true });
|
|
65687
65839
|
const entries = new Map;
|
|
65688
65840
|
let run = null;
|
|
65689
|
-
const errorLogPathOf = (id) =>
|
|
65690
|
-
const upstreamLogOf = (id) =>
|
|
65841
|
+
const errorLogPathOf = (id) => join47(path, "errors", `${id}.log`);
|
|
65842
|
+
const upstreamLogOf = (id) => join47(path, "errors", `${id}-upstream.jsonl`);
|
|
65691
65843
|
const commandOf = (e) => ["claudish", "-i", "--model", e.spawnModel ?? e.model, "-y", "--quiet", ...claudeFlags].join(" ");
|
|
65692
65844
|
function writeResponse(e, text) {
|
|
65693
65845
|
e.answer = text;
|
|
65694
65846
|
try {
|
|
65695
|
-
writeFileSync20(
|
|
65847
|
+
writeFileSync20(join47(path, `response-${e.id}.md`), text, "utf-8");
|
|
65696
65848
|
} catch (err) {
|
|
65697
65849
|
persistErrorLog(errorLogPathOf(e.id), `response file not written: ${String(err)}`, []);
|
|
65698
65850
|
}
|
|
@@ -66023,20 +66175,20 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
66023
66175
|
const active = activeRunAt(resolve4(sessionPath));
|
|
66024
66176
|
if (active)
|
|
66025
66177
|
throw new Error(`invalid_args: the team run at ${resolve4(sessionPath)} is still ACTIVE (run_id ${active.runId}); judge it once it has settled`);
|
|
66026
|
-
const responseFiles =
|
|
66178
|
+
const responseFiles = readdirSync9(sessionPath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
66027
66179
|
if (responseFiles.length < 2) {
|
|
66028
66180
|
throw new Error(`Need at least 2 responses to judge, found ${responseFiles.length}`);
|
|
66029
66181
|
}
|
|
66030
66182
|
const responses = {};
|
|
66031
66183
|
for (const file of responseFiles) {
|
|
66032
66184
|
const id = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
66033
|
-
responses[id] =
|
|
66185
|
+
responses[id] = readFileSync29(join47(sessionPath, file), "utf-8");
|
|
66034
66186
|
}
|
|
66035
|
-
const input =
|
|
66187
|
+
const input = readFileSync29(join47(sessionPath, "input.md"), "utf-8");
|
|
66036
66188
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
66037
|
-
writeFileSync20(
|
|
66189
|
+
writeFileSync20(join47(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
66038
66190
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
66039
|
-
const judgePath =
|
|
66191
|
+
const judgePath = join47(sessionPath, "judging");
|
|
66040
66192
|
mkdirSync19(judgePath, { recursive: true });
|
|
66041
66193
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
66042
66194
|
await runModels(judgePath, {
|
|
@@ -66047,11 +66199,11 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
66047
66199
|
});
|
|
66048
66200
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
66049
66201
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
66050
|
-
writeFileSync20(
|
|
66202
|
+
writeFileSync20(join47(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
66051
66203
|
return verdict;
|
|
66052
66204
|
}
|
|
66053
66205
|
function getStatus(sessionPath) {
|
|
66054
|
-
return JSON.parse(
|
|
66206
|
+
return JSON.parse(readFileSync29(join47(sessionPath, "status.json"), "utf-8"));
|
|
66055
66207
|
}
|
|
66056
66208
|
function readTeamStatus(sessionPath) {
|
|
66057
66209
|
try {
|
|
@@ -66087,7 +66239,7 @@ function fisherYatesShuffle(arr) {
|
|
|
66087
66239
|
return arr;
|
|
66088
66240
|
}
|
|
66089
66241
|
function getDefaultJudgeModels(sessionPath) {
|
|
66090
|
-
const manifest = JSON.parse(
|
|
66242
|
+
const manifest = JSON.parse(readFileSync29(join47(sessionPath, "manifest.json"), "utf-8"));
|
|
66091
66243
|
return Object.values(manifest.models).map((e) => e.model);
|
|
66092
66244
|
}
|
|
66093
66245
|
function buildJudgePrompt(input, responses) {
|
|
@@ -66145,12 +66297,12 @@ function buildJudgePrompt(input, responses) {
|
|
|
66145
66297
|
}
|
|
66146
66298
|
function parseJudgeVotes(judgePath, responseIds) {
|
|
66147
66299
|
const votes = [];
|
|
66148
|
-
const responseFiles =
|
|
66300
|
+
const responseFiles = readdirSync9(judgePath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
66149
66301
|
for (const file of responseFiles) {
|
|
66150
66302
|
const judgeId = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
66151
66303
|
let content;
|
|
66152
66304
|
try {
|
|
66153
|
-
content =
|
|
66305
|
+
content = readFileSync29(join47(judgePath, file), "utf-8");
|
|
66154
66306
|
} catch {
|
|
66155
66307
|
continue;
|
|
66156
66308
|
}
|
|
@@ -66202,7 +66354,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
66202
66354
|
function formatVerdict(verdict, sessionPath) {
|
|
66203
66355
|
let manifest = null;
|
|
66204
66356
|
try {
|
|
66205
|
-
manifest = JSON.parse(
|
|
66357
|
+
manifest = JSON.parse(readFileSync29(join47(sessionPath, "manifest.json"), "utf-8"));
|
|
66206
66358
|
} catch {}
|
|
66207
66359
|
let output = `# Team Verdict
|
|
66208
66360
|
|
|
@@ -66258,13 +66410,13 @@ import {
|
|
|
66258
66410
|
existsSync as existsSync31,
|
|
66259
66411
|
mkdirSync as mkdirSync20,
|
|
66260
66412
|
openSync as openSync9,
|
|
66261
|
-
readFileSync as
|
|
66413
|
+
readFileSync as readFileSync30,
|
|
66262
66414
|
readSync as readSync4,
|
|
66263
66415
|
renameSync as renameSync4,
|
|
66264
66416
|
statSync as statSync11,
|
|
66265
66417
|
writeFileSync as writeFileSync21
|
|
66266
66418
|
} from "fs";
|
|
66267
|
-
import { join as
|
|
66419
|
+
import { join as join48, resolve as resolve5, sep } from "path";
|
|
66268
66420
|
function normaliseTimeoutSeconds(raw) {
|
|
66269
66421
|
const n = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
|
|
66270
66422
|
if (typeof n !== "number" || !Number.isFinite(n))
|
|
@@ -66411,7 +66563,7 @@ function readJsonObject(path, maxBytes) {
|
|
|
66411
66563
|
try {
|
|
66412
66564
|
if (fileSize2(path) > maxBytes)
|
|
66413
66565
|
return null;
|
|
66414
|
-
const parsed = JSON.parse(
|
|
66566
|
+
const parsed = JSON.parse(readFileSync30(path, "utf-8"));
|
|
66415
66567
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
66416
66568
|
return null;
|
|
66417
66569
|
return parsed;
|
|
@@ -66437,7 +66589,7 @@ function dropLeadingFragment(tail) {
|
|
|
66437
66589
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
66438
66590
|
}
|
|
66439
66591
|
function diskAccounting(sessionDir) {
|
|
66440
|
-
const stats = readTokenStatsAt(
|
|
66592
|
+
const stats = readTokenStatsAt(join48(sessionDir, "tokens.json"));
|
|
66441
66593
|
return {
|
|
66442
66594
|
tokensIn: stats?.billed_input_tokens ?? null,
|
|
66443
66595
|
tokensOut: stats?.output_tokens ?? null,
|
|
@@ -66510,7 +66662,7 @@ class SessionManager {
|
|
|
66510
66662
|
let dir = "";
|
|
66511
66663
|
for (let attempt = 0;; attempt++) {
|
|
66512
66664
|
id = `team-${randomUUID6().replace(/-/g, "").slice(0, 8)}`;
|
|
66513
|
-
dir =
|
|
66665
|
+
dir = join48(this.sessionsDir, id);
|
|
66514
66666
|
try {
|
|
66515
66667
|
mkdirSync20(dir);
|
|
66516
66668
|
break;
|
|
@@ -66542,9 +66694,9 @@ class SessionManager {
|
|
|
66542
66694
|
if (dir === null)
|
|
66543
66695
|
throw new Error("not a record id");
|
|
66544
66696
|
const completedAt = new Date().toISOString();
|
|
66545
|
-
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(
|
|
66697
|
+
const startedAt = this.teamRunStarts.get(record) ?? metaString(readJsonObject(join48(dir, "spawn.json"), META_READ_LIMIT)?.startedAt) ?? completedAt;
|
|
66546
66698
|
const elapsedMs = Date.parse(completedAt) - Date.parse(startedAt);
|
|
66547
|
-
writeJsonAtomic(
|
|
66699
|
+
writeJsonAtomic(join48(dir, "meta.json"), {
|
|
66548
66700
|
kind: "team",
|
|
66549
66701
|
status: outcome.status,
|
|
66550
66702
|
startedAt,
|
|
@@ -66576,7 +66728,7 @@ class SessionManager {
|
|
|
66576
66728
|
startedAt,
|
|
66577
66729
|
...rest
|
|
66578
66730
|
};
|
|
66579
|
-
writeJsonAtomic(
|
|
66731
|
+
writeJsonAtomic(join48(dir, "spawn.json"), body);
|
|
66580
66732
|
}
|
|
66581
66733
|
async createSession(opts) {
|
|
66582
66734
|
if (this.activeSessions + this.starting >= this.maxSessions) {
|
|
@@ -66635,10 +66787,10 @@ class SessionManager {
|
|
|
66635
66787
|
const claudeSessionId = randomUUID6();
|
|
66636
66788
|
const timeout = normaliseTimeoutSeconds(opts.timeoutSeconds);
|
|
66637
66789
|
const startedAt = new Date().toISOString();
|
|
66638
|
-
const sessionDir = opts.sessionDir ??
|
|
66790
|
+
const sessionDir = opts.sessionDir ?? join48(this.sessionsDir, sessionId);
|
|
66639
66791
|
mkdirSync20(sessionDir, { recursive: true });
|
|
66640
66792
|
if (opts.prompt)
|
|
66641
|
-
writeFileSync21(
|
|
66793
|
+
writeFileSync21(join48(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
66642
66794
|
this.writeSpawnRecord(sessionDir, {
|
|
66643
66795
|
kind: "session",
|
|
66644
66796
|
sessionId,
|
|
@@ -66651,7 +66803,7 @@ class SessionManager {
|
|
|
66651
66803
|
const cwd = opts.cwd ?? process.cwd();
|
|
66652
66804
|
const parentEnv = opts.parentEnv ?? this.parentEnv;
|
|
66653
66805
|
const spawnModel = opts.spawnModel ?? null;
|
|
66654
|
-
const tokenFile = opts.tokenFile ??
|
|
66806
|
+
const tokenFile = opts.tokenFile ?? join48(sessionDir, "tokens.json");
|
|
66655
66807
|
return {
|
|
66656
66808
|
info: {
|
|
66657
66809
|
sessionId,
|
|
@@ -66686,17 +66838,17 @@ class SessionManager {
|
|
|
66686
66838
|
},
|
|
66687
66839
|
session: null,
|
|
66688
66840
|
scrollback: new ScrollbackBuffer(this.scrollbackCapacity),
|
|
66689
|
-
outputLogStream: createWriteStream(
|
|
66841
|
+
outputLogStream: createWriteStream(join48(sessionDir, "output.log")),
|
|
66690
66842
|
sessionDir,
|
|
66691
66843
|
cwd,
|
|
66692
66844
|
tokenFile,
|
|
66693
|
-
eventLogPath:
|
|
66845
|
+
eventLogPath: join48(sessionDir, "events.jsonl"),
|
|
66694
66846
|
eventLogBytes: 0,
|
|
66695
|
-
upstreamErrorLogPath:
|
|
66847
|
+
upstreamErrorLogPath: join48(sessionDir, "upstream-errors.jsonl"),
|
|
66696
66848
|
eventRing: [],
|
|
66697
66849
|
proseBytes: 0,
|
|
66698
|
-
answeredTurns: new
|
|
66699
|
-
waitLogPath:
|
|
66850
|
+
answeredTurns: new Map,
|
|
66851
|
+
waitLogPath: join48(sessionDir, "waits.jsonl"),
|
|
66700
66852
|
waitLogBytes: 0,
|
|
66701
66853
|
waitSince: null,
|
|
66702
66854
|
ended: false,
|
|
@@ -66844,7 +66996,7 @@ class SessionManager {
|
|
|
66844
66996
|
try {
|
|
66845
66997
|
const text = screenLines.join(`
|
|
66846
66998
|
`).replace(/\s+$/, "");
|
|
66847
|
-
writeFileSync21(
|
|
66999
|
+
writeFileSync21(join48(entry.sessionDir, "screen.txt"), `${redactSecrets2(text)}
|
|
66848
67000
|
`, "utf-8");
|
|
66849
67001
|
} catch {}
|
|
66850
67002
|
}
|
|
@@ -66858,7 +67010,7 @@ class SessionManager {
|
|
|
66858
67010
|
entry.waitSince = null;
|
|
66859
67011
|
}
|
|
66860
67012
|
try {
|
|
66861
|
-
writeJsonAtomic(
|
|
67013
|
+
writeJsonAtomic(join48(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
|
|
66862
67014
|
} catch (err) {
|
|
66863
67015
|
process.stderr.write(`[claudish] session ${entry.info.sessionId}: could not write meta.json: ` + `${err instanceof Error ? err.message : String(err)}
|
|
66864
67016
|
`);
|
|
@@ -67058,6 +67210,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67058
67210
|
screenTail: "",
|
|
67059
67211
|
sockPath: null,
|
|
67060
67212
|
magmuxStderr: "",
|
|
67213
|
+
registry: null,
|
|
67061
67214
|
preambleBytes: 0,
|
|
67062
67215
|
readCoverage: null,
|
|
67063
67216
|
claudeCodeVersion: null,
|
|
@@ -67071,6 +67224,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67071
67224
|
screenTail: redactSecrets2(snap.screenTail),
|
|
67072
67225
|
sockPath: session.sockPath,
|
|
67073
67226
|
magmuxStderr: redactSecrets2(pane.magmuxStderr),
|
|
67227
|
+
registry: pane.registry,
|
|
67074
67228
|
preambleBytes: pane.preambleBytes,
|
|
67075
67229
|
readCoverage: pane.readCoverage,
|
|
67076
67230
|
claudeCodeVersion: snap.claudeCodeVersion,
|
|
@@ -67143,7 +67297,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67143
67297
|
return null;
|
|
67144
67298
|
const root = resolve5(this.sessionsDir);
|
|
67145
67299
|
const dir = resolve5(root, sessionId);
|
|
67146
|
-
if (dir !==
|
|
67300
|
+
if (dir !== join48(root, sessionId))
|
|
67147
67301
|
return null;
|
|
67148
67302
|
if (!dir.startsWith(root + sep))
|
|
67149
67303
|
return null;
|
|
@@ -67162,10 +67316,10 @@ ${entry.blockText}` : ""}`;
|
|
|
67162
67316
|
} catch {
|
|
67163
67317
|
return null;
|
|
67164
67318
|
}
|
|
67165
|
-
const spawnRecord = readJsonObject(
|
|
67319
|
+
const spawnRecord = readJsonObject(join48(sessionDir, "spawn.json"), META_READ_LIMIT);
|
|
67166
67320
|
if (spawnRecord?.kind === "team")
|
|
67167
67321
|
return null;
|
|
67168
|
-
const meta = readJsonObject(
|
|
67322
|
+
const meta = readJsonObject(join48(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
67169
67323
|
if (meta?.kind === "team")
|
|
67170
67324
|
return null;
|
|
67171
67325
|
const partial = meta === null;
|
|
@@ -67187,7 +67341,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67187
67341
|
return stored;
|
|
67188
67342
|
}
|
|
67189
67343
|
diskOutput(record, tailLines) {
|
|
67190
|
-
const tail = readTailText(
|
|
67344
|
+
const tail = readTailText(join48(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
67191
67345
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
67192
67346
|
if (tail?.text)
|
|
67193
67347
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -67207,12 +67361,12 @@ ${entry.blockText}` : ""}`;
|
|
|
67207
67361
|
}
|
|
67208
67362
|
diskDiagnostics(record, limit) {
|
|
67209
67363
|
const { sessionDir, info } = record;
|
|
67210
|
-
const eventLogPath =
|
|
67211
|
-
const upstreamErrorLogPath =
|
|
67212
|
-
const outputLogPath =
|
|
67364
|
+
const eventLogPath = join48(sessionDir, "events.jsonl");
|
|
67365
|
+
const upstreamErrorLogPath = join48(sessionDir, "upstream-errors.jsonl");
|
|
67366
|
+
const outputLogPath = join48(sessionDir, "output.log");
|
|
67213
67367
|
const events = readTailLines(eventLogPath, EVENT_TAIL_BYTES);
|
|
67214
67368
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
67215
|
-
const screen = readTailText(
|
|
67369
|
+
const screen = readTailText(join48(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
|
|
67216
67370
|
return {
|
|
67217
67371
|
sessionId: info.sessionId,
|
|
67218
67372
|
state: info.state,
|
|
@@ -67240,6 +67394,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67240
67394
|
pane: info.pane,
|
|
67241
67395
|
sockPath: null,
|
|
67242
67396
|
magmuxStderr: "",
|
|
67397
|
+
registry: null,
|
|
67243
67398
|
captureSource: info.captureSource,
|
|
67244
67399
|
turnSource: info.turnSource,
|
|
67245
67400
|
preambleBytes: 0,
|
|
@@ -67280,15 +67435,17 @@ ${entry.blockText}` : ""}`;
|
|
|
67280
67435
|
entry.info.elapsedSeconds = elapsedSecondsBetween(entry.info.startedAt, Date.now());
|
|
67281
67436
|
}
|
|
67282
67437
|
appendAnswer(entry, index, answer) {
|
|
67283
|
-
|
|
67438
|
+
const prior = entry.answeredTurns.get(index);
|
|
67439
|
+
if (prior !== undefined && (answer.length <= prior.length || !answer.startsWith(prior)))
|
|
67284
67440
|
return;
|
|
67285
|
-
entry.answeredTurns.
|
|
67286
|
-
|
|
67441
|
+
entry.answeredTurns.set(index, answer);
|
|
67442
|
+
const added = prior === undefined ? answer : answer.slice(prior.length).replace(/^\n+/, "");
|
|
67443
|
+
if (!added)
|
|
67287
67444
|
return;
|
|
67288
|
-
const text =
|
|
67289
|
-
`) ?
|
|
67445
|
+
const text = added.endsWith(`
|
|
67446
|
+
`) ? added : `${added}
|
|
67290
67447
|
`;
|
|
67291
|
-
entry.proseBytes += Buffer.byteLength(
|
|
67448
|
+
entry.proseBytes += Buffer.byteLength(added, "utf-8");
|
|
67292
67449
|
this.appendToOutput(entry, text);
|
|
67293
67450
|
}
|
|
67294
67451
|
recordNote(entry, note) {
|
|
@@ -67568,14 +67725,14 @@ var init_progress_heartbeat = __esm(() => {
|
|
|
67568
67725
|
});
|
|
67569
67726
|
|
|
67570
67727
|
// src/mcp-server.ts
|
|
67571
|
-
import { existsSync as existsSync32, mkdirSync as mkdirSync21, readFileSync as
|
|
67728
|
+
import { existsSync as existsSync32, mkdirSync as mkdirSync21, readFileSync as readFileSync31, readdirSync as readdirSync10, writeFileSync as writeFileSync22 } from "fs";
|
|
67572
67729
|
import { homedir as homedir33 } from "os";
|
|
67573
|
-
import { dirname as dirname14, join as
|
|
67730
|
+
import { dirname as dirname14, join as join49, resolve as resolve6 } from "path";
|
|
67574
67731
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
67575
67732
|
async function loadAllModels(forceRefresh = false) {
|
|
67576
67733
|
if (!forceRefresh && existsSync32(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
67577
67734
|
try {
|
|
67578
|
-
const cacheData = JSON.parse(
|
|
67735
|
+
const cacheData = JSON.parse(readFileSync31(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
67579
67736
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
67580
67737
|
const ageInDays = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
67581
67738
|
if (ageInDays <= CACHE_MAX_AGE_DAYS) {
|
|
@@ -67594,7 +67751,7 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
67594
67751
|
return models;
|
|
67595
67752
|
} catch {
|
|
67596
67753
|
if (existsSync32(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
67597
|
-
const cacheData = JSON.parse(
|
|
67754
|
+
const cacheData = JSON.parse(readFileSync31(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
67598
67755
|
return cacheData.models || [];
|
|
67599
67756
|
}
|
|
67600
67757
|
return [];
|
|
@@ -68447,8 +68604,8 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68447
68604
|
const promptText = () => {
|
|
68448
68605
|
if (input !== undefined)
|
|
68449
68606
|
return input;
|
|
68450
|
-
const existing =
|
|
68451
|
-
return existsSync32(existing) ?
|
|
68607
|
+
const existing = join49(resolved, "input.md");
|
|
68608
|
+
return existsSync32(existing) ? readFileSync31(existing, "utf-8") : undefined;
|
|
68452
68609
|
};
|
|
68453
68610
|
switch (mode) {
|
|
68454
68611
|
case "run": {
|
|
@@ -68598,7 +68755,7 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68598
68755
|
let stderrFull = stderr_snippet || "";
|
|
68599
68756
|
if (error_log_path) {
|
|
68600
68757
|
try {
|
|
68601
|
-
stderrFull =
|
|
68758
|
+
stderrFull = readFileSync31(error_log_path, "utf-8");
|
|
68602
68759
|
} catch {}
|
|
68603
68760
|
}
|
|
68604
68761
|
const sessionData = {};
|
|
@@ -68606,26 +68763,26 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68606
68763
|
const sp = session_path;
|
|
68607
68764
|
for (const file of ["status.json", "manifest.json", "input.md"]) {
|
|
68608
68765
|
try {
|
|
68609
|
-
sessionData[file] =
|
|
68766
|
+
sessionData[file] = readFileSync31(join49(sp, file), "utf-8");
|
|
68610
68767
|
} catch {}
|
|
68611
68768
|
}
|
|
68612
68769
|
try {
|
|
68613
|
-
const errorDir =
|
|
68770
|
+
const errorDir = join49(sp, "errors");
|
|
68614
68771
|
if (existsSync32(errorDir)) {
|
|
68615
|
-
for (const f of
|
|
68772
|
+
for (const f of readdirSync10(errorDir)) {
|
|
68616
68773
|
if (f.endsWith(".log")) {
|
|
68617
68774
|
try {
|
|
68618
|
-
sessionData[`errors/${f}`] =
|
|
68775
|
+
sessionData[`errors/${f}`] = readFileSync31(join49(errorDir, f), "utf-8");
|
|
68619
68776
|
} catch {}
|
|
68620
68777
|
}
|
|
68621
68778
|
}
|
|
68622
68779
|
}
|
|
68623
68780
|
} catch {}
|
|
68624
68781
|
try {
|
|
68625
|
-
for (const f of
|
|
68782
|
+
for (const f of readdirSync10(sp)) {
|
|
68626
68783
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
68627
68784
|
try {
|
|
68628
|
-
const content =
|
|
68785
|
+
const content = readFileSync31(join49(sp, f), "utf-8");
|
|
68629
68786
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
68630
68787
|
} catch {}
|
|
68631
68788
|
}
|
|
@@ -68634,9 +68791,9 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68634
68791
|
}
|
|
68635
68792
|
let version = "unknown";
|
|
68636
68793
|
try {
|
|
68637
|
-
const pkgPath =
|
|
68794
|
+
const pkgPath = join49(__dirname3, "../package.json");
|
|
68638
68795
|
if (existsSync32(pkgPath)) {
|
|
68639
|
-
version = JSON.parse(
|
|
68796
|
+
version = JSON.parse(readFileSync31(pkgPath, "utf-8")).version;
|
|
68640
68797
|
}
|
|
68641
68798
|
} catch {}
|
|
68642
68799
|
const report = {
|
|
@@ -69173,8 +69330,8 @@ var init_mcp_server = __esm(() => {
|
|
|
69173
69330
|
import_dotenv2.config({ quiet: true });
|
|
69174
69331
|
__filename3 = fileURLToPath3(import.meta.url);
|
|
69175
69332
|
__dirname3 = dirname14(__filename3);
|
|
69176
|
-
CLAUDISH_CACHE_DIR =
|
|
69177
|
-
OPENROUTER_MODELS_CACHE_PATH =
|
|
69333
|
+
CLAUDISH_CACHE_DIR = join49(homedir33(), ".claudish");
|
|
69334
|
+
OPENROUTER_MODELS_CACHE_PATH = join49(CLAUDISH_CACHE_DIR, "openrouter-models.json");
|
|
69178
69335
|
NEXT_STEP = {
|
|
69179
69336
|
cancelled: "you stopped this slot; nothing is wrong with it. Re-run it if you still want its vote",
|
|
69180
69337
|
timeout: "grid mode only \u2014 magmux ended the pane. The orchestrator has no deadline",
|
|
@@ -69208,7 +69365,7 @@ var init_mcp_server = __esm(() => {
|
|
|
69208
69365
|
});
|
|
69209
69366
|
|
|
69210
69367
|
// src/serve-command.ts
|
|
69211
|
-
import { existsSync as existsSync33, readFileSync as
|
|
69368
|
+
import { existsSync as existsSync33, readFileSync as readFileSync32 } from "fs";
|
|
69212
69369
|
function parseServeArgs(args) {
|
|
69213
69370
|
const out = {};
|
|
69214
69371
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -69232,7 +69389,7 @@ function loadModelMap(path) {
|
|
|
69232
69389
|
}
|
|
69233
69390
|
let raw;
|
|
69234
69391
|
try {
|
|
69235
|
-
raw =
|
|
69392
|
+
raw = readFileSync32(path, "utf-8");
|
|
69236
69393
|
} catch (e) {
|
|
69237
69394
|
throw new Error(`failed to read --models file ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
69238
69395
|
}
|
|
@@ -69307,7 +69464,7 @@ var init_serve_command = __esm(() => {
|
|
|
69307
69464
|
});
|
|
69308
69465
|
|
|
69309
69466
|
// src/behavior-command.ts
|
|
69310
|
-
import { existsSync as existsSync34, readFileSync as
|
|
69467
|
+
import { existsSync as existsSync34, readFileSync as readFileSync33, writeFileSync as writeFileSync23 } from "fs";
|
|
69311
69468
|
function severityColor(sev) {
|
|
69312
69469
|
if (sev === "fix")
|
|
69313
69470
|
return green(sev);
|
|
@@ -69406,7 +69563,7 @@ function setTelemetryEnabled(value) {
|
|
|
69406
69563
|
let cfg = {};
|
|
69407
69564
|
try {
|
|
69408
69565
|
if (existsSync34(path)) {
|
|
69409
|
-
const parsed = JSON.parse(
|
|
69566
|
+
const parsed = JSON.parse(readFileSync33(path, "utf-8"));
|
|
69410
69567
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
69411
69568
|
cfg = parsed;
|
|
69412
69569
|
}
|
|
@@ -69428,7 +69585,7 @@ function showTelemetry(action, json) {
|
|
|
69428
69585
|
try {
|
|
69429
69586
|
const path = outboxPath();
|
|
69430
69587
|
if (existsSync34(path)) {
|
|
69431
|
-
pending =
|
|
69588
|
+
pending = readFileSync33(path, "utf8").split(`
|
|
69432
69589
|
`).filter(Boolean).length;
|
|
69433
69590
|
}
|
|
69434
69591
|
} catch {}
|
|
@@ -69508,9 +69665,9 @@ var init_behavior_command = __esm(() => {
|
|
|
69508
69665
|
|
|
69509
69666
|
// src/team-grid.ts
|
|
69510
69667
|
import { spawn as spawn2 } from "child_process";
|
|
69511
|
-
import { existsSync as existsSync35, readFileSync as
|
|
69668
|
+
import { existsSync as existsSync35, readFileSync as readFileSync34, writeFileSync as writeFileSync24 } from "fs";
|
|
69512
69669
|
import { connect as netConnect2 } from "net";
|
|
69513
|
-
import { join as
|
|
69670
|
+
import { join as join50 } from "path";
|
|
69514
69671
|
import { setTimeout as wait } from "timers/promises";
|
|
69515
69672
|
function paneRouteLine(explanation) {
|
|
69516
69673
|
const origin = describeRouteExplanation(explanation);
|
|
@@ -69660,9 +69817,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69660
69817
|
const keep = opts?.keep ?? false;
|
|
69661
69818
|
const manifest = setupSession(sessionPath, models, input);
|
|
69662
69819
|
const startedAt = new Date().toISOString();
|
|
69663
|
-
const gridfilePath =
|
|
69664
|
-
const prompt =
|
|
69665
|
-
const rawPrompt =
|
|
69820
|
+
const gridfilePath = join50(sessionPath, "gridfile.txt");
|
|
69821
|
+
const prompt = readFileSync34(join50(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
|
|
69822
|
+
const rawPrompt = readFileSync34(join50(sessionPath, "input.md"), "utf-8");
|
|
69666
69823
|
const usedBannerColors = new Set;
|
|
69667
69824
|
const routeLines = mode === "interactive" ? new Map : await resolvePaneRouteLines(Object.values(manifest.models).map((entry) => entry.model));
|
|
69668
69825
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
@@ -69694,7 +69851,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69694
69851
|
});
|
|
69695
69852
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
69696
69853
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
69697
|
-
const statusPath =
|
|
69854
|
+
const statusPath = join50(sessionPath, "status.json");
|
|
69698
69855
|
writeFileSync24(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
69699
69856
|
return status;
|
|
69700
69857
|
}
|
|
@@ -69714,8 +69871,8 @@ var init_team_grid = __esm(() => {
|
|
|
69714
69871
|
});
|
|
69715
69872
|
|
|
69716
69873
|
// src/team-cli.ts
|
|
69717
|
-
import { readFileSync as
|
|
69718
|
-
import { join as
|
|
69874
|
+
import { readFileSync as readFileSync35 } from "fs";
|
|
69875
|
+
import { join as join51 } from "path";
|
|
69719
69876
|
async function runPaneTeam(sessionPath, models, input, opts) {
|
|
69720
69877
|
installPaneShutdownHooks({ exitAfter: true });
|
|
69721
69878
|
try {
|
|
@@ -69851,7 +70008,7 @@ async function teamCommand(args) {
|
|
|
69851
70008
|
}
|
|
69852
70009
|
case "judge": {
|
|
69853
70010
|
await judgeResponses(sessionPath, { judges });
|
|
69854
|
-
console.log(
|
|
70011
|
+
console.log(readFileSync35(join51(sessionPath, "verdict.md"), "utf-8"));
|
|
69855
70012
|
break;
|
|
69856
70013
|
}
|
|
69857
70014
|
case "run-and-judge": {
|
|
@@ -69867,7 +70024,7 @@ async function teamCommand(args) {
|
|
|
69867
70024
|
});
|
|
69868
70025
|
printStatus(status);
|
|
69869
70026
|
await judgeResponses(sessionPath, { judges });
|
|
69870
|
-
console.log(
|
|
70027
|
+
console.log(readFileSync35(join51(sessionPath, "verdict.md"), "utf-8"));
|
|
69871
70028
|
break;
|
|
69872
70029
|
}
|
|
69873
70030
|
case "status": {
|
|
@@ -70440,7 +70597,7 @@ var init_keychain_command = __esm(() => {
|
|
|
70440
70597
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
70441
70598
|
import { existsSync as existsSync36, unlinkSync as unlinkSync9 } from "fs";
|
|
70442
70599
|
import { homedir as homedir34 } from "os";
|
|
70443
|
-
import { join as
|
|
70600
|
+
import { join as join52 } from "path";
|
|
70444
70601
|
async function defaultSuggestModel() {
|
|
70445
70602
|
try {
|
|
70446
70603
|
const tok = readSharedAntigravityToken();
|
|
@@ -70561,7 +70718,7 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
70561
70718
|
async logout(deps) {
|
|
70562
70719
|
deleteSharedAntigravityToken(deps);
|
|
70563
70720
|
try {
|
|
70564
|
-
const tokenFile =
|
|
70721
|
+
const tokenFile = join52(homedir34(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
70565
70722
|
if (existsSync36(tokenFile))
|
|
70566
70723
|
unlinkSync9(tokenFile);
|
|
70567
70724
|
} catch {}
|
|
@@ -78814,14 +78971,14 @@ import {
|
|
|
78814
78971
|
existsSync as existsSync38,
|
|
78815
78972
|
mkdirSync as mkdirSync22,
|
|
78816
78973
|
openSync as openSync10,
|
|
78817
|
-
readFileSync as
|
|
78818
|
-
readdirSync as
|
|
78974
|
+
readFileSync as readFileSync36,
|
|
78975
|
+
readdirSync as readdirSync11,
|
|
78819
78976
|
statSync as statSync12,
|
|
78820
78977
|
unlinkSync as unlinkSync10,
|
|
78821
78978
|
writeFileSync as writeFileSync25
|
|
78822
78979
|
} from "fs";
|
|
78823
78980
|
import { homedir as homedir35, tmpdir as tmpdir2 } from "os";
|
|
78824
|
-
import { dirname as dirname15, join as
|
|
78981
|
+
import { dirname as dirname15, join as join53 } from "path";
|
|
78825
78982
|
import { isatty } from "tty";
|
|
78826
78983
|
function releaseTerminalIsolation() {
|
|
78827
78984
|
if (!restoreTerminal)
|
|
@@ -78886,7 +79043,7 @@ function hasResolvableAnthropicAuth(deps = {}) {
|
|
|
78886
79043
|
if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") || isRealAnthropicEnvCredential(env, "ANTHROPIC_AUTH_TOKEN")) {
|
|
78887
79044
|
return true;
|
|
78888
79045
|
}
|
|
78889
|
-
if (fileExists(
|
|
79046
|
+
if (fileExists(join53(homedir35(), ".claude", ".credentials.json")))
|
|
78890
79047
|
return true;
|
|
78891
79048
|
return keychainProbe();
|
|
78892
79049
|
}
|
|
@@ -78901,14 +79058,14 @@ function isProxyAuthMode(config) {
|
|
|
78901
79058
|
}
|
|
78902
79059
|
function managedSettingsPath() {
|
|
78903
79060
|
if (isWindows2()) {
|
|
78904
|
-
return
|
|
79061
|
+
return join53(process.env.PROGRAMDATA || "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
78905
79062
|
}
|
|
78906
79063
|
if (process.platform === "darwin") {
|
|
78907
79064
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
78908
79065
|
}
|
|
78909
79066
|
return "/etc/claude-code/managed-settings.json";
|
|
78910
79067
|
}
|
|
78911
|
-
function managedSettingsForcesClaudeAi(readFile =
|
|
79068
|
+
function managedSettingsForcesClaudeAi(readFile = readFileSync36) {
|
|
78912
79069
|
try {
|
|
78913
79070
|
const raw = readFile(managedSettingsPath(), "utf-8");
|
|
78914
79071
|
const parsed = JSON.parse(raw);
|
|
@@ -78922,9 +79079,9 @@ function isWindows2() {
|
|
|
78922
79079
|
}
|
|
78923
79080
|
function createStatusLineScript(tokenFilePath) {
|
|
78924
79081
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
78925
|
-
const claudishDir =
|
|
79082
|
+
const claudishDir = join53(homeDir, ".claudish");
|
|
78926
79083
|
const timestamp = Date.now();
|
|
78927
|
-
const scriptPath =
|
|
79084
|
+
const scriptPath = join53(claudishDir, `status-${timestamp}.js`);
|
|
78928
79085
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
78929
79086
|
const light = getThemeMode() === "light";
|
|
78930
79087
|
const cyanCode = light ? "38;2;14;116;144" : "96";
|
|
@@ -79082,7 +79239,7 @@ function cleanupStaleTokenFiles(dir, now = Date.now(), maxAgeMs = STALE_TOKEN_FI
|
|
|
79082
79239
|
let removed = 0;
|
|
79083
79240
|
let entries;
|
|
79084
79241
|
try {
|
|
79085
|
-
entries =
|
|
79242
|
+
entries = readdirSync11(dir);
|
|
79086
79243
|
} catch {
|
|
79087
79244
|
return 0;
|
|
79088
79245
|
}
|
|
@@ -79094,7 +79251,7 @@ function cleanupStaleTokenFiles(dir, now = Date.now(), maxAgeMs = STALE_TOKEN_FI
|
|
|
79094
79251
|
if (!name.startsWith("tokens-") || !name.endsWith(".json"))
|
|
79095
79252
|
continue;
|
|
79096
79253
|
scanned++;
|
|
79097
|
-
const full =
|
|
79254
|
+
const full = join53(dir, name);
|
|
79098
79255
|
try {
|
|
79099
79256
|
if (statSync12(full).mtimeMs >= cutoff)
|
|
79100
79257
|
continue;
|
|
@@ -79111,7 +79268,7 @@ function parseSettingsArg(value) {
|
|
|
79111
79268
|
if (value.trimStart().startsWith("{")) {
|
|
79112
79269
|
return JSON.parse(value);
|
|
79113
79270
|
}
|
|
79114
|
-
return JSON.parse(
|
|
79271
|
+
return JSON.parse(readFileSync36(value, "utf-8"));
|
|
79115
79272
|
}
|
|
79116
79273
|
function parseSettingsArgSafe(value) {
|
|
79117
79274
|
try {
|
|
@@ -79123,9 +79280,9 @@ function parseSettingsArgSafe(value) {
|
|
|
79123
79280
|
}
|
|
79124
79281
|
function userSettingsFileCandidates(cwd) {
|
|
79125
79282
|
return [
|
|
79126
|
-
|
|
79127
|
-
|
|
79128
|
-
|
|
79283
|
+
join53(homedir35(), ".claude", "settings.json"),
|
|
79284
|
+
join53(cwd, ".claude", "settings.json"),
|
|
79285
|
+
join53(cwd, ".claude", "settings.local.json")
|
|
79129
79286
|
];
|
|
79130
79287
|
}
|
|
79131
79288
|
function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd()) {
|
|
@@ -79166,12 +79323,12 @@ function buildChainedStatusCommand(userCommand, claudishBody, claudishSegment) {
|
|
|
79166
79323
|
}
|
|
79167
79324
|
function createTempSettingsFile(_modelDisplay, port, proxyAuthMode, userStatusLineCommand) {
|
|
79168
79325
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
79169
|
-
const claudishDir =
|
|
79326
|
+
const claudishDir = join53(homeDir, ".claudish");
|
|
79170
79327
|
try {
|
|
79171
79328
|
mkdirSync22(claudishDir, { recursive: true });
|
|
79172
79329
|
} catch {}
|
|
79173
79330
|
const timestamp = Date.now();
|
|
79174
|
-
const tempPath =
|
|
79331
|
+
const tempPath = join53(claudishDir, `settings-${timestamp}.json`);
|
|
79175
79332
|
const assignedFile = assignedTokenFile(process.env) !== null;
|
|
79176
79333
|
const tokenFilePath = resolveTokenFilePath(port);
|
|
79177
79334
|
cleanupStaleTokenFiles(claudishDir);
|
|
@@ -79546,7 +79703,7 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup) {
|
|
|
79546
79703
|
console.error(`
|
|
79547
79704
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
79548
79705
|
const home = homedir35();
|
|
79549
|
-
const localPath = isWindows2() ?
|
|
79706
|
+
const localPath = isWindows2() ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
79550
79707
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
79551
79708
|
process.exit(1);
|
|
79552
79709
|
}
|
|
@@ -79659,15 +79816,15 @@ async function findClaudeBinary() {
|
|
|
79659
79816
|
}
|
|
79660
79817
|
}
|
|
79661
79818
|
const home = homedir35();
|
|
79662
|
-
const localPath = isWindows ?
|
|
79819
|
+
const localPath = isWindows ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
79663
79820
|
if (existsSync38(localPath)) {
|
|
79664
79821
|
return localPath;
|
|
79665
79822
|
}
|
|
79666
79823
|
if (isWindows) {
|
|
79667
79824
|
const windowsPaths = [
|
|
79668
|
-
|
|
79669
|
-
|
|
79670
|
-
|
|
79825
|
+
join53(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
79826
|
+
join53(home, ".npm-global", "claude.cmd"),
|
|
79827
|
+
join53(home, "node_modules", ".bin", "claude.cmd")
|
|
79671
79828
|
];
|
|
79672
79829
|
for (const path of windowsPaths) {
|
|
79673
79830
|
if (existsSync38(path)) {
|
|
@@ -79678,11 +79835,11 @@ async function findClaudeBinary() {
|
|
|
79678
79835
|
const commonPaths = [
|
|
79679
79836
|
"/usr/local/bin/claude",
|
|
79680
79837
|
"/opt/homebrew/bin/claude",
|
|
79681
|
-
|
|
79682
|
-
|
|
79683
|
-
|
|
79838
|
+
join53(home, ".npm-global/bin/claude"),
|
|
79839
|
+
join53(home, ".local/bin/claude"),
|
|
79840
|
+
join53(home, "node_modules/.bin/claude"),
|
|
79684
79841
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
79685
|
-
|
|
79842
|
+
join53(home, "../usr/bin/claude")
|
|
79686
79843
|
];
|
|
79687
79844
|
for (const path of commonPaths) {
|
|
79688
79845
|
if (existsSync38(path)) {
|
|
@@ -79767,16 +79924,16 @@ var init_claude_runner = __esm(() => {
|
|
|
79767
79924
|
// src/diag-output.ts
|
|
79768
79925
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync23, unlinkSync as unlinkSync11, writeFileSync as writeFileSync26 } from "fs";
|
|
79769
79926
|
import { homedir as homedir36 } from "os";
|
|
79770
|
-
import { join as
|
|
79927
|
+
import { join as join54 } from "path";
|
|
79771
79928
|
function getClaudishDir() {
|
|
79772
|
-
const dir =
|
|
79929
|
+
const dir = join54(homedir36(), ".claudish");
|
|
79773
79930
|
try {
|
|
79774
79931
|
mkdirSync23(dir, { recursive: true });
|
|
79775
79932
|
} catch {}
|
|
79776
79933
|
return dir;
|
|
79777
79934
|
}
|
|
79778
79935
|
function getDiagLogPath() {
|
|
79779
|
-
return
|
|
79936
|
+
return join54(getClaudishDir(), `diag-${process.pid}.log`);
|
|
79780
79937
|
}
|
|
79781
79938
|
|
|
79782
79939
|
class LogFileDiagOutput {
|
|
@@ -81980,11 +82137,11 @@ var exports_session_stats = {};
|
|
|
81980
82137
|
__export(exports_session_stats, {
|
|
81981
82138
|
readSessionStats: () => readSessionStats
|
|
81982
82139
|
});
|
|
81983
|
-
import { readFileSync as
|
|
82140
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
81984
82141
|
function readSessionStats(port, opts) {
|
|
81985
82142
|
let raw;
|
|
81986
82143
|
try {
|
|
81987
|
-
raw = JSON.parse(
|
|
82144
|
+
raw = JSON.parse(readFileSync37(resolveTokenFilePath(port), "utf-8"));
|
|
81988
82145
|
} catch {
|
|
81989
82146
|
return null;
|
|
81990
82147
|
}
|
|
@@ -82344,8 +82501,8 @@ init_op_source();
|
|
|
82344
82501
|
init_startup_trace();
|
|
82345
82502
|
init_picker_cancelled();
|
|
82346
82503
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
82347
|
-
import { existsSync as existsSync39, readFileSync as
|
|
82348
|
-
import { join as
|
|
82504
|
+
import { existsSync as existsSync39, readFileSync as readFileSync38 } from "fs";
|
|
82505
|
+
import { join as join55, resolve as resolve7 } from "path";
|
|
82349
82506
|
|
|
82350
82507
|
// src/tui/runtime/should-open-picker.ts
|
|
82351
82508
|
function noModelConfigured(gate) {
|
|
@@ -82645,14 +82802,14 @@ async function runCli() {
|
|
|
82645
82802
|
if (cliConfig.team && cliConfig.team.length > 0) {
|
|
82646
82803
|
let prompt = cliConfig.claudeArgs.join(" ");
|
|
82647
82804
|
if (cliConfig.inputFile) {
|
|
82648
|
-
prompt =
|
|
82805
|
+
prompt = readFileSync38(cliConfig.inputFile, "utf-8");
|
|
82649
82806
|
}
|
|
82650
82807
|
if (!prompt.trim()) {
|
|
82651
82808
|
console.error("Error: --team requires a prompt (positional args or -f <file>)");
|
|
82652
82809
|
process.exit(1);
|
|
82653
82810
|
}
|
|
82654
82811
|
const mode = cliConfig.teamMode ?? "default";
|
|
82655
|
-
const sessionPath =
|
|
82812
|
+
const sessionPath = join55(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
82656
82813
|
if (mode === "json") {
|
|
82657
82814
|
await Promise.resolve().then(() => init_pane());
|
|
82658
82815
|
await Promise.resolve().then(() => init_team_orchestrator());
|
|
@@ -82672,9 +82829,9 @@ async function runCli() {
|
|
|
82672
82829
|
const status = await runModels(sessionPath);
|
|
82673
82830
|
const result = { ...status, responses: {} };
|
|
82674
82831
|
for (const anonId of Object.keys(status.models)) {
|
|
82675
|
-
const responsePath =
|
|
82832
|
+
const responsePath = join55(sessionPath, `response-${anonId}.md`);
|
|
82676
82833
|
try {
|
|
82677
|
-
const raw =
|
|
82834
|
+
const raw = readFileSync38(responsePath, "utf-8").trim();
|
|
82678
82835
|
try {
|
|
82679
82836
|
result.responses[anonId] = JSON.parse(raw);
|
|
82680
82837
|
} catch {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudish",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.5.0",
|
|
4
4
|
"description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"ai"
|
|
61
61
|
],
|
|
62
62
|
"optionalDependencies": {
|
|
63
|
-
"@claudish/magmux-darwin-arm64": "10.
|
|
64
|
-
"@claudish/magmux-darwin-x64": "10.
|
|
65
|
-
"@claudish/magmux-linux-arm64": "10.
|
|
66
|
-
"@claudish/magmux-linux-x64": "10.
|
|
63
|
+
"@claudish/magmux-darwin-arm64": "10.5.0",
|
|
64
|
+
"@claudish/magmux-darwin-x64": "10.5.0",
|
|
65
|
+
"@claudish/magmux-linux-arm64": "10.5.0",
|
|
66
|
+
"@claudish/magmux-linux-x64": "10.5.0"
|
|
67
67
|
},
|
|
68
68
|
"author": "Jack Rudenko <i@madappgang.com>",
|
|
69
69
|
"license": "MIT",
|