claudish 5.14.0 → 5.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1152 -382
- package/package.json +1 -1
- package/recommended-models.json +1 -1
package/dist/index.js
CHANGED
|
@@ -28416,19 +28416,379 @@ var init_stdio2 = __esm(() => {
|
|
|
28416
28416
|
init_stdio();
|
|
28417
28417
|
});
|
|
28418
28418
|
|
|
28419
|
+
// src/team-orchestrator.ts
|
|
28420
|
+
import { spawn } from "child_process";
|
|
28421
|
+
import {
|
|
28422
|
+
mkdirSync,
|
|
28423
|
+
writeFileSync,
|
|
28424
|
+
readFileSync,
|
|
28425
|
+
existsSync,
|
|
28426
|
+
readdirSync,
|
|
28427
|
+
statSync,
|
|
28428
|
+
createWriteStream
|
|
28429
|
+
} from "fs";
|
|
28430
|
+
import { join, resolve } from "path";
|
|
28431
|
+
function validateSessionPath(sessionPath) {
|
|
28432
|
+
const resolved = resolve(sessionPath);
|
|
28433
|
+
const cwd = process.cwd();
|
|
28434
|
+
if (!resolved.startsWith(cwd + "/") && resolved !== cwd) {
|
|
28435
|
+
throw new Error(`Session path must be within current directory: ${sessionPath}`);
|
|
28436
|
+
}
|
|
28437
|
+
return resolved;
|
|
28438
|
+
}
|
|
28439
|
+
function setupSession(sessionPath, models, input) {
|
|
28440
|
+
if (models.length === 0) {
|
|
28441
|
+
throw new Error("At least one model is required");
|
|
28442
|
+
}
|
|
28443
|
+
mkdirSync(join(sessionPath, "work"), { recursive: true });
|
|
28444
|
+
mkdirSync(join(sessionPath, "errors"), { recursive: true });
|
|
28445
|
+
if (input !== undefined) {
|
|
28446
|
+
writeFileSync(join(sessionPath, "input.md"), input, "utf-8");
|
|
28447
|
+
} else if (!existsSync(join(sessionPath, "input.md"))) {
|
|
28448
|
+
throw new Error(`No input.md found at ${sessionPath} and no input provided`);
|
|
28449
|
+
}
|
|
28450
|
+
const ids = models.map((_, i) => String(i + 1).padStart(2, "0"));
|
|
28451
|
+
const shuffled = fisherYatesShuffle([...ids]);
|
|
28452
|
+
const now = new Date().toISOString();
|
|
28453
|
+
const manifest = {
|
|
28454
|
+
created: now,
|
|
28455
|
+
models: {},
|
|
28456
|
+
shuffleOrder: shuffled
|
|
28457
|
+
};
|
|
28458
|
+
for (let i = 0;i < models.length; i++) {
|
|
28459
|
+
const anonId = shuffled[i];
|
|
28460
|
+
manifest.models[anonId] = {
|
|
28461
|
+
model: models[i],
|
|
28462
|
+
assignedAt: now
|
|
28463
|
+
};
|
|
28464
|
+
mkdirSync(join(sessionPath, "work", anonId), { recursive: true });
|
|
28465
|
+
}
|
|
28466
|
+
writeFileSync(join(sessionPath, "manifest.json"), JSON.stringify(manifest, null, 2), "utf-8");
|
|
28467
|
+
const status = {
|
|
28468
|
+
startedAt: now,
|
|
28469
|
+
models: Object.fromEntries(Object.keys(manifest.models).map((id) => [
|
|
28470
|
+
id,
|
|
28471
|
+
{
|
|
28472
|
+
state: "PENDING",
|
|
28473
|
+
exitCode: null,
|
|
28474
|
+
startedAt: null,
|
|
28475
|
+
completedAt: null,
|
|
28476
|
+
outputSize: 0
|
|
28477
|
+
}
|
|
28478
|
+
]))
|
|
28479
|
+
};
|
|
28480
|
+
writeFileSync(join(sessionPath, "status.json"), JSON.stringify(status, null, 2), "utf-8");
|
|
28481
|
+
return manifest;
|
|
28482
|
+
}
|
|
28483
|
+
async function runModels(sessionPath, opts = {}) {
|
|
28484
|
+
const timeoutMs = (opts.timeout ?? 300) * 1000;
|
|
28485
|
+
const manifest = JSON.parse(readFileSync(join(sessionPath, "manifest.json"), "utf-8"));
|
|
28486
|
+
const statusPath = join(sessionPath, "status.json");
|
|
28487
|
+
const inputPath = join(sessionPath, "input.md");
|
|
28488
|
+
const inputContent = readFileSync(inputPath, "utf-8");
|
|
28489
|
+
const statusCache = JSON.parse(readFileSync(statusPath, "utf-8"));
|
|
28490
|
+
function updateModelStatus(id, update) {
|
|
28491
|
+
statusCache.models[id] = { ...statusCache.models[id], ...update };
|
|
28492
|
+
writeFileSync(statusPath, JSON.stringify(statusCache, null, 2), "utf-8");
|
|
28493
|
+
}
|
|
28494
|
+
const processes = new Map;
|
|
28495
|
+
const sigintHandler = () => {
|
|
28496
|
+
for (const [, proc] of processes) {
|
|
28497
|
+
if (!proc.killed)
|
|
28498
|
+
proc.kill("SIGTERM");
|
|
28499
|
+
}
|
|
28500
|
+
process.exit(1);
|
|
28501
|
+
};
|
|
28502
|
+
process.on("SIGINT", sigintHandler);
|
|
28503
|
+
const completionPromises = [];
|
|
28504
|
+
for (const [anonId, entry] of Object.entries(manifest.models)) {
|
|
28505
|
+
const outputPath = join(sessionPath, `response-${anonId}.md`);
|
|
28506
|
+
const errorLogPath = join(sessionPath, "errors", `${anonId}.log`);
|
|
28507
|
+
const workDir = join(sessionPath, "work", anonId);
|
|
28508
|
+
const args = [
|
|
28509
|
+
"--model",
|
|
28510
|
+
entry.model,
|
|
28511
|
+
"-y",
|
|
28512
|
+
"--stdin",
|
|
28513
|
+
"--quiet",
|
|
28514
|
+
...opts.claudeFlags ?? []
|
|
28515
|
+
];
|
|
28516
|
+
updateModelStatus(anonId, {
|
|
28517
|
+
state: "RUNNING",
|
|
28518
|
+
startedAt: new Date().toISOString()
|
|
28519
|
+
});
|
|
28520
|
+
const proc = spawn("claudish", args, {
|
|
28521
|
+
cwd: workDir,
|
|
28522
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
28523
|
+
shell: false
|
|
28524
|
+
});
|
|
28525
|
+
const outputStream = createWriteStream(outputPath);
|
|
28526
|
+
proc.stdout?.pipe(outputStream);
|
|
28527
|
+
let stderr = "";
|
|
28528
|
+
proc.stderr?.on("data", (chunk) => {
|
|
28529
|
+
stderr += chunk.toString();
|
|
28530
|
+
});
|
|
28531
|
+
proc.stdin?.write(inputContent);
|
|
28532
|
+
proc.stdin?.end();
|
|
28533
|
+
const completionPromise = new Promise((resolve2) => {
|
|
28534
|
+
let exitCode = null;
|
|
28535
|
+
let resolved = false;
|
|
28536
|
+
const finish = () => {
|
|
28537
|
+
if (resolved)
|
|
28538
|
+
return;
|
|
28539
|
+
resolved = true;
|
|
28540
|
+
let outputSize = 0;
|
|
28541
|
+
try {
|
|
28542
|
+
outputSize = statSync(outputPath).size;
|
|
28543
|
+
} catch {}
|
|
28544
|
+
updateModelStatus(anonId, {
|
|
28545
|
+
state: exitCode === 0 ? "COMPLETED" : "FAILED",
|
|
28546
|
+
exitCode: exitCode ?? 1,
|
|
28547
|
+
completedAt: new Date().toISOString(),
|
|
28548
|
+
outputSize
|
|
28549
|
+
});
|
|
28550
|
+
opts.onStatusChange?.(anonId, statusCache.models[anonId]);
|
|
28551
|
+
resolve2();
|
|
28552
|
+
};
|
|
28553
|
+
outputStream.on("close", finish);
|
|
28554
|
+
proc.on("exit", (code) => {
|
|
28555
|
+
const current = statusCache.models[anonId];
|
|
28556
|
+
if (current?.state === "TIMEOUT") {
|
|
28557
|
+
resolved = true;
|
|
28558
|
+
resolve2();
|
|
28559
|
+
return;
|
|
28560
|
+
}
|
|
28561
|
+
if (stderr) {
|
|
28562
|
+
writeFileSync(errorLogPath, stderr, "utf-8");
|
|
28563
|
+
}
|
|
28564
|
+
exitCode = code;
|
|
28565
|
+
if (outputStream.destroyed) {
|
|
28566
|
+
finish();
|
|
28567
|
+
}
|
|
28568
|
+
});
|
|
28569
|
+
});
|
|
28570
|
+
processes.set(anonId, proc);
|
|
28571
|
+
completionPromises.push(completionPromise);
|
|
28572
|
+
}
|
|
28573
|
+
let timeoutHandle = null;
|
|
28574
|
+
await Promise.race([
|
|
28575
|
+
Promise.all(completionPromises),
|
|
28576
|
+
new Promise((resolve2) => {
|
|
28577
|
+
timeoutHandle = setTimeout(() => {
|
|
28578
|
+
for (const [id, proc] of processes) {
|
|
28579
|
+
if (!proc.killed) {
|
|
28580
|
+
proc.kill("SIGTERM");
|
|
28581
|
+
updateModelStatus(id, {
|
|
28582
|
+
state: "TIMEOUT",
|
|
28583
|
+
completedAt: new Date().toISOString()
|
|
28584
|
+
});
|
|
28585
|
+
opts.onStatusChange?.(id, statusCache.models[id]);
|
|
28586
|
+
}
|
|
28587
|
+
}
|
|
28588
|
+
resolve2();
|
|
28589
|
+
}, timeoutMs);
|
|
28590
|
+
})
|
|
28591
|
+
]);
|
|
28592
|
+
if (timeoutHandle !== null)
|
|
28593
|
+
clearTimeout(timeoutHandle);
|
|
28594
|
+
process.off("SIGINT", sigintHandler);
|
|
28595
|
+
return statusCache;
|
|
28596
|
+
}
|
|
28597
|
+
async function judgeResponses(sessionPath, opts = {}) {
|
|
28598
|
+
const responseFiles = readdirSync(sessionPath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
28599
|
+
if (responseFiles.length < 2) {
|
|
28600
|
+
throw new Error(`Need at least 2 responses to judge, found ${responseFiles.length}`);
|
|
28601
|
+
}
|
|
28602
|
+
const responses = {};
|
|
28603
|
+
for (const file2 of responseFiles) {
|
|
28604
|
+
const id = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
28605
|
+
responses[id] = readFileSync(join(sessionPath, file2), "utf-8");
|
|
28606
|
+
}
|
|
28607
|
+
const input = readFileSync(join(sessionPath, "input.md"), "utf-8");
|
|
28608
|
+
const judgePrompt = buildJudgePrompt(input, responses);
|
|
28609
|
+
writeFileSync(join(sessionPath, "judge-prompt.md"), judgePrompt, "utf-8");
|
|
28610
|
+
const judgeModels = opts.judges ?? getDefaultJudgeModels(sessionPath);
|
|
28611
|
+
const judgePath = join(sessionPath, "judging");
|
|
28612
|
+
mkdirSync(judgePath, { recursive: true });
|
|
28613
|
+
setupSession(judgePath, judgeModels, judgePrompt);
|
|
28614
|
+
await runModels(judgePath, { claudeFlags: opts.claudeFlags });
|
|
28615
|
+
const votes = parseJudgeVotes(judgePath, Object.keys(responses));
|
|
28616
|
+
const verdict = aggregateVerdict(votes, Object.keys(responses));
|
|
28617
|
+
writeFileSync(join(sessionPath, "verdict.md"), formatVerdict(verdict, sessionPath), "utf-8");
|
|
28618
|
+
return verdict;
|
|
28619
|
+
}
|
|
28620
|
+
function getStatus(sessionPath) {
|
|
28621
|
+
return JSON.parse(readFileSync(join(sessionPath, "status.json"), "utf-8"));
|
|
28622
|
+
}
|
|
28623
|
+
function fisherYatesShuffle(arr) {
|
|
28624
|
+
for (let i = arr.length - 1;i > 0; i--) {
|
|
28625
|
+
const j = Math.floor(Math.random() * (i + 1));
|
|
28626
|
+
[arr[i], arr[j]] = [arr[j], arr[i]];
|
|
28627
|
+
}
|
|
28628
|
+
return arr;
|
|
28629
|
+
}
|
|
28630
|
+
function getDefaultJudgeModels(sessionPath) {
|
|
28631
|
+
const manifest = JSON.parse(readFileSync(join(sessionPath, "manifest.json"), "utf-8"));
|
|
28632
|
+
return Object.values(manifest.models).map((e) => e.model);
|
|
28633
|
+
}
|
|
28634
|
+
function buildJudgePrompt(input, responses) {
|
|
28635
|
+
const ids = Object.keys(responses).sort();
|
|
28636
|
+
let prompt = `## Blind Evaluation Task
|
|
28637
|
+
|
|
28638
|
+
`;
|
|
28639
|
+
prompt += `### Original Task
|
|
28640
|
+
|
|
28641
|
+
`;
|
|
28642
|
+
prompt += input + `
|
|
28643
|
+
|
|
28644
|
+
`;
|
|
28645
|
+
prompt += `---
|
|
28646
|
+
|
|
28647
|
+
`;
|
|
28648
|
+
prompt += `### Responses to Evaluate
|
|
28649
|
+
|
|
28650
|
+
`;
|
|
28651
|
+
prompt += `Evaluate each response independently. You do not know which model produced which response.
|
|
28652
|
+
|
|
28653
|
+
`;
|
|
28654
|
+
for (const id of ids) {
|
|
28655
|
+
prompt += `#### Response ${id}
|
|
28656
|
+
|
|
28657
|
+
`;
|
|
28658
|
+
prompt += responses[id] + `
|
|
28659
|
+
|
|
28660
|
+
`;
|
|
28661
|
+
prompt += `---
|
|
28662
|
+
|
|
28663
|
+
`;
|
|
28664
|
+
}
|
|
28665
|
+
prompt += `### Your Assignment
|
|
28666
|
+
|
|
28667
|
+
`;
|
|
28668
|
+
prompt += `For EACH of the ${ids.length} responses above, provide a vote block in this exact format:
|
|
28669
|
+
|
|
28670
|
+
`;
|
|
28671
|
+
prompt += "```vote\n";
|
|
28672
|
+
prompt += `RESPONSE: [ID]
|
|
28673
|
+
`;
|
|
28674
|
+
prompt += `VERDICT: [APPROVE|REJECT|ABSTAIN]
|
|
28675
|
+
`;
|
|
28676
|
+
prompt += `CONFIDENCE: [1-10]
|
|
28677
|
+
`;
|
|
28678
|
+
prompt += `SUMMARY: [One sentence]
|
|
28679
|
+
`;
|
|
28680
|
+
prompt += `KEY_ISSUES: [Comma-separated issues, or None]
|
|
28681
|
+
`;
|
|
28682
|
+
prompt += "```\n\n";
|
|
28683
|
+
prompt += `Provide exactly ${ids.length} vote blocks, one per response. Be decisive and analytical.
|
|
28684
|
+
`;
|
|
28685
|
+
return prompt;
|
|
28686
|
+
}
|
|
28687
|
+
function parseJudgeVotes(judgePath, responseIds) {
|
|
28688
|
+
const votes = [];
|
|
28689
|
+
const responseFiles = readdirSync(judgePath).filter((f) => f.startsWith("response-") && f.endsWith(".md")).sort();
|
|
28690
|
+
for (const file2 of responseFiles) {
|
|
28691
|
+
const judgeId = file2.replace(/^response-/, "").replace(/\.md$/, "");
|
|
28692
|
+
let content;
|
|
28693
|
+
try {
|
|
28694
|
+
content = readFileSync(join(judgePath, file2), "utf-8");
|
|
28695
|
+
} catch {
|
|
28696
|
+
continue;
|
|
28697
|
+
}
|
|
28698
|
+
const votePattern = /```vote\s*\n([\s\S]*?)\n\s*```/g;
|
|
28699
|
+
let match;
|
|
28700
|
+
while ((match = votePattern.exec(content)) !== null) {
|
|
28701
|
+
const block = match[1];
|
|
28702
|
+
const responseMatch = block.match(/RESPONSE:\s*(\S+)/);
|
|
28703
|
+
const verdictMatch = block.match(/VERDICT:\s*(APPROVE|REJECT|ABSTAIN)/);
|
|
28704
|
+
const confidenceMatch = block.match(/CONFIDENCE:\s*(\d+)/);
|
|
28705
|
+
const summaryMatch = block.match(/SUMMARY:\s*(.+)/);
|
|
28706
|
+
const keyIssuesMatch = block.match(/KEY_ISSUES:\s*(.+)/);
|
|
28707
|
+
const responseId = responseMatch?.[1];
|
|
28708
|
+
const verdict = verdictMatch?.[1];
|
|
28709
|
+
if (!responseId || !verdict)
|
|
28710
|
+
continue;
|
|
28711
|
+
if (!responseIds.includes(responseId))
|
|
28712
|
+
continue;
|
|
28713
|
+
votes.push({
|
|
28714
|
+
judgeId,
|
|
28715
|
+
responseId,
|
|
28716
|
+
verdict,
|
|
28717
|
+
confidence: parseInt(confidenceMatch?.[1] ?? "5", 10),
|
|
28718
|
+
summary: summaryMatch?.[1]?.trim() ?? "",
|
|
28719
|
+
keyIssues: keyIssuesMatch?.[1]?.split(",").map((s) => s.trim()).filter((s) => s.toLowerCase() !== "none" && s.length > 0) ?? []
|
|
28720
|
+
});
|
|
28721
|
+
}
|
|
28722
|
+
}
|
|
28723
|
+
return votes;
|
|
28724
|
+
}
|
|
28725
|
+
function aggregateVerdict(votes, responseIds) {
|
|
28726
|
+
const responses = {};
|
|
28727
|
+
for (const id of responseIds) {
|
|
28728
|
+
const votesForResponse = votes.filter((v) => v.responseId === id);
|
|
28729
|
+
const approvals = votesForResponse.filter((v) => v.verdict === "APPROVE").length;
|
|
28730
|
+
const rejections = votesForResponse.filter((v) => v.verdict === "REJECT").length;
|
|
28731
|
+
const abstentions = votesForResponse.filter((v) => v.verdict === "ABSTAIN").length;
|
|
28732
|
+
const total = approvals + rejections;
|
|
28733
|
+
responses[id] = {
|
|
28734
|
+
approvals,
|
|
28735
|
+
rejections,
|
|
28736
|
+
abstentions,
|
|
28737
|
+
score: total > 0 ? approvals / total : 0
|
|
28738
|
+
};
|
|
28739
|
+
}
|
|
28740
|
+
const ranking = Object.entries(responses).sort(([, a], [, b]) => b.score - a.score).map(([id]) => id);
|
|
28741
|
+
return { responses, ranking, votes };
|
|
28742
|
+
}
|
|
28743
|
+
function formatVerdict(verdict, sessionPath) {
|
|
28744
|
+
let manifest = null;
|
|
28745
|
+
try {
|
|
28746
|
+
manifest = JSON.parse(readFileSync(join(sessionPath, "manifest.json"), "utf-8"));
|
|
28747
|
+
} catch {}
|
|
28748
|
+
let output = `# Team Verdict
|
|
28749
|
+
|
|
28750
|
+
`;
|
|
28751
|
+
output += `## Ranking
|
|
28752
|
+
|
|
28753
|
+
`;
|
|
28754
|
+
output += `| Rank | Response | Model | Score | Approvals | Rejections | Abstentions |
|
|
28755
|
+
`;
|
|
28756
|
+
output += `|------|----------|-------|-------|-----------|------------|-------------|
|
|
28757
|
+
`;
|
|
28758
|
+
for (let i = 0;i < verdict.ranking.length; i++) {
|
|
28759
|
+
const id = verdict.ranking[i];
|
|
28760
|
+
const r = verdict.responses[id];
|
|
28761
|
+
const modelName = manifest?.models[id]?.model ?? "unknown";
|
|
28762
|
+
const scoreStr = `${(r.score * 100).toFixed(0)}%`;
|
|
28763
|
+
output += `| ${i + 1} | ${id} | ${modelName} | ${scoreStr} | ${r.approvals} | ${r.rejections} | ${r.abstentions} |
|
|
28764
|
+
`;
|
|
28765
|
+
}
|
|
28766
|
+
output += `
|
|
28767
|
+
## Individual Votes
|
|
28768
|
+
|
|
28769
|
+
`;
|
|
28770
|
+
for (const vote of verdict.votes) {
|
|
28771
|
+
const issueStr = vote.keyIssues.length > 0 ? ` Issues: ${vote.keyIssues.join(", ")}.` : "";
|
|
28772
|
+
output += `- **Judge ${vote.judgeId}** -> Response ${vote.responseId}: **${vote.verdict}** (${vote.confidence}/10) \u2014 ${vote.summary}${issueStr}
|
|
28773
|
+
`;
|
|
28774
|
+
}
|
|
28775
|
+
return output;
|
|
28776
|
+
}
|
|
28777
|
+
var init_team_orchestrator = () => {};
|
|
28778
|
+
|
|
28419
28779
|
// src/mcp-server.ts
|
|
28420
28780
|
var exports_mcp_server = {};
|
|
28421
28781
|
__export(exports_mcp_server, {
|
|
28422
28782
|
startMcpServer: () => startMcpServer
|
|
28423
28783
|
});
|
|
28424
|
-
import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
|
|
28425
|
-
import { join, dirname } from "path";
|
|
28784
|
+
import { readFileSync as readFileSync2, existsSync as existsSync2, writeFileSync as writeFileSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
28785
|
+
import { join as join2, dirname } from "path";
|
|
28426
28786
|
import { homedir } from "os";
|
|
28427
28787
|
import { fileURLToPath } from "url";
|
|
28428
28788
|
function loadRecommendedModels() {
|
|
28429
|
-
if (
|
|
28789
|
+
if (existsSync2(RECOMMENDED_MODELS_PATH)) {
|
|
28430
28790
|
try {
|
|
28431
|
-
const data = JSON.parse(
|
|
28791
|
+
const data = JSON.parse(readFileSync2(RECOMMENDED_MODELS_PATH, "utf-8"));
|
|
28432
28792
|
return data.models || [];
|
|
28433
28793
|
} catch {
|
|
28434
28794
|
return [];
|
|
@@ -28437,9 +28797,9 @@ function loadRecommendedModels() {
|
|
|
28437
28797
|
return [];
|
|
28438
28798
|
}
|
|
28439
28799
|
async function loadAllModels(forceRefresh = false) {
|
|
28440
|
-
if (!forceRefresh &&
|
|
28800
|
+
if (!forceRefresh && existsSync2(ALL_MODELS_CACHE_PATH)) {
|
|
28441
28801
|
try {
|
|
28442
|
-
const cacheData = JSON.parse(
|
|
28802
|
+
const cacheData = JSON.parse(readFileSync2(ALL_MODELS_CACHE_PATH, "utf-8"));
|
|
28443
28803
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
28444
28804
|
const ageInDays = (Date.now() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
28445
28805
|
if (ageInDays <= CACHE_MAX_AGE_DAYS) {
|
|
@@ -28453,15 +28813,15 @@ async function loadAllModels(forceRefresh = false) {
|
|
|
28453
28813
|
throw new Error(`API returned ${response.status}`);
|
|
28454
28814
|
const data = await response.json();
|
|
28455
28815
|
const models = data.data || [];
|
|
28456
|
-
|
|
28457
|
-
|
|
28816
|
+
mkdirSync2(CLAUDISH_CACHE_DIR, { recursive: true });
|
|
28817
|
+
writeFileSync2(ALL_MODELS_CACHE_PATH, JSON.stringify({
|
|
28458
28818
|
lastUpdated: new Date().toISOString(),
|
|
28459
28819
|
models
|
|
28460
28820
|
}), "utf-8");
|
|
28461
28821
|
return models;
|
|
28462
28822
|
} catch (error46) {
|
|
28463
|
-
if (
|
|
28464
|
-
const cacheData = JSON.parse(
|
|
28823
|
+
if (existsSync2(ALL_MODELS_CACHE_PATH)) {
|
|
28824
|
+
const cacheData = JSON.parse(readFileSync2(ALL_MODELS_CACHE_PATH, "utf-8"));
|
|
28465
28825
|
return cacheData.models || [];
|
|
28466
28826
|
}
|
|
28467
28827
|
return [];
|
|
@@ -28488,7 +28848,7 @@ async function runPrompt(model, prompt, systemPrompt, maxTokens) {
|
|
|
28488
28848
|
body: JSON.stringify({
|
|
28489
28849
|
model,
|
|
28490
28850
|
messages,
|
|
28491
|
-
max_tokens: maxTokens
|
|
28851
|
+
...maxTokens ? { max_tokens: maxTokens } : {}
|
|
28492
28852
|
})
|
|
28493
28853
|
});
|
|
28494
28854
|
if (!response.ok) {
|
|
@@ -28526,7 +28886,7 @@ async function main() {
|
|
|
28526
28886
|
model: exports_external.string().describe("OpenRouter model ID (e.g., 'x-ai/grok-code-fast-1', 'openai/gpt-5.1-codex')"),
|
|
28527
28887
|
prompt: exports_external.string().describe("The prompt to send to the model"),
|
|
28528
28888
|
system_prompt: exports_external.string().optional().describe("Optional system prompt"),
|
|
28529
|
-
max_tokens: exports_external.number().optional().describe("Maximum tokens in response (
|
|
28889
|
+
max_tokens: exports_external.number().optional().describe("Maximum tokens in response (omit to let model decide)")
|
|
28530
28890
|
}, async ({ model, prompt, system_prompt, max_tokens }) => {
|
|
28531
28891
|
try {
|
|
28532
28892
|
const result = await runPrompt(model, prompt, system_prompt, max_tokens);
|
|
@@ -28633,12 +28993,13 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
28633
28993
|
server.tool("compare_models", "Run the same prompt through multiple models and compare responses", {
|
|
28634
28994
|
models: exports_external.array(exports_external.string()).describe("List of model IDs to compare"),
|
|
28635
28995
|
prompt: exports_external.string().describe("The prompt to send to all models"),
|
|
28636
|
-
system_prompt: exports_external.string().optional().describe("Optional system prompt")
|
|
28637
|
-
|
|
28996
|
+
system_prompt: exports_external.string().optional().describe("Optional system prompt"),
|
|
28997
|
+
max_tokens: exports_external.number().optional().describe("Maximum tokens in response (omit to let model decide)")
|
|
28998
|
+
}, async ({ models, prompt, system_prompt, max_tokens }) => {
|
|
28638
28999
|
const results = [];
|
|
28639
29000
|
for (const model of models) {
|
|
28640
29001
|
try {
|
|
28641
|
-
const result = await runPrompt(model, prompt, system_prompt,
|
|
29002
|
+
const result = await runPrompt(model, prompt, system_prompt, max_tokens);
|
|
28642
29003
|
results.push({
|
|
28643
29004
|
model,
|
|
28644
29005
|
response: result.content,
|
|
@@ -28682,6 +29043,93 @@ Use with: run_prompt(model="${results[0].model.id}", prompt="your prompt")`;
|
|
|
28682
29043
|
}
|
|
28683
29044
|
return { content: [{ type: "text", text: output }] };
|
|
28684
29045
|
});
|
|
29046
|
+
server.tool("team_run", "Run multiple AI models on a task and produce anonymized outputs in a session directory", {
|
|
29047
|
+
path: exports_external.string().describe("Session directory path (must be within current working directory)"),
|
|
29048
|
+
models: exports_external.array(exports_external.string()).describe("Model IDs to run (e.g., ['minimax-m2.5', 'kimi-k2.5'])"),
|
|
29049
|
+
input: exports_external.string().optional().describe("Task prompt text (or place input.md in the session directory before calling)"),
|
|
29050
|
+
timeout: exports_external.number().optional().describe("Per-model timeout in seconds (default: 300)")
|
|
29051
|
+
}, async ({ path, models, input, timeout }) => {
|
|
29052
|
+
try {
|
|
29053
|
+
const resolved = validateSessionPath(path);
|
|
29054
|
+
setupSession(resolved, models, input);
|
|
29055
|
+
const status = await runModels(resolved, { timeout });
|
|
29056
|
+
return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }] };
|
|
29057
|
+
} catch (error46) {
|
|
29058
|
+
return {
|
|
29059
|
+
content: [
|
|
29060
|
+
{
|
|
29061
|
+
type: "text",
|
|
29062
|
+
text: `Error: ${error46 instanceof Error ? error46.message : String(error46)}`
|
|
29063
|
+
}
|
|
29064
|
+
],
|
|
29065
|
+
isError: true
|
|
29066
|
+
};
|
|
29067
|
+
}
|
|
29068
|
+
});
|
|
29069
|
+
server.tool("team_judge", "Blind-judge existing anonymized model outputs in a session directory", {
|
|
29070
|
+
path: exports_external.string().describe("Session directory containing response-*.md files (must be within current working directory)"),
|
|
29071
|
+
judges: exports_external.array(exports_external.string()).optional().describe("Model IDs to use as judges (default: same models that produced the responses)")
|
|
29072
|
+
}, async ({ path, judges }) => {
|
|
29073
|
+
try {
|
|
29074
|
+
const resolved = validateSessionPath(path);
|
|
29075
|
+
const verdict = await judgeResponses(resolved, { judges });
|
|
29076
|
+
return { content: [{ type: "text", text: JSON.stringify(verdict, null, 2) }] };
|
|
29077
|
+
} catch (error46) {
|
|
29078
|
+
return {
|
|
29079
|
+
content: [
|
|
29080
|
+
{
|
|
29081
|
+
type: "text",
|
|
29082
|
+
text: `Error: ${error46 instanceof Error ? error46.message : String(error46)}`
|
|
29083
|
+
}
|
|
29084
|
+
],
|
|
29085
|
+
isError: true
|
|
29086
|
+
};
|
|
29087
|
+
}
|
|
29088
|
+
});
|
|
29089
|
+
server.tool("team_run_and_judge", "Run multiple AI models on a task, then blind-judge their outputs \u2014 full pipeline", {
|
|
29090
|
+
path: exports_external.string().describe("Session directory path (must be within current working directory)"),
|
|
29091
|
+
models: exports_external.array(exports_external.string()).describe("Model IDs to run"),
|
|
29092
|
+
judges: exports_external.array(exports_external.string()).optional().describe("Model IDs to use as judges (default: same as runners)"),
|
|
29093
|
+
input: exports_external.string().optional().describe("Task prompt text"),
|
|
29094
|
+
timeout: exports_external.number().optional().describe("Per-model timeout in seconds (default: 300)")
|
|
29095
|
+
}, async ({ path, models, judges, input, timeout }) => {
|
|
29096
|
+
try {
|
|
29097
|
+
const resolved = validateSessionPath(path);
|
|
29098
|
+
setupSession(resolved, models, input);
|
|
29099
|
+
await runModels(resolved, { timeout });
|
|
29100
|
+
const verdict = await judgeResponses(resolved, { judges });
|
|
29101
|
+
return { content: [{ type: "text", text: JSON.stringify(verdict, null, 2) }] };
|
|
29102
|
+
} catch (error46) {
|
|
29103
|
+
return {
|
|
29104
|
+
content: [
|
|
29105
|
+
{
|
|
29106
|
+
type: "text",
|
|
29107
|
+
text: `Error: ${error46 instanceof Error ? error46.message : String(error46)}`
|
|
29108
|
+
}
|
|
29109
|
+
],
|
|
29110
|
+
isError: true
|
|
29111
|
+
};
|
|
29112
|
+
}
|
|
29113
|
+
});
|
|
29114
|
+
server.tool("team_status", "Check the execution status of a team orchestrator session", {
|
|
29115
|
+
path: exports_external.string().describe("Session directory path (must be within current working directory)")
|
|
29116
|
+
}, async ({ path }) => {
|
|
29117
|
+
try {
|
|
29118
|
+
const resolved = validateSessionPath(path);
|
|
29119
|
+
const status = getStatus(resolved);
|
|
29120
|
+
return { content: [{ type: "text", text: JSON.stringify(status, null, 2) }] };
|
|
29121
|
+
} catch (error46) {
|
|
29122
|
+
return {
|
|
29123
|
+
content: [
|
|
29124
|
+
{
|
|
29125
|
+
type: "text",
|
|
29126
|
+
text: `Error: ${error46 instanceof Error ? error46.message : String(error46)}`
|
|
29127
|
+
}
|
|
29128
|
+
],
|
|
29129
|
+
isError: true
|
|
29130
|
+
};
|
|
29131
|
+
}
|
|
29132
|
+
});
|
|
28685
29133
|
const transport = new StdioServerTransport;
|
|
28686
29134
|
await server.connect(transport);
|
|
28687
29135
|
console.error("[claudish] MCP server started");
|
|
@@ -28697,19 +29145,21 @@ var init_mcp_server = __esm(() => {
|
|
|
28697
29145
|
init_mcp();
|
|
28698
29146
|
init_stdio2();
|
|
28699
29147
|
init_zod();
|
|
29148
|
+
init_team_orchestrator();
|
|
28700
29149
|
import_dotenv = __toESM(require_main(), 1);
|
|
28701
29150
|
import_dotenv.config();
|
|
28702
29151
|
__filename2 = fileURLToPath(import.meta.url);
|
|
28703
29152
|
__dirname2 = dirname(__filename2);
|
|
28704
|
-
RECOMMENDED_MODELS_PATH =
|
|
28705
|
-
CLAUDISH_CACHE_DIR =
|
|
28706
|
-
ALL_MODELS_CACHE_PATH =
|
|
29153
|
+
RECOMMENDED_MODELS_PATH = join2(__dirname2, "../recommended-models.json");
|
|
29154
|
+
CLAUDISH_CACHE_DIR = join2(homedir(), ".claudish");
|
|
29155
|
+
ALL_MODELS_CACHE_PATH = join2(CLAUDISH_CACHE_DIR, "all-models.json");
|
|
28707
29156
|
});
|
|
28708
29157
|
|
|
28709
29158
|
// src/logger.ts
|
|
28710
29159
|
var exports_logger = {};
|
|
28711
29160
|
__export(exports_logger, {
|
|
28712
29161
|
truncateContent: () => truncateContent,
|
|
29162
|
+
structuralRedact: () => structuralRedact,
|
|
28713
29163
|
setStderrQuiet: () => setStderrQuiet,
|
|
28714
29164
|
setLogLevel: () => setLogLevel,
|
|
28715
29165
|
maskCredential: () => maskCredential,
|
|
@@ -28719,10 +29169,12 @@ __export(exports_logger, {
|
|
|
28719
29169
|
isLoggingEnabled: () => isLoggingEnabled,
|
|
28720
29170
|
initLogger: () => initLogger,
|
|
28721
29171
|
getLogLevel: () => getLogLevel,
|
|
28722
|
-
getLogFilePath: () => getLogFilePath
|
|
29172
|
+
getLogFilePath: () => getLogFilePath,
|
|
29173
|
+
getAlwaysOnLogPath: () => getAlwaysOnLogPath
|
|
28723
29174
|
});
|
|
28724
|
-
import { writeFileSync as
|
|
28725
|
-
import { join as
|
|
29175
|
+
import { writeFileSync as writeFileSync3, appendFile, existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync2, unlinkSync } from "fs";
|
|
29176
|
+
import { join as join3 } from "path";
|
|
29177
|
+
import { homedir as homedir2 } from "os";
|
|
28726
29178
|
function flushLogBuffer() {
|
|
28727
29179
|
if (!logFilePath || logBuffer.length === 0)
|
|
28728
29180
|
return;
|
|
@@ -28734,11 +29186,19 @@ function flushLogBuffer() {
|
|
|
28734
29186
|
}
|
|
28735
29187
|
});
|
|
28736
29188
|
}
|
|
29189
|
+
function flushAlwaysOnBuffer() {
|
|
29190
|
+
if (!alwaysOnLogPath || alwaysOnBuffer.length === 0)
|
|
29191
|
+
return;
|
|
29192
|
+
const toWrite = alwaysOnBuffer.join("");
|
|
29193
|
+
alwaysOnBuffer = [];
|
|
29194
|
+
appendFile(alwaysOnLogPath, toWrite, () => {});
|
|
29195
|
+
}
|
|
28737
29196
|
function scheduleFlush() {
|
|
28738
29197
|
if (flushTimer)
|
|
28739
29198
|
return;
|
|
28740
29199
|
flushTimer = setInterval(() => {
|
|
28741
29200
|
flushLogBuffer();
|
|
29201
|
+
flushAlwaysOnBuffer();
|
|
28742
29202
|
}, FLUSH_INTERVAL_MS);
|
|
28743
29203
|
process.on("exit", () => {
|
|
28744
29204
|
if (flushTimer) {
|
|
@@ -28746,33 +29206,106 @@ function scheduleFlush() {
|
|
|
28746
29206
|
flushTimer = null;
|
|
28747
29207
|
}
|
|
28748
29208
|
if (logFilePath && logBuffer.length > 0) {
|
|
28749
|
-
|
|
29209
|
+
writeFileSync3(logFilePath, logBuffer.join(""), { flag: "a" });
|
|
28750
29210
|
logBuffer = [];
|
|
28751
29211
|
}
|
|
29212
|
+
if (alwaysOnLogPath && alwaysOnBuffer.length > 0) {
|
|
29213
|
+
writeFileSync3(alwaysOnLogPath, alwaysOnBuffer.join(""), { flag: "a" });
|
|
29214
|
+
alwaysOnBuffer = [];
|
|
29215
|
+
}
|
|
28752
29216
|
});
|
|
28753
29217
|
}
|
|
28754
|
-
function
|
|
28755
|
-
|
|
28756
|
-
|
|
28757
|
-
|
|
28758
|
-
|
|
28759
|
-
|
|
29218
|
+
function rotateOldLogs(dir, keep) {
|
|
29219
|
+
try {
|
|
29220
|
+
const files = readdirSync2(dir).filter((f) => f.startsWith("claudish_") && f.endsWith(".log")).sort().reverse();
|
|
29221
|
+
for (const file2 of files.slice(keep)) {
|
|
29222
|
+
try {
|
|
29223
|
+
unlinkSync(join3(dir, file2));
|
|
29224
|
+
} catch {}
|
|
28760
29225
|
}
|
|
28761
|
-
|
|
29226
|
+
} catch {}
|
|
29227
|
+
}
|
|
29228
|
+
function structuralRedact(jsonStr) {
|
|
29229
|
+
try {
|
|
29230
|
+
const obj = JSON.parse(jsonStr);
|
|
29231
|
+
return JSON.stringify(redactDeep(obj));
|
|
29232
|
+
} catch {
|
|
29233
|
+
return jsonStr.replace(/"[^"]{20,}"/g, (m) => `"<${m.length - 2} chars>"`);
|
|
28762
29234
|
}
|
|
28763
|
-
|
|
28764
|
-
|
|
28765
|
-
if (
|
|
28766
|
-
|
|
29235
|
+
}
|
|
29236
|
+
function redactDeep(val, key) {
|
|
29237
|
+
if (val === null || val === undefined)
|
|
29238
|
+
return val;
|
|
29239
|
+
if (typeof val === "boolean" || typeof val === "number")
|
|
29240
|
+
return val;
|
|
29241
|
+
if (typeof val === "string") {
|
|
29242
|
+
if (key && CONTENT_KEYS.has(key)) {
|
|
29243
|
+
return `<${val.length} chars>`;
|
|
29244
|
+
}
|
|
29245
|
+
return val.length <= 20 ? val : `<${val.length} chars>`;
|
|
29246
|
+
}
|
|
29247
|
+
if (Array.isArray(val))
|
|
29248
|
+
return val.map((v) => redactDeep(v));
|
|
29249
|
+
if (typeof val === "object") {
|
|
29250
|
+
const result = {};
|
|
29251
|
+
for (const [k, v] of Object.entries(val)) {
|
|
29252
|
+
result[k] = redactDeep(v, k);
|
|
29253
|
+
}
|
|
29254
|
+
return result;
|
|
29255
|
+
}
|
|
29256
|
+
return val;
|
|
29257
|
+
}
|
|
29258
|
+
function isStructuralLogWorthy(msg) {
|
|
29259
|
+
return msg.startsWith("[SSE:") || msg.startsWith("[Proxy]") || msg.startsWith("[Fallback]") || msg.startsWith("[Streaming] ===") || msg.startsWith("[Streaming] Chunk:") || msg.startsWith("[Streaming] Received") || msg.startsWith("[Streaming] Text-based tool calls") || msg.startsWith("[Streaming] Final usage") || msg.startsWith("[Streaming] Sending") || msg.startsWith("[AnthropicSSE] Stream complete") || msg.startsWith("[AnthropicSSE] Tool use:") || msg.includes("Response status:") || msg.includes("Error") || msg.includes("error") || msg.includes("[Auto-route]");
|
|
29260
|
+
}
|
|
29261
|
+
function redactLogLine(message, timestamp) {
|
|
29262
|
+
if (message.startsWith("[SSE:")) {
|
|
29263
|
+
const prefixEnd = message.indexOf("] ") + 2;
|
|
29264
|
+
const prefix = message.substring(0, prefixEnd);
|
|
29265
|
+
const payload = message.substring(prefixEnd);
|
|
29266
|
+
return `[${timestamp}] ${prefix}${structuralRedact(payload)}
|
|
29267
|
+
`;
|
|
28767
29268
|
}
|
|
28768
|
-
|
|
28769
|
-
|
|
28770
|
-
|
|
29269
|
+
return `[${timestamp}] ${message}
|
|
29270
|
+
`;
|
|
29271
|
+
}
|
|
29272
|
+
function initLogger(debugMode, level = "info", noLogs = false) {
|
|
29273
|
+
if (!noLogs) {
|
|
29274
|
+
const logsDir = join3(homedir2(), ".claudish", "logs");
|
|
29275
|
+
if (!existsSync3(logsDir)) {
|
|
29276
|
+
mkdirSync3(logsDir, { recursive: true });
|
|
29277
|
+
}
|
|
29278
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").split("T").join("_").slice(0, -5);
|
|
29279
|
+
alwaysOnLogPath = join3(logsDir, `claudish_${timestamp}.log`);
|
|
29280
|
+
writeFileSync3(alwaysOnLogPath, `Claudish Session Log - ${new Date().toISOString()}
|
|
29281
|
+
Mode: structural (content redacted)
|
|
29282
|
+
${"=".repeat(60)}
|
|
29283
|
+
|
|
29284
|
+
`);
|
|
29285
|
+
rotateOldLogs(logsDir, 20);
|
|
29286
|
+
scheduleFlush();
|
|
29287
|
+
}
|
|
29288
|
+
if (debugMode) {
|
|
29289
|
+
logLevel = level;
|
|
29290
|
+
const logsDir = join3(process.cwd(), "logs");
|
|
29291
|
+
if (!existsSync3(logsDir)) {
|
|
29292
|
+
mkdirSync3(logsDir, { recursive: true });
|
|
29293
|
+
}
|
|
29294
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, "-").split("T").join("_").slice(0, -5);
|
|
29295
|
+
logFilePath = join3(logsDir, `claudish_${timestamp}.log`);
|
|
29296
|
+
writeFileSync3(logFilePath, `Claudish Debug Log - ${new Date().toISOString()}
|
|
28771
29297
|
Log Level: ${level}
|
|
28772
29298
|
${"=".repeat(80)}
|
|
28773
29299
|
|
|
28774
29300
|
`);
|
|
28775
|
-
|
|
29301
|
+
scheduleFlush();
|
|
29302
|
+
} else {
|
|
29303
|
+
logFilePath = null;
|
|
29304
|
+
if (noLogs && flushTimer) {
|
|
29305
|
+
clearInterval(flushTimer);
|
|
29306
|
+
flushTimer = null;
|
|
29307
|
+
}
|
|
29308
|
+
}
|
|
28776
29309
|
}
|
|
28777
29310
|
function log(message, forceConsole = false) {
|
|
28778
29311
|
const timestamp = new Date().toISOString();
|
|
@@ -28784,6 +29317,13 @@ function log(message, forceConsole = false) {
|
|
|
28784
29317
|
flushLogBuffer();
|
|
28785
29318
|
}
|
|
28786
29319
|
}
|
|
29320
|
+
if (alwaysOnLogPath && isStructuralLogWorthy(message)) {
|
|
29321
|
+
const redactedLine = redactLogLine(message, timestamp);
|
|
29322
|
+
alwaysOnBuffer.push(redactedLine);
|
|
29323
|
+
if (alwaysOnBuffer.length >= MAX_BUFFER_SIZE) {
|
|
29324
|
+
flushAlwaysOnBuffer();
|
|
29325
|
+
}
|
|
29326
|
+
}
|
|
28787
29327
|
if (forceConsole) {
|
|
28788
29328
|
console.log(message);
|
|
28789
29329
|
}
|
|
@@ -28801,8 +29341,11 @@ function setStderrQuiet(quiet) {
|
|
|
28801
29341
|
function getLogFilePath() {
|
|
28802
29342
|
return logFilePath;
|
|
28803
29343
|
}
|
|
29344
|
+
function getAlwaysOnLogPath() {
|
|
29345
|
+
return alwaysOnLogPath;
|
|
29346
|
+
}
|
|
28804
29347
|
function isLoggingEnabled() {
|
|
28805
|
-
return logFilePath !== null;
|
|
29348
|
+
return logFilePath !== null || alwaysOnLogPath !== null;
|
|
28806
29349
|
}
|
|
28807
29350
|
function maskCredential(credential) {
|
|
28808
29351
|
if (!credential || credential.length <= 8) {
|
|
@@ -28849,9 +29392,19 @@ function logStructured(label, data) {
|
|
|
28849
29392
|
}
|
|
28850
29393
|
log(`[${label}] ${JSON.stringify(data, null, 2)}`);
|
|
28851
29394
|
}
|
|
28852
|
-
var logFilePath = null, logLevel = "info", stderrQuiet = false, logBuffer, flushTimer = null, FLUSH_INTERVAL_MS = 100, MAX_BUFFER_SIZE = 50;
|
|
29395
|
+
var logFilePath = null, logLevel = "info", stderrQuiet = false, logBuffer, flushTimer = null, FLUSH_INTERVAL_MS = 100, MAX_BUFFER_SIZE = 50, alwaysOnLogPath = null, alwaysOnBuffer, CONTENT_KEYS;
|
|
28853
29396
|
var init_logger = __esm(() => {
|
|
28854
29397
|
logBuffer = [];
|
|
29398
|
+
alwaysOnBuffer = [];
|
|
29399
|
+
CONTENT_KEYS = new Set([
|
|
29400
|
+
"content",
|
|
29401
|
+
"reasoning_content",
|
|
29402
|
+
"text",
|
|
29403
|
+
"thinking",
|
|
29404
|
+
"partial_json",
|
|
29405
|
+
"arguments",
|
|
29406
|
+
"input"
|
|
29407
|
+
]);
|
|
28855
29408
|
});
|
|
28856
29409
|
|
|
28857
29410
|
// src/auth/gemini-oauth.ts
|
|
@@ -28864,9 +29417,9 @@ __export(exports_gemini_oauth, {
|
|
|
28864
29417
|
});
|
|
28865
29418
|
import { createServer } from "http";
|
|
28866
29419
|
import { randomBytes, createHash } from "crypto";
|
|
28867
|
-
import { readFileSync as
|
|
28868
|
-
import { homedir as
|
|
28869
|
-
import { join as
|
|
29420
|
+
import { readFileSync as readFileSync3, existsSync as existsSync4, unlinkSync as unlinkSync2, openSync, writeSync, closeSync } from "fs";
|
|
29421
|
+
import { homedir as homedir3 } from "os";
|
|
29422
|
+
import { join as join4 } from "path";
|
|
28870
29423
|
import { exec } from "child_process";
|
|
28871
29424
|
import { promisify } from "util";
|
|
28872
29425
|
|
|
@@ -28889,8 +29442,8 @@ class GeminiOAuth {
|
|
|
28889
29442
|
return this.credentials !== null && !!this.credentials.refresh_token;
|
|
28890
29443
|
}
|
|
28891
29444
|
getCredentialsPath() {
|
|
28892
|
-
const claudishDir =
|
|
28893
|
-
return
|
|
29445
|
+
const claudishDir = join4(homedir3(), ".claudish");
|
|
29446
|
+
return join4(claudishDir, "gemini-oauth.json");
|
|
28894
29447
|
}
|
|
28895
29448
|
async login() {
|
|
28896
29449
|
log("[GeminiOAuth] Starting OAuth login flow");
|
|
@@ -28911,8 +29464,8 @@ class GeminiOAuth {
|
|
|
28911
29464
|
}
|
|
28912
29465
|
async logout() {
|
|
28913
29466
|
const credPath = this.getCredentialsPath();
|
|
28914
|
-
if (
|
|
28915
|
-
|
|
29467
|
+
if (existsSync4(credPath)) {
|
|
29468
|
+
unlinkSync2(credPath);
|
|
28916
29469
|
log("[GeminiOAuth] Credentials deleted");
|
|
28917
29470
|
}
|
|
28918
29471
|
this.credentials = null;
|
|
@@ -28988,11 +29541,11 @@ Details: ${e.message}`);
|
|
|
28988
29541
|
}
|
|
28989
29542
|
loadCredentials() {
|
|
28990
29543
|
const credPath = this.getCredentialsPath();
|
|
28991
|
-
if (!
|
|
29544
|
+
if (!existsSync4(credPath)) {
|
|
28992
29545
|
return null;
|
|
28993
29546
|
}
|
|
28994
29547
|
try {
|
|
28995
|
-
const data =
|
|
29548
|
+
const data = readFileSync3(credPath, "utf-8");
|
|
28996
29549
|
const credentials = JSON.parse(data);
|
|
28997
29550
|
if (!credentials.access_token || !credentials.refresh_token || !credentials.expires_at) {
|
|
28998
29551
|
log("[GeminiOAuth] Invalid credentials file structure");
|
|
@@ -29007,10 +29560,10 @@ Details: ${e.message}`);
|
|
|
29007
29560
|
}
|
|
29008
29561
|
saveCredentials(credentials) {
|
|
29009
29562
|
const credPath = this.getCredentialsPath();
|
|
29010
|
-
const claudishDir =
|
|
29011
|
-
if (!
|
|
29012
|
-
const { mkdirSync:
|
|
29013
|
-
|
|
29563
|
+
const claudishDir = join4(homedir3(), ".claudish");
|
|
29564
|
+
if (!existsSync4(claudishDir)) {
|
|
29565
|
+
const { mkdirSync: mkdirSync4 } = __require("fs");
|
|
29566
|
+
mkdirSync4(claudishDir, { recursive: true });
|
|
29014
29567
|
}
|
|
29015
29568
|
const fd = openSync(credPath, "w", 384);
|
|
29016
29569
|
try {
|
|
@@ -29043,7 +29596,7 @@ Details: ${e.message}`);
|
|
|
29043
29596
|
return `${OAUTH_CONFIG.authUrl}?${params.toString()}`;
|
|
29044
29597
|
}
|
|
29045
29598
|
async startCallbackServer(codeChallenge, state) {
|
|
29046
|
-
return new Promise((
|
|
29599
|
+
return new Promise((resolve2, reject) => {
|
|
29047
29600
|
let redirectUri = "";
|
|
29048
29601
|
const server = createServer((req, res) => {
|
|
29049
29602
|
const url2 = new URL(req.url, redirectUri.replace("/callback", ""));
|
|
@@ -29106,7 +29659,7 @@ Details: ${e.message}`);
|
|
|
29106
29659
|
</html>
|
|
29107
29660
|
`);
|
|
29108
29661
|
server.close();
|
|
29109
|
-
|
|
29662
|
+
resolve2({ authCode: code, redirectUri });
|
|
29110
29663
|
} else {
|
|
29111
29664
|
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
29112
29665
|
res.end("Not found");
|
|
@@ -29322,9 +29875,9 @@ __export(exports_kimi_oauth, {
|
|
|
29322
29875
|
KimiOAuth: () => KimiOAuth
|
|
29323
29876
|
});
|
|
29324
29877
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
29325
|
-
import { readFileSync as
|
|
29326
|
-
import { homedir as
|
|
29327
|
-
import { join as
|
|
29878
|
+
import { readFileSync as readFileSync4, existsSync as existsSync5, unlinkSync as unlinkSync3, openSync as openSync2, writeSync as writeSync2, closeSync as closeSync2 } from "fs";
|
|
29879
|
+
import { homedir as homedir4, hostname as hostname3, platform, release } from "os";
|
|
29880
|
+
import { join as join5 } from "path";
|
|
29328
29881
|
import { exec as exec2 } from "child_process";
|
|
29329
29882
|
import { promisify as promisify2 } from "util";
|
|
29330
29883
|
|
|
@@ -29349,23 +29902,23 @@ class KimiOAuth {
|
|
|
29349
29902
|
return this.credentials !== null && !!this.credentials.refresh_token;
|
|
29350
29903
|
}
|
|
29351
29904
|
getCredentialsPath() {
|
|
29352
|
-
const claudishDir =
|
|
29353
|
-
return
|
|
29905
|
+
const claudishDir = join5(homedir4(), ".claudish");
|
|
29906
|
+
return join5(claudishDir, "kimi-oauth.json");
|
|
29354
29907
|
}
|
|
29355
29908
|
getDeviceIdPath() {
|
|
29356
|
-
const claudishDir =
|
|
29357
|
-
return
|
|
29909
|
+
const claudishDir = join5(homedir4(), ".claudish");
|
|
29910
|
+
return join5(claudishDir, "kimi-device-id");
|
|
29358
29911
|
}
|
|
29359
29912
|
loadOrCreateDeviceId() {
|
|
29360
29913
|
const deviceIdPath = this.getDeviceIdPath();
|
|
29361
|
-
const claudishDir =
|
|
29362
|
-
if (!
|
|
29363
|
-
const { mkdirSync:
|
|
29364
|
-
|
|
29914
|
+
const claudishDir = join5(homedir4(), ".claudish");
|
|
29915
|
+
if (!existsSync5(claudishDir)) {
|
|
29916
|
+
const { mkdirSync: mkdirSync4 } = __require("fs");
|
|
29917
|
+
mkdirSync4(claudishDir, { recursive: true });
|
|
29365
29918
|
}
|
|
29366
|
-
if (
|
|
29919
|
+
if (existsSync5(deviceIdPath)) {
|
|
29367
29920
|
try {
|
|
29368
|
-
const deviceId2 =
|
|
29921
|
+
const deviceId2 = readFileSync4(deviceIdPath, "utf-8").trim();
|
|
29369
29922
|
if (deviceId2) {
|
|
29370
29923
|
return deviceId2;
|
|
29371
29924
|
}
|
|
@@ -29389,7 +29942,7 @@ class KimiOAuth {
|
|
|
29389
29942
|
}
|
|
29390
29943
|
getVersion() {
|
|
29391
29944
|
try {
|
|
29392
|
-
const packageJson = JSON.parse(
|
|
29945
|
+
const packageJson = JSON.parse(readFileSync4(join5(__dirname, "../../package.json"), "utf-8"));
|
|
29393
29946
|
return packageJson.version;
|
|
29394
29947
|
} catch {
|
|
29395
29948
|
return "4.0.6";
|
|
@@ -29467,7 +30020,7 @@ Waiting for authorization...`);
|
|
|
29467
30020
|
const timeoutMs = expiresIn * 1000;
|
|
29468
30021
|
let currentInterval = interval * 1000;
|
|
29469
30022
|
while (Date.now() - startTime < timeoutMs) {
|
|
29470
|
-
await new Promise((
|
|
30023
|
+
await new Promise((resolve2) => setTimeout(resolve2, currentInterval));
|
|
29471
30024
|
const result = await this.pollForTokenWithRetry(deviceCode);
|
|
29472
30025
|
if (result.error) {
|
|
29473
30026
|
if (result.error === "authorization_pending") {
|
|
@@ -29517,7 +30070,7 @@ Waiting for authorization...`);
|
|
|
29517
30070
|
} catch (e) {
|
|
29518
30071
|
if (retryCount < maxRetries) {
|
|
29519
30072
|
log(`[KimiOAuth] Network error during polling (attempt ${retryCount + 1}/${maxRetries}), retrying in ${backoffMs}ms...`);
|
|
29520
|
-
await new Promise((
|
|
30073
|
+
await new Promise((resolve2) => setTimeout(resolve2, backoffMs));
|
|
29521
30074
|
return this.pollForTokenWithRetry(deviceCode, retryCount + 1);
|
|
29522
30075
|
}
|
|
29523
30076
|
throw new Error(`Network error during token polling: ${e.message}`);
|
|
@@ -29539,8 +30092,8 @@ Waiting for authorization...`);
|
|
|
29539
30092
|
}
|
|
29540
30093
|
async logout() {
|
|
29541
30094
|
const credPath = this.getCredentialsPath();
|
|
29542
|
-
if (
|
|
29543
|
-
|
|
30095
|
+
if (existsSync5(credPath)) {
|
|
30096
|
+
unlinkSync3(credPath);
|
|
29544
30097
|
log("[KimiOAuth] Credentials deleted");
|
|
29545
30098
|
}
|
|
29546
30099
|
this.credentials = null;
|
|
@@ -29606,8 +30159,8 @@ Waiting for authorization...`);
|
|
|
29606
30159
|
} catch (e) {
|
|
29607
30160
|
log(`[KimiOAuth] Refresh failed: ${e.message}`);
|
|
29608
30161
|
const credPath = this.getCredentialsPath();
|
|
29609
|
-
if (
|
|
29610
|
-
|
|
30162
|
+
if (existsSync5(credPath)) {
|
|
30163
|
+
unlinkSync3(credPath);
|
|
29611
30164
|
}
|
|
29612
30165
|
this.credentials = null;
|
|
29613
30166
|
if (process.env.MOONSHOT_API_KEY || process.env.KIMI_API_KEY) {
|
|
@@ -29623,11 +30176,11 @@ Waiting for authorization...`);
|
|
|
29623
30176
|
}
|
|
29624
30177
|
loadCredentials() {
|
|
29625
30178
|
const credPath = this.getCredentialsPath();
|
|
29626
|
-
if (!
|
|
30179
|
+
if (!existsSync5(credPath)) {
|
|
29627
30180
|
return null;
|
|
29628
30181
|
}
|
|
29629
30182
|
try {
|
|
29630
|
-
const data =
|
|
30183
|
+
const data = readFileSync4(credPath, "utf-8");
|
|
29631
30184
|
const credentials = JSON.parse(data);
|
|
29632
30185
|
if (!credentials.access_token || !credentials.refresh_token || !credentials.expires_at || !credentials.scope || !credentials.token_type) {
|
|
29633
30186
|
log("[KimiOAuth] Invalid credentials file structure");
|
|
@@ -29642,10 +30195,10 @@ Waiting for authorization...`);
|
|
|
29642
30195
|
}
|
|
29643
30196
|
saveCredentials(credentials) {
|
|
29644
30197
|
const credPath = this.getCredentialsPath();
|
|
29645
|
-
const claudishDir =
|
|
29646
|
-
if (!
|
|
29647
|
-
const { mkdirSync:
|
|
29648
|
-
|
|
30198
|
+
const claudishDir = join5(homedir4(), ".claudish");
|
|
30199
|
+
if (!existsSync5(claudishDir)) {
|
|
30200
|
+
const { mkdirSync: mkdirSync4 } = __require("fs");
|
|
30201
|
+
mkdirSync4(claudishDir, { recursive: true });
|
|
29649
30202
|
}
|
|
29650
30203
|
const fd = openSync2(credPath, "w", 384);
|
|
29651
30204
|
try {
|
|
@@ -29666,10 +30219,10 @@ async function getValidKimiAccessToken() {
|
|
|
29666
30219
|
}
|
|
29667
30220
|
function hasKimiOAuthCredentials() {
|
|
29668
30221
|
try {
|
|
29669
|
-
const credPath =
|
|
29670
|
-
if (!
|
|
30222
|
+
const credPath = join5(homedir4(), ".claudish", "kimi-oauth.json");
|
|
30223
|
+
if (!existsSync5(credPath))
|
|
29671
30224
|
return false;
|
|
29672
|
-
const data = JSON.parse(
|
|
30225
|
+
const data = JSON.parse(readFileSync4(credPath, "utf-8"));
|
|
29673
30226
|
const now = Date.now();
|
|
29674
30227
|
const bufferMs = 5 * 60 * 1000;
|
|
29675
30228
|
return !!(data.access_token && data.refresh_token && data.expires_at && data.expires_at > now + bufferMs);
|
|
@@ -29732,24 +30285,24 @@ var init_config = __esm(() => {
|
|
|
29732
30285
|
});
|
|
29733
30286
|
|
|
29734
30287
|
// src/model-loader.ts
|
|
29735
|
-
import { readFileSync as
|
|
29736
|
-
import { join as
|
|
30288
|
+
import { readFileSync as readFileSync5, existsSync as existsSync6, writeFileSync as writeFileSync4, mkdirSync as mkdirSync4 } from "fs";
|
|
30289
|
+
import { join as join6, dirname as dirname2 } from "path";
|
|
29737
30290
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
29738
|
-
import { homedir as
|
|
30291
|
+
import { homedir as homedir5 } from "os";
|
|
29739
30292
|
import { createHash as createHash2 } from "crypto";
|
|
29740
30293
|
function getRecommendedModelsPath() {
|
|
29741
|
-
return
|
|
30294
|
+
return join6(__dirname3, "../recommended-models.json");
|
|
29742
30295
|
}
|
|
29743
30296
|
function loadRecommendedModelsJSON() {
|
|
29744
30297
|
if (_cachedRecommendedModels) {
|
|
29745
30298
|
return _cachedRecommendedModels;
|
|
29746
30299
|
}
|
|
29747
30300
|
const jsonPath = getRecommendedModelsPath();
|
|
29748
|
-
if (!
|
|
30301
|
+
if (!existsSync6(jsonPath)) {
|
|
29749
30302
|
throw new Error(`recommended-models.json not found at ${jsonPath}. ` + `Run 'claudish --update-models' to fetch the latest model list.`);
|
|
29750
30303
|
}
|
|
29751
30304
|
try {
|
|
29752
|
-
const jsonContent =
|
|
30305
|
+
const jsonContent = readFileSync5(jsonPath, "utf-8");
|
|
29753
30306
|
_cachedRecommendedModels = JSON.parse(jsonContent);
|
|
29754
30307
|
return _cachedRecommendedModels;
|
|
29755
30308
|
} catch (error46) {
|
|
@@ -29807,11 +30360,11 @@ async function ensureOpenRouterModelsLoaded() {
|
|
|
29807
30360
|
}
|
|
29808
30361
|
async function fetchLiteLLMModels(baseUrl, apiKey, forceUpdate = false) {
|
|
29809
30362
|
const hash2 = createHash2("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
29810
|
-
const cacheDir =
|
|
29811
|
-
const cachePath =
|
|
29812
|
-
if (!forceUpdate &&
|
|
30363
|
+
const cacheDir = join6(homedir5(), ".claudish");
|
|
30364
|
+
const cachePath = join6(cacheDir, `litellm-models-${hash2}.json`);
|
|
30365
|
+
if (!forceUpdate && existsSync6(cachePath)) {
|
|
29813
30366
|
try {
|
|
29814
|
-
const cacheData = JSON.parse(
|
|
30367
|
+
const cacheData = JSON.parse(readFileSync5(cachePath, "utf-8"));
|
|
29815
30368
|
const timestamp = new Date(cacheData.timestamp);
|
|
29816
30369
|
const now = new Date;
|
|
29817
30370
|
const ageInHours = (now.getTime() - timestamp.getTime()) / (1000 * 60 * 60);
|
|
@@ -29830,9 +30383,9 @@ async function fetchLiteLLMModels(baseUrl, apiKey, forceUpdate = false) {
|
|
|
29830
30383
|
});
|
|
29831
30384
|
if (!response.ok) {
|
|
29832
30385
|
console.error(`Failed to fetch LiteLLM models: ${response.status} ${response.statusText}`);
|
|
29833
|
-
if (
|
|
30386
|
+
if (existsSync6(cachePath)) {
|
|
29834
30387
|
try {
|
|
29835
|
-
const cacheData2 = JSON.parse(
|
|
30388
|
+
const cacheData2 = JSON.parse(readFileSync5(cachePath, "utf-8"));
|
|
29836
30389
|
return cacheData2.models;
|
|
29837
30390
|
} catch {
|
|
29838
30391
|
return [];
|
|
@@ -29868,18 +30421,18 @@ async function fetchLiteLLMModels(baseUrl, apiKey, forceUpdate = false) {
|
|
|
29868
30421
|
source: "LiteLLM"
|
|
29869
30422
|
};
|
|
29870
30423
|
});
|
|
29871
|
-
|
|
30424
|
+
mkdirSync4(cacheDir, { recursive: true });
|
|
29872
30425
|
const cacheData = {
|
|
29873
30426
|
timestamp: new Date().toISOString(),
|
|
29874
30427
|
models: transformedModels
|
|
29875
30428
|
};
|
|
29876
|
-
|
|
30429
|
+
writeFileSync4(cachePath, JSON.stringify(cacheData, null, 2), "utf-8");
|
|
29877
30430
|
return transformedModels;
|
|
29878
30431
|
} catch (error46) {
|
|
29879
30432
|
console.error(`Failed to fetch LiteLLM models: ${error46}`);
|
|
29880
|
-
if (
|
|
30433
|
+
if (existsSync6(cachePath)) {
|
|
29881
30434
|
try {
|
|
29882
|
-
const cacheData = JSON.parse(
|
|
30435
|
+
const cacheData = JSON.parse(readFileSync5(cachePath, "utf-8"));
|
|
29883
30436
|
return cacheData.models;
|
|
29884
30437
|
} catch {
|
|
29885
30438
|
return [];
|
|
@@ -29939,21 +30492,21 @@ function fuzzyScore2(text, query) {
|
|
|
29939
30492
|
}
|
|
29940
30493
|
|
|
29941
30494
|
// src/profile-config.ts
|
|
29942
|
-
import { existsSync as
|
|
29943
|
-
import { homedir as
|
|
29944
|
-
import { join as
|
|
30495
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
30496
|
+
import { homedir as homedir6 } from "os";
|
|
30497
|
+
import { join as join7 } from "path";
|
|
29945
30498
|
function ensureConfigDir() {
|
|
29946
|
-
if (!
|
|
29947
|
-
|
|
30499
|
+
if (!existsSync7(CONFIG_DIR)) {
|
|
30500
|
+
mkdirSync5(CONFIG_DIR, { recursive: true });
|
|
29948
30501
|
}
|
|
29949
30502
|
}
|
|
29950
30503
|
function loadConfig() {
|
|
29951
30504
|
ensureConfigDir();
|
|
29952
|
-
if (!
|
|
30505
|
+
if (!existsSync7(CONFIG_FILE)) {
|
|
29953
30506
|
return { ...DEFAULT_CONFIG };
|
|
29954
30507
|
}
|
|
29955
30508
|
try {
|
|
29956
|
-
const content =
|
|
30509
|
+
const content = readFileSync6(CONFIG_FILE, "utf-8");
|
|
29957
30510
|
const config3 = JSON.parse(content);
|
|
29958
30511
|
const merged = {
|
|
29959
30512
|
version: config3.version || DEFAULT_CONFIG.version,
|
|
@@ -29983,31 +30536,31 @@ function loadConfig() {
|
|
|
29983
30536
|
}
|
|
29984
30537
|
function saveConfig(config3) {
|
|
29985
30538
|
ensureConfigDir();
|
|
29986
|
-
|
|
30539
|
+
writeFileSync5(CONFIG_FILE, JSON.stringify(config3, null, 2), "utf-8");
|
|
29987
30540
|
}
|
|
29988
30541
|
function configExists() {
|
|
29989
|
-
return
|
|
30542
|
+
return existsSync7(CONFIG_FILE);
|
|
29990
30543
|
}
|
|
29991
30544
|
function getConfigPath() {
|
|
29992
30545
|
return CONFIG_FILE;
|
|
29993
30546
|
}
|
|
29994
30547
|
function getLocalConfigPath() {
|
|
29995
|
-
return
|
|
30548
|
+
return join7(process.cwd(), LOCAL_CONFIG_FILENAME);
|
|
29996
30549
|
}
|
|
29997
30550
|
function localConfigExists() {
|
|
29998
|
-
return
|
|
30551
|
+
return existsSync7(getLocalConfigPath());
|
|
29999
30552
|
}
|
|
30000
30553
|
function isProjectDirectory() {
|
|
30001
30554
|
const cwd = process.cwd();
|
|
30002
|
-
return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) =>
|
|
30555
|
+
return [".git", "package.json", "Cargo.toml", "go.mod", "pyproject.toml", ".claudish.json"].some((f) => existsSync7(join7(cwd, f)));
|
|
30003
30556
|
}
|
|
30004
30557
|
function loadLocalConfig() {
|
|
30005
30558
|
const localPath = getLocalConfigPath();
|
|
30006
|
-
if (!
|
|
30559
|
+
if (!existsSync7(localPath)) {
|
|
30007
30560
|
return null;
|
|
30008
30561
|
}
|
|
30009
30562
|
try {
|
|
30010
|
-
const content =
|
|
30563
|
+
const content = readFileSync6(localPath, "utf-8");
|
|
30011
30564
|
const config3 = JSON.parse(content);
|
|
30012
30565
|
const local = {
|
|
30013
30566
|
version: config3.version || DEFAULT_CONFIG.version,
|
|
@@ -30024,7 +30577,7 @@ function loadLocalConfig() {
|
|
|
30024
30577
|
}
|
|
30025
30578
|
}
|
|
30026
30579
|
function saveLocalConfig(config3) {
|
|
30027
|
-
|
|
30580
|
+
writeFileSync5(getLocalConfigPath(), JSON.stringify(config3, null, 2), "utf-8");
|
|
30028
30581
|
}
|
|
30029
30582
|
function loadConfigForScope(scope) {
|
|
30030
30583
|
if (scope === "local") {
|
|
@@ -30229,8 +30782,8 @@ function removeEndpoint(name) {
|
|
|
30229
30782
|
}
|
|
30230
30783
|
var CONFIG_DIR, CONFIG_FILE, LOCAL_CONFIG_FILENAME = ".claudish.json", DEFAULT_CONFIG;
|
|
30231
30784
|
var init_profile_config = __esm(() => {
|
|
30232
|
-
CONFIG_DIR =
|
|
30233
|
-
CONFIG_FILE =
|
|
30785
|
+
CONFIG_DIR = join7(homedir6(), ".claudish");
|
|
30786
|
+
CONFIG_FILE = join7(CONFIG_DIR, "config.json");
|
|
30234
30787
|
DEFAULT_CONFIG = {
|
|
30235
30788
|
version: "1.0.0",
|
|
30236
30789
|
defaultProfile: "default",
|
|
@@ -30464,18 +31017,18 @@ var init_model_parser = __esm(() => {
|
|
|
30464
31017
|
});
|
|
30465
31018
|
|
|
30466
31019
|
// src/auth/oauth-registry.ts
|
|
30467
|
-
import { existsSync as
|
|
30468
|
-
import { join as
|
|
30469
|
-
import { homedir as
|
|
31020
|
+
import { existsSync as existsSync8, readFileSync as readFileSync7 } from "fs";
|
|
31021
|
+
import { join as join8 } from "path";
|
|
31022
|
+
import { homedir as homedir7 } from "os";
|
|
30470
31023
|
function hasValidOAuthCredentials(descriptor) {
|
|
30471
|
-
const credPath =
|
|
30472
|
-
if (!
|
|
31024
|
+
const credPath = join8(homedir7(), ".claudish", descriptor.credentialFile);
|
|
31025
|
+
if (!existsSync8(credPath))
|
|
30473
31026
|
return false;
|
|
30474
31027
|
if (descriptor.validationMode === "file-exists") {
|
|
30475
31028
|
return true;
|
|
30476
31029
|
}
|
|
30477
31030
|
try {
|
|
30478
|
-
const data = JSON.parse(
|
|
31031
|
+
const data = JSON.parse(readFileSync7(credPath, "utf-8"));
|
|
30479
31032
|
if (!data.access_token)
|
|
30480
31033
|
return false;
|
|
30481
31034
|
if (data.refresh_token)
|
|
@@ -30555,9 +31108,9 @@ var init_static_fallback = __esm(() => {
|
|
|
30555
31108
|
});
|
|
30556
31109
|
|
|
30557
31110
|
// src/providers/catalog-resolvers/openrouter.ts
|
|
30558
|
-
import { readFileSync as
|
|
30559
|
-
import { join as
|
|
30560
|
-
import { homedir as
|
|
31111
|
+
import { readFileSync as readFileSync8, existsSync as existsSync9 } from "fs";
|
|
31112
|
+
import { join as join9 } from "path";
|
|
31113
|
+
import { homedir as homedir8 } from "os";
|
|
30561
31114
|
|
|
30562
31115
|
class OpenRouterCatalogResolver {
|
|
30563
31116
|
provider = "openrouter";
|
|
@@ -30602,10 +31155,10 @@ class OpenRouterCatalogResolver {
|
|
|
30602
31155
|
_getModels() {
|
|
30603
31156
|
if (_memCache)
|
|
30604
31157
|
return _memCache;
|
|
30605
|
-
const diskPath =
|
|
30606
|
-
if (
|
|
31158
|
+
const diskPath = join9(homedir8(), ".claudish", "all-models.json");
|
|
31159
|
+
if (existsSync9(diskPath)) {
|
|
30607
31160
|
try {
|
|
30608
|
-
const data = JSON.parse(
|
|
31161
|
+
const data = JSON.parse(readFileSync8(diskPath, "utf-8"));
|
|
30609
31162
|
if (Array.isArray(data.models) && data.models.length > 0) {
|
|
30610
31163
|
_memCache = data.models;
|
|
30611
31164
|
return _memCache;
|
|
@@ -30622,16 +31175,16 @@ var init_openrouter = __esm(() => {
|
|
|
30622
31175
|
});
|
|
30623
31176
|
|
|
30624
31177
|
// src/providers/catalog-resolvers/litellm.ts
|
|
30625
|
-
import { readFileSync as
|
|
30626
|
-
import { join as
|
|
30627
|
-
import { homedir as
|
|
31178
|
+
import { readFileSync as readFileSync9, existsSync as existsSync10 } from "fs";
|
|
31179
|
+
import { join as join10 } from "path";
|
|
31180
|
+
import { homedir as homedir9 } from "os";
|
|
30628
31181
|
import { createHash as createHash3 } from "crypto";
|
|
30629
31182
|
function getCachePath() {
|
|
30630
31183
|
const baseUrl = process.env.LITELLM_BASE_URL;
|
|
30631
31184
|
if (!baseUrl)
|
|
30632
31185
|
return null;
|
|
30633
31186
|
const hash2 = createHash3("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
30634
|
-
return
|
|
31187
|
+
return join10(homedir9(), ".claudish", `litellm-models-${hash2}.json`);
|
|
30635
31188
|
}
|
|
30636
31189
|
|
|
30637
31190
|
class LiteLLMCatalogResolver {
|
|
@@ -30659,10 +31212,10 @@ class LiteLLMCatalogResolver {
|
|
|
30659
31212
|
}
|
|
30660
31213
|
async warmCache() {
|
|
30661
31214
|
const path = getCachePath();
|
|
30662
|
-
if (!path || !
|
|
31215
|
+
if (!path || !existsSync10(path))
|
|
30663
31216
|
return;
|
|
30664
31217
|
try {
|
|
30665
|
-
const data = JSON.parse(
|
|
31218
|
+
const data = JSON.parse(readFileSync9(path, "utf-8"));
|
|
30666
31219
|
if (Array.isArray(data.models)) {
|
|
30667
31220
|
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
30668
31221
|
}
|
|
@@ -30675,10 +31228,10 @@ class LiteLLMCatalogResolver {
|
|
|
30675
31228
|
if (_memCache2)
|
|
30676
31229
|
return _memCache2;
|
|
30677
31230
|
const path = getCachePath();
|
|
30678
|
-
if (!path || !
|
|
31231
|
+
if (!path || !existsSync10(path))
|
|
30679
31232
|
return null;
|
|
30680
31233
|
try {
|
|
30681
|
-
const data = JSON.parse(
|
|
31234
|
+
const data = JSON.parse(readFileSync9(path, "utf-8"));
|
|
30682
31235
|
if (Array.isArray(data.models)) {
|
|
30683
31236
|
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
30684
31237
|
return _memCache2;
|
|
@@ -30737,17 +31290,17 @@ var init_model_catalog_resolver = __esm(() => {
|
|
|
30737
31290
|
});
|
|
30738
31291
|
|
|
30739
31292
|
// src/providers/auto-route.ts
|
|
30740
|
-
import { existsSync as
|
|
30741
|
-
import { join as
|
|
30742
|
-
import { homedir as
|
|
31293
|
+
import { existsSync as existsSync11, readFileSync as readFileSync10 } from "fs";
|
|
31294
|
+
import { join as join11 } from "path";
|
|
31295
|
+
import { homedir as homedir10 } from "os";
|
|
30743
31296
|
import { createHash as createHash4 } from "crypto";
|
|
30744
31297
|
function readLiteLLMCacheSync(baseUrl) {
|
|
30745
31298
|
const hash2 = createHash4("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
30746
|
-
const cachePath =
|
|
30747
|
-
if (!
|
|
31299
|
+
const cachePath = join11(homedir10(), ".claudish", `litellm-models-${hash2}.json`);
|
|
31300
|
+
if (!existsSync11(cachePath))
|
|
30748
31301
|
return null;
|
|
30749
31302
|
try {
|
|
30750
|
-
const data = JSON.parse(
|
|
31303
|
+
const data = JSON.parse(readFileSync10(cachePath, "utf-8"));
|
|
30751
31304
|
if (!Array.isArray(data.models))
|
|
30752
31305
|
return null;
|
|
30753
31306
|
return data.models;
|
|
@@ -30858,11 +31411,11 @@ function autoRoute(modelName, nativeProvider) {
|
|
|
30858
31411
|
return null;
|
|
30859
31412
|
}
|
|
30860
31413
|
function readZenModelCacheSync() {
|
|
30861
|
-
const cachePath =
|
|
30862
|
-
if (!
|
|
31414
|
+
const cachePath = join11(homedir10(), ".claudish", "zen-models.json");
|
|
31415
|
+
if (!existsSync11(cachePath))
|
|
30863
31416
|
return null;
|
|
30864
31417
|
try {
|
|
30865
|
-
const data = JSON.parse(
|
|
31418
|
+
const data = JSON.parse(readFileSync10(cachePath, "utf-8"));
|
|
30866
31419
|
if (!Array.isArray(data.models))
|
|
30867
31420
|
return null;
|
|
30868
31421
|
return new Set(data.models.map((m) => m.id));
|
|
@@ -30889,10 +31442,10 @@ async function warmZenModelCache() {
|
|
|
30889
31442
|
const models = (data.data ?? []).map((m) => ({ id: m.id }));
|
|
30890
31443
|
if (models.length === 0)
|
|
30891
31444
|
return;
|
|
30892
|
-
const cacheDir =
|
|
30893
|
-
const { mkdirSync:
|
|
30894
|
-
|
|
30895
|
-
writeSync3(
|
|
31445
|
+
const cacheDir = join11(homedir10(), ".claudish");
|
|
31446
|
+
const { mkdirSync: mkdirSync6, writeFileSync: writeSync3 } = await import("fs");
|
|
31447
|
+
mkdirSync6(cacheDir, { recursive: true });
|
|
31448
|
+
writeSync3(join11(cacheDir, "zen-models.json"), JSON.stringify({ models, fetchedAt: new Date().toISOString() }));
|
|
30896
31449
|
}
|
|
30897
31450
|
function hasProviderCredentials(provider) {
|
|
30898
31451
|
const keyInfo = API_KEY_ENV_VARS[provider];
|
|
@@ -31489,9 +32042,9 @@ __export(exports_provider_resolver, {
|
|
|
31489
32042
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
31490
32043
|
getMissingKeyError: () => getMissingKeyError
|
|
31491
32044
|
});
|
|
31492
|
-
import { existsSync as
|
|
31493
|
-
import { join as
|
|
31494
|
-
import { homedir as
|
|
32045
|
+
import { existsSync as existsSync12 } from "fs";
|
|
32046
|
+
import { join as join12 } from "path";
|
|
32047
|
+
import { homedir as homedir11 } from "os";
|
|
31495
32048
|
function isApiKeyAvailable(info) {
|
|
31496
32049
|
if (!info.envVar) {
|
|
31497
32050
|
return true;
|
|
@@ -31508,8 +32061,8 @@ function isApiKeyAvailable(info) {
|
|
|
31508
32061
|
}
|
|
31509
32062
|
if (info.oauthFallback) {
|
|
31510
32063
|
try {
|
|
31511
|
-
const credPath =
|
|
31512
|
-
if (
|
|
32064
|
+
const credPath = join12(homedir11(), ".claudish", info.oauthFallback);
|
|
32065
|
+
if (existsSync12(credPath)) {
|
|
31513
32066
|
return true;
|
|
31514
32067
|
}
|
|
31515
32068
|
} catch {}
|
|
@@ -32421,6 +32974,8 @@ var init_grok_adapter = __esm(() => {
|
|
|
32421
32974
|
}
|
|
32422
32975
|
getContextWindow() {
|
|
32423
32976
|
const model = this.modelId.toLowerCase();
|
|
32977
|
+
if (model.includes("grok-4.20") || model.includes("grok-4-20"))
|
|
32978
|
+
return 2000000;
|
|
32424
32979
|
if (model.includes("grok-4.1-fast") || model.includes("grok-4-1-fast"))
|
|
32425
32980
|
return 2000000;
|
|
32426
32981
|
if (model.includes("grok-4-fast"))
|
|
@@ -33666,7 +34221,7 @@ CRITICAL INSTRUCTION FOR OUTPUT FORMAT:
|
|
|
33666
34221
|
this.reasoningBlockDepth = 0;
|
|
33667
34222
|
}
|
|
33668
34223
|
getContextWindow() {
|
|
33669
|
-
return
|
|
34224
|
+
return 1048576;
|
|
33670
34225
|
}
|
|
33671
34226
|
shouldHandle(modelId) {
|
|
33672
34227
|
return modelId.includes("gemini") || modelId.includes("google/");
|
|
@@ -33886,9 +34441,11 @@ var init_openai_adapter = __esm(() => {
|
|
|
33886
34441
|
}
|
|
33887
34442
|
getContextWindow() {
|
|
33888
34443
|
const model = this.modelId.toLowerCase();
|
|
34444
|
+
if (model.includes("gpt-5.4"))
|
|
34445
|
+
return 1050000;
|
|
33889
34446
|
if (model.includes("gpt-5"))
|
|
33890
|
-
return
|
|
33891
|
-
if (model.includes("o1") || model.includes("o3"))
|
|
34447
|
+
return 400000;
|
|
34448
|
+
if (model.includes("o1") || model.includes("o3") || model.includes("o4"))
|
|
33892
34449
|
return 200000;
|
|
33893
34450
|
if (model.includes("gpt-4o") || model.includes("gpt-4-turbo"))
|
|
33894
34451
|
return 128000;
|
|
@@ -34068,18 +34625,20 @@ var init_glm_adapter = __esm(() => {
|
|
|
34068
34625
|
init_base_adapter();
|
|
34069
34626
|
init_logger();
|
|
34070
34627
|
GLM_CONTEXT_WINDOWS = [
|
|
34071
|
-
["glm-5",
|
|
34072
|
-
["glm-
|
|
34073
|
-
["glm-4.7",
|
|
34074
|
-
["glm-4.
|
|
34628
|
+
["glm-5-turbo", 202752],
|
|
34629
|
+
["glm-5", 80000],
|
|
34630
|
+
["glm-4.7-flash", 202752],
|
|
34631
|
+
["glm-4.7", 202752],
|
|
34632
|
+
["glm-4.6v", 131072],
|
|
34075
34633
|
["glm-4.6", 204800],
|
|
34076
|
-
["glm-4.5v",
|
|
34634
|
+
["glm-4.5v", 65536],
|
|
34077
34635
|
["glm-4.5-flash", 131072],
|
|
34078
34636
|
["glm-4.5-air", 131072],
|
|
34079
34637
|
["glm-4.5", 131072],
|
|
34080
34638
|
["glm-4-long", 1e6],
|
|
34081
34639
|
["glm-4-plus", 128000],
|
|
34082
34640
|
["glm-4-flash", 128000],
|
|
34641
|
+
["glm-4-32b", 128000],
|
|
34083
34642
|
["glm-4", 128000],
|
|
34084
34643
|
["glm-3-turbo", 128000],
|
|
34085
34644
|
["glm-", 131072]
|
|
@@ -34121,6 +34680,43 @@ var init_glm_adapter = __esm(() => {
|
|
|
34121
34680
|
};
|
|
34122
34681
|
});
|
|
34123
34682
|
|
|
34683
|
+
// src/adapters/xiaomi-adapter.ts
|
|
34684
|
+
var XiaomiAdapter;
|
|
34685
|
+
var init_xiaomi_adapter = __esm(() => {
|
|
34686
|
+
init_base_adapter();
|
|
34687
|
+
init_logger();
|
|
34688
|
+
XiaomiAdapter = class XiaomiAdapter extends BaseModelAdapter {
|
|
34689
|
+
processTextContent(textContent, accumulatedText) {
|
|
34690
|
+
return {
|
|
34691
|
+
cleanedText: textContent,
|
|
34692
|
+
extractedToolCalls: [],
|
|
34693
|
+
wasTransformed: false
|
|
34694
|
+
};
|
|
34695
|
+
}
|
|
34696
|
+
getToolNameLimit() {
|
|
34697
|
+
return 64;
|
|
34698
|
+
}
|
|
34699
|
+
prepareRequest(request, originalRequest) {
|
|
34700
|
+
if (originalRequest.thinking) {
|
|
34701
|
+
log(`[XiaomiAdapter] Stripping thinking object (not supported by Xiaomi API)`);
|
|
34702
|
+
delete request.thinking;
|
|
34703
|
+
}
|
|
34704
|
+
this.truncateToolNames(request);
|
|
34705
|
+
if (request.messages) {
|
|
34706
|
+
this.truncateToolNamesInMessages(request.messages);
|
|
34707
|
+
}
|
|
34708
|
+
return request;
|
|
34709
|
+
}
|
|
34710
|
+
shouldHandle(modelId) {
|
|
34711
|
+
const lower = modelId.toLowerCase();
|
|
34712
|
+
return lower.includes("xiaomi") || lower.includes("mimo");
|
|
34713
|
+
}
|
|
34714
|
+
getName() {
|
|
34715
|
+
return "XiaomiAdapter";
|
|
34716
|
+
}
|
|
34717
|
+
};
|
|
34718
|
+
});
|
|
34719
|
+
|
|
34124
34720
|
// src/adapters/adapter-manager.ts
|
|
34125
34721
|
var exports_adapter_manager = {};
|
|
34126
34722
|
__export(exports_adapter_manager, {
|
|
@@ -34139,7 +34735,8 @@ class AdapterManager {
|
|
|
34139
34735
|
new QwenAdapter(modelId),
|
|
34140
34736
|
new MiniMaxAdapter(modelId),
|
|
34141
34737
|
new DeepSeekAdapter(modelId),
|
|
34142
|
-
new GLMAdapter(modelId)
|
|
34738
|
+
new GLMAdapter(modelId),
|
|
34739
|
+
new XiaomiAdapter(modelId)
|
|
34143
34740
|
];
|
|
34144
34741
|
this.defaultAdapter = new DefaultAdapter(modelId);
|
|
34145
34742
|
}
|
|
@@ -34165,6 +34762,7 @@ var init_adapter_manager = __esm(() => {
|
|
|
34165
34762
|
init_minimax_adapter();
|
|
34166
34763
|
init_deepseek_adapter();
|
|
34167
34764
|
init_glm_adapter();
|
|
34765
|
+
init_xiaomi_adapter();
|
|
34168
34766
|
});
|
|
34169
34767
|
|
|
34170
34768
|
// src/cli.ts
|
|
@@ -34181,31 +34779,31 @@ __export(exports_cli, {
|
|
|
34181
34779
|
getMissingKeyError: () => getMissingKeyError
|
|
34182
34780
|
});
|
|
34183
34781
|
import {
|
|
34184
|
-
readFileSync as
|
|
34185
|
-
writeFileSync as
|
|
34186
|
-
existsSync as
|
|
34187
|
-
mkdirSync as
|
|
34782
|
+
readFileSync as readFileSync11,
|
|
34783
|
+
writeFileSync as writeFileSync6,
|
|
34784
|
+
existsSync as existsSync13,
|
|
34785
|
+
mkdirSync as mkdirSync6,
|
|
34188
34786
|
copyFileSync,
|
|
34189
|
-
readdirSync,
|
|
34190
|
-
unlinkSync as
|
|
34787
|
+
readdirSync as readdirSync3,
|
|
34788
|
+
unlinkSync as unlinkSync4
|
|
34191
34789
|
} from "fs";
|
|
34192
34790
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
34193
|
-
import { dirname as dirname3, join as
|
|
34194
|
-
import { homedir as
|
|
34791
|
+
import { dirname as dirname3, join as join13 } from "path";
|
|
34792
|
+
import { homedir as homedir12 } from "os";
|
|
34195
34793
|
function getVersion() {
|
|
34196
34794
|
return VERSION;
|
|
34197
34795
|
}
|
|
34198
34796
|
function clearAllModelCaches() {
|
|
34199
|
-
const cacheDir =
|
|
34200
|
-
if (!
|
|
34797
|
+
const cacheDir = join13(homedir12(), ".claudish");
|
|
34798
|
+
if (!existsSync13(cacheDir))
|
|
34201
34799
|
return;
|
|
34202
34800
|
const cachePatterns = ["all-models.json", "pricing-cache.json"];
|
|
34203
34801
|
let cleared = 0;
|
|
34204
34802
|
try {
|
|
34205
|
-
const files =
|
|
34803
|
+
const files = readdirSync3(cacheDir);
|
|
34206
34804
|
for (const file2 of files) {
|
|
34207
34805
|
if (cachePatterns.includes(file2) || file2.startsWith("litellm-models-")) {
|
|
34208
|
-
|
|
34806
|
+
unlinkSync4(join13(cacheDir, file2));
|
|
34209
34807
|
cleared++;
|
|
34210
34808
|
}
|
|
34211
34809
|
}
|
|
@@ -34229,6 +34827,7 @@ async function parseArgs(args) {
|
|
|
34229
34827
|
monitor: false,
|
|
34230
34828
|
stdin: false,
|
|
34231
34829
|
freeOnly: false,
|
|
34830
|
+
noLogs: false,
|
|
34232
34831
|
claudeArgs: []
|
|
34233
34832
|
};
|
|
34234
34833
|
const claudishModel = process.env[ENV.CLAUDISH_MODEL];
|
|
@@ -34395,6 +34994,8 @@ async function parseArgs(args) {
|
|
|
34395
34994
|
process.exit(0);
|
|
34396
34995
|
} else if (arg === "--summarize-tools") {
|
|
34397
34996
|
config3.summarizeTools = true;
|
|
34997
|
+
} else if (arg === "--no-logs") {
|
|
34998
|
+
config3.noLogs = true;
|
|
34398
34999
|
} else if (arg === "--") {
|
|
34399
35000
|
config3.claudeArgs.push(...args.slice(i + 1));
|
|
34400
35001
|
break;
|
|
@@ -34496,9 +35097,9 @@ async function fetchOllamaModels() {
|
|
|
34496
35097
|
}
|
|
34497
35098
|
async function searchAndPrintModels(query, forceUpdate) {
|
|
34498
35099
|
let models = [];
|
|
34499
|
-
if (!forceUpdate &&
|
|
35100
|
+
if (!forceUpdate && existsSync13(ALL_MODELS_JSON_PATH)) {
|
|
34500
35101
|
try {
|
|
34501
|
-
const cacheData = JSON.parse(
|
|
35102
|
+
const cacheData = JSON.parse(readFileSync11(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
34502
35103
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34503
35104
|
const now = new Date;
|
|
34504
35105
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -34515,8 +35116,8 @@ async function searchAndPrintModels(query, forceUpdate) {
|
|
|
34515
35116
|
throw new Error(`API returned ${response.status}`);
|
|
34516
35117
|
const data = await response.json();
|
|
34517
35118
|
models = data.data;
|
|
34518
|
-
|
|
34519
|
-
|
|
35119
|
+
mkdirSync6(CLAUDISH_CACHE_DIR2, { recursive: true });
|
|
35120
|
+
writeFileSync6(ALL_MODELS_JSON_PATH, JSON.stringify({
|
|
34520
35121
|
lastUpdated: new Date().toISOString(),
|
|
34521
35122
|
models
|
|
34522
35123
|
}), "utf-8");
|
|
@@ -34666,9 +35267,9 @@ Found ${results.length} matching models:
|
|
|
34666
35267
|
async function printAllModels(jsonOutput, forceUpdate) {
|
|
34667
35268
|
let models = [];
|
|
34668
35269
|
const [ollamaModels, zenModels] = await Promise.all([fetchOllamaModels(), fetchZenModels()]);
|
|
34669
|
-
if (!forceUpdate &&
|
|
35270
|
+
if (!forceUpdate && existsSync13(ALL_MODELS_JSON_PATH)) {
|
|
34670
35271
|
try {
|
|
34671
|
-
const cacheData = JSON.parse(
|
|
35272
|
+
const cacheData = JSON.parse(readFileSync11(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
34672
35273
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34673
35274
|
const now = new Date;
|
|
34674
35275
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -34688,8 +35289,8 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
34688
35289
|
throw new Error(`API returned ${response.status}`);
|
|
34689
35290
|
const data = await response.json();
|
|
34690
35291
|
models = data.data;
|
|
34691
|
-
|
|
34692
|
-
|
|
35292
|
+
mkdirSync6(CLAUDISH_CACHE_DIR2, { recursive: true });
|
|
35293
|
+
writeFileSync6(ALL_MODELS_JSON_PATH, JSON.stringify({
|
|
34693
35294
|
lastUpdated: new Date().toISOString(),
|
|
34694
35295
|
models
|
|
34695
35296
|
}), "utf-8");
|
|
@@ -34869,12 +35470,12 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
34869
35470
|
console.log("Top models: claudish --top-models");
|
|
34870
35471
|
}
|
|
34871
35472
|
function isCacheStale() {
|
|
34872
|
-
const cachePath =
|
|
34873
|
-
if (!
|
|
35473
|
+
const cachePath = existsSync13(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35474
|
+
if (!existsSync13(cachePath)) {
|
|
34874
35475
|
return true;
|
|
34875
35476
|
}
|
|
34876
35477
|
try {
|
|
34877
|
-
const jsonContent =
|
|
35478
|
+
const jsonContent = readFileSync11(cachePath, "utf-8");
|
|
34878
35479
|
const data = JSON.parse(jsonContent);
|
|
34879
35480
|
if (!data.lastUpdated) {
|
|
34880
35481
|
return true;
|
|
@@ -34953,10 +35554,10 @@ async function updateModelsFromOpenRouter() {
|
|
|
34953
35554
|
providers.add(provider);
|
|
34954
35555
|
}
|
|
34955
35556
|
let version2 = "1.2.0";
|
|
34956
|
-
const existingPath =
|
|
34957
|
-
if (
|
|
35557
|
+
const existingPath = existsSync13(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35558
|
+
if (existsSync13(existingPath)) {
|
|
34958
35559
|
try {
|
|
34959
|
-
const existing = JSON.parse(
|
|
35560
|
+
const existing = JSON.parse(readFileSync11(existingPath, "utf-8"));
|
|
34960
35561
|
version2 = existing.version || version2;
|
|
34961
35562
|
} catch {}
|
|
34962
35563
|
}
|
|
@@ -34966,8 +35567,8 @@ async function updateModelsFromOpenRouter() {
|
|
|
34966
35567
|
source: "https://openrouter.ai/models?categories=programming&fmt=cards&order=top-weekly",
|
|
34967
35568
|
models: recommendations
|
|
34968
35569
|
};
|
|
34969
|
-
|
|
34970
|
-
|
|
35570
|
+
mkdirSync6(CLAUDISH_CACHE_DIR2, { recursive: true });
|
|
35571
|
+
writeFileSync6(CACHED_MODELS_PATH, JSON.stringify(updatedData, null, 2), "utf-8");
|
|
34971
35572
|
console.error(`\u2705 Updated ${recommendations.length} models (last updated: ${updatedData.lastUpdated})`);
|
|
34972
35573
|
} catch (error46) {
|
|
34973
35574
|
console.error(`\u274C Failed to update models: ${error46 instanceof Error ? error46.message : String(error46)}`);
|
|
@@ -34985,8 +35586,8 @@ async function checkAndUpdateModelsCache(forceUpdate = false) {
|
|
|
34985
35586
|
await updateModelsFromOpenRouter();
|
|
34986
35587
|
} else {
|
|
34987
35588
|
try {
|
|
34988
|
-
const cachePath =
|
|
34989
|
-
const data = JSON.parse(
|
|
35589
|
+
const cachePath = existsSync13(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35590
|
+
const data = JSON.parse(readFileSync11(cachePath, "utf-8"));
|
|
34990
35591
|
console.error(`\u2713 Using cached models (last updated: ${data.lastUpdated})`);
|
|
34991
35592
|
} catch {}
|
|
34992
35593
|
}
|
|
@@ -35293,6 +35894,7 @@ OPTIONS:
|
|
|
35293
35894
|
-p, --profile <name> Use named profile for model mapping (default: uses default profile)
|
|
35294
35895
|
--port <port> Proxy server port (default: random)
|
|
35295
35896
|
-d, --debug Enable debug logging to file (logs/claudish_*.log)
|
|
35897
|
+
--no-logs Disable always-on structural logging (~/.claudish/logs/)
|
|
35296
35898
|
--log-level <level> Log verbosity: debug (full), info (truncated), minimal (labels only)
|
|
35297
35899
|
-q, --quiet Suppress [claudish] log messages (default in single-shot mode)
|
|
35298
35900
|
-v, --verbose Show [claudish] log messages (default in interactive mode)
|
|
@@ -35544,8 +36146,8 @@ MORE INFO:
|
|
|
35544
36146
|
}
|
|
35545
36147
|
function printAIAgentGuide() {
|
|
35546
36148
|
try {
|
|
35547
|
-
const guidePath =
|
|
35548
|
-
const guideContent =
|
|
36149
|
+
const guidePath = join13(__dirname4, "../AI_AGENT_GUIDE.md");
|
|
36150
|
+
const guideContent = readFileSync11(guidePath, "utf-8");
|
|
35549
36151
|
console.log(guideContent);
|
|
35550
36152
|
} catch (error46) {
|
|
35551
36153
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -35561,19 +36163,19 @@ async function initializeClaudishSkill() {
|
|
|
35561
36163
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
35562
36164
|
`);
|
|
35563
36165
|
const cwd = process.cwd();
|
|
35564
|
-
const claudeDir =
|
|
35565
|
-
const skillsDir =
|
|
35566
|
-
const claudishSkillDir =
|
|
35567
|
-
const skillFile =
|
|
35568
|
-
if (
|
|
36166
|
+
const claudeDir = join13(cwd, ".claude");
|
|
36167
|
+
const skillsDir = join13(claudeDir, "skills");
|
|
36168
|
+
const claudishSkillDir = join13(skillsDir, "claudish-usage");
|
|
36169
|
+
const skillFile = join13(claudishSkillDir, "SKILL.md");
|
|
36170
|
+
if (existsSync13(skillFile)) {
|
|
35569
36171
|
console.log("\u2705 Claudish skill already installed at:");
|
|
35570
36172
|
console.log(` ${skillFile}
|
|
35571
36173
|
`);
|
|
35572
36174
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
35573
36175
|
return;
|
|
35574
36176
|
}
|
|
35575
|
-
const sourceSkillPath =
|
|
35576
|
-
if (!
|
|
36177
|
+
const sourceSkillPath = join13(__dirname4, "../skills/claudish-usage/SKILL.md");
|
|
36178
|
+
if (!existsSync13(sourceSkillPath)) {
|
|
35577
36179
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
35578
36180
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
35579
36181
|
console.error(`
|
|
@@ -35582,16 +36184,16 @@ async function initializeClaudishSkill() {
|
|
|
35582
36184
|
process.exit(1);
|
|
35583
36185
|
}
|
|
35584
36186
|
try {
|
|
35585
|
-
if (!
|
|
35586
|
-
|
|
36187
|
+
if (!existsSync13(claudeDir)) {
|
|
36188
|
+
mkdirSync6(claudeDir, { recursive: true });
|
|
35587
36189
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
35588
36190
|
}
|
|
35589
|
-
if (!
|
|
35590
|
-
|
|
36191
|
+
if (!existsSync13(skillsDir)) {
|
|
36192
|
+
mkdirSync6(skillsDir, { recursive: true });
|
|
35591
36193
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
35592
36194
|
}
|
|
35593
|
-
if (!
|
|
35594
|
-
|
|
36195
|
+
if (!existsSync13(claudishSkillDir)) {
|
|
36196
|
+
mkdirSync6(claudishSkillDir, { recursive: true });
|
|
35595
36197
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
35596
36198
|
}
|
|
35597
36199
|
copyFileSync(sourceSkillPath, skillFile);
|
|
@@ -35633,9 +36235,9 @@ function printAvailableModels() {
|
|
|
35633
36235
|
let lastUpdated = "unknown";
|
|
35634
36236
|
let models = [];
|
|
35635
36237
|
try {
|
|
35636
|
-
const cachePath =
|
|
35637
|
-
if (
|
|
35638
|
-
const data = JSON.parse(
|
|
36238
|
+
const cachePath = existsSync13(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
36239
|
+
if (existsSync13(cachePath)) {
|
|
36240
|
+
const data = JSON.parse(readFileSync11(cachePath, "utf-8"));
|
|
35639
36241
|
lastUpdated = data.lastUpdated || "unknown";
|
|
35640
36242
|
models = data.models || [];
|
|
35641
36243
|
}
|
|
@@ -35684,9 +36286,9 @@ Force update: claudish --list-models --force-update
|
|
|
35684
36286
|
`);
|
|
35685
36287
|
}
|
|
35686
36288
|
function printAvailableModelsJSON() {
|
|
35687
|
-
const jsonPath =
|
|
36289
|
+
const jsonPath = existsSync13(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35688
36290
|
try {
|
|
35689
|
-
const jsonContent =
|
|
36291
|
+
const jsonContent = readFileSync11(jsonPath, "utf-8");
|
|
35690
36292
|
const data = JSON.parse(jsonContent);
|
|
35691
36293
|
console.log(JSON.stringify(data, null, 2));
|
|
35692
36294
|
} catch (error46) {
|
|
@@ -35771,7 +36373,7 @@ async function fetchGLMCodingModels() {
|
|
|
35771
36373
|
return [];
|
|
35772
36374
|
}
|
|
35773
36375
|
}
|
|
35774
|
-
var __filename4, __dirname4, VERSION = "5.
|
|
36376
|
+
var __filename4, __dirname4, VERSION = "5.15.0", CACHE_MAX_AGE_DAYS2 = 2, CLAUDISH_CACHE_DIR2, BUNDLED_MODELS_PATH, CACHED_MODELS_PATH, ALL_MODELS_JSON_PATH;
|
|
35775
36377
|
var init_cli = __esm(() => {
|
|
35776
36378
|
init_config();
|
|
35777
36379
|
init_model_loader();
|
|
@@ -35783,13 +36385,13 @@ var init_cli = __esm(() => {
|
|
|
35783
36385
|
__filename4 = fileURLToPath3(import.meta.url);
|
|
35784
36386
|
__dirname4 = dirname3(__filename4);
|
|
35785
36387
|
try {
|
|
35786
|
-
const packageJson = JSON.parse(
|
|
36388
|
+
const packageJson = JSON.parse(readFileSync11(join13(__dirname4, "../package.json"), "utf-8"));
|
|
35787
36389
|
VERSION = packageJson.version;
|
|
35788
36390
|
} catch {}
|
|
35789
|
-
CLAUDISH_CACHE_DIR2 =
|
|
35790
|
-
BUNDLED_MODELS_PATH =
|
|
35791
|
-
CACHED_MODELS_PATH =
|
|
35792
|
-
ALL_MODELS_JSON_PATH =
|
|
36391
|
+
CLAUDISH_CACHE_DIR2 = join13(homedir12(), ".claudish");
|
|
36392
|
+
BUNDLED_MODELS_PATH = join13(__dirname4, "../recommended-models.json");
|
|
36393
|
+
CACHED_MODELS_PATH = join13(CLAUDISH_CACHE_DIR2, "recommended-models.json");
|
|
36394
|
+
ALL_MODELS_JSON_PATH = join13(CLAUDISH_CACHE_DIR2, "all-models.json");
|
|
35793
36395
|
});
|
|
35794
36396
|
|
|
35795
36397
|
// src/update-checker.ts
|
|
@@ -35801,9 +36403,9 @@ __export(exports_update_checker, {
|
|
|
35801
36403
|
checkForUpdates: () => checkForUpdates
|
|
35802
36404
|
});
|
|
35803
36405
|
import { execSync } from "child_process";
|
|
35804
|
-
import { existsSync as
|
|
35805
|
-
import { homedir as
|
|
35806
|
-
import { join as
|
|
36406
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readFileSync as readFileSync12, unlinkSync as unlinkSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
36407
|
+
import { homedir as homedir13, platform as platform2, tmpdir } from "os";
|
|
36408
|
+
import { join as join14 } from "path";
|
|
35807
36409
|
import { createInterface } from "readline";
|
|
35808
36410
|
function getUpdateCommand() {
|
|
35809
36411
|
const scriptPath = process.argv[1] || "";
|
|
@@ -35815,27 +36417,27 @@ function getUpdateCommand() {
|
|
|
35815
36417
|
function getCacheFilePath() {
|
|
35816
36418
|
let cacheDir;
|
|
35817
36419
|
if (isWindows) {
|
|
35818
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
35819
|
-
cacheDir =
|
|
36420
|
+
const localAppData = process.env.LOCALAPPDATA || join14(homedir13(), "AppData", "Local");
|
|
36421
|
+
cacheDir = join14(localAppData, "claudish");
|
|
35820
36422
|
} else {
|
|
35821
|
-
cacheDir =
|
|
36423
|
+
cacheDir = join14(homedir13(), ".cache", "claudish");
|
|
35822
36424
|
}
|
|
35823
36425
|
try {
|
|
35824
|
-
if (!
|
|
35825
|
-
|
|
36426
|
+
if (!existsSync14(cacheDir)) {
|
|
36427
|
+
mkdirSync7(cacheDir, { recursive: true });
|
|
35826
36428
|
}
|
|
35827
|
-
return
|
|
36429
|
+
return join14(cacheDir, "update-check.json");
|
|
35828
36430
|
} catch {
|
|
35829
|
-
return
|
|
36431
|
+
return join14(tmpdir(), "claudish-update-check.json");
|
|
35830
36432
|
}
|
|
35831
36433
|
}
|
|
35832
36434
|
function readCache() {
|
|
35833
36435
|
try {
|
|
35834
36436
|
const cachePath = getCacheFilePath();
|
|
35835
|
-
if (!
|
|
36437
|
+
if (!existsSync14(cachePath)) {
|
|
35836
36438
|
return null;
|
|
35837
36439
|
}
|
|
35838
|
-
const data = JSON.parse(
|
|
36440
|
+
const data = JSON.parse(readFileSync12(cachePath, "utf-8"));
|
|
35839
36441
|
return data;
|
|
35840
36442
|
} catch {
|
|
35841
36443
|
return null;
|
|
@@ -35848,7 +36450,7 @@ function writeCache(latestVersion) {
|
|
|
35848
36450
|
lastCheck: Date.now(),
|
|
35849
36451
|
latestVersion
|
|
35850
36452
|
};
|
|
35851
|
-
|
|
36453
|
+
writeFileSync7(cachePath, JSON.stringify(data), "utf-8");
|
|
35852
36454
|
} catch {}
|
|
35853
36455
|
}
|
|
35854
36456
|
function isCacheValid(cache) {
|
|
@@ -35858,8 +36460,8 @@ function isCacheValid(cache) {
|
|
|
35858
36460
|
function clearCache() {
|
|
35859
36461
|
try {
|
|
35860
36462
|
const cachePath = getCacheFilePath();
|
|
35861
|
-
if (
|
|
35862
|
-
|
|
36463
|
+
if (existsSync14(cachePath)) {
|
|
36464
|
+
unlinkSync5(cachePath);
|
|
35863
36465
|
}
|
|
35864
36466
|
} catch {}
|
|
35865
36467
|
}
|
|
@@ -35895,7 +36497,7 @@ async function fetchLatestVersion() {
|
|
|
35895
36497
|
}
|
|
35896
36498
|
}
|
|
35897
36499
|
function promptUser(question) {
|
|
35898
|
-
return new Promise((
|
|
36500
|
+
return new Promise((resolve2) => {
|
|
35899
36501
|
const rl = createInterface({
|
|
35900
36502
|
input: process.stdin,
|
|
35901
36503
|
output: process.stderr
|
|
@@ -35903,7 +36505,7 @@ function promptUser(question) {
|
|
|
35903
36505
|
rl.question(question, (answer) => {
|
|
35904
36506
|
rl.close();
|
|
35905
36507
|
const normalized = answer.toLowerCase().trim();
|
|
35906
|
-
|
|
36508
|
+
resolve2(normalized === "y" || normalized === "yes");
|
|
35907
36509
|
});
|
|
35908
36510
|
});
|
|
35909
36511
|
}
|
|
@@ -36014,7 +36616,7 @@ function getUpdateCommand2(method) {
|
|
|
36014
36616
|
}
|
|
36015
36617
|
}
|
|
36016
36618
|
function promptUser2(question) {
|
|
36017
|
-
return new Promise((
|
|
36619
|
+
return new Promise((resolve2) => {
|
|
36018
36620
|
const rl = createInterface2({
|
|
36019
36621
|
input: process.stdin,
|
|
36020
36622
|
output: process.stdout
|
|
@@ -36022,7 +36624,7 @@ function promptUser2(question) {
|
|
|
36022
36624
|
rl.question(question, (answer) => {
|
|
36023
36625
|
rl.close();
|
|
36024
36626
|
const normalized = answer.toLowerCase().trim();
|
|
36025
|
-
|
|
36627
|
+
resolve2(normalized === "y" || normalized === "yes" || normalized === "");
|
|
36026
36628
|
});
|
|
36027
36629
|
});
|
|
36028
36630
|
}
|
|
@@ -37708,13 +38310,13 @@ var PromisePolyfill;
|
|
|
37708
38310
|
var init_promise_polyfill = __esm(() => {
|
|
37709
38311
|
PromisePolyfill = class PromisePolyfill extends Promise {
|
|
37710
38312
|
static withResolver() {
|
|
37711
|
-
let
|
|
38313
|
+
let resolve2;
|
|
37712
38314
|
let reject;
|
|
37713
38315
|
const promise3 = new Promise((res, rej) => {
|
|
37714
|
-
|
|
38316
|
+
resolve2 = res;
|
|
37715
38317
|
reject = rej;
|
|
37716
38318
|
});
|
|
37717
|
-
return { promise: promise3, resolve, reject };
|
|
38319
|
+
return { promise: promise3, resolve: resolve2, reject };
|
|
37718
38320
|
}
|
|
37719
38321
|
};
|
|
37720
38322
|
});
|
|
@@ -37751,7 +38353,7 @@ function createPrompt(view) {
|
|
|
37751
38353
|
output
|
|
37752
38354
|
});
|
|
37753
38355
|
const screen = new ScreenManager(rl);
|
|
37754
|
-
const { promise: promise3, resolve, reject } = PromisePolyfill.withResolver();
|
|
38356
|
+
const { promise: promise3, resolve: resolve2, reject } = PromisePolyfill.withResolver();
|
|
37755
38357
|
const cancel = () => reject(new CancelPromptError);
|
|
37756
38358
|
if (signal) {
|
|
37757
38359
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -37778,7 +38380,7 @@ function createPrompt(view) {
|
|
|
37778
38380
|
cycle(() => {
|
|
37779
38381
|
try {
|
|
37780
38382
|
const nextView = view(config3, (value) => {
|
|
37781
|
-
setImmediate(() =>
|
|
38383
|
+
setImmediate(() => resolve2(value));
|
|
37782
38384
|
});
|
|
37783
38385
|
if (nextView === undefined) {
|
|
37784
38386
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -38339,14 +38941,14 @@ __export(exports_model_selector, {
|
|
|
38339
38941
|
promptForApiKey: () => promptForApiKey,
|
|
38340
38942
|
confirmAction: () => confirmAction
|
|
38341
38943
|
});
|
|
38342
|
-
import { readFileSync as
|
|
38343
|
-
import { join as
|
|
38344
|
-
import { homedir as
|
|
38944
|
+
import { readFileSync as readFileSync13, writeFileSync as writeFileSync8, existsSync as existsSync15, mkdirSync as mkdirSync8 } from "fs";
|
|
38945
|
+
import { join as join15, dirname as dirname4 } from "path";
|
|
38946
|
+
import { homedir as homedir14 } from "os";
|
|
38345
38947
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
38346
38948
|
function loadRecommendedModels2() {
|
|
38347
|
-
if (
|
|
38949
|
+
if (existsSync15(RECOMMENDED_MODELS_JSON_PATH)) {
|
|
38348
38950
|
try {
|
|
38349
|
-
const content =
|
|
38951
|
+
const content = readFileSync13(RECOMMENDED_MODELS_JSON_PATH, "utf-8");
|
|
38350
38952
|
const data = JSON.parse(content);
|
|
38351
38953
|
return (data.models || []).map((model) => ({
|
|
38352
38954
|
...model,
|
|
@@ -38359,9 +38961,9 @@ function loadRecommendedModels2() {
|
|
|
38359
38961
|
return [];
|
|
38360
38962
|
}
|
|
38361
38963
|
async function fetchAllModels(forceUpdate = false) {
|
|
38362
|
-
if (!forceUpdate &&
|
|
38964
|
+
if (!forceUpdate && existsSync15(ALL_MODELS_JSON_PATH2)) {
|
|
38363
38965
|
try {
|
|
38364
|
-
const cacheData = JSON.parse(
|
|
38966
|
+
const cacheData = JSON.parse(readFileSync13(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
38365
38967
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
38366
38968
|
const now = new Date;
|
|
38367
38969
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -38377,8 +38979,8 @@ async function fetchAllModels(forceUpdate = false) {
|
|
|
38377
38979
|
throw new Error(`API returned ${response.status}`);
|
|
38378
38980
|
const data = await response.json();
|
|
38379
38981
|
const models = data.data;
|
|
38380
|
-
|
|
38381
|
-
|
|
38982
|
+
mkdirSync8(CLAUDISH_CACHE_DIR3, { recursive: true });
|
|
38983
|
+
writeFileSync8(ALL_MODELS_JSON_PATH2, JSON.stringify({
|
|
38382
38984
|
lastUpdated: new Date().toISOString(),
|
|
38383
38985
|
models
|
|
38384
38986
|
}), "utf-8");
|
|
@@ -38863,11 +39465,11 @@ async function fetchOllamaCloudModels() {
|
|
|
38863
39465
|
}
|
|
38864
39466
|
}
|
|
38865
39467
|
function shouldRefreshForFreeModels() {
|
|
38866
|
-
if (!
|
|
39468
|
+
if (!existsSync15(ALL_MODELS_JSON_PATH2)) {
|
|
38867
39469
|
return true;
|
|
38868
39470
|
}
|
|
38869
39471
|
try {
|
|
38870
|
-
const cacheData = JSON.parse(
|
|
39472
|
+
const cacheData = JSON.parse(readFileSync13(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
38871
39473
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
38872
39474
|
const now = new Date;
|
|
38873
39475
|
const ageInHours = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
|
@@ -39468,9 +40070,9 @@ var init_model_selector = __esm(() => {
|
|
|
39468
40070
|
init_model_loader();
|
|
39469
40071
|
__filename5 = fileURLToPath4(import.meta.url);
|
|
39470
40072
|
__dirname5 = dirname4(__filename5);
|
|
39471
|
-
CLAUDISH_CACHE_DIR3 =
|
|
39472
|
-
ALL_MODELS_JSON_PATH2 =
|
|
39473
|
-
RECOMMENDED_MODELS_JSON_PATH =
|
|
40073
|
+
CLAUDISH_CACHE_DIR3 = join15(homedir14(), ".claudish");
|
|
40074
|
+
ALL_MODELS_JSON_PATH2 = join15(CLAUDISH_CACHE_DIR3, "all-models.json");
|
|
40075
|
+
RECOMMENDED_MODELS_JSON_PATH = join15(__dirname5, "../recommended-models.json");
|
|
39474
40076
|
PROVIDER_FILTER_ALIASES = {
|
|
39475
40077
|
zen: "Zen",
|
|
39476
40078
|
openrouter: "OpenRouter",
|
|
@@ -40328,11 +40930,11 @@ async function runConsentPrompt(ctx) {
|
|
|
40328
40930
|
Does NOT send: prompts, paths, API keys, or credentials.
|
|
40329
40931
|
Disable anytime: claudish telemetry off
|
|
40330
40932
|
`);
|
|
40331
|
-
const answer = await new Promise((
|
|
40933
|
+
const answer = await new Promise((resolve2) => {
|
|
40332
40934
|
const rl = createInterface4({ input: process.stdin, output: process.stderr });
|
|
40333
40935
|
rl.question("Send anonymous error report? [y/N] ", (ans) => {
|
|
40334
40936
|
rl.close();
|
|
40335
|
-
|
|
40937
|
+
resolve2(ans.trim().toLowerCase());
|
|
40336
40938
|
});
|
|
40337
40939
|
});
|
|
40338
40940
|
const accepted = answer === "y" || answer === "yes";
|
|
@@ -40516,25 +41118,25 @@ var init_telemetry = __esm(() => {
|
|
|
40516
41118
|
|
|
40517
41119
|
// src/stats-buffer.ts
|
|
40518
41120
|
import {
|
|
40519
|
-
existsSync as
|
|
40520
|
-
mkdirSync as
|
|
40521
|
-
readFileSync as
|
|
41121
|
+
existsSync as existsSync16,
|
|
41122
|
+
mkdirSync as mkdirSync9,
|
|
41123
|
+
readFileSync as readFileSync14,
|
|
40522
41124
|
renameSync,
|
|
40523
|
-
unlinkSync as
|
|
40524
|
-
writeFileSync as
|
|
41125
|
+
unlinkSync as unlinkSync6,
|
|
41126
|
+
writeFileSync as writeFileSync9
|
|
40525
41127
|
} from "fs";
|
|
40526
|
-
import { homedir as
|
|
40527
|
-
import { join as
|
|
41128
|
+
import { homedir as homedir15 } from "os";
|
|
41129
|
+
import { join as join16 } from "path";
|
|
40528
41130
|
function ensureDir() {
|
|
40529
|
-
if (!
|
|
40530
|
-
|
|
41131
|
+
if (!existsSync16(CLAUDISH_DIR)) {
|
|
41132
|
+
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
40531
41133
|
}
|
|
40532
41134
|
}
|
|
40533
41135
|
function readFromDisk() {
|
|
40534
41136
|
try {
|
|
40535
|
-
if (!
|
|
41137
|
+
if (!existsSync16(BUFFER_FILE))
|
|
40536
41138
|
return [];
|
|
40537
|
-
const raw =
|
|
41139
|
+
const raw = readFileSync14(BUFFER_FILE, "utf-8");
|
|
40538
41140
|
const parsed = JSON.parse(raw);
|
|
40539
41141
|
if (!Array.isArray(parsed.events))
|
|
40540
41142
|
return [];
|
|
@@ -40558,8 +41160,8 @@ function writeToDisk(events) {
|
|
|
40558
41160
|
ensureDir();
|
|
40559
41161
|
const trimmed = enforceSizeCap([...events]);
|
|
40560
41162
|
const payload = { version: 1, events: trimmed };
|
|
40561
|
-
const tmpFile =
|
|
40562
|
-
|
|
41163
|
+
const tmpFile = join16(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
41164
|
+
writeFileSync9(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
40563
41165
|
renameSync(tmpFile, BUFFER_FILE);
|
|
40564
41166
|
memoryCache = trimmed;
|
|
40565
41167
|
} catch {}
|
|
@@ -40603,8 +41205,8 @@ function clearBuffer() {
|
|
|
40603
41205
|
try {
|
|
40604
41206
|
memoryCache = [];
|
|
40605
41207
|
eventsSinceLastFlush = 0;
|
|
40606
|
-
if (
|
|
40607
|
-
|
|
41208
|
+
if (existsSync16(BUFFER_FILE)) {
|
|
41209
|
+
unlinkSync6(BUFFER_FILE);
|
|
40608
41210
|
}
|
|
40609
41211
|
} catch {}
|
|
40610
41212
|
}
|
|
@@ -40632,8 +41234,8 @@ function syncFlushOnExit() {
|
|
|
40632
41234
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, lastFlushTime, flushScheduled = false;
|
|
40633
41235
|
var init_stats_buffer = __esm(() => {
|
|
40634
41236
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
40635
|
-
CLAUDISH_DIR =
|
|
40636
|
-
BUFFER_FILE =
|
|
41237
|
+
CLAUDISH_DIR = join16(homedir15(), ".claudish");
|
|
41238
|
+
BUFFER_FILE = join16(CLAUDISH_DIR, "stats-buffer.json");
|
|
40637
41239
|
lastFlushTime = Date.now();
|
|
40638
41240
|
process.on("exit", syncFlushOnExit);
|
|
40639
41241
|
process.on("SIGTERM", () => {
|
|
@@ -41118,16 +41720,16 @@ import { EventEmitter } from "events";
|
|
|
41118
41720
|
import { Buffer as Buffer2 } from "buffer";
|
|
41119
41721
|
import { Buffer as Buffer3 } from "buffer";
|
|
41120
41722
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
41121
|
-
import { resolve, dirname as dirname5 } from "path";
|
|
41723
|
+
import { resolve as resolve2, dirname as dirname5 } from "path";
|
|
41122
41724
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
41123
|
-
import { resolve as
|
|
41124
|
-
import { existsSync as
|
|
41125
|
-
import { basename, join as
|
|
41725
|
+
import { resolve as resolve22, isAbsolute, parse as parse6 } from "path";
|
|
41726
|
+
import { existsSync as existsSync17 } from "fs";
|
|
41727
|
+
import { basename, join as join17 } from "path";
|
|
41126
41728
|
import os from "os";
|
|
41127
41729
|
import path from "path";
|
|
41128
41730
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
41129
41731
|
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr4 } from "bun:ffi";
|
|
41130
|
-
import { existsSync as existsSync22, writeFileSync as
|
|
41732
|
+
import { existsSync as existsSync22, writeFileSync as writeFileSync10 } from "fs";
|
|
41131
41733
|
import { EventEmitter as EventEmitter4 } from "events";
|
|
41132
41734
|
import { toArrayBuffer, ptr } from "bun:ffi";
|
|
41133
41735
|
import { ptr as ptr2, toArrayBuffer as toArrayBuffer2 } from "bun:ffi";
|
|
@@ -43463,24 +44065,24 @@ function getParsers() {
|
|
|
43463
44065
|
{
|
|
43464
44066
|
filetype: "javascript",
|
|
43465
44067
|
queries: {
|
|
43466
|
-
highlights: [
|
|
44068
|
+
highlights: [resolve2(dirname5(fileURLToPath5(import.meta.url)), highlights_default)]
|
|
43467
44069
|
},
|
|
43468
|
-
wasm:
|
|
44070
|
+
wasm: resolve2(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_javascript_default)
|
|
43469
44071
|
},
|
|
43470
44072
|
{
|
|
43471
44073
|
filetype: "typescript",
|
|
43472
44074
|
queries: {
|
|
43473
|
-
highlights: [
|
|
44075
|
+
highlights: [resolve2(dirname5(fileURLToPath5(import.meta.url)), highlights_default2)]
|
|
43474
44076
|
},
|
|
43475
|
-
wasm:
|
|
44077
|
+
wasm: resolve2(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_typescript_default)
|
|
43476
44078
|
},
|
|
43477
44079
|
{
|
|
43478
44080
|
filetype: "markdown",
|
|
43479
44081
|
queries: {
|
|
43480
|
-
highlights: [
|
|
43481
|
-
injections: [
|
|
44082
|
+
highlights: [resolve2(dirname5(fileURLToPath5(import.meta.url)), highlights_default3)],
|
|
44083
|
+
injections: [resolve2(dirname5(fileURLToPath5(import.meta.url)), injections_default)]
|
|
43482
44084
|
},
|
|
43483
|
-
wasm:
|
|
44085
|
+
wasm: resolve2(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_default),
|
|
43484
44086
|
injectionMapping: {
|
|
43485
44087
|
nodeTypes: {
|
|
43486
44088
|
inline: "markdown_inline",
|
|
@@ -43499,16 +44101,16 @@ function getParsers() {
|
|
|
43499
44101
|
{
|
|
43500
44102
|
filetype: "markdown_inline",
|
|
43501
44103
|
queries: {
|
|
43502
|
-
highlights: [
|
|
44104
|
+
highlights: [resolve2(dirname5(fileURLToPath5(import.meta.url)), highlights_default4)]
|
|
43503
44105
|
},
|
|
43504
|
-
wasm:
|
|
44106
|
+
wasm: resolve2(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_inline_default)
|
|
43505
44107
|
},
|
|
43506
44108
|
{
|
|
43507
44109
|
filetype: "zig",
|
|
43508
44110
|
queries: {
|
|
43509
|
-
highlights: [
|
|
44111
|
+
highlights: [resolve2(dirname5(fileURLToPath5(import.meta.url)), highlights_default5)]
|
|
43510
44112
|
},
|
|
43511
|
-
wasm:
|
|
44113
|
+
wasm: resolve2(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_zig_default)
|
|
43512
44114
|
}
|
|
43513
44115
|
];
|
|
43514
44116
|
}
|
|
@@ -43521,7 +44123,7 @@ function getBunfsRootPath() {
|
|
|
43521
44123
|
return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
|
|
43522
44124
|
}
|
|
43523
44125
|
function normalizeBunfsPath(fileName) {
|
|
43524
|
-
return
|
|
44126
|
+
return join17(getBunfsRootPath(), basename(fileName));
|
|
43525
44127
|
}
|
|
43526
44128
|
function isValidDirectoryName(name) {
|
|
43527
44129
|
if (!name || typeof name !== "string") {
|
|
@@ -46473,7 +47075,7 @@ function convertToDebugSymbols(symbols) {
|
|
|
46473
47075
|
if (env.OTUI_DEBUG_FFI && globalFFILogPath) {
|
|
46474
47076
|
const logPath = globalFFILogPath;
|
|
46475
47077
|
const writeSync3 = (msg) => {
|
|
46476
|
-
|
|
47078
|
+
writeFileSync10(logPath, msg + `
|
|
46477
47079
|
`, { flag: "a" });
|
|
46478
47080
|
};
|
|
46479
47081
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
@@ -53717,7 +54319,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
53717
54319
|
worker_path = this.options.workerPath;
|
|
53718
54320
|
} else {
|
|
53719
54321
|
worker_path = new URL("./parser.worker.js", import.meta.url).href;
|
|
53720
|
-
if (!
|
|
54322
|
+
if (!existsSync17(resolve22(import.meta.dirname, "parser.worker.js"))) {
|
|
53721
54323
|
worker_path = new URL("./parser.worker.ts", import.meta.url).href;
|
|
53722
54324
|
}
|
|
53723
54325
|
}
|
|
@@ -53783,7 +54385,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
53783
54385
|
return normalizeBunfsPath(parse6(path2).base);
|
|
53784
54386
|
}
|
|
53785
54387
|
if (!isAbsolute(path2)) {
|
|
53786
|
-
return
|
|
54388
|
+
return resolve22(path2);
|
|
53787
54389
|
}
|
|
53788
54390
|
return path2;
|
|
53789
54391
|
}
|
|
@@ -98429,24 +99031,163 @@ var init_tui = __esm(async () => {
|
|
|
98429
99031
|
}
|
|
98430
99032
|
});
|
|
98431
99033
|
|
|
99034
|
+
// src/team-cli.ts
|
|
99035
|
+
var exports_team_cli = {};
|
|
99036
|
+
__export(exports_team_cli, {
|
|
99037
|
+
teamCommand: () => teamCommand
|
|
99038
|
+
});
|
|
99039
|
+
import { readFileSync as readFileSync15 } from "fs";
|
|
99040
|
+
import { join as join18 } from "path";
|
|
99041
|
+
function getFlag(args, flag) {
|
|
99042
|
+
const idx = args.indexOf(flag);
|
|
99043
|
+
if (idx === -1 || idx + 1 >= args.length)
|
|
99044
|
+
return;
|
|
99045
|
+
return args[idx + 1];
|
|
99046
|
+
}
|
|
99047
|
+
function hasFlag(args, flag) {
|
|
99048
|
+
return args.includes(flag);
|
|
99049
|
+
}
|
|
99050
|
+
function printStatus(status) {
|
|
99051
|
+
const modelIds = Object.keys(status.models).sort();
|
|
99052
|
+
console.log(`
|
|
99053
|
+
Team Status (started: ${status.startedAt})`);
|
|
99054
|
+
console.log("\u2500".repeat(60));
|
|
99055
|
+
for (const id of modelIds) {
|
|
99056
|
+
const m2 = status.models[id];
|
|
99057
|
+
const duration3 = m2.startedAt && m2.completedAt ? `${Math.round((new Date(m2.completedAt).getTime() - new Date(m2.startedAt).getTime()) / 1000)}s` : m2.startedAt ? "running" : "pending";
|
|
99058
|
+
const size = m2.outputSize > 0 ? ` (${m2.outputSize} bytes)` : "";
|
|
99059
|
+
console.log(` ${id} ${m2.state.padEnd(10)} ${duration3}${size}`);
|
|
99060
|
+
}
|
|
99061
|
+
console.log("");
|
|
99062
|
+
}
|
|
99063
|
+
function printHelp2() {
|
|
99064
|
+
console.log(`
|
|
99065
|
+
Usage: claudish team <subcommand> [options]
|
|
99066
|
+
|
|
99067
|
+
Subcommands:
|
|
99068
|
+
run Run multiple models on a task in parallel
|
|
99069
|
+
judge Blind-judge existing model outputs
|
|
99070
|
+
run-and-judge Run models then judge their outputs
|
|
99071
|
+
status Show current session status
|
|
99072
|
+
|
|
99073
|
+
Options (run / run-and-judge):
|
|
99074
|
+
--path <dir> Session directory (default: .)
|
|
99075
|
+
--models <a,b,...> Comma-separated model IDs to run
|
|
99076
|
+
--input <text> Task prompt (or create input.md in --path beforehand)
|
|
99077
|
+
--timeout <secs> Timeout per model in seconds (default: 300)
|
|
99078
|
+
|
|
99079
|
+
Options (judge / run-and-judge):
|
|
99080
|
+
--judges <a,b,...> Comma-separated judge model IDs (default: same as runners)
|
|
99081
|
+
|
|
99082
|
+
Options (status):
|
|
99083
|
+
--path <dir> Session directory (default: .)
|
|
99084
|
+
|
|
99085
|
+
Examples:
|
|
99086
|
+
claudish team run --path ./review --models minimax-m2.5,kimi-k2.5 --input "Review this code"
|
|
99087
|
+
claudish team judge --path ./review
|
|
99088
|
+
claudish team run-and-judge --path ./review --models gpt-5.4,gemini-3.1-pro-preview --input "Evaluate this design"
|
|
99089
|
+
claudish team status --path ./review
|
|
99090
|
+
`);
|
|
99091
|
+
}
|
|
99092
|
+
async function teamCommand(args) {
|
|
99093
|
+
const subcommand = args[0];
|
|
99094
|
+
if (!subcommand || hasFlag(args, "--help") || hasFlag(args, "-h")) {
|
|
99095
|
+
printHelp2();
|
|
99096
|
+
process.exit(0);
|
|
99097
|
+
}
|
|
99098
|
+
const rawSessionPath = getFlag(args, "--path") ?? ".";
|
|
99099
|
+
let sessionPath;
|
|
99100
|
+
try {
|
|
99101
|
+
sessionPath = validateSessionPath(rawSessionPath);
|
|
99102
|
+
} catch (err) {
|
|
99103
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
99104
|
+
process.exit(1);
|
|
99105
|
+
}
|
|
99106
|
+
const modelsRaw = getFlag(args, "--models");
|
|
99107
|
+
const judgesRaw = getFlag(args, "--judges");
|
|
99108
|
+
const input = getFlag(args, "--input");
|
|
99109
|
+
const timeoutStr = getFlag(args, "--timeout");
|
|
99110
|
+
const timeout = timeoutStr ? parseInt(timeoutStr, 10) : 300;
|
|
99111
|
+
const models = modelsRaw ? modelsRaw.split(",").map((m2) => m2.trim()).filter(Boolean) : [];
|
|
99112
|
+
const judges = judgesRaw ? judgesRaw.split(",").map((m2) => m2.trim()).filter(Boolean) : undefined;
|
|
99113
|
+
switch (subcommand) {
|
|
99114
|
+
case "run": {
|
|
99115
|
+
if (models.length === 0) {
|
|
99116
|
+
console.error("Error: --models is required for 'run'");
|
|
99117
|
+
process.exit(1);
|
|
99118
|
+
}
|
|
99119
|
+
setupSession(sessionPath, models, input);
|
|
99120
|
+
const runStatus = await runModels(sessionPath, {
|
|
99121
|
+
timeout,
|
|
99122
|
+
onStatusChange: (id, s) => {
|
|
99123
|
+
process.stderr.write(`[team] ${id}: ${s.state}
|
|
99124
|
+
`);
|
|
99125
|
+
}
|
|
99126
|
+
});
|
|
99127
|
+
printStatus(runStatus);
|
|
99128
|
+
break;
|
|
99129
|
+
}
|
|
99130
|
+
case "judge": {
|
|
99131
|
+
const verdict = await judgeResponses(sessionPath, { judges });
|
|
99132
|
+
console.log(readFileSync15(join18(sessionPath, "verdict.md"), "utf-8"));
|
|
99133
|
+
break;
|
|
99134
|
+
}
|
|
99135
|
+
case "run-and-judge": {
|
|
99136
|
+
if (models.length === 0) {
|
|
99137
|
+
console.error("Error: --models is required for 'run-and-judge'");
|
|
99138
|
+
process.exit(1);
|
|
99139
|
+
}
|
|
99140
|
+
setupSession(sessionPath, models, input);
|
|
99141
|
+
const status = await runModels(sessionPath, {
|
|
99142
|
+
timeout,
|
|
99143
|
+
onStatusChange: (id, s) => {
|
|
99144
|
+
process.stderr.write(`[team] ${id}: ${s.state}
|
|
99145
|
+
`);
|
|
99146
|
+
}
|
|
99147
|
+
});
|
|
99148
|
+
printStatus(status);
|
|
99149
|
+
await judgeResponses(sessionPath, { judges });
|
|
99150
|
+
console.log(readFileSync15(join18(sessionPath, "verdict.md"), "utf-8"));
|
|
99151
|
+
break;
|
|
99152
|
+
}
|
|
99153
|
+
case "status": {
|
|
99154
|
+
const status = getStatus(sessionPath);
|
|
99155
|
+
printStatus(status);
|
|
99156
|
+
break;
|
|
99157
|
+
}
|
|
99158
|
+
default: {
|
|
99159
|
+
console.error(`Unknown team subcommand: ${subcommand}`);
|
|
99160
|
+
printHelp2();
|
|
99161
|
+
process.exit(1);
|
|
99162
|
+
}
|
|
99163
|
+
}
|
|
99164
|
+
}
|
|
99165
|
+
var init_team_cli = __esm(() => {
|
|
99166
|
+
init_team_orchestrator();
|
|
99167
|
+
});
|
|
99168
|
+
|
|
98432
99169
|
// src/claude-runner.ts
|
|
98433
99170
|
var exports_claude_runner = {};
|
|
98434
99171
|
__export(exports_claude_runner, {
|
|
98435
99172
|
runClaudeWithProxy: () => runClaudeWithProxy,
|
|
98436
99173
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
98437
99174
|
});
|
|
98438
|
-
import { spawn } from "child_process";
|
|
98439
|
-
import { writeFileSync as
|
|
98440
|
-
import { tmpdir as tmpdir2, homedir as
|
|
98441
|
-
import { join as
|
|
99175
|
+
import { spawn as spawn2 } from "child_process";
|
|
99176
|
+
import { writeFileSync as writeFileSync11, unlinkSync as unlinkSync7, mkdirSync as mkdirSync10, existsSync as existsSync18, readFileSync as readFileSync16 } from "fs";
|
|
99177
|
+
import { tmpdir as tmpdir2, homedir as homedir16 } from "os";
|
|
99178
|
+
import { join as join19 } from "path";
|
|
99179
|
+
function hasNativeAnthropicMapping(config3) {
|
|
99180
|
+
const models = [config3.model, config3.modelOpus, config3.modelSonnet, config3.modelHaiku, config3.modelSubagent];
|
|
99181
|
+
return models.some((m2) => m2 && parseModelSpec(m2).provider === "native-anthropic");
|
|
99182
|
+
}
|
|
98442
99183
|
function isWindows2() {
|
|
98443
99184
|
return process.platform === "win32";
|
|
98444
99185
|
}
|
|
98445
99186
|
function createStatusLineScript(tokenFilePath) {
|
|
98446
99187
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
98447
|
-
const claudishDir =
|
|
99188
|
+
const claudishDir = join19(homeDir, ".claudish");
|
|
98448
99189
|
const timestamp = Date.now();
|
|
98449
|
-
const scriptPath =
|
|
99190
|
+
const scriptPath = join19(claudishDir, `status-${timestamp}.js`);
|
|
98450
99191
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
98451
99192
|
const script = `
|
|
98452
99193
|
const fs = require('fs');
|
|
@@ -98526,18 +99267,18 @@ process.stdin.on('end', () => {
|
|
|
98526
99267
|
}
|
|
98527
99268
|
});
|
|
98528
99269
|
`;
|
|
98529
|
-
|
|
99270
|
+
writeFileSync11(scriptPath, script, "utf-8");
|
|
98530
99271
|
return scriptPath;
|
|
98531
99272
|
}
|
|
98532
99273
|
function createTempSettingsFile(modelDisplay, port) {
|
|
98533
99274
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
98534
|
-
const claudishDir =
|
|
99275
|
+
const claudishDir = join19(homeDir, ".claudish");
|
|
98535
99276
|
try {
|
|
98536
|
-
|
|
99277
|
+
mkdirSync10(claudishDir, { recursive: true });
|
|
98537
99278
|
} catch {}
|
|
98538
99279
|
const timestamp = Date.now();
|
|
98539
|
-
const tempPath =
|
|
98540
|
-
const tokenFilePath =
|
|
99280
|
+
const tempPath = join19(claudishDir, `settings-${timestamp}.json`);
|
|
99281
|
+
const tokenFilePath = join19(claudishDir, `tokens-${port}.json`);
|
|
98541
99282
|
let statusCommand;
|
|
98542
99283
|
if (isWindows2()) {
|
|
98543
99284
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -98559,7 +99300,7 @@ function createTempSettingsFile(modelDisplay, port) {
|
|
|
98559
99300
|
padding: 0
|
|
98560
99301
|
};
|
|
98561
99302
|
const settings = { statusLine };
|
|
98562
|
-
|
|
99303
|
+
writeFileSync11(tempPath, JSON.stringify(settings, null, 2), "utf-8");
|
|
98563
99304
|
return { path: tempPath, statusLine };
|
|
98564
99305
|
}
|
|
98565
99306
|
function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
@@ -98573,11 +99314,11 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
98573
99314
|
if (userSettingsValue.trimStart().startsWith("{")) {
|
|
98574
99315
|
userSettings = JSON.parse(userSettingsValue);
|
|
98575
99316
|
} else {
|
|
98576
|
-
const rawUserSettings =
|
|
99317
|
+
const rawUserSettings = readFileSync16(userSettingsValue, "utf-8");
|
|
98577
99318
|
userSettings = JSON.parse(rawUserSettings);
|
|
98578
99319
|
}
|
|
98579
99320
|
userSettings.statusLine = statusLine;
|
|
98580
|
-
|
|
99321
|
+
writeFileSync11(tempSettingsPath, JSON.stringify(userSettings, null, 2), "utf-8");
|
|
98581
99322
|
} catch {
|
|
98582
99323
|
if (!config3.quiet) {
|
|
98583
99324
|
console.warn(`[claudish] Warning: could not merge user settings: ${userSettingsValue}`);
|
|
@@ -98636,14 +99377,19 @@ async function runClaudeWithProxy(config3, proxyUrl) {
|
|
|
98636
99377
|
env2[ENV.ANTHROPIC_MODEL] = modelId;
|
|
98637
99378
|
env2[ENV.ANTHROPIC_SMALL_FAST_MODEL] = modelId;
|
|
98638
99379
|
}
|
|
98639
|
-
|
|
98640
|
-
|
|
99380
|
+
if (hasNativeAnthropicMapping(config3)) {} else {
|
|
99381
|
+
env2.ANTHROPIC_API_KEY = process.env.ANTHROPIC_API_KEY || "sk-ant-api03-placeholder-not-used-proxy-handles-auth-with-openrouter-key-xxxxxxxxxxxxxxxxxxxxx";
|
|
99382
|
+
env2.ANTHROPIC_AUTH_TOKEN = process.env.ANTHROPIC_AUTH_TOKEN || "placeholder-token-not-used-proxy-handles-auth";
|
|
99383
|
+
}
|
|
98641
99384
|
}
|
|
98642
99385
|
const log2 = (message) => {
|
|
98643
99386
|
if (!config3.quiet) {
|
|
98644
99387
|
console.log(message);
|
|
98645
99388
|
}
|
|
98646
99389
|
};
|
|
99390
|
+
if (!config3.monitor && hasNativeAnthropicMapping(config3)) {
|
|
99391
|
+
log2("[claudish] Native Claude model detected \u2014 using Claude Code subscription credentials");
|
|
99392
|
+
}
|
|
98647
99393
|
if (config3.interactive) {
|
|
98648
99394
|
log2(`
|
|
98649
99395
|
[claudish] Model: ${modelDisplayName}
|
|
@@ -98660,14 +99406,14 @@ async function runClaudeWithProxy(config3, proxyUrl) {
|
|
|
98660
99406
|
console.error("Install it from: https://claude.com/claude-code");
|
|
98661
99407
|
console.error(`
|
|
98662
99408
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
98663
|
-
const home =
|
|
98664
|
-
const localPath = isWindows2() ?
|
|
99409
|
+
const home = homedir16();
|
|
99410
|
+
const localPath = isWindows2() ? join19(home, ".claude", "local", "claude.exe") : join19(home, ".claude", "local", "claude");
|
|
98665
99411
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
98666
99412
|
process.exit(1);
|
|
98667
99413
|
}
|
|
98668
99414
|
const needsShell = isWindows2() && claudeBinary.endsWith(".cmd");
|
|
98669
99415
|
const spawnCommand = needsShell ? `"${claudeBinary}"` : claudeBinary;
|
|
98670
|
-
const proc =
|
|
99416
|
+
const proc = spawn2(spawnCommand, claudeArgs, {
|
|
98671
99417
|
env: env2,
|
|
98672
99418
|
stdio: "inherit",
|
|
98673
99419
|
shell: needsShell
|
|
@@ -98679,7 +99425,7 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
98679
99425
|
});
|
|
98680
99426
|
});
|
|
98681
99427
|
try {
|
|
98682
|
-
|
|
99428
|
+
unlinkSync7(tempSettingsPath);
|
|
98683
99429
|
} catch (error46) {}
|
|
98684
99430
|
return exitCode;
|
|
98685
99431
|
}
|
|
@@ -98693,7 +99439,7 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet) {
|
|
|
98693
99439
|
}
|
|
98694
99440
|
proc.kill();
|
|
98695
99441
|
try {
|
|
98696
|
-
|
|
99442
|
+
unlinkSync7(tempSettingsPath);
|
|
98697
99443
|
} catch {}
|
|
98698
99444
|
process.exit(0);
|
|
98699
99445
|
});
|
|
@@ -98702,23 +99448,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet) {
|
|
|
98702
99448
|
async function findClaudeBinary() {
|
|
98703
99449
|
const isWindows3 = process.platform === "win32";
|
|
98704
99450
|
if (process.env.CLAUDE_PATH) {
|
|
98705
|
-
if (
|
|
99451
|
+
if (existsSync18(process.env.CLAUDE_PATH)) {
|
|
98706
99452
|
return process.env.CLAUDE_PATH;
|
|
98707
99453
|
}
|
|
98708
99454
|
}
|
|
98709
|
-
const home =
|
|
98710
|
-
const localPath = isWindows3 ?
|
|
98711
|
-
if (
|
|
99455
|
+
const home = homedir16();
|
|
99456
|
+
const localPath = isWindows3 ? join19(home, ".claude", "local", "claude.exe") : join19(home, ".claude", "local", "claude");
|
|
99457
|
+
if (existsSync18(localPath)) {
|
|
98712
99458
|
return localPath;
|
|
98713
99459
|
}
|
|
98714
99460
|
if (isWindows3) {
|
|
98715
99461
|
const windowsPaths = [
|
|
98716
|
-
|
|
98717
|
-
|
|
98718
|
-
|
|
99462
|
+
join19(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
99463
|
+
join19(home, ".npm-global", "claude.cmd"),
|
|
99464
|
+
join19(home, "node_modules", ".bin", "claude.cmd")
|
|
98719
99465
|
];
|
|
98720
99466
|
for (const path2 of windowsPaths) {
|
|
98721
|
-
if (
|
|
99467
|
+
if (existsSync18(path2)) {
|
|
98722
99468
|
return path2;
|
|
98723
99469
|
}
|
|
98724
99470
|
}
|
|
@@ -98726,21 +99472,21 @@ async function findClaudeBinary() {
|
|
|
98726
99472
|
const commonPaths = [
|
|
98727
99473
|
"/usr/local/bin/claude",
|
|
98728
99474
|
"/opt/homebrew/bin/claude",
|
|
98729
|
-
|
|
98730
|
-
|
|
98731
|
-
|
|
99475
|
+
join19(home, ".npm-global/bin/claude"),
|
|
99476
|
+
join19(home, ".local/bin/claude"),
|
|
99477
|
+
join19(home, "node_modules/.bin/claude"),
|
|
98732
99478
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
98733
|
-
|
|
99479
|
+
join19(home, "../usr/bin/claude")
|
|
98734
99480
|
];
|
|
98735
99481
|
for (const path2 of commonPaths) {
|
|
98736
|
-
if (
|
|
99482
|
+
if (existsSync18(path2)) {
|
|
98737
99483
|
return path2;
|
|
98738
99484
|
}
|
|
98739
99485
|
}
|
|
98740
99486
|
}
|
|
98741
99487
|
try {
|
|
98742
99488
|
const shellCommand = isWindows3 ? "where claude" : "command -v claude";
|
|
98743
|
-
const proc =
|
|
99489
|
+
const proc = spawn2(shellCommand, [], {
|
|
98744
99490
|
stdio: "pipe",
|
|
98745
99491
|
shell: true
|
|
98746
99492
|
});
|
|
@@ -98772,6 +99518,7 @@ async function checkClaudeInstalled() {
|
|
|
98772
99518
|
}
|
|
98773
99519
|
var init_claude_runner = __esm(() => {
|
|
98774
99520
|
init_config();
|
|
99521
|
+
init_model_parser();
|
|
98775
99522
|
});
|
|
98776
99523
|
|
|
98777
99524
|
// src/port-manager.ts
|
|
@@ -101360,8 +102107,10 @@ class OpenRouterProvider {
|
|
|
101360
102107
|
streamFormat = "openai-sse";
|
|
101361
102108
|
apiKey;
|
|
101362
102109
|
queue;
|
|
101363
|
-
|
|
102110
|
+
modelId;
|
|
102111
|
+
constructor(apiKey, modelId) {
|
|
101364
102112
|
this.apiKey = apiKey;
|
|
102113
|
+
this.modelId = modelId || "";
|
|
101365
102114
|
this.queue = OpenRouterRequestQueue.getInstance();
|
|
101366
102115
|
}
|
|
101367
102116
|
overrideStreamFormat() {
|
|
@@ -101380,10 +102129,16 @@ class OpenRouterProvider {
|
|
|
101380
102129
|
async enqueueRequest(fetchFn) {
|
|
101381
102130
|
return this.queue.enqueue(fetchFn);
|
|
101382
102131
|
}
|
|
102132
|
+
getContextWindow() {
|
|
102133
|
+
const models = this.modelId ? getCachedOpenRouterModels() : null;
|
|
102134
|
+
const model = models?.find((m2) => m2.id === this.modelId);
|
|
102135
|
+
return model?.context_length || model?.top_provider?.context_length || 200000;
|
|
102136
|
+
}
|
|
101383
102137
|
}
|
|
101384
102138
|
var OPENROUTER_API_URL2 = "https://openrouter.ai/api/v1/chat/completions";
|
|
101385
102139
|
var init_openrouter2 = __esm(() => {
|
|
101386
102140
|
init_openrouter_queue();
|
|
102141
|
+
init_model_loader();
|
|
101387
102142
|
});
|
|
101388
102143
|
|
|
101389
102144
|
// src/adapters/openrouter-adapter.ts
|
|
@@ -102349,9 +103104,9 @@ var init_middleware = __esm(() => {
|
|
|
102349
103104
|
});
|
|
102350
103105
|
|
|
102351
103106
|
// src/handlers/shared/token-tracker.ts
|
|
102352
|
-
import { mkdirSync as
|
|
102353
|
-
import { homedir as
|
|
102354
|
-
import { join as
|
|
103107
|
+
import { mkdirSync as mkdirSync11, writeFileSync as writeFileSync12 } from "fs";
|
|
103108
|
+
import { homedir as homedir17 } from "os";
|
|
103109
|
+
import { join as join20 } from "path";
|
|
102355
103110
|
|
|
102356
103111
|
class TokenTracker {
|
|
102357
103112
|
port;
|
|
@@ -102465,9 +103220,9 @@ class TokenTracker {
|
|
|
102465
103220
|
is_free: isFreeModel,
|
|
102466
103221
|
is_estimated: isEstimate || false
|
|
102467
103222
|
};
|
|
102468
|
-
const claudishDir =
|
|
102469
|
-
|
|
102470
|
-
|
|
103223
|
+
const claudishDir = join20(homedir17(), ".claudish");
|
|
103224
|
+
mkdirSync11(claudishDir, { recursive: true });
|
|
103225
|
+
writeFileSync12(join20(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
102471
103226
|
} catch (e) {
|
|
102472
103227
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
102473
103228
|
}
|
|
@@ -103519,9 +104274,9 @@ class ComposedHandler {
|
|
|
103519
104274
|
});
|
|
103520
104275
|
return c.json({ error: { type: "connection_error", message: err.message } }, 503);
|
|
103521
104276
|
}
|
|
103522
|
-
|
|
103523
|
-
|
|
103524
|
-
|
|
104277
|
+
}
|
|
104278
|
+
if (this.provider.getContextWindow) {
|
|
104279
|
+
this.tokenTracker.setContextWindow(this.provider.getContextWindow());
|
|
103525
104280
|
}
|
|
103526
104281
|
if (this.provider.transformPayload) {
|
|
103527
104282
|
requestPayload = this.provider.transformPayload(requestPayload);
|
|
@@ -103888,9 +104643,9 @@ var init_composed_handler = __esm(() => {
|
|
|
103888
104643
|
});
|
|
103889
104644
|
|
|
103890
104645
|
// src/services/pricing-cache.ts
|
|
103891
|
-
import { readFileSync as
|
|
103892
|
-
import { homedir as
|
|
103893
|
-
import { join as
|
|
104646
|
+
import { readFileSync as readFileSync17, writeFileSync as writeFileSync13, existsSync as existsSync19, mkdirSync as mkdirSync12, statSync as statSync2 } from "fs";
|
|
104647
|
+
import { homedir as homedir18 } from "os";
|
|
104648
|
+
import { join as join21 } from "path";
|
|
103894
104649
|
function getDynamicPricingSync(provider, modelName) {
|
|
103895
104650
|
if (provider === "openrouter") {
|
|
103896
104651
|
const direct = pricingMap.get(modelName);
|
|
@@ -103955,12 +104710,12 @@ async function warmPricingCache() {
|
|
|
103955
104710
|
}
|
|
103956
104711
|
function loadDiskCache() {
|
|
103957
104712
|
try {
|
|
103958
|
-
if (!
|
|
104713
|
+
if (!existsSync19(CACHE_FILE))
|
|
103959
104714
|
return false;
|
|
103960
|
-
const stat =
|
|
104715
|
+
const stat = statSync2(CACHE_FILE);
|
|
103961
104716
|
const age = Date.now() - stat.mtimeMs;
|
|
103962
104717
|
const isFresh = age < CACHE_TTL_MS;
|
|
103963
|
-
const raw2 =
|
|
104718
|
+
const raw2 = readFileSync17(CACHE_FILE, "utf-8");
|
|
103964
104719
|
const data = JSON.parse(raw2);
|
|
103965
104720
|
for (const [key, pricing] of Object.entries(data)) {
|
|
103966
104721
|
pricingMap.set(key, pricing);
|
|
@@ -103972,12 +104727,12 @@ function loadDiskCache() {
|
|
|
103972
104727
|
}
|
|
103973
104728
|
function saveDiskCache() {
|
|
103974
104729
|
try {
|
|
103975
|
-
|
|
104730
|
+
mkdirSync12(CACHE_DIR, { recursive: true });
|
|
103976
104731
|
const data = {};
|
|
103977
104732
|
for (const [key, pricing] of pricingMap) {
|
|
103978
104733
|
data[key] = pricing;
|
|
103979
104734
|
}
|
|
103980
|
-
|
|
104735
|
+
writeFileSync13(CACHE_FILE, JSON.stringify(data), "utf-8");
|
|
103981
104736
|
} catch (error46) {
|
|
103982
104737
|
log(`[PricingCache] Error saving disk cache: ${error46}`);
|
|
103983
104738
|
}
|
|
@@ -104007,8 +104762,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
104007
104762
|
init_model_loader();
|
|
104008
104763
|
init_remote_provider_types();
|
|
104009
104764
|
pricingMap = new Map;
|
|
104010
|
-
CACHE_DIR =
|
|
104011
|
-
CACHE_FILE =
|
|
104765
|
+
CACHE_DIR = join21(homedir18(), ".claudish");
|
|
104766
|
+
CACHE_FILE = join21(CACHE_DIR, "pricing-cache.json");
|
|
104012
104767
|
CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
104013
104768
|
PROVIDER_TO_OR_PREFIX = {
|
|
104014
104769
|
openai: ["openai/"],
|
|
@@ -104467,12 +105222,12 @@ class AnthropicCompatProvider {
|
|
|
104467
105222
|
}
|
|
104468
105223
|
if (this.provider.name === "kimi-coding" && !this.apiKey) {
|
|
104469
105224
|
try {
|
|
104470
|
-
const { existsSync:
|
|
104471
|
-
const { join:
|
|
104472
|
-
const { homedir:
|
|
104473
|
-
const credPath =
|
|
104474
|
-
if (
|
|
104475
|
-
const data = JSON.parse(
|
|
105225
|
+
const { existsSync: existsSync20, readFileSync: readFileSync18 } = await import("fs");
|
|
105226
|
+
const { join: join22 } = await import("path");
|
|
105227
|
+
const { homedir: homedir19 } = await import("os");
|
|
105228
|
+
const credPath = join22(homedir19(), ".claudish", "kimi-oauth.json");
|
|
105229
|
+
if (existsSync20(credPath)) {
|
|
105230
|
+
const data = JSON.parse(readFileSync18(credPath, "utf-8"));
|
|
104476
105231
|
if (data.access_token && data.refresh_token) {
|
|
104477
105232
|
const { KimiOAuth: KimiOAuth2 } = await Promise.resolve().then(() => (init_kimi_oauth(), exports_kimi_oauth));
|
|
104478
105233
|
const oauth = KimiOAuth2.getInstance();
|
|
@@ -104589,12 +105344,18 @@ var init_anthropic_passthrough_adapter = __esm(() => {
|
|
|
104589
105344
|
if (model.includes("kimi-k2.5") || model.includes("kimi-k2-5"))
|
|
104590
105345
|
return 262144;
|
|
104591
105346
|
if (model.includes("kimi-k2"))
|
|
104592
|
-
return
|
|
105347
|
+
return 131000;
|
|
104593
105348
|
if (this.providerName === "kimi" || this.providerName === "kimi-coding" || model.includes("kimi")) {
|
|
104594
105349
|
return 131072;
|
|
104595
105350
|
}
|
|
105351
|
+
if (model.includes("minimax-01") || model.includes("minimax-m1"))
|
|
105352
|
+
return 1e6;
|
|
105353
|
+
if (model.includes("minimax-m2.7"))
|
|
105354
|
+
return 204800;
|
|
105355
|
+
if (model.includes("minimax-m2"))
|
|
105356
|
+
return 196608;
|
|
104596
105357
|
if (this.providerName === "minimax" || this.providerName === "minimax-coding") {
|
|
104597
|
-
return
|
|
105358
|
+
return 196608;
|
|
104598
105359
|
}
|
|
104599
105360
|
return 128000;
|
|
104600
105361
|
}
|
|
@@ -104775,10 +105536,10 @@ var init_litellm2 = __esm(() => {
|
|
|
104775
105536
|
});
|
|
104776
105537
|
|
|
104777
105538
|
// src/adapters/litellm-adapter.ts
|
|
104778
|
-
import { existsSync as
|
|
105539
|
+
import { existsSync as existsSync20, readFileSync as readFileSync18 } from "fs";
|
|
104779
105540
|
import { createHash as createHash5 } from "crypto";
|
|
104780
|
-
import { homedir as
|
|
104781
|
-
import { join as
|
|
105541
|
+
import { homedir as homedir19 } from "os";
|
|
105542
|
+
import { join as join22 } from "path";
|
|
104782
105543
|
var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
|
|
104783
105544
|
var init_litellm_adapter = __esm(() => {
|
|
104784
105545
|
init_base_adapter();
|
|
@@ -104874,10 +105635,10 @@ var init_litellm_adapter = __esm(() => {
|
|
|
104874
105635
|
checkVisionSupport() {
|
|
104875
105636
|
try {
|
|
104876
105637
|
const hash2 = createHash5("sha256").update(this.baseUrl).digest("hex").substring(0, 16);
|
|
104877
|
-
const cachePath =
|
|
104878
|
-
if (!
|
|
105638
|
+
const cachePath = join22(homedir19(), ".claudish", `litellm-models-${hash2}.json`);
|
|
105639
|
+
if (!existsSync20(cachePath))
|
|
104879
105640
|
return true;
|
|
104880
|
-
const cacheData = JSON.parse(
|
|
105641
|
+
const cacheData = JSON.parse(readFileSync18(cachePath, "utf-8"));
|
|
104881
105642
|
const model = cacheData.models?.find((m2) => m2.name === this.modelId);
|
|
104882
105643
|
if (model && model.supportsVision === false) {
|
|
104883
105644
|
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
|
|
@@ -104894,9 +105655,9 @@ var init_litellm_adapter = __esm(() => {
|
|
|
104894
105655
|
// src/auth/vertex-auth.ts
|
|
104895
105656
|
import { exec as exec4 } from "child_process";
|
|
104896
105657
|
import { promisify as promisify3 } from "util";
|
|
104897
|
-
import { existsSync as
|
|
104898
|
-
import { homedir as
|
|
104899
|
-
import { join as
|
|
105658
|
+
import { existsSync as existsSync21 } from "fs";
|
|
105659
|
+
import { homedir as homedir20 } from "os";
|
|
105660
|
+
import { join as join23 } from "path";
|
|
104900
105661
|
|
|
104901
105662
|
class VertexAuthManager {
|
|
104902
105663
|
cachedToken = null;
|
|
@@ -104950,8 +105711,8 @@ class VertexAuthManager {
|
|
|
104950
105711
|
}
|
|
104951
105712
|
async tryADC() {
|
|
104952
105713
|
try {
|
|
104953
|
-
const adcPath =
|
|
104954
|
-
if (!
|
|
105714
|
+
const adcPath = join23(homedir20(), ".config/gcloud/application_default_credentials.json");
|
|
105715
|
+
if (!existsSync21(adcPath)) {
|
|
104955
105716
|
log("[VertexAuth] ADC credentials file not found");
|
|
104956
105717
|
return null;
|
|
104957
105718
|
}
|
|
@@ -104975,7 +105736,7 @@ class VertexAuthManager {
|
|
|
104975
105736
|
if (!credPath) {
|
|
104976
105737
|
return null;
|
|
104977
105738
|
}
|
|
104978
|
-
if (!
|
|
105739
|
+
if (!existsSync21(credPath)) {
|
|
104979
105740
|
throw new Error(`Service account file not found: ${credPath}
|
|
104980
105741
|
|
|
104981
105742
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -105014,8 +105775,8 @@ function validateVertexOAuthConfig() {
|
|
|
105014
105775
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
105015
105776
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
105016
105777
|
}
|
|
105017
|
-
const adcPath =
|
|
105018
|
-
const hasADC =
|
|
105778
|
+
const adcPath = join23(homedir20(), ".config/gcloud/application_default_credentials.json");
|
|
105779
|
+
const hasADC = existsSync21(adcPath);
|
|
105019
105780
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
105020
105781
|
if (!hasADC && !hasServiceAccount) {
|
|
105021
105782
|
return `No Vertex AI credentials found.
|
|
@@ -105343,7 +106104,7 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
105343
106104
|
const parsed = parseModelSpec(targetModel);
|
|
105344
106105
|
const modelId = targetModel.includes("@") ? parsed.model : targetModel;
|
|
105345
106106
|
if (!openRouterHandlers.has(modelId)) {
|
|
105346
|
-
const orProvider = new OpenRouterProvider(openrouterApiKey || "");
|
|
106107
|
+
const orProvider = new OpenRouterProvider(openrouterApiKey || "", modelId);
|
|
105347
106108
|
const orAdapter = new OpenRouterAdapter(modelId);
|
|
105348
106109
|
openRouterHandlers.set(modelId, new ComposedHandler(orProvider, modelId, modelId, port, {
|
|
105349
106110
|
adapter: orAdapter,
|
|
@@ -105651,16 +106412,16 @@ var init_proxy_server = __esm(() => {
|
|
|
105651
106412
|
|
|
105652
106413
|
// src/index.ts
|
|
105653
106414
|
var import_dotenv2 = __toESM(require_main(), 1);
|
|
105654
|
-
import { existsSync as
|
|
105655
|
-
import { homedir as
|
|
105656
|
-
import { join as
|
|
106415
|
+
import { existsSync as existsSync23, readFileSync as readFileSync20 } from "fs";
|
|
106416
|
+
import { homedir as homedir21 } from "os";
|
|
106417
|
+
import { join as join24 } from "path";
|
|
105657
106418
|
import_dotenv2.config({ quiet: true });
|
|
105658
106419
|
function loadStoredApiKeys() {
|
|
105659
106420
|
try {
|
|
105660
|
-
const configPath =
|
|
105661
|
-
if (!
|
|
106421
|
+
const configPath = join24(homedir21(), ".claudish", "config.json");
|
|
106422
|
+
if (!existsSync23(configPath))
|
|
105662
106423
|
return;
|
|
105663
|
-
const raw2 =
|
|
106424
|
+
const raw2 = readFileSync20(configPath, "utf-8");
|
|
105664
106425
|
const cfg = JSON.parse(raw2);
|
|
105665
106426
|
if (cfg.apiKeys) {
|
|
105666
106427
|
for (const [envVar, value] of Object.entries(cfg.apiKeys)) {
|
|
@@ -105698,6 +106459,7 @@ var isProfileCommand = args[0] === "profile" || args.some((a, i) => a === "profi
|
|
|
105698
106459
|
var isTelemetryCommand = args[0] === "telemetry";
|
|
105699
106460
|
var isStatsCommand = args[0] === "stats";
|
|
105700
106461
|
var isConfigCommand = args[0] === "config";
|
|
106462
|
+
var isTeamCommand = args[0] === "team";
|
|
105701
106463
|
if (isMcpMode) {
|
|
105702
106464
|
Promise.resolve().then(() => (init_mcp_server(), exports_mcp_server)).then((mcp) => mcp.startMcpServer());
|
|
105703
106465
|
} else if (isGeminiLogin) {
|
|
@@ -105776,6 +106538,8 @@ if (isMcpMode) {
|
|
|
105776
106538
|
});
|
|
105777
106539
|
} else if (isConfigCommand) {
|
|
105778
106540
|
init_tui().then(() => exports_tui).then((m2) => m2.startConfigTui().catch(handlePromptExit));
|
|
106541
|
+
} else if (isTeamCommand) {
|
|
106542
|
+
Promise.resolve().then(() => (init_team_cli(), exports_team_cli)).then((m2) => m2.teamCommand(args.slice(1)));
|
|
105779
106543
|
} else {
|
|
105780
106544
|
runCli();
|
|
105781
106545
|
}
|
|
@@ -105790,7 +106554,7 @@ async function runCli() {
|
|
|
105790
106554
|
getMissingKeyResolutions: getMissingKeyResolutions2,
|
|
105791
106555
|
getMissingKeysError: getMissingKeysError2
|
|
105792
106556
|
} = await Promise.resolve().then(() => (init_provider_resolver(), exports_provider_resolver));
|
|
105793
|
-
const { initLogger: initLogger2, getLogFilePath: getLogFilePath2, setStderrQuiet: setStderrQuiet2 } = await Promise.resolve().then(() => (init_logger(), exports_logger));
|
|
106557
|
+
const { initLogger: initLogger2, getLogFilePath: getLogFilePath2, getAlwaysOnLogPath: getAlwaysOnLogPath2, setStderrQuiet: setStderrQuiet2 } = await Promise.resolve().then(() => (init_logger(), exports_logger));
|
|
105794
106558
|
const { findAvailablePort: findAvailablePort2 } = await Promise.resolve().then(() => (init_port_manager(), exports_port_manager));
|
|
105795
106559
|
const { createProxyServer: createProxyServer2 } = await Promise.resolve().then(() => (init_proxy_server(), exports_proxy_server));
|
|
105796
106560
|
const { checkForUpdates: checkForUpdates2 } = await Promise.resolve().then(() => (init_update_checker(), exports_update_checker));
|
|
@@ -105803,7 +106567,7 @@ async function runCli() {
|
|
|
105803
106567
|
}
|
|
105804
106568
|
try {
|
|
105805
106569
|
const cliConfig = await parseArgs2(process.argv.slice(2));
|
|
105806
|
-
initLogger2(cliConfig.debug, cliConfig.logLevel);
|
|
106570
|
+
initLogger2(cliConfig.debug, cliConfig.logLevel, cliConfig.noLogs);
|
|
105807
106571
|
const { initTelemetry: initTelemetry2 } = await Promise.resolve().then(() => (init_telemetry(), exports_telemetry));
|
|
105808
106572
|
initTelemetry2(cliConfig);
|
|
105809
106573
|
const { initStats: initStats2, showMonthlyBanner: showMonthlyBanner2 } = await Promise.resolve().then(() => (init_stats(), exports_stats));
|
|
@@ -105926,6 +106690,12 @@ async function runCli() {
|
|
|
105926
106690
|
console.log(`[claudish] Done
|
|
105927
106691
|
`);
|
|
105928
106692
|
}
|
|
106693
|
+
const sessionLogPath = getAlwaysOnLogPath2();
|
|
106694
|
+
if (exitCode !== 0 && sessionLogPath && !cliConfig.quiet) {
|
|
106695
|
+
console.error(`
|
|
106696
|
+
[claudish] Session ended with errors. Log: ${sessionLogPath}`);
|
|
106697
|
+
console.error(`[claudish] To review: /debug-logs ${sessionLogPath}`);
|
|
106698
|
+
}
|
|
105929
106699
|
process.exit(exitCode);
|
|
105930
106700
|
} catch (error46) {
|
|
105931
106701
|
console.error("[claudish] Fatal error:", error46);
|