app
Pup - the AI's own browser
Public Made by Adomby adom
pup gives your AI a real browser on your desktop that it drives completely, in the background, signed in as you: windows that never jump in front of your work, one shared profile that learns your logins, and every window labeled on the taskbar with its AI thread's name.
← Commit history
Stop the enum_windows flood John caught in ab's Activity Log. (1) enumChromeWidgetWindows now COALESCES concurrent callers into ONE desktop_enum_windows ab call and caches the result for 120ms, so the many independent sweeps (enforcer, park, flash, reconcile) that each enumerated every Chrome window in the same tick collapse to a single call; the birth and off-screen re-capture detection loops pass fresh:true to bypass the cache so they still see new windows appear. (2) resolveSessionHwndByBounds skipped only the geometry wiggle during its resolution cooldown but still fired the title find_window + natural-title enum on every sweep for an unresolvable session; both OS-probe passes are now gated behind the backoff too, so a stuck session stops hammering ab (the 30s-throttled off-screen re-capture still runs, so it self-heals).
4 files changed
+44−24
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "2.0.147",- "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.147/adom-bridge-puppeteer-v2.0.147.zip",- "sha256": "4d12772b7c9ce3873c858bf0319b2da3d6ff00264f91f1a9674cdd02f92bab52",- "size": 898981,+ "version": "2.0.148",+ "url": "https://wiki.adom.inc/download/adom/pup-bridge/2.0.148/adom-bridge-puppeteer-v2.0.148.zip",+ "sha256": "1c7445289f50f015e846f55358783c8d0e9e47abd0473924ad12d28d195a79aa",+ "size": 899573, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-2.0.147+2.0.148
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "2.0.147",+ "version": "2.0.148", "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+38−18@@ -6786,21 +6786,36 @@ async function hwndBelongsToPup(hwnd, session) { } // v1.9.304: enumerate every visible top-level Chrome browser frame with its owner pid + rect. Shared // by birth-time resolution (createPageInNewWindow) and the resolver. Returns [{h,pid,L,T,W,H}].-async function enumChromeWidgetWindows() {- // v2.0.27: native (desktop_enum_windows, ab 2.0.16+) — the EnumWindows-by-class PS is gone. Keeps- // the legacy row shape {h,pid,L,T,W,H}; includeOffscreen so a just-born window at -32000 resolves.+// v2.0.148 (John: "why are you calling enum_windows a bazillion times via ab?"): COALESCE + a tiny+// TTL cache. The enforcer/park/flash/reconcile sweeps each independently enumerate every Chrome+// window, so a single tick fired many identical desktop_enum_windows calls at ab within the same+// few ms — the flood John saw. (1) In-flight coalescing: concurrent callers share ONE ab call.+// (2) A 120ms result cache: a burst of back-to-back calls reuses one snapshot. 120ms is under the+// birth/re-capture loops' 120ms inter-try sleeps, so those still see fresh windows appear on their+// next iteration — pass {fresh:true} to bypass the cache entirely for the rare caller that must.+let _enumInflight = null;+let _enumCache = { at: 0, rows: null };+async function enumChromeWidgetWindows(opts) { if (process.platform !== 'win32') return [];- try {- const d = abPayload(await chrome.abCommand('desktop_enum_windows', { className: 'Chrome_WidgetWin_1', includeOffscreen: true }, { timeoutMs: 8000 }));- const rows = [];- for (const w of ((d && d.windows) || [])) {- if (w.visible === false) continue;- const r = w.rect || [];- const h = Number(w.hwnd);- if (h && Number.isFinite(Number(r[2]))) rows.push({ h, pid: Number(w.pid), L: Number(r[0]), T: Number(r[1]), W: Number(r[2]) - Number(r[0]), H: Number(r[3]) - Number(r[1]), title: String(w.title || '') });- }- return rows;- } catch (e) { return []; }+ const fresh = !!(opts && opts.fresh);+ if (!fresh && _enumCache.rows && Date.now() - _enumCache.at < 120) return _enumCache.rows;+ if (!fresh && _enumInflight) return _enumInflight;+ const run = (async () => {+ try {+ const d = abPayload(await chrome.abCommand('desktop_enum_windows', { className: 'Chrome_WidgetWin_1', includeOffscreen: true }, { timeoutMs: 8000 }));+ const rows = [];+ for (const w of ((d && d.windows) || [])) {+ if (w.visible === false) continue;+ const r = w.rect || [];+ const h = Number(w.hwnd);+ if (h && Number.isFinite(Number(r[2]))) rows.push({ h, pid: Number(w.pid), L: Number(r[0]), T: Number(r[1]), W: Number(r[2]) - Number(r[0]), H: Number(r[3]) - Number(r[1]), title: String(w.title || '') });+ }+ _enumCache = { at: Date.now(), rows };+ return rows;+ } catch (e) { return []; }+ })();+ if (!fresh) { _enumInflight = run; run.finally(() => { if (_enumInflight === run) _enumInflight = null; }); }+ return run; } // v1.9.309 (John: "how many times did you say you couldn't look up a window by title... you keep // duct-taping it instead of a permanent solution"). He counted right — 23 call sites resolved a@@ -6872,7 +6887,12 @@ async function resolveSessionHwndByBounds(session, sessionId) { // same-profile windows apart. A page title-observer that strips the tag just yields count 0 (or a // recycle yields >1), and we fall through to the wiggle — never guessing. This is what the earlier // titleTag gate blocked: the resolver could see the tag but was told not to use it.- try {+ // v2.0.148 (John's enum flood): during the resolution COOLDOWN, skip these OS-probe passes+ // (the title find_window + the natural-title enum) — they hammer ab every sweep for a session+ // that already failed to resolve 3x, and if they COULD resolve it the backoff would never have+ // accumulated. The 30s-throttled off-screen re-capture below still runs (v2.0.33), so a stuck+ // background window still self-heals; we just stop the per-sweep probe storm meanwhile.+ if (!_geomBackoff) try { const fw = abPayload(await chrome.abCommand('desktop_find_window', { titleContains: `(${TITLE_LABEL}: ${sessionId}` }, { timeoutMs: 5000, caller: sessionCaller(session) })); const cnt = fw && (fw.count != null ? fw.count : (fw.data && fw.data.count)); const b = fw && (fw.best || (fw.data && fw.data.best));@@ -6887,7 +6907,7 @@ async function resolveSessionHwndByBounds(session, sessionId) { // the recovery-continuity pid — John's own Chrome (same window class!) can never be matched even // if he has the identical page open. Same-title siblings yield 2+ matches and are refused // (bare > wrong). This is what finally re-resolves recovered windows the geometry never could.- try {+ if (!_geomBackoff) try { // v2.0.45 (the handle theft): the OS title mirrors the tab CHROME shows, which is NOT always // pup's activeTabId (tab adds leave Chrome on the last-opened tab while pup's bookkeeping says // the first). Asking the wrong title made this session uniquely match SOMEONE ELSE'S window.@@ -7022,7 +7042,7 @@ async function resolveSessionHwndByBounds(session, sessionId) { await cdp2.send('Browser.setWindowBounds', { windowId, bounds: { left: probeLeft, top: -33000, width: 900, height: 700 } }); let got = null; for (let i = 0; i < 8 && !got; i++) {- const rr = await enumChromeWidgetWindows();+ const rr = await enumChromeWidgetWindows({ fresh: true }); const moved = rr.filter(r => !hwndOwnedByOtherSession(r.h, sessionId) && _before.has(r.h) && _before.get(r.h) !== `${r.L},${r.T},${r.W},${r.H}`); if (moved.length === 1) got = moved[0].h; else if (moved.length > 1) { console.log(`[hwnd] "${sessionId}" re-capture saw ${moved.length} windows move at once — refusing (concurrent motion)`); break; }@@ -9048,7 +9068,7 @@ async function createPageInNewWindow(browser, profileName) { } if (process.platform === 'win32') { for (let i = 0; i < 20 && !capturedHwnd; i++) {- const rows = await enumChromeWidgetWindows();+ const rows = await enumChromeWidgetWindows({ fresh: true }); const fresh2 = rows.filter(r => !beforeHwnds.has(Number(r.h)) && !hwndOwnedByOtherSession(r.h, null)); if (fresh2.length === 1) { capturedHwnd = fresh2[0].h; break; } if (fresh2.length > 1) {