import { A as ToolResultMessage, C as TextContent, E as ThinkingLevel, M as Usage, N as UserMessage, O as Tool, S as StreamOptions, T as ThinkingContent, _ as ProviderStreamOptions, a as AssistantMessageEventStreamContract, c as Context, d as Message, f as Model, g as ProviderResponse, i as AssistantMessageEvent, k as ToolCall, l as ImageContent, n as Api, o as CacheRetention, p as ModelThinkingLevel, r as AssistantMessage, v as SimpleStreamOptions, w as ThinkingBudgets, x as StreamFunction, y as StopReason } from "./types-CZAevFX5.js"; import { a as createAssistantMessageEventStream, n as validateToolCall, r as AssistantMessageEventStream, t as validateToolArguments } from "./index-D3HJMhgl.js"; import { a as streamSimple, i as stream, n as complete, r as completeSimple, t as getEnvApiKey } from "./stream-DRio68UP.js"; import { Agent } from "node:http"; import { Agent as Agent$1 } from "node:https"; //#region packages/llm-runtime/src/api-registry.d.ts /** Runtime stream adapter signature stored in the API provider registry. */ type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract; /** Runtime simple-stream adapter signature stored in the API provider registry. */ type ApiStreamSimpleFunction = (model: Model, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStreamContract; /** Provider implementation registered by core or plugins for a specific model API. */ interface ApiProvider { /** Model API id this provider handles. */ api: TApi; /** Full streaming adapter for callers that already own structured options. */ stream: StreamFunction; /** Simple streaming adapter used by agent and plugin runtime defaults. */ streamSimple: StreamFunction; } interface ApiProviderInternal { api: Api; stream: ApiStreamFunction; streamSimple: ApiStreamSimpleFunction; } /** Registers or replaces the provider implementation for an API id. */ declare function registerApiProvider(provider: ApiProvider, /** Optional source id used to unregister all providers owned by one plugin/runtime. */ sourceId?: string): void; /** Looks up a registered API provider by API id. */ declare function getApiProvider(api: Api): ApiProviderInternal | undefined; /** Lists all currently registered API providers. */ declare function getApiProviders(): ApiProviderInternal[]; /** Removes all providers registered by a plugin/source id. */ declare function unregisterApiProviders(sourceId: string): void; //#endregion //#region src/llm/model-utils.d.ts /** Calculates and stores model cost fields from token usage and per-million pricing. */ declare function calculateCost(model: Model, usage: Usage): Usage["cost"]; /** Clamps a requested thinking level to the closest supported level for a model. */ declare function clampThinkingLevel(model: Model, level: ModelThinkingLevel): ModelThinkingLevel; //#endregion //#region src/llm/providers/simple-options.d.ts declare function buildBaseOptions(model: Model, options?: SimpleStreamOptions, apiKey?: string): StreamOptions; declare function clampReasoning(effort: ThinkingLevel | undefined): Exclude | undefined; declare function adjustMaxTokensForThinking(baseMaxTokens: number | undefined, modelMaxTokens: number, reasoningLevel: ThinkingLevel, customBudgets?: ThinkingBudgets): { maxTokens: number; thinkingBudget: number; }; //#endregion //#region src/llm/providers/transform-messages.d.ts /** * Normalize tool call ID for cross-provider compatibility. * OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`. * Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars). */ declare function transformMessages(messages: Message[], model: Model, normalizeToolCallId?: (id: string, model: Model, source: AssistantMessage) => string): Message[]; //#endregion //#region src/llm/utils/json-parse.d.ts /** * Attempts to parse potentially incomplete JSON during streaming. * Always returns a valid object, even if the JSON is incomplete. * * @param partialJson The partial JSON string from streaming * @returns Parsed object or empty object if parsing fails */ declare function parseStreamingJson(partialJson: string | undefined): Record; //#endregion //#region src/llm/utils/node-http-proxy.d.ts /** HTTP(S) agent pair for Node fetch/client integrations that accept explicit agents. */ interface NodeHttpProxyAgents { httpAgent: Agent; httpsAgent: Agent$1; } /** Builds fixed HTTP and HTTPS proxy agents for a target URL, when env proxy config applies. */ declare function createHttpProxyAgentsForTarget(targetUrl: string | URL): NodeHttpProxyAgents | undefined; //#endregion //#region src/llm/utils/sanitize-unicode.d.ts /** * Removes unpaired Unicode surrogate characters from a string. * * Unpaired surrogates (high surrogates 0xD800-0xDBFF without matching low surrogates 0xDC00-0xDFFF, * or vice versa) cause JSON serialization errors in many API providers. * * Valid emoji and other characters outside the Basic Multilingual Plane use properly paired * surrogates and will NOT be affected by this function. * * @param text - The text to sanitize * @returns The sanitized text with unpaired surrogates removed * * @example * // Valid emoji (properly paired surrogates) are preserved * sanitizeSurrogates("Hello 🙈 World") // => "Hello 🙈 World" * * // Unpaired high surrogate is removed * const unpaired = String.fromCharCode(0xD83D); // high surrogate without low * sanitizeSurrogates(`Text ${unpaired} here`) // => "Text here" */ declare function sanitizeSurrogates(text: string): string; //#endregion export { type Api, type ApiProvider, type AssistantMessage, type AssistantMessageEvent, AssistantMessageEventStream, type AssistantMessageEventStreamContract, type CacheRetention, type Context, type ImageContent, type Message, type Model, type ModelThinkingLevel, type ProviderResponse, type ProviderStreamOptions, type SimpleStreamOptions, type StopReason, type StreamFunction, type StreamOptions, type TextContent, type ThinkingBudgets, type ThinkingContent, type ThinkingLevel, type Tool, type ToolCall, type ToolResultMessage, type Usage, type UserMessage, adjustMaxTokensForThinking, buildBaseOptions, calculateCost, clampReasoning, clampThinkingLevel, complete, completeSimple, createAssistantMessageEventStream, createHttpProxyAgentsForTarget, getApiProvider, getApiProviders, getEnvApiKey, parseStreamingJson, registerApiProvider, sanitizeSurrogates, stream, streamSimple, transformMessages, unregisterApiProviders, validateToolArguments, validateToolCall };