@juspay/neurolink 7.33.0 → 7.33.2
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/agent/directTools.d.ts +6 -6
- package/dist/cli/commands/config.d.ts +68 -68
- package/dist/cli/utils/interactiveSetup.d.ts +1 -1
- package/dist/cli/utils/interactiveSetup.js +1 -1
- package/dist/core/analytics.d.ts +1 -2
- package/dist/core/baseProvider.d.ts +1 -1
- package/dist/core/baseProvider.js +1 -0
- package/dist/core/dynamicModels.d.ts +1 -132
- package/dist/core/dynamicModels.js +0 -7
- package/dist/core/evaluation.d.ts +1 -39
- package/dist/core/evaluationProviders.d.ts +1 -17
- package/dist/core/evaluationProviders.js +1 -1
- package/dist/core/factory.d.ts +1 -3
- package/dist/core/factory.js +0 -1
- package/dist/core/modelConfiguration.d.ts +8 -69
- package/dist/core/modelConfiguration.js +11 -11
- package/dist/core/serviceRegistry.d.ts +1 -8
- package/dist/core/streamAnalytics.d.ts +2 -45
- package/dist/factories/providerFactory.d.ts +1 -1
- package/dist/factories/providerRegistry.js +1 -1
- package/dist/index.d.ts +8 -9
- package/dist/index.js +1 -1
- package/dist/lib/core/analytics.d.ts +1 -2
- package/dist/lib/core/baseProvider.d.ts +1 -1
- package/dist/lib/core/baseProvider.js +1 -0
- package/dist/lib/core/dynamicModels.d.ts +1 -132
- package/dist/lib/core/dynamicModels.js +0 -7
- package/dist/lib/core/evaluation.d.ts +1 -39
- package/dist/lib/core/evaluationProviders.d.ts +1 -17
- package/dist/lib/core/evaluationProviders.js +1 -1
- package/dist/lib/core/factory.d.ts +1 -3
- package/dist/lib/core/factory.js +0 -1
- package/dist/lib/core/modelConfiguration.d.ts +8 -69
- package/dist/lib/core/modelConfiguration.js +11 -11
- package/dist/lib/core/serviceRegistry.d.ts +1 -8
- package/dist/lib/core/streamAnalytics.d.ts +2 -45
- package/dist/lib/factories/providerFactory.d.ts +1 -1
- package/dist/lib/factories/providerRegistry.js +1 -1
- package/dist/lib/index.d.ts +5 -6
- package/dist/lib/index.js +1 -1
- 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 +1 -1
- package/dist/lib/models/modelResolver.d.ts +1 -1
- package/dist/lib/neurolink.d.ts +2 -2
- package/dist/lib/neurolink.js +4 -3
- package/dist/lib/providers/amazonBedrock.d.ts +1 -2
- package/dist/lib/providers/amazonSagemaker.d.ts +1 -1
- package/dist/lib/providers/anthropic.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +1 -1
- package/dist/lib/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/lib/providers/anthropicBaseProvider.js +1 -1
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.d.ts +1 -1
- package/dist/lib/providers/googleAiStudio.js +1 -1
- package/dist/lib/providers/googleVertex.d.ts +1 -1
- package/dist/lib/providers/googleVertex.js +1 -1
- package/dist/lib/providers/huggingFace.d.ts +1 -1
- package/dist/lib/providers/index.d.ts +1 -1
- package/dist/lib/providers/litellm.d.ts +1 -1
- package/dist/lib/providers/mistral.d.ts +1 -1
- package/dist/lib/providers/ollama.d.ts +1 -1
- package/dist/lib/providers/ollama.js +1 -1
- package/dist/lib/providers/openAI.d.ts +1 -1
- package/dist/lib/providers/openAI.js +1 -1
- package/dist/lib/providers/openaiCompatible.d.ts +1 -1
- package/dist/lib/providers/sagemaker/language-model.d.ts +2 -2
- package/dist/lib/types/analytics.d.ts +53 -0
- package/dist/lib/types/analytics.js +5 -0
- package/dist/lib/types/cli.d.ts +1 -1
- package/dist/lib/types/evaluation.d.ts +119 -0
- package/dist/lib/types/evaluation.js +5 -0
- package/dist/lib/types/evaluationProviders.d.ts +104 -0
- package/dist/lib/types/evaluationProviders.js +5 -0
- package/dist/lib/types/generateTypes.d.ts +89 -18
- package/dist/lib/types/index.d.ts +10 -2
- package/dist/lib/types/index.js +12 -0
- package/dist/lib/types/modelTypes.d.ts +242 -0
- package/dist/lib/types/modelTypes.js +30 -0
- package/dist/lib/types/providers.d.ts +193 -127
- package/dist/lib/types/providers.js +110 -18
- package/dist/lib/types/serviceTypes.d.ts +79 -0
- package/dist/lib/types/serviceTypes.js +5 -0
- package/dist/lib/types/streamTypes.d.ts +101 -21
- package/dist/lib/utils/analyticsUtils.d.ts +5 -1
- package/dist/lib/utils/analyticsUtils.js +13 -0
- package/dist/lib/utils/conversationMemoryUtils.d.ts +1 -1
- package/dist/lib/utils/evaluationUtils.d.ts +1 -1
- package/dist/lib/utils/factoryProcessing.d.ts +1 -1
- package/dist/lib/utils/messageBuilder.d.ts +1 -1
- package/dist/lib/utils/providerHealth.d.ts +1 -1
- package/dist/lib/utils/providerHealth.js +1 -1
- package/dist/lib/utils/providerUtils.d.ts +5 -0
- package/dist/lib/utils/providerUtils.js +6 -0
- 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 +1 -1
- package/dist/models/modelResolver.d.ts +1 -1
- package/dist/neurolink.d.ts +2 -2
- package/dist/neurolink.js +4 -3
- package/dist/providers/amazonBedrock.d.ts +1 -2
- package/dist/providers/amazonSagemaker.d.ts +1 -1
- package/dist/providers/anthropic.d.ts +1 -1
- package/dist/providers/anthropic.js +1 -1
- package/dist/providers/anthropicBaseProvider.d.ts +1 -1
- package/dist/providers/anthropicBaseProvider.js +1 -1
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/googleAiStudio.d.ts +1 -1
- package/dist/providers/googleAiStudio.js +1 -1
- package/dist/providers/googleVertex.d.ts +1 -1
- package/dist/providers/googleVertex.js +1 -1
- package/dist/providers/huggingFace.d.ts +1 -1
- package/dist/providers/index.d.ts +1 -1
- package/dist/providers/litellm.d.ts +1 -1
- package/dist/providers/mistral.d.ts +1 -1
- package/dist/providers/ollama.d.ts +1 -1
- package/dist/providers/ollama.js +1 -1
- package/dist/providers/openAI.d.ts +1 -1
- package/dist/providers/openAI.js +1 -1
- package/dist/providers/openaiCompatible.d.ts +1 -1
- package/dist/types/analytics.d.ts +53 -0
- package/dist/types/analytics.js +5 -0
- package/dist/types/cli.d.ts +1 -1
- package/dist/types/evaluation.d.ts +119 -0
- package/dist/types/evaluation.js +5 -0
- package/dist/types/evaluationProviders.d.ts +104 -0
- package/dist/types/evaluationProviders.js +5 -0
- package/dist/types/generateTypes.d.ts +89 -18
- package/dist/types/index.d.ts +10 -2
- package/dist/types/index.js +12 -0
- package/dist/types/modelTypes.d.ts +242 -0
- package/dist/types/modelTypes.js +30 -0
- package/dist/types/providers.d.ts +193 -127
- package/dist/types/providers.js +110 -18
- package/dist/types/serviceTypes.d.ts +79 -0
- package/dist/types/serviceTypes.js +5 -0
- package/dist/types/streamTypes.d.ts +101 -21
- package/dist/utils/analyticsUtils.d.ts +5 -1
- package/dist/utils/analyticsUtils.js +13 -0
- package/dist/utils/conversationMemoryUtils.d.ts +1 -1
- package/dist/utils/evaluationUtils.d.ts +1 -1
- package/dist/utils/factoryProcessing.d.ts +1 -1
- package/dist/utils/messageBuilder.d.ts +1 -1
- package/dist/utils/providerHealth.d.ts +1 -1
- package/dist/utils/providerHealth.js +1 -1
- package/dist/utils/providerUtils.d.ts +5 -0
- package/dist/utils/providerUtils.js +6 -0
- package/package.json +1 -1
- package/dist/core/types.d.ts +0 -223
- package/dist/core/types.js +0 -111
- package/dist/lib/core/types.d.ts +0 -223
- package/dist/lib/core/types.js +0 -111
package/dist/lib/core/factory.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Replaces hardcoded model-specific logic with configurable, runtime-updateable configurations.
|
|
5
5
|
* This addresses GitHub Copilot review comment about making model-specific logic configuration-based.
|
|
6
6
|
*/
|
|
7
|
-
import type {
|
|
7
|
+
import type { ModelTier, ProviderConfiguration, ConfigSource } from "../types/modelTypes.js";
|
|
8
8
|
/**
|
|
9
9
|
* Model name constants - extracted from hardcoded values for better maintainability
|
|
10
10
|
* These constants can be overridden by environment variables
|
|
@@ -61,67 +61,6 @@ export declare const MODEL_NAMES: {
|
|
|
61
61
|
readonly QUALITY: "mistral-large-latest";
|
|
62
62
|
};
|
|
63
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
64
|
/**
|
|
126
65
|
* Model configuration manager
|
|
127
66
|
*/
|
|
@@ -147,7 +86,7 @@ export declare class ModelConfigurationManager {
|
|
|
147
86
|
/**
|
|
148
87
|
* Create all provider configurations - centralized approach
|
|
149
88
|
*/
|
|
150
|
-
private
|
|
89
|
+
private createAllProviderConfigurations;
|
|
151
90
|
/**
|
|
152
91
|
* Create Anthropic provider configuration
|
|
153
92
|
*/
|
|
@@ -209,15 +148,15 @@ export declare class ModelConfigurationManager {
|
|
|
209
148
|
/**
|
|
210
149
|
* Get provider configuration
|
|
211
150
|
*/
|
|
212
|
-
|
|
151
|
+
getProviderConfiguration(provider: string): ProviderConfiguration | null;
|
|
213
152
|
/**
|
|
214
153
|
* Get all provider configurations
|
|
215
154
|
*/
|
|
216
|
-
getAllConfigurations(): Map<string,
|
|
155
|
+
getAllConfigurations(): Map<string, ProviderConfiguration>;
|
|
217
156
|
/**
|
|
218
157
|
* Update provider configuration (runtime updates)
|
|
219
158
|
*/
|
|
220
|
-
|
|
159
|
+
updateProviderConfiguration(provider: string, config: ProviderConfiguration): void;
|
|
221
160
|
/**
|
|
222
161
|
* Parse YAML content with basic support
|
|
223
162
|
* For full YAML support, would need a proper YAML library
|
|
@@ -244,7 +183,7 @@ export declare class ModelConfigurationManager {
|
|
|
244
183
|
/**
|
|
245
184
|
* Validate provider configuration structure
|
|
246
185
|
*/
|
|
247
|
-
private
|
|
186
|
+
private isValidProviderConfiguration;
|
|
248
187
|
/**
|
|
249
188
|
* Apply model name overrides from configuration file
|
|
250
189
|
*/
|
|
@@ -279,7 +218,7 @@ export declare class ModelConfigurationManager {
|
|
|
279
218
|
/**
|
|
280
219
|
* Get available providers
|
|
281
220
|
*/
|
|
282
|
-
getAvailableProviders():
|
|
221
|
+
getAvailableProviders(): ProviderConfiguration[];
|
|
283
222
|
}
|
|
284
223
|
/**
|
|
285
224
|
* Global instance accessor
|
|
@@ -291,7 +230,7 @@ export declare const modelConfig: ModelConfigurationManager;
|
|
|
291
230
|
/**
|
|
292
231
|
* Get provider configuration (backwards compatible)
|
|
293
232
|
*/
|
|
294
|
-
export declare function
|
|
233
|
+
export declare function getProviderConfiguration(provider: string): ProviderConfiguration | null;
|
|
295
234
|
/**
|
|
296
235
|
* Get model for tier (backwards compatible)
|
|
297
236
|
*/
|
|
@@ -175,7 +175,7 @@ export class ModelConfigurationManager {
|
|
|
175
175
|
/**
|
|
176
176
|
* Create all provider configurations - centralized approach
|
|
177
177
|
*/
|
|
178
|
-
|
|
178
|
+
createAllProviderConfigurations() {
|
|
179
179
|
return {
|
|
180
180
|
"google-ai": this.createGoogleAIConfig(),
|
|
181
181
|
"google-vertex": this.createVertexConfig(),
|
|
@@ -383,7 +383,7 @@ export class ModelConfigurationManager {
|
|
|
383
383
|
*/
|
|
384
384
|
loadDefaultConfigurations() {
|
|
385
385
|
// Load all provider configurations using centralized method
|
|
386
|
-
const defaultConfigs = this.
|
|
386
|
+
const defaultConfigs = this.createAllProviderConfigurations();
|
|
387
387
|
// Load configurations
|
|
388
388
|
for (const [provider, config] of Object.entries(defaultConfigs)) {
|
|
389
389
|
this.configurations.set(provider, config);
|
|
@@ -484,7 +484,7 @@ export class ModelConfigurationManager {
|
|
|
484
484
|
/**
|
|
485
485
|
* Get provider configuration
|
|
486
486
|
*/
|
|
487
|
-
|
|
487
|
+
getProviderConfiguration(provider) {
|
|
488
488
|
return this.configurations.get(provider) || null;
|
|
489
489
|
}
|
|
490
490
|
/**
|
|
@@ -496,7 +496,7 @@ export class ModelConfigurationManager {
|
|
|
496
496
|
/**
|
|
497
497
|
* Update provider configuration (runtime updates)
|
|
498
498
|
*/
|
|
499
|
-
|
|
499
|
+
updateProviderConfiguration(provider, config) {
|
|
500
500
|
this.configurations.set(provider, config);
|
|
501
501
|
this.lastUpdated = Date.now();
|
|
502
502
|
this.configSource = "dynamic";
|
|
@@ -596,7 +596,7 @@ export class ModelConfigurationManager {
|
|
|
596
596
|
if (config.providers && typeof config.providers === "object") {
|
|
597
597
|
const providers = config.providers;
|
|
598
598
|
for (const [providerName, providerConfig] of Object.entries(providers)) {
|
|
599
|
-
if (this.
|
|
599
|
+
if (this.isValidProviderConfiguration(providerConfig)) {
|
|
600
600
|
this.configurations.set(providerName, providerConfig);
|
|
601
601
|
logger.debug(`Loaded configuration for provider: ${providerName}`);
|
|
602
602
|
}
|
|
@@ -629,7 +629,7 @@ export class ModelConfigurationManager {
|
|
|
629
629
|
/**
|
|
630
630
|
* Validate provider configuration structure
|
|
631
631
|
*/
|
|
632
|
-
|
|
632
|
+
isValidProviderConfiguration(config) {
|
|
633
633
|
if (!config || typeof config !== "object") {
|
|
634
634
|
return false;
|
|
635
635
|
}
|
|
@@ -769,14 +769,14 @@ export class ModelConfigurationManager {
|
|
|
769
769
|
* Get model for specific tier and provider
|
|
770
770
|
*/
|
|
771
771
|
getModelForTier(provider, tier) {
|
|
772
|
-
const config = this.
|
|
772
|
+
const config = this.getProviderConfiguration(provider);
|
|
773
773
|
return config?.models[tier] || null;
|
|
774
774
|
}
|
|
775
775
|
/**
|
|
776
776
|
* Get cost information for provider and model
|
|
777
777
|
*/
|
|
778
778
|
getCostInfo(provider, model) {
|
|
779
|
-
const config = this.
|
|
779
|
+
const config = this.getProviderConfiguration(provider);
|
|
780
780
|
if (!config) {
|
|
781
781
|
return null;
|
|
782
782
|
}
|
|
@@ -790,7 +790,7 @@ export class ModelConfigurationManager {
|
|
|
790
790
|
* Check if provider is available (has required environment variables)
|
|
791
791
|
*/
|
|
792
792
|
isProviderAvailable(provider) {
|
|
793
|
-
const config = this.
|
|
793
|
+
const config = this.getProviderConfiguration(provider);
|
|
794
794
|
if (!config) {
|
|
795
795
|
return false;
|
|
796
796
|
}
|
|
@@ -816,8 +816,8 @@ export const modelConfig = ModelConfigurationManager.getInstance();
|
|
|
816
816
|
/**
|
|
817
817
|
* Get provider configuration (backwards compatible)
|
|
818
818
|
*/
|
|
819
|
-
export function
|
|
820
|
-
return modelConfig.
|
|
819
|
+
export function getProviderConfiguration(provider) {
|
|
820
|
+
return modelConfig.getProviderConfiguration(provider);
|
|
821
821
|
}
|
|
822
822
|
/**
|
|
823
823
|
* Get model for tier (backwards compatible)
|
|
@@ -2,14 +2,7 @@
|
|
|
2
2
|
* Service Registry for Dependency Injection
|
|
3
3
|
* Breaks circular dependencies by providing lazy loading and centralized service management
|
|
4
4
|
*/
|
|
5
|
-
|
|
6
|
-
(): T | Promise<T>;
|
|
7
|
-
}
|
|
8
|
-
export interface ServiceRegistration<T = unknown> {
|
|
9
|
-
factory: ServiceFactory<T>;
|
|
10
|
-
singleton: boolean;
|
|
11
|
-
instance?: T;
|
|
12
|
-
}
|
|
5
|
+
import type { ServiceFactory } from "../types/serviceTypes.js";
|
|
13
6
|
export declare class ServiceRegistry {
|
|
14
7
|
private static services;
|
|
15
8
|
private static initializing;
|
|
@@ -1,47 +1,5 @@
|
|
|
1
|
-
import type { AnalyticsData } from "
|
|
2
|
-
import type {
|
|
3
|
-
import type { ToolCall, ToolResult } from "../types/streamTypes.js";
|
|
4
|
-
/**
|
|
5
|
-
* Raw usage data from Vercel AI SDK (uses different field names)
|
|
6
|
-
*/
|
|
7
|
-
interface AISDKUsage {
|
|
8
|
-
promptTokens: number;
|
|
9
|
-
completionTokens: number;
|
|
10
|
-
totalTokens: number;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Stream analytics result from Vercel AI SDK streamText
|
|
14
|
-
*/
|
|
15
|
-
export interface StreamTextResult {
|
|
16
|
-
textStream: AsyncIterable<string>;
|
|
17
|
-
text: Promise<string>;
|
|
18
|
-
usage: Promise<AISDKUsage | undefined>;
|
|
19
|
-
response: Promise<{
|
|
20
|
-
id?: string;
|
|
21
|
-
model?: string;
|
|
22
|
-
timestamp?: number | Date;
|
|
23
|
-
} | undefined>;
|
|
24
|
-
finishReason: Promise<"stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown">;
|
|
25
|
-
toolResults?: Promise<ToolResult[]>;
|
|
26
|
-
toolCalls?: Promise<ToolCall[]>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Interface for collecting analytics from streaming results
|
|
30
|
-
*/
|
|
31
|
-
export interface StreamAnalyticsCollector {
|
|
32
|
-
collectUsage(result: StreamTextResult): Promise<TokenUsage>;
|
|
33
|
-
collectMetadata(result: StreamTextResult): Promise<ResponseMetadata>;
|
|
34
|
-
createAnalytics(provider: string, model: string, result: StreamTextResult, responseTime: number, metadata?: Record<string, unknown>): Promise<AnalyticsData>;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Response metadata from stream result
|
|
38
|
-
*/
|
|
39
|
-
export interface ResponseMetadata {
|
|
40
|
-
id?: string;
|
|
41
|
-
model?: string;
|
|
42
|
-
timestamp?: number;
|
|
43
|
-
finishReason?: string;
|
|
44
|
-
}
|
|
1
|
+
import type { AnalyticsData, TokenUsage } from "../types/analytics.js";
|
|
2
|
+
import type { StreamTextResult, StreamAnalyticsCollector, ResponseMetadata } from "../types/streamTypes.js";
|
|
45
3
|
/**
|
|
46
4
|
* Base implementation for collecting analytics from Vercel AI SDK stream results
|
|
47
5
|
*/
|
|
@@ -67,4 +25,3 @@ export declare class BaseStreamAnalyticsCollector implements StreamAnalyticsColl
|
|
|
67
25
|
* Global instance of stream analytics collector
|
|
68
26
|
*/
|
|
69
27
|
export declare const streamAnalyticsCollector: BaseStreamAnalyticsCollector;
|
|
70
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AIProvider, AIProviderName } from "../
|
|
1
|
+
import type { AIProvider, AIProviderName } from "../types/index.js";
|
|
2
2
|
import type { UnknownRecord } from "../types/common.js";
|
|
3
3
|
/**
|
|
4
4
|
* Provider constructor interface - supports both sync constructors and async factory functions
|
|
@@ -2,7 +2,7 @@ import { ProviderFactory } from "./providerFactory.js";
|
|
|
2
2
|
// Lazy loading all providers to avoid circular dependencies
|
|
3
3
|
// Removed all static imports - providers loaded dynamically when needed
|
|
4
4
|
// This breaks the circular dependency chain completely
|
|
5
|
-
import { AIProviderName, GoogleAIModels, OpenAIModels } from "../
|
|
5
|
+
import { AIProviderName, GoogleAIModels, OpenAIModels, } from "../types/index.js";
|
|
6
6
|
import { logger } from "../utils/logger.js";
|
|
7
7
|
/**
|
|
8
8
|
* Provider Registry - registers all providers with the factory
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { AIProviderFactory } from "./core/factory.js";
|
|
10
10
|
export { AIProviderFactory };
|
|
11
|
-
export type { AIProvider, AIProviderName, ProviderConfig, StreamingOptions, ProviderAttempt, SupportedModelName, } from "./
|
|
11
|
+
export type { AIProvider, AIProviderName, ProviderConfig, StreamingOptions, ProviderAttempt, SupportedModelName, } from "./types/index.js";
|
|
12
12
|
export type { GenerateOptions, GenerateResult, EnhancedProvider, } from "./types/generateTypes.js";
|
|
13
13
|
export type { ToolContext } from "./sdk/toolRegistration.js";
|
|
14
14
|
export { validateTool } from "./sdk/toolRegistration.js";
|
|
15
15
|
export type { ToolResult, ToolDefinition } from "./types/tools.js";
|
|
16
|
-
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./
|
|
16
|
+
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./types/index.js";
|
|
17
17
|
export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
|
|
18
18
|
export { dynamicModelProvider } from "./core/dynamicModels.js";
|
|
19
|
-
export type {
|
|
19
|
+
export type { DynamicModelConfig, ModelRegistry } from "./types/modelTypes.js";
|
|
20
20
|
export { NeuroLink } from "./neurolink.js";
|
|
21
21
|
export type { ProviderStatus, MCPStatus } from "./neurolink.js";
|
|
22
22
|
export type { MCPServerInfo } from "./types/mcpTypes.js";
|
|
@@ -85,8 +85,7 @@ export declare function getTelemetryStatus(): {
|
|
|
85
85
|
enabled: boolean;
|
|
86
86
|
initialized: boolean;
|
|
87
87
|
};
|
|
88
|
-
export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, } from "./
|
|
89
|
-
export type { EvaluationData } from "./types/providers.js";
|
|
88
|
+
export type { TextGenerationOptions, TextGenerationResult, AnalyticsData, EvaluationData, } from "./types/index.js";
|
|
90
89
|
/**
|
|
91
90
|
* BACKWARD COMPATIBILITY: Legacy generateText function
|
|
92
91
|
* Provides standalone generateText function for existing code that uses it
|
|
@@ -103,4 +102,4 @@ export type { EvaluationData } from "./types/providers.js";
|
|
|
103
102
|
* console.log(result.content);
|
|
104
103
|
* ```
|
|
105
104
|
*/
|
|
106
|
-
export declare function generateText(options: import("./
|
|
105
|
+
export declare function generateText(options: import("./types/index.js").TextGenerationOptions): Promise<import("./types/index.js").TextGenerationResult>;
|
package/dist/lib/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { AIProviderFactory } from "./core/factory.js";
|
|
|
11
11
|
export { AIProviderFactory };
|
|
12
12
|
export { validateTool } from "./sdk/toolRegistration.js";
|
|
13
13
|
// Model enums
|
|
14
|
-
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./
|
|
14
|
+
export { BedrockModels, OpenAIModels, VertexModels, DEFAULT_PROVIDER_CONFIGS, } from "./types/index.js";
|
|
15
15
|
// Utility exports
|
|
16
16
|
export { getBestProvider, getAvailableProviders, isValidProvider, } from "./utils/providerUtils.js";
|
|
17
17
|
// Dynamic Models exports
|
|
@@ -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 "../
|
|
6
|
+
import { AIProviderName } from "../types/index.js";
|
|
7
7
|
import type { JsonValue } from "../types/common.js";
|
|
8
8
|
/**
|
|
9
9
|
* Model capabilities interface
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides model resolution, search, and recommendation functionality
|
|
4
4
|
* Part of Phase 4.1 - Models Command System
|
|
5
5
|
*/
|
|
6
|
-
import { AIProviderName } from "../
|
|
6
|
+
import { AIProviderName } from "../types/index.js";
|
|
7
7
|
import type { JsonValue } from "../types/common.js";
|
|
8
8
|
import { type ModelInfo, type ModelSearchFilters, type ModelSearchResult, type ModelCapabilities, type UseCaseSuitability } from "./modelRegistry.js";
|
|
9
9
|
/**
|
package/dist/lib/neurolink.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Enhanced AI provider system with natural MCP tool access.
|
|
6
6
|
* Uses real MCP infrastructure for tool discovery and execution.
|
|
7
7
|
*/
|
|
8
|
-
import type { TextGenerationOptions, TextGenerationResult } from "./
|
|
8
|
+
import type { TextGenerationOptions, TextGenerationResult } from "./types/index.js";
|
|
9
9
|
import type { GenerateOptions, GenerateResult } from "./types/generateTypes.js";
|
|
10
10
|
import type { StreamOptions, StreamResult } from "./types/streamTypes.js";
|
|
11
11
|
import type { MCPServerInfo, MCPExecutableTool } from "./types/mcpTypes.js";
|
|
@@ -146,7 +146,7 @@ export declare class NeuroLink {
|
|
|
146
146
|
*/
|
|
147
147
|
private registerDirectToolsServerInternal;
|
|
148
148
|
/**
|
|
149
|
-
* Load MCP configuration from .mcp-config.json
|
|
149
|
+
* Load MCP configuration from .mcp-config.json with parallel loading for improved performance
|
|
150
150
|
*/
|
|
151
151
|
private loadMCPConfigurationInternal;
|
|
152
152
|
/**
|
package/dist/lib/neurolink.js
CHANGED
|
@@ -36,7 +36,7 @@ import { ExternalServerManager } from "./mcp/externalServerManager.js";
|
|
|
36
36
|
// Import direct tools server for automatic registration
|
|
37
37
|
import { directToolsServer } from "./mcp/servers/agent/directToolsServer.js";
|
|
38
38
|
import { isNonNullObject } from "./utils/typeUtils.js";
|
|
39
|
-
// Core types imported from
|
|
39
|
+
// Core types imported from "./types/index.js"
|
|
40
40
|
export class NeuroLink {
|
|
41
41
|
mcpInitialized = false;
|
|
42
42
|
emitter = new EventEmitter();
|
|
@@ -705,7 +705,7 @@ export class NeuroLink {
|
|
|
705
705
|
}
|
|
706
706
|
}
|
|
707
707
|
/**
|
|
708
|
-
* Load MCP configuration from .mcp-config.json
|
|
708
|
+
* Load MCP configuration from .mcp-config.json with parallel loading for improved performance
|
|
709
709
|
*/
|
|
710
710
|
async loadMCPConfigurationInternal(mcpInitId, mcpInitStartTime, mcpInitHrTimeStart) {
|
|
711
711
|
const mcpConfigStartTime = process.hrtime.bigint();
|
|
@@ -720,7 +720,8 @@ export class NeuroLink {
|
|
|
720
720
|
message: "Starting MCP configuration loading from .mcp-config.json",
|
|
721
721
|
});
|
|
722
722
|
try {
|
|
723
|
-
const configResult = await this.externalServerManager.loadMCPConfiguration(
|
|
723
|
+
const configResult = await this.externalServerManager.loadMCPConfiguration(undefined, // Use default config path
|
|
724
|
+
{ parallel: true });
|
|
724
725
|
const mcpConfigSuccessTime = process.hrtime.bigint();
|
|
725
726
|
const mcpConfigDurationNs = mcpConfigSuccessTime - mcpConfigStartTime;
|
|
726
727
|
logger.debug(`[NeuroLink] ✅ LOG_POINT_M015_MCP_CONFIG_SUCCESS`, {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { BedrockRuntimeClient } from "@aws-sdk/client-bedrock-runtime";
|
|
2
2
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
3
|
-
import type { AIProviderName, EnhancedGenerateResult } from "../
|
|
3
|
+
import type { AIProviderName, EnhancedGenerateResult, TextGenerationOptions } from "../types/index.js";
|
|
4
4
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
|
-
import type { TextGenerationOptions } from "../core/types.js";
|
|
6
5
|
import type { NeuroLink } from "../neurolink.js";
|
|
7
6
|
export declare class AmazonBedrockProvider extends BaseProvider {
|
|
8
7
|
private bedrockClient;
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ZodType, ZodTypeDef } from "zod";
|
|
8
8
|
import type { Schema, LanguageModelV1 } from "ai";
|
|
9
|
-
import type { AIProviderName } from "../
|
|
9
|
+
import type { AIProviderName } from "../types/index.js";
|
|
10
10
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
11
11
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
12
12
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
2
|
import type { ValidationSchema } from "../types/typeAliases.js";
|
|
3
|
-
import type { AIProviderName } from "../
|
|
3
|
+
import type { AIProviderName } from "../types/index.js";
|
|
4
4
|
import type { StreamOptions, StreamResult } from "../types/streamTypes.js";
|
|
5
5
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createAnthropic } from "@ai-sdk/anthropic";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
-
import { AnthropicModels } from "../
|
|
3
|
+
import { AnthropicModels } from "../types/index.js";
|
|
4
4
|
import { BaseProvider } from "../core/baseProvider.js";
|
|
5
5
|
import { logger } from "../utils/logger.js";
|
|
6
6
|
import { createTimeoutController, TimeoutError } from "../utils/timeout.js";
|