@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
|
@@ -1,26 +1,65 @@
|
|
|
1
1
|
import type { Tool } from "ai";
|
|
2
2
|
import type { ValidationSchema, StandardRecord } from "./typeAliases.js";
|
|
3
|
-
import type { AIProviderName,
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
3
|
+
import type { AIProviderName, ProviderConfig } from "./providers.js";
|
|
4
|
+
import type { AnalyticsData, TokenUsage } from "./analytics.js";
|
|
5
|
+
import type { EvaluationData } from "./evaluation.js";
|
|
6
6
|
import type { UnknownRecord, JsonValue } from "./common.js";
|
|
7
7
|
import type { ChatMessage } from "./conversationTypes.js";
|
|
8
|
-
import type { MiddlewareFactoryOptions } from "
|
|
8
|
+
import type { MiddlewareFactoryOptions } from "./middlewareTypes.js";
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Progress tracking and metadata for streaming operations
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type StreamingProgressData = {
|
|
13
|
+
chunkCount: number;
|
|
14
|
+
totalBytes: number;
|
|
15
|
+
chunkSize: number;
|
|
16
|
+
elapsedTime: number;
|
|
17
|
+
estimatedRemaining?: number;
|
|
18
|
+
streamId?: string;
|
|
19
|
+
phase: "initializing" | "streaming" | "processing" | "complete" | "error";
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Streaming metadata for performance tracking
|
|
23
|
+
*/
|
|
24
|
+
export type StreamingMetadata = {
|
|
25
|
+
startTime: number;
|
|
26
|
+
endTime?: number;
|
|
27
|
+
totalDuration?: number;
|
|
28
|
+
averageChunkSize: number;
|
|
29
|
+
maxChunkSize: number;
|
|
30
|
+
minChunkSize: number;
|
|
31
|
+
throughputBytesPerSecond?: number;
|
|
32
|
+
streamingProvider: string;
|
|
33
|
+
modelUsed: string;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Options for AI requests with unified provider configuration
|
|
37
|
+
*/
|
|
38
|
+
export type StreamingOptions = {
|
|
39
|
+
providers: ProviderConfig[];
|
|
40
|
+
temperature?: number;
|
|
41
|
+
maxTokens?: number;
|
|
42
|
+
systemPrompt?: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Progress callback for streaming operations
|
|
46
|
+
*/
|
|
47
|
+
export type ProgressCallback = (progress: StreamingProgressData) => void | Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Type for tool execution calls (AI SDK compatible)
|
|
50
|
+
*/
|
|
51
|
+
export type ToolCall = {
|
|
13
52
|
type?: "tool-call";
|
|
14
53
|
toolCallId?: string;
|
|
15
54
|
toolName: string;
|
|
16
55
|
parameters?: UnknownRecord;
|
|
17
56
|
args?: UnknownRecord;
|
|
18
57
|
id?: string;
|
|
19
|
-
}
|
|
58
|
+
};
|
|
20
59
|
/**
|
|
21
|
-
*
|
|
60
|
+
* Type for tool execution results - Enhanced for type safety
|
|
22
61
|
*/
|
|
23
|
-
export
|
|
62
|
+
export type ToolResult = {
|
|
24
63
|
toolName: string;
|
|
25
64
|
status: "success" | "failure";
|
|
26
65
|
output?: JsonValue;
|
|
@@ -34,7 +73,7 @@ export interface ToolResult {
|
|
|
34
73
|
toolCategory?: string;
|
|
35
74
|
isExternal?: boolean;
|
|
36
75
|
};
|
|
37
|
-
}
|
|
76
|
+
};
|
|
38
77
|
/**
|
|
39
78
|
* Tool Call Results Array - High Reusability
|
|
40
79
|
*/
|
|
@@ -46,7 +85,7 @@ export type ToolCalls = Array<ToolCall>;
|
|
|
46
85
|
/**
|
|
47
86
|
* Stream Analytics Data - Enhanced for performance tracking
|
|
48
87
|
*/
|
|
49
|
-
export
|
|
88
|
+
export type StreamAnalyticsData = {
|
|
50
89
|
/** Tool execution results with timing */
|
|
51
90
|
toolResults?: Promise<ToolCallResults>;
|
|
52
91
|
/** Tool calls made during stream */
|
|
@@ -61,9 +100,9 @@ export interface StreamAnalyticsData {
|
|
|
61
100
|
};
|
|
62
101
|
/** Provider analytics */
|
|
63
102
|
providerAnalytics?: AnalyticsData;
|
|
64
|
-
}
|
|
103
|
+
};
|
|
65
104
|
/**
|
|
66
|
-
* Stream function options
|
|
105
|
+
* Stream function options type - Primary method for streaming content
|
|
67
106
|
* Future-ready for multi-modal capabilities while maintaining text focus
|
|
68
107
|
*/
|
|
69
108
|
export type PCMEncoding = "PCM16LE";
|
|
@@ -79,7 +118,7 @@ export interface AudioChunk {
|
|
|
79
118
|
channels: number;
|
|
80
119
|
encoding: PCMEncoding;
|
|
81
120
|
}
|
|
82
|
-
export
|
|
121
|
+
export type StreamOptions = {
|
|
83
122
|
input: {
|
|
84
123
|
text?: string;
|
|
85
124
|
audio?: AudioInputSpec;
|
|
@@ -127,12 +166,12 @@ export interface StreamOptions {
|
|
|
127
166
|
};
|
|
128
167
|
conversationMessages?: ChatMessage[];
|
|
129
168
|
middleware?: MiddlewareFactoryOptions;
|
|
130
|
-
}
|
|
169
|
+
};
|
|
131
170
|
/**
|
|
132
|
-
* Stream function result
|
|
171
|
+
* Stream function result type - Primary output format for streaming
|
|
133
172
|
* Future-ready for multi-modal outputs while maintaining text focus
|
|
134
173
|
*/
|
|
135
|
-
export
|
|
174
|
+
export type StreamResult = {
|
|
136
175
|
stream: AsyncIterable<{
|
|
137
176
|
content: string;
|
|
138
177
|
} | {
|
|
@@ -155,12 +194,53 @@ export interface StreamResult {
|
|
|
155
194
|
};
|
|
156
195
|
analytics?: AnalyticsData | Promise<AnalyticsData>;
|
|
157
196
|
evaluation?: EvaluationData | Promise<EvaluationData>;
|
|
158
|
-
}
|
|
197
|
+
};
|
|
159
198
|
/**
|
|
160
|
-
* Enhanced provider
|
|
199
|
+
* Enhanced provider type with stream method
|
|
161
200
|
*/
|
|
162
|
-
export
|
|
201
|
+
export type EnhancedStreamProvider = {
|
|
163
202
|
stream(options: StreamOptions): Promise<StreamResult>;
|
|
164
203
|
getName(): string;
|
|
165
204
|
isAvailable(): Promise<boolean>;
|
|
166
|
-
}
|
|
205
|
+
};
|
|
206
|
+
/**
|
|
207
|
+
* Stream text result from AI SDK
|
|
208
|
+
*/
|
|
209
|
+
export type StreamTextResult = {
|
|
210
|
+
textStream: AsyncIterable<string>;
|
|
211
|
+
text: Promise<string>;
|
|
212
|
+
usage: Promise<AISDKUsage | undefined>;
|
|
213
|
+
response: Promise<{
|
|
214
|
+
id?: string;
|
|
215
|
+
model?: string;
|
|
216
|
+
timestamp?: number | Date;
|
|
217
|
+
} | undefined>;
|
|
218
|
+
finishReason: Promise<"stop" | "length" | "content-filter" | "tool-calls" | "error" | "other" | "unknown">;
|
|
219
|
+
toolResults?: Promise<ToolResult[]>;
|
|
220
|
+
toolCalls?: Promise<ToolCall[]>;
|
|
221
|
+
};
|
|
222
|
+
/**
|
|
223
|
+
* Raw usage data from Vercel AI SDK
|
|
224
|
+
*/
|
|
225
|
+
export type AISDKUsage = {
|
|
226
|
+
promptTokens: number;
|
|
227
|
+
completionTokens: number;
|
|
228
|
+
totalTokens: number;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Stream analytics collector type
|
|
232
|
+
*/
|
|
233
|
+
export type StreamAnalyticsCollector = {
|
|
234
|
+
collectUsage(result: StreamTextResult): Promise<TokenUsage>;
|
|
235
|
+
collectMetadata(result: StreamTextResult): Promise<ResponseMetadata>;
|
|
236
|
+
createAnalytics(provider: string, model: string, result: StreamTextResult, startTime: number, context?: Record<string, unknown>): Promise<AnalyticsData>;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Response metadata from stream
|
|
240
|
+
*/
|
|
241
|
+
export type ResponseMetadata = {
|
|
242
|
+
id?: string;
|
|
243
|
+
model?: string;
|
|
244
|
+
timestamp?: number | Date;
|
|
245
|
+
finishReason?: string;
|
|
246
|
+
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Analytics utility functions for TokenUsage and AnalyticsData
|
|
3
3
|
* Provides helper functions to avoid manual field access patterns
|
|
4
4
|
*/
|
|
5
|
-
import type { TokenUsage, AnalyticsData } from "../types/
|
|
5
|
+
import type { TokenUsage, AnalyticsData } from "../types/index.js";
|
|
6
6
|
/**
|
|
7
7
|
* Format token usage as a human-readable string
|
|
8
8
|
*/
|
|
@@ -31,3 +31,7 @@ export declare function getAnalyticsSummary(analytics: AnalyticsData): {
|
|
|
31
31
|
costPerToken: number | null;
|
|
32
32
|
requestsPerSecond: number;
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* Type guard for token usage
|
|
36
|
+
*/
|
|
37
|
+
export declare function isTokenUsage(value: unknown): value is TokenUsage;
|
|
@@ -74,3 +74,16 @@ export function getAnalyticsSummary(analytics) {
|
|
|
74
74
|
requestsPerSecond,
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Type guard for token usage
|
|
79
|
+
*/
|
|
80
|
+
export function isTokenUsage(value) {
|
|
81
|
+
return (typeof value === "object" &&
|
|
82
|
+
value !== null &&
|
|
83
|
+
"input" in value &&
|
|
84
|
+
"output" in value &&
|
|
85
|
+
"total" in value &&
|
|
86
|
+
typeof value.input === "number" &&
|
|
87
|
+
typeof value.output === "number" &&
|
|
88
|
+
typeof value.total === "number");
|
|
89
|
+
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { ConversationMemoryConfig, ChatMessage } from "../types/conversationTypes.js";
|
|
6
6
|
import type { ConversationMemoryManager } from "../core/conversationMemoryManager.js";
|
|
7
|
-
import type { TextGenerationOptions, TextGenerationResult } from "../
|
|
7
|
+
import type { TextGenerationOptions, TextGenerationResult } from "../types/index.js";
|
|
8
8
|
/**
|
|
9
9
|
* Apply conversation memory defaults to user configuration
|
|
10
10
|
* Merges user config with environment variables and default values
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Provides helper functions to handle partial evaluation data and ensure
|
|
4
4
|
* complete EvaluationData objects with safe defaults
|
|
5
5
|
*/
|
|
6
|
-
import type { EvaluationData } from "../types/
|
|
6
|
+
import type { EvaluationData } from "../types/evaluation.js";
|
|
7
7
|
/**
|
|
8
8
|
* Normalize partial EvaluationData into a complete EvaluationData object
|
|
9
9
|
* with safe defaults for missing required fields
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import type { GenerateOptions } from "../types/generateTypes.js";
|
|
7
7
|
import type { StreamOptions } from "../types/streamTypes.js";
|
|
8
|
-
import type { TextGenerationOptions } from "../
|
|
8
|
+
import type { TextGenerationOptions } from "../types/index.js";
|
|
9
9
|
import type { UnknownRecord, JsonValue } from "../types/common.js";
|
|
10
10
|
import type { StandardRecord } from "../types/typeAliases.js";
|
|
11
11
|
/**
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Centralized logic for building message arrays from TextGenerationOptions
|
|
4
4
|
*/
|
|
5
5
|
import type { ChatMessage } from "../types/conversationTypes.js";
|
|
6
|
-
import type { TextGenerationOptions } from "../
|
|
6
|
+
import type { TextGenerationOptions } from "../types/index.js";
|
|
7
7
|
import type { StreamOptions } from "../types/streamTypes.js";
|
|
8
8
|
/**
|
|
9
9
|
* Build a properly formatted message array for AI providers
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Provider Health Checking System
|
|
3
3
|
* Prevents 500 errors by validating provider availability and configuration
|
|
4
4
|
*/
|
|
5
|
-
import { AIProviderName } from "../
|
|
5
|
+
import { AIProviderName } from "../types/index.js";
|
|
6
6
|
export interface ProviderHealthStatus {
|
|
7
7
|
provider: AIProviderName;
|
|
8
8
|
isHealthy: boolean;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Prevents 500 errors by validating provider availability and configuration
|
|
4
4
|
*/
|
|
5
5
|
import { logger } from "./logger.js";
|
|
6
|
-
import { AIProviderName } from "../
|
|
6
|
+
import { AIProviderName } from "../types/index.js";
|
|
7
7
|
import { basename } from "path";
|
|
8
8
|
import { createProxyFetch } from "../proxy/proxyFetch.js";
|
|
9
9
|
export class ProviderHealthChecker {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ProviderError } from "../types/index.js";
|
|
1
2
|
/**
|
|
2
3
|
* Get the best available provider based on real-time availability checks
|
|
3
4
|
* Enhanced version consolidated from providerUtils-fixed.ts
|
|
@@ -40,3 +41,7 @@ export declare function getAvailableProviders(): string[];
|
|
|
40
41
|
* @returns True if provider name is valid
|
|
41
42
|
*/
|
|
42
43
|
export declare function isValidProvider(provider: string): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Type guard for provider error
|
|
46
|
+
*/
|
|
47
|
+
export declare function isProviderError(error: unknown): error is ProviderError;
|
|
@@ -434,3 +434,9 @@ export function getAvailableProviders() {
|
|
|
434
434
|
export function isValidProvider(provider) {
|
|
435
435
|
return getAvailableProviders().includes(provider.toLowerCase());
|
|
436
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Type guard for provider error
|
|
439
|
+
*/
|
|
440
|
+
export function isProviderError(error) {
|
|
441
|
+
return error instanceof Error && "provider" in error;
|
|
442
|
+
}
|
|
@@ -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/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/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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZodType, ZodTypeDef } from "zod";
|
|
2
2
|
import { type Schema, type LanguageModelV1 } from "ai";
|
|
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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LanguageModelV1 } from "ai";
|
|
2
2
|
import { BaseProvider } from "../core/baseProvider.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
|
export declare class AzureOpenAIProvider extends BaseProvider {
|
|
6
6
|
private apiKey;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Schema, type LanguageModelV1 } from "ai";
|
|
2
2
|
import type { ZodUnknownSchema } 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 { createGoogleGenerativeAI } from "@ai-sdk/google";
|
|
2
2
|
import { streamText } from "ai";
|
|
3
|
-
import { GoogleAIModels } from "../
|
|
3
|
+
import { GoogleAIModels } 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";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ZodType, ZodTypeDef } from "zod";
|
|
2
2
|
import { type Schema, type LanguageModelV1, type LanguageModel } from "ai";
|
|
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
|
/**
|