import { ActionStep } from '../engine/types'; import { PageState } from '../types'; export interface AIMessage { role: 'system' | 'user' | 'assistant'; content: string; } export interface AIResponse { content: string; finishReason?: 'stop' | 'length' | 'tool_calls' | 'content_filter'; usage?: { promptTokens: number; completionTokens: number; totalTokens: number; }; } /** * AI Configuration for providers */ export interface AIConfig { model: string; provider?: string; apiKey?: string; baseUrl?: string; temperature?: number; maxTokens?: number; timeout?: number; } export interface VisionCapabilities { supportsImages: boolean; supportedFormats: string[]; maxImageSize?: number; } /** * Generic AI Provider interface for different AI services */ export interface AIProvider { readonly name: string; readonly config: AIConfig; readonly visionCapabilities: VisionCapabilities; /** * Send a text-only prompt to the AI */ generateText(prompt: string, systemPrompt?: string): Promise; /** * Generate structured JSON response (optional - for providers that support it) */ generateStructuredJSON?(prompt: string, systemPrompt?: string): Promise; /** * Send a multi-modal prompt (text + images) to the AI */ generateWithVision?(prompt: string, images: Buffer[], systemPrompt?: string): Promise; /** * Send a conversation with multiple messages */ generateFromMessages(messages: AIMessage[]): Promise; /** * Test if the provider is available/healthy */ healthCheck(): Promise; /** * Get available models for this provider */ getAvailableModels?(): Promise; } /** * AI Engine that manages multiple providers and provides a unified interface */ export declare class AIEngine { private providers; private defaultProvider?; private promptTemplate; constructor(); /** * Register an AI provider */ registerProvider(provider: AIProvider): void; /** * Add a provider to the engine by name and configuration */ addProvider(providerName: string, config: AIConfig): void; /** * Creates a provider instance based on the provider name */ private createProvider; /** * Set the default provider */ setDefaultProvider(providerName: string): void; /** * Get a specific provider */ getProvider(providerName: string): AIProvider | undefined; /** * Get the default provider */ getDefaultProvider(): AIProvider; /** * Generate text using the default provider */ generateText(prompt: string, systemPrompt?: string): Promise; /** * Generate structured JSON response using the best available method */ generateStructuredJSON(prompt: string, systemPrompt?: string): Promise; /** * Generate with vision using the default provider (if supported) */ generateWithVision(prompt: string, images: Buffer[], systemPrompt?: string): Promise; /** * Parse instruction into browser automation steps using AI */ parseInstructionToSteps(instruction: string, pageState: PageState): Promise; /** * Fallback parsing when AI fails */ private fallbackParsing; /** * Analyze page content using AI (with vision if available) */ analyzePageContent(pageState: PageState, query?: string): Promise; /** * List all registered providers */ listProviders(): string[]; /** * Health check all providers */ checkAllProviders(): Promise>; }