@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
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Core Plugin Manager
|
|
3
|
-
* Enhanced plugin management with advanced lifecycle control
|
|
4
|
-
*/
|
|
5
|
-
import { mcpLogger } from "../logging.js";
|
|
6
|
-
/**
|
|
7
|
-
* Enhanced plugin manager with core functionality
|
|
8
|
-
*/
|
|
9
|
-
export class CorePluginManager {
|
|
10
|
-
plugins = new Map();
|
|
11
|
-
constructors = new Map();
|
|
12
|
-
metadata = new Map();
|
|
13
|
-
/**
|
|
14
|
-
* Load a plugin from constructor
|
|
15
|
-
*/
|
|
16
|
-
async loadPlugin(name, Constructor, config) {
|
|
17
|
-
try {
|
|
18
|
-
const instance = new Constructor();
|
|
19
|
-
await instance.initialize(config);
|
|
20
|
-
this.plugins.set(name, instance);
|
|
21
|
-
this.constructors.set(name, Constructor);
|
|
22
|
-
this.metadata.set(name, instance.getMetadata());
|
|
23
|
-
mcpLogger.info(`[CorePluginManager] Loaded plugin: ${name}`);
|
|
24
|
-
return {
|
|
25
|
-
success: true,
|
|
26
|
-
plugin: instance,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
mcpLogger.error(`[CorePluginManager] Failed to load plugin ${name}:`, error);
|
|
31
|
-
return {
|
|
32
|
-
success: false,
|
|
33
|
-
error: error instanceof Error ? error.message : String(error),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execute a plugin operation
|
|
39
|
-
*/
|
|
40
|
-
async executePlugin(name, context, args) {
|
|
41
|
-
const startTime = Date.now();
|
|
42
|
-
try {
|
|
43
|
-
const plugin = this.plugins.get(name);
|
|
44
|
-
if (!plugin) {
|
|
45
|
-
throw new Error(`Plugin ${name} not loaded`);
|
|
46
|
-
}
|
|
47
|
-
const result = await plugin.execute(context, args);
|
|
48
|
-
const executionTime = Date.now() - startTime;
|
|
49
|
-
return {
|
|
50
|
-
success: true,
|
|
51
|
-
result: result,
|
|
52
|
-
executionTime,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const executionTime = Date.now() - startTime;
|
|
57
|
-
mcpLogger.error(`[CorePluginManager] Plugin execution failed for ${name}:`, error);
|
|
58
|
-
return {
|
|
59
|
-
success: false,
|
|
60
|
-
error: error instanceof Error ? error.message : String(error),
|
|
61
|
-
executionTime,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get plugin instance
|
|
67
|
-
*/
|
|
68
|
-
getPlugin(name) {
|
|
69
|
-
return this.plugins.get(name);
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Get plugin metadata
|
|
73
|
-
*/
|
|
74
|
-
getPluginMetadata(name) {
|
|
75
|
-
return this.metadata.get(name);
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* List all loaded plugins
|
|
79
|
-
*/
|
|
80
|
-
listPlugins() {
|
|
81
|
-
return Array.from(this.plugins.keys());
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Unload a plugin
|
|
85
|
-
*/
|
|
86
|
-
async unloadPlugin(name) {
|
|
87
|
-
const plugin = this.plugins.get(name);
|
|
88
|
-
if (plugin) {
|
|
89
|
-
await plugin.dispose();
|
|
90
|
-
this.plugins.delete(name);
|
|
91
|
-
this.constructors.delete(name);
|
|
92
|
-
this.metadata.delete(name);
|
|
93
|
-
mcpLogger.info(`[CorePluginManager] Unloaded plugin: ${name}`);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Dispose all plugins
|
|
98
|
-
*/
|
|
99
|
-
async dispose() {
|
|
100
|
-
const pluginNames = Array.from(this.plugins.keys());
|
|
101
|
-
for (const name of pluginNames) {
|
|
102
|
-
await this.unloadPlugin(name);
|
|
103
|
-
}
|
|
104
|
-
mcpLogger.info("[CorePluginManager] All plugins disposed");
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Default core plugin manager instance
|
|
109
|
-
*/
|
|
110
|
-
export const corePluginManager = new CorePluginManager();
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Demo - Example MCP Plugin Usage
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Demo plugin functionality
|
|
6
|
-
*/
|
|
7
|
-
export declare class PluginDemo {
|
|
8
|
-
/**
|
|
9
|
-
* Demonstrate filesystem plugin
|
|
10
|
-
*/
|
|
11
|
-
static demonstrateFileSystem(): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Demonstrate plugin execution via ecosystem
|
|
14
|
-
*/
|
|
15
|
-
static demonstrateEcosystem(): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Demonstrate quick plugin factory
|
|
18
|
-
*/
|
|
19
|
-
static demonstrateQuickFactory(): Promise<void>;
|
|
20
|
-
}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Demo - Example MCP Plugin Usage
|
|
3
|
-
*/
|
|
4
|
-
import { mcpEcosystem } from "../ecosystem.js";
|
|
5
|
-
import { FileSystemMCP } from "../plugins/core/filesystem-mcp.js";
|
|
6
|
-
import { QuickPluginFactory, executePlugin, } from "../adapters/plugin-bridge.js";
|
|
7
|
-
import { mcpLogger } from "../logging.js";
|
|
8
|
-
/**
|
|
9
|
-
* Demo plugin functionality
|
|
10
|
-
*/
|
|
11
|
-
export class PluginDemo {
|
|
12
|
-
/**
|
|
13
|
-
* Demonstrate filesystem plugin
|
|
14
|
-
*/
|
|
15
|
-
static async demonstrateFileSystem() {
|
|
16
|
-
try {
|
|
17
|
-
// Create filesystem plugin instance
|
|
18
|
-
const fsPlugin = new FileSystemMCP();
|
|
19
|
-
await fsPlugin.initialize({ basePath: process.cwd() });
|
|
20
|
-
mcpLogger.info("FileSystem plugin demonstration started");
|
|
21
|
-
// This would normally be done through the ecosystem
|
|
22
|
-
// but we're demonstrating direct usage
|
|
23
|
-
const result = await mcpEcosystem.filesystem({
|
|
24
|
-
action: "listFiles",
|
|
25
|
-
path: ".",
|
|
26
|
-
basePath: process.cwd(),
|
|
27
|
-
});
|
|
28
|
-
mcpLogger.info("File listing result:", result);
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
mcpLogger.error("Demo failed:", error);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Demonstrate plugin execution via ecosystem
|
|
36
|
-
*/
|
|
37
|
-
static async demonstrateEcosystem() {
|
|
38
|
-
try {
|
|
39
|
-
await mcpEcosystem.initialize();
|
|
40
|
-
const stats = await mcpEcosystem.getStats();
|
|
41
|
-
mcpLogger.info("MCP Ecosystem stats:", stats);
|
|
42
|
-
// Try to read a file
|
|
43
|
-
const fsPlugin = new FileSystemMCP();
|
|
44
|
-
await fsPlugin.initialize({ basePath: process.cwd() });
|
|
45
|
-
// Cast FileSystemMCP to UnknownRecord for executePlugin compatibility
|
|
46
|
-
const pluginAsRecord = fsPlugin;
|
|
47
|
-
const result = await executePlugin(pluginAsRecord, createMockContext(), "listFiles", ".");
|
|
48
|
-
mcpLogger.info("Plugin execution result:", result);
|
|
49
|
-
}
|
|
50
|
-
catch (error) {
|
|
51
|
-
mcpLogger.error("Ecosystem demo failed:", error);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Demonstrate quick plugin factory
|
|
56
|
-
*/
|
|
57
|
-
static async demonstrateQuickFactory() {
|
|
58
|
-
try {
|
|
59
|
-
const fsPlugin = new FileSystemMCP();
|
|
60
|
-
await fsPlugin.initialize({ basePath: process.cwd() });
|
|
61
|
-
const quickPlugin = await QuickPluginFactory.create("demo-plugin", {
|
|
62
|
-
basePath: process.cwd(),
|
|
63
|
-
});
|
|
64
|
-
mcpLogger.info("Quick plugin created:", quickPlugin);
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
mcpLogger.error("Quick factory demo failed:", error);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Create a mock execution context for testing
|
|
73
|
-
*/
|
|
74
|
-
function createMockContext() {
|
|
75
|
-
return {
|
|
76
|
-
sessionId: "demo-session",
|
|
77
|
-
userId: "demo-user",
|
|
78
|
-
grantedPermissions: ["fs:read:./**/*", "fs:write:./temp/**/*"],
|
|
79
|
-
secureFS: {
|
|
80
|
-
async readFile(path, encoding) {
|
|
81
|
-
return `Mock content from ${path}`;
|
|
82
|
-
},
|
|
83
|
-
async writeFile(path, content) {
|
|
84
|
-
mcpLogger.info(`Mock write to ${path}`);
|
|
85
|
-
},
|
|
86
|
-
async readdir(path) {
|
|
87
|
-
return ["file1.txt", "file2.json", "subdir"];
|
|
88
|
-
},
|
|
89
|
-
async stat(path) {
|
|
90
|
-
return {
|
|
91
|
-
size: 1024,
|
|
92
|
-
mtime: new Date(),
|
|
93
|
-
isDirectory: () => false,
|
|
94
|
-
isFile: () => true,
|
|
95
|
-
};
|
|
96
|
-
},
|
|
97
|
-
async mkdir(path, options) {
|
|
98
|
-
mcpLogger.info(`Mock mkdir: ${path}`);
|
|
99
|
-
},
|
|
100
|
-
async exists(path) {
|
|
101
|
-
return true;
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
path: {
|
|
105
|
-
join: (...paths) => paths.join("/"),
|
|
106
|
-
resolve: (...paths) => "/" + paths.join("/"),
|
|
107
|
-
relative: (from, to) => to,
|
|
108
|
-
dirname: (path) => path.split("/").slice(0, -1).join("/"),
|
|
109
|
-
basename: (path, ext) => {
|
|
110
|
-
const name = path.split("/").pop() || "";
|
|
111
|
-
return ext ? name.replace(ext, "") : name;
|
|
112
|
-
},
|
|
113
|
-
},
|
|
114
|
-
log: (level, message, data) => {
|
|
115
|
-
mcpLogger[level](`[MockContext] ${message}`, data);
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
}
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Dynamic AI Tool Chain Executor
|
|
3
|
-
* Allows AI to dynamically decide tool execution sequences based on context and results
|
|
4
|
-
*/
|
|
5
|
-
import type { MCPOrchestrator } from "./orchestrator.js";
|
|
6
|
-
import type { MCPRegistry } from "./registry.js";
|
|
7
|
-
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
8
|
-
import type { JsonValue, UnknownRecord } from "../types/common.js";
|
|
9
|
-
import { ErrorManager } from "./error-manager.js";
|
|
10
|
-
/**
|
|
11
|
-
* Tool input schema structure
|
|
12
|
-
*/
|
|
13
|
-
export interface ToolInputSchema {
|
|
14
|
-
type?: string;
|
|
15
|
-
properties?: Record<string, unknown>;
|
|
16
|
-
required?: string[];
|
|
17
|
-
[key: string]: unknown;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Tool execution parameters
|
|
21
|
-
*/
|
|
22
|
-
export interface ToolExecutionParameters extends Record<string, JsonValue> {
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Context evolution entry tracking data changes
|
|
26
|
-
*/
|
|
27
|
-
export interface ContextEvolutionEntry {
|
|
28
|
-
step: string;
|
|
29
|
-
timestamp: number;
|
|
30
|
-
dataKeys: string[];
|
|
31
|
-
[key: string]: JsonValue;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* AI model planning response structure
|
|
35
|
-
*/
|
|
36
|
-
export interface AIPlanningResponse {
|
|
37
|
-
toolName: string | null;
|
|
38
|
-
parameters?: ToolExecutionParameters;
|
|
39
|
-
reasoning?: string;
|
|
40
|
-
confidence?: number;
|
|
41
|
-
expectedOutcome?: string;
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* AI model evaluation response structure
|
|
45
|
-
*/
|
|
46
|
-
export interface AIEvaluationResponse {
|
|
47
|
-
goalAchieved: boolean;
|
|
48
|
-
confidence: number;
|
|
49
|
-
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
50
|
-
reasoning: string;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Available tool descriptor
|
|
54
|
-
*/
|
|
55
|
-
export interface AvailableToolDescriptor {
|
|
56
|
-
name: string;
|
|
57
|
-
description: string;
|
|
58
|
-
inputSchema: ToolInputSchema;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Tool execution result with metadata
|
|
62
|
-
*/
|
|
63
|
-
export interface ToolExecutionResult {
|
|
64
|
-
toolName: string;
|
|
65
|
-
success: boolean;
|
|
66
|
-
result?: JsonValue;
|
|
67
|
-
error?: Error;
|
|
68
|
-
timestamp: number;
|
|
69
|
-
executionTime: number;
|
|
70
|
-
context?: UnknownRecord;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Chain execution step
|
|
74
|
-
*/
|
|
75
|
-
export interface ChainStep {
|
|
76
|
-
stepId: string;
|
|
77
|
-
toolName: string;
|
|
78
|
-
parameters: ToolExecutionParameters;
|
|
79
|
-
reasoning: string;
|
|
80
|
-
confidence: number;
|
|
81
|
-
expectedOutcome: string;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Chain execution context
|
|
85
|
-
*/
|
|
86
|
-
export interface ChainExecutionContext {
|
|
87
|
-
goal: string;
|
|
88
|
-
currentStep: number;
|
|
89
|
-
totalSteps?: number;
|
|
90
|
-
executionHistory: ToolExecutionResult[];
|
|
91
|
-
accumulatedContext: UnknownRecord;
|
|
92
|
-
userContext?: NeuroLinkExecutionContext;
|
|
93
|
-
maxSteps: number;
|
|
94
|
-
aiModel?: string;
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* Chain execution result
|
|
98
|
-
*/
|
|
99
|
-
export interface ChainExecutionResult {
|
|
100
|
-
success: boolean;
|
|
101
|
-
goal: string;
|
|
102
|
-
totalSteps: number;
|
|
103
|
-
executionTime: number;
|
|
104
|
-
results: ToolExecutionResult[];
|
|
105
|
-
finalResult?: JsonValue;
|
|
106
|
-
reasoning: string;
|
|
107
|
-
error?: Error;
|
|
108
|
-
metadata: {
|
|
109
|
-
toolsUsed: string[];
|
|
110
|
-
averageConfidence: number;
|
|
111
|
-
contextEvolution: ContextEvolutionEntry[];
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* AI Tool Chain Planner interface
|
|
116
|
-
*/
|
|
117
|
-
export interface AIChainPlanner {
|
|
118
|
-
name: string;
|
|
119
|
-
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
120
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Simple AI Chain Planner using heuristics
|
|
124
|
-
*/
|
|
125
|
-
export declare class HeuristicChainPlanner implements AIChainPlanner {
|
|
126
|
-
name: string;
|
|
127
|
-
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
128
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
129
|
-
private generateParameters;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Advanced AI Chain Planner using actual AI model
|
|
133
|
-
*/
|
|
134
|
-
export declare class AIModelChainPlanner implements AIChainPlanner {
|
|
135
|
-
name: string;
|
|
136
|
-
private aiModel;
|
|
137
|
-
constructor(aiModel?: string);
|
|
138
|
-
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
139
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
140
|
-
private buildPlanningPrompt;
|
|
141
|
-
private buildEvaluationPrompt;
|
|
142
|
-
private callAIModel;
|
|
143
|
-
private parseAIResponse;
|
|
144
|
-
private parseEvaluationResponse;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Dynamic Chain Executor
|
|
148
|
-
*/
|
|
149
|
-
export declare class DynamicChainExecutor {
|
|
150
|
-
private orchestrator;
|
|
151
|
-
private registry;
|
|
152
|
-
private errorManager;
|
|
153
|
-
private planner;
|
|
154
|
-
constructor(orchestrator: MCPOrchestrator, registry: MCPRegistry, errorManager: ErrorManager, planner?: AIChainPlanner);
|
|
155
|
-
/**
|
|
156
|
-
* Execute dynamic tool chain to achieve a goal
|
|
157
|
-
*
|
|
158
|
-
* @param goal The goal to achieve
|
|
159
|
-
* @param initialContext Initial context data
|
|
160
|
-
* @param userContext User execution context
|
|
161
|
-
* @param options Execution options
|
|
162
|
-
* @returns Chain execution result
|
|
163
|
-
*/
|
|
164
|
-
executeChain(goal: string, initialContext?: UnknownRecord, userContext?: NeuroLinkExecutionContext, options?: {
|
|
165
|
-
maxSteps?: number;
|
|
166
|
-
aiModel?: string;
|
|
167
|
-
timeout?: number;
|
|
168
|
-
}): Promise<ChainExecutionResult>;
|
|
169
|
-
/**
|
|
170
|
-
* Execute chain steps iteratively
|
|
171
|
-
*
|
|
172
|
-
* @private
|
|
173
|
-
*/
|
|
174
|
-
private executeChainSteps;
|
|
175
|
-
/**
|
|
176
|
-
* Execute a single step
|
|
177
|
-
*
|
|
178
|
-
* @private
|
|
179
|
-
*/
|
|
180
|
-
private executeStep;
|
|
181
|
-
/**
|
|
182
|
-
* Update accumulated context with new result
|
|
183
|
-
*
|
|
184
|
-
* @private
|
|
185
|
-
*/
|
|
186
|
-
private updateAccumulatedContext;
|
|
187
|
-
/**
|
|
188
|
-
* Calculate average confidence across execution history
|
|
189
|
-
*
|
|
190
|
-
* @private
|
|
191
|
-
*/
|
|
192
|
-
private calculateAverageConfidence;
|
|
193
|
-
/**
|
|
194
|
-
* Track context evolution through execution
|
|
195
|
-
*
|
|
196
|
-
* @private
|
|
197
|
-
*/
|
|
198
|
-
private trackContextEvolution;
|
|
199
|
-
/**
|
|
200
|
-
* Set AI planner
|
|
201
|
-
*
|
|
202
|
-
* @param planner AI chain planner instance
|
|
203
|
-
*/
|
|
204
|
-
setPlanner(planner: AIChainPlanner): void;
|
|
205
|
-
/**
|
|
206
|
-
* Get current planner
|
|
207
|
-
*
|
|
208
|
-
* @returns Current AI chain planner
|
|
209
|
-
*/
|
|
210
|
-
getPlanner(): AIChainPlanner;
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Default dynamic chain executor instance
|
|
214
|
-
*/
|
|
215
|
-
export declare let defaultDynamicChainExecutor: DynamicChainExecutor | null;
|
|
216
|
-
/**
|
|
217
|
-
* Initialize default dynamic chain executor
|
|
218
|
-
*
|
|
219
|
-
* @param orchestrator MCP orchestrator
|
|
220
|
-
* @param registry Tool registry
|
|
221
|
-
* @param errorManager Error manager
|
|
222
|
-
* @param planner Optional AI planner
|
|
223
|
-
* @returns Dynamic chain executor instance
|
|
224
|
-
*/
|
|
225
|
-
export declare function initializeDynamicChainExecutor(orchestrator: MCPOrchestrator, registry: MCPRegistry, errorManager: ErrorManager, planner?: AIChainPlanner): DynamicChainExecutor;
|