@juspay/neurolink 7.51.1 → 7.51.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 +2 -0
- package/dist/core/conversationMemoryFactory.d.ts +1 -4
- package/dist/core/redisConversationMemoryManager.d.ts +4 -0
- package/dist/core/redisConversationMemoryManager.js +4 -0
- package/dist/lib/core/conversationMemoryFactory.d.ts +1 -4
- package/dist/lib/core/redisConversationMemoryManager.d.ts +4 -0
- package/dist/lib/core/redisConversationMemoryManager.js +4 -0
- package/dist/lib/neurolink.d.ts +2 -1
- package/dist/lib/types/common.d.ts +18 -61
- package/dist/lib/types/content.d.ts +21 -10
- package/dist/lib/types/contextTypes.d.ts +11 -11
- package/dist/lib/types/conversation.d.ts +27 -27
- package/dist/lib/types/domainTypes.d.ts +12 -12
- package/dist/lib/types/evaluationTypes.d.ts +12 -12
- package/dist/lib/types/externalMcp.d.ts +20 -20
- package/dist/lib/types/guardrails.d.ts +18 -18
- package/dist/lib/types/middlewareTypes.d.ts +86 -23
- package/dist/lib/types/providers.d.ts +72 -61
- package/dist/lib/types/providers.js +3 -0
- package/dist/lib/types/sdkTypes.d.ts +2 -2
- package/dist/lib/types/streamTypes.d.ts +8 -8
- package/dist/lib/types/tools.d.ts +79 -1
- package/dist/lib/types/utilities.d.ts +29 -0
- package/dist/lib/types/utilities.js +5 -0
- package/dist/lib/utils/providerConfig.d.ts +3 -22
- package/dist/lib/utils/timeout.d.ts +1 -16
- package/dist/neurolink.d.ts +2 -1
- package/dist/types/common.d.ts +18 -61
- package/dist/types/content.d.ts +21 -10
- package/dist/types/contextTypes.d.ts +11 -11
- package/dist/types/conversation.d.ts +27 -27
- package/dist/types/domainTypes.d.ts +12 -12
- package/dist/types/evaluationTypes.d.ts +12 -12
- package/dist/types/externalMcp.d.ts +20 -20
- package/dist/types/guardrails.d.ts +18 -18
- package/dist/types/middlewareTypes.d.ts +86 -23
- package/dist/types/providers.d.ts +72 -61
- package/dist/types/providers.js +3 -0
- package/dist/types/sdkTypes.d.ts +2 -2
- package/dist/types/streamTypes.d.ts +8 -8
- package/dist/types/tools.d.ts +79 -1
- package/dist/types/utilities.d.ts +29 -0
- package/dist/types/utilities.js +4 -0
- package/dist/utils/providerConfig.d.ts +3 -22
- package/dist/utils/timeout.d.ts +1 -16
- package/package.json +1 -1
|
@@ -7,12 +7,6 @@ import type { ValidationSchema } from "./typeAliases.js";
|
|
|
7
7
|
import type { EnhancedGenerateResult, GenerateResult, TextGenerationOptions } from "./generateTypes.js";
|
|
8
8
|
import type { StreamOptions, StreamResult } from "./streamTypes.js";
|
|
9
9
|
import type { ExternalMCPToolInfo } from "./externalMcp.js";
|
|
10
|
-
/**
|
|
11
|
-
* Generic AI SDK model interface
|
|
12
|
-
*/
|
|
13
|
-
export type AISDKModel = {
|
|
14
|
-
[key: string]: unknown;
|
|
15
|
-
};
|
|
16
10
|
/**
|
|
17
11
|
* Supported AI Provider Names
|
|
18
12
|
*/
|
|
@@ -105,6 +99,12 @@ export declare enum APIVersions {
|
|
|
105
99
|
GOOGLE_AI_BETA = "v1beta",
|
|
106
100
|
ANTHROPIC_CURRENT = "2023-06-01"
|
|
107
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Generic AI SDK model interface
|
|
104
|
+
*/
|
|
105
|
+
export type AISDKModel = {
|
|
106
|
+
[key: string]: unknown;
|
|
107
|
+
};
|
|
108
108
|
/**
|
|
109
109
|
* Union type of all supported model names
|
|
110
110
|
*/
|
|
@@ -284,7 +284,18 @@ export type IndividualProviderConfig = {
|
|
|
284
284
|
[key: string]: unknown;
|
|
285
285
|
};
|
|
286
286
|
/**
|
|
287
|
-
*
|
|
287
|
+
* Configuration options for provider validation
|
|
288
|
+
*/
|
|
289
|
+
export type ProviderConfigOptions = {
|
|
290
|
+
providerName: string;
|
|
291
|
+
envVarName: string;
|
|
292
|
+
setupUrl: string;
|
|
293
|
+
description: string;
|
|
294
|
+
instructions: string[];
|
|
295
|
+
fallbackEnvVars?: string[];
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* AI Provider type with flexible parameter support
|
|
288
299
|
*/
|
|
289
300
|
export type AIProvider = {
|
|
290
301
|
stream(optionsOrPrompt: StreamOptions | string, analysisSchema?: ValidationSchema): Promise<StreamResult>;
|
|
@@ -314,59 +325,6 @@ export type ProviderCreationError = {
|
|
|
314
325
|
provider: string;
|
|
315
326
|
details?: Record<string, unknown>;
|
|
316
327
|
};
|
|
317
|
-
/**
|
|
318
|
-
* Amazon Bedrock specific types
|
|
319
|
-
*/
|
|
320
|
-
export declare namespace BedrockTypes {
|
|
321
|
-
interface Client {
|
|
322
|
-
send(command: unknown): Promise<unknown>;
|
|
323
|
-
config: {
|
|
324
|
-
region?: string;
|
|
325
|
-
credentials?: unknown;
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
interface InvokeModelCommand {
|
|
329
|
-
input: {
|
|
330
|
-
modelId: string;
|
|
331
|
-
body: string;
|
|
332
|
-
contentType?: string;
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
/**
|
|
337
|
-
* Mistral specific types
|
|
338
|
-
*/
|
|
339
|
-
export declare namespace MistralTypes {
|
|
340
|
-
interface Client {
|
|
341
|
-
chat?: {
|
|
342
|
-
complete?: (options: unknown) => Promise<unknown>;
|
|
343
|
-
stream?: (options: unknown) => AsyncIterable<unknown>;
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* OpenTelemetry specific types (for telemetry service)
|
|
349
|
-
*/
|
|
350
|
-
export declare namespace TelemetryTypes {
|
|
351
|
-
interface Meter {
|
|
352
|
-
createCounter(name: string, options?: unknown): Counter;
|
|
353
|
-
createHistogram(name: string, options?: unknown): Histogram;
|
|
354
|
-
}
|
|
355
|
-
interface Tracer {
|
|
356
|
-
startSpan(name: string, options?: unknown): Span;
|
|
357
|
-
}
|
|
358
|
-
interface Counter {
|
|
359
|
-
add(value: number, attributes?: UnknownRecord): void;
|
|
360
|
-
}
|
|
361
|
-
interface Histogram {
|
|
362
|
-
record(value: number, attributes?: UnknownRecord): void;
|
|
363
|
-
}
|
|
364
|
-
interface Span {
|
|
365
|
-
end(): void;
|
|
366
|
-
setStatus(status: unknown): void;
|
|
367
|
-
recordException(exception: unknown): void;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
328
|
/**
|
|
371
329
|
* Provider factory function type
|
|
372
330
|
*/
|
|
@@ -1028,7 +986,7 @@ export type EndpointMetrics = {
|
|
|
1028
986
|
memoryUtilization?: number;
|
|
1029
987
|
/** Instance count */
|
|
1030
988
|
instanceCount: number;
|
|
1031
|
-
/** Timestamp of metrics */
|
|
989
|
+
/** Timestamp of metrics as ISO 8601 date string */
|
|
1032
990
|
timestamp: string;
|
|
1033
991
|
};
|
|
1034
992
|
/**
|
|
@@ -1102,3 +1060,56 @@ export type SageMakerGenerateResult = {
|
|
|
1102
1060
|
toolCalls?: SageMakerToolCall[];
|
|
1103
1061
|
object?: unknown;
|
|
1104
1062
|
};
|
|
1063
|
+
/**
|
|
1064
|
+
* Amazon Bedrock specific types
|
|
1065
|
+
*/
|
|
1066
|
+
export declare namespace BedrockTypes {
|
|
1067
|
+
interface Client {
|
|
1068
|
+
send(command: unknown): Promise<unknown>;
|
|
1069
|
+
config: {
|
|
1070
|
+
region?: string;
|
|
1071
|
+
credentials?: unknown;
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
interface InvokeModelCommand {
|
|
1075
|
+
input: {
|
|
1076
|
+
modelId: string;
|
|
1077
|
+
body: string;
|
|
1078
|
+
contentType?: string;
|
|
1079
|
+
};
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Mistral specific types
|
|
1084
|
+
*/
|
|
1085
|
+
export declare namespace MistralTypes {
|
|
1086
|
+
interface Client {
|
|
1087
|
+
chat?: {
|
|
1088
|
+
complete?: (options: unknown) => Promise<unknown>;
|
|
1089
|
+
stream?: (options: unknown) => AsyncIterable<unknown>;
|
|
1090
|
+
};
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
/**
|
|
1094
|
+
* OpenTelemetry specific types (for telemetry service)
|
|
1095
|
+
*/
|
|
1096
|
+
export declare namespace TelemetryTypes {
|
|
1097
|
+
interface Meter {
|
|
1098
|
+
createCounter(name: string, options?: unknown): Counter;
|
|
1099
|
+
createHistogram(name: string, options?: unknown): Histogram;
|
|
1100
|
+
}
|
|
1101
|
+
interface Tracer {
|
|
1102
|
+
startSpan(name: string, options?: unknown): Span;
|
|
1103
|
+
}
|
|
1104
|
+
interface Counter {
|
|
1105
|
+
add(value: number, attributes?: UnknownRecord): void;
|
|
1106
|
+
}
|
|
1107
|
+
interface Histogram {
|
|
1108
|
+
record(value: number, attributes?: UnknownRecord): void;
|
|
1109
|
+
}
|
|
1110
|
+
interface Span {
|
|
1111
|
+
end(): void;
|
|
1112
|
+
setStatus(status: unknown): void;
|
|
1113
|
+
recordException(exception: unknown): void;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Provider-specific type definitions for NeuroLink
|
|
3
3
|
*/
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// ENUMS
|
|
6
|
+
// ============================================================================
|
|
4
7
|
/**
|
|
5
8
|
* Supported AI Provider Names
|
|
6
9
|
*/
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
export type { StreamResult, StreamingProgressData, StreamingMetadata, ProgressCallback, ToolCall as StreamToolCall, // Note: Renamed in main index to avoid conflict with tools.js ToolCall
|
|
9
9
|
ToolResult as StreamToolResult, // Note: Renamed in main index to avoid conflict with tools.js ToolResult
|
|
10
10
|
ToolCallResults, ToolCalls, StreamOptions, StreamingOptions, EnhancedStreamProvider, StreamTextResult, AISDKUsage, StreamAnalyticsCollector, ResponseMetadata, AudioInputSpec, AudioChunk, PCMEncoding, } from "./streamTypes.js";
|
|
11
|
-
export type {
|
|
11
|
+
export type { TypedEventEmitter, NeuroLinkEvents, StreamEvent, AsyncFunction, SyncFunction, AnyFunction, } from "./common.js";
|
|
12
12
|
export type { NeuroLinkConfig, ProviderConfig, PerformanceConfig, CacheConfig, FallbackConfig, RetryConfig, AnalyticsConfig, ToolConfig, BackupInfo, BackupMetadata, ConfigValidationResult, ConfigUpdateOptions, } from "./configTypes.js";
|
|
13
|
-
export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, BaseToolArgs, ToolExecutionMetadata, ToolParameterSchema, ZodUnknownSchema, ZodAnySchema, ZodObjectSchema, ZodStringSchema, } from "./tools.js";
|
|
13
|
+
export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, BaseToolArgs, ToolExecutionEvent, ToolExecutionSummary, ToolExecutionContext, ToolExecutionMetadata, ToolParameterSchema, ZodUnknownSchema, ZodAnySchema, ZodObjectSchema, ZodStringSchema, } from "./tools.js";
|
|
14
14
|
export type { AISDKModel, ProviderError, AIModelProviderConfig, AIProviderName, ProviderName, ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, ProviderCapabilities, } from "./providers.js";
|
|
15
15
|
export type { GenerateOptions, GenerateResult, UnifiedGenerationOptions, EnhancedProvider, FactoryEnhancedProvider, TextGenerationOptions, TextGenerationResult, EnhancedGenerateResult, } from "./generateTypes.js";
|
|
16
16
|
export type { TokenUsage, AnalyticsData } from "./analytics.js";
|
|
@@ -2,10 +2,10 @@ import type { Tool } from "ai";
|
|
|
2
2
|
import type { ValidationSchema, StandardRecord } from "./typeAliases.js";
|
|
3
3
|
import type { AIModelProviderConfig } from "./providers.js";
|
|
4
4
|
import type { TextContent, ImageContent } from "./content.js";
|
|
5
|
-
import type { AIProviderName, AnalyticsData } from "../types/index.js";
|
|
5
|
+
import type { AIProviderName, AnalyticsData, ToolExecutionEvent, ToolExecutionSummary } from "../types/index.js";
|
|
6
6
|
import type { TokenUsage } from "./analytics.js";
|
|
7
7
|
import type { EvaluationData } from "../index.js";
|
|
8
|
-
import type { UnknownRecord, JsonValue
|
|
8
|
+
import type { UnknownRecord, JsonValue } from "./common.js";
|
|
9
9
|
import type { MiddlewareFactoryOptions } from "../types/middlewareTypes.js";
|
|
10
10
|
import type { ChatMessage } from "./conversation.js";
|
|
11
11
|
/**
|
|
@@ -108,19 +108,19 @@ export type StreamAnalyticsData = {
|
|
|
108
108
|
* Future-ready for multi-modal capabilities while maintaining text focus
|
|
109
109
|
*/
|
|
110
110
|
export type PCMEncoding = "PCM16LE";
|
|
111
|
-
export
|
|
111
|
+
export type AudioInputSpec = {
|
|
112
112
|
frames: AsyncIterable<Buffer>;
|
|
113
113
|
sampleRateHz?: number;
|
|
114
114
|
encoding?: PCMEncoding;
|
|
115
115
|
channels?: 1;
|
|
116
|
-
}
|
|
117
|
-
export
|
|
116
|
+
};
|
|
117
|
+
export type AudioChunk = {
|
|
118
118
|
data: Buffer;
|
|
119
119
|
sampleRateHz: number;
|
|
120
120
|
channels: number;
|
|
121
121
|
encoding: PCMEncoding;
|
|
122
|
-
}
|
|
123
|
-
export
|
|
122
|
+
};
|
|
123
|
+
export type StreamOptions = {
|
|
124
124
|
input: {
|
|
125
125
|
text: string;
|
|
126
126
|
audio?: AudioInputSpec;
|
|
@@ -179,7 +179,7 @@ export interface StreamOptions {
|
|
|
179
179
|
};
|
|
180
180
|
conversationMessages?: ChatMessage[];
|
|
181
181
|
middleware?: MiddlewareFactoryOptions;
|
|
182
|
-
}
|
|
182
|
+
};
|
|
183
183
|
/**
|
|
184
184
|
* Stream function result type - Primary output format for streaming
|
|
185
185
|
* Future-ready for multi-modal outputs while maintaining text focus
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* argument patterns, execution metadata, context, and result types.
|
|
4
4
|
*/
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import type {
|
|
6
|
+
import type { ErrorInfo, JsonObject, JsonValue, Result, UnknownRecord } from "./common.js";
|
|
7
7
|
import type { StandardRecord, ZodUnknownSchema } from "./typeAliases.js";
|
|
8
8
|
/**
|
|
9
9
|
* Commonly used Zod schema type aliases for cleaner type declarations
|
|
@@ -176,6 +176,63 @@ export type ToolMetadata = {
|
|
|
176
176
|
documentation?: string;
|
|
177
177
|
[key: string]: JsonValue | undefined;
|
|
178
178
|
};
|
|
179
|
+
/**
|
|
180
|
+
* Tool call object type for type-safe access to tool call properties
|
|
181
|
+
*/
|
|
182
|
+
export type ToolCallObject = UnknownRecord & {
|
|
183
|
+
toolName?: string;
|
|
184
|
+
name?: string;
|
|
185
|
+
toolCallId?: string;
|
|
186
|
+
id?: string;
|
|
187
|
+
args?: UnknownRecord;
|
|
188
|
+
arguments?: UnknownRecord;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Tool execution context for tracking
|
|
192
|
+
*/
|
|
193
|
+
export type ToolExecutionContext = {
|
|
194
|
+
executionId: string;
|
|
195
|
+
tool: string;
|
|
196
|
+
startTime: number;
|
|
197
|
+
endTime?: number;
|
|
198
|
+
result?: unknown;
|
|
199
|
+
error?: string;
|
|
200
|
+
metadata?: JsonObject;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* NeuroLink Native Event System Types
|
|
204
|
+
*/
|
|
205
|
+
/**
|
|
206
|
+
* Tool execution event for real-time streaming
|
|
207
|
+
*/
|
|
208
|
+
export type ToolExecutionEvent = {
|
|
209
|
+
type: "tool:start" | "tool:end";
|
|
210
|
+
tool: string;
|
|
211
|
+
input?: unknown;
|
|
212
|
+
result?: unknown;
|
|
213
|
+
error?: string;
|
|
214
|
+
timestamp: number;
|
|
215
|
+
duration?: number;
|
|
216
|
+
executionId: string;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Tool execution summary for completed executions
|
|
220
|
+
*/
|
|
221
|
+
export type ToolExecutionSummary = {
|
|
222
|
+
tool: string;
|
|
223
|
+
startTime: number;
|
|
224
|
+
endTime: number;
|
|
225
|
+
duration: number;
|
|
226
|
+
success: boolean;
|
|
227
|
+
result?: unknown;
|
|
228
|
+
error?: string;
|
|
229
|
+
executionId: string;
|
|
230
|
+
metadata?: {
|
|
231
|
+
serverId?: string;
|
|
232
|
+
toolCategory?: "direct" | "custom" | "mcp";
|
|
233
|
+
isExternal?: boolean;
|
|
234
|
+
};
|
|
235
|
+
};
|
|
179
236
|
/**
|
|
180
237
|
* Tool definition type
|
|
181
238
|
*/
|
|
@@ -215,6 +272,27 @@ export type ToolExecution = {
|
|
|
215
272
|
executionTime: number;
|
|
216
273
|
timestamp: number;
|
|
217
274
|
};
|
|
275
|
+
/**
|
|
276
|
+
* Pending tool execution type for Redis memory manager
|
|
277
|
+
* Temporary storage for tool execution data to avoid race conditions
|
|
278
|
+
*/
|
|
279
|
+
export type PendingToolExecution = {
|
|
280
|
+
toolCalls: Array<{
|
|
281
|
+
toolCallId?: string;
|
|
282
|
+
toolName?: string;
|
|
283
|
+
args?: Record<string, unknown>;
|
|
284
|
+
timestamp?: Date;
|
|
285
|
+
[key: string]: unknown;
|
|
286
|
+
}>;
|
|
287
|
+
toolResults: Array<{
|
|
288
|
+
toolCallId?: string;
|
|
289
|
+
result?: unknown;
|
|
290
|
+
error?: string;
|
|
291
|
+
timestamp?: Date;
|
|
292
|
+
[key: string]: unknown;
|
|
293
|
+
}>;
|
|
294
|
+
timestamp: number;
|
|
295
|
+
};
|
|
218
296
|
/**
|
|
219
297
|
* Available tool information
|
|
220
298
|
*/
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility module types - extracted from utils module files
|
|
3
|
+
*/
|
|
4
|
+
export type TimeoutConfig = {
|
|
5
|
+
operation: string;
|
|
6
|
+
timeout?: number | string;
|
|
7
|
+
gracefulShutdown?: boolean;
|
|
8
|
+
retryOnTimeout?: boolean;
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
export type TimeoutResult<T> = {
|
|
13
|
+
success: boolean;
|
|
14
|
+
data?: T;
|
|
15
|
+
error?: Error;
|
|
16
|
+
timedOut: boolean;
|
|
17
|
+
executionTime: number;
|
|
18
|
+
retriesUsed: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Enhanced validation result with format checking
|
|
22
|
+
*/
|
|
23
|
+
export type APIValidationResult = {
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
apiKey: string;
|
|
26
|
+
formatValid?: boolean;
|
|
27
|
+
errorType?: "missing" | "format" | "config";
|
|
28
|
+
error?: string;
|
|
29
|
+
};
|
|
@@ -4,17 +4,8 @@
|
|
|
4
4
|
* Eliminates duplicate error messages and configuration logic
|
|
5
5
|
* Enhanced with format validation and advanced error classification
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
10
|
-
export interface ProviderConfigOptions {
|
|
11
|
-
providerName: string;
|
|
12
|
-
envVarName: string;
|
|
13
|
-
setupUrl: string;
|
|
14
|
-
description: string;
|
|
15
|
-
instructions: string[];
|
|
16
|
-
fallbackEnvVars?: string[];
|
|
17
|
-
}
|
|
7
|
+
import type { APIValidationResult } from "../types/utilities.js";
|
|
8
|
+
import type { ProviderConfigOptions } from "../types/providers.js";
|
|
18
9
|
/**
|
|
19
10
|
* API key format validation patterns (extracted from advanced validation system)
|
|
20
11
|
* Exported for use across the codebase to replace scattered regex patterns
|
|
@@ -40,16 +31,6 @@ export declare const PROJECT_ID_FORMAT: {
|
|
|
40
31
|
readonly MAX_LENGTH: 30;
|
|
41
32
|
readonly PATTERN: RegExp;
|
|
42
33
|
};
|
|
43
|
-
/**
|
|
44
|
-
* Enhanced validation result with format checking
|
|
45
|
-
*/
|
|
46
|
-
export interface ValidationResult {
|
|
47
|
-
isValid: boolean;
|
|
48
|
-
apiKey: string;
|
|
49
|
-
formatValid?: boolean;
|
|
50
|
-
errorType?: "missing" | "format" | "config";
|
|
51
|
-
error?: string;
|
|
52
|
-
}
|
|
53
34
|
/**
|
|
54
35
|
* Validates API key format for a specific provider
|
|
55
36
|
* @param providerKey Provider identifier (e.g., 'openai', 'anthropic')
|
|
@@ -63,7 +44,7 @@ export declare function validateApiKeyFormat(providerKey: string, apiKey: string
|
|
|
63
44
|
* @param enableFormatValidation Whether to validate API key format
|
|
64
45
|
* @returns Validation result with detailed information
|
|
65
46
|
*/
|
|
66
|
-
export declare function validateApiKeyEnhanced(config: ProviderConfigOptions, enableFormatValidation?: boolean):
|
|
47
|
+
export declare function validateApiKeyEnhanced(config: ProviderConfigOptions, enableFormatValidation?: boolean): APIValidationResult;
|
|
67
48
|
/**
|
|
68
49
|
* Validates an API key for a provider and returns it (BACKWARD COMPATIBLE)
|
|
69
50
|
* Throws detailed error message if validation fails
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* Provides flexible timeout parsing and error handling for AI operations.
|
|
5
5
|
* Supports multiple time formats: milliseconds, seconds, minutes, hours.
|
|
6
6
|
*/
|
|
7
|
+
import type { TimeoutConfig, TimeoutResult } from "../types/utilities.js";
|
|
7
8
|
/**
|
|
8
9
|
* Custom error class for timeout operations
|
|
9
10
|
*/
|
|
@@ -66,22 +67,6 @@ export declare function getDefaultTimeout(provider: string, operation?: "generat
|
|
|
66
67
|
* @returns Promise that rejects with TimeoutError
|
|
67
68
|
*/
|
|
68
69
|
export declare function createTimeoutPromise(timeout: number | string | undefined, provider: string, operation: "generate" | "stream"): Promise<never> | null;
|
|
69
|
-
export interface TimeoutConfig {
|
|
70
|
-
operation: string;
|
|
71
|
-
timeout?: number | string;
|
|
72
|
-
gracefulShutdown?: boolean;
|
|
73
|
-
retryOnTimeout?: boolean;
|
|
74
|
-
maxRetries?: number;
|
|
75
|
-
abortSignal?: AbortSignal;
|
|
76
|
-
}
|
|
77
|
-
export interface TimeoutResult<T> {
|
|
78
|
-
success: boolean;
|
|
79
|
-
data?: T;
|
|
80
|
-
error?: Error;
|
|
81
|
-
timedOut: boolean;
|
|
82
|
-
executionTime: number;
|
|
83
|
-
retriesUsed: number;
|
|
84
|
-
}
|
|
85
70
|
/**
|
|
86
71
|
* Enhanced timeout manager with proper cleanup and abort controller integration
|
|
87
72
|
* Consolidated from timeout-manager.ts
|
package/dist/neurolink.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ import type { GenerateOptions, GenerateResult } from "./types/generateTypes.js";
|
|
|
11
11
|
import type { StreamOptions, StreamResult } from "./types/streamTypes.js";
|
|
12
12
|
import type { MCPServerInfo, MCPExecutableTool } from "./types/mcpTypes.js";
|
|
13
13
|
import type { ToolInfo } from "./types/tools.js";
|
|
14
|
-
import type { NeuroLinkEvents, TypedEventEmitter
|
|
14
|
+
import type { NeuroLinkEvents, TypedEventEmitter } from "./types/common.js";
|
|
15
|
+
import type { ToolExecutionContext, ToolExecutionSummary } from "./types/tools.js";
|
|
15
16
|
import type { JsonObject } from "./types/common.js";
|
|
16
17
|
import type { BatchOperationResult } from "./types/typeAliases.js";
|
|
17
18
|
import type { ConversationMemoryConfig, ChatMessage } from "./types/conversation.js";
|
package/dist/types/common.d.ts
CHANGED
|
@@ -13,38 +13,41 @@ export type UnknownRecord = Record<string, unknown>;
|
|
|
13
13
|
* Type-safe array of unknown items
|
|
14
14
|
*/
|
|
15
15
|
export type UnknownArray = unknown[];
|
|
16
|
+
/**
|
|
17
|
+
* Storage type for conversation memory factory
|
|
18
|
+
*/
|
|
19
|
+
export type StorageType = "memory" | "redis";
|
|
16
20
|
/**
|
|
17
21
|
* JSON-serializable value type
|
|
18
22
|
*/
|
|
19
23
|
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
20
|
-
export
|
|
24
|
+
export type JsonObject = {
|
|
21
25
|
[key: string]: JsonValue;
|
|
22
|
-
}
|
|
23
|
-
export
|
|
24
|
-
}
|
|
26
|
+
};
|
|
27
|
+
export type JsonArray = JsonValue[];
|
|
25
28
|
/**
|
|
26
29
|
* Type-safe error handling
|
|
27
30
|
*/
|
|
28
|
-
export
|
|
31
|
+
export type ErrorInfo = {
|
|
29
32
|
message: string;
|
|
30
33
|
code?: string | number;
|
|
31
34
|
stack?: string;
|
|
32
35
|
cause?: unknown;
|
|
33
|
-
}
|
|
36
|
+
};
|
|
34
37
|
/**
|
|
35
38
|
* Generic success/error result type
|
|
36
39
|
*/
|
|
37
|
-
export
|
|
40
|
+
export type Result<T = unknown, E = ErrorInfo> = {
|
|
38
41
|
success: boolean;
|
|
39
42
|
data?: T;
|
|
40
43
|
error?: E;
|
|
41
|
-
}
|
|
44
|
+
};
|
|
42
45
|
/**
|
|
43
46
|
* Function parameter type for dynamic functions
|
|
44
47
|
*/
|
|
45
|
-
export
|
|
48
|
+
export type FunctionParameters = {
|
|
46
49
|
[key: string]: unknown;
|
|
47
|
-
}
|
|
50
|
+
};
|
|
48
51
|
/**
|
|
49
52
|
* Generic async function type
|
|
50
53
|
*/
|
|
@@ -73,54 +76,20 @@ export declare function getErrorMessage(error: unknown): string;
|
|
|
73
76
|
* Safe error conversion
|
|
74
77
|
*/
|
|
75
78
|
export declare function toErrorInfo(error: unknown): ErrorInfo;
|
|
76
|
-
/**
|
|
77
|
-
* NeuroLink Native Event System Types
|
|
78
|
-
*/
|
|
79
|
-
/**
|
|
80
|
-
* Tool execution event for real-time streaming
|
|
81
|
-
*/
|
|
82
|
-
export interface ToolExecutionEvent {
|
|
83
|
-
type: "tool:start" | "tool:end";
|
|
84
|
-
tool: string;
|
|
85
|
-
input?: unknown;
|
|
86
|
-
result?: unknown;
|
|
87
|
-
error?: string;
|
|
88
|
-
timestamp: number;
|
|
89
|
-
duration?: number;
|
|
90
|
-
executionId: string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Tool execution summary for completed executions
|
|
94
|
-
*/
|
|
95
|
-
export interface ToolExecutionSummary {
|
|
96
|
-
tool: string;
|
|
97
|
-
startTime: number;
|
|
98
|
-
endTime: number;
|
|
99
|
-
duration: number;
|
|
100
|
-
success: boolean;
|
|
101
|
-
result?: unknown;
|
|
102
|
-
error?: string;
|
|
103
|
-
executionId: string;
|
|
104
|
-
metadata?: {
|
|
105
|
-
serverId?: string;
|
|
106
|
-
toolCategory?: "direct" | "custom" | "mcp";
|
|
107
|
-
isExternal?: boolean;
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
79
|
/**
|
|
111
80
|
* Stream event types for real-time communication
|
|
112
81
|
*/
|
|
113
|
-
export
|
|
82
|
+
export type StreamEvent = {
|
|
114
83
|
type: "stream:chunk" | "stream:complete" | "stream:error";
|
|
115
84
|
content?: string;
|
|
116
85
|
metadata?: JsonObject;
|
|
117
86
|
timestamp: number;
|
|
118
|
-
}
|
|
87
|
+
};
|
|
119
88
|
/**
|
|
120
89
|
* Enhanced NeuroLink event types
|
|
121
|
-
* Flexible
|
|
90
|
+
* Flexible type to support both typed and legacy event patterns
|
|
122
91
|
*/
|
|
123
|
-
export
|
|
92
|
+
export type NeuroLinkEvents = {
|
|
124
93
|
"tool:start": unknown;
|
|
125
94
|
"tool:end": unknown;
|
|
126
95
|
"stream:start": unknown;
|
|
@@ -146,7 +115,7 @@ export interface NeuroLinkEvents {
|
|
|
146
115
|
error: unknown;
|
|
147
116
|
log: unknown;
|
|
148
117
|
[key: string]: unknown;
|
|
149
|
-
}
|
|
118
|
+
};
|
|
150
119
|
/**
|
|
151
120
|
* TypeScript utility for typed EventEmitter
|
|
152
121
|
* Flexible interface to support both typed and legacy event patterns
|
|
@@ -159,15 +128,3 @@ export interface TypedEventEmitter<TEvents extends Record<string, unknown>> {
|
|
|
159
128
|
listenerCount<K extends keyof TEvents>(event: K): number;
|
|
160
129
|
listeners<K extends keyof TEvents>(event: K): Array<(...args: unknown[]) => void>;
|
|
161
130
|
}
|
|
162
|
-
/**
|
|
163
|
-
* Tool execution context for tracking
|
|
164
|
-
*/
|
|
165
|
-
export interface ToolExecutionContext {
|
|
166
|
-
executionId: string;
|
|
167
|
-
tool: string;
|
|
168
|
-
startTime: number;
|
|
169
|
-
endTime?: number;
|
|
170
|
-
result?: unknown;
|
|
171
|
-
error?: string;
|
|
172
|
-
metadata?: JsonObject;
|
|
173
|
-
}
|
package/dist/types/content.d.ts
CHANGED
|
@@ -59,46 +59,57 @@ export type Content = TextContent | ImageContent | CSVContent | PDFContent;
|
|
|
59
59
|
/**
|
|
60
60
|
* Vision capability information for providers
|
|
61
61
|
*/
|
|
62
|
-
export
|
|
62
|
+
export type VisionCapability = {
|
|
63
63
|
provider: string;
|
|
64
64
|
supportedModels: string[];
|
|
65
65
|
maxImageSize?: number;
|
|
66
66
|
supportedFormats: string[];
|
|
67
67
|
maxImagesPerRequest?: number;
|
|
68
|
-
}
|
|
68
|
+
};
|
|
69
69
|
/**
|
|
70
70
|
* Provider-specific image format requirements
|
|
71
71
|
*/
|
|
72
|
-
export
|
|
72
|
+
export type ProviderImageFormat = {
|
|
73
73
|
provider: string;
|
|
74
74
|
format: "data_uri" | "base64" | "inline_data" | "source";
|
|
75
75
|
requiresPrefix?: boolean;
|
|
76
76
|
mimeTypeField?: string;
|
|
77
77
|
dataField?: string;
|
|
78
|
-
}
|
|
78
|
+
};
|
|
79
79
|
/**
|
|
80
80
|
* Image processing result
|
|
81
81
|
*/
|
|
82
|
-
export
|
|
82
|
+
export type ProcessedImage = {
|
|
83
83
|
data: string;
|
|
84
84
|
mediaType: string;
|
|
85
85
|
size: number;
|
|
86
86
|
format: "data_uri" | "base64" | "inline_data" | "source";
|
|
87
|
-
}
|
|
87
|
+
};
|
|
88
88
|
/**
|
|
89
89
|
* Multimodal message structure for provider adapters
|
|
90
90
|
*/
|
|
91
|
-
export
|
|
91
|
+
export type MultimodalMessage = {
|
|
92
92
|
role: "user" | "assistant" | "system";
|
|
93
93
|
content: Content[];
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Multimodal input type for options that may contain images or content arrays
|
|
97
|
+
*/
|
|
98
|
+
export type MultimodalInput = {
|
|
99
|
+
text: string;
|
|
100
|
+
images?: Array<Buffer | string>;
|
|
101
|
+
content?: Array<TextContent | ImageContent>;
|
|
102
|
+
csvFiles?: Array<Buffer | string>;
|
|
103
|
+
pdfFiles?: Array<Buffer | string>;
|
|
104
|
+
files?: Array<Buffer | string>;
|
|
105
|
+
};
|
|
95
106
|
/**
|
|
96
107
|
* Provider-specific multimodal payload
|
|
97
108
|
*/
|
|
98
|
-
export
|
|
109
|
+
export type ProviderMultimodalPayload = {
|
|
99
110
|
provider: string;
|
|
100
111
|
model: string;
|
|
101
112
|
messages?: MultimodalMessage[];
|
|
102
113
|
contents?: unknown[];
|
|
103
114
|
[key: string]: unknown;
|
|
104
|
-
}
|
|
115
|
+
};
|