@juspay/neurolink 5.3.0 → 6.1.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 (273) hide show
  1. package/CHANGELOG.md +83 -2
  2. package/dist/chat/client-utils.d.ts +3 -0
  3. package/dist/chat/client-utils.js +22 -5
  4. package/dist/chat/index.d.ts +4 -7
  5. package/dist/chat/index.js +0 -8
  6. package/dist/chat/session-storage.d.ts +2 -2
  7. package/dist/chat/session.d.ts +4 -3
  8. package/dist/chat/session.js +1 -1
  9. package/dist/chat/sse-handler.js +13 -21
  10. package/dist/chat/types.d.ts +3 -2
  11. package/dist/chat/websocket-chat-handler.d.ts +4 -3
  12. package/dist/chat/websocket-chat-handler.js +12 -12
  13. package/dist/cli/commands/config.d.ts +2 -2
  14. package/dist/cli/commands/mcp.d.ts +3 -2
  15. package/dist/cli/commands/mcp.js +39 -29
  16. package/dist/cli/commands/ollama.js +8 -4
  17. package/dist/cli/factories/command-factory.d.ts +2 -1
  18. package/dist/cli/index.js +22 -19
  19. package/dist/core/analytics.d.ts +3 -2
  20. package/dist/core/analytics.js +16 -7
  21. package/dist/core/base-provider.d.ts +35 -7
  22. package/dist/core/base-provider.js +36 -13
  23. package/dist/core/defaults.d.ts +2 -1
  24. package/dist/core/evaluation.d.ts +4 -4
  25. package/dist/core/evaluation.js +17 -7
  26. package/dist/core/factory.d.ts +3 -2
  27. package/dist/core/service-registry.d.ts +4 -4
  28. package/dist/core/types.d.ts +11 -4
  29. package/dist/factories/compatibility-factory.d.ts +16 -1
  30. package/dist/factories/compatibility-factory.js +3 -1
  31. package/dist/factories/provider-factory.d.ts +5 -4
  32. package/dist/factories/provider-factory.js +15 -24
  33. package/dist/factories/provider-generate-factory.js +26 -20
  34. package/dist/lib/chat/client-utils.d.ts +3 -0
  35. package/dist/lib/chat/client-utils.js +22 -5
  36. package/dist/lib/chat/index.d.ts +4 -7
  37. package/dist/lib/chat/index.js +0 -8
  38. package/dist/lib/chat/session-storage.d.ts +2 -2
  39. package/dist/lib/chat/session.d.ts +4 -3
  40. package/dist/lib/chat/session.js +1 -1
  41. package/dist/lib/chat/sse-handler.js +13 -21
  42. package/dist/lib/chat/types.d.ts +3 -2
  43. package/dist/lib/chat/websocket-chat-handler.d.ts +4 -3
  44. package/dist/lib/chat/websocket-chat-handler.js +12 -12
  45. package/dist/lib/core/analytics.d.ts +3 -2
  46. package/dist/lib/core/analytics.js +16 -7
  47. package/dist/lib/core/base-provider.d.ts +35 -7
  48. package/dist/lib/core/base-provider.js +36 -13
  49. package/dist/lib/core/defaults.d.ts +2 -1
  50. package/dist/lib/core/evaluation.d.ts +4 -4
  51. package/dist/lib/core/evaluation.js +17 -7
  52. package/dist/lib/core/factory.d.ts +3 -2
  53. package/dist/lib/core/service-registry.d.ts +4 -4
  54. package/dist/lib/core/types.d.ts +11 -4
  55. package/dist/lib/factories/compatibility-factory.d.ts +16 -1
  56. package/dist/lib/factories/compatibility-factory.js +3 -1
  57. package/dist/lib/factories/provider-factory.d.ts +5 -4
  58. package/dist/lib/factories/provider-factory.js +15 -24
  59. package/dist/lib/factories/provider-generate-factory.js +26 -20
  60. package/dist/lib/mcp/adapters/plugin-bridge.d.ts +5 -4
  61. package/dist/lib/mcp/adapters/plugin-bridge.js +13 -6
  62. package/dist/lib/mcp/client.d.ts +2 -1
  63. package/dist/lib/mcp/client.js +12 -10
  64. package/dist/lib/mcp/context-manager.d.ts +1 -1
  65. package/dist/lib/mcp/contracts/mcp-contract.d.ts +15 -8
  66. package/dist/lib/mcp/core/plugin-manager.d.ts +3 -2
  67. package/dist/lib/mcp/core/plugin-manager.js +1 -1
  68. package/dist/lib/mcp/demo/plugin-demo.js +3 -1
  69. package/dist/lib/mcp/dynamic-chain-executor.d.ts +64 -40
  70. package/dist/lib/mcp/dynamic-chain-executor.js +3 -3
  71. package/dist/lib/mcp/dynamic-orchestrator.d.ts +14 -8
  72. package/dist/lib/mcp/ecosystem.d.ts +4 -4
  73. package/dist/lib/mcp/error-manager.d.ts +2 -2
  74. package/dist/lib/mcp/error-recovery.d.ts +4 -3
  75. package/dist/lib/mcp/external-client.d.ts +1 -1
  76. package/dist/lib/mcp/external-client.js +14 -10
  77. package/dist/lib/mcp/external-manager.d.ts +3 -3
  78. package/dist/lib/mcp/external-manager.js +9 -3
  79. package/dist/lib/mcp/factory.d.ts +7 -7
  80. package/dist/lib/mcp/function-calling.d.ts +3 -2
  81. package/dist/lib/mcp/health-monitor.d.ts +2 -1
  82. package/dist/lib/mcp/health-monitor.js +16 -7
  83. package/dist/lib/mcp/index.d.ts +5 -5
  84. package/dist/lib/mcp/initialize-tools.d.ts +2 -1
  85. package/dist/lib/mcp/initialize-tools.js +10 -2
  86. package/dist/lib/mcp/manager.d.ts +2 -1
  87. package/dist/lib/mcp/neurolink-mcp-client.js +1 -1
  88. package/dist/lib/mcp/orchestrator.d.ts +13 -12
  89. package/dist/lib/mcp/orchestrator.js +10 -8
  90. package/dist/lib/mcp/plugin-manager.js +4 -2
  91. package/dist/lib/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  92. package/dist/lib/mcp/plugins/core/filesystem-mcp.js +5 -2
  93. package/dist/lib/mcp/plugins/filesystem-mcp.d.ts +2 -1
  94. package/dist/lib/mcp/registry.d.ts +2 -1
  95. package/dist/lib/mcp/registry.js +2 -1
  96. package/dist/lib/mcp/security-manager.d.ts +4 -2
  97. package/dist/lib/mcp/servers/agent/direct-tools-server.js +18 -6
  98. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  99. package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  100. package/dist/lib/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  101. package/dist/lib/mcp/servers/ai-providers/ai-core-server.js +15 -133
  102. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  103. package/dist/lib/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  104. package/dist/lib/mcp/session-manager.d.ts +4 -3
  105. package/dist/lib/mcp/session-persistence.js +5 -2
  106. package/dist/lib/mcp/tool-integration.d.ts +3 -2
  107. package/dist/lib/mcp/tool-integration.js +3 -1
  108. package/dist/lib/mcp/tool-registry.d.ts +18 -1
  109. package/dist/lib/mcp/tool-registry.js +11 -8
  110. package/dist/lib/mcp/transport-manager.d.ts +2 -1
  111. package/dist/lib/mcp/transport-manager.js +5 -1
  112. package/dist/lib/mcp/unified-mcp.d.ts +5 -5
  113. package/dist/lib/mcp/unified-registry.d.ts +18 -2
  114. package/dist/lib/mcp/unified-registry.js +52 -3
  115. package/dist/lib/neurolink.d.ts +2 -2
  116. package/dist/lib/neurolink.js +40 -15
  117. package/dist/lib/providers/amazon-bedrock.d.ts +1 -1
  118. package/dist/lib/providers/amazon-bedrock.js +8 -7
  119. package/dist/lib/providers/analytics-helper.d.ts +8 -23
  120. package/dist/lib/providers/analytics-helper.js +95 -33
  121. package/dist/lib/providers/anthropic-baseprovider.d.ts +3 -3
  122. package/dist/lib/providers/anthropic-baseprovider.js +6 -5
  123. package/dist/lib/providers/anthropic.d.ts +2 -2
  124. package/dist/lib/providers/anthropic.js +11 -4
  125. package/dist/lib/providers/azure-openai.d.ts +5 -4
  126. package/dist/lib/providers/azure-openai.js +10 -4
  127. package/dist/lib/providers/function-calling-provider.d.ts +2 -2
  128. package/dist/lib/providers/function-calling-provider.js +1 -1
  129. package/dist/lib/providers/google-ai-studio.d.ts +2 -2
  130. package/dist/lib/providers/google-ai-studio.js +9 -3
  131. package/dist/lib/providers/google-vertex.d.ts +2 -2
  132. package/dist/lib/providers/google-vertex.js +18 -12
  133. package/dist/lib/providers/huggingFace.d.ts +1 -1
  134. package/dist/lib/providers/huggingFace.js +8 -4
  135. package/dist/lib/providers/mcp-provider.d.ts +3 -3
  136. package/dist/lib/providers/mistral.d.ts +34 -27
  137. package/dist/lib/providers/mistral.js +115 -107
  138. package/dist/lib/providers/ollama.d.ts +2 -1
  139. package/dist/lib/providers/ollama.js +43 -3
  140. package/dist/lib/providers/openAI.d.ts +1 -1
  141. package/dist/lib/providers/openAI.js +8 -4
  142. package/dist/lib/proxy/proxy-fetch.js +3 -2
  143. package/dist/lib/sdk/tool-extension.d.ts +12 -12
  144. package/dist/lib/sdk/tool-extension.js +2 -1
  145. package/dist/lib/sdk/tool-registration.d.ts +16 -12
  146. package/dist/lib/sdk/tool-registration.js +3 -2
  147. package/dist/lib/services/types.d.ts +5 -4
  148. package/dist/lib/services/websocket/websocket-server.d.ts +1 -1
  149. package/dist/lib/services/websocket/websocket-server.js +1 -1
  150. package/dist/lib/telemetry/telemetry-service.js +1 -1
  151. package/dist/lib/types/cli.d.ts +247 -0
  152. package/dist/lib/types/cli.js +22 -0
  153. package/dist/lib/types/common.d.ts +76 -0
  154. package/dist/lib/types/common.js +52 -0
  155. package/dist/lib/types/generate-types.d.ts +6 -6
  156. package/dist/lib/types/index.d.ts +12 -0
  157. package/dist/lib/types/index.js +12 -0
  158. package/dist/lib/types/mcp-types.d.ts +7 -7
  159. package/dist/lib/types/providers.d.ts +158 -0
  160. package/dist/lib/types/providers.js +23 -0
  161. package/dist/lib/types/stream-types.d.ts +4 -3
  162. package/dist/lib/types/tools.d.ts +154 -0
  163. package/dist/lib/types/tools.js +24 -0
  164. package/dist/lib/utils/logger.d.ts +5 -5
  165. package/dist/lib/utils/provider-validation.d.ts +2 -1
  166. package/dist/mcp/adapters/plugin-bridge.d.ts +5 -4
  167. package/dist/mcp/adapters/plugin-bridge.js +13 -6
  168. package/dist/mcp/client.d.ts +2 -1
  169. package/dist/mcp/client.js +12 -10
  170. package/dist/mcp/context-manager.d.ts +1 -1
  171. package/dist/mcp/contracts/mcp-contract.d.ts +15 -8
  172. package/dist/mcp/core/plugin-manager.d.ts +3 -2
  173. package/dist/mcp/core/plugin-manager.js +1 -1
  174. package/dist/mcp/demo/plugin-demo.js +3 -1
  175. package/dist/mcp/dynamic-chain-executor.d.ts +64 -40
  176. package/dist/mcp/dynamic-chain-executor.js +3 -3
  177. package/dist/mcp/dynamic-orchestrator.d.ts +14 -8
  178. package/dist/mcp/dynamic-orchestrator.js +1 -1
  179. package/dist/mcp/ecosystem.d.ts +4 -4
  180. package/dist/mcp/error-manager.d.ts +2 -2
  181. package/dist/mcp/error-recovery.d.ts +4 -3
  182. package/dist/mcp/external-client.d.ts +1 -1
  183. package/dist/mcp/external-client.js +14 -10
  184. package/dist/mcp/external-manager.d.ts +3 -3
  185. package/dist/mcp/external-manager.js +9 -3
  186. package/dist/mcp/factory.d.ts +7 -7
  187. package/dist/mcp/function-calling.d.ts +3 -2
  188. package/dist/mcp/health-monitor.d.ts +2 -1
  189. package/dist/mcp/health-monitor.js +16 -7
  190. package/dist/mcp/index.d.ts +5 -5
  191. package/dist/mcp/initialize-tools.d.ts +2 -1
  192. package/dist/mcp/initialize-tools.js +10 -2
  193. package/dist/mcp/manager.d.ts +2 -1
  194. package/dist/mcp/neurolink-mcp-client.js +1 -1
  195. package/dist/mcp/orchestrator.d.ts +13 -12
  196. package/dist/mcp/orchestrator.js +10 -8
  197. package/dist/mcp/plugin-manager.js +4 -2
  198. package/dist/mcp/plugins/core/filesystem-mcp.d.ts +3 -2
  199. package/dist/mcp/plugins/core/filesystem-mcp.js +5 -2
  200. package/dist/mcp/plugins/filesystem-mcp.d.ts +2 -1
  201. package/dist/mcp/registry.d.ts +2 -1
  202. package/dist/mcp/registry.js +2 -1
  203. package/dist/mcp/security-manager.d.ts +4 -2
  204. package/dist/mcp/servers/agent/direct-tools-server.js +19 -6
  205. package/dist/mcp/servers/ai-providers/ai-analysis-tools.d.ts +1 -16
  206. package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +21 -17
  207. package/dist/mcp/servers/ai-providers/ai-core-server.d.ts +2 -2
  208. package/dist/mcp/servers/ai-providers/ai-core-server.js +15 -132
  209. package/dist/mcp/servers/ai-providers/ai-workflow-tools.d.ts +1 -97
  210. package/dist/mcp/servers/ai-providers/ai-workflow-tools.js +18 -18
  211. package/dist/mcp/session-manager.d.ts +4 -3
  212. package/dist/mcp/session-persistence.js +5 -2
  213. package/dist/mcp/tool-integration.d.ts +3 -2
  214. package/dist/mcp/tool-integration.js +3 -1
  215. package/dist/mcp/tool-registry.d.ts +18 -1
  216. package/dist/mcp/tool-registry.js +11 -8
  217. package/dist/mcp/transport-manager.d.ts +2 -1
  218. package/dist/mcp/transport-manager.js +5 -1
  219. package/dist/mcp/unified-mcp.d.ts +5 -5
  220. package/dist/mcp/unified-registry.d.ts +18 -2
  221. package/dist/mcp/unified-registry.js +52 -3
  222. package/dist/neurolink.d.ts +2 -2
  223. package/dist/neurolink.js +40 -15
  224. package/dist/providers/amazon-bedrock.d.ts +1 -1
  225. package/dist/providers/amazon-bedrock.js +8 -7
  226. package/dist/providers/analytics-helper.d.ts +8 -23
  227. package/dist/providers/analytics-helper.js +95 -33
  228. package/dist/providers/anthropic-baseprovider.d.ts +3 -3
  229. package/dist/providers/anthropic-baseprovider.js +6 -5
  230. package/dist/providers/anthropic.d.ts +2 -2
  231. package/dist/providers/anthropic.js +11 -4
  232. package/dist/providers/azure-openai.d.ts +5 -4
  233. package/dist/providers/azure-openai.js +10 -4
  234. package/dist/providers/function-calling-provider.d.ts +2 -2
  235. package/dist/providers/function-calling-provider.js +1 -1
  236. package/dist/providers/google-ai-studio.d.ts +2 -2
  237. package/dist/providers/google-ai-studio.js +9 -3
  238. package/dist/providers/google-vertex.d.ts +2 -2
  239. package/dist/providers/google-vertex.js +18 -12
  240. package/dist/providers/huggingFace.d.ts +1 -1
  241. package/dist/providers/huggingFace.js +8 -4
  242. package/dist/providers/mcp-provider.d.ts +3 -3
  243. package/dist/providers/mistral.d.ts +34 -27
  244. package/dist/providers/mistral.js +116 -108
  245. package/dist/providers/ollama.d.ts +2 -1
  246. package/dist/providers/ollama.js +43 -3
  247. package/dist/providers/openAI.d.ts +1 -1
  248. package/dist/providers/openAI.js +8 -4
  249. package/dist/proxy/proxy-fetch.js +3 -2
  250. package/dist/sdk/tool-extension.d.ts +12 -12
  251. package/dist/sdk/tool-extension.js +2 -1
  252. package/dist/sdk/tool-registration.d.ts +16 -12
  253. package/dist/sdk/tool-registration.js +3 -2
  254. package/dist/services/types.d.ts +5 -4
  255. package/dist/services/websocket/websocket-server.d.ts +1 -1
  256. package/dist/services/websocket/websocket-server.js +2 -1
  257. package/dist/telemetry/telemetry-service.js +1 -1
  258. package/dist/types/cli.d.ts +247 -0
  259. package/dist/types/cli.js +22 -0
  260. package/dist/types/common.d.ts +76 -0
  261. package/dist/types/common.js +52 -0
  262. package/dist/types/generate-types.d.ts +6 -6
  263. package/dist/types/index.d.ts +12 -0
  264. package/dist/types/index.js +12 -0
  265. package/dist/types/mcp-types.d.ts +7 -7
  266. package/dist/types/providers.d.ts +158 -0
  267. package/dist/types/providers.js +23 -0
  268. package/dist/types/stream-types.d.ts +4 -3
  269. package/dist/types/tools.d.ts +154 -0
  270. package/dist/types/tools.js +25 -0
  271. package/dist/utils/logger.d.ts +5 -5
  272. package/dist/utils/provider-validation.d.ts +2 -1
  273. package/package.json +2 -1
@@ -2,7 +2,17 @@
2
2
  * Unified MCP Registry - Combines Multiple Registration Sources
3
3
  */
4
4
  import type { DiscoveredMCP, ExecutionContext } from "./contracts/mcp-contract.js";
5
+ import type { JsonValue } from "../types/common.js";
5
6
  import type { DiscoveryOptions } from "./auto-discovery.js";
7
+ interface MCPServerConfig {
8
+ name: string;
9
+ id?: string;
10
+ command: string;
11
+ args?: string[];
12
+ env?: Record<string, string>;
13
+ transport?: string;
14
+ [key: string]: JsonValue | undefined;
15
+ }
6
16
  import { MCPToolRegistry, type ToolInfo } from "./tool-registry.js";
7
17
  import { Client } from "@modelcontextprotocol/sdk/client/index.js";
8
18
  import { ErrorManager } from "./error-manager.js";
@@ -53,7 +63,7 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
53
63
  /**
54
64
  * Get manual servers
55
65
  */
56
- getManualServers(): Map<string, any>;
66
+ getManualServers(): Map<string, MCPServerConfig>;
57
67
  /**
58
68
  * List all tools from all registered plugins
59
69
  */
@@ -73,7 +83,7 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
73
83
  /**
74
84
  * Register a manual server
75
85
  */
76
- registerManualServer(id: string, server: any): void;
86
+ registerManualServer(id: string, server: MCPServerConfig): void;
77
87
  /**
78
88
  * Get registry statistics (override parent method)
79
89
  */
@@ -142,8 +152,14 @@ export declare class UnifiedMCPRegistry extends MCPToolRegistry {
142
152
  * Clear all registries and close active connections asynchronously
143
153
  */
144
154
  clearAsync(): Promise<void>;
155
+ /**
156
+ * Convert unknown arguments to JsonValue for CLI compatibility
157
+ * Attempts to serialize complex types to JSON-safe format
158
+ */
159
+ private toJsonValue;
145
160
  }
146
161
  /**
147
162
  * Default unified registry instance
148
163
  */
149
164
  export declare const unifiedRegistry: UnifiedMCPRegistry;
165
+ export {};
@@ -284,7 +284,25 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
284
284
  unifiedRegistryLogger.debug(`Trying tool ${toolName} on server ${serverId}`);
285
285
  // Import the executeMCPTool function
286
286
  const { executeMCPTool } = await import("../../cli/commands/mcp.js");
287
- const result = await executeMCPTool(serverConfig, toolName, args || {});
287
+ const typedServerConfig = serverConfig;
288
+ const mcpServerConfig = {
289
+ name: serverId,
290
+ command: (typeof typedServerConfig.command === "string"
291
+ ? typedServerConfig.command
292
+ : "npx"),
293
+ args: (Array.isArray(typedServerConfig.args)
294
+ ? typedServerConfig.args
295
+ : []),
296
+ env: (typeof typedServerConfig.env === "object" &&
297
+ typedServerConfig.env
298
+ ? typedServerConfig.env
299
+ : {}),
300
+ cwd: typeof typedServerConfig.cwd === "string"
301
+ ? typedServerConfig.cwd
302
+ : undefined,
303
+ transport: typedServerConfig.transport || "stdio",
304
+ };
305
+ const result = await executeMCPTool(mcpServerConfig, toolName, this.toJsonValue(args || {}));
288
306
  // Convert to ToolResult format
289
307
  const toolResult = {
290
308
  success: true,
@@ -349,7 +367,8 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
349
367
  const bySource = {};
350
368
  const byType = {};
351
369
  for (const plugin of plugins) {
352
- const source = plugin.source || "unknown";
370
+ const source = plugin.source ||
371
+ "unknown";
353
372
  bySource[source] = (bySource[source] || 0) + 1;
354
373
  // Extract type from name or metadata
355
374
  const type = plugin.metadata.name.split("/")[1]?.split("-")[0] || "unknown";
@@ -388,7 +407,11 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
388
407
  };
389
408
  // Register in internal registry
390
409
  this.register(serverMeta);
391
- this.manualServers.set(serverId, config);
410
+ this.manualServers.set(serverId, {
411
+ ...config,
412
+ name: serverId,
413
+ command: config.command || "npx",
414
+ });
392
415
  this.availableServers.add(serverId);
393
416
  // Establish actual connection to make server immediately reachable
394
417
  try {
@@ -482,6 +505,32 @@ export class UnifiedMCPRegistry extends MCPToolRegistry {
482
505
  // Clear registries without attempting to close connections again
483
506
  this.clearRegistriesOnly();
484
507
  }
508
+ /**
509
+ * Convert unknown arguments to JsonValue for CLI compatibility
510
+ * Attempts to serialize complex types to JSON-safe format
511
+ */
512
+ toJsonValue(args) {
513
+ try {
514
+ // First try to use it directly if it's already a JsonValue
515
+ if (args === null ||
516
+ typeof args === "string" ||
517
+ typeof args === "number" ||
518
+ typeof args === "boolean") {
519
+ return args;
520
+ }
521
+ // For objects and arrays, try JSON round-trip to ensure serialization
522
+ if (typeof args === "object") {
523
+ return JSON.parse(JSON.stringify(args));
524
+ }
525
+ // For other types, convert to string
526
+ return String(args);
527
+ }
528
+ catch (error) {
529
+ // If serialization fails, return empty object as fallback
530
+ unifiedRegistryLogger.warn("Failed to convert args to JsonValue, using empty object:", error);
531
+ return {};
532
+ }
533
+ }
485
534
  }
486
535
  /**
487
536
  * Default unified registry instance
@@ -36,7 +36,7 @@ export interface MCPServerInfo {
36
36
  source: string;
37
37
  status: "connected" | "discovered" | "failed";
38
38
  hasServer: boolean;
39
- metadata?: any;
39
+ metadata?: unknown;
40
40
  }
41
41
  export declare class NeuroLink {
42
42
  private mcpInitialized;
@@ -132,7 +132,7 @@ export declare class NeuroLink {
132
132
  * @param options - Execution options
133
133
  * @returns Tool execution result
134
134
  */
135
- executeTool<T = any>(toolName: string, params?: any, options?: {
135
+ executeTool<T = unknown>(toolName: string, params?: unknown, options?: {
136
136
  timeout?: number;
137
137
  }): Promise<T>;
138
138
  /**
@@ -112,20 +112,45 @@ export class NeuroLink {
112
112
  : undefined,
113
113
  responseTime: textResult.responseTime,
114
114
  toolsUsed: textResult.toolsUsed,
115
- toolExecutions: textResult.toolExecutions?.map((te) => ({
116
- name: te.toolName || te.name || "",
117
- input: te.input || {},
118
- output: te.output || te.result,
119
- duration: te.executionTime || te.duration || 0,
120
- })),
115
+ toolExecutions: textResult.toolExecutions?.map((te) => {
116
+ const teRecord = te;
117
+ return {
118
+ name: te.toolName || teRecord.name || "",
119
+ input: teRecord.input ||
120
+ teRecord.args ||
121
+ {},
122
+ output: teRecord.output ||
123
+ teRecord.result ||
124
+ (te.success ? "success" : "failed"),
125
+ duration: te.executionTime || teRecord.duration || 0,
126
+ };
127
+ }),
121
128
  enhancedWithTools: textResult.enhancedWithTools,
122
- availableTools: textResult.availableTools?.map((tool) => ({
123
- name: tool.name || "",
124
- description: tool.description || "",
125
- parameters: tool.parameters || {},
126
- })),
129
+ availableTools: textResult.availableTools?.map((tool) => {
130
+ const toolRecord = tool;
131
+ return {
132
+ name: tool.name || "",
133
+ description: tool.description || "",
134
+ parameters: toolRecord.parameters ||
135
+ toolRecord.schema ||
136
+ {},
137
+ };
138
+ }),
127
139
  analytics: textResult.analytics,
128
- evaluation: textResult.evaluation,
140
+ evaluation: textResult.evaluation
141
+ ? {
142
+ ...textResult.evaluation,
143
+ isOffTopic: textResult.evaluation
144
+ .isOffTopic ?? false,
145
+ alertSeverity: textResult.evaluation.alertSeverity ?? "none",
146
+ reasoning: textResult.evaluation.reasoning ??
147
+ "No evaluation provided",
148
+ evaluationModel: textResult.evaluation
149
+ .evaluationModel ?? "unknown",
150
+ evaluationTime: textResult.evaluation
151
+ .evaluationTime ?? Date.now(),
152
+ }
153
+ : undefined,
129
154
  };
130
155
  return generateResult;
131
156
  }
@@ -213,9 +238,9 @@ export class NeuroLink {
213
238
  try {
214
239
  const allTools = await toolRegistry.listTools();
215
240
  availableTools = allTools.map((tool) => ({
216
- name: tool.name,
241
+ name: tool.name || "Unknown",
217
242
  description: tool.description || "No description available",
218
- server: tool.server,
243
+ server: tool.server || "Unknown",
219
244
  category: tool.category,
220
245
  }));
221
246
  }
@@ -245,7 +270,7 @@ export class NeuroLink {
245
270
  toolsUsed: [],
246
271
  enhancedWithTools: true,
247
272
  availableTools: availableTools.length > 0 ? availableTools : undefined,
248
- // 🔧 FIX: Include analytics and evaluation from BaseProvider
273
+ // Include analytics and evaluation from BaseProvider
249
274
  analytics: result.analytics,
250
275
  evaluation: result.evaluation,
251
276
  };
@@ -26,7 +26,7 @@ export declare class AmazonBedrockProvider extends BaseProvider {
26
26
  */
27
27
  protected getAISDKModel(): LanguageModelV1;
28
28
  protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
29
- protected handleProviderError(error: any): Error;
29
+ protected handleProviderError(error: unknown): Error;
30
30
  private validateStreamOptions;
31
31
  }
32
32
  export default AmazonBedrockProvider;
@@ -112,19 +112,20 @@ export class AmazonBedrockProvider extends BaseProvider {
112
112
  }
113
113
  }
114
114
  handleProviderError(error) {
115
- if (error.name === "TimeoutError") {
115
+ if (error instanceof Error && error.name === "TimeoutError") {
116
116
  return new TimeoutError(`Amazon Bedrock request timed out. Consider increasing timeout or using a lighter model.`, this.defaultTimeout);
117
117
  }
118
- if (error.message?.includes("InvalidRequestException")) {
119
- return new Error(`❌ Amazon Bedrock Request Error\n\nThe request was invalid: ${error.message}\n\n🔧 Common Solutions:\n1. Check your model ID format\n2. Verify your request parameters\n3. Ensure your AWS account has Bedrock access`);
118
+ const errorMessage = error instanceof Error ? error.message : String(error);
119
+ if (errorMessage.includes("InvalidRequestException")) {
120
+ return new Error(`❌ Amazon Bedrock Request Error\n\nThe request was invalid: ${errorMessage}\n\n🔧 Common Solutions:\n1. Check your model ID format\n2. Verify your request parameters\n3. Ensure your AWS account has Bedrock access`);
120
121
  }
121
- if (error.message?.includes("AccessDeniedException")) {
122
+ if (errorMessage.includes("AccessDeniedException")) {
122
123
  return new Error(`❌ Amazon Bedrock Access Denied\n\nYour AWS credentials don't have permission to access Bedrock.\n\n🔧 Required Steps:\n1. Ensure your IAM user has bedrock:InvokeModel permission\n2. Check if Bedrock is available in your region\n3. Verify model access is enabled in Bedrock console`);
123
124
  }
124
- if (error.message?.includes("ValidationException")) {
125
- return new Error(`❌ Amazon Bedrock Validation Error\n\n${error.message}\n\n🔧 Check:\n1. Model ID format (should be ARN or model identifier)\n2. Request parameters are within limits\n3. Region configuration is correct`);
125
+ if (errorMessage.includes("ValidationException")) {
126
+ return new Error(`❌ Amazon Bedrock Validation Error\n\n${errorMessage}\n\n🔧 Check:\n1. Model ID format (should be ARN or model identifier)\n2. Request parameters are within limits\n3. Region configuration is correct`);
126
127
  }
127
- return new Error(`❌ Amazon Bedrock Provider Error\n\n${error.message || "Unknown error occurred"}\n\n🔧 Troubleshooting:\n1. Check AWS credentials and permissions\n2. Verify model availability\n3. Check network connectivity`);
128
+ return new Error(`❌ Amazon Bedrock Provider Error\n\n${errorMessage || "Unknown error occurred"}\n\n🔧 Troubleshooting:\n1. Check AWS credentials and permissions\n2. Verify model availability\n3. Check network connectivity`);
128
129
  }
129
130
  validateStreamOptions(options) {
130
131
  if (!options.input?.text?.trim()) {
@@ -3,18 +3,9 @@
3
3
  * Ensures consistent analytics data format across providers
4
4
  * Integrates with Universal Evaluation System
5
5
  */
6
- export interface AnalyticsData {
7
- provider: string;
8
- model: string;
9
- tokens: {
10
- input: number;
11
- output: number;
12
- total: number;
13
- };
14
- cost?: number;
15
- responseTime: number;
16
- timestamp: string;
17
- context?: Record<string, any>;
6
+ import type { UnknownRecord } from "../types/common.js";
7
+ import type { AnalyticsData as CoreAnalyticsData } from "../core/types.js";
8
+ export interface AnalyticsData extends CoreAnalyticsData {
18
9
  evaluation?: {
19
10
  relevanceScore: number;
20
11
  accuracyScore: number;
@@ -24,30 +15,24 @@ export interface AnalyticsData {
24
15
  evaluationTime?: number;
25
16
  evaluationAttempt?: number;
26
17
  };
27
- costDetails?: {
28
- inputCost: number;
29
- outputCost: number;
30
- evaluationCost?: number;
31
- totalCost: number;
32
- currency: string;
33
- };
18
+ costDetails?: UnknownRecord;
34
19
  }
35
20
  /**
36
21
  * Create standardized analytics data from provider response
37
22
  */
38
- export declare function createAnalytics(provider: string, model: string, result: any, responseTime: number, context?: Record<string, any>): AnalyticsData;
23
+ export declare function createAnalytics(provider: string, model: string, result: unknown, responseTime: number, context?: Record<string, unknown>): AnalyticsData;
39
24
  /**
40
25
  * Create enhanced analytics data with accurate cost calculations (async version)
41
26
  */
42
- export declare function createEnhancedAnalytics(provider: string, model: string, result: any, responseTime: number, context?: Record<string, any>): Promise<AnalyticsData>;
27
+ export declare function createEnhancedAnalytics(provider: string, model: string, result: unknown, responseTime: number, context?: Record<string, unknown>): Promise<AnalyticsData>;
43
28
  /**
44
29
  * Calculate enhanced cost details using provider configurations
45
30
  */
46
31
  export declare function calculateEnhancedCost(provider: string, inputTokens: number, outputTokens: number): Promise<{
47
- costDetails: any;
32
+ costDetails: UnknownRecord;
48
33
  estimatedCost: number;
49
34
  }>;
50
35
  /**
51
36
  * Enhance analytics with evaluation data
52
37
  */
53
- export declare function enhanceAnalyticsWithEvaluation(analytics: AnalyticsData, evaluationResult: any): AnalyticsData;
38
+ export declare function enhanceAnalyticsWithEvaluation(analytics: AnalyticsData, evaluationResult: UnknownRecord): AnalyticsData;
@@ -3,23 +3,43 @@
3
3
  * Ensures consistent analytics data format across providers
4
4
  * Integrates with Universal Evaluation System
5
5
  */
6
+ // Type guard for checking if an unknown value is a number
7
+ function isNumber(value) {
8
+ return typeof value === "number" && !isNaN(value);
9
+ }
10
+ // Type guard for checking if an unknown value is an object
11
+ function isRecord(value) {
12
+ return typeof value === "object" && value !== null && !Array.isArray(value);
13
+ }
6
14
  /**
7
15
  * Create standardized analytics data from provider response
8
16
  */
9
17
  export function createAnalytics(provider, model, result, responseTime, context) {
10
18
  // Handle different token usage formats across providers
11
- const tokenUsage = result.usage || {};
19
+ const tokenUsage = result?.usage || {};
12
20
  // Standardize token field names across providers
13
- const inputTokens = tokenUsage.promptTokens ||
14
- tokenUsage.input_tokens ||
15
- tokenUsage.inputTokens ||
21
+ const inputTokens = (typeof tokenUsage.promptTokens === "number"
22
+ ? tokenUsage.promptTokens
23
+ : 0) ||
24
+ (typeof tokenUsage.input_tokens === "number"
25
+ ? tokenUsage.input_tokens
26
+ : 0) ||
27
+ (typeof tokenUsage.inputTokens === "number" ? tokenUsage.inputTokens : 0) ||
16
28
  0;
17
- const outputTokens = tokenUsage.completionTokens ||
18
- tokenUsage.output_tokens ||
19
- tokenUsage.outputTokens ||
29
+ const outputTokens = (typeof tokenUsage.completionTokens === "number"
30
+ ? tokenUsage.completionTokens
31
+ : 0) ||
32
+ (typeof tokenUsage.output_tokens === "number"
33
+ ? tokenUsage.output_tokens
34
+ : 0) ||
35
+ (typeof tokenUsage.outputTokens === "number"
36
+ ? tokenUsage.outputTokens
37
+ : 0) ||
20
38
  0;
21
- const totalTokens = tokenUsage.totalTokens ||
22
- tokenUsage.total_tokens ||
39
+ const totalTokens = (typeof tokenUsage.totalTokens === "number" ? tokenUsage.totalTokens : 0) ||
40
+ (typeof tokenUsage.total_tokens === "number"
41
+ ? tokenUsage.total_tokens
42
+ : 0) ||
23
43
  inputTokens + outputTokens ||
24
44
  0;
25
45
  // Simple cost estimation for synchronous use
@@ -35,7 +55,7 @@ export function createAnalytics(provider, model, result, responseTime, context)
35
55
  cost: estimatedCost,
36
56
  responseTime,
37
57
  timestamp: new Date().toISOString(),
38
- context,
58
+ context: context,
39
59
  };
40
60
  }
41
61
  /**
@@ -43,18 +63,30 @@ export function createAnalytics(provider, model, result, responseTime, context)
43
63
  */
44
64
  export async function createEnhancedAnalytics(provider, model, result, responseTime, context) {
45
65
  // Handle different token usage formats across providers
46
- const tokenUsage = result.usage || {};
66
+ const tokenUsage = result?.usage || {};
47
67
  // Standardize token field names across providers
48
- const inputTokens = tokenUsage.promptTokens ||
49
- tokenUsage.input_tokens ||
50
- tokenUsage.inputTokens ||
68
+ const inputTokens = (typeof tokenUsage.promptTokens === "number"
69
+ ? tokenUsage.promptTokens
70
+ : 0) ||
71
+ (typeof tokenUsage.input_tokens === "number"
72
+ ? tokenUsage.input_tokens
73
+ : 0) ||
74
+ (typeof tokenUsage.inputTokens === "number" ? tokenUsage.inputTokens : 0) ||
51
75
  0;
52
- const outputTokens = tokenUsage.completionTokens ||
53
- tokenUsage.output_tokens ||
54
- tokenUsage.outputTokens ||
76
+ const outputTokens = (typeof tokenUsage.completionTokens === "number"
77
+ ? tokenUsage.completionTokens
78
+ : 0) ||
79
+ (typeof tokenUsage.output_tokens === "number"
80
+ ? tokenUsage.output_tokens
81
+ : 0) ||
82
+ (typeof tokenUsage.outputTokens === "number"
83
+ ? tokenUsage.outputTokens
84
+ : 0) ||
55
85
  0;
56
- const totalTokens = tokenUsage.totalTokens ||
57
- tokenUsage.total_tokens ||
86
+ const totalTokens = (typeof tokenUsage.totalTokens === "number" ? tokenUsage.totalTokens : 0) ||
87
+ (typeof tokenUsage.total_tokens === "number"
88
+ ? tokenUsage.total_tokens
89
+ : 0) ||
58
90
  inputTokens + outputTokens ||
59
91
  0;
60
92
  // Enhanced cost calculation using provider configuration
@@ -70,7 +102,7 @@ export async function createEnhancedAnalytics(provider, model, result, responseT
70
102
  cost: estimatedCost,
71
103
  responseTime,
72
104
  timestamp: new Date().toISOString(),
73
- context,
105
+ context: context,
74
106
  costDetails,
75
107
  };
76
108
  }
@@ -127,27 +159,57 @@ export async function calculateEnhancedCost(provider, inputTokens, outputTokens)
127
159
  * Enhance analytics with evaluation data
128
160
  */
129
161
  export function enhanceAnalyticsWithEvaluation(analytics, evaluationResult) {
162
+ // Helper function to safely extract number values with fallback
163
+ const getNumberValue = (obj, ...keys) => {
164
+ for (const key of keys) {
165
+ const value = obj[key];
166
+ if (isNumber(value)) {
167
+ return value;
168
+ }
169
+ }
170
+ return 1; // Default minimum score
171
+ };
172
+ // Helper function to safely extract evaluation config cost
173
+ const getEvaluationCost = (obj) => {
174
+ const evaluationConfig = obj.evaluationConfig;
175
+ if (isRecord(evaluationConfig)) {
176
+ const costEstimate = evaluationConfig.costEstimate;
177
+ return isNumber(costEstimate) ? costEstimate : 0;
178
+ }
179
+ return 0;
180
+ };
181
+ // Helper function to safely get existing total cost
182
+ const getExistingTotalCost = (costDetails) => {
183
+ if (!costDetails) {
184
+ return 0;
185
+ }
186
+ const totalCost = costDetails.totalCost;
187
+ return isNumber(totalCost) ? totalCost : 0;
188
+ };
189
+ const evaluationCost = getEvaluationCost(evaluationResult);
130
190
  return {
131
191
  ...analytics,
132
192
  evaluation: {
133
- // FIX: Use correct field names and ensure minimum score of 1
134
- relevanceScore: evaluationResult.relevance || evaluationResult.relevanceScore || 1,
135
- accuracyScore: evaluationResult.accuracy || evaluationResult.accuracyScore || 1,
136
- completenessScore: evaluationResult.completeness ||
137
- evaluationResult.completenessScore ||
138
- 1,
139
- overall: evaluationResult.overall || 1,
140
- evaluationProvider: evaluationResult.evaluationProvider,
141
- evaluationTime: evaluationResult.evaluationTime,
142
- evaluationAttempt: evaluationResult.evaluationAttempt,
193
+ relevanceScore: getNumberValue(evaluationResult, "relevance", "relevanceScore"),
194
+ accuracyScore: getNumberValue(evaluationResult, "accuracy", "accuracyScore"),
195
+ completenessScore: getNumberValue(evaluationResult, "completeness", "completenessScore"),
196
+ overall: getNumberValue(evaluationResult, "overall"),
197
+ evaluationProvider: typeof evaluationResult.evaluationProvider === "string"
198
+ ? evaluationResult.evaluationProvider
199
+ : undefined,
200
+ evaluationTime: isNumber(evaluationResult.evaluationTime)
201
+ ? evaluationResult.evaluationTime
202
+ : undefined,
203
+ evaluationAttempt: isNumber(evaluationResult.evaluationAttempt)
204
+ ? evaluationResult.evaluationAttempt
205
+ : undefined,
143
206
  },
144
207
  // Add evaluation cost if available
145
208
  costDetails: analytics.costDetails
146
209
  ? {
147
210
  ...analytics.costDetails,
148
- evaluationCost: evaluationResult.evaluationConfig?.costEstimate || 0,
149
- totalCost: (analytics.costDetails.totalCost || 0) +
150
- (evaluationResult.evaluationConfig?.costEstimate || 0),
211
+ evaluationCost,
212
+ totalCost: getExistingTotalCost(analytics.costDetails) + evaluationCost,
151
213
  }
152
214
  : undefined,
153
215
  };
@@ -1,5 +1,5 @@
1
1
  import type { ZodType, ZodTypeDef } from "zod";
2
- import { type Schema } from "ai";
2
+ import { type Schema, type LanguageModelV1 } from "ai";
3
3
  import type { AIProviderName } from "../core/types.js";
4
4
  import type { StreamOptions, StreamResult } from "../types/stream-types.js";
5
5
  import { BaseProvider } from "../core/base-provider.js";
@@ -15,8 +15,8 @@ export declare class AnthropicProviderV2 extends BaseProvider {
15
15
  /**
16
16
  * Returns the Vercel AI SDK model instance for Anthropic
17
17
  */
18
- protected getAISDKModel(): any;
19
- protected handleProviderError(error: any): Error;
18
+ protected getAISDKModel(): LanguageModelV1;
19
+ protected handleProviderError(error: unknown): Error;
20
20
  private getApiKey;
21
21
  protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
22
22
  }
@@ -38,16 +38,17 @@ export class AnthropicProviderV2 extends BaseProvider {
38
38
  if (error instanceof TimeoutError) {
39
39
  return new Error(`Anthropic request timed out: ${error.message}`);
40
40
  }
41
- if (error?.status === 401) {
41
+ const errorWithStatus = error;
42
+ if (errorWithStatus?.status === 401) {
42
43
  return new Error("Invalid Anthropic API key. Please check your ANTHROPIC_API_KEY environment variable.");
43
44
  }
44
- if (error?.status === 429) {
45
+ if (errorWithStatus?.status === 429) {
45
46
  return new Error("Anthropic rate limit exceeded. Please try again later.");
46
47
  }
47
- if (error?.status === 400) {
48
- return new Error(`Anthropic bad request: ${error?.message || "Invalid request parameters"}`);
48
+ if (errorWithStatus?.status === 400) {
49
+ return new Error(`Anthropic bad request: ${errorWithStatus?.message || "Invalid request parameters"}`);
49
50
  }
50
- return new Error(`Anthropic error: ${error?.message || "Unknown error"}`);
51
+ return new Error(`Anthropic error: ${errorWithStatus?.message || String(error) || "Unknown error"}`);
51
52
  }
52
53
  getApiKey() {
53
54
  const apiKey = process.env.ANTHROPIC_API_KEY;
@@ -9,14 +9,14 @@ import { BaseProvider } from "../core/base-provider.js";
9
9
  */
10
10
  export declare class AnthropicProvider extends BaseProvider {
11
11
  private model;
12
- constructor(modelName?: string, sdk?: any);
12
+ constructor(modelName?: string, sdk?: unknown);
13
13
  protected getProviderName(): AIProviderName;
14
14
  protected getDefaultModel(): string;
15
15
  /**
16
16
  * Returns the Vercel AI SDK model instance for Anthropic
17
17
  */
18
18
  protected getAISDKModel(): LanguageModelV1;
19
- protected handleProviderError(error: any): Error;
19
+ protected handleProviderError(error: unknown): Error;
20
20
  protected executeStream(options: StreamOptions, analysisSchema?: ZodType<unknown, ZodTypeDef, unknown> | Schema<unknown>): Promise<StreamResult>;
21
21
  isAvailable(): Promise<boolean>;
22
22
  getModel(): LanguageModelV1;
@@ -47,14 +47,21 @@ export class AnthropicProvider extends BaseProvider {
47
47
  if (error instanceof TimeoutError) {
48
48
  return new Error(`Anthropic request timed out: ${error.message}`);
49
49
  }
50
- if (error?.message?.includes("API_KEY_INVALID") ||
51
- error?.message?.includes("Invalid API key")) {
50
+ const errorRecord = error;
51
+ if ((typeof errorRecord?.message === "string" &&
52
+ errorRecord.message.includes("API_KEY_INVALID")) ||
53
+ (typeof errorRecord?.message === "string" &&
54
+ errorRecord.message.includes("Invalid API key"))) {
52
55
  return new Error("Invalid Anthropic API key. Please check your ANTHROPIC_API_KEY environment variable.");
53
56
  }
54
- if (error?.message?.includes("rate limit")) {
57
+ if (typeof errorRecord?.message === "string" &&
58
+ errorRecord.message.includes("rate limit")) {
55
59
  return new Error("Anthropic rate limit exceeded. Please try again later.");
56
60
  }
57
- return new Error(`Anthropic error: ${error?.message || "Unknown error"}`);
61
+ const message = typeof errorRecord?.message === "string"
62
+ ? errorRecord.message
63
+ : "Unknown error";
64
+ return new Error(`Anthropic error: ${message}`);
58
65
  }
59
66
  // executeGenerate removed - BaseProvider handles all generation with tools
60
67
  async executeStream(options, analysisSchema) {
@@ -1,3 +1,4 @@
1
+ import { type LanguageModelV1 } from "ai";
1
2
  import { BaseProvider } from "../core/base-provider.js";
2
3
  import type { AIProviderName } from "../core/types.js";
3
4
  import type { StreamOptions, StreamResult } from "../types/stream-types.js";
@@ -7,14 +8,14 @@ export declare class AzureOpenAIProvider extends BaseProvider {
7
8
  private deployment;
8
9
  private apiVersion;
9
10
  private azureProvider;
10
- constructor(modelName?: string);
11
+ constructor(modelName?: string, sdk?: unknown);
11
12
  protected getProviderName(): AIProviderName;
12
13
  protected getDefaultModel(): string;
13
14
  /**
14
15
  * Returns the Vercel AI SDK model instance for Azure OpenAI
15
16
  */
16
- protected getAISDKModel(): any;
17
- protected handleProviderError(error: any): Error;
18
- protected executeStream(options: StreamOptions, analysisSchema?: any): Promise<StreamResult>;
17
+ protected getAISDKModel(): LanguageModelV1;
18
+ protected handleProviderError(error: unknown): Error;
19
+ protected executeStream(options: StreamOptions, analysisSchema?: unknown): Promise<StreamResult>;
19
20
  }
20
21
  export default AzureOpenAIProvider;
@@ -7,8 +7,8 @@ export class AzureOpenAIProvider extends BaseProvider {
7
7
  deployment;
8
8
  apiVersion;
9
9
  azureProvider;
10
- constructor(modelName) {
11
- super(modelName, "azure");
10
+ constructor(modelName, sdk) {
11
+ super(modelName, "azure", sdk);
12
12
  this.apiKey = process.env.AZURE_OPENAI_API_KEY || "";
13
13
  const endpoint = process.env.AZURE_OPENAI_ENDPOINT || "";
14
14
  this.resourceName = endpoint
@@ -52,10 +52,16 @@ export class AzureOpenAIProvider extends BaseProvider {
52
52
  return this.azureProvider(this.deployment);
53
53
  }
54
54
  handleProviderError(error) {
55
- if (error?.message?.includes("401")) {
55
+ const errorObj = error;
56
+ if (errorObj?.message &&
57
+ typeof errorObj.message === "string" &&
58
+ errorObj.message.includes("401")) {
56
59
  return new Error("Invalid Azure OpenAI API key or endpoint.");
57
60
  }
58
- return new Error(`Azure OpenAI error: ${error?.message || "Unknown error"}`);
61
+ const message = errorObj?.message && typeof errorObj.message === "string"
62
+ ? errorObj.message
63
+ : "Unknown error";
64
+ return new Error(`Azure OpenAI error: ${message}`);
59
65
  }
60
66
  // executeGenerate removed - BaseProvider handles all generation with tools
61
67
  async executeStream(options, analysisSchema) {