@juspay/neurolink 6.2.0 → 6.2.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 -2
- package/dist/agent/direct-tools.js +6 -5
- package/dist/config/configManager.js +11 -10
- package/dist/lib/agent/direct-tools.js +6 -5
- package/dist/lib/config/configManager.js +11 -10
- package/dist/lib/mcp/index.d.ts +2 -2
- package/dist/lib/mcp/index.js +1 -1
- package/dist/lib/mcp/registry.js +1 -1
- package/dist/lib/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
- package/dist/lib/mcp/tool-registry.js +1 -1
- package/dist/lib/neurolink.js +1 -1
- package/dist/lib/providers/azure-openai.js +2 -1
- package/dist/lib/telemetry/index.js +2 -1
- package/dist/lib/utils/logger.d.ts +62 -2
- package/dist/lib/utils/logger.js +174 -9
- package/dist/mcp/index.d.ts +2 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mcp/registry.js +1 -1
- package/dist/mcp/servers/ai-providers/ai-analysis-tools.js +2 -1
- package/dist/mcp/tool-registry.js +1 -1
- package/dist/neurolink.js +1 -1
- package/dist/providers/azure-openai.js +2 -1
- package/dist/telemetry/index.js +2 -1
- package/dist/utils/logger.d.ts +62 -2
- package/dist/utils/logger.js +174 -9
- package/package.json +1 -1
- package/dist/lib/mcp/logging.d.ts +0 -38
- package/dist/lib/mcp/logging.js +0 -100
- package/dist/mcp/logging.d.ts +0 -38
- package/dist/mcp/logging.js +0 -100
package/dist/mcp/index.js
CHANGED
package/dist/mcp/registry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MCP Registry - Industry Standard Interface with camelCase
|
|
3
3
|
*/
|
|
4
|
-
import { registryLogger } from "
|
|
4
|
+
import { registryLogger } from "../utils/logger.js";
|
|
5
5
|
/**
|
|
6
6
|
* Simple MCP registry for plugin management
|
|
7
7
|
* Maintains backward compatibility with existing code
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { z } from "zod";
|
|
7
7
|
import { AIProviderFactory } from "../../../core/factory.js";
|
|
8
8
|
import { getBestProvider, getAvailableProviders, } from "../../../utils/providerUtils.js";
|
|
9
|
+
import { logger } from "../../../utils/logger.js";
|
|
9
10
|
/**
|
|
10
11
|
* Input Schemas for AI Analysis Tools
|
|
11
12
|
*/
|
|
@@ -89,7 +90,7 @@ const analyzeAIUsageTool = {
|
|
|
89
90
|
const typedParams = params;
|
|
90
91
|
const startTime = Date.now();
|
|
91
92
|
try {
|
|
92
|
-
|
|
93
|
+
logger.debug(`[AI-Analysis] Starting real AI-powered usage analysis for timeRange: ${typedParams.timeRange}`);
|
|
93
94
|
const providerName = await getBestProvider();
|
|
94
95
|
const provider = await AIProviderFactory.createProvider(providerName);
|
|
95
96
|
if (!provider) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Updated to match industry standard camelCase interfaces
|
|
4
4
|
*/
|
|
5
5
|
import { MCPRegistry } from "./registry.js";
|
|
6
|
-
import { registryLogger } from "
|
|
6
|
+
import { registryLogger } from "../utils/logger.js";
|
|
7
7
|
import { randomUUID } from "crypto";
|
|
8
8
|
export class MCPToolRegistry extends MCPRegistry {
|
|
9
9
|
tools = new Map();
|
package/dist/neurolink.js
CHANGED
|
@@ -14,7 +14,7 @@ catch (error) {
|
|
|
14
14
|
// Environment variables should be set externally in production
|
|
15
15
|
}
|
|
16
16
|
import { AIProviderFactory } from "./core/factory.js";
|
|
17
|
-
import { mcpLogger } from "./
|
|
17
|
+
import { mcpLogger } from "./utils/logger.js";
|
|
18
18
|
import { toolRegistry } from "./mcp/tool-registry.js";
|
|
19
19
|
import { logger } from "./utils/logger.js";
|
|
20
20
|
import { getBestProvider } from "./utils/providerUtils.js";
|
|
@@ -2,6 +2,7 @@ import { createAzure } from "@ai-sdk/azure";
|
|
|
2
2
|
import { streamText } from "ai";
|
|
3
3
|
import { BaseProvider } from "../core/base-provider.js";
|
|
4
4
|
import { validateApiKey, createAzureAPIKeyConfig, createAzureEndpointConfig, } from "../utils/providerConfig.js";
|
|
5
|
+
import { logger } from "../utils/logger.js";
|
|
5
6
|
export class AzureOpenAIProvider extends BaseProvider {
|
|
6
7
|
apiKey;
|
|
7
8
|
resourceName;
|
|
@@ -35,7 +36,7 @@ export class AzureOpenAIProvider extends BaseProvider {
|
|
|
35
36
|
apiKey: this.apiKey,
|
|
36
37
|
apiVersion: this.apiVersion,
|
|
37
38
|
});
|
|
38
|
-
|
|
39
|
+
logger.debug("Azure Vercel Provider initialized", {
|
|
39
40
|
deployment: this.deployment,
|
|
40
41
|
resourceName: this.resourceName,
|
|
41
42
|
provider: "azure-vercel",
|
package/dist/telemetry/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Optional Telemetry Infrastructure (Phase 2)
|
|
2
2
|
export { TelemetryService } from "./telemetry-service.js";
|
|
3
|
+
import { logger } from "../utils/logger.js";
|
|
3
4
|
/**
|
|
4
5
|
* Initialize telemetry for NeuroLink
|
|
5
6
|
* OPTIONAL - Only works when NEUROLINK_TELEMETRY_ENABLED=true
|
|
@@ -9,7 +10,7 @@ export async function initializeTelemetry() {
|
|
|
9
10
|
const telemetry = TelemetryService.getInstance();
|
|
10
11
|
if (telemetry.isEnabled()) {
|
|
11
12
|
await telemetry.initialize();
|
|
12
|
-
|
|
13
|
+
logger.info("[NeuroLink] Telemetry initialized");
|
|
13
14
|
}
|
|
14
15
|
return telemetry;
|
|
15
16
|
}
|
package/dist/utils/logger.d.ts
CHANGED
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NeuroLink Logger Utility
|
|
2
|
+
* NeuroLink Unified Logger Utility
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Centralized logging for the entire NeuroLink ecosystem
|
|
5
|
+
* Supports both CLI --debug flag and NEUROLINK_DEBUG environment variable
|
|
6
|
+
* Migrated from MCP logging with enhanced features
|
|
5
7
|
*/
|
|
8
|
+
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
9
|
+
interface LogEntry {
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
message: string;
|
|
12
|
+
timestamp: Date;
|
|
13
|
+
data?: unknown;
|
|
14
|
+
}
|
|
15
|
+
declare class NeuroLinkLogger {
|
|
16
|
+
private logLevel;
|
|
17
|
+
private logs;
|
|
18
|
+
private maxLogs;
|
|
19
|
+
private isDebugMode;
|
|
20
|
+
constructor();
|
|
21
|
+
setLogLevel(level: LogLevel): void;
|
|
22
|
+
shouldLog(level: LogLevel): boolean;
|
|
23
|
+
private getLogPrefix;
|
|
24
|
+
/**
|
|
25
|
+
* Outputs a log entry to the console based on the log level.
|
|
26
|
+
*
|
|
27
|
+
* @param level - The log level (debug, info, warn, error).
|
|
28
|
+
* @param prefix - The formatted log prefix.
|
|
29
|
+
* @param message - The log message.
|
|
30
|
+
* @param data - Optional additional data to log.
|
|
31
|
+
*/
|
|
32
|
+
private outputToConsole;
|
|
33
|
+
private log;
|
|
34
|
+
debug(message: string, data?: unknown): void;
|
|
35
|
+
info(message: string, data?: unknown): void;
|
|
36
|
+
warn(message: string, data?: unknown): void;
|
|
37
|
+
error(message: string, data?: unknown): void;
|
|
38
|
+
getLogs(level?: LogLevel): LogEntry[];
|
|
39
|
+
clearLogs(): void;
|
|
40
|
+
/**
|
|
41
|
+
* Logs messages unconditionally using `console.log`.
|
|
42
|
+
*
|
|
43
|
+
* This method is part of a legacy simple logger interface for backward compatibility.
|
|
44
|
+
* It bypasses the structured logging mechanism and should only be used when
|
|
45
|
+
* unstructured, unconditional logging is required.
|
|
46
|
+
*
|
|
47
|
+
* @param args - The arguments to log. These are passed directly to `console.log`.
|
|
48
|
+
*/
|
|
49
|
+
always(...args: unknown[]): void;
|
|
50
|
+
}
|
|
6
51
|
export declare const logger: {
|
|
7
52
|
debug: (...args: unknown[]) => void;
|
|
8
53
|
info: (...args: unknown[]) => void;
|
|
9
54
|
warn: (...args: unknown[]) => void;
|
|
10
55
|
error: (...args: unknown[]) => void;
|
|
11
56
|
always: (...args: unknown[]) => void;
|
|
57
|
+
setLogLevel: (level: LogLevel) => void;
|
|
58
|
+
getLogs: (level?: LogLevel) => LogEntry[];
|
|
59
|
+
clearLogs: () => void;
|
|
12
60
|
};
|
|
61
|
+
export declare const mcpLogger: NeuroLinkLogger;
|
|
62
|
+
export declare const autoDiscoveryLogger: NeuroLinkLogger;
|
|
63
|
+
export declare const registryLogger: NeuroLinkLogger;
|
|
64
|
+
export declare const unifiedRegistryLogger: NeuroLinkLogger;
|
|
65
|
+
export declare function setGlobalMCPLogLevel(level: LogLevel): void;
|
|
66
|
+
export declare const LogLevels: {
|
|
67
|
+
readonly debug: "debug";
|
|
68
|
+
readonly info: "info";
|
|
69
|
+
readonly warn: "warn";
|
|
70
|
+
readonly error: "error";
|
|
71
|
+
};
|
|
72
|
+
export type { LogEntry };
|
package/dist/utils/logger.js
CHANGED
|
@@ -1,25 +1,190 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* NeuroLink Logger Utility
|
|
2
|
+
* NeuroLink Unified Logger Utility
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Centralized logging for the entire NeuroLink ecosystem
|
|
5
|
+
* Supports both CLI --debug flag and NEUROLINK_DEBUG environment variable
|
|
6
|
+
* Migrated from MCP logging with enhanced features
|
|
5
7
|
*/
|
|
8
|
+
// Pre-computed uppercase log levels for performance optimization
|
|
9
|
+
const UPPERCASE_LOG_LEVELS = {
|
|
10
|
+
debug: "DEBUG",
|
|
11
|
+
info: "INFO",
|
|
12
|
+
warn: "WARN",
|
|
13
|
+
error: "ERROR",
|
|
14
|
+
};
|
|
15
|
+
class NeuroLinkLogger {
|
|
16
|
+
logLevel = "info";
|
|
17
|
+
logs = [];
|
|
18
|
+
maxLogs = 1000;
|
|
19
|
+
isDebugMode;
|
|
20
|
+
constructor() {
|
|
21
|
+
// Cache debug mode check to avoid repeated array searches
|
|
22
|
+
this.isDebugMode =
|
|
23
|
+
process.argv.includes("--debug") ||
|
|
24
|
+
process.env.NEUROLINK_DEBUG === "true";
|
|
25
|
+
// Check NEUROLINK_LOG_LEVEL for consistency with the unified NeuroLink logger
|
|
26
|
+
let envLevel = process.env.NEUROLINK_LOG_LEVEL?.toLowerCase();
|
|
27
|
+
// Fallback to MCP_LOG_LEVEL for backward compatibility (if needed)
|
|
28
|
+
if (!envLevel) {
|
|
29
|
+
envLevel = process.env.MCP_LOG_LEVEL?.toLowerCase();
|
|
30
|
+
}
|
|
31
|
+
if (envLevel && ["debug", "info", "warn", "error"].includes(envLevel)) {
|
|
32
|
+
this.logLevel = envLevel;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
setLogLevel(level) {
|
|
36
|
+
this.logLevel = level;
|
|
37
|
+
}
|
|
38
|
+
shouldLog(level) {
|
|
39
|
+
// Hide all logs except errors unless debugging
|
|
40
|
+
if (!this.isDebugMode && level !== "error") {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const levels = ["debug", "info", "warn", "error"];
|
|
44
|
+
return levels.indexOf(level) >= levels.indexOf(this.logLevel);
|
|
45
|
+
}
|
|
46
|
+
getLogPrefix(timestamp, level) {
|
|
47
|
+
return `[${timestamp}] [NEUROLINK:${UPPERCASE_LOG_LEVELS[level]}]`;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Outputs a log entry to the console based on the log level.
|
|
51
|
+
*
|
|
52
|
+
* @param level - The log level (debug, info, warn, error).
|
|
53
|
+
* @param prefix - The formatted log prefix.
|
|
54
|
+
* @param message - The log message.
|
|
55
|
+
* @param data - Optional additional data to log.
|
|
56
|
+
*/
|
|
57
|
+
outputToConsole(level, prefix, message, data) {
|
|
58
|
+
const logMethod = {
|
|
59
|
+
debug: console.debug,
|
|
60
|
+
info: console.info,
|
|
61
|
+
warn: console.warn,
|
|
62
|
+
error: console.error,
|
|
63
|
+
}[level];
|
|
64
|
+
if (data !== undefined && data !== null) {
|
|
65
|
+
logMethod(prefix, message, data);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
logMethod(prefix, message);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
log(level, message, data) {
|
|
72
|
+
if (!this.shouldLog(level)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const entry = {
|
|
76
|
+
level,
|
|
77
|
+
message,
|
|
78
|
+
timestamp: new Date(),
|
|
79
|
+
data,
|
|
80
|
+
};
|
|
81
|
+
// Store log entry
|
|
82
|
+
this.logs.push(entry);
|
|
83
|
+
// Trim old logs
|
|
84
|
+
if (this.logs.length > this.maxLogs) {
|
|
85
|
+
this.logs = this.logs.slice(-this.maxLogs);
|
|
86
|
+
}
|
|
87
|
+
// Console output
|
|
88
|
+
const timestamp = entry.timestamp.toISOString();
|
|
89
|
+
const prefix = this.getLogPrefix(timestamp, level);
|
|
90
|
+
this.outputToConsole(level, prefix, message, data);
|
|
91
|
+
}
|
|
92
|
+
debug(message, data) {
|
|
93
|
+
this.log("debug", message, data);
|
|
94
|
+
}
|
|
95
|
+
info(message, data) {
|
|
96
|
+
this.log("info", message, data);
|
|
97
|
+
}
|
|
98
|
+
warn(message, data) {
|
|
99
|
+
this.log("warn", message, data);
|
|
100
|
+
}
|
|
101
|
+
error(message, data) {
|
|
102
|
+
this.log("error", message, data);
|
|
103
|
+
}
|
|
104
|
+
getLogs(level) {
|
|
105
|
+
if (level) {
|
|
106
|
+
return this.logs.filter((log) => log.level === level);
|
|
107
|
+
}
|
|
108
|
+
return [...this.logs];
|
|
109
|
+
}
|
|
110
|
+
clearLogs() {
|
|
111
|
+
this.logs = [];
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Logs messages unconditionally using `console.log`.
|
|
115
|
+
*
|
|
116
|
+
* This method is part of a legacy simple logger interface for backward compatibility.
|
|
117
|
+
* It bypasses the structured logging mechanism and should only be used when
|
|
118
|
+
* unstructured, unconditional logging is required.
|
|
119
|
+
*
|
|
120
|
+
* @param args - The arguments to log. These are passed directly to `console.log`.
|
|
121
|
+
*/
|
|
122
|
+
always(...args) {
|
|
123
|
+
console.log(...args);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// Export singleton instance
|
|
127
|
+
const neuroLinkLogger = new NeuroLinkLogger();
|
|
128
|
+
// Helper function to process arguments with minimal overhead
|
|
129
|
+
function processLoggerArgs(args, logMethod) {
|
|
130
|
+
if (args.length === 0) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
// Serialize the first argument robustly to handle complex objects
|
|
134
|
+
const message = (() => {
|
|
135
|
+
try {
|
|
136
|
+
return typeof args[0] === "string" ? args[0] : JSON.stringify(args[0]);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
return "[Unserializable Object]";
|
|
140
|
+
}
|
|
141
|
+
})();
|
|
142
|
+
const data = args.length === 2 ? args[1] : args.length > 2 ? args.slice(1) : undefined;
|
|
143
|
+
logMethod(message, data);
|
|
144
|
+
}
|
|
145
|
+
// Main unified logger export
|
|
6
146
|
export const logger = {
|
|
7
147
|
debug: (...args) => {
|
|
8
|
-
if (
|
|
9
|
-
|
|
148
|
+
if (neuroLinkLogger.shouldLog("debug")) {
|
|
149
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.debug(message, data));
|
|
10
150
|
}
|
|
11
151
|
},
|
|
12
152
|
info: (...args) => {
|
|
13
|
-
|
|
153
|
+
if (neuroLinkLogger.shouldLog("info")) {
|
|
154
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.info(message, data));
|
|
155
|
+
}
|
|
14
156
|
},
|
|
15
157
|
warn: (...args) => {
|
|
16
|
-
|
|
158
|
+
if (neuroLinkLogger.shouldLog("warn")) {
|
|
159
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.warn(message, data));
|
|
160
|
+
}
|
|
17
161
|
},
|
|
18
162
|
error: (...args) => {
|
|
19
|
-
|
|
20
|
-
|
|
163
|
+
if (neuroLinkLogger.shouldLog("error")) {
|
|
164
|
+
processLoggerArgs(args, (message, data) => neuroLinkLogger.error(message, data));
|
|
165
|
+
}
|
|
21
166
|
},
|
|
22
167
|
always: (...args) => {
|
|
23
|
-
|
|
168
|
+
neuroLinkLogger.always(...args);
|
|
24
169
|
},
|
|
170
|
+
// Expose structured logging methods
|
|
171
|
+
setLogLevel: (level) => neuroLinkLogger.setLogLevel(level),
|
|
172
|
+
getLogs: (level) => neuroLinkLogger.getLogs(level),
|
|
173
|
+
clearLogs: () => neuroLinkLogger.clearLogs(),
|
|
174
|
+
};
|
|
175
|
+
// MCP compatibility exports - all use the same unified logger
|
|
176
|
+
export const mcpLogger = neuroLinkLogger;
|
|
177
|
+
export const autoDiscoveryLogger = neuroLinkLogger;
|
|
178
|
+
export const registryLogger = neuroLinkLogger;
|
|
179
|
+
export const unifiedRegistryLogger = neuroLinkLogger;
|
|
180
|
+
// Global log level setter
|
|
181
|
+
export function setGlobalMCPLogLevel(level) {
|
|
182
|
+
neuroLinkLogger.setLogLevel(level);
|
|
183
|
+
}
|
|
184
|
+
// Export LogLevel enum for runtime use
|
|
185
|
+
export const LogLevels = {
|
|
186
|
+
debug: "debug",
|
|
187
|
+
info: "info",
|
|
188
|
+
warn: "warn",
|
|
189
|
+
error: "error",
|
|
25
190
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juspay/neurolink",
|
|
3
|
-
"version": "6.2.
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Universal AI Development Platform with working MCP integration, multi-provider support, and professional CLI. Built-in tools operational, 58+ external MCP servers discoverable. Connect to filesystem, GitHub, database operations, and more. Build, test, and deploy AI applications with 9 major providers: OpenAI, Anthropic, Google AI, AWS Bedrock, Azure, Hugging Face, Ollama, and Mistral AI.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Juspay Technologies",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Logging Utility
|
|
3
|
-
* Centralized logging for the MCP ecosystem
|
|
4
|
-
*/
|
|
5
|
-
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
6
|
-
interface LogEntry {
|
|
7
|
-
level: LogLevel;
|
|
8
|
-
message: string;
|
|
9
|
-
timestamp: Date;
|
|
10
|
-
data?: unknown;
|
|
11
|
-
}
|
|
12
|
-
declare class MCPLogger {
|
|
13
|
-
private logLevel;
|
|
14
|
-
private logs;
|
|
15
|
-
private maxLogs;
|
|
16
|
-
constructor();
|
|
17
|
-
setLogLevel(level: LogLevel): void;
|
|
18
|
-
private shouldLog;
|
|
19
|
-
private log;
|
|
20
|
-
debug(message: string, data?: unknown): void;
|
|
21
|
-
info(message: string, data?: unknown): void;
|
|
22
|
-
warn(message: string, data?: unknown): void;
|
|
23
|
-
error(message: string, data?: unknown): void;
|
|
24
|
-
getLogs(level?: LogLevel): LogEntry[];
|
|
25
|
-
clearLogs(): void;
|
|
26
|
-
}
|
|
27
|
-
export declare const mcpLogger: MCPLogger;
|
|
28
|
-
export declare const autoDiscoveryLogger: MCPLogger;
|
|
29
|
-
export declare const registryLogger: MCPLogger;
|
|
30
|
-
export declare const unifiedRegistryLogger: MCPLogger;
|
|
31
|
-
export declare function setGlobalMCPLogLevel(level: LogLevel): void;
|
|
32
|
-
export declare const LogLevels: {
|
|
33
|
-
readonly debug: "debug";
|
|
34
|
-
readonly info: "info";
|
|
35
|
-
readonly warn: "warn";
|
|
36
|
-
readonly error: "error";
|
|
37
|
-
};
|
|
38
|
-
export {};
|
package/dist/lib/mcp/logging.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Logging Utility
|
|
3
|
-
* Centralized logging for the MCP ecosystem
|
|
4
|
-
*/
|
|
5
|
-
class MCPLogger {
|
|
6
|
-
logLevel = "info";
|
|
7
|
-
logs = [];
|
|
8
|
-
maxLogs = 1000;
|
|
9
|
-
constructor() {
|
|
10
|
-
// Set log level from environment
|
|
11
|
-
const envLevel = process.env.MCP_LOG_LEVEL?.toLowerCase();
|
|
12
|
-
if (envLevel && ["debug", "info", "warn", "error"].includes(envLevel)) {
|
|
13
|
-
this.logLevel = envLevel;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
setLogLevel(level) {
|
|
17
|
-
this.logLevel = level;
|
|
18
|
-
}
|
|
19
|
-
shouldLog(level) {
|
|
20
|
-
// CRITICAL: Respect CLI debug flag - hide all logs except errors unless debugging
|
|
21
|
-
const isDebugMode = process.argv.includes("--debug");
|
|
22
|
-
if (!isDebugMode && level !== "error") {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const levels = ["debug", "info", "warn", "error"];
|
|
26
|
-
return levels.indexOf(level) >= levels.indexOf(this.logLevel);
|
|
27
|
-
}
|
|
28
|
-
log(level, message, data) {
|
|
29
|
-
if (!this.shouldLog(level)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const entry = {
|
|
33
|
-
level,
|
|
34
|
-
message,
|
|
35
|
-
timestamp: new Date(),
|
|
36
|
-
data,
|
|
37
|
-
};
|
|
38
|
-
// Store log entry
|
|
39
|
-
this.logs.push(entry);
|
|
40
|
-
// Trim old logs
|
|
41
|
-
if (this.logs.length > this.maxLogs) {
|
|
42
|
-
this.logs = this.logs.slice(-this.maxLogs);
|
|
43
|
-
}
|
|
44
|
-
// Console output
|
|
45
|
-
const timestamp = entry.timestamp.toISOString();
|
|
46
|
-
const prefix = `[${timestamp}] [MCP:${level.toUpperCase()}]`;
|
|
47
|
-
switch (level) {
|
|
48
|
-
case "debug":
|
|
49
|
-
console.debug(prefix, message, data ? data : "");
|
|
50
|
-
break;
|
|
51
|
-
case "info":
|
|
52
|
-
console.info(prefix, message, data ? data : "");
|
|
53
|
-
break;
|
|
54
|
-
case "warn":
|
|
55
|
-
console.warn(prefix, message, data ? data : "");
|
|
56
|
-
break;
|
|
57
|
-
case "error":
|
|
58
|
-
console.error(prefix, message, data ? data : "");
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
debug(message, data) {
|
|
63
|
-
this.log("debug", message, data);
|
|
64
|
-
}
|
|
65
|
-
info(message, data) {
|
|
66
|
-
this.log("info", message, data);
|
|
67
|
-
}
|
|
68
|
-
warn(message, data) {
|
|
69
|
-
this.log("warn", message, data);
|
|
70
|
-
}
|
|
71
|
-
error(message, data) {
|
|
72
|
-
this.log("error", message, data);
|
|
73
|
-
}
|
|
74
|
-
getLogs(level) {
|
|
75
|
-
if (level) {
|
|
76
|
-
return this.logs.filter((log) => log.level === level);
|
|
77
|
-
}
|
|
78
|
-
return [...this.logs];
|
|
79
|
-
}
|
|
80
|
-
clearLogs() {
|
|
81
|
-
this.logs = [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Export singleton instance
|
|
85
|
-
export const mcpLogger = new MCPLogger();
|
|
86
|
-
// Additional logger instances for different modules
|
|
87
|
-
export const autoDiscoveryLogger = mcpLogger;
|
|
88
|
-
export const registryLogger = mcpLogger;
|
|
89
|
-
export const unifiedRegistryLogger = mcpLogger;
|
|
90
|
-
// Global log level setter
|
|
91
|
-
export function setGlobalMCPLogLevel(level) {
|
|
92
|
-
mcpLogger.setLogLevel(level);
|
|
93
|
-
}
|
|
94
|
-
// Export LogLevel enum for runtime use
|
|
95
|
-
export const LogLevels = {
|
|
96
|
-
debug: "debug",
|
|
97
|
-
info: "info",
|
|
98
|
-
warn: "warn",
|
|
99
|
-
error: "error",
|
|
100
|
-
};
|
package/dist/mcp/logging.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Logging Utility
|
|
3
|
-
* Centralized logging for the MCP ecosystem
|
|
4
|
-
*/
|
|
5
|
-
export type LogLevel = "debug" | "info" | "warn" | "error";
|
|
6
|
-
interface LogEntry {
|
|
7
|
-
level: LogLevel;
|
|
8
|
-
message: string;
|
|
9
|
-
timestamp: Date;
|
|
10
|
-
data?: unknown;
|
|
11
|
-
}
|
|
12
|
-
declare class MCPLogger {
|
|
13
|
-
private logLevel;
|
|
14
|
-
private logs;
|
|
15
|
-
private maxLogs;
|
|
16
|
-
constructor();
|
|
17
|
-
setLogLevel(level: LogLevel): void;
|
|
18
|
-
private shouldLog;
|
|
19
|
-
private log;
|
|
20
|
-
debug(message: string, data?: unknown): void;
|
|
21
|
-
info(message: string, data?: unknown): void;
|
|
22
|
-
warn(message: string, data?: unknown): void;
|
|
23
|
-
error(message: string, data?: unknown): void;
|
|
24
|
-
getLogs(level?: LogLevel): LogEntry[];
|
|
25
|
-
clearLogs(): void;
|
|
26
|
-
}
|
|
27
|
-
export declare const mcpLogger: MCPLogger;
|
|
28
|
-
export declare const autoDiscoveryLogger: MCPLogger;
|
|
29
|
-
export declare const registryLogger: MCPLogger;
|
|
30
|
-
export declare const unifiedRegistryLogger: MCPLogger;
|
|
31
|
-
export declare function setGlobalMCPLogLevel(level: LogLevel): void;
|
|
32
|
-
export declare const LogLevels: {
|
|
33
|
-
readonly debug: "debug";
|
|
34
|
-
readonly info: "info";
|
|
35
|
-
readonly warn: "warn";
|
|
36
|
-
readonly error: "error";
|
|
37
|
-
};
|
|
38
|
-
export {};
|
package/dist/mcp/logging.js
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* MCP Logging Utility
|
|
3
|
-
* Centralized logging for the MCP ecosystem
|
|
4
|
-
*/
|
|
5
|
-
class MCPLogger {
|
|
6
|
-
logLevel = "info";
|
|
7
|
-
logs = [];
|
|
8
|
-
maxLogs = 1000;
|
|
9
|
-
constructor() {
|
|
10
|
-
// Set log level from environment
|
|
11
|
-
const envLevel = process.env.MCP_LOG_LEVEL?.toLowerCase();
|
|
12
|
-
if (envLevel && ["debug", "info", "warn", "error"].includes(envLevel)) {
|
|
13
|
-
this.logLevel = envLevel;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
setLogLevel(level) {
|
|
17
|
-
this.logLevel = level;
|
|
18
|
-
}
|
|
19
|
-
shouldLog(level) {
|
|
20
|
-
// CRITICAL: Respect CLI debug flag - hide all logs except errors unless debugging
|
|
21
|
-
const isDebugMode = process.argv.includes("--debug");
|
|
22
|
-
if (!isDebugMode && level !== "error") {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
const levels = ["debug", "info", "warn", "error"];
|
|
26
|
-
return levels.indexOf(level) >= levels.indexOf(this.logLevel);
|
|
27
|
-
}
|
|
28
|
-
log(level, message, data) {
|
|
29
|
-
if (!this.shouldLog(level)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
const entry = {
|
|
33
|
-
level,
|
|
34
|
-
message,
|
|
35
|
-
timestamp: new Date(),
|
|
36
|
-
data,
|
|
37
|
-
};
|
|
38
|
-
// Store log entry
|
|
39
|
-
this.logs.push(entry);
|
|
40
|
-
// Trim old logs
|
|
41
|
-
if (this.logs.length > this.maxLogs) {
|
|
42
|
-
this.logs = this.logs.slice(-this.maxLogs);
|
|
43
|
-
}
|
|
44
|
-
// Console output
|
|
45
|
-
const timestamp = entry.timestamp.toISOString();
|
|
46
|
-
const prefix = `[${timestamp}] [MCP:${level.toUpperCase()}]`;
|
|
47
|
-
switch (level) {
|
|
48
|
-
case "debug":
|
|
49
|
-
console.debug(prefix, message, data ? data : "");
|
|
50
|
-
break;
|
|
51
|
-
case "info":
|
|
52
|
-
console.info(prefix, message, data ? data : "");
|
|
53
|
-
break;
|
|
54
|
-
case "warn":
|
|
55
|
-
console.warn(prefix, message, data ? data : "");
|
|
56
|
-
break;
|
|
57
|
-
case "error":
|
|
58
|
-
console.error(prefix, message, data ? data : "");
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
debug(message, data) {
|
|
63
|
-
this.log("debug", message, data);
|
|
64
|
-
}
|
|
65
|
-
info(message, data) {
|
|
66
|
-
this.log("info", message, data);
|
|
67
|
-
}
|
|
68
|
-
warn(message, data) {
|
|
69
|
-
this.log("warn", message, data);
|
|
70
|
-
}
|
|
71
|
-
error(message, data) {
|
|
72
|
-
this.log("error", message, data);
|
|
73
|
-
}
|
|
74
|
-
getLogs(level) {
|
|
75
|
-
if (level) {
|
|
76
|
-
return this.logs.filter((log) => log.level === level);
|
|
77
|
-
}
|
|
78
|
-
return [...this.logs];
|
|
79
|
-
}
|
|
80
|
-
clearLogs() {
|
|
81
|
-
this.logs = [];
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
// Export singleton instance
|
|
85
|
-
export const mcpLogger = new MCPLogger();
|
|
86
|
-
// Additional logger instances for different modules
|
|
87
|
-
export const autoDiscoveryLogger = mcpLogger;
|
|
88
|
-
export const registryLogger = mcpLogger;
|
|
89
|
-
export const unifiedRegistryLogger = mcpLogger;
|
|
90
|
-
// Global log level setter
|
|
91
|
-
export function setGlobalMCPLogLevel(level) {
|
|
92
|
-
mcpLogger.setLogLevel(level);
|
|
93
|
-
}
|
|
94
|
-
// Export LogLevel enum for runtime use
|
|
95
|
-
export const LogLevels = {
|
|
96
|
-
debug: "debug",
|
|
97
|
-
info: "info",
|
|
98
|
-
warn: "warn",
|
|
99
|
-
error: "error",
|
|
100
|
-
};
|