browser-ipc-cdp 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/brave_ipc.py +118 -33
- package/package.json +1 -1
package/brave_ipc.py
CHANGED
|
@@ -33,35 +33,109 @@ from pathlib import Path
|
|
|
33
33
|
CONFIG_FILE = Path(__file__).parent / "browser_config.json"
|
|
34
34
|
IPC_INFO_FILE = Path(__file__).parent / "cdp_info.json"
|
|
35
35
|
|
|
36
|
-
# Rutas de búsqueda por navegador
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
36
|
+
# Rutas de búsqueda por navegador, según sistema operativo.
|
|
37
|
+
# Path(p).exists() filtra las que no aplican, pero separamos por plataforma
|
|
38
|
+
# para no depender de %VARS% de Windows en Mac/Linux (no se expanden ahí).
|
|
39
|
+
_HOME = Path.home()
|
|
40
|
+
|
|
41
|
+
if sys.platform == "win32":
|
|
42
|
+
BROWSER_SEARCH_PATHS = {
|
|
43
|
+
"brave": [
|
|
44
|
+
r"C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe",
|
|
45
|
+
r"C:\Program Files (x86)\BraveSoftware\Brave-Browser\Application\brave.exe",
|
|
46
|
+
os.path.expandvars(r"%LOCALAPPDATA%\BraveSoftware\Brave-Browser\Application\brave.exe"),
|
|
47
|
+
],
|
|
48
|
+
"chrome": [
|
|
49
|
+
r"C:\Program Files\Google\Chrome\Application\chrome.exe",
|
|
50
|
+
r"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe",
|
|
51
|
+
os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe"),
|
|
52
|
+
],
|
|
53
|
+
"edge": [
|
|
54
|
+
r"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe",
|
|
55
|
+
r"C:\Program Files\Microsoft\Edge\Application\msedge.exe",
|
|
56
|
+
],
|
|
57
|
+
"chromium": [
|
|
58
|
+
os.path.expandvars(r"%LOCALAPPDATA%\Chromium\Application\chrome.exe"),
|
|
59
|
+
],
|
|
60
|
+
}
|
|
61
|
+
BROWSER_USER_DATA = {
|
|
62
|
+
"brave": os.path.expandvars(r"%LOCALAPPDATA%\BraveSoftware\Brave-Browser\User Data"),
|
|
63
|
+
"chrome": os.path.expandvars(r"%LOCALAPPDATA%\Google\Chrome\User Data"),
|
|
64
|
+
"edge": os.path.expandvars(r"%LOCALAPPDATA%\Microsoft\Edge\User Data"),
|
|
65
|
+
"chromium": os.path.expandvars(r"%LOCALAPPDATA%\Chromium\User Data"),
|
|
66
|
+
}
|
|
67
|
+
elif sys.platform == "darwin":
|
|
68
|
+
BROWSER_SEARCH_PATHS = {
|
|
69
|
+
"brave": [
|
|
70
|
+
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser",
|
|
71
|
+
str(_HOME / "Applications/Brave Browser.app/Contents/MacOS/Brave Browser"),
|
|
72
|
+
],
|
|
73
|
+
"chrome": [
|
|
74
|
+
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
|
|
75
|
+
],
|
|
76
|
+
"edge": [
|
|
77
|
+
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge",
|
|
78
|
+
],
|
|
79
|
+
"chromium": [
|
|
80
|
+
"/Applications/Chromium.app/Contents/MacOS/Chromium",
|
|
81
|
+
],
|
|
82
|
+
}
|
|
83
|
+
_APP_SUPPORT = _HOME / "Library/Application Support"
|
|
84
|
+
BROWSER_USER_DATA = {
|
|
85
|
+
"brave": str(_APP_SUPPORT / "BraveSoftware/Brave-Browser"),
|
|
86
|
+
"chrome": str(_APP_SUPPORT / "Google/Chrome"),
|
|
87
|
+
"edge": str(_APP_SUPPORT / "Microsoft Edge"),
|
|
88
|
+
"chromium": str(_APP_SUPPORT / "Chromium"),
|
|
89
|
+
}
|
|
90
|
+
else: # linux y otros unix
|
|
91
|
+
BROWSER_SEARCH_PATHS = {
|
|
92
|
+
"brave": [
|
|
93
|
+
"/usr/bin/brave-browser",
|
|
94
|
+
"/usr/bin/brave-browser-stable",
|
|
95
|
+
"/opt/brave.com/brave/brave",
|
|
96
|
+
"/snap/bin/brave",
|
|
97
|
+
str(_HOME / ".local/share/flatpak/exports/bin/com.brave.Browser"),
|
|
98
|
+
"/var/lib/flatpak/exports/bin/com.brave.Browser",
|
|
99
|
+
],
|
|
100
|
+
"chrome": [
|
|
101
|
+
"/usr/bin/google-chrome",
|
|
102
|
+
"/usr/bin/google-chrome-stable",
|
|
103
|
+
"/opt/google/chrome/chrome",
|
|
104
|
+
],
|
|
105
|
+
"edge": [
|
|
106
|
+
"/usr/bin/microsoft-edge",
|
|
107
|
+
"/opt/microsoft/msedge/msedge",
|
|
108
|
+
],
|
|
109
|
+
"chromium": [
|
|
110
|
+
"/usr/bin/chromium",
|
|
111
|
+
"/usr/bin/chromium-browser",
|
|
112
|
+
"/snap/bin/chromium",
|
|
113
|
+
],
|
|
114
|
+
}
|
|
115
|
+
_CONFIG = _HOME / ".config"
|
|
116
|
+
BROWSER_USER_DATA = {
|
|
117
|
+
"brave": str(_CONFIG / "BraveSoftware/Brave-Browser"),
|
|
118
|
+
"chrome": str(_CONFIG / "google-chrome"),
|
|
119
|
+
"edge": str(_CONFIG / "microsoft-edge"),
|
|
120
|
+
"chromium": str(_CONFIG / "chromium"),
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# Nombres de ejecutable a buscar en el PATH (fallback), por plataforma.
|
|
124
|
+
if sys.platform == "win32":
|
|
125
|
+
BROWSER_PATH_CMDS = ["brave", "chrome", "msedge", "chromium"]
|
|
126
|
+
elif sys.platform == "darwin":
|
|
127
|
+
BROWSER_PATH_CMDS = ["brave", "brave-browser", "google-chrome", "chromium"]
|
|
128
|
+
else:
|
|
129
|
+
BROWSER_PATH_CMDS = [
|
|
130
|
+
"brave-browser", "brave-browser-stable", "brave",
|
|
131
|
+
"google-chrome", "google-chrome-stable",
|
|
132
|
+
"chromium", "chromium-browser", "microsoft-edge",
|
|
133
|
+
]
|
|
134
|
+
|
|
135
|
+
if sys.platform == "win32":
|
|
136
|
+
CLEAN_USER_DATA = Path(os.path.expandvars(r"%USERPROFILE%\browser-cdp-profile"))
|
|
137
|
+
else:
|
|
138
|
+
CLEAN_USER_DATA = _HOME / "browser-cdp-profile"
|
|
65
139
|
|
|
66
140
|
|
|
67
141
|
# ─── Utilidades ───────────────────────────────────────────────────────────────
|
|
@@ -89,11 +163,22 @@ def detect_browsers() -> list[dict]:
|
|
|
89
163
|
if Path(p).exists():
|
|
90
164
|
found.append({"name": name, "exe": p, "user_data": BROWSER_USER_DATA.get(name, "")})
|
|
91
165
|
break
|
|
92
|
-
# Buscar también en PATH
|
|
93
|
-
for cmd in
|
|
94
|
-
exe = shutil.which(cmd) or shutil.which(f"{cmd}.exe")
|
|
166
|
+
# Buscar también en PATH (nombres de binario según plataforma)
|
|
167
|
+
for cmd in BROWSER_PATH_CMDS:
|
|
168
|
+
exe = shutil.which(cmd) or (shutil.which(f"{cmd}.exe") if sys.platform == "win32" else None)
|
|
95
169
|
if exe and not any(b["exe"] == exe for b in found):
|
|
96
|
-
|
|
170
|
+
# Normaliza el nombre lógico para reusar BROWSER_USER_DATA
|
|
171
|
+
if "brave" in cmd:
|
|
172
|
+
name = "brave"
|
|
173
|
+
elif "chrome" in cmd:
|
|
174
|
+
name = "chrome"
|
|
175
|
+
elif "edge" in cmd:
|
|
176
|
+
name = "edge"
|
|
177
|
+
elif "chromium" in cmd:
|
|
178
|
+
name = "chromium"
|
|
179
|
+
else:
|
|
180
|
+
name = cmd
|
|
181
|
+
found.append({"name": name, "exe": exe, "user_data": BROWSER_USER_DATA.get(name, "")})
|
|
97
182
|
return found
|
|
98
183
|
|
|
99
184
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-ipc-cdp",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "Control remoto de navegadores Chromium (Brave, Chrome, Edge) via IPC + CDP dinamico. Un comando para conectar Claude Code a tu navegador real.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"browser-ipc-cdp": "bin/cli.js",
|