/** * Interaction Learner (OWL-002) * * Learns click, type, and select patterns as procedural skills. * Captures robust selectors with fallbacks and replays interactions reliably. * * Progressive optimization: * - First interaction: Record trajectory with multiple selector strategies * - Learn: Build robust selector chains, compute embeddings * - Future interactions: Execute learned patterns with fallback support * * Part of the "Browser Minimizer" philosophy - learns interaction patterns * to make browsing more reliable and predictable over time. */ import type { Page } from 'playwright'; import type { InteractionType, RobustSelector, InteractionAction, InteractionTrajectory, LearnedInteractionPattern, InteractionPatternMatch, RecordInteractionOptions, ExecuteInteractionOptions, InteractionExecutionResult, InteractionLearnerConfig, InteractionLearningEvent } from '../types/interaction-patterns.js'; /** * Interaction Learner for click, type, and select patterns */ export declare class InteractionLearner { private patterns; private trajectoryBuffer; private config; private eventListeners; private isRecording; private currentRecording; constructor(config?: Partial); /** * Start recording interactions for a new trajectory */ startRecording(page: Page, options?: RecordInteractionOptions): Promise; /** * Record a single interaction action */ recordAction(page: Page, type: InteractionType, options?: { selector?: string; value?: string; key?: string; scrollDirection?: 'up' | 'down' | 'left' | 'right'; scrollPixels?: number; delayMs?: number; modifiers?: Array<'ctrl' | 'shift' | 'alt' | 'meta'>; }): Promise; /** * Stop recording and optionally learn from the trajectory */ stopRecording(success: boolean, page?: Page): Promise; /** * Learn a pattern from a successful trajectory */ learnFromTrajectory(trajectory: InteractionTrajectory): Promise; /** * Find matching patterns for a given page context */ findPatterns(page: Page, goal?: string): Promise; /** * Execute a learned pattern */ executePattern(page: Page, patternId: string, options?: ExecuteInteractionOptions): Promise; /** * Build a robust selector with fallbacks */ buildRobustSelector(page: Page, primarySelector: string): Promise; /** * Get all learned patterns */ getPatterns(): LearnedInteractionPattern[]; /** * Get pattern by ID */ getPattern(id: string): LearnedInteractionPattern | undefined; /** * Delete a pattern */ deletePattern(id: string): boolean; /** * Add event listener for learning events */ onLearningEvent(listener: (event: InteractionLearningEvent) => void): void; /** * Remove event listener */ offLearningEvent(listener: (event: InteractionLearningEvent) => void): void; private executeAction; private capturePageContext; private extractElementMetadata; private generateFallbackSelectors; private detectStrategy; private generateEmbedding; private generateContextEmbedding; private normalizeEmbedding; private hashString; private cosineSimilarity; private findSimilarPatterns; private checkPreconditions; private mergePattern; private generatePatternName; private generateDescription; private extractPreconditions; private extractDynamicSelectors; private inferPageType; private determineTier; private evictLeastUsedPattern; private substituteVariables; private generateMatchReason; private emitEvent; /** * Export patterns to JSON */ exportPatterns(): string; /** * Import patterns from JSON */ importPatterns(json: string): number; } //# sourceMappingURL=interaction-learner.d.ts.map