feat(cdp): auto-connect to Windows Chrome/Edge when running in WSL#1449
Open
jorinyang wants to merge 1 commit into
Open
feat(cdp): auto-connect to Windows Chrome/Edge when running in WSL#1449jorinyang wants to merge 1 commit into
jorinyang wants to merge 1 commit into
Conversation
When agent-browser runs inside WSL without a display server, the existing auto-connect logic fails because: - No Linux Chrome user-data dirs exist (the user's Chrome is on Windows) - 127.0.0.1 probes don't reach the Windows host - Local Chromium can't launch (no GPU/X11) This adds a WSL-aware fallback to `auto_connect_cdp()` that: 1. Detects WSL via /proc/version and /proc/sys/fs/binfmt_misc/WSLInterop 2. Resolves the Windows host IP from /etc/resolv.conf 3. Probes common CDP ports (9222-9224, 9229) on the Windows host 4. If no running Chrome is found, auto-launches Windows Chrome/Edge with --remote-debugging-port and --remote-debugging-address=0.0.0.0 5. Polls for CDP readiness and returns the WebSocket URL The launch uses a separate --user-data-dir under C:\temp to avoid conflicts with the user's normal browser session. Tested on WSL2 with both Chrome stable and Edge.
Contributor
|
Someone is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
|
||
| let mut cmd = Command::new(exe_path); | ||
| cmd.arg(format!("--remote-debugging-port={}", port)) | ||
| .arg("--remote-debugging-address=0.0.0.0") // allow connections from WSL |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
agent-browser --auto-connectruns inside WSL without a display server, auto-connect currently fails because:127.0.0.1probes don't reach the Windows hostThis PR adds a WSL-aware fallback to
auto_connect_cdp()incli/src/native/cdp/chrome.rs.What it does
When standard auto-connect methods fail and we detect WSL:
/proc/version("microsoft"/"WSL") and/proc/sys/fs/binfmt_misc/WSLInterop/etc/resolv.confnameserver (set by WSL to the Windows virtual NIC)chrome.exeandmsedge.exevia/mnt/c/--remote-debugging-port=9222 --remote-debugging-address=0.0.0.0--user-data-dirunderC:\temp— does NOT interfere with the user's normal Chrome sessionFiles changed
cli/src/native/cdp/wsl.rscli/src/native/cdp/mod.rspub mod wsl;cli/src/native/cdp/chrome.rsauto_connect_cdp()Total: +248 lines, 0 dependencies added.
Behavior
is_wsl()returnsfalse, the new code path is never enteredTesting
Tested on WSL2 (Ubuntu 24.04) with:
is_wsl()correctly returnsfalse)