@dynamicu/chromedebug-mcp 2.2.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/CLAUDE.md +344 -0
- package/LICENSE +21 -0
- package/README.md +250 -0
- package/chrome-extension/README.md +41 -0
- package/chrome-extension/background.js +3917 -0
- package/chrome-extension/chrome-session-manager.js +706 -0
- package/chrome-extension/content.css +181 -0
- package/chrome-extension/content.js +3022 -0
- package/chrome-extension/data-buffer.js +435 -0
- package/chrome-extension/dom-tracker.js +411 -0
- package/chrome-extension/extension-config.js +78 -0
- package/chrome-extension/firebase-client.js +278 -0
- package/chrome-extension/firebase-config.js +32 -0
- package/chrome-extension/firebase-config.module.js +22 -0
- package/chrome-extension/firebase-config.module.template.js +27 -0
- package/chrome-extension/firebase-config.template.js +36 -0
- package/chrome-extension/frame-capture.js +407 -0
- package/chrome-extension/icon128.png +1 -0
- package/chrome-extension/icon16.png +1 -0
- package/chrome-extension/icon48.png +1 -0
- package/chrome-extension/license-helper.js +181 -0
- package/chrome-extension/logger.js +23 -0
- package/chrome-extension/manifest.json +73 -0
- package/chrome-extension/network-tracker.js +510 -0
- package/chrome-extension/offscreen.html +10 -0
- package/chrome-extension/options.html +203 -0
- package/chrome-extension/options.js +282 -0
- package/chrome-extension/pako.min.js +2 -0
- package/chrome-extension/performance-monitor.js +533 -0
- package/chrome-extension/pii-redactor.js +405 -0
- package/chrome-extension/popup.html +532 -0
- package/chrome-extension/popup.js +2446 -0
- package/chrome-extension/upload-manager.js +323 -0
- package/chrome-extension/web-vitals.iife.js +1 -0
- package/config/api-keys.json +11 -0
- package/config/chrome-pilot-config.json +45 -0
- package/package.json +126 -0
- package/scripts/cleanup-processes.js +109 -0
- package/scripts/config-manager.js +280 -0
- package/scripts/generate-extension-config.js +53 -0
- package/scripts/setup-security.js +64 -0
- package/src/capture/architecture.js +426 -0
- package/src/capture/error-handling-tests.md +38 -0
- package/src/capture/error-handling-types.ts +360 -0
- package/src/capture/index.js +508 -0
- package/src/capture/interfaces.js +625 -0
- package/src/capture/memory-manager.js +713 -0
- package/src/capture/types.js +342 -0
- package/src/chrome-controller.js +2658 -0
- package/src/cli.js +19 -0
- package/src/config-loader.js +303 -0
- package/src/database.js +2178 -0
- package/src/firebase-license-manager.js +462 -0
- package/src/firebase-privacy-guard.js +397 -0
- package/src/http-server.js +1516 -0
- package/src/index-direct.js +157 -0
- package/src/index-modular.js +219 -0
- package/src/index-monolithic-backup.js +2230 -0
- package/src/index.js +305 -0
- package/src/legacy/chrome-controller-old.js +1406 -0
- package/src/legacy/index-express.js +625 -0
- package/src/legacy/index-old.js +977 -0
- package/src/legacy/routes.js +260 -0
- package/src/legacy/shared-storage.js +101 -0
- package/src/logger.js +10 -0
- package/src/mcp/handlers/chrome-tool-handler.js +306 -0
- package/src/mcp/handlers/element-tool-handler.js +51 -0
- package/src/mcp/handlers/frame-tool-handler.js +957 -0
- package/src/mcp/handlers/request-handler.js +104 -0
- package/src/mcp/handlers/workflow-tool-handler.js +636 -0
- package/src/mcp/server.js +68 -0
- package/src/mcp/tools/index.js +701 -0
- package/src/middleware/auth.js +371 -0
- package/src/middleware/security.js +267 -0
- package/src/port-discovery.js +258 -0
- package/src/routes/admin.js +182 -0
- package/src/services/browser-daemon.js +494 -0
- package/src/services/chrome-service.js +375 -0
- package/src/services/failover-manager.js +412 -0
- package/src/services/git-safety-service.js +675 -0
- package/src/services/heartbeat-manager.js +200 -0
- package/src/services/http-client.js +195 -0
- package/src/services/process-manager.js +318 -0
- package/src/services/process-tracker.js +574 -0
- package/src/services/profile-manager.js +449 -0
- package/src/services/project-manager.js +415 -0
- package/src/services/session-manager.js +497 -0
- package/src/services/session-registry.js +491 -0
- package/src/services/unified-session-manager.js +678 -0
- package/src/shared-storage-old.js +267 -0
- package/src/standalone-server.js +53 -0
- package/src/utils/extension-path.js +145 -0
- package/src/utils.js +187 -0
- package/src/validation/log-transformer.js +125 -0
- package/src/validation/schemas.js +391 -0
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chrome Pilot Error Handling System - Type Definitions
|
|
3
|
+
* Architecture designed collaboratively with Second Opinion Consultant
|
|
4
|
+
*
|
|
5
|
+
* APPROVED ARCHITECTURE - No modifications without team review
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
// System Requirements
|
|
9
|
+
export const SYSTEM_REQUIREMENTS = {
|
|
10
|
+
maxDataLossTime: 30000, // 30 seconds max data loss
|
|
11
|
+
maxRetainedInteractions: 100, // Memory limit
|
|
12
|
+
notificationThrottleMs: 5000, // User experience
|
|
13
|
+
maxRetryAttempts: 3,
|
|
14
|
+
backupRetentionDays: 7,
|
|
15
|
+
recoverabilityLevel: 'GUARANTEED' as const
|
|
16
|
+
} as const;
|
|
17
|
+
|
|
18
|
+
// Data Protection Tiers
|
|
19
|
+
export interface DataProtectionTier {
|
|
20
|
+
maxLoss: number;
|
|
21
|
+
includes: string[];
|
|
22
|
+
storage: 'PERSISTENT_BACKUP' | 'REDUNDANT_STORAGE' | 'SINGLE_STORAGE';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const DATA_PROTECTION_TIERS = {
|
|
26
|
+
CRITICAL_DATA: {
|
|
27
|
+
maxLoss: 0,
|
|
28
|
+
includes: ['session_metadata', 'user_authentication'],
|
|
29
|
+
storage: 'PERSISTENT_BACKUP'
|
|
30
|
+
} as DataProtectionTier,
|
|
31
|
+
|
|
32
|
+
HIGH_VALUE_DATA: {
|
|
33
|
+
maxLoss: 30000,
|
|
34
|
+
includes: ['user_interactions', 'form_data'],
|
|
35
|
+
storage: 'REDUNDANT_STORAGE'
|
|
36
|
+
} as DataProtectionTier,
|
|
37
|
+
|
|
38
|
+
RECOVERABLE_DATA: {
|
|
39
|
+
maxLoss: 300000,
|
|
40
|
+
includes: ['performance_metrics', 'debug_logs'],
|
|
41
|
+
storage: 'SINGLE_STORAGE'
|
|
42
|
+
} as DataProtectionTier
|
|
43
|
+
} as const;
|
|
44
|
+
|
|
45
|
+
// Enhanced Screen Interaction Format
|
|
46
|
+
export interface ScreenInteraction {
|
|
47
|
+
type: 'click' | 'scroll' | 'keypress' | 'mousemove';
|
|
48
|
+
timestamp: number;
|
|
49
|
+
x?: number;
|
|
50
|
+
y?: number;
|
|
51
|
+
|
|
52
|
+
// Enhanced fields for error recovery
|
|
53
|
+
element_html?: string;
|
|
54
|
+
component_data?: string;
|
|
55
|
+
event_handlers?: string;
|
|
56
|
+
element_state?: string;
|
|
57
|
+
performance_metrics?: string;
|
|
58
|
+
|
|
59
|
+
// Error tracking
|
|
60
|
+
id?: string;
|
|
61
|
+
sessionId: string;
|
|
62
|
+
retryCount?: number;
|
|
63
|
+
compressionApplied?: boolean;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Error State Management
|
|
67
|
+
export interface ErrorDetails {
|
|
68
|
+
type: 'NETWORK_FAILURE' | 'SERVER_ERROR' | 'STORAGE_FAILURE' | 'BROWSER_CRASH' | 'NOTIFICATION_FAILURE';
|
|
69
|
+
message: string;
|
|
70
|
+
timestamp: number;
|
|
71
|
+
retryCount: number;
|
|
72
|
+
stackTrace?: string;
|
|
73
|
+
context?: Record<string, any>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface ErrorState {
|
|
77
|
+
failedSaveCount: number;
|
|
78
|
+
lastNotificationTime: number;
|
|
79
|
+
retainedInteractions: ScreenInteraction[];
|
|
80
|
+
lastError: ErrorDetails;
|
|
81
|
+
circuitBreakerState: 'CLOSED' | 'OPEN' | 'HALF_OPEN';
|
|
82
|
+
id?: string;
|
|
83
|
+
sessionId: string;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Backup/Recovery Format
|
|
87
|
+
export interface SessionInfo {
|
|
88
|
+
sessionId: string;
|
|
89
|
+
startTime: number;
|
|
90
|
+
userId?: string;
|
|
91
|
+
pageUrl: string;
|
|
92
|
+
userAgent: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface BackupData {
|
|
96
|
+
sessionId: string;
|
|
97
|
+
interactions: ScreenInteraction[];
|
|
98
|
+
timestamp: number;
|
|
99
|
+
sessionData: SessionInfo;
|
|
100
|
+
retryCount: number;
|
|
101
|
+
compressionRatio?: number;
|
|
102
|
+
backupType: 'AUTOMATIC' | 'MANUAL' | 'EMERGENCY';
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Notification System
|
|
106
|
+
export interface NotificationButton {
|
|
107
|
+
text: string;
|
|
108
|
+
action: 'RETRY' | 'DISCARD' | 'VIEW_DETAILS' | 'DOWNLOAD_BACKUP';
|
|
109
|
+
primary?: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface NotificationConfig {
|
|
113
|
+
throttleMs: number;
|
|
114
|
+
maxRetainedInteractions: number;
|
|
115
|
+
retryThreshold: number;
|
|
116
|
+
buttons: NotificationButton[];
|
|
117
|
+
title: string;
|
|
118
|
+
message: string;
|
|
119
|
+
priority: 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Storage Architecture
|
|
123
|
+
export interface StorageTier {
|
|
124
|
+
api: 'chrome.storage.local' | 'IndexedDB' | 'sessionStorage';
|
|
125
|
+
maxSize: string;
|
|
126
|
+
data: string[];
|
|
127
|
+
backup?: string;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const STORAGE_ARCHITECTURE = {
|
|
131
|
+
critical: {
|
|
132
|
+
api: 'chrome.storage.local',
|
|
133
|
+
maxSize: '1MB',
|
|
134
|
+
data: ['sessionId', 'userAuth', 'recoveryTokens'],
|
|
135
|
+
backup: 'IndexedDB mirror'
|
|
136
|
+
} as StorageTier,
|
|
137
|
+
|
|
138
|
+
highValue: {
|
|
139
|
+
api: 'IndexedDB',
|
|
140
|
+
maxSize: '50MB',
|
|
141
|
+
data: ['interactions', 'formData', 'elementStates'],
|
|
142
|
+
backup: 'chrome.storage.local (compressed)'
|
|
143
|
+
} as StorageTier,
|
|
144
|
+
|
|
145
|
+
recoverable: {
|
|
146
|
+
api: 'IndexedDB',
|
|
147
|
+
maxSize: 'Unlimited (with cleanup)',
|
|
148
|
+
data: ['performance', 'debugLogs', 'analytics'],
|
|
149
|
+
backup: 'None (acceptable loss)'
|
|
150
|
+
} as StorageTier
|
|
151
|
+
} as const;
|
|
152
|
+
|
|
153
|
+
// Communication Protocol
|
|
154
|
+
export interface ServerUploadPayload {
|
|
155
|
+
sessionId: string;
|
|
156
|
+
interactions: ScreenInteraction[];
|
|
157
|
+
metadata: SessionInfo;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface ServerUploadConfig {
|
|
161
|
+
endpoint: string;
|
|
162
|
+
method: 'POST';
|
|
163
|
+
headers: Record<string, string>;
|
|
164
|
+
payload: ServerUploadPayload;
|
|
165
|
+
timeout: number;
|
|
166
|
+
retryStrategy: 'exponentialBackoff';
|
|
167
|
+
circuitBreaker: 'enabled';
|
|
168
|
+
fallbackAction: 'STORE_LOCAL_BACKUP';
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// Internal Messages
|
|
172
|
+
export type InternalMessageType = 'SAVE_FAILURE' | 'RECOVERY_REQUEST' | 'BACKUP_COMPLETE';
|
|
173
|
+
|
|
174
|
+
export interface InternalMessage<T = any> {
|
|
175
|
+
type: InternalMessageType;
|
|
176
|
+
from: 'background' | 'contentScript' | 'errorHandler';
|
|
177
|
+
to: 'background' | 'contentScript' | 'errorHandler';
|
|
178
|
+
data: T;
|
|
179
|
+
timestamp: number;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Circuit Breaker Pattern
|
|
183
|
+
export interface CircuitBreakerConfig {
|
|
184
|
+
failureThreshold: number;
|
|
185
|
+
resetTimeout: number;
|
|
186
|
+
states: ['CLOSED', 'OPEN', 'HALF_OPEN'];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const CIRCUIT_BREAKER_CONFIG: CircuitBreakerConfig = {
|
|
190
|
+
failureThreshold: 3,
|
|
191
|
+
resetTimeout: 30000,
|
|
192
|
+
states: ['CLOSED', 'OPEN', 'HALF_OPEN']
|
|
193
|
+
} as const;
|
|
194
|
+
|
|
195
|
+
// State Machine
|
|
196
|
+
export type ErrorHandlingState =
|
|
197
|
+
| 'NORMAL_OPERATION'
|
|
198
|
+
| 'ERROR_DETECTED'
|
|
199
|
+
| 'BACKUP_MODE'
|
|
200
|
+
| 'RECOVERY_ATTEMPT'
|
|
201
|
+
| 'CRITICAL_FAILURE'
|
|
202
|
+
| 'MANUAL_RECOVERY';
|
|
203
|
+
|
|
204
|
+
export type ErrorHandlingEvent =
|
|
205
|
+
| 'SAVE_FAILURE'
|
|
206
|
+
| 'NETWORK_ERROR'
|
|
207
|
+
| 'RETRY_SUCCESS'
|
|
208
|
+
| 'RETRY_FAILURE'
|
|
209
|
+
| 'MAX_RETRIES_EXCEEDED'
|
|
210
|
+
| 'BACKUP_SUCCESS'
|
|
211
|
+
| 'BACKUP_FAILURE'
|
|
212
|
+
| 'NETWORK_RESTORED'
|
|
213
|
+
| 'RECOVERY_SUCCESS'
|
|
214
|
+
| 'RECOVERY_FAILURE'
|
|
215
|
+
| 'USER_INTERVENTION'
|
|
216
|
+
| 'SYSTEM_RESET';
|
|
217
|
+
|
|
218
|
+
export interface StateTransition {
|
|
219
|
+
from: ErrorHandlingState;
|
|
220
|
+
event: ErrorHandlingEvent;
|
|
221
|
+
to: ErrorHandlingState;
|
|
222
|
+
actions: string[];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export interface StateMachineConfig {
|
|
226
|
+
initialState: ErrorHandlingState;
|
|
227
|
+
states: Record<ErrorHandlingState, {
|
|
228
|
+
on: Partial<Record<ErrorHandlingEvent, ErrorHandlingState>>;
|
|
229
|
+
actions: string[];
|
|
230
|
+
}>;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// IndexedDB Schema
|
|
234
|
+
export interface IndexedDBIndex {
|
|
235
|
+
name: string;
|
|
236
|
+
keyPath: string;
|
|
237
|
+
unique?: boolean;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export interface IndexedDBStore {
|
|
241
|
+
keyPath: string;
|
|
242
|
+
autoIncrement?: boolean;
|
|
243
|
+
indexes: IndexedDBIndex[];
|
|
244
|
+
data: string;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export interface IndexedDBSchema {
|
|
248
|
+
database: string;
|
|
249
|
+
version: number;
|
|
250
|
+
stores: Record<string, IndexedDBStore>;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
// Compression Configuration
|
|
254
|
+
export interface CompressionConfig {
|
|
255
|
+
algorithm: 'gzip';
|
|
256
|
+
threshold: number;
|
|
257
|
+
targets: string[];
|
|
258
|
+
ratio: number;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export const COMPRESSION_CONFIG: CompressionConfig = {
|
|
262
|
+
algorithm: 'gzip',
|
|
263
|
+
threshold: 1024,
|
|
264
|
+
targets: ['element_html', 'component_data', 'element_state'],
|
|
265
|
+
ratio: 0.3
|
|
266
|
+
} as const;
|
|
267
|
+
|
|
268
|
+
// Export complete configuration objects
|
|
269
|
+
export const ERROR_HANDLING_STATE_MACHINE: StateMachineConfig = {
|
|
270
|
+
initialState: 'NORMAL_OPERATION',
|
|
271
|
+
|
|
272
|
+
states: {
|
|
273
|
+
NORMAL_OPERATION: {
|
|
274
|
+
on: {
|
|
275
|
+
SAVE_FAILURE: 'ERROR_DETECTED',
|
|
276
|
+
NETWORK_ERROR: 'BACKUP_MODE'
|
|
277
|
+
},
|
|
278
|
+
actions: ['processInteractions', 'uploadToServer']
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
ERROR_DETECTED: {
|
|
282
|
+
on: {
|
|
283
|
+
RETRY_SUCCESS: 'NORMAL_OPERATION',
|
|
284
|
+
RETRY_FAILURE: 'BACKUP_MODE',
|
|
285
|
+
MAX_RETRIES_EXCEEDED: 'CRITICAL_FAILURE'
|
|
286
|
+
},
|
|
287
|
+
actions: ['incrementRetryCount', 'exponentialBackoff', 'retryUpload']
|
|
288
|
+
},
|
|
289
|
+
|
|
290
|
+
BACKUP_MODE: {
|
|
291
|
+
on: {
|
|
292
|
+
BACKUP_SUCCESS: 'RECOVERY_ATTEMPT',
|
|
293
|
+
BACKUP_FAILURE: 'CRITICAL_FAILURE',
|
|
294
|
+
NETWORK_RESTORED: 'RECOVERY_ATTEMPT'
|
|
295
|
+
},
|
|
296
|
+
actions: ['storeLocalBackup', 'notifyUser', 'monitorNetwork']
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
RECOVERY_ATTEMPT: {
|
|
300
|
+
on: {
|
|
301
|
+
RECOVERY_SUCCESS: 'NORMAL_OPERATION',
|
|
302
|
+
RECOVERY_FAILURE: 'BACKUP_MODE'
|
|
303
|
+
},
|
|
304
|
+
actions: ['uploadBackedData', 'clearLocalBackup']
|
|
305
|
+
},
|
|
306
|
+
|
|
307
|
+
CRITICAL_FAILURE: {
|
|
308
|
+
on: {
|
|
309
|
+
USER_INTERVENTION: 'MANUAL_RECOVERY',
|
|
310
|
+
SYSTEM_RESET: 'NORMAL_OPERATION'
|
|
311
|
+
},
|
|
312
|
+
actions: ['persistCriticalData', 'notifyUserCritical', 'logError']
|
|
313
|
+
},
|
|
314
|
+
|
|
315
|
+
MANUAL_RECOVERY: {
|
|
316
|
+
on: {
|
|
317
|
+
RECOVERY_SUCCESS: 'NORMAL_OPERATION',
|
|
318
|
+
SYSTEM_RESET: 'NORMAL_OPERATION'
|
|
319
|
+
},
|
|
320
|
+
actions: ['processUserInput', 'attemptManualRecovery']
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
} as const;
|
|
324
|
+
|
|
325
|
+
export const INDEXEDDB_SCHEMA: IndexedDBSchema = {
|
|
326
|
+
database: 'ChromePilotErrorRecovery',
|
|
327
|
+
version: 1,
|
|
328
|
+
stores: {
|
|
329
|
+
interactions: {
|
|
330
|
+
keyPath: 'id',
|
|
331
|
+
autoIncrement: true,
|
|
332
|
+
indexes: [
|
|
333
|
+
{ name: 'sessionId', keyPath: 'sessionId' },
|
|
334
|
+
{ name: 'timestamp', keyPath: 'timestamp' },
|
|
335
|
+
{ name: 'type', keyPath: 'type' }
|
|
336
|
+
],
|
|
337
|
+
data: 'ScreenInteraction[]'
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
sessionBackups: {
|
|
341
|
+
keyPath: 'sessionId',
|
|
342
|
+
indexes: [
|
|
343
|
+
{ name: 'timestamp', keyPath: 'timestamp' },
|
|
344
|
+
{ name: 'retryCount', keyPath: 'retryCount' }
|
|
345
|
+
],
|
|
346
|
+
data: 'BackupData'
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
errorStates: {
|
|
350
|
+
keyPath: 'id',
|
|
351
|
+
autoIncrement: true,
|
|
352
|
+
indexes: [
|
|
353
|
+
{ name: 'sessionId', keyPath: 'sessionId' },
|
|
354
|
+
{ name: 'errorType', keyPath: 'errorType' },
|
|
355
|
+
{ name: 'timestamp', keyPath: 'timestamp' }
|
|
356
|
+
],
|
|
357
|
+
data: 'ErrorState'
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
} as const;
|