import type { PlanGate, UsageReport } from "../usage.js"; import type { AuthCredential, ApiKeyCredential, OAuthCredential } from "./types.js"; /** Selected stored credential and its pool index. */ export type CredentialSelection = { credential: T; index: number; }; /** Selected OAuth credential for routing. */ export type OAuthSelection = CredentialSelection; /** Selected API-key credential for routing. */ export type ApiKeySelection = CredentialSelection; /** Selected credential with its observed usage. */ export type UsageCandidate = { selection: CredentialSelection; usage: UsageReport | null; usageChecked: boolean; /** Present after policy-aware ranking; used to decide whether a warm automatic pin may be evicted. */ inReserve?: boolean; /** True only when reserve ranking had a usable remaining-fraction measurement. */ reserveMeasured?: boolean; /** * Present after ranking: the account's renewable allowance for this request is * spent, so if it still serves it draws on paid overage such as Codex credits. */ allowanceSpent?: boolean; }; /** OAuth credential eligible for usage ranking. */ export type OAuthCandidate = UsageCandidate; /** API-key credential eligible for usage ranking. */ export type ApiKeyCandidate = UsageCandidate; /** Ranked candidate with a possible block deadline. */ export type UsageRankingResult = UsageCandidate & { blockedUntil: number | undefined; }; /** Candidate with all account-policy and usage ranking metrics. */ export type UsageRankedCandidate = UsageCandidate & { blocked: boolean; blockedUntil?: number; inReserve: boolean; reserveMeasured?: boolean; accountPriority: number; hasPriorityBoost: boolean; allowanceSpent: boolean; usageMeasured: boolean; planPriority: number; secondaryUsed: number; secondaryRequiredDrain: number; primaryUsed: number; primaryRequiredDrain: number; orderPos: number; }; /** OAuth candidate with complete ranking metrics. */ export type RankedOAuthCandidate = UsageRankedCandidate; /** API-key candidate with complete ranking metrics. */ export type RankedApiKeyCandidate = UsageRankedCandidate; /** Rank accounts by model-plan eligibility when a plan gate applies. */ export declare function planPriority(gate: PlanGate | undefined, report: UsageReport | null): number; /** Sort ranked candidates by blocks, plan, spent allowance, reserve, boost, hot window, usage and drain. */ export declare function orderUsageRankedCandidates(candidates: UsageRankedCandidate[], planGated: boolean): UsageCandidate[];