import * as _mlc_ai_web_llm from '@mlc-ai/web-llm'; interface BaseModelConfig { modelName: string; modelType: ModelType; repo: string; pipeline: string; defaultQuantization: string; supportedDTypes?: string[]; contextLength?: number; defaultParams?: Record; quantizations?: string[]; requiredFeatures?: string[]; modelLibrary?: string; metadata?: Record; } type ModelType = 'text-generation' | 'sentiment-analysis' | 'feature-extraction' | 'automatic-speech-recognition' | 'multimodal' | 'text-to-speech'; interface MLCConfig extends BaseModelConfig { engine: 'mlc'; quantized?: boolean; threads?: number; overrides?: Record; } interface TransformersConfig extends BaseModelConfig { engine: 'transformers'; revision?: string; } type ModelConfig = MLCConfig | TransformersConfig; declare class BrowserAI { private engine; currentModel: ModelConfig | null; private mediaRecorder; private audioChunks; private modelIdentifier; private customModels; constructor(); registerCustomModel(modelIdentifier: string, modelConfig: ModelConfig): void; loadModel(modelIdentifier: string, options?: Record): Promise; generateText(prompt: string, options?: Record): Promise; embed(input: string, options?: Record): Promise; transcribeAudio(audio: Blob | Float32Array, options?: Record): Promise; startRecording(): Promise; stopRecording(): Promise; generateResponse(text: string): Promise; textToSpeech(text: string, options?: Record): Promise; generateImage(text: string, options?: Record): Promise; clearModelCache(): Promise; clearSpecificModelCache(modelIdentifier: string): Promise; dispose(): void; } interface MLCLoadModelOptions { useWorker?: boolean; onProgress?: (progress: any) => void; quantization?: string; [key: string]: any; } declare class MLCEngineWrapper { private mlcEngine; private appConfig; private worker; private cacheManager; constructor(); loadModel(modelConfig: ModelConfig, options?: MLCLoadModelOptions): Promise; generateText(input: string | Record[], options?: any): Promise<_mlc_ai_web_llm.ChatCompletion>; embed(input: string, options?: any): Promise; dispose(): void; clearModelCache(): Promise; clearSpecificModel(modelIdentifier: string): Promise; getCacheInfo(): Promise; printCacheInfo(): Promise; private formatBytes; } declare class TransformersEngineWrapper { private transformersPipeline; private modelType; private ttsEngine; private imageProcessor; private multimodalModel; constructor(); loadModel(modelConfig: ModelConfig, options?: any): Promise; generateText(input: string | Array<{ role: string; content: string; }>, options?: any): Promise; extractFeatures(text: string, options?: any): Promise; transcribe(audioInput: Float32Array | Float64Array | string | Blob, options?: any): Promise; textToSpeechStream(text: string, options?: any): Promise<{ stream: AsyncGenerator, any, any>; sampleRate: number; }>; generate(prompt: string, options?: any): Promise; embed(input: string, options?: any): Promise; generateImage(input: { text: string; }, options?: any): Promise; } var mlcModels = { "llama-3.2-1b-instruct": { engine: "mlc", modelName: "Llama-3.2-1B-Instruct", modelType: "text-generation", repo: "mlc-ai/Llama-3.2-1B-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1", "q0f32", "q0f16" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 2048 }, pipeline: "text-generation" }, "llama-3.2-3b-instruct": { engine: "mlc", modelName: "Llama-3.2-3B-Instruct", modelType: "text-generation", repo: "mlc-ai/Llama-3.2-3B-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 2048 }, pipeline: "text-generation", metadata: { context_window_size: 4096, download_size_in_mb: { q4f16_1: 1797, q4f32_1: 1797 }, estimated_vram_in_mb: { q4f16_1: 1797, q4f32_1: 1797 } } }, "hermes-llama-3.2-3b": { engine: "mlc", modelName: "hermes-llama-3.2-3b", modelType: "text-generation", repo: "mlc-ai/Hermes-3-Llama-3.2-3B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 2048 }, pipeline: "text-generation", metadata: { context_window_size: 4096, download_size_in_mb: { q4f16_1: 1797, q4f32_1: 1797 }, estimated_vram_in_mb: { q4f16_1: 1797, q4f32_1: 1797 } } }, "qwen2.5-3b-instruct": { engine: "mlc", modelName: "Qwen2.5-3B-Instruct", modelType: "text-generation", repo: "mlc-ai/Qwen2.5-3B-Instruct-{quantization}-MLC", quantizations: [ "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 4096 }, pipeline: "text-generation" }, "smollm2-135m-instruct": { engine: "mlc", modelName: "SmolLM2-135M-Instruct", modelType: "text-generation", repo: "mlc-ai/SmolLM2-135M-Instruct-{quantization}-MLC", quantizations: [ "q0f32", "q0f16" ], defaultQuantization: "q0f32", defaultParams: { temperature: 0.7, maxTokens: 2048 }, required_features: [ "shader-f16" ], overrides: { context_window_size: 4096 }, pipeline: "text-generation" }, "smollm2-360m-instruct": { engine: "mlc", modelName: "SmolLM2-360M-Instruct", modelType: "text-generation", repo: "mlc-ai/SmolLM2-360M-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1", "q0f32", "q0f16" ], defaultQuantization: "q4f32_1", required_features: [ "shader-f16" ], defaultParams: { temperature: 0.1, maxTokens: 2048 }, pipeline: "text-generation" }, "smollm2-1.7b-instruct": { engine: "mlc", modelName: "SmolLM2-1.7B-Instruct", modelType: "text-generation", repo: "mlc-ai/SmolLM2-1.7B-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation", defaultParams: { temperature: 0.1, maxTokens: 2048 } }, "qwen2.5-0.5b-instruct": { engine: "mlc", modelName: "Qwen2.5-0.5B-Instruct", modelType: "text-generation", repo: "mlc-ai/Qwen2.5-0.5B-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1", "q0f32", "q0f16" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "gemma-2b-it": { engine: "mlc", modelName: "gemma-2b-it", modelType: "text-generation", repo: "mlc-ai/gemma-2b-it-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation", required_features: [ "shader-f16" ] }, "tinyllama-1.1b-chat-v0.4": { engine: "mlc", modelName: "TinyLlama-1.1B-Chat-v0.4", modelType: "text-generation", repo: "mlc-ai/TinyLlama-1.1B-Chat-v0.4-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "phi-3.5-mini-instruct": { engine: "mlc", modelName: "Phi-3.5-mini-instruct", modelType: "text-generation", repo: "mlc-ai/Phi-3.5-mini-instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "qwen2.5-1.5b-instruct": { engine: "mlc", modelName: "Qwen2.5-1.5B-Instruct", modelType: "text-generation", repo: "mlc-ai/Qwen2.5-1.5B-Instruct-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "deepseek-r1-distill-qwen-1.5b": { engine: "mlc", modelName: "DeepSeek-R1-Distill-Qwen-1.5B-MLC", modelType: "text-generation", modelLibrary: "Qwen2-1.5B-Instruct-q4f32_1-ctx4k_cs1k-webgpu.wasm", repo: "sauravpanda/DeepSeek-R1-Distill-Qwen-1.5B-MLC", quantizations: [ "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "deepseek-r1-distill-qwen-7b": { engine: "mlc", modelName: "DeepSeek-R1-Distill-Qwen-7B", modelType: "text-generation", repo: "mlc-ai/DeepSeek-R1-Distill-Qwen-7B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "deepseek-r1-distill-llama-8b": { engine: "mlc", modelName: "DeepSeek-R1-Distill-Llama-8B", modelType: "text-generation", repo: "mlc-ai/DeepSeek-R1-Distill-Llama-8B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", pipeline: "text-generation" }, "snowflake-arctic-embed-m-b4": { engine: "mlc", modelName: "snowflake-arctic-embed-m-b4", modelType: "embedding", repo: "mlc-ai/snowflake-arctic-embed-m-{quantization}-MLC-b4", quantizations: [ "q0f32" ], defaultQuantization: "q0f32", pipeline: "embedding", metadata: { context_window_size: 512, download_size_in_mb: { q0f32: 218 }, estimated_vram_in_mb: { q0f32: 218 } } }, "snowflake-arctic-embed-s-b4": { engine: "mlc", modelName: "snowflake-arctic-embed-s-b4", modelType: "embedding", repo: "mlc-ai/snowflake-arctic-embed-s-{quantization}-MLC-b4", quantizations: [ "q0f32" ], defaultQuantization: "q0f32", pipeline: "embedding", metadata: { context_window_size: 512, download_size_in_mb: { q0f32: 66.4 }, estimated_vram_in_mb: { q0f32: 66.4 } } }, "snowflake-arctic-embed-m-b32": { engine: "mlc", modelName: "snowflake-arctic-embed-m-b32", modelType: "embedding", repo: "mlc-ai/snowflake-arctic-embed-m-{quantization}-MLC-b32", quantizations: [ "q0f32" ], defaultQuantization: "q0f32", pipeline: "embedding", metadata: { context_window_size: 512, download_size_in_mb: { q0f32: 218 }, estimated_vram_in_mb: { q0f32: 218 } } }, "snowflake-arctic-embed-s-b32": { engine: "mlc", modelName: "snowflake-arctic-embed-s-b32", modelType: "embedding", repo: "mlc-ai/snowflake-arctic-embed-s-{quantization}-MLC-b32", quantizations: [ "q0f32" ], defaultQuantization: "q0f32", pipeline: "embedding", metadata: { context_window_size: 512, download_size_in_mb: { q0f32: 66.4 }, estimated_vram_in_mb: { q0f32: 66.4 } } }, "qwen3-0.6b": { engine: "mlc", modelName: "Qwen3-0.6B", modelType: "text-generation", repo: "mlc-ai/Qwen3-0.6B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1", "q0f16", "q0f32" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 4096 }, pipeline: "text-generation", metadata: { context_window_size: 4096, estimated_vram_in_mb: { q4f16_1: 1403.34, q4f32_1: 1924.98, q0f16: 2220.38, q0f32: 3843.25 } } }, "qwen3-1.7b": { engine: "mlc", modelName: "Qwen3-1.7B", modelType: "text-generation", repo: "mlc-ai/Qwen3-1.7B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 4096 }, pipeline: "text-generation", metadata: { context_window_size: 4096, estimated_vram_in_mb: { q4f16_1: 2036.66, q4f32_1: 2635.44 } } }, "qwen3-4b": { engine: "mlc", modelName: "Qwen3-4B", modelType: "text-generation", repo: "mlc-ai/Qwen3-4B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 4096 }, pipeline: "text-generation", metadata: { context_window_size: 4096, estimated_vram_in_mb: { q4f16_1: 3431.59, q4f32_1: 4327.71 } } }, "qwen3-8b": { engine: "mlc", modelName: "Qwen3-8B", modelType: "text-generation", repo: "mlc-ai/Qwen3-8B-{quantization}-MLC", quantizations: [ "q4f16_1", "q4f32_1" ], defaultQuantization: "q4f32_1", defaultParams: { temperature: 0.7, maxTokens: 4096 }, pipeline: "text-generation", metadata: { context_window_size: 4096, estimated_vram_in_mb: { q4f16_1: 5695.78, q4f32_1: 6852.55 } } } }; var transformersModels = { "llama-3.2-1b-instruct": { engine: "transformers", modelName: "Llama-3.2-1b-Instruct", modelType: "text-generation", repo: "Xenova/llama-3.2-1b-instruct", pipeline: "text-generation", defaultParams: { temperature: 0.7, maxLength: 2048 }, defaultQuantization: "q4" }, "whisper-tiny-en": { engine: "transformers", modelName: "whisper-tiny-en", modelType: "automatic-speech-recognition", repo: "onnx-community/whisper-tiny.en", pipeline: "automatic-speech-recognition", defaultQuantization: "q4", quantizations: [ "q4", "fp16", "int4" ] }, "whisper-base-all": { engine: "transformers", modelName: "whisper-base-all", modelType: "automatic-speech-recognition", repo: "onnx-community/whisper-base_timestamped", pipeline: "automatic-speech-recognition", defaultQuantization: "q4", quantizations: [ "q4", "fp16", "int4" ] }, "whisper-small-all": { engine: "transformers", modelName: "whisper-small-all", modelType: "automatic-speech-recognition", repo: "onnx-community/whisper-small_timestamped", pipeline: "automatic-speech-recognition", defaultQuantization: "q4", quantizations: [ "q4", "fp16", "int4" ] }, "kokoro-tts": { engine: "transformers", modelName: "kokoro-tts", modelType: "text-to-speech", repo: "onnx-community/Kokoro-82M-v1.0-ONNX", pipeline: "text-to-speech", defaultQuantization: "fp32", quantizations: [ "q4", "q8", "fp32", "fp16", "q4f16" ], defaultParams: { language: "en" } }, "janus-1.3b": { engine: "transformers", modelName: "Janus-1.3B-ONNX", modelType: "multimodal", repo: "onnx-community/Janus-1.3B-ONNX", pipeline: "multimodal", defaultQuantization: "q4f16", quantizations: [ "q4", "q8", "fp32", "fp16", "q4f16" ], defaultParams: { } } }; interface Storable { id: string; } interface DatabaseConfig { databaseName: string; version?: number; storeName?: string; } interface Database { store(data: T): Promise; get(id: string): Promise; getAll(): Promise; update(data: T): Promise; delete(id: string): Promise; clear(): Promise; close(): void; } type DatabaseType = 'indexeddb' | 'sqlite'; interface DatabaseOptions { type: DatabaseType; config: DatabaseConfig; } declare class DatabaseImpl implements Database { private storage; private vectorStore?; constructor(); initialize(options: DatabaseOptions): Promise; store(data: T): Promise; get(id: string): Promise; getAll(): Promise; update(data: T): Promise; delete(id: string): Promise; clear(): Promise; close(): void; setVectorStore(type: string): void; addVector(id: string, vector: number[]): Promise; searchVector(vector: number[], topK: number): Promise; } declare class HTMLCleaner { private tagsToRemove; private attributesToRemove; /** * Creates an instance of HTMLCleaner. * @param {string[]} [tagsToRemove] - Array of HTML tags to remove from the content * @param {string[]} [attributesToRemove] - Array of HTML attributes to remove from remaining elements */ constructor(tagsToRemove?: string[], attributesToRemove?: string[]); /** * Cleans HTML content by removing specified tags and attributes, returning only text content. * @param {string} html - The HTML content to clean * @returns {string} Cleaned text content with excess whitespace removed */ clean(html: string): string; /** * Extracts text content from semantically important HTML elements. * @param {string} html - The HTML content to process * @returns {string} Concatenated text content from semantic elements with line breaks */ cleanSemantic(html: string): string; /** * Extracts information about interactive elements from HTML content. * @param {string} html - The HTML content to process * @returns {string} Formatted string containing information about interactive elements */ cleanForInteractive(html: string): string; /** * Preserves the hierarchical structure of HTML content, focusing on headings and paragraphs. * @param {string} html - The HTML content to process * @returns {string} Indented text representation of the document's semantic structure */ preserveSemanticHierarchy(html: string): string; /** * Deduplicates the final output to remove repeated paragraphs and sections * @param {string} text - The text to deduplicate * @returns {string} Deduplicated text */ private deduplicateFinalOutput; /** * Calculates similarity between two strings (0-1 scale) * @private * @param {string} str1 - First string to compare * @param {string} str2 - Second string to compare * @returns {number} Similarity score between 0 and 1 */ private calculateSimilarity; /** * Calculates Levenshtein similarity between two strings * @private * @param {string} str1 - First string to compare * @param {string} str2 - Second string to compare * @returns {number} Similarity score between 0 and 1 */ private calculateLevenshteinSimilarity; /** * Applies deduplication to all cleaning methods */ private applyDeduplicationToAllMethods; /** * Creates a structured representation of HTML with element IDs for easy reference, * optimized to reduce noise and focus on meaningful content. * @param {string} html - The HTML content to process * @param {Object} options - Configuration options * @param {boolean} [options.includeCodeBlocks=false] - Whether to include code blocks in the output * @param {boolean} [options.includeScripts=false] - Whether to include script content in the output * @returns {Object} Object containing the structured content, element mapping, and reference mapping */ cleanWithElementIDs(html: string, options?: { includeCodeBlocks?: boolean; includeScripts?: boolean; }): { content: string; elements: Record; }>; references: Record; }; } declare function identifyMainContent(cleanedText: string): string; interface ContentClassification { type: 'article' | 'product' | 'form' | 'navigation' | 'other'; confidence: number; keywords: string[]; entities: string[]; } declare function classifyContent(content: string): ContentClassification; interface ContentSection { type: 'header' | 'profile' | 'main' | 'navigation' | 'interaction' | 'metadata' | 'other'; elements: Element[]; content: string; relevanceScore?: number; confidence: number; } interface SectionAnalysis { sections: ContentSection[]; summary: string; recommendedSections: ContentSection[]; } interface PlatformPatterns { selectors: string[]; classPatterns: RegExp[]; contentRules: { type: ContentSection['type']; patterns: string[]; }[]; } declare class ContentSectionAnalyzer { private platform; private patterns; constructor(); /** * Detect the platform and set appropriate patterns */ private detectPlatform; analyzeSections(rootElement: Element, task?: string): SectionAnalysis; private groupIntoSections; private analyzeSectionRelevance; private calculateRelevanceScore; private evaluateContentQuality; private getTypeRelevanceScore; private evaluateTaskRelevance; private determineSectionType; private inferTypeFromContext; private isNearElementType; private calculateDOMDistance; private getPathToRoot; private areElementsVisuallyClose; private areElementsSemanticallyRelated; private isElementInSections; private generateSectionSummary; private getRecommendedSections; } interface BrowserAgentAction { type: 'click' | 'scroll' | 'navigate' | 'extract' | 'read' | 'wait' | 'think' | 'analyze' | 'classify' | 'summarize'; target?: string; value?: any; taskType?: AgentModelConfig['taskType']; } interface PageMetadata { title: string; url: string; description: string; keywords: string; timestamp: string; } interface RetryConfig { maxRetries: number; delay: number; backoffFactor: number; } declare class ActionError extends Error { action: BrowserAgentAction; constructor(action: BrowserAgentAction, message: string); } interface AgentState { currentUrl: string; lastAction: BrowserAgentAction | null; actionHistory: BrowserAgentAction[]; errors: ActionError[]; } interface AgentModelConfig { taskType: 'navigation' | 'analysis' | 'extraction' | 'decision' | 'conversation'; modelId: string; options?: Record; } interface AgentConfig { models: { [key in AgentModelConfig['taskType']]?: AgentModelConfig; }; defaultModel?: string; } declare class BrowserAgent { private currentUrl; private htmlCleaner; private actionHistory; private retryConfig; private browserAI; private config; constructor(config: AgentConfig); private initializeModels; private getModelForTask; executeAction(action: BrowserAgentAction): Promise; private executeWithRetry; private performAction; private validateAction; private clickElement; private scroll; private navigate; private extractContent; private readPageContent; private wait; private getMainContent; private extractMetadata; private getMetaContent; private makeDecision; private analyzeContent; private classifyContent; private summarizeContent; performTask(goal: string): Promise; getActionHistory(): BrowserAgentAction[]; } /** * DOM Structure Analyzer * A TypeScript library for identifying semantic sections of webpages */ type SectionType = 'navigation' | 'header' | 'footer' | 'sidebar' | 'main-content' | 'article' | 'comments' | 'search' | 'social-links' | 'advertisement' | 'form' | 'unknown'; interface AnalysisResult { element: HTMLElement; type: SectionType; confidence: number; highlightColor?: string; } interface AnalyzerOptions { highlightColors?: Record; minimumConfidence?: number; enabledAnalyzers?: Array; } /** * Main class for DOM Structure Analysis */ declare class DOMStructureAnalyzer { private options; private results; private highlightElements; constructor(options?: Partial); /** * Analyze the DOM to identify sections */ analyze(root?: HTMLElement): AnalysisResult[]; /** * Highlight identified sections on the page */ highlight(): void; /** * Remove all highlights */ removeHighlights(): void; /** * Get section mapping (for use in other applications) */ getSectionMap(): Record; /** * Get potential DOM sections for analysis */ private getPotentialSections; /** * Filter out nested elements to prevent duplicate highlighting */ private filterNestedElements; /** * Check if an element has minimum size to be considered a section */ private hasMinimumSize; } /** * Individual analyzers that assign scores to different section types */ declare const analyzers: { /** * Analyzes semantic HTML tags */ semantic(element: HTMLElement): Record; /** * Analyzes class and ID attributes */ classId(element: HTMLElement): Record; /** * Analyzes element position on the page */ position(element: HTMLElement): Record; /** * Analyzes content characteristics */ content(element: HTMLElement): Record; /** * Analyzes ARIA roles and landmarks */ aria(element: HTMLElement): Record; }; /** * Usage example */ declare function analyzeAndHighlightPage(): void; /** * Browser action helper functions for AI agent interactions * These standalone functions can be used in agent workflows to interact with web pages */ /** * Click on an element matching the provided selector * @param selector CSS selector for the target element * @returns Promise resolving to true if click was successful, false otherwise */ declare function clickElement(selector: string): Promise; /** * Fill a form input with the provided value * @param selector CSS selector for the input element * @param value Value to enter into the input * @returns Promise resolving to true if input was filled successfully, false otherwise */ declare function fillInput(selector: string, value: string): Promise; /** * Select an option from a dropdown * @param selector CSS selector for the select element * @param value Value to select * @returns Promise resolving to true if selection was successful, false otherwise */ declare function selectOption(selector: string, value: string): Promise; /** * Scroll the page in the specified direction and amount * @param options Scroll options including direction and amount * @returns Promise resolving to void */ declare function scrollPage(options: { direction: 'up' | 'down'; amount: number; }): Promise; /** * Navigate to a specified URL * @param url URL to navigate to * @returns Promise resolving to void */ declare function navigateTo(url: string): Promise; /** * Wait for an element to appear in the DOM * @param selector CSS selector for the element to wait for * @param timeout Maximum time to wait in milliseconds * @returns Promise resolving to the element if found, null if timeout */ declare function waitForElement(selector: string, timeout?: number): Promise; /** * Extract text content from an element * @param selector CSS selector for the target element * @returns Promise resolving to the text content or empty string if element not found */ declare function extractText(selector: string): Promise; /** * Check if an element exists in the DOM * @param selector CSS selector for the element to check * @returns Promise resolving to true if element exists, false otherwise */ declare function elementExists(selector: string): Promise; /** * Find all elements matching a selector and return their text content * @param selector CSS selector for the elements to find * @returns Promise resolving to array of text content from matching elements */ declare function findAllElements(selector: string): Promise; /** * Submit a form * @param selector CSS selector for the form element * @returns Promise resolving to true if submission was successful, false otherwise */ declare function submitForm(selector: string): Promise; /** * Focus on an element * @param selector CSS selector for the element to focus * @returns Promise resolving to true if focus was successful, false otherwise */ declare function focusElement(selector: string): Promise; /** * Get attributes of an element * @param selector CSS selector for the target element * @param attributeNames Array of attribute names to retrieve * @returns Promise resolving to object with attribute name-value pairs */ declare function getElementAttributes(selector: string, attributeNames: string[]): Promise>; /** * PDF Parser for extracting text from PDF files * Uses PDF.js library for parsing PDF documents in the browser */ /** * Options for PDF parsing */ interface PDFParseOptions { /** * Maximum number of pages to parse (default: all pages) */ maxPages?: number; /** * Whether to include page numbers in the output (default: false) */ includePageNumbers?: boolean; /** * Custom page separator (default: "\n\n") */ pageSeparator?: string; /** * Debug mode (default: false) */ debug?: boolean; } /** * Result of PDF parsing */ interface PDFParseResult { /** * The extracted text content */ text: string; /** * Number of pages in the document */ numPages: number; /** * Text content by page */ pages: string[]; /** * Any errors encountered during parsing */ errors?: string[]; /** * Debug information about the parsing process */ debugInfo?: string[]; } /** * PDF Parser class for extracting text from PDF files */ declare class PDFParser { /** * Parse a PDF file from a URL * * @param url URL of the PDF file to parse * @param options Parsing options * @returns Promise resolving to the parsed PDF content */ static parseFromUrl(url: string, options?: PDFParseOptions): Promise; /** * Parse a PDF file from an ArrayBuffer * * @param data ArrayBuffer containing the PDF data * @param options Parsing options * @returns Promise resolving to the parsed PDF content */ static parseFromData(data: ArrayBuffer, options?: PDFParseOptions): Promise; /** * Extract text content from a PDF document * * @param pdf PDF document proxy * @param options Parsing options * @returns Promise resolving to the parsed PDF content */ private static extractTextFromPdf; /** * Loads the PDF.js library from a CDN if not already available * @param pdfJsPath Path to the PDF.js library * @param workerPath Path to the PDF.js worker */ static loadPdfJsLibrary(pdfJsPath?: string, workerPath?: string): Promise; /** * Checks if PDF.js is available in the current environment */ static isPdfJsAvailable(): boolean; } /** * Utility function to extract text from a PDF file * * @param source URL or ArrayBuffer of the PDF file * @param options Parsing options * @returns Promise resolving to the parsed PDF content */ declare function extractTextFromPdf(source: string | ArrayBuffer, options?: PDFParseOptions): Promise; /** * Utility function to extract structured text from a PDF file with page information * * @param source URL or ArrayBuffer of the PDF file * @param options Parsing options * @returns Promise resolving to the parsed PDF content with page information */ declare function extractStructuredTextFromPdf(source: string | ArrayBuffer, options?: PDFParseOptions): Promise; /** * Formats PDF text with page numbers and additional metadata * @param result The parsed PDF result * @param options Formatting options * @returns Formatted text representation of the PDF */ declare function pdfToText(result: PDFParseResult, options?: { includePageNumbers?: boolean; includeSummary?: boolean; pagePrefix?: string; pageSuffix?: string; }): string; /** * Processes a PDF file and returns both text and structured data * This is a convenience function that handles buffer copying and multiple extractions * * @param file The PDF file to process * @param options Parsing options * @returns An object containing text, structured data, and debug information */ declare function processPdfFile(file: File, options?: PDFParseOptions & { textFormatting?: { includePageNumbers?: boolean; includeSummary?: boolean; pagePrefix?: string; pageSuffix?: string; }; }): Promise<{ text: string; structured: PDFParseResult; formattedText: string; debugInfo: string[]; }>; /** * CSV Parser for BrowserAI * Provides functionality to parse CSV files in browser environments */ /** * Options for CSV parsing */ interface CSVParseOptions { /** * Whether to include headers in the output (default: true) */ includeHeaders?: boolean; /** * Custom delimiter (default: ",") */ delimiter?: string; /** * Whether to trim whitespace from values (default: true) */ trimValues?: boolean; /** * Whether to skip empty lines (default: true) */ skipEmptyLines?: boolean; /** * Custom quote character (default: '"') */ quoteChar?: string; /** * Debug mode (default: false) */ debug?: boolean; } /** * Result of CSV parsing */ interface CSVParseResult { /** * Headers from the CSV file */ headers: string[]; /** * Data rows as arrays of values */ rows: string[][]; /** * Data as an array of objects (using headers as keys) */ data: Record[]; /** * Total number of rows (excluding headers if present) */ rowCount: number; /** * Total number of columns */ columnCount: number; /** * Any errors encountered during parsing */ errors?: string[]; /** * Debug information */ debugInfo?: string[]; } /** * CSV Parser class */ declare class CSVParser { /** * Parse CSV content from a string * @param content CSV content as string * @param options Parsing options * @returns Parsed CSV data */ static parseFromString(content: string, options?: CSVParseOptions): CSVParseResult; /** * Parse a single CSV line into an array of values */ private static parseLine; /** * Parse CSV from a File object * @param file CSV file * @param options Parsing options * @returns Promise resolving to parsed CSV data */ static parseFromFile(file: File, options?: CSVParseOptions): Promise; } /** * Converts parsed CSV data to a formatted text string * @param csvData The parsed CSV data * @param options Formatting options * @returns Formatted text representation of the CSV data */ declare function csvToText(csvData: CSVParseResult, options?: { includeHeaders?: boolean; columnSeparator?: string; rowSeparator?: string; maxRows?: number; maxColumnWidth?: number; }): string; /** * Extract text representation from a CSV file * @param source CSV content as string or File * @param options Parsing and formatting options * @returns Promise resolving to text representation of the CSV */ declare function extractTextFromCSV(source: string | File, options?: CSVParseOptions & { textFormatting?: { includeHeaders?: boolean; columnSeparator?: string; rowSeparator?: string; maxRows?: number; maxColumnWidth?: number; }; }): Promise; /** * Processes a CSV file and returns both structured data and text representation * @param file The CSV file to process * @param options Parsing and formatting options * @returns Promise resolving to processed CSV data */ declare function processCSVFile(file: File, options?: CSVParseOptions & { textFormatting?: { includeHeaders?: boolean; columnSeparator?: string; rowSeparator?: string; maxRows?: number; maxColumnWidth?: number; }; }): Promise<{ parsed: CSVParseResult; text: string; debugInfo: string[]; }>; /** * Extract data from a CSV file as an array of objects * @param source CSV content as string or File * @param options Parsing options * @returns Promise resolving to array of objects */ declare function extractDataFromCSV(source: string | File, options?: CSVParseOptions): Promise[]>; /** * DOCX Parser for BrowserAI * Provides functionality to parse DOCX files in browser environments */ /** * Options for DOCX parsing */ interface DOCXParseOptions { /** * Whether to extract images (default: false) */ extractImages?: boolean; /** * Whether to preserve styles (default: false) */ preserveStyles?: boolean; /** * Whether to include headers and footers (default: true) */ includeHeadersFooters?: boolean; /** * Whether to extract document properties (default: false) */ extractProperties?: boolean; /** * Debug mode (default: false) */ debug?: boolean; } /** * Result of DOCX parsing */ interface DOCXParseResult { /** * The extracted text content */ text: string; /** * HTML representation of the document */ html: string; /** * Document properties (if extracted) */ properties?: Record; /** * Document structure information */ structure?: { paragraphs: number; tables: number; images: number; sections: number; }; /** * Any errors encountered during parsing */ errors?: string[]; /** * Debug information */ debugInfo?: string[]; } /** * DOCX Parser class */ declare class DOCXParser { /** * Parse DOCX from a File object * @param file DOCX file * @param options Parsing options * @returns Promise resolving to parsed DOCX data */ static parseFromFile(file: File, options?: DOCXParseOptions): Promise; /** * Extract text from HTML * @param html HTML content * @returns Plain text */ private static extractTextFromHtml; /** * Extract document structure information * @param html HTML content * @returns Structure information */ private static extractStructure; /** * Extract document properties * @param arrayBuffer Document as ArrayBuffer * @returns Document properties */ private static extractProperties; /** * Check if the file is a valid DOCX file * @param file File to check * @returns True if the file is a valid DOCX file */ static isValidDocxFile(file: File): boolean; /** * Check if the file is a valid DOC file * @param file File to check * @returns True if the file is a valid DOC file */ static isValidDocFile(file: File): boolean; } /** * Formats DOCX content for AI consumption * @param result The parsed DOCX result * @param options Formatting options * @returns Formatted text representation of the DOCX */ declare function docxToText(result: DOCXParseResult, options?: { includeSummary?: boolean; includeStructure?: boolean; includeProperties?: boolean; }): string; /** * Extract text from a DOCX file * @param file DOCX file * @param options Parsing options * @returns Promise resolving to extracted text */ declare function extractTextFromDOCX(file: File, options?: DOCXParseOptions): Promise; /** * Processes a DOCX file and returns both structured data and text representation * @param file The DOCX file to process * @param options Parsing and formatting options * @returns Promise resolving to processed DOCX data */ declare function processDOCXFile(file: File, options?: DOCXParseOptions & { textFormatting?: { includeSummary?: boolean; includeStructure?: boolean; includeProperties?: boolean; }; }): Promise<{ parsed: DOCXParseResult; text: string; formattedText: string; debugInfo: string[]; }>; /** * Options for image parsing */ interface ImageParseOptions { /** * Language for OCR (default: 'eng') */ language?: string; /** * Whether to include confidence scores (default: false) */ includeConfidence?: boolean; /** * Debug mode (default: false) */ debug?: boolean; } /** * Result of image parsing */ interface ImageParseResult { /** * The extracted text content */ text: string; /** * Image properties */ properties?: { width: number; height: number; format: string; size: number; }; /** * OCR confidence score (0-100) */ confidence?: number; /** * Any errors encountered during parsing */ errors?: string[]; /** * Debug information */ debugInfo?: string[]; /** * Whether the image contains meaningful text */ hasText?: boolean; } /** * Parser for image files (JPEG, PNG) */ declare class ImageParser { /** * Parse text from an image file */ static parseFromFile(file: File, options?: ImageParseOptions): Promise; /** * Extract properties from an image file */ private static extractImageProperties; /** * Check if a file is a valid image file */ static isValidImageFile(file: File): boolean; /** * Clean OCR text by removing non-text symbols and noise * @param text Raw OCR text * @returns Cleaned text */ private static cleanOcrText; /** * Determines if extracted text is meaningful or just OCR noise * @param text The extracted text * @param confidence OCR confidence score * @returns Whether the text is meaningful */ private static hasActualText; } /** * Formats image OCR results for AI consumption */ declare function imageToText(result: ImageParseResult, options?: { includeSummary?: boolean; }): string; /** * Extract text from an image file */ declare function extractTextFromImage(file: File, options?: ImageParseOptions): Promise; /** * Process an image file and return various representations */ declare function processImageFile(file: File, options?: ImageParseOptions & { textFormatting?: { includeSummary?: boolean; }; }): Promise<{ parsed: ImageParseResult; text: string; formattedText: string; debugInfo: string[]; }>; export { ActionError, type AgentConfig, type AgentModelConfig, type AgentState, type AnalysisResult, type AnalyzerOptions, BrowserAI, BrowserAgent, type BrowserAgentAction, type CSVParseOptions, type CSVParseResult, CSVParser, type ContentClassification, type ContentSection, ContentSectionAnalyzer, type DOCXParseOptions, type DOCXParseResult, DOCXParser, DOMStructureAnalyzer, DatabaseImpl, HTMLCleaner, type ImageParseOptions, type ImageParseResult, ImageParser, MLCEngineWrapper, type PDFParseOptions, type PDFParseResult, PDFParser, type PageMetadata, type PlatformPatterns, type RetryConfig, type SectionAnalysis, type SectionType, TransformersEngineWrapper, analyzeAndHighlightPage, classifyContent, clickElement, csvToText, docxToText, elementExists, extractDataFromCSV, extractStructuredTextFromPdf, extractText, extractTextFromCSV, extractTextFromDOCX, extractTextFromImage, extractTextFromPdf, fillInput, findAllElements, focusElement, getElementAttributes, identifyMainContent, imageToText, mlcModels, navigateTo, pdfToText, processCSVFile, processDOCXFile, processImageFile, processPdfFile, scrollPage, selectOption, submitForm, transformersModels, waitForElement };