@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,625 @@
1
+ /**
2
+ * Unified Interaction Capture System - Module Interfaces
3
+ *
4
+ * This module defines clean interfaces between capture system components.
5
+ * Each interface can be implemented independently, enabling parallel development.
6
+ *
7
+ * ARCHITECTURE BOUNDARIES:
8
+ * ┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
9
+ * │ CaptureSource │───▶│ CaptureCollector │───▶│ CaptureProcessor│
10
+ * │ (Chrome Ext) │ │ (Event Router) │ │ (Transform) │
11
+ * └─────────────────┘ └──────────────────┘ └─────────────────┘
12
+ * │
13
+ * ┌─────────────────┐ ┌──────────────────┐ ▼
14
+ * │ CaptureQuery │◀───│ CaptureStorage │ ┌─────────────────┐
15
+ * │ (Search/Filter) │ │ (Persistence) │◀───│ CaptureAnalyzer │
16
+ * └─────────────────┘ └──────────────────┘ │ (Processing) │
17
+ * └─────────────────┘
18
+ */
19
+
20
+ import { CaptureEvent, CaptureSession } from './types.js';
21
+
22
+ /**
23
+ * Interface for capture event sources (Chrome extension, Puppeteer, etc.)
24
+ *
25
+ * INDEPENDENCE: Can be implemented without knowledge of other modules
26
+ * TESTING: Easy to mock for unit tests
27
+ */
28
+ export class ICaptureSource {
29
+ /**
30
+ * Initialize the capture source
31
+ * @param {Object} config - Source-specific configuration
32
+ * @returns {Promise<void>}
33
+ */
34
+ async initialize(config) {
35
+ throw new Error('ICaptureSource.initialize() must be implemented');
36
+ }
37
+
38
+ /**
39
+ * Start capturing events for a session
40
+ * @param {CaptureSession} session - Session to capture for
41
+ * @returns {Promise<void>}
42
+ */
43
+ async startCapture(session) {
44
+ throw new Error('ICaptureSource.startCapture() must be implemented');
45
+ }
46
+
47
+ /**
48
+ * Stop capturing events
49
+ * @returns {Promise<void>}
50
+ */
51
+ async stopCapture() {
52
+ throw new Error('ICaptureSource.stopCapture() must be implemented');
53
+ }
54
+
55
+ /**
56
+ * Register event handler for captured events
57
+ * @param {Function} handler - Function to handle events: (CaptureEvent) => void
58
+ */
59
+ onEvent(handler) {
60
+ throw new Error('ICaptureSource.onEvent() must be implemented');
61
+ }
62
+
63
+ /**
64
+ * Get current capture status
65
+ * @returns {Object} Status information
66
+ */
67
+ getStatus() {
68
+ throw new Error('ICaptureSource.getStatus() must be implemented');
69
+ }
70
+
71
+ /**
72
+ * Cleanup resources
73
+ * @returns {Promise<void>}
74
+ */
75
+ async dispose() {
76
+ throw new Error('ICaptureSource.dispose() must be implemented');
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Interface for collecting and routing capture events
82
+ *
83
+ * RESPONSIBILITY: Route events from sources to processors
84
+ * INDEPENDENCE: Works with any source/processor implementation
85
+ */
86
+ export class ICaptureCollector {
87
+ /**
88
+ * Initialize the collector
89
+ * @param {Object} config - Collector configuration
90
+ * @returns {Promise<void>}
91
+ */
92
+ async initialize(config) {
93
+ throw new Error('ICaptureCollector.initialize() must be implemented');
94
+ }
95
+
96
+ /**
97
+ * Register a capture source
98
+ * @param {ICaptureSource} source - Source to register
99
+ * @returns {Promise<void>}
100
+ */
101
+ async registerSource(source) {
102
+ throw new Error('ICaptureCollector.registerSource() must be implemented');
103
+ }
104
+
105
+ /**
106
+ * Register a capture processor
107
+ * @param {ICaptureProcessor} processor - Processor to register
108
+ * @returns {Promise<void>}
109
+ */
110
+ async registerProcessor(processor) {
111
+ throw new Error('ICaptureCollector.registerProcessor() must be implemented');
112
+ }
113
+
114
+ /**
115
+ * Start collecting events for a session
116
+ * @param {CaptureSession} session - Session to collect for
117
+ * @returns {Promise<void>}
118
+ */
119
+ async startCollection(session) {
120
+ throw new Error('ICaptureCollector.startCollection() must be implemented');
121
+ }
122
+
123
+ /**
124
+ * Stop collecting events
125
+ * @returns {Promise<void>}
126
+ */
127
+ async stopCollection() {
128
+ throw new Error('ICaptureCollector.stopCollection() must be implemented');
129
+ }
130
+
131
+ /**
132
+ * Get collection statistics
133
+ * @returns {Object} Collection stats
134
+ */
135
+ getStats() {
136
+ throw new Error('ICaptureCollector.getStats() must be implemented');
137
+ }
138
+ }
139
+
140
+ /**
141
+ * Interface for processing and transforming capture events
142
+ *
143
+ * RESPONSIBILITY: Transform, filter, and enrich events
144
+ * INDEPENDENCE: Can process any CaptureEvent without knowing source
145
+ */
146
+ export class ICaptureProcessor {
147
+ /**
148
+ * Initialize the processor
149
+ * @param {Object} config - Processor configuration
150
+ * @returns {Promise<void>}
151
+ */
152
+ async initialize(config) {
153
+ throw new Error('ICaptureProcessor.initialize() must be implemented');
154
+ }
155
+
156
+ /**
157
+ * Process a capture event
158
+ * @param {CaptureEvent} event - Event to process
159
+ * @returns {Promise<CaptureEvent|CaptureEvent[]|null>} Processed event(s) or null to drop
160
+ */
161
+ async processEvent(event) {
162
+ throw new Error('ICaptureProcessor.processEvent() must be implemented');
163
+ }
164
+
165
+ /**
166
+ * Process multiple events as a batch
167
+ * @param {CaptureEvent[]} events - Events to process
168
+ * @returns {Promise<CaptureEvent[]>} Processed events
169
+ */
170
+ async processBatch(events) {
171
+ // Default implementation processes individually
172
+ const results = [];
173
+ for (const event of events) {
174
+ const processed = await this.processEvent(event);
175
+ if (processed) {
176
+ if (Array.isArray(processed)) {
177
+ results.push(...processed);
178
+ } else {
179
+ results.push(processed);
180
+ }
181
+ }
182
+ }
183
+ return results;
184
+ }
185
+
186
+ /**
187
+ * Get processor capabilities
188
+ * @returns {Object} Processor capabilities
189
+ */
190
+ getCapabilities() {
191
+ return {
192
+ supportedTypes: ['*'], // Types this processor handles
193
+ canBatch: false, // Whether it supports batch processing
194
+ canStream: false, // Whether it supports streaming
195
+ priority: 'normal' // Processing priority
196
+ };
197
+ }
198
+ }
199
+
200
+ /**
201
+ * Interface for storing capture events
202
+ *
203
+ * RESPONSIBILITY: Persist events to storage (database, files, etc.)
204
+ * INDEPENDENCE: Can store any CaptureEvent without knowing source/processor
205
+ */
206
+ export class ICaptureStorage {
207
+ /**
208
+ * Initialize the storage
209
+ * @param {Object} config - Storage configuration
210
+ * @returns {Promise<void>}
211
+ */
212
+ async initialize(config) {
213
+ throw new Error('ICaptureStorage.initialize() must be implemented');
214
+ }
215
+
216
+ /**
217
+ * Store a single event
218
+ * @param {CaptureEvent} event - Event to store
219
+ * @returns {Promise<string>} Stored event ID
220
+ */
221
+ async storeEvent(event) {
222
+ throw new Error('ICaptureStorage.storeEvent() must be implemented');
223
+ }
224
+
225
+ /**
226
+ * Store multiple events efficiently
227
+ * @param {CaptureEvent[]} events - Events to store
228
+ * @returns {Promise<string[]>} Stored event IDs
229
+ */
230
+ async storeEvents(events) {
231
+ // Default implementation stores individually
232
+ const ids = [];
233
+ for (const event of events) {
234
+ const id = await this.storeEvent(event);
235
+ ids.push(id);
236
+ }
237
+ return ids;
238
+ }
239
+
240
+ /**
241
+ * Store session metadata
242
+ * @param {CaptureSession} session - Session to store
243
+ * @returns {Promise<string>} Stored session ID
244
+ */
245
+ async storeSession(session) {
246
+ throw new Error('ICaptureStorage.storeSession() must be implemented');
247
+ }
248
+
249
+ /**
250
+ * Update session metadata
251
+ * @param {string} sessionId - Session ID to update
252
+ * @param {Object} updates - Fields to update
253
+ * @returns {Promise<void>}
254
+ */
255
+ async updateSession(sessionId, updates) {
256
+ throw new Error('ICaptureStorage.updateSession() must be implemented');
257
+ }
258
+
259
+ /**
260
+ * Get storage statistics
261
+ * @returns {Promise<Object>} Storage statistics
262
+ */
263
+ async getStats() {
264
+ throw new Error('ICaptureStorage.getStats() must be implemented');
265
+ }
266
+
267
+ /**
268
+ * Cleanup old data
269
+ * @param {Object} criteria - Cleanup criteria
270
+ * @returns {Promise<Object>} Cleanup results
271
+ */
272
+ async cleanup(criteria) {
273
+ throw new Error('ICaptureStorage.cleanup() must be implemented');
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Interface for querying and analyzing capture data
279
+ *
280
+ * RESPONSIBILITY: Search, filter, and analyze stored events
281
+ * INDEPENDENCE: Can query any stored CaptureEvent format
282
+ */
283
+ export class ICaptureQuery {
284
+ /**
285
+ * Initialize the query engine
286
+ * @param {ICaptureStorage} storage - Storage to query
287
+ * @returns {Promise<void>}
288
+ */
289
+ async initialize(storage) {
290
+ throw new Error('ICaptureQuery.initialize() must be implemented');
291
+ }
292
+
293
+ /**
294
+ * Query events by criteria
295
+ * @param {Object} criteria - Query criteria
296
+ * @param {Object} options - Query options (pagination, sorting)
297
+ * @returns {Promise<Object>} Query results with events and metadata
298
+ */
299
+ async queryEvents(criteria, options = {}) {
300
+ throw new Error('ICaptureQuery.queryEvents() must be implemented');
301
+ }
302
+
303
+ /**
304
+ * Get session by ID
305
+ * @param {string} sessionId - Session ID
306
+ * @returns {Promise<CaptureSession|null>} Session data
307
+ */
308
+ async getSession(sessionId) {
309
+ throw new Error('ICaptureQuery.getSession() must be implemented');
310
+ }
311
+
312
+ /**
313
+ * List all sessions
314
+ * @param {Object} options - List options
315
+ * @returns {Promise<CaptureSession[]>} Session list
316
+ */
317
+ async listSessions(options = {}) {
318
+ throw new Error('ICaptureQuery.listSessions() must be implemented');
319
+ }
320
+
321
+ /**
322
+ * Search events by text
323
+ * @param {string} query - Search query
324
+ * @param {Object} options - Search options
325
+ * @returns {Promise<Object>} Search results
326
+ */
327
+ async searchEvents(query, options = {}) {
328
+ throw new Error('ICaptureQuery.searchEvents() must be implemented');
329
+ }
330
+
331
+ /**
332
+ * Get event statistics
333
+ * @param {Object} criteria - Statistics criteria
334
+ * @returns {Promise<Object>} Event statistics
335
+ */
336
+ async getEventStats(criteria = {}) {
337
+ throw new Error('ICaptureQuery.getEventStats() must be implemented');
338
+ }
339
+ }
340
+
341
+ /**
342
+ * Interface for analyzing capture data patterns
343
+ *
344
+ * RESPONSIBILITY: Extract insights and patterns from events
345
+ * INDEPENDENCE: Can analyze any CaptureEvent data
346
+ */
347
+ export class ICaptureAnalyzer {
348
+ /**
349
+ * Initialize the analyzer
350
+ * @param {ICaptureQuery} query - Query interface for data access
351
+ * @returns {Promise<void>}
352
+ */
353
+ async initialize(query) {
354
+ throw new Error('ICaptureAnalyzer.initialize() must be implemented');
355
+ }
356
+
357
+ /**
358
+ * Analyze user interaction patterns
359
+ * @param {string} sessionId - Session to analyze
360
+ * @returns {Promise<Object>} Interaction analysis
361
+ */
362
+ async analyzeInteractions(sessionId) {
363
+ throw new Error('ICaptureAnalyzer.analyzeInteractions() must be implemented');
364
+ }
365
+
366
+ /**
367
+ * Analyze performance patterns
368
+ * @param {string} sessionId - Session to analyze
369
+ * @returns {Promise<Object>} Performance analysis
370
+ */
371
+ async analyzePerformance(sessionId) {
372
+ throw new Error('ICaptureAnalyzer.analyzePerformance() must be implemented');
373
+ }
374
+
375
+ /**
376
+ * Detect errors and issues
377
+ * @param {string} sessionId - Session to analyze
378
+ * @returns {Promise<Object>} Error analysis
379
+ */
380
+ async detectErrors(sessionId) {
381
+ throw new Error('ICaptureAnalyzer.detectErrors() must be implemented');
382
+ }
383
+
384
+ /**
385
+ * Generate session summary
386
+ * @param {string} sessionId - Session to summarize
387
+ * @returns {Promise<Object>} Session summary
388
+ */
389
+ async generateSummary(sessionId) {
390
+ throw new Error('ICaptureAnalyzer.generateSummary() must be implemented');
391
+ }
392
+
393
+ /**
394
+ * Compare multiple sessions
395
+ * @param {string[]} sessionIds - Sessions to compare
396
+ * @returns {Promise<Object>} Comparison results
397
+ */
398
+ async compareSessions(sessionIds) {
399
+ throw new Error('ICaptureAnalyzer.compareSessions() must be implemented');
400
+ }
401
+ }
402
+
403
+ /**
404
+ * Interface for memory management and optimization
405
+ *
406
+ * RESPONSIBILITY: Manage memory usage and optimize performance
407
+ * INDEPENDENCE: Can manage any capture system component
408
+ */
409
+ export class ICaptureMemoryManager {
410
+ /**
411
+ * Initialize the memory manager
412
+ * @param {Object} config - Memory management configuration
413
+ * @returns {Promise<void>}
414
+ */
415
+ async initialize(config) {
416
+ throw new Error('ICaptureMemoryManager.initialize() must be implemented');
417
+ }
418
+
419
+ /**
420
+ * Check current memory usage
421
+ * @returns {Promise<Object>} Memory usage statistics
422
+ */
423
+ async getMemoryUsage() {
424
+ throw new Error('ICaptureMemoryManager.getMemoryUsage() must be implemented');
425
+ }
426
+
427
+ /**
428
+ * Request memory cleanup
429
+ * @param {string} [priority='normal'] - Cleanup priority
430
+ * @returns {Promise<Object>} Cleanup results
431
+ */
432
+ async requestCleanup(priority = 'normal') {
433
+ throw new Error('ICaptureMemoryManager.requestCleanup() must be implemented');
434
+ }
435
+
436
+ /**
437
+ * Set memory limits
438
+ * @param {Object} limits - Memory limits configuration
439
+ * @returns {Promise<void>}
440
+ */
441
+ async setLimits(limits) {
442
+ throw new Error('ICaptureMemoryManager.setLimits() must be implemented');
443
+ }
444
+
445
+ /**
446
+ * Register component for memory monitoring
447
+ * @param {string} componentId - Component identifier
448
+ * @param {Object} component - Component to monitor
449
+ * @returns {Promise<void>}
450
+ */
451
+ async registerComponent(componentId, component) {
452
+ throw new Error('ICaptureMemoryManager.registerComponent() must be implemented');
453
+ }
454
+ }
455
+
456
+ /**
457
+ * Error handling interface for capture system
458
+ *
459
+ * RESPONSIBILITY: Standardized error handling across all modules
460
+ * INDEPENDENCE: Can handle errors from any capture component
461
+ */
462
+ export class ICaptureErrorHandler {
463
+ /**
464
+ * Initialize the error handler
465
+ * @param {Object} config - Error handling configuration
466
+ * @returns {Promise<void>}
467
+ */
468
+ async initialize(config) {
469
+ throw new Error('ICaptureErrorHandler.initialize() must be implemented');
470
+ }
471
+
472
+ /**
473
+ * Handle capture error
474
+ * @param {Error} error - Error to handle
475
+ * @param {Object} context - Error context
476
+ * @returns {Promise<void>}
477
+ */
478
+ async handleError(error, context) {
479
+ throw new Error('ICaptureErrorHandler.handleError() must be implemented');
480
+ }
481
+
482
+ /**
483
+ * Get error statistics
484
+ * @returns {Promise<Object>} Error statistics
485
+ */
486
+ async getErrorStats() {
487
+ throw new Error('ICaptureErrorHandler.getErrorStats() must be implemented');
488
+ }
489
+
490
+ /**
491
+ * Register error recovery strategy
492
+ * @param {string} errorType - Type of error
493
+ * @param {Function} recoveryFn - Recovery function
494
+ * @returns {Promise<void>}
495
+ */
496
+ async registerRecovery(errorType, recoveryFn) {
497
+ throw new Error('ICaptureErrorHandler.registerRecovery() must be implemented');
498
+ }
499
+ }
500
+
501
+ /**
502
+ * Main capture system coordinator interface
503
+ *
504
+ * RESPONSIBILITY: Coordinate all capture system components
505
+ * INDEPENDENCE: Orchestrates but doesn't implement specific capture logic
506
+ */
507
+ export class ICaptureSystem {
508
+ /**
509
+ * Initialize the complete capture system
510
+ * @param {Object} config - System configuration
511
+ * @returns {Promise<void>}
512
+ */
513
+ async initialize(config) {
514
+ throw new Error('ICaptureSystem.initialize() must be implemented');
515
+ }
516
+
517
+ /**
518
+ * Start a new capture session
519
+ * @param {Object} sessionConfig - Session configuration
520
+ * @returns {Promise<CaptureSession>} Created session
521
+ */
522
+ async startSession(sessionConfig) {
523
+ throw new Error('ICaptureSystem.startSession() must be implemented');
524
+ }
525
+
526
+ /**
527
+ * Stop the current capture session
528
+ * @returns {Promise<void>}
529
+ */
530
+ async stopSession() {
531
+ throw new Error('ICaptureSystem.stopSession() must be implemented');
532
+ }
533
+
534
+ /**
535
+ * Get system status
536
+ * @returns {Promise<Object>} System status
537
+ */
538
+ async getStatus() {
539
+ throw new Error('ICaptureSystem.getStatus() must be implemented');
540
+ }
541
+
542
+ /**
543
+ * Shutdown the capture system
544
+ * @returns {Promise<void>}
545
+ */
546
+ async shutdown() {
547
+ throw new Error('ICaptureSystem.shutdown() must be implemented');
548
+ }
549
+ }
550
+
551
+ /**
552
+ * Module registry for dependency injection and testing
553
+ */
554
+ export class CaptureModuleRegistry {
555
+ constructor() {
556
+ this.modules = new Map();
557
+ this.instances = new Map();
558
+ }
559
+
560
+ /**
561
+ * Register a module implementation
562
+ * @param {string} interfaceName - Interface name
563
+ * @param {Class} implementation - Implementation class
564
+ */
565
+ register(interfaceName, implementation) {
566
+ this.modules.set(interfaceName, implementation);
567
+ }
568
+
569
+ /**
570
+ * Get module implementation
571
+ * @param {string} interfaceName - Interface name
572
+ * @returns {Class} Implementation class
573
+ */
574
+ get(interfaceName) {
575
+ return this.modules.get(interfaceName);
576
+ }
577
+
578
+ /**
579
+ * Create module instance
580
+ * @param {string} interfaceName - Interface name
581
+ * @param {...any} args - Constructor arguments
582
+ * @returns {Object} Module instance
583
+ */
584
+ create(interfaceName, ...args) {
585
+ const Implementation = this.modules.get(interfaceName);
586
+ if (!Implementation) {
587
+ throw new Error(`No implementation registered for ${interfaceName}`);
588
+ }
589
+ return new Implementation(...args);
590
+ }
591
+
592
+ /**
593
+ * Get or create singleton instance
594
+ * @param {string} interfaceName - Interface name
595
+ * @param {...any} args - Constructor arguments
596
+ * @returns {Object} Module instance
597
+ */
598
+ getInstance(interfaceName, ...args) {
599
+ if (!this.instances.has(interfaceName)) {
600
+ this.instances.set(interfaceName, this.create(interfaceName, ...args));
601
+ }
602
+ return this.instances.get(interfaceName);
603
+ }
604
+
605
+ /**
606
+ * Clear all registrations
607
+ */
608
+ clear() {
609
+ this.modules.clear();
610
+ this.instances.clear();
611
+ }
612
+ }
613
+
614
+ // Export all interfaces for easy importing
615
+ export {
616
+ ICaptureSource,
617
+ ICaptureCollector,
618
+ ICaptureProcessor,
619
+ ICaptureStorage,
620
+ ICaptureQuery,
621
+ ICaptureAnalyzer,
622
+ ICaptureMemoryManager,
623
+ ICaptureErrorHandler,
624
+ ICaptureSystem
625
+ };