/** * Model provider module - integrates built-in models with custom models from models.json */ import { type Model, type Api } from '@earendil-works/pi-ai/compat'; import { type Config } from '../config/schema.js'; import { type CredentialResolverOptions } from '../auth/credentials.js'; import type { ProviderModelDefinition } from '../extensions/types/providers.js'; export { EXTENSION_PROVIDER_BASE_URL } from './constants.js'; export { getApiKeyFromEnv, PROVIDER_ENV_MAP } from './env-keys.js'; /** Map a plugin registry model to the pi-ai {@link Model} shape. */ export declare function pluginModelToModel(providerId: string, definition: ProviderModelDefinition): Model; /** * Get API key synchronously: checks registry (models.json) first, then environment variables. * Use this for Agent's getApiKey callback which must be synchronous. */ export declare function getApiKeySync(provider: string): string | undefined; /** * Resolve model reference. Supports: * - "provider/modelId" format * - "modelId" auto-detection via pi-ai or custom models * @throws if model not found */ export declare function resolveModel(ref: string): Model; export declare function getModelsByProvider(provider: string): readonly Model[]; export declare function getAllProviders(): string[]; export declare function getApiKey(provider: string, credentialOptions?: CredentialResolverOptions): Promise; /** * Synchronous version for use in non-async contexts * Only checks environment variables and registry, not credential system */ export declare function isProviderConfiguredSync(provider: string): boolean; export declare function isProviderConfigured(provider: string): Promise; /** Where runtime {@link getApiKey} resolves the key from (no secret values). */ export type ProviderActiveKeySource = 'none' | 'agent' | 'gateway' | 'oauth' | 'env' | 'models_json' | 'extension'; export type ProviderAuthMode = ProviderActiveKeySource; export type ProviderAuthStatus = 'connected' | 'expired' | 'not_connected'; export interface ProviderAuthState { authMode: ProviderAuthMode; authStatus: ProviderAuthStatus; expiresAt?: number; } export declare function getProviderActiveKeySource(provider: string): Promise; export declare function getProviderAuthState(provider: string): Promise; export declare function getConfiguredProviders(): Promise; export declare function getAllModels(): readonly Model[]; export declare function getAvailableModels(): Promise[]>; export type { Model, Api } from '@earendil-works/pi-ai'; export type ProviderCategory = 'common' | 'domestic' | 'specialty' | 'oauth' | 'enterprise' | 'extension'; export interface ProviderMeta { name: string; category: ProviderCategory; supportsOAuth?: boolean; supportsApiKey?: boolean; } export declare const PROVIDER_META: Record; export declare function getSortedProviders(): string[]; export declare function getProviderDisplayName(provider: string): string; export declare function providerSupportsOAuth(provider: string): boolean; export declare function providerSupportsApiKey(provider: string): boolean; /** * Get a default model reference. * Priority: * 1. Effective model inherited from the global default preset / agent presets / agent override * 2. Empty string only when no default model is present in the loaded config */ export declare function getDefaultModel(config?: Config | null | undefined): Promise; /** * Synchronous default model resolution for constructors and sync code paths. * Uses catalog/registry only (no async credential checks). * * When no model is present in the loaded config, returns an empty string so * setup flows can prompt for the global default model. */ export declare function getDefaultModelSync(config?: Config | null | undefined): string; export { ModelRegistry, getModelRegistry, resetModelRegistry, prewarmModelRegistry } from './model-registry.js';