@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
94 lines • 4.96 kB
TypeScript
import { type CallCounters, type OutstandingCall } from "./compact-call-model.ts";
import { type ComponentRoot } from "./compact-component-roots.ts";
import type { CompactContentStore } from "./compact-content-store.ts";
import { type ValueRef } from "./compact-values.ts";
interface Slot {
readonly ref: ValueRef;
readonly bytes: number;
}
/**
* The resident side of the calls component (S06 design section 2): the live entries, four indexes, the owned slot
* values, and the persistent root every change republishes through the shared component roots.
*/
export declare class CompactCallTable {
root: ComponentRoot<OutstandingCall>;
private readonly store;
private readonly values;
private readonly roots;
private readonly entries;
private readonly byTurn;
private readonly byMessage;
private readonly byId;
private readonly children;
private readonly shared;
private slotBytes;
private headerBytes;
readonly counters: {
replacements: number;
progressReplacements: number;
unknown: number;
late: number;
collisions: number;
reused: number;
};
constructor(store: CompactContentStore);
get(key: string): OutstandingCall | undefined;
byTurnId(turnId: string | null, toolCallId: string | null): OutstandingCall | undefined;
byOwner(messageId: string, contentIndex: number): OutstandingCall | undefined;
/** The newest call with this id that is non-terminal or holds a synthetic outcome (design section 3). */
newestById(toolCallId: string): OutstandingCall | undefined;
/**
* The oldest `open` call with this id, its own turn first (FIFO by creation, senpi#4278): when a reused id overlaps
* a call still executing, each execution end closes, and each carrier settles, the call it belongs to.
*/
oldestById(toolCallId: string, turnId: string | null, open: (call: OutstandingCall) => boolean): OutstandingCall | undefined;
/**
* The oldest call of `turnId` started under `id` before any block joined it (a bridge-started call, RULING-127 (b)):
* a block joins it and keeps its first key; oldest first, the order the producer assigns their keys to blocks.
*/
bridgeStarted(turnId: string | null, id: string | null): OutstandingCall | undefined;
/**
* RULING-123, C3.4: whether another call of `call`'s own message took the same toolCallId. An execution or hook
* record names only the toolCallId, so it cannot say which of those calls it is about. The mark lasts while any call
* of that message and id is live, so a later record is not attributed by elimination either.
*/
sharesIdInMessage(call: OutstandingCall): boolean;
ofTurn(turnId: string): Iterable<OutstandingCall>;
all(): Iterable<OutstandingCall>;
childrenOf(parentKey: string): readonly OutstandingCall[];
/** Measured before owning: a value the engine cannot serialize (too deep) throws with nothing owned yet (RULING-59). */
own(value: unknown): Slot;
/** X07 `slotBytes` counts one copy per slot: the replaced value's bytes leave with it. */
replaceSlot(call: OutstandingCall, field: "hook" | "progress" | "result", value: unknown): OutstandingCall;
private readonly slotBytesOf;
/**
* Publishes a created or changed call at its creation ordinal and refreshes every index it is reachable by. The
* stored header carries `callUnknown: true` exactly while `sharesIdInMessage` holds for it (#5348), so the snapshot
* row, the in-process view and the settled projection all state the mark this table keeps; the first call to share
* an id with another of its message republishes the others marked.
*/
put(input: OutstandingCall, creation: {
readonly sequence: number;
readonly k: number;
}): void;
/** A changed call keeps the creation ordinal its key was put at (RULING-13 Q1), whatever minted that key. */
reput(input: OutstandingCall): void;
private putAt;
/** Whether `call`, once put, shares its toolCallId inside its message: the mark is set, or another live call has it. */
private willShare;
remove(key: string): void;
/** Whether another live call already owns this (turn, id) slot: a collision leaves the index unchanged. */
indexedTo(turnId: string, toolCallId: string): string | undefined;
/** A reused id (senpi#4278) points the (turn, id) slot at the fresh call. */
repoint(turnId: string, toolCallId: string, key: string): void;
snapshot(): CallCounters;
freeze(): ValueRef | undefined;
release(ref: ValueRef | undefined): void;
entriesOf(ref: ValueRef | undefined, valid: () => void): AsyncGenerator<readonly [string, OutstandingCall], any, any>;
private index;
/** The live calls of one message under one toolCallId. */
private inMessage;
private unindex;
}
export {};
//# sourceMappingURL=compact-call-table.d.ts.map