@kenkaiiii/gg-ai 5.73.0 → 5.74.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 +162 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +161 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
classifyProviderError: () => classifyProviderError,
|
|
41
41
|
dropInvalidToolCalls: () => dropInvalidToolCalls,
|
|
42
42
|
environmentSecrets: () => environmentSecrets,
|
|
43
|
+
formatChatError: () => formatChatError,
|
|
43
44
|
formatError: () => formatError,
|
|
44
45
|
formatErrorForDisplay: () => formatErrorForDisplay,
|
|
45
46
|
hasLoneSurrogate: () => hasLoneSurrogate,
|
|
@@ -1494,6 +1495,10 @@ function toLocalReasoningEffort(level) {
|
|
|
1494
1495
|
function toGlmReasoningEffort(level) {
|
|
1495
1496
|
return level === "ultra" ? "max" : level;
|
|
1496
1497
|
}
|
|
1498
|
+
function toCodexReasoningEffort(level, model) {
|
|
1499
|
+
if (level !== "ultra") return level;
|
|
1500
|
+
return model === "gpt-6-astra" || model === "gpt-6.1-sol" ? "xhigh" : "max";
|
|
1501
|
+
}
|
|
1497
1502
|
function toOpenAIReasoningEffort(level, model) {
|
|
1498
1503
|
const effort = level === "max" || level === "ultra" ? "xhigh" : level;
|
|
1499
1504
|
if (model.startsWith("fugu") && (effort === "low" || effort === "medium")) {
|
|
@@ -2758,7 +2763,7 @@ function toError2(err, provider = "openai") {
|
|
|
2758
2763
|
const cleanMessage = isRawHtmlErrorEcho(messageCandidate) ? providerHtmlErrorMessage(err.status) : bodyMessage ? bodyMessage : isRawJsonErrorEcho(err.message) ? emptyProviderErrorMessage(err.status) : err.message;
|
|
2759
2764
|
let hint;
|
|
2760
2765
|
if (modelName === "codex-mini-latest" || cleanMessage.includes("codex-mini-latest")) {
|
|
2761
|
-
hint = "codex-mini-latest
|
|
2766
|
+
hint = "This request could not use codex-mini-latest. Check your account access or choose another available model.";
|
|
2762
2767
|
}
|
|
2763
2768
|
const requestId = err.request_id ?? (typeof body?.request_id === "string" ? body.request_id : void 0);
|
|
2764
2769
|
const code = typeof err.code === "string" ? err.code : void 0;
|
|
@@ -2961,7 +2966,7 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
|
|
|
2961
2966
|
// GPT-5.6/6 require at least low; older models still support thinking off.
|
|
2962
2967
|
// Apply the floor here for every caller, including one-off prompt rewrites.
|
|
2963
2968
|
// `ultra` is a client orchestration preset, not a Codex API effort.
|
|
2964
|
-
effort: options.thinking
|
|
2969
|
+
effort: options.thinking ? toCodexReasoningEffort(options.thinking, options.model) : responsesLite ? "low" : "none",
|
|
2965
2970
|
summary: "auto",
|
|
2966
2971
|
...liteShape ? { context: "all_turns" } : {}
|
|
2967
2972
|
};
|
|
@@ -3022,9 +3027,9 @@ async function* runStream3(options, retriedWithoutReasoning = false) {
|
|
|
3022
3027
|
if (usageLimit) throw usageLimit;
|
|
3023
3028
|
let hint;
|
|
3024
3029
|
if (response.status === 400 && message === `The '${options.model}' model is not supported when using Codex with a ChatGPT account.`) {
|
|
3025
|
-
hint = "This model is not available through your ChatGPT account.
|
|
3030
|
+
hint = "This model is not available through your ChatGPT account. Choose another available model using the model selector.";
|
|
3026
3031
|
} else if (response.status === 404 && text.includes("does not exist")) {
|
|
3027
|
-
hint = "This model is not in OpenAI's current catalog for your ChatGPT account.
|
|
3032
|
+
hint = "This model is not in OpenAI's current catalog for your ChatGPT account. Choose another available model using the model selector.";
|
|
3028
3033
|
}
|
|
3029
3034
|
throw new ProviderError("openai", message, {
|
|
3030
3035
|
statusCode: response.status,
|
|
@@ -3497,6 +3502,7 @@ function codexUsageLimitError(errorObj, statusCode, requestId) {
|
|
|
3497
3502
|
const isRateOr429 = CODEX_RATE_LIMIT_CODE.test(code) || statusCode === 429;
|
|
3498
3503
|
if (!isHardUsage && !(isRateOr429 && resetsAt != null)) return null;
|
|
3499
3504
|
return new ProviderError("openai", "ChatGPT usage limit reached", {
|
|
3505
|
+
cause: errorObj,
|
|
3500
3506
|
statusCode: statusCode ?? 429,
|
|
3501
3507
|
...requestId ? { requestId } : {},
|
|
3502
3508
|
...resetsAt ? { resetsAt } : {}
|
|
@@ -4421,6 +4427,157 @@ function messagesContainVideo(messages) {
|
|
|
4421
4427
|
return false;
|
|
4422
4428
|
}
|
|
4423
4429
|
|
|
4430
|
+
// src/chat-error.ts
|
|
4431
|
+
function causeCode(error) {
|
|
4432
|
+
if (!(error instanceof Error) || !error.cause || typeof error.cause !== "object") return "";
|
|
4433
|
+
const cause = error.cause;
|
|
4434
|
+
if ("code" in cause && typeof cause.code === "string") return cause.code;
|
|
4435
|
+
if ("type" in cause && typeof cause.type === "string") return cause.type;
|
|
4436
|
+
return "";
|
|
4437
|
+
}
|
|
4438
|
+
function formatChatError(error) {
|
|
4439
|
+
const base = formatError(error);
|
|
4440
|
+
const raw = error instanceof Error ? error.message : "";
|
|
4441
|
+
const code = causeCode(error);
|
|
4442
|
+
const text = `${code} ${raw}`.toLowerCase();
|
|
4443
|
+
const provider = /chatgpt/i.test(raw) ? "ChatGPT" : providerLabel(base.provider);
|
|
4444
|
+
const present = (reason, headline, guidance) => ({
|
|
4445
|
+
...base,
|
|
4446
|
+
...raw ? { message: raw } : {},
|
|
4447
|
+
reason,
|
|
4448
|
+
headline,
|
|
4449
|
+
guidance
|
|
4450
|
+
});
|
|
4451
|
+
if (error instanceof VideoUnsupportedError) {
|
|
4452
|
+
return present(
|
|
4453
|
+
"capability",
|
|
4454
|
+
"This model can\u2019t read this video",
|
|
4455
|
+
"Choose a model that supports video."
|
|
4456
|
+
);
|
|
4457
|
+
}
|
|
4458
|
+
if (base.source === "capability") {
|
|
4459
|
+
return present(
|
|
4460
|
+
"unknown",
|
|
4461
|
+
"This request isn\u2019t supported",
|
|
4462
|
+
"Open details to check the request requirements."
|
|
4463
|
+
);
|
|
4464
|
+
}
|
|
4465
|
+
if (/requires a newer version of codex/.test(text)) {
|
|
4466
|
+
return present(
|
|
4467
|
+
"update",
|
|
4468
|
+
"GG Coder needs an update",
|
|
4469
|
+
"Update the app, or choose another model."
|
|
4470
|
+
);
|
|
4471
|
+
}
|
|
4472
|
+
if (/insufficient.*(?:balance|credits?)|(?:balance|credits?).*(?:insufficient|exhausted|depleted)|credit balance is too low|payment_required/.test(
|
|
4473
|
+
text
|
|
4474
|
+
)) {
|
|
4475
|
+
return present(
|
|
4476
|
+
"billing",
|
|
4477
|
+
`${provider} credits are unavailable`,
|
|
4478
|
+
"Check your balance and billing, or use another provider."
|
|
4479
|
+
);
|
|
4480
|
+
}
|
|
4481
|
+
if (/usage_not_included|does not yet include access|not supported when using codex with a chatgpt account|(?:model[^\n]*(?:not found|not available|does not exist))|model_not_found/.test(
|
|
4482
|
+
text
|
|
4483
|
+
)) {
|
|
4484
|
+
return present(
|
|
4485
|
+
"model_access",
|
|
4486
|
+
"This model isn\u2019t available to this account",
|
|
4487
|
+
"Choose another model available to your account."
|
|
4488
|
+
);
|
|
4489
|
+
}
|
|
4490
|
+
if (/insufficient_quota|exceeded your current quota|billing.?limit|spend.?limit|quota.?exceeded/.test(
|
|
4491
|
+
text
|
|
4492
|
+
)) {
|
|
4493
|
+
return present(
|
|
4494
|
+
"quota",
|
|
4495
|
+
`${provider} quota is unavailable`,
|
|
4496
|
+
"Check your plan or billing, or use another provider."
|
|
4497
|
+
);
|
|
4498
|
+
}
|
|
4499
|
+
if (/^rate_limit_exceeded$/i.test(code)) {
|
|
4500
|
+
return present(
|
|
4501
|
+
"rate_limit",
|
|
4502
|
+
`${provider} is limiting requests`,
|
|
4503
|
+
"Wait a moment before trying again."
|
|
4504
|
+
);
|
|
4505
|
+
}
|
|
4506
|
+
if (/usage limit reached|usage_limit_reached/.test(text)) {
|
|
4507
|
+
return present(
|
|
4508
|
+
"usage_limit",
|
|
4509
|
+
`${provider} usage limit reached`,
|
|
4510
|
+
"Wait for the reset, or use another provider."
|
|
4511
|
+
);
|
|
4512
|
+
}
|
|
4513
|
+
if (base.source === "network") {
|
|
4514
|
+
return present(
|
|
4515
|
+
"network",
|
|
4516
|
+
"Couldn\u2019t reach the provider",
|
|
4517
|
+
"Check your connection before trying again."
|
|
4518
|
+
);
|
|
4519
|
+
}
|
|
4520
|
+
if (base.source === "auth" || base.statusCode === 401) {
|
|
4521
|
+
return present(
|
|
4522
|
+
"auth",
|
|
4523
|
+
`${provider} sign-in needs attention`,
|
|
4524
|
+
"Reconnect your account in provider settings."
|
|
4525
|
+
);
|
|
4526
|
+
}
|
|
4527
|
+
if (base.statusCode === 413 || /context[_ ](?:length|window)|maximum context|request_too_large|prompt is too long/.test(text)) {
|
|
4528
|
+
return present(
|
|
4529
|
+
"context",
|
|
4530
|
+
"This conversation is too large",
|
|
4531
|
+
"Compact the conversation or send a smaller request."
|
|
4532
|
+
);
|
|
4533
|
+
}
|
|
4534
|
+
if (base.statusCode === 429 || /rate_limit|rate limit|too many requests/.test(text)) {
|
|
4535
|
+
return present(
|
|
4536
|
+
"rate_limit",
|
|
4537
|
+
`${provider} is limiting requests`,
|
|
4538
|
+
"Wait a moment before trying again."
|
|
4539
|
+
);
|
|
4540
|
+
}
|
|
4541
|
+
if (base.statusCode === 403) {
|
|
4542
|
+
return present(
|
|
4543
|
+
"model_access",
|
|
4544
|
+
"This account can\u2019t use this request",
|
|
4545
|
+
"Check account access or choose another model."
|
|
4546
|
+
);
|
|
4547
|
+
}
|
|
4548
|
+
if (error instanceof ProviderError) {
|
|
4549
|
+
if (base.statusCode != null && base.statusCode >= 500) {
|
|
4550
|
+
return present(
|
|
4551
|
+
"provider",
|
|
4552
|
+
`${provider} couldn\u2019t complete the request`,
|
|
4553
|
+
"Try again later. Check details if it keeps happening."
|
|
4554
|
+
);
|
|
4555
|
+
}
|
|
4556
|
+
return present(
|
|
4557
|
+
"provider",
|
|
4558
|
+
`${provider} didn\u2019t accept the request`,
|
|
4559
|
+
"Check the details before trying again."
|
|
4560
|
+
);
|
|
4561
|
+
}
|
|
4562
|
+
return present("unknown", "Something went wrong", "Open details to see what was reported.");
|
|
4563
|
+
}
|
|
4564
|
+
function providerLabel(provider) {
|
|
4565
|
+
switch (provider) {
|
|
4566
|
+
case "openai":
|
|
4567
|
+
return "OpenAI";
|
|
4568
|
+
case "anthropic":
|
|
4569
|
+
return "Anthropic";
|
|
4570
|
+
case "gemini":
|
|
4571
|
+
return "Gemini";
|
|
4572
|
+
case "xai":
|
|
4573
|
+
return "xAI";
|
|
4574
|
+
case "local":
|
|
4575
|
+
return "The local server";
|
|
4576
|
+
default:
|
|
4577
|
+
return "The provider";
|
|
4578
|
+
}
|
|
4579
|
+
}
|
|
4580
|
+
|
|
4424
4581
|
// src/error-classification.ts
|
|
4425
4582
|
var CONTEXT_OVERFLOW_PATTERNS = [
|
|
4426
4583
|
/context_length_exceeded/i,
|
|
@@ -4811,6 +4968,7 @@ function registerPalsuProvider(config) {
|
|
|
4811
4968
|
classifyProviderError,
|
|
4812
4969
|
dropInvalidToolCalls,
|
|
4813
4970
|
environmentSecrets,
|
|
4971
|
+
formatChatError,
|
|
4814
4972
|
formatError,
|
|
4815
4973
|
formatErrorForDisplay,
|
|
4816
4974
|
hasLoneSurrogate,
|