← Commit history

v2.0.385 (insiders): Measured-progress fix: the timing helpers collided with an older same-named function later in the file (a later function declaration wins), so samples were never persisted; renamed to collision-proof names. Not promoted.

John Lauer ·de977ff5ee ·1mo ago ·parent 9338b50
4 files changed +11−11
package.json+1−1
@@ -1,6 +1,6 @@ {   "slug": "pup-bridge",-  "version": "2.0.384",+  "version": "2.0.385",   "type": "app",   "description": "The pup SKILL PACK \u2014 the AI skills that teach a cloud/container AI how to drive the Adom Desktop Puppeteer (pup) bridge (browser_* verbs): the everyday `pup` skill plus focused sub-skills for windows/sessions/tabs, screenshots+recording, browsers+Chrome install, and driving the Adom wiki. Installs into ~/.claude/skills + ~/.codex/skills. DOCS ONLY \u2014 this is NOT the bridge runtime. The bridge itself (the Node program that drives the browser) runs on the DESKTOP: Adom Desktop bundles it and auto-installs/updates it, and it's published separately on the Releases tab as adom-bridge-puppeteer-v<ver>.zip. The pkg version is kept in lockstep with the Release version so the page's max version row always carries BOTH a pkg tarball (skills) and a runtime zip (bridge) \u2014 a skills-only or runtime-only bump on the top row breaks constraint installs. TL;DR: pkg install = the skills for your AI; the bridge = the Release zip, which Adom Desktop manages for you.",   "keywords": [
src/BRIDGE_VERSION+1−1
@@ -1 +1 @@-2.0.384\ No newline at end of file+2.0.385\ No newline at end of file
src/bridge.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 1,   "name": "puppeteer",   "displayName": "Puppeteer (Chrome for Testing + Native)",-  "version": "2.0.384",+  "version": "2.0.385",   "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. pup_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. pup_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, pup_alert_window posts a native toast whose click focuses the window, pup_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-bridge",   "author": "Adom Inc.",
src/server.js+8−8
@@ -920,7 +920,7 @@ async function decryptBrowserCreds(argsObj) { // confidence is 'measured' only once there are enough of them. Exposed in pup_describe. const TIMINGS_PATH = path.join(os.homedir(), '.adom', 'pup-timings.json'); function _readTimings() { try { return JSON.parse(fs.readFileSync(TIMINGS_PATH, 'utf8')); } catch (e) { return {}; } }-function recordTiming(kind, ms) {+function pupTimingRecord(kind, ms) {   try {     const t = _readTimings(); const arr = Array.isArray(t[kind]) ? t[kind] : [];     arr.push(Math.round(ms)); while (arr.length > 20) arr.shift(); t[kind] = arr;@@ -928,13 +928,13 @@ function recordTiming(kind, ms) {     console.log(`[launch] timing recorded ${kind}=${Math.round(ms)}ms (${arr.length} samples)`);   } catch (e) { console.log(`[launch] timing record FAILED for ${kind}: ${e.message}`); } }-function timingEstimate(kind) {+function pupTimingEstimate(kind) {   const arr = (_readTimings()[kind] || []).slice().sort((a, b) => a - b);   if (!arr.length) return { estimatedSec: null, samples: 0, confidence: 'unknown' };   const med = arr[Math.floor(arr.length / 2)];   return { estimatedSec: Math.max(1, Math.round(med / 1000)), samples: arr.length, confidence: arr.length >= 3 ? 'measured' : 'estimated' }; }-function timingsSummary() { const t = _readTimings(); const o = {}; for (const k of Object.keys(t)) o[k] = timingEstimate(k); return o; }+function pupTimingsSummary() { const t = _readTimings(); const o = {}; for (const k of Object.keys(t)) o[k] = pupTimingEstimate(k); return o; } let _lastLaunchAt = 0, _lastLaunchMs = 0;          // set where the browser process is actually spawned const _inflightOpens = new Map();                  // id -> { t0, sessionId, thread } const _pendingConsents = new Map();                // toastId -> { since, what }@@ -942,8 +942,8 @@ const _pendingConsents = new Map();                // toastId -> { since, what } function openProgressFrame(t0) {   const launched = _lastLaunchAt >= t0;   const kind = launched ? 'cold' : 'warm';-  const el = Date.now() - t0; recordTiming('open_window_' + kind, el);-  const est = timingEstimate('open_window_' + kind);+  const el = Date.now() - t0; pupTimingRecord('open_window_' + kind, el);+  const est = pupTimingEstimate('open_window_' + kind);   return { phase: launched ? 'cold_start' : 'open_window', stepLabel: launched ? 'Launched the browser and opened the window' : 'Opened the window in the running browser',     percent: 100, elapsedSec: Math.round(el / 1000 * 10) / 10, estimatedSec: est.estimatedSec, etaSec: 0, confidence: est.confidence, startKind: kind,     launchMs: launched ? _lastLaunchMs : undefined };@@ -954,7 +954,7 @@ function activeProgress() {   for (const [id, o] of _inflightOpens) {     if (now - o.t0 > 180000) { _inflightOpens.delete(id); continue; }     const kind = (_lastLaunchAt >= o.t0) ? 'cold' : 'warm';-    const est = timingEstimate('open_window_' + kind); const el = (now - o.t0) / 1000;+    const est = pupTimingEstimate('open_window_' + kind); const el = (now - o.t0) / 1000;     const pct = est.estimatedSec ? Math.min(95, Math.round(el / est.estimatedSec * 100)) : null;     rows.push({ id, verb: 'pup_open_window', phase: kind === 'cold' ? 'cold_start' : 'open_window', stepLabel: (kind === 'cold' ? 'Launching the browser' : 'Opening the window') + (o.sessionId ? ` (${o.sessionId})` : ''),       percent: pct, elapsedSec: Math.round(el), estimatedSec: est.estimatedSec, etaSec: est.estimatedSec ? Math.max(0, Math.round(est.estimatedSec - el)) : null, confidence: est.confidence, startKind: kind });@@ -10828,7 +10828,7 @@ async function getOrLaunchBrowser(profileName, { freshProfile = false, strictPer           if (isDetachedLaunch) {             browser = await tryDetachedLaunch(attempt, cand.executablePath);           } else {-            { const _lt0 = Date.now(); browser = await puppeteer.launch(launchOpts); _lastLaunchMs = Date.now() - _lt0; _lastLaunchAt = Date.now(); try { recordTiming('browser_launch_' + (cand.kind || 'unknown'), _lastLaunchMs); } catch (e) {} }   // v2.0.383 (#59): measure the cold spawn+            { const _lt0 = Date.now(); browser = await puppeteer.launch(launchOpts); _lastLaunchMs = Date.now() - _lt0; _lastLaunchAt = Date.now(); try { pupTimingRecord('browser_launch_' + (cand.kind || 'unknown'), _lastLaunchMs); } catch (e) {} }   // v2.0.383 (#59): measure the cold spawn           }           chosen = cand;           lastErr = null;@@ -14866,7 +14866,7 @@ const server = http.createServer(async (req, res) => {           };           sendJSON(res, { success: true, bridge: 'puppeteer',             // v2.0.383 (#59/#64): the measured-progress contract, per the Bridge SDK.-            progressContract: { statusVerb: 'pup_readiness', activeKey: 'active', slowVerbs: ['pup_open_window', 'pup_prewarm', 'pup_use'], blockedByPhases: ['consent', 'dialog'], timings: timingsSummary() },+            progressContract: { statusVerb: 'pup_readiness', activeKey: 'active', slowVerbs: ['pup_open_window', 'pup_prewarm', 'pup_use'], blockedByPhases: ['consent', 'dialog'], timings: pupTimingsSummary() },             verbs: [             V('pup_my_windows', 'START HERE for window management: everything YOUR thread owns — windows, tabs, urls, titles, state — with ready-to-run next steps. Zero args. You NEVER need an hwnd, desktop_find_window, or desktop_screenshot_window for a pup window: pup keys every window to its owning --ai-thread name and resolves ids for you — omit sessionId in any pup verb to target your own window, or pass "ai-thread" to address a thread by name (the CLI\'s --ai-thread flag, same spelling). pup_screenshot {} screenshots it; pup_reload {} refreshes it.', { 'ai-thread': 'optional str — inspect another thread\'s windows (read-only listing); default = the calling thread. The CLI flag\'s exact spelling; aiThread also accepted' }, 10, {}),             V('pup_open_window', 'Open a generic pup window — a fresh isolated Chrome/Edge process (never your real signed-in browser), fully drivable via CDP. ALWAYS opens in the BACKGROUND (does not steal focus; never disturbs the user\'s main work; still fully screenshottable/drivable) UNLESS you pass foreground:true — do that ONLY when the user explicitly wants to watch. Pass width+height (+ optional x,y, screen px) to place it at a specific size/position for screenshot framing — this NO LONGER foregrounds it (sizing stays in the background too; default unsized is maximized). profile defaults to the durable shared \'adom-you\' profile (logins/localStorage persist + are shared across all pup windows); isolated:true for a private throwaway. OWNERSHIP: sessionIds are shared across ALL AI threads — use a task-prefixed sessionId + owner:"<your-task>" so pup can refuse other threads stealing your window (reusing an existing id with a new url navigates it away; declared cross-owner reuse errors with session_owned_by_another_thread unless takeover:true). (For the user\'s REAL Chrome/Edge, use the Adom extension\'s nbrowser_* verbs.)', { sessionId: 'optional str — OMIT IT (recommended): your thread gets its OWN window keyed on your --ai-thread name; the first open creates it, later opens become TABS in it, and no other thread can touch it. Pass an explicit id only when you need a SEPARATE window (task-prefix it, e.g. "mytask-web")', url: 'optional str', profile: 'optional str — a named durable jar; DEFAULT is the shared "adom-you" profile (signed-in state shared across windows). isolated:true overrides to a throwaway', isolated: 'optional bool — private throwaway profile: fresh-login tests, acting as a different user. REASON-GATED (v2.0.101): requires isolationReason or the open is refused — every window defaults to the shared adom-you profile', isolationReason: 'required WITH isolated:true — why this window must NOT ride the shared adom-you profile (min 10 chars; logged, auditable). webSecurity:false and wikiView:public carry their own built-in reason', webSecurity: 'optional false — dev escape hatch for cross-origin eval; FORCES isolation so insecure flags never touch the credentialed profile', owner: 'optional str — your thread/task label; lets pup protect this window from other threads', takeover: 'optional bool — claim a window owned by another thread (only when the user explicitly asks)', foreground: 'optional bool — request showing the window on the user\'s screen. GATED (v1.8.70): requires foregroundReason too, else the open succeeds but stays BACKGROUND with foregroundDenied set. Only when the USER explicitly asked to watch.', foregroundReason: 'required WITH foreground:true — quote/paraphrase what the user said that justifies putting a window on their screen (min 10 chars; logged + recorded in lastAgentUpdate, auditable)', width: 'optional int px — sizes for screenshot framing, stays background', height: 'optional int px', x: 'optional int px', y: 'optional int px', wikiView: 'optional "authed"|"public" — for wiki.adom.inc URLs. THREE distinct cases: (1) OMIT = the shared adom-you profile, LOGGED IN as the user if they have signed into the wiki (the usual case); this is NOT anonymous. (2) "public" = the SERVER renders the page exactly as a signed-out visitor sees it via the ?view=public param (adom/wiki#126: request user nulled, byte-identical to logged-out, private pages 404) — the window STAYS on the shared profile, session untouched, no isolated jar; use this to verify a publish did not leak private source. (3) "authed" = the explicit logged-in view (30-day SSO; first use may need a one-time login — response says wikiLoginNeeded). To compare "what I see" vs "what the world sees", open one "authed" (or omit) AND one "public" tab — do NOT rely on omit for the public view.', appName: 'optional str — the APP this window is driving (e.g. "shotlog"); shown in the hover tooltip', appIconB64: 'optional base64 PNG — override the app icon worn in the taskbar overlay. Usually UNNECESSARY: pup auto-fetches the page\'s own <link rel="icon"> favicon (the adom-ui-design standard artifact every app must serve) and wears it automatically. An app-looking URL with NO favicon gets a reprimand hint.', updateNote: 'optional str — a short "what I did" note, surfaced back in list_tabs/list_windows as lastAgentUpdate so the user knows what changed', autoFlash: 'optional bool (default true) — mutating verbs auto-flash this window\'s taskbar (debounced, never steals focus) so the user notices the agent touched it; pass false to make this window silent by default', silent: 'optional bool — suppress the auto-flash for just this call' }, 60, { sessionId: 'mytask-web', owner: 'mytask', url: 'https://example.com', width: 960, height: 540 }),