@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
38 lines • 1.32 kB
JavaScript
/**
* Message writes the session file refused. The first error of a run is reported once, by whoever
* owns the run (its prompt, or the continuation that started it); the refused messages leave the
* model context before the next prompt, so that context matches what a reload shows.
*/
export class TranscriptWriteFailures {
constructor() {
this.reported = false;
this.refused = new Map();
}
startRun() {
this.runFailure = undefined;
this.reported = false;
}
record(message, error) {
this.refused.set(message, { error });
this.runFailure ??= { error };
}
refusal(message) {
return this.refused.get(message);
}
takeReport() {
if (this.reported || !this.runFailure)
return undefined;
this.reported = true;
return this.runFailure;
}
/** `messages` without the refused ones, or `undefined` when none of them is there. */
takeRefusedOut(messages) {
if (this.refused.size === 0)
return undefined;
const refused = this.refused;
const kept = messages.filter((message) => !refused.has(message));
refused.clear();
return kept.length === messages.length ? undefined : kept;
}
}
//# sourceMappingURL=transcript-write-failures.js.map