@juspay/neurolink 7.6.1 → 7.7.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 +15 -4
- package/README.md +78 -3
- package/dist/cli/commands/config.d.ts +275 -3
- package/dist/cli/commands/config.js +121 -0
- package/dist/cli/commands/mcp.js +77 -28
- package/dist/cli/factories/commandFactory.js +359 -6
- package/dist/core/analytics.js +7 -27
- package/dist/core/baseProvider.js +43 -4
- package/dist/core/constants.d.ts +46 -0
- package/dist/core/constants.js +47 -0
- package/dist/core/dynamicModels.d.ts +16 -4
- package/dist/core/dynamicModels.js +130 -26
- package/dist/core/evaluation.js +5 -1
- package/dist/core/evaluationProviders.d.ts +6 -2
- package/dist/core/evaluationProviders.js +41 -125
- package/dist/core/factory.d.ts +5 -0
- package/dist/core/factory.js +62 -50
- package/dist/core/modelConfiguration.d.ts +246 -0
- package/dist/core/modelConfiguration.js +775 -0
- package/dist/core/types.d.ts +22 -3
- package/dist/core/types.js +5 -1
- package/dist/factories/providerRegistry.js +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/core/analytics.js +7 -27
- package/dist/lib/core/baseProvider.js +43 -4
- package/dist/lib/core/constants.d.ts +46 -0
- package/dist/lib/core/constants.js +47 -0
- package/dist/lib/core/dynamicModels.d.ts +16 -4
- package/dist/lib/core/dynamicModels.js +130 -26
- package/dist/lib/core/evaluation.js +5 -1
- package/dist/lib/core/evaluationProviders.d.ts +6 -2
- package/dist/lib/core/evaluationProviders.js +41 -125
- package/dist/lib/core/factory.d.ts +5 -0
- package/dist/lib/core/factory.js +63 -50
- package/dist/lib/core/modelConfiguration.d.ts +246 -0
- package/dist/lib/core/modelConfiguration.js +775 -0
- package/dist/lib/core/types.d.ts +22 -3
- package/dist/lib/core/types.js +5 -1
- package/dist/lib/factories/providerRegistry.js +3 -3
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/mcp/factory.d.ts +5 -5
- package/dist/lib/mcp/factory.js +2 -2
- package/dist/lib/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/lib/mcp/toolRegistry.js +2 -2
- package/dist/lib/neurolink.d.ts +168 -12
- package/dist/lib/neurolink.js +685 -123
- package/dist/lib/providers/anthropic.js +52 -2
- package/dist/lib/providers/googleAiStudio.js +4 -0
- package/dist/lib/providers/googleVertex.d.ts +75 -9
- package/dist/lib/providers/googleVertex.js +365 -46
- package/dist/lib/providers/huggingFace.d.ts +52 -11
- package/dist/lib/providers/huggingFace.js +180 -42
- package/dist/lib/providers/litellm.d.ts +9 -9
- package/dist/lib/providers/litellm.js +103 -16
- package/dist/lib/providers/ollama.d.ts +52 -17
- package/dist/lib/providers/ollama.js +276 -68
- package/dist/lib/sdk/toolRegistration.d.ts +42 -0
- package/dist/lib/sdk/toolRegistration.js +269 -27
- package/dist/lib/telemetry/telemetryService.d.ts +6 -0
- package/dist/lib/telemetry/telemetryService.js +38 -3
- package/dist/lib/types/contextTypes.d.ts +75 -11
- package/dist/lib/types/contextTypes.js +227 -1
- package/dist/lib/types/domainTypes.d.ts +62 -0
- package/dist/lib/types/domainTypes.js +5 -0
- package/dist/lib/types/generateTypes.d.ts +52 -0
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/lib/types/mcpTypes.d.ts +1 -1
- package/dist/lib/types/mcpTypes.js +1 -1
- package/dist/lib/types/streamTypes.d.ts +14 -0
- package/dist/lib/types/universalProviderOptions.d.ts +1 -1
- package/dist/lib/utils/errorHandling.d.ts +142 -0
- package/dist/lib/utils/errorHandling.js +316 -0
- package/dist/lib/utils/factoryProcessing.d.ts +74 -0
- package/dist/lib/utils/factoryProcessing.js +588 -0
- package/dist/lib/utils/optionsConversion.d.ts +54 -0
- package/dist/lib/utils/optionsConversion.js +126 -0
- package/dist/lib/utils/optionsUtils.d.ts +246 -0
- package/dist/lib/utils/optionsUtils.js +960 -0
- package/dist/lib/utils/providerConfig.js +6 -2
- package/dist/lib/utils/providerHealth.d.ts +107 -0
- package/dist/lib/utils/providerHealth.js +543 -0
- package/dist/lib/utils/providerUtils.d.ts +17 -0
- package/dist/lib/utils/providerUtils.js +271 -16
- package/dist/lib/utils/timeout.js +1 -1
- package/dist/lib/utils/tokenLimits.d.ts +33 -0
- package/dist/lib/utils/tokenLimits.js +118 -0
- package/dist/mcp/factory.d.ts +5 -5
- package/dist/mcp/factory.js +2 -2
- package/dist/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/mcp/servers/utilities/utilityServer.js +1 -1
- package/dist/mcp/toolRegistry.js +2 -2
- package/dist/neurolink.d.ts +168 -12
- package/dist/neurolink.js +685 -123
- package/dist/providers/anthropic.js +52 -2
- package/dist/providers/googleAiStudio.js +4 -0
- package/dist/providers/googleVertex.d.ts +75 -9
- package/dist/providers/googleVertex.js +365 -46
- package/dist/providers/huggingFace.d.ts +52 -11
- package/dist/providers/huggingFace.js +181 -43
- package/dist/providers/litellm.d.ts +9 -9
- package/dist/providers/litellm.js +103 -16
- package/dist/providers/ollama.d.ts +52 -17
- package/dist/providers/ollama.js +276 -68
- package/dist/sdk/toolRegistration.d.ts +42 -0
- package/dist/sdk/toolRegistration.js +269 -27
- package/dist/telemetry/telemetryService.d.ts +6 -0
- package/dist/telemetry/telemetryService.js +38 -3
- package/dist/types/contextTypes.d.ts +75 -11
- package/dist/types/contextTypes.js +227 -2
- package/dist/types/domainTypes.d.ts +62 -0
- package/dist/types/domainTypes.js +5 -0
- package/dist/types/generateTypes.d.ts +52 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/mcpTypes.d.ts +1 -1
- package/dist/types/mcpTypes.js +1 -1
- package/dist/types/streamTypes.d.ts +14 -0
- package/dist/types/universalProviderOptions.d.ts +1 -1
- package/dist/types/universalProviderOptions.js +0 -1
- package/dist/utils/errorHandling.d.ts +142 -0
- package/dist/utils/errorHandling.js +316 -0
- package/dist/utils/factoryProcessing.d.ts +74 -0
- package/dist/utils/factoryProcessing.js +588 -0
- package/dist/utils/optionsConversion.d.ts +54 -0
- package/dist/utils/optionsConversion.js +126 -0
- package/dist/utils/optionsUtils.d.ts +246 -0
- package/dist/utils/optionsUtils.js +960 -0
- package/dist/utils/providerConfig.js +6 -2
- package/dist/utils/providerHealth.d.ts +107 -0
- package/dist/utils/providerHealth.js +543 -0
- package/dist/utils/providerUtils.d.ts +17 -0
- package/dist/utils/providerUtils.js +271 -16
- package/dist/utils/timeout.js +1 -1
- package/dist/utils/tokenLimits.d.ts +33 -0
- package/dist/utils/tokenLimits.js +118 -0
- package/package.json +2 -2
package/dist/neurolink.d.ts
CHANGED
|
@@ -43,6 +43,8 @@ export declare class NeuroLink {
|
|
|
43
43
|
private mcpInitialized;
|
|
44
44
|
private customTools;
|
|
45
45
|
private inMemoryServers;
|
|
46
|
+
private toolCircuitBreakers;
|
|
47
|
+
private toolExecutionMetrics;
|
|
46
48
|
constructor();
|
|
47
49
|
/**
|
|
48
50
|
* Initialize MCP registry with enhanced error handling and resource cleanup
|
|
@@ -80,6 +82,15 @@ export declare class NeuroLink {
|
|
|
80
82
|
* Create tool-aware system prompt that informs AI about available tools
|
|
81
83
|
*/
|
|
82
84
|
private createToolAwareSystemPrompt;
|
|
85
|
+
/**
|
|
86
|
+
* Execute tools if available through centralized registry
|
|
87
|
+
* Simplified approach without domain detection - relies on tool registry
|
|
88
|
+
*/
|
|
89
|
+
private detectAndExecuteTools;
|
|
90
|
+
/**
|
|
91
|
+
* Enhance prompt with tool results (domain-agnostic)
|
|
92
|
+
*/
|
|
93
|
+
private enhancePromptWithToolResults;
|
|
83
94
|
/**
|
|
84
95
|
* BACKWARD COMPATIBILITY: Legacy streamText method
|
|
85
96
|
* Internally calls stream() and converts result format
|
|
@@ -97,10 +108,16 @@ export declare class NeuroLink {
|
|
|
97
108
|
*/
|
|
98
109
|
registerTool(name: string, tool: SimpleTool): void;
|
|
99
110
|
/**
|
|
100
|
-
* Register multiple tools at once
|
|
101
|
-
* @param tools - Object mapping tool names to configurations
|
|
111
|
+
* Register multiple tools at once - Supports both object and array formats
|
|
112
|
+
* @param tools - Object mapping tool names to configurations OR Array of tools with names
|
|
113
|
+
*
|
|
114
|
+
* Object format (existing): { toolName: SimpleTool, ... }
|
|
115
|
+
* Array format (Lighthouse compatible): [{ name: string, tool: SimpleTool }, ...]
|
|
102
116
|
*/
|
|
103
|
-
registerTools(tools: Record<string, SimpleTool>
|
|
117
|
+
registerTools(tools: Record<string, SimpleTool> | Array<{
|
|
118
|
+
name: string;
|
|
119
|
+
tool: SimpleTool;
|
|
120
|
+
}>): void;
|
|
104
121
|
/**
|
|
105
122
|
* Unregister a custom tool
|
|
106
123
|
* @param name - Name of the tool to remove
|
|
@@ -125,8 +142,8 @@ export declare class NeuroLink {
|
|
|
125
142
|
*/
|
|
126
143
|
getInMemoryServers(): Map<string, InMemoryMCPServerConfig>;
|
|
127
144
|
/**
|
|
128
|
-
* Execute a specific tool by name
|
|
129
|
-
* Supports both custom tools and MCP server tools
|
|
145
|
+
* Execute a specific tool by name with robust error handling
|
|
146
|
+
* Supports both custom tools and MCP server tools with timeout, retry, and circuit breaker patterns
|
|
130
147
|
* @param toolName - Name of the tool to execute
|
|
131
148
|
* @param params - Parameters to pass to the tool
|
|
132
149
|
* @param options - Execution options
|
|
@@ -134,12 +151,33 @@ export declare class NeuroLink {
|
|
|
134
151
|
*/
|
|
135
152
|
executeTool<T = unknown>(toolName: string, params?: unknown, options?: {
|
|
136
153
|
timeout?: number;
|
|
154
|
+
maxRetries?: number;
|
|
155
|
+
retryDelayMs?: number;
|
|
137
156
|
}): Promise<T>;
|
|
157
|
+
/**
|
|
158
|
+
* Internal tool execution method (extracted for better error handling)
|
|
159
|
+
*/
|
|
160
|
+
private executeToolInternal;
|
|
138
161
|
/**
|
|
139
162
|
* Get all available tools including custom and in-memory ones
|
|
140
163
|
* @returns Array of available tools with metadata
|
|
141
164
|
*/
|
|
142
|
-
getAllAvailableTools(): Promise<
|
|
165
|
+
getAllAvailableTools(): Promise<({
|
|
166
|
+
toolName: string;
|
|
167
|
+
serverId: string | undefined;
|
|
168
|
+
name: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
category?: string;
|
|
171
|
+
inputSchema?: Record<string, unknown>;
|
|
172
|
+
outputSchema?: Record<string, unknown>;
|
|
173
|
+
} | {
|
|
174
|
+
name: string;
|
|
175
|
+
toolName: string;
|
|
176
|
+
description: string;
|
|
177
|
+
serverId: string;
|
|
178
|
+
category: string;
|
|
179
|
+
inputSchema: {};
|
|
180
|
+
})[]>;
|
|
143
181
|
/**
|
|
144
182
|
* Get comprehensive status of all AI providers
|
|
145
183
|
* Primary method for provider health checking and diagnostics
|
|
@@ -157,12 +195,6 @@ export declare class NeuroLink {
|
|
|
157
195
|
* Internal method to test provider connection with minimal generation call
|
|
158
196
|
*/
|
|
159
197
|
private testProviderConnection;
|
|
160
|
-
/**
|
|
161
|
-
* Check if a provider has required environment variables configured
|
|
162
|
-
* @param providerName - Name of the provider to check
|
|
163
|
-
* @returns True if provider has required environment variables
|
|
164
|
-
*/
|
|
165
|
-
hasProviderEnvVars(providerName: string): Promise<boolean>;
|
|
166
198
|
/**
|
|
167
199
|
* Get the best available AI provider based on configuration and availability
|
|
168
200
|
* @param requestedProvider - Optional preferred provider name
|
|
@@ -196,6 +228,130 @@ export declare class NeuroLink {
|
|
|
196
228
|
* @returns Promise resolving to true if server is reachable
|
|
197
229
|
*/
|
|
198
230
|
testMCPServer(serverId: string): Promise<boolean>;
|
|
231
|
+
/**
|
|
232
|
+
* Check if a provider has the required environment variables configured
|
|
233
|
+
* @param providerName - Name of the provider to check
|
|
234
|
+
* @returns Promise resolving to true if provider has required env vars
|
|
235
|
+
*/
|
|
236
|
+
hasProviderEnvVars(providerName: string): Promise<boolean>;
|
|
237
|
+
/**
|
|
238
|
+
* Perform comprehensive health check on a specific provider
|
|
239
|
+
* @param providerName - Name of the provider to check
|
|
240
|
+
* @param options - Health check options
|
|
241
|
+
* @returns Promise resolving to detailed health status
|
|
242
|
+
*/
|
|
243
|
+
checkProviderHealth(providerName: string, options?: {
|
|
244
|
+
timeout?: number;
|
|
245
|
+
includeConnectivityTest?: boolean;
|
|
246
|
+
includeModelValidation?: boolean;
|
|
247
|
+
cacheResults?: boolean;
|
|
248
|
+
}): Promise<{
|
|
249
|
+
provider: string;
|
|
250
|
+
isHealthy: boolean;
|
|
251
|
+
isConfigured: boolean;
|
|
252
|
+
hasApiKey: boolean;
|
|
253
|
+
lastChecked: Date;
|
|
254
|
+
error?: string;
|
|
255
|
+
warning?: string;
|
|
256
|
+
responseTime?: number;
|
|
257
|
+
configurationIssues: string[];
|
|
258
|
+
recommendations: string[];
|
|
259
|
+
}>;
|
|
260
|
+
/**
|
|
261
|
+
* Check health of all supported providers
|
|
262
|
+
* @param options - Health check options
|
|
263
|
+
* @returns Promise resolving to array of health statuses for all providers
|
|
264
|
+
*/
|
|
265
|
+
checkAllProvidersHealth(options?: {
|
|
266
|
+
timeout?: number;
|
|
267
|
+
includeConnectivityTest?: boolean;
|
|
268
|
+
includeModelValidation?: boolean;
|
|
269
|
+
cacheResults?: boolean;
|
|
270
|
+
}): Promise<Array<{
|
|
271
|
+
provider: string;
|
|
272
|
+
isHealthy: boolean;
|
|
273
|
+
isConfigured: boolean;
|
|
274
|
+
hasApiKey: boolean;
|
|
275
|
+
lastChecked: Date;
|
|
276
|
+
error?: string;
|
|
277
|
+
warning?: string;
|
|
278
|
+
responseTime?: number;
|
|
279
|
+
configurationIssues: string[];
|
|
280
|
+
recommendations: string[];
|
|
281
|
+
}>>;
|
|
282
|
+
/**
|
|
283
|
+
* Get a summary of provider health across all supported providers
|
|
284
|
+
* @returns Promise resolving to health summary statistics
|
|
285
|
+
*/
|
|
286
|
+
getProviderHealthSummary(): Promise<{
|
|
287
|
+
total: number;
|
|
288
|
+
healthy: number;
|
|
289
|
+
configured: number;
|
|
290
|
+
hasIssues: number;
|
|
291
|
+
healthyProviders: string[];
|
|
292
|
+
unhealthyProviders: string[];
|
|
293
|
+
recommendations: string[];
|
|
294
|
+
}>;
|
|
295
|
+
/**
|
|
296
|
+
* Clear provider health cache (useful for re-testing after configuration changes)
|
|
297
|
+
* @param providerName - Optional specific provider to clear cache for
|
|
298
|
+
*/
|
|
299
|
+
clearProviderHealthCache(providerName?: string): Promise<void>;
|
|
300
|
+
/**
|
|
301
|
+
* Get execution metrics for all tools
|
|
302
|
+
* @returns Object with execution metrics for each tool
|
|
303
|
+
*/
|
|
304
|
+
getToolExecutionMetrics(): Record<string, {
|
|
305
|
+
totalExecutions: number;
|
|
306
|
+
successfulExecutions: number;
|
|
307
|
+
failedExecutions: number;
|
|
308
|
+
successRate: number;
|
|
309
|
+
averageExecutionTime: number;
|
|
310
|
+
lastExecutionTime: number;
|
|
311
|
+
}>;
|
|
312
|
+
/**
|
|
313
|
+
* Get circuit breaker status for all tools
|
|
314
|
+
* @returns Object with circuit breaker status for each tool
|
|
315
|
+
*/
|
|
316
|
+
getToolCircuitBreakerStatus(): Record<string, {
|
|
317
|
+
state: "closed" | "open" | "half-open";
|
|
318
|
+
failureCount: number;
|
|
319
|
+
isHealthy: boolean;
|
|
320
|
+
}>;
|
|
321
|
+
/**
|
|
322
|
+
* Reset circuit breaker for a specific tool
|
|
323
|
+
* @param toolName - Name of the tool to reset circuit breaker for
|
|
324
|
+
*/
|
|
325
|
+
resetToolCircuitBreaker(toolName: string): void;
|
|
326
|
+
/**
|
|
327
|
+
* Clear all tool execution metrics
|
|
328
|
+
*/
|
|
329
|
+
clearToolExecutionMetrics(): void;
|
|
330
|
+
/**
|
|
331
|
+
* Get comprehensive tool health report
|
|
332
|
+
* @returns Detailed health report for all tools
|
|
333
|
+
*/
|
|
334
|
+
getToolHealthReport(): {
|
|
335
|
+
totalTools: number;
|
|
336
|
+
healthyTools: number;
|
|
337
|
+
unhealthyTools: number;
|
|
338
|
+
tools: Record<string, {
|
|
339
|
+
name: string;
|
|
340
|
+
isHealthy: boolean;
|
|
341
|
+
metrics: {
|
|
342
|
+
totalExecutions: number;
|
|
343
|
+
successRate: number;
|
|
344
|
+
averageExecutionTime: number;
|
|
345
|
+
lastExecutionTime: number;
|
|
346
|
+
};
|
|
347
|
+
circuitBreaker: {
|
|
348
|
+
state: "closed" | "open" | "half-open";
|
|
349
|
+
failureCount: number;
|
|
350
|
+
};
|
|
351
|
+
issues: string[];
|
|
352
|
+
recommendations: string[];
|
|
353
|
+
}>;
|
|
354
|
+
};
|
|
199
355
|
}
|
|
200
356
|
export declare const neurolink: NeuroLink;
|
|
201
357
|
export default neurolink;
|