import type { Subprocess } from "bun"; import type { Browser, CDPSession } from "puppeteer-core"; import { type UserAgentOverride } from "./launch"; import type { ProfileReusePosture } from "./profile-posture"; export type BrowserKind = { kind: "headless"; headless: boolean; } | { kind: "spawned"; path: string; } | { kind: "chrome-profile"; path: string; userDataDir: string; profileDirectory: string; background: boolean; noFocus: boolean; cdpPort?: number; } | { kind: "connected"; cdpUrl: string; }; export type BrowserKindTag = BrowserKind["kind"]; export interface BrowserGeo { readonly timezone?: string; readonly locale?: string; } export interface BrowserHandle { key: string; kind: BrowserKind; readonly geo?: BrowserGeo; browser: Browser; cdpUrl?: string; pid?: number; subprocess?: Subprocess; refCount: number; stealth: { browserSession: CDPSession | null; override: UserAgentOverride | null; }; } type SpawnedChromeProfileKind = Extract; export interface AcquireBrowserOptions { cwd: string; viewport?: { width: number; height: number; deviceScaleFactor?: number; }; appArgs?: string[]; signal?: AbortSignal; /** * Profile-reuse posture for the default headless path (from settings * `browser.profileReuse`, resolved by the settings-aware caller). When set, * the headless browser may warm up from an isolated copy of the user's real * Chrome profile (see profile-reuse.ts). Omitted = synthetic session. */ profileReuse?: ProfileReusePosture; /** * Opt-in geo alignment for the default headless path (from settings * `browser.geo.*`). Default unset = no-op (real timezone/locale preserved). */ geo?: BrowserGeo; } export declare function browserKeyForTest(kind: BrowserKind, opts: Pick): string; export declare function acquireBrowser(kind: BrowserKind, opts: AcquireBrowserOptions): Promise; export declare function buildChromeProfileLaunchArgs(kind: SpawnedChromeProfileKind, appArgs: readonly string[] | undefined, port: number): string[]; export declare function buildChromeProfileLaunchArgsForTest(kind: SpawnedChromeProfileKind, appArgs: readonly string[] | undefined, port: number): string[]; export declare function openChromeProfileHandle(kind: SpawnedChromeProfileKind, opts: AcquireBrowserOptions): Promise; export declare function holdBrowser(handle: BrowserHandle): void; export declare function releaseBrowser(handle: BrowserHandle, opts: { kill: boolean; }): Promise; export {};