/** * Options for {@link SerializedMessageStream}. */ export interface SerializedMessageStreamOptions { /** Writes `content` to the platform message (e.g. an edit/update call). */ apply: (content: string) => Promise; /** Minimum gap between consecutive applies, in ms. `flush()` bypasses it. */ throttleMs: number; /** * Sink for a failed `apply`; defaults to `console.error`. The failure is * swallowed after reporting: a failed FINAL apply leaves the platform * message stale, and nothing retries it unless newer content arrives. */ onApplyError?: (err: unknown) => void; /** Clock override for tests; defaults to `Date.now`. */ now?: () => number; } /** * Per-message streaming text state machine. * * Wraps a single posted platform message and lets callers feed it the growing * text buffer of a streaming reply. Edits are throttled (chat platforms * rate-limit message updates) and *serialised* through a per-message promise * queue so concurrent updates can't race — a hazard the upstream project hit, * where an end-triggered flush of "ALPHA" could be overtaken by an in-flight * flush of "AL" and the final state read "AL". * * Guarantees: at most one `apply` in flight; applies happen in enqueue order; * a newer `enqueue` supersedes older un-applied content (no stale flush); no * `apply` more often than `throttleMs` except on `flush()`. */ export declare class SerializedMessageStream { private buffer; private applied; private queue; private lastApplyAt; private flushTimer; private readonly throttleMs; private readonly apply; private readonly onApplyError; private readonly now; constructor(opts: SerializedMessageStreamOptions); /** Replace the in-flight buffer (callers pass the accumulated text). */ enqueue(content: string): void; /** * Mark the stream done. Cancels any pending throttled flush, enqueues a * final flush, and resolves once the entire queue (including the final * flush and anything previously in flight) has drained. * * After this resolves, the platform message reflects the final buffer state. */ flush(): Promise; private scheduleFlush; private enqueueFlush; private flushNow; } //# sourceMappingURL=message-stream.d.ts.map