@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
42 lines • 2.02 kB
TypeScript
import { type LeafId } from "./compact-content-store.ts";
import { type ContentDigest } from "./compact-recovery-ids.ts";
/**
* A catalog node's private pointers: where each child's stored bytes live. Never part of a node's hashed bytes and
* never sent. The list is a tree of side leaves, each at most `COMPACT_LEAF_CODE_UNITS` (32,768 code units, 64 KiB
* stored), however many children or component leaves it names:
*
* - a height-0 leaf `{"h":0,"v":[...]}` holds tokens in child order: a node child `{"n":node,"s":side,"d":digest}`,
* or a component header `{"c":count}` followed by its `count` leaf ids, which may continue in the next leaf;
* - a height-h leaf `{"h":h,"v":[{"s":side,"d":digest},...]}` lists the height h-1 leaves below it in order.
*
* Every side leaf is checked against its `pointer`-domain digest (recorded by its parent leaf, the parent node's
* pointers or the root) before decode, so a changed or stale pointer is `integrity`. The writer keeps one open leaf
* per height and the reader one decoded leaf per height: no pointer list is ever one string.
*/
export interface PointerHead {
readonly side: LeafId;
readonly digest: ContentDigest;
}
type Pointer = {
readonly kind: "node";
readonly node: LeafId;
readonly head: PointerHead;
} | {
readonly kind: "component";
readonly leaves: readonly LeafId[];
};
export declare class CatalogPointerWriter {
private readonly open;
private readonly create;
constructor(create: (text: string) => LeafId);
node(node: LeafId, head: PointerHead): void;
component(leaves: readonly LeafId[]): void;
finish(): PointerHead;
private level;
private push;
private seal;
}
/** The pointer of child `step`, or `undefined` past the last child; a malformed list is `integrity`. */
export declare function catalogPointer(read: (side: LeafId) => Promise<string>, head: PointerHead, step: number): Promise<Pointer | undefined>;
export {};
//# sourceMappingURL=compact-catalog-pointers.d.ts.map