import { C as ThinkingBudgets, D as Tool, M as UserMessage, O as ToolCall, S as TextContent, T as ThinkingLevel, _ as SimpleStreamOptions, a as AssistantMessageEventStreamContract, b as StreamFunction, c as Context, d as Model, f as ModelThinkingLevel, g as ProviderStreamOptions, h as ProviderResponse, i as AssistantMessageEvent, j as Usage, k as ToolResultMessage, l as ImageContent, n as Api, o as CacheRetention, r as AssistantMessage, u as Message, v as StopReason, w as ThinkingContent, x as StreamOptions } from "./types-D7a857tt.js";
import { a as createAssistantMessageEventStream, n as validateToolCall, r as AssistantMessageEventStream, t as validateToolArguments } from "./index-DZRrGkqL.js";
import { a as streamSimple, i as stream, n as complete, r as completeSimple, t as getEnvApiKey } from "./stream-Bk_N19pz.js";
import { Agent } from "node:http";
import { Agent as Agent$1 } from "node:https";

//#region packages/llm-runtime/src/api-registry.d.ts
type ApiStreamFunction = (model: Model, context: Context, options?: StreamOptions) => AssistantMessageEventStreamContract;
type ApiStreamSimpleFunction = (model: Model, context: Context, options?: SimpleStreamOptions) => AssistantMessageEventStreamContract;
interface ApiProvider<TApi extends Api = Api, TOptions extends StreamOptions = StreamOptions> {
  api: TApi;
  stream: StreamFunction<TApi, TOptions>;
  streamSimple: StreamFunction<TApi, SimpleStreamOptions>;
}
interface ApiProviderInternal {
  api: Api;
  stream: ApiStreamFunction;
  streamSimple: ApiStreamSimpleFunction;
}
declare function registerApiProvider<TApi extends Api, TOptions extends StreamOptions>(provider: ApiProvider<TApi, TOptions>, sourceId?: string): void;
declare function getApiProvider(api: Api): ApiProviderInternal | undefined;
declare function getApiProviders(): ApiProviderInternal[];
declare function unregisterApiProviders(sourceId: string): void;
//#endregion
//#region src/llm/model-utils.d.ts
declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
declare function clampThinkingLevel<TApi extends Api>(model: Model<TApi>, 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<ThinkingLevel, "xhigh"> | 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<TApi extends Api>(messages: Message[], model: Model<TApi>, normalizeToolCallId?: (id: string, model: Model<TApi>, 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<string, unknown>;
//#endregion
//#region src/llm/utils/node-http-proxy.d.ts
interface NodeHttpProxyAgents {
  httpAgent: Agent;
  httpsAgent: Agent$1;
}
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 };