@generativereality/browser-automation 0.4.18 → 0.4.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.
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -0
- package/dist/index.js +93 -12
- package/package.json +1 -1
- package/scripts/launch-chrome.sh +36 -15
- package/skills/browser/SKILL.md +7 -0
|
@@ -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.4.
|
|
4
|
+
"version": "0.4.19",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "generativereality"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -186,6 +186,7 @@ same one-action-per-snapshot rule as Playwright refs.
|
|
|
186
186
|
repeats a rule is a copy of it, and goes stale the same way code does.
|
|
187
187
|
`doctor` prints it too, and warns if another user holds it.
|
|
188
188
|
- `BROWSER_AUTOMATION_CDP` — full CDP host, overriding the port entirely.
|
|
189
|
+
- `CHROME` / `BROWSER_AUTOMATION_CHROME` — the Chrome executable `launch` starts, when it is not in a standard place. Otherwise: macOS `/Applications` then `~/Applications`; Windows Program Files then `%LOCALAPPDATA%`; Linux `google-chrome`/`chromium` on PATH. `doctor` shows which.
|
|
189
190
|
- `BROWSER_AUTOMATION_PROFILE` — Chrome profile dir for `launch`. Default `~/.browser-automation/chrome-profile`; a profile still at the old location inside Chrome's own folder is moved there on launch (`browser-automation profile --migrate` to do it by hand).
|
|
190
191
|
- `BAC_SHOW_TAB=1` — `--show` on every `goto`/`new`: select the tab in its window when the automation Chrome is already in front (never raises Chrome over another app). macOS and Windows.
|
|
191
192
|
- `BAC_SESSION` — default session name for page commands.
|
package/dist/index.js
CHANGED
|
@@ -3,13 +3,13 @@ import updateNotifier from "update-notifier";
|
|
|
3
3
|
import { cli, define } from "gunshi";
|
|
4
4
|
import consola, { consola as consola$1 } from "consola";
|
|
5
5
|
import { homedir, tmpdir } from "node:os";
|
|
6
|
-
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
7
|
-
import { appendFileSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
6
|
+
import { basename, delimiter, dirname, extname, join, resolve } from "node:path";
|
|
7
|
+
import { accessSync, appendFileSync, constants, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { execFileSync, spawn, spawnSync } from "node:child_process";
|
|
9
9
|
import { fileURLToPath } from "node:url";
|
|
10
10
|
//#region package.json
|
|
11
11
|
var name = "@generativereality/browser-automation";
|
|
12
|
-
var version = "0.4.
|
|
12
|
+
var version = "0.4.19";
|
|
13
13
|
var description = "Daemonless, per-tab-isolated browser automation CLI for Claude Code. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.";
|
|
14
14
|
var package_default = {
|
|
15
15
|
name,
|
|
@@ -2931,17 +2931,88 @@ function migrateProfile() {
|
|
|
2931
2931
|
};
|
|
2932
2932
|
}
|
|
2933
2933
|
//#endregion
|
|
2934
|
+
//#region src/core/chrome-path.ts
|
|
2935
|
+
function executable(p) {
|
|
2936
|
+
try {
|
|
2937
|
+
if (!statSync(p).isFile()) return false;
|
|
2938
|
+
if (process.platform === "win32") return true;
|
|
2939
|
+
accessSync(p, constants.X_OK);
|
|
2940
|
+
return true;
|
|
2941
|
+
} catch {
|
|
2942
|
+
return false;
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
const MAC_BINARY = join("Google Chrome.app", "Contents", "MacOS", "Google Chrome");
|
|
2946
|
+
function platformCandidates() {
|
|
2947
|
+
if (process.platform === "darwin") return [{
|
|
2948
|
+
path: join(process.env.BROWSER_AUTOMATION_TEST_SYSTEM_APPS || "/Applications", MAC_BINARY),
|
|
2949
|
+
source: "/Applications"
|
|
2950
|
+
}, {
|
|
2951
|
+
path: join(homedir(), "Applications", MAC_BINARY),
|
|
2952
|
+
source: "~/Applications"
|
|
2953
|
+
}];
|
|
2954
|
+
if (process.platform === "win32") {
|
|
2955
|
+
const out = [];
|
|
2956
|
+
const exe = join("Google", "Chrome", "Application", "chrome.exe");
|
|
2957
|
+
if (process.env.PROGRAMFILES) out.push({
|
|
2958
|
+
path: join(process.env.PROGRAMFILES, exe),
|
|
2959
|
+
source: "Program Files"
|
|
2960
|
+
});
|
|
2961
|
+
if (process.env["PROGRAMFILES(X86)"]) out.push({
|
|
2962
|
+
path: join(process.env["PROGRAMFILES(X86)"], exe),
|
|
2963
|
+
source: "Program Files (x86)"
|
|
2964
|
+
});
|
|
2965
|
+
if (process.env.LOCALAPPDATA) out.push({
|
|
2966
|
+
path: join(process.env.LOCALAPPDATA, exe),
|
|
2967
|
+
source: "%LOCALAPPDATA%"
|
|
2968
|
+
});
|
|
2969
|
+
return out;
|
|
2970
|
+
}
|
|
2971
|
+
const dirs = (process.env.PATH ?? "").split(delimiter).filter(Boolean);
|
|
2972
|
+
return [
|
|
2973
|
+
"google-chrome",
|
|
2974
|
+
"google-chrome-stable",
|
|
2975
|
+
"chromium",
|
|
2976
|
+
"chromium-browser"
|
|
2977
|
+
].flatMap((name) => dirs.map((d) => ({
|
|
2978
|
+
path: join(d, name),
|
|
2979
|
+
source: `PATH (${name})`
|
|
2980
|
+
})));
|
|
2981
|
+
}
|
|
2982
|
+
function chromeExecutable() {
|
|
2983
|
+
let ignored;
|
|
2984
|
+
for (const name of ["BROWSER_AUTOMATION_CHROME", "CHROME"]) {
|
|
2985
|
+
const v = process.env[name];
|
|
2986
|
+
if (!v) continue;
|
|
2987
|
+
if (executable(v)) return {
|
|
2988
|
+
path: v,
|
|
2989
|
+
source: name
|
|
2990
|
+
};
|
|
2991
|
+
ignored ??= `${name}=${v} is not an executable file`;
|
|
2992
|
+
}
|
|
2993
|
+
const hit = platformCandidates().find((c) => executable(c.path));
|
|
2994
|
+
return hit ? {
|
|
2995
|
+
path: hit.path,
|
|
2996
|
+
source: hit.source,
|
|
2997
|
+
ignored
|
|
2998
|
+
} : {
|
|
2999
|
+
path: null,
|
|
3000
|
+
source: "not found",
|
|
3001
|
+
ignored
|
|
3002
|
+
};
|
|
3003
|
+
}
|
|
3004
|
+
/** Where we looked, for a "not found" message. */
|
|
3005
|
+
function chromeSearchDescription() {
|
|
3006
|
+
if (process.platform === "darwin") return "/Applications and ~/Applications";
|
|
3007
|
+
if (process.platform === "win32") return "Program Files, Program Files (x86) and %LOCALAPPDATA%";
|
|
3008
|
+
return "google-chrome, google-chrome-stable, chromium and chromium-browser on PATH";
|
|
3009
|
+
}
|
|
3010
|
+
//#endregion
|
|
2934
3011
|
//#region src/core/launch-windows.ts
|
|
2935
3012
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
2936
|
-
/** chrome.exe
|
|
3013
|
+
/** chrome.exe — decided in one place for every platform (core/chrome-path.ts). */
|
|
2937
3014
|
function windowsChromeExe() {
|
|
2938
|
-
|
|
2939
|
-
if (explicit) return existsSync(explicit) ? explicit : null;
|
|
2940
|
-
return [
|
|
2941
|
-
process.env.PROGRAMFILES && join(process.env.PROGRAMFILES, "Google", "Chrome", "Application", "chrome.exe"),
|
|
2942
|
-
process.env["PROGRAMFILES(X86)"] && join(process.env["PROGRAMFILES(X86)"], "Google", "Chrome", "Application", "chrome.exe"),
|
|
2943
|
-
process.env.LOCALAPPDATA && join(process.env.LOCALAPPDATA, "Google", "Chrome", "Application", "chrome.exe")
|
|
2944
|
-
].filter(Boolean).find((p) => existsSync(p)) ?? null;
|
|
3015
|
+
return chromeExecutable().path;
|
|
2945
3016
|
}
|
|
2946
3017
|
/** Is anything answering CDP on this port? (The script's `is_up`.) */
|
|
2947
3018
|
async function cdpUp(port) {
|
|
@@ -3111,7 +3182,13 @@ const launchCommand = define({
|
|
|
3111
3182
|
if (m.outcome === "moved") consola$1.success(`Profile ${m.detail} — logins travel with it.`);
|
|
3112
3183
|
else if (m.outcome === "refused" || m.outcome === "failed") consola$1.warn(`Profile not moved: ${m.detail}`);
|
|
3113
3184
|
else if (m.outcome === "in-use") consola$1.info(`Profile not moved yet: ${m.detail}`);
|
|
3114
|
-
const
|
|
3185
|
+
const chrome = chromeExecutable();
|
|
3186
|
+
if (chrome.ignored) consola$1.warn(`Ignoring ${chrome.ignored}.`);
|
|
3187
|
+
const r = bash([
|
|
3188
|
+
"--profile",
|
|
3189
|
+
m.dir,
|
|
3190
|
+
...chrome.path ? ["--chrome", chrome.path] : []
|
|
3191
|
+
]);
|
|
3115
3192
|
if (r.status !== 0) process.exit(r.status ?? 1);
|
|
3116
3193
|
}
|
|
3117
3194
|
const health = await probeRenderer().catch((e) => ({
|
|
@@ -3227,6 +3304,10 @@ const doctorCommand = define({
|
|
|
3227
3304
|
consola$1.log(` ⚠ still inside Chrome's own folder, which an app-hosted session may be refused.`);
|
|
3228
3305
|
consola$1.log(` Move it (logins included): browser-automation profile --migrate`);
|
|
3229
3306
|
}
|
|
3307
|
+
const chrome = chromeExecutable();
|
|
3308
|
+
if (chrome.path) consola$1.log(` • Chrome binary: ${chrome.path} (${chrome.source})`);
|
|
3309
|
+
else bad(`Chrome binary: not found (looked in ${chromeSearchDescription()}) — \`launch\` cannot start one. Install Chrome, or set CHROME.`);
|
|
3310
|
+
if (chrome.ignored) consola$1.log(` ⚠ ignoring ${chrome.ignored}`);
|
|
3230
3311
|
let version;
|
|
3231
3312
|
try {
|
|
3232
3313
|
version = await (await fetch(`${cdpHost()}/json/version`)).json();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@generativereality/browser-automation",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.19",
|
|
4
4
|
"description": "Daemonless, per-tab-isolated browser automation CLI for Claude Code. Drives one shared headed Chrome (persistent profile + extensions) over per-target CDP — many parallel sessions, no focus stealing, nothing long-lived to crash.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/scripts/launch-chrome.sh
CHANGED
|
@@ -56,6 +56,7 @@ ask_cli_for_port() {
|
|
|
56
56
|
|
|
57
57
|
PORT=""
|
|
58
58
|
PROFILE=""
|
|
59
|
+
CHROME_ARG=""
|
|
59
60
|
RESTART=0
|
|
60
61
|
STOP_ONLY=0
|
|
61
62
|
ARGS=()
|
|
@@ -63,6 +64,7 @@ while [ $# -gt 0 ]; do
|
|
|
63
64
|
case "$1" in
|
|
64
65
|
--port) PORT="${2:-}"; shift 2 ;;
|
|
65
66
|
--profile) PROFILE="${2:-}"; shift 2 ;;
|
|
67
|
+
--chrome) CHROME_ARG="${2:-}"; shift 2 ;;
|
|
66
68
|
--restart) RESTART=1; shift ;;
|
|
67
69
|
# Quit our Chrome and stop there. `launch --restart` uses it so the profile
|
|
68
70
|
# can be moved while nothing has it open, before the relaunch.
|
|
@@ -227,22 +229,41 @@ if is_up; then
|
|
|
227
229
|
exit 0
|
|
228
230
|
fi
|
|
229
231
|
|
|
230
|
-
# Resolve Chrome binary
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
232
|
+
# Resolve the Chrome binary. **Asked for, like the port and the profile**:
|
|
233
|
+
# `chromeExecutable()` in src/core/chrome-path.ts decides, and `launch` passes it
|
|
234
|
+
# with --chrome. The order below only repeats it for a person running this by
|
|
235
|
+
# hand: an explicit $BROWSER_AUTOMATION_CHROME / $CHROME that is executable, then
|
|
236
|
+
# /Applications, then ~/Applications.
|
|
237
|
+
#
|
|
238
|
+
# This used to hardcode /Applications/Google Chrome.app and OVERWRITE $CHROME, so
|
|
239
|
+
# a Chrome in ~/Applications — where Mind My Money installs it for an account
|
|
240
|
+
# that cannot write /Applications — could not be launched at all (2026-10-05).
|
|
241
|
+
CHROME_FROM_ENV="${CHROME:-}" # read BEFORE reusing the name below
|
|
242
|
+
CHROME=""
|
|
243
|
+
for c in "$CHROME_ARG" "${BROWSER_AUTOMATION_CHROME:-}" "$CHROME_FROM_ENV"; do
|
|
244
|
+
if [ -n "$c" ] && [ -x "$c" ] && [ ! -d "$c" ]; then CHROME="$c"; break; fi
|
|
245
|
+
done
|
|
246
|
+
if [ -z "$CHROME" ]; then
|
|
247
|
+
case "$(uname -s)" in
|
|
248
|
+
Darwin)
|
|
249
|
+
for c in "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" \
|
|
250
|
+
"$HOME/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"; do
|
|
251
|
+
if [ -x "$c" ]; then CHROME="$c"; break; fi
|
|
252
|
+
done
|
|
253
|
+
;;
|
|
254
|
+
Linux)
|
|
255
|
+
CHROME="$(command -v google-chrome || command -v google-chrome-stable || command -v chromium || command -v chromium-browser || true)"
|
|
256
|
+
;;
|
|
257
|
+
*)
|
|
258
|
+
echo "Error: this script is for macOS and Linux (got $(uname -s)). On Windows, run \`browser-automation launch\` — it does not use this script." >&2
|
|
259
|
+
exit 1
|
|
260
|
+
;;
|
|
261
|
+
esac
|
|
262
|
+
fi
|
|
243
263
|
|
|
244
|
-
if [ ! -x "$CHROME" ]; then
|
|
245
|
-
echo "Error: Chrome not found
|
|
264
|
+
if [ -z "$CHROME" ] || [ ! -x "$CHROME" ]; then
|
|
265
|
+
echo "Error: Chrome not found (looked in /Applications and ~/Applications on macOS, PATH on Linux)." >&2
|
|
266
|
+
echo " Install it, or set CHROME=/path/to/chrome if it lives elsewhere." >&2
|
|
246
267
|
exit 1
|
|
247
268
|
fi
|
|
248
269
|
|
package/skills/browser/SKILL.md
CHANGED
|
@@ -333,6 +333,13 @@ code lives, how to validate with `node dist/index.js`, and the PR steps:
|
|
|
333
333
|
|
|
334
334
|
## Troubleshooting
|
|
335
335
|
|
|
336
|
+
- **Which Chrome `launch` starts:** `CHROME` / `BROWSER_AUTOMATION_CHROME` when it
|
|
337
|
+
points at an executable; otherwise macOS `/Applications` then **`~/Applications`**
|
|
338
|
+
(where an account that cannot write `/Applications` gets Chrome installed),
|
|
339
|
+
Windows Program Files then the per-user `%LOCALAPPDATA%` install, Linux
|
|
340
|
+
`google-chrome`/`chromium` on PATH. `doctor` prints the one it found — check that
|
|
341
|
+
line before concluding "Chrome is not installed". Before 0.4.19 the macOS launcher
|
|
342
|
+
only knew `/Applications` and ignored `CHROME`.
|
|
336
343
|
- **`No CDP browser on http://localhost:<port>`** → `browser-automation launch`.
|
|
337
344
|
If it says the port is held by ANOTHER user, that is not your Chrome and
|
|
338
345
|
driving it would act in their session — quit Chrome in that account, or set
|