sub-agents-mcp 0.13.0 → 0.14.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/README.md +21 -11
- package/dist/agents/AgentManager.d.ts +0 -45
- package/dist/agents/AgentManager.d.ts.map +1 -1
- package/dist/agents/AgentManager.js +0 -52
- package/dist/agents/AgentManager.js.map +1 -1
- package/dist/config/ServerConfig.d.ts +0 -41
- package/dist/config/ServerConfig.d.ts.map +1 -1
- package/dist/config/ServerConfig.js +0 -52
- package/dist/config/ServerConfig.js.map +1 -1
- package/dist/execution/AgentExecutor.d.ts +3 -151
- package/dist/execution/AgentExecutor.d.ts.map +1 -1
- package/dist/execution/AgentExecutor.js +30 -104
- package/dist/execution/AgentExecutor.js.map +1 -1
- package/dist/execution/StreamProcessor.d.ts +1 -10
- package/dist/execution/StreamProcessor.d.ts.map +1 -1
- package/dist/execution/StreamProcessor.js +33 -10
- package/dist/execution/StreamProcessor.js.map +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -15
- package/dist/index.js.map +1 -1
- package/dist/resources/AgentResources.d.ts +0 -71
- package/dist/resources/AgentResources.d.ts.map +1 -1
- package/dist/resources/AgentResources.js +0 -68
- package/dist/resources/AgentResources.js.map +1 -1
- package/dist/server/McpServer.d.ts +0 -88
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +0 -98
- package/dist/server/McpServer.js.map +1 -1
- package/dist/session/SessionHistoryFormatter.d.ts +0 -29
- package/dist/session/SessionHistoryFormatter.d.ts.map +1 -1
- package/dist/session/SessionHistoryFormatter.js +1 -34
- package/dist/session/SessionHistoryFormatter.js.map +1 -1
- package/dist/session/SessionManager.d.ts +0 -142
- package/dist/session/SessionManager.d.ts.map +1 -1
- package/dist/session/SessionManager.js +0 -180
- package/dist/session/SessionManager.js.map +1 -1
- package/dist/tools/RunAgentTool.d.ts +0 -121
- package/dist/tools/RunAgentTool.d.ts.map +1 -1
- package/dist/tools/RunAgentTool.js +16 -168
- package/dist/tools/RunAgentTool.js.map +1 -1
- package/dist/types/AgentDefinition.d.ts +0 -25
- package/dist/types/AgentDefinition.d.ts.map +1 -1
- package/dist/types/ExecutionParams.d.ts +0 -24
- package/dist/types/ExecutionParams.d.ts.map +1 -1
- package/dist/types/SessionData.d.ts +0 -23
- package/dist/types/SessionData.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.d.ts +0 -67
- package/dist/utils/ErrorHandler.d.ts.map +1 -1
- package/dist/utils/ErrorHandler.js +0 -59
- package/dist/utils/ErrorHandler.js.map +1 -1
- package/dist/utils/Logger.d.ts +0 -78
- package/dist/utils/Logger.d.ts.map +1 -1
- package/dist/utils/Logger.js +0 -75
- package/dist/utils/Logger.js.map +1 -1
- package/package.json +6 -9
|
@@ -1,86 +1,19 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error context information for detailed error reporting.
|
|
3
|
-
*/
|
|
4
1
|
export interface ErrorContext {
|
|
5
|
-
/** Request ID for tracing */
|
|
6
2
|
requestId?: string;
|
|
7
|
-
/** Operation being performed when error occurred */
|
|
8
3
|
operation?: string;
|
|
9
|
-
/** Additional metadata relevant to the error */
|
|
10
4
|
metadata?: Record<string, unknown>;
|
|
11
|
-
/** Timestamp when error occurred */
|
|
12
5
|
timestamp?: Date;
|
|
13
|
-
/** Component or service where error originated */
|
|
14
6
|
component?: string;
|
|
15
7
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Base application error class for structured error handling.
|
|
18
|
-
*
|
|
19
|
-
* Provides a standardized way to handle errors throughout the application
|
|
20
|
-
* with error codes, HTTP status codes, and contextual information for proper
|
|
21
|
-
* error response handling and debugging.
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* ```typescript
|
|
25
|
-
* throw new AppError('Agent not found', 'AGENT_NOT_FOUND', 404, {
|
|
26
|
-
* requestId: 'req_123',
|
|
27
|
-
* operation: 'agent_execution',
|
|
28
|
-
* component: 'AgentManager'
|
|
29
|
-
* })
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
8
|
export declare class AppError extends Error {
|
|
33
|
-
/** Error code for programmatic error identification */
|
|
34
9
|
readonly code: string;
|
|
35
|
-
/** HTTP status code for error response handling */
|
|
36
10
|
readonly statusCode: number;
|
|
37
|
-
/** Context information for debugging and tracing */
|
|
38
11
|
readonly context: ErrorContext;
|
|
39
|
-
/**
|
|
40
|
-
* Creates a new AppError instance.
|
|
41
|
-
*
|
|
42
|
-
* @param message - Human-readable error message
|
|
43
|
-
* @param code - Error code for programmatic identification
|
|
44
|
-
* @param statusCode - HTTP status code (default: 500)
|
|
45
|
-
* @param context - Additional context information
|
|
46
|
-
*/
|
|
47
12
|
constructor(message: string, code: string, statusCode?: number, context?: ErrorContext);
|
|
48
|
-
/**
|
|
49
|
-
* Converts error to a structured object for logging or API responses.
|
|
50
|
-
*
|
|
51
|
-
* @returns Structured error object
|
|
52
|
-
*/
|
|
53
13
|
toJSON(): Record<string, unknown>;
|
|
54
|
-
/**
|
|
55
|
-
* Creates a user-friendly error message without sensitive information.
|
|
56
|
-
*
|
|
57
|
-
* @returns User-friendly error message
|
|
58
|
-
*/
|
|
59
14
|
toUserMessage(): string;
|
|
60
15
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Validation error class for input validation failures.
|
|
63
|
-
*
|
|
64
|
-
* Used when user input fails validation checks such as format validation,
|
|
65
|
-
* required field checks, or constraint violations.
|
|
66
|
-
* Automatically sets HTTP status code to 400 (Bad Request).
|
|
67
|
-
*
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* throw new ValidationError('Invalid email format', 'INVALID_EMAIL', {
|
|
71
|
-
* operation: 'user_input_validation',
|
|
72
|
-
* metadata: { field: 'email', value: 'invalid-email' }
|
|
73
|
-
* })
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
16
|
export declare class ValidationError extends AppError {
|
|
77
|
-
/**
|
|
78
|
-
* Creates a new ValidationError instance.
|
|
79
|
-
*
|
|
80
|
-
* @param message - Description of the validation failure
|
|
81
|
-
* @param code - Error code for the specific validation failure
|
|
82
|
-
* @param context - Additional context information
|
|
83
|
-
*/
|
|
84
17
|
constructor(message: string, code: string, context?: ErrorContext);
|
|
85
18
|
}
|
|
86
19
|
//# sourceMappingURL=ErrorHandler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAElC,SAAS,CAAC,EAAE,IAAI,CAAA;IAEhB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAE5B,SAAgB,UAAU,EAAE,MAAM,CAAA;IAElC,SAAgB,OAAO,EAAE,YAAY,CAAA;gBAEzB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,SAAM,EAAE,OAAO,GAAE,YAAiB;IAgBvF,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWjC,aAAa,IAAI,MAAM;CAGxB;AAED,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB;CAMtE"}
|
|
@@ -1,34 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Base application error class for structured error handling.
|
|
3
|
-
*
|
|
4
|
-
* Provides a standardized way to handle errors throughout the application
|
|
5
|
-
* with error codes, HTTP status codes, and contextual information for proper
|
|
6
|
-
* error response handling and debugging.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```typescript
|
|
10
|
-
* throw new AppError('Agent not found', 'AGENT_NOT_FOUND', 404, {
|
|
11
|
-
* requestId: 'req_123',
|
|
12
|
-
* operation: 'agent_execution',
|
|
13
|
-
* component: 'AgentManager'
|
|
14
|
-
* })
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
1
|
export class AppError extends Error {
|
|
18
|
-
/** Error code for programmatic error identification */
|
|
19
2
|
code;
|
|
20
|
-
/** HTTP status code for error response handling */
|
|
21
3
|
statusCode;
|
|
22
|
-
/** Context information for debugging and tracing */
|
|
23
4
|
context;
|
|
24
|
-
/**
|
|
25
|
-
* Creates a new AppError instance.
|
|
26
|
-
*
|
|
27
|
-
* @param message - Human-readable error message
|
|
28
|
-
* @param code - Error code for programmatic identification
|
|
29
|
-
* @param statusCode - HTTP status code (default: 500)
|
|
30
|
-
* @param context - Additional context information
|
|
31
|
-
*/
|
|
32
5
|
constructor(message, code, statusCode = 500, context = {}) {
|
|
33
6
|
super(message);
|
|
34
7
|
this.name = this.constructor.name;
|
|
@@ -43,11 +16,6 @@ export class AppError extends Error {
|
|
|
43
16
|
Error.captureStackTrace(this, this.constructor);
|
|
44
17
|
}
|
|
45
18
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Converts error to a structured object for logging or API responses.
|
|
48
|
-
*
|
|
49
|
-
* @returns Structured error object
|
|
50
|
-
*/
|
|
51
19
|
toJSON() {
|
|
52
20
|
return {
|
|
53
21
|
name: this.name,
|
|
@@ -58,38 +26,11 @@ export class AppError extends Error {
|
|
|
58
26
|
stack: this.stack,
|
|
59
27
|
};
|
|
60
28
|
}
|
|
61
|
-
/**
|
|
62
|
-
* Creates a user-friendly error message without sensitive information.
|
|
63
|
-
*
|
|
64
|
-
* @returns User-friendly error message
|
|
65
|
-
*/
|
|
66
29
|
toUserMessage() {
|
|
67
30
|
return `${this.message} (Error Code: ${this.code})`;
|
|
68
31
|
}
|
|
69
32
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Validation error class for input validation failures.
|
|
72
|
-
*
|
|
73
|
-
* Used when user input fails validation checks such as format validation,
|
|
74
|
-
* required field checks, or constraint violations.
|
|
75
|
-
* Automatically sets HTTP status code to 400 (Bad Request).
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```typescript
|
|
79
|
-
* throw new ValidationError('Invalid email format', 'INVALID_EMAIL', {
|
|
80
|
-
* operation: 'user_input_validation',
|
|
81
|
-
* metadata: { field: 'email', value: 'invalid-email' }
|
|
82
|
-
* })
|
|
83
|
-
* ```
|
|
84
|
-
*/
|
|
85
33
|
export class ValidationError extends AppError {
|
|
86
|
-
/**
|
|
87
|
-
* Creates a new ValidationError instance.
|
|
88
|
-
*
|
|
89
|
-
* @param message - Description of the validation failure
|
|
90
|
-
* @param code - Error code for the specific validation failure
|
|
91
|
-
* @param context - Additional context information
|
|
92
|
-
*/
|
|
93
34
|
constructor(message, code, context = {}) {
|
|
94
35
|
super(message, code, 400, {
|
|
95
36
|
component: 'Validation',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorHandler.js","sourceRoot":"","sources":["../../src/utils/ErrorHandler.ts"],"names":[],"mappings":"AAYA,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjB,IAAI,CAAQ;IAEZ,UAAU,CAAQ;IAElB,OAAO,CAAc;IAErC,YAAY,OAAe,EAAE,IAAY,EAAE,UAAU,GAAG,GAAG,EAAE,UAAwB,EAAE;QACrF,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAA;QACjC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,OAAO,GAAG;YACb,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,GAAG,OAAO;SACX,CAAA;QAED,yEAAyE;QACzE,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACjD,CAAC;IACH,CAAC;IAED,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAED,aAAa;QACX,OAAO,GAAG,IAAI,CAAC,OAAO,iBAAiB,IAAI,CAAC,IAAI,GAAG,CAAA;IACrD,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe,EAAE,IAAY,EAAE,UAAwB,EAAE;QACnE,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE;YACxB,SAAS,EAAE,YAAY;YACvB,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC;CACF"}
|
package/dist/utils/Logger.d.ts
CHANGED
|
@@ -1,105 +1,27 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Supported log levels. Single source of truth for both runtime validation
|
|
3
|
-
* (ServerConfig) and static typing.
|
|
4
|
-
*/
|
|
5
1
|
export declare const LOG_LEVELS: readonly ["debug", "info", "warn", "error"];
|
|
6
|
-
/**
|
|
7
|
-
* Log level enumeration for structured logging.
|
|
8
|
-
*/
|
|
9
2
|
export type LogLevel = (typeof LOG_LEVELS)[number];
|
|
10
3
|
export declare function isLogLevel(value: unknown): value is LogLevel;
|
|
11
|
-
/**
|
|
12
|
-
* Log entry structure for consistent logging format.
|
|
13
|
-
*/
|
|
14
4
|
export interface LogEntry {
|
|
15
|
-
/** Timestamp of the log entry */
|
|
16
5
|
timestamp: string;
|
|
17
|
-
/** Log level */
|
|
18
6
|
level: LogLevel;
|
|
19
|
-
/** Log message */
|
|
20
7
|
message: string;
|
|
21
|
-
/** Optional context data */
|
|
22
8
|
context?: Record<string, unknown>;
|
|
23
|
-
/** Optional error object */
|
|
24
9
|
error?: Error;
|
|
25
10
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Logger utility class for structured logging.
|
|
28
|
-
*
|
|
29
|
-
* Provides consistent logging format with timestamps, levels, and context data.
|
|
30
|
-
* Supports filtering by log level and structured output for debugging.
|
|
31
|
-
*/
|
|
32
11
|
export declare class Logger {
|
|
33
12
|
private currentLevel;
|
|
34
13
|
private readonly logFilePath?;
|
|
35
14
|
private fileWriteErrorShown;
|
|
36
|
-
/**
|
|
37
|
-
* Log level priority for filtering.
|
|
38
|
-
*/
|
|
39
15
|
private static readonly levelPriority;
|
|
40
16
|
constructor(level?: LogLevel);
|
|
41
|
-
/**
|
|
42
|
-
* Logs a debug message.
|
|
43
|
-
*
|
|
44
|
-
* @param message - The message to log
|
|
45
|
-
* @param context - Optional context data
|
|
46
|
-
*/
|
|
47
17
|
debug(message: string, context?: Record<string, unknown>): void;
|
|
48
|
-
/**
|
|
49
|
-
* Logs an info message.
|
|
50
|
-
*
|
|
51
|
-
* @param message - The message to log
|
|
52
|
-
* @param context - Optional context data
|
|
53
|
-
*/
|
|
54
18
|
info(message: string, context?: Record<string, unknown>): void;
|
|
55
|
-
/**
|
|
56
|
-
* Logs a warning message.
|
|
57
|
-
*
|
|
58
|
-
* @param message - The message to log
|
|
59
|
-
* @param context - Optional context data
|
|
60
|
-
*/
|
|
61
19
|
warn(message: string, context?: Record<string, unknown>): void;
|
|
62
|
-
/**
|
|
63
|
-
* Logs an error message.
|
|
64
|
-
*
|
|
65
|
-
* @param message - The message to log
|
|
66
|
-
* @param error - Optional error object
|
|
67
|
-
* @param context - Optional context data
|
|
68
|
-
*/
|
|
69
20
|
error(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
70
|
-
/**
|
|
71
|
-
* Internal log method that handles the actual logging.
|
|
72
|
-
*
|
|
73
|
-
* @param level - The log level
|
|
74
|
-
* @param message - The message to log
|
|
75
|
-
* @param context - Optional context data
|
|
76
|
-
*/
|
|
77
21
|
private log;
|
|
78
|
-
/**
|
|
79
|
-
* Determines if a message should be logged based on current level.
|
|
80
|
-
*
|
|
81
|
-
* @param level - The log level to check
|
|
82
|
-
* @returns True if the message should be logged
|
|
83
|
-
*/
|
|
84
22
|
private shouldLog;
|
|
85
|
-
/**
|
|
86
|
-
* Outputs the log entry to the console and optionally to a file.
|
|
87
|
-
*
|
|
88
|
-
* @param entry - The log entry to output
|
|
89
|
-
*/
|
|
90
23
|
private output;
|
|
91
|
-
/**
|
|
92
|
-
* Writes log entry to file in JSON format.
|
|
93
|
-
* Errors are handled internally and do not affect main logging flow.
|
|
94
|
-
*
|
|
95
|
-
* @param entry - The log entry to write to file
|
|
96
|
-
*/
|
|
97
24
|
private writeToFile;
|
|
98
|
-
/**
|
|
99
|
-
* Performs the actual file write operation.
|
|
100
|
-
*
|
|
101
|
-
* @param entry - The log entry to write
|
|
102
|
-
*/
|
|
103
25
|
private performFileWrite;
|
|
104
26
|
}
|
|
105
27
|
//# sourceMappingURL=Logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,6CAA8C,CAAA;AAErE,MAAM,MAAM,QAAQ,GAAG,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,C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3
|
-
/**
|
|
4
|
-
* Supported log levels. Single source of truth for both runtime validation
|
|
5
|
-
* (ServerConfig) and static typing.
|
|
6
|
-
*/
|
|
7
3
|
export const LOG_LEVELS = ['debug', 'info', 'warn', 'error'];
|
|
8
4
|
export function isLogLevel(value) {
|
|
9
5
|
return typeof value === 'string' && LOG_LEVELS.includes(value);
|
|
10
6
|
}
|
|
11
|
-
/**
|
|
12
|
-
* Logger utility class for structured logging.
|
|
13
|
-
*
|
|
14
|
-
* Provides consistent logging format with timestamps, levels, and context data.
|
|
15
|
-
* Supports filtering by log level and structured output for debugging.
|
|
16
|
-
*/
|
|
17
7
|
export class Logger {
|
|
18
8
|
currentLevel;
|
|
19
9
|
logFilePath;
|
|
20
10
|
fileWriteErrorShown = false;
|
|
21
|
-
/**
|
|
22
|
-
* Log level priority for filtering.
|
|
23
|
-
*/
|
|
24
11
|
static levelPriority = {
|
|
25
12
|
debug: 0,
|
|
26
13
|
info: 1,
|
|
@@ -29,57 +16,24 @@ export class Logger {
|
|
|
29
16
|
};
|
|
30
17
|
constructor(level = 'info') {
|
|
31
18
|
this.currentLevel = level;
|
|
32
|
-
// Check for optional file logging via environment variable
|
|
33
19
|
const logFile = process.env['LOG_FILE'];
|
|
34
20
|
if (logFile?.trim()) {
|
|
35
21
|
this.logFilePath = logFile.trim();
|
|
36
22
|
}
|
|
37
23
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Logs a debug message.
|
|
40
|
-
*
|
|
41
|
-
* @param message - The message to log
|
|
42
|
-
* @param context - Optional context data
|
|
43
|
-
*/
|
|
44
24
|
debug(message, context) {
|
|
45
25
|
this.log('debug', message, context);
|
|
46
26
|
}
|
|
47
|
-
/**
|
|
48
|
-
* Logs an info message.
|
|
49
|
-
*
|
|
50
|
-
* @param message - The message to log
|
|
51
|
-
* @param context - Optional context data
|
|
52
|
-
*/
|
|
53
27
|
info(message, context) {
|
|
54
28
|
this.log('info', message, context);
|
|
55
29
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Logs a warning message.
|
|
58
|
-
*
|
|
59
|
-
* @param message - The message to log
|
|
60
|
-
* @param context - Optional context data
|
|
61
|
-
*/
|
|
62
30
|
warn(message, context) {
|
|
63
31
|
this.log('warn', message, context);
|
|
64
32
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Logs an error message.
|
|
67
|
-
*
|
|
68
|
-
* @param message - The message to log
|
|
69
|
-
* @param error - Optional error object
|
|
70
|
-
* @param context - Optional context data
|
|
71
|
-
*/
|
|
72
33
|
error(message, error, context) {
|
|
73
34
|
const errorContext = error ? { ...context, error: error.message, stack: error.stack } : context;
|
|
74
35
|
this.log('error', message, errorContext);
|
|
75
36
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Internal log method that handles the actual logging.
|
|
78
|
-
*
|
|
79
|
-
* @param level - The log level
|
|
80
|
-
* @param message - The message to log
|
|
81
|
-
* @param context - Optional context data
|
|
82
|
-
*/
|
|
83
37
|
log(level, message, context) {
|
|
84
38
|
if (!this.shouldLog(level)) {
|
|
85
39
|
return;
|
|
@@ -92,23 +46,11 @@ export class Logger {
|
|
|
92
46
|
};
|
|
93
47
|
this.output(logEntry);
|
|
94
48
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Determines if a message should be logged based on current level.
|
|
97
|
-
*
|
|
98
|
-
* @param level - The log level to check
|
|
99
|
-
* @returns True if the message should be logged
|
|
100
|
-
*/
|
|
101
49
|
shouldLog(level) {
|
|
102
50
|
return Logger.levelPriority[level] >= Logger.levelPriority[this.currentLevel];
|
|
103
51
|
}
|
|
104
|
-
/**
|
|
105
|
-
* Outputs the log entry to the console and optionally to a file.
|
|
106
|
-
*
|
|
107
|
-
* @param entry - The log entry to output
|
|
108
|
-
*/
|
|
109
52
|
output(entry) {
|
|
110
53
|
const { timestamp, level, message, context } = entry;
|
|
111
|
-
// Format output for console readability
|
|
112
54
|
const formattedMessage = `[${timestamp}] ${level.toUpperCase()}: ${message}`;
|
|
113
55
|
if (context && Object.keys(context).length > 0) {
|
|
114
56
|
console.error(formattedMessage, context);
|
|
@@ -116,41 +58,24 @@ export class Logger {
|
|
|
116
58
|
else {
|
|
117
59
|
console.error(formattedMessage);
|
|
118
60
|
}
|
|
119
|
-
// Optional file output in JSON format
|
|
120
61
|
if (this.logFilePath) {
|
|
121
62
|
this.writeToFile(entry);
|
|
122
63
|
}
|
|
123
64
|
}
|
|
124
|
-
/**
|
|
125
|
-
* Writes log entry to file in JSON format.
|
|
126
|
-
* Errors are handled internally and do not affect main logging flow.
|
|
127
|
-
*
|
|
128
|
-
* @param entry - The log entry to write to file
|
|
129
|
-
*/
|
|
130
65
|
writeToFile(entry) {
|
|
131
|
-
// Fire-and-forget async operation to avoid blocking main thread
|
|
132
66
|
this.performFileWrite(entry).catch((error) => {
|
|
133
|
-
// Only show file write error once to avoid spam
|
|
134
67
|
if (!this.fileWriteErrorShown) {
|
|
135
68
|
this.fileWriteErrorShown = true;
|
|
136
69
|
console.error('Logger: Failed to write to log file, falling back to console only', error);
|
|
137
70
|
}
|
|
138
71
|
});
|
|
139
72
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Performs the actual file write operation.
|
|
142
|
-
*
|
|
143
|
-
* @param entry - The log entry to write
|
|
144
|
-
*/
|
|
145
73
|
async performFileWrite(entry) {
|
|
146
74
|
if (!this.logFilePath)
|
|
147
75
|
return;
|
|
148
|
-
// Ensure directory exists
|
|
149
76
|
const dir = dirname(this.logFilePath);
|
|
150
77
|
await fs.mkdir(dir, { recursive: true });
|
|
151
|
-
// Convert entry to JSON string
|
|
152
78
|
const jsonLine = `${JSON.stringify(entry)}\n`;
|
|
153
|
-
// Append to file
|
|
154
79
|
await fs.appendFile(this.logFilePath, jsonLine, 'utf8');
|
|
155
80
|
}
|
|
156
81
|
}
|
package/dist/utils/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/utils/Logger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,Q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|
-
"description": "MCP server for delegating tasks to specialized AI assistants in Cursor, Claude Code, Codex, Google Antigravity, Gemini, GLM, Kimi, Grok, and OpenCode",
|
|
5
|
+
"description": "MCP server for delegating tasks to specialized AI assistants in Cursor, Claude Code, Codex, Command Code, Google Antigravity, Gemini, GLM, Kimi, Grok, and OpenCode",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"grok",
|
|
31
31
|
"antigravity",
|
|
32
32
|
"opencode",
|
|
33
|
+
"command-code",
|
|
33
34
|
"llm",
|
|
34
35
|
"cli",
|
|
35
36
|
"agent-orchestration"
|
|
@@ -53,10 +54,6 @@
|
|
|
53
54
|
"watch": "tsx watch src/index.ts",
|
|
54
55
|
"test": "vitest run",
|
|
55
56
|
"test:ui": "vitest --ui",
|
|
56
|
-
"test:coverage": "vitest run --coverage",
|
|
57
|
-
"test:coverage:summary": "node scripts/show-coverage.js",
|
|
58
|
-
"test:coverage:clean": "rm -rf coverage .vitest-cache",
|
|
59
|
-
"test:coverage:fresh": "npm run test:coverage:clean && npm run test:coverage",
|
|
60
57
|
"test:watch": "vitest",
|
|
61
58
|
"typecheck:test": "tsc -p tsconfig.test.json --noEmit",
|
|
62
59
|
"format": "biome format --write src",
|
|
@@ -67,9 +64,9 @@
|
|
|
67
64
|
"check:fix": "biome check --write src",
|
|
68
65
|
"check:deps": "dpdm --no-warning --no-tree --circular --exclude \"node_modules|__tests__|\\.test\\.ts$|\\.spec\\.ts$\" --tsconfig ./tsconfig.json --transform --exit-code circular:1 src/index.ts",
|
|
69
66
|
"check:knip": "knip",
|
|
70
|
-
"check:all": "
|
|
67
|
+
"check:all": "pnpm run check && pnpm run lint && pnpm run format:check && pnpm run check:deps && pnpm run check:knip && pnpm run build && pnpm run typecheck:test && pnpm run test",
|
|
71
68
|
"cleanup:processes": "bash ./scripts/cleanup-test-processes.sh",
|
|
72
|
-
"test:safe": "
|
|
69
|
+
"test:safe": "pnpm test && pnpm run cleanup:processes",
|
|
73
70
|
"lang:ja": "node scripts/set-language.js ja",
|
|
74
71
|
"lang:en": "node scripts/set-language.js en",
|
|
75
72
|
"prepare": "husky"
|
|
@@ -80,7 +77,6 @@
|
|
|
80
77
|
"devDependencies": {
|
|
81
78
|
"@biomejs/biome": "^2.5.2",
|
|
82
79
|
"@types/node": "^26.1.0",
|
|
83
|
-
"@vitest/coverage-v8": "^4.1.10",
|
|
84
80
|
"@vitest/ui": "^4.1.10",
|
|
85
81
|
"dpdm": "^4.2.0",
|
|
86
82
|
"husky": "^9.1.7",
|
|
@@ -90,6 +86,7 @@
|
|
|
90
86
|
"typescript": "^6.0.3",
|
|
91
87
|
"vitest": "^4.1.10"
|
|
92
88
|
},
|
|
89
|
+
"packageManager": "pnpm@11.24.0",
|
|
93
90
|
"engines": {
|
|
94
91
|
"node": ">=22.22.2"
|
|
95
92
|
},
|