@juspay/neurolink 7.51.1 → 7.51.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/core/baseProvider.js +5 -1
- 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/baseProvider.js +5 -1
- 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
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
import type { JsonObject } from "./common.js";
|
|
6
6
|
import type { ExecutionContext } from "../types/tools.js";
|
|
7
7
|
/**
|
|
8
|
-
* Base context
|
|
8
|
+
* Base context type for all AI operations
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export type BaseContext = {
|
|
11
11
|
userId?: string;
|
|
12
12
|
sessionId?: string;
|
|
13
13
|
requestId?: string;
|
|
@@ -23,7 +23,7 @@ export interface BaseContext {
|
|
|
23
23
|
departmentId?: string;
|
|
24
24
|
projectId?: string;
|
|
25
25
|
[key: string]: unknown;
|
|
26
|
-
}
|
|
26
|
+
};
|
|
27
27
|
/**
|
|
28
28
|
* Context integration mode types
|
|
29
29
|
*/
|
|
@@ -31,18 +31,18 @@ type ContextIntegrationMode = "prompt_prefix" | "prompt_suffix" | "system_prompt
|
|
|
31
31
|
/**
|
|
32
32
|
* Context configuration for AI generation
|
|
33
33
|
*/
|
|
34
|
-
export
|
|
34
|
+
export type ContextConfig = {
|
|
35
35
|
mode: ContextIntegrationMode;
|
|
36
36
|
includeInPrompt?: boolean;
|
|
37
37
|
includeInAnalytics?: boolean;
|
|
38
38
|
includeInEvaluation?: boolean;
|
|
39
39
|
template?: string;
|
|
40
40
|
maxLength?: number;
|
|
41
|
-
}
|
|
41
|
+
};
|
|
42
42
|
/**
|
|
43
43
|
* Context processing result
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
type ProcessedContext = {
|
|
46
46
|
originalContext: BaseContext;
|
|
47
47
|
processedContext: string | null;
|
|
48
48
|
config: ContextConfig;
|
|
@@ -52,17 +52,17 @@ interface ProcessedContext {
|
|
|
52
52
|
template: string;
|
|
53
53
|
mode: ContextIntegrationMode;
|
|
54
54
|
};
|
|
55
|
-
}
|
|
55
|
+
};
|
|
56
56
|
/**
|
|
57
57
|
* Configuration for framework fields exclusion
|
|
58
58
|
* Can be customized per application or environment
|
|
59
59
|
*/
|
|
60
|
-
export
|
|
60
|
+
export type FrameworkFieldsConfig = {
|
|
61
61
|
defaultFields: string[];
|
|
62
62
|
additionalFields?: string[];
|
|
63
63
|
overrideFields?: string[];
|
|
64
64
|
includeFields?: string[];
|
|
65
|
-
}
|
|
65
|
+
};
|
|
66
66
|
/**
|
|
67
67
|
* Factory for context processing
|
|
68
68
|
*/
|
|
@@ -150,11 +150,11 @@ export declare class ContextFactory {
|
|
|
150
150
|
* Context conversion utilities for domain-specific data
|
|
151
151
|
* Replaces hardcoded business context with generic domain context
|
|
152
152
|
*/
|
|
153
|
-
|
|
153
|
+
type ContextConversionOptions = {
|
|
154
154
|
preserveLegacyFields?: boolean;
|
|
155
155
|
validateDomainData?: boolean;
|
|
156
156
|
includeMetadata?: boolean;
|
|
157
|
-
}
|
|
157
|
+
};
|
|
158
158
|
export declare class ContextConverter {
|
|
159
159
|
/**
|
|
160
160
|
* Convert legacy business context to generic domain context
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import type { MemoryConfig } from "mem0ai/oss";
|
|
6
6
|
/**
|
|
7
|
-
* Mem0 configuration
|
|
7
|
+
* Mem0 configuration type matching mem0ai/oss MemoryConfig structure
|
|
8
8
|
*/
|
|
9
9
|
/**
|
|
10
10
|
* Configuration for conversation memory feature
|
|
11
11
|
*/
|
|
12
|
-
export
|
|
12
|
+
export type ConversationMemoryConfig = {
|
|
13
13
|
/** Enable conversation memory feature */
|
|
14
14
|
enabled: boolean;
|
|
15
15
|
/** Maximum number of sessions to keep in memory (default: 50) */
|
|
@@ -30,12 +30,12 @@ export interface ConversationMemoryConfig {
|
|
|
30
30
|
mem0Enabled?: boolean;
|
|
31
31
|
/** Configuration for mem0 integration */
|
|
32
32
|
mem0Config?: MemoryConfig;
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
34
|
/**
|
|
35
35
|
* Complete memory for a conversation session
|
|
36
36
|
* ULTRA-OPTIMIZED: Direct ChatMessage[] storage - zero conversion overhead
|
|
37
37
|
*/
|
|
38
|
-
export
|
|
38
|
+
export type SessionMemory = {
|
|
39
39
|
/** Unique session identifier */
|
|
40
40
|
sessionId: string;
|
|
41
41
|
/** User identifier (optional) */
|
|
@@ -57,20 +57,20 @@ export interface SessionMemory {
|
|
|
57
57
|
/** Custom data specific to the organization */
|
|
58
58
|
customData?: Record<string, unknown>;
|
|
59
59
|
};
|
|
60
|
-
}
|
|
60
|
+
};
|
|
61
61
|
/**
|
|
62
62
|
* Statistics about conversation memory usage (simplified for pure in-memory storage)
|
|
63
63
|
*/
|
|
64
|
-
export
|
|
64
|
+
export type ConversationMemoryStats = {
|
|
65
65
|
/** Total number of active sessions */
|
|
66
66
|
totalSessions: number;
|
|
67
67
|
/** Total number of conversation turns across all sessions */
|
|
68
68
|
totalTurns: number;
|
|
69
|
-
}
|
|
69
|
+
};
|
|
70
70
|
/**
|
|
71
71
|
* Chat message format for conversation history
|
|
72
72
|
*/
|
|
73
|
-
export
|
|
73
|
+
export type ChatMessage = {
|
|
74
74
|
/** Role/type of the message */
|
|
75
75
|
role: "user" | "assistant" | "system" | "tool_call" | "tool_result";
|
|
76
76
|
/** Content of the message */
|
|
@@ -91,30 +91,30 @@ export interface ChatMessage {
|
|
|
91
91
|
type?: string;
|
|
92
92
|
error?: string;
|
|
93
93
|
};
|
|
94
|
-
}
|
|
94
|
+
};
|
|
95
95
|
/**
|
|
96
96
|
* Content format for multimodal messages (used internally)
|
|
97
97
|
*/
|
|
98
|
-
export
|
|
98
|
+
export type MessageContent = {
|
|
99
99
|
type: string;
|
|
100
100
|
text?: string;
|
|
101
101
|
image?: string;
|
|
102
102
|
mimeType?: string;
|
|
103
103
|
[key: string]: unknown;
|
|
104
|
-
}
|
|
104
|
+
};
|
|
105
105
|
/**
|
|
106
106
|
* Extended chat message for multimodal support (internal use)
|
|
107
107
|
*/
|
|
108
|
-
export
|
|
108
|
+
export type MultimodalChatMessage = {
|
|
109
109
|
/** Role of the message sender */
|
|
110
110
|
role: "user" | "assistant" | "system";
|
|
111
111
|
/** Content of the message - can be text or multimodal content array */
|
|
112
112
|
content: string | MessageContent[];
|
|
113
|
-
}
|
|
113
|
+
};
|
|
114
114
|
/**
|
|
115
115
|
* Events emitted by conversation memory system
|
|
116
116
|
*/
|
|
117
|
-
export
|
|
117
|
+
export type ConversationMemoryEvents = {
|
|
118
118
|
/** Emitted when a new session is created */
|
|
119
119
|
"session:created": {
|
|
120
120
|
sessionId: string;
|
|
@@ -139,7 +139,7 @@ export interface ConversationMemoryEvents {
|
|
|
139
139
|
turnsIncluded: number;
|
|
140
140
|
timestamp: number;
|
|
141
141
|
};
|
|
142
|
-
}
|
|
142
|
+
};
|
|
143
143
|
/**
|
|
144
144
|
* Error types specific to conversation memory
|
|
145
145
|
*/
|
|
@@ -152,14 +152,14 @@ export declare class ConversationMemoryError extends Error {
|
|
|
152
152
|
* NeuroLink initialization options
|
|
153
153
|
* Configuration for creating NeuroLink instances with conversation memory
|
|
154
154
|
*/
|
|
155
|
-
export
|
|
155
|
+
export type NeurolinkOptions = {
|
|
156
156
|
/** Conversation memory configuration */
|
|
157
157
|
conversationMemory?: ConversationMemoryConfig;
|
|
158
158
|
/** Session identifier for conversation context */
|
|
159
159
|
sessionId?: string;
|
|
160
160
|
/** Observability configuration */
|
|
161
161
|
observability?: import("./observability.js").ObservabilityConfig;
|
|
162
|
-
}
|
|
162
|
+
};
|
|
163
163
|
/**
|
|
164
164
|
* Session identifier for Redis storage operations
|
|
165
165
|
*/
|
|
@@ -171,17 +171,17 @@ export type SessionIdentifier = {
|
|
|
171
171
|
* Lightweight session metadata for efficient session listing
|
|
172
172
|
* Contains only essential information without heavy message arrays
|
|
173
173
|
*/
|
|
174
|
-
export
|
|
174
|
+
export type SessionMetadata = {
|
|
175
175
|
id: string;
|
|
176
176
|
title: string;
|
|
177
177
|
createdAt: string;
|
|
178
178
|
updatedAt: string;
|
|
179
|
-
}
|
|
179
|
+
};
|
|
180
180
|
/**
|
|
181
181
|
* Base conversation metadata (shared fields across all conversation types)
|
|
182
182
|
* Contains essential conversation information without heavy data arrays
|
|
183
183
|
*/
|
|
184
|
-
export
|
|
184
|
+
export type ConversationBase = {
|
|
185
185
|
/** Unique conversation identifier (UUID v4) */
|
|
186
186
|
id: string;
|
|
187
187
|
/** Auto-generated conversation title */
|
|
@@ -194,20 +194,20 @@ export interface ConversationBase {
|
|
|
194
194
|
createdAt: string;
|
|
195
195
|
/** When this conversation was last updated */
|
|
196
196
|
updatedAt: string;
|
|
197
|
-
}
|
|
197
|
+
};
|
|
198
198
|
/**
|
|
199
199
|
* Redis conversation storage object format
|
|
200
200
|
* Contains conversation metadata and full message history
|
|
201
201
|
*/
|
|
202
|
-
export
|
|
202
|
+
export type RedisConversationObject = ConversationBase & {
|
|
203
203
|
/** Array of conversation messages */
|
|
204
204
|
messages: ChatMessage[];
|
|
205
|
-
}
|
|
205
|
+
};
|
|
206
206
|
/**
|
|
207
207
|
* Full conversation data for session restoration and manipulation
|
|
208
208
|
* Extends Redis storage object with additional loop mode metadata
|
|
209
209
|
*/
|
|
210
|
-
export
|
|
210
|
+
export type ConversationData = RedisConversationObject & {
|
|
211
211
|
/** Optional metadata for session variables and other loop mode data */
|
|
212
212
|
metadata?: {
|
|
213
213
|
/** Session variables set during loop mode */
|
|
@@ -217,12 +217,12 @@ export interface ConversationData extends RedisConversationObject {
|
|
|
217
217
|
/** Additional metadata can be added here */
|
|
218
218
|
[key: string]: unknown;
|
|
219
219
|
};
|
|
220
|
-
}
|
|
220
|
+
};
|
|
221
221
|
/**
|
|
222
222
|
* Conversation summary for listing and selection
|
|
223
223
|
* Contains conversation preview information without heavy message arrays
|
|
224
224
|
*/
|
|
225
|
-
export
|
|
225
|
+
export type ConversationSummary = ConversationBase & {
|
|
226
226
|
/** First message preview (for conversation preview) */
|
|
227
227
|
firstMessage: {
|
|
228
228
|
content: string;
|
|
@@ -237,7 +237,7 @@ export interface ConversationSummary extends ConversationBase {
|
|
|
237
237
|
messageCount: number;
|
|
238
238
|
/** Human-readable time since last update (e.g., "2 hours ago") */
|
|
239
239
|
duration: string;
|
|
240
|
-
}
|
|
240
|
+
};
|
|
241
241
|
/**
|
|
242
242
|
* Redis storage configuration
|
|
243
243
|
*/
|
|
@@ -8,9 +8,9 @@ import type { JsonObject } from "./common.js";
|
|
|
8
8
|
*/
|
|
9
9
|
export type DomainType = "healthcare" | "finance" | "analytics" | "ecommerce" | "education" | "legal" | "technology" | "generic";
|
|
10
10
|
/**
|
|
11
|
-
* Domain evaluation criteria
|
|
11
|
+
* Domain evaluation criteria type
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export type DomainEvaluationCriteria = {
|
|
14
14
|
accuracyWeight: number;
|
|
15
15
|
completenessWeight: number;
|
|
16
16
|
relevanceWeight: number;
|
|
@@ -18,11 +18,11 @@ export interface DomainEvaluationCriteria {
|
|
|
18
18
|
domainSpecificRules: string[];
|
|
19
19
|
failurePatterns: string[];
|
|
20
20
|
successPatterns: string[];
|
|
21
|
-
}
|
|
21
|
+
};
|
|
22
22
|
/**
|
|
23
|
-
* Domain configuration
|
|
23
|
+
* Domain configuration type
|
|
24
24
|
*/
|
|
25
|
-
export
|
|
25
|
+
export type DomainConfig = {
|
|
26
26
|
domainType: DomainType;
|
|
27
27
|
domainName: string;
|
|
28
28
|
description: string;
|
|
@@ -33,30 +33,30 @@ export interface DomainConfig {
|
|
|
33
33
|
createdAt: number;
|
|
34
34
|
updatedAt: number;
|
|
35
35
|
};
|
|
36
|
-
}
|
|
36
|
+
};
|
|
37
37
|
/**
|
|
38
38
|
* Domain template for factory registration
|
|
39
39
|
*/
|
|
40
|
-
export
|
|
40
|
+
export type DomainTemplate = {
|
|
41
41
|
domainType: DomainType;
|
|
42
42
|
template: Partial<DomainConfig>;
|
|
43
43
|
isDefault?: boolean;
|
|
44
|
-
}
|
|
44
|
+
};
|
|
45
45
|
/**
|
|
46
46
|
* Domain validation rule
|
|
47
47
|
*/
|
|
48
|
-
export
|
|
48
|
+
export type DomainValidationRule = {
|
|
49
49
|
ruleName: string;
|
|
50
50
|
ruleType: "required" | "pattern" | "range" | "custom";
|
|
51
51
|
validation: (value: unknown) => boolean;
|
|
52
52
|
errorMessage: string;
|
|
53
|
-
}
|
|
53
|
+
};
|
|
54
54
|
/**
|
|
55
55
|
* Domain configuration options for factory
|
|
56
56
|
*/
|
|
57
|
-
export
|
|
57
|
+
export type DomainConfigOptions = {
|
|
58
58
|
domainType: DomainType;
|
|
59
59
|
customConfig?: Partial<DomainConfig>;
|
|
60
60
|
validateDomainData?: boolean;
|
|
61
61
|
includeDefaults?: boolean;
|
|
62
|
-
}
|
|
62
|
+
};
|
|
@@ -6,19 +6,19 @@ import type { ToolExecution } from "./tools.js";
|
|
|
6
6
|
* Represents the analysis of the user's query intent.
|
|
7
7
|
* This provides a basic understanding of what the user is trying to achieve.
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export type QueryIntentAnalysis = {
|
|
10
10
|
/** The type of query, e.g., asking a question or giving a command. */
|
|
11
11
|
type: "question" | "command" | "greeting" | "unknown";
|
|
12
12
|
/** The estimated complexity of the query. */
|
|
13
13
|
complexity: "low" | "medium" | "high";
|
|
14
14
|
/** Whether the query likely required the use of tools to be answered correctly. */
|
|
15
15
|
shouldHaveUsedTools: boolean;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
/**
|
|
18
18
|
* Represents a single turn in an enhanced conversation history,
|
|
19
19
|
* including tool executions and evaluations for richer context.
|
|
20
20
|
*/
|
|
21
|
-
export
|
|
21
|
+
export type EnhancedConversationTurn = {
|
|
22
22
|
/** The role of the speaker, either 'user' or 'assistant'. */
|
|
23
23
|
role: "user" | "assistant";
|
|
24
24
|
/** The content of the message. */
|
|
@@ -29,12 +29,12 @@ export interface EnhancedConversationTurn {
|
|
|
29
29
|
toolExecutions?: ToolExecution[];
|
|
30
30
|
/** The evaluation result for this turn, if applicable. */
|
|
31
31
|
evaluation?: EvaluationResult;
|
|
32
|
-
}
|
|
32
|
+
};
|
|
33
33
|
/**
|
|
34
34
|
* Contains all the rich context needed for a thorough, RAGAS-style evaluation.
|
|
35
35
|
* This object is constructed by the `ContextBuilder` and used by the `RAGASEvaluator`.
|
|
36
36
|
*/
|
|
37
|
-
export
|
|
37
|
+
export type EnhancedEvaluationContext = {
|
|
38
38
|
/** The original user query. */
|
|
39
39
|
userQuery: string;
|
|
40
40
|
/** An analysis of the user's query intent. */
|
|
@@ -63,11 +63,11 @@ export interface EnhancedEvaluationContext {
|
|
|
63
63
|
previousEvaluations?: EvaluationResult[];
|
|
64
64
|
/** The current attempt number for this evaluation (1-based). */
|
|
65
65
|
attemptNumber: number;
|
|
66
|
-
}
|
|
66
|
+
};
|
|
67
67
|
/**
|
|
68
68
|
* Represents the result of a single evaluation attempt, based on RAGAS principles.
|
|
69
69
|
*/
|
|
70
|
-
export
|
|
70
|
+
export type EvaluationResult = {
|
|
71
71
|
/** The final, overall score for the response, typically from 1 to 10. */
|
|
72
72
|
finalScore: number;
|
|
73
73
|
/** How well the response addresses the user's query. */
|
|
@@ -90,11 +90,11 @@ export interface EvaluationResult {
|
|
|
90
90
|
evaluationTime: number;
|
|
91
91
|
/** The attempt number for this evaluation. */
|
|
92
92
|
attemptNumber: number;
|
|
93
|
-
}
|
|
93
|
+
};
|
|
94
94
|
/**
|
|
95
95
|
* Provides detailed information when a response fails quality assurance checks.
|
|
96
96
|
*/
|
|
97
|
-
export
|
|
97
|
+
export type QualityErrorDetails = {
|
|
98
98
|
/** The history of all evaluation attempts for this response. */
|
|
99
99
|
evaluationHistory: EvaluationResult[];
|
|
100
100
|
/** The final score of the last attempt. */
|
|
@@ -103,11 +103,11 @@ export interface QualityErrorDetails {
|
|
|
103
103
|
attempts: number;
|
|
104
104
|
/** A summary message of the failure. */
|
|
105
105
|
message: string;
|
|
106
|
-
}
|
|
106
|
+
};
|
|
107
107
|
/**
|
|
108
108
|
* Configuration for the main `Evaluator` class.
|
|
109
109
|
*/
|
|
110
|
-
export
|
|
110
|
+
export type EvaluationConfig = {
|
|
111
111
|
/** The minimum score (1-10) for a response to be considered passing. */
|
|
112
112
|
threshold?: number;
|
|
113
113
|
/** The evaluation strategy to use. Currently only 'ragas' is supported. */
|
|
@@ -129,7 +129,7 @@ export interface EvaluationConfig {
|
|
|
129
129
|
highSeverityThreshold?: number;
|
|
130
130
|
/** An optional function to generate custom evaluation prompts. */
|
|
131
131
|
promptGenerator?: GetPromptFunction;
|
|
132
|
-
}
|
|
132
|
+
};
|
|
133
133
|
/**
|
|
134
134
|
* A function that generates the main body of an evaluation prompt.
|
|
135
135
|
*/
|
|
@@ -14,7 +14,7 @@ export type MCPTransportType = "stdio" | "sse" | "websocket";
|
|
|
14
14
|
/**
|
|
15
15
|
* External MCP server configuration for process spawning
|
|
16
16
|
*/
|
|
17
|
-
export
|
|
17
|
+
export type ExternalMCPServerConfig = {
|
|
18
18
|
/** Unique identifier for the server */
|
|
19
19
|
id: string;
|
|
20
20
|
/** Command to execute (e.g., 'npx', 'node', 'python') */
|
|
@@ -39,11 +39,11 @@ export interface ExternalMCPServerConfig {
|
|
|
39
39
|
url?: string;
|
|
40
40
|
/** Additional metadata */
|
|
41
41
|
metadata?: Record<string, JsonValue>;
|
|
42
|
-
}
|
|
42
|
+
};
|
|
43
43
|
/**
|
|
44
44
|
* Runtime state of an external MCP server instance
|
|
45
45
|
*/
|
|
46
|
-
export
|
|
46
|
+
export type ExternalMCPServerInstance = {
|
|
47
47
|
/** Server configuration */
|
|
48
48
|
config: ExternalMCPServerConfig;
|
|
49
49
|
/** Child process (for stdio transport) */
|
|
@@ -87,7 +87,7 @@ export interface ExternalMCPServerInstance {
|
|
|
87
87
|
averageResponseTime: number;
|
|
88
88
|
lastResponseTime: number;
|
|
89
89
|
};
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
91
|
/**
|
|
92
92
|
* External MCP server status states
|
|
93
93
|
*/
|
|
@@ -95,7 +95,7 @@ export type ExternalMCPServerStatus = "initializing" | "connecting" | "connected
|
|
|
95
95
|
/**
|
|
96
96
|
* Tool information from external MCP server
|
|
97
97
|
*/
|
|
98
|
-
export
|
|
98
|
+
export type ExternalMCPToolInfo = {
|
|
99
99
|
/** Tool name */
|
|
100
100
|
name: string;
|
|
101
101
|
/** Tool description */
|
|
@@ -118,11 +118,11 @@ export interface ExternalMCPToolInfo {
|
|
|
118
118
|
averageExecutionTime: number;
|
|
119
119
|
lastExecutionTime: number;
|
|
120
120
|
};
|
|
121
|
-
}
|
|
121
|
+
};
|
|
122
122
|
/**
|
|
123
123
|
* External MCP server health status
|
|
124
124
|
*/
|
|
125
|
-
export
|
|
125
|
+
export type ExternalMCPServerHealth = {
|
|
126
126
|
/** Server ID */
|
|
127
127
|
serverId: string;
|
|
128
128
|
/** Whether the server is healthy */
|
|
@@ -144,11 +144,11 @@ export interface ExternalMCPServerHealth {
|
|
|
144
144
|
cpuUsage?: number;
|
|
145
145
|
averageResponseTime: number;
|
|
146
146
|
};
|
|
147
|
-
}
|
|
147
|
+
};
|
|
148
148
|
/**
|
|
149
149
|
* External MCP server configuration validation result
|
|
150
150
|
*/
|
|
151
|
-
export
|
|
151
|
+
export type ExternalMCPConfigValidation = {
|
|
152
152
|
/** Whether the configuration is valid */
|
|
153
153
|
isValid: boolean;
|
|
154
154
|
/** Validation errors */
|
|
@@ -157,11 +157,11 @@ export interface ExternalMCPConfigValidation {
|
|
|
157
157
|
warnings: string[];
|
|
158
158
|
/** Suggestions for improvement */
|
|
159
159
|
suggestions: string[];
|
|
160
|
-
}
|
|
160
|
+
};
|
|
161
161
|
/**
|
|
162
162
|
* External MCP server operation result
|
|
163
163
|
*/
|
|
164
|
-
export
|
|
164
|
+
export type ExternalMCPOperationResult<T = unknown> = {
|
|
165
165
|
/** Whether the operation was successful */
|
|
166
166
|
success: boolean;
|
|
167
167
|
/** Result data if successful */
|
|
@@ -178,11 +178,11 @@ export interface ExternalMCPOperationResult<T = unknown> {
|
|
|
178
178
|
operation: string;
|
|
179
179
|
[key: string]: JsonValue;
|
|
180
180
|
};
|
|
181
|
-
}
|
|
181
|
+
};
|
|
182
182
|
/**
|
|
183
183
|
* External MCP tool execution context
|
|
184
184
|
*/
|
|
185
|
-
export
|
|
185
|
+
export type ExternalMCPToolContext = {
|
|
186
186
|
/** Execution session ID */
|
|
187
187
|
sessionId: string;
|
|
188
188
|
/** User ID if available */
|
|
@@ -195,11 +195,11 @@ export interface ExternalMCPToolContext {
|
|
|
195
195
|
timeout?: number;
|
|
196
196
|
/** Additional context data */
|
|
197
197
|
metadata?: Record<string, JsonValue>;
|
|
198
|
-
}
|
|
198
|
+
};
|
|
199
199
|
/**
|
|
200
200
|
* External MCP tool execution result
|
|
201
201
|
*/
|
|
202
|
-
export
|
|
202
|
+
export type ExternalMCPToolResult = {
|
|
203
203
|
/** Whether the execution was successful */
|
|
204
204
|
success: boolean;
|
|
205
205
|
/** Result data if successful */
|
|
@@ -215,11 +215,11 @@ export interface ExternalMCPToolResult {
|
|
|
215
215
|
timestamp: number;
|
|
216
216
|
[key: string]: JsonValue;
|
|
217
217
|
};
|
|
218
|
-
}
|
|
218
|
+
};
|
|
219
219
|
/**
|
|
220
220
|
* External MCP server events
|
|
221
221
|
*/
|
|
222
|
-
export
|
|
222
|
+
export type ExternalMCPServerEvents = {
|
|
223
223
|
/** Server status changed */
|
|
224
224
|
statusChanged: {
|
|
225
225
|
serverId: string;
|
|
@@ -264,11 +264,11 @@ export interface ExternalMCPServerEvents {
|
|
|
264
264
|
health: ExternalMCPServerHealth;
|
|
265
265
|
timestamp: Date;
|
|
266
266
|
};
|
|
267
|
-
}
|
|
267
|
+
};
|
|
268
268
|
/**
|
|
269
269
|
* External MCP manager configuration
|
|
270
270
|
*/
|
|
271
|
-
export
|
|
271
|
+
export type ExternalMCPManagerConfig = {
|
|
272
272
|
/** Maximum number of concurrent servers */
|
|
273
273
|
maxServers?: number;
|
|
274
274
|
/** Default timeout for operations */
|
|
@@ -285,4 +285,4 @@ export interface ExternalMCPManagerConfig {
|
|
|
285
285
|
enablePerformanceMonitoring?: boolean;
|
|
286
286
|
/** Log level for external MCP operations */
|
|
287
287
|
logLevel?: "debug" | "info" | "warn" | "error";
|
|
288
|
-
}
|
|
288
|
+
};
|
|
@@ -2,7 +2,7 @@ import type { LanguageModelV1 } from "ai";
|
|
|
2
2
|
/**
|
|
3
3
|
* Result from precall evaluation of user input
|
|
4
4
|
*/
|
|
5
|
-
export
|
|
5
|
+
export type PrecallEvaluationResult = {
|
|
6
6
|
overall: "safe" | "unsafe" | "suspicious" | "inappropriate";
|
|
7
7
|
safetyScore: number;
|
|
8
8
|
appropriatenessScore: number;
|
|
@@ -14,25 +14,25 @@ export interface PrecallEvaluationResult {
|
|
|
14
14
|
}[];
|
|
15
15
|
suggestedAction: "allow" | "block" | "sanitize" | "warn";
|
|
16
16
|
reasoning?: string;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
export type IssueCategory = "explicit_content" | "hate_speech" | "violence" | "personal_info" | "spam" | "other";
|
|
19
19
|
export type IssueSeverity = "low" | "medium" | "high" | "critical";
|
|
20
20
|
export type EvaluationAction = "allow" | "block" | "sanitize" | "warn";
|
|
21
21
|
export type SafetyStatus = "safe" | "unsafe" | "suspicious" | "inappropriate";
|
|
22
|
-
export
|
|
22
|
+
export type EvaluationActions = {
|
|
23
23
|
onUnsafe?: "block" | "sanitize" | "warn" | "log";
|
|
24
24
|
onInappropriate?: "block" | "sanitize" | "warn" | "log";
|
|
25
25
|
onSuspicious?: "warn" | "log" | "allow";
|
|
26
|
-
}
|
|
27
|
-
export
|
|
26
|
+
};
|
|
27
|
+
export type EvaluationThresholds = {
|
|
28
28
|
safetyScore?: number;
|
|
29
29
|
appropriatenessScore?: number;
|
|
30
30
|
confidenceLevel?: number;
|
|
31
|
-
}
|
|
31
|
+
};
|
|
32
32
|
/**
|
|
33
33
|
* Configuration for precall evaluation using AI models
|
|
34
34
|
*/
|
|
35
|
-
export
|
|
35
|
+
export type PrecallEvaluationConfig = {
|
|
36
36
|
enabled?: boolean;
|
|
37
37
|
provider?: string;
|
|
38
38
|
evaluationModel?: string;
|
|
@@ -63,8 +63,8 @@ export interface PrecallEvaluationConfig {
|
|
|
63
63
|
* - '[FILTERED]'
|
|
64
64
|
*/
|
|
65
65
|
replacementText?: string;
|
|
66
|
-
}
|
|
67
|
-
export
|
|
66
|
+
};
|
|
67
|
+
export type BadWordsConfig = {
|
|
68
68
|
enabled?: boolean;
|
|
69
69
|
list?: string[];
|
|
70
70
|
regexPatterns?: string[];
|
|
@@ -79,25 +79,25 @@ export interface BadWordsConfig {
|
|
|
79
79
|
* - '[FILTERED]'
|
|
80
80
|
*/
|
|
81
81
|
replacementText?: string;
|
|
82
|
-
}
|
|
83
|
-
export
|
|
82
|
+
};
|
|
83
|
+
export type ModelFilterConfig = {
|
|
84
84
|
enabled?: boolean;
|
|
85
85
|
filterModel?: LanguageModelV1;
|
|
86
|
-
}
|
|
86
|
+
};
|
|
87
87
|
/**
|
|
88
88
|
* Configuration for the Guardrails middleware
|
|
89
89
|
*/
|
|
90
|
-
export
|
|
90
|
+
export type GuardrailsMiddlewareConfig = {
|
|
91
91
|
badWords?: BadWordsConfig;
|
|
92
92
|
modelFilter?: ModelFilterConfig;
|
|
93
93
|
precallEvaluation?: PrecallEvaluationConfig;
|
|
94
|
-
}
|
|
95
|
-
export
|
|
94
|
+
};
|
|
95
|
+
export type EvaluationActionResult = {
|
|
96
96
|
shouldBlock: boolean;
|
|
97
97
|
sanitizedInput?: string;
|
|
98
|
-
}
|
|
99
|
-
export
|
|
98
|
+
};
|
|
99
|
+
export type EvaluationIssue = {
|
|
100
100
|
category: IssueCategory;
|
|
101
101
|
severity: IssueSeverity;
|
|
102
102
|
description: string;
|
|
103
|
-
}
|
|
103
|
+
};
|