import type { CdpPage } from './browse-types'; /** * Enable the Page domain and install the per-tab instrumentation the loop * relies on: the stealth console wrapper, the Page.frameNavigated listener and * the debounced MutationObserver. Extracted so every (re)attach - including a * tab switch/close - re-runs it on the NEW tab. All of it must be idempotent * (the injected scripts already early-return when their Symbol key exists). */ export declare function instrumentPage(page: CdpPage): Promise; /** * Re-inject the document-scoped MutationObserver into the page's CURRENT * document. Idempotent: the injected script early-returns when its Symbol key * already exists. Must run again after every (main-frame) navigation. */ export declare function reinjectObserver(page: CdpPage): Promise; /** * Debounced observer re-inject after a main-frame navigation: `frameNavigated` * can fire before the new document is ready, and rapid redirects would * otherwise inject several times. */ export declare function scheduleObserverReinject(page: CdpPage): void; /** * Connect directly to a page's WebSocket from /json/list. * This avoids the Target.attachToTarget complexity. * * Uses the ACTIVE-tab picker (`resolveActivePage`): the loop must bind to the * tab the human/site has focused right now, not the first entry of /json/list. * `resolveActivePage` falls back to the general attachable-page picker (which * may open a blank tab) only when no page can be probed. */ export declare function connectToPage(port: number, preferTargetId?: string): Promise; /** Register a listener for a CDP event (e.g. 'Page.frameNavigated'). */ export declare function onCdpEvent(page: CdpPage, event: string, cb: (params: any) => void): void; export declare const CDP_STACK_RE: RegExp; export declare const STEALTH_SOURCE_URL = "//# sourceURL=chrome-extension://pbjikgmbmlelhpamhfbhjnknahkdbcm/inject.js"; /** Override Error.prepareStackTrace to strip CDP-related frames from stack traces. */ export declare function installStackTraceStealth(): void; /** * Stealth wrapper for Runtime.evaluate. * Adds sourceURL marker (makes stack traces look like a Chrome extension) * and sanitizes stack traces to hide CDP frames. */ export declare function cdpEval(page: CdpPage, expression: string, returnByValue?: boolean): Promise; export declare function cdpSend(page: CdpPage, method: string, params: any): Promise; /** * Capture the visible viewport as JPEG, then downscale LOCALLY (sharp) so the * longest side is at most `maxEdge` px. This keeps the vision call fast (a big * page produced 100KB+ images that exceeded the model timeout) WITHOUT asking * Chrome to scale the capture — Chrome's `clip.scale` re-rasterizes the surface * and flashes the tab on Windows, once per round. Clicking is unaffected — * actions use element coordinates (CSS px), not image pixels. */ export declare function captureScreenshot(page: CdpPage, quality: number, maxEdge?: number): Promise;