@prestyj/ai 5.16.0 → 5.16.2
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 +34 -18
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +34 -18
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -235,6 +235,9 @@ function providerGuidance(provider, message, statusCode) {
|
|
|
235
235
|
if (statusCode === 401 || lower.includes("unauthorized") || lower.includes("invalid api key")) {
|
|
236
236
|
return `Authentication failed with ${name}. Re-authenticate to refresh your credentials.`;
|
|
237
237
|
}
|
|
238
|
+
if (lower.includes("requires a newer version")) {
|
|
239
|
+
return `${name} needs a newer EZ Coder to serve this model. Update EZ Coder to the latest version and retry, or switch to another ${name} model via the model selector.`;
|
|
240
|
+
}
|
|
238
241
|
if (lower.includes("overloaded") || lower.includes("engine_overloaded")) {
|
|
239
242
|
return `${name}'s servers are overloaded right now. Retry in a moment \u2014 not a EZ Coder issue.`;
|
|
240
243
|
}
|
|
@@ -982,7 +985,7 @@ function toOpenAIMessages(messages, options) {
|
|
|
982
985
|
(part) => {
|
|
983
986
|
if (part.type === "text") return { type: "text", text: part.text };
|
|
984
987
|
if (part.type === "video") {
|
|
985
|
-
const videoUrl = part.fileId ? { url: `ms://${part.fileId}`, id: part.fileId } : { url: `data:${part.mediaType};base64,${part.data}` };
|
|
988
|
+
const videoUrl = options?.provider === "moonshot" && part.fileId ? { url: `ms://${part.fileId}`, id: part.fileId } : { url: `data:${part.mediaType};base64,${part.data}` };
|
|
986
989
|
return {
|
|
987
990
|
type: "video_url",
|
|
988
991
|
video_url: videoUrl
|
|
@@ -1921,7 +1924,7 @@ async function* runStream2(options) {
|
|
|
1921
1924
|
const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
|
|
1922
1925
|
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1923
1926
|
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1924
|
-
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1927
|
+
const usesThinkingParam = options.provider === "deepseek" || options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1925
1928
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1926
1929
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1927
1930
|
if (options.provider === "moonshot") {
|
|
@@ -1947,7 +1950,7 @@ async function* runStream2(options) {
|
|
|
1947
1950
|
model: options.model,
|
|
1948
1951
|
messages,
|
|
1949
1952
|
stream: useStreaming,
|
|
1950
|
-
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
1953
|
+
...options.maxTokens ? options.provider === "deepseek" || options.provider === "glm" || options.provider === "moonshot" ? { max_tokens: options.maxTokens } : { max_completion_tokens: options.maxTokens } : {},
|
|
1951
1954
|
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
1952
1955
|
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
1953
1956
|
...options.stop ? { stop: options.stop } : {},
|
|
@@ -1959,7 +1962,7 @@ async function* runStream2(options) {
|
|
|
1959
1962
|
if (options.provider === "openai" || options.provider === "moonshot") {
|
|
1960
1963
|
const paramsAny = params;
|
|
1961
1964
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ezcoder");
|
|
1962
|
-
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
1965
|
+
if (options.provider === "openai" && (options.model.startsWith("gpt-5.6") || options.model.startsWith("gpt-6"))) {
|
|
1963
1966
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
1964
1967
|
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
1965
1968
|
paramsAny.prompt_cache_retention = "24h";
|
|
@@ -1970,6 +1973,9 @@ async function* runStream2(options) {
|
|
|
1970
1973
|
options.thinking
|
|
1971
1974
|
);
|
|
1972
1975
|
}
|
|
1976
|
+
if (options.provider === "sakana" && options.model === "fugu-ultra" && (options.thinking === "max" || options.thinking === "ultra")) {
|
|
1977
|
+
params.reasoning_effort = "max";
|
|
1978
|
+
}
|
|
1973
1979
|
if (options.provider === "openai" && options.serviceTier) {
|
|
1974
1980
|
params.service_tier = options.serviceTier;
|
|
1975
1981
|
}
|
|
@@ -1986,7 +1992,9 @@ async function* runStream2(options) {
|
|
|
1986
1992
|
if (usesThinkingParam) {
|
|
1987
1993
|
if (options.thinking) {
|
|
1988
1994
|
params.thinking = { type: "enabled" };
|
|
1989
|
-
if (options.provider === "
|
|
1995
|
+
if (options.provider === "deepseek") {
|
|
1996
|
+
params.reasoning_effort = options.thinking === "low" ? "low" : options.thinking === "medium" || options.thinking === "high" ? "high" : "max";
|
|
1997
|
+
} else if (options.provider === "glm") {
|
|
1990
1998
|
params.reasoning_effort = toGlmReasoningEffort(
|
|
1991
1999
|
options.thinking
|
|
1992
2000
|
);
|
|
@@ -2381,7 +2389,7 @@ function extractRequestIdFromMessage(message) {
|
|
|
2381
2389
|
|
|
2382
2390
|
// src/providers/openai-codex.ts
|
|
2383
2391
|
var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
|
|
2384
|
-
var CODEX_CLIENT_VERSION = "0.
|
|
2392
|
+
var CODEX_CLIENT_VERSION = "0.153.4";
|
|
2385
2393
|
var CODEX_REQUEST_COMPRESSION_MIN_BYTES = 16 * 1024;
|
|
2386
2394
|
var zstdInitPromise;
|
|
2387
2395
|
async function encodeCodexRequest(body) {
|
|
@@ -2427,7 +2435,7 @@ async function encodeCodexRequest(body) {
|
|
|
2427
2435
|
}
|
|
2428
2436
|
}
|
|
2429
2437
|
function usesResponsesLite(model) {
|
|
2430
|
-
return model.startsWith("gpt-5.6-");
|
|
2438
|
+
return model.startsWith("gpt-5.6-") || model.startsWith("gpt-6-");
|
|
2431
2439
|
}
|
|
2432
2440
|
function outputTextKey(itemId, contentIndex) {
|
|
2433
2441
|
return `${itemId ?? ""}:${contentIndex ?? 0}`;
|
|
@@ -2481,8 +2489,10 @@ async function* runStream3(options) {
|
|
|
2481
2489
|
body.temperature = options.temperature;
|
|
2482
2490
|
}
|
|
2483
2491
|
body.reasoning = {
|
|
2492
|
+
// GPT-5.6/6 require at least low; older models still support thinking off.
|
|
2493
|
+
// Apply the floor here for every caller, including one-off prompt rewrites.
|
|
2484
2494
|
// `ultra` is a client orchestration preset, not a Codex API effort.
|
|
2485
|
-
effort: options.thinking === "ultra" ? "max" : options.thinking ?? "none",
|
|
2495
|
+
effort: options.thinking === "ultra" ? "max" : options.thinking ?? (responsesLite ? "low" : "none"),
|
|
2486
2496
|
summary: "auto",
|
|
2487
2497
|
...responsesLite ? { context: "all_turns" } : {}
|
|
2488
2498
|
};
|
|
@@ -2527,14 +2537,10 @@ async function* runStream3(options) {
|
|
|
2527
2537
|
const usageLimit = codexUsageLimitError(parsed.errorObj, response.status, requestId);
|
|
2528
2538
|
if (usageLimit) throw usageLimit;
|
|
2529
2539
|
let hint;
|
|
2530
|
-
if (response.status === 400 &&
|
|
2531
|
-
|
|
2532
|
-
hint = "Use gpt-5.5 instead. OpenAI's Codex model catalog does not list gpt-5.5-pro.";
|
|
2533
|
-
} else {
|
|
2534
|
-
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.";
|
|
2535
|
-
}
|
|
2540
|
+
if (response.status === 400 && message === `The '${options.model}' model is not supported when using Codex with a ChatGPT account.`) {
|
|
2541
|
+
hint = "This model is not available through your ChatGPT account. Switch to a model listed for OpenAI via the model selector, or check your ChatGPT usage limits.";
|
|
2536
2542
|
} else if (response.status === 404 && text.includes("does not exist")) {
|
|
2537
|
-
hint = "This model is not in
|
|
2543
|
+
hint = "This model is not in OpenAI's current catalog for your ChatGPT account. Switch to GPT-6 Astra, GPT-5.6 Sol, GPT-5.6 Terra, or GPT-5.6 Luna via the model selector.";
|
|
2538
2544
|
}
|
|
2539
2545
|
throw new ProviderError("openai", message, {
|
|
2540
2546
|
statusCode: response.status,
|
|
@@ -2974,6 +2980,8 @@ var CODE_ASSIST_SUPPORTED_MODELS = /* @__PURE__ */ new Set([
|
|
|
2974
2980
|
"gemini-3-flash",
|
|
2975
2981
|
"gemini-3.1-flash-lite",
|
|
2976
2982
|
"gemini-3.7-flash",
|
|
2983
|
+
"gemini-3.8-flash",
|
|
2984
|
+
"gemini-3.5-flash-lite",
|
|
2977
2985
|
"gemini-2.5-pro",
|
|
2978
2986
|
"gemini-2.5-flash",
|
|
2979
2987
|
"gemma-4-31b-it",
|
|
@@ -2997,12 +3005,20 @@ var ACCOUNT_GATED_MODELS = /* @__PURE__ */ new Set([
|
|
|
2997
3005
|
"gemini-3.5-flash",
|
|
2998
3006
|
"gemini-3.1-pro-preview",
|
|
2999
3007
|
"gemini-3.1-pro-preview-customtools",
|
|
3000
|
-
"gemini-3.7-flash"
|
|
3008
|
+
"gemini-3.7-flash",
|
|
3009
|
+
"gemini-3.8-flash",
|
|
3010
|
+
"gemini-3.5-flash-lite"
|
|
3001
3011
|
]);
|
|
3002
3012
|
function accountGatedMessage(model) {
|
|
3013
|
+
if (model === "gemini-3.8-flash" || model === "gemini-3.5-flash-lite") {
|
|
3014
|
+
return `${model} is not available through Code Assist for this account. Public Gemini API availability does not guarantee Code Assist OAuth access.`;
|
|
3015
|
+
}
|
|
3003
3016
|
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.`;
|
|
3004
3017
|
}
|
|
3005
|
-
function accountGatedHint() {
|
|
3018
|
+
function accountGatedHint(model) {
|
|
3019
|
+
if (model === "gemini-3.8-flash" || model === "gemini-3.5-flash-lite") {
|
|
3020
|
+
return "Use /model to select Gemini 3.1 Flash Lite, or retry once Google enables this model through Code Assist for your account.";
|
|
3021
|
+
}
|
|
3006
3022
|
return `Newer Gemini models (3.7 Flash, 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.`;
|
|
3007
3023
|
}
|
|
3008
3024
|
function formatErrorMessage(status, body, model) {
|
|
@@ -3328,7 +3344,7 @@ async function fetchCodeAssist(plan, options) {
|
|
|
3328
3344
|
throw new ProviderError("gemini", message, {
|
|
3329
3345
|
statusCode: response.status,
|
|
3330
3346
|
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
3331
|
-
...accountGated ? { hint: accountGatedHint() } : {}
|
|
3347
|
+
...accountGated ? { hint: accountGatedHint(options.model) } : {}
|
|
3332
3348
|
});
|
|
3333
3349
|
}
|
|
3334
3350
|
return response;
|