/** * Per-Discord-message streaming text state machine. * * Wraps a single posted Discord message and lets callers feed it the growing * text buffer of a streaming reply. Edits are throttled (Discord's edit rate * limit is ~5 edits/5s per channel, tighter than Slack's ~1/sec per message) * and *serialised* through a per-message promise queue so concurrent updates * can't race — a hazard the previous implementation hit, where End-triggered * flush of "ALPHA" could be overtaken by an in-flight flush of "AL" and the * final state read "AL". * * Nothing in this file knows about AG-UI events or discord.js — it's a * pure Discord-side primitive: "give me text, I'll keep one Discord message * in sync with it." */ export interface MessageStreamConfig { /** Function that actually writes `text` to Discord (e.g. message.edit). */ update: (text: string) => Promise; /** Minimum gap between consecutive flushes, in ms (defaults to 1100). */ minIntervalMs?: number; } export declare class MessageStream { private buffer; private posted; private queue; private lastFlushedAt; private flushTimer; private readonly minIntervalMs; private readonly update; constructor(config: MessageStreamConfig); /** Replace the in-flight buffer (callers pass the accumulated text). */ append(text: 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 Discord message reflects the final buffer state. */ finish(): Promise; private scheduleFlush; private enqueueFlush; private flushNow; } //# sourceMappingURL=message-stream.d.ts.map