{"version":3,"sources":["/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-GZTNUK3B.cjs","../../src/modules/models/base.model.ts"],"names":[],"mappings":"AAAA;AC2CO,IAAe,UAAA,EAAf,MAAoD;AAmG3D,CAAA;AD3IA;AACA;AACE;AACF,8BAAC","file":"/Users/shyun/comcom/ain-enterprise/ain-adk/dist/cjs/chunk-GZTNUK3B.cjs","sourcesContent":[null,"import type { ConnectorTool, FetchResponse } from \"@/types/connector.js\";\nimport type { ThreadObject } from \"@/types/memory.js\";\nimport type { AssembledToolCall, LLMStream } from \"@/types/stream.js\";\n\nexport type ModelFetchOptions = {\n\treasoning?: \"none\" | \"minimal\" | \"low\" | \"medium\" | \"high\";\n\tverbosity?: \"low\" | \"medium\" | \"high\";\n\ttoolChoice?: \"auto\" | \"required\";\n};\n\n/**\n * Arguments for {@link BaseModel.appendAssistantToolCallTurn}.\n */\nexport interface AssistantToolCallTurn {\n\t/** Text the assistant streamed in the same turn as the tool calls, or null. */\n\tcontent: string | null;\n\t/** Tool calls assembled from the stream. Must preserve provider-issued ids. */\n\ttoolCalls: AssembledToolCall[];\n}\n\n/**\n * Arguments for {@link BaseModel.appendToolResult}.\n */\nexport interface ToolResultMessage {\n\t/** Matches the `id` of the corresponding {@link AssembledToolCall}. */\n\ttoolCallId: string;\n\ttoolName: string;\n\t/** Stringified result; providers wrap it in their native shape. */\n\tcontent: string;\n\t/** When true, the result represents a failure (skipped/error/invalid args). */\n\tisError?: boolean;\n}\n\n/**\n * Abstract base class for AI model implementations.\n *\n * Provides a common interface for different AI model providers (OpenAI, Gemini, etc.)\n * to integrate with the AIN-ADK framework. Each model implementation must handle\n * message formatting, tool conversion, and API communication.\n *\n * @typeParam MessageType - The message format used by the specific model API\n * @typeParam FunctionType - The function/tool format used by the specific model API\n */\nexport abstract class BaseModel<MessageType, FunctionType> {\n\t/**\n\t * Generates an array of messages from thread and current query.\n\t *\n\t * @param query - Current user query\n\t * @param thread - Previous conversation history\n\t * @param systemPrompt - Optional system prompt to set context\n\t * @returns Array of messages formatted for the specific model API\n\t */\n\tabstract generateMessages(params: {\n\t\tquery: string;\n\t\tthread?: ThreadObject;\n\t\tsystemPrompt?: string;\n\t}): MessageType[];\n\n\t/**\n\t * Appends the assistant's tool-call turn to the message history.\n\t *\n\t * Called by `ToolCallingService` immediately after the streamed assistant\n\t * response is fully assembled and contains one or more tool calls, and\n\t * before the corresponding tool results are pushed.\n\t *\n\t * Each provider must translate the input into the shape its own protocol\n\t * expects (e.g. OpenAI/Azure: `{role:\"assistant\", content, tool_calls}`,\n\t * Gemini: `{role:\"model\", parts:[..., {functionCall}]}`).\n\t *\n\t * @param messages - Existing message array to mutate\n\t * @param turn - Assembled assistant turn (content + tool calls)\n\t */\n\tabstract appendAssistantToolCallTurn(\n\t\tmessages: MessageType[],\n\t\tturn: AssistantToolCallTurn,\n\t): void;\n\n\t/**\n\t * Appends a single tool's result to the message history.\n\t *\n\t * Must be called once per `toolCallId` that appeared in the most recent\n\t * {@link appendAssistantToolCallTurn} — including cases where the tool was\n\t * skipped (unknown name, invalid arguments, etc.). Providers that enforce\n\t * matched tool_calls/tool_results pairs (e.g. OpenAI/Azure) will return a\n\t * 400 on the next request if this invariant is violated.\n\t *\n\t * @param messages - Existing message array to mutate\n\t * @param result - Tool execution result keyed by `toolCallId`\n\t */\n\tabstract appendToolResult(\n\t\tmessages: MessageType[],\n\t\tresult: ToolResultMessage,\n\t): void;\n\n\t/**\n\t * Converts protocol-agnostic tools to model-specific function format.\n\t *\n\t * @param tools - Array of agent tools from MCP or A2A sources\n\t * @returns Array of functions in the format required by the model API\n\t */\n\tabstract convertToolsToFunctions(tools: ConnectorTool[]): FunctionType[];\n\n\t/**\n\t * Fetches a response from the model API without tool support.\n\t *\n\t * @param messages - Array of messages to send to the model\n\t * @returns Promise resolving to the model's response\n\t */\n\tabstract fetch(\n\t\tmessages: MessageType[],\n\t\toptions?: ModelFetchOptions,\n\t): Promise<FetchResponse>;\n\n\t/**\n\t * Fetches a response from the model API with tool/function support.\n\t *\n\t * @param messages - Array of messages to send to the model\n\t * @param functions - Array of available functions/tools the model can call\n\t * @returns Promise resolving to the model's response, possibly including tool calls\n\t */\n\tabstract fetchWithContextMessage(\n\t\tmessages: MessageType[],\n\t\tfunctions: FunctionType[],\n\t\toptions?: ModelFetchOptions,\n\t): Promise<FetchResponse>;\n\n\t/**\n\t * Fetches a streaming response from the model API with tool/function support.\n\t *\n\t * Returns a standardized LLMStream that can be used consistently across\n\t * different AI model providers. Each implementation should convert their\n\t * provider-specific stream format to the common StreamChunk interface.\n\t *\n\t * @param messages - Array of messages to send to the model\n\t * @param functions - Array of available functions/tools the model can call\n\t * @returns Promise resolving to an LLMStream for consistent iteration\n\t */\n\tabstract fetchStreamWithContextMessage(\n\t\tmessages: MessageType[],\n\t\tfunctions: FunctionType[],\n\t\toptions?: ModelFetchOptions,\n\t): Promise<LLMStream>;\n}\n"]}