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
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user