/** * Progress Reporter Interface * Allows consumers to track execution progress (logs, DB writes, etc.) */ import { SiteLearnings } from './orchestrator/types'; import { TestPathway } from './types'; /** * Execution status for a step * Matches scriptservice StepExecutionStatus enum */ export declare enum StepExecutionStatus { SUCCESS = "SUCCESS_STEP_EXECUTION", FAILURE = "FAILURE_STEP_EXECUTION", IN_PROGRESS = "IN_PROGRESS_STEP_EXECUTION", SKIPPED = "SKIPPED_STEP_EXECUTION" } /** * Scenario coverage status for @Scenario annotations * Matches scriptservice ScenarioCoverageStatus enum */ export declare enum ScenarioCoverageStatus { UNKNOWN = "UNKNOWN_SCENARIO_COVERAGE_STATUS", SUCCESSFUL = "SUCCESSFUL_SCENARIO_COVERAGE", FAILED = "FAILED_SCENARIO_COVERAGE", NOT_ATTEMPTED = "NOT_ATTEMPTED_SCENARIO_COVERAGE" } /** * Step progress report - camelCase for TypeScript * Structure matches scriptservice's SmartTestExecutionStep / ScriptGenStep */ export interface StepProgress { jobId: string; stepId?: string; stepNumber: number; description: string; code?: string; agentCode?: string; screenStateAnnotation?: string; screenshotDataUrl?: string; status: StepExecutionStatus; error?: string; wasRepaired?: boolean; subActionCount?: number; attempt?: number; agentIteration?: number; agentReasoning?: string; agentSelfReflection?: any; agentExperiences?: string[]; agentToolsUsed?: string[]; agentStatus?: string; noteToFutureSelf?: string; } /** * Job progress report - camelCase for TypeScript */ export interface JobProgress { jobId: string; status: 'started' | 'in_progress' | 'completed' | 'failed'; currentStep?: number; totalSteps?: number; testName?: string; script?: string; error?: string; } /** * Token usage tracking */ export interface TokenUsage { jobId: string; stepNumber?: number; iteration?: number; inputTokens: number; outputTokens: number; includesImage: boolean; model: string; timestamp: number; } /** * Tool usage statistics per tool */ export interface ToolUsageStats { [toolName: string]: { count: number; averageUsefulnessScore: number; numTimesRated: number; }; } /** * Debug statistics for a test run (populated only on completion) */ export interface DebugStats { tokensUsedIn: number; tokensUsedOut: number; imagesUsed: number; toolsUsed: ToolUsageStats; promptImproveSuggestions: string[]; coordinateActionsCount: number; } /** * Additional step info for lifecycle callbacks */ export interface StepInfo { stepId?: string; stepNumber: number; description: string; code?: string; } /** * Result from beforeStepStart callback indicating step modification * Allows skipping the step or replacing it with an alternative command */ export interface StepModificationResult { /** * If true, skip the step entirely (don't execute) */ skip?: boolean; /** * Optional reason for skipping (logged for debugging) */ reason?: string; /** * Alternative command to execute instead of the original step code * If provided, this command will be executed instead of the original step * Mutually exclusive with skip (if alternativeCommand is provided, skip is ignored) */ alternativeCommand?: string; } /** * Response from onStepProgress callback * Allows callback to control exploration flow */ export interface StepProgressResponse { shouldContinue: boolean; } /** * Progress reporter interface for external consumers */ export interface ProgressReporter { /** * Called when a step starts, updates, or completes * - VS Extension/GitHub: Log to console * - Script Service: Write to DB, upload screenshot to GCS * Can return StepProgressResponse to control exploration flow (abort/continue) */ onStepProgress?(progress: StepProgress): Promise; /** * Called when overall job status changes * - VS Extension/GitHub: Log status * - Script Service: Update job in DB */ onJobProgress?(progress: JobProgress): Promise; /** * Called when script is generated/updated */ onScriptGenerated?(jobId: string, script: string, testName: string): Promise; /** * Called when script is repaired/updated */ onScriptRepaired?(jobId: string, originalScript: string, repairedScript: string, confidence: number): Promise; /** * Called when tokens are used (for cost tracking) * - VS Extension/GitHub: Log token usage * - Script Service: Store in DB for analytics */ onTokensUsed?(usage: TokenUsage): Promise; /** * Generic logging (for environments that don't need structured progress) */ log?(message: string, level?: 'log' | 'error' | 'warn'): void; /** * LIFECYCLE CALLBACKS (optional - used by scriptservice, ignored by local clients) */ /** * Called before test execution starts * - Script Service: Initialize browser context, set up DB records * - VS Extension/GitHub: Not used (ignore) */ beforeStartTest?(page: any, browser: any, context: any): Promise; /** * Called before each step execution * - Script Service: Update step status to IN_PROGRESS in DB * - VS Extension/GitHub: Not used (ignore) * @returns If returns StepModificationResult: * - If skip is true, the step will be skipped and not executed * - If alternativeCommand is provided, it will be executed instead of the original step code */ beforeStepStart?(step: StepInfo, page: any): Promise; /** * Called after test execution completes (success or failure). Receives the live Playwright page and * browser/context so clients can perform final analysis before teardown. */ afterEndTest?(status: 'passed' | 'failed', error?: string, page?: any, siteLearnings?: SiteLearnings, debugStats?: DebugStats, browser?: any, context?: any): Promise; /** * Called before each step to check if execution should be cancelled * - Script Service: Check database for USER_ABORTED status * - VS Extension/GitHub: Not used (always return true to continue) * @returns true to continue execution, false to abort */ shouldContinue?(jobId: string): Promise; /** * TEST FILE EXECUTION CALLBACKS (optional - used for test file orchestration with hooks) * These are suite-level callbacks that track individual test executions within a test file */ /** * Called when a test starts execution (within a test file) * - Script Service: Initialize test execution record in DB with generated jobId * - VS Extension/GitHub: Not used (ignore) * @param testPathway - Test pathway (suite path + test name) identifying the test * @param jobId - Generated jobId for this test execution (UUID) * @param page - Playwright page instance (shared across hooks and tests) * @param browser - Playwright browser instance * @param context - Playwright browser context instance */ onStartTest?(testPathway: TestPathway, jobId: string, page: any, browser: any, context: any): Promise; /** * Called when a test completes execution (within a test file) * - Script Service: Update test execution record in DB with final status * - VS Extension/GitHub: Not used (ignore) * @param testPathway - Test pathway (suite path + test name) identifying the test * @param jobId - Same jobId passed in onStartTest for this test * @param status - Test execution status ('passed' or 'failed') * @param error - Error message if test failed * @param page - Playwright page instance (shared across hooks and tests) * @param browser - Playwright browser instance * @param context - Playwright browser context instance */ onEndTest?(testPathway: TestPathway, jobId: string, status: 'passed' | 'failed', error?: string, page?: any, browser?: any, context?: any): Promise; /** * Called when a scenario annotation completes execution * - Script Service: Accumulate scenario coverage results */ onScenarioCompletion?(scenarioTitle: string, status: ScenarioCoverageStatus): Promise; /** * Called after exploration completes (for all termination reasons) * - Script Service: Parse proto from final decision and invoke recipe callback * - VS Extension/GitHub: Not used (ignore) * @param decision - Final AgentDecision from the exploration * @param memory - JourneyMemory containing extractedData */ afterExplorationComplete?(decision: any, memory: any): Promise | void; } //# sourceMappingURL=progress-reporter.d.ts.map