Skip to content

Conversation

@miguelg719
Copy link
Collaborator

why

To enable sending direct CDP commands through the page object

what changed

Added a page.sendCDP method similar to the one on stagehand v2 that allows sending CDP commands to the page's mainSession

test plan

@changeset-bot
Copy link

changeset-bot bot commented Nov 5, 2025

🦋 Changeset detected

Latest commit: e668c48

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@miguelg719 miguelg719 marked this pull request as ready for review November 5, 2025 00:48
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Greptile Overview

Greptile Summary

Added page.sendCDP() method to enable direct Chrome DevTools Protocol (CDP) command execution through the page's main session, providing v3 parity with the v2 API.

  • Simple wrapper around mainSession.send<T>(method, params) with proper TypeScript generic support
  • Well-documented with JSDoc including parameter descriptions and usage examples
  • Consistent with existing CDP usage patterns throughout the codebase
  • Enables advanced users to execute arbitrary CDP commands when needed

Confidence Score: 5/5

  • Safe to merge with no concerns
  • This is a straightforward feature addition that adds a thin wrapper method exposing existing functionality. The implementation is minimal, well-documented, follows existing patterns in the codebase, and introduces no new logic or security concerns.
  • No files require special attention

Important Files Changed

File Analysis

Filename Score Overview
.changeset/early-brooms-draw.md 5/5 Standard changeset file documenting the patch-level addition of page.sendCDP method
packages/core/lib/v3/understudy/page.ts 5/5 Added sendCDP method to expose CDP commands through the main session with proper TypeScript generics and documentation

Sequence Diagram

sequenceDiagram
    participant User
    participant Page
    participant mainSession as CDPSessionLike
    participant Browser as Chrome Browser

    User->>Page: sendCDP(method, params)
    Note over User,Page: e.g., sendCDP("Runtime.evaluate", {expression: "1+1"})
    Page->>mainSession: send<T>(method, params)
    mainSession->>Browser: CDP Command via WebSocket
    Browser-->>mainSession: CDP Response
    mainSession-->>Page: Typed Response<T>
    Page-->>User: Promise<T>
Loading

1 file reviewed, no comments

Edit Code Review Agent Settings | Greptile

@miguelg719 miguelg719 merged commit 6fc9de2 into main Nov 5, 2025
15 checks passed
miguelg719 pushed a commit that referenced this pull request Nov 14, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @browserbasehq/stagehand@3.0.2

### Patch Changes

- [#1245](#1245)
[`a224b33`](a224b33)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - allow act()
to call hover()

- [#1234](#1234)
[`6fc9de2`](6fc9de2)
Thanks [@miguelg719](https://github.com/miguelg719)! - Add a
page.sendCDP method

- [#1233](#1233)
[`4935be7`](4935be7)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - extend
page.screenshot() options to mirror playwright

- [#1232](#1232)
[`bdd76fc`](bdd76fc)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - export Page
type

- [#1229](#1229)
[`7ea18a4`](7ea18a4)
Thanks [@tkattkat](https://github.com/tkattkat)! - Adjust extract tool +
expose extract response in agent result

- [#1239](#1239)
[`d4de014`](d4de014)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix
stagehand.metrics on api mode

- [#1241](#1241)
[`2d1b573`](2d1b573)
Thanks [@miguelg719](https://github.com/miguelg719)! - Return response
on page.goto api mode

- [#1253](#1253)
[`5556041`](5556041)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - fix missing
page issue when connecting to existing browser

- [#1235](#1235)
[`7e4b43e`](7e4b43e)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - make
page.goto() return a Response object

- [#1254](#1254)
[`7e72adf`](7e72adf)
Thanks [@sameelarif](https://github.com/sameelarif)! - Added custom
error types to allow for a smoother debugging experience.

- [#1227](#1227)
[`9bf09d0`](9bf09d0)
Thanks [@miguelg719](https://github.com/miguelg719)! - Fix readme's
media links and add instructions for installing from a branch

- [#1257](#1257)
[`92d32ea`](92d32ea)
Thanks [@tkattkat](https://github.com/tkattkat)! - Add support for a
custom baseUrl with google cua client

- [#1230](#1230)
[`ebcf3a1`](ebcf3a1)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add
stagehand.browserbaseSessionID getter

- [#1262](#1262)
[`c29a4f2`](c29a4f2)
Thanks [@miguelg719](https://github.com/miguelg719)! - Remove error
throwing when api and experimental are both set

- [#1223](#1223)
[`6d21efa`](6d21efa)
Thanks [@miguelg719](https://github.com/miguelg719)! - Disable api mode
when using custom LLM clients

- [#1228](#1228)
[`525ef0c`](525ef0c)
Thanks [@Kylejeong2](https://github.com/Kylejeong2)! - update slack link
in docs

- [#1226](#1226)
[`9ddb872`](9ddb872)
Thanks [@seanmcguire12](https://github.com/seanmcguire12)! - add support
for page.on('console') events

## @browserbasehq/stagehand-evals@1.1.2

### Patch Changes

- Updated dependencies
\[[`a224b33`](a224b33),
[`6fc9de2`](6fc9de2),
[`4935be7`](4935be7),
[`bdd76fc`](bdd76fc),
[`7ea18a4`](7ea18a4),
[`d4de014`](d4de014),
[`2d1b573`](2d1b573),
[`5556041`](5556041),
[`7e4b43e`](7e4b43e),
[`7e72adf`](7e72adf),
[`9bf09d0`](9bf09d0),
[`92d32ea`](92d32ea),
[`ebcf3a1`](ebcf3a1),
[`c29a4f2`](c29a4f2),
[`6d21efa`](6d21efa),
[`525ef0c`](525ef0c),
[`9ddb872`](9ddb872)]:
    -   @browserbasehq/stagehand@3.0.2

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants