import { EventEmitter } from './EventEmitter'; import { ChatProcessorOptions } from './ChatProcessor'; import { MemoryOptions } from './MemoryManager'; import { ChatProviderName, ChatServiceOptionsByProvider } from '@aituber-onair/chat'; import { VoiceServiceOptions, VoiceServiceOptionsUpdate } from '@aituber-onair/voice'; import { Message, ToolDefinition, MCPServerConfig } from '@aituber-onair/chat'; import { MemoryStorage } from '../types'; /** * Setting options for AITuberOnAirCore */ export type SpeechChunkLocale = 'ja' | 'en' | 'ko' | 'zh' | 'all'; export interface SpeechChunkingOptions { /** Enable or disable speech chunking. Defaults to false (disabled). */ enabled?: boolean; /** Minimum words (approx.) per speech chunk. Set to 0 or omit to disable merging. */ minWords?: number; /** Locale preset used to decide punctuation delimiters. */ locale?: SpeechChunkLocale; /** Custom separator characters (overrides locale preset). */ separators?: string[]; } export interface AITuberOnAirCoreOptions { /** AI provider name */ chatProvider?: ChatProviderName; /** AI API key */ apiKey: string; /** AI model name (default is provider's default model) */ model?: string; /** ChatProcessor options */ chatOptions: Omit; /** Memory options (disabled by default) */ memoryOptions?: MemoryOptions; /** Memory storage for persistence (optional) */ memoryStorage?: MemoryStorage; /** Voice service options */ voiceOptions?: VoiceServiceOptions; /** Speech chunking behaviour */ speechChunking?: SpeechChunkingOptions; /** Debug mode */ debug?: boolean; /** ChatService provider-specific options (optional) */ providerOptions?: Omit; /** Tools */ tools?: { definition: ToolDefinition; handler: (input: any) => Promise; }[]; /** MCP servers configuration (OpenAI, Claude, and Gemini) */ mcpServers?: MCPServerConfig[]; } /** * Event types for AITuberOnAirCore */ export declare enum AITuberOnAirCoreEvent { /** Processing started */ PROCESSING_START = "processingStart", /** Processing ended */ PROCESSING_END = "processingEnd", /** Assistant (partial) response */ ASSISTANT_PARTIAL = "assistantPartial", /** Assistant response completed */ ASSISTANT_RESPONSE = "assistantResponse", /** Assistant response was truncated by the model/token budget */ ASSISTANT_RESPONSE_TRUNCATED = "assistantResponseTruncated", /** Speech started */ SPEECH_START = "speechStart", /** Speech ended */ SPEECH_END = "speechEnd", /** Error occurred */ ERROR = "error", /** Tool use */ TOOL_USE = "toolUse", /** Tool result */ TOOL_RESULT = "toolResult", /** Chat history set */ CHAT_HISTORY_SET = "chatHistorySet", /** Chat history cleared */ CHAT_HISTORY_CLEARED = "chatHistoryCleared", /** Memory created */ MEMORY_CREATED = "memoryCreated", /** Memory removed */ MEMORY_REMOVED = "memoryRemoved", /** Memory loaded */ MEMORY_LOADED = "memoryLoaded", /** Memory saved */ MEMORY_SAVED = "memorySaved", /** Storage cleared */ STORAGE_CLEARED = "storageCleared" } /** * AITuberOnAirCore is a core class that integrates the main features of AITuber * - Chat processing (ChatService, ChatProcessor) * - Speech synthesis (VoiceService) * - Memory management (MemoryManager) */ export declare class AITuberOnAirCore extends EventEmitter { private chatService; private chatProcessor; private memoryManager?; private voiceService?; private isProcessing; private debug; private toolExecutor; private speechChunkEnabled; private speechChunkMinWords; private speechChunkLocale; private speechChunkSeparators?; /** * Constructor * @param options Configuration options */ constructor(options: AITuberOnAirCoreOptions); private buildChatServiceOptions; /** * Process text chat * @param text User input text * @returns Success or failure of processing */ processChat(text: string): Promise; /** * Process image-based chat * @param imageDataUrl Image data URL * @param visionPrompt Custom prompt for describing the image (optional) * @returns Success or failure of processing */ processVisionChat(imageDataUrl: string, visionPrompt?: string): Promise; private withProcessing; /** * Stop speech playback */ stopSpeech(): void; /** * Get chat history */ getChatHistory(): Message[]; /** * Set chat history from external source * @param messages Message array to set as chat history */ setChatHistory(messages: Message[]): void; /** * Clear chat history */ clearChatHistory(): void; /** * Update voice service * @param options New voice service options */ updateVoiceService(options: VoiceServiceOptions): void; /** * Update speech chunking behaviour */ updateSpeechChunking(options: SpeechChunkingOptions): void; /** * Speak text with custom voice options * @param text Text to speak * @param options Speech options * @returns Promise that resolves when speech is complete */ speakTextWithOptions(text: string, options?: { enableAnimation?: boolean; temporaryVoiceOptions?: VoiceServiceOptionsUpdate; audioElementId?: string; }): Promise; /** * Setup forwarding of ChatProcessor events */ private setupEventForwarding; /** * Handle tool use * @param blocks Tool use blocks * @returns Tool result blocks */ private handleToolUse; /** * Split screenplay text into smaller chunks for sequential speech synthesis. * Falls back to the original text when no delimiters are present. */ private splitTextForSpeech; private getActiveSpeechSeparators; private segmentTextBySeparators; private countApproxWords; /** * Output debug log (only in debug mode) */ private log; /** * Generate new content based on the system prompt and the provided message history (one-shot). * The provided message history is used only for this generation and does not affect the internal chat history. * This is ideal for generating standalone content like blog posts, reports, or summaries from existing conversations. * * @param prompt The system prompt to guide the content generation * @param messageHistory The message history to use as context * @returns The generated content as a string */ generateOneShotContentFromHistory(prompt: string, messageHistory: Message[]): Promise; /** * Check if memory functionality is enabled */ isMemoryEnabled(): boolean; /** * Remove all event listeners */ offAll(): void; /** * Get current provider information * @returns Provider information object */ getProviderInfo(): { name: string; model?: string; }; /** * Get list of available providers * @returns Array of available provider names */ static getAvailableProviders(): string[]; /** * Get list of models supported by the specified provider * @param providerName Provider name * @returns Array of supported models */ static getSupportedModels(providerName: string): string[]; }