@essentialai/cogent-bridge
Version:
Cogent Bridge — cross-agent comms for Claude Code, OpenAI Codex and Slack. Codex users: install with `curl -fsSL https://cogent.tools/install.sh | sh`, then start with `cogent-codex` for real-time peer wake.
38 lines • 2.16 kB
TypeScript
/** Hard ceiling on how long one lease may exclude others. Mirrors wake-claim's CLAIM_MAX_MS. */
export declare const WAKE_LOCK_MAX_MS = 1800000;
/** `~/.cogent/wake-locks/<sha256(cwd)[..16]>.json` — ONE checkout, ONE turn. */
export declare function wakeLockPath(cwd?: string): string;
export interface WakeLease {
/** True whenever the caller may wake — including every fail-open path. */
acquired: boolean;
/** Milliseconds spent waiting for another process. 0 when uncontended. */
waitedMs: number;
/** True when another live process held the lease and we had to wait for it. */
contended: boolean;
/** Idempotent. Safe to call even when the lease was never really taken. */
release: () => void;
/**
* COG-93: push the lease's expiry out to `untilMs` (never shortens it, capped at WAKE_LOCK_MAX_MS from
* now) for a wake given more time than the TTL assumed. Only rewrites a lease this process holds;
* best-effort and silent — a lease that could not be extended can at worst be taken over when it expires.
*/
extend: (untilMs: number) => void;
}
/**
* Become the single process running an agent turn in `cwd`, waiting out any other holder.
*
* `sessionId` is recorded in the lease for diagnostics; it is NOT part of the key (see the header).
*
* Never returns `acquired: false` today — every path either takes the lease or fails open — but the
* field is explicit so a caller reads the intent rather than assuming it.
*/
export declare function acquireWakeLock(cwd?: string, sessionId?: string, opts?: {
maxWaitMs?: number;
}): Promise<WakeLease>;
/** Test-only: reset the in-process nesting counter. Production code must never call this. */
export declare function __resetWakeLockDepthForTests(): void;
/** COG-93: see WakeLease.extend. Rewrites the lease only when this process is its recorded holder. */
export declare function extendWakeLock(cwd: string, untilMs: number): void;
/** Release the lease. Best-effort; an orphan expires or is stolen when its holder dies. */
export declare function releaseWakeLock(cwd?: string): void;
//# sourceMappingURL=wake-lock.d.ts.map