claude-mpm 5.1.9__py3-none-any.whl → 5.4.14__py3-none-any.whl

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.

Potentially problematic release.


This version of claude-mpm might be problematic. Click here for more details.

Files changed (162) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/__init__.py +4 -0
  3. claude_mpm/agents/PM_INSTRUCTIONS.md +85 -0
  4. claude_mpm/agents/agent_loader.py +13 -44
  5. claude_mpm/agents/templates/circuit-breakers.md +138 -1
  6. claude_mpm/cli/__main__.py +4 -0
  7. claude_mpm/cli/commands/agent_state_manager.py +8 -17
  8. claude_mpm/cli/commands/auto_configure.py +210 -25
  9. claude_mpm/cli/commands/config.py +88 -2
  10. claude_mpm/cli/commands/configure.py +1097 -158
  11. claude_mpm/cli/commands/configure_agent_display.py +15 -6
  12. claude_mpm/cli/commands/mpm_init/core.py +160 -46
  13. claude_mpm/cli/commands/mpm_init/knowledge_extractor.py +481 -0
  14. claude_mpm/cli/commands/mpm_init/prompts.py +280 -0
  15. claude_mpm/cli/commands/skills.py +21 -2
  16. claude_mpm/cli/commands/summarize.py +413 -0
  17. claude_mpm/cli/executor.py +11 -3
  18. claude_mpm/cli/parsers/base_parser.py +5 -0
  19. claude_mpm/cli/parsers/config_parser.py +153 -83
  20. claude_mpm/cli/parsers/skills_parser.py +3 -2
  21. claude_mpm/cli/startup.py +333 -89
  22. claude_mpm/commands/mpm-config.md +266 -0
  23. claude_mpm/commands/{mpm-ticket-organize.md → mpm-organize.md} +4 -5
  24. claude_mpm/config/agent_sources.py +27 -0
  25. claude_mpm/core/framework/formatters/content_formatter.py +3 -13
  26. claude_mpm/core/framework/loaders/agent_loader.py +8 -5
  27. claude_mpm/core/framework_loader.py +4 -2
  28. claude_mpm/core/logger.py +13 -0
  29. claude_mpm/core/socketio_pool.py +3 -3
  30. claude_mpm/core/unified_agent_registry.py +5 -15
  31. claude_mpm/hooks/claude_hooks/correlation_manager.py +60 -0
  32. claude_mpm/hooks/claude_hooks/event_handlers.py +206 -78
  33. claude_mpm/hooks/claude_hooks/hook_handler.py +6 -0
  34. claude_mpm/hooks/claude_hooks/installer.py +33 -10
  35. claude_mpm/hooks/claude_hooks/memory_integration.py +26 -9
  36. claude_mpm/hooks/claude_hooks/response_tracking.py +2 -3
  37. claude_mpm/hooks/claude_hooks/services/connection_manager.py +4 -0
  38. claude_mpm/hooks/memory_integration_hook.py +46 -1
  39. claude_mpm/init.py +0 -19
  40. claude_mpm/scripts/claude-hook-handler.sh +58 -18
  41. claude_mpm/scripts/launch_monitor.py +93 -13
  42. claude_mpm/services/agents/agent_recommendation_service.py +278 -0
  43. claude_mpm/services/agents/agent_review_service.py +280 -0
  44. claude_mpm/services/agents/deployment/agent_discovery_service.py +2 -3
  45. claude_mpm/services/agents/deployment/agent_template_builder.py +4 -2
  46. claude_mpm/services/agents/deployment/multi_source_deployment_service.py +78 -9
  47. claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +335 -53
  48. claude_mpm/services/agents/git_source_manager.py +34 -0
  49. claude_mpm/services/agents/loading/base_agent_manager.py +1 -13
  50. claude_mpm/services/agents/sources/git_source_sync_service.py +8 -1
  51. claude_mpm/services/agents/toolchain_detector.py +10 -6
  52. claude_mpm/services/analysis/__init__.py +11 -1
  53. claude_mpm/services/analysis/clone_detector.py +1030 -0
  54. claude_mpm/services/command_deployment_service.py +71 -10
  55. claude_mpm/services/event_bus/config.py +3 -1
  56. claude_mpm/services/git/git_operations_service.py +93 -8
  57. claude_mpm/services/monitor/daemon.py +9 -2
  58. claude_mpm/services/monitor/daemon_manager.py +39 -3
  59. claude_mpm/services/monitor/server.py +225 -19
  60. claude_mpm/services/self_upgrade_service.py +120 -12
  61. claude_mpm/services/skills/__init__.py +3 -0
  62. claude_mpm/services/skills/git_skill_source_manager.py +32 -2
  63. claude_mpm/services/skills/selective_skill_deployer.py +230 -0
  64. claude_mpm/services/skills/skill_to_agent_mapper.py +406 -0
  65. claude_mpm/services/skills_deployer.py +64 -3
  66. claude_mpm/services/socketio/event_normalizer.py +15 -1
  67. claude_mpm/services/socketio/server/core.py +160 -21
  68. claude_mpm/services/version_control/git_operations.py +103 -0
  69. claude_mpm/utils/agent_filters.py +17 -44
  70. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/METADATA +47 -84
  71. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/RECORD +76 -150
  72. claude_mpm-5.4.14.dist-info/entry_points.txt +5 -0
  73. claude_mpm-5.4.14.dist-info/licenses/LICENSE +94 -0
  74. claude_mpm-5.4.14.dist-info/licenses/LICENSE-FAQ.md +153 -0
  75. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +0 -292
  76. claude_mpm/agents/BASE_DOCUMENTATION.md +0 -53
  77. claude_mpm/agents/BASE_ENGINEER.md +0 -658
  78. claude_mpm/agents/BASE_OPS.md +0 -219
  79. claude_mpm/agents/BASE_PM.md +0 -480
  80. claude_mpm/agents/BASE_PROMPT_ENGINEER.md +0 -787
  81. claude_mpm/agents/BASE_QA.md +0 -167
  82. claude_mpm/agents/BASE_RESEARCH.md +0 -53
  83. claude_mpm/agents/base_agent.json +0 -31
  84. claude_mpm/agents/base_agent_loader.py +0 -601
  85. claude_mpm/cli/ticket_cli.py +0 -35
  86. claude_mpm/commands/mpm-config-view.md +0 -150
  87. claude_mpm/dashboard/analysis_runner.py +0 -455
  88. claude_mpm/dashboard/index.html +0 -13
  89. claude_mpm/dashboard/open_dashboard.py +0 -66
  90. claude_mpm/dashboard/static/css/activity.css +0 -1958
  91. claude_mpm/dashboard/static/css/connection-status.css +0 -370
  92. claude_mpm/dashboard/static/css/dashboard.css +0 -4701
  93. claude_mpm/dashboard/static/js/components/activity-tree.js +0 -1871
  94. claude_mpm/dashboard/static/js/components/agent-hierarchy.js +0 -777
  95. claude_mpm/dashboard/static/js/components/agent-inference.js +0 -956
  96. claude_mpm/dashboard/static/js/components/build-tracker.js +0 -333
  97. claude_mpm/dashboard/static/js/components/code-simple.js +0 -857
  98. claude_mpm/dashboard/static/js/components/connection-debug.js +0 -654
  99. claude_mpm/dashboard/static/js/components/diff-viewer.js +0 -891
  100. claude_mpm/dashboard/static/js/components/event-processor.js +0 -542
  101. claude_mpm/dashboard/static/js/components/event-viewer.js +0 -1155
  102. claude_mpm/dashboard/static/js/components/export-manager.js +0 -368
  103. claude_mpm/dashboard/static/js/components/file-change-tracker.js +0 -443
  104. claude_mpm/dashboard/static/js/components/file-change-viewer.js +0 -690
  105. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +0 -724
  106. claude_mpm/dashboard/static/js/components/file-viewer.js +0 -580
  107. claude_mpm/dashboard/static/js/components/hud-library-loader.js +0 -211
  108. claude_mpm/dashboard/static/js/components/hud-manager.js +0 -671
  109. claude_mpm/dashboard/static/js/components/hud-visualizer.js +0 -1718
  110. claude_mpm/dashboard/static/js/components/module-viewer.js +0 -2764
  111. claude_mpm/dashboard/static/js/components/session-manager.js +0 -579
  112. claude_mpm/dashboard/static/js/components/socket-manager.js +0 -368
  113. claude_mpm/dashboard/static/js/components/ui-state-manager.js +0 -749
  114. claude_mpm/dashboard/static/js/components/unified-data-viewer.js +0 -1824
  115. claude_mpm/dashboard/static/js/components/working-directory.js +0 -920
  116. claude_mpm/dashboard/static/js/connection-manager.js +0 -536
  117. claude_mpm/dashboard/static/js/dashboard.js +0 -1914
  118. claude_mpm/dashboard/static/js/extension-error-handler.js +0 -164
  119. claude_mpm/dashboard/static/js/socket-client.js +0 -1474
  120. claude_mpm/dashboard/static/js/tab-isolation-fix.js +0 -185
  121. claude_mpm/dashboard/static/socket.io.min.js +0 -7
  122. claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +0 -7
  123. claude_mpm/dashboard/templates/code_simple.html +0 -153
  124. claude_mpm/dashboard/templates/index.html +0 -606
  125. claude_mpm/dashboard/test_dashboard.html +0 -372
  126. claude_mpm/scripts/mcp_server.py +0 -75
  127. claude_mpm/scripts/mcp_wrapper.py +0 -39
  128. claude_mpm/services/mcp_gateway/__init__.py +0 -159
  129. claude_mpm/services/mcp_gateway/auto_configure.py +0 -369
  130. claude_mpm/services/mcp_gateway/config/__init__.py +0 -17
  131. claude_mpm/services/mcp_gateway/config/config_loader.py +0 -296
  132. claude_mpm/services/mcp_gateway/config/config_schema.py +0 -243
  133. claude_mpm/services/mcp_gateway/config/configuration.py +0 -429
  134. claude_mpm/services/mcp_gateway/core/__init__.py +0 -43
  135. claude_mpm/services/mcp_gateway/core/base.py +0 -312
  136. claude_mpm/services/mcp_gateway/core/exceptions.py +0 -253
  137. claude_mpm/services/mcp_gateway/core/interfaces.py +0 -443
  138. claude_mpm/services/mcp_gateway/core/process_pool.py +0 -977
  139. claude_mpm/services/mcp_gateway/core/singleton_manager.py +0 -315
  140. claude_mpm/services/mcp_gateway/core/startup_verification.py +0 -316
  141. claude_mpm/services/mcp_gateway/main.py +0 -589
  142. claude_mpm/services/mcp_gateway/registry/__init__.py +0 -12
  143. claude_mpm/services/mcp_gateway/registry/service_registry.py +0 -412
  144. claude_mpm/services/mcp_gateway/registry/tool_registry.py +0 -489
  145. claude_mpm/services/mcp_gateway/server/__init__.py +0 -15
  146. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +0 -414
  147. claude_mpm/services/mcp_gateway/server/stdio_handler.py +0 -372
  148. claude_mpm/services/mcp_gateway/server/stdio_server.py +0 -712
  149. claude_mpm/services/mcp_gateway/tools/__init__.py +0 -36
  150. claude_mpm/services/mcp_gateway/tools/base_adapter.py +0 -485
  151. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +0 -789
  152. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +0 -654
  153. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +0 -456
  154. claude_mpm/services/mcp_gateway/tools/hello_world.py +0 -551
  155. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +0 -555
  156. claude_mpm/services/mcp_gateway/utils/__init__.py +0 -14
  157. claude_mpm/services/mcp_gateway/utils/package_version_checker.py +0 -160
  158. claude_mpm/services/mcp_gateway/utils/update_preferences.py +0 -170
  159. claude_mpm-5.1.9.dist-info/entry_points.txt +0 -10
  160. claude_mpm-5.1.9.dist-info/licenses/LICENSE +0 -21
  161. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/WHEEL +0 -0
  162. {claude_mpm-5.1.9.dist-info → claude_mpm-5.4.14.dist-info}/top_level.txt +0 -0
@@ -1,542 +0,0 @@
1
- /**
2
- * Event Processor Module
3
- *
4
- * Handles event processing, filtering, and rendering for different tabs in the dashboard.
5
- * Provides centralized event filtering and rendering logic for agents, tools, and files tabs.
6
- *
7
- * WHY: Extracted from main dashboard to isolate complex event processing logic
8
- * that involves filtering, transforming, and rendering events across different views.
9
- * This improves maintainability and makes the event processing logic testable.
10
- *
11
- * DESIGN DECISION: Maintains its own filtered event collections while relying on
12
- * eventViewer for source data. Provides separate filtering logic for each tab type
13
- * while sharing common filtering patterns and utilities.
14
- */
15
- class EventProcessor {
16
- constructor(eventViewer, agentInference) {
17
- this.eventViewer = eventViewer;
18
- this.agentInference = agentInference;
19
-
20
- // Processed event collections for different tabs
21
- this.agentEvents = [];
22
- this.filteredAgentEvents = [];
23
- this.filteredToolEvents = [];
24
- this.filteredFileEvents = [];
25
-
26
- // Session filtering
27
- this.selectedSessionId = null;
28
-
29
- console.log('Event processor initialized');
30
- }
31
-
32
- /**
33
- * Get filtered events for a specific tab
34
- * @param {string} tabName - Tab name ('agents', 'tools', 'files', 'events')
35
- * @returns {Array} - Filtered events
36
- */
37
- getFilteredEventsForTab(tabName) {
38
- const events = this.eventViewer.events;
39
- console.log(`getFilteredEventsForTab(${tabName}) - using RAW events: ${events.length} total`);
40
-
41
- // Use session manager to filter events by session if needed
42
- const sessionManager = window.sessionManager;
43
- if (sessionManager && sessionManager.selectedSessionId) {
44
- const sessionEvents = sessionManager.getEventsForSession(sessionManager.selectedSessionId);
45
- console.log(`Filtering by session ${sessionManager.selectedSessionId}: ${sessionEvents.length} events`);
46
- return sessionEvents;
47
- }
48
-
49
- return events;
50
- }
51
-
52
- /**
53
- * Apply agents tab filtering for unique instances
54
- * @param {Array} uniqueInstances - Unique agent instances to filter
55
- * @returns {Array} - Filtered unique instances
56
- */
57
- applyAgentsFilters(uniqueInstances) {
58
- const searchInput = document.getElementById('agents-search-input');
59
- const typeFilter = document.getElementById('agents-type-filter');
60
-
61
- const searchText = searchInput ? searchInput.value.toLowerCase() : '';
62
- const typeValue = typeFilter ? typeFilter.value : '';
63
-
64
- return uniqueInstances.filter(instance => {
65
- // Search filter
66
- if (searchText) {
67
- const searchableText = [
68
- instance.agentName || '',
69
- instance.type || '',
70
- instance.isImplied ? 'implied' : 'explicit'
71
- ].join(' ').toLowerCase();
72
-
73
- if (!searchableText.includes(searchText)) {
74
- return false;
75
- }
76
- }
77
-
78
- // Type filter
79
- if (typeValue) {
80
- const agentName = instance.agentName || 'unknown';
81
- if (!agentName.toLowerCase().includes(typeValue.toLowerCase())) {
82
- return false;
83
- }
84
- }
85
-
86
- return true;
87
- });
88
- }
89
-
90
- /**
91
- * Apply tools tab filtering
92
- * @param {Array} events - Events to filter
93
- * @returns {Array} - Filtered events
94
- */
95
- applyToolsFilters(events) {
96
- const searchInput = document.getElementById('tools-search-input');
97
- const typeFilter = document.getElementById('tools-type-filter');
98
-
99
- const searchText = searchInput ? searchInput.value.toLowerCase() : '';
100
- const typeValue = typeFilter ? typeFilter.value : '';
101
-
102
- return events.filter(event => {
103
- // Search filter
104
- if (searchText) {
105
- const searchableText = [
106
- event.tool_name || '',
107
- event.agent_type || '',
108
- event.type || '',
109
- event.subtype || ''
110
- ].join(' ').toLowerCase();
111
-
112
- if (!searchableText.includes(searchText)) {
113
- return false;
114
- }
115
- }
116
-
117
- // Type filter
118
- if (typeValue) {
119
- const toolName = event.tool_name || '';
120
- if (toolName !== typeValue) {
121
- return false;
122
- }
123
- }
124
-
125
- return true;
126
- });
127
- }
128
-
129
- /**
130
- * Apply tools tab filtering for tool calls
131
- * @param {Array} toolCallsArray - Tool calls array to filter
132
- * @returns {Array} - Filtered tool calls
133
- */
134
- applyToolCallFilters(toolCallsArray) {
135
- const searchInput = document.getElementById('tools-search-input');
136
- const typeFilter = document.getElementById('tools-type-filter');
137
-
138
- const searchText = searchInput ? searchInput.value.toLowerCase() : '';
139
- const typeValue = typeFilter ? typeFilter.value : '';
140
-
141
- return toolCallsArray.filter(([key, toolCall]) => {
142
- // Search filter
143
- if (searchText) {
144
- const searchableText = [
145
- toolCall.tool_name || '',
146
- toolCall.agent_type || '',
147
- 'tool_call'
148
- ].join(' ').toLowerCase();
149
-
150
- if (!searchableText.includes(searchText)) {
151
- return false;
152
- }
153
- }
154
-
155
- // Type filter
156
- if (typeValue) {
157
- const toolName = toolCall.tool_name || '';
158
- if (toolName !== typeValue) {
159
- return false;
160
- }
161
- }
162
-
163
- return true;
164
- });
165
- }
166
-
167
- /**
168
- * Apply files tab filtering
169
- * @param {Array} fileOperations - File operations to filter
170
- * @returns {Array} - Filtered file operations
171
- */
172
- applyFilesFilters(fileOperations) {
173
- const searchInput = document.getElementById('files-search-input');
174
- const typeFilter = document.getElementById('files-type-filter');
175
-
176
- const searchText = searchInput ? searchInput.value.toLowerCase() : '';
177
- const typeValue = typeFilter ? typeFilter.value : '';
178
-
179
- return fileOperations.filter(([filePath, fileData]) => {
180
- // Session filter - filter operations within each file
181
- if (this.selectedSessionId) {
182
- // Filter operations for this file by session
183
- const sessionOperations = fileData.operations.filter(op =>
184
- op.sessionId === this.selectedSessionId
185
- );
186
-
187
- // If no operations from this session, exclude the file
188
- if (sessionOperations.length === 0) {
189
- return false;
190
- }
191
-
192
- // Update the fileData to only include session-specific operations
193
- // (Note: This creates a filtered view without modifying the original)
194
- fileData = {
195
- ...fileData,
196
- operations: sessionOperations,
197
- lastOperation: sessionOperations[sessionOperations.length - 1]?.timestamp || fileData.lastOperation
198
- };
199
- }
200
-
201
- // Search filter
202
- if (searchText) {
203
- const searchableText = [
204
- filePath,
205
- ...fileData.operations.map(op => op.operation),
206
- ...fileData.operations.map(op => op.agent)
207
- ].join(' ').toLowerCase();
208
-
209
- if (!searchableText.includes(searchText)) {
210
- return false;
211
- }
212
- }
213
-
214
- // Type filter
215
- if (typeValue) {
216
- const operations = fileData.operations.map(op => op.operation);
217
- if (!operations.includes(typeValue)) {
218
- return false;
219
- }
220
- }
221
-
222
- return true;
223
- });
224
- }
225
-
226
- /**
227
- * Extract operation type from event type
228
- * @param {string} eventType - Event type string
229
- * @returns {string} - Operation type
230
- */
231
- extractOperation(eventType) {
232
- if (!eventType) return 'unknown';
233
-
234
- const type = eventType.toLowerCase();
235
- if (type.includes('read')) return 'read';
236
- if (type.includes('write')) return 'write';
237
- if (type.includes('edit')) return 'edit';
238
- if (type.includes('create')) return 'create';
239
- if (type.includes('delete')) return 'delete';
240
- if (type.includes('move') || type.includes('rename')) return 'move';
241
-
242
- return 'other';
243
- }
244
-
245
- /**
246
- * Extract tool name from hook event type
247
- * @param {string} eventType - Hook event type
248
- * @returns {string} - Tool name
249
- */
250
- extractToolFromHook(eventType) {
251
- if (!eventType) return '';
252
-
253
- // Pattern: Pre{ToolName}Use or Post{ToolName}Use
254
- const match = eventType.match(/^(?:Pre|Post)(.+)Use$/);
255
- return match ? match[1] : '';
256
- }
257
-
258
- /**
259
- * Extract tool name from subtype
260
- * @param {string} subtype - Event subtype
261
- * @returns {string} - Tool name
262
- */
263
- extractToolFromSubtype(subtype) {
264
- if (!subtype) return '';
265
-
266
- // Handle various subtype patterns
267
- if (subtype.includes('_')) {
268
- const parts = subtype.split('_');
269
- return parts[0] || '';
270
- }
271
-
272
- return subtype;
273
- }
274
-
275
- /**
276
- * Extract target information from tool parameters
277
- * @param {string} toolName - Tool name
278
- * @param {Object} params - Tool parameters
279
- * @param {Object} toolParameters - Alternative tool parameters
280
- * @returns {string} - Target information
281
- */
282
- extractToolTarget(toolName, params, toolParameters) {
283
- const parameters = params || toolParameters || {};
284
-
285
- switch (toolName?.toLowerCase()) {
286
- case 'read':
287
- case 'write':
288
- case 'edit':
289
- return parameters.file_path || parameters.path || '';
290
- case 'bash':
291
- return parameters.command || '';
292
- case 'grep':
293
- return parameters.pattern || '';
294
- case 'task':
295
- return parameters.subagent_type || parameters.agent_type || '';
296
- default:
297
- // Try to find a meaningful parameter
298
- const keys = Object.keys(parameters);
299
- const meaningfulKeys = ['path', 'file_path', 'command', 'pattern', 'query', 'target'];
300
- for (const key of meaningfulKeys) {
301
- if (parameters[key]) {
302
- return parameters[key];
303
- }
304
- }
305
- return keys.length > 0 ? `${keys[0]}: ${parameters[keys[0]]}` : '';
306
- }
307
- }
308
-
309
- /**
310
- * Generate HTML for unique agent instances (one row per PM delegation)
311
- * @param {Array} events - Agent events to render (not used, kept for compatibility)
312
- * @returns {string} - HTML string
313
- */
314
- generateAgentHTML(events) {
315
- // Get unique agent instances from agent inference
316
- const uniqueInstances = this.agentInference.getUniqueAgentInstances();
317
-
318
- // Apply filtering
319
- const filteredInstances = this.applyAgentsFilters(uniqueInstances);
320
-
321
- return filteredInstances.map((instance, index) => {
322
- const agentName = instance.agentName;
323
- const timestamp = this.formatTimestamp(instance.firstTimestamp || instance.timestamp);
324
- const delegationType = instance.isImplied ? 'implied' : 'explicit';
325
- // Fix: Use totalEventCount which is the actual property name from getUniqueAgentInstances()
326
- const eventCount = instance.totalEventCount || instance.eventCount || 0;
327
-
328
- const onclickString = `dashboard.selectCard('agents', ${index}, 'agent_instance', '${instance.id}'); dashboard.showAgentInstanceDetails('${instance.id}');`;
329
-
330
- // Format: "[Agent Name] (delegationType, eventCount events)" with separate timestamp
331
- const agentMainContent = `${agentName} (${delegationType}, ${eventCount} events)`;
332
-
333
- return `
334
- <div class="event-item single-row event-agent" onclick="${onclickString}">
335
- <span class="event-single-row-content">
336
- <span class="event-content-main">${agentMainContent}</span>
337
- <span class="event-timestamp">${timestamp}</span>
338
- </span>
339
- </div>
340
- `;
341
- }).join('');
342
- }
343
-
344
- /**
345
- * Generate HTML for tool events
346
- * @param {Array} toolCalls - Tool calls to render
347
- * @returns {string} - HTML string
348
- */
349
- generateToolHTML(toolCalls) {
350
- const filteredToolCalls = this.applyToolCallFilters(toolCalls);
351
-
352
- return filteredToolCalls.map(([key, toolCall], index) => {
353
- const toolName = toolCall.tool_name || 'Unknown';
354
- const rawAgent = toolCall.agent_type || 'Unknown';
355
- const timestamp = this.formatTimestamp(toolCall.timestamp);
356
- const status = toolCall.post_event ? 'completed' : 'pending';
357
- const statusClass = status === 'completed' ? 'status-success' : 'status-pending';
358
-
359
- // Convert agent name: show "pm" for PM agent, otherwise show actual agent name
360
- const agentName = rawAgent.toLowerCase() === 'pm' ? 'pm' : rawAgent;
361
-
362
- // Format: "Tool Name (Agent Name)" - removed duration from main display
363
- const toolMainContent = `${toolName} (${agentName})`;
364
-
365
- return `
366
- <div class="event-item single-row event-tool ${statusClass}" onclick="dashboard.selectCard('tools', ${index}, 'toolCall', '${key}'); dashboard.showToolCallDetails('${key}')">
367
- <span class="event-single-row-content">
368
- <span class="event-content-main">${toolMainContent}</span>
369
- <span class="event-timestamp">${timestamp}</span>
370
- </span>
371
- </div>
372
- `;
373
- }).join('');
374
- }
375
-
376
- /**
377
- * Generate HTML for file operations
378
- * @param {Array} fileOperations - File operations to render
379
- * @returns {string} - HTML string
380
- */
381
- generateFileHTML(fileOperations) {
382
- const filteredFiles = this.applyFilesFilters(fileOperations);
383
-
384
- return filteredFiles.map(([filePath, fileData], index) => {
385
- const operations = fileData.operations.map(op => op.operation);
386
- const timestamp = this.formatTimestamp(fileData.lastOperation);
387
-
388
- // Count operations by type for display: "read(2), write(1)"
389
- const operationCounts = {};
390
- operations.forEach(op => {
391
- operationCounts[op] = (operationCounts[op] || 0) + 1;
392
- });
393
-
394
- const operationSummary = Object.entries(operationCounts)
395
- .map(([op, count]) => `${op}(${count})`)
396
- .join(', ');
397
-
398
- // Get unique agents that worked on this file
399
- const uniqueAgents = [...new Set(fileData.operations.map(op => op.agent))];
400
- const agentSummary = uniqueAgents.length > 1 ? `by ${uniqueAgents.length} agents` : `by ${uniqueAgents[0] || 'unknown'}`;
401
-
402
- // Format: "[file path] read(2), write(1) by agent" with separate timestamp
403
- const fileName = this.getRelativeFilePath(filePath);
404
- const fileMainContent = `${fileName} ${operationSummary} ${agentSummary}`;
405
-
406
- return `
407
- <div class="event-item single-row file-item" onclick="dashboard.selectCard('files', ${index}, 'file', '${filePath}'); dashboard.showFileDetails('${filePath}')">
408
- <span class="event-single-row-content">
409
- <span class="event-content-main">${fileMainContent}</span>
410
- <span class="event-timestamp">${timestamp}</span>
411
- </span>
412
- </div>
413
- `;
414
- }).join('');
415
- }
416
-
417
- /**
418
- * Get icon for file operations
419
- * @param {Array} operations - Array of operations
420
- * @returns {string} - Icon representation
421
- */
422
- getFileOperationIcon(operations) {
423
- if (operations.includes('write') || operations.includes('create')) return '📝';
424
- if (operations.includes('edit')) return '✏️';
425
- if (operations.includes('read')) return '👁️';
426
- if (operations.includes('delete')) return '🗑️';
427
- if (operations.includes('move')) return '📦';
428
- return '📄';
429
- }
430
-
431
- /**
432
- * Get relative file path
433
- * @param {string} filePath - Full file path
434
- * @returns {string} - Relative path
435
- */
436
- getRelativeFilePath(filePath) {
437
- if (!filePath) return '';
438
-
439
- // Simple relative path logic - can be enhanced
440
- const parts = filePath.split('/');
441
- if (parts.length > 3) {
442
- return '.../' + parts.slice(-2).join('/');
443
- }
444
- return filePath;
445
- }
446
-
447
- /**
448
- * Format timestamp for display
449
- * @param {string|number} timestamp - Timestamp to format
450
- * @returns {string} - Formatted timestamp
451
- */
452
- formatTimestamp(timestamp) {
453
- if (!timestamp) return '';
454
-
455
- const date = new Date(timestamp);
456
- return date.toLocaleTimeString();
457
- }
458
-
459
- /**
460
- * Set selected session ID for filtering
461
- * @param {string} sessionId - Session ID to filter by
462
- */
463
- setSelectedSessionId(sessionId) {
464
- this.selectedSessionId = sessionId;
465
- }
466
-
467
- /**
468
- * Get selected session ID
469
- * @returns {string|null} - Current session ID
470
- */
471
- getSelectedSessionId() {
472
- return this.selectedSessionId;
473
- }
474
-
475
- /**
476
- * Get unique tool instances (one row per unique tool call)
477
- * This deduplicates tool calls to show unique instances only
478
- * @param {Array} toolCallsArray - Tool calls array
479
- * @returns {Array} - Unique tool instances
480
- */
481
- getUniqueToolInstances(toolCallsArray) {
482
- // The toolCallsArray already represents unique tool calls
483
- // since it's generated from paired pre/post events in FileToolTracker
484
- // Just apply filtering and return
485
- return this.applyToolCallFilters(toolCallsArray);
486
- }
487
-
488
- /**
489
- * Get unique file instances (one row per unique file)
490
- * This aggregates all operations on each file
491
- * @param {Array} fileOperations - File operations array
492
- * @returns {Array} - Unique file instances (same as input since already unique per file)
493
- */
494
- getUniqueFileInstances(fileOperations) {
495
- // The fileOperations array already represents unique files
496
- // since it's keyed by file path in FileToolTracker
497
- // Just apply filtering and return
498
- return this.applyFilesFilters(fileOperations);
499
- }
500
-
501
-
502
-
503
- /**
504
- * Show agent instance details for unique instance view
505
- * @param {string} instanceId - Agent instance ID
506
- */
507
- showAgentInstanceDetails(instanceId) {
508
- const pmDelegations = this.agentInference.getPMDelegations();
509
- const instance = pmDelegations.get(instanceId);
510
-
511
- if (!instance) {
512
- console.error('Agent instance not found:', instanceId);
513
- return;
514
- }
515
-
516
- // Show details about this PM delegation and its events
517
- console.log('Showing agent instance details for:', instanceId, instance);
518
-
519
- // This would integrate with the existing detail view system
520
- // For now, just log the details - can be expanded to show in a modal/sidebar
521
- const detailsHtml = `
522
- <div class="agent-instance-details">
523
- <h3>Agent Instance: ${instance.agentName}</h3>
524
- <p><strong>Type:</strong> ${instance.isImplied ? 'Implied PM Delegation' : 'Explicit PM Delegation'}</p>
525
- <p><strong>Start Time:</strong> ${this.formatTimestamp(instance.timestamp)}</p>
526
- <p><strong>Event Count:</strong> ${instance.agentEvents.length}</p>
527
- <p><strong>Session:</strong> ${instance.sessionId}</p>
528
- ${instance.pmCall ? `<p><strong>PM Call:</strong> Task delegation to ${instance.agentName}</p>` : '<p><strong>Note:</strong> Implied delegation (no explicit PM call found)</p>'}
529
- </div>
530
- `;
531
-
532
- // You would integrate this with your existing detail display system
533
- console.log('Agent instance details HTML:', detailsHtml);
534
- }
535
- }
536
-
537
- // ES6 Module export
538
- export { EventProcessor };
539
- export default EventProcessor;
540
-
541
- // Make EventProcessor globally available for dist/dashboard.js
542
- window.EventProcessor = EventProcessor;