@juspay/neurolink 7.12.0 → 7.14.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 +12 -0
- package/README.md +90 -25
- package/dist/config/conversationMemoryConfig.js +2 -1
- package/dist/context/ContextManager.d.ts +28 -0
- package/dist/context/ContextManager.js +113 -0
- package/dist/context/config.d.ts +5 -0
- package/dist/context/config.js +42 -0
- package/dist/context/types.d.ts +20 -0
- package/dist/context/types.js +1 -0
- package/dist/context/utils.d.ts +7 -0
- package/dist/context/utils.js +8 -0
- package/dist/core/baseProvider.d.ts +16 -1
- package/dist/core/baseProvider.js +208 -9
- package/dist/core/conversationMemoryManager.js +3 -2
- package/dist/core/factory.js +13 -2
- package/dist/factories/providerFactory.js +5 -11
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/lib/config/conversationMemoryConfig.js +2 -1
- package/dist/lib/context/ContextManager.d.ts +28 -0
- package/dist/lib/context/ContextManager.js +113 -0
- package/dist/lib/context/config.d.ts +5 -0
- package/dist/lib/context/config.js +42 -0
- package/dist/lib/context/types.d.ts +20 -0
- package/dist/lib/context/types.js +1 -0
- package/dist/lib/context/utils.d.ts +7 -0
- package/dist/lib/context/utils.js +8 -0
- package/dist/lib/core/baseProvider.d.ts +16 -1
- package/dist/lib/core/baseProvider.js +208 -9
- package/dist/lib/core/conversationMemoryManager.js +3 -2
- package/dist/lib/core/factory.js +13 -2
- package/dist/lib/factories/providerFactory.js +5 -11
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/mcp/externalServerManager.d.ts +115 -0
- package/dist/lib/mcp/externalServerManager.js +677 -0
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/lib/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/lib/mcp/mcpClientFactory.d.ts +104 -0
- package/dist/lib/mcp/mcpClientFactory.js +416 -0
- package/dist/lib/mcp/toolDiscoveryService.d.ts +192 -0
- package/dist/lib/mcp/toolDiscoveryService.js +578 -0
- package/dist/lib/neurolink.d.ts +128 -16
- package/dist/lib/neurolink.js +555 -49
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +23 -7
- package/dist/lib/types/externalMcp.d.ts +282 -0
- package/dist/lib/types/externalMcp.js +6 -0
- package/dist/lib/types/generateTypes.d.ts +0 -1
- package/dist/lib/types/index.d.ts +1 -0
- package/dist/mcp/externalServerManager.d.ts +115 -0
- package/dist/mcp/externalServerManager.js +677 -0
- package/dist/mcp/mcpCircuitBreaker.d.ts +184 -0
- package/dist/mcp/mcpCircuitBreaker.js +338 -0
- package/dist/mcp/mcpClientFactory.d.ts +104 -0
- package/dist/mcp/mcpClientFactory.js +416 -0
- package/dist/mcp/toolDiscoveryService.d.ts +192 -0
- package/dist/mcp/toolDiscoveryService.js +578 -0
- package/dist/neurolink.d.ts +128 -16
- package/dist/neurolink.js +555 -49
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/googleVertex.js +23 -7
- package/dist/types/externalMcp.d.ts +282 -0
- package/dist/types/externalMcp.js +6 -0
- package/dist/types/generateTypes.d.ts +0 -1
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/neurolink.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import type { SimpleTool } from "./sdk/toolRegistration.js";
|
|
|
12
12
|
import type { InMemoryMCPServerConfig } from "./types/mcpTypes.js";
|
|
13
13
|
import { EventEmitter } from "events";
|
|
14
14
|
import type { ConversationMemoryConfig } from "./types/conversationTypes.js";
|
|
15
|
+
import type { ExternalMCPServerConfig, ExternalMCPServerInstance, ExternalMCPOperationResult, ExternalMCPToolInfo } from "./types/externalMcp.js";
|
|
15
16
|
export interface ProviderStatus {
|
|
16
17
|
provider: string;
|
|
17
18
|
status: "working" | "failed" | "not-configured";
|
|
@@ -30,6 +31,10 @@ export interface MCPStatus {
|
|
|
30
31
|
autoDiscoveredServers: MCPServerInfo[];
|
|
31
32
|
customToolsCount: number;
|
|
32
33
|
inMemoryServersCount: number;
|
|
34
|
+
externalMCPServersCount?: number;
|
|
35
|
+
externalMCPConnectedCount?: number;
|
|
36
|
+
externalMCPFailedCount?: number;
|
|
37
|
+
externalMCPServers?: MCPServerInfo[];
|
|
33
38
|
error?: string;
|
|
34
39
|
[key: string]: unknown;
|
|
35
40
|
}
|
|
@@ -41,11 +46,14 @@ export interface MCPServerInfo {
|
|
|
41
46
|
hasServer: boolean;
|
|
42
47
|
metadata?: unknown;
|
|
43
48
|
}
|
|
49
|
+
import type { ContextManagerConfig } from "./context/types.js";
|
|
44
50
|
export declare class NeuroLink {
|
|
45
51
|
private mcpInitialized;
|
|
46
52
|
private emitter;
|
|
53
|
+
private contextManager;
|
|
47
54
|
private customTools;
|
|
48
55
|
private inMemoryServers;
|
|
56
|
+
private externalServerManager;
|
|
49
57
|
private toolCircuitBreakers;
|
|
50
58
|
private toolExecutionMetrics;
|
|
51
59
|
/**
|
|
@@ -69,6 +77,21 @@ export declare class NeuroLink {
|
|
|
69
77
|
* MAIN ENTRY POINT: Enhanced generate method with new function signature
|
|
70
78
|
* Replaces both generateText and legacy methods
|
|
71
79
|
*/
|
|
80
|
+
/**
|
|
81
|
+
* Extracts the original prompt text from the provided input.
|
|
82
|
+
* If a string is provided, it returns the string directly.
|
|
83
|
+
* If a GenerateOptions object is provided, it returns the input text from the object.
|
|
84
|
+
* @param optionsOrPrompt The prompt input, either as a string or a GenerateOptions object.
|
|
85
|
+
* @returns The original prompt text as a string.
|
|
86
|
+
*/
|
|
87
|
+
private _extractOriginalPrompt;
|
|
88
|
+
/**
|
|
89
|
+
* Enables automatic context summarization for the NeuroLink instance.
|
|
90
|
+
* Once enabled, the instance will maintain conversation history and
|
|
91
|
+
* automatically summarize it when it exceeds token limits.
|
|
92
|
+
* @param config Optional configuration to override default summarization settings.
|
|
93
|
+
*/
|
|
94
|
+
enableContextSummarization(config?: Partial<ContextManagerConfig>): void;
|
|
72
95
|
generate(optionsOrPrompt: GenerateOptions | string): Promise<GenerateResult>;
|
|
73
96
|
/**
|
|
74
97
|
* BACKWARD COMPATIBILITY: Legacy generateText method
|
|
@@ -183,22 +206,7 @@ export declare class NeuroLink {
|
|
|
183
206
|
* Get all available tools including custom and in-memory ones
|
|
184
207
|
* @returns Array of available tools with metadata
|
|
185
208
|
*/
|
|
186
|
-
getAllAvailableTools(): Promise<
|
|
187
|
-
toolName: string;
|
|
188
|
-
serverId: string | undefined;
|
|
189
|
-
name: string;
|
|
190
|
-
description?: string;
|
|
191
|
-
category?: string;
|
|
192
|
-
inputSchema?: Record<string, unknown>;
|
|
193
|
-
outputSchema?: Record<string, unknown>;
|
|
194
|
-
} | {
|
|
195
|
-
name: string;
|
|
196
|
-
toolName: string;
|
|
197
|
-
description: string;
|
|
198
|
-
serverId: string;
|
|
199
|
-
category: string;
|
|
200
|
-
inputSchema: {};
|
|
201
|
-
})[]>;
|
|
209
|
+
getAllAvailableTools(): Promise<any[]>;
|
|
202
210
|
/**
|
|
203
211
|
* Get comprehensive status of all AI providers
|
|
204
212
|
* Primary method for provider health checking and diagnostics
|
|
@@ -385,6 +393,110 @@ export declare class NeuroLink {
|
|
|
385
393
|
* Clear all conversation history (public API)
|
|
386
394
|
*/
|
|
387
395
|
clearAllConversations(): Promise<void>;
|
|
396
|
+
/**
|
|
397
|
+
* Add an external MCP server
|
|
398
|
+
* Automatically discovers and registers tools from the server
|
|
399
|
+
* @param serverId - Unique identifier for the server
|
|
400
|
+
* @param config - External MCP server configuration
|
|
401
|
+
* @returns Operation result with server instance
|
|
402
|
+
*/
|
|
403
|
+
addExternalMCPServer(serverId: string, config: ExternalMCPServerConfig): Promise<ExternalMCPOperationResult<ExternalMCPServerInstance>>;
|
|
404
|
+
/**
|
|
405
|
+
* Remove an external MCP server
|
|
406
|
+
* Stops the server and removes all its tools
|
|
407
|
+
* @param serverId - ID of the server to remove
|
|
408
|
+
* @returns Operation result
|
|
409
|
+
*/
|
|
410
|
+
removeExternalMCPServer(serverId: string): Promise<ExternalMCPOperationResult<void>>;
|
|
411
|
+
/**
|
|
412
|
+
* List all external MCP servers
|
|
413
|
+
* @returns Array of server health information
|
|
414
|
+
*/
|
|
415
|
+
listExternalMCPServers(): Array<{
|
|
416
|
+
serverId: string;
|
|
417
|
+
status: string;
|
|
418
|
+
toolCount: number;
|
|
419
|
+
uptime: number;
|
|
420
|
+
isHealthy: boolean;
|
|
421
|
+
config: ExternalMCPServerConfig;
|
|
422
|
+
}>;
|
|
423
|
+
/**
|
|
424
|
+
* Get external MCP server status
|
|
425
|
+
* @param serverId - ID of the server
|
|
426
|
+
* @returns Server instance or undefined if not found
|
|
427
|
+
*/
|
|
428
|
+
getExternalMCPServer(serverId: string): ExternalMCPServerInstance | undefined;
|
|
429
|
+
/**
|
|
430
|
+
* Execute a tool from an external MCP server
|
|
431
|
+
* @param serverId - ID of the server
|
|
432
|
+
* @param toolName - Name of the tool
|
|
433
|
+
* @param parameters - Tool parameters
|
|
434
|
+
* @param options - Execution options
|
|
435
|
+
* @returns Tool execution result
|
|
436
|
+
*/
|
|
437
|
+
executeExternalMCPTool(serverId: string, toolName: string, parameters: Record<string, any>, options?: {
|
|
438
|
+
timeout?: number;
|
|
439
|
+
}): Promise<any>;
|
|
440
|
+
/**
|
|
441
|
+
* Get all tools from external MCP servers
|
|
442
|
+
* @returns Array of external tool information
|
|
443
|
+
*/
|
|
444
|
+
getExternalMCPTools(): ExternalMCPToolInfo[];
|
|
445
|
+
/**
|
|
446
|
+
* Get tools from a specific external MCP server
|
|
447
|
+
* @param serverId - ID of the server
|
|
448
|
+
* @returns Array of tool information for the server
|
|
449
|
+
*/
|
|
450
|
+
getExternalMCPServerTools(serverId: string): ExternalMCPToolInfo[];
|
|
451
|
+
/**
|
|
452
|
+
* Test connection to an external MCP server
|
|
453
|
+
* @param config - Server configuration to test
|
|
454
|
+
* @returns Test result with connection status
|
|
455
|
+
*/
|
|
456
|
+
testExternalMCPConnection(config: ExternalMCPServerConfig): Promise<{
|
|
457
|
+
success: boolean;
|
|
458
|
+
error?: string;
|
|
459
|
+
toolCount?: number;
|
|
460
|
+
}>;
|
|
461
|
+
/**
|
|
462
|
+
* Get external MCP server manager statistics
|
|
463
|
+
* @returns Statistics about external servers and tools
|
|
464
|
+
*/
|
|
465
|
+
getExternalMCPStatistics(): {
|
|
466
|
+
totalServers: number;
|
|
467
|
+
connectedServers: number;
|
|
468
|
+
failedServers: number;
|
|
469
|
+
totalTools: number;
|
|
470
|
+
totalConnections: number;
|
|
471
|
+
totalErrors: number;
|
|
472
|
+
};
|
|
473
|
+
/**
|
|
474
|
+
* Shutdown all external MCP servers
|
|
475
|
+
* Called automatically on process exit
|
|
476
|
+
*/
|
|
477
|
+
shutdownExternalMCPServers(): Promise<void>;
|
|
478
|
+
/**
|
|
479
|
+
* Convert external MCP tools to Vercel AI SDK tool format
|
|
480
|
+
* This allows AI providers to use external tools directly
|
|
481
|
+
*/
|
|
482
|
+
private convertExternalMCPToolsToAISDKFormat;
|
|
483
|
+
/**
|
|
484
|
+
* Convert JSON Schema to AI SDK compatible format
|
|
485
|
+
* For now, we'll skip schema validation and let the AI SDK handle parameters dynamically
|
|
486
|
+
*/
|
|
487
|
+
private convertJSONSchemaToAISDKFormat;
|
|
488
|
+
/**
|
|
489
|
+
* Unregister external MCP tools from a specific server
|
|
490
|
+
*/
|
|
491
|
+
private unregisterExternalMCPToolsFromRegistry;
|
|
492
|
+
/**
|
|
493
|
+
* Unregister a specific external MCP tool from the main registry
|
|
494
|
+
*/
|
|
495
|
+
private unregisterExternalMCPToolFromRegistry;
|
|
496
|
+
/**
|
|
497
|
+
* Unregister all external MCP tools from the main registry
|
|
498
|
+
*/
|
|
499
|
+
private unregisterAllExternalMCPToolsFromRegistry;
|
|
388
500
|
}
|
|
389
501
|
export declare const neurolink: NeuroLink;
|
|
390
502
|
export default neurolink;
|