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.54: GetForegroundWindow replaces document.hasFocus for user-click detection; hasFocus lies for CDP-created windows
4 files changed
+36−27
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.8.53",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.53/adom-bridge-puppeteer-v1.8.53.zip",- "sha256": "0393446988db76888ec3e3e6ffb77b53f1ada772b3f66ec55ccf8a3c7dd6b19d",- "size": 168311,+ "version": "1.8.54",+ "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.54/adom-bridge-puppeteer-v1.8.54.zip",+ "sha256": "a594e60a3793403e78ea7219bbf75f99e7b59f2280450c1635034d005b49fa02",+ "size": 168525, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.8.53+1.8.54
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.8.53",+ "version": "1.8.54", "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+30−21@@ -1925,21 +1925,31 @@ function osMinimizeToBackground(pid, cdpPort, respectUser) { // no direct API (CDP has no z-order; AD has no send-to-back verb yet — issue filed). Minimal // PS: one P/Invoke signature, no window-finding, no pid guessing, hwnd comes from AD's native // desktop_find_window. Everything else in the park is CDP/AD direct.-function osSendHwndToBottom(hwnd) {- if (process.platform !== 'win32' || !hwnd) return false;+function osBottomUnlessForeground(hwnd) {+ if (process.platform !== 'win32' || !hwnd) return 'error'; try { const scriptPath = path.join(require('os').tmpdir(), `_adom_zbot_${hwnd}.ps1`); const ps = [ 'Add-Type @"', 'using System; using System.Runtime.InteropServices;',- 'public class ZBot { [DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h, IntPtr a, int x, int y, int cx, int cy, uint f); }',+ 'public class ZBot {',+ ' [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();',+ '}', '"@',- `[ZBot]::SetWindowPos([IntPtr]${Number(hwnd)}, [IntPtr]1, 0, 0, 0, 0, 0x13) | Out-Null`, // HWND_BOTTOM; SWP_NOSIZE|NOMOVE|NOACTIVATE+ // THE OS truth: GetForegroundWindow. (document.hasFocus() via CDP LIES for CDP-created+ // windows — it reports internal focus even when the OS never foregrounded them, which+ // false-fired 'user-foreground' on every open in the first 1.8.53 build.) With+ // --no-startup-window, OS-foreground == the user clicked; then do NOT bottom it.+ `$h = [IntPtr]${Number(hwnd)}`,+ 'if ([ZBot]::GetForegroundWindow() -eq $h) { Write-Output "foreground"; exit }',+ '[ZBot]::SetWindowPos($h, [IntPtr]1, 0, 0, 0, 0, 0x13) | Out-Null', // HWND_BOTTOM; SWP_NOSIZE|NOMOVE|NOACTIVATE+ 'Write-Output "bottomed"', ].join('\r\n'); fs.writeFileSync(scriptPath, ps);- runPsHidden(scriptPath, { timeout: 5000 });- return true;- } catch (e) { return false; }+ const out = runPsHidden(scriptPath, { timeout: 5000 }).trim();+ return out || 'error';+ } catch (e) { return 'error'; } } // v1.8.53: THE park — direct APIs end to end (John: "why powershell? that's heavy. why aren't@@ -1950,7 +1960,8 @@ function osSendHwndToBottom(hwnd) { // taskbar during the launch gap (Chrome can't self-focus anymore) → move on-screen, leave // them on it, report 'user-foreground'. // 2. Z-bottom while still OFF-SCREEN (invisible): hwnd via AD desktop_find_window (native,-// title-suffix match), then osSendHwndToBottom (the one residual Win32 call).+// title-suffix match), then osBottomUnlessForeground (the one residual Win32 call,+// which ALSO reads GetForegroundWindow — the only honest user-click signal). // 3. Re-check focus (user may have clicked mid-park) → if so, on-screen + AD bring_to_front. // 4. CDP Browser.setWindowBounds → on-screen full-size. CDP addresses the EXACT window by // windowId, so the catch-2 failure mode (parked the wrong window) is impossible.@@ -1960,17 +1971,15 @@ async function parkSessionWindowDirect(page, sessionId) { if (process.platform !== 'win32') return null; let cdp = null; try {- const hasFocus = async () => { try { return await page.evaluate(() => document.hasFocus()); } catch (e) { return false; } }; cdp = await page.target().createCDPSession(); const { windowId } = await cdp.send('Browser.getWindowForTarget');- let scr = { w: 1280, h: 800 };+ let scr = { w: 1600, h: 900 }; try { scr = await page.evaluate(() => ({ w: screen.availWidth, h: screen.availHeight })); } catch (e) {}- const onScreenBounds = { left: 0, top: 0, width: scr.w, height: scr.h };- if (await hasFocus()) {+ const onScreenBounds = { left: 0, top: 0, width: Math.round(scr.w), height: Math.round(scr.h) };+ const placeOnScreen = async () => { await cdp.send('Browser.setWindowBounds', { windowId, bounds: { windowState: 'normal' } }); await cdp.send('Browser.setWindowBounds', { windowId, bounds: onScreenBounds });- return 'user-foreground';- }+ }; // hwnd via AD (native) — the title suffix "(session: <id>" is set by the welcome page. let hwnd = null; for (let i = 0; i < 4 && !hwnd; i++) {@@ -1981,17 +1990,17 @@ async function parkSessionWindowDirect(page, sessionId) { } catch (e) {} if (!hwnd) await new Promise(r2 => setTimeout(r2, 250)); }- if (hwnd) osSendHwndToBottom(hwnd);- if (await hasFocus()) {- // User clicked while we were parking — give them the window, foregrounded, on-screen.- await cdp.send('Browser.setWindowBounds', { windowId, bounds: { windowState: 'normal' } });- await cdp.send('Browser.setWindowBounds', { windowId, bounds: onScreenBounds });+ // Z-bottom while still off-screen — UNLESS the OS says the user has it foreground+ // (GetForegroundWindow, the only honest signal; document.hasFocus() lies for CDP windows).+ const z = osBottomUnlessForeground(hwnd);+ if (z === 'foreground') {+ // User clicked during the launch gap — give them the window on-screen, foregrounded.+ await placeOnScreen(); if (hwnd) { try { await chrome.adCommand('desktop_bring_to_front', { hwnd }, { timeoutMs: 3000 }); } catch (e) {} } return 'user-foreground'; } // On-screen full-size WITHOUT activation — CDP move preserves z-order (we're at bottom).- await cdp.send('Browser.setWindowBounds', { windowId, bounds: { windowState: 'normal' } });- await cdp.send('Browser.setWindowBounds', { windowId, bounds: onScreenBounds });+ await placeOnScreen(); // Verify POSITION, not just focus. let verified = false; try {