slicc-cdp-client
Shared Chrome DevTools Protocol connection for the playwright-cli and curlwright binaries.
The crates.io name is slicc-cdp-client. The Rust library name stays cdp_client:
cdp-client = { package = "slicc-cdp-client", version = "1" }
One browser WebSocket. Target.attachToTarget uses {targetId, flatten: true}. Later page commands send that sessionId at the top level. There is no /devtools/page/<id> socket.
Fetch interception
cdp_client::fetch pauses requests on one target session. Interception::attach(&mut cdp, target_id, &patterns) checks the target, attaches, and sends Fetch.enable; dropping it, or finish(), sends Fetch.disable and detaches. Interception::on_session does the same on a session you already hold and leaves it attached. cdp::detach also forgets that session's paused requests.
Pattern::request(glob)andPattern::response(glob)are CDPurlPatterns (*,?,\to escape) at the Request or Response stage, with an optionalresource_type.next(timeout)returns aPaused:method,url,url_fragment,full_url(),headers,post_data, and at the response stagestatus,response_headersandlocation(), which resolvesLocationagainst the request URL and keeps its fragment.decide(&paused, &Decision)sendsContinue(Overrides)(continueRequestwith URL, method, body or headers),ContinueResponse(ResponseOverrides),Fulfill(Fulfill)(fulfillRequest: status, headers, body;Fulfill::signed_in()is a short "Signed in, you can close this tab" page) orFail(ErrorReason)(failRequest).response_body(&paused)isFetch.getResponseBody, decoded.navigation(guard, event)reads aPage.frameNavigatedevent asurlplusurlFragment, for a redirect made by script.Cdp::set_decider(session, Some(Box<dyn FnMut(&Paused) -> Decision>))answers pauses inline, even while another call waits for its reply, so a synchronousPage.navigatedoesn't deadlock. A decision CDP rejects is retried as a plain continue and kept intake_fetch_errors().
Seven and the vault are never intercepted. protected::Protected implements protectedOrigins from the slicc-browsers crate with a WHATWG URL parser and passes every vector in its protected.json. A paused request whose URL, or whose Location, is protected is continued unchanged at once and never reaches next or a decider. enable refuses a pattern that names a protected host, and any call without a session (browser-wide Fetch.enable). Interception::attach refuses a target on a protected origin, or a blank popup whose opener is protected or gone. A decision can't redirect to a protected URL, by url, Location or Refresh. Cdp::protect_origins(&[...]) adds extra origins.
use ;
let mut seen = attach?;
let session = seen.session_id.to_string;
seen.notify;
if let Some = seen.next?
Host builds use native-tls for wss:// and for https:// discovery, on macOS, Linux, and Windows. Rust 1.83 or newer. The wasm32-wasip1 build has no TLS. This crate does not launch Chrome. Callers pass a DevTools WebSocket URL or an http:// discovery URL.
cargo install slicc-cdp installs the playwright-cli command. cargo install curlwright installs curlwright. @ai-ecoverse/slicc-cdp on npm ships their WASI builds for SLICC.