@juspay/neurolink 7.10.2 → 7.11.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/config/types.d.ts +14 -0
  3. package/dist/config/types.js +6 -0
  4. package/dist/core/baseProvider.d.ts +45 -340
  5. package/dist/core/baseProvider.js +205 -30
  6. package/dist/core/types.d.ts +4 -0
  7. package/dist/factories/providerFactory.js +1 -1
  8. package/dist/factories/providerRegistry.js +8 -8
  9. package/dist/lib/config/types.d.ts +14 -0
  10. package/dist/lib/config/types.js +6 -0
  11. package/dist/lib/core/baseProvider.d.ts +45 -340
  12. package/dist/lib/core/baseProvider.js +205 -30
  13. package/dist/lib/core/types.d.ts +4 -0
  14. package/dist/lib/factories/providerFactory.js +1 -1
  15. package/dist/lib/factories/providerRegistry.js +8 -8
  16. package/dist/lib/mcp/servers/agent/directToolsServer.js +80 -68
  17. package/dist/lib/mcp/toolRegistry.js +8 -2
  18. package/dist/lib/neurolink.js +20 -0
  19. package/dist/lib/providers/amazonBedrock.d.ts +0 -1
  20. package/dist/lib/providers/amazonBedrock.js +0 -13
  21. package/dist/lib/providers/anthropic.js +8 -25
  22. package/dist/lib/providers/googleAiStudio.d.ts +0 -1
  23. package/dist/lib/providers/googleAiStudio.js +10 -15
  24. package/dist/lib/providers/googleVertex.d.ts +0 -1
  25. package/dist/lib/providers/googleVertex.js +17 -24
  26. package/dist/lib/providers/huggingFace.d.ts +0 -1
  27. package/dist/lib/providers/huggingFace.js +0 -8
  28. package/dist/lib/providers/litellm.d.ts +0 -1
  29. package/dist/lib/providers/litellm.js +0 -8
  30. package/dist/lib/providers/mistral.d.ts +9 -24
  31. package/dist/lib/providers/mistral.js +44 -82
  32. package/dist/lib/providers/ollama.d.ts +0 -1
  33. package/dist/lib/providers/ollama.js +0 -12
  34. package/dist/lib/providers/openAI.d.ts +2 -3
  35. package/dist/lib/providers/openAI.js +12 -20
  36. package/dist/lib/providers/openaiCompatible.d.ts +0 -1
  37. package/dist/lib/providers/openaiCompatible.js +0 -8
  38. package/dist/lib/utils/toolUtils.d.ts +32 -0
  39. package/dist/lib/utils/toolUtils.js +60 -0
  40. package/dist/mcp/servers/agent/directToolsServer.js +80 -68
  41. package/dist/mcp/toolRegistry.js +8 -2
  42. package/dist/neurolink.js +20 -0
  43. package/dist/providers/amazonBedrock.d.ts +0 -1
  44. package/dist/providers/amazonBedrock.js +0 -13
  45. package/dist/providers/anthropic.js +8 -25
  46. package/dist/providers/googleAiStudio.d.ts +0 -1
  47. package/dist/providers/googleAiStudio.js +10 -15
  48. package/dist/providers/googleVertex.d.ts +0 -1
  49. package/dist/providers/googleVertex.js +17 -24
  50. package/dist/providers/huggingFace.d.ts +0 -1
  51. package/dist/providers/huggingFace.js +0 -8
  52. package/dist/providers/litellm.d.ts +0 -1
  53. package/dist/providers/litellm.js +0 -8
  54. package/dist/providers/mistral.d.ts +9 -24
  55. package/dist/providers/mistral.js +44 -82
  56. package/dist/providers/ollama.d.ts +0 -1
  57. package/dist/providers/ollama.js +0 -12
  58. package/dist/providers/openAI.d.ts +2 -3
  59. package/dist/providers/openAI.js +12 -20
  60. package/dist/providers/openaiCompatible.d.ts +0 -1
  61. package/dist/providers/openaiCompatible.js +0 -8
  62. package/dist/utils/toolUtils.d.ts +32 -0
  63. package/dist/utils/toolUtils.js +60 -0
  64. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## [7.11.0](https://github.com/juspay/neurolink/compare/v7.10.3...v7.11.0) (2025-08-14)
2
+
3
+ ### Features
4
+
5
+ - **(providers):** consolidate provider logic to BaseProvider for consistency and performance ([a5da739](https://github.com/juspay/neurolink/commit/a5da73982523f4cee57bbdf108b54a339a62d9b3))
6
+
7
+ ## [7.10.3](https://github.com/juspay/neurolink/compare/v7.10.2...v7.10.3) (2025-08-13)
8
+
9
+ ### Bug Fixes
10
+
11
+ - **(ci):** make comment posting non-blocking for external contributor PRs ([f40b3f7](https://github.com/juspay/neurolink/commit/f40b3f75a8162df41461ef5ca1b2bb97d62719c2))
12
+
1
13
  ## [7.10.2](https://github.com/juspay/neurolink/compare/v7.10.1...v7.10.2) (2025-08-13)
2
14
 
3
15
  ### Bug Fixes
@@ -9,6 +9,7 @@ export interface NeuroLinkConfig {
9
9
  providers?: Record<string, ProviderConfig>;
10
10
  performance?: PerformanceConfig;
11
11
  analytics?: AnalyticsConfig;
12
+ tools?: ToolConfig;
12
13
  lastUpdated?: number;
13
14
  configVersion?: string;
14
15
  [key: string]: unknown;
@@ -90,6 +91,19 @@ export interface AnalyticsConfig {
90
91
  maxEntries?: number;
91
92
  };
92
93
  }
94
+ /**
95
+ * Tool configuration
96
+ */
97
+ export interface ToolConfig {
98
+ /** Whether built-in tools should be disabled */
99
+ disableBuiltinTools?: boolean;
100
+ /** Whether custom tools are allowed */
101
+ allowCustomTools?: boolean;
102
+ /** Maximum number of tools per provider */
103
+ maxToolsPerProvider?: number;
104
+ /** Whether MCP tools should be enabled */
105
+ enableMCPTools?: boolean;
106
+ }
93
107
  /**
94
108
  * Backup metadata information
95
109
  */
@@ -39,5 +39,11 @@ export const DEFAULT_CONFIG = {
39
39
  maxEntries: 10000,
40
40
  },
41
41
  },
42
+ tools: {
43
+ disableBuiltinTools: false,
44
+ allowCustomTools: true,
45
+ maxToolsPerProvider: 100,
46
+ enableMCPTools: true,
47
+ },
42
48
  configVersion: "3.0.1",
43
49
  };
@@ -38,346 +38,7 @@ export declare abstract class BaseProvider implements AIProvider {
38
38
  protected readonly modelName: string;
39
39
  protected readonly providerName: AIProviderName;
40
40
  protected readonly defaultTimeout: number;
41
- protected readonly directTools: {
42
- getCurrentTime: Tool<import("zod").ZodObject<{
43
- timezone: import("zod").ZodOptional<import("zod").ZodString>;
44
- }, "strip", import("zod").ZodTypeAny, {
45
- timezone?: string | undefined;
46
- }, {
47
- timezone?: string | undefined;
48
- }>, {
49
- success: boolean;
50
- time: string;
51
- timezone: string;
52
- iso: string;
53
- timestamp?: undefined;
54
- error?: undefined;
55
- } | {
56
- success: boolean;
57
- time: string;
58
- iso: string;
59
- timestamp: number;
60
- timezone?: undefined;
61
- error?: undefined;
62
- } | {
63
- success: boolean;
64
- error: string;
65
- time?: undefined;
66
- timezone?: undefined;
67
- iso?: undefined;
68
- timestamp?: undefined;
69
- }> & {
70
- execute: (args: {
71
- timezone?: string | undefined;
72
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
73
- success: boolean;
74
- time: string;
75
- timezone: string;
76
- iso: string;
77
- timestamp?: undefined;
78
- error?: undefined;
79
- } | {
80
- success: boolean;
81
- time: string;
82
- iso: string;
83
- timestamp: number;
84
- timezone?: undefined;
85
- error?: undefined;
86
- } | {
87
- success: boolean;
88
- error: string;
89
- time?: undefined;
90
- timezone?: undefined;
91
- iso?: undefined;
92
- timestamp?: undefined;
93
- }>;
94
- };
95
- readFile: Tool<import("zod").ZodObject<{
96
- path: import("zod").ZodString;
97
- }, "strip", import("zod").ZodTypeAny, {
98
- path: string;
99
- }, {
100
- path: string;
101
- }>, {
102
- success: boolean;
103
- error: string;
104
- content?: undefined;
105
- size?: undefined;
106
- path?: undefined;
107
- lastModified?: undefined;
108
- } | {
109
- success: boolean;
110
- content: string;
111
- size: number;
112
- path: string;
113
- lastModified: string;
114
- error?: undefined;
115
- } | {
116
- success: boolean;
117
- error: string;
118
- path: string;
119
- content?: undefined;
120
- size?: undefined;
121
- lastModified?: undefined;
122
- }> & {
123
- execute: (args: {
124
- path: string;
125
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
126
- success: boolean;
127
- error: string;
128
- content?: undefined;
129
- size?: undefined;
130
- path?: undefined;
131
- lastModified?: undefined;
132
- } | {
133
- success: boolean;
134
- content: string;
135
- size: number;
136
- path: string;
137
- lastModified: string;
138
- error?: undefined;
139
- } | {
140
- success: boolean;
141
- error: string;
142
- path: string;
143
- content?: undefined;
144
- size?: undefined;
145
- lastModified?: undefined;
146
- }>;
147
- };
148
- listDirectory: Tool<import("zod").ZodObject<{
149
- path: import("zod").ZodString;
150
- includeHidden: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
151
- }, "strip", import("zod").ZodTypeAny, {
152
- path: string;
153
- includeHidden: boolean;
154
- }, {
155
- path: string;
156
- includeHidden?: boolean | undefined;
157
- }>, {
158
- success: boolean;
159
- path: string;
160
- items: {
161
- name: string;
162
- type: string;
163
- size: number | undefined;
164
- lastModified: string;
165
- }[];
166
- count: number;
167
- error?: undefined;
168
- } | {
169
- success: boolean;
170
- error: string;
171
- path: string;
172
- items?: undefined;
173
- count?: undefined;
174
- }> & {
175
- execute: (args: {
176
- path: string;
177
- includeHidden: boolean;
178
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
179
- success: boolean;
180
- path: string;
181
- items: {
182
- name: string;
183
- type: string;
184
- size: number | undefined;
185
- lastModified: string;
186
- }[];
187
- count: number;
188
- error?: undefined;
189
- } | {
190
- success: boolean;
191
- error: string;
192
- path: string;
193
- items?: undefined;
194
- count?: undefined;
195
- }>;
196
- };
197
- calculateMath: Tool<import("zod").ZodObject<{
198
- expression: import("zod").ZodString;
199
- precision: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
200
- }, "strip", import("zod").ZodTypeAny, {
201
- expression: string;
202
- precision: number;
203
- }, {
204
- expression: string;
205
- precision?: number | undefined;
206
- }>, {
207
- success: boolean;
208
- error: string;
209
- expression?: undefined;
210
- result?: undefined;
211
- type?: undefined;
212
- } | {
213
- success: boolean;
214
- expression: string;
215
- result: any;
216
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
217
- error?: undefined;
218
- } | {
219
- success: boolean;
220
- error: string;
221
- expression: string;
222
- result?: undefined;
223
- type?: undefined;
224
- }> & {
225
- execute: (args: {
226
- expression: string;
227
- precision: number;
228
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
229
- success: boolean;
230
- error: string;
231
- expression?: undefined;
232
- result?: undefined;
233
- type?: undefined;
234
- } | {
235
- success: boolean;
236
- expression: string;
237
- result: any;
238
- type: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
239
- error?: undefined;
240
- } | {
241
- success: boolean;
242
- error: string;
243
- expression: string;
244
- result?: undefined;
245
- type?: undefined;
246
- }>;
247
- };
248
- writeFile: Tool<import("zod").ZodObject<{
249
- path: import("zod").ZodString;
250
- content: import("zod").ZodString;
251
- mode: import("zod").ZodDefault<import("zod").ZodEnum<["create", "overwrite", "append"]>>;
252
- }, "strip", import("zod").ZodTypeAny, {
253
- path: string;
254
- content: string;
255
- mode: "create" | "overwrite" | "append";
256
- }, {
257
- path: string;
258
- content: string;
259
- mode?: "create" | "overwrite" | "append" | undefined;
260
- }>, {
261
- success: boolean;
262
- error: string;
263
- path?: undefined;
264
- mode?: undefined;
265
- size?: undefined;
266
- written?: undefined;
267
- } | {
268
- success: boolean;
269
- path: string;
270
- mode: "create" | "overwrite" | "append";
271
- size: number;
272
- written: number;
273
- error?: undefined;
274
- } | {
275
- success: boolean;
276
- error: string;
277
- path: string;
278
- mode?: undefined;
279
- size?: undefined;
280
- written?: undefined;
281
- }> & {
282
- execute: (args: {
283
- path: string;
284
- content: string;
285
- mode: "create" | "overwrite" | "append";
286
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
287
- success: boolean;
288
- error: string;
289
- path?: undefined;
290
- mode?: undefined;
291
- size?: undefined;
292
- written?: undefined;
293
- } | {
294
- success: boolean;
295
- path: string;
296
- mode: "create" | "overwrite" | "append";
297
- size: number;
298
- written: number;
299
- error?: undefined;
300
- } | {
301
- success: boolean;
302
- error: string;
303
- path: string;
304
- mode?: undefined;
305
- size?: undefined;
306
- written?: undefined;
307
- }>;
308
- };
309
- searchFiles: Tool<import("zod").ZodObject<{
310
- directory: import("zod").ZodString;
311
- pattern: import("zod").ZodString;
312
- recursive: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
313
- }, "strip", import("zod").ZodTypeAny, {
314
- directory: string;
315
- pattern: string;
316
- recursive: boolean;
317
- }, {
318
- directory: string;
319
- pattern: string;
320
- recursive?: boolean | undefined;
321
- }>, {
322
- success: boolean;
323
- error: string;
324
- directory?: undefined;
325
- pattern?: undefined;
326
- matches?: undefined;
327
- count?: undefined;
328
- } | {
329
- success: boolean;
330
- directory: string;
331
- pattern: string;
332
- matches: {
333
- name: string;
334
- path: string;
335
- size: number;
336
- lastModified: string;
337
- }[];
338
- count: number;
339
- error?: undefined;
340
- } | {
341
- success: boolean;
342
- error: string;
343
- directory: string;
344
- pattern: string;
345
- matches?: undefined;
346
- count?: undefined;
347
- }> & {
348
- execute: (args: {
349
- directory: string;
350
- pattern: string;
351
- recursive: boolean;
352
- }, options: import("ai").ToolExecutionOptions) => PromiseLike<{
353
- success: boolean;
354
- error: string;
355
- directory?: undefined;
356
- pattern?: undefined;
357
- matches?: undefined;
358
- count?: undefined;
359
- } | {
360
- success: boolean;
361
- directory: string;
362
- pattern: string;
363
- matches: {
364
- name: string;
365
- path: string;
366
- size: number;
367
- lastModified: string;
368
- }[];
369
- count: number;
370
- error?: undefined;
371
- } | {
372
- success: boolean;
373
- error: string;
374
- directory: string;
375
- pattern: string;
376
- matches?: undefined;
377
- count?: undefined;
378
- }>;
379
- };
380
- };
41
+ protected readonly directTools: {};
381
42
  protected mcpTools?: Record<string, Tool>;
382
43
  protected sessionId?: string;
383
44
  protected userId?: string;
@@ -433,6 +94,50 @@ export declare abstract class BaseProvider implements AIProvider {
433
94
  * Provider-specific error handling
434
95
  */
435
96
  protected abstract handleProviderError(error: unknown): Error;
97
+ /**
98
+ * Execute operation with timeout and proper cleanup
99
+ * Consolidates identical timeout handling from 8/10 providers
100
+ */
101
+ protected executeWithTimeout<T>(operation: () => Promise<T>, options: {
102
+ timeout?: number | string;
103
+ operationType?: string;
104
+ }): Promise<T>;
105
+ /**
106
+ * Validate stream options - consolidates validation from 7/10 providers
107
+ */
108
+ protected validateStreamOptions(options: StreamOptions): void;
109
+ /**
110
+ * Create text stream transformation - consolidates identical logic from 7/10 providers
111
+ */
112
+ protected createTextStream(result: {
113
+ textStream: AsyncIterable<string>;
114
+ }): AsyncGenerator<{
115
+ content: string;
116
+ }>;
117
+ /**
118
+ * Create standardized stream result - consolidates result structure
119
+ */
120
+ protected createStreamResult(stream: AsyncGenerator<{
121
+ content: string;
122
+ }>, additionalProps?: Partial<StreamResult>): StreamResult;
123
+ /**
124
+ * Create stream analytics - consolidates analytics from 4/10 providers
125
+ */
126
+ protected createStreamAnalytics(result: UnknownRecord, startTime: number, options: StreamOptions): Promise<UnknownRecord | undefined>;
127
+ /**
128
+ * Handle common error patterns - consolidates error handling from multiple providers
129
+ */
130
+ protected handleCommonErrors(error: unknown): Error | null;
131
+ /**
132
+ * Set up tool executor for a provider to enable actual tool execution
133
+ * Consolidates identical setupToolExecutor logic from neurolink.ts (used in 4 places)
134
+ * @param sdk - The NeuroLinkSDK instance for tool execution
135
+ * @param functionTag - Function name for logging
136
+ */
137
+ setupToolExecutor(sdk: {
138
+ customTools: Map<string, unknown>;
139
+ executeTool: (toolName: string, params: unknown) => Promise<unknown>;
140
+ }, functionTag: string): void;
436
141
  protected normalizeTextOptions(optionsOrPrompt: TextGenerationOptions | string): TextGenerationOptions;
437
142
  protected normalizeStreamOptions(optionsOrPrompt: StreamOptions | string): StreamOptions;
438
143
  protected enhanceResult(result: EnhancedGenerateResult, options: TextGenerationOptions, startTime: number): Promise<EnhancedGenerateResult>;