@juspay/neurolink 9.26.2 → 9.28.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 +12 -0
- package/README.md +59 -9
- package/dist/cli/commands/config.d.ts +4 -4
- package/dist/cli/commands/mcp.d.ts +87 -0
- package/dist/cli/commands/mcp.js +1524 -0
- package/dist/cli/loop/optionsSchema.js +4 -0
- package/dist/core/modules/ToolsManager.js +29 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +27 -1
- package/dist/lib/core/modules/ToolsManager.js +29 -2
- package/dist/lib/index.d.ts +2 -1
- package/dist/lib/index.js +27 -1
- package/dist/lib/mcp/agentExposure.d.ts +228 -0
- package/dist/lib/mcp/agentExposure.js +357 -0
- package/dist/lib/mcp/batching/index.d.ts +11 -0
- package/dist/lib/mcp/batching/index.js +11 -0
- package/dist/lib/mcp/batching/requestBatcher.d.ts +202 -0
- package/dist/lib/mcp/batching/requestBatcher.js +442 -0
- package/dist/lib/mcp/caching/index.d.ts +11 -0
- package/dist/lib/mcp/caching/index.js +11 -0
- package/dist/lib/mcp/caching/toolCache.d.ts +221 -0
- package/dist/lib/mcp/caching/toolCache.js +434 -0
- package/dist/lib/mcp/elicitation/elicitationManager.d.ts +169 -0
- package/dist/lib/mcp/elicitation/elicitationManager.js +377 -0
- package/dist/lib/mcp/elicitation/index.d.ts +11 -0
- package/dist/lib/mcp/elicitation/index.js +12 -0
- package/dist/lib/mcp/elicitation/types.d.ts +278 -0
- package/dist/lib/mcp/elicitation/types.js +11 -0
- package/dist/lib/mcp/elicitationProtocol.d.ts +228 -0
- package/dist/lib/mcp/elicitationProtocol.js +376 -0
- package/dist/lib/mcp/enhancedToolDiscovery.d.ts +205 -0
- package/dist/lib/mcp/enhancedToolDiscovery.js +482 -0
- package/dist/lib/mcp/index.d.ts +38 -1
- package/dist/lib/mcp/index.js +36 -3
- package/dist/lib/mcp/mcpRegistryClient.d.ts +332 -0
- package/dist/lib/mcp/mcpRegistryClient.js +489 -0
- package/dist/lib/mcp/mcpServerBase.d.ts +227 -0
- package/dist/lib/mcp/mcpServerBase.js +374 -0
- package/dist/lib/mcp/multiServerManager.d.ts +310 -0
- package/dist/lib/mcp/multiServerManager.js +580 -0
- package/dist/lib/mcp/routing/index.d.ts +11 -0
- package/dist/lib/mcp/routing/index.js +11 -0
- package/dist/lib/mcp/routing/toolRouter.d.ts +219 -0
- package/dist/lib/mcp/routing/toolRouter.js +417 -0
- package/dist/lib/mcp/serverCapabilities.d.ts +341 -0
- package/dist/lib/mcp/serverCapabilities.js +503 -0
- package/dist/lib/mcp/toolAnnotations.d.ts +154 -0
- package/dist/lib/mcp/toolAnnotations.js +240 -0
- package/dist/lib/mcp/toolConverter.d.ts +178 -0
- package/dist/lib/mcp/toolConverter.js +259 -0
- package/dist/lib/mcp/toolIntegration.d.ts +136 -0
- package/dist/lib/mcp/toolIntegration.js +335 -0
- package/dist/lib/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/lib/memory/hippocampusInitializer.js +1 -1
- package/dist/lib/neurolink.d.ts +275 -2
- package/dist/lib/neurolink.js +596 -56
- package/dist/lib/providers/litellm.d.ts +10 -0
- package/dist/lib/providers/litellm.js +104 -2
- package/dist/lib/types/configTypes.d.ts +56 -0
- package/dist/lib/types/conversation.d.ts +2 -2
- package/dist/lib/types/generateTypes.d.ts +4 -0
- package/dist/lib/types/index.d.ts +2 -1
- package/dist/lib/types/modelTypes.d.ts +6 -6
- package/dist/lib/types/streamTypes.d.ts +2 -0
- package/dist/lib/types/tools.d.ts +2 -0
- package/dist/lib/utils/pricing.js +177 -17
- package/dist/lib/utils/schemaConversion.d.ts +6 -1
- package/dist/lib/utils/schemaConversion.js +50 -28
- package/dist/lib/workflow/config.d.ts +16 -16
- package/dist/mcp/agentExposure.d.ts +228 -0
- package/dist/mcp/agentExposure.js +356 -0
- package/dist/mcp/batching/index.d.ts +11 -0
- package/dist/mcp/batching/index.js +10 -0
- package/dist/mcp/batching/requestBatcher.d.ts +202 -0
- package/dist/mcp/batching/requestBatcher.js +441 -0
- package/dist/mcp/caching/index.d.ts +11 -0
- package/dist/mcp/caching/index.js +10 -0
- package/dist/mcp/caching/toolCache.d.ts +221 -0
- package/dist/mcp/caching/toolCache.js +433 -0
- package/dist/mcp/elicitation/elicitationManager.d.ts +169 -0
- package/dist/mcp/elicitation/elicitationManager.js +376 -0
- package/dist/mcp/elicitation/index.d.ts +11 -0
- package/dist/mcp/elicitation/index.js +11 -0
- package/dist/mcp/elicitation/types.d.ts +278 -0
- package/dist/mcp/elicitation/types.js +10 -0
- package/dist/mcp/elicitationProtocol.d.ts +228 -0
- package/dist/mcp/elicitationProtocol.js +375 -0
- package/dist/mcp/enhancedToolDiscovery.d.ts +205 -0
- package/dist/mcp/enhancedToolDiscovery.js +481 -0
- package/dist/mcp/index.d.ts +38 -1
- package/dist/mcp/index.js +36 -3
- package/dist/mcp/mcpRegistryClient.d.ts +332 -0
- package/dist/mcp/mcpRegistryClient.js +488 -0
- package/dist/mcp/mcpServerBase.d.ts +227 -0
- package/dist/mcp/mcpServerBase.js +373 -0
- package/dist/mcp/multiServerManager.d.ts +310 -0
- package/dist/mcp/multiServerManager.js +579 -0
- package/dist/mcp/routing/index.d.ts +11 -0
- package/dist/mcp/routing/index.js +10 -0
- package/dist/mcp/routing/toolRouter.d.ts +219 -0
- package/dist/mcp/routing/toolRouter.js +416 -0
- package/dist/mcp/serverCapabilities.d.ts +341 -0
- package/dist/mcp/serverCapabilities.js +502 -0
- package/dist/mcp/toolAnnotations.d.ts +154 -0
- package/dist/mcp/toolAnnotations.js +239 -0
- package/dist/mcp/toolConverter.d.ts +178 -0
- package/dist/mcp/toolConverter.js +258 -0
- package/dist/mcp/toolIntegration.d.ts +136 -0
- package/dist/mcp/toolIntegration.js +334 -0
- package/dist/memory/hippocampusInitializer.d.ts +2 -2
- package/dist/memory/hippocampusInitializer.js +1 -1
- package/dist/neurolink.d.ts +275 -2
- package/dist/neurolink.js +596 -56
- package/dist/providers/litellm.d.ts +10 -0
- package/dist/providers/litellm.js +104 -2
- package/dist/types/configTypes.d.ts +56 -0
- package/dist/types/conversation.d.ts +2 -2
- package/dist/types/generateTypes.d.ts +4 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/streamTypes.d.ts +2 -0
- package/dist/types/tools.d.ts +2 -0
- package/dist/utils/pricing.js +177 -17
- package/dist/utils/schemaConversion.d.ts +6 -1
- package/dist/utils/schemaConversion.js +50 -28
- package/package.json +2 -2
|
@@ -82,5 +82,9 @@ export const textGenerationOptionsSchema = {
|
|
|
82
82
|
type: "boolean",
|
|
83
83
|
description: "Skip injecting tool descriptions into the system prompt. Useful when tool info is already provided.",
|
|
84
84
|
},
|
|
85
|
+
disableToolCache: {
|
|
86
|
+
type: "boolean",
|
|
87
|
+
description: "Disable tool result caching for this request (overrides global mcp.cache.enabled).",
|
|
88
|
+
},
|
|
85
89
|
};
|
|
86
90
|
//# sourceMappingURL=optionsSchema.js.map
|
|
@@ -318,6 +318,32 @@ export class ToolsManager {
|
|
|
318
318
|
const startTime = Date.now();
|
|
319
319
|
let executionId;
|
|
320
320
|
try {
|
|
321
|
+
// Route through NeuroLink.executeTool() when available for MCP enhancement support
|
|
322
|
+
// (cache, middleware, annotations, circuit breaker, routing)
|
|
323
|
+
if (this.toolExecutor) {
|
|
324
|
+
const result = await this.toolExecutor(toolName, params);
|
|
325
|
+
const convertedResult = this.utilities?.convertToolResult
|
|
326
|
+
? await this.utilities.convertToolResult(result)
|
|
327
|
+
: result;
|
|
328
|
+
const endTime = Date.now();
|
|
329
|
+
customToolSpan.setAttribute("tool.duration_ms", endTime - startTime);
|
|
330
|
+
let errorResult = undefined;
|
|
331
|
+
if (convertedResult &&
|
|
332
|
+
typeof convertedResult === "object" &&
|
|
333
|
+
"isError" in convertedResult &&
|
|
334
|
+
convertedResult.isError) {
|
|
335
|
+
try {
|
|
336
|
+
errorResult = JSON.stringify(convertedResult);
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
logger.error(`Failed to serialize error result for ${toolName}`, error);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
customToolSpan.setAttribute("tool.result.status", errorResult ? "error" : "success");
|
|
343
|
+
customToolSpan.setStatus({ code: SpanStatusCode.OK });
|
|
344
|
+
return convertedResult;
|
|
345
|
+
}
|
|
346
|
+
// Fallback: direct execution (standalone usage without NeuroLink SDK)
|
|
321
347
|
if (this.neurolink?.emitToolStart) {
|
|
322
348
|
executionId = this.neurolink.emitToolStart(toolName, params, startTime);
|
|
323
349
|
}
|
|
@@ -350,8 +376,9 @@ export class ToolsManager {
|
|
|
350
376
|
catch (error) {
|
|
351
377
|
const endTime = Date.now();
|
|
352
378
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
353
|
-
// Emit tool end event (error)
|
|
354
|
-
|
|
379
|
+
// Emit tool end event (error) — only for fallback path
|
|
380
|
+
// When toolExecutor is used, executeTool() handles event emission
|
|
381
|
+
if (!this.toolExecutor && this.neurolink?.emitToolEnd) {
|
|
355
382
|
this.neurolink.emitToolEnd(toolName, undefined, // no result
|
|
356
383
|
errorMsg, startTime, endTime, executionId);
|
|
357
384
|
logger.debug(`Custom tool error: ${toolName} (${endTime - startTime}ms)`, { error: errorMsg });
|
package/dist/index.d.ts
CHANGED
|
@@ -200,7 +200,8 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
|
|
|
200
200
|
* await writeFile('output.txt', 'Hello from MCP!');
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
|
-
export { CircuitBreakerManager, calculateExpiresAt, createMCPServer, createOAuthProviderFromConfig, DEFAULT_HTTP_RETRY_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, executeMCP, FileTokenStorage, getMCPStats, getServerInfo, globalCircuitBreakerManager, globalRateLimiterManager, HTTPRateLimiter, InMemoryTokenStorage, initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs, MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry, } from "./mcp/index.js";
|
|
203
|
+
export { CircuitBreakerManager, calculateExpiresAt, createMCPServer, createOAuthProviderFromConfig, DEFAULT_HTTP_RETRY_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, executeMCP, FileTokenStorage, getMCPStats, getServerInfo, globalCircuitBreakerManager, globalRateLimiterManager, HTTPRateLimiter, InMemoryTokenStorage, initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs, MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry, MCPToolRegistry, ExternalServerManager, MCPClientFactory, ToolRouter, createToolRouter, DEFAULT_ROUTER_CONFIG, ToolCache, createToolCache, DEFAULT_CACHE_CONFIG, ToolResultCache, createToolResultCache, RequestBatcher, ToolCallBatcher, createRequestBatcher, createToolCallBatcher, DEFAULT_BATCH_CONFIG, inferAnnotations, createAnnotatedTool, validateAnnotations, filterToolsByAnnotations, mergeAnnotations, getAnnotationSummary, requiresConfirmation, isSafeToRetry, getToolSafetyLevel, ElicitationManager, globalElicitationManager, EnhancedToolDiscovery, MCPRegistryClient, globalMCPRegistryClient, getWellKnownServer, getAllWellKnownServers, MCPServerBase, MultiServerManager, globalMultiServerManager, AgentExposureManager, exposeAgentAsTool, exposeAgentsAsTools, exposeWorkflowAsTool, exposeWorkflowsAsTools, globalAgentExposureManager, ServerCapabilitiesManager, createTextResource, createJsonResource, createPrompt, neuroLinkToolToMCP, mcpToolToNeuroLink, batchConvertToMCP, batchConvertToNeuroLink, sanitizeToolName, validateToolName, createToolFromFunction, mcpProtocolToolToServerTool, serverToolToMCPProtocol, TOOL_COMPATIBILITY, ToolIntegrationManager, globalToolIntegrationManager, wrapToolWithElicitation, wrapToolsWithElicitation, createElicitationContext, confirmationMiddleware, validationMiddleware, loggingMiddleware, createRetryMiddleware, createTimeoutMiddleware, createToolMiddlewareChain, ElicitationProtocolAdapter, globalElicitationProtocol, isElicitationProtocolMessage, protocolMessageToElicitation, elicitationResponseToProtocol, createElicitationRequest, createElicitationResponse, createElicitationCancel, createTextInputRequest, createSelectRequest, createConfirmationRequest, createFormRequest, } from "./mcp/index.js";
|
|
204
|
+
export type { RoutingStrategy, ToolRouterConfig, RoutingDecision, MCPTool, ToolRouterEvents, AffinityRule, CategoryMapping, RouterServerWeight, CacheStrategy, CacheConfig as MCPCacheConfig, CacheStats, CacheEvents, BatchConfig, BatchResult, BatchExecutor, BatcherEvents, MCPToolAnnotations, MCPServerTool, ToolConverterOptions, MCPProtocolTool, NeuroLinkTool, ToolMiddleware, EnhancedExecutionContext, ToolWrapperOptions, ExposableAgent, ExposableWorkflow, ExposureOptions, ExposureResult, MCPResource, MCPPrompt, ServerCapabilitiesConfig, PromptGenerator, PromptMessage, PromptResult, RegisteredPrompt, RegisteredResource, ResourceContent, ResourceReader, ResourceSubscriptionCallback, RegistryEntry, RegistrySearchOptions, RegistrySearchResult, RegistrySourceType, RegistryConfig, MCPRegistryClientConfig, LoadBalancingStrategy, ServerGroup, UnifiedTool, MultiServerManagerConfig, ServerWeight, MCPServerBaseConfig, MCPServerEvents, EnhancedToolInfo, ToolSearchCriteria, ToolSearchResult, CompatibilityCheckResult, ElicitationType, Elicitation, ElicitationResponse, ElicitationHandler, ElicitationManagerConfig, ElicitationRequest, ElicitationContext, TextElicitation, SelectElicitation, SelectOption, MultiSelectElicitation, ConfirmationElicitation, FileElicitation, SecretElicitation, FormElicitation, FormField, ElicitationProtocolMessage, ElicitationProtocolMessageType, ElicitationProtocolPayload, ElicitationProtocolHandler, ElicitationProtocolAdapterConfig, ElicitationRequestMessage, ElicitationRequestParams, ElicitationResponseMessage, ElicitationResponseParams, ElicitationCancelMessage, ElicitationCancelParams, } from "./mcp/index.js";
|
|
204
205
|
export type { AuthorizationUrlResult, DiscoveredMcp, HTTPRetryConfig, MCPOAuthConfig, McpMetadata, OAuthClientInformation, OAuthTokens as McpOAuthTokens, RateLimitConfig, TokenExchangeRequest, TokenStorage, } from "./types/mcpTypes.js";
|
|
205
206
|
export type { ExecutionContext, ToolExecutionResult, ToolInfo, } from "./types/tools.js";
|
|
206
207
|
export type { LogLevel } from "./types/utilities.js";
|
package/dist/index.js
CHANGED
|
@@ -237,7 +237,33 @@ InMemoryTokenStorage,
|
|
|
237
237
|
// Simplified MCP exports
|
|
238
238
|
initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs,
|
|
239
239
|
// Circuit Breaker
|
|
240
|
-
MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry,
|
|
240
|
+
MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry,
|
|
241
|
+
// Core MCP Components
|
|
242
|
+
MCPToolRegistry, ExternalServerManager, MCPClientFactory,
|
|
243
|
+
// MCP Enhancements - Routing, Caching, Batching
|
|
244
|
+
ToolRouter, createToolRouter, DEFAULT_ROUTER_CONFIG, ToolCache, createToolCache, DEFAULT_CACHE_CONFIG, ToolResultCache, createToolResultCache, RequestBatcher, ToolCallBatcher, createRequestBatcher, createToolCallBatcher, DEFAULT_BATCH_CONFIG,
|
|
245
|
+
// MCP Enhancements - Tool Annotations
|
|
246
|
+
inferAnnotations, createAnnotatedTool, validateAnnotations, filterToolsByAnnotations, mergeAnnotations, getAnnotationSummary, requiresConfirmation, isSafeToRetry, getToolSafetyLevel,
|
|
247
|
+
// MCP Enhancements - Elicitation
|
|
248
|
+
ElicitationManager, globalElicitationManager,
|
|
249
|
+
// MCP Enhancements - Enhanced Tool Discovery
|
|
250
|
+
EnhancedToolDiscovery,
|
|
251
|
+
// MCP Enhancements - Registry Client
|
|
252
|
+
MCPRegistryClient, globalMCPRegistryClient, getWellKnownServer, getAllWellKnownServers,
|
|
253
|
+
// MCP Enhancements - Server Base
|
|
254
|
+
MCPServerBase,
|
|
255
|
+
// MCP Enhancements - Multi-Server Manager
|
|
256
|
+
MultiServerManager, globalMultiServerManager,
|
|
257
|
+
// MCP Enhancements - Agent Exposure
|
|
258
|
+
AgentExposureManager, exposeAgentAsTool, exposeAgentsAsTools, exposeWorkflowAsTool, exposeWorkflowsAsTools, globalAgentExposureManager,
|
|
259
|
+
// MCP Enhancements - Server Capabilities
|
|
260
|
+
ServerCapabilitiesManager, createTextResource, createJsonResource, createPrompt,
|
|
261
|
+
// MCP Enhancements - Tool Converter
|
|
262
|
+
neuroLinkToolToMCP, mcpToolToNeuroLink, batchConvertToMCP, batchConvertToNeuroLink, sanitizeToolName, validateToolName, createToolFromFunction, mcpProtocolToolToServerTool, serverToolToMCPProtocol, TOOL_COMPATIBILITY,
|
|
263
|
+
// MCP Enhancements - Tool Integration
|
|
264
|
+
ToolIntegrationManager, globalToolIntegrationManager, wrapToolWithElicitation, wrapToolsWithElicitation, createElicitationContext, confirmationMiddleware, validationMiddleware, loggingMiddleware, createRetryMiddleware, createTimeoutMiddleware, createToolMiddlewareChain,
|
|
265
|
+
// MCP Enhancements - Elicitation Protocol
|
|
266
|
+
ElicitationProtocolAdapter, globalElicitationProtocol, isElicitationProtocolMessage, protocolMessageToElicitation, elicitationResponseToProtocol, createElicitationRequest, createElicitationResponse, createElicitationCancel, createTextInputRequest, createSelectRequest, createConfirmationRequest, createFormRequest, } from "./mcp/index.js";
|
|
241
267
|
export { logger } from "./utils/logger.js";
|
|
242
268
|
export { getPoolStats } from "./utils/redis.js";
|
|
243
269
|
// ============================================================================
|
|
@@ -318,6 +318,32 @@ export class ToolsManager {
|
|
|
318
318
|
const startTime = Date.now();
|
|
319
319
|
let executionId;
|
|
320
320
|
try {
|
|
321
|
+
// Route through NeuroLink.executeTool() when available for MCP enhancement support
|
|
322
|
+
// (cache, middleware, annotations, circuit breaker, routing)
|
|
323
|
+
if (this.toolExecutor) {
|
|
324
|
+
const result = await this.toolExecutor(toolName, params);
|
|
325
|
+
const convertedResult = this.utilities?.convertToolResult
|
|
326
|
+
? await this.utilities.convertToolResult(result)
|
|
327
|
+
: result;
|
|
328
|
+
const endTime = Date.now();
|
|
329
|
+
customToolSpan.setAttribute("tool.duration_ms", endTime - startTime);
|
|
330
|
+
let errorResult = undefined;
|
|
331
|
+
if (convertedResult &&
|
|
332
|
+
typeof convertedResult === "object" &&
|
|
333
|
+
"isError" in convertedResult &&
|
|
334
|
+
convertedResult.isError) {
|
|
335
|
+
try {
|
|
336
|
+
errorResult = JSON.stringify(convertedResult);
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
logger.error(`Failed to serialize error result for ${toolName}`, error);
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
customToolSpan.setAttribute("tool.result.status", errorResult ? "error" : "success");
|
|
343
|
+
customToolSpan.setStatus({ code: SpanStatusCode.OK });
|
|
344
|
+
return convertedResult;
|
|
345
|
+
}
|
|
346
|
+
// Fallback: direct execution (standalone usage without NeuroLink SDK)
|
|
321
347
|
if (this.neurolink?.emitToolStart) {
|
|
322
348
|
executionId = this.neurolink.emitToolStart(toolName, params, startTime);
|
|
323
349
|
}
|
|
@@ -350,8 +376,9 @@ export class ToolsManager {
|
|
|
350
376
|
catch (error) {
|
|
351
377
|
const endTime = Date.now();
|
|
352
378
|
const errorMsg = error instanceof Error ? error.message : String(error);
|
|
353
|
-
// Emit tool end event (error)
|
|
354
|
-
|
|
379
|
+
// Emit tool end event (error) — only for fallback path
|
|
380
|
+
// When toolExecutor is used, executeTool() handles event emission
|
|
381
|
+
if (!this.toolExecutor && this.neurolink?.emitToolEnd) {
|
|
355
382
|
this.neurolink.emitToolEnd(toolName, undefined, // no result
|
|
356
383
|
errorMsg, startTime, endTime, executionId);
|
|
357
384
|
logger.debug(`Custom tool error: ${toolName} (${endTime - startTime}ms)`, { error: errorMsg });
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -200,7 +200,8 @@ export declare function createBestAIProvider(requestedProvider?: string, modelNa
|
|
|
200
200
|
* await writeFile('output.txt', 'Hello from MCP!');
|
|
201
201
|
* ```
|
|
202
202
|
*/
|
|
203
|
-
export { CircuitBreakerManager, calculateExpiresAt, createMCPServer, createOAuthProviderFromConfig, DEFAULT_HTTP_RETRY_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, executeMCP, FileTokenStorage, getMCPStats, getServerInfo, globalCircuitBreakerManager, globalRateLimiterManager, HTTPRateLimiter, InMemoryTokenStorage, initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs, MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry, } from "./mcp/index.js";
|
|
203
|
+
export { CircuitBreakerManager, calculateExpiresAt, createMCPServer, createOAuthProviderFromConfig, DEFAULT_HTTP_RETRY_CONFIG, DEFAULT_RATE_LIMIT_CONFIG, executeMCP, FileTokenStorage, getMCPStats, getServerInfo, globalCircuitBreakerManager, globalRateLimiterManager, HTTPRateLimiter, InMemoryTokenStorage, initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs, MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry, MCPToolRegistry, ExternalServerManager, MCPClientFactory, ToolRouter, createToolRouter, DEFAULT_ROUTER_CONFIG, ToolCache, createToolCache, DEFAULT_CACHE_CONFIG, ToolResultCache, createToolResultCache, RequestBatcher, ToolCallBatcher, createRequestBatcher, createToolCallBatcher, DEFAULT_BATCH_CONFIG, inferAnnotations, createAnnotatedTool, validateAnnotations, filterToolsByAnnotations, mergeAnnotations, getAnnotationSummary, requiresConfirmation, isSafeToRetry, getToolSafetyLevel, ElicitationManager, globalElicitationManager, EnhancedToolDiscovery, MCPRegistryClient, globalMCPRegistryClient, getWellKnownServer, getAllWellKnownServers, MCPServerBase, MultiServerManager, globalMultiServerManager, AgentExposureManager, exposeAgentAsTool, exposeAgentsAsTools, exposeWorkflowAsTool, exposeWorkflowsAsTools, globalAgentExposureManager, ServerCapabilitiesManager, createTextResource, createJsonResource, createPrompt, neuroLinkToolToMCP, mcpToolToNeuroLink, batchConvertToMCP, batchConvertToNeuroLink, sanitizeToolName, validateToolName, createToolFromFunction, mcpProtocolToolToServerTool, serverToolToMCPProtocol, TOOL_COMPATIBILITY, ToolIntegrationManager, globalToolIntegrationManager, wrapToolWithElicitation, wrapToolsWithElicitation, createElicitationContext, confirmationMiddleware, validationMiddleware, loggingMiddleware, createRetryMiddleware, createTimeoutMiddleware, createToolMiddlewareChain, ElicitationProtocolAdapter, globalElicitationProtocol, isElicitationProtocolMessage, protocolMessageToElicitation, elicitationResponseToProtocol, createElicitationRequest, createElicitationResponse, createElicitationCancel, createTextInputRequest, createSelectRequest, createConfirmationRequest, createFormRequest, } from "./mcp/index.js";
|
|
204
|
+
export type { RoutingStrategy, ToolRouterConfig, RoutingDecision, MCPTool, ToolRouterEvents, AffinityRule, CategoryMapping, RouterServerWeight, CacheStrategy, CacheConfig as MCPCacheConfig, CacheStats, CacheEvents, BatchConfig, BatchResult, BatchExecutor, BatcherEvents, MCPToolAnnotations, MCPServerTool, ToolConverterOptions, MCPProtocolTool, NeuroLinkTool, ToolMiddleware, EnhancedExecutionContext, ToolWrapperOptions, ExposableAgent, ExposableWorkflow, ExposureOptions, ExposureResult, MCPResource, MCPPrompt, ServerCapabilitiesConfig, PromptGenerator, PromptMessage, PromptResult, RegisteredPrompt, RegisteredResource, ResourceContent, ResourceReader, ResourceSubscriptionCallback, RegistryEntry, RegistrySearchOptions, RegistrySearchResult, RegistrySourceType, RegistryConfig, MCPRegistryClientConfig, LoadBalancingStrategy, ServerGroup, UnifiedTool, MultiServerManagerConfig, ServerWeight, MCPServerBaseConfig, MCPServerEvents, EnhancedToolInfo, ToolSearchCriteria, ToolSearchResult, CompatibilityCheckResult, ElicitationType, Elicitation, ElicitationResponse, ElicitationHandler, ElicitationManagerConfig, ElicitationRequest, ElicitationContext, TextElicitation, SelectElicitation, SelectOption, MultiSelectElicitation, ConfirmationElicitation, FileElicitation, SecretElicitation, FormElicitation, FormField, ElicitationProtocolMessage, ElicitationProtocolMessageType, ElicitationProtocolPayload, ElicitationProtocolHandler, ElicitationProtocolAdapterConfig, ElicitationRequestMessage, ElicitationRequestParams, ElicitationResponseMessage, ElicitationResponseParams, ElicitationCancelMessage, ElicitationCancelParams, } from "./mcp/index.js";
|
|
204
205
|
export type { AuthorizationUrlResult, DiscoveredMcp, HTTPRetryConfig, MCPOAuthConfig, McpMetadata, OAuthClientInformation, OAuthTokens as McpOAuthTokens, RateLimitConfig, TokenExchangeRequest, TokenStorage, } from "./types/mcpTypes.js";
|
|
205
206
|
export type { ExecutionContext, ToolExecutionResult, ToolInfo, } from "./types/tools.js";
|
|
206
207
|
export type { LogLevel } from "./types/utilities.js";
|
package/dist/lib/index.js
CHANGED
|
@@ -237,7 +237,33 @@ InMemoryTokenStorage,
|
|
|
237
237
|
// Simplified MCP exports
|
|
238
238
|
initializeMCPEcosystem, isRetryableHTTPError, isRetryableStatusCode, isTokenExpired, listMCPs,
|
|
239
239
|
// Circuit Breaker
|
|
240
|
-
MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry,
|
|
240
|
+
MCPCircuitBreaker, mcpLogger, NeuroLinkOAuthProvider, RateLimiterManager, validateServerTools, validateTool as validateMCPTool, withHTTPRetry,
|
|
241
|
+
// Core MCP Components
|
|
242
|
+
MCPToolRegistry, ExternalServerManager, MCPClientFactory,
|
|
243
|
+
// MCP Enhancements - Routing, Caching, Batching
|
|
244
|
+
ToolRouter, createToolRouter, DEFAULT_ROUTER_CONFIG, ToolCache, createToolCache, DEFAULT_CACHE_CONFIG, ToolResultCache, createToolResultCache, RequestBatcher, ToolCallBatcher, createRequestBatcher, createToolCallBatcher, DEFAULT_BATCH_CONFIG,
|
|
245
|
+
// MCP Enhancements - Tool Annotations
|
|
246
|
+
inferAnnotations, createAnnotatedTool, validateAnnotations, filterToolsByAnnotations, mergeAnnotations, getAnnotationSummary, requiresConfirmation, isSafeToRetry, getToolSafetyLevel,
|
|
247
|
+
// MCP Enhancements - Elicitation
|
|
248
|
+
ElicitationManager, globalElicitationManager,
|
|
249
|
+
// MCP Enhancements - Enhanced Tool Discovery
|
|
250
|
+
EnhancedToolDiscovery,
|
|
251
|
+
// MCP Enhancements - Registry Client
|
|
252
|
+
MCPRegistryClient, globalMCPRegistryClient, getWellKnownServer, getAllWellKnownServers,
|
|
253
|
+
// MCP Enhancements - Server Base
|
|
254
|
+
MCPServerBase,
|
|
255
|
+
// MCP Enhancements - Multi-Server Manager
|
|
256
|
+
MultiServerManager, globalMultiServerManager,
|
|
257
|
+
// MCP Enhancements - Agent Exposure
|
|
258
|
+
AgentExposureManager, exposeAgentAsTool, exposeAgentsAsTools, exposeWorkflowAsTool, exposeWorkflowsAsTools, globalAgentExposureManager,
|
|
259
|
+
// MCP Enhancements - Server Capabilities
|
|
260
|
+
ServerCapabilitiesManager, createTextResource, createJsonResource, createPrompt,
|
|
261
|
+
// MCP Enhancements - Tool Converter
|
|
262
|
+
neuroLinkToolToMCP, mcpToolToNeuroLink, batchConvertToMCP, batchConvertToNeuroLink, sanitizeToolName, validateToolName, createToolFromFunction, mcpProtocolToolToServerTool, serverToolToMCPProtocol, TOOL_COMPATIBILITY,
|
|
263
|
+
// MCP Enhancements - Tool Integration
|
|
264
|
+
ToolIntegrationManager, globalToolIntegrationManager, wrapToolWithElicitation, wrapToolsWithElicitation, createElicitationContext, confirmationMiddleware, validationMiddleware, loggingMiddleware, createRetryMiddleware, createTimeoutMiddleware, createToolMiddlewareChain,
|
|
265
|
+
// MCP Enhancements - Elicitation Protocol
|
|
266
|
+
ElicitationProtocolAdapter, globalElicitationProtocol, isElicitationProtocolMessage, protocolMessageToElicitation, elicitationResponseToProtocol, createElicitationRequest, createElicitationResponse, createElicitationCancel, createTextInputRequest, createSelectRequest, createConfirmationRequest, createFormRequest, } from "./mcp/index.js";
|
|
241
267
|
export { logger } from "./utils/logger.js";
|
|
242
268
|
export { getPoolStats } from "./utils/redis.js";
|
|
243
269
|
// ============================================================================
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent and Workflow Exposure as MCP Tools
|
|
3
|
+
*
|
|
4
|
+
* Enables exposing NeuroLink agents and workflows as MCP tools,
|
|
5
|
+
* allowing external MCP clients to invoke complex AI operations
|
|
6
|
+
* through the standardized MCP protocol.
|
|
7
|
+
*
|
|
8
|
+
* @module mcp/agentExposure
|
|
9
|
+
* @since 8.39.0
|
|
10
|
+
*/
|
|
11
|
+
import type { JsonObject } from "../types/common.js";
|
|
12
|
+
import type { NeuroLinkExecutionContext } from "../types/mcpTypes.js";
|
|
13
|
+
import type { MCPServerTool, MCPToolAnnotations } from "./toolAnnotations.js";
|
|
14
|
+
/**
|
|
15
|
+
* Agent definition for MCP exposure
|
|
16
|
+
*/
|
|
17
|
+
export type ExposableAgent = {
|
|
18
|
+
/**
|
|
19
|
+
* Unique agent identifier
|
|
20
|
+
*/
|
|
21
|
+
id: string;
|
|
22
|
+
/**
|
|
23
|
+
* Human-readable agent name
|
|
24
|
+
*/
|
|
25
|
+
name: string;
|
|
26
|
+
/**
|
|
27
|
+
* Agent description for AI models
|
|
28
|
+
*/
|
|
29
|
+
description: string;
|
|
30
|
+
/**
|
|
31
|
+
* Input schema for the agent
|
|
32
|
+
*/
|
|
33
|
+
inputSchema?: JsonObject;
|
|
34
|
+
/**
|
|
35
|
+
* Output schema for the agent
|
|
36
|
+
*/
|
|
37
|
+
outputSchema?: JsonObject;
|
|
38
|
+
/**
|
|
39
|
+
* Agent execution function
|
|
40
|
+
*/
|
|
41
|
+
execute: (input: unknown, context?: NeuroLinkExecutionContext) => Promise<unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Additional agent metadata
|
|
44
|
+
*/
|
|
45
|
+
metadata?: {
|
|
46
|
+
version?: string;
|
|
47
|
+
author?: string;
|
|
48
|
+
category?: string;
|
|
49
|
+
tags?: string[];
|
|
50
|
+
estimatedDuration?: number;
|
|
51
|
+
costHint?: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Workflow definition for MCP exposure
|
|
56
|
+
*/
|
|
57
|
+
export type ExposableWorkflow = {
|
|
58
|
+
/**
|
|
59
|
+
* Unique workflow identifier
|
|
60
|
+
*/
|
|
61
|
+
id: string;
|
|
62
|
+
/**
|
|
63
|
+
* Human-readable workflow name
|
|
64
|
+
*/
|
|
65
|
+
name: string;
|
|
66
|
+
/**
|
|
67
|
+
* Workflow description
|
|
68
|
+
*/
|
|
69
|
+
description: string;
|
|
70
|
+
/**
|
|
71
|
+
* Workflow steps (for documentation)
|
|
72
|
+
*/
|
|
73
|
+
steps?: Array<{
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Input schema for the workflow
|
|
80
|
+
*/
|
|
81
|
+
inputSchema?: JsonObject;
|
|
82
|
+
/**
|
|
83
|
+
* Output schema for the workflow
|
|
84
|
+
*/
|
|
85
|
+
outputSchema?: JsonObject;
|
|
86
|
+
/**
|
|
87
|
+
* Workflow execution function
|
|
88
|
+
*/
|
|
89
|
+
execute: (input: unknown, context?: NeuroLinkExecutionContext) => Promise<unknown>;
|
|
90
|
+
/**
|
|
91
|
+
* Workflow metadata
|
|
92
|
+
*/
|
|
93
|
+
metadata?: {
|
|
94
|
+
version?: string;
|
|
95
|
+
author?: string;
|
|
96
|
+
category?: string;
|
|
97
|
+
tags?: string[];
|
|
98
|
+
estimatedDuration?: number;
|
|
99
|
+
retriable?: boolean;
|
|
100
|
+
idempotent?: boolean;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Options for exposing agents/workflows as MCP tools
|
|
105
|
+
*/
|
|
106
|
+
export type ExposureOptions = {
|
|
107
|
+
/**
|
|
108
|
+
* Prefix for tool names
|
|
109
|
+
*/
|
|
110
|
+
prefix?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Default annotations for all exposed tools
|
|
113
|
+
*/
|
|
114
|
+
defaultAnnotations?: MCPToolAnnotations;
|
|
115
|
+
/**
|
|
116
|
+
* Whether to include metadata in tool description
|
|
117
|
+
*/
|
|
118
|
+
includeMetadataInDescription?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Custom name transformer
|
|
121
|
+
*/
|
|
122
|
+
nameTransformer?: (name: string) => string;
|
|
123
|
+
/**
|
|
124
|
+
* Add execution context wrapper
|
|
125
|
+
*/
|
|
126
|
+
wrapWithContext?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Timeout for agent/workflow execution (ms)
|
|
129
|
+
*/
|
|
130
|
+
executionTimeout?: number;
|
|
131
|
+
/**
|
|
132
|
+
* Enable execution logging
|
|
133
|
+
*/
|
|
134
|
+
enableLogging?: boolean;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Exposure result
|
|
138
|
+
*/
|
|
139
|
+
export type ExposureResult = {
|
|
140
|
+
/**
|
|
141
|
+
* Generated MCP tool
|
|
142
|
+
*/
|
|
143
|
+
tool: MCPServerTool;
|
|
144
|
+
/**
|
|
145
|
+
* Original source type
|
|
146
|
+
*/
|
|
147
|
+
sourceType: "agent" | "workflow";
|
|
148
|
+
/**
|
|
149
|
+
* Original source ID
|
|
150
|
+
*/
|
|
151
|
+
sourceId: string;
|
|
152
|
+
/**
|
|
153
|
+
* Generated tool name
|
|
154
|
+
*/
|
|
155
|
+
toolName: string;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Expose an agent as an MCP tool
|
|
159
|
+
*/
|
|
160
|
+
export declare function exposeAgentAsTool(agent: ExposableAgent, options?: ExposureOptions): ExposureResult;
|
|
161
|
+
/**
|
|
162
|
+
* Expose a workflow as an MCP tool
|
|
163
|
+
*/
|
|
164
|
+
export declare function exposeWorkflowAsTool(workflow: ExposableWorkflow, options?: ExposureOptions): ExposureResult;
|
|
165
|
+
/**
|
|
166
|
+
* Batch expose agents as MCP tools
|
|
167
|
+
*/
|
|
168
|
+
export declare function exposeAgentsAsTools(agents: ExposableAgent[], options?: ExposureOptions): ExposureResult[];
|
|
169
|
+
/**
|
|
170
|
+
* Batch expose workflows as MCP tools
|
|
171
|
+
*/
|
|
172
|
+
export declare function exposeWorkflowsAsTools(workflows: ExposableWorkflow[], options?: ExposureOptions): ExposureResult[];
|
|
173
|
+
/**
|
|
174
|
+
* Agent Exposure Manager
|
|
175
|
+
*
|
|
176
|
+
* Manages the lifecycle of exposed agents and workflows,
|
|
177
|
+
* providing registration, lookup, and invocation capabilities.
|
|
178
|
+
*/
|
|
179
|
+
export declare class AgentExposureManager {
|
|
180
|
+
private exposedTools;
|
|
181
|
+
private options;
|
|
182
|
+
constructor(options?: ExposureOptions);
|
|
183
|
+
/**
|
|
184
|
+
* Expose an agent and register it
|
|
185
|
+
*/
|
|
186
|
+
exposeAgent(agent: ExposableAgent): MCPServerTool;
|
|
187
|
+
/**
|
|
188
|
+
* Expose a workflow and register it
|
|
189
|
+
*/
|
|
190
|
+
exposeWorkflow(workflow: ExposableWorkflow): MCPServerTool;
|
|
191
|
+
/**
|
|
192
|
+
* Get all exposed tools
|
|
193
|
+
*/
|
|
194
|
+
getExposedTools(): MCPServerTool[];
|
|
195
|
+
/**
|
|
196
|
+
* Get exposed tool by name
|
|
197
|
+
*/
|
|
198
|
+
getExposedTool(toolName: string): MCPServerTool | undefined;
|
|
199
|
+
/**
|
|
200
|
+
* Get exposure result by tool name
|
|
201
|
+
*/
|
|
202
|
+
getExposureResult(toolName: string): ExposureResult | undefined;
|
|
203
|
+
/**
|
|
204
|
+
* Get tools by source type
|
|
205
|
+
*/
|
|
206
|
+
getToolsBySourceType(sourceType: "agent" | "workflow"): MCPServerTool[];
|
|
207
|
+
/**
|
|
208
|
+
* Remove exposed tool
|
|
209
|
+
*/
|
|
210
|
+
unexpose(toolName: string): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Clear all exposed tools
|
|
213
|
+
*/
|
|
214
|
+
clear(): void;
|
|
215
|
+
/**
|
|
216
|
+
* Get statistics
|
|
217
|
+
*/
|
|
218
|
+
getStatistics(): {
|
|
219
|
+
totalExposed: number;
|
|
220
|
+
exposedAgents: number;
|
|
221
|
+
exposedWorkflows: number;
|
|
222
|
+
toolNames: string[];
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Global agent exposure manager instance
|
|
227
|
+
*/
|
|
228
|
+
export declare const globalAgentExposureManager: AgentExposureManager;
|