claudish 10.4.0 → 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/bin/claudish.cjs +1 -1
- package/dist/index.js +451 -474
- 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";
|
|
@@ -32422,66 +32422,6 @@ function sessionsDirFrom(env, homedirFn = homedir23) {
|
|
|
32422
32422
|
return explicit;
|
|
32423
32423
|
return join23(userHomeFrom(env, homedirFn), ".claudish", "sessions");
|
|
32424
32424
|
}
|
|
32425
|
-
var init_home_dir = () => {};
|
|
32426
|
-
|
|
32427
|
-
// src/channel/parent-proof.ts
|
|
32428
|
-
import * as fsPromises from "fs/promises";
|
|
32429
|
-
import { join as join24 } from "path";
|
|
32430
|
-
function positiveInt(value) {
|
|
32431
|
-
if (value === undefined || !/^[1-9][0-9]*$/.test(value))
|
|
32432
|
-
return;
|
|
32433
|
-
const n = Number(value);
|
|
32434
|
-
return Number.isSafeInteger(n) ? n : undefined;
|
|
32435
|
-
}
|
|
32436
|
-
function hostPidFrom(env, ppid) {
|
|
32437
|
-
const launcherPpid = positiveInt(env.CLAUDISH_LAUNCHER_PPID);
|
|
32438
|
-
if (env.CLAUDISH_LAUNCHER_PID === String(ppid) && launcherPpid !== undefined && launcherPpid !== ppid) {
|
|
32439
|
-
return { hostPid: launcherPpid, launcherPid: ppid };
|
|
32440
|
-
}
|
|
32441
|
-
return { hostPid: ppid };
|
|
32442
|
-
}
|
|
32443
|
-
function parentSessionIdFrom(env) {
|
|
32444
|
-
const id = env.CLAUDE_CODE_SESSION_ID;
|
|
32445
|
-
if (id === undefined || !CLAUDE_ID_RE.test(id))
|
|
32446
|
-
return;
|
|
32447
|
-
if (env.CLAUDE_CODE_CHILD_SESSION)
|
|
32448
|
-
return;
|
|
32449
|
-
return id;
|
|
32450
|
-
}
|
|
32451
|
-
function claudeConfigDir(env) {
|
|
32452
|
-
const fromEnv = env.CLAUDE_CONFIG_DIR;
|
|
32453
|
-
return fromEnv && fromEnv.length > 0 ? fromEnv : join24(userHomeFrom(env), ".claude");
|
|
32454
|
-
}
|
|
32455
|
-
async function readHostSessionRecord(opts) {
|
|
32456
|
-
const fs = opts.fs ?? defaultFs;
|
|
32457
|
-
try {
|
|
32458
|
-
const raw = await fs.readFile(join24(opts.configDir, "sessions", `${opts.hostPid}.json`), "utf-8");
|
|
32459
|
-
const parsed = JSON.parse(raw);
|
|
32460
|
-
if (!parsed || typeof parsed !== "object")
|
|
32461
|
-
return;
|
|
32462
|
-
const rec = parsed;
|
|
32463
|
-
if (rec.pid !== opts.hostPid)
|
|
32464
|
-
return;
|
|
32465
|
-
if (typeof rec.sessionId !== "string" || !CLAUDE_ID_RE.test(rec.sessionId))
|
|
32466
|
-
return;
|
|
32467
|
-
return {
|
|
32468
|
-
sessionId: rec.sessionId,
|
|
32469
|
-
...typeof rec.cwd === "string" && rec.cwd.length > 0 ? { cwd: rec.cwd } : {}
|
|
32470
|
-
};
|
|
32471
|
-
} catch {
|
|
32472
|
-
return;
|
|
32473
|
-
}
|
|
32474
|
-
}
|
|
32475
|
-
async function gatherProofCandidates(opts) {
|
|
32476
|
-
const record = await readHostSessionRecord({
|
|
32477
|
-
configDir: opts.configDir,
|
|
32478
|
-
hostPid: opts.hostPid,
|
|
32479
|
-
fs: opts.fs
|
|
32480
|
-
});
|
|
32481
|
-
const cwd = record?.cwd;
|
|
32482
|
-
const ids = [parentSessionIdFrom(opts.env), record?.sessionId].filter((id) => id !== undefined);
|
|
32483
|
-
return [...new Set(ids)].map((sessionId) => ({ sessionId, ...cwd ? { cwd } : {} }));
|
|
32484
|
-
}
|
|
32485
32425
|
function claudeCodeStringHash(s) {
|
|
32486
32426
|
let h = 0;
|
|
32487
32427
|
for (let i = 0;i < s.length; i++)
|
|
@@ -32494,183 +32434,8 @@ function projectDirNameFor(cwd) {
|
|
|
32494
32434
|
return slug;
|
|
32495
32435
|
return `${slug.slice(0, PROJECT_DIR_SLUG_MAX)}-${Math.abs(claudeCodeStringHash(cwd)).toString(36)}`;
|
|
32496
32436
|
}
|
|
32497
|
-
|
|
32498
|
-
|
|
32499
|
-
return (await fs.stat(path)).isFile();
|
|
32500
|
-
} catch {
|
|
32501
|
-
return false;
|
|
32502
|
-
}
|
|
32503
|
-
}
|
|
32504
|
-
async function findProjectDir(fs, configDir, candidate, cache) {
|
|
32505
|
-
const cacheKey = `${configDir}\x00${candidate.sessionId}`;
|
|
32506
|
-
const projectsDir = join24(configDir, "projects");
|
|
32507
|
-
const fileName = `${candidate.sessionId}.jsonl`;
|
|
32508
|
-
const cached = cache.get(cacheKey);
|
|
32509
|
-
if (cached !== undefined) {
|
|
32510
|
-
if (await isTranscriptFile(fs, join24(cached, fileName)))
|
|
32511
|
-
return cached;
|
|
32512
|
-
cache.delete(cacheKey);
|
|
32513
|
-
}
|
|
32514
|
-
if (candidate.cwd) {
|
|
32515
|
-
const fast = join24(projectsDir, projectDirNameFor(candidate.cwd));
|
|
32516
|
-
if (await isTranscriptFile(fs, join24(fast, fileName)))
|
|
32517
|
-
return fast;
|
|
32518
|
-
}
|
|
32519
|
-
let names;
|
|
32520
|
-
try {
|
|
32521
|
-
names = await fs.readdir(projectsDir);
|
|
32522
|
-
} catch {
|
|
32523
|
-
return;
|
|
32524
|
-
}
|
|
32525
|
-
for (const name of names) {
|
|
32526
|
-
const dir = join24(projectsDir, name);
|
|
32527
|
-
if (await isTranscriptFile(fs, join24(dir, fileName))) {
|
|
32528
|
-
cache.set(cacheKey, dir);
|
|
32529
|
-
return dir;
|
|
32530
|
-
}
|
|
32531
|
-
}
|
|
32532
|
-
return;
|
|
32533
|
-
}
|
|
32534
|
-
async function tailContains(fs, path, needle) {
|
|
32535
|
-
let handle;
|
|
32536
|
-
try {
|
|
32537
|
-
const { size } = await fs.stat(path);
|
|
32538
|
-
const length = Math.min(size, TRANSCRIPT_TAIL_BYTES);
|
|
32539
|
-
if (length < needle.length)
|
|
32540
|
-
return false;
|
|
32541
|
-
const buffer = Buffer.alloc(length);
|
|
32542
|
-
handle = await fs.open(path, "r");
|
|
32543
|
-
const { bytesRead } = await handle.read(buffer, 0, length, size - length);
|
|
32544
|
-
return buffer.subarray(0, bytesRead).includes(needle);
|
|
32545
|
-
} catch {
|
|
32546
|
-
return false;
|
|
32547
|
-
} finally {
|
|
32548
|
-
await handle?.close().catch(() => {});
|
|
32549
|
-
}
|
|
32550
|
-
}
|
|
32551
|
-
async function recentSubagentTranscripts(fs, projectDir, candidateId, nowMs) {
|
|
32552
|
-
const dir = join24(projectDir, candidateId, "subagents");
|
|
32553
|
-
let names;
|
|
32554
|
-
try {
|
|
32555
|
-
names = await fs.readdir(dir);
|
|
32556
|
-
} catch {
|
|
32557
|
-
return [];
|
|
32558
|
-
}
|
|
32559
|
-
const recent = [];
|
|
32560
|
-
for (const name of names) {
|
|
32561
|
-
if (!name.endsWith(".jsonl"))
|
|
32562
|
-
continue;
|
|
32563
|
-
const path = join24(dir, name);
|
|
32564
|
-
try {
|
|
32565
|
-
const { mtimeMs } = await fs.stat(path);
|
|
32566
|
-
if (nowMs - mtimeMs <= SUBAGENT_WINDOW_MS)
|
|
32567
|
-
recent.push({ path, mtimeMs });
|
|
32568
|
-
} catch {}
|
|
32569
|
-
}
|
|
32570
|
-
recent.sort((a, b) => b.mtimeMs - a.mtimeMs);
|
|
32571
|
-
return recent.slice(0, MAX_SUBAGENT_FILES).map((f) => f.path);
|
|
32572
|
-
}
|
|
32573
|
-
async function candidateHolds(fs, configDir, candidate, needle, nowMs, cache) {
|
|
32574
|
-
const projectDir = await findProjectDir(fs, configDir, candidate, cache);
|
|
32575
|
-
if (projectDir === undefined)
|
|
32576
|
-
return false;
|
|
32577
|
-
if (await tailContains(fs, join24(projectDir, `${candidate.sessionId}.jsonl`), needle)) {
|
|
32578
|
-
return true;
|
|
32579
|
-
}
|
|
32580
|
-
for (const path of await recentSubagentTranscripts(fs, projectDir, candidate.sessionId, nowMs)) {
|
|
32581
|
-
if (await tailContains(fs, path, needle))
|
|
32582
|
-
return true;
|
|
32583
|
-
}
|
|
32584
|
-
return false;
|
|
32585
|
-
}
|
|
32586
|
-
async function proveCallingConversation(opts) {
|
|
32587
|
-
const { toolUseId } = opts;
|
|
32588
|
-
if (typeof toolUseId !== "string" || !CLAUDE_ID_RE.test(toolUseId))
|
|
32589
|
-
return;
|
|
32590
|
-
const candidates = normaliseCandidates(opts.candidates);
|
|
32591
|
-
if (candidates.length === 0)
|
|
32592
|
-
return;
|
|
32593
|
-
const fs = opts.fs ?? defaultFs;
|
|
32594
|
-
const now = opts.now ?? Date.now;
|
|
32595
|
-
const sleep = opts.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
32596
|
-
const cache = opts.cache ?? serverProjectDirCache;
|
|
32597
|
-
const needle = Buffer.from(`"${toolUseId}"`, "utf-8");
|
|
32598
|
-
const look = async () => {
|
|
32599
|
-
for (const candidate of candidates) {
|
|
32600
|
-
if (await candidateHolds(fs, opts.configDir, candidate, needle, now(), cache)) {
|
|
32601
|
-
return candidate.sessionId;
|
|
32602
|
-
}
|
|
32603
|
-
}
|
|
32604
|
-
return;
|
|
32605
|
-
};
|
|
32606
|
-
try {
|
|
32607
|
-
const startedAt = now();
|
|
32608
|
-
let slept = 0;
|
|
32609
|
-
for (;; ) {
|
|
32610
|
-
const found = await look();
|
|
32611
|
-
if (found !== undefined)
|
|
32612
|
-
return found;
|
|
32613
|
-
const remaining = PROOF_DEADLINE_MS - Math.max(now() - startedAt, slept);
|
|
32614
|
-
if (remaining <= 0)
|
|
32615
|
-
return;
|
|
32616
|
-
const wait = Math.min(PROOF_POLL_INTERVAL_MS, remaining);
|
|
32617
|
-
await sleep(wait);
|
|
32618
|
-
slept += wait;
|
|
32619
|
-
}
|
|
32620
|
-
} catch {
|
|
32621
|
-
return;
|
|
32622
|
-
}
|
|
32623
|
-
}
|
|
32624
|
-
function normaliseCandidates(raw) {
|
|
32625
|
-
const out = [];
|
|
32626
|
-
for (const entry of raw) {
|
|
32627
|
-
const candidate = typeof entry === "string" ? { sessionId: entry } : entry;
|
|
32628
|
-
if (!CLAUDE_ID_RE.test(candidate.sessionId))
|
|
32629
|
-
continue;
|
|
32630
|
-
if (out.some((c) => c.sessionId === candidate.sessionId))
|
|
32631
|
-
continue;
|
|
32632
|
-
out.push(candidate);
|
|
32633
|
-
if (out.length === 2)
|
|
32634
|
-
break;
|
|
32635
|
-
}
|
|
32636
|
-
return out;
|
|
32637
|
-
}
|
|
32638
|
-
async function proveParentForCall(opts) {
|
|
32639
|
-
if (typeof opts.toolUseId !== "string" || !CLAUDE_ID_RE.test(opts.toolUseId))
|
|
32640
|
-
return;
|
|
32641
|
-
const env = opts.env ?? process.env;
|
|
32642
|
-
const configDir = claudeConfigDir(env);
|
|
32643
|
-
try {
|
|
32644
|
-
const candidates = await gatherProofCandidates({
|
|
32645
|
-
env,
|
|
32646
|
-
hostPid: opts.hostPid,
|
|
32647
|
-
configDir,
|
|
32648
|
-
fs: opts.fs
|
|
32649
|
-
});
|
|
32650
|
-
return await proveCallingConversation({
|
|
32651
|
-
toolUseId: opts.toolUseId,
|
|
32652
|
-
candidates,
|
|
32653
|
-
configDir,
|
|
32654
|
-
fs: opts.fs
|
|
32655
|
-
});
|
|
32656
|
-
} catch {
|
|
32657
|
-
return;
|
|
32658
|
-
}
|
|
32659
|
-
}
|
|
32660
|
-
var CLAUDE_ID_RE, TOOL_USE_ID_META_KEY = "claudecode/toolUseId", TRANSCRIPT_TAIL_BYTES, SUBAGENT_WINDOW_MS, MAX_SUBAGENT_FILES = 32, PROOF_POLL_INTERVAL_MS = 100, PROOF_DEADLINE_MS = 2000, defaultFs, PROJECT_DIR_SLUG_MAX = 200, serverProjectDirCache;
|
|
32661
|
-
var init_parent_proof = __esm(() => {
|
|
32662
|
-
init_home_dir();
|
|
32663
|
-
CLAUDE_ID_RE = /^[A-Za-z0-9_-]{8,128}$/;
|
|
32664
|
-
TRANSCRIPT_TAIL_BYTES = 256 * 1024;
|
|
32665
|
-
SUBAGENT_WINDOW_MS = 10 * 60000;
|
|
32666
|
-
defaultFs = {
|
|
32667
|
-
readFile: (path, encoding) => fsPromises.readFile(path, encoding),
|
|
32668
|
-
readdir: (path) => fsPromises.readdir(path),
|
|
32669
|
-
stat: (path) => fsPromises.stat(path),
|
|
32670
|
-
open: (path, flags) => fsPromises.open(path, flags)
|
|
32671
|
-
};
|
|
32672
|
-
serverProjectDirCache = new Map;
|
|
32673
|
-
});
|
|
32437
|
+
var PROJECT_DIR_SLUG_MAX = 200;
|
|
32438
|
+
var init_home_dir = () => {};
|
|
32674
32439
|
|
|
32675
32440
|
// src/session-events/event-translator.ts
|
|
32676
32441
|
function translateLine(line) {
|
|
@@ -32830,7 +32595,7 @@ var init_transcript_tailer = () => {};
|
|
|
32830
32595
|
// src/session-events/index.ts
|
|
32831
32596
|
import { existsSync as existsSync16, readFileSync as readFileSync16, readdirSync as readdirSync3 } from "fs";
|
|
32832
32597
|
import { homedir as homedir24 } from "os";
|
|
32833
|
-
import { join as
|
|
32598
|
+
import { join as join24 } from "path";
|
|
32834
32599
|
function extractSessionId2(metadata) {
|
|
32835
32600
|
const userId = metadata?.user_id;
|
|
32836
32601
|
if (typeof userId !== "string")
|
|
@@ -32855,7 +32620,7 @@ class SessionEventRegistry {
|
|
|
32855
32620
|
claudeHome;
|
|
32856
32621
|
pollIntervalMs;
|
|
32857
32622
|
constructor(opts = {}) {
|
|
32858
|
-
this.claudeHome = opts.claudeHome ??
|
|
32623
|
+
this.claudeHome = opts.claudeHome ?? join24(homedir24(), ".claude");
|
|
32859
32624
|
this.pollIntervalMs = opts.pollIntervalMs;
|
|
32860
32625
|
}
|
|
32861
32626
|
ensureSession(sessionId) {
|
|
@@ -32941,13 +32706,13 @@ class SessionEventRegistry {
|
|
|
32941
32706
|
}
|
|
32942
32707
|
}
|
|
32943
32708
|
locateTranscript(sessionId) {
|
|
32944
|
-
const projectsDir =
|
|
32945
|
-
const primary =
|
|
32709
|
+
const projectsDir = join24(this.claudeHome, "projects");
|
|
32710
|
+
const primary = join24(projectsDir, slugFromCwd(process.cwd()), `${sessionId}.jsonl`);
|
|
32946
32711
|
if (existsSync16(primary))
|
|
32947
32712
|
return primary;
|
|
32948
32713
|
try {
|
|
32949
32714
|
for (const dir of readdirSync3(projectsDir)) {
|
|
32950
|
-
const candidate =
|
|
32715
|
+
const candidate = join24(projectsDir, dir, `${sessionId}.jsonl`);
|
|
32951
32716
|
if (existsSync16(candidate))
|
|
32952
32717
|
return candidate;
|
|
32953
32718
|
}
|
|
@@ -32956,7 +32721,7 @@ class SessionEventRegistry {
|
|
|
32956
32721
|
}
|
|
32957
32722
|
readSettingsEffortLevel() {
|
|
32958
32723
|
try {
|
|
32959
|
-
const settings = JSON.parse(readFileSync16(
|
|
32724
|
+
const settings = JSON.parse(readFileSync16(join24(this.claudeHome, "settings.json"), "utf-8"));
|
|
32960
32725
|
return typeof settings.effortLevel === "string" ? settings.effortLevel : undefined;
|
|
32961
32726
|
} catch {
|
|
32962
32727
|
return;
|
|
@@ -32974,7 +32739,7 @@ class SessionEventRegistry {
|
|
|
32974
32739
|
}
|
|
32975
32740
|
var MISS_TTL_MS = 5000, MAX_MISSES = 5, IDLE_SWEEP_MS, sessionEvents;
|
|
32976
32741
|
var init_session_events = __esm(() => {
|
|
32977
|
-
|
|
32742
|
+
init_home_dir();
|
|
32978
32743
|
init_logger();
|
|
32979
32744
|
init_event_translator();
|
|
32980
32745
|
init_transcript_tailer();
|
|
@@ -33213,7 +32978,7 @@ import {
|
|
|
33213
32978
|
writeFileSync as writeFileSync8
|
|
33214
32979
|
} from "fs";
|
|
33215
32980
|
import { homedir as homedir25 } from "os";
|
|
33216
|
-
import { join as
|
|
32981
|
+
import { join as join25 } from "path";
|
|
33217
32982
|
function ensureDir() {
|
|
33218
32983
|
if (!existsSync17(CLAUDISH_DIR)) {
|
|
33219
32984
|
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
@@ -33248,7 +33013,7 @@ function writeToDisk(events) {
|
|
|
33248
33013
|
ensureDir();
|
|
33249
33014
|
const trimmed = enforceSizeCap([...events]);
|
|
33250
33015
|
const payload = { version: 1, events: trimmed };
|
|
33251
|
-
const tmpFile =
|
|
33016
|
+
const tmpFile = join25(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
33252
33017
|
writeFileSync8(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
33253
33018
|
renameSync2(tmpFile, BUFFER_FILE);
|
|
33254
33019
|
memoryCache = trimmed;
|
|
@@ -33321,8 +33086,8 @@ function syncFlushOnExit() {
|
|
|
33321
33086
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, flushScheduled = false, SIGNAL_EXIT_CODE;
|
|
33322
33087
|
var init_stats_buffer = __esm(() => {
|
|
33323
33088
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
33324
|
-
CLAUDISH_DIR =
|
|
33325
|
-
BUFFER_FILE =
|
|
33089
|
+
CLAUDISH_DIR = join25(homedir25(), ".claudish");
|
|
33090
|
+
BUFFER_FILE = join25(CLAUDISH_DIR, "stats-buffer.json");
|
|
33326
33091
|
process.on("exit", syncFlushOnExit);
|
|
33327
33092
|
SIGNAL_EXIT_CODE = { SIGTERM: 143, SIGINT: 130 };
|
|
33328
33093
|
for (const signal of ["SIGTERM", "SIGINT"]) {
|
|
@@ -36462,7 +36227,7 @@ var init_openai_responses_sse = __esm(() => {
|
|
|
36462
36227
|
});
|
|
36463
36228
|
|
|
36464
36229
|
// src/session/token-file.ts
|
|
36465
|
-
import { join as
|
|
36230
|
+
import { join as join26 } from "path";
|
|
36466
36231
|
function assignedTokenFile(env) {
|
|
36467
36232
|
const f = env.CLAUDISH_TOKEN_FILE;
|
|
36468
36233
|
if (!f || f === env.CLAUDISH_PUBLISHED_TOKEN_FILE)
|
|
@@ -36470,7 +36235,7 @@ function assignedTokenFile(env) {
|
|
|
36470
36235
|
return f;
|
|
36471
36236
|
}
|
|
36472
36237
|
function resolveTokenFilePath(port, env = process.env) {
|
|
36473
|
-
return assignedTokenFile(env) ??
|
|
36238
|
+
return assignedTokenFile(env) ?? join26(userHomeFrom(env), ".claudish", `tokens-${port}.json`);
|
|
36474
36239
|
}
|
|
36475
36240
|
var init_token_file = __esm(() => {
|
|
36476
36241
|
init_home_dir();
|
|
@@ -38023,9 +37788,9 @@ var init_composed_handler = __esm(() => {
|
|
|
38023
37788
|
// src/providers/api-key-provenance.ts
|
|
38024
37789
|
import { existsSync as existsSync18, readFileSync as readFileSync18 } from "fs";
|
|
38025
37790
|
import { homedir as homedir26 } from "os";
|
|
38026
|
-
import { join as
|
|
37791
|
+
import { join as join27, resolve as resolve2 } from "path";
|
|
38027
37792
|
function activeConfigPath() {
|
|
38028
|
-
return activeGlobalConfigFile(
|
|
37793
|
+
return activeGlobalConfigFile(join27(homedir26(), ".claudish", "config.json"));
|
|
38029
37794
|
}
|
|
38030
37795
|
function configLayerLabel() {
|
|
38031
37796
|
return getConfigFileOverride() ? activeConfigPath() : "~/.claudish/config.json";
|
|
@@ -41828,7 +41593,7 @@ function compareByConnectionPrice(a, b) {
|
|
|
41828
41593
|
// src/providers/probe-catalog.ts
|
|
41829
41594
|
import { existsSync as existsSync19, mkdirSync as mkdirSync11, readFileSync as readFileSync19, writeFileSync as writeFileSync10 } from "fs";
|
|
41830
41595
|
import { homedir as homedir27 } from "os";
|
|
41831
|
-
import { dirname as dirname9, join as
|
|
41596
|
+
import { dirname as dirname9, join as join28 } from "path";
|
|
41832
41597
|
function describeProbeCatalogFailure(outcome) {
|
|
41833
41598
|
switch (outcome.kind) {
|
|
41834
41599
|
case "incompatible":
|
|
@@ -41999,7 +41764,7 @@ var PROBE_MODELS_URL = "https://us-central1-claudish-6da10.cloudfunctions.net/pr
|
|
|
41999
41764
|
var init_probe_catalog = __esm(() => {
|
|
42000
41765
|
init_catalog_route_bindings();
|
|
42001
41766
|
CACHE_TTL_MS4 = 60 * 60 * 1000;
|
|
42002
|
-
PROBE_MODELS_CACHE_PATH =
|
|
41767
|
+
PROBE_MODELS_CACHE_PATH = join28(homedir27(), ".claudish", "probe-models.json");
|
|
42003
41768
|
});
|
|
42004
41769
|
|
|
42005
41770
|
// src/providers/route-candidates.ts
|
|
@@ -43352,7 +43117,7 @@ var init_slot_row = __esm(() => {
|
|
|
43352
43117
|
|
|
43353
43118
|
// src/pane/prompt-delivery.ts
|
|
43354
43119
|
import { writeFileSync as writeFileSync11 } from "fs";
|
|
43355
|
-
import { join as
|
|
43120
|
+
import { join as join29 } from "path";
|
|
43356
43121
|
function stripControl(s) {
|
|
43357
43122
|
let out = "";
|
|
43358
43123
|
for (const ch of s) {
|
|
@@ -43419,7 +43184,7 @@ function renderTurnFile(text, limit = READ_LINE_LIMIT) {
|
|
|
43419
43184
|
`), lines: out.length, marker };
|
|
43420
43185
|
}
|
|
43421
43186
|
function turnFilePath(turnDir, turnIndex) {
|
|
43422
|
-
return
|
|
43187
|
+
return join29(turnDir, `turn-${turnIndex}.md`);
|
|
43423
43188
|
}
|
|
43424
43189
|
function fileTemplate(file, marker) {
|
|
43425
43190
|
const base = `Your task is in the file \`${file}\`. Read all of it with the Read tool (in parts if it is long), then do exactly what it says, treating its content as the user's message.`;
|
|
@@ -43500,12 +43265,12 @@ var init_prompt_delivery = __esm(() => {
|
|
|
43500
43265
|
|
|
43501
43266
|
// src/team-stats.ts
|
|
43502
43267
|
import { existsSync as existsSync20, readFileSync as readFileSync20, writeFileSync as writeFileSync12 } from "fs";
|
|
43503
|
-
import { join as
|
|
43268
|
+
import { join as join30 } from "path";
|
|
43504
43269
|
function statsDir(sessionPath) {
|
|
43505
|
-
return
|
|
43270
|
+
return join30(sessionPath, "stats");
|
|
43506
43271
|
}
|
|
43507
43272
|
function tokenFileFor(sessionPath, anonId) {
|
|
43508
|
-
return
|
|
43273
|
+
return join30(statsDir(sessionPath), `${anonId}.json`);
|
|
43509
43274
|
}
|
|
43510
43275
|
function readTokenStatsAt(path) {
|
|
43511
43276
|
if (!existsSync20(path))
|
|
@@ -43668,7 +43433,7 @@ ${segs.join(" \xB7 ")}`;
|
|
|
43668
43433
|
}
|
|
43669
43434
|
function writeStatusFile(sessionPath, manifest, status, opts) {
|
|
43670
43435
|
try {
|
|
43671
|
-
writeFileSync12(
|
|
43436
|
+
writeFileSync12(join30(sessionPath, "status.txt"), `${renderTeamStats(sessionPath, manifest, status, opts)}
|
|
43672
43437
|
`, "utf-8");
|
|
43673
43438
|
} catch {}
|
|
43674
43439
|
}
|
|
@@ -43758,7 +43523,7 @@ var init_cache_ttl = __esm(() => {
|
|
|
43758
43523
|
// src/model-loader.ts
|
|
43759
43524
|
import { existsSync as existsSync21, mkdirSync as mkdirSync12, readFileSync as readFileSync21, writeFileSync as writeFileSync13 } from "fs";
|
|
43760
43525
|
import { homedir as homedir28 } from "os";
|
|
43761
|
-
import { join as
|
|
43526
|
+
import { join as join31 } from "path";
|
|
43762
43527
|
async function fetchCatalogPage(url, timeoutMs, generationId) {
|
|
43763
43528
|
const requestUrl = new URL(url);
|
|
43764
43529
|
if (generationId)
|
|
@@ -43985,7 +43750,7 @@ async function getRecommendedModels(opts = {}) {
|
|
|
43985
43750
|
if (data.models.length > 0) {
|
|
43986
43751
|
_cachedRecommendedModels = data;
|
|
43987
43752
|
try {
|
|
43988
|
-
const cacheDir =
|
|
43753
|
+
const cacheDir = join31(homedir28(), ".claudish");
|
|
43989
43754
|
mkdirSync12(cacheDir, { recursive: true });
|
|
43990
43755
|
writeFileSync13(RECOMMENDED_MODELS_CACHE_PATH, JSON.stringify(data), "utf-8");
|
|
43991
43756
|
} catch {}
|
|
@@ -44129,7 +43894,7 @@ var init_model_loader = __esm(() => {
|
|
|
44129
43894
|
init_catalog_client();
|
|
44130
43895
|
init_catalog_route_bindings();
|
|
44131
43896
|
FIREBASE_RECOMMENDED_URL = `${FIREBASE_BASE_URL}?catalog=recommended`;
|
|
44132
|
-
RECOMMENDED_MODELS_CACHE_PATH =
|
|
43897
|
+
RECOMMENDED_MODELS_CACHE_PATH = join31(homedir28(), ".claudish", "recommended-models-cache.json");
|
|
44133
43898
|
RECOMMENDED_ROUTE_TIER_ORDER = {
|
|
44134
43899
|
native: 0,
|
|
44135
43900
|
general: 1,
|
|
@@ -47697,7 +47462,7 @@ var init_DiscoveryNotice = __esm(() => {
|
|
|
47697
47462
|
// src/providers/model-descriptions.ts
|
|
47698
47463
|
import { existsSync as existsSync22, mkdirSync as mkdirSync13, readFileSync as readFileSync22, writeFileSync as writeFileSync14 } from "fs";
|
|
47699
47464
|
import { homedir as homedir29 } from "os";
|
|
47700
|
-
import { dirname as dirname10, join as
|
|
47465
|
+
import { dirname as dirname10, join as join32 } from "path";
|
|
47701
47466
|
function emptyDescriptionIndex() {
|
|
47702
47467
|
return EMPTY_INDEX;
|
|
47703
47468
|
}
|
|
@@ -47790,7 +47555,7 @@ var init_model_descriptions = __esm(() => {
|
|
|
47790
47555
|
init_logger();
|
|
47791
47556
|
init_model_loader();
|
|
47792
47557
|
init_cache_ttl();
|
|
47793
|
-
MODEL_DESCRIPTIONS_CACHE_PATH =
|
|
47558
|
+
MODEL_DESCRIPTIONS_CACHE_PATH = join32(homedir29(), ".claudish", "model-descriptions.json");
|
|
47794
47559
|
EMPTY_INDEX = { get: () => {
|
|
47795
47560
|
return;
|
|
47796
47561
|
}, size: 0 };
|
|
@@ -53728,22 +53493,22 @@ var init_branding = __esm(() => {
|
|
|
53728
53493
|
// src/update-checker.ts
|
|
53729
53494
|
import { existsSync as existsSync23, mkdirSync as mkdirSync14, readFileSync as readFileSync23, unlinkSync as unlinkSync6, writeFileSync as writeFileSync15 } from "fs";
|
|
53730
53495
|
import { homedir as homedir30, platform as platform2, tmpdir } from "os";
|
|
53731
|
-
import { join as
|
|
53496
|
+
import { join as join33 } from "path";
|
|
53732
53497
|
function getCacheFilePath() {
|
|
53733
53498
|
let cacheDir;
|
|
53734
53499
|
if (isWindows) {
|
|
53735
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
53736
|
-
cacheDir =
|
|
53500
|
+
const localAppData = process.env.LOCALAPPDATA || join33(homedir30(), "AppData", "Local");
|
|
53501
|
+
cacheDir = join33(localAppData, "claudish");
|
|
53737
53502
|
} else {
|
|
53738
|
-
cacheDir =
|
|
53503
|
+
cacheDir = join33(homedir30(), ".cache", "claudish");
|
|
53739
53504
|
}
|
|
53740
53505
|
try {
|
|
53741
53506
|
if (!existsSync23(cacheDir)) {
|
|
53742
53507
|
mkdirSync14(cacheDir, { recursive: true });
|
|
53743
53508
|
}
|
|
53744
|
-
return
|
|
53509
|
+
return join33(cacheDir, "update-check.json");
|
|
53745
53510
|
} catch {
|
|
53746
|
-
return
|
|
53511
|
+
return join33(tmpdir(), "claudish-update-check.json");
|
|
53747
53512
|
}
|
|
53748
53513
|
}
|
|
53749
53514
|
function readCache2() {
|
|
@@ -58403,7 +58168,7 @@ var init_openrouter = __esm(() => {
|
|
|
58403
58168
|
// src/services/pricing-cache.ts
|
|
58404
58169
|
import { existsSync as existsSync24, readFileSync as readFileSync24, statSync as statSync6 } from "fs";
|
|
58405
58170
|
import { homedir as homedir31 } from "os";
|
|
58406
|
-
import { join as
|
|
58171
|
+
import { join as join34 } from "path";
|
|
58407
58172
|
function prefixMatch(modelName) {
|
|
58408
58173
|
for (const [key, pricing] of pricingMap) {
|
|
58409
58174
|
if (modelName.startsWith(key))
|
|
@@ -58463,14 +58228,14 @@ var init_pricing_cache = __esm(() => {
|
|
|
58463
58228
|
init_logger();
|
|
58464
58229
|
init_catalog_query();
|
|
58465
58230
|
pricingMap = new Map;
|
|
58466
|
-
CACHE_DIR =
|
|
58467
|
-
CACHE_FILE =
|
|
58231
|
+
CACHE_DIR = join34(homedir31(), ".claudish");
|
|
58232
|
+
CACHE_FILE = join34(CACHE_DIR, "pricing-cache.json");
|
|
58468
58233
|
CACHE_TTL_MS5 = 24 * 60 * 60 * 1000;
|
|
58469
58234
|
});
|
|
58470
58235
|
|
|
58471
58236
|
// src/proxy-server.ts
|
|
58472
58237
|
import { appendFileSync as appendFileSync7, mkdirSync as mkdirSync15 } from "fs";
|
|
58473
|
-
import { join as
|
|
58238
|
+
import { join as join35 } from "path";
|
|
58474
58239
|
function isTerminalRoutingFailure(e) {
|
|
58475
58240
|
return e instanceof RoutingError;
|
|
58476
58241
|
}
|
|
@@ -58478,7 +58243,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
58478
58243
|
if (!process.env.CLAUDISH_CLASSIFIER_DEBUG)
|
|
58479
58244
|
return;
|
|
58480
58245
|
try {
|
|
58481
|
-
const dir =
|
|
58246
|
+
const dir = join35(process.cwd(), "logs");
|
|
58482
58247
|
if (!classifierCaptureDirReady) {
|
|
58483
58248
|
mkdirSync15(dir, { recursive: true });
|
|
58484
58249
|
classifierCaptureDirReady = true;
|
|
@@ -58503,7 +58268,7 @@ function maybeCaptureClassifierRequest(c, body) {
|
|
|
58503
58268
|
"x-api-key": c.req.header("x-api-key") ? "<present>" : null
|
|
58504
58269
|
}
|
|
58505
58270
|
};
|
|
58506
|
-
appendFileSync7(
|
|
58271
|
+
appendFileSync7(join35(dir, "classifier-capture.jsonl"), `${JSON.stringify(record)}
|
|
58507
58272
|
`);
|
|
58508
58273
|
} catch {}
|
|
58509
58274
|
}
|
|
@@ -59052,13 +58817,13 @@ import {
|
|
|
59052
58817
|
unlinkSync as unlinkSync7
|
|
59053
58818
|
} from "fs";
|
|
59054
58819
|
import { homedir as homedir32 } from "os";
|
|
59055
|
-
import { dirname as dirname11, join as
|
|
58820
|
+
import { dirname as dirname11, join as join36 } from "path";
|
|
59056
58821
|
import { fileURLToPath } from "url";
|
|
59057
58822
|
function getVersion3() {
|
|
59058
58823
|
return VERSION;
|
|
59059
58824
|
}
|
|
59060
58825
|
function clearAllModelCaches() {
|
|
59061
|
-
const cacheDir =
|
|
58826
|
+
const cacheDir = join36(homedir32(), ".claudish");
|
|
59062
58827
|
if (!existsSync25(cacheDir))
|
|
59063
58828
|
return;
|
|
59064
58829
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache.json"];
|
|
@@ -59067,7 +58832,7 @@ function clearAllModelCaches() {
|
|
|
59067
58832
|
const files = readdirSync4(cacheDir);
|
|
59068
58833
|
for (const file of files) {
|
|
59069
58834
|
if (cachePatterns.includes(file)) {
|
|
59070
|
-
unlinkSync7(
|
|
58835
|
+
unlinkSync7(join36(cacheDir, file));
|
|
59071
58836
|
cleared++;
|
|
59072
58837
|
}
|
|
59073
58838
|
}
|
|
@@ -60601,7 +60366,7 @@ ${h("MORE INFO")}
|
|
|
60601
60366
|
}
|
|
60602
60367
|
function printAIAgentGuide() {
|
|
60603
60368
|
try {
|
|
60604
|
-
const guidePath =
|
|
60369
|
+
const guidePath = join36(__dirname2, "../AI_AGENT_GUIDE.md");
|
|
60605
60370
|
const guideContent = readFileSync25(guidePath, "utf-8");
|
|
60606
60371
|
console.log(guideContent);
|
|
60607
60372
|
} catch (error) {
|
|
@@ -60618,10 +60383,10 @@ async function initializeClaudishSkill() {
|
|
|
60618
60383
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
60619
60384
|
`);
|
|
60620
60385
|
const cwd = process.cwd();
|
|
60621
|
-
const claudeDir =
|
|
60622
|
-
const skillsDir =
|
|
60623
|
-
const claudishSkillDir =
|
|
60624
|
-
const skillFile =
|
|
60386
|
+
const claudeDir = join36(cwd, ".claude");
|
|
60387
|
+
const skillsDir = join36(claudeDir, "skills");
|
|
60388
|
+
const claudishSkillDir = join36(skillsDir, "claudish-usage");
|
|
60389
|
+
const skillFile = join36(claudishSkillDir, "SKILL.md");
|
|
60625
60390
|
if (existsSync25(skillFile)) {
|
|
60626
60391
|
console.log("\u2705 Claudish skill already installed at:");
|
|
60627
60392
|
console.log(` ${skillFile}
|
|
@@ -60629,7 +60394,7 @@ async function initializeClaudishSkill() {
|
|
|
60629
60394
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
60630
60395
|
return;
|
|
60631
60396
|
}
|
|
60632
|
-
const sourceSkillPath =
|
|
60397
|
+
const sourceSkillPath = join36(__dirname2, "../skills/claudish-usage/SKILL.md");
|
|
60633
60398
|
if (!existsSync25(sourceSkillPath)) {
|
|
60634
60399
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
60635
60400
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
@@ -60819,16 +60584,16 @@ var init_cli = __esm(() => {
|
|
|
60819
60584
|
// src/launcher/magmux-binary.ts
|
|
60820
60585
|
import { execSync } from "child_process";
|
|
60821
60586
|
import { existsSync as existsSync26 } from "fs";
|
|
60822
|
-
import { dirname as dirname12, join as
|
|
60587
|
+
import { dirname as dirname12, join as join37 } from "path";
|
|
60823
60588
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
60824
60589
|
function findMagmuxBinaryOrNull() {
|
|
60825
60590
|
const thisFile = fileURLToPath2(import.meta.url);
|
|
60826
60591
|
const thisDir = dirname12(thisFile);
|
|
60827
|
-
const pkgRoots = [
|
|
60592
|
+
const pkgRoots = [join37(thisDir, ".."), join37(thisDir, "..", "..")];
|
|
60828
60593
|
const platform = process.platform;
|
|
60829
60594
|
const arch = process.arch;
|
|
60830
60595
|
for (const pkgRoot of pkgRoots) {
|
|
60831
|
-
const bundled =
|
|
60596
|
+
const bundled = join37(pkgRoot, "native", `magmux-${platform}-${arch}`);
|
|
60832
60597
|
if (existsSync26(bundled))
|
|
60833
60598
|
return bundled;
|
|
60834
60599
|
}
|
|
@@ -60836,7 +60601,7 @@ function findMagmuxBinaryOrNull() {
|
|
|
60836
60601
|
const pkgName = `@claudish/magmux-${platform}-${arch}`;
|
|
60837
60602
|
let searchDir = pkgRoots[0];
|
|
60838
60603
|
for (let i = 0;i < 5; i++) {
|
|
60839
|
-
const candidate =
|
|
60604
|
+
const candidate = join37(searchDir, "node_modules", pkgName, "bin", "magmux");
|
|
60840
60605
|
if (existsSync26(candidate))
|
|
60841
60606
|
return candidate;
|
|
60842
60607
|
const parent = dirname12(searchDir);
|
|
@@ -60873,7 +60638,7 @@ import {
|
|
|
60873
60638
|
writeFileSync as writeFileSync16
|
|
60874
60639
|
} from "fs";
|
|
60875
60640
|
import { connect as netConnect } from "net";
|
|
60876
|
-
import { join as
|
|
60641
|
+
import { join as join38 } from "path";
|
|
60877
60642
|
function envDeltas(parentEnv, childEnv) {
|
|
60878
60643
|
const set = [];
|
|
60879
60644
|
const unset = [];
|
|
@@ -60939,9 +60704,9 @@ function planMagmuxWrap(input) {
|
|
|
60939
60704
|
const controlSocket = `/tmp/magmux-${id}.sock`;
|
|
60940
60705
|
const tmpRoot = input.tmpRoot ?? "/tmp";
|
|
60941
60706
|
mkdirSync17(tmpRoot, { recursive: true });
|
|
60942
|
-
const scriptDir = mkdtempSync(
|
|
60707
|
+
const scriptDir = mkdtempSync(join38(tmpRoot, "claudish-launch-"));
|
|
60943
60708
|
chmodSync(scriptDir, 448);
|
|
60944
|
-
const scriptPath =
|
|
60709
|
+
const scriptPath = join38(scriptDir, "claude-launch.sh");
|
|
60945
60710
|
const parentEnv = input.parentEnv ?? process.env;
|
|
60946
60711
|
const deltas = envDeltas(parentEnv, input.childEnv);
|
|
60947
60712
|
const fd = openSync6(scriptPath, "wx", 384);
|
|
@@ -61070,7 +60835,7 @@ var CLAUDISH_BIN_ENV = "CLAUDISH_BIN";
|
|
|
61070
60835
|
// src/pane/process-identity.ts
|
|
61071
60836
|
import { execFile, execFileSync as execFileSync2 } from "child_process";
|
|
61072
60837
|
import { lstatSync } from "fs";
|
|
61073
|
-
import { basename, dirname as dirname13, join as
|
|
60838
|
+
import { basename, dirname as dirname13, join as join39 } from "path";
|
|
61074
60839
|
function collapse(s) {
|
|
61075
60840
|
return s.trim().replace(/\s+/g, " ");
|
|
61076
60841
|
}
|
|
@@ -61251,16 +61016,16 @@ function isValidPaneId(id) {
|
|
|
61251
61016
|
return PANE_ID_RE.test(id) && !/^\d+$/.test(id);
|
|
61252
61017
|
}
|
|
61253
61018
|
function sockPathOf(root, paneId) {
|
|
61254
|
-
return
|
|
61019
|
+
return join39(root, `magmux-${paneId}.sock`);
|
|
61255
61020
|
}
|
|
61256
61021
|
function recordPathOf(root, paneId) {
|
|
61257
|
-
return
|
|
61022
|
+
return join39(root, "panes", `${paneId}.json`);
|
|
61258
61023
|
}
|
|
61259
61024
|
function isPaneSockPath(root, p, paneId) {
|
|
61260
61025
|
return isValidPaneId(paneId) && dirname13(p) === root && basename(p) === `magmux-${paneId}.sock`;
|
|
61261
61026
|
}
|
|
61262
61027
|
function isPaneRecordPath(root, p, paneId) {
|
|
61263
|
-
return isValidPaneId(paneId) && dirname13(p) ===
|
|
61028
|
+
return isValidPaneId(paneId) && dirname13(p) === join39(root, "panes") && basename(p) === `${paneId}.json`;
|
|
61264
61029
|
}
|
|
61265
61030
|
function watcherArgv(a) {
|
|
61266
61031
|
return [
|
|
@@ -61361,7 +61126,7 @@ var init_process_identity = __esm(() => {
|
|
|
61361
61126
|
import { execFile as execFile2, spawn } from "child_process";
|
|
61362
61127
|
import { randomBytes as randomBytes7 } from "crypto";
|
|
61363
61128
|
import { chmodSync as chmodSync2, lstatSync as lstatSync2, mkdirSync as mkdirSync18, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync17 } from "fs";
|
|
61364
|
-
import { join as
|
|
61129
|
+
import { join as join40, resolve as resolve3 } from "path";
|
|
61365
61130
|
import { promisify as promisify5 } from "util";
|
|
61366
61131
|
function uid() {
|
|
61367
61132
|
return typeof process.getuid === "function" ? process.getuid() : 0;
|
|
@@ -61390,7 +61155,7 @@ function ensureSockRoot(given = sockRootFor()) {
|
|
|
61390
61155
|
throw e;
|
|
61391
61156
|
}
|
|
61392
61157
|
assertPrivateDir(root);
|
|
61393
|
-
const panes =
|
|
61158
|
+
const panes = join40(root, "panes");
|
|
61394
61159
|
try {
|
|
61395
61160
|
mkdirSync18(panes, { mode: 448 });
|
|
61396
61161
|
} catch (e) {
|
|
@@ -61445,7 +61210,7 @@ function buildPaneEnv(input) {
|
|
|
61445
61210
|
if ((input.platform ?? process.platform) === "linux" && entryBytes > LINUX_ENV_STRING_LIMIT)
|
|
61446
61211
|
throw new PaneEnvTooLargeError(`pane environment snapshot is ${entryBytes} bytes, over Linux's 131072-byte limit per variable`);
|
|
61447
61212
|
env[ENV.CLAUDISH_PANE_ENV] = json;
|
|
61448
|
-
env.SHELL =
|
|
61213
|
+
env.SHELL = join40(input.ctlDir, "sh-shim");
|
|
61449
61214
|
return { magmuxEnv: env };
|
|
61450
61215
|
}
|
|
61451
61216
|
function buildClaudishPaneArgv(spawnModel, sessionUuid, turnDir, callerFlags) {
|
|
@@ -61591,21 +61356,21 @@ exec ${words}
|
|
|
61591
61356
|
`;
|
|
61592
61357
|
}
|
|
61593
61358
|
function paneCommand(ctlDir) {
|
|
61594
|
-
const cmd = `. ${shq2(
|
|
61359
|
+
const cmd = `. ${shq2(join40(ctlDir, "pane-launch.sh"))}`;
|
|
61595
61360
|
if (/claude /.test(cmd) || /claude$/.test(cmd) || /(^|\/)claude['"]?$/.test(cmd))
|
|
61596
61361
|
throw new Error(`pane command would attach magmux's Claude Code controller: ${cmd}`);
|
|
61597
61362
|
return cmd;
|
|
61598
61363
|
}
|
|
61599
61364
|
function createLaunchDirs(root) {
|
|
61600
|
-
const ctlDir = mkdtempSync2(
|
|
61365
|
+
const ctlDir = mkdtempSync2(join40(root, "launch-"));
|
|
61601
61366
|
chmodSync2(ctlDir, 448);
|
|
61602
|
-
const turnDir = mkdtempSync2(
|
|
61367
|
+
const turnDir = mkdtempSync2(join40(root, "launch-"));
|
|
61603
61368
|
chmodSync2(turnDir, 448);
|
|
61604
61369
|
return { ctlDir, turnDir };
|
|
61605
61370
|
}
|
|
61606
61371
|
function writeLauncherFiles(ctlDir, script) {
|
|
61607
|
-
writeFileSync17(
|
|
61608
|
-
writeFileSync17(
|
|
61372
|
+
writeFileSync17(join40(ctlDir, "pane-launch.sh"), script, { mode: 384, flag: "wx" });
|
|
61373
|
+
writeFileSync17(join40(ctlDir, "sh-shim"), SHELL_SHIM, { mode: 448, flag: "wx" });
|
|
61609
61374
|
}
|
|
61610
61375
|
function spawnPaneWatcher(args) {
|
|
61611
61376
|
const proc = spawn("/bin/sh", watcherArgv(args), {
|
|
@@ -61983,7 +61748,7 @@ import {
|
|
|
61983
61748
|
unlinkSync as unlinkSync8,
|
|
61984
61749
|
writeFileSync as writeFileSync18
|
|
61985
61750
|
} from "fs";
|
|
61986
|
-
import { join as
|
|
61751
|
+
import { join as join41 } from "path";
|
|
61987
61752
|
function ownerStartOfSelf() {
|
|
61988
61753
|
if (ownStart)
|
|
61989
61754
|
return ownStart;
|
|
@@ -61996,7 +61761,7 @@ function ownerAlive(rec, table) {
|
|
|
61996
61761
|
return !!row && row.lstart === rec.ownerStart;
|
|
61997
61762
|
}
|
|
61998
61763
|
function recordsDir(root) {
|
|
61999
|
-
return
|
|
61764
|
+
return join41(root, "panes");
|
|
62000
61765
|
}
|
|
62001
61766
|
function writeRecord(root, rec) {
|
|
62002
61767
|
const p = recordPathOf(root, rec.paneId);
|
|
@@ -62066,13 +61831,13 @@ function readRecords(root) {
|
|
|
62066
61831
|
}
|
|
62067
61832
|
function readGroupFile(ctlDir) {
|
|
62068
61833
|
try {
|
|
62069
|
-
return parseGroupFile(readFileSync26(
|
|
61834
|
+
return parseGroupFile(readFileSync26(join41(ctlDir, "group"), "utf8"));
|
|
62070
61835
|
} catch {
|
|
62071
61836
|
return null;
|
|
62072
61837
|
}
|
|
62073
61838
|
}
|
|
62074
61839
|
function writeGroupFile(ctlDir, snap) {
|
|
62075
|
-
const p =
|
|
61840
|
+
const p = join41(ctlDir, "group");
|
|
62076
61841
|
const tmp = `${p}.tmp`;
|
|
62077
61842
|
try {
|
|
62078
61843
|
writeFileSync18(tmp, formatGroupFile(snap), { mode: 384 });
|
|
@@ -62284,7 +62049,7 @@ async function sweepRecordlessSocket(root, name, out) {
|
|
|
62284
62049
|
const table = readProcessTable();
|
|
62285
62050
|
if (ownerOfIdAlive(id, table))
|
|
62286
62051
|
return;
|
|
62287
|
-
const sockPath =
|
|
62052
|
+
const sockPath = join41(root, name);
|
|
62288
62053
|
let client = null;
|
|
62289
62054
|
try {
|
|
62290
62055
|
client = await MagmuxClient.dial(sockPath);
|
|
@@ -62353,6 +62118,64 @@ var init_pane_registry = __esm(() => {
|
|
|
62353
62118
|
sweptRoots = new Set;
|
|
62354
62119
|
});
|
|
62355
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
|
+
|
|
62356
62179
|
// src/process-tree.ts
|
|
62357
62180
|
function waitForExit(proc, ms) {
|
|
62358
62181
|
if (proc.exitCode !== null || proc.signalCode !== null)
|
|
@@ -62392,7 +62215,7 @@ function emptyScreen(cols, rows) {
|
|
|
62392
62215
|
};
|
|
62393
62216
|
}
|
|
62394
62217
|
function isBoxRule(line, cols) {
|
|
62395
|
-
if (!line || !/^\u2500
|
|
62218
|
+
if (!line || !/^\u2500+(?: [^\u2500]+ \u2500+)?$/.test(line))
|
|
62396
62219
|
return false;
|
|
62397
62220
|
return line.length >= Math.max(20, Math.min(cols, 160) - 1);
|
|
62398
62221
|
}
|
|
@@ -62667,6 +62490,104 @@ var init_screen_classifier = __esm(() => {
|
|
|
62667
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\+/;
|
|
62668
62491
|
});
|
|
62669
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
|
+
|
|
62670
62591
|
// src/pane/settle-rule.ts
|
|
62671
62592
|
function agentsBalanced(t) {
|
|
62672
62593
|
return t.agentsLaunched === t.agentsCompleted;
|
|
@@ -62851,11 +62772,11 @@ import {
|
|
|
62851
62772
|
fstatSync,
|
|
62852
62773
|
openSync as openSync7,
|
|
62853
62774
|
readSync as readSync2,
|
|
62854
|
-
readdirSync as
|
|
62775
|
+
readdirSync as readdirSync7,
|
|
62855
62776
|
realpathSync as realpathSync2,
|
|
62856
62777
|
statSync as statSync7
|
|
62857
62778
|
} from "fs";
|
|
62858
|
-
import { join as
|
|
62779
|
+
import { join as join44 } from "path";
|
|
62859
62780
|
function initialFollowerState(resolvePath = safeRealpath) {
|
|
62860
62781
|
return {
|
|
62861
62782
|
turns: [],
|
|
@@ -63351,7 +63272,7 @@ class TranscriptFollower {
|
|
|
63351
63272
|
if (!existsSync29(this.subagentsDir))
|
|
63352
63273
|
return [];
|
|
63353
63274
|
try {
|
|
63354
|
-
return
|
|
63275
|
+
return readdirSync7(this.subagentsDir).filter((f) => f.endsWith(".jsonl"));
|
|
63355
63276
|
} catch {
|
|
63356
63277
|
return [];
|
|
63357
63278
|
}
|
|
@@ -63361,7 +63282,7 @@ class TranscriptFollower {
|
|
|
63361
63282
|
for (const f of this.subagentFiles()) {
|
|
63362
63283
|
let tail = this.subs.get(f);
|
|
63363
63284
|
if (!tail) {
|
|
63364
|
-
tail = new Tail(
|
|
63285
|
+
tail = new Tail(join44(this.subagentsDir, f));
|
|
63365
63286
|
this.subs.set(f, tail);
|
|
63366
63287
|
}
|
|
63367
63288
|
for (const { line } of tail.read()) {
|
|
@@ -63443,8 +63364,8 @@ var init_transcript_follower = __esm(() => {
|
|
|
63443
63364
|
});
|
|
63444
63365
|
|
|
63445
63366
|
// src/pane/pane-session.ts
|
|
63446
|
-
import { readFileSync as
|
|
63447
|
-
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";
|
|
63448
63369
|
function iso(ms) {
|
|
63449
63370
|
return new Date(ms).toISOString();
|
|
63450
63371
|
}
|
|
@@ -63507,6 +63428,13 @@ class PaneSessionImpl {
|
|
|
63507
63428
|
claudeCodeVersion = null;
|
|
63508
63429
|
anomalies = new Map;
|
|
63509
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;
|
|
63510
63438
|
exitScrollback = "";
|
|
63511
63439
|
exitLastLine = "";
|
|
63512
63440
|
bootKind = null;
|
|
@@ -63546,7 +63474,11 @@ class PaneSessionImpl {
|
|
|
63546
63474
|
this.queue.push(o.initialPrompt);
|
|
63547
63475
|
this.secondaryQuietMs = o.timings?.secondaryQuietMs ?? SECONDARY_QUIET_MS;
|
|
63548
63476
|
this.corroborationMs = o.timings?.corroborationMs ?? CORROBORATION_MS;
|
|
63549
|
-
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
|
+
});
|
|
63550
63482
|
this.ready = new Promise((r) => {
|
|
63551
63483
|
this.resolveReady = r;
|
|
63552
63484
|
});
|
|
@@ -63587,7 +63519,7 @@ class PaneSessionImpl {
|
|
|
63587
63519
|
return this.spawnFailed(new Error("magmux did not start"));
|
|
63588
63520
|
this.magmux = proc;
|
|
63589
63521
|
try {
|
|
63590
|
-
writeFileSync19(
|
|
63522
|
+
writeFileSync19(join45(this.ctlDir, "magmux.pid"), `${proc.pid}
|
|
63591
63523
|
`, { mode: 384 });
|
|
63592
63524
|
} catch {}
|
|
63593
63525
|
updateRecord(this.root, this.paneId, { magmuxPid: proc.pid });
|
|
@@ -63860,8 +63792,46 @@ class PaneSessionImpl {
|
|
|
63860
63792
|
this.evalIdle(view);
|
|
63861
63793
|
break;
|
|
63862
63794
|
}
|
|
63795
|
+
this.checkRegistry();
|
|
63863
63796
|
this.pump();
|
|
63864
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
|
+
}
|
|
63865
63835
|
checkLiveness() {
|
|
63866
63836
|
if (this.client || !this.panePidValue || this.paneExited)
|
|
63867
63837
|
return;
|
|
@@ -63911,6 +63881,7 @@ class PaneSessionImpl {
|
|
|
63911
63881
|
}
|
|
63912
63882
|
}
|
|
63913
63883
|
bootReady() {
|
|
63884
|
+
this.bootReadyAtMs = Date.now();
|
|
63914
63885
|
if (this.queue.length === 0) {
|
|
63915
63886
|
this.fire("boot_ready_idle");
|
|
63916
63887
|
return;
|
|
@@ -64393,7 +64364,7 @@ class PaneSessionImpl {
|
|
|
64393
64364
|
const p = this.errorLogPath();
|
|
64394
64365
|
if (p && this.errorLogSize() > st.errorLogSize) {
|
|
64395
64366
|
try {
|
|
64396
|
-
const text =
|
|
64367
|
+
const text = readFileSync28(p, "utf8").slice(st.errorLogSize).trim();
|
|
64397
64368
|
return { status: null, category: "upstream_error_log", text };
|
|
64398
64369
|
} catch {}
|
|
64399
64370
|
}
|
|
@@ -64557,8 +64528,10 @@ ${screenTailOf(this.screen)}`
|
|
|
64557
64528
|
}
|
|
64558
64529
|
diagnostics() {
|
|
64559
64530
|
const cur = this.follower.view().current;
|
|
64531
|
+
const rec = this.registryRec;
|
|
64560
64532
|
return {
|
|
64561
64533
|
magmuxStderr: this.stderrHead,
|
|
64534
|
+
registry: rec ? { status: rec.status, waitingFor: rec.waitingFor, version: rec.version } : null,
|
|
64562
64535
|
preambleBytes: cur?.preambleBytes ?? 0,
|
|
64563
64536
|
readCoverage: cur?.delivery ? {
|
|
64564
64537
|
linesTotal: cur.delivery.lines,
|
|
@@ -64826,8 +64799,9 @@ async function startPaneSession(o) {
|
|
|
64826
64799
|
await session.start({ magmuxBinary: magmux.binary, env: p.magmuxEnv, cwd: p.cwd });
|
|
64827
64800
|
return session;
|
|
64828
64801
|
}
|
|
64829
|
-
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;
|
|
64830
64803
|
var init_pane_session = __esm(() => {
|
|
64804
|
+
init_parent_session();
|
|
64831
64805
|
init_process_tree();
|
|
64832
64806
|
init_redact();
|
|
64833
64807
|
init_magmux_client();
|
|
@@ -64836,6 +64810,7 @@ var init_pane_session = __esm(() => {
|
|
|
64836
64810
|
init_process_identity();
|
|
64837
64811
|
init_prompt_delivery();
|
|
64838
64812
|
init_screen_classifier();
|
|
64813
|
+
init_session_registry();
|
|
64839
64814
|
init_settle_rule();
|
|
64840
64815
|
init_slot_state();
|
|
64841
64816
|
init_transcript_follower();
|
|
@@ -64889,10 +64864,10 @@ __export(exports_session_discovery, {
|
|
|
64889
64864
|
transcriptPathFor: () => transcriptPathFor
|
|
64890
64865
|
});
|
|
64891
64866
|
import { execFile as execFile3, execFileSync as execFileSync3 } from "child_process";
|
|
64892
|
-
import { closeSync as closeSync8, openSync as openSync8, readSync as readSync3, readdirSync as
|
|
64893
|
-
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";
|
|
64894
64869
|
function projectsDir(env = process.env) {
|
|
64895
|
-
return
|
|
64870
|
+
return join46(claudeConfigDir(env), "projects");
|
|
64896
64871
|
}
|
|
64897
64872
|
function slugForPath(absPath) {
|
|
64898
64873
|
return projectDirNameFor(absPath);
|
|
@@ -64902,7 +64877,7 @@ function transcriptPathFor(cwd, sessionUuid, projectsRoot = projectsDir()) {
|
|
|
64902
64877
|
try {
|
|
64903
64878
|
real = realpathSync4(cwd);
|
|
64904
64879
|
} catch {}
|
|
64905
|
-
return
|
|
64880
|
+
return join46(projectsRoot, slugForPath(real), `${sessionUuid}.jsonl`);
|
|
64906
64881
|
}
|
|
64907
64882
|
function isAgentSession(row) {
|
|
64908
64883
|
return row.entrypoint !== undefined && row.entrypoint !== "cli";
|
|
@@ -64943,22 +64918,22 @@ function getRepoContext(cwd = process.cwd()) {
|
|
|
64943
64918
|
}
|
|
64944
64919
|
function projectDirs() {
|
|
64945
64920
|
try {
|
|
64946
|
-
return
|
|
64921
|
+
return readdirSync8(projectsDir(), { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
64947
64922
|
} catch {
|
|
64948
64923
|
return [];
|
|
64949
64924
|
}
|
|
64950
64925
|
}
|
|
64951
64926
|
function sessionsIn(dirName) {
|
|
64952
|
-
const dir =
|
|
64927
|
+
const dir = join46(projectsDir(), dirName);
|
|
64953
64928
|
let names;
|
|
64954
64929
|
try {
|
|
64955
|
-
names =
|
|
64930
|
+
names = readdirSync8(dir).filter((n) => n.endsWith(".jsonl"));
|
|
64956
64931
|
} catch {
|
|
64957
64932
|
return [];
|
|
64958
64933
|
}
|
|
64959
64934
|
const rows = [];
|
|
64960
64935
|
for (const n of names) {
|
|
64961
|
-
const file =
|
|
64936
|
+
const file = join46(dir, n);
|
|
64962
64937
|
try {
|
|
64963
64938
|
const st = statSync9(file);
|
|
64964
64939
|
if (st.size === 0)
|
|
@@ -65320,7 +65295,8 @@ function findLatestSessionId(cwd = process.cwd(), sinceMs = 0) {
|
|
|
65320
65295
|
}
|
|
65321
65296
|
var ENTRYPOINT_BYTES = 8192, ACTIVE_WINDOW_MS = 120000, HEAD_BYTES, TAIL_BYTES, HARNESS_ENVELOPES, DEEP_TAIL_BYTES, RECENT_AI_TURNS = 5, RECENT_USER_TURNS = 1;
|
|
65322
65297
|
var init_session_discovery = __esm(() => {
|
|
65323
|
-
|
|
65298
|
+
init_home_dir();
|
|
65299
|
+
init_parent_session();
|
|
65324
65300
|
HEAD_BYTES = 64 * 1024;
|
|
65325
65301
|
TAIL_BYTES = 128 * 1024;
|
|
65326
65302
|
HARNESS_ENVELOPES = [
|
|
@@ -65334,8 +65310,8 @@ var init_session_discovery = __esm(() => {
|
|
|
65334
65310
|
|
|
65335
65311
|
// src/team-orchestrator.ts
|
|
65336
65312
|
import { randomBytes as randomBytes8, randomUUID as randomUUID5 } from "crypto";
|
|
65337
|
-
import { existsSync as existsSync30, mkdirSync as mkdirSync19, readFileSync as
|
|
65338
|
-
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";
|
|
65339
65315
|
function slotTerminal(e) {
|
|
65340
65316
|
if (!e.session)
|
|
65341
65317
|
return true;
|
|
@@ -65496,14 +65472,14 @@ function teamRunRowFromDisk(path, status) {
|
|
|
65496
65472
|
}
|
|
65497
65473
|
function statusMtimeMs(path) {
|
|
65498
65474
|
try {
|
|
65499
|
-
return statSync10(
|
|
65475
|
+
return statSync10(join47(path, "status.json")).mtimeMs;
|
|
65500
65476
|
} catch {
|
|
65501
65477
|
return null;
|
|
65502
65478
|
}
|
|
65503
65479
|
}
|
|
65504
65480
|
function readManifestOrNull(path) {
|
|
65505
65481
|
try {
|
|
65506
|
-
return JSON.parse(
|
|
65482
|
+
return JSON.parse(readFileSync29(join47(path, "manifest.json"), "utf-8"));
|
|
65507
65483
|
} catch {
|
|
65508
65484
|
return null;
|
|
65509
65485
|
}
|
|
@@ -65711,7 +65687,7 @@ function readTeamInputFile(inputPath) {
|
|
|
65711
65687
|
if (!existsSync30(resolved)) {
|
|
65712
65688
|
throw new Error(`Input file not found: ${resolved}`);
|
|
65713
65689
|
}
|
|
65714
|
-
const text =
|
|
65690
|
+
const text = readFileSync29(resolved, "utf-8");
|
|
65715
65691
|
if (text.trim().length === 0) {
|
|
65716
65692
|
throw new Error(`Input file is empty: ${resolved}`);
|
|
65717
65693
|
}
|
|
@@ -65721,14 +65697,14 @@ function setupSession(sessionPath, models, input) {
|
|
|
65721
65697
|
if (models.length === 0) {
|
|
65722
65698
|
throw new Error("At least one model is required");
|
|
65723
65699
|
}
|
|
65724
|
-
if (existsSync30(
|
|
65700
|
+
if (existsSync30(join47(sessionPath, "manifest.json"))) {
|
|
65725
65701
|
throw new Error(`Session already exists at ${sessionPath}. Use a new directory path or delete the existing session first.`);
|
|
65726
65702
|
}
|
|
65727
|
-
mkdirSync19(
|
|
65728
|
-
mkdirSync19(
|
|
65703
|
+
mkdirSync19(join47(sessionPath, "work"), { recursive: true });
|
|
65704
|
+
mkdirSync19(join47(sessionPath, "errors"), { recursive: true });
|
|
65729
65705
|
if (input !== undefined) {
|
|
65730
|
-
writeFileSync20(
|
|
65731
|
-
} else if (!existsSync30(
|
|
65706
|
+
writeFileSync20(join47(sessionPath, "input.md"), input, "utf-8");
|
|
65707
|
+
} else if (!existsSync30(join47(sessionPath, "input.md"))) {
|
|
65732
65708
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
65733
65709
|
}
|
|
65734
65710
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -65745,9 +65721,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
65745
65721
|
model: models[i],
|
|
65746
65722
|
assignedAt: now
|
|
65747
65723
|
};
|
|
65748
|
-
mkdirSync19(
|
|
65724
|
+
mkdirSync19(join47(sessionPath, "work", anonId), { recursive: true });
|
|
65749
65725
|
}
|
|
65750
|
-
writeFileSync20(
|
|
65726
|
+
writeFileSync20(join47(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
65751
65727
|
const status = {
|
|
65752
65728
|
startedAt: now,
|
|
65753
65729
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -65762,7 +65738,7 @@ function setupSession(sessionPath, models, input) {
|
|
|
65762
65738
|
}
|
|
65763
65739
|
]))
|
|
65764
65740
|
};
|
|
65765
|
-
writeFileSync20(
|
|
65741
|
+
writeFileSync20(join47(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
65766
65742
|
return manifest;
|
|
65767
65743
|
}
|
|
65768
65744
|
function assertValidRequirePattern(pattern) {
|
|
@@ -65822,9 +65798,9 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65822
65798
|
if (!flagCheck.ok)
|
|
65823
65799
|
throw new Error(`invalid_args: ${flagCheck.message}`);
|
|
65824
65800
|
const path = resolve4(sessionPath);
|
|
65825
|
-
const manifest = JSON.parse(
|
|
65826
|
-
const statusPath =
|
|
65827
|
-
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");
|
|
65828
65804
|
const readAvailable = !flagsRemoveRead(claudeFlags);
|
|
65829
65805
|
const refusal = deliveryRefusal(inputContent, readAvailable);
|
|
65830
65806
|
if (refusal)
|
|
@@ -65834,7 +65810,7 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65834
65810
|
const kind = opts.kind ?? "run";
|
|
65835
65811
|
const spawnPlan = await (opts.spawnPlanner ?? prehydrateCredentialsForSpawn)(Object.values(manifest.models).map((m) => m.model));
|
|
65836
65812
|
await assertMagmuxAvailable();
|
|
65837
|
-
const statusCache = JSON.parse(
|
|
65813
|
+
const statusCache = JSON.parse(readFileSync29(statusPath, "utf-8"));
|
|
65838
65814
|
const startMs = Date.now();
|
|
65839
65815
|
const runId = mintRunId(path, startMs);
|
|
65840
65816
|
statusCache.runId = runId;
|
|
@@ -65862,13 +65838,13 @@ async function startModelsIn(flight, sessionPath, opts) {
|
|
|
65862
65838
|
mkdirSync19(statsDir(path), { recursive: true });
|
|
65863
65839
|
const entries = new Map;
|
|
65864
65840
|
let run = null;
|
|
65865
|
-
const errorLogPathOf = (id) =>
|
|
65866
|
-
const upstreamLogOf = (id) =>
|
|
65841
|
+
const errorLogPathOf = (id) => join47(path, "errors", `${id}.log`);
|
|
65842
|
+
const upstreamLogOf = (id) => join47(path, "errors", `${id}-upstream.jsonl`);
|
|
65867
65843
|
const commandOf = (e) => ["claudish", "-i", "--model", e.spawnModel ?? e.model, "-y", "--quiet", ...claudeFlags].join(" ");
|
|
65868
65844
|
function writeResponse(e, text) {
|
|
65869
65845
|
e.answer = text;
|
|
65870
65846
|
try {
|
|
65871
|
-
writeFileSync20(
|
|
65847
|
+
writeFileSync20(join47(path, `response-${e.id}.md`), text, "utf-8");
|
|
65872
65848
|
} catch (err) {
|
|
65873
65849
|
persistErrorLog(errorLogPathOf(e.id), `response file not written: ${String(err)}`, []);
|
|
65874
65850
|
}
|
|
@@ -66199,20 +66175,20 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
66199
66175
|
const active = activeRunAt(resolve4(sessionPath));
|
|
66200
66176
|
if (active)
|
|
66201
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`);
|
|
66202
|
-
const responseFiles =
|
|
66178
|
+
const responseFiles = readdirSync9(sessionPath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
66203
66179
|
if (responseFiles.length < 2) {
|
|
66204
66180
|
throw new Error(`Need at least 2 responses to judge, found ${responseFiles.length}`);
|
|
66205
66181
|
}
|
|
66206
66182
|
const responses = {};
|
|
66207
66183
|
for (const file of responseFiles) {
|
|
66208
66184
|
const id = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
66209
|
-
responses[id] =
|
|
66185
|
+
responses[id] = readFileSync29(join47(sessionPath, file), "utf-8");
|
|
66210
66186
|
}
|
|
66211
|
-
const input =
|
|
66187
|
+
const input = readFileSync29(join47(sessionPath, "input.md"), "utf-8");
|
|
66212
66188
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
66213
|
-
writeFileSync20(
|
|
66189
|
+
writeFileSync20(join47(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
66214
66190
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
66215
|
-
const judgePath =
|
|
66191
|
+
const judgePath = join47(sessionPath, "judging");
|
|
66216
66192
|
mkdirSync19(judgePath, { recursive: true });
|
|
66217
66193
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
66218
66194
|
await runModels(judgePath, {
|
|
@@ -66223,11 +66199,11 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
66223
66199
|
});
|
|
66224
66200
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
66225
66201
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
66226
|
-
writeFileSync20(
|
|
66202
|
+
writeFileSync20(join47(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
66227
66203
|
return verdict;
|
|
66228
66204
|
}
|
|
66229
66205
|
function getStatus(sessionPath) {
|
|
66230
|
-
return JSON.parse(
|
|
66206
|
+
return JSON.parse(readFileSync29(join47(sessionPath, "status.json"), "utf-8"));
|
|
66231
66207
|
}
|
|
66232
66208
|
function readTeamStatus(sessionPath) {
|
|
66233
66209
|
try {
|
|
@@ -66263,7 +66239,7 @@ function fisherYatesShuffle(arr) {
|
|
|
66263
66239
|
return arr;
|
|
66264
66240
|
}
|
|
66265
66241
|
function getDefaultJudgeModels(sessionPath) {
|
|
66266
|
-
const manifest = JSON.parse(
|
|
66242
|
+
const manifest = JSON.parse(readFileSync29(join47(sessionPath, "manifest.json"), "utf-8"));
|
|
66267
66243
|
return Object.values(manifest.models).map((e) => e.model);
|
|
66268
66244
|
}
|
|
66269
66245
|
function buildJudgePrompt(input, responses) {
|
|
@@ -66321,12 +66297,12 @@ function buildJudgePrompt(input, responses) {
|
|
|
66321
66297
|
}
|
|
66322
66298
|
function parseJudgeVotes(judgePath, responseIds) {
|
|
66323
66299
|
const votes = [];
|
|
66324
|
-
const responseFiles =
|
|
66300
|
+
const responseFiles = readdirSync9(judgePath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
66325
66301
|
for (const file of responseFiles) {
|
|
66326
66302
|
const judgeId = file.replace(/^response-/, "").replace(/\.md$/, "");
|
|
66327
66303
|
let content;
|
|
66328
66304
|
try {
|
|
66329
|
-
content =
|
|
66305
|
+
content = readFileSync29(join47(judgePath, file), "utf-8");
|
|
66330
66306
|
} catch {
|
|
66331
66307
|
continue;
|
|
66332
66308
|
}
|
|
@@ -66378,7 +66354,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
66378
66354
|
function formatVerdict(verdict, sessionPath) {
|
|
66379
66355
|
let manifest = null;
|
|
66380
66356
|
try {
|
|
66381
|
-
manifest = JSON.parse(
|
|
66357
|
+
manifest = JSON.parse(readFileSync29(join47(sessionPath, "manifest.json"), "utf-8"));
|
|
66382
66358
|
} catch {}
|
|
66383
66359
|
let output = `# Team Verdict
|
|
66384
66360
|
|
|
@@ -66434,13 +66410,13 @@ import {
|
|
|
66434
66410
|
existsSync as existsSync31,
|
|
66435
66411
|
mkdirSync as mkdirSync20,
|
|
66436
66412
|
openSync as openSync9,
|
|
66437
|
-
readFileSync as
|
|
66413
|
+
readFileSync as readFileSync30,
|
|
66438
66414
|
readSync as readSync4,
|
|
66439
66415
|
renameSync as renameSync4,
|
|
66440
66416
|
statSync as statSync11,
|
|
66441
66417
|
writeFileSync as writeFileSync21
|
|
66442
66418
|
} from "fs";
|
|
66443
|
-
import { join as
|
|
66419
|
+
import { join as join48, resolve as resolve5, sep } from "path";
|
|
66444
66420
|
function normaliseTimeoutSeconds(raw) {
|
|
66445
66421
|
const n = typeof raw === "string" && raw.trim() !== "" ? Number(raw) : raw;
|
|
66446
66422
|
if (typeof n !== "number" || !Number.isFinite(n))
|
|
@@ -66587,7 +66563,7 @@ function readJsonObject(path, maxBytes) {
|
|
|
66587
66563
|
try {
|
|
66588
66564
|
if (fileSize2(path) > maxBytes)
|
|
66589
66565
|
return null;
|
|
66590
|
-
const parsed = JSON.parse(
|
|
66566
|
+
const parsed = JSON.parse(readFileSync30(path, "utf-8"));
|
|
66591
66567
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
66592
66568
|
return null;
|
|
66593
66569
|
return parsed;
|
|
@@ -66613,7 +66589,7 @@ function dropLeadingFragment(tail) {
|
|
|
66613
66589
|
return firstBreak === -1 ? tail.text : tail.text.slice(firstBreak + 1);
|
|
66614
66590
|
}
|
|
66615
66591
|
function diskAccounting(sessionDir) {
|
|
66616
|
-
const stats = readTokenStatsAt(
|
|
66592
|
+
const stats = readTokenStatsAt(join48(sessionDir, "tokens.json"));
|
|
66617
66593
|
return {
|
|
66618
66594
|
tokensIn: stats?.billed_input_tokens ?? null,
|
|
66619
66595
|
tokensOut: stats?.output_tokens ?? null,
|
|
@@ -66686,7 +66662,7 @@ class SessionManager {
|
|
|
66686
66662
|
let dir = "";
|
|
66687
66663
|
for (let attempt = 0;; attempt++) {
|
|
66688
66664
|
id = `team-${randomUUID6().replace(/-/g, "").slice(0, 8)}`;
|
|
66689
|
-
dir =
|
|
66665
|
+
dir = join48(this.sessionsDir, id);
|
|
66690
66666
|
try {
|
|
66691
66667
|
mkdirSync20(dir);
|
|
66692
66668
|
break;
|
|
@@ -66718,9 +66694,9 @@ class SessionManager {
|
|
|
66718
66694
|
if (dir === null)
|
|
66719
66695
|
throw new Error("not a record id");
|
|
66720
66696
|
const completedAt = new Date().toISOString();
|
|
66721
|
-
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;
|
|
66722
66698
|
const elapsedMs = Date.parse(completedAt) - Date.parse(startedAt);
|
|
66723
|
-
writeJsonAtomic(
|
|
66699
|
+
writeJsonAtomic(join48(dir, "meta.json"), {
|
|
66724
66700
|
kind: "team",
|
|
66725
66701
|
status: outcome.status,
|
|
66726
66702
|
startedAt,
|
|
@@ -66752,7 +66728,7 @@ class SessionManager {
|
|
|
66752
66728
|
startedAt,
|
|
66753
66729
|
...rest
|
|
66754
66730
|
};
|
|
66755
|
-
writeJsonAtomic(
|
|
66731
|
+
writeJsonAtomic(join48(dir, "spawn.json"), body);
|
|
66756
66732
|
}
|
|
66757
66733
|
async createSession(opts) {
|
|
66758
66734
|
if (this.activeSessions + this.starting >= this.maxSessions) {
|
|
@@ -66811,10 +66787,10 @@ class SessionManager {
|
|
|
66811
66787
|
const claudeSessionId = randomUUID6();
|
|
66812
66788
|
const timeout = normaliseTimeoutSeconds(opts.timeoutSeconds);
|
|
66813
66789
|
const startedAt = new Date().toISOString();
|
|
66814
|
-
const sessionDir = opts.sessionDir ??
|
|
66790
|
+
const sessionDir = opts.sessionDir ?? join48(this.sessionsDir, sessionId);
|
|
66815
66791
|
mkdirSync20(sessionDir, { recursive: true });
|
|
66816
66792
|
if (opts.prompt)
|
|
66817
|
-
writeFileSync21(
|
|
66793
|
+
writeFileSync21(join48(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
66818
66794
|
this.writeSpawnRecord(sessionDir, {
|
|
66819
66795
|
kind: "session",
|
|
66820
66796
|
sessionId,
|
|
@@ -66827,7 +66803,7 @@ class SessionManager {
|
|
|
66827
66803
|
const cwd = opts.cwd ?? process.cwd();
|
|
66828
66804
|
const parentEnv = opts.parentEnv ?? this.parentEnv;
|
|
66829
66805
|
const spawnModel = opts.spawnModel ?? null;
|
|
66830
|
-
const tokenFile = opts.tokenFile ??
|
|
66806
|
+
const tokenFile = opts.tokenFile ?? join48(sessionDir, "tokens.json");
|
|
66831
66807
|
return {
|
|
66832
66808
|
info: {
|
|
66833
66809
|
sessionId,
|
|
@@ -66862,17 +66838,17 @@ class SessionManager {
|
|
|
66862
66838
|
},
|
|
66863
66839
|
session: null,
|
|
66864
66840
|
scrollback: new ScrollbackBuffer(this.scrollbackCapacity),
|
|
66865
|
-
outputLogStream: createWriteStream(
|
|
66841
|
+
outputLogStream: createWriteStream(join48(sessionDir, "output.log")),
|
|
66866
66842
|
sessionDir,
|
|
66867
66843
|
cwd,
|
|
66868
66844
|
tokenFile,
|
|
66869
|
-
eventLogPath:
|
|
66845
|
+
eventLogPath: join48(sessionDir, "events.jsonl"),
|
|
66870
66846
|
eventLogBytes: 0,
|
|
66871
|
-
upstreamErrorLogPath:
|
|
66847
|
+
upstreamErrorLogPath: join48(sessionDir, "upstream-errors.jsonl"),
|
|
66872
66848
|
eventRing: [],
|
|
66873
66849
|
proseBytes: 0,
|
|
66874
|
-
answeredTurns: new
|
|
66875
|
-
waitLogPath:
|
|
66850
|
+
answeredTurns: new Map,
|
|
66851
|
+
waitLogPath: join48(sessionDir, "waits.jsonl"),
|
|
66876
66852
|
waitLogBytes: 0,
|
|
66877
66853
|
waitSince: null,
|
|
66878
66854
|
ended: false,
|
|
@@ -67020,7 +66996,7 @@ class SessionManager {
|
|
|
67020
66996
|
try {
|
|
67021
66997
|
const text = screenLines.join(`
|
|
67022
66998
|
`).replace(/\s+$/, "");
|
|
67023
|
-
writeFileSync21(
|
|
66999
|
+
writeFileSync21(join48(entry.sessionDir, "screen.txt"), `${redactSecrets2(text)}
|
|
67024
67000
|
`, "utf-8");
|
|
67025
67001
|
} catch {}
|
|
67026
67002
|
}
|
|
@@ -67034,7 +67010,7 @@ class SessionManager {
|
|
|
67034
67010
|
entry.waitSince = null;
|
|
67035
67011
|
}
|
|
67036
67012
|
try {
|
|
67037
|
-
writeJsonAtomic(
|
|
67013
|
+
writeJsonAtomic(join48(entry.sessionDir, "meta.json"), toMetaRecord(entry.info, entry.cwd));
|
|
67038
67014
|
} catch (err) {
|
|
67039
67015
|
process.stderr.write(`[claudish] session ${entry.info.sessionId}: could not write meta.json: ` + `${err instanceof Error ? err.message : String(err)}
|
|
67040
67016
|
`);
|
|
@@ -67234,6 +67210,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67234
67210
|
screenTail: "",
|
|
67235
67211
|
sockPath: null,
|
|
67236
67212
|
magmuxStderr: "",
|
|
67213
|
+
registry: null,
|
|
67237
67214
|
preambleBytes: 0,
|
|
67238
67215
|
readCoverage: null,
|
|
67239
67216
|
claudeCodeVersion: null,
|
|
@@ -67247,6 +67224,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67247
67224
|
screenTail: redactSecrets2(snap.screenTail),
|
|
67248
67225
|
sockPath: session.sockPath,
|
|
67249
67226
|
magmuxStderr: redactSecrets2(pane.magmuxStderr),
|
|
67227
|
+
registry: pane.registry,
|
|
67250
67228
|
preambleBytes: pane.preambleBytes,
|
|
67251
67229
|
readCoverage: pane.readCoverage,
|
|
67252
67230
|
claudeCodeVersion: snap.claudeCodeVersion,
|
|
@@ -67319,7 +67297,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67319
67297
|
return null;
|
|
67320
67298
|
const root = resolve5(this.sessionsDir);
|
|
67321
67299
|
const dir = resolve5(root, sessionId);
|
|
67322
|
-
if (dir !==
|
|
67300
|
+
if (dir !== join48(root, sessionId))
|
|
67323
67301
|
return null;
|
|
67324
67302
|
if (!dir.startsWith(root + sep))
|
|
67325
67303
|
return null;
|
|
@@ -67338,10 +67316,10 @@ ${entry.blockText}` : ""}`;
|
|
|
67338
67316
|
} catch {
|
|
67339
67317
|
return null;
|
|
67340
67318
|
}
|
|
67341
|
-
const spawnRecord = readJsonObject(
|
|
67319
|
+
const spawnRecord = readJsonObject(join48(sessionDir, "spawn.json"), META_READ_LIMIT);
|
|
67342
67320
|
if (spawnRecord?.kind === "team")
|
|
67343
67321
|
return null;
|
|
67344
|
-
const meta = readJsonObject(
|
|
67322
|
+
const meta = readJsonObject(join48(sessionDir, "meta.json"), META_READ_LIMIT);
|
|
67345
67323
|
if (meta?.kind === "team")
|
|
67346
67324
|
return null;
|
|
67347
67325
|
const partial = meta === null;
|
|
@@ -67363,7 +67341,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67363
67341
|
return stored;
|
|
67364
67342
|
}
|
|
67365
67343
|
diskOutput(record, tailLines) {
|
|
67366
|
-
const tail = readTailText(
|
|
67344
|
+
const tail = readTailText(join48(record.sessionDir, "output.log"), OUTPUT_TAIL_BYTES);
|
|
67367
67345
|
const buffer = new ScrollbackBuffer(this.scrollbackCapacity);
|
|
67368
67346
|
if (tail?.text)
|
|
67369
67347
|
buffer.append(dropLeadingFragment(tail));
|
|
@@ -67383,12 +67361,12 @@ ${entry.blockText}` : ""}`;
|
|
|
67383
67361
|
}
|
|
67384
67362
|
diskDiagnostics(record, limit) {
|
|
67385
67363
|
const { sessionDir, info } = record;
|
|
67386
|
-
const eventLogPath =
|
|
67387
|
-
const upstreamErrorLogPath =
|
|
67388
|
-
const outputLogPath =
|
|
67364
|
+
const eventLogPath = join48(sessionDir, "events.jsonl");
|
|
67365
|
+
const upstreamErrorLogPath = join48(sessionDir, "upstream-errors.jsonl");
|
|
67366
|
+
const outputLogPath = join48(sessionDir, "output.log");
|
|
67389
67367
|
const events = readTailLines(eventLogPath, EVENT_TAIL_BYTES);
|
|
67390
67368
|
const outputTail = readTailText(outputLogPath, OUTPUT_TAIL_BYTES);
|
|
67391
|
-
const screen = readTailText(
|
|
67369
|
+
const screen = readTailText(join48(sessionDir, "screen.txt"), SCREEN_READ_BYTES);
|
|
67392
67370
|
return {
|
|
67393
67371
|
sessionId: info.sessionId,
|
|
67394
67372
|
state: info.state,
|
|
@@ -67416,6 +67394,7 @@ ${entry.blockText}` : ""}`;
|
|
|
67416
67394
|
pane: info.pane,
|
|
67417
67395
|
sockPath: null,
|
|
67418
67396
|
magmuxStderr: "",
|
|
67397
|
+
registry: null,
|
|
67419
67398
|
captureSource: info.captureSource,
|
|
67420
67399
|
turnSource: info.turnSource,
|
|
67421
67400
|
preambleBytes: 0,
|
|
@@ -67456,15 +67435,17 @@ ${entry.blockText}` : ""}`;
|
|
|
67456
67435
|
entry.info.elapsedSeconds = elapsedSecondsBetween(entry.info.startedAt, Date.now());
|
|
67457
67436
|
}
|
|
67458
67437
|
appendAnswer(entry, index, answer) {
|
|
67459
|
-
|
|
67438
|
+
const prior = entry.answeredTurns.get(index);
|
|
67439
|
+
if (prior !== undefined && (answer.length <= prior.length || !answer.startsWith(prior)))
|
|
67460
67440
|
return;
|
|
67461
|
-
entry.answeredTurns.
|
|
67462
|
-
|
|
67441
|
+
entry.answeredTurns.set(index, answer);
|
|
67442
|
+
const added = prior === undefined ? answer : answer.slice(prior.length).replace(/^\n+/, "");
|
|
67443
|
+
if (!added)
|
|
67463
67444
|
return;
|
|
67464
|
-
const text =
|
|
67465
|
-
`) ?
|
|
67445
|
+
const text = added.endsWith(`
|
|
67446
|
+
`) ? added : `${added}
|
|
67466
67447
|
`;
|
|
67467
|
-
entry.proseBytes += Buffer.byteLength(
|
|
67448
|
+
entry.proseBytes += Buffer.byteLength(added, "utf-8");
|
|
67468
67449
|
this.appendToOutput(entry, text);
|
|
67469
67450
|
}
|
|
67470
67451
|
recordNote(entry, note) {
|
|
@@ -67625,7 +67606,7 @@ var init_session_manager = __esm(() => {
|
|
|
67625
67606
|
init_team_orchestrator();
|
|
67626
67607
|
init_team_stats();
|
|
67627
67608
|
init_home_dir();
|
|
67628
|
-
|
|
67609
|
+
init_parent_session();
|
|
67629
67610
|
init_scrollback_buffer();
|
|
67630
67611
|
TERMINAL_RETENTION_MS = 30 * 60000;
|
|
67631
67612
|
EVENT_LOG_LIMIT = 4 * 1024 * 1024;
|
|
@@ -67744,14 +67725,14 @@ var init_progress_heartbeat = __esm(() => {
|
|
|
67744
67725
|
});
|
|
67745
67726
|
|
|
67746
67727
|
// src/mcp-server.ts
|
|
67747
|
-
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";
|
|
67748
67729
|
import { homedir as homedir33 } from "os";
|
|
67749
|
-
import { dirname as dirname14, join as
|
|
67730
|
+
import { dirname as dirname14, join as join49, resolve as resolve6 } from "path";
|
|
67750
67731
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
67751
67732
|
async function loadAllModels(forceRefresh = false) {
|
|
67752
67733
|
if (!forceRefresh && existsSync32(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
67753
67734
|
try {
|
|
67754
|
-
const cacheData = JSON.parse(
|
|
67735
|
+
const cacheData = JSON.parse(readFileSync31(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
67755
67736
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
67756
67737
|
const ageInDays = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
67757
67738
|
if (ageInDays <= CACHE_MAX_AGE_DAYS) {
|
|
@@ -67770,7 +67751,7 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
67770
67751
|
return models;
|
|
67771
67752
|
} catch {
|
|
67772
67753
|
if (existsSync32(OPENROUTER_MODELS_CACHE_PATH)) {
|
|
67773
|
-
const cacheData = JSON.parse(
|
|
67754
|
+
const cacheData = JSON.parse(readFileSync31(OPENROUTER_MODELS_CACHE_PATH, "utf-8"));
|
|
67774
67755
|
return cacheData.models || [];
|
|
67775
67756
|
}
|
|
67776
67757
|
return [];
|
|
@@ -68623,8 +68604,8 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68623
68604
|
const promptText = () => {
|
|
68624
68605
|
if (input !== undefined)
|
|
68625
68606
|
return input;
|
|
68626
|
-
const existing =
|
|
68627
|
-
return existsSync32(existing) ?
|
|
68607
|
+
const existing = join49(resolved, "input.md");
|
|
68608
|
+
return existsSync32(existing) ? readFileSync31(existing, "utf-8") : undefined;
|
|
68628
68609
|
};
|
|
68629
68610
|
switch (mode) {
|
|
68630
68611
|
case "run": {
|
|
@@ -68638,8 +68619,7 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68638
68619
|
requirePattern
|
|
68639
68620
|
});
|
|
68640
68621
|
setupSession(resolved, models, input);
|
|
68641
|
-
const parentClaudeSessionId = await
|
|
68642
|
-
toolUseId: ctx.toolUseId,
|
|
68622
|
+
const parentClaudeSessionId = await parentSessionForCall({
|
|
68643
68623
|
hostPid: sessionManager.hostPid
|
|
68644
68624
|
});
|
|
68645
68625
|
const monitorRecord = sessionManager.recordTeamRun({
|
|
@@ -68775,7 +68755,7 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68775
68755
|
let stderrFull = stderr_snippet || "";
|
|
68776
68756
|
if (error_log_path) {
|
|
68777
68757
|
try {
|
|
68778
|
-
stderrFull =
|
|
68758
|
+
stderrFull = readFileSync31(error_log_path, "utf-8");
|
|
68779
68759
|
} catch {}
|
|
68780
68760
|
}
|
|
68781
68761
|
const sessionData = {};
|
|
@@ -68783,26 +68763,26 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68783
68763
|
const sp = session_path;
|
|
68784
68764
|
for (const file of ["status.json", "manifest.json", "input.md"]) {
|
|
68785
68765
|
try {
|
|
68786
|
-
sessionData[file] =
|
|
68766
|
+
sessionData[file] = readFileSync31(join49(sp, file), "utf-8");
|
|
68787
68767
|
} catch {}
|
|
68788
68768
|
}
|
|
68789
68769
|
try {
|
|
68790
|
-
const errorDir =
|
|
68770
|
+
const errorDir = join49(sp, "errors");
|
|
68791
68771
|
if (existsSync32(errorDir)) {
|
|
68792
|
-
for (const f of
|
|
68772
|
+
for (const f of readdirSync10(errorDir)) {
|
|
68793
68773
|
if (f.endsWith(".log")) {
|
|
68794
68774
|
try {
|
|
68795
|
-
sessionData[`errors/${f}`] =
|
|
68775
|
+
sessionData[`errors/${f}`] = readFileSync31(join49(errorDir, f), "utf-8");
|
|
68796
68776
|
} catch {}
|
|
68797
68777
|
}
|
|
68798
68778
|
}
|
|
68799
68779
|
}
|
|
68800
68780
|
} catch {}
|
|
68801
68781
|
try {
|
|
68802
|
-
for (const f of
|
|
68782
|
+
for (const f of readdirSync10(sp)) {
|
|
68803
68783
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
68804
68784
|
try {
|
|
68805
|
-
const content =
|
|
68785
|
+
const content = readFileSync31(join49(sp, f), "utf-8");
|
|
68806
68786
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
68807
68787
|
} catch {}
|
|
68808
68788
|
}
|
|
@@ -68811,9 +68791,9 @@ Use with: run_prompt(model="${suggested}", prompt="your prompt")`;
|
|
|
68811
68791
|
}
|
|
68812
68792
|
let version = "unknown";
|
|
68813
68793
|
try {
|
|
68814
|
-
const pkgPath =
|
|
68794
|
+
const pkgPath = join49(__dirname3, "../package.json");
|
|
68815
68795
|
if (existsSync32(pkgPath)) {
|
|
68816
|
-
version = JSON.parse(
|
|
68796
|
+
version = JSON.parse(readFileSync31(pkgPath, "utf-8")).version;
|
|
68817
68797
|
}
|
|
68818
68798
|
} catch {}
|
|
68819
68799
|
const report = {
|
|
@@ -68925,7 +68905,7 @@ Report manually at https://github.com/anthropics/claudish/issues${autoSendHint}`
|
|
|
68925
68905
|
required: ["model"]
|
|
68926
68906
|
},
|
|
68927
68907
|
group: "channel",
|
|
68928
|
-
handler: async (args
|
|
68908
|
+
handler: async (args) => {
|
|
68929
68909
|
try {
|
|
68930
68910
|
const claudishFlags = buildChildClaudeFlags(args.agent, args.claude_flags) ?? [];
|
|
68931
68911
|
const flagCheck = checkChildFlags(claudishFlags);
|
|
@@ -68937,8 +68917,7 @@ Report manually at https://github.com/anthropics/claudish/issues${autoSendHint}`
|
|
|
68937
68917
|
const plan = await prehydrateCredentialsForSpawn([requestedModel], {
|
|
68938
68918
|
pin: workDir === undefined || resolve6(workDir) === process.cwd()
|
|
68939
68919
|
});
|
|
68940
|
-
const parentClaudeSessionId = await
|
|
68941
|
-
toolUseId: ctx.toolUseId,
|
|
68920
|
+
const parentClaudeSessionId = await parentSessionForCall({
|
|
68942
68921
|
hostPid: sessionManager.hostPid
|
|
68943
68922
|
});
|
|
68944
68923
|
const sessionId = await sessionManager.createSession({
|
|
@@ -69251,10 +69230,8 @@ Call get_diagnostics with session_id: "${sessionId}" for the final screen, the u
|
|
|
69251
69230
|
intervalMs: progressIntervalMs,
|
|
69252
69231
|
send: (frame) => extra.sendNotification({ method: "notifications/progress", params: frame })
|
|
69253
69232
|
}) : NOOP_HEARTBEAT;
|
|
69254
|
-
const rawToolUseId = extra._meta?.[TOOL_USE_ID_META_KEY];
|
|
69255
69233
|
const ctx = {
|
|
69256
|
-
reportProgress: (message) => heartbeat.tick(message)
|
|
69257
|
-
...typeof rawToolUseId === "string" ? { toolUseId: rawToolUseId } : {}
|
|
69234
|
+
reportProgress: (message) => heartbeat.tick(message)
|
|
69258
69235
|
};
|
|
69259
69236
|
try {
|
|
69260
69237
|
return await tool.handler(args ?? {}, ctx);
|
|
@@ -69332,7 +69309,7 @@ var init_mcp_server = __esm(() => {
|
|
|
69332
69309
|
init_prehydrate();
|
|
69333
69310
|
init_diagnostics();
|
|
69334
69311
|
init_channel();
|
|
69335
|
-
|
|
69312
|
+
init_parent_session();
|
|
69336
69313
|
init_remote_provider_types();
|
|
69337
69314
|
init_progress_heartbeat();
|
|
69338
69315
|
init_model_loader();
|
|
@@ -69353,8 +69330,8 @@ var init_mcp_server = __esm(() => {
|
|
|
69353
69330
|
import_dotenv2.config({ quiet: true });
|
|
69354
69331
|
__filename3 = fileURLToPath3(import.meta.url);
|
|
69355
69332
|
__dirname3 = dirname14(__filename3);
|
|
69356
|
-
CLAUDISH_CACHE_DIR =
|
|
69357
|
-
OPENROUTER_MODELS_CACHE_PATH =
|
|
69333
|
+
CLAUDISH_CACHE_DIR = join49(homedir33(), ".claudish");
|
|
69334
|
+
OPENROUTER_MODELS_CACHE_PATH = join49(CLAUDISH_CACHE_DIR, "openrouter-models.json");
|
|
69358
69335
|
NEXT_STEP = {
|
|
69359
69336
|
cancelled: "you stopped this slot; nothing is wrong with it. Re-run it if you still want its vote",
|
|
69360
69337
|
timeout: "grid mode only \u2014 magmux ended the pane. The orchestrator has no deadline",
|
|
@@ -69388,7 +69365,7 @@ var init_mcp_server = __esm(() => {
|
|
|
69388
69365
|
});
|
|
69389
69366
|
|
|
69390
69367
|
// src/serve-command.ts
|
|
69391
|
-
import { existsSync as existsSync33, readFileSync as
|
|
69368
|
+
import { existsSync as existsSync33, readFileSync as readFileSync32 } from "fs";
|
|
69392
69369
|
function parseServeArgs(args) {
|
|
69393
69370
|
const out = {};
|
|
69394
69371
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -69412,7 +69389,7 @@ function loadModelMap(path) {
|
|
|
69412
69389
|
}
|
|
69413
69390
|
let raw;
|
|
69414
69391
|
try {
|
|
69415
|
-
raw =
|
|
69392
|
+
raw = readFileSync32(path, "utf-8");
|
|
69416
69393
|
} catch (e) {
|
|
69417
69394
|
throw new Error(`failed to read --models file ${path}: ${e instanceof Error ? e.message : String(e)}`);
|
|
69418
69395
|
}
|
|
@@ -69487,7 +69464,7 @@ var init_serve_command = __esm(() => {
|
|
|
69487
69464
|
});
|
|
69488
69465
|
|
|
69489
69466
|
// src/behavior-command.ts
|
|
69490
|
-
import { existsSync as existsSync34, readFileSync as
|
|
69467
|
+
import { existsSync as existsSync34, readFileSync as readFileSync33, writeFileSync as writeFileSync23 } from "fs";
|
|
69491
69468
|
function severityColor(sev) {
|
|
69492
69469
|
if (sev === "fix")
|
|
69493
69470
|
return green(sev);
|
|
@@ -69586,7 +69563,7 @@ function setTelemetryEnabled(value) {
|
|
|
69586
69563
|
let cfg = {};
|
|
69587
69564
|
try {
|
|
69588
69565
|
if (existsSync34(path)) {
|
|
69589
|
-
const parsed = JSON.parse(
|
|
69566
|
+
const parsed = JSON.parse(readFileSync33(path, "utf-8"));
|
|
69590
69567
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
69591
69568
|
cfg = parsed;
|
|
69592
69569
|
}
|
|
@@ -69608,7 +69585,7 @@ function showTelemetry(action, json) {
|
|
|
69608
69585
|
try {
|
|
69609
69586
|
const path = outboxPath();
|
|
69610
69587
|
if (existsSync34(path)) {
|
|
69611
|
-
pending =
|
|
69588
|
+
pending = readFileSync33(path, "utf8").split(`
|
|
69612
69589
|
`).filter(Boolean).length;
|
|
69613
69590
|
}
|
|
69614
69591
|
} catch {}
|
|
@@ -69688,9 +69665,9 @@ var init_behavior_command = __esm(() => {
|
|
|
69688
69665
|
|
|
69689
69666
|
// src/team-grid.ts
|
|
69690
69667
|
import { spawn as spawn2 } from "child_process";
|
|
69691
|
-
import { existsSync as existsSync35, readFileSync as
|
|
69668
|
+
import { existsSync as existsSync35, readFileSync as readFileSync34, writeFileSync as writeFileSync24 } from "fs";
|
|
69692
69669
|
import { connect as netConnect2 } from "net";
|
|
69693
|
-
import { join as
|
|
69670
|
+
import { join as join50 } from "path";
|
|
69694
69671
|
import { setTimeout as wait } from "timers/promises";
|
|
69695
69672
|
function paneRouteLine(explanation) {
|
|
69696
69673
|
const origin = describeRouteExplanation(explanation);
|
|
@@ -69840,9 +69817,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69840
69817
|
const keep = opts?.keep ?? false;
|
|
69841
69818
|
const manifest = setupSession(sessionPath, models, input);
|
|
69842
69819
|
const startedAt = new Date().toISOString();
|
|
69843
|
-
const gridfilePath =
|
|
69844
|
-
const prompt =
|
|
69845
|
-
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");
|
|
69846
69823
|
const usedBannerColors = new Set;
|
|
69847
69824
|
const routeLines = mode === "interactive" ? new Map : await resolvePaneRouteLines(Object.values(manifest.models).map((entry) => entry.model));
|
|
69848
69825
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
@@ -69874,7 +69851,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69874
69851
|
});
|
|
69875
69852
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
69876
69853
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
69877
|
-
const statusPath =
|
|
69854
|
+
const statusPath = join50(sessionPath, "status.json");
|
|
69878
69855
|
writeFileSync24(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
69879
69856
|
return status;
|
|
69880
69857
|
}
|
|
@@ -69894,8 +69871,8 @@ var init_team_grid = __esm(() => {
|
|
|
69894
69871
|
});
|
|
69895
69872
|
|
|
69896
69873
|
// src/team-cli.ts
|
|
69897
|
-
import { readFileSync as
|
|
69898
|
-
import { join as
|
|
69874
|
+
import { readFileSync as readFileSync35 } from "fs";
|
|
69875
|
+
import { join as join51 } from "path";
|
|
69899
69876
|
async function runPaneTeam(sessionPath, models, input, opts) {
|
|
69900
69877
|
installPaneShutdownHooks({ exitAfter: true });
|
|
69901
69878
|
try {
|
|
@@ -70031,7 +70008,7 @@ async function teamCommand(args) {
|
|
|
70031
70008
|
}
|
|
70032
70009
|
case "judge": {
|
|
70033
70010
|
await judgeResponses(sessionPath, { judges });
|
|
70034
|
-
console.log(
|
|
70011
|
+
console.log(readFileSync35(join51(sessionPath, "verdict.md"), "utf-8"));
|
|
70035
70012
|
break;
|
|
70036
70013
|
}
|
|
70037
70014
|
case "run-and-judge": {
|
|
@@ -70047,7 +70024,7 @@ async function teamCommand(args) {
|
|
|
70047
70024
|
});
|
|
70048
70025
|
printStatus(status);
|
|
70049
70026
|
await judgeResponses(sessionPath, { judges });
|
|
70050
|
-
console.log(
|
|
70027
|
+
console.log(readFileSync35(join51(sessionPath, "verdict.md"), "utf-8"));
|
|
70051
70028
|
break;
|
|
70052
70029
|
}
|
|
70053
70030
|
case "status": {
|
|
@@ -70620,7 +70597,7 @@ var init_keychain_command = __esm(() => {
|
|
|
70620
70597
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
70621
70598
|
import { existsSync as existsSync36, unlinkSync as unlinkSync9 } from "fs";
|
|
70622
70599
|
import { homedir as homedir34 } from "os";
|
|
70623
|
-
import { join as
|
|
70600
|
+
import { join as join52 } from "path";
|
|
70624
70601
|
async function defaultSuggestModel() {
|
|
70625
70602
|
try {
|
|
70626
70603
|
const tok = readSharedAntigravityToken();
|
|
@@ -70741,7 +70718,7 @@ No session detected yet. Starting the Antigravity CLI interactively \u2014
|
|
|
70741
70718
|
async logout(deps) {
|
|
70742
70719
|
deleteSharedAntigravityToken(deps);
|
|
70743
70720
|
try {
|
|
70744
|
-
const tokenFile =
|
|
70721
|
+
const tokenFile = join52(homedir34(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
|
|
70745
70722
|
if (existsSync36(tokenFile))
|
|
70746
70723
|
unlinkSync9(tokenFile);
|
|
70747
70724
|
} catch {}
|
|
@@ -78994,14 +78971,14 @@ import {
|
|
|
78994
78971
|
existsSync as existsSync38,
|
|
78995
78972
|
mkdirSync as mkdirSync22,
|
|
78996
78973
|
openSync as openSync10,
|
|
78997
|
-
readFileSync as
|
|
78998
|
-
readdirSync as
|
|
78974
|
+
readFileSync as readFileSync36,
|
|
78975
|
+
readdirSync as readdirSync11,
|
|
78999
78976
|
statSync as statSync12,
|
|
79000
78977
|
unlinkSync as unlinkSync10,
|
|
79001
78978
|
writeFileSync as writeFileSync25
|
|
79002
78979
|
} from "fs";
|
|
79003
78980
|
import { homedir as homedir35, tmpdir as tmpdir2 } from "os";
|
|
79004
|
-
import { dirname as dirname15, join as
|
|
78981
|
+
import { dirname as dirname15, join as join53 } from "path";
|
|
79005
78982
|
import { isatty } from "tty";
|
|
79006
78983
|
function releaseTerminalIsolation() {
|
|
79007
78984
|
if (!restoreTerminal)
|
|
@@ -79066,7 +79043,7 @@ function hasResolvableAnthropicAuth(deps = {}) {
|
|
|
79066
79043
|
if (isRealAnthropicEnvCredential(env, "ANTHROPIC_API_KEY") || isRealAnthropicEnvCredential(env, "ANTHROPIC_AUTH_TOKEN")) {
|
|
79067
79044
|
return true;
|
|
79068
79045
|
}
|
|
79069
|
-
if (fileExists(
|
|
79046
|
+
if (fileExists(join53(homedir35(), ".claude", ".credentials.json")))
|
|
79070
79047
|
return true;
|
|
79071
79048
|
return keychainProbe();
|
|
79072
79049
|
}
|
|
@@ -79081,14 +79058,14 @@ function isProxyAuthMode(config) {
|
|
|
79081
79058
|
}
|
|
79082
79059
|
function managedSettingsPath() {
|
|
79083
79060
|
if (isWindows2()) {
|
|
79084
|
-
return
|
|
79061
|
+
return join53(process.env.PROGRAMDATA || "C:\\ProgramData", "ClaudeCode", "managed-settings.json");
|
|
79085
79062
|
}
|
|
79086
79063
|
if (process.platform === "darwin") {
|
|
79087
79064
|
return "/Library/Application Support/ClaudeCode/managed-settings.json";
|
|
79088
79065
|
}
|
|
79089
79066
|
return "/etc/claude-code/managed-settings.json";
|
|
79090
79067
|
}
|
|
79091
|
-
function managedSettingsForcesClaudeAi(readFile =
|
|
79068
|
+
function managedSettingsForcesClaudeAi(readFile = readFileSync36) {
|
|
79092
79069
|
try {
|
|
79093
79070
|
const raw = readFile(managedSettingsPath(), "utf-8");
|
|
79094
79071
|
const parsed = JSON.parse(raw);
|
|
@@ -79102,9 +79079,9 @@ function isWindows2() {
|
|
|
79102
79079
|
}
|
|
79103
79080
|
function createStatusLineScript(tokenFilePath) {
|
|
79104
79081
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
79105
|
-
const claudishDir =
|
|
79082
|
+
const claudishDir = join53(homeDir, ".claudish");
|
|
79106
79083
|
const timestamp = Date.now();
|
|
79107
|
-
const scriptPath =
|
|
79084
|
+
const scriptPath = join53(claudishDir, `status-${timestamp}.js`);
|
|
79108
79085
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
79109
79086
|
const light = getThemeMode() === "light";
|
|
79110
79087
|
const cyanCode = light ? "38;2;14;116;144" : "96";
|
|
@@ -79262,7 +79239,7 @@ function cleanupStaleTokenFiles(dir, now = Date.now(), maxAgeMs = STALE_TOKEN_FI
|
|
|
79262
79239
|
let removed = 0;
|
|
79263
79240
|
let entries;
|
|
79264
79241
|
try {
|
|
79265
|
-
entries =
|
|
79242
|
+
entries = readdirSync11(dir);
|
|
79266
79243
|
} catch {
|
|
79267
79244
|
return 0;
|
|
79268
79245
|
}
|
|
@@ -79274,7 +79251,7 @@ function cleanupStaleTokenFiles(dir, now = Date.now(), maxAgeMs = STALE_TOKEN_FI
|
|
|
79274
79251
|
if (!name.startsWith("tokens-") || !name.endsWith(".json"))
|
|
79275
79252
|
continue;
|
|
79276
79253
|
scanned++;
|
|
79277
|
-
const full =
|
|
79254
|
+
const full = join53(dir, name);
|
|
79278
79255
|
try {
|
|
79279
79256
|
if (statSync12(full).mtimeMs >= cutoff)
|
|
79280
79257
|
continue;
|
|
@@ -79291,7 +79268,7 @@ function parseSettingsArg(value) {
|
|
|
79291
79268
|
if (value.trimStart().startsWith("{")) {
|
|
79292
79269
|
return JSON.parse(value);
|
|
79293
79270
|
}
|
|
79294
|
-
return JSON.parse(
|
|
79271
|
+
return JSON.parse(readFileSync36(value, "utf-8"));
|
|
79295
79272
|
}
|
|
79296
79273
|
function parseSettingsArgSafe(value) {
|
|
79297
79274
|
try {
|
|
@@ -79303,9 +79280,9 @@ function parseSettingsArgSafe(value) {
|
|
|
79303
79280
|
}
|
|
79304
79281
|
function userSettingsFileCandidates(cwd) {
|
|
79305
79282
|
return [
|
|
79306
|
-
|
|
79307
|
-
|
|
79308
|
-
|
|
79283
|
+
join53(homedir35(), ".claude", "settings.json"),
|
|
79284
|
+
join53(cwd, ".claude", "settings.json"),
|
|
79285
|
+
join53(cwd, ".claude", "settings.local.json")
|
|
79309
79286
|
];
|
|
79310
79287
|
}
|
|
79311
79288
|
function discoverUserStatusLineCommand(claudeArgs = [], cwd = process.cwd()) {
|
|
@@ -79346,12 +79323,12 @@ function buildChainedStatusCommand(userCommand, claudishBody, claudishSegment) {
|
|
|
79346
79323
|
}
|
|
79347
79324
|
function createTempSettingsFile(_modelDisplay, port, proxyAuthMode, userStatusLineCommand) {
|
|
79348
79325
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
79349
|
-
const claudishDir =
|
|
79326
|
+
const claudishDir = join53(homeDir, ".claudish");
|
|
79350
79327
|
try {
|
|
79351
79328
|
mkdirSync22(claudishDir, { recursive: true });
|
|
79352
79329
|
} catch {}
|
|
79353
79330
|
const timestamp = Date.now();
|
|
79354
|
-
const tempPath =
|
|
79331
|
+
const tempPath = join53(claudishDir, `settings-${timestamp}.json`);
|
|
79355
79332
|
const assignedFile = assignedTokenFile(process.env) !== null;
|
|
79356
79333
|
const tokenFilePath = resolveTokenFilePath(port);
|
|
79357
79334
|
cleanupStaleTokenFiles(claudishDir);
|
|
@@ -79726,7 +79703,7 @@ async function runClaudeWithProxy(config, proxyUrl, onCleanup) {
|
|
|
79726
79703
|
console.error(`
|
|
79727
79704
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
79728
79705
|
const home = homedir35();
|
|
79729
|
-
const localPath = isWindows2() ?
|
|
79706
|
+
const localPath = isWindows2() ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
79730
79707
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
79731
79708
|
process.exit(1);
|
|
79732
79709
|
}
|
|
@@ -79839,15 +79816,15 @@ async function findClaudeBinary() {
|
|
|
79839
79816
|
}
|
|
79840
79817
|
}
|
|
79841
79818
|
const home = homedir35();
|
|
79842
|
-
const localPath = isWindows ?
|
|
79819
|
+
const localPath = isWindows ? join53(home, ".claude", "local", "claude.exe") : join53(home, ".claude", "local", "claude");
|
|
79843
79820
|
if (existsSync38(localPath)) {
|
|
79844
79821
|
return localPath;
|
|
79845
79822
|
}
|
|
79846
79823
|
if (isWindows) {
|
|
79847
79824
|
const windowsPaths = [
|
|
79848
|
-
|
|
79849
|
-
|
|
79850
|
-
|
|
79825
|
+
join53(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
79826
|
+
join53(home, ".npm-global", "claude.cmd"),
|
|
79827
|
+
join53(home, "node_modules", ".bin", "claude.cmd")
|
|
79851
79828
|
];
|
|
79852
79829
|
for (const path of windowsPaths) {
|
|
79853
79830
|
if (existsSync38(path)) {
|
|
@@ -79858,11 +79835,11 @@ async function findClaudeBinary() {
|
|
|
79858
79835
|
const commonPaths = [
|
|
79859
79836
|
"/usr/local/bin/claude",
|
|
79860
79837
|
"/opt/homebrew/bin/claude",
|
|
79861
|
-
|
|
79862
|
-
|
|
79863
|
-
|
|
79838
|
+
join53(home, ".npm-global/bin/claude"),
|
|
79839
|
+
join53(home, ".local/bin/claude"),
|
|
79840
|
+
join53(home, "node_modules/.bin/claude"),
|
|
79864
79841
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
79865
|
-
|
|
79842
|
+
join53(home, "../usr/bin/claude")
|
|
79866
79843
|
];
|
|
79867
79844
|
for (const path of commonPaths) {
|
|
79868
79845
|
if (existsSync38(path)) {
|
|
@@ -79947,16 +79924,16 @@ var init_claude_runner = __esm(() => {
|
|
|
79947
79924
|
// src/diag-output.ts
|
|
79948
79925
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync23, unlinkSync as unlinkSync11, writeFileSync as writeFileSync26 } from "fs";
|
|
79949
79926
|
import { homedir as homedir36 } from "os";
|
|
79950
|
-
import { join as
|
|
79927
|
+
import { join as join54 } from "path";
|
|
79951
79928
|
function getClaudishDir() {
|
|
79952
|
-
const dir =
|
|
79929
|
+
const dir = join54(homedir36(), ".claudish");
|
|
79953
79930
|
try {
|
|
79954
79931
|
mkdirSync23(dir, { recursive: true });
|
|
79955
79932
|
} catch {}
|
|
79956
79933
|
return dir;
|
|
79957
79934
|
}
|
|
79958
79935
|
function getDiagLogPath() {
|
|
79959
|
-
return
|
|
79936
|
+
return join54(getClaudishDir(), `diag-${process.pid}.log`);
|
|
79960
79937
|
}
|
|
79961
79938
|
|
|
79962
79939
|
class LogFileDiagOutput {
|
|
@@ -82160,11 +82137,11 @@ var exports_session_stats = {};
|
|
|
82160
82137
|
__export(exports_session_stats, {
|
|
82161
82138
|
readSessionStats: () => readSessionStats
|
|
82162
82139
|
});
|
|
82163
|
-
import { readFileSync as
|
|
82140
|
+
import { readFileSync as readFileSync37 } from "fs";
|
|
82164
82141
|
function readSessionStats(port, opts) {
|
|
82165
82142
|
let raw;
|
|
82166
82143
|
try {
|
|
82167
|
-
raw = JSON.parse(
|
|
82144
|
+
raw = JSON.parse(readFileSync37(resolveTokenFilePath(port), "utf-8"));
|
|
82168
82145
|
} catch {
|
|
82169
82146
|
return null;
|
|
82170
82147
|
}
|
|
@@ -82524,8 +82501,8 @@ init_op_source();
|
|
|
82524
82501
|
init_startup_trace();
|
|
82525
82502
|
init_picker_cancelled();
|
|
82526
82503
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
82527
|
-
import { existsSync as existsSync39, readFileSync as
|
|
82528
|
-
import { join as
|
|
82504
|
+
import { existsSync as existsSync39, readFileSync as readFileSync38 } from "fs";
|
|
82505
|
+
import { join as join55, resolve as resolve7 } from "path";
|
|
82529
82506
|
|
|
82530
82507
|
// src/tui/runtime/should-open-picker.ts
|
|
82531
82508
|
function noModelConfigured(gate) {
|
|
@@ -82825,14 +82802,14 @@ async function runCli() {
|
|
|
82825
82802
|
if (cliConfig.team && cliConfig.team.length > 0) {
|
|
82826
82803
|
let prompt = cliConfig.claudeArgs.join(" ");
|
|
82827
82804
|
if (cliConfig.inputFile) {
|
|
82828
|
-
prompt =
|
|
82805
|
+
prompt = readFileSync38(cliConfig.inputFile, "utf-8");
|
|
82829
82806
|
}
|
|
82830
82807
|
if (!prompt.trim()) {
|
|
82831
82808
|
console.error("Error: --team requires a prompt (positional args or -f <file>)");
|
|
82832
82809
|
process.exit(1);
|
|
82833
82810
|
}
|
|
82834
82811
|
const mode = cliConfig.teamMode ?? "default";
|
|
82835
|
-
const sessionPath =
|
|
82812
|
+
const sessionPath = join55(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
82836
82813
|
if (mode === "json") {
|
|
82837
82814
|
await Promise.resolve().then(() => init_pane());
|
|
82838
82815
|
await Promise.resolve().then(() => init_team_orchestrator());
|
|
@@ -82852,9 +82829,9 @@ async function runCli() {
|
|
|
82852
82829
|
const status = await runModels(sessionPath);
|
|
82853
82830
|
const result = { ...status, responses: {} };
|
|
82854
82831
|
for (const anonId of Object.keys(status.models)) {
|
|
82855
|
-
const responsePath =
|
|
82832
|
+
const responsePath = join55(sessionPath, `response-${anonId}.md`);
|
|
82856
82833
|
try {
|
|
82857
|
-
const raw =
|
|
82834
|
+
const raw = readFileSync38(responsePath, "utf-8").trim();
|
|
82858
82835
|
try {
|
|
82859
82836
|
result.responses[anonId] = JSON.parse(raw);
|
|
82860
82837
|
} catch {
|