/** * Result of probing a port for an existing bridge server. * `null` if nothing healthy responded. */ export type PingResult = { ok: boolean; version: string; cwd?: string; }; /** * The action `serve` should take after probing the requested port. * * - `start` — no bridge is listening; bind a fresh server on this port. * - `reuse` — a healthy bridge on the same version is already running; do not bind. * - `replace` — a healthy bridge on a different version is running; terminate it, then bind. */ export type StartActionKind = 'start' | 'reuse' | 'replace'; export type StartAction = { kind: StartActionKind; reason: string; }; /** * Pure decision function: given the result of probing the target port with a * `/api/v1/ping` request, decide whether to start, reuse, or replace. * * Keeping this pure (no I/O) makes the core singleton policy directly testable * without spawning real servers. * * @param ping parsed ping payload, or `null` if nothing healthy responded * @param version the current plugin version */ export declare function decideStartAction(ping: PingResult | null, version: string): StartAction; /** * Probe a port for a healthy bridge server via `GET /api/v1/ping`. * Returns the parsed payload, or `null` when nothing healthy answers * (connection refused, timeout, non-2xx, or unparseable body). */ export declare function probeBridge(hostname: string, port: number): Promise; /** Test seam: override the runtime dir so pidfile I/O can target a temp dir. */ export declare function setRuntimeDir(dir: string | undefined): void; /** Stable pidfile path for a given port. */ export declare function pidfilePath(port: number): string; /** Write `` for the given port. Best-effort: never throws. */ export declare function writePidfile(port: number, pid?: number): void; /** Read the pid recorded for a port, or `null` if absent/unreadable/invalid. */ export declare function readPidfile(port: number): number | null; /** Remove the pidfile for a port. Best-effort: never throws. */ export declare function removePidfile(port: number): void; /** Whether a pid is alive. Uses signal 0 (no-op probe). */ export declare function isPidAlive(pid: number): boolean; /** * Terminate a previously recorded bridge instance for `port` (SIGTERM). * Handles stale pidfiles (pid no longer alive). Returns `true` if a live * process was signalled, `false` otherwise. */ export declare function terminateRecordedBridge(port: number): boolean;