claudish 7.7.0 → 7.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +482 -343
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -581,7 +581,135 @@ var init_onepassword_config = __esm(() => {
|
|
|
581
581
|
});
|
|
582
582
|
|
|
583
583
|
// src/version.ts
|
|
584
|
-
var VERSION = "7.7.
|
|
584
|
+
var VERSION = "7.7.2";
|
|
585
|
+
|
|
586
|
+
// src/providers/onepassword-wasm.ts
|
|
587
|
+
var exports_onepassword_wasm = {};
|
|
588
|
+
__export(exports_onepassword_wasm, {
|
|
589
|
+
verifyIntegrity: () => verifyIntegrity,
|
|
590
|
+
extractFileFromTarGz: () => extractFileFromTarGz,
|
|
591
|
+
ensureOpWasmAvailable: () => ensureOpWasmAvailable,
|
|
592
|
+
__resetOpWasmStateForTest: () => __resetOpWasmStateForTest,
|
|
593
|
+
SDK_CORE_VERSION: () => SDK_CORE_VERSION,
|
|
594
|
+
SDK_CORE_INTEGRITY: () => SDK_CORE_INTEGRITY
|
|
595
|
+
});
|
|
596
|
+
import { createHash } from "crypto";
|
|
597
|
+
import { copyFileSync, existsSync as existsSync2, mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
598
|
+
import { createRequire } from "module";
|
|
599
|
+
import { homedir as homedir2 } from "os";
|
|
600
|
+
import { dirname, join as join2 } from "path";
|
|
601
|
+
import { gunzipSync } from "zlib";
|
|
602
|
+
function tarballUrl() {
|
|
603
|
+
return `https://registry.npmjs.org/@1password/sdk-core/-/sdk-core-${SDK_CORE_VERSION}.tgz`;
|
|
604
|
+
}
|
|
605
|
+
function cacheWasmPath() {
|
|
606
|
+
return join2(homedir2(), ".claudish", "cache", "1password", WASM_FILENAME);
|
|
607
|
+
}
|
|
608
|
+
function verifyIntegrity(bytes) {
|
|
609
|
+
const [algo, expected] = SDK_CORE_INTEGRITY.split("-", 2);
|
|
610
|
+
const actual = createHash(algo).update(bytes).digest("base64");
|
|
611
|
+
if (actual !== expected) {
|
|
612
|
+
throw new Error(`1Password runtime integrity check failed (${algo}): expected ${expected}, got ${actual}`);
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
function extractFileFromTarGz(tgz, entrySuffix) {
|
|
616
|
+
const tar = gunzipSync(tgz);
|
|
617
|
+
let off = 0;
|
|
618
|
+
while (off + 512 <= tar.length) {
|
|
619
|
+
const header = tar.subarray(off, off + 512);
|
|
620
|
+
const name = header.subarray(0, 100).toString("utf8").replace(/\0.*$/, "");
|
|
621
|
+
if (name === "")
|
|
622
|
+
break;
|
|
623
|
+
const sizeStr = header.subarray(124, 136).toString("utf8").replace(/\0.*$/, "").trim();
|
|
624
|
+
const size = Number.parseInt(sizeStr, 8) || 0;
|
|
625
|
+
const dataStart = off + 512;
|
|
626
|
+
if (name.endsWith(entrySuffix)) {
|
|
627
|
+
return tar.subarray(dataStart, dataStart + size);
|
|
628
|
+
}
|
|
629
|
+
off = dataStart + Math.ceil(size / 512) * 512;
|
|
630
|
+
}
|
|
631
|
+
return null;
|
|
632
|
+
}
|
|
633
|
+
function installReadFileSyncIntercept() {
|
|
634
|
+
if (interceptInstalled)
|
|
635
|
+
return;
|
|
636
|
+
const require2 = createRequire(import.meta.url);
|
|
637
|
+
const fs = require2("node:fs");
|
|
638
|
+
const original = fs.readFileSync;
|
|
639
|
+
fs.readFileSync = (path, ...rest) => {
|
|
640
|
+
if (typeof path === "string" && path.endsWith(WASM_FILENAME)) {
|
|
641
|
+
const cached = cacheWasmPath();
|
|
642
|
+
if (existsSync2(cached)) {
|
|
643
|
+
return original(cached);
|
|
644
|
+
}
|
|
645
|
+
if (existsSync2(path)) {
|
|
646
|
+
try {
|
|
647
|
+
mkdirSync(dirname(cached), { recursive: true });
|
|
648
|
+
copyFileSync(path, cached);
|
|
649
|
+
} catch {}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
return original(path, ...rest);
|
|
653
|
+
};
|
|
654
|
+
interceptInstalled = true;
|
|
655
|
+
}
|
|
656
|
+
async function downloadAndCacheWasm() {
|
|
657
|
+
const cached = cacheWasmPath();
|
|
658
|
+
process.stderr.write(`[claudish] fetching 1Password runtime (~10MB, one time)\u2026
|
|
659
|
+
`);
|
|
660
|
+
const res = await fetch(tarballUrl());
|
|
661
|
+
if (!res.ok) {
|
|
662
|
+
throw new Error(`download failed: HTTP ${res.status} ${res.statusText} for ${tarballUrl()}`);
|
|
663
|
+
}
|
|
664
|
+
const tgz = Buffer.from(await res.arrayBuffer());
|
|
665
|
+
verifyIntegrity(tgz);
|
|
666
|
+
const wasm = extractFileFromTarGz(tgz, WASM_TARBALL_ENTRY);
|
|
667
|
+
if (!wasm) {
|
|
668
|
+
throw new Error(`1Password runtime archive did not contain ${WASM_TARBALL_ENTRY}`);
|
|
669
|
+
}
|
|
670
|
+
mkdirSync(dirname(cached), { recursive: true });
|
|
671
|
+
const tmp = `${cached}.tmp`;
|
|
672
|
+
writeFileSync2(tmp, wasm);
|
|
673
|
+
createRequire(import.meta.url)("node:fs").renameSync(tmp, cached);
|
|
674
|
+
process.stderr.write(`[claudish] 1Password runtime cached.
|
|
675
|
+
`);
|
|
676
|
+
}
|
|
677
|
+
function ensureOpWasmAvailable() {
|
|
678
|
+
if (wasmReady)
|
|
679
|
+
return Promise.resolve();
|
|
680
|
+
if (ensured)
|
|
681
|
+
return ensured;
|
|
682
|
+
ensured = (async () => {
|
|
683
|
+
installReadFileSyncIntercept();
|
|
684
|
+
if (existsSync2(cacheWasmPath()))
|
|
685
|
+
return;
|
|
686
|
+
if (findRealWasmNearby())
|
|
687
|
+
return;
|
|
688
|
+
await downloadAndCacheWasm();
|
|
689
|
+
})();
|
|
690
|
+
ensured.then(() => {
|
|
691
|
+
wasmReady = true;
|
|
692
|
+
}, () => {
|
|
693
|
+
ensured = null;
|
|
694
|
+
});
|
|
695
|
+
return ensured;
|
|
696
|
+
}
|
|
697
|
+
function findRealWasmNearby() {
|
|
698
|
+
try {
|
|
699
|
+
const require2 = createRequire(import.meta.url);
|
|
700
|
+
const coreJs = require2.resolve("@1password/sdk-core/nodejs/core.js");
|
|
701
|
+
return existsSync2(join2(dirname(coreJs), WASM_FILENAME));
|
|
702
|
+
} catch {
|
|
703
|
+
return false;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
function __resetOpWasmStateForTest() {
|
|
707
|
+
ensured = null;
|
|
708
|
+
interceptInstalled = false;
|
|
709
|
+
wasmReady = false;
|
|
710
|
+
}
|
|
711
|
+
var SDK_CORE_VERSION = "0.4.1-beta.1", SDK_CORE_INTEGRITY = "sha512-/otbg1JVhsEn6oUIeReoT9TmFr8J7KBwr9UuRVfJFwwGG3bHPF8ewT+LhRimQeJtypqQ69ZVuOYkxknD4iQHxw==", WASM_FILENAME = "core_bg.wasm", WASM_TARBALL_ENTRY = "nodejs/core_bg.wasm", interceptInstalled = false, ensured = null, wasmReady = false;
|
|
712
|
+
var init_onepassword_wasm = () => {};
|
|
585
713
|
|
|
586
714
|
// ../../node_modules/.bun/@1password+sdk-core@0.4.1-beta.1/node_modules/@1password/sdk-core/nodejs/core.js
|
|
587
715
|
var require_core = __commonJS((exports, module) => {
|
|
@@ -3381,6 +3509,8 @@ var OP_REF_RE, ENV_VAR_NAME_RE, sdkClientCache, defaultSdkClientFactory = async
|
|
|
3381
3509
|
if (cached)
|
|
3382
3510
|
return cached;
|
|
3383
3511
|
const build = (async () => {
|
|
3512
|
+
const { ensureOpWasmAvailable: ensureOpWasmAvailable2 } = await Promise.resolve().then(() => (init_onepassword_wasm(), exports_onepassword_wasm));
|
|
3513
|
+
await ensureOpWasmAvailable2();
|
|
3384
3514
|
const { createClient, DesktopAuth } = await Promise.resolve().then(() => __toESM(require_sdk(), 1));
|
|
3385
3515
|
const client = await createClient({
|
|
3386
3516
|
auth: auth.kind === "token" ? auth.token : new DesktopAuth(auth.accountName),
|
|
@@ -25488,14 +25618,14 @@ __export(exports_team_orchestrator, {
|
|
|
25488
25618
|
});
|
|
25489
25619
|
import { spawn } from "child_process";
|
|
25490
25620
|
import {
|
|
25491
|
-
mkdirSync,
|
|
25492
|
-
writeFileSync as
|
|
25621
|
+
mkdirSync as mkdirSync2,
|
|
25622
|
+
writeFileSync as writeFileSync3,
|
|
25493
25623
|
readFileSync as readFileSync2,
|
|
25494
|
-
existsSync as
|
|
25624
|
+
existsSync as existsSync3,
|
|
25495
25625
|
readdirSync,
|
|
25496
25626
|
createWriteStream
|
|
25497
25627
|
} from "fs";
|
|
25498
|
-
import { join as
|
|
25628
|
+
import { join as join3, resolve } from "path";
|
|
25499
25629
|
function validateSessionPath(sessionPath) {
|
|
25500
25630
|
const resolved = resolve(sessionPath);
|
|
25501
25631
|
const cwd = process.cwd();
|
|
@@ -25516,18 +25646,18 @@ function setupSession(sessionPath, models, input) {
|
|
|
25516
25646
|
if (models.length === 0) {
|
|
25517
25647
|
throw new Error("At least one model is required");
|
|
25518
25648
|
}
|
|
25519
|
-
if (
|
|
25649
|
+
if (existsSync3(join3(sessionPath, "manifest.json"))) {
|
|
25520
25650
|
throw new Error(`Session already exists at ${sessionPath}. ` + `Use a new directory path or delete the existing session first.`);
|
|
25521
25651
|
}
|
|
25522
25652
|
const sentinels = models.filter(isSentinelModel);
|
|
25523
25653
|
if (sentinels.length > 0) {
|
|
25524
25654
|
throw new Error(`Invalid model(s) for team run: ${sentinels.join(", ")}. ` + `These are Claude Code agent selectors, not external model IDs. ` + `Use real external models (e.g., "gemini-2.0-flash", "gpt-4o", "or@deepseek/deepseek-r1"). ` + `For Claude models, use a Task agent instead of the team tool.`);
|
|
25525
25655
|
}
|
|
25526
|
-
|
|
25527
|
-
|
|
25656
|
+
mkdirSync2(join3(sessionPath, "work"), { recursive: true });
|
|
25657
|
+
mkdirSync2(join3(sessionPath, "errors"), { recursive: true });
|
|
25528
25658
|
if (input !== undefined) {
|
|
25529
|
-
|
|
25530
|
-
} else if (!
|
|
25659
|
+
writeFileSync3(join3(sessionPath, "input.md"), input, "utf-8");
|
|
25660
|
+
} else if (!existsSync3(join3(sessionPath, "input.md"))) {
|
|
25531
25661
|
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
25532
25662
|
}
|
|
25533
25663
|
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
@@ -25544,9 +25674,9 @@ function setupSession(sessionPath, models, input) {
|
|
|
25544
25674
|
model: models[i],
|
|
25545
25675
|
assignedAt: now
|
|
25546
25676
|
};
|
|
25547
|
-
|
|
25677
|
+
mkdirSync2(join3(sessionPath, "work", anonId), { recursive: true });
|
|
25548
25678
|
}
|
|
25549
|
-
|
|
25679
|
+
writeFileSync3(join3(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
25550
25680
|
const status = {
|
|
25551
25681
|
startedAt: now,
|
|
25552
25682
|
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
@@ -25560,19 +25690,19 @@ function setupSession(sessionPath, models, input) {
|
|
|
25560
25690
|
}
|
|
25561
25691
|
]))
|
|
25562
25692
|
};
|
|
25563
|
-
|
|
25693
|
+
writeFileSync3(join3(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
25564
25694
|
return manifest;
|
|
25565
25695
|
}
|
|
25566
25696
|
async function runModels(sessionPath, opts = {}) {
|
|
25567
25697
|
const timeoutMs = (opts.timeout ?? 300) * 1000;
|
|
25568
|
-
const manifest = JSON.parse(readFileSync2(
|
|
25569
|
-
const statusPath =
|
|
25570
|
-
const inputPath =
|
|
25698
|
+
const manifest = JSON.parse(readFileSync2(join3(sessionPath, "manifest.json"), "utf-8"));
|
|
25699
|
+
const statusPath = join3(sessionPath, "status.json");
|
|
25700
|
+
const inputPath = join3(sessionPath, "input.md");
|
|
25571
25701
|
const inputContent = readFileSync2(inputPath, "utf-8");
|
|
25572
25702
|
const statusCache = JSON.parse(readFileSync2(statusPath, "utf-8"));
|
|
25573
25703
|
function updateModelStatus(id, update) {
|
|
25574
25704
|
statusCache.models[id] = { ...statusCache.models[id], ...update };
|
|
25575
|
-
|
|
25705
|
+
writeFileSync3(statusPath, JSON.stringify(statusCache, null, 2), "utf-8");
|
|
25576
25706
|
}
|
|
25577
25707
|
const processes = new Map;
|
|
25578
25708
|
const sigintHandler = () => {
|
|
@@ -25585,8 +25715,8 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
25585
25715
|
process.on("SIGINT", sigintHandler);
|
|
25586
25716
|
const completionPromises = [];
|
|
25587
25717
|
for (const [anonId, entry] of Object.entries(manifest.models)) {
|
|
25588
|
-
const outputPath =
|
|
25589
|
-
const errorLogPath =
|
|
25718
|
+
const outputPath = join3(sessionPath, `response-${anonId}.md`);
|
|
25719
|
+
const errorLogPath = join3(sessionPath, "errors", `${anonId}.log`);
|
|
25590
25720
|
const args = ["--model", entry.model, "-y", "--stdin", "--quiet", ...opts.claudeFlags ?? []];
|
|
25591
25721
|
updateModelStatus(anonId, {
|
|
25592
25722
|
state: "RUNNING",
|
|
@@ -25639,7 +25769,7 @@ async function runModels(sessionPath, opts = {}) {
|
|
|
25639
25769
|
return;
|
|
25640
25770
|
}
|
|
25641
25771
|
if (stderr) {
|
|
25642
|
-
|
|
25772
|
+
writeFileSync3(errorLogPath, stderr, "utf-8");
|
|
25643
25773
|
}
|
|
25644
25774
|
exitCode = code;
|
|
25645
25775
|
if (outputStream.destroyed) {
|
|
@@ -25684,23 +25814,23 @@ async function judgeResponses(sessionPath, opts = {}) {
|
|
|
25684
25814
|
const responses = {};
|
|
25685
25815
|
for (const file2 of responseFiles) {
|
|
25686
25816
|
const id = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
25687
|
-
responses[id] = readFileSync2(
|
|
25817
|
+
responses[id] = readFileSync2(join3(sessionPath, file2), "utf-8");
|
|
25688
25818
|
}
|
|
25689
|
-
const input = readFileSync2(
|
|
25819
|
+
const input = readFileSync2(join3(sessionPath, "input.md"), "utf-8");
|
|
25690
25820
|
const judgePrompt = buildJudgePrompt(input, responses);
|
|
25691
|
-
|
|
25821
|
+
writeFileSync3(join3(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
25692
25822
|
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
25693
|
-
const judgePath =
|
|
25694
|
-
|
|
25823
|
+
const judgePath = join3(sessionPath, "judging");
|
|
25824
|
+
mkdirSync2(judgePath, { recursive: true });
|
|
25695
25825
|
setupSession(judgePath, judgeModels, judgePrompt);
|
|
25696
25826
|
await runModels(judgePath, { claudeFlags: opts.claudeFlags });
|
|
25697
25827
|
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
25698
25828
|
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
25699
|
-
|
|
25829
|
+
writeFileSync3(join3(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
25700
25830
|
return verdict;
|
|
25701
25831
|
}
|
|
25702
25832
|
function getStatus(sessionPath) {
|
|
25703
|
-
return JSON.parse(readFileSync2(
|
|
25833
|
+
return JSON.parse(readFileSync2(join3(sessionPath, "status.json"), "utf-8"));
|
|
25704
25834
|
}
|
|
25705
25835
|
function fisherYatesShuffle(arr) {
|
|
25706
25836
|
for (let i = arr.length - 1;i > 0; i--) {
|
|
@@ -25710,7 +25840,7 @@ function fisherYatesShuffle(arr) {
|
|
|
25710
25840
|
return arr;
|
|
25711
25841
|
}
|
|
25712
25842
|
function getDefaultJudgeModels(sessionPath) {
|
|
25713
|
-
const manifest = JSON.parse(readFileSync2(
|
|
25843
|
+
const manifest = JSON.parse(readFileSync2(join3(sessionPath, "manifest.json"), "utf-8"));
|
|
25714
25844
|
return Object.values(manifest.models).map((e) => e.model);
|
|
25715
25845
|
}
|
|
25716
25846
|
function buildJudgePrompt(input, responses) {
|
|
@@ -25773,7 +25903,7 @@ function parseJudgeVotes(judgePath, responseIds) {
|
|
|
25773
25903
|
const judgeId = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
25774
25904
|
let content;
|
|
25775
25905
|
try {
|
|
25776
|
-
content = readFileSync2(
|
|
25906
|
+
content = readFileSync2(join3(judgePath, file2), "utf-8");
|
|
25777
25907
|
} catch {
|
|
25778
25908
|
continue;
|
|
25779
25909
|
}
|
|
@@ -25825,7 +25955,7 @@ function aggregateVerdict(votes, responseIds) {
|
|
|
25825
25955
|
function formatVerdict(verdict, sessionPath) {
|
|
25826
25956
|
let manifest = null;
|
|
25827
25957
|
try {
|
|
25828
|
-
manifest = JSON.parse(readFileSync2(
|
|
25958
|
+
manifest = JSON.parse(readFileSync2(join3(sessionPath, "manifest.json"), "utf-8"));
|
|
25829
25959
|
} catch {}
|
|
25830
25960
|
let output = `# Team Verdict
|
|
25831
25961
|
|
|
@@ -26058,9 +26188,9 @@ var init_signal_watcher = __esm(() => {
|
|
|
26058
26188
|
|
|
26059
26189
|
// src/channel/session-manager.ts
|
|
26060
26190
|
import { spawn as spawn2 } from "child_process";
|
|
26061
|
-
import { mkdirSync as
|
|
26062
|
-
import { join as
|
|
26063
|
-
import { homedir as
|
|
26191
|
+
import { mkdirSync as mkdirSync3, writeFileSync as writeFileSync4, createWriteStream as createWriteStream2 } from "fs";
|
|
26192
|
+
import { join as join4 } from "path";
|
|
26193
|
+
import { homedir as homedir3 } from "os";
|
|
26064
26194
|
import { randomUUID } from "crypto";
|
|
26065
26195
|
|
|
26066
26196
|
class SessionManager {
|
|
@@ -26081,10 +26211,10 @@ class SessionManager {
|
|
|
26081
26211
|
const sessionId = randomUUID().slice(0, 8);
|
|
26082
26212
|
const timeout = Math.min(opts.timeoutSeconds ?? DEFAULT_TIMEOUT, MAX_TIMEOUT);
|
|
26083
26213
|
const startedAt = new Date().toISOString();
|
|
26084
|
-
const sessionDir =
|
|
26085
|
-
|
|
26214
|
+
const sessionDir = join4(homedir3(), ".claudish", "sessions", sessionId);
|
|
26215
|
+
mkdirSync3(sessionDir, { recursive: true });
|
|
26086
26216
|
if (opts.prompt) {
|
|
26087
|
-
|
|
26217
|
+
writeFileSync4(join4(sessionDir, "prompt.md"), opts.prompt, "utf-8");
|
|
26088
26218
|
}
|
|
26089
26219
|
const args = ["--model", opts.model, "-y", "--stdin", "--quiet", ...opts.claudishFlags ?? []];
|
|
26090
26220
|
const proc = spawn2("claudish", args, {
|
|
@@ -26111,7 +26241,7 @@ class SessionManager {
|
|
|
26111
26241
|
});
|
|
26112
26242
|
}
|
|
26113
26243
|
});
|
|
26114
|
-
const outputLogStream = createWriteStream2(
|
|
26244
|
+
const outputLogStream = createWriteStream2(join4(sessionDir, "output.log"));
|
|
26115
26245
|
const entry = {
|
|
26116
26246
|
info: {
|
|
26117
26247
|
sessionId,
|
|
@@ -26158,9 +26288,9 @@ class SessionManager {
|
|
|
26158
26288
|
watcher.processExited(code);
|
|
26159
26289
|
outputLogStream.end();
|
|
26160
26290
|
if (entry.stderr) {
|
|
26161
|
-
|
|
26291
|
+
writeFileSync4(join4(sessionDir, "stderr.log"), entry.stderr, "utf-8");
|
|
26162
26292
|
}
|
|
26163
|
-
|
|
26293
|
+
writeFileSync4(join4(sessionDir, "meta.json"), JSON.stringify(entry.info, null, 2), "utf-8");
|
|
26164
26294
|
this.cleanupSigint();
|
|
26165
26295
|
});
|
|
26166
26296
|
proc.on("error", (err) => {
|
|
@@ -28605,9 +28735,9 @@ __export(exports_logger, {
|
|
|
28605
28735
|
getLogFilePath: () => getLogFilePath,
|
|
28606
28736
|
getAlwaysOnLogPath: () => getAlwaysOnLogPath
|
|
28607
28737
|
});
|
|
28608
|
-
import { writeFileSync as
|
|
28609
|
-
import { join as
|
|
28610
|
-
import { homedir as
|
|
28738
|
+
import { writeFileSync as writeFileSync5, appendFile, existsSync as existsSync4, mkdirSync as mkdirSync4, readdirSync as readdirSync2, unlinkSync } from "fs";
|
|
28739
|
+
import { join as join5 } from "path";
|
|
28740
|
+
import { homedir as homedir4 } from "os";
|
|
28611
28741
|
function flushLogBuffer() {
|
|
28612
28742
|
if (!logFilePath || logBuffer.length === 0)
|
|
28613
28743
|
return;
|
|
@@ -28639,11 +28769,11 @@ function scheduleFlush() {
|
|
|
28639
28769
|
flushTimer = null;
|
|
28640
28770
|
}
|
|
28641
28771
|
if (logFilePath && logBuffer.length > 0) {
|
|
28642
|
-
|
|
28772
|
+
writeFileSync5(logFilePath, logBuffer.join(""), { flag: "a" });
|
|
28643
28773
|
logBuffer = [];
|
|
28644
28774
|
}
|
|
28645
28775
|
if (alwaysOnLogPath && alwaysOnBuffer.length > 0) {
|
|
28646
|
-
|
|
28776
|
+
writeFileSync5(alwaysOnLogPath, alwaysOnBuffer.join(""), { flag: "a" });
|
|
28647
28777
|
alwaysOnBuffer = [];
|
|
28648
28778
|
}
|
|
28649
28779
|
});
|
|
@@ -28653,7 +28783,7 @@ function rotateOldLogs(dir, keep) {
|
|
|
28653
28783
|
const files = readdirSync2(dir).filter((f) => f.startsWith("claudish_") && f.endsWith(".log")).sort().reverse();
|
|
28654
28784
|
for (const file2 of files.slice(keep)) {
|
|
28655
28785
|
try {
|
|
28656
|
-
unlinkSync(
|
|
28786
|
+
unlinkSync(join5(dir, file2));
|
|
28657
28787
|
} catch {}
|
|
28658
28788
|
}
|
|
28659
28789
|
} catch {}
|
|
@@ -28704,13 +28834,13 @@ function redactLogLine(message, timestamp) {
|
|
|
28704
28834
|
}
|
|
28705
28835
|
function initLogger(debugMode, level = "info", noLogs = false) {
|
|
28706
28836
|
if (!noLogs) {
|
|
28707
|
-
const logsDir =
|
|
28708
|
-
if (!
|
|
28709
|
-
|
|
28837
|
+
const logsDir = join5(homedir4(), ".claudish", "logs");
|
|
28838
|
+
if (!existsSync4(logsDir)) {
|
|
28839
|
+
mkdirSync4(logsDir, { recursive: true });
|
|
28710
28840
|
}
|
|
28711
28841
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").split("T").join("_").slice(0, -5);
|
|
28712
|
-
alwaysOnLogPath =
|
|
28713
|
-
|
|
28842
|
+
alwaysOnLogPath = join5(logsDir, `claudish_${timestamp}.log`);
|
|
28843
|
+
writeFileSync5(alwaysOnLogPath, `Claudish Session Log - ${new Date().toISOString()}
|
|
28714
28844
|
Mode: structural (content redacted)
|
|
28715
28845
|
${"=".repeat(60)}
|
|
28716
28846
|
|
|
@@ -28720,13 +28850,13 @@ ${"=".repeat(60)}
|
|
|
28720
28850
|
}
|
|
28721
28851
|
if (debugMode) {
|
|
28722
28852
|
logLevel = level;
|
|
28723
|
-
const logsDir =
|
|
28724
|
-
if (!
|
|
28725
|
-
|
|
28853
|
+
const logsDir = join5(process.cwd(), "logs");
|
|
28854
|
+
if (!existsSync4(logsDir)) {
|
|
28855
|
+
mkdirSync4(logsDir, { recursive: true });
|
|
28726
28856
|
}
|
|
28727
28857
|
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").split("T").join("_").slice(0, -5);
|
|
28728
|
-
logFilePath =
|
|
28729
|
-
|
|
28858
|
+
logFilePath = join5(logsDir, `claudish_${timestamp}.log`);
|
|
28859
|
+
writeFileSync5(logFilePath, `Claudish Debug Log - ${new Date().toISOString()}
|
|
28730
28860
|
Log Level: ${level}
|
|
28731
28861
|
${"=".repeat(80)}
|
|
28732
28862
|
|
|
@@ -28937,17 +29067,17 @@ __export(exports_profile_config, {
|
|
|
28937
29067
|
configExistsForScope: () => configExistsForScope,
|
|
28938
29068
|
configExists: () => configExists
|
|
28939
29069
|
});
|
|
28940
|
-
import { existsSync as
|
|
28941
|
-
import { homedir as
|
|
28942
|
-
import { dirname, join as
|
|
29070
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync6 } from "fs";
|
|
29071
|
+
import { homedir as homedir5 } from "os";
|
|
29072
|
+
import { dirname as dirname2, join as join6, parse as parse6 } from "path";
|
|
28943
29073
|
function ensureConfigDir() {
|
|
28944
|
-
if (!
|
|
28945
|
-
|
|
29074
|
+
if (!existsSync5(CONFIG_DIR)) {
|
|
29075
|
+
mkdirSync5(CONFIG_DIR, { recursive: true });
|
|
28946
29076
|
}
|
|
28947
29077
|
}
|
|
28948
29078
|
function loadConfig() {
|
|
28949
29079
|
ensureConfigDir();
|
|
28950
|
-
if (!
|
|
29080
|
+
if (!existsSync5(CONFIG_FILE)) {
|
|
28951
29081
|
return { ...DEFAULT_CONFIG };
|
|
28952
29082
|
}
|
|
28953
29083
|
try {
|
|
@@ -29002,39 +29132,39 @@ function loadConfig() {
|
|
|
29002
29132
|
}
|
|
29003
29133
|
function saveConfig(config2) {
|
|
29004
29134
|
ensureConfigDir();
|
|
29005
|
-
|
|
29135
|
+
writeFileSync6(CONFIG_FILE, JSON.stringify(config2, null, 2), "utf-8");
|
|
29006
29136
|
}
|
|
29007
29137
|
function configExists() {
|
|
29008
|
-
return
|
|
29138
|
+
return existsSync5(CONFIG_FILE);
|
|
29009
29139
|
}
|
|
29010
29140
|
function getConfigPath() {
|
|
29011
29141
|
return CONFIG_FILE;
|
|
29012
29142
|
}
|
|
29013
29143
|
function getLocalConfigPath() {
|
|
29014
|
-
const home =
|
|
29144
|
+
const home = homedir5();
|
|
29015
29145
|
let dir = process.cwd();
|
|
29016
29146
|
const root = parse6(dir).root;
|
|
29017
29147
|
while (dir !== root && dir !== home) {
|
|
29018
|
-
const candidate =
|
|
29019
|
-
if (
|
|
29148
|
+
const candidate = join6(dir, LOCAL_CONFIG_FILENAME);
|
|
29149
|
+
if (existsSync5(candidate))
|
|
29020
29150
|
return candidate;
|
|
29021
|
-
if (
|
|
29151
|
+
if (existsSync5(join6(dir, ".git"))) {
|
|
29022
29152
|
return candidate;
|
|
29023
29153
|
}
|
|
29024
|
-
dir =
|
|
29154
|
+
dir = dirname2(dir);
|
|
29025
29155
|
}
|
|
29026
|
-
return
|
|
29156
|
+
return join6(process.cwd(), LOCAL_CONFIG_FILENAME);
|
|
29027
29157
|
}
|
|
29028
29158
|
function localConfigExists() {
|
|
29029
|
-
return
|
|
29159
|
+
return existsSync5(getLocalConfigPath());
|
|
29030
29160
|
}
|
|
29031
29161
|
function isProjectDirectory() {
|
|
29032
29162
|
const cwd = process.cwd();
|
|
29033
|
-
return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) =>
|
|
29163
|
+
return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) => existsSync5(join6(cwd, f)));
|
|
29034
29164
|
}
|
|
29035
29165
|
function loadLocalConfig() {
|
|
29036
29166
|
const localPath = getLocalConfigPath();
|
|
29037
|
-
if (!
|
|
29167
|
+
if (!existsSync5(localPath)) {
|
|
29038
29168
|
return null;
|
|
29039
29169
|
}
|
|
29040
29170
|
try {
|
|
@@ -29056,7 +29186,7 @@ function saveLocalConfig(config2) {
|
|
|
29056
29186
|
if (toWrite.routing !== undefined && Object.keys(toWrite.routing).length === 0) {
|
|
29057
29187
|
delete toWrite.routing;
|
|
29058
29188
|
}
|
|
29059
|
-
|
|
29189
|
+
writeFileSync6(getLocalConfigPath(), JSON.stringify(toWrite, null, 2), "utf-8");
|
|
29060
29190
|
}
|
|
29061
29191
|
function loadConfigForScope(scope) {
|
|
29062
29192
|
if (scope === "local") {
|
|
@@ -29297,8 +29427,8 @@ function disableLocalProvider(providerName) {
|
|
|
29297
29427
|
}
|
|
29298
29428
|
var CONFIG_DIR, CONFIG_FILE, LOCAL_CONFIG_FILENAME = ".claudish.json", DEFAULT_CONFIG;
|
|
29299
29429
|
var init_profile_config = __esm(() => {
|
|
29300
|
-
CONFIG_DIR =
|
|
29301
|
-
CONFIG_FILE =
|
|
29430
|
+
CONFIG_DIR = join6(homedir5(), ".claudish");
|
|
29431
|
+
CONFIG_FILE = join6(CONFIG_DIR, "config.json");
|
|
29302
29432
|
DEFAULT_CONFIG = {
|
|
29303
29433
|
version: "1.0.0",
|
|
29304
29434
|
defaultProfile: "default",
|
|
@@ -29315,9 +29445,9 @@ var init_profile_config = __esm(() => {
|
|
|
29315
29445
|
});
|
|
29316
29446
|
|
|
29317
29447
|
// src/providers/provider-definitions.ts
|
|
29318
|
-
import { existsSync as
|
|
29319
|
-
import { join as
|
|
29320
|
-
import { homedir as
|
|
29448
|
+
import { existsSync as existsSync6 } from "fs";
|
|
29449
|
+
import { join as join7 } from "path";
|
|
29450
|
+
import { homedir as homedir6 } from "os";
|
|
29321
29451
|
function ensureProviderByNameCache() {
|
|
29322
29452
|
if (!_providerByNameCache) {
|
|
29323
29453
|
_providerByNameCache = new Map;
|
|
@@ -29472,7 +29602,7 @@ function isProviderAvailable(def) {
|
|
|
29472
29602
|
}
|
|
29473
29603
|
if (def.oauthFallback) {
|
|
29474
29604
|
try {
|
|
29475
|
-
if (
|
|
29605
|
+
if (existsSync6(join7(homedir6(), ".claudish", def.oauthFallback)))
|
|
29476
29606
|
return true;
|
|
29477
29607
|
} catch {}
|
|
29478
29608
|
}
|
|
@@ -30100,11 +30230,11 @@ var init_model_parser = __esm(() => {
|
|
|
30100
30230
|
});
|
|
30101
30231
|
|
|
30102
30232
|
// src/providers/all-models-cache.ts
|
|
30103
|
-
import { readFileSync as readFileSync4, existsSync as
|
|
30104
|
-
import { join as
|
|
30105
|
-
import { homedir as
|
|
30233
|
+
import { readFileSync as readFileSync4, existsSync as existsSync7, writeFileSync as writeFileSync7, mkdirSync as mkdirSync6 } from "fs";
|
|
30234
|
+
import { join as join8, dirname as dirname3 } from "path";
|
|
30235
|
+
import { homedir as homedir7 } from "os";
|
|
30106
30236
|
function readAllModelsCache(path = ALL_MODELS_CACHE_PATH) {
|
|
30107
|
-
if (!
|
|
30237
|
+
if (!existsSync7(path))
|
|
30108
30238
|
return null;
|
|
30109
30239
|
let raw2;
|
|
30110
30240
|
try {
|
|
@@ -30133,12 +30263,12 @@ function writeAllModelsCache(data, path = ALL_MODELS_CACHE_PATH) {
|
|
|
30133
30263
|
entries: data.entries ?? existing?.entries ?? [],
|
|
30134
30264
|
models: data.models ?? existing?.models ?? []
|
|
30135
30265
|
};
|
|
30136
|
-
|
|
30137
|
-
|
|
30266
|
+
mkdirSync6(dirname3(path), { recursive: true });
|
|
30267
|
+
writeFileSync7(path, JSON.stringify(merged), "utf-8");
|
|
30138
30268
|
}
|
|
30139
30269
|
var ALL_MODELS_CACHE_PATH;
|
|
30140
30270
|
var init_all_models_cache = __esm(() => {
|
|
30141
|
-
ALL_MODELS_CACHE_PATH =
|
|
30271
|
+
ALL_MODELS_CACHE_PATH = join8(homedir7(), ".claudish", "all-models.json");
|
|
30142
30272
|
});
|
|
30143
30273
|
|
|
30144
30274
|
// src/providers/catalog-resolvers/openrouter.ts
|
|
@@ -35013,9 +35143,9 @@ var init_middleware = __esm(() => {
|
|
|
35013
35143
|
});
|
|
35014
35144
|
|
|
35015
35145
|
// src/handlers/shared/token-tracker.ts
|
|
35016
|
-
import { mkdirSync as
|
|
35017
|
-
import { homedir as
|
|
35018
|
-
import { join as
|
|
35146
|
+
import { mkdirSync as mkdirSync7, writeFileSync as writeFileSync8 } from "fs";
|
|
35147
|
+
import { homedir as homedir8 } from "os";
|
|
35148
|
+
import { join as join9 } from "path";
|
|
35019
35149
|
|
|
35020
35150
|
class TokenTracker {
|
|
35021
35151
|
port;
|
|
@@ -35149,9 +35279,9 @@ class TokenTracker {
|
|
|
35149
35279
|
if (this.quotaRemaining !== undefined) {
|
|
35150
35280
|
data.quota_remaining = this.quotaRemaining;
|
|
35151
35281
|
}
|
|
35152
|
-
const claudishDir =
|
|
35153
|
-
|
|
35154
|
-
|
|
35282
|
+
const claudishDir = join9(homedir8(), ".claudish");
|
|
35283
|
+
mkdirSync7(claudishDir, { recursive: true });
|
|
35284
|
+
writeFileSync8(join9(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
35155
35285
|
} catch (e) {
|
|
35156
35286
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
35157
35287
|
}
|
|
@@ -36620,23 +36750,23 @@ var init_telemetry = __esm(() => {
|
|
|
36620
36750
|
|
|
36621
36751
|
// src/stats-buffer.ts
|
|
36622
36752
|
import {
|
|
36623
|
-
existsSync as
|
|
36624
|
-
mkdirSync as
|
|
36753
|
+
existsSync as existsSync8,
|
|
36754
|
+
mkdirSync as mkdirSync8,
|
|
36625
36755
|
readFileSync as readFileSync5,
|
|
36626
36756
|
renameSync,
|
|
36627
36757
|
unlinkSync as unlinkSync2,
|
|
36628
|
-
writeFileSync as
|
|
36758
|
+
writeFileSync as writeFileSync9
|
|
36629
36759
|
} from "fs";
|
|
36630
|
-
import { homedir as
|
|
36631
|
-
import { join as
|
|
36760
|
+
import { homedir as homedir9 } from "os";
|
|
36761
|
+
import { join as join10 } from "path";
|
|
36632
36762
|
function ensureDir() {
|
|
36633
|
-
if (!
|
|
36634
|
-
|
|
36763
|
+
if (!existsSync8(CLAUDISH_DIR)) {
|
|
36764
|
+
mkdirSync8(CLAUDISH_DIR, { recursive: true });
|
|
36635
36765
|
}
|
|
36636
36766
|
}
|
|
36637
36767
|
function readFromDisk() {
|
|
36638
36768
|
try {
|
|
36639
|
-
if (!
|
|
36769
|
+
if (!existsSync8(BUFFER_FILE))
|
|
36640
36770
|
return [];
|
|
36641
36771
|
const raw2 = readFileSync5(BUFFER_FILE, "utf-8");
|
|
36642
36772
|
const parsed = JSON.parse(raw2);
|
|
@@ -36662,8 +36792,8 @@ function writeToDisk(events) {
|
|
|
36662
36792
|
ensureDir();
|
|
36663
36793
|
const trimmed = enforceSizeCap([...events]);
|
|
36664
36794
|
const payload = { version: 1, events: trimmed };
|
|
36665
|
-
const tmpFile =
|
|
36666
|
-
|
|
36795
|
+
const tmpFile = join10(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
36796
|
+
writeFileSync9(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
36667
36797
|
renameSync(tmpFile, BUFFER_FILE);
|
|
36668
36798
|
memoryCache = trimmed;
|
|
36669
36799
|
} catch {}
|
|
@@ -36707,7 +36837,7 @@ function clearBuffer() {
|
|
|
36707
36837
|
try {
|
|
36708
36838
|
memoryCache = [];
|
|
36709
36839
|
eventsSinceLastFlush = 0;
|
|
36710
|
-
if (
|
|
36840
|
+
if (existsSync8(BUFFER_FILE)) {
|
|
36711
36841
|
unlinkSync2(BUFFER_FILE);
|
|
36712
36842
|
}
|
|
36713
36843
|
} catch {}
|
|
@@ -36736,8 +36866,8 @@ function syncFlushOnExit() {
|
|
|
36736
36866
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, lastFlushTime, flushScheduled = false;
|
|
36737
36867
|
var init_stats_buffer = __esm(() => {
|
|
36738
36868
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
36739
|
-
CLAUDISH_DIR =
|
|
36740
|
-
BUFFER_FILE =
|
|
36869
|
+
CLAUDISH_DIR = join10(homedir9(), ".claudish");
|
|
36870
|
+
BUFFER_FILE = join10(CLAUDISH_DIR, "stats-buffer.json");
|
|
36741
36871
|
lastFlushTime = Date.now();
|
|
36742
36872
|
process.on("exit", syncFlushOnExit);
|
|
36743
36873
|
process.on("SIGTERM", () => {
|
|
@@ -38014,9 +38144,9 @@ __export(exports_provider_resolver, {
|
|
|
38014
38144
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
38015
38145
|
getMissingKeyError: () => getMissingKeyError
|
|
38016
38146
|
});
|
|
38017
|
-
import { existsSync as
|
|
38018
|
-
import { homedir as
|
|
38019
|
-
import { join as
|
|
38147
|
+
import { existsSync as existsSync9 } from "fs";
|
|
38148
|
+
import { homedir as homedir10 } from "os";
|
|
38149
|
+
import { join as join11 } from "path";
|
|
38020
38150
|
function getApiKeyInfoForProvider(providerName) {
|
|
38021
38151
|
const lookupName = providerName === "gemini" ? "google" : providerName;
|
|
38022
38152
|
const info = getApiKeyInfo(lookupName);
|
|
@@ -38051,8 +38181,8 @@ function isApiKeyAvailable(info) {
|
|
|
38051
38181
|
}
|
|
38052
38182
|
if (info.oauthFallback) {
|
|
38053
38183
|
try {
|
|
38054
|
-
const credPath =
|
|
38055
|
-
if (
|
|
38184
|
+
const credPath = join11(homedir10(), ".claudish", info.oauthFallback);
|
|
38185
|
+
if (existsSync9(credPath)) {
|
|
38056
38186
|
return true;
|
|
38057
38187
|
}
|
|
38058
38188
|
} catch {}
|
|
@@ -38315,9 +38445,9 @@ var init_provider_resolver = __esm(() => {
|
|
|
38315
38445
|
});
|
|
38316
38446
|
|
|
38317
38447
|
// src/services/pricing-cache.ts
|
|
38318
|
-
import { readFileSync as readFileSync6, existsSync as
|
|
38319
|
-
import { homedir as
|
|
38320
|
-
import { join as
|
|
38448
|
+
import { readFileSync as readFileSync6, existsSync as existsSync10, statSync as statSync2 } from "fs";
|
|
38449
|
+
import { homedir as homedir11 } from "os";
|
|
38450
|
+
import { join as join12 } from "path";
|
|
38321
38451
|
function prefixMatch(modelName) {
|
|
38322
38452
|
for (const [key, pricing] of pricingMap) {
|
|
38323
38453
|
if (modelName.startsWith(key))
|
|
@@ -38355,7 +38485,7 @@ async function warmPricingCache() {
|
|
|
38355
38485
|
}
|
|
38356
38486
|
function loadDiskCache() {
|
|
38357
38487
|
try {
|
|
38358
|
-
if (!
|
|
38488
|
+
if (!existsSync10(CACHE_FILE))
|
|
38359
38489
|
return false;
|
|
38360
38490
|
const stat = statSync2(CACHE_FILE);
|
|
38361
38491
|
const age = Date.now() - stat.mtimeMs;
|
|
@@ -38376,8 +38506,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
38376
38506
|
init_remote_provider_types();
|
|
38377
38507
|
init_catalog_query();
|
|
38378
38508
|
pricingMap = new Map;
|
|
38379
|
-
CACHE_DIR =
|
|
38380
|
-
CACHE_FILE =
|
|
38509
|
+
CACHE_DIR = join12(homedir11(), ".claudish");
|
|
38510
|
+
CACHE_FILE = join12(CACHE_DIR, "pricing-cache.json");
|
|
38381
38511
|
CACHE_TTL_MS2 = 24 * 60 * 60 * 1000;
|
|
38382
38512
|
});
|
|
38383
38513
|
|
|
@@ -38388,9 +38518,9 @@ var init_cache_ttl = __esm(() => {
|
|
|
38388
38518
|
});
|
|
38389
38519
|
|
|
38390
38520
|
// src/model-loader.ts
|
|
38391
|
-
import { readFileSync as readFileSync7, existsSync as
|
|
38392
|
-
import { join as
|
|
38393
|
-
import { homedir as
|
|
38521
|
+
import { readFileSync as readFileSync7, existsSync as existsSync11, writeFileSync as writeFileSync10, mkdirSync as mkdirSync9 } from "fs";
|
|
38522
|
+
import { join as join13 } from "path";
|
|
38523
|
+
import { homedir as homedir12 } from "os";
|
|
38394
38524
|
function groupRecommendedModels(entries) {
|
|
38395
38525
|
const byId = new Map;
|
|
38396
38526
|
for (const entry of entries) {
|
|
@@ -38486,7 +38616,7 @@ async function getRecommendedModels(opts = {}) {
|
|
|
38486
38616
|
if (!forceRefresh && _cachedRecommendedModels) {
|
|
38487
38617
|
return _cachedRecommendedModels;
|
|
38488
38618
|
}
|
|
38489
|
-
if (!forceRefresh &&
|
|
38619
|
+
if (!forceRefresh && existsSync11(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
38490
38620
|
try {
|
|
38491
38621
|
const cacheData = JSON.parse(readFileSync7(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
38492
38622
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
@@ -38504,9 +38634,9 @@ async function getRecommendedModels(opts = {}) {
|
|
|
38504
38634
|
if (data.models && data.models.length > 0) {
|
|
38505
38635
|
_cachedRecommendedModels = data;
|
|
38506
38636
|
try {
|
|
38507
|
-
const cacheDir =
|
|
38508
|
-
|
|
38509
|
-
|
|
38637
|
+
const cacheDir = join13(homedir12(), ".claudish");
|
|
38638
|
+
mkdirSync9(cacheDir, { recursive: true });
|
|
38639
|
+
writeFileSync10(RECOMMENDED_MODELS_CACHE_PATH, JSON.stringify(data), "utf-8");
|
|
38510
38640
|
} catch {}
|
|
38511
38641
|
return data;
|
|
38512
38642
|
}
|
|
@@ -38517,7 +38647,7 @@ async function getRecommendedModels(opts = {}) {
|
|
|
38517
38647
|
function getRecommendedModelsSync() {
|
|
38518
38648
|
if (_cachedRecommendedModels)
|
|
38519
38649
|
return _cachedRecommendedModels;
|
|
38520
|
-
if (
|
|
38650
|
+
if (existsSync11(RECOMMENDED_MODELS_CACHE_PATH)) {
|
|
38521
38651
|
try {
|
|
38522
38652
|
const cacheData = JSON.parse(readFileSync7(RECOMMENDED_MODELS_CACHE_PATH, "utf-8"));
|
|
38523
38653
|
if (cacheData.models && cacheData.models.length > 0 && isFreshEnough(cacheData)) {
|
|
@@ -38643,7 +38773,7 @@ var _cachedModelInfo = null, _cachedModelIds = null, _cachedRecommendedModels =
|
|
|
38643
38773
|
var init_model_loader = __esm(() => {
|
|
38644
38774
|
init_cache_ttl();
|
|
38645
38775
|
FIREBASE_RECOMMENDED_URL = `${FIREBASE_BASE_URL}?catalog=recommended`;
|
|
38646
|
-
RECOMMENDED_MODELS_CACHE_PATH =
|
|
38776
|
+
RECOMMENDED_MODELS_CACHE_PATH = join13(homedir12(), ".claudish", "recommended-models-cache.json");
|
|
38647
38777
|
FIREBASE_SLUG_TO_PROVIDER_NAME = {
|
|
38648
38778
|
openai: "openai",
|
|
38649
38779
|
google: "google",
|
|
@@ -38780,12 +38910,12 @@ var init_fallback_handler = __esm(() => {
|
|
|
38780
38910
|
});
|
|
38781
38911
|
|
|
38782
38912
|
// src/auth/oauth-registry.ts
|
|
38783
|
-
import { existsSync as
|
|
38784
|
-
import { join as
|
|
38785
|
-
import { homedir as
|
|
38913
|
+
import { existsSync as existsSync12, readFileSync as readFileSync8 } from "fs";
|
|
38914
|
+
import { join as join14 } from "path";
|
|
38915
|
+
import { homedir as homedir13 } from "os";
|
|
38786
38916
|
function hasValidOAuthCredentials(descriptor) {
|
|
38787
|
-
const credPath =
|
|
38788
|
-
if (!
|
|
38917
|
+
const credPath = join14(homedir13(), ".claudish", descriptor.credentialFile);
|
|
38918
|
+
if (!existsSync12(credPath))
|
|
38789
38919
|
return false;
|
|
38790
38920
|
if (descriptor.validationMode === "file-exists") {
|
|
38791
38921
|
return true;
|
|
@@ -39263,10 +39393,10 @@ var init_gemini_apikey = __esm(() => {
|
|
|
39263
39393
|
|
|
39264
39394
|
// src/auth/gemini-oauth.ts
|
|
39265
39395
|
import { createServer } from "http";
|
|
39266
|
-
import { randomBytes as randomBytes2, createHash } from "crypto";
|
|
39267
|
-
import { readFileSync as readFileSync9, existsSync as
|
|
39268
|
-
import { homedir as
|
|
39269
|
-
import { join as
|
|
39396
|
+
import { randomBytes as randomBytes2, createHash as createHash2 } from "crypto";
|
|
39397
|
+
import { readFileSync as readFileSync9, existsSync as existsSync13, unlinkSync as unlinkSync3, openSync, writeSync, closeSync } from "fs";
|
|
39398
|
+
import { homedir as homedir14 } from "os";
|
|
39399
|
+
import { join as join15 } from "path";
|
|
39270
39400
|
import { exec } from "child_process";
|
|
39271
39401
|
import { promisify } from "util";
|
|
39272
39402
|
|
|
@@ -39289,8 +39419,8 @@ class GeminiOAuth {
|
|
|
39289
39419
|
return this.credentials !== null && !!this.credentials.refresh_token;
|
|
39290
39420
|
}
|
|
39291
39421
|
getCredentialsPath() {
|
|
39292
|
-
const claudishDir =
|
|
39293
|
-
return
|
|
39422
|
+
const claudishDir = join15(homedir14(), ".claudish");
|
|
39423
|
+
return join15(claudishDir, "gemini-oauth.json");
|
|
39294
39424
|
}
|
|
39295
39425
|
async login() {
|
|
39296
39426
|
log("[GeminiOAuth] Starting OAuth login flow");
|
|
@@ -39311,7 +39441,7 @@ class GeminiOAuth {
|
|
|
39311
39441
|
}
|
|
39312
39442
|
async logout() {
|
|
39313
39443
|
const credPath = this.getCredentialsPath();
|
|
39314
|
-
if (
|
|
39444
|
+
if (existsSync13(credPath)) {
|
|
39315
39445
|
unlinkSync3(credPath);
|
|
39316
39446
|
log("[GeminiOAuth] Credentials deleted");
|
|
39317
39447
|
}
|
|
@@ -39388,7 +39518,7 @@ Details: ${e.message}`);
|
|
|
39388
39518
|
}
|
|
39389
39519
|
loadCredentials() {
|
|
39390
39520
|
const credPath = this.getCredentialsPath();
|
|
39391
|
-
if (!
|
|
39521
|
+
if (!existsSync13(credPath)) {
|
|
39392
39522
|
return null;
|
|
39393
39523
|
}
|
|
39394
39524
|
try {
|
|
@@ -39407,10 +39537,10 @@ Details: ${e.message}`);
|
|
|
39407
39537
|
}
|
|
39408
39538
|
saveCredentials(credentials) {
|
|
39409
39539
|
const credPath = this.getCredentialsPath();
|
|
39410
|
-
const claudishDir =
|
|
39411
|
-
if (!
|
|
39412
|
-
const { mkdirSync:
|
|
39413
|
-
|
|
39540
|
+
const claudishDir = join15(homedir14(), ".claudish");
|
|
39541
|
+
if (!existsSync13(claudishDir)) {
|
|
39542
|
+
const { mkdirSync: mkdirSync10 } = __require("fs");
|
|
39543
|
+
mkdirSync10(claudishDir, { recursive: true });
|
|
39414
39544
|
}
|
|
39415
39545
|
const fd = openSync(credPath, "w", 384);
|
|
39416
39546
|
try {
|
|
@@ -39425,7 +39555,7 @@ Details: ${e.message}`);
|
|
|
39425
39555
|
return randomBytes2(64).toString("base64url");
|
|
39426
39556
|
}
|
|
39427
39557
|
async generateCodeChallenge(verifier) {
|
|
39428
|
-
const hash2 =
|
|
39558
|
+
const hash2 = createHash2("sha256").update(verifier).digest("base64url");
|
|
39429
39559
|
return hash2;
|
|
39430
39560
|
}
|
|
39431
39561
|
buildAuthUrl(codeChallenge, state, redirectUri) {
|
|
@@ -40115,11 +40245,11 @@ var init_openai = __esm(() => {
|
|
|
40115
40245
|
|
|
40116
40246
|
// src/auth/codex-oauth.ts
|
|
40117
40247
|
import { exec as exec2 } from "child_process";
|
|
40118
|
-
import { createHash as
|
|
40119
|
-
import { closeSync as closeSync2, existsSync as
|
|
40248
|
+
import { createHash as createHash3, randomBytes as randomBytes3 } from "crypto";
|
|
40249
|
+
import { closeSync as closeSync2, existsSync as existsSync14, openSync as openSync2, readFileSync as readFileSync10, unlinkSync as unlinkSync4, writeSync as writeSync2 } from "fs";
|
|
40120
40250
|
import { createServer as createServer2 } from "http";
|
|
40121
|
-
import { homedir as
|
|
40122
|
-
import { join as
|
|
40251
|
+
import { homedir as homedir15 } from "os";
|
|
40252
|
+
import { join as join16 } from "path";
|
|
40123
40253
|
import { promisify as promisify2 } from "util";
|
|
40124
40254
|
|
|
40125
40255
|
class CodexOAuth {
|
|
@@ -40141,8 +40271,8 @@ class CodexOAuth {
|
|
|
40141
40271
|
return this.credentials !== null && !!this.credentials.refresh_token;
|
|
40142
40272
|
}
|
|
40143
40273
|
getCredentialsPath() {
|
|
40144
|
-
const claudishDir =
|
|
40145
|
-
return
|
|
40274
|
+
const claudishDir = join16(homedir15(), ".claudish");
|
|
40275
|
+
return join16(claudishDir, "codex-oauth.json");
|
|
40146
40276
|
}
|
|
40147
40277
|
async login() {
|
|
40148
40278
|
log("[CodexOAuth] Starting OAuth login flow");
|
|
@@ -40168,7 +40298,7 @@ class CodexOAuth {
|
|
|
40168
40298
|
}
|
|
40169
40299
|
async logout() {
|
|
40170
40300
|
const credPath = this.getCredentialsPath();
|
|
40171
|
-
if (
|
|
40301
|
+
if (existsSync14(credPath)) {
|
|
40172
40302
|
unlinkSync4(credPath);
|
|
40173
40303
|
log("[CodexOAuth] Credentials deleted");
|
|
40174
40304
|
}
|
|
@@ -40246,7 +40376,7 @@ Details: ${e.message}`);
|
|
|
40246
40376
|
}
|
|
40247
40377
|
loadCredentials() {
|
|
40248
40378
|
const credPath = this.getCredentialsPath();
|
|
40249
|
-
if (!
|
|
40379
|
+
if (!existsSync14(credPath)) {
|
|
40250
40380
|
return null;
|
|
40251
40381
|
}
|
|
40252
40382
|
try {
|
|
@@ -40265,10 +40395,10 @@ Details: ${e.message}`);
|
|
|
40265
40395
|
}
|
|
40266
40396
|
saveCredentials(credentials) {
|
|
40267
40397
|
const credPath = this.getCredentialsPath();
|
|
40268
|
-
const claudishDir =
|
|
40269
|
-
if (!
|
|
40270
|
-
const { mkdirSync:
|
|
40271
|
-
|
|
40398
|
+
const claudishDir = join16(homedir15(), ".claudish");
|
|
40399
|
+
if (!existsSync14(claudishDir)) {
|
|
40400
|
+
const { mkdirSync: mkdirSync10 } = __require("fs");
|
|
40401
|
+
mkdirSync10(claudishDir, { recursive: true });
|
|
40272
40402
|
}
|
|
40273
40403
|
const fd = openSync2(credPath, "w", 384);
|
|
40274
40404
|
try {
|
|
@@ -40283,7 +40413,7 @@ Details: ${e.message}`);
|
|
|
40283
40413
|
return randomBytes3(64).toString("base64url");
|
|
40284
40414
|
}
|
|
40285
40415
|
async generateCodeChallenge(verifier) {
|
|
40286
|
-
const hash2 =
|
|
40416
|
+
const hash2 = createHash3("sha256").update(verifier).digest("base64url");
|
|
40287
40417
|
return hash2;
|
|
40288
40418
|
}
|
|
40289
40419
|
extractAccountId(idToken) {
|
|
@@ -40481,9 +40611,9 @@ var init_codex_oauth = __esm(() => {
|
|
|
40481
40611
|
});
|
|
40482
40612
|
|
|
40483
40613
|
// src/providers/transport/openai-codex.ts
|
|
40484
|
-
import { existsSync as
|
|
40485
|
-
import { homedir as
|
|
40486
|
-
import { join as
|
|
40614
|
+
import { existsSync as existsSync15, readFileSync as readFileSync11 } from "fs";
|
|
40615
|
+
import { homedir as homedir16 } from "os";
|
|
40616
|
+
import { join as join17 } from "path";
|
|
40487
40617
|
function buildOAuthHeaders(token, accountId) {
|
|
40488
40618
|
const headers = {
|
|
40489
40619
|
Authorization: `Bearer ${token}`,
|
|
@@ -40512,8 +40642,8 @@ var init_openai_codex = __esm(() => {
|
|
|
40512
40642
|
return super.getHeaders();
|
|
40513
40643
|
}
|
|
40514
40644
|
getEndpoint() {
|
|
40515
|
-
const credPath =
|
|
40516
|
-
if (
|
|
40645
|
+
const credPath = join17(homedir16(), ".claudish", "codex-oauth.json");
|
|
40646
|
+
if (existsSync15(credPath)) {
|
|
40517
40647
|
try {
|
|
40518
40648
|
const creds = JSON.parse(readFileSync11(credPath, "utf-8"));
|
|
40519
40649
|
if (creds.access_token && creds.refresh_token) {
|
|
@@ -40524,8 +40654,8 @@ var init_openai_codex = __esm(() => {
|
|
|
40524
40654
|
return `${this.provider.baseUrl}${this.provider.apiPath}`;
|
|
40525
40655
|
}
|
|
40526
40656
|
async tryOAuthHeaders() {
|
|
40527
|
-
const credPath =
|
|
40528
|
-
if (!
|
|
40657
|
+
const credPath = join17(homedir16(), ".claudish", "codex-oauth.json");
|
|
40658
|
+
if (!existsSync15(credPath))
|
|
40529
40659
|
return null;
|
|
40530
40660
|
try {
|
|
40531
40661
|
const creds = JSON.parse(readFileSync11(credPath, "utf-8"));
|
|
@@ -40565,9 +40695,9 @@ var init_openai_codex = __esm(() => {
|
|
|
40565
40695
|
|
|
40566
40696
|
// src/auth/kimi-oauth.ts
|
|
40567
40697
|
import { randomBytes as randomBytes4 } from "crypto";
|
|
40568
|
-
import { readFileSync as readFileSync12, existsSync as
|
|
40569
|
-
import { homedir as
|
|
40570
|
-
import { join as
|
|
40698
|
+
import { readFileSync as readFileSync12, existsSync as existsSync16, unlinkSync as unlinkSync5, openSync as openSync3, writeSync as writeSync3, closeSync as closeSync3 } from "fs";
|
|
40699
|
+
import { homedir as homedir17, hostname as hostname3, platform, release } from "os";
|
|
40700
|
+
import { join as join18 } from "path";
|
|
40571
40701
|
import { exec as exec3 } from "child_process";
|
|
40572
40702
|
import { promisify as promisify3 } from "util";
|
|
40573
40703
|
|
|
@@ -40592,21 +40722,21 @@ class KimiOAuth {
|
|
|
40592
40722
|
return this.credentials !== null && !!this.credentials.refresh_token;
|
|
40593
40723
|
}
|
|
40594
40724
|
getCredentialsPath() {
|
|
40595
|
-
const claudishDir =
|
|
40596
|
-
return
|
|
40725
|
+
const claudishDir = join18(homedir17(), ".claudish");
|
|
40726
|
+
return join18(claudishDir, "kimi-oauth.json");
|
|
40597
40727
|
}
|
|
40598
40728
|
getDeviceIdPath() {
|
|
40599
|
-
const claudishDir =
|
|
40600
|
-
return
|
|
40729
|
+
const claudishDir = join18(homedir17(), ".claudish");
|
|
40730
|
+
return join18(claudishDir, "kimi-device-id");
|
|
40601
40731
|
}
|
|
40602
40732
|
loadOrCreateDeviceId() {
|
|
40603
40733
|
const deviceIdPath = this.getDeviceIdPath();
|
|
40604
|
-
const claudishDir =
|
|
40605
|
-
if (!
|
|
40606
|
-
const { mkdirSync:
|
|
40607
|
-
|
|
40734
|
+
const claudishDir = join18(homedir17(), ".claudish");
|
|
40735
|
+
if (!existsSync16(claudishDir)) {
|
|
40736
|
+
const { mkdirSync: mkdirSync10 } = __require("fs");
|
|
40737
|
+
mkdirSync10(claudishDir, { recursive: true });
|
|
40608
40738
|
}
|
|
40609
|
-
if (
|
|
40739
|
+
if (existsSync16(deviceIdPath)) {
|
|
40610
40740
|
try {
|
|
40611
40741
|
const deviceId2 = readFileSync12(deviceIdPath, "utf-8").trim();
|
|
40612
40742
|
if (deviceId2) {
|
|
@@ -40777,7 +40907,7 @@ Waiting for authorization...`);
|
|
|
40777
40907
|
}
|
|
40778
40908
|
async logout() {
|
|
40779
40909
|
const credPath = this.getCredentialsPath();
|
|
40780
|
-
if (
|
|
40910
|
+
if (existsSync16(credPath)) {
|
|
40781
40911
|
unlinkSync5(credPath);
|
|
40782
40912
|
log("[KimiOAuth] Credentials deleted");
|
|
40783
40913
|
}
|
|
@@ -40844,7 +40974,7 @@ Waiting for authorization...`);
|
|
|
40844
40974
|
} catch (e) {
|
|
40845
40975
|
log(`[KimiOAuth] Refresh failed: ${e.message}`);
|
|
40846
40976
|
const credPath = this.getCredentialsPath();
|
|
40847
|
-
if (
|
|
40977
|
+
if (existsSync16(credPath)) {
|
|
40848
40978
|
unlinkSync5(credPath);
|
|
40849
40979
|
}
|
|
40850
40980
|
this.credentials = null;
|
|
@@ -40861,7 +40991,7 @@ Waiting for authorization...`);
|
|
|
40861
40991
|
}
|
|
40862
40992
|
loadCredentials() {
|
|
40863
40993
|
const credPath = this.getCredentialsPath();
|
|
40864
|
-
if (!
|
|
40994
|
+
if (!existsSync16(credPath)) {
|
|
40865
40995
|
return null;
|
|
40866
40996
|
}
|
|
40867
40997
|
try {
|
|
@@ -40880,10 +41010,10 @@ Waiting for authorization...`);
|
|
|
40880
41010
|
}
|
|
40881
41011
|
saveCredentials(credentials) {
|
|
40882
41012
|
const credPath = this.getCredentialsPath();
|
|
40883
|
-
const claudishDir =
|
|
40884
|
-
if (!
|
|
40885
|
-
const { mkdirSync:
|
|
40886
|
-
|
|
41013
|
+
const claudishDir = join18(homedir17(), ".claudish");
|
|
41014
|
+
if (!existsSync16(claudishDir)) {
|
|
41015
|
+
const { mkdirSync: mkdirSync10 } = __require("fs");
|
|
41016
|
+
mkdirSync10(claudishDir, { recursive: true });
|
|
40887
41017
|
}
|
|
40888
41018
|
const fd = openSync3(credPath, "w", 384);
|
|
40889
41019
|
try {
|
|
@@ -40908,9 +41038,9 @@ var init_kimi_oauth = __esm(() => {
|
|
|
40908
41038
|
});
|
|
40909
41039
|
|
|
40910
41040
|
// src/providers/transport/anthropic-compat.ts
|
|
40911
|
-
import { existsSync as
|
|
40912
|
-
import { join as
|
|
40913
|
-
import { homedir as
|
|
41041
|
+
import { existsSync as existsSync17, readFileSync as readFileSync13 } from "fs";
|
|
41042
|
+
import { join as join19 } from "path";
|
|
41043
|
+
import { homedir as homedir18 } from "os";
|
|
40914
41044
|
|
|
40915
41045
|
class AnthropicProviderTransport {
|
|
40916
41046
|
name;
|
|
@@ -40941,8 +41071,8 @@ class AnthropicProviderTransport {
|
|
|
40941
41071
|
}
|
|
40942
41072
|
if (this.provider.name === "kimi-coding") {
|
|
40943
41073
|
try {
|
|
40944
|
-
const credPath =
|
|
40945
|
-
if (
|
|
41074
|
+
const credPath = join19(homedir18(), ".claudish", "kimi-oauth.json");
|
|
41075
|
+
if (existsSync17(credPath)) {
|
|
40946
41076
|
const data = JSON.parse(readFileSync13(credPath, "utf-8"));
|
|
40947
41077
|
if (data.access_token && data.refresh_token) {
|
|
40948
41078
|
const oauth = KimiOAuth.getInstance();
|
|
@@ -41368,9 +41498,9 @@ var init_litellm_api_format = __esm(() => {
|
|
|
41368
41498
|
// src/auth/vertex-auth.ts
|
|
41369
41499
|
import { exec as exec4 } from "child_process";
|
|
41370
41500
|
import { promisify as promisify4 } from "util";
|
|
41371
|
-
import { existsSync as
|
|
41372
|
-
import { homedir as
|
|
41373
|
-
import { join as
|
|
41501
|
+
import { existsSync as existsSync18 } from "fs";
|
|
41502
|
+
import { homedir as homedir19 } from "os";
|
|
41503
|
+
import { join as join20 } from "path";
|
|
41374
41504
|
|
|
41375
41505
|
class VertexAuthManager {
|
|
41376
41506
|
cachedToken = null;
|
|
@@ -41424,8 +41554,8 @@ class VertexAuthManager {
|
|
|
41424
41554
|
}
|
|
41425
41555
|
async tryADC() {
|
|
41426
41556
|
try {
|
|
41427
|
-
const adcPath =
|
|
41428
|
-
if (!
|
|
41557
|
+
const adcPath = join20(homedir19(), ".config/gcloud/application_default_credentials.json");
|
|
41558
|
+
if (!existsSync18(adcPath)) {
|
|
41429
41559
|
log("[VertexAuth] ADC credentials file not found");
|
|
41430
41560
|
return null;
|
|
41431
41561
|
}
|
|
@@ -41449,7 +41579,7 @@ class VertexAuthManager {
|
|
|
41449
41579
|
if (!credPath) {
|
|
41450
41580
|
return null;
|
|
41451
41581
|
}
|
|
41452
|
-
if (!
|
|
41582
|
+
if (!existsSync18(credPath)) {
|
|
41453
41583
|
throw new Error(`Service account file not found: ${credPath}
|
|
41454
41584
|
|
|
41455
41585
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -41488,8 +41618,8 @@ function validateVertexOAuthConfig() {
|
|
|
41488
41618
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
41489
41619
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
41490
41620
|
}
|
|
41491
|
-
const adcPath =
|
|
41492
|
-
const hasADC =
|
|
41621
|
+
const adcPath = join20(homedir19(), ".config/gcloud/application_default_credentials.json");
|
|
41622
|
+
const hasADC = existsSync18(adcPath);
|
|
41493
41623
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
41494
41624
|
if (!hasADC && !hasServiceAccount) {
|
|
41495
41625
|
return `No Vertex AI credentials found.
|
|
@@ -41595,9 +41725,9 @@ var init_vertex_oauth = __esm(() => {
|
|
|
41595
41725
|
});
|
|
41596
41726
|
|
|
41597
41727
|
// src/providers/api-key-provenance.ts
|
|
41598
|
-
import { existsSync as
|
|
41599
|
-
import { join as
|
|
41600
|
-
import { homedir as
|
|
41728
|
+
import { existsSync as existsSync19, readFileSync as readFileSync15 } from "fs";
|
|
41729
|
+
import { join as join21, resolve as resolve2 } from "path";
|
|
41730
|
+
import { homedir as homedir20 } from "os";
|
|
41601
41731
|
function maskKey(key) {
|
|
41602
41732
|
if (!key)
|
|
41603
41733
|
return null;
|
|
@@ -41668,7 +41798,7 @@ function formatProvenanceLog(p) {
|
|
|
41668
41798
|
function readDotenvKey(envVars) {
|
|
41669
41799
|
try {
|
|
41670
41800
|
const dotenvPath = resolve2(".env");
|
|
41671
|
-
if (!
|
|
41801
|
+
if (!existsSync19(dotenvPath))
|
|
41672
41802
|
return null;
|
|
41673
41803
|
const parsed = import_dotenv.parse(readFileSync15(dotenvPath, "utf-8"));
|
|
41674
41804
|
for (const v of envVars) {
|
|
@@ -41682,8 +41812,8 @@ function readDotenvKey(envVars) {
|
|
|
41682
41812
|
}
|
|
41683
41813
|
function readConfigKey(envVar) {
|
|
41684
41814
|
try {
|
|
41685
|
-
const configPath =
|
|
41686
|
-
if (!
|
|
41815
|
+
const configPath = join21(homedir20(), ".claudish", "config.json");
|
|
41816
|
+
if (!existsSync19(configPath))
|
|
41687
41817
|
return null;
|
|
41688
41818
|
const cfg = JSON.parse(readFileSync15(configPath, "utf-8"));
|
|
41689
41819
|
return cfg.apiKeys?.[envVar] || null;
|
|
@@ -42624,12 +42754,12 @@ __export(exports_mcp_server, {
|
|
|
42624
42754
|
runPromptViaProxy: () => runPromptViaProxy,
|
|
42625
42755
|
parseAnthropicSse: () => parseAnthropicSse
|
|
42626
42756
|
});
|
|
42627
|
-
import { readFileSync as readFileSync16, existsSync as
|
|
42628
|
-
import { join as
|
|
42629
|
-
import { homedir as
|
|
42757
|
+
import { readFileSync as readFileSync16, existsSync as existsSync20, writeFileSync as writeFileSync11, mkdirSync as mkdirSync10, readdirSync as readdirSync3 } from "fs";
|
|
42758
|
+
import { join as join22, dirname as dirname4 } from "path";
|
|
42759
|
+
import { homedir as homedir21 } from "os";
|
|
42630
42760
|
import { fileURLToPath } from "url";
|
|
42631
42761
|
async function loadAllModels(forceRefresh = false) {
|
|
42632
|
-
if (!forceRefresh &&
|
|
42762
|
+
if (!forceRefresh && existsSync20(ALL_MODELS_CACHE_PATH2)) {
|
|
42633
42763
|
try {
|
|
42634
42764
|
const cacheData = JSON.parse(readFileSync16(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
42635
42765
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
@@ -42645,11 +42775,11 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
42645
42775
|
throw new Error(`API returned ${response.status}`);
|
|
42646
42776
|
const data = await response.json();
|
|
42647
42777
|
const models = data.data || [];
|
|
42648
|
-
|
|
42649
|
-
|
|
42778
|
+
mkdirSync10(CLAUDISH_CACHE_DIR, { recursive: true });
|
|
42779
|
+
writeFileSync11(ALL_MODELS_CACHE_PATH2, JSON.stringify({ lastUpdated: new Date().toISOString(), models }), "utf-8");
|
|
42650
42780
|
return models;
|
|
42651
42781
|
} catch {
|
|
42652
|
-
if (
|
|
42782
|
+
if (existsSync20(ALL_MODELS_CACHE_PATH2)) {
|
|
42653
42783
|
const cacheData = JSON.parse(readFileSync16(ALL_MODELS_CACHE_PATH2, "utf-8"));
|
|
42654
42784
|
return cacheData.models || [];
|
|
42655
42785
|
}
|
|
@@ -43222,16 +43352,16 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
43222
43352
|
const sp = session_path;
|
|
43223
43353
|
for (const file2 of ["status.json", "manifest.json", "input.md"]) {
|
|
43224
43354
|
try {
|
|
43225
|
-
sessionData[file2] = readFileSync16(
|
|
43355
|
+
sessionData[file2] = readFileSync16(join22(sp, file2), "utf-8");
|
|
43226
43356
|
} catch {}
|
|
43227
43357
|
}
|
|
43228
43358
|
try {
|
|
43229
|
-
const errorDir =
|
|
43230
|
-
if (
|
|
43359
|
+
const errorDir = join22(sp, "errors");
|
|
43360
|
+
if (existsSync20(errorDir)) {
|
|
43231
43361
|
for (const f of readdirSync3(errorDir)) {
|
|
43232
43362
|
if (f.endsWith(".log")) {
|
|
43233
43363
|
try {
|
|
43234
|
-
sessionData[`errors/${f}`] = readFileSync16(
|
|
43364
|
+
sessionData[`errors/${f}`] = readFileSync16(join22(errorDir, f), "utf-8");
|
|
43235
43365
|
} catch {}
|
|
43236
43366
|
}
|
|
43237
43367
|
}
|
|
@@ -43241,7 +43371,7 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
43241
43371
|
for (const f of readdirSync3(sp)) {
|
|
43242
43372
|
if (f.startsWith("response-") && f.endsWith(".md")) {
|
|
43243
43373
|
try {
|
|
43244
|
-
const content = readFileSync16(
|
|
43374
|
+
const content = readFileSync16(join22(sp, f), "utf-8");
|
|
43245
43375
|
sessionData[f] = content.slice(0, 200) + (content.length > 200 ? "... (truncated)" : "");
|
|
43246
43376
|
} catch {}
|
|
43247
43377
|
}
|
|
@@ -43250,8 +43380,8 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
43250
43380
|
}
|
|
43251
43381
|
let version2 = "unknown";
|
|
43252
43382
|
try {
|
|
43253
|
-
const pkgPath =
|
|
43254
|
-
if (
|
|
43383
|
+
const pkgPath = join22(__dirname2, "../package.json");
|
|
43384
|
+
if (existsSync20(pkgPath)) {
|
|
43255
43385
|
version2 = JSON.parse(readFileSync16(pkgPath, "utf-8")).version;
|
|
43256
43386
|
}
|
|
43257
43387
|
} catch {}
|
|
@@ -43624,9 +43754,9 @@ var init_mcp_server = __esm(() => {
|
|
|
43624
43754
|
import_dotenv2 = __toESM(require_main(), 1);
|
|
43625
43755
|
import_dotenv2.config();
|
|
43626
43756
|
__filename2 = fileURLToPath(import.meta.url);
|
|
43627
|
-
__dirname2 =
|
|
43628
|
-
CLAUDISH_CACHE_DIR =
|
|
43629
|
-
ALL_MODELS_CACHE_PATH2 =
|
|
43757
|
+
__dirname2 = dirname4(__filename2);
|
|
43758
|
+
CLAUDISH_CACHE_DIR = join22(homedir21(), ".claudish");
|
|
43759
|
+
ALL_MODELS_CACHE_PATH2 = join22(CLAUDISH_CACHE_DIR, "all-models.json");
|
|
43630
43760
|
EVENT_TO_TASK_STATUS = new Map([
|
|
43631
43761
|
["starting", "working"],
|
|
43632
43762
|
["running", "working"],
|
|
@@ -43643,7 +43773,7 @@ var exports_serve_command = {};
|
|
|
43643
43773
|
__export(exports_serve_command, {
|
|
43644
43774
|
serveCommand: () => serveCommand
|
|
43645
43775
|
});
|
|
43646
|
-
import { existsSync as
|
|
43776
|
+
import { existsSync as existsSync21, readFileSync as readFileSync17 } from "fs";
|
|
43647
43777
|
function parseServeArgs(args) {
|
|
43648
43778
|
const out = {};
|
|
43649
43779
|
for (let i = 0;i < args.length; i++) {
|
|
@@ -43662,7 +43792,7 @@ function parseServeArgs(args) {
|
|
|
43662
43792
|
return out;
|
|
43663
43793
|
}
|
|
43664
43794
|
function loadModelMap(path) {
|
|
43665
|
-
if (!
|
|
43795
|
+
if (!existsSync21(path)) {
|
|
43666
43796
|
throw new Error(`--models file not found: ${path}`);
|
|
43667
43797
|
}
|
|
43668
43798
|
let raw2;
|
|
@@ -55104,7 +55234,7 @@ var init_RemoveFileError = __esm(() => {
|
|
|
55104
55234
|
|
|
55105
55235
|
// ../../node_modules/.bun/@inquirer+external-editor@2.0.1+04f2146be16c61ef/node_modules/@inquirer/external-editor/dist/index.js
|
|
55106
55236
|
import { spawn as spawn3, spawnSync as spawnSync2 } from "child_process";
|
|
55107
|
-
import { readFileSync as readFileSync18, unlinkSync as unlinkSync6, writeFileSync as
|
|
55237
|
+
import { readFileSync as readFileSync18, unlinkSync as unlinkSync6, writeFileSync as writeFileSync12 } from "fs";
|
|
55108
55238
|
import path from "path";
|
|
55109
55239
|
import os from "os";
|
|
55110
55240
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
@@ -55213,7 +55343,7 @@ class ExternalEditor {
|
|
|
55213
55343
|
if (Object.prototype.hasOwnProperty.call(this.fileOptions, "mode")) {
|
|
55214
55344
|
opt.mode = this.fileOptions.mode;
|
|
55215
55345
|
}
|
|
55216
|
-
|
|
55346
|
+
writeFileSync12(this.tempFile, this.text, opt);
|
|
55217
55347
|
} catch (createFileError) {
|
|
55218
55348
|
throw new CreateFileError(createFileError);
|
|
55219
55349
|
}
|
|
@@ -56410,11 +56540,11 @@ async function geminiQuotaHandler() {
|
|
|
56410
56540
|
}
|
|
56411
56541
|
}
|
|
56412
56542
|
async function codexQuotaHandler() {
|
|
56413
|
-
const { readFileSync: readFileSync19, existsSync:
|
|
56414
|
-
const { join:
|
|
56415
|
-
const { homedir:
|
|
56416
|
-
const credPath =
|
|
56417
|
-
if (!
|
|
56543
|
+
const { readFileSync: readFileSync19, existsSync: existsSync22 } = await import("fs");
|
|
56544
|
+
const { join: join23 } = await import("path");
|
|
56545
|
+
const { homedir: homedir22 } = await import("os");
|
|
56546
|
+
const credPath = join23(homedir22(), ".claudish", "codex-oauth.json");
|
|
56547
|
+
if (!existsSync22(credPath)) {
|
|
56418
56548
|
console.error(`${RED}No Codex credentials found.${R} Run: ${B}claudish login codex${R}`);
|
|
56419
56549
|
process.exit(1);
|
|
56420
56550
|
}
|
|
@@ -56470,8 +56600,8 @@ async function codexQuotaHandler() {
|
|
|
56470
56600
|
}
|
|
56471
56601
|
let modelSlugs = [];
|
|
56472
56602
|
try {
|
|
56473
|
-
const modelsPath =
|
|
56474
|
-
if (
|
|
56603
|
+
const modelsPath = join23(homedir22(), ".codex", "models_cache.json");
|
|
56604
|
+
if (existsSync22(modelsPath)) {
|
|
56475
56605
|
const cache = JSON.parse(readFileSync19(modelsPath, "utf-8"));
|
|
56476
56606
|
modelSlugs = (cache.models || []).map((m) => m.slug || m.id).filter(Boolean);
|
|
56477
56607
|
}
|
|
@@ -60172,22 +60302,22 @@ __export(exports_cli, {
|
|
|
60172
60302
|
});
|
|
60173
60303
|
import {
|
|
60174
60304
|
readFileSync as readFileSync19,
|
|
60175
|
-
existsSync as
|
|
60176
|
-
mkdirSync as
|
|
60177
|
-
copyFileSync,
|
|
60305
|
+
existsSync as existsSync22,
|
|
60306
|
+
mkdirSync as mkdirSync11,
|
|
60307
|
+
copyFileSync as copyFileSync2,
|
|
60178
60308
|
readdirSync as readdirSync4,
|
|
60179
60309
|
unlinkSync as unlinkSync7,
|
|
60180
|
-
writeFileSync as
|
|
60310
|
+
writeFileSync as writeFileSync13
|
|
60181
60311
|
} from "fs";
|
|
60182
60312
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
60183
|
-
import { dirname as
|
|
60184
|
-
import { homedir as
|
|
60313
|
+
import { dirname as dirname5, join as join23 } from "path";
|
|
60314
|
+
import { homedir as homedir22 } from "os";
|
|
60185
60315
|
function getVersion3() {
|
|
60186
60316
|
return VERSION;
|
|
60187
60317
|
}
|
|
60188
60318
|
function clearAllModelCaches() {
|
|
60189
|
-
const cacheDir =
|
|
60190
|
-
if (!
|
|
60319
|
+
const cacheDir = join23(homedir22(), ".claudish");
|
|
60320
|
+
if (!existsSync22(cacheDir))
|
|
60191
60321
|
return;
|
|
60192
60322
|
const cachePatterns = ["pricing-cache.json", "recommended-models-cache.json"];
|
|
60193
60323
|
let cleared = 0;
|
|
@@ -60195,7 +60325,7 @@ function clearAllModelCaches() {
|
|
|
60195
60325
|
const files = readdirSync4(cacheDir);
|
|
60196
60326
|
for (const file2 of files) {
|
|
60197
60327
|
if (cachePatterns.includes(file2)) {
|
|
60198
|
-
unlinkSync7(
|
|
60328
|
+
unlinkSync7(join23(cacheDir, file2));
|
|
60199
60329
|
cleared++;
|
|
60200
60330
|
}
|
|
60201
60331
|
}
|
|
@@ -60579,15 +60709,15 @@ Usage: claudish --list-models --provider <slug>`);
|
|
|
60579
60709
|
});
|
|
60580
60710
|
config3.resolvedDefaultProvider = resolved;
|
|
60581
60711
|
if (resolved.legacyAutoPromoted && !config3.quiet) {
|
|
60582
|
-
const markerFile =
|
|
60583
|
-
if (!
|
|
60712
|
+
const markerFile = join23(homedir22(), ".claudish", ".legacy-litellm-hint-shown");
|
|
60713
|
+
if (!existsSync22(markerFile)) {
|
|
60584
60714
|
const hint = buildLegacyHint(resolved);
|
|
60585
60715
|
if (hint) {
|
|
60586
60716
|
console.error(hint);
|
|
60587
60717
|
}
|
|
60588
60718
|
try {
|
|
60589
|
-
|
|
60590
|
-
|
|
60719
|
+
mkdirSync11(dirname5(markerFile), { recursive: true });
|
|
60720
|
+
writeFileSync13(markerFile, new Date().toISOString(), "utf-8");
|
|
60591
60721
|
} catch {}
|
|
60592
60722
|
}
|
|
60593
60723
|
}
|
|
@@ -61737,7 +61867,7 @@ MORE INFO:
|
|
|
61737
61867
|
}
|
|
61738
61868
|
function printAIAgentGuide() {
|
|
61739
61869
|
try {
|
|
61740
|
-
const guidePath =
|
|
61870
|
+
const guidePath = join23(__dirname3, "../AI_AGENT_GUIDE.md");
|
|
61741
61871
|
const guideContent = readFileSync19(guidePath, "utf-8");
|
|
61742
61872
|
console.log(guideContent);
|
|
61743
61873
|
} catch (error46) {
|
|
@@ -61754,19 +61884,19 @@ async function initializeClaudishSkill() {
|
|
|
61754
61884
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
61755
61885
|
`);
|
|
61756
61886
|
const cwd = process.cwd();
|
|
61757
|
-
const claudeDir =
|
|
61758
|
-
const skillsDir =
|
|
61759
|
-
const claudishSkillDir =
|
|
61760
|
-
const skillFile =
|
|
61761
|
-
if (
|
|
61887
|
+
const claudeDir = join23(cwd, ".claude");
|
|
61888
|
+
const skillsDir = join23(claudeDir, "skills");
|
|
61889
|
+
const claudishSkillDir = join23(skillsDir, "claudish-usage");
|
|
61890
|
+
const skillFile = join23(claudishSkillDir, "SKILL.md");
|
|
61891
|
+
if (existsSync22(skillFile)) {
|
|
61762
61892
|
console.log("\u2705 Claudish skill already installed at:");
|
|
61763
61893
|
console.log(` ${skillFile}
|
|
61764
61894
|
`);
|
|
61765
61895
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
61766
61896
|
return;
|
|
61767
61897
|
}
|
|
61768
|
-
const sourceSkillPath =
|
|
61769
|
-
if (!
|
|
61898
|
+
const sourceSkillPath = join23(__dirname3, "../skills/claudish-usage/SKILL.md");
|
|
61899
|
+
if (!existsSync22(sourceSkillPath)) {
|
|
61770
61900
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
61771
61901
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
61772
61902
|
console.error(`
|
|
@@ -61775,19 +61905,19 @@ async function initializeClaudishSkill() {
|
|
|
61775
61905
|
process.exit(1);
|
|
61776
61906
|
}
|
|
61777
61907
|
try {
|
|
61778
|
-
if (!
|
|
61779
|
-
|
|
61908
|
+
if (!existsSync22(claudeDir)) {
|
|
61909
|
+
mkdirSync11(claudeDir, { recursive: true });
|
|
61780
61910
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
61781
61911
|
}
|
|
61782
|
-
if (!
|
|
61783
|
-
|
|
61912
|
+
if (!existsSync22(skillsDir)) {
|
|
61913
|
+
mkdirSync11(skillsDir, { recursive: true });
|
|
61784
61914
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
61785
61915
|
}
|
|
61786
|
-
if (!
|
|
61787
|
-
|
|
61916
|
+
if (!existsSync22(claudishSkillDir)) {
|
|
61917
|
+
mkdirSync11(claudishSkillDir, { recursive: true });
|
|
61788
61918
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
61789
61919
|
}
|
|
61790
|
-
|
|
61920
|
+
copyFileSync2(sourceSkillPath, skillFile);
|
|
61791
61921
|
console.log("\u2705 Installed Claudish skill at:");
|
|
61792
61922
|
console.log(` ${skillFile}
|
|
61793
61923
|
`);
|
|
@@ -61856,7 +61986,7 @@ var init_cli = __esm(() => {
|
|
|
61856
61986
|
init_probe_results_printer();
|
|
61857
61987
|
init_provider_resolver();
|
|
61858
61988
|
__filename3 = fileURLToPath2(import.meta.url);
|
|
61859
|
-
__dirname3 =
|
|
61989
|
+
__dirname3 = dirname5(__filename3);
|
|
61860
61990
|
});
|
|
61861
61991
|
|
|
61862
61992
|
// src/update-checker.ts
|
|
@@ -61867,30 +61997,30 @@ __export(exports_update_checker, {
|
|
|
61867
61997
|
clearCache: () => clearCache,
|
|
61868
61998
|
checkForUpdates: () => checkForUpdates
|
|
61869
61999
|
});
|
|
61870
|
-
import { existsSync as
|
|
61871
|
-
import { homedir as
|
|
61872
|
-
import { join as
|
|
62000
|
+
import { existsSync as existsSync23, mkdirSync as mkdirSync12, readFileSync as readFileSync20, unlinkSync as unlinkSync8, writeFileSync as writeFileSync14 } from "fs";
|
|
62001
|
+
import { homedir as homedir23, platform as platform2, tmpdir } from "os";
|
|
62002
|
+
import { join as join24 } from "path";
|
|
61873
62003
|
function getCacheFilePath() {
|
|
61874
62004
|
let cacheDir;
|
|
61875
62005
|
if (isWindows) {
|
|
61876
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
61877
|
-
cacheDir =
|
|
62006
|
+
const localAppData = process.env.LOCALAPPDATA || join24(homedir23(), "AppData", "Local");
|
|
62007
|
+
cacheDir = join24(localAppData, "claudish");
|
|
61878
62008
|
} else {
|
|
61879
|
-
cacheDir =
|
|
62009
|
+
cacheDir = join24(homedir23(), ".cache", "claudish");
|
|
61880
62010
|
}
|
|
61881
62011
|
try {
|
|
61882
|
-
if (!
|
|
61883
|
-
|
|
62012
|
+
if (!existsSync23(cacheDir)) {
|
|
62013
|
+
mkdirSync12(cacheDir, { recursive: true });
|
|
61884
62014
|
}
|
|
61885
|
-
return
|
|
62015
|
+
return join24(cacheDir, "update-check.json");
|
|
61886
62016
|
} catch {
|
|
61887
|
-
return
|
|
62017
|
+
return join24(tmpdir(), "claudish-update-check.json");
|
|
61888
62018
|
}
|
|
61889
62019
|
}
|
|
61890
62020
|
function readCache() {
|
|
61891
62021
|
try {
|
|
61892
62022
|
const cachePath = getCacheFilePath();
|
|
61893
|
-
if (!
|
|
62023
|
+
if (!existsSync23(cachePath)) {
|
|
61894
62024
|
return null;
|
|
61895
62025
|
}
|
|
61896
62026
|
const data = JSON.parse(readFileSync20(cachePath, "utf-8"));
|
|
@@ -61906,7 +62036,7 @@ function writeCache(latestVersion) {
|
|
|
61906
62036
|
lastCheck: Date.now(),
|
|
61907
62037
|
latestVersion
|
|
61908
62038
|
};
|
|
61909
|
-
|
|
62039
|
+
writeFileSync14(cachePath, JSON.stringify(data), "utf-8");
|
|
61910
62040
|
} catch {}
|
|
61911
62041
|
}
|
|
61912
62042
|
function isCacheValid(cache) {
|
|
@@ -61916,7 +62046,7 @@ function isCacheValid(cache) {
|
|
|
61916
62046
|
function clearCache() {
|
|
61917
62047
|
try {
|
|
61918
62048
|
const cachePath = getCacheFilePath();
|
|
61919
|
-
if (
|
|
62049
|
+
if (existsSync23(cachePath)) {
|
|
61920
62050
|
unlinkSync8(cachePath);
|
|
61921
62051
|
}
|
|
61922
62052
|
} catch {}
|
|
@@ -62700,11 +62830,11 @@ var init_profile_commands = __esm(() => {
|
|
|
62700
62830
|
});
|
|
62701
62831
|
|
|
62702
62832
|
// src/providers/probe-catalog.ts
|
|
62703
|
-
import { existsSync as
|
|
62704
|
-
import { homedir as
|
|
62705
|
-
import { dirname as
|
|
62833
|
+
import { existsSync as existsSync24, mkdirSync as mkdirSync13, readFileSync as readFileSync21, writeFileSync as writeFileSync15 } from "fs";
|
|
62834
|
+
import { homedir as homedir24 } from "os";
|
|
62835
|
+
import { dirname as dirname6, join as join25 } from "path";
|
|
62706
62836
|
function readProbeModelsCache(path2 = PROBE_MODELS_CACHE_PATH) {
|
|
62707
|
-
if (!
|
|
62837
|
+
if (!existsSync24(path2))
|
|
62708
62838
|
return null;
|
|
62709
62839
|
let raw2;
|
|
62710
62840
|
try {
|
|
@@ -62717,8 +62847,8 @@ function readProbeModelsCache(path2 = PROBE_MODELS_CACHE_PATH) {
|
|
|
62717
62847
|
return raw2;
|
|
62718
62848
|
}
|
|
62719
62849
|
function writeProbeModelsCache(data, path2 = PROBE_MODELS_CACHE_PATH) {
|
|
62720
|
-
|
|
62721
|
-
|
|
62850
|
+
mkdirSync13(dirname6(path2), { recursive: true });
|
|
62851
|
+
writeFileSync15(path2, JSON.stringify(data), "utf-8");
|
|
62722
62852
|
}
|
|
62723
62853
|
function isCacheFresh(data, ttlMs = CACHE_TTL_MS3) {
|
|
62724
62854
|
if (!data?.generatedAt)
|
|
@@ -62837,7 +62967,7 @@ function isValidResponse(raw2) {
|
|
|
62837
62967
|
var PROBE_MODELS_URL = "https://us-central1-claudish-6da10.cloudfunctions.net/probeModels", CACHE_TTL_MS3, FETCH_TIMEOUT_MS2 = 15000, PROBE_MODELS_CACHE_PATH, _inFlight = null;
|
|
62838
62968
|
var init_probe_catalog = __esm(() => {
|
|
62839
62969
|
CACHE_TTL_MS3 = 60 * 60 * 1000;
|
|
62840
|
-
PROBE_MODELS_CACHE_PATH =
|
|
62970
|
+
PROBE_MODELS_CACHE_PATH = join25(homedir24(), ".claudish", "probe-models.json");
|
|
62841
62971
|
});
|
|
62842
62972
|
|
|
62843
62973
|
// src/tui/probe-proxy.ts
|
|
@@ -68964,9 +69094,9 @@ __export(exports_claude_runner, {
|
|
|
68964
69094
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
68965
69095
|
});
|
|
68966
69096
|
import { spawn as spawn4 } from "child_process";
|
|
68967
|
-
import { writeFileSync as
|
|
68968
|
-
import { tmpdir as tmpdir2, homedir as
|
|
68969
|
-
import { join as
|
|
69097
|
+
import { writeFileSync as writeFileSync16, unlinkSync as unlinkSync9, mkdirSync as mkdirSync14, existsSync as existsSync25, readFileSync as readFileSync22 } from "fs";
|
|
69098
|
+
import { tmpdir as tmpdir2, homedir as homedir25 } from "os";
|
|
69099
|
+
import { join as join26 } from "path";
|
|
68970
69100
|
function hasNativeAnthropicMapping(config3) {
|
|
68971
69101
|
const models = [
|
|
68972
69102
|
config3.model,
|
|
@@ -68982,9 +69112,9 @@ function isWindows2() {
|
|
|
68982
69112
|
}
|
|
68983
69113
|
function createStatusLineScript(tokenFilePath) {
|
|
68984
69114
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
68985
|
-
const claudishDir =
|
|
69115
|
+
const claudishDir = join26(homeDir, ".claudish");
|
|
68986
69116
|
const timestamp = Date.now();
|
|
68987
|
-
const scriptPath =
|
|
69117
|
+
const scriptPath = join26(claudishDir, `status-${timestamp}.js`);
|
|
68988
69118
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
68989
69119
|
const script = `
|
|
68990
69120
|
const fs = require('fs');
|
|
@@ -69076,18 +69206,18 @@ process.stdin.on('end', () => {
|
|
|
69076
69206
|
}
|
|
69077
69207
|
});
|
|
69078
69208
|
`;
|
|
69079
|
-
|
|
69209
|
+
writeFileSync16(scriptPath, script, "utf-8");
|
|
69080
69210
|
return scriptPath;
|
|
69081
69211
|
}
|
|
69082
69212
|
function createTempSettingsFile(modelDisplay, port) {
|
|
69083
69213
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
69084
|
-
const claudishDir =
|
|
69214
|
+
const claudishDir = join26(homeDir, ".claudish");
|
|
69085
69215
|
try {
|
|
69086
|
-
|
|
69216
|
+
mkdirSync14(claudishDir, { recursive: true });
|
|
69087
69217
|
} catch {}
|
|
69088
69218
|
const timestamp = Date.now();
|
|
69089
|
-
const tempPath =
|
|
69090
|
-
const tokenFilePath =
|
|
69219
|
+
const tempPath = join26(claudishDir, `settings-${timestamp}.json`);
|
|
69220
|
+
const tokenFilePath = join26(claudishDir, `tokens-${port}.json`);
|
|
69091
69221
|
let statusCommand;
|
|
69092
69222
|
if (isWindows2()) {
|
|
69093
69223
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -69109,7 +69239,7 @@ function createTempSettingsFile(modelDisplay, port) {
|
|
|
69109
69239
|
padding: 0
|
|
69110
69240
|
};
|
|
69111
69241
|
const settings = { statusLine };
|
|
69112
|
-
|
|
69242
|
+
writeFileSync16(tempPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
69113
69243
|
return { path: tempPath, statusLine };
|
|
69114
69244
|
}
|
|
69115
69245
|
function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
@@ -69127,7 +69257,7 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
69127
69257
|
userSettings = JSON.parse(rawUserSettings);
|
|
69128
69258
|
}
|
|
69129
69259
|
userSettings.statusLine = statusLine;
|
|
69130
|
-
|
|
69260
|
+
writeFileSync16(tempSettingsPath, JSON.stringify(userSettings, null, 2), "utf-8");
|
|
69131
69261
|
} catch {
|
|
69132
69262
|
if (!config3.quiet) {
|
|
69133
69263
|
console.warn(`[claudish] Warning: could not merge user settings: ${userSettingsValue}`);
|
|
@@ -69215,8 +69345,8 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
69215
69345
|
console.error("Install it from: https://claude.com/claude-code");
|
|
69216
69346
|
console.error(`
|
|
69217
69347
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
69218
|
-
const home =
|
|
69219
|
-
const localPath = isWindows2() ?
|
|
69348
|
+
const home = homedir25();
|
|
69349
|
+
const localPath = isWindows2() ? join26(home, ".claude", "local", "claude.exe") : join26(home, ".claude", "local", "claude");
|
|
69220
69350
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
69221
69351
|
process.exit(1);
|
|
69222
69352
|
}
|
|
@@ -69264,23 +69394,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet, onCleanup) {
|
|
|
69264
69394
|
async function findClaudeBinary() {
|
|
69265
69395
|
const isWindows3 = process.platform === "win32";
|
|
69266
69396
|
if (process.env.CLAUDE_PATH) {
|
|
69267
|
-
if (
|
|
69397
|
+
if (existsSync25(process.env.CLAUDE_PATH)) {
|
|
69268
69398
|
return process.env.CLAUDE_PATH;
|
|
69269
69399
|
}
|
|
69270
69400
|
}
|
|
69271
|
-
const home =
|
|
69272
|
-
const localPath = isWindows3 ?
|
|
69273
|
-
if (
|
|
69401
|
+
const home = homedir25();
|
|
69402
|
+
const localPath = isWindows3 ? join26(home, ".claude", "local", "claude.exe") : join26(home, ".claude", "local", "claude");
|
|
69403
|
+
if (existsSync25(localPath)) {
|
|
69274
69404
|
return localPath;
|
|
69275
69405
|
}
|
|
69276
69406
|
if (isWindows3) {
|
|
69277
69407
|
const windowsPaths = [
|
|
69278
|
-
|
|
69279
|
-
|
|
69280
|
-
|
|
69408
|
+
join26(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
69409
|
+
join26(home, ".npm-global", "claude.cmd"),
|
|
69410
|
+
join26(home, "node_modules", ".bin", "claude.cmd")
|
|
69281
69411
|
];
|
|
69282
69412
|
for (const path2 of windowsPaths) {
|
|
69283
|
-
if (
|
|
69413
|
+
if (existsSync25(path2)) {
|
|
69284
69414
|
return path2;
|
|
69285
69415
|
}
|
|
69286
69416
|
}
|
|
@@ -69288,14 +69418,14 @@ async function findClaudeBinary() {
|
|
|
69288
69418
|
const commonPaths = [
|
|
69289
69419
|
"/usr/local/bin/claude",
|
|
69290
69420
|
"/opt/homebrew/bin/claude",
|
|
69291
|
-
|
|
69292
|
-
|
|
69293
|
-
|
|
69421
|
+
join26(home, ".npm-global/bin/claude"),
|
|
69422
|
+
join26(home, ".local/bin/claude"),
|
|
69423
|
+
join26(home, "node_modules/.bin/claude"),
|
|
69294
69424
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
69295
|
-
|
|
69425
|
+
join26(home, "../usr/bin/claude")
|
|
69296
69426
|
];
|
|
69297
69427
|
for (const path2 of commonPaths) {
|
|
69298
|
-
if (
|
|
69428
|
+
if (existsSync25(path2)) {
|
|
69299
69429
|
return path2;
|
|
69300
69430
|
}
|
|
69301
69431
|
}
|
|
@@ -69345,18 +69475,18 @@ __export(exports_diag_output, {
|
|
|
69345
69475
|
NullDiagOutput: () => NullDiagOutput,
|
|
69346
69476
|
LogFileDiagOutput: () => LogFileDiagOutput
|
|
69347
69477
|
});
|
|
69348
|
-
import { createWriteStream as createWriteStream3, mkdirSync as
|
|
69349
|
-
import { homedir as
|
|
69350
|
-
import { join as
|
|
69478
|
+
import { createWriteStream as createWriteStream3, mkdirSync as mkdirSync15, writeFileSync as writeFileSync17, unlinkSync as unlinkSync10 } from "fs";
|
|
69479
|
+
import { homedir as homedir26 } from "os";
|
|
69480
|
+
import { join as join27 } from "path";
|
|
69351
69481
|
function getClaudishDir() {
|
|
69352
|
-
const dir =
|
|
69482
|
+
const dir = join27(homedir26(), ".claudish");
|
|
69353
69483
|
try {
|
|
69354
|
-
|
|
69484
|
+
mkdirSync15(dir, { recursive: true });
|
|
69355
69485
|
} catch {}
|
|
69356
69486
|
return dir;
|
|
69357
69487
|
}
|
|
69358
69488
|
function getDiagLogPath() {
|
|
69359
|
-
return
|
|
69489
|
+
return join27(getClaudishDir(), `diag-${process.pid}.log`);
|
|
69360
69490
|
}
|
|
69361
69491
|
|
|
69362
69492
|
class LogFileDiagOutput {
|
|
@@ -69365,7 +69495,7 @@ class LogFileDiagOutput {
|
|
|
69365
69495
|
constructor() {
|
|
69366
69496
|
this.logPath = getDiagLogPath();
|
|
69367
69497
|
try {
|
|
69368
|
-
|
|
69498
|
+
writeFileSync17(this.logPath, `--- claudish diag session ${new Date().toISOString()} ---
|
|
69369
69499
|
`);
|
|
69370
69500
|
} catch {}
|
|
69371
69501
|
this.stream = createWriteStream3(this.logPath, { flags: "a" });
|
|
@@ -69567,11 +69697,11 @@ __export(exports_team_grid, {
|
|
|
69567
69697
|
});
|
|
69568
69698
|
import { spawn as spawn5 } from "child_process";
|
|
69569
69699
|
import {
|
|
69570
|
-
existsSync as
|
|
69700
|
+
existsSync as existsSync26,
|
|
69571
69701
|
readFileSync as readFileSync23,
|
|
69572
|
-
writeFileSync as
|
|
69702
|
+
writeFileSync as writeFileSync18
|
|
69573
69703
|
} from "fs";
|
|
69574
|
-
import { dirname as
|
|
69704
|
+
import { dirname as dirname7, join as join28 } from "path";
|
|
69575
69705
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
69576
69706
|
import { execSync as execSync2 } from "child_process";
|
|
69577
69707
|
import { connect as netConnect } from "net";
|
|
@@ -69666,21 +69796,21 @@ function buildPaneHeader(model, prompt, bg) {
|
|
|
69666
69796
|
}
|
|
69667
69797
|
function findMagmuxBinary() {
|
|
69668
69798
|
const thisFile = fileURLToPath3(import.meta.url);
|
|
69669
|
-
const thisDir =
|
|
69670
|
-
const pkgRoot =
|
|
69799
|
+
const thisDir = dirname7(thisFile);
|
|
69800
|
+
const pkgRoot = join28(thisDir, "..");
|
|
69671
69801
|
const platform3 = process.platform;
|
|
69672
69802
|
const arch = process.arch;
|
|
69673
|
-
const bundledMagmux =
|
|
69674
|
-
if (
|
|
69803
|
+
const bundledMagmux = join28(pkgRoot, "native", `magmux-${platform3}-${arch}`);
|
|
69804
|
+
if (existsSync26(bundledMagmux))
|
|
69675
69805
|
return bundledMagmux;
|
|
69676
69806
|
try {
|
|
69677
69807
|
const pkgName = `@claudish/magmux-${platform3}-${arch}`;
|
|
69678
69808
|
let searchDir = pkgRoot;
|
|
69679
69809
|
for (let i = 0;i < 5; i++) {
|
|
69680
|
-
const candidate =
|
|
69681
|
-
if (
|
|
69810
|
+
const candidate = join28(searchDir, "node_modules", pkgName, "bin", "magmux");
|
|
69811
|
+
if (existsSync26(candidate))
|
|
69682
69812
|
return candidate;
|
|
69683
|
-
const parent =
|
|
69813
|
+
const parent = dirname7(searchDir);
|
|
69684
69814
|
if (parent === searchDir)
|
|
69685
69815
|
break;
|
|
69686
69816
|
searchDir = parent;
|
|
@@ -69697,7 +69827,7 @@ function findMagmuxBinary() {
|
|
|
69697
69827
|
async function subscribeToMagmux(sockPath, onEvent) {
|
|
69698
69828
|
let client = null;
|
|
69699
69829
|
for (let attempt = 0;attempt < 40; attempt++) {
|
|
69700
|
-
if (
|
|
69830
|
+
if (existsSync26(sockPath)) {
|
|
69701
69831
|
try {
|
|
69702
69832
|
client = await new Promise((resolve3, reject) => {
|
|
69703
69833
|
const s = netConnect(sockPath);
|
|
@@ -69784,9 +69914,9 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69784
69914
|
const keep = opts?.keep ?? false;
|
|
69785
69915
|
const manifest = setupSession(sessionPath, models, input);
|
|
69786
69916
|
const startedAt = new Date().toISOString();
|
|
69787
|
-
const gridfilePath =
|
|
69788
|
-
const prompt = readFileSync23(
|
|
69789
|
-
const rawPrompt = readFileSync23(
|
|
69917
|
+
const gridfilePath = join28(sessionPath, "gridfile.txt");
|
|
69918
|
+
const prompt = readFileSync23(join28(sessionPath, "input.md"), "utf-8").replace(/'/g, "'\\''").replace(/\n/g, " ");
|
|
69919
|
+
const rawPrompt = readFileSync23(join28(sessionPath, "input.md"), "utf-8");
|
|
69790
69920
|
const usedBannerColors = new Set;
|
|
69791
69921
|
const gridLines = Object.entries(manifest.models).map(([anonId]) => {
|
|
69792
69922
|
const model = manifest.models[anonId].model;
|
|
@@ -69797,7 +69927,7 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69797
69927
|
const header = buildPaneHeader(model, rawPrompt, bg);
|
|
69798
69928
|
return `${header} claudish --model ${model} -y --quiet '${prompt}'`;
|
|
69799
69929
|
});
|
|
69800
|
-
|
|
69930
|
+
writeFileSync18(gridfilePath, gridLines.join(`
|
|
69801
69931
|
`) + `
|
|
69802
69932
|
`, "utf-8");
|
|
69803
69933
|
const magmuxPath = findMagmuxBinary();
|
|
@@ -69817,8 +69947,8 @@ async function runWithGrid(sessionPath, models, input, opts) {
|
|
|
69817
69947
|
});
|
|
69818
69948
|
const [{ results }] = await Promise.all([subscription, procExit]);
|
|
69819
69949
|
const status = buildTeamStatus(manifest, startedAt, results?.panes ?? null);
|
|
69820
|
-
const statusPath =
|
|
69821
|
-
|
|
69950
|
+
const statusPath = join28(sessionPath, "status.json");
|
|
69951
|
+
writeFileSync18(statusPath, JSON.stringify(status, null, 2), "utf-8");
|
|
69822
69952
|
return status;
|
|
69823
69953
|
}
|
|
69824
69954
|
var BANNER_BG_COLORS;
|
|
@@ -69840,9 +69970,9 @@ var init_team_grid = __esm(() => {
|
|
|
69840
69970
|
// src/index.ts
|
|
69841
69971
|
init_onepassword_config();
|
|
69842
69972
|
var import_dotenv3 = __toESM(require_main(), 1);
|
|
69843
|
-
import { existsSync as
|
|
69844
|
-
import { homedir as
|
|
69845
|
-
import { join as
|
|
69973
|
+
import { existsSync as existsSync27, readFileSync as readFileSync24 } from "fs";
|
|
69974
|
+
import { homedir as homedir27 } from "os";
|
|
69975
|
+
import { join as join29 } from "path";
|
|
69846
69976
|
import_dotenv3.config({ quiet: true });
|
|
69847
69977
|
function readConfiguredOnepasswordAccount() {
|
|
69848
69978
|
return readOnepasswordAccount();
|
|
@@ -70014,8 +70144,8 @@ async function loadStoredApiKeys() {
|
|
|
70014
70144
|
let globImports = [];
|
|
70015
70145
|
let apiKeysForSeed;
|
|
70016
70146
|
try {
|
|
70017
|
-
const configPath =
|
|
70018
|
-
if (!
|
|
70147
|
+
const configPath = join29(homedir27(), ".claudish", "config.json");
|
|
70148
|
+
if (!existsSync27(configPath))
|
|
70019
70149
|
return;
|
|
70020
70150
|
const raw2 = readFileSync24(configPath, "utf-8");
|
|
70021
70151
|
const cfg = JSON.parse(raw2);
|
|
@@ -70055,7 +70185,10 @@ async function loadStoredApiKeys() {
|
|
|
70055
70185
|
}
|
|
70056
70186
|
for (const globPath of globImports) {
|
|
70057
70187
|
try {
|
|
70058
|
-
const resolved = await resolveGlobImport2(globPath, {
|
|
70188
|
+
const resolved = await resolveGlobImport2(globPath, {
|
|
70189
|
+
auth,
|
|
70190
|
+
warn: () => {}
|
|
70191
|
+
});
|
|
70059
70192
|
for (const [envVar, value] of Object.entries(resolved)) {
|
|
70060
70193
|
if (!process.env[envVar]) {
|
|
70061
70194
|
process.env[envVar] = value;
|
|
@@ -70075,8 +70208,8 @@ async function loadStoredApiKeys() {
|
|
|
70075
70208
|
async function applyCustomEndpointOpKeys() {
|
|
70076
70209
|
let refs = {};
|
|
70077
70210
|
try {
|
|
70078
|
-
const configPath =
|
|
70079
|
-
if (!
|
|
70211
|
+
const configPath = join29(homedir27(), ".claudish", "config.json");
|
|
70212
|
+
if (!existsSync27(configPath))
|
|
70080
70213
|
return;
|
|
70081
70214
|
const cfg = JSON.parse(readFileSync24(configPath, "utf-8"));
|
|
70082
70215
|
const endpoints = cfg.customEndpoints;
|
|
@@ -70112,10 +70245,16 @@ async function applyCustomEndpointOpKeys() {
|
|
|
70112
70245
|
process.exit(1);
|
|
70113
70246
|
}
|
|
70114
70247
|
}
|
|
70115
|
-
|
|
70116
|
-
|
|
70117
|
-
|
|
70118
|
-
|
|
70248
|
+
var earlyArgv = process.argv.slice(2);
|
|
70249
|
+
var hasExplicitOpFlag = earlyArgv.some((a) => a === "--op" || a === "--op-env" || a.startsWith("--op-env="));
|
|
70250
|
+
var earlyFirst = earlyArgv.find((a) => !a.startsWith("-"));
|
|
70251
|
+
var isNoSecretCommand = !hasExplicitOpFlag && (earlyArgv.includes("--help") || earlyArgv.includes("-h") || earlyArgv.includes("--help-ai") || earlyArgv.includes("--version") || earlyArgv.includes("-v") || earlyFirst === "help" || earlyFirst === "version");
|
|
70252
|
+
if (!isNoSecretCommand) {
|
|
70253
|
+
await applyOpEnvironment();
|
|
70254
|
+
await applyOpImport();
|
|
70255
|
+
await loadStoredApiKeys();
|
|
70256
|
+
await applyCustomEndpointOpKeys();
|
|
70257
|
+
}
|
|
70119
70258
|
var isMcpMode = process.argv.includes("--mcp");
|
|
70120
70259
|
function handlePromptExit(err) {
|
|
70121
70260
|
if (err && typeof err === "object" && "name" in err && err.name === "ExitPromptError") {
|
|
@@ -70233,7 +70372,7 @@ async function runCli() {
|
|
|
70233
70372
|
process.exit(1);
|
|
70234
70373
|
}
|
|
70235
70374
|
const mode = cliConfig.teamMode ?? "default";
|
|
70236
|
-
const sessionPath =
|
|
70375
|
+
const sessionPath = join29(process.cwd(), `.claudish-team-${Date.now()}`);
|
|
70237
70376
|
if (mode === "json") {
|
|
70238
70377
|
const { setupSession: setupSession2, runModels: runModels2 } = await Promise.resolve().then(() => (init_team_orchestrator(), exports_team_orchestrator));
|
|
70239
70378
|
setupSession2(sessionPath, cliConfig.team, prompt);
|
|
@@ -70243,7 +70382,7 @@ async function runCli() {
|
|
|
70243
70382
|
});
|
|
70244
70383
|
const result = { ...status2, responses: {} };
|
|
70245
70384
|
for (const anonId of Object.keys(status2.models)) {
|
|
70246
|
-
const responsePath =
|
|
70385
|
+
const responsePath = join29(sessionPath, `response-${anonId}.md`);
|
|
70247
70386
|
try {
|
|
70248
70387
|
const raw2 = readFileSync24(responsePath, "utf-8").trim();
|
|
70249
70388
|
try {
|