import type { CookieJar } from "../cookies/index.js"; /** * Thin wrapper over Vercel Labs' `agent-browser` Rust CLI. * * agent-browser is a process that wraps a managed Chrome for Testing * binary and exposes verbs over its own daemon (state persists across * invocations within a shell). This wrapper exec's the binary; it does * **not** manage the daemon itself. * * Optional cookie-jar integration: if a CookieJar is passed in the * options, the wrapper will write the jar contents to a temp state file * and `state load` it before any nav, then `cookies get` and merge the * result back into the jar after work is done. Cookies are best-effort: * the wrapper never fails because a load/save round-trip blew up. * * Canonical for `harn browse-ai` (dev side); ready to be the shared core of * the agent-side `browse` wrapper (sandbox side) when that wrapper gets refactored. */ export interface AgentBrowserOptions { /** Override the binary path. Default: looks up `agent-browser` on PATH. */ binary?: string; /** Cookie jar for cross-tool sharing. Pass `null` to skip. */ jar?: CookieJar | null; /** Default per-call timeout in ms. Default 60000. */ timeoutMs?: number; /** Extra env vars to merge into every spawn. */ env?: Record; /** * Path used as the `state load` source when seeding cookies into the * agent-browser session. Defaults to a tmp file derived from the jar. */ stateFilePath?: string; } export interface ExecResult { stdout: string; stderr: string; ok: boolean; exitCode: number | null; } export declare class AgentBrowser { private readonly opts; private cookiesSeeded; constructor(opts?: AgentBrowserOptions); /** * Run an `agent-browser` subcommand. Returns a structured result. * Throws only on spawn failure (e.g., binary not found); non-zero exit * returns ok=false. */ exec(args: string[], timeoutMs?: number): ExecResult; /** * Same as `exec` but throws on non-zero exit code, with stderr in the * error message. Use when the caller can't recover from a failure. */ execOrThrow(args: string[], timeoutMs?: number): ExecResult; /** * Seed the jar's cookies into the agent-browser session via `state load`. * Called automatically by `open()`. Safe to call multiple times; only * the first call does work. */ seedCookies(): void; open(url: string, timeoutMs?: number): ExecResult; snapshot(opts?: { interactive?: boolean; }): string; screenshot(path: string, opts?: { full?: boolean; annotate?: boolean; }): void; click(refOrSelector: string): ExecResult; fill(refOrSelector: string, value: string): ExecResult; press(key: string): ExecResult; wait(selectorOrMs: string): ExecResult; evaluate(script: string): string; /** * Run a semicolon-separated batch of agent-browser sub-commands in a * single session. Each step is exec'd with the same daemon, so state * persists. Returns one ExecResult per step in order. */ batch(steps: string[]): ExecResult[]; /** Start HAR recording. Pair with `harStop`. */ harStart(path: string): ExecResult; /** Stop HAR recording. Returns the same result for symmetry with start. */ harStop(path: string): ExecResult; /** * Pull cookies out of the agent-browser session via `cookies get --json`, * merge them into the jar (if one was provided), and persist. Best-effort: * a parse failure or missing jar returns 0 without raising. */ syncCookiesToJar(): { saved: number; }; /** * Some shell environments leak XDG_CONFIG_HOME into Chrome's crashpad * lookup, which can cause SIGTRAP if the path is read-only (e.g. in * containerized sandbox environments). Strip it here defensively. */ private scrubEnv; } //# sourceMappingURL=client.d.ts.map