@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.
48 lines • 1.99 kB
TypeScript
interface BridgeEntry {
pid: number;
startedAt: number;
version: string;
peerId: string;
endpoint: string;
cwd: string;
}
/** `~/.cogent/bridges/<sha256(cwd)[..16]>.<peerId>/` — one directory per identity. */
export declare function bridgeDirFor(cwd: string, peerId: string): string;
/**
* Announce this process as a bridge serving `peerId` in `cwd`.
*
* Called once the peer is actually registered, so a bridge that never registered never competes
* for ownership. Best-effort: a failure here leaves us un-announced, which can only make us LOSE
* ownership to someone else, never wrongly take it.
*/
export declare function announceBridge(cwd: string, peerId: string, version: string, endpoint: string): void;
/** Remove this process's announcement. Called on graceful shutdown; a crash is handled by pruning. */
export declare function withdrawBridge(cwd: string, peerId: string): void;
/**
* Every LIVE bridge announced for this identity, newest process first.
*
* Prunes entries whose process is gone, so a machine that has been through a dozen plugin updates
* does not accumulate junk here forever.
*/
export declare function listLiveBridges(cwd: string, peerId: string): BridgeEntry[];
export interface OwnershipVerdict {
/** True when this process should do this peer's work. Every uncertain path returns true. */
isOwner: boolean;
/** The bridge that owns it instead, when we do not. */
owner?: {
pid: number;
version: string;
endpoint: string;
};
/** How many live bridges serve this identity, including us. */
liveCount: number;
}
/**
* Should THIS process wake for `peerId` in `cwd`?
*
* No when a strictly newer live bridge serves the same identity — that bridge is the one the user
* most recently started, and we are the leftover.
*/
export declare function checkWakeOwnership(cwd: string, peerId: string): OwnershipVerdict;
export {};
//# sourceMappingURL=wake-ownership.d.ts.map