@prestyj/ai 5.3.1 → 5.4.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 +55 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +55 -27
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -343,15 +343,15 @@ declare const providerRegistry: ProviderRegistryImpl;
|
|
|
343
343
|
*
|
|
344
344
|
* Every error users see should answer one question: "is this me or them?"
|
|
345
345
|
* That answer drives whether they retry, switch model, log in, or report a
|
|
346
|
-
*
|
|
346
|
+
* EZ Coder bug. The `FormattedError` shape captures it in plain English:
|
|
347
347
|
*
|
|
348
348
|
* ✗ OpenAI returned an error.
|
|
349
349
|
* An error occurred while processing your request...
|
|
350
|
-
* → This is an OpenAI issue, not
|
|
350
|
+
* → This is an OpenAI issue, not EZ Coder. Retry — if it persists, check status.openai.com.
|
|
351
351
|
*
|
|
352
|
-
* ✗
|
|
352
|
+
* ✗ EZ Coder hit an unexpected error.
|
|
353
353
|
* Cannot read property 'foo' of undefined
|
|
354
|
-
* → This is a
|
|
354
|
+
* → This is a EZ Coder bug — please report it.
|
|
355
355
|
*/
|
|
356
356
|
type ErrorSource = "provider" | "ezcoder" | "network" | "auth" | "capability";
|
|
357
357
|
interface FormattedError {
|
package/dist/index.d.ts
CHANGED
|
@@ -343,15 +343,15 @@ declare const providerRegistry: ProviderRegistryImpl;
|
|
|
343
343
|
*
|
|
344
344
|
* Every error users see should answer one question: "is this me or them?"
|
|
345
345
|
* That answer drives whether they retry, switch model, log in, or report a
|
|
346
|
-
*
|
|
346
|
+
* EZ Coder bug. The `FormattedError` shape captures it in plain English:
|
|
347
347
|
*
|
|
348
348
|
* ✗ OpenAI returned an error.
|
|
349
349
|
* An error occurred while processing your request...
|
|
350
|
-
* → This is an OpenAI issue, not
|
|
350
|
+
* → This is an OpenAI issue, not EZ Coder. Retry — if it persists, check status.openai.com.
|
|
351
351
|
*
|
|
352
|
-
* ✗
|
|
352
|
+
* ✗ EZ Coder hit an unexpected error.
|
|
353
353
|
* Cannot read property 'foo' of undefined
|
|
354
|
-
* → This is a
|
|
354
|
+
* → This is a EZ Coder bug — please report it.
|
|
355
355
|
*/
|
|
356
356
|
type ErrorSource = "provider" | "ezcoder" | "network" | "auth" | "capability";
|
|
357
357
|
interface FormattedError {
|
package/dist/index.js
CHANGED
|
@@ -117,7 +117,7 @@ function formatError(err) {
|
|
|
117
117
|
provider: err.provider,
|
|
118
118
|
statusCode: err.statusCode,
|
|
119
119
|
...err.requestId ? { requestId: err.requestId } : {},
|
|
120
|
-
guidance: "Request access via your Anthropic account team (see platform.claude.com/docs/en/about-claude/models/overview), or switch to
|
|
120
|
+
guidance: "Request access via your Anthropic account team (see platform.claude.com/docs/en/about-claude/models/overview), or switch to Claude Fable 5 via the model selector \u2014 same underlying model, generally available."
|
|
121
121
|
};
|
|
122
122
|
}
|
|
123
123
|
if (isUsageLimitError(err)) {
|
|
@@ -159,7 +159,7 @@ function finaliseBySource(source, message, requestId, hint) {
|
|
|
159
159
|
headline: "Network error \u2014 couldn't reach the provider.",
|
|
160
160
|
source,
|
|
161
161
|
message,
|
|
162
|
-
guidance: hint ?? "Check your internet connection. Not a
|
|
162
|
+
guidance: hint ?? "Check your internet connection. Not a EZ Coder issue \u2014 retry shortly.",
|
|
163
163
|
...requestId ? { requestId } : {}
|
|
164
164
|
};
|
|
165
165
|
case "auth":
|
|
@@ -167,7 +167,7 @@ function finaliseBySource(source, message, requestId, hint) {
|
|
|
167
167
|
headline: "Authentication issue.",
|
|
168
168
|
source,
|
|
169
169
|
message,
|
|
170
|
-
guidance: hint ?? "
|
|
170
|
+
guidance: hint ?? "Re-authenticate to refresh your credentials.",
|
|
171
171
|
...requestId ? { requestId } : {}
|
|
172
172
|
};
|
|
173
173
|
case "provider":
|
|
@@ -183,15 +183,15 @@ function finaliseBySource(source, message, requestId, hint) {
|
|
|
183
183
|
headline: message,
|
|
184
184
|
source,
|
|
185
185
|
message: "",
|
|
186
|
-
guidance: hint ?? "Only Kimi, Gemini, MiniMax, and MiMo-V2.5 can analyze video. Switch
|
|
186
|
+
guidance: hint ?? "Only Kimi, Gemini, MiniMax, and MiMo-V2.5 can analyze video. Switch to one of those via the model selector.",
|
|
187
187
|
...requestId ? { requestId } : {}
|
|
188
188
|
};
|
|
189
189
|
case "ezcoder":
|
|
190
190
|
return {
|
|
191
|
-
headline: "
|
|
191
|
+
headline: "EZ Coder hit an unexpected error.",
|
|
192
192
|
source,
|
|
193
193
|
message,
|
|
194
|
-
guidance: hint ?? "This looks like a
|
|
194
|
+
guidance: hint ?? "This looks like a EZ Coder bug \u2014 please report it to the developer (see /help).",
|
|
195
195
|
...requestId ? { requestId } : {}
|
|
196
196
|
};
|
|
197
197
|
}
|
|
@@ -222,36 +222,39 @@ function providerGuidance(provider, message, statusCode) {
|
|
|
222
222
|
const status = provider ? PROVIDER_STATUS_URL[provider] : void 0;
|
|
223
223
|
const lower = message.toLowerCase();
|
|
224
224
|
if (statusCode === 401 || lower.includes("unauthorized") || lower.includes("invalid api key")) {
|
|
225
|
-
return `Authentication failed with ${name}.
|
|
225
|
+
return `Authentication failed with ${name}. Re-authenticate to refresh your credentials.`;
|
|
226
226
|
}
|
|
227
227
|
if (lower.includes("overloaded") || lower.includes("engine_overloaded")) {
|
|
228
|
-
return `${name}'s servers are overloaded right now. Retry in a moment \u2014 not a
|
|
228
|
+
return `${name}'s servers are overloaded right now. Retry in a moment \u2014 not a EZ Coder issue.`;
|
|
229
229
|
}
|
|
230
230
|
if (lower.includes("insufficient balance") || lower.includes("quota exceeded") || lower.includes("recharge") || lower.includes("no resource package")) {
|
|
231
|
-
return `Your ${name} account has a billing or quota issue \u2014 check your balance. Not a
|
|
231
|
+
return `Your ${name} account has a billing or quota issue \u2014 check your balance. Not a EZ Coder issue.`;
|
|
232
232
|
}
|
|
233
233
|
if (statusCode === 429 || lower.includes("rate limit") || lower.includes("too many requests")) {
|
|
234
|
-
return `${name} rate limit hit. Wait a moment then retry \u2014 not a
|
|
234
|
+
return `${name} rate limit hit. Wait a moment then retry \u2014 not a EZ Coder issue.`;
|
|
235
235
|
}
|
|
236
236
|
if (statusCode === 502 || lower.includes("bad gateway")) {
|
|
237
|
-
return `${name} returned a bad gateway. Retry \u2014 this is on their side, not
|
|
237
|
+
return `${name} returned a bad gateway. Retry \u2014 this is on their side, not EZ Coder.`;
|
|
238
238
|
}
|
|
239
239
|
if (statusCode === 503 || lower.includes("service unavailable")) {
|
|
240
|
-
return `${name} is temporarily unavailable. Retry shortly \u2014 not a
|
|
240
|
+
return `${name} is temporarily unavailable. Retry shortly \u2014 not a EZ Coder issue.`;
|
|
241
241
|
}
|
|
242
242
|
if (statusCode === 500 || lower.includes("server_error") || lower.includes("500") && lower.includes("internal server error")) {
|
|
243
|
-
return status ? `This is an error from ${name}, not
|
|
243
|
+
return status ? `This is an error from ${name}, not EZ Coder. Retry \u2014 if it keeps happening, check ${status}.` : `This is an error from ${name}, not EZ Coder. Retry \u2014 if it keeps happening, try a different model via the model selector.`;
|
|
244
244
|
}
|
|
245
245
|
if (lower.includes("timeout") || lower.includes("timed out")) {
|
|
246
|
-
return `Request to ${name} timed out. Their servers may be slow \u2014 retry. Not a
|
|
246
|
+
return `Request to ${name} timed out. Their servers may be slow \u2014 retry. Not a EZ Coder issue.`;
|
|
247
247
|
}
|
|
248
248
|
if (lower.includes("does not recognize the requested model") || lower.includes("model") && (lower.includes("not exist") || lower.includes("not found") || lower.includes("no access"))) {
|
|
249
|
-
return `${name} doesn't recognise this model on your account.
|
|
249
|
+
return `${name} doesn't recognise this model on your account. Switch to a different model via the model selector, or check your subscription tier.`;
|
|
250
250
|
}
|
|
251
251
|
if (lower.includes("context_length_exceeded") || lower.includes("prompt is too long")) {
|
|
252
|
-
return `Context window for this ${name} model is full.
|
|
252
|
+
return `Context window for this ${name} model is full. Compact the conversation to shrink history, or start a new session.`;
|
|
253
253
|
}
|
|
254
|
-
|
|
254
|
+
if (statusCode === 413 || lower.includes("request_too_large") || lower.includes("request exceeds the maximum size")) {
|
|
255
|
+
return `The request to ${name} is too large. Compact the conversation to shrink history, or start a new session.`;
|
|
256
|
+
}
|
|
257
|
+
return status ? `This is an error from ${name}, not EZ Coder. Retry \u2014 if it persists, check ${status}.` : `This is an error from ${name}, not EZ Coder. Retry \u2014 if it persists, try a different model via the model selector.`;
|
|
255
258
|
}
|
|
256
259
|
|
|
257
260
|
// src/providers/anthropic.ts
|
|
@@ -2132,6 +2135,10 @@ function extractRequestIdFromMessage(message) {
|
|
|
2132
2135
|
|
|
2133
2136
|
// src/providers/openai-codex.ts
|
|
2134
2137
|
var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
|
|
2138
|
+
var CODEX_CLIENT_VERSION = "0.144.1";
|
|
2139
|
+
function usesResponsesLite(model) {
|
|
2140
|
+
return model.startsWith("gpt-5.6-");
|
|
2141
|
+
}
|
|
2135
2142
|
function outputTextKey(itemId, contentIndex) {
|
|
2136
2143
|
return `${itemId ?? ""}:${contentIndex ?? 0}`;
|
|
2137
2144
|
}
|
|
@@ -2147,6 +2154,7 @@ async function* runStream3(options) {
|
|
|
2147
2154
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
2148
2155
|
const downgraded = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
2149
2156
|
const { system, input } = toCodexInput(downgraded, { supportsImages: options.supportsImages });
|
|
2157
|
+
const responsesLite = usesResponsesLite(options.model);
|
|
2150
2158
|
const body = {
|
|
2151
2159
|
model: options.model,
|
|
2152
2160
|
store: false,
|
|
@@ -2154,7 +2162,7 @@ async function* runStream3(options) {
|
|
|
2154
2162
|
instructions: system,
|
|
2155
2163
|
input,
|
|
2156
2164
|
tool_choice: "auto",
|
|
2157
|
-
parallel_tool_calls:
|
|
2165
|
+
parallel_tool_calls: !responsesLite,
|
|
2158
2166
|
include: ["reasoning.encrypted_content"]
|
|
2159
2167
|
};
|
|
2160
2168
|
if (options.tools?.length) {
|
|
@@ -2166,15 +2174,20 @@ async function* runStream3(options) {
|
|
|
2166
2174
|
}
|
|
2167
2175
|
body.reasoning = {
|
|
2168
2176
|
effort: options.thinking ?? "none",
|
|
2169
|
-
summary: "auto"
|
|
2177
|
+
summary: "auto",
|
|
2178
|
+
...responsesLite ? { context: "all_turns" } : {}
|
|
2170
2179
|
};
|
|
2171
2180
|
const headers = {
|
|
2172
2181
|
"Content-Type": "application/json",
|
|
2173
2182
|
Accept: "text/event-stream",
|
|
2174
2183
|
Authorization: `Bearer ${options.apiKey}`,
|
|
2175
2184
|
"OpenAI-Beta": "responses=experimental",
|
|
2176
|
-
originator: "ezcoder",
|
|
2177
|
-
"User-Agent": `ezcoder (${os.platform()} ${os.release()}; ${os.arch()})
|
|
2185
|
+
originator: responsesLite ? "codex_cli_rs" : "ezcoder",
|
|
2186
|
+
"User-Agent": responsesLite ? `codex_cli_rs/${CODEX_CLIENT_VERSION}` : `ezcoder (${os.platform()} ${os.release()}; ${os.arch()})`,
|
|
2187
|
+
...responsesLite ? {
|
|
2188
|
+
version: CODEX_CLIENT_VERSION,
|
|
2189
|
+
"X-OpenAI-Internal-Codex-Responses-Lite": "true"
|
|
2190
|
+
} : {}
|
|
2178
2191
|
};
|
|
2179
2192
|
if (options.accountId) {
|
|
2180
2193
|
headers["chatgpt-account-id"] = options.accountId;
|
|
@@ -2202,10 +2215,10 @@ async function* runStream3(options) {
|
|
|
2202
2215
|
if (options.model === "gpt-5.5-pro") {
|
|
2203
2216
|
hint = "Use gpt-5.5 instead. OpenAI's Codex model catalog does not list gpt-5.5-pro.";
|
|
2204
2217
|
} else {
|
|
2205
|
-
hint = "This model is not available through Codex for the authenticated account.
|
|
2218
|
+
hint = "This model is not available through Codex for the authenticated account. Switch to a model listed for OpenAI Codex via the model selector, or check your Codex usage limits.";
|
|
2206
2219
|
}
|
|
2207
2220
|
} else if (response.status === 404 && text.includes("does not exist")) {
|
|
2208
|
-
hint = "This model is not in the current OpenAI Codex catalog for this account.
|
|
2221
|
+
hint = "This model is not in the current OpenAI Codex catalog for this account. Switch to gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna, or gpt-5.5 via the model selector.";
|
|
2209
2222
|
}
|
|
2210
2223
|
throw new ProviderError("openai", message, {
|
|
2211
2224
|
statusCode: response.status,
|
|
@@ -2629,10 +2642,11 @@ var CODE_ASSIST_SUPPORTED_MODELS = /* @__PURE__ */ new Set([
|
|
|
2629
2642
|
"gemini-3.1-pro-preview",
|
|
2630
2643
|
"gemini-3.1-pro-preview-customtools",
|
|
2631
2644
|
"gemini-3-flash-preview",
|
|
2632
|
-
"gemini-3.
|
|
2645
|
+
"gemini-3.5-flash",
|
|
2646
|
+
"gemini-3-flash",
|
|
2647
|
+
"gemini-3.1-flash-lite",
|
|
2633
2648
|
"gemini-2.5-pro",
|
|
2634
2649
|
"gemini-2.5-flash",
|
|
2635
|
-
"gemini-2.5-flash-lite",
|
|
2636
2650
|
"gemma-4-31b-it",
|
|
2637
2651
|
"gemma-4-26b-a4b-it"
|
|
2638
2652
|
]);
|
|
@@ -2649,6 +2663,18 @@ function getCodeAssistEndpoint(method) {
|
|
|
2649
2663
|
function formatUnsupportedModelMessage(model) {
|
|
2650
2664
|
return `Gemini OAuth is configured to use the Gemini Code Assist subscription endpoint only. That endpoint does not currently expose model "${model}".`;
|
|
2651
2665
|
}
|
|
2666
|
+
var ACCOUNT_GATED_MODELS = /* @__PURE__ */ new Set([
|
|
2667
|
+
"gemini-3-flash",
|
|
2668
|
+
"gemini-3.5-flash",
|
|
2669
|
+
"gemini-3.1-pro-preview",
|
|
2670
|
+
"gemini-3.1-pro-preview-customtools"
|
|
2671
|
+
]);
|
|
2672
|
+
function accountGatedMessage(model) {
|
|
2673
|
+
return `Your Google account isn't entitled to "${model}" over Gemini Code Assist OAuth, so the API reports it as not found. This is an account-access limit, not a ezcoder bug.`;
|
|
2674
|
+
}
|
|
2675
|
+
function accountGatedHint() {
|
|
2676
|
+
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 \u2014 free/personal accounts usually can't call them. Switch to Gemini 3.1 Flash Lite (it works on this account) with /model, or sign in with a Code Assist Standard/Enterprise account that has preview access.`;
|
|
2677
|
+
}
|
|
2652
2678
|
function formatErrorMessage(status, body, model) {
|
|
2653
2679
|
if (status === 404 && !CODE_ASSIST_SUPPORTED_MODELS.has(model)) {
|
|
2654
2680
|
return `Gemini API error (404): ${body}
|
|
@@ -2959,7 +2985,8 @@ async function fetchCodeAssist(plan, options) {
|
|
|
2959
2985
|
if (!response.ok) {
|
|
2960
2986
|
const text = await response.text().catch(() => "");
|
|
2961
2987
|
const quota = parseGeminiQuota(response.status, text);
|
|
2962
|
-
|
|
2988
|
+
const accountGated = response.status === 404 && ACCOUNT_GATED_MODELS.has(options.model);
|
|
2989
|
+
let message = accountGated ? accountGatedMessage(options.model) : formatErrorMessage(response.status, text, options.model);
|
|
2963
2990
|
let resetsAt;
|
|
2964
2991
|
if (quota?.exhausted) {
|
|
2965
2992
|
message = `Gemini quota exhausted \u2014 usage limit reached. ${message}`;
|
|
@@ -2968,7 +2995,8 @@ async function fetchCodeAssist(plan, options) {
|
|
|
2968
2995
|
}
|
|
2969
2996
|
throw new ProviderError("gemini", message, {
|
|
2970
2997
|
statusCode: response.status,
|
|
2971
|
-
...resetsAt !== void 0 ? { resetsAt } : {}
|
|
2998
|
+
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
2999
|
+
...accountGated ? { hint: accountGatedHint() } : {}
|
|
2972
3000
|
});
|
|
2973
3001
|
}
|
|
2974
3002
|
return response;
|