import { BotStatus, BotRecord, SpawnVoiceAgentOptions, SpawnScreenshareBotOptions } from '../types/bot'; /** * Configuration for BotSpawner */ export interface BotSpawnerConfig { /** * Backend API base URL */ apiBaseUrl: string; /** * Maximum time to wait for bot to reach 'running' state (milliseconds) */ spawnTimeout?: number; /** * Polling interval for checking bot status (milliseconds) */ pollInterval?: number; /** * Maximum number of spawn retry attempts */ maxRetries?: number; /** * Enable debug logging */ debug?: boolean; } /** * BotSpawner manages the lifecycle of voice agent and screenshare bots * * @example * ```typescript * const spawner = new BotSpawner({ * apiBaseUrl: 'https://api.example.com' * }); * * // Spawn voice agent * const voiceStatus = await spawner.spawnVoiceAgent('session-123'); * * // Spawn screenshare bot * const screenshareStatus = await spawner.spawnScreenshareBot('session-123', { * deckId: 'deck-456' * }); * * // Clean up all bots * await spawner.killBots('session-123'); * ``` */ export declare class BotSpawner { private readonly config; private readonly logger; private readonly bots; private readonly sessionBots; /** * Create a new BotSpawner instance * * @param config - BotSpawner configuration */ constructor(config: BotSpawnerConfig); /** * Spawn a voice agent bot for a session * * @param sessionId - Session ID to spawn voice agent for * @param options - Optional configuration for voice agent * @returns Promise resolving to bot status * @throws Error if spawn fails after retries * * @example * ```typescript * const status = await spawner.spawnVoiceAgent('session-123', { * config: { language: 'en-US' } * }); * console.log('Voice agent:', status.bot_id); * ``` */ spawnVoiceAgent(sessionId: string, options?: SpawnVoiceAgentOptions): Promise; /** * Spawn a screenshare bot for a session * * @param sessionId - Session ID to spawn screenshare bot for * @param options - Configuration including deck ID * @returns Promise resolving to bot status * @throws Error if spawn fails after retries * * @example * ```typescript * const status = await spawner.spawnScreenshareBot('session-123', { * deckId: 'deck-456' * }); * console.log('Screenshare bot:', status.bot_id); * ``` */ spawnScreenshareBot(sessionId: string, options: SpawnScreenshareBotOptions): Promise; /** * Get the current status of a bot * * @param botId - Bot ID to check * @returns Promise resolving to bot status * @throws Error if bot not found or API request fails * * @example * ```typescript * const status = await spawner.getBotStatus('bot-123'); * console.log('Bot state:', status.status); * ``` */ getBotStatus(botId: string): Promise; /** * Kill all bots associated with a session * * @param sessionId - Session ID to kill bots for * @returns Promise that resolves when all bots are killed * * @example * ```typescript * await spawner.killBots('session-123'); * console.log('All bots terminated'); * ``` */ killBots(sessionId: string): Promise; /** * Get all bot IDs for a session * * @param sessionId - Session ID to get bots for * @returns Array of bot IDs */ getSessionBots(sessionId: string): string[]; /** * Get all tracked bots * * @returns Array of bot records */ getAllBots(): BotRecord[]; /** * Spawn a bot with retry logic * * @private */ private spawnBotWithRetry; /** * Spawn a bot and wait for it to reach 'running' state * * @private */ private spawnBot; /** * Call the backend spawn endpoint * * @private */ private callSpawnEndpoint; /** * Wait for bot to reach 'running' state with polling * * @private */ private waitForBotRunning; /** * Kill a single bot * * @private */ private killBot; /** * Parse error response from API * * @private */ private parseErrorResponse; /** * Sleep helper * * @private */ private sleep; }