UNPKG

@code-yeongyu/senpi

Version:

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

74 lines • 2.96 kB
import { type CompactContentStore, type LeafId } from "./compact-content-store.ts"; export type ValueRef = { readonly node: LeafId; readonly owner: LeafId; } | { readonly node: 0; readonly owner: 0; readonly value: string | number | boolean | null; }; type Field = readonly [ValueRef, ValueRef]; export type ValuePage = { readonly kind: "scalar"; readonly value: number | boolean | null; } | { readonly kind: "string"; readonly text: string; readonly next?: ValueRef; } | { readonly kind: "array"; readonly items: readonly ValueRef[]; readonly next?: ValueRef; } | { readonly kind: "object"; readonly items: readonly Field[]; readonly next?: ValueRef; }; /** One bounded step of a value walk: a string arrives in page-sized chunks, an object alternates key and value. */ export type ValueStep = { readonly kind: "scalar"; readonly value: number | boolean | null; } | { readonly kind: "string"; readonly text: string; readonly more: boolean; } | { readonly kind: "open"; readonly container: "array" | "object"; } | { readonly kind: "close"; }; /** Field/array descriptors and string chunks live in bounded leaves; owners share immutable subtrees. */ export declare class CompactValues { private readonly store; residentPages: number; peakResidentPages: number; constructor(store: CompactContentStore); record(fields: ReadonlyMap<string, ValueRef>): ValueRef; /** Owns a JSON-normal value through bounded pages; no aggregate size, depth or node cap (S03b-4). */ own(value: unknown): ValueRef; page(ref: ValueRef): Promise<{ value: ValuePage; [Symbol.dispose]: () => void; }>; /** * The incremental read: one page resident at a time and one frame per open container, whatever the value's size * or depth. `valid` runs after every page read, so a reader under a cut lease rechecks it between steps. */ walk(ref: ValueRef, valid?: () => void): AsyncGenerator<ValueStep>; /** Whole-value assembly for a caller that wants the value itself; it costs the value's size, nothing more. */ read(ref: ValueRef, valid?: () => void): Promise<unknown>; /** * The fields of a stored object, one page resident (carry 45): each key is matched against `names` page by page and * never assembled past the longest of them, so a key of any size costs one page unless a name shares its prefix; * the match is the equal name, or undefined. */ fields(ref: ValueRef, names: ReadonlySet<string>, valid?: () => void): AsyncGenerator<readonly [string | undefined, ValueRef, ValueRef]>; private objectPage; private matchKey; /** Patches are coalesced before this call; copy descriptors, never the fields' payloads. */ merge(base: ValueRef, patch: ReadonlyMap<string, ValueRef>): Promise<ValueRef>; private make; } export {}; //# sourceMappingURL=compact-values.d.ts.map