import { type Logger } from '@agentuity/client';
import { z } from 'zod';
import { type AIGatewayWSUsage } from './protocol.ts';
export declare const AIGatewayWebSocketErrorCode: {
    readonly connection_error: "connection_error";
    readonly connection_draining: "connection_draining";
    readonly connection_closed: "connection_closed";
    readonly invalid_response: "invalid_response";
    readonly max_reconnects_exceeded: "max_reconnects_exceeded";
    readonly request_timeout: "request_timeout";
};
export type AIGatewayWebSocketErrorCode = (typeof AIGatewayWebSocketErrorCode)[keyof typeof AIGatewayWebSocketErrorCode];
export declare const AIGatewayWebSocketError: {
    new (args?: ({
        code: AIGatewayWebSocketErrorCode;
        statusCode?: number;
        requestId?: string;
        closeCode?: number;
        closeReason?: string;
    } & {
        message?: string;
        cause?: unknown;
    }) | undefined): import("@agentuity/adapter").RichError & {
        readonly _tag: "AIGatewayWebSocketError";
    } & Readonly<{
        code: AIGatewayWebSocketErrorCode;
        statusCode?: number;
        requestId?: string;
        closeCode?: number;
        closeReason?: string;
    }>;
    readonly defaultMessage?: string;
};
export type AIGatewayWebSocketErrorInstance = InstanceType<typeof AIGatewayWebSocketError>;
export type AIGatewayWebSocketState = 'connecting' | 'connected' | 'reconnecting' | 'draining' | 'closed';
export declare const AIGatewayWSRequestOptionsSchema: z.ZodObject<{
    id: z.ZodOptional<z.ZodString>;
    compact: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
    model: z.ZodOptional<z.ZodString>;
    prompt: z.ZodOptional<z.ZodString>;
    system: z.ZodOptional<z.ZodString>;
    thinking: z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>;
    temperature: z.ZodOptional<z.ZodNumber>;
    max_tokens: z.ZodOptional<z.ZodNumber>;
    stream: z.ZodOptional<z.ZodBoolean>;
    data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
    timeoutMs: z.ZodOptional<z.ZodNumber>;
}, z.core.$strip>;
export type AIGatewayWSRequestOptions = z.infer<typeof AIGatewayWSRequestOptionsSchema>;
export interface AIGatewayWSResult {
    id: string;
    content?: string;
    usage?: AIGatewayWSUsage;
    cost?: number;
    unit?: string;
    inputQty?: number;
    outputQty?: number;
    statusCode?: number;
    data?: unknown;
}
export type AIGatewayWSStreamEvent = {
    type: 'delta';
    delta: string;
} | {
    type: 'thinking_delta';
    thinking: string;
} | {
    type: 'event';
    event: string;
    data: unknown;
} | {
    type: 'complete';
    result: AIGatewayWSResult;
};
export interface AIGatewayWebSocketOptions {
    apiKey: string;
    orgId?: string;
    url?: string;
    autoReconnect?: boolean;
    reconnectDelayMs?: number;
    maxReconnectDelayMs?: number;
    maxReconnectAttempts?: number;
    defaultTimeoutMs?: number;
    /** Log outbound request and inbound response frames. Defaults to AGENTUITY_AIGATEWAY_WS_DEBUG. */
    debug?: boolean;
    logger?: Logger;
    onOpen?: () => void;
    onClose?: (code: number, reason: string) => void;
    onError?: (error: AIGatewayWebSocketErrorInstance) => void;
    onDraining?: (message: string) => void;
    onReconnect?: (attempt: number) => void;
    onStateChange?: (state: AIGatewayWebSocketState) => void;
}
/** @internal Exported for unit tests and SDK consumers building frames manually. */
export declare function buildAIGatewayWebSocketRequestFrame(options: AIGatewayWSRequestOptions, id: string): Record<string, unknown>;
export declare class AIGatewayWebSocketClient {
    #private;
    constructor(options: AIGatewayWebSocketOptions);
    get state(): AIGatewayWebSocketState;
    get isDraining(): boolean;
    get url(): string;
    get orgId(): string | undefined;
    connect(): Promise<void>;
    close(code?: number, reason?: string): void;
    cancel(requestId: string): void;
    complete(options: AIGatewayWSRequestOptions): Promise<AIGatewayWSResult>;
    stream(options: AIGatewayWSRequestOptions): AsyncGenerator<AIGatewayWSStreamEvent>;
}
export declare function createAIGatewayWebSocketClient(options: AIGatewayWebSocketOptions): AIGatewayWebSocketClient;
//# sourceMappingURL=websocket.d.ts.map