import type * as z from 'zod/v4'; export declare class InvokeError extends Error { type: InvokeErrorType; retryable: boolean; statusCode?: number; rawError?: unknown; rawResponse?: unknown; constructor(type: InvokeErrorType, message: string, rawError?: unknown, rawResponse?: unknown); private isRetryable; } declare type InvokeErrorType = (typeof InvokeErrorTypes)[keyof typeof InvokeErrorTypes]; /** * Error types and error handling for LLM invocations */ export declare const InvokeErrorTypes: { readonly NETWORK_ERROR: "network_error"; readonly RATE_LIMIT: "rate_limit"; readonly SERVER_ERROR: "server_error"; readonly NO_TOOL_CALL: "no_tool_call"; readonly INVALID_TOOL_ARGS: "invalid_tool_args"; readonly TOOL_EXECUTION_ERROR: "tool_execution_error"; readonly UNKNOWN: "unknown"; readonly CONFIG_ERROR: "config_error"; readonly AUTH_ERROR: "auth_error"; readonly CONTEXT_LENGTH: "context_length"; readonly CONTENT_FILTER: "content_filter"; }; /** * Invoke options for LLM call */ export declare interface InvokeOptions { /** * Force LLM to call a specific tool by name. * If provided: tool_choice = { type: 'function', function: { name: toolChoiceName } } * If not provided: tool_choice = 'required' (must call some tool, but model chooses which) */ toolChoiceName?: string; /** * Response normalization function. * Called before parsing the response. * Used to fix various response format errors from the model. */ normalizeResponse?: (response: any) => any; } /** * Invoke result (strict typing, supports generics) */ export declare interface InvokeResult { toolCall: { name: string; args: any; }; toolResult: TResult; usage: { promptTokens: number; completionTokens: number; totalTokens: number; cachedTokens?: number; reasoningTokens?: number; }; rawResponse?: unknown; rawRequest?: unknown; } export declare class LLM extends EventTarget { config: Required; client: LLMClient; constructor(config: LLMConfig); /** * - call llm api *once* * - invoke tool call *once* * - return the result of the tool */ invoke(messages: Message[], tools: Record, abortSignal: AbortSignal, options?: InvokeOptions): Promise; } /** * LLM Client interface * Note: Does not use generics because each tool in the tools array has different types */ export declare interface LLMClient { invoke(messages: Message[], tools: Record, abortSignal?: AbortSignal, options?: InvokeOptions): Promise; } /** * LLM configuration */ export declare interface LLMConfig { baseURL: string; model: string; apiKey?: string; temperature?: number; maxRetries?: number; /** * Transform the final request body before sending it to the provider. * Use this to implement provider-specific request tweaks such as caching hints or custom flags. * * Return a new object, or mutate the input object and return undefined. */ transformRequestBody?: (requestBody: Record) => Record | undefined; /** * remove the tool_choice field from the request. * @note fix "Invalid tool_choice type: 'object'" for some LLMs. */ disableNamedToolChoice?: boolean; /** * Custom fetch function for LLM API requests. * Use this to customize headers, credentials, proxy, etc. * The response should follow OpenAI API format. */ customFetch?: typeof globalThis.fetch; } /** * Message format - OpenAI standard (industry standard) */ export declare interface Message { role: 'system' | 'user' | 'assistant' | 'tool'; content?: string | null; tool_calls?: { id: string; type: 'function'; function: { name: string; arguments: string; }; }[]; tool_call_id?: string; name?: string; } export declare function parseLLMConfig(config: LLMConfig): Required; /** * Tool definition - uses Zod schema (LLM-agnostic) * Supports generics for type-safe parameters and return values */ export declare interface Tool { description?: string; inputSchema: z.ZodType; execute: (args: TParams) => Promise; } export { }