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
v1.8.22: screenshot_element below-fold clip fix + closest option
4 files changed
+37−18
adom-bridge-puppeteer-manifest.json+4−4@@ -1,10 +1,10 @@ { "manifest_version": 1, "name": "puppeteer",- "version": "1.8.21",- "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.21/adom-bridge-puppeteer-v1.8.21.zip",- "sha256": "86878af8b1666b1a3427f8d9c81f1f94b8dbe6b27935c573ca0a6da992c8336e",- "size": 148624,+ "version": "1.8.22",+ "url": "https://wiki.adom.inc/download/adom/adom-desktop-puppeteer-bridge/1.8.22/adom-bridge-puppeteer-v1.8.22.zip",+ "sha256": "cf9fd4e0332bf2539db4ac73c3b4b8306b6112efdc9c7062eaded7523f7c3395",+ "size": 149439, "verbPrefixes": [ "browser_", "desktop_recorder_",
src/BRIDGE_VERSION+1−1@@ -1 +1 @@-1.8.21+1.8.22
src/bridge.json+1−1@@ -2,7 +2,7 @@ "manifest_version": 1, "name": "puppeteer", "displayName": "Puppeteer (Chrome for Testing + Native)",- "version": "1.8.21",+ "version": "1.8.22", "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+31−12@@ -2637,7 +2637,7 @@ const server = http.createServer(async (req, res) => { V('browser_type', 'Type text into the focused/selected field.', { sessionId: 'required str', text: 'required str', selector: 'optional str' }, 20, { sessionId: 'work', text: 'hello' }), V('browser_press_key', 'Press a key / chord (e.g. Enter, Ctrl+A).', { sessionId: 'required str', key: 'required str' }, 15, { sessionId: 'work', key: 'Enter' }), V('browser_screenshot', 'Screenshot the page (PNG; fullPage optional). NOTE: fullPage only covers DOCUMENT-level scroll — on SPAs that scroll inside a nested container it returns just the viewport + a nestedScroll hint; use browser_screenshot_element or browser_scroll for those.', { sessionId: 'required str', fullPage: 'optional bool' }, 30, { sessionId: 'work' }),- V('browser_screenshot_element', 'Screenshot ONE element, resolved by CSS selector OR visible text (pierces shadow DOM), scrolled into view first. The clean way to grab a single card/widget on a component-heavy page. Returns base64 + filePath like browser_screenshot.', { sessionId: 'required str', selector: 'CSS selector (or use text)', text: 'visible text to match (or use selector)', padding: 'optional int px around the element', deep: 'optional bool — pierce shadow DOM (default true)' }, 30, { sessionId: 'work', text: 'Download for your machine' }),+ V('browser_screenshot_element', 'Screenshot ONE element, resolved by CSS selector OR visible text (pierces shadow DOM), scrolled into view first. The clean way to grab a single card/widget on a component-heavy page. Text matches the TIGHTEST text node — to capture the enclosing CARD, add closest (e.g. {text:"Download…", closest:".download-card"}); with closest, an ambiguous phrase still lands on the real widget (skips prose that has no such ancestor). Returns base64 + filePath like browser_screenshot.', { sessionId: 'required str', selector: 'CSS selector (or use text)', text: 'visible text to match (or use selector)', closest: 'optional selector — climb to the nearest ancestor matching it (the card container)', padding: 'optional int px around the element', deep: 'optional bool — pierce shadow DOM (default true)' }, 30, { sessionId: 'work', selector: '.download-card' }), V('browser_scroll', 'Scroll the ACTUAL scrolling element (nearest ancestor whose scrollHeight>clientHeight, NOT just window — window.scrollTo no-ops on nested-scroll SPAs). Scroll by delta {dy,dx} OR to an element {toSelector|toText} (pierces shadow DOM). Returns {scrollElement, scrollTop, scrollHeight, clientHeight} so you can confirm it landed.', { sessionId: 'required str', dy: 'optional int px (down+/up-)', dx: 'optional int px', toSelector: 'optional CSS selector to scroll to', toText: 'optional visible text to scroll to', block: 'optional start|center|end (for scroll-to; default center)', behavior: 'optional auto|smooth' }, 30, { sessionId: 'work', toText: 'Download' }), V('browser_set_viewport', 'Set the page viewport (CDP device-metrics) deterministically, independent of the OS window size — fixes a too-small innerWidth so fullPage/element shots render at a known width. width+height required.', { sessionId: 'required str', width: 'required int px', height: 'required int px', deviceScaleFactor: 'optional number (default 1)' }, 15, { sessionId: 'work', width: 1280, height: 900 }), V('browser_evaluate', 'Evaluate JS in the page; returns the result.', { sessionId: 'required str', expression: 'required str' }, 30, { sessionId: 'work', expression: 'document.title' }),@@ -3280,25 +3280,44 @@ const server = http.createServer(async (req, res) => { await ensureDeepHelpers(tab.page); let handle; try {- handle = await tab.page.evaluateHandle((sel, txt) => (sel ? window.$deep(sel) : window.deepText(txt)), args.selector || null, args.text || null);+ // Resolve by selector or text (shadow-piercing), then optionally climb to the+ // nearest matching ancestor with `closest` — e.g. {text:"Download…", closest:".card"}+ // grabs the whole CARD, not just the text node. Returns the FIRST text match+ // whose closest(sel) exists, so an ambiguous phrase (also in README prose) still+ // lands on the real widget.+ handle = await tab.page.evaluateHandle((sel, txt, closest) => {+ let el = sel ? window.$deep(sel) : null;+ if (!el && txt) {+ if (closest) {+ // scan all text matches, pick the first whose closest(sel) resolves+ const marks = [];+ const walk = (root) => { const a = root.querySelectorAll('*'); for (const e of a) {+ let own = ''; for (const c of e.childNodes) if (c.nodeType === 3) own += c.textContent;+ if (own.toLowerCase().indexOf(txt.toLowerCase()) !== -1) { const r = e.getBoundingClientRect(); if (r.width > 0 && r.height > 0) marks.push(e); }+ if (e.shadowRoot) walk(e.shadowRoot); } };+ walk(document);+ for (const m of marks) { const c = m.closest(closest); if (c) { el = c; break; } }+ } else { el = window.deepText(txt); }+ } else if (el && closest) { el = el.closest(closest) || el; }+ return el;+ }, args.selector || null, args.text || null, args.closest || null); const el = handle.asElement(); if (!el) { try { await handle.dispose(); } catch {}- sendJSON(res, { success: false, errorCode: 'element_not_found', error: `browser_screenshot_element: no element matched ${args.selector ? 'selector "'+args.selector+'"' : 'text "'+args.text+'"'} (searched, piercing shadow roots).`, sessionId: resolvedId, tabId });+ sendJSON(res, { success: false, errorCode: 'element_not_found', error: `browser_screenshot_element: no element matched ${args.selector ? 'selector "'+args.selector+'"' : 'text "'+args.text+'"'}${args.closest ? ' with a closest("'+args.closest+'") ancestor' : ''} (searched, piercing shadow roots).`, sessionId: resolvedId, tabId, _hint: 'If matching by text is ambiguous (the phrase also appears in prose), pass a `selector` for the widget, or a `closest` selector for its card container.' }); return; } await el.evaluate((e) => e.scrollIntoView({ block: 'center', inline: 'center' })); await new Promise(r => setTimeout(r, 150)); // let layout settle after scroll const pad = Number(args.padding) || 0;- let rawBuf;- if (pad > 0) {- const box = await el.boundingBox();- if (!box) throw new Error('element has no rendered box (hidden/zero-size)');- const clip = { x: Math.max(0, box.x - pad), y: Math.max(0, box.y - pad), width: box.width + 2 * pad, height: box.height + 2 * pad };- rawBuf = await withTimeout(tab.page.screenshot({ type: 'png', clip }), 20_000, 'element.screenshot(clip)');- } else {- rawBuf = await withTimeout(el.screenshot({ type: 'png' }), 20_000, 'element.screenshot');- }+ // Document-relative clip (getBoundingClientRect + scroll) + captureBeyondViewport —+ // this is coordinate-correct even when the element is below the fold (puppeteer's+ // boundingBox()/clip spaces mismatched and captured the wrong region).+ const rect = await el.evaluate((e, p) => { const r = e.getBoundingClientRect();+ return { x: r.left + (window.scrollX || 0) - p, y: r.top + (window.scrollY || 0) - p, width: r.width + 2 * p, height: r.height + 2 * p, vw: r.width, vh: r.height };+ }, pad);+ if (rect.vw < 1 || rect.vh < 1) throw new Error('element has no rendered box (hidden/zero-size)');+ const rawBuf = await withTimeout(tab.page.screenshot({ type: 'png', captureBeyondViewport: true, clip: { x: Math.max(0, Math.round(rect.x)), y: Math.max(0, Math.round(rect.y)), width: Math.round(rect.width), height: Math.round(rect.height) } }), 20_000, 'element.screenshot(clip)'); try { await handle.dispose(); } catch {} const shot = await processScreenshot(rawBuf, MAX_SCREENSHOT_DIM); const ts = Date.now();