@juspay/neurolink 7.13.0 → 7.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +89 -25
- package/dist/agent/directTools.d.ts +3 -3
- package/dist/agent/directTools.js +1 -1
- package/dist/cli/commands/mcp.js +67 -207
- package/dist/cli/factories/commandFactory.js +7 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/config/conversationMemoryConfig.js +2 -1
- package/dist/context/ContextManager.js +15 -4
- package/dist/context/config.js +5 -1
- package/dist/context/utils.js +1 -1
- package/dist/core/baseProvider.d.ts +11 -30
- package/dist/core/baseProvider.js +268 -42
- package/dist/core/conversationMemoryManager.js +3 -2
- package/dist/core/dynamicModels.d.ts +14 -14
- package/dist/core/dynamicModels.js +1 -1
- package/dist/core/evaluation.js +1 -1
- package/dist/core/factory.js +1 -1
- package/dist/factories/providerFactory.js +5 -11
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +5 -4
- package/dist/index.js +1 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/config/conversationMemoryConfig.js +2 -1
- package/dist/lib/context/ContextManager.js +15 -4
- package/dist/lib/context/config.js +5 -1
- package/dist/lib/context/utils.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +11 -30
- package/dist/lib/core/baseProvider.js +268 -42
- package/dist/lib/core/conversationMemoryManager.js +3 -2
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -1
- package/dist/lib/factories/providerFactory.js +5 -11
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +5 -4
- package/dist/lib/index.js +1 -1
- package/dist/lib/mcp/externalServerManager.d.ts +148 -0
- package/dist/lib/mcp/externalServerManager.js +1038 -0
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/lib/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/lib/mcp/mcpClientFactory.js +421 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/lib/mcp/toolDiscoveryService.js +646 -0
- package/dist/lib/mcp/toolRegistry.d.ts +15 -11
- package/dist/lib/mcp/toolRegistry.js +118 -55
- package/dist/lib/models/modelResolver.js +1 -1
- package/dist/lib/neurolink.d.ts +139 -43
- package/dist/lib/neurolink.js +604 -174
- package/dist/lib/providers/googleVertex.d.ts +7 -1
- package/dist/lib/providers/googleVertex.js +34 -7
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.js +3 -3
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +3 -2
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +2 -2
- package/dist/lib/providers/sagemaker/config.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +4 -13
- package/dist/lib/sdk/toolRegistration.js +19 -66
- package/dist/lib/types/cli.d.ts +0 -1
- package/dist/lib/types/cli.js +0 -1
- package/dist/lib/types/common.d.ts +1 -2
- package/dist/lib/types/common.js +0 -1
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/contextTypes.js +3 -3
- package/dist/lib/types/externalMcp.d.ts +288 -0
- package/dist/lib/types/externalMcp.js +7 -0
- package/dist/lib/types/generateTypes.d.ts +0 -1
- package/dist/lib/types/index.d.ts +2 -2
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/mcpTypes.d.ts +53 -99
- package/dist/lib/types/providers.d.ts +0 -1
- package/dist/lib/types/providers.js +0 -1
- package/dist/lib/types/tools.d.ts +2 -2
- package/dist/lib/types/tools.js +2 -2
- package/dist/lib/utils/factoryProcessing.js +1 -1
- package/dist/lib/utils/mcpDefaults.d.ts +54 -0
- package/dist/lib/utils/mcpDefaults.js +125 -0
- package/dist/lib/utils/providerConfig.d.ts +1 -1
- package/dist/lib/utils/providerConfig.js +2 -2
- package/dist/lib/utils/providerHealth.js +6 -6
- package/dist/mcp/externalServerManager.d.ts +148 -0
- package/dist/mcp/externalServerManager.js +1038 -0
- package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/mcp/mcpClientFactory.d.ts +105 -0
- package/dist/mcp/mcpClientFactory.js +421 -0
- package/dist/mcp/toolDiscoveryService.d.ts +193 -0
- package/dist/mcp/toolDiscoveryService.js +646 -0
- package/dist/mcp/toolRegistry.d.ts +15 -11
- package/dist/mcp/toolRegistry.js +118 -55
- package/dist/models/modelResolver.js +1 -1
- package/dist/neurolink.d.ts +139 -43
- package/dist/neurolink.js +604 -174
- package/dist/providers/googleVertex.d.ts +7 -1
- package/dist/providers/googleVertex.js +34 -7
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.js +3 -3
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +3 -2
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +2 -2
- package/dist/providers/sagemaker/config.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +4 -13
- package/dist/sdk/toolRegistration.js +19 -66
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.js +0 -1
- package/dist/types/common.d.ts +1 -2
- package/dist/types/common.js +0 -1
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/contextTypes.js +3 -3
- package/dist/types/externalMcp.d.ts +288 -0
- package/dist/types/externalMcp.js +7 -0
- package/dist/types/generateTypes.d.ts +0 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/index.js +0 -1
- package/dist/types/mcpTypes.d.ts +53 -99
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/tools.d.ts +2 -2
- package/dist/types/tools.js +2 -2
- package/dist/utils/factoryProcessing.js +1 -1
- package/dist/utils/mcpDefaults.d.ts +54 -0
- package/dist/utils/mcpDefaults.js +125 -0
- package/dist/utils/providerConfig.d.ts +1 -1
- package/dist/utils/providerConfig.js +2 -2
- package/dist/utils/providerHealth.js +6 -6
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ExecutionContext, ToolInfo } from "./contracts/mcpContract.js";
|
|
6
6
|
import type { ToolResult } from "./factory.js";
|
|
7
|
+
import type { MCPServerInfo } from "../types/mcpTypes.js";
|
|
7
8
|
import { MCPRegistry } from "./registry.js";
|
|
8
9
|
interface ToolImplementation {
|
|
9
10
|
execute: (params: unknown, context?: ExecutionContext) => Promise<unknown> | unknown;
|
|
@@ -13,15 +14,6 @@ interface ToolImplementation {
|
|
|
13
14
|
category?: string;
|
|
14
15
|
permissions?: string[];
|
|
15
16
|
}
|
|
16
|
-
interface ServerRegistration {
|
|
17
|
-
id?: string;
|
|
18
|
-
serverId?: string;
|
|
19
|
-
description?: string;
|
|
20
|
-
title?: string;
|
|
21
|
-
category?: string;
|
|
22
|
-
tools?: Record<string, ToolImplementation>;
|
|
23
|
-
configuration?: Record<string, unknown>;
|
|
24
|
-
}
|
|
25
17
|
export type ToolExecutionResult = ToolResult;
|
|
26
18
|
/**
|
|
27
19
|
* Tool execution options
|
|
@@ -39,15 +31,17 @@ export declare class MCPToolRegistry extends MCPRegistry {
|
|
|
39
31
|
private tools;
|
|
40
32
|
private toolImpls;
|
|
41
33
|
private toolExecutionStats;
|
|
34
|
+
private builtInServerInfos;
|
|
42
35
|
constructor();
|
|
43
36
|
/**
|
|
44
37
|
* Register all direct tools from directAgentTools
|
|
45
38
|
*/
|
|
46
39
|
private registerDirectTools;
|
|
47
40
|
/**
|
|
48
|
-
* Register a server with its tools (
|
|
41
|
+
* Register a server with its tools - ONLY accepts MCPServerInfo (zero conversions)
|
|
49
42
|
*/
|
|
50
|
-
registerServer(
|
|
43
|
+
registerServer(serverInfo: MCPServerInfo, context?: ExecutionContext): Promise<void>;
|
|
44
|
+
registerServer(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
|
|
51
45
|
/**
|
|
52
46
|
* Execute a tool with enhanced context
|
|
53
47
|
*/
|
|
@@ -89,6 +83,11 @@ export declare class MCPToolRegistry extends MCPRegistry {
|
|
|
89
83
|
* Clear execution statistics
|
|
90
84
|
*/
|
|
91
85
|
clearStats(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Get built-in servers
|
|
88
|
+
* @returns Array of MCPServerInfo for built-in tools
|
|
89
|
+
*/
|
|
90
|
+
getBuiltInServerInfos(): MCPServerInfo[];
|
|
92
91
|
/**
|
|
93
92
|
* Get tools by category
|
|
94
93
|
*/
|
|
@@ -97,6 +96,11 @@ export declare class MCPToolRegistry extends MCPRegistry {
|
|
|
97
96
|
* Check if tool exists
|
|
98
97
|
*/
|
|
99
98
|
hasTool(toolName: string): boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Register a tool with implementation directly
|
|
101
|
+
* This is used for external MCP server tools
|
|
102
|
+
*/
|
|
103
|
+
registerTool(toolId: string, toolInfo: ToolInfo, toolImpl: ToolImplementation): void;
|
|
100
104
|
/**
|
|
101
105
|
* Remove a tool
|
|
102
106
|
*/
|
package/dist/mcp/toolRegistry.js
CHANGED
|
@@ -7,10 +7,12 @@ import { registryLogger } from "../utils/logger.js";
|
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
8
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
9
9
|
import { directAgentTools } from "../agent/directTools.js";
|
|
10
|
+
import { detectCategory, createMCPServerInfo } from "../utils/mcpDefaults.js";
|
|
10
11
|
export class MCPToolRegistry extends MCPRegistry {
|
|
11
12
|
tools = new Map();
|
|
12
13
|
toolImpls = new Map(); // Store actual tool implementations
|
|
13
14
|
toolExecutionStats = new Map();
|
|
15
|
+
builtInServerInfos = []; // DIRECT storage for MCPServerInfo
|
|
14
16
|
constructor() {
|
|
15
17
|
super();
|
|
16
18
|
// 🔧 CONDITIONAL: Only auto-register direct tools if not disabled via configuration
|
|
@@ -33,7 +35,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
33
35
|
description: toolDef.description || `Direct tool: ${toolName}`,
|
|
34
36
|
inputSchema: {},
|
|
35
37
|
serverId: "direct",
|
|
36
|
-
category: "
|
|
38
|
+
category: detectCategory({ isBuiltIn: true, serverId: "direct" }),
|
|
37
39
|
};
|
|
38
40
|
this.tools.set(toolId, toolInfo);
|
|
39
41
|
this.toolImpls.set(toolId, {
|
|
@@ -75,69 +77,109 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
75
77
|
}
|
|
76
78
|
registryLogger.debug(`Auto-registered ${Object.keys(directAgentTools).length} direct tools`);
|
|
77
79
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
"No description"
|
|
94
|
-
: "No description",
|
|
95
|
-
},
|
|
96
|
-
tools: typeof serverConfig === "object" && serverConfig
|
|
97
|
-
? serverConfig.tools
|
|
98
|
-
: {},
|
|
99
|
-
configuration: typeof serverConfig === "object" && serverConfig
|
|
100
|
-
? serverConfig
|
|
101
|
-
: {},
|
|
102
|
-
};
|
|
80
|
+
async registerServer(serverInfoOrId, serverConfigOrContext, context) {
|
|
81
|
+
// Handle both signatures for backward compatibility
|
|
82
|
+
let serverInfo;
|
|
83
|
+
let finalContext;
|
|
84
|
+
if (typeof serverInfoOrId === "string") {
|
|
85
|
+
// Legacy signature: registerServer(serverId, serverConfig, context)
|
|
86
|
+
const serverId = serverInfoOrId;
|
|
87
|
+
finalContext = context;
|
|
88
|
+
// Convert legacy call to MCPServerInfo format using smart defaults
|
|
89
|
+
serverInfo = createMCPServerInfo({
|
|
90
|
+
id: serverId,
|
|
91
|
+
name: serverId,
|
|
92
|
+
tools: [],
|
|
93
|
+
isExternal: true,
|
|
94
|
+
});
|
|
103
95
|
}
|
|
104
96
|
else {
|
|
105
|
-
// New
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
97
|
+
// New signature: registerServer(serverInfo, context)
|
|
98
|
+
serverInfo = serverInfoOrId;
|
|
99
|
+
finalContext = serverConfigOrContext;
|
|
100
|
+
}
|
|
101
|
+
const serverId = serverInfo.id;
|
|
102
|
+
registryLogger.info(`Registering MCPServerInfo directly: ${serverId}`);
|
|
103
|
+
// Use MCPServerInfo.tools array directly - ZERO conversions!
|
|
104
|
+
const toolsObject = {};
|
|
105
|
+
for (const tool of serverInfo.tools) {
|
|
106
|
+
toolsObject[tool.name] = {
|
|
107
|
+
execute: tool.execute ||
|
|
108
|
+
(async () => {
|
|
109
|
+
throw new Error(`Tool ${tool.name} has no execute function`);
|
|
110
|
+
}),
|
|
111
|
+
description: tool.description,
|
|
112
|
+
inputSchema: tool.inputSchema,
|
|
113
|
+
category: detectCategory({
|
|
114
|
+
existingCategory: serverInfo.metadata?.category,
|
|
115
|
+
serverId: serverInfo.id,
|
|
116
|
+
}),
|
|
118
117
|
};
|
|
119
118
|
}
|
|
119
|
+
const plugin = {
|
|
120
|
+
metadata: {
|
|
121
|
+
name: serverInfo.name,
|
|
122
|
+
description: serverInfo.description,
|
|
123
|
+
category: detectCategory({
|
|
124
|
+
existingCategory: serverInfo.metadata?.category,
|
|
125
|
+
serverId: serverInfo.id,
|
|
126
|
+
}),
|
|
127
|
+
},
|
|
128
|
+
tools: toolsObject,
|
|
129
|
+
configuration: {},
|
|
130
|
+
};
|
|
120
131
|
// Call the parent register method
|
|
121
132
|
this.register(plugin);
|
|
122
|
-
//
|
|
123
|
-
const tools =
|
|
124
|
-
registryLogger.debug(`Registering ${
|
|
125
|
-
for (const
|
|
126
|
-
|
|
133
|
+
// Use MCPServerInfo.tools array directly - ZERO conversions!
|
|
134
|
+
const tools = serverInfo.tools;
|
|
135
|
+
registryLogger.debug(`Registering ${tools.length} tools for server ${serverId}:`, tools.map((t) => t.name));
|
|
136
|
+
for (const tool of tools) {
|
|
137
|
+
// For custom tools, use just the tool name to avoid redundant serverId.toolName format
|
|
138
|
+
// For other tools, use fully-qualified serverId.toolName to avoid collisions
|
|
139
|
+
const isCustomTool = serverId.startsWith("custom-tool-");
|
|
140
|
+
const toolId = isCustomTool ? tool.name : `${serverId}.${tool.name}`;
|
|
127
141
|
const toolInfo = {
|
|
128
|
-
name:
|
|
129
|
-
description:
|
|
130
|
-
inputSchema:
|
|
131
|
-
outputSchema:
|
|
142
|
+
name: tool.name,
|
|
143
|
+
description: tool.description,
|
|
144
|
+
inputSchema: tool.inputSchema,
|
|
145
|
+
outputSchema: undefined, // MCPServerInfo.tools doesn't have outputSchema
|
|
132
146
|
serverId,
|
|
133
|
-
category:
|
|
134
|
-
|
|
147
|
+
category: detectCategory({
|
|
148
|
+
existingCategory: serverInfo.metadata?.category,
|
|
149
|
+
serverId: serverInfo.id,
|
|
150
|
+
}),
|
|
151
|
+
permissions: [], // MCPServerInfo.tools doesn't have permissions
|
|
135
152
|
};
|
|
136
153
|
// Register only with fully-qualified toolId to avoid collisions
|
|
137
154
|
this.tools.set(toolId, toolInfo);
|
|
138
155
|
// Store the actual tool implementation for execution using toolId as key
|
|
139
|
-
this.toolImpls.set(toolId,
|
|
140
|
-
|
|
156
|
+
this.toolImpls.set(toolId, {
|
|
157
|
+
execute: tool.execute ||
|
|
158
|
+
(async () => {
|
|
159
|
+
throw new Error(`Tool ${tool.name} has no execute function`);
|
|
160
|
+
}),
|
|
161
|
+
description: tool.description,
|
|
162
|
+
inputSchema: tool.inputSchema,
|
|
163
|
+
category: detectCategory({
|
|
164
|
+
existingCategory: serverInfo.metadata?.category,
|
|
165
|
+
serverId: serverInfo.id,
|
|
166
|
+
}),
|
|
167
|
+
});
|
|
168
|
+
registryLogger.debug(`Registered tool '${tool.name}' with execute function:`, typeof tool.execute);
|
|
169
|
+
}
|
|
170
|
+
// Store MCPServerInfo directly - NO recreation needed!
|
|
171
|
+
if (tools.length > 0) {
|
|
172
|
+
const category = detectCategory({
|
|
173
|
+
existingCategory: serverInfo.metadata?.category,
|
|
174
|
+
serverId: serverInfo.id,
|
|
175
|
+
});
|
|
176
|
+
// Only store in builtInServerInfos if it's a real in-memory MCP server
|
|
177
|
+
// Do NOT create fake servers for built-in direct tools
|
|
178
|
+
if (category === "in-memory") {
|
|
179
|
+
// Use the original MCPServerInfo directly - ZERO conversions!
|
|
180
|
+
this.builtInServerInfos.push(serverInfo);
|
|
181
|
+
registryLogger.debug(`Added ${category} server to builtInServerInfos: ${serverId} with ${tools.length} tools`);
|
|
182
|
+
}
|
|
141
183
|
}
|
|
142
184
|
}
|
|
143
185
|
/**
|
|
@@ -323,6 +365,13 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
323
365
|
clearStats() {
|
|
324
366
|
this.toolExecutionStats.clear();
|
|
325
367
|
}
|
|
368
|
+
/**
|
|
369
|
+
* Get built-in servers
|
|
370
|
+
* @returns Array of MCPServerInfo for built-in tools
|
|
371
|
+
*/
|
|
372
|
+
getBuiltInServerInfos() {
|
|
373
|
+
return this.builtInServerInfos;
|
|
374
|
+
}
|
|
326
375
|
/**
|
|
327
376
|
* Get tools by category
|
|
328
377
|
*/
|
|
@@ -340,7 +389,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
340
389
|
* Check if tool exists
|
|
341
390
|
*/
|
|
342
391
|
hasTool(toolName) {
|
|
343
|
-
// Check by fully-qualified name first, then fallback to
|
|
392
|
+
// Check by fully-qualified name first, then fallback to first matching tool name
|
|
344
393
|
if (this.tools.has(toolName)) {
|
|
345
394
|
return true;
|
|
346
395
|
}
|
|
@@ -351,11 +400,21 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
351
400
|
}
|
|
352
401
|
return false;
|
|
353
402
|
}
|
|
403
|
+
/**
|
|
404
|
+
* Register a tool with implementation directly
|
|
405
|
+
* This is used for external MCP server tools
|
|
406
|
+
*/
|
|
407
|
+
registerTool(toolId, toolInfo, toolImpl) {
|
|
408
|
+
registryLogger.debug(`Registering tool: ${toolId}`);
|
|
409
|
+
this.tools.set(toolId, toolInfo);
|
|
410
|
+
this.toolImpls.set(toolId, toolImpl);
|
|
411
|
+
registryLogger.debug(`Successfully registered tool: ${toolId}`);
|
|
412
|
+
}
|
|
354
413
|
/**
|
|
355
414
|
* Remove a tool
|
|
356
415
|
*/
|
|
357
416
|
removeTool(toolName) {
|
|
358
|
-
// Remove by fully-qualified name first, then fallback to
|
|
417
|
+
// Remove by fully-qualified name first, then fallback to first matching tool name
|
|
359
418
|
let removed = false;
|
|
360
419
|
if (this.tools.has(toolName)) {
|
|
361
420
|
this.tools.delete(toolName);
|
|
@@ -420,9 +479,13 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
420
479
|
removedTools.push(toolId);
|
|
421
480
|
}
|
|
422
481
|
}
|
|
482
|
+
// Remove from builtInServerInfos storage
|
|
483
|
+
const originalLength = this.builtInServerInfos.length;
|
|
484
|
+
this.builtInServerInfos = this.builtInServerInfos.filter((server) => server.id !== serverId);
|
|
485
|
+
const removedFromBuiltIn = originalLength > this.builtInServerInfos.length;
|
|
423
486
|
// Remove from parent registry
|
|
424
487
|
const removed = this.unregister(serverId);
|
|
425
|
-
registryLogger.info(`Unregistered server ${serverId}, removed ${removedTools.length} tools`);
|
|
488
|
+
registryLogger.info(`Unregistered server ${serverId}, removed ${removedTools.length} tools${removedFromBuiltIn ? " and server from builtInServerInfos" : ""}`);
|
|
426
489
|
return removed;
|
|
427
490
|
}
|
|
428
491
|
}
|
|
@@ -294,7 +294,7 @@ export class ModelResolver {
|
|
|
294
294
|
}
|
|
295
295
|
// Base relevance score
|
|
296
296
|
if (score === 0) {
|
|
297
|
-
score = 1; // Minimal relevance for
|
|
297
|
+
score = 1; // Minimal relevance for model
|
|
298
298
|
matchReasons.push("Basic match");
|
|
299
299
|
}
|
|
300
300
|
return { model, score, matchReasons };
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
import type { TextGenerationOptions, TextGenerationResult } from "./core/types.js";
|
|
9
9
|
import type { GenerateOptions, GenerateResult } from "./types/generateTypes.js";
|
|
10
10
|
import type { StreamOptions, StreamResult } from "./types/streamTypes.js";
|
|
11
|
-
import type {
|
|
12
|
-
import type { InMemoryMCPServerConfig } from "./types/mcpTypes.js";
|
|
11
|
+
import type { MCPServerInfo, MCPExecutableTool } from "./types/mcpTypes.js";
|
|
13
12
|
import { EventEmitter } from "events";
|
|
14
13
|
import type { ConversationMemoryConfig } from "./types/conversationTypes.js";
|
|
14
|
+
import type { ExternalMCPServerInstance, ExternalMCPOperationResult, ExternalMCPToolInfo } from "./types/externalMcp.js";
|
|
15
15
|
export interface ProviderStatus {
|
|
16
16
|
provider: string;
|
|
17
17
|
status: "working" | "failed" | "not-configured";
|
|
@@ -30,24 +30,20 @@ export interface MCPStatus {
|
|
|
30
30
|
autoDiscoveredServers: MCPServerInfo[];
|
|
31
31
|
customToolsCount: number;
|
|
32
32
|
inMemoryServersCount: number;
|
|
33
|
+
externalMCPServersCount?: number;
|
|
34
|
+
externalMCPConnectedCount?: number;
|
|
35
|
+
externalMCPFailedCount?: number;
|
|
36
|
+
externalMCPServers?: MCPServerInfo[];
|
|
33
37
|
error?: string;
|
|
34
38
|
[key: string]: unknown;
|
|
35
39
|
}
|
|
36
|
-
export interface MCPServerInfo {
|
|
37
|
-
id: string;
|
|
38
|
-
name: string;
|
|
39
|
-
source: string;
|
|
40
|
-
status: "connected" | "discovered" | "failed";
|
|
41
|
-
hasServer: boolean;
|
|
42
|
-
metadata?: unknown;
|
|
43
|
-
}
|
|
44
40
|
import type { ContextManagerConfig } from "./context/types.js";
|
|
45
41
|
export declare class NeuroLink {
|
|
46
42
|
private mcpInitialized;
|
|
47
43
|
private emitter;
|
|
48
44
|
private contextManager;
|
|
49
|
-
private
|
|
50
|
-
private
|
|
45
|
+
private autoDiscoveredServerInfos;
|
|
46
|
+
private externalServerManager;
|
|
51
47
|
private toolCircuitBreakers;
|
|
52
48
|
private toolExecutionMetrics;
|
|
53
49
|
/**
|
|
@@ -142,19 +138,19 @@ export declare class NeuroLink {
|
|
|
142
138
|
/**
|
|
143
139
|
* Register a custom tool that will be available to all AI providers
|
|
144
140
|
* @param name - Unique name for the tool
|
|
145
|
-
* @param tool - Tool
|
|
141
|
+
* @param tool - Tool in MCPExecutableTool format (unified MCP protocol type)
|
|
146
142
|
*/
|
|
147
|
-
registerTool(name: string, tool:
|
|
143
|
+
registerTool(name: string, tool: MCPExecutableTool): void;
|
|
148
144
|
/**
|
|
149
145
|
* Register multiple tools at once - Supports both object and array formats
|
|
150
|
-
* @param tools - Object mapping tool names to
|
|
146
|
+
* @param tools - Object mapping tool names to MCPExecutableTool format OR Array of tools with names
|
|
151
147
|
*
|
|
152
|
-
* Object format (existing): { toolName:
|
|
153
|
-
* Array format (Lighthouse compatible): [{ name: string, tool:
|
|
148
|
+
* Object format (existing): { toolName: MCPExecutableTool, ... }
|
|
149
|
+
* Array format (Lighthouse compatible): [{ name: string, tool: MCPExecutableTool }, ...]
|
|
154
150
|
*/
|
|
155
|
-
registerTools(tools: Record<string,
|
|
151
|
+
registerTools(tools: Record<string, MCPExecutableTool> | Array<{
|
|
156
152
|
name: string;
|
|
157
|
-
tool:
|
|
153
|
+
tool: MCPExecutableTool;
|
|
158
154
|
}>): void;
|
|
159
155
|
/**
|
|
160
156
|
* Unregister a custom tool
|
|
@@ -164,21 +160,32 @@ export declare class NeuroLink {
|
|
|
164
160
|
unregisterTool(name: string): boolean;
|
|
165
161
|
/**
|
|
166
162
|
* Get all registered custom tools
|
|
167
|
-
* @returns Map of tool names to
|
|
163
|
+
* @returns Map of tool names to MCPExecutableTool format
|
|
168
164
|
*/
|
|
169
|
-
getCustomTools(): Map<string,
|
|
165
|
+
getCustomTools(): Map<string, MCPExecutableTool>;
|
|
170
166
|
/**
|
|
171
167
|
* Add an in-memory MCP server (from git diff)
|
|
172
168
|
* Allows registration of pre-instantiated server objects
|
|
173
169
|
* @param serverId - Unique identifier for the server
|
|
174
|
-
* @param
|
|
170
|
+
* @param serverInfo - Server configuration
|
|
175
171
|
*/
|
|
176
|
-
addInMemoryMCPServer(serverId: string,
|
|
172
|
+
addInMemoryMCPServer(serverId: string, serverInfo: MCPServerInfo): Promise<void>;
|
|
177
173
|
/**
|
|
178
174
|
* Get all registered in-memory servers
|
|
179
|
-
* @returns Map of server IDs to
|
|
175
|
+
* @returns Map of server IDs to MCPServerInfo
|
|
176
|
+
*/
|
|
177
|
+
getInMemoryServers(): Map<string, MCPServerInfo>;
|
|
178
|
+
/**
|
|
179
|
+
* Get in-memory servers as MCPServerInfo - ZERO conversion needed
|
|
180
|
+
* Now fetches from centralized tool registry instead of local duplication
|
|
181
|
+
* @returns Array of MCPServerInfo
|
|
180
182
|
*/
|
|
181
|
-
|
|
183
|
+
getInMemoryServerInfos(): MCPServerInfo[];
|
|
184
|
+
/**
|
|
185
|
+
* Get auto-discovered servers as MCPServerInfo - ZERO conversion needed
|
|
186
|
+
* @returns Array of MCPServerInfo
|
|
187
|
+
*/
|
|
188
|
+
getAutoDiscoveredServerInfos(): MCPServerInfo[];
|
|
182
189
|
/**
|
|
183
190
|
* Execute a specific tool by name with robust error handling
|
|
184
191
|
* Supports both custom tools and MCP server tools with timeout, retry, and circuit breaker patterns
|
|
@@ -200,22 +207,7 @@ export declare class NeuroLink {
|
|
|
200
207
|
* Get all available tools including custom and in-memory ones
|
|
201
208
|
* @returns Array of available tools with metadata
|
|
202
209
|
*/
|
|
203
|
-
getAllAvailableTools(): Promise<
|
|
204
|
-
toolName: string;
|
|
205
|
-
serverId: string | undefined;
|
|
206
|
-
name: string;
|
|
207
|
-
description?: string;
|
|
208
|
-
category?: string;
|
|
209
|
-
inputSchema?: Record<string, unknown>;
|
|
210
|
-
outputSchema?: Record<string, unknown>;
|
|
211
|
-
} | {
|
|
212
|
-
name: string;
|
|
213
|
-
toolName: string;
|
|
214
|
-
description: string;
|
|
215
|
-
serverId: string;
|
|
216
|
-
category: string;
|
|
217
|
-
inputSchema: {};
|
|
218
|
-
})[]>;
|
|
210
|
+
getAllAvailableTools(): Promise<any[]>;
|
|
219
211
|
/**
|
|
220
212
|
* Get comprehensive status of all AI providers
|
|
221
213
|
* Primary method for provider health checking and diagnostics
|
|
@@ -369,7 +361,7 @@ export declare class NeuroLink {
|
|
|
369
361
|
* Get comprehensive tool health report
|
|
370
362
|
* @returns Detailed health report for all tools
|
|
371
363
|
*/
|
|
372
|
-
getToolHealthReport(): {
|
|
364
|
+
getToolHealthReport(): Promise<{
|
|
373
365
|
totalTools: number;
|
|
374
366
|
healthyTools: number;
|
|
375
367
|
unhealthyTools: number;
|
|
@@ -389,7 +381,7 @@ export declare class NeuroLink {
|
|
|
389
381
|
issues: string[];
|
|
390
382
|
recommendations: string[];
|
|
391
383
|
}>;
|
|
392
|
-
}
|
|
384
|
+
}>;
|
|
393
385
|
/**
|
|
394
386
|
* Get conversation memory statistics (public API)
|
|
395
387
|
*/
|
|
@@ -402,6 +394,110 @@ export declare class NeuroLink {
|
|
|
402
394
|
* Clear all conversation history (public API)
|
|
403
395
|
*/
|
|
404
396
|
clearAllConversations(): Promise<void>;
|
|
397
|
+
/**
|
|
398
|
+
* Add an external MCP server
|
|
399
|
+
* Automatically discovers and registers tools from the server
|
|
400
|
+
* @param serverId - Unique identifier for the server
|
|
401
|
+
* @param config - External MCP server configuration
|
|
402
|
+
* @returns Operation result with server instance
|
|
403
|
+
*/
|
|
404
|
+
addExternalMCPServer(serverId: string, config: MCPServerInfo): Promise<ExternalMCPOperationResult<ExternalMCPServerInstance>>;
|
|
405
|
+
/**
|
|
406
|
+
* Remove an external MCP server
|
|
407
|
+
* Stops the server and removes all its tools
|
|
408
|
+
* @param serverId - ID of the server to remove
|
|
409
|
+
* @returns Operation result
|
|
410
|
+
*/
|
|
411
|
+
removeExternalMCPServer(serverId: string): Promise<ExternalMCPOperationResult<void>>;
|
|
412
|
+
/**
|
|
413
|
+
* List all external MCP servers
|
|
414
|
+
* @returns Array of server health information
|
|
415
|
+
*/
|
|
416
|
+
listExternalMCPServers(): Array<{
|
|
417
|
+
serverId: string;
|
|
418
|
+
status: string;
|
|
419
|
+
toolCount: number;
|
|
420
|
+
uptime: number;
|
|
421
|
+
isHealthy: boolean;
|
|
422
|
+
config: MCPServerInfo;
|
|
423
|
+
}>;
|
|
424
|
+
/**
|
|
425
|
+
* Get external MCP server status
|
|
426
|
+
* @param serverId - ID of the server
|
|
427
|
+
* @returns Server instance or undefined if not found
|
|
428
|
+
*/
|
|
429
|
+
getExternalMCPServer(serverId: string): ExternalMCPServerInstance | undefined;
|
|
430
|
+
/**
|
|
431
|
+
* Execute a tool from an external MCP server
|
|
432
|
+
* @param serverId - ID of the server
|
|
433
|
+
* @param toolName - Name of the tool
|
|
434
|
+
* @param parameters - Tool parameters
|
|
435
|
+
* @param options - Execution options
|
|
436
|
+
* @returns Tool execution result
|
|
437
|
+
*/
|
|
438
|
+
executeExternalMCPTool(serverId: string, toolName: string, parameters: Record<string, any>, options?: {
|
|
439
|
+
timeout?: number;
|
|
440
|
+
}): Promise<any>;
|
|
441
|
+
/**
|
|
442
|
+
* Get all tools from external MCP servers
|
|
443
|
+
* @returns Array of external tool information
|
|
444
|
+
*/
|
|
445
|
+
getExternalMCPTools(): ExternalMCPToolInfo[];
|
|
446
|
+
/**
|
|
447
|
+
* Get tools from a specific external MCP server
|
|
448
|
+
* @param serverId - ID of the server
|
|
449
|
+
* @returns Array of tool information for the server
|
|
450
|
+
*/
|
|
451
|
+
getExternalMCPServerTools(serverId: string): ExternalMCPToolInfo[];
|
|
452
|
+
/**
|
|
453
|
+
* Test connection to an external MCP server
|
|
454
|
+
* @param config - Server configuration to test
|
|
455
|
+
* @returns Test result with connection status
|
|
456
|
+
*/
|
|
457
|
+
testExternalMCPConnection(config: MCPServerInfo): Promise<{
|
|
458
|
+
success: boolean;
|
|
459
|
+
error?: string;
|
|
460
|
+
toolCount?: number;
|
|
461
|
+
}>;
|
|
462
|
+
/**
|
|
463
|
+
* Get external MCP server manager statistics
|
|
464
|
+
* @returns Statistics about external servers and tools
|
|
465
|
+
*/
|
|
466
|
+
getExternalMCPStatistics(): {
|
|
467
|
+
totalServers: number;
|
|
468
|
+
connectedServers: number;
|
|
469
|
+
failedServers: number;
|
|
470
|
+
totalTools: number;
|
|
471
|
+
totalConnections: number;
|
|
472
|
+
totalErrors: number;
|
|
473
|
+
};
|
|
474
|
+
/**
|
|
475
|
+
* Shutdown all external MCP servers
|
|
476
|
+
* Called automatically on process exit
|
|
477
|
+
*/
|
|
478
|
+
shutdownExternalMCPServers(): Promise<void>;
|
|
479
|
+
/**
|
|
480
|
+
* Convert external MCP tools to Vercel AI SDK tool format
|
|
481
|
+
* This allows AI providers to use external tools directly
|
|
482
|
+
*/
|
|
483
|
+
private convertExternalMCPToolsToAISDKFormat;
|
|
484
|
+
/**
|
|
485
|
+
* Convert JSON Schema to AI SDK compatible format
|
|
486
|
+
* For now, we'll skip schema validation and let the AI SDK handle parameters dynamically
|
|
487
|
+
*/
|
|
488
|
+
private convertJSONSchemaToAISDKFormat;
|
|
489
|
+
/**
|
|
490
|
+
* Unregister external MCP tools from a specific server
|
|
491
|
+
*/
|
|
492
|
+
private unregisterExternalMCPToolsFromRegistry;
|
|
493
|
+
/**
|
|
494
|
+
* Unregister a specific external MCP tool from the main registry
|
|
495
|
+
*/
|
|
496
|
+
private unregisterExternalMCPToolFromRegistry;
|
|
497
|
+
/**
|
|
498
|
+
* Unregister all external MCP tools from the main registry
|
|
499
|
+
*/
|
|
500
|
+
private unregisterAllExternalMCPToolsFromRegistry;
|
|
405
501
|
}
|
|
406
502
|
export declare const neurolink: NeuroLink;
|
|
407
503
|
export default neurolink;
|