@juspay/neurolink 7.33.1 → 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 +8 -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/mcp/externalServerManager.d.ts +18 -3
- package/dist/lib/mcp/externalServerManager.js +125 -3
- package/dist/lib/models/modelRegistry.d.ts +1 -1
- package/dist/lib/models/modelRegistry.js +63 -37
- package/dist/lib/neurolink.d.ts +1 -1
- package/dist/lib/neurolink.js +38 -36
- 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/mcp/externalServerManager.d.ts +18 -3
- package/dist/mcp/externalServerManager.js +125 -3
- package/dist/models/modelRegistry.d.ts +1 -1
- package/dist/models/modelRegistry.js +63 -37
- package/dist/neurolink.d.ts +1 -1
- package/dist/neurolink.js +38 -36
- 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
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import type { Tool, Schema } from "ai";
|
|
2
|
+
import type { ZodUnknownSchema, ValidationSchema } from "../types/typeAliases.js";
|
|
3
|
+
import type { GenerateResult } from "../types/generateTypes.js";
|
|
4
|
+
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
+
import type { JsonValue } from "../types/common.js";
|
|
6
|
+
import type { ChatMessage, ConversationMemoryConfig } from "../types/conversationTypes.js";
|
|
7
|
+
import type { TokenUsage, AnalyticsData } from "../types/analytics.js";
|
|
8
|
+
import type { EvaluationData } from "../index.js";
|
|
9
|
+
export type { EvaluationData };
|
|
10
|
+
import type { MiddlewareFactoryOptions } from "../types/middlewareTypes.js";
|
|
11
|
+
export interface TextGenerationResult {
|
|
12
|
+
content: string;
|
|
13
|
+
provider?: string;
|
|
14
|
+
model?: string;
|
|
15
|
+
usage?: TokenUsage;
|
|
16
|
+
responseTime?: number;
|
|
17
|
+
toolsUsed?: string[];
|
|
18
|
+
toolExecutions?: Array<{
|
|
19
|
+
toolName: string;
|
|
20
|
+
executionTime: number;
|
|
21
|
+
success: boolean;
|
|
22
|
+
serverId?: string;
|
|
23
|
+
}>;
|
|
24
|
+
enhancedWithTools?: boolean;
|
|
25
|
+
availableTools?: Array<{
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
server: string;
|
|
29
|
+
category?: string;
|
|
30
|
+
}>;
|
|
31
|
+
analytics?: AnalyticsData;
|
|
32
|
+
evaluation?: EvaluationData;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Supported AI Provider Names
|
|
36
|
+
*/
|
|
37
|
+
export declare enum AIProviderName {
|
|
38
|
+
BEDROCK = "bedrock",
|
|
39
|
+
OPENAI = "openai",
|
|
40
|
+
OPENAI_COMPATIBLE = "openai-compatible",
|
|
41
|
+
VERTEX = "vertex",
|
|
42
|
+
ANTHROPIC = "anthropic",
|
|
43
|
+
AZURE = "azure",
|
|
44
|
+
GOOGLE_AI = "google-ai",
|
|
45
|
+
HUGGINGFACE = "huggingface",
|
|
46
|
+
OLLAMA = "ollama",
|
|
47
|
+
MISTRAL = "mistral",
|
|
48
|
+
LITELLM = "litellm",
|
|
49
|
+
SAGEMAKER = "sagemaker",
|
|
50
|
+
AUTO = "auto"
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Supported Models for Amazon Bedrock
|
|
54
|
+
*/
|
|
55
|
+
export declare enum BedrockModels {
|
|
56
|
+
CLAUDE_3_SONNET = "anthropic.claude-3-sonnet-20240229-v1:0",
|
|
57
|
+
CLAUDE_3_HAIKU = "anthropic.claude-3-haiku-20240307-v1:0",
|
|
58
|
+
CLAUDE_3_5_SONNET = "anthropic.claude-3-5-sonnet-20240620-v1:0",
|
|
59
|
+
CLAUDE_3_7_SONNET = "arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0"
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Supported Models for OpenAI
|
|
63
|
+
*/
|
|
64
|
+
export declare enum OpenAIModels {
|
|
65
|
+
GPT_4 = "gpt-4",
|
|
66
|
+
GPT_4_TURBO = "gpt-4-turbo",
|
|
67
|
+
GPT_4O = "gpt-4o",
|
|
68
|
+
GPT_4O_MINI = "gpt-4o-mini",
|
|
69
|
+
GPT_3_5_TURBO = "gpt-3.5-turbo",
|
|
70
|
+
O1_PREVIEW = "o1-preview",
|
|
71
|
+
O1_MINI = "o1-mini"
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Supported Models for Google Vertex AI
|
|
75
|
+
*/
|
|
76
|
+
export declare enum VertexModels {
|
|
77
|
+
CLAUDE_4_0_SONNET = "claude-sonnet-4@20250514",
|
|
78
|
+
CLAUDE_4_0_OPUS = "claude-opus-4@20250514",
|
|
79
|
+
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
|
80
|
+
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
|
81
|
+
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
|
82
|
+
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
|
83
|
+
CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
|
|
84
|
+
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
|
85
|
+
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
|
86
|
+
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
|
87
|
+
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
|
88
|
+
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
|
89
|
+
GEMINI_1_5_FLASH = "gemini-1.5-flash"
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Supported Models for Google AI Studio
|
|
93
|
+
*/
|
|
94
|
+
export declare enum GoogleAIModels {
|
|
95
|
+
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
|
96
|
+
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
|
97
|
+
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
|
98
|
+
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
|
99
|
+
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
|
100
|
+
GEMINI_1_5_FLASH = "gemini-1.5-flash",
|
|
101
|
+
GEMINI_1_5_FLASH_LITE = "gemini-1.5-flash-lite"
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Supported Models for Anthropic (Direct API)
|
|
105
|
+
*/
|
|
106
|
+
export declare enum AnthropicModels {
|
|
107
|
+
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
|
108
|
+
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
|
109
|
+
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
|
110
|
+
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
|
111
|
+
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* API Versions for various providers
|
|
115
|
+
*/
|
|
116
|
+
export declare enum APIVersions {
|
|
117
|
+
AZURE_LATEST = "2025-04-01-preview",
|
|
118
|
+
AZURE_STABLE = "2024-10-21",
|
|
119
|
+
AZURE_LEGACY = "2023-12-01-preview",
|
|
120
|
+
OPENAI_CURRENT = "v1",
|
|
121
|
+
OPENAI_BETA = "v1-beta",
|
|
122
|
+
GOOGLE_AI_CURRENT = "v1",
|
|
123
|
+
GOOGLE_AI_BETA = "v1beta",
|
|
124
|
+
ANTHROPIC_CURRENT = "2023-06-01"
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Default model aliases for easy reference
|
|
128
|
+
*/
|
|
129
|
+
export declare const DEFAULT_MODEL_ALIASES: {
|
|
130
|
+
readonly LATEST_OPENAI: OpenAIModels.GPT_4O;
|
|
131
|
+
readonly FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI;
|
|
132
|
+
readonly LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
133
|
+
readonly FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU;
|
|
134
|
+
readonly LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO;
|
|
135
|
+
readonly FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH;
|
|
136
|
+
readonly BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
137
|
+
readonly BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO;
|
|
138
|
+
readonly BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
139
|
+
readonly BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH;
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* @deprecated Use DEFAULT_MODEL_ALIASES instead. Will be removed in future version.
|
|
143
|
+
*/
|
|
144
|
+
export declare const ModelAliases: {
|
|
145
|
+
readonly LATEST_OPENAI: OpenAIModels.GPT_4O;
|
|
146
|
+
readonly FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI;
|
|
147
|
+
readonly LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
148
|
+
readonly FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU;
|
|
149
|
+
readonly LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO;
|
|
150
|
+
readonly FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH;
|
|
151
|
+
readonly BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
152
|
+
readonly BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO;
|
|
153
|
+
readonly BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET;
|
|
154
|
+
readonly BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Union type of all supported model names
|
|
158
|
+
*/
|
|
159
|
+
export type SupportedModelName = BedrockModels | OpenAIModels | VertexModels | GoogleAIModels | AnthropicModels;
|
|
160
|
+
/**
|
|
161
|
+
* Provider configuration specifying provider and its available models
|
|
162
|
+
*/
|
|
163
|
+
export interface ProviderConfig {
|
|
164
|
+
provider: AIProviderName;
|
|
165
|
+
models: SupportedModelName[];
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Options for AI requests with unified provider configuration
|
|
169
|
+
*/
|
|
170
|
+
export interface StreamingOptions {
|
|
171
|
+
providers: ProviderConfig[];
|
|
172
|
+
temperature?: number;
|
|
173
|
+
maxTokens?: number;
|
|
174
|
+
systemPrompt?: string;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Text generation options interface
|
|
178
|
+
*/
|
|
179
|
+
export interface TextGenerationOptions {
|
|
180
|
+
prompt?: string;
|
|
181
|
+
input?: {
|
|
182
|
+
text: string;
|
|
183
|
+
};
|
|
184
|
+
provider?: AIProviderName;
|
|
185
|
+
model?: string;
|
|
186
|
+
temperature?: number;
|
|
187
|
+
maxTokens?: number;
|
|
188
|
+
systemPrompt?: string;
|
|
189
|
+
schema?: ZodUnknownSchema | Schema<unknown>;
|
|
190
|
+
tools?: Record<string, Tool>;
|
|
191
|
+
timeout?: number | string;
|
|
192
|
+
disableTools?: boolean;
|
|
193
|
+
maxSteps?: number;
|
|
194
|
+
enableEvaluation?: boolean;
|
|
195
|
+
enableAnalytics?: boolean;
|
|
196
|
+
context?: Record<string, JsonValue>;
|
|
197
|
+
evaluationDomain?: string;
|
|
198
|
+
toolUsageContext?: string;
|
|
199
|
+
conversationHistory?: Array<{
|
|
200
|
+
role: string;
|
|
201
|
+
content: string;
|
|
202
|
+
}>;
|
|
203
|
+
conversationMessages?: ChatMessage[];
|
|
204
|
+
conversationMemoryConfig?: Partial<ConversationMemoryConfig>;
|
|
205
|
+
originalPrompt?: string;
|
|
206
|
+
middleware?: MiddlewareFactoryOptions;
|
|
207
|
+
expectedOutcome?: string;
|
|
208
|
+
evaluationCriteria?: string[];
|
|
209
|
+
}
|
|
210
|
+
export type { AnalyticsData } from "../types/analytics.js";
|
|
211
|
+
/**
|
|
212
|
+
* Enhanced result interfaces with optional analytics/evaluation
|
|
213
|
+
*/
|
|
214
|
+
export interface EnhancedGenerateResult extends GenerateResult {
|
|
215
|
+
analytics?: AnalyticsData;
|
|
216
|
+
evaluation?: EvaluationData;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Phase 2: Enhanced Streaming Infrastructure
|
|
220
|
+
* Progress tracking and metadata for streaming operations
|
|
221
|
+
*/
|
|
222
|
+
export interface StreamingProgressData {
|
|
223
|
+
chunkCount: number;
|
|
224
|
+
totalBytes: number;
|
|
225
|
+
chunkSize: number;
|
|
226
|
+
elapsedTime: number;
|
|
227
|
+
estimatedRemaining?: number;
|
|
228
|
+
streamId?: string;
|
|
229
|
+
phase: "initializing" | "streaming" | "processing" | "complete" | "error";
|
|
230
|
+
}
|
|
231
|
+
export interface StreamingMetadata {
|
|
232
|
+
startTime: number;
|
|
233
|
+
endTime?: number;
|
|
234
|
+
totalDuration?: number;
|
|
235
|
+
averageChunkSize: number;
|
|
236
|
+
maxChunkSize: number;
|
|
237
|
+
minChunkSize: number;
|
|
238
|
+
throughputBytesPerSecond?: number;
|
|
239
|
+
streamingProvider: string;
|
|
240
|
+
modelUsed: string;
|
|
241
|
+
}
|
|
242
|
+
export type ProgressCallback = (progress: StreamingProgressData) => void;
|
|
243
|
+
/**
|
|
244
|
+
* AI Provider interface with flexible parameter support
|
|
245
|
+
*/
|
|
246
|
+
export interface AIProvider {
|
|
247
|
+
stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
248
|
+
generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
|
249
|
+
gen(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
|
250
|
+
setupToolExecutor(sdk: {
|
|
251
|
+
customTools: Map<string, unknown>;
|
|
252
|
+
executeTool: (toolName: string, params: unknown) => Promise<unknown>;
|
|
253
|
+
}, functionTag: string): void;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Provider attempt result for iteration tracking
|
|
257
|
+
*/
|
|
258
|
+
export interface ProviderAttempt {
|
|
259
|
+
provider: AIProviderName;
|
|
260
|
+
model: SupportedModelName;
|
|
261
|
+
success: boolean;
|
|
262
|
+
error?: string;
|
|
263
|
+
stack?: string;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Default provider configurations
|
|
267
|
+
*/
|
|
268
|
+
export declare const DEFAULT_PROVIDER_CONFIGS: ProviderConfig[];
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supported AI Provider Names
|
|
3
|
+
*/
|
|
4
|
+
export var AIProviderName;
|
|
5
|
+
(function (AIProviderName) {
|
|
6
|
+
AIProviderName["BEDROCK"] = "bedrock";
|
|
7
|
+
AIProviderName["OPENAI"] = "openai";
|
|
8
|
+
AIProviderName["OPENAI_COMPATIBLE"] = "openai-compatible";
|
|
9
|
+
AIProviderName["VERTEX"] = "vertex";
|
|
10
|
+
AIProviderName["ANTHROPIC"] = "anthropic";
|
|
11
|
+
AIProviderName["AZURE"] = "azure";
|
|
12
|
+
AIProviderName["GOOGLE_AI"] = "google-ai";
|
|
13
|
+
AIProviderName["HUGGINGFACE"] = "huggingface";
|
|
14
|
+
AIProviderName["OLLAMA"] = "ollama";
|
|
15
|
+
AIProviderName["MISTRAL"] = "mistral";
|
|
16
|
+
AIProviderName["LITELLM"] = "litellm";
|
|
17
|
+
AIProviderName["SAGEMAKER"] = "sagemaker";
|
|
18
|
+
AIProviderName["AUTO"] = "auto";
|
|
19
|
+
})(AIProviderName || (AIProviderName = {}));
|
|
20
|
+
/**
|
|
21
|
+
* Supported Models for Amazon Bedrock
|
|
22
|
+
*/
|
|
23
|
+
export var BedrockModels;
|
|
24
|
+
(function (BedrockModels) {
|
|
25
|
+
BedrockModels["CLAUDE_3_SONNET"] = "anthropic.claude-3-sonnet-20240229-v1:0";
|
|
26
|
+
BedrockModels["CLAUDE_3_HAIKU"] = "anthropic.claude-3-haiku-20240307-v1:0";
|
|
27
|
+
BedrockModels["CLAUDE_3_5_SONNET"] = "anthropic.claude-3-5-sonnet-20240620-v1:0";
|
|
28
|
+
BedrockModels["CLAUDE_3_7_SONNET"] = "arn:aws:bedrock:us-east-2:225681119357:inference-profile/us.anthropic.claude-3-7-sonnet-20250219-v1:0";
|
|
29
|
+
})(BedrockModels || (BedrockModels = {}));
|
|
30
|
+
/**
|
|
31
|
+
* Supported Models for OpenAI
|
|
32
|
+
*/
|
|
33
|
+
export var OpenAIModels;
|
|
34
|
+
(function (OpenAIModels) {
|
|
35
|
+
OpenAIModels["GPT_4"] = "gpt-4";
|
|
36
|
+
OpenAIModels["GPT_4_TURBO"] = "gpt-4-turbo";
|
|
37
|
+
OpenAIModels["GPT_4O"] = "gpt-4o";
|
|
38
|
+
OpenAIModels["GPT_4O_MINI"] = "gpt-4o-mini";
|
|
39
|
+
OpenAIModels["GPT_3_5_TURBO"] = "gpt-3.5-turbo";
|
|
40
|
+
OpenAIModels["O1_PREVIEW"] = "o1-preview";
|
|
41
|
+
OpenAIModels["O1_MINI"] = "o1-mini";
|
|
42
|
+
})(OpenAIModels || (OpenAIModels = {}));
|
|
43
|
+
/**
|
|
44
|
+
* Supported Models for Google Vertex AI
|
|
45
|
+
*/
|
|
46
|
+
export var VertexModels;
|
|
47
|
+
(function (VertexModels) {
|
|
48
|
+
// Claude 4 Series (Latest - May 2025)
|
|
49
|
+
VertexModels["CLAUDE_4_0_SONNET"] = "claude-sonnet-4@20250514";
|
|
50
|
+
VertexModels["CLAUDE_4_0_OPUS"] = "claude-opus-4@20250514";
|
|
51
|
+
// Claude 3.5 Series (Still supported)
|
|
52
|
+
VertexModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
|
53
|
+
VertexModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
|
54
|
+
// Claude 3 Series (Legacy support)
|
|
55
|
+
VertexModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
|
56
|
+
VertexModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
|
57
|
+
VertexModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
|
58
|
+
// Gemini 2.5 Series (Latest - 2025)
|
|
59
|
+
VertexModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
|
60
|
+
VertexModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
|
61
|
+
VertexModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
62
|
+
// Gemini 2.0 Series
|
|
63
|
+
VertexModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
|
64
|
+
// Gemini 1.5 Series (Legacy support)
|
|
65
|
+
VertexModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
|
66
|
+
VertexModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
|
67
|
+
})(VertexModels || (VertexModels = {}));
|
|
68
|
+
/**
|
|
69
|
+
* Supported Models for Google AI Studio
|
|
70
|
+
*/
|
|
71
|
+
export var GoogleAIModels;
|
|
72
|
+
(function (GoogleAIModels) {
|
|
73
|
+
// Gemini 2.5 Series (Latest - 2025)
|
|
74
|
+
GoogleAIModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
|
75
|
+
GoogleAIModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
|
76
|
+
GoogleAIModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
77
|
+
// Gemini 2.0 Series
|
|
78
|
+
GoogleAIModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
|
79
|
+
// Gemini 1.5 Series (Legacy support)
|
|
80
|
+
GoogleAIModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
|
81
|
+
GoogleAIModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
|
82
|
+
GoogleAIModels["GEMINI_1_5_FLASH_LITE"] = "gemini-1.5-flash-lite";
|
|
83
|
+
})(GoogleAIModels || (GoogleAIModels = {}));
|
|
84
|
+
/**
|
|
85
|
+
* Supported Models for Anthropic (Direct API)
|
|
86
|
+
*/
|
|
87
|
+
export var AnthropicModels;
|
|
88
|
+
(function (AnthropicModels) {
|
|
89
|
+
// Claude 3.5 Series (Latest)
|
|
90
|
+
AnthropicModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
|
91
|
+
AnthropicModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
|
92
|
+
// Claude 3 Series (Legacy support)
|
|
93
|
+
AnthropicModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
|
94
|
+
AnthropicModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
|
95
|
+
AnthropicModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
|
96
|
+
})(AnthropicModels || (AnthropicModels = {}));
|
|
97
|
+
/**
|
|
98
|
+
* API Versions for various providers
|
|
99
|
+
*/
|
|
100
|
+
export var APIVersions;
|
|
101
|
+
(function (APIVersions) {
|
|
102
|
+
// Azure OpenAI API versions
|
|
103
|
+
APIVersions["AZURE_LATEST"] = "2025-04-01-preview";
|
|
104
|
+
APIVersions["AZURE_STABLE"] = "2024-10-21";
|
|
105
|
+
APIVersions["AZURE_LEGACY"] = "2023-12-01-preview";
|
|
106
|
+
// OpenAI API versions
|
|
107
|
+
APIVersions["OPENAI_CURRENT"] = "v1";
|
|
108
|
+
APIVersions["OPENAI_BETA"] = "v1-beta";
|
|
109
|
+
// Google AI API versions
|
|
110
|
+
APIVersions["GOOGLE_AI_CURRENT"] = "v1";
|
|
111
|
+
APIVersions["GOOGLE_AI_BETA"] = "v1beta";
|
|
112
|
+
// Anthropic API versions
|
|
113
|
+
APIVersions["ANTHROPIC_CURRENT"] = "2023-06-01";
|
|
114
|
+
// Other provider versions can be added here
|
|
115
|
+
})(APIVersions || (APIVersions = {}));
|
|
116
|
+
/**
|
|
117
|
+
* Default model aliases for easy reference
|
|
118
|
+
*/
|
|
119
|
+
export const DEFAULT_MODEL_ALIASES = {
|
|
120
|
+
// Latest recommended models per provider
|
|
121
|
+
LATEST_OPENAI: OpenAIModels.GPT_4O,
|
|
122
|
+
FASTEST_OPENAI: OpenAIModels.GPT_4O_MINI,
|
|
123
|
+
LATEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_SONNET,
|
|
124
|
+
FASTEST_ANTHROPIC: AnthropicModels.CLAUDE_3_5_HAIKU,
|
|
125
|
+
LATEST_GOOGLE: GoogleAIModels.GEMINI_2_5_PRO,
|
|
126
|
+
FASTEST_GOOGLE: GoogleAIModels.GEMINI_2_5_FLASH,
|
|
127
|
+
// Best models by use case
|
|
128
|
+
BEST_CODING: AnthropicModels.CLAUDE_3_5_SONNET,
|
|
129
|
+
BEST_ANALYSIS: GoogleAIModels.GEMINI_2_5_PRO,
|
|
130
|
+
BEST_CREATIVE: AnthropicModels.CLAUDE_3_5_SONNET,
|
|
131
|
+
BEST_VALUE: GoogleAIModels.GEMINI_2_5_FLASH,
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* @deprecated Use DEFAULT_MODEL_ALIASES instead. Will be removed in future version.
|
|
135
|
+
*/
|
|
136
|
+
export const ModelAliases = DEFAULT_MODEL_ALIASES;
|
|
137
|
+
/**
|
|
138
|
+
* Default provider configurations
|
|
139
|
+
*/
|
|
140
|
+
export const DEFAULT_PROVIDER_CONFIGS = [
|
|
141
|
+
{
|
|
142
|
+
provider: AIProviderName.BEDROCK,
|
|
143
|
+
models: [BedrockModels.CLAUDE_3_7_SONNET, BedrockModels.CLAUDE_3_5_SONNET],
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
provider: AIProviderName.VERTEX,
|
|
147
|
+
models: [VertexModels.CLAUDE_4_0_SONNET, VertexModels.GEMINI_2_5_FLASH],
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
provider: AIProviderName.OPENAI,
|
|
151
|
+
models: [OpenAIModels.GPT_4O, OpenAIModels.GPT_4O_MINI],
|
|
152
|
+
},
|
|
153
|
+
];
|
|
@@ -22,12 +22,27 @@ export declare class ExternalServerManager extends EventEmitter {
|
|
|
22
22
|
enableMainRegistryIntegration?: boolean;
|
|
23
23
|
});
|
|
24
24
|
/**
|
|
25
|
-
* Load MCP server configurations from .mcp-config.json file
|
|
25
|
+
* Load MCP server configurations from .mcp-config.json file with parallel loading support
|
|
26
26
|
* Automatically registers servers found in the configuration
|
|
27
27
|
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
28
|
-
* @
|
|
28
|
+
* @param options Loading options including parallel support
|
|
29
|
+
* @returns Promise resolving to { serversLoaded, errors }
|
|
29
30
|
*/
|
|
30
|
-
loadMCPConfiguration(configPath?: string
|
|
31
|
+
loadMCPConfiguration(configPath?: string, options?: {
|
|
32
|
+
parallel?: boolean;
|
|
33
|
+
}): Promise<ServerLoadResult>;
|
|
34
|
+
/**
|
|
35
|
+
* Load MCP servers in parallel for improved performance
|
|
36
|
+
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
37
|
+
* @returns Promise resolving to batch operation result
|
|
38
|
+
*/
|
|
39
|
+
loadMCPConfigurationParallel(configPath?: string | null): Promise<ServerLoadResult>;
|
|
40
|
+
/**
|
|
41
|
+
* Load MCP servers sequentially (original implementation for backward compatibility)
|
|
42
|
+
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
43
|
+
* @returns Promise resolving to batch operation result
|
|
44
|
+
*/
|
|
45
|
+
loadMCPConfigurationSequential(configPath?: string): Promise<ServerLoadResult>;
|
|
31
46
|
/**
|
|
32
47
|
* Validate external MCP server configuration
|
|
33
48
|
*/
|
|
@@ -107,12 +107,134 @@ export class ExternalServerManager extends EventEmitter {
|
|
|
107
107
|
process.on("beforeExit", () => this.shutdown());
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
* Load MCP server configurations from .mcp-config.json file
|
|
110
|
+
* Load MCP server configurations from .mcp-config.json file with parallel loading support
|
|
111
111
|
* Automatically registers servers found in the configuration
|
|
112
112
|
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
113
|
-
* @
|
|
113
|
+
* @param options Loading options including parallel support
|
|
114
|
+
* @returns Promise resolving to { serversLoaded, errors }
|
|
114
115
|
*/
|
|
115
|
-
async loadMCPConfiguration(configPath) {
|
|
116
|
+
async loadMCPConfiguration(configPath, options = {}) {
|
|
117
|
+
if (options.parallel) {
|
|
118
|
+
return this.loadMCPConfigurationParallel(configPath);
|
|
119
|
+
}
|
|
120
|
+
return this.loadMCPConfigurationSequential(configPath);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Load MCP servers in parallel for improved performance
|
|
124
|
+
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
125
|
+
* @returns Promise resolving to batch operation result
|
|
126
|
+
*/
|
|
127
|
+
async loadMCPConfigurationParallel(configPath) {
|
|
128
|
+
const fs = await import("fs");
|
|
129
|
+
const path = await import("path");
|
|
130
|
+
const finalConfigPath = configPath || path.join(process.cwd(), ".mcp-config.json");
|
|
131
|
+
if (!fs.existsSync(finalConfigPath)) {
|
|
132
|
+
mcpLogger.debug(`[ExternalServerManager] No MCP config found at ${finalConfigPath}`);
|
|
133
|
+
return { serversLoaded: 0, errors: [] };
|
|
134
|
+
}
|
|
135
|
+
mcpLogger.debug(`[ExternalServerManager] Loading MCP configuration in PARALLEL mode from ${finalConfigPath}`);
|
|
136
|
+
try {
|
|
137
|
+
const configContent = fs.readFileSync(finalConfigPath, "utf8");
|
|
138
|
+
const config = JSON.parse(configContent);
|
|
139
|
+
if (!config.mcpServers || typeof config.mcpServers !== "object") {
|
|
140
|
+
mcpLogger.debug("[ExternalServerManager] No mcpServers found in configuration");
|
|
141
|
+
return { serversLoaded: 0, errors: [] };
|
|
142
|
+
}
|
|
143
|
+
// Create promises for all servers to start them concurrently
|
|
144
|
+
const serverPromises = Object.entries(config.mcpServers).map(async ([serverId, serverConfig]) => {
|
|
145
|
+
try {
|
|
146
|
+
// Validate and convert config format to MCPServerInfo
|
|
147
|
+
if (!isValidExternalMCPServerConfig(serverConfig)) {
|
|
148
|
+
throw new Error(`Invalid server config for ${serverId}: missing required properties or wrong types`);
|
|
149
|
+
}
|
|
150
|
+
const externalConfig = {
|
|
151
|
+
id: serverId,
|
|
152
|
+
name: serverId,
|
|
153
|
+
description: `External MCP server: ${serverId}`,
|
|
154
|
+
transport: typeof serverConfig.transport === "string"
|
|
155
|
+
? serverConfig.transport
|
|
156
|
+
: "stdio",
|
|
157
|
+
status: "initializing",
|
|
158
|
+
tools: [],
|
|
159
|
+
command: serverConfig.command,
|
|
160
|
+
args: Array.isArray(serverConfig.args)
|
|
161
|
+
? serverConfig.args
|
|
162
|
+
: [],
|
|
163
|
+
env: isNonNullObject(serverConfig.env)
|
|
164
|
+
? serverConfig.env
|
|
165
|
+
: {},
|
|
166
|
+
timeout: typeof serverConfig.timeout === "number"
|
|
167
|
+
? serverConfig.timeout
|
|
168
|
+
: undefined,
|
|
169
|
+
retries: typeof serverConfig.retries === "number"
|
|
170
|
+
? serverConfig.retries
|
|
171
|
+
: undefined,
|
|
172
|
+
healthCheckInterval: typeof serverConfig.healthCheckInterval === "number"
|
|
173
|
+
? serverConfig.healthCheckInterval
|
|
174
|
+
: undefined,
|
|
175
|
+
autoRestart: typeof serverConfig.autoRestart === "boolean"
|
|
176
|
+
? serverConfig.autoRestart
|
|
177
|
+
: undefined,
|
|
178
|
+
cwd: typeof serverConfig.cwd === "string"
|
|
179
|
+
? serverConfig.cwd
|
|
180
|
+
: undefined,
|
|
181
|
+
url: typeof serverConfig.url === "string"
|
|
182
|
+
? serverConfig.url
|
|
183
|
+
: undefined,
|
|
184
|
+
metadata: safeMetadataConversion(serverConfig.metadata),
|
|
185
|
+
};
|
|
186
|
+
const result = await this.addServer(serverId, externalConfig);
|
|
187
|
+
return { serverId, result };
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const errorMsg = `Failed to load MCP server ${serverId}: ${error instanceof Error ? error.message : String(error)}`;
|
|
191
|
+
mcpLogger.warn(`[ExternalServerManager] ${errorMsg}`);
|
|
192
|
+
return { serverId, error: errorMsg };
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
// Start all servers concurrently and wait for completion
|
|
196
|
+
const results = await Promise.allSettled(serverPromises);
|
|
197
|
+
// Process results to count successes and collect errors
|
|
198
|
+
let serversLoaded = 0;
|
|
199
|
+
const errors = [];
|
|
200
|
+
for (const result of results) {
|
|
201
|
+
if (result.status === "fulfilled") {
|
|
202
|
+
const { serverId, result: serverResult, error } = result.value;
|
|
203
|
+
if (serverResult && serverResult.success) {
|
|
204
|
+
serversLoaded++;
|
|
205
|
+
mcpLogger.debug(`[ExternalServerManager] Successfully loaded MCP server in parallel: ${serverId}`);
|
|
206
|
+
}
|
|
207
|
+
else if (error) {
|
|
208
|
+
errors.push(error);
|
|
209
|
+
}
|
|
210
|
+
else if (serverResult && !serverResult.success) {
|
|
211
|
+
const errorMsg = `Failed to load server ${serverId}: ${serverResult.error}`;
|
|
212
|
+
errors.push(errorMsg);
|
|
213
|
+
mcpLogger.warn(`[ExternalServerManager] ${errorMsg}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
// Promise.allSettled rejected - this shouldn't happen with our error handling
|
|
218
|
+
const errorMsg = `Unexpected error during parallel loading: ${result.reason}`;
|
|
219
|
+
errors.push(errorMsg);
|
|
220
|
+
mcpLogger.error(`[ExternalServerManager] ${errorMsg}`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
mcpLogger.info(`[ExternalServerManager] PARALLEL MCP configuration loading complete: ${serversLoaded} servers loaded, ${errors.length} errors`);
|
|
224
|
+
return { serversLoaded, errors };
|
|
225
|
+
}
|
|
226
|
+
catch (error) {
|
|
227
|
+
const errorMsg = `Failed to load MCP configuration in parallel mode: ${error instanceof Error ? error.message : String(error)}`;
|
|
228
|
+
mcpLogger.error(`[ExternalServerManager] ${errorMsg}`);
|
|
229
|
+
return { serversLoaded: 0, errors: [errorMsg] };
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Load MCP servers sequentially (original implementation for backward compatibility)
|
|
234
|
+
* @param configPath Optional path to config file (defaults to .mcp-config.json in cwd)
|
|
235
|
+
* @returns Promise resolving to batch operation result
|
|
236
|
+
*/
|
|
237
|
+
async loadMCPConfigurationSequential(configPath) {
|
|
116
238
|
const fs = await import("fs");
|
|
117
239
|
const path = await import("path");
|
|
118
240
|
const finalConfigPath = configPath || path.join(process.cwd(), ".mcp-config.json");
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides centralized model data for models command system
|
|
4
4
|
* Part of Phase 4.1 - Models Command System
|
|
5
5
|
*/
|
|
6
|
-
import { AIProviderName } from "../types
|
|
6
|
+
import { AIProviderName } from "../core/types.js";
|
|
7
7
|
import type { JsonValue } from "../types/common.js";
|
|
8
8
|
/**
|
|
9
9
|
* Model capabilities interface
|