/**
 * The streaming protocol.
 *
 * A connector's streaming call yields a {@link Channel} of {@link Emission}s —
 * incremental deltas followed by a single terminal `done` (success) or
 * `error` (failure).
 */
import type { Reply, StopReason, Usage } from "./reply";
import type { GatewayError } from "./errors";
/** Incremental assistant prose. */
export interface TextEmission {
    readonly kind: "text";
    readonly delta: string;
}
/** Incremental reasoning / chain-of-thought text. */
export interface ThinkingEmission {
    readonly kind: "thinking";
    readonly delta: string;
}
/** Announces the beginning of a tool call, before its arguments stream in. */
export interface ToolCallStartEmission {
    readonly kind: "tool_call_start";
    readonly id: string;
    readonly name: string;
}
/** A fragment of a tool call's argument JSON, keyed to its call `id`. */
export interface ToolCallDeltaEmission {
    readonly kind: "tool_call_delta";
    readonly id: string;
    readonly argsDelta: string;
}
/** Carries token accounting, typically near the end of a stream. */
export interface UsageEmission {
    readonly kind: "usage";
    readonly usage: Usage;
}
/** Reports the model's stop reason. */
export interface StopEmission {
    readonly kind: "stop";
    readonly stop: StopReason;
}
/** Terminal success: the fully assembled response. */
export interface DoneEmission {
    readonly kind: "done";
    readonly reply: Reply;
}
/** Terminal failure: a normalized gateway error. */
export interface ErrorEmission {
    readonly kind: "error";
    readonly error: GatewayError;
}
/** The tagged union of every streaming event a {@link Channel} can yield. */
export type Emission = TextEmission | ThinkingEmission | ToolCallStartEmission | ToolCallDeltaEmission | UsageEmission | StopEmission | DoneEmission | ErrorEmission;
/** An async stream of {@link Emission}s, consumed with `for await`. */
export type Channel = AsyncIterable<Emission>;
