@generativereality/browser-automation 0.7.2 → 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.
- package/.claude-plugin/plugin.json +1 -1
- package/dist/index.js +58 -10
- package/package.json +1 -1
|
@@ -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.
|
|
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.
|
|
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,
|
|
@@ -1690,19 +1690,53 @@ async function serve(o, releaseLock) {
|
|
|
1690
1690
|
const bySession = /* @__PURE__ */ new Map();
|
|
1691
1691
|
const clients = /* @__PURE__ */ new Set();
|
|
1692
1692
|
const socks = /* @__PURE__ */ new Set();
|
|
1693
|
-
const
|
|
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
|
+
};
|
|
1694
1727
|
const ask = (method, params) => new Promise((resolve) => {
|
|
1728
|
+
if (pipeGone) return resolve({ error: { message: `Chrome is shutting down: ${pipeGone}` } });
|
|
1695
1729
|
const id = nextId++;
|
|
1696
1730
|
own.set(id, resolve);
|
|
1697
|
-
toPipe({
|
|
1731
|
+
if (!toPipe({
|
|
1698
1732
|
id,
|
|
1699
1733
|
method,
|
|
1700
1734
|
params
|
|
1701
|
-
})
|
|
1735
|
+
})) {
|
|
1736
|
+
own.delete(id);
|
|
1737
|
+
resolve({ error: { message: "Chrome is shutting down: its DevTools pipe is closed" } });
|
|
1738
|
+
}
|
|
1702
1739
|
});
|
|
1703
|
-
const tell = (c, msg) => {
|
|
1704
|
-
if (!c.sock.destroyed) c.sock.write(JSON.stringify(msg) + "\n");
|
|
1705
|
-
};
|
|
1706
1740
|
let buf = "";
|
|
1707
1741
|
fromChrome.setEncoding("utf8");
|
|
1708
1742
|
fromChrome.on("data", (chunk) => {
|
|
@@ -1820,12 +1854,23 @@ async function serve(o, releaseLock) {
|
|
|
1820
1854
|
client: c,
|
|
1821
1855
|
id: msg.id
|
|
1822
1856
|
});
|
|
1823
|
-
toPipe({
|
|
1857
|
+
if (!toPipe({
|
|
1824
1858
|
id,
|
|
1825
1859
|
method: msg.method,
|
|
1826
1860
|
params: msg.params ?? {},
|
|
1827
1861
|
...c.sessionId ? { sessionId: c.sessionId } : {}
|
|
1828
|
-
})
|
|
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
|
+
}
|
|
1829
1874
|
}
|
|
1830
1875
|
});
|
|
1831
1876
|
const gone = () => {
|
|
@@ -1869,7 +1914,10 @@ async function serve(o, releaseLock) {
|
|
|
1869
1914
|
method: "Browser.close",
|
|
1870
1915
|
params: {}
|
|
1871
1916
|
});
|
|
1872
|
-
setTimeout(() =>
|
|
1917
|
+
setTimeout(() => {
|
|
1918
|
+
toChrome.end();
|
|
1919
|
+
losePipe("closed by the broker: Chrome did not quit within 10s of Browser.close");
|
|
1920
|
+
}, 1e4).unref();
|
|
1873
1921
|
setTimeout(() => chrome.kill("SIGKILL"), 2e4).unref();
|
|
1874
1922
|
};
|
|
1875
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.
|
|
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": {
|