/** * Shared provider ordering used by every provider-facing selector (`/login`, * `/model`, `/provider`). * * Providers the user already has come first, then a curated list of well-known * providers, then everything else alphabetically. This is the single source of * truth for that order — surfaces must not keep their own famous-provider list. */ /** * Auth/config state of a provider as seen by the calling surface. * * - `valid` — stored credentials that validated successfully. * - `checking` — stored credentials whose async validation is still in flight. * Ranked with `valid` so rows do not reflow when validation resolves. * - `configured` — no OAuth record, but the provider is present in the model * registry with a working API key (custom/API-compatible providers). * - `invalid` — stored credentials that failed validation (problematic login). * - `none` — nothing stored and nothing configured. */ export type ProviderAuthState = "valid" | "checking" | "configured" | "invalid" | "none"; export declare const PROVIDER_RANK_TIER: { readonly existing: 0; readonly problematic: 1; readonly famous: 2; readonly other: 3; }; export type ProviderRankTier = (typeof PROVIDER_RANK_TIER)[keyof typeof PROVIDER_RANK_TIER]; /** * Curated provider order for the famous tier. Regional and device variants sit * immediately behind their primary so related entries stay grouped. */ export declare const FAMOUS_PROVIDER_ORDER: readonly string[]; /** A provider as ranked by a surface. `label` is what the user sees. */ export interface RankableProvider { id: string; label: string; authState: ProviderAuthState; } /** A provider's position in the ordering: its tier plus its rank inside that tier. */ export interface ProviderRank { tier: ProviderRankTier; intraTierRank: number; } /** * The single ranking result for a provider. `intraTierRank` is the curated * famous-list position, or `Number.MAX_SAFE_INTEGER` for providers that are not * on the list and therefore order by display label. */ export declare function rankProvider(provider: RankableProvider): ProviderRank; export declare function providerRankTier(authState: ProviderAuthState, id: string): ProviderRankTier; /** Position within the famous list, or `undefined` for providers not on it. */ export declare function famousProviderIndex(id: string): number | undefined; /** * Total order over providers: tier, then famous-list position, then display * label, then id. The trailing id comparison guarantees no ties. */ export declare function compareRankedProviders(left: RankableProvider, right: RankableProvider): number; /** Convenience wrapper returning a new array in ranked order. */ export declare function sortRankedProviders(providers: readonly T[]): T[];