import { type Database } from "../data/database.js"; import { type ProviderConnection } from './connection-config.js'; import { type CatalogRefreshSource, type ModelDefinitionConfig, type ModelProtocol } from "./catalog.js"; export type { ModelDefinitionConfig, ModelProtocol } from "./catalog.js"; export type ModelAuthType = "api_key" | "oauth" | "none" | "ambient"; export type ModelCredentialProfileKind = "builtin_provider" | "custom_endpoint" | "trusted_adapter"; export type ModelRequestProfile = "standard" | "openai_codex_subscription"; export interface ModelCredentialProfile { connection?: ProviderConnection; credentialEnv?: Record; id: string; profileKind?: ModelCredentialProfileKind; name: string; providerSlug: string; protocol: ModelProtocol; baseUrl?: string; authType: ModelAuthType; apiKey?: string; oauthProviderId?: string; oauthCredentials?: Record; requestProfile: ModelRequestProfile; authHeader?: boolean; headers?: Record; enabled: boolean; isDefault: boolean; models: ModelDefinitionConfig[]; modelCustomizations?: { disabled?: string[]; contextWindowOverride?: Record; addedModels?: ModelDefinitionConfig[]; }; createdAt: number; updatedAt: number; } export type ModelCredentialProfileInput = Omit; export interface PublicModelCredentialProfile extends Omit { headerNames?: string[]; hasSecret: boolean; modelRefs: string[]; catalogModels?: ModelDefinitionConfig[]; addedModels?: ModelDefinitionConfig[]; } export interface ConnectApiKeyRequest { providerSlug: string; apiKey: string; name?: string; baseUrlOverride?: string; requestProfile?: ModelRequestProfile; isDefault?: boolean; } export interface OAuthDeviceCodeInfo { userCode: string; verificationUri: string; expiresInSeconds?: number; intervalSeconds?: number; } export interface OAuthSelectPrompt { message: string; options: Array<{ id: string; label: string; }>; } export interface AvailableModelOption extends Omit { ref: string; provider: string; providerSlug: string; providerDisplayName?: string; modelId: string; displayName?: string; profileId: string; profileName: string; profileBaseUrl?: string; protocol: ModelProtocol; credentialStatus: "configured" | "missing" | "no_auth" | "ambient"; images: boolean; } export declare const DUMMY_API_KEY = "__bossmode_no_auth__"; type ModelCredentialStore = { profiles: ModelCredentialProfile[]; migrations: string[]; }; export type OAuthCredentials = { refresh: string; access: string; expires: number; [key: string]: unknown; }; export type OAuthLoginCallbacks = { onAuth: (info: { url: string; instructions?: string; }) => void; onPrompt: (prompt: { message: string; placeholder?: string; allowEmpty?: boolean; secret?: boolean; }) => Promise; onProgress?: (message: string) => void; onManualCodeInput?: () => Promise; onDeviceCode: (deviceCode: OAuthDeviceCodeInfo) => void; onSelect: (prompt: OAuthSelectPrompt) => Promise; signal?: AbortSignal; }; export interface OAuthLoginAdapter { login(providerId: string, callbacks: OAuthLoginCallbacks): Promise; } export declare function now(): number; export declare function sanitizeProfile(profile: ModelCredentialProfile): PublicModelCredentialProfile; export declare function validateOAuthProvider(providerId: string | undefined): string; export declare function hasCompleteOAuthCredentials(value: unknown): value is OAuthCredentials; export declare function isNewerOAuthCredential(candidate: OAuthCredentials, current: unknown): boolean; export declare function validateInput(input: ModelCredentialProfileInput, existing?: ModelCredentialProfile, options?: { allowIncompleteOAuth?: boolean; }): ModelCredentialProfileInput & { models: ModelDefinitionConfig[]; profileKind: ModelCredentialProfileKind; }; export declare function loadModelCredentialProfiles(): ModelCredentialProfile[]; export declare function listPublicModelCredentialProfiles(): PublicModelCredentialProfile[]; export declare function getModelCredentialProfile(id: string): ModelCredentialProfile | null; export declare function saveModelCredentialProfile(input: ModelCredentialProfileInput & { id?: string; }, options?: { replaceApiKey?: boolean; }): PublicModelCredentialProfile; export declare function nextBuiltinProfileName(providerSlug: string, displayName: string): string; export declare function connectBuiltinProviderApiKey(input: ConnectApiKeyRequest): PublicModelCredentialProfile; export declare function deleteModelCredentialProfile(id: string): boolean; export interface ModelDiscoveryResult { models: ModelDefinitionConfig[]; partial: boolean; warnings: string[]; } export declare function normalizeRuntimeBaseUrl(profile: ModelCredentialProfile, rawBaseUrl: string): string; export interface CatalogManualRefreshResult { source: CatalogRefreshSource; error?: string; fetchedAt?: number | null; freshnessLabel: string; modelCount: number; triggered: boolean; reason: string; } export declare function refreshBuiltinCatalog(reason: string): Promise; export declare function maybeRefreshCatalogInBackground(reason: string): void; export declare function startCatalogAutoRefreshScheduler(): void; export declare function shouldUseSdkBuiltinCatalog(profile: ModelCredentialProfile): boolean; export declare function normalizeLegacyCredentialImport(store: ModelCredentialStore, catalog: any[]): ModelCredentialStore; export declare function discoverModelCredentialModels(input: Partial & { id?: string; }): Promise; export interface CredentialImport { profiles: ModelCredentialProfile[]; migrations: string[]; } export declare function credentialRevision(id: string, db?: Database): number | null; export declare function credentialSnapshot(id: string, db?: Database): { profile: ModelCredentialProfile | null; revision: number | null; }; export declare function readCredentialStore(db?: Database): CredentialImport; export declare function importModelProfile(p: ModelCredentialProfile, position?: number, db?: Database): void; export declare function replaceCredentialStore(store: CredentialImport, db?: Database): void; export declare function updateCredentialSecret(id: string, provider: string, revision: number, credential: { apiKey?: string; oauthCredentials?: Record; }, updatedAt: number, db?: Database): boolean; export declare function normalizeModelRef(modelRef: string): string; export declare function listAvailableModels(): AvailableModelOption[]; export declare function resolveCredentialProfileForModel(args: { modelRef: string; credentialId?: string; }): ModelCredentialProfile | null; export declare function isModelAvailable(modelRef: string): boolean; export declare function assertModelAvailable(modelRef: string, context: string): void; export type ModelCredential = { type: "api_key"; key?: string; env?: Record; } | ({ type: "oauth"; } & OAuthCredentials); export declare function readModelCredential(profileId: string, providerSlug: string): ModelCredential | undefined; export declare function modifyModelCredential(profileId: string, providerSlug: string, fn: (current: ModelCredential | undefined) => Promise): Promise; //# sourceMappingURL=models.d.ts.map