import { Memory } from '@mastra/memory'; import { EventEmitter } from 'events'; import { LaunchOptions, Page, BrowserContext as BrowserContext$1, ElementHandle, Browser as Browser$1 } from 'playwright'; import { z } from 'zod'; import { pino } from 'pino'; import { ToolCall, ToolResult, LanguageModel } from 'ai'; import * as _mastra_core_workflows from '@mastra/core/workflows'; import { Step } from '@mastra/core/workflows'; import { Agent } from '@mastra/core/agent'; import * as _mastra_core_tools from '@mastra/core/tools'; import { Tool } from '@mastra/core/tools'; import SteelSDK, { ClientOptions } from 'steel-sdk'; /** * Type definitions for the browser module */ /** * Browser class options */ type BrowserClass = "chromium" | "firefox" | "webkit"; /** * Proxy settings for browser connections */ type ProxySettings = LaunchOptions["proxy"]; /** * Zod schema for browser context configuration */ declare const BrowserContextConfigSchema: z.ZodObject<{ /** * Whether to record videos of browser sessions */ recordVideo: z.ZodOptional; /** * Directory to save recorded videos */ recordVideosDir: z.ZodOptional; /** * Whether to record HAR files (HTTP Archive) */ recordHar: z.ZodOptional; /** * Path to save HAR files */ recordHarPath: z.ZodOptional; /** * Whether to ignore HTTPS errors */ ignoreHttpsErrors: z.ZodOptional; /** * Directory to save downloads */ downloadsPath: z.ZodOptional; /** * Custom user agent string */ userAgent: z.ZodOptional; /** * Viewport dimensions */ viewport: z.ZodOptional>; /** * Options for handling downloads */ acceptDownloads: z.ZodOptional; /** * Whether to bypass Content Security Policy */ bypassCSP: z.ZodOptional; /** * Allowed domains for URL validation */ allowedDomains: z.ZodOptional>; }, "strip", z.ZodTypeAny, { recordVideo?: boolean | undefined; recordVideosDir?: string | undefined; recordHar?: boolean | undefined; recordHarPath?: string | undefined; ignoreHttpsErrors?: boolean | undefined; downloadsPath?: string | undefined; userAgent?: string | undefined; viewport?: { width: number; height: number; } | undefined; acceptDownloads?: boolean | undefined; bypassCSP?: boolean | undefined; allowedDomains?: string[] | undefined; }, { recordVideo?: boolean | undefined; recordVideosDir?: string | undefined; recordHar?: boolean | undefined; recordHarPath?: string | undefined; ignoreHttpsErrors?: boolean | undefined; downloadsPath?: string | undefined; userAgent?: string | undefined; viewport?: { width: number; height: number; } | undefined; acceptDownloads?: boolean | undefined; bypassCSP?: boolean | undefined; allowedDomains?: string[] | undefined; }>; /** * Configuration for browser context */ type BrowserContextConfig = z.infer; /** * Configuration for Browser initialization */ interface BrowserConfig { /** * WebSocket URL to connect to a browser instance */ wssUrl?: string; /** * CDP URL to connect to a browser instance */ cdpUrl?: string; /** * Browser class to use (chromium, firefox, webkit) */ browserClass?: BrowserClass; /** * Path to browser binary */ browserBinaryPath?: string; /** * Extra arguments to pass to the browser */ extraBrowserArgs?: string[]; /** * Whether to run browser in headless mode */ headless?: boolean; /** * Whether to disable browser security features */ disableSecurity?: boolean; /** * Enable deterministic rendering */ deterministicRendering?: boolean; /** * Keep the browser alive after completion */ keepAlive?: boolean; /** * Proxy settings for the browser */ proxy?: ProxySettings; /** * Default context configuration */ newContextConfig?: BrowserContextConfig; } /** * Tab information */ interface TabInfo { id: string; url: string; title: string; active: boolean; } /** * Browser state */ interface BrowserState { url: string; title: string; tabs: TabInfo[]; screenshot?: string; elementTree: unknown; selectorMap: Record; html?: string; } interface CoordinateSet { x: number; y: number; width: number; height: number; } interface ViewportInfo { width: number; height: number; scrollX: number; scrollY: number; } type HashedDomElement = string; declare abstract class DOMBaseNode$1 { isVisible: boolean; parent: DOMElementNode$1 | null; constructor(isVisible: boolean, parent?: DOMElementNode$1 | null); abstract toJSON(): Record; } declare class DOMElementNode$1 extends DOMBaseNode$1 { tagName: string; xpath: string; attributes: Record; children: DOMBaseNode$1[]; isInteractive: boolean; isTopElement: boolean; isInViewport: boolean; shadowRoot: boolean; highlightIndex: number | null; viewportCoordinates: CoordinateSet | null; pageCoordinates: CoordinateSet | null; viewportInfo: ViewportInfo | null; isNew: boolean | null; private _hash?; constructor(tagName: string, xpath: string, attributes: Record, children: DOMBaseNode$1[], isVisible: boolean, isInteractive?: boolean, isTopElement?: boolean, isInViewport?: boolean, shadowRoot?: boolean, highlightIndex?: number | null, viewportCoordinates?: CoordinateSet | null, pageCoordinates?: CoordinateSet | null, viewportInfo?: ViewportInfo | null, isNew?: boolean | null); get hash(): HashedDomElement; getAllText(maxDepth?: number): string; getAllTextTillNextClickableElement(maxDepth?: number): string; clickableElementsToString(includeAttributes?: string[] | null): string; findByTag(tagName: string): DOMElementNode$1[]; findByXPath(xpath: string): DOMElementNode$1[]; findByAttribute(name: string, value: string): DOMElementNode$1[]; toJSON(): Record; } interface SelectorMap$1 { [key: number]: DOMElementNode$1; } /** * DOM service for interacting with the page's DOM */ declare global { interface Window { buildDomTree: (args: { doHighlightElements: boolean; focusHighlightIndex: number; viewportExpansion: number; debugMode: boolean; }) => DOMEvalResult; } } interface BrowserViewport { width: number; height: number; } interface BrowserScroll { x: number; y: number; } interface FormattedTabInfo { id: string; title: string; isActive: boolean; } interface InteractiveElementInfo { key: string; tagName: string; text: string; xpath: string; } interface FormattedBrowserState { url: string; title: string; viewport: BrowserViewport; scroll: BrowserScroll; tabs: FormattedTabInfo[]; interactiveElements: InteractiveElementInfo[]; } /** * DOM data from JavaScript evaluation */ interface DOMEvalResult { map: Record; rootId: string; perfMetrics?: Record; } /** * Node data from DOM evaluation */ interface DOMNodeData { type?: string; text?: string; tagName?: string; xpath?: string; attributes?: Record; isVisible?: boolean; isInteractive?: boolean; isTopElement?: boolean; isInViewport?: boolean; highlightIndex?: number; shadowRoot?: boolean; children?: (string | number)[]; viewport?: { width: number; height: number; }; } /** * Service for accessing and manipulating the DOM */ declare class DomService { private page; private xpathCache; private jsCode; /** * Create a new DOM service * * @param page - Playwright page to operate on */ constructor(page: Page); /** * Gathers comprehensive browser state including DOM info, formatted for use cases like state messages. * * @param browserContextInstance - BrowserContext instance to use for state gathering * @returns An object containing formatted browser state information. */ getFormattedBrowserState(browserContextInstance: BrowserContext): Promise; /** * Get clickable elements from the page * * @param highlightElements - Whether to highlight elements in the page * @param focusElement - Index of the element to focus * @param viewportExpansion - How much to expand the viewport * @returns DOM state with element tree and selector map */ getClickableElements(highlightElements?: boolean, focusElement?: number, viewportExpansion?: number): Promise<{ elementTree: DOMElementNode$1; selectorMap: SelectorMap$1; }>; /** * Clean up any existing highlight elements * This prevents accumulation of highlight elements when buildDomTree is called multiple times */ private cleanupHighlights; /** * Get URLs of cross-origin iframes in the page * * @returns List of cross-origin iframe URLs */ getCrossOriginIframes(): Promise; /** * Build DOM tree from the page * * @param highlightElements - Whether to highlight elements * @param focusElement - Element to focus * @param viewportExpansion - How much to expand viewport * @returns Element tree and selector map */ private buildDomTree; /** * Construct a DOM tree from evaluation results * * @param evalPage - Page evaluation results * @returns Element tree and selector map */ private constructDomTree; /** * Add methods to element nodes * * @param node - Element node to add methods to */ private addElementNodeMethods; /** * Parse a node from the DOM data * * @param nodeData - Node data from JavaScript * @returns Parsed node and its children IDs */ private parseNode; } /** * Type definitions for DOM-related functionality */ /** * Base node interface for all DOM nodes */ interface DOMBaseNode { /** * Whether the node is visible in the viewport */ isVisible: boolean; /** * Parent node (null for root node) */ parent: DOMElementNode | null; } /** * Element node in the DOM tree */ interface DOMElementNode extends DOMBaseNode { /** * HTML tag name */ tagName: string; /** * XPath to the element */ xpath: string; /** * Element attributes */ attributes: Record; /** * Child nodes (elements and text) */ children: DOMBaseNode[]; /** * Whether the element is interactive (clickable, focusable, etc.) */ isInteractive?: boolean; /** * Whether the element is a top-level element */ isTopElement?: boolean; /** * Whether the element is in the viewport */ isInViewport?: boolean; /** * Index for highlighting in UI (used for interactive elements) */ highlightIndex?: number; /** * Whether the element has a shadow root */ shadowRoot?: boolean; /** * Get all text within this element and its children */ getAllText(maxDepth?: number): string; /** * Get text until the next clickable element */ getAllTextTillNextClickableElement(maxDepth?: number): string; /** * Find child nodes by tag name */ findByTag(tagName: string): DOMElementNode[]; /** * Find child nodes by XPath */ findByXPath(xpath: string): DOMElementNode[]; /** * Find child nodes by attribute */ findByAttribute(name: string, value: string): DOMElementNode[]; } /** * Text node in the DOM tree */ interface DOMTextNode extends DOMBaseNode { /** * Text content */ text: string; } /** * Map of selector indices to DOM elements */ type SelectorMap = Record; /** * Full DOM state including the element tree and selector map */ interface DOMState { /** * Root of the DOM element tree */ elementTree: DOMElementNode; /** * Map of selector indices to DOM elements */ selectorMap: SelectorMap; } /** * DOM history element for tracking interactions */ interface DOMHistoryElement { /** * Element index */ index: number; /** * XPath to the element */ xpath: string; /** * Tag name */ tagName: string; /** * Element text content */ text: string; } /** * Browser context for managing browser sessions and pages */ /** * Browser context that provides session management and high-level browser actions */ declare class BrowserContext { private config; private browser; private context; private currentPage; private domService; private selectorMap; private cached_state_clickable_elements_hashes; private allowedDomains; /** * Create a new browser context * * @param config - Browser context configuration * @param browser - Parent browser instance */ constructor({ config, browser }: { config: BrowserContextConfig; browser: Browser; }); /** * Initialize the browser context * * @returns Initialized browser context */ private init; /** * Get the current browser context * * @returns The browser context */ getContext(): Promise; /** * Get the current active page * * @returns The current page */ getCurrentPage(): Promise; /** * Get the DOM service for the current page * * @returns DOM service instance */ getDomService(): Promise; /** * Get formatted browser state using DomService * * @returns Formatted browser state */ getFormattedBrowserState(): Promise; /** * Get the current state of the browser * * @param captureScreenshot - Whether to capture a screenshot * @param cache_clickable_elements_hashes - Whether to cache clickable elements hashes * @returns Current browser state */ getState(captureScreenshot?: boolean, cache_clickable_elements_hashes?: boolean): Promise; /** * Get the current selector map * * @returns Selector map with element indices */ getSelectorMap(): Promise>; /** * Get a DOM element by its index * * @param index - Element index in the selector map * @returns DOM element node */ getDomElementByIndex(index: number): Promise; /** * Check if an element is a file uploader * * @param element - DOM element to check * @returns True if the element is a file input */ isFileUploader(element: DOMElementNode): Promise; /** * Advanced element location that handles iframes and parent traversal * * @param element - DOM element to locate * @returns Element handle or null if not found */ getLocateElement(element: DOMElementNode): Promise; /** * Converts a simple XPath to CSS selector when possible * * @param xpath - XPath to convert * @returns CSS selector or empty string if conversion not possible */ private convertSimpleXPathToCssSelector; /** * Generate an enhanced CSS selector for an element that's likely to be unique * * @param element - DOM element to create selector for * @param includeDynamicAttributes - Whether to include dynamic attributes in the selector * @returns CSS selector */ private enhancedCssSelectorForElement; /** * Input text into a DOM element * * @param element - DOM element to input text into * @param text - Text to input */ inputTextElementNode(element: DOMElementNode, text: string): Promise; /** * Click on a DOM element * * @param element - DOM element to click * @returns Path to downloaded file if click resulted in download, undefined otherwise */ clickElementNode(element: DOMElementNode): Promise; /** * Locate an element by CSS selector * * @param selector - CSS selector * @returns Element handle or null if not found */ getLocateElementByCssSelector(selector: string): Promise; /** * Locate an element by XPath * * @param xpath - XPath selector * @returns Element handle or null if not found */ getLocateElementByXpath(xpath: string): Promise; /** * Navigate back in browser history */ goBack(): Promise; /** * Wait for an element to be visible * * @param selector - CSS selector * @param timeout - Timeout in milliseconds */ waitForElement(selector: string, timeout?: number): Promise; /** * Switch to a specific tab * * @param index - Tab index (-1 for last tab) */ switchToTab(index: number): Promise; /** * Close the context and clean up resources */ close(): Promise; /** * Check if a URL is allowed based on domain restrictions * * @param url - URL to check * @returns True if the URL is allowed, false otherwise */ private isUrlAllowed; /** * Check and handle navigation to ensure URL is allowed * * @param page - Current page * @throws URLNotAllowedError if the URL is not allowed */ checkAndHandleNavigation(page: Page): Promise; /** * Navigate to a URL * * @param url - URL to navigate to * @throws URLNotAllowedError if the URL is not allowed */ navigate(url: string): Promise; } /** * Playwright browser wrapper with enhanced functionality */ /** * This is a persistent browser factory that can spawn multiple browser contexts. * It is recommended to use only one instance of Browser per your application (RAM usage will grow otherwise). */ declare class Browser { private config; private playwright; private playwrightBrowser; private chromeSubprocess; /** * Create a new Browser instance * * @param config - Browser configuration */ constructor(config?: BrowserConfig); /** * Create a new browser context * * @param config - Browser context configuration * @returns A new BrowserContext instance */ newContext(config?: BrowserContextConfig): Promise; /** * Get or initialize the Playwright browser instance * * @returns The Playwright browser instance */ getPlaywrightBrowser(): Promise; /** * Initialize the browser session * * @returns The initialized Playwright browser */ private init; /** * Set up a remote CDP browser connection * * @param browserType - Browser type * @returns Connected browser instance */ private setupRemoteCdpBrowser; /** * Set up a remote WSS browser connection * * @param playwright - Playwright instance * @returns Connected browser instance */ private setupRemoteWssBrowser; /** * Set up a browser instance using a user-provided browser binary * * @param playwright - Playwright instance * @returns Connected browser instance */ private setupUserProvidedBrowser; /** * Set up a built-in browser instance * * @param playwright - Playwright instance * @returns Browser instance */ private setupBuiltinBrowser; /** * Setup the browser based on configuration * * @param playwright - Playwright instance * @returns Configured browser instance */ private setupBrowser; /** * Close the browser instance and clean up resources */ close(): Promise; } /** * Logging configuration for the Beam library */ type LogLevel = pino.LevelWithSilent | "success"; /** * Token usage information */ interface TokenUsage { promptTokens: number; completionTokens: number; totalTokens: number; } /** * Metadata about step execution */ interface StepMetadata { startTime: number; endTime: number; durationSeconds: number; inputTokens?: number; outputTokens?: number; tokenUsage?: TokenUsage; model?: string; provider?: string; } /** * Individual history item for a single step */ interface HistoryItem { browserState: BrowserState; toolCalls: ToolCall>[]; toolResults: ToolResult, unknown>[]; status?: "continue" | "done"; metadata?: StepMetadata; } /** * Tracks the history of agent actions */ declare class AgentHistory { private history; private currentStep; /** * Add a new history item for the current step */ addHistoryItem(item: HistoryItem): void; /** * Create a new history item for the current step */ createHistoryItem(browserState: BrowserState): HistoryItem; /** * Finalize the current history item */ finalizeCurrentItem(status: "continue" | "done"): void; /** * Add token usage data to the current history item */ addTokenUsage(tokenUsage: TokenUsage, model?: string, provider?: string): void; /** * Add a tool call to the current history item */ addToolCall(toolCall: ToolCall>): void; /** * Add a tool result to the current history item */ addToolResult(toolResult: ToolResult, unknown>): void; /** * Get all history items */ getHistory(): HistoryItem[]; /** * Check if the agent is done */ isDone(): boolean; /** * Get total duration in seconds */ getTotalDurationSeconds(): number; /** * Get total token usage */ getTotalTokenUsage(): TokenUsage; /** * Get token usage by model */ getTokenUsageByModel(): Record; /** * Get all tool calls by name */ getToolCallsByName(name: string): ToolCall>[]; /** * Get the current step number */ getCurrentStep(): number; /** * Serialize the history to a JSON object */ toJSON(): Record; /** * Save history to a JSON file * @param filePath The path to save the history file to */ saveToFile(filePath: string): void; /** * Load history from a JSON file * @param filePath The path to load the history file from * @returns A new AgentHistory instance with the loaded data */ static loadFromFile(filePath: string): AgentHistory; /** * Get statistics about the agent's actions */ getStatistics(): Record; } /** * The type of data emitted during beam execution */ interface WorkflowStepData { /** Current step number */ step: number; /** Current browser state */ state: BrowserState; /** Current agent output */ output?: unknown; /** Results from actions executed */ results?: Record; /** Memory-related information */ memory?: { /** Whether memory was generated in this step */ generated: boolean; /** Current memory stats */ stats?: { /** Number of tokens saved by memory */ tokensSaved?: number; /** Number of messages in memory */ messageCount?: number; }; }; } /** * Workflow result with agent statistics */ interface WorkflowResult extends Record { agentStats?: { totalSteps: number; totalDuration: number; tokenUsage: TokenUsage; tokenUsageByModel: Record; toolCounts: Record; mostUsedTools: Record; isDone: boolean; }; } /** * Define event types for proper type safety */ interface WorkflowEvents { text: (content: string) => void; "tool-call": (toolCall: ToolCall>) => void; "tool-result": (toolResult: ToolResult, unknown>) => void; step: (data: WorkflowStepData) => void; error: (error: Error) => void; done: (result: WorkflowResult) => void; plan: (content: string) => void; "history-update": (history: AgentHistory) => void; } type WorkflowManagerConfig = { browserContext: BrowserContext; agent: Agent; plannerAgent: Agent | null; agentMemory: Memory; plannerMemory: Memory | null; maxSteps: number; plannerInterval: number; useVision: boolean; includeAttributes?: string[]; maxActionsPerStep: number; eventEmitter: EventEmitter; }; /** * WorkflowManager class handles the creation and execution of workflows */ declare class WorkflowManager { private config; private workflow; private container; private currentStep; private lastPlan; private logger; private emitter; private agentHistory; private currentHistoryItem; private lastToolCall; constructor(config: WorkflowManagerConfig); /** * Emit an event through the provided emitter */ private emit; /** * Run a task with the workflow */ run({ runId, task }: { runId: string; task: string; }): Promise<_mastra_core_workflows.WorkflowRunResult[], Record>>>[], any> | undefined>; /** * Run the planner to analyze the current state and suggest strategic next steps */ private runPlanner; /** * Finalize a step and emit history update */ private finalizeStep; /** * Set up the workflow with the necessary steps */ setupWorkflow({ runId, task }: { runId: string; task: string; }): Promise; /** * Get the agent history */ getAgentHistory(): AgentHistory; } declare const goToUrl: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const searchGoogle: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const goBack: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const clickElementByIndex: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const inputText: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const scrollDown: _mastra_core_tools.Tool; }, "strip", z.ZodTypeAny, { amount?: number | undefined; }, { amount?: number | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; }, "strip", z.ZodTypeAny, { amount?: number | undefined; }, { amount?: number | undefined; }>>>; declare const scrollUp: _mastra_core_tools.Tool; }, "strip", z.ZodTypeAny, { amount?: number | undefined; }, { amount?: number | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; }, "strip", z.ZodTypeAny, { amount?: number | undefined; }, { amount?: number | undefined; }>>>; declare const scrollToText: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const extractContent: _mastra_core_tools.Tool>; }, "strip", z.ZodTypeAny, { goal: string; shouldStripLinkUrls: boolean; }, { goal: string; shouldStripLinkUrls?: boolean | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext>; }, "strip", z.ZodTypeAny, { goal: string; shouldStripLinkUrls: boolean; }, { goal: string; shouldStripLinkUrls?: boolean | undefined; }>>>; declare const saveHtmlToFile: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const savePdf: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const dragDrop: _mastra_core_tools.Tool; elementTarget: z.ZodOptional; elementSourceOffset: z.ZodOptional>; elementTargetOffset: z.ZodOptional>; coordSourceX: z.ZodOptional; coordSourceY: z.ZodOptional; coordTargetX: z.ZodOptional; coordTargetY: z.ZodOptional; steps: z.ZodDefault>; delayMs: z.ZodDefault>; }, "strip", z.ZodTypeAny, { steps: number; delayMs: number; elementSource?: string | undefined; elementTarget?: string | undefined; elementSourceOffset?: { x: number; y: number; } | undefined; elementTargetOffset?: { x: number; y: number; } | undefined; coordSourceX?: number | undefined; coordSourceY?: number | undefined; coordTargetX?: number | undefined; coordTargetY?: number | undefined; }, { elementSource?: string | undefined; elementTarget?: string | undefined; elementSourceOffset?: { x: number; y: number; } | undefined; elementTargetOffset?: { x: number; y: number; } | undefined; coordSourceX?: number | undefined; coordSourceY?: number | undefined; coordTargetX?: number | undefined; coordTargetY?: number | undefined; steps?: number | undefined; delayMs?: number | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; elementTarget: z.ZodOptional; elementSourceOffset: z.ZodOptional>; elementTargetOffset: z.ZodOptional>; coordSourceX: z.ZodOptional; coordSourceY: z.ZodOptional; coordTargetX: z.ZodOptional; coordTargetY: z.ZodOptional; steps: z.ZodDefault>; delayMs: z.ZodDefault>; }, "strip", z.ZodTypeAny, { steps: number; delayMs: number; elementSource?: string | undefined; elementTarget?: string | undefined; elementSourceOffset?: { x: number; y: number; } | undefined; elementTargetOffset?: { x: number; y: number; } | undefined; coordSourceX?: number | undefined; coordSourceY?: number | undefined; coordTargetX?: number | undefined; coordTargetY?: number | undefined; }, { elementSource?: string | undefined; elementTarget?: string | undefined; elementSourceOffset?: { x: number; y: number; } | undefined; elementTargetOffset?: { x: number; y: number; } | undefined; coordSourceX?: number | undefined; coordSourceY?: number | undefined; coordTargetX?: number | undefined; coordTargetY?: number | undefined; steps?: number | undefined; delayMs?: number | undefined; }>>>; declare const switchTab: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const closeTab: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const groupTabs: _mastra_core_tools.Tool; groupName: z.ZodOptional; }, "strip", z.ZodTypeAny, { pageIds: number[]; groupName?: string | undefined; }, { pageIds: number[]; groupName?: string | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; groupName: z.ZodOptional; }, "strip", z.ZodTypeAny, { pageIds: number[]; groupName?: string | undefined; }, { pageIds: number[]; groupName?: string | undefined; }>>>; declare const ungroupTabs: _mastra_core_tools.Tool; }, "strip", z.ZodTypeAny, { groupId?: string | undefined; }, { groupId?: string | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; }, "strip", z.ZodTypeAny, { groupId?: string | undefined; }, { groupId?: string | undefined; }>>>; declare const wait: _mastra_core_tools.Tool; }, "strip", z.ZodTypeAny, { seconds: number; }, { seconds?: number | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; }, "strip", z.ZodTypeAny, { seconds: number; }, { seconds?: number | undefined; }>>>; declare const sendKeys: _mastra_core_tools.Tool, undefined, _mastra_core_tools.ToolExecutionContext>>; declare const done: _mastra_core_tools.Tool; }, "strip", z.ZodTypeAny, { success: boolean; text: string; }, { text: string; success?: boolean | undefined; }>, undefined, _mastra_core_tools.ToolExecutionContext; }, "strip", z.ZodTypeAny, { success: boolean; text: string; }, { text: string; success?: boolean | undefined; }>>>; declare const defaultTools_clickElementByIndex: typeof clickElementByIndex; declare const defaultTools_closeTab: typeof closeTab; declare const defaultTools_done: typeof done; declare const defaultTools_dragDrop: typeof dragDrop; declare const defaultTools_extractContent: typeof extractContent; declare const defaultTools_goBack: typeof goBack; declare const defaultTools_goToUrl: typeof goToUrl; declare const defaultTools_groupTabs: typeof groupTabs; declare const defaultTools_inputText: typeof inputText; declare const defaultTools_saveHtmlToFile: typeof saveHtmlToFile; declare const defaultTools_savePdf: typeof savePdf; declare const defaultTools_scrollDown: typeof scrollDown; declare const defaultTools_scrollToText: typeof scrollToText; declare const defaultTools_scrollUp: typeof scrollUp; declare const defaultTools_searchGoogle: typeof searchGoogle; declare const defaultTools_sendKeys: typeof sendKeys; declare const defaultTools_switchTab: typeof switchTab; declare const defaultTools_ungroupTabs: typeof ungroupTabs; declare const defaultTools_wait: typeof wait; declare namespace defaultTools { export { defaultTools_clickElementByIndex as clickElementByIndex, defaultTools_closeTab as closeTab, defaultTools_done as done, defaultTools_dragDrop as dragDrop, defaultTools_extractContent as extractContent, defaultTools_goBack as goBack, defaultTools_goToUrl as goToUrl, defaultTools_groupTabs as groupTabs, defaultTools_inputText as inputText, defaultTools_saveHtmlToFile as saveHtmlToFile, defaultTools_savePdf as savePdf, defaultTools_scrollDown as scrollDown, defaultTools_scrollToText as scrollToText, defaultTools_scrollUp as scrollUp, defaultTools_searchGoogle as searchGoogle, defaultTools_sendKeys as sendKeys, defaultTools_switchTab as switchTab, defaultTools_ungroupTabs as ungroupTabs, defaultTools_wait as wait }; } type DefaultToolKeys = keyof typeof defaultTools; type AnyTool = Tool; type ToolsConfig = Record | { /** List of default tool names to exclude */ exclude?: DefaultToolKeys[]; /** Custom tools to add (keys must not conflict with non-excluded default tools) */ custom?: Record; /** Override implementations of default tools */ override?: Partial>; /** Additional tool configuration options */ options?: { /** Allow overriding default tools (default: false) */ allowToolOverrides?: boolean; /** Validate tool schemas during registration (default: true) */ validateSchemas?: boolean; }; }; interface BeamEvents { "tool-call": (toolCall: ToolCall>) => void; "tool-result": (toolResult: ToolResult, unknown>) => void; text: (content: string) => void; step: (data: WorkflowStepData) => void; error: (error: Error) => void; done: (result: BeamResult) => void; plan: (content: string) => void; "history-update": (history: AgentHistory) => void; } /** * The type of data emitted during beam execution */ type BeamStepData = WorkflowStepData; /** * Base configuration options common to all Beam configurations */ interface BaseBeamConfig { /** Custom browser instance (optional) */ browser?: Browser; /** Custom browser context (optional) */ context?: BrowserContext; /** AI model to use */ llm: LanguageModel; /** Whether to use vision capabilities */ useVision?: boolean; /** Maximum number of steps to execute */ maxSteps?: number; /** Maximum number of consecutive failures allowed */ maxFailures?: number; /** Custom agent instructions */ instructions?: string; /** Path to save conversation logs */ saveConversationPath?: string; /** Whether to generate a GIF of the session */ generateGif?: boolean | string; /** Memory configuration */ memory?: Memory; /** Keep only this many recent messages for main agent */ lastMessages?: number; /** Keep this many messages for planner */ plannerLastMessages?: number; /** How many messages to include from semantic search for planner */ semanticRecallCount?: number; /** Whether to enable working memory */ useWorkingMemory?: boolean; /** Template for working memory in browser agent */ workingMemoryTemplate?: string; messageManager?: { maxInputTokens?: number; persistMemory?: boolean; permanentMessageTypes?: string[]; }; /** Separate LLM for the planner (optional) */ plannerLlm?: LanguageModel; /** Run planner every N steps (0 disables) */ plannerInterval?: number; /** Whether to include images in planner input */ useVisionForPlanner?: boolean; /** Whether planner should show reasoning */ isPlannerReasoning?: boolean; /** Maximum actions per step */ maxActionsPerStep?: number; /** Path to system prompt template */ systemPromptPath?: string; /** Override system message */ overrideSystemMessage?: string; /** Extend system message */ extendSystemMessage?: string; /** Attributes to include in element descriptions */ includeAttributes?: string[]; /** Allowed domains for navigation (security feature) */ allowedDomains?: string[]; /** Whether to keep the process alive after workflow completion */ keepAlive?: boolean; /** * Tools configuration for extending agent capabilities. * You can provide custom tools in several ways: * * 1. Simple mapping of tool name to tool implementation: * tools?: Record; * * 2. Exclude specific default tools: * tools?: { * exclude?: DefaultToolKeys[]; * custom?: Record; * }; * * 3. Full configuration with custom tools, exclusions, and overrides: * tools?: { * exclude?: DefaultToolKeys[]; * custom?: Record; * override?: Partial>; * options?: { * allowToolOverrides?: boolean; * validateSchemas?: boolean; * }; * }; */ tools?: ToolsConfig; /** Viewport configuration */ viewport?: { width: number; height: number; }; /** Logging level (optional) */ logLevel?: LogLevel; } /** * Configuration for Beam with Steel enabled */ interface SteelBeamConfig extends BaseBeamConfig { /** Whether to use Steel SDK for browser automation */ useSteel: true; /** Steel SDK configuration */ steel?: ClientOptions & { connectUrl?: string; }; } /** * Configuration for Beam without Steel */ interface RegularBeamConfig extends BaseBeamConfig { /** Whether to use Steel SDK for browser automation */ useSteel?: false; /** Steel SDK configuration is not available when not using Steel */ steel?: never; } /** * Configuration options for Beam - this is a discriminated union * that ensures Steel configuration is only available when useSteel is true */ type BeamConfig = SteelBeamConfig | RegularBeamConfig; /** * Options for running a task */ interface RunOptions { /** The task description */ task: string; /** Initial actions to perform */ /** Sensitive data to redact from outputs */ sensitiveData?: Record; /** Optional run ID for this execution */ runId?: string; } /** * Result type for Steel session data */ interface SteelSessionData { /** Steel session ID */ id: string; /** URL to view the live session */ viewerUrl: string; } /** * The result of running a task with Beam */ interface BeamResult extends WorkflowResult { /** Steel session information if Steel SDK was used */ steelSession?: SteelSessionData; } /** * Class for browser automation with AI */ declare class Beam extends EventEmitter { /** * Typed event handler for attaching listeners to specific events with correct type inference */ on(event: E, listener: BeamEvents[E]): this; /** * Typed event handler for one-time event listeners */ once(event: E, listener: BeamEvents[E]): this; /** * Typed event handler for removing listeners from specific events */ off(event: E, listener: BeamEvents[E]): this; /** * Typed event emitter that ensures correct parameter types per event */ emit(event: E, ...args: Parameters): boolean; private browser; private browserContext; private config; private consecutiveFailures; private running; private stopped; private paused; private container; private workflowManager; private agentManager; private redactor; private steelClient; private steelSession; private initialized; /** * Create a new Beam instance * * @param config - Configuration options */ constructor(config: T); /** * Initialize browser components and workflow manager * This must be called before running any tasks */ initialize(session?: T extends SteelBeamConfig ? SteelSDK.Sessions.SessionCreateParams : never): Promise; /** * Sets up browser components */ private setupBrowserComponents; /** * Sets up Steel browser integration */ private setupSteelBrowser; /** * Sets up the agent manager */ private setupAgentManager; /** * Sets up the workflow manager */ private setupWorkflowManager; /** * Run a task with the AI agent */ run(options: RunOptions): Promise; /** * Close the browser session and clean up resources */ close(): Promise; /** * Set the logging level dynamically * @param level - The logging level to set */ setLogLevel(level: LogLevel): void; /** * Get the current logging level * @returns The current log level */ getLogLevel(): string; } export { AgentHistory as A, Beam as B, DomService as D, type ProxySettings as P, type RunOptions as R, type SelectorMap as S, type TabInfo as T, type WorkflowStepData as W, type BrowserState as a, type WorkflowResult as b, type WorkflowEvents as c, Browser as d, BrowserContext as e, type BrowserClass as f, type BrowserConfig as g, type BrowserContextConfig as h, type DOMBaseNode as i, type DOMElementNode as j, type DOMTextNode as k, type DOMState as l, type DOMHistoryElement as m, type BeamConfig as n, type BeamStepData as o, type BeamEvents as p, WorkflowManager as q, type WorkflowManagerConfig as r, type TokenUsage as s, type DefaultToolKeys as t };