claudish 5.5.2 → 5.6.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 +368 -157
- package/package.json +1 -1
- package/recommended-models.json +4 -4
package/dist/index.js
CHANGED
|
@@ -29435,6 +29435,7 @@ var getRemoteProviders = () => [
|
|
|
29435
29435
|
apiPath: "/anthropic/v1/messages",
|
|
29436
29436
|
apiKeyEnvVar: "MINIMAX_API_KEY",
|
|
29437
29437
|
prefixes: ["mmax/", "mm/"],
|
|
29438
|
+
authScheme: "bearer",
|
|
29438
29439
|
capabilities: {
|
|
29439
29440
|
supportsTools: true,
|
|
29440
29441
|
supportsVision: true,
|
|
@@ -29449,6 +29450,7 @@ var getRemoteProviders = () => [
|
|
|
29449
29450
|
apiPath: "/anthropic/v1/messages",
|
|
29450
29451
|
apiKeyEnvVar: "MINIMAX_CODING_API_KEY",
|
|
29451
29452
|
prefixes: ["mmc/"],
|
|
29453
|
+
authScheme: "bearer",
|
|
29452
29454
|
capabilities: {
|
|
29453
29455
|
supportsTools: true,
|
|
29454
29456
|
supportsVision: true,
|
|
@@ -29650,18 +29652,228 @@ var init_oauth_registry = __esm(() => {
|
|
|
29650
29652
|
};
|
|
29651
29653
|
});
|
|
29652
29654
|
|
|
29653
|
-
// src/providers/
|
|
29654
|
-
|
|
29655
|
+
// src/providers/catalog-resolvers/static-fallback.ts
|
|
29656
|
+
function staticOpenRouterFallback(userInput) {
|
|
29657
|
+
if (userInput.includes("/"))
|
|
29658
|
+
return userInput;
|
|
29659
|
+
const lower = userInput.toLowerCase();
|
|
29660
|
+
for (const [key, vendor] of Object.entries(OPENROUTER_VENDOR_MAP)) {
|
|
29661
|
+
if (lower.startsWith(key)) {
|
|
29662
|
+
return `${vendor}/${userInput}`;
|
|
29663
|
+
}
|
|
29664
|
+
}
|
|
29665
|
+
return null;
|
|
29666
|
+
}
|
|
29667
|
+
var OPENROUTER_VENDOR_MAP;
|
|
29668
|
+
var init_static_fallback = __esm(() => {
|
|
29669
|
+
OPENROUTER_VENDOR_MAP = {
|
|
29670
|
+
google: "google",
|
|
29671
|
+
openai: "openai",
|
|
29672
|
+
kimi: "moonshotai",
|
|
29673
|
+
"kimi-coding": "moonshotai",
|
|
29674
|
+
glm: "z-ai",
|
|
29675
|
+
"glm-coding": "z-ai",
|
|
29676
|
+
zai: "z-ai",
|
|
29677
|
+
minimax: "minimax",
|
|
29678
|
+
ollamacloud: "meta-llama",
|
|
29679
|
+
qwen: "qwen"
|
|
29680
|
+
};
|
|
29681
|
+
});
|
|
29682
|
+
|
|
29683
|
+
// src/providers/catalog-resolvers/openrouter.ts
|
|
29684
|
+
import { readFileSync as readFileSync7, existsSync as existsSync8 } from "node:fs";
|
|
29655
29685
|
import { join as join8 } from "node:path";
|
|
29656
29686
|
import { homedir as homedir7 } from "node:os";
|
|
29687
|
+
|
|
29688
|
+
class OpenRouterCatalogResolver {
|
|
29689
|
+
provider = "openrouter";
|
|
29690
|
+
resolveSync(userInput) {
|
|
29691
|
+
if (userInput.includes("/")) {
|
|
29692
|
+
const models2 = this._getModels();
|
|
29693
|
+
if (models2) {
|
|
29694
|
+
const exactMatch = models2.find((m) => m.id === userInput);
|
|
29695
|
+
return exactMatch ? exactMatch.id : userInput;
|
|
29696
|
+
}
|
|
29697
|
+
return userInput;
|
|
29698
|
+
}
|
|
29699
|
+
const models = this._getModels();
|
|
29700
|
+
if (models) {
|
|
29701
|
+
const suffix = `/${userInput}`;
|
|
29702
|
+
const match = models.find((m) => m.id.endsWith(suffix));
|
|
29703
|
+
if (match)
|
|
29704
|
+
return match.id;
|
|
29705
|
+
const lowerSuffix = `/${userInput.toLowerCase()}`;
|
|
29706
|
+
const ciMatch = models.find((m) => m.id.toLowerCase().endsWith(lowerSuffix));
|
|
29707
|
+
if (ciMatch)
|
|
29708
|
+
return ciMatch.id;
|
|
29709
|
+
}
|
|
29710
|
+
return staticOpenRouterFallback(userInput);
|
|
29711
|
+
}
|
|
29712
|
+
async warmCache() {
|
|
29713
|
+
try {
|
|
29714
|
+
const existing = getCachedOpenRouterModels();
|
|
29715
|
+
if (existing && existing.length > 0) {
|
|
29716
|
+
_memCache = existing;
|
|
29717
|
+
return;
|
|
29718
|
+
}
|
|
29719
|
+
const models = await ensureOpenRouterModelsLoaded();
|
|
29720
|
+
if (models.length > 0) {
|
|
29721
|
+
_memCache = models;
|
|
29722
|
+
}
|
|
29723
|
+
} catch {}
|
|
29724
|
+
}
|
|
29725
|
+
isCacheWarm() {
|
|
29726
|
+
return _memCache !== null && _memCache.length > 0;
|
|
29727
|
+
}
|
|
29728
|
+
_getModels() {
|
|
29729
|
+
if (_memCache)
|
|
29730
|
+
return _memCache;
|
|
29731
|
+
const diskPath = join8(homedir7(), ".claudish", "all-models.json");
|
|
29732
|
+
if (existsSync8(diskPath)) {
|
|
29733
|
+
try {
|
|
29734
|
+
const data = JSON.parse(readFileSync7(diskPath, "utf-8"));
|
|
29735
|
+
if (Array.isArray(data.models) && data.models.length > 0) {
|
|
29736
|
+
_memCache = data.models;
|
|
29737
|
+
return _memCache;
|
|
29738
|
+
}
|
|
29739
|
+
} catch {}
|
|
29740
|
+
}
|
|
29741
|
+
return null;
|
|
29742
|
+
}
|
|
29743
|
+
}
|
|
29744
|
+
var _memCache = null;
|
|
29745
|
+
var init_openrouter = __esm(() => {
|
|
29746
|
+
init_model_loader();
|
|
29747
|
+
init_static_fallback();
|
|
29748
|
+
});
|
|
29749
|
+
|
|
29750
|
+
// src/providers/catalog-resolvers/litellm.ts
|
|
29751
|
+
import { readFileSync as readFileSync8, existsSync as existsSync9 } from "node:fs";
|
|
29752
|
+
import { join as join9 } from "node:path";
|
|
29753
|
+
import { homedir as homedir8 } from "node:os";
|
|
29657
29754
|
import { createHash as createHash3 } from "node:crypto";
|
|
29658
|
-
function
|
|
29755
|
+
function getCachePath() {
|
|
29756
|
+
const baseUrl = process.env.LITELLM_BASE_URL;
|
|
29757
|
+
if (!baseUrl)
|
|
29758
|
+
return null;
|
|
29659
29759
|
const hash2 = createHash3("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
29660
|
-
|
|
29661
|
-
|
|
29760
|
+
return join9(homedir8(), ".claudish", `litellm-models-${hash2}.json`);
|
|
29761
|
+
}
|
|
29762
|
+
|
|
29763
|
+
class LiteLLMCatalogResolver {
|
|
29764
|
+
provider = "litellm";
|
|
29765
|
+
resolveSync(userInput) {
|
|
29766
|
+
const ids = this._getModelIds();
|
|
29767
|
+
if (!ids || ids.length === 0)
|
|
29768
|
+
return null;
|
|
29769
|
+
if (ids.includes(userInput))
|
|
29770
|
+
return userInput;
|
|
29771
|
+
const prefixMatch = ids.find((id) => {
|
|
29772
|
+
if (!id.includes("/"))
|
|
29773
|
+
return false;
|
|
29774
|
+
const afterSlash = id.split("/").pop();
|
|
29775
|
+
return afterSlash === userInput;
|
|
29776
|
+
});
|
|
29777
|
+
if (prefixMatch)
|
|
29778
|
+
return prefixMatch;
|
|
29779
|
+
if (userInput.includes("/")) {
|
|
29780
|
+
const bare = userInput.split("/").pop();
|
|
29781
|
+
if (ids.includes(bare))
|
|
29782
|
+
return bare;
|
|
29783
|
+
}
|
|
29784
|
+
return null;
|
|
29785
|
+
}
|
|
29786
|
+
async warmCache() {
|
|
29787
|
+
const path = getCachePath();
|
|
29788
|
+
if (!path || !existsSync9(path))
|
|
29789
|
+
return;
|
|
29790
|
+
try {
|
|
29791
|
+
const data = JSON.parse(readFileSync8(path, "utf-8"));
|
|
29792
|
+
if (Array.isArray(data.models)) {
|
|
29793
|
+
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
29794
|
+
}
|
|
29795
|
+
} catch {}
|
|
29796
|
+
}
|
|
29797
|
+
isCacheWarm() {
|
|
29798
|
+
return _memCache2 !== null && _memCache2.length > 0;
|
|
29799
|
+
}
|
|
29800
|
+
_getModelIds() {
|
|
29801
|
+
if (_memCache2)
|
|
29802
|
+
return _memCache2;
|
|
29803
|
+
const path = getCachePath();
|
|
29804
|
+
if (!path || !existsSync9(path))
|
|
29805
|
+
return null;
|
|
29806
|
+
try {
|
|
29807
|
+
const data = JSON.parse(readFileSync8(path, "utf-8"));
|
|
29808
|
+
if (Array.isArray(data.models)) {
|
|
29809
|
+
_memCache2 = data.models.map((m) => m.name ?? m.id?.replace("litellm@", "") ?? "");
|
|
29810
|
+
return _memCache2;
|
|
29811
|
+
}
|
|
29812
|
+
} catch {}
|
|
29813
|
+
return null;
|
|
29814
|
+
}
|
|
29815
|
+
}
|
|
29816
|
+
var _memCache2 = null;
|
|
29817
|
+
var init_litellm = () => {};
|
|
29818
|
+
|
|
29819
|
+
// src/providers/model-catalog-resolver.ts
|
|
29820
|
+
function registerResolver(resolver) {
|
|
29821
|
+
RESOLVER_REGISTRY.set(resolver.provider, resolver);
|
|
29822
|
+
}
|
|
29823
|
+
function getResolver(provider) {
|
|
29824
|
+
return RESOLVER_REGISTRY.get(provider) ?? null;
|
|
29825
|
+
}
|
|
29826
|
+
function resolveModelNameSync(userInput, targetProvider) {
|
|
29827
|
+
if (targetProvider !== "openrouter" && userInput.includes("/")) {
|
|
29828
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29829
|
+
}
|
|
29830
|
+
const resolver = getResolver(targetProvider);
|
|
29831
|
+
if (!resolver) {
|
|
29832
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29833
|
+
}
|
|
29834
|
+
const resolved = resolver.resolveSync(userInput);
|
|
29835
|
+
if (!resolved || resolved === userInput) {
|
|
29836
|
+
return { resolvedId: userInput, wasResolved: false, sourceLabel: "passthrough" };
|
|
29837
|
+
}
|
|
29838
|
+
return {
|
|
29839
|
+
resolvedId: resolved,
|
|
29840
|
+
wasResolved: true,
|
|
29841
|
+
sourceLabel: `${targetProvider} catalog`
|
|
29842
|
+
};
|
|
29843
|
+
}
|
|
29844
|
+
function logResolution(userInput, result, quiet = false) {
|
|
29845
|
+
if (result.wasResolved && !quiet) {
|
|
29846
|
+
process.stderr.write(`[Model] Resolved "${userInput}" → "${result.resolvedId}" (${result.sourceLabel})
|
|
29847
|
+
`);
|
|
29848
|
+
}
|
|
29849
|
+
}
|
|
29850
|
+
async function warmAllCatalogs(providers) {
|
|
29851
|
+
const targets = providers ? [...RESOLVER_REGISTRY.entries()].filter(([k]) => providers.includes(k)) : [...RESOLVER_REGISTRY.entries()];
|
|
29852
|
+
await Promise.allSettled(targets.map(([, r]) => r.warmCache()));
|
|
29853
|
+
}
|
|
29854
|
+
var RESOLVER_REGISTRY;
|
|
29855
|
+
var init_model_catalog_resolver = __esm(() => {
|
|
29856
|
+
init_openrouter();
|
|
29857
|
+
init_litellm();
|
|
29858
|
+
RESOLVER_REGISTRY = new Map;
|
|
29859
|
+
[
|
|
29860
|
+
new OpenRouterCatalogResolver,
|
|
29861
|
+
new LiteLLMCatalogResolver
|
|
29862
|
+
].forEach(registerResolver);
|
|
29863
|
+
});
|
|
29864
|
+
|
|
29865
|
+
// src/providers/auto-route.ts
|
|
29866
|
+
import { existsSync as existsSync10, readFileSync as readFileSync9 } from "node:fs";
|
|
29867
|
+
import { join as join10 } from "node:path";
|
|
29868
|
+
import { homedir as homedir9 } from "node:os";
|
|
29869
|
+
import { createHash as createHash4 } from "node:crypto";
|
|
29870
|
+
function readLiteLLMCacheSync(baseUrl) {
|
|
29871
|
+
const hash2 = createHash4("sha256").update(baseUrl).digest("hex").substring(0, 16);
|
|
29872
|
+
const cachePath = join10(homedir9(), ".claudish", `litellm-models-${hash2}.json`);
|
|
29873
|
+
if (!existsSync10(cachePath))
|
|
29662
29874
|
return null;
|
|
29663
29875
|
try {
|
|
29664
|
-
const data = JSON.parse(
|
|
29876
|
+
const data = JSON.parse(readFileSync9(cachePath, "utf-8"));
|
|
29665
29877
|
if (!Array.isArray(data.models))
|
|
29666
29878
|
return null;
|
|
29667
29879
|
return data.models;
|
|
@@ -29708,16 +29920,6 @@ function checkApiKeyForProvider(nativeProvider, modelName) {
|
|
|
29708
29920
|
}
|
|
29709
29921
|
return null;
|
|
29710
29922
|
}
|
|
29711
|
-
function formatForOpenRouter(modelName, nativeProvider) {
|
|
29712
|
-
if (modelName.includes("/")) {
|
|
29713
|
-
return modelName;
|
|
29714
|
-
}
|
|
29715
|
-
const vendor = OPENROUTER_VENDOR_MAP[nativeProvider];
|
|
29716
|
-
if (vendor) {
|
|
29717
|
-
return `${vendor}/${modelName}`;
|
|
29718
|
-
}
|
|
29719
|
-
return modelName;
|
|
29720
|
-
}
|
|
29721
29923
|
function getAutoRouteHint(modelName, nativeProvider) {
|
|
29722
29924
|
const hint = PROVIDER_HINT_MAP[nativeProvider];
|
|
29723
29925
|
const lines = [
|
|
@@ -29771,7 +29973,8 @@ function autoRoute(modelName, nativeProvider) {
|
|
|
29771
29973
|
return apiKeyResult;
|
|
29772
29974
|
}
|
|
29773
29975
|
if (process.env.OPENROUTER_API_KEY) {
|
|
29774
|
-
const
|
|
29976
|
+
const resolution = resolveModelNameSync(modelName, "openrouter");
|
|
29977
|
+
const orModelId = resolution.resolvedId;
|
|
29775
29978
|
return {
|
|
29776
29979
|
provider: "openrouter",
|
|
29777
29980
|
resolvedModelId: orModelId,
|
|
@@ -29782,9 +29985,10 @@ function autoRoute(modelName, nativeProvider) {
|
|
|
29782
29985
|
}
|
|
29783
29986
|
return null;
|
|
29784
29987
|
}
|
|
29785
|
-
var API_KEY_ENV_VARS,
|
|
29988
|
+
var API_KEY_ENV_VARS, PROVIDER_HINT_MAP;
|
|
29786
29989
|
var init_auto_route = __esm(() => {
|
|
29787
29990
|
init_oauth_registry();
|
|
29991
|
+
init_model_catalog_resolver();
|
|
29788
29992
|
API_KEY_ENV_VARS = {
|
|
29789
29993
|
google: { envVar: "GEMINI_API_KEY" },
|
|
29790
29994
|
"gemini-codeassist": { envVar: "GEMINI_API_KEY" },
|
|
@@ -29802,18 +30006,6 @@ var init_auto_route = __esm(() => {
|
|
|
29802
30006
|
vertex: { envVar: "VERTEX_API_KEY", aliases: ["VERTEX_PROJECT"] },
|
|
29803
30007
|
poe: { envVar: "POE_API_KEY" }
|
|
29804
30008
|
};
|
|
29805
|
-
OPENROUTER_VENDOR_MAP = {
|
|
29806
|
-
google: "google",
|
|
29807
|
-
openai: "openai",
|
|
29808
|
-
kimi: "moonshotai",
|
|
29809
|
-
"kimi-coding": "moonshotai",
|
|
29810
|
-
glm: "z-ai",
|
|
29811
|
-
"glm-coding": "z-ai",
|
|
29812
|
-
zai: "z-ai",
|
|
29813
|
-
minimax: "minimax",
|
|
29814
|
-
ollamacloud: "meta-llama",
|
|
29815
|
-
qwen: "qwen"
|
|
29816
|
-
};
|
|
29817
30009
|
PROVIDER_HINT_MAP = {
|
|
29818
30010
|
"kimi-coding": {
|
|
29819
30011
|
loginFlag: "--kimi-login",
|
|
@@ -29870,9 +30062,9 @@ __export(exports_provider_resolver, {
|
|
|
29870
30062
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
29871
30063
|
getMissingKeyError: () => getMissingKeyError
|
|
29872
30064
|
});
|
|
29873
|
-
import { existsSync as
|
|
29874
|
-
import { join as
|
|
29875
|
-
import { homedir as
|
|
30065
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
30066
|
+
import { join as join11 } from "node:path";
|
|
30067
|
+
import { homedir as homedir10 } from "node:os";
|
|
29876
30068
|
function isApiKeyAvailable(info) {
|
|
29877
30069
|
if (!info.envVar) {
|
|
29878
30070
|
return true;
|
|
@@ -29889,8 +30081,8 @@ function isApiKeyAvailable(info) {
|
|
|
29889
30081
|
}
|
|
29890
30082
|
if (info.oauthFallback) {
|
|
29891
30083
|
try {
|
|
29892
|
-
const credPath =
|
|
29893
|
-
if (
|
|
30084
|
+
const credPath = join11(homedir10(), ".claudish", info.oauthFallback);
|
|
30085
|
+
if (existsSync11(credPath)) {
|
|
29894
30086
|
return true;
|
|
29895
30087
|
}
|
|
29896
30088
|
} catch {}
|
|
@@ -30287,16 +30479,16 @@ __export(exports_cli, {
|
|
|
30287
30479
|
getMissingKeyResolutions: () => getMissingKeyResolutions,
|
|
30288
30480
|
getMissingKeyError: () => getMissingKeyError
|
|
30289
30481
|
});
|
|
30290
|
-
import { readFileSync as
|
|
30482
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync5, existsSync as existsSync12, mkdirSync as mkdirSync5, copyFileSync, readdirSync, unlinkSync as unlinkSync3 } from "node:fs";
|
|
30291
30483
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
30292
|
-
import { dirname as dirname3, join as
|
|
30293
|
-
import { homedir as
|
|
30484
|
+
import { dirname as dirname3, join as join12 } from "node:path";
|
|
30485
|
+
import { homedir as homedir11 } from "node:os";
|
|
30294
30486
|
function getVersion() {
|
|
30295
30487
|
return VERSION;
|
|
30296
30488
|
}
|
|
30297
30489
|
function clearAllModelCaches() {
|
|
30298
|
-
const cacheDir =
|
|
30299
|
-
if (!
|
|
30490
|
+
const cacheDir = join12(homedir11(), ".claudish");
|
|
30491
|
+
if (!existsSync12(cacheDir))
|
|
30300
30492
|
return;
|
|
30301
30493
|
const cachePatterns = ["all-models.json", "pricing-cache.json"];
|
|
30302
30494
|
let cleared = 0;
|
|
@@ -30304,7 +30496,7 @@ function clearAllModelCaches() {
|
|
|
30304
30496
|
const files = readdirSync(cacheDir);
|
|
30305
30497
|
for (const file2 of files) {
|
|
30306
30498
|
if (cachePatterns.includes(file2) || file2.startsWith("litellm-models-")) {
|
|
30307
|
-
unlinkSync3(
|
|
30499
|
+
unlinkSync3(join12(cacheDir, file2));
|
|
30308
30500
|
cleared++;
|
|
30309
30501
|
}
|
|
30310
30502
|
}
|
|
@@ -30580,9 +30772,9 @@ async function fetchOllamaModels() {
|
|
|
30580
30772
|
}
|
|
30581
30773
|
async function searchAndPrintModels(query, forceUpdate) {
|
|
30582
30774
|
let models = [];
|
|
30583
|
-
if (!forceUpdate &&
|
|
30775
|
+
if (!forceUpdate && existsSync12(ALL_MODELS_JSON_PATH)) {
|
|
30584
30776
|
try {
|
|
30585
|
-
const cacheData = JSON.parse(
|
|
30777
|
+
const cacheData = JSON.parse(readFileSync10(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
30586
30778
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
30587
30779
|
const now = new Date;
|
|
30588
30780
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -30750,9 +30942,9 @@ Found ${results.length} matching models:
|
|
|
30750
30942
|
async function printAllModels(jsonOutput, forceUpdate) {
|
|
30751
30943
|
let models = [];
|
|
30752
30944
|
const [ollamaModels, zenModels] = await Promise.all([fetchOllamaModels(), fetchZenModels()]);
|
|
30753
|
-
if (!forceUpdate &&
|
|
30945
|
+
if (!forceUpdate && existsSync12(ALL_MODELS_JSON_PATH)) {
|
|
30754
30946
|
try {
|
|
30755
|
-
const cacheData = JSON.parse(
|
|
30947
|
+
const cacheData = JSON.parse(readFileSync10(ALL_MODELS_JSON_PATH, "utf-8"));
|
|
30756
30948
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
30757
30949
|
const now = new Date;
|
|
30758
30950
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -30953,11 +31145,11 @@ async function printAllModels(jsonOutput, forceUpdate) {
|
|
|
30953
31145
|
console.log("Top models: claudish --top-models");
|
|
30954
31146
|
}
|
|
30955
31147
|
function isCacheStale() {
|
|
30956
|
-
if (!
|
|
31148
|
+
if (!existsSync12(MODELS_JSON_PATH)) {
|
|
30957
31149
|
return true;
|
|
30958
31150
|
}
|
|
30959
31151
|
try {
|
|
30960
|
-
const jsonContent =
|
|
31152
|
+
const jsonContent = readFileSync10(MODELS_JSON_PATH, "utf-8");
|
|
30961
31153
|
const data = JSON.parse(jsonContent);
|
|
30962
31154
|
if (!data.lastUpdated) {
|
|
30963
31155
|
return true;
|
|
@@ -31052,9 +31244,9 @@ async function updateModelsFromOpenRouter() {
|
|
|
31052
31244
|
providers.add(provider);
|
|
31053
31245
|
}
|
|
31054
31246
|
let version2 = "1.1.5";
|
|
31055
|
-
if (
|
|
31247
|
+
if (existsSync12(MODELS_JSON_PATH)) {
|
|
31056
31248
|
try {
|
|
31057
|
-
const existing = JSON.parse(
|
|
31249
|
+
const existing = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31058
31250
|
version2 = existing.version || version2;
|
|
31059
31251
|
} catch {}
|
|
31060
31252
|
}
|
|
@@ -31082,7 +31274,7 @@ async function checkAndUpdateModelsCache(forceUpdate = false) {
|
|
|
31082
31274
|
await updateModelsFromOpenRouter();
|
|
31083
31275
|
} else {
|
|
31084
31276
|
try {
|
|
31085
|
-
const data = JSON.parse(
|
|
31277
|
+
const data = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31086
31278
|
console.error(`✓ Using cached models (last updated: ${data.lastUpdated})`);
|
|
31087
31279
|
} catch {}
|
|
31088
31280
|
}
|
|
@@ -31399,8 +31591,8 @@ MORE INFO:
|
|
|
31399
31591
|
}
|
|
31400
31592
|
function printAIAgentGuide() {
|
|
31401
31593
|
try {
|
|
31402
|
-
const guidePath =
|
|
31403
|
-
const guideContent =
|
|
31594
|
+
const guidePath = join12(__dirname4, "../AI_AGENT_GUIDE.md");
|
|
31595
|
+
const guideContent = readFileSync10(guidePath, "utf-8");
|
|
31404
31596
|
console.log(guideContent);
|
|
31405
31597
|
} catch (error46) {
|
|
31406
31598
|
console.error("Error reading AI Agent Guide:");
|
|
@@ -31416,19 +31608,19 @@ async function initializeClaudishSkill() {
|
|
|
31416
31608
|
console.log(`\uD83D\uDD27 Initializing Claudish skill in current project...
|
|
31417
31609
|
`);
|
|
31418
31610
|
const cwd = process.cwd();
|
|
31419
|
-
const claudeDir =
|
|
31420
|
-
const skillsDir =
|
|
31421
|
-
const claudishSkillDir =
|
|
31422
|
-
const skillFile =
|
|
31423
|
-
if (
|
|
31611
|
+
const claudeDir = join12(cwd, ".claude");
|
|
31612
|
+
const skillsDir = join12(claudeDir, "skills");
|
|
31613
|
+
const claudishSkillDir = join12(skillsDir, "claudish-usage");
|
|
31614
|
+
const skillFile = join12(claudishSkillDir, "SKILL.md");
|
|
31615
|
+
if (existsSync12(skillFile)) {
|
|
31424
31616
|
console.log("✅ Claudish skill already installed at:");
|
|
31425
31617
|
console.log(` ${skillFile}
|
|
31426
31618
|
`);
|
|
31427
31619
|
console.log("\uD83D\uDCA1 To reinstall, delete the file and run 'claudish --init' again.");
|
|
31428
31620
|
return;
|
|
31429
31621
|
}
|
|
31430
|
-
const sourceSkillPath =
|
|
31431
|
-
if (!
|
|
31622
|
+
const sourceSkillPath = join12(__dirname4, "../skills/claudish-usage/SKILL.md");
|
|
31623
|
+
if (!existsSync12(sourceSkillPath)) {
|
|
31432
31624
|
console.error("❌ Error: Claudish skill file not found in installation.");
|
|
31433
31625
|
console.error(` Expected at: ${sourceSkillPath}`);
|
|
31434
31626
|
console.error(`
|
|
@@ -31437,15 +31629,15 @@ async function initializeClaudishSkill() {
|
|
|
31437
31629
|
process.exit(1);
|
|
31438
31630
|
}
|
|
31439
31631
|
try {
|
|
31440
|
-
if (!
|
|
31632
|
+
if (!existsSync12(claudeDir)) {
|
|
31441
31633
|
mkdirSync5(claudeDir, { recursive: true });
|
|
31442
31634
|
console.log("\uD83D\uDCC1 Created .claude/ directory");
|
|
31443
31635
|
}
|
|
31444
|
-
if (!
|
|
31636
|
+
if (!existsSync12(skillsDir)) {
|
|
31445
31637
|
mkdirSync5(skillsDir, { recursive: true });
|
|
31446
31638
|
console.log("\uD83D\uDCC1 Created .claude/skills/ directory");
|
|
31447
31639
|
}
|
|
31448
|
-
if (!
|
|
31640
|
+
if (!existsSync12(claudishSkillDir)) {
|
|
31449
31641
|
mkdirSync5(claudishSkillDir, { recursive: true });
|
|
31450
31642
|
console.log("\uD83D\uDCC1 Created .claude/skills/claudish-usage/ directory");
|
|
31451
31643
|
}
|
|
@@ -31488,8 +31680,8 @@ function printAvailableModels() {
|
|
|
31488
31680
|
let lastUpdated = "unknown";
|
|
31489
31681
|
let models = [];
|
|
31490
31682
|
try {
|
|
31491
|
-
if (
|
|
31492
|
-
const data = JSON.parse(
|
|
31683
|
+
if (existsSync12(MODELS_JSON_PATH)) {
|
|
31684
|
+
const data = JSON.parse(readFileSync10(MODELS_JSON_PATH, "utf-8"));
|
|
31493
31685
|
lastUpdated = data.lastUpdated || "unknown";
|
|
31494
31686
|
models = data.models || [];
|
|
31495
31687
|
}
|
|
@@ -31538,9 +31730,9 @@ Force update: claudish --list-models --force-update
|
|
|
31538
31730
|
`);
|
|
31539
31731
|
}
|
|
31540
31732
|
function printAvailableModelsJSON() {
|
|
31541
|
-
const jsonPath =
|
|
31733
|
+
const jsonPath = join12(__dirname4, "../recommended-models.json");
|
|
31542
31734
|
try {
|
|
31543
|
-
const jsonContent =
|
|
31735
|
+
const jsonContent = readFileSync10(jsonPath, "utf-8");
|
|
31544
31736
|
const data = JSON.parse(jsonContent);
|
|
31545
31737
|
console.log(JSON.stringify(data, null, 2));
|
|
31546
31738
|
} catch (error46) {
|
|
@@ -31625,7 +31817,7 @@ async function fetchGLMCodingModels() {
|
|
|
31625
31817
|
return [];
|
|
31626
31818
|
}
|
|
31627
31819
|
}
|
|
31628
|
-
var __filename4, __dirname4, VERSION = "5.
|
|
31820
|
+
var __filename4, __dirname4, VERSION = "5.6.1", CACHE_MAX_AGE_DAYS2 = 2, MODELS_JSON_PATH, CLAUDISH_CACHE_DIR2, ALL_MODELS_JSON_PATH;
|
|
31629
31821
|
var init_cli = __esm(() => {
|
|
31630
31822
|
init_config();
|
|
31631
31823
|
init_model_loader();
|
|
@@ -31634,12 +31826,12 @@ var init_cli = __esm(() => {
|
|
|
31634
31826
|
__filename4 = fileURLToPath3(import.meta.url);
|
|
31635
31827
|
__dirname4 = dirname3(__filename4);
|
|
31636
31828
|
try {
|
|
31637
|
-
const packageJson = JSON.parse(
|
|
31829
|
+
const packageJson = JSON.parse(readFileSync10(join12(__dirname4, "../package.json"), "utf-8"));
|
|
31638
31830
|
VERSION = packageJson.version;
|
|
31639
31831
|
} catch {}
|
|
31640
|
-
MODELS_JSON_PATH =
|
|
31641
|
-
CLAUDISH_CACHE_DIR2 =
|
|
31642
|
-
ALL_MODELS_JSON_PATH =
|
|
31832
|
+
MODELS_JSON_PATH = join12(__dirname4, "../recommended-models.json");
|
|
31833
|
+
CLAUDISH_CACHE_DIR2 = join12(homedir11(), ".claudish");
|
|
31834
|
+
ALL_MODELS_JSON_PATH = join12(CLAUDISH_CACHE_DIR2, "all-models.json");
|
|
31643
31835
|
});
|
|
31644
31836
|
|
|
31645
31837
|
// src/update-checker.ts
|
|
@@ -31651,9 +31843,9 @@ __export(exports_update_checker, {
|
|
|
31651
31843
|
checkForUpdates: () => checkForUpdates
|
|
31652
31844
|
});
|
|
31653
31845
|
import { execSync } from "node:child_process";
|
|
31654
|
-
import { existsSync as
|
|
31655
|
-
import { homedir as
|
|
31656
|
-
import { join as
|
|
31846
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync6, readFileSync as readFileSync11, unlinkSync as unlinkSync4, writeFileSync as writeFileSync6 } from "node:fs";
|
|
31847
|
+
import { homedir as homedir12, platform as platform2, tmpdir } from "node:os";
|
|
31848
|
+
import { join as join13 } from "node:path";
|
|
31657
31849
|
import { createInterface } from "node:readline";
|
|
31658
31850
|
function getUpdateCommand() {
|
|
31659
31851
|
const scriptPath = process.argv[1] || "";
|
|
@@ -31665,27 +31857,27 @@ function getUpdateCommand() {
|
|
|
31665
31857
|
function getCacheFilePath() {
|
|
31666
31858
|
let cacheDir;
|
|
31667
31859
|
if (isWindows) {
|
|
31668
|
-
const localAppData = process.env.LOCALAPPDATA ||
|
|
31669
|
-
cacheDir =
|
|
31860
|
+
const localAppData = process.env.LOCALAPPDATA || join13(homedir12(), "AppData", "Local");
|
|
31861
|
+
cacheDir = join13(localAppData, "claudish");
|
|
31670
31862
|
} else {
|
|
31671
|
-
cacheDir =
|
|
31863
|
+
cacheDir = join13(homedir12(), ".cache", "claudish");
|
|
31672
31864
|
}
|
|
31673
31865
|
try {
|
|
31674
|
-
if (!
|
|
31866
|
+
if (!existsSync13(cacheDir)) {
|
|
31675
31867
|
mkdirSync6(cacheDir, { recursive: true });
|
|
31676
31868
|
}
|
|
31677
|
-
return
|
|
31869
|
+
return join13(cacheDir, "update-check.json");
|
|
31678
31870
|
} catch {
|
|
31679
|
-
return
|
|
31871
|
+
return join13(tmpdir(), "claudish-update-check.json");
|
|
31680
31872
|
}
|
|
31681
31873
|
}
|
|
31682
31874
|
function readCache() {
|
|
31683
31875
|
try {
|
|
31684
31876
|
const cachePath = getCacheFilePath();
|
|
31685
|
-
if (!
|
|
31877
|
+
if (!existsSync13(cachePath)) {
|
|
31686
31878
|
return null;
|
|
31687
31879
|
}
|
|
31688
|
-
const data = JSON.parse(
|
|
31880
|
+
const data = JSON.parse(readFileSync11(cachePath, "utf-8"));
|
|
31689
31881
|
return data;
|
|
31690
31882
|
} catch {
|
|
31691
31883
|
return null;
|
|
@@ -31708,7 +31900,7 @@ function isCacheValid(cache) {
|
|
|
31708
31900
|
function clearCache() {
|
|
31709
31901
|
try {
|
|
31710
31902
|
const cachePath = getCacheFilePath();
|
|
31711
|
-
if (
|
|
31903
|
+
if (existsSync13(cachePath)) {
|
|
31712
31904
|
unlinkSync4(cachePath);
|
|
31713
31905
|
}
|
|
31714
31906
|
} catch {}
|
|
@@ -34198,14 +34390,14 @@ __export(exports_model_selector, {
|
|
|
34198
34390
|
promptForApiKey: () => promptForApiKey,
|
|
34199
34391
|
confirmAction: () => confirmAction
|
|
34200
34392
|
});
|
|
34201
|
-
import { readFileSync as
|
|
34202
|
-
import { join as
|
|
34203
|
-
import { homedir as
|
|
34393
|
+
import { readFileSync as readFileSync12, writeFileSync as writeFileSync7, existsSync as existsSync14, mkdirSync as mkdirSync7 } from "node:fs";
|
|
34394
|
+
import { join as join14, dirname as dirname4 } from "node:path";
|
|
34395
|
+
import { homedir as homedir13 } from "node:os";
|
|
34204
34396
|
import { fileURLToPath as fileURLToPath4 } from "node:url";
|
|
34205
34397
|
function loadRecommendedModels2() {
|
|
34206
|
-
if (
|
|
34398
|
+
if (existsSync14(RECOMMENDED_MODELS_JSON_PATH)) {
|
|
34207
34399
|
try {
|
|
34208
|
-
const content =
|
|
34400
|
+
const content = readFileSync12(RECOMMENDED_MODELS_JSON_PATH, "utf-8");
|
|
34209
34401
|
const data = JSON.parse(content);
|
|
34210
34402
|
return (data.models || []).map((model) => ({
|
|
34211
34403
|
...model,
|
|
@@ -34218,9 +34410,9 @@ function loadRecommendedModels2() {
|
|
|
34218
34410
|
return [];
|
|
34219
34411
|
}
|
|
34220
34412
|
async function fetchAllModels(forceUpdate = false) {
|
|
34221
|
-
if (!forceUpdate &&
|
|
34413
|
+
if (!forceUpdate && existsSync14(ALL_MODELS_JSON_PATH2)) {
|
|
34222
34414
|
try {
|
|
34223
|
-
const cacheData = JSON.parse(
|
|
34415
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
34224
34416
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34225
34417
|
const now = new Date;
|
|
34226
34418
|
const ageInDays = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60 * 24);
|
|
@@ -34649,11 +34841,11 @@ async function fetchOllamaCloudModels() {
|
|
|
34649
34841
|
}
|
|
34650
34842
|
}
|
|
34651
34843
|
function shouldRefreshForFreeModels() {
|
|
34652
|
-
if (!
|
|
34844
|
+
if (!existsSync14(ALL_MODELS_JSON_PATH2)) {
|
|
34653
34845
|
return true;
|
|
34654
34846
|
}
|
|
34655
34847
|
try {
|
|
34656
|
-
const cacheData = JSON.parse(
|
|
34848
|
+
const cacheData = JSON.parse(readFileSync12(ALL_MODELS_JSON_PATH2, "utf-8"));
|
|
34657
34849
|
const lastUpdated = new Date(cacheData.lastUpdated);
|
|
34658
34850
|
const now = new Date;
|
|
34659
34851
|
const ageInHours = (now.getTime() - lastUpdated.getTime()) / (1000 * 60 * 60);
|
|
@@ -35169,9 +35361,9 @@ var init_model_selector = __esm(() => {
|
|
|
35169
35361
|
init_model_loader();
|
|
35170
35362
|
__filename5 = fileURLToPath4(import.meta.url);
|
|
35171
35363
|
__dirname5 = dirname4(__filename5);
|
|
35172
|
-
CLAUDISH_CACHE_DIR3 =
|
|
35173
|
-
ALL_MODELS_JSON_PATH2 =
|
|
35174
|
-
RECOMMENDED_MODELS_JSON_PATH =
|
|
35364
|
+
CLAUDISH_CACHE_DIR3 = join14(homedir13(), ".claudish");
|
|
35365
|
+
ALL_MODELS_JSON_PATH2 = join14(CLAUDISH_CACHE_DIR3, "all-models.json");
|
|
35366
|
+
RECOMMENDED_MODELS_JSON_PATH = join14(__dirname5, "../recommended-models.json");
|
|
35175
35367
|
PROVIDER_FILTER_ALIASES = {
|
|
35176
35368
|
zen: "Zen",
|
|
35177
35369
|
openrouter: "OpenRouter",
|
|
@@ -36168,17 +36360,17 @@ __export(exports_claude_runner, {
|
|
|
36168
36360
|
checkClaudeInstalled: () => checkClaudeInstalled
|
|
36169
36361
|
});
|
|
36170
36362
|
import { spawn } from "node:child_process";
|
|
36171
|
-
import { writeFileSync as writeFileSync8, unlinkSync as unlinkSync5, mkdirSync as mkdirSync8, existsSync as
|
|
36172
|
-
import { tmpdir as tmpdir2, homedir as
|
|
36173
|
-
import { join as
|
|
36363
|
+
import { writeFileSync as writeFileSync8, unlinkSync as unlinkSync5, mkdirSync as mkdirSync8, existsSync as existsSync15, readFileSync as readFileSync13 } from "node:fs";
|
|
36364
|
+
import { tmpdir as tmpdir2, homedir as homedir14 } from "node:os";
|
|
36365
|
+
import { join as join15 } from "node:path";
|
|
36174
36366
|
function isWindows2() {
|
|
36175
36367
|
return process.platform === "win32";
|
|
36176
36368
|
}
|
|
36177
36369
|
function createStatusLineScript(tokenFilePath) {
|
|
36178
36370
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
36179
|
-
const claudishDir =
|
|
36371
|
+
const claudishDir = join15(homeDir, ".claudish");
|
|
36180
36372
|
const timestamp = Date.now();
|
|
36181
|
-
const scriptPath =
|
|
36373
|
+
const scriptPath = join15(claudishDir, `status-${timestamp}.js`);
|
|
36182
36374
|
const escapedTokenPath = tokenFilePath.replace(/\\/g, "\\\\");
|
|
36183
36375
|
const script = `
|
|
36184
36376
|
const fs = require('fs');
|
|
@@ -36263,13 +36455,13 @@ process.stdin.on('end', () => {
|
|
|
36263
36455
|
}
|
|
36264
36456
|
function createTempSettingsFile(modelDisplay, port) {
|
|
36265
36457
|
const homeDir = process.env.HOME || process.env.USERPROFILE || tmpdir2();
|
|
36266
|
-
const claudishDir =
|
|
36458
|
+
const claudishDir = join15(homeDir, ".claudish");
|
|
36267
36459
|
try {
|
|
36268
36460
|
mkdirSync8(claudishDir, { recursive: true });
|
|
36269
36461
|
} catch {}
|
|
36270
36462
|
const timestamp = Date.now();
|
|
36271
|
-
const tempPath =
|
|
36272
|
-
const tokenFilePath =
|
|
36463
|
+
const tempPath = join15(claudishDir, `settings-${timestamp}.json`);
|
|
36464
|
+
const tokenFilePath = join15(claudishDir, `tokens-${port}.json`);
|
|
36273
36465
|
let statusCommand;
|
|
36274
36466
|
if (isWindows2()) {
|
|
36275
36467
|
const scriptPath = createStatusLineScript(tokenFilePath);
|
|
@@ -36305,7 +36497,7 @@ function mergeUserSettingsIfPresent(config3, tempSettingsPath, statusLine) {
|
|
|
36305
36497
|
if (userSettingsValue.trimStart().startsWith("{")) {
|
|
36306
36498
|
userSettings = JSON.parse(userSettingsValue);
|
|
36307
36499
|
} else {
|
|
36308
|
-
const rawUserSettings =
|
|
36500
|
+
const rawUserSettings = readFileSync13(userSettingsValue, "utf-8");
|
|
36309
36501
|
userSettings = JSON.parse(rawUserSettings);
|
|
36310
36502
|
}
|
|
36311
36503
|
userSettings.statusLine = statusLine;
|
|
@@ -36392,8 +36584,8 @@ async function runClaudeWithProxy(config3, proxyUrl) {
|
|
|
36392
36584
|
console.error("Install it from: https://claude.com/claude-code");
|
|
36393
36585
|
console.error(`
|
|
36394
36586
|
Or set CLAUDE_PATH to your custom installation:`);
|
|
36395
|
-
const home =
|
|
36396
|
-
const localPath = isWindows2() ?
|
|
36587
|
+
const home = homedir14();
|
|
36588
|
+
const localPath = isWindows2() ? join15(home, ".claude", "local", "claude.exe") : join15(home, ".claude", "local", "claude");
|
|
36397
36589
|
console.error(` export CLAUDE_PATH=${localPath}`);
|
|
36398
36590
|
process.exit(1);
|
|
36399
36591
|
}
|
|
@@ -36432,23 +36624,23 @@ function setupSignalHandlers(proc, tempSettingsPath, quiet) {
|
|
|
36432
36624
|
async function findClaudeBinary() {
|
|
36433
36625
|
const isWindows3 = process.platform === "win32";
|
|
36434
36626
|
if (process.env.CLAUDE_PATH) {
|
|
36435
|
-
if (
|
|
36627
|
+
if (existsSync15(process.env.CLAUDE_PATH)) {
|
|
36436
36628
|
return process.env.CLAUDE_PATH;
|
|
36437
36629
|
}
|
|
36438
36630
|
}
|
|
36439
|
-
const home =
|
|
36440
|
-
const localPath = isWindows3 ?
|
|
36441
|
-
if (
|
|
36631
|
+
const home = homedir14();
|
|
36632
|
+
const localPath = isWindows3 ? join15(home, ".claude", "local", "claude.exe") : join15(home, ".claude", "local", "claude");
|
|
36633
|
+
if (existsSync15(localPath)) {
|
|
36442
36634
|
return localPath;
|
|
36443
36635
|
}
|
|
36444
36636
|
if (isWindows3) {
|
|
36445
36637
|
const windowsPaths = [
|
|
36446
|
-
|
|
36447
|
-
|
|
36448
|
-
|
|
36638
|
+
join15(home, "AppData", "Roaming", "npm", "claude.cmd"),
|
|
36639
|
+
join15(home, ".npm-global", "claude.cmd"),
|
|
36640
|
+
join15(home, "node_modules", ".bin", "claude.cmd")
|
|
36449
36641
|
];
|
|
36450
36642
|
for (const path of windowsPaths) {
|
|
36451
|
-
if (
|
|
36643
|
+
if (existsSync15(path)) {
|
|
36452
36644
|
return path;
|
|
36453
36645
|
}
|
|
36454
36646
|
}
|
|
@@ -36456,14 +36648,14 @@ async function findClaudeBinary() {
|
|
|
36456
36648
|
const commonPaths = [
|
|
36457
36649
|
"/usr/local/bin/claude",
|
|
36458
36650
|
"/opt/homebrew/bin/claude",
|
|
36459
|
-
|
|
36460
|
-
|
|
36461
|
-
|
|
36651
|
+
join15(home, ".npm-global/bin/claude"),
|
|
36652
|
+
join15(home, ".local/bin/claude"),
|
|
36653
|
+
join15(home, "node_modules/.bin/claude"),
|
|
36462
36654
|
"/data/data/com.termux/files/usr/bin/claude",
|
|
36463
|
-
|
|
36655
|
+
join15(home, "../usr/bin/claude")
|
|
36464
36656
|
];
|
|
36465
36657
|
for (const path of commonPaths) {
|
|
36466
|
-
if (
|
|
36658
|
+
if (existsSync15(path)) {
|
|
36467
36659
|
return path;
|
|
36468
36660
|
}
|
|
36469
36661
|
}
|
|
@@ -39109,7 +39301,7 @@ class OpenRouterProvider {
|
|
|
39109
39301
|
}
|
|
39110
39302
|
}
|
|
39111
39303
|
var OPENROUTER_API_URL2 = "https://openrouter.ai/api/v1/chat/completions";
|
|
39112
|
-
var
|
|
39304
|
+
var init_openrouter2 = __esm(() => {
|
|
39113
39305
|
init_openrouter_queue();
|
|
39114
39306
|
});
|
|
39115
39307
|
|
|
@@ -62406,9 +62598,9 @@ var init_gemini_codeassist = __esm(() => {
|
|
|
62406
62598
|
// src/auth/vertex-auth.ts
|
|
62407
62599
|
import { exec as exec4 } from "node:child_process";
|
|
62408
62600
|
import { promisify as promisify3 } from "node:util";
|
|
62409
|
-
import { existsSync as
|
|
62410
|
-
import { homedir as
|
|
62411
|
-
import { join as
|
|
62601
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
62602
|
+
import { homedir as homedir15 } from "node:os";
|
|
62603
|
+
import { join as join16 } from "node:path";
|
|
62412
62604
|
|
|
62413
62605
|
class VertexAuthManager {
|
|
62414
62606
|
cachedToken = null;
|
|
@@ -62462,8 +62654,8 @@ class VertexAuthManager {
|
|
|
62462
62654
|
}
|
|
62463
62655
|
async tryADC() {
|
|
62464
62656
|
try {
|
|
62465
|
-
const adcPath =
|
|
62466
|
-
if (!
|
|
62657
|
+
const adcPath = join16(homedir15(), ".config/gcloud/application_default_credentials.json");
|
|
62658
|
+
if (!existsSync16(adcPath)) {
|
|
62467
62659
|
log("[VertexAuth] ADC credentials file not found");
|
|
62468
62660
|
return null;
|
|
62469
62661
|
}
|
|
@@ -62487,7 +62679,7 @@ class VertexAuthManager {
|
|
|
62487
62679
|
if (!credPath) {
|
|
62488
62680
|
return null;
|
|
62489
62681
|
}
|
|
62490
|
-
if (!
|
|
62682
|
+
if (!existsSync16(credPath)) {
|
|
62491
62683
|
throw new Error(`Service account file not found: ${credPath}
|
|
62492
62684
|
|
|
62493
62685
|
Check GOOGLE_APPLICATION_CREDENTIALS path.`);
|
|
@@ -62526,8 +62718,8 @@ function validateVertexOAuthConfig() {
|
|
|
62526
62718
|
` + ` export VERTEX_PROJECT='your-gcp-project-id'
|
|
62527
62719
|
` + " export VERTEX_LOCATION='us-central1' # optional";
|
|
62528
62720
|
}
|
|
62529
|
-
const adcPath =
|
|
62530
|
-
const hasADC =
|
|
62721
|
+
const adcPath = join16(homedir15(), ".config/gcloud/application_default_credentials.json");
|
|
62722
|
+
const hasADC = existsSync16(adcPath);
|
|
62531
62723
|
const hasServiceAccount = !!process.env.GOOGLE_APPLICATION_CREDENTIALS;
|
|
62532
62724
|
if (!hasADC && !hasServiceAccount) {
|
|
62533
62725
|
return `No Vertex AI credentials found.
|
|
@@ -62923,8 +63115,8 @@ var init_middleware = __esm(() => {
|
|
|
62923
63115
|
|
|
62924
63116
|
// src/handlers/shared/token-tracker.ts
|
|
62925
63117
|
import { mkdirSync as mkdirSync9, writeFileSync as writeFileSync9 } from "node:fs";
|
|
62926
|
-
import { homedir as
|
|
62927
|
-
import { join as
|
|
63118
|
+
import { homedir as homedir16 } from "node:os";
|
|
63119
|
+
import { join as join17 } from "node:path";
|
|
62928
63120
|
|
|
62929
63121
|
class TokenTracker {
|
|
62930
63122
|
port;
|
|
@@ -63038,9 +63230,9 @@ class TokenTracker {
|
|
|
63038
63230
|
is_free: isFreeModel,
|
|
63039
63231
|
is_estimated: isEstimate || false
|
|
63040
63232
|
};
|
|
63041
|
-
const claudishDir =
|
|
63233
|
+
const claudishDir = join17(homedir16(), ".claudish");
|
|
63042
63234
|
mkdirSync9(claudishDir, { recursive: true });
|
|
63043
|
-
writeFileSync9(
|
|
63235
|
+
writeFileSync9(join17(claudishDir, `tokens-${this.port}.json`), JSON.stringify(data), "utf-8");
|
|
63044
63236
|
} catch (e) {
|
|
63045
63237
|
log(`[TokenTracker] Error writing token file: ${e}`);
|
|
63046
63238
|
}
|
|
@@ -64348,17 +64540,17 @@ class LiteLLMProvider {
|
|
|
64348
64540
|
}
|
|
64349
64541
|
}
|
|
64350
64542
|
var MODEL_EXTRA_HEADERS;
|
|
64351
|
-
var
|
|
64543
|
+
var init_litellm2 = __esm(() => {
|
|
64352
64544
|
MODEL_EXTRA_HEADERS = [
|
|
64353
64545
|
{ pattern: "kimi", headers: { "User-Agent": "claude-code/1.0" } }
|
|
64354
64546
|
];
|
|
64355
64547
|
});
|
|
64356
64548
|
|
|
64357
64549
|
// src/adapters/litellm-adapter.ts
|
|
64358
|
-
import { existsSync as
|
|
64359
|
-
import { createHash as
|
|
64360
|
-
import { homedir as
|
|
64361
|
-
import { join as
|
|
64550
|
+
import { existsSync as existsSync17, readFileSync as readFileSync15 } from "node:fs";
|
|
64551
|
+
import { createHash as createHash5 } from "node:crypto";
|
|
64552
|
+
import { homedir as homedir17 } from "node:os";
|
|
64553
|
+
import { join as join18 } from "node:path";
|
|
64362
64554
|
var INLINE_IMAGE_MODEL_PATTERNS, LiteLLMAdapter;
|
|
64363
64555
|
var init_litellm_adapter = __esm(() => {
|
|
64364
64556
|
init_base_adapter();
|
|
@@ -64453,11 +64645,11 @@ var init_litellm_adapter = __esm(() => {
|
|
|
64453
64645
|
}
|
|
64454
64646
|
checkVisionSupport() {
|
|
64455
64647
|
try {
|
|
64456
|
-
const hash2 =
|
|
64457
|
-
const cachePath =
|
|
64458
|
-
if (!
|
|
64648
|
+
const hash2 = createHash5("sha256").update(this.baseUrl).digest("hex").substring(0, 16);
|
|
64649
|
+
const cachePath = join18(homedir17(), ".claudish", `litellm-models-${hash2}.json`);
|
|
64650
|
+
if (!existsSync17(cachePath))
|
|
64459
64651
|
return true;
|
|
64460
|
-
const cacheData = JSON.parse(
|
|
64652
|
+
const cacheData = JSON.parse(readFileSync15(cachePath, "utf-8"));
|
|
64461
64653
|
const model = cacheData.models?.find((m) => m.name === this.modelId);
|
|
64462
64654
|
if (model && model.supportsVision === false) {
|
|
64463
64655
|
log(`[LiteLLMAdapter] Model ${this.modelId} does not support vision`);
|
|
@@ -64567,20 +64759,24 @@ class AnthropicCompatProvider {
|
|
|
64567
64759
|
}
|
|
64568
64760
|
async getHeaders() {
|
|
64569
64761
|
const headers = {
|
|
64570
|
-
"x-api-key": this.apiKey,
|
|
64571
64762
|
"anthropic-version": "2023-06-01"
|
|
64572
64763
|
};
|
|
64764
|
+
if (this.provider.authScheme === "bearer") {
|
|
64765
|
+
headers["Authorization"] = `Bearer ${this.apiKey}`;
|
|
64766
|
+
} else {
|
|
64767
|
+
headers["x-api-key"] = this.apiKey;
|
|
64768
|
+
}
|
|
64573
64769
|
if (this.provider.headers) {
|
|
64574
64770
|
Object.assign(headers, this.provider.headers);
|
|
64575
64771
|
}
|
|
64576
64772
|
if (this.provider.name === "kimi-coding" && !this.apiKey) {
|
|
64577
64773
|
try {
|
|
64578
|
-
const { existsSync:
|
|
64579
|
-
const { join:
|
|
64580
|
-
const { homedir:
|
|
64581
|
-
const credPath =
|
|
64582
|
-
if (
|
|
64583
|
-
const data = JSON.parse(
|
|
64774
|
+
const { existsSync: existsSync18, readFileSync: readFileSync16 } = await import("node:fs");
|
|
64775
|
+
const { join: join19 } = await import("node:path");
|
|
64776
|
+
const { homedir: homedir18 } = await import("node:os");
|
|
64777
|
+
const credPath = join19(homedir18(), ".claudish", "kimi-oauth.json");
|
|
64778
|
+
if (existsSync18(credPath)) {
|
|
64779
|
+
const data = JSON.parse(readFileSync16(credPath, "utf-8"));
|
|
64584
64780
|
if (data.access_token && data.refresh_token) {
|
|
64585
64781
|
const { KimiOAuth: KimiOAuth2 } = await Promise.resolve().then(() => (init_kimi_oauth(), exports_kimi_oauth));
|
|
64586
64782
|
const oauth = KimiOAuth2.getInstance();
|
|
@@ -64802,9 +64998,9 @@ var init_ollamacloud_adapter = __esm(() => {
|
|
|
64802
64998
|
});
|
|
64803
64999
|
|
|
64804
65000
|
// src/services/pricing-cache.ts
|
|
64805
|
-
import { readFileSync as
|
|
64806
|
-
import { homedir as
|
|
64807
|
-
import { join as
|
|
65001
|
+
import { readFileSync as readFileSync16, writeFileSync as writeFileSync10, existsSync as existsSync18, mkdirSync as mkdirSync10, statSync } from "node:fs";
|
|
65002
|
+
import { homedir as homedir18 } from "node:os";
|
|
65003
|
+
import { join as join19 } from "node:path";
|
|
64808
65004
|
function getDynamicPricingSync(provider, modelName) {
|
|
64809
65005
|
if (provider === "openrouter") {
|
|
64810
65006
|
const direct = pricingMap.get(modelName);
|
|
@@ -64869,12 +65065,12 @@ async function warmPricingCache() {
|
|
|
64869
65065
|
}
|
|
64870
65066
|
function loadDiskCache() {
|
|
64871
65067
|
try {
|
|
64872
|
-
if (!
|
|
65068
|
+
if (!existsSync18(CACHE_FILE))
|
|
64873
65069
|
return false;
|
|
64874
65070
|
const stat = statSync(CACHE_FILE);
|
|
64875
65071
|
const age = Date.now() - stat.mtimeMs;
|
|
64876
65072
|
const isFresh = age < CACHE_TTL_MS;
|
|
64877
|
-
const raw2 =
|
|
65073
|
+
const raw2 = readFileSync16(CACHE_FILE, "utf-8");
|
|
64878
65074
|
const data = JSON.parse(raw2);
|
|
64879
65075
|
for (const [key, pricing] of Object.entries(data)) {
|
|
64880
65076
|
pricingMap.set(key, pricing);
|
|
@@ -64921,8 +65117,8 @@ var init_pricing_cache = __esm(() => {
|
|
|
64921
65117
|
init_model_loader();
|
|
64922
65118
|
init_remote_provider_types();
|
|
64923
65119
|
pricingMap = new Map;
|
|
64924
|
-
CACHE_DIR =
|
|
64925
|
-
CACHE_FILE =
|
|
65120
|
+
CACHE_DIR = join19(homedir18(), ".claudish");
|
|
65121
|
+
CACHE_FILE = join19(CACHE_DIR, "pricing-cache.json");
|
|
64926
65122
|
CACHE_TTL_MS = 24 * 60 * 60 * 1000;
|
|
64927
65123
|
PROVIDER_TO_OR_PREFIX = {
|
|
64928
65124
|
openai: ["openai/"],
|
|
@@ -65200,6 +65396,16 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
65200
65396
|
} else if (model) {
|
|
65201
65397
|
target = model;
|
|
65202
65398
|
}
|
|
65399
|
+
{
|
|
65400
|
+
const parsedTarget = parseModelSpec(target);
|
|
65401
|
+
if (parsedTarget.provider === "openrouter" || parsedTarget.provider === "litellm") {
|
|
65402
|
+
const resolution = resolveModelNameSync(parsedTarget.model, parsedTarget.provider);
|
|
65403
|
+
logResolution(parsedTarget.model, resolution, options.quiet);
|
|
65404
|
+
if (resolution.wasResolved) {
|
|
65405
|
+
target = `${parsedTarget.provider}@${resolution.resolvedId}`;
|
|
65406
|
+
}
|
|
65407
|
+
}
|
|
65408
|
+
}
|
|
65203
65409
|
if (isPoeModel(target)) {
|
|
65204
65410
|
const poeHandler = getPoeHandler(target);
|
|
65205
65411
|
if (poeHandler) {
|
|
@@ -65268,6 +65474,10 @@ async function createProxyServer(port, openrouterApiKey, model, monitorMode = fa
|
|
|
65268
65474
|
port = actualPort;
|
|
65269
65475
|
log(`[Proxy] Server started on port ${port}`);
|
|
65270
65476
|
warmPricingCache().catch(() => {});
|
|
65477
|
+
const catalogProvidersToWarm = ["openrouter"];
|
|
65478
|
+
if (process.env.LITELLM_BASE_URL)
|
|
65479
|
+
catalogProvidersToWarm.push("litellm");
|
|
65480
|
+
warmAllCatalogs(catalogProvidersToWarm).catch(() => {});
|
|
65271
65481
|
return {
|
|
65272
65482
|
port,
|
|
65273
65483
|
url: `http://127.0.0.1:${port}`,
|
|
@@ -65282,7 +65492,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65282
65492
|
init_dist10();
|
|
65283
65493
|
init_logger();
|
|
65284
65494
|
init_native_handler();
|
|
65285
|
-
|
|
65495
|
+
init_openrouter2();
|
|
65286
65496
|
init_openrouter_adapter();
|
|
65287
65497
|
init_local();
|
|
65288
65498
|
init_local_adapter();
|
|
@@ -65292,7 +65502,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65292
65502
|
init_vertex_oauth();
|
|
65293
65503
|
init_base_adapter();
|
|
65294
65504
|
init_composed_handler();
|
|
65295
|
-
|
|
65505
|
+
init_litellm2();
|
|
65296
65506
|
init_litellm_adapter();
|
|
65297
65507
|
init_openai();
|
|
65298
65508
|
init_openai_adapter();
|
|
@@ -65306,6 +65516,7 @@ var init_proxy_server = __esm(() => {
|
|
|
65306
65516
|
init_provider_resolver();
|
|
65307
65517
|
init_pricing_cache();
|
|
65308
65518
|
init_model_loader();
|
|
65519
|
+
init_model_catalog_resolver();
|
|
65309
65520
|
});
|
|
65310
65521
|
|
|
65311
65522
|
// 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,
|