import { Ref } from 'vue'; import { AIClient, AIProvider } from '../../../core/src'; export interface Message { role: 'system' | 'user' | 'assistant'; content: string; id?: string; timestamp?: Date; userId?: string; conversationId?: string; threadId?: string; metadata?: Record; attachments?: Array<{ type: string; name: string; url: string; size?: number; }>; reactions?: Array<{ emoji: string; userId: string; timestamp: Date; }>; edited?: boolean; editedAt?: Date; sentiment?: 'positive' | 'negative' | 'neutral'; confidence?: number; processingTime?: number; modelUsed?: string; } export interface Conversation { id: string; userId: string; title: string; threadId?: string; tags: string[]; metadata: Record; createdAt: Date; updatedAt: Date; messageCount: number; isArchived: boolean; isShared: boolean; sharedWith?: string[]; } export interface Thread { id: string; title: string; conversationIds: string[]; createdAt: Date; updatedAt: Date; tags: string[]; } export interface ChatOptions { provider: AIProvider; apiKey?: string; model?: string; client?: AIClient; baseUrl?: string; organizationId?: string; initialMessages?: Message[]; systemPrompt?: string; streaming?: boolean; persistenceKey?: string | null; maxMessages?: number; demoMode?: boolean; demoResponses?: Record; useProxy?: boolean; proxyUrl?: string; storage?: { provider?: 'supabase' | 'firebase' | 'mongodb' | 'postgresql' | 'localStorage'; connectionString?: string; apiKey?: string; projectId?: string; userId?: string; autoSave?: boolean; }; user?: { id: string; name?: string; email?: string; avatar?: string; preferences?: Record; }; threading?: { enabled?: boolean; autoCreateThreads?: boolean; threadNaming?: 'ai-generated' | 'manual' | 'timestamp'; maxThreads?: number; }; voice?: { speechToText?: boolean; textToSpeech?: boolean; language?: string; voiceId?: string; }; analytics?: { enabled?: boolean; trackUserSentiment?: boolean; trackUsageMetrics?: boolean; exportReports?: boolean; }; multiModel?: { enabled?: boolean; models?: Array<{ name: string; provider: AIProvider; apiKey?: string; specialty?: string; }>; autoSwitch?: boolean; }; fileProcessing?: { enabled?: boolean; maxSize?: string; allowedTypes?: string[]; ocrEnabled?: boolean; batchProcessing?: boolean; }; rag?: { enabled?: boolean; knowledgeBase?: any[]; chunkSize?: number; topK?: number; retrieveContext?: (query: string) => any; contextTemplate?: string; }; onError?: ((error: Error) => void) | null; onMessageSent?: ((message: Message) => void) | null; onResponseReceived?: ((message: Message) => void) | null; onConversationSaved?: ((conversationId: string) => void) | null; onThreadCreated?: ((threadId: string) => void) | null; } export interface ChatState { messages: Message[]; isLoading: boolean; error: Error | null; } export interface ChatEngineReturn { messages: Ref; isLoading: Ref; error: Ref; sendMessage: (content: string) => Promise; clearMessages: () => void; setMessages: (messages: Message[]) => void; addMessage: (message: Message) => void; resetError: () => void; updateConfig: (config: Partial) => void; saveConversation?: (title: string) => Promise; loadConversation?: (id: string) => Promise; deleteConversation?: (id: string) => Promise; searchConversations?: (query: string) => Promise; startListening?: () => Promise; stopListening?: () => void; speak?: (text: string) => Promise; stopSpeaking?: () => void; getUsageMetrics?: () => Promise; exportReport?: (format: 'json' | 'csv') => Promise; switchModel?: (modelName: string) => void; getAvailableModels?: () => any[]; getModelPerformance?: () => any[]; } /** * Composable for managing chat state and interactions with AI * * @param options - Configuration options * @returns Chat state and methods */ export declare function useChatEngine(options: ChatOptions): ChatEngineReturn; export default useChatEngine;