@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.
40 lines • 2.07 kB
TypeScript
import { type Platform } from "./exec-remote.js";
/** A candidate local session for a cwd: its id and last-write mtime. */
export interface Candidate {
sessionId: string;
mtimeMs: number;
}
export type ResolverDecision = "pinned-exact" | "single-candidate" | "newest-clear" | "ambiguous" | "none";
export type ResolverConfidence = "high" | "medium" | "none";
export interface SessionResolution {
/** null when decision is "ambiguous" | "none" (never guess silently). */
sessionId: string | null;
decision: ResolverDecision;
confidence: ResolverConfidence;
candidateCount: number;
/** newest minus 2nd-newest mtime; null when <2 candidates. */
mtimeGapMs: number | null;
/** human-readable, content-free (ids/counts/timings only). */
fallbackReason?: string;
/**
* Transcript directories that were scanned. Populated by resolveSession (the
* fs adapter) so a zero-candidate refusal can NAME the path it probed — without
* it, a cwd-representation mismatch is indistinguishable from an empty machine.
*/
probedPaths?: string[];
}
/**
* Pure acceptance-gate logic — no fs, fully deterministic and unit-tested.
* Prefer-exact: a live pin wins. Refuse-if-close: on ambiguity, return null
* rather than resume the wrong session. Vault: the Returning-null / Option
* error pattern (typescript-master-vault concepts/Error_Handling) — an
* un-resolvable wake is a null result, not an exception.
*/
export declare function decideResolution(candidates: Candidate[], pinnedSessionId: string | undefined, pinnedExists: boolean, marginMs: number): SessionResolution;
/**
* Async adapter: gather candidates + pin-existence concurrently, then decide.
* Vault: Parallelism (task parallelism) — the two independent fs probes run via
* Promise.all. marginMs defaults to COGENT_RESOLVER_AMBIGUOUS_MARGIN_MS.
*/
export declare function resolveSession(platform: Platform, cwd: string, pinnedSessionId?: string, marginMs?: number): Promise<SessionResolution>;
//# sourceMappingURL=session-resolver.d.ts.map