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; 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; }; } export interface ToolDefinition { readonly name: string; readonly description: string; readonly parameters: Record; } 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; } | { readonly role: "tool"; readonly toolCallId: string; readonly content: string; }; export interface ChatWithToolsResult { readonly content: string; readonly toolCalls: ReadonlyArray; } 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; /** * Transient *HTTP-level* upstream failures worth retrying: 429 (rate limit), * 502/503/504 (gateway / temporarily unavailable / overloaded). These are the * aggregator blips that previously aborted whole architect/writer/short runs * because only transport-level errors were retried. * * Deliberately does NOT match a bare 500 / "MODEL_NOT_AVAILABLE": on providers * like PPIO a 500 means the model isn't on inference at all — retrying is futile * and just delays the real error. */ export declare function isTransientLLMHttpError(error: unknown): boolean; export declare function chatCompletion(client: LLMClient, model: string, messages: ReadonlyArray, options?: { readonly temperature?: number; readonly maxTokens?: number; readonly webSearch?: boolean; readonly onStreamProgress?: OnStreamProgress; readonly onTextDelta?: (text: string) => void; }): Promise; export declare function chatWithTools(client: LLMClient, model: string, messages: ReadonlyArray, tools: ReadonlyArray, options?: { readonly temperature?: number; readonly maxTokens?: number; }): Promise; //# sourceMappingURL=provider.d.ts.map