Open-source Python library for AI browser agents, plus Browser Use Cloud: stealth browsers and a hosted agent API.
Python ai-agentsai-toolsbrowser-agentbrowser-automationbrowser-usecdpcloud-browsercomputer-useheadless-browserllmmcpplaywrightpythonremote-browserstealth-browserweb-automationweb-scraping
Bridge BrowserProfile permissions
Magnus Müller4840a65d3763
diff --git a/RUST_AGENT_INTEGRATION_FEATURES.md b/RUST_AGENT_INTEGRATION_FEATURES.mdindex 0ea4579a9..e38c4d15f 100644--- a/RUST_AGENT_INTEGRATION_FEATURES.md+++ b/RUST_AGENT_INTEGRATION_FEATURES.md@@ -160,14 +160,20 @@ Terminal core branch: `magnus/browser-use-rust-integration` at latest pulled mai- This works with the managed `user_data_dir` bridge so callers can target a named Chrome profile inside the persistent profile root.- Proof: `test_rust_agent_translates_browser_profile_profile_directory`.+31. BrowserProfile permissions bridge+ - `BrowserProfile.permissions` is serialized into `BU_BROWSER_PERMISSIONS`.+ - The terminal core parses that JSON permission list and calls CDP `Browser.grantPermissions` after connecting to managed, local, remote-CDP, or cloud browsers.+ - Proof: `test_rust_agent_translates_browser_profile_permissions` and `browser_permissions_env_parses_json_array`.+## Current Verification- `python3 -m py_compile browser_use/rust/service.py browser_use/rust/__init__.py browser_use/__init__.py tests/ci/test_rust_agent.py examples/rust_agent/basic.py examples/rust_agent/real_v8_smoke.py`-- `uv run pytest -q tests/ci/test_rust_agent.py` (40 tests)+- `uv run pytest -q tests/ci/test_rust_agent.py` (41 tests)- `cargo build -q -p browser-use-cli`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent selected_remote_cdp_mode_allows_remote_cdp_connect -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent bare_browser_connect_resolves_to_selected_managed_mode_with_launch_args -- --nocapture`- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-agent bare_browser_connect_resolves_to_selected_managed_mode_with_profile_dir -- --nocapture`+- `CARGO_INCREMENTAL=0 cargo test -q -p browser-use-browser browser_permissions_env_parses_json_array -- --nocapture`- Managed-headless end-to-end:- `BROWSER_USE_TERMINAL_BINARY=/home/exedev/Developer/terminal/target/debug/browser-use-terminal BROWSER_USE_RUST_BROWSER_MODE=managed-headless BU_TASK='Open https://example.com and report the page title only.' BU_MAX_STEPS=12 timeout 300 uv run python examples/rust_agent/basic.py`- Output: `Example Domain`diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 7fe31676b..919f90849 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -229,6 +229,24 @@ def _managed_browser_env(browser_session: BrowserSession | None, browser_profilereturn env+def _extract_profile_permissions(browser_session: BrowserSession | None, browser_profile: BrowserProfile | None) -> list[str]:+ values: list[str] = []+ seen: set[str] = set()+ session_profile = getattr(browser_session, 'browser_profile', None)+ for profile in (session_profile, browser_profile):+ raw_permissions = getattr(profile, 'permissions', None)+ if isinstance(raw_permissions, set):+ raw_permissions = sorted(raw_permissions)+ if not isinstance(raw_permissions, (list, tuple)):+ continue+ for permission in raw_permissions:+ if not isinstance(permission, str) or not permission or permission in seen:+ continue+ values.append(permission)+ seen.add(permission)+ return values++def _is_managed_browser_mode(mode: str) -> bool:normalized = mode.strip().lower().replace('_', '-').replace(' ', '-')return normalized in {'managed-headless', 'headless', 'headless-chromium', 'managed-headed', 'managed', 'headed'}@@ -759,6 +777,7 @@ class Agent(Generic[AgentStructuredOutput]):self.managed_browser_profile_dir = _managed_browser_profile_dir(self.browser_session, self.browser_profile)self.managed_browser_executable_path = _managed_browser_executable_path(self.browser_session, self.browser_profile)self.managed_browser_env = _managed_browser_env(self.browser_session, self.browser_profile)+ self.browser_permissions = _extract_profile_permissions(self.browser_session, self.browser_profile)self.sensitive_data_context = _sensitive_data_context(sensitive_data)self.display_files_in_done_text = display_files_in_done_textself.file_system_path = file_system_path@@ -1204,6 +1223,8 @@ class Agent(Generic[AgentStructuredOutput]):cdp_url = _extract_cdp_url(self.browser_session) or _extract_profile_cdp_url(self.browser_profile)if cdp_url:env['BU_CDP_URL'] = cdp_url+ if self.browser_permissions:+ env['BU_BROWSER_PERMISSIONS'] = json.dumps(self.browser_permissions)if self.managed_browser_env and _is_managed_browser_mode(browser_mode):env.update(self.managed_browser_env)if self.managed_browser_args and _is_managed_browser_mode(browser_mode):diff --git a/tests/ci/test_rust_agent.py b/tests/ci/test_rust_agent.pyindex cf5b98b97..0e5e38308 100644--- a/tests/ci/test_rust_agent.py+++ b/tests/ci/test_rust_agent.py@@ -346,6 +346,23 @@ def test_rust_agent_translates_browser_profile_profile_directory(monkeypatch):assert '--profile-directory=Profile 7' in launch_args+def test_rust_agent_translates_browser_profile_permissions(monkeypatch):+ from browser_use.rust import Agent++ class BrowserProfile:+ permissions = ['clipboardReadWrite', 'notifications', 'clipboardReadWrite']+ cdp_url = 'http://127.0.0.1:9222'++ monkeypatch.setenv('BROWSER_USE_TERMINAL_BINARY', '/tmp/browser-use-terminal')++ agent = Agent(task='report title', browser_profile=BrowserProfile())+ env = agent._run_env()++ assert env['LLM_BROWSER_BROWSER_MODE'] == 'remote-cdp'+ assert agent.browser_permissions == ['clipboardReadWrite', 'notifications']+ assert json.loads(env['BU_BROWSER_PERMISSIONS']) == ['clipboardReadWrite', 'notifications']++def test_rust_agent_translates_browser_profile_user_data_dir(monkeypatch, tmp_path):from browser_use.rust import Agent