UNPKG

@juspay/neurolink

Version:

Universal AI Development Platform with working MCP integration, multi-provider support, voice (TTS/STT/realtime), and professional CLI. 58+ external MCP servers discoverable, multimodal file processing, RAG pipelines. Build, test, and deploy AI applicatio

152 lines (151 loc) 5.19 kB
/** * MCP Tool Registry - Extended Registry with Tool Management * Updated to match industry standard camelCase interfaces */ import type { MCPServerInfo, ToolImplementation, ToolInfo, ExecutionContext, HITLManager } from "../types/index.js"; import { MCPRegistry } from "./registry.js"; export declare class MCPToolRegistry extends MCPRegistry { private tools; private toolImplementations; private toolExecutionStats; private builtInServerInfos; private hitlManager?; constructor(); /** * Set HITL manager for human-in-the-loop safety mechanisms * @param hitlManager - HITL manager instance (optional, can be undefined to disable) */ setHITLManager(hitlManager?: HITLManager): void; /** * Get current HITL manager */ getHITLManager(): HITLManager | undefined; /** * Register all direct tools from directAgentTools */ private registerDirectTools; /** * Register a server with its tools - ONLY accepts MCPServerInfo (zero conversions) */ registerServer(serverInfo: MCPServerInfo, context?: ExecutionContext): Promise<void>; registerServer(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>; /** * Execute a tool with enhanced context and automatic result wrapping * * This method handles both raw return values and ToolResult objects: * - Raw values (primitives, objects) are automatically wrapped in ToolResult format * - Existing ToolResult objects are enhanced with execution metadata * - All results include execution timing and context information * * @param toolName - Name of the tool to execute * @param args - Parameters to pass to the tool execution function * @param context - Execution context with session, user, and environment info * @returns Promise resolving to ToolResult object with data, metadata, and usage info * @throws Error if tool is not found or execution fails * * @example * ```typescript * // Tool that returns raw value * const result = await toolRegistry.executeTool("calculator", { a: 5, b: 3, op: "add" }); * // result.data === 8, result.metadata contains execution info * * // Tool that returns ToolResult * const result = await toolRegistry.executeTool("complexTool", { input: "test" }); * // result is enhanced ToolResult with additional metadata * ``` */ executeTool<T = unknown>(toolName: string, args?: unknown, context?: ExecutionContext): Promise<T>; /** * List all available tools (updated signature with filtering) */ listTools(): Promise<ToolInfo[]>; listTools(context: ExecutionContext): Promise<ToolInfo[]>; listTools(filter: { category?: string; serverId?: string; serverCategory?: string; permissions?: string[]; context?: ExecutionContext; }): Promise<ToolInfo[]>; private resolveToolExecutionTarget; private createExecutionContext; /** * Get tool information with server details */ getToolInfo(toolName: string): { tool: ToolInfo; server: { id: string; }; } | undefined; /** * Update execution statistics */ private updateStats; /** * Get execution statistics */ getExecutionStats(): Record<string, { count: number; averageTime: number; totalTime: number; }>; /** * Clear execution statistics */ clearStats(): void; /** * Get built-in servers * @returns Array of MCPServerInfo for built-in tools */ getBuiltInServerInfos(): MCPServerInfo[]; /** * Get tools by category */ getToolsByCategory(category: string): ToolInfo[]; /** * NL-001: Get available tools, filtering out those with OPEN circuit breakers. * Returns both the filtered tools and the list of unavailable tool names. */ getAvailableTools(circuitBreakers: Map<string, import("../utils/errorHandling.js").CircuitBreaker>): { tools: ToolInfo[]; unavailableTools: string[]; }; /** * Check if tool exists */ hasTool(toolName: string): boolean; /** * Register a tool with implementation directly * This is used for external MCP server tools */ registerTool(toolId: string, toolInfo: ToolInfo, toolImpl: ToolImplementation): Promise<void>; /** * Remove a tool */ removeTool(toolName: string): boolean; /** * Get tool count */ getToolCount(): number; /** * Get comprehensive statistics */ getStats(): { totalServers: number; totalTools: number; serversByCategory: Record<string, number>; toolsByCategory: Record<string, number>; executionStats: Record<string, { count: number; averageTime: number; totalTime: number; }>; }; /** * Unregister a server */ unregisterServer(serverId: string): boolean; } export declare const toolRegistry: MCPToolRegistry; export declare const defaultToolRegistry: MCPToolRegistry;