/** * Tool Name Mapper * * Bidirectional mapping class to track original ↔ sanitized tool names. * Used to restore original names in API responses after sanitization. * * Flow: * 1. Request: registerTools() sanitizes names and stores mapping * 2. Response: restoreToolUse() restores original names using mapping */ /** MCP tool definition from Claude API */ export interface Tool { name: string; description?: string; input_schema?: Record; [key: string]: unknown; } /** Tool use content block from Claude API response */ export interface ToolUseBlock { type: 'tool_use'; id: string; name: string; input: Record; } /** Content block from Claude API response (union type) */ export interface ContentBlock { type: string; [key: string]: unknown; } /** Record of a sanitization change */ export interface SanitizationChange { original: string; sanitized: string; } /** Record of a hash collision */ export interface HashCollision { sanitized: string; originals: string[]; } /** * Bidirectional mapper for tool name sanitization. * * Maintains a per-request mapping between sanitized and original tool names. * Must be cleared between requests to avoid memory leaks. */ export declare class ToolNameMapper { /** Map from sanitized name → original name */ private mapping; /** List of all changes made during registration */ private changes; /** List of detected hash collisions */ private collisions; /** * Register tools and sanitize their names. * Stores mapping for later restoration. * * @param tools Array of tool definitions * @returns Array of tools with sanitized names */ registerTools(tools: Tool[]): Tool[]; /** * Restore original tool names in content blocks. * Looks for tool_use blocks and restores their names. * * @param content Array of content blocks from API response * @returns Array with restored tool names */ restoreToolUse(content: ContentBlock[]): ContentBlock[]; /** * Restore tool name in a single tool_use block. * Useful for streaming responses. * * @param name The sanitized tool name * @returns Original name if mapped, otherwise the input name */ restoreName(name: string): string; /** * Check if any sanitization occurred during registration. */ hasChanges(): boolean; /** * Get all sanitization changes for logging. */ getChanges(): SanitizationChange[]; /** * Get the number of tools that were sanitized. */ getChangeCount(): number; /** * Check if any hash collisions were detected. * Collisions occur when multiple original names map to the same sanitized name. */ hasCollisions(): boolean; /** * Get all detected hash collisions for logging/warning. */ getCollisions(): HashCollision[]; /** * Clear all mappings. Call between requests. */ clear(): void; } //# sourceMappingURL=tool-name-mapper.d.ts.map