Skip to content

feat(cloudflare): typed Cloudflare.* CDP commands (handoff, session, live view)#218

Draft
jonnyparris wants to merge 2 commits into
mainfrom
ruskin/brapi-cdp-types
Draft

feat(cloudflare): typed Cloudflare.* CDP commands (handoff, session, live view)#218
jonnyparris wants to merge 2 commits into
mainfrom
ruskin/brapi-cdp-types

Conversation

@jonnyparris

Copy link
Copy Markdown
Member

What

Adds typed support for Cloudflare's custom Cloudflare.* CDP domain so calls like:

const { handoffId } = await cdpSession.send('Cloudflare.handoff', {
  instructions: 'Solve the captcha',
  timeout: 60_000,
});

type-check with full parameter and return-type inference, instead of being rejected as an unknown CDP command. (The wire layer already accepts arbitrary command strings at runtime; this adds the missing types.)

Covers the full domain:

Command Request Response
Cloudflare.handoff HandoffRequest HandoffResponse
Cloudflare.handoffComplete HandoffCompleteRequest HandoffCompleteResponse
Cloudflare.getHandoffState GetHandoffStateRequest GetHandoffStateResponse
Cloudflare.getSessionId GetSessionIdRequest GetSessionIdResponse
Cloudflare.getLiveView GetLiveViewRequest GetLiveViewResponse

How

  • New hand-written packages/playwright-cloudflare/cloudflare-cdp.d.ts declares the request/response interfaces and merges the commands into Protocol.CommandParameters / Protocol.CommandReturnValues — the two maps CDPSession.send() is keyed on.
  • Lives outside the build-generated types/ directory (overwritten by utils/copy_types.js) so the augmentation survives rebuilds, mirroring the existing Browser.sessionId() augmentation in index.d.ts.
  • Wired in via export * from './cloudflare-cdp' in index.d.ts (pulls in the augmentation and exposes the interfaces to consumers).

Shared source of truth

The interface block is byte-identical to the one vendored into the puppeteer fork (companion PR). Only the declare module glue differs per fork. This is the canonical definition pending the cloudflare/browser-run monorepo, at which point both copies are replaced by a shared imported package.

Tickets

  • BRAPI-1194 (handoff commands)
  • BRAPI-1218 (getSessionId / getLiveView commands)

Companion PR: cloudflare/puppeteer (same types, puppeteer augmentation).


beep-boop-ruskin-agent-🤖

Declares the request/response types for Cloudflare's custom CDP domain
(handoff, handoffComplete, getHandoffState, getSessionId, getLiveView)
and merges them into Protocol.CommandParameters / CommandReturnValues so
calls like cdpSession.send('Cloudflare.handoff', {...}) type-check with
full param and return-type inference.

The augmentation lives outside the build-generated types/ directory so it
survives copy_types.js rebuilds, mirroring the existing Browser.sessionId()
augmentation in index.d.ts.

The shared interface block is the canonical definition, vendored
identically into the puppeteer and playwright forks; it is intended to be
promoted to a shared package once the cloudflare/browser-run monorepo
lands. Only the Protocol augmentation is fork-specific.

BRAPI-1194, BRAPI-1218
@pkg-pr-new

pkg-pr-new Bot commented Jun 30, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/cloudflare/playwright/@cloudflare/playwright@218

commit: a3fd978

- GetSessionIdRequest: use Record<string, never> instead of an empty
  interface, matching the puppeteer fork's lint-clean canonical block
- scope an eslint-disable for no-namespace on the Protocol augmentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant