@juspay/neurolink 7.14.0 → 7.14.2
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/agent/directTools.d.ts +3 -3
- package/dist/agent/directTools.js +1 -1
- package/dist/cli/commands/mcp.js +67 -207
- package/dist/cli/factories/commandFactory.js +7 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/core/baseProvider.d.ts +6 -40
- package/dist/core/baseProvider.js +102 -75
- package/dist/core/dynamicModels.d.ts +14 -14
- package/dist/core/dynamicModels.js +1 -1
- package/dist/core/evaluation.js +1 -1
- package/dist/core/factory.js +1 -12
- package/dist/index.d.ts +23 -4
- package/dist/index.js +22 -1
- package/dist/lib/agent/directTools.js +1 -1
- package/dist/lib/core/baseProvider.d.ts +6 -40
- package/dist/lib/core/baseProvider.js +102 -75
- package/dist/lib/core/dynamicModels.js +1 -1
- package/dist/lib/core/evaluation.js +1 -1
- package/dist/lib/core/factory.js +1 -12
- package/dist/lib/index.d.ts +23 -4
- package/dist/lib/index.js +22 -1
- package/dist/lib/mcp/externalServerManager.d.ts +46 -13
- package/dist/lib/mcp/externalServerManager.js +393 -32
- package/dist/lib/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/lib/mcp/mcpClientFactory.js +8 -3
- package/dist/lib/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/lib/mcp/toolDiscoveryService.js +76 -8
- package/dist/lib/mcp/toolRegistry.d.ts +15 -11
- package/dist/lib/mcp/toolRegistry.js +118 -55
- package/dist/lib/models/modelResolver.js +1 -1
- package/dist/lib/neurolink.d.ts +32 -31
- package/dist/lib/neurolink.js +173 -210
- package/dist/lib/providers/googleVertex.d.ts +6 -0
- package/dist/lib/providers/googleVertex.js +11 -0
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/mistral.js +3 -3
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +3 -2
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/openaiCompatible.js +2 -2
- package/dist/lib/providers/sagemaker/config.js +1 -1
- package/dist/lib/sdk/toolRegistration.d.ts +4 -13
- package/dist/lib/sdk/toolRegistration.js +19 -66
- package/dist/lib/types/cli.d.ts +0 -1
- package/dist/lib/types/cli.js +0 -1
- package/dist/lib/types/common.d.ts +1 -2
- package/dist/lib/types/common.js +0 -1
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/contextTypes.js +3 -3
- package/dist/lib/types/externalMcp.d.ts +6 -0
- package/dist/lib/types/externalMcp.js +1 -0
- package/dist/lib/types/index.d.ts +2 -3
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/mcpTypes.d.ts +53 -99
- package/dist/lib/types/providers.d.ts +0 -1
- package/dist/lib/types/providers.js +0 -1
- package/dist/lib/types/tools.d.ts +2 -2
- package/dist/lib/types/tools.js +2 -2
- package/dist/lib/utils/factoryProcessing.js +1 -1
- package/dist/lib/utils/mcpDefaults.d.ts +54 -0
- package/dist/lib/utils/mcpDefaults.js +125 -0
- package/dist/lib/utils/providerConfig.d.ts +1 -1
- package/dist/lib/utils/providerConfig.js +2 -2
- package/dist/lib/utils/providerHealth.js +6 -6
- package/dist/mcp/externalServerManager.d.ts +46 -13
- package/dist/mcp/externalServerManager.js +393 -32
- package/dist/mcp/mcpClientFactory.d.ts +5 -4
- package/dist/mcp/mcpClientFactory.js +8 -3
- package/dist/mcp/toolDiscoveryService.d.ts +1 -0
- package/dist/mcp/toolDiscoveryService.js +76 -8
- package/dist/mcp/toolRegistry.d.ts +15 -11
- package/dist/mcp/toolRegistry.js +118 -55
- package/dist/models/modelResolver.js +1 -1
- package/dist/neurolink.d.ts +32 -31
- package/dist/neurolink.js +173 -210
- package/dist/providers/googleVertex.d.ts +6 -0
- package/dist/providers/googleVertex.js +11 -0
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/mistral.js +3 -3
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +3 -2
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/providers/openaiCompatible.js +2 -2
- package/dist/providers/sagemaker/config.js +1 -1
- package/dist/sdk/toolRegistration.d.ts +4 -13
- package/dist/sdk/toolRegistration.js +19 -66
- package/dist/types/cli.d.ts +0 -1
- package/dist/types/cli.js +0 -1
- package/dist/types/common.d.ts +1 -2
- package/dist/types/common.js +0 -1
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/contextTypes.js +3 -3
- package/dist/types/externalMcp.d.ts +6 -0
- package/dist/types/externalMcp.js +1 -0
- package/dist/types/index.d.ts +2 -3
- package/dist/types/index.js +0 -1
- package/dist/types/mcpTypes.d.ts +53 -99
- package/dist/types/providers.d.ts +0 -1
- package/dist/types/providers.js +0 -1
- package/dist/types/tools.d.ts +2 -2
- package/dist/types/tools.js +2 -2
- package/dist/utils/factoryProcessing.js +1 -1
- package/dist/utils/mcpDefaults.d.ts +54 -0
- package/dist/utils/mcpDefaults.js +125 -0
- package/dist/utils/providerConfig.d.ts +1 -1
- package/dist/utils/providerConfig.js +2 -2
- package/dist/utils/providerHealth.js +6 -6
- package/package.json +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
1
2
|
import { logger } from "../utils/logger.js";
|
|
2
3
|
import { SYSTEM_LIMITS, DEFAULT_MAX_STEPS } from "../core/constants.js";
|
|
3
4
|
import { directAgentTools } from "../agent/directTools.js";
|
|
@@ -5,19 +6,6 @@ import { getSafeMaxTokens } from "../utils/tokenLimits.js";
|
|
|
5
6
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|
|
6
7
|
import { shouldDisableBuiltinTools } from "../utils/toolUtils.js";
|
|
7
8
|
import { buildMessagesArray } from "../utils/messageBuilder.js";
|
|
8
|
-
/**
|
|
9
|
-
* Validates if a result contains a valid toolsObject structure
|
|
10
|
-
* @param result - The result object to validate
|
|
11
|
-
* @returns true if the result contains a valid toolsObject, false otherwise
|
|
12
|
-
*/
|
|
13
|
-
function isValidToolsObject(result) {
|
|
14
|
-
return (result !== null &&
|
|
15
|
-
typeof result === "object" &&
|
|
16
|
-
"toolsObject" in result &&
|
|
17
|
-
result.toolsObject !== null &&
|
|
18
|
-
typeof result.toolsObject === "object" &&
|
|
19
|
-
Object.keys(result.toolsObject).length > 0);
|
|
20
|
-
}
|
|
21
9
|
/**
|
|
22
10
|
* Abstract base class for all AI providers
|
|
23
11
|
* Tools are integrated as first-class citizens - always available by default
|
|
@@ -31,13 +19,15 @@ export class BaseProvider {
|
|
|
31
19
|
? {}
|
|
32
20
|
: directAgentTools;
|
|
33
21
|
mcpTools; // MCP tools loaded dynamically when available
|
|
22
|
+
customTools; // Custom tools from registerTool()
|
|
23
|
+
toolExecutor; // Tool executor from setupToolExecutor
|
|
34
24
|
sessionId;
|
|
35
25
|
userId;
|
|
36
|
-
|
|
37
|
-
constructor(modelName, providerName,
|
|
26
|
+
neurolink; // Reference to actual NeuroLink instance for MCP tools
|
|
27
|
+
constructor(modelName, providerName, neurolink) {
|
|
38
28
|
this.modelName = modelName || this.getDefaultModel();
|
|
39
29
|
this.providerName = providerName || this.getProviderName();
|
|
40
|
-
this.
|
|
30
|
+
this.neurolink = neurolink;
|
|
41
31
|
}
|
|
42
32
|
/**
|
|
43
33
|
* Check if this provider supports tool/function calling
|
|
@@ -106,7 +96,7 @@ export class BaseProvider {
|
|
|
106
96
|
await new Promise((resolve) => setTimeout(resolve, Math.random() * 9 + 1));
|
|
107
97
|
}
|
|
108
98
|
}
|
|
109
|
-
// Yield
|
|
99
|
+
// Yield all remaining content
|
|
110
100
|
if (buffer.trim()) {
|
|
111
101
|
yield { content: buffer };
|
|
112
102
|
}
|
|
@@ -334,37 +324,88 @@ export class BaseProvider {
|
|
|
334
324
|
const tools = {
|
|
335
325
|
...this.directTools, // Always include direct tools
|
|
336
326
|
};
|
|
337
|
-
logger.debug(`[BaseProvider] getAllTools called
|
|
327
|
+
logger.debug(`[BaseProvider] getAllTools called for ${this.providerName}`, {
|
|
328
|
+
neurolinkAvailable: !!this.neurolink,
|
|
329
|
+
neurolinkType: typeof this.neurolink,
|
|
330
|
+
directToolsCount: Object.keys(this.directTools).length,
|
|
331
|
+
});
|
|
338
332
|
logger.debug(`[BaseProvider] Direct tools: ${Object.keys(this.directTools).join(", ")}`);
|
|
339
|
-
// Add custom tools from
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
333
|
+
// Add custom tools from setupToolExecutor if available
|
|
334
|
+
if (this.customTools && this.customTools.size > 0) {
|
|
335
|
+
logger.debug(`[BaseProvider] Loading ${this.customTools.size} custom tools from setupToolExecutor`);
|
|
336
|
+
for (const [toolName, toolDef] of this.customTools.entries()) {
|
|
337
|
+
logger.debug(`[BaseProvider] Processing custom tool: ${toolName}`, {
|
|
338
|
+
toolDef: typeof toolDef,
|
|
339
|
+
hasExecute: toolDef && typeof toolDef === "object" && "execute" in toolDef,
|
|
340
|
+
hasName: toolDef && typeof toolDef === "object" && "name" in toolDef,
|
|
341
|
+
});
|
|
342
|
+
if (toolDef &&
|
|
343
|
+
typeof toolDef === "object" &&
|
|
344
|
+
"execute" in toolDef &&
|
|
345
|
+
typeof toolDef.execute === "function") {
|
|
346
|
+
try {
|
|
347
|
+
const { tool: createAISDKTool } = await import("ai");
|
|
348
|
+
const typedToolDef = toolDef;
|
|
349
|
+
tools[toolName] = createAISDKTool({
|
|
350
|
+
description: typedToolDef.description || `Custom tool ${toolName}`,
|
|
351
|
+
parameters: z.object({}), // Use empty schema for custom tools
|
|
352
|
+
execute: async (args) => {
|
|
353
|
+
logger.debug(`[BaseProvider] Executing custom tool: ${toolName}`, { args });
|
|
354
|
+
// Use the tool executor if available (from setupToolExecutor)
|
|
355
|
+
if (this.toolExecutor) {
|
|
356
|
+
return await this.toolExecutor(toolName, args);
|
|
357
|
+
}
|
|
358
|
+
else {
|
|
359
|
+
return await typedToolDef.execute(args);
|
|
360
|
+
}
|
|
361
|
+
},
|
|
362
|
+
});
|
|
363
|
+
logger.debug(`[BaseProvider] Successfully added custom tool: ${toolName}`);
|
|
364
|
+
}
|
|
365
|
+
catch (error) {
|
|
366
|
+
logger.error(`[BaseProvider] Failed to add custom tool: ${toolName}`, error);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
else {
|
|
370
|
+
logger.warn(`[BaseProvider] Invalid custom tool format: ${toolName}`, {
|
|
371
|
+
toolDef: typeof toolDef,
|
|
372
|
+
hasExecute: toolDef && typeof toolDef === "object" && "execute" in toolDef,
|
|
373
|
+
executeType: toolDef && typeof toolDef === "object" && "execute" in toolDef
|
|
374
|
+
? typeof toolDef.execute
|
|
375
|
+
: "N/A",
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
// Add custom tools from NeuroLink if available
|
|
381
|
+
logger.debug(`[BaseProvider] Checking NeuroLink: ${!!this.neurolink}, has getInMemoryServers: ${this.neurolink && typeof this.neurolink.getInMemoryServers}`);
|
|
382
|
+
if (this.neurolink &&
|
|
383
|
+
typeof this.neurolink.getInMemoryServers === "function") {
|
|
384
|
+
logger.debug(`[BaseProvider] NeuroLink check passed, loading custom tools`);
|
|
343
385
|
try {
|
|
344
|
-
const inMemoryServers = this.
|
|
386
|
+
const inMemoryServers = this.neurolink.getInMemoryServers();
|
|
345
387
|
logger.debug(`[BaseProvider] Got servers:`, inMemoryServers.size);
|
|
346
388
|
logger.debug(`[BaseProvider] Loading custom tools from SDK, found ${inMemoryServers.size} servers`);
|
|
347
389
|
if (inMemoryServers && inMemoryServers.size > 0) {
|
|
348
390
|
// Convert in-memory server tools to AI SDK format
|
|
349
391
|
for (const [serverId, serverConfig] of inMemoryServers) {
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
392
|
+
if (serverConfig && serverConfig.tools) {
|
|
393
|
+
// Handle tools array from MCPServerInfo
|
|
394
|
+
const toolEntries = serverConfig.tools.map((tool) => [
|
|
395
|
+
tool.name,
|
|
396
|
+
tool,
|
|
397
|
+
]);
|
|
356
398
|
for (const [toolName, toolInfo] of toolEntries) {
|
|
357
399
|
if (toolInfo && typeof toolInfo.execute === "function") {
|
|
358
400
|
logger.debug(`[BaseProvider] Converting custom tool: ${toolName}`);
|
|
359
401
|
try {
|
|
360
402
|
// Convert to AI SDK tool format
|
|
361
403
|
const { tool: createAISDKTool } = await import("ai");
|
|
362
|
-
const { z } = await import("zod");
|
|
363
404
|
tools[toolName] = createAISDKTool({
|
|
364
405
|
description: toolInfo.description || `Tool ${toolName}`,
|
|
365
|
-
parameters: toolInfo.
|
|
366
|
-
toolInfo.parameters
|
|
367
|
-
z.object({}),
|
|
406
|
+
parameters: toolInfo.parameters instanceof z.ZodType
|
|
407
|
+
? toolInfo.parameters
|
|
408
|
+
: z.object({}),
|
|
368
409
|
execute: async (args) => {
|
|
369
410
|
const result = await toolInfo.execute(args);
|
|
370
411
|
// Handle MCP-style results
|
|
@@ -399,55 +440,40 @@ export class BaseProvider {
|
|
|
399
440
|
// Not an error - custom tools are optional
|
|
400
441
|
}
|
|
401
442
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
this.sdk.externalServerManager &&
|
|
405
|
-
typeof this.sdk.externalServerManager.getAllTools === "function") {
|
|
443
|
+
if (this.neurolink &&
|
|
444
|
+
typeof this.neurolink.getExternalMCPTools === "function") {
|
|
406
445
|
try {
|
|
407
|
-
logger.debug(`[BaseProvider] Loading external MCP tools from
|
|
408
|
-
const externalTools = this.
|
|
409
|
-
logger.debug(`[BaseProvider] Found ${externalTools.length} external MCP tools
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
server: t.serverId,
|
|
414
|
-
})),
|
|
415
|
-
});
|
|
416
|
-
for (const externalTool of externalTools) {
|
|
417
|
-
if (externalTool.isAvailable) {
|
|
418
|
-
logger.debug(`[BaseProvider] Converting external MCP tool: ${externalTool.name} from ${externalTool.serverId}`);
|
|
446
|
+
logger.debug(`[BaseProvider] Loading external MCP tools from NeuroLink via direct tool access`);
|
|
447
|
+
const externalTools = this.neurolink.getExternalMCPTools() || [];
|
|
448
|
+
logger.debug(`[BaseProvider] Found ${externalTools.length} external MCP tools`);
|
|
449
|
+
for (const tool of externalTools) {
|
|
450
|
+
logger.debug(`[BaseProvider] Converting external MCP tool: ${tool.name}`);
|
|
451
|
+
try {
|
|
419
452
|
// Convert to AI SDK tool format
|
|
420
453
|
const { tool: createAISDKTool } = await import("ai");
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
`External MCP tool ${externalTool.name}`,
|
|
425
|
-
parameters: await this.convertMCPSchemaToZod(externalTool.inputSchema),
|
|
454
|
+
tools[tool.name] = createAISDKTool({
|
|
455
|
+
description: tool.description || `External MCP tool ${tool.name}`,
|
|
456
|
+
parameters: await this.convertMCPSchemaToZod(tool.inputSchema),
|
|
426
457
|
execute: async (args) => {
|
|
427
|
-
logger.debug(`[BaseProvider] Executing external MCP tool: ${
|
|
428
|
-
// Execute via
|
|
429
|
-
if (this.
|
|
430
|
-
this.
|
|
431
|
-
|
|
432
|
-
"function") {
|
|
433
|
-
return await this.sdk.externalServerManager.executeTool(externalTool.serverId, externalTool.name, args);
|
|
458
|
+
logger.debug(`[BaseProvider] Executing external MCP tool: ${tool.name}`, { args });
|
|
459
|
+
// Execute via NeuroLink's direct tool execution
|
|
460
|
+
if (this.neurolink &&
|
|
461
|
+
typeof this.neurolink.executeExternalMCPTool === "function") {
|
|
462
|
+
return await this.neurolink.executeExternalMCPTool(tool.serverId || "unknown", tool.name, args);
|
|
434
463
|
}
|
|
435
464
|
else {
|
|
436
|
-
throw new Error(`Cannot execute external MCP tool:
|
|
465
|
+
throw new Error(`Cannot execute external MCP tool: NeuroLink executeExternalMCPTool not available`);
|
|
437
466
|
}
|
|
438
467
|
},
|
|
439
468
|
});
|
|
440
|
-
logger.debug(`[BaseProvider] Successfully added external MCP tool: ${
|
|
469
|
+
logger.debug(`[BaseProvider] Successfully added external MCP tool: ${tool.name}`);
|
|
441
470
|
}
|
|
442
|
-
|
|
443
|
-
logger.
|
|
471
|
+
catch (toolCreationError) {
|
|
472
|
+
logger.error(`Failed to create external MCP tool: ${tool.name}`, toolCreationError);
|
|
444
473
|
}
|
|
445
474
|
}
|
|
446
475
|
logger.debug(`[BaseProvider] External MCP tools loading complete`, {
|
|
447
|
-
|
|
448
|
-
availableExternalTools: externalTools.filter((t) => t.isAvailable)
|
|
449
|
-
.length,
|
|
450
|
-
addedToTools: externalTools.filter((t) => t.isAvailable).length,
|
|
476
|
+
totalToolsAdded: externalTools.length,
|
|
451
477
|
});
|
|
452
478
|
}
|
|
453
479
|
catch (error) {
|
|
@@ -456,12 +482,10 @@ export class BaseProvider {
|
|
|
456
482
|
}
|
|
457
483
|
}
|
|
458
484
|
else {
|
|
459
|
-
logger.debug(`[BaseProvider] No external MCP
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
this.sdk.externalServerManager &&
|
|
464
|
-
typeof this.sdk.externalServerManager.getAllTools === "function",
|
|
485
|
+
logger.debug(`[BaseProvider] No external MCP tool interface available`, {
|
|
486
|
+
hasNeuroLink: !!this.neurolink,
|
|
487
|
+
hasGetExternalMCPTools: this.neurolink &&
|
|
488
|
+
typeof this.neurolink.getExternalMCPTools === "function",
|
|
465
489
|
});
|
|
466
490
|
}
|
|
467
491
|
// MCP tools loading simplified - removed functionCalling dependency
|
|
@@ -689,6 +713,9 @@ export class BaseProvider {
|
|
|
689
713
|
});
|
|
690
714
|
return;
|
|
691
715
|
}
|
|
716
|
+
// Store custom tools for use in getAllTools()
|
|
717
|
+
this.customTools = sdk.customTools;
|
|
718
|
+
this.toolExecutor = sdk.executeTool;
|
|
692
719
|
logger.debug(`[${functionTag}] Setting up tool executor for provider`, {
|
|
693
720
|
providerType: this.constructor.name,
|
|
694
721
|
availableCustomTools: sdk.customTools.size,
|
|
@@ -89,7 +89,7 @@ export class DynamicModelProvider {
|
|
|
89
89
|
}
|
|
90
90
|
// Log all failures for debugging
|
|
91
91
|
logger.warn(`[DynamicModelProvider] All model configuration sources failed`, { errors });
|
|
92
|
-
throw new Error(`Failed to load model configuration from
|
|
92
|
+
throw new Error(`Failed to load model configuration from all source. Attempted: ${errors.map((e) => e.source).join(", ")}`);
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Load configuration from a source with timeout handling
|
|
@@ -181,7 +181,7 @@ Relevance: [score]
|
|
|
181
181
|
Accuracy: [score]
|
|
182
182
|
Completeness: [score]
|
|
183
183
|
Overall: [score]
|
|
184
|
-
Reasoning: [Provide a detailed explanation of your evaluation, explaining why you gave these scores. Include specific observations about the response's strengths and
|
|
184
|
+
Reasoning: [Provide a detailed explanation of your evaluation, explaining why you gave these scores. Include specific observations about the response's strengths and all possible areas for improvement.]
|
|
185
185
|
`;
|
|
186
186
|
// Generate evaluation
|
|
187
187
|
const result = await provider.generate(prompt);
|
package/dist/lib/core/factory.js
CHANGED
|
@@ -109,19 +109,8 @@ export class AIProviderFactory {
|
|
|
109
109
|
const finalModelName = resolvedModelName === "default" || resolvedModelName === null
|
|
110
110
|
? undefined
|
|
111
111
|
: resolvedModelName;
|
|
112
|
-
// ✅ CRITICAL FIX: Pass external MCP tools interface to BaseProvider
|
|
113
|
-
let finalSdk = sdk;
|
|
114
|
-
if (sdk && typeof sdk.getExternalMCPTools === "function") {
|
|
115
|
-
finalSdk = {
|
|
116
|
-
...sdk,
|
|
117
|
-
externalServerManager: {
|
|
118
|
-
getAllTools: () => sdk.getExternalMCPTools(),
|
|
119
|
-
executeTool: (serverId, toolName, params) => sdk.executeExternalMCPTool(serverId, toolName, params),
|
|
120
|
-
},
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
112
|
// Create provider with enhanced SDK
|
|
124
|
-
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName,
|
|
113
|
+
const provider = await ProviderFactory.createProvider(normalizedName, finalModelName, sdk);
|
|
125
114
|
logger.debug(componentIdentifier, "Pure factory pattern provider created", {
|
|
126
115
|
providerName: normalizedName,
|
|
127
116
|
modelName: finalModelName,
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -10,13 +10,14 @@ import { AIProviderFactory } from "./core/factory.js";
|
|
|
10
10
|
export { AIProviderFactory };
|
|
11
11
|
export type { AIProvider, AIProviderName, ProviderConfig, StreamingOptions, ProviderAttempt, SupportedModelName, } from "./core/types.js";
|
|
12
12
|
export type { GenerateOptions, GenerateResult, EnhancedProvider, } from "./types/generateTypes.js";
|
|
13
|
-
export type {
|
|
14
|
-
export {
|
|
15
|
-
export type {
|
|
13
|
+
export type { ToolContext } from "./sdk/toolRegistration.js";
|
|
14
|
+
export { validateTool } from "./sdk/toolRegistration.js";
|
|
15
|
+
export type { ToolResult, ToolDefinition } from "./types/tools.js";
|
|
16
16
|
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
|
|
17
17
|
export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
|
|
18
18
|
export { NeuroLink } from "./neurolink.js";
|
|
19
|
-
export type { ProviderStatus, MCPStatus
|
|
19
|
+
export type { ProviderStatus, MCPStatus } from "./neurolink.js";
|
|
20
|
+
export type { MCPServerInfo } from "./types/mcpTypes.js";
|
|
20
21
|
export declare const VERSION = "1.0.0";
|
|
21
22
|
/**
|
|
22
23
|
* Quick start factory function
|
|
@@ -83,3 +84,21 @@ export declare function getTelemetryStatus(): {
|
|
|
83
84
|
enabled: boolean;
|
|
84
85
|
initialized: boolean;
|
|
85
86
|
};
|
|
87
|
+
export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, EvaluationData, } from "./core/types.js";
|
|
88
|
+
/**
|
|
89
|
+
* BACKWARD COMPATIBILITY: Legacy generateText function
|
|
90
|
+
* Provides standalone generateText function for existing code that uses it
|
|
91
|
+
*
|
|
92
|
+
* @example
|
|
93
|
+
* ```typescript
|
|
94
|
+
* import { generateText } from '@juspay/neurolink';
|
|
95
|
+
*
|
|
96
|
+
* const result = await generateText({
|
|
97
|
+
* prompt: 'Hello, AI!',
|
|
98
|
+
* provider: 'bedrock',
|
|
99
|
+
* model: 'claude-3-sonnet'
|
|
100
|
+
* });
|
|
101
|
+
* console.log(result.content);
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
export declare function generateText(options: import("./core/types.js").TextGenerationOptions): Promise<import("./core/types.js").TextGenerationResult>;
|
package/dist/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// Core exports
|
|
10
10
|
import { AIProviderFactory } from "./core/factory.js";
|
|
11
11
|
export { AIProviderFactory };
|
|
12
|
-
export {
|
|
12
|
+
export { validateTool } from "./sdk/toolRegistration.js";
|
|
13
13
|
// Model enums
|
|
14
14
|
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./core/types.js";
|
|
15
15
|
// Utility exports
|
|
@@ -107,3 +107,24 @@ export function getTelemetryStatus() {
|
|
|
107
107
|
}
|
|
108
108
|
return { enabled: false, initialized: false };
|
|
109
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* BACKWARD COMPATIBILITY: Legacy generateText function
|
|
112
|
+
* Provides standalone generateText function for existing code that uses it
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import { generateText } from '@juspay/neurolink';
|
|
117
|
+
*
|
|
118
|
+
* const result = await generateText({
|
|
119
|
+
* prompt: 'Hello, AI!',
|
|
120
|
+
* provider: 'bedrock',
|
|
121
|
+
* model: 'claude-3-sonnet'
|
|
122
|
+
* });
|
|
123
|
+
* console.log(result.content);
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export async function generateText(options) {
|
|
127
|
+
// Import neurolink instance to avoid circular dependencies
|
|
128
|
+
const { neurolink } = await import("./neurolink.js");
|
|
129
|
+
return await neurolink.generateText(options);
|
|
130
|
+
}
|
|
@@ -8,25 +8,45 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { EventEmitter } from "events";
|
|
10
10
|
import { ToolDiscoveryService } from "./toolDiscoveryService.js";
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* Core class for managing external MCP servers
|
|
15
|
-
*/
|
|
11
|
+
import type { ExternalMCPServerInstance, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPManagerConfig, ExternalMCPToolInfo } from "../types/externalMcp.js";
|
|
12
|
+
import type { MCPServerInfo } from "../types/mcpTypes.js";
|
|
13
|
+
import type { JsonObject } from "../types/common.js";
|
|
16
14
|
export declare class ExternalServerManager extends EventEmitter {
|
|
17
15
|
private servers;
|
|
18
16
|
private config;
|
|
19
17
|
private isShuttingDown;
|
|
20
18
|
private toolDiscovery;
|
|
21
|
-
|
|
19
|
+
private enableMainRegistryIntegration;
|
|
20
|
+
constructor(config?: ExternalMCPManagerConfig, options?: {
|
|
21
|
+
enableMainRegistryIntegration?: boolean;
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Load MCP server configurations from .mcp-config.json file
|
|
25
|
+
* Automatically registers servers found in the configuration
|
|
26
|
+
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
27
|
+
* @returns Promise resolving to number of servers loaded
|
|
28
|
+
*/
|
|
29
|
+
loadMCPConfiguration(configPath?: string): Promise<{
|
|
30
|
+
serversLoaded: number;
|
|
31
|
+
errors: string[];
|
|
32
|
+
}>;
|
|
22
33
|
/**
|
|
23
34
|
* Validate external MCP server configuration
|
|
24
35
|
*/
|
|
25
|
-
validateConfig(config:
|
|
36
|
+
validateConfig(config: MCPServerInfo): ExternalMCPConfigValidation;
|
|
37
|
+
/**
|
|
38
|
+
* Convert MCPServerInfo format (keeping for backward compatibility)
|
|
39
|
+
* Helper function for transitioning to zero-conversion architecture
|
|
40
|
+
*/
|
|
41
|
+
private convertConfigToMCPServerInfo;
|
|
42
|
+
/**
|
|
43
|
+
* Add a new external MCP server - Backward compatibility overload
|
|
44
|
+
*/
|
|
45
|
+
addServer(serverId: string, config: MCPServerInfo): Promise<ExternalMCPOperationResult<ExternalMCPServerInstance>>;
|
|
26
46
|
/**
|
|
27
|
-
* Add a new external MCP server
|
|
47
|
+
* Add a new external MCP server - Updated to accept MCPServerInfo
|
|
28
48
|
*/
|
|
29
|
-
addServer(serverId: string,
|
|
49
|
+
addServer(serverId: string, serverInfo: MCPServerInfo): Promise<ExternalMCPOperationResult<ExternalMCPServerInstance>>;
|
|
30
50
|
/**
|
|
31
51
|
* Remove an external MCP server
|
|
32
52
|
*/
|
|
@@ -64,13 +84,17 @@ export declare class ExternalServerManager extends EventEmitter {
|
|
|
64
84
|
*/
|
|
65
85
|
private performHealthCheck;
|
|
66
86
|
/**
|
|
67
|
-
* Get server instance
|
|
87
|
+
* Get server instance - converted to ExternalMCPServerInstance for compatibility
|
|
68
88
|
*/
|
|
69
89
|
getServer(serverId: string): ExternalMCPServerInstance | undefined;
|
|
70
90
|
/**
|
|
71
|
-
* Get all servers
|
|
91
|
+
* Get all servers - converted to ExternalMCPServerInstance for compatibility
|
|
72
92
|
*/
|
|
73
93
|
getAllServers(): Map<string, ExternalMCPServerInstance>;
|
|
94
|
+
/**
|
|
95
|
+
* List servers as MCPServerInfo - ZERO conversion needed
|
|
96
|
+
*/
|
|
97
|
+
listServers(): MCPServerInfo[];
|
|
74
98
|
/**
|
|
75
99
|
* Get server statuses
|
|
76
100
|
*/
|
|
@@ -94,12 +118,21 @@ export declare class ExternalServerManager extends EventEmitter {
|
|
|
94
118
|
* Discover tools from a server
|
|
95
119
|
*/
|
|
96
120
|
private discoverServerTools;
|
|
121
|
+
/**
|
|
122
|
+
* Register server tools with main tool registry for unified access
|
|
123
|
+
* This enables external MCP tools to be accessed via the main toolRegistry.executeTool()
|
|
124
|
+
*/
|
|
125
|
+
private registerServerToolsWithMainRegistry;
|
|
126
|
+
/**
|
|
127
|
+
* Unregister server tools from main tool registry
|
|
128
|
+
*/
|
|
129
|
+
private unregisterServerToolsFromMainRegistry;
|
|
97
130
|
/**
|
|
98
131
|
* Execute a tool on a specific server
|
|
99
132
|
*/
|
|
100
|
-
executeTool(serverId: string, toolName: string, parameters:
|
|
133
|
+
executeTool(serverId: string, toolName: string, parameters: JsonObject, options?: {
|
|
101
134
|
timeout?: number;
|
|
102
|
-
}): Promise<
|
|
135
|
+
}): Promise<unknown>;
|
|
103
136
|
/**
|
|
104
137
|
* Get all tools from all servers
|
|
105
138
|
*/
|