← Commit history

The toolbar extension becomes a launch arg (John repinned pup to Chrome for Testing after the branded-Chrome extension lockdown made every install path ugly). CfT still honors load-extension, so when the driving browser is CfT and the toolbarExtension setting is on, every profile launch simply carries the flag and every window is born with the toolbar: there is no install step at all. The transient pipe-install experiment is deleted (verified session-scoped, useless with detached launches), staging is a plain file copy, the flag rides only chrome-for-testing candidates since branded Chrome removed it, and pup_install_toolbar is now informational

John Lauer ·e74b3f2458 ·2mo ago ·parent 578e0d8
4 files changed +36−58
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "2.0.52",-  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.52/adom-bridge-puppeteer-v2.0.52.zip",-  "sha256": "c6f12701732ebb1005571e879ebd288c158cc98a6c96f31036a54b8d8afffc0c",-  "size": 742025,+  "version": "2.0.53",+  "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.53/adom-bridge-puppeteer-v2.0.53.zip",+  "sha256": "0eab211a2c19c2f2d6940699830e99274860fbd8180eeb930f07a6edc02a6590",+  "size": 741570,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-2.0.52+2.0.53
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "2.0.52",+  "version": "2.0.53",   "description": "Drives a browser ALREADY on the machine \u2014 installed Chrome, else Microsoft Edge (every Windows PC ships with Edge) \u2014 launched with a FRESH isolated profile, so the common case has NO ~150 MB Chrome-for-Testing download and it never touches the user's real tabs/logins. Binds its local server to LOOPBACK (127.0.0.1) only, so no Windows Firewall 'allow Node through the firewall' prompt ever pops. Chrome for Testing is fetched only as a LAST RESORT if the machine has no Chromium browser at all. SPAWN-VERIFIED fallback: pup tries each detected browser (Chrome \u2192 Edge \u2192 CfT) and actually launches it, falling through to the next if one won't start (and handling browsers like Edge that relaunch onto another PID), so a corrupt/partial install never hard-fails an open. The browser that launches is cached as the default (persisted across restarts) so it isn't re-probed each time. On spawn the bridge SELF-WARMS: detects browsers + disk, and only if the box has no Chrome/Edge and no cached CfT does it background-fetch CfT so the first open is instant. pup_use pins a specific browser (chrome | edge | cft | auto); {browser:'chrome',install:true} downloads & installs REAL Google Chrome (user-scoped, no admin) on an Edge-only box. pup_readiness (READ-ONLY) reports which browser will be used + the full candidate list + the default + free disk. Every failure returns a specific errorCode + _hint (chrome_install_no_disk, chrome_download_network, chrome_install_permission, chrome_stable_not_detected, \u2026). Launches with FULL browser permissions by default for full debug (strictPermissions:true opts out). Headful automation: open/close windows+tabs, navigate, screenshot, eval JS, record. pup is a GENERIC, non-profile browser only \u2014 every session is a fresh isolated Chrome/Edge process, never the user's real signed-in browser; profile defaults to sessionId. To drive the user's REAL Chrome/Edge (their profile, cookies, SSO), use the Adom browser EXTENSION's nbrowser_* verbs \u2014 a separate bridge, not pup's job. macOS (v1.9.74+): full parity with mac-native mechanics \u2014 background-by-default is the app-level hide (windows stay drivable/screenshottable while hidden), raise/lower map to unhide+activate/hide, pup_alert_window posts a native toast whose click focuses the window, pup_use {browser:'chrome',install:true} installs Chrome from the official dmg, and taskbar identity/badging remains Windows-only.",   "homepage": "https://wiki.adom.inc/adom/adom-bridge",   "author": "Adom Inc.",
src/server.js+30−52
@@ -5518,36 +5518,25 @@ async function showCaptureToast(pg, previewDataUrl, line1) {   } catch (e) {} } -async function ensureToolbarExtensionInstalled(userDataDir, executablePath) {-  if (process.platform !== 'win32' || !userDataDir) return false;-  if (pupSettings().toolbarExtension === 'off') return false;+// v2.0.53 (John repinned pup to CfT): the toolbar extension is now a LAUNCH ARG. Chrome for+// Testing still honors --load-extension (branded Chrome >=137 removed it), so when the driving+// browser is CfT and the toolbarExtension setting is on, every profile launch carries the flag+// and every window is BORN with the toolbar: no install step exists at all. This helper just+// stages the extension files at a stable path for the flag to point at.+function stageToolbarExtension() {+  if (process.platform !== 'win32') return null;+  if (pupSettings().toolbarExtension === 'off') return null;   const srcDir = path.join(__dirname, 'extension');-  let extVer = '0';-  try { extVer = JSON.parse(fs.readFileSync(path.join(srcDir, 'manifest.json'), 'utf8')).version; } catch (e) { return false; }-  const marker = path.join(userDataDir, '.pup-toolbar-installed');-  try { if (fs.readFileSync(marker, 'utf8').trim() === extVer) return true; } catch (e) {}-  // stage at a stable absolute path (the profile references it)+  if (!fs.existsSync(path.join(srcDir, 'manifest.json'))) return null;   const dstDir = path.join(os.homedir(), '.adom', 'pup-extension');   try {     fs.mkdirSync(dstDir, { recursive: true });-    for (const f of fs.readdirSync(srcDir)) fs.copyFileSync(path.join(srcDir, f), path.join(dstDir, f));-  } catch (e) { return false; }-  let tb = null;-  try {-    tb = await puppeteer.launch({-      pipe: true, enableExtensions: true, userDataDir,-      ...(executablePath ? { executablePath } : {}),-      args: ['--no-first-run', '--no-default-browser-check', '--window-position=-32000,-32000', '--window-size=1,1'],-      handleSIGINT: false, handleSIGTERM: false, handleSIGHUP: false,-    });-    const id = await tb.installExtension(dstDir);-    fs.writeFileSync(marker, extVer);-    console.log(`[toolbar] extension v${extVer} auto-installed into profile "${path.basename(userDataDir)}" (pipe launch, id ${id}) — every window on this profile is born with the toolbar`);-    return true;-  } catch (e) {-    console.log(`[toolbar] pre-launch extension install failed: ${e.message} — continuing without the toolbar`);-    return false;-  } finally { try { if (tb) await tb.close(); } catch (e) {} }+    for (const f of fs.readdirSync(srcDir)) {+      const sp = path.join(srcDir, f), dp = path.join(dstDir, f);+      try { const a = fs.statSync(sp), b = fs.existsSync(dp) && fs.statSync(dp); if (!b || b.size !== a.size) fs.copyFileSync(sp, dp); } catch (e) { fs.copyFileSync(sp, dp); }+    }+    return dstDir;+  } catch (e) { return null; } } async function startAnnotation(session, sessionId, callerThread, opts) {   const tab = (session.activeTabId && (session.tabs || []).find(t => t.tabId === session.activeTabId)) || (session.tabs || [])[0];@@ -7960,14 +7949,8 @@ async function getOrLaunchBrowser(profileName, { freshProfile = false, strictPer       return b;     }; -    // v2.0.52 (John: "why can't your extension just auto-exist in pup? you control the-    // browser"): IT DOES NOW. Before a profile's Chrome ever launches, pup does an invisible-    // ~2s pipe-launch of the SAME profile and installs the toolbar extension via CDP-    // Extensions.loadUnpacked (puppeteer enableExtensions/installExtension — the sanctioned-    // replacement for --load-extension, which branded Chrome >=137 removed). The extension-    // persists in the profile, so every window is simply BORN with the toolbar. No dialogs,-    // no chrome://extensions driving, no user action, ever. Marker-gated per extension version.-    try { await ensureToolbarExtensionInstalled(userDataDir, (candidates[0] || {}).executablePath); } catch (e) {}+    // v2.0.53: stage the toolbar extension; CfT candidates carry it as --load-extension below.+    const _tbExtDir = stageToolbarExtension();      // ─── Spawn-verified launch: try each candidate browser in order, up to 3 ───     // attempts each (with orphan/lock cleanup between attempts). If a browser can't@@ -7987,6 +7970,9 @@ async function getOrLaunchBrowser(profileName, { freshProfile = false, strictPer     for (const cand of launchList) {       if (cand.executablePath) launchOpts.executablePath = cand.executablePath;       else delete launchOpts.executablePath;+      // v2.0.53: the toolbar rides ONLY on CfT (branded Chrome ignores/removed the flag).+      launchOpts.args = launchOpts.args.filter(a => !a.startsWith('--load-extension='));+      if (_tbExtDir && cand.kind === 'chrome-for-testing') launchOpts.args.push(`--load-extension=${_tbExtDir}`);       lastErr = null;       for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {         try {@@ -13903,24 +13889,16 @@ const server = http.createServer(async (req, res) => {           return;         }         case 'pup_install_toolbar': {-          // v2.0.52: thin now — the extension AUTO-INSTALLS at profile launch (see-          // ensureToolbarExtensionInstalled). This verb covers the one already-running-profile-          // case: it reports what to do, or installs immediately when the profile is cold.-          if (process.platform !== 'win32') { sendJSON(res, { success: false, error: 'windows only' }); return; }-          try {-            const profileName = args.profile || 'adom-you';-            const userDataDir = path.join(PROFILES_DIR, profileName);-            const be = browsers.get(profileName);-            const running = !!(be && be.browser && be.browser.isConnected());-            if (running) {-              const marker = path.join(userDataDir, '.pup-toolbar-installed');-              let installed = false; try { installed = !!fs.readFileSync(marker, 'utf8').trim(); } catch (e) {}-              sendJSON(res, { success: true, output: JSON.stringify({ ok: true, installed, running: true, _hint: installed ? 'Toolbar already installed in this profile.' : 'Profile Chrome is running; the toolbar auto-installs on the profile\'s NEXT launch (close its windows or wait for the natural restart — no action needed).' }) });-              return;-            }-            const okInst = await ensureToolbarExtensionInstalled(userDataDir, null);-            sendJSON(res, { success: okInst, output: JSON.stringify({ ok: okInst, installedNow: okInst }) });-          } catch (e) { sendJSON(res, { success: false, error: e.message }); }+          // v2.0.53: nothing to install anymore — on CfT the toolbar is a launch arg. This verb+          // reports the state so agents can explain it.+          const cft = (chrome && chrome.readiness) ? chrome.readiness() : {};+          const staged = stageToolbarExtension();+          sendJSON(res, { success: true, output: JSON.stringify({+            ok: true, mode: 'launch-flag', stagedAt: staged,+            driving: cft.browserKind || null,+            active: !!staged && cft.browserKind === 'chrome-for-testing',+            _hint: staged ? (cft.browserKind === 'chrome-for-testing' ? 'Toolbar auto-loads on every profile launch (CfT --load-extension).' : `Driving browser is ${cft.browserKind}; the toolbar flag only works on Chrome for Testing — pup_use {browser:"cft"} to enable.`) : 'toolbarExtension is off in settings (or non-Windows).',+          }) });           return;         }         case 'pup_annotate': {