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

100 lines (99 loc) 3.36 kB
/** * Tools Manager Module * * Handles all tool registration, discovery, and execution for AI providers. * Extracted from BaseProvider to follow Single Responsibility Principle. * * Responsibilities: * - Tool registration (direct, custom, MCP, external MCP) * - Tool discovery and aggregation * - Tool creation from definitions and schemas * - Tool executor setup * - Session context management for MCP tools * - Event emission wrapping for tool execution * * @module core/modules/ToolsManager */ import type { Tool } from "ai"; import type { AIProviderName, ToolUtilities } from "../../types/index.js"; import type { NeuroLink } from "../../neurolink.js"; /** * ToolsManager class - Handles all tool management operations */ export declare class ToolsManager { private readonly providerName; private readonly directTools; private readonly neurolink?; private readonly utilities?; protected mcpTools?: Record<string, Tool>; protected customTools?: Map<string, unknown>; protected toolExecutor?: (toolName: string, params: unknown, options?: Record<string, unknown>) => Promise<unknown>; protected sessionId?: string; protected userId?: string; constructor(providerName: AIProviderName, directTools: Record<string, unknown>, neurolink?: NeuroLink | undefined, utilities?: ToolUtilities | undefined); /** * BZ-666: Wrap tool execute with output truncation to prevent * context overflow when large results flow into the AI SDK accumulator. */ private wrapExecuteWithTruncation; /** * BZ-666: Apply generateToolOutputPreview to tool results to prevent * context overflow when large results flow into the AI SDK accumulator. */ private truncateToolResult; /** * Set session context for MCP tools */ setSessionContext(sessionId?: string, userId?: string): void; private emitToolEvent; /** * Set up tool executor for a provider to enable actual tool execution * @param sdk - The NeuroLinkSDK instance for tool execution * @param functionTag - Function name for logging */ setupToolExecutor(sdk: { customTools: Map<string, unknown>; executeTool: (toolName: string, params: unknown) => Promise<unknown>; }, functionTag: string): void; /** * Get all available tools - direct tools are ALWAYS available * MCP tools are added when available (without blocking) */ getAllTools(): Promise<Record<string, Tool>>; /** * Get direct tools (built-in agent tools) */ getDirectTools(): Record<string, unknown>; /** * Get MCP tools */ getMCPTools(): Record<string, Tool> | undefined; /** * Get custom tools */ getCustomTools(): Map<string, unknown> | undefined; /** * Process direct tools with event emission wrapping */ private processDirectTools; /** * Process custom tools from setupToolExecutor */ private processCustomTools; /** * Process MCP tools integration */ private processMCPTools; /** * Process external MCP tools */ private processExternalMCPTools; /** * Create a custom tool from tool definition */ private createCustomToolFromDefinition; /** * Create an external MCP tool */ private createExternalMCPTool; }