import { ZodType } from 'zod'; import OpenAI, { ClientOptions } from 'openai'; import { CompletionUsage, ChatCompletionChunk as ChatCompletionChunk$1 } from 'openai/resources'; import { ChatCompletionMessageParam, ChatCompletionCreateParamsBase, ChatCompletionChunk } from 'openai/resources/chat/completions'; import { Tool } from 'openai/resources/responses/responses'; import { RequestOptions } from 'openai/internal/request-options'; import Anthropic from '@anthropic-ai/sdk'; import { MessageParam, RawMessageStreamEvent } from '@anthropic-ai/sdk/resources'; import { MessageCreateParamsBase } from '@anthropic-ai/sdk/resources/messages/messages'; import { GoogleGenAI, Content, GenerateContentConfig, GenerateContentResponse } from '@google/genai'; import Groq from 'groq-sdk'; import { ChatCompletionMessageParam as ChatCompletionMessageParam$1, ChatCompletionChunk as ChatCompletionChunk$2 } from 'groq-sdk/resources/chat'; import { ChatCompletionCreateParamsBase as ChatCompletionCreateParamsBase$1 } from 'groq-sdk/resources/chat/completions'; import { Mistral } from '@mistralai/mistralai'; import { SystemMessage, UserMessage, AssistantMessage, ToolMessage, ChatCompletionStreamRequest, CompletionEvent } from '@mistralai/mistralai/models/components'; import { Ollama, ShowResponse, ProgressResponse, ChatRequest, ChatResponse } from 'ollama/dist/browser.cjs'; import { A } from 'ollama/dist/shared/ollama.1bfa89da.cjs'; type LlmInternalToolProvider = 'anthropic' | 'openai' | 'all' | string; type LlmInternalToolUserLocation = { type: 'approximate'; city?: string; region?: string; country?: string; timezone?: string; }; type LlmInternalWebSearchTool = { type: 'web_search'; provider?: LlmInternalToolProvider; version?: string; maxUses?: number; allowedDomains?: string[]; blockedDomains?: string[]; searchContextSize?: 'low' | 'medium' | 'high'; userLocation?: LlmInternalToolUserLocation; }; type LlmProviderInternalTool = { provider: LlmInternalToolProvider; tool: Record; }; type LlmInternalTool = LlmInternalWebSearchTool | LlmProviderInternalTool; type EngineCreateOpts = { apiKey?: string; baseURL?: string; timeout?: number; maxRetries?: number; deployment?: string; apiVersion?: string; useOpenAIResponsesApi?: boolean; preferResponses?: boolean; requestCooldown?: number; internalTools?: LlmInternalTool[]; }; type ModelsList = { chat: ChatModel[]; image?: Model[]; video?: Model[]; embedding?: Model[]; realtime?: Model[]; computer?: Model[]; tts?: Model[]; stt?: Model[]; }; type ModelCapabilities = { tools: undefined | boolean; vision: boolean; reasoning: boolean; caching: boolean; }; type Model = { id: string; name: string; meta?: ModelMetadata; }; type ChatModel = Model & { capabilities: ModelCapabilities; }; type ModelGeneric = { id: string; name: string; }; type ModelAnthropic = { type: string; id: string; display_name: string; created_at: string; }; type ModelCerebras = { id: string; object: string; created: number; owned_by: string; }; type ModelDeepseek = { id: string; object: string; owned_by: string; }; type ModelGoogle = { name: string; version?: string; displayName?: string; description?: string; inputTokenLimit?: number; outputTokenLimit?: number; supportedActions?: string[]; }; type ModelGroq = { id: string; object: string; created: number; owned_by: string; active?: boolean; context_window?: number; public_apps?: any; max_completion_tokens?: number; }; type ModelMeta = { id: string; created: number; object: string; owned_by: string; }; type ModelMistralAI = { id: string; object?: string; created?: number; ownedBy?: string; name?: string | null; description?: string | null; maxContextLength?: number; aliases?: string[]; deprecation?: any; capabilities: { completionChat?: boolean; completionFim?: boolean; functionCalling?: boolean; fineTuning?: boolean; vision?: boolean; }; type?: string; }; type ModelOllama = { name: string; model: string; modified_at: Date; size: number; digest: string; details: { parent_model: string; format: string; family: string; families: string[]; parameter_size: string; quantization_level: string; }; }; type ModelOpenAI = { id: string; object: string; created: number; owned_by: string; }; type ModelOpenRouter = { id: string; hugging_face_id: string | null; name: string; created: number; description: string; context_length: number; architecture: { modality: string; input_modalities: string[]; output_modalities: string[]; tokenizer: string; instruct_type: string | null; }; pricing: { prompt: string; completion: string; request: string; image: string; web_search: string; internal_reasoning: string; }; top_provider: { context_length: number; max_completion_tokens: number; is_moderated: boolean; }; per_request_limits: any; supported_parameters: string[]; }; type ModelTogether = { id: string; object: string; created: number; type: string; running: boolean; display_name: string; organization: string; link: string; context_length: number; config: { chat_template: string; stop: string[]; bos_token: string; eos_token: string; }; pricing: { hourly: number; input: number; output: number; base: number; finetune: number; }; }; type ModelxAI = { id: string; created: number; object: string; owned_by: string; }; type ModelMetadata = ModelGeneric | ModelAnthropic | ModelCerebras | ModelDeepseek | ModelGoogle | ModelGroq | ModelMeta | ModelMistralAI | ModelOllama | ModelOpenAI | ModelOpenRouter | ModelTogether | ModelxAI; type LlmRole = 'system' | 'developer' | 'user' | 'assistant'; type LlmToolChoiceAuto = { type: 'auto'; }; type LlmToolChoiceNone = { type: 'none'; }; type LlmToolChoiceRequired = { type: 'required'; }; type LlmToolChoiceNamed = { type: 'tool'; name: string; }; type LlmToolChoice = LlmToolChoiceNone | LlmToolChoiceAuto | LlmToolChoiceRequired | LlmToolChoiceNamed; type LlmToolCallInfo = { name: string; params: any; result: any; }; type LlmResponse = { type: 'text'; content?: string; toolCalls?: LlmToolCallInfo[]; thoughtSignature?: string; openAIResponseId?: string; usage?: LlmUsage; logprobs?: LlmLogprob[]; }; type LlmToolCall = { id: string; function: string; args: any; message?: any; result?: any; thoughtSignature?: string; reasoningDetails?: any; }; type NormalizedToolChunk = { type: 'start' | 'delta'; id?: string; name?: string; args?: string; message?: any; argumentsDelta?: string; metadata?: { index?: number; thoughtSignature?: string; reasoningDetails?: any; }; }; type LlmToolResponse = { type: 'tools'; calls: LlmToolCall[]; }; type LlmNonStreamingResponse = LlmResponse | LlmToolResponse; type LlmStream = AsyncIterable & { controller?: AbortController; }; type ToolHistoryEntry = { id: string; name: string; args: any; result: any; round: number; }; type LlmStreamingContext = { model: ChatModel; opts: LlmCompletionOpts; usage: LlmUsage; thread: T[]; toolCalls: LlmToolCall[]; toolHistory: ToolHistoryEntry[]; currentRound: number; startTime: number; }; type CompletedToolCall = { tc: LlmToolCall; args: any; result: any; }; type LlmStreamingResponse = { stream: LlmStream; context: T; }; type EngineHookName = 'beforeToolCallsResponse'; type EngineHookPayloads = { beforeToolCallsResponse: LlmStreamingContext; }; type EngineHookCallback = (payload: EngineHookPayloads[T]) => void | Promise; type LlmReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max'; type LlmVerbosity = 'low' | 'medium' | 'high'; type LLmCustomModelOpts = Record; type LlmOpenAIServiceTier = 'auto' | 'default' | 'flex' | 'scale' | 'priority' | null; type LlmOpenAIModelOpts = { useResponsesApi?: boolean; responseId?: string; reasoningEffort?: LlmReasoningEffort; verbosity?: LlmVerbosity; serviceTier?: LlmOpenAIServiceTier; }; type LlmAnthropicModelOpts = { reasoning?: boolean; reasoningBudget?: number; }; type LlmGoogleModelOpts = { thinkingBudget?: number; }; type LlmOllamaThink = boolean | 'high' | 'medium' | 'low'; type LlmOllamaModelOpts = { think?: LlmOllamaThink; logprobs?: boolean; top_logprobs?: number; }; type LlmModelOpts = { timeout?: number; contextWindowSize?: number; maxTokens?: number; temperature?: number; top_k?: number; top_p?: number; customOpts?: LLmCustomModelOpts; } & LlmOpenAIModelOpts & LlmAnthropicModelOpts & LlmGoogleModelOpts & LlmOllamaModelOpts; type LlmStructuredOutput = { name: string; structure: ZodType; }; type LlmToolExecutionValidationDecision = 'allow' | 'deny' | 'abort'; type LlmToolExecutionValidationResponse = { decision: LlmToolExecutionValidationDecision; extra?: any; }; type LlmToolExecutionValidationCallback = (context: PluginExecutionContext, tool: string, args: any) => Promise; type LlmCompletionOpts = { tools?: boolean; internalTools?: LlmInternalTool[]; toolChoice?: LlmToolChoice; toolExecutionDelegate?: ToolExecutionDelegate; toolExecutionValidation?: LlmToolExecutionValidationCallback; toolCallsInThread?: boolean; caching?: boolean; visionFallbackModel?: ChatModel; usage?: boolean; citations?: boolean; structuredOutput?: LlmStructuredOutput; abortSignal?: AbortSignal; } & LlmModelOpts; type LlmCompletionPayloadContent = { role: LlmRole; content: string | LlmContentPayload[]; images?: string[]; tool_calls?: any[]; }; type LlmCompletionPayloadTool = { role: 'tool'; tool_call_id: string; name: string; content: string; }; type LlmCompletionPayload = LlmCompletionPayloadContent | LlmCompletionPayloadTool; type LLmContentPayloadText = { type: 'text'; text: string; thoughtSignature?: string; }; type LLmContentPayloadImageOpenai = { type: 'image_url'; image_url: { url: string; }; }; type LLmContentPayloadDocumentAnthropic = { type: 'document'; source?: { type: 'text'; media_type: 'text/plain'; data: string; }; title?: string; context?: string; citations?: { enabled: boolean; }; }; type LLmContentPayloadImageAnthropic = { type: 'image'; source?: { type: string; media_type: 'image/jpeg' | 'image/png' | 'image/gif' | 'image/webp'; data: string; }; }; type LlmContentPayloadMistralai = { type: 'image_url'; imageUrl: { url: string; }; }; type LlmContentPayload = LLmContentPayloadText | LLmContentPayloadImageOpenai | LLmContentPayloadDocumentAnthropic | LLmContentPayloadImageAnthropic | LlmContentPayloadMistralai; type LlmChunkToolAbort = { type: 'tool_abort'; name: string; params: any; reason: LlmToolExecutionValidationResponse; }; type LlmChunkContent = { type: 'content' | 'reasoning'; text: string; thoughtSignature?: string; done: boolean; }; type LlmChunkStream = { type: 'stream'; stream: LlmStream; }; type ToolExecutionState = 'preparing' | 'running' | 'completed' | 'canceled' | 'error'; type LlmChunkTool = { type: 'tool'; id: string; name: string; state: ToolExecutionState; status?: string; call?: { params: any; result: any; }; thoughtSignature?: string; reasoningDetails?: any; done: boolean; }; type LlmChunkUsage = { type: 'usage'; usage: LlmUsage; }; type LlmOpenAIMessageId = { type: 'openai_message_id'; id: string; }; type LlmChunk = LlmChunkToolAbort | LlmChunkContent | LlmChunkStream | LlmChunkTool | LlmChunkUsage | LlmOpenAIMessageId; type ToolParameterType = 'string' | 'number' | 'boolean' | 'object' | 'array'; type LlmToolArrayItem = { name: string; type: ToolParameterType; description: string; required?: boolean; }; type LlmToolArrayItems = { type: string; required?: boolean; properties?: LlmToolArrayItem[]; }; type LlmToolParameterOpenAI = { type: ToolParameterType; description: string; enum?: string[]; items?: LlmToolArrayItems; }; type LlmToolOpenAI = { type: 'function'; function: { name: string; description: string; parameters: { type: 'object'; properties: Record; required: string[]; }; }; }; /** * LlmTool accepts both the new PluginTool format and legacy OpenAI format. * Prefer using PluginTool for new code. */ type LlmTool = PluginTool | LlmToolOpenAI; type LlmUsage = { prompt_tokens: number; completion_tokens: number; prompt_tokens_details?: { cached_tokens?: number; audio_tokens?: number; }; completion_tokens_details?: { reasoning_tokens?: number; audio_tokens?: number; }; }; type LlmTokenLogprob = { token: string; logprob: number; }; type LlmLogprob = LlmTokenLogprob & { top_logprobs?: LlmTokenLogprob[]; }; interface IPlugin { serializeInTools(): boolean; isEnabled(): boolean; getName(): string; getDescription(): string; getPreparationDescription(tool: string, partialArgs?: any): string; getRunningDescription(tool: string, args: any): string; getCompletedDescription(tool: string, args: any, results: any): string | undefined; getParameters(): PluginParameter[]; execute(context: PluginExecutionContext, parameters: any): Promise; executeWithUpdates?(context: PluginExecutionContext, parameters: any): AsyncGenerator; } type PluginParameter = { name: string; type: ToolParameterType; description: string; required?: boolean; enum?: string[]; items?: { type: string; properties?: PluginParameter[]; items?: { type: string; }; }; }; /** * Provider-agnostic tool definition format. * This is the recommended format for defining tools in plugins. * It will be converted to provider-specific formats internally. */ type PluginTool = { name: string; description: string; parameters: PluginParameter[]; }; type PluginExecutionContext = { model: string; abortSignal?: AbortSignal; }; type PluginExecutionStatusUpdate = { type: 'status'; status: string; }; type PluginExecutionResult = { type: 'result'; result: any; canceled?: boolean; validation?: LlmToolExecutionValidationResponse; }; type PluginExecutionUpdate = PluginExecutionStatusUpdate | PluginExecutionResult; /** * Delegate for external tool execution. * Allows callers to inject tool definitions and handle execution externally * without creating plugin classes. Tools from the delegate are per-request, * not registered globally on the engine. */ type ToolExecutionDelegate = { getTools(): Promise | PluginTool[]; execute(context: PluginExecutionContext, tool: string, args: any): Promise; }; declare const codeFormats: string[]; declare const configFormats: string[]; declare const textFormats: string[]; declare const imageFormats: string[]; declare class Attachment { content: string; mimeType: string; title: string; context: string; constructor(content?: string, mimeType?: string); format(): string; isText(): boolean; isImage(): boolean; } declare function mimeTypeToExtension(mimeType: string): string; declare function extensionToMimeType(extension: string): string; declare class Message { role: LlmRole; content: string; reasoning: string | null; attachments: Attachment[]; toolCalls: LlmToolCall[]; thoughtSignature?: string; reasoningDetails?: any; get contentForModel(): string; constructor(role: LlmRole, content?: string | null, attachment?: Attachment, toolCalls?: LlmToolCall[]); attach(attachment: Attachment): void; detach(attachment: Attachment): void; appendText(chunk: LlmChunkContent): void; } interface ICustomPlugin extends IPlugin { getTools(): Promise; } declare class Plugin implements IPlugin { serializeInTools(): boolean; isEnabled(): boolean; getName(): string; getDescription(): string; getPreparationDescription(tool: string, partialArgs?: any): string; getRunningDescription(tool: string, args: any): string; getCompletedDescription(tool: string, args: any, results: any): string | undefined; getCanceledDescription(tool: string, args: any): string | undefined; getParameters(): PluginParameter[]; execute(context: PluginExecutionContext, parameters: any): Promise; /** * Executes a promise with abort signal support and optional cleanup. * Races the promise against the abort signal. * * This is a generic helper that works with any Promise and AbortSignal, * not specific to IPC or any particular implementation. * * @param operation - The async operation to execute * @param abortSignal - Optional abort signal to monitor * @param onAbort - Optional callback invoked when abort is triggered (for cleanup) * @returns Promise that resolves with operation result or rejects on abort * * @example * // Simple fetch with abort * const data = await this.runWithAbort( * fetch('https://api.example.com/data'), * context.abortSignal * ) * * @example * // With cleanup callback * const result = await this.runWithAbort( * someAsyncOperation(), * context.abortSignal, * () => cleanup() * ) */ runWithAbort(operation: Promise, abortSignal?: AbortSignal, onAbort?: () => void): Promise; } declare class CustomToolPlugin extends Plugin implements ICustomPlugin { getTools(): Promise; } declare class MultiToolPlugin extends Plugin implements ICustomPlugin { toolsEnabled: string[] | null; enableTool(name: string): void; getTools(): Promise; handlesTool(name: string): boolean; } /** * Type guard to check if a tool is in the new PluginTool format. * PluginTool has parameters as an array, while OpenAI format has nested structure. */ declare function isToolDefinition(tool: LlmTool): tool is PluginTool; /** * Type guard to check if a tool is in the legacy OpenAI format. */ declare function isLegacyOpenAITool(tool: LlmTool): tool is LlmToolOpenAI; /** * Normalizes any LlmTool format to PluginTool. * Use this to convert legacy OpenAI format tools to the new format. */ declare function normalizeToToolDefinition(tool: LlmTool): PluginTool; /** * Converts a PluginTool to OpenAI format. * Use this for providers that use OpenAI SDK or expect OpenAI format. */ declare function toolDefinitionToOpenAI(tool: PluginTool): LlmToolOpenAI; /** * Converts any LlmTool to OpenAI format. * If already in OpenAI format, returns as-is. */ declare function toOpenAITool(tool: LlmTool): LlmToolOpenAI; /** * Normalizes an array of tools to PluginTool format. */ declare function normalizeTools(tools: LlmTool[]): PluginTool[]; /** * Converts an array of tools to OpenAI format. */ declare function toOpenAITools(tools: LlmTool[]): LlmToolOpenAI[]; declare const addUsages: (usage1: LlmUsage | null | undefined, usage2: LlmUsage | null | undefined) => LlmUsage; declare const PROVIDER_BASE_URLS: Record; declare const getProviderBaseURL: (provider: string) => string | null; declare abstract class LlmEngine { config: EngineCreateOpts; plugins: IPlugin[]; private hooks; private toolPreparationStatuses; static isConfigured: (opts: EngineCreateOpts) => boolean; static isReady: (opts: EngineCreateOpts, models: ModelsList) => boolean; constructor(config: EngineCreateOpts); addHook(name: T, callback: EngineHookCallback): () => void; protected callHook(name: T, payload: EngineHookPayloads[T]): Promise; protected abstract syncToolHistoryToThread(context: LlmStreamingContext): void; abstract getId(): string; getName(): string; abstract getModelCapabilities(model: ModelMetadata): ModelCapabilities; abstract getModels(): Promise; protected abstract chat(model: Model, thread: any[], opts?: LlmCompletionOpts): Promise; protected abstract stream(model: Model, thread: Message[], opts?: LlmCompletionOpts): Promise; /** * @deprecated This method is deprecated and may be removed in future versions. Use abortSignal in LlmCompletionOpts instead. */ abstract stop(stream: any): Promise; protected addTextToPayload(model: ChatModel, message: Message, attachment: Attachment, payload: LlmCompletionPayload, opts?: LlmCompletionOpts): void; protected addImageToPayload(model: ChatModel, attachment: Attachment, payload: LlmCompletionPayload, opts?: LlmCompletionOpts): void; protected abstract processNativeChunk(chunk: any, context: LlmStreamingContext): AsyncGenerator; clearPlugins(): void; addPlugin(plugin: Plugin): void; removePlugin(name: string): void; complete(model: ChatModel | string, thread: Message[], opts?: LlmCompletionOpts): Promise; generate(model: ChatModel | string, thread: Message[], opts?: LlmCompletionOpts): AsyncIterable; protected requiresVisionModelSwitch(thread: Message[], currentModel: ChatModel): boolean; protected selectModel(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): ChatModel; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; requiresReasoningContent(): boolean; buildPayload(model: ChatModel, thread: Message[] | string, opts?: LlmCompletionOpts): T[]; protected getAvailableTools(delegate?: ToolExecutionDelegate): Promise; protected getInternalTools(provider: string, opts?: LlmCompletionOpts): LlmInternalTool[]; protected getPluginAsTool(plugin: Plugin): PluginTool; protected getPluginForTool(tool: string): Plugin | null; protected getToolPreparationDescription(tool: string, partialArgs?: any): string; protected getToolRunningDescription(tool: string, args: any): string; protected getToolCompletedDescription(tool: string, args: any, results: any): string | undefined; protected getToolCanceledDescription(tool: string, args: any): string | undefined; protected parsePartialToolArgs(args: string): any | undefined; protected processToolExecutionResult(providerId: string, toolName: string, params: any, lastUpdate: PluginExecutionResult | undefined): { content: any; canceled: boolean; }; /** * ============================================================================ * Tool Call Normalization and Execution * ============================================================================ * * Providers stream tool calls in different formats. This base class provides * shared infrastructure to normalize parsing and execution across all providers. * * ## Flow * 1. Provider parses native chunk → creates NormalizedToolChunk * 2. processToolCallChunk() accumulates into context.toolCalls[] * 3. On finish, provider calls executeToolCalls*() with formatting callbacks * 4. Base class executes tools, provider formats results for its thread format * * ## Two Execution Patterns * * **Sequential (OpenAI/Groq/Mistral)** * - Each tool call/result added to thread immediately after execution * - Thread: [assistant+tool1] [result1] [assistant+tool2] [result2] ... * - Use: executeToolCallsSequentially() * * **Batched (Anthropic/Google)** * - All tools execute first, then all added to thread at once * - Thread: [assistant with ALL tool calls] [user/tool with ALL results] * - Use: executeToolCallsBatched() * * ## Provider Implementation * Providers only need to: * 1. Parse native chunks into NormalizedToolChunk format * 2. Call processToolCallChunk() to accumulate * 3. Provide formatters for their native thread message format * 4. Call the appropriate execute*() method * ============================================================================ */ /** * Normalize and accumulate a tool call chunk. * Handles both 'start' (new tool) and 'delta' (argument append) types. * Yields 'preparing' notification for new tool calls. */ protected processToolCallChunk(normalized: NormalizedToolChunk, context: { toolCalls: LlmToolCall[]; }): Generator; /** * Execute tool calls with per-tool thread formatting (OpenAI/Groq/Mistral style). * Each tool call and result is added to thread immediately after execution. */ protected executeToolCallsSequentially(toolCalls: LlmToolCall[], context: LlmStreamingContext, options: { formatToolCallForThread: (tc: LlmToolCall, args: any) => T; formatToolResultForThread: (result: any, tc: LlmToolCall, args: any) => T; createNewStream: (context: LlmStreamingContext) => Promise; }): AsyncGenerator; /** * Execute tool calls with batched thread formatting (Anthropic/Google style). * All tool calls execute first, then all are added to thread at once. */ protected executeToolCallsBatched(toolCalls: LlmToolCall[], context: LlmStreamingContext, options: { formatBatchForThread: (completed: CompletedToolCall[]) => T[]; createNewStream: (context: LlmStreamingContext) => Promise; }): AsyncGenerator; /** * Execute a single tool call. Shared by both sequential and batched methods. * Returns null if aborted, otherwise returns { args, result }. */ private executeOneTool; /** * Finalize tool execution: call hook, sync, and recurse. */ private finalizeToolExecution; /** * Apply cooldown delay if configured, based on elapsed time since startTime. */ protected applyCooldown(startTime: number): Promise; protected callTool(context: PluginExecutionContext, tool: string, args: any, delegate?: ToolExecutionDelegate, toolExecutionValidation?: LlmToolExecutionValidationCallback): AsyncGenerator; protected toModel(model: string | ChatModel): ChatModel; buildModel(model: string): ChatModel; } declare class LlmModel { engine: LlmEngine; model: string | ChatModel; constructor(engine: LlmEngine, model: string | ChatModel); get plugins(): IPlugin[]; clearPlugins(): void; addPlugin(plugin: Plugin): void; removePlugin(name: string): void; complete(thread: Message[], opts?: LlmCompletionOpts): Promise; generate(thread: Message[], opts?: LlmCompletionOpts): AsyncIterable; } type OpenAIToolOpts = Omit; type OpenAIStreamingContext = LlmStreamingContext & { reasoningContent: string; textContent: string; responsesApi: boolean; thinking: boolean; done?: boolean; }; declare class export_default$c extends LlmEngine { client: OpenAI; constructor(config: EngineCreateOpts, opts?: ClientOptions); getId(): string; getModelCapabilities(model: ModelMetadata): ModelCapabilities; supportsServiceTiering(): boolean; modelAcceptsSystemRole(model: string): boolean; modelSupportsMaxTokens(model: ChatModel): boolean; modelSupportsTemperature(model: ChatModel): boolean; modelSupportsTopP(model: ChatModel): boolean; modelSupportsTopK(model: ChatModel): boolean; modelSupportsReasoningEffort(model: ChatModel): boolean; modelSupportsVerbosity(model: ChatModel): boolean; modelRequiresResponsesApi(model: ChatModel): boolean; modelSupportsStructuredOutput(model: ChatModel): boolean; doesNotSendToolCallFinishReason(model: ChatModel): boolean; get systemRole(): LlmRole; getModels(): Promise; protected setBaseURL(): void; protected shouldUseResponsesApi(model: ChatModel, opts?: LlmCompletionOpts): boolean; buildOpenAIPayload(model: ChatModel, thread: Message[] | string, opts?: LlmCompletionOpts): ChatCompletionMessageParam[]; chat(model: ChatModel, thread: ChatCompletionMessageParam[], opts?: LlmCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: OpenAIStreamingContext): Promise; getCompletionOpts(model: ChatModel, opts?: LlmCompletionOpts): Omit; getRequestOptions(model: ChatModel, opts?: LlmCompletionOpts): RequestOptions; getToolsOpts(model: ChatModel, opts?: LlmCompletionOpts): Promise; stop(stream: LlmStream): Promise; syncToolHistoryToThread(context: OpenAIStreamingContext): void; processNativeChunk(chunk: ChatCompletionChunk, context: OpenAIStreamingContext): AsyncGenerator; defaultRequiresFlatTextPayload(model: ChatModel, msg: Message): boolean; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; accumulateUsage(cumulate: LlmUsage, usage: CompletionUsage): void; responsesChat(model: ChatModel, thread: LlmCompletionPayload[], opts?: LlmCompletionOpts): Promise; responsesStream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; private buildResponsesRequestFromMessages; private buildResponsesRequest; private attachResponsesTools; getResponsesTools(model: ChatModel, opts?: LlmCompletionOpts): Promise; private getOpenAIInternalTools; private pluginParamToResponsesSchema; private normalizeSchemaForResponses; private schemaHasType; private makeSchemaNullable; private getResponsesToolChoice; continueResponse(model: ChatModel, previousId: string, input: string, opts?: LlmCompletionOpts): Promise; forkResponse(model: ChatModel, previousId: string, input: string, opts?: LlmCompletionOpts): Promise; private accumulateResponsesUsage; } declare class export_default$b extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getModels(): Promise; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; } type AnthropicCompletionOpts = LlmCompletionOpts & { system?: string; }; interface AnthropicComputerToolInfo { plugin: Plugin; screenSize(): { width: number; height: number; }; screenNumber(): number; } type AnthropicStreamingContext = LlmStreamingContext & { system: string; requestUsage: LlmUsage; thinkingBlock?: string; thinkingSignature?: string; textContentBlock?: string; firstTextBlockStart: boolean; }; declare class export_default$a extends LlmEngine { client: Anthropic; computerInfo: AnthropicComputerToolInfo | null; constructor(config: EngineCreateOpts, computerInfo?: AnthropicComputerToolInfo | null); private toolDefinitionToInputSchema; private convertItems; getId(): string; getModelCapabilities(model: ModelAnthropic): ModelCapabilities; getComputerUseRealModel(): string; isComputerUseModel(model: string): boolean; getMaxTokens(model: string): number; getModels(): Promise; complete(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise; chat(model: ChatModel, thread: MessageParam[], opts?: AnthropicCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: AnthropicStreamingContext): Promise; doStreamNormal(context: AnthropicStreamingContext): Promise; doStreamBeta(context: AnthropicStreamingContext): Promise; getCompletionOpts(model: ChatModel, opts?: LlmCompletionOpts): Omit; getToolOpts(model: ChatModel, opts?: LlmCompletionOpts): Promise>; private getAnthropicInternalTools; cacheRequest(model: ChatModel, opts: LlmCompletionOpts, params: T): T; stop(stream: LlmStream): Promise; syncToolHistoryToThread(context: AnthropicStreamingContext): void; processNativeChunk(chunk: RawMessageStreamEvent, context: AnthropicStreamingContext): AsyncGenerator; addTextToPayload(model: ChatModel, message: Message, attachment: Attachment, payload: LlmCompletionPayload, opts?: LlmCompletionOpts): void; addImageToPayload(model: ChatModel, attachment: Attachment, payload: LlmCompletionPayload, opts?: LlmCompletionOpts): void; buildAnthropicPayload(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): MessageParam[]; } declare class export_default$9 extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getVisionModels(): string[]; modelSupportsTopK(model: Model): boolean; get systemRole(): LlmRole; getModels(): Promise; protected setBaseURL(): void; getAvailableTools(delegate?: any): Promise; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; processNativeChunk(chunk: ChatCompletionChunk$1, context: OpenAIStreamingContext): AsyncGenerator; } declare class export_default$8 extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getVisionModels(): string[]; getModelCapabilities(model: ModelDeepseek): ModelCapabilities; modelSupportsReasoningEffort(model: ChatModel): boolean; modelSupportsStructuredOutput(model: ChatModel): boolean; get systemRole(): LlmRole; getModels(): Promise; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; requiresReasoningContent(): boolean; } type GoogleCompletionOpts = LlmCompletionOpts & { instruction?: string; }; interface GoogleComputerToolInfo { plugin: Plugin; screenSize(): { width: number; height: number; }; screenNumber(): number; } type GoogleStreamingContext = LlmStreamingContext & { opts: GoogleCompletionOpts; requestUsage: LlmUsage; textContentBlock?: string; }; declare class export_default$7 extends LlmEngine { client: GoogleGenAI; computerInfo: GoogleComputerToolInfo | null; constructor(config: EngineCreateOpts, computerInfo?: GoogleComputerToolInfo | null); getId(): string; getModelCapabilities(model: ModelGoogle): ModelCapabilities; isComputerUseModel(model: string): boolean; getModels(): Promise; complete(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise; chat(model: ChatModel, thread: Content[], opts?: GoogleCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: GoogleStreamingContext): Promise; private supportsInstructions; private supportsStructuredOutput; private getInstructions; private typeToSchemaType; private pluginParamToGoogleSchema; private convertItemsForGoogle; protected getGenerationConfig(model: ChatModel, opts?: GoogleCompletionOpts): Promise; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; buildGooglePayload(thread: Message[], model: ChatModel, opts?: LlmCompletionOpts): Content[]; private messageToContent; private addAttachment; stop(stream: LlmStream): Promise; syncToolHistoryToThread(context: GoogleStreamingContext): void; processNativeChunk(chunk: GenerateContentResponse, context: GoogleStreamingContext): AsyncGenerator; addImageToPayload(model: ChatModel, attachment: Attachment, payload: LlmCompletionPayloadContent, opts?: LlmCompletionOpts): void; } type GroqStreamingContext = LlmStreamingContext & { textContent?: string; }; declare class export_default$6 extends LlmEngine { client: Groq; constructor(config: EngineCreateOpts); getId(): string; getModelCapabilities(model: ModelGroq): ModelCapabilities; getModels(): Promise; chat(model: ChatModel, thread: ChatCompletionMessageParam$1[], opts?: LlmCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: GroqStreamingContext): Promise; getCompletionOpts(model: ChatModel, opts?: LlmCompletionOpts): Omit; getToolOpts(model: ChatModel, opts?: LlmCompletionOpts): Promise>; stop(stream: LlmStream): Promise; syncToolHistoryToThread(context: GroqStreamingContext): void; processNativeChunk(chunk: ChatCompletionChunk$2, context: GroqStreamingContext): AsyncGenerator; buildGroqPayload(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): ChatCompletionMessageParam$1[]; } declare class export_default$5 extends export_default$c { static isConfigured: (engineConfig: EngineCreateOpts) => boolean; static isReady: (opts: EngineCreateOpts, models: ModelsList) => boolean; constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getModelCapabilities(model: ModelGeneric): ModelCapabilities; get systemRole(): LlmRole; getModels(): Promise; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; processNativeChunk(chunk: ChatCompletionChunk$1, context: OpenAIStreamingContext): AsyncGenerator; } declare class export_default$4 extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getModelCapabilities(model: ModelMeta): ModelCapabilities; modelSupportsStructuredOutput(model: ChatModel): boolean; get systemRole(): LlmRole; getModels(): Promise; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; } type MistralMessages = Array<(SystemMessage & { role: "system"; }) | (UserMessage & { role: "user"; }) | (AssistantMessage & { role: "assistant"; }) | (ToolMessage & { role: "tool"; })>; type MistralStreamingContext = LlmStreamingContext & { textContent?: string; }; declare class export_default$3 extends LlmEngine { client: Mistral; constructor(config: EngineCreateOpts); getId(): string; getModelCapabilities(model: ModelMistralAI): ModelCapabilities; getModels(): Promise; chat(model: ChatModel, thread: MistralMessages, opts?: LlmCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: MistralStreamingContext): Promise; getCompletionOpts(model: ChatModel, opts?: LlmCompletionOpts): Omit; getToolOpts(model: ChatModel, opts?: LlmCompletionOpts): Promise>; stop(): Promise; syncToolHistoryToThread(context: MistralStreamingContext): void; processNativeChunk(chunk: CompletionEvent, context: MistralStreamingContext): AsyncGenerator; protected addImageToPayload(model: ChatModel, attachment: Attachment, payload: LlmCompletionPayload, opts?: LlmCompletionOpts): void; buildMistralPayload(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): MistralMessages; } type OllamaMessage = NonNullable[number]; type OllamaStreamingContext = LlmStreamingContext & { thinking: boolean; textContent?: string; }; declare class export_default$2 extends LlmEngine { client: Ollama; static isConfigured: (engineConfig: EngineCreateOpts) => boolean; static isReady: (opts: EngineCreateOpts, models: ModelsList) => boolean; constructor(config: EngineCreateOpts); getId(): string; getModelCapabilities(model: ModelOllama): ModelCapabilities; getModels(): Promise; getModelInfo(model: string): Promise; pullModel(model: string): Promise | null>; deleteModel(model: string): Promise; chat(model: ChatModel, thread: OllamaMessage[], opts?: LlmCompletionOpts): Promise; stream(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): Promise>; doStream(context: OllamaStreamingContext): Promise; buildChatOptions({ model, messages, opts }: { model: string; messages: OllamaMessage[]; opts: LlmCompletionOpts | null; }): ChatRequest; getToolOpts(model: ChatModel, opts?: LlmCompletionOpts): Promise>; stop(): Promise; syncToolHistoryToThread(context: OllamaStreamingContext): void; processNativeChunk(chunk: ChatResponse, context: OllamaStreamingContext): AsyncGenerator; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; addImageToPayload(model: ChatModel, attachment: Attachment, payload: LlmCompletionPayloadContent, opts: LlmCompletionOpts): void; buildOllamaPayload(model: ChatModel, thread: Message[], opts?: LlmCompletionOpts): OllamaMessage[]; } declare class export_default$1 extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getModels(): Promise; getModelCapabilities(model: ModelOpenRouter): ModelCapabilities; modelSupportsStructuredOutput(model: ChatModel): boolean; get systemRole(): LlmRole; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; } declare const xAIBaseURL: string; declare class export_default extends export_default$c { constructor(config: EngineCreateOpts); getId(): string; supportsServiceTiering(): boolean; getModelCapabilities(model: ModelxAI): ModelCapabilities; get systemRole(): LlmRole; doesNotSendToolCallFinishReason(model: ChatModel): boolean; getModels(): Promise; protected setBaseURL(): void; requiresFlatTextPayload(model: ChatModel, msg: Message): boolean; } declare const staticModelsListEngines: never[]; declare const igniteEngine: (engine: string, config: EngineCreateOpts) => LlmEngine; declare const igniteModel: (engine: string, model: string | ChatModel, config: EngineCreateOpts) => LlmModel; declare const loadModels: (engine: string, config: EngineCreateOpts) => Promise; declare const loadAnthropicModels: (engineConfig: EngineCreateOpts, computerInfo?: AnthropicComputerToolInfo | null) => Promise; declare const loadAzureModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadCerebrasModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadDeepSeekModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadGoogleModels: (engineConfig: EngineCreateOpts, computerInfo?: GoogleComputerToolInfo | null) => Promise; declare const loadGroqModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadLMStudioModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadMetaModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadMistralAIModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadOllamaModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadOpenAIModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadOpenRouterModels: (engineConfig: EngineCreateOpts) => Promise; declare const loadXAIModels: (engineConfig: EngineCreateOpts) => Promise; declare const logger: { disable: () => void; set: (logger: any) => void; }; declare const defaultCapabilities: { capabilities: ModelCapabilities; }; export { export_default$a as Anthropic, Attachment, export_default$b as Azure, export_default$9 as Cerebras, type ChatModel, type CompletedToolCall, CustomToolPlugin, export_default$8 as DeepSeek, type EngineCreateOpts, type EngineHookCallback, type EngineHookName, type EngineHookPayloads, export_default$7 as Google, export_default$6 as Groq, type IPlugin, type LLmContentPayloadDocumentAnthropic, type LLmContentPayloadImageAnthropic, type LLmContentPayloadImageOpenai, type LLmContentPayloadText, type LLmCustomModelOpts, export_default$5 as LMStudio, type LlmAnthropicModelOpts, type LlmChunk, type LlmChunkContent, type LlmChunkStream, type LlmChunkTool, type LlmChunkToolAbort, type LlmChunkUsage, type LlmCompletionOpts, type LlmCompletionPayload, type LlmCompletionPayloadContent, type LlmCompletionPayloadTool, type LlmContentPayload, type LlmContentPayloadMistralai, LlmEngine, type LlmGoogleModelOpts, type LlmInternalTool, type LlmInternalToolProvider, type LlmInternalToolUserLocation, type LlmInternalWebSearchTool, type LlmLogprob, LlmModel, type LlmModelOpts, type LlmNonStreamingResponse, type LlmOllamaModelOpts, type LlmOllamaThink, type LlmOpenAIMessageId, type LlmOpenAIModelOpts, type LlmOpenAIServiceTier, type LlmProviderInternalTool, type LlmReasoningEffort, type LlmResponse, type LlmRole, type LlmStream, type LlmStreamingContext, type LlmStreamingResponse, type LlmStructuredOutput, type LlmTokenLogprob, type LlmTool, type LlmToolArrayItem, type LlmToolArrayItems, type LlmToolCall, type LlmToolCallInfo, type LlmToolChoice, type LlmToolChoiceAuto, type LlmToolChoiceNamed, type LlmToolChoiceNone, type LlmToolChoiceRequired, type LlmToolExecutionValidationCallback, type LlmToolExecutionValidationDecision, type LlmToolExecutionValidationResponse, type LlmToolOpenAI, type LlmToolParameterOpenAI, type LlmToolResponse, type LlmUsage, type LlmVerbosity, Message, export_default$4 as Meta, export_default$3 as MistralAI, type Model, type ModelAnthropic, type ModelCapabilities, type ModelCerebras, type ModelDeepseek, type ModelGeneric, type ModelGoogle, type ModelGroq, type ModelMeta, type ModelMetadata, type ModelMistralAI, type ModelOllama, type ModelOpenAI, type ModelOpenRouter, type ModelTogether, type ModelsList, type ModelxAI, MultiToolPlugin, type NormalizedToolChunk, export_default$2 as Ollama, type OllamaMessage, export_default$c as OpenAI, export_default$1 as OpenRouter, PROVIDER_BASE_URLS, Plugin, type PluginExecutionContext, type PluginExecutionResult, type PluginExecutionStatusUpdate, type PluginExecutionUpdate, type PluginParameter, type PluginTool, type ToolExecutionDelegate, type ToolExecutionState, type ToolHistoryEntry, type ToolParameterType, export_default as XAI, addUsages, codeFormats, configFormats, defaultCapabilities, extensionToMimeType, getProviderBaseURL, igniteEngine, igniteModel, imageFormats, isLegacyOpenAITool, isToolDefinition, loadAnthropicModels, loadAzureModels, loadCerebrasModels, loadDeepSeekModels, loadGoogleModels, loadGroqModels, loadLMStudioModels, loadMetaModels, loadMistralAIModels, loadModels, loadOllamaModels, loadOpenAIModels, loadOpenRouterModels, loadXAIModels, logger, mimeTypeToExtension, normalizeToToolDefinition, normalizeTools, staticModelsListEngines, textFormats, toOpenAITool, toOpenAITools, toolDefinitionToOpenAI, xAIBaseURL };