@juspay/neurolink 5.1.0 → 5.3.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 +21 -9
- package/README.md +123 -126
- package/dist/agent/direct-tools.d.ts +6 -6
- package/dist/cli/commands/config.d.ts +3 -3
- package/dist/cli/commands/mcp.js +8 -7
- package/dist/cli/factories/command-factory.d.ts +4 -0
- package/dist/cli/factories/command-factory.js +63 -8
- package/dist/cli/index.js +87 -140
- package/dist/core/base-provider.d.ts +423 -0
- package/dist/core/base-provider.js +376 -0
- package/dist/core/constants.d.ts +2 -1
- package/dist/core/constants.js +2 -1
- package/dist/core/dynamic-models.d.ts +6 -6
- package/dist/core/evaluation.d.ts +19 -80
- package/dist/core/evaluation.js +185 -484
- package/dist/core/factory.d.ts +3 -3
- package/dist/core/factory.js +31 -91
- package/dist/core/service-registry.d.ts +47 -0
- package/dist/core/service-registry.js +112 -0
- package/dist/core/types.d.ts +8 -1
- package/dist/factories/compatibility-factory.js +1 -1
- package/dist/factories/provider-factory.d.ts +72 -0
- package/dist/factories/provider-factory.js +144 -0
- package/dist/factories/provider-registry.d.ts +38 -0
- package/dist/factories/provider-registry.js +107 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +2 -4
- package/dist/lib/agent/direct-tools.d.ts +6 -6
- package/dist/lib/core/base-provider.d.ts +423 -0
- package/dist/lib/core/base-provider.js +376 -0
- package/dist/lib/core/constants.d.ts +2 -1
- package/dist/lib/core/constants.js +2 -1
- package/dist/lib/core/dynamic-models.d.ts +6 -6
- package/dist/lib/core/evaluation.d.ts +19 -80
- package/dist/lib/core/evaluation.js +185 -484
- package/dist/lib/core/factory.d.ts +3 -3
- package/dist/lib/core/factory.js +30 -91
- package/dist/lib/core/service-registry.d.ts +47 -0
- package/dist/lib/core/service-registry.js +112 -0
- package/dist/lib/core/types.d.ts +8 -1
- package/dist/lib/factories/compatibility-factory.js +1 -1
- package/dist/lib/factories/provider-factory.d.ts +72 -0
- package/dist/lib/factories/provider-factory.js +144 -0
- package/dist/lib/factories/provider-registry.d.ts +38 -0
- package/dist/lib/factories/provider-registry.js +107 -0
- package/dist/lib/index.d.ts +4 -3
- package/dist/lib/index.js +2 -4
- package/dist/lib/mcp/client.d.ts +1 -0
- package/dist/lib/mcp/client.js +1 -0
- package/dist/lib/mcp/config.js +28 -3
- package/dist/lib/mcp/context-manager.d.ts +1 -0
- package/dist/lib/mcp/context-manager.js +8 -4
- package/dist/lib/mcp/function-calling.d.ts +13 -0
- package/dist/lib/mcp/function-calling.js +134 -35
- package/dist/lib/mcp/initialize-tools.d.ts +1 -1
- package/dist/lib/mcp/initialize-tools.js +45 -1
- package/dist/lib/mcp/initialize.js +16 -6
- package/dist/lib/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/lib/mcp/neurolink-mcp-client.js +21 -5
- package/dist/lib/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/lib/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +3 -1
- package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/lib/mcp/unified-registry.d.ts +4 -0
- package/dist/lib/mcp/unified-registry.js +42 -9
- package/dist/lib/neurolink.d.ts +156 -117
- package/dist/lib/neurolink.js +619 -404
- package/dist/lib/providers/amazon-bedrock.d.ts +32 -0
- package/dist/lib/providers/amazon-bedrock.js +143 -0
- package/dist/lib/providers/analytics-helper.js +7 -4
- package/dist/lib/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/lib/providers/anthropic-baseprovider.js +114 -0
- package/dist/lib/providers/anthropic.d.ts +19 -43
- package/dist/lib/providers/anthropic.js +82 -306
- package/dist/lib/providers/azure-openai.d.ts +20 -0
- package/dist/lib/providers/azure-openai.js +89 -0
- package/dist/lib/providers/function-calling-provider.d.ts +64 -2
- package/dist/lib/providers/function-calling-provider.js +208 -9
- package/dist/lib/providers/google-ai-studio.d.ts +23 -0
- package/dist/lib/providers/google-ai-studio.js +107 -0
- package/dist/lib/providers/google-vertex.d.ts +47 -0
- package/dist/lib/providers/google-vertex.js +205 -0
- package/dist/lib/providers/huggingFace.d.ts +32 -25
- package/dist/lib/providers/huggingFace.js +97 -431
- package/dist/lib/providers/index.d.ts +9 -9
- package/dist/lib/providers/index.js +9 -9
- package/dist/lib/providers/mcp-provider.js +24 -5
- package/dist/lib/providers/mistral.d.ts +42 -0
- package/dist/lib/providers/mistral.js +160 -0
- package/dist/lib/providers/ollama.d.ts +52 -36
- package/dist/lib/providers/ollama.js +297 -520
- package/dist/lib/providers/openAI.d.ts +19 -18
- package/dist/lib/providers/openAI.js +76 -275
- package/dist/lib/sdk/tool-extension.d.ts +181 -0
- package/dist/lib/sdk/tool-extension.js +283 -0
- package/dist/lib/sdk/tool-registration.d.ts +95 -0
- package/dist/lib/sdk/tool-registration.js +167 -0
- package/dist/lib/services/streaming/streaming-manager.js +11 -10
- package/dist/lib/services/websocket/websocket-server.js +12 -11
- package/dist/lib/telemetry/telemetry-service.js +8 -7
- package/dist/lib/types/generate-types.d.ts +1 -0
- package/dist/lib/types/mcp-types.d.ts +116 -0
- package/dist/lib/types/mcp-types.js +5 -0
- package/dist/lib/types/stream-types.d.ts +30 -18
- package/dist/lib/types/universal-provider-options.d.ts +87 -0
- package/dist/lib/types/universal-provider-options.js +53 -0
- package/dist/mcp/client.d.ts +1 -0
- package/dist/mcp/client.js +1 -0
- package/dist/mcp/config.js +28 -3
- package/dist/mcp/context-manager.d.ts +1 -0
- package/dist/mcp/context-manager.js +8 -4
- package/dist/mcp/function-calling.d.ts +13 -0
- package/dist/mcp/function-calling.js +134 -35
- package/dist/mcp/initialize-tools.d.ts +1 -1
- package/dist/mcp/initialize-tools.js +45 -1
- package/dist/mcp/initialize.js +16 -6
- package/dist/mcp/neurolink-mcp-client.d.ts +1 -0
- package/dist/mcp/neurolink-mcp-client.js +21 -5
- package/dist/mcp/servers/agent/direct-tools-server.d.ts +8 -0
- package/dist/mcp/servers/agent/direct-tools-server.js +109 -0
- package/dist/mcp/servers/ai-providers/ai-core-server.js +3 -1
- package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +2 -2
- package/dist/mcp/unified-registry.d.ts +4 -0
- package/dist/mcp/unified-registry.js +42 -9
- package/dist/neurolink.d.ts +156 -117
- package/dist/neurolink.js +619 -404
- package/dist/providers/amazon-bedrock.d.ts +32 -0
- package/dist/providers/amazon-bedrock.js +143 -0
- package/dist/providers/analytics-helper.js +7 -4
- package/dist/providers/anthropic-baseprovider.d.ts +23 -0
- package/dist/providers/anthropic-baseprovider.js +114 -0
- package/dist/providers/anthropic.d.ts +19 -43
- package/dist/providers/anthropic.js +81 -305
- package/dist/providers/azure-openai.d.ts +20 -0
- package/dist/providers/azure-openai.js +89 -0
- package/dist/providers/function-calling-provider.d.ts +64 -2
- package/dist/providers/function-calling-provider.js +208 -9
- package/dist/providers/google-ai-studio.d.ts +23 -0
- package/dist/providers/google-ai-studio.js +108 -0
- package/dist/providers/google-vertex.d.ts +47 -0
- package/dist/providers/google-vertex.js +205 -0
- package/dist/providers/huggingFace.d.ts +32 -25
- package/dist/providers/huggingFace.js +96 -430
- package/dist/providers/index.d.ts +9 -9
- package/dist/providers/index.js +9 -9
- package/dist/providers/mcp-provider.js +24 -5
- package/dist/providers/mistral.d.ts +42 -0
- package/dist/providers/mistral.js +160 -0
- package/dist/providers/ollama.d.ts +52 -36
- package/dist/providers/ollama.js +297 -519
- package/dist/providers/openAI.d.ts +19 -18
- package/dist/providers/openAI.js +76 -276
- package/dist/sdk/tool-extension.d.ts +181 -0
- package/dist/sdk/tool-extension.js +283 -0
- package/dist/sdk/tool-registration.d.ts +95 -0
- package/dist/sdk/tool-registration.js +168 -0
- package/dist/services/streaming/streaming-manager.js +11 -10
- package/dist/services/websocket/websocket-server.js +12 -11
- package/dist/telemetry/telemetry-service.js +8 -7
- package/dist/types/generate-types.d.ts +1 -0
- package/dist/types/mcp-types.d.ts +116 -0
- package/dist/types/mcp-types.js +5 -0
- package/dist/types/stream-types.d.ts +30 -18
- package/dist/types/universal-provider-options.d.ts +87 -0
- package/dist/types/universal-provider-options.js +53 -0
- package/package.json +12 -5
- package/dist/lib/providers/agent-enhanced-provider.d.ts +0 -93
- package/dist/lib/providers/agent-enhanced-provider.js +0 -605
- package/dist/lib/providers/amazonBedrock.d.ts +0 -28
- package/dist/lib/providers/amazonBedrock.js +0 -364
- package/dist/lib/providers/azureOpenAI.d.ts +0 -42
- package/dist/lib/providers/azureOpenAI.js +0 -347
- package/dist/lib/providers/googleAIStudio.d.ts +0 -42
- package/dist/lib/providers/googleAIStudio.js +0 -364
- package/dist/lib/providers/googleVertexAI.d.ts +0 -34
- package/dist/lib/providers/googleVertexAI.js +0 -547
- package/dist/lib/providers/mistralAI.d.ts +0 -37
- package/dist/lib/providers/mistralAI.js +0 -325
- package/dist/providers/agent-enhanced-provider.d.ts +0 -93
- package/dist/providers/agent-enhanced-provider.js +0 -606
- package/dist/providers/amazonBedrock.d.ts +0 -28
- package/dist/providers/amazonBedrock.js +0 -364
- package/dist/providers/azureOpenAI.d.ts +0 -42
- package/dist/providers/azureOpenAI.js +0 -348
- package/dist/providers/googleAIStudio.d.ts +0 -42
- package/dist/providers/googleAIStudio.js +0 -364
- package/dist/providers/googleVertexAI.d.ts +0 -34
- package/dist/providers/googleVertexAI.js +0 -547
- package/dist/providers/mistralAI.d.ts +0 -37
- package/dist/providers/mistralAI.js +0 -325
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NeuroLink Direct Tools Server
|
|
3
|
+
* Wraps the agent direct tools as an MCP server for proper registration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Direct Tools Server - Agent direct tools for immediate use
|
|
7
|
+
*/
|
|
8
|
+
export declare const directToolsServer: import("../../factory.js").NeuroLinkMCPServer;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NeuroLink Direct Tools Server
|
|
3
|
+
* Wraps the agent direct tools as an MCP server for proper registration
|
|
4
|
+
*/
|
|
5
|
+
import { createMCPServer } from "../../factory.js";
|
|
6
|
+
import { directAgentTools } from "../../../agent/direct-tools.js";
|
|
7
|
+
import { logger } from "../../../utils/logger.js";
|
|
8
|
+
/**
|
|
9
|
+
* Direct Tools Server - Agent direct tools for immediate use
|
|
10
|
+
*/
|
|
11
|
+
export const directToolsServer = createMCPServer({
|
|
12
|
+
id: "neurolink-direct",
|
|
13
|
+
title: "NeuroLink Direct Tools Server",
|
|
14
|
+
description: "Provides direct agent tools for immediate execution",
|
|
15
|
+
category: "integrations",
|
|
16
|
+
version: "1.0.0",
|
|
17
|
+
});
|
|
18
|
+
/**
|
|
19
|
+
* Wrap each direct tool and register it with the server
|
|
20
|
+
*/
|
|
21
|
+
Object.entries(directAgentTools).forEach(([toolName, toolDef]) => {
|
|
22
|
+
// The toolDef is a Vercel AI SDK Tool object
|
|
23
|
+
// Extract properties from the Tool object
|
|
24
|
+
const toolSpec = toolDef._spec || toolDef;
|
|
25
|
+
const description = toolSpec.description || `Direct tool: ${toolName}`;
|
|
26
|
+
const inputSchema = toolSpec.parameters;
|
|
27
|
+
const execute = toolSpec.execute;
|
|
28
|
+
directToolsServer.registerTool({
|
|
29
|
+
name: toolName,
|
|
30
|
+
description: description,
|
|
31
|
+
category: getToolCategory(toolName),
|
|
32
|
+
inputSchema: inputSchema,
|
|
33
|
+
isImplemented: true,
|
|
34
|
+
execute: async (params, context) => {
|
|
35
|
+
const startTime = Date.now();
|
|
36
|
+
try {
|
|
37
|
+
logger.debug(`[Direct Tools] Executing ${toolName} with params:`, params);
|
|
38
|
+
// Execute the direct tool
|
|
39
|
+
const result = await execute(params);
|
|
40
|
+
// Convert direct tool result to ToolResult format
|
|
41
|
+
if (result.success) {
|
|
42
|
+
return {
|
|
43
|
+
success: true,
|
|
44
|
+
data: result,
|
|
45
|
+
usage: {
|
|
46
|
+
executionTime: Date.now() - startTime,
|
|
47
|
+
},
|
|
48
|
+
metadata: {
|
|
49
|
+
toolName,
|
|
50
|
+
serverId: "neurolink-direct",
|
|
51
|
+
sessionId: context.sessionId,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return {
|
|
57
|
+
success: false,
|
|
58
|
+
data: null,
|
|
59
|
+
error: result.error || "Unknown error",
|
|
60
|
+
usage: {
|
|
61
|
+
executionTime: Date.now() - startTime,
|
|
62
|
+
},
|
|
63
|
+
metadata: {
|
|
64
|
+
toolName,
|
|
65
|
+
serverId: "neurolink-direct",
|
|
66
|
+
sessionId: context.sessionId,
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
logger.error(`[Direct Tools] Error executing ${toolName}:`, error);
|
|
73
|
+
return {
|
|
74
|
+
success: false,
|
|
75
|
+
data: null,
|
|
76
|
+
error: error instanceof Error ? error.message : String(error),
|
|
77
|
+
usage: {
|
|
78
|
+
executionTime: Date.now() - startTime,
|
|
79
|
+
},
|
|
80
|
+
metadata: {
|
|
81
|
+
toolName,
|
|
82
|
+
serverId: "neurolink-direct",
|
|
83
|
+
sessionId: context.sessionId,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
/**
|
|
91
|
+
* Get tool category based on tool name
|
|
92
|
+
*/
|
|
93
|
+
function getToolCategory(toolName) {
|
|
94
|
+
switch (toolName) {
|
|
95
|
+
case "getCurrentTime":
|
|
96
|
+
return "time";
|
|
97
|
+
case "calculateMath":
|
|
98
|
+
return "math";
|
|
99
|
+
case "readFile":
|
|
100
|
+
case "writeFile":
|
|
101
|
+
case "listDirectory":
|
|
102
|
+
case "searchFiles":
|
|
103
|
+
return "filesystem";
|
|
104
|
+
default:
|
|
105
|
+
return "utility";
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// Log successful registration
|
|
109
|
+
logger.info(`[Direct Tools] Registered ${Object.keys(directAgentTools).length} direct tools`);
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { createMCPServer } from "../../factory.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ServiceRegistry } from "../../../core/service-registry.js";
|
|
9
9
|
import { getBestProvider, getAvailableProviders, } from "../../../utils/providerUtils.js";
|
|
10
10
|
import { logger } from "../../../utils/logger.js";
|
|
11
11
|
import { analyzeAIUsageTool, benchmarkProviderPerformanceTool, optimizePromptParametersTool, } from "./ai-analysis-tools.js";
|
|
@@ -86,6 +86,8 @@ aiCoreServer.registerTool({
|
|
|
86
86
|
logger.debug(`[AI-Core] Starting text generation: "${params.prompt.substring(0, 50)}..."`);
|
|
87
87
|
// Use existing AIProviderFactory with best provider selection
|
|
88
88
|
const selectedProvider = params.provider || (await getBestProvider(params.provider));
|
|
89
|
+
// Get AIProviderFactory from ServiceRegistry to avoid circular dependency
|
|
90
|
+
const AIProviderFactory = await ServiceRegistry.get("AIProviderFactory");
|
|
89
91
|
const provider = await AIProviderFactory.createBestProvider(selectedProvider);
|
|
90
92
|
// Generate text using existing NeuroLink patterns
|
|
91
93
|
const result = await provider.generate({
|
|
@@ -88,14 +88,14 @@ export declare const workflowToolSchemas: {
|
|
|
88
88
|
}, "strip", z.ZodTypeAny, {
|
|
89
89
|
aiOutput: string;
|
|
90
90
|
expectedBehavior: string;
|
|
91
|
-
outputType: "text" | "code" | "
|
|
91
|
+
outputType: "text" | "code" | "structured-data" | "conversation";
|
|
92
92
|
includeFixSuggestions: boolean;
|
|
93
93
|
context?: string | undefined;
|
|
94
94
|
}, {
|
|
95
95
|
aiOutput: string;
|
|
96
96
|
expectedBehavior: string;
|
|
97
97
|
context?: string | undefined;
|
|
98
|
-
outputType?: "text" | "code" | "
|
|
98
|
+
outputType?: "text" | "code" | "structured-data" | "conversation" | undefined;
|
|
99
99
|
includeFixSuggestions?: boolean | undefined;
|
|
100
100
|
}>;
|
|
101
101
|
};
|
|
@@ -26,6 +26,10 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
26
26
|
* Load servers from .mcp-config.json
|
|
27
27
|
*/
|
|
28
28
|
private loadManualConfig;
|
|
29
|
+
/**
|
|
30
|
+
* Connect to manually configured servers
|
|
31
|
+
*/
|
|
32
|
+
private connectManualServers;
|
|
29
33
|
/**
|
|
30
34
|
* Enable or disable auto-discovery
|
|
31
35
|
*/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { autoRegisterMCPServers, } from "./auto-discovery.js";
|
|
5
5
|
import { unifiedRegistryLogger } from "./logging.js";
|
|
6
|
-
import { MCPToolRegistry, } from "./tool-registry.js";
|
|
6
|
+
import { MCPToolRegistry, defaultToolRegistry, } from "./tool-registry.js";
|
|
7
7
|
import { TransportManager, TransportConfigSchema, } from "./transport-manager.js";
|
|
8
8
|
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
|
|
9
9
|
import { ErrorManager } from "./error-manager.js";
|
|
@@ -30,8 +30,18 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
30
30
|
*/
|
|
31
31
|
async initialize(options = {}) {
|
|
32
32
|
unifiedRegistryLogger.info("Initializing unified MCP registry...");
|
|
33
|
-
//
|
|
34
|
-
await
|
|
33
|
+
// Import ProviderRegistry to check options
|
|
34
|
+
const { ProviderRegistry } = await import("../factories/provider-registry.js");
|
|
35
|
+
const registryOptions = ProviderRegistry.getOptions();
|
|
36
|
+
// Only load manual config if explicitly enabled (CLI mode)
|
|
37
|
+
if (registryOptions.enableManualMCP) {
|
|
38
|
+
unifiedRegistryLogger.info("Manual MCP config enabled - loading .mcp-config.json");
|
|
39
|
+
await this.loadManualConfig();
|
|
40
|
+
await this.connectManualServers();
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
unifiedRegistryLogger.debug("Manual MCP config disabled - skipping .mcp-config.json");
|
|
44
|
+
}
|
|
35
45
|
if (this.autoDiscoveryEnabled) {
|
|
36
46
|
const result = await autoRegisterMCPServers(options);
|
|
37
47
|
unifiedRegistryLogger.info(`Auto-discovery complete: ${result.registered} registered, ${result.failed} failed`);
|
|
@@ -95,6 +105,29 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
95
105
|
unifiedRegistryLogger.error("Failed to load manual config:", error instanceof Error ? error.message : String(error));
|
|
96
106
|
}
|
|
97
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Connect to manually configured servers
|
|
110
|
+
*/
|
|
111
|
+
async connectManualServers() {
|
|
112
|
+
for (const [serverId, serverConfig] of this.manualServers.entries()) {
|
|
113
|
+
try {
|
|
114
|
+
unifiedRegistryLogger.info(`Connecting to manual server: ${serverId}`);
|
|
115
|
+
// Use addExternalServer method which properly establishes connections
|
|
116
|
+
await this.addExternalServer(serverId, {
|
|
117
|
+
type: "stdio",
|
|
118
|
+
command: serverConfig.command || "npx",
|
|
119
|
+
args: serverConfig.args || [],
|
|
120
|
+
env: serverConfig.env,
|
|
121
|
+
});
|
|
122
|
+
unifiedRegistryLogger.info(`Successfully connected manual server: ${serverId}`);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
unifiedRegistryLogger.error(`Failed to connect manual server ${serverId}:`, error instanceof Error ? error.message : String(error));
|
|
126
|
+
// Remove from available servers if connection fails
|
|
127
|
+
this.availableServers.delete(serverId);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
98
131
|
/**
|
|
99
132
|
* Enable or disable auto-discovery
|
|
100
133
|
*/
|
|
@@ -141,8 +174,8 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
141
174
|
async listAllTools() {
|
|
142
175
|
const allTools = [];
|
|
143
176
|
try {
|
|
144
|
-
// FIXED: Get built-in tools from
|
|
145
|
-
const builtInTools = await
|
|
177
|
+
// FIXED: Get built-in tools from defaultToolRegistry where they are actually registered
|
|
178
|
+
const builtInTools = await defaultToolRegistry.listTools();
|
|
146
179
|
allTools.push(...builtInTools.map((tool) => ({
|
|
147
180
|
...tool,
|
|
148
181
|
id: tool.name,
|
|
@@ -150,7 +183,7 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
150
183
|
source: "built-in",
|
|
151
184
|
isExternal: false,
|
|
152
185
|
})));
|
|
153
|
-
unifiedRegistryLogger.debug(`Found ${builtInTools.length} built-in tools`);
|
|
186
|
+
unifiedRegistryLogger.debug(`Found ${builtInTools.length} built-in tools from defaultToolRegistry`);
|
|
154
187
|
}
|
|
155
188
|
catch (error) {
|
|
156
189
|
unifiedRegistryLogger.warn("Failed to get built-in tools:", error);
|
|
@@ -194,10 +227,10 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
|
|
|
194
227
|
*/
|
|
195
228
|
async executeTool(toolName, args, context) {
|
|
196
229
|
unifiedRegistryLogger.info(`Executing tool: ${toolName}`);
|
|
197
|
-
// STEP 1: Try built-in tools first
|
|
230
|
+
// STEP 1: Try built-in tools first from defaultToolRegistry
|
|
198
231
|
try {
|
|
199
|
-
const result = await
|
|
200
|
-
unifiedRegistryLogger.info(`Tool ${toolName} executed successfully via
|
|
232
|
+
const result = await defaultToolRegistry.executeTool(toolName, args, context);
|
|
233
|
+
unifiedRegistryLogger.info(`Tool ${toolName} executed successfully via defaultToolRegistry`);
|
|
201
234
|
return result;
|
|
202
235
|
}
|
|
203
236
|
catch (builtInError) {
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* NeuroLink - Unified AI Interface with Real MCP Tool Integration
|
|
3
3
|
*
|
|
4
|
+
* REDESIGNED FALLBACK CHAIN - NO CIRCULAR DEPENDENCIES
|
|
4
5
|
* Enhanced AI provider system with natural MCP tool access.
|
|
5
6
|
* Uses real MCP infrastructure for tool discovery and execution.
|
|
6
7
|
*/
|
|
7
|
-
import type {
|
|
8
|
+
import type { TextGenerationOptions, TextGenerationResult } from "./core/types.js";
|
|
8
9
|
import type { GenerateOptions, GenerateResult } from "./types/generate-types.js";
|
|
9
10
|
import type { StreamOptions, StreamResult } from "./types/stream-types.js";
|
|
11
|
+
import type { SimpleTool } from "./sdk/tool-registration.js";
|
|
12
|
+
import type { InMemoryMCPServerConfig } from "./types/mcp-types.js";
|
|
13
|
+
export interface ProviderStatus {
|
|
14
|
+
provider: string;
|
|
15
|
+
status: "working" | "failed" | "not-configured";
|
|
16
|
+
configured: boolean;
|
|
17
|
+
authenticated: boolean;
|
|
18
|
+
error?: string;
|
|
19
|
+
responseTime?: number;
|
|
20
|
+
model?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface MCPStatus {
|
|
23
|
+
mcpInitialized: boolean;
|
|
24
|
+
totalServers: number;
|
|
25
|
+
availableServers: number;
|
|
26
|
+
autoDiscoveredCount: number;
|
|
27
|
+
totalTools: number;
|
|
28
|
+
autoDiscoveredServers: MCPServerInfo[];
|
|
29
|
+
customToolsCount: number;
|
|
30
|
+
inMemoryServersCount: number;
|
|
31
|
+
error?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface MCPServerInfo {
|
|
34
|
+
id: string;
|
|
35
|
+
name: string;
|
|
36
|
+
source: string;
|
|
37
|
+
status: "connected" | "discovered" | "failed";
|
|
38
|
+
hasServer: boolean;
|
|
39
|
+
metadata?: any;
|
|
40
|
+
}
|
|
10
41
|
export declare class NeuroLink {
|
|
11
42
|
private mcpInitialized;
|
|
12
43
|
private contextManager;
|
|
44
|
+
private customTools;
|
|
45
|
+
private inMemoryServers;
|
|
13
46
|
constructor();
|
|
14
47
|
/**
|
|
15
48
|
* Initialize MCP registry with enhanced error handling and resource cleanup
|
|
@@ -17,151 +50,157 @@ export declare class NeuroLink {
|
|
|
17
50
|
*/
|
|
18
51
|
private initializeMCP;
|
|
19
52
|
/**
|
|
20
|
-
*
|
|
21
|
-
|
|
22
|
-
private doIsolatedMCPInitialization;
|
|
23
|
-
/**
|
|
24
|
-
* PRIMARY METHOD: Generate content using AI (recommended for new code)
|
|
25
|
-
* Future-ready for multi-modal capabilities with current text focus
|
|
53
|
+
* MAIN ENTRY POINT: Enhanced generate method with new function signature
|
|
54
|
+
* Replaces both generateText and legacy methods
|
|
26
55
|
*/
|
|
27
|
-
generate(
|
|
56
|
+
generate(optionsOrPrompt: GenerateOptions | string): Promise<GenerateResult>;
|
|
28
57
|
/**
|
|
29
58
|
* BACKWARD COMPATIBILITY: Legacy generateText method
|
|
30
59
|
* Internally calls generate() and converts result format
|
|
31
60
|
*/
|
|
32
61
|
generateText(options: TextGenerationOptions): Promise<TextGenerationResult>;
|
|
33
62
|
/**
|
|
34
|
-
*
|
|
63
|
+
* REDESIGNED INTERNAL GENERATION - NO CIRCULAR DEPENDENCIES
|
|
64
|
+
*
|
|
65
|
+
* This method implements a clean fallback chain:
|
|
66
|
+
* 1. Try MCP-enhanced generation if available
|
|
67
|
+
* 2. Fall back to direct provider generation
|
|
68
|
+
* 3. No recursive calls - each method has a specific purpose
|
|
69
|
+
*/
|
|
70
|
+
private generateTextInternal;
|
|
71
|
+
/**
|
|
72
|
+
* Try MCP-enhanced generation (no fallback recursion)
|
|
35
73
|
*/
|
|
36
|
-
private
|
|
74
|
+
private tryMCPGeneration;
|
|
37
75
|
/**
|
|
38
|
-
*
|
|
76
|
+
* Direct provider generation (no MCP, no recursion)
|
|
39
77
|
*/
|
|
40
|
-
private
|
|
78
|
+
private directProviderGeneration;
|
|
41
79
|
/**
|
|
42
80
|
* Create tool-aware system prompt that informs AI about available tools
|
|
43
81
|
*/
|
|
44
82
|
private createToolAwareSystemPrompt;
|
|
83
|
+
/**
|
|
84
|
+
* BACKWARD COMPATIBILITY: Legacy streamText method
|
|
85
|
+
* Internally calls stream() and converts result format
|
|
86
|
+
*/
|
|
87
|
+
streamText(prompt: string, options?: Partial<StreamOptions>): Promise<AsyncIterable<string>>;
|
|
45
88
|
/**
|
|
46
89
|
* PRIMARY METHOD: Stream content using AI (recommended for new code)
|
|
47
90
|
* Future-ready for multi-modal capabilities with current text focus
|
|
48
91
|
*/
|
|
49
92
|
stream(options: StreamOptions): Promise<StreamResult>;
|
|
50
93
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
94
|
+
* Register a custom tool that will be available to all AI providers
|
|
95
|
+
* @param name - Unique name for the tool
|
|
96
|
+
* @param tool - Tool configuration
|
|
53
97
|
*/
|
|
54
|
-
|
|
55
|
-
content: string;
|
|
56
|
-
}>>;
|
|
98
|
+
registerTool(name: string, tool: SimpleTool): void;
|
|
57
99
|
/**
|
|
58
|
-
*
|
|
100
|
+
* Register multiple tools at once
|
|
101
|
+
* @param tools - Object mapping tool names to configurations
|
|
59
102
|
*/
|
|
60
|
-
|
|
103
|
+
registerTools(tools: Record<string, SimpleTool>): void;
|
|
61
104
|
/**
|
|
62
|
-
*
|
|
105
|
+
* Unregister a custom tool
|
|
106
|
+
* @param name - Name of the tool to remove
|
|
107
|
+
* @returns true if the tool was removed, false if it didn't exist
|
|
63
108
|
*/
|
|
64
|
-
|
|
109
|
+
unregisterTool(name: string): boolean;
|
|
65
110
|
/**
|
|
66
|
-
* Get
|
|
111
|
+
* Get all registered custom tools
|
|
112
|
+
* @returns Map of tool names to configurations
|
|
67
113
|
*/
|
|
68
|
-
|
|
114
|
+
getCustomTools(): Map<string, SimpleTool>;
|
|
69
115
|
/**
|
|
70
|
-
*
|
|
116
|
+
* Add an in-memory MCP server (from git diff)
|
|
117
|
+
* Allows registration of pre-instantiated server objects
|
|
118
|
+
* @param serverId - Unique identifier for the server
|
|
119
|
+
* @param config - Server configuration
|
|
71
120
|
*/
|
|
72
|
-
|
|
73
|
-
mcpInitialized: boolean;
|
|
74
|
-
totalServers: number;
|
|
75
|
-
availableServers: number;
|
|
76
|
-
autoDiscoveredCount: number;
|
|
77
|
-
totalTools: number;
|
|
78
|
-
autoDiscoveredServers: {
|
|
79
|
-
id: string;
|
|
80
|
-
name: string;
|
|
81
|
-
source: "core" | "project" | "installed";
|
|
82
|
-
status: string;
|
|
83
|
-
hasServer: boolean;
|
|
84
|
-
}[];
|
|
85
|
-
}>;
|
|
121
|
+
addInMemoryMCPServer(serverId: string, config: InMemoryMCPServerConfig): Promise<void>;
|
|
86
122
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* @param
|
|
95
|
-
* @
|
|
96
|
-
*
|
|
97
|
-
* @
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* await neurolink.addMCPServer('bitbucket', {
|
|
101
|
-
* command: 'npx',
|
|
102
|
-
* args: ['-y', '@nexus2520/bitbucket-mcp-server'],
|
|
103
|
-
* env: {
|
|
104
|
-
* BITBUCKET_USERNAME: 'your-username',
|
|
105
|
-
* BITBUCKET_APP_PASSWORD: 'your-app-password'
|
|
106
|
-
* }
|
|
107
|
-
* });
|
|
108
|
-
*
|
|
109
|
-
* // Add custom database connector
|
|
110
|
-
* await neurolink.addMCPServer('database', {
|
|
111
|
-
* command: 'node',
|
|
112
|
-
* args: ['./custom-db-mcp-server.js'],
|
|
113
|
-
* env: { DB_CONNECTION_STRING: 'postgresql://...' }
|
|
114
|
-
* });
|
|
115
|
-
* ```
|
|
116
|
-
*/
|
|
117
|
-
addMCPServer(serverId: string, config: {
|
|
118
|
-
command: string;
|
|
119
|
-
args?: string[];
|
|
120
|
-
env?: Record<string, string>;
|
|
121
|
-
cwd?: string;
|
|
122
|
-
type?: "stdio" | "sse" | "http";
|
|
123
|
-
url?: string;
|
|
124
|
-
headers?: Record<string, string>;
|
|
123
|
+
* Get all registered in-memory servers
|
|
124
|
+
* @returns Map of server IDs to configurations
|
|
125
|
+
*/
|
|
126
|
+
getInMemoryServers(): Map<string, InMemoryMCPServerConfig>;
|
|
127
|
+
/**
|
|
128
|
+
* Execute a specific tool by name (from git diff)
|
|
129
|
+
* Supports both custom tools and MCP server tools
|
|
130
|
+
* @param toolName - Name of the tool to execute
|
|
131
|
+
* @param params - Parameters to pass to the tool
|
|
132
|
+
* @param options - Execution options
|
|
133
|
+
* @returns Tool execution result
|
|
134
|
+
*/
|
|
135
|
+
executeTool<T = any>(toolName: string, params?: any, options?: {
|
|
125
136
|
timeout?: number;
|
|
126
|
-
}): Promise<
|
|
127
|
-
/**
|
|
128
|
-
*
|
|
129
|
-
* @
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
*
|
|
163
|
-
* @
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
137
|
+
}): Promise<T>;
|
|
138
|
+
/**
|
|
139
|
+
* Get all available tools including custom and in-memory ones
|
|
140
|
+
* @returns Array of available tools with metadata
|
|
141
|
+
*/
|
|
142
|
+
getAllAvailableTools(): Promise<{
|
|
143
|
+
serverId: string;
|
|
144
|
+
serverTitle: string;
|
|
145
|
+
toolName: string;
|
|
146
|
+
namespacedName: string;
|
|
147
|
+
description: string;
|
|
148
|
+
isImplemented: boolean;
|
|
149
|
+
}[]>;
|
|
150
|
+
/**
|
|
151
|
+
* Get comprehensive status of all AI providers
|
|
152
|
+
* Primary method for provider health checking and diagnostics
|
|
153
|
+
*/
|
|
154
|
+
getProviderStatus(): Promise<ProviderStatus[]>;
|
|
155
|
+
/**
|
|
156
|
+
* Test a specific AI provider's connectivity and authentication
|
|
157
|
+
* @param providerName - Name of the provider to test
|
|
158
|
+
* @returns Promise resolving to true if provider is working
|
|
159
|
+
*/
|
|
160
|
+
testProvider(providerName: string): Promise<boolean>;
|
|
161
|
+
/**
|
|
162
|
+
* Internal method to test provider connection with minimal generation call
|
|
163
|
+
*/
|
|
164
|
+
private testProviderConnection;
|
|
165
|
+
/**
|
|
166
|
+
* Check if a provider has required environment variables configured
|
|
167
|
+
* @param providerName - Name of the provider to check
|
|
168
|
+
* @returns True if provider has required environment variables
|
|
169
|
+
*/
|
|
170
|
+
hasProviderEnvVars(providerName: string): Promise<boolean>;
|
|
171
|
+
/**
|
|
172
|
+
* Get the best available AI provider based on configuration and availability
|
|
173
|
+
* @param requestedProvider - Optional preferred provider name
|
|
174
|
+
* @returns Promise resolving to the best provider name
|
|
175
|
+
*/
|
|
176
|
+
getBestProvider(requestedProvider?: string): Promise<string>;
|
|
177
|
+
/**
|
|
178
|
+
* Get list of all available AI provider names
|
|
179
|
+
* @returns Array of supported provider names
|
|
180
|
+
*/
|
|
181
|
+
getAvailableProviders(): Promise<string[]>;
|
|
182
|
+
/**
|
|
183
|
+
* Validate if a provider name is supported
|
|
184
|
+
* @param providerName - Provider name to validate
|
|
185
|
+
* @returns True if provider name is valid
|
|
186
|
+
*/
|
|
187
|
+
isValidProvider(providerName: string): Promise<boolean>;
|
|
188
|
+
/**
|
|
189
|
+
* Get comprehensive MCP (Model Context Protocol) status information
|
|
190
|
+
* @returns Promise resolving to MCP status details
|
|
191
|
+
*/
|
|
192
|
+
getMCPStatus(): Promise<MCPStatus>;
|
|
193
|
+
/**
|
|
194
|
+
* List all configured MCP servers with their status
|
|
195
|
+
* @returns Promise resolving to array of MCP server information
|
|
196
|
+
*/
|
|
197
|
+
listMCPServers(): Promise<MCPServerInfo[]>;
|
|
198
|
+
/**
|
|
199
|
+
* Test connectivity to a specific MCP server
|
|
200
|
+
* @param serverId - ID of the MCP server to test
|
|
201
|
+
* @returns Promise resolving to true if server is reachable
|
|
202
|
+
*/
|
|
203
|
+
testMCPServer(serverId: string): Promise<boolean>;
|
|
167
204
|
}
|
|
205
|
+
export declare const neurolink: NeuroLink;
|
|
206
|
+
export default neurolink;
|