fix: support WebSocket URLs in connect command (#205)
* fix: support WebSocket URLs in connect command * address feedback
This commit is contained in:
+41
-1
@@ -1317,6 +1317,46 @@ Examples:
|
||||
"##
|
||||
}
|
||||
|
||||
// === Connect ===
|
||||
"connect" => {
|
||||
r##"
|
||||
agent-browser connect - Connect to browser via CDP
|
||||
|
||||
Usage: agent-browser connect <port|url>
|
||||
|
||||
Connects to a running browser instance via Chrome DevTools Protocol (CDP).
|
||||
This allows controlling browsers, Electron apps, or remote browser services.
|
||||
|
||||
Arguments:
|
||||
<port> Local port number (e.g., 9222)
|
||||
<url> Full WebSocket URL (ws://, wss://, http://, https://)
|
||||
|
||||
Supported URL formats:
|
||||
- Port number: 9222 (connects to http://localhost:9222)
|
||||
- WebSocket URL: ws://localhost:9222/devtools/browser/...
|
||||
- Remote service: wss://remote-browser.example.com/cdp?token=...
|
||||
|
||||
Global Options:
|
||||
--json Output as JSON
|
||||
--session <name> Use specific session
|
||||
|
||||
Examples:
|
||||
# Connect to local Chrome with remote debugging
|
||||
# Start Chrome: google-chrome --remote-debugging-port=9222
|
||||
agent-browser connect 9222
|
||||
|
||||
# Connect using WebSocket URL from /json/version endpoint
|
||||
agent-browser connect "ws://localhost:9222/devtools/browser/abc123"
|
||||
|
||||
# Connect to remote browser service
|
||||
agent-browser connect "wss://browser-service.example.com/cdp?token=xyz"
|
||||
|
||||
# After connecting, run commands normally
|
||||
agent-browser snapshot
|
||||
agent-browser click @e1
|
||||
"##
|
||||
}
|
||||
|
||||
_ => return false,
|
||||
};
|
||||
println!("{}", help.trim());
|
||||
@@ -1351,7 +1391,7 @@ Core Commands:
|
||||
pdf <path> Save as PDF
|
||||
snapshot Accessibility tree with refs (for AI)
|
||||
eval <js> Run JavaScript
|
||||
connect <port> Connect to browser via CDP (e.g., connect 9222)
|
||||
connect <port|url> Connect to browser via CDP
|
||||
close Close browser
|
||||
|
||||
Navigation:
|
||||
|
||||
Reference in New Issue
Block a user