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
Validate Rust terminal SDK server binary
Laith Weinbergerd7c153f0a0d4
diff --git a/browser_use/rust/service.py b/browser_use/rust/service.pyindex 91dbad3b0..1d206a7f5 100644--- a/browser_use/rust/service.py+++ b/browser_use/rust/service.py@@ -12,6 +12,7 @@ import mimetypesimport osimport reimport shutil+import subprocessimport tempfileimport timefrom collections.abc import Awaitable, Callable@@ -188,16 +189,14 @@ def find_browser_use_terminal_binary() -> str:but_home = Path(os.environ.get('BUT_HOME', '~/.browser-use-terminal')).expanduser()but_install_dir = Path(os.environ.get('BUT_INSTALL_DIR', '~/.local/bin')).expanduser()candidates = [- Path.cwd() / 'target' / 'debug' / 'browser-use-terminal',- Path.cwd().parent / 'terminal' / 'target' / 'debug' / 'browser-use-terminal',but_home / 'packages' / 'standalone' / 'current' / 'bin' / 'browser-use-terminal',but_install_dir / 'browser-use-terminal',]for candidate in candidates:- if candidate.exists():+ if candidate.exists() and _terminal_supports_sdk_server(candidate):return str(candidate)path_binary = shutil.which('browser-use-terminal')- if path_binary:+ if path_binary and _terminal_supports_sdk_server(Path(path_binary)):return path_binaryraise RustAgentError(f'Could not find browser-use-terminal. Install Browser Use Terminal with `{TERMINAL_INSTALL_COMMAND}`, '@@ -205,6 +204,21 @@ def find_browser_use_terminal_binary() -> str:)+def _terminal_supports_sdk_server(binary: Path) -> bool:+ """Return whether a terminal binary supports the SDK server subcommand required by this wrapper."""+ try:+ result = subprocess.run(+ [str(binary), '--help'],+ capture_output=True,+ text=True,+ timeout=5,+ check=False,+ )+ except (OSError, subprocess.SubprocessError):+ return False+ return 'sdk-server' in f'{result.stdout}\n{result.stderr}'++class RustSdkJsonRpcError(RustAgentError):"""Raised when the Rust SDK server returns a JSON-RPC error."""