Agent Zero AI framework
Simplify Host Browser config
Alessandro001c7e2ccbf5
diff --git a/plugins/_browser/default_config.yaml b/plugins/_browser/default_config.yamlindex 89b1111be..377ae5f65 100644--- a/plugins/_browser/default_config.yaml+++ b/plugins/_browser/default_config.yaml@@ -10,8 +10,7 @@ autofocus_active_page: true# Runtime used by the agent-facing browser tool:# - container: use Agent Zero's Docker/server Playwright browser.-# - host_when_available: use A0 CLI host browser when a subscribed CLI can provide it, otherwise container.-# - host_required: require A0 CLI host browser and prepare it on first browser use when possible.+# - host_required: Bring Your Own Browser through A0 CLI and prepare it on first browser use when possible.runtime_backend: "container"# Local-model enforcement for host-browser content:diff --git a/plugins/_browser/helpers/selector.py b/plugins/_browser/helpers/selector.pyindex 061f8c977..1f348cebb 100644--- a/plugins/_browser/helpers/selector.py+++ b/plugins/_browser/helpers/selector.py@@ -2,6 +2,7 @@ from __future__ import annotationsfrom typing import Any+from helpers.errors import RepairableExceptionfrom plugins._browser.helpers.config import RUNTIME_BACKEND_KEY, get_browser_configfrom plugins._browser.helpers.runtime import get_runtime as get_container_runtime@@ -22,11 +23,14 @@ async def get_tool_runtime(agent: Any):if backend == "host_required":detail = _host_browser_status_detail(context_id)- raise RuntimeError(- "Browser host_required mode is enabled, but no subscribed A0 CLI currently "+ message = (+ "Bring Your Own Browser mode is enabled, but no subscribed A0 CLI currently ""advertises host-browser support"+ (f": {detail}" if detail else "."))+ raise RepairableException(+ f"{message} Connect A0 CLI to this chat, allow host browser access, and retry."+ )return await get_container_runtime(context_id)diff --git a/plugins/_browser/webui/browser-config-store.js b/plugins/_browser/webui/browser-config-store.jsindex ce9484855..a40932405 100644--- a/plugins/_browser/webui/browser-config-store.js+++ b/plugins/_browser/webui/browser-config-store.js@@ -3,7 +3,7 @@ import { callJsonApi } from "/js/api.js";const BROWSER_EXTENSIONS_API = "/plugins/_browser/extensions";const BROWSER_STATUS_API = "/plugins/_browser/status";-const RUNTIME_BACKENDS = new Set(["container", "host_when_available", "host_required"]);+const RUNTIME_BACKENDS = new Set(["container", "host_required"]);const HOST_PRIVACY_POLICIES = new Set(["enforce_local", "warn", "allow"]);function normalizePathList(value) {@@ -26,7 +26,7 @@ function ensureConfig(config) {config.extension_paths = normalizePathList(config.extension_paths);config.default_homepage = String(config.default_homepage || "about:blank").trim() || "about:blank";config.autofocus_active_page = normalizeBoolean(config.autofocus_active_page, true);- config.runtime_backend = normalizeChoice(config.runtime_backend, RUNTIME_BACKENDS, "container");+ config.runtime_backend = normalizeRuntimeBackend(config.runtime_backend);config.host_browser_privacy_policy = normalizeChoice(config.host_browser_privacy_policy,HOST_PRIVACY_POLICIES,@@ -42,6 +42,12 @@ function normalizeChoice(value, allowed, fallback) {return allowed.has(normalized) ? normalized : fallback;}+function normalizeRuntimeBackend(value) {+ const normalized = String(value || "").trim().toLowerCase().replace(/-/g, "_");+ if (normalized === "host_when_available") return "host_required";+ return RUNTIME_BACKENDS.has(normalized) ? normalized : "container";+}+function normalizeBoolean(value, fallback = true) {if (value === undefined || value === null || value === "") return fallback;if (typeof value === "boolean") return value;@@ -122,8 +128,7 @@ export const store = createStore("browserConfig", {runtimeBackendLabel() {const value = this.config?.runtime_backend || "container";- if (value === "host_when_available") return "Use Host When Ready";- if (value === "host_required") return "Require Host Browser";+ if (value === "host_required") return "Bring Your Own Browser";return "Docker Browser";},diff --git a/plugins/_browser/webui/config.html b/plugins/_browser/webui/config.htmlindex 33e5bca47..509d15a9e 100644--- a/plugins/_browser/webui/config.html+++ b/plugins/_browser/webui/config.html@@ -60,10 +60,14 @@<span class="browser-config-field-label">Browser location</span><select x-model="$store.browserConfig.config.runtime_backend"><option value="container">Docker browser</option>- <option value="host_when_available">Use host when ready</option>- <option value="host_required">Require host browser</option>+ <option value="host_required">Bring Your Own Browser</option></select>- <span class="browser-config-field-help">Require host browser when pages must stay on this computer.</span>+ <span+ class="browser-config-field-help"+ x-show="$store.browserConfig.config.runtime_backend === 'host_required'"+ >+ Use Google Chrome or a Chromium family browser. Visit chrome://inspect#remote-debugging and enable "Allow remote debugging".+ </span></label><label class="browser-config-field">diff --git a/tests/test_host_browser_connector.py b/tests/test_host_browser_connector.pyindex fe5af96fb..fe234ae9e 100644--- a/tests/test_host_browser_connector.py+++ b/tests/test_host_browser_connector.py@@ -11,6 +11,7 @@ PROJECT_ROOT = Path(__file__).resolve().parents[1]if str(PROJECT_ROOT) not in sys.path:sys.path.insert(0, str(PROJECT_ROOT))+from helpers.errors import RepairableExceptionfrom plugins._a0_connector.helpers import ws_runtimefrom plugins._browser.helpers.connector_runtime import (ConnectorBrowserRuntime,@@ -22,6 +23,19 @@ def _agent(context_id: str = "ctx-host"):return SimpleNamespace(context=SimpleNamespace(id=context_id))+def test_host_required_runtime_error_is_repairable(monkeypatch):+ from plugins._browser.helpers import selector as browser_selector++ monkeypatch.setattr(+ browser_selector,+ "get_browser_config",+ lambda agent=None: {"runtime_backend": "host_required"},+ )++ with pytest.raises(RepairableException, match="Bring Your Own Browser"):+ asyncio.run(browser_selector.get_tool_runtime(_agent("ctx-host-required-missing")))++def test_host_browser_metadata_selection_is_context_scoped():sid = "sid-host-browser"context_id = "ctx-host-browser"