@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
33 lines • 1.85 kB
TypeScript
/**
* The durable pause and resume records behind a headless engine's presence (C2, K7; senpi#5652).
*
* One pause per session and machine while that machine is offline: an append of `presence.pause` plus the open-pause
* document, in one atomic commit. Its resume appends `presence.resume` and deletes the document in one commit, so a
* resume is applied exactly once even across a restart: a second resume finds no open pause and writes nothing.
*/
import type { AdmissionLine, DurableStore } from "@earendil-works/pi-agent-core/conformance";
export declare const PRESENCE_PAUSE_RECORD = "presence.pause";
export declare const PRESENCE_RESUME_RECORD = "presence.resume";
/** Why a session waits: its owning machine (the placement) is offline, or a hand its tool calls run on is. */
export type PresenceRole = "owner" | "hand";
export interface PresencePause {
readonly pauseId: string;
readonly sessionId: string;
readonly machine: string;
readonly role: PresenceRole;
}
export interface PresenceLedger {
/** Records that `sessionId` waits on `machine`; returns the open pause unchanged when one already exists. */
pause(sessionId: string, machine: string, role: PresenceRole): Promise<PresencePause>;
/** Resumes the open pause of `sessionId` on `machine`; `undefined` when none is open (already resumed). */
resume(sessionId: string, machine: string): Promise<PresencePause | undefined>;
/** Every open pause, for recovery after a restart. */
openPauses(): Promise<readonly PresencePause[]>;
}
/** All writers on one writable store epoch share its single admission line. */
export declare function createPresenceLedger(options: {
readonly store: DurableStore;
readonly epoch: number;
readonly admission: AdmissionLine;
}): PresenceLedger;
//# sourceMappingURL=presence-ledger.d.ts.map