@juspay/neurolink 11.2.0 → 11.2.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/CHANGELOG.md +12 -0
- package/dist/auth/codexOAuth.d.ts +67 -0
- package/dist/auth/codexOAuth.js +202 -0
- package/dist/auth/index.d.ts +1 -0
- package/dist/auth/index.js +4 -0
- package/dist/browser/neurolink.min.js +419 -419
- package/dist/cli/commands/auth.d.ts +27 -8
- package/dist/cli/commands/auth.js +425 -6
- package/dist/cli/commands/proxy.js +230 -5
- package/dist/cli/factories/authCommandFactory.d.ts +8 -0
- package/dist/cli/factories/authCommandFactory.js +74 -1
- package/dist/lib/auth/codexOAuth.d.ts +67 -0
- package/dist/lib/auth/codexOAuth.js +203 -0
- package/dist/lib/auth/index.d.ts +1 -0
- package/dist/lib/auth/index.js +4 -0
- package/dist/lib/providers/openaiChatCompletionsBase.js +26 -14
- package/dist/lib/proxy/accountCooldown.js +35 -2
- package/dist/lib/proxy/accountQuota.d.ts +29 -3
- package/dist/lib/proxy/accountQuota.js +203 -12
- package/dist/lib/proxy/accountUsage.js +15 -2
- package/dist/lib/proxy/codexAccountUsage.d.ts +26 -0
- package/dist/lib/proxy/codexAccountUsage.js +174 -0
- package/dist/lib/proxy/proxyAnalysis.js +12 -1
- package/dist/lib/proxy/proxyConfig.js +24 -0
- package/dist/lib/proxy/routingEvidence.d.ts +12 -1
- package/dist/lib/proxy/routingEvidence.js +23 -0
- package/dist/lib/proxy/runtimeConfig.js +3 -0
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +79 -5
- package/dist/lib/server/routes/claudeProxyRoutes.js +653 -72
- package/dist/lib/server/routes/codexProxyRoutes.d.ts +64 -0
- package/dist/lib/server/routes/codexProxyRoutes.js +454 -0
- package/dist/lib/types/cli.d.ts +7 -1
- package/dist/lib/types/codex.d.ts +95 -0
- package/dist/lib/types/codex.js +15 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/index.js +1 -0
- package/dist/lib/types/proxy.d.ts +83 -0
- package/dist/lib/types/subscription.d.ts +13 -0
- package/dist/providers/openaiChatCompletionsBase.js +26 -14
- package/dist/proxy/accountCooldown.js +35 -2
- package/dist/proxy/accountQuota.d.ts +29 -3
- package/dist/proxy/accountQuota.js +203 -12
- package/dist/proxy/accountUsage.js +15 -2
- package/dist/proxy/codexAccountUsage.d.ts +26 -0
- package/dist/proxy/codexAccountUsage.js +173 -0
- package/dist/proxy/proxyAnalysis.js +12 -1
- package/dist/proxy/proxyConfig.js +24 -0
- package/dist/proxy/routingEvidence.d.ts +12 -1
- package/dist/proxy/routingEvidence.js +23 -0
- package/dist/proxy/runtimeConfig.js +3 -0
- package/dist/server/routes/claudeProxyRoutes.d.ts +79 -5
- package/dist/server/routes/claudeProxyRoutes.js +653 -72
- package/dist/server/routes/codexProxyRoutes.d.ts +64 -0
- package/dist/server/routes/codexProxyRoutes.js +453 -0
- package/dist/types/cli.d.ts +7 -1
- package/dist/types/codex.d.ts +95 -0
- package/dist/types/codex.js +14 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/proxy.d.ts +83 -0
- package/dist/types/subscription.d.ts +13 -0
- package/package.json +3 -1
package/dist/types/proxy.d.ts
CHANGED
|
@@ -481,6 +481,13 @@ export type ProxyAccountRoutingCandidate = {
|
|
|
481
481
|
weeklyStatus: string | null;
|
|
482
482
|
weeklyUsed: number | null;
|
|
483
483
|
weeklyResetAt: number | null;
|
|
484
|
+
/** Display name of the model-scoped window that matched the requested model
|
|
485
|
+
* (e.g. "Fable"), or null when the account reports no scoped cap for it.
|
|
486
|
+
* Optional so schema-v1 readers of older records stay valid. */
|
|
487
|
+
scopedModel?: string | null;
|
|
488
|
+
scopedStatus?: string | null;
|
|
489
|
+
scopedUsed?: number | null;
|
|
490
|
+
scopedResetAt?: number | null;
|
|
484
491
|
};
|
|
485
492
|
export type ProxyAccountRoutingDecision = {
|
|
486
493
|
schemaVersion: 1;
|
|
@@ -531,6 +538,15 @@ export type ProxyAccountSortMetrics = {
|
|
|
531
538
|
weeklyReset: number;
|
|
532
539
|
weeklyUsed: number | null;
|
|
533
540
|
weeklyUsedForSort: number;
|
|
541
|
+
/** Model-scoped weekly window matching the requested model. All null/false
|
|
542
|
+
* when the account reports no scoped cap for it (the common case), which
|
|
543
|
+
* makes every scoped comparator rung a no-op for unscoped traffic. */
|
|
544
|
+
scopedModel: string | null;
|
|
545
|
+
scopedStatus: string | null;
|
|
546
|
+
scopedUsed: number | null;
|
|
547
|
+
scopedReset: number;
|
|
548
|
+
scopedUsedForSort: number;
|
|
549
|
+
scopedSaturated: boolean;
|
|
534
550
|
};
|
|
535
551
|
export type RequestLogEntry = {
|
|
536
552
|
timestamp: string;
|
|
@@ -665,6 +681,8 @@ export type AnthropicLoopState = {
|
|
|
665
681
|
} | null;
|
|
666
682
|
authFailureMessage: string | null;
|
|
667
683
|
authCooldownMessage: string | null;
|
|
684
|
+
entitlementFailure: AnthropicEntitlementFailure | null;
|
|
685
|
+
scopedExhaustion: AnthropicScopedExhaustion | null;
|
|
668
686
|
fallbackFailureMessage?: string;
|
|
669
687
|
attemptNumber: number;
|
|
670
688
|
lastTransportErrorCode?: string;
|
|
@@ -752,6 +770,7 @@ export type AnthropicAuthRetryResult = {
|
|
|
752
770
|
retryDelayMs?: number;
|
|
753
771
|
lastError: unknown;
|
|
754
772
|
authFailureMessage: string | null;
|
|
773
|
+
entitlementFailure: AnthropicEntitlementFailure | null;
|
|
755
774
|
sawRateLimit: boolean;
|
|
756
775
|
sawTransientFailure: boolean;
|
|
757
776
|
sawNetworkError: boolean;
|
|
@@ -771,6 +790,7 @@ export type AnthropicNonOkResult = {
|
|
|
771
790
|
body: string;
|
|
772
791
|
contentType?: string;
|
|
773
792
|
} | null;
|
|
793
|
+
entitlementFailure: AnthropicEntitlementFailure | null;
|
|
774
794
|
upstreamSpan?: Span;
|
|
775
795
|
};
|
|
776
796
|
export type PreparedAnthropicAccountAttempt = {
|
|
@@ -997,6 +1017,17 @@ export type AccountQuota = {
|
|
|
997
1017
|
overageStatus: string;
|
|
998
1018
|
/** Whether Anthropic reports that paid overage is actively serving traffic. */
|
|
999
1019
|
overageInUse?: boolean;
|
|
1020
|
+
/** Why overage is unavailable, verbatim from
|
|
1021
|
+
* anthropic-ratelimit-unified-overage-disabled-reason (e.g.
|
|
1022
|
+
* "org_level_disabled"). Present only when the provider states one. */
|
|
1023
|
+
overageDisabledReason?: string;
|
|
1024
|
+
/** Authoritative extra-usage switch from the usage API's
|
|
1025
|
+
* `extra_usage.is_enabled`. Unlike the header trio this is reported even for
|
|
1026
|
+
* an account that has never served a request. */
|
|
1027
|
+
overageEnabled?: boolean;
|
|
1028
|
+
/** Which window Anthropic considers binding right now, verbatim from
|
|
1029
|
+
* anthropic-ratelimit-unified-representative-claim (e.g. "five_hour"). */
|
|
1030
|
+
representativeClaim?: string;
|
|
1000
1031
|
/** Epoch ms when we last captured this data */
|
|
1001
1032
|
lastUpdated: number;
|
|
1002
1033
|
/** Dynamic per-plan limit buckets from the usage API `limits[]` array
|
|
@@ -1033,8 +1064,21 @@ export type AccountQuotaWindow = {
|
|
|
1033
1064
|
isActive?: boolean;
|
|
1034
1065
|
/** Model display name for model-scoped windows (e.g. "Fable"). */
|
|
1035
1066
|
scopeModel?: string;
|
|
1067
|
+
/** Wire model id for the scope when the provider reports one
|
|
1068
|
+
* (`scope.model.id`), which matches a request's `model` exactly and so beats
|
|
1069
|
+
* display-name matching. Often null in practice. */
|
|
1070
|
+
scopeModelId?: string;
|
|
1036
1071
|
/** Surface scope when the provider reports one. */
|
|
1037
1072
|
scopeSurface?: string;
|
|
1073
|
+
/** Epoch ms this individual window was observed. Lets a header-derived window
|
|
1074
|
+
* and a usage-API window on the same account age independently — the flat
|
|
1075
|
+
* `lastUpdated` refreshes on every response and would otherwise make a
|
|
1076
|
+
* days-old scoped window look current. */
|
|
1077
|
+
updatedAt?: number;
|
|
1078
|
+
/** Provenance of this window, mirroring AccountQuotaSource. */
|
|
1079
|
+
source?: AccountQuotaSource;
|
|
1080
|
+
/** Raw unified header token for header-derived windows, e.g. "7d_oi". */
|
|
1081
|
+
headerWindow?: string;
|
|
1038
1082
|
};
|
|
1039
1083
|
/** One utilization window from the OAuth usage endpoint (wire shape, loose). */
|
|
1040
1084
|
export type AnthropicUsageWindow = {
|
|
@@ -2316,6 +2360,40 @@ export type ClaudeSnapshot = {
|
|
|
2316
2360
|
export type ParsedClaudeError = {
|
|
2317
2361
|
errorType?: string;
|
|
2318
2362
|
message?: string;
|
|
2363
|
+
/** `error.details.error_code`, e.g. "oauth_not_allowed_for_organization".
|
|
2364
|
+
* Absent on payloads that carry no details object. */
|
|
2365
|
+
errorCode?: string;
|
|
2366
|
+
};
|
|
2367
|
+
/**
|
|
2368
|
+
* Accounts rejected by an organization/plan entitlement policy during a single
|
|
2369
|
+
* request. Anthropic answers such an account with a `permission_error` that no
|
|
2370
|
+
* amount of retrying or token refreshing can fix, but which a *different*
|
|
2371
|
+
* account may not hit at all — so it drives rotation, and is reported to the
|
|
2372
|
+
* client only once every account has been tried.
|
|
2373
|
+
*/
|
|
2374
|
+
export type AnthropicEntitlementFailure = {
|
|
2375
|
+
status: number;
|
|
2376
|
+
/** Labels of every account that rejected this request on entitlement. */
|
|
2377
|
+
accounts: string[];
|
|
2378
|
+
/** Upstream message from the first such rejection. */
|
|
2379
|
+
message: string;
|
|
2380
|
+
errorCode?: string;
|
|
2381
|
+
};
|
|
2382
|
+
/**
|
|
2383
|
+
* Every account's model-scoped window for the requested model is spent. Unlike
|
|
2384
|
+
* a cooldown this is per-model: the same accounts stay healthy for every other
|
|
2385
|
+
* model, so the client is told to switch model rather than to back off.
|
|
2386
|
+
*/
|
|
2387
|
+
export type AnthropicScopedExhaustion = {
|
|
2388
|
+
/** Wire model id from the request. */
|
|
2389
|
+
model: string;
|
|
2390
|
+
/** Display name of the exhausted window, e.g. "Fable". */
|
|
2391
|
+
scopeModel: string;
|
|
2392
|
+
/** Epoch ms of the soonest reset across the exhausted accounts. */
|
|
2393
|
+
earliestResetMs: number;
|
|
2394
|
+
accounts: string[];
|
|
2395
|
+
/** Provider reason overage is unavailable, e.g. "org_level_disabled". */
|
|
2396
|
+
overageDisabledReason?: string;
|
|
2319
2397
|
};
|
|
2320
2398
|
/** ora spinner instance held by proxy CLI commands, nullable when --quiet. */
|
|
2321
2399
|
export type ProxySpinner = Ora | null;
|
|
@@ -2340,7 +2418,12 @@ export type ProxyRequestRoutingSnapshot = {
|
|
|
2340
2418
|
quotaRoutingEnabled: boolean;
|
|
2341
2419
|
sessionSoftLimit: number;
|
|
2342
2420
|
sessionResetToleranceMs: number;
|
|
2421
|
+
/** Operator policy on spending paid extra usage once a subscription window is
|
|
2422
|
+
* spent. Only "never" can override the provider's own signal. */
|
|
2423
|
+
useOverage: ProxyOveragePolicy;
|
|
2343
2424
|
};
|
|
2425
|
+
/** Operator policy for paid extra usage. */
|
|
2426
|
+
export type ProxyOveragePolicy = "auto" | "always" | "never";
|
|
2344
2427
|
/** Immutable last-known-good proxy configuration published at runtime. */
|
|
2345
2428
|
export type ProxyRuntimeConfigSnapshot = ProxyRequestRoutingSnapshot & {
|
|
2346
2429
|
loadedAt: string;
|
|
@@ -998,6 +998,19 @@ export type ProxyRoutingConfig = {
|
|
|
998
998
|
passthroughModels?: string[];
|
|
999
999
|
/** Enable quota-aware fill-first account ordering. Defaults to true. */
|
|
1000
1000
|
quotaRouting?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* Whether an account may keep serving on paid extra usage once its
|
|
1003
|
+
* subscription window is spent.
|
|
1004
|
+
*
|
|
1005
|
+
* - `auto` (default): follow whatever Anthropic reports for the account.
|
|
1006
|
+
* - `never`: park the account at the subscription limit even when extra usage
|
|
1007
|
+
* is enabled, so the pool can never spend credits.
|
|
1008
|
+
* - `always`: keep serving whenever the provider permits extra usage.
|
|
1009
|
+
*
|
|
1010
|
+
* Only `never` can override the provider — nothing here can enable extra usage
|
|
1011
|
+
* that Anthropic has disabled (e.g. `org_level_disabled`).
|
|
1012
|
+
*/
|
|
1013
|
+
useOverage?: "auto" | "always" | "never";
|
|
1001
1014
|
/** Session utilization threshold used to proactively demote an account. */
|
|
1002
1015
|
sessionSoftLimit?: number;
|
|
1003
1016
|
/** Reset-time bucket width used when ordering quota windows. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "11.2.
|
|
3
|
+
"version": "11.2.2",
|
|
4
4
|
"packageManager": "pnpm@10.15.1",
|
|
5
5
|
"description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
|
|
6
6
|
"author": {
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"test:memory": "npx tsx test/continuous-test-suite-memory.ts",
|
|
83
83
|
"test:openai-compat-streaming-retry": "npx tsx test/continuous-test-suite-openai-compat-streaming-retry.ts",
|
|
84
84
|
"test:anthropic-streaming-retry": "npx tsx test/continuous-test-suite-anthropic-streaming-retry.ts",
|
|
85
|
+
"test:adjust-body-after-400": "npx tsx test/continuous-test-suite-adjust-body-after-400.ts",
|
|
85
86
|
"test:error-classification-e2e": "npx tsx test/continuous-test-suite-error-classification-e2e.ts",
|
|
86
87
|
"test:error-classifier-contract": "npx tsx test/continuous-test-suite-error-classifier-contract.ts",
|
|
87
88
|
"test:middleware": "npx tsx test/continuous-test-suite-middleware.ts",
|
|
@@ -112,6 +113,7 @@
|
|
|
112
113
|
"test:credentials": "npx tsx test/continuous-test-suite-credentials.ts",
|
|
113
114
|
"test:dynamic": "npx tsx test/continuous-test-suite-dynamic.ts",
|
|
114
115
|
"test:proxy": "npx tsx test/continuous-test-suite-proxy.ts",
|
|
116
|
+
"test:codex": "npx tsx test/continuous-test-suite-codex.ts",
|
|
115
117
|
"test:bugfixes": "npx tsx test/continuous-test-suite-bugfixes.ts",
|
|
116
118
|
"test:json-e2e": "npx tsx test/continuous-test-suite-json-e2e.ts",
|
|
117
119
|
"test:workflow": "npx tsx test/continuous-test-suite-workflow.ts",
|