@juspay/neurolink 7.6.1 → 7.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/CHANGELOG.md +9 -4
  2. package/README.md +78 -3
  3. package/dist/cli/commands/config.d.ts +275 -3
  4. package/dist/cli/commands/config.js +121 -0
  5. package/dist/cli/commands/mcp.js +77 -28
  6. package/dist/cli/factories/commandFactory.js +359 -6
  7. package/dist/core/analytics.js +7 -27
  8. package/dist/core/baseProvider.js +43 -4
  9. package/dist/core/constants.d.ts +46 -0
  10. package/dist/core/constants.js +47 -0
  11. package/dist/core/dynamicModels.d.ts +16 -4
  12. package/dist/core/dynamicModels.js +130 -26
  13. package/dist/core/evaluation.js +5 -1
  14. package/dist/core/evaluationProviders.d.ts +6 -2
  15. package/dist/core/evaluationProviders.js +41 -125
  16. package/dist/core/factory.d.ts +5 -0
  17. package/dist/core/factory.js +62 -50
  18. package/dist/core/modelConfiguration.d.ts +246 -0
  19. package/dist/core/modelConfiguration.js +775 -0
  20. package/dist/core/types.d.ts +22 -3
  21. package/dist/core/types.js +5 -1
  22. package/dist/factories/providerRegistry.js +3 -3
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.js +1 -1
  25. package/dist/lib/core/analytics.js +7 -27
  26. package/dist/lib/core/baseProvider.js +43 -4
  27. package/dist/lib/core/constants.d.ts +46 -0
  28. package/dist/lib/core/constants.js +47 -0
  29. package/dist/lib/core/dynamicModels.d.ts +16 -4
  30. package/dist/lib/core/dynamicModels.js +130 -26
  31. package/dist/lib/core/evaluation.js +5 -1
  32. package/dist/lib/core/evaluationProviders.d.ts +6 -2
  33. package/dist/lib/core/evaluationProviders.js +41 -125
  34. package/dist/lib/core/factory.d.ts +5 -0
  35. package/dist/lib/core/factory.js +63 -50
  36. package/dist/lib/core/modelConfiguration.d.ts +246 -0
  37. package/dist/lib/core/modelConfiguration.js +775 -0
  38. package/dist/lib/core/types.d.ts +22 -3
  39. package/dist/lib/core/types.js +5 -1
  40. package/dist/lib/factories/providerRegistry.js +3 -3
  41. package/dist/lib/index.d.ts +1 -1
  42. package/dist/lib/index.js +1 -1
  43. package/dist/lib/mcp/factory.d.ts +5 -5
  44. package/dist/lib/mcp/factory.js +2 -2
  45. package/dist/lib/mcp/servers/utilities/utilityServer.d.ts +1 -1
  46. package/dist/lib/mcp/servers/utilities/utilityServer.js +1 -1
  47. package/dist/lib/mcp/toolRegistry.js +2 -2
  48. package/dist/lib/neurolink.d.ts +168 -12
  49. package/dist/lib/neurolink.js +685 -123
  50. package/dist/lib/providers/anthropic.js +52 -2
  51. package/dist/lib/providers/googleAiStudio.js +4 -0
  52. package/dist/lib/providers/googleVertex.d.ts +75 -9
  53. package/dist/lib/providers/googleVertex.js +365 -46
  54. package/dist/lib/providers/huggingFace.d.ts +52 -11
  55. package/dist/lib/providers/huggingFace.js +180 -42
  56. package/dist/lib/providers/litellm.d.ts +9 -9
  57. package/dist/lib/providers/litellm.js +103 -16
  58. package/dist/lib/providers/ollama.d.ts +52 -17
  59. package/dist/lib/providers/ollama.js +276 -68
  60. package/dist/lib/sdk/toolRegistration.d.ts +42 -0
  61. package/dist/lib/sdk/toolRegistration.js +269 -27
  62. package/dist/lib/telemetry/telemetryService.d.ts +6 -0
  63. package/dist/lib/telemetry/telemetryService.js +38 -3
  64. package/dist/lib/types/contextTypes.d.ts +75 -11
  65. package/dist/lib/types/contextTypes.js +227 -1
  66. package/dist/lib/types/domainTypes.d.ts +62 -0
  67. package/dist/lib/types/domainTypes.js +5 -0
  68. package/dist/lib/types/generateTypes.d.ts +52 -0
  69. package/dist/lib/types/index.d.ts +1 -0
  70. package/dist/lib/types/mcpTypes.d.ts +1 -1
  71. package/dist/lib/types/mcpTypes.js +1 -1
  72. package/dist/lib/types/streamTypes.d.ts +14 -0
  73. package/dist/lib/types/universalProviderOptions.d.ts +1 -1
  74. package/dist/lib/utils/errorHandling.d.ts +142 -0
  75. package/dist/lib/utils/errorHandling.js +316 -0
  76. package/dist/lib/utils/factoryProcessing.d.ts +74 -0
  77. package/dist/lib/utils/factoryProcessing.js +588 -0
  78. package/dist/lib/utils/optionsConversion.d.ts +54 -0
  79. package/dist/lib/utils/optionsConversion.js +126 -0
  80. package/dist/lib/utils/optionsUtils.d.ts +246 -0
  81. package/dist/lib/utils/optionsUtils.js +960 -0
  82. package/dist/lib/utils/providerHealth.d.ts +107 -0
  83. package/dist/lib/utils/providerHealth.js +507 -0
  84. package/dist/lib/utils/providerUtils.d.ts +17 -0
  85. package/dist/lib/utils/providerUtils.js +271 -16
  86. package/dist/lib/utils/timeout.js +1 -1
  87. package/dist/lib/utils/tokenLimits.d.ts +33 -0
  88. package/dist/lib/utils/tokenLimits.js +118 -0
  89. package/dist/mcp/factory.d.ts +5 -5
  90. package/dist/mcp/factory.js +2 -2
  91. package/dist/mcp/servers/utilities/utilityServer.d.ts +1 -1
  92. package/dist/mcp/servers/utilities/utilityServer.js +1 -1
  93. package/dist/mcp/toolRegistry.js +2 -2
  94. package/dist/neurolink.d.ts +168 -12
  95. package/dist/neurolink.js +685 -123
  96. package/dist/providers/anthropic.js +52 -2
  97. package/dist/providers/googleAiStudio.js +4 -0
  98. package/dist/providers/googleVertex.d.ts +75 -9
  99. package/dist/providers/googleVertex.js +365 -46
  100. package/dist/providers/huggingFace.d.ts +52 -11
  101. package/dist/providers/huggingFace.js +181 -43
  102. package/dist/providers/litellm.d.ts +9 -9
  103. package/dist/providers/litellm.js +103 -16
  104. package/dist/providers/ollama.d.ts +52 -17
  105. package/dist/providers/ollama.js +276 -68
  106. package/dist/sdk/toolRegistration.d.ts +42 -0
  107. package/dist/sdk/toolRegistration.js +269 -27
  108. package/dist/telemetry/telemetryService.d.ts +6 -0
  109. package/dist/telemetry/telemetryService.js +38 -3
  110. package/dist/types/contextTypes.d.ts +75 -11
  111. package/dist/types/contextTypes.js +227 -2
  112. package/dist/types/domainTypes.d.ts +62 -0
  113. package/dist/types/domainTypes.js +5 -0
  114. package/dist/types/generateTypes.d.ts +52 -0
  115. package/dist/types/index.d.ts +1 -0
  116. package/dist/types/mcpTypes.d.ts +1 -1
  117. package/dist/types/mcpTypes.js +1 -1
  118. package/dist/types/streamTypes.d.ts +14 -0
  119. package/dist/types/universalProviderOptions.d.ts +1 -1
  120. package/dist/types/universalProviderOptions.js +0 -1
  121. package/dist/utils/errorHandling.d.ts +142 -0
  122. package/dist/utils/errorHandling.js +316 -0
  123. package/dist/utils/factoryProcessing.d.ts +74 -0
  124. package/dist/utils/factoryProcessing.js +588 -0
  125. package/dist/utils/optionsConversion.d.ts +54 -0
  126. package/dist/utils/optionsConversion.js +126 -0
  127. package/dist/utils/optionsUtils.d.ts +246 -0
  128. package/dist/utils/optionsUtils.js +960 -0
  129. package/dist/utils/providerHealth.d.ts +107 -0
  130. package/dist/utils/providerHealth.js +507 -0
  131. package/dist/utils/providerUtils.d.ts +17 -0
  132. package/dist/utils/providerUtils.js +271 -16
  133. package/dist/utils/timeout.js +1 -1
  134. package/dist/utils/tokenLimits.d.ts +33 -0
  135. package/dist/utils/tokenLimits.js +118 -0
  136. package/package.json +2 -2
@@ -1,127 +1,49 @@
1
+ import { modelConfig } from "./modelConfiguration.js";
1
2
  /**
2
- * Comprehensive provider configurations for evaluation
3
- * All 9 NeuroLink providers with cost and performance data
3
+ * Convert new configuration format to legacy format for backwards compatibility
4
4
  */
5
- export const EVALUATION_PROVIDER_CONFIGS = {
6
- "google-ai": {
7
- provider: "google-ai",
8
- models: {
9
- fast: "gemini-2.5-flash",
10
- balanced: "gemini-2.5-pro",
11
- quality: "gemini-2.5-pro",
12
- },
13
- costPerToken: { input: 0.000075, output: 0.0003 },
14
- requiresApiKey: ["GOOGLE_AI_API_KEY", "GOOGLE_GENERATIVE_AI_API_KEY"],
15
- performance: { speed: 3, quality: 3, cost: 3 },
16
- },
17
- openai: {
18
- provider: "openai",
19
- models: {
20
- fast: "gpt-4o-mini",
21
- balanced: "gpt-4o",
22
- quality: "gpt-4o",
23
- },
24
- costPerToken: { input: 0.00015, output: 0.0006 },
25
- requiresApiKey: ["OPENAI_API_KEY"],
26
- performance: { speed: 2, quality: 3, cost: 2 },
27
- },
28
- anthropic: {
29
- provider: "anthropic",
30
- models: {
31
- fast: "claude-3-haiku-20240307",
32
- balanced: "claude-3-sonnet-20240229",
33
- quality: "claude-3-opus-20240229",
34
- },
35
- costPerToken: { input: 0.00025, output: 0.00125 },
36
- requiresApiKey: ["ANTHROPIC_API_KEY"],
37
- performance: { speed: 2, quality: 3, cost: 2 },
38
- },
39
- vertex: {
40
- provider: "vertex",
41
- models: {
42
- fast: "gemini-2.5-flash",
43
- balanced: "gemini-2.5-pro",
44
- quality: "gemini-2.5-pro",
45
- },
46
- costPerToken: { input: 0.000075, output: 0.0003 },
47
- requiresApiKey: [
48
- "GOOGLE_VERTEX_PROJECT",
49
- "GOOGLE_APPLICATION_CREDENTIALS",
50
- ],
51
- performance: { speed: 2, quality: 3, cost: 3 },
52
- },
53
- bedrock: {
54
- provider: "bedrock",
55
- models: {
56
- fast: "anthropic.claude-3-haiku-20240307-v1:0",
57
- balanced: "anthropic.claude-3-sonnet-20240229-v1:0",
58
- quality: "anthropic.claude-3-opus-20240229-v1:0",
59
- },
60
- costPerToken: { input: 0.00025, output: 0.00125 },
61
- requiresApiKey: ["AWS_ACCESS_KEY_ID", "AWS_SECRET_ACCESS_KEY"],
62
- performance: { speed: 2, quality: 3, cost: 2 },
63
- },
64
- azure: {
65
- provider: "azure",
66
- models: {
67
- fast: "gpt-4o-mini",
68
- balanced: "gpt-4o",
69
- quality: "gpt-4o",
70
- },
71
- costPerToken: { input: 0.00015, output: 0.0006 },
72
- requiresApiKey: ["AZURE_OPENAI_API_KEY", "AZURE_OPENAI_ENDPOINT"],
73
- performance: { speed: 2, quality: 3, cost: 2 },
74
- },
75
- ollama: {
76
- provider: "ollama",
77
- models: {
78
- fast: "llama3.2:latest",
79
- balanced: "llama3.1:8b",
80
- quality: "llama3.1:70b",
81
- },
82
- costPerToken: { input: 0, output: 0 }, // Local model
83
- requiresApiKey: [], // No API key needed
84
- performance: { speed: 1, quality: 2, cost: 3 },
85
- },
86
- huggingface: {
87
- provider: "huggingface",
88
- models: {
89
- fast: "microsoft/DialoGPT-medium",
90
- balanced: "microsoft/DialoGPT-large",
91
- quality: "meta-llama/Llama-2-7b-chat-hf",
92
- },
93
- costPerToken: { input: 0.0002, output: 0.0006 },
94
- requiresApiKey: ["HUGGINGFACE_API_KEY"],
95
- performance: { speed: 1, quality: 2, cost: 2 },
96
- },
97
- mistral: {
98
- provider: "mistral",
99
- models: {
100
- fast: "mistral-small-latest",
101
- balanced: "mistral-medium-latest",
102
- quality: "mistral-large-latest",
103
- },
104
- costPerToken: { input: 0.0002, output: 0.0006 },
105
- requiresApiKey: ["MISTRAL_API_KEY"],
106
- performance: { speed: 2, quality: 2, cost: 2 },
107
- },
108
- };
5
+ function convertToLegacyFormat(config) {
6
+ return {
7
+ provider: config.provider,
8
+ models: config.models,
9
+ costPerToken: config.defaultCost,
10
+ requiresApiKey: config.requiredEnvVars,
11
+ performance: config.performance,
12
+ };
13
+ }
14
+ /**
15
+ * Get all provider configurations using the new configuration system
16
+ * Replaces hardcoded EVALUATION_PROVIDER_CONFIGS with configurable system
17
+ */
18
+ function getEvaluationProviderConfigs() {
19
+ const configs = {};
20
+ const allConfigs = modelConfig.getAllConfigurations();
21
+ for (const [provider, config] of allConfigs) {
22
+ configs[provider] = convertToLegacyFormat(config);
23
+ }
24
+ return configs;
25
+ }
26
+ /**
27
+ * Dynamic provider configurations for evaluation
28
+ * Now uses configurable system instead of hardcoded values
29
+ */
30
+ export const EVALUATION_PROVIDER_CONFIGS = getEvaluationProviderConfigs();
109
31
  /**
110
32
  * Get provider configuration by name
33
+ * Now uses the configurable system
111
34
  */
112
35
  export function getProviderConfig(providerName) {
113
- return EVALUATION_PROVIDER_CONFIGS[providerName] || null;
36
+ const config = modelConfig.getProviderConfig(providerName);
37
+ return config ? convertToLegacyFormat(config) : null;
114
38
  }
115
39
  /**
116
40
  * Get all available providers with required API keys present
41
+ * Now uses the configurable system
117
42
  */
118
43
  export function getAvailableProviders() {
119
- return Object.values(EVALUATION_PROVIDER_CONFIGS).filter((config) => {
120
- if (config.requiresApiKey.length === 0) {
121
- return true;
122
- } // Ollama
123
- return config.requiresApiKey.some((key) => process.env[key]);
124
- });
44
+ return modelConfig
45
+ .getAvailableProviders()
46
+ .map((config) => convertToLegacyFormat(config));
125
47
  }
126
48
  /**
127
49
  * Sort providers by preference (cost, speed, quality)
@@ -152,27 +74,21 @@ export function sortProvidersByPreference(providers, preferCheap = true) {
152
74
  }
153
75
  /**
154
76
  * Estimate cost for a specific provider and token usage
77
+ * Now uses the configurable system
155
78
  */
156
79
  export function estimateProviderCost(providerName, inputTokens, outputTokens) {
157
- const config = getProviderConfig(providerName);
158
- if (!config || !config.costPerToken) {
80
+ const costInfo = modelConfig.getCostInfo(providerName);
81
+ if (!costInfo) {
159
82
  return 0;
160
83
  }
161
- return (inputTokens * config.costPerToken.input +
162
- outputTokens * config.costPerToken.output);
84
+ return inputTokens * costInfo.input + outputTokens * costInfo.output;
163
85
  }
164
86
  /**
165
87
  * Check if a provider is available (has required API keys)
88
+ * Now uses the configurable system
166
89
  */
167
90
  export function isProviderAvailable(providerName) {
168
- const config = getProviderConfig(providerName);
169
- if (!config) {
170
- return false;
171
- }
172
- if (config.requiresApiKey.length === 0) {
173
- return true;
174
- } // Ollama
175
- return config.requiresApiKey.some((key) => process.env[key]);
91
+ return modelConfig.isProviderAvailable(providerName);
176
92
  }
177
93
  /**
178
94
  * Get the best available provider based on preference
@@ -9,6 +9,11 @@ export declare class AIProviderFactory {
9
9
  * Normalize provider name using ProviderFactory
10
10
  */
11
11
  private static normalizeProviderName;
12
+ /**
13
+ * Initialize dynamic model provider with timeout protection
14
+ * Prevents hanging on non-responsive endpoints
15
+ */
16
+ private static initializeDynamicProviderWithTimeout;
12
17
  /**
13
18
  * Create a provider instance for the specified provider type
14
19
  * @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
@@ -22,6 +22,31 @@ export class AIProviderFactory {
22
22
  // If not found in factory, return as-is (will be handled by factory error handling)
23
23
  return providerName.toLowerCase();
24
24
  }
25
+ /**
26
+ * Initialize dynamic model provider with timeout protection
27
+ * Prevents hanging on non-responsive endpoints
28
+ */
29
+ static async initializeDynamicProviderWithTimeout() {
30
+ const functionTag = "AIProviderFactory.initializeDynamicProviderWithTimeout";
31
+ const INIT_TIMEOUT = 10000; // 10 seconds total timeout for initialization
32
+ try {
33
+ // Race the initialization against a timeout
34
+ await Promise.race([
35
+ dynamicModelProvider.initialize(),
36
+ new Promise((_, reject) => setTimeout(() => reject(new Error("Dynamic provider initialization timeout")), INIT_TIMEOUT)),
37
+ ]);
38
+ logger.debug(`[${functionTag}] Dynamic model provider initialized successfully`);
39
+ }
40
+ catch (error) {
41
+ const errorMessage = error instanceof Error ? error.message : String(error);
42
+ logger.warn(`[${functionTag}] Dynamic model provider initialization failed`, {
43
+ error: errorMessage,
44
+ fallback: "Using static model defaults",
45
+ });
46
+ // Don't throw - graceful degradation to static models
47
+ // This ensures the factory continues to work even if dynamic models fail
48
+ }
49
+ }
25
50
  /**
26
51
  * Create a provider instance for the specified provider type
27
52
  * @param providerName - Name of the provider ('vertex', 'bedrock', 'openai')
@@ -38,58 +63,45 @@ export class AIProviderFactory {
38
63
  enableMCP,
39
64
  });
40
65
  try {
41
- // DYNAMIC MODEL PROVIDER STATUS (2025): Disabled due to reliability issues
42
- //
43
- // Root Cause: Dynamic model provider initialization can hang when:
44
- // - Local model server (localhost:3001) is not running or responding
45
- // - GitHub raw URL requests timeout due to network issues
46
- // - Local config file doesn't exist
66
+ // DYNAMIC MODEL PROVIDER STATUS (2025): Enhanced with timeout handling
47
67
  //
48
- // Current Behavior: Static model resolution works reliably
49
- // Impact: No functionality loss - providers use built-in model defaults
68
+ // FIXED: Hanging issues resolved with comprehensive timeout implementation
69
+ // - Added robust timeout handling (3s localhost, 5s GitHub, 1s local file)
70
+ // - Implemented health checks for localhost endpoints
71
+ // - Added graceful degradation when all sources fail
72
+ // - Enhanced error handling and logging for debugging
50
73
  //
51
- // Implementation Requirements (if re-enabling):
52
- // 1. Add robust timeout handling (3s max per source)
53
- // 2. Implement exponential backoff for network requests
54
- // 3. Add graceful degradation when all sources fail
55
- // 4. Create health check for localhost:3001 before attempting connection
56
- // 5. Add comprehensive error handling and logging
57
- //
58
- // Until these improvements are implemented, dynamic model provider remains disabled
59
- // for system reliability. Static model defaults provide stable functionality.
60
- // COMPREHENSIVE FIX: Disable dynamic model resolution completely until provider is fixed
61
- // This prevents stale gemini-1.5-pro-latest from overriding correct gemini-2.5-pro defaults
62
- const resolvedModelName = modelName;
63
- // COMMENTED OUT: Dynamic model resolution causing 1.5 vs 2.5 Pro issues
64
- // if (!modelName || modelName === "default") {
65
- // try {
66
- // const normalizedProvider = this.normalizeProviderName(providerName);
67
- // const dynamicModel = dynamicModelProvider.resolveModel(
68
- // normalizedProvider,
69
- // modelName || undefined,
70
- // );
71
- // if (dynamicModel) {
72
- // resolvedModelName = dynamicModel.id;
73
- // logger.debug(`[${functionTag}] Resolved dynamic model`, {
74
- // provider: normalizedProvider,
75
- // requestedModel: modelName || "default",
76
- // resolvedModel: resolvedModelName,
77
- // displayName: dynamicModel.displayName,
78
- // pricing: dynamicModel.pricing.input,
79
- // });
80
- // }
81
- // } catch (resolveError) {
82
- // logger.debug(
83
- // `[${functionTag}] Dynamic model resolution failed, using fallback`,
84
- // {
85
- // error:
86
- // resolveError instanceof Error
87
- // ? resolveError.message
88
- // : String(resolveError),
89
- // },
90
- // );
91
- // }
92
- // }
74
+ // The dynamic model provider now provides reliable functionality without hanging
75
+ let resolvedModelName = modelName;
76
+ // Enable dynamic model resolution with timeout-protected initialization
77
+ if (!modelName || modelName === "default") {
78
+ try {
79
+ const normalizedProvider = this.normalizeProviderName(providerName);
80
+ // Initialize with timeout protection - won't hang anymore
81
+ if (dynamicModelProvider.needsRefresh()) {
82
+ await this.initializeDynamicProviderWithTimeout();
83
+ }
84
+ const dynamicModel = dynamicModelProvider.resolveModel(normalizedProvider, modelName || undefined);
85
+ if (dynamicModel) {
86
+ resolvedModelName = dynamicModel.id;
87
+ logger.debug(`[${functionTag}] Resolved dynamic model`, {
88
+ provider: normalizedProvider,
89
+ requestedModel: modelName || "default",
90
+ resolvedModel: resolvedModelName,
91
+ displayName: dynamicModel.displayName,
92
+ pricing: dynamicModel.pricing.input,
93
+ });
94
+ }
95
+ }
96
+ catch (resolveError) {
97
+ logger.debug(`[${functionTag}] Dynamic model resolution failed, using static fallback`, {
98
+ error: resolveError instanceof Error
99
+ ? resolveError.message
100
+ : String(resolveError),
101
+ });
102
+ // Continue with static model name - no functionality loss
103
+ }
104
+ }
93
105
  // CRITICAL FIX: Initialize providers before using them
94
106
  await ProviderRegistry.registerAllProviders();
95
107
  // PURE FACTORY PATTERN: No switch statements - use ProviderFactory exclusively
@@ -0,0 +1,246 @@
1
+ /**
2
+ * Model Configuration System
3
+ *
4
+ * Replaces hardcoded model-specific logic with configurable, runtime-updateable configurations.
5
+ * This addresses GitHub Copilot review comment about making model-specific logic configuration-based.
6
+ */
7
+ import type { JsonValue } from "../types/common.js";
8
+ /**
9
+ * Model name constants - extracted from hardcoded values for better maintainability
10
+ * These constants can be overridden by environment variables
11
+ */
12
+ export declare const MODEL_NAMES: {
13
+ readonly GOOGLE_AI: {
14
+ readonly FAST: "gemini-2.5-flash";
15
+ readonly BALANCED: "gemini-2.5-pro";
16
+ readonly QUALITY: "gemini-2.5-pro";
17
+ };
18
+ readonly GOOGLE_VERTEX: {
19
+ readonly FAST: "gemini-2.5-flash";
20
+ readonly BALANCED: "gemini-2.5-pro";
21
+ readonly QUALITY: "gemini-2.5-pro";
22
+ };
23
+ readonly OPENAI: {
24
+ readonly FAST: "gpt-4o-mini";
25
+ readonly BALANCED: "gpt-4o";
26
+ readonly QUALITY: "gpt-4o";
27
+ };
28
+ readonly ANTHROPIC: {
29
+ readonly FAST: "claude-3-haiku-20240307";
30
+ readonly BALANCED: "claude-3-sonnet-20240229";
31
+ readonly QUALITY: "claude-3-5-sonnet-20241022";
32
+ };
33
+ readonly VERTEX: {
34
+ readonly FAST: "gemini-2.5-flash";
35
+ readonly BALANCED: "gemini-2.5-pro";
36
+ readonly QUALITY: "gemini-2.5-pro";
37
+ };
38
+ readonly BEDROCK: {
39
+ readonly FAST: "anthropic.claude-3-haiku-20240307-v1:0";
40
+ readonly BALANCED: "anthropic.claude-3-sonnet-20240229-v1:0";
41
+ readonly QUALITY: "anthropic.claude-3-opus-20240229-v1:0";
42
+ };
43
+ readonly AZURE: {
44
+ readonly FAST: "gpt-4o-mini";
45
+ readonly BALANCED: "gpt-4o";
46
+ readonly QUALITY: "gpt-4o";
47
+ };
48
+ readonly OLLAMA: {
49
+ readonly FAST: "llama3.2:latest";
50
+ readonly BALANCED: "llama3.1:8b";
51
+ readonly QUALITY: "llama3.1:70b";
52
+ };
53
+ readonly HUGGINGFACE: {
54
+ readonly FAST: "microsoft/DialoGPT-medium";
55
+ readonly BALANCED: "microsoft/DialoGPT-large";
56
+ readonly QUALITY: "meta-llama/Llama-2-7b-chat-hf";
57
+ };
58
+ readonly MISTRAL: {
59
+ readonly FAST: "mistral-small-latest";
60
+ readonly BALANCED: "mistral-medium-latest";
61
+ readonly QUALITY: "mistral-large-latest";
62
+ };
63
+ };
64
+ /**
65
+ * Model performance tier definition
66
+ */
67
+ export type ModelTier = "fast" | "balanced" | "quality";
68
+ /**
69
+ * Model configuration for a specific provider
70
+ */
71
+ export interface ModelConfig {
72
+ /** Model identifier */
73
+ id: string;
74
+ /** Display name */
75
+ name: string;
76
+ /** Performance tier */
77
+ tier: ModelTier;
78
+ /** Cost per 1K tokens */
79
+ cost: {
80
+ input: number;
81
+ output: number;
82
+ };
83
+ /** Model capabilities */
84
+ capabilities: string[];
85
+ /** Model-specific options */
86
+ options?: Record<string, JsonValue>;
87
+ }
88
+ /**
89
+ * Provider configuration with models
90
+ */
91
+ export interface ProviderConfig {
92
+ /** Provider name */
93
+ provider: string;
94
+ /** Available models by tier */
95
+ models: Record<ModelTier, string>;
96
+ /** Default cost per token (fallback) */
97
+ defaultCost: {
98
+ input: number;
99
+ output: number;
100
+ };
101
+ /** Required environment variables */
102
+ requiredEnvVars: string[];
103
+ /** Provider-specific performance metrics */
104
+ performance: {
105
+ speed: number;
106
+ quality: number;
107
+ cost: number;
108
+ };
109
+ /** Provider-specific model configurations */
110
+ modelConfigs?: Record<string, ModelConfig>;
111
+ /** Provider-specific model behavior configurations */
112
+ modelBehavior?: {
113
+ /** Models that have issues with maxTokens parameter */
114
+ maxTokensIssues?: string[];
115
+ /** Models that require special handling */
116
+ specialHandling?: Record<string, JsonValue>;
117
+ /** Models that support tool calling (Ollama-specific) */
118
+ toolCapableModels?: string[];
119
+ };
120
+ }
121
+ /**
122
+ * Configuration source type
123
+ */
124
+ export type ConfigSource = "default" | "environment" | "file" | "dynamic";
125
+ /**
126
+ * Model configuration manager
127
+ */
128
+ export declare class ModelConfigurationManager {
129
+ private static instance;
130
+ private configurations;
131
+ private configSource;
132
+ private lastUpdated;
133
+ private constructor();
134
+ static getInstance(): ModelConfigurationManager;
135
+ /**
136
+ * Load default configurations (replaces hardcoded values)
137
+ */
138
+ private loadDefaultConfigurations;
139
+ /**
140
+ * Helper method to get configuration value with fallback and validation
141
+ */
142
+ private getConfigValue;
143
+ /**
144
+ * Validate configuration values for security and correctness
145
+ */
146
+ private isValidConfigValue;
147
+ /**
148
+ * Helper method to get configuration array with fallback
149
+ * Parses comma-separated environment variable values
150
+ */
151
+ private getConfigArray;
152
+ /**
153
+ * Helper method to parse float with fallback
154
+ */
155
+ private parseFloat;
156
+ /**
157
+ * Helper method to parse int with fallback
158
+ */
159
+ private parseInt;
160
+ /**
161
+ * Helper method to get configuration object with fallback
162
+ * Parses JSON environment variable values
163
+ */
164
+ private getConfigObject;
165
+ /**
166
+ * Get provider configuration
167
+ */
168
+ getProviderConfig(provider: string): ProviderConfig | null;
169
+ /**
170
+ * Get all provider configurations
171
+ */
172
+ getAllConfigurations(): Map<string, ProviderConfig>;
173
+ /**
174
+ * Update provider configuration (runtime updates)
175
+ */
176
+ updateProviderConfig(provider: string, config: ProviderConfig): void;
177
+ /**
178
+ * Load configurations from external source
179
+ */
180
+ loadConfigurationsFromFile(configPath: string): void;
181
+ /**
182
+ * Validate provider configuration structure
183
+ */
184
+ private isValidProviderConfig;
185
+ /**
186
+ * Apply model name overrides from configuration file
187
+ */
188
+ private applyModelNameOverrides;
189
+ /**
190
+ * Apply global default configurations
191
+ */
192
+ private applyGlobalDefaults;
193
+ /**
194
+ * Get configuration metadata
195
+ */
196
+ getConfigurationMeta(): {
197
+ source: ConfigSource;
198
+ lastUpdated: number;
199
+ providerCount: number;
200
+ };
201
+ /**
202
+ * Get model for specific tier and provider
203
+ */
204
+ getModelForTier(provider: string, tier: ModelTier): string | null;
205
+ /**
206
+ * Get cost information for provider and model
207
+ */
208
+ getCostInfo(provider: string, model?: string): {
209
+ input: number;
210
+ output: number;
211
+ } | null;
212
+ /**
213
+ * Check if provider is available (has required environment variables)
214
+ */
215
+ isProviderAvailable(provider: string): boolean;
216
+ /**
217
+ * Get available providers
218
+ */
219
+ getAvailableProviders(): ProviderConfig[];
220
+ }
221
+ /**
222
+ * Global instance accessor
223
+ */
224
+ export declare const modelConfig: ModelConfigurationManager;
225
+ /**
226
+ * Convenience functions for common operations
227
+ */
228
+ /**
229
+ * Get provider configuration (backwards compatible)
230
+ */
231
+ export declare function getProviderConfig(provider: string): ProviderConfig | null;
232
+ /**
233
+ * Get model for tier (backwards compatible)
234
+ */
235
+ export declare function getModelForTier(provider: string, tier: ModelTier): string | null;
236
+ /**
237
+ * Get cost information (backwards compatible)
238
+ */
239
+ export declare function getCostInfo(provider: string, model?: string): {
240
+ input: number;
241
+ output: number;
242
+ } | null;
243
+ /**
244
+ * Check provider availability (backwards compatible)
245
+ */
246
+ export declare function isProviderAvailable(provider: string): boolean;