@kenkaiiii/gg-ai 4.3.242 → 4.4.0
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 +92 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -34,6 +34,7 @@ __export(index_exports, {
|
|
|
34
34
|
GGAIError: () => GGAIError,
|
|
35
35
|
ProviderError: () => ProviderError,
|
|
36
36
|
StreamResult: () => StreamResult,
|
|
37
|
+
classifyProviderError: () => classifyProviderError,
|
|
37
38
|
formatError: () => formatError,
|
|
38
39
|
formatErrorForDisplay: () => formatErrorForDisplay,
|
|
39
40
|
isHardBillingMessage: () => isHardBillingMessage,
|
|
@@ -2876,6 +2877,96 @@ function stream(options) {
|
|
|
2876
2877
|
return entry.stream(options);
|
|
2877
2878
|
}
|
|
2878
2879
|
|
|
2880
|
+
// src/error-classification.ts
|
|
2881
|
+
var CONTEXT_OVERFLOW_PATTERNS = [
|
|
2882
|
+
/context_length_exceeded/i,
|
|
2883
|
+
/context length exceeded/i,
|
|
2884
|
+
/context window/i,
|
|
2885
|
+
// OpenAI Codex / Responses
|
|
2886
|
+
/maximum context length/i,
|
|
2887
|
+
// OpenAI / OpenRouter / Mistral
|
|
2888
|
+
/prompt is too long/i,
|
|
2889
|
+
// Anthropic
|
|
2890
|
+
/request_too_large/i,
|
|
2891
|
+
// Anthropic HTTP 413
|
|
2892
|
+
/input is too long/i,
|
|
2893
|
+
// Bedrock
|
|
2894
|
+
/input token count.*exceeds the maximum/i,
|
|
2895
|
+
// Gemini
|
|
2896
|
+
/maximum prompt length/i,
|
|
2897
|
+
// xAI / Grok
|
|
2898
|
+
/reduce the length of the messages/i,
|
|
2899
|
+
// Groq
|
|
2900
|
+
/too large for model/i,
|
|
2901
|
+
// Mistral
|
|
2902
|
+
/token limit/i
|
|
2903
|
+
// generic
|
|
2904
|
+
];
|
|
2905
|
+
var RATE_LIMIT_PATTERNS = [
|
|
2906
|
+
/rate[ _-]?limit/i,
|
|
2907
|
+
/\b429\b/,
|
|
2908
|
+
/too many requests/i,
|
|
2909
|
+
/tokens per minute/i,
|
|
2910
|
+
/requests per minute/i
|
|
2911
|
+
];
|
|
2912
|
+
var PROVIDER_TRANSIENT_PATTERNS = [
|
|
2913
|
+
/\b5\d\d\b/,
|
|
2914
|
+
/api_error/i,
|
|
2915
|
+
/server_error/i,
|
|
2916
|
+
/internal server error/i,
|
|
2917
|
+
/bad gateway/i,
|
|
2918
|
+
/service unavailable/i,
|
|
2919
|
+
/gateway timeout/i,
|
|
2920
|
+
/overloaded/i,
|
|
2921
|
+
/\b529\b/
|
|
2922
|
+
];
|
|
2923
|
+
var BILLING_PATTERNS = [
|
|
2924
|
+
/payment required/i,
|
|
2925
|
+
/\b402\b/,
|
|
2926
|
+
/quota_exceeded/i,
|
|
2927
|
+
// underscore variant not in isHardBillingMessage
|
|
2928
|
+
/credit balance/i
|
|
2929
|
+
];
|
|
2930
|
+
var AUTH_PATTERNS = [
|
|
2931
|
+
/invalid[ _]api[ _]key/i,
|
|
2932
|
+
/unauthorized/i,
|
|
2933
|
+
/\b401\b/,
|
|
2934
|
+
/authentication[ _]failed/i,
|
|
2935
|
+
/please run \/login/i
|
|
2936
|
+
// Anthropic Claude Code-style hint
|
|
2937
|
+
];
|
|
2938
|
+
function matchesAny(message, patterns) {
|
|
2939
|
+
return patterns.some((p) => p.test(message));
|
|
2940
|
+
}
|
|
2941
|
+
function classifyProviderError(message) {
|
|
2942
|
+
if (matchesAny(message, CONTEXT_OVERFLOW_PATTERNS)) {
|
|
2943
|
+
return `[context_overflow] Worker context window exceeded \u2014 the conversation is too large to continue. Recovery: call reset_worker(project) to wipe history, then re-prompt with the task. Re-prompting WITHOUT reset will fail the same way.
|
|
2944
|
+
|
|
2945
|
+
Original: ${message}`;
|
|
2946
|
+
}
|
|
2947
|
+
if (isHardBillingMessage(message) || matchesAny(message, BILLING_PATTERNS)) {
|
|
2948
|
+
return `[billing] Provider billing/quota issue. Recovery: surface to the user \u2014 they need to top up or switch providers. Do NOT retry.
|
|
2949
|
+
|
|
2950
|
+
Original: ${message}`;
|
|
2951
|
+
}
|
|
2952
|
+
if (matchesAny(message, AUTH_PATTERNS)) {
|
|
2953
|
+
return `[auth] Provider authentication failed. Recovery: surface to the user \u2014 they need to re-login. Do NOT retry.
|
|
2954
|
+
|
|
2955
|
+
Original: ${message}`;
|
|
2956
|
+
}
|
|
2957
|
+
if (matchesAny(message, RATE_LIMIT_PATTERNS)) {
|
|
2958
|
+
return `[rate_limited] Provider rate limit hit. Recovery: wait ~30s, then re-prompt the same worker (no reset needed).
|
|
2959
|
+
|
|
2960
|
+
Original: ${message}`;
|
|
2961
|
+
}
|
|
2962
|
+
if (matchesAny(message, PROVIDER_TRANSIENT_PATTERNS)) {
|
|
2963
|
+
return `[provider_transient] Provider server-side/transient error. Recovery: wait briefly, then re-prompt the same worker (no reset needed). If it keeps happening, switch models/providers or check provider status.
|
|
2964
|
+
|
|
2965
|
+
Original: ${message}`;
|
|
2966
|
+
}
|
|
2967
|
+
return message;
|
|
2968
|
+
}
|
|
2969
|
+
|
|
2879
2970
|
// src/providers/palsu.ts
|
|
2880
2971
|
function palsuText(text) {
|
|
2881
2972
|
return { role: "assistant", content: text ? [{ type: "text", text }] : [] };
|
|
@@ -3033,6 +3124,7 @@ function registerPalsuProvider(config) {
|
|
|
3033
3124
|
GGAIError,
|
|
3034
3125
|
ProviderError,
|
|
3035
3126
|
StreamResult,
|
|
3127
|
+
classifyProviderError,
|
|
3036
3128
|
formatError,
|
|
3037
3129
|
formatErrorForDisplay,
|
|
3038
3130
|
isHardBillingMessage,
|