@juspay/neurolink 7.37.0 → 7.38.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/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 +44 -3
- package/dist/core/baseProvider.js +729 -352
- package/dist/core/constants.d.ts +2 -30
- package/dist/core/constants.js +15 -43
- package/dist/core/redisConversationMemoryManager.d.ts +98 -15
- package/dist/core/redisConversationMemoryManager.js +665 -203
- 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 +44 -3
- package/dist/lib/core/baseProvider.js +729 -352
- package/dist/lib/core/constants.d.ts +2 -30
- package/dist/lib/core/constants.js +15 -43
- package/dist/lib/core/redisConversationMemoryManager.d.ts +98 -15
- package/dist/lib/core/redisConversationMemoryManager.js +665 -203
- 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 +95 -28
- package/dist/lib/neurolink.js +479 -719
- package/dist/lib/providers/amazonBedrock.js +2 -2
- package/dist/lib/providers/anthropic.js +8 -0
- package/dist/lib/providers/anthropicBaseProvider.js +8 -0
- package/dist/lib/providers/azureOpenai.js +8 -0
- package/dist/lib/providers/googleAiStudio.js +8 -0
- package/dist/lib/providers/googleVertex.d.ts +3 -23
- package/dist/lib/providers/googleVertex.js +24 -342
- package/dist/lib/providers/huggingFace.js +8 -0
- package/dist/lib/providers/litellm.js +8 -0
- package/dist/lib/providers/mistral.js +8 -0
- package/dist/lib/providers/openAI.d.ts +23 -0
- package/dist/lib/providers/openAI.js +323 -6
- package/dist/lib/providers/openaiCompatible.js +8 -0
- 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/conversation.d.ts +52 -2
- package/dist/lib/types/streamTypes.d.ts +13 -6
- package/dist/lib/types/typeAliases.d.ts +3 -2
- package/dist/lib/utils/conversationMemory.js +3 -1
- package/dist/lib/utils/messageBuilder.d.ts +10 -2
- package/dist/lib/utils/messageBuilder.js +22 -1
- package/dist/lib/utils/parameterValidation.js +6 -25
- package/dist/lib/utils/promptRedaction.js +4 -4
- package/dist/lib/utils/redis.d.ts +10 -6
- package/dist/lib/utils/redis.js +71 -70
- 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 +95 -28
- package/dist/neurolink.js +479 -719
- package/dist/providers/amazonBedrock.js +2 -2
- package/dist/providers/anthropic.js +8 -0
- package/dist/providers/anthropicBaseProvider.js +8 -0
- package/dist/providers/azureOpenai.js +8 -0
- package/dist/providers/googleAiStudio.js +8 -0
- package/dist/providers/googleVertex.d.ts +3 -23
- package/dist/providers/googleVertex.js +24 -342
- package/dist/providers/huggingFace.js +8 -0
- package/dist/providers/litellm.js +8 -0
- package/dist/providers/mistral.js +8 -0
- package/dist/providers/openAI.d.ts +23 -0
- package/dist/providers/openAI.js +323 -6
- package/dist/providers/openaiCompatible.js +8 -0
- 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/conversation.d.ts +52 -2
- package/dist/types/streamTypes.d.ts +13 -6
- package/dist/types/typeAliases.d.ts +3 -2
- package/dist/utils/conversationMemory.js +3 -1
- package/dist/utils/messageBuilder.d.ts +10 -2
- package/dist/utils/messageBuilder.js +22 -1
- package/dist/utils/parameterValidation.js +6 -25
- package/dist/utils/promptRedaction.js +4 -4
- package/dist/utils/redis.d.ts +10 -6
- package/dist/utils/redis.js +71 -70
- 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
@@ -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/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/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
|
}
|
@@ -34,6 +34,39 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
34
34
|
* When tools are involved, falls back to generate() with synthetic streaming
|
35
35
|
*/
|
36
36
|
stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
37
|
+
/**
|
38
|
+
* Prepare generation context including tools and model
|
39
|
+
*/
|
40
|
+
private prepareGenerationContext;
|
41
|
+
/**
|
42
|
+
* Build messages array for generation
|
43
|
+
*/
|
44
|
+
private buildMessages;
|
45
|
+
/**
|
46
|
+
* Execute the generation with AI SDK
|
47
|
+
*/
|
48
|
+
private executeGeneration;
|
49
|
+
/**
|
50
|
+
* Log generation completion information
|
51
|
+
*/
|
52
|
+
private logGenerationComplete;
|
53
|
+
/**
|
54
|
+
* Record performance metrics
|
55
|
+
*/
|
56
|
+
private recordPerformanceMetrics;
|
57
|
+
/**
|
58
|
+
* Extract tool information from generation result
|
59
|
+
*/
|
60
|
+
private extractToolInformation;
|
61
|
+
/**
|
62
|
+
* Format the enhanced result
|
63
|
+
*/
|
64
|
+
private formatEnhancedResult;
|
65
|
+
/**
|
66
|
+
* Analyze AI response structure and log detailed debugging information
|
67
|
+
* Extracted from generate method to reduce complexity
|
68
|
+
*/
|
69
|
+
private analyzeAIResponse;
|
37
70
|
/**
|
38
71
|
* Text generation method - implements AIProvider interface
|
39
72
|
* Tools are always available unless explicitly disabled
|
@@ -85,12 +118,17 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
85
118
|
private isZodSchema;
|
86
119
|
/**
|
87
120
|
* Convert tool execution result from MCP format to standard format
|
121
|
+
* Handles tool failures gracefully to prevent stream termination
|
88
122
|
*/
|
89
123
|
private convertToolResult;
|
90
124
|
/**
|
91
125
|
* Create a custom tool from tool definition
|
92
126
|
*/
|
93
127
|
private createCustomToolFromDefinition;
|
128
|
+
/**
|
129
|
+
* Process direct tools with event emission wrapping
|
130
|
+
*/
|
131
|
+
private processDirectTools;
|
94
132
|
/**
|
95
133
|
* Process custom tools from setupToolExecutor
|
96
134
|
*/
|
@@ -117,10 +155,9 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
117
155
|
*/
|
118
156
|
private calculateActualCost;
|
119
157
|
/**
|
120
|
-
*
|
121
|
-
* Handles common MCP schema patterns safely
|
158
|
+
* Create a permissive Zod schema that accepts all parameters as-is
|
122
159
|
*/
|
123
|
-
private
|
160
|
+
private createPermissiveZodSchema;
|
124
161
|
/**
|
125
162
|
* Set session context for MCP tools
|
126
163
|
*/
|
@@ -187,6 +224,10 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
187
224
|
* Get timeout value in milliseconds
|
188
225
|
*/
|
189
226
|
getTimeout(options: TextGenerationOptions | StreamOptions): number;
|
227
|
+
/**
|
228
|
+
* Check if tool executions should be stored and handle storage
|
229
|
+
*/
|
230
|
+
protected handleToolExecutionStorage(toolCalls: unknown[], toolResults: unknown[], options: TextGenerationOptions | StreamOptions): Promise<void>;
|
190
231
|
/**
|
191
232
|
* Utility method to chunk large prompts into smaller pieces
|
192
233
|
* @param prompt The prompt to chunk
|