/** * @module koi/oo-harness/harness-events * * The run's own memory of what happened, as data rather than as prose. * * A transcript is a bad memory: to find "what did the build say twenty steps * ago" the model has to re-read everything, and when the transcript is * compacted the answer is gone for good. NOOA's answer (Apache-2.0) is an * append-only log of TYPED, TAGGED events that the model can query by tag, * kind or text — so history becomes addressable, and compaction becomes a * collapse of a range into a summary rather than a loss. * * That is what makes long autonomy possible here: the koi can run for hours, * collapse everything it has finished with, and still answer "what was the * error in step 12" by asking for tag 12 instead of hoping it survived. */ export type HarnessEventKind = "task" | "turn" | "cell" | "output" | "tool" | "state" | "note" | "error" | "result" | "summary"; export type HarnessEvent = { /** Stable address the model uses: events(12). Monotonic, never reused. */ tag: number; kind: HarnessEventKind; /** One line, safe to render anywhere. */ title: string; /** The body, already bounded by the writer. */ text?: string; at: number; /** Structured payload for the views; never rendered into the prompt raw. */ meta?: Record; /** Set when this event replaced a collapsed range. */ collapsed?: { from: number; to: number; count: number; }; }; export type EventQuery = { kind?: HarnessEventKind | HarnessEventKind[]; /** Case-insensitive substring over title and text. */ contains?: string; since?: number; limit?: number; }; export declare class HarnessEventLog { private readonly events; private nextTag; private readonly maxEvents; constructor(options?: { maxEvents?: number; }); append(event: Omit & { at?: number; }): HarnessEvent; get(tag: number): HarnessEvent | undefined; all(): HarnessEvent[]; /** The model-facing query: kind, text, recency — nothing exotic. */ query(request?: EventQuery): HarnessEvent[]; /** * Replace a finished stretch of history with one summary event. The range * is REMOVED, not hidden: this is how a long run stays inside its context * without the model having to re-read what it already concluded. */ collapse(from: number, to: number, summary: string): HarnessEvent; /** The event region of the context, oldest first, tags visible. */ render(limit?: number): string; snapshot(limit?: number): Array>; }