import type { Node } from './nodes.js'; import type { MultiAgentStreamEvent } from './events.js'; import type { NodeResult } from './state.js'; /** * Data produced by a running node: a streaming event, a completion signal, or an error. */ export type QueueData = { type: 'event'; node: Node; event: MultiAgentStreamEvent; } | { type: 'result'; node: Node; result: NodeResult; } | { type: 'error'; node: Node; error: Error; }; /** * Queue data paired with an acknowledgement callback. * The consumer must call {@link ack} after fully processing the data * to unblock any producer waiting via {@link Queue.send}. */ export interface QueueEntry { data: QueueData; ack: () => void; } /** * Async queue with promise-based notification and optional back-pressure. * * Producers use {@link push} for fire-and-forget or {@link send} to * block until the consumer has fully processed the data. The consumer calls * {@link shift} to dequeue, then {@link QueueEntry.ack} after * processing to unblock the producer. */ export declare class Queue { private readonly _entries; /** Resolve function for the pending wait() promise, if any. */ private _notify?; private _disposed; /** * Push data to the queue, waking any waiting consumer. */ push(data: QueueData): void; /** * Push data and wait until the consumer has fully processed it. * Provides back-pressure so the producer pauses until the event * has been yielded and hook callbacks have been invoked. * * @param data - The queue data to push * @returns Promise that resolves when the consumer calls {@link QueueEntry.ack} */ send(data: QueueData): Promise; /** * Wait until at least one entry is available. */ wait(): Promise; /** * Remove and return the next entry, or undefined if empty. */ shift(): QueueEntry | undefined; /** * Dispose the queue by resolving all pending acks and draining entries. * Future {@link send} calls resolve immediately. */ dispose(): void; /** * Number of entries in the queue. */ get size(): number; } //# sourceMappingURL=queue.d.ts.map