/** * Browser Agent Adapter * * Integrates browser automation agents (Playwright, Puppeteer, or * any CDP-compatible driver) with the SwarmOrchestrator. * * Provides a BYOC (bring your own client) interface for browser * agents that navigate, scrape, interact with, and test web pages. * * Usage: * const adapter = new BrowserAgentAdapter(); * adapter.registerBrowser('scraper', { * driver: myPlaywrightDriver, * mode: 'scrape', * }); * * @module BrowserAgentAdapter * @version 1.0.0 */ import { BaseAdapter } from './base-adapter'; import type { AdapterCapabilities, AgentPayload, AgentContext, AgentResult } from '../types/agent-adapter'; /** Browser agent operating mode */ export type BrowserMode = 'navigate' | 'scrape' | 'interact' | 'test' | 'screenshot'; /** Navigation/action step for scripted browser agents */ export interface BrowserStep { /** Action type */ action: 'goto' | 'click' | 'type' | 'select' | 'wait' | 'screenshot' | 'evaluate' | 'scroll'; /** CSS selector for click/type/select */ selector?: string; /** URL for goto, text for type */ value?: string; /** Wait time in ms for wait action */ waitMs?: number; /** JavaScript to evaluate for evaluate action */ script?: string; } /** Result from a browser action */ export interface BrowserActionResult { /** URL after action */ url: string; /** Page title */ title: string; /** Extracted text content (for scrape mode) */ textContent?: string; /** Extracted HTML (for scrape mode) */ html?: string; /** Screenshot as base64 (for screenshot mode) */ screenshot?: string; /** Evaluate result (for evaluate action) */ evalResult?: unknown; /** Console messages captured */ consoleMessages?: string[]; /** Network errors captured */ networkErrors?: string[]; /** Execution time for this action */ actionDurationMs?: number; } /** * Browser driver interface — wraps Playwright, Puppeteer, or CDP. * Users supply their own driver implementation. */ export interface BrowserDriver { /** Navigate to a URL */ goto(url: string): Promise; /** Click an element */ click(selector: string): Promise; /** Type text into an element */ type(selector: string, text: string): Promise; /** Select an option */ select(selector: string, value: string): Promise; /** Wait for a duration or selector */ wait(ms: number): Promise; /** Take a screenshot */ screenshot(): Promise; /** Evaluate JavaScript in the page */ evaluate(script: string): Promise; /** Get the current page text content */ getTextContent(): Promise; /** Get the current URL */ getCurrentUrl(): Promise; /** Get the page title */ getTitle(): Promise; /** Close the browser/page */ close(): Promise; } /** Configuration for a registered browser agent */ export interface BrowserAgentConfig { /** The browser driver instance */ driver: BrowserDriver; /** Default mode (default: 'navigate') */ mode?: BrowserMode; /** Default steps for scripted execution */ steps?: BrowserStep[]; /** Per-invocation timeout in ms (default: 60000) */ timeoutMs?: number; /** Whether to capture console logs (default: false) */ captureConsole?: boolean; /** Whether to capture screenshots after each step (default: false) */ screenshotPerStep?: boolean; } /** * Adapter for browser automation agents. * * Supports scripted step sequences or single-action modes * (navigate, scrape, screenshot, interact, test). */ export declare class BrowserAgentAdapter extends BaseAdapter { readonly name = "browser-agent"; readonly version = "1.0.0"; private browsers; get capabilities(): AdapterCapabilities; /** * Register a browser agent with a driver. */ registerBrowser(agentId: string, config: BrowserAgentConfig): void; executeAgent(agentId: string, payload: AgentPayload, _context: AgentContext): Promise; private executeSingleMode; private executeSteps; shutdown(): Promise; } //# sourceMappingURL=browser-agent-adapter.d.ts.map