move socket path into /tmp/.browser_cli subfolder with registry

This commit is contained in:
2026-04-09 08:46:50 +02:00
parent 50dc2bb5e5
commit 7c2fa9a9ac
3 changed files with 37 additions and 11 deletions
+4 -2
View File
@@ -20,7 +20,8 @@ import threading
import uuid
from pathlib import Path
REGISTRY_PATH = Path("/tmp/browser-cli-registry.json")
SOCKET_DIR = Path("/tmp/.browser_cli")
REGISTRY_PATH = SOCKET_DIR / "registry.json"
DEFAULT_ALIAS = "default"
SOCKET_PATH: str = "" # set after hello handshake
@@ -71,7 +72,7 @@ def _registry_remove(alias: str) -> None:
def _socket_path_for(alias: str) -> str:
safe = alias.replace(" ", "_").replace("/", "_")
return f"/tmp/browser-cli-{safe}.sock"
return str(SOCKET_DIR / f"{safe}.sock")
# --- Thread A: read messages from extension (stdin) ---
@@ -202,6 +203,7 @@ def main():
PENDING[msg_id] = q
write_native_message(sys.stdout.buffer, first_msg)
SOCKET_DIR.mkdir(mode=0o700, exist_ok=True)
sock_path = _socket_path_for(alias)
_registry_add(alias, sock_path)