claudish 5.5.1 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +364 -157
- package/package.json +1 -1
- package/recommended-models.json +4 -4
package/dist/index.js
CHANGED
|
@@ -27585,7 +27585,9 @@ function getLogLevel() {
|
|
|
27585
27585
|
return logLevel;
|
|
27586
27586
|
}
|
|
27587
27587
|
function truncateContent(content, maxLength = 200) {
|
|
27588
|
-
|
|
27588
|
+
if (content === undefined || content === null)
|
|
27589
|
+
return "[empty]";
|
|
27590
|
+
const str = typeof content === "string" ? content : JSON.stringify(content) ?? "[empty]";
|
|
27589
27591
|
if (str.length <= maxLength) {
|
|
27590
27592
|
return str;
|
|
27591
27593
|
}
|
|
@@ -29648,18 +29650,228 @@ var init_oauth_registry = __esm(() => {
|
|
|
29648
29650
|
};
|
|
29649
29651
|
});
|
|
29650
29652
|
|
|
29651
|
-
// src/providers/
|
|
29652
|
-
|
|
29653
|
+
// src/providers/catalog-resolvers/static-fallback.ts
|
|
29654
|
+
function staticOpenRouterFallback(userInput) {
|
|
29655
|
+
if (userInput.includes("/"))
|
|
29656
|
+
return userInput;
|
|
29657
|
+
const lower = userInput.toLowerCase();
|
|
29658
|
+
for (const [key, vendor] of Object.entries(OPENROUTER_VENDOR_MAP)) {
|
|
29659
|
+
if (lower.startsWith(key)) {
|
|
29660
|
+
return `${vendor}/${userInput}`;
|
|
29661
|
+
}
|
|
29662
|
+
}
|
|
29663
|
+
return null;
|
|
29664
|
+
}
|
|
29665
|
+
var OPENROUTER_VENDOR_MAP;
|
|
29666
|
+
var init_static_fallback = __esm(() => {
|
|
29667
|
+
OPENROUTER_VENDOR_MAP = {
|
|
29668
|
+
google: "google",
|
|
29669
|
+
openai: "openai",
|
|
29670
|
+
kimi: "moonshotai",
|
|
29671
|
+
"kimi-coding": "moonshotai",
|
|
29672
|
+
glm: "z-ai",
|
|
29673
|
+
"glm-coding": "z-ai",
|
|
29674
|
+
zai: "z-ai",
|
|
29675
|
+
minimax: "minimax",
|
|
29676
|
+
ollamacloud: "meta-llama",
|
|
29677
|
+
qwen: "qwen"
|
|
29678
|
+
};
|
|
29679
|
+
});
|
|
29680
|
+
|
|
29681
|
+
// src/providers/catalog-resolvers/openrouter.ts
|
|
29682
|
+
import { readFileSync as readFileSync7, existsSync as existsSync8 } from "node:fs";
|
|
29653
29683
|
import { join as join8 } from "node:path";
|
|
29654
29684
|
import { homedir as homedir7 } from "node:os";
|
|
29685
|
+
|
|
29686
|
+
class OpenRouterCatalogResolver {
|
|
29687
|
+
provider = "openrouter";
|
|
29688
|
+
resolveSync(userInput) {
|
|
29689
|
+
if (userInput.includes("/")) {
|
|
29690
|
+
const models2 = this._getModels();
|
|
29691
|
+
if (models2) {
|
|
29692
|
+
const exactMatch = models2.find((m) => m.id === userInput);
|
|
29693
|
+
return exactMatch ? exactMatch.id : userInput;
|
|
29694
|
+
}
|
|
29695
|
+
return userInput;
|
|
29696
|
+
}
|
|
29697
|
+
const models = this._getModels();
|
|
29698
|
+
if (models) {
|
|
29699
|
+
const suffix = `/${userInput}`;
|
|
29700
|
+
const match = models.find((m) => m.id.endsWith(suffix));
|
|
29701
|
+
if (match)
|
|
29702
|
+
return match.id;
|
|
29703
|
+
const lowerSuffix = `/${userInput.toLowerCase()}`;
|
|
29704
|
+
const ciMatch = models.find((m) => m.id.toLowerCase().endsWith(lowerSuffix));
|
|
29705
|
+
if (ciMatch)
|
|
29706
|
+
return ciMatch.id;
|
|
29707
|
+
}
|
|
29708
|
+
return staticOpenRouterFallback(userInput);
|
|
29709
|
+
}
|
|
29710
|
+
async warmCache() {
|
|
29711
|
+
try {
|
|
29712
|
+
const existing = getCachedOpenRouterModels();
|
|
29713
|
+
if (existing && existing.length > 0) {
|
|
29714
|
+
_memCache = existing;
|
|
29715
|
+
return;
|
|
29716
|
+
}
|
|
29717
|
+
const models = await ensureOpenRouterModelsLoaded();
|
|
29718
|
+
if (models.length > 0) {
|
|
29719
|
+
_memCache = models;
|
|
29720
|
+
}
|
|
29721
|
+
} catch {}
|
|
29722
|
+
}
|
|
29723
|
+
isCacheWarm() {
|
|
29724
|
+
return _memCache !== null && _memCache.length > 0;
|
|
29725
|
+
}
|
|
29726
|
+
_getModels() {
|
|
29727
|
+
if (_memCache)
|
|
29728
|
+
return _memCache;
|
|
29729
|
+
const diskPath = join8(homedir7(), ".claudish", "all-models.json");
|
|
29730
|
+
if (existsSync8(diskPath)) {
|
|
29731
|
+
try {
|
|
29732
|
+
const data = JSON.parse(readFileSync7(diskPath, "utf-8"));
|
|
29733
|
+
if (Array.isArray(data.models) && data.models.length > 0) {
|
|
29734
|
+
_memCache = data.models;
|
|
29735
|
+
return _memCache;
|
|
29736
|
+
}
|
|
29737
|
+
} catch {}
|
|
29738
|
+
}
|
|
29739
|
+
return null;
|
|
29740
|
+
}
|
|
29741
|
+
}
|
|
29742
|
+
var _memCache = null;
|
|
29743
|
+
var init_openrouter = __esm(() => {
|
|
29744
|
+
init_model_loader();
|
|
29745
|
+
init_static_fallback();
|
|
29746
|
+
});
|
|
29747
|
+
|
|
29748
|
+
// src/providers/catalog-resolvers/litellm.ts
|
|
29749
|
+
import { readFileSync as readFileSync8, existsSync as existsSync9 } from "node:fs";
|
|
29750
|
+
import { join as join9 } from "node:path";
|
|
29751
|
+
import { homedir as homedir8 } from "node:os";
|
|
29655
29752
|
import { createHash as createHash3 } from "node:crypto";
|
|
29656
|
-
function
|
|
29753
|
+
function getCachePath() {
|
|
29754
|
+
const baseUrl = process.env.LITELLM_BASE_URL;
|
|
29755
|
+
if (!baseUrl)
|
|
29756
|
+
return null;
|
|
29657
29757
|
const hash2 = createHash3("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
29658
|
-
|
|
29659
|
-
|
|
29758
|
+
return join9(homedir8(), ".claudish", `litellm-models-${hash2}.json`);
|
|
29759
|
+
}
|
|
29760
|
+
|
|
29761
|
+
class LiteLLMCatalogResolver {
|
|
29762
|
+
provider = "litellm";
|
|
29763
|
+
resolveSync(userInput) {
|
|
29764
|
+
const ids = this._getModelIds();
|
|
29765
|
+
if (!ids || ids.length === 0)
|
|
29766
|
+
return null;
|
|
29767
|
+
if (ids.includes(userInput))
|
|
29768
|
+
return userInput;
|
|
29769
|
+
const prefixMatch = ids.find((id) => {
|
|
29770
|
+
if (!id.includes("/"))
|
|
29771
|
+
return false;
|
|
29772
|
+
const afterSlash = id.split("/").pop();
|
|
29773
|
+
return afterSlash === userInput;
|
|
29774
|
+
});
|
|
29775
|
+
if (prefixMatch)
|
|
29776
|
+
return prefixMatch;
|
|
29777
|
+
if (userInput.includes("/")) {
|
|
29778
|
+
const bare = userInput.split("/").pop();
|
|
29779
|
+
if (ids.includes(bare))
|
|
29780
|
+
return bare;
|
|
29781
|
+
}
|
|
29782
|
+
return null;
|
|
29783
|
+
}
|
|
29784
|
+
async warmCache() {
|
|
29785
|
+
const path = getCachePath();
|
|
29786
|
+
if (!path || !existsSync9(path))
|
|
29787
|
+
return;
|
|
29788
|
+
try {
|
|
29789
|
+
const data = JSON.parse(readFileSync8(path, "utf-8"));
|
|
29790
|
+
if (Array.isArray(data.models)) {
|
|
29791
|
+
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
29792
|
+
}
|
|
29793
|
+
} catch {}
|
|
29794
|
+
}
|
|
29795
|
+
isCacheWarm() {
|
|
29796
|
+
return _memCache2 !== null && _memCache2.length > 0;
|
|
29797
|
+
}
|
|
29798
|
+
_getModelIds() {
|
|
29799
|
+
if (_memCache2)
|
|
29800
|
+
return _memCache2;
|
|
29801
|
+
const path = getCachePath();
|
|
29802
|
+
if (!path || !existsSync9(path))
|
|
29803
|
+
return null;
|
|
29804
|
+
try {
|
|
29805
|
+
const data = JSON.parse(readFileSync8(path, "utf-8"));
|
|
29806
|
+
if (Array.isArray(data.models)) {
|
|
29807
|
+
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
29808
|
+
return _memCache2;
|
|
29809
|
+
}
|
|
29810
|
+
} catch {}
|
|
29811
|
+
return null;
|
|
29812
|
+
}
|
|
29813
|
+
}
|
|
29814
|
+
var _memCache2 = null;
|
|
29815
|
+
var init_litellm = () => {};
|
|
29816
|
+
|
|
29817
|
+
// src/providers/model-catalog-resolver.ts
|
|
29818
|
+
function registerResolver(resolver) {
|
|
29819
|
+
RESOLVER_REGISTRY.set(resolver.provider, resolver);
|
|
29820
|
+
}
|
|
29821
|
+
function getResolver(provider) {
|
|
29822
|
+
return RESOLVER_REGISTRY.get(provider) ?? null;
|
|
29823
|
+
}
|
|
29824
|
+
function resolveModelNameSync(userInput, targetProvider) {
|
|
29825
|
+
if (targetProvider !== "openrouter" && userInput.includes("/")) {
|
|
29826
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29827
|
+
}
|
|
29828
|
+
const resolver = getResolver(targetProvider);
|
|
29829
|
+
if (!resolver) {
|
|
29830
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29831
|
+
}
|
|
29832
|
+
const resolved = resolver.resolveSync(userInput);
|
|
29833
|
+
if (!resolved || resolved === userInput) {
|
|
29834
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29835
|
+
}
|
|
29836
|
+
return {
|
|
29837
|
+
resolvedId: resolved,
|
|
29838
|
+
wasResolved: true,
|
|
29839
|
+
sourceLabel: `${targetProvider} catalog`
|
|
29840
|
+
};
|
|
29841
|
+
}
|
|
29842
|
+
function logResolution(userInput, result, quiet = false) {
|
|
29843
|
+
if (result.wasResolved && !quiet) {
|
|
29844
|
+
process.stderr.write(`[Model] Resolved "${userInput}" → "${result.resolvedId}" (${result.sourceLabel})
|
|
29845
|
+
`);
|
|
29846
|
+
}
|
|
29847
|
+
}
|
|
29848
|
+
async function warmAllCatalogs(providers) {
|
|
29849
|
+
const targets = providers ? [...RESOLVER_REGISTRY.entries()].filter(([k]) => providers.includes(k)) : [...RESOLVER_REGISTRY.entries()];
|
|
29850
|
+
await Promise.allSettled(targets.map(([, r]) => r.warmCache()));
|
|
29851
|
+
}
|
|
29852
|
+
var RESOLVER_REGISTRY;
|
|
29853
|
+
var init_model_catalog_resolver = __esm(() => {
|
|
29854
|
+
init_openrouter();
|
|
29855
|
+
init_litellm();
|
|
29856
|
+
RESOLVER_REGISTRY = new Map;
|
|
29857
|
+
[
|
|
29858
|
+
new OpenRouterCatalogResolver,
|
|
29859
|
+
new LiteLLMCatalogResolver
|
|
29860
|
+
].forEach(registerResolver);
|
|
29861
|
+
});
|
|
29862
|
+
|
|
29863
|
+
// src/providers/auto-route.ts
|
|
29864
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9 } from "node:fs";
|
|
29865
|
+
import { join as join10 } from "node:path";
|
|
29866
|
+
import { homedir as homedir9 } from "node:os";
|
|
29867
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
29868
|
+
function readLiteLLMCacheSync(baseUrl) {
|
|
29869
|
+
const hash2 = createHash4("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
29870
|
+
const cachePath = join10(homedir9(), ".claudish", `litellm-models-${hash2}.json`);
|
|
29871
|
+
if (!existsSync10(cachePath))
|
|
29660
29872
|
return null;
|
|
29661
29873
|
try {
|
|
29662
|
-
const data = JSON.parse(
|
|
29874
|
+
const data = JSON.parse(readFileSync9(cachePath, "utf-8"));
|
|
29663
29875
|
if (!Array.isArray(data.models))
|
|
29664
29876
|
return null;
|
|
29665
29877
|
return data.models;
|
|
@@ -29706,16 +29918,6 @@ function checkApiKeyForProvider(nativeProvider, modelName) {
|
|
|
29706
29918
|
}
|
|
29707
29919
|
return null;
|
|
29708
29920
|
}
|
|
29709
|
-
function formatForOpenRouter(modelName, nativeProvider) {
|
|
29710
|
-
if (modelName.includes("/")) {
|
|
29711
|
-
return modelName;
|
|
29712
|
-
}
|
|
29713
|
-
const vendor = OPENROUTER_VENDOR_MAP[nativeProvider];
|
|
29714
|
-
if (vendor) {
|
|
29715
|
-
return `${vendor}/${modelName}`;
|
|
29716
|
-
}
|
|
29717
|
-
return modelName;
|
|
29718
|
-
}
|
|
29719
29921
|
function getAutoRouteHint(modelName, nativeProvider) {
|
|
29720
29922
|
const hint = PROVIDER_HINT_MAP[nativeProvider];
|
|
29721
29923
|
const lines = [
|
|
@@ -29769,7 +29971,8 @@ function autoRoute(modelName, nativeProvider) {
|
|
|
29769
29971
|
return apiKeyResult;
|
|
29770
29972
|
}
|
|
29771
29973
|
if (process.env.OPENROUTER_API_KEY) {
|
|
29772
|
-
const
|
|
29974
|
+
const resolution = resolveModelNameSync(modelName, "openrouter");
|
|
29975
|
+
const orModelId = resolution.resolvedId;
|
|
29773
29976
|
return {
|
|
29774
29977
|
provider: "openrouter",
|
|
29775
29978
|
resolvedModelId: orModelId,
|
|
@@ -29780,9 +29983,10 @@ function autoRoute(modelName, nativeProvider) {
|
|
|
29780
29983
|
}
|
|
29781
29984
|
return null;
|
|
29782
29985
|
}
|
|
29783
|
-
var API_KEY_ENV_VARS,
|
|
29986
|
+
var API_KEY_ENV_VARS, PROVIDER_HINT_MAP;
|
|
29784
29987
|
var init_auto_route = __esm(() => {
|
|
29785
29988
|
init_oauth_registry();
|
|
29989
|
+
init_model_catalog_resolver();
|
|
29786
29990
|
API_KEY_ENV_VARS = {
|
|
29787
29991
|
google: { envVar: "GEMINI_API_KEY" },
|
|
29788
29992
|
"gemini-codeassist": { envVar: "GEMINI_API_KEY" },
|
|
@@ -29800,18 +30004,6 @@ var init_auto_route = __esm(() => {
|
|
|
29800
30004
|
vertex: { envVar: "VERTEX_API_KEY", aliases: ["VERTEX_PROJECT"] },
|
|
29801
30005
|
poe: { envVar: "POE_API_KEY" }
|
|
29802
30006
|
};
|
|
29803
|
-
OPENROUTER_VENDOR_MAP = {
|
|
29804
|
-
google: "google",
|
|
29805
|
-
openai: "openai",
|
|
29806
|
-
kimi: "moonshotai",
|
|
29807
|
-
"kimi-coding": "moonshotai",
|
|
29808
|
-
glm: "z-ai",
|
|
29809
|
-
"glm-coding": "z-ai",
|
|
29810
|
-
zai: "z-ai",
|
|
29811
|
-
minimax: "minimax",
|
|
29812
|
-
ollamacloud: "meta-llama",
|
|
29813
|
-
qwen: "qwen"
|
|
29814
|
-
};
|
|
29815
30007
|
PROVIDER_HINT_MAP = {
|
|
29816
30008
|
"kimi-coding": {
|
|
29817
30009
|
loginFlag: "--kimi-login",
|
|
@@ -29868,9 +30060,9 @@ __export(exports_provider_resolver, {
|
|
|
29868
30060
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
29869
30061
|
getMissingKeyError: () => getMissingKeyError
|
|
29870
30062
|
});
|
|
29871
|
-
import { existsSync as
|
|
29872
|
-
import { join as
|
|
29873
|
-
import { homedir as
|
|
30063
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
30064
|
+
import { join as join11 } from "node:path";
|
|
30065
|
+
import { homedir as homedir10 } from "node:os";
|
|
29874
30066
|
function isApiKeyAvailable(info) {
|
|
29875
30067
|
if (!info.envVar) {
|
|
29876
30068
|
return true;
|
|
@@ -29887,8 +30079,8 @@ function isApiKeyAvailable(info) {
|
|
|
29887
30079
|
}
|
|
29888
30080
|
if (info.oauthFallback) {
|
|
29889
30081
|
try {
|
|
29890
|
-
const credPath =
|
|
29891
|
-
if (
|
|
30082
|
+
const credPath = join11(homedir10(), ".claudish", info.oauthFallback);
|
|
30083
|
+
if (existsSync11(credPath)) {
|
|
29892
30084
|
return true;
|
|
29893
30085
|
}
|
|
29894
30086
|
} catch {}
|
|
@@ -30285,16 +30477,16 @@ __export(exports_cli, {
|
|
|
30285
30477
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
30286
30478
|
getMissingKeyError: () => getMissingKeyError
|
|
30287
30479
|
});
|
|
30288
|
-
import { readFileSync as
|
|
30480
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync5, existsSync as existsSync12, mkdirSync as mkdirSync5, copyFileSync, readdirSync, unlinkSync as unlinkSync3 } from "node:fs";
|
|
30289
30481
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30290
|
-
import { dirname as dirname3, join as
|
|
30291
|
-
import { homedir as
|
|
30482
|
+
import { dirname as dirname3, join as join12 } from "node:path";
|
|
30483
|
+
import { homedir as homedir11 } from "node:os";
|
|
30292
30484
|
function getVersion() {
|
|
30293
30485
|
return VERSION;
|
|
30294
30486
|
}
|
|
30295
30487
|
function clearAllModelCaches() {
|
|
30296
|
-
const cacheDir =
|
|
30297
|
-
if (!
|
|
30488
|
+
const cacheDir = join12(homedir11(), ".claudish");
|
|
30489
|
+
if (!existsSync12(cacheDir))
|
|
30298
30490
|
return;
|
|
30299
30491
|
const cachePatterns = ["all-models.json", "pricing-cache.json"];
|
|
30300
30492
|
let cleared = 0;
|
|
@@ -30302,7 +30494,7 @@ function clearAllModelCaches() {
|
|
|
30302
30494
|
const files = readdirSync(cacheDir);
|
|
30303
30495
|
for (const file2 of files) {
|
|
30304
30496
|
if (cachePatterns.includes(file2) || file2.startsWith("litellm-models-")) {
|
|
30305
|
-
unlinkSync3(
|
|
30497
|
+
unlinkSync3(join12(cacheDir, file2));
|
|
30306
30498
|
cleared++;
|
|
30307
30499
|
}
|
|
30308
30500
|
}
|
|
@@ -30578,9 +30770,9 @@ async function fetchOllamaModels() {
|
|
|
30578
30770
|
}
|
|
30579
30771
|
async function searchAndPrintModels(query, forceUpdate) {
|
|
30580
30772
|
let models = [];
|
|
30581
|
-
if (!forceUpdate &&
|
|
30773
|
+
if (!forceUpdate && existsSync12(ALL_MODELS_JSON_PATH)) {
|
|
30582
30774
|
try {
|
|
30583
|
-
const cacheData = JSON.parse(
|
|
30775
|
+
const cacheData = JSON.parse(readFileSync10(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
30584
30776
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
30585
30777
|
const now = new Date;
|
|
30586
30778
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -30748,9 +30940,9 @@ Found ${results.length} matching models:
|
|
|
30748
30940
|
async function printAllModels(jsonOutput, forceUpdate) {
|
|
30749
30941
|
let models = [];
|
|
30750
30942
|
const [ollamaModels, zenModels] = await Promise.all([fetchOllamaModels(), fetchZenModels()]);
|
|
30751
|
-
if (!forceUpdate &&
|
|
30943
|
+
if (!forceUpdate && existsSync12(ALL_MODELS_JSON_PATH)) {
|
|
30752
30944
|
try {
|
|
30753
|
-
const cacheData = JSON.parse(
|
|
30945
|
+
const cacheData = JSON.parse(readFileSync10(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
30754
30946
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
30755
30947
|
const now = new Date;
|
|
30756
30948
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -30951,11 +31143,11 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
30951
31143
|
console.log("Top models: claudish --top-models");
|
|
30952
31144
|
}
|
|
30953
31145
|
function isCacheStale() {
|
|
30954
|
-
if (!
|
|
31146
|
+
if (!existsSync12(MODELS_JSON_PATH)) {
|
|
30955
31147
|
return true;
|
|
30956
31148
|
}
|
|
30957
31149
|
try {
|
|
30958
|
-
const jsonContent =
|
|
31150
|
+
const jsonContent = readFileSync10(MODELS_JSON_PATH, "utf-8");
|
|
30959
31151
|
const data = JSON.parse(jsonContent);
|
|
30960
31152
|
if (!data.lastUpdated) {
|
|
30961
31153
|
return true;
|
|
@@ -31050,9 +31242,9 @@ async function updateModelsFromOpenRouter() {
|
|
|
31050
31242
|
providers.add(provider);
|
|
31051
31243
|
}
|
|
31052
31244
|
let version2 = "1.1.5";
|
|
31053
|
-
if (
|
|
31245
|
+
if (existsSync12(MODELS_JSON_PATH)) {
|
|
31054
31246
|
try {
|
|
31055
|
-
const existing = JSON.parse(
|
|
31247
|
+
const existing = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31056
31248
|
version2 = existing.version || version2;
|
|
31057
31249
|
} catch {}
|
|
31058
31250
|
}
|
|
@@ -31080,7 +31272,7 @@ async function checkAndUpdateModelsCache(forceUpdate = false) {
|
|
|
31080
31272
|
await updateModelsFromOpenRouter();
|
|
31081
31273
|
} else {
|
|
31082
31274
|
try {
|
|
31083
|
-
const data = JSON.parse(
|
|
31275
|
+
const data = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31084
31276
|
console.error(`✓ Using cached models (last updated: ${data.lastUpdated})`);
|
|
31085
31277
|
} catch {}
|
|
31086
31278
|
}
|
|
@@ -31397,8 +31589,8 @@ MORE INFO:
|
|
|
31397
31589
|
}
|
|
31398
31590
|
function printAIAgentGuide() {
|
|
31399
31591
|
try {
|
|
31400
|
-
const guidePath =
|
|
31401
|
-
const guideContent =
|
|
31592
|
+
const guidePath = join12(__dirname4, "../AI_AGENT_GUIDE.md");
|
|
31593
|
+
const guideContent = readFileSync10(guidePath, "utf-8");
|
|
31402
31594
|
console.log(guideContent);
|
|
31403
31595
|
} catch (error46) {
|
|
31404
31596
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -31414,19 +31606,19 @@ async function initializeClaudishSkill() {
|
|
|
31414
31606
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
31415
31607
|
`);
|
|
31416
31608
|
const cwd = process.cwd();
|
|
31417
|
-
const claudeDir =
|
|
31418
|
-
const skillsDir =
|
|
31419
|
-
const claudishSkillDir =
|
|
31420
|
-
const skillFile =
|
|
31421
|
-
if (
|
|
31609
|
+
const claudeDir = join12(cwd, ".claude");
|
|
31610
|
+
const skillsDir = join12(claudeDir, "skills");
|
|
31611
|
+
const claudishSkillDir = join12(skillsDir, "claudish-usage");
|
|
31612
|
+
const skillFile = join12(claudishSkillDir, "SKILL.md");
|
|
31613
|
+
if (existsSync12(skillFile)) {
|
|
31422
31614
|
console.log("✅ Claudish skill already installed at:");
|
|
31423
31615
|
console.log(` ${skillFile}
|
|
31424
31616
|
`);
|
|
31425
31617
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
31426
31618
|
return;
|
|
31427
31619
|
}
|
|
31428
|
-
const sourceSkillPath =
|
|
31429
|
-
if (!
|
|
31620
|
+
const sourceSkillPath = join12(__dirname4, "../skills/claudish-usage/SKILL.md");
|
|
31621
|
+
if (!existsSync12(sourceSkillPath)) {
|
|
31430
31622
|
console.error("❌ Error: Claudish skill file not found in installation.");
|
|
31431
31623
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
31432
31624
|
console.error(`
|
|
@@ -31435,15 +31627,15 @@ async function initializeClaudishSkill() {
|
|
|
31435
31627
|
process.exit(1);
|
|
31436
31628
|
}
|
|
31437
31629
|
try {
|
|
31438
|
-
if (!
|
|
31630
|
+
if (!existsSync12(claudeDir)) {
|
|
31439
31631
|
mkdirSync5(claudeDir, { recursive: true });
|
|
31440
31632
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
31441
31633
|
}
|
|
31442
|
-
if (!
|
|
31634
|
+
if (!existsSync12(skillsDir)) {
|
|
31443
31635
|
mkdirSync5(skillsDir, { recursive: true });
|
|
31444
31636
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
31445
31637
|
}
|
|
31446
|
-
if (!
|
|
31638
|
+
if (!existsSync12(claudishSkillDir)) {
|
|
31447
31639
|
mkdirSync5(claudishSkillDir, { recursive: true });
|
|
31448
31640
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
31449
31641
|
}
|
|
@@ -31486,8 +31678,8 @@ function printAvailableModels() {
|
|
|
31486
31678
|
let lastUpdated = "unknown";
|
|
31487
31679
|
let models = [];
|
|
31488
31680
|
try {
|
|
31489
|
-
if (
|
|
31490
|
-
const data = JSON.parse(
|
|
31681
|
+
if (existsSync12(MODELS_JSON_PATH)) {
|
|
31682
|
+
const data = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31491
31683
|
lastUpdated = data.lastUpdated || "unknown";
|
|
31492
31684
|
models = data.models || [];
|
|
31493
31685
|
}
|
|
@@ -31536,9 +31728,9 @@ Force update: claudish --list-models --force-update
|
|
|
31536
31728
|
`);
|
|
31537
31729
|
}
|
|
31538
31730
|
function printAvailableModelsJSON() {
|
|
31539
|
-
const jsonPath =
|
|
31731
|
+
const jsonPath = join12(__dirname4, "../recommended-models.json");
|
|
31540
31732
|
try {
|
|
31541
|
-
const jsonContent =
|
|
31733
|
+
const jsonContent = readFileSync10(jsonPath, "utf-8");
|
|
31542
31734
|
const data = JSON.parse(jsonContent);
|
|
31543
31735
|
console.log(JSON.stringify(data, null, 2));
|
|
31544
31736
|
} catch (error46) {
|
|
@@ -31623,7 +31815,7 @@ async function fetchGLMCodingModels() {
|
|
|
31623
31815
|
return [];
|
|
31624
31816
|
}
|
|
31625
31817
|
}
|
|
31626
|
-
var __filename4, __dirname4, VERSION = "5.
|
|
31818
|
+
var __filename4, __dirname4, VERSION = "5.6.0", CACHE_MAX_AGE_DAYS2 = 2, MODELS_JSON_PATH, CLAUDISH_CACHE_DIR2, ALL_MODELS_JSON_PATH;
|
|
31627
31819
|
var init_cli = __esm(() => {
|
|
31628
31820
|
init_config();
|
|
31629
31821
|
init_model_loader();
|
|
@@ -31632,12 +31824,12 @@ var init_cli = __esm(() => {
|
|
|
31632
31824
|
__filename4 = fileURLToPath3(import.meta.url);
|
|
31633
31825
|
__dirname4 = dirname3(__filename4);
|
|
31634
31826
|
try {
|
|
31635
|
-
const packageJson = JSON.parse(
|
|
31827
|
+
const packageJson = JSON.parse(readFileSync10(join12(__dirname4, "../package.json"), "utf-8"));
|
|
31636
31828
|
VERSION = packageJson.version;
|
|
31637
31829
|
} catch {}
|
|
31638
|
-
MODELS_JSON_PATH =
|
|
31639
|
-
CLAUDISH_CACHE_DIR2 =
|
|
31640
|
-
ALL_MODELS_JSON_PATH =
|
|
31830
|
+
MODELS_JSON_PATH = join12(__dirname4, "../recommended-models.json");
|
|
31831
|
+
CLAUDISH_CACHE_DIR2 = join12(homedir11(), ".claudish");
|
|
31832
|
+
ALL_MODELS_JSON_PATH = join12(CLAUDISH_CACHE_DIR2, "all-models.json");
|
|
31641
31833
|
});
|
|
31642
31834
|
|
|
31643
31835
|
// src/update-checker.ts
|
|
@@ -31649,9 +31841,9 @@ __export(exports_update_checker, {
|
|
|
31649
31841
|
checkForUpdates: () => checkForUpdates
|
|
31650
31842
|
});
|
|
31651
31843
|
import { execSync } from "node:child_process";
|
|
31652
|
-
import { existsSync as
|
|
31653
|
-
import { homedir as
|
|
31654
|
-
import { join as
|
|
31844
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync11, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
31845
|
+
import { homedir as homedir12, platform as platform2, tmpdir } from "node:os";
|
|
31846
|
+
import { join as join13 } from "node:path";
|
|
31655
31847
|
import { createInterface } from "node:readline";
|
|
31656
31848
|
function getUpdateCommand() {
|
|
31657
31849
|
const scriptPath = process.argv[1] || "";
|
|
@@ -31663,27 +31855,27 @@ function getUpdateCommand() {
|
|
|
31663
31855
|
function getCacheFilePath() {
|
|
31664
31856
|
let cacheDir;
|
|
31665
31857
|
if (isWindows) {
|
|
31666
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
31667
|
-
cacheDir =
|
|
31858
|
+
const localAppData = process.env.LOCALAPPDATA || join13(homedir12(), "AppData", "Local");
|
|
31859
|
+
cacheDir = join13(localAppData, "claudish");
|
|
31668
31860
|
} else {
|
|
31669
|
-
cacheDir =
|
|
31861
|
+
cacheDir = join13(homedir12(), ".cache", "claudish");
|
|
31670
31862
|
}
|
|
31671
31863
|
try {
|
|
31672
|
-
if (!
|
|
31864
|
+
if (!existsSync13(cacheDir)) {
|
|
31673
31865
|
mkdirSync6(cacheDir, { recursive: true });
|
|
31674
31866
|
}
|
|
31675
|
-
return
|
|
31867
|
+
return join13(cacheDir, "update-check.json");
|
|
31676
31868
|
} catch {
|
|
31677
|
-
return
|
|
31869
|
+
return join13(tmpdir(), "claudish-update-check.json");
|
|
31678
31870
|
}
|
|
31679
31871
|
}
|
|
31680
31872
|
function readCache() {
|
|
31681
31873
|
try {
|
|
31682
31874
|
const cachePath = getCacheFilePath();
|
|
31683
|
-
if (!
|
|
31875
|
+
if (!existsSync13(cachePath)) {
|
|
31684
31876
|
return null;
|
|
31685
31877
|
}
|
|
31686
|
-
const data = JSON.parse(
|
|
31878
|
+
const data = JSON.parse(readFileSync11(cachePath, "utf-8"));
|
|
31687
31879
|
return data;
|
|
31688
31880
|
} catch {
|
|
31689
31881
|
return null;
|
|
@@ -31706,7 +31898,7 @@ function isCacheValid(cache) {
|
|
|
31706
31898
|
function clearCache() {
|
|
31707
31899
|
try {
|
|
31708
31900
|
const cachePath = getCacheFilePath();
|
|
31709
|
-
if (
|
|
31901
|
+
if (existsSync13(cachePath)) {
|
|
31710
31902
|
unlinkSync4(cachePath);
|
|
31711
31903
|
}
|
|
31712
31904
|
} catch {}
|
|
@@ -34196,14 +34388,14 @@ __export(exports_model_selector, {
|
|
|
34196
34388
|
promptForApiKey: () => promptForApiKey,
|
|
34197
34389
|
confirmAction: () => confirmAction
|
|
34198
34390
|
});
|
|
34199
|
-
import { readFileSync as
|
|
34200
|
-
import { join as
|
|
34201
|
-
import { homedir as
|
|
34391
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, existsSync as existsSync14, mkdirSync as mkdirSync7 } from "node:fs";
|
|
34392
|
+
import { join as join14, dirname as dirname4 } from "node:path";
|
|
34393
|
+
import { homedir as homedir13 } from "node:os";
|
|
34202
34394
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
34203
34395
|
function loadRecommendedModels2() {
|
|
34204
|
-
if (
|
|
34396
|
+
if (existsSync14(RECOMMENDED_MODELS_JSON_PATH)) {
|
|
34205
34397
|
try {
|
|
34206
|
-
const content =
|
|
34398
|
+
const content = readFileSync12(RECOMMENDED_MODELS_JSON_PATH, "utf-8");
|
|
34207
34399
|
const data = JSON.parse(content);
|
|
34208
34400
|
return (data.models || []).map((model) => ({
|
|
34209
34401
|
...model,
|
|
@@ -34216,9 +34408,9 @@ function loadRecommendedModels2() {
|
|
|
34216
34408
|
return [];
|
|
34217
34409
|
}
|
|
34218
34410
|
async function fetchAllModels(forceUpdate = false) {
|
|
34219
|
-
if (!forceUpdate &&
|
|
34411
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH2)) {
|
|
34220
34412
|
try {
|
|
34221
|
-
const cacheData = JSON.parse(
|
|
34413
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
34222
34414
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34223
34415
|
const now = new Date;
|
|
34224
34416
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -34647,11 +34839,11 @@ async function fetchOllamaCloudModels() {
|
|
|
34647
34839
|
}
|
|
34648
34840
|
}
|
|
34649
34841
|
function shouldRefreshForFreeModels() {
|
|
34650
|
-
if (!
|
|
34842
|
+
if (!existsSync14(ALL_MODELS_JSON_PATH2)) {
|
|
34651
34843
|
return true;
|
|
34652
34844
|
}
|
|
34653
34845
|
try {
|
|
34654
|
-
const cacheData = JSON.parse(
|
|
34846
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
34655
34847
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34656
34848
|
const now = new Date;
|
|
34657
34849
|
const ageInHours = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
|
@@ -35167,9 +35359,9 @@ var init_model_selector = __esm(() => {
|
|
|
35167
35359
|
init_model_loader();
|
|
35168
35360
|
__filename5 = fileURLToPath4(import.meta.url);
|
|
35169
35361
|
__dirname5 = dirname4(__filename5);
|
|
35170
|
-
CLAUDISH_CACHE_DIR3 =
|
|
35171
|
-
ALL_MODELS_JSON_PATH2 =
|
|
35172
|
-
RECOMMENDED_MODELS_JSON_PATH =
|
|
35362
|
+
CLAUDISH_CACHE_DIR3 = join14(homedir13(), ".claudish");
|
|
35363
|
+
ALL_MODELS_JSON_PATH2 = join14(CLAUDISH_CACHE_DIR3, "all-models.json");
|
|
35364
|
+
RECOMMENDED_MODELS_JSON_PATH = join14(__dirname5, "../recommended-models.json");
|
|
35173
35365
|
PROVIDER_FILTER_ALIASES = {
|
|
35174
35366
|
zen: "Zen",
|
|
35175
35367
|
openrouter: "OpenRouter",
|
|
@@ -36166,17 +36358,17 @@ __export(exports_claude_runner, {
|
|
|
36166
36358
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
36167
36359
|
});
|
|
36168
36360
|
import { spawn } from "node:child_process";
|
|
36169
|
-
import { writeFileSync as writeFileSync8, unlinkSync as unlinkSync5, mkdirSync as mkdirSync8, existsSync as
|
|
36170
|
-
import { tmpdir as tmpdir2, homedir as
|
|
36171
|
-
import { join as
|
|
36361
|
+
import { writeFileSync as writeFileSync8, unlinkSync as unlinkSync5, mkdirSync as mkdirSync8, existsSync as existsSync15, readFileSync as readFileSync13 } from "node:fs";
|
|
36362
|
+
import { tmpdir as tmpdir2, homedir as homedir14 } from "node:os";
|
|
36363
|
+
import { join as join15 } from "node:path";
|
|
36172
36364
|
function isWindows2() {
|
|
36173
36365
|
return process.platform === "win32";
|
|
36174
36366
|
}
|
|
36175
36367
|
function createStatusLineScript(tokenFilePath) {
|
|
36176
36368
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
36177
|
-
const claudishDir =
|
|
36369
|
+
const claudishDir = join15(homeDir, ".claudish");
|
|
36178
36370
|
const timestamp = Date.now();
|
|
36179
|
-
const scriptPath =
|
|
36371
|
+
const scriptPath = join15(claudishDir, `status-${timestamp}.js`);
|
|
36180
36372
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
36181
36373
|
const script = `
|
|
36182
36374
|
const fs = require('fs');
|
|
@@ -36261,13 +36453,13 @@ process.stdin.on('end', () => {
|
|
|
36261
36453
|
}
|
|
36262
36454
|
function createTempSettingsFile(modelDisplay, port) {
|
|
36263
36455
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
36264
|
-
const claudishDir =
|
|
36456
|
+
const claudishDir = join15(homeDir, ".claudish");
|
|
36265
36457
|
try {
|
|
36266
36458
|
mkdirSync8(claudishDir, { recursive: true });
|
|
36267
36459
|
} catch {}
|
|
36268
36460
|
const timestamp = Date.now();
|
|
36269
|
-
const tempPath =
|
|
36270
|
-
const tokenFilePath =
|
|
36461
|
+
const tempPath = join15(claudishDir, `settings-${timestamp}.json`);
|
|
36462
|
+
const tokenFilePath = join15(claudishDir, `tokens-${port}.json`);
|
|
36271
36463
|
let statusCommand;
|
|
36272
36464
|
if (isWindows2()) {
|
|
36273
36465
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -36303,7 +36495,7 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
36303
36495
|
if (userSettingsValue.trimStart().startsWith("{")) {
|
|
36304
36496
|
userSettings = JSON.parse(userSettingsValue);
|
|
36305
36497
|
} else {
|
|
36306
|
-
const rawUserSettings =
|
|
36498
|
+
const rawUserSettings = readFileSync13(userSettingsValue, "utf-8");
|
|
36307
36499
|
userSettings = JSON.parse(rawUserSettings);
|
|
36308
36500
|
}
|
|
36309
36501
|
userSettings.statusLine = statusLine;
|
|
@@ -36390,8 +36582,8 @@ async function runClaudeWithProxy(config3, proxyUrl) {
|
|
|
36390
36582
|
console.error("Install it from: https://claude.com/claude-code");
|
|
36391
36583
|
console.error(`
|
|
36392
36584
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
36393
|
-
const home =
|
|
36394
|
-
const localPath = isWindows2() ?
|
|
36585
|
+
const home = homedir14();
|
|
36586
|
+
const localPath = isWindows2() ? join15(home, ".claude", "local", "claude.exe") : join15(home, ".claude", "local", "claude");
|
|
36395
36587
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
36396
36588
|
process.exit(1);
|
|
36397
36589
|
}
|
|
@@ -36430,23 +36622,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet) {
|
|
|
36430
36622
|
async function findClaudeBinary() {
|
|
36431
36623
|
const isWindows3 = process.platform === "win32";
|
|
36432
36624
|
if (process.env.CLAUDE_PATH) {
|
|
36433
|
-
if (
|
|
36625
|
+
if (existsSync15(process.env.CLAUDE_PATH)) {
|
|
36434
36626
|
return process.env.CLAUDE_PATH;
|
|
36435
36627
|
}
|
|
36436
36628
|
}
|
|
36437
|
-
const home =
|
|
36438
|
-
const localPath = isWindows3 ?
|
|
36439
|
-
if (
|
|
36629
|
+
const home = homedir14();
|
|
36630
|
+
const localPath = isWindows3 ? join15(home, ".claude", "local", "claude.exe") : join15(home, ".claude", "local", "claude");
|
|
36631
|
+
if (existsSync15(localPath)) {
|
|
36440
36632
|
return localPath;
|
|
36441
36633
|
}
|
|
36442
36634
|
if (isWindows3) {
|
|
36443
36635
|
const windowsPaths = [
|
|
36444
|
-
|
|
36445
|
-
|
|
36446
|
-
|
|
36636
|
+
join15(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
36637
|
+
join15(home, ".npm-global", "claude.cmd"),
|
|
36638
|
+
join15(home, "node_modules", ".bin", "claude.cmd")
|
|
36447
36639
|
];
|
|
36448
36640
|
for (const path of windowsPaths) {
|
|
36449
|
-
if (
|
|
36641
|
+
if (existsSync15(path)) {
|
|
36450
36642
|
return path;
|
|
36451
36643
|
}
|
|
36452
36644
|
}
|
|
@@ -36454,14 +36646,14 @@ async function findClaudeBinary() {
|
|
|
36454
36646
|
const commonPaths = [
|
|
36455
36647
|
"/usr/local/bin/claude",
|
|
36456
36648
|
"/opt/homebrew/bin/claude",
|
|
36457
|
-
|
|
36458
|
-
|
|
36459
|
-
|
|
36649
|
+
join15(home, ".npm-global/bin/claude"),
|
|
36650
|
+
join15(home, ".local/bin/claude"),
|
|
36651
|
+
join15(home, "node_modules/.bin/claude"),
|
|
36460
36652
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
36461
|
-
|
|
36653
|
+
join15(home, "../usr/bin/claude")
|
|
36462
36654
|
];
|
|
36463
36655
|
for (const path of commonPaths) {
|
|
36464
|
-
if (
|
|
36656
|
+
if (existsSync15(path)) {
|
|
36465
36657
|
return path;
|
|
36466
36658
|
}
|
|
36467
36659
|
}
|
|
@@ -39107,7 +39299,7 @@ class OpenRouterProvider {
|
|
|
39107
39299
|
}
|
|
39108
39300
|
}
|
|
39109
39301
|
var OPENROUTER_API_URL2 = "https://openrouter.ai/api/v1/chat/completions";
|
|
39110
|
-
var
|
|
39302
|
+
var init_openrouter2 = __esm(() => {
|
|
39111
39303
|
init_openrouter_queue();
|
|
39112
39304
|
});
|
|
39113
39305
|
|
|
@@ -62404,9 +62596,9 @@ var init_gemini_codeassist = __esm(() => {
|
|
|
62404
62596
|
// src/auth/vertex-auth.ts
|
|
62405
62597
|
import { exec as exec4 } from "node:child_process";
|
|
62406
62598
|
import { promisify as promisify3 } from "node:util";
|
|
62407
|
-
import { existsSync as
|
|
62408
|
-
import { homedir as
|
|
62409
|
-
import { join as
|
|
62599
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
62600
|
+
import { homedir as homedir15 } from "node:os";
|
|
62601
|
+
import { join as join16 } from "node:path";
|
|
62410
62602
|
|
|
62411
62603
|
class VertexAuthManager {
|
|
62412
62604
|
cachedToken = null;
|
|
@@ -62460,8 +62652,8 @@ class VertexAuthManager {
|
|
|
62460
62652
|
}
|
|
62461
62653
|
async tryADC() {
|
|
62462
62654
|
try {
|
|
62463
|
-
const adcPath =
|
|
62464
|
-
if (!
|
|
62655
|
+
const adcPath = join16(homedir15(), ".config/gcloud/application_default_credentials.json");
|
|
62656
|
+
if (!existsSync16(adcPath)) {
|
|
62465
62657
|
log("[VertexAuth] ADC credentials file not found");
|
|
62466
62658
|
return null;
|
|
62467
62659
|
}
|
|
@@ -62485,7 +62677,7 @@ class VertexAuthManager {
|
|
|
62485
62677
|
if (!credPath) {
|
|
62486
62678
|
return null;
|
|
62487
62679
|
}
|
|
62488
|
-
if (!
|
|
62680
|
+
if (!existsSync16(credPath)) {
|
|
62489
62681
|
throw new Error(`Service account file not found: ${credPath}
|
|
62490
62682
|
|
|
62491
62683
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -62524,8 +62716,8 @@ function validateVertexOAuthConfig() {
|
|
|
62524
62716
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
62525
62717
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
62526
62718
|
}
|
|
62527
|
-
const adcPath =
|
|
62528
|
-
const hasADC =
|
|
62719
|
+
const adcPath = join16(homedir15(), ".config/gcloud/application_default_credentials.json");
|
|
62720
|
+
const hasADC = existsSync16(adcPath);
|
|
62529
62721
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
62530
62722
|
if (!hasADC && !hasServiceAccount) {
|
|
62531
62723
|
return `No Vertex AI credentials found.
|
|
@@ -62921,8 +63113,8 @@ var init_middleware = __esm(() => {
|
|
|
62921
63113
|
|
|
62922
63114
|
// src/handlers/shared/token-tracker.ts
|
|
62923
63115
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
62924
|
-
import { homedir as
|
|
62925
|
-
import { join as
|
|
63116
|
+
import { homedir as homedir16 } from "node:os";
|
|
63117
|
+
import { join as join17 } from "node:path";
|
|
62926
63118
|
|
|
62927
63119
|
class TokenTracker {
|
|
62928
63120
|
port;
|
|
@@ -63036,9 +63228,9 @@ class TokenTracker {
|
|
|
63036
63228
|
is_free: isFreeModel,
|
|
63037
63229
|
is_estimated: isEstimate || false
|
|
63038
63230
|
};
|
|
63039
|
-
const claudishDir =
|
|
63231
|
+
const claudishDir = join17(homedir16(), ".claudish");
|
|
63040
63232
|
mkdirSync9(claudishDir, { recursive: true });
|
|
63041
|
-
writeFileSync9(
|
|
63233
|
+
writeFileSync9(join17(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
63042
63234
|
} catch (e) {
|
|
63043
63235
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
63044
63236
|
}
|
|
@@ -64346,17 +64538,17 @@ class LiteLLMProvider {
|
|
|
64346
64538
|
}
|
|
64347
64539
|
}
|
|
64348
64540
|
var MODEL_EXTRA_HEADERS;
|
|
64349
|
-
var
|
|
64541
|
+
var init_litellm2 = __esm(() => {
|
|
64350
64542
|
MODEL_EXTRA_HEADERS = [
|
|
64351
64543
|
{ pattern: "kimi", headers: { "User-Agent": "claude-code/1.0" } }
|
|
64352
64544
|
];
|
|
64353
64545
|
});
|
|
64354
64546
|
|
|
64355
64547
|
// src/adapters/litellm-adapter.ts
|
|
64356
|
-
import { existsSync as
|
|
64357
|
-
import { createHash as
|
|
64358
|
-
import { homedir as
|
|
64359
|
-
import { join as
|
|
64548
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15 } from "node:fs";
|
|
64549
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
64550
|
+
import { homedir as homedir17 } from "node:os";
|
|
64551
|
+
import { join as join18 } from "node:path";
|
|
64360
64552
|
var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
|
|
64361
64553
|
var init_litellm_adapter = __esm(() => {
|
|
64362
64554
|
init_base_adapter();
|
|
@@ -64451,11 +64643,11 @@ var init_litellm_adapter = __esm(() => {
|
|
|
64451
64643
|
}
|
|
64452
64644
|
checkVisionSupport() {
|
|
64453
64645
|
try {
|
|
64454
|
-
const hash2 =
|
|
64455
|
-
const cachePath =
|
|
64456
|
-
if (!
|
|
64646
|
+
const hash2 = createHash5("sha256").update(this.baseUrl).digest("hex").substring(0, 16);
|
|
64647
|
+
const cachePath = join18(homedir17(), ".claudish", `litellm-models-${hash2}.json`);
|
|
64648
|
+
if (!existsSync17(cachePath))
|
|
64457
64649
|
return true;
|
|
64458
|
-
const cacheData = JSON.parse(
|
|
64650
|
+
const cacheData = JSON.parse(readFileSync15(cachePath, "utf-8"));
|
|
64459
64651
|
const model = cacheData.models?.find((m) => m.name === this.modelId);
|
|
64460
64652
|
if (model && model.supportsVision === false) {
|
|
64461
64653
|
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
|
|
@@ -64573,12 +64765,12 @@ class AnthropicCompatProvider {
|
|
|
64573
64765
|
}
|
|
64574
64766
|
if (this.provider.name === "kimi-coding" && !this.apiKey) {
|
|
64575
64767
|
try {
|
|
64576
|
-
const { existsSync:
|
|
64577
|
-
const { join:
|
|
64578
|
-
const { homedir:
|
|
64579
|
-
const credPath =
|
|
64580
|
-
if (
|
|
64581
|
-
const data = JSON.parse(
|
|
64768
|
+
const { existsSync: existsSync18, readFileSync: readFileSync16 } = await import("node:fs");
|
|
64769
|
+
const { join: join19 } = await import("node:path");
|
|
64770
|
+
const { homedir: homedir18 } = await import("node:os");
|
|
64771
|
+
const credPath = join19(homedir18(), ".claudish", "kimi-oauth.json");
|
|
64772
|
+
if (existsSync18(credPath)) {
|
|
64773
|
+
const data = JSON.parse(readFileSync16(credPath, "utf-8"));
|
|
64582
64774
|
if (data.access_token && data.refresh_token) {
|
|
64583
64775
|
const { KimiOAuth: KimiOAuth2 } = await Promise.resolve().then(() => (init_kimi_oauth(), exports_kimi_oauth));
|
|
64584
64776
|
const oauth = KimiOAuth2.getInstance();
|
|
@@ -64800,9 +64992,9 @@ var init_ollamacloud_adapter = __esm(() => {
|
|
|
64800
64992
|
});
|
|
64801
64993
|
|
|
64802
64994
|
// src/services/pricing-cache.ts
|
|
64803
|
-
import { readFileSync as
|
|
64804
|
-
import { homedir as
|
|
64805
|
-
import { join as
|
|
64995
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync10, existsSync as existsSync18, mkdirSync as mkdirSync10, statSync } from "node:fs";
|
|
64996
|
+
import { homedir as homedir18 } from "node:os";
|
|
64997
|
+
import { join as join19 } from "node:path";
|
|
64806
64998
|
function getDynamicPricingSync(provider, modelName) {
|
|
64807
64999
|
if (provider === "openrouter") {
|
|
64808
65000
|
const direct = pricingMap.get(modelName);
|
|
@@ -64867,12 +65059,12 @@ async function warmPricingCache() {
|
|
|
64867
65059
|
}
|
|
64868
65060
|
function loadDiskCache() {
|
|
64869
65061
|
try {
|
|
64870
|
-
if (!
|
|
65062
|
+
if (!existsSync18(CACHE_FILE))
|
|
64871
65063
|
return false;
|
|
64872
65064
|
const stat = statSync(CACHE_FILE);
|
|
64873
65065
|
const age = Date.now() - stat.mtimeMs;
|
|
64874
65066
|
const isFresh = age < CACHE_TTL_MS;
|
|
64875
|
-
const raw2 =
|
|
65067
|
+
const raw2 = readFileSync16(CACHE_FILE, "utf-8");
|
|
64876
65068
|
const data = JSON.parse(raw2);
|
|
64877
65069
|
for (const [key, pricing] of Object.entries(data)) {
|
|
64878
65070
|
pricingMap.set(key, pricing);
|
|
@@ -64919,8 +65111,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
64919
65111
|
init_model_loader();
|
|
64920
65112
|
init_remote_provider_types();
|
|
64921
65113
|
pricingMap = new Map;
|
|
64922
|
-
CACHE_DIR =
|
|
64923
|
-
CACHE_FILE =
|
|
65114
|
+
CACHE_DIR = join19(homedir18(), ".claudish");
|
|
65115
|
+
CACHE_FILE = join19(CACHE_DIR, "pricing-cache.json");
|
|
64924
65116
|
CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
64925
65117
|
PROVIDER_TO_OR_PREFIX = {
|
|
64926
65118
|
openai: ["openai/"],
|
|
@@ -65198,6 +65390,16 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
65198
65390
|
} else if (model) {
|
|
65199
65391
|
target = model;
|
|
65200
65392
|
}
|
|
65393
|
+
{
|
|
65394
|
+
const parsedTarget = parseModelSpec(target);
|
|
65395
|
+
if (parsedTarget.provider === "openrouter" || parsedTarget.provider === "litellm") {
|
|
65396
|
+
const resolution = resolveModelNameSync(parsedTarget.model, parsedTarget.provider);
|
|
65397
|
+
logResolution(parsedTarget.model, resolution, options.quiet);
|
|
65398
|
+
if (resolution.wasResolved) {
|
|
65399
|
+
target = `${parsedTarget.provider}@${resolution.resolvedId}`;
|
|
65400
|
+
}
|
|
65401
|
+
}
|
|
65402
|
+
}
|
|
65201
65403
|
if (isPoeModel(target)) {
|
|
65202
65404
|
const poeHandler = getPoeHandler(target);
|
|
65203
65405
|
if (poeHandler) {
|
|
@@ -65266,6 +65468,10 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
65266
65468
|
port = actualPort;
|
|
65267
65469
|
log(`[Proxy] Server started on port ${port}`);
|
|
65268
65470
|
warmPricingCache().catch(() => {});
|
|
65471
|
+
const catalogProvidersToWarm = ["openrouter"];
|
|
65472
|
+
if (process.env.LITELLM_BASE_URL)
|
|
65473
|
+
catalogProvidersToWarm.push("litellm");
|
|
65474
|
+
warmAllCatalogs(catalogProvidersToWarm).catch(() => {});
|
|
65269
65475
|
return {
|
|
65270
65476
|
port,
|
|
65271
65477
|
url: `http://127.0.0.1:${port}`,
|
|
@@ -65280,7 +65486,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65280
65486
|
init_dist10();
|
|
65281
65487
|
init_logger();
|
|
65282
65488
|
init_native_handler();
|
|
65283
|
-
|
|
65489
|
+
init_openrouter2();
|
|
65284
65490
|
init_openrouter_adapter();
|
|
65285
65491
|
init_local();
|
|
65286
65492
|
init_local_adapter();
|
|
@@ -65290,7 +65496,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65290
65496
|
init_vertex_oauth();
|
|
65291
65497
|
init_base_adapter();
|
|
65292
65498
|
init_composed_handler();
|
|
65293
|
-
|
|
65499
|
+
init_litellm2();
|
|
65294
65500
|
init_litellm_adapter();
|
|
65295
65501
|
init_openai();
|
|
65296
65502
|
init_openai_adapter();
|
|
@@ -65304,6 +65510,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65304
65510
|
init_provider_resolver();
|
|
65305
65511
|
init_pricing_cache();
|
|
65306
65512
|
init_model_loader();
|
|
65513
|
+
init_model_catalog_resolver();
|
|
65307
65514
|
});
|
|
65308
65515
|
|
|
65309
65516
|
// src/index.ts
|
package/package.json
CHANGED
package/recommended-models.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.2.0",
|
|
3
|
-
"lastUpdated": "2026-03-
|
|
3
|
+
"lastUpdated": "2026-03-05",
|
|
4
4
|
"source": "https://openrouter.ai/models?categories=programming&fmt=cards&order=top-weekly",
|
|
5
5
|
"models": [
|
|
6
6
|
{
|
|
@@ -122,9 +122,9 @@
|
|
|
122
122
|
"category": "vision",
|
|
123
123
|
"priority": 6,
|
|
124
124
|
"pricing": {
|
|
125
|
-
"input": "$0.
|
|
126
|
-
"output": "$
|
|
127
|
-
"average": "$
|
|
125
|
+
"input": "$0.26/1M",
|
|
126
|
+
"output": "$1.56/1M",
|
|
127
|
+
"average": "$0.91/1M"
|
|
128
128
|
},
|
|
129
129
|
"context": "1000K",
|
|
130
130
|
"maxOutputTokens": 65536,
|