agentgui 1.0.822 → 1.0.824

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.
@@ -1,118 +0,0 @@
1
- class EventFilter {
2
- constructor(renderer) {
3
- this.renderer = renderer;
4
- this.allEvents = [];
5
- this.filteredEvents = [];
6
- this.filterState = {
7
- types: new Set(),
8
- searchText: '',
9
- startTime: null,
10
- endTime: null,
11
- isActive: false
12
- };
13
- this.replayState = {
14
- isReplaying: false,
15
- currentIndex: 0,
16
- speed: 1
17
- };
18
- }
19
-
20
- trackEvent(event) {
21
- this.allEvents.push({
22
- ...event,
23
- trackingId: this.allEvents.length,
24
- trackedAt: Date.now()
25
- });
26
- if (this.allEvents.length > 5000) this.allEvents.shift();
27
- if (this.filterState.isActive) this.applyFilters();
28
- return event;
29
- }
30
-
31
- setTypeFilter(types) { this.filterState.types = new Set(types); this.applyFilters(); }
32
-
33
- toggleType(type) {
34
- if (this.filterState.types.has(type)) this.filterState.types.delete(type);
35
- else this.filterState.types.add(type);
36
- this.applyFilters();
37
- }
38
-
39
- setSearchText(text) { this.filterState.searchText = text.toLowerCase(); this.applyFilters(); }
40
-
41
- setTimeRange(startTime, endTime) { this.filterState.startTime = startTime; this.filterState.endTime = endTime; this.applyFilters(); }
42
-
43
- applyFilters() {
44
- this.filterState.isActive =
45
- this.filterState.types.size > 0 ||
46
- this.filterState.searchText.length > 0 ||
47
- this.filterState.startTime !== null ||
48
- this.filterState.endTime !== null;
49
- if (!this.filterState.isActive) { this.filteredEvents = [...this.allEvents]; return this.filteredEvents; }
50
- this.filteredEvents = this.allEvents.filter(event => {
51
- if (this.filterState.types.size > 0 && !this.filterState.types.has(event.type)) return false;
52
- if (this.filterState.searchText.length > 0) {
53
- if (!JSON.stringify(event).toLowerCase().includes(this.filterState.searchText)) return false;
54
- }
55
- const eventTime = event.timestamp || event.trackedAt;
56
- if (this.filterState.startTime && eventTime < this.filterState.startTime) return false;
57
- if (this.filterState.endTime && eventTime > this.filterState.endTime) return false;
58
- return true;
59
- });
60
- return this.filteredEvents;
61
- }
62
-
63
- search(query) {
64
- const lowerQuery = query.toLowerCase();
65
- return this.allEvents.map((event, i) => {
66
- const searchable = JSON.stringify(event).toLowerCase();
67
- if (!searchable.includes(lowerQuery)) return null;
68
- return { event, index: i, matchCount: (searchable.match(new RegExp(lowerQuery, 'g')) || []).length };
69
- }).filter(Boolean).sort((a, b) => b.matchCount - a.matchCount);
70
- }
71
-
72
- getStats() {
73
- const stats = { total: this.allEvents.length, byType: {}, byTime: { oldest: null, newest: null, span: 0 } };
74
- for (const event of this.allEvents) {
75
- stats.byType[event.type] = (stats.byType[event.type] || 0) + 1;
76
- const time = event.timestamp || event.trackedAt;
77
- if (!stats.byTime.oldest || time < stats.byTime.oldest) stats.byTime.oldest = time;
78
- if (!stats.byTime.newest || time > stats.byTime.newest) stats.byTime.newest = time;
79
- }
80
- if (stats.byTime.oldest && stats.byTime.newest) stats.byTime.span = stats.byTime.newest - stats.byTime.oldest;
81
- return stats;
82
- }
83
-
84
- async startReplay(events = null, speed = 1) {
85
- const replayEvents = events || this.filteredEvents;
86
- if (replayEvents.length === 0) return;
87
- this.replayState = { isReplaying: true, currentIndex: 0, speed };
88
- this.renderer.clear();
89
- for (const event of replayEvents) {
90
- if (!this.replayState.isReplaying) break;
91
- await new Promise(resolve => setTimeout(resolve, 100 / this.replayState.speed));
92
- this.renderer.queueEvent(event);
93
- this.replayState.currentIndex++;
94
- }
95
- this.replayState.isReplaying = false;
96
- }
97
-
98
- stopReplay() { this.replayState.isReplaying = false; }
99
-
100
- getReplayProgress() {
101
- const total = this.filteredEvents.length;
102
- const current = this.replayState.currentIndex;
103
- return { current, total, percentage: total > 0 ? (current / total) * 100 : 0, isReplaying: this.replayState.isReplaying };
104
- }
105
-
106
- export(format = 'json') {
107
- const events = this.filterState.isActive ? this.filteredEvents : this.allEvents;
108
- if (format === 'csv') return window.exportEventsAsCSV(events);
109
- if (format === 'markdown') return window.exportEventsAsMarkdown(events);
110
- return window.exportEventsAsJSON(events);
111
- }
112
-
113
- clear() { this.allEvents = []; this.filteredEvents = []; this.stopReplay(); }
114
- }
115
-
116
- window.EventFilter = EventFilter;
117
-
118
- if (typeof module !== 'undefined' && module.exports) module.exports = EventFilter;