UNPKG

@nanocollective/nanocoder

Version:

A local-first CLI coding agent that brings the power of agentic coding tools like Claude Code and Gemini CLI to local models or controlled APIs like OpenRouter

56 lines 2.08 kB
import type { ToolCall } from '../types/index.js'; interface ParsedToolCall { toolName: string; parameters: Record<string, unknown>; } /** * Parses XML-formatted tool calls from non-function-calling models * Expected format: <tool_name><param1>value1</param1><param2>value2</param2></tool_name> */ export declare class XMLToolCallParser { private static readonly TOOL_CALL_REGEX; private static readonly PARAMETER_REGEX; /** * Extracts tool calls from text content containing XML-formatted tool calls * Type-preserving: Accepts unknown type, converts to string for processing */ static parseToolCalls(content: unknown): ParsedToolCall[]; /** * Validates that a matched string is a proper tool call * Rejects partial matches, malformed syntax, and invalid structures */ private static isValidToolCall; /** * Parses parameters from inner XML content */ private static parseParameters; /** * Converts parsed tool calls to the standard ToolCall format */ static convertToToolCalls(parsedCalls: ParsedToolCall[]): ToolCall[]; /** * Removes XML tool call blocks from content, leaving only the text * Type-preserving: Accepts unknown type, converts to string for processing */ static removeToolCallsFromContent(content: unknown): string; /** * Checks if content contains XML-formatted tool calls * Type-preserving: Accepts unknown type, converts to string for processing */ static hasToolCalls(content: unknown): boolean; /** * Detects malformed XML tool call attempts and returns error details * Returns null if no malformed tool calls detected * Type-preserving: Accepts unknown type, converts to string for processing */ static detectMalformedToolCall(content: unknown): { error: string; examples: string; } | null; /** * Generates correct format examples for error messages */ private static getCorrectFormatExamples; } export {}; //# sourceMappingURL=xml-parser.d.ts.map