browser-ipc-cdp 1.2.0 → 1.4.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/bin/cli.js CHANGED
@@ -152,16 +152,28 @@ async function main() {
152
152
 
153
153
  // Resumen
154
154
  console.log('');
155
+ // URL correcta segun entorno
156
+ const cdpLocalUrl = `http://127.0.0.1:${port}`;
157
+ const cdpWslUrl = `http://${wslIp}:${port}`;
158
+ const cdpUrl = (IS_WSL || wslIp !== '127.0.0.1') ? cdpWslUrl : cdpLocalUrl;
159
+
155
160
  console.log('='.repeat(55));
156
161
  console.log(` MODO: ${mode}${mode === 'ATTACHED' ? ' (sin reiniciar)' : ' (nuevo proceso)'}`);
162
+ console.log(` Plataforma: ${platform}`);
157
163
  console.log(` Navegador: ${browserVersion}`);
158
164
  console.log(` Puerto CDP: ${port} (dinamico via IPC)`);
159
165
  console.log(` Paginas: ${pages}`);
160
- console.log(` WSL IP: ${wslIp}`);
161
- console.log(` Portproxy: 0.0.0.0:${port} -> 127.0.0.1:${port}`);
162
- console.log(` .mcp.json: Actualizado`);
163
166
  console.log('='.repeat(55));
164
167
  console.log('');
168
+ console.log(' URLs de conexion:');
169
+ console.log(` Desde Windows: ${cdpLocalUrl}`);
170
+ if (wslIp !== '127.0.0.1') {
171
+ console.log(` Desde WSL: ${cdpWslUrl}`);
172
+ }
173
+ console.log('');
174
+ console.log(' MCP configurado en .mcp.json:');
175
+ console.log(` browserUrl: ${cdpUrl}`);
176
+ console.log('');
165
177
  console.log(' Siguiente paso en Claude Code:');
166
178
  console.log(' /mcp (para conectar el MCP brave)');
167
179
  console.log('');
package/lib/mcp.js CHANGED
@@ -6,10 +6,12 @@ const { log, success, warn } = require('./logger');
6
6
  function getWslHostIp() {
7
7
  const IS_WIN = process.platform === 'win32';
8
8
 
9
- // Mac/Linux: localhost funciona directo, no necesita IP especial
10
- if (!IS_WIN) return '127.0.0.1';
9
+ // Mac/Linux nativo (sin WSL): localhost directo
10
+ if (!IS_WIN && !fs.existsSync('/proc/version')) return '127.0.0.1';
11
11
 
12
- // Windows: detectar IP para WSL
12
+ // Windows o WSL: Claude Code SIEMPRE corre en WSL,
13
+ // asi que SIEMPRE necesitamos la IP del host Windows.
14
+ // No importa si el usuario ejecuta npx desde Windows o WSL.
13
15
 
14
16
  // 1. Desde WSL: leer resolv.conf directamente
15
17
  try {
package/lib/network.js CHANGED
@@ -29,6 +29,7 @@ function setupFirewall() {
29
29
  if (check.includes(FIREWALL_RULE)) return true;
30
30
  } catch (e) {}
31
31
 
32
+ // Intento 1: cmd.exe directo
32
33
  try {
33
34
  execSync(
34
35
  `cmd.exe /c netsh advfirewall firewall add rule name="${FIREWALL_RULE}" dir=in action=allow protocol=TCP localport=1024-65535`,
@@ -36,8 +37,19 @@ function setupFirewall() {
36
37
  );
37
38
  success('Firewall: regla universal creada (via WSL)');
38
39
  return true;
40
+ } catch (e) {}
41
+
42
+ // Intento 2: elevar con powershell
43
+ try {
44
+ const fwCmd = `netsh advfirewall firewall add rule name="${FIREWALL_RULE}" dir=in action=allow protocol=TCP localport=1024-65535`;
45
+ execSync(
46
+ `powershell.exe -Command "Start-Process cmd -ArgumentList '/c ${fwCmd}' -Verb RunAs -Wait"`,
47
+ { timeout: 30000, stdio: 'pipe' }
48
+ );
49
+ success('Firewall: regla universal creada (elevado)');
50
+ return true;
39
51
  } catch (e) {
40
- warn('Firewall: no se pudo crear regla desde WSL (ejecuta como Admin en Windows)');
52
+ warn('Firewall: no se pudo crear regla (ejecuta como Admin en Windows)');
41
53
  return false;
42
54
  }
43
55
  }
@@ -83,6 +95,7 @@ function setupPortproxy(port) {
83
95
  }
84
96
  } catch (e) {}
85
97
 
98
+ // Intento 1: cmd.exe directo (si WSL tiene permisos)
86
99
  try {
87
100
  execSync(
88
101
  `cmd.exe /c netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=${port} connectaddress=127.0.0.1 connectport=${port}`,
@@ -90,8 +103,20 @@ function setupPortproxy(port) {
90
103
  );
91
104
  success(`Portproxy: 0.0.0.0:${port} -> 127.0.0.1:${port} (via WSL)`);
92
105
  return true;
106
+ } catch (e) {}
107
+
108
+ // Intento 2: elevar con powershell -Verb RunAs
109
+ try {
110
+ const netshCmd = `netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=${port} connectaddress=127.0.0.1 connectport=${port}`;
111
+ execSync(
112
+ `powershell.exe -Command "Start-Process cmd -ArgumentList '/c ${netshCmd}' -Verb RunAs -Wait"`,
113
+ { timeout: 30000, stdio: 'pipe' }
114
+ );
115
+ success(`Portproxy: 0.0.0.0:${port} -> 127.0.0.1:${port} (elevado)`);
116
+ return true;
93
117
  } catch (e) {
94
- warn(`Portproxy: fallo desde WSL (ejecuta como Admin en Windows)`);
118
+ warn(`Portproxy: fallo. Ejecuta manualmente como Admin en Windows:`);
119
+ warn(` netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=${port} connectaddress=127.0.0.1 connectport=${port}`);
95
120
  return false;
96
121
  }
97
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-ipc-cdp",
3
- "version": "1.2.0",
3
+ "version": "1.4.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"