@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/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [7.33.4](https://github.com/juspay/neurolink/compare/v7.33.3...v7.33.4) (2025-09-04)
|
2
|
+
|
3
|
+
### Bug Fixes
|
4
|
+
|
5
|
+
- **(azure):** resolve provider initialization and streaming issues ([f35114b](https://github.com/juspay/neurolink/commit/f35114bcf29ee23c3b9abefcb99c49f7a0533507))
|
6
|
+
|
7
|
+
## [7.33.3](https://github.com/juspay/neurolink/compare/v7.33.2...v7.33.3) (2025-09-04)
|
8
|
+
|
1
9
|
## [7.33.2](https://github.com/juspay/neurolink/compare/v7.33.1...v7.33.2) (2025-09-04)
|
2
10
|
|
3
11
|
### Bug Fixes
|
@@ -238,7 +238,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
238
238
|
preferences: z.ZodDefault<z.ZodObject<{
|
239
239
|
outputFormat: z.ZodDefault<z.ZodEnum<["text", "json", "yaml"]>>;
|
240
240
|
temperature: z.ZodDefault<z.ZodNumber>;
|
241
|
-
maxTokens: z.
|
241
|
+
maxTokens: z.ZodOptional<z.ZodNumber>;
|
242
242
|
enableLogging: z.ZodDefault<z.ZodBoolean>;
|
243
243
|
enableCaching: z.ZodDefault<z.ZodBoolean>;
|
244
244
|
cacheStrategy: z.ZodDefault<z.ZodEnum<["memory", "file", "redis"]>>;
|
@@ -246,7 +246,6 @@ declare const ConfigSchema: z.ZodObject<{
|
|
246
246
|
enableAnalyticsByDefault: z.ZodDefault<z.ZodBoolean>;
|
247
247
|
enableEvaluationByDefault: z.ZodDefault<z.ZodBoolean>;
|
248
248
|
}, "strip", z.ZodTypeAny, {
|
249
|
-
maxTokens: number;
|
250
249
|
temperature: number;
|
251
250
|
outputFormat: "text" | "json" | "yaml";
|
252
251
|
enableLogging: boolean;
|
@@ -254,6 +253,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
254
253
|
cacheStrategy: "memory" | "redis" | "file";
|
255
254
|
enableAnalyticsByDefault: boolean;
|
256
255
|
enableEvaluationByDefault: boolean;
|
256
|
+
maxTokens?: number | undefined;
|
257
257
|
defaultEvaluationDomain?: string | undefined;
|
258
258
|
}, {
|
259
259
|
maxTokens?: number | undefined;
|
@@ -508,7 +508,6 @@ declare const ConfigSchema: z.ZodObject<{
|
|
508
508
|
defaultProvider: "openai" | "anthropic" | "vertex" | "google-ai" | "bedrock" | "azure" | "huggingface" | "ollama" | "mistral" | "auto";
|
509
509
|
profiles: Record<string, any>;
|
510
510
|
preferences: {
|
511
|
-
maxTokens: number;
|
512
511
|
temperature: number;
|
513
512
|
outputFormat: "text" | "json" | "yaml";
|
514
513
|
enableLogging: boolean;
|
@@ -516,6 +515,7 @@ declare const ConfigSchema: z.ZodObject<{
|
|
516
515
|
cacheStrategy: "memory" | "redis" | "file";
|
517
516
|
enableAnalyticsByDefault: boolean;
|
518
517
|
enableEvaluationByDefault: boolean;
|
518
|
+
maxTokens?: number | undefined;
|
519
519
|
defaultEvaluationDomain?: string | undefined;
|
520
520
|
};
|
521
521
|
domains: {
|
@@ -713,7 +713,6 @@ export declare class ConfigManager {
|
|
713
713
|
* Mistral AI provider setup
|
714
714
|
*/
|
715
715
|
private setupMistral;
|
716
|
-
/**
|
717
716
|
/**
|
718
717
|
* Get current configuration
|
719
718
|
*/
|
@@ -110,7 +110,7 @@ const ConfigSchema = z.object({
|
|
110
110
|
.number()
|
111
111
|
.min(CLI_LIMITS.maxTokens.min)
|
112
112
|
.max(CLI_LIMITS.maxTokens.max)
|
113
|
-
.
|
113
|
+
.optional(), // No default limit
|
114
114
|
enableLogging: z.boolean().default(false),
|
115
115
|
enableCaching: z.boolean().default(true),
|
116
116
|
cacheStrategy: z.enum(["memory", "file", "redis"]).default("memory"),
|
@@ -726,7 +726,6 @@ export class ConfigManager {
|
|
726
726
|
]);
|
727
727
|
this.config.providers.mistral = answers;
|
728
728
|
}
|
729
|
-
/**
|
730
729
|
/**
|
731
730
|
* Get current configuration
|
732
731
|
*/
|
@@ -749,7 +748,7 @@ export class ConfigManager {
|
|
749
748
|
logger.always(` Default Provider: ${chalk.white(this.config.defaultProvider)}`);
|
750
749
|
logger.always(` Output Format: ${chalk.white(this.config.preferences.outputFormat)}`);
|
751
750
|
logger.always(` Temperature: ${chalk.white(this.config.preferences.temperature)}`);
|
752
|
-
logger.always(` Max Tokens: ${chalk.white(this.config.preferences.maxTokens)}`);
|
751
|
+
logger.always(` Max Tokens: ${chalk.white(this.config.preferences.maxTokens ?? "Provider default (no cap)")}`);
|
753
752
|
logger.always(` Default Evaluation Domain: ${chalk.white(this.config.preferences.defaultEvaluationDomain || "None")}`);
|
754
753
|
logger.always(` Analytics by Default: ${chalk.white(this.config.preferences.enableAnalyticsByDefault)}`);
|
755
754
|
logger.always(` Evaluation by Default: ${chalk.white(this.config.preferences.enableEvaluationByDefault)}`);
|
@@ -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
|
+
};
|
@@ -0,0 +1,195 @@
|
|
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
|
+
// ===== TIMEOUT CONSTANTS =====
|
16
|
+
export { TOOL_TIMEOUTS, PROVIDER_TIMEOUTS, MCP_TIMEOUTS, CIRCUIT_BREAKER_TIMEOUTS, NETWORK_TIMEOUTS, SYSTEM_TIMEOUTS, DEV_TIMEOUTS, TIMEOUTS, TimeoutUtils,
|
17
|
+
// Legacy compatibility
|
18
|
+
DEFAULT_TIMEOUT, PROVIDER_TEST_TIMEOUT, MCP_INIT_TIMEOUT, CIRCUIT_BREAKER_RESET_MS, } from "./timeouts.js";
|
19
|
+
// ===== RETRY CONSTANTS =====
|
20
|
+
export { RETRY_ATTEMPTS, RETRY_DELAYS, BACKOFF_CONFIG, CIRCUIT_BREAKER, PROVIDER_RETRY, OPERATION_RETRY, RetryUtils,
|
21
|
+
// Legacy compatibility
|
22
|
+
DEFAULT_RETRY_ATTEMPTS, DEFAULT_INITIAL_DELAY, DEFAULT_MAX_DELAY, DEFAULT_BACKOFF_MULTIPLIER, CIRCUIT_BREAKER_FAILURE_THRESHOLD, } from "./retry.js";
|
23
|
+
// ===== PERFORMANCE CONSTANTS =====
|
24
|
+
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,
|
25
|
+
// Legacy compatibility
|
26
|
+
HIGH_MEMORY_THRESHOLD, DEFAULT_CONCURRENCY_LIMIT, MAX_CONCURRENCY_LIMIT, SMALL_BUFFER_SIZE, LARGE_BUFFER_SIZE, DEFAULT_CACHE_SIZE,
|
27
|
+
// New convenience exports
|
28
|
+
NANOSECOND_TO_MS_DIVISOR, TEXT_PREVIEW_LENGTHS_EXPORT, PERFORMANCE_THRESHOLDS_EXPORT, } from "./performance.js";
|
29
|
+
// ===== TOKEN CONSTANTS =====
|
30
|
+
export { TOKEN_LIMITS, PROVIDER_TOKEN_LIMITS, USE_CASE_TOKENS, CONTEXT_WINDOWS, TOKEN_ESTIMATION, TokenUtils,
|
31
|
+
// Legacy compatibility
|
32
|
+
DEFAULT_MAX_TOKENS, DEFAULT_EVALUATION_MAX_TOKENS, DEFAULT_ANALYSIS_MAX_TOKENS, DEFAULT_DOCUMENTATION_MAX_TOKENS, ANTHROPIC_SAFE, OPENAI_STANDARD, GOOGLE_STANDARD, } from "./tokens.js";
|
33
|
+
// ===== COMPOSITE CONFIGURATIONS =====
|
34
|
+
/**
|
35
|
+
* Common timeout configurations for different operation types
|
36
|
+
*/
|
37
|
+
export const OPERATION_TIMEOUTS = {
|
38
|
+
QUICK: PROVIDER_TIMEOUTS.TEST_MS, // Fast operations (health checks, simple queries)
|
39
|
+
STANDARD: TOOL_TIMEOUTS.EXECUTION_DEFAULT_MS, // Standard operations (tool execution, generation)
|
40
|
+
EXTENDED: TOOL_TIMEOUTS.EXECUTION_COMPLEX_MS, // Long operations (complex analysis, large file processing)
|
41
|
+
CRITICAL: TOOL_TIMEOUTS.EXECUTION_BATCH_MS, // Critical operations (system initialization, backup)
|
42
|
+
};
|
43
|
+
// Import the constants from the individual files for use in composite configurations
|
44
|
+
import { PROVIDER_TIMEOUTS, MCP_TIMEOUTS, TimeoutUtils, TOOL_TIMEOUTS, } from "./timeouts.js";
|
45
|
+
import { RETRY_ATTEMPTS, RETRY_DELAYS, PROVIDER_RETRY, RetryUtils, } from "./retry.js";
|
46
|
+
import { CONCURRENCY_LIMITS, MEMORY_THRESHOLDS, BUFFER_SIZES, } from "./performance.js";
|
47
|
+
import { TokenUtils } from "./tokens.js";
|
48
|
+
/**
|
49
|
+
* Provider operation configurations combining timeouts and retries
|
50
|
+
*/
|
51
|
+
export const PROVIDER_OPERATION_CONFIGS = {
|
52
|
+
OPENAI: {
|
53
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
54
|
+
maxRetries: PROVIDER_RETRY.OPENAI.maxAttempts,
|
55
|
+
retryDelay: PROVIDER_RETRY.OPENAI.baseDelay,
|
56
|
+
},
|
57
|
+
ANTHROPIC: {
|
58
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
59
|
+
maxRetries: PROVIDER_RETRY.ANTHROPIC.maxAttempts,
|
60
|
+
retryDelay: PROVIDER_RETRY.ANTHROPIC.baseDelay,
|
61
|
+
},
|
62
|
+
GOOGLE_AI: {
|
63
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
64
|
+
maxRetries: PROVIDER_RETRY.GOOGLE.maxAttempts,
|
65
|
+
retryDelay: PROVIDER_RETRY.GOOGLE.baseDelay,
|
66
|
+
},
|
67
|
+
BEDROCK: {
|
68
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
69
|
+
maxRetries: PROVIDER_RETRY.BEDROCK.maxAttempts,
|
70
|
+
retryDelay: PROVIDER_RETRY.BEDROCK.baseDelay,
|
71
|
+
},
|
72
|
+
AZURE: {
|
73
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
74
|
+
maxRetries: PROVIDER_RETRY.AZURE.maxAttempts,
|
75
|
+
retryDelay: PROVIDER_RETRY.AZURE.baseDelay,
|
76
|
+
},
|
77
|
+
OLLAMA: {
|
78
|
+
timeout: PROVIDER_TIMEOUTS.CONNECTION_MS,
|
79
|
+
maxRetries: PROVIDER_RETRY.OLLAMA.maxAttempts,
|
80
|
+
retryDelay: PROVIDER_RETRY.OLLAMA.baseDelay,
|
81
|
+
},
|
82
|
+
};
|
83
|
+
/**
|
84
|
+
* MCP operation configurations for different server types
|
85
|
+
*/
|
86
|
+
export const MCP_OPERATION_CONFIGS = {
|
87
|
+
INITIALIZATION: {
|
88
|
+
timeout: MCP_TIMEOUTS.INITIALIZATION_MS,
|
89
|
+
maxRetries: RETRY_ATTEMPTS.DEFAULT,
|
90
|
+
retryDelay: RETRY_DELAYS.BASE_MS,
|
91
|
+
},
|
92
|
+
TOOL_DISCOVERY: {
|
93
|
+
timeout: MCP_TIMEOUTS.TOOL_DISCOVERY_MS,
|
94
|
+
maxRetries: RETRY_ATTEMPTS.DEFAULT,
|
95
|
+
retryDelay: RETRY_DELAYS.BASE_MS,
|
96
|
+
},
|
97
|
+
TOOL_EXECUTION: {
|
98
|
+
timeout: MCP_TIMEOUTS.TOOL_DISCOVERY_MS, // Reuse tool discovery timeout
|
99
|
+
maxRetries: RETRY_ATTEMPTS.DEFAULT,
|
100
|
+
retryDelay: RETRY_DELAYS.BASE_MS,
|
101
|
+
},
|
102
|
+
HEALTH_CHECK: {
|
103
|
+
timeout: PROVIDER_TIMEOUTS.TEST_MS, // Use provider test timeout for health checks
|
104
|
+
maxRetries: RETRY_ATTEMPTS.QUICK,
|
105
|
+
retryDelay: RETRY_DELAYS.QUICK_MS,
|
106
|
+
},
|
107
|
+
};
|
108
|
+
/**
|
109
|
+
* Performance profiles for different system loads
|
110
|
+
*/
|
111
|
+
export const PERFORMANCE_PROFILES = {
|
112
|
+
LOW_LOAD: {
|
113
|
+
concurrency: CONCURRENCY_LIMITS.LOW_RESOURCE,
|
114
|
+
memoryThreshold: MEMORY_THRESHOLDS.WARNING_MB,
|
115
|
+
bufferSize: BUFFER_SIZES.SMALL_BYTES,
|
116
|
+
},
|
117
|
+
NORMAL_LOAD: {
|
118
|
+
concurrency: CONCURRENCY_LIMITS.DEFAULT,
|
119
|
+
memoryThreshold: MEMORY_THRESHOLDS.WARNING_MB,
|
120
|
+
bufferSize: BUFFER_SIZES.STANDARD_BYTES,
|
121
|
+
},
|
122
|
+
HIGH_LOAD: {
|
123
|
+
concurrency: CONCURRENCY_LIMITS.HIGH_LOAD,
|
124
|
+
memoryThreshold: MEMORY_THRESHOLDS.CRITICAL_MB,
|
125
|
+
bufferSize: BUFFER_SIZES.LARGE_BYTES,
|
126
|
+
},
|
127
|
+
ENTERPRISE: {
|
128
|
+
concurrency: CONCURRENCY_LIMITS.HIGH_LOAD, // Use high load as enterprise default
|
129
|
+
memoryThreshold: MEMORY_THRESHOLDS.LEAK_DETECTION_MB, // Higher threshold for enterprise
|
130
|
+
bufferSize: BUFFER_SIZES.XLARGE_BYTES, // Larger buffers for enterprise
|
131
|
+
},
|
132
|
+
};
|
133
|
+
// ===== UTILITY FUNCTIONS =====
|
134
|
+
/**
|
135
|
+
* Get timeout value with environment-based adjustments
|
136
|
+
*/
|
137
|
+
export function getTimeout(baseTimeout, environment = "production") {
|
138
|
+
return TimeoutUtils.getEnvironmentTimeout(baseTimeout, environment);
|
139
|
+
}
|
140
|
+
/**
|
141
|
+
* Get retry configuration for a specific provider
|
142
|
+
*/
|
143
|
+
export function getProviderRetryConfig(provider) {
|
144
|
+
return RetryUtils.getProviderRetryConfig(provider);
|
145
|
+
}
|
146
|
+
/**
|
147
|
+
* Map use case to appropriate token limits
|
148
|
+
* @param useCase - Use case category
|
149
|
+
* @returns Token limit for the use case
|
150
|
+
*/
|
151
|
+
function mapUseCaseToTokenLimit(useCase = "standard") {
|
152
|
+
switch (useCase) {
|
153
|
+
case "conservative":
|
154
|
+
return 4096; // TOKEN_LIMITS.CONSERVATIVE
|
155
|
+
case "standard":
|
156
|
+
return 8192; // TOKEN_LIMITS.STANDARD
|
157
|
+
case "high_capacity":
|
158
|
+
return 16384; // TOKEN_LIMITS.HIGH_CAPACITY
|
159
|
+
default:
|
160
|
+
return 8192; // Default to standard
|
161
|
+
}
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* Get token limit for a specific provider and use case
|
165
|
+
* @param provider - Provider name
|
166
|
+
* @param useCase - Use case category that determines token limits
|
167
|
+
* @returns Token limit appropriate for the provider and use case
|
168
|
+
*/
|
169
|
+
export function getProviderTokenLimit(provider, useCase = "standard") {
|
170
|
+
// Get the base token limit for the use case
|
171
|
+
const useCaseLimit = mapUseCaseToTokenLimit(useCase);
|
172
|
+
// Get the provider's default limit (without specific model)
|
173
|
+
const providerLimit = TokenUtils.getProviderTokenLimit(provider);
|
174
|
+
// Return the minimum of use case limit and provider limit for safety
|
175
|
+
return Math.min(useCaseLimit, providerLimit);
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* Get performance configuration for current system load
|
179
|
+
*/
|
180
|
+
export function getPerformanceConfig(load = "normal") {
|
181
|
+
const upper = load.toUpperCase();
|
182
|
+
const loadKey = (upper === "ENTERPRISE" ? "ENTERPRISE" : `${upper}_LOAD`);
|
183
|
+
return PERFORMANCE_PROFILES[loadKey] ?? PERFORMANCE_PROFILES.NORMAL_LOAD;
|
184
|
+
}
|
185
|
+
// ===== VERSION AND METADATA =====
|
186
|
+
/**
|
187
|
+
* Constants system metadata
|
188
|
+
*/
|
189
|
+
export const CONSTANTS_METADATA = {
|
190
|
+
VERSION: "1.0.0",
|
191
|
+
LAST_UPDATED: "2025-01-27",
|
192
|
+
TOTAL_CONSTANTS: 300,
|
193
|
+
CATEGORIES: ["timeouts", "retry", "performance", "tokens"],
|
194
|
+
COMPATIBILITY: "backward_compatible",
|
195
|
+
};
|