import type { ArtifactRef, BrowserSession, BrowserSessionOptions, McpServerRef } from "@boardwalk-labs/workflow/runtime"; /** One MCP tool result content block (the subset we consume). */ export interface McpContentBlock { type: string; text?: string; /** base64 for `type: "image"`. */ data?: string; mimeType?: string; } export interface McpToolResult { content: readonly McpContentBlock[]; isError: boolean; } /** A live MCP client bound to one session's Playwright MCP server (the PROGRAM's channel). */ export interface SessionMcpCaller { callTool: (name: string, args: Record) => Promise; close: () => Promise; } /** A launched browser process: the CDP endpoint + the Playwright MCP HTTP URL the agent binds to. */ export interface BrowserProcess { /** e.g. `http://127.0.0.1:9222` (program-internal, never exposed). */ readonly cdpUrl: string; /** e.g. `http://127.0.0.1:9333/mcp` — the agent's MCP endpoint. */ readonly mcpUrl: string; /** Terminate Chromium + the Playwright MCP server. Idempotent. */ kill: () => Promise; } /** Spawns Chromium (headful on the guest display) + a per-session Playwright MCP attached to it, * with the arbitrary-JS tools (`browser_evaluate`, `browser_run_code_unsafe`) DISABLED for the * agent — page-eval stays program-only. Production impl in browser_session_backend.ts. */ export interface BrowserBackend { launch: (opts: BrowserSessionOptions | undefined) => Promise; } /** Store a captured screenshot as a run artifact; returns its ref (the same store `artifacts.write` uses). */ export type ScreenshotArtifactWriter = (name: string, contentType: string, base64: string, metadata: Record) => Promise; export interface BrowserSessionManagerDeps { backend: BrowserBackend; /** Open the PROGRAM's MCP client to a session's Playwright MCP HTTP URL. */ connect: (mcpUrl: string) => Promise; writeArtifact: ScreenshotArtifactWriter; /** Monotonic session-id source (injected for determinism in tests). */ nextId: () => string; } /** * Per-run manager of browser sessions. Opens them (spawn + connect + handle), resolves a session to * its agent-facing MCP ref for `agent({ session })` binding, and reaps every open session at run end. */ export declare class BrowserSessionManager { private readonly deps; private readonly sessions; constructor(deps: BrowserSessionManagerDeps); open(opts?: BrowserSessionOptions): Promise; /** The agent-facing MCP ref for a session handle, or null if it isn't a live session of this run * (e.g. already closed, or a foreign object). The host appends this to the leaf's `mcp`. */ mcpRefFor(session: BrowserSession): McpServerRef | null; /** Tear down every still-open session. Called once when the run ends (best-effort per session). */ closeAll(): Promise; private reap; } /** * Pull the evaluated value out of a `browser_evaluate` reply. Playwright MCP answers with a markdown * envelope, not a bare value: * * ### Result * {"title":"Example Domain"} * ### Ran Playwright code * ```js * await page.evaluate(...) * ``` * * so parsing the whole text always failed and `eval()` handed the caller that prose instead of the * value its signature promises. Take the `### Result` section and stop at the next heading. */ export declare function evalResultText(text: string): string;