/** * Pure functions for flushing completed live items to Static history. * * During an agent run, items (text blocks, tool calls, etc.) accumulate in * the live area. Ink re-renders ALL live items on every state change, so if * they grow unbounded the live area becomes very tall, making Ink's cursor * math expensive and causing visible jank. * * These functions determine which items can be safely moved to Static history * (where Ink writes them once and never re-renders them). */ /** Minimal item shape needed for flush logic. */ export interface FlushableItem { kind: string; id: string; } /** * Max history items kept in React state. Ink's renders items once * to stdout, so pruned items remain visible in terminal scrollback — we just * release the JS object references to avoid unbounded memory growth. */ export declare const MAX_HISTORY_ITEMS = 200; /** * Prune history to keep at most MAX_HISTORY_ITEMS. Oldest items are dropped * first; they remain visible in terminal scrollback. */ export declare function pruneHistory(items: T[]): T[]; /** * Trim large payload data from items that have been flushed to Static history. * Ink already rendered them to the terminal — we only keep a truncated version * to prevent multi-GB memory retention from tool results, server tool data, and * sub-agent results. * * Works with any item shape via duck-typing: truncates `result` strings, * clears `input`/`data` fields, and trims sub-agent result strings. */ export declare function trimFlushedItems(items: T[]): T[]; /** * Called when `onTurnText` fires (end of each LLM turn that produced text). * All previous items are guaranteed complete — tool calls from this turn * finished before `turn_end` fired, and `onTurnText` fires inside `turn_end`. * * Returns the items to flush to history. Callers should keep the live area * bounded and avoid re-rendering finalized long text through Ink. */ export declare function flushOnTurnText(liveItems: T[]): T[]; export declare function flushOverflow(liveItems: T[]): { flushed: T[]; remaining: T[]; }; /** * When a turn finalizes, decide how many leading items must be flushed to * scrollback immediately because the pinned frame is too tall for the live * area. Finalized items lose the streaming-time table/code-block clamp, so a * too-tall pinned frame exceeds the terminal and Ink can only paint its * bottom rows — the top of the response (e.g. a table's header) is never * painted anywhere until the next turn's flush finally writes it to * scrollback. * * The budget is CUMULATIVE: a turn segmented on [DONE:N] markers pins several * assistant items whose individual heights fit while their sum overflows. * Walking from the end, keep the largest suffix that fits within * `liveAreaRows` and flush the leading complement — a contiguous prefix, so * transcript order is preserved. An item taller than the whole budget flushes * itself and everything before it. Returns 0 when everything fits or the * live area hasn't been measured yet. */ export declare function countOversizedFlushItems(items: readonly { kind: string; text?: string; }[], estimateRows: (text: string) => number, liveAreaRows: number): number; export declare function splitOversizedPinnedItems(items: readonly T[], estimateRows: (text: string) => number, liveAreaRows: number): { flushed: T[]; remaining: T[]; }; /** * Called when `onTurnEnd` fires with a tool_use stop reason (LLM responded * with only tool calls, no text). Flushes all items IF none are still pending * (no `tool_start` without a corresponding `tool_done`). * * Returns { flushed, remaining } — flushed items go to history, remaining * items stay in liveItems. */ export declare function flushOnTurnEnd(liveItems: T[], stopReason: string): { flushed: T[]; remaining: T[]; }; //# sourceMappingURL=live-item-flush.d.ts.map