/** One saved API key / OAuth token, with the secret already masked. */ export interface AuthKeyRow { label: string; /** Pre-masked display form ("sk-a…f3k2" / "••••••") — never the secret. */ masked: string; createdAt: string; active: boolean; authMethod?: 'api_key' | 'oauth' | 'session_token' | undefined; expiresAt?: string | undefined; } /** One saved provider from the active profile config. */ export interface AuthProviderRow { id: string; type?: string | undefined; family?: string | undefined; baseUrl?: string | undefined; models: string[]; envVars: string[]; keys: AuthKeyRow[]; } /** One models.dev catalog entry offered by "Add provider (catalog)". */ export interface AuthCatalogRow { id: string; name: string; family: string; apiBase?: string | undefined; envVars: string[]; /** Already present in the saved config (shown as ◉). */ saved: boolean; } /** One local-LLM preset (OmniRoute / Ollama / vLLM / LM Studio). */ export interface AuthLocalPresetRow { id: string; label: string; defaultBaseUrl: string; noAuth: boolean; hint: string; } export type AuthOAuthKind = 'chatgpt' | 'claude' | 'copilot'; /** * Bridge the CLI flows use to talk to the panel while a flow runs. * `prompt` REJECTS when the user cancels (Esc) — flows treat a thrown * prompt as user-cancel, which aborts before anything is saved. */ export interface AuthFlowIo { onLog(line: string): void; prompt(question: string, opts: { secret: boolean; }): Promise; signal: AbortSignal; } export interface AuthFlowResult { ok: boolean; message?: string | undefined; } /** * Host callbacks the CLI provides. Simple mutations return an error * string (or null on success); multi-step interactions run as "flows" * that log and prompt through {@link AuthFlowIo}. */ export interface AuthPanelHost { listProviders(): Promise; listCatalog(): Promise; localPresets(): AuthLocalPresetRow[]; setActiveKey(providerId: string, label: string): Promise; deleteKey(providerId: string, label: string): Promise; removeProvider(providerId: string): Promise; addKey(providerId: string, io: AuthFlowIo): Promise; updateKey(providerId: string, label: string, io: AuthFlowIo): Promise; editField(providerId: string, field: 'family' | 'baseUrl' | 'models', io: AuthFlowIo): Promise; /** * Edit a single model's detailed schema fields (ME-5). Opens a field-group * prompt flow covering identity, limits, pricing, modalities, capability * flags, and dates. Validates via the ME-1 zod schema. * * Shows the models.dev catalog reference values alongside the current * values so the user can see what the upstream defaults are and reset * individual fields back to them. */ editModelDetails(providerId: string, modelId: string, io: AuthFlowIo): Promise; /** * Add a model to the provider's allowlist with optional full schema details * (ME-5). When `fromCatalog` is true, prefills from the models.dev registry. */ addModel(providerId: string, io: AuthFlowIo, opts?: { fromCatalog?: boolean | undefined; }): Promise; /** Remove a single model from the provider's allowlist + customModels (ME-5). */ removeModel(providerId: string, modelId: string): Promise; /** * Reset a model's customModels override back to the models.dev catalog * values (ME-5). Drops the customModels entry for this modelId so the * runtime falls back to the live catalog data. */ resetModelToCatalog(providerId: string, modelId: string): Promise; addCatalogProvider(catalogId: string, io: AuthFlowIo): Promise; addCustomProvider(io: AuthFlowIo): Promise; addLocal(presetId: string, io: AuthFlowIo): Promise; oauthLogin(kind: AuthOAuthKind, io: AuthFlowIo): Promise; } export type AuthPanelView = 'list' | 'provider' | 'models' | 'catalog' | 'local' | 'oauth' | 'flow'; export type AuthConfirmAction = { kind: 'delete-key'; providerId: string; label: string; } | { kind: 'remove-provider'; providerId: string; } | { kind: 'remove-model'; providerId: string; modelId: string; }; export interface AuthPanelState { open: boolean; view: AuthPanelView; busy: boolean; hint?: string | undefined; providers: AuthProviderRow[]; presets: AuthLocalPresetRow[]; catalog: AuthCatalogRow[]; /** Cursor index into `authPanelRows(state)` for the current view. */ selected: number; /** Provider shown in the 'provider' detail view. */ providerId?: string | undefined; /** Type-to-filter query for the catalog view. */ filter: string; /** Running/last flow (OAuth, catalog add, local add, key edit, …). */ flowTitle: string; log: string[]; flowDone: boolean; flowOk?: boolean | undefined; /** Modal one-line prompt raised by a flow (masked for secrets). */ input?: { label: string; masked: boolean; draft: string; } | undefined; /** Modal y/N confirmation for destructive actions. */ confirm?: { question: string; action: AuthConfirmAction; } | undefined; } export declare const AUTH_PANEL_INITIAL: AuthPanelState; export type AuthPanelRow = { kind: 'provider'; provider: AuthProviderRow; } | { kind: 'list-action'; action: 'catalog' | 'local' | 'custom' | 'oauth'; } | { kind: 'key'; keyRow: AuthKeyRow; } | { kind: 'provider-action'; action: 'add-key' | 'edit-family' | 'edit-base-url' | 'edit-models' | 'edit-model-details' | 'add-model' | 'reset-model-to-catalog' | 'remove' | 'back-to-list'; } | { kind: 'model-row'; providerId: string; modelId: string; name: string; } | { kind: 'catalog-entry'; entry: AuthCatalogRow; } | { kind: 'local-preset'; preset: AuthLocalPresetRow; } | { kind: 'oauth-option'; oauth: AuthOAuthKind; }; /** Case-insensitive substring filter over id + name + family. */ export declare function filterAuthCatalog(catalog: AuthCatalogRow[], filter: string): AuthCatalogRow[]; export declare function authSelectedProvider(state: AuthPanelState): AuthProviderRow | undefined; /** * Selectable rows for the current view, in render order. The component * renders exactly this list; the reducer clamps `selected` to its length; * the Enter handler dispatches on `rows[selected]`. */ export declare function authPanelRows(state: AuthPanelState): AuthPanelRow[]; /** Wrap-around cursor move over the current view's rows. */ export declare function authMoveSelected(state: AuthPanelState, delta: number): number; //# sourceMappingURL=auth-panel-model.d.ts.map