/** * In-memory, per-session buffer of opencode messages + parts. * * opencode plugins run in-process in the long-lived server, so — unlike * weave-codex, which reads an append-only rollout file with a byte cursor — we * accumulate the structured event stream directly. `takeCompletedTurns()` is the * cursor's moral equivalent: it returns turns that look fully flushed and not * yet emitted, marks them emitted, and prunes their messages so the buffer stays * bounded over a long session. Pure and synchronous; the plugin owns I/O. */ import type { ReconstructedTurn } from '../model.js'; import { type OcEvent } from './types.js'; export declare class Accumulator { private readonly sessions; /** Feed one opencode event. Unknown event types are ignored. */ ingest(event: OcEvent): void; /** * Return turns for `sessionId` that are complete and not yet emitted, marking * them emitted and pruning their messages. Call this on `session.idle`. */ takeCompletedTurns(sessionId: string): ReconstructedTurn[]; /** Drop a session's buffer entirely (e.g. on session end / error cleanup). */ forget(sessionId: string): void; private snapshot; private buffer; private dropMessage; }