claudish 7.54.0 → 7.56.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 +318 -94
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -729,7 +729,7 @@ var init_onepassword_config = __esm(() => {
|
|
|
729
729
|
});
|
|
730
730
|
|
|
731
731
|
// src/version.ts
|
|
732
|
-
var VERSION = "7.
|
|
732
|
+
var VERSION = "7.56.0";
|
|
733
733
|
|
|
734
734
|
// src/logger.ts
|
|
735
735
|
var exports_logger = {};
|
|
@@ -28057,6 +28057,7 @@ var init_provider_definitions = __esm(() => {
|
|
|
28057
28057
|
{ prefix: "antigravity/", stripPrefix: true },
|
|
28058
28058
|
{ prefix: "go/", stripPrefix: true }
|
|
28059
28059
|
],
|
|
28060
|
+
modelDiscovery: { path: "", format: "antigravity" },
|
|
28060
28061
|
isDirectApi: true,
|
|
28061
28062
|
description: "Antigravity subscription (ag@; go@ deprecated)"
|
|
28062
28063
|
},
|
|
@@ -30105,6 +30106,17 @@ var init_openai_api_format = __esm(() => {
|
|
|
30105
30106
|
});
|
|
30106
30107
|
|
|
30107
30108
|
// src/auth/antigravity-token.ts
|
|
30109
|
+
var exports_antigravity_token = {};
|
|
30110
|
+
__export(exports_antigravity_token, {
|
|
30111
|
+
writeSharedAntigravityToken: () => writeSharedAntigravityToken,
|
|
30112
|
+
readSharedAntigravityToken: () => readSharedAntigravityToken,
|
|
30113
|
+
locateAgyBinary: () => locateAgyBinary,
|
|
30114
|
+
hasSharedAntigravityToken: () => hasSharedAntigravityToken,
|
|
30115
|
+
getValidAntigravityAccessToken: () => getValidAntigravityAccessToken,
|
|
30116
|
+
forceRefreshAntigravityToken: () => forceRefreshAntigravityToken,
|
|
30117
|
+
deleteSharedAntigravityToken: () => deleteSharedAntigravityToken,
|
|
30118
|
+
_resetAntigravityTokenState: () => _resetAntigravityTokenState
|
|
30119
|
+
});
|
|
30108
30120
|
import { execFileSync } from "child_process";
|
|
30109
30121
|
import { existsSync as existsSync7 } from "fs";
|
|
30110
30122
|
import { homedir as homedir9 } from "os";
|
|
@@ -30298,6 +30310,17 @@ var init_antigravity_token = __esm(() => {
|
|
|
30298
30310
|
});
|
|
30299
30311
|
|
|
30300
30312
|
// src/auth/antigravity-user.ts
|
|
30313
|
+
var exports_antigravity_user = {};
|
|
30314
|
+
__export(exports_antigravity_user, {
|
|
30315
|
+
setupAntigravityUser: () => setupAntigravityUser,
|
|
30316
|
+
retrieveUserQuota: () => retrieveUserQuota,
|
|
30317
|
+
resetAntigravityUserCache: () => resetAntigravityUserCache,
|
|
30318
|
+
getServedAntigravityModels: () => getServedAntigravityModels,
|
|
30319
|
+
getAntigravityTierFullName: () => getAntigravityTierFullName,
|
|
30320
|
+
getAntigravityTierDisplayName: () => getAntigravityTierDisplayName,
|
|
30321
|
+
buildAntigravityUserAgent: () => buildAntigravityUserAgent,
|
|
30322
|
+
_resetAntigravityServedModelsCache: () => _resetAntigravityServedModelsCache
|
|
30323
|
+
});
|
|
30301
30324
|
function makeTerminalSetupError(message) {
|
|
30302
30325
|
const err = new Error(message);
|
|
30303
30326
|
err.terminal = true;
|
|
@@ -30357,6 +30380,9 @@ function getAntigravityTierDisplayName() {
|
|
|
30357
30380
|
return "Antigravity Free";
|
|
30358
30381
|
return cachedAgTierName || "Antigravity";
|
|
30359
30382
|
}
|
|
30383
|
+
function getAntigravityTierFullName() {
|
|
30384
|
+
return cachedAgTierName || getAntigravityTierDisplayName();
|
|
30385
|
+
}
|
|
30360
30386
|
async function retrieveUserQuota(accessToken, projectId) {
|
|
30361
30387
|
try {
|
|
30362
30388
|
const res = await fetch(`${ANTIGRAVITY_API_BASE}:retrieveUserQuota`, {
|
|
@@ -30364,7 +30390,7 @@ async function retrieveUserQuota(accessToken, projectId) {
|
|
|
30364
30390
|
headers: {
|
|
30365
30391
|
Authorization: `Bearer ${accessToken}`,
|
|
30366
30392
|
"Content-Type": "application/json",
|
|
30367
|
-
"User-Agent":
|
|
30393
|
+
"User-Agent": buildAntigravityUserAgent()
|
|
30368
30394
|
},
|
|
30369
30395
|
body: JSON.stringify({ project: projectId })
|
|
30370
30396
|
});
|
|
@@ -30398,7 +30424,21 @@ async function getServedAntigravityModels(accessToken, projectId, opts) {
|
|
|
30398
30424
|
const servedIds = data.models ? Object.keys(data.models) : [];
|
|
30399
30425
|
const defaultId = typeof data.defaultAgentModelId === "string" ? data.defaultAgentModelId : null;
|
|
30400
30426
|
if (servedIds.length > 0) {
|
|
30401
|
-
|
|
30427
|
+
const meta3 = {};
|
|
30428
|
+
for (const [id, record4] of Object.entries(data.models ?? {})) {
|
|
30429
|
+
const entry = {};
|
|
30430
|
+
if (typeof record4?.maxTokens === "number" && record4.maxTokens > 0) {
|
|
30431
|
+
entry.contextWindow = record4.maxTokens;
|
|
30432
|
+
}
|
|
30433
|
+
if (typeof record4?.maxOutputTokens === "number" && record4.maxOutputTokens > 0) {
|
|
30434
|
+
entry.maxOutputTokens = record4.maxOutputTokens;
|
|
30435
|
+
}
|
|
30436
|
+
if (typeof record4?.displayName === "string" && record4.displayName) {
|
|
30437
|
+
entry.displayName = record4.displayName;
|
|
30438
|
+
}
|
|
30439
|
+
meta3[id] = entry;
|
|
30440
|
+
}
|
|
30441
|
+
agServedCache = { servedIds, defaultId, meta: meta3 };
|
|
30402
30442
|
agServedCacheAt = now;
|
|
30403
30443
|
return agServedCache;
|
|
30404
30444
|
}
|
|
@@ -30410,7 +30450,11 @@ async function getServedAntigravityModels(accessToken, projectId, opts) {
|
|
|
30410
30450
|
}
|
|
30411
30451
|
if (agServedCache)
|
|
30412
30452
|
return agServedCache;
|
|
30413
|
-
return { servedIds: [], defaultId: null };
|
|
30453
|
+
return { servedIds: [], defaultId: null, meta: {} };
|
|
30454
|
+
}
|
|
30455
|
+
function _resetAntigravityServedModelsCache() {
|
|
30456
|
+
agServedCache = null;
|
|
30457
|
+
agServedCacheAt = 0;
|
|
30414
30458
|
}
|
|
30415
30459
|
var ANTIGRAVITY_API_BASE = "https://cloudcode-pa.googleapis.com/v1internal", SERVED_MODELS_TTL_MS, ANTIGRAVITY_IDE_TYPE = "ANTIGRAVITY", cachedAgProjectId = null, cachedAgTierId = null, cachedAgTierName = null, agServedCache = null, agServedCacheAt = 0;
|
|
30416
30460
|
var init_antigravity_user = __esm(() => {
|
|
@@ -32142,6 +32186,10 @@ async function resolveGrokClientVersion() {
|
|
|
32142
32186
|
} catch {}
|
|
32143
32187
|
return FALLBACK_GROK_CLIENT_VERSION;
|
|
32144
32188
|
}
|
|
32189
|
+
function readGrokProxyUrl() {
|
|
32190
|
+
const fromEnv = process.env[GROK_PROXY_URL_ENV]?.trim();
|
|
32191
|
+
return (fromEnv || DEFAULT_GROK_PROXY_URL).replace(/\/+$/, "");
|
|
32192
|
+
}
|
|
32145
32193
|
function grokAuthHeaders(token, version2 = readGrokClientVersion()) {
|
|
32146
32194
|
return {
|
|
32147
32195
|
Authorization: `Bearer ${token}`,
|
|
@@ -32254,7 +32302,7 @@ function refreshShared(cred) {
|
|
|
32254
32302
|
}
|
|
32255
32303
|
return refreshInFlight;
|
|
32256
32304
|
}
|
|
32257
|
-
var GROK_CLIENT_IDENTIFIER = "grok-shell", FALLBACK_GROK_CLIENT_VERSION = "1.0.4", LEGACY_SCOPE = "https://accounts.x.ai/sign-in", EXPIRY_SKEW_MS2, grokHomeOverride = null, claudishOAuthPathOverride = null, GROK_CHANNEL_URL = "https://x.ai/cli/stable", liveClientVersion = null, SIGN_IN_HINT, refreshInFlight = null;
|
|
32305
|
+
var GROK_PROXY_URL_ENV = "GROK_PROXY_URL", DEFAULT_GROK_PROXY_URL = "https://cli-chat-proxy.grok.com/v1", GROK_CLIENT_IDENTIFIER = "grok-shell", FALLBACK_GROK_CLIENT_VERSION = "1.0.4", LEGACY_SCOPE = "https://accounts.x.ai/sign-in", EXPIRY_SKEW_MS2, grokHomeOverride = null, claudishOAuthPathOverride = null, GROK_CHANNEL_URL = "https://x.ai/cli/stable", liveClientVersion = null, SIGN_IN_HINT, refreshInFlight = null;
|
|
32258
32306
|
var init_grok_credentials = __esm(() => {
|
|
32259
32307
|
init_grok_oauth();
|
|
32260
32308
|
EXPIRY_SKEW_MS2 = 5 * 60 * 1000;
|
|
@@ -32976,15 +33024,22 @@ function validateVertexOAuthConfig() {
|
|
|
32976
33024
|
}
|
|
32977
33025
|
return null;
|
|
32978
33026
|
}
|
|
33027
|
+
function vertexApiHost(location) {
|
|
33028
|
+
if (location === "global")
|
|
33029
|
+
return "aiplatform.googleapis.com";
|
|
33030
|
+
if (location === "eu")
|
|
33031
|
+
return "aiplatform.eu.rep.googleapis.com";
|
|
33032
|
+
return `${location}-aiplatform.googleapis.com`;
|
|
33033
|
+
}
|
|
32979
33034
|
function buildVertexOAuthEndpoint(config2, publisher, model, streaming = true) {
|
|
32980
33035
|
const method = streaming ? "streamGenerateContent" : "generateContent";
|
|
32981
33036
|
if (publisher === "google") {
|
|
32982
33037
|
const sseParam = streaming ? "?alt=sse" : "";
|
|
32983
|
-
return `https://${config2.location}
|
|
33038
|
+
return `https://${vertexApiHost(config2.location)}/v1/` + `projects/${config2.projectId}/locations/${config2.location}/` + `publishers/${publisher}/models/${model}:${method}${sseParam}`;
|
|
32984
33039
|
}
|
|
32985
33040
|
if (publisher === "mistralai") {
|
|
32986
33041
|
const mistralMethod = streaming ? "streamRawPredict" : "rawPredict";
|
|
32987
|
-
return `https://${config2.location}
|
|
33042
|
+
return `https://${vertexApiHost(config2.location)}/v1/` + `projects/${config2.projectId}/locations/${config2.location}/` + `publishers/mistralai/models/${model}:${mistralMethod}`;
|
|
32988
33043
|
}
|
|
32989
33044
|
return `https://aiplatform.googleapis.com/v1/projects/${config2.projectId}/locations/global/endpoints/openapi/chat/completions`;
|
|
32990
33045
|
}
|
|
@@ -35268,39 +35323,17 @@ var init_xiaomi_model_dialect = __esm(() => {
|
|
|
35268
35323
|
// src/adapters/dialect-manager.ts
|
|
35269
35324
|
var exports_dialect_manager = {};
|
|
35270
35325
|
__export(exports_dialect_manager, {
|
|
35271
|
-
|
|
35272
|
-
AdapterManager: () => DialectManager
|
|
35326
|
+
resolveModelDialect: () => resolveModelDialect
|
|
35273
35327
|
});
|
|
35274
|
-
|
|
35275
|
-
|
|
35276
|
-
|
|
35277
|
-
|
|
35278
|
-
|
|
35279
|
-
this.adapters = [
|
|
35280
|
-
new GrokModelDialect(modelId, wireFormat),
|
|
35281
|
-
new GeminiAPIFormat(modelId, wireFormat),
|
|
35282
|
-
new CodexAPIFormat(modelId, wireFormat),
|
|
35283
|
-
new OpenAIAPIFormat(modelId, wireFormat),
|
|
35284
|
-
new QwenModelDialect(modelId, wireFormat),
|
|
35285
|
-
new MiniMaxModelDialect(modelId, wireFormat),
|
|
35286
|
-
new DeepSeekModelDialect(modelId, wireFormat),
|
|
35287
|
-
new GLMModelDialect(modelId, wireFormat),
|
|
35288
|
-
new XiaomiModelDialect(modelId, wireFormat)
|
|
35289
|
-
];
|
|
35290
|
-
this.defaultAdapter = new DefaultAPIFormat(modelId, wireFormat);
|
|
35291
|
-
}
|
|
35292
|
-
getAdapter() {
|
|
35293
|
-
for (const adapter of this.adapters) {
|
|
35294
|
-
if (adapter.shouldHandle(this.defaultAdapter.getModelId())) {
|
|
35295
|
-
return adapter;
|
|
35296
|
-
}
|
|
35297
|
-
}
|
|
35298
|
-
return this.defaultAdapter;
|
|
35299
|
-
}
|
|
35300
|
-
needsTransformation() {
|
|
35301
|
-
return this.getAdapter() !== this.defaultAdapter;
|
|
35328
|
+
function resolveModelDialect(modelId, wireFormat) {
|
|
35329
|
+
for (const make of DIALECT_FACTORIES) {
|
|
35330
|
+
const dialect = make(modelId, wireFormat);
|
|
35331
|
+
if (dialect.shouldHandle(modelId))
|
|
35332
|
+
return dialect;
|
|
35302
35333
|
}
|
|
35334
|
+
return new DefaultAPIFormat(modelId, wireFormat);
|
|
35303
35335
|
}
|
|
35336
|
+
var DIALECT_FACTORIES;
|
|
35304
35337
|
var init_dialect_manager = __esm(() => {
|
|
35305
35338
|
init_base_api_format();
|
|
35306
35339
|
init_codex_api_format();
|
|
@@ -35312,6 +35345,17 @@ var init_dialect_manager = __esm(() => {
|
|
|
35312
35345
|
init_openai_api_format();
|
|
35313
35346
|
init_qwen_model_dialect();
|
|
35314
35347
|
init_xiaomi_model_dialect();
|
|
35348
|
+
DIALECT_FACTORIES = [
|
|
35349
|
+
(m, w) => new GrokModelDialect(m, w),
|
|
35350
|
+
(m, w) => new GeminiAPIFormat(m, w),
|
|
35351
|
+
(m, w) => new CodexAPIFormat(m, w),
|
|
35352
|
+
(m, w) => new OpenAIAPIFormat(m, w),
|
|
35353
|
+
(m, w) => new QwenModelDialect(m, w),
|
|
35354
|
+
(m, w) => new MiniMaxModelDialect(m, w),
|
|
35355
|
+
(m, w) => new DeepSeekModelDialect(m, w),
|
|
35356
|
+
(m, w) => new GLMModelDialect(m, w),
|
|
35357
|
+
(m, w) => new XiaomiModelDialect(m, w)
|
|
35358
|
+
];
|
|
35315
35359
|
});
|
|
35316
35360
|
|
|
35317
35361
|
// src/auth/quota/types.ts
|
|
@@ -35379,6 +35423,27 @@ function windowFromBucket(bucket) {
|
|
|
35379
35423
|
}
|
|
35380
35424
|
return window2;
|
|
35381
35425
|
}
|
|
35426
|
+
function parseModelVersion(modelId) {
|
|
35427
|
+
const match = modelId.match(/(?:^|-)(\d+(?:[.-]\d+)*)(?![0-9a-z])/i);
|
|
35428
|
+
if (!match)
|
|
35429
|
+
return;
|
|
35430
|
+
const [major, minor] = match[1].split(/[.-]/);
|
|
35431
|
+
const value = Number(`${major}.${(minor ?? "0").slice(0, 3)}`);
|
|
35432
|
+
return Number.isFinite(value) ? value : undefined;
|
|
35433
|
+
}
|
|
35434
|
+
function compareModelRecency(a, b) {
|
|
35435
|
+
const va = parseModelVersion(a.id);
|
|
35436
|
+
const vb = parseModelVersion(b.id);
|
|
35437
|
+
if (va === undefined && vb === undefined)
|
|
35438
|
+
return a.id.localeCompare(b.id);
|
|
35439
|
+
if (va === undefined)
|
|
35440
|
+
return 1;
|
|
35441
|
+
if (vb === undefined)
|
|
35442
|
+
return -1;
|
|
35443
|
+
if (vb !== va)
|
|
35444
|
+
return vb - va;
|
|
35445
|
+
return a.id.localeCompare(b.id);
|
|
35446
|
+
}
|
|
35382
35447
|
function planFromBuckets(buckets, activeModelId) {
|
|
35383
35448
|
const windows = [];
|
|
35384
35449
|
if (activeModelId) {
|
|
@@ -35394,6 +35459,7 @@ function planFromBuckets(buckets, activeModelId) {
|
|
|
35394
35459
|
if (w)
|
|
35395
35460
|
windows.push(w);
|
|
35396
35461
|
}
|
|
35462
|
+
windows.sort(compareModelRecency);
|
|
35397
35463
|
}
|
|
35398
35464
|
if (windows.length === 0)
|
|
35399
35465
|
return;
|
|
@@ -35612,6 +35678,106 @@ var init_codex = __esm(() => {
|
|
|
35612
35678
|
};
|
|
35613
35679
|
});
|
|
35614
35680
|
|
|
35681
|
+
// src/auth/quota/sources/grok.ts
|
|
35682
|
+
function periodLabel(type) {
|
|
35683
|
+
switch (type) {
|
|
35684
|
+
case "USAGE_PERIOD_TYPE_WEEKLY":
|
|
35685
|
+
return "7d";
|
|
35686
|
+
case "USAGE_PERIOD_TYPE_DAILY":
|
|
35687
|
+
return "24h";
|
|
35688
|
+
case "USAGE_PERIOD_TYPE_MONTHLY":
|
|
35689
|
+
return "30d";
|
|
35690
|
+
default:
|
|
35691
|
+
if (!type)
|
|
35692
|
+
return "period";
|
|
35693
|
+
return type.replace(/^USAGE_PERIOD_TYPE_/, "").toLowerCase() || "period";
|
|
35694
|
+
}
|
|
35695
|
+
}
|
|
35696
|
+
function windowsFromBilling(config2) {
|
|
35697
|
+
const resetsAt = config2.currentPeriod?.end ?? config2.billingPeriodEnd;
|
|
35698
|
+
const label = periodLabel(config2.currentPeriod?.type);
|
|
35699
|
+
const windows = [];
|
|
35700
|
+
for (const entry of config2.productUsage ?? []) {
|
|
35701
|
+
if (typeof entry?.usagePercent !== "number" || !entry.product)
|
|
35702
|
+
continue;
|
|
35703
|
+
const used = toUsedPct(entry.usagePercent);
|
|
35704
|
+
if (used === undefined)
|
|
35705
|
+
continue;
|
|
35706
|
+
const w = { id: entry.product, used_pct: used };
|
|
35707
|
+
if (resetsAt)
|
|
35708
|
+
w.resets_at = resetsAt;
|
|
35709
|
+
windows.push(w);
|
|
35710
|
+
}
|
|
35711
|
+
if (windows.length === 0 && typeof config2.creditUsagePercent === "number") {
|
|
35712
|
+
const used = toUsedPct(config2.creditUsagePercent);
|
|
35713
|
+
if (used !== undefined) {
|
|
35714
|
+
const w = { id: label, used_pct: used };
|
|
35715
|
+
if (resetsAt)
|
|
35716
|
+
w.resets_at = resetsAt;
|
|
35717
|
+
windows.push(w);
|
|
35718
|
+
}
|
|
35719
|
+
}
|
|
35720
|
+
return windows;
|
|
35721
|
+
}
|
|
35722
|
+
async function fetchPlan2() {
|
|
35723
|
+
try {
|
|
35724
|
+
const [token, version2] = await Promise.all([
|
|
35725
|
+
resolveGrokAccessToken(),
|
|
35726
|
+
resolveGrokClientVersion()
|
|
35727
|
+
]);
|
|
35728
|
+
const res = await fetch(`${readGrokProxyUrl()}${BILLING_PATH}`, {
|
|
35729
|
+
method: "GET",
|
|
35730
|
+
headers: grokAuthHeaders(token, version2)
|
|
35731
|
+
});
|
|
35732
|
+
if (!res.ok) {
|
|
35733
|
+
log(`[quota:grok] billing fetch failed: ${res.status}`);
|
|
35734
|
+
return;
|
|
35735
|
+
}
|
|
35736
|
+
const body = await res.json();
|
|
35737
|
+
const config2 = body?.config;
|
|
35738
|
+
if (!config2)
|
|
35739
|
+
return;
|
|
35740
|
+
const windows = windowsFromBilling(config2);
|
|
35741
|
+
if (windows.length === 0)
|
|
35742
|
+
return;
|
|
35743
|
+
return {
|
|
35744
|
+
label: "Grok Build",
|
|
35745
|
+
windows,
|
|
35746
|
+
source: "provider",
|
|
35747
|
+
observed_at: new Date().toISOString()
|
|
35748
|
+
};
|
|
35749
|
+
} catch (err) {
|
|
35750
|
+
log(`[quota:grok] billing fetch error: ${err}`);
|
|
35751
|
+
return;
|
|
35752
|
+
}
|
|
35753
|
+
}
|
|
35754
|
+
var BILLING_PATH = "/billing?format=credits", grokQuotaAdapter;
|
|
35755
|
+
var init_grok = __esm(() => {
|
|
35756
|
+
init_logger();
|
|
35757
|
+
init_grok_credentials();
|
|
35758
|
+
init_types2();
|
|
35759
|
+
grokQuotaAdapter = {
|
|
35760
|
+
providerId: "grok-subscription",
|
|
35761
|
+
label: "Grok Build",
|
|
35762
|
+
capability() {
|
|
35763
|
+
return { kind: "endpoint" };
|
|
35764
|
+
},
|
|
35765
|
+
isAvailable() {
|
|
35766
|
+
try {
|
|
35767
|
+
return hasGrokCredentials();
|
|
35768
|
+
} catch {
|
|
35769
|
+
return false;
|
|
35770
|
+
}
|
|
35771
|
+
},
|
|
35772
|
+
poll(_ctx) {
|
|
35773
|
+
return fetchPlan2();
|
|
35774
|
+
},
|
|
35775
|
+
fetchExplicit(_ctx) {
|
|
35776
|
+
return fetchPlan2();
|
|
35777
|
+
}
|
|
35778
|
+
};
|
|
35779
|
+
});
|
|
35780
|
+
|
|
35615
35781
|
// src/auth/quota/registry.ts
|
|
35616
35782
|
function unsupported(providerId, label, evidence) {
|
|
35617
35783
|
return {
|
|
@@ -35635,6 +35801,7 @@ var PROBED_ON = "2026-08-05", NO_SURFACE, ADAPTERS, BY_ID;
|
|
|
35635
35801
|
var init_registry = __esm(() => {
|
|
35636
35802
|
init_antigravity2();
|
|
35637
35803
|
init_codex();
|
|
35804
|
+
init_grok();
|
|
35638
35805
|
NO_SURFACE = [
|
|
35639
35806
|
{
|
|
35640
35807
|
id: "glm-coding",
|
|
@@ -35764,6 +35931,7 @@ var init_registry = __esm(() => {
|
|
|
35764
35931
|
ADAPTERS = [
|
|
35765
35932
|
codexQuotaAdapter,
|
|
35766
35933
|
antigravityQuotaAdapter,
|
|
35934
|
+
grokQuotaAdapter,
|
|
35767
35935
|
...NO_SURFACE.map((p) => unsupported(p.id, p.label, p.evidence))
|
|
35768
35936
|
];
|
|
35769
35937
|
BY_ID = new Map(ADAPTERS.map((a) => [a.providerId, a]));
|
|
@@ -37534,6 +37702,9 @@ class OpenAIProviderTransport {
|
|
|
37534
37702
|
}
|
|
37535
37703
|
return `${this.provider.baseUrl}${this.provider.apiPath}`;
|
|
37536
37704
|
}
|
|
37705
|
+
overrideStreamFormat() {
|
|
37706
|
+
return this.provider.streamFormatOverride;
|
|
37707
|
+
}
|
|
37537
37708
|
async getHeaders() {
|
|
37538
37709
|
const headers = {};
|
|
37539
37710
|
if (this.apiKey) {
|
|
@@ -39867,6 +40038,44 @@ data: {"type":"ping"}
|
|
|
39867
40038
|
let insideThinkingBlock = false;
|
|
39868
40039
|
let thinkingBlocksSuppressed = 0;
|
|
39869
40040
|
let suppressedFrame = false;
|
|
40041
|
+
let highestSeenIndex = -1;
|
|
40042
|
+
const remappedBlocks = new Map;
|
|
40043
|
+
const trackIndex = (idx) => {
|
|
40044
|
+
if (idx > highestSeenIndex)
|
|
40045
|
+
highestSeenIndex = idx;
|
|
40046
|
+
};
|
|
40047
|
+
const emitIndexed = (controller2, data, line) => {
|
|
40048
|
+
if (typeof data.index !== "number") {
|
|
40049
|
+
enqueueData(controller2, data, line);
|
|
40050
|
+
return;
|
|
40051
|
+
}
|
|
40052
|
+
if (data.type === "content_block_start") {
|
|
40053
|
+
const expected = highestSeenIndex + 1;
|
|
40054
|
+
if (data.index !== expected) {
|
|
40055
|
+
log(`[AnthropicSSE] content_block_start index ${data.index} remapped to ${expected} (model=${opts.modelName})`);
|
|
40056
|
+
remappedBlocks.set(data.index, expected);
|
|
40057
|
+
const remapped2 = { ...data, index: expected };
|
|
40058
|
+
enqueueData(controller2, remapped2, `data: ${JSON.stringify(remapped2)}`);
|
|
40059
|
+
} else {
|
|
40060
|
+
enqueueData(controller2, data, line);
|
|
40061
|
+
}
|
|
40062
|
+
trackIndex(expected);
|
|
40063
|
+
return;
|
|
40064
|
+
}
|
|
40065
|
+
const remapped = remappedBlocks.get(data.index);
|
|
40066
|
+
if (data.type === "content_block_stop")
|
|
40067
|
+
remappedBlocks.delete(data.index);
|
|
40068
|
+
if (remapped !== undefined) {
|
|
40069
|
+
const modified = { ...data, index: remapped };
|
|
40070
|
+
enqueueData(controller2, modified, `data: ${JSON.stringify(modified)}`);
|
|
40071
|
+
} else if (data.index > highestSeenIndex) {
|
|
40072
|
+
log(`[AnthropicSSE] Dropping orphan ${data.type} at index ${data.index} (no open block \u2014 model=${opts.modelName})`);
|
|
40073
|
+
pendingEventLine = null;
|
|
40074
|
+
suppressedFrame = true;
|
|
40075
|
+
} else {
|
|
40076
|
+
enqueueData(controller2, data, line);
|
|
40077
|
+
}
|
|
40078
|
+
};
|
|
39870
40079
|
while (true) {
|
|
39871
40080
|
const { done, value } = await reader.read();
|
|
39872
40081
|
if (done)
|
|
@@ -39921,18 +40130,7 @@ data: ${JSON.stringify({
|
|
|
39921
40130
|
suppressedFrame = true;
|
|
39922
40131
|
continue;
|
|
39923
40132
|
}
|
|
39924
|
-
|
|
39925
|
-
const reindexed = data.index - thinkingBlocksSuppressed;
|
|
39926
|
-
const modifiedLine = `data: ${JSON.stringify({ ...data, index: reindexed })}`;
|
|
39927
|
-
if (!isClosed) {
|
|
39928
|
-
flushPendingEvent(controller);
|
|
39929
|
-
controller.enqueue(encoder.encode(`${modifiedLine}
|
|
39930
|
-
`));
|
|
39931
|
-
noteLifecycle(data, reindexed);
|
|
39932
|
-
}
|
|
39933
|
-
} else {
|
|
39934
|
-
enqueueData(controller, data, line);
|
|
39935
|
-
}
|
|
40133
|
+
emitIndexed(controller, data, line);
|
|
39936
40134
|
} catch {
|
|
39937
40135
|
if (!isClosed) {
|
|
39938
40136
|
flushPendingEvent(controller);
|
|
@@ -39964,47 +40162,44 @@ data: ${JSON.stringify({
|
|
|
39964
40162
|
}
|
|
39965
40163
|
return;
|
|
39966
40164
|
}
|
|
39967
|
-
|
|
39968
|
-
|
|
39969
|
-
|
|
39970
|
-
|
|
39971
|
-
|
|
39972
|
-
|
|
39973
|
-
|
|
39974
|
-
|
|
39975
|
-
|
|
39976
|
-
|
|
39977
|
-
|
|
39978
|
-
|
|
39979
|
-
|
|
39980
|
-
|
|
39981
|
-
|
|
39982
|
-
|
|
39983
|
-
|
|
39984
|
-
|
|
39985
|
-
|
|
39986
|
-
|
|
39987
|
-
|
|
39988
|
-
|
|
39989
|
-
|
|
40165
|
+
emitIndexed(controller, data, line);
|
|
40166
|
+
try {
|
|
40167
|
+
if (data.message?.usage) {
|
|
40168
|
+
inputTokens = data.message.usage.input_tokens || inputTokens;
|
|
40169
|
+
outputTokens = data.message.usage.output_tokens || outputTokens;
|
|
40170
|
+
}
|
|
40171
|
+
if (data.usage) {
|
|
40172
|
+
inputTokens = data.usage.input_tokens || inputTokens;
|
|
40173
|
+
outputTokens = data.usage.output_tokens || outputTokens;
|
|
40174
|
+
}
|
|
40175
|
+
if (data.type === "content_block_delta" && data.delta?.type === "text_delta") {
|
|
40176
|
+
const txt = data.delta.text || "";
|
|
40177
|
+
opts.onAssistantText?.(txt, "text");
|
|
40178
|
+
textChunks++;
|
|
40179
|
+
log(`[AnthropicSSE] Text chunk: "${txt.substring(0, 30).replace(/\n/g, "\\n")}" (${txt.length} chars)`);
|
|
40180
|
+
}
|
|
40181
|
+
if (data.type === "content_block_start" && data.content_block?.type === "tool_use") {
|
|
40182
|
+
toolUseBlocks++;
|
|
40183
|
+
opts.onToolCallObserved?.(data.content_block.name);
|
|
40184
|
+
log(`[AnthropicSSE] Tool use: ${data.content_block.name}`);
|
|
40185
|
+
}
|
|
40186
|
+
if (data.type === "message_delta" && data.delta?.stop_reason) {
|
|
40187
|
+
stopReason = data.delta.stop_reason;
|
|
40188
|
+
}
|
|
40189
|
+
} catch {}
|
|
39990
40190
|
} catch {
|
|
39991
40191
|
if (!isClosed) {
|
|
39992
40192
|
controller.enqueue(encoder.encode(`${line}
|
|
39993
40193
|
`));
|
|
39994
40194
|
}
|
|
39995
40195
|
}
|
|
39996
|
-
} else
|
|
40196
|
+
} else {
|
|
39997
40197
|
if (line.startsWith("event:")) {
|
|
39998
40198
|
pendingEventLine = line;
|
|
39999
40199
|
} else if (line.trim() === "" && suppressedFrame) {
|
|
40000
40200
|
suppressedFrame = false;
|
|
40001
40201
|
} else if (!isClosed) {
|
|
40002
40202
|
controller.enqueue(encoder.encode(`${line}
|
|
40003
|
-
`));
|
|
40004
|
-
}
|
|
40005
|
-
} else {
|
|
40006
|
-
if (!isClosed) {
|
|
40007
|
-
controller.enqueue(encoder.encode(`${line}
|
|
40008
40203
|
`));
|
|
40009
40204
|
}
|
|
40010
40205
|
}
|
|
@@ -41484,7 +41679,7 @@ function extractAuthHeaders(c) {
|
|
|
41484
41679
|
|
|
41485
41680
|
class ComposedHandler {
|
|
41486
41681
|
provider;
|
|
41487
|
-
|
|
41682
|
+
resolvedDialect;
|
|
41488
41683
|
explicitAdapter;
|
|
41489
41684
|
modelAdapter;
|
|
41490
41685
|
middlewareManager;
|
|
@@ -41506,8 +41701,8 @@ class ComposedHandler {
|
|
|
41506
41701
|
this.options = options;
|
|
41507
41702
|
this.explicitAdapter = options.adapter;
|
|
41508
41703
|
this.isInteractive = options.isInteractive ?? false;
|
|
41509
|
-
this.
|
|
41510
|
-
const resolvedModelAdapter = this.
|
|
41704
|
+
this.resolvedDialect = resolveModelDialect(this.bareModelName, this.explicitAdapter?.getStreamFormat());
|
|
41705
|
+
const resolvedModelAdapter = this.resolvedDialect;
|
|
41511
41706
|
if (resolvedModelAdapter.getName() !== "DefaultAPIFormat") {
|
|
41512
41707
|
this.modelAdapter = resolvedModelAdapter;
|
|
41513
41708
|
}
|
|
@@ -41525,7 +41720,7 @@ class ComposedHandler {
|
|
|
41525
41720
|
});
|
|
41526
41721
|
}
|
|
41527
41722
|
getAdapter() {
|
|
41528
|
-
return this.explicitAdapter || this.
|
|
41723
|
+
return this.explicitAdapter || this.resolvedDialect;
|
|
41529
41724
|
}
|
|
41530
41725
|
getModelContextWindow() {
|
|
41531
41726
|
return this.modelAdapter?.getContextWindow() ?? this.getAdapter().getContextWindow();
|
|
@@ -43020,6 +43215,27 @@ async function discoverProviderModels(providerName) {
|
|
|
43020
43215
|
_cache.set(providerName, { models: models2, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
43021
43216
|
return models2;
|
|
43022
43217
|
}
|
|
43218
|
+
if (descriptor.format === "antigravity") {
|
|
43219
|
+
const { getValidAntigravityAccessToken: getValidAntigravityAccessToken2 } = await Promise.resolve().then(() => (init_antigravity_token(), exports_antigravity_token));
|
|
43220
|
+
const { setupAntigravityUser: setupAntigravityUser2, getServedAntigravityModels: getServedAntigravityModels2 } = await Promise.resolve().then(() => (init_antigravity_user(), exports_antigravity_user));
|
|
43221
|
+
const token = await getValidAntigravityAccessToken2();
|
|
43222
|
+
if (!token) {
|
|
43223
|
+
return recordFailure({ kind: "no-credentials", provider: providerName });
|
|
43224
|
+
}
|
|
43225
|
+
const { projectId } = await setupAntigravityUser2(token);
|
|
43226
|
+
const { servedIds, meta: meta3 } = await getServedAntigravityModels2(token, projectId);
|
|
43227
|
+
if (servedIds.length === 0) {
|
|
43228
|
+
return recordFailure({ kind: "empty-roster", provider: providerName });
|
|
43229
|
+
}
|
|
43230
|
+
const models2 = servedIds.map((id) => {
|
|
43231
|
+
const m = meta3[id];
|
|
43232
|
+
return m?.contextWindow ? { id, contextWindow: m.contextWindow } : { id };
|
|
43233
|
+
});
|
|
43234
|
+
_failures.delete(providerName);
|
|
43235
|
+
log(`[model-discovery:${providerName}] discovered ${models2.length} models`);
|
|
43236
|
+
_cache.set(providerName, { models: models2, expiresAt: Date.now() + CACHE_TTL_MS });
|
|
43237
|
+
return models2;
|
|
43238
|
+
}
|
|
43023
43239
|
if (descriptor.format === "ollama-tags") {
|
|
43024
43240
|
const { fetchOllamaModels: fetchOllamaModels2 } = await Promise.resolve().then(() => exports_ollama_discovery);
|
|
43025
43241
|
const installed = await fetchOllamaModels2({ enrichCapabilities: false });
|
|
@@ -43484,6 +43700,9 @@ class AnthropicProviderTransport {
|
|
|
43484
43700
|
getEndpoint() {
|
|
43485
43701
|
return `${this.provider.baseUrl}${this.provider.apiPath}`;
|
|
43486
43702
|
}
|
|
43703
|
+
overrideStreamFormat() {
|
|
43704
|
+
return this.provider.streamFormatOverride;
|
|
43705
|
+
}
|
|
43487
43706
|
async getHeaders() {
|
|
43488
43707
|
const headers = {
|
|
43489
43708
|
"anthropic-version": "2023-06-01"
|
|
@@ -43830,7 +44049,8 @@ function buildComplexHandler(ep, ctx, apiKey, baseUrl) {
|
|
|
43830
44049
|
apiKeyEnvVar: ctx.provider.apiKeyEnvVar,
|
|
43831
44050
|
prefixes: ctx.provider.prefixes ?? [],
|
|
43832
44051
|
headers: ep.headers,
|
|
43833
|
-
authScheme: ep.authScheme ?? "bearer"
|
|
44052
|
+
authScheme: ep.authScheme ?? "bearer",
|
|
44053
|
+
streamFormatOverride: ep.streamFormat
|
|
43834
44054
|
};
|
|
43835
44055
|
const transport = new OpenAIProviderTransport(remoteProvider, finalModel, apiKey);
|
|
43836
44056
|
const adapter = new OpenAIAPIFormat(finalModel);
|
|
@@ -43848,7 +44068,8 @@ function buildComplexHandler(ep, ctx, apiKey, baseUrl) {
|
|
|
43848
44068
|
apiKeyEnvVar: ctx.provider.apiKeyEnvVar,
|
|
43849
44069
|
prefixes: ctx.provider.prefixes ?? [],
|
|
43850
44070
|
headers: ep.headers,
|
|
43851
|
-
authScheme: ep.authScheme ?? "x-api-key"
|
|
44071
|
+
authScheme: ep.authScheme ?? "x-api-key",
|
|
44072
|
+
streamFormatOverride: ep.streamFormat
|
|
43852
44073
|
};
|
|
43853
44074
|
const transport = new AnthropicProviderTransport(remoteProvider, apiKey);
|
|
43854
44075
|
const adapter = new AnthropicAPIFormat(finalModel, ctx.provider.name);
|
|
@@ -48066,8 +48287,7 @@ var init_local_adapter = __esm(() => {
|
|
|
48066
48287
|
constructor(modelId, providerName) {
|
|
48067
48288
|
super(modelId);
|
|
48068
48289
|
this.providerName = providerName;
|
|
48069
|
-
|
|
48070
|
-
this.innerAdapter = manager.getAdapter();
|
|
48290
|
+
this.innerAdapter = resolveModelDialect(modelId);
|
|
48071
48291
|
}
|
|
48072
48292
|
processTextContent(textContent, accumulatedText) {
|
|
48073
48293
|
return this.innerAdapter.processTextContent(textContent, accumulatedText);
|
|
@@ -48235,8 +48455,7 @@ var init_openrouter_api_format = __esm(() => {
|
|
|
48235
48455
|
innerAdapter;
|
|
48236
48456
|
constructor(modelId) {
|
|
48237
48457
|
super(modelId);
|
|
48238
|
-
|
|
48239
|
-
this.innerAdapter = manager.getAdapter();
|
|
48458
|
+
this.innerAdapter = resolveModelDialect(modelId);
|
|
48240
48459
|
}
|
|
48241
48460
|
modelSupportsReasoning() {
|
|
48242
48461
|
const id = this.modelId.toLowerCase();
|
|
@@ -67258,12 +67477,16 @@ function renderPlan(adapter, plan) {
|
|
|
67258
67477
|
console.log("");
|
|
67259
67478
|
console.log(` ${peakColor}${B}${peak}%${R} ${D}peak usage across ${plan.windows.length} window${plan.windows.length === 1 ? "" : "s"}${R}`);
|
|
67260
67479
|
console.log("");
|
|
67480
|
+
const NAME_MIN = 14;
|
|
67481
|
+
const NAME_MAX = 28;
|
|
67482
|
+
const widest = plan.windows.reduce((m, w) => Math.max(m, w.id.length), 0);
|
|
67483
|
+
const nameWidth = Math.min(NAME_MAX, Math.max(NAME_MIN, widest + 1));
|
|
67261
67484
|
for (const w of plan.windows) {
|
|
67262
67485
|
const color = colorFor(w.used_pct);
|
|
67263
67486
|
const bar = buildUsageBar(w.used_pct / 100, color, 24);
|
|
67264
67487
|
const reset = w.resets_at ? formatRelativeReset(w.resets_at) : "";
|
|
67265
|
-
const name = w.id.length >
|
|
67266
|
-
console.log(` ${GRY}\u2502${R} ${WHT}${name.padEnd(
|
|
67488
|
+
const name = w.id.length > nameWidth ? `${w.id.slice(0, nameWidth - 1)}\u2026` : w.id;
|
|
67489
|
+
console.log(` ${GRY}\u2502${R} ${WHT}${name.padEnd(nameWidth)}${R}${bar} ${color}${String(w.used_pct).padStart(3)}%${R} ${GRY}${I}${reset}${R}`);
|
|
67267
67490
|
}
|
|
67268
67491
|
console.log("");
|
|
67269
67492
|
console.log(` ${GRN}\u2588${R}${GRY} <50%${R} ${YEL}\u2588${R}${GRY} 50-80%${R} ${RED}\u2588${R}${GRY} >80%${R} ${D}\u2591 available${R}`);
|
|
@@ -67351,7 +67574,9 @@ var init_quota_command = __esm(() => {
|
|
|
67351
67574
|
sakana: "sakana-subscription",
|
|
67352
67575
|
fugu: "sakana-subscription",
|
|
67353
67576
|
zen: "opencode-zen-go",
|
|
67354
|
-
qwen: "qwen-cloud"
|
|
67577
|
+
qwen: "qwen-cloud",
|
|
67578
|
+
grok: "grok-subscription",
|
|
67579
|
+
supergrok: "grok-subscription"
|
|
67355
67580
|
};
|
|
67356
67581
|
});
|
|
67357
67582
|
|
|
@@ -72075,9 +72300,8 @@ async function probeModelRouting(models, jsonOutput, options = { live: true, tim
|
|
|
72075
72300
|
formatAdapterName = "OpenAIAPIFormat";
|
|
72076
72301
|
declaredStreamFormat = "openai-sse";
|
|
72077
72302
|
}
|
|
72078
|
-
const {
|
|
72079
|
-
const
|
|
72080
|
-
const modelTranslator = adapterManager.getAdapter();
|
|
72303
|
+
const { resolveModelDialect: resolveModelDialect2 } = await Promise.resolve().then(() => (init_dialect_manager(), exports_dialect_manager));
|
|
72304
|
+
const modelTranslator = resolveModelDialect2(modelName);
|
|
72081
72305
|
const modelTranslatorName = modelTranslator.getName();
|
|
72082
72306
|
const TRANSPORT_OVERRIDES = {
|
|
72083
72307
|
litellm: "openai-sse",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudish",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.56.0",
|
|
4
4
|
"description": "Run Claude Code with any model - OpenRouter, Ollama, LM Studio & local models",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"ai"
|
|
61
61
|
],
|
|
62
62
|
"optionalDependencies": {
|
|
63
|
-
"@claudish/magmux-darwin-arm64": "7.
|
|
64
|
-
"@claudish/magmux-darwin-x64": "7.
|
|
65
|
-
"@claudish/magmux-linux-arm64": "7.
|
|
66
|
-
"@claudish/magmux-linux-x64": "7.
|
|
63
|
+
"@claudish/magmux-darwin-arm64": "7.56.0",
|
|
64
|
+
"@claudish/magmux-darwin-x64": "7.56.0",
|
|
65
|
+
"@claudish/magmux-linux-arm64": "7.56.0",
|
|
66
|
+
"@claudish/magmux-linux-x64": "7.56.0"
|
|
67
67
|
},
|
|
68
68
|
"author": "Jack Rudenko <i@madappgang.com>",
|
|
69
69
|
"license": "MIT",
|