@juspay/neurolink 12.7.1 → 12.7.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.
@@ -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, JsonObject, AccountCooldownPlan, AccountQuota, AccountQuotaWindow, AccountUsageFetchResult, AnthropicAttemptLogger, AnthropicAuthRetryResult, AnthropicEntitlementFailure, AnthropicLoopState, AnthropicScopedExhaustion, AnthropicNonOkResult, AnthropicSuccessResult, AnthropicUpstreamFetchResult, ClaudeFinalRequestLogger, ClaudeLoggedErrorBuilder, ClaudeRequest, ClaudeProxyRouteRuntimeOptions, ModelRouterInterface, ParsedClaudeError, ProxyAccountRoutingDecision, ProxyAccountSortMetrics, ProxyBodyCaptureLogger, ProxyLimitsRefreshResponse, ProxyQuotaCooldownUpdate, ProxyOveragePolicy, ProxyPassthroughAccount, QueuedAccountAdmission, RouteGroup, RuntimeAccountState, ServerContext, StreamTerminalOutcome } from "../../types/index.js";
15
+ import type { AccountAllowlist, AccountAdmissionLease, JsonObject, AccountCooldownPlan, AccountQuota, AccountQuotaWindow, AccountUsageFetchResult, AnthropicAttemptLogger, AnthropicAuthRetryResult, AnthropicEntitlementFailure, AnthropicInvalidRequestFailure, AnthropicLoopState, AnthropicScopedExhaustion, AnthropicNonOkResult, AnthropicSuccessResult, AnthropicUpstreamFetchResult, ClaudeFinalRequestLogger, ClaudeLoggedErrorBuilder, ClaudeRequest, ClaudeProxyRouteRuntimeOptions, ModelRouterInterface, ParsedClaudeError, ProxyAccountRoutingDecision, ProxyAccountSortMetrics, ProxyBodyCaptureLogger, ProxyLimitsRefreshResponse, ProxyQuotaCooldownUpdate, ProxyOveragePolicy, 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>;
@@ -173,6 +173,18 @@ declare function trackUpstreamReadableStream(source: ReadableStream<Uint8Array>)
173
173
  stream: ReadableStream<Uint8Array>;
174
174
  outcome: Promise<StreamTerminalOutcome>;
175
175
  };
176
+ /**
177
+ * Remove what a borrower has no business seeing.
178
+ *
179
+ * `x-neurolink-account` carries the lender's account label, which for an OAuth
180
+ * account is their email address; the pool counters describe the shape of a
181
+ * pool that is not the borrower's. The borrower's own routing needs the quota
182
+ * and grant headers, and nothing else here.
183
+ *
184
+ * A no-op for the node's own traffic, where these headers are exactly the
185
+ * diagnostics the operator wants.
186
+ */
187
+ declare function redactHeadersForBorrower(headers: Record<string, string>): Record<string, string>;
176
188
  declare function executeClaudeFallbackTranslation(args: {
177
189
  ctx: ServerContext;
178
190
  body: ClaudeRequest;
@@ -203,6 +215,7 @@ declare function executeClaudeFallbackTranslation(args: {
203
215
  idleTimeoutMs?: number;
204
216
  }): Promise<unknown>;
205
217
  declare function executeClaudeFallbackWithRetry(args: Parameters<typeof executeClaudeFallbackTranslation>[0]): Promise<unknown>;
218
+ declare function getCodexFallbackInvalidRequestFailure(error: unknown): AnthropicInvalidRequestFailure | null;
206
219
  declare function buildClaudeAnthropicFailureResponse(args: {
207
220
  tracer?: ProxyTracer;
208
221
  requestStartTime: number;
@@ -329,6 +342,7 @@ declare function handleAnthropicNonOkResponse(args: {
329
342
  contentType?: string;
330
343
  } | null;
331
344
  entitlementFailure: AnthropicEntitlementFailure | null;
345
+ allowConfiguredModelFallback?: boolean;
332
346
  }): Promise<AnthropicNonOkResult>;
333
347
  /**
334
348
  * Detect Anthropic's anti-abuse / request-construction 429.
@@ -388,6 +402,11 @@ export declare function parseClaudeErrorBody(errBody: string): ParsedClaudeError
388
402
  * Detect malformed request errors that should not trigger account/provider failover.
389
403
  */
390
404
  export declare function isInvalidRequestError(status: number, errBody: string): boolean;
405
+ /**
406
+ * A 404 for a retired model can be served by an explicitly configured fallback;
407
+ * other 404s remain terminal so a bad endpoint or resource is never disguised.
408
+ */
409
+ declare function isAnthropicModelNotFound(status: number, errBody: string): boolean;
391
410
  /**
392
411
  * A subscription-specific beta rejection. Anthropic returns
393
412
  * `400 invalid_request_error` with a message like
@@ -492,7 +511,10 @@ export declare const __testHooks: {
492
511
  redactProviderErrorMessage: typeof redactProviderErrorMessage;
493
512
  isUpstreamOverload: typeof isUpstreamOverload;
494
513
  getOverloadRotationDelayMs: typeof getOverloadRotationDelayMs;
514
+ redactHeadersForBorrower: typeof redactHeadersForBorrower;
495
515
  shouldAttemptClaudeFallback: typeof shouldAttemptClaudeFallback;
516
+ isAnthropicModelNotFound: typeof isAnthropicModelNotFound;
517
+ getCodexFallbackInvalidRequestFailure: typeof getCodexFallbackInvalidRequestFailure;
496
518
  executeClaudeFallbackWithRetry: typeof executeClaudeFallbackWithRetry;
497
519
  buildClaudeAnthropicFailureResponse: typeof buildClaudeAnthropicFailureResponse;
498
520
  isAccountEntitlementError: typeof isAccountEntitlementError;