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<number>;
/** Poll `${cdpUrl}/json/version` until it responds with 200, with abort + timeout support. */
export declare function waitForCdp(cdpUrl: string, timeoutMs: number, signal?: AbortSignal): Promise<void>;
/**
 * 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. Prefer discoverable page
 * targets first so Chromium/Edge attach flows that hide pages from
 * `browser.pages()` can still return a usable tab.
 */
export declare function pickElectronTarget(browser: Browser, matcher?: string): Promise<Page>;
/**
 * 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<void>;
/**
 * 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<number>;
