@juspay/neurolink 7.32.0 → 7.33.1
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 +7 -1
- package/dist/core/baseProvider.js +59 -42
- 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 +7 -1
- package/dist/lib/core/baseProvider.js +59 -42
- 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/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 +1 -1
- package/dist/lib/neurolink.js +1 -1
- 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/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 +1 -1
- package/dist/neurolink.js +1 -1
- 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
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.33.1",
|
|
4
4
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juspay Technologies",
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,223 +0,0 @@
|
|
|
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/providers.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
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Supported Models for Google Vertex AI
|
|
73
|
-
*/
|
|
74
|
-
export declare enum VertexModels {
|
|
75
|
-
CLAUDE_4_0_SONNET = "claude-sonnet-4@20250514",
|
|
76
|
-
CLAUDE_4_0_OPUS = "claude-opus-4@20250514",
|
|
77
|
-
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
|
78
|
-
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
|
79
|
-
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
|
80
|
-
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
|
81
|
-
CLAUDE_3_HAIKU = "claude-3-haiku-20240307",
|
|
82
|
-
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
|
83
|
-
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
|
84
|
-
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
|
85
|
-
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
|
86
|
-
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
|
87
|
-
GEMINI_1_5_FLASH = "gemini-1.5-flash"
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Supported Models for Google AI Studio
|
|
91
|
-
*/
|
|
92
|
-
export declare enum GoogleAIModels {
|
|
93
|
-
GEMINI_2_5_PRO = "gemini-2.5-pro",
|
|
94
|
-
GEMINI_2_5_FLASH = "gemini-2.5-flash",
|
|
95
|
-
GEMINI_2_5_FLASH_LITE = "gemini-2.5-flash-lite",
|
|
96
|
-
GEMINI_2_0_FLASH_001 = "gemini-2.0-flash-001",
|
|
97
|
-
GEMINI_1_5_PRO = "gemini-1.5-pro",
|
|
98
|
-
GEMINI_1_5_FLASH = "gemini-1.5-flash",
|
|
99
|
-
GEMINI_1_5_FLASH_LITE = "gemini-1.5-flash-lite"
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
* Supported Models for Anthropic (Direct API)
|
|
103
|
-
*/
|
|
104
|
-
export declare enum AnthropicModels {
|
|
105
|
-
CLAUDE_3_5_SONNET = "claude-3-5-sonnet-20241022",
|
|
106
|
-
CLAUDE_3_5_HAIKU = "claude-3-5-haiku-20241022",
|
|
107
|
-
CLAUDE_3_SONNET = "claude-3-sonnet-20240229",
|
|
108
|
-
CLAUDE_3_OPUS = "claude-3-opus-20240229",
|
|
109
|
-
CLAUDE_3_HAIKU = "claude-3-haiku-20240307"
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Union type of all supported model names
|
|
113
|
-
*/
|
|
114
|
-
export type SupportedModelName = BedrockModels | OpenAIModels | VertexModels | GoogleAIModels | AnthropicModels;
|
|
115
|
-
/**
|
|
116
|
-
* Provider configuration specifying provider and its available models
|
|
117
|
-
*/
|
|
118
|
-
export interface ProviderConfig {
|
|
119
|
-
provider: AIProviderName;
|
|
120
|
-
models: SupportedModelName[];
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Options for AI requests with unified provider configuration
|
|
124
|
-
*/
|
|
125
|
-
export interface StreamingOptions {
|
|
126
|
-
providers: ProviderConfig[];
|
|
127
|
-
temperature?: number;
|
|
128
|
-
maxTokens?: number;
|
|
129
|
-
systemPrompt?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Text generation options interface
|
|
133
|
-
*/
|
|
134
|
-
export interface TextGenerationOptions {
|
|
135
|
-
prompt?: string;
|
|
136
|
-
input?: {
|
|
137
|
-
text: string;
|
|
138
|
-
};
|
|
139
|
-
provider?: AIProviderName;
|
|
140
|
-
model?: string;
|
|
141
|
-
temperature?: number;
|
|
142
|
-
maxTokens?: number;
|
|
143
|
-
systemPrompt?: string;
|
|
144
|
-
schema?: ZodUnknownSchema | Schema<unknown>;
|
|
145
|
-
tools?: Record<string, Tool>;
|
|
146
|
-
timeout?: number | string;
|
|
147
|
-
disableTools?: boolean;
|
|
148
|
-
maxSteps?: number;
|
|
149
|
-
enableEvaluation?: boolean;
|
|
150
|
-
enableAnalytics?: boolean;
|
|
151
|
-
context?: Record<string, JsonValue>;
|
|
152
|
-
evaluationDomain?: string;
|
|
153
|
-
toolUsageContext?: string;
|
|
154
|
-
conversationHistory?: Array<{
|
|
155
|
-
role: string;
|
|
156
|
-
content: string;
|
|
157
|
-
}>;
|
|
158
|
-
conversationMessages?: ChatMessage[];
|
|
159
|
-
conversationMemoryConfig?: Partial<ConversationMemoryConfig>;
|
|
160
|
-
originalPrompt?: string;
|
|
161
|
-
middleware?: MiddlewareFactoryOptions;
|
|
162
|
-
expectedOutcome?: string;
|
|
163
|
-
evaluationCriteria?: string[];
|
|
164
|
-
}
|
|
165
|
-
export type { AnalyticsData } from "../types/providers.js";
|
|
166
|
-
/**
|
|
167
|
-
* Enhanced result interfaces with optional analytics/evaluation
|
|
168
|
-
*/
|
|
169
|
-
export interface EnhancedGenerateResult extends GenerateResult {
|
|
170
|
-
analytics?: AnalyticsData;
|
|
171
|
-
evaluation?: EvaluationData;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Phase 2: Enhanced Streaming Infrastructure
|
|
175
|
-
* Progress tracking and metadata for streaming operations
|
|
176
|
-
*/
|
|
177
|
-
export interface StreamingProgressData {
|
|
178
|
-
chunkCount: number;
|
|
179
|
-
totalBytes: number;
|
|
180
|
-
chunkSize: number;
|
|
181
|
-
elapsedTime: number;
|
|
182
|
-
estimatedRemaining?: number;
|
|
183
|
-
streamId?: string;
|
|
184
|
-
phase: "initializing" | "streaming" | "processing" | "complete" | "error";
|
|
185
|
-
}
|
|
186
|
-
export interface StreamingMetadata {
|
|
187
|
-
startTime: number;
|
|
188
|
-
endTime?: number;
|
|
189
|
-
totalDuration?: number;
|
|
190
|
-
averageChunkSize: number;
|
|
191
|
-
maxChunkSize: number;
|
|
192
|
-
minChunkSize: number;
|
|
193
|
-
throughputBytesPerSecond?: number;
|
|
194
|
-
streamingProvider: string;
|
|
195
|
-
modelUsed: string;
|
|
196
|
-
}
|
|
197
|
-
export type ProgressCallback = (progress: StreamingProgressData) => void;
|
|
198
|
-
/**
|
|
199
|
-
* AI Provider interface with flexible parameter support
|
|
200
|
-
*/
|
|
201
|
-
export interface AIProvider {
|
|
202
|
-
stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
203
|
-
generate(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
|
204
|
-
gen(optionsOrPrompt: TextGenerationOptions | string, analysisSchema?: ValidationSchema): Promise<EnhancedGenerateResult | null>;
|
|
205
|
-
setupToolExecutor(sdk: {
|
|
206
|
-
customTools: Map<string, unknown>;
|
|
207
|
-
executeTool: (toolName: string, params: unknown) => Promise<unknown>;
|
|
208
|
-
}, functionTag: string): void;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Provider attempt result for iteration tracking
|
|
212
|
-
*/
|
|
213
|
-
export interface ProviderAttempt {
|
|
214
|
-
provider: AIProviderName;
|
|
215
|
-
model: SupportedModelName;
|
|
216
|
-
success: boolean;
|
|
217
|
-
error?: string;
|
|
218
|
-
stack?: string;
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
|
-
* Default provider configurations
|
|
222
|
-
*/
|
|
223
|
-
export declare const DEFAULT_PROVIDER_CONFIGS: ProviderConfig[];
|
package/dist/core/types.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
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 || (OpenAIModels = {}));
|
|
41
|
-
/**
|
|
42
|
-
* Supported Models for Google Vertex AI
|
|
43
|
-
*/
|
|
44
|
-
export var VertexModels;
|
|
45
|
-
(function (VertexModels) {
|
|
46
|
-
// Claude 4 Series (Latest - May 2025)
|
|
47
|
-
VertexModels["CLAUDE_4_0_SONNET"] = "claude-sonnet-4@20250514";
|
|
48
|
-
VertexModels["CLAUDE_4_0_OPUS"] = "claude-opus-4@20250514";
|
|
49
|
-
// Claude 3.5 Series (Still supported)
|
|
50
|
-
VertexModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
|
51
|
-
VertexModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
|
52
|
-
// Claude 3 Series (Legacy support)
|
|
53
|
-
VertexModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
|
54
|
-
VertexModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
|
55
|
-
VertexModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
|
56
|
-
// Gemini 2.5 Series (Latest - 2025)
|
|
57
|
-
VertexModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
|
58
|
-
VertexModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
|
59
|
-
VertexModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
60
|
-
// Gemini 2.0 Series
|
|
61
|
-
VertexModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
|
62
|
-
// Gemini 1.5 Series (Legacy support)
|
|
63
|
-
VertexModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
|
64
|
-
VertexModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
|
65
|
-
})(VertexModels || (VertexModels = {}));
|
|
66
|
-
/**
|
|
67
|
-
* Supported Models for Google AI Studio
|
|
68
|
-
*/
|
|
69
|
-
export var GoogleAIModels;
|
|
70
|
-
(function (GoogleAIModels) {
|
|
71
|
-
// Gemini 2.5 Series (Latest - 2025)
|
|
72
|
-
GoogleAIModels["GEMINI_2_5_PRO"] = "gemini-2.5-pro";
|
|
73
|
-
GoogleAIModels["GEMINI_2_5_FLASH"] = "gemini-2.5-flash";
|
|
74
|
-
GoogleAIModels["GEMINI_2_5_FLASH_LITE"] = "gemini-2.5-flash-lite";
|
|
75
|
-
// Gemini 2.0 Series
|
|
76
|
-
GoogleAIModels["GEMINI_2_0_FLASH_001"] = "gemini-2.0-flash-001";
|
|
77
|
-
// Gemini 1.5 Series (Legacy support)
|
|
78
|
-
GoogleAIModels["GEMINI_1_5_PRO"] = "gemini-1.5-pro";
|
|
79
|
-
GoogleAIModels["GEMINI_1_5_FLASH"] = "gemini-1.5-flash";
|
|
80
|
-
GoogleAIModels["GEMINI_1_5_FLASH_LITE"] = "gemini-1.5-flash-lite";
|
|
81
|
-
})(GoogleAIModels || (GoogleAIModels = {}));
|
|
82
|
-
/**
|
|
83
|
-
* Supported Models for Anthropic (Direct API)
|
|
84
|
-
*/
|
|
85
|
-
export var AnthropicModels;
|
|
86
|
-
(function (AnthropicModels) {
|
|
87
|
-
// Claude 3.5 Series (Latest)
|
|
88
|
-
AnthropicModels["CLAUDE_3_5_SONNET"] = "claude-3-5-sonnet-20241022";
|
|
89
|
-
AnthropicModels["CLAUDE_3_5_HAIKU"] = "claude-3-5-haiku-20241022";
|
|
90
|
-
// Claude 3 Series (Legacy support)
|
|
91
|
-
AnthropicModels["CLAUDE_3_SONNET"] = "claude-3-sonnet-20240229";
|
|
92
|
-
AnthropicModels["CLAUDE_3_OPUS"] = "claude-3-opus-20240229";
|
|
93
|
-
AnthropicModels["CLAUDE_3_HAIKU"] = "claude-3-haiku-20240307";
|
|
94
|
-
})(AnthropicModels || (AnthropicModels = {}));
|
|
95
|
-
/**
|
|
96
|
-
* Default provider configurations
|
|
97
|
-
*/
|
|
98
|
-
export const DEFAULT_PROVIDER_CONFIGS = [
|
|
99
|
-
{
|
|
100
|
-
provider: AIProviderName.BEDROCK,
|
|
101
|
-
models: [BedrockModels.CLAUDE_3_7_SONNET, BedrockModels.CLAUDE_3_5_SONNET],
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
provider: AIProviderName.VERTEX,
|
|
105
|
-
models: [VertexModels.CLAUDE_4_0_SONNET, VertexModels.GEMINI_2_5_FLASH],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
provider: AIProviderName.OPENAI,
|
|
109
|
-
models: [OpenAIModels.GPT_4O, OpenAIModels.GPT_4O_MINI],
|
|
110
|
-
},
|
|
111
|
-
];
|