Agent Zero AI framework
Fix SOCKS proxy support for HTTPX clients
Alessandro335811833a22
diff --git a/AGENTS.md b/AGENTS.mdindex 19dfbd60a..0f10a19c0 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -20,6 +20,7 @@- Native function calls use canonical call content for history and repeat comparison, even when accompanied by commentary. The canonical content passes through the normal history template/masking hook; provider output metadata remains intact.- `initialize.py` owns framework initialization.- `models.py` owns model-provider configuration and LiteLLM integration.+- `requirements.txt` includes HTTPX's SOCKS extra so framework clients support SOCKS proxy environment variables before plugin setup.- Native agent-turn response callbacks may receive a display-only commentary preview as their full text; legacy callbacks, accumulated model output, usage and native dispatch retain the original text and result metadata.- `run_ui.py` is the WebUI entry point.- `DockerfileLocal` must remain compatible with the contracts under `docker/`.diff --git a/plugins/_browser/AGENTS.md b/plugins/_browser/AGENTS.mdindex aa9f4aa96..352dea43e 100644--- a/plugins/_browser/AGENTS.md+++ b/plugins/_browser/AGENTS.md@@ -61,6 +61,7 @@- Browser keyboard layout settings (`keyboard_layout`/`keyboard_variant`, e.g. `de`/`mac`) apply the configured XKB layout to the private browser display with setxkbmap and pin it on the Xpra shadow server so non-US keyboards type their printed characters; layout changes flow through `browser_runtime_config` and restart internal runtimes. Fallback canvas input forwards AltGraph and macOS Option text without converting ordinary Alt shortcuts into text.- Browser startup and on-demand launch must converge on the Chromium revision declared by Patchright; let its installer select the host architecture rather than hardcoding x64 or ARM downloads.- `hooks.prepare_playwright_cache()` owns reconciliation of the pinned Patchright package and Chromium binary so repository self-updates and fresh images use the same setup path.+- `hooks.install()` also installs HTTPX's SOCKS extra in the framework runtime when `socksio` is missing; this supports shared HTTP clients using proxy environment variables independently of Chromium's proxy settings.- Browser startup must install the shared virtual-desktop route hook itself; do not make Browser depend on the Desktop plugin being enabled.- Use shared `surface-workspace`, toolbar/control, and separator styles from `webui/css/surfaces.css`; match the lighter Files/Browser panel palette and preserve disabled, active, and keyboard focus states.diff --git a/plugins/_browser/hooks.py b/plugins/_browser/hooks.pyindex 8ccd83981..b6194ab25 100644--- a/plugins/_browser/hooks.py+++ b/plugins/_browser/hooks.py@@ -118,6 +118,18 @@ def prepare_playwright_cache() -> dict:def install() -> dict:+ with _SETUP_LOCK:+ if importlib.util.find_spec("socksio") is None:+ uv = shutil.which("uv")+ if not uv:+ raise RuntimeError("Browser plugin requires 'uv' to install HTTPX SOCKS support")+ subprocess.check_call(+ [uv, "pip", "install", "--python", sys.executable, "httpx[socks]"],+ cwd=str(_PLUGIN_DIR),+ )+ importlib.invalidate_caches()+ if importlib.util.find_spec("socksio") is None:+ raise RuntimeError("Browser dependency 'socksio' is unavailable after installation")return prepare_playwright_cache()diff --git a/requirements.txt b/requirements.txtindex f98491147..bd1cbeeee 100644--- a/requirements.txt+++ b/requirements.txt@@ -11,6 +11,7 @@ flask-basicauth==0.2.0flaredantic==0.1.5GitPython==3.1.43giturlparse==0.14.0+httpx[socks]==0.28.1inputimeout==1.0.4json_repair==0.63.4kokoro>=0.9.2diff --git a/tests/test_browser_agent_regressions.py b/tests/test_browser_agent_regressions.pyindex 215f77388..8d32b81c6 100644--- a/tests/test_browser_agent_regressions.py+++ b/tests/test_browser_agent_regressions.py@@ -666,6 +666,40 @@ def test_browser_hook_installs_patchright_for_existing_self_updated_runtime(monkassert current is True[email protected]("socks_installed", [False, True])+def test_browser_install_ensures_httpx_socks_support(monkeypatch, socks_installed):+ installed = socks_installed+ calls = []++ def find_spec(name):+ assert name == "socksio"+ return object() if installed else None++ def install(command, *, cwd):+ nonlocal installed+ assert command == [+ "/usr/local/bin/uv", "pip", "install", "--python", sys.executable,+ "httpx[socks]",+ ]+ assert cwd == str(PROJECT_ROOT / "plugins" / "_browser")+ calls.append(command)+ installed = True++ def prepare():+ assert installed+ return {"binary": "chromium"}++ monkeypatch.setattr(browser_hooks_module.importlib.util, "find_spec", find_spec)+ monkeypatch.setattr(browser_hooks_module.shutil, "which", lambda name: "/usr/local/bin/uv")+ monkeypatch.setattr(browser_hooks_module.subprocess, "check_call", install)+ monkeypatch.setattr(browser_hooks_module, "prepare_playwright_cache", prepare)++ assert browser_hooks_module.install() == {"binary": "chromium"}+ assert len(calls) == (0 if socks_installed else 1)+ assert browser_hooks_module.install() == {"binary": "chromium"}+ assert len(calls) == (0 if socks_installed else 1)++def _write_playwright_binary(cache_dir: Path) -> Path:browser_binary = cache_dir / "chromium-1169" / "chrome-linux" / "chrome"browser_binary.parent.mkdir(parents=True)