Expand description
Playwright sidecar — spawn and talk to a Node script that wraps
playwright-core.
This module owns the lifecycle of the Node child process and the
NDJSON-over-stdio JSON-RPC channel to it. Tools in the MCP layer call
Sidecar::call with (method, params) and get back the parsed
result (or an error).
Lifecycle (per Sidecar instance):
Sidecar::start— picks a launcher (bunpreferred, thennode), prepares the cache directory containing the bundledsidecar.mjs+package.json, runsbun install/npm installif the deps aren’t already there, then spawns the child with stdin/stdout piped.Sidecar::connect— sends aconnectRPC carrying the CDP endpoint URL so the sidecar holds a PlaywrightBrowserfor the duration.Sidecar::call— send a request, receive the response. Many requests can be in flight (each carries a unique id); responses are routed by id.- Drop — closes stdin, the child exits.
Errors that originate inside the sidecar arrive as JSON-RPC error
responses; we surface them as anyhow errors. Connection-level
failures (sidecar process gone, stdio closed) surface as SidecarGone
so the caller can decide whether to restart.
Modules§
- assets
- Cache-dir management for the embedded sidecar assets.
Structs§
- Sidecar
- Live sidecar handle. Cloneable: behaviour is shared through
Arcs inside. - Sidecar
Config - User-facing configuration for spawning a sidecar.
Enums§
- Launcher
- Which runtime + package manager we use to launch the sidecar.
Constants§
- DEFAULT_
PLAYWRIGHT_ VERSION - Default
playwright-coreversion pinned inassets/playwright-sidecar/package.json. Overridable via--playwright-version(CLI) orSidecarConfig::version.