import type { RunEvent } from '../types/run/events.js';
interface CoalesceOptions {
    windowMs: number;
}
/**
 * Coalesces high-frequency `text_delta` and `tool_input_delta` events into
 * fewer, larger events to relieve downstream backpressure (typically a
 * Server-Sent Events adapter writing to a slow client).
 *
 * Within a sliding `windowMs` window, consecutive `text_delta` events for
 * the same `messageId` are merged by string concatenation; consecutive
 * `tool_input_delta` events for the same `toolUseId` are likewise merged.
 * All other event types pass through immediately and flush any buffered
 * deltas first to preserve ordering.
 *
 * The orchestrator does NOT use this — it emits raw deltas. SSE adapters
 * and other slow consumers opt in. A 16ms window roughly aligns with one
 * UI animation frame at 60fps, which is the empirically derived default
 * for cowork's stream route.
 *
 * Backpressure semantics: this helper does not drop events. If the
 * upstream produces faster than the consumer drains, the helper still
 * yields every coalesced batch; the consumer must apply its own bound or
 * accept queue growth.
 */
export declare function coalesce(stream: AsyncIterable<RunEvent>, options?: CoalesceOptions): AsyncGenerator<RunEvent, void, unknown>;
export {};
//# sourceMappingURL=coalesce.d.ts.map