@juspay/neurolink
Version:
The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002
32 lines (31 loc) • 2.09 kB
TypeScript
/**
* Codex account enumeration + usage/quota normalisation.
*
* Mirrors `accountUsage.ts` (Anthropic) for the Codex pool. Codex reports two
* rate-limit windows — `primary` (short) and `secondary` (weekly) — which we
* map onto the shared AccountQuota session/weekly fields so the same routing,
* cooldown, and display code works for both providers.
*/
import type { CodexProxyStatusAccountIdentity } from "../types/index.js";
import type { AccountQuota, CodexRateLimits, CodexUsageFetchResult, ProxyPassthroughAccount } from "../types/index.js";
export declare const CODEX_ACCOUNT_PREFIX = "codex:";
/** Keep an account label in the Codex namespace used by its token store. */
export declare function normalizeCodexAccountKey(value: string): string;
/** Resolve the provider-qualified key used to render a proxy status row. */
export declare function resolveProxyStatusAccountIdentity(label: string, type: string, persistedKey?: string): CodexProxyStatusAccountIdentity;
/** Enumerate Codex OAuth accounts from the token store for usage refresh. */
export declare function listCodexAccountsForUsage(): Promise<ProxyPassthroughAccount[]>;
/** Normalise a Codex rate-limit block into the shared AccountQuota shape. */
export declare function codexRateLimitsToQuota(rateLimits: CodexRateLimits | null | undefined, now?: number): AccountQuota;
/**
* Parse Codex rate-limit information from response headers. The ChatGPT backend
* returns a JSON rate-limit blob in `x-codex-ratelimit` / `x-codex-active-limit`
* on some responses; parse defensively and return null when absent.
*/
export declare function parseCodexRateLimitHeaders(headers: Headers, now?: number): AccountQuota | null;
/** Fetch the usage/limits window for one Codex account. */
export declare function fetchCodexAccountUsage(account: ProxyPassthroughAccount, options?: {
timeoutMs?: number;
}): Promise<CodexUsageFetchResult>;
/** Decode plan type from an account's access token (display convenience). */
export declare function codexAccountPlanType(account: ProxyPassthroughAccount): string | undefined;