import type { LLMConfig } from "../models/project.js";
import type { Api as PiApi, Model as PiModel } from "@mariozechner/pi-ai";
export interface StreamProgress {
    readonly elapsedMs: number;
    readonly totalChars: number;
    readonly chineseChars: number;
    readonly status: "streaming" | "done";
}
export type OnStreamProgress = (progress: StreamProgress) => void;
export declare function createStreamMonitor(onProgress?: OnStreamProgress, intervalMs?: number): {
    readonly onChunk: (text: string) => void;
    readonly stop: () => void;
};
export interface LLMResponse {
    readonly content: string;
    readonly usage: {
        readonly promptTokens: number;
        readonly completionTokens: number;
        readonly totalTokens: number;
    };
}
export interface LLMMessage {
    readonly role: "system" | "user" | "assistant";
    readonly content: string;
}
export interface LLMClient {
    readonly provider: "openai" | "anthropic";
    readonly service?: string;
    readonly configSource?: LLMConfig["configSource"];
    readonly apiFormat: "chat" | "responses";
    readonly stream: boolean;
    readonly proxyUrl?: string;
    readonly _piModel?: PiModel<PiApi>;
    readonly _apiKey?: string;
    readonly defaults: {
        readonly temperature: number;
        /**
         * Per-call fallback: 当 agent 调 chat() 不传 options.maxTokens 时用这个值。
         * 命中模型卡时来自 providers bank 的 modelCard.maxOutput；未知模型走写作兜底预算。
         */
        readonly maxTokens: number;
        /**
         * Legacy mock compatibility only. v2 provider resolution no longer caps
         * per-call maxTokens from project config; model max output comes from the
         * provider bank.
         */
        readonly maxTokensCap?: number | null;
        readonly thinkingBudget: number;
        readonly extra: Record<string, unknown>;
    };
}
export interface ToolDefinition {
    readonly name: string;
    readonly description: string;
    readonly parameters: Record<string, unknown>;
}
export interface ToolCall {
    readonly id: string;
    readonly name: string;
    readonly arguments: string;
}
export type AgentMessage = {
    readonly role: "system";
    readonly content: string;
} | {
    readonly role: "user";
    readonly content: string;
} | {
    readonly role: "assistant";
    readonly content: string | null;
    readonly toolCalls?: ReadonlyArray<ToolCall>;
} | {
    readonly role: "tool";
    readonly toolCallId: string;
    readonly content: string;
};
export interface ChatWithToolsResult {
    readonly content: string;
    readonly toolCalls: ReadonlyArray<ToolCall>;
}
export declare function createLLMClient(config: LLMConfig): LLMClient;
export declare class PartialResponseError extends Error {
    readonly partialContent: string;
    constructor(partialContent: string, cause: unknown);
}
export declare function __resetFixedTemperatureWarnings(): void;
export declare function chatCompletion(client: LLMClient, model: string, messages: ReadonlyArray<LLMMessage>, options?: {
    readonly temperature?: number;
    readonly maxTokens?: number;
    readonly webSearch?: boolean;
    readonly onStreamProgress?: OnStreamProgress;
    readonly onTextDelta?: (text: string) => void;
}): Promise<LLMResponse>;
export declare function chatWithTools(client: LLMClient, model: string, messages: ReadonlyArray<AgentMessage>, tools: ReadonlyArray<ToolDefinition>, options?: {
    readonly temperature?: number;
    readonly maxTokens?: number;
}): Promise<ChatWithToolsResult>;
//# sourceMappingURL=provider.d.ts.map