@hmharness/browser 0.23.21 → 0.23.23

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/dist/cdp.js CHANGED
@@ -184,6 +184,25 @@ export class CdpBrowser {
184
184
  return Buffer.from(r.data, 'base64');
185
185
  }
186
186
  async close() {
187
+ // dropSocket() nulls the field WITHOUT closing the socket — the WS
188
+ // would stay open and hold the event loop (found by the extension
189
+ // real-browser test: runner hung after PASS until this was fixed).
190
+ // Bounded by a 1s race: a socket whose peer already died may never
191
+ // deliver a close event.
192
+ const ws = this.ws;
187
193
  this.dropSocket();
194
+ if (ws && (ws.readyState === WebSocket.OPEN || ws.readyState === WebSocket.CONNECTING)) {
195
+ await new Promise((resolve) => {
196
+ const t = setTimeout(resolve, 1_000);
197
+ ws.addEventListener('close', () => { clearTimeout(t); resolve(); }, { once: true });
198
+ try {
199
+ ws.close();
200
+ }
201
+ catch {
202
+ clearTimeout(t);
203
+ resolve(); /* already dead */
204
+ }
205
+ });
206
+ }
188
207
  }
189
208
  }
package/dist/registry.js CHANGED
@@ -14,7 +14,7 @@
14
14
  */
15
15
  import { spawnSync } from 'node:child_process';
16
16
  import { existsSync, readFileSync, statSync } from 'node:fs';
17
- import { join } from 'node:path';
17
+ import { basename, dirname, join } from 'node:path';
18
18
  import { homedir } from 'node:os';
19
19
  export const BROWSEROS_INSTALL_URL = 'https://www.browseros.com';
20
20
  export const BROWSEROS_REPO_URL = 'https://github.com/browseros-ai/BrowserOS';
@@ -60,10 +60,12 @@ function which(cmd) {
60
60
  const first = (probe.stdout || '').split('\n').map((l) => l.trim()).filter(Boolean)[0];
61
61
  return first ?? null;
62
62
  }
63
- /** Health = a plausible Chromium binary on disk. `--version` is displayed
64
- * when the platform prints it, but Windows GUI-subsystem binaries stay
65
- * silent with exit 0 — silence must not read as brokenness here (unlike
66
- * language servers, whose shims DO speak --version). */
63
+ /** Health = a plausible Chromium binary on disk. The binary is NEVER
64
+ * EXECUTED for probing: on Windows, chrome-family `--version` LAUNCHES
65
+ * THE BROWSER (GUI-subsystem quirk — observed popping a full BrowserOS
66
+ * instance on every `hmh` startup). Version info, when wanted, is parsed
67
+ * from the versioned directory that ships beside the executable
68
+ * (Application/<ver>/chrome.exe layout). */
67
69
  function healthProbe(command) {
68
70
  try {
69
71
  const size = statSync(command).size;
@@ -75,17 +77,12 @@ function healthProbe(command) {
75
77
  }
76
78
  let version;
77
79
  try {
78
- const r = spawnSync(command, ['--version'], { encoding: 'utf8', timeout: 5_000, windowsHide: true });
79
- if (r.status === 0) {
80
- const line = ((r.stdout || '') + (r.stderr || '')).split('\n').map((l) => l.trim()).filter(Boolean)[0];
81
- // keep only ASCII version banners; a zh-CN Windows chrome.exe answers
82
- // --version with a GBK "opening in existing session" notice (mojibake
83
- // in utf8, and delegation noise even when decoded) — not version info
84
- if (line && /^(BrowserOS|Chrome|Chromium|Edg)[\s/]/i.test(line))
85
- version = line.slice(0, 80);
86
- }
80
+ const dir = dirname(command);
81
+ const m = basename(dir).match(/^\d+\.\d+\.\d+\.\d+$/);
82
+ if (m)
83
+ version = m[0];
87
84
  }
88
- catch { /* GUI subsystem silence is fine */ }
85
+ catch { /* version display is optional */ }
89
86
  return { healthy: true, version };
90
87
  }
91
88
  /** Discover BrowserOS on THIS machine (install roots > PATH > config
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hmharness/browser",
3
- "version": "0.23.21",
3
+ "version": "0.23.23",
4
4
  "description": "hmharness BrowserOS driver — discovers, trust-pins and launches the BrowserOS AI browser (Chromium fork), then drives it over the Chrome DevTools Protocol. Client only, zero dependencies, dedicated profile: the user's daily browser is never touched.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -15,7 +15,7 @@
15
15
  "build": "tsc -p tsconfig.build.json"
16
16
  },
17
17
  "dependencies": {
18
- "@hmharness/kernel": "0.23.21"
18
+ "@hmharness/kernel": "0.23.23"
19
19
  },
20
20
  "files": [
21
21
  "dist"