@duanluan/codex-plus-plus-launcher 1.2.18 → 1.2.19

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.
@@ -1,3 +1,3 @@
1
- __version__ = "1.2.18"
1
+ __version__ = "1.2.19"
2
2
 
3
3
 
package/npm/launcher.js CHANGED
@@ -447,10 +447,12 @@ function exitSoon(code) {
447
447
  }
448
448
  }
449
449
 
450
- function readJson(pathname) {
450
+ const HTTP_HOSTS = ['localhost', '127.0.0.1', '::1'];
451
+
452
+ function readJsonFromHost(host, pathname) {
451
453
  return new Promise((resolve, reject) => {
452
454
  const request = http.get({
453
- host: '127.0.0.1',
455
+ host,
454
456
  port: debugPort,
455
457
  path: pathname,
456
458
  timeout: 1500,
@@ -471,13 +473,30 @@ function readJson(pathname) {
471
473
  });
472
474
  }
473
475
 
476
+ async function readJson(pathname) {
477
+ let lastError = null;
478
+ for (const host of HTTP_HOSTS) {
479
+ try {
480
+ return await readJsonFromHost(host, pathname);
481
+ } catch (error) {
482
+ lastError = error;
483
+ }
484
+ }
485
+ throw lastError || new Error('CDP HTTP unavailable');
486
+ }
487
+
474
488
  function parseWebSocketTarget(webSocketDebuggerUrl) {
475
489
  const parsed = new URL(webSocketDebuggerUrl);
476
490
  if (parsed.protocol !== 'ws:') {
477
491
  throw new Error('unsupported websocket protocol');
478
492
  }
493
+ const host = parsed.hostname.startsWith('[') && parsed.hostname.endsWith(']')
494
+ ? parsed.hostname.slice(1, -1)
495
+ : parsed.hostname;
496
+ const hostHeader = host.includes(':') ? '[' + host + ']' : host;
479
497
  return {
480
- host: parsed.hostname,
498
+ host,
499
+ hostHeader,
481
500
  port: Number(parsed.port || 80),
482
501
  path: (parsed.pathname || '/') + (parsed.search || ''),
483
502
  };
@@ -617,7 +636,7 @@ function evaluateMenuState(webSocketDebuggerUrl) {
617
636
  const key = crypto.randomBytes(16).toString('base64');
618
637
  socket.write([
619
638
  'GET ' + target.path + ' HTTP/1.1',
620
- 'Host: ' + target.host + ':' + target.port,
639
+ 'Host: ' + target.hostHeader + ':' + target.port,
621
640
  'Upgrade: websocket',
622
641
  'Connection: Upgrade',
623
642
  'Sec-WebSocket-Key: ' + key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duanluan/codex-plus-plus-launcher",
3
- "version": "1.2.18",
3
+ "version": "1.2.19",
4
4
  "description": "Install and launch Codex++ from npm",
5
5
  "bin": {
6
6
  "cxpp": "npm/cxpp.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "upstream_version": "v1.2.15",
3
- "package_version": "1.2.18",
3
+ "package_version": "1.2.19",
4
4
  "ref": "v1.2.15",
5
5
  "version": "v1.2.15",
6
6
  "commit": "324a350d00376d4f9565aeeae3c8820b0cbbbe2a",