import { ToolCallRequest } from '@quilltap/plugin-types'; export { AnthropicToolDefinition, GoogleToolDefinition, OpenAIToolDefinition, ToolCall, ToolCallRequest, ToolFormatOptions, ToolResult, UniversalTool } from '@quilltap/plugin-types'; export { T as ToolCallFormat, a as ToolConvertTarget, b as applyDescriptionLimit, c as convertFromAnthropicFormat, d as convertFromGoogleFormat, e as convertOpenAIToAnthropicFormat, f as convertOpenAIToGoogleFormat, g as convertToAnthropicFormat, h as convertToGoogleFormat, i as convertToolTo, j as convertToolsTo, k as detectToolCallFormat, l as hasToolCalls, p as parseAnthropicToolCalls, m as parseGoogleToolCalls, n as parseOpenAIToolCalls, o as parseToolCalls } from '../converters-BPYo8xdH.mjs'; /** * Text-Based Tool Call Parsers * * Utility functions for parsing spontaneous XML-style tool calls from LLM * text responses. These are for models that emit tool-call-like markup in * their output instead of using native function calling APIs. * * Provider plugins import and compose these utilities to implement their * `hasTextToolMarkers`, `parseTextToolCalls`, and `stripTextToolMarkers` methods. * * @module @quilltap/plugin-utils/tools/text-parsers */ /** * Parsed text-based tool call from LLM output */ interface ParsedTextTool { /** The tool name */ toolName: string; /** Arguments extracted from the markup */ arguments: Record; /** The full matched markup text (for stripping) */ fullMatch: string; /** Start index in the original text */ startIndex: number; /** End index in the original text */ endIndex: number; /** Which format was detected */ format: 'deepseek' | 'claude' | 'generic' | 'function_call' | 'tool_use' | 'invoke'; } /** * Normalize a tool name from hallucinated markup to the canonical name. * Returns the original name if no alias is found (passes through unknown tools). */ declare function normalizeToolName(name: string): string; /** * Convert a ParsedTextTool to the standard ToolCallRequest format. * * For well-known tools, normalizes argument names (e.g., "search" → "query"). * For unknown tools, passes arguments through as-is. */ declare function convertToToolCallRequest(parsed: ParsedTextTool): ToolCallRequest; /** * Parse `` format (DeepSeek and Claude-style) */ declare function parseFunctionCallsFormat(response: string): ParsedTextTool[]; /** * Parse `` format (generic XML) */ declare function parseToolCallFormat(response: string): ParsedTextTool[]; /** * Parse `` format */ declare function parseFunctionCallFormat(response: string): ParsedTextTool[]; /** * Parse `` format (Gemini and others) * * Handles multiple sub-formats: * - Bare JSON: `{"name":"fn","input":{...}}` * - XML children: `fn...` * - JSON in arguments: `fn{"q":"v"}` * - Attributed: `...` */ declare function parseToolUseFormat(response: string): ParsedTextTool[]; /** * Parse bare `` format (Kimi K2 and similar models) * * Matches `` tags that appear WITHOUT a `` wrapper. * IMPORTANT: In composite parsing, this must run AFTER parseFunctionCallsFormat * so that wrapped invokes are claimed first and deduplicated by startIndex. */ declare function parseInvokeFormat(response: string): ParsedTextTool[]; /** * Parse all known XML tool call formats from response text. * Deduplicates by position and sorts by start index. * * Plugins can call this directly or compose individual format parsers * for provider-specific behavior. */ declare function parseAllXMLFormats(response: string): ParsedTextTool[]; /** * Convert parsed text tools to standard ToolCallRequest array. * Convenience wrapper for plugins implementing parseTextToolCalls. */ declare function parseAllXMLAsToolCalls(response: string): ToolCallRequest[]; /** * Check if text contains any of the known XML tool call patterns. * Quick regex check before full parsing. */ declare function hasAnyXMLToolMarkers(response: string): boolean; /** Check for `` markers (DeepSeek/Claude-style) */ declare function hasFunctionCallsMarkers(response: string): boolean; /** Check for `` markers (generic) */ declare function hasToolCallMarkers(response: string): boolean; /** Check for `` markers */ declare function hasFunctionCallMarkers(response: string): boolean; /** Check for `` markers (Gemini-style) */ declare function hasToolUseMarkers(response: string): boolean; /** Check for bare `` markers (Kimi K2-style) */ declare function hasInvokeMarkers(response: string): boolean; /** * Strip all known XML tool call markers from text. * Cleans up whitespace left behind. */ declare function stripAllXMLToolMarkers(response: string): string; /** Strip `` blocks */ declare function stripFunctionCallsMarkers(response: string): string; /** Strip `` blocks */ declare function stripToolCallMarkers(response: string): string; /** Strip `` blocks */ declare function stripFunctionCallMarkers(response: string): string; /** Strip `` blocks */ declare function stripToolUseMarkers(response: string): string; /** Strip bare `` blocks (Kimi K2-style) */ declare function stripInvokeMarkers(response: string): string; export { type ParsedTextTool, convertToToolCallRequest as convertTextToolToRequest, hasAnyXMLToolMarkers, hasFunctionCallMarkers, hasFunctionCallsMarkers, hasInvokeMarkers, hasToolCallMarkers, hasToolUseMarkers, normalizeToolName, parseAllXMLAsToolCalls, parseAllXMLFormats, parseFunctionCallFormat, parseFunctionCallsFormat, parseInvokeFormat, parseToolCallFormat, parseToolUseFormat, stripAllXMLToolMarkers, stripFunctionCallMarkers, stripFunctionCallsMarkers, stripInvokeMarkers, stripToolCallMarkers, stripToolUseMarkers };