@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.
- package/CHANGELOG.md +15 -0
- package/dist/browser/neurolink.min.js +510 -510
- package/dist/cli/commands/setup.d.ts +8 -1
- package/dist/cli/commands/setup.js +62 -46
- package/dist/cli/factories/commandFactory.d.ts +1157 -1
- package/dist/cli/factories/commandFactory.js +20 -53
- package/dist/constants/networkErrorCodes.d.ts +14 -0
- package/dist/constants/networkErrorCodes.js +21 -0
- package/dist/factories/providerDescriptors.d.ts +18 -0
- package/dist/factories/providerDescriptors.js +546 -0
- package/dist/factories/providerFactory.d.ts +25 -14
- package/dist/factories/providerFactory.js +46 -23
- package/dist/factories/providerRegistry.js +31 -30
- package/dist/index.d.ts +10 -1
- package/dist/index.js +13 -3
- package/dist/lib/constants/networkErrorCodes.d.ts +14 -0
- package/dist/lib/constants/networkErrorCodes.js +22 -0
- package/dist/lib/factories/providerDescriptors.d.ts +18 -0
- package/dist/lib/factories/providerDescriptors.js +547 -0
- package/dist/lib/factories/providerFactory.d.ts +25 -14
- package/dist/lib/factories/providerFactory.js +46 -23
- package/dist/lib/factories/providerRegistry.js +31 -30
- package/dist/lib/index.d.ts +10 -1
- package/dist/lib/index.js +13 -3
- package/dist/lib/neurolink.js +25 -37
- package/dist/lib/processors/base/BaseFileProcessor.d.ts +17 -0
- package/dist/lib/processors/base/BaseFileProcessor.js +40 -0
- package/dist/lib/processors/document/OpenDocumentProcessor.js +12 -2
- package/dist/lib/providers/amazonBedrock/client.js +34 -16
- package/dist/lib/providers/anthropic/client.js +39 -34
- package/dist/lib/providers/azureOpenai.js +17 -15
- package/dist/lib/providers/cloudflare.js +12 -21
- package/dist/lib/providers/cohere.js +31 -25
- package/dist/lib/providers/deepseek.js +23 -26
- package/dist/lib/providers/fireworks.js +12 -21
- package/dist/lib/providers/googleAiStudio/client.d.ts +2 -0
- package/dist/lib/providers/googleAiStudio/client.js +39 -17
- package/dist/lib/providers/googleVertex/client.js +107 -99
- package/dist/lib/providers/groq.js +19 -22
- package/dist/lib/providers/huggingFace/client.js +26 -24
- package/dist/lib/providers/litellm/client.js +54 -39
- package/dist/lib/providers/llamaCpp.js +21 -18
- package/dist/lib/providers/lmStudio.js +22 -19
- package/dist/lib/providers/mistral.js +12 -24
- package/dist/lib/providers/nvidiaNim/client.js +37 -34
- package/dist/lib/providers/ollama/client.js +50 -35
- package/dist/lib/providers/openAI/client.js +37 -40
- package/dist/lib/providers/openRouter/client.js +53 -47
- package/dist/lib/providers/openaiChatCompletionsBase.js +40 -16
- package/dist/lib/providers/openaiCompatible/client.js +36 -32
- package/dist/lib/providers/perplexity.js +12 -21
- package/dist/lib/providers/togetherAi.js +12 -21
- package/dist/lib/providers/xai.js +17 -26
- package/dist/lib/proxy/proxyFetch.js +1 -9
- package/dist/lib/server/errors.d.ts +1 -1
- package/dist/lib/server/errors.js +2 -2
- package/dist/lib/server/index.d.ts +2 -2
- package/dist/lib/server/index.js +5 -3
- package/dist/lib/server/middleware/rateLimit.d.ts +0 -4
- package/dist/lib/server/middleware/rateLimit.js +0 -4
- package/dist/lib/types/cli.d.ts +2 -0
- package/dist/lib/types/errors.d.ts +35 -0
- package/dist/lib/types/providers.d.ts +79 -0
- package/dist/lib/utils/errorClassifier.d.ts +30 -0
- package/dist/lib/utils/errorClassifier.js +183 -0
- package/dist/lib/utils/fileDetector.js +6 -43
- package/dist/lib/utils/providerConfig.d.ts +16 -0
- package/dist/lib/utils/providerConfig.js +23 -0
- package/dist/lib/utils/providerHealth.d.ts +53 -12
- package/dist/lib/utils/providerHealth.js +125 -131
- package/dist/lib/utils/providerUtils.js +22 -64
- package/dist/neurolink.js +25 -37
- package/dist/processors/base/BaseFileProcessor.d.ts +17 -0
- package/dist/processors/base/BaseFileProcessor.js +40 -0
- package/dist/processors/document/OpenDocumentProcessor.js +12 -2
- package/dist/providers/amazonBedrock/client.js +34 -16
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/anthropic/client.js +39 -34
- package/dist/providers/azureOpenai.js +17 -15
- package/dist/providers/cloudflare.js +12 -21
- package/dist/providers/cohere.js +31 -25
- package/dist/providers/deepseek.js +23 -26
- package/dist/providers/fireworks.js +12 -21
- package/dist/providers/googleAiStudio/client.d.ts +2 -0
- package/dist/providers/googleAiStudio/client.js +39 -17
- package/dist/providers/googleVertex/client.js +107 -99
- package/dist/providers/groq.js +19 -22
- package/dist/providers/huggingFace/client.js +26 -24
- package/dist/providers/litellm/client.js +54 -39
- package/dist/providers/llamaCpp.js +21 -18
- package/dist/providers/lmStudio.js +22 -19
- package/dist/providers/mistral.js +12 -24
- package/dist/providers/nvidiaNim/client.js +37 -34
- package/dist/providers/ollama/client.js +50 -35
- package/dist/providers/openAI/client.js +37 -40
- package/dist/providers/openRouter/client.js +53 -47
- package/dist/providers/openaiChatCompletionsBase.js +40 -16
- package/dist/providers/openaiCompatible/client.js +36 -32
- package/dist/providers/perplexity.js +12 -21
- package/dist/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/providers/togetherAi.js +12 -21
- package/dist/providers/xai.js +17 -26
- package/dist/proxy/proxyFetch.js +1 -9
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/errors.js +2 -2
- package/dist/server/index.d.ts +2 -2
- package/dist/server/index.js +5 -3
- package/dist/server/middleware/rateLimit.d.ts +0 -4
- package/dist/server/middleware/rateLimit.js +0 -4
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/errors.d.ts +35 -0
- package/dist/types/providers.d.ts +79 -0
- package/dist/utils/errorClassifier.d.ts +30 -0
- package/dist/utils/errorClassifier.js +182 -0
- package/dist/utils/fileDetector.js +6 -43
- package/dist/utils/providerConfig.d.ts +16 -0
- package/dist/utils/providerConfig.js +23 -0
- package/dist/utils/providerHealth.d.ts +53 -12
- package/dist/utils/providerHealth.js +125 -131
- package/dist/utils/providerUtils.js +22 -64
- package/package.json +15 -70
|
@@ -21,7 +21,14 @@ export declare const EXTRA_PROVIDER_CONFIGS: Record<string, ProviderConfigOption
|
|
|
21
21
|
* Main setup command handler
|
|
22
22
|
*/
|
|
23
23
|
export declare function handleSetup(argv: SetupArgs): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Check which providers are already configured
|
|
26
|
+
*/
|
|
27
|
+
export declare function checkExistingConfigurations(): Promise<string[]>;
|
|
24
28
|
/**
|
|
25
29
|
* Delegate to existing provider setup commands
|
|
26
30
|
*/
|
|
27
|
-
export declare function delegateToProviderSetup(providerId: string
|
|
31
|
+
export declare function delegateToProviderSetup(providerId: string, flags?: {
|
|
32
|
+
check?: boolean;
|
|
33
|
+
nonInteractive?: boolean;
|
|
34
|
+
}): Promise<void>;
|
|
@@ -19,7 +19,8 @@ import { handleBedrockSetup } from "./setup-bedrock.js";
|
|
|
19
19
|
import { handleGCPSetup } from "./setup-gcp.js";
|
|
20
20
|
import { handleHuggingFaceSetup } from "./setup-huggingface.js";
|
|
21
21
|
import { handleMistralSetup } from "./setup-mistral.js";
|
|
22
|
-
import {
|
|
22
|
+
import { PROVIDER_DESCRIPTORS_BY_NAME } from "../../lib/factories/providerDescriptors.js";
|
|
23
|
+
import { createCloudflareConfig, createCohereConfig, createDeepSeekConfig, createFireworksConfig, createGroqConfig, createIdeogramConfig, createJinaConfig, createNvidiaNimConfig, createOpenAICompatibleConfig, createPerplexityConfig, createRecraftConfig, createReplicateConfig, createStabilityConfig, createTogetherAIConfig, createVoyageConfig, createXaiConfig, satisfiesFallbacks, } from "../../lib/utils/providerConfig.js";
|
|
23
24
|
// Provider information database
|
|
24
25
|
const PROVIDERS = [
|
|
25
26
|
{
|
|
@@ -276,15 +277,22 @@ function printGenericProviderSetup(providerId, config) {
|
|
|
276
277
|
*/
|
|
277
278
|
export async function handleSetup(argv) {
|
|
278
279
|
try {
|
|
279
|
-
// Handle specific flags
|
|
280
|
+
// Handle specific flags. `--list`/`--status` are documented as one-shot,
|
|
281
|
+
// non-interactive informational commands (see the `setup --list` /
|
|
282
|
+
// `setup --status` examples in setupCommandFactory.ts) — pass
|
|
283
|
+
// interactive: false so they print and return instead of chaining into
|
|
284
|
+
// the wizard's follow-up inquirer prompt below.
|
|
280
285
|
if (argv.list) {
|
|
281
|
-
return await showProviderList();
|
|
286
|
+
return await showProviderList(false);
|
|
282
287
|
}
|
|
283
288
|
if (argv.status) {
|
|
284
|
-
return await showProviderStatus();
|
|
289
|
+
return await showProviderStatus(false);
|
|
285
290
|
}
|
|
286
291
|
if (argv.provider && argv.provider !== "auto") {
|
|
287
|
-
return await delegateToProviderSetup(argv.provider
|
|
292
|
+
return await delegateToProviderSetup(argv.provider, {
|
|
293
|
+
check: argv.check,
|
|
294
|
+
nonInteractive: argv.nonInteractive,
|
|
295
|
+
});
|
|
288
296
|
}
|
|
289
297
|
// Main setup wizard
|
|
290
298
|
await showWelcomeScreen();
|
|
@@ -383,40 +391,25 @@ async function runSetupWizard() {
|
|
|
383
391
|
/**
|
|
384
392
|
* Check which providers are already configured
|
|
385
393
|
*/
|
|
386
|
-
async function checkExistingConfigurations() {
|
|
394
|
+
export async function checkExistingConfigurations() {
|
|
387
395
|
const configured = [];
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (process.env.GOOGLE_APPLICATION_CREDENTIALS ||
|
|
406
|
-
process.env.GOOGLE_SERVICE_ACCOUNT_KEY) {
|
|
407
|
-
configured.push("vertex");
|
|
408
|
-
}
|
|
409
|
-
if (process.env.HUGGINGFACE_API_KEY ||
|
|
410
|
-
process.env.HUGGINGFACE_API_TOKEN ||
|
|
411
|
-
process.env.HF_TOKEN ||
|
|
412
|
-
process.env.HF_API_TOKEN) {
|
|
413
|
-
configured.push("huggingface");
|
|
414
|
-
}
|
|
415
|
-
if (process.env.MISTRAL_API_KEY) {
|
|
416
|
-
configured.push("mistral");
|
|
417
|
-
}
|
|
418
|
-
if (process.env.OPENROUTER_API_KEY) {
|
|
419
|
-
configured.push("openrouter");
|
|
396
|
+
for (const p of PROVIDERS) {
|
|
397
|
+
const descriptor = PROVIDER_DESCRIPTORS_BY_NAME.get(p.id);
|
|
398
|
+
if (!descriptor) {
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
const { apiKey, fallbacks, extraRequired, extraRequiredFallbacks } = descriptor.envVars;
|
|
402
|
+
const hasPrimary = !!apiKey &&
|
|
403
|
+
(!!process.env[apiKey] ||
|
|
404
|
+
(fallbacks ?? []).some((v) => !!process.env[v]));
|
|
405
|
+
if (!hasPrimary) {
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
const requiredOk = (extraRequired ?? []).every((v) => !!process.env[v]) ||
|
|
409
|
+
satisfiesFallbacks(extraRequiredFallbacks, process.env);
|
|
410
|
+
if (requiredOk) {
|
|
411
|
+
configured.push(p.id);
|
|
412
|
+
}
|
|
420
413
|
}
|
|
421
414
|
return configured;
|
|
422
415
|
}
|
|
@@ -496,11 +489,16 @@ async function runProviderSelection() {
|
|
|
496
489
|
/**
|
|
497
490
|
* Delegate to existing provider setup commands
|
|
498
491
|
*/
|
|
499
|
-
export async function delegateToProviderSetup(providerId
|
|
492
|
+
export async function delegateToProviderSetup(providerId, flags = {
|
|
493
|
+
check: false,
|
|
494
|
+
nonInteractive: false,
|
|
495
|
+
}) {
|
|
496
|
+
const nonInteractive = flags.nonInteractive ?? false;
|
|
497
|
+
const check = flags.check ?? false;
|
|
500
498
|
const setupArgs = {
|
|
501
|
-
nonInteractive
|
|
502
|
-
"non-interactive":
|
|
503
|
-
check
|
|
499
|
+
nonInteractive,
|
|
500
|
+
"non-interactive": nonInteractive,
|
|
501
|
+
check,
|
|
504
502
|
_: [],
|
|
505
503
|
$0: "neurolink",
|
|
506
504
|
};
|
|
@@ -594,9 +592,15 @@ async function showSetupCompletion(providerId) {
|
|
|
594
592
|
logger.always(chalk.blue("Happy generating! 🚀"));
|
|
595
593
|
}
|
|
596
594
|
/**
|
|
597
|
-
* Show detailed provider information
|
|
595
|
+
* Show detailed provider information.
|
|
596
|
+
*
|
|
597
|
+
* @param interactive - When true (the default, used by the interactive
|
|
598
|
+
* wizard's "learn more" menu choice), follows up with a prompt offering to
|
|
599
|
+
* launch the setup wizard. When false (used by the direct `setup --list`
|
|
600
|
+
* flag), returns immediately after printing so the command exits cleanly
|
|
601
|
+
* without waiting on stdin.
|
|
598
602
|
*/
|
|
599
|
-
async function showProviderList() {
|
|
603
|
+
async function showProviderList(interactive = true) {
|
|
600
604
|
logger.always(chalk.blue("📚 NeuroLink Supported AI Providers"));
|
|
601
605
|
logger.always("");
|
|
602
606
|
for (const provider of PROVIDERS) {
|
|
@@ -626,6 +630,9 @@ async function showProviderList() {
|
|
|
626
630
|
logger.always("• neurolink setup --provider azure");
|
|
627
631
|
logger.always("• neurolink setup --provider bedrock");
|
|
628
632
|
logger.always("");
|
|
633
|
+
if (!interactive) {
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
629
636
|
const { action } = await inquirer.prompt([
|
|
630
637
|
{
|
|
631
638
|
type: "select",
|
|
@@ -642,9 +649,15 @@ async function showProviderList() {
|
|
|
642
649
|
}
|
|
643
650
|
}
|
|
644
651
|
/**
|
|
645
|
-
* Show provider status with detailed information
|
|
652
|
+
* Show provider status with detailed information.
|
|
653
|
+
*
|
|
654
|
+
* @param interactive - When true (the default, used by the interactive
|
|
655
|
+
* wizard's "check status" menu choice), follows up with a prompt offering to
|
|
656
|
+
* set up another provider. When false (used by the direct `setup --status`
|
|
657
|
+
* flag), returns immediately after printing so the command exits cleanly
|
|
658
|
+
* without waiting on stdin.
|
|
646
659
|
*/
|
|
647
|
-
async function showProviderStatus() {
|
|
660
|
+
async function showProviderStatus(interactive = true) {
|
|
648
661
|
const spinner = ora("🔍 Checking all AI provider configurations...").start();
|
|
649
662
|
try {
|
|
650
663
|
// Get provider status using NeuroLink SDK
|
|
@@ -705,6 +718,9 @@ async function showProviderStatus() {
|
|
|
705
718
|
logger.always("• Check performance: neurolink provider status");
|
|
706
719
|
logger.always("");
|
|
707
720
|
}
|
|
721
|
+
if (!interactive) {
|
|
722
|
+
return;
|
|
723
|
+
}
|
|
708
724
|
const { setupAnother } = await inquirer.prompt([
|
|
709
725
|
{
|
|
710
726
|
type: "confirm",
|