@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
29 lines • 1.5 kB
TypeScript
/**
* The durable takeover record behind a headless engine's quiet takeover (R21; S37).
*
* One holder per durable session: the client that last took the session over. A takeover by a new holder appends
* `attach.takeover` and replaces the holder document in one atomic commit, with the generation one higher. A takeover
* by the current holder writes nothing, so a retried takeover is applied exactly once, across a restart too.
*/
import type { AdmissionLine, DurableStore } from "@earendil-works/pi-agent-core/conformance";
export declare const ATTACH_TAKEOVER_RECORD = "attach.takeover";
/** Who drives a session now: `generation` counts its holders, 1 for the first takeover. */
export interface AttachHolder {
readonly takeoverId: string;
readonly sessionId: string;
readonly holder: string;
readonly generation: number;
}
export interface AttachLedger {
/** Makes `holder` the session's holder; returns the current record unchanged when it already is. */
takeOver(sessionId: string, holder: string): Promise<AttachHolder>;
/** The session's holder, `undefined` before its first takeover. */
holderOf(sessionId: string): Promise<AttachHolder | undefined>;
}
/** All writers on one writable store epoch share its single admission line. */
export declare function createAttachLedger(options: {
readonly store: DurableStore;
readonly epoch: number;
readonly admission: AdmissionLine;
}): AttachLedger;
//# sourceMappingURL=attach-ledger.d.ts.map