/** * File-lock acquisition and management for the Telegram poller. * * Only one MCP instance may poll Telegram at a time. This module provides * a file-system–based lock (with stale-lock detection via PID check) so * multiple instances can coordinate without conflicts. */ /** Check whether a PID is still alive. */ export declare function isPidAlive(pid: number): boolean; export declare function readLock(): Promise<{ pid: number; ts: number; } | null>; /** * Outcome of a lock-refresh attempt. * * - `refreshed`: the lock timestamp was successfully updated on disk. * - `lost`: the lock is missing or now owned by a different PID — ownership * has genuinely changed, so the caller must step down. * - `io-error`: a transient filesystem error (e.g. Windows EPERM/EBUSY from an * antivirus/indexer briefly holding the file) prevented the timestamp update, * but ownership is unchanged. The caller still owns the lock and should keep * running; the next refresh will retry. */ export type LockRefreshResult = "refreshed" | "lost" | "io-error"; /** * Write (refresh) the lock file, but only if we still own it. * Prevents a TOCTOU race where two pollers run simultaneously: * if another process stole the lock between our check and write, * we must not overwrite their lock. * * Ownership is defined solely by the PID recorded in the lock file — NOT by * the timestamp. A transient inability to update the timestamp therefore does * not imply ownership loss, so it is reported as `io-error` (non-fatal) rather * than conflated with a genuine handover (`lost`). */ export declare function refreshLock(): Promise; export declare function removeLock(): void; /** * Try to acquire the poller lock, retrying up to `maxAttempts` times with * `delayMs` between attempts. Handles the Windows race where a just-killed * process still appears alive briefly to process.kill(pid, 0). */ export declare function tryAcquireLockWithRetry(maxAttempts?: number, delayMs?: number): Promise; export declare function tryAcquireLock(): Promise; //# sourceMappingURL=lock.d.ts.map