@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
@@ -0,0 +1,537 @@
1
+ import { AIProviderName } from "../constants/enums.js";
2
+ import { GoogleAIModels, OpenAIModels, AnthropicModels, VertexModels, MistralModels, OllamaModels, LiteLLMModels, HuggingFaceModels, DeepSeekModels, NvidiaNimModels, OpenRouterModels, XaiModels, GroqModels, CohereModels, TogetherAIModels, FireworksModels, PerplexityModels, CloudflareModels, VoyageModels, JinaModels, StabilityModels, IdeogramModels, RecraftModels, ReplicateModels, } from "../constants/enums.js";
3
+ import { API_KEY_FORMATS } from "../utils/providerConfig.js";
4
+ /**
5
+ * Single source of truth for provider identity, credentials, defaults, and
6
+ * runtime behavior classification. Pure data — no provider-class imports,
7
+ * no dynamic import(), no side effects beyond building the two derived
8
+ * lookup maps below. Order follows the AIProviderName enum declaration
9
+ * order (enums.ts:8-40) so this file stays easy to diff against it.
10
+ */
11
+ export const PROVIDER_DESCRIPTORS = [
12
+ {
13
+ name: AIProviderName.BEDROCK,
14
+ aliases: ["aws"],
15
+ credentialsKey: "bedrock",
16
+ envVars: {
17
+ apiKey: "AWS_ACCESS_KEY_ID",
18
+ extraRequired: ["AWS_SECRET_ACCESS_KEY"],
19
+ model: "BEDROCK_MODEL",
20
+ },
21
+ defaultModel: "",
22
+ toolSupport: "native",
23
+ localRuntime: false,
24
+ healthCheck: "env-only",
25
+ setupUrl: "https://console.aws.amazon.com/iam/",
26
+ timeouts: { generateMs: 45_000, streamMs: 120_000 },
27
+ autoSelectPriority: 7,
28
+ apiKeyFormatPattern: API_KEY_FORMATS.bedrock,
29
+ },
30
+ {
31
+ name: AIProviderName.OPENAI,
32
+ aliases: ["gpt", "chatgpt"],
33
+ credentialsKey: "openai",
34
+ envVars: { apiKey: "OPENAI_API_KEY", baseURL: "OPENAI_BASE_URL" },
35
+ defaultModel: OpenAIModels.GPT_4O_MINI,
36
+ toolSupport: "native",
37
+ localRuntime: false,
38
+ healthCheck: "models-probe",
39
+ setupUrl: "https://platform.openai.com/api-keys",
40
+ timeouts: { generateMs: 30_000, streamMs: 120_000 },
41
+ autoSelectPriority: 5,
42
+ apiKeyFormatPattern: API_KEY_FORMATS.openai,
43
+ },
44
+ {
45
+ name: AIProviderName.OPENAI_COMPATIBLE,
46
+ aliases: ["vllm", "compatible"],
47
+ credentialsKey: "openaiCompatible",
48
+ envVars: {
49
+ apiKey: "OPENAI_COMPATIBLE_API_KEY",
50
+ baseURL: "OPENAI_COMPATIBLE_BASE_URL",
51
+ model: "OPENAI_COMPATIBLE_MODEL",
52
+ },
53
+ defaultModel: "",
54
+ toolSupport: "native",
55
+ localRuntime: false,
56
+ healthCheck: "env-only",
57
+ },
58
+ {
59
+ name: AIProviderName.OPENROUTER,
60
+ aliases: ["or"],
61
+ credentialsKey: "openrouter",
62
+ envVars: {
63
+ apiKey: "OPENROUTER_API_KEY",
64
+ baseURL: "OPENROUTER_BASE_URL",
65
+ model: "OPENROUTER_MODEL",
66
+ },
67
+ defaultModel: OpenRouterModels.CLAUDE_SONNET_4_5,
68
+ toolSupport: "model-dependent",
69
+ localRuntime: false,
70
+ healthCheck: "env-only",
71
+ setupUrl: "https://openrouter.ai/keys",
72
+ },
73
+ {
74
+ name: AIProviderName.VERTEX,
75
+ aliases: ["googleVertex"],
76
+ credentialsKey: "vertex",
77
+ envVars: {
78
+ // "apiKey" here names the primary identity env var, not a secret —
79
+ // Vertex's real auth is the extraRequired file-or-individual-creds
80
+ // check below. See checkVertexAuthentication() in providerHealth.ts.
81
+ apiKey: "GOOGLE_CLOUD_PROJECT_ID",
82
+ fallbacks: [
83
+ "VERTEX_PROJECT_ID",
84
+ "GOOGLE_VERTEX_PROJECT",
85
+ "GOOGLE_CLOUD_PROJECT",
86
+ ],
87
+ extraRequired: ["GOOGLE_APPLICATION_CREDENTIALS"],
88
+ // GOOGLE_APPLICATION_CREDENTIALS_NEUROLINK is checked with higher
89
+ // priority than GOOGLE_APPLICATION_CREDENTIALS by the real gating
90
+ // logic (hasGoogleCredentials() in googleVertex/client.ts and
91
+ // googleVertex/utils.ts) — corrected here vs. the plan snippet, which
92
+ // omitted it.
93
+ extraRequiredFallbacks: [
94
+ "GOOGLE_APPLICATION_CREDENTIALS_NEUROLINK",
95
+ "GOOGLE_SERVICE_ACCOUNT_KEY",
96
+ "GOOGLE_AUTH_CLIENT_EMAIL",
97
+ "GOOGLE_AUTH_PRIVATE_KEY",
98
+ ],
99
+ },
100
+ defaultModel: VertexModels.CLAUDE_4_6_SONNET,
101
+ toolSupport: "native",
102
+ localRuntime: false,
103
+ healthCheck: "env-only",
104
+ setupUrl: "https://console.cloud.google.com/",
105
+ timeouts: { generateMs: 60_000, streamMs: 120_000 },
106
+ autoSelectPriority: 3,
107
+ },
108
+ {
109
+ name: AIProviderName.ANTHROPIC,
110
+ aliases: ["claude"],
111
+ credentialsKey: "anthropic",
112
+ envVars: {
113
+ apiKey: "ANTHROPIC_API_KEY",
114
+ fallbacks: [
115
+ "ANTHROPIC_OAUTH_TOKEN",
116
+ "CLAUDE_OAUTH_TOKEN",
117
+ "ANTHROPIC_OAUTH_ACCESS_TOKEN",
118
+ ],
119
+ baseURL: "ANTHROPIC_BASE_URL",
120
+ },
121
+ defaultModel: AnthropicModels.CLAUDE_SONNET_4_6,
122
+ toolSupport: "native",
123
+ localRuntime: false,
124
+ healthCheck: "env-only",
125
+ setupUrl: "https://console.anthropic.com/settings/keys",
126
+ timeouts: { generateMs: 60_000, streamMs: 120_000 },
127
+ autoSelectPriority: 6,
128
+ apiKeyFormatPattern: API_KEY_FORMATS.anthropic,
129
+ },
130
+ {
131
+ name: AIProviderName.AZURE,
132
+ aliases: ["azureOpenai"],
133
+ credentialsKey: "azure",
134
+ envVars: {
135
+ apiKey: "AZURE_OPENAI_API_KEY",
136
+ extraRequired: ["AZURE_OPENAI_ENDPOINT"],
137
+ model: "AZURE_MODEL",
138
+ modelFallbacks: [
139
+ "AZURE_OPENAI_MODEL",
140
+ "AZURE_OPENAI_DEPLOYMENT",
141
+ "AZURE_OPENAI_DEPLOYMENT_ID",
142
+ ],
143
+ },
144
+ defaultModel: "gpt-4o-mini",
145
+ toolSupport: "native",
146
+ localRuntime: false,
147
+ healthCheck: "env-only",
148
+ setupUrl: "https://portal.azure.com/",
149
+ timeouts: { generateMs: 30_000, streamMs: 120_000 },
150
+ autoSelectPriority: 8,
151
+ apiKeyFormatPattern: API_KEY_FORMATS.azure,
152
+ },
153
+ {
154
+ name: AIProviderName.GOOGLE_AI,
155
+ aliases: ["googleAiStudio", "google", "gemini", "google-ai-studio"],
156
+ credentialsKey: "googleAiStudio",
157
+ envVars: {
158
+ apiKey: "GOOGLE_AI_API_KEY",
159
+ fallbacks: ["GOOGLE_GENERATIVE_AI_API_KEY"],
160
+ baseURL: "GOOGLE_AI_BASE_URL",
161
+ },
162
+ defaultModel: GoogleAIModels.GEMINI_2_5_FLASH,
163
+ toolSupport: "native",
164
+ localRuntime: false,
165
+ healthCheck: "env-only",
166
+ setupUrl: "https://aistudio.google.com/apikey",
167
+ timeouts: { generateMs: 30_000, streamMs: 120_000 },
168
+ autoSelectPriority: 4,
169
+ apiKeyFormatPattern: API_KEY_FORMATS["google-ai"],
170
+ },
171
+ {
172
+ name: AIProviderName.HUGGINGFACE,
173
+ aliases: ["hf"],
174
+ credentialsKey: "huggingFace",
175
+ envVars: {
176
+ // Only HF_TOKEN is an actual accepted fallback — confirmed against
177
+ // createHuggingFaceConfig() in providerConfig.ts, which is the only
178
+ // place the huggingFace/client.ts provider resolves its key from.
179
+ // The plan snippet additionally listed HUGGINGFACE_API_TOKEN and
180
+ // HF_API_TOKEN, but neither is read anywhere in the codebase; removed.
181
+ apiKey: "HUGGINGFACE_API_KEY",
182
+ fallbacks: ["HF_TOKEN"],
183
+ baseURL: "HUGGINGFACE_BASE_URL",
184
+ model: "HUGGINGFACE_MODEL",
185
+ },
186
+ defaultModel: HuggingFaceModels.QWEN_2_5_72B_INSTRUCT,
187
+ toolSupport: "model-dependent",
188
+ localRuntime: false,
189
+ healthCheck: "env-only",
190
+ setupUrl: "https://huggingface.co/settings/tokens",
191
+ timeouts: { generateMs: 120_000, streamMs: 120_000 },
192
+ autoSelectPriority: 10,
193
+ apiKeyFormatPattern: API_KEY_FORMATS.huggingface,
194
+ },
195
+ {
196
+ name: AIProviderName.OLLAMA,
197
+ aliases: ["local"],
198
+ credentialsKey: "ollama",
199
+ envVars: {
200
+ baseURL: "OLLAMA_BASE_URL",
201
+ baseURLFallbacks: ["OLLAMA_API_BASE"],
202
+ model: "OLLAMA_MODEL",
203
+ optional: true,
204
+ },
205
+ defaultModel: OllamaModels.LLAMA3_2_LATEST,
206
+ toolSupport: "model-dependent",
207
+ localRuntime: true,
208
+ healthCheck: "models-probe",
209
+ setupUrl: "https://ollama.com/download",
210
+ timeouts: { generateMs: 300_000, streamMs: 120_000 },
211
+ autoSelectPriority: 2,
212
+ },
213
+ {
214
+ name: AIProviderName.MISTRAL,
215
+ aliases: [],
216
+ credentialsKey: "mistral",
217
+ envVars: { apiKey: "MISTRAL_API_KEY", baseURL: "MISTRAL_BASE_URL" },
218
+ defaultModel: MistralModels.MISTRAL_LARGE_LATEST,
219
+ toolSupport: "native",
220
+ localRuntime: false,
221
+ healthCheck: "env-only",
222
+ setupUrl: "https://console.mistral.ai/api-keys",
223
+ timeouts: { generateMs: 45_000, streamMs: 120_000 },
224
+ autoSelectPriority: 9,
225
+ apiKeyFormatPattern: API_KEY_FORMATS.mistral,
226
+ },
227
+ {
228
+ name: AIProviderName.LITELLM,
229
+ aliases: [],
230
+ credentialsKey: "litellm",
231
+ envVars: {
232
+ apiKey: "LITELLM_API_KEY",
233
+ baseURL: "LITELLM_BASE_URL",
234
+ model: "LITELLM_MODEL",
235
+ optional: true,
236
+ },
237
+ defaultModel: LiteLLMModels.OPENAI_GPT_4O_MINI,
238
+ toolSupport: "native",
239
+ localRuntime: false,
240
+ healthCheck: "models-probe",
241
+ setupUrl: "https://docs.litellm.ai/docs/proxy/quick_start",
242
+ timeouts: { generateMs: 300_000, streamMs: 120_000 },
243
+ autoSelectPriority: 1,
244
+ },
245
+ {
246
+ name: AIProviderName.SAGEMAKER,
247
+ aliases: ["aws-sagemaker"],
248
+ credentialsKey: "sagemaker",
249
+ envVars: {
250
+ apiKey: "AWS_ACCESS_KEY_ID",
251
+ extraRequired: ["AWS_SECRET_ACCESS_KEY"],
252
+ model: "SAGEMAKER_MODEL",
253
+ modelFallbacks: [
254
+ "SAGEMAKER_MODEL_NAME",
255
+ "SAGEMAKER_DEFAULT_ENDPOINT",
256
+ "SAGEMAKER_ENDPOINT_NAME",
257
+ ],
258
+ baseURL: "SAGEMAKER_ENDPOINT",
259
+ },
260
+ defaultModel: "sagemaker-model",
261
+ toolSupport: "native",
262
+ localRuntime: false,
263
+ // Deliberate: SageMaker has no models-list endpoint, so a live
264
+ // minimal generate() call is the only real reachability check
265
+ // (mirrors providerUtils.isProviderAvailable()'s legacy fallback).
266
+ healthCheck: "live-generate",
267
+ setupUrl: "https://console.aws.amazon.com/iam/",
268
+ apiKeyFormatPattern: API_KEY_FORMATS.aws,
269
+ },
270
+ {
271
+ name: AIProviderName.DEEPSEEK,
272
+ aliases: ["ds"],
273
+ credentialsKey: "deepseek",
274
+ envVars: {
275
+ apiKey: "DEEPSEEK_API_KEY",
276
+ baseURL: "DEEPSEEK_BASE_URL",
277
+ model: "DEEPSEEK_MODEL",
278
+ },
279
+ defaultModel: DeepSeekModels.DEEPSEEK_CHAT,
280
+ toolSupport: "native",
281
+ localRuntime: false,
282
+ healthCheck: "env-only",
283
+ setupUrl: "https://platform.deepseek.com/api_keys",
284
+ },
285
+ {
286
+ name: AIProviderName.NVIDIA_NIM,
287
+ aliases: ["nvidia", "nim"],
288
+ credentialsKey: "nvidiaNim",
289
+ envVars: {
290
+ apiKey: "NVIDIA_NIM_API_KEY",
291
+ baseURL: "NVIDIA_NIM_BASE_URL",
292
+ model: "NVIDIA_NIM_MODEL",
293
+ },
294
+ defaultModel: NvidiaNimModels.LLAMA_3_3_70B_INSTRUCT,
295
+ toolSupport: "native",
296
+ localRuntime: false,
297
+ healthCheck: "env-only",
298
+ setupUrl: "https://build.nvidia.com/settings/api-keys",
299
+ },
300
+ {
301
+ name: AIProviderName.LM_STUDIO,
302
+ aliases: ["lmstudio", "lms"],
303
+ credentialsKey: "lmStudio",
304
+ envVars: {
305
+ baseURL: "LM_STUDIO_BASE_URL",
306
+ model: "LM_STUDIO_MODEL",
307
+ optional: true,
308
+ },
309
+ defaultModel: "",
310
+ toolSupport: "native",
311
+ localRuntime: true,
312
+ healthCheck: "env-only",
313
+ setupUrl: "https://lmstudio.ai/",
314
+ },
315
+ {
316
+ name: AIProviderName.LLAMACPP,
317
+ aliases: ["llama.cpp", "llama-cpp"],
318
+ credentialsKey: "llamacpp",
319
+ envVars: {
320
+ baseURL: "LLAMACPP_BASE_URL",
321
+ model: "LLAMACPP_MODEL",
322
+ optional: true,
323
+ },
324
+ defaultModel: "",
325
+ toolSupport: "native",
326
+ localRuntime: true,
327
+ healthCheck: "env-only",
328
+ setupUrl: "https://github.com/ggerganov/llama.cpp",
329
+ },
330
+ {
331
+ name: AIProviderName.XAI,
332
+ aliases: ["grok"],
333
+ credentialsKey: "xai",
334
+ envVars: {
335
+ apiKey: "XAI_API_KEY",
336
+ baseURL: "XAI_BASE_URL",
337
+ model: "XAI_MODEL",
338
+ },
339
+ defaultModel: XaiModels.GROK_3,
340
+ toolSupport: "native",
341
+ localRuntime: false,
342
+ healthCheck: "env-only",
343
+ setupUrl: "https://console.x.ai/",
344
+ },
345
+ {
346
+ name: AIProviderName.GROQ,
347
+ aliases: [],
348
+ credentialsKey: "groq",
349
+ envVars: {
350
+ apiKey: "GROQ_API_KEY",
351
+ baseURL: "GROQ_BASE_URL",
352
+ model: "GROQ_MODEL",
353
+ },
354
+ defaultModel: GroqModels.LLAMA_3_3_70B_VERSATILE,
355
+ toolSupport: "native",
356
+ localRuntime: false,
357
+ healthCheck: "env-only",
358
+ setupUrl: "https://console.groq.com/keys",
359
+ },
360
+ {
361
+ name: AIProviderName.COHERE,
362
+ aliases: [],
363
+ credentialsKey: "cohere",
364
+ envVars: {
365
+ apiKey: "COHERE_API_KEY",
366
+ baseURL: "COHERE_BASE_URL",
367
+ model: "COHERE_MODEL",
368
+ },
369
+ defaultModel: CohereModels.COMMAND_R_PLUS,
370
+ toolSupport: "native",
371
+ localRuntime: false,
372
+ healthCheck: "env-only",
373
+ setupUrl: "https://dashboard.cohere.com/api-keys",
374
+ },
375
+ {
376
+ name: AIProviderName.TOGETHER_AI,
377
+ aliases: ["together"],
378
+ credentialsKey: "together",
379
+ envVars: {
380
+ apiKey: "TOGETHER_API_KEY",
381
+ baseURL: "TOGETHER_BASE_URL",
382
+ model: "TOGETHER_MODEL",
383
+ },
384
+ defaultModel: TogetherAIModels.LLAMA_3_3_70B_INSTRUCT_TURBO,
385
+ toolSupport: "native",
386
+ localRuntime: false,
387
+ healthCheck: "env-only",
388
+ setupUrl: "https://api.together.xyz/settings/api-keys",
389
+ },
390
+ {
391
+ name: AIProviderName.FIREWORKS,
392
+ aliases: [],
393
+ credentialsKey: "fireworks",
394
+ envVars: {
395
+ apiKey: "FIREWORKS_API_KEY",
396
+ baseURL: "FIREWORKS_BASE_URL",
397
+ model: "FIREWORKS_MODEL",
398
+ },
399
+ defaultModel: FireworksModels.DEEPSEEK_V4_PRO,
400
+ toolSupport: "native",
401
+ localRuntime: false,
402
+ healthCheck: "env-only",
403
+ setupUrl: "https://fireworks.ai/account/api-keys",
404
+ },
405
+ {
406
+ name: AIProviderName.PERPLEXITY,
407
+ aliases: ["pplx"],
408
+ credentialsKey: "perplexity",
409
+ envVars: {
410
+ apiKey: "PERPLEXITY_API_KEY",
411
+ baseURL: "PERPLEXITY_BASE_URL",
412
+ model: "PERPLEXITY_MODEL",
413
+ },
414
+ defaultModel: PerplexityModels.SONAR,
415
+ toolSupport: "native",
416
+ localRuntime: false,
417
+ healthCheck: "env-only",
418
+ setupUrl: "https://www.perplexity.ai/settings/api",
419
+ },
420
+ {
421
+ name: AIProviderName.CLOUDFLARE,
422
+ aliases: ["workers-ai", "cf-ai"],
423
+ credentialsKey: "cloudflare",
424
+ envVars: {
425
+ apiKey: "CLOUDFLARE_API_KEY",
426
+ extraRequired: ["CLOUDFLARE_ACCOUNT_ID"],
427
+ model: "CLOUDFLARE_MODEL",
428
+ },
429
+ defaultModel: CloudflareModels.LLAMA_3_3_70B_FAST,
430
+ toolSupport: "native",
431
+ localRuntime: false,
432
+ healthCheck: "env-only",
433
+ setupUrl: "https://dash.cloudflare.com/profile/api-tokens",
434
+ },
435
+ {
436
+ name: AIProviderName.REPLICATE,
437
+ aliases: [],
438
+ credentialsKey: "replicate",
439
+ // NOTE: Replicate's NeurolinkCredentials shape uses non-standard field
440
+ // names (apiToken not apiKey, baseUrl not baseURL) — envVars below
441
+ // still describes the *environment variable* names, which follow the
442
+ // usual convention; only the credentials object's field names differ.
443
+ envVars: { apiKey: "REPLICATE_API_TOKEN", model: "REPLICATE_MODEL" },
444
+ defaultModel: ReplicateModels.LLAMA_3_70B_INSTRUCT,
445
+ toolSupport: "none",
446
+ localRuntime: false,
447
+ healthCheck: "env-only",
448
+ setupUrl: "https://replicate.com/account/api-tokens",
449
+ },
450
+ {
451
+ name: AIProviderName.VOYAGE,
452
+ aliases: ["voyage-ai"],
453
+ credentialsKey: "voyage",
454
+ envVars: {
455
+ apiKey: "VOYAGE_API_KEY",
456
+ baseURL: "VOYAGE_BASE_URL",
457
+ model: "VOYAGE_MODEL",
458
+ },
459
+ defaultModel: VoyageModels.VOYAGE_3_5,
460
+ toolSupport: "none",
461
+ localRuntime: false,
462
+ healthCheck: "env-only",
463
+ setupUrl: "https://dash.voyageai.com/api-keys",
464
+ },
465
+ {
466
+ name: AIProviderName.JINA,
467
+ aliases: ["jina-ai"],
468
+ credentialsKey: "jina",
469
+ envVars: {
470
+ apiKey: "JINA_API_KEY",
471
+ baseURL: "JINA_BASE_URL",
472
+ model: "JINA_MODEL",
473
+ },
474
+ defaultModel: JinaModels.JINA_EMBEDDINGS_V3,
475
+ toolSupport: "none",
476
+ localRuntime: false,
477
+ healthCheck: "env-only",
478
+ setupUrl: "https://jina.ai/?sui=apikey",
479
+ },
480
+ {
481
+ name: AIProviderName.STABILITY,
482
+ aliases: ["stability-ai", "sd"],
483
+ credentialsKey: "stability",
484
+ envVars: {
485
+ apiKey: "STABILITY_API_KEY",
486
+ baseURL: "STABILITY_BASE_URL",
487
+ model: "STABILITY_MODEL",
488
+ },
489
+ defaultModel: StabilityModels.STABLE_IMAGE_ULTRA,
490
+ toolSupport: "none",
491
+ localRuntime: false,
492
+ healthCheck: "env-only",
493
+ setupUrl: "https://platform.stability.ai/account/keys",
494
+ },
495
+ {
496
+ name: AIProviderName.IDEOGRAM,
497
+ aliases: [],
498
+ credentialsKey: "ideogram",
499
+ envVars: {
500
+ apiKey: "IDEOGRAM_API_KEY",
501
+ baseURL: "IDEOGRAM_BASE_URL",
502
+ model: "IDEOGRAM_MODEL",
503
+ },
504
+ defaultModel: IdeogramModels.IDEOGRAM_V3,
505
+ toolSupport: "none",
506
+ localRuntime: false,
507
+ healthCheck: "env-only",
508
+ setupUrl: "https://developer.ideogram.ai/",
509
+ },
510
+ {
511
+ name: AIProviderName.RECRAFT,
512
+ aliases: [],
513
+ credentialsKey: "recraft",
514
+ envVars: {
515
+ apiKey: "RECRAFT_API_KEY",
516
+ baseURL: "RECRAFT_BASE_URL",
517
+ model: "RECRAFT_MODEL",
518
+ },
519
+ defaultModel: RecraftModels.RECRAFT_V3,
520
+ toolSupport: "none",
521
+ localRuntime: false,
522
+ healthCheck: "env-only",
523
+ setupUrl: "https://www.recraft.ai/api",
524
+ },
525
+ ];
526
+ /** O(1) canonical-name → descriptor lookup. */
527
+ export const PROVIDER_DESCRIPTORS_BY_NAME = new Map(PROVIDER_DESCRIPTORS.map((d) => [d.name, d]));
528
+ /**
529
+ * O(1) alias → canonical-name lookup, covering both `aliases` and each
530
+ * descriptor's own lowercased `name`. Replaces the O(n) linear scan in
531
+ * ProviderFactory.normalizeProviderName().
532
+ */
533
+ export const PROVIDER_ALIAS_INDEX = new Map(PROVIDER_DESCRIPTORS.flatMap((d) => [
534
+ [d.name.toLowerCase(), d.name],
535
+ ...d.aliases.map((alias) => [alias.toLowerCase(), d.name]),
536
+ ]));
537
+ //# sourceMappingURL=providerDescriptors.js.map
@@ -1,6 +1,22 @@
1
1
  import type { NeuroLink } from "../neurolink.js";
2
2
  import type { AIProviderName } from "../constants/enums.js";
3
- import type { AIProvider, NeurolinkCredentials, ProviderConstructor, ProviderRegistration } from "../types/index.js";
3
+ import type { AIProvider, NeurolinkCredentials, ProviderConstructor, ProviderDescriptor, ProviderRegistration } from "../types/index.js";
4
+ /**
5
+ * Resolve a registered provider name (or alias) to its NeurolinkCredentials
6
+ * key. Backed by ProviderFactory.getDescriptor() — PROVIDER_DESCRIPTORS is
7
+ * the single source of truth for provider identity — instead of a
8
+ * hand-maintained map, so this can no longer drift out of sync with the
9
+ * descriptors, and it correctly resolves aliases (e.g. "hf") through
10
+ * PROVIDER_ALIAS_INDEX, not just canonical names. Falls back to the
11
+ * lowercased input when no descriptor is found, matching the retired
12
+ * map's behavior for unknown provider names.
13
+ *
14
+ * Referencing ProviderFactory here (defined further down this file) is
15
+ * safe: this function's body only runs when called, by which point the
16
+ * module has finished evaluating and ProviderFactory is fully defined —
17
+ * there is no temporal-dead-zone hazard from the declaration order.
18
+ */
19
+ export declare function resolveCredentialKey(providerName: string): string;
4
20
  /**
5
21
  * True Factory Pattern implementation for AI Providers
6
22
  * Uses registration-based approach to eliminate switch statements
@@ -13,7 +29,7 @@ export declare class ProviderFactory {
13
29
  * Register a provider with the factory
14
30
  */
15
31
  static registerProvider(name: AIProviderName | string, constructor: ProviderConstructor, defaultModel?: string, // Optional - provider can read from env
16
- aliases?: string[]): void;
32
+ aliases?: string[], descriptor?: ProviderDescriptor): void;
17
33
  /**
18
34
  * Create a provider instance
19
35
  * @param providerName - Provider name (optional, uses NEUROLINK_PROVIDER env var or 'vertex' as default)
@@ -32,6 +48,16 @@ export declare class ProviderFactory {
32
48
  * Get provider registration info
33
49
  */
34
50
  static getProviderInfo(providerName: string): ProviderRegistration | undefined;
51
+ /**
52
+ * Look up a provider's static descriptor. Checks the built-in
53
+ * PROVIDER_DESCRIPTORS first (works even before registerAllProviders()
54
+ * has run, and resolves aliases via PROVIDER_ALIAS_INDEX), then falls
55
+ * back to whatever descriptor a live custom registration attached via
56
+ * registerProvider()'s 5th parameter.
57
+ */
58
+ static getDescriptor(name: string): ProviderDescriptor | undefined;
59
+ /** All built-in provider descriptors (does not include custom-registered providers that lack a descriptor). */
60
+ static getAllDescriptors(): readonly ProviderDescriptor[];
35
61
  /**
36
62
  * Normalize provider names using aliases (PHASE 1: Factory Pattern)
37
63
  */