@juspay/neurolink 10.12.7 → 10.12.8

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.
@@ -12,7 +12,7 @@
12
12
  import { buildTranslationOptions } from "../../proxy/proxyTranslationEngine.js";
13
13
  import { ProxyTracer } from "../../proxy/proxyTracer.js";
14
14
  import { isPermanentRefreshFailure } from "../../proxy/tokenRefresh.js";
15
- import type { AccountAllowlist, AccountAdmissionLease, AccountCooldownPlan, AccountQuota, AnthropicAttemptLogger, AnthropicAuthRetryResult, AnthropicLoopState, AnthropicNonOkResult, AnthropicSuccessResult, AnthropicUpstreamFetchResult, ClaudeFinalRequestLogger, ClaudeLoggedErrorBuilder, ClaudeRequest, ClaudeProxyRouteRuntimeOptions, ModelRouterInterface, ParsedClaudeError, ProxyAccountRoutingDecision, ProxyAccountSortMetrics, ProxyBodyCaptureLogger, ProxyLimitsRefreshResponse, ProxyQuotaCooldownUpdate, ProxyPassthroughAccount, QueuedAccountAdmission, RouteGroup, RuntimeAccountState, ServerContext, StreamTerminalOutcome } from "../../types/index.js";
15
+ import type { AccountAllowlist, AccountAdmissionLease, AccountCooldownPlan, AccountQuota, AccountUsageFetchResult, AnthropicAttemptLogger, AnthropicAuthRetryResult, AnthropicLoopState, AnthropicNonOkResult, AnthropicSuccessResult, AnthropicUpstreamFetchResult, ClaudeFinalRequestLogger, ClaudeLoggedErrorBuilder, ClaudeRequest, ClaudeProxyRouteRuntimeOptions, ModelRouterInterface, ParsedClaudeError, ProxyAccountRoutingDecision, ProxyAccountSortMetrics, ProxyBodyCaptureLogger, ProxyLimitsRefreshResponse, ProxyQuotaCooldownUpdate, ProxyPassthroughAccount, QueuedAccountAdmission, RouteGroup, RuntimeAccountState, ServerContext, StreamTerminalOutcome } from "../../types/index.js";
16
16
  declare function tryAcquireAccountAdmission(accountKey: string, capacity: number | undefined): AccountAdmissionLease | undefined;
17
17
  declare function enqueueAccountAdmission(accountKey: string, capacity: number): QueuedAccountAdmission;
18
18
  declare function acquireAccountAdmission(accountKey: string, capacity: number, abortSignal?: AbortSignal, timeoutMs?: number): Promise<AccountAdmissionLease | undefined>;
@@ -75,6 +75,7 @@ declare function reconcileCooldownFromQuota(state: RuntimeAccountState, quota: A
75
75
  * headers can change admission state.
76
76
  */
77
77
  declare function seedRuntimeQuotasFromDisk(accounts: ProxyPassthroughAccount[]): Promise<void>;
78
+ declare function applyAccountUsageResult(account: ProxyPassthroughAccount, fetchResult: AccountUsageFetchResult, observedAt: number, prior?: AccountQuota | null): Promise<AccountQuota | null>;
78
79
  /**
79
80
  * Fetch fresh limits from Anthropic's usage endpoint for every eligible OAuth
80
81
  * account and write them through the exact same chain the passive header
@@ -95,9 +96,8 @@ declare function refreshAccountLimits(options?: {
95
96
  * temporarily demoted until that session resets.
96
97
  *
97
98
  * Priority among usable accounts:
98
- * 1. no quota data yet probe first: one request reveals its windows and
99
- * self-corrects the ordering. (Ranking unknowns last would starve them
100
- * forever: never picked → never observed → never comparable.)
99
+ * 1. known healthy quota before unknown or ambiguous stale evidence. Quota
100
+ * discovery is handled by a lightweight usage GET, never a user request.
101
101
  * 2. session headroom before session-saturated (>= soft limit or
102
102
  * "throttled") — do not re-hammer an urgent weekly account while its 5h
103
103
  * capacity is temporarily unavailable.
@@ -113,6 +113,8 @@ declare function refreshAccountLimits(options?: {
113
113
  * last resort.
114
114
  */
115
115
  declare function orderAccountsByQuota(accounts: ProxyPassthroughAccount[], now: number, primaryKey: string | undefined, sessionSoftLimit?: number, sessionResetToleranceMs?: number): ProxyPassthroughAccount[];
116
+ declare function scheduleAdaptiveQuotaRefreshes(accounts: ProxyPassthroughAccount[], orderedAccounts: ProxyPassthroughAccount[], sessionSoftLimit: number, routingMetrics?: ReadonlyMap<string, ProxyAccountSortMetrics>): void;
117
+ declare function scheduleHandoffQuotaRefresh(current: ProxyPassthroughAccount, candidate: ProxyPassthroughAccount | undefined, handoffEpoch: number, sessionSoftLimit: number): void;
116
118
  declare function buildRoutingDecision(args: {
117
119
  accounts: ProxyPassthroughAccount[];
118
120
  orderedAccounts: ProxyPassthroughAccount[];
@@ -160,6 +162,8 @@ declare function buildClaudeAnthropicFailureResponse(args: {
160
162
  sawTransientFailure: boolean;
161
163
  sawRateLimit: boolean;
162
164
  lastError: unknown;
165
+ lastTransportErrorCode?: string;
166
+ lastTransportScope?: "shared_provider_transport" | "connection_transport";
163
167
  fallbackFailureMessage?: string;
164
168
  orderedAccounts: ProxyPassthroughAccount[];
165
169
  buildLoggedClaudeError: ClaudeLoggedErrorBuilder;
@@ -360,12 +364,16 @@ export declare const __testHooks: {
360
364
  planCooldownFor429: typeof planCooldownFor429;
361
365
  reconcileCooldownFromQuota: typeof reconcileCooldownFromQuota;
362
366
  refreshAccountLimits: typeof refreshAccountLimits;
367
+ applyAccountUsageResult: typeof applyAccountUsageResult;
363
368
  clearLimitsRefreshStateForTests: () => void;
364
369
  isRetryableNetworkError: typeof isRetryableNetworkError;
365
370
  isPermanentRefreshFailure: typeof isPermanentRefreshFailure;
366
371
  getStreamFailureDetails: typeof getStreamFailureDetails;
367
372
  trackUpstreamReadableStream: typeof trackUpstreamReadableStream;
368
373
  orderAccountsByQuota: typeof orderAccountsByQuota;
374
+ scheduleAdaptiveQuotaRefreshes: typeof scheduleAdaptiveQuotaRefreshes;
375
+ scheduleHandoffQuotaRefresh: typeof scheduleHandoffQuotaRefresh;
376
+ getQuotaRefreshState: (key: string) => import("../../index.js").ProxyQuotaRefreshRuntimeState;
369
377
  buildQuotaRoutingDecision: (accounts: ProxyPassthroughAccount[], now: number, primaryKey: string | undefined, sessionSoftLimit?: number, sessionResetToleranceMs?: number) => ProxyAccountRoutingDecision | undefined;
370
378
  buildRoutingDecision: typeof buildRoutingDecision;
371
379
  resetEpochToMs: typeof resetEpochToMs;