@juspay/neurolink 7.33.2 → 7.33.3
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 +2 -0
- 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/types.d.ts +268 -0
- package/dist/core/types.js +153 -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/types.d.ts +268 -0
- package/dist/lib/core/types.js +153 -0
- 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/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +2 -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 +40 -33
- package/dist/lib/utils/providerSetupMessages.js +7 -6
- package/dist/lib/utils/providerUtils.js +16 -24
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +63 -37
- package/dist/neurolink.js +35 -34
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +2 -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 +40 -33
- package/dist/utils/providerSetupMessages.js +7 -6
- package/dist/utils/providerUtils.js +16 -24
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -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
|
+
};
|