UNPKG

@code-yeongyu/senpi

Version:

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

63 lines • 2.68 kB
import { type ResidentStoreSize } from "./session-resident-store-size.ts"; export declare const RESIDENT_STRING_PREFIX = "\0senpi-resident-string:v1:"; export interface ResidentStoreStats { blobCount: number; blobBytes: number; evictedCount?: number; evictedBytes?: number; } export interface ResidentStringStoreOptions { maxBytes?: number; blobsDir?: () => string | undefined; } export declare class ResidentStringStore { private readonly tokenFree; private strings; private readonly accounting; private readonly maxBytes; private blobsDir?; constructor(options?: ResidentStringStoreOptions); configure(options: { blobsDir?: () => string | undefined; }): void; clear(): void; /** * Unlike clear(), the blob backing itself survives: consumers of entries that * were spilled keep hydrating from it instead of falling back to a full JSONL * reload. Used where the store is emptied in place (post-compaction mirror * trim) rather than across a session switch. */ spillResident(): void; stats(): ResidentStoreStats; /** Strings held in memory and their summed UTF-8 length, kept as strings come and go (no serialization). */ size(): ResidentStoreSize; externalize<T>(value: T): T; /** * An externalized value without resident tokens is already the store's own JSON-normalized copy, * so it is returned as is; copying every entry on every read made each context build copy the * whole session. Readers must not mutate what they get, as `getEntries()` already documents. */ materialize<T>(value: T, onMissing?: (id: string) => string | undefined): T; /** * Whether `externalize` returned this value without any resident token: it is then the store's * JSON-normalized copy and `materialize` returns it as is. */ isTokenFree(value: object): boolean; /** Records `value` as token-free, so `materialize` returns it as is (senpi#2537). */ adoptTokenFree(value: object): void; resolvedBlobsDir(): string | undefined; /** * Replace large strings reachable from `value` with resident tokens, mutating * the object graph in place so consumer-held references stay valid. */ externalizeInPlace(value: unknown): void; /** Hydrate resident tokens reachable from `value` in place (inverse of externalizeInPlace). */ materializeInPlace(value: unknown): void; private _mutateStringsInPlace; private externalizeString; private materializeString; private _enforceBudget; private _writeBlob; private _readBlob; } //# sourceMappingURL=session-resident-store.d.ts.map