import type { Api, Context, Model, StreamOptions } from "../types.js";
import type { AssistantMessageEventStream } from "./event-stream.js";
import type { StreamingStateManager } from "./streaming-state-manager.js";
/**
 * Generic adapter interface for streaming providers.
 * Encapsulates provider-specific client, request building, and stream processing.
 */
export interface ProviderAdapter<TOptions extends StreamOptions = StreamOptions> {
    /** API identifier (e.g., "anthropic-messages"). */
    readonly api: Api;
    /** Provider name (e.g., "anthropic"). */
    readonly provider: string;
    /** Model identifier. */
    readonly model: Model<Api>;
    /** Optional provider-specific options. */
    readonly options?: TOptions;
    /** Context (system prompt, messages, tools). */
    readonly context: Context;
    /** Stream to push events to. */
    readonly stream: AssistantMessageEventStream;
    /** Optional abort signal. */
    readonly signal?: AbortSignal;
    /** Streaming state manager (tracks output, usage, stop reason). */
    state: StreamingStateManager;
    /** Initialize the adapter (e.g., create client). */
    initialize(): Promise<void> | void;
    /** Build provider-specific request parameters. */
    buildRequest(): unknown;
    /** Execute the request and stream events. */
    executeStream(): Promise<void>;
    /** Cleanup resources after streaming completes. */
    cleanup(): Promise<void> | void;
}
/**
 * Base adapter with shared lifecycle and helper methods.
 */
export declare abstract class BaseProviderAdapter<TOptions extends StreamOptions = StreamOptions> implements ProviderAdapter<TOptions> {
    readonly model: Model<Api>;
    readonly context: Context;
    readonly stream: AssistantMessageEventStream;
    readonly options?: TOptions | undefined;
    readonly signal?: AbortSignal | undefined;
    readonly api: Api;
    readonly provider: string;
    constructor(model: Model<Api>, context: Context, stream: AssistantMessageEventStream, options?: TOptions | undefined, signal?: AbortSignal | undefined);
    /** To be set by subclasses during initialization. */
    state: StreamingStateManager;
    abstract initialize(): Promise<void> | void;
    abstract buildRequest(): unknown;
    abstract executeStream(): Promise<void>;
    cleanup(): Promise<void> | void;
    /** Check if aborted. */
    protected isAborted(): boolean;
    /** Emit error if aborted. */
    protected throwIfAborted(): void;
}
