@mseep/mcp-agent-social 1.1.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/LICENSE +21 -0
- package/README.md +154 -0
- package/bin/mcp-agent-social +30 -0
- package/dist/api-client.d.ts +31 -0
- package/dist/api-client.d.ts.map +1 -0
- package/dist/api-client.js +212 -0
- package/dist/api-client.js.map +1 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +79 -0
- package/dist/config.js.map +1 -0
- package/dist/hooks/index.d.ts +38 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +253 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +35 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +4 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/http-server.d.ts +38 -0
- package/dist/http-server.d.ts.map +1 -0
- package/dist/http-server.js +210 -0
- package/dist/http-server.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +186 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.d.ts +44 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +281 -0
- package/dist/logger.js.map +1 -0
- package/dist/metrics.d.ts +47 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +178 -0
- package/dist/metrics.js.map +1 -0
- package/dist/middleware/error-handler.d.ts +74 -0
- package/dist/middleware/error-handler.d.ts.map +1 -0
- package/dist/middleware/error-handler.js +218 -0
- package/dist/middleware/error-handler.js.map +1 -0
- package/dist/middleware/index.d.ts +55 -0
- package/dist/middleware/index.d.ts.map +1 -0
- package/dist/middleware/index.js +91 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/timeout.d.ts +52 -0
- package/dist/middleware/timeout.d.ts.map +1 -0
- package/dist/middleware/timeout.js +189 -0
- package/dist/middleware/timeout.js.map +1 -0
- package/dist/middleware/validator.d.ts +25 -0
- package/dist/middleware/validator.d.ts.map +1 -0
- package/dist/middleware/validator.js +186 -0
- package/dist/middleware/validator.js.map +1 -0
- package/dist/prompts/analyze.d.ts +46 -0
- package/dist/prompts/analyze.d.ts.map +1 -0
- package/dist/prompts/analyze.js +351 -0
- package/dist/prompts/analyze.js.map +1 -0
- package/dist/prompts/generate.d.ts +48 -0
- package/dist/prompts/generate.d.ts.map +1 -0
- package/dist/prompts/generate.js +177 -0
- package/dist/prompts/generate.js.map +1 -0
- package/dist/prompts/index.d.ts +23 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +69 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/summarize.d.ts +32 -0
- package/dist/prompts/summarize.d.ts.map +1 -0
- package/dist/prompts/summarize.js +182 -0
- package/dist/prompts/summarize.js.map +1 -0
- package/dist/prompts/types.d.ts +34 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +24 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/resources/agents.d.ts +17 -0
- package/dist/resources/agents.d.ts.map +1 -0
- package/dist/resources/agents.js +139 -0
- package/dist/resources/agents.js.map +1 -0
- package/dist/resources/feed.d.ts +19 -0
- package/dist/resources/feed.d.ts.map +1 -0
- package/dist/resources/feed.js +138 -0
- package/dist/resources/feed.js.map +1 -0
- package/dist/resources/index.d.ts +19 -0
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +146 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/resources/posts.d.ts +17 -0
- package/dist/resources/posts.d.ts.map +1 -0
- package/dist/resources/posts.js +151 -0
- package/dist/resources/posts.js.map +1 -0
- package/dist/resources/types.d.ts +91 -0
- package/dist/resources/types.d.ts.map +1 -0
- package/dist/resources/types.js +12 -0
- package/dist/resources/types.js.map +1 -0
- package/dist/roots/index.d.ts +43 -0
- package/dist/roots/index.d.ts.map +1 -0
- package/dist/roots/index.js +131 -0
- package/dist/roots/index.js.map +1 -0
- package/dist/roots/types.d.ts +31 -0
- package/dist/roots/types.d.ts.map +1 -0
- package/dist/roots/types.js +4 -0
- package/dist/roots/types.js.map +1 -0
- package/dist/session-manager.d.ts +50 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +127 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/tools/create-post.d.ts +45 -0
- package/dist/tools/create-post.d.ts.map +1 -0
- package/dist/tools/create-post.js +119 -0
- package/dist/tools/create-post.js.map +1 -0
- package/dist/tools/index.d.ts +13 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +44 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/login.d.ts +35 -0
- package/dist/tools/login.d.ts.map +1 -0
- package/dist/tools/login.js +132 -0
- package/dist/tools/login.js.map +1 -0
- package/dist/tools/read-posts.d.ts +48 -0
- package/dist/tools/read-posts.d.ts.map +1 -0
- package/dist/tools/read-posts.js +93 -0
- package/dist/tools/read-posts.js.map +1 -0
- package/dist/types.d.ts +88 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/json.d.ts +13 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +48 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/validation.d.ts +58 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +223 -0
- package/dist/validation.js.map +1 -0
- package/package.json +70 -0
- package/src/api-client.ts +292 -0
- package/src/config.ts +92 -0
- package/src/hooks/index.ts +304 -0
- package/src/hooks/types.ts +44 -0
- package/src/http-server.ts +243 -0
- package/src/index.ts +213 -0
- package/src/logger.ts +326 -0
- package/src/metrics.ts +235 -0
- package/src/middleware/error-handler.ts +252 -0
- package/src/middleware/index.ts +112 -0
- package/src/middleware/timeout.ts +216 -0
- package/src/middleware/validator.ts +216 -0
- package/src/prompts/analyze.ts +404 -0
- package/src/prompts/generate.ts +217 -0
- package/src/prompts/index.ts +121 -0
- package/src/prompts/summarize.ts +217 -0
- package/src/prompts/types.ts +44 -0
- package/src/resources/agents.ts +165 -0
- package/src/resources/feed.ts +169 -0
- package/src/resources/index.ts +210 -0
- package/src/resources/posts.ts +179 -0
- package/src/resources/types.ts +104 -0
- package/src/roots/index.ts +166 -0
- package/src/roots/types.ts +36 -0
- package/src/session-manager.ts +149 -0
- package/src/tools/create-post.ts +154 -0
- package/src/tools/index.ts +70 -0
- package/src/tools/login.ts +169 -0
- package/src/tools/read-posts.ts +120 -0
- package/src/types.ts +107 -0
- package/src/utils/json.ts +46 -0
- package/src/validation.ts +322 -0
- package/tsconfig.json +22 -0
package/dist/metrics.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
// ABOUTME: Basic performance monitoring and metrics collection
|
|
2
|
+
// ABOUTME: Tracks operation timings, memory usage, and system health
|
|
3
|
+
export class MetricsCollector {
|
|
4
|
+
static instance;
|
|
5
|
+
metrics;
|
|
6
|
+
startTime;
|
|
7
|
+
sessionCount;
|
|
8
|
+
activeOperations;
|
|
9
|
+
cleanupInterval = null;
|
|
10
|
+
OPERATION_TIMEOUT = 5 * 60 * 1000; // 5 minutes
|
|
11
|
+
constructor() {
|
|
12
|
+
this.metrics = new Map();
|
|
13
|
+
this.startTime = Date.now();
|
|
14
|
+
this.sessionCount = 0;
|
|
15
|
+
this.activeOperations = new Map();
|
|
16
|
+
// Set up periodic cleanup of stale operations
|
|
17
|
+
this.cleanupInterval = setInterval(() => this.cleanupStaleOperations(), 60000); // Every minute
|
|
18
|
+
// Allow process to exit even if interval is active (for tests)
|
|
19
|
+
if (this.cleanupInterval.unref) {
|
|
20
|
+
this.cleanupInterval.unref();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
static getInstance() {
|
|
24
|
+
if (!MetricsCollector.instance) {
|
|
25
|
+
MetricsCollector.instance = new MetricsCollector();
|
|
26
|
+
}
|
|
27
|
+
return MetricsCollector.instance;
|
|
28
|
+
}
|
|
29
|
+
// Start tracking an operation
|
|
30
|
+
startOperation(operationName) {
|
|
31
|
+
const operationId = `${operationName}_${Date.now()}_${Math.random()}`;
|
|
32
|
+
this.activeOperations.set(operationId, Date.now());
|
|
33
|
+
return operationId;
|
|
34
|
+
}
|
|
35
|
+
// End tracking an operation
|
|
36
|
+
endOperation(operationId, success = true) {
|
|
37
|
+
const startTime = this.activeOperations.get(operationId);
|
|
38
|
+
if (!startTime) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const duration = Date.now() - startTime;
|
|
42
|
+
this.activeOperations.delete(operationId);
|
|
43
|
+
// Extract operation name from ID
|
|
44
|
+
const operationName = operationId.split('_')[0];
|
|
45
|
+
this.recordOperation(operationName, duration, success);
|
|
46
|
+
}
|
|
47
|
+
// Cleanup stale operations that have been running too long
|
|
48
|
+
cleanupStaleOperations() {
|
|
49
|
+
const now = Date.now();
|
|
50
|
+
const staleOperations = [];
|
|
51
|
+
for (const [id, startTime] of this.activeOperations.entries()) {
|
|
52
|
+
if (now - startTime > this.OPERATION_TIMEOUT) {
|
|
53
|
+
staleOperations.push(id);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// Remove stale operations and record them as timed out
|
|
57
|
+
for (const id of staleOperations) {
|
|
58
|
+
this.activeOperations.delete(id);
|
|
59
|
+
const operationName = id.split('_')[0];
|
|
60
|
+
this.recordOperation(operationName, this.OPERATION_TIMEOUT, false, 'timeout');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// Record an operation metric
|
|
64
|
+
recordOperation(name, duration, success, _reason) {
|
|
65
|
+
let metrics = this.metrics.get(name);
|
|
66
|
+
if (!metrics) {
|
|
67
|
+
metrics = {
|
|
68
|
+
count: 0,
|
|
69
|
+
totalDuration: 0,
|
|
70
|
+
minDuration: Number.POSITIVE_INFINITY,
|
|
71
|
+
maxDuration: 0,
|
|
72
|
+
averageDuration: 0,
|
|
73
|
+
lastDuration: 0,
|
|
74
|
+
errors: 0,
|
|
75
|
+
};
|
|
76
|
+
this.metrics.set(name, metrics);
|
|
77
|
+
}
|
|
78
|
+
metrics.count++;
|
|
79
|
+
metrics.totalDuration += duration;
|
|
80
|
+
metrics.minDuration = Math.min(metrics.minDuration, duration);
|
|
81
|
+
metrics.maxDuration = Math.max(metrics.maxDuration, duration);
|
|
82
|
+
metrics.averageDuration = metrics.totalDuration / metrics.count;
|
|
83
|
+
metrics.lastDuration = duration;
|
|
84
|
+
if (!success) {
|
|
85
|
+
metrics.errors++;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
// Session management metrics
|
|
89
|
+
incrementSessionCount() {
|
|
90
|
+
this.sessionCount++;
|
|
91
|
+
}
|
|
92
|
+
decrementSessionCount() {
|
|
93
|
+
this.sessionCount = Math.max(0, this.sessionCount - 1);
|
|
94
|
+
}
|
|
95
|
+
getSessionCount() {
|
|
96
|
+
return this.sessionCount;
|
|
97
|
+
}
|
|
98
|
+
// Get metrics for a specific operation
|
|
99
|
+
getOperationMetrics(operationName) {
|
|
100
|
+
return this.metrics.get(operationName);
|
|
101
|
+
}
|
|
102
|
+
// Get all metrics
|
|
103
|
+
getAllMetrics() {
|
|
104
|
+
const result = {};
|
|
105
|
+
this.metrics.forEach((value, key) => {
|
|
106
|
+
result[key] = { ...value };
|
|
107
|
+
});
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
// Get system metrics
|
|
111
|
+
getSystemMetrics() {
|
|
112
|
+
return {
|
|
113
|
+
uptime: Math.floor((Date.now() - this.startTime) / 1000),
|
|
114
|
+
memoryUsage: process.memoryUsage(),
|
|
115
|
+
sessionCount: this.sessionCount,
|
|
116
|
+
activeOperations: this.activeOperations.size,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
// Get formatted summary
|
|
120
|
+
getSummary() {
|
|
121
|
+
const system = this.getSystemMetrics();
|
|
122
|
+
const operations = this.getAllMetrics();
|
|
123
|
+
let summary = '=== System Metrics ===\n';
|
|
124
|
+
summary += `Uptime: ${system.uptime}s\n`;
|
|
125
|
+
summary += `Memory (RSS): ${Math.round(system.memoryUsage.rss / 1024 / 1024)}MB\n`;
|
|
126
|
+
summary += `Memory (Heap Used): ${Math.round(system.memoryUsage.heapUsed / 1024 / 1024)}MB\n`;
|
|
127
|
+
summary += `Active Sessions: ${system.sessionCount}\n`;
|
|
128
|
+
summary += `Active Operations: ${system.activeOperations}\n\n`;
|
|
129
|
+
summary += '=== Operation Metrics ===\n';
|
|
130
|
+
for (const [name, metrics] of Object.entries(operations)) {
|
|
131
|
+
summary += `${name}:\n`;
|
|
132
|
+
summary += ` Count: ${metrics.count}\n`;
|
|
133
|
+
summary += ` Avg Duration: ${Math.round(metrics.averageDuration)}ms\n`;
|
|
134
|
+
summary += ` Min Duration: ${Math.round(metrics.minDuration)}ms\n`;
|
|
135
|
+
summary += ` Max Duration: ${Math.round(metrics.maxDuration)}ms\n`;
|
|
136
|
+
summary += ` Error Rate: ${((metrics.errors / metrics.count) * 100).toFixed(2)}%\n`;
|
|
137
|
+
}
|
|
138
|
+
return summary;
|
|
139
|
+
}
|
|
140
|
+
// Reset all metrics (useful for testing)
|
|
141
|
+
reset() {
|
|
142
|
+
this.metrics.clear();
|
|
143
|
+
this.activeOperations.clear();
|
|
144
|
+
this.sessionCount = 0;
|
|
145
|
+
// Clear the cleanup interval when resetting
|
|
146
|
+
if (this.cleanupInterval) {
|
|
147
|
+
clearInterval(this.cleanupInterval);
|
|
148
|
+
this.cleanupInterval = setInterval(() => this.cleanupStaleOperations(), 60000);
|
|
149
|
+
// Allow process to exit even if interval is active (for tests)
|
|
150
|
+
if (this.cleanupInterval.unref) {
|
|
151
|
+
this.cleanupInterval.unref();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Shutdown the metrics collector (for cleanup)
|
|
156
|
+
shutdown() {
|
|
157
|
+
if (this.cleanupInterval) {
|
|
158
|
+
clearInterval(this.cleanupInterval);
|
|
159
|
+
this.cleanupInterval = null;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Export singleton instance
|
|
164
|
+
export const metrics = MetricsCollector.getInstance();
|
|
165
|
+
// Helper function for timing async operations
|
|
166
|
+
export async function withMetrics(operationName, operation) {
|
|
167
|
+
const operationId = metrics.startOperation(operationName);
|
|
168
|
+
try {
|
|
169
|
+
const result = await operation();
|
|
170
|
+
metrics.endOperation(operationId, true);
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
catch (error) {
|
|
174
|
+
metrics.endOperation(operationId, false);
|
|
175
|
+
throw error;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
//# sourceMappingURL=metrics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrics.js","sourceRoot":"","sources":["../src/metrics.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,qEAAqE;AAmBrE,MAAM,OAAO,gBAAgB;IACnB,MAAM,CAAC,QAAQ,CAAmB;IAClC,OAAO,CAAgC;IACvC,SAAS,CAAS;IAClB,YAAY,CAAS;IACrB,gBAAgB,CAAsB;IACtC,eAAe,GAA0C,IAAI,CAAC;IACrD,iBAAiB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,YAAY;IAEhE;QACE,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC;QACtB,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;QAElC,8CAA8C;QAC9C,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,sBAAsB,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,eAAe;QAC/F,+DAA+D;QAC/D,IAAI,IAAI,CAAC,eAAe,CAA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AAC;QACf,OAAO,CAAC,YAAY,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzC,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare class McpValidationError extends Error {
|
|
2
|
+
details?: any | undefined;
|
|
3
|
+
constructor(message: string, details?: any | undefined);
|
|
4
|
+
}
|
|
5
|
+
export declare class McpAuthenticationError extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
8
|
+
export declare class McpRateLimitError extends Error {
|
|
9
|
+
retryAfter?: number | undefined;
|
|
10
|
+
constructor(message: string, retryAfter?: number | undefined);
|
|
11
|
+
}
|
|
12
|
+
export declare class McpTimeoutError extends Error {
|
|
13
|
+
timeout?: number | undefined;
|
|
14
|
+
constructor(message: string, timeout?: number | undefined);
|
|
15
|
+
}
|
|
16
|
+
export declare class McpMethodNotFoundError extends Error {
|
|
17
|
+
method?: string | undefined;
|
|
18
|
+
constructor(message: string, method?: string | undefined);
|
|
19
|
+
}
|
|
20
|
+
export interface ErrorContext {
|
|
21
|
+
sessionId: string;
|
|
22
|
+
requestId: string;
|
|
23
|
+
method: string;
|
|
24
|
+
startTime: number;
|
|
25
|
+
}
|
|
26
|
+
export interface McpError {
|
|
27
|
+
code: number;
|
|
28
|
+
message: string;
|
|
29
|
+
data?: any;
|
|
30
|
+
}
|
|
31
|
+
export declare class ErrorHandler {
|
|
32
|
+
private errorCount;
|
|
33
|
+
private errorsByType;
|
|
34
|
+
private errorsByMethod;
|
|
35
|
+
/**
|
|
36
|
+
* Handle and enrich errors with context
|
|
37
|
+
*/
|
|
38
|
+
handleError(error: any, request: any, context: ErrorContext): Promise<Error>;
|
|
39
|
+
/**
|
|
40
|
+
* Create an enriched error with proper MCP formatting
|
|
41
|
+
*/
|
|
42
|
+
private createEnrichedError;
|
|
43
|
+
/**
|
|
44
|
+
* Format error for MCP response
|
|
45
|
+
*/
|
|
46
|
+
formatMcpError(error: any): McpError;
|
|
47
|
+
/**
|
|
48
|
+
* Check if error is recoverable
|
|
49
|
+
*/
|
|
50
|
+
isRecoverableError(error: any): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get error statistics
|
|
53
|
+
*/
|
|
54
|
+
getStats(): {
|
|
55
|
+
totalErrors: number;
|
|
56
|
+
errorsByType: {
|
|
57
|
+
[k: string]: number;
|
|
58
|
+
};
|
|
59
|
+
errorsByMethod: {
|
|
60
|
+
[k: string]: number;
|
|
61
|
+
};
|
|
62
|
+
mostCommonError: string | null;
|
|
63
|
+
errorRate: number;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get the most common error type
|
|
67
|
+
*/
|
|
68
|
+
private getMostCommonError;
|
|
69
|
+
/**
|
|
70
|
+
* Clear error statistics
|
|
71
|
+
*/
|
|
72
|
+
clearStats(): void;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=error-handler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.d.ts","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAmB,SAAQ,KAAK;IAGlC,OAAO,CAAC,EAAE,GAAG;gBADpB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,GAAG,YAAA;CAKvB;AAED,qBAAa,sBAAuB,SAAQ,KAAK;gBACnC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAGjC,UAAU,CAAC,EAAE,MAAM;gBAD1B,OAAO,EAAE,MAAM,EACR,UAAU,CAAC,EAAE,MAAM,YAAA;CAK7B;AAED,qBAAa,eAAgB,SAAQ,KAAK;IAG/B,OAAO,CAAC,EAAE,MAAM;gBADvB,OAAO,EAAE,MAAM,EACR,OAAO,CAAC,EAAE,MAAM,YAAA;CAK1B;AAED,qBAAa,sBAAuB,SAAQ,KAAK;IAGtC,MAAM,CAAC,EAAE,MAAM;gBADtB,OAAO,EAAE,MAAM,EACR,MAAM,CAAC,EAAE,MAAM,YAAA;CAKzB;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,GAAG,CAAC;CACZ;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,YAAY,CAA6B;IACjD,OAAO,CAAC,cAAc,CAA6B;IAEnD;;OAEG;IACG,WAAW,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC;IAyBlF;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkF3B;;OAEG;IACH,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,QAAQ;IAQpC;;OAEG;IACH,kBAAkB,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO;IAYvC;;OAEG;IACH,QAAQ;;;;;;;;;;;IAUR;;OAEG;IACH,OAAO,CAAC,kBAAkB;IAgB1B;;OAEG;IACH,UAAU,IAAI,IAAI;CAMnB"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
// ABOUTME: Enhanced error handling with context enrichment and proper MCP error formatting
|
|
2
|
+
// ABOUTME: Provides structured error responses and comprehensive error tracking
|
|
3
|
+
import { logger } from '../logger.js';
|
|
4
|
+
// Custom error classes for better type safety
|
|
5
|
+
export class McpValidationError extends Error {
|
|
6
|
+
details;
|
|
7
|
+
constructor(message, details) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.details = details;
|
|
10
|
+
this.name = 'McpValidationError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export class McpAuthenticationError extends Error {
|
|
14
|
+
constructor(message) {
|
|
15
|
+
super(message);
|
|
16
|
+
this.name = 'McpAuthenticationError';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class McpRateLimitError extends Error {
|
|
20
|
+
retryAfter;
|
|
21
|
+
constructor(message, retryAfter) {
|
|
22
|
+
super(message);
|
|
23
|
+
this.retryAfter = retryAfter;
|
|
24
|
+
this.name = 'McpRateLimitError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class McpTimeoutError extends Error {
|
|
28
|
+
timeout;
|
|
29
|
+
constructor(message, timeout) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.timeout = timeout;
|
|
32
|
+
this.name = 'McpTimeoutError';
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class McpMethodNotFoundError extends Error {
|
|
36
|
+
method;
|
|
37
|
+
constructor(message, method) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.method = method;
|
|
40
|
+
this.name = 'McpMethodNotFoundError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export class ErrorHandler {
|
|
44
|
+
errorCount = 0;
|
|
45
|
+
errorsByType = new Map();
|
|
46
|
+
errorsByMethod = new Map();
|
|
47
|
+
/**
|
|
48
|
+
* Handle and enrich errors with context
|
|
49
|
+
*/
|
|
50
|
+
async handleError(error, request, context) {
|
|
51
|
+
this.errorCount++;
|
|
52
|
+
const errorType = error.constructor.name;
|
|
53
|
+
this.errorsByType.set(errorType, (this.errorsByType.get(errorType) || 0) + 1);
|
|
54
|
+
this.errorsByMethod.set(context.method, (this.errorsByMethod.get(context.method) || 0) + 1);
|
|
55
|
+
// Create enriched error
|
|
56
|
+
const enrichedError = this.createEnrichedError(error, request, context);
|
|
57
|
+
// Log error with context
|
|
58
|
+
logger.error('Request processing error', {
|
|
59
|
+
error: enrichedError.message,
|
|
60
|
+
errorType,
|
|
61
|
+
method: context.method,
|
|
62
|
+
sessionId: context.sessionId,
|
|
63
|
+
requestId: context.requestId,
|
|
64
|
+
processingTime: Date.now() - context.startTime,
|
|
65
|
+
originalError: error.message,
|
|
66
|
+
stack: error.stack,
|
|
67
|
+
});
|
|
68
|
+
return enrichedError;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Create an enriched error with proper MCP formatting
|
|
72
|
+
*/
|
|
73
|
+
createEnrichedError(error, request, context) {
|
|
74
|
+
let mcpError;
|
|
75
|
+
// Handle known error types using proper type checking
|
|
76
|
+
if (error.code && typeof error.code === 'number') {
|
|
77
|
+
// Already an MCP error
|
|
78
|
+
mcpError = {
|
|
79
|
+
code: error.code,
|
|
80
|
+
message: error.message,
|
|
81
|
+
data: error.data,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
else if (error instanceof McpValidationError) {
|
|
85
|
+
mcpError = {
|
|
86
|
+
code: -32602, // Invalid params
|
|
87
|
+
message: 'Request validation failed',
|
|
88
|
+
data: {
|
|
89
|
+
originalMessage: error.message,
|
|
90
|
+
details: error.details,
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
else if (error instanceof McpTimeoutError) {
|
|
95
|
+
mcpError = {
|
|
96
|
+
code: -32603, // Internal error
|
|
97
|
+
message: 'Request timed out',
|
|
98
|
+
data: {
|
|
99
|
+
timeout: error.timeout,
|
|
100
|
+
method: context.method,
|
|
101
|
+
},
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
else if (error instanceof McpMethodNotFoundError) {
|
|
105
|
+
mcpError = {
|
|
106
|
+
code: -32601, // Method not found
|
|
107
|
+
message: 'Method not found',
|
|
108
|
+
data: {
|
|
109
|
+
method: error.method || request.method,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
else if (error instanceof McpAuthenticationError) {
|
|
114
|
+
mcpError = {
|
|
115
|
+
code: -32600, // Invalid request
|
|
116
|
+
message: 'Unauthorized request',
|
|
117
|
+
data: {
|
|
118
|
+
sessionId: context.sessionId,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
else if (error instanceof McpRateLimitError) {
|
|
123
|
+
mcpError = {
|
|
124
|
+
code: -32603, // Internal error
|
|
125
|
+
message: 'Rate limit exceeded',
|
|
126
|
+
data: {
|
|
127
|
+
retryAfter: error.retryAfter || 60,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// Generic internal error
|
|
133
|
+
mcpError = {
|
|
134
|
+
code: -32603, // Internal error
|
|
135
|
+
message: 'Internal server error',
|
|
136
|
+
data: {
|
|
137
|
+
originalMessage: error.message,
|
|
138
|
+
type: error.constructor.name,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// Create final error object
|
|
143
|
+
const finalError = new Error(mcpError.message);
|
|
144
|
+
finalError.code = mcpError.code;
|
|
145
|
+
finalError.data = {
|
|
146
|
+
...mcpError.data,
|
|
147
|
+
context: {
|
|
148
|
+
sessionId: context.sessionId,
|
|
149
|
+
requestId: context.requestId,
|
|
150
|
+
method: context.method,
|
|
151
|
+
timestamp: new Date().toISOString(),
|
|
152
|
+
processingTime: Date.now() - context.startTime,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
return finalError;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Format error for MCP response
|
|
159
|
+
*/
|
|
160
|
+
formatMcpError(error) {
|
|
161
|
+
return {
|
|
162
|
+
code: error.code || -32603,
|
|
163
|
+
message: error.message || 'Internal server error',
|
|
164
|
+
data: error.data || null,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Check if error is recoverable
|
|
169
|
+
*/
|
|
170
|
+
isRecoverableError(error) {
|
|
171
|
+
if (!error.code)
|
|
172
|
+
return false;
|
|
173
|
+
const recoverableCodes = [
|
|
174
|
+
-32602, // Invalid params - client can fix
|
|
175
|
+
-32601, // Method not found - client can fix
|
|
176
|
+
-32600, // Invalid request - client can fix
|
|
177
|
+
];
|
|
178
|
+
return recoverableCodes.includes(error.code);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Get error statistics
|
|
182
|
+
*/
|
|
183
|
+
getStats() {
|
|
184
|
+
return {
|
|
185
|
+
totalErrors: this.errorCount,
|
|
186
|
+
errorsByType: Object.fromEntries(this.errorsByType),
|
|
187
|
+
errorsByMethod: Object.fromEntries(this.errorsByMethod),
|
|
188
|
+
mostCommonError: this.getMostCommonError(),
|
|
189
|
+
errorRate: this.errorCount, // This would be divided by total requests in a real system
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Get the most common error type
|
|
194
|
+
*/
|
|
195
|
+
getMostCommonError() {
|
|
196
|
+
if (this.errorsByType.size === 0)
|
|
197
|
+
return null;
|
|
198
|
+
let maxCount = 0;
|
|
199
|
+
let mostCommon = '';
|
|
200
|
+
for (const [type, count] of this.errorsByType) {
|
|
201
|
+
if (count > maxCount) {
|
|
202
|
+
maxCount = count;
|
|
203
|
+
mostCommon = type;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return mostCommon;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Clear error statistics
|
|
210
|
+
*/
|
|
211
|
+
clearStats() {
|
|
212
|
+
this.errorCount = 0;
|
|
213
|
+
this.errorsByType.clear();
|
|
214
|
+
this.errorsByMethod.clear();
|
|
215
|
+
logger.info('Error statistics cleared');
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/middleware/error-handler.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,gFAAgF;AAEhF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,8CAA8C;AAC9C,MAAM,OAAO,kBAAmB,SAAQ,KAAK;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gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO;YACL,WAAW,EAAE,IAAI,CAAC,UAAU;YAC5B,YAAY,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC;YACnD,cAAc,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC;YACvD,eAAe,EAAE,IAAI,CAAC,kBAAkB,EAAE;YAC1C,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,2DAA2D;SACxF,CAAC;IACJ,CAAC;IAED;;OAEG;IACK,kBAAkB;QACxB,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAE9C,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,IAAI,UAAU,GAAG,EAAE,CAAC;QAEpB,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC9C,IAAI,KAAK,GAAG,QAAQ,EAAE,CAAC;gBACrB,QAAQ,GAAG,KAAK,CAAC;gBACjB,UAAU,GAAG,IAAI,CAAC;YACpB,CAAC;QACH,CAAC;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC;QACpB,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC1B,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;QAC5B,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface MiddlewareContext {
|
|
2
|
+
sessionId: string;
|
|
3
|
+
startTime: number;
|
|
4
|
+
requestId: string;
|
|
5
|
+
method: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class ProtocolMiddleware {
|
|
8
|
+
private validator;
|
|
9
|
+
private errorHandler;
|
|
10
|
+
private timeoutManager;
|
|
11
|
+
constructor();
|
|
12
|
+
/**
|
|
13
|
+
* Process request through validation and preprocessing
|
|
14
|
+
*/
|
|
15
|
+
processRequest(request: any, context: MiddlewareContext): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
* Process response through enrichment and validation
|
|
18
|
+
*/
|
|
19
|
+
processResponse(response: any, request: any, context: MiddlewareContext): Promise<any>;
|
|
20
|
+
private doProcessRequest;
|
|
21
|
+
/**
|
|
22
|
+
* Get middleware statistics
|
|
23
|
+
*/
|
|
24
|
+
getStats(): {
|
|
25
|
+
validator: {
|
|
26
|
+
totalValidations: number;
|
|
27
|
+
validationErrors: number;
|
|
28
|
+
successRate: number;
|
|
29
|
+
};
|
|
30
|
+
errorHandler: {
|
|
31
|
+
totalErrors: number;
|
|
32
|
+
errorsByType: {
|
|
33
|
+
[k: string]: number;
|
|
34
|
+
};
|
|
35
|
+
errorsByMethod: {
|
|
36
|
+
[k: string]: number;
|
|
37
|
+
};
|
|
38
|
+
mostCommonError: string | null;
|
|
39
|
+
errorRate: number;
|
|
40
|
+
};
|
|
41
|
+
timeoutManager: {
|
|
42
|
+
totalTimeouts: number;
|
|
43
|
+
activeTimeouts: number;
|
|
44
|
+
config: {
|
|
45
|
+
defaultTimeout: number;
|
|
46
|
+
maxTimeout: number;
|
|
47
|
+
methodTimeoutCount: number;
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export { RequestValidator } from './validator.js';
|
|
53
|
+
export { ErrorHandler } from './error-handler.js';
|
|
54
|
+
export { TimeoutManager } from './timeout.js';
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,SAAS,CAAmB;IACpC,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,cAAc,CAAiB;;IAUvC;;OAEG;IACG,cAAc,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;IA6B5E;;OAEG;IACG,eAAe,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,GAAG,CAAC;YAmB9E,gBAAgB;IAe9B;;OAEG;IACH,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;CAOT;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// ABOUTME: Enhanced middleware for protocol-level validation, error handling, and timeouts
|
|
2
|
+
// ABOUTME: Provides comprehensive request/response processing and error management
|
|
3
|
+
import { logger } from '../logger.js';
|
|
4
|
+
import { ErrorHandler } from './error-handler.js';
|
|
5
|
+
import { TimeoutManager } from './timeout.js';
|
|
6
|
+
import { RequestValidator } from './validator.js';
|
|
7
|
+
export class ProtocolMiddleware {
|
|
8
|
+
validator;
|
|
9
|
+
errorHandler;
|
|
10
|
+
timeoutManager;
|
|
11
|
+
constructor() {
|
|
12
|
+
this.validator = new RequestValidator();
|
|
13
|
+
this.errorHandler = new ErrorHandler();
|
|
14
|
+
this.timeoutManager = new TimeoutManager();
|
|
15
|
+
logger.info('Protocol middleware initialized');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Process request through validation and preprocessing
|
|
19
|
+
*/
|
|
20
|
+
async processRequest(request, context) {
|
|
21
|
+
const startTime = Date.now();
|
|
22
|
+
try {
|
|
23
|
+
// 1. Validate request structure
|
|
24
|
+
await this.validator.validateRequest(request);
|
|
25
|
+
// 2. Set up timeout
|
|
26
|
+
const timeoutPromise = this.timeoutManager.createTimeout(context.method);
|
|
27
|
+
// 3. Process with timeout
|
|
28
|
+
const processedRequest = await Promise.race([
|
|
29
|
+
this.doProcessRequest(request, context),
|
|
30
|
+
timeoutPromise,
|
|
31
|
+
]);
|
|
32
|
+
logger.debug('Request processed successfully', {
|
|
33
|
+
method: context.method,
|
|
34
|
+
sessionId: context.sessionId,
|
|
35
|
+
processingTime: Date.now() - startTime,
|
|
36
|
+
});
|
|
37
|
+
return processedRequest;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
const processedError = await this.errorHandler.handleError(error, request, context);
|
|
41
|
+
throw processedError;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Process response through enrichment and validation
|
|
46
|
+
*/
|
|
47
|
+
async processResponse(response, request, context) {
|
|
48
|
+
try {
|
|
49
|
+
// Validate response structure
|
|
50
|
+
await this.validator.validateResponse(response, request.method);
|
|
51
|
+
// Add processing metadata
|
|
52
|
+
const enrichedResponse = {
|
|
53
|
+
...response,
|
|
54
|
+
_processingTime: Date.now() - context.startTime,
|
|
55
|
+
_requestId: context.requestId,
|
|
56
|
+
};
|
|
57
|
+
return enrichedResponse;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const processedError = await this.errorHandler.handleError(error, request, context);
|
|
61
|
+
throw processedError;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async doProcessRequest(request, context) {
|
|
65
|
+
// Add request metadata
|
|
66
|
+
const enrichedRequest = {
|
|
67
|
+
...request,
|
|
68
|
+
_metadata: {
|
|
69
|
+
requestId: context.requestId,
|
|
70
|
+
sessionId: context.sessionId,
|
|
71
|
+
timestamp: new Date().toISOString(),
|
|
72
|
+
processingStarted: context.startTime,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
return enrichedRequest;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Get middleware statistics
|
|
79
|
+
*/
|
|
80
|
+
getStats() {
|
|
81
|
+
return {
|
|
82
|
+
validator: this.validator.getStats(),
|
|
83
|
+
errorHandler: this.errorHandler.getStats(),
|
|
84
|
+
timeoutManager: this.timeoutManager.getStats(),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export { RequestValidator } from './validator.js';
|
|
89
|
+
export { ErrorHandler } from './error-handler.js';
|
|
90
|
+
export { TimeoutManager } from './timeout.js';
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/middleware/index.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,mFAAmF;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AASlD,MAAM,OAAO,kBAAkB;IACrB,SAAS,CAAmB;IAC5B,YAAY,CAAe;IAC3B,cAAc,CAAiB;IAEvC;QACE,IAAI,CAAC,SAAS,GAAG,IAAI,gBAAgB,EAAE,CAAC;QACxC,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;QACvC,IAAI,CAAC,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC;QAE3C,MAAM,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,cAAc,CAAC,OAAY,EAAE,OAA0B;QAC3D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