@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
40 lines (39 loc) • 1.65 kB
TypeScript
/**
* Per-Account Quota Tracking
*
* Captures Anthropic rate-limit / utilisation headers from proxy responses
* and persists them to ~/.neurolink/account-quotas.json so the CLI can
* display remaining session & weekly capacity per account.
*
* Hot-path design: parseQuotaHeaders is pure CPU (no I/O). saveAccountQuota
* updates an in-memory cache and debounces disk writes so the request/response
* path is never blocked by file I/O.
*/
import type { AccountQuota } from "../types/index.js";
/**
* Parse Anthropic rate-limit / quota headers into an `AccountQuota`.
* Returns `null` when key headers are absent.
* Pure computation — no I/O, no blocking.
*/
export declare function parseQuotaHeaders(headers: Headers | Record<string, string>): AccountQuota | null;
/**
* Initialise the quota module with a custom file path.
* When set, all reads/writes go to this path instead of the default
* ~/.neurolink/account-quotas.json. Call before the first load/save.
*/
export declare function initAccountQuota(quotaFilePath: string): void;
/**
* Load all persisted account quotas.
* First call reads from disk; subsequent calls return the in-memory cache.
*/
export declare function loadAccountQuotas(): Promise<Record<string, AccountQuota>>;
/**
* Load quota for a single account.
*/
export declare function loadAccountQuota(accountKey: string): Promise<AccountQuota | null>;
/**
* Update quota for a single account.
* Updates in-memory cache immediately (non-blocking),
* then debounces the disk write to every 5 seconds.
*/
export declare function saveAccountQuota(accountKey: string, quota: AccountQuota): Promise<void>;