@cnwenf/occ 2.1.253 → 2.1.254
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +1561 -319
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -57636,10 +57636,15 @@ var init_env = __esm(() => {
|
|
|
57636
57636
|
init_which();
|
|
57637
57637
|
getGlobalClaudeFile = memoize_default(() => {
|
|
57638
57638
|
if (getFsImplementation().existsSync(join16(getClaudeConfigHomeDir(), ".config.json"))) {
|
|
57639
|
+
process.stderr.write(`[DIAGCFG] getGlobalClaudeFile -> legacy .config.json at ${join16(getClaudeConfigHomeDir(), ".config.json")}
|
|
57640
|
+
`);
|
|
57639
57641
|
return join16(getClaudeConfigHomeDir(), ".config.json");
|
|
57640
57642
|
}
|
|
57641
57643
|
const filename = `.claude${fileSuffixForOauthConfig()}.json`;
|
|
57642
|
-
|
|
57644
|
+
const p = join16(process.env.CLAUDE_CONFIG_DIR || homedir7(), filename);
|
|
57645
|
+
process.stderr.write(`[DIAGCFG] getGlobalClaudeFile -> ${p} (homedir=${homedir7()} CLAUDE_CONFIG_DIR=${process.env.CLAUDE_CONFIG_DIR ?? "unset"})
|
|
57646
|
+
`);
|
|
57647
|
+
return p;
|
|
57643
57648
|
});
|
|
57644
57649
|
hasInternetAccess = memoize_default(async () => {
|
|
57645
57650
|
try {
|
|
@@ -363766,10 +363771,10 @@ function parseSource(source, timeoutMs) {
|
|
|
363766
363771
|
stopToken: null
|
|
363767
363772
|
};
|
|
363768
363773
|
try {
|
|
363769
|
-
const
|
|
363774
|
+
const program2 = parseProgram(P2);
|
|
363770
363775
|
if (P2.aborted)
|
|
363771
363776
|
return null;
|
|
363772
|
-
return
|
|
363777
|
+
return program2;
|
|
363773
363778
|
} catch {
|
|
363774
363779
|
return null;
|
|
363775
363780
|
}
|
|
@@ -650450,13 +650455,331 @@ var init_chromeNativeHost = __esm(() => {
|
|
|
650450
650455
|
}).passthrough());
|
|
650451
650456
|
});
|
|
650452
650457
|
|
|
650458
|
+
// src/daemon/process.ts
|
|
650459
|
+
import { execFileSync as execFileSync5 } from "child_process";
|
|
650460
|
+
function isPidAlive(pid) {
|
|
650461
|
+
if (!pid || pid <= 0)
|
|
650462
|
+
return false;
|
|
650463
|
+
try {
|
|
650464
|
+
process.kill(pid, 0);
|
|
650465
|
+
return true;
|
|
650466
|
+
} catch (err2) {
|
|
650467
|
+
return err2?.code === "EPERM";
|
|
650468
|
+
}
|
|
650469
|
+
}
|
|
650470
|
+
function getProcessStartMs(pid) {
|
|
650471
|
+
if (!pid || pid <= 0)
|
|
650472
|
+
return null;
|
|
650473
|
+
let out;
|
|
650474
|
+
try {
|
|
650475
|
+
out = execFileSync5("ps", ["-o", "lstart=", "-p", String(pid)], {
|
|
650476
|
+
encoding: "utf-8",
|
|
650477
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
650478
|
+
timeout: 2000
|
|
650479
|
+
}).trim();
|
|
650480
|
+
} catch {
|
|
650481
|
+
return null;
|
|
650482
|
+
}
|
|
650483
|
+
if (!out)
|
|
650484
|
+
return null;
|
|
650485
|
+
const ms = Date.parse(out);
|
|
650486
|
+
return Number.isFinite(ms) ? ms : null;
|
|
650487
|
+
}
|
|
650488
|
+
function pidRecycled(pid, startedAt) {
|
|
650489
|
+
if (!isPidAlive(pid)) {
|
|
650490
|
+
return false;
|
|
650491
|
+
}
|
|
650492
|
+
const actualStart = getProcessStartMs(pid);
|
|
650493
|
+
if (actualStart === null) {
|
|
650494
|
+
return false;
|
|
650495
|
+
}
|
|
650496
|
+
const tolerance = 2000;
|
|
650497
|
+
return actualStart > startedAt + tolerance;
|
|
650498
|
+
}
|
|
650499
|
+
function sigtermWorker(pid) {
|
|
650500
|
+
try {
|
|
650501
|
+
process.kill(pid, "SIGTERM");
|
|
650502
|
+
return true;
|
|
650503
|
+
} catch {
|
|
650504
|
+
return false;
|
|
650505
|
+
}
|
|
650506
|
+
}
|
|
650507
|
+
async function ensureZombieKill(pid, graceMs = 3000) {
|
|
650508
|
+
if (!isPidAlive(pid))
|
|
650509
|
+
return true;
|
|
650510
|
+
try {
|
|
650511
|
+
process.kill(pid, "SIGTERM");
|
|
650512
|
+
} catch {}
|
|
650513
|
+
const deadline = Date.now() + graceMs;
|
|
650514
|
+
while (Date.now() < deadline) {
|
|
650515
|
+
if (!isPidAlive(pid))
|
|
650516
|
+
return true;
|
|
650517
|
+
await new Promise((r4) => setTimeout(r4, 150));
|
|
650518
|
+
}
|
|
650519
|
+
try {
|
|
650520
|
+
process.kill(pid, "SIGKILL");
|
|
650521
|
+
} catch {}
|
|
650522
|
+
await new Promise((r4) => setTimeout(r4, 200));
|
|
650523
|
+
return !isPidAlive(pid);
|
|
650524
|
+
}
|
|
650525
|
+
var init_process = () => {};
|
|
650526
|
+
|
|
650453
650527
|
// src/daemon/workerRegistry.ts
|
|
650454
650528
|
var exports_workerRegistry = {};
|
|
650455
650529
|
__export(exports_workerRegistry, {
|
|
650456
|
-
|
|
650530
|
+
validateDaemonJsonWorkers: () => validateDaemonJsonWorkers,
|
|
650531
|
+
sweepWorkers: () => sweepWorkers,
|
|
650532
|
+
stopAllWorkers: () => stopAllWorkers,
|
|
650533
|
+
spawnWorker: () => spawnWorker,
|
|
650534
|
+
settleWorker: () => settleWorker,
|
|
650535
|
+
runDaemonWorker: () => runDaemonWorker,
|
|
650536
|
+
readDaemonJson: () => readDaemonJson,
|
|
650537
|
+
listWorkers: () => listWorkers,
|
|
650538
|
+
getWorker: () => getWorker,
|
|
650539
|
+
getDaemonJsonPath: () => getDaemonJsonPath,
|
|
650540
|
+
forceRespawnWorker: () => forceRespawnWorker,
|
|
650541
|
+
eStale: () => eStale,
|
|
650542
|
+
DEFAULT_PREWARM_PER_SWEEP: () => DEFAULT_PREWARM_PER_SWEEP
|
|
650543
|
+
});
|
|
650544
|
+
import { spawn as spawn13 } from "child_process";
|
|
650545
|
+
import { existsSync as existsSync15, readFileSync as readFileSync26 } from "fs";
|
|
650546
|
+
import { join as join156 } from "path";
|
|
650547
|
+
function getDaemonJsonPath() {
|
|
650548
|
+
return join156(getClaudeConfigHomeDir(), "daemon.json");
|
|
650549
|
+
}
|
|
650550
|
+
function nextWorkerId() {
|
|
650551
|
+
return `w${_nextId++}`;
|
|
650552
|
+
}
|
|
650553
|
+
function readDaemonJson() {
|
|
650554
|
+
const path28 = getDaemonJsonPath();
|
|
650555
|
+
if (!existsSync15(path28)) {
|
|
650556
|
+
return { prewarmPerSweep: DEFAULT_PREWARM_PER_SWEEP };
|
|
650557
|
+
}
|
|
650558
|
+
let raw;
|
|
650559
|
+
try {
|
|
650560
|
+
raw = readFileSync26(path28, { encoding: "utf-8" });
|
|
650561
|
+
} catch {
|
|
650562
|
+
return { prewarmPerSweep: DEFAULT_PREWARM_PER_SWEEP };
|
|
650563
|
+
}
|
|
650564
|
+
let parsed;
|
|
650565
|
+
try {
|
|
650566
|
+
parsed = JSON.parse(raw);
|
|
650567
|
+
} catch {
|
|
650568
|
+
console.error("daemon.json is malformed \u2014 ignoring worker config");
|
|
650569
|
+
logEvent("daemon_json_malformed", {});
|
|
650570
|
+
return { prewarmPerSweep: DEFAULT_PREWARM_PER_SWEEP };
|
|
650571
|
+
}
|
|
650572
|
+
const config7 = {
|
|
650573
|
+
workers: Array.isArray(parsed?.workers) ? parsed.workers : undefined,
|
|
650574
|
+
scheduled: Array.isArray(parsed?.scheduled) ? parsed.scheduled : undefined,
|
|
650575
|
+
prewarmPerSweep: typeof parsed?.prewarmPerSweep === "number" ? parsed.prewarmPerSweep : DEFAULT_PREWARM_PER_SWEEP
|
|
650576
|
+
};
|
|
650577
|
+
return config7;
|
|
650578
|
+
}
|
|
650579
|
+
function validateDaemonJsonWorkers(config7) {
|
|
650580
|
+
const warnings = [];
|
|
650581
|
+
if (!config7.workers || config7.workers.length === 0)
|
|
650582
|
+
return warnings;
|
|
650583
|
+
const knownKinds = new Set(["default", "prewarm", "remote_control"]);
|
|
650584
|
+
for (const w3 of config7.workers) {
|
|
650585
|
+
if (!w3?.kind || !knownKinds.has(w3.kind)) {
|
|
650586
|
+
warnings.push(`has configured workers but they do not match a known kind: ${w3?.kind ?? "(missing)"}`);
|
|
650587
|
+
}
|
|
650588
|
+
}
|
|
650589
|
+
return warnings;
|
|
650590
|
+
}
|
|
650591
|
+
function getCliVersion() {
|
|
650592
|
+
const macro = globalThis.MACRO;
|
|
650593
|
+
return macro?.VERSION ?? "unknown";
|
|
650594
|
+
}
|
|
650595
|
+
function spawnWorker(kind, opts) {
|
|
650596
|
+
const id = opts?.id ?? nextWorkerId();
|
|
650597
|
+
const cwd2 = opts?.cwd ?? getCwd();
|
|
650598
|
+
const entry = process.argv[1] ?? "dist/cli.js";
|
|
650599
|
+
const existing = registry2.get(id);
|
|
650600
|
+
if (existing && isPidAlive(existing.pid)) {
|
|
650601
|
+
sigtermWorker(existing.pid);
|
|
650602
|
+
}
|
|
650603
|
+
const child = spawn13(process.execPath, [entry, "--daemon-worker", kind], {
|
|
650604
|
+
cwd: cwd2,
|
|
650605
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
650606
|
+
detached: false,
|
|
650607
|
+
env: {
|
|
650608
|
+
...process.env,
|
|
650609
|
+
CLAUDE_CODE_DAEMON_WORKER: "1",
|
|
650610
|
+
CLAUDE_CODE_DAEMON_WORKER_KIND: kind
|
|
650611
|
+
}
|
|
650612
|
+
});
|
|
650613
|
+
const record3 = {
|
|
650614
|
+
pid: child.pid ?? -1,
|
|
650615
|
+
outcome: "running",
|
|
650616
|
+
cliVersion: getCliVersion(),
|
|
650617
|
+
startedAt: Date.now(),
|
|
650618
|
+
cwd: cwd2,
|
|
650619
|
+
restart: existing?.restart ?? 0,
|
|
650620
|
+
kind,
|
|
650621
|
+
id
|
|
650622
|
+
};
|
|
650623
|
+
registry2.set(id, record3);
|
|
650624
|
+
children2.set(id, child);
|
|
650625
|
+
child.on("exit", (code, signal) => {
|
|
650626
|
+
const rec = registry2.get(id);
|
|
650627
|
+
if (!rec)
|
|
650628
|
+
return;
|
|
650629
|
+
rec.exitCode = code ?? undefined;
|
|
650630
|
+
if (signal === "SIGTERM")
|
|
650631
|
+
rec.outcome = "sigterm";
|
|
650632
|
+
else if (signal === "SIGKILL")
|
|
650633
|
+
rec.outcome = "sigkill";
|
|
650634
|
+
else if (code === 0)
|
|
650635
|
+
rec.outcome = "exited_clean";
|
|
650636
|
+
else
|
|
650637
|
+
rec.outcome = "exited_error";
|
|
650638
|
+
children2.delete(id);
|
|
650639
|
+
});
|
|
650640
|
+
child.on("error", () => {
|
|
650641
|
+
const rec = registry2.get(id);
|
|
650642
|
+
if (rec)
|
|
650643
|
+
rec.outcome = "exited_error";
|
|
650644
|
+
children2.delete(id);
|
|
650645
|
+
});
|
|
650646
|
+
return record3;
|
|
650647
|
+
}
|
|
650648
|
+
async function settleWorker(id, graceMs = 3000) {
|
|
650649
|
+
const rec = registry2.get(id);
|
|
650650
|
+
if (!rec)
|
|
650651
|
+
return;
|
|
650652
|
+
const child = children2.get(id);
|
|
650653
|
+
if (child && isPidAlive(rec.pid)) {
|
|
650654
|
+
sigtermWorker(rec.pid);
|
|
650655
|
+
const deadline = Date.now() + graceMs;
|
|
650656
|
+
while (Date.now() < deadline) {
|
|
650657
|
+
if (!isPidAlive(rec.pid))
|
|
650658
|
+
break;
|
|
650659
|
+
await new Promise((r4) => setTimeout(r4, 100));
|
|
650660
|
+
}
|
|
650661
|
+
}
|
|
650662
|
+
if (rec && isPidAlive(rec.pid)) {
|
|
650663
|
+
rec.outcome = "stalled";
|
|
650664
|
+
}
|
|
650665
|
+
}
|
|
650666
|
+
function listWorkers() {
|
|
650667
|
+
return Array.from(registry2.values());
|
|
650668
|
+
}
|
|
650669
|
+
function getWorker(id) {
|
|
650670
|
+
return registry2.get(id);
|
|
650671
|
+
}
|
|
650672
|
+
async function sweepWorkers(config7) {
|
|
650673
|
+
const prewarmPerSweep = config7.prewarmPerSweep ?? DEFAULT_PREWARM_PER_SWEEP;
|
|
650674
|
+
let alive = 0;
|
|
650675
|
+
for (const rec of registry2.values()) {
|
|
650676
|
+
if (rec.outcome !== "running")
|
|
650677
|
+
continue;
|
|
650678
|
+
if (!isPidAlive(rec.pid)) {
|
|
650679
|
+
rec.outcome = "exited_clean";
|
|
650680
|
+
continue;
|
|
650681
|
+
}
|
|
650682
|
+
if (pidRecycled(rec.pid, rec.startedAt)) {
|
|
650683
|
+
rec.outcome = "stalled";
|
|
650684
|
+
eStale(rec, "pid_recycled");
|
|
650685
|
+
continue;
|
|
650686
|
+
}
|
|
650687
|
+
alive++;
|
|
650688
|
+
}
|
|
650689
|
+
const prewarmAlive = Array.from(registry2.values()).filter((w3) => w3.kind === "prewarm" && w3.outcome === "running" && isPidAlive(w3.pid)).length;
|
|
650690
|
+
const toPrewarm = Math.max(0, prewarmPerSweep - prewarmAlive);
|
|
650691
|
+
for (let i6 = 0;i6 < toPrewarm; i6++) {
|
|
650692
|
+
const rec = spawnWorker("prewarm");
|
|
650693
|
+
logEvent("tengu_bg_prewarm_per_sweep", {
|
|
650694
|
+
kind: "prewarm",
|
|
650695
|
+
pid: rec.pid
|
|
650696
|
+
});
|
|
650697
|
+
}
|
|
650698
|
+
if (config7.workers) {
|
|
650699
|
+
for (const w3 of config7.workers) {
|
|
650700
|
+
const kind = w3.kind;
|
|
650701
|
+
const has2 = Array.from(registry2.values()).some((r4) => r4.kind === kind && r4.outcome === "running" && isPidAlive(r4.pid));
|
|
650702
|
+
if (!has2) {
|
|
650703
|
+
spawnWorker(kind, { cwd: w3?.["cwd"] });
|
|
650704
|
+
}
|
|
650705
|
+
}
|
|
650706
|
+
}
|
|
650707
|
+
return alive;
|
|
650708
|
+
}
|
|
650709
|
+
function eStale(rec, reason) {
|
|
650710
|
+
rec.outcome = "stalled";
|
|
650711
|
+
logEvent("tengu_bg_worker_stale", {
|
|
650712
|
+
kind: rec.kind,
|
|
650713
|
+
reason,
|
|
650714
|
+
pid: rec.pid,
|
|
650715
|
+
restart: rec.restart
|
|
650716
|
+
});
|
|
650717
|
+
const fresh = spawnWorker(rec.kind, { cwd: rec.cwd });
|
|
650718
|
+
fresh.restart = rec.restart + 1;
|
|
650719
|
+
registry2.set(fresh.id, fresh);
|
|
650720
|
+
}
|
|
650721
|
+
async function stopAllWorkers(graceMs = 3000) {
|
|
650722
|
+
const ids = Array.from(registry2.keys());
|
|
650723
|
+
await Promise.all(ids.map((id) => settleWorker(id, graceMs)));
|
|
650724
|
+
registry2.clear();
|
|
650725
|
+
children2.clear();
|
|
650726
|
+
}
|
|
650727
|
+
function forceRespawnWorker(id) {
|
|
650728
|
+
const rec = registry2.get(id);
|
|
650729
|
+
if (!rec)
|
|
650730
|
+
return null;
|
|
650731
|
+
if (isPidAlive(rec.pid)) {
|
|
650732
|
+
try {
|
|
650733
|
+
process.kill(rec.pid, "SIGKILL");
|
|
650734
|
+
} catch {}
|
|
650735
|
+
}
|
|
650736
|
+
const fresh = spawnWorker(rec.kind, { cwd: rec.cwd, id });
|
|
650737
|
+
fresh.restart = rec.restart + 1;
|
|
650738
|
+
registry2.set(id, fresh);
|
|
650739
|
+
return fresh;
|
|
650740
|
+
}
|
|
650741
|
+
var DEFAULT_PREWARM_PER_SWEEP = 3, registry2, children2, _nextId = 1, runDaemonWorker = async (workerId) => {
|
|
650742
|
+
const kind = workerId || process.env.CLAUDE_CODE_DAEMON_WORKER_KIND || "default";
|
|
650743
|
+
const startMs = Date.now();
|
|
650744
|
+
const parentPpid = process.ppid;
|
|
650745
|
+
console.log(`[daemon-worker] kind=${kind} pid=${process.pid} parent=${parentPpid} ready`);
|
|
650746
|
+
let settling = false;
|
|
650747
|
+
const shutdown = async (signal) => {
|
|
650748
|
+
if (settling)
|
|
650749
|
+
return;
|
|
650750
|
+
settling = true;
|
|
650751
|
+
console.log(`[daemon-worker] kind=${kind} received ${signal}, settling`);
|
|
650752
|
+
process.exit(0);
|
|
650753
|
+
};
|
|
650754
|
+
process.on("SIGTERM", () => void shutdown("SIGTERM"));
|
|
650755
|
+
process.on("SIGINT", () => void shutdown("SIGINT"));
|
|
650756
|
+
const orphanWatch = setInterval(() => {
|
|
650757
|
+
if (!isPidAlive(parentPpid)) {
|
|
650758
|
+
console.log(`orphan watchdog: ppid ${parentPpid}\u2192process.ppid, no client found`);
|
|
650759
|
+
console.log("parent supervisor gone \u2014 exiting");
|
|
650760
|
+
clearInterval(orphanWatch);
|
|
650761
|
+
process.exit(0);
|
|
650762
|
+
}
|
|
650763
|
+
}, 5000);
|
|
650764
|
+
const idleCapMs = 30 * 60 * 1000;
|
|
650765
|
+
const idleDeadline = startMs + idleCapMs;
|
|
650766
|
+
while (!settling) {
|
|
650767
|
+
const now2 = Date.now();
|
|
650768
|
+
if (now2 > idleDeadline) {
|
|
650769
|
+
console.log(`[daemon-worker] kind=${kind} idle cap reached, exiting`);
|
|
650770
|
+
process.exit(0);
|
|
650771
|
+
}
|
|
650772
|
+
await new Promise((r4) => setTimeout(r4, 1000));
|
|
650773
|
+
}
|
|
650774
|
+
};
|
|
650775
|
+
var init_workerRegistry = __esm(() => {
|
|
650776
|
+
init_envUtils();
|
|
650777
|
+
init_cwd2();
|
|
650778
|
+
init_analytics();
|
|
650779
|
+
init_process();
|
|
650780
|
+
registry2 = new Map;
|
|
650781
|
+
children2 = new Map;
|
|
650457
650782
|
});
|
|
650458
|
-
var runDaemonWorker = () => Promise.resolve();
|
|
650459
|
-
var init_workerRegistry = () => {};
|
|
650460
650783
|
|
|
650461
650784
|
// src/bridge/bridgeUI.ts
|
|
650462
650785
|
async function generateQr(url3) {
|
|
@@ -651034,10 +651357,10 @@ var init_pollConfig = __esm(() => {
|
|
|
651034
651357
|
});
|
|
651035
651358
|
|
|
651036
651359
|
// src/bridge/sessionRunner.ts
|
|
651037
|
-
import { spawn as
|
|
651360
|
+
import { spawn as spawn14 } from "child_process";
|
|
651038
651361
|
import { createWriteStream as createWriteStream4 } from "fs";
|
|
651039
651362
|
import { tmpdir as tmpdir14 } from "os";
|
|
651040
|
-
import { dirname as dirname67, join as
|
|
651363
|
+
import { dirname as dirname67, join as join157 } from "path";
|
|
651041
651364
|
import { createInterface as createInterface2 } from "readline";
|
|
651042
651365
|
function safeFilenameId(id) {
|
|
651043
651366
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -651170,12 +651493,12 @@ function createSessionSpawner(deps) {
|
|
|
651170
651493
|
debugFile = `${deps.debugFile}-${safeId}`;
|
|
651171
651494
|
}
|
|
651172
651495
|
} else if (deps.verbose || process.env.USER_TYPE === "ant") {
|
|
651173
|
-
debugFile =
|
|
651496
|
+
debugFile = join157(tmpdir14(), "claude", `bridge-session-${safeId}.log`);
|
|
651174
651497
|
}
|
|
651175
651498
|
let transcriptStream = null;
|
|
651176
651499
|
let transcriptPath;
|
|
651177
651500
|
if (deps.debugFile) {
|
|
651178
|
-
transcriptPath =
|
|
651501
|
+
transcriptPath = join157(dirname67(deps.debugFile), `bridge-transcript-${safeId}.jsonl`);
|
|
651179
651502
|
transcriptStream = createWriteStream4(transcriptPath, { flags: "a" });
|
|
651180
651503
|
transcriptStream.on("error", (err2) => {
|
|
651181
651504
|
deps.onDebug(`[bridge:session] Transcript write error: ${err2.message}`);
|
|
@@ -651216,7 +651539,7 @@ function createSessionSpawner(deps) {
|
|
|
651216
651539
|
if (debugFile) {
|
|
651217
651540
|
deps.onDebug(`[bridge:session] Debug log: ${debugFile}`);
|
|
651218
651541
|
}
|
|
651219
|
-
const child =
|
|
651542
|
+
const child = spawn14(deps.execPath, args, {
|
|
651220
651543
|
cwd: dir,
|
|
651221
651544
|
stdio: ["pipe", "pipe", "pipe"],
|
|
651222
651545
|
env: env6,
|
|
@@ -651449,9 +651772,9 @@ __export(exports_bridgePointer, {
|
|
|
651449
651772
|
BRIDGE_POINTER_TTL_MS: () => BRIDGE_POINTER_TTL_MS
|
|
651450
651773
|
});
|
|
651451
651774
|
import { mkdir as mkdir54, readFile as readFile62, stat as stat49, unlink as unlink25, writeFile as writeFile56 } from "fs/promises";
|
|
651452
|
-
import { dirname as dirname68, join as
|
|
651775
|
+
import { dirname as dirname68, join as join158 } from "path";
|
|
651453
651776
|
function getBridgePointerPath(dir) {
|
|
651454
|
-
return
|
|
651777
|
+
return join158(getProjectsDir(), sanitizePath2(dir), "bridge-pointer.json");
|
|
651455
651778
|
}
|
|
651456
651779
|
async function writeBridgePointer(dir, pointer) {
|
|
651457
651780
|
const path28 = getBridgePointerPath(dir);
|
|
@@ -651553,12 +651876,12 @@ var init_bridgePointer = __esm(() => {
|
|
|
651553
651876
|
});
|
|
651554
651877
|
|
|
651555
651878
|
// src/utils/errorLogSink.ts
|
|
651556
|
-
import { dirname as dirname69, join as
|
|
651879
|
+
import { dirname as dirname69, join as join159 } from "path";
|
|
651557
651880
|
function getErrorsPath() {
|
|
651558
|
-
return
|
|
651881
|
+
return join159(CACHE_PATHS.errors(), DATE + ".jsonl");
|
|
651559
651882
|
}
|
|
651560
651883
|
function getMCPLogsPath(serverName) {
|
|
651561
|
-
return
|
|
651884
|
+
return join159(CACHE_PATHS.mcpLogs(serverName), DATE + ".jsonl");
|
|
651562
651885
|
}
|
|
651563
651886
|
function createJsonlWriter(options) {
|
|
651564
651887
|
const writer = createBufferedWriter(options);
|
|
@@ -651714,7 +652037,7 @@ __export(exports_bridgeMain, {
|
|
|
651714
652037
|
});
|
|
651715
652038
|
import { randomUUID as randomUUID41 } from "crypto";
|
|
651716
652039
|
import { hostname as hostname4, tmpdir as tmpdir15 } from "os";
|
|
651717
|
-
import { basename as basename49, join as
|
|
652040
|
+
import { basename as basename49, join as join160, resolve as resolve49 } from "path";
|
|
651718
652041
|
async function isMultiSessionSpawnEnabled() {
|
|
651719
652042
|
return checkGate_CACHED_OR_BLOCKING("tengu_ccr_bridge_multi_session");
|
|
651720
652043
|
}
|
|
@@ -651845,7 +652168,7 @@ async function runBridgeLoop(config7, environmentId, environmentSecret, api4, sp
|
|
|
651845
652168
|
const ext = config7.debugFile.lastIndexOf(".");
|
|
651846
652169
|
debugGlob = ext > 0 ? `${config7.debugFile.slice(0, ext)}-*${config7.debugFile.slice(ext)}` : `${config7.debugFile}-*`;
|
|
651847
652170
|
} else {
|
|
651848
|
-
debugGlob =
|
|
652171
|
+
debugGlob = join160(tmpdir15(), "claude", "bridge-session-*.log");
|
|
651849
652172
|
}
|
|
651850
652173
|
logger30.setDebugLogPath(debugGlob);
|
|
651851
652174
|
}
|
|
@@ -652236,7 +652559,7 @@ async function runBridgeLoop(config7, environmentId, environmentSecret, api4, sp
|
|
|
652236
652559
|
sessionDebugFile = `${config7.debugFile}-${safeId}`;
|
|
652237
652560
|
}
|
|
652238
652561
|
} else if (config7.verbose || process.env.USER_TYPE === "ant") {
|
|
652239
|
-
sessionDebugFile =
|
|
652562
|
+
sessionDebugFile = join160(tmpdir15(), "claude", `bridge-session-${safeId}.log`);
|
|
652240
652563
|
}
|
|
652241
652564
|
if (sessionDebugFile) {
|
|
652242
652565
|
logger30.logVerbose(`Debug log: ${sessionDebugFile}`);
|
|
@@ -653335,24 +653658,833 @@ var init_bridgeMain = __esm(() => {
|
|
|
653335
653658
|
};
|
|
653336
653659
|
});
|
|
653337
653660
|
|
|
653661
|
+
// src/daemon/lockfile.ts
|
|
653662
|
+
import { open as open15, readFile as readFile63, unlink as unlink26 } from "fs/promises";
|
|
653663
|
+
import { existsSync as existsSync16, statSync as statSync15 } from "fs";
|
|
653664
|
+
import { join as join161 } from "path";
|
|
653665
|
+
function getDaemonLockfilePath() {
|
|
653666
|
+
return join161(getClaudeConfigHomeDir(), "daemon.lock");
|
|
653667
|
+
}
|
|
653668
|
+
async function readLockfile() {
|
|
653669
|
+
const path28 = getDaemonLockfilePath();
|
|
653670
|
+
if (!existsSync16(path28)) {
|
|
653671
|
+
return null;
|
|
653672
|
+
}
|
|
653673
|
+
try {
|
|
653674
|
+
const raw = await readFile63(path28, { encoding: "utf-8" });
|
|
653675
|
+
const parsed = JSON.parse(raw);
|
|
653676
|
+
if (typeof parsed?.supervisorPid !== "number" || typeof parsed?.supervisorProcStart !== "number") {
|
|
653677
|
+
return null;
|
|
653678
|
+
}
|
|
653679
|
+
return {
|
|
653680
|
+
supervisorPid: parsed.supervisorPid,
|
|
653681
|
+
supervisorProcStart: parsed.supervisorProcStart,
|
|
653682
|
+
holderPid: typeof parsed.holderPid === "number" ? parsed.holderPid : parsed.supervisorPid
|
|
653683
|
+
};
|
|
653684
|
+
} catch {
|
|
653685
|
+
return null;
|
|
653686
|
+
}
|
|
653687
|
+
}
|
|
653688
|
+
async function acquireLockfile(identity8) {
|
|
653689
|
+
const path28 = getDaemonLockfilePath();
|
|
653690
|
+
const { mkdir: mkdir55 } = await import("fs/promises");
|
|
653691
|
+
await mkdir55(getClaudeConfigHomeDir(), { recursive: true }).catch(() => {});
|
|
653692
|
+
if (!existsSync16(path28)) {
|
|
653693
|
+
try {
|
|
653694
|
+
const fh = await open15(path28, "ax");
|
|
653695
|
+
const contents = {
|
|
653696
|
+
supervisorPid: identity8.supervisorPid,
|
|
653697
|
+
supervisorProcStart: identity8.supervisorProcStart,
|
|
653698
|
+
holderPid: identity8.supervisorPid
|
|
653699
|
+
};
|
|
653700
|
+
await fh.writeFile(JSON.stringify(contents), { encoding: "utf-8" });
|
|
653701
|
+
await fh.close();
|
|
653702
|
+
return true;
|
|
653703
|
+
} catch (err2) {
|
|
653704
|
+
if (err2?.code !== "EEXIST") {
|
|
653705
|
+
return false;
|
|
653706
|
+
}
|
|
653707
|
+
}
|
|
653708
|
+
}
|
|
653709
|
+
const existing = await readLockfile();
|
|
653710
|
+
if (!existing) {
|
|
653711
|
+
try {
|
|
653712
|
+
await unlink26(path28);
|
|
653713
|
+
} catch {}
|
|
653714
|
+
return acquireLockfile(identity8);
|
|
653715
|
+
}
|
|
653716
|
+
if (existing.supervisorPid === identity8.supervisorPid && existing.supervisorProcStart === identity8.supervisorProcStart) {
|
|
653717
|
+
return true;
|
|
653718
|
+
}
|
|
653719
|
+
const holderAlive = isPidAlive(existing.supervisorPid);
|
|
653720
|
+
const holderStartMs = getProcessStartMs(existing.supervisorPid);
|
|
653721
|
+
const startMatches = holderStartMs !== null && Math.abs(holderStartMs - existing.supervisorProcStart) < 2000;
|
|
653722
|
+
if (holderAlive && startMatches) {
|
|
653723
|
+
console.log(`lockfile now held by pid=${existing.supervisorPid} \u2014 displaced, yielding`);
|
|
653724
|
+
return false;
|
|
653725
|
+
}
|
|
653726
|
+
try {
|
|
653727
|
+
await unlink26(path28);
|
|
653728
|
+
} catch {}
|
|
653729
|
+
try {
|
|
653730
|
+
const fh = await open15(path28, "ax");
|
|
653731
|
+
const contents = {
|
|
653732
|
+
supervisorPid: identity8.supervisorPid,
|
|
653733
|
+
supervisorProcStart: identity8.supervisorProcStart,
|
|
653734
|
+
holderPid: identity8.supervisorPid
|
|
653735
|
+
};
|
|
653736
|
+
await fh.writeFile(JSON.stringify(contents), { encoding: "utf-8" });
|
|
653737
|
+
await fh.close();
|
|
653738
|
+
return true;
|
|
653739
|
+
} catch {
|
|
653740
|
+
return false;
|
|
653741
|
+
}
|
|
653742
|
+
}
|
|
653743
|
+
async function releaseLockfile(identity8) {
|
|
653744
|
+
const existing = await readLockfile();
|
|
653745
|
+
if (!existing)
|
|
653746
|
+
return;
|
|
653747
|
+
if (existing.supervisorPid === identity8.supervisorPid && existing.supervisorProcStart === identity8.supervisorProcStart) {
|
|
653748
|
+
try {
|
|
653749
|
+
await unlink26(getDaemonLockfilePath());
|
|
653750
|
+
} catch {}
|
|
653751
|
+
}
|
|
653752
|
+
}
|
|
653753
|
+
async function displaceHolder() {
|
|
653754
|
+
const existing = await readLockfile();
|
|
653755
|
+
if (!existing) {
|
|
653756
|
+
return { displaced: false, holder: null };
|
|
653757
|
+
}
|
|
653758
|
+
const holderStartMs = getProcessStartMs(existing.supervisorPid);
|
|
653759
|
+
const startMatches = holderStartMs !== null && Math.abs(holderStartMs - existing.supervisorProcStart) < 2000;
|
|
653760
|
+
if (!isPidAlive(existing.supervisorPid) || !startMatches) {
|
|
653761
|
+
await releaseLockfile({
|
|
653762
|
+
supervisorPid: existing.supervisorPid,
|
|
653763
|
+
supervisorProcStart: existing.supervisorProcStart
|
|
653764
|
+
}).catch(() => {});
|
|
653765
|
+
return { displaced: true, holder: existing };
|
|
653766
|
+
}
|
|
653767
|
+
try {
|
|
653768
|
+
process.kill(existing.supervisorPid, "SIGTERM");
|
|
653769
|
+
} catch {}
|
|
653770
|
+
const deadline = Date.now() + 5000;
|
|
653771
|
+
while (Date.now() < deadline) {
|
|
653772
|
+
if (!isPidAlive(existing.supervisorPid))
|
|
653773
|
+
break;
|
|
653774
|
+
await new Promise((r4) => setTimeout(r4, 200));
|
|
653775
|
+
}
|
|
653776
|
+
if (isPidAlive(existing.supervisorPid)) {
|
|
653777
|
+
try {
|
|
653778
|
+
process.kill(existing.supervisorPid, "SIGKILL");
|
|
653779
|
+
} catch {}
|
|
653780
|
+
await new Promise((r4) => setTimeout(r4, 300));
|
|
653781
|
+
}
|
|
653782
|
+
await releaseLockfile({
|
|
653783
|
+
supervisorPid: existing.supervisorPid,
|
|
653784
|
+
supervisorProcStart: existing.supervisorProcStart
|
|
653785
|
+
}).catch(() => {});
|
|
653786
|
+
return { displaced: true, holder: existing };
|
|
653787
|
+
}
|
|
653788
|
+
function lockfileMtime() {
|
|
653789
|
+
try {
|
|
653790
|
+
return statSync15(getDaemonLockfilePath()).mtimeMs;
|
|
653791
|
+
} catch {
|
|
653792
|
+
return null;
|
|
653793
|
+
}
|
|
653794
|
+
}
|
|
653795
|
+
var init_lockfile = __esm(() => {
|
|
653796
|
+
init_envUtils();
|
|
653797
|
+
init_process();
|
|
653798
|
+
});
|
|
653799
|
+
|
|
653800
|
+
// src/daemon/respawn.ts
|
|
653801
|
+
import { execFileSync as execFileSync6 } from "child_process";
|
|
653802
|
+
function findOrphanedWorkers() {
|
|
653803
|
+
let out;
|
|
653804
|
+
try {
|
|
653805
|
+
out = execFileSync6("ps", ["-e", "-o", "pid=,ppid=,command="], {
|
|
653806
|
+
encoding: "utf-8",
|
|
653807
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
653808
|
+
timeout: 3000
|
|
653809
|
+
});
|
|
653810
|
+
} catch {
|
|
653811
|
+
return [];
|
|
653812
|
+
}
|
|
653813
|
+
const orphans = [];
|
|
653814
|
+
for (const line of out.split(`
|
|
653815
|
+
`)) {
|
|
653816
|
+
const m5 = line.trim().match(/^(\d+)\s+(\d+)\s+(.*)$/);
|
|
653817
|
+
if (!m5)
|
|
653818
|
+
continue;
|
|
653819
|
+
const pid = Number(m5[1]);
|
|
653820
|
+
const ppid = Number(m5[2]);
|
|
653821
|
+
const cmd = m5[3];
|
|
653822
|
+
if (!cmd.includes("--daemon-worker"))
|
|
653823
|
+
continue;
|
|
653824
|
+
if (pid === process.pid)
|
|
653825
|
+
continue;
|
|
653826
|
+
if (!isPidAlive(ppid)) {
|
|
653827
|
+
orphans.push({ pid, ppid, cmd });
|
|
653828
|
+
}
|
|
653829
|
+
}
|
|
653830
|
+
return orphans;
|
|
653831
|
+
}
|
|
653832
|
+
function recoverOrphanedWorkers() {
|
|
653833
|
+
const orphans = findOrphanedWorkers();
|
|
653834
|
+
if (orphans.length > 0) {
|
|
653835
|
+
console.log("background agent(s) orphaned by previous process exit");
|
|
653836
|
+
console.log(`[print.ts] ${orphans.length} orphaned background task(s) after restart`);
|
|
653837
|
+
logEvent("tengu_bg_orphan_recovery", { count: orphans.length });
|
|
653838
|
+
for (const o5 of orphans) {
|
|
653839
|
+
console.log(`orphan watchdog: ppid ${o5.ppid}\u2192process.ppid, no client found (pid=${o5.pid})`);
|
|
653840
|
+
try {
|
|
653841
|
+
process.kill(o5.pid, "SIGTERM");
|
|
653842
|
+
} catch {}
|
|
653843
|
+
}
|
|
653844
|
+
}
|
|
653845
|
+
return orphans.length;
|
|
653846
|
+
}
|
|
653847
|
+
var init_respawn = __esm(() => {
|
|
653848
|
+
init_analytics();
|
|
653849
|
+
init_process();
|
|
653850
|
+
init_workerRegistry();
|
|
653851
|
+
});
|
|
653852
|
+
|
|
653853
|
+
// src/daemon/install.ts
|
|
653854
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync11, writeFileSync as writeFileSync11, unlinkSync as unlinkSync5 } from "fs";
|
|
653855
|
+
import { homedir as homedir40 } from "os";
|
|
653856
|
+
import { join as join162 } from "path";
|
|
653857
|
+
import { spawnSync as spawnSync9 } from "child_process";
|
|
653858
|
+
function detectInstallPlatform() {
|
|
653859
|
+
if (process.platform === "darwin") {
|
|
653860
|
+
return existsSync17("/bin/launchctl") ? "launchd" : "unsupported";
|
|
653861
|
+
}
|
|
653862
|
+
if (process.platform === "linux") {
|
|
653863
|
+
return existsSync17("/bin/systemctl") || existsSync17("/usr/bin/systemctl") ? "systemd" : "unsupported";
|
|
653864
|
+
}
|
|
653865
|
+
return "unsupported";
|
|
653866
|
+
}
|
|
653867
|
+
function cliEntry() {
|
|
653868
|
+
return process.argv[1] ?? "dist/cli.js";
|
|
653869
|
+
}
|
|
653870
|
+
function launchdPlistPath() {
|
|
653871
|
+
return join162(homedir40(), "Library", "LaunchAgents", "com.anthropic.claude.daemon.plist");
|
|
653872
|
+
}
|
|
653873
|
+
function systemdUnitPath() {
|
|
653874
|
+
return join162(homedir40(), ".config", "systemd", "user", "claude-daemon.service");
|
|
653875
|
+
}
|
|
653876
|
+
function installPersistentService() {
|
|
653877
|
+
const plat = detectInstallPlatform();
|
|
653878
|
+
if (plat === "unsupported") {
|
|
653879
|
+
const msg = `claude daemon install isn't available on ${process.platform} (no launchd/systemd)`;
|
|
653880
|
+
logEvent("daemon_install_unsupported", { platform: process.platform });
|
|
653881
|
+
return msg;
|
|
653882
|
+
}
|
|
653883
|
+
if (plat === "launchd") {
|
|
653884
|
+
return installLaunchd();
|
|
653885
|
+
}
|
|
653886
|
+
return installSystemd();
|
|
653887
|
+
}
|
|
653888
|
+
function installLaunchd() {
|
|
653889
|
+
const plistPath = launchdPlistPath();
|
|
653890
|
+
mkdirSync11(join162(plistPath, ".."), { recursive: true });
|
|
653891
|
+
const plist = `<?xml version="1.0" encoding="UTF-8"?>
|
|
653892
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
653893
|
+
<plist version="1.0">
|
|
653894
|
+
<dict>
|
|
653895
|
+
<key>Label</key>
|
|
653896
|
+
<string>com.anthropic.claude.daemon</string>
|
|
653897
|
+
<key>ProgramArguments</key>
|
|
653898
|
+
<array>
|
|
653899
|
+
<string>${process.execPath}</string>
|
|
653900
|
+
<string>${cliEntry()}</string>
|
|
653901
|
+
<string>daemon</string>
|
|
653902
|
+
<string>start</string>
|
|
653903
|
+
</array>
|
|
653904
|
+
<key>RunAtLoad</key>
|
|
653905
|
+
<true/>
|
|
653906
|
+
<key>KeepAlive</key>
|
|
653907
|
+
<true/>
|
|
653908
|
+
<key>StandardOutPath</key>
|
|
653909
|
+
<string>${join162(homedir40(), ".claude", "daemon.log")}</string>
|
|
653910
|
+
<key>StandardErrorPath</key>
|
|
653911
|
+
<string>${join162(homedir40(), ".claude", "daemon.log")}</string>
|
|
653912
|
+
</dict>
|
|
653913
|
+
</plist>
|
|
653914
|
+
`;
|
|
653915
|
+
writeFileSync11(plistPath, plist, { encoding: "utf-8" });
|
|
653916
|
+
spawnSync9("launchctl", ["unload", plistPath], { stdio: "ignore" });
|
|
653917
|
+
const res = spawnSync9("launchctl", ["load", plistPath], { encoding: "utf-8" });
|
|
653918
|
+
logEvent("daemon_install_launchd", { ok: res.status === 0 });
|
|
653919
|
+
return res.status === 0 ? `launchd unit installed at ${plistPath}` : `launchd install failed: ${res.stderr?.trim() ?? "unknown error"}`;
|
|
653920
|
+
}
|
|
653921
|
+
function installSystemd() {
|
|
653922
|
+
const unitPath = systemdUnitPath();
|
|
653923
|
+
mkdirSync11(join162(unitPath, ".."), { recursive: true });
|
|
653924
|
+
const unit = `[Unit]
|
|
653925
|
+
Description=Claude Code background-agent daemon
|
|
653926
|
+
After=network.target
|
|
653927
|
+
|
|
653928
|
+
[Service]
|
|
653929
|
+
Type=simple
|
|
653930
|
+
ExecStart=${process.execPath} ${cliEntry()} daemon start
|
|
653931
|
+
Restart=on-failure
|
|
653932
|
+
RestartSec=2
|
|
653933
|
+
StandardOutput=append:${join162(homedir40(), ".claude", "daemon.log")}
|
|
653934
|
+
StandardError=append:${join162(homedir40(), ".claude", "daemon.log")}
|
|
653935
|
+
|
|
653936
|
+
[Install]
|
|
653937
|
+
WantedBy=default.target
|
|
653938
|
+
`;
|
|
653939
|
+
writeFileSync11(unitPath, unit, { encoding: "utf-8" });
|
|
653940
|
+
spawnSync9("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
|
|
653941
|
+
spawnSync9("systemctl", ["--user", "enable", "claude-daemon.service"], { stdio: "ignore" });
|
|
653942
|
+
spawnSync9("loginctl", ["enable-linger", process.env.USER ?? "root"], {
|
|
653943
|
+
stdio: "ignore"
|
|
653944
|
+
});
|
|
653945
|
+
logEvent("daemon_install_systemd", {});
|
|
653946
|
+
return `systemd unit installed at ${unitPath} (enable-linger ${process.env.USER ?? "root"})`;
|
|
653947
|
+
}
|
|
653948
|
+
function uninstallPersistentService() {
|
|
653949
|
+
const plat = detectInstallPlatform();
|
|
653950
|
+
if (plat === "launchd") {
|
|
653951
|
+
const plistPath = launchdPlistPath();
|
|
653952
|
+
spawnSync9("launchctl", ["unload", plistPath], { stdio: "ignore" });
|
|
653953
|
+
try {
|
|
653954
|
+
unlinkSync5(plistPath);
|
|
653955
|
+
} catch {}
|
|
653956
|
+
logEvent("daemon_uninstall_launchd", {});
|
|
653957
|
+
return `launchd unit removed`;
|
|
653958
|
+
}
|
|
653959
|
+
if (plat === "systemd") {
|
|
653960
|
+
spawnSync9("systemctl", ["--user", "disable", "claude-daemon.service"], {
|
|
653961
|
+
stdio: "ignore"
|
|
653962
|
+
});
|
|
653963
|
+
try {
|
|
653964
|
+
unlinkSync5(systemdUnitPath());
|
|
653965
|
+
} catch {}
|
|
653966
|
+
spawnSync9("systemctl", ["--user", "daemon-reload"], { stdio: "ignore" });
|
|
653967
|
+
logEvent("daemon_uninstall_systemd", {});
|
|
653968
|
+
return `systemd unit removed`;
|
|
653969
|
+
}
|
|
653970
|
+
return `claude daemon uninstall isn't available on ${process.platform} (no launchd/systemd)`;
|
|
653971
|
+
}
|
|
653972
|
+
var init_install = __esm(() => {
|
|
653973
|
+
init_analytics();
|
|
653974
|
+
});
|
|
653975
|
+
|
|
653976
|
+
// src/daemon/supervisor.ts
|
|
653977
|
+
import { existsSync as existsSync18, statSync as statSync16 } from "fs";
|
|
653978
|
+
function buildIdentity() {
|
|
653979
|
+
return {
|
|
653980
|
+
supervisorPid: process.pid,
|
|
653981
|
+
supervisorProcStart: Date.now()
|
|
653982
|
+
};
|
|
653983
|
+
}
|
|
653984
|
+
function getDaemonColdStart() {
|
|
653985
|
+
const env6 = process.env.CLAUDE_CODE_DAEMON_COLD_START;
|
|
653986
|
+
if (env6 === "transient" || env6 === "ask")
|
|
653987
|
+
return env6;
|
|
653988
|
+
const fromConfig = getGlobalConfig().daemonColdStart;
|
|
653989
|
+
if (fromConfig === "transient" || fromConfig === "ask")
|
|
653990
|
+
return fromConfig;
|
|
653991
|
+
return "transient";
|
|
653992
|
+
}
|
|
653993
|
+
function checkBinaryIdentity() {
|
|
653994
|
+
const execPath2 = process.execPath;
|
|
653995
|
+
const entry = process.argv[1];
|
|
653996
|
+
try {
|
|
653997
|
+
if (!execPath2 || !existsSync18(execPath2)) {
|
|
653998
|
+
return "binary identity unresolvable";
|
|
653999
|
+
}
|
|
654000
|
+
statSync16(execPath2);
|
|
654001
|
+
} catch {
|
|
654002
|
+
return "binary identity unresolvable";
|
|
654003
|
+
}
|
|
654004
|
+
if (entry) {
|
|
654005
|
+
try {
|
|
654006
|
+
if (!existsSync18(entry)) {
|
|
654007
|
+
return `binary at ${entry} was deleted`;
|
|
654008
|
+
}
|
|
654009
|
+
} catch {
|
|
654010
|
+
return `binary at ${entry} was deleted`;
|
|
654011
|
+
}
|
|
654012
|
+
}
|
|
654013
|
+
return null;
|
|
654014
|
+
}
|
|
654015
|
+
async function holderRefusesToYield() {
|
|
654016
|
+
const existing = await readLockfile();
|
|
654017
|
+
if (!existing)
|
|
654018
|
+
return false;
|
|
654019
|
+
return isPidAlive(existing.supervisorPid);
|
|
654020
|
+
}
|
|
654021
|
+
async function stopExistingSupervisor() {
|
|
654022
|
+
const existing = await readLockfile();
|
|
654023
|
+
if (!existing) {
|
|
654024
|
+
return { stopped: false, holder: null, eperm: false };
|
|
654025
|
+
}
|
|
654026
|
+
if (!isPidAlive(existing.supervisorPid)) {
|
|
654027
|
+
await releaseLockfile({
|
|
654028
|
+
supervisorPid: existing.supervisorPid,
|
|
654029
|
+
supervisorProcStart: existing.supervisorProcStart
|
|
654030
|
+
}).catch(() => {});
|
|
654031
|
+
return { stopped: true, holder: existing, eperm: false };
|
|
654032
|
+
}
|
|
654033
|
+
let eperm = false;
|
|
654034
|
+
try {
|
|
654035
|
+
process.kill(existing.supervisorPid, "SIGTERM");
|
|
654036
|
+
} catch (err2) {
|
|
654037
|
+
if (err2?.code === "EPERM") {
|
|
654038
|
+
eperm = true;
|
|
654039
|
+
console.error("could not restart supervisor (EPERM)");
|
|
654040
|
+
await ensureZombieKill(existing.supervisorPid, 4000);
|
|
654041
|
+
}
|
|
654042
|
+
}
|
|
654043
|
+
const deadline = Date.now() + 5000;
|
|
654044
|
+
while (Date.now() < deadline) {
|
|
654045
|
+
if (!isPidAlive(existing.supervisorPid))
|
|
654046
|
+
break;
|
|
654047
|
+
await new Promise((r4) => setTimeout(r4, 200));
|
|
654048
|
+
}
|
|
654049
|
+
if (isPidAlive(existing.supervisorPid)) {
|
|
654050
|
+
console.error("existing daemon refused to yield");
|
|
654051
|
+
return { stopped: false, holder: existing, eperm };
|
|
654052
|
+
}
|
|
654053
|
+
await releaseLockfile({
|
|
654054
|
+
supervisorPid: existing.supervisorPid,
|
|
654055
|
+
supervisorProcStart: existing.supervisorProcStart
|
|
654056
|
+
}).catch(() => {});
|
|
654057
|
+
return { stopped: true, holder: existing, eperm };
|
|
654058
|
+
}
|
|
654059
|
+
async function displaceAny() {
|
|
654060
|
+
return displaceHolder();
|
|
654061
|
+
}
|
|
654062
|
+
async function runSupervisor(args) {
|
|
654063
|
+
const sub = args[0] ?? "start";
|
|
654064
|
+
const identity8 = buildIdentity();
|
|
654065
|
+
logEvent("tengu_bg_supervisor_start", {
|
|
654066
|
+
sub,
|
|
654067
|
+
coldStart: getDaemonColdStart()
|
|
654068
|
+
});
|
|
654069
|
+
const binaryErr = checkBinaryIdentity();
|
|
654070
|
+
if (binaryErr) {
|
|
654071
|
+
console.error(binaryErr);
|
|
654072
|
+
logEvent("tengu_bg_supervisor_binary_bad", { reason: binaryErr });
|
|
654073
|
+
process.exit(1);
|
|
654074
|
+
}
|
|
654075
|
+
const acquired = await acquireLockfile(identity8);
|
|
654076
|
+
if (!acquired) {
|
|
654077
|
+
if (await holderRefusesToYield()) {
|
|
654078
|
+
console.error("existing daemon refused to yield");
|
|
654079
|
+
}
|
|
654080
|
+
process.exit(0);
|
|
654081
|
+
}
|
|
654082
|
+
const orphanCount = recoverOrphanedWorkers();
|
|
654083
|
+
const config7 = readDaemonJson();
|
|
654084
|
+
const warnings = validateDaemonJsonWorkers(config7);
|
|
654085
|
+
for (const w3 of warnings) {
|
|
654086
|
+
console.warn(w3);
|
|
654087
|
+
}
|
|
654088
|
+
let shutdownCause = null;
|
|
654089
|
+
const handleSignal = (signal, cause) => {
|
|
654090
|
+
if (shutdownCause)
|
|
654091
|
+
return;
|
|
654092
|
+
shutdownCause = cause;
|
|
654093
|
+
shutdown(cause).catch(() => process.exit(0));
|
|
654094
|
+
};
|
|
654095
|
+
process.on("SIGTERM", () => handleSignal("SIGTERM", "sigterm"));
|
|
654096
|
+
process.on("SIGINT", () => handleSignal("SIGINT", "sigint"));
|
|
654097
|
+
running = true;
|
|
654098
|
+
const startedAt = Date.now();
|
|
654099
|
+
let lastActivityAt = startedAt;
|
|
654100
|
+
let lastSweepAt = 0;
|
|
654101
|
+
console.log(`[daemon] supervisor pid=${identity8.supervisorPid} start=${identity8.supervisorProcStart} coldStart=${getDaemonColdStart()}`);
|
|
654102
|
+
while (running) {
|
|
654103
|
+
const now2 = Date.now();
|
|
654104
|
+
if (now2 - lastSweepAt >= SWEEP_INTERVAL_MS) {
|
|
654105
|
+
lastSweepAt = now2;
|
|
654106
|
+
const alive = await sweepWorkers(config7);
|
|
654107
|
+
if (alive > 0) {
|
|
654108
|
+
lastActivityAt = now2;
|
|
654109
|
+
}
|
|
654110
|
+
const idleMs = now2 - lastActivityAt;
|
|
654111
|
+
if (alive === 0 && idleMs >= IDLE_SHUTDOWN_MS) {
|
|
654112
|
+
const idleSec = Math.round(idleMs / 1000);
|
|
654113
|
+
console.log(`idle ${idleSec}s with no workers`);
|
|
654114
|
+
await shutdown("idle");
|
|
654115
|
+
break;
|
|
654116
|
+
}
|
|
654117
|
+
}
|
|
654118
|
+
await new Promise((r4) => setTimeout(r4, 500));
|
|
654119
|
+
}
|
|
654120
|
+
async function shutdown(cause) {
|
|
654121
|
+
running = false;
|
|
654122
|
+
const uptime = Date.now() - startedAt;
|
|
654123
|
+
const uptimeS = Math.round(uptime / 1000);
|
|
654124
|
+
console.log(`shutting down (cause=${cause}, uptime=${uptimeS}s)`);
|
|
654125
|
+
logEvent("tengu_bg_supervisor_shutdown", {
|
|
654126
|
+
cause,
|
|
654127
|
+
uptimeS
|
|
654128
|
+
});
|
|
654129
|
+
await stopAllWorkers(3000);
|
|
654130
|
+
await releaseLockfile({
|
|
654131
|
+
supervisorPid: identity8.supervisorPid,
|
|
654132
|
+
supervisorProcStart: identity8.supervisorProcStart
|
|
654133
|
+
}).catch(() => {});
|
|
654134
|
+
process.exit(0);
|
|
654135
|
+
}
|
|
654136
|
+
}
|
|
654137
|
+
async function daemonInstall() {
|
|
654138
|
+
const msg = installPersistentService();
|
|
654139
|
+
console.log(msg);
|
|
654140
|
+
}
|
|
654141
|
+
async function daemonUninstall() {
|
|
654142
|
+
await stopExistingSupervisor().catch(() => {});
|
|
654143
|
+
const msg = uninstallPersistentService();
|
|
654144
|
+
console.log(msg);
|
|
654145
|
+
}
|
|
654146
|
+
async function daemonRestart() {
|
|
654147
|
+
await stopExistingSupervisor().catch(() => {});
|
|
654148
|
+
console.log("supervisor restarting");
|
|
654149
|
+
process.exit(0);
|
|
654150
|
+
}
|
|
654151
|
+
var IDLE_SHUTDOWN_MS = 60000, SWEEP_INTERVAL_MS = 5000, running = false;
|
|
654152
|
+
var init_supervisor = __esm(() => {
|
|
654153
|
+
init_analytics();
|
|
654154
|
+
init_config4();
|
|
654155
|
+
init_lockfile();
|
|
654156
|
+
init_process();
|
|
654157
|
+
init_respawn();
|
|
654158
|
+
init_workerRegistry();
|
|
654159
|
+
init_install();
|
|
654160
|
+
});
|
|
654161
|
+
|
|
654162
|
+
// src/cli/handlers/daemon.ts
|
|
654163
|
+
var exports_daemon = {};
|
|
654164
|
+
__export(exports_daemon, {
|
|
654165
|
+
stopHandler: () => stopHandler,
|
|
654166
|
+
logsHandler: () => logsHandler,
|
|
654167
|
+
daemonSubcommand: () => daemonSubcommand,
|
|
654168
|
+
attachHandler: () => attachHandler,
|
|
654169
|
+
appendDaemonLog: () => appendDaemonLog
|
|
654170
|
+
});
|
|
654171
|
+
import { existsSync as existsSync19, mkdirSync as mkdirSync12, readFileSync as readFileSync27, writeFileSync as writeFileSync12, appendFileSync as appendFileSync4 } from "fs";
|
|
654172
|
+
import { join as join163 } from "path";
|
|
654173
|
+
import { execSync as execSync2 } from "child_process";
|
|
654174
|
+
function daemonLogPath() {
|
|
654175
|
+
return join163(getClaudeConfigHomeDir(), "daemon.log");
|
|
654176
|
+
}
|
|
654177
|
+
function scheduledStatusPath() {
|
|
654178
|
+
return join163(getClaudeConfigHomeDir(), "daemon.scheduled.status.json");
|
|
654179
|
+
}
|
|
654180
|
+
function printDaemonUsage() {
|
|
654181
|
+
console.log(`Usage: claude daemon <subcommand>
|
|
654182
|
+
|
|
654183
|
+
Subcommands:
|
|
654184
|
+
start Start the supervisor (default)
|
|
654185
|
+
stop [--any] Stop the supervisor (or displace any holder with --any)
|
|
654186
|
+
restart Restart the supervisor
|
|
654187
|
+
status Show supervisor + worker status
|
|
654188
|
+
logs Tail the daemon log
|
|
654189
|
+
install Install a persistent service (launchd/systemd)
|
|
654190
|
+
uninstall Remove the persistent service
|
|
654191
|
+
scheduled add|rm Manage scheduled tasks
|
|
654192
|
+
remote-control Configure the remote-control daemon worker
|
|
654193
|
+
hub Interactive daemon hub (TTY)
|
|
654194
|
+
--help Show this help
|
|
654195
|
+
`);
|
|
654196
|
+
}
|
|
654197
|
+
async function daemonSubcommand(sub, args) {
|
|
654198
|
+
switch (sub) {
|
|
654199
|
+
case "start":
|
|
654200
|
+
await runSupervisor(["start", ...args]);
|
|
654201
|
+
return;
|
|
654202
|
+
case "stop": {
|
|
654203
|
+
const any3 = args.includes("--any") || args.includes("-a");
|
|
654204
|
+
if (any3) {
|
|
654205
|
+
const res = await displaceAny();
|
|
654206
|
+
if (res.displaced && res.holder) {
|
|
654207
|
+
console.log(`Stopped background sessions held by pid=${res.holder.supervisorPid}.`);
|
|
654208
|
+
} else if (!res.holder) {
|
|
654209
|
+
console.log("No background sessions found.");
|
|
654210
|
+
}
|
|
654211
|
+
} else {
|
|
654212
|
+
const res = await stopExistingSupervisor();
|
|
654213
|
+
if (res.holder && !res.stopped) {
|
|
654214
|
+
console.error("Run `claude daemon stop --any` to stop any background sessions and report on the holder");
|
|
654215
|
+
process.exitCode = 1;
|
|
654216
|
+
} else if (res.stopped && res.holder) {
|
|
654217
|
+
console.log(`Stopped daemon (pid=${res.holder.supervisorPid}).`);
|
|
654218
|
+
} else {
|
|
654219
|
+
console.log("No daemon running.");
|
|
654220
|
+
}
|
|
654221
|
+
}
|
|
654222
|
+
break;
|
|
654223
|
+
}
|
|
654224
|
+
case "restart":
|
|
654225
|
+
await daemonRestart();
|
|
654226
|
+
break;
|
|
654227
|
+
case "status":
|
|
654228
|
+
await statusHandler();
|
|
654229
|
+
break;
|
|
654230
|
+
case "logs":
|
|
654231
|
+
await logsHandlerDaemon();
|
|
654232
|
+
break;
|
|
654233
|
+
case "install":
|
|
654234
|
+
await daemonInstall();
|
|
654235
|
+
break;
|
|
654236
|
+
case "uninstall":
|
|
654237
|
+
await daemonUninstall();
|
|
654238
|
+
break;
|
|
654239
|
+
case "scheduled":
|
|
654240
|
+
await scheduledHandler(args);
|
|
654241
|
+
break;
|
|
654242
|
+
case "remote-control":
|
|
654243
|
+
console.log("remote-control daemon worker: configured via the remoteControlAtStartup setting (B7 follow-up).");
|
|
654244
|
+
logEvent("daemon_remote_control_cli", {});
|
|
654245
|
+
break;
|
|
654246
|
+
case "hub":
|
|
654247
|
+
await renderDaemonHubStandalone();
|
|
654248
|
+
break;
|
|
654249
|
+
case "--help":
|
|
654250
|
+
case "-h":
|
|
654251
|
+
case "help":
|
|
654252
|
+
printDaemonUsage();
|
|
654253
|
+
break;
|
|
654254
|
+
default:
|
|
654255
|
+
console.error(`Unknown daemon subcommand: ${sub}`);
|
|
654256
|
+
printDaemonUsage();
|
|
654257
|
+
process.exitCode = 1;
|
|
654258
|
+
}
|
|
654259
|
+
process.exit(process.exitCode ?? 0);
|
|
654260
|
+
}
|
|
654261
|
+
async function statusHandler() {
|
|
654262
|
+
const lf = await readLockfile();
|
|
654263
|
+
const mtime = lockfileMtime();
|
|
654264
|
+
const cold = getDaemonColdStart();
|
|
654265
|
+
const workers = listWorkers();
|
|
654266
|
+
console.log("Daemon status");
|
|
654267
|
+
if (!lf) {
|
|
654268
|
+
console.log(" supervisor: not running (no lockfile)");
|
|
654269
|
+
} else {
|
|
654270
|
+
const alive = isPidAlive(lf.supervisorPid);
|
|
654271
|
+
console.log(` supervisor: pid=${lf.supervisorPid} ${alive ? "running" : "dead"} start=${new Date(lf.supervisorProcStart).toISOString()}${mtime ? ` (lockfile mtime=${new Date(mtime).toISOString()})` : ""}`);
|
|
654272
|
+
}
|
|
654273
|
+
console.log(` coldStart: ${cold}`);
|
|
654274
|
+
console.log(` daemon.json: ${getDaemonJsonPath()} (${existsSync19(getDaemonJsonPath()) ? "present" : "absent"})`);
|
|
654275
|
+
console.log(` workers: ${workers.length}`);
|
|
654276
|
+
for (const w3 of workers) {
|
|
654277
|
+
const alive = isPidAlive(w3.pid);
|
|
654278
|
+
console.log(` id=${w3.id} kind=${w3.kind} pid=${w3.pid} ${alive ? "alive" : "dead"} outcome=${w3.outcome} restart=${w3.restart} started=${new Date(w3.startedAt).toISOString()}`);
|
|
654279
|
+
}
|
|
654280
|
+
}
|
|
654281
|
+
async function logsHandlerDaemon() {
|
|
654282
|
+
const path28 = daemonLogPath();
|
|
654283
|
+
if (!existsSync19(path28)) {
|
|
654284
|
+
console.log(`No daemon log at ${path28}`);
|
|
654285
|
+
return;
|
|
654286
|
+
}
|
|
654287
|
+
try {
|
|
654288
|
+
const out = execSync2(`tail -n 200 ${JSON.stringify(path28)}`, {
|
|
654289
|
+
encoding: "utf-8",
|
|
654290
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
654291
|
+
});
|
|
654292
|
+
process.stdout.write(out);
|
|
654293
|
+
} catch (err2) {
|
|
654294
|
+
const raw = readFileSync27(path28, { encoding: "utf-8" });
|
|
654295
|
+
const lines2 = raw.split(`
|
|
654296
|
+
`).slice(-200).join(`
|
|
654297
|
+
`);
|
|
654298
|
+
process.stdout.write(lines2);
|
|
654299
|
+
}
|
|
654300
|
+
}
|
|
654301
|
+
async function scheduledHandler(args) {
|
|
654302
|
+
const op = args[0];
|
|
654303
|
+
if (op !== "add" && op !== "remove" && op !== "rm" && op !== "list") {
|
|
654304
|
+
console.error("Usage: claude daemon scheduled add|remove <task-id> [--schedule <cron>] [--prompt <text>]");
|
|
654305
|
+
process.exitCode = 1;
|
|
654306
|
+
return;
|
|
654307
|
+
}
|
|
654308
|
+
const config7 = readScheduledConfig();
|
|
654309
|
+
if (op === "list") {
|
|
654310
|
+
console.log("Scheduled tasks:");
|
|
654311
|
+
for (const t4 of config7) {
|
|
654312
|
+
console.log(` ${t4.id} ${t4.schedule} ${t4.enabled ? "enabled" : "disabled"} "${t4.prompt}"`);
|
|
654313
|
+
}
|
|
654314
|
+
return;
|
|
654315
|
+
}
|
|
654316
|
+
const taskId = args[1];
|
|
654317
|
+
if (!taskId) {
|
|
654318
|
+
console.error("task-id required");
|
|
654319
|
+
process.exitCode = 1;
|
|
654320
|
+
return;
|
|
654321
|
+
}
|
|
654322
|
+
if (op === "add") {
|
|
654323
|
+
const schedule = flagValue(args, "--schedule") ?? "0 * * * *";
|
|
654324
|
+
const prompt = flagValue(args, "--prompt") ?? "";
|
|
654325
|
+
const task = { id: taskId, schedule, prompt, enabled: true };
|
|
654326
|
+
const idx = config7.findIndex((t4) => t4.id === taskId);
|
|
654327
|
+
if (idx >= 0)
|
|
654328
|
+
config7[idx] = task;
|
|
654329
|
+
else
|
|
654330
|
+
config7.push(task);
|
|
654331
|
+
writeScheduledConfig(config7);
|
|
654332
|
+
logEvent("daemon_scheduled_add", { taskId });
|
|
654333
|
+
console.log(`Scheduled task ${taskId} added.`);
|
|
654334
|
+
} else {
|
|
654335
|
+
const idx = config7.findIndex((t4) => t4.id === taskId);
|
|
654336
|
+
if (idx < 0) {
|
|
654337
|
+
console.error(`Scheduled task ${taskId} not found.`);
|
|
654338
|
+
process.exitCode = 1;
|
|
654339
|
+
return;
|
|
654340
|
+
}
|
|
654341
|
+
config7.splice(idx, 1);
|
|
654342
|
+
writeScheduledConfig(config7);
|
|
654343
|
+
logEvent("daemon_scheduled_remove", { taskId });
|
|
654344
|
+
console.log(`Scheduled task ${taskId} removed.`);
|
|
654345
|
+
}
|
|
654346
|
+
}
|
|
654347
|
+
function flagValue(args, flag) {
|
|
654348
|
+
const i6 = args.indexOf(flag);
|
|
654349
|
+
return i6 >= 0 && i6 + 1 < args.length ? args[i6 + 1] : undefined;
|
|
654350
|
+
}
|
|
654351
|
+
function readScheduledConfig() {
|
|
654352
|
+
const path28 = getDaemonJsonPath();
|
|
654353
|
+
if (!existsSync19(path28))
|
|
654354
|
+
return [];
|
|
654355
|
+
try {
|
|
654356
|
+
const parsed = JSON.parse(readFileSync27(path28, { encoding: "utf-8" }));
|
|
654357
|
+
return Array.isArray(parsed?.scheduled) ? parsed.scheduled : [];
|
|
654358
|
+
} catch {
|
|
654359
|
+
return [];
|
|
654360
|
+
}
|
|
654361
|
+
}
|
|
654362
|
+
function writeScheduledConfig(tasks2) {
|
|
654363
|
+
const path28 = getDaemonJsonPath();
|
|
654364
|
+
let current = {};
|
|
654365
|
+
if (existsSync19(path28)) {
|
|
654366
|
+
try {
|
|
654367
|
+
current = JSON.parse(readFileSync27(path28, { encoding: "utf-8" }));
|
|
654368
|
+
} catch {
|
|
654369
|
+
current = {};
|
|
654370
|
+
}
|
|
654371
|
+
}
|
|
654372
|
+
current.scheduled = tasks2;
|
|
654373
|
+
mkdirSync12(join163(path28, ".."), { recursive: true });
|
|
654374
|
+
writeFileSync12(path28, JSON.stringify(current, null, 2), { encoding: "utf-8" });
|
|
654375
|
+
writeFileSync12(scheduledStatusPath(), JSON.stringify({ tasks: tasks2, updatedAt: Date.now() }, null, 2), {
|
|
654376
|
+
encoding: "utf-8"
|
|
654377
|
+
});
|
|
654378
|
+
}
|
|
654379
|
+
async function renderDaemonHubStandalone() {
|
|
654380
|
+
console.log("Claude daemon hub");
|
|
654381
|
+
await statusHandler();
|
|
654382
|
+
console.log(`
|
|
654383
|
+
(Press q to quit \u2014 interactive hub is a follow-up.)`);
|
|
654384
|
+
}
|
|
654385
|
+
async function stopHandler(id) {
|
|
654386
|
+
const w3 = getWorker(id);
|
|
654387
|
+
if (!w3) {
|
|
654388
|
+
const pid = Number(id);
|
|
654389
|
+
if (Number.isFinite(pid) && isPidAlive(pid)) {
|
|
654390
|
+
try {
|
|
654391
|
+
process.kill(pid, "SIGTERM");
|
|
654392
|
+
console.log(`Sent SIGTERM to pid ${pid}.`);
|
|
654393
|
+
process.exit(0);
|
|
654394
|
+
} catch {}
|
|
654395
|
+
}
|
|
654396
|
+
console.error(`No background session "${id}" found.`);
|
|
654397
|
+
process.exitCode = 1;
|
|
654398
|
+
process.exit(process.exitCode ?? 1);
|
|
654399
|
+
return;
|
|
654400
|
+
}
|
|
654401
|
+
await settleWorker(id, 3000);
|
|
654402
|
+
console.log(`Stopped background session ${id} (pid=${w3.pid}).`);
|
|
654403
|
+
process.exit(process.exitCode ?? 0);
|
|
654404
|
+
}
|
|
654405
|
+
async function attachHandler(id) {
|
|
654406
|
+
const w3 = getWorker(id);
|
|
654407
|
+
if (!w3) {
|
|
654408
|
+
console.error(`No background session "${id}" found.`);
|
|
654409
|
+
process.exitCode = 1;
|
|
654410
|
+
process.exit(process.exitCode ?? 1);
|
|
654411
|
+
return;
|
|
654412
|
+
}
|
|
654413
|
+
console.log(`Background session ${id}: kind=${w3.kind} pid=${w3.pid} outcome=${w3.outcome} started=${new Date(w3.startedAt).toISOString()}`);
|
|
654414
|
+
console.log(`Log: ${daemonLogPath()}`);
|
|
654415
|
+
console.log("(Interactive attach is a follow-up.)");
|
|
654416
|
+
process.exit(process.exitCode ?? 0);
|
|
654417
|
+
}
|
|
654418
|
+
async function logsHandler(id) {
|
|
654419
|
+
const path28 = daemonLogPath();
|
|
654420
|
+
if (!existsSync19(path28)) {
|
|
654421
|
+
console.log(`No daemon log at ${path28}`);
|
|
654422
|
+
process.exit(0);
|
|
654423
|
+
}
|
|
654424
|
+
const w3 = getWorker(id);
|
|
654425
|
+
const pid = w3?.pid ?? Number(id);
|
|
654426
|
+
try {
|
|
654427
|
+
const grep = Number.isFinite(pid) ? `grep -F "[pid=${pid}]" ${JSON.stringify(path28)} || true` : null;
|
|
654428
|
+
const cmd = grep ? `${grep} | tail -n 200` : `tail -n 200 ${JSON.stringify(path28)}`;
|
|
654429
|
+
const out = execSync2(cmd, { encoding: "utf-8", stdio: ["ignore", "pipe", "pipe"] });
|
|
654430
|
+
process.stdout.write(out);
|
|
654431
|
+
} catch {
|
|
654432
|
+
const raw = readFileSync27(path28, { encoding: "utf-8" });
|
|
654433
|
+
process.stdout.write(raw.split(`
|
|
654434
|
+
`).slice(-200).join(`
|
|
654435
|
+
`));
|
|
654436
|
+
}
|
|
654437
|
+
process.exit(process.exitCode ?? 0);
|
|
654438
|
+
}
|
|
654439
|
+
function appendDaemonLog(line) {
|
|
654440
|
+
try {
|
|
654441
|
+
mkdirSync12(join163(daemonLogPath(), ".."), { recursive: true });
|
|
654442
|
+
appendFileSync4(daemonLogPath(), line.endsWith(`
|
|
654443
|
+
`) ? line : line + `
|
|
654444
|
+
`, {
|
|
654445
|
+
encoding: "utf-8"
|
|
654446
|
+
});
|
|
654447
|
+
} catch {}
|
|
654448
|
+
}
|
|
654449
|
+
var init_daemon = __esm(() => {
|
|
654450
|
+
init_envUtils();
|
|
654451
|
+
init_analytics();
|
|
654452
|
+
init_supervisor();
|
|
654453
|
+
init_lockfile();
|
|
654454
|
+
init_workerRegistry();
|
|
654455
|
+
init_process();
|
|
654456
|
+
});
|
|
654457
|
+
|
|
653338
654458
|
// src/daemon/main.ts
|
|
653339
654459
|
var exports_main = {};
|
|
653340
654460
|
__export(exports_main, {
|
|
654461
|
+
runSupervisor: () => runSupervisor,
|
|
653341
654462
|
daemonMain: () => daemonMain
|
|
653342
654463
|
});
|
|
653343
|
-
var daemonMain = () =>
|
|
653344
|
-
|
|
654464
|
+
var daemonMain = async (args) => {
|
|
654465
|
+
const sub = args[0] ?? "start";
|
|
654466
|
+
if (sub === "start" || sub === undefined) {
|
|
654467
|
+
await runSupervisor(args.length > 0 ? args.slice(1) : ["start"]);
|
|
654468
|
+
return;
|
|
654469
|
+
}
|
|
654470
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
654471
|
+
await daemonSubcommand2(sub, args.slice(1));
|
|
654472
|
+
};
|
|
654473
|
+
var init_main3 = __esm(() => {
|
|
654474
|
+
init_supervisor();
|
|
654475
|
+
init_supervisor();
|
|
654476
|
+
});
|
|
653345
654477
|
|
|
653346
654478
|
// src/cli/bg.ts
|
|
653347
654479
|
var exports_bg = {};
|
|
653348
654480
|
__export(exports_bg, {
|
|
653349
654481
|
psHandler: () => psHandler,
|
|
653350
|
-
logsHandler: () =>
|
|
654482
|
+
logsHandler: () => logsHandler2,
|
|
653351
654483
|
killHandler: () => killHandler,
|
|
653352
654484
|
handleBgFlag: () => handleBgFlag,
|
|
653353
|
-
attachHandler: () =>
|
|
654485
|
+
attachHandler: () => attachHandler2
|
|
653354
654486
|
});
|
|
653355
|
-
var psHandler = async () => {},
|
|
654487
|
+
var psHandler = async () => {}, logsHandler2 = async () => {}, attachHandler2 = async () => {}, killHandler = async () => {}, handleBgFlag = async () => {};
|
|
653356
654488
|
var init_bg2 = () => {};
|
|
653357
654489
|
|
|
653358
654490
|
// src/cli/handlers/templateJobs.ts
|
|
@@ -655431,11 +656563,11 @@ var require_extra_typings = __commonJS((exports, module) => {
|
|
|
655431
656563
|
});
|
|
655432
656564
|
|
|
655433
656565
|
// node_modules/.bun/@commander-js+extra-typings@14.0.0+1cee9bec6fc8d393/node_modules/@commander-js/extra-typings/esm.mjs
|
|
655434
|
-
var import__6,
|
|
656566
|
+
var import__6, program2, createCommand, createArgument, createOption, CommanderError, InvalidArgumentError, InvalidOptionArgumentError, Command, Argument, Option, Help;
|
|
655435
656567
|
var init_esm26 = __esm(() => {
|
|
655436
656568
|
import__6 = __toESM(require_extra_typings(), 1);
|
|
655437
656569
|
({
|
|
655438
|
-
program,
|
|
656570
|
+
program: program2,
|
|
655439
656571
|
createCommand,
|
|
655440
656572
|
createArgument,
|
|
655441
656573
|
createOption,
|
|
@@ -656024,9 +657156,9 @@ __export(exports_upstreamproxy, {
|
|
|
656024
657156
|
getUpstreamProxyEnv: () => getUpstreamProxyEnv,
|
|
656025
657157
|
SESSION_TOKEN_PATH: () => SESSION_TOKEN_PATH
|
|
656026
657158
|
});
|
|
656027
|
-
import { mkdir as mkdir55, readFile as
|
|
656028
|
-
import { homedir as
|
|
656029
|
-
import { join as
|
|
657159
|
+
import { mkdir as mkdir55, readFile as readFile64, unlink as unlink27, writeFile as writeFile58 } from "fs/promises";
|
|
657160
|
+
import { homedir as homedir41 } from "os";
|
|
657161
|
+
import { join as join164 } from "path";
|
|
656030
657162
|
async function initUpstreamProxy(opts) {
|
|
656031
657163
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_REMOTE)) {
|
|
656032
657164
|
return state3;
|
|
@@ -656047,7 +657179,7 @@ async function initUpstreamProxy(opts) {
|
|
|
656047
657179
|
}
|
|
656048
657180
|
setNonDumpable();
|
|
656049
657181
|
const baseUrl = opts?.ccrBaseUrl ?? process.env.ANTHROPIC_BASE_URL ?? "https://api.anthropic.com";
|
|
656050
|
-
const caBundlePath = opts?.caBundlePath ??
|
|
657182
|
+
const caBundlePath = opts?.caBundlePath ?? join164(homedir41(), ".ccr", "ca-bundle.crt");
|
|
656051
657183
|
const caOk = await downloadCaBundle(baseUrl, opts?.systemCaPath ?? SYSTEM_CA_BUNDLE, caBundlePath);
|
|
656052
657184
|
if (!caOk)
|
|
656053
657185
|
return state3;
|
|
@@ -656057,7 +657189,7 @@ async function initUpstreamProxy(opts) {
|
|
|
656057
657189
|
registerCleanup(async () => relay.stop());
|
|
656058
657190
|
state3 = { enabled: true, port: relay.port, caBundlePath };
|
|
656059
657191
|
logForDebugging(`[upstreamproxy] enabled on 127.0.0.1:${relay.port}`);
|
|
656060
|
-
await
|
|
657192
|
+
await unlink27(tokenPath).catch(() => {
|
|
656061
657193
|
logForDebugging("[upstreamproxy] token file unlink failed", {
|
|
656062
657194
|
level: "warn"
|
|
656063
657195
|
});
|
|
@@ -656105,7 +657237,7 @@ function resetUpstreamProxyForTests() {
|
|
|
656105
657237
|
}
|
|
656106
657238
|
async function readToken(path28) {
|
|
656107
657239
|
try {
|
|
656108
|
-
const raw = await
|
|
657240
|
+
const raw = await readFile64(path28, "utf8");
|
|
656109
657241
|
return raw.trim() || null;
|
|
656110
657242
|
} catch (err2) {
|
|
656111
657243
|
if (isENOENT(err2))
|
|
@@ -656146,9 +657278,9 @@ async function downloadCaBundle(baseUrl, systemCaPath, outPath) {
|
|
|
656146
657278
|
return false;
|
|
656147
657279
|
}
|
|
656148
657280
|
const ccrCa = await resp.text();
|
|
656149
|
-
const systemCa = await
|
|
656150
|
-
await mkdir55(
|
|
656151
|
-
await
|
|
657281
|
+
const systemCa = await readFile64(systemCaPath, "utf8").catch(() => "");
|
|
657282
|
+
await mkdir55(join164(outPath, ".."), { recursive: true });
|
|
657283
|
+
await writeFile58(outPath, systemCa + `
|
|
656152
657284
|
` + ccrCa, "utf8");
|
|
656153
657285
|
return true;
|
|
656154
657286
|
} catch (err2) {
|
|
@@ -656609,15 +657741,15 @@ function FpsMetricsProvider(t0) {
|
|
|
656609
657741
|
const $4 = import_compiler_runtime258.c(3);
|
|
656610
657742
|
const {
|
|
656611
657743
|
getFpsMetrics,
|
|
656612
|
-
children:
|
|
657744
|
+
children: children3
|
|
656613
657745
|
} = t0;
|
|
656614
657746
|
let t1;
|
|
656615
|
-
if ($4[0] !==
|
|
657747
|
+
if ($4[0] !== children3 || $4[1] !== getFpsMetrics) {
|
|
656616
657748
|
t1 = /* @__PURE__ */ jsx_dev_runtime351.jsxDEV(FpsMetricsContext.Provider, {
|
|
656617
657749
|
value: getFpsMetrics,
|
|
656618
|
-
children:
|
|
657750
|
+
children: children3
|
|
656619
657751
|
}, undefined, false, undefined, this);
|
|
656620
|
-
$4[0] =
|
|
657752
|
+
$4[0] = children3;
|
|
656621
657753
|
$4[1] = getFpsMetrics;
|
|
656622
657754
|
$4[2] = t1;
|
|
656623
657755
|
} else {
|
|
@@ -656720,7 +657852,7 @@ function StatsProvider(t0) {
|
|
|
656720
657852
|
const $4 = import_compiler_runtime259.c(7);
|
|
656721
657853
|
const {
|
|
656722
657854
|
store: externalStore,
|
|
656723
|
-
children:
|
|
657855
|
+
children: children3
|
|
656724
657856
|
} = t0;
|
|
656725
657857
|
let t1;
|
|
656726
657858
|
if ($4[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
@@ -656759,12 +657891,12 @@ function StatsProvider(t0) {
|
|
|
656759
657891
|
}
|
|
656760
657892
|
import_react190.useEffect(t22, t32);
|
|
656761
657893
|
let t4;
|
|
656762
|
-
if ($4[4] !==
|
|
657894
|
+
if ($4[4] !== children3 || $4[5] !== store) {
|
|
656763
657895
|
t4 = /* @__PURE__ */ jsx_dev_runtime352.jsxDEV(StatsContext.Provider, {
|
|
656764
657896
|
value: store,
|
|
656765
|
-
children:
|
|
657897
|
+
children: children3
|
|
656766
657898
|
}, undefined, false, undefined, this);
|
|
656767
|
-
$4[4] =
|
|
657899
|
+
$4[4] = children3;
|
|
656768
657900
|
$4[5] = store;
|
|
656769
657901
|
$4[6] = t4;
|
|
656770
657902
|
} else {
|
|
@@ -656928,16 +658060,16 @@ function App2(t0) {
|
|
|
656928
658060
|
getFpsMetrics,
|
|
656929
658061
|
stats,
|
|
656930
658062
|
initialState,
|
|
656931
|
-
children:
|
|
658063
|
+
children: children3
|
|
656932
658064
|
} = t0;
|
|
656933
658065
|
let t1;
|
|
656934
|
-
if ($4[0] !==
|
|
658066
|
+
if ($4[0] !== children3 || $4[1] !== initialState) {
|
|
656935
658067
|
t1 = /* @__PURE__ */ jsx_dev_runtime353.jsxDEV(AppStateProvider, {
|
|
656936
658068
|
initialState,
|
|
656937
658069
|
onChangeAppState,
|
|
656938
|
-
children:
|
|
658070
|
+
children: children3
|
|
656939
658071
|
}, undefined, false, undefined, this);
|
|
656940
|
-
$4[0] =
|
|
658072
|
+
$4[0] = children3;
|
|
656941
658073
|
$4[1] = initialState;
|
|
656942
658074
|
$4[2] = t1;
|
|
656943
658075
|
} else {
|
|
@@ -657208,7 +658340,7 @@ var init_IdleReturnDialog = __esm(() => {
|
|
|
657208
658340
|
});
|
|
657209
658341
|
|
|
657210
658342
|
// src/services/preventSleep.ts
|
|
657211
|
-
import { spawn as
|
|
658343
|
+
import { spawn as spawn15 } from "child_process";
|
|
657212
658344
|
function startPreventSleep() {
|
|
657213
658345
|
refCount++;
|
|
657214
658346
|
if (refCount === 1) {
|
|
@@ -657266,7 +658398,7 @@ function spawnCaffeinate() {
|
|
|
657266
658398
|
});
|
|
657267
658399
|
}
|
|
657268
658400
|
try {
|
|
657269
|
-
caffeinateProcess =
|
|
658401
|
+
caffeinateProcess = spawn15("caffeinate", ["-i", "-t", String(CAFFEINATE_TIMEOUT_SECONDS)], {
|
|
657270
658402
|
stdio: "ignore"
|
|
657271
658403
|
});
|
|
657272
658404
|
caffeinateProcess.unref();
|
|
@@ -661882,8 +663014,8 @@ __export(exports_inboundAttachments, {
|
|
|
661882
663014
|
extractInboundAttachments: () => extractInboundAttachments
|
|
661883
663015
|
});
|
|
661884
663016
|
import { randomUUID as randomUUID46 } from "crypto";
|
|
661885
|
-
import { mkdir as mkdir56, writeFile as
|
|
661886
|
-
import { basename as basename50, join as
|
|
663017
|
+
import { mkdir as mkdir56, writeFile as writeFile59 } from "fs/promises";
|
|
663018
|
+
import { basename as basename50, join as join165 } from "path";
|
|
661887
663019
|
function debug4(msg) {
|
|
661888
663020
|
logForDebugging(`[bridge:inbound-attach] ${msg}`);
|
|
661889
663021
|
}
|
|
@@ -661899,7 +663031,7 @@ function sanitizeFileName(name3) {
|
|
|
661899
663031
|
return base2 || "attachment";
|
|
661900
663032
|
}
|
|
661901
663033
|
function uploadsDir() {
|
|
661902
|
-
return
|
|
663034
|
+
return join165(getClaudeConfigHomeDir(), "uploads", getSessionId());
|
|
661903
663035
|
}
|
|
661904
663036
|
async function resolveOne(att) {
|
|
661905
663037
|
const token = getBridgeAccessToken();
|
|
@@ -661928,10 +663060,10 @@ async function resolveOne(att) {
|
|
|
661928
663060
|
const safeName = sanitizeFileName(att.file_name);
|
|
661929
663061
|
const prefix = (att.file_uuid.slice(0, 8) || randomUUID46().slice(0, 8)).replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
661930
663062
|
const dir = uploadsDir();
|
|
661931
|
-
const outPath =
|
|
663063
|
+
const outPath = join165(dir, `${prefix}-${safeName}`);
|
|
661932
663064
|
try {
|
|
661933
663065
|
await mkdir56(dir, { recursive: true });
|
|
661934
|
-
await
|
|
663066
|
+
await writeFile59(outPath, data);
|
|
661935
663067
|
} catch (e4) {
|
|
661936
663068
|
debug4(`write ${outPath} failed: ${e4}`);
|
|
661937
663069
|
return;
|
|
@@ -668396,16 +669528,16 @@ function DiffBody(t0) {
|
|
|
668396
669528
|
function DiffFrame(t0) {
|
|
668397
669529
|
const $4 = import_compiler_runtime274.c(5);
|
|
668398
669530
|
const {
|
|
668399
|
-
children:
|
|
669531
|
+
children: children3,
|
|
668400
669532
|
placeholder
|
|
668401
669533
|
} = t0;
|
|
668402
669534
|
let t1;
|
|
668403
|
-
if ($4[0] !==
|
|
669535
|
+
if ($4[0] !== children3 || $4[1] !== placeholder) {
|
|
668404
669536
|
t1 = placeholder ? /* @__PURE__ */ jsx_dev_runtime369.jsxDEV(ThemedText, {
|
|
668405
669537
|
dimColor: true,
|
|
668406
669538
|
children: "\u2026"
|
|
668407
|
-
}, undefined, false, undefined, this) :
|
|
668408
|
-
$4[0] =
|
|
669539
|
+
}, undefined, false, undefined, this) : children3;
|
|
669540
|
+
$4[0] = children3;
|
|
668409
669541
|
$4[1] = placeholder;
|
|
668410
669542
|
$4[2] = t1;
|
|
668411
669543
|
} else {
|
|
@@ -668927,8 +670059,8 @@ var init_ShowInIDEPrompt = __esm(() => {
|
|
|
668927
670059
|
});
|
|
668928
670060
|
|
|
668929
670061
|
// src/components/permissions/FilePermissionDialog/permissionOptions.tsx
|
|
668930
|
-
import { homedir as
|
|
668931
|
-
import { basename as basename54, join as
|
|
670062
|
+
import { homedir as homedir42 } from "os";
|
|
670063
|
+
import { basename as basename54, join as join166, sep as sep39 } from "path";
|
|
668932
670064
|
function isInClaudeFolder(filePath) {
|
|
668933
670065
|
const absolutePath = expandPath(filePath);
|
|
668934
670066
|
const claudeFolderPath = expandPath(`${getOriginalCwd()}/.claude`);
|
|
@@ -668938,7 +670070,7 @@ function isInClaudeFolder(filePath) {
|
|
|
668938
670070
|
}
|
|
668939
670071
|
function isInGlobalClaudeFolder(filePath) {
|
|
668940
670072
|
const absolutePath = expandPath(filePath);
|
|
668941
|
-
const globalClaudeFolderPath =
|
|
670073
|
+
const globalClaudeFolderPath = join166(homedir42(), ".claude");
|
|
668942
670074
|
const normalizedAbsolutePath = normalizeCaseForComparison2(absolutePath);
|
|
668943
670075
|
const normalizedGlobalClaudeFolderPath = normalizeCaseForComparison2(globalClaudeFolderPath);
|
|
668944
670076
|
return normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + sep39.toLowerCase()) || normalizedAbsolutePath.startsWith(normalizedGlobalClaudeFolderPath + "/");
|
|
@@ -686092,8 +687224,8 @@ function findTextObject(text2, offset, objectType2, isInner) {
|
|
|
686092
687224
|
return findWordObject(text2, offset, isInner, (ch2) => !isVimWhitespace(ch2));
|
|
686093
687225
|
const pair = PAIRS[objectType2];
|
|
686094
687226
|
if (pair) {
|
|
686095
|
-
const [
|
|
686096
|
-
return
|
|
687227
|
+
const [open16, close] = pair;
|
|
687228
|
+
return open16 === close ? findQuoteObject(text2, offset, open16, isInner) : findBracketObject(text2, offset, open16, close, isInner);
|
|
686097
687229
|
}
|
|
686098
687230
|
return null;
|
|
686099
687231
|
}
|
|
@@ -686168,13 +687300,13 @@ function findQuoteObject(text2, offset, quote2, isInner) {
|
|
|
686168
687300
|
}
|
|
686169
687301
|
return null;
|
|
686170
687302
|
}
|
|
686171
|
-
function findBracketObject(text2, offset,
|
|
687303
|
+
function findBracketObject(text2, offset, open16, close, isInner) {
|
|
686172
687304
|
let depth = 0;
|
|
686173
687305
|
let start = -1;
|
|
686174
687306
|
for (let i6 = offset;i6 >= 0; i6--) {
|
|
686175
687307
|
if (text2[i6] === close && i6 !== offset)
|
|
686176
687308
|
depth++;
|
|
686177
|
-
else if (text2[i6] ===
|
|
687309
|
+
else if (text2[i6] === open16) {
|
|
686178
687310
|
if (depth === 0) {
|
|
686179
687311
|
start = i6;
|
|
686180
687312
|
break;
|
|
@@ -686187,7 +687319,7 @@ function findBracketObject(text2, offset, open15, close, isInner) {
|
|
|
686187
687319
|
depth = 0;
|
|
686188
687320
|
let end = -1;
|
|
686189
687321
|
for (let i6 = start + 1;i6 < text2.length; i6++) {
|
|
686190
|
-
if (text2[i6] ===
|
|
687322
|
+
if (text2[i6] === open16)
|
|
686191
687323
|
depth++;
|
|
686192
687324
|
else if (text2[i6] === close) {
|
|
686193
687325
|
if (depth === 0) {
|
|
@@ -688660,18 +689792,18 @@ function SummaryPill(t0) {
|
|
|
688660
689792
|
const {
|
|
688661
689793
|
selected,
|
|
688662
689794
|
onClick,
|
|
688663
|
-
children:
|
|
689795
|
+
children: children3
|
|
688664
689796
|
} = t0;
|
|
688665
689797
|
const [hover, setHover] = import_react247.useState(false);
|
|
688666
689798
|
const t1 = selected || hover;
|
|
688667
689799
|
let t22;
|
|
688668
|
-
if ($4[0] !==
|
|
689800
|
+
if ($4[0] !== children3 || $4[1] !== t1) {
|
|
688669
689801
|
t22 = /* @__PURE__ */ jsx_dev_runtime418.jsxDEV(ThemedText, {
|
|
688670
689802
|
color: "background",
|
|
688671
689803
|
inverse: t1,
|
|
688672
|
-
children:
|
|
689804
|
+
children: children3
|
|
688673
689805
|
}, undefined, false, undefined, this);
|
|
688674
|
-
$4[0] =
|
|
689806
|
+
$4[0] = children3;
|
|
688675
689807
|
$4[1] = t1;
|
|
688676
689808
|
$4[2] = t22;
|
|
688677
689809
|
} else {
|
|
@@ -694358,9 +695490,9 @@ function initSkillImprovement() {
|
|
|
694358
695490
|
async function applySkillImprovement(skillName, updates) {
|
|
694359
695491
|
if (!skillName)
|
|
694360
695492
|
return;
|
|
694361
|
-
const { join:
|
|
695493
|
+
const { join: join167 } = await import("path");
|
|
694362
695494
|
const fs19 = await import("fs/promises");
|
|
694363
|
-
const filePath =
|
|
695495
|
+
const filePath = join167(getCwd(), ".claude", "skills", skillName, "SKILL.md");
|
|
694364
695496
|
let currentContent;
|
|
694365
695497
|
try {
|
|
694366
695498
|
currentContent = await fs19.readFile(filePath, "utf-8");
|
|
@@ -696492,13 +697624,13 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
696492
697624
|
readlink: readlink3,
|
|
696493
697625
|
stat: stat50,
|
|
696494
697626
|
symlink: symlink6,
|
|
696495
|
-
unlink:
|
|
697627
|
+
unlink: unlink28,
|
|
696496
697628
|
utimes: utimes3
|
|
696497
697629
|
} = __require("fs/promises");
|
|
696498
697630
|
var {
|
|
696499
697631
|
dirname: dirname70,
|
|
696500
697632
|
isAbsolute: isAbsolute29,
|
|
696501
|
-
join:
|
|
697633
|
+
join: join167,
|
|
696502
697634
|
parse: parse17,
|
|
696503
697635
|
resolve: resolve51,
|
|
696504
697636
|
sep: sep42,
|
|
@@ -696690,7 +697822,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
696690
697822
|
}
|
|
696691
697823
|
async function mayCopyFile(srcStat, src, dest, opts) {
|
|
696692
697824
|
if (opts.force) {
|
|
696693
|
-
await
|
|
697825
|
+
await unlink28(dest);
|
|
696694
697826
|
return _copyFile(srcStat, src, dest, opts);
|
|
696695
697827
|
} else if (opts.errorOnExist) {
|
|
696696
697828
|
throw new ERR_FS_CP_EEXIST({
|
|
@@ -696747,8 +697879,8 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
696747
697879
|
const dir = await readdir36(src);
|
|
696748
697880
|
for (let i6 = 0;i6 < dir.length; i6++) {
|
|
696749
697881
|
const item = dir[i6];
|
|
696750
|
-
const srcItem =
|
|
696751
|
-
const destItem =
|
|
697882
|
+
const srcItem = join167(src, item);
|
|
697883
|
+
const destItem = join167(dest, item);
|
|
696752
697884
|
const { destStat } = await checkPaths(srcItem, destItem, opts);
|
|
696753
697885
|
await startCopy(destStat, srcItem, destItem, opts);
|
|
696754
697886
|
}
|
|
@@ -696793,7 +697925,7 @@ var require_polyfill = __commonJS((exports, module) => {
|
|
|
696793
697925
|
return copyLink(resolvedSrc, dest);
|
|
696794
697926
|
}
|
|
696795
697927
|
async function copyLink(resolvedSrc, dest) {
|
|
696796
|
-
await
|
|
697928
|
+
await unlink28(dest);
|
|
696797
697929
|
return symlink6(resolvedSrc, dest);
|
|
696798
697930
|
}
|
|
696799
697931
|
module.exports = cp;
|
|
@@ -696817,7 +697949,7 @@ var require_cp = __commonJS((exports, module) => {
|
|
|
696817
697949
|
|
|
696818
697950
|
// node_modules/.bun/@npmcli+fs@5.0.0/node_modules/@npmcli/fs/lib/with-temp-dir.js
|
|
696819
697951
|
var require_with_temp_dir = __commonJS((exports, module) => {
|
|
696820
|
-
var { join:
|
|
697952
|
+
var { join: join167, sep: sep42 } = __require("path");
|
|
696821
697953
|
var getOptions2 = require_get_options();
|
|
696822
697954
|
var { mkdir: mkdir57, mkdtemp: mkdtemp4, rm: rm13 } = __require("fs/promises");
|
|
696823
697955
|
var withTempDir = async (root3, fn, opts) => {
|
|
@@ -696825,7 +697957,7 @@ var require_with_temp_dir = __commonJS((exports, module) => {
|
|
|
696825
697957
|
copy: ["tmpPrefix"]
|
|
696826
697958
|
});
|
|
696827
697959
|
await mkdir57(root3, { recursive: true });
|
|
696828
|
-
const target = await mkdtemp4(
|
|
697960
|
+
const target = await mkdtemp4(join167(`${root3}${sep42}`, options.tmpPrefix || ""));
|
|
696829
697961
|
let err2;
|
|
696830
697962
|
let result;
|
|
696831
697963
|
try {
|
|
@@ -696847,13 +697979,13 @@ var require_with_temp_dir = __commonJS((exports, module) => {
|
|
|
696847
697979
|
// node_modules/.bun/@npmcli+fs@5.0.0/node_modules/@npmcli/fs/lib/readdir-scoped.js
|
|
696848
697980
|
var require_readdir_scoped = __commonJS((exports, module) => {
|
|
696849
697981
|
var { readdir: readdir36 } = __require("fs/promises");
|
|
696850
|
-
var { join:
|
|
697982
|
+
var { join: join167 } = __require("path");
|
|
696851
697983
|
var readdirScoped = async (dir) => {
|
|
696852
697984
|
const results = [];
|
|
696853
697985
|
for (const item of await readdir36(dir)) {
|
|
696854
697986
|
if (item.startsWith("@")) {
|
|
696855
|
-
for (const scopedItem of await readdir36(
|
|
696856
|
-
results.push(
|
|
697987
|
+
for (const scopedItem of await readdir36(join167(dir, item))) {
|
|
697988
|
+
results.push(join167(item, scopedItem));
|
|
696857
697989
|
}
|
|
696858
697990
|
} else {
|
|
696859
697991
|
results.push(item);
|
|
@@ -696866,7 +697998,7 @@ var require_readdir_scoped = __commonJS((exports, module) => {
|
|
|
696866
697998
|
|
|
696867
697999
|
// node_modules/.bun/@npmcli+fs@5.0.0/node_modules/@npmcli/fs/lib/move-file.js
|
|
696868
698000
|
var require_move_file = __commonJS((exports, module) => {
|
|
696869
|
-
var { dirname: dirname70, join:
|
|
698001
|
+
var { dirname: dirname70, join: join167, resolve: resolve51, relative: relative37, isAbsolute: isAbsolute29 } = __require("path");
|
|
696870
698002
|
var fs19 = __require("fs/promises");
|
|
696871
698003
|
var pathExists2 = async (path31) => {
|
|
696872
698004
|
try {
|
|
@@ -696895,7 +698027,7 @@ var require_move_file = __commonJS((exports, module) => {
|
|
|
696895
698027
|
const sourceStat = await fs19.lstat(source);
|
|
696896
698028
|
if (sourceStat.isDirectory()) {
|
|
696897
698029
|
const files3 = await fs19.readdir(source);
|
|
696898
|
-
await Promise.all(files3.map((file2) => moveFile(
|
|
698030
|
+
await Promise.all(files3.map((file2) => moveFile(join167(source, file2), join167(destination, file2), options, false, symlinks)));
|
|
696899
698031
|
} else if (sourceStat.isSymbolicLink()) {
|
|
696900
698032
|
symlinks.push({ source, destination });
|
|
696901
698033
|
} else {
|
|
@@ -697084,10 +698216,10 @@ var require_entry_index = __commonJS((exports, module) => {
|
|
|
697084
698216
|
var {
|
|
697085
698217
|
appendFile: appendFile8,
|
|
697086
698218
|
mkdir: mkdir57,
|
|
697087
|
-
readFile:
|
|
698219
|
+
readFile: readFile65,
|
|
697088
698220
|
readdir: readdir36,
|
|
697089
698221
|
rm: rm13,
|
|
697090
|
-
writeFile:
|
|
698222
|
+
writeFile: writeFile60
|
|
697091
698223
|
} = __require("fs/promises");
|
|
697092
698224
|
var { Minipass } = require_commonjs();
|
|
697093
698225
|
var path31 = __require("path");
|
|
@@ -697141,7 +698273,7 @@ var require_entry_index = __commonJS((exports, module) => {
|
|
|
697141
698273
|
}
|
|
697142
698274
|
};
|
|
697143
698275
|
const write = async (tmp2) => {
|
|
697144
|
-
await
|
|
698276
|
+
await writeFile60(tmp2.target, newIndex, { flag: "wx" });
|
|
697145
698277
|
await mkdir57(path31.dirname(bucket), { recursive: true });
|
|
697146
698278
|
await moveFile(tmp2.target, bucket);
|
|
697147
698279
|
tmp2.moved = true;
|
|
@@ -697257,7 +698389,7 @@ ${hashEntry(stringified)} ${stringified}`);
|
|
|
697257
698389
|
}
|
|
697258
698390
|
exports.bucketEntries = bucketEntries;
|
|
697259
698391
|
async function bucketEntries(bucket, filter2) {
|
|
697260
|
-
const data = await
|
|
698392
|
+
const data = await readFile65(bucket, "utf8");
|
|
697261
698393
|
return _bucketEntries(data, filter2);
|
|
697262
698394
|
}
|
|
697263
698395
|
function _bucketEntries(data) {
|
|
@@ -702263,11 +703395,11 @@ var require_rm2 = __commonJS((exports, module) => {
|
|
|
702263
703395
|
var require_verify2 = __commonJS((exports, module) => {
|
|
702264
703396
|
var {
|
|
702265
703397
|
mkdir: mkdir57,
|
|
702266
|
-
readFile:
|
|
703398
|
+
readFile: readFile65,
|
|
702267
703399
|
rm: rm13,
|
|
702268
703400
|
stat: stat50,
|
|
702269
703401
|
truncate: truncate3,
|
|
702270
|
-
writeFile:
|
|
703402
|
+
writeFile: writeFile60
|
|
702271
703403
|
} = __require("fs/promises");
|
|
702272
703404
|
var contentPath = require_path2();
|
|
702273
703405
|
var fsm = require_lib19();
|
|
@@ -702460,11 +703592,11 @@ var require_verify2 = __commonJS((exports, module) => {
|
|
|
702460
703592
|
async function writeVerifile(cache9, opts) {
|
|
702461
703593
|
const verifile = path31.join(cache9, "_lastverified");
|
|
702462
703594
|
opts.log.silly("verify", "writing verifile to " + verifile);
|
|
702463
|
-
return
|
|
703595
|
+
return writeFile60(verifile, `${Date.now()}`);
|
|
702464
703596
|
}
|
|
702465
703597
|
module.exports.lastRun = lastRun;
|
|
702466
703598
|
async function lastRun(cache9) {
|
|
702467
|
-
const data = await
|
|
703599
|
+
const data = await readFile65(path31.join(cache9, "_lastverified"), { encoding: "utf8" });
|
|
702468
703600
|
return new Date(+data);
|
|
702469
703601
|
}
|
|
702470
703602
|
});
|
|
@@ -702507,8 +703639,8 @@ var require_lib20 = __commonJS((exports, module) => {
|
|
|
702507
703639
|
|
|
702508
703640
|
// src/utils/cleanup.ts
|
|
702509
703641
|
import * as fs19 from "fs/promises";
|
|
702510
|
-
import { homedir as
|
|
702511
|
-
import { join as
|
|
703642
|
+
import { homedir as homedir43 } from "os";
|
|
703643
|
+
import { join as join167 } from "path";
|
|
702512
703644
|
function getCutoffDate() {
|
|
702513
703645
|
const settings = getSettings_DEPRECATED() || {};
|
|
702514
703646
|
const cleanupPeriodDays = settings.cleanupPeriodDays ?? DEFAULT_CLEANUP_PERIOD_DAYS;
|
|
@@ -702533,7 +703665,7 @@ async function cleanupOldFilesInDirectory(dirPath, cutoffDate, isMessagePath) {
|
|
|
702533
703665
|
try {
|
|
702534
703666
|
const timestamp2 = convertFileNameToDate(file2.name);
|
|
702535
703667
|
if (timestamp2 < cutoffDate) {
|
|
702536
|
-
await getFsImplementation().unlink(
|
|
703668
|
+
await getFsImplementation().unlink(join167(dirPath, file2.name));
|
|
702537
703669
|
if (isMessagePath) {
|
|
702538
703670
|
result.messages++;
|
|
702539
703671
|
} else {
|
|
@@ -702564,7 +703696,7 @@ async function cleanupOldMessageFiles() {
|
|
|
702564
703696
|
} catch {
|
|
702565
703697
|
return result;
|
|
702566
703698
|
}
|
|
702567
|
-
const mcpLogDirs = dirents.filter((dirent) => dirent.isDirectory() && dirent.name.startsWith("mcp-logs-")).map((dirent) =>
|
|
703699
|
+
const mcpLogDirs = dirents.filter((dirent) => dirent.isDirectory() && dirent.name.startsWith("mcp-logs-")).map((dirent) => join167(baseCachePath, dirent.name));
|
|
702568
703700
|
for (const mcpLogDir of mcpLogDirs) {
|
|
702569
703701
|
result = addCleanupResults(result, await cleanupOldFilesInDirectory(mcpLogDir, cutoffDate, true));
|
|
702570
703702
|
await tryRmdir(mcpLogDir, fsImpl);
|
|
@@ -702603,7 +703735,7 @@ async function cleanupOldSessionFiles() {
|
|
|
702603
703735
|
for (const projectDirent of projectDirents) {
|
|
702604
703736
|
if (!projectDirent.isDirectory())
|
|
702605
703737
|
continue;
|
|
702606
|
-
const projectDir =
|
|
703738
|
+
const projectDir = join167(projectsDir, projectDirent.name);
|
|
702607
703739
|
let entries;
|
|
702608
703740
|
try {
|
|
702609
703741
|
entries = await fsImpl.readdir(projectDir);
|
|
@@ -702617,15 +703749,15 @@ async function cleanupOldSessionFiles() {
|
|
|
702617
703749
|
continue;
|
|
702618
703750
|
}
|
|
702619
703751
|
try {
|
|
702620
|
-
if (await unlinkIfOld(
|
|
703752
|
+
if (await unlinkIfOld(join167(projectDir, entry.name), cutoffDate, fsImpl)) {
|
|
702621
703753
|
result.messages++;
|
|
702622
703754
|
}
|
|
702623
703755
|
} catch {
|
|
702624
703756
|
result.errors++;
|
|
702625
703757
|
}
|
|
702626
703758
|
} else if (entry.isDirectory()) {
|
|
702627
|
-
const sessionDir =
|
|
702628
|
-
const toolResultsDir =
|
|
703759
|
+
const sessionDir = join167(projectDir, entry.name);
|
|
703760
|
+
const toolResultsDir = join167(sessionDir, TOOL_RESULTS_SUBDIR);
|
|
702629
703761
|
let toolDirs;
|
|
702630
703762
|
try {
|
|
702631
703763
|
toolDirs = await fsImpl.readdir(toolResultsDir);
|
|
@@ -702636,14 +703768,14 @@ async function cleanupOldSessionFiles() {
|
|
|
702636
703768
|
for (const toolEntry of toolDirs) {
|
|
702637
703769
|
if (toolEntry.isFile()) {
|
|
702638
703770
|
try {
|
|
702639
|
-
if (await unlinkIfOld(
|
|
703771
|
+
if (await unlinkIfOld(join167(toolResultsDir, toolEntry.name), cutoffDate, fsImpl)) {
|
|
702640
703772
|
result.messages++;
|
|
702641
703773
|
}
|
|
702642
703774
|
} catch {
|
|
702643
703775
|
result.errors++;
|
|
702644
703776
|
}
|
|
702645
703777
|
} else if (toolEntry.isDirectory()) {
|
|
702646
|
-
const toolDirPath =
|
|
703778
|
+
const toolDirPath = join167(toolResultsDir, toolEntry.name);
|
|
702647
703779
|
let toolFiles;
|
|
702648
703780
|
try {
|
|
702649
703781
|
toolFiles = await fsImpl.readdir(toolDirPath);
|
|
@@ -702654,7 +703786,7 @@ async function cleanupOldSessionFiles() {
|
|
|
702654
703786
|
if (!tf.isFile())
|
|
702655
703787
|
continue;
|
|
702656
703788
|
try {
|
|
702657
|
-
if (await unlinkIfOld(
|
|
703789
|
+
if (await unlinkIfOld(join167(toolDirPath, tf.name), cutoffDate, fsImpl)) {
|
|
702658
703790
|
result.messages++;
|
|
702659
703791
|
}
|
|
702660
703792
|
} catch {
|
|
@@ -702686,7 +703818,7 @@ async function cleanupSingleDirectory(dirPath, extension, removeEmptyDir = true)
|
|
|
702686
703818
|
if (!dirent.isFile() || !dirent.name.endsWith(extension))
|
|
702687
703819
|
continue;
|
|
702688
703820
|
try {
|
|
702689
|
-
if (await unlinkIfOld(
|
|
703821
|
+
if (await unlinkIfOld(join167(dirPath, dirent.name), cutoffDate, fsImpl)) {
|
|
702690
703822
|
result.messages++;
|
|
702691
703823
|
}
|
|
702692
703824
|
} catch {
|
|
@@ -702699,7 +703831,7 @@ async function cleanupSingleDirectory(dirPath, extension, removeEmptyDir = true)
|
|
|
702699
703831
|
return result;
|
|
702700
703832
|
}
|
|
702701
703833
|
function cleanupOldPlanFiles() {
|
|
702702
|
-
const plansDir =
|
|
703834
|
+
const plansDir = join167(getClaudeConfigHomeDir(), "plans");
|
|
702703
703835
|
return cleanupSingleDirectory(plansDir, ".md");
|
|
702704
703836
|
}
|
|
702705
703837
|
async function cleanupOldFileHistoryBackups() {
|
|
@@ -702708,14 +703840,14 @@ async function cleanupOldFileHistoryBackups() {
|
|
|
702708
703840
|
const fsImpl = getFsImplementation();
|
|
702709
703841
|
try {
|
|
702710
703842
|
const configDir = getClaudeConfigHomeDir();
|
|
702711
|
-
const fileHistoryStorageDir =
|
|
703843
|
+
const fileHistoryStorageDir = join167(configDir, "file-history");
|
|
702712
703844
|
let dirents;
|
|
702713
703845
|
try {
|
|
702714
703846
|
dirents = await fsImpl.readdir(fileHistoryStorageDir);
|
|
702715
703847
|
} catch {
|
|
702716
703848
|
return result;
|
|
702717
703849
|
}
|
|
702718
|
-
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
703850
|
+
const fileHistorySessionsDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join167(fileHistoryStorageDir, dirent.name));
|
|
702719
703851
|
await Promise.all(fileHistorySessionsDirs.map(async (fileHistorySessionDir) => {
|
|
702720
703852
|
try {
|
|
702721
703853
|
const stats = await fsImpl.stat(fileHistorySessionDir);
|
|
@@ -702742,14 +703874,14 @@ async function cleanupOldSessionEnvDirs() {
|
|
|
702742
703874
|
const fsImpl = getFsImplementation();
|
|
702743
703875
|
try {
|
|
702744
703876
|
const configDir = getClaudeConfigHomeDir();
|
|
702745
|
-
const sessionEnvBaseDir =
|
|
703877
|
+
const sessionEnvBaseDir = join167(configDir, "session-env");
|
|
702746
703878
|
let dirents;
|
|
702747
703879
|
try {
|
|
702748
703880
|
dirents = await fsImpl.readdir(sessionEnvBaseDir);
|
|
702749
703881
|
} catch {
|
|
702750
703882
|
return result;
|
|
702751
703883
|
}
|
|
702752
|
-
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) =>
|
|
703884
|
+
const sessionEnvDirs = dirents.filter((dirent) => dirent.isDirectory()).map((dirent) => join167(sessionEnvBaseDir, dirent.name));
|
|
702753
703885
|
for (const sessionEnvDir of sessionEnvDirs) {
|
|
702754
703886
|
try {
|
|
702755
703887
|
const stats = await fsImpl.stat(sessionEnvDir);
|
|
@@ -702771,7 +703903,7 @@ async function cleanupOldDebugLogs() {
|
|
|
702771
703903
|
const cutoffDate = getCutoffDate();
|
|
702772
703904
|
const result = { messages: 0, errors: 0 };
|
|
702773
703905
|
const fsImpl = getFsImplementation();
|
|
702774
|
-
const debugDir =
|
|
703906
|
+
const debugDir = join167(getClaudeConfigHomeDir(), "debug");
|
|
702775
703907
|
let dirents;
|
|
702776
703908
|
try {
|
|
702777
703909
|
dirents = await fsImpl.readdir(debugDir);
|
|
@@ -702783,7 +703915,7 @@ async function cleanupOldDebugLogs() {
|
|
|
702783
703915
|
continue;
|
|
702784
703916
|
}
|
|
702785
703917
|
try {
|
|
702786
|
-
if (await unlinkIfOld(
|
|
703918
|
+
if (await unlinkIfOld(join167(debugDir, dirent.name), cutoffDate, fsImpl)) {
|
|
702787
703919
|
result.messages++;
|
|
702788
703920
|
}
|
|
702789
703921
|
} catch {
|
|
@@ -702797,12 +703929,12 @@ async function cleanupOldMiscConfigDirs() {
|
|
|
702797
703929
|
const configDir = getClaudeConfigHomeDir();
|
|
702798
703930
|
let result = { messages: 0, errors: 0 };
|
|
702799
703931
|
for (const subdir of ["tasks", "shell-snapshots", "backups"]) {
|
|
702800
|
-
result = addCleanupResults(result, await cleanupOldFilesInDirectory(
|
|
703932
|
+
result = addCleanupResults(result, await cleanupOldFilesInDirectory(join167(configDir, subdir), cutoffDate, false));
|
|
702801
703933
|
}
|
|
702802
703934
|
return result;
|
|
702803
703935
|
}
|
|
702804
703936
|
async function cleanupNpmCacheForAnthropicPackages() {
|
|
702805
|
-
const markerPath =
|
|
703937
|
+
const markerPath = join167(getClaudeConfigHomeDir(), ".npm-cache-cleanup");
|
|
702806
703938
|
try {
|
|
702807
703939
|
const stat51 = await fs19.stat(markerPath);
|
|
702808
703940
|
if (Date.now() - stat51.mtimeMs < ONE_DAY_MS) {
|
|
@@ -702817,7 +703949,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
702817
703949
|
return;
|
|
702818
703950
|
}
|
|
702819
703951
|
logForDebugging("npm cache cleanup: starting");
|
|
702820
|
-
const npmCachePath =
|
|
703952
|
+
const npmCachePath = join167(homedir43(), ".npm", "_cacache");
|
|
702821
703953
|
const NPM_CACHE_RETENTION_COUNT = 5;
|
|
702822
703954
|
const startTime = Date.now();
|
|
702823
703955
|
try {
|
|
@@ -702872,7 +704004,7 @@ async function cleanupNpmCacheForAnthropicPackages() {
|
|
|
702872
704004
|
}
|
|
702873
704005
|
}
|
|
702874
704006
|
async function cleanupOldVersionsThrottled() {
|
|
702875
|
-
const markerPath =
|
|
704007
|
+
const markerPath = join167(getClaudeConfigHomeDir(), ".version-cleanup");
|
|
702876
704008
|
try {
|
|
702877
704009
|
const stat51 = await fs19.stat(markerPath);
|
|
702878
704010
|
if (Date.now() - stat51.mtimeMs < ONE_DAY_MS) {
|
|
@@ -703407,7 +704539,7 @@ var init_useApiKeyVerification = __esm(() => {
|
|
|
703407
704539
|
});
|
|
703408
704540
|
|
|
703409
704541
|
// src/utils/terminalPanel.ts
|
|
703410
|
-
import { spawn as
|
|
704542
|
+
import { spawn as spawn16, spawnSync as spawnSync10 } from "child_process";
|
|
703411
704543
|
function getTerminalPanelSocket() {
|
|
703412
704544
|
const sessionId = getSessionId();
|
|
703413
704545
|
return `claude-panel-${sessionId.slice(0, 8)}`;
|
|
@@ -703428,7 +704560,7 @@ class TerminalPanel {
|
|
|
703428
704560
|
checkTmux() {
|
|
703429
704561
|
if (this.hasTmux !== undefined)
|
|
703430
704562
|
return this.hasTmux;
|
|
703431
|
-
const result =
|
|
704563
|
+
const result = spawnSync10("tmux", ["-V"], { encoding: "utf-8" });
|
|
703432
704564
|
this.hasTmux = result.status === 0;
|
|
703433
704565
|
if (!this.hasTmux) {
|
|
703434
704566
|
logForDebugging("Terminal panel: tmux not found, falling back to non-persistent shell");
|
|
@@ -703436,14 +704568,14 @@ class TerminalPanel {
|
|
|
703436
704568
|
return this.hasTmux;
|
|
703437
704569
|
}
|
|
703438
704570
|
hasSession() {
|
|
703439
|
-
const result =
|
|
704571
|
+
const result = spawnSync10("tmux", ["-L", getTerminalPanelSocket(), "has-session", "-t", TMUX_SESSION], { encoding: "utf-8" });
|
|
703440
704572
|
return result.status === 0;
|
|
703441
704573
|
}
|
|
703442
704574
|
createSession() {
|
|
703443
704575
|
const shell = process.env.SHELL || "/bin/bash";
|
|
703444
704576
|
const cwd2 = pwd();
|
|
703445
704577
|
const socket = getTerminalPanelSocket();
|
|
703446
|
-
const result =
|
|
704578
|
+
const result = spawnSync10("tmux", [
|
|
703447
704579
|
"-L",
|
|
703448
704580
|
socket,
|
|
703449
704581
|
"new-session",
|
|
@@ -703459,7 +704591,7 @@ class TerminalPanel {
|
|
|
703459
704591
|
logForDebugging(`Terminal panel: failed to create tmux session: ${result.stderr}`);
|
|
703460
704592
|
return false;
|
|
703461
704593
|
}
|
|
703462
|
-
|
|
704594
|
+
spawnSync10("tmux", [
|
|
703463
704595
|
"-L",
|
|
703464
704596
|
socket,
|
|
703465
704597
|
"bind-key",
|
|
@@ -703490,7 +704622,7 @@ class TerminalPanel {
|
|
|
703490
704622
|
if (!this.cleanupRegistered) {
|
|
703491
704623
|
this.cleanupRegistered = true;
|
|
703492
704624
|
registerCleanup(async () => {
|
|
703493
|
-
|
|
704625
|
+
spawn16("tmux", ["-L", socket, "kill-server"], {
|
|
703494
704626
|
detached: true,
|
|
703495
704627
|
stdio: "ignore"
|
|
703496
704628
|
}).on("error", () => {}).unref();
|
|
@@ -703499,7 +704631,7 @@ class TerminalPanel {
|
|
|
703499
704631
|
return true;
|
|
703500
704632
|
}
|
|
703501
704633
|
attachSession() {
|
|
703502
|
-
|
|
704634
|
+
spawnSync10("tmux", ["-L", getTerminalPanelSocket(), "attach-session", "-t", TMUX_SESSION], { stdio: "inherit" });
|
|
703503
704635
|
}
|
|
703504
704636
|
showShell() {
|
|
703505
704637
|
const inkInstance = instances_default.get(process.stdout);
|
|
@@ -703526,7 +704658,7 @@ class TerminalPanel {
|
|
|
703526
704658
|
runShellDirect() {
|
|
703527
704659
|
const shell = process.env.SHELL || "/bin/bash";
|
|
703528
704660
|
const cwd2 = pwd();
|
|
703529
|
-
|
|
704661
|
+
spawnSync10(shell, ["-i", "-l"], {
|
|
703530
704662
|
stdio: "inherit",
|
|
703531
704663
|
cwd: cwd2,
|
|
703532
704664
|
env: process.env
|
|
@@ -703873,12 +705005,12 @@ function CancelRequestHandler(props) {
|
|
|
703873
705005
|
});
|
|
703874
705006
|
const killAllAgentsAndNotify = import_react268.useCallback(() => {
|
|
703875
705007
|
const tasks2 = store.getState().tasks;
|
|
703876
|
-
const
|
|
703877
|
-
if (
|
|
705008
|
+
const running2 = Object.entries(tasks2).filter(([, t4]) => t4.type === "local_agent" && t4.status === "running");
|
|
705009
|
+
if (running2.length === 0)
|
|
703878
705010
|
return false;
|
|
703879
705011
|
killAllRunningAgentTasks(tasks2, setAppState);
|
|
703880
705012
|
const descriptions = [];
|
|
703881
|
-
for (const [taskId, task] of
|
|
705013
|
+
for (const [taskId, task] of running2) {
|
|
703882
705014
|
markAgentsNotified(taskId, setAppState);
|
|
703883
705015
|
descriptions.push(task.description);
|
|
703884
705016
|
emitTaskTerminatedSdk(taskId, "stopped", {
|
|
@@ -706915,7 +708047,7 @@ __export(exports_asciicast, {
|
|
|
706915
708047
|
_resetRecordingStateForTesting: () => _resetRecordingStateForTesting
|
|
706916
708048
|
});
|
|
706917
708049
|
import { appendFile as appendFile8, rename as rename10 } from "fs/promises";
|
|
706918
|
-
import { basename as basename63, dirname as dirname71, join as
|
|
708050
|
+
import { basename as basename63, dirname as dirname71, join as join170 } from "path";
|
|
706919
708051
|
function getRecordFilePath() {
|
|
706920
708052
|
if (recordingState.filePath !== null) {
|
|
706921
708053
|
return recordingState.filePath;
|
|
@@ -706926,10 +708058,10 @@ function getRecordFilePath() {
|
|
|
706926
708058
|
if (!isEnvTruthy(process.env.CLAUDE_CODE_TERMINAL_RECORDING)) {
|
|
706927
708059
|
return null;
|
|
706928
708060
|
}
|
|
706929
|
-
const projectsDir =
|
|
706930
|
-
const projectDir =
|
|
708061
|
+
const projectsDir = join170(getClaudeConfigHomeDir(), "projects");
|
|
708062
|
+
const projectDir = join170(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
706931
708063
|
recordingState.timestamp = Date.now();
|
|
706932
|
-
recordingState.filePath =
|
|
708064
|
+
recordingState.filePath = join170(projectDir, `${getSessionId()}-${recordingState.timestamp}.cast`);
|
|
706933
708065
|
return recordingState.filePath;
|
|
706934
708066
|
}
|
|
706935
708067
|
function _resetRecordingStateForTesting() {
|
|
@@ -706938,13 +708070,13 @@ function _resetRecordingStateForTesting() {
|
|
|
706938
708070
|
}
|
|
706939
708071
|
function getSessionRecordingPaths() {
|
|
706940
708072
|
const sessionId = getSessionId();
|
|
706941
|
-
const projectsDir =
|
|
706942
|
-
const projectDir =
|
|
708073
|
+
const projectsDir = join170(getClaudeConfigHomeDir(), "projects");
|
|
708074
|
+
const projectDir = join170(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
706943
708075
|
try {
|
|
706944
708076
|
const entries = getFsImplementation().readdirSync(projectDir);
|
|
706945
708077
|
const names = typeof entries[0] === "string" ? entries : entries.map((e4) => e4.name);
|
|
706946
708078
|
const files3 = names.filter((f4) => f4.startsWith(sessionId) && f4.endsWith(".cast")).sort();
|
|
706947
|
-
return files3.map((f4) =>
|
|
708079
|
+
return files3.map((f4) => join170(projectDir, f4));
|
|
706948
708080
|
} catch {
|
|
706949
708081
|
return [];
|
|
706950
708082
|
}
|
|
@@ -706954,9 +708086,9 @@ async function renameRecordingForSession() {
|
|
|
706954
708086
|
if (!oldPath || recordingState.timestamp === 0) {
|
|
706955
708087
|
return;
|
|
706956
708088
|
}
|
|
706957
|
-
const projectsDir =
|
|
706958
|
-
const projectDir =
|
|
706959
|
-
const newPath =
|
|
708089
|
+
const projectsDir = join170(getClaudeConfigHomeDir(), "projects");
|
|
708090
|
+
const projectDir = join170(projectsDir, sanitizePath2(getOriginalCwd()));
|
|
708091
|
+
const newPath = join170(projectDir, `${getSessionId()}-${recordingState.timestamp}.cast`);
|
|
706960
708092
|
if (oldPath === newPath) {
|
|
706961
708093
|
return;
|
|
706962
708094
|
}
|
|
@@ -708537,7 +709669,7 @@ var init_Feedback = __esm(() => {
|
|
|
708537
709669
|
});
|
|
708538
709670
|
|
|
708539
709671
|
// src/components/FeedbackSurvey/submitTranscriptShare.ts
|
|
708540
|
-
import { readFile as
|
|
709672
|
+
import { readFile as readFile65, stat as stat51 } from "fs/promises";
|
|
708541
709673
|
async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
708542
709674
|
try {
|
|
708543
709675
|
logForDebugging("Collecting transcript for sharing", { level: "info" });
|
|
@@ -708549,7 +709681,7 @@ async function submitTranscriptShare(messages, trigger, appearanceId) {
|
|
|
708549
709681
|
const transcriptPath = getTranscriptPath();
|
|
708550
709682
|
const { size } = await stat51(transcriptPath);
|
|
708551
709683
|
if (size <= MAX_TRANSCRIPT_READ_BYTES) {
|
|
708552
|
-
rawTranscriptJsonl = await
|
|
709684
|
+
rawTranscriptJsonl = await readFile65(transcriptPath, "utf-8");
|
|
708553
709685
|
} else {
|
|
708554
709686
|
logForDebugging(`Skipping raw transcript read: file too large (${size} bytes)`, { level: "warn" });
|
|
708555
709687
|
}
|
|
@@ -708630,7 +709762,7 @@ function useSurveyState({
|
|
|
708630
709762
|
setState("submitted");
|
|
708631
709763
|
setTimeout(setState, hideThanksAfterMs, "closed");
|
|
708632
709764
|
}, [hideThanksAfterMs]);
|
|
708633
|
-
const
|
|
709765
|
+
const open16 = import_react288.useCallback(() => {
|
|
708634
709766
|
if (state4 !== "closed") {
|
|
708635
709767
|
return;
|
|
708636
709768
|
}
|
|
@@ -708681,7 +709813,7 @@ function useSurveyState({
|
|
|
708681
709813
|
return {
|
|
708682
709814
|
state: state4,
|
|
708683
709815
|
lastResponse,
|
|
708684
|
-
open:
|
|
709816
|
+
open: open16,
|
|
708685
709817
|
handleSelect,
|
|
708686
709818
|
handleTranscriptSelect
|
|
708687
709819
|
};
|
|
@@ -708817,7 +709949,7 @@ function useFeedbackSurvey(messages, isLoading, submitCount, surveyType = "sessi
|
|
|
708817
709949
|
const {
|
|
708818
709950
|
state: state4,
|
|
708819
709951
|
lastResponse,
|
|
708820
|
-
open:
|
|
709952
|
+
open: open16,
|
|
708821
709953
|
handleSelect,
|
|
708822
709954
|
handleTranscriptSelect
|
|
708823
709955
|
} = useSurveyState({
|
|
@@ -708898,9 +710030,9 @@ function useFeedbackSurvey(messages, isLoading, submitCount, surveyType = "sessi
|
|
|
708898
710030
|
}, [state4, isLoading, hasActivePrompt, isModelAllowed2, feedbackSurvey.timeLastShown, feedbackSurvey.submitCountAtLastAppearance, submitCount, config7.minTimeBetweenFeedbackMs, config7.minTimeBetweenGlobalFeedbackMs, config7.minUserTurnsBetweenFeedback, config7.minTimeBeforeFeedbackMs, config7.minUserTurnsBeforeFeedback, config7.probability, settingsRate]);
|
|
708899
710031
|
import_react289.useEffect(() => {
|
|
708900
710032
|
if (shouldOpen) {
|
|
708901
|
-
|
|
710033
|
+
open16();
|
|
708902
710034
|
}
|
|
708903
|
-
}, [shouldOpen,
|
|
710035
|
+
}, [shouldOpen, open16]);
|
|
708904
710036
|
return {
|
|
708905
710037
|
state: state4,
|
|
708906
710038
|
lastResponse,
|
|
@@ -709044,7 +710176,7 @@ function useMemorySurvey(messages, isLoading, hasActivePrompt = false, {
|
|
|
709044
710176
|
const {
|
|
709045
710177
|
state: state4,
|
|
709046
710178
|
lastResponse,
|
|
709047
|
-
open:
|
|
710179
|
+
open: open16,
|
|
709048
710180
|
handleSelect,
|
|
709049
710181
|
handleTranscriptSelect
|
|
709050
710182
|
} = useSurveyState({
|
|
@@ -709097,9 +710229,9 @@ function useMemorySurvey(messages, isLoading, hasActivePrompt = false, {
|
|
|
709097
710229
|
return;
|
|
709098
710230
|
}
|
|
709099
710231
|
if (Math.random() < SURVEY_PROBABILITY) {
|
|
709100
|
-
|
|
710232
|
+
open16();
|
|
709101
710233
|
}
|
|
709102
|
-
}, [enabled2, state4, isLoading, hasActivePrompt, lastAssistant, messages,
|
|
710234
|
+
}, [enabled2, state4, isLoading, hasActivePrompt, lastAssistant, messages, open16]);
|
|
709103
710235
|
return {
|
|
709104
710236
|
state: state4,
|
|
709105
710237
|
lastResponse,
|
|
@@ -709181,7 +710313,7 @@ function usePostCompactSurvey(messages, isLoading, t0, t1) {
|
|
|
709181
710313
|
const {
|
|
709182
710314
|
state: state4,
|
|
709183
710315
|
lastResponse,
|
|
709184
|
-
open:
|
|
710316
|
+
open: open16,
|
|
709185
710317
|
handleSelect
|
|
709186
710318
|
} = useSurveyState(t5);
|
|
709187
710319
|
let t6;
|
|
@@ -709213,7 +710345,7 @@ function usePostCompactSurvey(messages, isLoading, t0, t1) {
|
|
|
709213
710345
|
const currentCompactBoundaries = t8;
|
|
709214
710346
|
let t10;
|
|
709215
710347
|
let t9;
|
|
709216
|
-
if ($4[9] !== currentCompactBoundaries || $4[10] !== enabled2 || $4[11] !== gateEnabled || $4[12] !== hasActivePrompt || $4[13] !== isLoading || $4[14] !== messages || $4[15] !==
|
|
710348
|
+
if ($4[9] !== currentCompactBoundaries || $4[10] !== enabled2 || $4[11] !== gateEnabled || $4[12] !== hasActivePrompt || $4[13] !== isLoading || $4[14] !== messages || $4[15] !== open16 || $4[16] !== state4) {
|
|
709217
710349
|
t9 = () => {
|
|
709218
710350
|
if (!enabled2) {
|
|
709219
710351
|
return;
|
|
@@ -709237,7 +710369,7 @@ function usePostCompactSurvey(messages, isLoading, t0, t1) {
|
|
|
709237
710369
|
if (hasMessageAfterBoundary(messages, pendingCompactBoundaryUuid.current)) {
|
|
709238
710370
|
pendingCompactBoundaryUuid.current = null;
|
|
709239
710371
|
if (Math.random() < SURVEY_PROBABILITY2) {
|
|
709240
|
-
|
|
710372
|
+
open16();
|
|
709241
710373
|
}
|
|
709242
710374
|
return;
|
|
709243
710375
|
}
|
|
@@ -709248,14 +710380,14 @@ function usePostCompactSurvey(messages, isLoading, t0, t1) {
|
|
|
709248
710380
|
pendingCompactBoundaryUuid.current = newBoundaries[newBoundaries.length - 1];
|
|
709249
710381
|
}
|
|
709250
710382
|
};
|
|
709251
|
-
t10 = [enabled2, currentCompactBoundaries, state4, isLoading, hasActivePrompt, gateEnabled, messages,
|
|
710383
|
+
t10 = [enabled2, currentCompactBoundaries, state4, isLoading, hasActivePrompt, gateEnabled, messages, open16];
|
|
709252
710384
|
$4[9] = currentCompactBoundaries;
|
|
709253
710385
|
$4[10] = enabled2;
|
|
709254
710386
|
$4[11] = gateEnabled;
|
|
709255
710387
|
$4[12] = hasActivePrompt;
|
|
709256
710388
|
$4[13] = isLoading;
|
|
709257
710389
|
$4[14] = messages;
|
|
709258
|
-
$4[15] =
|
|
710390
|
+
$4[15] = open16;
|
|
709259
710391
|
$4[16] = state4;
|
|
709260
710392
|
$4[17] = t10;
|
|
709261
710393
|
$4[18] = t9;
|
|
@@ -709917,7 +711049,7 @@ var init_useChromeExtensionNotification = __esm(() => {
|
|
|
709917
711049
|
});
|
|
709918
711050
|
|
|
709919
711051
|
// src/utils/plugins/officialMarketplaceStartupCheck.ts
|
|
709920
|
-
import { join as
|
|
711052
|
+
import { join as join171 } from "path";
|
|
709921
711053
|
function isOfficialMarketplaceAutoInstallDisabled() {
|
|
709922
711054
|
return isEnvTruthy(process.env.CLAUDE_CODE_DISABLE_OFFICIAL_MARKETPLACE_AUTOINSTALL);
|
|
709923
711055
|
}
|
|
@@ -710000,7 +711132,7 @@ async function checkAndInstallOfficialMarketplace() {
|
|
|
710000
711132
|
return { installed: false, skipped: true, reason: "policy_blocked" };
|
|
710001
711133
|
}
|
|
710002
711134
|
const cacheDir = getMarketplacesCacheDir();
|
|
710003
|
-
const installLocation =
|
|
711135
|
+
const installLocation = join171(cacheDir, OFFICIAL_MARKETPLACE_NAME);
|
|
710004
711136
|
const gcsSha = await fetchOfficialMarketplaceFromGcs(installLocation, cacheDir);
|
|
710005
711137
|
if (gcsSha !== null) {
|
|
710006
711138
|
const known = await loadKnownMarketplacesConfig();
|
|
@@ -713030,7 +714162,7 @@ var init_usePluginRecommendationBase = __esm(() => {
|
|
|
713030
714162
|
});
|
|
713031
714163
|
|
|
713032
714164
|
// src/hooks/useLspPluginRecommendation.tsx
|
|
713033
|
-
import { extname as extname18, join as
|
|
714165
|
+
import { extname as extname18, join as join172 } from "path";
|
|
713034
714166
|
function useLspPluginRecommendation() {
|
|
713035
714167
|
const $4 = import_compiler_runtime335.c(12);
|
|
713036
714168
|
const trackedFiles = useAppState(_temp291);
|
|
@@ -713115,7 +714247,7 @@ function useLspPluginRecommendation() {
|
|
|
713115
714247
|
case "yes": {
|
|
713116
714248
|
installPluginAndNotify(pluginId, pluginName, "lsp-plugin", addNotification, async (pluginData) => {
|
|
713117
714249
|
logForDebugging(`[useLspPluginRecommendation] Installing plugin: ${pluginId}`);
|
|
713118
|
-
const localSourcePath = typeof pluginData.entry.source === "string" ?
|
|
714250
|
+
const localSourcePath = typeof pluginData.entry.source === "string" ? join172(pluginData.marketplaceInstallLocation, pluginData.entry.source) : undefined;
|
|
713119
714251
|
await cacheAndRegisterPlugin(pluginId, pluginData.entry, "user", undefined, localSourcePath);
|
|
713120
714252
|
const settings = getSettingsForSource("userSettings");
|
|
713121
714253
|
updateSettingsForSource("userSettings", {
|
|
@@ -715267,7 +716399,7 @@ var init_DevBar = __esm(() => {
|
|
|
715267
716399
|
function AlternateScreen(t0) {
|
|
715268
716400
|
const $4 = import_compiler_runtime346.c(7);
|
|
715269
716401
|
const {
|
|
715270
|
-
children:
|
|
716402
|
+
children: children3,
|
|
715271
716403
|
mouseTracking: t1
|
|
715272
716404
|
} = t0;
|
|
715273
716405
|
const mouseTracking = t1 === undefined ? true : t1;
|
|
@@ -715301,15 +716433,15 @@ function AlternateScreen(t0) {
|
|
|
715301
716433
|
import_react311.useInsertionEffect(t22, t32);
|
|
715302
716434
|
const t4 = size?.rows ?? 24;
|
|
715303
716435
|
let t5;
|
|
715304
|
-
if ($4[4] !==
|
|
716436
|
+
if ($4[4] !== children3 || $4[5] !== t4) {
|
|
715305
716437
|
t5 = /* @__PURE__ */ jsx_dev_runtime456.jsxDEV(Box_default, {
|
|
715306
716438
|
flexDirection: "column",
|
|
715307
716439
|
height: t4,
|
|
715308
716440
|
width: "100%",
|
|
715309
716441
|
flexShrink: 0,
|
|
715310
|
-
children:
|
|
716442
|
+
children: children3
|
|
715311
716443
|
}, undefined, false, undefined, this);
|
|
715312
|
-
$4[4] =
|
|
716444
|
+
$4[4] = children3;
|
|
715313
716445
|
$4[5] = t4;
|
|
715314
716446
|
$4[6] = t5;
|
|
715315
716447
|
} else {
|
|
@@ -715962,20 +717094,20 @@ var init_ScrollKeybindingHandler = __esm(() => {
|
|
|
715962
717094
|
// src/components/FleetView/rowHelpers.ts
|
|
715963
717095
|
function buildFleetRows(tasks2, now2 = Date.now(), foldWindowMs = 60000) {
|
|
715964
717096
|
const all4 = Object.values(tasks2);
|
|
715965
|
-
const
|
|
717097
|
+
const running2 = [];
|
|
715966
717098
|
const done = [];
|
|
715967
717099
|
for (const t4 of all4) {
|
|
715968
717100
|
if (isBackgroundTask(t4)) {
|
|
715969
|
-
|
|
717101
|
+
running2.push(t4);
|
|
715970
717102
|
continue;
|
|
715971
717103
|
}
|
|
715972
717104
|
if (isTerminalTaskStatus(t4.status) && t4.endTime && now2 - t4.endTime <= foldWindowMs) {
|
|
715973
717105
|
done.push(t4);
|
|
715974
717106
|
}
|
|
715975
717107
|
}
|
|
715976
|
-
|
|
717108
|
+
running2.sort((a5, b5) => a5.startTime - b5.startTime);
|
|
715977
717109
|
done.sort((a5, b5) => (b5.endTime ?? 0) - (a5.endTime ?? 0));
|
|
715978
|
-
return { running, done };
|
|
717110
|
+
return { running: running2, done };
|
|
715979
717111
|
}
|
|
715980
717112
|
function jobLabel(task) {
|
|
715981
717113
|
switch (task.type) {
|
|
@@ -716080,11 +717212,11 @@ function fleetVerticalBudget(terminalRows) {
|
|
|
716080
717212
|
const half = Math.floor(terminalRows / 2);
|
|
716081
717213
|
return Math.max(4, Math.min(12, half));
|
|
716082
717214
|
}
|
|
716083
|
-
function fleetTitle(
|
|
716084
|
-
if (
|
|
716085
|
-
return `Agents \xB7 ${
|
|
716086
|
-
if (
|
|
716087
|
-
return `Agents \xB7 ${
|
|
717215
|
+
function fleetTitle(running2, done) {
|
|
717216
|
+
if (running2 > 0 && done > 0)
|
|
717217
|
+
return `Agents \xB7 ${running2} live \xB7 ${done} done`;
|
|
717218
|
+
if (running2 > 0)
|
|
717219
|
+
return `Agents \xB7 ${running2} live`;
|
|
716088
717220
|
if (done > 0)
|
|
716089
717221
|
return `Agents \xB7 ${done} done`;
|
|
716090
717222
|
return "Agents";
|
|
@@ -716396,17 +717528,17 @@ var init_SessionPreview2 = __esm(() => {
|
|
|
716396
717528
|
// src/components/FleetView/FleetView.tsx
|
|
716397
717529
|
function FleetView(props) {
|
|
716398
717530
|
const { rows, focused, selectedIndex, showPreview, now: now2, terminalRows } = props;
|
|
716399
|
-
const { running, done } = rows;
|
|
717531
|
+
const { running: running2, done } = rows;
|
|
716400
717532
|
const budget = fleetVerticalBudget(terminalRows);
|
|
716401
|
-
if (
|
|
717533
|
+
if (running2.length === 0 && done.length === 0) {
|
|
716402
717534
|
return /* @__PURE__ */ jsx_dev_runtime458.jsxDEV(FleetEmptyState, {
|
|
716403
717535
|
focused
|
|
716404
717536
|
}, undefined, false, undefined, this);
|
|
716405
717537
|
}
|
|
716406
|
-
const title = fleetTitle(
|
|
717538
|
+
const title = fleetTitle(running2.length, done.length);
|
|
716407
717539
|
const maxRows = Math.max(1, budget - 2);
|
|
716408
|
-
const visibleRunning =
|
|
716409
|
-
const hidden2 =
|
|
717540
|
+
const visibleRunning = running2.slice(0, maxRows);
|
|
717541
|
+
const hidden2 = running2.length - visibleRunning.length;
|
|
716410
717542
|
return /* @__PURE__ */ jsx_dev_runtime458.jsxDEV(ThemedBox_default, {
|
|
716411
717543
|
flexDirection: "column",
|
|
716412
717544
|
paddingLeft: 1,
|
|
@@ -716457,8 +717589,8 @@ function FleetView(props) {
|
|
|
716457
717589
|
]
|
|
716458
717590
|
}, undefined, true, undefined, this)
|
|
716459
717591
|
}, undefined, false, undefined, this),
|
|
716460
|
-
showPreview && focused &&
|
|
716461
|
-
task:
|
|
717592
|
+
showPreview && focused && running2[selectedIndex] && /* @__PURE__ */ jsx_dev_runtime458.jsxDEV(SessionPreview2, {
|
|
717593
|
+
task: running2[selectedIndex],
|
|
716462
717594
|
now: now2
|
|
716463
717595
|
}, undefined, false, undefined, this)
|
|
716464
717596
|
]
|
|
@@ -717123,15 +718255,15 @@ var init_cronJitterConfig = __esm(() => {
|
|
|
717123
718255
|
});
|
|
717124
718256
|
|
|
717125
718257
|
// src/utils/cronTasksLock.ts
|
|
717126
|
-
import { mkdir as mkdir57, readFile as
|
|
717127
|
-
import { dirname as dirname73, join as
|
|
718258
|
+
import { mkdir as mkdir57, readFile as readFile66, unlink as unlink28, writeFile as writeFile61 } from "fs/promises";
|
|
718259
|
+
import { dirname as dirname73, join as join173 } from "path";
|
|
717128
718260
|
function getLockPath2(dir) {
|
|
717129
|
-
return
|
|
718261
|
+
return join173(dir ?? getProjectRoot(), LOCK_FILE_REL);
|
|
717130
718262
|
}
|
|
717131
718263
|
async function readLock2(dir) {
|
|
717132
718264
|
let raw;
|
|
717133
718265
|
try {
|
|
717134
|
-
raw = await
|
|
718266
|
+
raw = await readFile66(getLockPath2(dir), "utf8");
|
|
717135
718267
|
} catch {
|
|
717136
718268
|
return;
|
|
717137
718269
|
}
|
|
@@ -717142,7 +718274,7 @@ async function tryCreateExclusive2(lock2, dir) {
|
|
|
717142
718274
|
const path32 = getLockPath2(dir);
|
|
717143
718275
|
const body = jsonStringify(lock2);
|
|
717144
718276
|
try {
|
|
717145
|
-
await
|
|
718277
|
+
await writeFile61(path32, body, { flag: "wx" });
|
|
717146
718278
|
return true;
|
|
717147
718279
|
} catch (e4) {
|
|
717148
718280
|
const code = getErrnoCode(e4);
|
|
@@ -717151,7 +718283,7 @@ async function tryCreateExclusive2(lock2, dir) {
|
|
|
717151
718283
|
if (code === "ENOENT") {
|
|
717152
718284
|
await mkdir57(dirname73(path32), { recursive: true });
|
|
717153
718285
|
try {
|
|
717154
|
-
await
|
|
718286
|
+
await writeFile61(path32, body, { flag: "wx" });
|
|
717155
718287
|
return true;
|
|
717156
718288
|
} catch (retryErr) {
|
|
717157
718289
|
if (getErrnoCode(retryErr) === "EEXIST")
|
|
@@ -717185,7 +718317,7 @@ async function tryAcquireSchedulerLock(opts) {
|
|
|
717185
718317
|
const existing = await readLock2(dir);
|
|
717186
718318
|
if (existing?.sessionId === sessionId) {
|
|
717187
718319
|
if (existing.pid !== process.pid) {
|
|
717188
|
-
await
|
|
718320
|
+
await writeFile61(getLockPath2(dir), jsonStringify(lock2));
|
|
717189
718321
|
registerLockCleanup2(opts);
|
|
717190
718322
|
}
|
|
717191
718323
|
return true;
|
|
@@ -717200,7 +718332,7 @@ async function tryAcquireSchedulerLock(opts) {
|
|
|
717200
718332
|
if (existing) {
|
|
717201
718333
|
logForDebugging(`[ScheduledTasks] recovering stale scheduler lock from PID ${existing.pid}`);
|
|
717202
718334
|
}
|
|
717203
|
-
await
|
|
718335
|
+
await unlink28(getLockPath2(dir)).catch(() => {});
|
|
717204
718336
|
if (await tryCreateExclusive2(lock2, dir)) {
|
|
717205
718337
|
lastBlockedBy = undefined;
|
|
717206
718338
|
registerLockCleanup2(opts);
|
|
@@ -717218,7 +718350,7 @@ async function releaseSchedulerLock(opts) {
|
|
|
717218
718350
|
if (!existing || existing.sessionId !== sessionId)
|
|
717219
718351
|
return;
|
|
717220
718352
|
try {
|
|
717221
|
-
await
|
|
718353
|
+
await unlink28(getLockPath2(dir));
|
|
717222
718354
|
logForDebugging("[ScheduledTasks] released scheduler lock");
|
|
717223
718355
|
} catch {}
|
|
717224
718356
|
}
|
|
@@ -717232,7 +718364,7 @@ var init_cronTasksLock = __esm(() => {
|
|
|
717232
718364
|
init_genericProcessUtils();
|
|
717233
718365
|
init_json();
|
|
717234
718366
|
init_slowOperations();
|
|
717235
|
-
LOCK_FILE_REL =
|
|
718367
|
+
LOCK_FILE_REL = join173(".claude", "scheduled_tasks.lock");
|
|
717236
718368
|
schedulerLockSchema = lazySchema(() => exports_external.object({
|
|
717237
718369
|
sessionId: exports_external.string(),
|
|
717238
718370
|
pid: exports_external.number(),
|
|
@@ -717610,10 +718742,10 @@ var exports_REPL = {};
|
|
|
717610
718742
|
__export(exports_REPL, {
|
|
717611
718743
|
REPL: () => REPL
|
|
717612
718744
|
});
|
|
717613
|
-
import { spawnSync as
|
|
717614
|
-
import { dirname as dirname74, join as
|
|
718745
|
+
import { spawnSync as spawnSync11 } from "child_process";
|
|
718746
|
+
import { dirname as dirname74, join as join174 } from "path";
|
|
717615
718747
|
import { tmpdir as tmpdir16 } from "os";
|
|
717616
|
-
import { writeFile as
|
|
718748
|
+
import { writeFile as writeFile62 } from "fs/promises";
|
|
717617
718749
|
import { randomUUID as randomUUID62 } from "crypto";
|
|
717618
718750
|
function TranscriptModeFooter(t0) {
|
|
717619
718751
|
const $4 = import_compiler_runtime347.c(9);
|
|
@@ -719872,7 +721004,7 @@ Error: sandbox required but unavailable: ${reason}
|
|
|
719872
721004
|
const handleExit = import_react316.useCallback(async () => {
|
|
719873
721005
|
setIsExiting(true);
|
|
719874
721006
|
if (feature("BG_SESSIONS") && isBgSession()) {
|
|
719875
|
-
|
|
721007
|
+
spawnSync11("tmux", ["detach-client"], {
|
|
719876
721008
|
stdio: "ignore"
|
|
719877
721009
|
});
|
|
719878
721010
|
setIsExiting(false);
|
|
@@ -720369,8 +721501,8 @@ Note: ctrl + z now suspends Claude Code, ctrl + _ undoes input.
|
|
|
720369
721501
|
const w3 = Math.max(80, (process.stdout.columns ?? 80) - 6);
|
|
720370
721502
|
const raw = await renderMessagesToPlainText(deferredMessages, tools, w3);
|
|
720371
721503
|
const text2 = raw.replace(/[ \t]+$/gm, "");
|
|
720372
|
-
const path32 =
|
|
720373
|
-
await
|
|
721504
|
+
const path32 = join174(tmpdir16(), `cc-transcript-${Date.now()}.txt`);
|
|
721505
|
+
await writeFile62(path32, text2);
|
|
720374
721506
|
const opened = openFileInExternalEditor(path32);
|
|
720375
721507
|
setStatus(opened ? `opening ${path32}` : `wrote ${path32} \xB7 no $VISUAL/$EDITOR set`);
|
|
720376
721508
|
} catch (e4) {
|
|
@@ -723503,7 +724635,7 @@ var init_WelcomeV2 = __esm(() => {
|
|
|
723503
724635
|
function OrderedListItem(t0) {
|
|
723504
724636
|
const $4 = import_compiler_runtime354.c(7);
|
|
723505
724637
|
const {
|
|
723506
|
-
children:
|
|
724638
|
+
children: children3
|
|
723507
724639
|
} = t0;
|
|
723508
724640
|
const {
|
|
723509
724641
|
marker
|
|
@@ -723520,12 +724652,12 @@ function OrderedListItem(t0) {
|
|
|
723520
724652
|
t1 = $4[1];
|
|
723521
724653
|
}
|
|
723522
724654
|
let t22;
|
|
723523
|
-
if ($4[2] !==
|
|
724655
|
+
if ($4[2] !== children3) {
|
|
723524
724656
|
t22 = /* @__PURE__ */ jsx_dev_runtime469.jsxDEV(ThemedBox_default, {
|
|
723525
724657
|
flexDirection: "column",
|
|
723526
|
-
children:
|
|
724658
|
+
children: children3
|
|
723527
724659
|
}, undefined, false, undefined, this);
|
|
723528
|
-
$4[2] =
|
|
724660
|
+
$4[2] = children3;
|
|
723529
724661
|
$4[3] = t22;
|
|
723530
724662
|
} else {
|
|
723531
724663
|
t22 = $4[3];
|
|
@@ -723562,13 +724694,13 @@ var init_OrderedListItem = __esm(() => {
|
|
|
723562
724694
|
function OrderedListComponent(t0) {
|
|
723563
724695
|
const $4 = import_compiler_runtime355.c(9);
|
|
723564
724696
|
const {
|
|
723565
|
-
children:
|
|
724697
|
+
children: children3
|
|
723566
724698
|
} = t0;
|
|
723567
724699
|
const {
|
|
723568
724700
|
marker: parentMarker
|
|
723569
724701
|
} = import_react320.useContext(OrderedListContext);
|
|
723570
724702
|
let numberOfItems = 0;
|
|
723571
|
-
for (const child of import_react320.default.Children.toArray(
|
|
724703
|
+
for (const child of import_react320.default.Children.toArray(children3)) {
|
|
723572
724704
|
if (!import_react320.isValidElement(child) || child.type !== OrderedListItem) {
|
|
723573
724705
|
continue;
|
|
723574
724706
|
}
|
|
@@ -723576,7 +724708,7 @@ function OrderedListComponent(t0) {
|
|
|
723576
724708
|
}
|
|
723577
724709
|
const maxMarkerWidth = String(numberOfItems).length;
|
|
723578
724710
|
let t1;
|
|
723579
|
-
if ($4[0] !==
|
|
724711
|
+
if ($4[0] !== children3 || $4[1] !== maxMarkerWidth || $4[2] !== parentMarker) {
|
|
723580
724712
|
let t23;
|
|
723581
724713
|
if ($4[4] !== maxMarkerWidth || $4[5] !== parentMarker) {
|
|
723582
724714
|
t23 = (child_0, index2) => {
|
|
@@ -723603,8 +724735,8 @@ function OrderedListComponent(t0) {
|
|
|
723603
724735
|
} else {
|
|
723604
724736
|
t23 = $4[6];
|
|
723605
724737
|
}
|
|
723606
|
-
t1 = import_react320.default.Children.map(
|
|
723607
|
-
$4[0] =
|
|
724738
|
+
t1 = import_react320.default.Children.map(children3, t23);
|
|
724739
|
+
$4[0] = children3;
|
|
723608
724740
|
$4[1] = maxMarkerWidth;
|
|
723609
724741
|
$4[2] = parentMarker;
|
|
723610
724742
|
$4[3] = t1;
|
|
@@ -723906,7 +725038,7 @@ function SkippableStep(t0) {
|
|
|
723906
725038
|
const {
|
|
723907
725039
|
skip,
|
|
723908
725040
|
onSkip,
|
|
723909
|
-
children:
|
|
725041
|
+
children: children3
|
|
723910
725042
|
} = t0;
|
|
723911
725043
|
let t1;
|
|
723912
725044
|
let t22;
|
|
@@ -723929,7 +725061,7 @@ function SkippableStep(t0) {
|
|
|
723929
725061
|
if (skip) {
|
|
723930
725062
|
return null;
|
|
723931
725063
|
}
|
|
723932
|
-
return
|
|
725064
|
+
return children3;
|
|
723933
725065
|
}
|
|
723934
725066
|
var import_compiler_runtime356, import_react321, jsx_dev_runtime471;
|
|
723935
725067
|
var init_Onboarding = __esm(() => {
|
|
@@ -724093,7 +725225,7 @@ var exports_TrustDialog = {};
|
|
|
724093
725225
|
__export(exports_TrustDialog, {
|
|
724094
725226
|
TrustDialog: () => TrustDialog
|
|
724095
725227
|
});
|
|
724096
|
-
import { homedir as
|
|
725228
|
+
import { homedir as homedir45 } from "os";
|
|
724097
725229
|
function TrustDialog(t0) {
|
|
724098
725230
|
const $4 = import_compiler_runtime357.c(33);
|
|
724099
725231
|
const {
|
|
@@ -724204,7 +725336,7 @@ function TrustDialog(t0) {
|
|
|
724204
725336
|
let t13;
|
|
724205
725337
|
if ($4[13] !== hasAnyBashExecution) {
|
|
724206
725338
|
t12 = () => {
|
|
724207
|
-
const isHomeDir =
|
|
725339
|
+
const isHomeDir = homedir45() === getCwd();
|
|
724208
725340
|
logEvent("tengu_trust_dialog_shown", {
|
|
724209
725341
|
isHomeDir,
|
|
724210
725342
|
hasMcpServers,
|
|
@@ -724233,7 +725365,7 @@ function TrustDialog(t0) {
|
|
|
724233
725365
|
gracefulShutdownSync(1);
|
|
724234
725366
|
return;
|
|
724235
725367
|
}
|
|
724236
|
-
const isHomeDir_0 =
|
|
725368
|
+
const isHomeDir_0 = homedir45() === getCwd();
|
|
724237
725369
|
logEvent("tengu_trust_dialog_accept", {
|
|
724238
725370
|
isHomeDir: isHomeDir_0,
|
|
724239
725371
|
hasMcpServers,
|
|
@@ -724877,7 +726009,7 @@ var init_ClaudeInChromeOnboarding = __esm(() => {
|
|
|
724877
726009
|
});
|
|
724878
726010
|
|
|
724879
726011
|
// src/interactiveHelpers.tsx
|
|
724880
|
-
import { appendFileSync as
|
|
726012
|
+
import { appendFileSync as appendFileSync5 } from "fs";
|
|
724881
726013
|
function completeOnboarding() {
|
|
724882
726014
|
saveGlobalConfig((current) => ({
|
|
724883
726015
|
...current,
|
|
@@ -725105,7 +726237,7 @@ function getRenderContext(exitOnCtrlC) {
|
|
|
725105
726237
|
cpu: process.cpuUsage()
|
|
725106
726238
|
}) + `
|
|
725107
726239
|
`;
|
|
725108
|
-
|
|
726240
|
+
appendFileSync5(frameTimingLogPath, line);
|
|
725109
726241
|
}
|
|
725110
726242
|
if (isSynchronizedOutputSupported()) {
|
|
725111
726243
|
return;
|
|
@@ -726963,7 +728095,7 @@ var init_claudeInChrome = __esm(() => {
|
|
|
726963
728095
|
});
|
|
726964
728096
|
|
|
726965
728097
|
// src/skills/bundled/debug.ts
|
|
726966
|
-
import { open as
|
|
728098
|
+
import { open as open16, stat as stat52 } from "fs/promises";
|
|
726967
728099
|
function registerDebugSkill() {
|
|
726968
728100
|
registerBundledSkill({
|
|
726969
728101
|
name: "debug",
|
|
@@ -726980,7 +728112,7 @@ function registerDebugSkill() {
|
|
|
726980
728112
|
const stats = await stat52(debugLogPath);
|
|
726981
728113
|
const readSize = Math.min(stats.size, TAIL_READ_BYTES);
|
|
726982
728114
|
const startOffset = stats.size - readSize;
|
|
726983
|
-
const fd2 = await
|
|
728115
|
+
const fd2 = await open16(debugLogPath, "r");
|
|
726984
728116
|
try {
|
|
726985
728117
|
const { buffer, bytesRead } = await fd2.read({
|
|
726986
728118
|
buffer: Buffer.alloc(readSize),
|
|
@@ -729662,8 +730794,8 @@ var init_bundled2 = __esm(() => {
|
|
|
729662
730794
|
|
|
729663
730795
|
// src/utils/deepLink/banner.ts
|
|
729664
730796
|
import { stat as stat53 } from "fs/promises";
|
|
729665
|
-
import { homedir as
|
|
729666
|
-
import { join as
|
|
730797
|
+
import { homedir as homedir46 } from "os";
|
|
730798
|
+
import { join as join175, sep as sep43 } from "path";
|
|
729667
730799
|
function buildDeepLinkBanner(info) {
|
|
729668
730800
|
const lines2 = [
|
|
729669
730801
|
`This session was opened by an external deep link in ${tildify(info.cwd)}`
|
|
@@ -729685,8 +730817,8 @@ async function readLastFetchTime(cwd2) {
|
|
|
729685
730817
|
return;
|
|
729686
730818
|
const commonDir = await getCommonDir(gitDir);
|
|
729687
730819
|
const [local, common4] = await Promise.all([
|
|
729688
|
-
mtimeOrUndefined(
|
|
729689
|
-
commonDir ? mtimeOrUndefined(
|
|
730820
|
+
mtimeOrUndefined(join175(gitDir, "FETCH_HEAD")),
|
|
730821
|
+
commonDir ? mtimeOrUndefined(join175(commonDir, "FETCH_HEAD")) : Promise.resolve(undefined)
|
|
729690
730822
|
]);
|
|
729691
730823
|
if (local && common4)
|
|
729692
730824
|
return local > common4 ? local : common4;
|
|
@@ -729701,7 +730833,7 @@ async function mtimeOrUndefined(p4) {
|
|
|
729701
730833
|
}
|
|
729702
730834
|
}
|
|
729703
730835
|
function tildify(p4) {
|
|
729704
|
-
const home =
|
|
730836
|
+
const home = homedir46();
|
|
729705
730837
|
if (p4 === home)
|
|
729706
730838
|
return "~";
|
|
729707
730839
|
if (p4.startsWith(home + sep43))
|
|
@@ -730065,9 +731197,9 @@ function levenshtein2(a5, b5) {
|
|
|
730065
731197
|
}
|
|
730066
731198
|
return prev[n6];
|
|
730067
731199
|
}
|
|
730068
|
-
function getSubcommandNames(
|
|
731200
|
+
function getSubcommandNames(program3) {
|
|
730069
731201
|
const names = [];
|
|
730070
|
-
for (const cmd of
|
|
731202
|
+
for (const cmd of program3.commands) {
|
|
730071
731203
|
const name3 = cmd.name();
|
|
730072
731204
|
if (name3)
|
|
730073
731205
|
names.push(name3);
|
|
@@ -730076,12 +731208,12 @@ function getSubcommandNames(program2) {
|
|
|
730076
731208
|
}
|
|
730077
731209
|
return names;
|
|
730078
731210
|
}
|
|
730079
|
-
function findClosestSubcommand(word,
|
|
731211
|
+
function findClosestSubcommand(word, program3) {
|
|
730080
731212
|
if (!word)
|
|
730081
731213
|
return;
|
|
730082
731214
|
let best;
|
|
730083
731215
|
let bestDist = Infinity;
|
|
730084
|
-
for (const name3 of getSubcommandNames(
|
|
731216
|
+
for (const name3 of getSubcommandNames(program3)) {
|
|
730085
731217
|
if (name3 === word)
|
|
730086
731218
|
continue;
|
|
730087
731219
|
const dist = levenshtein2(word, name3);
|
|
@@ -730535,7 +731667,7 @@ var parseConnectUrl = () => ({ serverUrl: "", authToken: "" });
|
|
|
730535
731667
|
var init_parseConnectUrl = () => {};
|
|
730536
731668
|
|
|
730537
731669
|
// src/utils/deepLink/terminalLauncher.ts
|
|
730538
|
-
import { spawn as
|
|
731670
|
+
import { spawn as spawn17 } from "child_process";
|
|
730539
731671
|
import { basename as basename64 } from "path";
|
|
730540
731672
|
async function detectMacosTerminal() {
|
|
730541
731673
|
const stored = getGlobalConfig().deepLinkTerminal;
|
|
@@ -730792,7 +731924,7 @@ async function launchWindowsTerminal(terminal, claudePath, claudeArgs, cwd2) {
|
|
|
730792
731924
|
}
|
|
730793
731925
|
function spawnDetached(command10, args, opts = {}) {
|
|
730794
731926
|
return new Promise((resolve53) => {
|
|
730795
|
-
const child =
|
|
731927
|
+
const child = spawn17(command10, args, {
|
|
730796
731928
|
detached: true,
|
|
730797
731929
|
stdio: "ignore",
|
|
730798
731930
|
cwd: opts.cwd,
|
|
@@ -730875,7 +732007,7 @@ __export(exports_protocolHandler, {
|
|
|
730875
732007
|
handleUrlSchemeLaunch: () => handleUrlSchemeLaunch,
|
|
730876
732008
|
handleDeepLinkUri: () => handleDeepLinkUri
|
|
730877
732009
|
});
|
|
730878
|
-
import { homedir as
|
|
732010
|
+
import { homedir as homedir47 } from "os";
|
|
730879
732011
|
async function handleDeepLinkUri(uri3) {
|
|
730880
732012
|
logForDebugging(`Handling deep link URI: ${uri3}`);
|
|
730881
732013
|
let action2;
|
|
@@ -730929,7 +732061,7 @@ async function resolveCwd(action2) {
|
|
|
730929
732061
|
}
|
|
730930
732062
|
logForDebugging(`No local clone found for repo ${action2.repo}, falling back to home`);
|
|
730931
732063
|
}
|
|
730932
|
-
return { cwd:
|
|
732064
|
+
return { cwd: homedir47() };
|
|
730933
732065
|
}
|
|
730934
732066
|
var init_protocolHandler = __esm(() => {
|
|
730935
732067
|
init_debug();
|
|
@@ -730946,12 +732078,12 @@ var exports_setup = {};
|
|
|
730946
732078
|
__export(exports_setup, {
|
|
730947
732079
|
setupComputerUseMCP: () => setupComputerUseMCP
|
|
730948
732080
|
});
|
|
730949
|
-
import { join as
|
|
732081
|
+
import { join as join176 } from "path";
|
|
730950
732082
|
import { fileURLToPath as fileURLToPath9 } from "url";
|
|
730951
732083
|
function setupComputerUseMCP() {
|
|
730952
732084
|
const allowedTools = buildComputerUseTools(CLI_CU_CAPABILITIES, getChicagoCoordinateMode()).map((t4) => buildMcpToolName(COMPUTER_USE_MCP_SERVER_NAME, t4.name));
|
|
730953
732085
|
const args = isInBundledMode() ? ["--computer-use-mcp"] : [
|
|
730954
|
-
|
|
732086
|
+
join176(fileURLToPath9(import.meta.url), "..", "cli.js"),
|
|
730955
732087
|
"--computer-use-mcp"
|
|
730956
732088
|
];
|
|
730957
732089
|
return {
|
|
@@ -730974,7 +732106,7 @@ var init_setup3 = __esm(() => {
|
|
|
730974
732106
|
});
|
|
730975
732107
|
|
|
730976
732108
|
// src/services/SessionMemory/sessionMemory.ts
|
|
730977
|
-
import { writeFile as
|
|
732109
|
+
import { writeFile as writeFile63 } from "fs/promises";
|
|
730978
732110
|
function isSessionMemoryGateEnabled() {
|
|
730979
732111
|
return getFeatureValue_CACHED_MAY_BE_STALE("tengu_session_memory", false);
|
|
730980
732112
|
}
|
|
@@ -731028,13 +732160,13 @@ async function setupSessionMemoryFile(toolUseContext) {
|
|
|
731028
732160
|
await fs21.mkdir(sessionMemoryDir, { mode: 448 });
|
|
731029
732161
|
const memoryPath = getSessionMemoryPath();
|
|
731030
732162
|
try {
|
|
731031
|
-
await
|
|
732163
|
+
await writeFile63(memoryPath, "", {
|
|
731032
732164
|
encoding: "utf-8",
|
|
731033
732165
|
mode: 384,
|
|
731034
732166
|
flag: "wx"
|
|
731035
732167
|
});
|
|
731036
732168
|
const template = await loadSessionMemoryTemplate();
|
|
731037
|
-
await
|
|
732169
|
+
await writeFile63(memoryPath, template, {
|
|
731038
732170
|
encoding: "utf-8",
|
|
731039
732171
|
mode: 384
|
|
731040
732172
|
});
|
|
@@ -731172,8 +732304,8 @@ var init_sessionMemory = __esm(() => {
|
|
|
731172
732304
|
|
|
731173
732305
|
// src/utils/iTermBackup.ts
|
|
731174
732306
|
import { copyFile as copyFile12, stat as stat54 } from "fs/promises";
|
|
731175
|
-
import { homedir as
|
|
731176
|
-
import { join as
|
|
732307
|
+
import { homedir as homedir48 } from "os";
|
|
732308
|
+
import { join as join177 } from "path";
|
|
731177
732309
|
function markITerm2SetupComplete() {
|
|
731178
732310
|
saveGlobalConfig((current) => ({
|
|
731179
732311
|
...current,
|
|
@@ -731188,7 +732320,7 @@ function getIterm2RecoveryInfo() {
|
|
|
731188
732320
|
};
|
|
731189
732321
|
}
|
|
731190
732322
|
function getITerm2PlistPath() {
|
|
731191
|
-
return
|
|
732323
|
+
return join177(homedir48(), "Library", "Preferences", "com.googlecode.iterm2.plist");
|
|
731192
732324
|
}
|
|
731193
732325
|
async function checkAndRestoreITerm2Backup() {
|
|
731194
732326
|
const { inProgress, backupPath } = getIterm2RecoveryInfo();
|
|
@@ -732715,7 +733847,7 @@ var init_QueryEngine = __esm(() => {
|
|
|
732715
733847
|
var FILE_COUNT_LIMIT = 1e4, OUTPUTS_SUBDIR = ".claude-code/outputs", DEFAULT_UPLOAD_CONCURRENCY = 5;
|
|
732716
733848
|
|
|
732717
733849
|
// src/utils/filePersistence/filePersistence.ts
|
|
732718
|
-
import { join as
|
|
733850
|
+
import { join as join178, relative as relative37 } from "path";
|
|
732719
733851
|
async function runFilePersistence(turnStartTime, signal) {
|
|
732720
733852
|
const environmentKind = getEnvironmentKind();
|
|
732721
733853
|
if (environmentKind !== "byoc") {
|
|
@@ -732734,7 +733866,7 @@ async function runFilePersistence(turnStartTime, signal) {
|
|
|
732734
733866
|
oauthToken: sessionAccessToken,
|
|
732735
733867
|
sessionId
|
|
732736
733868
|
};
|
|
732737
|
-
const outputsDir =
|
|
733869
|
+
const outputsDir = join178(getCwd(), sessionId, OUTPUTS_SUBDIR);
|
|
732738
733870
|
if (signal?.aborted) {
|
|
732739
733871
|
logDebug("Persistence aborted before processing");
|
|
732740
733872
|
return null;
|
|
@@ -732942,11 +734074,11 @@ var init_sessionUrl = __esm(() => {
|
|
|
732942
734074
|
});
|
|
732943
734075
|
|
|
732944
734076
|
// src/utils/plugins/zipCacheAdapters.ts
|
|
732945
|
-
import { readFile as
|
|
732946
|
-
import { join as
|
|
734077
|
+
import { readFile as readFile67 } from "fs/promises";
|
|
734078
|
+
import { join as join179 } from "path";
|
|
732947
734079
|
async function readZipCacheKnownMarketplaces() {
|
|
732948
734080
|
try {
|
|
732949
|
-
const content = await
|
|
734081
|
+
const content = await readFile67(getZipCacheKnownMarketplacesPath(), "utf-8");
|
|
732950
734082
|
const parsed = KnownMarketplacesFileSchema().safeParse(jsonParse(content));
|
|
732951
734083
|
if (!parsed.success) {
|
|
732952
734084
|
logForDebugging(`Invalid known_marketplaces.json in zip cache: ${parsed.error.message}`, { level: "error" });
|
|
@@ -732968,18 +734100,18 @@ async function saveMarketplaceJsonToZipCache(marketplaceName, installLocation) {
|
|
|
732968
734100
|
const content = await readMarketplaceJsonContent(installLocation);
|
|
732969
734101
|
if (content !== null) {
|
|
732970
734102
|
const relPath = getMarketplaceJsonRelativePath(marketplaceName);
|
|
732971
|
-
await atomicWriteToZipCache(
|
|
734103
|
+
await atomicWriteToZipCache(join179(zipCachePath, relPath), content);
|
|
732972
734104
|
}
|
|
732973
734105
|
}
|
|
732974
734106
|
async function readMarketplaceJsonContent(dir) {
|
|
732975
734107
|
const candidates = [
|
|
732976
|
-
|
|
732977
|
-
|
|
734108
|
+
join179(dir, ".claude-plugin", "marketplace.json"),
|
|
734109
|
+
join179(dir, "marketplace.json"),
|
|
732978
734110
|
dir
|
|
732979
734111
|
];
|
|
732980
734112
|
for (const candidate of candidates) {
|
|
732981
734113
|
try {
|
|
732982
|
-
return await
|
|
734114
|
+
return await readFile67(candidate, "utf-8");
|
|
732983
734115
|
} catch {}
|
|
732984
734116
|
}
|
|
732985
734117
|
return null;
|
|
@@ -733109,7 +734241,7 @@ __export(exports_print, {
|
|
|
733109
734241
|
createCanUseToolWithPermissionPrompt: () => createCanUseToolWithPermissionPrompt,
|
|
733110
734242
|
canBatchWith: () => canBatchWith
|
|
733111
734243
|
});
|
|
733112
|
-
import { readFile as
|
|
734244
|
+
import { readFile as readFile68, stat as stat55 } from "fs/promises";
|
|
733113
734245
|
import { dirname as dirname76 } from "path";
|
|
733114
734246
|
import { cwd as cwd2 } from "process";
|
|
733115
734247
|
import { randomUUID as randomUUID65 } from "crypto";
|
|
@@ -733435,7 +734567,7 @@ Error: sandbox required but unavailable: ${sandboxUnavailableReason}
|
|
|
733435
734567
|
gracefulShutdownSync(lastMessage?.type === "result" && lastMessage?.is_error ? 1 : 0);
|
|
733436
734568
|
}
|
|
733437
734569
|
function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initialMessages, canUseTool, sdkMcpConfigs, getAppState, setAppState, agents2, options, turnInterruptionState) {
|
|
733438
|
-
let
|
|
734570
|
+
let running2 = false;
|
|
733439
734571
|
let runPhase;
|
|
733440
734572
|
let inputClosed = false;
|
|
733441
734573
|
let shutdownPromptInjected = false;
|
|
@@ -733457,7 +734589,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
733457
734589
|
bg[t4.type] = (bg[t4.type] ?? 0) + 1;
|
|
733458
734590
|
}
|
|
733459
734591
|
logForDiagnosticsNoPII("info", "run_state_at_shutdown", {
|
|
733460
|
-
run_active:
|
|
734592
|
+
run_active: running2,
|
|
733461
734593
|
run_phase: runPhase,
|
|
733462
734594
|
worker_status: getSessionState(),
|
|
733463
734595
|
internal_events_pending: structuredIO.internalEventsPending,
|
|
@@ -733816,7 +734948,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
733816
734948
|
installPluginsAndApplyMcpInBackground();
|
|
733817
734949
|
}
|
|
733818
734950
|
}
|
|
733819
|
-
const idleTimeout = createIdleTimeoutManager(() => !
|
|
734951
|
+
const idleTimeout = createIdleTimeoutManager(() => !running2);
|
|
733820
734952
|
let currentCommands = commands7;
|
|
733821
734953
|
let currentAgents = agents2;
|
|
733822
734954
|
async function refreshPluginState() {
|
|
@@ -733873,10 +735005,10 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
733873
735005
|
}
|
|
733874
735006
|
});
|
|
733875
735007
|
const run = async () => {
|
|
733876
|
-
if (
|
|
735008
|
+
if (running2) {
|
|
733877
735009
|
return;
|
|
733878
735010
|
}
|
|
733879
|
-
|
|
735011
|
+
running2 = true;
|
|
733880
735012
|
runPhase = undefined;
|
|
733881
735013
|
notifySessionStateChanged("running");
|
|
733882
735014
|
idleTimeout.stop();
|
|
@@ -734228,7 +735360,7 @@ function runHeadlessStreaming(structuredIO, mcpClients, commands7, tools, initia
|
|
|
734228
735360
|
output.enqueue(event);
|
|
734229
735361
|
}
|
|
734230
735362
|
}
|
|
734231
|
-
|
|
735363
|
+
running2 = false;
|
|
734232
735364
|
idleTimeout.start();
|
|
734233
735365
|
}
|
|
734234
735366
|
if ((feature("PROACTIVE") || feature("KAIROS")) && proactiveModule9?.isProactiveActive() && !proactiveModule9.isProactivePaused()) {
|
|
@@ -734373,7 +735505,7 @@ ${m5.text}
|
|
|
734373
735505
|
});
|
|
734374
735506
|
run();
|
|
734375
735507
|
},
|
|
734376
|
-
isLoading: () =>
|
|
735508
|
+
isLoading: () => running2 || inputClosed,
|
|
734377
735509
|
getJitterConfig: cronJitterConfigModule?.getCronJitterConfig,
|
|
734378
735510
|
isKilled: () => !cronGate?.isKairosCronEnabled()
|
|
734379
735511
|
});
|
|
@@ -734552,7 +735684,7 @@ ${m5.text}
|
|
|
734552
735684
|
const normalizedPath = expandPath(message.request.path);
|
|
734553
735685
|
const diskMtime = Math.floor((await stat55(normalizedPath)).mtimeMs);
|
|
734554
735686
|
if (diskMtime <= message.request.mtime) {
|
|
734555
|
-
const raw = await
|
|
735687
|
+
const raw = await readFile68(normalizedPath, "utf-8");
|
|
734556
735688
|
const content = (raw.charCodeAt(0) === 65279 ? raw.slice(1) : raw).replaceAll(`\r
|
|
734557
735689
|
`, `
|
|
734558
735690
|
`);
|
|
@@ -735238,7 +736370,7 @@ ${m5.text}
|
|
|
735238
736370
|
}
|
|
735239
736371
|
inputClosed = true;
|
|
735240
736372
|
cronScheduler?.stop();
|
|
735241
|
-
if (!
|
|
736373
|
+
if (!running2) {
|
|
735242
736374
|
if (suggestionState.inflightPromise) {
|
|
735243
736375
|
await Promise.race([suggestionState.inflightPromise, sleep3(5000)]);
|
|
735244
736376
|
}
|
|
@@ -737250,16 +738382,16 @@ __export(exports_claudeDesktop, {
|
|
|
737250
738382
|
readClaudeDesktopMcpServers: () => readClaudeDesktopMcpServers,
|
|
737251
738383
|
getClaudeDesktopConfigPath: () => getClaudeDesktopConfigPath
|
|
737252
738384
|
});
|
|
737253
|
-
import { readdir as readdir37, readFile as
|
|
737254
|
-
import { homedir as
|
|
737255
|
-
import { join as
|
|
738385
|
+
import { readdir as readdir37, readFile as readFile69, stat as stat56 } from "fs/promises";
|
|
738386
|
+
import { homedir as homedir49 } from "os";
|
|
738387
|
+
import { join as join180 } from "path";
|
|
737256
738388
|
async function getClaudeDesktopConfigPath() {
|
|
737257
738389
|
const platform7 = getPlatform();
|
|
737258
738390
|
if (!SUPPORTED_PLATFORMS.includes(platform7)) {
|
|
737259
738391
|
throw new Error(`Unsupported platform: ${platform7} - Claude Desktop integration only works on macOS and WSL.`);
|
|
737260
738392
|
}
|
|
737261
738393
|
if (platform7 === "macos") {
|
|
737262
|
-
return
|
|
738394
|
+
return join180(homedir49(), "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
737263
738395
|
}
|
|
737264
738396
|
const windowsHome = process.env.USERPROFILE ? process.env.USERPROFILE.replace(/\\/g, "/") : null;
|
|
737265
738397
|
if (windowsHome) {
|
|
@@ -737278,7 +738410,7 @@ async function getClaudeDesktopConfigPath() {
|
|
|
737278
738410
|
if (user.name === "Public" || user.name === "Default" || user.name === "Default User" || user.name === "All Users") {
|
|
737279
738411
|
continue;
|
|
737280
738412
|
}
|
|
737281
|
-
const potentialConfigPath =
|
|
738413
|
+
const potentialConfigPath = join180(usersDir, user.name, "AppData", "Roaming", "Claude", "claude_desktop_config.json");
|
|
737282
738414
|
try {
|
|
737283
738415
|
await stat56(potentialConfigPath);
|
|
737284
738416
|
return potentialConfigPath;
|
|
@@ -737298,7 +738430,7 @@ async function readClaudeDesktopMcpServers() {
|
|
|
737298
738430
|
const configPath = await getClaudeDesktopConfigPath();
|
|
737299
738431
|
let configContent;
|
|
737300
738432
|
try {
|
|
737301
|
-
configContent = await
|
|
738433
|
+
configContent = await readFile69(configPath, { encoding: "utf8" });
|
|
737302
738434
|
} catch (e4) {
|
|
737303
738435
|
const code = getErrnoCode(e4);
|
|
737304
738436
|
if (code === "ENOENT") {
|
|
@@ -738246,13 +739378,13 @@ var exports_install = {};
|
|
|
738246
739378
|
__export(exports_install, {
|
|
738247
739379
|
install: () => install
|
|
738248
739380
|
});
|
|
738249
|
-
import { homedir as
|
|
738250
|
-
import { join as
|
|
739381
|
+
import { homedir as homedir50 } from "os";
|
|
739382
|
+
import { join as join181 } from "path";
|
|
738251
739383
|
function getInstallationPath2() {
|
|
738252
739384
|
const isWindows3 = env4.platform === "win32";
|
|
738253
|
-
const homeDir =
|
|
739385
|
+
const homeDir = homedir50();
|
|
738254
739386
|
if (isWindows3) {
|
|
738255
|
-
const windowsPath =
|
|
739387
|
+
const windowsPath = join181(homeDir, ".local", "bin", "claude.exe");
|
|
738256
739388
|
return windowsPath.replace(/\//g, "\\");
|
|
738257
739389
|
}
|
|
738258
739390
|
return "~/.local/bin/claude";
|
|
@@ -738564,7 +739696,7 @@ function Install({
|
|
|
738564
739696
|
}, undefined, true, undefined, this);
|
|
738565
739697
|
}
|
|
738566
739698
|
var import_compiler_runtime368, import_react332, jsx_dev_runtime486, install;
|
|
738567
|
-
var
|
|
739699
|
+
var init_install2 = __esm(() => {
|
|
738568
739700
|
init_analytics();
|
|
738569
739701
|
init_StatusIcon();
|
|
738570
739702
|
init_ink2();
|
|
@@ -738698,7 +739830,7 @@ async function installHandler(target, options) {
|
|
|
738698
739830
|
await setup2(cwd4(), "default", false, false, undefined, false);
|
|
738699
739831
|
const {
|
|
738700
739832
|
install: install2
|
|
738701
|
-
} = await Promise.resolve().then(() => (
|
|
739833
|
+
} = await Promise.resolve().then(() => (init_install2(), exports_install));
|
|
738702
739834
|
await new Promise((resolve53) => {
|
|
738703
739835
|
const args = [];
|
|
738704
739836
|
if (target)
|
|
@@ -738837,7 +739969,7 @@ var exports_projectPurge = {};
|
|
|
738837
739969
|
__export(exports_projectPurge, {
|
|
738838
739970
|
purgeProjectHandler: () => purgeProjectHandler
|
|
738839
739971
|
});
|
|
738840
|
-
import { join as
|
|
739972
|
+
import { join as join182 } from "path";
|
|
738841
739973
|
function resolveAbsolutePath(input) {
|
|
738842
739974
|
if (!input) {
|
|
738843
739975
|
return getCwd();
|
|
@@ -738856,7 +739988,7 @@ async function discoverAllProjectPaths() {
|
|
|
738856
739988
|
try {
|
|
738857
739989
|
const entries = await fs21.readdir(projectsDir);
|
|
738858
739990
|
for (const entry of entries) {
|
|
738859
|
-
paths2.add(
|
|
739991
|
+
paths2.add(join182(projectsDir, entry.name));
|
|
738860
739992
|
}
|
|
738861
739993
|
} catch {}
|
|
738862
739994
|
return [...paths2];
|
|
@@ -738866,7 +739998,7 @@ async function collectItemsForProject(projectPath) {
|
|
|
738866
739998
|
const warnings = [];
|
|
738867
739999
|
const fs21 = getFsImplementation();
|
|
738868
740000
|
const projectsDir = getProjectsDir2();
|
|
738869
|
-
const transcriptDir =
|
|
740001
|
+
const transcriptDir = join182(projectsDir, sanitizePath2(projectPath));
|
|
738870
740002
|
try {
|
|
738871
740003
|
const stat58 = await fs21.stat(transcriptDir);
|
|
738872
740004
|
if (stat58.isDirectory()) {
|
|
@@ -739532,7 +740664,7 @@ __export(exports_main4, {
|
|
|
739532
740664
|
startDeferredPrefetches: () => startDeferredPrefetches,
|
|
739533
740665
|
main: () => main
|
|
739534
740666
|
});
|
|
739535
|
-
import { readFileSync as
|
|
740667
|
+
import { readFileSync as readFileSync28 } from "fs";
|
|
739536
740668
|
import { resolve as resolve53 } from "path";
|
|
739537
740669
|
function logManagedSettings() {
|
|
739538
740670
|
try {
|
|
@@ -739609,26 +740741,54 @@ async function logStartupTelemetry() {
|
|
|
739609
740741
|
});
|
|
739610
740742
|
}
|
|
739611
740743
|
function runMigrations() {
|
|
740744
|
+
process.stderr.write(`[DIAG5] runMigrations entry
|
|
740745
|
+
`);
|
|
739612
740746
|
if (getGlobalConfig().migrationVersion !== CURRENT_MIGRATION_VERSION) {
|
|
740747
|
+
process.stderr.write(`[DIAG5] before migrateAutoUpdates
|
|
740748
|
+
`);
|
|
739613
740749
|
migrateAutoUpdatesToSettings();
|
|
740750
|
+
process.stderr.write(`[DIAG5] before migrateBypass
|
|
740751
|
+
`);
|
|
739614
740752
|
migrateBypassPermissionsAcceptedToSettings();
|
|
740753
|
+
process.stderr.write(`[DIAG5] before migrateEnableAllMcp
|
|
740754
|
+
`);
|
|
739615
740755
|
migrateEnableAllProjectMcpServersToSettings();
|
|
740756
|
+
process.stderr.write(`[DIAG5] before resetPro
|
|
740757
|
+
`);
|
|
739616
740758
|
resetProToOpusDefault();
|
|
740759
|
+
process.stderr.write(`[DIAG5] before migrateSonnet1m
|
|
740760
|
+
`);
|
|
739617
740761
|
migrateSonnet1mToSonnet45();
|
|
740762
|
+
process.stderr.write(`[DIAG5] before migrateLegacyOpus
|
|
740763
|
+
`);
|
|
739618
740764
|
migrateLegacyOpusToCurrent();
|
|
740765
|
+
process.stderr.write(`[DIAG5] before migrateSonnet45
|
|
740766
|
+
`);
|
|
739619
740767
|
migrateSonnet45ToSonnet46();
|
|
740768
|
+
process.stderr.write(`[DIAG5] before migrateOpus1m
|
|
740769
|
+
`);
|
|
739620
740770
|
migrateOpusToOpus1m();
|
|
740771
|
+
process.stderr.write(`[DIAG5] before migrateReplBridge
|
|
740772
|
+
`);
|
|
739621
740773
|
migrateReplBridgeEnabledToRemoteControlAtStartup();
|
|
739622
740774
|
if (feature("TRANSCRIPT_CLASSIFIER")) {
|
|
739623
740775
|
resetAutoModeOptInForDefaultOffer();
|
|
739624
740776
|
}
|
|
739625
740777
|
if (false) {}
|
|
740778
|
+
process.stderr.write(`[DIAG5] before saveGlobalConfig
|
|
740779
|
+
`);
|
|
739626
740780
|
saveGlobalConfig((prev) => prev.migrationVersion === CURRENT_MIGRATION_VERSION ? prev : {
|
|
739627
740781
|
...prev,
|
|
739628
740782
|
migrationVersion: CURRENT_MIGRATION_VERSION
|
|
739629
740783
|
});
|
|
740784
|
+
process.stderr.write(`[DIAG5] after saveGlobalConfig
|
|
740785
|
+
`);
|
|
739630
740786
|
}
|
|
740787
|
+
process.stderr.write(`[DIAG5] before migrateChangelog
|
|
740788
|
+
`);
|
|
739631
740789
|
migrateChangelogFromConfig().catch(() => {});
|
|
740790
|
+
process.stderr.write(`[DIAG5] runMigrations exit
|
|
740791
|
+
`);
|
|
739632
740792
|
}
|
|
739633
740793
|
function prefetchSystemContextIfSafe() {
|
|
739634
740794
|
const isNonInteractiveSession = getIsNonInteractiveSession();
|
|
@@ -739690,7 +740850,7 @@ function loadSettingsFromFlag(settingsFile) {
|
|
|
739690
740850
|
resolvedPath: resolvedSettingsPath
|
|
739691
740851
|
} = safeResolvePath(getFsImplementation(), settingsFile);
|
|
739692
740852
|
try {
|
|
739693
|
-
|
|
740853
|
+
readFileSync28(resolvedSettingsPath, "utf8");
|
|
739694
740854
|
} catch (e4) {
|
|
739695
740855
|
if (isENOENT(e4)) {
|
|
739696
740856
|
process.stderr.write(source_default.red(`Error: Settings file not found: ${resolvedSettingsPath}
|
|
@@ -739912,6 +741072,13 @@ async function main() {
|
|
|
739912
741072
|
const hasInitOnlyFlag = cliArgs.includes("--init-only");
|
|
739913
741073
|
const hasSdkUrl = cliArgs.some((arg) => arg.startsWith("--sdk-url"));
|
|
739914
741074
|
const isNonInteractive = hasPrintFlag || hasInitOnlyFlag || hasSdkUrl || !process.stdout.isTTY;
|
|
741075
|
+
const daemonWorkerIdx = cliArgs.indexOf("--daemon-worker");
|
|
741076
|
+
if (daemonWorkerIdx >= 0) {
|
|
741077
|
+
const workerKind = cliArgs[daemonWorkerIdx + 1] ?? "default";
|
|
741078
|
+
const { runDaemonWorker: runDaemonWorker2 } = await Promise.resolve().then(() => (init_workerRegistry(), exports_workerRegistry));
|
|
741079
|
+
await runDaemonWorker2(workerKind);
|
|
741080
|
+
return program;
|
|
741081
|
+
}
|
|
739915
741082
|
if (isNonInteractive) {
|
|
739916
741083
|
stopCapturingEarlyInput();
|
|
739917
741084
|
}
|
|
@@ -739988,9 +741155,9 @@ async function run() {
|
|
|
739988
741155
|
compareOptions: (a5, b5) => getOptionSortKey(a5).localeCompare(getOptionSortKey(b5))
|
|
739989
741156
|
});
|
|
739990
741157
|
}
|
|
739991
|
-
const
|
|
741158
|
+
const program3 = new Command().configureHelp(createSortedHelpConfig()).enablePositionalOptions();
|
|
739992
741159
|
profileCheckpoint("run_commander_initialized");
|
|
739993
|
-
|
|
741160
|
+
program3.hook("preAction", async (thisCommand) => {
|
|
739994
741161
|
profileCheckpoint("preAction_start");
|
|
739995
741162
|
await Promise.all([ensureMdmSettingsLoaded(), ensureKeychainPrefetchCompleted()]);
|
|
739996
741163
|
profileCheckpoint("preAction_after_mdm");
|
|
@@ -740005,11 +741172,17 @@ async function run() {
|
|
|
740005
741172
|
initSinks2();
|
|
740006
741173
|
profileCheckpoint("preAction_after_sinks");
|
|
740007
741174
|
const pluginDir = thisCommand.getOptionValue("pluginDir");
|
|
741175
|
+
process.stderr.write(`[DIAG4] before pluginDir check
|
|
741176
|
+
`);
|
|
740008
741177
|
if (Array.isArray(pluginDir) && pluginDir.length > 0 && pluginDir.every((p4) => typeof p4 === "string")) {
|
|
740009
741178
|
setInlinePlugins(pluginDir);
|
|
740010
741179
|
clearPluginCache("preAction: --plugin-dir inline plugins");
|
|
740011
741180
|
}
|
|
741181
|
+
process.stderr.write(`[DIAG4] before runMigrations
|
|
741182
|
+
`);
|
|
740012
741183
|
runMigrations();
|
|
741184
|
+
process.stderr.write(`[DIAG4] after runMigrations
|
|
741185
|
+
`);
|
|
740013
741186
|
profileCheckpoint("preAction_after_migrations");
|
|
740014
741187
|
if (getSettingsForSource("policySettings")?.forceRemoteSettingsRefresh) {
|
|
740015
741188
|
const result = await forceRefreshRemoteManagedSettingsOrFailClosed();
|
|
@@ -740028,7 +741201,7 @@ async function run() {
|
|
|
740028
741201
|
}
|
|
740029
741202
|
profileCheckpoint("preAction_after_settings_sync");
|
|
740030
741203
|
});
|
|
740031
|
-
|
|
741204
|
+
program3.name("claude").description(`Claude Code - starts an interactive session by default, use -p/--print for non-interactive output`).argument("[prompt]", "Your prompt", String).helpOption("-h, --help", "Display help for command").option("-d, --debug [filter]", 'Enable debug mode with optional category filtering (e.g., "api,hooks" or "!1p,!file")', (_value) => {
|
|
740032
741205
|
return true;
|
|
740033
741206
|
}).addOption(new Option("--debug-to-stderr", "Enable debug mode (to stderr)").argParser(Boolean).hideHelp()).option("--debug-file <path>", "Write debug logs to a specific file path (implicitly enables debug mode)", () => true).option("--verbose", "Override verbose mode setting from config", () => true).option("-p, --print", "Print response and exit (useful for pipes). Note: The workspace trust dialog is skipped when Claude is run with the -p mode. Only use this flag in directories you trust.", () => true).option("--bare", "Minimal mode: skip hooks, LSP, plugin sync, attribution, auto-memory, background prefetches, keychain reads, and CLAUDE.md auto-discovery. Sets CLAUDE_CODE_SIMPLE=1. Anthropic auth is strictly ANTHROPIC_API_KEY or apiKeyHelper via --settings (OAuth and keychain are never read). 3P providers (Bedrock/Vertex/Foundry) use their own credentials. Skills still resolve via /skill-name. Explicitly provide context via: --system-prompt[-file], --append-system-prompt[-file], --add-dir (CLAUDE.md dirs), --mcp-config, --settings, --agents, --plugin-dir.", () => true).addOption(new Option("--init", "Run Setup hooks with init trigger, then continue").hideHelp()).addOption(new Option("--init-only", "Run Setup and SessionStart:startup hooks, then exit").hideHelp()).addOption(new Option("--maintenance", "Run Setup hooks with maintenance trigger, then continue").hideHelp()).addOption(new Option("--output-format <format>", 'Output format (only works with --print): "text" (default), "json" (single result), or "stream-json" (realtime streaming)').choices(["text", "json", "stream-json"])).addOption(new Option("--json-schema <schema>", 'JSON Schema for structured output validation. Example: {"type":"object","properties":{"name":{"type":"string"}},"required":["name"]}').argParser(String)).option("--include-hook-events", "Include all hook lifecycle events in the output stream (only works with --output-format=stream-json)", () => true).option("--include-partial-messages", "Include partial message chunks as they arrive (only works with --print and --output-format=stream-json)", () => true).addOption(new Option("--input-format <format>", 'Input format (only works with --print): "text" (default), or "stream-json" (realtime streaming input)').choices(["text", "stream-json"])).option("--mcp-debug", "[DEPRECATED. Use --debug instead] Enable MCP debug mode (shows MCP server errors)", () => true).option("--dangerously-skip-permissions", "Bypass all permission checks. Recommended only for sandboxes with no internet access.", () => true).option("--allow-dangerously-skip-permissions", "Enable bypassing all permission checks as an option, without it being enabled by default. Recommended only for sandboxes with no internet access.", () => true).addOption(new Option("--thinking <mode>", "Thinking mode: enabled (equivalent to adaptive), disabled").choices(["enabled", "adaptive", "disabled"]).hideHelp()).addOption(new Option("--max-thinking-tokens <tokens>", "[DEPRECATED. Use --thinking instead for newer models] Maximum number of thinking tokens (only works with --print)").argParser(Number).hideHelp()).addOption(new Option("--max-turns <turns>", "Maximum number of agentic turns in non-interactive mode. This will early exit the conversation after the specified number of turns. (only works with --print)").argParser(Number).hideHelp()).addOption(new Option("--max-budget-usd <amount>", "Maximum dollar amount to spend on API calls (only works with --print)").argParser((value) => {
|
|
740034
741207
|
const amount = Number(value);
|
|
@@ -740068,12 +741241,12 @@ async function run() {
|
|
|
740068
741241
|
});
|
|
740069
741242
|
}
|
|
740070
741243
|
if (prompt && typeof prompt === "string" && !/\s/.test(prompt) && prompt.length > 0) {
|
|
740071
|
-
const subcommandSuggestion = findClosestSubcommand(prompt,
|
|
741244
|
+
const subcommandSuggestion = findClosestSubcommand(prompt, program3);
|
|
740072
741245
|
if (subcommandSuggestion) {
|
|
740073
741246
|
process.stderr.write(`Unknown command: ${prompt}. Did you mean '${subcommandSuggestion}'?
|
|
740074
741247
|
`);
|
|
740075
741248
|
await gracefulShutdown(1);
|
|
740076
|
-
return
|
|
741249
|
+
return program3;
|
|
740077
741250
|
}
|
|
740078
741251
|
}
|
|
740079
741252
|
let kairosEnabled = false;
|
|
@@ -740266,7 +741439,7 @@ ${getTmuxInstallInstructions2()}
|
|
|
740266
741439
|
}
|
|
740267
741440
|
try {
|
|
740268
741441
|
const filePath = resolve53(options.systemPromptFile);
|
|
740269
|
-
systemPrompt =
|
|
741442
|
+
systemPrompt = readFileSync28(filePath, "utf8");
|
|
740270
741443
|
} catch (error52) {
|
|
740271
741444
|
const code = getErrnoCode(error52);
|
|
740272
741445
|
if (code === "ENOENT") {
|
|
@@ -740288,7 +741461,7 @@ ${getTmuxInstallInstructions2()}
|
|
|
740288
741461
|
}
|
|
740289
741462
|
try {
|
|
740290
741463
|
const filePath = resolve53(options.appendSystemPromptFile);
|
|
740291
|
-
appendSystemPrompt =
|
|
741464
|
+
appendSystemPrompt = readFileSync28(filePath, "utf8");
|
|
740292
741465
|
} catch (error52) {
|
|
740293
741466
|
const code = getErrnoCode(error52);
|
|
740294
741467
|
if (code === "ENOENT") {
|
|
@@ -742062,59 +743235,60 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
742062
743235
|
}, renderAndRun);
|
|
742063
743236
|
}
|
|
742064
743237
|
}).version(`${MACRO.VERSION} (Claude Code)`, "-v, --version", "Output the version number");
|
|
742065
|
-
|
|
742066
|
-
|
|
743238
|
+
program3.option("-w, --worktree [name]", "Create a new git worktree for this session (optionally specify a name)");
|
|
743239
|
+
program3.option("--tmux", "Create a tmux session for the worktree (requires --worktree). Uses iTerm2 native panes when available; use --tmux=classic for traditional tmux.");
|
|
742067
743240
|
if (canUserConfigureAdvisor()) {
|
|
742068
|
-
|
|
743241
|
+
program3.addOption(new Option("--advisor <model>", "Enable the server-side advisor tool with the specified model (alias or full ID).").hideHelp());
|
|
742069
743242
|
}
|
|
742070
743243
|
if (false) {}
|
|
742071
743244
|
if (feature("TRANSCRIPT_CLASSIFIER")) {
|
|
742072
|
-
|
|
743245
|
+
program3.addOption(new Option("--enable-auto-mode", "Opt in to auto mode").hideHelp());
|
|
742073
743246
|
}
|
|
742074
743247
|
if (feature("PROACTIVE") || feature("KAIROS")) {
|
|
742075
|
-
|
|
743248
|
+
program3.addOption(new Option("--proactive", "Start in proactive autonomous mode"));
|
|
742076
743249
|
}
|
|
742077
743250
|
if (feature("UDS_INBOX")) {
|
|
742078
|
-
|
|
743251
|
+
program3.addOption(new Option("--messaging-socket-path <path>", "Unix domain socket path for the UDS messaging server (defaults to a tmp path)"));
|
|
742079
743252
|
}
|
|
742080
743253
|
if (feature("KAIROS") || feature("KAIROS_BRIEF")) {
|
|
742081
|
-
|
|
743254
|
+
program3.addOption(new Option("--brief", "Enable SendUserMessage tool for agent-to-user communication"));
|
|
742082
743255
|
}
|
|
742083
743256
|
if (feature("KAIROS")) {
|
|
742084
|
-
|
|
743257
|
+
program3.addOption(new Option("--assistant", "Force assistant mode (Agent SDK daemon use)").hideHelp());
|
|
742085
743258
|
}
|
|
742086
743259
|
if (feature("KAIROS") || feature("KAIROS_CHANNELS")) {
|
|
742087
|
-
|
|
742088
|
-
|
|
742089
|
-
}
|
|
742090
|
-
|
|
742091
|
-
|
|
742092
|
-
|
|
742093
|
-
|
|
742094
|
-
|
|
742095
|
-
|
|
742096
|
-
|
|
742097
|
-
|
|
742098
|
-
|
|
742099
|
-
|
|
742100
|
-
|
|
743260
|
+
program3.addOption(new Option("--channels <servers...>", "MCP servers whose channel notifications (inbound push) should register this session. Space-separated server names.").hideHelp());
|
|
743261
|
+
program3.addOption(new Option("--dangerously-load-development-channels <servers...>", "Load channel servers not on the approved allowlist. For local channel development only. Shows a confirmation dialog at startup.").hideHelp());
|
|
743262
|
+
}
|
|
743263
|
+
program3.addOption(new Option("--agent-id <id>", "Teammate agent ID").hideHelp());
|
|
743264
|
+
program3.addOption(new Option("--agent-name <name>", "Teammate display name").hideHelp());
|
|
743265
|
+
program3.addOption(new Option("--team-name <name>", "Team name for swarm coordination").hideHelp());
|
|
743266
|
+
program3.addOption(new Option("--agent-color <color>", "Teammate UI color").hideHelp());
|
|
743267
|
+
program3.addOption(new Option("--plan-mode-required", "Require plan mode before implementation").hideHelp());
|
|
743268
|
+
program3.addOption(new Option("--parent-session-id <id>", "Parent session ID for analytics correlation").hideHelp());
|
|
743269
|
+
program3.addOption(new Option("--teammate-mode <mode>", 'How to spawn teammates: "tmux", "in-process", or "auto"').choices(["auto", "tmux", "in-process"]).hideHelp());
|
|
743270
|
+
program3.addOption(new Option("--agent-type <type>", "Custom agent type for this teammate").hideHelp());
|
|
743271
|
+
program3.addOption(new Option("--sdk-url <url>", "Use remote WebSocket endpoint for SDK I/O streaming (only with -p and stream-json format)").hideHelp());
|
|
743272
|
+
program3.addOption(new Option("--daemon-worker <kind>", "Run as a B daemon worker of the given kind (internal)").hideHelp());
|
|
743273
|
+
program3.addOption(new Option("--teleport [session]", "Resume a teleport session, optionally specify session ID").hideHelp());
|
|
743274
|
+
program3.addOption(new Option("--remote [description]", "Create a remote session with the given description").hideHelp());
|
|
742101
743275
|
if (feature("BRIDGE_MODE")) {
|
|
742102
|
-
|
|
742103
|
-
|
|
743276
|
+
program3.addOption(new Option("--remote-control [name]", "Start an interactive session with Remote Control enabled (optionally named)").argParser((value) => value || true).hideHelp());
|
|
743277
|
+
program3.addOption(new Option("--rc [name]", "Alias for --remote-control").argParser((value) => value || true).hideHelp());
|
|
742104
743278
|
}
|
|
742105
743279
|
if (feature("HARD_FAIL")) {
|
|
742106
|
-
|
|
743280
|
+
program3.addOption(new Option("--hard-fail", "Crash on logError calls instead of silently logging").hideHelp());
|
|
742107
743281
|
}
|
|
742108
743282
|
profileCheckpoint("run_main_options_built");
|
|
742109
743283
|
const isPrintMode = process.argv.includes("-p") || process.argv.includes("--print");
|
|
742110
743284
|
const isCcUrl = process.argv.some((a5) => a5.startsWith("cc://") || a5.startsWith("cc+unix://"));
|
|
742111
743285
|
if (isPrintMode && !isCcUrl) {
|
|
742112
743286
|
profileCheckpoint("run_before_parse");
|
|
742113
|
-
await
|
|
743287
|
+
await program3.parseAsync(process.argv);
|
|
742114
743288
|
profileCheckpoint("run_after_parse");
|
|
742115
|
-
return
|
|
743289
|
+
return program3;
|
|
742116
743290
|
}
|
|
742117
|
-
const mcp2 =
|
|
743291
|
+
const mcp2 = program3.command("mcp").description("Configure and manage MCP servers").configureHelp(createSortedHelpConfig()).enablePositionalOptions();
|
|
742118
743292
|
mcp2.command("serve").description(`Start the Claude Code MCP server`).option("-d, --debug", "Enable debug mode", () => true).option("--verbose", "Override verbose mode setting from config", () => true).action(async ({
|
|
742119
743293
|
debug: debug5,
|
|
742120
743294
|
verbose
|
|
@@ -742168,7 +743342,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
742168
743342
|
await mcpResetChoicesHandler2();
|
|
742169
743343
|
});
|
|
742170
743344
|
if (feature("DIRECT_CONNECT")) {
|
|
742171
|
-
|
|
743345
|
+
program3.command("server").description("Start a Claude Code session server").option("--port <number>", "HTTP port", "0").option("--host <string>", "Bind address", "0.0.0.0").option("--auth-token <token>", "Bearer token for auth").option("--unix <path>", "Listen on a unix domain socket").option("--workspace <dir>", "Default working directory for sessions that do not specify cwd").option("--idle-timeout <ms>", "Idle timeout for detached sessions in ms (0 = never expire)", "600000").option("--max-sessions <n>", "Maximum concurrent sessions (0 = unlimited)", "32").action(async (opts) => {
|
|
742172
743346
|
const {
|
|
742173
743347
|
randomBytes: randomBytes20
|
|
742174
743348
|
} = await import("crypto");
|
|
@@ -742239,7 +743413,7 @@ Usage: claude --remote "your task description"`, () => gracefulShutdown(1));
|
|
|
742239
743413
|
});
|
|
742240
743414
|
}
|
|
742241
743415
|
if (feature("SSH_REMOTE")) {
|
|
742242
|
-
|
|
743416
|
+
program3.command("ssh <host> [dir]").description("Run Claude Code on a remote host over SSH. Deploys the binary and " + "tunnels API auth back through your local machine \u2014 no remote setup needed.").option("--permission-mode <mode>", "Permission mode for the remote session").option("--dangerously-skip-permissions", "Skip all permission prompts on the remote (dangerous)").option("--local", "e2e test mode \u2014 spawn the child CLI locally (skip ssh/deploy). " + "Exercises the auth proxy and unix-socket plumbing without a remote host.").action(async () => {
|
|
742243
743417
|
process.stderr.write(`Usage: claude ssh <user@host | ssh-config-alias> [dir]
|
|
742244
743418
|
|
|
742245
743419
|
Runs Claude Code on a remote Linux host. You don't need to install
|
|
@@ -742249,7 +743423,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742249
743423
|
});
|
|
742250
743424
|
}
|
|
742251
743425
|
if (feature("DIRECT_CONNECT")) {
|
|
742252
|
-
|
|
743426
|
+
program3.command("open <cc-url>").description("Connect to a Claude Code server (internal \u2014 use cc:// URLs)").option("-p, --print [prompt]", "Print mode (headless)").option("--output-format <format>", "Output format: text, json, stream-json", "text").action(async (ccUrl, opts, _command) => {
|
|
742253
743427
|
const {
|
|
742254
743428
|
parseConnectUrl: parseConnectUrl2
|
|
742255
743429
|
} = await Promise.resolve().then(() => (init_parseConnectUrl(), exports_parseConnectUrl));
|
|
@@ -742283,7 +743457,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742283
743457
|
await runConnectHeadless2(connectConfig, prompt, opts.outputFormat, interactive);
|
|
742284
743458
|
});
|
|
742285
743459
|
}
|
|
742286
|
-
const auth6 =
|
|
743460
|
+
const auth6 = program3.command("auth").description("Manage authentication").configureHelp(createSortedHelpConfig());
|
|
742287
743461
|
auth6.command("login").description("Sign in to your Anthropic account").option("--email <email>", "Pre-populate email address on the login page").option("--sso", "Force SSO login flow").option("--console", "Use Anthropic Console (API usage billing) instead of Claude subscription").option("--claudeai", "Use Claude subscription (default)").action(async ({
|
|
742288
743462
|
email: email3,
|
|
742289
743463
|
sso,
|
|
@@ -742312,8 +743486,76 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742312
743486
|
} = await Promise.resolve().then(() => (init_auth10(), exports_auth2));
|
|
742313
743487
|
await authLogout2();
|
|
742314
743488
|
});
|
|
743489
|
+
const daemonCmd = program3.command("daemon").description("Manage the background-agent daemon (supervisor + workers)").configureHelp(createSortedHelpConfig());
|
|
743490
|
+
daemonCmd.command("start", { isDefault: true }).description("Start the supervisor (default)").allowUnknownOption().action(async () => {
|
|
743491
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743492
|
+
await daemonSubcommand2("start", []);
|
|
743493
|
+
});
|
|
743494
|
+
daemonCmd.command("stop").description("Stop the supervisor").option("--any, -a", "Displace any holder (force)").allowUnknownOption().action(async (opts) => {
|
|
743495
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743496
|
+
const any3 = !!(opts.any || opts.a);
|
|
743497
|
+
await daemonSubcommand2("stop", any3 ? ["--any"] : []);
|
|
743498
|
+
});
|
|
743499
|
+
daemonCmd.command("restart").description("Restart the supervisor").action(async () => {
|
|
743500
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743501
|
+
await daemonSubcommand2("restart", []);
|
|
743502
|
+
});
|
|
743503
|
+
daemonCmd.command("status").description("Show supervisor + worker status").action(async () => {
|
|
743504
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743505
|
+
await daemonSubcommand2("status", []);
|
|
743506
|
+
});
|
|
743507
|
+
daemonCmd.command("logs").description("Tail the daemon log").action(async () => {
|
|
743508
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743509
|
+
await daemonSubcommand2("logs", []);
|
|
743510
|
+
});
|
|
743511
|
+
daemonCmd.command("install").description("Install a persistent service (launchd/systemd)").action(async () => {
|
|
743512
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743513
|
+
await daemonSubcommand2("install", []);
|
|
743514
|
+
});
|
|
743515
|
+
daemonCmd.command("uninstall").description("Remove the persistent service").action(async () => {
|
|
743516
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743517
|
+
await daemonSubcommand2("uninstall", []);
|
|
743518
|
+
});
|
|
743519
|
+
const daemonScheduled = daemonCmd.command("scheduled").description("Manage scheduled daemon tasks").configureHelp(createSortedHelpConfig());
|
|
743520
|
+
daemonScheduled.command("add <task-id>").description("Add a scheduled task").option("--schedule <cron>", "Cron schedule (default: 0 * * * *)").option("--prompt <text>", "Prompt to dispatch when the task fires").action(async (taskId, opts) => {
|
|
743521
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743522
|
+
const args = ["add", taskId];
|
|
743523
|
+
if (opts.schedule)
|
|
743524
|
+
args.push("--schedule", opts.schedule);
|
|
743525
|
+
if (opts.prompt)
|
|
743526
|
+
args.push("--prompt", opts.prompt);
|
|
743527
|
+
await daemonSubcommand2("scheduled", args);
|
|
743528
|
+
});
|
|
743529
|
+
daemonScheduled.command("remove <task-id>").alias("rm").description("Remove a scheduled task").action(async (taskId) => {
|
|
743530
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743531
|
+
await daemonSubcommand2("scheduled", ["remove", taskId]);
|
|
743532
|
+
});
|
|
743533
|
+
daemonScheduled.command("list").description("List scheduled tasks").action(async () => {
|
|
743534
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743535
|
+
await daemonSubcommand2("scheduled", ["list"]);
|
|
743536
|
+
});
|
|
743537
|
+
daemonCmd.command("remote-control").description("Configure the remote-control daemon worker").action(async () => {
|
|
743538
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743539
|
+
await daemonSubcommand2("remote-control", []);
|
|
743540
|
+
});
|
|
743541
|
+
daemonCmd.command("hub").description("Interactive daemon hub (TTY)").action(async () => {
|
|
743542
|
+
const { daemonSubcommand: daemonSubcommand2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743543
|
+
await daemonSubcommand2("hub", []);
|
|
743544
|
+
});
|
|
743545
|
+
program3.command("stop <id>").description("Stop a background session").action(async (id) => {
|
|
743546
|
+
const { stopHandler: stopHandler2 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743547
|
+
await stopHandler2(id);
|
|
743548
|
+
});
|
|
743549
|
+
program3.command("attach <id>").description("Open/join the background session").action(async (id) => {
|
|
743550
|
+
const { attachHandler: attachHandler3 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743551
|
+
await attachHandler3(id);
|
|
743552
|
+
});
|
|
743553
|
+
program3.command("logs <id>").description("Print the background session log").action(async (id) => {
|
|
743554
|
+
const { logsHandler: logsHandler3 } = await Promise.resolve().then(() => (init_daemon(), exports_daemon));
|
|
743555
|
+
await logsHandler3(id);
|
|
743556
|
+
});
|
|
742315
743557
|
const coworkOption = () => new Option("--cowork", "Use cowork_plugins directory").hideHelp();
|
|
742316
|
-
const pluginCmd =
|
|
743558
|
+
const pluginCmd = program3.command("plugin").alias("plugins").description("Manage Claude Code plugins").configureHelp(createSortedHelpConfig());
|
|
742317
743559
|
pluginCmd.command("validate <path>").description("Validate a plugin or marketplace manifest").addOption(coworkOption()).action(async (manifestPath, options) => {
|
|
742318
743560
|
const {
|
|
742319
743561
|
pluginValidateHandler: pluginValidateHandler2
|
|
@@ -742381,7 +743623,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742381
743623
|
} = await Promise.resolve().then(() => (init_plugins(), exports_plugins));
|
|
742382
743624
|
await pluginUpdateHandler2(plugin2, options);
|
|
742383
743625
|
});
|
|
742384
|
-
|
|
743626
|
+
program3.command("setup-token").description("Set up a long-lived authentication token (requires Claude subscription)").action(async () => {
|
|
742385
743627
|
const [{
|
|
742386
743628
|
setupTokenHandler: setupTokenHandler2
|
|
742387
743629
|
}, {
|
|
@@ -742390,14 +743632,14 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742390
743632
|
const root3 = await createRoot3(getBaseRenderOptions(false));
|
|
742391
743633
|
await setupTokenHandler2(root3);
|
|
742392
743634
|
});
|
|
742393
|
-
|
|
743635
|
+
program3.command("agents").description("List configured agents").option("--setting-sources <sources>", "Comma-separated list of setting sources to load (user, project, local).").action(async () => {
|
|
742394
743636
|
const {
|
|
742395
743637
|
agentsHandler: agentsHandler2
|
|
742396
743638
|
} = await Promise.resolve().then(() => (init_agents2(), exports_agents2));
|
|
742397
743639
|
await agentsHandler2();
|
|
742398
743640
|
process.exit(0);
|
|
742399
743641
|
});
|
|
742400
|
-
const projectCmd =
|
|
743642
|
+
const projectCmd = program3.command("project").description("Manage Claude Code project state").configureHelp(createSortedHelpConfig());
|
|
742401
743643
|
projectCmd.command("purge [path]").description("Delete all Claude Code state for a project (transcripts, tasks, file history, config entry)").option("--dry-run", "List what would be deleted without deleting").option("--all", "Purge state for every project (mutually exclusive with [path])").option("-i, --interactive", "Interactively select a project to purge").action(async (path32, options) => {
|
|
742402
743644
|
const {
|
|
742403
743645
|
purgeProjectHandler: purgeProjectHandler2
|
|
@@ -742405,7 +743647,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742405
743647
|
await purgeProjectHandler2(path32, options);
|
|
742406
743648
|
process.exit(0);
|
|
742407
743649
|
});
|
|
742408
|
-
|
|
743650
|
+
program3.command("ultrareview [target]").description("Run a cloud-hosted multi-agent code review of the current branch (or a PR number / base branch) and print the findings").option("--json", "Print the raw bugs.json payload instead of formatted findings").option("--timeout <minutes>", "Maximum minutes to wait for the review to finish (default: 30)").action(async (target, options) => {
|
|
742409
743651
|
const {
|
|
742410
743652
|
ultrareviewHandler: ultrareviewHandler2
|
|
742411
743653
|
} = await Promise.resolve().then(() => (init_ultrareview(), exports_ultrareview));
|
|
@@ -742414,7 +743656,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742414
743656
|
});
|
|
742415
743657
|
if (feature("TRANSCRIPT_CLASSIFIER")) {
|
|
742416
743658
|
if (getAutoModeEnabledStateIfCached() !== "disabled") {
|
|
742417
|
-
const autoModeCmd =
|
|
743659
|
+
const autoModeCmd = program3.command("auto-mode").description("Inspect auto mode classifier configuration");
|
|
742418
743660
|
autoModeCmd.command("defaults").description("Print the default auto mode environment, allow, and deny rules as JSON").action(async () => {
|
|
742419
743661
|
const {
|
|
742420
743662
|
autoModeDefaultsHandler: autoModeDefaultsHandler2
|
|
@@ -742439,7 +743681,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742439
743681
|
}
|
|
742440
743682
|
}
|
|
742441
743683
|
if (feature("BRIDGE_MODE")) {
|
|
742442
|
-
|
|
743684
|
+
program3.command("remote-control", {
|
|
742443
743685
|
hidden: true
|
|
742444
743686
|
}).alias("rc").description("Connect your local environment for remote-control sessions via claude.ai/code").action(async () => {
|
|
742445
743687
|
const {
|
|
@@ -742449,7 +743691,7 @@ Runs Claude Code on a remote Linux host. You don't need to install
|
|
|
742449
743691
|
});
|
|
742450
743692
|
}
|
|
742451
743693
|
if (feature("KAIROS")) {
|
|
742452
|
-
|
|
743694
|
+
program3.command("assistant [sessionId]").description("Attach the REPL as a client to a running bridge session. Discovers sessions via API if no sessionId given.").action(() => {
|
|
742453
743695
|
process.stderr.write(`Usage: claude assistant [sessionId]
|
|
742454
743696
|
|
|
742455
743697
|
Attach the REPL as a viewer client to a running bridge session.
|
|
@@ -742458,7 +743700,7 @@ Omit sessionId to discover and pick from available sessions.
|
|
|
742458
743700
|
process.exit(1);
|
|
742459
743701
|
});
|
|
742460
743702
|
}
|
|
742461
|
-
|
|
743703
|
+
program3.command("doctor").description("Check the health of your Claude Code auto-updater. Note: The workspace trust dialog is skipped and stdio servers from .mcp.json are spawned for health checks. Only use this command in directories you trust.").action(async () => {
|
|
742462
743704
|
const [{
|
|
742463
743705
|
doctorHandler: doctorHandler2
|
|
742464
743706
|
}, {
|
|
@@ -742467,7 +743709,7 @@ Omit sessionId to discover and pick from available sessions.
|
|
|
742467
743709
|
const root3 = await createRoot3(getBaseRenderOptions(false));
|
|
742468
743710
|
await doctorHandler2(root3);
|
|
742469
743711
|
});
|
|
742470
|
-
|
|
743712
|
+
program3.command("update").alias("upgrade").description("Check for updates and install if available").action(async () => {
|
|
742471
743713
|
const {
|
|
742472
743714
|
update: update2
|
|
742473
743715
|
} = await Promise.resolve().then(() => (init_update(), exports_update));
|
|
@@ -742475,7 +743717,7 @@ Omit sessionId to discover and pick from available sessions.
|
|
|
742475
743717
|
});
|
|
742476
743718
|
if (false) {}
|
|
742477
743719
|
if (false) {}
|
|
742478
|
-
|
|
743720
|
+
program3.command("install [target]").description("Install Claude Code native build. Use [target] to specify version (stable, latest, or specific version)").option("--force", "Force installation even if already installed").action(async (target, options) => {
|
|
742479
743721
|
const {
|
|
742480
743722
|
installHandler: installHandler2
|
|
742481
743723
|
} = await Promise.resolve().then(() => (init_util6(), exports_util2));
|
|
@@ -742483,11 +743725,11 @@ Omit sessionId to discover and pick from available sessions.
|
|
|
742483
743725
|
});
|
|
742484
743726
|
if (false) {}
|
|
742485
743727
|
profileCheckpoint("run_before_parse");
|
|
742486
|
-
await
|
|
743728
|
+
await program3.parseAsync(process.argv);
|
|
742487
743729
|
profileCheckpoint("run_after_parse");
|
|
742488
743730
|
profileCheckpoint("main_after_run");
|
|
742489
743731
|
profileReport();
|
|
742490
|
-
return
|
|
743732
|
+
return program3;
|
|
742491
743733
|
}
|
|
742492
743734
|
async function logTenguInit({
|
|
742493
743735
|
hasInitialPrompt,
|