@juspay/neurolink 7.37.0 → 7.37.1
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 +6 -0
- package/dist/cli/commands/config.d.ts +18 -18
- package/dist/cli/factories/commandFactory.d.ts +24 -0
- package/dist/cli/factories/commandFactory.js +297 -245
- package/dist/core/baseProvider.d.ts +40 -3
- package/dist/core/baseProvider.js +689 -352
- package/dist/core/constants.d.ts +2 -30
- package/dist/core/constants.js +15 -43
- package/dist/factories/providerFactory.js +23 -6
- package/dist/index.d.ts +3 -2
- package/dist/index.js +4 -3
- package/dist/lib/core/baseProvider.d.ts +40 -3
- package/dist/lib/core/baseProvider.js +689 -352
- package/dist/lib/core/constants.d.ts +2 -30
- package/dist/lib/core/constants.js +15 -43
- package/dist/lib/factories/providerFactory.js +23 -6
- package/dist/lib/index.d.ts +3 -2
- package/dist/lib/index.js +4 -3
- package/dist/lib/mcp/externalServerManager.js +2 -2
- package/dist/lib/mcp/registry.js +2 -2
- package/dist/lib/mcp/servers/agent/directToolsServer.js +19 -10
- package/dist/lib/mcp/toolRegistry.js +4 -8
- package/dist/lib/neurolink.d.ts +62 -27
- package/dist/lib/neurolink.js +415 -719
- package/dist/lib/providers/amazonBedrock.js +2 -2
- package/dist/lib/providers/googleVertex.d.ts +3 -23
- package/dist/lib/providers/googleVertex.js +14 -342
- package/dist/lib/providers/openAI.d.ts +23 -0
- package/dist/lib/providers/openAI.js +313 -6
- package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/lib/sdk/toolRegistration.js +18 -1
- package/dist/lib/types/common.d.ts +98 -0
- package/dist/lib/types/streamTypes.d.ts +13 -6
- package/dist/lib/types/typeAliases.d.ts +3 -2
- package/dist/lib/utils/parameterValidation.js +6 -25
- package/dist/lib/utils/promptRedaction.js +4 -4
- package/dist/lib/utils/schemaConversion.d.ts +14 -0
- package/dist/lib/utils/schemaConversion.js +140 -0
- package/dist/lib/utils/transformationUtils.js +143 -5
- package/dist/mcp/externalServerManager.js +2 -2
- package/dist/mcp/registry.js +2 -2
- package/dist/mcp/servers/agent/directToolsServer.js +19 -10
- package/dist/mcp/toolRegistry.js +4 -8
- package/dist/neurolink.d.ts +62 -27
- package/dist/neurolink.js +415 -719
- package/dist/providers/amazonBedrock.js +2 -2
- package/dist/providers/googleVertex.d.ts +3 -23
- package/dist/providers/googleVertex.js +14 -342
- package/dist/providers/openAI.d.ts +23 -0
- package/dist/providers/openAI.js +313 -6
- package/dist/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/sdk/toolRegistration.js +18 -1
- package/dist/types/common.d.ts +98 -0
- package/dist/types/streamTypes.d.ts +13 -6
- package/dist/types/typeAliases.d.ts +3 -2
- package/dist/utils/parameterValidation.js +6 -25
- package/dist/utils/promptRedaction.js +4 -4
- package/dist/utils/schemaConversion.d.ts +14 -0
- package/dist/utils/schemaConversion.js +140 -0
- package/dist/utils/transformationUtils.js +143 -5
- package/package.json +3 -2
@@ -4,8 +4,8 @@
|
|
4
4
|
*/
|
5
5
|
export declare const DEFAULT_MAX_TOKENS: undefined;
|
6
6
|
export declare const DEFAULT_TEMPERATURE = 0.7;
|
7
|
-
export declare const DEFAULT_TIMEOUT =
|
8
|
-
export declare const DEFAULT_MAX_STEPS =
|
7
|
+
export declare const DEFAULT_TIMEOUT = 60000;
|
8
|
+
export declare const DEFAULT_MAX_STEPS = 200;
|
9
9
|
export declare const STEP_LIMITS: {
|
10
10
|
min: number;
|
11
11
|
max: number;
|
@@ -31,49 +31,21 @@ export declare const PROVIDER_CONFIG: {
|
|
31
31
|
};
|
32
32
|
export declare const PROVIDER_MAX_TOKENS: {
|
33
33
|
anthropic: {
|
34
|
-
"claude-3-haiku-20240307": number;
|
35
|
-
"claude-3-5-sonnet-20241022": number;
|
36
|
-
"claude-3-opus-20240229": number;
|
37
|
-
"claude-3-5-sonnet-20240620": number;
|
38
34
|
default: number;
|
39
35
|
};
|
40
36
|
openai: {
|
41
|
-
"gpt-4o": number;
|
42
|
-
"gpt-4o-mini": number;
|
43
|
-
"gpt-3.5-turbo": number;
|
44
|
-
"gpt-4": number;
|
45
|
-
"gpt-4-turbo": number;
|
46
37
|
default: number;
|
47
38
|
};
|
48
39
|
"google-ai": {
|
49
|
-
"gemini-1.5-pro": number;
|
50
|
-
"gemini-1.5-flash": number;
|
51
|
-
"gemini-2.5-pro": number;
|
52
|
-
"gemini-2.5-flash": number;
|
53
|
-
"gemini-pro": number;
|
54
40
|
default: number;
|
55
41
|
};
|
56
42
|
vertex: {
|
57
|
-
"gemini-1.5-pro": number;
|
58
|
-
"gemini-1.5-flash": number;
|
59
|
-
"gemini-2.5-pro": number;
|
60
|
-
"gemini-2.5-flash": number;
|
61
|
-
"claude-4.0-sonnet": number;
|
62
43
|
default: number;
|
63
44
|
};
|
64
45
|
bedrock: {
|
65
|
-
"anthropic.claude-3-sonnet-20240229-v1:0": number;
|
66
|
-
"anthropic.claude-3-haiku-20240307-v1:0": number;
|
67
|
-
"anthropic.claude-3-5-sonnet-20240620-v1:0": number;
|
68
46
|
default: number;
|
69
47
|
};
|
70
48
|
azure: {
|
71
|
-
"gpt-4o": number;
|
72
|
-
"gpt-4o-mini": number;
|
73
|
-
"gpt-4.1": number;
|
74
|
-
"gpt-3.5-turbo": number;
|
75
|
-
"gpt-4": number;
|
76
|
-
"gpt-4-turbo": number;
|
77
49
|
default: number;
|
78
50
|
};
|
79
51
|
ollama: {
|
@@ -5,12 +5,12 @@
|
|
5
5
|
// Core AI Generation Defaults
|
6
6
|
export const DEFAULT_MAX_TOKENS = undefined; // Unlimited by default - let providers decide their own limits
|
7
7
|
export const DEFAULT_TEMPERATURE = 0.7;
|
8
|
-
export const DEFAULT_TIMEOUT =
|
9
|
-
export const DEFAULT_MAX_STEPS =
|
8
|
+
export const DEFAULT_TIMEOUT = 60000;
|
9
|
+
export const DEFAULT_MAX_STEPS = 200;
|
10
10
|
// Step execution limits
|
11
11
|
export const STEP_LIMITS = {
|
12
12
|
min: 1,
|
13
|
-
max:
|
13
|
+
max: 500,
|
14
14
|
default: DEFAULT_MAX_STEPS,
|
15
15
|
};
|
16
16
|
// Specialized Use Case Defaults
|
@@ -33,68 +33,40 @@ export const PROVIDER_CONFIG = {
|
|
33
33
|
temperature: 0.4,
|
34
34
|
},
|
35
35
|
};
|
36
|
-
// Provider-specific maxTokens limits
|
36
|
+
// Provider-specific maxTokens limits
|
37
37
|
export const PROVIDER_MAX_TOKENS = {
|
38
38
|
anthropic: {
|
39
|
-
|
40
|
-
"claude-3-5-sonnet-20241022": 4096,
|
41
|
-
"claude-3-opus-20240229": 4096,
|
42
|
-
"claude-3-5-sonnet-20240620": 4096,
|
43
|
-
default: 4096, // Conservative default for Anthropic
|
39
|
+
default: 64000,
|
44
40
|
},
|
45
41
|
openai: {
|
46
|
-
|
47
|
-
"gpt-4o-mini": 16384,
|
48
|
-
"gpt-3.5-turbo": 4096,
|
49
|
-
"gpt-4": 8192,
|
50
|
-
"gpt-4-turbo": 4096,
|
51
|
-
default: 8192, // OpenAI generally supports higher limits
|
42
|
+
default: 500000,
|
52
43
|
},
|
53
44
|
"google-ai": {
|
54
|
-
|
55
|
-
"gemini-1.5-flash": 8192,
|
56
|
-
"gemini-2.5-pro": 8192,
|
57
|
-
"gemini-2.5-flash": 8192,
|
58
|
-
"gemini-pro": 4096,
|
59
|
-
default: 4096, // Conservative default due to 500 errors at high limits
|
45
|
+
default: 64000,
|
60
46
|
},
|
61
47
|
vertex: {
|
62
|
-
|
63
|
-
"gemini-1.5-flash": 8192,
|
64
|
-
"gemini-2.5-pro": 8192,
|
65
|
-
"gemini-2.5-flash": 8192,
|
66
|
-
"claude-4.0-sonnet": 4096,
|
67
|
-
default: 4096,
|
48
|
+
default: 64000,
|
68
49
|
},
|
69
50
|
bedrock: {
|
70
|
-
|
71
|
-
"anthropic.claude-3-haiku-20240307-v1:0": 4096,
|
72
|
-
"anthropic.claude-3-5-sonnet-20240620-v1:0": 4096,
|
73
|
-
default: 4096,
|
51
|
+
default: 64000,
|
74
52
|
},
|
75
53
|
azure: {
|
76
|
-
|
77
|
-
"gpt-4o-mini": 16384,
|
78
|
-
"gpt-4.1": 16384,
|
79
|
-
"gpt-3.5-turbo": 4096,
|
80
|
-
"gpt-4": 8192,
|
81
|
-
"gpt-4-turbo": 4096,
|
82
|
-
default: 8192, // Azure OpenAI generally supports similar limits to OpenAI
|
54
|
+
default: 64000,
|
83
55
|
},
|
84
56
|
ollama: {
|
85
|
-
default:
|
57
|
+
default: 64000,
|
86
58
|
},
|
87
59
|
litellm: {
|
88
|
-
default:
|
60
|
+
default: 500000,
|
89
61
|
},
|
90
|
-
default:
|
62
|
+
default: 64000,
|
91
63
|
};
|
92
64
|
// CLI Validation Limits
|
93
65
|
export const CLI_LIMITS = {
|
94
66
|
maxTokens: {
|
95
67
|
min: 1,
|
96
|
-
max:
|
97
|
-
default:
|
68
|
+
max: 64000,
|
69
|
+
default: DEFAULT_MAX_TOKENS,
|
98
70
|
},
|
99
71
|
temperature: {
|
100
72
|
min: 0,
|
@@ -49,16 +49,33 @@ export class ProviderFactory {
|
|
49
49
|
model = model || registration.defaultModel;
|
50
50
|
}
|
51
51
|
try {
|
52
|
+
if (typeof registration.constructor !== "function") {
|
53
|
+
throw new Error(`Invalid constructor for provider ${providerName}: not a function`);
|
54
|
+
}
|
52
55
|
let result;
|
53
56
|
try {
|
54
|
-
|
55
|
-
|
57
|
+
const factoryResult = registration.constructor(model, providerName, sdk);
|
58
|
+
// Handle both sync and async results
|
59
|
+
result =
|
60
|
+
factoryResult instanceof Promise
|
61
|
+
? await factoryResult
|
62
|
+
: factoryResult;
|
56
63
|
}
|
57
|
-
catch {
|
58
|
-
|
59
|
-
|
64
|
+
catch (factoryError) {
|
65
|
+
if (registration.constructor.prototype &&
|
66
|
+
registration.constructor.prototype.constructor ===
|
67
|
+
registration.constructor) {
|
68
|
+
try {
|
69
|
+
result = new registration.constructor(model, providerName, sdk);
|
70
|
+
}
|
71
|
+
catch (constructorError) {
|
72
|
+
throw new Error(`Both factory function and constructor failed. Factory error: ${factoryError}. Constructor error: ${constructorError}`);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
throw factoryError;
|
77
|
+
}
|
60
78
|
}
|
61
|
-
// Return result (no need to await again if already awaited in try block)
|
62
79
|
return result;
|
63
80
|
}
|
64
81
|
catch (error) {
|
package/dist/lib/index.d.ts
CHANGED
@@ -17,7 +17,8 @@ export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, }
|
|
17
17
|
export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
|
18
18
|
export { dynamicModelProvider } from "./core/dynamicModels.js";
|
19
19
|
export type { DynamicModelConfig, ModelRegistry } from "./types/modelTypes.js";
|
20
|
-
|
20
|
+
import { NeuroLink } from "./neurolink.js";
|
21
|
+
export { NeuroLink };
|
21
22
|
export type { ProviderStatus, MCPStatus } from "./neurolink.js";
|
22
23
|
export type { MCPServerInfo } from "./types/mcpTypes.js";
|
23
24
|
export type { NeuroLinkMiddleware, MiddlewareContext, MiddlewareFactoryOptions, MiddlewarePreset, MiddlewareConfig, } from "./types/middlewareTypes.js";
|
@@ -102,4 +103,4 @@ export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, Evalua
|
|
102
103
|
* console.log(result.content);
|
103
104
|
* ```
|
104
105
|
*/
|
105
|
-
export declare function generateText(options: import("./types
|
106
|
+
export declare function generateText(options: import("./core/types.js").TextGenerationOptions): Promise<import("./core/types.js").TextGenerationResult>;
|
package/dist/lib/index.js
CHANGED
@@ -17,7 +17,8 @@ export { getBestProvider, getAvailableProviders, isValidProvider, } from "./util
|
|
17
17
|
// Dynamic Models exports
|
18
18
|
export { dynamicModelProvider } from "./core/dynamicModels.js";
|
19
19
|
// Main NeuroLink wrapper class and diagnostic types
|
20
|
-
|
20
|
+
import { NeuroLink } from "./neurolink.js";
|
21
|
+
export { NeuroLink };
|
21
22
|
export { MiddlewareFactory } from "./middleware/factory.js";
|
22
23
|
// Version
|
23
24
|
export const VERSION = "1.0.0";
|
@@ -127,7 +128,7 @@ export function getTelemetryStatus() {
|
|
127
128
|
* ```
|
128
129
|
*/
|
129
130
|
export async function generateText(options) {
|
130
|
-
//
|
131
|
-
const
|
131
|
+
// Create instance on-demand without auto-instantiation
|
132
|
+
const neurolink = new NeuroLink();
|
132
133
|
return await neurolink.generateText(options);
|
133
134
|
}
|
@@ -89,9 +89,9 @@ export class ExternalServerManager extends EventEmitter {
|
|
89
89
|
enablePerformanceMonitoring: config.enablePerformanceMonitoring ?? true,
|
90
90
|
logLevel: config.logLevel ?? "info",
|
91
91
|
};
|
92
|
-
//
|
92
|
+
// Disable main tool registry integration by default to prevent automatic tool execution
|
93
93
|
this.enableMainRegistryIntegration =
|
94
|
-
options.enableMainRegistryIntegration ??
|
94
|
+
options.enableMainRegistryIntegration ?? false;
|
95
95
|
// Initialize tool discovery service
|
96
96
|
this.toolDiscovery = new ToolDiscoveryService();
|
97
97
|
// Forward tool discovery events
|
package/dist/lib/mcp/registry.js
CHANGED
@@ -13,7 +13,7 @@ export class MCPRegistry {
|
|
13
13
|
*/
|
14
14
|
register(plugin) {
|
15
15
|
this.plugins.set(plugin.metadata.name, plugin);
|
16
|
-
registryLogger.
|
16
|
+
registryLogger.debug(`Registered plugin: ${plugin.metadata.name}`);
|
17
17
|
}
|
18
18
|
/**
|
19
19
|
* Unregister a plugin
|
@@ -21,7 +21,7 @@ export class MCPRegistry {
|
|
21
21
|
unregister(name) {
|
22
22
|
const removed = this.plugins.delete(name);
|
23
23
|
if (removed) {
|
24
|
-
registryLogger.
|
24
|
+
registryLogger.debug(`Unregistered plugin: ${name}`);
|
25
25
|
}
|
26
26
|
return removed;
|
27
27
|
}
|
@@ -46,8 +46,24 @@ if (!shouldDisableBuiltinTools()) {
|
|
46
46
|
execute: async (params, context) => {
|
47
47
|
const startTime = Date.now();
|
48
48
|
try {
|
49
|
-
|
50
|
-
|
49
|
+
if (Object.keys(params || {}).length === 0) {
|
50
|
+
return {
|
51
|
+
success: false,
|
52
|
+
data: null,
|
53
|
+
error: "Tool execution blocked: Empty parameters not allowed during startup",
|
54
|
+
usage: {
|
55
|
+
executionTime: Date.now() - startTime,
|
56
|
+
},
|
57
|
+
metadata: {
|
58
|
+
toolName,
|
59
|
+
serverId: "neurolink-direct",
|
60
|
+
sessionId: context.sessionId,
|
61
|
+
blocked: true,
|
62
|
+
reason: "empty_parameters_startup_prevention",
|
63
|
+
timestamp: Date.now(),
|
64
|
+
},
|
65
|
+
};
|
66
|
+
}
|
51
67
|
if (!execute || typeof execute !== "function") {
|
52
68
|
throw new Error(`Tool ${toolName} has no execute function`);
|
53
69
|
}
|
@@ -104,7 +120,7 @@ if (!shouldDisableBuiltinTools()) {
|
|
104
120
|
});
|
105
121
|
}
|
106
122
|
else {
|
107
|
-
logger.
|
123
|
+
logger.debug("Built-in tools disabled via configuration");
|
108
124
|
}
|
109
125
|
/**
|
110
126
|
* Get tool category based on tool name
|
@@ -126,10 +142,3 @@ function getToolCategory(toolName) {
|
|
126
142
|
return "utility";
|
127
143
|
}
|
128
144
|
}
|
129
|
-
// Log successful registration or disable status
|
130
|
-
if (!shouldDisableBuiltinTools()) {
|
131
|
-
logger.info(`[Direct Tools] Registered ${Object.keys(directAgentTools).length} direct tools`);
|
132
|
-
}
|
133
|
-
else {
|
134
|
-
logger.info("[Direct Tools] 0 direct tools registered (disabled via environment variable)");
|
135
|
-
}
|
@@ -16,13 +16,9 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
16
16
|
builtInServerInfos = []; // DIRECT storage for MCPServerInfo
|
17
17
|
constructor() {
|
18
18
|
super();
|
19
|
-
// 🔧 CONDITIONAL: Only auto-register direct tools if not disabled via configuration
|
20
19
|
if (!shouldDisableBuiltinTools()) {
|
21
20
|
this.registerDirectTools();
|
22
21
|
}
|
23
|
-
else {
|
24
|
-
registryLogger.debug("Built-in direct tools disabled via configuration");
|
25
|
-
}
|
26
22
|
}
|
27
23
|
/**
|
28
24
|
* Register all direct tools from directAgentTools
|
@@ -100,7 +96,6 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
100
96
|
_finalContext = serverConfigOrContext;
|
101
97
|
}
|
102
98
|
const serverId = serverInfo.id;
|
103
|
-
registryLogger.info(`Registering MCPServerInfo directly: ${serverId}`);
|
104
99
|
// Use MCPServerInfo.tools array directly - ZERO conversions!
|
105
100
|
const toolsObject = {};
|
106
101
|
for (const tool of serverInfo.tools) {
|
@@ -133,7 +128,6 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
133
128
|
this.register(plugin);
|
134
129
|
// Use MCPServerInfo.tools array directly - ZERO conversions!
|
135
130
|
const tools = serverInfo.tools;
|
136
|
-
registryLogger.debug(`Registering ${tools.length} tools for server ${serverId}:`, tools.map((t) => t.name));
|
137
131
|
for (const tool of tools) {
|
138
132
|
// For custom tools, use just the tool name to avoid redundant serverId.toolName format
|
139
133
|
// For other tools, use fully-qualified serverId.toolName to avoid collisions
|
@@ -166,7 +160,7 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
166
160
|
serverId: serverInfo.id,
|
167
161
|
}),
|
168
162
|
});
|
169
|
-
|
163
|
+
// Tool registered successfully
|
170
164
|
}
|
171
165
|
// Store MCPServerInfo directly - NO recreation needed!
|
172
166
|
if (tools.length > 0) {
|
@@ -211,9 +205,11 @@ export class MCPToolRegistry extends MCPRegistry {
|
|
211
205
|
async executeTool(toolName, args, context) {
|
212
206
|
const startTime = Date.now();
|
213
207
|
try {
|
214
|
-
registryLogger.info(
|
208
|
+
registryLogger.info(`🔧 [TOOL_EXECUTION] Starting execution: ${toolName}`);
|
209
|
+
registryLogger.info(`🔧 [TOOL_EXECUTION] Starting execution: ${toolName}`, { args, context });
|
215
210
|
// Try to find the tool by fully-qualified name first
|
216
211
|
let tool = this.tools.get(toolName);
|
212
|
+
registryLogger.info(`🔍 [TOOL_LOOKUP] Direct lookup result for '${toolName}':`, !!tool);
|
217
213
|
// If not found, search for tool by name across all entries (for backward compatibility)
|
218
214
|
let toolId = toolName;
|
219
215
|
if (!tool) {
|
package/dist/lib/neurolink.d.ts
CHANGED
@@ -10,9 +10,9 @@ import type { GenerateOptions, GenerateResult } from "./types/generateTypes.js";
|
|
10
10
|
import type { StreamOptions, StreamResult } from "./types/streamTypes.js";
|
11
11
|
import type { MCPServerInfo, MCPExecutableTool } from "./types/mcpTypes.js";
|
12
12
|
import type { ToolInfo } from "./mcp/contracts/mcpContract.js";
|
13
|
+
import type { NeuroLinkEvents, TypedEventEmitter, ToolExecutionContext, ToolExecutionSummary } from "./types/common.js";
|
13
14
|
import type { JsonObject } from "./types/common.js";
|
14
15
|
import type { BatchOperationResult } from "./types/typeAliases.js";
|
15
|
-
import { EventEmitter } from "events";
|
16
16
|
import type { ConversationMemoryConfig, ChatMessage } from "./types/conversation.js";
|
17
17
|
import type { ExternalMCPServerInstance, ExternalMCPOperationResult, ExternalMCPToolInfo } from "./types/externalMcp.js";
|
18
18
|
export interface ProviderStatus {
|
@@ -49,6 +49,9 @@ export declare class NeuroLink {
|
|
49
49
|
private readonly toolCacheDuration;
|
50
50
|
private toolCircuitBreakers;
|
51
51
|
private toolExecutionMetrics;
|
52
|
+
private currentStreamToolExecutions;
|
53
|
+
private toolExecutionHistory;
|
54
|
+
private activeToolExecutions;
|
52
55
|
/**
|
53
56
|
* Helper method to emit tool end event in a consistent way
|
54
57
|
* Used by executeTool in both success and error paths
|
@@ -63,6 +66,11 @@ export declare class NeuroLink {
|
|
63
66
|
private conversationMemoryNeedsInit;
|
64
67
|
private conversationMemoryConfig?;
|
65
68
|
private enableOrchestration;
|
69
|
+
/**
|
70
|
+
* Context storage for tool execution
|
71
|
+
* This context will be merged with any runtime context passed by the AI model
|
72
|
+
*/
|
73
|
+
private toolExecutionContext?;
|
66
74
|
/**
|
67
75
|
* Creates a new NeuroLink instance for AI text generation with MCP tool integration.
|
68
76
|
*
|
@@ -101,10 +109,6 @@ export declare class NeuroLink {
|
|
101
109
|
conversationMemory?: Partial<ConversationMemoryConfig>;
|
102
110
|
enableOrchestration?: boolean;
|
103
111
|
});
|
104
|
-
/**
|
105
|
-
* Log constructor start with comprehensive environment analysis
|
106
|
-
*/
|
107
|
-
private logConstructorStart;
|
108
112
|
/**
|
109
113
|
* Initialize provider registry with security settings
|
110
114
|
*/
|
@@ -130,14 +134,6 @@ export declare class NeuroLink {
|
|
130
134
|
* Uses isolated async context to prevent hanging
|
131
135
|
*/
|
132
136
|
private initializeMCP;
|
133
|
-
/**
|
134
|
-
* Log MCP initialization start
|
135
|
-
*/
|
136
|
-
private logMCPInitStart;
|
137
|
-
/**
|
138
|
-
* Log MCP already initialized
|
139
|
-
*/
|
140
|
-
private logMCPAlreadyInitialized;
|
141
137
|
/**
|
142
138
|
* Import performance manager with error handling
|
143
139
|
*/
|
@@ -293,10 +289,6 @@ export declare class NeuroLink {
|
|
293
289
|
* Simplified approach without domain detection - relies on tool registry
|
294
290
|
*/
|
295
291
|
private detectAndExecuteTools;
|
296
|
-
/**
|
297
|
-
* Enhance prompt with tool results (domain-agnostic)
|
298
|
-
*/
|
299
|
-
private enhancePromptWithToolResults;
|
300
292
|
/**
|
301
293
|
* BACKWARD COMPATIBILITY: Legacy streamText method
|
302
294
|
* Internally calls stream() and converts result format
|
@@ -354,14 +346,6 @@ export declare class NeuroLink {
|
|
354
346
|
* @throws {Error} When conversation memory operations fail (if enabled)
|
355
347
|
*/
|
356
348
|
stream(options: StreamOptions): Promise<StreamResult>;
|
357
|
-
/**
|
358
|
-
* Log stream entry point with comprehensive analysis
|
359
|
-
*/
|
360
|
-
private logStreamEntryPoint;
|
361
|
-
/**
|
362
|
-
* Log performance baseline
|
363
|
-
*/
|
364
|
-
private logPerformanceBaseline;
|
365
349
|
/**
|
366
350
|
* Validate stream input with comprehensive error reporting
|
367
351
|
*/
|
@@ -564,13 +548,58 @@ export declare class NeuroLink {
|
|
564
548
|
* @see {@link NeuroLink.stream} for events related to streaming
|
565
549
|
* @see {@link NeuroLink.executeTool} for events related to tool execution
|
566
550
|
*/
|
567
|
-
getEventEmitter():
|
551
|
+
getEventEmitter(): TypedEventEmitter<NeuroLinkEvents>;
|
552
|
+
/**
|
553
|
+
* Emit tool start event with execution tracking
|
554
|
+
* @param toolName - Name of the tool being executed
|
555
|
+
* @param input - Input parameters for the tool
|
556
|
+
* @param startTime - Timestamp when execution started
|
557
|
+
* @returns executionId for tracking this specific execution
|
558
|
+
*/
|
559
|
+
emitToolStart(toolName: string, input: unknown, startTime?: number): string;
|
560
|
+
/**
|
561
|
+
* Emit tool end event with execution summary
|
562
|
+
* @param toolName - Name of the tool that finished
|
563
|
+
* @param result - Result from the tool execution
|
564
|
+
* @param error - Error message if execution failed
|
565
|
+
* @param startTime - When execution started
|
566
|
+
* @param endTime - When execution finished
|
567
|
+
* @param executionId - Optional execution ID for tracking
|
568
|
+
*/
|
569
|
+
emitToolEnd(toolName: string, result?: unknown, error?: string, startTime?: number, endTime?: number, executionId?: string): void;
|
570
|
+
/**
|
571
|
+
* Get current tool execution contexts for stream metadata
|
572
|
+
*/
|
573
|
+
getCurrentToolExecutions(): ToolExecutionContext[];
|
574
|
+
/**
|
575
|
+
* Get tool execution history
|
576
|
+
*/
|
577
|
+
getToolExecutionHistory(): ToolExecutionSummary[];
|
578
|
+
/**
|
579
|
+
* Clear current stream tool executions (called at stream start)
|
580
|
+
*/
|
581
|
+
clearCurrentStreamExecutions(): void;
|
568
582
|
/**
|
569
583
|
* Register a custom tool that will be available to all AI providers
|
570
584
|
* @param name - Unique name for the tool
|
571
585
|
* @param tool - Tool in MCPExecutableTool format (unified MCP protocol type)
|
572
586
|
*/
|
573
587
|
registerTool(name: string, tool: MCPExecutableTool): void;
|
588
|
+
/**
|
589
|
+
* Set the context that will be passed to tools during execution
|
590
|
+
* This context will be merged with any runtime context passed by the AI model
|
591
|
+
* @param context - Context object containing session info, tokens, shop data, etc.
|
592
|
+
*/
|
593
|
+
setToolContext(context: Record<string, unknown>): void;
|
594
|
+
/**
|
595
|
+
* Get the current tool execution context
|
596
|
+
* @returns Current context or undefined if not set
|
597
|
+
*/
|
598
|
+
getToolContext(): Record<string, unknown> | undefined;
|
599
|
+
/**
|
600
|
+
* Clear the tool execution context
|
601
|
+
*/
|
602
|
+
clearToolContext(): void;
|
574
603
|
/**
|
575
604
|
* Register multiple tools at once - Supports both object and array formats
|
576
605
|
* @param tools - Object mapping tool names to MCPExecutableTool format OR Array of tools with names
|
@@ -621,13 +650,19 @@ export declare class NeuroLink {
|
|
621
650
|
* Supports both custom tools and MCP server tools with timeout, retry, and circuit breaker patterns
|
622
651
|
* @param toolName - Name of the tool to execute
|
623
652
|
* @param params - Parameters to pass to the tool
|
624
|
-
* @param options - Execution options
|
653
|
+
* @param options - Execution options including optional authentication context
|
625
654
|
* @returns Tool execution result
|
626
655
|
*/
|
627
656
|
executeTool<T = unknown>(toolName: string, params?: unknown, options?: {
|
628
657
|
timeout?: number;
|
629
658
|
maxRetries?: number;
|
630
659
|
retryDelayMs?: number;
|
660
|
+
authContext?: {
|
661
|
+
userId?: string;
|
662
|
+
sessionId?: string;
|
663
|
+
user?: Record<string, unknown>;
|
664
|
+
[key: string]: unknown;
|
665
|
+
};
|
631
666
|
}): Promise<T>;
|
632
667
|
/**
|
633
668
|
* Internal tool execution method (extracted for better error handling)
|