@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
@@ -16,6 +16,55 @@ export class OllamaUtils {
16
16
  };
17
17
  return spawnSync(command, args, defaultOptions);
18
18
  }
19
+ /**
20
+ * Check if Ollama command line is available
21
+ */
22
+ static isOllamaCommandReady() {
23
+ const cmdCheck = this.safeSpawn("ollama", ["list"]);
24
+ return !cmdCheck.error && cmdCheck.status === 0;
25
+ }
26
+ /**
27
+ * Validate HTTP API response from Ollama
28
+ */
29
+ static validateApiResponse(output) {
30
+ const httpCodeMatch = output.match(/(\d{3})$/);
31
+ if (!httpCodeMatch || httpCodeMatch[1] !== "200") {
32
+ return false;
33
+ }
34
+ // Try to parse the JSON response (excluding HTTP code)
35
+ const jsonResponse = output.replace(/\d{3}$/, "");
36
+ try {
37
+ const parsedResponse = JSON.parse(jsonResponse);
38
+ return parsedResponse && typeof parsedResponse === "object";
39
+ }
40
+ catch {
41
+ // JSON parsing failed, but HTTP 200 is good enough
42
+ return true;
43
+ }
44
+ }
45
+ /**
46
+ * Check if Ollama HTTP API is ready
47
+ */
48
+ static isOllamaApiReady() {
49
+ try {
50
+ const apiCheck = this.safeSpawn("curl", [
51
+ "-s",
52
+ "--max-time",
53
+ "3",
54
+ "--fail", // Fail on HTTP error codes
55
+ "-w",
56
+ "%{http_code}",
57
+ "http://localhost:11434/api/tags",
58
+ ]);
59
+ if (apiCheck.error || apiCheck.status !== 0 || !apiCheck.stdout.trim()) {
60
+ return false;
61
+ }
62
+ return this.validateApiResponse(apiCheck.stdout.trim());
63
+ }
64
+ catch {
65
+ return false;
66
+ }
67
+ }
19
68
  /**
20
69
  * Wait for Ollama service to become ready with exponential backoff
21
70
  */
@@ -23,49 +72,16 @@ export class OllamaUtils {
23
72
  let delay = initialDelay;
24
73
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
25
74
  try {
26
- // Try both command line and HTTP API checks
27
- const cmdCheck = this.safeSpawn("ollama", ["list"]);
28
- if (!cmdCheck.error && cmdCheck.status === 0) {
29
- // Stronger HTTP API probe with response validation
30
- try {
31
- const apiCheck = this.safeSpawn("curl", [
32
- "-s",
33
- "--max-time",
34
- "3",
35
- "--fail", // Fail on HTTP error codes
36
- "-w",
37
- "%{http_code}",
38
- "http://localhost:11434/api/tags",
39
- ]);
40
- if (!apiCheck.error &&
41
- apiCheck.status === 0 &&
42
- apiCheck.stdout.trim()) {
43
- // Validate that we get a proper HTTP 200 response and JSON structure
44
- const output = apiCheck.stdout.trim();
45
- const httpCodeMatch = output.match(/(\d{3})$/);
46
- if (httpCodeMatch && httpCodeMatch[1] === "200") {
47
- // Try to parse the JSON response (excluding HTTP code)
48
- const jsonResponse = output.replace(/\d{3}$/, "");
49
- try {
50
- const parsedResponse = JSON.parse(jsonResponse);
51
- // Verify it has the expected structure
52
- if (parsedResponse && typeof parsedResponse === "object") {
53
- return true; // Strong verification passed
54
- }
55
- }
56
- catch {
57
- // JSON parsing failed, but HTTP 200 is good enough
58
- return true;
59
- }
60
- }
61
- }
62
- }
63
- catch {
64
- // If curl fails, fall back to command check only
65
- return true;
66
- }
67
- return true; // Command check passed
75
+ // Try command line check first
76
+ if (!this.isOllamaCommandReady()) {
77
+ continue;
78
+ }
79
+ // If command check passes, verify HTTP API
80
+ if (this.isOllamaApiReady()) {
81
+ return true;
68
82
  }
83
+ // Command check passed but API not ready, still consider ready
84
+ return true;
69
85
  }
70
86
  catch {
71
87
  // Service not ready yet
@@ -6,6 +6,7 @@ import { promises as fs } from "fs";
6
6
  import path from "path";
7
7
  import crypto from "crypto";
8
8
  import { logger } from "../utils/logger.js";
9
+ import { DEFAULT_CONFIG } from "./types.js";
9
10
  const { readFile, writeFile, readdir, mkdir, unlink, access } = fs;
10
11
  /**
11
12
  * Enhanced Config Manager with automatic backup/restore capabilities
@@ -237,7 +238,6 @@ export default ${JSON.stringify(currentConfig, null, 2)};`;
237
238
  * Generate default configuration
238
239
  */
239
240
  async generateDefaultConfig() {
240
- const { DEFAULT_CONFIG } = await import("./types.js");
241
241
  return {
242
242
  ...DEFAULT_CONFIG,
243
243
  lastUpdated: Date.now(),
@@ -266,7 +266,10 @@ export default ${JSON.stringify(currentConfig, null, 2)};`;
266
266
  throw new Error("Invalid config file format");
267
267
  }
268
268
  catch (error) {
269
- logger.info("Config file not found, generating default...");
269
+ logger.info("Config file not found or invalid, generating default...", {
270
+ error: error instanceof Error ? error.message : String(error),
271
+ configPath: this.configPath,
272
+ });
270
273
  return await this.generateDefaultConfig();
271
274
  }
272
275
  }
@@ -4,30 +4,8 @@
4
4
  * Provides lightweight analytics tracking for AI provider usage,
5
5
  * including tokens, costs, performance metrics, and custom context.
6
6
  */
7
- import type { JsonValue, UnknownRecord } from "../types/common.js";
8
- export interface AnalyticsData {
9
- provider: string;
10
- model: string;
11
- tokens: {
12
- input: number;
13
- output: number;
14
- total: number;
15
- };
16
- cost?: number;
17
- responseTime: number;
18
- context?: Record<string, JsonValue>;
19
- timestamp: string;
20
- evaluation?: {
21
- relevanceScore: number;
22
- accuracyScore: number;
23
- completenessScore: number;
24
- overall: number;
25
- evaluationProvider?: string;
26
- evaluationTime?: number;
27
- evaluationAttempt?: number;
28
- };
29
- costDetails?: UnknownRecord;
30
- }
7
+ import type { AnalyticsData } from "../types/providers.js";
8
+ export type { AnalyticsData, TokenUsage } from "../types/providers.js";
31
9
  /**
32
10
  * Create analytics data structure from AI response
33
11
  */
@@ -19,9 +19,9 @@ export function createAnalytics(provider, model, result, responseTime, context)
19
19
  const analytics = {
20
20
  provider,
21
21
  model,
22
- tokens,
22
+ tokenUsage: tokens,
23
23
  cost,
24
- responseTime,
24
+ requestDuration: responseTime,
25
25
  context: context,
26
26
  timestamp: new Date().toISOString(),
27
27
  };
@@ -40,8 +40,8 @@ export function createAnalytics(provider, model, result, responseTime, context)
40
40
  return {
41
41
  provider,
42
42
  model,
43
- tokens: { input: 0, output: 0, total: 0 },
44
- responseTime,
43
+ tokenUsage: { input: 0, output: 0, total: 0 },
44
+ requestDuration: responseTime,
45
45
  context: context,
46
46
  timestamp: new Date().toISOString(),
47
47
  };
@@ -56,14 +56,11 @@ function extractTokenUsage(result) {
56
56
  typeof result.usage === "object" &&
57
57
  result.usage !== null) {
58
58
  const usage = result.usage;
59
- // Try BaseProvider normalized format first (inputTokens/outputTokens)
60
- if (typeof usage.inputTokens === "number" ||
61
- typeof usage.outputTokens === "number") {
62
- const input = typeof usage.inputTokens === "number" ? usage.inputTokens : 0;
63
- const output = typeof usage.outputTokens === "number" ? usage.outputTokens : 0;
64
- const total = typeof usage.totalTokens === "number"
65
- ? usage.totalTokens
66
- : input + output;
59
+ // Try BaseProvider normalized format first (input/output/total)
60
+ if (typeof usage.input === "number" || typeof usage.output === "number") {
61
+ const input = typeof usage.input === "number" ? usage.input : 0;
62
+ const output = typeof usage.output === "number" ? usage.output : 0;
63
+ const total = typeof usage.total === "number" ? usage.total : input + output;
67
64
  return { input, output, total };
68
65
  }
69
66
  // Try OpenAI/Mistral format (promptTokens/completionTokens)
@@ -71,14 +68,12 @@ function extractTokenUsage(result) {
71
68
  typeof usage.completionTokens === "number") {
72
69
  const input = typeof usage.promptTokens === "number" ? usage.promptTokens : 0;
73
70
  const output = typeof usage.completionTokens === "number" ? usage.completionTokens : 0;
74
- const total = typeof usage.totalTokens === "number"
75
- ? usage.totalTokens
76
- : input + output;
71
+ const total = typeof usage.total === "number" ? usage.total : input + output;
77
72
  return { input, output, total };
78
73
  }
79
74
  // Handle total-only case
80
- if (typeof usage.totalTokens === "number") {
81
- return { input: 0, output: 0, total: usage.totalTokens };
75
+ if (typeof usage.total === "number") {
76
+ return { input: 0, output: 0, total: usage.total };
82
77
  }
83
78
  }
84
79
  // Fallback for edge cases
@@ -1,6 +1,7 @@
1
1
  import type { ValidationSchema } from "../types/typeAliases.js";
2
2
  import type { Tool, LanguageModelV1 } from "ai";
3
- import type { AIProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, AnalyticsData, AIProviderName, EvaluationData } from "../core/types.js";
3
+ import type { AIProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, AnalyticsData, AIProviderName } from "../core/types.js";
4
+ import type { EvaluationData } from "../index.js";
4
5
  import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
5
6
  import type { UnknownRecord } from "../types/common.js";
6
7
  import type { NeuroLink } from "../neurolink.js";
@@ -76,6 +77,34 @@ export declare abstract class BaseProvider implements AIProvider {
76
77
  * Determine if middleware should be skipped for this request
77
78
  */
78
79
  private shouldSkipMiddleware;
80
+ /**
81
+ * Check if a schema is a Zod schema
82
+ */
83
+ private isZodSchema;
84
+ /**
85
+ * Convert tool execution result from MCP format to standard format
86
+ */
87
+ private convertToolResult;
88
+ /**
89
+ * Create a custom tool from tool definition
90
+ */
91
+ private createCustomToolFromDefinition;
92
+ /**
93
+ * Process custom tools from setupToolExecutor
94
+ */
95
+ private processCustomTools;
96
+ /**
97
+ * Create an external MCP tool
98
+ */
99
+ private createExternalMCPTool;
100
+ /**
101
+ * Process external MCP tools
102
+ */
103
+ private processExternalMCPTools;
104
+ /**
105
+ * Process MCP tools integration
106
+ */
107
+ private processMCPTools;
79
108
  /**
80
109
  * Get all available tools - direct tools are ALWAYS available
81
110
  * MCP tools are added when available (without blocking)