import type { Browser, Page } from "puppeteer-core"; /** * Allocate an unused TCP port on 127.0.0.1 by binding to port 0 and reading * back the kernel-assigned port. There's a small race between close and the * subsequent bind in the launched app, but Chromium's listener will retry. */ export declare function findFreeCdpPort(): Promise; /** Poll `${cdpUrl}/json/version` until it responds with 200, with abort + timeout support. */ export declare function waitForCdp(cdpUrl: string, timeoutMs: number, signal?: AbortSignal): Promise; /** * If any running instance of `exe` was launched with `--remote-debugging-port` * and that endpoint actually answers, return it so attach can reuse it instead * of killing and respawning. Idempotent re-attaches are the common case. */ export declare function findReusableCdp(exe: string, signal?: AbortSignal): Promise<{ cdpUrl: string; pid: number; } | null>; /** * Pick the best page target on an attached browser. Without a matcher, prefer * a page that doesn't look like a helper window (devtools, request handler, * background pages); with a matcher, return the first url+title substring hit. */ export declare function pickElectronTarget(browser: Browser, matcher?: string): Promise; /** * SIGTERM the process tree, wait briefly, then SIGKILL anything still alive. * Single-process variant for our own spawned children. */ export declare function gracefulKillTreeOnce(pid: number, gracePeriodMs?: number): Promise; /** * Multi-process variant for attach: find every PID running `executablePath` * (single-instance apps may keep an orphan around) and tear them all down. */ export declare function killExistingByPath(executablePath: string, signal?: AbortSignal): Promise;