import { z } from 'zod'; import { ActionStep, PageState } from '../types'; /** * Represents the execution result of a step */ export interface StepExecutionResult { step: ActionStep; success: boolean; error?: string; timestamp: Date; pageStateBefore?: PageState; pageStateAfter?: PageState; elementFound?: boolean; selectorUsed?: string; valueEntered?: string; } /** * Contextual information about previous steps for AI decision making */ export interface StepContext { previousSteps: StepExecutionResult[]; currentStepIndex: number; totalSteps: number; sessionStartTime: Date; formElements?: FormElementContext[]; pageHistory: PageState[]; } /** * Information about form elements discovered during execution */ export interface FormElementContext { selector: string; type: string; name?: string; value?: string; label?: string; required?: boolean; filled?: boolean; stepIndex?: number; } /** * LangChain schema for step context analysis */ export declare const StepContextAnalysisSchema: z.ZodObject<{ recommendations: z.ZodArray; description: z.ZodString; confidence: z.ZodNumber; }, "strip", z.ZodTypeAny, { type: "SELECTOR_IMPROVEMENT" | "VALUE_ADJUSTMENT" | "TIMING_DELAY" | "ALTERNATIVE_APPROACH"; description: string; confidence: number; }, { type: "SELECTOR_IMPROVEMENT" | "VALUE_ADJUSTMENT" | "TIMING_DELAY" | "ALTERNATIVE_APPROACH"; description: string; confidence: number; }>, "many">; contextualInsights: z.ZodObject<{ elementsDiscovered: z.ZodArray; patternsObserved: z.ZodArray; potentialIssues: z.ZodArray; }, "strip", z.ZodTypeAny, { elementsDiscovered: string[]; patternsObserved: string[]; potentialIssues: string[]; }, { elementsDiscovered: string[]; patternsObserved: string[]; potentialIssues: string[]; }>; nextStepGuidance: z.ZodObject<{ suggestedSelector: z.ZodOptional; suggestedValue: z.ZodOptional; waitConditions: z.ZodOptional>; alternativeActions: z.ZodOptional>; }, "strip", z.ZodTypeAny, { suggestedSelector?: string | undefined; suggestedValue?: string | undefined; waitConditions?: string[] | undefined; alternativeActions?: string[] | undefined; }, { suggestedSelector?: string | undefined; suggestedValue?: string | undefined; waitConditions?: string[] | undefined; alternativeActions?: string[] | undefined; }>; }, "strip", z.ZodTypeAny, { recommendations: { type: "SELECTOR_IMPROVEMENT" | "VALUE_ADJUSTMENT" | "TIMING_DELAY" | "ALTERNATIVE_APPROACH"; description: string; confidence: number; }[]; contextualInsights: { elementsDiscovered: string[]; patternsObserved: string[]; potentialIssues: string[]; }; nextStepGuidance: { suggestedSelector?: string | undefined; suggestedValue?: string | undefined; waitConditions?: string[] | undefined; alternativeActions?: string[] | undefined; }; }, { recommendations: { type: "SELECTOR_IMPROVEMENT" | "VALUE_ADJUSTMENT" | "TIMING_DELAY" | "ALTERNATIVE_APPROACH"; description: string; confidence: number; }[]; contextualInsights: { elementsDiscovered: string[]; patternsObserved: string[]; potentialIssues: string[]; }; nextStepGuidance: { suggestedSelector?: string | undefined; suggestedValue?: string | undefined; waitConditions?: string[] | undefined; alternativeActions?: string[] | undefined; }; }>; export type StepContextAnalysis = z.infer; /** * Manages the context and history of executed steps for better AI decision making */ export declare class StepContextManager { private stepHistory; private formElements; private pageHistory; private sessionStartTime; /** * Add a completed step to the context */ addStepResult(result: StepExecutionResult): void; /** * Get the current context for a step */ getCurrentContext(currentStepIndex: number, totalSteps: number): StepContext; /** * Get the last N steps for context */ getRecentSteps(count?: number): StepExecutionResult[]; /** * Get form elements discovered so far */ getKnownFormElements(): FormElementContext[]; /** * Get successful selectors that have been used */ getSuccessfulSelectors(): string[]; /** * Get patterns from previous interactions */ getInteractionPatterns(): { selector: string; action: string; success: boolean; }[]; /** * Clear the context (for new automation sessions) */ reset(): void; /** * Export context for AI analysis */ exportContextSummary(): string; private isFormInteraction; private updateFormElementContext; private inferElementType; private extractNameFromSelector; }