@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
32 lines • 969 B
JavaScript
import { Buffer } from "buffer";
/** Incremental byte accounting of a resident string store: updated per string, never by re-serializing. */
export class ResidentSizeAccounting {
constructor() {
this.bytes = 0;
this.evictedCount = 0;
this.evictedBytes = 0;
}
get residentBytes() {
return this.bytes;
}
added(text) {
this.bytes += Buffer.byteLength(text, "utf8");
}
removed(text) {
this.bytes -= Buffer.byteLength(text, "utf8");
}
/** A string left memory for its blob file. */
evicted(text) {
this.evictedCount++;
this.evictedBytes += Buffer.byteLength(text, "utf8");
}
reset() {
this.bytes = 0;
this.evictedCount = 0;
this.evictedBytes = 0;
}
stats() {
return { blobBytes: this.bytes, evictedCount: this.evictedCount, evictedBytes: this.evictedBytes };
}
}
//# sourceMappingURL=session-resident-store-size.js.map