@generativereality/browser-automation 0.7.1 → 0.7.3

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,7 +1,7 @@
1
1
  {
2
2
  "name": "browser-automation",
3
3
  "description": "Daemonless, per-tab-isolated browser automation for Claude Code via the `browser-automation` CLI. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.",
4
- "version": "0.7.1",
4
+ "version": "0.7.3",
5
5
  "author": {
6
6
  "name": "generativereality"
7
7
  },
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import consola, { consola as consola$1 } from "consola";
11
11
  import { fileURLToPath } from "node:url";
12
12
  //#region package.json
13
13
  var name = "@generativereality/browser-automation";
14
- var version = "0.7.1";
14
+ var version = "0.7.3";
15
15
  var description = "Let many Claude Code sessions use your own signed-in Chrome at once, each in its own tab, without stealing your screen. Daemonless CLI over per-target CDP: persistent profile and extensions, no MCP server, nothing long-lived to crash.";
16
16
  var package_default = {
17
17
  name,
@@ -1549,10 +1549,22 @@ function servedSocket(dir) {
1549
1549
  return null;
1550
1550
  }
1551
1551
  }
1552
+ /**
1553
+ * Chrome marks itself automated (navigator.webdriver = true, the
1554
+ * AutomationControlled Blink feature) whenever it is started with
1555
+ * --remote-debugging-pipe, as it does for --enable-automation and headless; the
1556
+ * port never did. Cloudflare's Turnstile refuses a browser with that mark however
1557
+ * often the person ticks the box, so from the move to the pipe (#34, 2026-10-27)
1558
+ * claude.ai and dash.cloudflare.com stopped passing in a Chrome that had passed
1559
+ * them for months. This is the person's own headed, signed-in browser, not a
1560
+ * test harness: switch the mark off and keep the pipe.
1561
+ */
1562
+ const NO_AUTOMATION_MARK = "--disable-blink-features=AutomationControlled";
1552
1563
  /** The flags Chrome is started with. The profile flag is also how `ps` finds it. */
1553
1564
  function chromeArgs(profile, extra = []) {
1554
1565
  return [
1555
1566
  "--remote-debugging-pipe",
1567
+ NO_AUTOMATION_MARK,
1556
1568
  `--user-data-dir=${profile}`,
1557
1569
  "--no-first-run",
1558
1570
  "--no-default-browser-check",
@@ -1678,19 +1690,53 @@ async function serve(o, releaseLock) {
1678
1690
  const bySession = /* @__PURE__ */ new Map();
1679
1691
  const clients = /* @__PURE__ */ new Set();
1680
1692
  const socks = /* @__PURE__ */ new Set();
1681
- const toPipe = (msg) => toChrome.write(JSON.stringify(msg) + "\0");
1693
+ const tell = (c, msg) => {
1694
+ if (!c.sock.destroyed) c.sock.write(JSON.stringify(msg) + "\n");
1695
+ };
1696
+ let pipeGone = null;
1697
+ const losePipe = (why) => {
1698
+ if (pipeGone) return;
1699
+ pipeGone = why;
1700
+ try {
1701
+ appendFileSync(o.log, `browser-automation broker: Chrome's DevTools pipe is gone (${why}); waiting for Chrome to exit\n`);
1702
+ } catch {}
1703
+ for (const [id, r] of relayed) {
1704
+ relayed.delete(id);
1705
+ tell(r.client, {
1706
+ id: r.id,
1707
+ error: {
1708
+ code: -32e3,
1709
+ message: `Chrome is shutting down: ${why}`
1710
+ }
1711
+ });
1712
+ }
1713
+ for (const [id, resolve] of own) {
1714
+ own.delete(id);
1715
+ resolve({ error: { message: why } });
1716
+ }
1717
+ for (const s of socks) s.end();
1718
+ };
1719
+ toChrome.on("error", (e) => losePipe(`writing to it failed: ${e.message}`));
1720
+ toChrome.on("close", () => losePipe("it closed"));
1721
+ fromChrome.on("error", (e) => losePipe(`reading from it failed: ${e.message}`));
1722
+ const toPipe = (msg) => {
1723
+ if (pipeGone || toChrome.writableEnded || toChrome.destroyed) return false;
1724
+ toChrome.write(JSON.stringify(msg) + "\0");
1725
+ return true;
1726
+ };
1682
1727
  const ask = (method, params) => new Promise((resolve) => {
1728
+ if (pipeGone) return resolve({ error: { message: `Chrome is shutting down: ${pipeGone}` } });
1683
1729
  const id = nextId++;
1684
1730
  own.set(id, resolve);
1685
- toPipe({
1731
+ if (!toPipe({
1686
1732
  id,
1687
1733
  method,
1688
1734
  params
1689
- });
1735
+ })) {
1736
+ own.delete(id);
1737
+ resolve({ error: { message: "Chrome is shutting down: its DevTools pipe is closed" } });
1738
+ }
1690
1739
  });
1691
- const tell = (c, msg) => {
1692
- if (!c.sock.destroyed) c.sock.write(JSON.stringify(msg) + "\n");
1693
- };
1694
1740
  let buf = "";
1695
1741
  fromChrome.setEncoding("utf8");
1696
1742
  fromChrome.on("data", (chunk) => {
@@ -1808,12 +1854,23 @@ async function serve(o, releaseLock) {
1808
1854
  client: c,
1809
1855
  id: msg.id
1810
1856
  });
1811
- toPipe({
1857
+ if (!toPipe({
1812
1858
  id,
1813
1859
  method: msg.method,
1814
1860
  params: msg.params ?? {},
1815
1861
  ...c.sessionId ? { sessionId: c.sessionId } : {}
1816
- });
1862
+ })) {
1863
+ relayed.delete(id);
1864
+ tell(c, {
1865
+ id: msg.id,
1866
+ error: {
1867
+ code: -32e3,
1868
+ message: `Chrome is shutting down: ${pipeGone ?? "its DevTools pipe is closed"}`
1869
+ }
1870
+ });
1871
+ sock.end();
1872
+ return;
1873
+ }
1817
1874
  }
1818
1875
  });
1819
1876
  const gone = () => {
@@ -1857,7 +1914,10 @@ async function serve(o, releaseLock) {
1857
1914
  method: "Browser.close",
1858
1915
  params: {}
1859
1916
  });
1860
- setTimeout(() => toChrome.end(), 1e4).unref();
1917
+ setTimeout(() => {
1918
+ toChrome.end();
1919
+ losePipe("closed by the broker: Chrome did not quit within 10s of Browser.close");
1920
+ }, 1e4).unref();
1861
1921
  setTimeout(() => chrome.kill("SIGKILL"), 2e4).unref();
1862
1922
  };
1863
1923
  process.on("SIGTERM", stop);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generativereality/browser-automation",
3
- "version": "0.7.1",
3
+ "version": "0.7.3",
4
4
  "description": "Let many Claude Code sessions use your own signed-in Chrome at once, each in its own tab, without stealing your screen. Daemonless CLI over per-target CDP: persistent profile and extensions, no MCP server, nothing long-lived to crash.",
5
5
  "type": "module",
6
6
  "bin": {