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
CRITICAL: pup painted an overlay on the user's real Microsoft Edge taskbar button (John: 'you should never be touching edge? what the fuck?'). Root cause: HWND RECYCLING. pup cached a session's hwnd; the real window changed and that handle died; Windows reuses hwnd NUMBERS, so the number was reassigned to an Edge window; the overlay paint trusted the stale cache and landed on Edge (confirmed: session pup-tour cached hwnd 10880418, which resolved to a dead pid-0 handle). THE FIX - proof-of-ownership on every OS-level window op: new hwndBelongsToPup() confirms an hwnd's owning pid (or parent pid) is one of pup's own browser processes; the overlay paint and the flash both REFUSE to act on any hwnd that fails this check (no bare-title or raw-cache fallback that could hit another app), and resolveSessionHwndByBounds now revalidates the cached _hwnd and discards a stale/foreign handle instead of trusting it. pup's guarantee that it never touches Edge is now enforced by proof, not intent. Recorded as a hard rule in dev-skills/pup-bridge-dev.
4 files changed
+77−10
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.9.277",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.277/adom-bridge-puppeteer-v1.9.277.zip",- "sha256": "c187ea95fbdc75678d51d6c7909cca9677beb8e8988176476d455f79cfd94dfa",- "size": 708886,+ "version": "1.9.278",+ "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.9.278/adom-bridge-puppeteer-v1.9.278.zip",+ "sha256": "610cc9d481ca064a2eae6e725b4df5747d4a8014eeabfce061e79ae845dc935f",+ "size": 710194, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.9.277+1.9.278
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.9.277",+ "version": "1.9.278", "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+71−4@@ -4411,9 +4411,16 @@ async function applyAppOverlay(session, sessionId) { console.log(`[overlay-debug] "${sessionId}" composed ${Buffer.from(overlay, 'base64').length}B -> ${_dbgPath} | src=${(src && src.href) || '?'} | hwnd=${session._hwnd || '(none, using title)'}`); } catch (e) { console.log(`[overlay-debug] dump failed: ${e.message}`); } if (!session._hwnd) { try { await resolveSessionHwndByBounds(session, sessionId); } catch (e) {} }- const _tgt = (session._hwnd ? { hwnd: session._hwnd } : { titleContains: `(session: ${sessionId}` });+ // v1.9.278 THE EDGE GUARD: paint ONLY to an hwnd proven to be a pup browser window. If we cannot+ // prove ownership (recycled/dead handle), REFUSE - never fall back to a bare title match that+ // could hit another app. A missed overlay this cycle self-heals next sweep; painting on Edge does not.+ if (!session._hwnd || !(await hwndBelongsToPup(session._hwnd))) {+ session._hwnd = null; session._appOverlay = false;+ console.log(`[overlay] "${sessionId}" REFUSED to paint โ no pup-owned hwnd confirmed (protecting non-pup taskbar buttons like Edge)`);+ return false;+ } await chrome.adCommand('desktop_taskbar', {- ..._tgt,+ hwnd: session._hwnd, overlay: { icon: overlay, tooltip: `Adom Pup โ ${nm}${plateAuthed ? 'Adom wiki: SIGNED IN ยท ' : ''}${tabs} tab${tabs === 1 ? '' : 's'}${tabs > 1 ? ' (icon = active tab)' : ''}` }, }, { timeoutMs: 5000 }); session._appOverlay = true;@@ -4652,10 +4659,66 @@ async function ensureWindowOpenedWatch() { // Break the circle with facts we already have: pup knows the profile's Chrome PID, and CDP tells us // the window's exact bounds. Enumerate that PID's top-level windows and match on geometry. Works for // any document type, needs no title, and the handle is then cached on the session.+// v1.9.278 (John: "why do i see a pup icon overlay over the msedge taskbar icon? you should never+// be touching edge?"). Root cause: pup cached a session's hwnd, the real window changed, the cached+// handle DIED, and Windows RECYCLES hwnd numbers - so that number was reassigned to an Edge window,+// and pup's overlay paint (which trusted the stale cache) landed on Edge. THE GUARANTEE, enforced+// below: pup only ever paints/flashes an hwnd it can PROVE belongs to one of its own browser+// processes. Any other hwnd is refused. pup can never touch Edge (or any app it did not launch).+function pupBrowserPidSet() {+ const pids = new Set();+ for (const [, be] of browsers) {+ try {+ const b = be && be.browser; if (!b) continue;+ if (b._detachedPid) pids.add(Number(b._detachedPid));+ const pr = b.process && b.process(); if (pr && pr.pid) pids.add(Number(pr.pid));+ } catch (e) {}+ }+ return pids;+}+async function hwndOwnerPid(hwnd) {+ if (process.platform !== 'win32' || !hwnd) return null;+ try {+ const sp = path.join(require('os').tmpdir(), `_adom_hpid_${process.pid}.ps1`);+ fs.writeFileSync(sp, [+ 'Add-Type @"',+ 'using System; using System.Runtime.InteropServices;',+ 'public class HPid { [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);',+ ' [DllImport("user32.dll")] public static extern bool IsWindow(IntPtr h); }',+ '"@',+ `$h = [IntPtr]${Number(hwnd)}`,+ 'if (-not [HPid]::IsWindow($h)) { Write-Output "0"; exit }',+ '$p = 0; [void][HPid]::GetWindowThreadProcessId($h, [ref]$p); Write-Output $p',+ ].join(String.fromCharCode(13, 10)));+ const out = (runPsHidden(sp, { timeout: 4000 }) || '').trim();+ const pid = Number(out); return Number.isFinite(pid) && pid > 0 ? pid : null;+ } catch (e) { return null; }+}+// Confirm an hwnd is a LIVE window owned by a pup browser process. Used as the hard gate before any+// taskbar paint/flash, and to invalidate a stale cached hwnd (recycled numbers).+async function hwndBelongsToPup(hwnd) {+ const pid = await hwndOwnerPid(hwnd);+ if (!pid) return false;+ // pupBrowserPidSet is the parent detached pids; the real window often belongs to a CHILD chrome.+ if (pupBrowserPidSet().has(pid)) return true;+ try {+ const sp = path.join(require('os').tmpdir(), `_adom_ppid_${process.pid}.ps1`);+ fs.writeFileSync(sp, `try { (Get-CimInstance Win32_Process -Filter "ProcessId=${pid}" -EA Stop).ParentProcessId } catch { 0 }`);+ const par = Number((runPsHidden(sp, { timeout: 4000 }) || '0').trim());+ if (par && pupBrowserPidSet().has(par)) return true;+ } catch (e) {}+ return false;+} async function resolveSessionHwndByBounds(session, sessionId) { if (process.platform !== 'win32' || !session) return null; try {- if (session._hwnd) return Number(session._hwnd);+ // v1.9.278: NEVER trust a cached hwnd blind - validate it still belongs to pup before reuse+ // (a dead/recycled handle now owned by Edge is exactly how the Edge overlay happened).+ if (session._hwnd) {+ if (await hwndBelongsToPup(session._hwnd)) return Number(session._hwnd);+ console.log(`[hwnd] "${sessionId}" cached hwnd ${session._hwnd} is stale/foreign โ discarding and re-resolving`);+ session._hwnd = null;+ } // v1.9.274 (John's dashboard showed 3 'untracked' windows that WERE the real session windows): // every parked window shares the IDENTICAL rect (work-area minus insets), so pure geometry // matching cannot distinguish windows after a restart and misassigns hwnds. The title tag is@@ -6049,7 +6112,11 @@ async function flashViaAD(sessionId, opts) { // them even if the session is gone or retitled by then. const session = sessions.get(sessionId); if (session && !session._hwnd) { try { await resolveSessionHwndByBounds(session, sessionId); } catch (e) {} }- const tgt = (session && session._hwnd) ? { hwnd: session._hwnd } : { titleContains: `(session: ${sessionId}` };+ // v1.9.278: flash only a proven pup hwnd; else title match (a title tag can only exist on a pup+ // window). Never flash a bare recycled hwnd - same Edge-protection guarantee as the overlay paint.+ let _flashHwndOk = false;+ if (session && session._hwnd) { try { _flashHwndOk = await hwndBelongsToPup(session._hwnd); } catch (e) {} if (!_flashHwndOk) session._hwnd = null; }+ const tgt = _flashHwndOk ? { hwnd: session._hwnd } : { titleContains: `(session: ${sessionId}` }; if (!opts.stop && session && session._hwnd) _flashedHwnds.add(session._hwnd); const args = opts.stop ? { ...tgt, stop: true } : { ...tgt, mode: 'count', count: 4 }; try { return await chrome.adCommand('desktop_flash_window', args, { timeoutMs: 6000 }); }