import { EventEmitter } from 'events'; import { ActionStep } from '../types'; export interface ExecutionEvent { type: 'plan_created' | 'step_start' | 'step_complete' | 'step_error' | 'screenshot' | 'page_change' | 'execution_complete'; stepIndex?: number; step?: ActionStep; steps?: ActionStep[]; totalSteps?: number; screenshot?: string; url?: string; title?: string; error?: string; timestamp: Date; sessionId: string; } export interface StreamClient { id: string; response: any; lastPing: Date; } /** * ExecutionStream - Provides real-time execution visualization for web integration */ export declare class ExecutionStream extends EventEmitter { private clients; private currentSessionId; private executionHistory; private cleanupInterval?; constructor(); /** * Start a new execution session */ startSession(sessionId: string): void; /** * Stream plan creation event with total step count and steps */ streamPlanCreated(totalSteps: number, steps?: ActionStep[]): void; /** * Stream step start event */ streamStepStart(stepIndex: number, step: ActionStep): void; /** * Stream step completion with screenshot */ streamStepComplete(stepIndex: number, step: ActionStep, screenshot?: Buffer): void; /** * Stream step error */ streamStepError(stepIndex: number, step: ActionStep, error: string): void; /** * Stream page change event */ streamPageChange(url: string, title: string, screenshot?: Buffer): void; /** * Stream execution completion */ streamExecutionComplete(): void; /** * Add a new SSE client */ addClient(clientId: string, response: any): void; /** * Remove a client */ removeClient(clientId: string): void; /** * Get current execution status for REST API */ getExecutionStatus(): { sessionId: string | null; isActive: boolean; totalEvents: number; connectedClients: number; lastEvent?: ExecutionEvent; }; /** * Get execution history for REST API */ getExecutionHistory(): ExecutionEvent[]; private broadcastEvent; private sendToClient; private setupCleanupInterval; /** * Cleanup resources - mainly for testing */ cleanup(): void; } export declare const executionStream: ExecutionStream;