@generativereality/browser-automation 0.4.3 → 0.4.4

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.4.3",
4
+ "version": "0.4.4",
5
5
  "author": {
6
6
  "name": "generativereality"
7
7
  },
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.3";
10
+ var version = "0.4.4";
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
@@ -468,10 +468,24 @@ const SNAPSHOT_EXPR = WALK + `(() => {
468
468
  const disabled=(el.disabled===true)||truthy(el.getAttribute&&el.getAttribute('aria-disabled'));
469
469
  return [checked?'checked':'',disabled?'disabled':''].filter(Boolean).join(' ');
470
470
  };
471
- const out=[]; let i=1;
471
+ // Open overlays (menus, dialogs, popovers, listboxes) are almost always WHAT
472
+ // the agent wants to act on next — but they're portal-rendered at the END of
473
+ // the DOM, so on a busy page their items fall past the element cap and vanish
474
+ // from the snapshot (e.g. a dropdown menu's items, a modal's buttons). Collect
475
+ // interactive elements in two buckets and emit OVERLAY ITEMS FIRST and uncapped,
476
+ // so an open menu/dialog is always addressable. Standard ARIA + native popover
477
+ // selectors keep this generic (no app-specific class names).
478
+ const OVERLAY='[role=dialog],[role=menu],[role=listbox],[role=menubar],[aria-modal=true],dialog[open]';
479
+ const inOverlay=(el)=>{ try{ if(el.closest&&el.closest(OVERLAY)) return true; }catch(e){} try{ if(el.matches&&el.matches(':popover-open,'+OVERLAY)) return true; }catch(e){} return false; };
480
+ const overlayEls=[], restEls=[];
472
481
  __baEachEl((el)=>{
473
- if(out.length>=200) return;
474
482
  if(!isInteractive(el)||!__baVisible(el))return;
483
+ (inOverlay(el)?overlayEls:restEls).push(el);
484
+ });
485
+ const CAP=200;
486
+ const chosen=overlayEls.concat(restEls.slice(0,Math.max(0,CAP-overlayEls.length)));
487
+ const out=[]; let i=1;
488
+ for(const el of chosen){
475
489
  const ref='e'+(i++);
476
490
  el.setAttribute('data-ba-ref',ref);
477
491
  const tag=el.tagName.toLowerCase();
@@ -479,8 +493,21 @@ const SNAPSHOT_EXPR = WALK + `(() => {
479
493
  const type=el.getAttribute('type')||'';
480
494
  let name=(el.getAttribute('aria-label')||el.getAttribute('placeholder')||(el.value||'')||el.innerText||el.textContent||el.getAttribute('title')||el.getAttribute('name')||'').toString().trim().replace(/\\s+/g,' ').slice(0,80);
481
495
  out.push({ref,role,tag,type,name,state:stateOf(el)});
482
- });
483
- return {url:location.href,title:document.title,count:out.length,elements:out};
496
+ }
497
+ // The open overlay's full text — so a caller can read a dialog's prompt
498
+ // (e.g. "send this invitation to <name>", an email-gate warning) WITHOUT a
499
+ // second round-trip. That matters for light-dismiss popovers, which close on
500
+ // the next stray interaction: getting refs + prompt text in one snapshot lets
501
+ // the caller verify and act before the overlay can vanish. Prefer a top-layer
502
+ // popover (always stacked on top); else the last-in-DOM ARIA overlay.
503
+ let overlayText='';
504
+ try{
505
+ const pops=[...document.querySelectorAll('[popover]')].filter(e=>{try{return e.matches(':popover-open')}catch(x){return false}});
506
+ const others=[...document.querySelectorAll(OVERLAY)].filter(e=>__baVisible(e));
507
+ const r=pops.length?pops[pops.length-1]:(others.length?others[others.length-1]:null);
508
+ if(r) overlayText=(r.innerText||'').replace(/\\s+/g,' ').trim().slice(0,600);
509
+ }catch(e){}
510
+ return {url:location.href,title:document.title,count:out.length,overlayCount:overlayEls.length,overlayText,elements:out};
484
511
  })()`;
485
512
  function clickExpr(ref) {
486
513
  const r = JSON.stringify(ref);
@@ -596,7 +623,9 @@ const snapshotCommand = define({
596
623
  process.stdout.write(JSON.stringify(snap, null, 2) + "\n");
597
624
  return;
598
625
  }
599
- consola.log(`# ${snap.title}\n# ${snap.url}\n# ${snap.count} interactive elements`);
626
+ const overlayNote = snap.overlayCount ? ` (${snap.overlayCount} in an open overlay, listed first)` : "";
627
+ consola.log(`# ${snap.title}\n# ${snap.url}\n# ${snap.count} interactive elements${overlayNote}`);
628
+ if (snap.overlayText) consola.log(`# overlay: ${snap.overlayText}`);
600
629
  for (const el of snap.elements) {
601
630
  const label = el.type ? `${el.role}[${el.type}]` : el.role;
602
631
  const st = el.state ? `[${el.state}] ` : "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@generativereality/browser-automation",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
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": {