@juspay/neurolink 10.12.9 → 11.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 (241) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/browser/neurolink.min.js +504 -506
  3. package/dist/cli/commands/setup.d.ts +20 -1
  4. package/dist/cli/commands/setup.js +160 -36
  5. package/dist/cli/factories/commandFactory.d.ts +1157 -1
  6. package/dist/cli/factories/commandFactory.js +20 -53
  7. package/dist/core/baseProvider.js +3 -3
  8. package/dist/core/dynamicModels.d.ts +1 -1
  9. package/dist/core/dynamicModels.js +1 -23
  10. package/dist/core/modelConfiguration.d.ts +1 -70
  11. package/dist/core/modelConfiguration.js +0 -303
  12. package/dist/core/modules/GenerationHandler.js +2 -2
  13. package/dist/core/modules/structuredOutputPolicy.d.ts +2 -2
  14. package/dist/core/modules/structuredOutputPolicy.js +2 -2
  15. package/dist/factories/providerDescriptors.d.ts +18 -0
  16. package/dist/factories/providerDescriptors.js +536 -0
  17. package/dist/factories/providerFactory.d.ts +28 -2
  18. package/dist/factories/providerFactory.js +53 -42
  19. package/dist/factories/providerRegistry.js +33 -32
  20. package/dist/index.d.ts +10 -1
  21. package/dist/index.js +13 -3
  22. package/dist/lib/core/baseProvider.js +3 -3
  23. package/dist/lib/core/dynamicModels.d.ts +1 -1
  24. package/dist/lib/core/dynamicModels.js +1 -23
  25. package/dist/lib/core/modelConfiguration.d.ts +1 -70
  26. package/dist/lib/core/modelConfiguration.js +0 -303
  27. package/dist/lib/core/modules/GenerationHandler.js +2 -2
  28. package/dist/lib/core/modules/structuredOutputPolicy.d.ts +2 -2
  29. package/dist/lib/core/modules/structuredOutputPolicy.js +2 -2
  30. package/dist/lib/factories/providerDescriptors.d.ts +18 -0
  31. package/dist/lib/factories/providerDescriptors.js +537 -0
  32. package/dist/lib/factories/providerFactory.d.ts +28 -2
  33. package/dist/lib/factories/providerFactory.js +53 -42
  34. package/dist/lib/factories/providerRegistry.js +33 -32
  35. package/dist/lib/index.d.ts +10 -1
  36. package/dist/lib/index.js +13 -3
  37. package/dist/lib/models/anthropicModels.d.ts +0 -7
  38. package/dist/lib/models/anthropicModels.js +0 -9
  39. package/dist/lib/neurolink.js +25 -37
  40. package/dist/lib/providers/amazonBedrock/client.js +34 -16
  41. package/dist/lib/providers/anthropic/client.js +39 -34
  42. package/dist/lib/providers/anthropic/constants.d.ts +0 -1
  43. package/dist/lib/providers/anthropic/constants.js +0 -2
  44. package/dist/lib/providers/anthropic/index.d.ts +0 -1
  45. package/dist/lib/providers/anthropic/index.js +0 -1
  46. package/dist/lib/providers/azureOpenai.js +17 -15
  47. package/dist/lib/providers/cloudflare.js +12 -21
  48. package/dist/lib/providers/cohere.js +31 -25
  49. package/dist/lib/providers/deepseek.js +23 -26
  50. package/dist/lib/providers/fireworks.js +12 -21
  51. package/dist/lib/providers/googleAiStudio/client.d.ts +2 -0
  52. package/dist/lib/providers/googleAiStudio/client.js +39 -17
  53. package/dist/lib/providers/googleAiStudio/index.d.ts +0 -1
  54. package/dist/lib/providers/googleAiStudio/index.js +0 -1
  55. package/dist/lib/providers/googleNativeGemini3/index.d.ts +0 -1
  56. package/dist/lib/providers/googleNativeGemini3/index.js +0 -1
  57. package/dist/lib/providers/googleVertex/client.d.ts +0 -51
  58. package/dist/lib/providers/googleVertex/client.js +107 -777
  59. package/dist/lib/providers/groq.js +19 -22
  60. package/dist/lib/providers/huggingFace/client.d.ts +1 -1
  61. package/dist/lib/providers/huggingFace/client.js +27 -25
  62. package/dist/lib/providers/huggingFace/index.d.ts +0 -1
  63. package/dist/lib/providers/huggingFace/index.js +0 -1
  64. package/dist/lib/providers/jina.d.ts +0 -1
  65. package/dist/lib/providers/jina.js +0 -1
  66. package/dist/lib/providers/litellm/client.js +54 -39
  67. package/dist/lib/providers/litellm/index.d.ts +0 -2
  68. package/dist/lib/providers/litellm/index.js +0 -2
  69. package/dist/lib/providers/llamaCpp.d.ts +1 -0
  70. package/dist/lib/providers/llamaCpp.js +24 -18
  71. package/dist/lib/providers/lmStudio.js +25 -42
  72. package/dist/lib/providers/mistral.js +12 -24
  73. package/dist/lib/providers/nvidiaNim/client.js +37 -34
  74. package/dist/lib/providers/nvidiaNim/index.d.ts +0 -1
  75. package/dist/lib/providers/nvidiaNim/index.js +0 -1
  76. package/dist/lib/providers/ollama/client.js +51 -58
  77. package/dist/lib/providers/ollama/index.d.ts +0 -1
  78. package/dist/lib/providers/ollama/index.js +0 -1
  79. package/dist/lib/providers/openAI/client.js +37 -40
  80. package/dist/lib/providers/openAI/index.d.ts +0 -2
  81. package/dist/lib/providers/openAI/index.js +0 -2
  82. package/dist/lib/providers/openRouter/client.js +53 -47
  83. package/dist/lib/providers/openRouter/utils.d.ts +0 -2
  84. package/dist/lib/providers/openRouter/utils.js +0 -12
  85. package/dist/lib/providers/openaiChatCompletionsBase.d.ts +9 -0
  86. package/dist/lib/providers/openaiChatCompletionsBase.js +73 -16
  87. package/dist/lib/providers/openaiCompatible/client.js +36 -32
  88. package/dist/lib/providers/perplexity.d.ts +2 -1
  89. package/dist/lib/providers/perplexity.js +14 -22
  90. package/dist/lib/providers/replicate.d.ts +0 -1
  91. package/dist/lib/providers/replicate.js +22 -9
  92. package/dist/lib/providers/togetherAi.js +12 -21
  93. package/dist/lib/providers/voyage.d.ts +0 -1
  94. package/dist/lib/providers/voyage.js +0 -1
  95. package/dist/lib/providers/xai.js +17 -26
  96. package/dist/lib/server/errors.d.ts +1 -1
  97. package/dist/lib/server/errors.js +2 -2
  98. package/dist/lib/server/index.d.ts +2 -2
  99. package/dist/lib/server/index.js +5 -3
  100. package/dist/lib/server/middleware/rateLimit.d.ts +0 -4
  101. package/dist/lib/server/middleware/rateLimit.js +0 -4
  102. package/dist/lib/types/errors.d.ts +35 -0
  103. package/dist/lib/types/index.d.ts +0 -1
  104. package/dist/lib/types/index.js +0 -1
  105. package/dist/lib/types/providers.d.ts +66 -11
  106. package/dist/lib/utils/errorClassifier.d.ts +30 -0
  107. package/dist/lib/utils/errorClassifier.js +94 -0
  108. package/dist/lib/utils/fileDetector.js +6 -43
  109. package/dist/lib/utils/providerConfig.d.ts +0 -8
  110. package/dist/lib/utils/providerConfig.js +0 -37
  111. package/dist/lib/utils/providerHealth.d.ts +42 -7
  112. package/dist/lib/utils/providerHealth.js +115 -122
  113. package/dist/lib/utils/providerUtils.js +21 -87
  114. package/dist/models/anthropicModels.d.ts +0 -7
  115. package/dist/models/anthropicModels.js +0 -9
  116. package/dist/neurolink.js +25 -37
  117. package/dist/providers/amazonBedrock/client.js +34 -16
  118. package/dist/providers/amazonSagemaker.d.ts +1 -1
  119. package/dist/providers/anthropic/client.js +39 -34
  120. package/dist/providers/anthropic/constants.d.ts +0 -1
  121. package/dist/providers/anthropic/constants.js +0 -2
  122. package/dist/providers/anthropic/index.d.ts +0 -1
  123. package/dist/providers/anthropic/index.js +0 -1
  124. package/dist/providers/azureOpenai.js +17 -15
  125. package/dist/providers/cloudflare.js +12 -21
  126. package/dist/providers/cohere.js +31 -25
  127. package/dist/providers/deepseek.js +23 -26
  128. package/dist/providers/fireworks.js +12 -21
  129. package/dist/providers/googleAiStudio/client.d.ts +2 -0
  130. package/dist/providers/googleAiStudio/client.js +39 -17
  131. package/dist/providers/googleAiStudio/index.d.ts +0 -1
  132. package/dist/providers/googleAiStudio/index.js +0 -1
  133. package/dist/providers/googleNativeGemini3/index.d.ts +0 -1
  134. package/dist/providers/googleNativeGemini3/index.js +0 -1
  135. package/dist/providers/googleVertex/client.d.ts +0 -51
  136. package/dist/providers/googleVertex/client.js +107 -777
  137. package/dist/providers/groq.js +19 -22
  138. package/dist/providers/huggingFace/client.d.ts +1 -1
  139. package/dist/providers/huggingFace/client.js +27 -25
  140. package/dist/providers/huggingFace/index.d.ts +0 -1
  141. package/dist/providers/huggingFace/index.js +0 -1
  142. package/dist/providers/jina.d.ts +0 -1
  143. package/dist/providers/jina.js +0 -1
  144. package/dist/providers/litellm/client.js +54 -39
  145. package/dist/providers/litellm/index.d.ts +0 -2
  146. package/dist/providers/litellm/index.js +0 -2
  147. package/dist/providers/llamaCpp.d.ts +1 -0
  148. package/dist/providers/llamaCpp.js +24 -18
  149. package/dist/providers/lmStudio.js +25 -42
  150. package/dist/providers/mistral.js +12 -24
  151. package/dist/providers/nvidiaNim/client.js +37 -34
  152. package/dist/providers/nvidiaNim/index.d.ts +0 -1
  153. package/dist/providers/nvidiaNim/index.js +0 -1
  154. package/dist/providers/ollama/client.js +51 -58
  155. package/dist/providers/ollama/index.d.ts +0 -1
  156. package/dist/providers/ollama/index.js +0 -1
  157. package/dist/providers/openAI/client.js +37 -40
  158. package/dist/providers/openAI/index.d.ts +0 -2
  159. package/dist/providers/openAI/index.js +0 -2
  160. package/dist/providers/openRouter/client.js +53 -47
  161. package/dist/providers/openRouter/utils.d.ts +0 -2
  162. package/dist/providers/openRouter/utils.js +0 -12
  163. package/dist/providers/openaiChatCompletionsBase.d.ts +9 -0
  164. package/dist/providers/openaiChatCompletionsBase.js +73 -16
  165. package/dist/providers/openaiCompatible/client.js +36 -32
  166. package/dist/providers/perplexity.d.ts +2 -1
  167. package/dist/providers/perplexity.js +14 -22
  168. package/dist/providers/replicate.d.ts +0 -1
  169. package/dist/providers/replicate.js +22 -9
  170. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  171. package/dist/providers/togetherAi.js +12 -21
  172. package/dist/providers/voyage.d.ts +0 -1
  173. package/dist/providers/voyage.js +0 -1
  174. package/dist/providers/xai.js +17 -26
  175. package/dist/server/errors.d.ts +1 -1
  176. package/dist/server/errors.js +2 -2
  177. package/dist/server/index.d.ts +2 -2
  178. package/dist/server/index.js +5 -3
  179. package/dist/server/middleware/rateLimit.d.ts +0 -4
  180. package/dist/server/middleware/rateLimit.js +0 -4
  181. package/dist/types/errors.d.ts +35 -0
  182. package/dist/types/index.d.ts +0 -1
  183. package/dist/types/index.js +0 -1
  184. package/dist/types/providers.d.ts +66 -11
  185. package/dist/utils/errorClassifier.d.ts +30 -0
  186. package/dist/utils/errorClassifier.js +93 -0
  187. package/dist/utils/fileDetector.js +6 -43
  188. package/dist/utils/providerConfig.d.ts +0 -8
  189. package/dist/utils/providerConfig.js +0 -37
  190. package/dist/utils/providerHealth.d.ts +42 -7
  191. package/dist/utils/providerHealth.js +115 -122
  192. package/dist/utils/providerUtils.js +21 -87
  193. package/package.json +21 -75
  194. package/dist/lib/providers/anthropic/utils.d.ts +0 -7
  195. package/dist/lib/providers/anthropic/utils.js +0 -150
  196. package/dist/lib/providers/googleAiStudio/utils.d.ts +0 -2
  197. package/dist/lib/providers/googleAiStudio/utils.js +0 -19
  198. package/dist/lib/providers/googleNativeGemini3/constants.d.ts +0 -1
  199. package/dist/lib/providers/googleNativeGemini3/constants.js +0 -2
  200. package/dist/lib/providers/huggingFace/utils.d.ts +0 -2
  201. package/dist/lib/providers/huggingFace/utils.js +0 -8
  202. package/dist/lib/providers/index.d.ts +0 -33
  203. package/dist/lib/providers/index.js +0 -34
  204. package/dist/lib/providers/litellm/constants.d.ts +0 -1
  205. package/dist/lib/providers/litellm/constants.js +0 -3
  206. package/dist/lib/providers/litellm/utils.d.ts +0 -5
  207. package/dist/lib/providers/litellm/utils.js +0 -11
  208. package/dist/lib/providers/nvidiaNim/utils.d.ts +0 -9
  209. package/dist/lib/providers/nvidiaNim/utils.js +0 -101
  210. package/dist/lib/providers/ollama/utils.d.ts +0 -8
  211. package/dist/lib/providers/ollama/utils.js +0 -43
  212. package/dist/lib/providers/openAI/constants.d.ts +0 -1
  213. package/dist/lib/providers/openAI/constants.js +0 -3
  214. package/dist/lib/providers/openAI/utils.d.ts +0 -2
  215. package/dist/lib/providers/openAI/utils.js +0 -8
  216. package/dist/lib/types/universalProviderOptions.d.ts +0 -89
  217. package/dist/lib/types/universalProviderOptions.js +0 -55
  218. package/dist/providers/anthropic/utils.d.ts +0 -7
  219. package/dist/providers/anthropic/utils.js +0 -149
  220. package/dist/providers/googleAiStudio/utils.d.ts +0 -2
  221. package/dist/providers/googleAiStudio/utils.js +0 -18
  222. package/dist/providers/googleNativeGemini3/constants.d.ts +0 -1
  223. package/dist/providers/googleNativeGemini3/constants.js +0 -1
  224. package/dist/providers/huggingFace/utils.d.ts +0 -2
  225. package/dist/providers/huggingFace/utils.js +0 -7
  226. package/dist/providers/index.d.ts +0 -33
  227. package/dist/providers/index.js +0 -33
  228. package/dist/providers/litellm/constants.d.ts +0 -1
  229. package/dist/providers/litellm/constants.js +0 -2
  230. package/dist/providers/litellm/utils.d.ts +0 -5
  231. package/dist/providers/litellm/utils.js +0 -10
  232. package/dist/providers/nvidiaNim/utils.d.ts +0 -9
  233. package/dist/providers/nvidiaNim/utils.js +0 -100
  234. package/dist/providers/ollama/utils.d.ts +0 -8
  235. package/dist/providers/ollama/utils.js +0 -42
  236. package/dist/providers/openAI/constants.d.ts +0 -1
  237. package/dist/providers/openAI/constants.js +0 -2
  238. package/dist/providers/openAI/utils.d.ts +0 -2
  239. package/dist/providers/openAI/utils.js +0 -7
  240. package/dist/types/universalProviderOptions.d.ts +0 -89
  241. package/dist/types/universalProviderOptions.js +0 -54
@@ -4,10 +4,11 @@
4
4
  */
5
5
  import { logger } from "./logger.js";
6
6
  import { AIProviderName, OpenAIModels, GoogleAIModels, AnthropicModels, BedrockModels, } from "../constants/enums.js";
7
- import { API_KEY_LENGTHS, PROJECT_ID_FORMAT } from "./providerConfig.js";
7
+ import { PROJECT_ID_FORMAT } from "./providerConfig.js";
8
8
  import { basename } from "path";
9
9
  import { createProxyFetch } from "../proxy/proxyFetch.js";
10
10
  import { DEFAULT_OLLAMA_MODEL } from "../providers/ollama/constants.js";
11
+ import { ProviderFactory } from "../factories/providerFactory.js";
11
12
  export class ProviderHealthChecker {
12
13
  static healthCache = new Map();
13
14
  static DEFAULT_TIMEOUT = 5000; // 5 seconds
@@ -172,55 +173,36 @@ export class ProviderHealthChecker {
172
173
  logger.debug("Vertex AI authentication check starting", {
173
174
  providerName,
174
175
  });
175
- // Method 1: Check GOOGLE_APPLICATION_CREDENTIALS (file-based)
176
- const credentialsFile = process.env.GOOGLE_APPLICATION_CREDENTIALS;
177
- let fileBasedAuthValid = false;
178
- if (credentialsFile) {
179
- logger.debug("Checking GOOGLE_APPLICATION_CREDENTIALS file");
180
- try {
181
- const { promises: fs } = await import("fs");
182
- try {
183
- await fs.access(credentialsFile);
184
- fileBasedAuthValid = true;
185
- }
186
- catch {
187
- fileBasedAuthValid = false;
188
- }
189
- logger.debug("File auth check result", {
190
- fileExists: fileBasedAuthValid,
191
- });
192
- }
193
- catch (error) {
194
- logger.debug("File auth check error", {
195
- error: String(error),
196
- });
197
- fileBasedAuthValid = false;
198
- }
199
- }
200
- // Method 2: Check individual environment variables
201
- const hasIndividualAuth = !!(process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
202
- process.env.GOOGLE_AUTH_PRIVATE_KEY);
203
- logger.debug("Individual auth check", {
204
- hasClientEmail: !!process.env.GOOGLE_AUTH_CLIENT_EMAIL,
205
- hasPrivateKey: !!process.env.GOOGLE_AUTH_PRIVATE_KEY,
206
- hasIndividualAuth,
207
- });
208
- // Vertex is valid if EITHER auth method works
209
- const hasValidAuth = fileBasedAuthValid || hasIndividualAuth;
210
- logger.debug("Vertex auth final result", {
211
- fileBasedAuthValid,
212
- hasIndividualAuth,
213
- hasValidAuth,
214
- });
176
+ // Derive auth-var acceptance from the vertex descriptor instead of a
177
+ // hand-maintained var list, so this stays in sync with the real
178
+ // gating logic (hasGoogleCredentials() in googleVertex/client.ts and
179
+ // googleVertex/utils.ts): extraRequired.every(...) ||
180
+ // extraRequiredFallbacks.some(...), the same pattern used by
181
+ // hasProviderEnvVars() (providerUtils.ts), setup.ts, and
182
+ // environmentManager.ts. The old two-method check here only
183
+ // recognized GOOGLE_APPLICATION_CREDENTIALS or the
184
+ // GOOGLE_AUTH_CLIENT_EMAIL + GOOGLE_AUTH_PRIVATE_KEY pair — missing
185
+ // GOOGLE_SERVICE_ACCOUNT_KEY and, most importantly,
186
+ // GOOGLE_APPLICATION_CREDENTIALS_NEUROLINK, the descriptor's
187
+ // documented first-priority fallback. A user configured via that
188
+ // var alone had a fully working Vertex provider but was reported
189
+ // unhealthy here. Note: this is a presence-only check — it no
190
+ // longer verifies the GOOGLE_APPLICATION_CREDENTIALS file actually
191
+ // exists on disk (the old file-based method did via fs.access),
192
+ // matching the presence-only semantics already used by the other
193
+ // three callers of this pattern.
194
+ const descriptor = ProviderFactory.getDescriptor(AIProviderName.VERTEX);
195
+ const { extraRequired, extraRequiredFallbacks } = descriptor?.envVars ?? {};
196
+ const hasValidAuth = (extraRequired ?? []).every((v) => !!process.env[v]) ||
197
+ (extraRequiredFallbacks ?? []).some((v) => !!process.env[v]);
198
+ logger.debug("Vertex auth final result", { hasValidAuth });
215
199
  if (hasValidAuth) {
216
200
  healthStatus.hasApiKey = true;
217
- logger.debug("Vertex auth SUCCESS", {
218
- authMethod: fileBasedAuthValid ? "file-based" : "individual-env-vars",
219
- });
201
+ logger.debug("Vertex auth SUCCESS");
220
202
  }
221
203
  else {
222
204
  healthStatus.hasApiKey = false;
223
- healthStatus.configurationIssues.push(`Vertex AI authentication not found: neither GOOGLE_APPLICATION_CREDENTIALS file nor individual credentials (GOOGLE_AUTH_CLIENT_EMAIL + GOOGLE_AUTH_PRIVATE_KEY) are properly configured`);
205
+ healthStatus.configurationIssues.push("Vertex AI authentication not found: set GOOGLE_APPLICATION_CREDENTIALS, GOOGLE_APPLICATION_CREDENTIALS_NEUROLINK, GOOGLE_SERVICE_ACCOUNT_KEY, or both GOOGLE_AUTH_CLIENT_EMAIL and GOOGLE_AUTH_PRIVATE_KEY");
224
206
  logger.debug("Vertex auth FAILED", {
225
207
  reason: "No valid auth method found",
226
208
  });
@@ -359,104 +341,115 @@ export class ProviderHealthChecker {
359
341
  }
360
342
  }
361
343
  }
344
+ /**
345
+ * Providers whose credential model can't be reduced to "every one of
346
+ * these exact env vars must be literally set" — the check in
347
+ * checkEnvironmentConfiguration() below ANDs every entry in the
348
+ * returned list together, which can't express Vertex's file-OR-
349
+ * individual-creds-OR-service-account auth, Bedrock's AWS SDK default
350
+ * provider chain (profile / IAM role, no env vars at all), or
351
+ * LiteLLM's documented zero-config local proxy. Their real requirement
352
+ * is validated by checkProviderSpecificConfig()'s dedicated per-provider
353
+ * checks instead — matches the original hand-written switch's
354
+ * deliberate `return []` for exactly these three. Naively deriving
355
+ * [apiKey, ...extraRequired] from the descriptor here (as for the other
356
+ * 27 providers) would make checkEnvironmentConfiguration() push a false
357
+ * "missing environment variables" issue — and therefore isHealthy=false
358
+ * — for legitimate fallback-based Vertex auth, AWS_PROFILE/IAM-role
359
+ * Bedrock auth, and unauthenticated local LiteLLM proxies. See
360
+ * hasProviderEnvVars() in providerUtils.ts for the equivalent OR-aware
361
+ * check used for auto-select gating.
362
+ */
363
+ static ENV_CHECK_DELEGATED_TO_SPECIFIC_CONFIG = new Set([
364
+ AIProviderName.VERTEX,
365
+ AIProviderName.BEDROCK,
366
+ AIProviderName.LITELLM,
367
+ ]);
362
368
  /**
363
369
  * Get required environment variables for a provider
364
370
  */
365
371
  static getRequiredEnvironmentVariables(providerName) {
366
- switch (providerName) {
367
- case AIProviderName.ANTHROPIC:
368
- return ["ANTHROPIC_API_KEY"];
369
- case AIProviderName.OPENAI:
370
- return ["OPENAI_API_KEY"];
371
- case AIProviderName.VERTEX:
372
- // Vertex AI requires authentication, but not via a single environment variable.
373
- // Authentication can be provided via a credential file or individual credentials + project.
374
- // The required authentication is checked in checkProviderSpecificConfig instead of here.
375
- // Returning an empty array here does NOT mean authentication is not required.
376
- return [];
377
- case AIProviderName.GOOGLE_AI:
378
- return ["GOOGLE_AI_API_KEY"];
379
- case AIProviderName.BEDROCK:
380
- // Bedrock credentials are resolved via AWS SDK default provider chain.
381
- // Region/auth validated in provider-specific checks.
382
- return [];
383
- case AIProviderName.AZURE:
384
- return ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"];
385
- case AIProviderName.LITELLM:
386
- return [];
387
- case AIProviderName.OLLAMA:
388
- return []; // Ollama typically doesn't require API keys
389
- default:
390
- return [];
391
- }
372
+ // Resolve the descriptor FIRST so the delegation-Set check below is
373
+ // keyed on the canonical, alias-resolved `descriptor.name` — not the
374
+ // raw, possibly-aliased `providerName` argument. Checking the raw
375
+ // input here would let documented aliases (e.g. "googleVertex" for
376
+ // vertex, "aws" for bedrock) skip the delegation and fall through to
377
+ // the naive [apiKey, ...extraRequired] derivation below, reproducing
378
+ // the exact false "missing environment variables" regression this
379
+ // Set exists to prevent.
380
+ const descriptor = ProviderFactory.getDescriptor(providerName);
381
+ if (!descriptor) {
382
+ return [];
383
+ }
384
+ if (this.ENV_CHECK_DELEGATED_TO_SPECIFIC_CONFIG.has(descriptor.name)) {
385
+ return [];
386
+ }
387
+ const { apiKey, extraRequired } = descriptor.envVars;
388
+ return [...(apiKey ? [apiKey] : []), ...(extraRequired ?? [])];
392
389
  }
393
390
  /**
394
- * Get API key environment variable for a provider
391
+ * Get API key environment variable for a provider.
392
+ *
393
+ * Dead code at its sole call site today (checkApiKeyValidity() early-
394
+ * returns for VERTEX/OLLAMA/BEDROCK/LITELLM before reaching this), but
395
+ * now `static` (public) so a future direct caller is plausible — hence
396
+ * the two intentional diffs from the original hand-written switch are
397
+ * documented here rather than left silent:
398
+ * - vertex: old switch returned "GOOGLE_APPLICATION_CREDENTIALS"
399
+ * (one of several valid auth vars); the descriptor's `envVars.apiKey`
400
+ * is "GOOGLE_CLOUD_PROJECT_ID" instead — the actual identity var for
401
+ * the provider, not one specific credential-supply mechanism.
402
+ * - ollama: old switch returned "OLLAMA_BASE_URL"; the descriptor has
403
+ * no `envVars.apiKey` for ollama (it's a local, unauthenticated
404
+ * runtime), so this now returns "".
405
+ * Both are kept deliberately (semantically truer identity vars) rather
406
+ * than reproduced byte-for-byte from the old switch.
395
407
  */
396
408
  static getApiKeyEnvironmentVariable(providerName) {
397
- switch (providerName) {
398
- case AIProviderName.ANTHROPIC:
399
- return "ANTHROPIC_API_KEY";
400
- case AIProviderName.OPENAI:
401
- return "OPENAI_API_KEY";
402
- case AIProviderName.VERTEX:
403
- return "GOOGLE_APPLICATION_CREDENTIALS";
404
- case AIProviderName.GOOGLE_AI:
405
- return "GOOGLE_AI_API_KEY";
406
- case AIProviderName.BEDROCK:
407
- return "AWS_ACCESS_KEY_ID";
408
- case AIProviderName.AZURE:
409
- return "AZURE_OPENAI_API_KEY";
410
- case AIProviderName.LITELLM:
411
- return "LITELLM_API_KEY";
412
- case AIProviderName.OLLAMA:
413
- return "OLLAMA_BASE_URL";
414
- default:
415
- return "";
416
- }
409
+ return ProviderFactory.getDescriptor(providerName)?.envVars.apiKey ?? "";
417
410
  }
418
411
  /**
419
412
  * Validate API key format for a provider
420
413
  */
421
414
  static validateApiKeyFormat(providerName, apiKey) {
422
- switch (providerName) {
423
- case AIProviderName.ANTHROPIC:
424
- return (apiKey.startsWith("sk-ant-") &&
425
- apiKey.length >= API_KEY_LENGTHS.ANTHROPIC_MIN);
426
- case AIProviderName.OPENAI:
427
- return (apiKey.startsWith("sk-") &&
428
- apiKey.length >= API_KEY_LENGTHS.OPENAI_MIN);
429
- case AIProviderName.GOOGLE_AI:
430
- return apiKey.length >= API_KEY_LENGTHS.GOOGLE_AI_EXACT; // Basic length check
431
- case AIProviderName.VERTEX:
432
- return apiKey.endsWith(".json") || apiKey.includes("type"); // JSON key format
433
- case AIProviderName.BEDROCK:
434
- return apiKey.length >= API_KEY_LENGTHS.AWS_ACCESS_KEY; // AWS access key length
435
- case AIProviderName.AZURE:
436
- return apiKey.length >= API_KEY_LENGTHS.AZURE_MIN; // Azure OpenAI API key length
437
- case AIProviderName.LITELLM:
438
- return apiKey.length > 0;
439
- case AIProviderName.OLLAMA:
440
- return true; // Ollama usually doesn't require specific format
441
- default:
442
- return true; // Default to true for unknown providers
415
+ // Vertex's "API key" is really a credentials file path (or an inline
416
+ // JSON blob via GOOGLE_SERVICE_ACCOUNT_KEY) — never governed by the
417
+ // shared API_KEY_FORMATS regexes. Preserved exactly from the original
418
+ // switch even though checkApiKeyValidity() early-returns before ever
419
+ // reaching this call for Vertex today; kept correct for any other/
420
+ // future caller.
421
+ if (providerName === AIProviderName.VERTEX) {
422
+ return apiKey.endsWith(".json") || apiKey.includes("type");
423
+ }
424
+ const descriptor = ProviderFactory.getDescriptor(providerName);
425
+ if (!descriptor?.apiKeyFormatPattern) {
426
+ // Providers with no documented format (or local runtimes / providers
427
+ // usable with zero configuration) are accepted as-is — matches the
428
+ // old switch's per-provider `default: true`/no-format-check branches
429
+ // (ollama, litellm).
430
+ if (descriptor?.localRuntime || descriptor?.envVars.optional) {
431
+ return true;
432
+ }
433
+ return apiKey.length > 0;
443
434
  }
435
+ return descriptor.apiKeyFormatPattern.test(apiKey);
444
436
  }
445
437
  /**
446
438
  * Get health check endpoint for connectivity testing
447
439
  */
448
440
  static getProviderHealthEndpoint(providerName) {
449
- switch (providerName) {
450
- case AIProviderName.ANTHROPIC:
451
- return null; // Anthropic doesn't have a public health endpoint
441
+ const descriptor = ProviderFactory.getDescriptor(providerName);
442
+ if (descriptor?.healthCheck !== "models-probe") {
443
+ return null;
444
+ }
445
+ // OpenAI/LiteLLM/Ollama each need a provider-specific URL builder that
446
+ // isn't pure descriptor data (LiteLLM/Ollama depend on the configured
447
+ // base URL) — keep the existing per-provider dispatch for the 3
448
+ // models-probe providers, now gated on the descriptor instead of a
449
+ // hardcoded name list.
450
+ switch (descriptor.name) {
452
451
  case AIProviderName.OPENAI:
453
452
  return "https://api.openai.com/v1/models";
454
- case AIProviderName.GOOGLE_AI:
455
- return null; // No public health endpoint
456
- case AIProviderName.VERTEX:
457
- return null; // Complex authentication required
458
- case AIProviderName.BEDROCK:
459
- return null; // AWS endpoints vary by region
460
453
  case AIProviderName.LITELLM:
461
454
  return this.getLiteLLMModelsUrl();
462
455
  case AIProviderName.OLLAMA:
@@ -8,6 +8,8 @@ import { AIProviderName } from "../constants/enums.js";
8
8
  import { ProviderHealthChecker } from "./providerHealth.js";
9
9
  import { API_KEY_FORMATS, API_KEY_LENGTHS, PROJECT_ID_FORMAT, } from "./providerConfig.js";
10
10
  import { DEFAULT_OLLAMA_MODEL } from "../providers/ollama/constants.js";
11
+ import { ProviderFactory } from "../factories/providerFactory.js";
12
+ import { PROVIDER_DESCRIPTORS } from "../factories/providerDescriptors.js";
11
13
  /**
12
14
  * Get the best available provider based on real-time availability checks
13
15
  * Enhanced version consolidated from providerUtils-fixed.ts
@@ -20,19 +22,6 @@ export async function getBestProvider(requestedProvider) {
20
22
  // For explicit provider requests, ALWAYS honor the request
21
23
  // Never override explicit provider selection with health-based fallbacks
22
24
  logger.debug(`[getBestProvider] Using explicitly requested provider: ${requestedProvider}`);
23
- // Optional health check for logging purposes only
24
- try {
25
- const health = await ProviderHealthChecker.checkProviderHealth(requestedProvider, { includeConnectivityTest: false, cacheResults: true });
26
- if (health.isHealthy) {
27
- logger.debug(`[getBestProvider] Explicitly requested provider ${requestedProvider} is healthy`);
28
- }
29
- else {
30
- logger.warn(`[getBestProvider] Explicitly requested provider ${requestedProvider} may have issues, but using anyway`, { error: health.error });
31
- }
32
- }
33
- catch (error) {
34
- logger.warn(`[getBestProvider] Health check failed for explicitly requested provider ${requestedProvider}, using anyway`, { error: error instanceof Error ? error.message : String(error) });
35
- }
36
25
  // ALWAYS return the explicitly requested provider
37
26
  return requestedProvider;
38
27
  }
@@ -73,18 +62,9 @@ export async function getBestProvider(requestedProvider) {
73
62
  * - Other providers are ordered based on a combination of reliability, feature set, and historical performance.
74
63
  * Please update this comment if the order is changed in the future, and document the rationale for maintainability.
75
64
  */
76
- const providers = [
77
- "litellm", // Prioritize self-hosted proxy deployments first
78
- "ollama", // Local models when the configured runtime target is installed
79
- "vertex", // Google Cloud AI (enterprise)
80
- "google-ai", // Google AI ecosystem support
81
- "openai", // Reliable with broad model support
82
- "anthropic",
83
- "bedrock",
84
- "azure",
85
- "mistral",
86
- "huggingface",
87
- ];
65
+ const providers = PROVIDER_DESCRIPTORS.filter((d) => d.autoSelectPriority !== undefined)
66
+ .sort((a, b) => (a.autoSelectPriority ?? 0) - (b.autoSelectPriority ?? 0))
67
+ .map((d) => d.name);
88
68
  for (const provider of providers) {
89
69
  if (await isProviderAvailable(provider)) {
90
70
  logger.debug(`[getBestProvider] Selected provider: ${provider}`);
@@ -345,75 +325,29 @@ function isValidUrl(url) {
345
325
  * @returns True if the provider has required environment variables
346
326
  */
347
327
  export function hasProviderEnvVars(provider) {
348
- switch (provider.toLowerCase()) {
349
- case "bedrock":
350
- case "amazon":
351
- case "aws":
352
- return !!(process.env.AWS_ACCESS_KEY_ID && process.env.AWS_SECRET_ACCESS_KEY);
353
- case "vertex":
354
- case "googlevertex":
355
- case "google":
356
- case "gemini":
357
- return !!((process.env.GOOGLE_CLOUD_PROJECT_ID ||
358
- process.env.VERTEX_PROJECT_ID ||
359
- process.env.GOOGLE_VERTEX_PROJECT ||
360
- process.env.GOOGLE_CLOUD_PROJECT) &&
361
- (process.env.GOOGLE_APPLICATION_CREDENTIALS ||
362
- process.env.GOOGLE_SERVICE_ACCOUNT_KEY ||
363
- (process.env.GOOGLE_AUTH_CLIENT_EMAIL &&
364
- process.env.GOOGLE_AUTH_PRIVATE_KEY)));
365
- case "openai":
366
- case "gpt":
367
- return !!process.env.OPENAI_API_KEY;
368
- case "anthropic":
369
- case "claude":
370
- return !!process.env.ANTHROPIC_API_KEY;
371
- case "azure":
372
- case "azureopenai":
373
- return !!process.env.AZURE_OPENAI_API_KEY;
374
- case "google-ai":
375
- case "google-studio":
376
- return !!(process.env.GOOGLE_AI_API_KEY ||
377
- process.env.GOOGLE_GENERATIVE_AI_API_KEY);
378
- case "huggingface":
379
- case "hugging-face":
380
- case "hf":
381
- return !!(process.env.HUGGINGFACE_API_KEY || process.env.HF_TOKEN);
382
- case "ollama":
383
- case "local":
384
- case "local-ollama":
385
- // For Ollama, we check if the service is potentially available
386
- // This is a basic check - actual connectivity will be verified during usage
387
- return true; // Ollama doesn't require environment variables, just local service
388
- case "mistral":
389
- case "mistral-ai":
390
- case "mistralai":
391
- return !!process.env.MISTRAL_API_KEY;
392
- case "litellm":
393
- // LiteLLM requires a proxy server, which can be checked for availability
394
- // Default base URL is assumed, or can be configured via environment
395
- return true; // LiteLLM proxy availability will be checked during usage
396
- default:
397
- return false;
328
+ const descriptor = ProviderFactory.getDescriptor(provider);
329
+ if (!descriptor) {
330
+ return false;
331
+ }
332
+ if (descriptor.envVars.optional || descriptor.localRuntime) {
333
+ // Ollama / LiteLLM / LM Studio / llama.cpp: usable with defaults.
334
+ return true;
335
+ }
336
+ const { apiKey, fallbacks, extraRequired, extraRequiredFallbacks } = descriptor.envVars;
337
+ const hasPrimary = !!apiKey &&
338
+ (!!process.env[apiKey] || (fallbacks ?? []).some((v) => !!process.env[v]));
339
+ if (!hasPrimary) {
340
+ return false;
398
341
  }
342
+ return ((extraRequired ?? []).every((v) => !!process.env[v]) ||
343
+ (extraRequiredFallbacks ?? []).some((v) => !!process.env[v]));
399
344
  }
400
345
  /**
401
346
  * Get available provider names
402
347
  * @returns Array of available provider names
403
348
  */
404
349
  export function getAvailableProviders() {
405
- return [
406
- "bedrock",
407
- "vertex",
408
- "openai",
409
- "anthropic",
410
- "azure",
411
- "google-ai",
412
- "litellm",
413
- "huggingface",
414
- "ollama",
415
- "mistral",
416
- ];
350
+ return PROVIDER_DESCRIPTORS.map((d) => d.name);
417
351
  }
418
352
  /**
419
353
  * Validate provider name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juspay/neurolink",
3
- "version": "10.12.9",
3
+ "version": "11.1.0",
4
4
  "packageManager": "pnpm@10.15.1",
5
5
  "description": "TypeScript AI SDK with 24+ LLM providers behind one consistent API. MCP-native (connect any MCP server), voice TTS/STT/realtime, RAG, agents, memory, context compaction. OpenAI · Anthropic · Gemini · Bedrock · Azure · Ollama · DeepSeek · NVIDIA NIM and more.",
6
6
  "author": {
@@ -71,26 +71,19 @@
71
71
  "test": "npx tsx test/continuous-test-suite.ts",
72
72
  "test:client": "npx tsx test/continuous-test-suite-client.ts",
73
73
  "test:context": "npx tsx test/continuous-test-suite-context.ts",
74
- "test:cache": "npx tsx test/continuous-test-suite-cache-breakpoints.ts",
75
74
  "test:evaluation": "npx tsx test/continuous-test-suite-evaluation.ts",
76
75
  "test:mcp": "npx tsx test/continuous-test-suite-mcp-infra.ts",
77
76
  "test:tool-resolution": "npx tsx test/continuous-test-suite-tool-resolution.ts",
78
77
  "test:mcp:http": "npx tsx test/continuous-test-suite-mcp-http.ts",
79
78
  "test:mcp:sdk": "npx tsx test/continuous-test-suite-mcp-sdk.ts",
80
79
  "test:mcp:cli": "npx tsx test/continuous-test-suite-mcp-cli.ts",
81
- "test:mcp:full": "pnpm run test:mcp:infra && pnpm run test:mcp:bash && pnpm run test:mcp:limits && pnpm run test:mcp:spans && pnpm run test:mcp:sdk && pnpm run test:mcp:cli && pnpm run test:mcp:http",
80
+ "test:mcp:full": "pnpm run test:mcp:infra && pnpm run test:mcp:spans && pnpm run test:mcp:sdk && pnpm run test:mcp:cli && pnpm run test:mcp:http",
82
81
  "test:media": "npx tsx test/continuous-test-suite-media-gen.ts",
83
- "test:litellm-parity": "npx tsx test/continuous-test-suite-litellm-parity.ts",
84
82
  "test:memory": "npx tsx test/continuous-test-suite-memory.ts",
85
- "test:tool-pairing": "npx tsx test/continuous-test-suite-tool-pairing.ts",
86
- "test:token-accounting": "npx tsx test/continuous-test-suite-token-accounting.ts",
87
- "test:step-guard": "npx tsx test/continuous-test-suite-step-guard.ts",
88
- "test:loop-guard-core": "npx tsx test/continuous-test-suite-loop-guard-core.ts",
89
- "test:openai-compat-guard": "npx tsx test/continuous-test-suite-openai-compat-guard.ts",
90
- "test:anthropic-guard": "npx tsx test/continuous-test-suite-anthropic-guard.ts",
91
- "test:tool-storage-parity": "npx tsx test/continuous-test-suite-tool-storage-parity.ts",
92
- "test:redis-append-only": "npx tsx test/continuous-test-suite-redis-append-only.ts",
93
- "test:gemini-guard": "npx tsx test/continuous-test-suite-gemini-guard.ts",
83
+ "test:openai-compat-streaming-retry": "npx tsx test/continuous-test-suite-openai-compat-streaming-retry.ts",
84
+ "test:anthropic-streaming-retry": "npx tsx test/continuous-test-suite-anthropic-streaming-retry.ts",
85
+ "test:error-classification-e2e": "npx tsx test/continuous-test-suite-error-classification-e2e.ts",
86
+ "test:error-classifier-contract": "npx tsx test/continuous-test-suite-error-classifier-contract.ts",
94
87
  "test:middleware": "npx tsx test/continuous-test-suite-middleware.ts",
95
88
  "test:observability": "npx tsx test/continuous-test-suite-observability.ts",
96
89
  "test:ppt": "npx tsx test/continuous-test-suite-ppt.ts",
@@ -99,76 +92,43 @@
99
92
  "test:matrix": "npx tsx test/continuous-test-suite-provider-matrix.ts",
100
93
  "test:matrix:cli": "npx tsx test/continuous-test-suite-provider-matrix-cli.ts",
101
94
  "test:mcp:spans": "npx tsx test/continuous-test-suite-mcp-spans.ts",
102
- "test:mcp:bash": "npx tsx test/continuous-test-suite-mcp-bash.ts",
103
- "test:mcp:limits": "npx tsx test/continuous-test-suite-mcp-output-limits.ts",
104
95
  "test:mcp:infra": "npx tsx test/continuous-test-suite-mcp-infra.ts",
105
96
  "test:providers-mocked": "npx tsx test/continuous-test-suite-providers-mocked.ts",
97
+ "test:provider-descriptors": "npx tsx test/continuous-test-suite-provider-descriptors.ts",
98
+ "test:provider-structure": "npx tsx test/continuous-test-suite-provider-structure.ts",
106
99
  "test:provider-fallback": "npx tsx test/continuous-test-suite-provider-fallback.ts",
107
100
  "test:provider-fallback-latency": "npx tsx test/continuous-test-suite-provider-fallback-latency.ts",
101
+ "test:provider-wiring": "npx tsx test/continuous-test-suite-provider-wiring.ts",
108
102
  "test:rag": "npx tsx test/continuous-test-suite-rag.ts",
109
- "test:vector-pinecone": "npx tsx test/continuous-test-suite-vector-pinecone.ts",
110
- "test:vector-pgvector": "npx tsx test/continuous-test-suite-vector-pgvector.ts",
111
- "test:vector-chroma": "npx tsx test/continuous-test-suite-vector-chroma.ts",
112
103
  "test:skills": "npx tsx test/continuous-test-suite-skills.ts",
113
104
  "test:servers": "npx tsx test/continuous-test-suite-servers.ts",
114
105
  "test:tool-reliability": "npx tsx test/continuous-test-suite-tool-reliability.ts",
115
- "test:google-native": "npx tsx test/continuous-test-suite-google-native.ts",
116
- "test:gemini-abort": "npx tsx test/continuous-test-suite-gemini-abort.ts",
117
- "test:anthropic-cap": "npx tsx test/continuous-test-suite-anthropic-cap.ts",
118
- "test:token-usage": "npx tsx test/continuous-test-suite-token-usage.ts",
119
106
  "test:tts": "npx tsx test/continuous-test-suite-tts.ts",
120
107
  "test:voice": "npx tsx test/continuous-test-suite-voice.ts",
121
- "test:voice-server": "npx tsx test/continuous-test-suite-voice-server.ts",
122
108
  "test:avatar": "npx tsx test/continuous-test-suite-avatar.ts",
123
109
  "test:music": "npx tsx test/continuous-test-suite-music.ts",
124
110
  "test:image-gen": "npx tsx test/continuous-test-suite-image-gen-extras.ts",
125
- "test:ssrf": "npx tsx test/continuous-test-suite-ssrf.ts",
126
- "test:log-sanitize": "npx tsx test/continuous-test-suite-log-sanitize.ts",
127
- "test:sse-client": "npx tsx test/continuous-test-suite-sse-client.ts",
128
- "test:stream-span": "npx tsx test/continuous-test-suite-stream-span.ts",
129
- "test:vertex-langfuse-spans": "npx tsx test/continuous-test-suite-vertex-langfuse-spans.ts",
130
111
  "test:credentials": "npx tsx test/continuous-test-suite-credentials.ts",
131
112
  "test:dynamic": "npx tsx test/continuous-test-suite-dynamic.ts",
132
113
  "test:proxy": "npx tsx test/continuous-test-suite-proxy.ts",
133
114
  "test:bugfixes": "npx tsx test/continuous-test-suite-bugfixes.ts",
134
- "test:file-detector-extension": "npx tsx test/continuous-test-suite-file-detector-extension.ts",
135
- "test:file-detector-magic-bytes": "npx tsx test/continuous-test-suite-file-detector-magic-bytes.ts",
136
- "test:json": "npx tsx test/continuous-test-suite-json.ts",
137
115
  "test:json-e2e": "npx tsx test/continuous-test-suite-json-e2e.ts",
138
- "test:coerce-truncation": "npx tsx test/continuous-test-suite-coerce-truncation.ts",
139
116
  "test:workflow": "npx tsx test/continuous-test-suite-workflow.ts",
140
117
  "test:hitl": "npx tsx test/continuous-test-suite-hitl.ts",
141
- "test:analytics": "npx tsx test/continuous-test-suite-analytics.ts",
142
118
  "test:tasks": "npx tsx test/continuous-test-suite-tasks.ts",
143
119
  "test:auth": "npx tsx test/continuous-test-suite-auth.ts",
144
120
  "test:autoresearch": "npx tsx test/continuous-test-suite-autoresearch.ts",
145
- "test:autoresearch:redis": "npx tsx test/continuous-test-suite-autoresearch-redis.ts",
146
- "test:anthropic-tools-policy": "npx tsx test/continuous-test-suite-anthropic-tools-policy.ts",
147
- "test:anthropic-structured": "npx tsx test/continuous-test-suite-anthropic-structured-tools.ts",
148
- "test:sagemaker-tools": "npx tsx test/continuous-test-suite-sagemaker-tools.ts",
149
- "test:anthropic-multimodal": "npx tsx test/continuous-test-suite-anthropic-multimodal.ts",
150
- "test:unified-files-prompt-sync": "npx tsx test/continuous-test-suite-unified-files-prompt-sync.ts",
151
- "test:excel-interop": "npx tsx test/continuous-test-suite-excel-interop.ts",
152
- "test:envguard": "npx tsx test/helpers/envGuard.test.ts",
153
- "test:tool-routing-cli": "npx tsx test/continuous-test-suite-tool-routing-flags.ts && npx tsx test/continuous-test-suite-tool-routing-cli.ts",
121
+ "test:tool-routing-cli": "npx tsx test/continuous-test-suite-tool-routing-cli.ts",
154
122
  "test:tool-dedup": "npx tsx test/continuous-test-suite-tool-dedup.ts",
155
- "test:model-pool": "npx tsx test/continuous-test-suite-model-pool.ts",
156
123
  "test:model-not-found-retryable": "npx tsx test/continuous-test-suite-model-not-found-retryable.ts",
157
- "test:model-capabilities": "npx tsx test/continuous-test-suite-model-capabilities.ts",
158
- "test:agent-runtime:vitest": "pnpm exec vitest run test/agentRuntime.test.ts",
159
- "test:retry-after:vitest": "pnpm exec vitest run test/retryAfter.test.ts",
160
- "test:websearch-grounding": "npx tsx test/continuous-test-suite-websearch-grounding.ts",
161
124
  "test:ci": "pnpm run test && pnpm run test:client && pnpm run test:hitl",
162
- "// CI tier — fast, no live AI calls, safe for every commit": "",
125
+ "// CI tier — fast, no live AI calls, safe for every commit (test:unit; also see the separate provider-safety-net CI job, which runs build + test:providers-mocked + test:provider-structure on every PR)": "",
163
126
  "test:tool-routing": "npx tsx test/continuous-test-suite-tool-routing.ts",
164
- "test:classifier-router": "npx tsx test/continuous-test-suite-classifier-router.ts",
165
- "test:system-messages": "npx tsx test/continuous-test-suite-system-messages.ts",
166
- "test:test-stubs": "npx tsx test/continuous-test-suite-test-stubs.ts",
167
127
  "test:tool-routing-semantic": "npx tsx test/continuous-test-suite-tool-routing-semantic.ts",
168
- "test:unit": "pnpm run test:envguard && pnpm run test:bugfixes && pnpm run test:file-detector-extension && pnpm run test:file-detector-magic-bytes && pnpm run test:mcp:infra && pnpm run test:mcp:bash && pnpm run test:mcp:limits && pnpm run test:mcp:spans && pnpm run test:autoresearch:redis && pnpm run test:tool-routing && pnpm run test:tool-routing-cli && pnpm run test:tool-dedup && pnpm run test:model-pool && pnpm run test:litellm-context && pnpm run test:dedup-execute-map && pnpm run test:step-budget-guard && pnpm run test:agent-plumbing && pnpm run test:tool-execution-recorder && pnpm run test:proxy-terminal-errors && pnpm run test:proxy-usage-refresh && pnpm run test:system-messages && pnpm run test:tool-routing-semantic && pnpm run test:anthropic-tools-policy && pnpm run test:anthropic-structured && pnpm run test:sagemaker-tools && pnpm run test:anthropic-multimodal && pnpm run test:unified-files-prompt-sync && pnpm run test:excel-interop && pnpm run test:model-capabilities && pnpm run test:agent-runtime:vitest && pnpm run test:agent-delegation && pnpm run test:retry-after:vitest && pnpm run test:sampling-params && pnpm run test:structured-recovery && pnpm run test:prompt-redaction && pnpm run test:mcp-result-cache && pnpm run test:test-stubs && pnpm run test:model-not-found-retryable && pnpm run test:websearch-grounding && pnpm run test:archive:security && pnpm run test:office:security && pnpm run test:proxy:vitest",
169
- "// CI tier — live providers, runs only when API keys are present (test:credentials and test:dynamic make real provider calls when keys are set, so they live here, not in test:unit)": "",
128
+ "test:unit": "pnpm run test:bugfixes && pnpm run test:mcp:infra && pnpm run test:mcp:spans && pnpm run test:tool-routing && pnpm run test:tool-routing-cli && pnpm run test:tool-dedup && pnpm run test:model-pool && pnpm run test:tool-routing-semantic && pnpm run test:mcp-result-cache && pnpm run test:model-not-found-retryable && pnpm run test:archive:security && pnpm run test:office:security && pnpm run test:vector-chroma && pnpm run test:vector-pgvector && pnpm run test:vector-pinecone && pnpm run test:provider-wiring",
129
+ "// CI tier — live providers, runs only when API keys are present (test:credentials and test:dynamic make real provider calls when keys are set, so they live here, not in test:unit; test:matrix, a different suite covering the full provider capability matrix, runs nightly via .github/workflows/live-matrix.yml — test:providers itself is still only wired into test:live, not any GitHub Actions workflow)": "",
170
130
  "test:live": "pnpm run test:providers && pnpm run test:mcp:http && pnpm run test:mcp:sdk && pnpm run test:mcp:cli && pnpm run test:observability && pnpm run test:context && pnpm run test:memory && pnpm run test:tool-reliability && pnpm run test:evaluation && pnpm run test:autoresearch && pnpm run test:credentials && pnpm run test:dynamic",
171
- "// CI tier — product output (image/video/TTS/PPT) — costs $$ per run": "",
131
+ "// CI tier — product output (image/video/TTS/PPT) — costs $$ per run (not wired into any GitHub Actions workflow as of this comment; run manually or add to live-matrix.yml if nightly coverage is needed)": "",
172
132
  "test:product": "pnpm run test:media && pnpm run test:tts && pnpm run test:ppt && pnpm run test:proxy",
173
133
  "test:performance": "tsx tools/testing/performanceMonitor.ts",
174
134
  "// Content Generation (Cross-platform JS)": "",
@@ -225,32 +185,18 @@
225
185
  "quality:metrics": "tsx scripts/quality-metrics.ts",
226
186
  "quality:report": "pnpm run quality:metrics && echo 'Quality metrics saved to quality-metrics.json'",
227
187
  "pre-commit": "lint-staged",
228
- "pre-push": "pnpm run validate:commit && pnpm run validate:env && pnpm run validate && pnpm run test:ci",
188
+ "pre-push": "pnpm run build && pnpm run test:providers-mocked && pnpm run test:provider-structure",
229
189
  "check:all": "pnpm run lint && pnpm run format --check && pnpm run validate && pnpm run validate:commit",
230
- "test:litellm-context": "npx tsx test/continuous-test-suite-litellm-context-windows.ts",
231
- "test:dedup-execute-map": "npx tsx test/continuous-test-suite-dedup-execute-map.ts",
232
- "test:agent-delegation": "npx tsx test/continuous-test-suite-agent-delegation.ts",
233
- "test:step-budget-guard": "npx tsx test/continuous-test-suite-step-budget-guard.ts",
234
- "test:agent-plumbing": "npx tsx test/continuous-test-suite-agent-plumbing.ts",
235
- "test:tool-execution-recorder": "npx tsx test/continuous-test-suite-tool-execution-recorder.ts",
236
- "test:proxy-terminal-errors": "npx tsx test/continuous-test-suite-proxy-terminal-errors.ts",
237
- "test:proxy-limit-headers": "npx tsx test/continuous-test-suite-proxy-limit-headers.ts",
238
- "test:proxy-usage-refresh": "npx tsx test/continuous-test-suite-proxy-usage-refresh.ts",
239
- "test:proxy:vitest": "pnpm exec vitest run test/proxyAnalysis.test.ts test/proxyConfigHotReload.test.ts test/proxyObservabilityFoundation.test.ts test/proxyReliabilityHardening.test.ts test/proxyReplay.test.ts test/proxyRollingWorkerHandoff.test.ts test/proxyTestIsolation.test.ts test/proxyUpdaterFallback.test.ts test/proxyUsageStatsPersistence.test.ts",
240
- "test:anthropic-limit-capture": "npx tsx test/continuous-test-suite-anthropic-limit-capture.ts",
241
- "test:audio": "npx tsx test/continuous-test-suite-audio.ts",
242
190
  "test:file-formats": "npx tsx test/continuous-test-suite-file-formats.ts",
243
- "test:office": "npx tsx test/continuous-test-suite-office.ts",
244
- "test:tts:unit": "npx tsx test/continuous-test-suite-tts-unit.ts",
245
- "test:video": "npx tsx test/continuous-test-suite-video.ts",
246
- "test:multimodal": "pnpm run test:file-formats && pnpm run test:audio && pnpm run test:video && pnpm run test:office && pnpm run test:tts:unit && pnpm run test:multimodal:sdk",
191
+ "test:multimodal": "pnpm run test:file-formats && pnpm run test:multimodal:sdk",
247
192
  "test:multimodal:sdk": "npx tsx test/continuous-test-suite-multimodal-sdk.ts",
248
- "test:sampling-params": "npx tsx test/continuous-test-suite-sampling-params.ts",
249
- "test:structured-recovery": "npx tsx test/continuous-test-suite-structured-recovery.ts",
250
- "test:prompt-redaction": "npx tsx test/continuous-test-suite-prompt-redaction.ts",
251
193
  "test:mcp-result-cache": "npx tsx test/continuous-test-suite-mcp-result-cache.ts",
252
194
  "test:archive:security": "npx tsx test/continuous-test-suite-archive-security.ts",
253
- "test:office:security": "npx tsx test/continuous-test-suite-office-security.ts"
195
+ "test:office:security": "npx tsx test/continuous-test-suite-office-security.ts",
196
+ "test:model-pool": "npx tsx test/continuous-test-suite-model-pool.ts",
197
+ "test:vector-chroma": "npx tsx test/continuous-test-suite-vector-chroma.ts",
198
+ "test:vector-pgvector": "npx tsx test/continuous-test-suite-vector-pgvector.ts",
199
+ "test:vector-pinecone": "npx tsx test/continuous-test-suite-vector-pinecone.ts"
254
200
  },
255
201
  "files": [
256
202
  "dist",
@@ -1,7 +0,0 @@
1
- import type { AnthropicAuthMethod, AnthropicRateLimitInfo, ClaudeSubscriptionTier, OAuthToken } from "../../types/index.js";
2
- export declare const getAnthropicApiKey: () => string;
3
- export declare const getDefaultAnthropicModel: () => string;
4
- export declare const getOAuthToken: () => OAuthToken | null;
5
- export declare const detectSubscriptionTier: (oauthToken: OAuthToken | null) => ClaudeSubscriptionTier;
6
- export declare const detectAuthMethod: (oauthToken: OAuthToken | null) => AnthropicAuthMethod;
7
- export declare const parseRateLimitHeaders: (headers: Headers | Record<string, string>) => AnthropicRateLimitInfo;