export interface DaemonLifetimeLock { /** Canonical state directory protected by this lock. */ stateDir: string; /** SQLite database used only for the lifetime write transaction. */ lockPath: string; release(): Promise; } export declare class DaemonLifetimeLockHeldError extends Error { readonly stateDir: string; readonly lockPath: string; readonly cause?: unknown | undefined; constructor(stateDir: string, lockPath: string, cause?: unknown | undefined); } export declare function canonicalizeStateDir(stateDir: string): Promise; /** * Acquire the daemon-owned lifetime lock for a canonical stateDir. * * This is intentionally separate from daemon.lock/daemon.pid: those coordinate * startup metadata, while this held write transaction is the OS-backed guard * that prevents another daemon from reaching index.db for the same stateDir. * * Implementation note: we deliberately avoid `@libsql/client`'s interactive * `transaction()` API. That path moves the native connection off the client * (`#db = null`) and never closes it from `Transaction.close()` / `client.close()`, * so the handle is only finalized by GC — which intermittently access-violates * on Windows during process exit (exit code 0xC0000005). Holding * `BEGIN IMMEDIATE` on the client's own connection means `client.close()` owns * teardown end-to-end. */ export declare function acquireDaemonLifetimeLock(stateDir: string): Promise;