import type { ClientModel, ModelAccountChoiceRefusal } from "@opengeni/sdk"; import type { BillingClass } from "../billing-class-mark.js"; import type { SubscriptionAccountMenuRow, SubscriptionAccountMenuUsage, SubscriptionAccountUsageWindow } from "./subscription-account-menu.js"; export type SubscriptionAccountUsage = { /** When the reading was taken; null when unknown. */ observedAt: string | null; windows: Array<{ id: string; /** Null means unknown; values over 100 can represent overage. */ usedPercent: number | null; resetsAt: string | null; status: "ok" | "warning" | "exhausted" | "unknown"; }>; exhaustedUntil: string | null; exhaustedKind: "quota" | "rate_limit" | null; }; export type SubscriptionAccount = { id: string; label: string | null; email: string | null; plan: string | null; /** Who the account belongs to; null when the source does not say. */ source: "personal" | "workspace" | "organization" | null; /** The provider's account status (`active`, `needs_relogin`, …). */ status: string; refusal: ModelAccountChoiceRefusal | null; choosable: boolean; /** Undefined: not reported. Null: no reading yet. */ usage: SubscriptionAccountUsage | null | undefined; }; export type SubscriptionAccountState = { /** `codex`, `claude`, `xai`, … */ provider: string; /** True until the first read settles. */ loading: boolean; /** The accounts could not be read. */ unavailable: boolean; /** Accounts this person can pick for the next turn. */ accounts: SubscriptionAccount[]; /** The account the chat runs on (or will next), when this person can see it. */ current: SubscriptionAccount | null; /** The chat runs on a chosen or serving account this person cannot see. */ currentHidden: boolean; /** `current`/`currentHidden` is the account serving the chat's latest turn. */ serving: boolean; /** Automatic selection, not a person's explicit choice. */ automatic: boolean; /** The explicitly chosen account, when this person can see it. */ chosenId: string | null; /** A turn waits for capacity on the current account. */ waiting: boolean; /** * A live usage check, for sources that offer one: `checking` until its * first reading arrives, `failed` when it produced none for this account. */ usageCheck: "idle" | "checking" | "failed"; choosing: boolean; /** The in-flight target (`null` is automatic; `undefined` when idle). */ choosingTarget: string | null | undefined; appliedTo: "waiting_turn" | "next_turn" | null; mutationError: string | null; }; export declare function subscriptionProviderPresentation(provider: string): { name: string; billingClass: BillingClass; }; export declare function accountLabel(account: SubscriptionAccount): string; export declare function accountStatus(account: SubscriptionAccount): string | null; /** The reading as usage rows: percentage used, with when each window resets. */ export declare function subscriptionAccountUsage(usage: SubscriptionAccountUsage | null | undefined, now?: number): { windows?: SubscriptionAccountUsageWindow[]; message?: string; note?: string; summary?: string; }; /** * Whether there is anything to show or choose. A chat whose provider offers * no accounts to this person, with nothing chosen, serving or waiting, shows * the provider's mark alone instead of an empty menu. */ export declare function showsSubscriptionAccountMenu(state: SubscriptionAccountState): boolean; /** * The subscription whose accounts a chat's header offers, or null for a chat * that does not run on a subscription. Codex product models are Codex * subscriptions even before the catalog lists them, and so are Claude * subscription model ids. The workspace catalog leaves `credentialSource` * out, so its public provider id and rail decide for the rest. */ export declare function subscriptionAccountProvider(modelId: string, model: Pick | null | undefined): string | null; /** Everything the account menu shows, from the neutral state. */ export declare function subscriptionAccountMenuContent(state: SubscriptionAccountState): { ariaLabel: string; selectionLabel: string; displayName: string; identity: string | null; metadata: string; tone: "bad" | "ok" | "warn"; usage: SubscriptionAccountMenuUsage; accounts: SubscriptionAccountMenuRow[]; selectedId: string | null; automaticSelected: boolean; actionLabel: string; automaticLabel: string; emptyMessage: string; error: string | null; note: string; };