import { SessionHeldError, type SessionHolder, type SessionHolderEndpoint, SessionMovedError, SessionMovingError } from "./session-hold-errors.ts";
import { type HolderGeneration, type SessionHolderProbes } from "./session-holder-records.ts";
export { type HolderGeneration, SessionHeldError, type SessionHolder, type SessionHolderProbes, SessionMovedError, SessionMovingError, };
export interface SessionHold {
    release(): void;
}
/** What a holder publishes for a session it has open: its identity and, for an RPC host, that host's endpoint. */
export interface HolderRecord extends Partial<SessionHolderEndpoint> {
    readonly pid: number;
    readonly bootAtMs: number;
    readonly processStartedAtMs: number;
    readonly cwd?: string;
}
/**
 * Publishes this process as a holder of `sessionFile` until `release()`. Throws `SessionMovingError`
 * while another process is moving the session, and `SessionMovedError` when a session that was read
 * from disk (`expectExisting`) is gone, so nothing is ever appended to a path the session left.
 */
export declare function holdSessionFile(sessionFile: string, sessionId: string, options: {
    readonly cwd?: string;
    readonly expectExisting: boolean;
    readonly holderEndpoint?: SessionHolderEndpoint;
}): Promise<SessionHold>;
/**
 * Live processes that have `sessionFile` open right now (stale records of dead or reused pids are
 * reclaimed on the way). A caller about to start another writer uses it to wait instead of racing one.
 */
export declare function liveSessionHolders(sessionFile: string, sessionId: string, probes?: SessionHolderProbes): Promise<SessionHolder[]>;
/**
 * Runs `move` holding the session's move lock, after proving no live process holds the session.
 * Waits up to `waitMs` for a concurrent move to finish, then fails with `SessionMovingError`.
 */
export declare function withSessionMoveLock<T>(sessionFile: string, sessionId: string, move: () => T | Promise<T>, options?: {
    readonly waitMs?: number;
}): Promise<T>;
//# sourceMappingURL=session-holders.d.ts.map