@juspay/neurolink 9.41.0 → 9.42.1
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/README.md +7 -1
- package/dist/auth/anthropicOAuth.d.ts +18 -3
- package/dist/auth/anthropicOAuth.js +149 -4
- package/dist/auth/providers/firebase.js +5 -1
- package/dist/auth/providers/jwt.js +5 -1
- package/dist/auth/providers/workos.js +5 -1
- package/dist/auth/sessionManager.d.ts +1 -1
- package/dist/auth/sessionManager.js +58 -27
- package/dist/browser/neurolink.min.js +354 -334
- package/dist/cli/commands/mcp.d.ts +6 -0
- package/dist/cli/commands/mcp.js +188 -181
- package/dist/cli/commands/proxy.d.ts +2 -1
- package/dist/cli/commands/proxy.js +713 -431
- package/dist/cli/commands/task.js +3 -0
- package/dist/cli/factories/commandFactory.d.ts +2 -0
- package/dist/cli/factories/commandFactory.js +38 -0
- package/dist/cli/parser.js +4 -3
- package/dist/client/aiSdkAdapter.js +3 -0
- package/dist/client/streamingClient.js +30 -10
- package/dist/core/baseProvider.d.ts +6 -1
- package/dist/core/baseProvider.js +208 -230
- package/dist/core/factory.d.ts +3 -0
- package/dist/core/factory.js +138 -188
- package/dist/core/modules/GenerationHandler.js +3 -2
- package/dist/core/redisConversationMemoryManager.js +7 -3
- package/dist/evaluation/BatchEvaluator.js +4 -1
- package/dist/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/evaluation/pipeline/evaluationPipeline.js +24 -9
- package/dist/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/evaluation/scorers/scorerRegistry.d.ts +3 -0
- package/dist/evaluation/scorers/scorerRegistry.js +353 -282
- package/dist/lib/auth/anthropicOAuth.d.ts +18 -3
- package/dist/lib/auth/anthropicOAuth.js +149 -4
- package/dist/lib/auth/providers/firebase.js +5 -1
- package/dist/lib/auth/providers/jwt.js +5 -1
- package/dist/lib/auth/providers/workos.js +5 -1
- package/dist/lib/auth/sessionManager.d.ts +1 -1
- package/dist/lib/auth/sessionManager.js +58 -27
- package/dist/lib/client/aiSdkAdapter.js +3 -0
- package/dist/lib/client/streamingClient.js +30 -10
- package/dist/lib/core/baseProvider.d.ts +6 -1
- package/dist/lib/core/baseProvider.js +208 -230
- package/dist/lib/core/factory.d.ts +3 -0
- package/dist/lib/core/factory.js +138 -188
- package/dist/lib/core/modules/GenerationHandler.js +3 -2
- package/dist/lib/core/redisConversationMemoryManager.js +7 -3
- package/dist/lib/evaluation/BatchEvaluator.js +4 -1
- package/dist/lib/evaluation/hooks/observabilityHooks.js +5 -3
- package/dist/lib/evaluation/pipeline/evaluationPipeline.d.ts +3 -2
- package/dist/lib/evaluation/pipeline/evaluationPipeline.js +24 -9
- package/dist/lib/evaluation/pipeline/strategies/batchStrategy.js +6 -3
- package/dist/lib/evaluation/pipeline/strategies/samplingStrategy.js +18 -10
- package/dist/lib/evaluation/scorers/scorerRegistry.d.ts +3 -0
- package/dist/lib/evaluation/scorers/scorerRegistry.js +353 -282
- package/dist/lib/mcp/toolRegistry.d.ts +2 -0
- package/dist/lib/mcp/toolRegistry.js +32 -31
- package/dist/lib/neurolink.d.ts +41 -2
- package/dist/lib/neurolink.js +1616 -1681
- package/dist/lib/observability/otelBridge.d.ts +2 -2
- package/dist/lib/observability/otelBridge.js +12 -3
- package/dist/lib/providers/amazonBedrock.js +2 -4
- package/dist/lib/providers/anthropic.d.ts +9 -5
- package/dist/lib/providers/anthropic.js +19 -14
- package/dist/lib/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/lib/providers/anthropicBaseProvider.js +5 -4
- package/dist/lib/providers/azureOpenai.d.ts +1 -1
- package/dist/lib/providers/azureOpenai.js +5 -4
- package/dist/lib/providers/googleAiStudio.js +30 -6
- package/dist/lib/providers/googleVertex.d.ts +10 -0
- package/dist/lib/providers/googleVertex.js +437 -423
- package/dist/lib/providers/huggingFace.d.ts +3 -3
- package/dist/lib/providers/huggingFace.js +6 -8
- package/dist/lib/providers/litellm.d.ts +1 -0
- package/dist/lib/providers/litellm.js +76 -55
- package/dist/lib/providers/mistral.js +2 -1
- package/dist/lib/providers/ollama.js +93 -23
- package/dist/lib/providers/openAI.d.ts +2 -0
- package/dist/lib/providers/openAI.js +141 -141
- package/dist/lib/providers/openRouter.js +2 -1
- package/dist/lib/providers/openaiCompatible.d.ts +4 -4
- package/dist/lib/providers/openaiCompatible.js +4 -4
- package/dist/lib/proxy/claudeFormat.d.ts +3 -2
- package/dist/lib/proxy/claudeFormat.js +27 -14
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/lib/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/lib/proxy/modelRouter.js +3 -0
- package/dist/lib/proxy/oauthFetch.d.ts +1 -1
- package/dist/lib/proxy/oauthFetch.js +289 -316
- package/dist/lib/proxy/proxyConfig.js +46 -24
- package/dist/lib/proxy/proxyEnv.d.ts +19 -0
- package/dist/lib/proxy/proxyEnv.js +73 -0
- package/dist/lib/proxy/proxyFetch.js +291 -217
- package/dist/lib/proxy/proxyTracer.d.ts +133 -0
- package/dist/lib/proxy/proxyTracer.js +645 -0
- package/dist/lib/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/lib/proxy/rawStreamCapture.js +83 -0
- package/dist/lib/proxy/requestLogger.d.ts +32 -5
- package/dist/lib/proxy/requestLogger.js +503 -47
- package/dist/lib/proxy/sseInterceptor.d.ts +97 -0
- package/dist/lib/proxy/sseInterceptor.js +427 -0
- package/dist/lib/proxy/usageStats.d.ts +4 -3
- package/dist/lib/proxy/usageStats.js +25 -12
- package/dist/lib/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/lib/rag/chunking/markdownChunker.js +15 -6
- package/dist/lib/server/routes/claudeProxyRoutes.d.ts +17 -3
- package/dist/lib/server/routes/claudeProxyRoutes.js +3032 -1349
- package/dist/lib/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/lib/services/server/ai/observability/instrumentation.js +337 -161
- package/dist/lib/tasks/backends/bullmqBackend.d.ts +1 -0
- package/dist/lib/tasks/backends/bullmqBackend.js +35 -22
- package/dist/lib/tasks/store/redisTaskStore.d.ts +1 -0
- package/dist/lib/tasks/store/redisTaskStore.js +54 -39
- package/dist/lib/tasks/taskManager.d.ts +5 -0
- package/dist/lib/tasks/taskManager.js +158 -30
- package/dist/lib/telemetry/index.d.ts +2 -1
- package/dist/lib/telemetry/index.js +2 -1
- package/dist/lib/telemetry/telemetryService.d.ts +3 -0
- package/dist/lib/telemetry/telemetryService.js +69 -5
- package/dist/lib/types/cli.d.ts +10 -0
- package/dist/lib/types/proxyTypes.d.ts +160 -5
- package/dist/lib/types/streamTypes.d.ts +25 -3
- package/dist/lib/utils/messageBuilder.js +3 -2
- package/dist/lib/utils/providerHealth.d.ts +19 -0
- package/dist/lib/utils/providerHealth.js +279 -33
- package/dist/lib/utils/providerUtils.js +17 -22
- package/dist/lib/utils/toolChoice.d.ts +4 -0
- package/dist/lib/utils/toolChoice.js +7 -0
- package/dist/mcp/toolRegistry.d.ts +2 -0
- package/dist/mcp/toolRegistry.js +32 -31
- package/dist/neurolink.d.ts +41 -2
- package/dist/neurolink.js +1616 -1681
- package/dist/observability/otelBridge.d.ts +2 -2
- package/dist/observability/otelBridge.js +12 -3
- package/dist/providers/amazonBedrock.js +2 -4
- package/dist/providers/anthropic.d.ts +9 -5
- package/dist/providers/anthropic.js +19 -14
- package/dist/providers/anthropicBaseProvider.d.ts +3 -3
- package/dist/providers/anthropicBaseProvider.js +5 -4
- package/dist/providers/azureOpenai.d.ts +1 -1
- package/dist/providers/azureOpenai.js +5 -4
- package/dist/providers/googleAiStudio.js +30 -6
- package/dist/providers/googleVertex.d.ts +10 -0
- package/dist/providers/googleVertex.js +437 -423
- package/dist/providers/huggingFace.d.ts +3 -3
- package/dist/providers/huggingFace.js +6 -7
- package/dist/providers/litellm.d.ts +1 -0
- package/dist/providers/litellm.js +76 -55
- package/dist/providers/mistral.js +2 -1
- package/dist/providers/ollama.js +93 -23
- package/dist/providers/openAI.d.ts +2 -0
- package/dist/providers/openAI.js +141 -141
- package/dist/providers/openRouter.js +2 -1
- package/dist/providers/openaiCompatible.d.ts +4 -4
- package/dist/providers/openaiCompatible.js +4 -3
- package/dist/proxy/claudeFormat.d.ts +3 -2
- package/dist/proxy/claudeFormat.js +27 -14
- package/dist/proxy/cloaking/plugins/sessionIdentity.d.ts +2 -6
- package/dist/proxy/cloaking/plugins/sessionIdentity.js +9 -33
- package/dist/proxy/modelRouter.js +3 -0
- package/dist/proxy/oauthFetch.d.ts +1 -1
- package/dist/proxy/oauthFetch.js +289 -316
- package/dist/proxy/proxyConfig.js +46 -24
- package/dist/proxy/proxyEnv.d.ts +19 -0
- package/dist/proxy/proxyEnv.js +72 -0
- package/dist/proxy/proxyFetch.js +291 -217
- package/dist/proxy/proxyTracer.d.ts +133 -0
- package/dist/proxy/proxyTracer.js +644 -0
- package/dist/proxy/rawStreamCapture.d.ts +10 -0
- package/dist/proxy/rawStreamCapture.js +82 -0
- package/dist/proxy/requestLogger.d.ts +32 -5
- package/dist/proxy/requestLogger.js +503 -47
- package/dist/proxy/sseInterceptor.d.ts +97 -0
- package/dist/proxy/sseInterceptor.js +426 -0
- package/dist/proxy/usageStats.d.ts +4 -3
- package/dist/proxy/usageStats.js +25 -12
- package/dist/rag/chunkers/MarkdownChunker.js +13 -5
- package/dist/rag/chunking/markdownChunker.js +15 -6
- package/dist/server/routes/claudeProxyRoutes.d.ts +17 -3
- package/dist/server/routes/claudeProxyRoutes.js +3032 -1349
- package/dist/services/server/ai/observability/instrumentation.d.ts +7 -1
- package/dist/services/server/ai/observability/instrumentation.js +337 -161
- package/dist/tasks/backends/bullmqBackend.d.ts +1 -0
- package/dist/tasks/backends/bullmqBackend.js +35 -22
- package/dist/tasks/store/redisTaskStore.d.ts +1 -0
- package/dist/tasks/store/redisTaskStore.js +54 -39
- package/dist/tasks/taskManager.d.ts +5 -0
- package/dist/tasks/taskManager.js +158 -30
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/telemetry/telemetryService.d.ts +3 -0
- package/dist/telemetry/telemetryService.js +69 -5
- package/dist/types/cli.d.ts +10 -0
- package/dist/types/proxyTypes.d.ts +160 -5
- package/dist/types/streamTypes.d.ts +25 -3
- package/dist/utils/messageBuilder.js +3 -2
- package/dist/utils/providerHealth.d.ts +19 -0
- package/dist/utils/providerHealth.js +279 -33
- package/dist/utils/providerUtils.js +18 -22
- package/dist/utils/toolChoice.d.ts +4 -0
- package/dist/utils/toolChoice.js +6 -0
- package/docs/assets/dashboards/neurolink-proxy-observability-dashboard.json +6609 -0
- package/docs/changelog.md +252 -0
- package/package.json +19 -2
- package/scripts/observability/check-proxy-telemetry.mjs +235 -0
- package/scripts/observability/docker-compose.proxy-observability.yaml +55 -0
- package/scripts/observability/import-openobserve-dashboard.mjs +240 -0
- package/scripts/observability/manage-local-openobserve.sh +215 -0
- package/scripts/observability/otel-collector.proxy-observability.yaml +78 -0
- package/scripts/observability/proxy-observability.env.example +23 -0
|
@@ -163,4 +163,10 @@ export declare class MCPCommandFactory {
|
|
|
163
163
|
* Execute annotate command
|
|
164
164
|
*/
|
|
165
165
|
private static executeAnnotate;
|
|
166
|
+
private static getMCPStatusWithTimeout;
|
|
167
|
+
private static listToolAnnotations;
|
|
168
|
+
private static collectToolAnnotations;
|
|
169
|
+
private static findToolForAnnotation;
|
|
170
|
+
private static buildAnnotationsFromArgs;
|
|
171
|
+
private static printAnnotationUpdate;
|
|
166
172
|
}
|
package/dist/cli/commands/mcp.js
CHANGED
|
@@ -115,6 +115,7 @@ const POPULAR_MCP_SERVERS = {
|
|
|
115
115
|
description: "Bitbucket repository management and development workflows",
|
|
116
116
|
},
|
|
117
117
|
};
|
|
118
|
+
const MCP_STATUS_TIMEOUT_MS = 30_000;
|
|
118
119
|
/**
|
|
119
120
|
* MCP CLI command factory
|
|
120
121
|
*/
|
|
@@ -565,6 +566,7 @@ export class MCPCommandFactory {
|
|
|
565
566
|
? null
|
|
566
567
|
: ora("Testing MCP server connections...").start();
|
|
567
568
|
const sdk = new NeuroLink();
|
|
569
|
+
await this.getMCPStatusWithTimeout(sdk, Number(argv.timeout) || MCP_STATUS_TIMEOUT_MS);
|
|
568
570
|
let serversToTest = await sdk.listMCPServers();
|
|
569
571
|
if (targetServer) {
|
|
570
572
|
serversToTest = serversToTest.filter((s) => s.name === targetServer);
|
|
@@ -654,6 +656,7 @@ export class MCPCommandFactory {
|
|
|
654
656
|
}
|
|
655
657
|
}
|
|
656
658
|
const sdk = new NeuroLink();
|
|
659
|
+
await this.getMCPStatusWithTimeout(sdk);
|
|
657
660
|
// Check if server exists and is connected
|
|
658
661
|
const allServers = await sdk.listMCPServers();
|
|
659
662
|
const server = allServers.find((s) => s.name === serverName);
|
|
@@ -762,6 +765,7 @@ export class MCPCommandFactory {
|
|
|
762
765
|
process.exit(1);
|
|
763
766
|
}
|
|
764
767
|
const sdk = new NeuroLink();
|
|
768
|
+
await this.getMCPStatusWithTimeout(sdk);
|
|
765
769
|
const allServers = await sdk.listMCPServers();
|
|
766
770
|
const server = allServers.find((s) => s.name === serverName);
|
|
767
771
|
if (!server) {
|
|
@@ -2231,154 +2235,23 @@ ${tools.length > 0 ? tools.map((t) => `- **${t}**: TODO: Add description`).join(
|
|
|
2231
2235
|
try {
|
|
2232
2236
|
const sdk = new NeuroLink();
|
|
2233
2237
|
const servers = await sdk.listMCPServers();
|
|
2234
|
-
// List mode - show all tools with annotations
|
|
2235
2238
|
if (argv.list) {
|
|
2236
|
-
|
|
2237
|
-
? null
|
|
2238
|
-
: ora("Loading tool annotations...").start();
|
|
2239
|
-
const allTools = [];
|
|
2240
|
-
for (const server of servers) {
|
|
2241
|
-
if (server.status !== "connected") {
|
|
2242
|
-
continue;
|
|
2243
|
-
}
|
|
2244
|
-
for (const tool of server.tools || []) {
|
|
2245
|
-
const existing = tool
|
|
2246
|
-
.annotations;
|
|
2247
|
-
const annotations = existing ??
|
|
2248
|
-
inferAnnotations({
|
|
2249
|
-
name: tool.name,
|
|
2250
|
-
description: tool.description,
|
|
2251
|
-
});
|
|
2252
|
-
allTools.push({
|
|
2253
|
-
serverName: server.name,
|
|
2254
|
-
serverId: server.id,
|
|
2255
|
-
toolName: tool.name,
|
|
2256
|
-
description: tool.description,
|
|
2257
|
-
annotations,
|
|
2258
|
-
});
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
if (spinner) {
|
|
2262
|
-
spinner.succeed(`Found ${allTools.length} tools`);
|
|
2263
|
-
}
|
|
2264
|
-
if (argv.format === "json") {
|
|
2265
|
-
logger.always(JSON.stringify(allTools, null, 2));
|
|
2266
|
-
return;
|
|
2267
|
-
}
|
|
2268
|
-
logger.always(chalk.bold("\n Tool Annotations:\n"));
|
|
2269
|
-
// Group by server
|
|
2270
|
-
const byServer = allTools.reduce((acc, tool) => {
|
|
2271
|
-
if (!acc[tool.serverId]) {
|
|
2272
|
-
acc[tool.serverId] = {
|
|
2273
|
-
serverName: tool.serverName,
|
|
2274
|
-
tools: [],
|
|
2275
|
-
};
|
|
2276
|
-
}
|
|
2277
|
-
acc[tool.serverId].tools.push(tool);
|
|
2278
|
-
return acc;
|
|
2279
|
-
}, {});
|
|
2280
|
-
for (const [serverId, { serverName, tools }] of Object.entries(byServer)) {
|
|
2281
|
-
logger.always(chalk.cyan.bold(`\n${serverName} (${serverId}):`));
|
|
2282
|
-
for (const tool of tools) {
|
|
2283
|
-
const annotationStr = getAnnotationSummary(tool.annotations);
|
|
2284
|
-
logger.always(` ${chalk.yellow(tool.toolName)} ${chalk.gray(annotationStr)}`);
|
|
2285
|
-
if (argv.detailed) {
|
|
2286
|
-
logger.always(` ${chalk.gray(tool.description)}`);
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
}
|
|
2290
|
-
logger.always();
|
|
2239
|
+
await this.listToolAnnotations(servers, argv);
|
|
2291
2240
|
return;
|
|
2292
2241
|
}
|
|
2293
|
-
// Annotate specific tool
|
|
2294
2242
|
const toolName = argv.tool;
|
|
2295
2243
|
if (!toolName) {
|
|
2296
2244
|
logger.error(chalk.red("Tool name is required. Use --tool <name> or --list to see all tools."));
|
|
2297
2245
|
process.exit(1);
|
|
2298
2246
|
}
|
|
2299
|
-
// Find the tool
|
|
2300
|
-
let foundTool = null;
|
|
2301
2247
|
const serverId = argv.server;
|
|
2302
|
-
|
|
2303
|
-
if (serverId && server.id !== serverId) {
|
|
2304
|
-
continue;
|
|
2305
|
-
}
|
|
2306
|
-
for (const tool of server.tools || []) {
|
|
2307
|
-
if (tool.name === toolName) {
|
|
2308
|
-
foundTool = {
|
|
2309
|
-
name: tool.name,
|
|
2310
|
-
description: tool.description,
|
|
2311
|
-
serverId: server.id,
|
|
2312
|
-
serverName: server.name,
|
|
2313
|
-
};
|
|
2314
|
-
break;
|
|
2315
|
-
}
|
|
2316
|
-
}
|
|
2317
|
-
if (foundTool) {
|
|
2318
|
-
break;
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2248
|
+
const foundTool = this.findToolForAnnotation(servers, toolName, serverId);
|
|
2321
2249
|
if (!foundTool) {
|
|
2322
2250
|
logger.error(chalk.red(`Tool '${toolName}' not found.${serverId ? ` Server: ${serverId}` : ""}`));
|
|
2323
2251
|
logger.always(chalk.yellow("Use 'neurolink mcp annotate --list' to see available tools."));
|
|
2324
2252
|
process.exit(1);
|
|
2325
2253
|
}
|
|
2326
|
-
|
|
2327
|
-
let annotations = {};
|
|
2328
|
-
// Parse JSON annotations if provided
|
|
2329
|
-
if (argv.annotations) {
|
|
2330
|
-
try {
|
|
2331
|
-
const parsed = JSON.parse(argv.annotations);
|
|
2332
|
-
annotations = { ...annotations, ...parsed };
|
|
2333
|
-
}
|
|
2334
|
-
catch {
|
|
2335
|
-
logger.error(chalk.red("Invalid JSON in --annotations"));
|
|
2336
|
-
process.exit(1);
|
|
2337
|
-
}
|
|
2338
|
-
}
|
|
2339
|
-
// Apply individual annotation flags
|
|
2340
|
-
if (argv["read-only"] !== undefined) {
|
|
2341
|
-
annotations.readOnlyHint = argv["read-only"];
|
|
2342
|
-
}
|
|
2343
|
-
if (argv.destructive !== undefined) {
|
|
2344
|
-
annotations.destructiveHint = argv.destructive;
|
|
2345
|
-
}
|
|
2346
|
-
if (argv.idempotent !== undefined) {
|
|
2347
|
-
annotations.idempotentHint = argv.idempotent;
|
|
2348
|
-
}
|
|
2349
|
-
if (argv["requires-confirmation"] !== undefined) {
|
|
2350
|
-
annotations.requiresConfirmation = argv["requires-confirmation"];
|
|
2351
|
-
}
|
|
2352
|
-
if (argv.tags) {
|
|
2353
|
-
annotations.tags = argv.tags;
|
|
2354
|
-
}
|
|
2355
|
-
if (argv["estimated-duration"] !== undefined) {
|
|
2356
|
-
annotations.estimatedDuration = argv["estimated-duration"];
|
|
2357
|
-
}
|
|
2358
|
-
if (argv["rate-limit"] !== undefined) {
|
|
2359
|
-
annotations.rateLimitHint = argv["rate-limit"];
|
|
2360
|
-
}
|
|
2361
|
-
if (argv.cost !== undefined) {
|
|
2362
|
-
annotations.costHint = argv.cost;
|
|
2363
|
-
}
|
|
2364
|
-
if (argv.complexity) {
|
|
2365
|
-
annotations.complexity = argv.complexity;
|
|
2366
|
-
}
|
|
2367
|
-
if (argv["security-level"]) {
|
|
2368
|
-
annotations.securityLevel = argv["security-level"];
|
|
2369
|
-
}
|
|
2370
|
-
if (argv.audit !== undefined) {
|
|
2371
|
-
annotations.auditRequired = argv.audit;
|
|
2372
|
-
}
|
|
2373
|
-
// Infer annotations if requested
|
|
2374
|
-
if (argv.infer) {
|
|
2375
|
-
const inferred = inferAnnotations({
|
|
2376
|
-
name: foundTool.name,
|
|
2377
|
-
description: foundTool.description,
|
|
2378
|
-
});
|
|
2379
|
-
annotations = mergeAnnotations(inferred, annotations);
|
|
2380
|
-
}
|
|
2381
|
-
// Validate annotations
|
|
2254
|
+
const annotations = this.buildAnnotationsFromArgs(argv, foundTool);
|
|
2382
2255
|
const errors = validateAnnotations(annotations);
|
|
2383
2256
|
if (errors.length > 0) {
|
|
2384
2257
|
logger.error(chalk.red("Annotation validation errors:"));
|
|
@@ -2393,63 +2266,197 @@ ${tools.length > 0 ? tools.map((t) => `- **${t}**: TODO: Add description`).join(
|
|
|
2393
2266
|
logger.always(JSON.stringify(annotations, null, 2));
|
|
2394
2267
|
return;
|
|
2395
2268
|
}
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
logger.
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2269
|
+
this.printAnnotationUpdate(foundTool, annotations);
|
|
2270
|
+
}
|
|
2271
|
+
catch (error) {
|
|
2272
|
+
logger.error(chalk.red(`Annotate command failed: ${error instanceof Error ? error.message : String(error)}`));
|
|
2273
|
+
process.exit(1);
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
static async getMCPStatusWithTimeout(sdk, timeoutMs = MCP_STATUS_TIMEOUT_MS) {
|
|
2277
|
+
return withTimeout(sdk.getMCPStatus(), timeoutMs, ErrorFactory.toolTimeout("mcpStatus", timeoutMs));
|
|
2278
|
+
}
|
|
2279
|
+
static async listToolAnnotations(servers, argv) {
|
|
2280
|
+
const spinner = argv.quiet
|
|
2281
|
+
? null
|
|
2282
|
+
: ora("Loading tool annotations...").start();
|
|
2283
|
+
const allTools = this.collectToolAnnotations(servers);
|
|
2284
|
+
if (spinner) {
|
|
2285
|
+
spinner.succeed(`Found ${allTools.length} tools`);
|
|
2286
|
+
}
|
|
2287
|
+
if (argv.format === "json") {
|
|
2288
|
+
logger.always(JSON.stringify(allTools, null, 2));
|
|
2289
|
+
return;
|
|
2290
|
+
}
|
|
2291
|
+
logger.always(chalk.bold("\n Tool Annotations:\n"));
|
|
2292
|
+
const byServer = allTools.reduce((acc, tool) => {
|
|
2293
|
+
if (!acc[tool.serverId]) {
|
|
2294
|
+
acc[tool.serverId] = {
|
|
2295
|
+
serverName: tool.serverName,
|
|
2296
|
+
tools: [],
|
|
2297
|
+
};
|
|
2414
2298
|
}
|
|
2415
|
-
|
|
2416
|
-
|
|
2299
|
+
acc[tool.serverId].tools.push(tool);
|
|
2300
|
+
return acc;
|
|
2301
|
+
}, {});
|
|
2302
|
+
for (const [serverId, { serverName, tools }] of Object.entries(byServer)) {
|
|
2303
|
+
logger.always(chalk.cyan.bold(`\n${serverName} (${serverId}):`));
|
|
2304
|
+
for (const tool of tools) {
|
|
2305
|
+
logger.always(` ${chalk.yellow(tool.toolName)} ${chalk.gray(getAnnotationSummary(tool.annotations))}`);
|
|
2306
|
+
if (argv.detailed) {
|
|
2307
|
+
logger.always(` ${chalk.gray(tool.description)}`);
|
|
2308
|
+
}
|
|
2417
2309
|
}
|
|
2418
|
-
|
|
2419
|
-
|
|
2310
|
+
}
|
|
2311
|
+
logger.always();
|
|
2312
|
+
}
|
|
2313
|
+
static collectToolAnnotations(servers) {
|
|
2314
|
+
const allTools = [];
|
|
2315
|
+
for (const server of servers) {
|
|
2316
|
+
if (server.status !== "connected") {
|
|
2317
|
+
continue;
|
|
2420
2318
|
}
|
|
2421
|
-
|
|
2422
|
-
|
|
2319
|
+
for (const tool of server.tools || []) {
|
|
2320
|
+
const existing = tool
|
|
2321
|
+
.annotations;
|
|
2322
|
+
allTools.push({
|
|
2323
|
+
serverName: server.name,
|
|
2324
|
+
serverId: server.id,
|
|
2325
|
+
toolName: tool.name,
|
|
2326
|
+
description: tool.description,
|
|
2327
|
+
annotations: existing ??
|
|
2328
|
+
inferAnnotations({
|
|
2329
|
+
name: tool.name,
|
|
2330
|
+
description: tool.description,
|
|
2331
|
+
}),
|
|
2332
|
+
});
|
|
2423
2333
|
}
|
|
2424
|
-
|
|
2425
|
-
|
|
2334
|
+
}
|
|
2335
|
+
return allTools;
|
|
2336
|
+
}
|
|
2337
|
+
static findToolForAnnotation(servers, toolName, serverId) {
|
|
2338
|
+
for (const server of servers) {
|
|
2339
|
+
if (serverId && server.id !== serverId) {
|
|
2340
|
+
continue;
|
|
2426
2341
|
}
|
|
2427
|
-
|
|
2428
|
-
|
|
2342
|
+
for (const tool of server.tools || []) {
|
|
2343
|
+
if (tool.name === toolName) {
|
|
2344
|
+
return {
|
|
2345
|
+
name: tool.name,
|
|
2346
|
+
description: tool.description,
|
|
2347
|
+
serverId: server.id,
|
|
2348
|
+
serverName: server.name,
|
|
2349
|
+
};
|
|
2350
|
+
}
|
|
2429
2351
|
}
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2352
|
+
}
|
|
2353
|
+
return null;
|
|
2354
|
+
}
|
|
2355
|
+
static buildAnnotationsFromArgs(argv, foundTool) {
|
|
2356
|
+
let annotations = {};
|
|
2357
|
+
if (argv.annotations) {
|
|
2358
|
+
try {
|
|
2359
|
+
annotations = {
|
|
2360
|
+
...annotations,
|
|
2361
|
+
...JSON.parse(argv.annotations),
|
|
2362
|
+
};
|
|
2437
2363
|
}
|
|
2438
|
-
|
|
2439
|
-
logger.
|
|
2364
|
+
catch {
|
|
2365
|
+
logger.error(chalk.red("Invalid JSON in --annotations"));
|
|
2366
|
+
process.exit(1);
|
|
2440
2367
|
}
|
|
2441
|
-
logger.always();
|
|
2442
|
-
logger.always(chalk.gray(" Summary: ") + getAnnotationSummary(annotations));
|
|
2443
|
-
logger.always();
|
|
2444
|
-
// Note: In a full implementation, this would persist the annotations
|
|
2445
|
-
// to a configuration file or database. For now, we just display them.
|
|
2446
|
-
logger.always(chalk.blue("Note: Annotations displayed above. To persist annotations, add them to your MCP server configuration."));
|
|
2447
|
-
logger.always(chalk.gray(`Example: Add to your server's tool definition or use environment-specific annotation overrides.`));
|
|
2448
2368
|
}
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2369
|
+
if (argv["read-only"] !== undefined) {
|
|
2370
|
+
annotations.readOnlyHint = argv["read-only"];
|
|
2371
|
+
}
|
|
2372
|
+
if (argv.destructive !== undefined) {
|
|
2373
|
+
annotations.destructiveHint = argv.destructive;
|
|
2374
|
+
}
|
|
2375
|
+
if (argv.idempotent !== undefined) {
|
|
2376
|
+
annotations.idempotentHint = argv.idempotent;
|
|
2377
|
+
}
|
|
2378
|
+
if (argv["requires-confirmation"] !== undefined) {
|
|
2379
|
+
annotations.requiresConfirmation = argv["requires-confirmation"];
|
|
2380
|
+
}
|
|
2381
|
+
if (argv.tags) {
|
|
2382
|
+
annotations.tags = argv.tags;
|
|
2383
|
+
}
|
|
2384
|
+
if (argv["estimated-duration"] !== undefined) {
|
|
2385
|
+
annotations.estimatedDuration = argv["estimated-duration"];
|
|
2386
|
+
}
|
|
2387
|
+
if (argv["rate-limit"] !== undefined) {
|
|
2388
|
+
annotations.rateLimitHint = argv["rate-limit"];
|
|
2389
|
+
}
|
|
2390
|
+
if (argv.cost !== undefined) {
|
|
2391
|
+
annotations.costHint = argv.cost;
|
|
2392
|
+
}
|
|
2393
|
+
if (argv.complexity) {
|
|
2394
|
+
annotations.complexity = argv.complexity;
|
|
2395
|
+
}
|
|
2396
|
+
if (argv["security-level"]) {
|
|
2397
|
+
annotations.securityLevel = argv["security-level"];
|
|
2398
|
+
}
|
|
2399
|
+
if (argv.audit !== undefined) {
|
|
2400
|
+
annotations.auditRequired = argv.audit;
|
|
2401
|
+
}
|
|
2402
|
+
if (argv.infer) {
|
|
2403
|
+
annotations = mergeAnnotations(inferAnnotations({
|
|
2404
|
+
name: foundTool.name,
|
|
2405
|
+
description: foundTool.description,
|
|
2406
|
+
}), annotations);
|
|
2407
|
+
}
|
|
2408
|
+
return annotations;
|
|
2409
|
+
}
|
|
2410
|
+
static printAnnotationUpdate(foundTool, annotations) {
|
|
2411
|
+
logger.always(chalk.bold("\n Tool Annotation Update:\n"));
|
|
2412
|
+
logger.always(` Server: ${chalk.cyan(foundTool.serverName)} (${foundTool.serverId})`);
|
|
2413
|
+
logger.always(` Tool: ${chalk.yellow(foundTool.name)}`);
|
|
2414
|
+
logger.always(` Description: ${chalk.gray(foundTool.description)}`);
|
|
2415
|
+
logger.always();
|
|
2416
|
+
logger.always(chalk.bold(" Annotations:"));
|
|
2417
|
+
if (annotations.readOnlyHint !== undefined) {
|
|
2418
|
+
logger.always(` readOnlyHint: ${annotations.readOnlyHint ? chalk.green("true") : chalk.red("false")}`);
|
|
2419
|
+
}
|
|
2420
|
+
if (annotations.destructiveHint !== undefined) {
|
|
2421
|
+
logger.always(` destructiveHint: ${annotations.destructiveHint ? chalk.red("true") : chalk.green("false")}`);
|
|
2422
|
+
}
|
|
2423
|
+
if (annotations.idempotentHint !== undefined) {
|
|
2424
|
+
logger.always(` idempotentHint: ${annotations.idempotentHint ? chalk.green("true") : chalk.gray("false")}`);
|
|
2425
|
+
}
|
|
2426
|
+
if (annotations.requiresConfirmation !== undefined) {
|
|
2427
|
+
logger.always(` requiresConfirmation: ${annotations.requiresConfirmation ? chalk.yellow("true") : chalk.gray("false")}`);
|
|
2428
|
+
}
|
|
2429
|
+
if (annotations.tags?.length) {
|
|
2430
|
+
logger.always(` tags: ${chalk.blue(annotations.tags.join(", "))}`);
|
|
2431
|
+
}
|
|
2432
|
+
if (annotations.estimatedDuration !== undefined) {
|
|
2433
|
+
logger.always(` estimatedDuration: ${annotations.estimatedDuration}ms`);
|
|
2434
|
+
}
|
|
2435
|
+
if (annotations.rateLimitHint !== undefined) {
|
|
2436
|
+
logger.always(` rateLimitHint: ${annotations.rateLimitHint} calls/min`);
|
|
2437
|
+
}
|
|
2438
|
+
if (annotations.costHint !== undefined) {
|
|
2439
|
+
logger.always(` costHint: ${annotations.costHint}`);
|
|
2440
|
+
}
|
|
2441
|
+
if (annotations.complexity) {
|
|
2442
|
+
logger.always(` complexity: ${chalk.cyan(annotations.complexity)}`);
|
|
2443
|
+
}
|
|
2444
|
+
if (annotations.securityLevel) {
|
|
2445
|
+
const secColor = annotations.securityLevel === "restricted"
|
|
2446
|
+
? chalk.red
|
|
2447
|
+
: annotations.securityLevel === "internal"
|
|
2448
|
+
? chalk.yellow
|
|
2449
|
+
: chalk.green;
|
|
2450
|
+
logger.always(` securityLevel: ${secColor(annotations.securityLevel)}`);
|
|
2451
|
+
}
|
|
2452
|
+
if (annotations.auditRequired !== undefined) {
|
|
2453
|
+
logger.always(` auditRequired: ${annotations.auditRequired ? chalk.yellow("true") : chalk.gray("false")}`);
|
|
2452
2454
|
}
|
|
2455
|
+
logger.always();
|
|
2456
|
+
logger.always(chalk.gray(" Summary: ") + getAnnotationSummary(annotations));
|
|
2457
|
+
logger.always();
|
|
2458
|
+
logger.always(chalk.blue("Note: Annotations displayed above. To persist annotations, add them to your MCP server configuration."));
|
|
2459
|
+
logger.always(chalk.gray("Example: Add to your server's tool definition or use environment-specific annotation overrides."));
|
|
2453
2460
|
}
|
|
2454
2461
|
}
|
|
2455
2462
|
//# sourceMappingURL=mcp.js.map
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
* (generate/stream), with an optional ModelRouter for model remapping.
|
|
11
11
|
*/
|
|
12
12
|
import type { CommandModule } from "yargs";
|
|
13
|
-
import type { ProxyStartArgs, ProxyStatusArgs, ProxyGuardArgs } from "../../lib/types/index.js";
|
|
13
|
+
import type { ProxyStartArgs, ProxyStatusArgs, ProxyGuardArgs, ProxyTelemetryArgs } from "../../lib/types/index.js";
|
|
14
14
|
export declare function mapClaudeErrorTypeToStatus(errorType?: string): number;
|
|
15
15
|
export declare const proxyStartCommand: CommandModule<object, ProxyStartArgs>;
|
|
16
16
|
export declare const proxyStatusCommand: CommandModule<object, ProxyStatusArgs>;
|
|
17
|
+
export declare const proxyTelemetryCommand: CommandModule<object, ProxyTelemetryArgs>;
|
|
17
18
|
export declare const proxyGuardCommand: CommandModule<object, ProxyGuardArgs>;
|
|
18
19
|
export declare const proxySetupCommand: CommandModule;
|
|
19
20
|
export declare const proxyInstallCommand: CommandModule;
|