@prestyj/ai 5.16.1 → 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.cjs
CHANGED
|
@@ -302,6 +302,9 @@ function providerGuidance(provider, message, statusCode) {
|
|
|
302
302
|
if (statusCode === 401 || lower.includes("unauthorized") || lower.includes("invalid api key")) {
|
|
303
303
|
return `Authentication failed with ${name}. Re-authenticate to refresh your credentials.`;
|
|
304
304
|
}
|
|
305
|
+
if (lower.includes("requires a newer version")) {
|
|
306
|
+
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.`;
|
|
307
|
+
}
|
|
305
308
|
if (lower.includes("overloaded") || lower.includes("engine_overloaded")) {
|
|
306
309
|
return `${name}'s servers are overloaded right now. Retry in a moment \u2014 not a EZ Coder issue.`;
|
|
307
310
|
}
|
|
@@ -1049,7 +1052,7 @@ function toOpenAIMessages(messages, options) {
|
|
|
1049
1052
|
(part) => {
|
|
1050
1053
|
if (part.type === "text") return { type: "text", text: part.text };
|
|
1051
1054
|
if (part.type === "video") {
|
|
1052
|
-
const videoUrl = part.fileId ? { url: `ms://${part.fileId}`, id: part.fileId } : { url: `data:${part.mediaType};base64,${part.data}` };
|
|
1055
|
+
const videoUrl = options?.provider === "moonshot" && part.fileId ? { url: `ms://${part.fileId}`, id: part.fileId } : { url: `data:${part.mediaType};base64,${part.data}` };
|
|
1053
1056
|
return {
|
|
1054
1057
|
type: "video_url",
|
|
1055
1058
|
video_url: videoUrl
|
|
@@ -1988,7 +1991,7 @@ async function* runStream2(options) {
|
|
|
1988
1991
|
const k3Effort = options.thinking ? toKimiK3Effort(options.thinking) : void 0;
|
|
1989
1992
|
const isKimiK27 = options.provider === "moonshot" && options.model.startsWith("kimi-k2.7-code");
|
|
1990
1993
|
const hasFixedKimiSampling = isKimiK3 || isKimiK27;
|
|
1991
|
-
const usesThinkingParam = options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1994
|
+
const usesThinkingParam = options.provider === "deepseek" || options.provider === "glm" || options.provider === "moonshot" && !isKimiK3 && !isKimiK27 || options.provider === "xiaomi";
|
|
1992
1995
|
const downgradedImages = downgradeUnsupportedImages(options.messages, options.supportsImages);
|
|
1993
1996
|
const downgradedMessages = downgradeUnsupportedVideos(downgradedImages, options.supportsVideo);
|
|
1994
1997
|
if (options.provider === "moonshot") {
|
|
@@ -2014,7 +2017,7 @@ async function* runStream2(options) {
|
|
|
2014
2017
|
model: options.model,
|
|
2015
2018
|
messages,
|
|
2016
2019
|
stream: useStreaming,
|
|
2017
|
-
...options.maxTokens ? { max_completion_tokens: options.maxTokens } : {},
|
|
2020
|
+
...options.maxTokens ? options.provider === "deepseek" || options.provider === "glm" || options.provider === "moonshot" ? { max_tokens: options.maxTokens } : { max_completion_tokens: options.maxTokens } : {},
|
|
2018
2021
|
...effectiveTemp != null && !options.thinking && !hasFixedKimiSampling ? { temperature: effectiveTemp } : {},
|
|
2019
2022
|
...options.topP != null && !hasFixedKimiSampling ? { top_p: options.topP } : {},
|
|
2020
2023
|
...options.stop ? { stop: options.stop } : {},
|
|
@@ -2026,7 +2029,7 @@ async function* runStream2(options) {
|
|
|
2026
2029
|
if (options.provider === "openai" || options.provider === "moonshot") {
|
|
2027
2030
|
const paramsAny = params;
|
|
2028
2031
|
paramsAny.prompt_cache_key = normalizePromptCacheKey(options.promptCacheKey ?? "ezcoder");
|
|
2029
|
-
if (options.provider === "openai" && options.model.startsWith("gpt-5.6")) {
|
|
2032
|
+
if (options.provider === "openai" && (options.model.startsWith("gpt-5.6") || options.model.startsWith("gpt-6"))) {
|
|
2030
2033
|
paramsAny.prompt_cache_options = { mode: "implicit", ttl: "30m" };
|
|
2031
2034
|
} else if (!isKimiK3 && (options.cacheRetention ?? "short") === "long") {
|
|
2032
2035
|
paramsAny.prompt_cache_retention = "24h";
|
|
@@ -2037,6 +2040,9 @@ async function* runStream2(options) {
|
|
|
2037
2040
|
options.thinking
|
|
2038
2041
|
);
|
|
2039
2042
|
}
|
|
2043
|
+
if (options.provider === "sakana" && options.model === "fugu-ultra" && (options.thinking === "max" || options.thinking === "ultra")) {
|
|
2044
|
+
params.reasoning_effort = "max";
|
|
2045
|
+
}
|
|
2040
2046
|
if (options.provider === "openai" && options.serviceTier) {
|
|
2041
2047
|
params.service_tier = options.serviceTier;
|
|
2042
2048
|
}
|
|
@@ -2053,7 +2059,9 @@ async function* runStream2(options) {
|
|
|
2053
2059
|
if (usesThinkingParam) {
|
|
2054
2060
|
if (options.thinking) {
|
|
2055
2061
|
params.thinking = { type: "enabled" };
|
|
2056
|
-
if (options.provider === "
|
|
2062
|
+
if (options.provider === "deepseek") {
|
|
2063
|
+
params.reasoning_effort = options.thinking === "low" ? "low" : options.thinking === "medium" || options.thinking === "high" ? "high" : "max";
|
|
2064
|
+
} else if (options.provider === "glm") {
|
|
2057
2065
|
params.reasoning_effort = toGlmReasoningEffort(
|
|
2058
2066
|
options.thinking
|
|
2059
2067
|
);
|
|
@@ -2448,7 +2456,7 @@ function extractRequestIdFromMessage(message) {
|
|
|
2448
2456
|
|
|
2449
2457
|
// src/providers/openai-codex.ts
|
|
2450
2458
|
var DEFAULT_BASE_URL = "https://chatgpt.com/backend-api";
|
|
2451
|
-
var CODEX_CLIENT_VERSION = "0.
|
|
2459
|
+
var CODEX_CLIENT_VERSION = "0.153.4";
|
|
2452
2460
|
var CODEX_REQUEST_COMPRESSION_MIN_BYTES = 16 * 1024;
|
|
2453
2461
|
var zstdInitPromise;
|
|
2454
2462
|
async function encodeCodexRequest(body) {
|
|
@@ -2494,7 +2502,7 @@ async function encodeCodexRequest(body) {
|
|
|
2494
2502
|
}
|
|
2495
2503
|
}
|
|
2496
2504
|
function usesResponsesLite(model) {
|
|
2497
|
-
return model.startsWith("gpt-5.6-");
|
|
2505
|
+
return model.startsWith("gpt-5.6-") || model.startsWith("gpt-6-");
|
|
2498
2506
|
}
|
|
2499
2507
|
function outputTextKey(itemId, contentIndex) {
|
|
2500
2508
|
return `${itemId ?? ""}:${contentIndex ?? 0}`;
|
|
@@ -2548,8 +2556,10 @@ async function* runStream3(options) {
|
|
|
2548
2556
|
body.temperature = options.temperature;
|
|
2549
2557
|
}
|
|
2550
2558
|
body.reasoning = {
|
|
2559
|
+
// GPT-5.6/6 require at least low; older models still support thinking off.
|
|
2560
|
+
// Apply the floor here for every caller, including one-off prompt rewrites.
|
|
2551
2561
|
// `ultra` is a client orchestration preset, not a Codex API effort.
|
|
2552
|
-
effort: options.thinking === "ultra" ? "max" : options.thinking ?? "none",
|
|
2562
|
+
effort: options.thinking === "ultra" ? "max" : options.thinking ?? (responsesLite ? "low" : "none"),
|
|
2553
2563
|
summary: "auto",
|
|
2554
2564
|
...responsesLite ? { context: "all_turns" } : {}
|
|
2555
2565
|
};
|
|
@@ -2594,14 +2604,10 @@ async function* runStream3(options) {
|
|
|
2594
2604
|
const usageLimit = codexUsageLimitError(parsed.errorObj, response.status, requestId);
|
|
2595
2605
|
if (usageLimit) throw usageLimit;
|
|
2596
2606
|
let hint;
|
|
2597
|
-
if (response.status === 400 &&
|
|
2598
|
-
|
|
2599
|
-
hint = "Use gpt-5.5 instead. OpenAI's Codex model catalog does not list gpt-5.5-pro.";
|
|
2600
|
-
} else {
|
|
2601
|
-
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.";
|
|
2602
|
-
}
|
|
2607
|
+
if (response.status === 400 && message === `The '${options.model}' model is not supported when using Codex with a ChatGPT account.`) {
|
|
2608
|
+
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.";
|
|
2603
2609
|
} else if (response.status === 404 && text.includes("does not exist")) {
|
|
2604
|
-
hint = "This model is not in
|
|
2610
|
+
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.";
|
|
2605
2611
|
}
|
|
2606
2612
|
throw new ProviderError("openai", message, {
|
|
2607
2613
|
statusCode: response.status,
|
|
@@ -3041,6 +3047,8 @@ var CODE_ASSIST_SUPPORTED_MODELS = /* @__PURE__ */ new Set([
|
|
|
3041
3047
|
"gemini-3-flash",
|
|
3042
3048
|
"gemini-3.1-flash-lite",
|
|
3043
3049
|
"gemini-3.7-flash",
|
|
3050
|
+
"gemini-3.8-flash",
|
|
3051
|
+
"gemini-3.5-flash-lite",
|
|
3044
3052
|
"gemini-2.5-pro",
|
|
3045
3053
|
"gemini-2.5-flash",
|
|
3046
3054
|
"gemma-4-31b-it",
|
|
@@ -3064,12 +3072,20 @@ var ACCOUNT_GATED_MODELS = /* @__PURE__ */ new Set([
|
|
|
3064
3072
|
"gemini-3.5-flash",
|
|
3065
3073
|
"gemini-3.1-pro-preview",
|
|
3066
3074
|
"gemini-3.1-pro-preview-customtools",
|
|
3067
|
-
"gemini-3.7-flash"
|
|
3075
|
+
"gemini-3.7-flash",
|
|
3076
|
+
"gemini-3.8-flash",
|
|
3077
|
+
"gemini-3.5-flash-lite"
|
|
3068
3078
|
]);
|
|
3069
3079
|
function accountGatedMessage(model) {
|
|
3080
|
+
if (model === "gemini-3.8-flash" || model === "gemini-3.5-flash-lite") {
|
|
3081
|
+
return `${model} is not available through Code Assist for this account. Public Gemini API availability does not guarantee Code Assist OAuth access.`;
|
|
3082
|
+
}
|
|
3070
3083
|
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.`;
|
|
3071
3084
|
}
|
|
3072
|
-
function accountGatedHint() {
|
|
3085
|
+
function accountGatedHint(model) {
|
|
3086
|
+
if (model === "gemini-3.8-flash" || model === "gemini-3.5-flash-lite") {
|
|
3087
|
+
return "Use /model to select Gemini 3.1 Flash Lite, or retry once Google enables this model through Code Assist for your account.";
|
|
3088
|
+
}
|
|
3073
3089
|
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.`;
|
|
3074
3090
|
}
|
|
3075
3091
|
function formatErrorMessage(status, body, model) {
|
|
@@ -3395,7 +3411,7 @@ async function fetchCodeAssist(plan, options) {
|
|
|
3395
3411
|
throw new ProviderError("gemini", message, {
|
|
3396
3412
|
statusCode: response.status,
|
|
3397
3413
|
...resetsAt !== void 0 ? { resetsAt } : {},
|
|
3398
|
-
...accountGated ? { hint: accountGatedHint() } : {}
|
|
3414
|
+
...accountGated ? { hint: accountGatedHint(options.model) } : {}
|
|
3399
3415
|
});
|
|
3400
3416
|
}
|
|
3401
3417
|
return response;
|