@juspay/neurolink
Version:
Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio
69 lines (68 loc) • 2.88 kB
TypeScript
/**
* AccountPool — manages a pool of proxy accounts with round-robin / fill-first
* selection and exponential-backoff cooldowns for quota-exceeded accounts.
*
* @module auth/accountPool
*/
import type { ProxyAccount, AccountPoolConfig } from "../types/index.js";
export declare class AccountPool {
private accounts;
private cursor;
private readonly config;
constructor(config?: Partial<AccountPoolConfig>);
/** Add (or replace) an account in the pool. */
addAccount(account: ProxyAccount): void;
/** Remove an account from the pool by id. */
removeAccount(id: string): void;
/**
* Return the next healthy account according to the configured strategy.
* Returns `null` when no healthy accounts are available.
*/
getNextAccount(): ProxyAccount | null;
/**
* Mark an account as quota-exceeded. The account enters a cooldown state
* with exponential backoff capped at `maxCooldownMs`.
*
* @deprecated Proxy routes now use `RuntimeAccountState` in `claudeProxyRoutes.ts`
* for runtime account state management. This method is retained for public API compatibility.
*
* @param id Account id
* @param retryAfterMs Optional explicit retry-after duration (from server header)
*/
markQuotaExceeded(id: string, retryAfterMs?: number): void;
/**
* Manually mark an account as available (healthy), clearing its cooldown.
*
* @deprecated Proxy routes now use `RuntimeAccountState` in `claudeProxyRoutes.ts`
* for runtime account state management. This method is retained for public API compatibility.
*/
markAvailable(id: string): void;
/**
* Mark an account as having completed a request successfully.
*
* @deprecated Proxy routes now use `RuntimeAccountState` in `claudeProxyRoutes.ts`
* for runtime account state management. This method is retained for public API compatibility.
*/
markSuccess(id: string): void;
/** Return the number of currently healthy (not cooling/disabled) accounts. */
getHealthyCount(): number;
/** Return a snapshot of all accounts in the pool. */
getAllAccounts(): ProxyAccount[];
/** Return the configured selection strategy. */
getStrategy(): string;
/**
* Wire automatic token refresh for an OAuth account.
* Call after addAccount() for OAuth accounts that have a refresh token.
*
* @param accountId The account id to wire refresh for
* @param refreshFn Function that takes a refresh token and returns new token data
*/
wireTokenRefresh(accountId: string, refreshFn: (refreshToken: string) => Promise<{
accessToken: string;
refreshToken?: string;
expiresAt: number | Date;
tokenType?: string;
}>): void;
private _getHealthyAccounts;
private _expireCooldowns;
}