fix that the cli still used the DEFAULT_SOCKET Const, give better error message when no browser found adding test for client and update cli test, and update version and readme
Package Extension / package-extension (push) Failing after 53s
Build & Publish Package / publish (push) Successful in 39s

This commit is contained in:
2026-04-10 02:14:59 +02:00
parent 147d1d4ca3
commit f18d2d5536
6 changed files with 59 additions and 11 deletions
+6 -3
View File
@@ -6,7 +6,7 @@ Profile selection order:
1. Explicit `profile` argument to send_command()
2. BROWSER_CLI_PROFILE environment variable
3. First entry in /tmp/.browser_cli/registry.json
4. Fallback: /tmp/.browser_cli/default.sock
4. Otherwise, no browser can be resolved automatically
"""
import json
import os
@@ -18,7 +18,6 @@ from typing import Any
SOCKET_DIR = Path("/tmp/.browser_cli")
REGISTRY_PATH = SOCKET_DIR / "registry.json"
DEFAULT_SOCKET = str(SOCKET_DIR / "default.sock")
class BrowserNotConnected(Exception):
@@ -64,7 +63,11 @@ def _resolve_socket(profile: str | None = None) -> str:
except Exception:
pass
return DEFAULT_SOCKET
raise BrowserNotConnected(
"Cannot resolve a browser socket automatically.\n"
"Make sure the browser is running with the browser-cli extension enabled,\n"
"or pass --browser <alias> / set BROWSER_CLI_PROFILE to a known alias."
)
def send_command(command: str, args: dict | None = None, profile: str | None = None) -> Any: