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
1.8.47: background via minimize (restore rect on-screen), remove re-park loop that fought user clicks, screenshots keep working via disabled occlusion
5 files changed
+157−33
CHANGELOG.md+17@@ -1,5 +1,22 @@ # Changelog — Adom Desktop Puppeteer Bridge +## 1.8.47 — 2026-07-14 — Background = MINIMIZE (no more re-park loop fighting the user's clicks)++The on-screen-z-bottom park needed a re-park retry loop to counter Chrome's startup foreground-grab,+and that loop fought the user: click a window to view it and pup yanked it back. Rebuilt the background+primitive around **minimize**, which removes the whole conflict:++- **Minimizing hands the foreground back to the user automatically** (no foreground-lock fight, no+ AttachThreadInput) — no focus steal, and no visible pop (the window launched off-screen).+- **The restore rectangle is set on-screen** (`SetWindowPlacement`), so a taskbar click restores the+ window centered + visible — **and it STAYS**, because there is NO on-screen re-park loop to yank it.+- **Screenshots still work** because Chrome already launches with occlusion detection disabled+ (`--disable-features=CalculateNativeWinOcclusion` + `--disable-backgrounding-occluded-windows`), so a+ minimized window keeps compositing frames.+- The only late passes are safety re-minimizes that RESPECT a user restore: the instant the window is+ un-minimized by a real click (physical input), pup latches `_userForeground` and never touches it again.+- `browser_lower_os_window` / post-resize re-park also minimize now. `raise` restores via CDP as before.+ ## 1.8.46 — 2026-07-14 — Resolve the REAL browser window (the background park was targeting a phantom) **The bug behind "I click a pup window and it never shows."** The background park resolved the window via
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.8.46",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.46/adom-bridge-puppeteer-v1.8.46.zip",- "sha256": "828bed5bf1aabe12265129a15f68abd6fc806ac4990c76a0e3b5b0f68948c4b2",- "size": 163740,+ "version": "1.8.47",+ "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.47/adom-bridge-puppeteer-v1.8.47.zip",+ "sha256": "fc25ab80bc72cbb34451bb1f599fc832af1b618f40a08aed55fd264660326e0f",+ "size": 165160, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.8.46+1.8.47
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.8.46",+ "version": "1.8.47", "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.", "homepage": "https://wiki.adom.inc/adom/adom-desktop", "author": "Adom Inc.",
src/server.js+134−27@@ -1669,15 +1669,14 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { ' }', ' }', '}',- // The window launched OFF-SCREEN (nothing popped up). Move it ON-SCREEN, sized to the- // monitor, at the BOTTOM of the z-order: fully behind the user's windows (invisible,- // never covering) but reachable via its taskbar button. No minimize (that flickers).- '[WinBgP]::SetWindowPos($pup, $BOTTOM, 0, 0, $scrW, $scrH, $SWP) | Out-Null',- // The browser grabbed keyboard focus on launch. Hand it straight back to the user's- // window. SetForegroundWindow is normally BLOCKED by the foreground lock, so we use the- // AttachThreadInput trick: attach the (current-foreground = pup) window's input thread- // to ours, which lets SetForegroundWindow succeed, then detach. This is what makes- // background-by-default NOT steal keystrokes.+ // ORDER MATTERS (v1.8.46): the browser grabbed the foreground on launch while it's still+ // OFF-SCREEN (invisible). Hand focus back to the user FIRST — deactivating the pup window+ // while it is off-screen — and ONLY THEN move it on-screen at z-bottom. If we moved it+ // on-screen first, it would flash visible on TOP for a moment (an active window stays+ // topmost until it is deactivated) = the "I saw the window open" pop. Deactivate, then park.+ // SetForegroundWindow is BLOCKED by the foreground lock, so use the AttachThreadInput trick:+ // attach the (current-foreground = pup) window's input thread to ours, SetForegroundWindow+ // the user's window, detach. This is what makes background-by-default NOT steal keystrokes. '$fg = [WinBgP]::GetForegroundWindow()', 'if ($fg -eq $pup -and $restore -ne [IntPtr]::Zero) {', ' $procId = [uint32]0',@@ -1688,7 +1687,12 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { ' [WinBgP]::BringWindowToTop($restore) | Out-Null', ' [WinBgP]::AttachThreadInput($pupTid, $myTid, $false) | Out-Null', '}',- // Re-verify after the hand-back.+ // NOW pup is deactivated (still off-screen). Move it on-screen sized to the monitor at the+ // BOTTOM of the z-order (SWP_NOACTIVATE): fully behind the user's windows (invisible, never+ // covering) but reachable via its taskbar button. Because it is no longer the active+ // window, dropping it to HWND_BOTTOM keeps it hidden — no pop.+ '[WinBgP]::SetWindowPos($pup, $BOTTOM, 0, 0, $scrW, $scrH, $SWP) | Out-Null',+ // Re-verify: the user's window (not pup) should be foreground. '$fg2 = [WinBgP]::GetForegroundWindow()', 'if ($fg2 -eq $pup) { Write-Output "still-foreground" } else { Write-Output "backgrounded" }', ].join('\r\n');@@ -1698,6 +1702,109 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { } catch (e) { console.error(`[bg] pid ${pid} port ${cdpPort}: ${e.message}`); return 'error'; } } +// v1.8.47: THE background primitive, rebuilt around MINIMIZE (replaces the on-screen-z-bottom+// park + its re-park retry loop, which fought the user's clicks). Why minimize is correct:+// • Minimizing a foreground window hands the foreground back to the user's window AUTOMATICALLY+// (no foreground-lock fight, no AttachThreadInput) — R4 (no focus steal) for free.+// • We set the window's RESTORE rectangle on-screen (SetWindowPlacement rcNormalPosition), so a+// taskbar click restores it centered + visible — and it STAYS, because there is NO re-park loop+// to yank it back. This is exactly the user↔AI handoff John demanded.+// • Screenshots keep working (R3) because Chrome launches with occlusion detection disabled+// (--disable-features=CalculateNativeWinOcclusion + --disable-backgrounding-occluded-windows),+// so a minimized window still composites frames for Page.captureScreenshot.+// • No visible pop (R1): the window launched OFF-SCREEN, so minimizing it is never seen.+// respectUser (on the safety re-passes): if the window is NOT minimized and a real user input+// happened in the last ~1.5s, the USER restored it → return "user-foreground", do NOT re-minimize.+// Returns "minimized" | "user-foreground" | "still-foreground" | "no-window" | "error".+function osMinimizeToBackground(pid, cdpPort, respectUser) {+ if (process.platform !== 'win32' || (!pid && !cdpPort)) return 'error';+ try {+ const port = Number(cdpPort) || 0;+ const scriptPath = path.join(require('os').tmpdir(), `_adom_min_${pid || port}.ps1`);+ const ps = [+ 'Add-Type @"',+ 'using System; using System.Runtime.InteropServices; using System.Text;',+ 'public struct LASTINPUTINFO { public uint cbSize; public uint dwTime; }',+ 'public class WinMin {',+ ' public delegate bool EnumProc(IntPtr h, IntPtr l);',+ ' [DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc cb, IntPtr l);',+ ' [DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h);',+ ' [DllImport("user32.dll")] public static extern bool IsIconic(IntPtr h);',+ ' [DllImport("user32.dll")] public static extern int GetClassName(IntPtr h, StringBuilder s, int m);',+ ' public struct RECT { public int L; public int T; public int R; public int B; }',+ ' public struct POINT { public int X; public int Y; }',+ ' [StructLayout(LayoutKind.Sequential)] public struct WP { public int length; public int flags; public int showCmd; public POINT ptMin; public POINT ptMax; public RECT rc; }',+ ' [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);',+ ' [DllImport("user32.dll")] public static extern bool GetWindowPlacement(IntPtr h, ref WP p);',+ ' [DllImport("user32.dll")] public static extern bool SetWindowPlacement(IntPtr h, ref WP p);',+ ' [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();',+ ' [DllImport("user32.dll")] public static extern int GetSystemMetrics(int i);',+ ' [DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);',+ ' [DllImport("user32.dll")] public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);',+ ' [DllImport("kernel32.dll")] public static extern uint GetTickCount();',+ ' public static IntPtr BestWindow(int[] pids) {',+ ' IntPtr best = IntPtr.Zero; long bestArea = -1;',+ ' EnumWindows(delegate(IntPtr h, IntPtr l) {',+ ' if (!IsWindowVisible(h) && !IsIconic(h)) return true;',+ ' uint wp; GetWindowThreadProcessId(h, out wp);',+ ' bool m = false; foreach (int p in pids) { if ((uint)p == wp) { m = true; break; } }',+ ' if (!m) return true;',+ ' StringBuilder sb = new StringBuilder(256); GetClassName(h, sb, 256);',+ ' if (sb.ToString() != "Chrome_WidgetWin_1") return true;',+ ' RECT r; GetWindowRect(h, out r); long a = (long)(r.R - r.L) * (r.B - r.T);',+ ' if (a > bestArea) { bestArea = a; best = h; }',+ ' return true;',+ ' }, IntPtr.Zero);',+ ' return best;',+ ' }',+ '}',+ '"@',+ `$targetPid = ${Number(pid) || 0}`,+ `$cdpPort = ${port}`,+ '$scrW = [WinMin]::GetSystemMetrics(0)',+ '$scrH = [WinMin]::GetSystemMetrics(1)',+ '$pidList = New-Object System.Collections.ArrayList',+ 'if ($targetPid -ne 0) { [void]$pidList.Add([int]$targetPid) }',+ 'if ($cdpPort -ne 0) { try { $own = Get-NetTCPConnection -LocalPort $cdpPort -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty OwningProcess; if ($own) { [void]$pidList.Add([int]$own) } } catch {} }',+ '$anchors = @($pidList.ToArray())',+ 'foreach ($tp in $anchors) { Get-CimInstance Win32_Process -Filter "ParentProcessId=$tp" -ErrorAction SilentlyContinue | Where-Object { $_.Name -in @("chrome.exe","msedge.exe") } | ForEach-Object { [void]$pidList.Add([int]$_.ProcessId) } }',+ '$pup = [WinMin]::BestWindow([int[]]@($pidList.ToArray()))',+ 'if ($pup -eq [IntPtr]::Zero) { Write-Output "no-window"; exit }',+ // Already minimized = already parked. Never re-touch it (that would fight a user who is+ // about to/just restored it). This is what makes the design not yank the window.+ 'if ([WinMin]::IsIconic($pup)) { Write-Output "minimized"; exit }',+ `$respectUser = ${respectUser ? 1 : 0}`,+ 'if ($respectUser -eq 1) {',+ ' $fg0 = [WinMin]::GetForegroundWindow()',+ ' if ($fg0 -eq $pup) {',+ ' $lii = New-Object LASTINPUTINFO',+ ' $lii.cbSize = [uint32][System.Runtime.InteropServices.Marshal]::SizeOf($lii)',+ ' [WinMin]::GetLastInputInfo([ref]$lii) | Out-Null',+ ' $idle = [WinMin]::GetTickCount() - $lii.dwTime',+ ' if ($idle -lt 1500) { Write-Output "user-foreground"; exit }',+ ' }',+ '}',+ // Minimize WITHOUT activating (SW_SHOWMINNOACTIVE=7) and set the RESTORE rect on-screen+ // (centered ~80%), so a taskbar click restores it visible. PowerShell can only mutate a+ // struct field on the top-level variable, so build RECT separately and assign the whole rc.+ '$wp = New-Object -TypeName "WinMin+WP"',+ '$wp.length = [int][System.Runtime.InteropServices.Marshal]::SizeOf($wp)',+ '[WinMin]::GetWindowPlacement($pup, [ref]$wp) | Out-Null',+ '$vw = [int]($scrW * 0.8); $vh = [int]($scrH * 0.8); $vx = [int](($scrW - $vw)/2); $vy = [int](($scrH - $vh)/2)',+ '$rc = New-Object -TypeName "WinMin+RECT"',+ '$rc.L = $vx; $rc.T = $vy; $rc.R = $vx + $vw; $rc.B = $vy + $vh',+ '$wp.showCmd = 7',+ '$wp.rc = $rc',+ '[WinMin]::SetWindowPlacement($pup, [ref]$wp) | Out-Null',+ '$fg2 = [WinMin]::GetForegroundWindow()',+ 'if ($fg2 -eq $pup) { Write-Output "still-foreground" } else { Write-Output "minimized" }',+ ].join('\r\n');+ fs.writeFileSync(scriptPath, ps);+ const out = runPsHidden(scriptPath).trim();+ return out || 'error';+ } catch (e) { console.error(`[min] pid ${pid} port ${cdpPort}: ${e.message}`); return 'error'; }+}+ // v1.8.45: TRULY clear a window's taskbar attention (the orange/pink Win11 "flash" tint). // FLASHW_STOP only stops the PULSE — the tint persists until the window is ACTIVATED. So we // clear it the only way Windows allows: activate the window. To avoid a visible pop, we move@@ -2175,25 +2282,24 @@ async function getOrLaunchBrowser(profileName, { freshProfile = false, strictPer // can re-raise itself during startup (first paint, restore prompts). Resolve the // window via the CDP-port owner (reliable across launcher→browser pid relaunches). if (!foreground && process.platform === 'win32') {- b._bgResult = osBackgroundWindowByPid(child.pid, debugPort, priorForeground);- console.log(`[bg] initial background result for "${profileName}": ${b._bgResult}`);- // A couple of late passes: Chrome/Edge can re-grab foreground right after first paint,- // so re-run the background+focus-handback until startup settles. No minimize now, so- // these don't flicker. v1.8.44: these passes RESPECT a deliberate user raise — if the- // user clicks the taskbar button to watch the page load, osBackgroundWindowByPid returns- // "user-foreground"; we latch it and cancel the remaining passes so we never yank the- // window out from under them.+ // v1.8.47: MINIMIZE to background (see osMinimizeToBackground). Minimizing hands focus+ // back to the user automatically, and there is NO on-screen re-park loop to fight a+ // click. A few late passes only handle: (a) the window not existing yet at connect, and+ // (b) Chrome re-raising itself during first paint. They RESPECT a user restore — the+ // instant the window is un-minimized by a real click, we latch and STOP touching it.+ b._bgResult = osMinimizeToBackground(child.pid, debugPort);+ console.log(`[bg] initial minimize for "${profileName}": ${b._bgResult}`); const _bgTimers = [];- for (const delay of [600, 1400, 2500]) {+ for (const delay of [400, 900, 1600, 2600]) { const t = setTimeout(() => { try {- if (b._userForeground) return; // user already took it — leave it alone- const r = osBackgroundWindowByPid(child.pid, debugPort, priorForeground, true);- b._bgResult = r;+ if (b._userForeground) return; // user has it — never re-minimize+ const r = osMinimizeToBackground(child.pid, debugPort, true);+ if (r && r !== 'no-window') b._bgResult = r; if (r === 'user-foreground') { b._userForeground = true; for (const tt of _bgTimers) clearTimeout(tt);- console.log(`[bg] user raised "${profileName}" — respecting it, halting re-park`);+ console.log(`[bg] user restored "${profileName}" — respecting it, halting re-minimize`); } } catch (e) {} }, delay);@@ -3286,7 +3392,7 @@ const server = http.createServer(async (req, res) => { // v1.8.44: if the user deliberately raised this window to watch it, don't yank it // back on a resize either — honor the same latch the open-time retries set. if (be && be.browser && be.browser._userForeground) { /* user is watching — leave it */ }- else if (be && be.browser) be.browser._bgResult = osBackgroundWindowByPid(be.browser._detachedPid, be.browser._cdpPort, be.browser._priorForeground, true);+ else if (be && be.browser) be.browser._bgResult = osMinimizeToBackground(be.browser._detachedPid, be.browser._cdpPort, true); else osSendWindowToBack(args.profile); } catch (e) {} }@@ -3632,10 +3738,11 @@ const server = http.createServer(async (req, res) => { return; } const session = sessions.get(sessionId);- // v1.8.26: use the real focus-dropping backgrounder (minimize→show-no-activate),- // not the z-order-only one, so lowering actually relinquishes focus if held.+ // v1.8.47: minimize to background. An explicit lower is a deliberate re-park, so clear+ // the user-foreground latch too (the user/AI asked for it back in the background). const be = browsers.get(session.profileName);- const ok = (be && be.browser) ? (osBackgroundWindowByPid(be.browser._detachedPid, be.browser._cdpPort) === 'backgrounded') : osSendWindowToBack(session.profileName);+ if (be && be.browser) be.browser._userForeground = false;+ const ok = (be && be.browser) ? (osMinimizeToBackground(be.browser._detachedPid, be.browser._cdpPort) === 'minimized') : osSendWindowToBack(session.profileName); session._foreground = false; sendJSON(res, { success: true, output: JSON.stringify({ ok: true, sessionId, placement: 'background', applied: ok, _hint: 'Window sent behind the user\'s windows (still drivable/screenshottable). Keep pup in the background unless the user asked to watch.' }) }); return;