@juspay/neurolink 7.33.2 → 7.33.4
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 +8 -0
- package/dist/cli/commands/config.d.ts +3 -4
- package/dist/cli/commands/config.js +2 -3
- package/dist/constants/index.d.ts +192 -0
- package/dist/constants/index.js +195 -0
- package/dist/constants/performance.d.ts +366 -0
- package/dist/constants/performance.js +389 -0
- package/dist/constants/retry.d.ts +224 -0
- package/dist/constants/retry.js +266 -0
- package/dist/constants/timeouts.d.ts +225 -0
- package/dist/constants/timeouts.js +182 -0
- package/dist/constants/tokens.d.ts +234 -0
- package/dist/constants/tokens.js +314 -0
- package/dist/core/baseProvider.js +26 -1
- package/dist/core/constants.d.ts +12 -3
- package/dist/core/constants.js +22 -6
- package/dist/core/factory.js +19 -0
- package/dist/core/types.d.ts +268 -0
- package/dist/core/types.js +153 -0
- package/dist/factories/providerRegistry.js +2 -0
- package/dist/lib/constants/index.d.ts +192 -0
- package/dist/lib/constants/index.js +195 -0
- package/dist/lib/constants/performance.d.ts +366 -0
- package/dist/lib/constants/performance.js +389 -0
- package/dist/lib/constants/retry.d.ts +224 -0
- package/dist/lib/constants/retry.js +266 -0
- package/dist/lib/constants/timeouts.d.ts +225 -0
- package/dist/lib/constants/timeouts.js +182 -0
- package/dist/lib/constants/tokens.d.ts +234 -0
- package/dist/lib/constants/tokens.js +314 -0
- package/dist/lib/core/baseProvider.js +26 -1
- package/dist/lib/core/constants.d.ts +12 -3
- package/dist/lib/core/constants.js +22 -6
- package/dist/lib/core/factory.js +19 -0
- package/dist/lib/core/types.d.ts +268 -0
- package/dist/lib/core/types.js +153 -0
- package/dist/lib/factories/providerRegistry.js +2 -0
- package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +2 -2
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +63 -37
- package/dist/lib/neurolink.js +35 -34
- package/dist/lib/providers/amazonBedrock.js +2 -2
- package/dist/lib/providers/anthropic.js +3 -12
- package/dist/lib/providers/anthropicBaseProvider.js +1 -2
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +51 -9
- package/dist/lib/providers/googleAiStudio.js +3 -3
- package/dist/lib/providers/googleVertex.js +2 -2
- package/dist/lib/providers/huggingFace.js +1 -2
- package/dist/lib/providers/litellm.js +1 -2
- package/dist/lib/providers/mistral.js +2 -2
- package/dist/lib/providers/ollama.js +7 -8
- package/dist/lib/providers/openAI.js +2 -2
- package/dist/lib/providers/openaiCompatible.js +5 -2
- package/dist/lib/providers/sagemaker/language-model.d.ts +5 -0
- package/dist/lib/providers/sagemaker/language-model.js +9 -1
- package/dist/lib/utils/providerConfig.d.ts +25 -0
- package/dist/lib/utils/providerConfig.js +24 -3
- package/dist/lib/utils/providerHealth.d.ts +1 -1
- package/dist/lib/utils/providerHealth.js +47 -36
- package/dist/lib/utils/providerSetupMessages.js +7 -6
- package/dist/lib/utils/providerUtils.js +16 -24
- package/dist/lib/utils/tokenLimits.d.ts +2 -2
- package/dist/lib/utils/tokenLimits.js +10 -3
- package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +2 -2
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +63 -37
- package/dist/neurolink.js +35 -34
- package/dist/providers/amazonBedrock.js +2 -2
- package/dist/providers/anthropic.js +3 -12
- package/dist/providers/anthropicBaseProvider.js +1 -2
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +51 -9
- package/dist/providers/googleAiStudio.js +3 -3
- package/dist/providers/googleVertex.js +2 -2
- package/dist/providers/huggingFace.js +1 -2
- package/dist/providers/litellm.js +1 -2
- package/dist/providers/mistral.js +2 -2
- package/dist/providers/ollama.js +7 -8
- package/dist/providers/openAI.js +2 -2
- package/dist/providers/openaiCompatible.js +5 -2
- package/dist/providers/sagemaker/language-model.d.ts +5 -0
- package/dist/providers/sagemaker/language-model.js +9 -1
- package/dist/utils/providerConfig.d.ts +25 -0
- package/dist/utils/providerConfig.js +24 -3
- package/dist/utils/providerHealth.d.ts +1 -1
- package/dist/utils/providerHealth.js +47 -36
- package/dist/utils/providerSetupMessages.js +7 -6
- package/dist/utils/providerUtils.js +16 -24
- package/dist/utils/tokenLimits.d.ts +2 -2
- package/dist/utils/tokenLimits.js +10 -3
- package/package.json +1 -1
package/dist/core/factory.js
CHANGED
@@ -111,6 +111,25 @@ export class AIProviderFactory {
|
|
111
111
|
logger.debug(`[${functionTag}] No Vertex environment variables found (VERTEX_MODEL)`);
|
112
112
|
}
|
113
113
|
}
|
114
|
+
else if (providerName.toLowerCase().includes("azure")) {
|
115
|
+
const envModel = process.env.AZURE_OPENAI_MODEL ||
|
116
|
+
process.env.AZURE_OPENAI_DEPLOYMENT ||
|
117
|
+
process.env.AZURE_OPENAI_DEPLOYMENT_ID;
|
118
|
+
if (envModel) {
|
119
|
+
resolvedModelName = envModel;
|
120
|
+
logger.debug(`[${functionTag}] Environment variable found for Azure`, {
|
121
|
+
envVariable: process.env.AZURE_OPENAI_MODEL
|
122
|
+
? "AZURE_OPENAI_MODEL"
|
123
|
+
: process.env.AZURE_OPENAI_DEPLOYMENT
|
124
|
+
? "AZURE_OPENAI_DEPLOYMENT"
|
125
|
+
: "AZURE_OPENAI_DEPLOYMENT_ID",
|
126
|
+
resolvedModel: envModel,
|
127
|
+
});
|
128
|
+
}
|
129
|
+
else {
|
130
|
+
logger.debug(`[${functionTag}] No Azure environment variables found (AZURE_OPENAI_MODEL, AZURE_OPENAI_DEPLOYMENT, AZURE_OPENAI_DEPLOYMENT_ID)`);
|
131
|
+
}
|
132
|
+
}
|
114
133
|
else {
|
115
134
|
logger.debug(`[${functionTag}] Provider ${providerName} - no environment variable check implemented`);
|
116
135
|
}
|
@@ -0,0 +1,268 @@
|
|
1
|
+
import type { Tool, Schema } from "ai";
|
2
|
+
import type { ZodUnknownSchema, ValidationSchema } from "../types/typeAliases.js";
|
3
|
+
import type { GenerateResult } from "../types/generateTypes.js";
|
4
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
5
|
+
import type { JsonValue } from "../types/common.js";
|
6
|
+
import type { ChatMessage, ConversationMemoryConfig } from "../types/conversationTypes.js";
|
7
|
+
import type { TokenUsage, AnalyticsData } from "../types/analytics.js";
|
8
|
+
import type { EvaluationData } from "../index.js";
|
9
|
+
export type { EvaluationData };
|
10
|
+
import type { MiddlewareFactoryOptions } from "../types/middlewareTypes.js";
|
11
|
+
export interface TextGenerationResult {
|
12
|
+
content: string;
|
13
|
+
provider?: string;
|
14
|
+
model?: string;
|
15
|
+
usage?: TokenUsage;
|
16
|
+
responseTime?: number;
|
17
|
+
toolsUsed?: string[];
|
18
|
+
toolExecutions?: Array<{
|
19
|
+
toolName: string;
|
20
|
+
executionTime: number;
|
21
|
+
success: boolean;
|
22
|
+
serverId?: string;
|
23
|
+
}>;
|
24
|
+
enhancedWithTools?: boolean;
|
25
|
+
availableTools?: Array<{
|
26
|
+
name: string;
|
27
|
+
description: string;
|
28
|
+
server: string;
|
29
|
+
category?: string;
|
30
|
+
}>;
|
31
|
+
analytics?: AnalyticsData;
|
32
|
+
evaluation?: EvaluationData;
|
33
|
+
}
|
34
|
+
/**
|
35
|
+
* Supported AI Provider Names
|
36
|
+
*/
|
37
|
+
export declare enum AIProviderName {
|
38
|
+
BEDROCK = "bedrock",
|
39
|
+
OPENAI = "openai",
|
40
|
+
OPENAI_COMPATIBLE = "openai-compatible",
|
41
|
+
VERTEX = "vertex",
|
42
|
+
ANTHROPIC = "anthropic",
|
43
|
+
AZURE = "azure",
|
44
|
+
GOOGLE_AI = "google-ai",
|
45
|
+
HUGGINGFACE = "huggingface",
|
46
|
+
OLLAMA = "ollama",
|
47
|
+
MISTRAL = "mistral",
|
48
|
+
LITELLM = "litellm",
|
49
|
+
SAGEMAKER = "sagemaker",
|
50
|
+
AUTO = "auto"
|
51
|
+
}
|
52
|
+
/**
|
53
|
+
* Supported Models for Amazon Bedrock
|
54
|
+
*/
|
55
|
+
export declare enum BedrockModels {
|
56
|
+
CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0",
|
57
|
+
CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0",
|
58
|
+
CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
59
|
+
CLAUDE_3_7_SONNET = "arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Supported Models for OpenAI
|
63
|
+
*/
|
64
|
+
export declare enum OpenAIModels {
|
65
|
+
GPT_4 = "gpt-4",
|
66
|
+
GPT_4_TURBO = "gpt-4-turbo",
|
67
|
+
GPT_4O = "gpt-4o",
|
68
|
+
GPT_4O_MINI = "gpt-4o-mini",
|
69
|
+
GPT_3_5_TURBO = "gpt-3.5-turbo",
|
70
|
+
O1_PREVIEW = "o1-preview",
|
71
|
+
O1_MINI = "o1-mini"
|
72
|
+
}
|
73
|
+
/**
|
74
|
+
* Supported Models for Google Vertex AI
|
75
|
+
*/
|
76
|
+
export declare enum VertexModels {
|
77
|
+
CLAUDE_4_0_SONNET = "claude-sonnet-4@20250514",
|
78
|
+
CLAUDE_4_0_OPUS = "claude-opus-4@20250514",
|
79
|
+
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
80
|
+
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
81
|
+
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
82
|
+
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
83
|
+
CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
|
84
|
+
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
85
|
+
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
86
|
+
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
87
|
+
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
88
|
+
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
89
|
+
GEMINI_1_5_FLASH = "gemini-1.5-flash"
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Supported Models for Google AI Studio
|
93
|
+
*/
|
94
|
+
export declare enum GoogleAIModels {
|
95
|
+
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
96
|
+
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
97
|
+
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
98
|
+
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
99
|
+
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
100
|
+
GEMINI_1_5_FLASH = "gemini-1.5-flash",
|
101
|
+
GEMINI_1_5_FLASH_LITE = "gemini-1.5-flash-lite"
|
102
|
+
}
|
103
|
+
/**
|
104
|
+
* Supported Models for Anthropic (Direct API)
|
105
|
+
*/
|
106
|
+
export declare enum AnthropicModels {
|
107
|
+
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
108
|
+
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
109
|
+
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
110
|
+
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
111
|
+
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
|
112
|
+
}
|
113
|
+
/**
|
114
|
+
* API Versions for various providers
|
115
|
+
*/
|
116
|
+
export declare enum APIVersions {
|
117
|
+
AZURE_LATEST = "2025-04-01-preview",
|
118
|
+
AZURE_STABLE = "2024-10-21",
|
119
|
+
AZURE_LEGACY = "2023-12-01-preview",
|
120
|
+
OPENAI_CURRENT = "v1",
|
121
|
+
OPENAI_BETA = "v1-beta",
|
122
|
+
GOOGLE_AI_CURRENT = "v1",
|
123
|
+
GOOGLE_AI_BETA = "v1beta",
|
124
|
+
ANTHROPIC_CURRENT = "2023-06-01"
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* Default model aliases for easy reference
|
128
|
+
*/
|
129
|
+
export declare const DEFAULT_MODEL_ALIASES: {
|
130
|
+
readonly LATEST_OPENAI: OpenAIModels.GPT_4O;
|
131
|
+
readonly FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI;
|
132
|
+
readonly LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET;
|
133
|
+
readonly FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU;
|
134
|
+
readonly LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO;
|
135
|
+
readonly FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH;
|
136
|
+
readonly BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET;
|
137
|
+
readonly BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO;
|
138
|
+
readonly BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET;
|
139
|
+
readonly BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH;
|
140
|
+
};
|
141
|
+
/**
|
142
|
+
* @deprecated Use DEFAULT_MODEL_ALIASES instead. Will be removed in future version.
|
143
|
+
*/
|
144
|
+
export declare const ModelAliases: {
|
145
|
+
readonly LATEST_OPENAI: OpenAIModels.GPT_4O;
|
146
|
+
readonly FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI;
|
147
|
+
readonly LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET;
|
148
|
+
readonly FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU;
|
149
|
+
readonly LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO;
|
150
|
+
readonly FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH;
|
151
|
+
readonly BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET;
|
152
|
+
readonly BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO;
|
153
|
+
readonly BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET;
|
154
|
+
readonly BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH;
|
155
|
+
};
|
156
|
+
/**
|
157
|
+
* Union type of all supported model names
|
158
|
+
*/
|
159
|
+
export type SupportedModelName = BedrockModels | OpenAIModels | VertexModels | GoogleAIModels | AnthropicModels;
|
160
|
+
/**
|
161
|
+
* Provider configuration specifying provider and its available models
|
162
|
+
*/
|
163
|
+
export interface ProviderConfig {
|
164
|
+
provider: AIProviderName;
|
165
|
+
models: SupportedModelName[];
|
166
|
+
}
|
167
|
+
/**
|
168
|
+
* Options for AI requests with unified provider configuration
|
169
|
+
*/
|
170
|
+
export interface StreamingOptions {
|
171
|
+
providers: ProviderConfig[];
|
172
|
+
temperature?: number;
|
173
|
+
maxTokens?: number;
|
174
|
+
systemPrompt?: string;
|
175
|
+
}
|
176
|
+
/**
|
177
|
+
* Text generation options interface
|
178
|
+
*/
|
179
|
+
export interface TextGenerationOptions {
|
180
|
+
prompt?: string;
|
181
|
+
input?: {
|
182
|
+
text: string;
|
183
|
+
};
|
184
|
+
provider?: AIProviderName;
|
185
|
+
model?: string;
|
186
|
+
temperature?: number;
|
187
|
+
maxTokens?: number;
|
188
|
+
systemPrompt?: string;
|
189
|
+
schema?: ZodUnknownSchema | Schema<unknown>;
|
190
|
+
tools?: Record<string, Tool>;
|
191
|
+
timeout?: number | string;
|
192
|
+
disableTools?: boolean;
|
193
|
+
maxSteps?: number;
|
194
|
+
enableEvaluation?: boolean;
|
195
|
+
enableAnalytics?: boolean;
|
196
|
+
context?: Record<string, JsonValue>;
|
197
|
+
evaluationDomain?: string;
|
198
|
+
toolUsageContext?: string;
|
199
|
+
conversationHistory?: Array<{
|
200
|
+
role: string;
|
201
|
+
content: string;
|
202
|
+
}>;
|
203
|
+
conversationMessages?: ChatMessage[];
|
204
|
+
conversationMemoryConfig?: Partial<ConversationMemoryConfig>;
|
205
|
+
originalPrompt?: string;
|
206
|
+
middleware?: MiddlewareFactoryOptions;
|
207
|
+
expectedOutcome?: string;
|
208
|
+
evaluationCriteria?: string[];
|
209
|
+
}
|
210
|
+
export type { AnalyticsData } from "../types/analytics.js";
|
211
|
+
/**
|
212
|
+
* Enhanced result interfaces with optional analytics/evaluation
|
213
|
+
*/
|
214
|
+
export interface EnhancedGenerateResult extends GenerateResult {
|
215
|
+
analytics?: AnalyticsData;
|
216
|
+
evaluation?: EvaluationData;
|
217
|
+
}
|
218
|
+
/**
|
219
|
+
* Phase 2: Enhanced Streaming Infrastructure
|
220
|
+
* Progress tracking and metadata for streaming operations
|
221
|
+
*/
|
222
|
+
export interface StreamingProgressData {
|
223
|
+
chunkCount: number;
|
224
|
+
totalBytes: number;
|
225
|
+
chunkSize: number;
|
226
|
+
elapsedTime: number;
|
227
|
+
estimatedRemaining?: number;
|
228
|
+
streamId?: string;
|
229
|
+
phase: "initializing" | "streaming" | "processing" | "complete" | "error";
|
230
|
+
}
|
231
|
+
export interface StreamingMetadata {
|
232
|
+
startTime: number;
|
233
|
+
endTime?: number;
|
234
|
+
totalDuration?: number;
|
235
|
+
averageChunkSize: number;
|
236
|
+
maxChunkSize: number;
|
237
|
+
minChunkSize: number;
|
238
|
+
throughputBytesPerSecond?: number;
|
239
|
+
streamingProvider: string;
|
240
|
+
modelUsed: string;
|
241
|
+
}
|
242
|
+
export type ProgressCallback = (progress: StreamingProgressData) => void;
|
243
|
+
/**
|
244
|
+
* AI Provider interface with flexible parameter support
|
245
|
+
*/
|
246
|
+
export interface AIProvider {
|
247
|
+
stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
248
|
+
generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
249
|
+
gen(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
250
|
+
setupToolExecutor(sdk: {
|
251
|
+
customTools: Map<string, unknown>;
|
252
|
+
executeTool: (toolName: string, params: unknown) => Promise<unknown>;
|
253
|
+
}, functionTag: string): void;
|
254
|
+
}
|
255
|
+
/**
|
256
|
+
* Provider attempt result for iteration tracking
|
257
|
+
*/
|
258
|
+
export interface ProviderAttempt {
|
259
|
+
provider: AIProviderName;
|
260
|
+
model: SupportedModelName;
|
261
|
+
success: boolean;
|
262
|
+
error?: string;
|
263
|
+
stack?: string;
|
264
|
+
}
|
265
|
+
/**
|
266
|
+
* Default provider configurations
|
267
|
+
*/
|
268
|
+
export declare const DEFAULT_PROVIDER_CONFIGS: ProviderConfig[];
|
@@ -0,0 +1,153 @@
|
|
1
|
+
/**
|
2
|
+
* Supported AI Provider Names
|
3
|
+
*/
|
4
|
+
export var AIProviderName;
|
5
|
+
(function (AIProviderName) {
|
6
|
+
AIProviderName["BEDROCK"] = "bedrock";
|
7
|
+
AIProviderName["OPENAI"] = "openai";
|
8
|
+
AIProviderName["OPENAI_COMPATIBLE"] = "openai-compatible";
|
9
|
+
AIProviderName["VERTEX"] = "vertex";
|
10
|
+
AIProviderName["ANTHROPIC"] = "anthropic";
|
11
|
+
AIProviderName["AZURE"] = "azure";
|
12
|
+
AIProviderName["GOOGLE_AI"] = "google-ai";
|
13
|
+
AIProviderName["HUGGINGFACE"] = "huggingface";
|
14
|
+
AIProviderName["OLLAMA"] = "ollama";
|
15
|
+
AIProviderName["MISTRAL"] = "mistral";
|
16
|
+
AIProviderName["LITELLM"] = "litellm";
|
17
|
+
AIProviderName["SAGEMAKER"] = "sagemaker";
|
18
|
+
AIProviderName["AUTO"] = "auto";
|
19
|
+
})(AIProviderName || (AIProviderName = {}));
|
20
|
+
/**
|
21
|
+
* Supported Models for Amazon Bedrock
|
22
|
+
*/
|
23
|
+
export var BedrockModels;
|
24
|
+
(function (BedrockModels) {
|
25
|
+
BedrockModels["CLAUDE_3_SONNET"] = "anthropic.claude-3-sonnet-20240229-v1:0";
|
26
|
+
BedrockModels["CLAUDE_3_HAIKU"] = "anthropic.claude-3-haiku-20240307-v1:0";
|
27
|
+
BedrockModels["CLAUDE_3_5_SONNET"] = "anthropic.claude-3-5-sonnet-20240620-v1:0";
|
28
|
+
BedrockModels["CLAUDE_3_7_SONNET"] = "arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0";
|
29
|
+
})(BedrockModels || (BedrockModels = {}));
|
30
|
+
/**
|
31
|
+
* Supported Models for OpenAI
|
32
|
+
*/
|
33
|
+
export var OpenAIModels;
|
34
|
+
(function (OpenAIModels) {
|
35
|
+
OpenAIModels["GPT_4"] = "gpt-4";
|
36
|
+
OpenAIModels["GPT_4_TURBO"] = "gpt-4-turbo";
|
37
|
+
OpenAIModels["GPT_4O"] = "gpt-4o";
|
38
|
+
OpenAIModels["GPT_4O_MINI"] = "gpt-4o-mini";
|
39
|
+
OpenAIModels["GPT_3_5_TURBO"] = "gpt-3.5-turbo";
|
40
|
+
OpenAIModels["O1_PREVIEW"] = "o1-preview";
|
41
|
+
OpenAIModels["O1_MINI"] = "o1-mini";
|
42
|
+
})(OpenAIModels || (OpenAIModels = {}));
|
43
|
+
/**
|
44
|
+
* Supported Models for Google Vertex AI
|
45
|
+
*/
|
46
|
+
export var VertexModels;
|
47
|
+
(function (VertexModels) {
|
48
|
+
// Claude 4 Series (Latest - May 2025)
|
49
|
+
VertexModels["CLAUDE_4_0_SONNET"] = "claude-sonnet-4@20250514";
|
50
|
+
VertexModels["CLAUDE_4_0_OPUS"] = "claude-opus-4@20250514";
|
51
|
+
// Claude 3.5 Series (Still supported)
|
52
|
+
VertexModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
53
|
+
VertexModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
54
|
+
// Claude 3 Series (Legacy support)
|
55
|
+
VertexModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
56
|
+
VertexModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
57
|
+
VertexModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
58
|
+
// Gemini 2.5 Series (Latest - 2025)
|
59
|
+
VertexModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
60
|
+
VertexModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
61
|
+
VertexModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
62
|
+
// Gemini 2.0 Series
|
63
|
+
VertexModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
64
|
+
// Gemini 1.5 Series (Legacy support)
|
65
|
+
VertexModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
66
|
+
VertexModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
67
|
+
})(VertexModels || (VertexModels = {}));
|
68
|
+
/**
|
69
|
+
* Supported Models for Google AI Studio
|
70
|
+
*/
|
71
|
+
export var GoogleAIModels;
|
72
|
+
(function (GoogleAIModels) {
|
73
|
+
// Gemini 2.5 Series (Latest - 2025)
|
74
|
+
GoogleAIModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
75
|
+
GoogleAIModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
76
|
+
GoogleAIModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
77
|
+
// Gemini 2.0 Series
|
78
|
+
GoogleAIModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
79
|
+
// Gemini 1.5 Series (Legacy support)
|
80
|
+
GoogleAIModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
81
|
+
GoogleAIModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
82
|
+
GoogleAIModels["GEMINI_1_5_FLASH_LITE"] = "gemini-1.5-flash-lite";
|
83
|
+
})(GoogleAIModels || (GoogleAIModels = {}));
|
84
|
+
/**
|
85
|
+
* Supported Models for Anthropic (Direct API)
|
86
|
+
*/
|
87
|
+
export var AnthropicModels;
|
88
|
+
(function (AnthropicModels) {
|
89
|
+
// Claude 3.5 Series (Latest)
|
90
|
+
AnthropicModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
91
|
+
AnthropicModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
92
|
+
// Claude 3 Series (Legacy support)
|
93
|
+
AnthropicModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
94
|
+
AnthropicModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
95
|
+
AnthropicModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
96
|
+
})(AnthropicModels || (AnthropicModels = {}));
|
97
|
+
/**
|
98
|
+
* API Versions for various providers
|
99
|
+
*/
|
100
|
+
export var APIVersions;
|
101
|
+
(function (APIVersions) {
|
102
|
+
// Azure OpenAI API versions
|
103
|
+
APIVersions["AZURE_LATEST"] = "2025-04-01-preview";
|
104
|
+
APIVersions["AZURE_STABLE"] = "2024-10-21";
|
105
|
+
APIVersions["AZURE_LEGACY"] = "2023-12-01-preview";
|
106
|
+
// OpenAI API versions
|
107
|
+
APIVersions["OPENAI_CURRENT"] = "v1";
|
108
|
+
APIVersions["OPENAI_BETA"] = "v1-beta";
|
109
|
+
// Google AI API versions
|
110
|
+
APIVersions["GOOGLE_AI_CURRENT"] = "v1";
|
111
|
+
APIVersions["GOOGLE_AI_BETA"] = "v1beta";
|
112
|
+
// Anthropic API versions
|
113
|
+
APIVersions["ANTHROPIC_CURRENT"] = "2023-06-01";
|
114
|
+
// Other provider versions can be added here
|
115
|
+
})(APIVersions || (APIVersions = {}));
|
116
|
+
/**
|
117
|
+
* Default model aliases for easy reference
|
118
|
+
*/
|
119
|
+
export const DEFAULT_MODEL_ALIASES = {
|
120
|
+
// Latest recommended models per provider
|
121
|
+
LATEST_OPENAI: OpenAIModels.GPT_4O,
|
122
|
+
FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI,
|
123
|
+
LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET,
|
124
|
+
FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU,
|
125
|
+
LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO,
|
126
|
+
FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH,
|
127
|
+
// Best models by use case
|
128
|
+
BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET,
|
129
|
+
BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO,
|
130
|
+
BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET,
|
131
|
+
BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH,
|
132
|
+
};
|
133
|
+
/**
|
134
|
+
* @deprecated Use DEFAULT_MODEL_ALIASES instead. Will be removed in future version.
|
135
|
+
*/
|
136
|
+
export const ModelAliases = DEFAULT_MODEL_ALIASES;
|
137
|
+
/**
|
138
|
+
* Default provider configurations
|
139
|
+
*/
|
140
|
+
export const DEFAULT_PROVIDER_CONFIGS = [
|
141
|
+
{
|
142
|
+
provider: AIProviderName.BEDROCK,
|
143
|
+
models: [BedrockModels.CLAUDE_3_7_SONNET, BedrockModels.CLAUDE_3_5_SONNET],
|
144
|
+
},
|
145
|
+
{
|
146
|
+
provider: AIProviderName.VERTEX,
|
147
|
+
models: [VertexModels.CLAUDE_4_0_SONNET, VertexModels.GEMINI_2_5_FLASH],
|
148
|
+
},
|
149
|
+
{
|
150
|
+
provider: AIProviderName.OPENAI,
|
151
|
+
models: [OpenAIModels.GPT_4O, OpenAIModels.GPT_4O_MINI],
|
152
|
+
},
|
153
|
+
];
|
@@ -49,6 +49,8 @@ export class ProviderRegistry {
|
|
49
49
|
const { AzureOpenAIProvider } = await import("../providers/azureOpenai.js");
|
50
50
|
return new AzureOpenAIProvider(modelName);
|
51
51
|
}, process.env.AZURE_MODEL ||
|
52
|
+
process.env.AZURE_OPENAI_MODEL ||
|
53
|
+
process.env.AZURE_OPENAI_DEPLOYMENT ||
|
52
54
|
process.env.AZURE_OPENAI_DEPLOYMENT_ID ||
|
53
55
|
"gpt-4o-mini", ["azure", "azureOpenai"]);
|
54
56
|
// Register Google Vertex AI provider
|
@@ -0,0 +1,192 @@
|
|
1
|
+
/**
|
2
|
+
* Unified Constants Export
|
3
|
+
*
|
4
|
+
* This file provides a centralized export point for all NeuroLink constants,
|
5
|
+
* replacing magic numbers throughout the codebase with named, documented values.
|
6
|
+
*
|
7
|
+
* Categories:
|
8
|
+
* - Timeouts: Tool execution, provider testing, MCP initialization
|
9
|
+
* - Retry Logic: Backoff strategies, circuit breaker patterns
|
10
|
+
* - Performance: Memory thresholds, concurrency limits, buffer sizes
|
11
|
+
* - Tokens: Provider limits, use-case specific allocations
|
12
|
+
*
|
13
|
+
* @see MAGIC_NUMBER_REFACTORING_ANALYSIS.md for implementation details
|
14
|
+
*/
|
15
|
+
export { TOOL_TIMEOUTS, PROVIDER_TIMEOUTS, MCP_TIMEOUTS, CIRCUIT_BREAKER_TIMEOUTS, NETWORK_TIMEOUTS, SYSTEM_TIMEOUTS, DEV_TIMEOUTS, TIMEOUTS, TimeoutUtils, DEFAULT_TIMEOUT, PROVIDER_TEST_TIMEOUT, MCP_INIT_TIMEOUT, CIRCUIT_BREAKER_RESET_MS, } from "./timeouts.js";
|
16
|
+
export { RETRY_ATTEMPTS, RETRY_DELAYS, BACKOFF_CONFIG, CIRCUIT_BREAKER, PROVIDER_RETRY, OPERATION_RETRY, RetryUtils, DEFAULT_RETRY_ATTEMPTS, DEFAULT_INITIAL_DELAY, DEFAULT_MAX_DELAY, DEFAULT_BACKOFF_MULTIPLIER, CIRCUIT_BREAKER_FAILURE_THRESHOLD, } from "./retry.js";
|
17
|
+
export { UNIT_CONVERSIONS, TEXT_PREVIEW_LENGTHS, PERFORMANCE_THRESHOLDS, MEMORY_THRESHOLDS, RESPONSE_TIME_THRESHOLDS, CONCURRENCY_LIMITS, BUFFER_SIZES, CACHE_CONFIG, MONITORING_CONFIG, OPTIMIZATION_THRESHOLDS, GC_CONFIG, SERVER_CONFIG, PerformanceUtils, HIGH_MEMORY_THRESHOLD, DEFAULT_CONCURRENCY_LIMIT, MAX_CONCURRENCY_LIMIT, SMALL_BUFFER_SIZE, LARGE_BUFFER_SIZE, DEFAULT_CACHE_SIZE, NANOSECOND_TO_MS_DIVISOR, TEXT_PREVIEW_LENGTHS_EXPORT, PERFORMANCE_THRESHOLDS_EXPORT, } from "./performance.js";
|
18
|
+
export { TOKEN_LIMITS, PROVIDER_TOKEN_LIMITS, USE_CASE_TOKENS, CONTEXT_WINDOWS, TOKEN_ESTIMATION, TokenUtils, DEFAULT_MAX_TOKENS, DEFAULT_EVALUATION_MAX_TOKENS, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_DOCUMENTATION_MAX_TOKENS, ANTHROPIC_SAFE, OPENAI_STANDARD, GOOGLE_STANDARD, } from "./tokens.js";
|
19
|
+
/**
|
20
|
+
* Common timeout configurations for different operation types
|
21
|
+
*/
|
22
|
+
export declare const OPERATION_TIMEOUTS: {
|
23
|
+
readonly QUICK: 5000;
|
24
|
+
readonly STANDARD: 30000;
|
25
|
+
readonly EXTENDED: 60000;
|
26
|
+
readonly CRITICAL: 120000;
|
27
|
+
};
|
28
|
+
import { TOOL_TIMEOUTS } from "./timeouts.js";
|
29
|
+
import { BACKOFF_CONFIG } from "./retry.js";
|
30
|
+
/**
|
31
|
+
* Provider operation configurations combining timeouts and retries
|
32
|
+
*/
|
33
|
+
export declare const PROVIDER_OPERATION_CONFIGS: {
|
34
|
+
readonly OPENAI: {
|
35
|
+
readonly timeout: 10000;
|
36
|
+
readonly maxRetries: 3;
|
37
|
+
readonly retryDelay: 1000;
|
38
|
+
};
|
39
|
+
readonly ANTHROPIC: {
|
40
|
+
readonly timeout: 10000;
|
41
|
+
readonly maxRetries: 3;
|
42
|
+
readonly retryDelay: 1000;
|
43
|
+
};
|
44
|
+
readonly GOOGLE_AI: {
|
45
|
+
readonly timeout: 10000;
|
46
|
+
readonly maxRetries: 4;
|
47
|
+
readonly retryDelay: 2000;
|
48
|
+
};
|
49
|
+
readonly BEDROCK: {
|
50
|
+
readonly timeout: 10000;
|
51
|
+
readonly maxRetries: 5;
|
52
|
+
readonly retryDelay: 1000;
|
53
|
+
};
|
54
|
+
readonly AZURE: {
|
55
|
+
readonly timeout: 10000;
|
56
|
+
readonly maxRetries: 3;
|
57
|
+
readonly retryDelay: 1000;
|
58
|
+
};
|
59
|
+
readonly OLLAMA: {
|
60
|
+
readonly timeout: 10000;
|
61
|
+
readonly maxRetries: 2;
|
62
|
+
readonly retryDelay: 200;
|
63
|
+
};
|
64
|
+
};
|
65
|
+
/**
|
66
|
+
* MCP operation configurations for different server types
|
67
|
+
*/
|
68
|
+
export declare const MCP_OPERATION_CONFIGS: {
|
69
|
+
readonly INITIALIZATION: {
|
70
|
+
readonly timeout: 3000;
|
71
|
+
readonly maxRetries: 3;
|
72
|
+
readonly retryDelay: 1000;
|
73
|
+
};
|
74
|
+
readonly TOOL_DISCOVERY: {
|
75
|
+
readonly timeout: 10000;
|
76
|
+
readonly maxRetries: 3;
|
77
|
+
readonly retryDelay: 1000;
|
78
|
+
};
|
79
|
+
readonly TOOL_EXECUTION: {
|
80
|
+
readonly timeout: 10000;
|
81
|
+
readonly maxRetries: 3;
|
82
|
+
readonly retryDelay: 1000;
|
83
|
+
};
|
84
|
+
readonly HEALTH_CHECK: {
|
85
|
+
readonly timeout: 5000;
|
86
|
+
readonly maxRetries: 2;
|
87
|
+
readonly retryDelay: 200;
|
88
|
+
};
|
89
|
+
};
|
90
|
+
/**
|
91
|
+
* Performance profiles for different system loads
|
92
|
+
*/
|
93
|
+
export declare const PERFORMANCE_PROFILES: {
|
94
|
+
readonly LOW_LOAD: {
|
95
|
+
readonly concurrency: 2;
|
96
|
+
readonly memoryThreshold: 100;
|
97
|
+
readonly bufferSize: 1024;
|
98
|
+
};
|
99
|
+
readonly NORMAL_LOAD: {
|
100
|
+
readonly concurrency: 5;
|
101
|
+
readonly memoryThreshold: 100;
|
102
|
+
readonly bufferSize: 4096;
|
103
|
+
};
|
104
|
+
readonly HIGH_LOAD: {
|
105
|
+
readonly concurrency: 10;
|
106
|
+
readonly memoryThreshold: 200;
|
107
|
+
readonly bufferSize: 8192;
|
108
|
+
};
|
109
|
+
readonly ENTERPRISE: {
|
110
|
+
readonly concurrency: 10;
|
111
|
+
readonly memoryThreshold: 300;
|
112
|
+
readonly bufferSize: 16384;
|
113
|
+
};
|
114
|
+
};
|
115
|
+
/**
|
116
|
+
* Get timeout value with environment-based adjustments
|
117
|
+
*/
|
118
|
+
export declare function getTimeout(baseTimeout: number, environment?: "development" | "test" | "production"): number;
|
119
|
+
/**
|
120
|
+
* Get retry configuration for a specific provider
|
121
|
+
*/
|
122
|
+
export declare function getProviderRetryConfig(provider: string): {
|
123
|
+
readonly maxAttempts: 3;
|
124
|
+
readonly baseDelay: 1000;
|
125
|
+
readonly maxDelay: 30000;
|
126
|
+
readonly multiplier: 2;
|
127
|
+
} | {
|
128
|
+
readonly maxAttempts: 3;
|
129
|
+
readonly baseDelay: 1000;
|
130
|
+
readonly maxDelay: 30000;
|
131
|
+
readonly multiplier: 1.5;
|
132
|
+
} | {
|
133
|
+
readonly maxAttempts: 4;
|
134
|
+
readonly baseDelay: 2000;
|
135
|
+
readonly maxDelay: 30000;
|
136
|
+
readonly multiplier: 2;
|
137
|
+
} | {
|
138
|
+
readonly maxAttempts: 5;
|
139
|
+
readonly baseDelay: 1000;
|
140
|
+
readonly maxDelay: 30000;
|
141
|
+
readonly multiplier: 1.5;
|
142
|
+
} | {
|
143
|
+
readonly maxAttempts: 2;
|
144
|
+
readonly baseDelay: 200;
|
145
|
+
readonly maxDelay: 5000;
|
146
|
+
readonly multiplier: 1.5;
|
147
|
+
};
|
148
|
+
/**
|
149
|
+
* Get token limit for a specific provider and use case
|
150
|
+
* @param provider - Provider name
|
151
|
+
* @param useCase - Use case category that determines token limits
|
152
|
+
* @returns Token limit appropriate for the provider and use case
|
153
|
+
*/
|
154
|
+
export declare function getProviderTokenLimit(provider: string, useCase?: "conservative" | "standard" | "high_capacity"): number;
|
155
|
+
/**
|
156
|
+
* Get performance configuration for current system load
|
157
|
+
*/
|
158
|
+
export declare function getPerformanceConfig(load?: "low" | "normal" | "high" | "enterprise"): {
|
159
|
+
readonly concurrency: 2;
|
160
|
+
readonly memoryThreshold: 100;
|
161
|
+
readonly bufferSize: 1024;
|
162
|
+
} | {
|
163
|
+
readonly concurrency: 5;
|
164
|
+
readonly memoryThreshold: 100;
|
165
|
+
readonly bufferSize: 4096;
|
166
|
+
} | {
|
167
|
+
readonly concurrency: 10;
|
168
|
+
readonly memoryThreshold: 200;
|
169
|
+
readonly bufferSize: 8192;
|
170
|
+
} | {
|
171
|
+
readonly concurrency: 10;
|
172
|
+
readonly memoryThreshold: 300;
|
173
|
+
readonly bufferSize: 16384;
|
174
|
+
};
|
175
|
+
/**
|
176
|
+
* Type definitions for configuration objects
|
177
|
+
*/
|
178
|
+
export type TimeoutCategory = keyof typeof TOOL_TIMEOUTS;
|
179
|
+
export type RetryStrategy = keyof typeof BACKOFF_CONFIG;
|
180
|
+
export type PerformanceProfile = keyof typeof PERFORMANCE_PROFILES;
|
181
|
+
export type ProviderConfig = (typeof PROVIDER_OPERATION_CONFIGS)[keyof typeof PROVIDER_OPERATION_CONFIGS];
|
182
|
+
export type McpConfig = (typeof MCP_OPERATION_CONFIGS)[keyof typeof MCP_OPERATION_CONFIGS];
|
183
|
+
/**
|
184
|
+
* Constants system metadata
|
185
|
+
*/
|
186
|
+
export declare const CONSTANTS_METADATA: {
|
187
|
+
readonly VERSION: "1.0.0";
|
188
|
+
readonly LAST_UPDATED: "2025-01-27";
|
189
|
+
readonly TOTAL_CONSTANTS: 300;
|
190
|
+
readonly CATEGORIES: readonly ["timeouts", "retry", "performance", "tokens"];
|
191
|
+
readonly COMPATIBILITY: "backward_compatible";
|
192
|
+
};
|