agent-zero/plugins/_browser/hooks.py
Alessandro 983d431a5e browser: replace browser-use agent with native browser
Introduce the new built-in Browser plugin for Agent Zero, replacing the legacy
browser-use-based browser agent with a direct Playwright-powered browser tool,
live WebUI viewer, browser session controls, status APIs, configuration, and
extension-management support.

Add browser-specific modal behavior so the browser can run as a floating,
resizable, no-backdrop window, including modal focus, toggle, and idempotent
open helpers for richer WebUI surfaces.

Remove the old `_browser_agent` core plugin and the `browser-use` dependency,
then clean up stale browser-model wiring and references across agent code,
model configuration docs, setup guides, troubleshooting docs, skills, and
Agent Zero knowledge.

Update regression and WebUI extension-surface coverage for the new browser
architecture and modal behavior.

The legacy browser-use implementation has been extracted from core so it can
continue separately as a community plugin published through the A0 Plugin Index for any user or professional that were relying on it for workflow.
2026-04-24 15:43:52 +02:00

47 lines
1.5 KiB
Python

from __future__ import annotations
from helpers import files, plugins, yaml as yaml_helper
from plugins._browser.helpers.config import (
PLUGIN_NAME,
browser_runtime_config,
normalize_browser_config,
)
from plugins._browser.helpers.runtime import close_all_runtimes_sync
def _load_saved_browser_config(project_name: str = "", agent_profile: str = "") -> dict:
entries = plugins.find_plugin_assets(
plugins.CONFIG_FILE_NAME,
plugin_name=PLUGIN_NAME,
project_name=project_name,
agent_profile=agent_profile,
only_first=True,
)
path = entries[0].get("path", "") if entries else ""
if path and files.exists(path):
return files.read_file_json(path) or {}
plugin_dir = plugins.find_plugin_dir(PLUGIN_NAME)
default_path = (
files.get_abs_path(plugin_dir, plugins.CONFIG_DEFAULT_FILE_NAME)
if plugin_dir
else ""
)
if default_path and files.exists(default_path):
return yaml_helper.loads(files.read_file(default_path)) or {}
return {}
def get_plugin_config(default=None, **kwargs):
return normalize_browser_config(default)
def save_plugin_config(settings=None, project_name="", agent_profile="", **kwargs):
normalized = normalize_browser_config(settings)
current = normalize_browser_config(
_load_saved_browser_config(project_name=project_name, agent_profile=agent_profile)
)
if browser_runtime_config(normalized) != browser_runtime_config(current):
close_all_runtimes_sync()
return normalized