@juspay/neurolink 7.29.1 → 7.29.3
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 +12 -0
- package/dist/cli/commands/config.d.ts +86 -86
- package/dist/cli/commands/mcp.js +64 -9
- package/dist/cli/commands/models.js +25 -21
- package/dist/cli/commands/ollama.js +2 -2
- package/dist/cli/factories/commandFactory.d.ts +9 -0
- package/dist/cli/factories/commandFactory.js +177 -83
- package/dist/cli/factories/ollamaCommandFactory.js +3 -1
- package/dist/cli/factories/sagemakerCommandFactory.js +3 -2
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +19 -11
- package/dist/cli/utils/envManager.js +5 -5
- package/dist/cli/utils/ollamaUtils.d.ts +12 -0
- package/dist/cli/utils/ollamaUtils.js +58 -42
- package/dist/config/configManager.js +5 -2
- package/dist/core/analytics.d.ts +2 -24
- package/dist/core/analytics.js +12 -17
- package/dist/core/baseProvider.d.ts +30 -1
- package/dist/core/baseProvider.js +180 -198
- package/dist/core/dynamicModels.d.ts +4 -4
- package/dist/core/dynamicModels.js +7 -7
- package/dist/core/evaluation.d.ts +9 -9
- package/dist/core/evaluation.js +117 -65
- package/dist/core/evaluationProviders.d.ts +18 -2
- package/dist/core/evaluationProviders.js +15 -13
- package/dist/core/factory.js +77 -4
- package/dist/core/modelConfiguration.d.ts +63 -0
- package/dist/core/modelConfiguration.js +354 -290
- package/dist/core/streamAnalytics.d.ts +10 -5
- package/dist/core/streamAnalytics.js +10 -10
- package/dist/core/types.d.ts +19 -109
- package/dist/core/types.js +13 -0
- package/dist/factories/providerFactory.js +4 -1
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/lib/config/configManager.js +5 -2
- package/dist/lib/core/analytics.d.ts +2 -24
- package/dist/lib/core/analytics.js +12 -17
- package/dist/lib/core/baseProvider.d.ts +30 -1
- package/dist/lib/core/baseProvider.js +180 -198
- package/dist/lib/core/dynamicModels.js +7 -7
- package/dist/lib/core/evaluation.d.ts +9 -9
- package/dist/lib/core/evaluation.js +117 -65
- package/dist/lib/core/evaluationProviders.d.ts +18 -2
- package/dist/lib/core/evaluationProviders.js +15 -13
- package/dist/lib/core/factory.js +77 -4
- package/dist/lib/core/modelConfiguration.d.ts +63 -0
- package/dist/lib/core/modelConfiguration.js +354 -290
- package/dist/lib/core/streamAnalytics.d.ts +10 -5
- package/dist/lib/core/streamAnalytics.js +10 -10
- package/dist/lib/core/types.d.ts +19 -109
- package/dist/lib/core/types.js +13 -0
- package/dist/lib/factories/providerFactory.js +4 -1
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/mcp/externalServerManager.js +14 -6
- package/dist/lib/mcp/factory.js +1 -1
- package/dist/lib/mcp/flexibleToolValidator.d.ts +50 -0
- package/dist/lib/mcp/flexibleToolValidator.js +161 -0
- package/dist/lib/mcp/index.d.ts +1 -1
- package/dist/lib/mcp/index.js +1 -1
- package/dist/lib/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/lib/mcp/mcpClientFactory.js +3 -0
- package/dist/lib/mcp/registry.d.ts +3 -3
- package/dist/lib/mcp/registry.js +3 -3
- package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/lib/mcp/toolDiscoveryService.js +8 -2
- package/dist/lib/mcp/toolRegistry.d.ts +2 -2
- package/dist/lib/mcp/toolRegistry.js +29 -54
- package/dist/lib/middleware/builtin/analytics.js +4 -4
- package/dist/lib/middleware/builtin/guardrails.js +2 -2
- package/dist/lib/middleware/registry.js +11 -2
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +3 -3
- package/dist/lib/models/modelResolver.d.ts +1 -1
- package/dist/lib/models/modelResolver.js +2 -2
- package/dist/lib/neurolink.d.ts +118 -0
- package/dist/lib/neurolink.js +814 -952
- package/dist/lib/providers/amazonBedrock.d.ts +47 -6
- package/dist/lib/providers/amazonBedrock.js +282 -23
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/amazonSagemaker.js +12 -3
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +7 -6
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +4 -3
- package/dist/lib/providers/aws/credentialProvider.d.ts +58 -0
- package/dist/lib/providers/aws/credentialProvider.js +267 -0
- package/dist/lib/providers/aws/credentialTester.d.ts +49 -0
- package/dist/lib/providers/aws/credentialTester.js +394 -0
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +1 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +40 -0
- package/dist/lib/providers/googleVertex.js +330 -274
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.d.ts +4 -0
- package/dist/lib/providers/ollama.js +38 -18
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/lib/providers/sagemaker/client.js +13 -3
- package/dist/lib/providers/sagemaker/config.js +5 -1
- package/dist/lib/providers/sagemaker/detection.js +19 -9
- package/dist/lib/providers/sagemaker/errors.d.ts +8 -1
- package/dist/lib/providers/sagemaker/errors.js +103 -20
- package/dist/lib/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/lib/providers/sagemaker/language-model.js +4 -4
- package/dist/lib/providers/sagemaker/parsers.js +14 -6
- package/dist/lib/providers/sagemaker/streaming.js +14 -3
- package/dist/lib/providers/sagemaker/types.d.ts +1 -1
- package/dist/lib/proxy/awsProxyIntegration.d.ts +23 -0
- package/dist/lib/proxy/awsProxyIntegration.js +285 -0
- package/dist/lib/proxy/proxyFetch.d.ts +9 -5
- package/dist/lib/proxy/proxyFetch.js +232 -98
- package/dist/lib/proxy/utils/noProxyUtils.d.ts +39 -0
- package/dist/lib/proxy/utils/noProxyUtils.js +149 -0
- package/dist/lib/sdk/toolRegistration.d.ts +1 -1
- package/dist/lib/types/cli.d.ts +80 -8
- package/dist/lib/types/contextTypes.js +2 -2
- package/dist/lib/types/generateTypes.d.ts +4 -6
- package/dist/lib/types/providers.d.ts +124 -19
- package/dist/lib/types/providers.js +6 -6
- package/dist/lib/types/streamTypes.d.ts +4 -6
- package/dist/lib/types/typeAliases.d.ts +1 -1
- package/dist/lib/utils/analyticsUtils.d.ts +33 -0
- package/dist/lib/utils/analyticsUtils.js +76 -0
- package/dist/lib/utils/errorHandling.js +4 -1
- package/dist/lib/utils/evaluationUtils.d.ts +27 -0
- package/dist/lib/utils/evaluationUtils.js +131 -0
- package/dist/lib/utils/optionsUtils.js +10 -1
- package/dist/lib/utils/performance.d.ts +1 -1
- package/dist/lib/utils/performance.js +15 -3
- package/dist/lib/utils/providerConfig.d.ts +1 -0
- package/dist/lib/utils/providerConfig.js +2 -1
- package/dist/lib/utils/providerHealth.d.ts +48 -0
- package/dist/lib/utils/providerHealth.js +221 -158
- package/dist/lib/utils/providerUtils.js +2 -2
- package/dist/lib/utils/timeout.js +8 -3
- package/dist/mcp/externalServerManager.js +14 -6
- package/dist/mcp/factory.js +1 -1
- package/dist/mcp/flexibleToolValidator.d.ts +50 -0
- package/dist/mcp/flexibleToolValidator.js +161 -0
- package/dist/mcp/index.d.ts +1 -1
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/mcpCircuitBreaker.js +5 -1
- package/dist/mcp/mcpClientFactory.js +3 -0
- package/dist/mcp/registry.d.ts +3 -3
- package/dist/mcp/registry.js +3 -3
- package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
- package/dist/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/mcp/toolDiscoveryService.js +8 -2
- package/dist/mcp/toolRegistry.d.ts +2 -2
- package/dist/mcp/toolRegistry.js +29 -54
- package/dist/middleware/builtin/analytics.js +4 -4
- package/dist/middleware/builtin/guardrails.js +2 -2
- package/dist/middleware/registry.js +11 -2
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +3 -3
- package/dist/models/modelResolver.d.ts +1 -1
- package/dist/models/modelResolver.js +2 -2
- package/dist/neurolink.d.ts +118 -0
- package/dist/neurolink.js +814 -952
- package/dist/providers/amazonBedrock.d.ts +47 -6
- package/dist/providers/amazonBedrock.js +282 -23
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/amazonSagemaker.js +12 -3
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +7 -6
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +4 -3
- package/dist/providers/aws/credentialProvider.d.ts +58 -0
- package/dist/providers/aws/credentialProvider.js +267 -0
- package/dist/providers/aws/credentialTester.d.ts +49 -0
- package/dist/providers/aws/credentialTester.js +394 -0
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +1 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +2 -2
- package/dist/providers/googleVertex.d.ts +40 -0
- package/dist/providers/googleVertex.js +330 -274
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.d.ts +4 -0
- package/dist/providers/ollama.js +38 -18
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/sagemaker/adaptive-semaphore.js +7 -4
- package/dist/providers/sagemaker/client.js +13 -3
- package/dist/providers/sagemaker/config.js +5 -1
- package/dist/providers/sagemaker/detection.js +19 -9
- package/dist/providers/sagemaker/errors.d.ts +8 -1
- package/dist/providers/sagemaker/errors.js +103 -20
- package/dist/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/providers/sagemaker/language-model.js +4 -4
- package/dist/providers/sagemaker/parsers.js +14 -6
- package/dist/providers/sagemaker/streaming.js +14 -3
- package/dist/providers/sagemaker/types.d.ts +1 -1
- package/dist/proxy/awsProxyIntegration.d.ts +23 -0
- package/dist/proxy/awsProxyIntegration.js +285 -0
- package/dist/proxy/proxyFetch.d.ts +9 -5
- package/dist/proxy/proxyFetch.js +232 -98
- package/dist/proxy/utils/noProxyUtils.d.ts +39 -0
- package/dist/proxy/utils/noProxyUtils.js +149 -0
- package/dist/sdk/toolRegistration.d.ts +1 -1
- package/dist/types/cli.d.ts +80 -8
- package/dist/types/contextTypes.js +2 -2
- package/dist/types/generateTypes.d.ts +4 -6
- package/dist/types/providers.d.ts +124 -19
- package/dist/types/providers.js +6 -6
- package/dist/types/streamTypes.d.ts +4 -6
- package/dist/types/typeAliases.d.ts +1 -1
- package/dist/utils/analyticsUtils.d.ts +33 -0
- package/dist/utils/analyticsUtils.js +76 -0
- package/dist/utils/errorHandling.js +4 -1
- package/dist/utils/evaluationUtils.d.ts +27 -0
- package/dist/utils/evaluationUtils.js +131 -0
- package/dist/utils/optionsUtils.js +10 -1
- package/dist/utils/performance.d.ts +1 -1
- package/dist/utils/performance.js +15 -3
- package/dist/utils/providerConfig.d.ts +1 -0
- package/dist/utils/providerConfig.js +2 -1
- package/dist/utils/providerHealth.d.ts +48 -0
- package/dist/utils/providerHealth.js +221 -158
- package/dist/utils/providerUtils.js +2 -2
- package/dist/utils/timeout.js +8 -3
- package/package.json +5 -1
package/dist/lib/mcp/registry.js
CHANGED
|
@@ -53,7 +53,7 @@ export class MCPRegistry {
|
|
|
53
53
|
/**
|
|
54
54
|
* Register a server (compatible with new interface)
|
|
55
55
|
*/
|
|
56
|
-
async registerServer(serverId, serverConfig,
|
|
56
|
+
async registerServer(serverId, serverConfig, _context) {
|
|
57
57
|
const plugin = {
|
|
58
58
|
metadata: {
|
|
59
59
|
name: serverId,
|
|
@@ -74,14 +74,14 @@ export class MCPRegistry {
|
|
|
74
74
|
/**
|
|
75
75
|
* Execute a tool (mock implementation for tests)
|
|
76
76
|
*/
|
|
77
|
-
async executeTool(toolName, args,
|
|
77
|
+
async executeTool(toolName, args, _context) {
|
|
78
78
|
registryLogger.info(`Executing tool: ${toolName}`);
|
|
79
79
|
return { result: `Mock execution of ${toolName}`, args };
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* List all tools (compatible with new interface)
|
|
83
83
|
*/
|
|
84
|
-
async listTools(
|
|
84
|
+
async listTools(_context) {
|
|
85
85
|
const tools = this.list().map((plugin) => ({
|
|
86
86
|
name: plugin.metadata.name,
|
|
87
87
|
description: plugin.metadata.description || "No description",
|
|
@@ -78,7 +78,7 @@ const OptimizeParametersSchema = z.object({
|
|
|
78
78
|
* AI Usage Analysis Tool
|
|
79
79
|
* Analyzes AI usage patterns, token consumption, and cost optimization opportunities
|
|
80
80
|
*/
|
|
81
|
-
const
|
|
81
|
+
const _analyzeAIUsageTool = {
|
|
82
82
|
name: "analyze-ai-usage",
|
|
83
83
|
description: "Analyze AI usage patterns, token consumption, and cost optimization opportunities",
|
|
84
84
|
category: "ai-analysis",
|
|
@@ -163,7 +163,7 @@ const analyzeAIUsageTool = {
|
|
|
163
163
|
* Provider Performance Benchmarking Tool
|
|
164
164
|
* Benchmarks AI provider performance across latency, quality, and cost metrics
|
|
165
165
|
*/
|
|
166
|
-
const
|
|
166
|
+
const _benchmarkProviderPerformanceTool = {
|
|
167
167
|
name: "benchmark-provider-performance",
|
|
168
168
|
description: "Benchmark AI provider performance across latency, quality, and cost metrics",
|
|
169
169
|
category: "ai-analysis",
|
|
@@ -199,7 +199,7 @@ const benchmarkProviderPerformanceTool = {
|
|
|
199
199
|
});
|
|
200
200
|
if (result && result.usage) {
|
|
201
201
|
totalLatency += Date.now() - testStartTime;
|
|
202
|
-
totalTokens += result.usage.
|
|
202
|
+
totalTokens += result.usage.total || 0;
|
|
203
203
|
successfulTests++;
|
|
204
204
|
}
|
|
205
205
|
}
|
|
@@ -210,7 +210,7 @@ const benchmarkProviderPerformanceTool = {
|
|
|
210
210
|
avgLatency: successfulTests > 0
|
|
211
211
|
? Math.round(totalLatency / successfulTests)
|
|
212
212
|
: 0,
|
|
213
|
-
|
|
213
|
+
total: totalTokens,
|
|
214
214
|
successRate: (successfulTests /
|
|
215
215
|
(testPrompts.length * typedParams.iterations)) *
|
|
216
216
|
100,
|
|
@@ -259,7 +259,7 @@ const benchmarkProviderPerformanceTool = {
|
|
|
259
259
|
* Prompt Parameter Optimization Tool
|
|
260
260
|
* Optimizes prompt parameters (temperature, max tokens) for better AI output quality and efficiency
|
|
261
261
|
*/
|
|
262
|
-
const
|
|
262
|
+
const _optimizePromptParametersTool = {
|
|
263
263
|
name: "optimize-prompt-parameters",
|
|
264
264
|
description: "Optimize prompt parameters (temperature, max tokens) for better AI output quality and efficiency",
|
|
265
265
|
category: "ai-optimization",
|
|
@@ -99,7 +99,7 @@ const debugAIOutputSchema = z.object({
|
|
|
99
99
|
/**
|
|
100
100
|
* Generate test cases for code functions
|
|
101
101
|
*/
|
|
102
|
-
const
|
|
102
|
+
const _generateTestCasesTool = {
|
|
103
103
|
name: "generate-test-cases",
|
|
104
104
|
description: "Generate comprehensive test cases for code functions with various test types and frameworks",
|
|
105
105
|
category: "ai-workflow",
|
|
@@ -203,7 +203,7 @@ Generate 3-5 comprehensive test cases covering the requested types.`;
|
|
|
203
203
|
/**
|
|
204
204
|
* Refactor code for improved quality
|
|
205
205
|
*/
|
|
206
|
-
const
|
|
206
|
+
const _refactorCodeTool = {
|
|
207
207
|
name: "refactor-code",
|
|
208
208
|
description: "AI-powered code refactoring for improved readability, performance, and maintainability",
|
|
209
209
|
category: "ai-workflow",
|
|
@@ -316,7 +316,7 @@ Focus on real, actionable improvements based on the specified objectives.`;
|
|
|
316
316
|
/**
|
|
317
317
|
* Generate documentation from code
|
|
318
318
|
*/
|
|
319
|
-
const
|
|
319
|
+
const _generateDocumentationTool = {
|
|
320
320
|
name: "generate-documentation",
|
|
321
321
|
description: "Automatically generate comprehensive documentation from code",
|
|
322
322
|
category: "ai-workflow",
|
|
@@ -427,7 +427,7 @@ Focus on creating accurate, useful documentation that explains the code's purpos
|
|
|
427
427
|
/**
|
|
428
428
|
* Debug AI-generated output
|
|
429
429
|
*/
|
|
430
|
-
const
|
|
430
|
+
const _debugAIOutputTool = {
|
|
431
431
|
name: "debug-ai-output",
|
|
432
432
|
description: "Analyze and debug AI-generated output to identify issues and suggest improvements",
|
|
433
433
|
category: "ai-workflow",
|
|
@@ -549,13 +549,13 @@ Provide thorough, actionable analysis focused on improving AI output quality.`;
|
|
|
549
549
|
},
|
|
550
550
|
};
|
|
551
551
|
// Helper functions
|
|
552
|
-
function
|
|
552
|
+
function _extractFunctionName(code) {
|
|
553
553
|
const match = code.match(/function\s+(\w+)|const\s+(\w+)\s*=|(\w+)\s*\(/);
|
|
554
554
|
return match
|
|
555
555
|
? match[1] || match[2] || match[3] || "processData"
|
|
556
556
|
: "processData";
|
|
557
557
|
}
|
|
558
|
-
function
|
|
558
|
+
function _simulateRefactoring(code, objectives, _styleGuide) {
|
|
559
559
|
// Simulate basic refactoring
|
|
560
560
|
let refactored = code;
|
|
561
561
|
if (objectives.includes("readability")) {
|
|
@@ -61,7 +61,7 @@ utilityServer.registerTool({
|
|
|
61
61
|
});
|
|
62
62
|
resultData.actualTimezone = timezone;
|
|
63
63
|
}
|
|
64
|
-
catch
|
|
64
|
+
catch {
|
|
65
65
|
const fallbackTimezone = "Asia/Kolkata";
|
|
66
66
|
logger.warn(`[Utility] Invalid timezone '${timezone}', falling back to ${fallbackTimezone}`);
|
|
67
67
|
resultData.localTime = now.toLocaleString("en-US", {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { EventEmitter } from "events";
|
|
7
7
|
import { mcpLogger } from "../utils/logger.js";
|
|
8
8
|
import { globalCircuitBreakerManager } from "./mcpCircuitBreaker.js";
|
|
9
|
-
import { isObject, isNullish
|
|
9
|
+
import { isObject, isNullish } from "../utils/typeUtils.js";
|
|
10
10
|
import { validateToolName, validateToolDescription, } from "../utils/parameterValidation.js";
|
|
11
11
|
/**
|
|
12
12
|
* ToolDiscoveryService
|
|
@@ -133,6 +133,9 @@ export class ToolDiscoveryService extends EventEmitter {
|
|
|
133
133
|
this.serverToolStorage.set(serverId, []);
|
|
134
134
|
}
|
|
135
135
|
const serverTools = this.serverToolStorage.get(serverId);
|
|
136
|
+
if (!serverTools) {
|
|
137
|
+
throw new Error(`Server tools storage not found for ${serverId}`);
|
|
138
|
+
}
|
|
136
139
|
// Add tool if not already present
|
|
137
140
|
if (!serverTools.find((t) => t.name === tool.name)) {
|
|
138
141
|
serverTools.push({
|
|
@@ -145,7 +148,10 @@ export class ToolDiscoveryService extends EventEmitter {
|
|
|
145
148
|
if (!this.serverTools.has(serverId)) {
|
|
146
149
|
this.serverTools.set(serverId, new Set());
|
|
147
150
|
}
|
|
148
|
-
this.serverTools.get(serverId)
|
|
151
|
+
const serverToolSet = this.serverTools.get(serverId);
|
|
152
|
+
if (serverToolSet) {
|
|
153
|
+
serverToolSet.add(tool.name);
|
|
154
|
+
}
|
|
149
155
|
registeredTools.push(toolInfo);
|
|
150
156
|
// Emit tool registered event
|
|
151
157
|
this.emit("toolRegistered", {
|
|
@@ -29,7 +29,7 @@ export interface ToolExecutionOptions {
|
|
|
29
29
|
}
|
|
30
30
|
export declare class MCPToolRegistry extends MCPRegistry {
|
|
31
31
|
private tools;
|
|
32
|
-
private
|
|
32
|
+
private toolImplementations;
|
|
33
33
|
private toolExecutionStats;
|
|
34
34
|
private builtInServerInfos;
|
|
35
35
|
constructor();
|
|
@@ -122,7 +122,7 @@ export declare class MCPToolRegistry extends MCPRegistry {
|
|
|
122
122
|
* Register a tool with implementation directly
|
|
123
123
|
* This is used for external MCP server tools
|
|
124
124
|
*/
|
|
125
|
-
registerTool(toolId: string, toolInfo: ToolInfo, toolImpl: ToolImplementation): void
|
|
125
|
+
registerTool(toolId: string, toolInfo: ToolInfo, toolImpl: ToolImplementation): Promise<void>;
|
|
126
126
|
/**
|
|
127
127
|
* Remove a tool
|
|
128
128
|
*/
|
|
@@ -8,9 +8,10 @@ import { randomUUID } from "crypto";
|
|
|
8
8
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
9
9
|
import { directAgentTools } from "../agent/directTools.js";
|
|
10
10
|
import { detectCategory, createMCPServerInfo } from "../utils/mcpDefaults.js";
|
|
11
|
+
import { FlexibleToolValidator } from "./flexibleToolValidator.js";
|
|
11
12
|
export class MCPToolRegistry extends MCPRegistry {
|
|
12
13
|
tools = new Map();
|
|
13
|
-
|
|
14
|
+
toolImplementations = new Map(); // Store actual tool implementations
|
|
14
15
|
toolExecutionStats = new Map();
|
|
15
16
|
builtInServerInfos = []; // DIRECT storage for MCPServerInfo
|
|
16
17
|
constructor() {
|
|
@@ -38,7 +39,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
38
39
|
category: detectCategory({ isBuiltIn: true, serverId: "direct" }),
|
|
39
40
|
};
|
|
40
41
|
this.tools.set(toolId, toolInfo);
|
|
41
|
-
this.
|
|
42
|
+
this.toolImplementations.set(toolId, {
|
|
42
43
|
execute: async (params, context) => {
|
|
43
44
|
try {
|
|
44
45
|
// Direct tools from AI SDK expect their specific parameter structure
|
|
@@ -80,11 +81,11 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
80
81
|
async registerServer(serverInfoOrId, serverConfigOrContext, context) {
|
|
81
82
|
// Handle both signatures for backward compatibility
|
|
82
83
|
let serverInfo;
|
|
83
|
-
let
|
|
84
|
+
let _finalContext;
|
|
84
85
|
if (typeof serverInfoOrId === "string") {
|
|
85
86
|
// Legacy signature: registerServer(serverId, serverConfig, context)
|
|
86
87
|
const serverId = serverInfoOrId;
|
|
87
|
-
|
|
88
|
+
_finalContext = context;
|
|
88
89
|
// Convert legacy call to MCPServerInfo format using smart defaults
|
|
89
90
|
serverInfo = createMCPServerInfo({
|
|
90
91
|
id: serverId,
|
|
@@ -96,7 +97,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
96
97
|
else {
|
|
97
98
|
// New signature: registerServer(serverInfo, context)
|
|
98
99
|
serverInfo = serverInfoOrId;
|
|
99
|
-
|
|
100
|
+
_finalContext = serverConfigOrContext;
|
|
100
101
|
}
|
|
101
102
|
const serverId = serverInfo.id;
|
|
102
103
|
registryLogger.info(`Registering MCPServerInfo directly: ${serverId}`);
|
|
@@ -153,7 +154,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
153
154
|
// Register only with fully-qualified toolId to avoid collisions
|
|
154
155
|
this.tools.set(toolId, toolInfo);
|
|
155
156
|
// Store the actual tool implementation for execution using toolId as key
|
|
156
|
-
this.
|
|
157
|
+
this.toolImplementations.set(toolId, {
|
|
157
158
|
execute: tool.execute ||
|
|
158
159
|
(async () => {
|
|
159
160
|
throw new Error(`Tool ${tool.name} has no execute function`);
|
|
@@ -234,9 +235,9 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
234
235
|
...context,
|
|
235
236
|
};
|
|
236
237
|
// Get the tool implementation using the resolved toolId
|
|
237
|
-
const toolImpl = this.
|
|
238
|
+
const toolImpl = this.toolImplementations.get(toolId);
|
|
238
239
|
registryLogger.debug(`Looking for tool '${toolName}' (toolId: '${toolId}'), found: ${!!toolImpl}, type: ${typeof toolImpl?.execute}`);
|
|
239
|
-
registryLogger.debug(`Available tools:`, Array.from(this.
|
|
240
|
+
registryLogger.debug(`Available tools:`, Array.from(this.toolImplementations.keys()));
|
|
240
241
|
if (!toolImpl || typeof toolImpl?.execute !== "function") {
|
|
241
242
|
throw new Error(`Tool '${toolName}' implementation not found or not executable`);
|
|
242
243
|
}
|
|
@@ -347,7 +348,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
347
348
|
if (filter.permissions && filter.permissions.length > 0) {
|
|
348
349
|
result = result.filter((tool) => {
|
|
349
350
|
const toolPermissions = tool.permissions || [];
|
|
350
|
-
return filter.permissions
|
|
351
|
+
return (filter.permissions?.some((perm) => toolPermissions.includes(perm)) ?? false);
|
|
351
352
|
});
|
|
352
353
|
}
|
|
353
354
|
}
|
|
@@ -450,55 +451,25 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
450
451
|
* Register a tool with implementation directly
|
|
451
452
|
* This is used for external MCP server tools
|
|
452
453
|
*/
|
|
453
|
-
registerTool(toolId, toolInfo, toolImpl) {
|
|
454
|
+
async registerTool(toolId, toolInfo, toolImpl) {
|
|
454
455
|
registryLogger.debug(`Registering tool: ${toolId}`);
|
|
455
|
-
//
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
(
|
|
463
|
-
|
|
464
|
-
}
|
|
465
|
-
catch (error) {
|
|
466
|
-
// Fallback: skip validation if import fails (graceful degradation)
|
|
467
|
-
registryLogger.warn("Tool validation module not available, skipping advanced validation", {
|
|
468
|
-
error: error instanceof Error ? error.message : String(error),
|
|
469
|
-
});
|
|
470
|
-
// Create minimal validation functions
|
|
471
|
-
validateTool = () => { }; // No-op
|
|
472
|
-
isToolNameAvailable = () => true; // Allow all names
|
|
473
|
-
suggestToolNames = () => ["alternative_tool"];
|
|
474
|
-
}
|
|
475
|
-
// Check if tool name is available (not reserved)
|
|
476
|
-
if (!isToolNameAvailable(toolId)) {
|
|
477
|
-
const suggestions = suggestToolNames(toolId);
|
|
478
|
-
registryLogger.error(`Tool registration failed for ${toolId}: Name not available`);
|
|
479
|
-
throw new Error(`Tool name '${toolId}' is not available (reserved or invalid format). ` +
|
|
480
|
-
`Suggested alternatives: ${suggestions.slice(0, 3).join(", ")}`);
|
|
456
|
+
// Universal safety validation using FlexibleToolValidator
|
|
457
|
+
// Only blocks truly dangerous cases to support maximum MCP tool compatibility
|
|
458
|
+
const validation = FlexibleToolValidator.validateToolInfo(toolId, {
|
|
459
|
+
description: toolInfo.description,
|
|
460
|
+
serverId: toolInfo.serverId,
|
|
461
|
+
});
|
|
462
|
+
if (!validation.isValid) {
|
|
463
|
+
registryLogger.error(`Tool registration failed for ${toolId}: ${validation.error}`);
|
|
464
|
+
throw new Error(`Tool validation failed: ${validation.error}`);
|
|
481
465
|
}
|
|
482
|
-
//
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
execute: async () => "",
|
|
486
|
-
parameters: undefined,
|
|
487
|
-
metadata: {
|
|
488
|
-
category: toolInfo.category,
|
|
489
|
-
serverId: toolInfo.serverId,
|
|
490
|
-
},
|
|
491
|
-
};
|
|
492
|
-
// Use comprehensive validation logic
|
|
493
|
-
try {
|
|
494
|
-
validateTool(toolId, toolForValidation);
|
|
495
|
-
}
|
|
496
|
-
catch (error) {
|
|
497
|
-
registryLogger.error(`Tool registration failed for ${toolId}:`, error instanceof Error ? error.message : String(error));
|
|
498
|
-
throw error;
|
|
466
|
+
// Log any warnings but allow registration to proceed
|
|
467
|
+
if (validation.warnings && validation.warnings.length > 0) {
|
|
468
|
+
registryLogger.warn(`Tool registration warnings for ${toolId}:`, validation.warnings);
|
|
499
469
|
}
|
|
470
|
+
registryLogger.debug(`✅ Tool '${toolId}' passed flexible validation - registration proceeding`);
|
|
500
471
|
this.tools.set(toolId, toolInfo);
|
|
501
|
-
this.
|
|
472
|
+
this.toolImplementations.set(toolId, toolImpl);
|
|
502
473
|
registryLogger.debug(`Successfully registered tool: ${toolId}`);
|
|
503
474
|
}
|
|
504
475
|
/**
|
|
@@ -509,6 +480,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
509
480
|
let removed = false;
|
|
510
481
|
if (this.tools.has(toolName)) {
|
|
511
482
|
this.tools.delete(toolName);
|
|
483
|
+
this.toolImplementations.delete(toolName); // Fix memory leak
|
|
512
484
|
this.toolExecutionStats.delete(toolName);
|
|
513
485
|
registryLogger.info(`Removed tool: ${toolName}`);
|
|
514
486
|
removed = true;
|
|
@@ -518,6 +490,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
518
490
|
for (const [toolId, tool] of Array.from(this.tools.entries())) {
|
|
519
491
|
if (tool.name === toolName) {
|
|
520
492
|
this.tools.delete(toolId);
|
|
493
|
+
this.toolImplementations.delete(toolId); // Fix memory leak
|
|
521
494
|
this.toolExecutionStats.delete(toolId);
|
|
522
495
|
registryLogger.info(`Removed tool: ${toolId}`);
|
|
523
496
|
removed = true;
|
|
@@ -567,6 +540,8 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
|
567
540
|
for (const [toolId, tool] of this.tools.entries()) {
|
|
568
541
|
if (tool.serverId === serverId) {
|
|
569
542
|
this.tools.delete(toolId);
|
|
543
|
+
this.toolImplementations.delete(toolId); // Fix memory leak
|
|
544
|
+
this.toolExecutionStats.delete(toolId); // Fix memory leak
|
|
570
545
|
removedTools.push(toolId);
|
|
571
546
|
}
|
|
572
547
|
}
|
|
@@ -30,10 +30,10 @@ export function createAnalyticsMiddleware() {
|
|
|
30
30
|
responseTime,
|
|
31
31
|
timestamp: new Date().toISOString(),
|
|
32
32
|
usage: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
(result.usage?.completionTokens
|
|
33
|
+
input: result.usage?.promptTokens ?? 0,
|
|
34
|
+
output: result.usage?.completionTokens ?? 0,
|
|
35
|
+
total: (result.usage?.promptTokens ?? 0) +
|
|
36
|
+
(result.usage?.completionTokens ?? 0),
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
// Store metrics for potential retrieval
|
|
@@ -13,7 +13,7 @@ export function createGuardrailsMiddleware(config = {}) {
|
|
|
13
13
|
defaultEnabled: true,
|
|
14
14
|
};
|
|
15
15
|
const middleware = {
|
|
16
|
-
wrapGenerate: async ({ doGenerate, params }) => {
|
|
16
|
+
wrapGenerate: async ({ doGenerate, params: _params }) => {
|
|
17
17
|
logger.debug(`[GuardrailsMiddleware] Applying to generate call.`, {
|
|
18
18
|
badWordsEnabled: !!config.badWords?.enabled,
|
|
19
19
|
modelFilterEnabled: !!config.modelFilter?.enabled,
|
|
@@ -53,7 +53,7 @@ export function createGuardrailsMiddleware(config = {}) {
|
|
|
53
53
|
}
|
|
54
54
|
return result;
|
|
55
55
|
},
|
|
56
|
-
wrapStream: async ({ doStream, params }) => {
|
|
56
|
+
wrapStream: async ({ doStream, params: _params }) => {
|
|
57
57
|
logger.debug(`[GuardrailsMiddleware] Applying to stream call.`, {
|
|
58
58
|
badWordsEnabled: !!config.badWords?.enabled,
|
|
59
59
|
});
|
|
@@ -135,9 +135,9 @@ export class MiddlewareRegistry {
|
|
|
135
135
|
/**
|
|
136
136
|
* Configure middleware with runtime configuration
|
|
137
137
|
*/
|
|
138
|
-
configureMiddleware(middleware, config, globalConfig,
|
|
138
|
+
configureMiddleware(middleware, config, globalConfig, _context) {
|
|
139
139
|
// Merge configurations: global < middleware config < runtime config
|
|
140
|
-
const
|
|
140
|
+
const _mergedConfig = {
|
|
141
141
|
...globalConfig,
|
|
142
142
|
...config?.config,
|
|
143
143
|
};
|
|
@@ -149,6 +149,9 @@ export class MiddlewareRegistry {
|
|
|
149
149
|
wrappedMiddleware.transformParams = async (args) => {
|
|
150
150
|
const startTime = Date.now();
|
|
151
151
|
try {
|
|
152
|
+
if (!middleware.transformParams) {
|
|
153
|
+
throw new Error("transformParams method is required");
|
|
154
|
+
}
|
|
152
155
|
const result = await middleware.transformParams(args);
|
|
153
156
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
154
157
|
return result;
|
|
@@ -163,6 +166,9 @@ export class MiddlewareRegistry {
|
|
|
163
166
|
wrappedMiddleware.wrapGenerate = async (args) => {
|
|
164
167
|
const startTime = Date.now();
|
|
165
168
|
try {
|
|
169
|
+
if (!middleware.wrapGenerate) {
|
|
170
|
+
throw new Error("wrapGenerate method is required");
|
|
171
|
+
}
|
|
166
172
|
const result = await middleware.wrapGenerate(args);
|
|
167
173
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
168
174
|
return result;
|
|
@@ -177,6 +183,9 @@ export class MiddlewareRegistry {
|
|
|
177
183
|
wrappedMiddleware.wrapStream = async (args) => {
|
|
178
184
|
const startTime = Date.now();
|
|
179
185
|
try {
|
|
186
|
+
if (!middleware.wrapStream) {
|
|
187
|
+
throw new Error("wrapStream method is required");
|
|
188
|
+
}
|
|
180
189
|
const result = await middleware.wrapStream(args);
|
|
181
190
|
this.recordExecution(middleware.metadata.id, startTime, true);
|
|
182
191
|
return result;
|
|
@@ -125,7 +125,7 @@ export declare function getAvailableProviders(): AIProviderName[];
|
|
|
125
125
|
/**
|
|
126
126
|
* Calculate estimated cost for a request
|
|
127
127
|
*/
|
|
128
|
-
export declare function calculateCost(model: ModelInfo,
|
|
128
|
+
export declare function calculateCost(model: ModelInfo, input: number, output: number): number;
|
|
129
129
|
/**
|
|
130
130
|
* Format model for display
|
|
131
131
|
*/
|
|
@@ -445,9 +445,9 @@ export function getAvailableProviders() {
|
|
|
445
445
|
/**
|
|
446
446
|
* Calculate estimated cost for a request
|
|
447
447
|
*/
|
|
448
|
-
export function calculateCost(model,
|
|
449
|
-
const inputCost = (
|
|
450
|
-
const outputCost = (
|
|
448
|
+
export function calculateCost(model, input, output) {
|
|
449
|
+
const inputCost = (input / 1000) * model.pricing.inputCostPer1K;
|
|
450
|
+
const outputCost = (output / 1000) * model.pricing.outputCostPer1K;
|
|
451
451
|
return inputCost + outputCost;
|
|
452
452
|
}
|
|
453
453
|
/**
|
|
@@ -76,7 +76,7 @@ export declare class ModelResolver {
|
|
|
76
76
|
/**
|
|
77
77
|
* Calculate cost comparison for models
|
|
78
78
|
*/
|
|
79
|
-
static calculateCostComparison(models: ModelInfo[],
|
|
79
|
+
static calculateCostComparison(models: ModelInfo[], input?: number, output?: number): Array<{
|
|
80
80
|
model: ModelInfo;
|
|
81
81
|
cost: number;
|
|
82
82
|
costPer1K: number;
|
|
@@ -160,11 +160,11 @@ export class ModelResolver {
|
|
|
160
160
|
/**
|
|
161
161
|
* Calculate cost comparison for models
|
|
162
162
|
*/
|
|
163
|
-
static calculateCostComparison(models,
|
|
163
|
+
static calculateCostComparison(models, input = 1000, output = 500) {
|
|
164
164
|
return models
|
|
165
165
|
.map((model) => ({
|
|
166
166
|
model,
|
|
167
|
-
cost: calculateCost(model,
|
|
167
|
+
cost: calculateCost(model, input, output),
|
|
168
168
|
costPer1K: model.pricing.inputCostPer1K + model.pricing.outputCostPer1K,
|
|
169
169
|
}))
|
|
170
170
|
.sort((a, b) => a.cost - b.cost);
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -54,6 +54,8 @@ export declare class NeuroLink {
|
|
|
54
54
|
* @param toolName - Name of the tool
|
|
55
55
|
* @param startTime - Timestamp when tool execution started
|
|
56
56
|
* @param success - Whether the tool execution was successful
|
|
57
|
+
* @param result - The result of the tool execution (optional)
|
|
58
|
+
* @param error - The error if execution failed (optional)
|
|
57
59
|
*/
|
|
58
60
|
private emitToolEndEvent;
|
|
59
61
|
private conversationMemory?;
|
|
@@ -88,11 +90,71 @@ export declare class NeuroLink {
|
|
|
88
90
|
constructor(config?: {
|
|
89
91
|
conversationMemory?: Partial<ConversationMemoryConfig>;
|
|
90
92
|
});
|
|
93
|
+
/**
|
|
94
|
+
* Log constructor start with comprehensive environment analysis
|
|
95
|
+
*/
|
|
96
|
+
private logConstructorStart;
|
|
97
|
+
/**
|
|
98
|
+
* Initialize provider registry with security settings
|
|
99
|
+
*/
|
|
100
|
+
private initializeProviderRegistry;
|
|
101
|
+
/**
|
|
102
|
+
* Initialize conversation memory if enabled
|
|
103
|
+
*/
|
|
104
|
+
private initializeConversationMemory;
|
|
105
|
+
/**
|
|
106
|
+
* Initialize external server manager with event handlers
|
|
107
|
+
*/
|
|
108
|
+
private initializeExternalServerManager;
|
|
109
|
+
/**
|
|
110
|
+
* Setup event handlers for external server manager
|
|
111
|
+
*/
|
|
112
|
+
private setupExternalServerEventHandlers;
|
|
113
|
+
/**
|
|
114
|
+
* Log constructor completion with final state summary
|
|
115
|
+
*/
|
|
116
|
+
private logConstructorComplete;
|
|
91
117
|
/**
|
|
92
118
|
* Initialize MCP registry with enhanced error handling and resource cleanup
|
|
93
119
|
* Uses isolated async context to prevent hanging
|
|
94
120
|
*/
|
|
95
121
|
private initializeMCP;
|
|
122
|
+
/**
|
|
123
|
+
* Log MCP initialization start
|
|
124
|
+
*/
|
|
125
|
+
private logMCPInitStart;
|
|
126
|
+
/**
|
|
127
|
+
* Log MCP already initialized
|
|
128
|
+
*/
|
|
129
|
+
private logMCPAlreadyInitialized;
|
|
130
|
+
/**
|
|
131
|
+
* Import performance manager with error handling
|
|
132
|
+
*/
|
|
133
|
+
private importPerformanceManager;
|
|
134
|
+
/**
|
|
135
|
+
* Perform main MCP initialization logic
|
|
136
|
+
*/
|
|
137
|
+
private performMCPInitialization;
|
|
138
|
+
/**
|
|
139
|
+
* Initialize tool registry with timeout protection
|
|
140
|
+
*/
|
|
141
|
+
private initializeToolRegistryInternal;
|
|
142
|
+
/**
|
|
143
|
+
* Initialize provider registry
|
|
144
|
+
*/
|
|
145
|
+
private initializeProviderRegistryInternal;
|
|
146
|
+
/**
|
|
147
|
+
* Register direct tools server
|
|
148
|
+
*/
|
|
149
|
+
private registerDirectToolsServerInternal;
|
|
150
|
+
/**
|
|
151
|
+
* Load MCP configuration from .mcp-config.json
|
|
152
|
+
*/
|
|
153
|
+
private loadMCPConfigurationInternal;
|
|
154
|
+
/**
|
|
155
|
+
* Log MCP initialization completion
|
|
156
|
+
*/
|
|
157
|
+
private logMCPInitComplete;
|
|
96
158
|
/**
|
|
97
159
|
* MAIN ENTRY POINT: Enhanced generate method with new function signature
|
|
98
160
|
* Replaces both generateText and legacy methods
|
|
@@ -177,6 +239,26 @@ export declare class NeuroLink {
|
|
|
177
239
|
* 5. Store conversation turn for future context
|
|
178
240
|
*/
|
|
179
241
|
private generateTextInternal;
|
|
242
|
+
/**
|
|
243
|
+
* Log generateTextInternal start with comprehensive analysis
|
|
244
|
+
*/
|
|
245
|
+
private logGenerateTextInternalStart;
|
|
246
|
+
/**
|
|
247
|
+
* Emit generation start events
|
|
248
|
+
*/
|
|
249
|
+
private emitGenerationStartEvents;
|
|
250
|
+
/**
|
|
251
|
+
* Initialize conversation memory for generation
|
|
252
|
+
*/
|
|
253
|
+
private initializeConversationMemoryForGeneration;
|
|
254
|
+
/**
|
|
255
|
+
* Attempt MCP generation with retry logic
|
|
256
|
+
*/
|
|
257
|
+
private attemptMCPGeneration;
|
|
258
|
+
/**
|
|
259
|
+
* Perform MCP generation with retry logic
|
|
260
|
+
*/
|
|
261
|
+
private performMCPGenerationRetries;
|
|
180
262
|
/**
|
|
181
263
|
* Try MCP-enhanced generation (no fallback recursion)
|
|
182
264
|
*/
|
|
@@ -255,6 +337,42 @@ export declare class NeuroLink {
|
|
|
255
337
|
* @throws {Error} When conversation memory operations fail (if enabled)
|
|
256
338
|
*/
|
|
257
339
|
stream(options: StreamOptions): Promise<StreamResult>;
|
|
340
|
+
/**
|
|
341
|
+
* Log stream entry point with comprehensive analysis
|
|
342
|
+
*/
|
|
343
|
+
private logStreamEntryPoint;
|
|
344
|
+
/**
|
|
345
|
+
* Log performance baseline
|
|
346
|
+
*/
|
|
347
|
+
private logPerformanceBaseline;
|
|
348
|
+
/**
|
|
349
|
+
* Validate stream input with comprehensive error reporting
|
|
350
|
+
*/
|
|
351
|
+
private validateStreamInput;
|
|
352
|
+
/**
|
|
353
|
+
* Emit stream start events
|
|
354
|
+
*/
|
|
355
|
+
private emitStreamStartEvents;
|
|
356
|
+
/**
|
|
357
|
+
* Create MCP stream
|
|
358
|
+
*/
|
|
359
|
+
private createMCPStream;
|
|
360
|
+
/**
|
|
361
|
+
* Process stream result
|
|
362
|
+
*/
|
|
363
|
+
private processStreamResult;
|
|
364
|
+
/**
|
|
365
|
+
* Emit stream end events
|
|
366
|
+
*/
|
|
367
|
+
private emitStreamEndEvents;
|
|
368
|
+
/**
|
|
369
|
+
* Create stream response
|
|
370
|
+
*/
|
|
371
|
+
private createStreamResponse;
|
|
372
|
+
/**
|
|
373
|
+
* Handle stream error with fallback
|
|
374
|
+
*/
|
|
375
|
+
private handleStreamError;
|
|
258
376
|
/**
|
|
259
377
|
* Get the EventEmitter instance to listen to NeuroLink events for real-time monitoring and debugging.
|
|
260
378
|
* This method provides access to the internal event system that emits events during AI generation,
|