import type { Browser, CDPSession, Connection, ConnectOptions, Device, JSHandle, NetworkConditions, Page, default as Puppeteer, Target } from "puppeteer-core"; export declare const DEFAULT_VIEWPORT: { width: number; height: number; deviceScaleFactor: number; }; /** * Per-CDP-message timeout applied to every puppeteer launch/connect. Set above * `TOOL_TIMEOUTS.browser.max` (30s) so the agent-side wall-clock is the canonical * limit; this constant only catches genuinely stuck CDP sockets (renderer wedged, * connection dropped, etc.). */ export declare const BROWSER_PROTOCOL_TIMEOUT_MS = 60000; /** * Puppeteer default args to pass as `ignoreDefaultArgs` so Chromium does not run in * automation mode. Used by the browser tool and the sign-in browser, where Google * rejects automation-controlled browsers as insecure. */ export declare function stealthIgnoreDefaultArgs(executablePath: string | undefined): string[]; /** Launch arg that keeps `navigator.webdriver` false; pair with {@link stealthIgnoreDefaultArgs}. */ export declare const DISABLE_AUTOMATION_CONTROLLED_ARG = "--disable-blink-features=AutomationControlled"; /** * Chromium switches that keep every renderer at normal scheduling priority. On macOS, Chromium up * to M152 moves the renderers of background tabs and spare processes into the Darwin background * band (priority 4) behind `MacAllowBackgroundingRenderProcesses`, ignoring Puppeteer's * `--disable-renderer-backgrounding`. On a busy host the kernel then barely runs them: Tracing.start * waits out Chromium's 10s ack timeout for them, and CDP calls into a tab opened beside another * stall. Unknown feature names are ignored, so builds without the feature are unaffected; Puppeteer * merges every `--disable-features` switch it is given. */ export declare const RENDERER_PRIORITY_ARGS: readonly string[]; /** Identify handles using the lazily loaded Puppeteer instance without triggering an early import. */ export declare function isPuppeteerHandle(value: unknown): value is JSHandle; /** * Recognize Puppeteer's `TimeoutError` by class identity: release builds minify class names, * so its `name` reads like `Og` there and never equals "TimeoutError". */ export declare function isPuppeteerTimeout(error: unknown): boolean; /** Recognize Puppeteer's error for a command whose session closed under it, by class identity like {@link isPuppeteerTimeout}. */ export declare function isPuppeteerTargetClose(error: unknown): boolean; /** * Build Puppeteer's `TimeoutError` for a deadline omp enforces in place of one of Puppeteer's waits. * Its `name` stays "TimeoutError" in release builds: back/forward/reload pass this error to the agent's cell as is. */ export declare function puppeteerTimeoutError(message: string): Error; export declare function loadPuppeteer(): Promise; export declare function loadPuppeteerInWorker(safeDir: string): Promise; /** Normalize transport event rejections before they cross browser or worker boundaries. */ export declare function connectPuppeteer(puppeteer: typeof Puppeteer, options: ConnectOptions): Promise; /** * The connection's root session, which answers browser-level `Target.*` commands. The omp relay serves * those but exposes no attachable browser target, so `browser.target().createCDPSession()` fails there. */ export declare function browserConnection(browser: Browser): Connection; /** Return device descriptors from the already-loaded Puppeteer module. */ export declare function loadedKnownDevices(): Readonly>; /** Return network presets from the already-loaded Puppeteer module. */ export declare function loadedNetworkConditions(): Readonly>; export declare function ensureChromiumExecutable(): Promise; /** * Resolve the executable for interactive sign-in windows. Microsoft Edge needs * Puppeteer's `--enable-automation` to launch (see {@link stealthIgnoreDefaultArgs}), * and Google sign-in rejects automation-controlled browsers, so an Edge * resolution is replaced with Chrome for Testing. * * Throws when Edge is the only local browser and Chrome for Testing cannot be installed. */ export declare function ensureSignInChromiumExecutable(): Promise; /** Per-process launch features controlled by browser.open options. */ export interface HeadlessLaunchFeatures { /** Trust invalid HTTPS certificates in this Chromium process. */ ignoreHttpsErrors?: boolean; /** Permit file: documents to read other local files. */ allowFileAccess?: boolean; } /** Options shared by headless Chromium consumers. */ export interface LaunchHeadlessOptions extends HeadlessLaunchFeatures { headless: boolean; viewport?: { width: number; height: number; deviceScaleFactor?: number; }; /** Additional Chromium arguments merged with the centralized launch defaults. */ args?: readonly string[]; /** Additional exact Puppeteer default arguments to suppress. */ ignoreDefaultArgs?: readonly string[]; } /** Result of a headless Chromium launch. */ export interface LaunchHeadlessResult { browser: Browser; /** Browser-level WebSocket endpoint for other CDP clients, such as tab workers. */ wsEndpoint: string; /** * OMP-owned temporary Chromium profile directory to remove after the browser * process tree exits, or `undefined` when the caller supplied its own * `--user-data-dir` (which OMP must not delete). */ userDataDir?: string; } /** * Base Chromium argv shared by process-local puppeteer launches and the * broker-owned shared browser: sandbox/stealth flags, window size, and * PUPPETEER_PROXY* env-derived proxy flags. */ export declare function buildHeadlessLaunchArgs(viewport: { width: number; height: number; }, features?: HeadlessLaunchFeatures): string[]; export declare function launchHeadlessBrowser(opts: LaunchHeadlessOptions): Promise; /** Close a browser {@link launchHeadlessBrowser} started, force-killing its process tree when the close hangs. */ export declare function closeLaunchedBrowser(browser: Browser): Promise; /** * Pin automation-safe preferences in a Chromium profile OMP owns. Password leak * detection answers a password form submit with a tab-modal "Change your * password" dialog; while it is open Chromium drops `Input.dispatchMouseEvent` * input for the tab, and a hidden browser offers no way to close it. Chromium * reads `Preferences` only at startup and rewrites it from memory, so call this * before a Chromium process starts on the profile. Best-effort: the preference * only suppresses a dialog, so a failure is logged and never blocks the launch. */ export declare function seedOwnedProfilePreferences(userDataDir: string): Promise; /** * Discard Chromium's session-restore state in a persistent profile OMP owns. * When the first window of a new Chromium process opens, it reopens every page * recorded in `Default/Sessions`, however the previous process exited. On the * project-shared browser that resurrects whatever was open when its * predecessor stopped or was killed, and no omp process owns those pages: * target ownership dies with the browser instance, so neither idle-close nor * the orphan reaper ever closes them. Call this before a Chromium process * starts on the profile. Best-effort: a failure is logged and never blocks the * launch. */ export declare function discardOwnedProfileSessions(userDataDir: string): Promise; /** Fully resolved executable and argv for a broker-spawned shared Chromium. */ export interface SharedBrowserLaunchSpec { executablePath: string; args: string[]; } /** * Resolve the executable and complete argv for a shared Chromium the daemon * broker spawns directly (no puppeteer inside the broker). Mirrors * `launchHeadlessBrowser` flag assembly — puppeteer's default args minus the * stealth-suppressed set — suppresses Puppeteer's unowned startup window, and * exposes CDP on an ephemeral port. Returns null when no executable resolves; * callers fall back to a process-local launch. */ export declare function resolveSharedBrowserLaunchSpec(opts: { headless: boolean; userDataDir: string; viewport?: { width: number; height: number; }; }): Promise; /** * Remove an OMP-owned headless Chromium profile directory, tolerating the brief * window on Windows in which Chromium (or an orphaned browser subprocess) still * holds the profile lock. The shared temp remover centralizes retry handling * for EBUSY/EPERM/ENOTEMPTY; if the directory is still busy afterwards we warn * and leave it for a later cleanup pass rather than throwing — a shutdown cleanup * failure must never crash the process (issue #7058). */ export declare function removeUserDataDir(dir: string): Promise; export declare function applyViewport(page: Page, viewport?: { width: number; height: number; deviceScaleFactor?: number; }): Promise; /** * The emulated viewport, else the window's own: connected and visible browsers emulate none, and an * emulated scale of 0 keeps the window's own device scale. */ export declare function readPageViewport(page: Page, signal?: AbortSignal): Promise<{ width: number; height: number; deviceScaleFactor?: number; }>; export interface UserAgentOverride { userAgent: string; platform: string; acceptLanguage: string; userAgentMetadata: { brands: Array<{ brand: string; version: string; }>; fullVersion: string; fullVersionList: Array<{ brand: string; version: string; }>; platform: string; platformVersion: string; architecture: string; bitness: string; model: string; mobile: boolean; }; } export interface UserAgentSession { override: UserAgentOverride; browserSession: CDPSession | null; } /** Builds the browser-page stealth bootstrap source for regression tests. */ export declare function buildStealthInjectionScriptForTest(scripts?: readonly string[]): string; /** Apply stealth patches + UA override to a headless page. Idempotent within a tab. */ export declare function applyStealthPatches(browser: Browser, page: Page, state: { browserSession: CDPSession | null; override: UserAgentOverride | null; }): Promise; /** Exposes executable candidates for detection tests. */ export declare function systemChromiumCandidatesForTest(platform?: NodeJS.Platform, home?: string, which?: (name: string) => string | null | undefined): string[]; export declare function chromiumExecutableProbeForTest(executablePath: string): Promise; export declare function targetSupportsUserAgentOverrideForTest(target: Target): boolean; export declare function configureUserAgentTargetsForTest(browser: Browser, state: { browserSession: CDPSession | null; override: UserAgentOverride; }, targetTimeoutMs?: number): Promise;