import type { LocalModelConfig } from "../config.js";
import type { Logger } from "../logger.js";
import type { ModelProvider } from "../models/registry.js";
export interface ChatMessage {
    role: "system" | "user" | "assistant" | "tool";
    content: string;
    tool_call_id?: string;
    tool_calls?: OpenAIToolCall[];
}
export interface OpenAIToolDefinition {
    type: "function";
    function: {
        name: string;
        description: string;
        parameters: Record<string, unknown>;
    };
}
export interface OpenAIToolCall {
    id: string;
    type: "function";
    function: {
        name: string;
        arguments: string;
    };
}
export type OpenAICompletionEvent = {
    type: "text";
    text: string;
} | {
    type: "tool_calls";
    toolCalls: OpenAIToolCall[];
};
export type OpenAIBackendErrorCode = "http_error" | "malformed_sse" | "request_aborted" | "request_timeout";
export interface OpenAIStreamOptions {
    signal?: AbortSignal;
    timeoutMs?: number;
    /**
     * Observability correlation id forwarded to the model backend (gateway) as
     * `x-fusion-trace-id`. The gateway honors it so the Cursor edge shares one
     * observable session with the downstream fusion run.
     */
    traceId?: string;
}
export declare class OpenAIBackendError extends Error {
    readonly code: OpenAIBackendErrorCode;
    constructor(code: OpenAIBackendErrorCode, message: string, options?: ErrorOptions);
}
export declare class OpenAIStreamParseError extends OpenAIBackendError {
    constructor(message: string, options?: ErrorOptions);
}
export declare class OpenAICompatibleProvider implements ModelProvider {
    private readonly config;
    private readonly logger?;
    private readonly options;
    readonly name = "openai-compatible";
    constructor(config: LocalModelConfig, logger?: Logger | undefined, options?: {
        logFullPayload: boolean;
    });
    streamCompletion(messages: ChatMessage[], options?: OpenAIStreamOptions): AsyncGenerator<string>;
    streamCompletionEvents(messages: ChatMessage[], tools?: OpenAIToolDefinition[], options?: OpenAIStreamOptions): AsyncGenerator<OpenAICompletionEvent>;
}
export declare function parseOpenAIStream(stream: AsyncIterable<Uint8Array>): AsyncGenerator<string | Extract<OpenAICompletionEvent, {
    type: "tool_calls";
}>>;
