import { type MessageStreamEvent } from "#protocol/message.js";
import type { CancelSessionResult, MessageResult } from "#client/types.js";
/**
 * Internal configuration passed to construct a {@link MessageResponse}.
 */
interface MessageResponseInput {
    readonly cancelTurn: (turnId: string) => Promise<CancelSessionResult>;
    readonly createStream: (source?: AsyncIterable<MessageStreamEvent>) => AsyncGenerator<MessageStreamEvent>;
    readonly deliveryId?: string;
    readonly sessionId: string;
}
declare const consumeResponse: unique symbol;
declare const acceptedDeliveryId: unique symbol;
/**
 * The response from {@link ClientSession.send}.
 *
 * Like `fetch()`, the response exposes its session ID as soon as the POST
 * completes. Collect the event stream via
 * {@link result} or iterate it with `for await...of`.
 */
export declare class MessageResponse<TOutput = unknown> implements AsyncIterable<MessageStreamEvent> {
    #private;
    /**
     * Session ID assigned by the server.
     */
    readonly sessionId: string;
    readonly [acceptedDeliveryId]: string | undefined;
    /** @internal */
    constructor(input: MessageResponseInput);
    /**
     * Requests cooperative cancellation of this exact turn.
     *
     * The request waits for the response stream to identify the turn when
     * necessary. Continue consuming the stream to observe its durable boundary.
     */
    cancel(): Promise<CancelSessionResult>;
    /**
     * Consumes the full event stream and returns the aggregated
     * {@link MessageResult}.
     */
    result(): Promise<MessageResult<TOutput>>;
    /**
     * Yields stream events one at a time.
     *
     * Each response can only be consumed once.
     */
    [Symbol.asyncIterator](): AsyncIterator<MessageStreamEvent>;
    [consumeResponse](source?: AsyncIterable<MessageStreamEvent>): AsyncGenerator<MessageStreamEvent>;
}
/** @internal Returns the accepted message identity without consuming its response stream. */
export declare function getMessageResponseDeliveryId(response: MessageResponse): string | undefined;
/** @internal Observe a turn through the frontend's existing session stream. */
export declare function consumeMessageResponse(response: MessageResponse, source: AsyncIterable<MessageStreamEvent>): AsyncIterable<MessageStreamEvent>;
export {};
