@code-yeongyu/senpi-ai 2026.10.27-2 → 2026.10.30-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/api/anthropic-messages.js +6 -4
- package/dist/api/simple-options.js +1 -0
- package/dist/auth/pool/select.d.ts +5 -0
- package/dist/auth/pool/select.js +17 -5
- package/dist/legacy-provider-ids.d.ts +5 -0
- package/dist/legacy-provider-ids.js +7 -0
- package/dist/models.d.ts +5 -0
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/amazon-bedrock.json +1 -1
- package/dist/providers/data/chatgpt-subscription.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/mistral.json +1 -1
- package/dist/providers/data/nvidia.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/opengateway.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/radius.json +1 -1
- package/dist/providers/data/venice.json +1 -1
- package/dist/providers/data/vercel-ai-gateway.json +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/utils/provider-diagnostic-sources.d.ts +3 -2
- package/dist/utils/provider-diagnostic-sources.js +15 -4
- package/dist/utils/provider-diagnostic-vocabulary.d.ts +4 -3
- package/dist/utils/provider-diagnostic-vocabulary.js +6 -3
- package/dist/utils/provider-failure-description.js +14 -3
- package/dist/utils/retry.js +8 -3
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -175,6 +175,12 @@ export interface StreamOptions extends ProviderRequestOptions<Model<Api>> {
|
|
|
175
175
|
* Adapter support is explicit; unsupported adapters do not invoke it.
|
|
176
176
|
*/
|
|
177
177
|
onProviderStreamEvent?: (data: unknown, model: Model<Api>) => void | Promise<void>;
|
|
178
|
+
/**
|
|
179
|
+
* Called whenever the response body delivers bytes, keep-alives included (SSE `ping` events, `:` comments).
|
|
180
|
+
* Liveness only: it says the connection is alive, not that the model produced anything. Adapter support is
|
|
181
|
+
* explicit; unsupported adapters do not invoke it.
|
|
182
|
+
*/
|
|
183
|
+
onTransportActivity?: () => void;
|
|
178
184
|
temperature?: number;
|
|
179
185
|
/**
|
|
180
186
|
* Arbitrary sampling parameters merged into the request body as-is, after the named request
|
|
@@ -11,8 +11,9 @@ export declare function anthropicProviderDiagnosticFromError(error: unknown): Pr
|
|
|
11
11
|
export declare function anthropicProviderDiagnosticFromSseData(data: string): ProviderDiagnostic | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* OpenAI SDK `APIError` (HTTP rejection or in-stream error chunk): reads
|
|
14
|
-
* `status` and `code` once each. `type` is
|
|
15
|
-
*
|
|
14
|
+
* `status` and `code` once each. `type` is read only when `code` is absent, and
|
|
15
|
+
* only a precise token counts: OpenAI-compatible servers reuse `type` for coarse
|
|
16
|
+
* buckets that can contradict the precise code.
|
|
16
17
|
*/
|
|
17
18
|
export declare function openAICompatibleProviderDiagnosticFromError(error: unknown): ProviderDiagnostic | undefined;
|
|
18
19
|
export declare function transportProviderDiagnosticFromError(error: unknown): ProviderDiagnostic | undefined;
|
|
@@ -65,10 +65,19 @@ export function anthropicProviderDiagnosticFromSseData(data) {
|
|
|
65
65
|
return undefined;
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* `error.type` values an OpenAI-compatible server uses for exactly one failure, so they stand in for a
|
|
70
|
+
* missing `error.code` (senpi#4950). Coarse buckets such as `invalid_request_error` never do.
|
|
71
|
+
*/
|
|
72
|
+
const OPENAI_COMPATIBLE_PRECISE_TYPES = new Set([
|
|
73
|
+
"exceeded_current_quota_error",
|
|
74
|
+
"insufficient_quota",
|
|
75
|
+
]);
|
|
68
76
|
/**
|
|
69
77
|
* OpenAI SDK `APIError` (HTTP rejection or in-stream error chunk): reads
|
|
70
|
-
* `status` and `code` once each. `type` is
|
|
71
|
-
*
|
|
78
|
+
* `status` and `code` once each. `type` is read only when `code` is absent, and
|
|
79
|
+
* only a precise token counts: OpenAI-compatible servers reuse `type` for coarse
|
|
80
|
+
* buckets that can contradict the precise code.
|
|
72
81
|
*/
|
|
73
82
|
export function openAICompatibleProviderDiagnosticFromError(error) {
|
|
74
83
|
try {
|
|
@@ -78,9 +87,11 @@ export function openAICompatibleProviderDiagnosticFromError(error) {
|
|
|
78
87
|
const code = optionalString(Reflect.get(error, "code"));
|
|
79
88
|
if (code === null)
|
|
80
89
|
return undefined;
|
|
81
|
-
|
|
90
|
+
const type = code === undefined ? optionalString(Reflect.get(error, "type")) : undefined;
|
|
91
|
+
const token = code ?? (typeof type === "string" && OPENAI_COMPATIBLE_PRECISE_TYPES.has(type) ? type : undefined);
|
|
92
|
+
if (token === undefined && (status === undefined || status === null))
|
|
82
93
|
return undefined;
|
|
83
|
-
return classifyProviderFailure({ status, code });
|
|
94
|
+
return classifyProviderFailure({ status, code: token });
|
|
84
95
|
}
|
|
85
96
|
catch {
|
|
86
97
|
return undefined;
|
|
@@ -3,9 +3,10 @@ import type { ProviderDiagnostic, ProviderDiagnosticCategory, ProviderDiagnostic
|
|
|
3
3
|
export declare const PROVIDER_DIAGNOSTIC_MAX_BYTES = 512;
|
|
4
4
|
/**
|
|
5
5
|
* Closed allowlist of provider error tokens and the family each one proves.
|
|
6
|
-
* Exact tokens only: Anthropic `error.type` values
|
|
7
|
-
* `error.code` values
|
|
8
|
-
*
|
|
6
|
+
* Exact tokens only: Anthropic `error.type` values, OpenAI-compatible
|
|
7
|
+
* `error.code` values, and the precise OpenAI-compatible `error.type` values
|
|
8
|
+
* that stand in for a missing code (`exceeded_current_quota_error`, senpi#4950).
|
|
9
|
+
* `billing_error` proves a billing failure, not quota exhaustion, so it stays `unknown`.
|
|
9
10
|
*/
|
|
10
11
|
export declare function categoryForProviderCode(code: string): ProviderDiagnosticCategory | undefined;
|
|
11
12
|
/**
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
export const PROVIDER_DIAGNOSTIC_MAX_BYTES = 512;
|
|
3
3
|
/**
|
|
4
4
|
* Closed allowlist of provider error tokens and the family each one proves.
|
|
5
|
-
* Exact tokens only: Anthropic `error.type` values
|
|
6
|
-
* `error.code` values
|
|
7
|
-
*
|
|
5
|
+
* Exact tokens only: Anthropic `error.type` values, OpenAI-compatible
|
|
6
|
+
* `error.code` values, and the precise OpenAI-compatible `error.type` values
|
|
7
|
+
* that stand in for a missing code (`exceeded_current_quota_error`, senpi#4950).
|
|
8
|
+
* `billing_error` proves a billing failure, not quota exhaustion, so it stays `unknown`.
|
|
8
9
|
*/
|
|
9
10
|
export function categoryForProviderCode(code) {
|
|
10
11
|
switch (code) {
|
|
@@ -15,6 +16,7 @@ export function categoryForProviderCode(code) {
|
|
|
15
16
|
case "rate_limit_exceeded":
|
|
16
17
|
return "rate_limit";
|
|
17
18
|
case "insufficient_quota":
|
|
19
|
+
case "exceeded_current_quota_error":
|
|
18
20
|
case "usage_limit_reached":
|
|
19
21
|
case "usage_not_included":
|
|
20
22
|
return "quota";
|
|
@@ -68,6 +70,7 @@ export function isProviderCodeStatusCompatible(code, status) {
|
|
|
68
70
|
case "rate_limit_error":
|
|
69
71
|
case "rate_limit_exceeded":
|
|
70
72
|
case "insufficient_quota":
|
|
73
|
+
case "exceeded_current_quota_error":
|
|
71
74
|
case "usage_limit_reached":
|
|
72
75
|
case "usage_not_included":
|
|
73
76
|
return status === 429;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { describeProviderStallForUser, formatStallDuration, isAnthropicThirdPartyBillingMessage, } from "./retry.js";
|
|
2
2
|
const CLAUDE_EXTRA_USAGE_URL = "https://claude.ai/settings/usage";
|
|
3
|
+
/**
|
|
4
|
+
* `PROVIDER_NOT_CONFIGURED_PREFIX` from `../auth/resolve.ts`, repeated because importing it pulls the auth
|
|
5
|
+
* modules past this entry's import budget (`check:entry-graphs`). The description test builds its input with
|
|
6
|
+
* `providerNotConfiguredMessage`, so the two copies cannot drift apart.
|
|
7
|
+
*/
|
|
8
|
+
const PROVIDER_NOT_CONFIGURED_PREFIX = "Provider is not configured: ";
|
|
3
9
|
/**
|
|
4
10
|
* Opens the sentence an adapter adds when its own account-limit text already names the next step
|
|
5
11
|
* (senpi#3615). Such text is shown as written instead of the generic switch-provider advice.
|
|
@@ -14,9 +20,9 @@ const RETRY_AFTER_MARKER = /\s*\(retry-after-ms: \d+\)$/;
|
|
|
14
20
|
*/
|
|
15
21
|
function describeAnthropicThirdPartyBilling(provider) {
|
|
16
22
|
if (provider === "anthropic-subscription") {
|
|
17
|
-
return `Anthropic billed this Claude Code request to your extra usage instead of your plan limits, and your extra usage is used up. Add extra usage at ${CLAUDE_EXTRA_USAGE_URL}, or switch to another model
|
|
23
|
+
return `Anthropic billed this Claude Code request to your extra usage instead of your plan limits, and your extra usage is used up. Add extra usage at ${CLAUDE_EXTRA_USAGE_URL}, or switch to another model.`;
|
|
18
24
|
}
|
|
19
|
-
return `Anthropic billed this request to your extra usage instead of your Claude plan limits, because a Claude subscription used directly through the Anthropic API counts as a third-party app.
|
|
25
|
+
return `Anthropic billed this request to your extra usage instead of your Claude plan limits, because a Claude subscription used directly through the Anthropic API counts as a third-party app. Connect "Anthropic Subscription (Claude Pro/Max)" so requests run through Claude Code and use your plan limits, add extra usage at ${CLAUDE_EXTRA_USAGE_URL}, or switch to another model.`;
|
|
20
26
|
}
|
|
21
27
|
/**
|
|
22
28
|
* Session-internal replay-suppression signal, read off the error text by the
|
|
@@ -66,6 +72,11 @@ export function describeProviderFailureForUser(errorMessage, options = {}) {
|
|
|
66
72
|
if (isAnthropicThirdPartyBillingMessage(message)) {
|
|
67
73
|
return describeAnthropicThirdPartyBilling(options.model?.split("/")[0]);
|
|
68
74
|
}
|
|
75
|
+
// The sentinel stays on the message for the classifiers that key on it; the reader gets the step (senpi#4329).
|
|
76
|
+
if (message.startsWith(PROVIDER_NOT_CONFIGURED_PREFIX)) {
|
|
77
|
+
const provider = message.slice(PROVIDER_NOT_CONFIGURED_PREFIX.length);
|
|
78
|
+
return `${provider} is not connected: no API key or sign-in is saved for it. Connect the provider, or choose another model.`;
|
|
79
|
+
}
|
|
69
80
|
if (options.usageLimit === "account") {
|
|
70
81
|
if (message.includes(ACCOUNT_LIMIT_NEXT_STEP_LEAD))
|
|
71
82
|
return message.replace(RETRY_AFTER_MARKER, "");
|
|
@@ -74,7 +85,7 @@ export function describeProviderFailureForUser(errorMessage, options = {}) {
|
|
|
74
85
|
.exec(message)?.[1]
|
|
75
86
|
?.trim()
|
|
76
87
|
.replace(/[.;]+$/, "");
|
|
77
|
-
return `The ${provider ? `${provider} ` : ""}account usage limit has been reached${reset ? ` (resets ${reset})` : ""}. Switch to another provider
|
|
88
|
+
return `The ${provider ? `${provider} ` : ""}account usage limit has been reached${reset ? ` (resets ${reset})` : ""}. Switch to another provider, or configure another provider in retry.fallbackChains.`;
|
|
78
89
|
}
|
|
79
90
|
const stall = describeProviderStallForUser(message, options);
|
|
80
91
|
if (stall !== undefined)
|
package/dist/utils/retry.js
CHANGED
|
@@ -406,15 +406,15 @@ export function isRetryableAssistantError(message) {
|
|
|
406
406
|
}
|
|
407
407
|
/**
|
|
408
408
|
* Matches the agent-loop stream watchdog failures ("Idle timeout waiting for
|
|
409
|
-
* provider stream after <n>ms"
|
|
410
|
-
* <n>ms"), the WebSocket liveness verdict ("WebSocket liveness timeout after
|
|
409
|
+
* provider stream after <n>ms", "Provider stream start timed out after
|
|
410
|
+
* <n>ms" and "Provider stream sent only keep-alives and timed out after <n>ms"), the WebSocket liveness verdict ("WebSocket liveness timeout after
|
|
411
411
|
* <n>ms (<k> pings unanswered)"), and the Responses completion-phase verdict
|
|
412
412
|
* ("Provider stream stalled after the last output item: response.completed
|
|
413
413
|
* timed out after <n>ms"). These anchored shapes
|
|
414
414
|
* distinguish provider-stream stalls from unrelated extension, command, or MCP
|
|
415
415
|
* timeout diagnostics.
|
|
416
416
|
*/
|
|
417
|
-
const PROVIDER_STREAM_STALL_ERROR_PATTERN = /^(?:Idle timeout waiting for provider stream after \d+ms|Provider stream start timed out after \d+ms(?: \([^)]*\))?|WebSocket liveness timeout after \d+ms \(\d+ pings unanswered\)|Provider stream stalled after the last output item: response\.completed timed out after \d+ms)$/i;
|
|
417
|
+
const PROVIDER_STREAM_STALL_ERROR_PATTERN = /^(?:Idle timeout waiting for provider stream after \d+ms|Provider stream start timed out after \d+ms(?: \([^)]*\))?|Provider stream sent only keep-alives and timed out after \d+ms(?: \([^)]*\))?|WebSocket liveness timeout after \d+ms \(\d+ pings unanswered\)|Provider stream stalled after the last output item: response\.completed timed out after \d+ms)$/i;
|
|
418
418
|
const PROVIDER_TRANSPORT_TIMEOUT_ERROR_PATTERN = /^Request timed out\.?$/i;
|
|
419
419
|
export function isProviderStreamStallError(message) {
|
|
420
420
|
return message.stopReason === "error" && PROVIDER_STREAM_STALL_ERROR_PATTERN.test(message.errorMessage ?? "");
|
|
@@ -426,6 +426,11 @@ const PROVIDER_STALL_PHASES = [
|
|
|
426
426
|
symptom: "accepted the request but never started sending a response",
|
|
427
427
|
setting: "retry.provider.streamStartTimeoutMs",
|
|
428
428
|
},
|
|
429
|
+
{
|
|
430
|
+
pattern: /^Provider stream sent only keep-alives and timed out after (\d+)ms/i,
|
|
431
|
+
symptom: "kept the connection alive but sent no response",
|
|
432
|
+
setting: "retry.provider.keepAliveTimeoutMs",
|
|
433
|
+
},
|
|
429
434
|
{
|
|
430
435
|
pattern: /^Idle timeout waiting for provider stream after (\d+)ms/i,
|
|
431
436
|
symptom: "started the response and then went silent",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-ai",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.30-2",
|
|
4
4
|
"description": "Unified LLM API with automatic model discovery and provider configuration",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"dependencies": {
|
|
89
89
|
"@anthropic-ai/sdk": "0.127.0",
|
|
90
90
|
"@aws-sdk/client-bedrock-runtime": "3.1136.0",
|
|
91
|
-
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.10.
|
|
91
|
+
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.10.30-2",
|
|
92
92
|
"@google/genai": "2.23.0",
|
|
93
93
|
"@smithy/node-http-handler": "4.12.1",
|
|
94
94
|
"google-auth-library": "10.6.2",
|