/** * Atomic filesystem helpers — the single source of truth for durable * config/session writes across `@a5c-ai/agent-mux`. * * Guarantees: * - Writes are atomic: a concurrent reader observes either the old or the * new bytes, never a torn intermediate. * - Writes are durable: data + directory entry are fsynced before rename. * - Concurrent writers serialise through an advisory lockfile (`.lock`) * which records the holder's PID and a monotonic timestamp. Stale locks * (holder dead or older than `staleMs`) are forcibly reclaimed. * * These primitives have no runtime dependencies beyond Node built-ins and * work identically on Windows, macOS, and Linux. * * @see docs/08-config-and-auth.md */ export interface AtomicWriteOptions { /** Acquire an advisory lock before writing. @default true */ readonly lock?: boolean; /** Max time to wait for a lock, in ms. @default 5000 */ readonly lockTimeoutMs?: number; /** Lock is considered stale after this many ms without refresh. @default 30000 */ readonly staleMs?: number; /** fsync the file after write. @default true */ readonly fsync?: boolean; /** File mode for writeFile. */ readonly mode?: number; } /** Write `data` to `filePath` atomically (tmp + fsync + rename). */ export declare function writeFileAtomic(filePath: string, data: string | Uint8Array, opts?: AtomicWriteOptions): Promise; /** Write `data` as pretty-printed JSON atomically. */ export declare function writeJsonAtomic(filePath: string, data: unknown, opts?: AtomicWriteOptions): Promise;