/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ /** * Copyright 2025 Vybestack LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { type IToolFormatter, type ToolFormat, type OpenAITool, type ResponsesTool } from './IToolFormatter.js'; import { type ITool } from '../providers/ITool.js'; import { type ToolCallBlock } from '../services/history/IContent.js'; export declare class ToolFormatter implements IToolFormatter { private logger; /** * Convert Gemini format tools directly to OpenAI format * @param geminiTools Tools in Gemini format with functionDeclarations * @returns Tools in OpenAI format with type: "function" wrapper */ convertGeminiToOpenAI(geminiTools?: Array<{ functionDeclarations: Array<{ name: string; description?: string; parametersJsonSchema?: unknown; }>; }>): Array<{ type: 'function'; function: { name: string; description: string; parameters: Record; }; }> | undefined; /** * Convert Gemini format tools directly to Anthropic format * @param geminiTools Tools in Gemini format with functionDeclarations * @returns Tools in Anthropic format with input_schema */ convertGeminiToAnthropic(geminiTools?: Array<{ functionDeclarations: Array<{ name: string; description?: string; parametersJsonSchema?: unknown; }>; }>): Array<{ name: string; description: string; input_schema: { type: 'object'; [key: string]: unknown; }; }> | undefined; /** * Convert Gemini format tools to the specified provider format * @param geminiTools Tools in Gemini format with functionDeclarations * @param format The target format to convert to * @returns Tools in the specified provider format */ convertGeminiToFormat(geminiTools?: Array<{ functionDeclarations: Array<{ name: string; description?: string; parametersJsonSchema?: unknown; }>; }>, format?: ToolFormat): unknown; /** * Converts Gemini schema format (with uppercase Type enums) to standard JSON Schema format */ convertGeminiSchemaToStandard(schema: unknown): unknown; toProviderFormat(tools: ITool[], format: 'openai'): OpenAITool[]; toProviderFormat(tools: ITool[], format: ToolFormat): unknown; fromProviderFormat(rawToolCall: unknown, format: ToolFormat): ToolCallBlock[]; /** * Handles streaming tool call accumulation for OpenAI-compatible providers * This accumulates partial tool calls from streaming responses */ accumulateStreamingToolCall(deltaToolCall: { index?: number; id?: string; type?: string; function?: { name?: string; arguments?: string; }; }, accumulatedToolCalls: ToolCallBlock[], format: ToolFormat): void; /** * Formats tools specifically for the OpenAI Responses API * The Responses API expects a flatter format than the regular OpenAI API */ toResponsesTool(tools: ITool[]): ResponsesTool[]; }