import type { Message, Tool } from 'ollama';
import type { ChatResult, IChatClient, StreamChunk } from './chatClient';
/**
 * OpenAI Chat Completions-compatible backend.
 *
 * Speaks the standard `/v1/chat/completions` API surface so the harness can
 * use any provider in that ecosystem (OpenAI, Cerebras, Groq, GitHub Models,
 * Mistral, OpenRouter, Together, Fireworks, etc.) without custom adapters.
 *
 * Chosen on purpose:
 *   - No SDK dependency. Plain `fetch` keeps install footprint small and
 *     avoids version skew across providers that have minor protocol drift.
 *   - Streaming is currently collected and returned as a single ChatResult,
 *     matching the OllamaClient streaming behaviour. The agent loop never
 *     consumed the partial stream events, so faking streaming here is fine.
 *   - Tool/message translation to and from Ollama's shape happens at the
 *     edges of this class so the rest of the codebase keeps using
 *     `ollama.Message` / `ollama.Tool` types without churn.
 */
export interface OpenAIClientConfig {
    /** OpenAI-compatible base URL, e.g. https://api.cerebras.ai/v1 */
    baseUrl: string;
    /** Bearer token. Single string, or comma-separated list for round-robin on 429. */
    apiKey: string | string[];
    /** Provider model id, e.g. gpt-oss-120b or gpt-4.1 */
    model: string;
    /** Optional fallback context window (rarely served by these APIs). */
    contextWindow?: number;
    /** Per-request timeout in milliseconds (default 120s). */
    timeoutMs?: number;
    /** Identifier surfaced in errors / debug logs. */
    providerLabel?: string;
    /** Max attempts on 429/5xx before surfacing the error (default 3). */
    maxRetries?: number;
    /** Initial backoff in ms; doubled per attempt. Capped at 30s. (default 2000) */
    retryBaseDelayMs?: number;
}
export declare class OpenAIClient implements IChatClient {
    private readonly baseUrl;
    private readonly apiKeys;
    private keyIndex;
    private readonly model;
    private readonly contextWindow?;
    private readonly timeoutMs;
    private readonly providerLabel;
    private readonly maxRetries;
    private readonly retryBaseDelayMs;
    constructor(config: OpenAIClientConfig);
    /** Get the active key. Rotates after retryable failures. */
    private currentKey;
    /** Move to the next key in the pool. No-op when only one key configured. */
    private rotateKey;
    chat(messages: Message[], tools?: Tool[], abortSignal?: AbortSignal): Promise<ChatResult>;
    chatOnce(messages: Message[], tools?: Tool[]): Promise<ChatResult>;
    /**
     * Real SSE streaming. Yields one StreamChunk per delta the provider
     * emits. The final chunk has done=true. Tool-call deltas are
     * accumulated by index because OpenAI streams them as fragmented JSON
     * over multiple chunks (`name` arrives once, `arguments` builds up).
     */
    chatStream(messages: Message[], tools?: Tool[], abortSignal?: AbortSignal): AsyncGenerator<StreamChunk>;
    /**
     * The OpenAI-compatible providers we target do not expose a
     * `/v1/models` listing on the free tier in a uniform way, so this
     * returns just the configured model. Health-check uses the same value.
     */
    listModels(): Promise<string[]>;
    getContextWindow(): Promise<number | null>;
    healthCheck(): Promise<{
        ok: boolean;
        error?: string;
    }>;
    getModel(): string;
    private invoke;
}
//# sourceMappingURL=openaiClient.d.ts.map