@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/mcp/ecosystem.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Ecosystem Integration - Bridge Between Research Blueprint and NeuroLink
|
|
3
|
-
* Provides unified interface for plugin management and execution
|
|
4
|
-
*/
|
|
5
|
-
import { pluginManager, PluginManager } from "./plugin-manager.js";
|
|
6
|
-
import { SecurityManager } from "./security-manager.js";
|
|
7
|
-
import { MCP } from "./contracts/mcp-contract.js";
|
|
8
|
-
import { mcpLogger } from "./logging.js";
|
|
9
|
-
import { tool } from "ai";
|
|
10
|
-
import { z } from "zod";
|
|
11
|
-
/**
|
|
12
|
-
* MCP Ecosystem - Main Interface for Plugin Operations
|
|
13
|
-
*/
|
|
14
|
-
export class MCPEcosystem {
|
|
15
|
-
static instance;
|
|
16
|
-
securityManager;
|
|
17
|
-
initialized = false;
|
|
18
|
-
constructor() {
|
|
19
|
-
this.securityManager = new SecurityManager("moderate");
|
|
20
|
-
}
|
|
21
|
-
static getInstance() {
|
|
22
|
-
if (!MCPEcosystem.instance) {
|
|
23
|
-
MCPEcosystem.instance = new MCPEcosystem();
|
|
24
|
-
}
|
|
25
|
-
return MCPEcosystem.instance;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Initialize the MCP ecosystem
|
|
29
|
-
*/
|
|
30
|
-
async initialize() {
|
|
31
|
-
if (this.initialized) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
mcpLogger.info("[MCPEcosystem] Initializing MCP ecosystem...");
|
|
35
|
-
await pluginManager.initialize();
|
|
36
|
-
this.initialized = true;
|
|
37
|
-
const stats = pluginManager.getDiscoveryStats();
|
|
38
|
-
mcpLogger.info("[MCPEcosystem] MCP ecosystem initialized", stats);
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* List all available MCPs
|
|
42
|
-
*/
|
|
43
|
-
async list() {
|
|
44
|
-
await this.ensureInitialized();
|
|
45
|
-
return pluginManager.listDiscovered();
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Get metadata for a specific MCP
|
|
49
|
-
*/
|
|
50
|
-
async getMetadata(name) {
|
|
51
|
-
await this.ensureInitialized();
|
|
52
|
-
return pluginManager.getMetadata(name);
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create and execute an MCP instance
|
|
56
|
-
*/
|
|
57
|
-
async execute(name, config, args, context) {
|
|
58
|
-
await this.ensureInitialized();
|
|
59
|
-
const functionTag = "MCPEcosystem.execute";
|
|
60
|
-
try {
|
|
61
|
-
// Get MCP metadata for permissions
|
|
62
|
-
const metadata = await this.getMetadata(name);
|
|
63
|
-
if (!metadata) {
|
|
64
|
-
throw new Error(`MCP ${name} not found`);
|
|
65
|
-
}
|
|
66
|
-
// Create execution context
|
|
67
|
-
const executionContext = this.securityManager.createExecutionContext(context?.sessionId || `mcp-${Date.now()}`, context?.userId || "mcp-user", metadata.permissions, config?.basePath);
|
|
68
|
-
// Create MCP instance
|
|
69
|
-
const mcpInstance = await pluginManager.createInstance(name, config);
|
|
70
|
-
// Execute the MCP
|
|
71
|
-
mcpLogger.debug(`[${functionTag}] Executing ${name}`, { args });
|
|
72
|
-
const result = await mcpInstance.execute(executionContext, args);
|
|
73
|
-
mcpLogger.debug(`[${functionTag}] ${name} execution completed`, {
|
|
74
|
-
success: true,
|
|
75
|
-
resultType: typeof result,
|
|
76
|
-
});
|
|
77
|
-
return result;
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
mcpLogger.error(`[${functionTag}] ${name} execution failed:`, error);
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Execute filesystem operations using FileSystemMCP
|
|
86
|
-
*/
|
|
87
|
-
async filesystem(operation) {
|
|
88
|
-
return this.execute("@neurolink-mcp/filesystem", { basePath: operation.basePath || process.cwd() }, {
|
|
89
|
-
operation: operation.action,
|
|
90
|
-
path: operation.path,
|
|
91
|
-
content: operation.content,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Get ecosystem statistics
|
|
96
|
-
*/
|
|
97
|
-
async getStats() {
|
|
98
|
-
const available = await this.list();
|
|
99
|
-
return {
|
|
100
|
-
initialized: this.initialized,
|
|
101
|
-
pluginsDiscovered: available.length,
|
|
102
|
-
pluginsBySource: pluginManager.getDiscoveryStats(),
|
|
103
|
-
availablePlugins: available.map((p) => p.name),
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Create an MCP instance for direct use
|
|
108
|
-
*/
|
|
109
|
-
async createInstance(name, config) {
|
|
110
|
-
await this.ensureInitialized();
|
|
111
|
-
const metadata = await this.getMetadata(name);
|
|
112
|
-
if (!metadata) {
|
|
113
|
-
throw new Error(`MCP ${name} not found`);
|
|
114
|
-
}
|
|
115
|
-
return pluginManager.createInstance(name, config);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Create execution context for manual MCP usage
|
|
119
|
-
*/
|
|
120
|
-
createExecutionContext(sessionId, userId, permissions, basePath) {
|
|
121
|
-
return this.securityManager.createExecutionContext(sessionId, userId, permissions, basePath);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Ensure ecosystem is initialized
|
|
125
|
-
*/
|
|
126
|
-
async ensureInitialized() {
|
|
127
|
-
if (!this.initialized) {
|
|
128
|
-
await this.initialize();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Get all tools formatted for AI providers
|
|
133
|
-
*/
|
|
134
|
-
async getToolsForAI() {
|
|
135
|
-
await this.ensureInitialized();
|
|
136
|
-
const plugins = await this.list();
|
|
137
|
-
const tools = {};
|
|
138
|
-
for (const plugin of plugins) {
|
|
139
|
-
// This is a simplified representation. A real implementation
|
|
140
|
-
// would parse the plugin's metadata to get tool definitions.
|
|
141
|
-
if (plugin.name.includes("filesystem")) {
|
|
142
|
-
tools["filesystem_list"] = tool({
|
|
143
|
-
description: "List files in a directory",
|
|
144
|
-
parameters: z.object({
|
|
145
|
-
path: z.string().describe("The path to list files from"),
|
|
146
|
-
}),
|
|
147
|
-
execute: async ({ path }) => this.filesystem({ action: "listFiles", path }),
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return tools;
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Dispose of all resources
|
|
155
|
-
*/
|
|
156
|
-
async dispose() {
|
|
157
|
-
await pluginManager.dispose();
|
|
158
|
-
this.initialized = false;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
// Export singleton instance
|
|
162
|
-
export const mcpEcosystem = MCPEcosystem.getInstance();
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Enhanced Error Handling System
|
|
3
|
-
* Provides comprehensive error tracking, categorization, and debugging capabilities
|
|
4
|
-
* Based on error accumulation patterns from Cline
|
|
5
|
-
*/
|
|
6
|
-
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
7
|
-
/**
|
|
8
|
-
* Error categories for classification
|
|
9
|
-
*/
|
|
10
|
-
export declare enum ErrorCategory {
|
|
11
|
-
TOOL_ERROR = "TOOL_ERROR",
|
|
12
|
-
NETWORK_ERROR = "NETWORK_ERROR",
|
|
13
|
-
VALIDATION_ERROR = "VALIDATION_ERROR",
|
|
14
|
-
TIMEOUT_ERROR = "TIMEOUT_ERROR",
|
|
15
|
-
PERMISSION_ERROR = "PERMISSION_ERROR",
|
|
16
|
-
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
17
|
-
CONNECTION_ERROR = "CONNECTION_ERROR",
|
|
18
|
-
UNKNOWN_ERROR = "UNKNOWN_ERROR"
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Error severity levels
|
|
22
|
-
*/
|
|
23
|
-
export declare enum ErrorSeverity {
|
|
24
|
-
LOW = "LOW",
|
|
25
|
-
MEDIUM = "MEDIUM",
|
|
26
|
-
HIGH = "HIGH",
|
|
27
|
-
CRITICAL = "CRITICAL"
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Enhanced error entry with rich context
|
|
31
|
-
*/
|
|
32
|
-
export interface ErrorEntry {
|
|
33
|
-
id: string;
|
|
34
|
-
timestamp: number;
|
|
35
|
-
category: ErrorCategory;
|
|
36
|
-
severity: ErrorSeverity;
|
|
37
|
-
error: Error;
|
|
38
|
-
context: {
|
|
39
|
-
sessionId?: string;
|
|
40
|
-
toolName?: string;
|
|
41
|
-
parameters?: unknown;
|
|
42
|
-
executionContext?: NeuroLinkExecutionContext;
|
|
43
|
-
};
|
|
44
|
-
stackTrace?: string;
|
|
45
|
-
recovery?: {
|
|
46
|
-
attempted: boolean;
|
|
47
|
-
successful?: boolean;
|
|
48
|
-
recovered?: boolean;
|
|
49
|
-
fallbackUsed?: boolean;
|
|
50
|
-
nextAction?: string;
|
|
51
|
-
delay?: number;
|
|
52
|
-
suggestion?: string;
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Error statistics
|
|
57
|
-
*/
|
|
58
|
-
export interface ErrorStats {
|
|
59
|
-
totalErrors: number;
|
|
60
|
-
errorsByCategory: Record<ErrorCategory, number>;
|
|
61
|
-
errorsBySeverity: Record<ErrorSeverity, number>;
|
|
62
|
-
errorRate: number;
|
|
63
|
-
lastError?: ErrorEntry;
|
|
64
|
-
mostFrequentError?: {
|
|
65
|
-
message: string;
|
|
66
|
-
count: number;
|
|
67
|
-
category: ErrorCategory;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Options for error manager configuration
|
|
72
|
-
*/
|
|
73
|
-
export interface ErrorManagerOptions {
|
|
74
|
-
maxHistorySize?: number;
|
|
75
|
-
enableStackTrace?: boolean;
|
|
76
|
-
autoRecovery?: boolean;
|
|
77
|
-
errorRateWindow?: number;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Enhanced Error Manager with accumulation and analysis capabilities
|
|
81
|
-
*/
|
|
82
|
-
export declare class ErrorManager {
|
|
83
|
-
private errorHistory;
|
|
84
|
-
private maxHistorySize;
|
|
85
|
-
private enableStackTrace;
|
|
86
|
-
private autoRecovery;
|
|
87
|
-
private errorRateWindow;
|
|
88
|
-
private errorCounter;
|
|
89
|
-
private errorFrequency;
|
|
90
|
-
private categoryCounts;
|
|
91
|
-
private severityCounts;
|
|
92
|
-
private errorRecovery;
|
|
93
|
-
constructor(options?: ErrorManagerOptions);
|
|
94
|
-
/**
|
|
95
|
-
* Record an error with context
|
|
96
|
-
*
|
|
97
|
-
* @param error The error to record
|
|
98
|
-
* @param context Additional context about the error
|
|
99
|
-
* @returns The created error entry
|
|
100
|
-
*/
|
|
101
|
-
recordError(error: Error | unknown, context?: {
|
|
102
|
-
category?: ErrorCategory;
|
|
103
|
-
severity?: ErrorSeverity;
|
|
104
|
-
sessionId?: string;
|
|
105
|
-
toolName?: string;
|
|
106
|
-
parameters?: unknown;
|
|
107
|
-
executionContext?: NeuroLinkExecutionContext;
|
|
108
|
-
}): Promise<ErrorEntry>;
|
|
109
|
-
/**
|
|
110
|
-
* Get error history
|
|
111
|
-
*
|
|
112
|
-
* @param filter Optional filter criteria
|
|
113
|
-
* @returns Filtered error history
|
|
114
|
-
*/
|
|
115
|
-
getErrorHistory(filter?: {
|
|
116
|
-
category?: ErrorCategory;
|
|
117
|
-
severity?: ErrorSeverity;
|
|
118
|
-
sessionId?: string;
|
|
119
|
-
toolName?: string;
|
|
120
|
-
since?: number;
|
|
121
|
-
limit?: number;
|
|
122
|
-
}): ErrorEntry[];
|
|
123
|
-
/**
|
|
124
|
-
* Get error statistics
|
|
125
|
-
*
|
|
126
|
-
* @returns Current error statistics
|
|
127
|
-
*/
|
|
128
|
-
getStats(): ErrorStats;
|
|
129
|
-
/**
|
|
130
|
-
* Clear error history
|
|
131
|
-
*/
|
|
132
|
-
clearHistory(): void;
|
|
133
|
-
/**
|
|
134
|
-
* Get recovery suggestions for an error
|
|
135
|
-
*
|
|
136
|
-
* @param error The error entry
|
|
137
|
-
* @returns Recovery suggestion
|
|
138
|
-
*/
|
|
139
|
-
getRecoverySuggestion(error: ErrorEntry): string;
|
|
140
|
-
/**
|
|
141
|
-
* Categorize error based on message and type
|
|
142
|
-
*
|
|
143
|
-
* @private
|
|
144
|
-
*/
|
|
145
|
-
private categorizeError;
|
|
146
|
-
/**
|
|
147
|
-
* Determine error severity
|
|
148
|
-
*
|
|
149
|
-
* @private
|
|
150
|
-
*/
|
|
151
|
-
private determineSeverity;
|
|
152
|
-
/**
|
|
153
|
-
* Add error to circular buffer
|
|
154
|
-
*
|
|
155
|
-
* @private
|
|
156
|
-
*/
|
|
157
|
-
private addToHistory;
|
|
158
|
-
/**
|
|
159
|
-
* Update error statistics
|
|
160
|
-
*
|
|
161
|
-
* @private
|
|
162
|
-
*/
|
|
163
|
-
private updateStatistics;
|
|
164
|
-
/**
|
|
165
|
-
* Attempt automatic recovery
|
|
166
|
-
*
|
|
167
|
-
* @private
|
|
168
|
-
*/
|
|
169
|
-
private attemptRecovery;
|
|
170
|
-
/**
|
|
171
|
-
* Generate unique error ID
|
|
172
|
-
*
|
|
173
|
-
* @private
|
|
174
|
-
*/
|
|
175
|
-
private generateErrorId;
|
|
176
|
-
/**
|
|
177
|
-
* Detect error patterns in recent history
|
|
178
|
-
*
|
|
179
|
-
* @param timeWindow Time window to analyze (ms)
|
|
180
|
-
* @returns Detected patterns with counts and severity
|
|
181
|
-
*/
|
|
182
|
-
detectPatterns(timeWindow?: number): {
|
|
183
|
-
patterns: Array<{
|
|
184
|
-
pattern: string;
|
|
185
|
-
count: number;
|
|
186
|
-
errors: ErrorEntry[];
|
|
187
|
-
severity: ErrorSeverity;
|
|
188
|
-
recommendation: string;
|
|
189
|
-
}>;
|
|
190
|
-
correlations: Array<{
|
|
191
|
-
error1: string;
|
|
192
|
-
error2: string;
|
|
193
|
-
correlation: number;
|
|
194
|
-
}>;
|
|
195
|
-
};
|
|
196
|
-
/**
|
|
197
|
-
* Detect correlations between errors
|
|
198
|
-
*
|
|
199
|
-
* @private
|
|
200
|
-
*/
|
|
201
|
-
private detectCorrelations;
|
|
202
|
-
/**
|
|
203
|
-
* Get error trends over time
|
|
204
|
-
*
|
|
205
|
-
* @param bucketSize Time bucket size in ms (default: 1 minute)
|
|
206
|
-
* @param timeWindow Total time window to analyze
|
|
207
|
-
* @returns Error counts per time bucket
|
|
208
|
-
*/
|
|
209
|
-
getErrorTrends(bucketSize?: number, timeWindow?: number): Array<{
|
|
210
|
-
timestamp: number;
|
|
211
|
-
count: number;
|
|
212
|
-
categories: Record<ErrorCategory, number>;
|
|
213
|
-
}>;
|
|
214
|
-
/**
|
|
215
|
-
* Get recovery statistics
|
|
216
|
-
*
|
|
217
|
-
* @returns Recovery statistics from error recovery system
|
|
218
|
-
*/
|
|
219
|
-
getRecoveryStats(): {
|
|
220
|
-
totalAttempts: number;
|
|
221
|
-
successfulRecoveries: number;
|
|
222
|
-
failedRecoveries: number;
|
|
223
|
-
circuitBreakerStates: Record<string, import("./error-recovery.js").CircuitState>;
|
|
224
|
-
patternMatches: Record<string, number>;
|
|
225
|
-
};
|
|
226
|
-
/**
|
|
227
|
-
* Reset circuit breaker for specific resource
|
|
228
|
-
*
|
|
229
|
-
* @param resourceId Resource identifier (usually tool name)
|
|
230
|
-
*/
|
|
231
|
-
resetCircuitBreaker(resourceId: string): void;
|
|
232
|
-
/**
|
|
233
|
-
* Get error insights and recommendations
|
|
234
|
-
*
|
|
235
|
-
* @returns Insights based on error analysis
|
|
236
|
-
*/
|
|
237
|
-
getInsights(): {
|
|
238
|
-
criticalIssues: string[];
|
|
239
|
-
recommendations: string[];
|
|
240
|
-
healthScore: number;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
/**
|
|
244
|
-
* Default error manager instance
|
|
245
|
-
*/
|
|
246
|
-
export declare const defaultErrorManager: ErrorManager;
|
|
247
|
-
/**
|
|
248
|
-
* Utility function to record error with default manager
|
|
249
|
-
*
|
|
250
|
-
* @param error Error to record
|
|
251
|
-
* @param context Error context
|
|
252
|
-
* @returns Error entry
|
|
253
|
-
*/
|
|
254
|
-
export declare function recordError(error: Error | unknown, context?: Parameters<ErrorManager["recordError"]>[1]): Promise<ErrorEntry>;
|