import type { AssistantMessage, AssistantMessageEvent, ToolCall } from "../types.js";
export interface EventStreamOptions {
    historyLimit?: number;
}
/**
 * Generic producer/consumer channel: callers shove events in via `push` while
 * downstream code reads them with `for await`. Whichever event matches
 * `isComplete` flips the channel into a terminal state and settles a
 * dedicated result promise (typed as `R`) using `extractResult`.
 *
 * Implementation-wise, every event lands in a single FIFO array. After each
 * push (or when the channel is closed) we fire the optional "wake" callback
 * that an idle iterator is parked on. The iterator itself maintains a private
 * read cursor, flushes any backlog already sitting in the buffer, and only
 * suspends on a freshly-armed wake promise once it has caught up to head and
 * the channel hasn't been closed yet.
 */
export declare class EventStream<T, R = T> implements AsyncIterable<T> {
    private isComplete;
    private extractResult;
    private options;
    private buffer;
    private closed;
    private notify;
    private finalResultPromise;
    private resolveFinalResult;
    private rejectFinalResult;
    private history;
    constructor(isComplete: (event: T) => boolean, extractResult: (event: T) => R, options?: EventStreamOptions);
    /** Resume the iterator that is waiting on `notify`, when one exists. */
    private wake;
    push(event: T): void;
    end(result?: R): void;
    error(error: unknown): void;
    [Symbol.asyncIterator](): AsyncIterator<T>;
    result(): Promise<R>;
    resultWithTimeout(timeoutMs: number): Promise<R>;
    filter(predicate: (event: T) => boolean): AsyncIterable<T>;
    map<U>(mapper: (event: T) => U): AsyncIterable<U>;
    getHistory(): readonly T[];
    private pushHistory;
}
export declare class AssistantMessageEventStream extends EventStream<AssistantMessageEvent, AssistantMessage> {
    constructor(options?: EventStreamOptions);
    pushStart(partial: AssistantMessage): void;
    pushTextStart(contentIndex: number, partial: AssistantMessage): void;
    pushTextDelta(contentIndex: number, delta: string, partial: AssistantMessage): void;
    pushTextEnd(contentIndex: number, content: string, partial: AssistantMessage): void;
    pushThinkingStart(contentIndex: number, partial: AssistantMessage): void;
    pushThinkingDelta(contentIndex: number, delta: string, partial: AssistantMessage): void;
    pushThinkingEnd(contentIndex: number, content: string, partial: AssistantMessage): void;
    pushToolCallStart(contentIndex: number, partial: AssistantMessage): void;
    pushToolCallDelta(contentIndex: number, delta: string, partial: AssistantMessage): void;
    pushToolCallEnd(contentIndex: number, toolCall: ToolCall, partial: AssistantMessage): void;
    pushDone(reason: "stop" | "length" | "toolUse", message: AssistantMessage): void;
    pushError(reason: "aborted" | "error", error: AssistantMessage): void;
}
/**
 * Factory that hands back a fresh {@link AssistantMessageEventStream}
 * instance. Using it (instead of `new`-ing the class yourself) keeps
 * consumer code free of a direct dependency on the concrete constructor.
 */
export declare function createAssistantMessageEventStream(options?: EventStreamOptions): AssistantMessageEventStream;
