The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(bot-screen): dock Browser follows the agent-browser sandbox policy in containers too
teknium1069465f3b5b4
diff --git a/tests/tools/test_bot_desktop_browser.py b/tests/tools/test_bot_desktop_browser.pyindex dc1313730a9..98d46165bb8 100644--- a/tests/tools/test_bot_desktop_browser.py+++ b/tests/tools/test_bot_desktop_browser.py@@ -146,6 +146,18 @@ def test_root_dock_browser_starts_with_the_same_sandbox_args_as_the_agents_browsassert agent_flags, "root must inject sandbox flags for agent-browser"assert agent_flags <= set(browser.dock_argv("/opt/chrome", "/p/dir"))+ # Same policy for the NON-root container case (the official image runs the gateway as uid 10000 in+ # Docker): agent-browser bypasses the sandbox there, and the dock icon must too or it dies on click.+ monkeypatch.setattr(session.os, "geteuid", lambda: 10000)+ monkeypatch.setattr(browser.os, "geteuid", lambda: 10000)+ monkeypatch.setattr(session._install, "_running_in_docker", lambda: True)+ docker_env: dict = {}+ session._apply_chromium_sandbox_args(docker_env)+ assert set(docker_env["AGENT_BROWSER_ARGS"].split(",")) <= set(browser.dock_argv("/opt/chrome", "/p/dir"))+ monkeypatch.setattr(session._install, "_running_in_docker", lambda: False)+ monkeypatch.setattr(session, "apparmor_restricts_unprivileged_userns", lambda: False)+ assert "--no-sandbox" not in browser.dock_argv("/opt/chrome", "/p/dir") # seated non-root host: sandboxed+def test_status_reports_the_headed_browser_or_its_absence(monkeypatch):"""The official image ships only chromium_headless_shell: executable() is None and the dock silentlydiff --git a/tools/bot_desktop/browser.py b/tools/bot_desktop/browser.pyindex 161942e3b44..cb77cb62d34 100644--- a/tools/bot_desktop/browser.py+++ b/tools/bot_desktop/browser.py@@ -89,10 +89,13 @@ def dock_argv(exe: str, user_data_dir: str) -> list[str]:first-run / default-browser dialogs would sit between the human and the bot's tabs."""# --test-type hides the "Chrome for Testing is only for automated testing" and unsupported-flag# (--no-sandbox as root) infobars, which otherwise sit at the top of the human's takeover view.- # Root gets the same sandbox-bypass flags agent-browser starts this binary with (one policy).- from tools.browser_tool_session import CHROMIUM_SANDBOX_BYPASS_ARGS+ # The same sandbox policy agent-browser starts this binary with (root, Docker, AppArmor userns): the+ # human's Browser is the bot's browser, in the same container; a stricter rule here just made the dock+ # icon die with 'No usable sandbox!' in the official image while the agent's own Chromium ran fine.+ from tools.browser_tool_session import CHROMIUM_SANDBOX_BYPASS_ARGS, _needs_chromium_sandbox_bypassreturn [exe, f"--user-data-dir={user_data_dir}", "--remote-debugging-port=0", "--no-first-run",- "--no-default-browser-check", "--test-type", *(CHROMIUM_SANDBOX_BYPASS_ARGS if _is_root() else ())]+ "--no-default-browser-check", "--test-type",+ *(CHROMIUM_SANDBOX_BYPASS_ARGS if _needs_chromium_sandbox_bypass() else ())]def dock_exec_line(exe: str, user_data_dir: str) -> str: