/**
 * Per-account instance singleton guard (Cluster 2, 2026-05-31 report).
 *
 * Multiple `claude --continue` sessions each spawn a mailpouch MCP, and each
 * one runs its own IMAP IDLE/auth loop against the SAME mailbox — a compounded
 * connection leak. This guard lets the FIRST live instance for an account hold
 * a PID lock file under $HOME; a later instance that finds a *live* holder
 * exits cleanly (the caller logs and `process.exit(0)`s) instead of opening a
 * second IMAP connection.
 *
 * Design notes:
 *  - The lock is a plain file containing the holder's PID (decimal). We write
 *    it with `wx` (O_EXCL) so creation is atomic — only one process can win.
 *  - A *stale* lock (holder crashed without releasing) is reclaimed: if the
 *    recorded PID is not a live process, we delete the file and retry once.
 *    This is what allows a legitimate restart after a clean OR crashed shutdown
 *    to proceed — we never block on a dead PID.
 *  - Fail-safe: any unexpected error in the mechanism itself resolves to
 *    `acquired` so a broken lock can never block a legitimate start.
 *
 * No external dependency and no new runtime deps — `fs` + `process.kill(pid, 0)`
 * is sufficient for the single-host, cooperating-Node-process case.
 */
export type LockOutcome = {
    status: "acquired";
    path: string;
    reclaimed: boolean;
} | {
    status: "held-by-live-instance";
    path: string;
    pid: number;
};
/**
 * Derive the per-account lock file path. The account identity (typically the
 * username/email) is hashed so the filename never leaks the address and stays
 * filesystem-safe. Empty/undefined identity collapses to a stable "default"
 * bucket so a not-yet-configured install still gets a singleton guard.
 */
export declare function lockPathForAccount(accountIdentity: string | undefined | null): string;
/**
 * Attempt to acquire the singleton lock for `accountIdentity`.
 *
 * Returns `held-by-live-instance` when another live mailpouch already owns it
 * (caller should log + exit 0). Returns `acquired` when we now own the lock —
 * `reclaimed` is true if we broke a stale (dead-PID) lock to do so.
 *
 * Fail-safe: on any unexpected error, resolves to `acquired` so the start is
 * never blocked by a malfunctioning lock.
 *
 * @param pid the PID to record as the holder (defaults to this process).
 */
export declare function acquireSingletonLock(accountIdentity: string | undefined | null, pid?: number): LockOutcome;
/**
 * Release a previously-acquired lock. Only removes the file if it still records
 * OUR pid, so we never delete a lock another instance legitimately re-took
 * after we (e.g.) were considered stale. Best-effort; never throws.
 */
export declare function releaseSingletonLock(path: string, pid?: number): void;
//# sourceMappingURL=singleton-lock.d.ts.map