claude-mpm 5.0.2__py3-none-any.whl → 5.4.3__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 (184) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/agents/CLAUDE_MPM_TEACHER_OUTPUT_STYLE.md +2002 -0
  3. claude_mpm/agents/PM_INSTRUCTIONS.md +1218 -905
  4. claude_mpm/agents/agent_loader.py +10 -17
  5. claude_mpm/agents/base_agent_loader.py +10 -35
  6. claude_mpm/agents/frontmatter_validator.py +68 -0
  7. claude_mpm/agents/templates/circuit-breakers.md +431 -45
  8. claude_mpm/cli/__init__.py +0 -1
  9. claude_mpm/cli/commands/__init__.py +2 -0
  10. claude_mpm/cli/commands/agent_state_manager.py +67 -23
  11. claude_mpm/cli/commands/agents.py +446 -25
  12. claude_mpm/cli/commands/auto_configure.py +535 -233
  13. claude_mpm/cli/commands/configure.py +1500 -147
  14. claude_mpm/cli/commands/configure_agent_display.py +13 -6
  15. claude_mpm/cli/commands/mpm_init/core.py +158 -1
  16. claude_mpm/cli/commands/mpm_init/knowledge_extractor.py +481 -0
  17. claude_mpm/cli/commands/mpm_init/prompts.py +280 -0
  18. claude_mpm/cli/commands/postmortem.py +401 -0
  19. claude_mpm/cli/commands/run.py +1 -39
  20. claude_mpm/cli/commands/skills.py +322 -19
  21. claude_mpm/cli/commands/summarize.py +413 -0
  22. claude_mpm/cli/executor.py +8 -0
  23. claude_mpm/cli/interactive/agent_wizard.py +302 -195
  24. claude_mpm/cli/parsers/agents_parser.py +137 -0
  25. claude_mpm/cli/parsers/auto_configure_parser.py +13 -0
  26. claude_mpm/cli/parsers/base_parser.py +9 -0
  27. claude_mpm/cli/parsers/skills_parser.py +7 -0
  28. claude_mpm/cli/startup.py +133 -85
  29. claude_mpm/commands/mpm-agents-auto-configure.md +2 -2
  30. claude_mpm/commands/mpm-agents-list.md +2 -2
  31. claude_mpm/commands/mpm-config-view.md +2 -2
  32. claude_mpm/commands/mpm-help.md +3 -0
  33. claude_mpm/commands/{mpm-ticket-organize.md → mpm-organize.md} +4 -5
  34. claude_mpm/commands/mpm-postmortem.md +123 -0
  35. claude_mpm/commands/mpm-session-resume.md +2 -2
  36. claude_mpm/commands/mpm-ticket-view.md +2 -2
  37. claude_mpm/config/agent_presets.py +312 -82
  38. claude_mpm/config/agent_sources.py +27 -0
  39. claude_mpm/config/skill_presets.py +392 -0
  40. claude_mpm/constants.py +1 -0
  41. claude_mpm/core/claude_runner.py +2 -25
  42. claude_mpm/core/framework/loaders/agent_loader.py +8 -5
  43. claude_mpm/core/framework/loaders/file_loader.py +54 -101
  44. claude_mpm/core/interactive_session.py +19 -5
  45. claude_mpm/core/oneshot_session.py +16 -4
  46. claude_mpm/core/output_style_manager.py +173 -43
  47. claude_mpm/core/protocols/__init__.py +23 -0
  48. claude_mpm/core/protocols/runner_protocol.py +103 -0
  49. claude_mpm/core/protocols/session_protocol.py +131 -0
  50. claude_mpm/core/shared/singleton_manager.py +11 -4
  51. claude_mpm/core/socketio_pool.py +3 -3
  52. claude_mpm/core/system_context.py +38 -0
  53. claude_mpm/core/unified_agent_registry.py +134 -16
  54. claude_mpm/core/unified_config.py +22 -0
  55. claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-313.pyc +0 -0
  56. claude_mpm/hooks/claude_hooks/__pycache__/correlation_manager.cpython-313.pyc +0 -0
  57. claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-313.pyc +0 -0
  58. claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-313.pyc +0 -0
  59. claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-313.pyc +0 -0
  60. claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-313.pyc +0 -0
  61. claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-313.pyc +0 -0
  62. claude_mpm/hooks/claude_hooks/correlation_manager.py +60 -0
  63. claude_mpm/hooks/claude_hooks/event_handlers.py +35 -2
  64. claude_mpm/hooks/claude_hooks/hook_handler.py +4 -0
  65. claude_mpm/hooks/claude_hooks/memory_integration.py +12 -1
  66. claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-313.pyc +0 -0
  67. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-313.pyc +0 -0
  68. claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-313.pyc +0 -0
  69. claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-313.pyc +0 -0
  70. claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-313.pyc +0 -0
  71. claude_mpm/hooks/claude_hooks/services/connection_manager.py +4 -0
  72. claude_mpm/models/agent_definition.py +7 -0
  73. claude_mpm/scripts/launch_monitor.py +93 -13
  74. claude_mpm/services/agents/agent_recommendation_service.py +279 -0
  75. claude_mpm/services/agents/cache_git_manager.py +621 -0
  76. claude_mpm/services/agents/deployment/agent_template_builder.py +3 -2
  77. claude_mpm/services/agents/deployment/multi_source_deployment_service.py +110 -3
  78. claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +518 -55
  79. claude_mpm/services/agents/git_source_manager.py +20 -0
  80. claude_mpm/services/agents/sources/git_source_sync_service.py +45 -6
  81. claude_mpm/services/agents/toolchain_detector.py +6 -5
  82. claude_mpm/services/analysis/__init__.py +35 -0
  83. claude_mpm/services/analysis/clone_detector.py +1030 -0
  84. claude_mpm/services/analysis/postmortem_reporter.py +474 -0
  85. claude_mpm/services/analysis/postmortem_service.py +765 -0
  86. claude_mpm/services/command_deployment_service.py +106 -5
  87. claude_mpm/services/core/base.py +7 -2
  88. claude_mpm/services/diagnostics/checks/mcp_services_check.py +7 -15
  89. claude_mpm/services/event_bus/config.py +3 -1
  90. claude_mpm/services/git/git_operations_service.py +8 -8
  91. claude_mpm/services/mcp_config_manager.py +75 -145
  92. claude_mpm/services/mcp_service_verifier.py +6 -3
  93. claude_mpm/services/monitor/daemon.py +37 -10
  94. claude_mpm/services/monitor/daemon_manager.py +134 -21
  95. claude_mpm/services/monitor/server.py +225 -19
  96. claude_mpm/services/project/project_organizer.py +4 -0
  97. claude_mpm/services/runner_configuration_service.py +16 -3
  98. claude_mpm/services/session_management_service.py +16 -4
  99. claude_mpm/services/socketio/event_normalizer.py +15 -1
  100. claude_mpm/services/socketio/server/core.py +160 -21
  101. claude_mpm/services/version_control/git_operations.py +103 -0
  102. claude_mpm/utils/agent_filters.py +261 -0
  103. claude_mpm/utils/gitignore.py +3 -0
  104. claude_mpm/utils/migration.py +372 -0
  105. claude_mpm/utils/progress.py +5 -1
  106. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.dist-info}/METADATA +69 -84
  107. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.dist-info}/RECORD +112 -153
  108. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.dist-info}/entry_points.txt +0 -2
  109. claude_mpm/dashboard/analysis_runner.py +0 -455
  110. claude_mpm/dashboard/index.html +0 -13
  111. claude_mpm/dashboard/open_dashboard.py +0 -66
  112. claude_mpm/dashboard/static/css/activity.css +0 -1958
  113. claude_mpm/dashboard/static/css/connection-status.css +0 -370
  114. claude_mpm/dashboard/static/css/dashboard.css +0 -4701
  115. claude_mpm/dashboard/static/js/components/activity-tree.js +0 -1871
  116. claude_mpm/dashboard/static/js/components/agent-hierarchy.js +0 -777
  117. claude_mpm/dashboard/static/js/components/agent-inference.js +0 -956
  118. claude_mpm/dashboard/static/js/components/build-tracker.js +0 -333
  119. claude_mpm/dashboard/static/js/components/code-simple.js +0 -857
  120. claude_mpm/dashboard/static/js/components/connection-debug.js +0 -654
  121. claude_mpm/dashboard/static/js/components/diff-viewer.js +0 -891
  122. claude_mpm/dashboard/static/js/components/event-processor.js +0 -542
  123. claude_mpm/dashboard/static/js/components/event-viewer.js +0 -1155
  124. claude_mpm/dashboard/static/js/components/export-manager.js +0 -368
  125. claude_mpm/dashboard/static/js/components/file-change-tracker.js +0 -443
  126. claude_mpm/dashboard/static/js/components/file-change-viewer.js +0 -690
  127. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +0 -724
  128. claude_mpm/dashboard/static/js/components/file-viewer.js +0 -580
  129. claude_mpm/dashboard/static/js/components/hud-library-loader.js +0 -211
  130. claude_mpm/dashboard/static/js/components/hud-manager.js +0 -671
  131. claude_mpm/dashboard/static/js/components/hud-visualizer.js +0 -1718
  132. claude_mpm/dashboard/static/js/components/module-viewer.js +0 -2764
  133. claude_mpm/dashboard/static/js/components/session-manager.js +0 -579
  134. claude_mpm/dashboard/static/js/components/socket-manager.js +0 -368
  135. claude_mpm/dashboard/static/js/components/ui-state-manager.js +0 -749
  136. claude_mpm/dashboard/static/js/components/unified-data-viewer.js +0 -1824
  137. claude_mpm/dashboard/static/js/components/working-directory.js +0 -920
  138. claude_mpm/dashboard/static/js/connection-manager.js +0 -536
  139. claude_mpm/dashboard/static/js/dashboard.js +0 -1914
  140. claude_mpm/dashboard/static/js/extension-error-handler.js +0 -164
  141. claude_mpm/dashboard/static/js/socket-client.js +0 -1474
  142. claude_mpm/dashboard/static/js/tab-isolation-fix.js +0 -185
  143. claude_mpm/dashboard/static/socket.io.min.js +0 -7
  144. claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +0 -7
  145. claude_mpm/dashboard/templates/code_simple.html +0 -153
  146. claude_mpm/dashboard/templates/index.html +0 -606
  147. claude_mpm/dashboard/test_dashboard.html +0 -372
  148. claude_mpm/scripts/mcp_server.py +0 -75
  149. claude_mpm/scripts/mcp_wrapper.py +0 -39
  150. claude_mpm/services/mcp_gateway/__init__.py +0 -159
  151. claude_mpm/services/mcp_gateway/auto_configure.py +0 -369
  152. claude_mpm/services/mcp_gateway/config/__init__.py +0 -17
  153. claude_mpm/services/mcp_gateway/config/config_loader.py +0 -296
  154. claude_mpm/services/mcp_gateway/config/config_schema.py +0 -243
  155. claude_mpm/services/mcp_gateway/config/configuration.py +0 -429
  156. claude_mpm/services/mcp_gateway/core/__init__.py +0 -43
  157. claude_mpm/services/mcp_gateway/core/base.py +0 -312
  158. claude_mpm/services/mcp_gateway/core/exceptions.py +0 -253
  159. claude_mpm/services/mcp_gateway/core/interfaces.py +0 -443
  160. claude_mpm/services/mcp_gateway/core/process_pool.py +0 -971
  161. claude_mpm/services/mcp_gateway/core/singleton_manager.py +0 -315
  162. claude_mpm/services/mcp_gateway/core/startup_verification.py +0 -316
  163. claude_mpm/services/mcp_gateway/main.py +0 -589
  164. claude_mpm/services/mcp_gateway/registry/__init__.py +0 -12
  165. claude_mpm/services/mcp_gateway/registry/service_registry.py +0 -412
  166. claude_mpm/services/mcp_gateway/registry/tool_registry.py +0 -489
  167. claude_mpm/services/mcp_gateway/server/__init__.py +0 -15
  168. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +0 -414
  169. claude_mpm/services/mcp_gateway/server/stdio_handler.py +0 -372
  170. claude_mpm/services/mcp_gateway/server/stdio_server.py +0 -712
  171. claude_mpm/services/mcp_gateway/tools/__init__.py +0 -36
  172. claude_mpm/services/mcp_gateway/tools/base_adapter.py +0 -485
  173. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +0 -789
  174. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +0 -654
  175. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +0 -456
  176. claude_mpm/services/mcp_gateway/tools/hello_world.py +0 -551
  177. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +0 -555
  178. claude_mpm/services/mcp_gateway/utils/__init__.py +0 -14
  179. claude_mpm/services/mcp_gateway/utils/package_version_checker.py +0 -160
  180. claude_mpm/services/mcp_gateway/utils/update_preferences.py +0 -170
  181. /claude_mpm/agents/{OUTPUT_STYLE.md → CLAUDE_MPM_OUTPUT_STYLE.md} +0 -0
  182. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.dist-info}/WHEEL +0 -0
  183. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.dist-info}/licenses/LICENSE +0 -0
  184. {claude_mpm-5.0.2.dist-info → claude_mpm-5.4.3.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;