@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,71 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compatibility conversion factory for seamless migration
|
|
3
|
-
* between generateText and generate functions
|
|
4
|
-
*/
|
|
5
|
-
export class CompatibilityConversionFactory {
|
|
6
|
-
/**
|
|
7
|
-
* Convert TextGenerationOptions to GenerateOptions
|
|
8
|
-
*/
|
|
9
|
-
static convertTextToGenerate(options) {
|
|
10
|
-
const { prompt, ...rest } = options;
|
|
11
|
-
return {
|
|
12
|
-
input: { text: prompt || "" },
|
|
13
|
-
output: { format: "text" },
|
|
14
|
-
provider: rest.provider,
|
|
15
|
-
model: rest.model,
|
|
16
|
-
temperature: rest.temperature,
|
|
17
|
-
maxTokens: rest.maxTokens,
|
|
18
|
-
systemPrompt: rest.systemPrompt,
|
|
19
|
-
schema: rest.schema,
|
|
20
|
-
tools: rest.tools,
|
|
21
|
-
timeout: rest.timeout,
|
|
22
|
-
enableEvaluation: rest.enableEvaluation,
|
|
23
|
-
enableAnalytics: rest.enableAnalytics,
|
|
24
|
-
context: rest.context,
|
|
25
|
-
evaluationDomain: rest.evaluationDomain,
|
|
26
|
-
toolUsageContext: rest.toolUsageContext,
|
|
27
|
-
conversationHistory: rest.conversationHistory,
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Convert GenerateResult to legacy TextGenerationResult format
|
|
32
|
-
*/
|
|
33
|
-
static convertGenerateToText(result) {
|
|
34
|
-
return {
|
|
35
|
-
content: result.content,
|
|
36
|
-
provider: result.provider,
|
|
37
|
-
model: result.model,
|
|
38
|
-
usage: result.usage,
|
|
39
|
-
responseTime: result.responseTime,
|
|
40
|
-
toolsUsed: Array.isArray(result.toolsUsed)
|
|
41
|
-
? result.toolsUsed.length
|
|
42
|
-
: result.toolsUsed,
|
|
43
|
-
toolExecutions: result.toolExecutions,
|
|
44
|
-
enhancedWithTools: result.enhancedWithTools,
|
|
45
|
-
availableTools: result.availableTools,
|
|
46
|
-
analytics: result.analytics,
|
|
47
|
-
evaluation: result.evaluation,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Convert GenerateOptions to TextGenerationOptions
|
|
52
|
-
*/
|
|
53
|
-
static convertGenerateToText_Options(options) {
|
|
54
|
-
return {
|
|
55
|
-
prompt: options.input.text,
|
|
56
|
-
model: options.model,
|
|
57
|
-
temperature: options.temperature,
|
|
58
|
-
maxTokens: options.maxTokens,
|
|
59
|
-
systemPrompt: options.systemPrompt,
|
|
60
|
-
schema: options.schema,
|
|
61
|
-
tools: options.tools,
|
|
62
|
-
timeout: options.timeout,
|
|
63
|
-
enableEvaluation: options.enableEvaluation,
|
|
64
|
-
enableAnalytics: options.enableAnalytics,
|
|
65
|
-
context: options.context,
|
|
66
|
-
evaluationDomain: options.evaluationDomain,
|
|
67
|
-
toolUsageContext: options.toolUsageContext,
|
|
68
|
-
conversationHistory: options.conversationHistory,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { EnhancedProvider } from "../types/generate-types.js";
|
|
2
|
-
import type { AIProvider } from "../core/types.js";
|
|
3
|
-
/**
|
|
4
|
-
* Factory for enhancing providers with generate() capability using Proxy pattern
|
|
5
|
-
* Maintains 100% backward compatibility while adding new generate method
|
|
6
|
-
*/
|
|
7
|
-
export declare class ProviderGenerateFactory {
|
|
8
|
-
/**
|
|
9
|
-
* Enhance any provider with generate() method using TypeScript Proxy
|
|
10
|
-
*/
|
|
11
|
-
static enhanceProvider<T extends AIProvider>(provider: T): T & EnhancedProvider;
|
|
12
|
-
/**
|
|
13
|
-
* Create the generate() method that internally uses generateText for performance parity
|
|
14
|
-
*/
|
|
15
|
-
private static createGenerateMethod;
|
|
16
|
-
/**
|
|
17
|
-
* Enhance all providers from a registry
|
|
18
|
-
*/
|
|
19
|
-
static enhanceAllProviders(providers: Map<string, AIProvider>): Map<string, AIProvider & EnhancedProvider>;
|
|
20
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { CompatibilityConversionFactory } from "./compatibility-factory.js";
|
|
2
|
-
/**
|
|
3
|
-
* Factory for enhancing providers with generate() capability using Proxy pattern
|
|
4
|
-
* Maintains 100% backward compatibility while adding new generate method
|
|
5
|
-
*/
|
|
6
|
-
export class ProviderGenerateFactory {
|
|
7
|
-
/**
|
|
8
|
-
* Enhance any provider with generate() method using TypeScript Proxy
|
|
9
|
-
*/
|
|
10
|
-
static enhanceProvider(provider) {
|
|
11
|
-
return new Proxy(provider, {
|
|
12
|
-
get(target, prop, receiver) {
|
|
13
|
-
if (prop === "generate") {
|
|
14
|
-
return ProviderGenerateFactory.createGenerateMethod(target);
|
|
15
|
-
}
|
|
16
|
-
return Reflect.get(target, prop, receiver);
|
|
17
|
-
},
|
|
18
|
-
has(target, prop) {
|
|
19
|
-
if (prop === "generate") {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return Reflect.has(target, prop);
|
|
23
|
-
},
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Create the generate() method that internally uses generateText for performance parity
|
|
28
|
-
*/
|
|
29
|
-
static createGenerateMethod(provider) {
|
|
30
|
-
return async (options) => {
|
|
31
|
-
// Validate input
|
|
32
|
-
if (!options.input?.text) {
|
|
33
|
-
throw new Error("Generate options must include input.text");
|
|
34
|
-
}
|
|
35
|
-
// Convert GenerateOptions to TextGenerationOptions
|
|
36
|
-
const textOptions = CompatibilityConversionFactory.convertGenerateToText_Options(options);
|
|
37
|
-
try {
|
|
38
|
-
// Use existing generate method for identical performance
|
|
39
|
-
const textResult = await provider.generate(textOptions);
|
|
40
|
-
if (!textResult) {
|
|
41
|
-
throw new Error("Generate method returned null result");
|
|
42
|
-
}
|
|
43
|
-
// Convert back to GenerateResult format with type safety
|
|
44
|
-
const generateResult = {
|
|
45
|
-
content: textResult.content || "",
|
|
46
|
-
outputs: { text: textResult.content || "" },
|
|
47
|
-
provider: textResult.provider,
|
|
48
|
-
model: textResult.model,
|
|
49
|
-
usage: textResult.usage
|
|
50
|
-
? {
|
|
51
|
-
inputTokens: textResult.usage.inputTokens || 0,
|
|
52
|
-
outputTokens: textResult.usage.outputTokens || 0,
|
|
53
|
-
totalTokens: textResult.usage.totalTokens || 0,
|
|
54
|
-
}
|
|
55
|
-
: undefined,
|
|
56
|
-
responseTime: textResult.responseTime,
|
|
57
|
-
toolsUsed: textResult.toolsUsed,
|
|
58
|
-
toolExecutions: textResult.toolExecutions?.map((te) => {
|
|
59
|
-
const toolExecution = te;
|
|
60
|
-
return {
|
|
61
|
-
name: toolExecution.toolName || toolExecution.name || "",
|
|
62
|
-
input: toolExecution.input || {},
|
|
63
|
-
output: toolExecution.output || toolExecution.result,
|
|
64
|
-
duration: toolExecution.executionTime || toolExecution.duration || 0,
|
|
65
|
-
};
|
|
66
|
-
}),
|
|
67
|
-
enhancedWithTools: textResult.enhancedWithTools,
|
|
68
|
-
availableTools: textResult.availableTools?.map((at) => ({
|
|
69
|
-
name: at.name || "",
|
|
70
|
-
description: at.description || "",
|
|
71
|
-
parameters: at.parameters || {},
|
|
72
|
-
})),
|
|
73
|
-
analytics: textResult.analytics,
|
|
74
|
-
evaluation: textResult.evaluation,
|
|
75
|
-
};
|
|
76
|
-
return generateResult;
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
throw new Error(`Generate method failed: ${error}`);
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Enhance all providers from a registry
|
|
85
|
-
*/
|
|
86
|
-
static enhanceAllProviders(providers) {
|
|
87
|
-
const enhancedProviders = new Map();
|
|
88
|
-
for (const [name, provider] of providers) {
|
|
89
|
-
enhancedProviders.set(name, this.enhanceProvider(provider));
|
|
90
|
-
}
|
|
91
|
-
return enhancedProviders;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Bridge Adapter
|
|
3
|
-
* Provides compatibility layer for existing MCP integrations
|
|
4
|
-
*/
|
|
5
|
-
import type { ExecutionContext } from "../contracts/mcp-contract.js";
|
|
6
|
-
import type { JsonValue, UnknownRecord, Unknown } from "../../types/common.js";
|
|
7
|
-
/**
|
|
8
|
-
* Bridge interface for legacy MCP compatibility
|
|
9
|
-
*/
|
|
10
|
-
export interface LegacyMCPBridge {
|
|
11
|
-
writeFile: (filePath: string, content: string) => Promise<void>;
|
|
12
|
-
readFile: (filePath: string) => Promise<string>;
|
|
13
|
-
listFiles: (dirPath: string) => Promise<string[]>;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Create a bridge for legacy MCP integrations
|
|
17
|
-
*/
|
|
18
|
-
export declare function createLegacyBridge(context: ExecutionContext): LegacyMCPBridge;
|
|
19
|
-
/**
|
|
20
|
-
* Enhanced execution context with bridge compatibility
|
|
21
|
-
*/
|
|
22
|
-
export declare function enhanceExecutionContext(context: ExecutionContext): ExecutionContext;
|
|
23
|
-
/**
|
|
24
|
-
* Utility function to adapt legacy MCP calls
|
|
25
|
-
*/
|
|
26
|
-
export declare function adaptLegacyMCPCall(context: ExecutionContext, operation: string, ...args: JsonValue[]): Promise<Unknown>;
|
|
27
|
-
/**
|
|
28
|
-
* Quick plugin factory for simple plugin creation
|
|
29
|
-
*/
|
|
30
|
-
export declare class QuickPluginFactory {
|
|
31
|
-
static create(name: string, config: UnknownRecord): Promise<{
|
|
32
|
-
name: string;
|
|
33
|
-
config: UnknownRecord;
|
|
34
|
-
initialized: boolean;
|
|
35
|
-
}>;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Execute plugin with enhanced context
|
|
39
|
-
*/
|
|
40
|
-
export declare function executePlugin(plugin: UnknownRecord, context: ExecutionContext, operation: string, ...args: JsonValue[]): Promise<Unknown>;
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Plugin Bridge Adapter
|
|
3
|
-
* Provides compatibility layer for existing MCP integrations
|
|
4
|
-
*/
|
|
5
|
-
import * as path from "path";
|
|
6
|
-
/**
|
|
7
|
-
* Create a bridge for legacy MCP integrations
|
|
8
|
-
*/
|
|
9
|
-
export function createLegacyBridge(context) {
|
|
10
|
-
const basePath = process.cwd();
|
|
11
|
-
return {
|
|
12
|
-
async writeFile(filePath, content) {
|
|
13
|
-
const fullPath = path.resolve(basePath, filePath);
|
|
14
|
-
await context.secureFS.writeFile(fullPath, content);
|
|
15
|
-
},
|
|
16
|
-
async readFile(filePath) {
|
|
17
|
-
const fullPath = path.resolve(basePath, filePath);
|
|
18
|
-
const result = await context.secureFS.readFile(fullPath, "utf-8");
|
|
19
|
-
return typeof result === "string" ? result : result.toString();
|
|
20
|
-
},
|
|
21
|
-
async listFiles(dirPath) {
|
|
22
|
-
const fullPath = path.resolve(basePath, dirPath);
|
|
23
|
-
return await context.secureFS.readdir(fullPath);
|
|
24
|
-
},
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Enhanced execution context with bridge compatibility
|
|
29
|
-
*/
|
|
30
|
-
export function enhanceExecutionContext(context) {
|
|
31
|
-
return {
|
|
32
|
-
...context,
|
|
33
|
-
path: {
|
|
34
|
-
join: path.join,
|
|
35
|
-
resolve: path.resolve,
|
|
36
|
-
relative: path.relative,
|
|
37
|
-
dirname: path.dirname,
|
|
38
|
-
basename: path.basename,
|
|
39
|
-
},
|
|
40
|
-
plugin: createLegacyBridge(context),
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Utility function to adapt legacy MCP calls
|
|
45
|
-
*/
|
|
46
|
-
export async function adaptLegacyMCPCall(context, operation, ...args) {
|
|
47
|
-
const bridge = createLegacyBridge(context);
|
|
48
|
-
switch (operation) {
|
|
49
|
-
case "writeFile": {
|
|
50
|
-
const filePath = typeof args[0] === "string" ? args[0] : String(args[0]);
|
|
51
|
-
const content = typeof args[1] === "string" ? args[1] : String(args[1]);
|
|
52
|
-
return bridge.writeFile(filePath, content);
|
|
53
|
-
}
|
|
54
|
-
case "readFile": {
|
|
55
|
-
const readPath = typeof args[0] === "string" ? args[0] : String(args[0]);
|
|
56
|
-
return bridge.readFile(readPath);
|
|
57
|
-
}
|
|
58
|
-
case "listFiles": {
|
|
59
|
-
const listPath = typeof args[0] === "string" ? args[0] : String(args[0]);
|
|
60
|
-
return bridge.listFiles(listPath);
|
|
61
|
-
}
|
|
62
|
-
default:
|
|
63
|
-
throw new Error(`Unsupported legacy operation: ${operation}`);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Quick plugin factory for simple plugin creation
|
|
68
|
-
*/
|
|
69
|
-
export class QuickPluginFactory {
|
|
70
|
-
static async create(name, config) {
|
|
71
|
-
// Simple factory implementation
|
|
72
|
-
return {
|
|
73
|
-
name,
|
|
74
|
-
config,
|
|
75
|
-
initialized: true,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Execute plugin with enhanced context
|
|
81
|
-
*/
|
|
82
|
-
export async function executePlugin(plugin, context, operation, ...args) {
|
|
83
|
-
const enhancedContext = enhanceExecutionContext(context);
|
|
84
|
-
if (typeof plugin.execute === "function") {
|
|
85
|
-
return plugin.execute(enhancedContext, { operation, args });
|
|
86
|
-
}
|
|
87
|
-
// Fallback to legacy adaptation
|
|
88
|
-
return adaptLegacyMCPCall(enhancedContext, operation, ...args);
|
|
89
|
-
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Discovery Module for MCP Plugins
|
|
3
|
-
* Handles automatic plugin discovery and registration
|
|
4
|
-
*/
|
|
5
|
-
import type { DiscoveredMCP } from "./contracts/mcp-contract.js";
|
|
6
|
-
/**
|
|
7
|
-
* Auto-discovery configuration
|
|
8
|
-
*/
|
|
9
|
-
interface AutoDiscoveryConfig {
|
|
10
|
-
searchPaths: string[];
|
|
11
|
-
manifestName: string;
|
|
12
|
-
maxDepth: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Auto-discovery service for MCP plugins
|
|
16
|
-
*/
|
|
17
|
-
export declare class AutoDiscovery {
|
|
18
|
-
private config;
|
|
19
|
-
constructor(config?: Partial<AutoDiscoveryConfig>);
|
|
20
|
-
/**
|
|
21
|
-
* Discover all available MCP plugins
|
|
22
|
-
*/
|
|
23
|
-
discover(): Promise<DiscoveredMCP[]>;
|
|
24
|
-
/**
|
|
25
|
-
* Discover plugins in a specific path
|
|
26
|
-
*/
|
|
27
|
-
private discoverInPath;
|
|
28
|
-
/**
|
|
29
|
-
* Load plugin from manifest
|
|
30
|
-
*/
|
|
31
|
-
private loadPlugin;
|
|
32
|
-
/**
|
|
33
|
-
* Determine plugin source based on path
|
|
34
|
-
*/
|
|
35
|
-
private determineSource;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Default auto-discovery instance
|
|
39
|
-
*/
|
|
40
|
-
export declare const autoDiscovery: AutoDiscovery;
|
|
41
|
-
/**
|
|
42
|
-
* Discovery options interface
|
|
43
|
-
*/
|
|
44
|
-
export interface DiscoveryOptions {
|
|
45
|
-
searchPaths?: string[];
|
|
46
|
-
manifestName?: string;
|
|
47
|
-
maxDepth?: number;
|
|
48
|
-
includeDevPlugins?: boolean;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Discover MCP servers using auto-discovery
|
|
52
|
-
*/
|
|
53
|
-
export declare function discoverMCPServers(options?: DiscoveryOptions): Promise<DiscoveredMCP[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Auto-register discovered MCP servers
|
|
56
|
-
*/
|
|
57
|
-
export declare function autoRegisterMCPServers(options?: DiscoveryOptions): Promise<{
|
|
58
|
-
registered: number;
|
|
59
|
-
failed: number;
|
|
60
|
-
plugins: DiscoveredMCP[];
|
|
61
|
-
}>;
|
|
62
|
-
export {};
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Auto-Discovery Module for MCP Plugins
|
|
3
|
-
* Handles automatic plugin discovery and registration
|
|
4
|
-
*/
|
|
5
|
-
import * as fs from "fs/promises";
|
|
6
|
-
import * as path from "path";
|
|
7
|
-
import { autoDiscoveryLogger } from "./logging.js";
|
|
8
|
-
/**
|
|
9
|
-
* Default auto-discovery configuration
|
|
10
|
-
*/
|
|
11
|
-
const DEFAULT_CONFIG = {
|
|
12
|
-
searchPaths: ["./src/lib/mcp/plugins", "./neurolink-mcp", "./node_modules"],
|
|
13
|
-
manifestName: "neurolink-mcp.json",
|
|
14
|
-
maxDepth: 3,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Auto-discovery service for MCP plugins
|
|
18
|
-
*/
|
|
19
|
-
export class AutoDiscovery {
|
|
20
|
-
config;
|
|
21
|
-
constructor(config = {}) {
|
|
22
|
-
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Discover all available MCP plugins
|
|
26
|
-
*/
|
|
27
|
-
async discover() {
|
|
28
|
-
const discovered = [];
|
|
29
|
-
for (const searchPath of this.config.searchPaths) {
|
|
30
|
-
try {
|
|
31
|
-
const plugins = await this.discoverInPath(searchPath);
|
|
32
|
-
discovered.push(...plugins);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
autoDiscoveryLogger.debug(`Failed to discover in ${searchPath}:`, error);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
autoDiscoveryLogger.info(`Auto-discovery completed: ${discovered.length} plugins found`);
|
|
39
|
-
return discovered;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Discover plugins in a specific path
|
|
43
|
-
*/
|
|
44
|
-
async discoverInPath(basePath, depth = 0) {
|
|
45
|
-
if (depth > this.config.maxDepth) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
const discovered = [];
|
|
49
|
-
try {
|
|
50
|
-
const items = await fs.readdir(basePath);
|
|
51
|
-
for (const item of items) {
|
|
52
|
-
const itemPath = path.join(basePath, item);
|
|
53
|
-
const stats = await fs.stat(itemPath);
|
|
54
|
-
if (stats.isDirectory()) {
|
|
55
|
-
// Check for manifest in this directory
|
|
56
|
-
const manifestPath = path.join(itemPath, this.config.manifestName);
|
|
57
|
-
try {
|
|
58
|
-
await fs.access(manifestPath);
|
|
59
|
-
const plugin = await this.loadPlugin(manifestPath, itemPath);
|
|
60
|
-
if (plugin) {
|
|
61
|
-
discovered.push(plugin);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
// No manifest, continue searching subdirectories
|
|
66
|
-
const subPlugins = await this.discoverInPath(itemPath, depth + 1);
|
|
67
|
-
discovered.push(...subPlugins);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
catch (error) {
|
|
73
|
-
autoDiscoveryLogger.debug(`Failed to scan ${basePath}:`, error);
|
|
74
|
-
}
|
|
75
|
-
return discovered;
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Load plugin from manifest
|
|
79
|
-
*/
|
|
80
|
-
async loadPlugin(manifestPath, pluginPath) {
|
|
81
|
-
try {
|
|
82
|
-
const manifestContent = await fs.readFile(manifestPath, "utf-8");
|
|
83
|
-
const metadata = JSON.parse(manifestContent);
|
|
84
|
-
// Validate basic metadata
|
|
85
|
-
if (!metadata.name || !metadata.version || !metadata.main) {
|
|
86
|
-
autoDiscoveryLogger.warn(`Invalid manifest at ${manifestPath}`);
|
|
87
|
-
return null;
|
|
88
|
-
}
|
|
89
|
-
const entryPath = path.resolve(pluginPath, metadata.main);
|
|
90
|
-
return {
|
|
91
|
-
metadata,
|
|
92
|
-
entryPath,
|
|
93
|
-
source: this.determineSource(pluginPath),
|
|
94
|
-
constructor: undefined,
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
autoDiscoveryLogger.error(`Failed to load plugin manifest at ${manifestPath}:`, error);
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Determine plugin source based on path
|
|
104
|
-
*/
|
|
105
|
-
determineSource(pluginPath) {
|
|
106
|
-
if (pluginPath.includes("node_modules")) {
|
|
107
|
-
return "installed";
|
|
108
|
-
}
|
|
109
|
-
if (pluginPath.includes("src/lib/mcp/plugins")) {
|
|
110
|
-
return "core";
|
|
111
|
-
}
|
|
112
|
-
return "project";
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Default auto-discovery instance
|
|
117
|
-
*/
|
|
118
|
-
export const autoDiscovery = new AutoDiscovery();
|
|
119
|
-
/**
|
|
120
|
-
* Discover MCP servers using auto-discovery
|
|
121
|
-
*/
|
|
122
|
-
export async function discoverMCPServers(options = {}) {
|
|
123
|
-
const discovery = new AutoDiscovery(options);
|
|
124
|
-
return discovery.discover();
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Auto-register discovered MCP servers
|
|
128
|
-
*/
|
|
129
|
-
export async function autoRegisterMCPServers(options = {}) {
|
|
130
|
-
const discovered = await discoverMCPServers(options);
|
|
131
|
-
let registered = 0;
|
|
132
|
-
let failed = 0;
|
|
133
|
-
for (const plugin of discovered) {
|
|
134
|
-
try {
|
|
135
|
-
// Registration logic would go here
|
|
136
|
-
autoDiscoveryLogger.info(`Registered plugin: ${plugin.metadata.name}`);
|
|
137
|
-
registered++;
|
|
138
|
-
}
|
|
139
|
-
catch (error) {
|
|
140
|
-
autoDiscoveryLogger.error(`Failed to register ${plugin.metadata.name}:`, error);
|
|
141
|
-
failed++;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return {
|
|
145
|
-
registered,
|
|
146
|
-
failed,
|
|
147
|
-
plugins: discovered,
|
|
148
|
-
};
|
|
149
|
-
}
|
package/dist/lib/mcp/client.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NeuroLink MCP Client
|
|
3
|
-
* Following Lighthouse's pattern for MCP tool registration and execution
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "events";
|
|
6
|
-
import type { ToolResult, NeuroLinkExecutionContext } from "./factory.js";
|
|
7
|
-
import type { Unknown } from "../types/common.js";
|
|
8
|
-
/**
|
|
9
|
-
* MCP Client Configuration
|
|
10
|
-
*/
|
|
11
|
-
export interface MCPClientConfig {
|
|
12
|
-
sessionId: string;
|
|
13
|
-
userId?: string;
|
|
14
|
-
aiProvider?: string;
|
|
15
|
-
modelId?: string;
|
|
16
|
-
logLevel?: "debug" | "info" | "warn" | "error";
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* NeuroLink MCP Client
|
|
20
|
-
* Manages tool registration and execution following Lighthouse patterns
|
|
21
|
-
*/
|
|
22
|
-
export declare class NeuroLinkMCPClient extends EventEmitter {
|
|
23
|
-
private tools;
|
|
24
|
-
private config;
|
|
25
|
-
private executionCount;
|
|
26
|
-
private isConnected;
|
|
27
|
-
constructor(config: MCPClientConfig);
|
|
28
|
-
/**
|
|
29
|
-
* Register a tool with the MCP client
|
|
30
|
-
* Following Lighthouse's pattern of namespacing tools with server ID
|
|
31
|
-
*/
|
|
32
|
-
registerTool(toolName: string, execute: (name: string, params: Record<string, unknown>) => Promise<Unknown>, description?: string, inputSchema?: unknown): void;
|
|
33
|
-
/**
|
|
34
|
-
* Get all registered tools
|
|
35
|
-
*/
|
|
36
|
-
getTools(): Record<string, {
|
|
37
|
-
name: string;
|
|
38
|
-
description?: string;
|
|
39
|
-
inputSchema?: unknown;
|
|
40
|
-
}>;
|
|
41
|
-
/**
|
|
42
|
-
* Execute a tool by name
|
|
43
|
-
*/
|
|
44
|
-
executeTool(toolName: string, params: unknown, context?: Partial<NeuroLinkExecutionContext>): Promise<ToolResult>;
|
|
45
|
-
/**
|
|
46
|
-
* Check if connected to MCP
|
|
47
|
-
*/
|
|
48
|
-
isConnectedToMCP(): boolean;
|
|
49
|
-
/**
|
|
50
|
-
* Disconnect from MCP
|
|
51
|
-
*/
|
|
52
|
-
disconnect(): Promise<void>;
|
|
53
|
-
/**
|
|
54
|
-
* Get client statistics
|
|
55
|
-
*/
|
|
56
|
-
getStats(): {
|
|
57
|
-
sessionId: string;
|
|
58
|
-
toolCount: number;
|
|
59
|
-
executionCount: number;
|
|
60
|
-
isConnected: boolean;
|
|
61
|
-
uptime: number;
|
|
62
|
-
};
|
|
63
|
-
private startTime;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Create a new MCP client instance
|
|
67
|
-
*/
|
|
68
|
-
export declare function createMCPClient(config: MCPClientConfig): NeuroLinkMCPClient;
|