UNPKG

@code-yeongyu/senpi

Version:

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

42 lines • 1.79 kB
import { loadedContentFingerprints } from "./session-file-identity.js"; import { captureTranscriptBase, } from "./session-transcript-journal.js"; /** One lifecycle's identity and optional loaded base. A superseded asynchronous capture cannot publish. */ export class TranscriptFile { constructor() { this.base = null; this.history = 0; this.ready = Promise.resolve(); this.generation = 0; } reset() { this.generation++; this.base = null; this.history = 0; this.identity = undefined; this.unavailable = undefined; this.ready = Promise.resolve(); } capture(identity, entries, publish) { this.reset(); const generation = this.generation; const captured = entries ? captureTranscriptBase(entries) : undefined; // A base is anchored by its content as read (RULING-72); entries no capturing read produced cannot be one. const contentFingerprint = entries ? loadedContentFingerprints.get(entries) : undefined; this.ready = identity.then((fileIdentity) => { if (generation !== this.generation) return; if (!fileIdentity || (captured && contentFingerprint === undefined)) this.unavailable = "transcript_file_identity_unavailable"; else { this.identity = fileIdentity; if (captured && contentFingerprint !== undefined) { const { count, idFingerprint } = captured; this.base = { fileIdentity, count, idFingerprint, contentFingerprint }; this.history = captured.history; } } publish(); }); } } //# sourceMappingURL=session-transcript-file.js.map