@west10tech/constructionwire-mcp 1.0.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 +177 -0
- package/dist/clients/constructionwire-client.d.ts +110 -0
- package/dist/clients/constructionwire-client.d.ts.map +1 -0
- package/dist/clients/constructionwire-client.js +16746 -0
- package/dist/clients/constructionwire-client.js.map +1 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +63 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +165 -0
- package/dist/index.js.map +1 -0
- package/dist/services/log-batcher.d.ts +44 -0
- package/dist/services/log-batcher.d.ts.map +1 -0
- package/dist/services/log-batcher.js +81 -0
- package/dist/services/log-batcher.js.map +1 -0
- package/dist/services/log-shipper.d.ts +104 -0
- package/dist/services/log-shipper.d.ts.map +1 -0
- package/dist/services/log-shipper.js +384 -0
- package/dist/services/log-shipper.js.map +1 -0
- package/dist/services/logger.d.ts +92 -0
- package/dist/services/logger.d.ts.map +1 -0
- package/dist/services/logger.js +224 -0
- package/dist/services/logger.js.map +1 -0
- package/dist/services/progress-reporter.d.ts +64 -0
- package/dist/services/progress-reporter.d.ts.map +1 -0
- package/dist/services/progress-reporter.js +192 -0
- package/dist/services/progress-reporter.js.map +1 -0
- package/dist/services/request-tracker.d.ts +55 -0
- package/dist/services/request-tracker.d.ts.map +1 -0
- package/dist/services/request-tracker.js +184 -0
- package/dist/services/request-tracker.js.map +1 -0
- package/dist/tools/constructionwire-tools.d.ts +23 -0
- package/dist/tools/constructionwire-tools.d.ts.map +1 -0
- package/dist/tools/constructionwire-tools.js +8973 -0
- package/dist/tools/constructionwire-tools.js.map +1 -0
- package/dist/types.d.ts +25 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LogShipper - Centralized log shipping service for constructionwire-mcp
|
|
3
|
+
* Sends logs to the centralized logging API endpoint with batching and retry logic
|
|
4
|
+
*/
|
|
5
|
+
export class LogShipper {
|
|
6
|
+
constructor(config) {
|
|
7
|
+
this.logQueue = [];
|
|
8
|
+
this.flushTimer = null;
|
|
9
|
+
this.isShuttingDown = false;
|
|
10
|
+
this.lastSuccessfulFlush = 0;
|
|
11
|
+
this.config = config;
|
|
12
|
+
if (!this.config.enabled) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
this.validateConfig();
|
|
16
|
+
this.startFlushTimer();
|
|
17
|
+
// Log initialization
|
|
18
|
+
this.logLocally('INFO', 'LogShipper initialized', {
|
|
19
|
+
endpoint: this.config.endpoint,
|
|
20
|
+
batchSize: this.config.batchSize,
|
|
21
|
+
flushInterval: this.config.flushInterval,
|
|
22
|
+
maxRetries: this.config.maxRetries
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
validateConfig() {
|
|
26
|
+
if (!this.config.endpoint) {
|
|
27
|
+
throw new Error('LogShipper: endpoint is required');
|
|
28
|
+
}
|
|
29
|
+
// API key validation based on requireApiKey flag
|
|
30
|
+
if (this.config.requireApiKey && !this.config.apiKey) {
|
|
31
|
+
throw new Error('LogShipper: apiKey is required when requireApiKey is true');
|
|
32
|
+
}
|
|
33
|
+
// Warning for missing API key during transition period
|
|
34
|
+
if (!this.config.apiKey && !this.config.requireApiKey) {
|
|
35
|
+
this.logLocally('WARN', 'API key not configured. Log shipping will work now but will require an API key in the future.', {
|
|
36
|
+
help: 'Set LOG_INGESTION_API_KEY environment variable to prepare for future requirements'
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
if (!this.config.endpoint.startsWith('https://')) {
|
|
40
|
+
throw new Error('LogShipper: endpoint must use HTTPS');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
startFlushTimer() {
|
|
44
|
+
if (this.flushTimer) {
|
|
45
|
+
clearInterval(this.flushTimer);
|
|
46
|
+
}
|
|
47
|
+
this.flushTimer = setInterval(() => {
|
|
48
|
+
this.flush().catch(error => {
|
|
49
|
+
this.logLocally('ERROR', 'Scheduled flush failed', {
|
|
50
|
+
error: error.message,
|
|
51
|
+
queueSize: this.logQueue.length
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}, this.config.flushInterval);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add a log entry to the queue
|
|
58
|
+
*/
|
|
59
|
+
addLog(logEntry) {
|
|
60
|
+
if (!this.config.enabled || this.isShuttingDown) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
this.logQueue.push(logEntry);
|
|
64
|
+
// Trigger immediate flush if batch size reached
|
|
65
|
+
if (this.logQueue.length >= this.config.batchSize) {
|
|
66
|
+
this.flush().catch(error => {
|
|
67
|
+
this.logLocally('ERROR', 'Immediate flush failed', {
|
|
68
|
+
error: error.message,
|
|
69
|
+
queueSize: this.logQueue.length
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Flush all queued logs to the endpoint
|
|
76
|
+
*/
|
|
77
|
+
async flush() {
|
|
78
|
+
if (!this.config.enabled || this.logQueue.length === 0) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const batch = this.logQueue.splice(0, this.config.batchSize);
|
|
82
|
+
try {
|
|
83
|
+
await this.sendLogsWithRetry(batch);
|
|
84
|
+
this.lastSuccessfulFlush = Date.now();
|
|
85
|
+
this.logLocally('DEBUG', 'Logs shipped successfully', {
|
|
86
|
+
batchSize: batch.length,
|
|
87
|
+
queueRemaining: this.logQueue.length,
|
|
88
|
+
lastFlush: new Date(this.lastSuccessfulFlush).toISOString()
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
// Return logs to queue on failure
|
|
93
|
+
this.logQueue.unshift(...batch);
|
|
94
|
+
this.logLocally('ERROR', 'Failed to ship logs after retries', {
|
|
95
|
+
error: error instanceof Error ? error.message : String(error),
|
|
96
|
+
batchSize: batch.length,
|
|
97
|
+
queueSize: this.logQueue.length
|
|
98
|
+
});
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Send logs with retry logic
|
|
104
|
+
*/
|
|
105
|
+
async sendLogsWithRetry(logs) {
|
|
106
|
+
for (let attempt = 1; attempt <= this.config.maxRetries; attempt++) {
|
|
107
|
+
try {
|
|
108
|
+
await this.sendLogs(logs);
|
|
109
|
+
return; // Success
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
const status = error.status || error.response?.status;
|
|
113
|
+
// Don't retry on client errors (4xx except 429)
|
|
114
|
+
if (status >= 400 && status < 500 && status !== 429) {
|
|
115
|
+
this.logLocally('ERROR', 'Client error - not retrying', {
|
|
116
|
+
status,
|
|
117
|
+
error: error.message,
|
|
118
|
+
attempt
|
|
119
|
+
});
|
|
120
|
+
throw error;
|
|
121
|
+
}
|
|
122
|
+
// On last attempt, throw the error
|
|
123
|
+
if (attempt === this.config.maxRetries) {
|
|
124
|
+
this.logLocally('ERROR', 'Max retries exceeded', {
|
|
125
|
+
status,
|
|
126
|
+
error: error.message,
|
|
127
|
+
attempts: attempt
|
|
128
|
+
});
|
|
129
|
+
throw error;
|
|
130
|
+
}
|
|
131
|
+
// Calculate delay with exponential backoff
|
|
132
|
+
const baseDelay = status === 429 ? 1000 : 500; // Longer delay for rate limits
|
|
133
|
+
const delay = baseDelay * Math.pow(2, attempt - 1);
|
|
134
|
+
this.logLocally('WARN', 'Retrying log shipment', {
|
|
135
|
+
status,
|
|
136
|
+
error: error.message,
|
|
137
|
+
attempt,
|
|
138
|
+
nextAttemptIn: delay,
|
|
139
|
+
maxRetries: this.config.maxRetries
|
|
140
|
+
});
|
|
141
|
+
await new Promise(resolve => setTimeout(resolve, delay));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Map component values to API-accepted enum values
|
|
147
|
+
*/
|
|
148
|
+
mapComponentToValidEnum(component) {
|
|
149
|
+
const validComponents = ['client', 'tools', 'oauth-client'];
|
|
150
|
+
const componentMap = {
|
|
151
|
+
'server': 'client',
|
|
152
|
+
'client': 'client',
|
|
153
|
+
'tools': 'tools',
|
|
154
|
+
'oauth-client': 'oauth-client'
|
|
155
|
+
};
|
|
156
|
+
const componentStr = String(component || 'client');
|
|
157
|
+
const mapped = componentMap[componentStr.toLowerCase()];
|
|
158
|
+
return mapped || 'client'; // Default to 'client' for any unmapped components
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Map log level to API-accepted enum values (lowercase)
|
|
162
|
+
*/
|
|
163
|
+
mapLogLevelToValidEnum(level) {
|
|
164
|
+
const validLevels = ['info', 'error', 'warn', 'debug'];
|
|
165
|
+
const levelMap = {
|
|
166
|
+
'info': 'info',
|
|
167
|
+
'error': 'error',
|
|
168
|
+
'warn': 'warn',
|
|
169
|
+
'warning': 'warn',
|
|
170
|
+
'debug': 'debug',
|
|
171
|
+
'fatal': 'error' // Map fatal to error as API doesn't support fatal
|
|
172
|
+
};
|
|
173
|
+
const levelStr = String(level || 'info');
|
|
174
|
+
const mapped = levelMap[levelStr.toLowerCase()];
|
|
175
|
+
return mapped || 'info'; // Default to 'info' for any unmapped levels
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Validate and clean log entries to ensure API compatibility
|
|
179
|
+
*/
|
|
180
|
+
validateAndCleanLogs(logs) {
|
|
181
|
+
return logs.map(log => {
|
|
182
|
+
// Ensure all required fields are present and valid
|
|
183
|
+
const cleanedLog = {
|
|
184
|
+
timestamp: log.timestamp || new Date().toISOString(),
|
|
185
|
+
level: this.mapLogLevelToValidEnum(log.level || 'info'),
|
|
186
|
+
sessionId: log.sessionId || this.generateSessionId(),
|
|
187
|
+
user: log.user || process.env.CORETEXT_USER || 'unknown',
|
|
188
|
+
integration: log.integration || 'unknown',
|
|
189
|
+
component: this.mapComponentToValidEnum(log.component || 'client'),
|
|
190
|
+
action: log.action || 'unknown',
|
|
191
|
+
message: String(log.message || 'No message'),
|
|
192
|
+
serverName: log.serverName || 'constructionwire-mcp',
|
|
193
|
+
projectId: log.projectId || process.env.PROJECT_ID || '',
|
|
194
|
+
organizationId: log.organizationId || process.env.ORGANIZATION_ID || ''
|
|
195
|
+
};
|
|
196
|
+
// Clean and validate metadata
|
|
197
|
+
if (log.metadata && typeof log.metadata === 'object') {
|
|
198
|
+
cleanedLog.metadata = this.cleanMetadata(log.metadata);
|
|
199
|
+
}
|
|
200
|
+
return cleanedLog;
|
|
201
|
+
}).filter(log => {
|
|
202
|
+
// Filter out any logs that still have invalid data
|
|
203
|
+
return log.timestamp && log.level && log.user && log.message;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Clean metadata object to ensure JSON serialization compatibility
|
|
208
|
+
*/
|
|
209
|
+
cleanMetadata(metadata) {
|
|
210
|
+
if (!metadata || typeof metadata !== 'object') {
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
const cleaned = {};
|
|
214
|
+
for (const [key, value] of Object.entries(metadata)) {
|
|
215
|
+
try {
|
|
216
|
+
// Skip undefined values
|
|
217
|
+
if (value === undefined) {
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
// Convert functions to string representation
|
|
221
|
+
if (typeof value === 'function') {
|
|
222
|
+
cleaned[key] = '[Function]';
|
|
223
|
+
continue;
|
|
224
|
+
}
|
|
225
|
+
// Handle circular references and complex objects
|
|
226
|
+
if (typeof value === 'object' && value !== null) {
|
|
227
|
+
try {
|
|
228
|
+
// Test if the object can be serialized
|
|
229
|
+
JSON.stringify(value);
|
|
230
|
+
cleaned[key] = value;
|
|
231
|
+
}
|
|
232
|
+
catch (e) {
|
|
233
|
+
// If serialization fails, convert to string
|
|
234
|
+
cleaned[key] = String(value);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
else {
|
|
238
|
+
cleaned[key] = value;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (error) {
|
|
242
|
+
// If any error occurs with this field, skip it
|
|
243
|
+
this.logLocally('WARN', 'Skipping problematic metadata field', {
|
|
244
|
+
field: key,
|
|
245
|
+
error: error instanceof Error ? error.message : String(error)
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return cleaned;
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Send logs to the API endpoint
|
|
253
|
+
*/
|
|
254
|
+
async sendLogs(logs) {
|
|
255
|
+
const headers = {
|
|
256
|
+
'Content-Type': 'application/json'
|
|
257
|
+
};
|
|
258
|
+
// Only include API key header if provided
|
|
259
|
+
if (this.config.apiKey) {
|
|
260
|
+
headers['X-API-Key'] = this.config.apiKey;
|
|
261
|
+
}
|
|
262
|
+
// Validate and clean logs before sending
|
|
263
|
+
const cleanedLogs = this.validateAndCleanLogs(logs);
|
|
264
|
+
const payload = { logs: cleanedLogs };
|
|
265
|
+
// Debug logging - log the exact payload being sent
|
|
266
|
+
this.logLocally('DEBUG', 'Sending log payload', {
|
|
267
|
+
payloadSize: JSON.stringify(payload).length,
|
|
268
|
+
logCount: cleanedLogs.length,
|
|
269
|
+
endpoint: this.config.endpoint,
|
|
270
|
+
hasApiKey: !!this.config.apiKey,
|
|
271
|
+
payload: JSON.stringify(payload, null, 2)
|
|
272
|
+
});
|
|
273
|
+
const response = await fetch(this.config.endpoint, {
|
|
274
|
+
method: 'POST',
|
|
275
|
+
headers,
|
|
276
|
+
body: JSON.stringify(payload)
|
|
277
|
+
});
|
|
278
|
+
if (!response.ok) {
|
|
279
|
+
// Get response body for debugging
|
|
280
|
+
let responseBody = '';
|
|
281
|
+
try {
|
|
282
|
+
responseBody = await response.text();
|
|
283
|
+
}
|
|
284
|
+
catch (e) {
|
|
285
|
+
responseBody = 'Unable to read response body';
|
|
286
|
+
}
|
|
287
|
+
// Log detailed error information
|
|
288
|
+
this.logLocally('ERROR', 'HTTP error response from log ingestion API', {
|
|
289
|
+
status: response.status,
|
|
290
|
+
statusText: response.statusText,
|
|
291
|
+
responseBody,
|
|
292
|
+
requestPayloadSize: JSON.stringify({ logs: cleanedLogs }).length,
|
|
293
|
+
endpoint: this.config.endpoint,
|
|
294
|
+
headers: Object.keys(headers)
|
|
295
|
+
});
|
|
296
|
+
// Provide helpful message for authentication errors
|
|
297
|
+
if ((response.status === 401 || response.status === 403) && !this.config.apiKey) {
|
|
298
|
+
const error = new Error(`Authentication required (${response.status}). The log ingestion API now requires an API key. ` +
|
|
299
|
+
'Please set LOG_INGESTION_API_KEY environment variable and restart the server.');
|
|
300
|
+
error.status = response.status;
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
// Provide specific error message for 400 Bad Request
|
|
304
|
+
if (response.status === 400) {
|
|
305
|
+
const error = new Error(`Bad Request (400): The log payload format is invalid. ` +
|
|
306
|
+
`Response: ${responseBody}. ` +
|
|
307
|
+
'Check the payload structure and field formats.');
|
|
308
|
+
error.status = response.status;
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
const error = new Error(`HTTP ${response.status}: ${response.statusText}. Response: ${responseBody}`);
|
|
312
|
+
error.status = response.status;
|
|
313
|
+
throw error;
|
|
314
|
+
}
|
|
315
|
+
return response.json();
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Generate a unique session ID
|
|
319
|
+
*/
|
|
320
|
+
generateSessionId() {
|
|
321
|
+
return `constructionwire-mcp-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Log locally to stderr (for debugging the log shipper itself)
|
|
325
|
+
*/
|
|
326
|
+
logLocally(level, message, metadata) {
|
|
327
|
+
const timestamp = new Date().toISOString();
|
|
328
|
+
const user = process.env.CORETEXT_USER || 'unknown';
|
|
329
|
+
const logEntry = {
|
|
330
|
+
timestamp,
|
|
331
|
+
user,
|
|
332
|
+
component: 'log-shipper',
|
|
333
|
+
level,
|
|
334
|
+
message,
|
|
335
|
+
...(metadata && { metadata })
|
|
336
|
+
};
|
|
337
|
+
console.error(`[CONSTRUCTIONWIRE-MCP-LOG-SHIPPER] ${JSON.stringify(logEntry)}`);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Get health status of the log shipper
|
|
341
|
+
*/
|
|
342
|
+
getHealthStatus() {
|
|
343
|
+
const now = Date.now();
|
|
344
|
+
const timeSinceLastFlush = now - this.lastSuccessfulFlush;
|
|
345
|
+
const isHealthy = this.config.enabled && (this.lastSuccessfulFlush === 0 || timeSinceLastFlush < this.config.flushInterval * 3);
|
|
346
|
+
return {
|
|
347
|
+
healthy: isHealthy,
|
|
348
|
+
lastFlush: this.lastSuccessfulFlush > 0 ? new Date(this.lastSuccessfulFlush).toISOString() : undefined,
|
|
349
|
+
queueSize: this.logQueue.length,
|
|
350
|
+
config: {
|
|
351
|
+
enabled: this.config.enabled,
|
|
352
|
+
endpoint: this.config.endpoint,
|
|
353
|
+
batchSize: this.config.batchSize,
|
|
354
|
+
flushInterval: this.config.flushInterval
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Graceful shutdown - flush remaining logs
|
|
360
|
+
*/
|
|
361
|
+
async shutdown() {
|
|
362
|
+
this.isShuttingDown = true;
|
|
363
|
+
if (this.flushTimer) {
|
|
364
|
+
clearInterval(this.flushTimer);
|
|
365
|
+
this.flushTimer = null;
|
|
366
|
+
}
|
|
367
|
+
this.logLocally('INFO', 'LogShipper shutting down', {
|
|
368
|
+
queueSize: this.logQueue.length
|
|
369
|
+
});
|
|
370
|
+
if (this.logQueue.length > 0) {
|
|
371
|
+
try {
|
|
372
|
+
await this.flush();
|
|
373
|
+
this.logLocally('INFO', 'Final flush completed successfully');
|
|
374
|
+
}
|
|
375
|
+
catch (error) {
|
|
376
|
+
this.logLocally('ERROR', 'Final flush failed', {
|
|
377
|
+
error: error instanceof Error ? error.message : String(error),
|
|
378
|
+
lostLogs: this.logQueue.length
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
//# sourceMappingURL=log-shipper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log-shipper.js","sourceRoot":"","sources":["../../src/services/log-shipper.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH,MAAM,OAAO,UAAU;IAOrB,YAAY,MAAwB;QAL5B,aAAQ,GAAe,EAAE,CAAC;QAC1B,eAAU,GAA0B,IAAI,CAAC;QACzC,mBAAc,GAAG,KAAK,CAAC;QACvB,wBAAmB,GAAG,CAAC,CAAC;QAG9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,IAAI,CAAC,eAAe,EAAE,CAAC;QAEvB,qBAAqB;QACrB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,wBAAwB,EAAE;YAChD,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;YAChC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;YACxC,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,UAAU;SACnC,CAAC,CAAC;IACL,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,iDAAiD;QACjD,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,IAAI,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CAAC;gBACH,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;gBACnB,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;YAChE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,oBAAoB,EAAE;oBAC7C,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;oBAC7D,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM;iBAC/B,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logger - Centralized logging service for constructionwire-mcp
|
|
3
|
+
* Provides structured logging with centralized log shipping capability
|
|
4
|
+
*/
|
|
5
|
+
import { LogShipper } from './log-shipper.js';
|
|
6
|
+
export type LogLevel = 'DEBUG' | 'INFO' | 'WARN' | 'ERROR' | 'FATAL';
|
|
7
|
+
export interface LoggerConfig {
|
|
8
|
+
logLevel: LogLevel;
|
|
9
|
+
component: string;
|
|
10
|
+
enableConsole: boolean;
|
|
11
|
+
enableShipping: boolean;
|
|
12
|
+
serverName: string;
|
|
13
|
+
logShipper?: LogShipper;
|
|
14
|
+
}
|
|
15
|
+
export declare class Logger {
|
|
16
|
+
private config;
|
|
17
|
+
private batcher;
|
|
18
|
+
private logLevelPriority;
|
|
19
|
+
constructor(config: LoggerConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Log a debug message
|
|
22
|
+
*/
|
|
23
|
+
debug(action: string, message: string, metadata?: any): void;
|
|
24
|
+
/**
|
|
25
|
+
* Log an info message
|
|
26
|
+
*/
|
|
27
|
+
info(action: string, message: string, metadata?: any): void;
|
|
28
|
+
/**
|
|
29
|
+
* Log a warning message
|
|
30
|
+
*/
|
|
31
|
+
warn(action: string, message: string, metadata?: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* Log an error message
|
|
34
|
+
*/
|
|
35
|
+
error(action: string, message: string, metadata?: any): void;
|
|
36
|
+
/**
|
|
37
|
+
* Log a fatal error message
|
|
38
|
+
*/
|
|
39
|
+
fatal(action: string, message: string, metadata?: any): void;
|
|
40
|
+
/**
|
|
41
|
+
* Core logging method
|
|
42
|
+
*/
|
|
43
|
+
private log;
|
|
44
|
+
/**
|
|
45
|
+
* Log HTTP request start
|
|
46
|
+
*/
|
|
47
|
+
logRequestStart(method: string, url: string, metadata?: any): void;
|
|
48
|
+
/**
|
|
49
|
+
* Log HTTP request success
|
|
50
|
+
*/
|
|
51
|
+
logRequestSuccess(method: string, url: string, status: number, duration: number, metadata?: any): void;
|
|
52
|
+
/**
|
|
53
|
+
* Log HTTP request error
|
|
54
|
+
*/
|
|
55
|
+
logRequestError(method: string, url: string, error: any, duration: number, metadata?: any): void;
|
|
56
|
+
/**
|
|
57
|
+
* Log tool execution start
|
|
58
|
+
*/
|
|
59
|
+
logToolStart(toolName: string, params: any): void;
|
|
60
|
+
/**
|
|
61
|
+
* Log tool execution success
|
|
62
|
+
*/
|
|
63
|
+
logToolSuccess(toolName: string, duration: number, responseData?: any, httpStatus?: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Log tool execution error
|
|
66
|
+
*/
|
|
67
|
+
logToolError(toolName: string, error: any, duration: number, params?: any): void;
|
|
68
|
+
/**
|
|
69
|
+
* Log authentication events
|
|
70
|
+
*/
|
|
71
|
+
logAuthEvent(event: string, success: boolean, metadata?: any): void;
|
|
72
|
+
/**
|
|
73
|
+
* Log rate limiting events
|
|
74
|
+
*/
|
|
75
|
+
logRateLimit(action: string, delayMs: number, metadata?: any): void;
|
|
76
|
+
/**
|
|
77
|
+
* Truncate large data objects to prevent oversized log entries
|
|
78
|
+
*/
|
|
79
|
+
private truncateIfNeeded;
|
|
80
|
+
/**
|
|
81
|
+
* Get logger status
|
|
82
|
+
*/
|
|
83
|
+
getStatus(): {
|
|
84
|
+
config: LoggerConfig;
|
|
85
|
+
batcherStatus?: any;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Shutdown logger and flush remaining logs
|
|
89
|
+
*/
|
|
90
|
+
shutdown(): Promise<void>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/services/logger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAY,MAAM,kBAAkB,CAAC;AAExD,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,OAAO,CAAC;IACvB,cAAc,EAAE,OAAO,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,gBAAgB,CAMtB;gBAEU,MAAM,EAAE,YAAY;IAQhC;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI;IAI5D;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI;IAI3D;;OAEG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,GAAG,GAAG,IAAI;IAI3D;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE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