/** How a turn ended. Anything but `done` stops the queue. */ export type QueueTurnOutcome = "done" | "cancelled" | "failed" | "refused"; /** What a queued message must carry. Hosts add their own fields (attached * files, a context toggle…); the queue keeps them with the message. */ export interface QueueMessageInput { text: string; images?: string[]; } export type QueuedMessage = M & { id: string; }; export interface MessageQueueOptions { /** The host's own "a turn is running" flag. A turn the queue did not start * (another surface, a command) holds the queue back too. */ isStreaming: boolean; /** Starts a turn and resolves with how it ended. A rejection counts as * `failed`. */ send: (message: M) => Promise; /** The queue stopped after a turn that did not finish; `items` were still * waiting and are no longer queued. */ onHalted?: (items: QueuedMessage[], outcome: Exclude) => void; } export interface MessageQueue { items: QueuedMessage[]; /** Sends now when nothing is running or waiting, else queues behind it. */ submit: (message: M) => "sent" | "queued"; remove: (id: string) => void; /** Takes one message out of the queue (to edit it). */ take: (id: string) => QueuedMessage | undefined; /** Empties the queue and returns what was in it, oldest first. */ takeAll: () => QueuedMessage[]; /** Puts messages saved before a reload back at the front of the queue. * With `running`, a turn this queue started before the reload that is * still going: the queue waits for it as if it had sent it, stopping when * it does not finish. Without it, they run once nothing is running. */ restore: (items: QueuedMessage[], running?: Promise) => void; } /** A queue id, unique within the page. */ export declare function createQueuedMessageId(): string; /** The composer text after `items` come back into it: after what is already * there, one message per paragraph, in their order. */ export declare function draftWithQueued(current: string, items: readonly Pick[]): string; export declare function useMessageQueue({ isStreaming, send, onHalted, }: MessageQueueOptions): MessageQueue; //# sourceMappingURL=useMessageQueue.d.ts.map