@generativereality/browser-automation 0.4.2 → 0.4.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/README.md +12 -2
- package/dist/index.js +47 -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.4.
|
|
4
|
+
"version": "0.4.3",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "generativereality"
|
|
7
7
|
},
|
package/README.md
CHANGED
|
@@ -64,6 +64,15 @@ Page commands pick a tab with a selector (precedence `-t` > `-m` > `-s`):
|
|
|
64
64
|
- `-t <targetId>` — an exact tab (from `list`).
|
|
65
65
|
- `-s <name>` — a saved **session** bookmark (default `$BAC_SESSION`, else `default`).
|
|
66
66
|
|
|
67
|
+
A fourth selector, `-F <substr>`, is orthogonal — it descends **into** a tab,
|
|
68
|
+
to a **cross-origin child iframe** (OOPIF) whose URL/title contains the
|
|
69
|
+
substring (e.g. `-F js.stripe.com` to fill Stripe Elements). OOPIFs are
|
|
70
|
+
first-class CDP targets, so every page command (`snapshot`/`click`/`fill`/
|
|
71
|
+
`read`/`eval`) works inside them. Same-origin iframes aren't separate targets —
|
|
72
|
+
they're already reachable from the parent page, no `-F`. Discover frames with
|
|
73
|
+
`list --frames`; an ambiguous `-F` errors (narrow it, use `-t <iframeTargetId>`,
|
|
74
|
+
or `--first`).
|
|
75
|
+
|
|
67
76
|
Sessions are optional bookmarks, not locks — there's no one-session-one-tab rule.
|
|
68
77
|
|
|
69
78
|
```bash
|
|
@@ -113,8 +122,9 @@ same one-action-per-snapshot rule as Playwright refs.
|
|
|
113
122
|
`input`/`change`), which works on background tabs (native CDP mouse events do
|
|
114
123
|
not reliably reach a non-foreground tab in headed Chrome). Synthetic events are
|
|
115
124
|
not `isTrusted`, so a few hard anti-bot/payment flows may reject them.
|
|
116
|
-
- `read`/`snapshot` see the page + same-origin frames
|
|
117
|
-
|
|
125
|
+
- `read`/`snapshot` see the page + same-origin frames. A **cross-origin iframe**
|
|
126
|
+
is its own CDP target — reach it with `-F <substr>` (or `-t <iframeTargetId>`
|
|
127
|
+
from `list --frames`); every page command then runs inside that frame.
|
|
118
128
|
- `launch` resolves Chrome on macOS/Linux; elsewhere start Chrome manually with
|
|
119
129
|
`--remote-debugging-port=9223 --user-data-dir="<profile>"`.
|
|
120
130
|
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, s
|
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "0.4.
|
|
10
|
+
var version = "0.4.3";
|
|
11
11
|
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.";
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/core/session.ts
|
|
@@ -306,8 +306,23 @@ async function matchOne(match, first) {
|
|
|
306
306
|
if (hits.length > 1 && !first) throw new Error(`"${match}" matches ${hits.length} tabs — narrow it or pass --first:\n` + hits.map((h) => ` ${(h.title ?? "").slice(0, 30)} ${h.url}`).join("\n"));
|
|
307
307
|
return hits[0];
|
|
308
308
|
}
|
|
309
|
-
/**
|
|
309
|
+
/** Match a CROSS-ORIGIN child iframe (OOPIF) by URL/title substring. Out-of-process
|
|
310
|
+
* iframes are first-class CDP targets (type === 'iframe') with their own
|
|
311
|
+
* webSocketDebuggerUrl, so once resolved every page command drives them exactly
|
|
312
|
+
* like a tab. (Same-origin iframes share the parent's target and never appear
|
|
313
|
+
* here — they're already reachable from the parent page.) */
|
|
314
|
+
async function matchIframe(match, first) {
|
|
315
|
+
const frames = (await listTargets()).filter((t) => t.type === "iframe");
|
|
316
|
+
const m = match.toLowerCase();
|
|
317
|
+
const hits = frames.filter((f) => (f.url ?? "").toLowerCase().includes(m) || (f.title ?? "").toLowerCase().includes(m));
|
|
318
|
+
if (hits.length === 0) throw new Error(`no cross-origin iframe matches "${match}" — run \`browser-automation list --frames\` to see them. (Same-origin iframes aren't separate targets; reach them from the parent page without -F.)`);
|
|
319
|
+
if (hits.length > 1 && !first) throw new Error(`-F "${match}" matches ${hits.length} iframes — narrow it, address one exactly with \`-t <iframeTargetId>\` (from \`list --frames\`), or pass --first:\n` + hits.map((h) => ` ${h.id.slice(0, 12)} ${(h.url ?? "").slice(0, 70)}`).join("\n"));
|
|
320
|
+
return hits[0];
|
|
321
|
+
}
|
|
322
|
+
/** Resolve to an EXISTING live tab — or, with `-F`, a cross-origin child iframe
|
|
323
|
+
* of one. Never creates. For read/snapshot/click/fill/eval/close. */
|
|
310
324
|
async function resolveExistingTargetId(opts) {
|
|
325
|
+
if (opts.frame) return (await matchIframe(opts.frame, opts.first)).id;
|
|
311
326
|
if (opts.target) return resolveTargetIdArg(opts.target);
|
|
312
327
|
if (opts.match) return (await matchOne(opts.match, opts.first)).id;
|
|
313
328
|
const name = opts.session || defaultSessionName();
|
|
@@ -345,7 +360,12 @@ const targetArgs = {
|
|
|
345
360
|
},
|
|
346
361
|
first: {
|
|
347
362
|
type: "boolean",
|
|
348
|
-
description: "If --match is ambiguous, use the first match instead of erroring"
|
|
363
|
+
description: "If --match (or --frame) is ambiguous, use the first match instead of erroring"
|
|
364
|
+
},
|
|
365
|
+
frame: {
|
|
366
|
+
type: "string",
|
|
367
|
+
short: "F",
|
|
368
|
+
description: "Descend into a CROSS-ORIGIN child iframe (OOPIF) whose URL or title contains this substring, and run the command against that frame instead of the page (e.g. -F js.stripe.com to fill Stripe Elements). Out-of-process iframes are first-class CDP targets, so snapshot/click/fill/read/eval all work inside them. Same-origin iframes are NOT separate targets — already reachable from the parent page, no -F needed. Discover frames with `list --frames`. An ambiguous substring errors (use a more distinctive substring, an exact `-t <iframeTargetId>`, or --first)."
|
|
349
369
|
}
|
|
350
370
|
};
|
|
351
371
|
function targetOpts(values) {
|
|
@@ -353,7 +373,8 @@ function targetOpts(values) {
|
|
|
353
373
|
session: values.session,
|
|
354
374
|
match: values.match,
|
|
355
375
|
target: values.target,
|
|
356
|
-
first: values.first
|
|
376
|
+
first: values.first,
|
|
377
|
+
frame: values.frame
|
|
357
378
|
};
|
|
358
379
|
}
|
|
359
380
|
//#endregion
|
|
@@ -1111,18 +1132,26 @@ const screenshotCommand = define({
|
|
|
1111
1132
|
//#region src/commands/list.ts
|
|
1112
1133
|
const listCommand = define({
|
|
1113
1134
|
name: "list",
|
|
1114
|
-
description: "List sessions and every open tab (with targetId + title) so you can pick -m/-t",
|
|
1115
|
-
args: {
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1135
|
+
description: "List sessions and every open tab (with targetId + title) so you can pick -m/-t. Add --frames to also list cross-origin child iframes (OOPIFs) addressable with -F/-t.",
|
|
1136
|
+
args: {
|
|
1137
|
+
json: {
|
|
1138
|
+
type: "boolean",
|
|
1139
|
+
description: "Output raw JSON"
|
|
1140
|
+
},
|
|
1141
|
+
frames: {
|
|
1142
|
+
type: "boolean",
|
|
1143
|
+
description: "Also list cross-origin child iframes (OOPIFs) — their targetIds/URLs let you drive Stripe Elements, embedded SSO widgets, etc. via -F <substr> or -t <id>."
|
|
1144
|
+
}
|
|
1145
|
+
},
|
|
1119
1146
|
async run(ctx) {
|
|
1120
1147
|
const sessions = listSessions();
|
|
1121
1148
|
const targets = await listPageTargets().catch(() => []);
|
|
1149
|
+
const frames = ctx.values.frames ? (await listTargets().catch(() => [])).filter((t) => t.type === "iframe") : [];
|
|
1122
1150
|
if (ctx.values.json) {
|
|
1123
1151
|
process.stdout.write(JSON.stringify({
|
|
1124
1152
|
sessions,
|
|
1125
|
-
targets
|
|
1153
|
+
targets,
|
|
1154
|
+
...ctx.values.frames ? { frames } : {}
|
|
1126
1155
|
}, null, 2) + "\n");
|
|
1127
1156
|
return;
|
|
1128
1157
|
}
|
|
@@ -1138,6 +1167,14 @@ const listCommand = define({
|
|
|
1138
1167
|
const title = (t.title ?? "").replace(/\s+/g, " ").slice(0, 28);
|
|
1139
1168
|
consola.log(` ${t.id.slice(0, 12)} ${owner ? `(${owner.name}) ` : ""}${title.padEnd(28)} ${(t.url ?? "").slice(0, 70)}`);
|
|
1140
1169
|
}
|
|
1170
|
+
if (ctx.values.frames) {
|
|
1171
|
+
consola.log("");
|
|
1172
|
+
consola.log(`# cross-origin iframes (${frames.length}) — address with -F <substr> or -t <id>`);
|
|
1173
|
+
for (const f of frames) {
|
|
1174
|
+
const title = (f.title ?? "").replace(/\s+/g, " ").slice(0, 28);
|
|
1175
|
+
consola.log(` ${f.id.slice(0, 12)} ${title.padEnd(28)} ${(f.url ?? "").slice(0, 70)}`);
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1141
1178
|
}
|
|
1142
1179
|
});
|
|
1143
1180
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@generativereality/browser-automation",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.3",
|
|
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": {
|