Skip to content

feat: support remote CDP WebSocket URLs in --cdp flag#99

Merged
ctate merged 1 commit into
vercel-labs:mainfrom
kernel:feat/cdp-url-support
Jan 22, 2026
Merged

feat: support remote CDP WebSocket URLs in --cdp flag#99
ctate merged 1 commit into
vercel-labs:mainfrom
kernel:feat/cdp-url-support

Conversation

@rgarcia

@rgarcia rgarcia commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Extends --cdp flag to accept either a port number OR a full WebSocket URL
  • Enables connecting to remote browser services (Kernel, Browserless, etc.) that provide wss:// endpoints
  • Maintains backward compatibility with existing port-based usage

Motivation

Previously, --cdp only accepted a port number and connected via http://localhost:{port}. Remote browser services provide WebSocket URLs like wss://proxy.example.com/cdp?token=... that couldn't be used directly.

Changes

  • src/types.ts: Added cdpUrl?: string field to LaunchCommand
  • src/protocol.ts: Added URL validation for the new field
  • src/browser.ts: Updated connectViaCDP to detect URL vs port and handle both
  • cli/src/main.rs: Updated CLI to send cdpUrl for URLs, cdpPort for port numbers
  • README.md: Updated documentation with remote connection examples

Usage

# Local port (existing behavior)
agent-browser --cdp 9222 snapshot

# Remote WebSocket URL (new!)
agent-browser --cdp "wss://proxy.example.com:8443/browser/cdp?jwt=..." snapshot

Test plan

  • Existing tests pass (pnpm test)
  • Tested with Kernel browser service using wss:// URL
  • Test with local Chrome remote debugging port

@vercel

vercel Bot commented Jan 14, 2026

Copy link
Copy Markdown
Contributor

@rgarcia is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

@rgarcia rgarcia marked this pull request as ready for review January 14, 2026 19:17
@rgarcia rgarcia force-pushed the feat/cdp-url-support branch from db35812 to 9e9b357 Compare January 14, 2026 19:19

@vercel vercel Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Additional Suggestion:

CDP connection validation incorrectly rejects remote browser services that don't have pages open initially

Fix on Vercel

Comment thread src/protocol.ts Outdated
@rgarcia rgarcia force-pushed the feat/cdp-url-support branch 2 times, most recently from 4c34e9d to 38ec32e Compare January 18, 2026 11:15
@rgarcia

rgarcia commented Jan 18, 2026

Copy link
Copy Markdown
Contributor Author

rebased on latest main. This would be a killer feature and would love to see it merged in

@rgarcia rgarcia force-pushed the feat/cdp-url-support branch 3 times, most recently from 29d7324 to 3d26869 Compare January 18, 2026 19:22
@ctate

ctate commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

@rgarcia do you mind rebasing one more time? This will be the next to go in!

Previously, the --cdp flag only accepted a port number and connected via
http://localhost:{port}. This made it impossible to connect to remote
browser services like Kernel, Browserless, etc. that provide WebSocket URLs.

The --cdp flag now accepts either:
- A port number (e.g., 9222) for local connections
- A full WebSocket URL (e.g., wss://...) for remote browser services

Changes:
- Added cdpUrl field to LaunchCommand type
- Updated protocol validation to accept URL format with scheme validation
- Modified connectViaCDP to detect and handle both formats
- Handle numeric strings for JSON serialization edge cases
- Updated CLI to send cdpUrl or cdpPort based on input format
- Updated README with examples for remote connections

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@rgarcia rgarcia force-pushed the feat/cdp-url-support branch from 3d26869 to 8c8aae7 Compare January 22, 2026 00:04
@rgarcia

rgarcia commented Jan 22, 2026

Copy link
Copy Markdown
Contributor Author

@ctate done! Also saw you're accepting 3rd party providers so added Kernel over here: #200

@ctate

ctate commented Jan 22, 2026

Copy link
Copy Markdown
Collaborator

Thank you!!

@ctate ctate merged commit e892bce into vercel-labs:main Jan 22, 2026
1 of 2 checks passed
timothywangdev pushed a commit to timothywangdev/banana-browser that referenced this pull request Mar 17, 2026
Previously, the --cdp flag only accepted a port number and connected via
http://localhost:{port}. This made it impossible to connect to remote
browser services like Kernel, Browserless, etc. that provide WebSocket URLs.

The --cdp flag now accepts either:
- A port number (e.g., 9222) for local connections
- A full WebSocket URL (e.g., wss://...) for remote browser services

Changes:
- Added cdpUrl field to LaunchCommand type
- Updated protocol validation to accept URL format with scheme validation
- Modified connectViaCDP to detect and handle both formats
- Handle numeric strings for JSON serialization edge cases
- Updated CLI to send cdpUrl or cdpPort based on input format
- Updated README with examples for remote connections

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.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.

2 participants