@juspay/neurolink 10.12.9 → 11.0.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.
- package/CHANGELOG.md +26 -0
- package/dist/browser/neurolink.min.js +407 -409
- package/dist/cli/commands/setup.d.ts +16 -1
- package/dist/cli/commands/setup.js +141 -3
- package/dist/core/baseProvider.js +3 -3
- package/dist/core/dynamicModels.d.ts +1 -1
- package/dist/core/dynamicModels.js +1 -23
- package/dist/core/modelConfiguration.d.ts +1 -70
- package/dist/core/modelConfiguration.js +0 -303
- package/dist/core/modules/GenerationHandler.js +2 -2
- package/dist/core/modules/structuredOutputPolicy.d.ts +2 -2
- package/dist/core/modules/structuredOutputPolicy.js +2 -2
- package/dist/factories/providerFactory.d.ts +15 -0
- package/dist/factories/providerFactory.js +27 -39
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/lib/core/baseProvider.js +3 -3
- package/dist/lib/core/dynamicModels.d.ts +1 -1
- package/dist/lib/core/dynamicModels.js +1 -23
- package/dist/lib/core/modelConfiguration.d.ts +1 -70
- package/dist/lib/core/modelConfiguration.js +0 -303
- package/dist/lib/core/modules/GenerationHandler.js +2 -2
- package/dist/lib/core/modules/structuredOutputPolicy.d.ts +2 -2
- package/dist/lib/core/modules/structuredOutputPolicy.js +2 -2
- package/dist/lib/factories/providerFactory.d.ts +15 -0
- package/dist/lib/factories/providerFactory.js +27 -39
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/models/anthropicModels.d.ts +0 -7
- package/dist/lib/models/anthropicModels.js +0 -9
- package/dist/lib/providers/anthropic/constants.d.ts +0 -1
- package/dist/lib/providers/anthropic/constants.js +0 -2
- package/dist/lib/providers/anthropic/index.d.ts +0 -1
- package/dist/lib/providers/anthropic/index.js +0 -1
- package/dist/lib/providers/googleAiStudio/index.d.ts +0 -1
- package/dist/lib/providers/googleAiStudio/index.js +0 -1
- package/dist/lib/providers/googleNativeGemini3/index.d.ts +0 -1
- package/dist/lib/providers/googleNativeGemini3/index.js +0 -1
- package/dist/lib/providers/googleVertex/client.d.ts +0 -51
- package/dist/lib/providers/googleVertex/client.js +0 -678
- package/dist/lib/providers/huggingFace/client.d.ts +1 -1
- package/dist/lib/providers/huggingFace/client.js +1 -1
- package/dist/lib/providers/huggingFace/index.d.ts +0 -1
- package/dist/lib/providers/huggingFace/index.js +0 -1
- package/dist/lib/providers/jina.d.ts +0 -1
- package/dist/lib/providers/jina.js +0 -1
- package/dist/lib/providers/litellm/index.d.ts +0 -2
- package/dist/lib/providers/litellm/index.js +0 -2
- package/dist/lib/providers/llamaCpp.d.ts +1 -0
- package/dist/lib/providers/llamaCpp.js +3 -0
- package/dist/lib/providers/lmStudio.js +3 -23
- package/dist/lib/providers/nvidiaNim/index.d.ts +0 -1
- package/dist/lib/providers/nvidiaNim/index.js +0 -1
- package/dist/lib/providers/ollama/client.js +1 -23
- package/dist/lib/providers/ollama/index.d.ts +0 -1
- package/dist/lib/providers/ollama/index.js +0 -1
- package/dist/lib/providers/openAI/index.d.ts +0 -2
- package/dist/lib/providers/openAI/index.js +0 -2
- package/dist/lib/providers/openRouter/utils.d.ts +0 -2
- package/dist/lib/providers/openRouter/utils.js +0 -12
- package/dist/lib/providers/openaiChatCompletionsBase.d.ts +9 -0
- package/dist/lib/providers/openaiChatCompletionsBase.js +33 -0
- package/dist/lib/providers/perplexity.d.ts +2 -1
- package/dist/lib/providers/perplexity.js +2 -1
- package/dist/lib/providers/replicate.d.ts +0 -1
- package/dist/lib/providers/replicate.js +22 -9
- package/dist/lib/providers/voyage.d.ts +0 -1
- package/dist/lib/providers/voyage.js +0 -1
- package/dist/lib/types/index.d.ts +0 -1
- package/dist/lib/types/index.js +0 -1
- package/dist/lib/types/providers.d.ts +2 -11
- package/dist/lib/utils/providerConfig.d.ts +0 -8
- package/dist/lib/utils/providerConfig.js +0 -37
- package/dist/lib/utils/providerUtils.js +1 -25
- package/dist/models/anthropicModels.d.ts +0 -7
- package/dist/models/anthropicModels.js +0 -9
- package/dist/providers/anthropic/constants.d.ts +0 -1
- package/dist/providers/anthropic/constants.js +0 -2
- package/dist/providers/anthropic/index.d.ts +0 -1
- package/dist/providers/anthropic/index.js +0 -1
- package/dist/providers/googleAiStudio/index.d.ts +0 -1
- package/dist/providers/googleAiStudio/index.js +0 -1
- package/dist/providers/googleNativeGemini3/index.d.ts +0 -1
- package/dist/providers/googleNativeGemini3/index.js +0 -1
- package/dist/providers/googleVertex/client.d.ts +0 -51
- package/dist/providers/googleVertex/client.js +0 -678
- package/dist/providers/huggingFace/client.d.ts +1 -1
- package/dist/providers/huggingFace/client.js +1 -1
- package/dist/providers/huggingFace/index.d.ts +0 -1
- package/dist/providers/huggingFace/index.js +0 -1
- package/dist/providers/jina.d.ts +0 -1
- package/dist/providers/jina.js +0 -1
- package/dist/providers/litellm/index.d.ts +0 -2
- package/dist/providers/litellm/index.js +0 -2
- package/dist/providers/llamaCpp.d.ts +1 -0
- package/dist/providers/llamaCpp.js +3 -0
- package/dist/providers/lmStudio.js +3 -23
- package/dist/providers/nvidiaNim/index.d.ts +0 -1
- package/dist/providers/nvidiaNim/index.js +0 -1
- package/dist/providers/ollama/client.js +1 -23
- package/dist/providers/ollama/index.d.ts +0 -1
- package/dist/providers/ollama/index.js +0 -1
- package/dist/providers/openAI/index.d.ts +0 -2
- package/dist/providers/openAI/index.js +0 -2
- package/dist/providers/openRouter/utils.d.ts +0 -2
- package/dist/providers/openRouter/utils.js +0 -12
- package/dist/providers/openaiChatCompletionsBase.d.ts +9 -0
- package/dist/providers/openaiChatCompletionsBase.js +33 -0
- package/dist/providers/perplexity.d.ts +2 -1
- package/dist/providers/perplexity.js +2 -1
- package/dist/providers/replicate.d.ts +0 -1
- package/dist/providers/replicate.js +22 -9
- package/dist/providers/voyage.d.ts +0 -1
- package/dist/providers/voyage.js +0 -1
- package/dist/types/index.d.ts +0 -1
- package/dist/types/index.js +0 -1
- package/dist/types/providers.d.ts +2 -11
- package/dist/utils/providerConfig.d.ts +0 -8
- package/dist/utils/providerConfig.js +0 -37
- package/dist/utils/providerUtils.js +1 -25
- package/package.json +8 -7
- package/dist/lib/providers/anthropic/utils.d.ts +0 -7
- package/dist/lib/providers/anthropic/utils.js +0 -150
- package/dist/lib/providers/googleAiStudio/utils.d.ts +0 -2
- package/dist/lib/providers/googleAiStudio/utils.js +0 -19
- package/dist/lib/providers/googleNativeGemini3/constants.d.ts +0 -1
- package/dist/lib/providers/googleNativeGemini3/constants.js +0 -2
- package/dist/lib/providers/huggingFace/utils.d.ts +0 -2
- package/dist/lib/providers/huggingFace/utils.js +0 -8
- package/dist/lib/providers/index.d.ts +0 -33
- package/dist/lib/providers/index.js +0 -34
- package/dist/lib/providers/litellm/constants.d.ts +0 -1
- package/dist/lib/providers/litellm/constants.js +0 -3
- package/dist/lib/providers/litellm/utils.d.ts +0 -5
- package/dist/lib/providers/litellm/utils.js +0 -11
- package/dist/lib/providers/nvidiaNim/utils.d.ts +0 -9
- package/dist/lib/providers/nvidiaNim/utils.js +0 -101
- package/dist/lib/providers/ollama/utils.d.ts +0 -8
- package/dist/lib/providers/ollama/utils.js +0 -43
- package/dist/lib/providers/openAI/constants.d.ts +0 -1
- package/dist/lib/providers/openAI/constants.js +0 -3
- package/dist/lib/providers/openAI/utils.d.ts +0 -2
- package/dist/lib/providers/openAI/utils.js +0 -8
- package/dist/lib/types/universalProviderOptions.d.ts +0 -89
- package/dist/lib/types/universalProviderOptions.js +0 -55
- package/dist/providers/anthropic/utils.d.ts +0 -7
- package/dist/providers/anthropic/utils.js +0 -149
- package/dist/providers/googleAiStudio/utils.d.ts +0 -2
- package/dist/providers/googleAiStudio/utils.js +0 -18
- package/dist/providers/googleNativeGemini3/constants.d.ts +0 -1
- package/dist/providers/googleNativeGemini3/constants.js +0 -1
- package/dist/providers/huggingFace/utils.d.ts +0 -2
- package/dist/providers/huggingFace/utils.js +0 -7
- package/dist/providers/index.d.ts +0 -33
- package/dist/providers/index.js +0 -33
- package/dist/providers/litellm/constants.d.ts +0 -1
- package/dist/providers/litellm/constants.js +0 -2
- package/dist/providers/litellm/utils.d.ts +0 -5
- package/dist/providers/litellm/utils.js +0 -10
- package/dist/providers/nvidiaNim/utils.d.ts +0 -9
- package/dist/providers/nvidiaNim/utils.js +0 -100
- package/dist/providers/ollama/utils.d.ts +0 -8
- package/dist/providers/ollama/utils.js +0 -42
- package/dist/providers/openAI/constants.d.ts +0 -1
- package/dist/providers/openAI/constants.js +0 -2
- package/dist/providers/openAI/utils.d.ts +0 -2
- package/dist/providers/openAI/utils.js +0 -7
- package/dist/types/universalProviderOptions.d.ts +0 -89
- package/dist/types/universalProviderOptions.js +0 -54
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { NeuroLink } from "../neurolink.js";
|
|
2
2
|
import type { AIProviderName } from "../constants/enums.js";
|
|
3
3
|
import type { AIProvider, NeurolinkCredentials, ProviderConstructor, ProviderRegistration } from "../types/index.js";
|
|
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 camelCase — or 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.
|
|
17
|
+
*/
|
|
18
|
+
export declare function resolveCredentialKey(providerName: string): string;
|
|
4
19
|
/**
|
|
5
20
|
* True Factory Pattern implementation for AI Providers
|
|
6
21
|
* Uses registration-based approach to eliminate switch statements
|
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
import { logger } from "../utils/logger.js";
|
|
2
2
|
// Pure factory pattern with no hardcoded imports
|
|
3
3
|
// All providers loaded dynamically via registry to avoid circular dependencies
|
|
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 camelCase — or 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 const CREDENTIAL_KEY_MAP = {
|
|
14
|
+
"google-ai": "googleAiStudio",
|
|
15
|
+
"openai-compatible": "openaiCompatible",
|
|
16
|
+
huggingface: "huggingFace",
|
|
17
|
+
"lm-studio": "lmStudio",
|
|
18
|
+
"nvidia-nim": "nvidiaNim",
|
|
19
|
+
"together-ai": "together",
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a registered provider name to its NeurolinkCredentials key.
|
|
23
|
+
* Falls back to the provider name itself when no remapping is needed.
|
|
24
|
+
*/
|
|
25
|
+
export function resolveCredentialKey(providerName) {
|
|
26
|
+
return (CREDENTIAL_KEY_MAP[providerName.toLowerCase()] ?? providerName.toLowerCase());
|
|
27
|
+
}
|
|
4
28
|
/**
|
|
5
29
|
* True Factory Pattern implementation for AI Providers
|
|
6
30
|
* Uses registration-based approach to eliminate switch statements
|
|
@@ -58,21 +82,7 @@ export class ProviderFactory {
|
|
|
58
82
|
// Fallback to registry default if no env var
|
|
59
83
|
model = model || registration.defaultModel;
|
|
60
84
|
}
|
|
61
|
-
|
|
62
|
-
// Most names match (openai, anthropic, vertex, bedrock, etc.)
|
|
63
|
-
// but every kebab-case provider whose canonical credentials key is
|
|
64
|
-
// camelCase MUST be mapped here — otherwise per-call credential
|
|
65
|
-
// overrides silently get dropped (the factory looks up
|
|
66
|
-
// credentials["lm-studio"] which is undefined while the user wrote
|
|
67
|
-
// credentials.lmStudio).
|
|
68
|
-
const credentialKeyMap = {
|
|
69
|
-
"google-ai": "googleAiStudio",
|
|
70
|
-
"openai-compatible": "openaiCompatible",
|
|
71
|
-
huggingface: "huggingFace",
|
|
72
|
-
"lm-studio": "lmStudio",
|
|
73
|
-
"nvidia-nim": "nvidiaNim",
|
|
74
|
-
};
|
|
75
|
-
const credKey = credentialKeyMap[normalizedName] ?? normalizedName;
|
|
85
|
+
const credKey = resolveCredentialKey(normalizedName);
|
|
76
86
|
// Extract provider-scoped credential slice (e.g. credentials.openai for OpenAI)
|
|
77
87
|
const scopedCredentials = credentials
|
|
78
88
|
? credentials[credKey]
|
|
@@ -81,30 +91,8 @@ export class ProviderFactory {
|
|
|
81
91
|
if (typeof registration.constructor !== "function") {
|
|
82
92
|
throw new Error(`Invalid constructor for provider ${providerName}: not a function`);
|
|
83
93
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const factoryResult = registration.constructor(model, resolvedProviderName, sdk, region, scopedCredentials);
|
|
87
|
-
// Handle both sync and async results
|
|
88
|
-
result =
|
|
89
|
-
factoryResult instanceof Promise
|
|
90
|
-
? await factoryResult
|
|
91
|
-
: factoryResult;
|
|
92
|
-
}
|
|
93
|
-
catch (factoryError) {
|
|
94
|
-
if (registration.constructor.prototype &&
|
|
95
|
-
registration.constructor.prototype.constructor ===
|
|
96
|
-
registration.constructor) {
|
|
97
|
-
try {
|
|
98
|
-
result = new registration.constructor(model, resolvedProviderName, sdk, region, scopedCredentials);
|
|
99
|
-
}
|
|
100
|
-
catch (constructorError) {
|
|
101
|
-
throw new Error(`Both factory function and constructor failed. Factory error: ${factoryError}. Constructor error: ${constructorError}`, { cause: constructorError });
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
throw factoryError;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
94
|
+
const factoryResult = registration.constructor(model, resolvedProviderName, sdk, region, scopedCredentials);
|
|
95
|
+
const result = factoryResult instanceof Promise ? await factoryResult : factoryResult;
|
|
108
96
|
return result;
|
|
109
97
|
}
|
|
110
98
|
catch (error) {
|
|
@@ -104,10 +104,10 @@ export class ProviderRegistry {
|
|
|
104
104
|
return new GoogleVertexProvider(modelName, providerName, sdk, region, vertexCreds);
|
|
105
105
|
}, VertexModels.CLAUDE_4_6_SONNET, ["vertex", "googleVertex"]);
|
|
106
106
|
// Register Hugging Face provider (Unified Router implementation)
|
|
107
|
-
ProviderFactory.registerProvider(AIProviderName.HUGGINGFACE, async (modelName, _providerName,
|
|
107
|
+
ProviderFactory.registerProvider(AIProviderName.HUGGINGFACE, async (modelName, _providerName, sdk, region, credentials) => {
|
|
108
108
|
const hfCreds = credentials;
|
|
109
109
|
const { HuggingFaceProvider } = await import("../providers/huggingFace/index.js");
|
|
110
|
-
return new HuggingFaceProvider(modelName,
|
|
110
|
+
return new HuggingFaceProvider(modelName, sdk, region, hfCreds);
|
|
111
111
|
}, process.env.HUGGINGFACE_MODEL ||
|
|
112
112
|
HuggingFaceModels.QWEN_2_5_72B_INSTRUCT, ["huggingface", "hf"]);
|
|
113
113
|
// Register Mistral AI provider
|
|
@@ -242,13 +242,6 @@ export declare function getContextWindow(model: string): number;
|
|
|
242
242
|
* @returns The max output tokens, or 0 if model not found
|
|
243
243
|
*/
|
|
244
244
|
export declare function getMaxOutputTokens(model: string): number;
|
|
245
|
-
/**
|
|
246
|
-
* Check if a model supports vision/image input
|
|
247
|
-
*
|
|
248
|
-
* @param model - The model ID
|
|
249
|
-
* @returns true if the model supports vision
|
|
250
|
-
*/
|
|
251
|
-
export declare function supportsVision(model: string): boolean;
|
|
252
245
|
/**
|
|
253
246
|
* Check if a model supports extended thinking
|
|
254
247
|
*
|
|
@@ -531,15 +531,6 @@ export function getContextWindow(model) {
|
|
|
531
531
|
export function getMaxOutputTokens(model) {
|
|
532
532
|
return MODEL_METADATA[model]?.maxOutputTokens ?? 0;
|
|
533
533
|
}
|
|
534
|
-
/**
|
|
535
|
-
* Check if a model supports vision/image input
|
|
536
|
-
*
|
|
537
|
-
* @param model - The model ID
|
|
538
|
-
* @returns true if the model supports vision
|
|
539
|
-
*/
|
|
540
|
-
export function supportsVision(model) {
|
|
541
|
-
return MODEL_METADATA[model]?.supportsVision ?? false;
|
|
542
|
-
}
|
|
543
534
|
/**
|
|
544
535
|
* Check if a model supports extended thinking
|
|
545
536
|
*
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { trace } from "@opentelemetry/api";
|
|
2
1
|
export const ANTHROPIC_BETA_HEADERS = {
|
|
3
2
|
"anthropic-beta": [
|
|
4
3
|
"claude-code-20250219",
|
|
5
4
|
"fine-grained-tool-streaming-2025-05-14",
|
|
6
5
|
].join(","),
|
|
7
6
|
};
|
|
8
|
-
export const streamTracer = trace.getTracer("neurolink.provider.anthropic");
|
|
9
7
|
//# sourceMappingURL=constants.js.map
|
|
@@ -70,28 +70,6 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
70
70
|
* Creates fresh model instances for each request
|
|
71
71
|
*/
|
|
72
72
|
protected getAISDKModel(): Promise<LanguageModel>;
|
|
73
|
-
/**
|
|
74
|
-
* Initialize model creation tracking
|
|
75
|
-
*/
|
|
76
|
-
private initializeModelCreationLogging;
|
|
77
|
-
/**
|
|
78
|
-
* Check if model is Anthropic-based and attempt creation
|
|
79
|
-
*/
|
|
80
|
-
private attemptAnthropicModelCreation;
|
|
81
|
-
/**
|
|
82
|
-
* Create Google Vertex model with comprehensive logging and error handling
|
|
83
|
-
*/
|
|
84
|
-
private createGoogleVertexModel;
|
|
85
|
-
/**
|
|
86
|
-
* @deprecated This method is no longer used. All models now use native SDKs.
|
|
87
|
-
*/
|
|
88
|
-
private createVertexInstance;
|
|
89
|
-
/**
|
|
90
|
-
* Gets the appropriate model instance (Google or Anthropic)
|
|
91
|
-
* Uses dual provider architecture for proper model routing
|
|
92
|
-
* Creates fresh instances for each request to ensure proper authentication
|
|
93
|
-
*/
|
|
94
|
-
private getModel;
|
|
95
73
|
/**
|
|
96
74
|
* Validate stream options
|
|
97
75
|
*/
|
|
@@ -320,35 +298,6 @@ export declare class GoogleVertexProvider extends BaseProvider {
|
|
|
320
298
|
* @returns Promise<boolean> indicating if Anthropic support is available
|
|
321
299
|
*/
|
|
322
300
|
hasAnthropicSupport(): Promise<boolean>;
|
|
323
|
-
/**
|
|
324
|
-
* @deprecated This method is no longer used. Claude models now use native @anthropic-ai/vertex-sdk
|
|
325
|
-
* via executeNativeAnthropicStream and executeNativeAnthropicGenerate.
|
|
326
|
-
*/
|
|
327
|
-
createAnthropicModel(_modelName: string): Promise<LanguageModel | null>;
|
|
328
|
-
/**
|
|
329
|
-
* Validate Vertex AI authentication configuration
|
|
330
|
-
*/
|
|
331
|
-
private validateVertexAuthentication;
|
|
332
|
-
/**
|
|
333
|
-
* Validate Vertex AI project configuration
|
|
334
|
-
*/
|
|
335
|
-
private validateVertexProjectConfiguration;
|
|
336
|
-
/**
|
|
337
|
-
* Check if the specified region supports Anthropic models
|
|
338
|
-
*/
|
|
339
|
-
private checkVertexRegionalSupport;
|
|
340
|
-
/**
|
|
341
|
-
* Validate Anthropic model name format and availability
|
|
342
|
-
*/
|
|
343
|
-
private validateAnthropicModelName;
|
|
344
|
-
/**
|
|
345
|
-
* Analyze Anthropic model creation errors for detailed troubleshooting
|
|
346
|
-
*/
|
|
347
|
-
private analyzeAnthropicCreationError;
|
|
348
|
-
/**
|
|
349
|
-
* Get detailed troubleshooting steps based on error analysis
|
|
350
|
-
*/
|
|
351
|
-
private getAnthropicTroubleshootingSteps;
|
|
352
301
|
/**
|
|
353
302
|
* Register a tool with the AI provider
|
|
354
303
|
* @param name The name of the tool
|