/** * Backend Resolver - Unified LLM backend resolution with AI SDK preference * * Resolution order: * 1. AI SDK backend (if installed and enabled) * 2. Native provider registry (OpenAI, Anthropic, Google) * 3. Error with actionable guidance * * Environment variables: * - PRAISONAI_BACKEND: 'ai-sdk' | 'native' | 'auto' (default: 'auto') */ import type { LLMProvider, ProviderConfig } from './providers/types'; export type BackendSource = 'ai-sdk' | 'native' | 'custom' | 'legacy'; export interface BackendResolutionResult { provider: LLMProvider; source: BackendSource; providerId: string; modelId: string; warnings?: string[]; } export interface ResolveBackendOptions { /** Force a specific backend: 'ai-sdk' | 'native' | 'auto' (default: 'auto') */ backend?: 'ai-sdk' | 'native' | 'auto'; /** Provider configuration (API keys, timeouts, etc.) */ config?: ProviderConfig; /** Attribution context for multi-agent tracing */ attribution?: { agentId?: string; runId?: string; sessionId?: string; }; } /** * Check if AI SDK is available (installed) * Result is cached after first check */ export declare function isAISDKAvailable(): Promise; /** * Reset the AI SDK availability cache (for testing) */ export declare function resetAISDKAvailabilityCache(): void; /** * Get the preferred backend from environment */ export declare function getPreferredBackend(): 'ai-sdk' | 'native' | 'auto'; /** * Parse model string into provider and model ID */ export declare function parseModelString(model: string): { providerId: string; modelId: string; }; /** * Resolve the best available backend for a model * * @param modelString - Model string in format "provider/model" or just "model" * @param options - Resolution options * @returns Backend resolution result with provider instance * * @example * ```typescript * const { provider, source } = await resolveBackend('openai/gpt-4o-mini'); * const result = await provider.generateText({ messages: [...] }); * ``` */ export declare function resolveBackend(modelString: string, options?: ResolveBackendOptions): Promise; /** * Resolve backend synchronously using cached availability * Only works if isAISDKAvailable() has been called before * Falls back to native if cache is not populated */ export declare function resolveBackendSync(modelString: string, options?: ResolveBackendOptions): BackendResolutionResult; /** * Get default model string */ export declare function getDefaultModel(): string; export type { LLMProvider, ProviderConfig };