@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
@@ -2,14 +2,14 @@ import type { ZodType, ZodTypeDef } from "zod";
2
2
  import { type Schema, type LanguageModelV1 } from "ai";
3
3
  import { AIProviderName } from "../core/types.js";
4
4
  import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
- import { BaseProvider } from "../core/baseProvider.js";
5
+ import { BaseProvider, type NeuroLinkSDK } from "../core/baseProvider.js";
6
6
  /**
7
7
  * OpenAI Provider v2 - BaseProvider Implementation
8
8
  * Migrated to use factory pattern with exact Google AI provider pattern
9
9
  */
10
10
  export declare class OpenAIProvider extends BaseProvider {
11
11
  private model;
12
- constructor(modelName?: string);
12
+ constructor(modelName?: string, sdk?: NeuroLinkSDK);
13
13
  protected getProviderName(): AIProviderName;
14
14
  protected getDefaultModel(): string;
15
15
  /**
@@ -23,6 +23,5 @@ export declare class OpenAIProvider extends BaseProvider {
23
23
  * and the migration guide in the project repository.
24
24
  */
25
25
  protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
26
- private validateStreamOptions;
27
26
  }
28
27
  export default OpenAIProvider;
@@ -4,7 +4,7 @@ import { AIProviderName } from "../core/types.js";
4
4
  import { BaseProvider } from "../core/baseProvider.js";
5
5
  import { logger } from "../utils/logger.js";
6
6
  import { createTimeoutController, TimeoutError, } from "../utils/timeout.js";
7
- import { DEFAULT_MAX_TOKENS } from "../core/constants.js";
7
+ import { DEFAULT_MAX_TOKENS, DEFAULT_MAX_STEPS } from "../core/constants.js";
8
8
  import { validateApiKey, createOpenAIConfig, getProviderModel, } from "../utils/providerConfig.js";
9
9
  import { streamAnalyticsCollector } from "../core/streamAnalytics.js";
10
10
  // Configuration helpers - now using consolidated utility
@@ -20,8 +20,8 @@ const getOpenAIModel = () => {
20
20
  */
21
21
  export class OpenAIProvider extends BaseProvider {
22
22
  model;
23
- constructor(modelName) {
24
- super(modelName, AIProviderName.OPENAI);
23
+ constructor(modelName, sdk) {
24
+ super(modelName || getOpenAIModel(), AIProviderName.OPENAI, sdk);
25
25
  // Set OpenAI API key as environment variable (required by @ai-sdk/openai)
26
26
  process.env.OPENAI_API_KEY = getOpenAIApiKey();
27
27
  // Initialize model
@@ -74,30 +74,30 @@ export class OpenAIProvider extends BaseProvider {
74
74
  const timeout = this.getTimeout(options);
75
75
  const timeoutController = createTimeoutController(timeout, this.providerName, "stream");
76
76
  try {
77
+ // Get tools consistently with generate method
78
+ const shouldUseTools = !options.disableTools && this.supportsTools();
79
+ const tools = shouldUseTools ? await this.getAllTools() : {};
77
80
  const result = await streamText({
78
81
  model: this.model,
79
82
  prompt: options.input.text,
80
83
  system: options.systemPrompt,
81
84
  temperature: options.temperature,
82
85
  maxTokens: options.maxTokens || DEFAULT_MAX_TOKENS,
83
- tools: options.tools,
84
- toolChoice: "auto",
86
+ tools,
87
+ maxSteps: options.maxSteps || DEFAULT_MAX_STEPS,
88
+ toolChoice: shouldUseTools ? "auto" : "none",
85
89
  abortSignal: timeoutController?.controller.signal,
86
90
  });
87
91
  timeoutController?.cleanup();
88
- // Transform stream to match StreamResult interface
89
- const transformedStream = async function* () {
90
- for await (const chunk of result.textStream) {
91
- yield { content: chunk };
92
- }
93
- };
92
+ // Transform stream to match StreamResult interface using BaseProvider method
93
+ const transformedStream = this.createTextStream(result);
94
94
  // Create analytics promise that resolves after stream completion
95
95
  const analyticsPromise = streamAnalyticsCollector.createAnalytics(this.providerName, this.modelName, result, Date.now() - startTime, {
96
96
  requestId: `openai-stream-${Date.now()}`,
97
97
  streamingMode: true,
98
98
  });
99
99
  return {
100
- stream: transformedStream(),
100
+ stream: transformedStream,
101
101
  provider: this.providerName,
102
102
  model: this.modelName,
103
103
  analytics: analyticsPromise,
@@ -112,14 +112,6 @@ export class OpenAIProvider extends BaseProvider {
112
112
  throw this.handleProviderError(error);
113
113
  }
114
114
  }
115
- // ===================
116
- // PRIVATE VALIDATION METHODS
117
- // ===================
118
- validateStreamOptions(options) {
119
- if (!options.input?.text || options.input.text.trim().length === 0) {
120
- throw new Error("Input text is required and cannot be empty");
121
- }
122
- }
123
115
  }
124
116
  // Export for factory registration
125
117
  export default OpenAIProvider;
@@ -45,5 +45,4 @@ export declare class OpenAICompatibleProvider extends BaseProvider {
45
45
  * Fallback models when discovery fails
46
46
  */
47
47
  private getFallbackModels;
48
- private validateStreamOptions;
49
48
  }
@@ -249,12 +249,4 @@ export class OpenAICompatibleProvider extends BaseProvider {
249
249
  "gemini-pro",
250
250
  ];
251
251
  }
252
- // ===================
253
- // PRIVATE VALIDATION METHODS
254
- // ===================
255
- validateStreamOptions(options) {
256
- if (!options.input?.text || options.input.text.trim().length === 0) {
257
- throw new Error("Input text is required and cannot be empty");
258
- }
259
- }
260
252
  }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Tool Utilities - Centralized tool configuration access
3
+ *
4
+ * Consolidates environment variable access to avoid scattered process.env calls
5
+ */
6
+ import type { ToolConfig } from "../config/types.js";
7
+ /**
8
+ * Check if built-in tools should be disabled
9
+ * Centralized function to replace direct process.env access
10
+ *
11
+ * @param toolConfig - Optional tool configuration (if available from config)
12
+ * @returns true if built-in tools should be disabled
13
+ */
14
+ export declare function shouldDisableBuiltinTools(toolConfig?: ToolConfig): boolean;
15
+ /**
16
+ * Check if custom tools should be allowed
17
+ * @param toolConfig - Optional tool configuration
18
+ * @returns true if custom tools should be allowed
19
+ */
20
+ export declare function shouldAllowCustomTools(toolConfig?: ToolConfig): boolean;
21
+ /**
22
+ * Check if MCP tools should be enabled
23
+ * @param toolConfig - Optional tool configuration
24
+ * @returns true if MCP tools should be enabled
25
+ */
26
+ export declare function shouldEnableMCPTools(toolConfig?: ToolConfig): boolean;
27
+ /**
28
+ * Get maximum tools per provider
29
+ * @param toolConfig - Optional tool configuration
30
+ * @returns maximum number of tools per provider
31
+ */
32
+ export declare function getMaxToolsPerProvider(toolConfig?: ToolConfig): number;
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Tool Utilities - Centralized tool configuration access
3
+ *
4
+ * Consolidates environment variable access to avoid scattered process.env calls
5
+ */
6
+ /**
7
+ * Check if built-in tools should be disabled
8
+ * Centralized function to replace direct process.env access
9
+ *
10
+ * @param toolConfig - Optional tool configuration (if available from config)
11
+ * @returns true if built-in tools should be disabled
12
+ */
13
+ export function shouldDisableBuiltinTools(toolConfig) {
14
+ // Priority: explicit config > environment variable > default (false)
15
+ if (toolConfig?.disableBuiltinTools !== undefined) {
16
+ return toolConfig.disableBuiltinTools;
17
+ }
18
+ // Single source of truth for environment variable access
19
+ return process.env.NEUROLINK_DISABLE_BUILTIN_TOOLS === "true";
20
+ }
21
+ /**
22
+ * Check if custom tools should be allowed
23
+ * @param toolConfig - Optional tool configuration
24
+ * @returns true if custom tools should be allowed
25
+ */
26
+ export function shouldAllowCustomTools(toolConfig) {
27
+ if (toolConfig?.allowCustomTools !== undefined) {
28
+ return toolConfig.allowCustomTools;
29
+ }
30
+ return process.env.NEUROLINK_DISABLE_CUSTOM_TOOLS !== "true";
31
+ }
32
+ /**
33
+ * Check if MCP tools should be enabled
34
+ * @param toolConfig - Optional tool configuration
35
+ * @returns true if MCP tools should be enabled
36
+ */
37
+ export function shouldEnableMCPTools(toolConfig) {
38
+ if (toolConfig?.enableMCPTools !== undefined) {
39
+ return toolConfig.enableMCPTools;
40
+ }
41
+ return process.env.NEUROLINK_DISABLE_MCP_TOOLS !== "true";
42
+ }
43
+ /**
44
+ * Get maximum tools per provider
45
+ * @param toolConfig - Optional tool configuration
46
+ * @returns maximum number of tools per provider
47
+ */
48
+ export function getMaxToolsPerProvider(toolConfig) {
49
+ if (toolConfig?.maxToolsPerProvider !== undefined) {
50
+ return toolConfig.maxToolsPerProvider;
51
+ }
52
+ const envMax = process.env.NEUROLINK_MAX_TOOLS_PER_PROVIDER;
53
+ if (envMax) {
54
+ const parsed = parseInt(envMax, 10);
55
+ if (!isNaN(parsed) && parsed > 0) {
56
+ return parsed;
57
+ }
58
+ }
59
+ return 100; // Default
60
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "7.10.2",
3
+ "version": "7.11.0",
4
4
  "description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
5
5
  "author": {
6
6
  "name": "Juspay Technologies",