@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.
Files changed (95) hide show
  1. package/CLAUDE.md +344 -0
  2. package/LICENSE +21 -0
  3. package/README.md +250 -0
  4. package/chrome-extension/README.md +41 -0
  5. package/chrome-extension/background.js +3917 -0
  6. package/chrome-extension/chrome-session-manager.js +706 -0
  7. package/chrome-extension/content.css +181 -0
  8. package/chrome-extension/content.js +3022 -0
  9. package/chrome-extension/data-buffer.js +435 -0
  10. package/chrome-extension/dom-tracker.js +411 -0
  11. package/chrome-extension/extension-config.js +78 -0
  12. package/chrome-extension/firebase-client.js +278 -0
  13. package/chrome-extension/firebase-config.js +32 -0
  14. package/chrome-extension/firebase-config.module.js +22 -0
  15. package/chrome-extension/firebase-config.module.template.js +27 -0
  16. package/chrome-extension/firebase-config.template.js +36 -0
  17. package/chrome-extension/frame-capture.js +407 -0
  18. package/chrome-extension/icon128.png +1 -0
  19. package/chrome-extension/icon16.png +1 -0
  20. package/chrome-extension/icon48.png +1 -0
  21. package/chrome-extension/license-helper.js +181 -0
  22. package/chrome-extension/logger.js +23 -0
  23. package/chrome-extension/manifest.json +73 -0
  24. package/chrome-extension/network-tracker.js +510 -0
  25. package/chrome-extension/offscreen.html +10 -0
  26. package/chrome-extension/options.html +203 -0
  27. package/chrome-extension/options.js +282 -0
  28. package/chrome-extension/pako.min.js +2 -0
  29. package/chrome-extension/performance-monitor.js +533 -0
  30. package/chrome-extension/pii-redactor.js +405 -0
  31. package/chrome-extension/popup.html +532 -0
  32. package/chrome-extension/popup.js +2446 -0
  33. package/chrome-extension/upload-manager.js +323 -0
  34. package/chrome-extension/web-vitals.iife.js +1 -0
  35. package/config/api-keys.json +11 -0
  36. package/config/chrome-pilot-config.json +45 -0
  37. package/package.json +126 -0
  38. package/scripts/cleanup-processes.js +109 -0
  39. package/scripts/config-manager.js +280 -0
  40. package/scripts/generate-extension-config.js +53 -0
  41. package/scripts/setup-security.js +64 -0
  42. package/src/capture/architecture.js +426 -0
  43. package/src/capture/error-handling-tests.md +38 -0
  44. package/src/capture/error-handling-types.ts +360 -0
  45. package/src/capture/index.js +508 -0
  46. package/src/capture/interfaces.js +625 -0
  47. package/src/capture/memory-manager.js +713 -0
  48. package/src/capture/types.js +342 -0
  49. package/src/chrome-controller.js +2658 -0
  50. package/src/cli.js +19 -0
  51. package/src/config-loader.js +303 -0
  52. package/src/database.js +2178 -0
  53. package/src/firebase-license-manager.js +462 -0
  54. package/src/firebase-privacy-guard.js +397 -0
  55. package/src/http-server.js +1516 -0
  56. package/src/index-direct.js +157 -0
  57. package/src/index-modular.js +219 -0
  58. package/src/index-monolithic-backup.js +2230 -0
  59. package/src/index.js +305 -0
  60. package/src/legacy/chrome-controller-old.js +1406 -0
  61. package/src/legacy/index-express.js +625 -0
  62. package/src/legacy/index-old.js +977 -0
  63. package/src/legacy/routes.js +260 -0
  64. package/src/legacy/shared-storage.js +101 -0
  65. package/src/logger.js +10 -0
  66. package/src/mcp/handlers/chrome-tool-handler.js +306 -0
  67. package/src/mcp/handlers/element-tool-handler.js +51 -0
  68. package/src/mcp/handlers/frame-tool-handler.js +957 -0
  69. package/src/mcp/handlers/request-handler.js +104 -0
  70. package/src/mcp/handlers/workflow-tool-handler.js +636 -0
  71. package/src/mcp/server.js +68 -0
  72. package/src/mcp/tools/index.js +701 -0
  73. package/src/middleware/auth.js +371 -0
  74. package/src/middleware/security.js +267 -0
  75. package/src/port-discovery.js +258 -0
  76. package/src/routes/admin.js +182 -0
  77. package/src/services/browser-daemon.js +494 -0
  78. package/src/services/chrome-service.js +375 -0
  79. package/src/services/failover-manager.js +412 -0
  80. package/src/services/git-safety-service.js +675 -0
  81. package/src/services/heartbeat-manager.js +200 -0
  82. package/src/services/http-client.js +195 -0
  83. package/src/services/process-manager.js +318 -0
  84. package/src/services/process-tracker.js +574 -0
  85. package/src/services/profile-manager.js +449 -0
  86. package/src/services/project-manager.js +415 -0
  87. package/src/services/session-manager.js +497 -0
  88. package/src/services/session-registry.js +491 -0
  89. package/src/services/unified-session-manager.js +678 -0
  90. package/src/shared-storage-old.js +267 -0
  91. package/src/standalone-server.js +53 -0
  92. package/src/utils/extension-path.js +145 -0
  93. package/src/utils.js +187 -0
  94. package/src/validation/log-transformer.js +125 -0
  95. package/src/validation/schemas.js +391 -0
@@ -0,0 +1,342 @@
1
+ /**
2
+ * Unified Interaction Capture System - Core Type Definitions
3
+ *
4
+ * This module defines the unified data format for ALL interaction capture types:
5
+ * - Screen captures (frames/screenshots)
6
+ * - DOM state snapshots
7
+ * - Console logs and network traffic
8
+ * - User interactions (clicks, typing, navigation)
9
+ * - Function execution traces
10
+ * - Browser state changes
11
+ *
12
+ * DESIGN PRINCIPLES:
13
+ * 1. Single unified format for all capture types
14
+ * 2. Extensible without breaking existing code
15
+ * 3. Memory efficient with streaming support
16
+ * 4. Chrome extension compatible
17
+ * 5. Database optimized structure
18
+ *
19
+ * DATA FLOW ARCHITECTURE:
20
+ * ChromeExtension → CaptureCollector → CaptureProcessor → CaptureStorage
21
+ * ↓
22
+ * CaptureAnalyzer → CaptureQuery
23
+ */
24
+
25
+ /**
26
+ * Base timestamp interface for all capture events
27
+ */
28
+ export const TimestampInfo = {
29
+ /** Milliseconds since capture session started */
30
+ relative: 0,
31
+ /** Absolute timestamp (Date.now()) */
32
+ absolute: 0,
33
+ /** High-resolution timestamp for precise timing */
34
+ performance: 0
35
+ };
36
+
37
+ /**
38
+ * Unified capture event - the core data structure
39
+ * All interaction types extend this base format
40
+ */
41
+ export const CaptureEvent = {
42
+ /** Unique identifier for this capture event */
43
+ id: '',
44
+ /** Session ID this event belongs to */
45
+ sessionId: '',
46
+ /** Event sequence number within session */
47
+ sequence: 0,
48
+ /** Event timing information */
49
+ timestamp: TimestampInfo,
50
+ /** Event type identifier */
51
+ type: '', // 'screen', 'dom', 'console', 'user', 'function', 'network', 'state'
52
+ /** Event subtype for categorization */
53
+ subtype: '', // 'click', 'screenshot', 'log', 'error', 'navigation', etc.
54
+ /** Browser tab/page identifier */
55
+ pageId: '',
56
+ /** URL when event occurred */
57
+ url: '',
58
+ /** Event-specific data payload */
59
+ data: {},
60
+ /** Optional metadata for filtering/analysis */
61
+ metadata: {
62
+ /** Tags for categorization */
63
+ tags: [],
64
+ /** Source that generated this event */
65
+ source: '', // 'extension', 'puppeteer', 'devtools'
66
+ /** Processing priority */
67
+ priority: 'normal', // 'low', 'normal', 'high', 'critical'
68
+ /** Memory usage hint for storage optimization */
69
+ sizeHint: 'small' // 'small', 'medium', 'large', 'huge'
70
+ }
71
+ };
72
+
73
+ /**
74
+ * Screen capture event data
75
+ */
76
+ export const ScreenCaptureData = {
77
+ /** Image data (base64 or binary) */
78
+ imageData: null,
79
+ /** Image format */
80
+ format: 'jpeg', // 'jpeg', 'png', 'webp'
81
+ /** Image dimensions */
82
+ width: 0,
83
+ height: 0,
84
+ /** Quality/compression settings */
85
+ quality: 80,
86
+ /** Viewport information */
87
+ viewport: {
88
+ x: 0,
89
+ y: 0,
90
+ width: 0,
91
+ height: 0,
92
+ scale: 1.0
93
+ },
94
+ /** Optional screenshot of specific element */
95
+ elementSelector: null
96
+ };
97
+
98
+ /**
99
+ * DOM state capture data
100
+ */
101
+ export const DOMCaptureData = {
102
+ /** HTML content snapshot */
103
+ html: '',
104
+ /** Computed styles for key elements */
105
+ styles: {},
106
+ /** Form data values */
107
+ forms: {},
108
+ /** Scroll positions */
109
+ scroll: { x: 0, y: 0 },
110
+ /** Selected elements */
111
+ selection: [],
112
+ /** Focus information */
113
+ focus: { element: null, position: 0 },
114
+ /** Document ready state */
115
+ readyState: 'complete'
116
+ };
117
+
118
+ /**
119
+ * Console/log capture data
120
+ */
121
+ export const ConsoleCaptureData = {
122
+ /** Log level */
123
+ level: 'info', // 'trace', 'debug', 'info', 'warn', 'error', 'fatal'
124
+ /** Log message */
125
+ message: '',
126
+ /** Structured log arguments */
127
+ args: [],
128
+ /** Stack trace if available */
129
+ stack: null,
130
+ /** Source location */
131
+ source: { file: '', line: 0, column: 0 },
132
+ /** Console API method used */
133
+ method: 'log' // 'log', 'error', 'warn', 'debug', 'trace', 'assert'
134
+ };
135
+
136
+ /**
137
+ * User interaction capture data
138
+ */
139
+ export const UserInteractionData = {
140
+ /** Interaction type */
141
+ action: '', // 'click', 'type', 'scroll', 'hover', 'drag', 'key'
142
+ /** Target element information */
143
+ target: {
144
+ selector: '',
145
+ tagName: '',
146
+ text: '',
147
+ attributes: {},
148
+ bounds: { x: 0, y: 0, width: 0, height: 0 }
149
+ },
150
+ /** Input data (for typing, dragging) */
151
+ input: null,
152
+ /** Mouse/touch coordinates */
153
+ coordinates: { x: 0, y: 0 },
154
+ /** Modifier keys pressed */
155
+ modifiers: [],
156
+ /** Interaction duration */
157
+ duration: 0
158
+ };
159
+
160
+ /**
161
+ * Function execution trace data
162
+ */
163
+ export const FunctionTraceData = {
164
+ /** Function name */
165
+ name: '',
166
+ /** Function signature */
167
+ signature: '',
168
+ /** Source location */
169
+ source: { file: '', line: 0, column: 0 },
170
+ /** Execution status */
171
+ status: 'completed', // 'started', 'completed', 'error', 'timeout'
172
+ /** Execution duration in ms */
173
+ duration: 0,
174
+ /** Arguments passed to function */
175
+ args: [],
176
+ /** Return value */
177
+ result: null,
178
+ /** Error information if failed */
179
+ error: null,
180
+ /** Call stack depth */
181
+ depth: 0,
182
+ /** Parent function call ID */
183
+ parentId: null
184
+ };
185
+
186
+ /**
187
+ * Network request capture data
188
+ */
189
+ export const NetworkCaptureData = {
190
+ /** Request URL */
191
+ url: '',
192
+ /** HTTP method */
193
+ method: 'GET',
194
+ /** Request headers */
195
+ headers: {},
196
+ /** Request body */
197
+ body: null,
198
+ /** Response status */
199
+ status: 0,
200
+ /** Response headers */
201
+ responseHeaders: {},
202
+ /** Response body */
203
+ response: null,
204
+ /** Request timing */
205
+ timing: {
206
+ start: 0,
207
+ end: 0,
208
+ duration: 0
209
+ },
210
+ /** Request type */
211
+ type: 'xhr' // 'xhr', 'fetch', 'document', 'stylesheet', 'script', 'image'
212
+ };
213
+
214
+ /**
215
+ * Browser state change data
216
+ */
217
+ export const StateChangeData = {
218
+ /** State type */
219
+ type: '', // 'navigation', 'load', 'resize', 'focus', 'storage'
220
+ /** Previous state */
221
+ from: null,
222
+ /** New state */
223
+ to: null,
224
+ /** Change trigger */
225
+ trigger: '', // 'user', 'script', 'system'
226
+ /** Additional context */
227
+ context: {}
228
+ };
229
+
230
+ /**
231
+ * Capture session metadata
232
+ */
233
+ export const CaptureSession = {
234
+ /** Unique session identifier */
235
+ id: '',
236
+ /** Session name/description */
237
+ name: '',
238
+ /** Session start time */
239
+ startTime: 0,
240
+ /** Session end time (null if ongoing) */
241
+ endTime: null,
242
+ /** Session tags */
243
+ tags: [],
244
+ /** Browser information */
245
+ browser: {
246
+ name: '',
247
+ version: '',
248
+ userAgent: ''
249
+ },
250
+ /** Initial page information */
251
+ initialPage: {
252
+ url: '',
253
+ title: '',
254
+ timestamp: 0
255
+ },
256
+ /** Session configuration */
257
+ config: {
258
+ /** Capture types enabled */
259
+ captureTypes: [],
260
+ /** Screenshot settings */
261
+ screenshots: {
262
+ enabled: true,
263
+ quality: 80,
264
+ interval: 1000
265
+ },
266
+ /** Memory limits */
267
+ limits: {
268
+ maxEvents: 10000,
269
+ maxMemoryMB: 100
270
+ }
271
+ },
272
+ /** Session statistics */
273
+ stats: {
274
+ /** Total events captured */
275
+ totalEvents: 0,
276
+ /** Events by type */
277
+ eventsByType: {},
278
+ /** Memory usage */
279
+ memoryUsageMB: 0,
280
+ /** Duration in milliseconds */
281
+ duration: 0
282
+ }
283
+ };
284
+
285
+ /**
286
+ * Type mapping for event data validation
287
+ */
288
+ export const EVENT_DATA_TYPES = {
289
+ 'screen': ScreenCaptureData,
290
+ 'dom': DOMCaptureData,
291
+ 'console': ConsoleCaptureData,
292
+ 'user': UserInteractionData,
293
+ 'function': FunctionTraceData,
294
+ 'network': NetworkCaptureData,
295
+ 'state': StateChangeData
296
+ };
297
+
298
+ /**
299
+ * Event priority levels for processing and storage
300
+ */
301
+ export const PRIORITY_LEVELS = {
302
+ LOW: 'low', // Background events, low-frequency logs
303
+ NORMAL: 'normal', // Standard user interactions, regular logs
304
+ HIGH: 'high', // Important state changes, errors
305
+ CRITICAL: 'critical' // System errors, security events
306
+ };
307
+
308
+ /**
309
+ * Memory size hints for storage optimization
310
+ */
311
+ export const SIZE_HINTS = {
312
+ SMALL: 'small', // < 1KB (logs, simple interactions)
313
+ MEDIUM: 'medium', // 1KB - 100KB (DOM snapshots, small images)
314
+ LARGE: 'large', // 100KB - 1MB (screenshots, network responses)
315
+ HUGE: 'huge' // > 1MB (video frames, large network payloads)
316
+ };
317
+
318
+ /**
319
+ * Supported capture event types
320
+ */
321
+ export const CAPTURE_TYPES = {
322
+ SCREEN: 'screen',
323
+ DOM: 'dom',
324
+ CONSOLE: 'console',
325
+ USER: 'user',
326
+ FUNCTION: 'function',
327
+ NETWORK: 'network',
328
+ STATE: 'state'
329
+ };
330
+
331
+ /**
332
+ * Common event subtypes by category
333
+ */
334
+ export const SUBTYPES = {
335
+ screen: ['screenshot', 'video_frame', 'element_capture'],
336
+ dom: ['snapshot', 'mutation', 'selection_change'],
337
+ console: ['log', 'error', 'warn', 'debug', 'trace'],
338
+ user: ['click', 'type', 'scroll', 'hover', 'drag', 'key', 'touch'],
339
+ function: ['start', 'end', 'error', 'async_start', 'async_end'],
340
+ network: ['request', 'response', 'error', 'abort'],
341
+ state: ['navigation', 'load', 'resize', 'focus', 'storage', 'cookie']
342
+ };