@code-yeongyu/senpi-ai 2026.11.3-1 → 2026.11.3-3
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 +58 -10
- package/dist/api/anthropic-request-shape-log.d.ts +5 -0
- package/dist/api/anthropic-request-shape-log.js +11 -0
- package/dist/api/anthropic-thinking-binding.d.ts +28 -0
- package/dist/api/anthropic-thinking-binding.js +141 -0
- package/dist/api/lazy.js +3 -0
- package/dist/api/simple-options.js +1 -0
- package/dist/auth/oauth/openai-chatgpt.d.ts +26 -2
- package/dist/auth/oauth/openai-chatgpt.js +40 -20
- package/dist/auth/oauth-refresh.d.ts +3 -1
- package/dist/auth/oauth-refresh.js +49 -11
- package/dist/auth/pool/login-id.d.ts +9 -0
- package/dist/auth/pool/login-id.js +10 -0
- package/dist/auth/resolve.js +7 -0
- package/dist/auth/types.d.ts +16 -3
- package/dist/models.js +3 -2
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/opencode-go.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/oauth-page.d.ts +19 -0
- package/dist/utils/oauth-page.js +38 -2
- package/dist/utils/provider-diagnostic-vocabulary.d.ts +4 -0
- package/dist/utils/provider-diagnostic-vocabulary.js +18 -0
- package/dist/utils/provider-failure-description.d.ts +2 -0
- package/dist/utils/provider-failure-description.js +1 -1
- package/package.json +2 -2
package/dist/types.d.ts
CHANGED
|
@@ -213,6 +213,12 @@ export interface StreamOptions extends ProviderRequestOptions<Model<Api>> {
|
|
|
213
213
|
* session-aware features. Ignored by providers that don't support it.
|
|
214
214
|
*/
|
|
215
215
|
sessionId?: string;
|
|
216
|
+
/**
|
|
217
|
+
* Opaque, non-identifying routing key for the session. When set, Anthropic Messages sends it in
|
|
218
|
+
* the session-affinity header instead of `sessionId`, so a gateway keeps the session on one
|
|
219
|
+
* upstream account without learning the session id. Other providers ignore it.
|
|
220
|
+
*/
|
|
221
|
+
sessionAffinityKey?: string;
|
|
216
222
|
/**
|
|
217
223
|
* Optional custom fields to merge into the outgoing provider request body.
|
|
218
224
|
* Applied before `onPayload` so `onPayload` can observe/override them.
|
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product shown on the local sign-in result pages. The host that runs the engine sets it once at
|
|
3
|
+
* startup (the coding agent passes its `SENPI_BRAND` profile); without it the pages carry no product
|
|
4
|
+
* mark at all.
|
|
5
|
+
*/
|
|
6
|
+
export interface OAuthPageBrand {
|
|
7
|
+
readonly name: string;
|
|
8
|
+
/** A base64 image data URI (`data:image/svg+xml;base64,...`, PNG, WebP or JPEG); anything else is dropped. */
|
|
9
|
+
readonly logo?: string;
|
|
10
|
+
}
|
|
11
|
+
/** Sets the product shown on the sign-in result pages. An empty name clears it. */
|
|
12
|
+
export declare function setOAuthPageBrand(brand: OAuthPageBrand | undefined): void;
|
|
13
|
+
/** The brand name the host set with `setOAuthPageBrand`, or undefined when it set none. */
|
|
14
|
+
export declare function configuredOAuthBrandName(): string | undefined;
|
|
15
|
+
/**
|
|
16
|
+
* The product name a sign-in shows outside our own pages: the ChatGPT authorize hint and an MCP client registration,
|
|
17
|
+
* both displayed on the provider's consent screen. Falls back to `senpi` when the host set no brand.
|
|
18
|
+
*/
|
|
19
|
+
export declare function oauthBrandName(): string;
|
|
1
20
|
export declare function oauthSuccessHtml(message: string): string;
|
|
2
21
|
export declare function oauthErrorHtml(message: string, details?: string): string;
|
|
3
22
|
//# sourceMappingURL=oauth-page.d.ts.map
|
package/dist/utils/oauth-page.js
CHANGED
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { processSingleton } from "./process-singleton.js";
|
|
2
|
+
// Process-wide so the self-contained login chunks of the release bundle read the same value (#2334).
|
|
3
|
+
const brandSlot = processSingleton("@code-yeongyu/senpi-ai:oauth-page-brand", () => ({ current: undefined }));
|
|
4
|
+
// The logo lands in an <img src>, which never runs scripts; the base64 alphabet cannot close the attribute.
|
|
5
|
+
const LOGO_DATA_URI = /^data:image\/(?:svg\+xml|png|webp|jpeg);base64,[A-Za-z0-9+/]+={0,2}$/;
|
|
6
|
+
/** Sets the product shown on the sign-in result pages. An empty name clears it. */
|
|
7
|
+
export function setOAuthPageBrand(brand) {
|
|
8
|
+
const name = brand?.name.trim();
|
|
9
|
+
if (!brand || !name) {
|
|
10
|
+
brandSlot.current = undefined;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const logo = brand.logo && LOGO_DATA_URI.test(brand.logo) ? brand.logo : undefined;
|
|
14
|
+
brandSlot.current = logo ? { name, logo } : { name };
|
|
15
|
+
}
|
|
16
|
+
/** The brand name the host set with `setOAuthPageBrand`, or undefined when it set none. */
|
|
17
|
+
export function configuredOAuthBrandName() {
|
|
18
|
+
return brandSlot.current?.name;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The product name a sign-in shows outside our own pages: the ChatGPT authorize hint and an MCP client registration,
|
|
22
|
+
* both displayed on the provider's consent screen. Falls back to `senpi` when the host set no brand.
|
|
23
|
+
*/
|
|
24
|
+
export function oauthBrandName() {
|
|
25
|
+
return configuredOAuthBrandName() ?? "senpi";
|
|
26
|
+
}
|
|
2
27
|
function escapeHtml(value) {
|
|
3
28
|
return value
|
|
4
29
|
.replaceAll("&", "&")
|
|
@@ -12,6 +37,9 @@ function renderPage(options) {
|
|
|
12
37
|
const heading = escapeHtml(options.heading);
|
|
13
38
|
const message = escapeHtml(options.message);
|
|
14
39
|
const details = options.details ? escapeHtml(options.details) : undefined;
|
|
40
|
+
const brand = brandSlot.current;
|
|
41
|
+
const logo = brand?.logo ? `<img class="logo" src="${brand.logo}" alt="" />` : "";
|
|
42
|
+
const brandName = brand ? `<div class="brand-name">${escapeHtml(brand.name)}</div>` : "";
|
|
15
43
|
return `<!doctype html>
|
|
16
44
|
<html lang="en">
|
|
17
45
|
<head>
|
|
@@ -52,7 +80,14 @@ function renderPage(options) {
|
|
|
52
80
|
width: 72px;
|
|
53
81
|
height: 72px;
|
|
54
82
|
display: block;
|
|
83
|
+
margin-bottom: 16px;
|
|
84
|
+
}
|
|
85
|
+
.brand-name {
|
|
55
86
|
margin-bottom: 24px;
|
|
87
|
+
font-size: 15px;
|
|
88
|
+
font-weight: 600;
|
|
89
|
+
letter-spacing: 0.02em;
|
|
90
|
+
color: var(--text-dim);
|
|
56
91
|
}
|
|
57
92
|
h1 {
|
|
58
93
|
margin: 0 0 10px;
|
|
@@ -79,7 +114,8 @@ function renderPage(options) {
|
|
|
79
114
|
</head>
|
|
80
115
|
<body>
|
|
81
116
|
<main>
|
|
82
|
-
|
|
117
|
+
${logo}
|
|
118
|
+
${brandName}
|
|
83
119
|
<h1>${heading}</h1>
|
|
84
120
|
<p>${message}</p>
|
|
85
121
|
${details ? `<div class="details">${details}</div>` : ""}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import type { ProviderDiagnostic, ProviderDiagnosticCategory, ProviderDiagnosticEvidence } from "../provider-diagnostic.ts";
|
|
2
2
|
/** Serialized UTF-8 budget for one emitted diagnostic. */
|
|
3
3
|
export declare const PROVIDER_DIAGNOSTIC_MAX_BYTES = 512;
|
|
4
|
+
/** A credential pool whose every account is limited until `resetsAt`, the soonest one is due back. */
|
|
5
|
+
export declare function credentialPoolBlockedDiagnostic(resetsAt: number): ProviderDiagnostic | undefined;
|
|
4
6
|
/**
|
|
5
7
|
* Closed allowlist of provider error tokens and the family each one proves.
|
|
6
8
|
* Exact tokens only: Anthropic `error.type` values, OpenAI-compatible
|
|
7
9
|
* `error.code` values, and the precise OpenAI-compatible `error.type` values
|
|
8
10
|
* that stand in for a missing code (`exceeded_current_quota_error`, senpi#4950).
|
|
9
11
|
* `billing_error` proves a billing failure, not quota exhaustion, so it stays `unknown`.
|
|
12
|
+
* `credential_pool_blocked` is senpi's own token for a credential pool whose every account waits on a
|
|
13
|
+
* rate or usage limit (senpi#3975).
|
|
10
14
|
*/
|
|
11
15
|
export declare function categoryForProviderCode(code: string): ProviderDiagnosticCategory | undefined;
|
|
12
16
|
export declare function isTlsChainVerificationCode(code: string): boolean;
|
|
@@ -1,23 +1,40 @@
|
|
|
1
1
|
import { siwcErrorForCode } from "./provider-diagnostic-carrier.js";
|
|
2
2
|
/** Serialized UTF-8 budget for one emitted diagnostic. */
|
|
3
3
|
export const PROVIDER_DIAGNOSTIC_MAX_BYTES = 512;
|
|
4
|
+
const CREDENTIAL_POOL_BLOCKED_CODE = "credential_pool_blocked";
|
|
5
|
+
/** A credential pool whose every account is limited until `resetsAt`, the soonest one is due back. */
|
|
6
|
+
export function credentialPoolBlockedDiagnostic(resetsAt) {
|
|
7
|
+
return buildProviderDiagnostic({
|
|
8
|
+
category: "rate_limit",
|
|
9
|
+
code: CREDENTIAL_POOL_BLOCKED_CODE,
|
|
10
|
+
evidence: "structured_code",
|
|
11
|
+
resetsAt,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
4
14
|
/**
|
|
5
15
|
* Closed allowlist of provider error tokens and the family each one proves.
|
|
6
16
|
* Exact tokens only: Anthropic `error.type` values, OpenAI-compatible
|
|
7
17
|
* `error.code` values, and the precise OpenAI-compatible `error.type` values
|
|
8
18
|
* that stand in for a missing code (`exceeded_current_quota_error`, senpi#4950).
|
|
9
19
|
* `billing_error` proves a billing failure, not quota exhaustion, so it stays `unknown`.
|
|
20
|
+
* `credential_pool_blocked` is senpi's own token for a credential pool whose every account waits on a
|
|
21
|
+
* rate or usage limit (senpi#3975).
|
|
10
22
|
*/
|
|
11
23
|
export function categoryForProviderCode(code) {
|
|
12
24
|
const siwc = siwcErrorForCode(code);
|
|
13
25
|
if (siwc !== undefined)
|
|
14
26
|
return siwc.category;
|
|
15
27
|
switch (code) {
|
|
28
|
+
// `account_pool_auth_blocked`: a subscription account pool that refused the request locally because every account needs a new login.
|
|
16
29
|
case "authentication_error":
|
|
17
30
|
case "invalid_api_key":
|
|
31
|
+
case "account_pool_auth_blocked":
|
|
18
32
|
return "auth";
|
|
33
|
+
// `account_pool_blocked`: a subscription account pool that refused the request locally until its soonest reset (senpi#4672).
|
|
19
34
|
case "rate_limit_error":
|
|
20
35
|
case "rate_limit_exceeded":
|
|
36
|
+
case CREDENTIAL_POOL_BLOCKED_CODE:
|
|
37
|
+
case "account_pool_blocked":
|
|
21
38
|
return "rate_limit";
|
|
22
39
|
case "insufficient_quota":
|
|
23
40
|
case "exceeded_current_quota_error":
|
|
@@ -93,6 +110,7 @@ export function isProviderCodeStatusCompatible(code, status) {
|
|
|
93
110
|
return status === 401;
|
|
94
111
|
case "rate_limit_error":
|
|
95
112
|
case "rate_limit_exceeded":
|
|
113
|
+
case CREDENTIAL_POOL_BLOCKED_CODE:
|
|
96
114
|
case "insufficient_quota":
|
|
97
115
|
case "exceeded_current_quota_error":
|
|
98
116
|
case "usage_limit_reached":
|
|
@@ -22,6 +22,8 @@ export declare function stripTurnRetrySuppressionPrefix(message: string): string
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function describeProviderFailureForUser(errorMessage: string | undefined, options?: ProviderStallDescriptionOptions & {
|
|
24
24
|
usageLimit?: "account" | "model";
|
|
25
|
+
/** The account limit's reset as the caller knows it, used when the provider text names none. */
|
|
26
|
+
resetsAt?: string;
|
|
25
27
|
}): string | undefined;
|
|
26
28
|
/**
|
|
27
29
|
* The turn-ending message for a provider module that can no longer be imported because the
|
|
@@ -84,7 +84,7 @@ export function describeProviderFailureForUser(errorMessage, options = {}) {
|
|
|
84
84
|
const reset = /\bresets?\s+([^"}\n]+)/i
|
|
85
85
|
.exec(message)?.[1]
|
|
86
86
|
?.trim()
|
|
87
|
-
.replace(/[.;]+$/, "");
|
|
87
|
+
.replace(/[.;]+$/, "") ?? options.resetsAt;
|
|
88
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.`;
|
|
89
89
|
}
|
|
90
90
|
const stall = describeProviderStallForUser(message, options);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@code-yeongyu/senpi-ai",
|
|
3
|
-
"version": "2026.11.3-
|
|
3
|
+
"version": "2026.11.3-3",
|
|
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.11.3-
|
|
91
|
+
"@earendil-works/pi-telemetry": "npm:@code-yeongyu/senpi-telemetry@2026.11.3-3",
|
|
92
92
|
"@google/genai": "2.23.0",
|
|
93
93
|
"@smithy/node-http-handler": "4.12.1",
|
|
94
94
|
"google-auth-library": "10.6.2",
|