@kenkaiiii/gg-ai 5.82.0 → 5.83.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.cjs +196 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +193 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -30,6 +30,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
30
30
|
// src/index.ts
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
|
+
CODEX_CLIENT_VERSION: () => CODEX_CLIENT_VERSION,
|
|
33
34
|
EventStream: () => EventStream,
|
|
34
35
|
FAST_MODE_SUFFIX: () => FAST_MODE_SUFFIX,
|
|
35
36
|
GGAIError: () => GGAIError,
|
|
@@ -40,6 +41,7 @@ __export(index_exports, {
|
|
|
40
41
|
clampProviderContextImages: () => clampProviderContextImages,
|
|
41
42
|
classifyProviderError: () => classifyProviderError,
|
|
42
43
|
continuesTurn: () => continuesTurn,
|
|
44
|
+
describeFastModeRejection: () => describeFastModeRejection,
|
|
43
45
|
dropInvalidToolCalls: () => dropInvalidToolCalls,
|
|
44
46
|
embed: () => embed,
|
|
45
47
|
environmentSecrets: () => environmentSecrets,
|
|
@@ -58,6 +60,7 @@ __export(index_exports, {
|
|
|
58
60
|
palsuText: () => palsuText,
|
|
59
61
|
palsuThinking: () => palsuThinking,
|
|
60
62
|
palsuToolCall: () => palsuToolCall,
|
|
63
|
+
parseFastModeRejection: () => parseFastModeRejection,
|
|
61
64
|
prewarmAnthropicCache: () => prewarmAnthropicCache,
|
|
62
65
|
providerRegistry: () => providerRegistry,
|
|
63
66
|
redactText: () => redactText,
|
|
@@ -79,6 +82,96 @@ __export(index_exports, {
|
|
|
79
82
|
});
|
|
80
83
|
module.exports = __toCommonJS(index_exports);
|
|
81
84
|
|
|
85
|
+
// src/fast-mode.ts
|
|
86
|
+
var FAST_MODE_SUFFIX = "-fast";
|
|
87
|
+
var FAST_MODE_BASE_MODELS = {
|
|
88
|
+
anthropic: ["claude-opus-5-5"],
|
|
89
|
+
openai: ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-luna"]
|
|
90
|
+
};
|
|
91
|
+
function resolveFastModeModel(provider, model) {
|
|
92
|
+
if (!model.endsWith(FAST_MODE_SUFFIX)) return { model, fast: false };
|
|
93
|
+
const base = model.slice(0, -FAST_MODE_SUFFIX.length);
|
|
94
|
+
return FAST_MODE_BASE_MODELS[provider]?.includes(base) ? { model: base, fast: true } : { model, fast: false };
|
|
95
|
+
}
|
|
96
|
+
var FAST_MODE_REJECTION_HEADER = "anthropic-ratelimit-unified-overage-disabled-reason";
|
|
97
|
+
var FAST_MODE_REJECTION_PREFIX = "Fast mode unavailable";
|
|
98
|
+
var USAGE_PAGE = "claude.ai/settings/usage";
|
|
99
|
+
var STANDARD_SPEED_FALLBACK = "or switch to Claude Opus 5.5 (standard speed), which uses your plan";
|
|
100
|
+
function describeFastModeRejection(reason) {
|
|
101
|
+
const code = reason?.trim() || "unknown";
|
|
102
|
+
const of = (headline, guidance, kind) => ({ reason: code, headline, guidance, kind });
|
|
103
|
+
switch (code) {
|
|
104
|
+
case "overage_not_provisioned":
|
|
105
|
+
case "no_limits_configured":
|
|
106
|
+
return of(
|
|
107
|
+
"Claude usage credits are turned off",
|
|
108
|
+
`Fast mode bills your Claude usage credits, never your plan. Turn usage credits on at ${USAGE_PAGE}, ${STANDARD_SPEED_FALLBACK}.`,
|
|
109
|
+
"access"
|
|
110
|
+
);
|
|
111
|
+
case "out_of_credits":
|
|
112
|
+
return of(
|
|
113
|
+
"Your Claude usage credits have run out",
|
|
114
|
+
`Fast mode bills your Claude usage credits, never your plan, and the balance is empty. Add funds or turn on auto-reload at ${USAGE_PAGE}, ${STANDARD_SPEED_FALLBACK}.`,
|
|
115
|
+
"billing"
|
|
116
|
+
);
|
|
117
|
+
case "org_level_disabled_until":
|
|
118
|
+
case "org_spend_cap_reached":
|
|
119
|
+
return of(
|
|
120
|
+
"Claude usage credit limit reached",
|
|
121
|
+
`Fast mode bills your Claude usage credits and this period's spend limit is used up. Raise the limit at ${USAGE_PAGE}, ${STANDARD_SPEED_FALLBACK}.`,
|
|
122
|
+
"billing"
|
|
123
|
+
);
|
|
124
|
+
case "org_level_disabled":
|
|
125
|
+
case "org_service_level_disabled":
|
|
126
|
+
return of(
|
|
127
|
+
"Your organization turned Claude usage credits off",
|
|
128
|
+
`Fast mode needs usage credits. Ask an admin to turn them on, ${STANDARD_SPEED_FALLBACK}.`,
|
|
129
|
+
"access"
|
|
130
|
+
);
|
|
131
|
+
case "member_level_disabled":
|
|
132
|
+
return of(
|
|
133
|
+
"Claude usage credits are off for your account",
|
|
134
|
+
`Fast mode needs usage credits. Ask your organization's admin to turn them on for you, ${STANDARD_SPEED_FALLBACK}.`,
|
|
135
|
+
"access"
|
|
136
|
+
);
|
|
137
|
+
case "seat_tier_level_disabled":
|
|
138
|
+
case "seat_tier_zero_credit_limit":
|
|
139
|
+
case "member_zero_credit_limit":
|
|
140
|
+
case "group_zero_credit_limit":
|
|
141
|
+
return of(
|
|
142
|
+
"Claude usage credits aren't available on your plan",
|
|
143
|
+
`Fast mode needs usage credits, which your seat doesn't include. Ask your admin about access, ${STANDARD_SPEED_FALLBACK}.`,
|
|
144
|
+
"access"
|
|
145
|
+
);
|
|
146
|
+
case "fast_mode_org_disabled":
|
|
147
|
+
return of(
|
|
148
|
+
"Your organization turned fast mode off",
|
|
149
|
+
`An Owner can enable fast mode for the organization, ${STANDARD_SPEED_FALLBACK}.`,
|
|
150
|
+
"access"
|
|
151
|
+
);
|
|
152
|
+
default:
|
|
153
|
+
return of(
|
|
154
|
+
"Fast mode needs Claude usage credits",
|
|
155
|
+
`Fast mode bills your Claude usage credits, never your plan, and Anthropic couldn't charge them. Check usage credits at ${USAGE_PAGE}, ${STANDARD_SPEED_FALLBACK}.`,
|
|
156
|
+
"billing"
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function fastModeRejectionMessage(rejection) {
|
|
161
|
+
return `${FAST_MODE_REJECTION_PREFIX} (${rejection.reason}): ${rejection.headline}.`;
|
|
162
|
+
}
|
|
163
|
+
function parseFastModeRejection(message) {
|
|
164
|
+
const canonical = /fast mode unavailable \(([a-z_]+)\)/i.exec(message);
|
|
165
|
+
if (canonical) return describeFastModeRejection(canonical[1]);
|
|
166
|
+
if (/usage credits are required for fast mode/i.test(message)) {
|
|
167
|
+
return describeFastModeRejection(void 0);
|
|
168
|
+
}
|
|
169
|
+
if (/fast mode (?:has been |is )?disabled by your organization/i.test(message)) {
|
|
170
|
+
return describeFastModeRejection("fast_mode_org_disabled");
|
|
171
|
+
}
|
|
172
|
+
return void 0;
|
|
173
|
+
}
|
|
174
|
+
|
|
82
175
|
// src/errors.ts
|
|
83
176
|
function readHeader(headers, ...names) {
|
|
84
177
|
if (!headers) return void 0;
|
|
@@ -158,8 +251,8 @@ function isUsageLimitError(err) {
|
|
|
158
251
|
}
|
|
159
252
|
function isHardBillingMessage(message) {
|
|
160
253
|
const lower = message.toLowerCase();
|
|
161
|
-
return lower.includes("insufficient balance") || lower.includes("insufficient credits") || lower.includes("more credits") || lower.includes("insufficient_quota") || lower.includes("exceeded your current quota") || lower.includes("quota exceeded") || lower.includes("no resource package") || lower.includes("recharge") || lower.includes("balance is too low") || lower.includes("out of credits") || // Anthropic fast mode
|
|
162
|
-
lower.includes("usage credits are required") || lower.includes("arrears") || lower.includes("arrearage") || lower.includes("token quota") || lower.includes("exceeded_current_quota_error") || lower.includes("check your account balance") || lower.includes("does not yet include access") || lower.includes("subscription plan") || lower.includes("billing");
|
|
254
|
+
return lower.includes("insufficient balance") || lower.includes("insufficient credits") || lower.includes("more credits") || lower.includes("insufficient_quota") || lower.includes("exceeded your current quota") || lower.includes("quota exceeded") || lower.includes("no resource package") || lower.includes("recharge") || lower.includes("balance is too low") || lower.includes("out of credits") || // Anthropic fast mode when usage credits can't pay (see fast-mode.ts).
|
|
255
|
+
lower.includes("usage credits are required") || lower.includes("fast mode unavailable") || lower.includes("arrears") || lower.includes("arrearage") || lower.includes("token quota") || lower.includes("exceeded_current_quota_error") || lower.includes("check your account balance") || lower.includes("does not yet include access") || lower.includes("subscription plan") || lower.includes("billing");
|
|
163
256
|
}
|
|
164
257
|
function formatResetTime(resetsAt) {
|
|
165
258
|
const when = new Date(resetsAt * 1e3);
|
|
@@ -212,6 +305,18 @@ function formatError(err) {
|
|
|
212
305
|
guidance: "Request access via your Anthropic account team (see platform.claude.com/docs/en/about-claude/models/overview), or switch to Claude Fable 5.1 via the model selector \u2014 same underlying model, generally available."
|
|
213
306
|
};
|
|
214
307
|
}
|
|
308
|
+
const fastRejection = err.provider === "anthropic" ? parseFastModeRejection(err.message) : void 0;
|
|
309
|
+
if (fastRejection) {
|
|
310
|
+
return {
|
|
311
|
+
headline: `${fastRejection.headline}.`,
|
|
312
|
+
source: "provider",
|
|
313
|
+
message: cleanMessage,
|
|
314
|
+
provider: err.provider,
|
|
315
|
+
statusCode: err.statusCode,
|
|
316
|
+
...err.requestId ? { requestId: err.requestId } : {},
|
|
317
|
+
guidance: fastRejection.guidance
|
|
318
|
+
};
|
|
319
|
+
}
|
|
215
320
|
if (isUsageLimitError(err)) {
|
|
216
321
|
const resetClause = err.resetsAt ? ` It resets at ${formatResetTime(err.resetsAt)}.` : "";
|
|
217
322
|
return {
|
|
@@ -1388,7 +1493,7 @@ function isAdaptiveThinkingModel(model) {
|
|
|
1388
1493
|
function toAnthropicThinking(level, maxTokens, model) {
|
|
1389
1494
|
if (isAdaptiveThinkingModel(model)) {
|
|
1390
1495
|
let effort = level;
|
|
1391
|
-
if (effort === "xhigh" && !/opus-5|opus-4-8|opus-4-7|sonnet-5[-.]5|haiku-5[-.]5/.test(model)) {
|
|
1496
|
+
if (effort === "xhigh" && !/fable-5|mythos-5|opus-5|opus-4-8|opus-4-7|sonnet-5[-.]5|haiku-5[-.]5/.test(model)) {
|
|
1392
1497
|
effort = "high";
|
|
1393
1498
|
}
|
|
1394
1499
|
return {
|
|
@@ -1928,7 +2033,7 @@ async function* runStream(options) {
|
|
|
1928
2033
|
yield* synthesizeEventsFromMessage(message);
|
|
1929
2034
|
return messageToResponse(message);
|
|
1930
2035
|
} catch (err) {
|
|
1931
|
-
throw toError(err);
|
|
2036
|
+
throw toError(err, { fastMode: useFastMode });
|
|
1932
2037
|
}
|
|
1933
2038
|
}
|
|
1934
2039
|
const contentParts = [];
|
|
@@ -2145,7 +2250,7 @@ async function* runStream(options) {
|
|
|
2145
2250
|
}
|
|
2146
2251
|
}
|
|
2147
2252
|
} catch (err) {
|
|
2148
|
-
throw toError(err);
|
|
2253
|
+
throw toError(err, { fastMode: useFastMode });
|
|
2149
2254
|
}
|
|
2150
2255
|
if (!receivedAnyEvent) {
|
|
2151
2256
|
throw new ProviderError("anthropic", "Stream ended without producing any events.", {
|
|
@@ -2275,8 +2380,12 @@ function messageToResponse(message) {
|
|
|
2275
2380
|
}
|
|
2276
2381
|
};
|
|
2277
2382
|
}
|
|
2278
|
-
function
|
|
2279
|
-
|
|
2383
|
+
function readFastModeRejection(err, message, fastMode) {
|
|
2384
|
+
const reason = readHeader(err.headers, FAST_MODE_REJECTION_HEADER);
|
|
2385
|
+
if (fastMode && err.status === 429 && reason) return describeFastModeRejection(reason);
|
|
2386
|
+
const fromBody = parseFastModeRejection(message);
|
|
2387
|
+
if (!fromBody) return void 0;
|
|
2388
|
+
return reason ? describeFastModeRejection(reason) : fromBody;
|
|
2280
2389
|
}
|
|
2281
2390
|
function readUnifiedRateLimit(headers) {
|
|
2282
2391
|
const status = readHeader(headers, "anthropic-ratelimit-unified-status");
|
|
@@ -2290,7 +2399,7 @@ function readUnifiedRateLimit(headers) {
|
|
|
2290
2399
|
const resetsAt = Number.isFinite(resetNum) && resetNum > 0 ? resetNum : void 0;
|
|
2291
2400
|
return { rejected: status === "rejected", ...resetsAt ? { resetsAt } : {} };
|
|
2292
2401
|
}
|
|
2293
|
-
function toError(err) {
|
|
2402
|
+
function toError(err, context) {
|
|
2294
2403
|
if (err instanceof ProviderError) return err;
|
|
2295
2404
|
if (err instanceof import_sdk.default.APIError) {
|
|
2296
2405
|
const errorBody = err.error;
|
|
@@ -2301,11 +2410,12 @@ function toError(err) {
|
|
|
2301
2410
|
const fallbackMessage = isRawJsonErrorEcho(err.message) ? emptyProviderErrorMessage(err.status) : err.message;
|
|
2302
2411
|
const messageCandidate = bodyMessage ?? err.message;
|
|
2303
2412
|
const message = isRawHtmlErrorEcho(messageCandidate) ? providerHtmlErrorMessage(err.status) : bodyType && bodyMessage ? `${bodyType}: ${bodyMessage}` : bodyMessage ?? fallbackMessage;
|
|
2304
|
-
|
|
2305
|
-
|
|
2413
|
+
const fastRejection = readFastModeRejection(err, message, context?.fastMode === true);
|
|
2414
|
+
if (fastRejection) {
|
|
2415
|
+
return new ProviderError("anthropic", fastModeRejectionMessage(fastRejection), {
|
|
2306
2416
|
statusCode: err.status,
|
|
2307
2417
|
...requestId ? { requestId } : {},
|
|
2308
|
-
hint:
|
|
2418
|
+
hint: fastRejection.guidance,
|
|
2309
2419
|
cause: err
|
|
2310
2420
|
});
|
|
2311
2421
|
}
|
|
@@ -2604,10 +2714,16 @@ async function* runStream2(options) {
|
|
|
2604
2714
|
`
|
|
2605
2715
|
);
|
|
2606
2716
|
}
|
|
2717
|
+
const requestHeaders = options.provider === "xai" ? {
|
|
2718
|
+
headers: {
|
|
2719
|
+
"x-grok-conv-id": normalizePromptCacheKey(options.promptCacheKey ?? "ggcoder")
|
|
2720
|
+
}
|
|
2721
|
+
} : {};
|
|
2607
2722
|
if (!useStreaming) {
|
|
2608
2723
|
try {
|
|
2609
2724
|
const completion = await client.chat.completions.create(requestParams, {
|
|
2610
|
-
signal: options.signal ?? void 0
|
|
2725
|
+
signal: options.signal ?? void 0,
|
|
2726
|
+
...requestHeaders
|
|
2611
2727
|
});
|
|
2612
2728
|
yield* synthesizeEventsFromCompletion(completion, !!options.thinking, endpointKey);
|
|
2613
2729
|
return completionToResponse(completion, endpointKey);
|
|
@@ -2618,7 +2734,8 @@ async function* runStream2(options) {
|
|
|
2618
2734
|
let stream2;
|
|
2619
2735
|
try {
|
|
2620
2736
|
stream2 = await client.chat.completions.create(requestParams, {
|
|
2621
|
-
signal: options.signal ?? void 0
|
|
2737
|
+
signal: options.signal ?? void 0,
|
|
2738
|
+
...requestHeaders
|
|
2622
2739
|
});
|
|
2623
2740
|
} catch (err) {
|
|
2624
2741
|
throw toError2(err, providerName);
|
|
@@ -3661,6 +3778,9 @@ var CODE_ASSIST_SUPPORTED_MODELS = /* @__PURE__ */ new Set([
|
|
|
3661
3778
|
"gemma-4-31b-it",
|
|
3662
3779
|
"gemma-4-26b-a4b-it"
|
|
3663
3780
|
]);
|
|
3781
|
+
function isGeminiApiKeyRoute(options) {
|
|
3782
|
+
return options.baseUrl?.includes("generativelanguage.googleapis.com") === true;
|
|
3783
|
+
}
|
|
3664
3784
|
function getGoogleProject(options) {
|
|
3665
3785
|
const env = getEnvironment();
|
|
3666
3786
|
return options.projectId ?? env?.GOOGLE_CLOUD_PROJECT ?? env?.GOOGLE_CLOUD_PROJECT_ID;
|
|
@@ -3693,8 +3813,28 @@ function accountGatedHint(model) {
|
|
|
3693
3813
|
if (model === "gemini-3.8-flash" || model === "gemini-3.5-flash-lite") {
|
|
3694
3814
|
return "Use /model to select Gemini 3.1 Flash Lite, or retry once Google enables this model through Code Assist for your account.";
|
|
3695
3815
|
}
|
|
3696
|
-
return `Newer Gemini models (3.
|
|
3816
|
+
return `Newer Gemini models (3.5 Flash, 3.1 Pro Preview) are available only to Code Assist Standard/Enterprise accounts with preview/GA access enabled by a cloud admin. Try Gemini 3.1 Flash Lite with /model, or sign in with a Code Assist Standard/Enterprise account that has preview access.`;
|
|
3697
3817
|
}
|
|
3818
|
+
function isCodeAssistLicenseRequired(status, body) {
|
|
3819
|
+
if (status !== 403) return false;
|
|
3820
|
+
try {
|
|
3821
|
+
const parsed = JSON.parse(body);
|
|
3822
|
+
const details = typeof parsed === "object" && parsed !== null && "error" in parsed ? parsed.error?.details : void 0;
|
|
3823
|
+
return Array.isArray(details) && details.some(
|
|
3824
|
+
(detail) => typeof detail === "object" && detail !== null && detail.reason === "SUBSCRIPTION_REQUIRED"
|
|
3825
|
+
);
|
|
3826
|
+
} catch {
|
|
3827
|
+
return false;
|
|
3828
|
+
}
|
|
3829
|
+
}
|
|
3830
|
+
function isInvalidGeminiApiKey(status, body) {
|
|
3831
|
+
if (status !== 400 && status !== 401 && status !== 403) return false;
|
|
3832
|
+
return /"reason"\s*:\s*"API_KEY_INVALID"/.test(body) || /API key not valid/i.test(body);
|
|
3833
|
+
}
|
|
3834
|
+
var INVALID_API_KEY_MESSAGE = "Google rejected the Gemini API key: it is not valid.";
|
|
3835
|
+
var INVALID_API_KEY_HINT = "Create a key at aistudio.google.com/apikey and add it again under Gemini in Providers (or `ggcoder login`).";
|
|
3836
|
+
var LICENSE_REQUIRED_MESSAGE = "This Google account has no Gemini Code Assist licence. Google stopped serving Gemini through Code Assist to personal accounts (Google AI Pro/Ultra and the free individual tier) on June 18, 2026, so every Gemini model is refused, not just this one.";
|
|
3837
|
+
var LICENSE_REQUIRED_HINT = "Sign in to Gemini with a Google account that has a Gemini Code Assist Standard or Enterprise licence, or pick a model from another provider with /model.";
|
|
3698
3838
|
function formatErrorMessage(status, body, model) {
|
|
3699
3839
|
if (status === 404 && !CODE_ASSIST_SUPPORTED_MODELS.has(model)) {
|
|
3700
3840
|
return `Gemini API error (404): ${body}
|
|
@@ -3918,7 +4058,29 @@ function buildCodeAssistRequest(options, request, projectId) {
|
|
|
3918
4058
|
request
|
|
3919
4059
|
};
|
|
3920
4060
|
}
|
|
4061
|
+
var API_KEY_MODEL_IDS = {
|
|
4062
|
+
"gemini-3-flash": "gemini-3.5-flash"
|
|
4063
|
+
};
|
|
4064
|
+
function buildApiKeyRequestPlan(options, method) {
|
|
4065
|
+
const { session_id: _sessionId, ...request } = mergeProviderOptions(
|
|
4066
|
+
buildGenerateRequest(options),
|
|
4067
|
+
options.providerOptions
|
|
4068
|
+
);
|
|
4069
|
+
const base = (options.baseUrl ?? "").replace(/\/+$/, "");
|
|
4070
|
+
return {
|
|
4071
|
+
url: new URL(
|
|
4072
|
+
`${base}/models/${encodeURIComponent(API_KEY_MODEL_IDS[options.model] ?? options.model)}:${method}`
|
|
4073
|
+
),
|
|
4074
|
+
headers: {
|
|
4075
|
+
"Content-Type": "application/json",
|
|
4076
|
+
"x-goog-api-key": options.apiKey ?? ""
|
|
4077
|
+
},
|
|
4078
|
+
body: request,
|
|
4079
|
+
route: "api-key"
|
|
4080
|
+
};
|
|
4081
|
+
}
|
|
3921
4082
|
function buildRequestPlan(options, method) {
|
|
4083
|
+
if (isGeminiApiKeyRoute(options)) return buildApiKeyRequestPlan(options, method);
|
|
3922
4084
|
if (!CODE_ASSIST_SUPPORTED_MODELS.has(options.model)) {
|
|
3923
4085
|
throw new ProviderError("gemini", formatUnsupportedModelMessage(options.model));
|
|
3924
4086
|
}
|
|
@@ -3932,7 +4094,8 @@ function buildRequestPlan(options, method) {
|
|
|
3932
4094
|
"User-Agent": GEMINI_CLI_USER_AGENT,
|
|
3933
4095
|
"X-Goog-Api-Client": GEMINI_CLI_API_CLIENT
|
|
3934
4096
|
},
|
|
3935
|
-
body: buildCodeAssistRequest(options, request, projectId)
|
|
4097
|
+
body: buildCodeAssistRequest(options, request, projectId),
|
|
4098
|
+
route: "code-assist"
|
|
3936
4099
|
};
|
|
3937
4100
|
}
|
|
3938
4101
|
function normalizeGeminiStopReason(reason) {
|
|
@@ -4018,8 +4181,11 @@ async function fetchCodeAssist(plan, options) {
|
|
|
4018
4181
|
if (!response.ok) {
|
|
4019
4182
|
const text = await response.text().catch(() => "");
|
|
4020
4183
|
const quota = parseGeminiQuota(response.status, text);
|
|
4021
|
-
const
|
|
4022
|
-
|
|
4184
|
+
const codeAssist = plan.route === "code-assist";
|
|
4185
|
+
const accountGated = codeAssist && response.status === 404 && ACCOUNT_GATED_MODELS.has(options.model);
|
|
4186
|
+
const licenseRequired = codeAssist && isCodeAssistLicenseRequired(response.status, text);
|
|
4187
|
+
const invalidKey = !codeAssist && isInvalidGeminiApiKey(response.status, text);
|
|
4188
|
+
let message = invalidKey ? INVALID_API_KEY_MESSAGE : licenseRequired ? LICENSE_REQUIRED_MESSAGE : accountGated ? accountGatedMessage(options.model) : formatErrorMessage(response.status, text, options.model);
|
|
4023
4189
|
let resetsAt;
|
|
4024
4190
|
if (quota?.exhausted) {
|
|
4025
4191
|
message = `Gemini quota exhausted \u2014 usage limit reached. ${message}`;
|
|
@@ -4029,7 +4195,7 @@ async function fetchCodeAssist(plan, options) {
|
|
|
4029
4195
|
throw new ProviderError("gemini", message, {
|
|
4030
4196
|
statusCode: response.status,
|
|
4031
4197
|
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
4032
|
-
...accountGated ? { hint: accountGatedHint(options.model) } : {}
|
|
4198
|
+
...invalidKey ? { hint: INVALID_API_KEY_HINT, source: "auth" } : licenseRequired ? { hint: LICENSE_REQUIRED_HINT, source: "auth" } : accountGated ? { hint: accountGatedHint(options.model) } : {}
|
|
4033
4199
|
});
|
|
4034
4200
|
}
|
|
4035
4201
|
return response;
|
|
@@ -4814,18 +4980,6 @@ function observePreparedContext(before, after, tools) {
|
|
|
4814
4980
|
};
|
|
4815
4981
|
}
|
|
4816
4982
|
|
|
4817
|
-
// src/fast-mode.ts
|
|
4818
|
-
var FAST_MODE_SUFFIX = "-fast";
|
|
4819
|
-
var FAST_MODE_BASE_MODELS = {
|
|
4820
|
-
anthropic: ["claude-opus-5-5"],
|
|
4821
|
-
openai: ["gpt-6-astra", "gpt-6.1-sol", "gpt-6-luna"]
|
|
4822
|
-
};
|
|
4823
|
-
function resolveFastModeModel(provider, model) {
|
|
4824
|
-
if (!model.endsWith(FAST_MODE_SUFFIX)) return { model, fast: false };
|
|
4825
|
-
const base = model.slice(0, -FAST_MODE_SUFFIX.length);
|
|
4826
|
-
return FAST_MODE_BASE_MODELS[provider]?.includes(base) ? { model: base, fast: true } : { model, fast: false };
|
|
4827
|
-
}
|
|
4828
|
-
|
|
4829
4983
|
// src/stream.ts
|
|
4830
4984
|
var OPENAI_EMBED_BATCH_SIZE = 2048;
|
|
4831
4985
|
var OPENROUTER_EMBED_BATCH_SIZE = 64;
|
|
@@ -4928,7 +5082,7 @@ providerRegistry.register("sakana", {
|
|
|
4928
5082
|
providerRegistry.register("xai", {
|
|
4929
5083
|
// xAI's public API (console.x.ai key) is OpenAI-compatible — ride the Chat
|
|
4930
5084
|
// Completions transport like Moonshot/DeepSeek. Grok reasoning models take
|
|
4931
|
-
// top-level `reasoning_effort` (low/medium/high), which the shared thinking
|
|
5085
|
+
// top-level `reasoning_effort` (low/medium/high/xhigh), which the shared thinking
|
|
4932
5086
|
// path already sends.
|
|
4933
5087
|
//
|
|
4934
5088
|
// Subscription OAuth (SuperGrok / X Premium) routes to the Grok CLI chat proxy
|
|
@@ -5217,6 +5371,14 @@ function formatChatError(error) {
|
|
|
5217
5371
|
"Update the app, or choose another model."
|
|
5218
5372
|
);
|
|
5219
5373
|
}
|
|
5374
|
+
const fastRejection = base.provider === "anthropic" ? parseFastModeRejection(raw) : void 0;
|
|
5375
|
+
if (fastRejection) {
|
|
5376
|
+
return present(
|
|
5377
|
+
fastRejection.kind === "billing" ? "billing" : "model_access",
|
|
5378
|
+
fastRejection.headline,
|
|
5379
|
+
fastRejection.guidance
|
|
5380
|
+
);
|
|
5381
|
+
}
|
|
5220
5382
|
if (/insufficient.*(?:balance|credits?)|(?:balance|credits?).*(?:insufficient|exhausted|depleted)|credit balance is too low|payment_required/.test(
|
|
5221
5383
|
text
|
|
5222
5384
|
)) {
|
|
@@ -5633,6 +5795,7 @@ function palsuRerankScore(query, document) {
|
|
|
5633
5795
|
}
|
|
5634
5796
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5635
5797
|
0 && (module.exports = {
|
|
5798
|
+
CODEX_CLIENT_VERSION,
|
|
5636
5799
|
EventStream,
|
|
5637
5800
|
FAST_MODE_SUFFIX,
|
|
5638
5801
|
GGAIError,
|
|
@@ -5643,6 +5806,7 @@ function palsuRerankScore(query, document) {
|
|
|
5643
5806
|
clampProviderContextImages,
|
|
5644
5807
|
classifyProviderError,
|
|
5645
5808
|
continuesTurn,
|
|
5809
|
+
describeFastModeRejection,
|
|
5646
5810
|
dropInvalidToolCalls,
|
|
5647
5811
|
embed,
|
|
5648
5812
|
environmentSecrets,
|
|
@@ -5661,6 +5825,7 @@ function palsuRerankScore(query, document) {
|
|
|
5661
5825
|
palsuText,
|
|
5662
5826
|
palsuThinking,
|
|
5663
5827
|
palsuToolCall,
|
|
5828
|
+
parseFastModeRejection,
|
|
5664
5829
|
prewarmAnthropicCache,
|
|
5665
5830
|
providerRegistry,
|
|
5666
5831
|
redactText,
|