claudish 5.18.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 +411 -257
- package/package.json +1 -1
- package/recommended-models.json +1 -1
package/dist/index.js
CHANGED
|
@@ -32121,6 +32121,122 @@ var init_routing_rules = __esm(() => {
|
|
|
32121
32121
|
init_model_catalog_resolver();
|
|
32122
32122
|
});
|
|
32123
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
|
+
|
|
32124
32240
|
// src/providers/provider-registry.ts
|
|
32125
32241
|
function resolveProvider(modelId) {
|
|
32126
32242
|
const providers = getProviders();
|
|
@@ -32322,9 +32438,9 @@ __export(exports_provider_resolver, {
|
|
|
32322
32438
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
32323
32439
|
getMissingKeyError: () => getMissingKeyError
|
|
32324
32440
|
});
|
|
32325
|
-
import { existsSync as
|
|
32326
|
-
import { join as
|
|
32327
|
-
import { homedir as
|
|
32441
|
+
import { existsSync as existsSync13 } from "fs";
|
|
32442
|
+
import { join as join13 } from "path";
|
|
32443
|
+
import { homedir as homedir12 } from "os";
|
|
32328
32444
|
function getApiKeyInfoForProvider(providerName) {
|
|
32329
32445
|
const lookupName = providerName === "gemini" ? "google" : providerName;
|
|
32330
32446
|
const info = getApiKeyInfo(lookupName);
|
|
@@ -32359,8 +32475,8 @@ function isApiKeyAvailable(info) {
|
|
|
32359
32475
|
}
|
|
32360
32476
|
if (info.oauthFallback) {
|
|
32361
32477
|
try {
|
|
32362
|
-
const credPath =
|
|
32363
|
-
if (
|
|
32478
|
+
const credPath = join13(homedir12(), ".claudish", info.oauthFallback);
|
|
32479
|
+
if (existsSync13(credPath)) {
|
|
32364
32480
|
return true;
|
|
32365
32481
|
}
|
|
32366
32482
|
} catch {}
|
|
@@ -34997,23 +35113,23 @@ __export(exports_cli, {
|
|
|
34997
35113
|
getMissingKeyError: () => getMissingKeyError
|
|
34998
35114
|
});
|
|
34999
35115
|
import {
|
|
35000
|
-
readFileSync as
|
|
35116
|
+
readFileSync as readFileSync12,
|
|
35001
35117
|
writeFileSync as writeFileSync6,
|
|
35002
|
-
existsSync as
|
|
35118
|
+
existsSync as existsSync14,
|
|
35003
35119
|
mkdirSync as mkdirSync6,
|
|
35004
35120
|
copyFileSync,
|
|
35005
35121
|
readdirSync as readdirSync3,
|
|
35006
35122
|
unlinkSync as unlinkSync4
|
|
35007
35123
|
} from "fs";
|
|
35008
35124
|
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
35009
|
-
import { dirname as dirname3, join as
|
|
35010
|
-
import { homedir as
|
|
35125
|
+
import { dirname as dirname3, join as join14 } from "path";
|
|
35126
|
+
import { homedir as homedir13 } from "os";
|
|
35011
35127
|
function getVersion() {
|
|
35012
35128
|
return VERSION;
|
|
35013
35129
|
}
|
|
35014
35130
|
function clearAllModelCaches() {
|
|
35015
|
-
const cacheDir =
|
|
35016
|
-
if (!
|
|
35131
|
+
const cacheDir = join14(homedir13(), ".claudish");
|
|
35132
|
+
if (!existsSync14(cacheDir))
|
|
35017
35133
|
return;
|
|
35018
35134
|
const cachePatterns = ["all-models.json", "pricing-cache.json"];
|
|
35019
35135
|
let cleared = 0;
|
|
@@ -35021,7 +35137,7 @@ function clearAllModelCaches() {
|
|
|
35021
35137
|
const files = readdirSync3(cacheDir);
|
|
35022
35138
|
for (const file2 of files) {
|
|
35023
35139
|
if (cachePatterns.includes(file2) || file2.startsWith("litellm-models-")) {
|
|
35024
|
-
unlinkSync4(
|
|
35140
|
+
unlinkSync4(join14(cacheDir, file2));
|
|
35025
35141
|
cleared++;
|
|
35026
35142
|
}
|
|
35027
35143
|
}
|
|
@@ -35315,9 +35431,9 @@ async function fetchOllamaModels() {
|
|
|
35315
35431
|
}
|
|
35316
35432
|
async function searchAndPrintModels(query, forceUpdate) {
|
|
35317
35433
|
let models = [];
|
|
35318
|
-
if (!forceUpdate &&
|
|
35434
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH)) {
|
|
35319
35435
|
try {
|
|
35320
|
-
const cacheData = JSON.parse(
|
|
35436
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
35321
35437
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
35322
35438
|
const now = new Date;
|
|
35323
35439
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -35485,9 +35601,9 @@ Found ${results.length} matching models:
|
|
|
35485
35601
|
async function printAllModels(jsonOutput, forceUpdate) {
|
|
35486
35602
|
let models = [];
|
|
35487
35603
|
const [ollamaModels, zenModels] = await Promise.all([fetchOllamaModels(), fetchZenModels()]);
|
|
35488
|
-
if (!forceUpdate &&
|
|
35604
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH)) {
|
|
35489
35605
|
try {
|
|
35490
|
-
const cacheData = JSON.parse(
|
|
35606
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
35491
35607
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
35492
35608
|
const now = new Date;
|
|
35493
35609
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -35688,12 +35804,12 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
35688
35804
|
console.log("Top models: claudish --top-models");
|
|
35689
35805
|
}
|
|
35690
35806
|
function isCacheStale() {
|
|
35691
|
-
const cachePath =
|
|
35692
|
-
if (!
|
|
35807
|
+
const cachePath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35808
|
+
if (!existsSync14(cachePath)) {
|
|
35693
35809
|
return true;
|
|
35694
35810
|
}
|
|
35695
35811
|
try {
|
|
35696
|
-
const jsonContent =
|
|
35812
|
+
const jsonContent = readFileSync12(cachePath, "utf-8");
|
|
35697
35813
|
const data = JSON.parse(jsonContent);
|
|
35698
35814
|
if (!data.lastUpdated) {
|
|
35699
35815
|
return true;
|
|
@@ -35772,10 +35888,10 @@ async function updateModelsFromOpenRouter() {
|
|
|
35772
35888
|
providers.add(provider);
|
|
35773
35889
|
}
|
|
35774
35890
|
let version2 = "1.2.0";
|
|
35775
|
-
const existingPath =
|
|
35776
|
-
if (
|
|
35891
|
+
const existingPath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
35892
|
+
if (existsSync14(existingPath)) {
|
|
35777
35893
|
try {
|
|
35778
|
-
const existing = JSON.parse(
|
|
35894
|
+
const existing = JSON.parse(readFileSync12(existingPath, "utf-8"));
|
|
35779
35895
|
version2 = existing.version || version2;
|
|
35780
35896
|
} catch {}
|
|
35781
35897
|
}
|
|
@@ -35804,8 +35920,8 @@ async function checkAndUpdateModelsCache(forceUpdate = false) {
|
|
|
35804
35920
|
await updateModelsFromOpenRouter();
|
|
35805
35921
|
} else {
|
|
35806
35922
|
try {
|
|
35807
|
-
const cachePath =
|
|
35808
|
-
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"));
|
|
35809
35925
|
console.error(`\u2713 Using cached models (last updated: ${data.lastUpdated})`);
|
|
35810
35926
|
} catch {}
|
|
35811
35927
|
}
|
|
@@ -35828,6 +35944,25 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35828
35944
|
]);
|
|
35829
35945
|
const routingRules = loadRoutingRules();
|
|
35830
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
|
+
};
|
|
35831
35966
|
for (const modelInput of models) {
|
|
35832
35967
|
const parsed = parseModelSpec(modelInput);
|
|
35833
35968
|
const chain = (() => {
|
|
@@ -35865,35 +36000,18 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35865
36000
|
matchedPattern: undefined
|
|
35866
36001
|
};
|
|
35867
36002
|
})();
|
|
35868
|
-
const API_KEY_MAP = {
|
|
35869
|
-
litellm: { envVar: "LITELLM_API_KEY" },
|
|
35870
|
-
openrouter: { envVar: "OPENROUTER_API_KEY" },
|
|
35871
|
-
google: { envVar: "GEMINI_API_KEY" },
|
|
35872
|
-
openai: { envVar: "OPENAI_API_KEY" },
|
|
35873
|
-
minimax: { envVar: "MINIMAX_API_KEY" },
|
|
35874
|
-
"minimax-coding": { envVar: "MINIMAX_CODING_API_KEY" },
|
|
35875
|
-
kimi: { envVar: "MOONSHOT_API_KEY", aliases: ["KIMI_API_KEY"] },
|
|
35876
|
-
"kimi-coding": { envVar: "KIMI_CODING_API_KEY" },
|
|
35877
|
-
glm: { envVar: "ZHIPU_API_KEY", aliases: ["GLM_API_KEY"] },
|
|
35878
|
-
"glm-coding": { envVar: "GLM_CODING_API_KEY", aliases: ["ZAI_CODING_API_KEY"] },
|
|
35879
|
-
zai: { envVar: "ZAI_API_KEY" },
|
|
35880
|
-
ollamacloud: { envVar: "OLLAMA_API_KEY" },
|
|
35881
|
-
"opencode-zen": { envVar: "OPENCODE_API_KEY" },
|
|
35882
|
-
"opencode-zen-go": { envVar: "OPENCODE_API_KEY" },
|
|
35883
|
-
"gemini-codeassist": { envVar: "GEMINI_API_KEY" },
|
|
35884
|
-
vertex: { envVar: "VERTEX_API_KEY", aliases: ["VERTEX_PROJECT"] },
|
|
35885
|
-
poe: { envVar: "POE_API_KEY" }
|
|
35886
|
-
};
|
|
35887
36003
|
const chainDetails = chain.routes.map((route) => {
|
|
35888
36004
|
const keyInfo = API_KEY_MAP[route.provider];
|
|
35889
36005
|
let hasCredentials = false;
|
|
35890
36006
|
let credentialHint;
|
|
36007
|
+
let provenance;
|
|
35891
36008
|
if (!keyInfo) {
|
|
35892
36009
|
hasCredentials = true;
|
|
35893
36010
|
} else if (!keyInfo.envVar) {
|
|
35894
36011
|
hasCredentials = true;
|
|
35895
36012
|
} else {
|
|
35896
|
-
|
|
36013
|
+
provenance = resolveApiKeyProvenance(keyInfo.envVar, keyInfo.aliases);
|
|
36014
|
+
hasCredentials = !!provenance.effectiveValue;
|
|
35897
36015
|
if (!hasCredentials && keyInfo.aliases) {
|
|
35898
36016
|
hasCredentials = keyInfo.aliases.some((a) => !!process.env[a]);
|
|
35899
36017
|
}
|
|
@@ -35906,7 +36024,8 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35906
36024
|
displayName: route.displayName,
|
|
35907
36025
|
modelSpec: route.modelSpec,
|
|
35908
36026
|
hasCredentials,
|
|
35909
|
-
credentialHint
|
|
36027
|
+
credentialHint,
|
|
36028
|
+
provenance
|
|
35910
36029
|
};
|
|
35911
36030
|
});
|
|
35912
36031
|
let wiring = undefined;
|
|
@@ -35991,6 +36110,23 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
35991
36110
|
console.log(` ${DIM}${line}${RESET}`);
|
|
35992
36111
|
if (result.routingSource === "direct") {
|
|
35993
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
|
+
}
|
|
35994
36130
|
} else if (result.chain.length === 0) {
|
|
35995
36131
|
console.log(` ${RED} No providers available${RESET} \u2014 no credentials configured`);
|
|
35996
36132
|
} else {
|
|
@@ -36021,6 +36157,17 @@ async function probeModelRouting(models, jsonOutput) {
|
|
|
36021
36157
|
} else if (firstReady) {
|
|
36022
36158
|
console.log(`
|
|
36023
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
|
+
}
|
|
36024
36171
|
if (result.wiring) {
|
|
36025
36172
|
const w = result.wiring;
|
|
36026
36173
|
console.log("");
|
|
@@ -36364,8 +36511,8 @@ MORE INFO:
|
|
|
36364
36511
|
}
|
|
36365
36512
|
function printAIAgentGuide() {
|
|
36366
36513
|
try {
|
|
36367
|
-
const guidePath =
|
|
36368
|
-
const guideContent =
|
|
36514
|
+
const guidePath = join14(__dirname4, "../AI_AGENT_GUIDE.md");
|
|
36515
|
+
const guideContent = readFileSync12(guidePath, "utf-8");
|
|
36369
36516
|
console.log(guideContent);
|
|
36370
36517
|
} catch (error46) {
|
|
36371
36518
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -36381,19 +36528,19 @@ async function initializeClaudishSkill() {
|
|
|
36381
36528
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
36382
36529
|
`);
|
|
36383
36530
|
const cwd = process.cwd();
|
|
36384
|
-
const claudeDir =
|
|
36385
|
-
const skillsDir =
|
|
36386
|
-
const claudishSkillDir =
|
|
36387
|
-
const skillFile =
|
|
36388
|
-
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)) {
|
|
36389
36536
|
console.log("\u2705 Claudish skill already installed at:");
|
|
36390
36537
|
console.log(` ${skillFile}
|
|
36391
36538
|
`);
|
|
36392
36539
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
36393
36540
|
return;
|
|
36394
36541
|
}
|
|
36395
|
-
const sourceSkillPath =
|
|
36396
|
-
if (!
|
|
36542
|
+
const sourceSkillPath = join14(__dirname4, "../skills/claudish-usage/SKILL.md");
|
|
36543
|
+
if (!existsSync14(sourceSkillPath)) {
|
|
36397
36544
|
console.error("\u274C Error: Claudish skill file not found in installation.");
|
|
36398
36545
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
36399
36546
|
console.error(`
|
|
@@ -36402,15 +36549,15 @@ async function initializeClaudishSkill() {
|
|
|
36402
36549
|
process.exit(1);
|
|
36403
36550
|
}
|
|
36404
36551
|
try {
|
|
36405
|
-
if (!
|
|
36552
|
+
if (!existsSync14(claudeDir)) {
|
|
36406
36553
|
mkdirSync6(claudeDir, { recursive: true });
|
|
36407
36554
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
36408
36555
|
}
|
|
36409
|
-
if (!
|
|
36556
|
+
if (!existsSync14(skillsDir)) {
|
|
36410
36557
|
mkdirSync6(skillsDir, { recursive: true });
|
|
36411
36558
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
36412
36559
|
}
|
|
36413
|
-
if (!
|
|
36560
|
+
if (!existsSync14(claudishSkillDir)) {
|
|
36414
36561
|
mkdirSync6(claudishSkillDir, { recursive: true });
|
|
36415
36562
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
36416
36563
|
}
|
|
@@ -36453,9 +36600,9 @@ function printAvailableModels() {
|
|
|
36453
36600
|
let lastUpdated = "unknown";
|
|
36454
36601
|
let models = [];
|
|
36455
36602
|
try {
|
|
36456
|
-
const cachePath =
|
|
36457
|
-
if (
|
|
36458
|
-
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"));
|
|
36459
36606
|
lastUpdated = data.lastUpdated || "unknown";
|
|
36460
36607
|
models = data.models || [];
|
|
36461
36608
|
}
|
|
@@ -36504,9 +36651,9 @@ Force update: claudish --list-models --force-update
|
|
|
36504
36651
|
`);
|
|
36505
36652
|
}
|
|
36506
36653
|
function printAvailableModelsJSON() {
|
|
36507
|
-
const jsonPath =
|
|
36654
|
+
const jsonPath = existsSync14(CACHED_MODELS_PATH) ? CACHED_MODELS_PATH : BUNDLED_MODELS_PATH;
|
|
36508
36655
|
try {
|
|
36509
|
-
const jsonContent =
|
|
36656
|
+
const jsonContent = readFileSync12(jsonPath, "utf-8");
|
|
36510
36657
|
const data = JSON.parse(jsonContent);
|
|
36511
36658
|
console.log(JSON.stringify(data, null, 2));
|
|
36512
36659
|
} catch (error46) {
|
|
@@ -36591,7 +36738,7 @@ async function fetchGLMCodingModels() {
|
|
|
36591
36738
|
return [];
|
|
36592
36739
|
}
|
|
36593
36740
|
}
|
|
36594
|
-
var __filename4, __dirname4, VERSION = "5.18.
|
|
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;
|
|
36595
36742
|
var init_cli = __esm(() => {
|
|
36596
36743
|
init_config();
|
|
36597
36744
|
init_model_loader();
|
|
@@ -36599,17 +36746,18 @@ var init_cli = __esm(() => {
|
|
|
36599
36746
|
init_model_parser();
|
|
36600
36747
|
init_auto_route();
|
|
36601
36748
|
init_routing_rules();
|
|
36749
|
+
init_api_key_provenance();
|
|
36602
36750
|
init_provider_resolver();
|
|
36603
36751
|
__filename4 = fileURLToPath3(import.meta.url);
|
|
36604
36752
|
__dirname4 = dirname3(__filename4);
|
|
36605
36753
|
try {
|
|
36606
|
-
const packageJson = JSON.parse(
|
|
36754
|
+
const packageJson = JSON.parse(readFileSync12(join14(__dirname4, "../package.json"), "utf-8"));
|
|
36607
36755
|
VERSION = packageJson.version;
|
|
36608
36756
|
} catch {}
|
|
36609
|
-
CLAUDISH_CACHE_DIR2 =
|
|
36610
|
-
BUNDLED_MODELS_PATH =
|
|
36611
|
-
CACHED_MODELS_PATH =
|
|
36612
|
-
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");
|
|
36613
36761
|
});
|
|
36614
36762
|
|
|
36615
36763
|
// src/update-checker.ts
|
|
@@ -36621,9 +36769,9 @@ __export(exports_update_checker, {
|
|
|
36621
36769
|
checkForUpdates: () => checkForUpdates
|
|
36622
36770
|
});
|
|
36623
36771
|
import { execSync } from "child_process";
|
|
36624
|
-
import { existsSync as
|
|
36625
|
-
import { homedir as
|
|
36626
|
-
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";
|
|
36627
36775
|
import { createInterface } from "readline";
|
|
36628
36776
|
function getUpdateCommand() {
|
|
36629
36777
|
const scriptPath = process.argv[1] || "";
|
|
@@ -36635,27 +36783,27 @@ function getUpdateCommand() {
|
|
|
36635
36783
|
function getCacheFilePath() {
|
|
36636
36784
|
let cacheDir;
|
|
36637
36785
|
if (isWindows) {
|
|
36638
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
36639
|
-
cacheDir =
|
|
36786
|
+
const localAppData = process.env.LOCALAPPDATA || join15(homedir14(), "AppData", "Local");
|
|
36787
|
+
cacheDir = join15(localAppData, "claudish");
|
|
36640
36788
|
} else {
|
|
36641
|
-
cacheDir =
|
|
36789
|
+
cacheDir = join15(homedir14(), ".cache", "claudish");
|
|
36642
36790
|
}
|
|
36643
36791
|
try {
|
|
36644
|
-
if (!
|
|
36792
|
+
if (!existsSync15(cacheDir)) {
|
|
36645
36793
|
mkdirSync7(cacheDir, { recursive: true });
|
|
36646
36794
|
}
|
|
36647
|
-
return
|
|
36795
|
+
return join15(cacheDir, "update-check.json");
|
|
36648
36796
|
} catch {
|
|
36649
|
-
return
|
|
36797
|
+
return join15(tmpdir(), "claudish-update-check.json");
|
|
36650
36798
|
}
|
|
36651
36799
|
}
|
|
36652
36800
|
function readCache() {
|
|
36653
36801
|
try {
|
|
36654
36802
|
const cachePath = getCacheFilePath();
|
|
36655
|
-
if (!
|
|
36803
|
+
if (!existsSync15(cachePath)) {
|
|
36656
36804
|
return null;
|
|
36657
36805
|
}
|
|
36658
|
-
const data = JSON.parse(
|
|
36806
|
+
const data = JSON.parse(readFileSync13(cachePath, "utf-8"));
|
|
36659
36807
|
return data;
|
|
36660
36808
|
} catch {
|
|
36661
36809
|
return null;
|
|
@@ -36678,7 +36826,7 @@ function isCacheValid(cache) {
|
|
|
36678
36826
|
function clearCache() {
|
|
36679
36827
|
try {
|
|
36680
36828
|
const cachePath = getCacheFilePath();
|
|
36681
|
-
if (
|
|
36829
|
+
if (existsSync15(cachePath)) {
|
|
36682
36830
|
unlinkSync5(cachePath);
|
|
36683
36831
|
}
|
|
36684
36832
|
} catch {}
|
|
@@ -36715,7 +36863,7 @@ async function fetchLatestVersion() {
|
|
|
36715
36863
|
}
|
|
36716
36864
|
}
|
|
36717
36865
|
function promptUser(question) {
|
|
36718
|
-
return new Promise((
|
|
36866
|
+
return new Promise((resolve3) => {
|
|
36719
36867
|
const rl = createInterface({
|
|
36720
36868
|
input: process.stdin,
|
|
36721
36869
|
output: process.stderr
|
|
@@ -36723,7 +36871,7 @@ function promptUser(question) {
|
|
|
36723
36871
|
rl.question(question, (answer) => {
|
|
36724
36872
|
rl.close();
|
|
36725
36873
|
const normalized = answer.toLowerCase().trim();
|
|
36726
|
-
|
|
36874
|
+
resolve3(normalized === "y" || normalized === "yes");
|
|
36727
36875
|
});
|
|
36728
36876
|
});
|
|
36729
36877
|
}
|
|
@@ -36834,7 +36982,7 @@ function getUpdateCommand2(method) {
|
|
|
36834
36982
|
}
|
|
36835
36983
|
}
|
|
36836
36984
|
function promptUser2(question) {
|
|
36837
|
-
return new Promise((
|
|
36985
|
+
return new Promise((resolve3) => {
|
|
36838
36986
|
const rl = createInterface2({
|
|
36839
36987
|
input: process.stdin,
|
|
36840
36988
|
output: process.stdout
|
|
@@ -36842,7 +36990,7 @@ function promptUser2(question) {
|
|
|
36842
36990
|
rl.question(question, (answer) => {
|
|
36843
36991
|
rl.close();
|
|
36844
36992
|
const normalized = answer.toLowerCase().trim();
|
|
36845
|
-
|
|
36993
|
+
resolve3(normalized === "y" || normalized === "yes" || normalized === "");
|
|
36846
36994
|
});
|
|
36847
36995
|
});
|
|
36848
36996
|
}
|
|
@@ -38528,13 +38676,13 @@ var PromisePolyfill;
|
|
|
38528
38676
|
var init_promise_polyfill = __esm(() => {
|
|
38529
38677
|
PromisePolyfill = class PromisePolyfill extends Promise {
|
|
38530
38678
|
static withResolver() {
|
|
38531
|
-
let
|
|
38679
|
+
let resolve3;
|
|
38532
38680
|
let reject;
|
|
38533
38681
|
const promise3 = new Promise((res, rej) => {
|
|
38534
|
-
|
|
38682
|
+
resolve3 = res;
|
|
38535
38683
|
reject = rej;
|
|
38536
38684
|
});
|
|
38537
|
-
return { promise: promise3, resolve:
|
|
38685
|
+
return { promise: promise3, resolve: resolve3, reject };
|
|
38538
38686
|
}
|
|
38539
38687
|
};
|
|
38540
38688
|
});
|
|
@@ -38571,7 +38719,7 @@ function createPrompt(view) {
|
|
|
38571
38719
|
output
|
|
38572
38720
|
});
|
|
38573
38721
|
const screen = new ScreenManager(rl);
|
|
38574
|
-
const { promise: promise3, resolve:
|
|
38722
|
+
const { promise: promise3, resolve: resolve3, reject } = PromisePolyfill.withResolver();
|
|
38575
38723
|
const cancel = () => reject(new CancelPromptError);
|
|
38576
38724
|
if (signal) {
|
|
38577
38725
|
const abort = () => reject(new AbortPromptError({ cause: signal.reason }));
|
|
@@ -38598,7 +38746,7 @@ function createPrompt(view) {
|
|
|
38598
38746
|
cycle(() => {
|
|
38599
38747
|
try {
|
|
38600
38748
|
const nextView = view(config3, (value) => {
|
|
38601
|
-
setImmediate(() =>
|
|
38749
|
+
setImmediate(() => resolve3(value));
|
|
38602
38750
|
});
|
|
38603
38751
|
if (nextView === undefined) {
|
|
38604
38752
|
const callerFilename = callSites[1]?.getFileName();
|
|
@@ -39159,14 +39307,14 @@ __export(exports_model_selector, {
|
|
|
39159
39307
|
promptForApiKey: () => promptForApiKey,
|
|
39160
39308
|
confirmAction: () => confirmAction
|
|
39161
39309
|
});
|
|
39162
|
-
import { readFileSync as
|
|
39163
|
-
import { join as
|
|
39164
|
-
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";
|
|
39165
39313
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
39166
39314
|
function loadRecommendedModels2() {
|
|
39167
|
-
if (
|
|
39315
|
+
if (existsSync16(RECOMMENDED_MODELS_JSON_PATH)) {
|
|
39168
39316
|
try {
|
|
39169
|
-
const content =
|
|
39317
|
+
const content = readFileSync14(RECOMMENDED_MODELS_JSON_PATH, "utf-8");
|
|
39170
39318
|
const data = JSON.parse(content);
|
|
39171
39319
|
return (data.models || []).map((model) => ({
|
|
39172
39320
|
...model,
|
|
@@ -39179,9 +39327,9 @@ function loadRecommendedModels2() {
|
|
|
39179
39327
|
return [];
|
|
39180
39328
|
}
|
|
39181
39329
|
async function fetchAllModels(forceUpdate = false) {
|
|
39182
|
-
if (!forceUpdate &&
|
|
39330
|
+
if (!forceUpdate && existsSync16(ALL_MODELS_JSON_PATH2)) {
|
|
39183
39331
|
try {
|
|
39184
|
-
const cacheData = JSON.parse(
|
|
39332
|
+
const cacheData = JSON.parse(readFileSync14(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
39185
39333
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
39186
39334
|
const now = new Date;
|
|
39187
39335
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -39683,11 +39831,11 @@ async function fetchOllamaCloudModels() {
|
|
|
39683
39831
|
}
|
|
39684
39832
|
}
|
|
39685
39833
|
function shouldRefreshForFreeModels() {
|
|
39686
|
-
if (!
|
|
39834
|
+
if (!existsSync16(ALL_MODELS_JSON_PATH2)) {
|
|
39687
39835
|
return true;
|
|
39688
39836
|
}
|
|
39689
39837
|
try {
|
|
39690
|
-
const cacheData = JSON.parse(
|
|
39838
|
+
const cacheData = JSON.parse(readFileSync14(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
39691
39839
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
39692
39840
|
const now = new Date;
|
|
39693
39841
|
const ageInHours = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
|
@@ -40288,9 +40436,9 @@ var init_model_selector = __esm(() => {
|
|
|
40288
40436
|
init_model_loader();
|
|
40289
40437
|
__filename5 = fileURLToPath4(import.meta.url);
|
|
40290
40438
|
__dirname5 = dirname4(__filename5);
|
|
40291
|
-
CLAUDISH_CACHE_DIR3 =
|
|
40292
|
-
ALL_MODELS_JSON_PATH2 =
|
|
40293
|
-
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");
|
|
40294
40442
|
PROVIDER_FILTER_ALIASES = {
|
|
40295
40443
|
zen: "Zen",
|
|
40296
40444
|
openrouter: "OpenRouter",
|
|
@@ -41148,11 +41296,11 @@ async function runConsentPrompt(ctx) {
|
|
|
41148
41296
|
Does NOT send: prompts, paths, API keys, or credentials.
|
|
41149
41297
|
Disable anytime: claudish telemetry off
|
|
41150
41298
|
`);
|
|
41151
|
-
const answer = await new Promise((
|
|
41299
|
+
const answer = await new Promise((resolve3) => {
|
|
41152
41300
|
const rl = createInterface4({ input: process.stdin, output: process.stderr });
|
|
41153
41301
|
rl.question("Send anonymous error report? [y/N] ", (ans) => {
|
|
41154
41302
|
rl.close();
|
|
41155
|
-
|
|
41303
|
+
resolve3(ans.trim().toLowerCase());
|
|
41156
41304
|
});
|
|
41157
41305
|
});
|
|
41158
41306
|
const accepted = answer === "y" || answer === "yes";
|
|
@@ -41336,25 +41484,25 @@ var init_telemetry = __esm(() => {
|
|
|
41336
41484
|
|
|
41337
41485
|
// src/stats-buffer.ts
|
|
41338
41486
|
import {
|
|
41339
|
-
existsSync as
|
|
41487
|
+
existsSync as existsSync17,
|
|
41340
41488
|
mkdirSync as mkdirSync9,
|
|
41341
|
-
readFileSync as
|
|
41489
|
+
readFileSync as readFileSync15,
|
|
41342
41490
|
renameSync,
|
|
41343
41491
|
unlinkSync as unlinkSync6,
|
|
41344
41492
|
writeFileSync as writeFileSync9
|
|
41345
41493
|
} from "fs";
|
|
41346
|
-
import { homedir as
|
|
41347
|
-
import { join as
|
|
41494
|
+
import { homedir as homedir16 } from "os";
|
|
41495
|
+
import { join as join17 } from "path";
|
|
41348
41496
|
function ensureDir() {
|
|
41349
|
-
if (!
|
|
41497
|
+
if (!existsSync17(CLAUDISH_DIR)) {
|
|
41350
41498
|
mkdirSync9(CLAUDISH_DIR, { recursive: true });
|
|
41351
41499
|
}
|
|
41352
41500
|
}
|
|
41353
41501
|
function readFromDisk() {
|
|
41354
41502
|
try {
|
|
41355
|
-
if (!
|
|
41503
|
+
if (!existsSync17(BUFFER_FILE))
|
|
41356
41504
|
return [];
|
|
41357
|
-
const raw =
|
|
41505
|
+
const raw = readFileSync15(BUFFER_FILE, "utf-8");
|
|
41358
41506
|
const parsed = JSON.parse(raw);
|
|
41359
41507
|
if (!Array.isArray(parsed.events))
|
|
41360
41508
|
return [];
|
|
@@ -41378,7 +41526,7 @@ function writeToDisk(events) {
|
|
|
41378
41526
|
ensureDir();
|
|
41379
41527
|
const trimmed = enforceSizeCap([...events]);
|
|
41380
41528
|
const payload = { version: 1, events: trimmed };
|
|
41381
|
-
const tmpFile =
|
|
41529
|
+
const tmpFile = join17(CLAUDISH_DIR, `stats-buffer.tmp.${process.pid}.json`);
|
|
41382
41530
|
writeFileSync9(tmpFile, JSON.stringify(payload, null, 2), "utf-8");
|
|
41383
41531
|
renameSync(tmpFile, BUFFER_FILE);
|
|
41384
41532
|
memoryCache = trimmed;
|
|
@@ -41423,7 +41571,7 @@ function clearBuffer() {
|
|
|
41423
41571
|
try {
|
|
41424
41572
|
memoryCache = [];
|
|
41425
41573
|
eventsSinceLastFlush = 0;
|
|
41426
|
-
if (
|
|
41574
|
+
if (existsSync17(BUFFER_FILE)) {
|
|
41427
41575
|
unlinkSync6(BUFFER_FILE);
|
|
41428
41576
|
}
|
|
41429
41577
|
} catch {}
|
|
@@ -41452,8 +41600,8 @@ function syncFlushOnExit() {
|
|
|
41452
41600
|
var BUFFER_MAX_BYTES, CLAUDISH_DIR, BUFFER_FILE, memoryCache = null, eventsSinceLastFlush = 0, lastFlushTime, flushScheduled = false;
|
|
41453
41601
|
var init_stats_buffer = __esm(() => {
|
|
41454
41602
|
BUFFER_MAX_BYTES = 64 * 1024;
|
|
41455
|
-
CLAUDISH_DIR =
|
|
41456
|
-
BUFFER_FILE =
|
|
41603
|
+
CLAUDISH_DIR = join17(homedir16(), ".claudish");
|
|
41604
|
+
BUFFER_FILE = join17(CLAUDISH_DIR, "stats-buffer.json");
|
|
41457
41605
|
lastFlushTime = Date.now();
|
|
41458
41606
|
process.on("exit", syncFlushOnExit);
|
|
41459
41607
|
process.on("SIGTERM", () => {
|
|
@@ -41938,11 +42086,11 @@ import { EventEmitter } from "events";
|
|
|
41938
42086
|
import { Buffer as Buffer2 } from "buffer";
|
|
41939
42087
|
import { Buffer as Buffer3 } from "buffer";
|
|
41940
42088
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
41941
|
-
import { resolve as
|
|
42089
|
+
import { resolve as resolve3, dirname as dirname5 } from "path";
|
|
41942
42090
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
41943
42091
|
import { resolve as resolve22, isAbsolute, parse as parse6 } from "path";
|
|
41944
|
-
import { existsSync as
|
|
41945
|
-
import { basename, join as
|
|
42092
|
+
import { existsSync as existsSync18 } from "fs";
|
|
42093
|
+
import { basename, join as join18 } from "path";
|
|
41946
42094
|
import os from "os";
|
|
41947
42095
|
import path from "path";
|
|
41948
42096
|
import { EventEmitter as EventEmitter3 } from "events";
|
|
@@ -44188,13 +44336,13 @@ class DebounceController {
|
|
|
44188
44336
|
}
|
|
44189
44337
|
debounce(id, ms, fn) {
|
|
44190
44338
|
const scopeMap = TIMERS_MAP.get(this.scopeId);
|
|
44191
|
-
return new Promise((
|
|
44339
|
+
return new Promise((resolve4, reject) => {
|
|
44192
44340
|
if (scopeMap.has(id)) {
|
|
44193
44341
|
clearTimeout(scopeMap.get(id));
|
|
44194
44342
|
}
|
|
44195
44343
|
const timerId = setTimeout(() => {
|
|
44196
44344
|
try {
|
|
44197
|
-
|
|
44345
|
+
resolve4(fn());
|
|
44198
44346
|
} catch (error46) {
|
|
44199
44347
|
reject(error46);
|
|
44200
44348
|
}
|
|
@@ -44283,24 +44431,24 @@ function getParsers() {
|
|
|
44283
44431
|
{
|
|
44284
44432
|
filetype: "javascript",
|
|
44285
44433
|
queries: {
|
|
44286
|
-
highlights: [
|
|
44434
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default)]
|
|
44287
44435
|
},
|
|
44288
|
-
wasm:
|
|
44436
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_javascript_default)
|
|
44289
44437
|
},
|
|
44290
44438
|
{
|
|
44291
44439
|
filetype: "typescript",
|
|
44292
44440
|
queries: {
|
|
44293
|
-
highlights: [
|
|
44441
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default2)]
|
|
44294
44442
|
},
|
|
44295
|
-
wasm:
|
|
44443
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_typescript_default)
|
|
44296
44444
|
},
|
|
44297
44445
|
{
|
|
44298
44446
|
filetype: "markdown",
|
|
44299
44447
|
queries: {
|
|
44300
|
-
highlights: [
|
|
44301
|
-
injections: [
|
|
44448
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default3)],
|
|
44449
|
+
injections: [resolve3(dirname5(fileURLToPath5(import.meta.url)), injections_default)]
|
|
44302
44450
|
},
|
|
44303
|
-
wasm:
|
|
44451
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_default),
|
|
44304
44452
|
injectionMapping: {
|
|
44305
44453
|
nodeTypes: {
|
|
44306
44454
|
inline: "markdown_inline",
|
|
@@ -44319,16 +44467,16 @@ function getParsers() {
|
|
|
44319
44467
|
{
|
|
44320
44468
|
filetype: "markdown_inline",
|
|
44321
44469
|
queries: {
|
|
44322
|
-
highlights: [
|
|
44470
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default4)]
|
|
44323
44471
|
},
|
|
44324
|
-
wasm:
|
|
44472
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_markdown_inline_default)
|
|
44325
44473
|
},
|
|
44326
44474
|
{
|
|
44327
44475
|
filetype: "zig",
|
|
44328
44476
|
queries: {
|
|
44329
|
-
highlights: [
|
|
44477
|
+
highlights: [resolve3(dirname5(fileURLToPath5(import.meta.url)), highlights_default5)]
|
|
44330
44478
|
},
|
|
44331
|
-
wasm:
|
|
44479
|
+
wasm: resolve3(dirname5(fileURLToPath5(import.meta.url)), tree_sitter_zig_default)
|
|
44332
44480
|
}
|
|
44333
44481
|
];
|
|
44334
44482
|
}
|
|
@@ -44341,7 +44489,7 @@ function getBunfsRootPath() {
|
|
|
44341
44489
|
return process.platform === "win32" ? "B:\\~BUN\\root" : "/$bunfs/root";
|
|
44342
44490
|
}
|
|
44343
44491
|
function normalizeBunfsPath(fileName) {
|
|
44344
|
-
return
|
|
44492
|
+
return join18(getBunfsRootPath(), basename(fileName));
|
|
44345
44493
|
}
|
|
44346
44494
|
function isValidDirectoryName(name) {
|
|
44347
44495
|
if (!name || typeof name !== "string") {
|
|
@@ -54537,7 +54685,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54537
54685
|
worker_path = this.options.workerPath;
|
|
54538
54686
|
} else {
|
|
54539
54687
|
worker_path = new URL("./parser.worker.js", import.meta.url).href;
|
|
54540
|
-
if (!
|
|
54688
|
+
if (!existsSync18(resolve22(import.meta.dirname, "parser.worker.js"))) {
|
|
54541
54689
|
worker_path = new URL("./parser.worker.ts", import.meta.url).href;
|
|
54542
54690
|
}
|
|
54543
54691
|
}
|
|
@@ -54572,7 +54720,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54572
54720
|
if (this.initializePromise) {
|
|
54573
54721
|
return this.initializePromise;
|
|
54574
54722
|
}
|
|
54575
|
-
this.initializePromise = new Promise((
|
|
54723
|
+
this.initializePromise = new Promise((resolve32, reject) => {
|
|
54576
54724
|
const timeoutMs = this.options.initTimeout ?? 1e4;
|
|
54577
54725
|
const timeoutId = setTimeout(() => {
|
|
54578
54726
|
const error46 = new Error("Worker initialization timed out");
|
|
@@ -54580,7 +54728,7 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54580
54728
|
this.initializeResolvers = undefined;
|
|
54581
54729
|
reject(error46);
|
|
54582
54730
|
}, timeoutMs);
|
|
54583
|
-
this.initializeResolvers = { resolve:
|
|
54731
|
+
this.initializeResolvers = { resolve: resolve32, reject, timeoutId };
|
|
54584
54732
|
this.worker?.postMessage({
|
|
54585
54733
|
type: "INIT",
|
|
54586
54734
|
dataPath: this.options.dataPath
|
|
@@ -54620,8 +54768,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54620
54768
|
}
|
|
54621
54769
|
async getPerformance() {
|
|
54622
54770
|
const messageId = `performance_${this.messageIdCounter++}`;
|
|
54623
|
-
return new Promise((
|
|
54624
|
-
this.messageCallbacks.set(messageId,
|
|
54771
|
+
return new Promise((resolve32) => {
|
|
54772
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54625
54773
|
this.worker?.postMessage({ type: "GET_PERFORMANCE", messageId });
|
|
54626
54774
|
});
|
|
54627
54775
|
}
|
|
@@ -54634,8 +54782,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54634
54782
|
}
|
|
54635
54783
|
}
|
|
54636
54784
|
const messageId = `oneshot_${this.messageIdCounter++}`;
|
|
54637
|
-
return new Promise((
|
|
54638
|
-
this.messageCallbacks.set(messageId,
|
|
54785
|
+
return new Promise((resolve32) => {
|
|
54786
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54639
54787
|
this.worker?.postMessage({
|
|
54640
54788
|
type: "ONESHOT_HIGHLIGHT",
|
|
54641
54789
|
content,
|
|
@@ -54751,8 +54899,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54751
54899
|
}
|
|
54752
54900
|
async preloadParser(filetype) {
|
|
54753
54901
|
const messageId = `has_parser_${this.messageIdCounter++}`;
|
|
54754
|
-
const response = await new Promise((
|
|
54755
|
-
this.messageCallbacks.set(messageId,
|
|
54902
|
+
const response = await new Promise((resolve32) => {
|
|
54903
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54756
54904
|
this.worker?.postMessage({
|
|
54757
54905
|
type: "PRELOAD_PARSER",
|
|
54758
54906
|
filetype,
|
|
@@ -54779,8 +54927,8 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54779
54927
|
}
|
|
54780
54928
|
this.buffers.set(id, { id, content, filetype, version: version2, hasParser: false });
|
|
54781
54929
|
const messageId = `init_${this.messageIdCounter++}`;
|
|
54782
|
-
const response = await new Promise((
|
|
54783
|
-
this.messageCallbacks.set(messageId,
|
|
54930
|
+
const response = await new Promise((resolve32) => {
|
|
54931
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54784
54932
|
this.worker?.postMessage({
|
|
54785
54933
|
type: "INITIALIZE_PARSER",
|
|
54786
54934
|
bufferId: id,
|
|
@@ -54836,9 +54984,9 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54836
54984
|
this.editQueues.delete(bufferId);
|
|
54837
54985
|
}
|
|
54838
54986
|
if (this.worker) {
|
|
54839
|
-
await new Promise((
|
|
54987
|
+
await new Promise((resolve32) => {
|
|
54840
54988
|
const messageId = `dispose_${bufferId}`;
|
|
54841
|
-
this.messageCallbacks.set(messageId,
|
|
54989
|
+
this.messageCallbacks.set(messageId, resolve32);
|
|
54842
54990
|
try {
|
|
54843
54991
|
this.worker.postMessage({
|
|
54844
54992
|
type: "DISPOSE_BUFFER",
|
|
@@ -54846,13 +54994,13 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54846
54994
|
});
|
|
54847
54995
|
} catch (error46) {
|
|
54848
54996
|
console.error("Error disposing buffer", error46);
|
|
54849
|
-
|
|
54997
|
+
resolve32(false);
|
|
54850
54998
|
}
|
|
54851
54999
|
setTimeout(() => {
|
|
54852
55000
|
if (this.messageCallbacks.has(messageId)) {
|
|
54853
55001
|
this.messageCallbacks.delete(messageId);
|
|
54854
55002
|
console.warn({ bufferId }, "Timed out waiting for buffer to be disposed");
|
|
54855
|
-
|
|
55003
|
+
resolve32(false);
|
|
54856
55004
|
}
|
|
54857
55005
|
}, 3000);
|
|
54858
55006
|
});
|
|
@@ -54909,12 +55057,12 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54909
55057
|
this.options.dataPath = dataPath;
|
|
54910
55058
|
if (this.initialized && this.worker) {
|
|
54911
55059
|
const messageId = `update_datapath_${this.messageIdCounter++}`;
|
|
54912
|
-
return new Promise((
|
|
55060
|
+
return new Promise((resolve32, reject) => {
|
|
54913
55061
|
this.messageCallbacks.set(messageId, (response) => {
|
|
54914
55062
|
if (response.error) {
|
|
54915
55063
|
reject(new Error(response.error));
|
|
54916
55064
|
} else {
|
|
54917
|
-
|
|
55065
|
+
resolve32();
|
|
54918
55066
|
}
|
|
54919
55067
|
});
|
|
54920
55068
|
this.worker.postMessage({
|
|
@@ -54930,12 +55078,12 @@ var init_index_0wbvecnk = __esm(async () => {
|
|
|
54930
55078
|
throw new Error("Cannot clear cache: client is not initialized");
|
|
54931
55079
|
}
|
|
54932
55080
|
const messageId = `clear_cache_${this.messageIdCounter++}`;
|
|
54933
|
-
return new Promise((
|
|
55081
|
+
return new Promise((resolve32, reject) => {
|
|
54934
55082
|
this.messageCallbacks.set(messageId, (response) => {
|
|
54935
55083
|
if (response.error) {
|
|
54936
55084
|
reject(new Error(response.error));
|
|
54937
55085
|
} else {
|
|
54938
|
-
|
|
55086
|
+
resolve32();
|
|
54939
55087
|
}
|
|
54940
55088
|
});
|
|
54941
55089
|
this.worker.postMessage({
|
|
@@ -69964,14 +70112,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
69964
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. ");
|
|
69965
70113
|
actScopeDepth = prevActScopeDepth;
|
|
69966
70114
|
}
|
|
69967
|
-
function recursivelyFlushAsyncActWork(returnValue,
|
|
70115
|
+
function recursivelyFlushAsyncActWork(returnValue, resolve4, reject) {
|
|
69968
70116
|
var queue = ReactSharedInternals.actQueue;
|
|
69969
70117
|
if (queue !== null)
|
|
69970
70118
|
if (queue.length !== 0)
|
|
69971
70119
|
try {
|
|
69972
70120
|
flushActQueue(queue);
|
|
69973
70121
|
enqueueTask(function() {
|
|
69974
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
70122
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
|
|
69975
70123
|
});
|
|
69976
70124
|
return;
|
|
69977
70125
|
} catch (error46) {
|
|
@@ -69979,7 +70127,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
69979
70127
|
}
|
|
69980
70128
|
else
|
|
69981
70129
|
ReactSharedInternals.actQueue = null;
|
|
69982
|
-
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);
|
|
69983
70131
|
}
|
|
69984
70132
|
function flushActQueue(queue) {
|
|
69985
70133
|
if (!isFlushing) {
|
|
@@ -70155,14 +70303,14 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70155
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 () => ...);"));
|
|
70156
70304
|
});
|
|
70157
70305
|
return {
|
|
70158
|
-
then: function(
|
|
70306
|
+
then: function(resolve4, reject) {
|
|
70159
70307
|
didAwaitActCall = true;
|
|
70160
70308
|
thenable.then(function(returnValue) {
|
|
70161
70309
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
70162
70310
|
if (prevActScopeDepth === 0) {
|
|
70163
70311
|
try {
|
|
70164
70312
|
flushActQueue(queue), enqueueTask(function() {
|
|
70165
|
-
return recursivelyFlushAsyncActWork(returnValue,
|
|
70313
|
+
return recursivelyFlushAsyncActWork(returnValue, resolve4, reject);
|
|
70166
70314
|
});
|
|
70167
70315
|
} catch (error$0) {
|
|
70168
70316
|
ReactSharedInternals.thrownErrors.push(error$0);
|
|
@@ -70173,7 +70321,7 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70173
70321
|
reject(_thrownError);
|
|
70174
70322
|
}
|
|
70175
70323
|
} else
|
|
70176
|
-
|
|
70324
|
+
resolve4(returnValue);
|
|
70177
70325
|
}, function(error46) {
|
|
70178
70326
|
popActScope(prevActQueue, prevActScopeDepth);
|
|
70179
70327
|
0 < ReactSharedInternals.thrownErrors.length ? (error46 = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error46)) : reject(error46);
|
|
@@ -70189,11 +70337,11 @@ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix
|
|
|
70189
70337
|
if (0 < ReactSharedInternals.thrownErrors.length)
|
|
70190
70338
|
throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
|
|
70191
70339
|
return {
|
|
70192
|
-
then: function(
|
|
70340
|
+
then: function(resolve4, reject) {
|
|
70193
70341
|
didAwaitActCall = true;
|
|
70194
70342
|
prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
|
|
70195
|
-
return recursivelyFlushAsyncActWork(returnValue$jscomp$0,
|
|
70196
|
-
})) :
|
|
70343
|
+
return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve4, reject);
|
|
70344
|
+
})) : resolve4(returnValue$jscomp$0);
|
|
70197
70345
|
}
|
|
70198
70346
|
};
|
|
70199
70347
|
};
|
|
@@ -72674,8 +72822,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
72674
72822
|
currentEntangledActionThenable = {
|
|
72675
72823
|
status: "pending",
|
|
72676
72824
|
value: undefined,
|
|
72677
|
-
then: function(
|
|
72678
|
-
entangledListeners.push(
|
|
72825
|
+
then: function(resolve4) {
|
|
72826
|
+
entangledListeners.push(resolve4);
|
|
72679
72827
|
}
|
|
72680
72828
|
};
|
|
72681
72829
|
}
|
|
@@ -72699,8 +72847,8 @@ It can also happen if the client has a browser extension installed which messes
|
|
|
72699
72847
|
status: "pending",
|
|
72700
72848
|
value: null,
|
|
72701
72849
|
reason: null,
|
|
72702
|
-
then: function(
|
|
72703
|
-
listeners.push(
|
|
72850
|
+
then: function(resolve4) {
|
|
72851
|
+
listeners.push(resolve4);
|
|
72704
72852
|
}
|
|
72705
72853
|
};
|
|
72706
72854
|
thenable.then(function() {
|
|
@@ -97800,7 +97948,7 @@ var init_react = __esm(async () => {
|
|
|
97800
97948
|
});
|
|
97801
97949
|
|
|
97802
97950
|
// src/tui/providers.ts
|
|
97803
|
-
function
|
|
97951
|
+
function maskKey2(key) {
|
|
97804
97952
|
if (!key)
|
|
97805
97953
|
return "\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500";
|
|
97806
97954
|
if (key.length < 8)
|
|
@@ -98033,7 +98181,7 @@ function ApiKeysPanel({ focused, height: height2, width, onEditingChange }) {
|
|
|
98033
98181
|
const hasEnvK = !!process.env[p.apiKeyEnvVar];
|
|
98034
98182
|
const hasCfgK = !!config3.apiKeys?.[p.apiKeyEnvVar];
|
|
98035
98183
|
const icon = hasEnvK || hasCfgK ? "\u2713" : "\u2717";
|
|
98036
|
-
const kStr = p.apiKeyEnvVar ? pad(
|
|
98184
|
+
const kStr = p.apiKeyEnvVar ? pad(maskKey2(hasCfgK ? config3.apiKeys[p.apiKeyEnvVar] : process.env[p.apiKeyEnvVar]), 8) : " ";
|
|
98037
98185
|
const kSrc = hasEnvK && hasCfgK ? "e+c" : hasEnvK ? "env" : hasCfgK ? "cfg" : "---";
|
|
98038
98186
|
let eSrc = " ";
|
|
98039
98187
|
if (p.endpointEnvVar) {
|
|
@@ -98046,8 +98194,8 @@ function ApiKeysPanel({ focused, height: height2, width, onEditingChange }) {
|
|
|
98046
98194
|
value: p.name
|
|
98047
98195
|
};
|
|
98048
98196
|
});
|
|
98049
|
-
const envKeyMask =
|
|
98050
|
-
const cfgKeyMask =
|
|
98197
|
+
const envKeyMask = maskKey2(process.env[selectedProvider.apiKeyEnvVar]);
|
|
98198
|
+
const cfgKeyMask = maskKey2(config3.apiKeys?.[selectedProvider.apiKeyEnvVar]);
|
|
98051
98199
|
const activeUrl = config3.endpoints?.[selectedProvider.endpointEnvVar] || process.env[selectedProvider.endpointEnvVar] || selectedProvider.defaultEndpoint || "None";
|
|
98052
98200
|
const divider = "\u2500".repeat(Math.max(1, width - 2));
|
|
98053
98201
|
return /* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("box", {
|
|
@@ -98332,7 +98480,7 @@ function ConfigViewPanel({ focused, height: height2 }) {
|
|
|
98332
98480
|
fg: C2.green,
|
|
98333
98481
|
children: [
|
|
98334
98482
|
" ",
|
|
98335
|
-
|
|
98483
|
+
maskKey2(itm?.kVal)
|
|
98336
98484
|
]
|
|
98337
98485
|
}, undefined, true, undefined, this),
|
|
98338
98486
|
/* @__PURE__ */ import_jsx_dev_runtime2.jsxDEV("span", {
|
|
@@ -99254,8 +99402,8 @@ var exports_team_cli = {};
|
|
|
99254
99402
|
__export(exports_team_cli, {
|
|
99255
99403
|
teamCommand: () => teamCommand
|
|
99256
99404
|
});
|
|
99257
|
-
import { readFileSync as
|
|
99258
|
-
import { join as
|
|
99405
|
+
import { readFileSync as readFileSync16 } from "fs";
|
|
99406
|
+
import { join as join19 } from "path";
|
|
99259
99407
|
function getFlag(args, flag) {
|
|
99260
99408
|
const idx = args.indexOf(flag);
|
|
99261
99409
|
if (idx === -1 || idx + 1 >= args.length)
|
|
@@ -99347,7 +99495,7 @@ async function teamCommand(args) {
|
|
|
99347
99495
|
}
|
|
99348
99496
|
case "judge": {
|
|
99349
99497
|
const verdict = await judgeResponses(sessionPath, { judges });
|
|
99350
|
-
console.log(
|
|
99498
|
+
console.log(readFileSync16(join19(sessionPath, "verdict.md"), "utf-8"));
|
|
99351
99499
|
break;
|
|
99352
99500
|
}
|
|
99353
99501
|
case "run-and-judge": {
|
|
@@ -99365,7 +99513,7 @@ async function teamCommand(args) {
|
|
|
99365
99513
|
});
|
|
99366
99514
|
printStatus(status);
|
|
99367
99515
|
await judgeResponses(sessionPath, { judges });
|
|
99368
|
-
console.log(
|
|
99516
|
+
console.log(readFileSync16(join19(sessionPath, "verdict.md"), "utf-8"));
|
|
99369
99517
|
break;
|
|
99370
99518
|
}
|
|
99371
99519
|
case "status": {
|
|
@@ -99391,9 +99539,9 @@ __export(exports_claude_runner, {
|
|
|
99391
99539
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
99392
99540
|
});
|
|
99393
99541
|
import { spawn as spawn2 } from "child_process";
|
|
99394
|
-
import { writeFileSync as writeFileSync11, unlinkSync as unlinkSync7, mkdirSync as mkdirSync10, existsSync as
|
|
99395
|
-
import { tmpdir as tmpdir2, homedir as
|
|
99396
|
-
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";
|
|
99397
99545
|
function hasNativeAnthropicMapping(config3) {
|
|
99398
99546
|
const models = [config3.model, config3.modelOpus, config3.modelSonnet, config3.modelHaiku, config3.modelSubagent];
|
|
99399
99547
|
return models.some((m2) => m2 && parseModelSpec(m2).provider === "native-anthropic");
|
|
@@ -99403,9 +99551,9 @@ function isWindows2() {
|
|
|
99403
99551
|
}
|
|
99404
99552
|
function createStatusLineScript(tokenFilePath) {
|
|
99405
99553
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
99406
|
-
const claudishDir =
|
|
99554
|
+
const claudishDir = join20(homeDir, ".claudish");
|
|
99407
99555
|
const timestamp = Date.now();
|
|
99408
|
-
const scriptPath =
|
|
99556
|
+
const scriptPath = join20(claudishDir, `status-${timestamp}.js`);
|
|
99409
99557
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
99410
99558
|
const script = `
|
|
99411
99559
|
const fs = require('fs');
|
|
@@ -99490,13 +99638,13 @@ process.stdin.on('end', () => {
|
|
|
99490
99638
|
}
|
|
99491
99639
|
function createTempSettingsFile(modelDisplay, port) {
|
|
99492
99640
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
99493
|
-
const claudishDir =
|
|
99641
|
+
const claudishDir = join20(homeDir, ".claudish");
|
|
99494
99642
|
try {
|
|
99495
99643
|
mkdirSync10(claudishDir, { recursive: true });
|
|
99496
99644
|
} catch {}
|
|
99497
99645
|
const timestamp = Date.now();
|
|
99498
|
-
const tempPath =
|
|
99499
|
-
const tokenFilePath =
|
|
99646
|
+
const tempPath = join20(claudishDir, `settings-${timestamp}.json`);
|
|
99647
|
+
const tokenFilePath = join20(claudishDir, `tokens-${port}.json`);
|
|
99500
99648
|
let statusCommand;
|
|
99501
99649
|
if (isWindows2()) {
|
|
99502
99650
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -99532,7 +99680,7 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
99532
99680
|
if (userSettingsValue.trimStart().startsWith("{")) {
|
|
99533
99681
|
userSettings = JSON.parse(userSettingsValue);
|
|
99534
99682
|
} else {
|
|
99535
|
-
const rawUserSettings =
|
|
99683
|
+
const rawUserSettings = readFileSync17(userSettingsValue, "utf-8");
|
|
99536
99684
|
userSettings = JSON.parse(rawUserSettings);
|
|
99537
99685
|
}
|
|
99538
99686
|
userSettings.statusLine = statusLine;
|
|
@@ -99624,8 +99772,8 @@ async function runClaudeWithProxy(config3, proxyUrl, onCleanup) {
|
|
|
99624
99772
|
console.error("Install it from: https://claude.com/claude-code");
|
|
99625
99773
|
console.error(`
|
|
99626
99774
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
99627
|
-
const home =
|
|
99628
|
-
const localPath = isWindows2() ?
|
|
99775
|
+
const home = homedir17();
|
|
99776
|
+
const localPath = isWindows2() ? join20(home, ".claude", "local", "claude.exe") : join20(home, ".claude", "local", "claude");
|
|
99629
99777
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
99630
99778
|
process.exit(1);
|
|
99631
99779
|
}
|
|
@@ -99637,9 +99785,9 @@ Or set CLAUDE_PATH to your custom installation:`);
|
|
|
99637
99785
|
shell: needsShell
|
|
99638
99786
|
});
|
|
99639
99787
|
setupSignalHandlers(proc, tempSettingsPath, config3.quiet, onCleanup);
|
|
99640
|
-
const exitCode = await new Promise((
|
|
99788
|
+
const exitCode = await new Promise((resolve4) => {
|
|
99641
99789
|
proc.on("exit", (code) => {
|
|
99642
|
-
|
|
99790
|
+
resolve4(code ?? 1);
|
|
99643
99791
|
});
|
|
99644
99792
|
});
|
|
99645
99793
|
try {
|
|
@@ -99671,23 +99819,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet, onCleanup) {
|
|
|
99671
99819
|
async function findClaudeBinary() {
|
|
99672
99820
|
const isWindows3 = process.platform === "win32";
|
|
99673
99821
|
if (process.env.CLAUDE_PATH) {
|
|
99674
|
-
if (
|
|
99822
|
+
if (existsSync19(process.env.CLAUDE_PATH)) {
|
|
99675
99823
|
return process.env.CLAUDE_PATH;
|
|
99676
99824
|
}
|
|
99677
99825
|
}
|
|
99678
|
-
const home =
|
|
99679
|
-
const localPath = isWindows3 ?
|
|
99680
|
-
if (
|
|
99826
|
+
const home = homedir17();
|
|
99827
|
+
const localPath = isWindows3 ? join20(home, ".claude", "local", "claude.exe") : join20(home, ".claude", "local", "claude");
|
|
99828
|
+
if (existsSync19(localPath)) {
|
|
99681
99829
|
return localPath;
|
|
99682
99830
|
}
|
|
99683
99831
|
if (isWindows3) {
|
|
99684
99832
|
const windowsPaths = [
|
|
99685
|
-
|
|
99686
|
-
|
|
99687
|
-
|
|
99833
|
+
join20(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
99834
|
+
join20(home, ".npm-global", "claude.cmd"),
|
|
99835
|
+
join20(home, "node_modules", ".bin", "claude.cmd")
|
|
99688
99836
|
];
|
|
99689
99837
|
for (const path2 of windowsPaths) {
|
|
99690
|
-
if (
|
|
99838
|
+
if (existsSync19(path2)) {
|
|
99691
99839
|
return path2;
|
|
99692
99840
|
}
|
|
99693
99841
|
}
|
|
@@ -99695,14 +99843,14 @@ async function findClaudeBinary() {
|
|
|
99695
99843
|
const commonPaths = [
|
|
99696
99844
|
"/usr/local/bin/claude",
|
|
99697
99845
|
"/opt/homebrew/bin/claude",
|
|
99698
|
-
|
|
99699
|
-
|
|
99700
|
-
|
|
99846
|
+
join20(home, ".npm-global/bin/claude"),
|
|
99847
|
+
join20(home, ".local/bin/claude"),
|
|
99848
|
+
join20(home, "node_modules/.bin/claude"),
|
|
99701
99849
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
99702
|
-
|
|
99850
|
+
join20(home, "../usr/bin/claude")
|
|
99703
99851
|
];
|
|
99704
99852
|
for (const path2 of commonPaths) {
|
|
99705
|
-
if (
|
|
99853
|
+
if (existsSync19(path2)) {
|
|
99706
99854
|
return path2;
|
|
99707
99855
|
}
|
|
99708
99856
|
}
|
|
@@ -99717,9 +99865,9 @@ async function findClaudeBinary() {
|
|
|
99717
99865
|
proc.stdout?.on("data", (data) => {
|
|
99718
99866
|
output += data.toString();
|
|
99719
99867
|
});
|
|
99720
|
-
const exitCode = await new Promise((
|
|
99868
|
+
const exitCode = await new Promise((resolve4) => {
|
|
99721
99869
|
proc.on("exit", (code) => {
|
|
99722
|
-
|
|
99870
|
+
resolve4(code ?? 1);
|
|
99723
99871
|
});
|
|
99724
99872
|
});
|
|
99725
99873
|
if (exitCode === 0 && output.trim()) {
|
|
@@ -99754,17 +99902,17 @@ __export(exports_diag_output, {
|
|
|
99754
99902
|
});
|
|
99755
99903
|
import { createWriteStream as createWriteStream2, mkdirSync as mkdirSync11, writeFileSync as writeFileSync12, unlinkSync as unlinkSync8 } from "fs";
|
|
99756
99904
|
import { execFileSync } from "child_process";
|
|
99757
|
-
import { homedir as
|
|
99758
|
-
import { join as
|
|
99905
|
+
import { homedir as homedir18 } from "os";
|
|
99906
|
+
import { join as join21 } from "path";
|
|
99759
99907
|
function getClaudishDir() {
|
|
99760
|
-
const dir =
|
|
99908
|
+
const dir = join21(homedir18(), ".claudish");
|
|
99761
99909
|
try {
|
|
99762
99910
|
mkdirSync11(dir, { recursive: true });
|
|
99763
99911
|
} catch {}
|
|
99764
99912
|
return dir;
|
|
99765
99913
|
}
|
|
99766
99914
|
function getDiagLogPath() {
|
|
99767
|
-
return
|
|
99915
|
+
return join21(getClaudishDir(), `diag-${process.pid}.log`);
|
|
99768
99916
|
}
|
|
99769
99917
|
|
|
99770
99918
|
class LogFileDiagOutput {
|
|
@@ -99869,14 +100017,14 @@ async function findAvailablePort(startPort = 3000, endPort = 9000) {
|
|
|
99869
100017
|
throw new Error(`No available ports found in range ${startPort}-${endPort}`);
|
|
99870
100018
|
}
|
|
99871
100019
|
async function isPortAvailable(port) {
|
|
99872
|
-
return new Promise((
|
|
100020
|
+
return new Promise((resolve4) => {
|
|
99873
100021
|
const server = createServer2();
|
|
99874
100022
|
server.once("error", (err) => {
|
|
99875
|
-
|
|
100023
|
+
resolve4(err.code !== "EADDRINUSE");
|
|
99876
100024
|
});
|
|
99877
100025
|
server.once("listening", () => {
|
|
99878
100026
|
server.close();
|
|
99879
|
-
|
|
100027
|
+
resolve4(true);
|
|
99880
100028
|
});
|
|
99881
100029
|
server.listen(port, "127.0.0.1");
|
|
99882
100030
|
});
|
|
@@ -101796,7 +101944,7 @@ var RequestError, toRequestError = (e) => {
|
|
|
101796
101944
|
});
|
|
101797
101945
|
if (!chunk) {
|
|
101798
101946
|
if (i === 1) {
|
|
101799
|
-
await new Promise((
|
|
101947
|
+
await new Promise((resolve4) => setTimeout(resolve4));
|
|
101800
101948
|
maxReadCount = 3;
|
|
101801
101949
|
continue;
|
|
101802
101950
|
}
|
|
@@ -102223,10 +102371,10 @@ class OpenRouterRequestQueue {
|
|
|
102223
102371
|
}
|
|
102224
102372
|
throw new Error(`OpenRouter request queue full (${this.queue.length}/${this.maxQueueSize}). The API is rate-limited. Please wait and try again.`);
|
|
102225
102373
|
}
|
|
102226
|
-
return new Promise((
|
|
102374
|
+
return new Promise((resolve4, reject) => {
|
|
102227
102375
|
const queuedRequest = {
|
|
102228
102376
|
fetchFn,
|
|
102229
|
-
resolve:
|
|
102377
|
+
resolve: resolve4,
|
|
102230
102378
|
reject
|
|
102231
102379
|
};
|
|
102232
102380
|
this.queue.push(queuedRequest);
|
|
@@ -102294,7 +102442,7 @@ class OpenRouterRequestQueue {
|
|
|
102294
102442
|
if (getLogLevel() === "debug") {
|
|
102295
102443
|
log(`[OpenRouterQueue] Waiting ${waitMs}ms before next request`);
|
|
102296
102444
|
}
|
|
102297
|
-
await new Promise((
|
|
102445
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitMs));
|
|
102298
102446
|
}
|
|
102299
102447
|
}
|
|
102300
102448
|
calculateDelay() {
|
|
@@ -102636,10 +102784,10 @@ class LocalModelQueue {
|
|
|
102636
102784
|
}
|
|
102637
102785
|
throw new Error(`Local model queue full (${this.queue.length}/${this.maxQueueSize}). GPU is overloaded. Please wait for current requests to complete.`);
|
|
102638
102786
|
}
|
|
102639
|
-
return new Promise((
|
|
102787
|
+
return new Promise((resolve4, reject) => {
|
|
102640
102788
|
const queuedRequest = {
|
|
102641
102789
|
fetchFn,
|
|
102642
|
-
resolve:
|
|
102790
|
+
resolve: resolve4,
|
|
102643
102791
|
reject,
|
|
102644
102792
|
providerId
|
|
102645
102793
|
};
|
|
@@ -102734,7 +102882,7 @@ class LocalModelQueue {
|
|
|
102734
102882
|
return parsed;
|
|
102735
102883
|
}
|
|
102736
102884
|
delay(ms) {
|
|
102737
|
-
return new Promise((
|
|
102885
|
+
return new Promise((resolve4) => setTimeout(resolve4, ms));
|
|
102738
102886
|
}
|
|
102739
102887
|
getStats() {
|
|
102740
102888
|
return {
|
|
@@ -103433,8 +103581,8 @@ var init_middleware = __esm(() => {
|
|
|
103433
103581
|
|
|
103434
103582
|
// src/handlers/shared/token-tracker.ts
|
|
103435
103583
|
import { mkdirSync as mkdirSync12, writeFileSync as writeFileSync13 } from "fs";
|
|
103436
|
-
import { homedir as
|
|
103437
|
-
import { join as
|
|
103584
|
+
import { homedir as homedir19 } from "os";
|
|
103585
|
+
import { join as join22 } from "path";
|
|
103438
103586
|
|
|
103439
103587
|
class TokenTracker {
|
|
103440
103588
|
port;
|
|
@@ -103548,9 +103696,9 @@ class TokenTracker {
|
|
|
103548
103696
|
is_free: isFreeModel,
|
|
103549
103697
|
is_estimated: isEstimate || false
|
|
103550
103698
|
};
|
|
103551
|
-
const claudishDir =
|
|
103699
|
+
const claudishDir = join22(homedir19(), ".claudish");
|
|
103552
103700
|
mkdirSync12(claudishDir, { recursive: true });
|
|
103553
|
-
writeFileSync13(
|
|
103701
|
+
writeFileSync13(join22(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
103554
103702
|
} catch (e) {
|
|
103555
103703
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
103556
103704
|
}
|
|
@@ -104971,9 +105119,9 @@ var init_composed_handler = __esm(() => {
|
|
|
104971
105119
|
});
|
|
104972
105120
|
|
|
104973
105121
|
// src/services/pricing-cache.ts
|
|
104974
|
-
import { readFileSync as
|
|
104975
|
-
import { homedir as
|
|
104976
|
-
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";
|
|
104977
105125
|
function getDynamicPricingSync(provider, modelName) {
|
|
104978
105126
|
if (provider === "openrouter") {
|
|
104979
105127
|
const direct = pricingMap.get(modelName);
|
|
@@ -105038,12 +105186,12 @@ async function warmPricingCache() {
|
|
|
105038
105186
|
}
|
|
105039
105187
|
function loadDiskCache() {
|
|
105040
105188
|
try {
|
|
105041
|
-
if (!
|
|
105189
|
+
if (!existsSync20(CACHE_FILE))
|
|
105042
105190
|
return false;
|
|
105043
105191
|
const stat = statSync2(CACHE_FILE);
|
|
105044
105192
|
const age = Date.now() - stat.mtimeMs;
|
|
105045
105193
|
const isFresh = age < CACHE_TTL_MS;
|
|
105046
|
-
const raw2 =
|
|
105194
|
+
const raw2 = readFileSync18(CACHE_FILE, "utf-8");
|
|
105047
105195
|
const data = JSON.parse(raw2);
|
|
105048
105196
|
for (const [key, pricing] of Object.entries(data)) {
|
|
105049
105197
|
pricingMap.set(key, pricing);
|
|
@@ -105090,8 +105238,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
105090
105238
|
init_model_loader();
|
|
105091
105239
|
init_remote_provider_types();
|
|
105092
105240
|
pricingMap = new Map;
|
|
105093
|
-
CACHE_DIR =
|
|
105094
|
-
CACHE_FILE =
|
|
105241
|
+
CACHE_DIR = join23(homedir20(), ".claudish");
|
|
105242
|
+
CACHE_FILE = join23(CACHE_DIR, "pricing-cache.json");
|
|
105095
105243
|
CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
105096
105244
|
PROVIDER_TO_OR_PREFIX = {
|
|
105097
105245
|
openai: ["openai/"],
|
|
@@ -105253,10 +105401,10 @@ class GeminiRequestQueue {
|
|
|
105253
105401
|
log(`[GeminiQueue] Queue full (${this.queue.length}/${this.maxQueueSize}), rejecting request`);
|
|
105254
105402
|
throw new Error("Gemini request queue full. Please retry later.");
|
|
105255
105403
|
}
|
|
105256
|
-
return new Promise((
|
|
105404
|
+
return new Promise((resolve4, reject) => {
|
|
105257
105405
|
const queuedRequest = {
|
|
105258
105406
|
fetchFn,
|
|
105259
|
-
resolve:
|
|
105407
|
+
resolve: resolve4,
|
|
105260
105408
|
reject
|
|
105261
105409
|
};
|
|
105262
105410
|
this.queue.push(queuedRequest);
|
|
@@ -105312,7 +105460,7 @@ class GeminiRequestQueue {
|
|
|
105312
105460
|
if (timeSinceLastRequest < delayMs) {
|
|
105313
105461
|
const waitMs = delayMs - timeSinceLastRequest;
|
|
105314
105462
|
log(`[GeminiQueue] Waiting ${waitMs}ms before next request`);
|
|
105315
|
-
await new Promise((
|
|
105463
|
+
await new Promise((resolve4) => setTimeout(resolve4, waitMs));
|
|
105316
105464
|
}
|
|
105317
105465
|
}
|
|
105318
105466
|
handleRateLimitResponse(errorText) {
|
|
@@ -105550,12 +105698,12 @@ class AnthropicCompatProvider {
|
|
|
105550
105698
|
}
|
|
105551
105699
|
if (this.provider.name === "kimi-coding" && !this.apiKey) {
|
|
105552
105700
|
try {
|
|
105553
|
-
const { existsSync:
|
|
105554
|
-
const { join:
|
|
105555
|
-
const { homedir:
|
|
105556
|
-
const credPath =
|
|
105557
|
-
if (
|
|
105558
|
-
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"));
|
|
105559
105707
|
if (data.access_token && data.refresh_token) {
|
|
105560
105708
|
const { KimiOAuth: KimiOAuth2 } = await Promise.resolve().then(() => (init_kimi_oauth(), exports_kimi_oauth));
|
|
105561
105709
|
const oauth = KimiOAuth2.getInstance();
|
|
@@ -105864,10 +106012,10 @@ var init_litellm2 = __esm(() => {
|
|
|
105864
106012
|
});
|
|
105865
106013
|
|
|
105866
106014
|
// src/adapters/litellm-adapter.ts
|
|
105867
|
-
import { existsSync as
|
|
106015
|
+
import { existsSync as existsSync21, readFileSync as readFileSync19 } from "fs";
|
|
105868
106016
|
import { createHash as createHash5 } from "crypto";
|
|
105869
|
-
import { homedir as
|
|
105870
|
-
import { join as
|
|
106017
|
+
import { homedir as homedir21 } from "os";
|
|
106018
|
+
import { join as join24 } from "path";
|
|
105871
106019
|
var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
|
|
105872
106020
|
var init_litellm_adapter = __esm(() => {
|
|
105873
106021
|
init_base_adapter();
|
|
@@ -105963,10 +106111,10 @@ var init_litellm_adapter = __esm(() => {
|
|
|
105963
106111
|
checkVisionSupport() {
|
|
105964
106112
|
try {
|
|
105965
106113
|
const hash2 = createHash5("sha256").update(this.baseUrl).digest("hex").substring(0, 16);
|
|
105966
|
-
const cachePath =
|
|
105967
|
-
if (!
|
|
106114
|
+
const cachePath = join24(homedir21(), ".claudish", `litellm-models-${hash2}.json`);
|
|
106115
|
+
if (!existsSync21(cachePath))
|
|
105968
106116
|
return true;
|
|
105969
|
-
const cacheData = JSON.parse(
|
|
106117
|
+
const cacheData = JSON.parse(readFileSync19(cachePath, "utf-8"));
|
|
105970
106118
|
const model = cacheData.models?.find((m2) => m2.name === this.modelId);
|
|
105971
106119
|
if (model && model.supportsVision === false) {
|
|
105972
106120
|
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
|
|
@@ -105983,9 +106131,9 @@ var init_litellm_adapter = __esm(() => {
|
|
|
105983
106131
|
// src/auth/vertex-auth.ts
|
|
105984
106132
|
import { exec as exec4 } from "child_process";
|
|
105985
106133
|
import { promisify as promisify3 } from "util";
|
|
105986
|
-
import { existsSync as
|
|
105987
|
-
import { homedir as
|
|
105988
|
-
import { join as
|
|
106134
|
+
import { existsSync as existsSync23 } from "fs";
|
|
106135
|
+
import { homedir as homedir22 } from "os";
|
|
106136
|
+
import { join as join25 } from "path";
|
|
105989
106137
|
|
|
105990
106138
|
class VertexAuthManager {
|
|
105991
106139
|
cachedToken = null;
|
|
@@ -106039,8 +106187,8 @@ class VertexAuthManager {
|
|
|
106039
106187
|
}
|
|
106040
106188
|
async tryADC() {
|
|
106041
106189
|
try {
|
|
106042
|
-
const adcPath =
|
|
106043
|
-
if (!
|
|
106190
|
+
const adcPath = join25(homedir22(), ".config/gcloud/application_default_credentials.json");
|
|
106191
|
+
if (!existsSync23(adcPath)) {
|
|
106044
106192
|
log("[VertexAuth] ADC credentials file not found");
|
|
106045
106193
|
return null;
|
|
106046
106194
|
}
|
|
@@ -106064,7 +106212,7 @@ class VertexAuthManager {
|
|
|
106064
106212
|
if (!credPath) {
|
|
106065
106213
|
return null;
|
|
106066
106214
|
}
|
|
106067
|
-
if (!
|
|
106215
|
+
if (!existsSync23(credPath)) {
|
|
106068
106216
|
throw new Error(`Service account file not found: ${credPath}
|
|
106069
106217
|
|
|
106070
106218
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -106103,8 +106251,8 @@ function validateVertexOAuthConfig() {
|
|
|
106103
106251
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
106104
106252
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
106105
106253
|
}
|
|
106106
|
-
const adcPath =
|
|
106107
|
-
const hasADC =
|
|
106254
|
+
const adcPath = join25(homedir22(), ".config/gcloud/application_default_credentials.json");
|
|
106255
|
+
const hasADC = existsSync23(adcPath);
|
|
106108
106256
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
106109
106257
|
if (!hasADC && !hasServiceAccount) {
|
|
106110
106258
|
return `No Vertex AI credentials found.
|
|
@@ -106215,6 +106363,11 @@ function createHandlerForProvider(ctx) {
|
|
|
106215
106363
|
if (!profile) {
|
|
106216
106364
|
return null;
|
|
106217
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}`);
|
|
106218
106371
|
return profile.createHandler(ctx);
|
|
106219
106372
|
}
|
|
106220
106373
|
var geminiProfile, geminiCodeAssistProfile, openaiProfile, anthropicCompatProfile, glmProfile, openCodeZenProfile, ollamaCloudProfile, litellmProfile, vertexProfile, PROVIDER_PROFILES;
|
|
@@ -106235,6 +106388,7 @@ var init_provider_profiles = __esm(() => {
|
|
|
106235
106388
|
init_remote_provider_registry();
|
|
106236
106389
|
init_vertex_auth();
|
|
106237
106390
|
init_logger();
|
|
106391
|
+
init_api_key_provenance();
|
|
106238
106392
|
geminiProfile = {
|
|
106239
106393
|
createHandler(ctx) {
|
|
106240
106394
|
const transport = new GeminiApiKeyProvider(ctx.provider, ctx.modelName, ctx.apiKey);
|
|
@@ -106710,7 +106864,7 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
106710
106864
|
port,
|
|
106711
106865
|
url: `http://127.0.0.1:${port}`,
|
|
106712
106866
|
shutdown: async () => {
|
|
106713
|
-
return new Promise((
|
|
106867
|
+
return new Promise((resolve4) => server.close((e) => resolve4()));
|
|
106714
106868
|
}
|
|
106715
106869
|
};
|
|
106716
106870
|
}
|
|
@@ -106739,17 +106893,17 @@ var init_proxy_server = __esm(() => {
|
|
|
106739
106893
|
});
|
|
106740
106894
|
|
|
106741
106895
|
// src/index.ts
|
|
106742
|
-
var
|
|
106743
|
-
import { existsSync as
|
|
106744
|
-
import { homedir as
|
|
106745
|
-
import { join as
|
|
106746
|
-
|
|
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 });
|
|
106747
106901
|
function loadStoredApiKeys() {
|
|
106748
106902
|
try {
|
|
106749
|
-
const configPath =
|
|
106750
|
-
if (!
|
|
106903
|
+
const configPath = join26(homedir23(), ".claudish", "config.json");
|
|
106904
|
+
if (!existsSync25(configPath))
|
|
106751
106905
|
return;
|
|
106752
|
-
const raw2 =
|
|
106906
|
+
const raw2 = readFileSync21(configPath, "utf-8");
|
|
106753
106907
|
const cfg = JSON.parse(raw2);
|
|
106754
106908
|
if (cfg.apiKeys) {
|
|
106755
106909
|
for (const [envVar, value] of Object.entries(cfg.apiKeys)) {
|