@juspay/neurolink 7.29.1 → 7.29.3

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 (234) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cli/commands/config.d.ts +86 -86
  3. package/dist/cli/commands/mcp.js +64 -9
  4. package/dist/cli/commands/models.js +25 -21
  5. package/dist/cli/commands/ollama.js +2 -2
  6. package/dist/cli/factories/commandFactory.d.ts +9 -0
  7. package/dist/cli/factories/commandFactory.js +177 -83
  8. package/dist/cli/factories/ollamaCommandFactory.js +3 -1
  9. package/dist/cli/factories/sagemakerCommandFactory.js +3 -2
  10. package/dist/cli/index.d.ts +1 -1
  11. package/dist/cli/index.js +19 -11
  12. package/dist/cli/utils/envManager.js +5 -5
  13. package/dist/cli/utils/ollamaUtils.d.ts +12 -0
  14. package/dist/cli/utils/ollamaUtils.js +58 -42
  15. package/dist/config/configManager.js +5 -2
  16. package/dist/core/analytics.d.ts +2 -24
  17. package/dist/core/analytics.js +12 -17
  18. package/dist/core/baseProvider.d.ts +30 -1
  19. package/dist/core/baseProvider.js +180 -198
  20. package/dist/core/dynamicModels.d.ts +4 -4
  21. package/dist/core/dynamicModels.js +7 -7
  22. package/dist/core/evaluation.d.ts +9 -9
  23. package/dist/core/evaluation.js +117 -65
  24. package/dist/core/evaluationProviders.d.ts +18 -2
  25. package/dist/core/evaluationProviders.js +15 -13
  26. package/dist/core/factory.js +77 -4
  27. package/dist/core/modelConfiguration.d.ts +63 -0
  28. package/dist/core/modelConfiguration.js +354 -290
  29. package/dist/core/streamAnalytics.d.ts +10 -5
  30. package/dist/core/streamAnalytics.js +10 -10
  31. package/dist/core/types.d.ts +19 -109
  32. package/dist/core/types.js +13 -0
  33. package/dist/factories/providerFactory.js +4 -1
  34. package/dist/factories/providerRegistry.js +2 -2
  35. package/dist/index.d.ts +2 -1
  36. package/dist/lib/config/configManager.js +5 -2
  37. package/dist/lib/core/analytics.d.ts +2 -24
  38. package/dist/lib/core/analytics.js +12 -17
  39. package/dist/lib/core/baseProvider.d.ts +30 -1
  40. package/dist/lib/core/baseProvider.js +180 -198
  41. package/dist/lib/core/dynamicModels.js +7 -7
  42. package/dist/lib/core/evaluation.d.ts +9 -9
  43. package/dist/lib/core/evaluation.js +117 -65
  44. package/dist/lib/core/evaluationProviders.d.ts +18 -2
  45. package/dist/lib/core/evaluationProviders.js +15 -13
  46. package/dist/lib/core/factory.js +77 -4
  47. package/dist/lib/core/modelConfiguration.d.ts +63 -0
  48. package/dist/lib/core/modelConfiguration.js +354 -290
  49. package/dist/lib/core/streamAnalytics.d.ts +10 -5
  50. package/dist/lib/core/streamAnalytics.js +10 -10
  51. package/dist/lib/core/types.d.ts +19 -109
  52. package/dist/lib/core/types.js +13 -0
  53. package/dist/lib/factories/providerFactory.js +4 -1
  54. package/dist/lib/factories/providerRegistry.js +2 -2
  55. package/dist/lib/index.d.ts +2 -1
  56. package/dist/lib/mcp/externalServerManager.js +14 -6
  57. package/dist/lib/mcp/factory.js +1 -1
  58. package/dist/lib/mcp/flexibleToolValidator.d.ts +50 -0
  59. package/dist/lib/mcp/flexibleToolValidator.js +161 -0
  60. package/dist/lib/mcp/index.d.ts +1 -1
  61. package/dist/lib/mcp/index.js +1 -1
  62. package/dist/lib/mcp/mcpCircuitBreaker.js +5 -1
  63. package/dist/lib/mcp/mcpClientFactory.js +3 -0
  64. package/dist/lib/mcp/registry.d.ts +3 -3
  65. package/dist/lib/mcp/registry.js +3 -3
  66. package/dist/lib/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
  67. package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
  68. package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
  69. package/dist/lib/mcp/toolDiscoveryService.js +8 -2
  70. package/dist/lib/mcp/toolRegistry.d.ts +2 -2
  71. package/dist/lib/mcp/toolRegistry.js +29 -54
  72. package/dist/lib/middleware/builtin/analytics.js +4 -4
  73. package/dist/lib/middleware/builtin/guardrails.js +2 -2
  74. package/dist/lib/middleware/registry.js +11 -2
  75. package/dist/lib/models/modelRegistry.d.ts +1 -1
  76. package/dist/lib/models/modelRegistry.js +3 -3
  77. package/dist/lib/models/modelResolver.d.ts +1 -1
  78. package/dist/lib/models/modelResolver.js +2 -2
  79. package/dist/lib/neurolink.d.ts +118 -0
  80. package/dist/lib/neurolink.js +814 -952
  81. package/dist/lib/providers/amazonBedrock.d.ts +47 -6
  82. package/dist/lib/providers/amazonBedrock.js +282 -23
  83. package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
  84. package/dist/lib/providers/amazonSagemaker.js +12 -3
  85. package/dist/lib/providers/anthropic.d.ts +1 -1
  86. package/dist/lib/providers/anthropic.js +7 -6
  87. package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
  88. package/dist/lib/providers/anthropicBaseProvider.js +4 -3
  89. package/dist/lib/providers/aws/credentialProvider.d.ts +58 -0
  90. package/dist/lib/providers/aws/credentialProvider.js +267 -0
  91. package/dist/lib/providers/aws/credentialTester.d.ts +49 -0
  92. package/dist/lib/providers/aws/credentialTester.js +394 -0
  93. package/dist/lib/providers/azureOpenai.d.ts +1 -1
  94. package/dist/lib/providers/azureOpenai.js +1 -1
  95. package/dist/lib/providers/googleAiStudio.d.ts +1 -1
  96. package/dist/lib/providers/googleAiStudio.js +2 -2
  97. package/dist/lib/providers/googleVertex.d.ts +40 -0
  98. package/dist/lib/providers/googleVertex.js +330 -274
  99. package/dist/lib/providers/huggingFace.js +1 -1
  100. package/dist/lib/providers/mistral.d.ts +1 -1
  101. package/dist/lib/providers/mistral.js +2 -2
  102. package/dist/lib/providers/ollama.d.ts +4 -0
  103. package/dist/lib/providers/ollama.js +38 -18
  104. package/dist/lib/providers/openAI.d.ts +1 -1
  105. package/dist/lib/providers/openAI.js +2 -2
  106. package/dist/lib/providers/sagemaker/adaptive-semaphore.js +7 -4
  107. package/dist/lib/providers/sagemaker/client.js +13 -3
  108. package/dist/lib/providers/sagemaker/config.js +5 -1
  109. package/dist/lib/providers/sagemaker/detection.js +19 -9
  110. package/dist/lib/providers/sagemaker/errors.d.ts +8 -1
  111. package/dist/lib/providers/sagemaker/errors.js +103 -20
  112. package/dist/lib/providers/sagemaker/language-model.d.ts +3 -3
  113. package/dist/lib/providers/sagemaker/language-model.js +4 -4
  114. package/dist/lib/providers/sagemaker/parsers.js +14 -6
  115. package/dist/lib/providers/sagemaker/streaming.js +14 -3
  116. package/dist/lib/providers/sagemaker/types.d.ts +1 -1
  117. package/dist/lib/proxy/awsProxyIntegration.d.ts +23 -0
  118. package/dist/lib/proxy/awsProxyIntegration.js +285 -0
  119. package/dist/lib/proxy/proxyFetch.d.ts +9 -5
  120. package/dist/lib/proxy/proxyFetch.js +232 -98
  121. package/dist/lib/proxy/utils/noProxyUtils.d.ts +39 -0
  122. package/dist/lib/proxy/utils/noProxyUtils.js +149 -0
  123. package/dist/lib/sdk/toolRegistration.d.ts +1 -1
  124. package/dist/lib/types/cli.d.ts +80 -8
  125. package/dist/lib/types/contextTypes.js +2 -2
  126. package/dist/lib/types/generateTypes.d.ts +4 -6
  127. package/dist/lib/types/providers.d.ts +124 -19
  128. package/dist/lib/types/providers.js +6 -6
  129. package/dist/lib/types/streamTypes.d.ts +4 -6
  130. package/dist/lib/types/typeAliases.d.ts +1 -1
  131. package/dist/lib/utils/analyticsUtils.d.ts +33 -0
  132. package/dist/lib/utils/analyticsUtils.js +76 -0
  133. package/dist/lib/utils/errorHandling.js +4 -1
  134. package/dist/lib/utils/evaluationUtils.d.ts +27 -0
  135. package/dist/lib/utils/evaluationUtils.js +131 -0
  136. package/dist/lib/utils/optionsUtils.js +10 -1
  137. package/dist/lib/utils/performance.d.ts +1 -1
  138. package/dist/lib/utils/performance.js +15 -3
  139. package/dist/lib/utils/providerConfig.d.ts +1 -0
  140. package/dist/lib/utils/providerConfig.js +2 -1
  141. package/dist/lib/utils/providerHealth.d.ts +48 -0
  142. package/dist/lib/utils/providerHealth.js +221 -158
  143. package/dist/lib/utils/providerUtils.js +2 -2
  144. package/dist/lib/utils/timeout.js +8 -3
  145. package/dist/mcp/externalServerManager.js +14 -6
  146. package/dist/mcp/factory.js +1 -1
  147. package/dist/mcp/flexibleToolValidator.d.ts +50 -0
  148. package/dist/mcp/flexibleToolValidator.js +161 -0
  149. package/dist/mcp/index.d.ts +1 -1
  150. package/dist/mcp/index.js +1 -1
  151. package/dist/mcp/mcpCircuitBreaker.js +5 -1
  152. package/dist/mcp/mcpClientFactory.js +3 -0
  153. package/dist/mcp/registry.d.ts +3 -3
  154. package/dist/mcp/registry.js +3 -3
  155. package/dist/mcp/servers/aiProviders/aiAnalysisTools.js +5 -5
  156. package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +6 -6
  157. package/dist/mcp/servers/utilities/utilityServer.js +1 -1
  158. package/dist/mcp/toolDiscoveryService.js +8 -2
  159. package/dist/mcp/toolRegistry.d.ts +2 -2
  160. package/dist/mcp/toolRegistry.js +29 -54
  161. package/dist/middleware/builtin/analytics.js +4 -4
  162. package/dist/middleware/builtin/guardrails.js +2 -2
  163. package/dist/middleware/registry.js +11 -2
  164. package/dist/models/modelRegistry.d.ts +1 -1
  165. package/dist/models/modelRegistry.js +3 -3
  166. package/dist/models/modelResolver.d.ts +1 -1
  167. package/dist/models/modelResolver.js +2 -2
  168. package/dist/neurolink.d.ts +118 -0
  169. package/dist/neurolink.js +814 -952
  170. package/dist/providers/amazonBedrock.d.ts +47 -6
  171. package/dist/providers/amazonBedrock.js +282 -23
  172. package/dist/providers/amazonSagemaker.d.ts +1 -1
  173. package/dist/providers/amazonSagemaker.js +12 -3
  174. package/dist/providers/anthropic.d.ts +1 -1
  175. package/dist/providers/anthropic.js +7 -6
  176. package/dist/providers/anthropicBaseProvider.d.ts +1 -1
  177. package/dist/providers/anthropicBaseProvider.js +4 -3
  178. package/dist/providers/aws/credentialProvider.d.ts +58 -0
  179. package/dist/providers/aws/credentialProvider.js +267 -0
  180. package/dist/providers/aws/credentialTester.d.ts +49 -0
  181. package/dist/providers/aws/credentialTester.js +394 -0
  182. package/dist/providers/azureOpenai.d.ts +1 -1
  183. package/dist/providers/azureOpenai.js +1 -1
  184. package/dist/providers/googleAiStudio.d.ts +1 -1
  185. package/dist/providers/googleAiStudio.js +2 -2
  186. package/dist/providers/googleVertex.d.ts +40 -0
  187. package/dist/providers/googleVertex.js +330 -274
  188. package/dist/providers/huggingFace.js +1 -1
  189. package/dist/providers/mistral.d.ts +1 -1
  190. package/dist/providers/mistral.js +2 -2
  191. package/dist/providers/ollama.d.ts +4 -0
  192. package/dist/providers/ollama.js +38 -18
  193. package/dist/providers/openAI.d.ts +1 -1
  194. package/dist/providers/openAI.js +2 -2
  195. package/dist/providers/sagemaker/adaptive-semaphore.js +7 -4
  196. package/dist/providers/sagemaker/client.js +13 -3
  197. package/dist/providers/sagemaker/config.js +5 -1
  198. package/dist/providers/sagemaker/detection.js +19 -9
  199. package/dist/providers/sagemaker/errors.d.ts +8 -1
  200. package/dist/providers/sagemaker/errors.js +103 -20
  201. package/dist/providers/sagemaker/language-model.d.ts +3 -3
  202. package/dist/providers/sagemaker/language-model.js +4 -4
  203. package/dist/providers/sagemaker/parsers.js +14 -6
  204. package/dist/providers/sagemaker/streaming.js +14 -3
  205. package/dist/providers/sagemaker/types.d.ts +1 -1
  206. package/dist/proxy/awsProxyIntegration.d.ts +23 -0
  207. package/dist/proxy/awsProxyIntegration.js +285 -0
  208. package/dist/proxy/proxyFetch.d.ts +9 -5
  209. package/dist/proxy/proxyFetch.js +232 -98
  210. package/dist/proxy/utils/noProxyUtils.d.ts +39 -0
  211. package/dist/proxy/utils/noProxyUtils.js +149 -0
  212. package/dist/sdk/toolRegistration.d.ts +1 -1
  213. package/dist/types/cli.d.ts +80 -8
  214. package/dist/types/contextTypes.js +2 -2
  215. package/dist/types/generateTypes.d.ts +4 -6
  216. package/dist/types/providers.d.ts +124 -19
  217. package/dist/types/providers.js +6 -6
  218. package/dist/types/streamTypes.d.ts +4 -6
  219. package/dist/types/typeAliases.d.ts +1 -1
  220. package/dist/utils/analyticsUtils.d.ts +33 -0
  221. package/dist/utils/analyticsUtils.js +76 -0
  222. package/dist/utils/errorHandling.js +4 -1
  223. package/dist/utils/evaluationUtils.d.ts +27 -0
  224. package/dist/utils/evaluationUtils.js +131 -0
  225. package/dist/utils/optionsUtils.js +10 -1
  226. package/dist/utils/performance.d.ts +1 -1
  227. package/dist/utils/performance.js +15 -3
  228. package/dist/utils/providerConfig.d.ts +1 -0
  229. package/dist/utils/providerConfig.js +2 -1
  230. package/dist/utils/providerHealth.d.ts +48 -0
  231. package/dist/utils/providerHealth.js +221 -158
  232. package/dist/utils/providerUtils.js +2 -2
  233. package/dist/utils/timeout.js +8 -3
  234. package/package.json +5 -1
@@ -42,7 +42,7 @@ export class OptionsEnhancer {
42
42
  try {
43
43
  return new SharedArrayBuffer(4); // 4 bytes for Int32
44
44
  }
45
- catch (e) {
45
+ catch {
46
46
  // SharedArrayBuffer is defined but not usable (browser CORS headers not set)
47
47
  if (typeof logger !== "undefined" && logger?.warn) {
48
48
  logger.warn("[OptionsEnhancer] SharedArrayBuffer is defined but not usable. " +
@@ -304,6 +304,15 @@ export class OptionsEnhancer {
304
304
  }
305
305
  static applyLegacyMigration(options, enhancementOptions) {
306
306
  const legacyMigration = enhancementOptions.legacyMigration;
307
+ if (!legacyMigration) {
308
+ throw new Error("Legacy migration configuration is required");
309
+ }
310
+ if (!legacyMigration.legacyContext) {
311
+ throw new Error("Legacy context is required for migration");
312
+ }
313
+ if (!legacyMigration.domainType) {
314
+ throw new Error("Domain type is required for migration");
315
+ }
307
316
  // Convert legacy context to execution context
308
317
  const executionContext = ContextConverter.convertBusinessContext(legacyMigration.legacyContext, legacyMigration.domainType, {
309
318
  preserveLegacyFields: legacyMigration.preserveFields,
@@ -84,7 +84,7 @@ export declare class MemoryManager {
84
84
  /**
85
85
  * Decorator for tracking performance of async functions
86
86
  */
87
- export declare function trackPerformance(operationName: string): <T extends (...args: unknown[]) => Promise<unknown>>(target: unknown, propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
87
+ export declare function trackPerformance(operationName: string): <T extends (...args: unknown[]) => Promise<unknown>>(_target: unknown, _propertyName: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
88
88
  /**
89
89
  * Performance monitoring for CLI operations
90
90
  */
@@ -63,11 +63,20 @@ export class PerformanceTracker {
63
63
  return `${operationName}: No metrics available`;
64
64
  }
65
65
  const memoryMB = (bytes) => (bytes / 1024 / 1024).toFixed(1);
66
+ if (!metric.memoryDelta) {
67
+ return [
68
+ `${operationName}:`,
69
+ ` Duration: ${metric.duration}ms`,
70
+ ` Memory Delta: Not available`,
71
+ ].join("\n");
72
+ }
73
+ const signHeap = metric.memoryDelta.heapUsed >= 0 ? "+" : "-";
74
+ const signRss = metric.memoryDelta.rss >= 0 ? "+" : "-";
66
75
  return [
67
76
  `${operationName}:`,
68
77
  ` Duration: ${metric.duration}ms`,
69
- ` Memory Delta: +${memoryMB(metric.memoryDelta.heapUsed)}MB heap`,
70
- ` RSS Delta: +${memoryMB(metric.memoryDelta.rss)}MB`,
78
+ ` Memory Delta: ${signHeap}${memoryMB(Math.abs(metric.memoryDelta.heapUsed))}MB heap`,
79
+ ` RSS Delta: ${signRss}${memoryMB(Math.abs(metric.memoryDelta.rss))}MB`,
71
80
  ].join("\n");
72
81
  }
73
82
  }
@@ -142,8 +151,11 @@ export class MemoryManager {
142
151
  * Decorator for tracking performance of async functions
143
152
  */
144
153
  export function trackPerformance(operationName) {
145
- return function (target, propertyName, descriptor) {
154
+ return function (_target, _propertyName, descriptor) {
146
155
  const method = descriptor.value;
156
+ if (!method) {
157
+ throw new Error(`Method descriptor value is required for performance tracking`);
158
+ }
147
159
  descriptor.value = async function (...args) {
148
160
  globalTracker.start(operationName);
149
161
  try {
@@ -109,6 +109,7 @@ export declare function createGoogleAuthConfig(): ProviderConfigOptions;
109
109
  export declare function createAnthropicBaseConfig(): ProviderConfigOptions;
110
110
  /**
111
111
  * Gets AWS Region with default fallback
112
+ * Supports both AWS_REGION and AWS_DEFAULT_REGION for broader compatibility
112
113
  */
113
114
  export declare function getAWSRegion(): string;
114
115
  /**
@@ -359,9 +359,10 @@ export function createAnthropicBaseConfig() {
359
359
  // =============================================================================
360
360
  /**
361
361
  * Gets AWS Region with default fallback
362
+ * Supports both AWS_REGION and AWS_DEFAULT_REGION for broader compatibility
362
363
  */
363
364
  export function getAWSRegion() {
364
- return process.env.AWS_REGION || "us-east-1";
365
+ return (process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || "us-east-1");
365
366
  }
366
367
  /**
367
368
  * Gets AWS Session Token if available
@@ -72,6 +72,54 @@ export declare class ProviderHealthChecker {
72
72
  * Provider-specific configuration checks
73
73
  */
74
74
  private static checkProviderSpecificConfig;
75
+ /**
76
+ * Check Vertex AI configuration
77
+ */
78
+ private static checkVertexAIConfig;
79
+ /**
80
+ * Get Vertex AI project ID from environment variables
81
+ */
82
+ private static getVertexProjectId;
83
+ /**
84
+ * Check Vertex AI authentication
85
+ */
86
+ private static checkVertexAuthentication;
87
+ /**
88
+ * Check Google Application Credentials file
89
+ */
90
+ private static checkGoogleApplicationCredentials;
91
+ /**
92
+ * Check individual Google credentials
93
+ */
94
+ private static checkIndividualGoogleCredentials;
95
+ /**
96
+ * Check AWS Bedrock configuration
97
+ */
98
+ private static checkBedrockConfig;
99
+ /**
100
+ * Check AWS region configuration
101
+ */
102
+ private static checkAWSRegion;
103
+ /**
104
+ * Check AWS credentials
105
+ */
106
+ private static checkAWSCredentials;
107
+ /**
108
+ * Check Bedrock models
109
+ */
110
+ private static checkBedrockModels;
111
+ /**
112
+ * Check Bedrock endpoint
113
+ */
114
+ private static checkBedrockEndpoint;
115
+ /**
116
+ * Check Azure OpenAI configuration
117
+ */
118
+ private static checkAzureConfig;
119
+ /**
120
+ * Check Ollama configuration
121
+ */
122
+ private static checkOllamaConfig;
75
123
  /**
76
124
  * Get common models for a provider
77
125
  */
@@ -130,6 +130,14 @@ export class ProviderHealthChecker {
130
130
  */
131
131
  static async checkEnvironmentConfiguration(providerName, healthStatus) {
132
132
  const requiredEnvVars = this.getRequiredEnvironmentVariables(providerName);
133
+ logger.debug(`[ProviderHealthChecker] Checking environment configuration for ${providerName}`, {
134
+ requiredEnvVars,
135
+ presentEnvVars: requiredEnvVars.map((envVar) => ({
136
+ name: envVar,
137
+ present: !!process.env[envVar],
138
+ hasValue: !!(process.env[envVar] && process.env[envVar].trim() !== ""),
139
+ })),
140
+ });
133
141
  let allConfigured = true;
134
142
  const missingVars = [];
135
143
  for (const envVar of requiredEnvVars) {
@@ -140,6 +148,12 @@ export class ProviderHealthChecker {
140
148
  }
141
149
  }
142
150
  healthStatus.isConfigured = allConfigured;
151
+ logger.debug(`[ProviderHealthChecker] Environment configuration result for ${providerName}`, {
152
+ isConfigured: allConfigured,
153
+ missingVars,
154
+ totalRequired: requiredEnvVars.length,
155
+ totalMissing: missingVars.length,
156
+ });
143
157
  if (!allConfigured) {
144
158
  healthStatus.configurationIssues.push(`Missing required environment variables: ${missingVars.join(", ")}`);
145
159
  healthStatus.recommendations.push(`Set the following environment variables: ${missingVars.join(", ")}`);
@@ -211,6 +225,12 @@ export class ProviderHealthChecker {
211
225
  }
212
226
  return;
213
227
  }
228
+ // Providers that don't use API keys directly
229
+ if (providerName === AIProviderName.OLLAMA ||
230
+ providerName === AIProviderName.BEDROCK) {
231
+ healthStatus.hasApiKey = true;
232
+ return;
233
+ }
214
234
  // 🔧 STANDARD HANDLING FOR OTHER PROVIDERS
215
235
  const apiKeyVar = this.getApiKeyEnvironmentVariable(providerName);
216
236
  const apiKey = process.env[apiKeyVar];
@@ -342,7 +362,9 @@ export class ProviderHealthChecker {
342
362
  case AIProviderName.GOOGLE_AI:
343
363
  return ["GOOGLE_AI_API_KEY"];
344
364
  case AIProviderName.BEDROCK:
345
- return ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY", "AWS_REGION"];
365
+ // Bedrock credentials are resolved via AWS SDK default provider chain.
366
+ // Region/auth validated in provider-specific checks.
367
+ return [];
346
368
  case AIProviderName.AZURE:
347
369
  return ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"];
348
370
  case AIProviderName.OLLAMA:
@@ -423,169 +445,210 @@ export class ProviderHealthChecker {
423
445
  */
424
446
  static async checkProviderSpecificConfig(providerName, healthStatus) {
425
447
  switch (providerName) {
426
- case AIProviderName.VERTEX: {
427
- logger.debug("Starting Vertex AI health check", {
428
- providerName,
429
- });
430
- // Check for Google Cloud project ID (with fallbacks)
431
- const projectId = process.env.GOOGLE_PROJECT_ID ||
432
- process.env.GOOGLE_CLOUD_PROJECT_ID ||
433
- process.env.GOOGLE_VERTEX_PROJECT ||
434
- process.env.GOOGLE_CLOUD_PROJECT ||
435
- process.env.VERTEX_PROJECT_ID;
436
- logger.debug("Project ID validation", {
437
- hasProjectId: !!projectId,
438
- });
439
- if (!projectId) {
440
- healthStatus.configurationIssues.push("Google Cloud project ID not set");
441
- healthStatus.recommendations.push("Set one of: GOOGLE_VERTEX_PROJECT, GOOGLE_CLOUD_PROJECT_ID, GOOGLE_PROJECT_ID, or GOOGLE_CLOUD_PROJECT");
442
- }
443
- // Check for authentication with proper file existence validation
444
- // This aligns with the authentication logic fix in googleVertex.ts
445
- let hasValidAuth = false;
446
- logger.debug("Authentication validation starting", {
447
- hasGoogleApplicationCredentials: !!process.env.GOOGLE_APPLICATION_CREDENTIALS,
448
- });
449
- // Check for principal account authentication first (recommended for production)
450
- // BUT CRITICALLY: Also verify the file actually exists
451
- if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
452
- const credentialsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
453
- logger.debug("Checking GOOGLE_APPLICATION_CREDENTIALS file");
454
- // Check if the credentials file actually exists
455
- let fileExists = false;
456
- try {
457
- const { promises: fs } = await import("fs");
458
- try {
459
- await fs.access(credentialsPath);
460
- fileExists = true;
461
- }
462
- catch {
463
- fileExists = false;
464
- }
465
- logger.debug("File existence check completed", {
466
- fileExists,
467
- });
468
- }
469
- catch (error) {
470
- logger.debug("File existence check failed", {
471
- error: String(error),
472
- });
473
- healthStatus.warning = `Failed to check credentials file existence: ${error}`;
474
- fileExists = false;
475
- }
476
- if (fileExists) {
477
- // Validate file format
478
- const fileName = basename(credentialsPath);
479
- const jsonFilePattern = /\.json(\.\w+)?$/;
480
- if (!jsonFilePattern.test(fileName)) {
481
- healthStatus.warning =
482
- "GOOGLE_APPLICATION_CREDENTIALS should point to a JSON file (e.g., 'credentials.json' or 'key.json.backup')";
483
- }
484
- hasValidAuth = true;
485
- healthStatus.hasApiKey = true;
486
- logger.debug("GOOGLE_APPLICATION_CREDENTIALS file validated", {
487
- fileName,
488
- hasValidAuth,
489
- });
490
- }
491
- else {
492
- healthStatus.warning = `GOOGLE_APPLICATION_CREDENTIALS file does not exist: ${credentialsPath}`;
493
- logger.debug("GOOGLE_APPLICATION_CREDENTIALS file missing, falling back to individual env vars");
494
- // Fall through to check individual environment variables
495
- }
496
- }
497
- else {
498
- logger.debug("GOOGLE_APPLICATION_CREDENTIALS not set, checking individual env vars");
499
- }
500
- // Fallback to individual credentials for development and production
501
- // Enhanced to check ALL required fields from the .env file configuration
502
- if (!hasValidAuth) {
503
- const hasServiceAccountKey = !!process.env.GOOGLE_SERVICE_ACCOUNT_KEY;
504
- const hasIndividualCredentials = !!(process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
505
- process.env.GOOGLE_AUTH_PRIVATE_KEY);
506
- logger.debug("Individual credentials check", {
507
- hasServiceAccountKey,
508
- hasGoogleAuthClientEmail: !!process.env.GOOGLE_AUTH_CLIENT_EMAIL,
509
- hasGoogleAuthPrivateKey: !!process.env.GOOGLE_AUTH_PRIVATE_KEY,
510
- hasIndividualCredentials,
511
- });
512
- if (hasServiceAccountKey || hasIndividualCredentials) {
513
- hasValidAuth = true;
514
- healthStatus.hasApiKey = true;
515
- logger.debug("Individual credentials validated successfully", {
516
- hasServiceAccountKey,
517
- hasIndividualCredentials,
518
- hasValidAuth,
519
- });
520
- }
521
- else {
522
- logger.debug("Individual credentials validation failed", {
523
- hasServiceAccountKey,
524
- hasIndividualCredentials,
525
- });
526
- }
527
- }
528
- // Final validation
529
- if (!hasValidAuth) {
530
- healthStatus.configurationIssues.push("Google Cloud authentication not configured or credentials file missing");
531
- healthStatus.recommendations.push("Set either GOOGLE_APPLICATION_CREDENTIALS (valid file path), GOOGLE_SERVICE_ACCOUNT_KEY (base64), or both GOOGLE_AUTH_CLIENT_EMAIL and GOOGLE_AUTH_PRIVATE_KEY");
532
- logger.debug("Final auth validation FAILED", {
533
- hasValidAuth,
534
- });
535
- }
536
- else {
537
- logger.debug("Final auth validation SUCCESS", {
538
- hasValidAuth,
539
- });
540
- }
541
- // Mark as configured if we have both project ID and auth
542
- if (projectId && hasValidAuth) {
543
- healthStatus.isConfigured = true;
544
- logger.debug("Vertex AI health check PASSED", {
545
- hasProjectId: !!projectId,
546
- hasValidAuth,
547
- isConfigured: healthStatus.isConfigured,
548
- });
549
- }
550
- else {
551
- logger.debug("Vertex AI health check FAILED", {
552
- hasProjectId: !!projectId,
553
- hasValidAuth,
554
- isConfigured: healthStatus.isConfigured,
555
- });
556
- }
448
+ case AIProviderName.VERTEX:
449
+ await this.checkVertexAIConfig(healthStatus);
557
450
  break;
558
- }
559
451
  case AIProviderName.BEDROCK:
560
- // Check AWS region
561
- if (!process.env.AWS_REGION) {
562
- healthStatus.configurationIssues.push("AWS_REGION not set");
563
- healthStatus.recommendations.push("Set AWS_REGION (e.g., us-east-1)");
564
- }
452
+ await this.checkBedrockConfig(healthStatus);
565
453
  break;
566
- case AIProviderName.AZURE: {
567
- // Check Azure OpenAI endpoint
568
- const azureEndpoint = process.env.AZURE_OPENAI_ENDPOINT;
569
- if (azureEndpoint && !azureEndpoint.startsWith("https://")) {
570
- healthStatus.configurationIssues.push("Invalid AZURE_OPENAI_ENDPOINT format");
571
- healthStatus.recommendations.push("Set AZURE_OPENAI_ENDPOINT to a valid URL (e.g., https://your-resource.openai.azure.com/)");
572
- }
573
- // Check for deployment name
574
- if (!process.env.AZURE_OPENAI_DEPLOYMENT_NAME) {
575
- healthStatus.configurationIssues.push("AZURE_OPENAI_DEPLOYMENT_NAME not set");
576
- healthStatus.recommendations.push("Set AZURE_OPENAI_DEPLOYMENT_NAME to your deployment name");
577
- }
454
+ case AIProviderName.AZURE:
455
+ await this.checkAzureConfig(healthStatus);
578
456
  break;
579
- }
580
- case AIProviderName.OLLAMA: {
581
- // Check if custom endpoint is set
582
- const ollamaBase = process.env.OLLAMA_API_BASE || "http://localhost:11434";
583
- if (!ollamaBase.startsWith("http")) {
584
- healthStatus.configurationIssues.push("Invalid OLLAMA_API_BASE format");
585
- healthStatus.recommendations.push("Set OLLAMA_API_BASE to a valid URL (e.g., http://localhost:11434)");
586
- }
457
+ case AIProviderName.OLLAMA:
458
+ await this.checkOllamaConfig(healthStatus);
587
459
  break;
460
+ }
461
+ }
462
+ /**
463
+ * Check Vertex AI configuration
464
+ */
465
+ static async checkVertexAIConfig(healthStatus) {
466
+ logger.debug("Starting Vertex AI health check");
467
+ const projectId = this.getVertexProjectId();
468
+ if (!projectId) {
469
+ healthStatus.configurationIssues.push("Google Cloud project ID not set");
470
+ healthStatus.recommendations.push("Set one of: GOOGLE_VERTEX_PROJECT, GOOGLE_CLOUD_PROJECT_ID, GOOGLE_PROJECT_ID, or GOOGLE_CLOUD_PROJECT");
471
+ }
472
+ const hasValidAuth = await this.checkVertexAuthentication(healthStatus);
473
+ if (projectId && hasValidAuth) {
474
+ healthStatus.isConfigured = true;
475
+ logger.debug("Vertex AI health check PASSED");
476
+ }
477
+ else {
478
+ logger.debug("Vertex AI health check FAILED");
479
+ }
480
+ }
481
+ /**
482
+ * Get Vertex AI project ID from environment variables
483
+ */
484
+ static getVertexProjectId() {
485
+ return (process.env.GOOGLE_PROJECT_ID ||
486
+ process.env.GOOGLE_CLOUD_PROJECT_ID ||
487
+ process.env.GOOGLE_VERTEX_PROJECT ||
488
+ process.env.GOOGLE_CLOUD_PROJECT ||
489
+ process.env.VERTEX_PROJECT_ID);
490
+ }
491
+ /**
492
+ * Check Vertex AI authentication
493
+ */
494
+ static async checkVertexAuthentication(healthStatus) {
495
+ let hasValidAuth = false;
496
+ if (process.env.GOOGLE_APPLICATION_CREDENTIALS) {
497
+ hasValidAuth = await this.checkGoogleApplicationCredentials(healthStatus);
498
+ }
499
+ if (!hasValidAuth) {
500
+ hasValidAuth = this.checkIndividualGoogleCredentials(healthStatus);
501
+ }
502
+ if (!hasValidAuth) {
503
+ healthStatus.configurationIssues.push("Google Cloud authentication not configured or credentials file missing");
504
+ healthStatus.recommendations.push("Set either GOOGLE_APPLICATION_CREDENTIALS (valid file path), GOOGLE_SERVICE_ACCOUNT_KEY (base64), or both GOOGLE_AUTH_CLIENT_EMAIL and GOOGLE_AUTH_PRIVATE_KEY");
505
+ }
506
+ return hasValidAuth;
507
+ }
508
+ /**
509
+ * Check Google Application Credentials file
510
+ */
511
+ static async checkGoogleApplicationCredentials(healthStatus) {
512
+ const credentialsPath = process.env.GOOGLE_APPLICATION_CREDENTIALS;
513
+ if (!credentialsPath) {
514
+ healthStatus.warning =
515
+ "GOOGLE_APPLICATION_CREDENTIALS environment variable not set";
516
+ return false;
517
+ }
518
+ try {
519
+ const { promises: fs } = await import("fs");
520
+ await fs.access(credentialsPath);
521
+ const fileName = basename(credentialsPath);
522
+ const jsonFilePattern = /\.json(\.\w+)?$/;
523
+ if (!jsonFilePattern.test(fileName)) {
524
+ healthStatus.warning =
525
+ "GOOGLE_APPLICATION_CREDENTIALS should point to a JSON file";
588
526
  }
527
+ healthStatus.hasApiKey = true;
528
+ return true;
529
+ }
530
+ catch {
531
+ healthStatus.warning = `GOOGLE_APPLICATION_CREDENTIALS file does not exist: ${credentialsPath}`;
532
+ return false;
533
+ }
534
+ }
535
+ /**
536
+ * Check individual Google credentials
537
+ */
538
+ static checkIndividualGoogleCredentials(healthStatus) {
539
+ const hasServiceAccountKey = !!process.env.GOOGLE_SERVICE_ACCOUNT_KEY;
540
+ const hasIndividualCredentials = !!(process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
541
+ process.env.GOOGLE_AUTH_PRIVATE_KEY);
542
+ if (hasServiceAccountKey || hasIndividualCredentials) {
543
+ healthStatus.hasApiKey = true;
544
+ return true;
545
+ }
546
+ return false;
547
+ }
548
+ /**
549
+ * Check AWS Bedrock configuration
550
+ */
551
+ static async checkBedrockConfig(healthStatus) {
552
+ logger.debug("Starting AWS Bedrock comprehensive health check");
553
+ this.checkAWSRegion(healthStatus);
554
+ this.checkAWSCredentials(healthStatus);
555
+ this.checkBedrockModels(healthStatus);
556
+ this.checkBedrockEndpoint(healthStatus);
557
+ if (healthStatus.configurationIssues.length === 0) {
558
+ healthStatus.hasApiKey = true;
559
+ logger.debug("AWS Bedrock configuration appears valid");
560
+ }
561
+ }
562
+ /**
563
+ * Check AWS region configuration
564
+ */
565
+ static checkAWSRegion(healthStatus) {
566
+ const awsRegion = process.env.AWS_REGION;
567
+ const validBedrockRegions = [
568
+ "us-east-1",
569
+ "us-west-2",
570
+ "ap-southeast-1",
571
+ "ap-northeast-1",
572
+ "eu-central-1",
573
+ "eu-west-1",
574
+ "ap-south-1",
575
+ ];
576
+ if (!awsRegion) {
577
+ healthStatus.configurationIssues.push("AWS_REGION not set");
578
+ healthStatus.recommendations.push(`Set AWS_REGION to a Bedrock-supported region: ${validBedrockRegions.join(", ")}`);
579
+ }
580
+ else if (!validBedrockRegions.includes(awsRegion)) {
581
+ healthStatus.configurationIssues.push(`AWS_REGION '${awsRegion}' may not support all Bedrock models`);
582
+ healthStatus.recommendations.push(`Consider using a primary Bedrock region: ${validBedrockRegions.slice(0, 3).join(", ")}`);
583
+ }
584
+ }
585
+ /**
586
+ * Check AWS credentials
587
+ */
588
+ static checkAWSCredentials(healthStatus) {
589
+ const awsAccessKeyId = process.env.AWS_ACCESS_KEY_ID;
590
+ const awsSecretAccessKey = process.env.AWS_SECRET_ACCESS_KEY;
591
+ const awsProfile = process.env.AWS_PROFILE;
592
+ if (!awsAccessKeyId && !awsProfile) {
593
+ healthStatus.configurationIssues.push("No AWS credentials found");
594
+ healthStatus.recommendations.push("Set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY, or configure AWS_PROFILE");
595
+ }
596
+ else if (awsAccessKeyId && !awsSecretAccessKey) {
597
+ healthStatus.configurationIssues.push("AWS_ACCESS_KEY_ID set but AWS_SECRET_ACCESS_KEY missing");
598
+ healthStatus.recommendations.push("Set AWS_SECRET_ACCESS_KEY to match your AWS_ACCESS_KEY_ID");
599
+ }
600
+ }
601
+ /**
602
+ * Check Bedrock models
603
+ */
604
+ static checkBedrockModels(healthStatus) {
605
+ const bedrockModel = process.env.BEDROCK_MODEL || process.env.BEDROCK_MODEL_ID;
606
+ const supportedModels = [
607
+ "anthropic.claude-3-sonnet-20240229-v1:0",
608
+ "anthropic.claude-3-haiku-20240307-v1:0",
609
+ "anthropic.claude-3-opus-20240229-v1:0",
610
+ "anthropic.claude-v2:1",
611
+ "amazon.titan-text-express-v1",
612
+ ];
613
+ if (!bedrockModel) {
614
+ healthStatus.recommendations.push("Set BEDROCK_MODEL or BEDROCK_MODEL_ID for faster startup (e.g., anthropic.claude-3-sonnet-20240229-v1:0)");
615
+ }
616
+ else if (!supportedModels.includes(bedrockModel)) {
617
+ healthStatus.recommendations.push(`Consider using a popular Bedrock model: ${supportedModels.slice(0, 3).join(", ")}`);
618
+ }
619
+ }
620
+ /**
621
+ * Check Bedrock endpoint
622
+ */
623
+ static checkBedrockEndpoint(healthStatus) {
624
+ const bedrockEndpoint = process.env.BEDROCK_ENDPOINT_URL;
625
+ if (bedrockEndpoint && !bedrockEndpoint.startsWith("https://")) {
626
+ healthStatus.configurationIssues.push("BEDROCK_ENDPOINT_URL should use HTTPS");
627
+ healthStatus.recommendations.push("Update BEDROCK_ENDPOINT_URL to use HTTPS protocol");
628
+ }
629
+ }
630
+ /**
631
+ * Check Azure OpenAI configuration
632
+ */
633
+ static async checkAzureConfig(healthStatus) {
634
+ const azureEndpoint = process.env.AZURE_OPENAI_ENDPOINT;
635
+ if (azureEndpoint && !azureEndpoint.startsWith("https://")) {
636
+ healthStatus.configurationIssues.push("Invalid AZURE_OPENAI_ENDPOINT format");
637
+ healthStatus.recommendations.push("Set AZURE_OPENAI_ENDPOINT to a valid URL (e.g., https://your-resource.openai.azure.com/)");
638
+ }
639
+ if (!process.env.AZURE_OPENAI_DEPLOYMENT_NAME) {
640
+ healthStatus.configurationIssues.push("AZURE_OPENAI_DEPLOYMENT_NAME not set");
641
+ healthStatus.recommendations.push("Set AZURE_OPENAI_DEPLOYMENT_NAME to your deployment name");
642
+ }
643
+ }
644
+ /**
645
+ * Check Ollama configuration
646
+ */
647
+ static async checkOllamaConfig(healthStatus) {
648
+ const ollamaBase = process.env.OLLAMA_API_BASE || "http://localhost:11434";
649
+ if (!ollamaBase.startsWith("http")) {
650
+ healthStatus.configurationIssues.push("Invalid OLLAMA_API_BASE format");
651
+ healthStatus.recommendations.push("Set OLLAMA_API_BASE to a valid URL (e.g., http://localhost:11434)");
589
652
  }
590
653
  }
591
654
  /**
@@ -107,7 +107,7 @@ async function isProviderAvailable(providerName) {
107
107
  }
108
108
  return false;
109
109
  }
110
- catch (error) {
110
+ catch {
111
111
  return false;
112
112
  }
113
113
  }
@@ -116,7 +116,7 @@ async function isProviderAvailable(providerName) {
116
116
  await provider.generate({ prompt: "test", maxTokens: 1 });
117
117
  return true;
118
118
  }
119
- catch (error) {
119
+ catch {
120
120
  return false;
121
121
  }
122
122
  }
@@ -214,14 +214,17 @@ export class TimeoutManager {
214
214
  generateOperationId(operation) {
215
215
  return `${operation}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
216
216
  }
217
- createTimeoutPromise(timeoutMs, operationId) {
217
+ createTimeoutPromise(timeoutMs, _operationId) {
218
218
  let timer;
219
219
  const promise = new Promise((_, reject) => {
220
220
  timer = setTimeout(() => {
221
221
  reject(new TimeoutError(`Operation timeout after ${timeoutMs}ms`, timeoutMs));
222
222
  }, timeoutMs);
223
223
  });
224
- return { promise, timer: timer };
224
+ if (!timer) {
225
+ throw new Error("Failed to create timeout timer");
226
+ }
227
+ return { promise, timer };
225
228
  }
226
229
  registerTimeout(operationId, timer, controller, cleanup) {
227
230
  this.activeTimeouts.set(operationId, { timer, controller, cleanup });
@@ -291,7 +294,9 @@ export async function* withStreamingTimeout(generator, timeout, provider) {
291
294
  }
292
295
  }
293
296
  finally {
294
- clearTimeout(timeoutId);
297
+ if (timeoutId) {
298
+ clearTimeout(timeoutId);
299
+ }
295
300
  }
296
301
  }
297
302
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "7.29.1",
3
+ "version": "7.29.3",
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",
@@ -145,8 +145,12 @@
145
145
  "@ai-sdk/openai": "^1.0.0",
146
146
  "@ai-sdk/provider": "^1.1.3",
147
147
  "@ai-sdk/provider-utils": "^2.2.8",
148
+ "@aws-sdk/client-bedrock": "^3.876.0",
149
+ "@aws-sdk/client-bedrock-runtime": "^3.876.0",
148
150
  "@aws-sdk/client-sagemaker": "^3.862.0",
149
151
  "@aws-sdk/client-sagemaker-runtime": "^3.862.0",
152
+ "@aws-sdk/credential-provider-node": "^3.876.0",
153
+ "@aws-sdk/credential-providers": "^3.876.0",
150
154
  "@aws-sdk/types": "^3.862.0",
151
155
  "@google-cloud/vertexai": "^1.10.0",
152
156
  "@google/generative-ai": "^0.24.1",