@juspay/neurolink 8.3.0 → 8.4.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 +12 -0
- package/README.md +1 -0
- package/dist/adapters/providerImageAdapter.d.ts +1 -1
- package/dist/adapters/providerImageAdapter.js +62 -0
- package/dist/agent/directTools.d.ts +0 -72
- package/dist/agent/directTools.js +3 -74
- package/dist/cli/commands/config.d.ts +18 -18
- package/dist/cli/factories/commandFactory.js +1 -0
- package/dist/constants/enums.d.ts +1 -0
- package/dist/constants/enums.js +3 -1
- package/dist/constants/tokens.d.ts +3 -0
- package/dist/constants/tokens.js +3 -0
- package/dist/core/baseProvider.d.ts +56 -53
- package/dist/core/baseProvider.js +107 -1095
- package/dist/core/constants.d.ts +3 -0
- package/dist/core/constants.js +6 -3
- package/dist/core/modelConfiguration.js +10 -0
- package/dist/core/modules/GenerationHandler.d.ts +63 -0
- package/dist/core/modules/GenerationHandler.js +230 -0
- package/dist/core/modules/MessageBuilder.d.ts +39 -0
- package/dist/core/modules/MessageBuilder.js +179 -0
- package/dist/core/modules/StreamHandler.d.ts +52 -0
- package/dist/core/modules/StreamHandler.js +103 -0
- package/dist/core/modules/TelemetryHandler.d.ts +64 -0
- package/dist/core/modules/TelemetryHandler.js +170 -0
- package/dist/core/modules/ToolsManager.d.ts +98 -0
- package/dist/core/modules/ToolsManager.js +521 -0
- package/dist/core/modules/Utilities.d.ts +88 -0
- package/dist/core/modules/Utilities.js +329 -0
- package/dist/factories/providerRegistry.js +1 -1
- package/dist/lib/adapters/providerImageAdapter.d.ts +1 -1
- package/dist/lib/adapters/providerImageAdapter.js +62 -0
- package/dist/lib/agent/directTools.d.ts +0 -72
- package/dist/lib/agent/directTools.js +3 -74
- package/dist/lib/constants/enums.d.ts +1 -0
- package/dist/lib/constants/enums.js +3 -1
- package/dist/lib/constants/tokens.d.ts +3 -0
- package/dist/lib/constants/tokens.js +3 -0
- package/dist/lib/core/baseProvider.d.ts +56 -53
- package/dist/lib/core/baseProvider.js +107 -1095
- package/dist/lib/core/constants.d.ts +3 -0
- package/dist/lib/core/constants.js +6 -3
- package/dist/lib/core/modelConfiguration.js +10 -0
- package/dist/lib/core/modules/GenerationHandler.d.ts +63 -0
- package/dist/lib/core/modules/GenerationHandler.js +231 -0
- package/dist/lib/core/modules/MessageBuilder.d.ts +39 -0
- package/dist/lib/core/modules/MessageBuilder.js +180 -0
- package/dist/lib/core/modules/StreamHandler.d.ts +52 -0
- package/dist/lib/core/modules/StreamHandler.js +104 -0
- package/dist/lib/core/modules/TelemetryHandler.d.ts +64 -0
- package/dist/lib/core/modules/TelemetryHandler.js +171 -0
- package/dist/lib/core/modules/ToolsManager.d.ts +98 -0
- package/dist/lib/core/modules/ToolsManager.js +522 -0
- package/dist/lib/core/modules/Utilities.d.ts +88 -0
- package/dist/lib/core/modules/Utilities.js +330 -0
- package/dist/lib/factories/providerRegistry.js +1 -1
- package/dist/lib/mcp/servers/agent/directToolsServer.js +0 -1
- package/dist/lib/memory/mem0Initializer.d.ts +32 -1
- package/dist/lib/memory/mem0Initializer.js +55 -2
- package/dist/lib/models/modelRegistry.js +44 -0
- package/dist/lib/neurolink.d.ts +1 -1
- package/dist/lib/neurolink.js +43 -10
- package/dist/lib/providers/amazonBedrock.js +59 -10
- package/dist/lib/providers/anthropic.js +2 -30
- package/dist/lib/providers/azureOpenai.js +2 -24
- package/dist/lib/providers/googleAiStudio.js +2 -24
- package/dist/lib/providers/googleVertex.js +2 -45
- package/dist/lib/providers/huggingFace.js +3 -31
- package/dist/lib/providers/litellm.d.ts +1 -1
- package/dist/lib/providers/litellm.js +110 -44
- package/dist/lib/providers/mistral.js +5 -32
- package/dist/lib/providers/ollama.d.ts +1 -0
- package/dist/lib/providers/ollama.js +476 -129
- package/dist/lib/providers/openAI.js +2 -28
- package/dist/lib/providers/openaiCompatible.js +3 -31
- package/dist/lib/types/content.d.ts +16 -113
- package/dist/lib/types/content.js +16 -2
- package/dist/lib/types/conversation.d.ts +3 -17
- package/dist/lib/types/generateTypes.d.ts +2 -2
- package/dist/lib/types/index.d.ts +2 -0
- package/dist/lib/types/index.js +2 -0
- package/dist/lib/types/multimodal.d.ts +282 -0
- package/dist/lib/types/multimodal.js +101 -0
- package/dist/lib/types/streamTypes.d.ts +2 -2
- package/dist/lib/utils/imageProcessor.d.ts +1 -1
- package/dist/lib/utils/messageBuilder.js +25 -2
- package/dist/lib/utils/multimodalOptionsBuilder.d.ts +1 -1
- package/dist/lib/utils/pdfProcessor.d.ts +9 -0
- package/dist/lib/utils/pdfProcessor.js +67 -9
- package/dist/mcp/servers/agent/directToolsServer.js +0 -1
- package/dist/memory/mem0Initializer.d.ts +32 -1
- package/dist/memory/mem0Initializer.js +55 -2
- package/dist/models/modelRegistry.js +44 -0
- package/dist/neurolink.d.ts +1 -1
- package/dist/neurolink.js +43 -10
- package/dist/providers/amazonBedrock.js +59 -10
- package/dist/providers/anthropic.js +2 -30
- package/dist/providers/azureOpenai.js +2 -24
- package/dist/providers/googleAiStudio.js +2 -24
- package/dist/providers/googleVertex.js +2 -45
- package/dist/providers/huggingFace.js +3 -31
- package/dist/providers/litellm.d.ts +1 -1
- package/dist/providers/litellm.js +110 -44
- package/dist/providers/mistral.js +5 -32
- package/dist/providers/ollama.d.ts +1 -0
- package/dist/providers/ollama.js +476 -129
- package/dist/providers/openAI.js +2 -28
- package/dist/providers/openaiCompatible.js +3 -31
- package/dist/types/content.d.ts +16 -113
- package/dist/types/content.js +16 -2
- package/dist/types/conversation.d.ts +3 -17
- package/dist/types/generateTypes.d.ts +2 -2
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/multimodal.d.ts +282 -0
- package/dist/types/multimodal.js +100 -0
- package/dist/types/streamTypes.d.ts +2 -2
- package/dist/utils/imageProcessor.d.ts +1 -1
- package/dist/utils/messageBuilder.js +25 -2
- package/dist/utils/multimodalOptionsBuilder.d.ts +1 -1
- package/dist/utils/pdfProcessor.d.ts +9 -0
- package/dist/utils/pdfProcessor.js +67 -9
- package/package.json +5 -2
|
@@ -63,6 +63,7 @@ export const PROVIDER_TOKEN_LIMITS = {
|
|
|
63
63
|
"claude-3-5-sonnet-20241022": 4096,
|
|
64
64
|
"claude-3-opus-20240229": 4096,
|
|
65
65
|
"claude-3-5-haiku-20241022": 4096,
|
|
66
|
+
"claude-haiku-4-5-20251001": 8192,
|
|
66
67
|
"claude-3-sonnet-20240229": 4096,
|
|
67
68
|
default: 4096, // Conservative default for Anthropic
|
|
68
69
|
},
|
|
@@ -100,6 +101,7 @@ export const PROVIDER_TOKEN_LIMITS = {
|
|
|
100
101
|
"claude-opus-4@20250514": 4096,
|
|
101
102
|
"claude-3-5-sonnet-20241022": 4096,
|
|
102
103
|
"claude-3-5-haiku-20241022": 4096,
|
|
104
|
+
"claude-haiku-4-5-20251001": 8192,
|
|
103
105
|
"claude-3-sonnet-20240229": 4096,
|
|
104
106
|
"claude-3-haiku-20240307": 4096,
|
|
105
107
|
"claude-3-opus-20240229": 4096,
|
|
@@ -111,6 +113,7 @@ export const PROVIDER_TOKEN_LIMITS = {
|
|
|
111
113
|
"anthropic.claude-3-haiku-20240307-v1:0": 4096,
|
|
112
114
|
"anthropic.claude-3-5-sonnet-20240620-v1:0": 4096,
|
|
113
115
|
"anthropic.claude-3-opus-20240229-v1:0": 4096,
|
|
116
|
+
"anthropic.claude-haiku-4-5-20251001-v1:0": 8192,
|
|
114
117
|
"arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0": 4096,
|
|
115
118
|
default: 4096,
|
|
116
119
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
2
|
-
import type { Tool, LanguageModelV1 } from "ai";
|
|
2
|
+
import type { Tool, LanguageModelV1, CoreMessage } from "ai";
|
|
3
3
|
import type { AIProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, AnalyticsData } from "../types/index.js";
|
|
4
4
|
import { AIProviderName } from "../constants/enums.js";
|
|
5
5
|
import type { EvaluationData } from "../index.js";
|
|
@@ -23,6 +23,12 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
23
23
|
protected sessionId?: string;
|
|
24
24
|
protected userId?: string;
|
|
25
25
|
protected neurolink?: NeuroLink;
|
|
26
|
+
private readonly messageBuilder;
|
|
27
|
+
private readonly streamHandler;
|
|
28
|
+
private readonly generationHandler;
|
|
29
|
+
private readonly telemetryHandler;
|
|
30
|
+
private readonly utilities;
|
|
31
|
+
private readonly toolsManager;
|
|
26
32
|
constructor(modelName?: string, providerName?: AIProviderName, neurolink?: NeuroLink, middleware?: MiddlewareFactoryOptions);
|
|
27
33
|
/**
|
|
28
34
|
* Check if this provider supports tool/function calling
|
|
@@ -40,32 +46,40 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
40
46
|
*/
|
|
41
47
|
private prepareGenerationContext;
|
|
42
48
|
/**
|
|
43
|
-
* Build messages array for generation
|
|
49
|
+
* Build messages array for generation - delegated to MessageBuilder
|
|
44
50
|
*/
|
|
45
51
|
private buildMessages;
|
|
46
52
|
/**
|
|
47
|
-
*
|
|
53
|
+
* Build messages array for streaming operations - delegated to MessageBuilder
|
|
54
|
+
* This is a protected helper method that providers can use to build messages
|
|
55
|
+
* with automatic multimodal detection, eliminating code duplication
|
|
56
|
+
*
|
|
57
|
+
* @param options - Stream options or text generation options
|
|
58
|
+
* @returns Promise resolving to CoreMessage array ready for AI SDK
|
|
59
|
+
*/
|
|
60
|
+
protected buildMessagesForStream(options: StreamOptions | TextGenerationOptions): Promise<CoreMessage[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Execute the generation with AI SDK - delegated to GenerationHandler
|
|
48
63
|
*/
|
|
49
64
|
private executeGeneration;
|
|
50
65
|
/**
|
|
51
|
-
* Log generation completion information
|
|
66
|
+
* Log generation completion information - delegated to GenerationHandler
|
|
52
67
|
*/
|
|
53
68
|
private logGenerationComplete;
|
|
54
69
|
/**
|
|
55
|
-
* Record performance metrics
|
|
70
|
+
* Record performance metrics - delegated to TelemetryHandler
|
|
56
71
|
*/
|
|
57
72
|
private recordPerformanceMetrics;
|
|
58
73
|
/**
|
|
59
|
-
* Extract tool information from generation result
|
|
74
|
+
* Extract tool information from generation result - delegated to GenerationHandler
|
|
60
75
|
*/
|
|
61
76
|
private extractToolInformation;
|
|
62
77
|
/**
|
|
63
|
-
* Format the enhanced result
|
|
78
|
+
* Format the enhanced result - delegated to GenerationHandler
|
|
64
79
|
*/
|
|
65
80
|
private formatEnhancedResult;
|
|
66
81
|
/**
|
|
67
|
-
* Analyze AI response structure and log detailed debugging information
|
|
68
|
-
* Extracted from generate method to reduce complexity
|
|
82
|
+
* Analyze AI response structure and log detailed debugging information - delegated to GenerationHandler
|
|
69
83
|
*/
|
|
70
84
|
private analyzeAIResponse;
|
|
71
85
|
/**
|
|
@@ -109,63 +123,35 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
109
123
|
*/
|
|
110
124
|
protected getAISDKModelWithMiddleware(options?: TextGenerationOptions | StreamOptions): Promise<LanguageModelV1>;
|
|
111
125
|
/**
|
|
112
|
-
* Extract middleware options
|
|
113
|
-
* source of truth for deciding if middleware should be applied.
|
|
126
|
+
* Extract middleware options - delegated to Utilities
|
|
114
127
|
*/
|
|
115
128
|
private extractMiddlewareOptions;
|
|
116
129
|
/**
|
|
117
|
-
* Check if a schema is a Zod schema
|
|
130
|
+
* Check if a schema is a Zod schema - delegated to Utilities
|
|
118
131
|
*/
|
|
119
132
|
private isZodSchema;
|
|
120
133
|
/**
|
|
121
|
-
* Convert tool execution result
|
|
122
|
-
* Handles tool failures gracefully to prevent stream termination
|
|
134
|
+
* Convert tool execution result - delegated to Utilities
|
|
123
135
|
*/
|
|
124
136
|
private convertToolResult;
|
|
125
137
|
/**
|
|
126
|
-
*
|
|
127
|
-
*/
|
|
128
|
-
private createCustomToolFromDefinition;
|
|
129
|
-
/**
|
|
130
|
-
* Process direct tools with event emission wrapping
|
|
131
|
-
*/
|
|
132
|
-
private processDirectTools;
|
|
133
|
-
/**
|
|
134
|
-
* Process custom tools from setupToolExecutor
|
|
135
|
-
*/
|
|
136
|
-
private processCustomTools;
|
|
137
|
-
/**
|
|
138
|
-
* Recursively fix JSON Schema for OpenAI strict mode compatibility
|
|
139
|
-
* OpenAI requires additionalProperties: false at ALL levels and preserves required array
|
|
138
|
+
* Fix JSON Schema for OpenAI strict mode - delegated to Utilities
|
|
140
139
|
*/
|
|
141
140
|
private fixSchemaForOpenAIStrictMode;
|
|
142
141
|
/**
|
|
143
|
-
*
|
|
144
|
-
*/
|
|
145
|
-
private createExternalMCPTool;
|
|
146
|
-
/**
|
|
147
|
-
* Process external MCP tools
|
|
148
|
-
*/
|
|
149
|
-
private processExternalMCPTools;
|
|
150
|
-
/**
|
|
151
|
-
* Process MCP tools integration
|
|
152
|
-
*/
|
|
153
|
-
private processMCPTools;
|
|
154
|
-
/**
|
|
155
|
-
* Get all available tools - direct tools are ALWAYS available
|
|
156
|
-
* MCP tools are added when available (without blocking)
|
|
142
|
+
* Get all available tools - delegated to ToolsManager
|
|
157
143
|
*/
|
|
158
144
|
protected getAllTools(): Promise<Record<string, Tool>>;
|
|
159
145
|
/**
|
|
160
|
-
* Calculate actual cost
|
|
146
|
+
* Calculate actual cost - delegated to TelemetryHandler
|
|
161
147
|
*/
|
|
162
148
|
private calculateActualCost;
|
|
163
149
|
/**
|
|
164
|
-
* Create a permissive Zod schema
|
|
150
|
+
* Create a permissive Zod schema - delegated to Utilities
|
|
165
151
|
*/
|
|
166
152
|
private createPermissiveZodSchema;
|
|
167
153
|
/**
|
|
168
|
-
* Set session context for MCP tools
|
|
154
|
+
* Set session context for MCP tools - delegated to ToolsManager
|
|
169
155
|
*/
|
|
170
156
|
setSessionContext(sessionId?: string, userId?: string): void;
|
|
171
157
|
/**
|
|
@@ -181,11 +167,11 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
181
167
|
operationType?: string;
|
|
182
168
|
}): Promise<T>;
|
|
183
169
|
/**
|
|
184
|
-
* Validate stream options -
|
|
170
|
+
* Validate stream options - delegated to StreamHandler
|
|
185
171
|
*/
|
|
186
172
|
protected validateStreamOptions(options: StreamOptions): void;
|
|
187
173
|
/**
|
|
188
|
-
* Create text stream transformation -
|
|
174
|
+
* Create text stream transformation - delegated to StreamHandler
|
|
189
175
|
*/
|
|
190
176
|
protected createTextStream(result: {
|
|
191
177
|
textStream: AsyncIterable<string>;
|
|
@@ -193,22 +179,21 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
193
179
|
content: string;
|
|
194
180
|
}>;
|
|
195
181
|
/**
|
|
196
|
-
* Create standardized stream result -
|
|
182
|
+
* Create standardized stream result - delegated to StreamHandler
|
|
197
183
|
*/
|
|
198
184
|
protected createStreamResult(stream: AsyncGenerator<{
|
|
199
185
|
content: string;
|
|
200
186
|
}>, additionalProps?: Partial<StreamResult>): StreamResult;
|
|
201
187
|
/**
|
|
202
|
-
* Create stream analytics -
|
|
188
|
+
* Create stream analytics - delegated to StreamHandler
|
|
203
189
|
*/
|
|
204
190
|
protected createStreamAnalytics(result: UnknownRecord, startTime: number, options: StreamOptions): Promise<UnknownRecord | undefined>;
|
|
205
191
|
/**
|
|
206
|
-
* Handle common error patterns -
|
|
192
|
+
* Handle common error patterns - delegated to Utilities
|
|
207
193
|
*/
|
|
208
194
|
protected handleCommonErrors(error: unknown): Error | null;
|
|
209
195
|
/**
|
|
210
|
-
* Set up tool executor
|
|
211
|
-
* Consolidates identical setupToolExecutor logic from neurolink.ts (used in 4 places)
|
|
196
|
+
* Set up tool executor - delegated to ToolsManager
|
|
212
197
|
* @param sdk - The NeuroLinkSDK instance for tool execution
|
|
213
198
|
* @param functionTag - Function name for logging
|
|
214
199
|
*/
|
|
@@ -216,18 +201,36 @@ export declare abstract class BaseProvider implements AIProvider {
|
|
|
216
201
|
customTools: Map<string, unknown>;
|
|
217
202
|
executeTool: (toolName: string, params: unknown) => Promise<unknown>;
|
|
218
203
|
}, functionTag: string): void;
|
|
204
|
+
/**
|
|
205
|
+
* Normalize text generation options - delegated to Utilities
|
|
206
|
+
*/
|
|
219
207
|
protected normalizeTextOptions(optionsOrPrompt: TextGenerationOptions | string): TextGenerationOptions;
|
|
208
|
+
/**
|
|
209
|
+
* Normalize stream options - delegated to Utilities
|
|
210
|
+
*/
|
|
220
211
|
protected normalizeStreamOptions(optionsOrPrompt: StreamOptions | string): StreamOptions;
|
|
221
212
|
protected enhanceResult(result: EnhancedGenerateResult, options: TextGenerationOptions, startTime: number): Promise<EnhancedGenerateResult>;
|
|
213
|
+
/**
|
|
214
|
+
* Create analytics - delegated to TelemetryHandler
|
|
215
|
+
*/
|
|
222
216
|
protected createAnalytics(result: EnhancedGenerateResult, responseTime: number, options: TextGenerationOptions): Promise<AnalyticsData>;
|
|
217
|
+
/**
|
|
218
|
+
* Create evaluation - delegated to TelemetryHandler
|
|
219
|
+
*/
|
|
223
220
|
protected createEvaluation(result: EnhancedGenerateResult, options: TextGenerationOptions): Promise<EvaluationData>;
|
|
221
|
+
/**
|
|
222
|
+
* Validate text generation options - delegated to Utilities
|
|
223
|
+
*/
|
|
224
224
|
protected validateOptions(options: TextGenerationOptions): void;
|
|
225
|
+
/**
|
|
226
|
+
* Get provider information - delegated to Utilities
|
|
227
|
+
*/
|
|
225
228
|
protected getProviderInfo(): {
|
|
226
229
|
provider: string;
|
|
227
230
|
model: string;
|
|
228
231
|
};
|
|
229
232
|
/**
|
|
230
|
-
* Get timeout value in milliseconds
|
|
233
|
+
* Get timeout value in milliseconds - delegated to Utilities
|
|
231
234
|
*/
|
|
232
235
|
getTimeout(options: TextGenerationOptions | StreamOptions): number;
|
|
233
236
|
/**
|