@juspay/neurolink 7.48.1 → 7.49.0
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 +13 -0
- package/README.md +215 -16
- package/dist/agent/directTools.d.ts +55 -0
- package/dist/agent/directTools.js +266 -0
- package/dist/cli/factories/commandFactory.d.ts +2 -0
- package/dist/cli/factories/commandFactory.js +130 -16
- package/dist/cli/index.js +0 -0
- package/dist/cli/loop/conversationSelector.d.ts +45 -0
- package/dist/cli/loop/conversationSelector.js +222 -0
- package/dist/cli/loop/optionsSchema.d.ts +1 -1
- package/dist/cli/loop/session.d.ts +36 -8
- package/dist/cli/loop/session.js +257 -61
- package/dist/core/baseProvider.js +9 -2
- package/dist/core/evaluation.js +5 -2
- package/dist/factories/providerRegistry.js +2 -2
- package/dist/lib/agent/directTools.d.ts +55 -0
- package/dist/lib/agent/directTools.js +266 -0
- package/dist/lib/core/baseProvider.js +9 -2
- package/dist/lib/core/evaluation.js +5 -2
- package/dist/lib/factories/providerRegistry.js +2 -2
- package/dist/lib/mcp/factory.d.ts +2 -157
- package/dist/lib/mcp/flexibleToolValidator.d.ts +1 -5
- package/dist/lib/mcp/index.d.ts +3 -2
- package/dist/lib/mcp/mcpCircuitBreaker.d.ts +1 -75
- package/dist/lib/mcp/mcpClientFactory.d.ts +1 -20
- package/dist/lib/mcp/mcpClientFactory.js +1 -0
- package/dist/lib/mcp/registry.d.ts +3 -10
- package/dist/lib/mcp/servers/agent/directToolsServer.d.ts +1 -1
- package/dist/lib/mcp/servers/aiProviders/aiCoreServer.d.ts +1 -1
- package/dist/lib/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/lib/mcp/toolDiscoveryService.d.ts +3 -84
- package/dist/lib/mcp/toolRegistry.d.ts +2 -24
- package/dist/lib/middleware/builtin/guardrails.d.ts +5 -16
- package/dist/lib/middleware/builtin/guardrails.js +44 -39
- package/dist/lib/middleware/utils/guardrailsUtils.d.ts +64 -0
- package/dist/lib/middleware/utils/guardrailsUtils.js +387 -0
- package/dist/lib/neurolink.d.ts +1 -1
- package/dist/lib/providers/anthropic.js +46 -3
- package/dist/lib/providers/azureOpenai.js +8 -2
- package/dist/lib/providers/googleAiStudio.js +8 -2
- package/dist/lib/providers/googleVertex.js +11 -2
- package/dist/lib/providers/huggingFace.js +1 -1
- package/dist/lib/providers/litellm.js +1 -1
- package/dist/lib/providers/mistral.js +1 -1
- package/dist/lib/providers/openAI.js +46 -3
- package/dist/lib/session/globalSessionState.d.ts +26 -0
- package/dist/lib/session/globalSessionState.js +49 -0
- package/dist/lib/types/cli.d.ts +28 -0
- package/dist/lib/types/content.d.ts +18 -5
- package/dist/lib/types/contextTypes.d.ts +1 -1
- package/dist/lib/types/conversation.d.ts +55 -4
- package/dist/lib/types/fileTypes.d.ts +65 -0
- package/dist/lib/types/fileTypes.js +4 -0
- package/dist/lib/types/generateTypes.d.ts +12 -0
- package/dist/lib/types/guardrails.d.ts +103 -0
- package/dist/lib/types/guardrails.js +1 -0
- package/dist/lib/types/index.d.ts +4 -2
- package/dist/lib/types/index.js +4 -0
- package/dist/lib/types/mcpTypes.d.ts +407 -14
- package/dist/lib/types/streamTypes.d.ts +7 -0
- package/dist/lib/types/tools.d.ts +132 -35
- package/dist/lib/utils/csvProcessor.d.ts +68 -0
- package/dist/lib/utils/csvProcessor.js +277 -0
- package/dist/lib/utils/fileDetector.d.ts +57 -0
- package/dist/lib/utils/fileDetector.js +457 -0
- package/dist/lib/utils/imageProcessor.d.ts +10 -0
- package/dist/lib/utils/imageProcessor.js +22 -0
- package/dist/lib/utils/loopUtils.d.ts +71 -0
- package/dist/lib/utils/loopUtils.js +262 -0
- package/dist/lib/utils/messageBuilder.d.ts +2 -1
- package/dist/lib/utils/messageBuilder.js +197 -2
- package/dist/lib/utils/optionsUtils.d.ts +1 -1
- package/dist/mcp/factory.d.ts +2 -157
- package/dist/mcp/flexibleToolValidator.d.ts +1 -5
- package/dist/mcp/index.d.ts +3 -2
- package/dist/mcp/mcpCircuitBreaker.d.ts +1 -75
- package/dist/mcp/mcpClientFactory.d.ts +1 -20
- package/dist/mcp/mcpClientFactory.js +1 -0
- package/dist/mcp/registry.d.ts +3 -10
- package/dist/mcp/servers/agent/directToolsServer.d.ts +1 -1
- package/dist/mcp/servers/aiProviders/aiCoreServer.d.ts +1 -1
- package/dist/mcp/servers/utilities/utilityServer.d.ts +1 -1
- package/dist/mcp/toolDiscoveryService.d.ts +3 -84
- package/dist/mcp/toolRegistry.d.ts +2 -24
- package/dist/middleware/builtin/guardrails.d.ts +5 -16
- package/dist/middleware/builtin/guardrails.js +44 -39
- package/dist/middleware/utils/guardrailsUtils.d.ts +64 -0
- package/dist/middleware/utils/guardrailsUtils.js +387 -0
- package/dist/neurolink.d.ts +1 -1
- package/dist/providers/anthropic.js +46 -3
- package/dist/providers/azureOpenai.js +8 -2
- package/dist/providers/googleAiStudio.js +8 -2
- package/dist/providers/googleVertex.js +11 -2
- package/dist/providers/huggingFace.js +1 -1
- package/dist/providers/litellm.js +1 -1
- package/dist/providers/mistral.js +1 -1
- package/dist/providers/openAI.js +46 -3
- package/dist/session/globalSessionState.d.ts +26 -0
- package/dist/session/globalSessionState.js +49 -0
- package/dist/types/cli.d.ts +28 -0
- package/dist/types/content.d.ts +18 -5
- package/dist/types/contextTypes.d.ts +1 -1
- package/dist/types/conversation.d.ts +55 -4
- package/dist/types/fileTypes.d.ts +65 -0
- package/dist/types/fileTypes.js +4 -0
- package/dist/types/generateTypes.d.ts +12 -0
- package/dist/types/guardrails.d.ts +103 -0
- package/dist/types/guardrails.js +1 -0
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.js +4 -0
- package/dist/types/mcpTypes.d.ts +407 -14
- package/dist/types/modelTypes.d.ts +6 -6
- package/dist/types/streamTypes.d.ts +7 -0
- package/dist/types/tools.d.ts +132 -35
- package/dist/utils/csvProcessor.d.ts +68 -0
- package/dist/utils/csvProcessor.js +277 -0
- package/dist/utils/fileDetector.d.ts +57 -0
- package/dist/utils/fileDetector.js +457 -0
- package/dist/utils/imageProcessor.d.ts +10 -0
- package/dist/utils/imageProcessor.js +22 -0
- package/dist/utils/loopUtils.d.ts +71 -0
- package/dist/utils/loopUtils.js +262 -0
- package/dist/utils/messageBuilder.d.ts +2 -1
- package/dist/utils/messageBuilder.js +197 -2
- package/dist/utils/optionsUtils.d.ts +1 -1
- package/package.json +9 -3
- package/dist/lib/mcp/contracts/mcpContract.d.ts +0 -106
- package/dist/lib/mcp/contracts/mcpContract.js +0 -5
- package/dist/mcp/contracts/mcpContract.d.ts +0 -106
- package/dist/mcp/contracts/mcpContract.js +0 -5
|
@@ -13,6 +13,32 @@ export declare class GlobalSessionManager {
|
|
|
13
13
|
private loopSession;
|
|
14
14
|
static getInstance(): GlobalSessionManager;
|
|
15
15
|
setLoopSession(config?: ConversationMemoryConfig): string;
|
|
16
|
+
/**
|
|
17
|
+
* Restore a loop session with an existing sessionId and NeuroLink instance
|
|
18
|
+
* Used for conversation restoration
|
|
19
|
+
*/
|
|
20
|
+
restoreLoopSession(sessionId: string, neurolinkInstance: NeuroLink, config?: ConversationMemoryConfig, sessionVariables?: Record<string, SessionVariableValue>): void;
|
|
21
|
+
/**
|
|
22
|
+
* Update session variables during restoration
|
|
23
|
+
*/
|
|
24
|
+
restoreSessionVariables(variables: Record<string, SessionVariableValue>): void;
|
|
25
|
+
/**
|
|
26
|
+
* Check if a session is currently active
|
|
27
|
+
*/
|
|
28
|
+
hasActiveSession(): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Get current session metadata for restoration purposes
|
|
31
|
+
*/
|
|
32
|
+
getSessionMetadata(): {
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
conversationMemoryConfig?: ConversationMemoryConfig;
|
|
35
|
+
sessionVariables: Record<string, SessionVariableValue>;
|
|
36
|
+
isActive: boolean;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Update the sessionId of the current session (used during restoration)
|
|
40
|
+
*/
|
|
41
|
+
updateSessionId(newSessionId: string): void;
|
|
16
42
|
getLoopSession(): LoopSessionState | null;
|
|
17
43
|
clearLoopSession(): void;
|
|
18
44
|
getOrCreateNeuroLink(): NeuroLink;
|
|
@@ -28,6 +28,55 @@ export class GlobalSessionManager {
|
|
|
28
28
|
};
|
|
29
29
|
return sessionId;
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Restore a loop session with an existing sessionId and NeuroLink instance
|
|
33
|
+
* Used for conversation restoration
|
|
34
|
+
*/
|
|
35
|
+
restoreLoopSession(sessionId, neurolinkInstance, config, sessionVariables) {
|
|
36
|
+
this.loopSession = {
|
|
37
|
+
neurolinkInstance,
|
|
38
|
+
sessionId,
|
|
39
|
+
isActive: true,
|
|
40
|
+
conversationMemoryConfig: config,
|
|
41
|
+
sessionVariables: sessionVariables || {},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Update session variables during restoration
|
|
46
|
+
*/
|
|
47
|
+
restoreSessionVariables(variables) {
|
|
48
|
+
const session = this.getLoopSession();
|
|
49
|
+
if (session) {
|
|
50
|
+
session.sessionVariables = { ...session.sessionVariables, ...variables };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Check if a session is currently active
|
|
55
|
+
*/
|
|
56
|
+
hasActiveSession() {
|
|
57
|
+
return this.loopSession?.isActive ?? false;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get current session metadata for restoration purposes
|
|
61
|
+
*/
|
|
62
|
+
getSessionMetadata() {
|
|
63
|
+
const session = this.getLoopSession();
|
|
64
|
+
return {
|
|
65
|
+
sessionId: session?.sessionId,
|
|
66
|
+
conversationMemoryConfig: session?.conversationMemoryConfig,
|
|
67
|
+
sessionVariables: session?.sessionVariables || {},
|
|
68
|
+
isActive: session?.isActive ?? false,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Update the sessionId of the current session (used during restoration)
|
|
73
|
+
*/
|
|
74
|
+
updateSessionId(newSessionId) {
|
|
75
|
+
const session = this.getLoopSession();
|
|
76
|
+
if (session) {
|
|
77
|
+
session.sessionId = newSessionId;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
31
80
|
getLoopSession() {
|
|
32
81
|
return this.loopSession?.isActive ? this.loopSession : null;
|
|
33
82
|
}
|
package/dist/lib/types/cli.d.ts
CHANGED
|
@@ -411,6 +411,34 @@ export type JSONOutput = {
|
|
|
411
411
|
export type ConsoleOverride = {
|
|
412
412
|
[method: string]: (() => void) | undefined;
|
|
413
413
|
};
|
|
414
|
+
/**
|
|
415
|
+
* Conversation choice for inquirer prompt
|
|
416
|
+
*/
|
|
417
|
+
export type ConversationChoice = {
|
|
418
|
+
name: string;
|
|
419
|
+
value: string | "NEW_CONVERSATION";
|
|
420
|
+
short: string;
|
|
421
|
+
};
|
|
422
|
+
/**
|
|
423
|
+
* Session restore result
|
|
424
|
+
*/
|
|
425
|
+
export type SessionRestoreResult = {
|
|
426
|
+
success: boolean;
|
|
427
|
+
sessionId: string;
|
|
428
|
+
messageCount: number;
|
|
429
|
+
error?: string;
|
|
430
|
+
lastActivity?: string;
|
|
431
|
+
};
|
|
432
|
+
/**
|
|
433
|
+
* Tool context for restored sessions
|
|
434
|
+
*/
|
|
435
|
+
export type RestorationToolContext = Record<string, unknown> & {
|
|
436
|
+
sessionId: string;
|
|
437
|
+
userId: string;
|
|
438
|
+
source: string;
|
|
439
|
+
restored: boolean;
|
|
440
|
+
timestamp: string;
|
|
441
|
+
};
|
|
414
442
|
/**
|
|
415
443
|
* Type guard for generate result
|
|
416
444
|
*/
|
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* Text content type for multimodal messages
|
|
7
7
|
*/
|
|
8
|
-
export
|
|
8
|
+
export type TextContent = {
|
|
9
9
|
type: "text";
|
|
10
10
|
text: string;
|
|
11
|
-
}
|
|
11
|
+
};
|
|
12
12
|
/**
|
|
13
13
|
* Image content type for multimodal messages
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export type ImageContent = {
|
|
16
16
|
type: "image";
|
|
17
17
|
data: Buffer | string;
|
|
18
18
|
mediaType?: "image/jpeg" | "image/png" | "image/gif" | "image/webp" | "image/bmp" | "image/tiff";
|
|
@@ -25,11 +25,24 @@ export interface ImageContent {
|
|
|
25
25
|
};
|
|
26
26
|
filename?: string;
|
|
27
27
|
};
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* CSV content type for multimodal messages
|
|
31
|
+
*/
|
|
32
|
+
export type CSVContent = {
|
|
33
|
+
type: "csv";
|
|
34
|
+
data: Buffer | string;
|
|
35
|
+
metadata?: {
|
|
36
|
+
filename?: string;
|
|
37
|
+
maxRows?: number;
|
|
38
|
+
formatStyle?: "raw" | "markdown" | "json";
|
|
39
|
+
description?: string;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
29
42
|
/**
|
|
30
43
|
* Union type for all content types
|
|
31
44
|
*/
|
|
32
|
-
export type Content = TextContent | ImageContent;
|
|
45
|
+
export type Content = TextContent | ImageContent | CSVContent;
|
|
33
46
|
/**
|
|
34
47
|
* Vision capability information for providers
|
|
35
48
|
*/
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Provides type-safe context integration for AI generation
|
|
4
4
|
*/
|
|
5
5
|
import type { JsonObject } from "./common.js";
|
|
6
|
+
import type { ExecutionContext } from "../types/tools.js";
|
|
6
7
|
/**
|
|
7
8
|
* Base context interface for all AI operations
|
|
8
9
|
*/
|
|
@@ -149,7 +150,6 @@ export declare class ContextFactory {
|
|
|
149
150
|
* Context conversion utilities for domain-specific data
|
|
150
151
|
* Replaces hardcoded business context with generic domain context
|
|
151
152
|
*/
|
|
152
|
-
import type { ExecutionContext } from "../mcp/contracts/mcpContract.js";
|
|
153
153
|
interface ContextConversionOptions {
|
|
154
154
|
preserveLegacyFields?: boolean;
|
|
155
155
|
validateDomainData?: boolean;
|
|
@@ -148,6 +148,16 @@ export declare class ConversationMemoryError extends Error {
|
|
|
148
148
|
details?: Record<string, unknown> | undefined;
|
|
149
149
|
constructor(message: string, code: "STORAGE_ERROR" | "CONFIG_ERROR" | "SESSION_NOT_FOUND" | "CLEANUP_ERROR", details?: Record<string, unknown> | undefined);
|
|
150
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* NeuroLink initialization options
|
|
153
|
+
* Configuration for creating NeuroLink instances with conversation memory
|
|
154
|
+
*/
|
|
155
|
+
export interface NeurolinkOptions {
|
|
156
|
+
/** Conversation memory configuration */
|
|
157
|
+
conversationMemory?: ConversationMemoryConfig;
|
|
158
|
+
/** Session identifier for conversation context */
|
|
159
|
+
sessionId?: string;
|
|
160
|
+
}
|
|
151
161
|
/**
|
|
152
162
|
* Session identifier for Redis storage operations
|
|
153
163
|
*/
|
|
@@ -166,10 +176,10 @@ export interface SessionMetadata {
|
|
|
166
176
|
updatedAt: string;
|
|
167
177
|
}
|
|
168
178
|
/**
|
|
169
|
-
*
|
|
170
|
-
* Contains conversation
|
|
179
|
+
* Base conversation metadata (shared fields across all conversation types)
|
|
180
|
+
* Contains essential conversation information without heavy data arrays
|
|
171
181
|
*/
|
|
172
|
-
export
|
|
182
|
+
export interface ConversationBase {
|
|
173
183
|
/** Unique conversation identifier (UUID v4) */
|
|
174
184
|
id: string;
|
|
175
185
|
/** Auto-generated conversation title */
|
|
@@ -182,9 +192,50 @@ export type RedisConversationObject = {
|
|
|
182
192
|
createdAt: string;
|
|
183
193
|
/** When this conversation was last updated */
|
|
184
194
|
updatedAt: string;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Redis conversation storage object format
|
|
198
|
+
* Contains conversation metadata and full message history
|
|
199
|
+
*/
|
|
200
|
+
export interface RedisConversationObject extends ConversationBase {
|
|
185
201
|
/** Array of conversation messages */
|
|
186
202
|
messages: ChatMessage[];
|
|
187
|
-
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Full conversation data for session restoration and manipulation
|
|
206
|
+
* Extends Redis storage object with additional loop mode metadata
|
|
207
|
+
*/
|
|
208
|
+
export interface ConversationData extends RedisConversationObject {
|
|
209
|
+
/** Optional metadata for session variables and other loop mode data */
|
|
210
|
+
metadata?: {
|
|
211
|
+
/** Session variables set during loop mode */
|
|
212
|
+
sessionVariables?: Record<string, string | number | boolean>;
|
|
213
|
+
/** Message count (for compatibility) */
|
|
214
|
+
messageCount?: number;
|
|
215
|
+
/** Additional metadata can be added here */
|
|
216
|
+
[key: string]: unknown;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Conversation summary for listing and selection
|
|
221
|
+
* Contains conversation preview information without heavy message arrays
|
|
222
|
+
*/
|
|
223
|
+
export interface ConversationSummary extends ConversationBase {
|
|
224
|
+
/** First message preview (for conversation preview) */
|
|
225
|
+
firstMessage: {
|
|
226
|
+
content: string;
|
|
227
|
+
timestamp: string;
|
|
228
|
+
};
|
|
229
|
+
/** Last message preview (for conversation preview) */
|
|
230
|
+
lastMessage: {
|
|
231
|
+
content: string;
|
|
232
|
+
timestamp: string;
|
|
233
|
+
};
|
|
234
|
+
/** Total number of messages in conversation */
|
|
235
|
+
messageCount: number;
|
|
236
|
+
/** Human-readable time since last update (e.g., "2 hours ago") */
|
|
237
|
+
duration: string;
|
|
238
|
+
}
|
|
188
239
|
/**
|
|
189
240
|
* Redis storage configuration
|
|
190
241
|
*/
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File detection and processing types for unified file handling
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Supported file types for multimodal input
|
|
6
|
+
*/
|
|
7
|
+
export type FileType = "csv" | "image" | "pdf" | "text" | "unknown";
|
|
8
|
+
/**
|
|
9
|
+
* File input can be Buffer or string (path/URL/data URI)
|
|
10
|
+
*/
|
|
11
|
+
export type FileInput = Buffer | string;
|
|
12
|
+
/**
|
|
13
|
+
* File source type for tracking input origin
|
|
14
|
+
*/
|
|
15
|
+
export type FileSource = "url" | "path" | "buffer" | "datauri";
|
|
16
|
+
/**
|
|
17
|
+
* File detection result with confidence scoring
|
|
18
|
+
*/
|
|
19
|
+
export type FileDetectionResult = {
|
|
20
|
+
type: FileType;
|
|
21
|
+
mimeType: string;
|
|
22
|
+
extension: string | null;
|
|
23
|
+
source: FileSource;
|
|
24
|
+
metadata: {
|
|
25
|
+
size?: number;
|
|
26
|
+
filename?: string;
|
|
27
|
+
confidence: number;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* File processing result after detection and conversion
|
|
32
|
+
*/
|
|
33
|
+
export type FileProcessingResult = {
|
|
34
|
+
type: FileType;
|
|
35
|
+
content: string | Buffer;
|
|
36
|
+
mimeType: string;
|
|
37
|
+
metadata: {
|
|
38
|
+
confidence: number;
|
|
39
|
+
size?: number;
|
|
40
|
+
filename?: string;
|
|
41
|
+
rowCount?: number;
|
|
42
|
+
columnCount?: number;
|
|
43
|
+
columnNames?: string[];
|
|
44
|
+
sampleData?: string;
|
|
45
|
+
hasEmptyColumns?: boolean;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* CSV processor options
|
|
50
|
+
*/
|
|
51
|
+
export type CSVProcessorOptions = {
|
|
52
|
+
maxRows?: number;
|
|
53
|
+
formatStyle?: "raw" | "markdown" | "json";
|
|
54
|
+
includeHeaders?: boolean;
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* File detector options
|
|
58
|
+
*/
|
|
59
|
+
export type FileDetectorOptions = {
|
|
60
|
+
maxSize?: number;
|
|
61
|
+
timeout?: number;
|
|
62
|
+
allowedTypes?: FileType[];
|
|
63
|
+
csvOptions?: CSVProcessorOptions;
|
|
64
|
+
confidenceThreshold?: number;
|
|
65
|
+
};
|
|
@@ -15,11 +15,18 @@ export type GenerateOptions = {
|
|
|
15
15
|
input: {
|
|
16
16
|
text: string;
|
|
17
17
|
images?: Array<Buffer | string>;
|
|
18
|
+
csvFiles?: Array<Buffer | string>;
|
|
19
|
+
files?: Array<Buffer | string>;
|
|
18
20
|
content?: Array<TextContent | ImageContent>;
|
|
19
21
|
};
|
|
20
22
|
output?: {
|
|
21
23
|
format?: "text" | "structured" | "json";
|
|
22
24
|
};
|
|
25
|
+
csvOptions?: {
|
|
26
|
+
maxRows?: number;
|
|
27
|
+
formatStyle?: "raw" | "markdown" | "json";
|
|
28
|
+
includeHeaders?: boolean;
|
|
29
|
+
};
|
|
23
30
|
provider?: AIProviderName | string;
|
|
24
31
|
model?: string;
|
|
25
32
|
region?: string;
|
|
@@ -168,6 +175,11 @@ export type TextGenerationOptions = {
|
|
|
168
175
|
middleware?: MiddlewareFactoryOptions;
|
|
169
176
|
expectedOutcome?: string;
|
|
170
177
|
evaluationCriteria?: string[];
|
|
178
|
+
csvOptions?: {
|
|
179
|
+
maxRows?: number;
|
|
180
|
+
formatStyle?: "raw" | "markdown" | "json";
|
|
181
|
+
includeHeaders?: boolean;
|
|
182
|
+
};
|
|
171
183
|
};
|
|
172
184
|
/**
|
|
173
185
|
* Text generation result (consolidated from core types)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { LanguageModelV1 } from "ai";
|
|
2
|
+
/**
|
|
3
|
+
* Result from precall evaluation of user input
|
|
4
|
+
*/
|
|
5
|
+
export interface PrecallEvaluationResult {
|
|
6
|
+
overall: "safe" | "unsafe" | "suspicious" | "inappropriate";
|
|
7
|
+
safetyScore: number;
|
|
8
|
+
appropriatenessScore: number;
|
|
9
|
+
confidenceLevel: number;
|
|
10
|
+
issues?: {
|
|
11
|
+
category: "explicit_content" | "hate_speech" | "violence" | "personal_info" | "spam" | "other";
|
|
12
|
+
severity: "low" | "medium" | "high" | "critical";
|
|
13
|
+
description: string;
|
|
14
|
+
}[];
|
|
15
|
+
suggestedAction: "allow" | "block" | "sanitize" | "warn";
|
|
16
|
+
reasoning?: string;
|
|
17
|
+
}
|
|
18
|
+
export type IssueCategory = "explicit_content" | "hate_speech" | "violence" | "personal_info" | "spam" | "other";
|
|
19
|
+
export type IssueSeverity = "low" | "medium" | "high" | "critical";
|
|
20
|
+
export type EvaluationAction = "allow" | "block" | "sanitize" | "warn";
|
|
21
|
+
export type SafetyStatus = "safe" | "unsafe" | "suspicious" | "inappropriate";
|
|
22
|
+
export interface EvaluationActions {
|
|
23
|
+
onUnsafe?: "block" | "sanitize" | "warn" | "log";
|
|
24
|
+
onInappropriate?: "block" | "sanitize" | "warn" | "log";
|
|
25
|
+
onSuspicious?: "warn" | "log" | "allow";
|
|
26
|
+
}
|
|
27
|
+
export interface EvaluationThresholds {
|
|
28
|
+
safetyScore?: number;
|
|
29
|
+
appropriatenessScore?: number;
|
|
30
|
+
confidenceLevel?: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Configuration for precall evaluation using AI models
|
|
34
|
+
*/
|
|
35
|
+
export interface PrecallEvaluationConfig {
|
|
36
|
+
enabled?: boolean;
|
|
37
|
+
provider?: string;
|
|
38
|
+
evaluationModel?: string;
|
|
39
|
+
evaluationPrompt?: string;
|
|
40
|
+
actions?: EvaluationActions;
|
|
41
|
+
thresholds?: EvaluationThresholds;
|
|
42
|
+
blockUnsafeRequests?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Regex patterns to use for sanitizing input when action is "sanitize".
|
|
45
|
+
* Each pattern will be applied with the 'gi' flags (global, case-insensitive).
|
|
46
|
+
* Matched content will be replaced with the value specified in `replacementText`.
|
|
47
|
+
*
|
|
48
|
+
* Example patterns:
|
|
49
|
+
* - Email: '\\b[\\w.-]+@[\\w.-]+\\.\\w+\\b'
|
|
50
|
+
* - Phone: '\\b\\d{3}[-.]?\\d{3}[-.]?\\d{4}\\b'
|
|
51
|
+
* - SSN: '\\b\\d{3}-\\d{2}-\\d{4}\\b'
|
|
52
|
+
* - Custom words: '\\b(word1|word2|word3)\\b'
|
|
53
|
+
*/
|
|
54
|
+
sanitizationPatterns?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* Text to use when replacing sanitized content.
|
|
57
|
+
* @default '[REDACTED]'
|
|
58
|
+
*
|
|
59
|
+
* Examples:
|
|
60
|
+
* - '[REDACTED]' (default)
|
|
61
|
+
* - '***PRIVATE***'
|
|
62
|
+
* - '####'
|
|
63
|
+
* - '[FILTERED]'
|
|
64
|
+
*/
|
|
65
|
+
replacementText?: string;
|
|
66
|
+
}
|
|
67
|
+
export interface BadWordsConfig {
|
|
68
|
+
enabled?: boolean;
|
|
69
|
+
list?: string[];
|
|
70
|
+
regexPatterns?: string[];
|
|
71
|
+
/**
|
|
72
|
+
* Text to use when replacing filtered content.
|
|
73
|
+
* @default '[REDACTED]'
|
|
74
|
+
*
|
|
75
|
+
* Examples:
|
|
76
|
+
* - '[REDACTED]' (default)
|
|
77
|
+
* - '***'
|
|
78
|
+
* - '####'
|
|
79
|
+
* - '[FILTERED]'
|
|
80
|
+
*/
|
|
81
|
+
replacementText?: string;
|
|
82
|
+
}
|
|
83
|
+
export interface ModelFilterConfig {
|
|
84
|
+
enabled?: boolean;
|
|
85
|
+
filterModel?: LanguageModelV1;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Configuration for the Guardrails middleware
|
|
89
|
+
*/
|
|
90
|
+
export interface GuardrailsMiddlewareConfig {
|
|
91
|
+
badWords?: BadWordsConfig;
|
|
92
|
+
modelFilter?: ModelFilterConfig;
|
|
93
|
+
precallEvaluation?: PrecallEvaluationConfig;
|
|
94
|
+
}
|
|
95
|
+
export interface EvaluationActionResult {
|
|
96
|
+
shouldBlock: boolean;
|
|
97
|
+
sanitizedInput?: string;
|
|
98
|
+
}
|
|
99
|
+
export interface EvaluationIssue {
|
|
100
|
+
category: IssueCategory;
|
|
101
|
+
severity: IssueSeverity;
|
|
102
|
+
description: string;
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -8,11 +8,11 @@ export * from "./cli.js";
|
|
|
8
8
|
export * from "./taskClassificationTypes.js";
|
|
9
9
|
export type { NeuroLinkConfig, PerformanceConfig, CacheConfig, FallbackConfig, RetryConfig, AnalyticsConfig, ToolConfig, BackupInfo, BackupMetadata, ConfigValidationResult, ConfigUpdateOptions, } from "./configTypes.js";
|
|
10
10
|
export type { Unknown, UnknownRecord, UnknownArray, JsonValue, JsonObject, JsonArray, ErrorInfo, Result, FunctionParameters, } from "./common.js";
|
|
11
|
-
export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolExecution, } from "./tools.js";
|
|
11
|
+
export type { ToolArgs, ToolContext, ToolResult, ToolDefinition, SimpleTool, AvailableTool, ToolInfo, ToolExecution, ToolExecutionResult, ValidationResult, ExecutionContext, CacheOptions, FallbackOptions, } from "./tools.js";
|
|
12
12
|
export type { AISDKModel, ProviderError, AIModelProviderConfig, } from "./providers.js";
|
|
13
13
|
export type { BaseCommandArgs, GenerateCommandArgs, MCPCommandArgs, ModelsCommandArgs, CommandResult, GenerateResult, StreamChunk, } from "./cli.js";
|
|
14
14
|
export type { TaskType, TaskClassification, ClassificationScores, ClassificationStats, ClassificationValidation, } from "./taskClassificationTypes.js";
|
|
15
|
-
export type { MCPTransportType, MCPServerConnectionStatus, MCPServerCategory, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPToolInfo, MCPExecutableTool, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, } from "./mcpTypes.js";
|
|
15
|
+
export type { MCPTransportType, MCPServerConnectionStatus, MCPServerCategory, MCPServerStatus, MCPDiscoveredServer, MCPConnectedServer, MCPToolInfo, MCPExecutableTool, MCPServerMetadata, MCPToolMetadata, MCPServerRegistryEntry, NeuroLinkMCPTool, NeuroLinkMCPServer, NeuroLinkExecutionContext, MCPServerConfig, DiscoveredMcp, McpMetadata, ProviderStatus, ToolDiscoveryResult, ExternalToolExecutionOptions, ToolValidationResult, ToolRegistryEvents, CircuitBreakerState, CircuitBreakerConfig, CircuitBreakerStats, CircuitBreakerEvents, McpRegistry, MCPClientResult, FlexibleValidationResult, } from "./mcpTypes.js";
|
|
16
16
|
export type { ExternalMCPServerInstance, ExternalMCPServerStatus, ExternalMCPToolInfo, ExternalMCPServerHealth, ExternalMCPConfigValidation, ExternalMCPOperationResult, ExternalMCPToolContext, ExternalMCPToolResult, ExternalMCPServerEvents, ExternalMCPManagerConfig, } from "./externalMcp.js";
|
|
17
17
|
export type { ModelCapability, ModelUseCase, ModelFilter, ModelResolutionContext, ModelStats, ModelPricing, } from "./providers.js";
|
|
18
18
|
export type { DomainType, DomainConfig, DomainTemplate, DomainConfigOptions, DomainEvaluationCriteria, DomainValidationRule, } from "./domainTypes.js";
|
|
@@ -26,3 +26,5 @@ export * from "./modelTypes.js";
|
|
|
26
26
|
export * from "./serviceTypes.js";
|
|
27
27
|
export * from "./evaluationProviders.js";
|
|
28
28
|
export * from "./sdkTypes.js";
|
|
29
|
+
export * from "./fileTypes.js";
|
|
30
|
+
export * from "./content.js";
|
package/dist/lib/types/index.js
CHANGED
|
@@ -25,3 +25,7 @@ export * from "./serviceTypes.js";
|
|
|
25
25
|
export * from "./evaluationProviders.js";
|
|
26
26
|
// SDK Types - Core types for external developers
|
|
27
27
|
export * from "./sdkTypes.js";
|
|
28
|
+
// File detection and processing types
|
|
29
|
+
export * from "./fileTypes.js";
|
|
30
|
+
// Content types for multimodal support
|
|
31
|
+
export * from "./content.js";
|