@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.
Files changed (92) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/cli/commands/config.d.ts +3 -4
  3. package/dist/cli/commands/config.js +2 -3
  4. package/dist/constants/index.d.ts +192 -0
  5. package/dist/constants/index.js +195 -0
  6. package/dist/constants/performance.d.ts +366 -0
  7. package/dist/constants/performance.js +389 -0
  8. package/dist/constants/retry.d.ts +224 -0
  9. package/dist/constants/retry.js +266 -0
  10. package/dist/constants/timeouts.d.ts +225 -0
  11. package/dist/constants/timeouts.js +182 -0
  12. package/dist/constants/tokens.d.ts +234 -0
  13. package/dist/constants/tokens.js +314 -0
  14. package/dist/core/baseProvider.js +26 -1
  15. package/dist/core/constants.d.ts +12 -3
  16. package/dist/core/constants.js +22 -6
  17. package/dist/core/factory.js +19 -0
  18. package/dist/core/types.d.ts +268 -0
  19. package/dist/core/types.js +153 -0
  20. package/dist/factories/providerRegistry.js +2 -0
  21. package/dist/lib/constants/index.d.ts +192 -0
  22. package/dist/lib/constants/index.js +195 -0
  23. package/dist/lib/constants/performance.d.ts +366 -0
  24. package/dist/lib/constants/performance.js +389 -0
  25. package/dist/lib/constants/retry.d.ts +224 -0
  26. package/dist/lib/constants/retry.js +266 -0
  27. package/dist/lib/constants/timeouts.d.ts +225 -0
  28. package/dist/lib/constants/timeouts.js +182 -0
  29. package/dist/lib/constants/tokens.d.ts +234 -0
  30. package/dist/lib/constants/tokens.js +314 -0
  31. package/dist/lib/core/baseProvider.js +26 -1
  32. package/dist/lib/core/constants.d.ts +12 -3
  33. package/dist/lib/core/constants.js +22 -6
  34. package/dist/lib/core/factory.js +19 -0
  35. package/dist/lib/core/types.d.ts +268 -0
  36. package/dist/lib/core/types.js +153 -0
  37. package/dist/lib/factories/providerRegistry.js +2 -0
  38. package/dist/lib/mcp/servers/aiProviders/aiWorkflowTools.js +2 -2
  39. package/dist/lib/models/modelRegistry.d.ts +1 -1
  40. package/dist/lib/models/modelRegistry.js +63 -37
  41. package/dist/lib/neurolink.js +35 -34
  42. package/dist/lib/providers/amazonBedrock.js +2 -2
  43. package/dist/lib/providers/anthropic.js +3 -12
  44. package/dist/lib/providers/anthropicBaseProvider.js +1 -2
  45. package/dist/lib/providers/azureOpenai.d.ts +1 -1
  46. package/dist/lib/providers/azureOpenai.js +51 -9
  47. package/dist/lib/providers/googleAiStudio.js +3 -3
  48. package/dist/lib/providers/googleVertex.js +2 -2
  49. package/dist/lib/providers/huggingFace.js +1 -2
  50. package/dist/lib/providers/litellm.js +1 -2
  51. package/dist/lib/providers/mistral.js +2 -2
  52. package/dist/lib/providers/ollama.js +7 -8
  53. package/dist/lib/providers/openAI.js +2 -2
  54. package/dist/lib/providers/openaiCompatible.js +5 -2
  55. package/dist/lib/providers/sagemaker/language-model.d.ts +5 -0
  56. package/dist/lib/providers/sagemaker/language-model.js +9 -1
  57. package/dist/lib/utils/providerConfig.d.ts +25 -0
  58. package/dist/lib/utils/providerConfig.js +24 -3
  59. package/dist/lib/utils/providerHealth.d.ts +1 -1
  60. package/dist/lib/utils/providerHealth.js +47 -36
  61. package/dist/lib/utils/providerSetupMessages.js +7 -6
  62. package/dist/lib/utils/providerUtils.js +16 -24
  63. package/dist/lib/utils/tokenLimits.d.ts +2 -2
  64. package/dist/lib/utils/tokenLimits.js +10 -3
  65. package/dist/mcp/servers/aiProviders/aiWorkflowTools.js +2 -2
  66. package/dist/models/modelRegistry.d.ts +1 -1
  67. package/dist/models/modelRegistry.js +63 -37
  68. package/dist/neurolink.js +35 -34
  69. package/dist/providers/amazonBedrock.js +2 -2
  70. package/dist/providers/anthropic.js +3 -12
  71. package/dist/providers/anthropicBaseProvider.js +1 -2
  72. package/dist/providers/azureOpenai.d.ts +1 -1
  73. package/dist/providers/azureOpenai.js +51 -9
  74. package/dist/providers/googleAiStudio.js +3 -3
  75. package/dist/providers/googleVertex.js +2 -2
  76. package/dist/providers/huggingFace.js +1 -2
  77. package/dist/providers/litellm.js +1 -2
  78. package/dist/providers/mistral.js +2 -2
  79. package/dist/providers/ollama.js +7 -8
  80. package/dist/providers/openAI.js +2 -2
  81. package/dist/providers/openaiCompatible.js +5 -2
  82. package/dist/providers/sagemaker/language-model.d.ts +5 -0
  83. package/dist/providers/sagemaker/language-model.js +9 -1
  84. package/dist/utils/providerConfig.d.ts +25 -0
  85. package/dist/utils/providerConfig.js +24 -3
  86. package/dist/utils/providerHealth.d.ts +1 -1
  87. package/dist/utils/providerHealth.js +47 -36
  88. package/dist/utils/providerSetupMessages.js +7 -6
  89. package/dist/utils/providerUtils.js +16 -24
  90. package/dist/utils/tokenLimits.d.ts +2 -2
  91. package/dist/utils/tokenLimits.js +10 -3
  92. package/package.json +1 -1
@@ -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
+ };
@@ -0,0 +1,366 @@
1
+ /**
2
+ * Performance and Resource Constants for NeuroLink
3
+ *
4
+ * Centralized performance configuration to replace magic numbers throughout the codebase.
5
+ * Includes memory thresholds, concurrency limits, buffer sizes, and cache configurations.
6
+ *
7
+ * @fileoverview Performance constants for optimal resource utilization
8
+ * @author NeuroLink Team
9
+ * @version 1.0.0
10
+ */
11
+ /**
12
+ * Unit conversion constants
13
+ * Common conversion factors to replace magic numbers
14
+ */
15
+ export declare const UNIT_CONVERSIONS: {
16
+ /** Conversion factor from nanoseconds to milliseconds */
17
+ readonly NANOSECOND_TO_MS_DIVISOR: 1000000;
18
+ /** Conversion factor from microseconds to milliseconds */
19
+ readonly MICROSECOND_TO_MS_DIVISOR: 1000;
20
+ /** Conversion factor from seconds to milliseconds */
21
+ readonly SECOND_TO_MS_MULTIPLIER: 1000;
22
+ /** Conversion factor from minutes to milliseconds */
23
+ readonly MINUTE_TO_MS_MULTIPLIER: 60000;
24
+ /** Conversion factor from hours to milliseconds */
25
+ readonly HOUR_TO_MS_MULTIPLIER: 3600000;
26
+ };
27
+ /**
28
+ * Text processing constants
29
+ * Standard lengths for text preview, logging, and truncation
30
+ */
31
+ export declare const TEXT_PREVIEW_LENGTHS: {
32
+ /** Very short preview for debugging */
33
+ readonly VERY_SHORT: 50;
34
+ /** Short preview for compact logging */
35
+ readonly SHORT: 100;
36
+ /** Medium preview for standard logging */
37
+ readonly MEDIUM: 150;
38
+ /** Standard preview length */
39
+ readonly STANDARD: 200;
40
+ /** Long preview for detailed context */
41
+ readonly LONG: 300;
42
+ /** Extra long preview for comprehensive view */
43
+ readonly EXTRA_LONG: 500;
44
+ /** Maximum preview length before truncation */
45
+ readonly MAX_PREVIEW: 1000;
46
+ };
47
+ /**
48
+ * Performance thresholds for various operations
49
+ * Unified thresholds to replace scattered magic numbers
50
+ */
51
+ export declare const PERFORMANCE_THRESHOLDS: {
52
+ /** Success rate threshold for tool reliability */
53
+ readonly SUCCESS_RATE_THRESHOLD: 0.8;
54
+ /** High success rate threshold */
55
+ readonly HIGH_SUCCESS_RATE: 0.95;
56
+ /** Low success rate warning threshold */
57
+ readonly LOW_SUCCESS_RATE_WARNING: 0.6;
58
+ /** Critical success rate threshold */
59
+ readonly CRITICAL_SUCCESS_RATE: 0.5;
60
+ /** Tool execution time warning threshold (ms) */
61
+ readonly TOOL_EXECUTION_WARNING_MS: 10000;
62
+ /** Large tool collection threshold */
63
+ readonly LARGE_TOOL_COLLECTION: 100;
64
+ /** Circuit breaker failure threshold */
65
+ readonly CIRCUIT_BREAKER_FAILURES: 5;
66
+ /** Circuit breaker reset timeout (ms) */
67
+ readonly CIRCUIT_BREAKER_RESET_MS: 60000;
68
+ };
69
+ /**
70
+ * Memory threshold configuration
71
+ * Thresholds for monitoring and alerting on memory usage
72
+ */
73
+ export declare const MEMORY_THRESHOLDS: {
74
+ /** Warning threshold for general memory usage */
75
+ readonly WARNING_MB: 100;
76
+ /** Critical threshold requiring immediate attention */
77
+ readonly CRITICAL_MB: 200;
78
+ /** Tool-specific memory warning threshold */
79
+ readonly TOOL_WARNING_MB: 20;
80
+ /** Tool critical memory threshold */
81
+ readonly TOOL_CRITICAL_MB: 50;
82
+ /** Memory leak detection threshold */
83
+ readonly LEAK_DETECTION_MB: 300;
84
+ /** Maximum allowed memory before forced cleanup */
85
+ readonly MAX_ALLOWED_MB: 500;
86
+ /** Heap growth rate warning (MB per minute) */
87
+ readonly GROWTH_RATE_WARNING_MB_PER_MIN: 10;
88
+ /** Moderate memory usage threshold */
89
+ readonly MODERATE_USAGE_MB: 30;
90
+ /** Low memory usage threshold */
91
+ readonly LOW_USAGE_MB: 10;
92
+ /** Moderate memory delta threshold for operations */
93
+ readonly OPERATION_MODERATE_MB: 30;
94
+ /** Small memory delta threshold for operations */
95
+ readonly OPERATION_SMALL_MB: 10;
96
+ /** Large memory delta threshold requiring GC */
97
+ readonly OPERATION_LARGE_MB: 50;
98
+ };
99
+ /**
100
+ * Response time threshold configuration
101
+ * Defines what constitutes fast, acceptable, and slow response times
102
+ */
103
+ export declare const RESPONSE_TIME_THRESHOLDS: {
104
+ /** Fast response time - excellent performance */
105
+ readonly FAST_MS: 1000;
106
+ /** Acceptable response time - good performance */
107
+ readonly ACCEPTABLE_MS: 5000;
108
+ /** Slow response time - needs optimization */
109
+ readonly SLOW_MS: 10000;
110
+ /** Critical response time - unacceptable */
111
+ readonly CRITICAL_MS: 30000;
112
+ /** Tool execution fast threshold */
113
+ readonly TOOL_FAST_MS: 2000;
114
+ /** Tool execution slow threshold */
115
+ readonly TOOL_SLOW_MS: 15000;
116
+ /** Provider response fast threshold */
117
+ readonly PROVIDER_FAST_MS: 3000;
118
+ /** Provider response slow threshold */
119
+ readonly PROVIDER_SLOW_MS: 20000;
120
+ };
121
+ /**
122
+ * Concurrency limit configuration
123
+ * Controls parallel execution to prevent resource exhaustion
124
+ */
125
+ export declare const CONCURRENCY_LIMITS: {
126
+ /** Default concurrent operations */
127
+ readonly DEFAULT: 5;
128
+ /** High-load scenario concurrency */
129
+ readonly HIGH_LOAD: 10;
130
+ /** Low-resource environment concurrency */
131
+ readonly LOW_RESOURCE: 2;
132
+ /** Provider-specific concurrency */
133
+ readonly PROVIDER: 3;
134
+ /** Tool execution concurrency */
135
+ readonly TOOL_EXECUTION: 4;
136
+ /** MCP server concurrency */
137
+ readonly MCP_SERVER: 8;
138
+ /** Network request concurrency */
139
+ readonly NETWORK_REQUEST: 6;
140
+ /** Maximum concurrent streams */
141
+ readonly MAX_STREAMS: 3;
142
+ /** Database operation concurrency */
143
+ readonly DATABASE: 5;
144
+ };
145
+ /**
146
+ * Buffer size configuration
147
+ * Optimized buffer sizes for different types of operations
148
+ */
149
+ export declare const BUFFER_SIZES: {
150
+ /** Small buffer for lightweight operations */
151
+ readonly SMALL_BYTES: 1024;
152
+ /** Standard buffer for most operations */
153
+ readonly STANDARD_BYTES: 4096;
154
+ /** Large buffer for heavy operations */
155
+ readonly LARGE_BYTES: 8192;
156
+ /** Extra large buffer for file operations */
157
+ readonly XLARGE_BYTES: 16384;
158
+ /** Memory buffer for streaming */
159
+ readonly STREAM_BYTES: 2048;
160
+ /** Network buffer size */
161
+ readonly NETWORK_BYTES: 4096;
162
+ /** File I/O buffer size */
163
+ readonly FILE_IO_BYTES: 8192;
164
+ /** Maximum single buffer size */
165
+ readonly MAX_BYTES: 32768;
166
+ };
167
+ /**
168
+ * Cache configuration
169
+ * Size limits and policies for various cache types
170
+ */
171
+ export declare const CACHE_CONFIG: {
172
+ /** Small cache for frequently accessed items */
173
+ readonly SMALL_SIZE: 100;
174
+ /** Default cache size for most use cases */
175
+ readonly DEFAULT_SIZE: 1000;
176
+ /** Large cache for extensive data */
177
+ readonly LARGE_SIZE: 10000;
178
+ /** Provider cache size */
179
+ readonly PROVIDER_CACHE_SIZE: 500;
180
+ /** Tool registry cache size */
181
+ readonly TOOL_REGISTRY_SIZE: 200;
182
+ /** Model configuration cache */
183
+ readonly MODEL_CONFIG_SIZE: 50;
184
+ /** Session cache size */
185
+ readonly SESSION_CACHE_SIZE: 1000;
186
+ /** Maximum cache size */
187
+ readonly MAX_SIZE: 50000;
188
+ /** Cache TTL in milliseconds */
189
+ readonly DEFAULT_TTL_MS: 300000;
190
+ /** Short TTL for volatile data */
191
+ readonly SHORT_TTL_MS: 60000;
192
+ /** Long TTL for stable data */
193
+ readonly LONG_TTL_MS: 3600000;
194
+ };
195
+ /**
196
+ * Resource monitoring configuration
197
+ * Intervals and thresholds for monitoring system resources
198
+ */
199
+ export declare const MONITORING_CONFIG: {
200
+ /** Default monitoring interval */
201
+ readonly DEFAULT_INTERVAL_MS: 30000;
202
+ /** High-frequency monitoring interval */
203
+ readonly HIGH_FREQ_INTERVAL_MS: 5000;
204
+ /** Low-frequency monitoring interval */
205
+ readonly LOW_FREQ_INTERVAL_MS: 60000;
206
+ /** Memory check interval */
207
+ readonly MEMORY_CHECK_INTERVAL_MS: 15000;
208
+ /** Performance metrics collection interval */
209
+ readonly METRICS_INTERVAL_MS: 10000;
210
+ /** Health check interval */
211
+ readonly HEALTH_CHECK_INTERVAL_MS: 30000;
212
+ /** CPU usage check interval */
213
+ readonly CPU_CHECK_INTERVAL_MS: 20000;
214
+ /** Disk usage check interval */
215
+ readonly DISK_CHECK_INTERVAL_MS: 120000;
216
+ };
217
+ /**
218
+ * Performance optimization thresholds
219
+ * Values that trigger performance optimization actions
220
+ */
221
+ export declare const OPTIMIZATION_THRESHOLDS: {
222
+ /** CPU usage threshold for optimization */
223
+ readonly CPU_USAGE_PERCENT: 80;
224
+ /** Memory usage threshold for cleanup */
225
+ readonly MEMORY_CLEANUP_PERCENT: 85;
226
+ /** Disk usage threshold for cleanup */
227
+ readonly DISK_CLEANUP_PERCENT: 90;
228
+ /** Connection pool optimization threshold */
229
+ readonly CONNECTION_POOL_PERCENT: 75;
230
+ /** Cache hit rate minimum threshold */
231
+ readonly CACHE_HIT_RATE_MIN_PERCENT: 60;
232
+ /** Queue length threshold for scaling */
233
+ readonly QUEUE_LENGTH_THRESHOLD: 50;
234
+ /** Error rate threshold for intervention */
235
+ readonly ERROR_RATE_THRESHOLD_PERCENT: 5;
236
+ };
237
+ /**
238
+ * Garbage collection configuration
239
+ * Settings for automatic resource cleanup
240
+ */
241
+ export declare const GC_CONFIG: {
242
+ /** Memory threshold for forced GC */
243
+ readonly FORCE_GC_THRESHOLD_MB: 400;
244
+ /** Interval for automatic GC checks */
245
+ readonly AUTO_GC_INTERVAL_MS: 120000;
246
+ /** Memory growth rate for GC trigger */
247
+ readonly GC_TRIGGER_GROWTH_MB: 50;
248
+ /** Cache cleanup interval */
249
+ readonly CACHE_CLEANUP_INTERVAL_MS: 300000;
250
+ /** Temporary file cleanup interval */
251
+ readonly TEMP_FILE_CLEANUP_MS: 600000;
252
+ /** Log rotation threshold */
253
+ readonly LOG_ROTATION_SIZE_MB: 100;
254
+ };
255
+ /**
256
+ * Server configuration constants
257
+ * Default configurations for various server types
258
+ */
259
+ export declare const SERVER_CONFIG: {
260
+ /** Maximum number of MCP servers */
261
+ readonly MAX_MCP_SERVERS: 20;
262
+ /** Default Ollama port */
263
+ readonly DEFAULT_OLLAMA_PORT: 11434;
264
+ /** Maximum number of event handlers */
265
+ readonly MAX_EVENT_HANDLERS: 5;
266
+ /** Default server startup timeout */
267
+ readonly STARTUP_TIMEOUT_MS: 15000;
268
+ /** Provider test timeout */
269
+ readonly PROVIDER_TEST_TIMEOUT_MS: 5000;
270
+ /** MCP connection test timeout */
271
+ readonly MCP_CONNECTION_TEST_TIMEOUT_MS: 10000;
272
+ /** External tool execution timeout */
273
+ readonly EXTERNAL_TOOL_TIMEOUT_MS: 30000;
274
+ };
275
+ /**
276
+ * Performance utility functions
277
+ */
278
+ export declare const PerformanceUtils: {
279
+ /**
280
+ * Get appropriate concurrency limit based on available resources
281
+ * @param resourceLevel - Resource availability level (low, medium, high)
282
+ * @returns Recommended concurrency limit
283
+ */
284
+ readonly getConcurrencyLimit: (resourceLevel?: "low" | "medium" | "high") => number;
285
+ /**
286
+ * Get appropriate buffer size for operation type
287
+ * @param operationType - Type of operation (network, file, stream, etc.)
288
+ * @returns Recommended buffer size in bytes
289
+ */
290
+ readonly getBufferSize: (operationType?: "network" | "file" | "stream" | "standard") => number;
291
+ /**
292
+ * Get cache configuration for specific use case
293
+ * @param useCase - Cache use case (provider, tool, model, session)
294
+ * @returns Cache configuration object
295
+ */
296
+ readonly getCacheConfig: (useCase?: "provider" | "tool" | "model" | "session" | "default") => {
297
+ ttl: 300000;
298
+ maxSize: 1000;
299
+ } | {
300
+ maxSize: 500;
301
+ ttl: 300000;
302
+ } | {
303
+ maxSize: 200;
304
+ ttl: 300000;
305
+ } | {
306
+ maxSize: 50;
307
+ ttl: 3600000;
308
+ } | {
309
+ maxSize: 1000;
310
+ ttl: 60000;
311
+ };
312
+ /**
313
+ * Check if memory usage exceeds threshold
314
+ * @param currentUsageMB - Current memory usage in MB
315
+ * @param threshold - Threshold type to check against
316
+ * @returns True if threshold is exceeded
317
+ */
318
+ readonly isMemoryThresholdExceeded: (currentUsageMB: number, threshold?: "warning" | "critical" | "tool" | "leak") => boolean;
319
+ /**
320
+ * Categorize response time performance
321
+ * @param responseTimeMs - Response time in milliseconds
322
+ * @returns Performance category
323
+ */
324
+ readonly categorizeResponseTime: (responseTimeMs: number) => "fast" | "acceptable" | "slow" | "critical";
325
+ };
326
+ export declare const HIGH_MEMORY_THRESHOLD: 100;
327
+ export declare const DEFAULT_CONCURRENCY_LIMIT: 5;
328
+ export declare const MAX_CONCURRENCY_LIMIT: 10;
329
+ export declare const SMALL_BUFFER_SIZE: 1024;
330
+ export declare const LARGE_BUFFER_SIZE: 8192;
331
+ export declare const DEFAULT_CACHE_SIZE: 1000;
332
+ export declare const NANOSECOND_TO_MS_DIVISOR: 1000000;
333
+ export declare const TEXT_PREVIEW_LENGTHS_EXPORT: {
334
+ /** Very short preview for debugging */
335
+ readonly VERY_SHORT: 50;
336
+ /** Short preview for compact logging */
337
+ readonly SHORT: 100;
338
+ /** Medium preview for standard logging */
339
+ readonly MEDIUM: 150;
340
+ /** Standard preview length */
341
+ readonly STANDARD: 200;
342
+ /** Long preview for detailed context */
343
+ readonly LONG: 300;
344
+ /** Extra long preview for comprehensive view */
345
+ readonly EXTRA_LONG: 500;
346
+ /** Maximum preview length before truncation */
347
+ readonly MAX_PREVIEW: 1000;
348
+ };
349
+ export declare const PERFORMANCE_THRESHOLDS_EXPORT: {
350
+ /** Success rate threshold for tool reliability */
351
+ readonly SUCCESS_RATE_THRESHOLD: 0.8;
352
+ /** High success rate threshold */
353
+ readonly HIGH_SUCCESS_RATE: 0.95;
354
+ /** Low success rate warning threshold */
355
+ readonly LOW_SUCCESS_RATE_WARNING: 0.6;
356
+ /** Critical success rate threshold */
357
+ readonly CRITICAL_SUCCESS_RATE: 0.5;
358
+ /** Tool execution time warning threshold (ms) */
359
+ readonly TOOL_EXECUTION_WARNING_MS: 10000;
360
+ /** Large tool collection threshold */
361
+ readonly LARGE_TOOL_COLLECTION: 100;
362
+ /** Circuit breaker failure threshold */
363
+ readonly CIRCUIT_BREAKER_FAILURES: 5;
364
+ /** Circuit breaker reset timeout (ms) */
365
+ readonly CIRCUIT_BREAKER_RESET_MS: 60000;
366
+ };