# chrome-cdp Drive one extension-owned Chrome process from Pi using raw Chrome DevTools Protocol JSON. The root `pi-ext` package loads this extension; no separate package install is needed. ## Usage - `/chrome` toggles the `chrome_cdp` tool and checks for a Chrome binary without launching it; first tool call starts Chrome with a temporary profile and random loopback debugging port. - Start Pi with `--chrome` to enable the tool at startup. - `/chrome close` stops Chrome and deactivates the tool; a sole managed `close` operation stops it without deactivating the tool. - Page-scoped CDP methods need an explicit `sessionId` from the returned status or `Target.attachToTarget`; browser-scoped methods omit it. - `operations` runs sequentially and stops on error; failed batches include `failedOperation` with zero-based `operation` and `kind`, plus zero-based `skipped` operations; use labeled replies as whole-value references such as `{{label.result.path}}`. - Managed operations include waits, screenshots, WebM video, performance traces, status, and close. - A labeled command supports one `wait` in each batch; use distinct labeled commands for separate waits. - Chrome's `/json/protocol` URL appears in status; consult it for the running browser's command schema. ## Configuration Project `.pi/settings.json` overrides user settings per property under `"chrome-cdp"`: ```json { "chrome-cdp": { "profile": "work", "executablePath": "/path/to/chrome", "artifactDir": "/path/to/captures", "flags": [] } } ``` A named profile lives in extension-owned OS application data; omitting `profile` uses a disposable profile. Managed captures default to OS Downloads unless `artifactDir` is set; browser downloads use a separate temporary directory. `ffmpeg` is needed only for WebM recording. Set `PI_CHROME_CDP_DEBUG` to an owner-private JSONL path for bounded metadata-only diagnostics. Raw CDP is unrestricted and may access local URLs, browser data, or override download settings; managed capture paths are not a sandbox. Events, traces, browser profiles, and captures can contain secrets. Spool paths returned by a batch remain until its next batch starts or Chrome closes; when current-batch files consume the 16 MiB spool quota, later responses fail rather than deleting returned files. Replay returns only event files containing events after `replayFrom`; an evicted in-memory event returns `lost: true` without `spooled`, while `status.gaps` counts discarded spool data. Linux real-Chrome checks exist; macOS and Windows launch paths are not empirically verified. ## Verification - `mise run //extensions/chrome-cdp:lint` - `mise run //extensions/chrome-cdp:test` - `mise run //extensions/chrome-cdp:check` - `mise run //extensions/chrome-cdp:e2e` runs real-Chrome acceptance checks and writes temporary profiles, test captures, and a named test profile outside this repository. - `mise run //extensions/chrome-cdp:bench -- 60 compare` measures large labeled-response handling; see [benchmark methodology](__bench__/README.md).