@juspay/neurolink 11.0.0 → 11.1.1

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