/** * `createMarkdownStream()` — a one-line bridge between an AI token loop and * ``. * * It owns a reactive `value` signal and coalesces bursts of `append()` calls * into a single signal write per `flushIntervalMs` window, so a fast token * stream re-renders at a bounded rate instead of once per token. * * @example * ```tsx * const md = createMarkdownStream({ flushIntervalMs: 16 }); * * // producer * for await (const token of completion) md.append(token); * md.done(); * * // consumer * * ``` */ import { type PrimitiveSignal } from '@sigx/lynx'; export interface CreateMarkdownStreamOptions { /** * Coalesce `append()` calls within this many milliseconds into a single * `value` update. `0` (default) flushes synchronously on every append. * A small value such as `16` caps re-renders to ~60fps under fast streams. */ flushIntervalMs?: number; } export interface MarkdownStream { /** Reactive accumulated source. Pass to ``. */ readonly value: PrimitiveSignal; /** Reactive completion flag, set by {@link MarkdownStream.done}. */ readonly finished: PrimitiveSignal; /** Append a token/chunk; buffered and coalesced into `value`. */ append(chunk: string): void; /** Flush any pending buffer and mark the stream complete. */ done(): void; /** Clear the buffer, `value`, and `finished` (e.g. for a regenerate). */ reset(): void; } export declare function createMarkdownStream(opts?: CreateMarkdownStreamOptions): MarkdownStream;