import { DynamicStructuredTool } from '@langchain/core/tools'; /** * Browser tool names - keep in sync with the browser extension * These tools execute locally in the browser extension, NOT on the server */ export declare const EBrowserTools: { readonly CLICK: "browser_click"; readonly TYPE: "browser_type"; readonly NAVIGATE: "browser_navigate"; readonly SCROLL: "browser_scroll"; readonly EXTRACT: "browser_extract"; readonly HOVER: "browser_hover"; readonly WAIT: "browser_wait"; readonly BACK: "browser_back"; readonly SCREENSHOT: "browser_screenshot"; readonly GET_PAGE_STATE: "browser_get_page_state"; readonly KEYPRESS: "browser_keypress"; readonly SWITCH_TAB: "browser_switch_tab"; }; export type BrowserToolName = (typeof EBrowserTools)[keyof typeof EBrowserTools]; /** * Callback function type for waiting on browser action results * This allows the host server to provide a callback that waits for the extension * to POST results back to the server before returning to the LLM. * * @param action - The browser action (click, type, navigate, etc.) * @param args - Arguments for the action * @param toolCallId - Unique ID for this tool call (from config.toolCall.id) * @returns Promise that resolves with the actual browser result (page state, etc.) */ export type BrowserToolCallback = (action: string, args: Record, toolCallId: string) => Promise; /** * Result returned from browser action execution */ export interface BrowserActionResult { success: boolean; url?: string; title?: string; elementList?: string; error?: string; screenshot?: string; } /** * Check if browser capability is available based on request headers or context * The browser extension sets these headers when connected: * - X-Illuma-Browser-Extension: true * - X-Illuma-Browser-Capable: true */ export declare function hasBrowserCapability(req?: { headers?: Record; }): boolean; /** * Browser tool response interface * This is what the extension returns after executing the action */ export interface BrowserToolResponse { requiresBrowserExecution: true; action: string; args: Record; toolCallId?: string; } /** * Options for creating browser tools */ export interface CreateBrowserToolsOptions { /** * Optional callback that waits for browser action results. * When provided, tools will await this callback to get actual results from the extension. * When not provided, tools return markers immediately (for non-server contexts). */ waitForResult?: BrowserToolCallback; } /** * Create browser tools with optional callback for waiting on results * * When waitForResult callback is provided: * 1. Tool returns marker that triggers extension * 2. Tool then awaits callback to get actual results * 3. Returns real page state to LLM * * When no callback: * 1. Tool returns marker only (for non-server contexts) * * NOTE: These tools use TEXT-BASED element lists, NOT screenshots * Screenshots would be 100K+ tokens each - element lists are ~100 tokens */ export declare function createBrowserTools(options?: CreateBrowserToolsOptions): DynamicStructuredTool[];