fix(cli): read AGENT_BROWSER_CDP from environment variable #394
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
The
--cdpflag allows connecting to an existing browser via CDP, but unlike every other CLI flag (AGENT_BROWSER_EXECUTABLE_PATH,AGENT_BROWSER_PROFILE,AGENT_BROWSER_PROXY,AGENT_BROWSER_ARGS, etc.), it had no environment variable fallback. The default was hardcoded toNone.This one-line fix reads
AGENT_BROWSER_CDPfrom the environment, following the exact same pattern as all sibling flags inflags.rs.Use case
Users who always connect to an existing browser via CDP (e.g., a remote Chrome instance over SSH tunnel) had to pass
--cdp <port>on every single invocation. With this fix, they can setAGENT_BROWSER_CDP=9223once in their shell profile and all commands just work.Before
# Every command needs --cdp agent-browser --cdp 9223 open https://example.com agent-browser --cdp 9223 snapshot -i agent-browser --cdp 9223 tab listAfter
export AGENT_BROWSER_CDP=9223 agent-browser open https://example.com agent-browser snapshot -i agent-browser tab listChanges
cli/src/flags.rs:cdp: None→cdp: env::var("AGENT_BROWSER_CDP").ok()