@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.
57 lines • 2.92 kB
TypeScript
export interface SessionCopy {
pid: number;
sessionId: string;
procStart: string;
kind?: string;
version?: string;
/** ms since epoch, from the record. */
startedAt?: number;
}
/** The session-record directories Claude Code may use: $CLAUDE_CONFIG_DIR first, then ~/.claude. */
export declare function claudeSessionDirs(env?: NodeJS.ProcessEnv): string[];
/** Every `<pid>.json` record in `dirs` that names a pid, a session and a start time. Never throws. */
export declare function readSessionRecords(dirs: string[]): SessionCopy[];
/** A process's start time in Claude Code's own `procStart` form; undefined when it cannot be read. */
export declare function procStartOf(pid: number, platform?: NodeJS.Platform): string | undefined;
export interface CopyDeps {
records?: SessionCopy[];
procStartOf?: (pid: number) => string | undefined;
isAlive?: (pid: number) => boolean;
}
/** The LIVE interactive Claude Code processes on `sessionId`, verified pid + start time, oldest first. */
export declare function liveSessionCopies(sessionId: string, deps?: CopyDeps): SessionCopy[];
/**
* The copies to stop: every live copy except the NEWEST one, the current process and its ancestors
* (when this runs inside a copy — a bridge, or the command typed with `!` — that copy is kept).
*/
export declare function olderSessionCopies(copies: SessionCopy[], keep: Set<number>): SessionCopy[];
/** The current process and its ancestors (from one `ps` listing). */
export declare function selfAndAncestors(): Set<number>;
/** COG-97: the command shown to the human — runs the bridge CLI's `stop-duplicate-sessions`. */
export declare function stopDuplicatesCommand(sessionId: string, version: string): string;
/**
* COG-97: the warning a bridge gives when other live copies of ITS OWN session exist, or null.
* `others` excludes this process's own copy (an ancestor of the bridge).
*/
export declare function duplicateSessionWarning(sessionId: string, others: SessionCopy[], version: string): string | null;
export interface StopResult {
stopped: number[];
killed: number[];
survivors: number[];
refused: Array<{
pid: number;
why: string;
}>;
}
/**
* Stop `targets`: re-verify each (session + start time) right before signalling, SIGTERM, then
* SIGKILL for any survivor after `graceMs`. Never signals a pid in `keep`.
*/
export declare function stopSessionCopies(sessionId: string, targets: SessionCopy[], keep: Set<number>, deps?: CopyDeps & {
kill?: (pid: number, sig: NodeJS.Signals) => void;
graceMs?: number;
killWaitMs?: number;
}): Promise<StopResult>;
/** `cogent-bridge stop-duplicate-sessions <sessionId>` — the command the human runs. Returns an exit code. */
export declare function runStopDuplicateSessions(args: string[], write?: (s: string) => void): Promise<number>;
//# sourceMappingURL=duplicate-sessions.d.ts.map