claudish 7.52.0 → 7.53.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 +118 -8
- 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.53.0";
|
|
733
733
|
|
|
734
734
|
// src/logger.ts
|
|
735
735
|
var exports_logger = {};
|
|
@@ -30167,6 +30167,9 @@ function parseRecord(raw) {
|
|
|
30167
30167
|
return null;
|
|
30168
30168
|
}
|
|
30169
30169
|
}
|
|
30170
|
+
function encodeRecord(rec) {
|
|
30171
|
+
return PREFIX + Buffer.from(JSON.stringify(rec), "utf8").toString("base64");
|
|
30172
|
+
}
|
|
30170
30173
|
function readSharedAntigravityToken(deps = defaultDeps) {
|
|
30171
30174
|
const rec = parseRecord(deps.readStore());
|
|
30172
30175
|
return rec ? rec.token : null;
|
|
@@ -30184,6 +30187,15 @@ function hasSharedAntigravityToken(deps = defaultDeps) {
|
|
|
30184
30187
|
cachedHasToken = { at: now, value };
|
|
30185
30188
|
return value;
|
|
30186
30189
|
}
|
|
30190
|
+
function writeSharedAntigravityToken(tok, deps = defaultDeps) {
|
|
30191
|
+
const existing = parseRecord(deps.readStore());
|
|
30192
|
+
const base = existing ?? { token: tok };
|
|
30193
|
+
const merged = {
|
|
30194
|
+
...base,
|
|
30195
|
+
token: { ...base.token, ...tok }
|
|
30196
|
+
};
|
|
30197
|
+
deps.writeStore(encodeRecord(merged));
|
|
30198
|
+
}
|
|
30187
30199
|
function deleteSharedAntigravityToken(deps = defaultDeps) {
|
|
30188
30200
|
(deps.deleteStore ?? defaultDeleteStore)();
|
|
30189
30201
|
_resetAntigravityTokenState();
|
|
@@ -30222,6 +30234,31 @@ function getValidAntigravityAccessToken(deps = defaultDeps) {
|
|
|
30222
30234
|
});
|
|
30223
30235
|
return inFlight;
|
|
30224
30236
|
}
|
|
30237
|
+
async function forceRefreshAntigravityToken(deps = defaultDeps) {
|
|
30238
|
+
if (process.platform !== "darwin") {
|
|
30239
|
+
throw new Error("[Antigravity] The shared Antigravity token store is macOS-only for now. " + "Use g@<model> with GEMINI_API_KEY on this platform.");
|
|
30240
|
+
}
|
|
30241
|
+
_resetAntigravityTokenState();
|
|
30242
|
+
const rec = parseRecord(deps.readStore());
|
|
30243
|
+
if (!rec) {
|
|
30244
|
+
throw new Error("[Antigravity] No Antigravity session found. Sign in with `claudish login antigravity`, " + "or use g@<model> with GEMINI_API_KEY " + "(get one at https://aistudio.google.com/app/apikey).");
|
|
30245
|
+
}
|
|
30246
|
+
const original = rec.token;
|
|
30247
|
+
log("[Antigravity] Upstream rejected the current token \u2014 asking the Antigravity CLI to re-mint.");
|
|
30248
|
+
writeSharedAntigravityToken({ ...original, expiry: new Date(deps.now() - 1000).toISOString() }, deps);
|
|
30249
|
+
deps.runAgyRefresh();
|
|
30250
|
+
const refreshed = parseRecord(deps.readStore());
|
|
30251
|
+
const token = refreshed?.token;
|
|
30252
|
+
if (token && token.access_token !== original.access_token && !needsRefresh(token, deps.now())) {
|
|
30253
|
+
log("[Antigravity] Shared token re-minted by the Antigravity CLI.");
|
|
30254
|
+
return token.access_token;
|
|
30255
|
+
}
|
|
30256
|
+
if (!refreshed || refreshed.token.access_token === original.access_token) {
|
|
30257
|
+
writeSharedAntigravityToken(original, deps);
|
|
30258
|
+
}
|
|
30259
|
+
_resetAntigravityTokenState();
|
|
30260
|
+
throw new Error("[Antigravity] The Antigravity session was rejected upstream and could not be re-minted. " + "Run `claudish login antigravity` to sign in again.");
|
|
30261
|
+
}
|
|
30225
30262
|
function _resetAntigravityTokenState() {
|
|
30226
30263
|
inFlight = null;
|
|
30227
30264
|
cachedHasToken = null;
|
|
@@ -30248,6 +30285,13 @@ function makeTerminalSetupError(message) {
|
|
|
30248
30285
|
function buildAntigravityUserAgent() {
|
|
30249
30286
|
return `antigravity/cli/1.1.9 (aidev_client; os_type=${process.platform}; arch=${process.arch}; auth_method=consumer)`;
|
|
30250
30287
|
}
|
|
30288
|
+
function resetAntigravityUserCache() {
|
|
30289
|
+
cachedAgProjectId = null;
|
|
30290
|
+
cachedAgTierId = null;
|
|
30291
|
+
cachedAgTierName = null;
|
|
30292
|
+
agServedCache = null;
|
|
30293
|
+
agServedCacheAt = 0;
|
|
30294
|
+
}
|
|
30251
30295
|
async function callLoadCodeAssistAntigravity(accessToken) {
|
|
30252
30296
|
const res = await fetch(`${ANTIGRAVITY_API_BASE}:loadCodeAssist`, {
|
|
30253
30297
|
method: "POST",
|
|
@@ -30632,6 +30676,22 @@ class AntigravityProviderTransport {
|
|
|
30632
30676
|
this.servedModelName = resolveAntigravityModelId(this.modelName, this.servedModels, this.defaultServedModel, lookupFamilyDefaultVariant(this.modelName, "antigravity"));
|
|
30633
30677
|
log(`[Antigravity] Auth refreshed, project: ${this.projectId}, tier: ${this._displayName}, ` + `model: ${this.modelName} -> ${this.servedModelName}, served: ${this.servedModels.join(",") || "(none)"}`);
|
|
30634
30678
|
}
|
|
30679
|
+
async forceRefreshAuth() {
|
|
30680
|
+
await forceRefreshAntigravityToken();
|
|
30681
|
+
resetAntigravityUserCache();
|
|
30682
|
+
this.cachedAuth = null;
|
|
30683
|
+
await this.refreshAuth();
|
|
30684
|
+
}
|
|
30685
|
+
classifyTerminalError(status, bodyText) {
|
|
30686
|
+
if (status !== 429)
|
|
30687
|
+
return;
|
|
30688
|
+
const classification = classify429(bodyText);
|
|
30689
|
+
if (!classification)
|
|
30690
|
+
return;
|
|
30691
|
+
if (classification.reason === "MODEL_CAPACITY_EXHAUSTED")
|
|
30692
|
+
return false;
|
|
30693
|
+
return classification.terminal;
|
|
30694
|
+
}
|
|
30635
30695
|
transformPayload(payload) {
|
|
30636
30696
|
const envelope = this.cachedAuth?.transformPayload ? this.cachedAuth.transformPayload(payload) : this.buildEnvelope(payload, this.servedModelName);
|
|
30637
30697
|
this.lastEnvelope = envelope;
|
|
@@ -30672,8 +30732,7 @@ class AntigravityProviderTransport {
|
|
|
30672
30732
|
return this.handleCapacityExhausted(response, queue);
|
|
30673
30733
|
}
|
|
30674
30734
|
if (classification.terminal) {
|
|
30675
|
-
|
|
30676
|
-
return response;
|
|
30735
|
+
return await this.explainTerminalQuota(response, bodyText, classification.reason);
|
|
30677
30736
|
}
|
|
30678
30737
|
if (attempt < MAX_RETRY_ATTEMPTS) {
|
|
30679
30738
|
const delay = classification.retryDelayMs ?? DEFAULT_RATE_LIMIT_DELAY_MS;
|
|
@@ -30768,6 +30827,53 @@ class AntigravityProviderTransport {
|
|
|
30768
30827
|
headers: { "Content-Type": "application/json" }
|
|
30769
30828
|
});
|
|
30770
30829
|
}
|
|
30830
|
+
async quotaRemainingForServedModel() {
|
|
30831
|
+
if (!this.accessToken || !this.projectId)
|
|
30832
|
+
return;
|
|
30833
|
+
let timer;
|
|
30834
|
+
const data = await Promise.race([
|
|
30835
|
+
retrieveUserQuota(this.accessToken, this.projectId).catch(() => null),
|
|
30836
|
+
new Promise((resolve) => {
|
|
30837
|
+
timer = setTimeout(() => resolve(null), QUOTA_CHECK_TIMEOUT_MS);
|
|
30838
|
+
})
|
|
30839
|
+
]).finally(() => {
|
|
30840
|
+
if (timer)
|
|
30841
|
+
clearTimeout(timer);
|
|
30842
|
+
});
|
|
30843
|
+
const buckets = data?.buckets;
|
|
30844
|
+
if (!buckets?.length)
|
|
30845
|
+
return;
|
|
30846
|
+
const bucket = buckets.find((b) => b.modelId === this.servedModelName) ?? buckets.find((b) => b.modelId === this.modelName);
|
|
30847
|
+
return typeof bucket?.remainingFraction === "number" ? bucket.remainingFraction : undefined;
|
|
30848
|
+
}
|
|
30849
|
+
async explainTerminalQuota(response, bodyText, reason) {
|
|
30850
|
+
const remaining = await this.quotaRemainingForServedModel();
|
|
30851
|
+
const model = this.servedModelName;
|
|
30852
|
+
let advice;
|
|
30853
|
+
if (remaining !== undefined && remaining > 0) {
|
|
30854
|
+
advice = `your Antigravity plan still reports ${(remaining * 100).toFixed(1)}% of the ${model} ` + "allowance available, so this is probably NOT an exhausted plan. The usual cause is an " + "Antigravity session Google invalidated server-side; run `claudish login antigravity`.";
|
|
30855
|
+
} else if (remaining === undefined) {
|
|
30856
|
+
advice = "claudish could not read your Antigravity quota to confirm this. If your plan is not " + "actually spent, the session may be stale \u2014 run `claudish login antigravity`.";
|
|
30857
|
+
} else {
|
|
30858
|
+
advice = `your Antigravity plan reports no remaining ${model} allowance; it refills on Google's own schedule.`;
|
|
30859
|
+
}
|
|
30860
|
+
logStderr(`[Antigravity] Terminal 429 (${reason || "daily limit"}) \u2014 ${advice}`);
|
|
30861
|
+
let parsed;
|
|
30862
|
+
try {
|
|
30863
|
+
parsed = JSON.parse(bodyText);
|
|
30864
|
+
} catch {
|
|
30865
|
+
return response;
|
|
30866
|
+
}
|
|
30867
|
+
const target = Array.isArray(parsed) ? parsed[0]?.error : parsed?.error;
|
|
30868
|
+
if (!target || typeof target !== "object")
|
|
30869
|
+
return response;
|
|
30870
|
+
const upstream = typeof target.message === "string" && target.message.length > 0 ? target.message : "Resource has been exhausted";
|
|
30871
|
+
target.message = `${upstream} \u2014 ${advice}`;
|
|
30872
|
+
return new Response(JSON.stringify(parsed), {
|
|
30873
|
+
status: 429,
|
|
30874
|
+
headers: { "Content-Type": "application/json" }
|
|
30875
|
+
});
|
|
30876
|
+
}
|
|
30771
30877
|
async logQuotaInfo() {
|
|
30772
30878
|
if (!this.accessToken || !this.projectId)
|
|
30773
30879
|
return;
|
|
@@ -30817,7 +30923,7 @@ ${lines.join(`
|
|
|
30817
30923
|
}
|
|
30818
30924
|
}
|
|
30819
30925
|
}
|
|
30820
|
-
var ANTIGRAVITY_BASE = "https://cloudcode-pa.googleapis.com", ANTIGRAVITY_ENDPOINT, MAX_RETRY_ATTEMPTS = 3, DEFAULT_RATE_LIMIT_DELAY_MS = 1e4, REASONING_TIER_RANK;
|
|
30926
|
+
var ANTIGRAVITY_BASE = "https://cloudcode-pa.googleapis.com", ANTIGRAVITY_ENDPOINT, MAX_RETRY_ATTEMPTS = 3, DEFAULT_RATE_LIMIT_DELAY_MS = 1e4, QUOTA_CHECK_TIMEOUT_MS = 3000, REASONING_TIER_RANK;
|
|
30821
30927
|
var init_antigravity = __esm(() => {
|
|
30822
30928
|
init_model_catalog();
|
|
30823
30929
|
init_antigravity_token();
|
|
@@ -41136,7 +41242,8 @@ class ComposedHandler {
|
|
|
41136
41242
|
} else {
|
|
41137
41243
|
const errorText = await response.text();
|
|
41138
41244
|
log(`[${this.provider.displayName}] Error: ${errorText}`);
|
|
41139
|
-
const
|
|
41245
|
+
const transportTerminal = this.provider.classifyTerminalError?.(response.status, errorText);
|
|
41246
|
+
const hint = getRecoveryHint(response.status, errorText, this.provider.displayName, transportTerminal);
|
|
41140
41247
|
let parsedErrorBody;
|
|
41141
41248
|
try {
|
|
41142
41249
|
parsedErrorBody = JSON.parse(errorText);
|
|
@@ -41189,7 +41296,7 @@ class ComposedHandler {
|
|
|
41189
41296
|
const errorBody = parsedErrorBody ?? {
|
|
41190
41297
|
error: { type: "api_error", message: errorText }
|
|
41191
41298
|
};
|
|
41192
|
-
if (isTerminalError(response.status, errorText, isTerminal429(errorText))) {
|
|
41299
|
+
if (isTerminalError(response.status, errorText, transportTerminal ?? isTerminal429(errorText))) {
|
|
41193
41300
|
const surfaced = buildSurfacedErrorMessage({
|
|
41194
41301
|
providerDisplayName: this.provider.displayName,
|
|
41195
41302
|
status: response.status,
|
|
@@ -41565,14 +41672,17 @@ class ComposedHandler {
|
|
|
41565
41672
|
}
|
|
41566
41673
|
}
|
|
41567
41674
|
}
|
|
41568
|
-
function getRecoveryHint(status, errorText, providerName) {
|
|
41675
|
+
function getRecoveryHint(status, errorText, providerName, transportTerminal429) {
|
|
41569
41676
|
const lower = errorText.toLowerCase();
|
|
41570
41677
|
if (status === 503 || lower.includes("overloaded")) {
|
|
41571
41678
|
return "Provider overloaded. Retry or use a different model.";
|
|
41572
41679
|
}
|
|
41573
|
-
if (status === 429 && isTerminal429(errorText)) {
|
|
41680
|
+
if (status === 429 && (transportTerminal429 ?? isTerminal429(errorText))) {
|
|
41574
41681
|
return "Out of quota \u2014 check your plan & billing details. This won't recover on retry.";
|
|
41575
41682
|
}
|
|
41683
|
+
if (status === 429 && transportTerminal429 === false) {
|
|
41684
|
+
return "Rate limited. Wait, reduce concurrency, or check plan limits.";
|
|
41685
|
+
}
|
|
41576
41686
|
if (isQuotaExhaustionError(status, errorText)) {
|
|
41577
41687
|
return "Subscription allowance spent \u2014 this refills on the provider's own schedule (see the message below). Reducing concurrency won't help; switch model/provider or wait.";
|
|
41578
41688
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "claudish",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.53.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.53.0",
|
|
64
|
+
"@claudish/magmux-darwin-x64": "7.53.0",
|
|
65
|
+
"@claudish/magmux-linux-arm64": "7.53.0",
|
|
66
|
+
"@claudish/magmux-linux-x64": "7.53.0"
|
|
67
67
|
},
|
|
68
68
|
"author": "Jack Rudenko <i@madappgang.com>",
|
|
69
69
|
"license": "MIT",
|