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.46: resolve real browser window via EnumWindows so background park actually works and click-to-view shows the window
5 files changed
+92−45
CHANGELOG.md+14@@ -1,5 +1,19 @@ # Changelog — Adom Desktop Puppeteer Bridge +## 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+`Get-Process(pid).MainWindowHandle`, which on some boxes (John's laptop) returns a **hidden Chrome helper+window**, not the real browser window. So `SetWindowPos` moved a phantom, the real window stayed at its+off-screen launch coords (`screenX -21333`), and the "backgrounded" self-check passed against the phantom —+a **false positive**. Clicking the taskbar activated an off-screen window = nothing visible. Proven by+contrast: CDP `Browser.setWindowBounds` (which `raise` uses) put the same window at `0,0 1708×1068` first try.++- **Resolve the real window by ENUMERATION** (`EnumWindows`): the largest VISIBLE top-level+ `Chrome_WidgetWin_1` owned by the browser's pid (or its children). Replaces the flaky `MainWindowHandle`+ in `osBackgroundWindowByPid` AND `osClearFlashByActivate`. The park now actually moves the real window+ on-screen at z-bottom, so a taskbar click shows it — and the self-verify is honest.+ ## 1.8.45 — 2026-07-14 — User↔AI window balance + real flash clear + programmatic flash state Three related fixes, all from John's live testing. Governing rule now written into `pup-bridge-dev`
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.8.45",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.45/adom-bridge-puppeteer-v1.8.45.zip",- "sha256": "0f649ea50c4b367b5925734ee76d039b1dc02a157ec48f5b99aa857037735d25",- "size": 163240,+ "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, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.8.45+1.8.46
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.8.45",+ "version": "1.8.46", "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+72−39@@ -1586,9 +1586,15 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { const scriptPath = path.join(require('os').tmpdir(), `_adom_bgpid_${pid || port}.ps1`); const ps = [ 'Add-Type @"',- 'using System; using System.Runtime.InteropServices;',+ 'using System; using System.Runtime.InteropServices; using System.Text;', 'public struct LASTINPUTINFO { public uint cbSize; public uint dwTime; }', 'public class WinBgP {',+ ' 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 int GetClassName(IntPtr h, StringBuilder s, int m);',+ ' public struct RECT { public int L; public int T; public int R; public int B; }',+ ' [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);', ' [DllImport("user32.dll")] public static extern bool GetLastInputInfo(ref LASTINPUTINFO plii);', ' [DllImport("kernel32.dll")] public static extern uint GetTickCount();', ' [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h, IntPtr a, int x, int y, int cx, int cy, uint f);',@@ -1599,6 +1605,24 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { ' [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);', ' [DllImport("user32.dll")] public static extern bool BringWindowToTop(IntPtr h);', ' [DllImport("kernel32.dll")] public static extern uint GetCurrentThreadId();',+ // Find the REAL browser window for a set of pids: the largest VISIBLE top-level+ // Chrome_WidgetWin_1 window. MainWindowHandle returns a hidden helper on some boxes+ // (that was the "park silently fails, window stuck off-screen" bug) — enumerate instead.+ ' public static IntPtr BestWindow(int[] pids) {',+ ' IntPtr best = IntPtr.Zero; long bestArea = -1;',+ ' EnumWindows(delegate(IntPtr h, IntPtr l) {',+ ' if (!IsWindowVisible(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}`,@@ -1608,18 +1632,16 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { '$SWP = 0x10', // SWP_NOACTIVATE (allow move+size) '$scrW = [WinBgP]::GetSystemMetrics(0)', // SM_CXSCREEN (primary monitor) '$scrH = [WinBgP]::GetSystemMetrics(1)', // SM_CYSCREEN- '$handles = New-Object System.Collections.ArrayList',- '$pids = New-Object System.Collections.ArrayList',- 'if ($targetPid -ne 0) { [void]$pids.Add($targetPid) }',+ '$pidList = New-Object System.Collections.ArrayList',+ 'if ($targetPid -ne 0) { [void]$pidList.Add([int]$targetPid) }', // The process LISTENING on the CDP port is unambiguously the real browser.- 'if ($cdpPort -ne 0) { try { $own = Get-NetTCPConnection -LocalPort $cdpPort -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty OwningProcess; if ($own) { [void]$pids.Add([int]$own) } } catch {} }',- // For each anchor pid, take its own window + any chrome/msedge child windows.- 'foreach ($tp in $pids) {',- ' $p = Get-Process -Id $tp -ErrorAction SilentlyContinue',- ' if ($p -and $p.MainWindowHandle -ne 0) { [void]$handles.Add($p.MainWindowHandle) }',- ' Get-CimInstance Win32_Process -Filter "ParentProcessId=$tp" -ErrorAction SilentlyContinue | Where-Object { $_.Name -in @("chrome.exe","msedge.exe") } | ForEach-Object { $cp = Get-Process -Id $_.ProcessId -ErrorAction SilentlyContinue; if ($cp -and $cp.MainWindowHandle -ne 0) { [void]$handles.Add($cp.MainWindowHandle) } }',- '}',- 'if ($handles.Count -eq 0) { Write-Output "no-window"; exit }',+ '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 {} }',+ // Include child chrome/msedge pids — the real top-level window may belong to a child.+ '$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) } }',+ // Resolve the ONE real browser window (largest visible Chrome_WidgetWin_1), not a helper.+ '$pup = [WinBgP]::BestWindow([int[]]@($pidList.ToArray()))',+ 'if ($pup -eq [IntPtr]::Zero) { Write-Output "no-window"; exit }', // v1.8.44: if the USER deliberately raised this window (clicked its taskbar button to // WATCH a page load), do NOT fight them. A physical input in the last ~1.5s WITH the pup // window already foreground means the user took it — not Chrome self-raising (which is@@ -1628,9 +1650,7 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { `$respectUser = ${respectUser ? 1 : 0}`, 'if ($respectUser -eq 1) {', ' $fg0 = [WinBgP]::GetForegroundWindow()',- ' $isPup0 = $false',- ' foreach($h in $handles){ if($h -eq $fg0){ $isPup0 = $true } }',- ' if ($isPup0) {',+ ' if ($fg0 -eq $pup) {', ' $lii = New-Object LASTINPUTINFO', ' $lii.cbSize = [uint32][System.Runtime.InteropServices.Marshal]::SizeOf($lii)', ' [WinBgP]::GetLastInputInfo([ref]$lii) | Out-Null',@@ -1644,7 +1664,7 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { // the moment the human takes it, it becomes a real usable window. ' $vw = [int]($scrW * 0.8); $vh = [int]($scrH * 0.8)', ' $vx = [int](($scrW - $vw) / 2); $vy = [int](($scrH - $vh) / 2)',- ' foreach($hh in $handles){ [WinBgP]::SetWindowPos($hh, [IntPtr]0, $vx, $vy, $vw, $vh, 0x40) | Out-Null }', // HWND_TOP, SWP_SHOWWINDOW+ ' [WinBgP]::SetWindowPos($pup, [IntPtr]0, $vx, $vy, $vw, $vh, 0x40) | Out-Null', // HWND_TOP, SWP_SHOWWINDOW ' Write-Output "user-foreground"; exit', ' }', ' }',@@ -1652,16 +1672,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).- 'foreach($h in $handles){ [WinBgP]::SetWindowPos($h, $BOTTOM, 0, 0, $scrW, $scrH, $SWP) | Out-Null }',+ '[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. '$fg = [WinBgP]::GetForegroundWindow()',- '$isPup = $false',- 'foreach($h in $handles){ if($h -eq $fg){ $isPup = $true } }',- 'if ($isPup -and $restore -ne [IntPtr]::Zero) {',+ 'if ($fg -eq $pup -and $restore -ne [IntPtr]::Zero) {', ' $procId = [uint32]0', ' $pupTid = [WinBgP]::GetWindowThreadProcessId($fg, [ref]$procId)', ' $myTid = [WinBgP]::GetCurrentThreadId()',@@ -1672,9 +1690,7 @@ function osBackgroundWindowByPid(pid, cdpPort, restoreHwnd, respectUser) { '}', // Re-verify after the hand-back. '$fg2 = [WinBgP]::GetForegroundWindow()',- '$stillFg = $false',- 'foreach($h in $handles){ if($h -eq $fg2){ $stillFg = $true } }',- 'if ($stillFg) { Write-Output "still-foreground" } else { Write-Output "backgrounded" }',+ 'if ($fg2 -eq $pup) { Write-Output "still-foreground" } else { Write-Output "backgrounded" }', ].join('\r\n'); fs.writeFileSync(scriptPath, ps); const out = runPsHidden(scriptPath).trim();@@ -1696,8 +1712,14 @@ function osClearFlashByActivate(pid, cdpPort) { const scriptPath = path.join(require('os').tmpdir(), `_adom_clrflash_${pid || port}.ps1`); const ps = [ 'Add-Type @"',- 'using System; using System.Runtime.InteropServices;',+ 'using System; using System.Runtime.InteropServices; using System.Text;', 'public class WinClr {',+ ' 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 int GetClassName(IntPtr h, StringBuilder s, int m);',+ ' public struct RECT { public int L; public int T; public int R; public int B; }',+ ' [DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);', ' [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h, IntPtr a, int x, int y, int cx, int cy, uint f);', ' [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();', ' [DllImport("user32.dll")] public static extern int GetSystemMetrics(int i);',@@ -1706,6 +1728,21 @@ function osClearFlashByActivate(pid, cdpPort) { ' [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr h);', ' [DllImport("user32.dll")] public static extern bool BringWindowToTop(IntPtr h);', ' [DllImport("kernel32.dll")] public static extern uint GetCurrentThreadId();',+ ' public static IntPtr BestWindow(int[] pids) {',+ ' IntPtr best = IntPtr.Zero; long bestArea = -1;',+ ' EnumWindows(delegate(IntPtr h, IntPtr l) {',+ ' if (!IsWindowVisible(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}`,@@ -1714,24 +1751,20 @@ function osClearFlashByActivate(pid, cdpPort) { '$NOACT = 0x10', // SWP_NOACTIVATE '$scrW = [WinClr]::GetSystemMetrics(0)', '$scrH = [WinClr]::GetSystemMetrics(1)',- '$handles = New-Object System.Collections.ArrayList',- '$pids = New-Object System.Collections.ArrayList',- 'if ($targetPid -ne 0) { [void]$pids.Add($targetPid) }',- 'if ($cdpPort -ne 0) { try { $own = Get-NetTCPConnection -LocalPort $cdpPort -State Listen -ErrorAction SilentlyContinue | Select-Object -First 1 -ExpandProperty OwningProcess; if ($own) { [void]$pids.Add([int]$own) } } catch {} }',- 'foreach ($tp in $pids) {',- ' $p = Get-Process -Id $tp -ErrorAction SilentlyContinue',- ' if ($p -and $p.MainWindowHandle -ne 0) { [void]$handles.Add($p.MainWindowHandle) }',- ' Get-CimInstance Win32_Process -Filter "ParentProcessId=$tp" -ErrorAction SilentlyContinue | Where-Object { $_.Name -in @("chrome.exe","msedge.exe") } | ForEach-Object { $cp = Get-Process -Id $_.ProcessId -ErrorAction SilentlyContinue; if ($cp -and $cp.MainWindowHandle -ne 0) { [void]$handles.Add($cp.MainWindowHandle) } }',- '}',- 'if ($handles.Count -eq 0) { Write-Output "no-window"; exit }',- '$pup = $handles[0]',+ '$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 = [WinClr]::BestWindow([int[]]@($pidList.ToArray()))',+ 'if ($pup -eq [IntPtr]::Zero) { Write-Output "no-window"; exit }', '$myTid = [WinClr]::GetCurrentThreadId()', // Snapshot the user's current foreground so we can restore it. If it's ALREADY the pup // window, the user has it up (flash is moot) — do nothing. '$userFg = [WinClr]::GetForegroundWindow()',- 'foreach($h in $handles){ if($h -eq $userFg){ Write-Output "already-foreground"; exit } }',- // 1. Move every handle OFF-SCREEN (invisible), without activating.- 'foreach($h in $handles){ [WinClr]::SetWindowPos($h, $BOTTOM, -32000, -32000, $scrW, $scrH, $NOACT) | Out-Null }',+ 'if ($userFg -eq $pup) { Write-Output "already-foreground"; exit }',+ // 1. Move the window OFF-SCREEN (invisible), without activating.+ '[WinClr]::SetWindowPos($pup, $BOTTOM, -32000, -32000, $scrW, $scrH, $NOACT) | Out-Null', // 2. Activate the pup window off-screen → clears the taskbar attention tint. Bypass the // foreground lock by attaching our input thread to the current foreground's thread. '$uProc = [uint32]0',@@ -1742,7 +1775,7 @@ function osClearFlashByActivate(pid, cdpPort) { '[WinClr]::AttachThreadInput($uTid, $myTid, $false) | Out-Null', 'Start-Sleep -Milliseconds 60', // 3. Park back on-screen at z-bottom (invisible behind the user's windows).- 'foreach($h in $handles){ [WinClr]::SetWindowPos($h, $BOTTOM, 0, 0, $scrW, $scrH, $NOACT) | Out-Null }',+ '[WinClr]::SetWindowPos($pup, $BOTTOM, 0, 0, $scrW, $scrH, $NOACT) | Out-Null', // 4. Hand focus back to the user's window. '$pProc = [uint32]0', '$pTid = [WinClr]::GetWindowThreadProcessId($pup, [ref]$pProc)',