UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

70 lines • 3.72 kB
import { type StoredEntry, type SyncCommitStore } from "@earendil-works/pi-agent-core"; import type { FileIdentity } from "../session-transcript-journal.ts"; /** The binding's asynchronous whole-file projection writes; the default is the atomic replace below. A test seam for win32. */ export interface ProjectionFiles { replace(path: string, contents: string): Promise<void>; } export interface DurableStoreBinding { readonly store: SyncCommitStore; readonly epoch: number; readonly files?: ProjectionFiles; } /** SessionManager's write discipline for the binding's own file writes (repair, reprojection on open). */ export interface ProjectionHooks { /** Throws when this manager may no longer write the file (fenced, moved): the write does not happen. */ beforeWrite(path: string): void; /** The file was replaced: its identity changed. */ afterReplace(path: string, identity: FileIdentity | undefined): void; } export interface ProjectionWarning { readonly path: string; readonly code: string; readonly message: string; } /** The S07 importer's key rule: an entry id that starts with `~` gets one more, so it cannot equal a positional key. */ export declare const storeKeyOf: (entryId: string) => string; type Warn = (warning: ProjectionWarning) => void; /** * A SessionManager's binding to the durable store (S20b). Every write commits to the store first; the JSONL is its * projection. A projection write that fails after the commit never throws (the store took the entry): it commits a * durable stale mark, warns once per failed write, and the JSONL is rewritten from the store off the caller's call. * The binding adds no synchronous filesystem call to the session path: stamps and reprojection run on its admission * line. */ export declare class DurableSessionBinding { private stale; private projectedSize; private generation; private unrecordedTails; private wholeUnrecorded; private readonly binding; private readonly handle; private readonly importer; private readonly admission; private readonly warn; private readonly hooks; private constructor(); static open(binding: DurableStoreBinding, sessionFile: string, sessionId: string, headerLine: string, warn: Warn, hooks: ProjectionHooks): Promise<{ readonly session: DurableSessionBinding; readonly reprojected: boolean; }>; /** Store first: a refusal throws here, on the caller's call, and nothing was taken. */ commitAppend(entries: readonly StoredEntry[]): void; commitRewrite(headerLine: string, entries: readonly StoredEntry[]): void; /** While stale, the JSONL is not appended to: it is rewritten whole from the store. */ projectionStale(): boolean; /** The caller appended `entry`'s line to the file. The ledger records only those bytes, asynchronously. */ projected(sessionFile: string, entry: StoredEntry): void; /** The caller wrote the whole file from today's serializer: record that image, unless a later write supersedes it. */ recordWhole(sessionFile: string): void; /** Marks the projection stale in the store (durable, so a crash before the repair still reprojects on open). */ projectionFailed(sessionFile: string, error: unknown): void; /** The file no longer matches the store (it was rewritten from an older image): mark it stale and reproject. */ markProjectionStale(sessionFile: string): void; /** Settles once any scheduled reprojection and ledger record has run (tests and orderly shutdown). */ settled(): Promise<void>; scheduleRepair(sessionFile: string): void; private record; } export {}; //# sourceMappingURL=durable-binding.d.ts.map