@juspay/neurolink 11.0.0 → 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 (103) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/browser/neurolink.min.js +524 -524
  3. package/dist/cli/commands/setup.d.ts +4 -0
  4. package/dist/cli/commands/setup.js +19 -33
  5. package/dist/cli/factories/commandFactory.d.ts +1157 -1
  6. package/dist/cli/factories/commandFactory.js +20 -53
  7. package/dist/factories/providerDescriptors.d.ts +18 -0
  8. package/dist/factories/providerDescriptors.js +536 -0
  9. package/dist/factories/providerFactory.d.ts +25 -14
  10. package/dist/factories/providerFactory.js +46 -23
  11. package/dist/factories/providerRegistry.js +31 -30
  12. package/dist/index.d.ts +10 -1
  13. package/dist/index.js +13 -3
  14. package/dist/lib/factories/providerDescriptors.d.ts +18 -0
  15. package/dist/lib/factories/providerDescriptors.js +537 -0
  16. package/dist/lib/factories/providerFactory.d.ts +25 -14
  17. package/dist/lib/factories/providerFactory.js +46 -23
  18. package/dist/lib/factories/providerRegistry.js +31 -30
  19. package/dist/lib/index.d.ts +10 -1
  20. package/dist/lib/index.js +13 -3
  21. package/dist/lib/neurolink.js +25 -37
  22. package/dist/lib/providers/amazonBedrock/client.js +34 -16
  23. package/dist/lib/providers/anthropic/client.js +39 -34
  24. package/dist/lib/providers/azureOpenai.js +17 -15
  25. package/dist/lib/providers/cloudflare.js +12 -21
  26. package/dist/lib/providers/cohere.js +31 -25
  27. package/dist/lib/providers/deepseek.js +23 -26
  28. package/dist/lib/providers/fireworks.js +12 -21
  29. package/dist/lib/providers/googleAiStudio/client.d.ts +2 -0
  30. package/dist/lib/providers/googleAiStudio/client.js +39 -17
  31. package/dist/lib/providers/googleVertex/client.js +107 -99
  32. package/dist/lib/providers/groq.js +19 -22
  33. package/dist/lib/providers/huggingFace/client.js +26 -24
  34. package/dist/lib/providers/litellm/client.js +54 -39
  35. package/dist/lib/providers/llamaCpp.js +21 -18
  36. package/dist/lib/providers/lmStudio.js +22 -19
  37. package/dist/lib/providers/mistral.js +12 -24
  38. package/dist/lib/providers/nvidiaNim/client.js +37 -34
  39. package/dist/lib/providers/ollama/client.js +50 -35
  40. package/dist/lib/providers/openAI/client.js +37 -40
  41. package/dist/lib/providers/openRouter/client.js +53 -47
  42. package/dist/lib/providers/openaiChatCompletionsBase.js +40 -16
  43. package/dist/lib/providers/openaiCompatible/client.js +36 -32
  44. package/dist/lib/providers/perplexity.js +12 -21
  45. package/dist/lib/providers/togetherAi.js +12 -21
  46. package/dist/lib/providers/xai.js +17 -26
  47. package/dist/lib/server/errors.d.ts +1 -1
  48. package/dist/lib/server/errors.js +2 -2
  49. package/dist/lib/server/index.d.ts +2 -2
  50. package/dist/lib/server/index.js +5 -3
  51. package/dist/lib/server/middleware/rateLimit.d.ts +0 -4
  52. package/dist/lib/server/middleware/rateLimit.js +0 -4
  53. package/dist/lib/types/errors.d.ts +35 -0
  54. package/dist/lib/types/providers.d.ts +64 -0
  55. package/dist/lib/utils/errorClassifier.d.ts +30 -0
  56. package/dist/lib/utils/errorClassifier.js +94 -0
  57. package/dist/lib/utils/fileDetector.js +6 -43
  58. package/dist/lib/utils/providerHealth.d.ts +42 -7
  59. package/dist/lib/utils/providerHealth.js +115 -122
  60. package/dist/lib/utils/providerUtils.js +21 -63
  61. package/dist/neurolink.js +25 -37
  62. package/dist/providers/amazonBedrock/client.js +34 -16
  63. package/dist/providers/amazonSagemaker.d.ts +1 -1
  64. package/dist/providers/anthropic/client.js +39 -34
  65. package/dist/providers/azureOpenai.js +17 -15
  66. package/dist/providers/cloudflare.js +12 -21
  67. package/dist/providers/cohere.js +31 -25
  68. package/dist/providers/deepseek.js +23 -26
  69. package/dist/providers/fireworks.js +12 -21
  70. package/dist/providers/googleAiStudio/client.d.ts +2 -0
  71. package/dist/providers/googleAiStudio/client.js +39 -17
  72. package/dist/providers/googleVertex/client.js +107 -99
  73. package/dist/providers/groq.js +19 -22
  74. package/dist/providers/huggingFace/client.js +26 -24
  75. package/dist/providers/litellm/client.js +54 -39
  76. package/dist/providers/llamaCpp.js +21 -18
  77. package/dist/providers/lmStudio.js +22 -19
  78. package/dist/providers/mistral.js +12 -24
  79. package/dist/providers/nvidiaNim/client.js +37 -34
  80. package/dist/providers/ollama/client.js +50 -35
  81. package/dist/providers/openAI/client.js +37 -40
  82. package/dist/providers/openRouter/client.js +53 -47
  83. package/dist/providers/openaiChatCompletionsBase.js +40 -16
  84. package/dist/providers/openaiCompatible/client.js +36 -32
  85. package/dist/providers/perplexity.js +12 -21
  86. package/dist/providers/sagemaker/language-model.d.ts +2 -2
  87. package/dist/providers/togetherAi.js +12 -21
  88. package/dist/providers/xai.js +17 -26
  89. package/dist/server/errors.d.ts +1 -1
  90. package/dist/server/errors.js +2 -2
  91. package/dist/server/index.d.ts +2 -2
  92. package/dist/server/index.js +5 -3
  93. package/dist/server/middleware/rateLimit.d.ts +0 -4
  94. package/dist/server/middleware/rateLimit.js +0 -4
  95. package/dist/types/errors.d.ts +35 -0
  96. package/dist/types/providers.d.ts +64 -0
  97. package/dist/utils/errorClassifier.d.ts +30 -0
  98. package/dist/utils/errorClassifier.js +93 -0
  99. package/dist/utils/fileDetector.js +6 -43
  100. package/dist/utils/providerHealth.d.ts +42 -7
  101. package/dist/utils/providerHealth.js +115 -122
  102. package/dist/utils/providerUtils.js +21 -63
  103. package/package.json +15 -70
@@ -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,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
  */