@juspay/neurolink 7.48.0 → 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 +15 -0
- package/README.md +177 -784
- 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/providers/sagemaker/adaptive-semaphore.d.ts +1 -13
- package/dist/lib/providers/sagemaker/client.d.ts +1 -1
- package/dist/lib/providers/sagemaker/config.d.ts +1 -1
- package/dist/lib/providers/sagemaker/detection.d.ts +1 -1
- package/dist/lib/providers/sagemaker/errors.d.ts +1 -1
- package/dist/lib/providers/sagemaker/index.d.ts +1 -1
- package/dist/lib/providers/sagemaker/language-model.d.ts +1 -1
- package/dist/lib/providers/sagemaker/parsers.d.ts +1 -1
- package/dist/lib/providers/sagemaker/streaming.d.ts +1 -1
- package/dist/lib/providers/sagemaker/structured-parser.d.ts +1 -1
- 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/providers.d.ts +469 -0
- 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/providers/sagemaker/adaptive-semaphore.d.ts +1 -13
- package/dist/providers/sagemaker/client.d.ts +1 -1
- package/dist/providers/sagemaker/config.d.ts +1 -1
- package/dist/providers/sagemaker/detection.d.ts +1 -1
- package/dist/providers/sagemaker/errors.d.ts +1 -1
- package/dist/providers/sagemaker/index.d.ts +1 -1
- package/dist/providers/sagemaker/language-model.d.ts +3 -3
- package/dist/providers/sagemaker/parsers.d.ts +1 -1
- package/dist/providers/sagemaker/streaming.d.ts +1 -1
- package/dist/providers/sagemaker/structured-parser.d.ts +1 -1
- 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/providers.d.ts +469 -0
- 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/lib/providers/sagemaker/types.d.ts +0 -456
- package/dist/lib/providers/sagemaker/types.js +0 -7
- package/dist/mcp/contracts/mcpContract.d.ts +0 -106
- package/dist/mcp/contracts/mcpContract.js +0 -5
- package/dist/providers/sagemaker/types.d.ts +0 -456
- package/dist/providers/sagemaker/types.js +0 -7
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Enables various integrations to register tools directly
|
|
4
4
|
*/
|
|
5
5
|
import type { JsonValue, JsonObject } from "./common.js";
|
|
6
|
+
import type { ExecutionContext, ToolInfo } from "./tools.js";
|
|
6
7
|
/**
|
|
7
8
|
* In-memory MCP server configuration
|
|
8
9
|
*/
|
|
@@ -15,15 +16,19 @@ export type MCPTransportType = "stdio" | "sse" | "websocket" | "ws" | "tcp" | "u
|
|
|
15
16
|
*/
|
|
16
17
|
export type MCPServerConnectionStatus = "initializing" | "connecting" | "connected" | "disconnected" | "failed" | "restarting" | "stopping" | "stopped";
|
|
17
18
|
/**
|
|
18
|
-
* MCP Server Category Types -
|
|
19
|
+
* MCP Server Category Types - Deployment and server type classification
|
|
19
20
|
*/
|
|
20
21
|
export type MCPServerCategory = "external" | "in-memory" | "built-in" | "user-defined" | "custom" | "uncategorized";
|
|
22
|
+
/**
|
|
23
|
+
* MCP Server Domain Categories - Functional domain classification
|
|
24
|
+
*/
|
|
25
|
+
export type MCPServerDomainCategory = "aiProviders" | "frameworks" | "development" | "business" | "content" | "data" | "integrations" | "automation" | "analysis" | "custom";
|
|
21
26
|
/**
|
|
22
27
|
* Universal MCP Server - Unified configuration and runtime state
|
|
23
28
|
* MCP 2024-11-05 specification compliant
|
|
24
29
|
* Replaces both MCPServerInfo and MCPServerConfig
|
|
25
30
|
*/
|
|
26
|
-
export
|
|
31
|
+
export type MCPServerInfo = {
|
|
27
32
|
id: string;
|
|
28
33
|
name: string;
|
|
29
34
|
description: string;
|
|
@@ -56,11 +61,11 @@ export interface MCPServerInfo {
|
|
|
56
61
|
tags?: string[];
|
|
57
62
|
[key: string]: unknown;
|
|
58
63
|
};
|
|
59
|
-
}
|
|
64
|
+
};
|
|
60
65
|
/**
|
|
61
66
|
* MCP Server Status for CLI Operations - High Reusability
|
|
62
67
|
*/
|
|
63
|
-
export
|
|
68
|
+
export type MCPServerStatus = {
|
|
64
69
|
/** Whether MCP is initialized */
|
|
65
70
|
mcpInitialized: boolean;
|
|
66
71
|
/** Total number of servers */
|
|
@@ -85,11 +90,11 @@ export interface MCPServerStatus {
|
|
|
85
90
|
availableTools: MCPToolInfo[];
|
|
86
91
|
/** Server registry entries */
|
|
87
92
|
serverRegistry?: Record<string, MCPServerInfo>;
|
|
88
|
-
}
|
|
93
|
+
};
|
|
89
94
|
/**
|
|
90
95
|
* Auto-discovered MCP Server - High Reusability
|
|
91
96
|
*/
|
|
92
|
-
export
|
|
97
|
+
export type MCPDiscoveredServer = {
|
|
93
98
|
name: string;
|
|
94
99
|
status: MCPServerConnectionStatus;
|
|
95
100
|
source: string;
|
|
@@ -99,11 +104,11 @@ export interface MCPDiscoveredServer {
|
|
|
99
104
|
args?: string[];
|
|
100
105
|
env?: Record<string, string>;
|
|
101
106
|
metadata?: MCPServerMetadata;
|
|
102
|
-
}
|
|
107
|
+
};
|
|
103
108
|
/**
|
|
104
109
|
* Connected MCP Server - High Reusability
|
|
105
110
|
*/
|
|
106
|
-
export
|
|
111
|
+
export type MCPConnectedServer = {
|
|
107
112
|
name: string;
|
|
108
113
|
transport: MCPTransportType;
|
|
109
114
|
connected: boolean;
|
|
@@ -112,11 +117,11 @@ export interface MCPConnectedServer {
|
|
|
112
117
|
lastSeen?: Date;
|
|
113
118
|
connectionTime?: Date;
|
|
114
119
|
metadata?: MCPServerMetadata;
|
|
115
|
-
}
|
|
120
|
+
};
|
|
116
121
|
/**
|
|
117
122
|
* MCP Tool Information - High Reusability
|
|
118
123
|
*/
|
|
119
|
-
export
|
|
124
|
+
export type MCPToolInfo = {
|
|
120
125
|
name: string;
|
|
121
126
|
description: string;
|
|
122
127
|
serverId: string;
|
|
@@ -125,7 +130,7 @@ export interface MCPToolInfo {
|
|
|
125
130
|
inputSchema?: JsonObject;
|
|
126
131
|
outputSchema?: JsonObject;
|
|
127
132
|
metadata?: MCPToolMetadata;
|
|
128
|
-
}
|
|
133
|
+
};
|
|
129
134
|
/**
|
|
130
135
|
* MCP Executable Tool - Tool with execution capability
|
|
131
136
|
* Extracted from MCPServerInfo.tools array for better readability
|
|
@@ -159,9 +164,81 @@ export type MCPToolMetadata = {
|
|
|
159
164
|
*/
|
|
160
165
|
export type MCPServerRegistryEntry = [string, MCPServerInfo];
|
|
161
166
|
/**
|
|
162
|
-
*
|
|
167
|
+
* Call record for circuit breaker statistics tracking
|
|
168
|
+
* Extracted from mcpCircuitBreaker.ts for centralized type management
|
|
169
|
+
*/
|
|
170
|
+
export type CallRecord = {
|
|
171
|
+
timestamp: number;
|
|
172
|
+
success: boolean;
|
|
173
|
+
duration: number;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Tool execution context - Rich context passed to every tool execution
|
|
177
|
+
* Extracted from factory.ts for centralized type management
|
|
178
|
+
* Following standard patterns for rich tool context
|
|
179
|
+
*/
|
|
180
|
+
export type NeuroLinkExecutionContext = {
|
|
181
|
+
sessionId?: string;
|
|
182
|
+
userId?: string;
|
|
183
|
+
aiProvider?: string;
|
|
184
|
+
modelId?: string;
|
|
185
|
+
temperature?: number;
|
|
186
|
+
maxTokens?: number;
|
|
187
|
+
appId?: string;
|
|
188
|
+
clientId?: string;
|
|
189
|
+
clientVersion?: string;
|
|
190
|
+
organizationId?: string;
|
|
191
|
+
projectId?: string;
|
|
192
|
+
environment?: string;
|
|
193
|
+
environmentType?: "development" | "staging" | "production";
|
|
194
|
+
platform?: string;
|
|
195
|
+
device?: string;
|
|
196
|
+
browser?: string;
|
|
197
|
+
userAgent?: string;
|
|
198
|
+
frameworkType?: "react" | "vue" | "svelte" | "next" | "nuxt" | "sveltekit";
|
|
199
|
+
toolChain?: string[];
|
|
200
|
+
parentToolId?: string;
|
|
201
|
+
locale?: string;
|
|
202
|
+
timezone?: string;
|
|
203
|
+
ipAddress?: string;
|
|
204
|
+
requestId?: string;
|
|
205
|
+
timestamp?: number;
|
|
206
|
+
permissions?: string[];
|
|
207
|
+
features?: string[];
|
|
208
|
+
enableDemoMode?: boolean;
|
|
209
|
+
securityLevel?: "public" | "private" | "organization";
|
|
210
|
+
metadata?: Record<string, unknown>;
|
|
211
|
+
[key: string]: unknown;
|
|
212
|
+
};
|
|
213
|
+
/**
|
|
214
|
+
* Tool execution result - Standardized result format
|
|
215
|
+
*/
|
|
216
|
+
export type ToolResult = {
|
|
217
|
+
success: boolean;
|
|
218
|
+
data?: unknown;
|
|
219
|
+
error?: string | Error;
|
|
220
|
+
usage?: {
|
|
221
|
+
tokens?: number;
|
|
222
|
+
cost?: number;
|
|
223
|
+
provider?: string;
|
|
224
|
+
model?: string;
|
|
225
|
+
executionTime?: number;
|
|
226
|
+
};
|
|
227
|
+
metadata?: {
|
|
228
|
+
toolName?: string;
|
|
229
|
+
serverId?: string;
|
|
230
|
+
serverTitle?: string;
|
|
231
|
+
sessionId?: string;
|
|
232
|
+
timestamp?: number;
|
|
233
|
+
executionTime?: number;
|
|
234
|
+
executionId?: string;
|
|
235
|
+
[key: string]: unknown;
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Unified MCP Registry type
|
|
163
240
|
*/
|
|
164
|
-
export
|
|
241
|
+
export type UnifiedMCPRegistry = {
|
|
165
242
|
/**
|
|
166
243
|
* Register an in-memory server
|
|
167
244
|
*/
|
|
@@ -178,4 +255,320 @@ export interface UnifiedMCPRegistry {
|
|
|
178
255
|
* Check if connected to a server
|
|
179
256
|
*/
|
|
180
257
|
isConnected(serverId: string): boolean;
|
|
181
|
-
}
|
|
258
|
+
};
|
|
259
|
+
import type { StandardRecord } from "./typeAliases.js";
|
|
260
|
+
/**
|
|
261
|
+
* NeuroLink MCP Tool Type - Standardized tool definition for MCP integration
|
|
262
|
+
* Moved from src/lib/mcp/factory.ts
|
|
263
|
+
*/
|
|
264
|
+
export type NeuroLinkMCPTool = {
|
|
265
|
+
/** Unique tool identifier for MCP registration and execution */
|
|
266
|
+
name: string;
|
|
267
|
+
/** Human-readable description of tool functionality */
|
|
268
|
+
description: string;
|
|
269
|
+
/** Optional category for tool organization and discovery */
|
|
270
|
+
category?: string;
|
|
271
|
+
/** Optional input schema for parameter validation (Zod or JSON Schema) */
|
|
272
|
+
inputSchema?: unknown;
|
|
273
|
+
/** Optional output schema for result validation */
|
|
274
|
+
outputSchema?: unknown;
|
|
275
|
+
/** Implementation status flag for development tracking */
|
|
276
|
+
isImplemented?: boolean;
|
|
277
|
+
/** Required permissions for tool execution in secured environments */
|
|
278
|
+
permissions?: string[];
|
|
279
|
+
/** Tool version for compatibility and update management */
|
|
280
|
+
version?: string;
|
|
281
|
+
/** Additional metadata for tool information and capabilities */
|
|
282
|
+
metadata?: Record<string, unknown>;
|
|
283
|
+
/**
|
|
284
|
+
* Tool execution function with standardized signature
|
|
285
|
+
*/
|
|
286
|
+
execute: (params: unknown, context: NeuroLinkExecutionContext) => Promise<ToolResult>;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* NeuroLink MCP Server Type - Standard compatible
|
|
290
|
+
* Moved from src/lib/mcp/factory.ts
|
|
291
|
+
*/
|
|
292
|
+
export type NeuroLinkMCPServer = {
|
|
293
|
+
id: string;
|
|
294
|
+
title: string;
|
|
295
|
+
description?: string;
|
|
296
|
+
version?: string;
|
|
297
|
+
category?: MCPServerDomainCategory;
|
|
298
|
+
visibility?: "public" | "private" | "organization";
|
|
299
|
+
tools: Record<string, NeuroLinkMCPTool>;
|
|
300
|
+
registerTool(tool: NeuroLinkMCPTool): NeuroLinkMCPServer;
|
|
301
|
+
metadata?: Record<string, unknown>;
|
|
302
|
+
dependencies?: string[];
|
|
303
|
+
capabilities?: string[];
|
|
304
|
+
};
|
|
305
|
+
/**
|
|
306
|
+
* MCP Server Configuration for creation
|
|
307
|
+
* Moved from src/lib/mcp/factory.ts
|
|
308
|
+
*/
|
|
309
|
+
export type MCPServerConfig = {
|
|
310
|
+
id: string;
|
|
311
|
+
title: string;
|
|
312
|
+
description?: string;
|
|
313
|
+
version?: string;
|
|
314
|
+
category?: MCPServerDomainCategory;
|
|
315
|
+
visibility?: "public" | "private" | "organization";
|
|
316
|
+
metadata?: Record<string, unknown>;
|
|
317
|
+
dependencies?: string[];
|
|
318
|
+
capabilities?: string[];
|
|
319
|
+
};
|
|
320
|
+
/**
|
|
321
|
+
* Discovered MCP server/plugin definition
|
|
322
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
323
|
+
*/
|
|
324
|
+
export type DiscoveredMcp<TTools = StandardRecord> = {
|
|
325
|
+
metadata: McpMetadata;
|
|
326
|
+
tools?: TTools;
|
|
327
|
+
capabilities?: string[];
|
|
328
|
+
version?: string;
|
|
329
|
+
configuration?: Record<string, string | number | boolean>;
|
|
330
|
+
[key: string]: unknown;
|
|
331
|
+
};
|
|
332
|
+
/**
|
|
333
|
+
* MCP server metadata
|
|
334
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
335
|
+
*/
|
|
336
|
+
export type McpMetadata = {
|
|
337
|
+
name: string;
|
|
338
|
+
description?: string;
|
|
339
|
+
version?: string;
|
|
340
|
+
author?: string;
|
|
341
|
+
homepage?: string;
|
|
342
|
+
repository?: string;
|
|
343
|
+
category?: string;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* Provider status information
|
|
347
|
+
* Moved from src/lib/mcp/contracts/mcpContract.ts
|
|
348
|
+
*/
|
|
349
|
+
export type ProviderStatus = {
|
|
350
|
+
available: boolean;
|
|
351
|
+
lastCheck: number;
|
|
352
|
+
reason?: string;
|
|
353
|
+
model?: string;
|
|
354
|
+
cost?: number;
|
|
355
|
+
latencyMs?: number;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Tool discovery result
|
|
359
|
+
* Moved from src/lib/mcp/toolDiscoveryService.ts
|
|
360
|
+
*/
|
|
361
|
+
export type ToolDiscoveryResult = {
|
|
362
|
+
/** Whether discovery was successful */
|
|
363
|
+
success: boolean;
|
|
364
|
+
/** Number of tools discovered */
|
|
365
|
+
toolCount: number;
|
|
366
|
+
/** Discovered tools */
|
|
367
|
+
tools: import("./externalMcp.js").ExternalMCPToolInfo[];
|
|
368
|
+
/** Error message if failed */
|
|
369
|
+
error?: string;
|
|
370
|
+
/** Discovery duration in milliseconds */
|
|
371
|
+
duration: number;
|
|
372
|
+
/** Server ID */
|
|
373
|
+
serverId: string;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* External MCP tool execution options
|
|
377
|
+
* Moved from src/lib/mcp/toolDiscoveryService.ts
|
|
378
|
+
*/
|
|
379
|
+
export type ExternalToolExecutionOptions = {
|
|
380
|
+
/** Execution timeout in milliseconds */
|
|
381
|
+
timeout?: number;
|
|
382
|
+
/** Additional context for execution */
|
|
383
|
+
context?: Partial<import("./externalMcp.js").ExternalMCPToolContext>;
|
|
384
|
+
/** Whether to validate input parameters */
|
|
385
|
+
validateInput?: boolean;
|
|
386
|
+
/** Whether to validate output */
|
|
387
|
+
validateOutput?: boolean;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Tool validation result
|
|
391
|
+
* Moved from src/lib/mcp/toolDiscoveryService.ts
|
|
392
|
+
*/
|
|
393
|
+
export type ToolValidationResult = {
|
|
394
|
+
/** Whether the tool is valid */
|
|
395
|
+
isValid: boolean;
|
|
396
|
+
/** Validation errors */
|
|
397
|
+
errors: string[];
|
|
398
|
+
/** Validation warnings */
|
|
399
|
+
warnings: string[];
|
|
400
|
+
/** Tool metadata */
|
|
401
|
+
metadata?: {
|
|
402
|
+
category?: string;
|
|
403
|
+
complexity?: "simple" | "moderate" | "complex";
|
|
404
|
+
requiresAuth?: boolean;
|
|
405
|
+
isDeprecated?: boolean;
|
|
406
|
+
};
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* Tool registry events
|
|
410
|
+
* Moved from src/lib/mcp/toolDiscoveryService.ts
|
|
411
|
+
*/
|
|
412
|
+
export type ToolRegistryEvents = {
|
|
413
|
+
toolRegistered: {
|
|
414
|
+
serverId: string;
|
|
415
|
+
toolName: string;
|
|
416
|
+
toolInfo: import("./externalMcp.js").ExternalMCPToolInfo;
|
|
417
|
+
timestamp: Date;
|
|
418
|
+
};
|
|
419
|
+
toolUnregistered: {
|
|
420
|
+
serverId: string;
|
|
421
|
+
toolName: string;
|
|
422
|
+
timestamp: Date;
|
|
423
|
+
};
|
|
424
|
+
toolExecuted: {
|
|
425
|
+
serverId: string;
|
|
426
|
+
toolName: string;
|
|
427
|
+
success: boolean;
|
|
428
|
+
duration: number;
|
|
429
|
+
timestamp: Date;
|
|
430
|
+
};
|
|
431
|
+
discoveryStarted: {
|
|
432
|
+
serverId: string;
|
|
433
|
+
timestamp: Date;
|
|
434
|
+
};
|
|
435
|
+
discoveryCompleted: {
|
|
436
|
+
serverId: string;
|
|
437
|
+
toolCount: number;
|
|
438
|
+
duration: number;
|
|
439
|
+
timestamp: Date;
|
|
440
|
+
};
|
|
441
|
+
discoveryFailed: {
|
|
442
|
+
serverId: string;
|
|
443
|
+
error: string;
|
|
444
|
+
timestamp: Date;
|
|
445
|
+
};
|
|
446
|
+
};
|
|
447
|
+
/**
|
|
448
|
+
* Circuit breaker states
|
|
449
|
+
* Moved from src/lib/mcp/mcpCircuitBreaker.ts
|
|
450
|
+
*/
|
|
451
|
+
export type CircuitBreakerState = "closed" | "open" | "half-open";
|
|
452
|
+
/**
|
|
453
|
+
* Circuit breaker configuration
|
|
454
|
+
* Moved from src/lib/mcp/mcpCircuitBreaker.ts
|
|
455
|
+
*/
|
|
456
|
+
export type CircuitBreakerConfig = {
|
|
457
|
+
/** Number of failures before opening the circuit */
|
|
458
|
+
failureThreshold: number;
|
|
459
|
+
/** Time to wait before attempting reset (milliseconds) */
|
|
460
|
+
resetTimeout: number;
|
|
461
|
+
/** Maximum calls allowed in half-open state */
|
|
462
|
+
halfOpenMaxCalls: number;
|
|
463
|
+
/** Timeout for individual operations (milliseconds) */
|
|
464
|
+
operationTimeout: number;
|
|
465
|
+
/** Minimum number of calls before calculating failure rate */
|
|
466
|
+
minimumCallsBeforeCalculation: number;
|
|
467
|
+
/** Window size for calculating failure rate (milliseconds) */
|
|
468
|
+
statisticsWindowSize: number;
|
|
469
|
+
};
|
|
470
|
+
/**
|
|
471
|
+
* Circuit breaker statistics
|
|
472
|
+
* Moved from src/lib/mcp/mcpCircuitBreaker.ts
|
|
473
|
+
*/
|
|
474
|
+
export type CircuitBreakerStats = {
|
|
475
|
+
/** Current state */
|
|
476
|
+
state: CircuitBreakerState;
|
|
477
|
+
/** Total number of calls */
|
|
478
|
+
totalCalls: number;
|
|
479
|
+
/** Number of successful calls */
|
|
480
|
+
successfulCalls: number;
|
|
481
|
+
/** Number of failed calls */
|
|
482
|
+
failedCalls: number;
|
|
483
|
+
/** Current failure rate (0-1) */
|
|
484
|
+
failureRate: number;
|
|
485
|
+
/** Calls in current time window */
|
|
486
|
+
windowCalls: number;
|
|
487
|
+
/** Last state change timestamp */
|
|
488
|
+
lastStateChange: Date;
|
|
489
|
+
/** Next retry time (for open state) */
|
|
490
|
+
nextRetryTime?: Date;
|
|
491
|
+
/** Half-open call count */
|
|
492
|
+
halfOpenCalls: number;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Circuit breaker events
|
|
496
|
+
* Moved from src/lib/mcp/mcpCircuitBreaker.ts
|
|
497
|
+
*/
|
|
498
|
+
export type CircuitBreakerEvents = {
|
|
499
|
+
stateChange: {
|
|
500
|
+
oldState: CircuitBreakerState;
|
|
501
|
+
newState: CircuitBreakerState;
|
|
502
|
+
reason: string;
|
|
503
|
+
timestamp: Date;
|
|
504
|
+
};
|
|
505
|
+
callSuccess: {
|
|
506
|
+
duration: number;
|
|
507
|
+
timestamp: Date;
|
|
508
|
+
};
|
|
509
|
+
callFailure: {
|
|
510
|
+
error: string;
|
|
511
|
+
duration: number;
|
|
512
|
+
timestamp: Date;
|
|
513
|
+
};
|
|
514
|
+
circuitOpen: {
|
|
515
|
+
failureRate: number;
|
|
516
|
+
totalCalls: number;
|
|
517
|
+
timestamp: Date;
|
|
518
|
+
};
|
|
519
|
+
circuitHalfOpen: {
|
|
520
|
+
timestamp: Date;
|
|
521
|
+
};
|
|
522
|
+
circuitClosed: {
|
|
523
|
+
timestamp: Date;
|
|
524
|
+
};
|
|
525
|
+
};
|
|
526
|
+
/**
|
|
527
|
+
* MCP Registry type with optional methods for maximum flexibility
|
|
528
|
+
* Moved from src/lib/mcp/registry.ts
|
|
529
|
+
*/
|
|
530
|
+
export type McpRegistry = {
|
|
531
|
+
registerServer?(serverId: string, serverConfig?: unknown, context?: ExecutionContext): Promise<void>;
|
|
532
|
+
executeTool?<T = unknown>(toolName: string, args?: unknown, context?: ExecutionContext): Promise<T>;
|
|
533
|
+
listTools?(context?: ExecutionContext): Promise<ToolInfo[]>;
|
|
534
|
+
};
|
|
535
|
+
/**
|
|
536
|
+
* MCP client creation result
|
|
537
|
+
* Moved from src/lib/mcp/mcpClientFactory.ts
|
|
538
|
+
*/
|
|
539
|
+
export type MCPClientResult = {
|
|
540
|
+
/** Whether client creation was successful */
|
|
541
|
+
success: boolean;
|
|
542
|
+
/** Created client instance */
|
|
543
|
+
client?: import("@modelcontextprotocol/sdk/client/index.js").Client;
|
|
544
|
+
/** Created transport instance */
|
|
545
|
+
transport?: import("@modelcontextprotocol/sdk/shared/transport.js").Transport;
|
|
546
|
+
/** Created process (for stdio transport) */
|
|
547
|
+
process?: import("child_process").ChildProcess;
|
|
548
|
+
/** Error message if failed */
|
|
549
|
+
error?: string;
|
|
550
|
+
/** Creation duration in milliseconds */
|
|
551
|
+
duration: number;
|
|
552
|
+
/** Server capabilities reported during handshake */
|
|
553
|
+
capabilities?: import("@modelcontextprotocol/sdk/types.js").ClientCapabilities;
|
|
554
|
+
};
|
|
555
|
+
/**
|
|
556
|
+
* Flexible validation result
|
|
557
|
+
* Moved from src/lib/mcp/flexibleToolValidator.ts
|
|
558
|
+
*/
|
|
559
|
+
export type FlexibleValidationResult = {
|
|
560
|
+
/** Whether validation passed */
|
|
561
|
+
isValid: boolean;
|
|
562
|
+
/** Validation error message (for simple cases) */
|
|
563
|
+
error?: string;
|
|
564
|
+
/** Validation warnings */
|
|
565
|
+
warnings?: string[];
|
|
566
|
+
/** Normalized parameters (if valid) */
|
|
567
|
+
normalizedParams?: Record<string, unknown>;
|
|
568
|
+
/** Validation metadata */
|
|
569
|
+
metadata?: {
|
|
570
|
+
validationTime?: number;
|
|
571
|
+
validator?: string;
|
|
572
|
+
schema?: string;
|
|
573
|
+
};
|
|
574
|
+
};
|