export type LockKind = 'task' | 'chat' | 'doc' | 'board' | 'build' | 'orchestrator' | 'tool'; export interface AgentLock { pid: number; startedAt: string; kind: LockKind; taskId?: string; projectId?: string; documentId?: string; /** Board assistant session target (kind === 'board'). */ boardId?: string; } export declare const LOCK_DIR: string; /** Max session age before lock is considered stale (PID reuse safety net). * Primary liveness signal is pidAlive(); this is a fallback. Configurable * via TEAMSHARE_LOCK_MAX_SESSION_MS env var (ms). Default 24h — long enough * for orchestrator builds that can run 6h+. */ export declare const MAX_SESSION_MS: number; export declare const LOCK_POLL_MS = 10000; export declare const LOCK_MAX_WAIT_MS: number; export declare function lockPath(agentId: string): string; export declare function readLock(agentId: string): AgentLock | null; /** One-shot acquire: ok=true on success, ok=false + busy set when held. */ export declare function tryAcquireLock(agentId: string, kind: LockKind, meta?: Omit): { ok: boolean; busy?: AgentLock; }; /** Release the lock, but only if we hold it (pid match). */ export declare function releaseLock(agentId: string): void; /** Remove the lock unconditionally (manual override, `clear-lock`). */ export declare function clearLock(agentId: string): void; /** * Staleness-aware busy check for the daemon / probe: the agent is busy only * while the lock is held by a LIVE pid and younger than MAX_SESSION_MS. A * crashed session (dead pid) or an expired lock does NOT block - the queue * flush can spawn immediately instead of stalling on a dead lock. */ export declare function isLockBusy(agentId: string): boolean; /** * Wait until the lock is free, then acquire it. Used by the CLI when a * session starts so a manual run waits for the daemon-spawned session (and * vice versa). Returns the acquired lock, or null when maxWaitMs elapses. */ export declare function acquireLock(agentId: string, kind: LockKind, meta?: Omit, opts?: { pollMs?: number; maxWaitMs?: number; onWaiting?: (busy: AgentLock) => void; }): Promise;