← Commit history

Issue #15 — pup now SELF-HEALS its dependencies instead of dying on every respawn. pup ships a source-only zip (node_modules is 88MB of native builds and cannot go in a wiki release) and the design assumes AD runs npm install in the bridge dir on spawn. In practice that does not reliably happen: AD re-provisions the cache dir on respawn, wiping any manual install, and the bridge then dies at require('puppeteer') with MODULE_NOT_FOUND. Reporter's words: 'pup keeps breaking and I always have to reinstall it' — and a human had to npm install by hand again TODAY to bring it back. A bridge that cannot start without a step someone else may not perform is not robust, so it now detects missing deps BEFORE the require that would crash and installs them itself: idempotent, only runs when deps are actually absent, and turns a hard crash-loop into a slow first start. This does not replace AD's install, it makes pup survive when that install did not happen. Also adds a browser_deps verb reporting depsPresent / selfInstalledThisBoot / lastError so 'pup is broken' can be diagnosed without reading the spawn log.

John Lauer ·4e0dd0e379 ·3mo ago ·parent b2b5e43
4 files changed +61−7
adom-bridge-puppeteer-manifest.json+4−4
@@ -1,10 +1,10 @@ {   "manifest_version": 1,   "name": "puppeteer",-  "version": "1.9.217",-  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.217/adom-bridge-puppeteer-v1.9.217.zip",-  "sha256": "7cac401e2f82ec56849fdaa8fc1daeb3314f2d41febf4ee6c735f46c08def853",-  "size": 443156,+  "version": "1.9.218",+  "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.218/adom-bridge-puppeteer-v1.9.218.zip",+  "sha256": "341f5a135ed65892de01f365491a044b58ce23b54c2aa916585b8a6eb2e6b5ce",+  "size": 444459,   "verbPrefixes": [     "browser_",     "desktop_recorder_",
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-1.9.217+1.9.218
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "1.9.217",+  "version": "1.9.218",   "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. browser_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. browser_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, browser_alert_window posts a native toast whose click focuses the window, browser_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-desktop",   "author": "Adom Inc.",
src/server.js+55−1
@@ -106,6 +106,43 @@ function macSessionPid(session) {   } catch (e) { return null; } } +// ── v1.9.218 — SELF-HEALING DEPENDENCIES (wiki issue #15) ───────────────────────────────────────+// pup ships as a SOURCE-ONLY zip (node_modules is 88MB of native builds — it cannot go in the wiki+// release), and the design assumes AD runs `npm install` in the bridge dir on spawn. In practice that+// does not reliably happen: AD re-provisions the cache dir on respawn, wiping any manual install, and+// the bridge then dies at this very line with MODULE_NOT_FOUND: Cannot find module 'puppeteer'. The+// user's lived experience, in the reporter's words, is "pup keeps breaking and I always have to+// reinstall it" — and a human had to npm install by hand again TODAY to bring it back.+//+// A bridge that cannot start without a step someone else may not perform is not robust. So: detect+// missing deps HERE, before the require that would crash, and install them ourselves. This is+// idempotent, runs only when deps are actually absent, and turns a hard crash-loop into a slow first+// start. It does not replace AD's install — it makes pup survive when that install did not happen.+function ensureDepsInstalled() {+  try {+    require.resolve('puppeteer');+    return { ok: true, installed: false };+  } catch (e) {+    // Deps are missing. Install them in OUR directory, synchronously, before anything requires them.+    const dir = __dirname;+    console.error(`[deps] node_modules missing (${e.code || 'MODULE_NOT_FOUND'}) — self-installing in ${dir}. This is wiki issue #15: the source-only zip ships no node_modules and AD's install did not run or was wiped by a respawn.`);+    const started = Date.now();+    try {+      const npmCmd = process.platform === 'win32' ? 'npm.cmd' : 'npm';+      execFileSync(npmCmd, ['install', '--omit=dev', '--no-audit', '--no-fund', '--loglevel=error'], {+        cwd: dir, stdio: 'inherit', timeout: 300000, windowsHide: true,+      });+      require.resolve('puppeteer');+      console.error(`[deps] self-install SUCCEEDED in ${Math.round((Date.now() - started) / 1000)}s — pup is starting normally. No human npm install needed.`);+      return { ok: true, installed: true };+    } catch (e2) {+      console.error(`[deps] self-install FAILED: ${e2.message}. pup cannot start. Check that node + npm are on PATH for the AD process, then retry, or run: cd "${dir}" && npm install`);+      return { ok: false, installed: false, error: e2.message };+    }+  }+}+const _depState = ensureDepsInstalled();+ const puppeteer = require('puppeteer'); const credentialVault = require('./credential_vault'); const chrome = require('./chrome'); // Chrome-for-Testing self-heal: detect / auto-install / readiness (cold-start fix)@@ -3368,7 +3405,7 @@ function clearSessionBusy(sessionId) { // Verbs that are pure status/polling: they do NOT mean an agent is driving the window, and lighting // the bar for them would make every window look permanently busy (the audit loops alone poll these). const PASSIVE_VERBS = new Set([-  'browser_list_windows', 'browser_list_tabs', 'browser_readiness', 'browser_status', 'browser_maximize', 'browser_hover',+  'browser_list_windows', 'browser_list_tabs', 'browser_readiness', 'browser_status', 'browser_maximize', 'browser_hover', 'browser_deps',   'browser_describe', 'browser_configure', 'browser_prewarm', 'browser_rescan', 'browser_wait', ]); @@ -10588,6 +10625,23 @@ const server = http.createServer(async (req, res) => {           sendJSON(res, { success: true, output: JSON.stringify({ ok: true, url: args.url, sessionId: resolvedId, tabId, ...(authSteerHint(args.url) ? { _hint: authSteerHint(args.url).trim() } : {}) }) });           return;         }+        case 'browser_deps': {+          // v1.9.218 (issue #15): report dependency health so "pup is broken" can be answered without+          // reading the spawn log. selfInstalled:true means the bridge repaired itself this boot.+          let resolved = false; try { require.resolve('puppeteer'); resolved = true; } catch (e) {}+          sendJSON(res, { success: true, output: JSON.stringify({+            ok: resolved, depsPresent: resolved,+            selfInstalledThisBoot: !!(_depState && _depState.installed),+            lastError: (_depState && _depState.error) || null,+            dir: __dirname,+            _hint: resolved+              ? (_depState && _depState.installed+                 ? 'Dependencies were MISSING at boot and pup self-installed them (wiki issue #15: the source-only zip ships no node_modules and AD\'s install did not run, or a respawn wiped it). No human npm install is needed.'+                 : 'Dependencies present. Normal state.')+              : 'Dependencies MISSING and self-install failed — pup cannot drive a browser. Ensure node + npm are on PATH for the AD process, then bridge_kill + bridge_resume to retry the self-install.',+          }) });+          return;+        }         case 'browser_readiness': {           // READ-ONLY readiness probe. NEVER triggers a download. `ready` reflects both           // server-up (this verb answered) AND Chrome-for-Testing cached. For the general