-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add page.sendCDP #1234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add page.sendCDP #1234
Conversation
🦋 Changeset detectedLatest commit: e668c48 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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 |
There was a problem hiding this 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>
1 file reviewed, no comments
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>
why
To enable sending direct CDP commands through the page object
what changed
Added a
page.sendCDPmethod similar to the one on stagehand v2 that allows sending CDP commands to the page'smainSessiontest plan