Skip to content

feat(browser): add proxy configuration option - #20578

Closed
illusivejosiah wants to merge 8 commits into
openclaw:mainfrom
illusivejosiah:feat/browser-proxy-config
Closed

illusivejosiah wants to merge 8 commits into
openclaw:mainfrom
illusivejosiah:feat/browser-proxy-config

Conversation

@illusivejosiah

@illusivejosiah illusivejosiah commented Feb 19, 2026 •

Copy link
Copy Markdown

feat(browser): add proxy configuration option

Summary

Adds native proxy support to the browser tool. Users can route all browser traffic through HTTP, HTTPS, or SOCKS5 proxy servers via config.

What changed

Config (browser.proxy):

{
  browser: {
    proxy: "http://127.0.0.1:7890",
    profiles: {
      work: { proxy: "socks5://work-proxy:1080" }
    }
  }
}

Authenticated proxies — credentials in the URL are stripped before --proxy-server and injected via CDP Fetch.authRequired:

{ browser: { proxy: "http://user:[email protected]:8080" } }

Per-profile overrides — profile proxy falls back to global when not set.

Files changed (7)

File Change
src/config/types.browser.ts proxy?: string on BrowserConfig + BrowserProfileConfig
src/config/zod-schema.ts proxy + extraArgs added to Zod schema (extraArgs was in TS type but missing from schema — .strict() rejected it; required for proxy to pass validation)
src/browser/config.ts parseProxyUrl() with scheme validation, credential extraction, port check. Per-profile fallback to global.
src/browser/chrome.ts --proxy-server arg injection + setupCdpProxyAuth() for authenticated proxies via browser-level CDP
src/browser/config.test.ts Proxy config resolution tests: scheme validation, credential extraction, profile inheritance, edge cases
src/browser/chrome.proxy-launch.test.ts Launch-layer tests: --proxy-server arg injection, credential stripping, profile override
docs/tools/browser.md Proxy configuration docs with auth and per-profile examples

Why CDP for auth?

Chrome's --proxy-server silently ignores inline credentials (user:pass@host). When a proxy returns 407, we intercept it via CDP Fetch.authRequired and respond with the configured credentials. This is the same underlying mechanism Puppeteer uses for page.authenticate(), extended to the browser level via Target.setAutoAttach so it covers all tabs automatically.

Testing

  • pnpm build && pnpm check && pnpm test — all pass
  • Unit tests for proxy config resolution (scheme validation, credential extraction, profile inheritance, edge cases)
  • Launch-layer tests for --proxy-server arg injection and credential stripping
  • Manually verified with HTTP (no-auth), HTTP (auth), and SOCKS5 (auth) proxies

AI disclosure

  • AI-assisted: Claude + Codex
  • Testing degree: fully tested (pnpm build && pnpm check && pnpm test + targeted proxy unit/launch tests + manual proxy verification)
  • Prompts/session logs: available on request
  • Human review: I reviewed all changes and understand the implementation

Closes #8079

Greptile Summary

Adds native proxy support to the browser tool with HTTP, HTTPS, and SOCKS5 protocol support. Proxy credentials are extracted from URLs and injected via CDP's Fetch domain to handle 407 authentication challenges, since Chrome's --proxy-server doesn't support inline credentials. The implementation includes per-profile proxy overrides with proper fallback to global config, comprehensive test coverage for config resolution and launch behavior, and clear documentation with security notes.

Key changes:

  • Config validation via parseProxyUrl() with scheme validation, credential extraction, and port checking
  • CDP-based proxy authentication via setupCdpProxyAuth() that attaches to all page targets
  • Per-profile proxy inheritance with credential override support
  • Full test coverage: 17 config tests + 2 launch tests covering schemes, credentials, inheritance, and edge cases

Issue found:

  • CDP WebSocket in setupCdpProxyAuth lacks error handling and is never cleaned up (see inline comment)

Confidence Score: 4/5

  • Safe to merge with one WebSocket cleanup issue that should be addressed
  • Implementation is well-designed with proper credential handling, comprehensive tests (19 total), and good documentation. The CDP-based auth approach correctly handles Chrome's limitation with inline proxy credentials. However, the WebSocket connection in setupCdpProxyAuth lacks error handling and cleanup, which could cause resource leaks during long browser sessions. This is a minor issue that doesn't affect core functionality but should be fixed.
  • Pay attention to src/browser/chrome.ts (WebSocket lifecycle management)

Last reviewed commit: 78eccb7

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: L labels Feb 19, 2026

@greptile-apps greptile-apps 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.

7 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread src/browser/chrome.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 78eccb71d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/chrome.ts Resolved
@Myasuka

Myasuka commented Feb 26, 2026

Copy link
Copy Markdown

I think this PR shoud be merged to have stronger proxy power, @illusivejosiah could you update this PR to resovle conflicts?

@illusivejosiah
illusivejosiah force-pushed the feat/browser-proxy-config branch from c2feacc to eed19e9 Compare February 26, 2026 16:27

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eed19e9c21

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/chrome.ts Resolved
@illusivejosiah
illusivejosiah force-pushed the feat/browser-proxy-config branch from 7d4f0ad to 4e8fc84 Compare February 27, 2026 11:01

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e8fc849d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/config.ts Resolved
@illusivejosiah
illusivejosiah force-pushed the feat/browser-proxy-config branch from 4e8fc84 to b00827a Compare March 2, 2026 16:31
@illusivejosiah

illusivejosiah commented Mar 2, 2026 •

Copy link
Copy Markdown
Author

Rebased onto latest upstream/main and fixed a credential isolation bug:

Fix (new commit): When a profile sets its own proxy URL without credentials (e.g. socks5://work-proxy:1080), the resolved profile no longer inherits the global proxy's credentials. Previously, proxyCredentials fell through via ?? to the global value, which would send the wrong credentials to a different proxy server — causing repeated 407 failures. Credentials now only inherit when the profile doesn't specify its own proxy at all. Added test coverage for this edge case.

All 50 proxy tests passing.

@sebslight this PR supersedes the extraArgs escape hatch from #18443 with a proper browser.proxy config key (HTTP/HTTPS/SOCKS5 + authenticated proxies via CDP + per-profile overrides). @Myasuka already noted this in #18823. Would you be open to reviewing as the path forward? Conflicts resolved, CI should be green.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b00827a3d6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/chrome.ts Resolved
Comment thread src/browser/chrome.ts Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 06778c52d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/browser/chrome.ts Resolved
@openclaw-barnacle openclaw-barnacle Bot added channel: googlechat Channel integration: googlechat gateway Gateway runtime extensions: phone-control labels Mar 2, 2026
Non-page targets (workers, service workers) attaching first via
Target.setAutoAttach could prematurely resolve the startup readiness
promise before any page session had Fetch.enable, racing into a 407.

Now only page target attachments signal launch readiness, while Fetch
auth is still enabled on all sessions for full coverage.
When a profile specifies its own proxy URL without credentials,
don't fall through to global proxy credentials via nullish coalescing.
A profile proxy without auth means no auth — not 'use the global creds'.
@illusivejosiah
illusivejosiah force-pushed the feat/browser-proxy-config branch from d70f8dc to eef6bc5 Compare March 2, 2026 16:51
@openclaw-barnacle openclaw-barnacle Bot removed the channel: googlechat Channel integration: googlechat label Mar 2, 2026

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: eef6bc59d9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread docs/tools/browser.md Resolved
@illusivejosiah

illusivejosiah commented Mar 2, 2026 •

Copy link
Copy Markdown
Author

@vincentkoc saw you working on #31312 for the CDP proxy bypass. Our PR already handles that (commit d70f8dcd7 switches CDP discovery to getChromeWebSocketUrl which bypasses HTTP_PROXY for loopback probes), along with the full browser.proxy config surface: HTTP/HTTPS/SOCKS5, authenticated proxies via CDP Fetch.authRequired, per-profile overrides, and credential isolation. Would appreciate your eyes on this when you have a moment.

@m00dy

m00dy commented Mar 4, 2026

Copy link
Copy Markdown

Hello,

We are @proxybasehq, and eagerly waiting for this feature to be merged.

@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Mar 18, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #pr-thunderdome-dangerzone on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation size: L stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add proxy configuration option for browser tool

3 participants