@juspay/neurolink 5.2.0 → 6.0.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 +82 -2
- package/dist/chat/client-utils.d.ts +3 -0
- package/dist/chat/client-utils.js +22 -5
- package/dist/chat/index.d.ts +4 -7
- package/dist/chat/index.js +0 -8
- package/dist/chat/session-storage.d.ts +2 -2
- package/dist/chat/session.d.ts +4 -3
- package/dist/chat/session.js +1 -1
- package/dist/chat/sse-handler.js +13 -21
- package/dist/chat/types.d.ts +3 -2
- package/dist/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/chat/websocket-chat-handler.js +12 -12
- package/dist/cli/commands/config.d.ts +2 -2
- package/dist/cli/commands/mcp.d.ts +3 -2
- package/dist/cli/commands/mcp.js +39 -29
- package/dist/cli/commands/ollama.js +8 -4
- package/dist/cli/factories/command-factory.d.ts +2 -1
- package/dist/cli/factories/command-factory.js +6 -5
- package/dist/cli/index.js +22 -19
- package/dist/core/analytics.d.ts +3 -2
- package/dist/core/analytics.js +16 -7
- package/dist/core/base-provider.d.ts +35 -7
- package/dist/core/base-provider.js +57 -23
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +1 -0
- package/dist/core/defaults.d.ts +2 -1
- package/dist/core/evaluation.d.ts +4 -4
- package/dist/core/evaluation.js +17 -7
- package/dist/core/factory.d.ts +3 -2
- package/dist/core/service-registry.d.ts +4 -4
- package/dist/core/types.d.ts +11 -4
- package/dist/factories/compatibility-factory.d.ts +16 -1
- package/dist/factories/compatibility-factory.js +3 -1
- package/dist/factories/provider-factory.d.ts +5 -4
- package/dist/factories/provider-factory.js +15 -24
- package/dist/factories/provider-generate-factory.js +26 -20
- package/dist/lib/chat/client-utils.d.ts +3 -0
- package/dist/lib/chat/client-utils.js +22 -5
- package/dist/lib/chat/index.d.ts +4 -7
- package/dist/lib/chat/index.js +0 -8
- package/dist/lib/chat/session-storage.d.ts +2 -2
- package/dist/lib/chat/session.d.ts +4 -3
- package/dist/lib/chat/session.js +1 -1
- package/dist/lib/chat/sse-handler.js +13 -21
- package/dist/lib/chat/types.d.ts +3 -2
- package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
- package/dist/lib/chat/websocket-chat-handler.js +12 -12
- package/dist/lib/core/analytics.d.ts +3 -2
- package/dist/lib/core/analytics.js +16 -7
- package/dist/lib/core/base-provider.d.ts +35 -7
- package/dist/lib/core/base-provider.js +57 -23
- package/dist/lib/core/constants.d.ts +1 -0
- package/dist/lib/core/constants.js +1 -0
- package/dist/lib/core/defaults.d.ts +2 -1
- package/dist/lib/core/evaluation.d.ts +4 -4
- package/dist/lib/core/evaluation.js +17 -7
- package/dist/lib/core/factory.d.ts +3 -2
- package/dist/lib/core/service-registry.d.ts +4 -4
- package/dist/lib/core/types.d.ts +11 -4
- package/dist/lib/factories/compatibility-factory.d.ts +16 -1
- package/dist/lib/factories/compatibility-factory.js +3 -1
- package/dist/lib/factories/provider-factory.d.ts +5 -4
- package/dist/lib/factories/provider-factory.js +15 -24
- package/dist/lib/factories/provider-generate-factory.js +26 -20
- package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/lib/mcp/client.d.ts +3 -1
- package/dist/lib/mcp/client.js +13 -10
- package/dist/lib/mcp/context-manager.d.ts +2 -1
- package/dist/lib/mcp/context-manager.js +8 -4
- package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/lib/mcp/core/plugin-manager.js +1 -1
- package/dist/lib/mcp/demo/plugin-demo.js +3 -1
- package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
- package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/lib/mcp/ecosystem.d.ts +4 -4
- package/dist/lib/mcp/error-manager.d.ts +2 -2
- package/dist/lib/mcp/error-recovery.d.ts +4 -3
- package/dist/lib/mcp/external-client.d.ts +1 -1
- package/dist/lib/mcp/external-client.js +14 -10
- package/dist/lib/mcp/external-manager.d.ts +3 -3
- package/dist/lib/mcp/external-manager.js +9 -3
- package/dist/lib/mcp/factory.d.ts +7 -7
- package/dist/lib/mcp/function-calling.d.ts +14 -0
- package/dist/lib/mcp/function-calling.js +133 -34
- package/dist/lib/mcp/health-monitor.d.ts +2 -1
- package/dist/lib/mcp/health-monitor.js +16 -7
- package/dist/lib/mcp/index.d.ts +5 -5
- package/dist/lib/mcp/initialize-tools.d.ts +2 -1
- package/dist/lib/mcp/initialize-tools.js +10 -2
- package/dist/lib/mcp/manager.d.ts +2 -1
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +22 -6
- package/dist/lib/mcp/orchestrator.d.ts +13 -12
- package/dist/lib/mcp/orchestrator.js +10 -8
- package/dist/lib/mcp/plugin-manager.js +4 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/lib/mcp/registry.d.ts +2 -1
- package/dist/lib/mcp/registry.js +2 -1
- package/dist/lib/mcp/security-manager.d.ts +4 -2
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/lib/mcp/session-manager.d.ts +4 -3
- package/dist/lib/mcp/session-persistence.js +5 -2
- package/dist/lib/mcp/tool-integration.d.ts +3 -2
- package/dist/lib/mcp/tool-integration.js +3 -1
- package/dist/lib/mcp/tool-registry.d.ts +18 -1
- package/dist/lib/mcp/tool-registry.js +11 -8
- package/dist/lib/mcp/transport-manager.d.ts +2 -1
- package/dist/lib/mcp/transport-manager.js +5 -1
- package/dist/lib/mcp/unified-mcp.d.ts +5 -5
- package/dist/lib/mcp/unified-registry.d.ts +18 -2
- package/dist/lib/mcp/unified-registry.js +52 -3
- package/dist/lib/neurolink.d.ts +2 -2
- package/dist/lib/neurolink.js +40 -15
- package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
- package/dist/lib/providers/amazon-bedrock.js +8 -7
- package/dist/lib/providers/analytics-helper.d.ts +8 -23
- package/dist/lib/providers/analytics-helper.js +95 -33
- package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/lib/providers/anthropic-baseprovider.js +6 -5
- package/dist/lib/providers/anthropic.d.ts +2 -2
- package/dist/lib/providers/anthropic.js +11 -4
- package/dist/lib/providers/azure-openai.d.ts +5 -4
- package/dist/lib/providers/azure-openai.js +10 -4
- package/dist/lib/providers/function-calling-provider.d.ts +66 -4
- package/dist/lib/providers/function-calling-provider.js +209 -10
- package/dist/lib/providers/google-ai-studio.d.ts +2 -2
- package/dist/lib/providers/google-ai-studio.js +9 -3
- package/dist/lib/providers/google-vertex.d.ts +2 -2
- package/dist/lib/providers/google-vertex.js +18 -12
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/huggingFace.js +8 -4
- package/dist/lib/providers/mcp-provider.d.ts +3 -3
- package/dist/lib/providers/mcp-provider.js +20 -5
- package/dist/lib/providers/mistral.d.ts +34 -27
- package/dist/lib/providers/mistral.js +115 -107
- package/dist/lib/providers/ollama.d.ts +2 -1
- package/dist/lib/providers/ollama.js +43 -3
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +8 -4
- package/dist/lib/proxy/proxy-fetch.js +3 -2
- package/dist/lib/sdk/tool-extension.d.ts +12 -12
- package/dist/lib/sdk/tool-extension.js +2 -1
- package/dist/lib/sdk/tool-registration.d.ts +16 -12
- package/dist/lib/sdk/tool-registration.js +3 -2
- package/dist/lib/services/streaming/streaming-manager.js +11 -10
- package/dist/lib/services/types.d.ts +5 -4
- package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
- package/dist/lib/services/websocket/websocket-server.js +13 -12
- package/dist/lib/telemetry/telemetry-service.js +9 -8
- package/dist/lib/types/cli.d.ts +247 -0
- package/dist/lib/types/cli.js +22 -0
- package/dist/lib/types/common.d.ts +76 -0
- package/dist/lib/types/common.js +52 -0
- package/dist/lib/types/generate-types.d.ts +6 -6
- package/dist/lib/types/index.d.ts +12 -0
- package/dist/lib/types/index.js +12 -0
- package/dist/lib/types/mcp-types.d.ts +7 -7
- package/dist/lib/types/providers.d.ts +158 -0
- package/dist/lib/types/providers.js +23 -0
- package/dist/lib/types/stream-types.d.ts +4 -3
- package/dist/lib/types/tools.d.ts +154 -0
- package/dist/lib/types/tools.js +24 -0
- package/dist/lib/utils/logger.d.ts +5 -5
- package/dist/lib/utils/provider-validation.d.ts +2 -1
- package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
- package/dist/mcp/adapters/plugin-bridge.js +13 -6
- package/dist/mcp/client.d.ts +3 -1
- package/dist/mcp/client.js +13 -10
- package/dist/mcp/context-manager.d.ts +2 -1
- package/dist/mcp/context-manager.js +8 -4
- package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
- package/dist/mcp/core/plugin-manager.d.ts +3 -2
- package/dist/mcp/core/plugin-manager.js +1 -1
- package/dist/mcp/demo/plugin-demo.js +3 -1
- package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
- package/dist/mcp/dynamic-chain-executor.js +3 -3
- package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
- package/dist/mcp/dynamic-orchestrator.js +1 -1
- package/dist/mcp/ecosystem.d.ts +4 -4
- package/dist/mcp/error-manager.d.ts +2 -2
- package/dist/mcp/error-recovery.d.ts +4 -3
- package/dist/mcp/external-client.d.ts +1 -1
- package/dist/mcp/external-client.js +14 -10
- package/dist/mcp/external-manager.d.ts +3 -3
- package/dist/mcp/external-manager.js +9 -3
- package/dist/mcp/factory.d.ts +7 -7
- package/dist/mcp/function-calling.d.ts +14 -0
- package/dist/mcp/function-calling.js +133 -34
- package/dist/mcp/health-monitor.d.ts +2 -1
- package/dist/mcp/health-monitor.js +16 -7
- package/dist/mcp/index.d.ts +5 -5
- package/dist/mcp/initialize-tools.d.ts +2 -1
- package/dist/mcp/initialize-tools.js +10 -2
- package/dist/mcp/manager.d.ts +2 -1
- package/dist/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/mcp/neurolink-mcp-client.js +22 -6
- package/dist/mcp/orchestrator.d.ts +13 -12
- package/dist/mcp/orchestrator.js +10 -8
- package/dist/mcp/plugin-manager.js +4 -2
- package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
- package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
- package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
- package/dist/mcp/registry.d.ts +2 -1
- package/dist/mcp/registry.js +2 -1
- package/dist/mcp/security-manager.d.ts +4 -2
- package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
- package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
- package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
- package/dist/mcp/session-manager.d.ts +4 -3
- package/dist/mcp/session-persistence.js +5 -2
- package/dist/mcp/tool-integration.d.ts +3 -2
- package/dist/mcp/tool-integration.js +3 -1
- package/dist/mcp/tool-registry.d.ts +18 -1
- package/dist/mcp/tool-registry.js +11 -8
- package/dist/mcp/transport-manager.d.ts +2 -1
- package/dist/mcp/transport-manager.js +5 -1
- package/dist/mcp/unified-mcp.d.ts +5 -5
- package/dist/mcp/unified-registry.d.ts +18 -2
- package/dist/mcp/unified-registry.js +52 -3
- package/dist/neurolink.d.ts +2 -2
- package/dist/neurolink.js +40 -15
- package/dist/providers/amazon-bedrock.d.ts +1 -1
- package/dist/providers/amazon-bedrock.js +8 -7
- package/dist/providers/analytics-helper.d.ts +8 -23
- package/dist/providers/analytics-helper.js +95 -33
- package/dist/providers/anthropic-baseprovider.d.ts +3 -3
- package/dist/providers/anthropic-baseprovider.js +6 -5
- package/dist/providers/anthropic.d.ts +2 -2
- package/dist/providers/anthropic.js +11 -4
- package/dist/providers/azure-openai.d.ts +5 -4
- package/dist/providers/azure-openai.js +10 -4
- package/dist/providers/function-calling-provider.d.ts +66 -4
- package/dist/providers/function-calling-provider.js +209 -10
- package/dist/providers/google-ai-studio.d.ts +2 -2
- package/dist/providers/google-ai-studio.js +9 -3
- package/dist/providers/google-vertex.d.ts +2 -2
- package/dist/providers/google-vertex.js +18 -12
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/huggingFace.js +8 -4
- package/dist/providers/mcp-provider.d.ts +3 -3
- package/dist/providers/mcp-provider.js +20 -5
- package/dist/providers/mistral.d.ts +34 -27
- package/dist/providers/mistral.js +116 -108
- package/dist/providers/ollama.d.ts +2 -1
- package/dist/providers/ollama.js +43 -3
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +8 -4
- package/dist/proxy/proxy-fetch.js +3 -2
- package/dist/sdk/tool-extension.d.ts +12 -12
- package/dist/sdk/tool-extension.js +2 -1
- package/dist/sdk/tool-registration.d.ts +16 -12
- package/dist/sdk/tool-registration.js +3 -2
- package/dist/services/streaming/streaming-manager.js +11 -10
- package/dist/services/types.d.ts +5 -4
- package/dist/services/websocket/websocket-server.d.ts +1 -1
- package/dist/services/websocket/websocket-server.js +14 -12
- package/dist/telemetry/telemetry-service.js +9 -8
- package/dist/types/cli.d.ts +247 -0
- package/dist/types/cli.js +22 -0
- package/dist/types/common.d.ts +76 -0
- package/dist/types/common.js +52 -0
- package/dist/types/generate-types.d.ts +6 -6
- package/dist/types/index.d.ts +12 -0
- package/dist/types/index.js +12 -0
- package/dist/types/mcp-types.d.ts +7 -7
- package/dist/types/providers.d.ts +158 -0
- package/dist/types/providers.js +23 -0
- package/dist/types/stream-types.d.ts +4 -3
- package/dist/types/tools.d.ts +154 -0
- package/dist/types/tools.js +25 -0
- package/dist/utils/logger.d.ts +5 -5
- package/dist/utils/provider-validation.d.ts +2 -1
- package/package.json +12 -10
package/dist/mcp/client.js
CHANGED
|
@@ -49,13 +49,14 @@ export class NeuroLinkMCPClient extends EventEmitter {
|
|
|
49
49
|
return result;
|
|
50
50
|
}
|
|
51
51
|
// If it's in Lighthouse format with content array
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
const lightouseResult = result;
|
|
53
|
+
if (lightouseResult.text &&
|
|
54
|
+
Array.isArray(lightouseResult.text) &&
|
|
55
|
+
lightouseResult.text[0]?.text) {
|
|
55
56
|
try {
|
|
56
|
-
const data = JSON.parse(
|
|
57
|
+
const data = JSON.parse(lightouseResult.text[0].text);
|
|
57
58
|
return {
|
|
58
|
-
success: !
|
|
59
|
+
success: !lightouseResult.isError,
|
|
59
60
|
data,
|
|
60
61
|
metadata: {
|
|
61
62
|
toolName,
|
|
@@ -68,8 +69,8 @@ export class NeuroLinkMCPClient extends EventEmitter {
|
|
|
68
69
|
catch (parseError) {
|
|
69
70
|
// If JSON parsing fails, return the text as-is
|
|
70
71
|
return {
|
|
71
|
-
success: !
|
|
72
|
-
data: { text:
|
|
72
|
+
success: !lightouseResult.isError,
|
|
73
|
+
data: { text: lightouseResult.text[0].text },
|
|
73
74
|
metadata: {
|
|
74
75
|
toolName,
|
|
75
76
|
serverId,
|
|
@@ -80,10 +81,11 @@ export class NeuroLinkMCPClient extends EventEmitter {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
// If it has a direct text property
|
|
83
|
-
|
|
84
|
+
const textResult = result;
|
|
85
|
+
if (textResult.text) {
|
|
84
86
|
return {
|
|
85
87
|
success: true,
|
|
86
|
-
data: { text:
|
|
88
|
+
data: { text: textResult.text },
|
|
87
89
|
metadata: {
|
|
88
90
|
toolName,
|
|
89
91
|
serverId,
|
|
@@ -128,8 +130,9 @@ export class NeuroLinkMCPClient extends EventEmitter {
|
|
|
128
130
|
*/
|
|
129
131
|
getTools() {
|
|
130
132
|
const tools = {};
|
|
131
|
-
for (const [name, tool] of this.tools) {
|
|
133
|
+
for (const [name, tool] of Array.from(this.tools.entries())) {
|
|
132
134
|
tools[name] = {
|
|
135
|
+
name: name, // Include the tool name as a property
|
|
133
136
|
description: tool.description,
|
|
134
137
|
inputSchema: tool.inputSchema,
|
|
135
138
|
};
|
|
@@ -20,7 +20,7 @@ export interface ContextRequest {
|
|
|
20
20
|
frameworkType?: "react" | "vue" | "svelte" | "next" | "nuxt" | "sveltekit";
|
|
21
21
|
permissions?: string[];
|
|
22
22
|
securityLevel?: "public" | "private" | "organization";
|
|
23
|
-
[key: string]:
|
|
23
|
+
[key: string]: unknown;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
26
|
* Context manager for creating and managing execution contexts
|
|
@@ -29,6 +29,7 @@ export interface ContextRequest {
|
|
|
29
29
|
export declare class ContextManager {
|
|
30
30
|
private sessionCounter;
|
|
31
31
|
private activeContexts;
|
|
32
|
+
private static cachedLogger;
|
|
32
33
|
/**
|
|
33
34
|
* Create a new execution context with rich information
|
|
34
35
|
*
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
export class ContextManager {
|
|
11
11
|
sessionCounter = 0;
|
|
12
12
|
activeContexts = new Map();
|
|
13
|
+
static cachedLogger = null;
|
|
13
14
|
/**
|
|
14
15
|
* Create a new execution context with rich information
|
|
15
16
|
*
|
|
@@ -64,6 +65,7 @@ export class ContextManager {
|
|
|
64
65
|
},
|
|
65
66
|
path: {
|
|
66
67
|
join: (...paths) => {
|
|
68
|
+
// Use dynamic require for synchronous path operations
|
|
67
69
|
const path = require("path");
|
|
68
70
|
return path.join(...paths);
|
|
69
71
|
},
|
|
@@ -85,11 +87,13 @@ export class ContextManager {
|
|
|
85
87
|
},
|
|
86
88
|
},
|
|
87
89
|
grantedPermissions: request.permissions || [],
|
|
88
|
-
log: (level, message, data) => {
|
|
89
|
-
// Use logger if available, otherwise
|
|
90
|
+
log: async (level, message, data) => {
|
|
91
|
+
// Use cached logger if available, otherwise import and cache
|
|
90
92
|
try {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
+
if (!ContextManager.cachedLogger) {
|
|
94
|
+
ContextManager.cachedLogger = await import("../utils/logger.js").then(({ logger }) => logger);
|
|
95
|
+
}
|
|
96
|
+
ContextManager.cachedLogger[level](message, data);
|
|
93
97
|
}
|
|
94
98
|
catch {
|
|
95
99
|
console[level === "debug" ? "log" : level](message, data);
|
|
@@ -38,8 +38,14 @@ export interface ExecutionContext {
|
|
|
38
38
|
readFile: (path: string, encoding?: string) => Promise<string | Buffer>;
|
|
39
39
|
writeFile: (path: string, content: string | Buffer) => Promise<void>;
|
|
40
40
|
readdir: (path: string) => Promise<string[]>;
|
|
41
|
-
stat: (path: string) => Promise<
|
|
42
|
-
|
|
41
|
+
stat: (path: string) => Promise<{
|
|
42
|
+
size: number;
|
|
43
|
+
isFile: () => boolean;
|
|
44
|
+
isDirectory: () => boolean;
|
|
45
|
+
}>;
|
|
46
|
+
mkdir: (path: string, options?: {
|
|
47
|
+
recursive?: boolean;
|
|
48
|
+
}) => Promise<void>;
|
|
43
49
|
exists: (path: string) => Promise<boolean>;
|
|
44
50
|
};
|
|
45
51
|
/** Sandboxed path operations */
|
|
@@ -52,20 +58,20 @@ export interface ExecutionContext {
|
|
|
52
58
|
};
|
|
53
59
|
/** Sandboxed network operations (future) */
|
|
54
60
|
secureNet?: {
|
|
55
|
-
fetch: (url: string, options?:
|
|
61
|
+
fetch: (url: string, options?: RequestInit) => Promise<Response>;
|
|
56
62
|
};
|
|
57
63
|
/** Plugin-specific permissions granted */
|
|
58
64
|
grantedPermissions: string[];
|
|
59
65
|
/** Log function for debugging */
|
|
60
|
-
log: (level: "debug" | "info" | "warn" | "error", message: string, data?:
|
|
66
|
+
log: (level: "debug" | "info" | "warn" | "error", message: string, data?: unknown) => void;
|
|
61
67
|
/** Plugin instance reference (for plugin bridge compatibility) */
|
|
62
|
-
plugin?:
|
|
68
|
+
plugin?: unknown;
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* MCP Abstract Class - The Core Contract for All Plugins
|
|
66
72
|
* Uses TypeScript generics for type-safe configuration
|
|
67
73
|
*/
|
|
68
|
-
export declare abstract class MCP<TConfig =
|
|
74
|
+
export declare abstract class MCP<TConfig = unknown, TArgs = unknown, TResult = unknown> {
|
|
69
75
|
/** Static metadata loaded from manifest */
|
|
70
76
|
abstract readonly metadata: MCPMetadata;
|
|
71
77
|
/** Configuration state - accessible to child classes */
|
|
@@ -107,7 +113,7 @@ export declare abstract class MCP<TConfig = any, TArgs = any, TResult = any> {
|
|
|
107
113
|
/**
|
|
108
114
|
* Helper method for logging with context
|
|
109
115
|
*/
|
|
110
|
-
protected log(context: ExecutionContext, level: "debug" | "info" | "warn" | "error", message: string, data?:
|
|
116
|
+
protected log(context: ExecutionContext, level: "debug" | "info" | "warn" | "error", message: string, data?: unknown): void;
|
|
111
117
|
}
|
|
112
118
|
/**
|
|
113
119
|
* Type definitions for plugin registry
|
|
@@ -122,6 +128,7 @@ export interface DiscoveredMCP {
|
|
|
122
128
|
entryPath: string;
|
|
123
129
|
source: "core" | "project" | "installed";
|
|
124
130
|
constructor?: MCPConstructor;
|
|
131
|
+
[key: string]: unknown;
|
|
125
132
|
}
|
|
126
133
|
/**
|
|
127
134
|
* Plugin load result
|
|
@@ -143,7 +150,7 @@ export interface PluginDiscoveryResult {
|
|
|
143
150
|
/**
|
|
144
151
|
* Plugin execution result
|
|
145
152
|
*/
|
|
146
|
-
export interface PluginExecutionResult<T =
|
|
153
|
+
export interface PluginExecutionResult<T = unknown> {
|
|
147
154
|
success: boolean;
|
|
148
155
|
result?: T;
|
|
149
156
|
error?: string;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Enhanced plugin management with advanced lifecycle control
|
|
4
4
|
*/
|
|
5
5
|
import type { MCP, MCPMetadata, MCPConstructor, PluginLoadResult, PluginExecutionResult, ExecutionContext } from "../contracts/mcp-contract.js";
|
|
6
|
+
import type { UnknownRecord, Unknown } from "../../types/common.js";
|
|
6
7
|
/**
|
|
7
8
|
* Enhanced plugin manager with core functionality
|
|
8
9
|
*/
|
|
@@ -13,11 +14,11 @@ export declare class CorePluginManager {
|
|
|
13
14
|
/**
|
|
14
15
|
* Load a plugin from constructor
|
|
15
16
|
*/
|
|
16
|
-
loadPlugin(name: string, Constructor: MCPConstructor, config:
|
|
17
|
+
loadPlugin(name: string, Constructor: MCPConstructor, config: UnknownRecord): Promise<PluginLoadResult>;
|
|
17
18
|
/**
|
|
18
19
|
* Execute a plugin operation
|
|
19
20
|
*/
|
|
20
|
-
executePlugin<T =
|
|
21
|
+
executePlugin<T = Unknown>(name: string, context: ExecutionContext, args: Unknown): Promise<PluginExecutionResult<T>>;
|
|
21
22
|
/**
|
|
22
23
|
* Get plugin instance
|
|
23
24
|
*/
|
|
@@ -42,7 +42,9 @@ export class PluginDemo {
|
|
|
42
42
|
// Try to read a file
|
|
43
43
|
const fsPlugin = new FileSystemMCP();
|
|
44
44
|
await fsPlugin.initialize({ basePath: process.cwd() });
|
|
45
|
-
|
|
45
|
+
// Cast FileSystemMCP to UnknownRecord for executePlugin compatibility
|
|
46
|
+
const pluginAsRecord = fsPlugin;
|
|
47
|
+
const result = await executePlugin(pluginAsRecord, createMockContext(), "listFiles", ".");
|
|
46
48
|
mcpLogger.info("Plugin execution result:", result);
|
|
47
49
|
}
|
|
48
50
|
catch (error) {
|
|
@@ -5,18 +5,69 @@
|
|
|
5
5
|
import type { MCPOrchestrator } from "./orchestrator.js";
|
|
6
6
|
import type { MCPRegistry } from "./registry.js";
|
|
7
7
|
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
8
|
+
import type { JsonValue, UnknownRecord } from "../types/common.js";
|
|
8
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
|
+
}
|
|
9
60
|
/**
|
|
10
61
|
* Tool execution result with metadata
|
|
11
62
|
*/
|
|
12
63
|
export interface ToolExecutionResult {
|
|
13
64
|
toolName: string;
|
|
14
65
|
success: boolean;
|
|
15
|
-
result?:
|
|
66
|
+
result?: JsonValue;
|
|
16
67
|
error?: Error;
|
|
17
68
|
timestamp: number;
|
|
18
69
|
executionTime: number;
|
|
19
|
-
context?:
|
|
70
|
+
context?: UnknownRecord;
|
|
20
71
|
}
|
|
21
72
|
/**
|
|
22
73
|
* Chain execution step
|
|
@@ -24,7 +75,7 @@ export interface ToolExecutionResult {
|
|
|
24
75
|
export interface ChainStep {
|
|
25
76
|
stepId: string;
|
|
26
77
|
toolName: string;
|
|
27
|
-
parameters:
|
|
78
|
+
parameters: ToolExecutionParameters;
|
|
28
79
|
reasoning: string;
|
|
29
80
|
confidence: number;
|
|
30
81
|
expectedOutcome: string;
|
|
@@ -37,7 +88,7 @@ export interface ChainExecutionContext {
|
|
|
37
88
|
currentStep: number;
|
|
38
89
|
totalSteps?: number;
|
|
39
90
|
executionHistory: ToolExecutionResult[];
|
|
40
|
-
accumulatedContext:
|
|
91
|
+
accumulatedContext: UnknownRecord;
|
|
41
92
|
userContext?: NeuroLinkExecutionContext;
|
|
42
93
|
maxSteps: number;
|
|
43
94
|
aiModel?: string;
|
|
@@ -51,13 +102,13 @@ export interface ChainExecutionResult {
|
|
|
51
102
|
totalSteps: number;
|
|
52
103
|
executionTime: number;
|
|
53
104
|
results: ToolExecutionResult[];
|
|
54
|
-
finalResult?:
|
|
105
|
+
finalResult?: JsonValue;
|
|
55
106
|
reasoning: string;
|
|
56
107
|
error?: Error;
|
|
57
108
|
metadata: {
|
|
58
109
|
toolsUsed: string[];
|
|
59
110
|
averageConfidence: number;
|
|
60
|
-
contextEvolution:
|
|
111
|
+
contextEvolution: ContextEvolutionEntry[];
|
|
61
112
|
};
|
|
62
113
|
}
|
|
63
114
|
/**
|
|
@@ -65,34 +116,16 @@ export interface ChainExecutionResult {
|
|
|
65
116
|
*/
|
|
66
117
|
export interface AIChainPlanner {
|
|
67
118
|
name: string;
|
|
68
|
-
planNextStep(goal: string, availableTools:
|
|
69
|
-
|
|
70
|
-
description: string;
|
|
71
|
-
inputSchema: any;
|
|
72
|
-
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
73
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
74
|
-
goalAchieved: boolean;
|
|
75
|
-
confidence: number;
|
|
76
|
-
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
77
|
-
reasoning: string;
|
|
78
|
-
}>;
|
|
119
|
+
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
120
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
79
121
|
}
|
|
80
122
|
/**
|
|
81
123
|
* Simple AI Chain Planner using heuristics
|
|
82
124
|
*/
|
|
83
125
|
export declare class HeuristicChainPlanner implements AIChainPlanner {
|
|
84
126
|
name: string;
|
|
85
|
-
planNextStep(goal: string, availableTools:
|
|
86
|
-
|
|
87
|
-
description: string;
|
|
88
|
-
inputSchema: any;
|
|
89
|
-
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
90
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
91
|
-
goalAchieved: boolean;
|
|
92
|
-
confidence: number;
|
|
93
|
-
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
94
|
-
reasoning: string;
|
|
95
|
-
}>;
|
|
127
|
+
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
128
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
96
129
|
private generateParameters;
|
|
97
130
|
}
|
|
98
131
|
/**
|
|
@@ -102,17 +135,8 @@ export declare class AIModelChainPlanner implements AIChainPlanner {
|
|
|
102
135
|
name: string;
|
|
103
136
|
private aiModel;
|
|
104
137
|
constructor(aiModel?: string);
|
|
105
|
-
planNextStep(goal: string, availableTools:
|
|
106
|
-
|
|
107
|
-
description: string;
|
|
108
|
-
inputSchema: any;
|
|
109
|
-
}>, executionHistory: ToolExecutionResult[], accumulatedContext: Record<string, any>): Promise<ChainStep | null>;
|
|
110
|
-
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<{
|
|
111
|
-
goalAchieved: boolean;
|
|
112
|
-
confidence: number;
|
|
113
|
-
nextAction: "continue" | "retry" | "abort" | "complete";
|
|
114
|
-
reasoning: string;
|
|
115
|
-
}>;
|
|
138
|
+
planNextStep(goal: string, availableTools: AvailableToolDescriptor[], executionHistory: ToolExecutionResult[], accumulatedContext: UnknownRecord): Promise<ChainStep | null>;
|
|
139
|
+
evaluateResult(step: ChainStep, result: ToolExecutionResult, goal: string): Promise<AIEvaluationResponse>;
|
|
116
140
|
private buildPlanningPrompt;
|
|
117
141
|
private buildEvaluationPrompt;
|
|
118
142
|
private callAIModel;
|
|
@@ -137,7 +161,7 @@ export declare class DynamicChainExecutor {
|
|
|
137
161
|
* @param options Execution options
|
|
138
162
|
* @returns Chain execution result
|
|
139
163
|
*/
|
|
140
|
-
executeChain(goal: string, initialContext?:
|
|
164
|
+
executeChain(goal: string, initialContext?: UnknownRecord, userContext?: NeuroLinkExecutionContext, options?: {
|
|
141
165
|
maxSteps?: number;
|
|
142
166
|
aiModel?: string;
|
|
143
167
|
timeout?: number;
|
|
@@ -82,7 +82,7 @@ export class HeuristicChainPlanner {
|
|
|
82
82
|
const lastResult = history[history.length - 1];
|
|
83
83
|
if (lastResult?.result) {
|
|
84
84
|
// Pass relevant data from previous step
|
|
85
|
-
if (typeof lastResult.result === "object") {
|
|
85
|
+
if (typeof lastResult.result === "object" && lastResult.result !== null) {
|
|
86
86
|
Object.assign(params, lastResult.result);
|
|
87
87
|
}
|
|
88
88
|
else if (typeof lastResult.result === "string") {
|
|
@@ -378,7 +378,7 @@ export class DynamicChainExecutor {
|
|
|
378
378
|
return {
|
|
379
379
|
toolName: step.toolName,
|
|
380
380
|
success: true,
|
|
381
|
-
result,
|
|
381
|
+
result: result,
|
|
382
382
|
timestamp: Date.now(),
|
|
383
383
|
executionTime: Date.now() - startTime,
|
|
384
384
|
context: {
|
|
@@ -445,7 +445,7 @@ export class DynamicChainExecutor {
|
|
|
445
445
|
evolution.push({
|
|
446
446
|
step: result.toolName,
|
|
447
447
|
timestamp: result.timestamp,
|
|
448
|
-
dataKeys: typeof result.result === "object"
|
|
448
|
+
dataKeys: typeof result.result === "object" && result.result !== null
|
|
449
449
|
? Object.keys(result.result)
|
|
450
450
|
: ["primitive"],
|
|
451
451
|
});
|
|
@@ -6,12 +6,18 @@
|
|
|
6
6
|
import { MCPOrchestrator } from "./orchestrator.js";
|
|
7
7
|
import type { ToolResult } from "./factory.js";
|
|
8
8
|
import type { ContextRequest } from "./context-manager.js";
|
|
9
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
10
|
+
import { ErrorManager } from "./error-manager.js";
|
|
11
|
+
import type { MCPToolRegistry } from "./tool-registry.js";
|
|
12
|
+
import type { ContextManager } from "./context-manager.js";
|
|
13
|
+
import type { SemaphoreManager } from "./semaphore-manager.js";
|
|
14
|
+
import type { SessionManager } from "./session-manager.js";
|
|
9
15
|
/**
|
|
10
16
|
* Tool decision made by AI
|
|
11
17
|
*/
|
|
12
18
|
export interface ToolDecision {
|
|
13
19
|
toolName: string;
|
|
14
|
-
args:
|
|
20
|
+
args: UnknownRecord;
|
|
15
21
|
reasoning: string;
|
|
16
22
|
confidence: number;
|
|
17
23
|
shouldContinue: boolean;
|
|
@@ -42,7 +48,7 @@ export interface DynamicToolChainResult {
|
|
|
42
48
|
* Dynamic orchestrator with AI-driven tool selection
|
|
43
49
|
*/
|
|
44
50
|
export declare class DynamicOrchestrator extends MCPOrchestrator {
|
|
45
|
-
constructor(registry?:
|
|
51
|
+
constructor(registry?: MCPToolRegistry, contextManager?: ContextManager, semaphoreManager?: SemaphoreManager, sessionManager?: SessionManager, errorManager?: ErrorManager);
|
|
46
52
|
private defaultOptions;
|
|
47
53
|
/**
|
|
48
54
|
* Execute a dynamic tool chain where AI decides which tools to use
|
|
@@ -86,11 +92,11 @@ export declare class DynamicOrchestrator extends MCPOrchestrator {
|
|
|
86
92
|
reasoningCapture: boolean;
|
|
87
93
|
};
|
|
88
94
|
};
|
|
89
|
-
registry:
|
|
90
|
-
context:
|
|
91
|
-
session:
|
|
92
|
-
error:
|
|
93
|
-
health?:
|
|
95
|
+
registry: UnknownRecord;
|
|
96
|
+
context: UnknownRecord;
|
|
97
|
+
session: UnknownRecord;
|
|
98
|
+
error: UnknownRecord;
|
|
99
|
+
health?: UnknownRecord;
|
|
94
100
|
orchestrator: {
|
|
95
101
|
pipelinesExecuted: number;
|
|
96
102
|
};
|
|
@@ -106,4 +112,4 @@ export declare class DynamicOrchestrator extends MCPOrchestrator {
|
|
|
106
112
|
* @param errorManager Error manager (optional)
|
|
107
113
|
* @returns Dynamic orchestrator instance
|
|
108
114
|
*/
|
|
109
|
-
export declare function createDynamicOrchestrator(registry:
|
|
115
|
+
export declare function createDynamicOrchestrator(registry: MCPToolRegistry, contextManager: ContextManager, semaphoreManager?: SemaphoreManager, sessionManager?: SessionManager, errorManager?: ErrorManager): DynamicOrchestrator;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { MCPOrchestrator } from "./orchestrator.js";
|
|
7
7
|
import { createExecutionContext } from "./context-manager.js";
|
|
8
|
-
import { ErrorCategory, ErrorSeverity } from "./error-manager.js";
|
|
8
|
+
import { ErrorCategory, ErrorSeverity, ErrorManager } from "./error-manager.js";
|
|
9
9
|
import { aiCoreServer } from "./servers/ai-providers/ai-core-server.js";
|
|
10
10
|
/**
|
|
11
11
|
* AI prompt templates for tool selection
|
package/dist/mcp/ecosystem.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class MCPEcosystem {
|
|
|
28
28
|
/**
|
|
29
29
|
* Create and execute an MCP instance
|
|
30
30
|
*/
|
|
31
|
-
execute<T =
|
|
31
|
+
execute<T = unknown>(name: string, config: unknown, args: unknown, context?: {
|
|
32
32
|
sessionId?: string;
|
|
33
33
|
userId?: string;
|
|
34
34
|
}): Promise<T>;
|
|
@@ -40,7 +40,7 @@ export declare class MCPEcosystem {
|
|
|
40
40
|
path: string;
|
|
41
41
|
content?: string;
|
|
42
42
|
basePath?: string;
|
|
43
|
-
}): Promise<
|
|
43
|
+
}): Promise<unknown>;
|
|
44
44
|
/**
|
|
45
45
|
* Get ecosystem statistics
|
|
46
46
|
*/
|
|
@@ -53,7 +53,7 @@ export declare class MCPEcosystem {
|
|
|
53
53
|
/**
|
|
54
54
|
* Create an MCP instance for direct use
|
|
55
55
|
*/
|
|
56
|
-
createInstance<T extends MCP>(name: string, config:
|
|
56
|
+
createInstance<T extends MCP>(name: string, config: unknown): Promise<T>;
|
|
57
57
|
/**
|
|
58
58
|
* Create execution context for manual MCP usage
|
|
59
59
|
*/
|
|
@@ -65,7 +65,7 @@ export declare class MCPEcosystem {
|
|
|
65
65
|
/**
|
|
66
66
|
* Get all tools formatted for AI providers
|
|
67
67
|
*/
|
|
68
|
-
getToolsForAI(): Promise<
|
|
68
|
+
getToolsForAI(): Promise<Record<string, unknown>>;
|
|
69
69
|
/**
|
|
70
70
|
* Dispose of all resources
|
|
71
71
|
*/
|
|
@@ -38,7 +38,7 @@ export interface ErrorEntry {
|
|
|
38
38
|
context: {
|
|
39
39
|
sessionId?: string;
|
|
40
40
|
toolName?: string;
|
|
41
|
-
parameters?:
|
|
41
|
+
parameters?: unknown;
|
|
42
42
|
executionContext?: NeuroLinkExecutionContext;
|
|
43
43
|
};
|
|
44
44
|
stackTrace?: string;
|
|
@@ -103,7 +103,7 @@ export declare class ErrorManager {
|
|
|
103
103
|
severity?: ErrorSeverity;
|
|
104
104
|
sessionId?: string;
|
|
105
105
|
toolName?: string;
|
|
106
|
-
parameters?:
|
|
106
|
+
parameters?: unknown;
|
|
107
107
|
executionContext?: NeuroLinkExecutionContext;
|
|
108
108
|
}): Promise<ErrorEntry>;
|
|
109
109
|
/**
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { ErrorEntry, ErrorSeverity } from "./error-manager.js";
|
|
7
7
|
import type { NeuroLinkExecutionContext } from "./factory.js";
|
|
8
|
+
import type { UnknownRecord } from "../types/common.js";
|
|
8
9
|
/**
|
|
9
10
|
* Circuit breaker states
|
|
10
11
|
*/
|
|
@@ -16,7 +17,7 @@ export declare enum CircuitState {
|
|
|
16
17
|
/**
|
|
17
18
|
* Retry strategy configuration
|
|
18
19
|
*/
|
|
19
|
-
export interface RetryConfig {
|
|
20
|
+
export interface RetryConfig extends UnknownRecord {
|
|
20
21
|
maxAttempts: number;
|
|
21
22
|
initialDelay: number;
|
|
22
23
|
maxDelay: number;
|
|
@@ -26,7 +27,7 @@ export interface RetryConfig {
|
|
|
26
27
|
/**
|
|
27
28
|
* Circuit breaker configuration
|
|
28
29
|
*/
|
|
29
|
-
export interface CircuitBreakerConfig {
|
|
30
|
+
export interface CircuitBreakerConfig extends UnknownRecord {
|
|
30
31
|
failureThreshold: number;
|
|
31
32
|
resetTimeout: number;
|
|
32
33
|
successThreshold: number;
|
|
@@ -48,7 +49,7 @@ export interface ErrorPattern {
|
|
|
48
49
|
*/
|
|
49
50
|
export interface RecoveryStrategy {
|
|
50
51
|
type: "retry" | "circuit-breaker" | "fallback" | "manual";
|
|
51
|
-
config?:
|
|
52
|
+
config?: UnknownRecord;
|
|
52
53
|
action?: (context: RecoveryContext) => Promise<RecoveryResult>;
|
|
53
54
|
}
|
|
54
55
|
/**
|
|
@@ -44,7 +44,7 @@ export declare class ExternalMCPClient extends EventEmitter {
|
|
|
44
44
|
/**
|
|
45
45
|
* Execute a tool on the external server
|
|
46
46
|
*/
|
|
47
|
-
executeTool(toolName: string, params:
|
|
47
|
+
executeTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
|
|
48
48
|
/**
|
|
49
49
|
* Get available tools as NeuroLink MCP tools
|
|
50
50
|
*/
|
|
@@ -105,13 +105,15 @@ export class ExternalMCPClient extends EventEmitter {
|
|
|
105
105
|
async discoverTools() {
|
|
106
106
|
try {
|
|
107
107
|
const response = await this.sendRequest("tools/list", {});
|
|
108
|
-
|
|
108
|
+
const responseObj = response;
|
|
109
|
+
if (responseObj.tools && Array.isArray(responseObj.tools)) {
|
|
109
110
|
this.tools.clear();
|
|
110
|
-
for (const tool of
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
for (const tool of responseObj.tools) {
|
|
112
|
+
const toolObj = tool;
|
|
113
|
+
this.tools.set(toolObj.name || "unknown", {
|
|
114
|
+
name: toolObj.name || "unknown",
|
|
115
|
+
description: toolObj.description || "",
|
|
116
|
+
inputSchema: toolObj.inputSchema,
|
|
115
117
|
});
|
|
116
118
|
}
|
|
117
119
|
logger.debug(`[External MCP] Discovered ${this.tools.size} tools from ${this.config.name}`);
|
|
@@ -137,9 +139,10 @@ export class ExternalMCPClient extends EventEmitter {
|
|
|
137
139
|
});
|
|
138
140
|
const executionTime = Date.now() - startTime;
|
|
139
141
|
// Transform MCP response to NeuroLink format
|
|
142
|
+
const responseObj = response;
|
|
140
143
|
const result = {
|
|
141
|
-
success: !
|
|
142
|
-
data:
|
|
144
|
+
success: !responseObj.isError,
|
|
145
|
+
data: responseObj.text || responseObj.result || response,
|
|
143
146
|
metadata: {
|
|
144
147
|
toolName,
|
|
145
148
|
serverId: this.config.name,
|
|
@@ -149,8 +152,9 @@ export class ExternalMCPClient extends EventEmitter {
|
|
|
149
152
|
executionTime,
|
|
150
153
|
},
|
|
151
154
|
};
|
|
152
|
-
if (
|
|
153
|
-
|
|
155
|
+
if (responseObj.isError) {
|
|
156
|
+
const textArray = responseObj.text;
|
|
157
|
+
result.error = textArray?.[0]?.text || "Tool execution failed";
|
|
154
158
|
}
|
|
155
159
|
logger.debug(`[External MCP] Tool ${toolName} executed in ${executionTime}ms`);
|
|
156
160
|
return result;
|
|
@@ -11,8 +11,8 @@ import { MCPToolRegistry } from "./tool-registry.js";
|
|
|
11
11
|
*/
|
|
12
12
|
interface ExternalServerInfo {
|
|
13
13
|
name: string;
|
|
14
|
-
client: ExternalMCPClient;
|
|
15
|
-
server: NeuroLinkMCPServer;
|
|
14
|
+
client: ExternalMCPClient | null;
|
|
15
|
+
server: NeuroLinkMCPServer | null;
|
|
16
16
|
status: "connecting" | "connected" | "disconnected" | "error";
|
|
17
17
|
lastError?: string;
|
|
18
18
|
toolCount: number;
|
|
@@ -61,7 +61,7 @@ export declare class ExternalMCPManager {
|
|
|
61
61
|
/**
|
|
62
62
|
* Execute a tool on any connected server
|
|
63
63
|
*/
|
|
64
|
-
executeTool(toolName: string, params:
|
|
64
|
+
executeTool(toolName: string, params: unknown, context: NeuroLinkExecutionContext): Promise<ToolResult>;
|
|
65
65
|
/**
|
|
66
66
|
* List all available tools from external servers
|
|
67
67
|
*/
|