claudish 5.17.0 → 5.18.1
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 +418 -262
- package/package.json +1 -1
- package/recommended-models.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29769,17 +29769,19 @@ async function setupGeminiUser(accessToken) {
|
|
|
29769
29769
|
return { projectId: projectId2 };
|
|
29770
29770
|
}
|
|
29771
29771
|
}
|
|
29772
|
-
const tierId = "free-tier";
|
|
29772
|
+
const tierId = loadRes.allowedTiers?.[0]?.id || "free-tier";
|
|
29773
|
+
const isFree = tierId === "free-tier";
|
|
29774
|
+
const onboardProject = isFree ? undefined : envProject;
|
|
29773
29775
|
const MAX_POLL_ATTEMPTS = 30;
|
|
29774
|
-
log(
|
|
29775
|
-
let lro = await callOnboardUser(accessToken, tierId,
|
|
29776
|
+
log(`[GeminiOAuth] Onboarding user to ${tierId}...`);
|
|
29777
|
+
let lro = await callOnboardUser(accessToken, tierId, onboardProject);
|
|
29776
29778
|
log(`[GeminiOAuth] Initial onboardUser response: done=${lro.done}`);
|
|
29777
29779
|
let attempts = 0;
|
|
29778
29780
|
while (!lro.done && attempts < MAX_POLL_ATTEMPTS) {
|
|
29779
29781
|
attempts++;
|
|
29780
29782
|
log(`[GeminiOAuth] Polling onboardUser (attempt ${attempts}/${MAX_POLL_ATTEMPTS})...`);
|
|
29781
29783
|
await new Promise((r) => setTimeout(r, 2000));
|
|
29782
|
-
lro = await callOnboardUser(accessToken, tierId,
|
|
29784
|
+
lro = await callOnboardUser(accessToken, tierId, onboardProject);
|
|
29783
29785
|
}
|
|
29784
29786
|
if (!lro.done) {
|
|
29785
29787
|
throw new Error(`Gemini onboarding timed out after ${MAX_POLL_ATTEMPTS * 2} seconds`);
|
|
@@ -32119,6 +32121,122 @@ var init_routing_rules = __esm(() => {
|
|
|
32119
32121
|
init_model_catalog_resolver();
|
|
32120
32122
|
});
|
|
32121
32123
|
|
|
32124
|
+
// src/providers/api-key-provenance.ts
|
|
32125
|
+
import { existsSync as existsSync12, readFileSync as readFileSync11 } from "fs";
|
|
32126
|
+
import { join as join12, resolve as resolve2 } from "path";
|
|
32127
|
+
import { homedir as homedir11 } from "os";
|
|
32128
|
+
function maskKey(key) {
|
|
32129
|
+
if (!key)
|
|
32130
|
+
return null;
|
|
32131
|
+
if (key.length <= 8)
|
|
32132
|
+
return "***";
|
|
32133
|
+
return `${key.substring(0, 8)}...`;
|
|
32134
|
+
}
|
|
32135
|
+
function resolveApiKeyProvenance(envVar, aliases) {
|
|
32136
|
+
const layers = [];
|
|
32137
|
+
const effectiveValue = process.env[envVar] || null;
|
|
32138
|
+
let effectiveSource = "not set";
|
|
32139
|
+
const allVars = [envVar, ...aliases || []];
|
|
32140
|
+
const dotenvValue = readDotenvKey(allVars);
|
|
32141
|
+
layers.push({
|
|
32142
|
+
source: `.env (${resolve2(".env")})`,
|
|
32143
|
+
maskedValue: maskKey(dotenvValue),
|
|
32144
|
+
isActive: false
|
|
32145
|
+
});
|
|
32146
|
+
const configValue = readConfigKey(envVar);
|
|
32147
|
+
layers.push({
|
|
32148
|
+
source: `~/.claudish/config.json`,
|
|
32149
|
+
maskedValue: maskKey(configValue),
|
|
32150
|
+
isActive: false
|
|
32151
|
+
});
|
|
32152
|
+
let runtimeVar = envVar;
|
|
32153
|
+
let runtimeValue = process.env[envVar] || null;
|
|
32154
|
+
if (!runtimeValue && aliases) {
|
|
32155
|
+
for (const alias of aliases) {
|
|
32156
|
+
if (process.env[alias]) {
|
|
32157
|
+
runtimeVar = alias;
|
|
32158
|
+
runtimeValue = process.env[alias];
|
|
32159
|
+
break;
|
|
32160
|
+
}
|
|
32161
|
+
}
|
|
32162
|
+
}
|
|
32163
|
+
layers.push({
|
|
32164
|
+
source: `process.env[${runtimeVar}]`,
|
|
32165
|
+
maskedValue: maskKey(runtimeValue),
|
|
32166
|
+
isActive: !!runtimeValue
|
|
32167
|
+
});
|
|
32168
|
+
if (runtimeValue) {
|
|
32169
|
+
if (dotenvValue && dotenvValue === runtimeValue) {
|
|
32170
|
+
effectiveSource = ".env";
|
|
32171
|
+
layers[0].isActive = true;
|
|
32172
|
+
layers[2].isActive = false;
|
|
32173
|
+
} else if (configValue && configValue === runtimeValue) {
|
|
32174
|
+
effectiveSource = "~/.claudish/config.json";
|
|
32175
|
+
layers[1].isActive = true;
|
|
32176
|
+
layers[2].isActive = false;
|
|
32177
|
+
} else {
|
|
32178
|
+
effectiveSource = "shell environment";
|
|
32179
|
+
}
|
|
32180
|
+
}
|
|
32181
|
+
return {
|
|
32182
|
+
envVar: runtimeVar,
|
|
32183
|
+
effectiveValue: runtimeValue,
|
|
32184
|
+
effectiveMasked: maskKey(runtimeValue),
|
|
32185
|
+
effectiveSource,
|
|
32186
|
+
layers
|
|
32187
|
+
};
|
|
32188
|
+
}
|
|
32189
|
+
function formatProvenanceLog(p) {
|
|
32190
|
+
if (!p.effectiveValue) {
|
|
32191
|
+
return `${p.envVar}=(not set)`;
|
|
32192
|
+
}
|
|
32193
|
+
return `${p.envVar}=${p.effectiveMasked} [from: ${p.effectiveSource}]`;
|
|
32194
|
+
}
|
|
32195
|
+
function formatProvenanceProbe(p, indent = " ") {
|
|
32196
|
+
const lines = [];
|
|
32197
|
+
if (!p.effectiveValue) {
|
|
32198
|
+
lines.push(`${indent}${p.envVar}: not set`);
|
|
32199
|
+
return lines;
|
|
32200
|
+
}
|
|
32201
|
+
lines.push(`${indent}${p.envVar} = ${p.effectiveMasked} [from: ${p.effectiveSource}]`);
|
|
32202
|
+
for (const layer of p.layers) {
|
|
32203
|
+
const marker = layer.isActive ? ">>>" : " ";
|
|
32204
|
+
const value = layer.maskedValue || "(not set)";
|
|
32205
|
+
lines.push(`${indent} ${marker} ${layer.source}: ${value}`);
|
|
32206
|
+
}
|
|
32207
|
+
return lines;
|
|
32208
|
+
}
|
|
32209
|
+
function readDotenvKey(envVars) {
|
|
32210
|
+
try {
|
|
32211
|
+
const dotenvPath = resolve2(".env");
|
|
32212
|
+
if (!existsSync12(dotenvPath))
|
|
32213
|
+
return null;
|
|
32214
|
+
const parsed = import_dotenv2.parse(readFileSync11(dotenvPath, "utf-8"));
|
|
32215
|
+
for (const v of envVars) {
|
|
32216
|
+
if (parsed[v])
|
|
32217
|
+
return parsed[v];
|
|
32218
|
+
}
|
|
32219
|
+
return null;
|
|
32220
|
+
} catch {
|
|
32221
|
+
return null;
|
|
32222
|
+
}
|
|
32223
|
+
}
|
|
32224
|
+
function readConfigKey(envVar) {
|
|
32225
|
+
try {
|
|
32226
|
+
const configPath = join12(homedir11(), ".claudish", "config.json");
|
|
32227
|
+
if (!existsSync12(configPath))
|
|
32228
|
+
return null;
|
|
32229
|
+
const cfg = JSON.parse(readFileSync11(configPath, "utf-8"));
|
|
32230
|
+
return cfg.apiKeys?.[envVar] || null;
|
|
32231
|
+
} catch {
|
|
32232
|
+
return null;
|
|
32233
|
+
}
|
|
32234
|
+
}
|
|
32235
|
+
var import_dotenv2;
|
|
32236
|
+
var init_api_key_provenance = __esm(() => {
|
|
32237
|
+
import_dotenv2 = __toESM(require_main(), 1);
|
|
32238
|
+
});
|
|
32239
|
+
|
|
32122
32240
|
// src/providers/provider-registry.ts
|
|
32123
32241
|
function resolveProvider(modelId) {
|
|
32124
32242
|
const providers = getProviders();
|
|
@@ -32320,9 +32438,9 @@ __export(exports_provider_resolver, {
|
|
|
32320
32438
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
32321
32439
|
getMissingKeyError: () => getMissingKeyError
|
|
32322
32440
|
});
|
|
32323
|
-
import { existsSync as
|
|
32324
|
-
import { join as
|
|
32325
|
-
import { homedir as
|
|
32441
|
+
import { existsSync as existsSync13 } from "fs";
|
|
32442
|
+
import { join as join13 } from "path";
|
|
32443
|
+
import { homedir as homedir12 } from "os";
|
|
32326
32444
|
function getApiKeyInfoForProvider(providerName) {
|
|
32327
32445
|
const lookupName = providerName === "gemini" ? "google" : providerName;
|
|
32328
32446
|
const info = getApiKeyInfo(lookupName);
|
|
@@ -32357,8 +32475,8 @@ function isApiKeyAvailable(info) {
|
|
|
32357
32475
|
}
|
|
32358
32476
|
if (info.oauthFallback) {
|
|
32359
32477
|
try {
|
|
32360
|
-
const credPath =
|
|
32361
|
-
if (
|
|
32478
|
+
const credPath = join13(homedir12(), ".claudish", info.oauthFallback);
|
|
32479
|
+
if (existsSync13(credPath)) {
|
|
32362
32480
|
return true;
|
|
32363
32481
|
}
|
|
32364
32482
|
} catch {}
|
|
@@ -34995,23 +35113,23 @@ __export(exports_cli, {
|
|
|
34995
35113
|
getMissingKeyError: () => getMissingKeyError
|
|
34996
35114
|
});
|
|
34997
35115
|
import {
|
|
34998
|
-
readFileSync as
|
|
35116
|
+
readFileSync as readFileSync12,
|
|
34999
35117
|
writeFileSync as writeFileSync6,
|
|
35000
|
-
existsSync as
|
|
35118
|
+
existsSync as existsSync14,
|
|
35001
35119
|
mkdirSync as mkdirSync6,
|
|
35002
35120
|
copyFileSync,
|
|
35003
35121
|
readdirSync as readdirSync3,
|
|
35004
35122
|
unlinkSync as unlinkSync4
|
|
35005
35123
|
} from "fs";
|
|
35006
35124
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
35007
|
-
import { dirname as dirname3, join as
|
|
35008
|
-
import { homedir as
|
|
35125
|
+
import { dirname as dirname3, join as join14 } from "path";
|
|
35126
|
+
import { homedir as homedir13 } from "os";
|
|
35009
35127
|
function getVersion() {
|
|
35010
35128
|
return VERSION;
|
|
35011
35129
|
}
|
|
35012
35130
|
function clearAllModelCaches() {
|
|
35013
|
-
const cacheDir =
|
|
35014
|
-
if (!
|
|
35131
|
+
const cacheDir = join14(homedir13(), ".claudish");
|
|
35132
|
+
if (!existsSync14(cacheDir))
|
|
35015
35133
|
return;
|
|
35016
35134
|
const cachePatterns = ["all-models.json", "pricing-cache.json"];
|
|
35017
35135
|
let cleared = 0;
|
|
@@ -35019,7 +35137,7 @@ function clearAllModelCaches() {
|
|
|
35019
35137
|
const files = readdirSync3(cacheDir);
|
|
35020
35138
|
for (const file2 of files) {
|
|
35021
35139
|
if (cachePatterns.includes(file2) || file2.startsWith("litellm-models-")) {
|
|
35022
|
-
unlinkSync4(
|
|
35140
|
+
unlinkSync4(join14(cacheDir, file2));
|
|
35023
35141
|
cleared++;
|
|
35024
35142
|
}
|
|
35025
35143
|
}
|
|
@@ -35313,9 +35431,9 @@ async function fetchOllamaModels() {
|
|
|
35313
35431
|
}
|
|
35314
35432
|
async function searchAndPrintModels(query, forceUpdate) {
|
|
35315
35433
|
let models = [];
|
|
35316
|
-
if (!forceUpdate &&
|
|
35434
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH)) {
|
|
35317
35435
|
try {
|
|
35318
|
-
const cacheData = JSON.parse(
|
|
35436
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
35319
35437
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
35320
35438
|
const now = new Date;
|
|
35321
35439
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -35483,9 +35601,9 @@ Found ${results.length} matching models:
|
|
|
35483
35601
|
async function printAllModels(jsonOutput, forceUpdate) {
|
|
35484
35602
|
let models = [];
|
|
35485
35603
|
const [ollamaModels, zenModels] = await Promise.all([fetchOllamaModels(), fetchZenModels()]);
|
|
35486
|
-
if (!forceUpdate &&
|
|
35604
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH)) {
|
|
35487
35605
|
try {
|
|
35488
|
-
const cacheData = JSON.parse(
|
|
35606
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
35489
35607
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
35490
35608
|
const now = new Date;
|
|
35491
35609
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -35686,12 +35804,12 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
35686
35804
|
console.log("Top models: claudish --top-models");
|
|
35687
35805
|
}
|
|
35688
35806
|
function isCacheStale() {
|
|
35689
|
-
const cachePath =
|
|
35690
|
-
if (!
|
|
35807
|
+
const cachePath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35808
|
+
if (!existsSync14(cachePath)) {
|
|
35691
35809
|
return true;
|
|
35692
35810
|
}
|
|
35693
35811
|
try {
|
|
35694
|
-
const jsonContent =
|
|
35812
|
+
const jsonContent = readFileSync12(cachePath, "utf-8");
|
|
35695
35813
|
const data = JSON.parse(jsonContent);
|
|
35696
35814
|
if (!data.lastUpdated) {
|
|
35697
35815
|
return true;
|
|
@@ -35770,10 +35888,10 @@ async function updateModelsFromOpenRouter() {
|
|
|
35770
35888
|
providers.add(provider);
|
|
35771
35889
|
}
|
|
35772
35890
|
let version2 = "1.2.0";
|
|
35773
|
-
const existingPath =
|
|
35774
|
-
if (
|
|
35891
|
+
const existingPath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35892
|
+
if (existsSync14(existingPath)) {
|
|
35775
35893
|
try {
|
|
35776
|
-
const existing = JSON.parse(
|
|
35894
|
+
const existing = JSON.parse(readFileSync12(existingPath, "utf-8"));
|
|
35777
35895
|
version2 = existing.version || version2;
|
|
35778
35896
|
} catch {}
|
|
35779
35897
|
}
|
|
@@ -35802,8 +35920,8 @@ async function checkAndUpdateModelsCache(forceUpdate = false) {
|
|
|
35802
35920
|
await updateModelsFromOpenRouter();
|
|
35803
35921
|
} else {
|
|
35804
35922
|
try {
|
|
35805
|
-
const cachePath =
|
|
35806
|
-
const data = JSON.parse(
|
|
35923
|
+
const cachePath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35924
|
+
const data = JSON.parse(readFileSync12(cachePath, "utf-8"));
|
|
35807
35925
|
console.error(`\u2713 Using cached models (last updated: ${data.lastUpdated})`);
|
|
35808
35926
|
} catch {}
|
|
35809
35927
|
}
|
|
@@ -35826,6 +35944,25 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35826
35944
|
]);
|
|
35827
35945
|
const routingRules = loadRoutingRules();
|
|
35828
35946
|
const results = [];
|
|
35947
|
+
const API_KEY_MAP = {
|
|
35948
|
+
litellm: { envVar: "LITELLM_API_KEY" },
|
|
35949
|
+
openrouter: { envVar: "OPENROUTER_API_KEY" },
|
|
35950
|
+
google: { envVar: "GEMINI_API_KEY" },
|
|
35951
|
+
openai: { envVar: "OPENAI_API_KEY" },
|
|
35952
|
+
minimax: { envVar: "MINIMAX_API_KEY" },
|
|
35953
|
+
"minimax-coding": { envVar: "MINIMAX_CODING_API_KEY" },
|
|
35954
|
+
kimi: { envVar: "MOONSHOT_API_KEY", aliases: ["KIMI_API_KEY"] },
|
|
35955
|
+
"kimi-coding": { envVar: "KIMI_CODING_API_KEY" },
|
|
35956
|
+
glm: { envVar: "ZHIPU_API_KEY", aliases: ["GLM_API_KEY"] },
|
|
35957
|
+
"glm-coding": { envVar: "GLM_CODING_API_KEY", aliases: ["ZAI_CODING_API_KEY"] },
|
|
35958
|
+
zai: { envVar: "ZAI_API_KEY" },
|
|
35959
|
+
ollamacloud: { envVar: "OLLAMA_API_KEY" },
|
|
35960
|
+
"opencode-zen": { envVar: "OPENCODE_API_KEY" },
|
|
35961
|
+
"opencode-zen-go": { envVar: "OPENCODE_API_KEY" },
|
|
35962
|
+
"gemini-codeassist": { envVar: "GEMINI_API_KEY" },
|
|
35963
|
+
vertex: { envVar: "VERTEX_API_KEY", aliases: ["VERTEX_PROJECT"] },
|
|
35964
|
+
poe: { envVar: "POE_API_KEY" }
|
|
35965
|
+
};
|
|
35829
35966
|
for (const modelInput of models) {
|
|
35830
35967
|
const parsed = parseModelSpec(modelInput);
|
|
35831
35968
|
const chain = (() => {
|
|
@@ -35863,35 +36000,18 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35863
36000
|
matchedPattern: undefined
|
|
35864
36001
|
};
|
|
35865
36002
|
})();
|
|
35866
|
-
const API_KEY_MAP = {
|
|
35867
|
-
litellm: { envVar: "LITELLM_API_KEY" },
|
|
35868
|
-
openrouter: { envVar: "OPENROUTER_API_KEY" },
|
|
35869
|
-
google: { envVar: "GEMINI_API_KEY" },
|
|
35870
|
-
openai: { envVar: "OPENAI_API_KEY" },
|
|
35871
|
-
minimax: { envVar: "MINIMAX_API_KEY" },
|
|
35872
|
-
"minimax-coding": { envVar: "MINIMAX_CODING_API_KEY" },
|
|
35873
|
-
kimi: { envVar: "MOONSHOT_API_KEY", aliases: ["KIMI_API_KEY"] },
|
|
35874
|
-
"kimi-coding": { envVar: "KIMI_CODING_API_KEY" },
|
|
35875
|
-
glm: { envVar: "ZHIPU_API_KEY", aliases: ["GLM_API_KEY"] },
|
|
35876
|
-
"glm-coding": { envVar: "GLM_CODING_API_KEY", aliases: ["ZAI_CODING_API_KEY"] },
|
|
35877
|
-
zai: { envVar: "ZAI_API_KEY" },
|
|
35878
|
-
ollamacloud: { envVar: "OLLAMA_API_KEY" },
|
|
35879
|
-
"opencode-zen": { envVar: "OPENCODE_API_KEY" },
|
|
35880
|
-
"opencode-zen-go": { envVar: "OPENCODE_API_KEY" },
|
|
35881
|
-
"gemini-codeassist": { envVar: "GEMINI_API_KEY" },
|
|
35882
|
-
vertex: { envVar: "VERTEX_API_KEY", aliases: ["VERTEX_PROJECT"] },
|
|
35883
|
-
poe: { envVar: "POE_API_KEY" }
|
|
35884
|
-
};
|
|
35885
36003
|
const chainDetails = chain.routes.map((route) => {
|
|
35886
36004
|
const keyInfo = API_KEY_MAP[route.provider];
|
|
35887
36005
|
let hasCredentials = false;
|
|
35888
36006
|
let credentialHint;
|
|
36007
|
+
let provenance;
|
|
35889
36008
|
if (!keyInfo) {
|
|
35890
36009
|
hasCredentials = true;
|
|
35891
36010
|
} else if (!keyInfo.envVar) {
|
|
35892
36011
|
hasCredentials = true;
|
|
35893
36012
|
} else {
|
|
35894
|
-
|
|
36013
|
+
provenance = resolveApiKeyProvenance(keyInfo.envVar, keyInfo.aliases);
|
|
36014
|
+
hasCredentials = !!provenance.effectiveValue;
|
|
35895
36015
|
if (!hasCredentials && keyInfo.aliases) {
|
|
35896
36016
|
hasCredentials = keyInfo.aliases.some((a) => !!process.env[a]);
|
|
35897
36017
|
}
|
|
@@ -35904,7 +36024,8 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35904
36024
|
displayName: route.displayName,
|
|
35905
36025
|
modelSpec: route.modelSpec,
|
|
35906
36026
|
hasCredentials,
|
|
35907
|
-
credentialHint
|
|
36027
|
+
credentialHint,
|
|
36028
|
+
provenance
|
|
35908
36029
|
};
|
|
35909
36030
|
});
|
|
35910
36031
|
let wiring = undefined;
|
|
@@ -35989,6 +36110,23 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35989
36110
|
console.log(` ${DIM}${line}${RESET}`);
|
|
35990
36111
|
if (result.routingSource === "direct") {
|
|
35991
36112
|
console.log(` ${GREEN} Direct \u2192 ${result.nativeProvider}${RESET} (explicit provider prefix, no fallback chain)`);
|
|
36113
|
+
const directKeyInfo = API_KEY_MAP[result.nativeProvider];
|
|
36114
|
+
if (directKeyInfo?.envVar) {
|
|
36115
|
+
const provenance = resolveApiKeyProvenance(directKeyInfo.envVar, directKeyInfo.aliases);
|
|
36116
|
+
console.log("");
|
|
36117
|
+
if (provenance.effectiveValue) {
|
|
36118
|
+
console.log(` ${DIM} API Key Resolution:${RESET}`);
|
|
36119
|
+
for (const line2 of formatProvenanceProbe(provenance, " ")) {
|
|
36120
|
+
if (line2.includes(">>>")) {
|
|
36121
|
+
console.log(` ${GREEN}${line2}${RESET}`);
|
|
36122
|
+
} else {
|
|
36123
|
+
console.log(` ${DIM}${line2}${RESET}`);
|
|
36124
|
+
}
|
|
36125
|
+
}
|
|
36126
|
+
} else {
|
|
36127
|
+
console.log(` ${RED} API key: ${directKeyInfo.envVar} not set!${RESET}`);
|
|
36128
|
+
}
|
|
36129
|
+
}
|
|
35992
36130
|
} else if (result.chain.length === 0) {
|
|
35993
36131
|
console.log(` ${RED} No providers available${RESET} \u2014 no credentials configured`);
|
|
35994
36132
|
} else {
|
|
@@ -36019,6 +36157,17 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
36019
36157
|
} else if (firstReady) {
|
|
36020
36158
|
console.log(`
|
|
36021
36159
|
${DIM} Will use: ${RESET}${GREEN}${firstReady.displayName}${RESET}${DIM} (${readyCount}/${result.chain.length} providers available)${RESET}`);
|
|
36160
|
+
if (firstReady.provenance?.effectiveValue) {
|
|
36161
|
+
console.log("");
|
|
36162
|
+
console.log(` ${DIM} API Key Resolution:${RESET}`);
|
|
36163
|
+
for (const line2 of formatProvenanceProbe(firstReady.provenance, " ")) {
|
|
36164
|
+
if (line2.includes(">>>")) {
|
|
36165
|
+
console.log(` ${GREEN}${line2}${RESET}`);
|
|
36166
|
+
} else {
|
|
36167
|
+
console.log(` ${DIM}${line2}${RESET}`);
|
|
36168
|
+
}
|
|
36169
|
+
}
|
|
36170
|
+
}
|
|
36022
36171
|
if (result.wiring) {
|
|
36023
36172
|
const w = result.wiring;
|
|
36024
36173
|
console.log("");
|
|
@@ -36362,8 +36511,8 @@ MORE INFO:
|
|
|
36362
36511
|
}
|
|
36363
36512
|
function printAIAgentGuide() {
|
|
36364
36513
|
try {
|
|
36365
|
-
const guidePath =
|
|
36366
|
-
const guideContent =
|
|
36514
|
+
const guidePath = join14(__dirname4, "../AI_AGENT_GUIDE.md");
|
|
36515
|
+
const guideContent = readFileSync12(guidePath, "utf-8");
|
|
36367
36516
|
console.log(guideContent);
|
|
36368
36517
|
} catch (error46) {
|
|
36369
36518
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -36379,19 +36528,19 @@ async function initializeClaudishSkill() {
|
|
|
36379
36528
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
36380
36529
|
`);
|
|
36381
36530
|
const cwd = process.cwd();
|
|
36382
|
-
const claudeDir =
|
|
36383
|
-
const skillsDir =
|
|
36384
|
-
const claudishSkillDir =
|
|
36385
|
-
const skillFile =
|
|
36386
|
-
if (
|
|
36531
|
+
const claudeDir = join14(cwd, ".claude");
|
|
36532
|
+
const skillsDir = join14(claudeDir, "skills");
|
|
36533
|
+
const claudishSkillDir = join14(skillsDir, "claudish-usage");
|
|
36534
|
+
const skillFile = join14(claudishSkillDir, "SKILL.md");
|
|
36535
|
+
if (existsSync14(skillFile)) {
|
|
36387
36536
|
console.log("\u2705 Claudish skill already installed at:");
|
|
36388
36537
|
console.log(` ${skillFile}
|
|
36389
36538
|
`);
|
|
36390
36539
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
36391
36540
|
return;
|
|
36392
36541
|
}
|
|
36393
|
-
const sourceSkillPath =
|
|
36394
|
-
if (!
|
|
36542
|
+
const sourceSkillPath = join14(__dirname4, "../skills/claudish-usage/SKILL.md");
|
|
36543
|
+
if (!existsSync14(sourceSkillPath)) {
|
|
36395
36544
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
36396
36545
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
36397
36546
|
console.error(`
|
|
@@ -36400,15 +36549,15 @@ async function initializeClaudishSkill() {
|
|
|
36400
36549
|
process.exit(1);
|
|
36401
36550
|
}
|
|
36402
36551
|
try {
|
|
36403
|
-
if (!
|
|
36552
|
+
if (!existsSync14(claudeDir)) {
|
|
36404
36553
|
mkdirSync6(claudeDir, { recursive: true });
|
|
36405
36554
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
36406
36555
|
}
|
|
36407
|
-
if (!
|
|
36556
|
+
if (!existsSync14(skillsDir)) {
|
|
36408
36557
|
mkdirSync6(skillsDir, { recursive: true });
|
|
36409
36558
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
36410
36559
|
}
|
|
36411
|
-
if (!
|
|
36560
|
+
if (!existsSync14(claudishSkillDir)) {
|
|
36412
36561
|
mkdirSync6(claudishSkillDir, { recursive: true });
|
|
36413
36562
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
36414
36563
|
}
|
|
@@ -36451,9 +36600,9 @@ function printAvailableModels() {
|
|
|
36451
36600
|
let lastUpdated = "unknown";
|
|
36452
36601
|
let models = [];
|
|
36453
36602
|
try {
|
|
36454
|
-
const cachePath =
|
|
36455
|
-
if (
|
|
36456
|
-
const data = JSON.parse(
|
|
36603
|
+
const cachePath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
36604
|
+
if (existsSync14(cachePath)) {
|
|
36605
|
+
const data = JSON.parse(readFileSync12(cachePath, "utf-8"));
|
|
36457
36606
|
lastUpdated = data.lastUpdated || "unknown";
|
|
36458
36607
|
models = data.models || [];
|
|
36459
36608
|
}
|
|
@@ -36502,9 +36651,9 @@ Force update: claudish --list-models --force-update
|
|
|
36502
36651
|
`);
|
|
36503
36652
|
}
|
|
36504
36653
|
function printAvailableModelsJSON() {
|
|
36505
|
-
const jsonPath =
|
|
36654
|
+
const jsonPath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
36506
36655
|
try {
|
|
36507
|
-
const jsonContent =
|
|
36656
|
+
const jsonContent = readFileSync12(jsonPath, "utf-8");
|
|
36508
36657
|
const data = JSON.parse(jsonContent);
|
|
36509
36658
|
console.log(JSON.stringify(data, null, 2));
|
|
36510
36659
|
} catch (error46) {
|
|
@@ -36589,7 +36738,7 @@ async function fetchGLMCodingModels() {
|
|
|
36589
36738
|
return [];
|
|
36590
36739
|
}
|
|
36591
36740
|
}
|
|
36592
|
-
var __filename4, __dirname4, VERSION = "5.
|
|
36741
|
+
var __filename4, __dirname4, VERSION = "5.18.1", CACHE_MAX_AGE_DAYS2 = 2, CLAUDISH_CACHE_DIR2, BUNDLED_MODELS_PATH, CACHED_MODELS_PATH, ALL_MODELS_JSON_PATH;
|
|
36593
36742
|
var init_cli = __esm(() => {
|
|
36594
36743
|
init_config();
|
|
36595
36744
|
init_model_loader();
|
|
@@ -36597,17 +36746,18 @@ var init_cli = __esm(() => {
|
|
|
36597
36746
|
init_model_parser();
|
|
36598
36747
|
init_auto_route();
|
|
36599
36748
|
init_routing_rules();
|
|
36749
|
+
init_api_key_provenance();
|
|
36600
36750
|
init_provider_resolver();
|
|
36601
36751
|
__filename4 = fileURLToPath3(import.meta.url);
|
|
36602
36752
|
__dirname4 = dirname3(__filename4);
|
|
36603
36753
|
try {
|
|
36604
|
-
const packageJson = JSON.parse(
|
|
36754
|
+
const packageJson = JSON.parse(readFileSync12(join14(__dirname4, "../package.json"), "utf-8"));
|
|
36605
36755
|
VERSION = packageJson.version;
|
|
36606
36756
|
} catch {}
|
|
36607
|
-
CLAUDISH_CACHE_DIR2 =
|
|
36608
|
-
BUNDLED_MODELS_PATH =
|
|
36609
|
-
CACHED_MODELS_PATH =
|
|
36610
|
-
ALL_MODELS_JSON_PATH =
|
|
36757
|
+
CLAUDISH_CACHE_DIR2 = join14(homedir13(), ".claudish");
|
|
36758
|
+
BUNDLED_MODELS_PATH = join14(__dirname4, "../recommended-models.json");
|
|
36759
|
+
CACHED_MODELS_PATH = join14(CLAUDISH_CACHE_DIR2, "recommended-models.json");
|
|
36760
|
+
ALL_MODELS_JSON_PATH = join14(CLAUDISH_CACHE_DIR2, "all-models.json");
|
|
36611
36761
|
});
|
|
36612
36762
|
|
|
36613
36763
|
// src/update-checker.ts
|
|
@@ -36619,9 +36769,9 @@ __export(exports_update_checker, {
|
|
|
36619
36769
|
checkForUpdates: () => checkForUpdates
|
|
36620
36770
|
});
|
|
36621
36771
|
import { execSync } from "child_process";
|
|
36622
|
-
import { existsSync as
|
|
36623
|
-
import { homedir as
|
|
36624
|
-
import { join as
|
|
36772
|
+
import { existsSync as existsSync15, mkdirSync as mkdirSync7, readFileSync as readFileSync13, unlinkSync as unlinkSync5, writeFileSync as writeFileSync7 } from "fs";
|
|
36773
|
+
import { homedir as homedir14, platform as platform2, tmpdir } from "os";
|
|
36774
|
+
import { join as join15 } from "path";
|
|
36625
36775
|
import { createInterface } from "readline";
|
|
36626
36776
|
function getUpdateCommand() {
|
|
36627
36777
|
const scriptPath = process.argv[1] || "";
|
|
@@ -36633,27 +36783,27 @@ function getUpdateCommand() {
|
|
|
36633
36783
|
function getCacheFilePath() {
|
|
36634
36784
|
let cacheDir;
|
|
36635
36785
|
if (isWindows) {
|
|
36636
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
36637
|
-
cacheDir =
|
|
36786
|
+
const localAppData = process.env.LOCALAPPDATA || join15(homedir14(), "AppData", "Local");
|
|
36787
|
+
cacheDir = join15(localAppData, "claudish");
|
|
36638
36788
|
} else {
|
|
36639
|
-
cacheDir =
|
|
36789
|
+
cacheDir = join15(homedir14(), ".cache", "claudish");
|
|
36640
36790
|
}
|
|
36641
36791
|
try {
|
|
36642
|
-
if (!
|
|
36792
|
+
if (!existsSync15(cacheDir)) {
|
|
36643
36793
|
mkdirSync7(cacheDir, { recursive: true });
|
|
36644
36794
|
}
|
|
36645
|
-
return
|
|
36795
|
+
return join15(cacheDir, "update-check.json");
|
|
36646
36796
|
} catch {
|
|
36647
|
-
return
|
|
36797
|
+
return join15(tmpdir(), "claudish-update-check.json");
|
|
36648
36798
|
}
|
|
36649
36799
|
}
|
|
36650
36800
|
function readCache() {
|
|
36651
36801
|
try {
|
|
36652
36802
|
const cachePath = getCacheFilePath();
|
|
36653
|
-
if (!
|
|
36803
|
+
if (!existsSync15(cachePath)) {
|
|
36654
36804
|
return null;
|
|
36655
36805
|
}
|
|
36656
|
-
const data = JSON.parse(
|
|
36806
|
+
const data = JSON.parse(readFileSync13(cachePath, "utf-8"));
|
|
36657
36807
|
return data;
|
|
36658
36808
|
} catch {
|
|
36659
36809
|
return null;
|
|
@@ -36676,7 +36826,7 @@ function isCacheValid(cache) {
|
|
|
36676
36826
|
function clearCache() {
|
|
36677
36827
|
try {
|
|
36678
36828
|
const cachePath = getCacheFilePath();
|
|
36679
|
-
if (
|
|
36829
|
+
if (existsSync15(cachePath)) {
|
|
36680
36830
|
unlinkSync5(cachePath);
|
|
36681
36831
|
}
|
|
36682
36832
|
} catch {}
|
|
@@ -36713,7 +36863,7 @@ async function fetchLatestVersion() {
|
|
|
36713
36863
|
}
|
|
36714
36864
|
}
|
|
36715
36865
|
function promptUser(question) {
|
|
36716
|
-
return new Promise((
|
|
36866
|
+
return new Promise((resolve3) => {
|
|
36717
36867
|
const rl = createInterface({
|
|
36718
36868
|
input: process.stdin,
|
|
36719
36869
|
output: process.stderr
|
|
@@ -36721,7 +36871,7 @@ function promptUser(question) {
|
|
|
36721
36871
|
rl.question(question, (answer) => {
|
|
36722
36872
|
rl.close();
|
|
36723
36873
|
const normalized = answer.toLowerCase().trim();
|
|
36724
|
-
|
|
36874
|
+
resolve3(normalized === "y" || normalized === "yes");
|
|
36725
36875
|
});
|
|
36726
36876
|
});
|
|
36727
36877
|
}
|
|
@@ -36832,7 +36982,7 @@ function getUpdateCommand2(method) {
|
|
|
36832
36982
|
}
|
|
36833
36983
|
}
|
|
36834
36984
|
function promptUser2(question) {
|
|
36835
|
-
return new Promise((
|
|
36985
|
+
return new Promise((resolve3) => {
|
|
36836
36986
|
const rl = createInterface2({
|
|
36837
36987
|
input: process.stdin,
|
|
36838
36988
|
output: process.stdout
|
|
@@ -36840,7 +36990,7 @@ function promptUser2(question) {
|
|
|
36840
36990
|
rl.question(question, (answer) => {
|
|
36841
36991
|
rl.close();
|
|
36842
36992
|
const normalized = answer.toLowerCase().trim();
|
|
36843
|
-
|
|
36993
|
+
resolve3(normalized === "y" || normalized === "yes" || normalized === "");
|
|
36844
36994
|
});
|
|
36845
36995
|
});
|
|
36846
36996
|
}
|
|
@@ -38526,13 +38676,13 @@ var PromisePolyfill;
|
|
|
38526
38676
|
var init_promise_polyfill = __esm(() => {
|
|
38527
38677
|
PromisePolyfill = class PromisePolyfill extends Promise {
|
|
38528
38678
|
static withResolver() {
|
|
38529
|
-
let
|
|
38679
|
+
let resolve3;
|
|
38530
38680
|
let reject;
|
|
38531
38681
|
const promise3 = new Promise((res, rej) => {
|
|
38532
|
-
|
|
38682
|
+
resolve3 = res;
|
|
38533
38683
|
reject = rej;
|
|
38534
38684
|
});
|
|
38535
|
-
return { promise: promise3, resolve:
|
|
38685
|
+
return { promise: promise3, resolve: resolve3, reject };
|
|
38536
38686
|
}
|
|
38537
38687
|
};
|
|
38538
38688
|
});
|
|
@@ -38569,7 +38719,7 @@ function createPrompt(view) {
|
|
|
38569
38719
|
output
|
|
38570
38720
|
});
|
|
38571
38721
|
const screen = new ScreenManager(rl);
|
|
38572
|
-
const { promise: promise3, resolve:
|
|
38722
|
+
const { promise: promise3, resolve: resolve3, reject } = PromisePolyfill.withResolver();
|
|
38573
38723
|
const cancel = () => reject(new CancelPromptError);
|
|
38574
38724
|
if (signal) {
|
|
38575
38725
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -38596,7 +38746,7 @@ function createPrompt(view) {
|
|
|
38596
38746
|
cycle(() => {
|
|
38597
38747
|
try {
|
|
38598
38748
|
const nextView = view(config3, (value) => {
|
|
38599
|
-
setImmediate(() =>
|
|
38749
|
+
setImmediate(() => resolve3(value));
|
|
38600
38750
|
});
|
|
38601
38751
|
if (nextView === undefined) {
|
|
38602
38752
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -39157,14 +39307,14 @@ __export(exports_model_selector, {
|
|
|
39157
39307
|
promptForApiKey: () => promptForApiKey,
|
|
39158
39308
|
confirmAction: () => confirmAction
|
|
39159
39309
|
});
|
|
39160
|
-
import { readFileSync as
|
|
39161
|
-
import { join as
|
|
39162
|
-
import { homedir as
|
|
39310
|
+
import { readFileSync as readFileSync14, writeFileSync as writeFileSync8, existsSync as existsSync16, mkdirSync as mkdirSync8 } from "fs";
|
|
39311
|
+
import { join as join16, dirname as dirname4 } from "path";
|
|
39312
|
+
import { homedir as homedir15 } from "os";
|
|
39163
39313
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
39164
39314
|
function loadRecommendedModels2() {
|
|
39165
|
-
if (
|
|
39315
|
+
if (existsSync16(RECOMMENDED_MODELS_JSON_PATH)) {
|
|
39166
39316
|
try {
|
|
39167
|
-
const content =
|
|
39317
|
+
const content = readFileSync14(RECOMMENDED_MODELS_JSON_PATH, "utf-8");
|
|
39168
39318
|
const data = JSON.parse(content);
|
|
39169
39319
|
return (data.models || []).map((model) => ({
|
|
39170
39320
|
...model,
|
|
@@ -39177,9 +39327,9 @@ function loadRecommendedModels2() {
|
|
|
39177
39327
|
return [];
|
|
39178
39328
|
}
|
|
39179
39329
|
async function fetchAllModels(forceUpdate = false) {
|
|
39180
|
-
if (!forceUpdate &&
|
|
39330
|
+
if (!forceUpdate && existsSync16(ALL_MODELS_JSON_PATH2)) {
|
|
39181
39331
|
try {
|
|
39182
|
-
const cacheData = JSON.parse(
|
|
39332
|
+
const cacheData = JSON.parse(readFileSync14(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
39183
39333
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
39184
39334
|
const now = new Date;
|
|
39185
39335
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -39681,11 +39831,11 @@ async function fetchOllamaCloudModels() {
|
|
|
39681
39831
|
}
|
|
39682
39832
|
}
|
|
39683
39833
|
function shouldRefreshForFreeModels() {
|
|
39684
|
-
if (!
|
|
39834
|
+
if (!existsSync16(ALL_MODELS_JSON_PATH2)) {
|
|
39685
39835
|
return true;
|
|
39686
39836
|
}
|
|
39687
39837
|
try {
|
|
39688
|
-
const cacheData = JSON.parse(
|
|
39838
|
+
const cacheData = JSON.parse(readFileSync14(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
39689
39839
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
39690
39840
|
const now = new Date;
|
|
39691
39841
|
const ageInHours = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
|
@@ -40286,9 +40436,9 @@ var init_model_selector = __esm(() => {
|
|
|
40286
40436
|
init_model_loader();
|
|
40287
40437
|
__filename5 = fileURLToPath4(import.meta.url);
|
|
40288
40438
|
__dirname5 = dirname4(__filename5);
|
|
40289
|
-
CLAUDISH_CACHE_DIR3 =
|
|
40290
|
-
ALL_MODELS_JSON_PATH2 =
|
|
40291
|
-
RECOMMENDED_MODELS_JSON_PATH =
|
|
40439
|
+
CLAUDISH_CACHE_DIR3 = join16(homedir15(), ".claudish");
|
|
40440
|
+
ALL_MODELS_JSON_PATH2 = join16(CLAUDISH_CACHE_DIR3, "all-models.json");
|
|
40441
|
+
RECOMMENDED_MODELS_JSON_PATH = join16(__dirname5, "../recommended-models.json");
|
|
40292
40442
|
PROVIDER_FILTER_ALIASES = {
|
|
40293
40443
|
zen: "Zen",
|
|
40294
40444
|
openrouter: "OpenRouter",
|
|
@@ -41146,11 +41296,11 @@ async function runConsentPrompt(ctx) {
|
|
|
41146
41296
|
Does NOT send: prompts, paths, API keys, or credentials.
|
|
41147
41297
|
Disable anytime: claudish telemetry off
|
|
41148
41298
|
`);
|
|
41149
|
-
const answer = await new Promise((
|
|
41299
|
+
const answer = await new Promise((resolve3) => {
|
|
41150
41300
|
const rl = createInterface4({ input: process.stdin, output: process.stderr });
|
|
41151
41301
|
rl.question("Send anonymous error report? [y/N] ", (ans) => {
|
|
41152
41302
|
rl.close();
|
|
41153
|
-
|
|
41303
|
+
resolve3(ans.trim().toLowerCase());
|
|
41154
41304
|
});
|
|
41155
41305
|
});
|
|
41156
41306
|
const accepted = answer === "y" || answer === "yes";
|
|
@@ -41334,25 +41484,25 @@ var init_telemetry = __esm(() => {
|
|
|
41334
41484
|
|
|
41335
41485
|
// src/stats-buffer.ts
|
|
41336
41486
|
import {
|
|
41337
|
-
existsSync as
|
|
41487
|
+
existsSync as existsSync17,
|
|
41338
41488
|
mkdirSync as mkdirSync9,
|
|
41339
|
-
readFileSync as
|
|
41489
|
+
readFileSync as readFileSync15,
|
|
41340
41490
|
renameSync,
|
|
41341
41491
|
unlinkSync as unlinkSync6,
|
|
41342
41492
|
writeFileSync as writeFileSync9
|
|
41343
41493
|
} from "fs";
|
|
41344
|
-
import { homedir as
|
|
41345
|
-
import { join as
|
|
41494
|
+
import { homedir as homedir16 } from "os";
|
|
41495
|
+
import { join as join17 } from "path";
|
|
41346
41496
|
function ensureDir() {
|
|
41347
|
-
if (!
|
|
41497
|
+
if (!existsSync17(CLAUDISH_DIR)) {
|
|
41348
41498
|
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
41349
41499
|
}
|
|
41350
41500
|
}
|
|
41351
41501
|
function readFromDisk() {
|
|
41352
41502
|
try {
|
|
41353
|
-
if (!
|
|
41503
|
+
if (!existsSync17(BUFFER_FILE))
|
|
41354
41504
|
return [];
|
|
41355
|
-
const raw =
|
|
41505
|
+
const raw = readFileSync15(BUFFER_FILE, "utf-8");
|
|
41356
41506
|
const parsed = JSON.parse(raw);
|
|
41357
41507
|
if (!Array.isArray(parsed.events))
|
|
41358
41508
|
return [];
|
|
@@ -41376,7 +41526,7 @@ function writeToDisk(events) {
|
|
|
41376
41526
|
ensureDir();
|
|
41377
41527
|
const trimmed = enforceSizeCap([...events]);
|
|
41378
41528
|
const payload = { version: 1, events: trimmed };
|
|
41379
|
-
const tmpFile =
|
|
41529
|
+
const tmpFile = join17(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
41380
41530
|
writeFileSync9(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
41381
41531
|
renameSync(tmpFile, BUFFER_FILE);
|
|
41382
41532
|
memoryCache = trimmed;
|
|
@@ -41421,7 +41571,7 @@ function clearBuffer() {
|
|
|
41421
41571
|
try {
|
|
41422
41572
|
memoryCache = [];
|
|
41423
41573
|
eventsSinceLastFlush = 0;
|
|
41424
|
-
if (
|
|
41574
|
+
if (existsSync17(BUFFER_FILE)) {
|
|
41425
41575
|
unlinkSync6(BUFFER_FILE);
|
|
41426
41576
|
}
|
|
41427
41577
|
} catch {}
|
|
@@ -41450,8 +41600,8 @@ function syncFlushOnExit() {
|
|
|
41450
41600
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, lastFlushTime, flushScheduled = false;
|
|
41451
41601
|
var init_stats_buffer = __esm(() => {
|
|
41452
41602
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
41453
|
-
CLAUDISH_DIR =
|
|
41454
|
-
BUFFER_FILE =
|
|
41603
|
+
CLAUDISH_DIR = join17(homedir16(), ".claudish");
|
|
41604
|
+
BUFFER_FILE = join17(CLAUDISH_DIR, "stats-buffer.json");
|
|
41455
41605
|
lastFlushTime = Date.now();
|
|
41456
41606
|
process.on("exit", syncFlushOnExit);
|
|
41457
41607
|
process.on("SIGTERM", () => {
|
|
@@ -41936,11 +42086,11 @@ import { EventEmitter } from "events";
|
|
|
41936
42086
|
import { Buffer as Buffer2 } from "buffer";
|
|
41937
42087
|
import { Buffer as Buffer3 } from "buffer";
|
|
41938
42088
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
41939
|
-
import { resolve as
|
|
42089
|
+
import { resolve as resolve3, dirname as dirname5 } from "path";
|
|
41940
42090
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
41941
42091
|
import { resolve as resolve22, isAbsolute, parse as parse6 } from "path";
|
|
41942
|
-
import { existsSync as
|
|
41943
|
-
import { basename, join as
|
|
42092
|
+
import { existsSync as existsSync18 } from "fs";
|
|
42093
|
+
import { basename, join as join18 } from "path";
|
|
41944
42094
|
import os from "os";
|
|
41945
42095
|
import path from "path";
|
|
41946
42096
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
@@ -44186,13 +44336,13 @@ class DebounceController {
|
|
|
44186
44336
|
}
|
|
44187
44337
|
debounce(id, ms, fn) {
|
|
44188
44338
|
const scopeMap = TIMERS_MAP.get(this.scopeId);
|
|
44189
|
-
return new Promise((
|
|
44339
|
+
return new Promise((resolve4, reject) => {
|
|
44190
44340
|
if (scopeMap.has(id)) {
|
|
44191
44341
|
clearTimeout(scopeMap.get(id));
|
|
44192
44342
|
}
|
|
44193
44343
|
const timerId = setTimeout(() => {
|
|
44194
44344
|
try {
|
|
44195
|
-
|
|
44345
|
+
resolve4(fn());
|
|
44196
44346
|
} catch (error46) {
|
|
44197
44347
|
reject(error46);
|
|
44198
44348
|
}
|
|
@@ -44281,24 +44431,24 @@ function getParsers() {
|
|
|
44281
44431
|
{
|
|
44282
44432
|
filetype: "javascript",
|
|
44283
44433
|
queries: {
|
|
44284
|
-
highlights: [
|
|
44434
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default)]
|
|
44285
44435
|
},
|
|
44286
|
-
wasm:
|
|
44436
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_javascript_default)
|
|
44287
44437
|
},
|
|
44288
44438
|
{
|
|
44289
44439
|
filetype: "typescript",
|
|
44290
44440
|
queries: {
|
|
44291
|
-
highlights: [
|
|
44441
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default2)]
|
|
44292
44442
|
},
|
|
44293
|
-
wasm:
|
|
44443
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_typescript_default)
|
|
44294
44444
|
},
|
|
44295
44445
|
{
|
|
44296
44446
|
filetype: "markdown",
|
|
44297
44447
|
queries: {
|
|
44298
|
-
highlights: [
|
|
44299
|
-
injections: [
|
|
44448
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default3)],
|
|
44449
|
+
injections: [resolve3(dirname5(fileURLToPath5(import.meta.url)), injections_default)]
|
|
44300
44450
|
},
|
|
44301
|
-
wasm:
|
|
44451
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_default),
|
|
44302
44452
|
injectionMapping: {
|
|
44303
44453
|
nodeTypes: {
|
|
44304
44454
|
inline: "markdown_inline",
|
|
@@ -44317,16 +44467,16 @@ function getParsers() {
|
|
|
44317
44467
|
{
|
|
44318
44468
|
filetype: "markdown_inline",
|
|
44319
44469
|
queries: {
|
|
44320
|
-
highlights: [
|
|
44470
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default4)]
|
|
44321
44471
|
},
|
|
44322
|
-
wasm:
|
|
44472
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_inline_default)
|
|
44323
44473
|
},
|
|
44324
44474
|
{
|
|
44325
44475
|
filetype: "zig",
|
|
44326
44476
|
queries: {
|
|
44327
|
-
highlights: [
|
|
44477
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default5)]
|
|
44328
44478
|
},
|
|
44329
|
-
wasm:
|
|
44479
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_zig_default)
|
|
44330
44480
|
}
|
|
44331
44481
|
];
|
|
44332
44482
|
}
|
|
@@ -44339,7 +44489,7 @@ function getBunfsRootPath() {
|
|
|
44339
44489
|
return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
|
|
44340
44490
|
}
|
|
44341
44491
|
function normalizeBunfsPath(fileName) {
|
|
44342
|
-
return
|
|
44492
|
+
return join18(getBunfsRootPath(), basename(fileName));
|
|
44343
44493
|
}
|
|
44344
44494
|
function isValidDirectoryName(name) {
|
|
44345
44495
|
if (!name || typeof name !== "string") {
|
|
@@ -54535,7 +54685,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54535
54685
|
worker_path = this.options.workerPath;
|
|
54536
54686
|
} else {
|
|
54537
54687
|
worker_path = new URL("./parser.worker.js", import.meta.url).href;
|
|
54538
|
-
if (!
|
|
54688
|
+
if (!existsSync18(resolve22(import.meta.dirname, "parser.worker.js"))) {
|
|
54539
54689
|
worker_path = new URL("./parser.worker.ts", import.meta.url).href;
|
|
54540
54690
|
}
|
|
54541
54691
|
}
|
|
@@ -54570,7 +54720,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54570
54720
|
if (this.initializePromise) {
|
|
54571
54721
|
return this.initializePromise;
|
|
54572
54722
|
}
|
|
54573
|
-
this.initializePromise = new Promise((
|
|
54723
|
+
this.initializePromise = new Promise((resolve32, reject) => {
|
|
54574
54724
|
const timeoutMs = this.options.initTimeout ?? 1e4;
|
|
54575
54725
|
const timeoutId = setTimeout(() => {
|
|
54576
54726
|
const error46 = new Error("Worker initialization timed out");
|
|
@@ -54578,7 +54728,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54578
54728
|
this.initializeResolvers = undefined;
|
|
54579
54729
|
reject(error46);
|
|
54580
54730
|
}, timeoutMs);
|
|
54581
|
-
this.initializeResolvers = { resolve:
|
|
54731
|
+
this.initializeResolvers = { resolve: resolve32, reject, timeoutId };
|
|
54582
54732
|
this.worker?.postMessage({
|
|
54583
54733
|
type: "INIT",
|
|
54584
54734
|
dataPath: this.options.dataPath
|
|
@@ -54618,8 +54768,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54618
54768
|
}
|
|
54619
54769
|
async getPerformance() {
|
|
54620
54770
|
const messageId = `performance_${this.messageIdCounter++}`;
|
|
54621
|
-
return new Promise((
|
|
54622
|
-
this.messageCallbacks.set(messageId,
|
|
54771
|
+
return new Promise((resolve32) => {
|
|
54772
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54623
54773
|
this.worker?.postMessage({ type: "GET_PERFORMANCE", messageId });
|
|
54624
54774
|
});
|
|
54625
54775
|
}
|
|
@@ -54632,8 +54782,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54632
54782
|
}
|
|
54633
54783
|
}
|
|
54634
54784
|
const messageId = `oneshot_${this.messageIdCounter++}`;
|
|
54635
|
-
return new Promise((
|
|
54636
|
-
this.messageCallbacks.set(messageId,
|
|
54785
|
+
return new Promise((resolve32) => {
|
|
54786
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54637
54787
|
this.worker?.postMessage({
|
|
54638
54788
|
type: "ONESHOT_HIGHLIGHT",
|
|
54639
54789
|
content,
|
|
@@ -54749,8 +54899,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54749
54899
|
}
|
|
54750
54900
|
async preloadParser(filetype) {
|
|
54751
54901
|
const messageId = `has_parser_${this.messageIdCounter++}`;
|
|
54752
|
-
const response = await new Promise((
|
|
54753
|
-
this.messageCallbacks.set(messageId,
|
|
54902
|
+
const response = await new Promise((resolve32) => {
|
|
54903
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54754
54904
|
this.worker?.postMessage({
|
|
54755
54905
|
type: "PRELOAD_PARSER",
|
|
54756
54906
|
filetype,
|
|
@@ -54777,8 +54927,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54777
54927
|
}
|
|
54778
54928
|
this.buffers.set(id, { id, content, filetype, version: version2, hasParser: false });
|
|
54779
54929
|
const messageId = `init_${this.messageIdCounter++}`;
|
|
54780
|
-
const response = await new Promise((
|
|
54781
|
-
this.messageCallbacks.set(messageId,
|
|
54930
|
+
const response = await new Promise((resolve32) => {
|
|
54931
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54782
54932
|
this.worker?.postMessage({
|
|
54783
54933
|
type: "INITIALIZE_PARSER",
|
|
54784
54934
|
bufferId: id,
|
|
@@ -54834,9 +54984,9 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54834
54984
|
this.editQueues.delete(bufferId);
|
|
54835
54985
|
}
|
|
54836
54986
|
if (this.worker) {
|
|
54837
|
-
await new Promise((
|
|
54987
|
+
await new Promise((resolve32) => {
|
|
54838
54988
|
const messageId = `dispose_${bufferId}`;
|
|
54839
|
-
this.messageCallbacks.set(messageId,
|
|
54989
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54840
54990
|
try {
|
|
54841
54991
|
this.worker.postMessage({
|
|
54842
54992
|
type: "DISPOSE_BUFFER",
|
|
@@ -54844,13 +54994,13 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54844
54994
|
});
|
|
54845
54995
|
} catch (error46) {
|
|
54846
54996
|
console.error("Error disposing buffer", error46);
|
|
54847
|
-
|
|
54997
|
+
resolve32(false);
|
|
54848
54998
|
}
|
|
54849
54999
|
setTimeout(() => {
|
|
54850
55000
|
if (this.messageCallbacks.has(messageId)) {
|
|
54851
55001
|
this.messageCallbacks.delete(messageId);
|
|
54852
55002
|
console.warn({ bufferId }, "Timed out waiting for buffer to be disposed");
|
|
54853
|
-
|
|
55003
|
+
resolve32(false);
|
|
54854
55004
|
}
|
|
54855
55005
|
}, 3000);
|
|
54856
55006
|
});
|
|
@@ -54907,12 +55057,12 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54907
55057
|
this.options.dataPath = dataPath;
|
|
54908
55058
|
if (this.initialized && this.worker) {
|
|
54909
55059
|
const messageId = `update_datapath_${this.messageIdCounter++}`;
|
|
54910
|
-
return new Promise((
|
|
55060
|
+
return new Promise((resolve32, reject) => {
|
|
54911
55061
|
this.messageCallbacks.set(messageId, (response) => {
|
|
54912
55062
|
if (response.error) {
|
|
54913
55063
|
reject(new Error(response.error));
|
|
54914
55064
|
} else {
|
|
54915
|
-
|
|
55065
|
+
resolve32();
|
|
54916
55066
|
}
|
|
54917
55067
|
});
|
|
54918
55068
|
this.worker.postMessage({
|
|
@@ -54928,12 +55078,12 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54928
55078
|
throw new Error("Cannot clear cache: client is not initialized");
|
|
54929
55079
|
}
|
|
54930
55080
|
const messageId = `clear_cache_${this.messageIdCounter++}`;
|
|
54931
|
-
return new Promise((
|
|
55081
|
+
return new Promise((resolve32, reject) => {
|
|
54932
55082
|
this.messageCallbacks.set(messageId, (response) => {
|
|
54933
55083
|
if (response.error) {
|
|
54934
55084
|
reject(new Error(response.error));
|
|
54935
55085
|
} else {
|
|
54936
|
-
|
|
55086
|
+
resolve32();
|
|
54937
55087
|
}
|
|
54938
55088
|
});
|
|
54939
55089
|
this.worker.postMessage({
|
|
@@ -69962,14 +70112,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
69962
70112
|
prevActScopeDepth !== actScopeDepth - 1 && console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
|
|
69963
70113
|
actScopeDepth = prevActScopeDepth;
|
|
69964
70114
|
}
|
|
69965
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
70115
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve4, reject) {
|
|
69966
70116
|
var queue = ReactSharedInternals.actQueue;
|
|
69967
70117
|
if (queue !== null)
|
|
69968
70118
|
if (queue.length !== 0)
|
|
69969
70119
|
try {
|
|
69970
70120
|
flushActQueue(queue);
|
|
69971
70121
|
enqueueTask(function() {
|
|
69972
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
70122
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
|
|
69973
70123
|
});
|
|
69974
70124
|
return;
|
|
69975
70125
|
} catch (error46) {
|
|
@@ -69977,7 +70127,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
69977
70127
|
}
|
|
69978
70128
|
else
|
|
69979
70129
|
ReactSharedInternals.actQueue = null;
|
|
69980
|
-
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) :
|
|
70130
|
+
0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve4(returnValue);
|
|
69981
70131
|
}
|
|
69982
70132
|
function flushActQueue(queue) {
|
|
69983
70133
|
if (!isFlushing) {
|
|
@@ -70153,14 +70303,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70153
70303
|
didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"));
|
|
70154
70304
|
});
|
|
70155
70305
|
return {
|
|
70156
|
-
then: function(
|
|
70306
|
+
then: function(resolve4, reject) {
|
|
70157
70307
|
didAwaitActCall = true;
|
|
70158
70308
|
thenable.then(function(returnValue) {
|
|
70159
70309
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
70160
70310
|
if (prevActScopeDepth === 0) {
|
|
70161
70311
|
try {
|
|
70162
70312
|
flushActQueue(queue), enqueueTask(function() {
|
|
70163
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
70313
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
|
|
70164
70314
|
});
|
|
70165
70315
|
} catch (error$0) {
|
|
70166
70316
|
ReactSharedInternals.thrownErrors.push(error$0);
|
|
@@ -70171,7 +70321,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70171
70321
|
reject(_thrownError);
|
|
70172
70322
|
}
|
|
70173
70323
|
} else
|
|
70174
|
-
|
|
70324
|
+
resolve4(returnValue);
|
|
70175
70325
|
}, function(error46) {
|
|
70176
70326
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
70177
70327
|
0 < ReactSharedInternals.thrownErrors.length ? (error46 = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error46)) : reject(error46);
|
|
@@ -70187,11 +70337,11 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70187
70337
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
70188
70338
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
70189
70339
|
return {
|
|
70190
|
-
then: function(
|
|
70340
|
+
then: function(resolve4, reject) {
|
|
70191
70341
|
didAwaitActCall = true;
|
|
70192
70342
|
prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
70193
|
-
return recursivelyFlushAsyncActWork(returnValue$jscomp$0,
|
|
70194
|
-
})) :
|
|
70343
|
+
return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve4, reject);
|
|
70344
|
+
})) : resolve4(returnValue$jscomp$0);
|
|
70195
70345
|
}
|
|
70196
70346
|
};
|
|
70197
70347
|
};
|
|
@@ -72672,8 +72822,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
72672
72822
|
currentEntangledActionThenable = {
|
|
72673
72823
|
status: "pending",
|
|
72674
72824
|
value: undefined,
|
|
72675
|
-
then: function(
|
|
72676
|
-
entangledListeners.push(
|
|
72825
|
+
then: function(resolve4) {
|
|
72826
|
+
entangledListeners.push(resolve4);
|
|
72677
72827
|
}
|
|
72678
72828
|
};
|
|
72679
72829
|
}
|
|
@@ -72697,8 +72847,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
72697
72847
|
status: "pending",
|
|
72698
72848
|
value: null,
|
|
72699
72849
|
reason: null,
|
|
72700
|
-
then: function(
|
|
72701
|
-
listeners.push(
|
|
72850
|
+
then: function(resolve4) {
|
|
72851
|
+
listeners.push(resolve4);
|
|
72702
72852
|
}
|
|
72703
72853
|
};
|
|
72704
72854
|
thenable.then(function() {
|
|
@@ -97798,7 +97948,7 @@ var init_react = __esm(async () => {
|
|
|
97798
97948
|
});
|
|
97799
97949
|
|
|
97800
97950
|
// src/tui/providers.ts
|
|
97801
|
-
function
|
|
97951
|
+
function maskKey2(key) {
|
|
97802
97952
|
if (!key)
|
|
97803
97953
|
return "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
97804
97954
|
if (key.length < 8)
|
|
@@ -98031,7 +98181,7 @@ function ApiKeysPanel({ focused, height: height2, width, onEditingChange }) {
|
|
|
98031
98181
|
const hasEnvK = !!process.env[p.apiKeyEnvVar];
|
|
98032
98182
|
const hasCfgK = !!config3.apiKeys?.[p.apiKeyEnvVar];
|
|
98033
98183
|
const icon = hasEnvK || hasCfgK ? "\u2713" : "\u2717";
|
|
98034
|
-
const kStr = p.apiKeyEnvVar ? pad(
|
|
98184
|
+
const kStr = p.apiKeyEnvVar ? pad(maskKey2(hasCfgK ? config3.apiKeys[p.apiKeyEnvVar] : process.env[p.apiKeyEnvVar]), 8) : " ";
|
|
98035
98185
|
const kSrc = hasEnvK && hasCfgK ? "e+c" : hasEnvK ? "env" : hasCfgK ? "cfg" : "---";
|
|
98036
98186
|
let eSrc = " ";
|
|
98037
98187
|
if (p.endpointEnvVar) {
|
|
@@ -98044,8 +98194,8 @@ function ApiKeysPanel({ focused, height: height2, width, onEditingChange }) {
|
|
|
98044
98194
|
value: p.name
|
|
98045
98195
|
};
|
|
98046
98196
|
});
|
|
98047
|
-
const envKeyMask =
|
|
98048
|
-
const cfgKeyMask =
|
|
98197
|
+
const envKeyMask = maskKey2(process.env[selectedProvider.apiKeyEnvVar]);
|
|
98198
|
+
const cfgKeyMask = maskKey2(config3.apiKeys?.[selectedProvider.apiKeyEnvVar]);
|
|
98049
98199
|
const activeUrl = config3.endpoints?.[selectedProvider.endpointEnvVar] || process.env[selectedProvider.endpointEnvVar] || selectedProvider.defaultEndpoint || "None";
|
|
98050
98200
|
const divider = "\u2500".repeat(Math.max(1, width - 2));
|
|
98051
98201
|
return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
|
|
@@ -98330,7 +98480,7 @@ function ConfigViewPanel({ focused, height: height2 }) {
|
|
|
98330
98480
|
fg: C2.green,
|
|
98331
98481
|
children: [
|
|
98332
98482
|
" ",
|
|
98333
|
-
|
|
98483
|
+
maskKey2(itm?.kVal)
|
|
98334
98484
|
]
|
|
98335
98485
|
}, undefined, true, undefined, this),
|
|
98336
98486
|
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
|
|
@@ -99252,8 +99402,8 @@ var exports_team_cli = {};
|
|
|
99252
99402
|
__export(exports_team_cli, {
|
|
99253
99403
|
teamCommand: () => teamCommand
|
|
99254
99404
|
});
|
|
99255
|
-
import { readFileSync as
|
|
99256
|
-
import { join as
|
|
99405
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
99406
|
+
import { join as join19 } from "path";
|
|
99257
99407
|
function getFlag(args, flag) {
|
|
99258
99408
|
const idx = args.indexOf(flag);
|
|
99259
99409
|
if (idx === -1 || idx + 1 >= args.length)
|
|
@@ -99345,7 +99495,7 @@ async function teamCommand(args) {
|
|
|
99345
99495
|
}
|
|
99346
99496
|
case "judge": {
|
|
99347
99497
|
const verdict = await judgeResponses(sessionPath, { judges });
|
|
99348
|
-
console.log(
|
|
99498
|
+
console.log(readFileSync16(join19(sessionPath, "verdict.md"), "utf-8"));
|
|
99349
99499
|
break;
|
|
99350
99500
|
}
|
|
99351
99501
|
case "run-and-judge": {
|
|
@@ -99363,7 +99513,7 @@ async function teamCommand(args) {
|
|
|
99363
99513
|
});
|
|
99364
99514
|
printStatus(status);
|
|
99365
99515
|
await judgeResponses(sessionPath, { judges });
|
|
99366
|
-
console.log(
|
|
99516
|
+
console.log(readFileSync16(join19(sessionPath, "verdict.md"), "utf-8"));
|
|
99367
99517
|
break;
|
|
99368
99518
|
}
|
|
99369
99519
|
case "status": {
|
|
@@ -99389,9 +99539,9 @@ __export(exports_claude_runner, {
|
|
|
99389
99539
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
99390
99540
|
});
|
|
99391
99541
|
import { spawn as spawn2 } from "child_process";
|
|
99392
|
-
import { writeFileSync as writeFileSync11, unlinkSync as unlinkSync7, mkdirSync as mkdirSync10, existsSync as
|
|
99393
|
-
import { tmpdir as tmpdir2, homedir as
|
|
99394
|
-
import { join as
|
|
99542
|
+
import { writeFileSync as writeFileSync11, unlinkSync as unlinkSync7, mkdirSync as mkdirSync10, existsSync as existsSync19, readFileSync as readFileSync17 } from "fs";
|
|
99543
|
+
import { tmpdir as tmpdir2, homedir as homedir17 } from "os";
|
|
99544
|
+
import { join as join20 } from "path";
|
|
99395
99545
|
function hasNativeAnthropicMapping(config3) {
|
|
99396
99546
|
const models = [config3.model, config3.modelOpus, config3.modelSonnet, config3.modelHaiku, config3.modelSubagent];
|
|
99397
99547
|
return models.some((m2) => m2 && parseModelSpec(m2).provider === "native-anthropic");
|
|
@@ -99401,9 +99551,9 @@ function isWindows2() {
|
|
|
99401
99551
|
}
|
|
99402
99552
|
function createStatusLineScript(tokenFilePath) {
|
|
99403
99553
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
99404
|
-
const claudishDir =
|
|
99554
|
+
const claudishDir = join20(homeDir, ".claudish");
|
|
99405
99555
|
const timestamp = Date.now();
|
|
99406
|
-
const scriptPath =
|
|
99556
|
+
const scriptPath = join20(claudishDir, `status-${timestamp}.js`);
|
|
99407
99557
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
99408
99558
|
const script = `
|
|
99409
99559
|
const fs = require('fs');
|
|
@@ -99488,13 +99638,13 @@ process.stdin.on('end', () => {
|
|
|
99488
99638
|
}
|
|
99489
99639
|
function createTempSettingsFile(modelDisplay, port) {
|
|
99490
99640
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
99491
|
-
const claudishDir =
|
|
99641
|
+
const claudishDir = join20(homeDir, ".claudish");
|
|
99492
99642
|
try {
|
|
99493
99643
|
mkdirSync10(claudishDir, { recursive: true });
|
|
99494
99644
|
} catch {}
|
|
99495
99645
|
const timestamp = Date.now();
|
|
99496
|
-
const tempPath =
|
|
99497
|
-
const tokenFilePath =
|
|
99646
|
+
const tempPath = join20(claudishDir, `settings-${timestamp}.json`);
|
|
99647
|
+
const tokenFilePath = join20(claudishDir, `tokens-${port}.json`);
|
|
99498
99648
|
let statusCommand;
|
|
99499
99649
|
if (isWindows2()) {
|
|
99500
99650
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -99530,7 +99680,7 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
99530
99680
|
if (userSettingsValue.trimStart().startsWith("{")) {
|
|
99531
99681
|
userSettings = JSON.parse(userSettingsValue);
|
|
99532
99682
|
} else {
|
|
99533
|
-
const rawUserSettings =
|
|
99683
|
+
const rawUserSettings = readFileSync17(userSettingsValue, "utf-8");
|
|
99534
99684
|
userSettings = JSON.parse(rawUserSettings);
|
|
99535
99685
|
}
|
|
99536
99686
|
userSettings.statusLine = statusLine;
|
|
@@ -99622,8 +99772,8 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
99622
99772
|
console.error("Install it from: https://claude.com/claude-code");
|
|
99623
99773
|
console.error(`
|
|
99624
99774
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
99625
|
-
const home =
|
|
99626
|
-
const localPath = isWindows2() ?
|
|
99775
|
+
const home = homedir17();
|
|
99776
|
+
const localPath = isWindows2() ? join20(home, ".claude", "local", "claude.exe") : join20(home, ".claude", "local", "claude");
|
|
99627
99777
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
99628
99778
|
process.exit(1);
|
|
99629
99779
|
}
|
|
@@ -99635,9 +99785,9 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
99635
99785
|
shell: needsShell
|
|
99636
99786
|
});
|
|
99637
99787
|
setupSignalHandlers(proc, tempSettingsPath, config3.quiet, onCleanup);
|
|
99638
|
-
const exitCode = await new Promise((
|
|
99788
|
+
const exitCode = await new Promise((resolve4) => {
|
|
99639
99789
|
proc.on("exit", (code) => {
|
|
99640
|
-
|
|
99790
|
+
resolve4(code ?? 1);
|
|
99641
99791
|
});
|
|
99642
99792
|
});
|
|
99643
99793
|
try {
|
|
@@ -99669,23 +99819,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet, onCleanup) {
|
|
|
99669
99819
|
async function findClaudeBinary() {
|
|
99670
99820
|
const isWindows3 = process.platform === "win32";
|
|
99671
99821
|
if (process.env.CLAUDE_PATH) {
|
|
99672
|
-
if (
|
|
99822
|
+
if (existsSync19(process.env.CLAUDE_PATH)) {
|
|
99673
99823
|
return process.env.CLAUDE_PATH;
|
|
99674
99824
|
}
|
|
99675
99825
|
}
|
|
99676
|
-
const home =
|
|
99677
|
-
const localPath = isWindows3 ?
|
|
99678
|
-
if (
|
|
99826
|
+
const home = homedir17();
|
|
99827
|
+
const localPath = isWindows3 ? join20(home, ".claude", "local", "claude.exe") : join20(home, ".claude", "local", "claude");
|
|
99828
|
+
if (existsSync19(localPath)) {
|
|
99679
99829
|
return localPath;
|
|
99680
99830
|
}
|
|
99681
99831
|
if (isWindows3) {
|
|
99682
99832
|
const windowsPaths = [
|
|
99683
|
-
|
|
99684
|
-
|
|
99685
|
-
|
|
99833
|
+
join20(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
99834
|
+
join20(home, ".npm-global", "claude.cmd"),
|
|
99835
|
+
join20(home, "node_modules", ".bin", "claude.cmd")
|
|
99686
99836
|
];
|
|
99687
99837
|
for (const path2 of windowsPaths) {
|
|
99688
|
-
if (
|
|
99838
|
+
if (existsSync19(path2)) {
|
|
99689
99839
|
return path2;
|
|
99690
99840
|
}
|
|
99691
99841
|
}
|
|
@@ -99693,14 +99843,14 @@ async function findClaudeBinary() {
|
|
|
99693
99843
|
const commonPaths = [
|
|
99694
99844
|
"/usr/local/bin/claude",
|
|
99695
99845
|
"/opt/homebrew/bin/claude",
|
|
99696
|
-
|
|
99697
|
-
|
|
99698
|
-
|
|
99846
|
+
join20(home, ".npm-global/bin/claude"),
|
|
99847
|
+
join20(home, ".local/bin/claude"),
|
|
99848
|
+
join20(home, "node_modules/.bin/claude"),
|
|
99699
99849
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
99700
|
-
|
|
99850
|
+
join20(home, "../usr/bin/claude")
|
|
99701
99851
|
];
|
|
99702
99852
|
for (const path2 of commonPaths) {
|
|
99703
|
-
if (
|
|
99853
|
+
if (existsSync19(path2)) {
|
|
99704
99854
|
return path2;
|
|
99705
99855
|
}
|
|
99706
99856
|
}
|
|
@@ -99715,9 +99865,9 @@ async function findClaudeBinary() {
|
|
|
99715
99865
|
proc.stdout?.on("data", (data) => {
|
|
99716
99866
|
output += data.toString();
|
|
99717
99867
|
});
|
|
99718
|
-
const exitCode = await new Promise((
|
|
99868
|
+
const exitCode = await new Promise((resolve4) => {
|
|
99719
99869
|
proc.on("exit", (code) => {
|
|
99720
|
-
|
|
99870
|
+
resolve4(code ?? 1);
|
|
99721
99871
|
});
|
|
99722
99872
|
});
|
|
99723
99873
|
if (exitCode === 0 && output.trim()) {
|
|
@@ -99752,17 +99902,17 @@ __export(exports_diag_output, {
|
|
|
99752
99902
|
});
|
|
99753
99903
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, unlinkSync as unlinkSync8 } from "fs";
|
|
99754
99904
|
import { execFileSync } from "child_process";
|
|
99755
|
-
import { homedir as
|
|
99756
|
-
import { join as
|
|
99905
|
+
import { homedir as homedir18 } from "os";
|
|
99906
|
+
import { join as join21 } from "path";
|
|
99757
99907
|
function getClaudishDir() {
|
|
99758
|
-
const dir =
|
|
99908
|
+
const dir = join21(homedir18(), ".claudish");
|
|
99759
99909
|
try {
|
|
99760
99910
|
mkdirSync11(dir, { recursive: true });
|
|
99761
99911
|
} catch {}
|
|
99762
99912
|
return dir;
|
|
99763
99913
|
}
|
|
99764
99914
|
function getDiagLogPath() {
|
|
99765
|
-
return
|
|
99915
|
+
return join21(getClaudishDir(), `diag-${process.pid}.log`);
|
|
99766
99916
|
}
|
|
99767
99917
|
|
|
99768
99918
|
class LogFileDiagOutput {
|
|
@@ -99867,14 +100017,14 @@ async function findAvailablePort(startPort = 3000, endPort = 9000) {
|
|
|
99867
100017
|
throw new Error(`No available ports found in range ${startPort}-${endPort}`);
|
|
99868
100018
|
}
|
|
99869
100019
|
async function isPortAvailable(port) {
|
|
99870
|
-
return new Promise((
|
|
100020
|
+
return new Promise((resolve4) => {
|
|
99871
100021
|
const server = createServer2();
|
|
99872
100022
|
server.once("error", (err) => {
|
|
99873
|
-
|
|
100023
|
+
resolve4(err.code !== "EADDRINUSE");
|
|
99874
100024
|
});
|
|
99875
100025
|
server.once("listening", () => {
|
|
99876
100026
|
server.close();
|
|
99877
|
-
|
|
100027
|
+
resolve4(true);
|
|
99878
100028
|
});
|
|
99879
100029
|
server.listen(port, "127.0.0.1");
|
|
99880
100030
|
});
|
|
@@ -101794,7 +101944,7 @@ var RequestError, toRequestError = (e) => {
|
|
|
101794
101944
|
});
|
|
101795
101945
|
if (!chunk) {
|
|
101796
101946
|
if (i === 1) {
|
|
101797
|
-
await new Promise((
|
|
101947
|
+
await new Promise((resolve4) => setTimeout(resolve4));
|
|
101798
101948
|
maxReadCount = 3;
|
|
101799
101949
|
continue;
|
|
101800
101950
|
}
|
|
@@ -102221,10 +102371,10 @@ class OpenRouterRequestQueue {
|
|
|
102221
102371
|
}
|
|
102222
102372
|
throw new Error(`OpenRouter request queue full (${this.queue.length}/${this.maxQueueSize}). The API is rate-limited. Please wait and try again.`);
|
|
102223
102373
|
}
|
|
102224
|
-
return new Promise((
|
|
102374
|
+
return new Promise((resolve4, reject) => {
|
|
102225
102375
|
const queuedRequest = {
|
|
102226
102376
|
fetchFn,
|
|
102227
|
-
resolve:
|
|
102377
|
+
resolve: resolve4,
|
|
102228
102378
|
reject
|
|
102229
102379
|
};
|
|
102230
102380
|
this.queue.push(queuedRequest);
|
|
@@ -102292,7 +102442,7 @@ class OpenRouterRequestQueue {
|
|
|
102292
102442
|
if (getLogLevel() === "debug") {
|
|
102293
102443
|
log(`[OpenRouterQueue] Waiting ${waitMs}ms before next request`);
|
|
102294
102444
|
}
|
|
102295
|
-
await new Promise((
|
|
102445
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitMs));
|
|
102296
102446
|
}
|
|
102297
102447
|
}
|
|
102298
102448
|
calculateDelay() {
|
|
@@ -102634,10 +102784,10 @@ class LocalModelQueue {
|
|
|
102634
102784
|
}
|
|
102635
102785
|
throw new Error(`Local model queue full (${this.queue.length}/${this.maxQueueSize}). GPU is overloaded. Please wait for current requests to complete.`);
|
|
102636
102786
|
}
|
|
102637
|
-
return new Promise((
|
|
102787
|
+
return new Promise((resolve4, reject) => {
|
|
102638
102788
|
const queuedRequest = {
|
|
102639
102789
|
fetchFn,
|
|
102640
|
-
resolve:
|
|
102790
|
+
resolve: resolve4,
|
|
102641
102791
|
reject,
|
|
102642
102792
|
providerId
|
|
102643
102793
|
};
|
|
@@ -102732,7 +102882,7 @@ class LocalModelQueue {
|
|
|
102732
102882
|
return parsed;
|
|
102733
102883
|
}
|
|
102734
102884
|
delay(ms) {
|
|
102735
|
-
return new Promise((
|
|
102885
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
102736
102886
|
}
|
|
102737
102887
|
getStats() {
|
|
102738
102888
|
return {
|
|
@@ -103431,8 +103581,8 @@ var init_middleware = __esm(() => {
|
|
|
103431
103581
|
|
|
103432
103582
|
// src/handlers/shared/token-tracker.ts
|
|
103433
103583
|
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync13 } from "fs";
|
|
103434
|
-
import { homedir as
|
|
103435
|
-
import { join as
|
|
103584
|
+
import { homedir as homedir19 } from "os";
|
|
103585
|
+
import { join as join22 } from "path";
|
|
103436
103586
|
|
|
103437
103587
|
class TokenTracker {
|
|
103438
103588
|
port;
|
|
@@ -103546,9 +103696,9 @@ class TokenTracker {
|
|
|
103546
103696
|
is_free: isFreeModel,
|
|
103547
103697
|
is_estimated: isEstimate || false
|
|
103548
103698
|
};
|
|
103549
|
-
const claudishDir =
|
|
103699
|
+
const claudishDir = join22(homedir19(), ".claudish");
|
|
103550
103700
|
mkdirSync12(claudishDir, { recursive: true });
|
|
103551
|
-
writeFileSync13(
|
|
103701
|
+
writeFileSync13(join22(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
103552
103702
|
} catch (e) {
|
|
103553
103703
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
103554
103704
|
}
|
|
@@ -104969,9 +105119,9 @@ var init_composed_handler = __esm(() => {
|
|
|
104969
105119
|
});
|
|
104970
105120
|
|
|
104971
105121
|
// src/services/pricing-cache.ts
|
|
104972
|
-
import { readFileSync as
|
|
104973
|
-
import { homedir as
|
|
104974
|
-
import { join as
|
|
105122
|
+
import { readFileSync as readFileSync18, writeFileSync as writeFileSync14, existsSync as existsSync20, mkdirSync as mkdirSync13, statSync as statSync2 } from "fs";
|
|
105123
|
+
import { homedir as homedir20 } from "os";
|
|
105124
|
+
import { join as join23 } from "path";
|
|
104975
105125
|
function getDynamicPricingSync(provider, modelName) {
|
|
104976
105126
|
if (provider === "openrouter") {
|
|
104977
105127
|
const direct = pricingMap.get(modelName);
|
|
@@ -105036,12 +105186,12 @@ async function warmPricingCache() {
|
|
|
105036
105186
|
}
|
|
105037
105187
|
function loadDiskCache() {
|
|
105038
105188
|
try {
|
|
105039
|
-
if (!
|
|
105189
|
+
if (!existsSync20(CACHE_FILE))
|
|
105040
105190
|
return false;
|
|
105041
105191
|
const stat = statSync2(CACHE_FILE);
|
|
105042
105192
|
const age = Date.now() - stat.mtimeMs;
|
|
105043
105193
|
const isFresh = age < CACHE_TTL_MS;
|
|
105044
|
-
const raw2 =
|
|
105194
|
+
const raw2 = readFileSync18(CACHE_FILE, "utf-8");
|
|
105045
105195
|
const data = JSON.parse(raw2);
|
|
105046
105196
|
for (const [key, pricing] of Object.entries(data)) {
|
|
105047
105197
|
pricingMap.set(key, pricing);
|
|
@@ -105088,8 +105238,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
105088
105238
|
init_model_loader();
|
|
105089
105239
|
init_remote_provider_types();
|
|
105090
105240
|
pricingMap = new Map;
|
|
105091
|
-
CACHE_DIR =
|
|
105092
|
-
CACHE_FILE =
|
|
105241
|
+
CACHE_DIR = join23(homedir20(), ".claudish");
|
|
105242
|
+
CACHE_FILE = join23(CACHE_DIR, "pricing-cache.json");
|
|
105093
105243
|
CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
105094
105244
|
PROVIDER_TO_OR_PREFIX = {
|
|
105095
105245
|
openai: ["openai/"],
|
|
@@ -105251,10 +105401,10 @@ class GeminiRequestQueue {
|
|
|
105251
105401
|
log(`[GeminiQueue] Queue full (${this.queue.length}/${this.maxQueueSize}), rejecting request`);
|
|
105252
105402
|
throw new Error("Gemini request queue full. Please retry later.");
|
|
105253
105403
|
}
|
|
105254
|
-
return new Promise((
|
|
105404
|
+
return new Promise((resolve4, reject) => {
|
|
105255
105405
|
const queuedRequest = {
|
|
105256
105406
|
fetchFn,
|
|
105257
|
-
resolve:
|
|
105407
|
+
resolve: resolve4,
|
|
105258
105408
|
reject
|
|
105259
105409
|
};
|
|
105260
105410
|
this.queue.push(queuedRequest);
|
|
@@ -105310,7 +105460,7 @@ class GeminiRequestQueue {
|
|
|
105310
105460
|
if (timeSinceLastRequest < delayMs) {
|
|
105311
105461
|
const waitMs = delayMs - timeSinceLastRequest;
|
|
105312
105462
|
log(`[GeminiQueue] Waiting ${waitMs}ms before next request`);
|
|
105313
|
-
await new Promise((
|
|
105463
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitMs));
|
|
105314
105464
|
}
|
|
105315
105465
|
}
|
|
105316
105466
|
handleRateLimitResponse(errorText) {
|
|
@@ -105548,12 +105698,12 @@ class AnthropicCompatProvider {
|
|
|
105548
105698
|
}
|
|
105549
105699
|
if (this.provider.name === "kimi-coding" && !this.apiKey) {
|
|
105550
105700
|
try {
|
|
105551
|
-
const { existsSync:
|
|
105552
|
-
const { join:
|
|
105553
|
-
const { homedir:
|
|
105554
|
-
const credPath =
|
|
105555
|
-
if (
|
|
105556
|
-
const data = JSON.parse(
|
|
105701
|
+
const { existsSync: existsSync21, readFileSync: readFileSync19 } = await import("fs");
|
|
105702
|
+
const { join: join24 } = await import("path");
|
|
105703
|
+
const { homedir: homedir21 } = await import("os");
|
|
105704
|
+
const credPath = join24(homedir21(), ".claudish", "kimi-oauth.json");
|
|
105705
|
+
if (existsSync21(credPath)) {
|
|
105706
|
+
const data = JSON.parse(readFileSync19(credPath, "utf-8"));
|
|
105557
105707
|
if (data.access_token && data.refresh_token) {
|
|
105558
105708
|
const { KimiOAuth: KimiOAuth2 } = await Promise.resolve().then(() => (init_kimi_oauth(), exports_kimi_oauth));
|
|
105559
105709
|
const oauth = KimiOAuth2.getInstance();
|
|
@@ -105862,10 +106012,10 @@ var init_litellm2 = __esm(() => {
|
|
|
105862
106012
|
});
|
|
105863
106013
|
|
|
105864
106014
|
// src/adapters/litellm-adapter.ts
|
|
105865
|
-
import { existsSync as
|
|
106015
|
+
import { existsSync as existsSync21, readFileSync as readFileSync19 } from "fs";
|
|
105866
106016
|
import { createHash as createHash5 } from "crypto";
|
|
105867
|
-
import { homedir as
|
|
105868
|
-
import { join as
|
|
106017
|
+
import { homedir as homedir21 } from "os";
|
|
106018
|
+
import { join as join24 } from "path";
|
|
105869
106019
|
var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
|
|
105870
106020
|
var init_litellm_adapter = __esm(() => {
|
|
105871
106021
|
init_base_adapter();
|
|
@@ -105961,10 +106111,10 @@ var init_litellm_adapter = __esm(() => {
|
|
|
105961
106111
|
checkVisionSupport() {
|
|
105962
106112
|
try {
|
|
105963
106113
|
const hash2 = createHash5("sha256").update(this.baseUrl).digest("hex").substring(0, 16);
|
|
105964
|
-
const cachePath =
|
|
105965
|
-
if (!
|
|
106114
|
+
const cachePath = join24(homedir21(), ".claudish", `litellm-models-${hash2}.json`);
|
|
106115
|
+
if (!existsSync21(cachePath))
|
|
105966
106116
|
return true;
|
|
105967
|
-
const cacheData = JSON.parse(
|
|
106117
|
+
const cacheData = JSON.parse(readFileSync19(cachePath, "utf-8"));
|
|
105968
106118
|
const model = cacheData.models?.find((m2) => m2.name === this.modelId);
|
|
105969
106119
|
if (model && model.supportsVision === false) {
|
|
105970
106120
|
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
|
|
@@ -105981,9 +106131,9 @@ var init_litellm_adapter = __esm(() => {
|
|
|
105981
106131
|
// src/auth/vertex-auth.ts
|
|
105982
106132
|
import { exec as exec4 } from "child_process";
|
|
105983
106133
|
import { promisify as promisify3 } from "util";
|
|
105984
|
-
import { existsSync as
|
|
105985
|
-
import { homedir as
|
|
105986
|
-
import { join as
|
|
106134
|
+
import { existsSync as existsSync23 } from "fs";
|
|
106135
|
+
import { homedir as homedir22 } from "os";
|
|
106136
|
+
import { join as join25 } from "path";
|
|
105987
106137
|
|
|
105988
106138
|
class VertexAuthManager {
|
|
105989
106139
|
cachedToken = null;
|
|
@@ -106037,8 +106187,8 @@ class VertexAuthManager {
|
|
|
106037
106187
|
}
|
|
106038
106188
|
async tryADC() {
|
|
106039
106189
|
try {
|
|
106040
|
-
const adcPath =
|
|
106041
|
-
if (!
|
|
106190
|
+
const adcPath = join25(homedir22(), ".config/gcloud/application_default_credentials.json");
|
|
106191
|
+
if (!existsSync23(adcPath)) {
|
|
106042
106192
|
log("[VertexAuth] ADC credentials file not found");
|
|
106043
106193
|
return null;
|
|
106044
106194
|
}
|
|
@@ -106062,7 +106212,7 @@ class VertexAuthManager {
|
|
|
106062
106212
|
if (!credPath) {
|
|
106063
106213
|
return null;
|
|
106064
106214
|
}
|
|
106065
|
-
if (!
|
|
106215
|
+
if (!existsSync23(credPath)) {
|
|
106066
106216
|
throw new Error(`Service account file not found: ${credPath}
|
|
106067
106217
|
|
|
106068
106218
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -106101,8 +106251,8 @@ function validateVertexOAuthConfig() {
|
|
|
106101
106251
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
106102
106252
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
106103
106253
|
}
|
|
106104
|
-
const adcPath =
|
|
106105
|
-
const hasADC =
|
|
106254
|
+
const adcPath = join25(homedir22(), ".config/gcloud/application_default_credentials.json");
|
|
106255
|
+
const hasADC = existsSync23(adcPath);
|
|
106106
106256
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
106107
106257
|
if (!hasADC && !hasServiceAccount) {
|
|
106108
106258
|
return `No Vertex AI credentials found.
|
|
@@ -106213,6 +106363,11 @@ function createHandlerForProvider(ctx) {
|
|
|
106213
106363
|
if (!profile) {
|
|
106214
106364
|
return null;
|
|
106215
106365
|
}
|
|
106366
|
+
if (ctx.provider.apiKeyEnvVar) {
|
|
106367
|
+
const provenance = resolveApiKeyProvenance(ctx.provider.apiKeyEnvVar);
|
|
106368
|
+
log(`[Proxy] API key: ${formatProvenanceLog(provenance)}`);
|
|
106369
|
+
}
|
|
106370
|
+
log(`[Proxy] Handler: provider=${ctx.provider.name}, model=${ctx.modelName}`);
|
|
106216
106371
|
return profile.createHandler(ctx);
|
|
106217
106372
|
}
|
|
106218
106373
|
var geminiProfile, geminiCodeAssistProfile, openaiProfile, anthropicCompatProfile, glmProfile, openCodeZenProfile, ollamaCloudProfile, litellmProfile, vertexProfile, PROVIDER_PROFILES;
|
|
@@ -106233,6 +106388,7 @@ var init_provider_profiles = __esm(() => {
|
|
|
106233
106388
|
init_remote_provider_registry();
|
|
106234
106389
|
init_vertex_auth();
|
|
106235
106390
|
init_logger();
|
|
106391
|
+
init_api_key_provenance();
|
|
106236
106392
|
geminiProfile = {
|
|
106237
106393
|
createHandler(ctx) {
|
|
106238
106394
|
const transport = new GeminiApiKeyProvider(ctx.provider, ctx.modelName, ctx.apiKey);
|
|
@@ -106708,7 +106864,7 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
106708
106864
|
port,
|
|
106709
106865
|
url: `http://127.0.0.1:${port}`,
|
|
106710
106866
|
shutdown: async () => {
|
|
106711
|
-
return new Promise((
|
|
106867
|
+
return new Promise((resolve4) => server.close((e) => resolve4()));
|
|
106712
106868
|
}
|
|
106713
106869
|
};
|
|
106714
106870
|
}
|
|
@@ -106737,17 +106893,17 @@ var init_proxy_server = __esm(() => {
|
|
|
106737
106893
|
});
|
|
106738
106894
|
|
|
106739
106895
|
// src/index.ts
|
|
106740
|
-
var
|
|
106741
|
-
import { existsSync as
|
|
106742
|
-
import { homedir as
|
|
106743
|
-
import { join as
|
|
106744
|
-
|
|
106896
|
+
var import_dotenv3 = __toESM(require_main(), 1);
|
|
106897
|
+
import { existsSync as existsSync25, readFileSync as readFileSync21 } from "fs";
|
|
106898
|
+
import { homedir as homedir23 } from "os";
|
|
106899
|
+
import { join as join26 } from "path";
|
|
106900
|
+
import_dotenv3.config({ quiet: true });
|
|
106745
106901
|
function loadStoredApiKeys() {
|
|
106746
106902
|
try {
|
|
106747
|
-
const configPath =
|
|
106748
|
-
if (!
|
|
106903
|
+
const configPath = join26(homedir23(), ".claudish", "config.json");
|
|
106904
|
+
if (!existsSync25(configPath))
|
|
106749
106905
|
return;
|
|
106750
|
-
const raw2 =
|
|
106906
|
+
const raw2 = readFileSync21(configPath, "utf-8");
|
|
106751
106907
|
const cfg = JSON.parse(raw2);
|
|
106752
106908
|
if (cfg.apiKeys) {
|
|
106753
106909
|
for (const [envVar, value] of Object.entries(cfg.apiKeys)) {
|
|
@@ -106795,7 +106951,7 @@ if (isMcpMode) {
|
|
|
106795
106951
|
await oauth.login();
|
|
106796
106952
|
console.log(`
|
|
106797
106953
|
\u2705 Gemini OAuth login successful!`);
|
|
106798
|
-
console.log("You can now use Gemini Code Assist with: claudish --model go@gemini-
|
|
106954
|
+
console.log("You can now use Gemini Code Assist with: claudish --model go@gemini-3-pro-preview");
|
|
106799
106955
|
process.exit(0);
|
|
106800
106956
|
} catch (error46) {
|
|
106801
106957
|
console.error(`
|