@juspay/neurolink 6.0.0 → 6.2.0
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 +14 -3
- package/dist/cli/commands/config.d.ts +13 -13
- package/dist/cli/index.js +3 -9
- package/dist/core/analytics.d.ts +11 -1
- package/dist/core/analytics.js +2 -2
- package/dist/core/base-provider.js +4 -18
- package/dist/core/dynamic-models.d.ts +8 -8
- package/dist/core/factory.js +3 -11
- package/dist/index.d.ts +2 -4
- package/dist/index.js +2 -11
- package/dist/lib/core/analytics.d.ts +11 -1
- package/dist/lib/core/analytics.js +2 -2
- package/dist/lib/core/base-provider.js +4 -18
- package/dist/lib/core/dynamic-models.d.ts +8 -8
- package/dist/lib/core/factory.js +3 -11
- package/dist/lib/index.d.ts +2 -4
- package/dist/lib/index.js +2 -11
- package/dist/lib/mcp/factory.d.ts +1 -1
- package/dist/lib/mcp/index.d.ts +7 -19
- package/dist/lib/mcp/index.js +15 -56
- package/dist/lib/neurolink.d.ts +1 -9
- package/dist/lib/neurolink.js +21 -70
- package/dist/lib/providers/amazon-bedrock.js +5 -16
- package/dist/lib/providers/anthropic-baseprovider.js +3 -21
- package/dist/lib/providers/anthropic.js +4 -7
- package/dist/lib/providers/azure-openai.js +4 -2
- package/dist/lib/providers/google-vertex.js +5 -9
- package/dist/lib/providers/huggingFace.js +5 -10
- package/dist/lib/providers/mistral.js +5 -8
- package/dist/lib/providers/openAI.js +4 -7
- package/dist/lib/utils/providerConfig.d.ts +117 -0
- package/dist/lib/utils/providerConfig.js +353 -0
- package/dist/lib/utils/providerUtils.d.ts +2 -1
- package/dist/lib/utils/providerUtils.js +53 -36
- package/dist/lib/utils/timeout.d.ts +72 -1
- package/dist/lib/utils/timeout.js +203 -2
- package/dist/mcp/factory.d.ts +1 -1
- package/dist/mcp/index.d.ts +7 -19
- package/dist/mcp/index.js +15 -56
- package/dist/neurolink.d.ts +1 -9
- package/dist/neurolink.js +21 -70
- package/dist/providers/amazon-bedrock.js +5 -16
- package/dist/providers/anthropic-baseprovider.js +3 -21
- package/dist/providers/anthropic.js +4 -7
- package/dist/providers/azure-openai.js +4 -2
- package/dist/providers/google-vertex.js +5 -9
- package/dist/providers/huggingFace.js +5 -10
- package/dist/providers/mistral.js +5 -8
- package/dist/providers/openAI.js +4 -7
- package/dist/utils/providerConfig.d.ts +117 -0
- package/dist/utils/providerConfig.js +353 -0
- package/dist/utils/providerUtils.d.ts +2 -1
- package/dist/utils/providerUtils.js +53 -36
- package/dist/utils/timeout.d.ts +72 -1
- package/dist/utils/timeout.js +203 -2
- package/package.json +2 -1
- package/dist/chat/client-utils.d.ts +0 -95
- package/dist/chat/client-utils.js +0 -315
- package/dist/chat/index.d.ts +0 -24
- package/dist/chat/index.js +0 -33
- package/dist/chat/session-storage.d.ts +0 -77
- package/dist/chat/session-storage.js +0 -233
- package/dist/chat/session.d.ts +0 -96
- package/dist/chat/session.js +0 -257
- package/dist/chat/sse-handler.d.ts +0 -49
- package/dist/chat/sse-handler.js +0 -259
- package/dist/chat/types.d.ts +0 -74
- package/dist/chat/types.js +0 -5
- package/dist/chat/websocket-chat-handler.d.ts +0 -37
- package/dist/chat/websocket-chat-handler.js +0 -262
- package/dist/cli/commands/mcp.d.ts +0 -20
- package/dist/cli/commands/mcp.js +0 -1272
- package/dist/core/defaults.d.ts +0 -19
- package/dist/core/defaults.js +0 -29
- package/dist/core/evaluation-config.d.ts +0 -29
- package/dist/core/evaluation-config.js +0 -144
- package/dist/factories/compatibility-factory.d.ts +0 -35
- package/dist/factories/compatibility-factory.js +0 -71
- package/dist/factories/provider-generate-factory.d.ts +0 -20
- package/dist/factories/provider-generate-factory.js +0 -93
- package/dist/lib/chat/client-utils.d.ts +0 -95
- package/dist/lib/chat/client-utils.js +0 -315
- package/dist/lib/chat/index.d.ts +0 -24
- package/dist/lib/chat/index.js +0 -33
- package/dist/lib/chat/session-storage.d.ts +0 -77
- package/dist/lib/chat/session-storage.js +0 -233
- package/dist/lib/chat/session.d.ts +0 -96
- package/dist/lib/chat/session.js +0 -257
- package/dist/lib/chat/sse-handler.d.ts +0 -49
- package/dist/lib/chat/sse-handler.js +0 -259
- package/dist/lib/chat/types.d.ts +0 -74
- package/dist/lib/chat/types.js +0 -5
- package/dist/lib/chat/websocket-chat-handler.d.ts +0 -37
- package/dist/lib/chat/websocket-chat-handler.js +0 -262
- package/dist/lib/core/defaults.d.ts +0 -19
- package/dist/lib/core/defaults.js +0 -29
- package/dist/lib/core/evaluation-config.d.ts +0 -29
- package/dist/lib/core/evaluation-config.js +0 -144
- package/dist/lib/factories/compatibility-factory.d.ts +0 -35
- package/dist/lib/factories/compatibility-factory.js +0 -71
- package/dist/lib/factories/provider-generate-factory.d.ts +0 -20
- package/dist/lib/factories/provider-generate-factory.js +0 -93
- package/dist/lib/mcp/adapters/plugin-bridge.d.ts +0 -40
- package/dist/lib/mcp/adapters/plugin-bridge.js +0 -89
- package/dist/lib/mcp/auto-discovery.d.ts +0 -62
- package/dist/lib/mcp/auto-discovery.js +0 -149
- package/dist/lib/mcp/client.d.ts +0 -68
- package/dist/lib/mcp/client.js +0 -248
- package/dist/lib/mcp/config.d.ts +0 -31
- package/dist/lib/mcp/config.js +0 -99
- package/dist/lib/mcp/context-manager.d.ts +0 -171
- package/dist/lib/mcp/context-manager.js +0 -362
- package/dist/lib/mcp/contracts/mcp-contract.d.ts +0 -169
- package/dist/lib/mcp/contracts/mcp-contract.js +0 -58
- package/dist/lib/mcp/core/plugin-manager.d.ts +0 -46
- package/dist/lib/mcp/core/plugin-manager.js +0 -110
- package/dist/lib/mcp/demo/plugin-demo.d.ts +0 -20
- package/dist/lib/mcp/demo/plugin-demo.js +0 -118
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +0 -225
- package/dist/lib/mcp/dynamic-chain-executor.js +0 -489
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +0 -115
- package/dist/lib/mcp/dynamic-orchestrator.js +0 -351
- package/dist/lib/mcp/ecosystem.d.ts +0 -75
- package/dist/lib/mcp/ecosystem.js +0 -161
- package/dist/lib/mcp/error-manager.d.ts +0 -254
- package/dist/lib/mcp/error-manager.js +0 -501
- package/dist/lib/mcp/error-recovery.d.ts +0 -159
- package/dist/lib/mcp/error-recovery.js +0 -405
- package/dist/lib/mcp/external-client.d.ts +0 -88
- package/dist/lib/mcp/external-client.js +0 -331
- package/dist/lib/mcp/external-manager.d.ts +0 -112
- package/dist/lib/mcp/external-manager.js +0 -308
- package/dist/lib/mcp/function-calling.d.ts +0 -65
- package/dist/lib/mcp/function-calling.js +0 -642
- package/dist/lib/mcp/health-monitor.d.ts +0 -257
- package/dist/lib/mcp/health-monitor.js +0 -630
- package/dist/lib/mcp/initialize-tools.d.ts +0 -29
- package/dist/lib/mcp/initialize-tools.js +0 -261
- package/dist/lib/mcp/initialize.d.ts +0 -18
- package/dist/lib/mcp/initialize.js +0 -62
- package/dist/lib/mcp/manager.d.ts +0 -68
- package/dist/lib/mcp/manager.js +0 -176
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +0 -97
- package/dist/lib/mcp/neurolink-mcp-client.js +0 -462
- package/dist/lib/mcp/orchestrator.d.ts +0 -302
- package/dist/lib/mcp/orchestrator.js +0 -703
- package/dist/lib/mcp/plugin-manager.d.ts +0 -98
- package/dist/lib/mcp/plugin-manager.js +0 -296
- package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
- package/dist/lib/mcp/plugins/core/filesystem-mcp.js +0 -142
- package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +0 -37
- package/dist/lib/mcp/plugins/filesystem-mcp.js +0 -54
- package/dist/lib/mcp/security-manager.d.ts +0 -87
- package/dist/lib/mcp/security-manager.js +0 -344
- package/dist/lib/mcp/semaphore-manager.d.ts +0 -137
- package/dist/lib/mcp/semaphore-manager.js +0 -329
- package/dist/lib/mcp/session-manager.d.ts +0 -187
- package/dist/lib/mcp/session-manager.js +0 -400
- package/dist/lib/mcp/session-persistence.d.ts +0 -93
- package/dist/lib/mcp/session-persistence.js +0 -301
- package/dist/lib/mcp/tool-integration.d.ts +0 -58
- package/dist/lib/mcp/tool-integration.js +0 -203
- package/dist/lib/mcp/transport-manager.d.ts +0 -154
- package/dist/lib/mcp/transport-manager.js +0 -334
- package/dist/lib/mcp/unified-mcp.d.ts +0 -133
- package/dist/lib/mcp/unified-mcp.js +0 -251
- package/dist/lib/mcp/unified-registry.d.ts +0 -165
- package/dist/lib/mcp/unified-registry.js +0 -538
- package/dist/lib/providers/analytics-helper.d.ts +0 -38
- package/dist/lib/providers/analytics-helper.js +0 -216
- package/dist/lib/providers/function-calling-provider.d.ts +0 -142
- package/dist/lib/providers/function-calling-provider.js +0 -630
- package/dist/lib/providers/mcp-provider.d.ts +0 -75
- package/dist/lib/providers/mcp-provider.js +0 -283
- package/dist/lib/providers/timeout-wrapper.d.ts +0 -40
- package/dist/lib/providers/timeout-wrapper.js +0 -100
- package/dist/lib/sdk/tool-extension.d.ts +0 -181
- package/dist/lib/sdk/tool-extension.js +0 -284
- package/dist/lib/services/streaming/streaming-manager.d.ts +0 -29
- package/dist/lib/services/streaming/streaming-manager.js +0 -245
- package/dist/lib/services/types.d.ts +0 -156
- package/dist/lib/services/types.js +0 -2
- package/dist/lib/services/websocket/websocket-server.d.ts +0 -34
- package/dist/lib/services/websocket/websocket-server.js +0 -305
- package/dist/lib/utils/provider-validation.d.ts +0 -36
- package/dist/lib/utils/provider-validation.js +0 -625
- package/dist/lib/utils/providerUtils-fixed.d.ts +0 -8
- package/dist/lib/utils/providerUtils-fixed.js +0 -94
- package/dist/lib/utils/streaming-utils.d.ts +0 -79
- package/dist/lib/utils/streaming-utils.js +0 -198
- package/dist/lib/utils/timeout-manager.d.ts +0 -75
- package/dist/lib/utils/timeout-manager.js +0 -244
- package/dist/mcp/adapters/plugin-bridge.d.ts +0 -40
- package/dist/mcp/adapters/plugin-bridge.js +0 -89
- package/dist/mcp/auto-discovery.d.ts +0 -62
- package/dist/mcp/auto-discovery.js +0 -149
- package/dist/mcp/client.d.ts +0 -68
- package/dist/mcp/client.js +0 -248
- package/dist/mcp/config.d.ts +0 -31
- package/dist/mcp/config.js +0 -99
- package/dist/mcp/context-manager.d.ts +0 -171
- package/dist/mcp/context-manager.js +0 -362
- package/dist/mcp/contracts/mcp-contract.d.ts +0 -169
- package/dist/mcp/contracts/mcp-contract.js +0 -58
- package/dist/mcp/core/plugin-manager.d.ts +0 -46
- package/dist/mcp/core/plugin-manager.js +0 -110
- package/dist/mcp/demo/plugin-demo.d.ts +0 -20
- package/dist/mcp/demo/plugin-demo.js +0 -118
- package/dist/mcp/dynamic-chain-executor.d.ts +0 -225
- package/dist/mcp/dynamic-chain-executor.js +0 -489
- package/dist/mcp/dynamic-orchestrator.d.ts +0 -115
- package/dist/mcp/dynamic-orchestrator.js +0 -351
- package/dist/mcp/ecosystem.d.ts +0 -75
- package/dist/mcp/ecosystem.js +0 -162
- package/dist/mcp/error-manager.d.ts +0 -254
- package/dist/mcp/error-manager.js +0 -501
- package/dist/mcp/error-recovery.d.ts +0 -159
- package/dist/mcp/error-recovery.js +0 -405
- package/dist/mcp/external-client.d.ts +0 -88
- package/dist/mcp/external-client.js +0 -331
- package/dist/mcp/external-manager.d.ts +0 -112
- package/dist/mcp/external-manager.js +0 -308
- package/dist/mcp/function-calling.d.ts +0 -65
- package/dist/mcp/function-calling.js +0 -642
- package/dist/mcp/health-monitor.d.ts +0 -257
- package/dist/mcp/health-monitor.js +0 -630
- package/dist/mcp/initialize-tools.d.ts +0 -29
- package/dist/mcp/initialize-tools.js +0 -262
- package/dist/mcp/initialize.d.ts +0 -18
- package/dist/mcp/initialize.js +0 -62
- package/dist/mcp/manager.d.ts +0 -68
- package/dist/mcp/manager.js +0 -176
- package/dist/mcp/neurolink-mcp-client.d.ts +0 -97
- package/dist/mcp/neurolink-mcp-client.js +0 -462
- package/dist/mcp/orchestrator.d.ts +0 -302
- package/dist/mcp/orchestrator.js +0 -703
- package/dist/mcp/plugin-manager.d.ts +0 -98
- package/dist/mcp/plugin-manager.js +0 -297
- package/dist/mcp/plugins/core/filesystem-mcp.d.ts +0 -36
- package/dist/mcp/plugins/core/filesystem-mcp.js +0 -142
- package/dist/mcp/plugins/core/neurolink-mcp.json +0 -17
- package/dist/mcp/plugins/filesystem-mcp.d.ts +0 -37
- package/dist/mcp/plugins/filesystem-mcp.js +0 -54
- package/dist/mcp/security-manager.d.ts +0 -87
- package/dist/mcp/security-manager.js +0 -344
- package/dist/mcp/semaphore-manager.d.ts +0 -137
- package/dist/mcp/semaphore-manager.js +0 -329
- package/dist/mcp/session-manager.d.ts +0 -187
- package/dist/mcp/session-manager.js +0 -400
- package/dist/mcp/session-persistence.d.ts +0 -93
- package/dist/mcp/session-persistence.js +0 -302
- package/dist/mcp/tool-integration.d.ts +0 -58
- package/dist/mcp/tool-integration.js +0 -203
- package/dist/mcp/transport-manager.d.ts +0 -154
- package/dist/mcp/transport-manager.js +0 -335
- package/dist/mcp/unified-mcp.d.ts +0 -133
- package/dist/mcp/unified-mcp.js +0 -251
- package/dist/mcp/unified-registry.d.ts +0 -165
- package/dist/mcp/unified-registry.js +0 -539
- package/dist/providers/analytics-helper.d.ts +0 -38
- package/dist/providers/analytics-helper.js +0 -216
- package/dist/providers/function-calling-provider.d.ts +0 -142
- package/dist/providers/function-calling-provider.js +0 -630
- package/dist/providers/mcp-provider.d.ts +0 -75
- package/dist/providers/mcp-provider.js +0 -283
- package/dist/providers/timeout-wrapper.d.ts +0 -40
- package/dist/providers/timeout-wrapper.js +0 -100
- package/dist/sdk/tool-extension.d.ts +0 -181
- package/dist/sdk/tool-extension.js +0 -284
- package/dist/services/streaming/streaming-manager.d.ts +0 -29
- package/dist/services/streaming/streaming-manager.js +0 -245
- package/dist/services/types.d.ts +0 -156
- package/dist/services/types.js +0 -2
- package/dist/services/websocket/websocket-server.d.ts +0 -34
- package/dist/services/websocket/websocket-server.js +0 -306
- package/dist/utils/provider-validation.d.ts +0 -36
- package/dist/utils/provider-validation.js +0 -625
- package/dist/utils/providerUtils-fixed.d.ts +0 -8
- package/dist/utils/providerUtils-fixed.js +0 -94
- package/dist/utils/streaming-utils.d.ts +0 -79
- package/dist/utils/streaming-utils.js +0 -198
- package/dist/utils/timeout-manager.d.ts +0 -75
- package/dist/utils/timeout-manager.js +0 -244
package/dist/lib/mcp/client.js
DELETED
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Client
|
|
3
|
-
* Following Lighthouse's pattern for MCP tool registration and execution
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import { logger } from "../utils/logger.js";
|
|
7
|
-
/**
|
|
8
|
-
* NeuroLink MCP Client
|
|
9
|
-
* Manages tool registration and execution following Lighthouse patterns
|
|
10
|
-
*/
|
|
11
|
-
export class NeuroLinkMCPClient extends EventEmitter {
|
|
12
|
-
tools = new Map();
|
|
13
|
-
config;
|
|
14
|
-
executionCount = 0;
|
|
15
|
-
isConnected = false;
|
|
16
|
-
constructor(config) {
|
|
17
|
-
super();
|
|
18
|
-
this.config = config;
|
|
19
|
-
this.isConnected = true;
|
|
20
|
-
logger.info(`[MCP Client] Initialized for session ${config.sessionId}`, {
|
|
21
|
-
userId: config.userId,
|
|
22
|
-
aiProvider: config.aiProvider,
|
|
23
|
-
modelId: config.modelId,
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Register a tool with the MCP client
|
|
28
|
-
* Following Lighthouse's pattern of namespacing tools with server ID
|
|
29
|
-
*/
|
|
30
|
-
registerTool(toolName, execute, description, inputSchema) {
|
|
31
|
-
// Parse server ID from tool name (format: serverId_toolName)
|
|
32
|
-
const parts = toolName.split("_");
|
|
33
|
-
const serverId = parts[0];
|
|
34
|
-
const originalName = parts.slice(1).join("_");
|
|
35
|
-
// Create registered tool
|
|
36
|
-
const registeredTool = {
|
|
37
|
-
name: toolName,
|
|
38
|
-
originalName,
|
|
39
|
-
serverId,
|
|
40
|
-
execute: async (params, context) => {
|
|
41
|
-
try {
|
|
42
|
-
// Call the execute function with Lighthouse-style parameters
|
|
43
|
-
const result = await execute(toolName, params);
|
|
44
|
-
// Handle different response formats
|
|
45
|
-
if (result && typeof result === "object") {
|
|
46
|
-
// If it's already in NeuroLink format
|
|
47
|
-
if ("success" in result &&
|
|
48
|
-
("data" in result || "error" in result)) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
// If it's in Lighthouse format with content array
|
|
52
|
-
const lightouseResult = result;
|
|
53
|
-
if (lightouseResult.text &&
|
|
54
|
-
Array.isArray(lightouseResult.text) &&
|
|
55
|
-
lightouseResult.text[0]?.text) {
|
|
56
|
-
try {
|
|
57
|
-
const data = JSON.parse(lightouseResult.text[0].text);
|
|
58
|
-
return {
|
|
59
|
-
success: !lightouseResult.isError,
|
|
60
|
-
data,
|
|
61
|
-
metadata: {
|
|
62
|
-
toolName,
|
|
63
|
-
serverId,
|
|
64
|
-
sessionId: context.sessionId,
|
|
65
|
-
timestamp: Date.now(),
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
catch (parseError) {
|
|
70
|
-
// If JSON parsing fails, return the text as-is
|
|
71
|
-
return {
|
|
72
|
-
success: !lightouseResult.isError,
|
|
73
|
-
data: { text: lightouseResult.text[0].text },
|
|
74
|
-
metadata: {
|
|
75
|
-
toolName,
|
|
76
|
-
serverId,
|
|
77
|
-
sessionId: context.sessionId,
|
|
78
|
-
timestamp: Date.now(),
|
|
79
|
-
},
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
// If it has a direct text property
|
|
84
|
-
const textResult = result;
|
|
85
|
-
if (textResult.text) {
|
|
86
|
-
return {
|
|
87
|
-
success: true,
|
|
88
|
-
data: { text: textResult.text },
|
|
89
|
-
metadata: {
|
|
90
|
-
toolName,
|
|
91
|
-
serverId,
|
|
92
|
-
sessionId: context.sessionId,
|
|
93
|
-
timestamp: Date.now(),
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
success: false,
|
|
100
|
-
error: "Invalid tool response format",
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
catch (error) {
|
|
104
|
-
logger.error(`[MCP Client] Tool execution failed: ${toolName}`, error);
|
|
105
|
-
return {
|
|
106
|
-
success: false,
|
|
107
|
-
error: error instanceof Error ? error.message : String(error),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
description,
|
|
112
|
-
inputSchema,
|
|
113
|
-
};
|
|
114
|
-
// Register the tool
|
|
115
|
-
this.tools.set(toolName, registeredTool);
|
|
116
|
-
logger.debug(`[MCP Client] Registered tool: ${toolName}`, {
|
|
117
|
-
serverId,
|
|
118
|
-
originalName,
|
|
119
|
-
description,
|
|
120
|
-
});
|
|
121
|
-
// Emit tool registration event
|
|
122
|
-
this.emit("tool:registered", {
|
|
123
|
-
toolName,
|
|
124
|
-
serverId,
|
|
125
|
-
originalName,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Get all registered tools
|
|
130
|
-
*/
|
|
131
|
-
getTools() {
|
|
132
|
-
const tools = {};
|
|
133
|
-
for (const [name, tool] of Array.from(this.tools.entries())) {
|
|
134
|
-
tools[name] = {
|
|
135
|
-
name: name, // Include the tool name as a property
|
|
136
|
-
description: tool.description,
|
|
137
|
-
inputSchema: tool.inputSchema,
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
return tools;
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* Execute a tool by name
|
|
144
|
-
*/
|
|
145
|
-
async executeTool(toolName, params, context) {
|
|
146
|
-
const tool = this.tools.get(toolName);
|
|
147
|
-
if (!tool) {
|
|
148
|
-
return {
|
|
149
|
-
success: false,
|
|
150
|
-
error: `Tool not found: ${toolName}`,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
// Create full context using createExecutionContext for proper structure
|
|
154
|
-
const { createExecutionContext } = await import("./context-manager.js");
|
|
155
|
-
const fullContext = createExecutionContext({
|
|
156
|
-
sessionId: this.config.sessionId,
|
|
157
|
-
userId: this.config.userId,
|
|
158
|
-
aiProvider: this.config.aiProvider,
|
|
159
|
-
modelId: this.config.modelId,
|
|
160
|
-
...context,
|
|
161
|
-
});
|
|
162
|
-
// Track execution
|
|
163
|
-
this.executionCount++;
|
|
164
|
-
const executionId = `exec-${this.executionCount}`;
|
|
165
|
-
// Emit execution start event
|
|
166
|
-
this.emit("tool:execute:start", {
|
|
167
|
-
executionId,
|
|
168
|
-
toolName,
|
|
169
|
-
serverId: tool.serverId,
|
|
170
|
-
params,
|
|
171
|
-
});
|
|
172
|
-
const startTime = Date.now();
|
|
173
|
-
try {
|
|
174
|
-
// Execute the tool
|
|
175
|
-
const result = await tool.execute(params, fullContext);
|
|
176
|
-
// Add execution metadata
|
|
177
|
-
result.metadata = {
|
|
178
|
-
...result.metadata,
|
|
179
|
-
executionId,
|
|
180
|
-
executionTime: Date.now() - startTime,
|
|
181
|
-
};
|
|
182
|
-
// Emit execution complete event
|
|
183
|
-
this.emit("tool:execute:complete", {
|
|
184
|
-
executionId,
|
|
185
|
-
toolName,
|
|
186
|
-
serverId: tool.serverId,
|
|
187
|
-
success: result.success,
|
|
188
|
-
executionTime: result.metadata.executionTime,
|
|
189
|
-
});
|
|
190
|
-
return result;
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
const executionTime = Date.now() - startTime;
|
|
194
|
-
// Emit execution error event
|
|
195
|
-
this.emit("tool:execute:error", {
|
|
196
|
-
executionId,
|
|
197
|
-
toolName,
|
|
198
|
-
serverId: tool.serverId,
|
|
199
|
-
error: error instanceof Error ? error.message : String(error),
|
|
200
|
-
executionTime,
|
|
201
|
-
});
|
|
202
|
-
return {
|
|
203
|
-
success: false,
|
|
204
|
-
error: error instanceof Error ? error.message : String(error),
|
|
205
|
-
metadata: {
|
|
206
|
-
executionId,
|
|
207
|
-
toolName,
|
|
208
|
-
serverId: tool.serverId,
|
|
209
|
-
executionTime,
|
|
210
|
-
},
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
/**
|
|
215
|
-
* Check if connected to MCP
|
|
216
|
-
*/
|
|
217
|
-
isConnectedToMCP() {
|
|
218
|
-
return this.isConnected;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Disconnect from MCP
|
|
222
|
-
*/
|
|
223
|
-
async disconnect() {
|
|
224
|
-
this.isConnected = false;
|
|
225
|
-
this.tools.clear();
|
|
226
|
-
this.removeAllListeners();
|
|
227
|
-
logger.info(`[MCP Client] Disconnected for session ${this.config.sessionId}`);
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Get client statistics
|
|
231
|
-
*/
|
|
232
|
-
getStats() {
|
|
233
|
-
return {
|
|
234
|
-
sessionId: this.config.sessionId,
|
|
235
|
-
toolCount: this.tools.size,
|
|
236
|
-
executionCount: this.executionCount,
|
|
237
|
-
isConnected: this.isConnected,
|
|
238
|
-
uptime: Date.now() - (this.startTime || Date.now()),
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
startTime = Date.now();
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Create a new MCP client instance
|
|
245
|
-
*/
|
|
246
|
-
export function createMCPClient(config) {
|
|
247
|
-
return new NeuroLinkMCPClient(config);
|
|
248
|
-
}
|
package/dist/lib/mcp/config.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Configuration
|
|
3
|
-
* Central registry for all MCP servers following Lighthouse patterns
|
|
4
|
-
* Handles built-in servers only - auto-discovery handled by unified registry
|
|
5
|
-
*/
|
|
6
|
-
import type { NeuroLinkMCPServer } from "./factory.js";
|
|
7
|
-
/**
|
|
8
|
-
* Built-in MCP servers (kept for backward compatibility)
|
|
9
|
-
* Add new servers here as they are created
|
|
10
|
-
*/
|
|
11
|
-
export declare const allServers: NeuroLinkMCPServer[];
|
|
12
|
-
/**
|
|
13
|
-
* MCP Configuration following Lighthouse patterns
|
|
14
|
-
* Handles built-in servers - auto-discovery is handled by unified registry
|
|
15
|
-
*/
|
|
16
|
-
export declare const mcpConfig: {
|
|
17
|
-
/**
|
|
18
|
-
* Get list of active built-in MCP servers with implemented tools
|
|
19
|
-
*/
|
|
20
|
-
getServers: () => Promise<NeuroLinkMCPServer[]>;
|
|
21
|
-
/**
|
|
22
|
-
* Get all available tools across all servers
|
|
23
|
-
*/
|
|
24
|
-
getAllTools: () => Promise<{
|
|
25
|
-
name: string;
|
|
26
|
-
description: string;
|
|
27
|
-
serverId: string;
|
|
28
|
-
serverTitle: string;
|
|
29
|
-
category?: string;
|
|
30
|
-
}[]>;
|
|
31
|
-
};
|
package/dist/lib/mcp/config.js
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Configuration
|
|
3
|
-
* Central registry for all MCP servers following Lighthouse patterns
|
|
4
|
-
* Handles built-in servers only - auto-discovery handled by unified registry
|
|
5
|
-
*/
|
|
6
|
-
import { utilityServer } from "./servers/utilities/utility-server.js";
|
|
7
|
-
import { logger } from "../utils/logger.js";
|
|
8
|
-
/**
|
|
9
|
-
* Lazy-loaded AI Core Server to avoid circular dependencies
|
|
10
|
-
*/
|
|
11
|
-
let aiCoreServerCache = null;
|
|
12
|
-
async function getAICoreServer() {
|
|
13
|
-
if (!aiCoreServerCache) {
|
|
14
|
-
const { aiCoreServer } = await import("./servers/ai-providers/ai-core-server.js");
|
|
15
|
-
aiCoreServerCache = aiCoreServer;
|
|
16
|
-
}
|
|
17
|
-
return aiCoreServerCache;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Lazy-loaded Direct Tools Server to avoid circular dependencies
|
|
21
|
-
*/
|
|
22
|
-
let directToolsServerCache = null;
|
|
23
|
-
async function getDirectToolsServer() {
|
|
24
|
-
if (!directToolsServerCache) {
|
|
25
|
-
const { directToolsServer } = await import("./servers/agent/direct-tools-server.js");
|
|
26
|
-
directToolsServerCache = directToolsServer;
|
|
27
|
-
}
|
|
28
|
-
return directToolsServerCache;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Built-in MCP servers (kept for backward compatibility)
|
|
32
|
-
* Add new servers here as they are created
|
|
33
|
-
*/
|
|
34
|
-
export const allServers = [
|
|
35
|
-
// aiCoreServer will be added dynamically in getServers()
|
|
36
|
-
utilityServer,
|
|
37
|
-
// Add more servers as they are created
|
|
38
|
-
];
|
|
39
|
-
/**
|
|
40
|
-
* MCP Configuration following Lighthouse patterns
|
|
41
|
-
* Handles built-in servers - auto-discovery is handled by unified registry
|
|
42
|
-
*/
|
|
43
|
-
export const mcpConfig = {
|
|
44
|
-
/**
|
|
45
|
-
* Get list of active built-in MCP servers with implemented tools
|
|
46
|
-
*/
|
|
47
|
-
getServers: async () => {
|
|
48
|
-
const activeServers = [];
|
|
49
|
-
// Get all servers including dynamically loaded ones
|
|
50
|
-
const aiCoreServer = await getAICoreServer();
|
|
51
|
-
const directToolsServer = await getDirectToolsServer();
|
|
52
|
-
const servers = [aiCoreServer, directToolsServer, ...allServers];
|
|
53
|
-
// Include built-in servers with filtering
|
|
54
|
-
for (const server of servers) {
|
|
55
|
-
const implementedTools = {};
|
|
56
|
-
let hasImplementedTools = false;
|
|
57
|
-
for (const toolName in server.tools) {
|
|
58
|
-
const tool = server.tools[toolName];
|
|
59
|
-
// Only include tools that are implemented (default to true if not specified)
|
|
60
|
-
if (tool.isImplemented !== false) {
|
|
61
|
-
implementedTools[toolName] = tool;
|
|
62
|
-
hasImplementedTools = true;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
// Only include servers that have at least one implemented tool
|
|
66
|
-
if (hasImplementedTools) {
|
|
67
|
-
activeServers.push({
|
|
68
|
-
...server,
|
|
69
|
-
tools: implementedTools,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
logger.debug("[MCP Config] Built-in servers:", {
|
|
74
|
-
total: activeServers.length,
|
|
75
|
-
serverIds: activeServers.map((s) => s.id),
|
|
76
|
-
});
|
|
77
|
-
return activeServers;
|
|
78
|
-
},
|
|
79
|
-
/**
|
|
80
|
-
* Get all available tools across all servers
|
|
81
|
-
*/
|
|
82
|
-
getAllTools: async () => {
|
|
83
|
-
const servers = await mcpConfig.getServers();
|
|
84
|
-
const allTools = [];
|
|
85
|
-
for (const server of servers) {
|
|
86
|
-
for (const toolName in server.tools) {
|
|
87
|
-
const tool = server.tools[toolName];
|
|
88
|
-
allTools.push({
|
|
89
|
-
name: toolName,
|
|
90
|
-
description: tool.description,
|
|
91
|
-
serverId: server.id,
|
|
92
|
-
serverTitle: server.title,
|
|
93
|
-
category: tool.category,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return allTools;
|
|
98
|
-
},
|
|
99
|
-
};
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Context Management System
|
|
3
|
-
* Unified context creation and management for all tool executions
|
|
4
|
-
* Ensures rich context flows through tool chain with session tracking
|
|
5
|
-
*/
|
|
6
|
-
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
7
|
-
/**
|
|
8
|
-
* Context creation request interface
|
|
9
|
-
*/
|
|
10
|
-
export interface ContextRequest {
|
|
11
|
-
sessionId?: string;
|
|
12
|
-
userId?: string;
|
|
13
|
-
aiProvider?: string;
|
|
14
|
-
modelId?: string;
|
|
15
|
-
temperature?: number;
|
|
16
|
-
maxTokens?: number;
|
|
17
|
-
organizationId?: string;
|
|
18
|
-
projectId?: string;
|
|
19
|
-
environmentType?: "development" | "staging" | "production";
|
|
20
|
-
frameworkType?: "react" | "vue" | "svelte" | "next" | "nuxt" | "sveltekit";
|
|
21
|
-
permissions?: string[];
|
|
22
|
-
securityLevel?: "public" | "private" | "organization";
|
|
23
|
-
[key: string]: unknown;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Context manager for creating and managing execution contexts
|
|
27
|
-
* Provides rich context for all tool executions with session tracking
|
|
28
|
-
*/
|
|
29
|
-
export declare class ContextManager {
|
|
30
|
-
private sessionCounter;
|
|
31
|
-
private activeContexts;
|
|
32
|
-
private static cachedLogger;
|
|
33
|
-
/**
|
|
34
|
-
* Create a new execution context with rich information
|
|
35
|
-
*
|
|
36
|
-
* @param request Context creation request with optional fields
|
|
37
|
-
* @returns Complete execution context ready for tool chain
|
|
38
|
-
*/
|
|
39
|
-
createContext(request?: ContextRequest): NeuroLinkExecutionContext;
|
|
40
|
-
/**
|
|
41
|
-
* Add a tool to the execution chain
|
|
42
|
-
*
|
|
43
|
-
* @param context Execution context to modify
|
|
44
|
-
* @param toolName Name of the tool being executed
|
|
45
|
-
*/
|
|
46
|
-
addToToolChain(context: NeuroLinkExecutionContext, toolName: string): void;
|
|
47
|
-
/**
|
|
48
|
-
* Get the current tool chain for a context
|
|
49
|
-
*
|
|
50
|
-
* @param context Execution context
|
|
51
|
-
* @returns Array of tool names in execution order
|
|
52
|
-
*/
|
|
53
|
-
getToolChain(context: NeuroLinkExecutionContext): string[];
|
|
54
|
-
/**
|
|
55
|
-
* Set parent tool for nested tool execution
|
|
56
|
-
*
|
|
57
|
-
* @param context Execution context to modify
|
|
58
|
-
* @param parentToolId ID of the parent tool
|
|
59
|
-
*/
|
|
60
|
-
setParentTool(context: NeuroLinkExecutionContext, parentToolId: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Create child context for nested tool execution
|
|
63
|
-
*
|
|
64
|
-
* @param parentContext Parent execution context
|
|
65
|
-
* @param childToolName Name of the child tool
|
|
66
|
-
* @returns New child context with inherited properties
|
|
67
|
-
*/
|
|
68
|
-
createChildContext(parentContext: NeuroLinkExecutionContext, childToolName: string): NeuroLinkExecutionContext;
|
|
69
|
-
/**
|
|
70
|
-
* Get context by session ID
|
|
71
|
-
*
|
|
72
|
-
* @param sessionId Session identifier
|
|
73
|
-
* @returns Execution context or undefined if not found
|
|
74
|
-
*/
|
|
75
|
-
getContext(sessionId: string): NeuroLinkExecutionContext | undefined;
|
|
76
|
-
/**
|
|
77
|
-
* Update context with new information
|
|
78
|
-
*
|
|
79
|
-
* @param sessionId Session identifier
|
|
80
|
-
* @param updates Partial context updates
|
|
81
|
-
*/
|
|
82
|
-
updateContext(sessionId: string, updates: Partial<NeuroLinkExecutionContext>): void;
|
|
83
|
-
/**
|
|
84
|
-
* Store context directly (used when session ID changes)
|
|
85
|
-
*
|
|
86
|
-
* @param context Complete execution context to store
|
|
87
|
-
*/
|
|
88
|
-
storeContext(context: NeuroLinkExecutionContext): void;
|
|
89
|
-
/**
|
|
90
|
-
* Remove context from active tracking
|
|
91
|
-
*
|
|
92
|
-
* @param sessionId Session identifier
|
|
93
|
-
*/
|
|
94
|
-
removeContext(sessionId: string): void;
|
|
95
|
-
/**
|
|
96
|
-
* Get all active contexts (for debugging/monitoring)
|
|
97
|
-
*
|
|
98
|
-
* @returns Array of all active contexts
|
|
99
|
-
*/
|
|
100
|
-
getActiveContexts(): NeuroLinkExecutionContext[];
|
|
101
|
-
/**
|
|
102
|
-
* Clear all active contexts
|
|
103
|
-
*/
|
|
104
|
-
clearAllContexts(): void;
|
|
105
|
-
/**
|
|
106
|
-
* Get context statistics
|
|
107
|
-
*
|
|
108
|
-
* @returns Context usage statistics
|
|
109
|
-
*/
|
|
110
|
-
getStats(): {
|
|
111
|
-
activeContexts: number;
|
|
112
|
-
totalSessionsCreated: number;
|
|
113
|
-
averageToolChainLength: number;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Generate unique session ID
|
|
117
|
-
*
|
|
118
|
-
* @returns Unique session identifier
|
|
119
|
-
*/
|
|
120
|
-
private generateSessionId;
|
|
121
|
-
/**
|
|
122
|
-
* Extract custom fields from request (excluding known fields)
|
|
123
|
-
*
|
|
124
|
-
* @param request Context creation request
|
|
125
|
-
* @returns Custom fields object
|
|
126
|
-
*/
|
|
127
|
-
private extractCustomFields;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Default context manager instance
|
|
131
|
-
* Can be used across the application for consistent context management
|
|
132
|
-
*/
|
|
133
|
-
export declare const defaultContextManager: ContextManager;
|
|
134
|
-
/**
|
|
135
|
-
* Utility function to create context with defaults
|
|
136
|
-
*
|
|
137
|
-
* @param request Optional context request
|
|
138
|
-
* @returns Execution context with sensible defaults
|
|
139
|
-
*/
|
|
140
|
-
export declare function createExecutionContext(request?: ContextRequest): NeuroLinkExecutionContext;
|
|
141
|
-
/**
|
|
142
|
-
* Utility function to add tool to default context manager
|
|
143
|
-
*
|
|
144
|
-
* @param context Execution context
|
|
145
|
-
* @param toolName Tool name to add
|
|
146
|
-
*/
|
|
147
|
-
export declare function addToolToChain(context: NeuroLinkExecutionContext, toolName: string): void;
|
|
148
|
-
/**
|
|
149
|
-
* Context validation utilities
|
|
150
|
-
*/
|
|
151
|
-
export declare class ContextValidator {
|
|
152
|
-
/**
|
|
153
|
-
* Validate context has required fields for tool execution
|
|
154
|
-
*
|
|
155
|
-
* @param context Execution context to validate
|
|
156
|
-
* @returns Validation result with details
|
|
157
|
-
*/
|
|
158
|
-
static validateContext(context: NeuroLinkExecutionContext): {
|
|
159
|
-
isValid: boolean;
|
|
160
|
-
errors: string[];
|
|
161
|
-
warnings: string[];
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Validate context permissions for tool execution
|
|
165
|
-
*
|
|
166
|
-
* @param context Execution context
|
|
167
|
-
* @param requiredPermissions Permissions required by tool
|
|
168
|
-
* @returns Whether context has required permissions
|
|
169
|
-
*/
|
|
170
|
-
static hasPermissions(context: NeuroLinkExecutionContext, requiredPermissions: string[]): boolean;
|
|
171
|
-
}
|