/**
 * Browser Automation Tool
 *
 * Provides headless browser capabilities using Playwright for:
 * - Web page navigation and interaction
 * - Form filling and button clicking
 * - Screenshot capture
 * - JavaScript execution
 * - DOM element selection
 *
 * Playwright is loaded as an optional dependency - if not installed,
 * the tool will provide installation instructions.
 */
import { EventEmitter } from 'events';
import type { ToolResult } from '../types/index.js';
/**
 * Browser action types supported by the tool
 */
export type BrowserAction = 'navigate' | 'click' | 'fill' | 'screenshot' | 'getText' | 'getHtml' | 'evaluate' | 'waitForSelector' | 'getLinks' | 'getForms' | 'submit' | 'select' | 'hover' | 'scroll' | 'goBack' | 'goForward' | 'reload' | 'close';
/**
 * Parameters for browser tool execution
 */
export interface BrowserParams {
    /** The action to perform */
    action: BrowserAction;
    /** URL to navigate to (for navigate action) */
    url?: string;
    /** CSS selector for element operations */
    selector?: string;
    /** Value for fill/select operations */
    value?: string;
    /** JavaScript code for evaluate action */
    script?: string;
    /** Timeout in milliseconds */
    timeout?: number;
    /** Screenshot options */
    screenshotOptions?: {
        fullPage?: boolean;
        path?: string;
        type?: 'png' | 'jpeg';
        quality?: number;
    };
    /** Scroll options */
    scrollOptions?: {
        x?: number;
        y?: number;
        behavior?: 'auto' | 'smooth';
    };
}
/**
 * Browser configuration
 */
export interface BrowserConfig {
    /** Run in headless mode */
    headless: boolean;
    /** Viewport dimensions */
    viewport: {
        width: number;
        height: number;
    };
    /** Custom user agent */
    userAgent?: string;
    /** Default timeout for operations */
    timeout: number;
    /** Directory for screenshots */
    screenshotDir: string;
    /** Browser type to use */
    browserType: 'chromium' | 'firefox' | 'webkit';
    /** Block requests to these patterns */
    blockedUrls?: string[];
    /** Enable JavaScript */
    javaScriptEnabled: boolean;
}
/**
 * Page information returned by browser operations
 */
export interface PageInfo {
    url: string;
    title: string;
    html?: string;
    text?: string;
    screenshot?: string;
}
/**
 * Link information extracted from page
 */
export interface LinkInfo {
    href: string;
    text: string;
    title?: string;
}
/**
 * Form information extracted from page
 */
export interface FormInfo {
    action: string;
    method: string;
    id?: string;
    name?: string;
    fields: Array<{
        name: string;
        type: string;
        id?: string;
        placeholder?: string;
        required?: boolean;
    }>;
}
/**
 * BrowserTool provides headless browser automation capabilities
 * using Playwright for web page interaction, testing, and scraping.
 */
export declare class BrowserTool extends EventEmitter {
    name: string;
    description: string;
    dangerLevel: 'safe' | 'low' | 'medium' | 'high';
    inputSchema: {
        type: "object";
        properties: {
            action: {
                type: string;
                enum: string[];
                description: string;
            };
            url: {
                type: string;
                description: string;
            };
            selector: {
                type: string;
                description: string;
            };
            value: {
                type: string;
                description: string;
            };
            script: {
                type: string;
                description: string;
            };
            timeout: {
                type: string;
                description: string;
            };
            screenshotOptions: {
                type: string;
                description: string;
            };
        };
        required: string[];
    };
    private config;
    private playwright;
    private browser;
    private context;
    private page;
    private isPlaywrightAvailable;
    private currentUrl;
    constructor(config?: Partial<BrowserConfig>);
    /**
     * Inject playwright module for testing purposes
     * @internal
     */
    _injectPlaywright(playwright: unknown): void;
    /**
     * Ensure screenshot directory exists
     */
    private ensureScreenshotDir;
    /**
     * Check if Playwright is available
     */
    private checkPlaywrightAvailable;
    /**
     * Get installation instructions for Playwright
     */
    private getInstallInstructions;
    /**
     * Check if URL is blocked (internal/local)
     */
    private isBlockedUrl;
    /**
     * Initialize browser instance
     */
    private initBrowser;
    /**
     * Execute browser action
     */
    execute(params: BrowserParams): Promise<ToolResult>;
    /**
     * Navigate to URL
     */
    private navigate;
    /**
     * Click on element
     */
    private click;
    /**
     * Fill input field
     */
    private fill;
    /**
     * Take screenshot
     */
    private screenshot;
    /**
     * Get text content
     */
    private getText;
    /**
     * Get HTML content
     */
    private getHtml;
    /**
     * Evaluate JavaScript
     */
    private evaluate;
    /**
     * Wait for selector
     */
    private waitForSelector;
    /**
     * Get all links on page
     */
    private getLinks;
    /**
     * Get all forms on page
     */
    private getForms;
    /**
     * Submit form
     */
    private submit;
    /**
     * Select option from dropdown
     */
    private select;
    /**
     * Hover over element
     */
    private hover;
    /**
     * Scroll page
     */
    private scroll;
    /**
     * Go back in history
     */
    private goBack;
    /**
     * Go forward in history
     */
    private goForward;
    /**
     * Reload page
     */
    private reload;
    /**
     * Close browser
     */
    close(): Promise<ToolResult>;
    /**
     * Get current page info
     */
    getPageInfo(): Promise<PageInfo | null>;
    /**
     * Check if browser is initialized
     */
    isInitialized(): boolean;
    /**
     * Update configuration
     */
    updateConfig(config: Partial<BrowserConfig>): void;
    /**
     * Get current configuration
     */
    getConfig(): BrowserConfig;
    /**
     * Dispose and cleanup resources
     */
    dispose(): Promise<void>;
}
/**
 * Get the singleton BrowserTool instance
 */
export declare function getBrowserTool(config?: Partial<BrowserConfig>): BrowserTool;
/**
 * Reset the singleton instance (for testing)
 */
export declare function resetBrowserTool(): Promise<void>;
