claude-mpm 5.0.9__py3-none-any.whl → 5.4.41__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 (263) hide show
  1. claude_mpm/VERSION +1 -1
  2. claude_mpm/__init__.py +4 -0
  3. claude_mpm/agents/BASE_AGENT.md +164 -0
  4. claude_mpm/agents/{PM_INSTRUCTIONS_TEACH.md → CLAUDE_MPM_TEACHER_OUTPUT_STYLE.md} +721 -41
  5. claude_mpm/agents/MEMORY.md +1 -1
  6. claude_mpm/agents/PM_INSTRUCTIONS.md +468 -468
  7. claude_mpm/agents/WORKFLOW.md +5 -254
  8. claude_mpm/agents/agent_loader.py +13 -44
  9. claude_mpm/agents/base_agent.json +1 -1
  10. claude_mpm/agents/frontmatter_validator.py +70 -2
  11. claude_mpm/agents/templates/circuit-breakers.md +431 -45
  12. claude_mpm/cli/__init__.py +0 -1
  13. claude_mpm/cli/__main__.py +4 -0
  14. claude_mpm/cli/chrome_devtools_installer.py +175 -0
  15. claude_mpm/cli/commands/agent_state_manager.py +18 -27
  16. claude_mpm/cli/commands/agents.py +175 -37
  17. claude_mpm/cli/commands/auto_configure.py +723 -236
  18. claude_mpm/cli/commands/config.py +88 -2
  19. claude_mpm/cli/commands/configure.py +1262 -157
  20. claude_mpm/cli/commands/configure_agent_display.py +25 -6
  21. claude_mpm/cli/commands/mpm_init/core.py +225 -46
  22. claude_mpm/cli/commands/mpm_init/knowledge_extractor.py +481 -0
  23. claude_mpm/cli/commands/mpm_init/prompts.py +280 -0
  24. claude_mpm/cli/commands/postmortem.py +1 -1
  25. claude_mpm/cli/commands/profile.py +277 -0
  26. claude_mpm/cli/commands/skills.py +214 -189
  27. claude_mpm/cli/commands/summarize.py +413 -0
  28. claude_mpm/cli/executor.py +21 -3
  29. claude_mpm/cli/interactive/agent_wizard.py +85 -10
  30. claude_mpm/cli/parsers/agents_parser.py +54 -9
  31. claude_mpm/cli/parsers/auto_configure_parser.py +13 -138
  32. claude_mpm/cli/parsers/base_parser.py +12 -0
  33. claude_mpm/cli/parsers/config_parser.py +153 -83
  34. claude_mpm/cli/parsers/profile_parser.py +148 -0
  35. claude_mpm/cli/parsers/skills_parser.py +3 -2
  36. claude_mpm/cli/startup.py +879 -149
  37. claude_mpm/commands/mpm-config.md +28 -0
  38. claude_mpm/commands/mpm-doctor.md +9 -22
  39. claude_mpm/commands/mpm-help.md +5 -287
  40. claude_mpm/commands/mpm-init.md +81 -507
  41. claude_mpm/commands/mpm-monitor.md +15 -402
  42. claude_mpm/commands/mpm-organize.md +120 -0
  43. claude_mpm/commands/mpm-postmortem.md +6 -108
  44. claude_mpm/commands/mpm-session-resume.md +12 -363
  45. claude_mpm/commands/mpm-status.md +5 -69
  46. claude_mpm/commands/mpm-ticket-view.md +52 -495
  47. claude_mpm/commands/mpm-version.md +5 -107
  48. claude_mpm/config/agent_sources.py +27 -0
  49. claude_mpm/core/config.py +2 -4
  50. claude_mpm/core/framework/formatters/content_formatter.py +3 -13
  51. claude_mpm/core/framework/loaders/agent_loader.py +8 -5
  52. claude_mpm/core/framework/loaders/instruction_loader.py +52 -11
  53. claude_mpm/core/framework_loader.py +4 -2
  54. claude_mpm/core/logger.py +13 -0
  55. claude_mpm/core/optimized_startup.py +59 -0
  56. claude_mpm/core/output_style_manager.py +173 -43
  57. claude_mpm/core/shared/config_loader.py +1 -1
  58. claude_mpm/core/socketio_pool.py +3 -3
  59. claude_mpm/core/unified_agent_registry.py +134 -16
  60. claude_mpm/core/unified_config.py +22 -0
  61. claude_mpm/dashboard/static/svelte-build/_app/env.js +1 -0
  62. claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/0.B_FtCwCQ.css +1 -0
  63. claude_mpm/dashboard/static/svelte-build/_app/immutable/assets/2.Cl_eSA4x.css +1 -0
  64. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/BgChzWQ1.js +1 -0
  65. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CIXEwuWe.js +1 -0
  66. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/CWc5urbQ.js +1 -0
  67. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DMkZpdF2.js +2 -0
  68. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/DjhvlsAc.js +1 -0
  69. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/N4qtv3Hx.js +2 -0
  70. claude_mpm/dashboard/static/svelte-build/_app/immutable/chunks/uj46x2Wr.js +1 -0
  71. claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/app.DTL5mJO-.js +2 -0
  72. claude_mpm/dashboard/static/svelte-build/_app/immutable/entry/start.DzuEhzqh.js +1 -0
  73. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/0.CAGBuiOw.js +1 -0
  74. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/1.DFLC8jdE.js +1 -0
  75. claude_mpm/dashboard/static/svelte-build/_app/immutable/nodes/2.DPvEihJJ.js +10 -0
  76. claude_mpm/dashboard/static/svelte-build/_app/version.json +1 -0
  77. claude_mpm/dashboard/static/svelte-build/favicon.svg +7 -0
  78. claude_mpm/dashboard/static/svelte-build/index.html +36 -0
  79. claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-311.pyc +0 -0
  80. claude_mpm/hooks/claude_hooks/__pycache__/correlation_manager.cpython-311.pyc +0 -0
  81. claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-311.pyc +0 -0
  82. claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-311.pyc +0 -0
  83. claude_mpm/hooks/claude_hooks/__pycache__/installer.cpython-311.pyc +0 -0
  84. claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-311.pyc +0 -0
  85. claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-311.pyc +0 -0
  86. claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-311.pyc +0 -0
  87. claude_mpm/hooks/claude_hooks/correlation_manager.py +60 -0
  88. claude_mpm/hooks/claude_hooks/event_handlers.py +211 -78
  89. claude_mpm/hooks/claude_hooks/hook_handler.py +155 -1
  90. claude_mpm/hooks/claude_hooks/installer.py +33 -10
  91. claude_mpm/hooks/claude_hooks/memory_integration.py +28 -0
  92. claude_mpm/hooks/claude_hooks/response_tracking.py +2 -3
  93. claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-311.pyc +0 -0
  94. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager.cpython-311.pyc +0 -0
  95. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-311.pyc +0 -0
  96. claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-311.pyc +0 -0
  97. claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-311.pyc +0 -0
  98. claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-311.pyc +0 -0
  99. claude_mpm/hooks/claude_hooks/services/connection_manager.py +30 -6
  100. claude_mpm/hooks/memory_integration_hook.py +46 -1
  101. claude_mpm/init.py +63 -19
  102. claude_mpm/models/agent_definition.py +7 -0
  103. claude_mpm/models/git_repository.py +3 -3
  104. claude_mpm/scripts/claude-hook-handler.sh +58 -18
  105. claude_mpm/scripts/launch_monitor.py +93 -13
  106. claude_mpm/scripts/start_activity_logging.py +0 -0
  107. claude_mpm/services/agents/agent_builder.py +3 -3
  108. claude_mpm/services/agents/agent_recommendation_service.py +278 -0
  109. claude_mpm/services/agents/agent_review_service.py +280 -0
  110. claude_mpm/services/agents/cache_git_manager.py +6 -6
  111. claude_mpm/services/agents/deployment/agent_deployment.py +29 -7
  112. claude_mpm/services/agents/deployment/agent_discovery_service.py +4 -5
  113. claude_mpm/services/agents/deployment/agent_template_builder.py +5 -3
  114. claude_mpm/services/agents/deployment/agents_directory_resolver.py +2 -2
  115. claude_mpm/services/agents/deployment/multi_source_deployment_service.py +320 -29
  116. claude_mpm/services/agents/deployment/remote_agent_discovery_service.py +546 -68
  117. claude_mpm/services/agents/git_source_manager.py +36 -2
  118. claude_mpm/services/agents/loading/base_agent_manager.py +1 -13
  119. claude_mpm/services/agents/recommender.py +5 -3
  120. claude_mpm/services/agents/single_tier_deployment_service.py +2 -2
  121. claude_mpm/services/agents/sources/git_source_sync_service.py +13 -6
  122. claude_mpm/services/agents/startup_sync.py +22 -2
  123. claude_mpm/services/agents/toolchain_detector.py +10 -6
  124. claude_mpm/services/analysis/__init__.py +11 -1
  125. claude_mpm/services/analysis/clone_detector.py +1030 -0
  126. claude_mpm/services/command_deployment_service.py +81 -10
  127. claude_mpm/services/diagnostics/checks/agent_check.py +2 -2
  128. claude_mpm/services/diagnostics/checks/agent_sources_check.py +1 -1
  129. claude_mpm/services/event_bus/config.py +3 -1
  130. claude_mpm/services/git/git_operations_service.py +101 -16
  131. claude_mpm/services/monitor/daemon.py +9 -2
  132. claude_mpm/services/monitor/daemon_manager.py +39 -3
  133. claude_mpm/services/monitor/management/lifecycle.py +8 -1
  134. claude_mpm/services/monitor/server.py +698 -22
  135. claude_mpm/services/pm_skills_deployer.py +676 -0
  136. claude_mpm/services/profile_manager.py +331 -0
  137. claude_mpm/services/project/project_organizer.py +4 -0
  138. claude_mpm/services/self_upgrade_service.py +120 -12
  139. claude_mpm/services/skills/__init__.py +3 -0
  140. claude_mpm/services/skills/git_skill_source_manager.py +130 -2
  141. claude_mpm/services/skills/selective_skill_deployer.py +704 -0
  142. claude_mpm/services/skills/skill_to_agent_mapper.py +406 -0
  143. claude_mpm/services/skills_deployer.py +126 -9
  144. claude_mpm/services/socketio/dashboard_server.py +1 -0
  145. claude_mpm/services/socketio/event_normalizer.py +51 -6
  146. claude_mpm/services/socketio/server/core.py +386 -108
  147. claude_mpm/services/version_control/git_operations.py +103 -0
  148. claude_mpm/skills/skill_manager.py +92 -3
  149. claude_mpm/utils/agent_dependency_loader.py +14 -2
  150. claude_mpm/utils/agent_filters.py +17 -44
  151. claude_mpm/utils/gitignore.py +3 -0
  152. claude_mpm/utils/migration.py +4 -4
  153. claude_mpm/utils/robust_installer.py +47 -3
  154. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/METADATA +57 -87
  155. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/RECORD +160 -211
  156. claude_mpm-5.4.41.dist-info/entry_points.txt +5 -0
  157. claude_mpm-5.4.41.dist-info/licenses/LICENSE +94 -0
  158. claude_mpm-5.4.41.dist-info/licenses/LICENSE-FAQ.md +153 -0
  159. claude_mpm/agents/BASE_AGENT_TEMPLATE.md +0 -292
  160. claude_mpm/agents/BASE_DOCUMENTATION.md +0 -53
  161. claude_mpm/agents/BASE_OPS.md +0 -219
  162. claude_mpm/agents/BASE_PM.md +0 -480
  163. claude_mpm/agents/BASE_PROMPT_ENGINEER.md +0 -787
  164. claude_mpm/agents/BASE_QA.md +0 -167
  165. claude_mpm/agents/BASE_RESEARCH.md +0 -53
  166. claude_mpm/agents/base_agent_loader.py +0 -601
  167. claude_mpm/cli/commands/agents_detect.py +0 -380
  168. claude_mpm/cli/commands/agents_recommend.py +0 -309
  169. claude_mpm/cli/ticket_cli.py +0 -35
  170. claude_mpm/commands/mpm-agents-auto-configure.md +0 -278
  171. claude_mpm/commands/mpm-agents-detect.md +0 -177
  172. claude_mpm/commands/mpm-agents-list.md +0 -131
  173. claude_mpm/commands/mpm-agents-recommend.md +0 -223
  174. claude_mpm/commands/mpm-config-view.md +0 -150
  175. claude_mpm/commands/mpm-ticket-organize.md +0 -304
  176. claude_mpm/dashboard/analysis_runner.py +0 -455
  177. claude_mpm/dashboard/index.html +0 -13
  178. claude_mpm/dashboard/open_dashboard.py +0 -66
  179. claude_mpm/dashboard/static/css/activity.css +0 -1958
  180. claude_mpm/dashboard/static/css/connection-status.css +0 -370
  181. claude_mpm/dashboard/static/css/dashboard.css +0 -4701
  182. claude_mpm/dashboard/static/js/components/activity-tree.js +0 -1871
  183. claude_mpm/dashboard/static/js/components/agent-hierarchy.js +0 -777
  184. claude_mpm/dashboard/static/js/components/agent-inference.js +0 -956
  185. claude_mpm/dashboard/static/js/components/build-tracker.js +0 -333
  186. claude_mpm/dashboard/static/js/components/code-simple.js +0 -857
  187. claude_mpm/dashboard/static/js/components/connection-debug.js +0 -654
  188. claude_mpm/dashboard/static/js/components/diff-viewer.js +0 -891
  189. claude_mpm/dashboard/static/js/components/event-processor.js +0 -542
  190. claude_mpm/dashboard/static/js/components/event-viewer.js +0 -1155
  191. claude_mpm/dashboard/static/js/components/export-manager.js +0 -368
  192. claude_mpm/dashboard/static/js/components/file-change-tracker.js +0 -443
  193. claude_mpm/dashboard/static/js/components/file-change-viewer.js +0 -690
  194. claude_mpm/dashboard/static/js/components/file-tool-tracker.js +0 -724
  195. claude_mpm/dashboard/static/js/components/file-viewer.js +0 -580
  196. claude_mpm/dashboard/static/js/components/hud-library-loader.js +0 -211
  197. claude_mpm/dashboard/static/js/components/hud-manager.js +0 -671
  198. claude_mpm/dashboard/static/js/components/hud-visualizer.js +0 -1718
  199. claude_mpm/dashboard/static/js/components/module-viewer.js +0 -2764
  200. claude_mpm/dashboard/static/js/components/session-manager.js +0 -579
  201. claude_mpm/dashboard/static/js/components/socket-manager.js +0 -368
  202. claude_mpm/dashboard/static/js/components/ui-state-manager.js +0 -749
  203. claude_mpm/dashboard/static/js/components/unified-data-viewer.js +0 -1824
  204. claude_mpm/dashboard/static/js/components/working-directory.js +0 -920
  205. claude_mpm/dashboard/static/js/connection-manager.js +0 -536
  206. claude_mpm/dashboard/static/js/dashboard.js +0 -1914
  207. claude_mpm/dashboard/static/js/extension-error-handler.js +0 -164
  208. claude_mpm/dashboard/static/js/socket-client.js +0 -1474
  209. claude_mpm/dashboard/static/js/tab-isolation-fix.js +0 -185
  210. claude_mpm/dashboard/static/socket.io.min.js +0 -7
  211. claude_mpm/dashboard/static/socket.io.v4.8.1.backup.js +0 -7
  212. claude_mpm/dashboard/templates/code_simple.html +0 -153
  213. claude_mpm/dashboard/templates/index.html +0 -606
  214. claude_mpm/dashboard/test_dashboard.html +0 -372
  215. claude_mpm/hooks/claude_hooks/__pycache__/__init__.cpython-313.pyc +0 -0
  216. claude_mpm/hooks/claude_hooks/__pycache__/event_handlers.cpython-313.pyc +0 -0
  217. claude_mpm/hooks/claude_hooks/__pycache__/hook_handler.cpython-313.pyc +0 -0
  218. claude_mpm/hooks/claude_hooks/__pycache__/memory_integration.cpython-313.pyc +0 -0
  219. claude_mpm/hooks/claude_hooks/__pycache__/response_tracking.cpython-313.pyc +0 -0
  220. claude_mpm/hooks/claude_hooks/__pycache__/tool_analysis.cpython-313.pyc +0 -0
  221. claude_mpm/hooks/claude_hooks/services/__pycache__/__init__.cpython-313.pyc +0 -0
  222. claude_mpm/hooks/claude_hooks/services/__pycache__/connection_manager_http.cpython-313.pyc +0 -0
  223. claude_mpm/hooks/claude_hooks/services/__pycache__/duplicate_detector.cpython-313.pyc +0 -0
  224. claude_mpm/hooks/claude_hooks/services/__pycache__/state_manager.cpython-313.pyc +0 -0
  225. claude_mpm/hooks/claude_hooks/services/__pycache__/subagent_processor.cpython-313.pyc +0 -0
  226. claude_mpm/scripts/mcp_server.py +0 -75
  227. claude_mpm/scripts/mcp_wrapper.py +0 -39
  228. claude_mpm/services/mcp_gateway/__init__.py +0 -159
  229. claude_mpm/services/mcp_gateway/auto_configure.py +0 -369
  230. claude_mpm/services/mcp_gateway/config/__init__.py +0 -17
  231. claude_mpm/services/mcp_gateway/config/config_loader.py +0 -296
  232. claude_mpm/services/mcp_gateway/config/config_schema.py +0 -243
  233. claude_mpm/services/mcp_gateway/config/configuration.py +0 -429
  234. claude_mpm/services/mcp_gateway/core/__init__.py +0 -43
  235. claude_mpm/services/mcp_gateway/core/base.py +0 -312
  236. claude_mpm/services/mcp_gateway/core/exceptions.py +0 -253
  237. claude_mpm/services/mcp_gateway/core/interfaces.py +0 -443
  238. claude_mpm/services/mcp_gateway/core/process_pool.py +0 -977
  239. claude_mpm/services/mcp_gateway/core/singleton_manager.py +0 -315
  240. claude_mpm/services/mcp_gateway/core/startup_verification.py +0 -316
  241. claude_mpm/services/mcp_gateway/main.py +0 -589
  242. claude_mpm/services/mcp_gateway/registry/__init__.py +0 -12
  243. claude_mpm/services/mcp_gateway/registry/service_registry.py +0 -412
  244. claude_mpm/services/mcp_gateway/registry/tool_registry.py +0 -489
  245. claude_mpm/services/mcp_gateway/server/__init__.py +0 -15
  246. claude_mpm/services/mcp_gateway/server/mcp_gateway.py +0 -414
  247. claude_mpm/services/mcp_gateway/server/stdio_handler.py +0 -372
  248. claude_mpm/services/mcp_gateway/server/stdio_server.py +0 -712
  249. claude_mpm/services/mcp_gateway/tools/__init__.py +0 -36
  250. claude_mpm/services/mcp_gateway/tools/base_adapter.py +0 -485
  251. claude_mpm/services/mcp_gateway/tools/document_summarizer.py +0 -789
  252. claude_mpm/services/mcp_gateway/tools/external_mcp_services.py +0 -654
  253. claude_mpm/services/mcp_gateway/tools/health_check_tool.py +0 -456
  254. claude_mpm/services/mcp_gateway/tools/hello_world.py +0 -551
  255. claude_mpm/services/mcp_gateway/tools/kuzu_memory_service.py +0 -555
  256. claude_mpm/services/mcp_gateway/utils/__init__.py +0 -14
  257. claude_mpm/services/mcp_gateway/utils/package_version_checker.py +0 -160
  258. claude_mpm/services/mcp_gateway/utils/update_preferences.py +0 -170
  259. claude_mpm-5.0.9.dist-info/entry_points.txt +0 -10
  260. claude_mpm-5.0.9.dist-info/licenses/LICENSE +0 -21
  261. /claude_mpm/agents/{OUTPUT_STYLE.md → CLAUDE_MPM_OUTPUT_STYLE.md} +0 -0
  262. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/WHEEL +0 -0
  263. {claude_mpm-5.0.9.dist-info → claude_mpm-5.4.41.dist-info}/top_level.txt +0 -0
@@ -1,579 +0,0 @@
1
- /**
2
- * Session Manager Component
3
- * Handles session selection and management
4
- *
5
- * WHY: Provides session filtering and management for the dashboard, allowing users
6
- * to view events from specific sessions or all sessions.
7
- *
8
- * BROWSER COMPATIBILITY: This component runs in the browser. All Node.js-specific
9
- * globals (process, require, etc.) have been removed. Uses browser-compatible
10
- * alternatives for path handling and defaults.
11
- *
12
- * FIX APPLIED: Removed process.cwd() reference that caused "process is not defined"
13
- * error in browser. Now uses window.location.pathname or hardcoded fallbacks.
14
- */
15
-
16
- class SessionManager {
17
- constructor(socketClient) {
18
- this.socketClient = socketClient;
19
- this.sessions = new Map();
20
- this.currentSessionId = null;
21
- this.selectedSessionId = '';
22
-
23
- this.init();
24
- }
25
-
26
- /**
27
- * Initialize the session manager
28
- */
29
- init() {
30
- this.setupEventHandlers();
31
- this.setupSocketListeners();
32
- this.updateSessionSelect();
33
- }
34
-
35
- /**
36
- * Setup event handlers for UI controls
37
- */
38
- setupEventHandlers() {
39
- // Session selection dropdown
40
- const sessionSelect = document.getElementById('session-select');
41
- if (sessionSelect) {
42
- sessionSelect.addEventListener('change', (e) => {
43
- this.selectedSessionId = e.target.value;
44
- this.onSessionFilterChanged();
45
-
46
- // Load working directory for this session
47
- if (window.dashboard && window.dashboard.loadWorkingDirectoryForSession) {
48
- window.dashboard.loadWorkingDirectoryForSession(e.target.value);
49
- }
50
- });
51
- }
52
-
53
- // Refresh sessions button
54
- const refreshBtn = document.querySelector('button[onclick="refreshSessions()"]');
55
- if (refreshBtn) {
56
- refreshBtn.addEventListener('click', () => {
57
- this.refreshSessions();
58
- });
59
- }
60
- }
61
-
62
- /**
63
- * Setup socket event listeners
64
- */
65
- setupSocketListeners() {
66
- // Listen for socket event updates
67
- this.socketClient.onEventUpdate((events, sessions) => {
68
- // Log the sessions data to debug
69
- console.log('[SESSION-MANAGER] Received sessions update:', sessions);
70
- this.sessions = sessions;
71
- this.updateSessionSelect();
72
- // Update footer info when new events arrive
73
- this.updateFooterInfo();
74
- });
75
-
76
- // Listen for connection status changes
77
- document.addEventListener('socketConnectionStatus', (e) => {
78
- if (e.detail.type === 'connected') {
79
- // Request fresh session data when connected
80
- setTimeout(() => this.refreshSessions(), 1000);
81
- }
82
- });
83
- }
84
-
85
- /**
86
- * Update the session selection dropdown
87
- */
88
- updateSessionSelect() {
89
- const sessionSelect = document.getElementById('session-select');
90
- if (!sessionSelect) return;
91
-
92
- // Store current selection
93
- const currentSelection = sessionSelect.value;
94
-
95
- // Get the default working directory from various sources
96
- let defaultWorkingDir = '/';
97
-
98
- // Try to get from working directory manager
99
- if (window.dashboard && window.dashboard.workingDirectoryManager) {
100
- defaultWorkingDir = window.dashboard.workingDirectoryManager.getDefaultWorkingDir();
101
- } else {
102
- // Fallback: Try to get from header display element
103
- const headerWorkingDir = document.getElementById('working-dir-path');
104
- if (headerWorkingDir?.textContent?.trim()) {
105
- const headerPath = headerWorkingDir.textContent.trim();
106
- if (headerPath !== 'Loading...' && headerPath !== 'Unknown') {
107
- defaultWorkingDir = headerPath;
108
- }
109
- }
110
- }
111
-
112
- console.log('[SESSION-MANAGER] Using default working directory:', defaultWorkingDir);
113
-
114
- // Update "All Sessions" option to show working directory
115
- sessionSelect.innerHTML = `
116
- <option value="">${defaultWorkingDir} | All Sessions</option>
117
- `;
118
-
119
- // Add sessions from the sessions map
120
- if (this.sessions && this.sessions.size > 0) {
121
- const sortedSessions = Array.from(this.sessions.values())
122
- .sort((a, b) => new Date(b.lastActivity || b.startTime) - new Date(a.lastActivity || a.startTime));
123
-
124
- sortedSessions.forEach(session => {
125
- const option = document.createElement('option');
126
- option.value = session.id;
127
-
128
- // Format session display text
129
- const startTime = new Date(session.startTime || session.last_activity).toLocaleString();
130
- const eventCount = session.eventCount || session.event_count || 0;
131
- const isActive = session.id === this.currentSessionId;
132
-
133
- // Extract working directory from session or events
134
- let workingDir = session.working_directory || session.workingDirectory || '';
135
-
136
- // Log for debugging
137
- console.log(`[SESSION-DROPDOWN] Session ${session.id.substring(0, 8)} working_directory:`, workingDir);
138
-
139
- if (!workingDir) {
140
- const sessionData = this.extractSessionInfoFromEvents(session.id);
141
- workingDir = sessionData.workingDir || defaultWorkingDir;
142
- console.log(`[SESSION-DROPDOWN] Extracted working directory from events:`, workingDir);
143
- }
144
-
145
- // Format display: working_directory | session_id...
146
- const shortId = session.id.substring(0, 8);
147
- const dirDisplay = workingDir || defaultWorkingDir;
148
- option.textContent = `${dirDisplay} | ${shortId}...${isActive ? ' [ACTIVE]' : ''}`;
149
- sessionSelect.appendChild(option);
150
- });
151
- }
152
-
153
- // Restore selection if it still exists
154
- if (currentSelection && Array.from(sessionSelect.options).some(opt => opt.value === currentSelection)) {
155
- sessionSelect.value = currentSelection;
156
- this.selectedSessionId = currentSelection;
157
- // Trigger events for restored selection
158
- this.onSessionFilterChanged();
159
- } else {
160
- this.selectedSessionId = sessionSelect.value;
161
- // Trigger events for new selection
162
- if (this.selectedSessionId) {
163
- this.onSessionFilterChanged();
164
- }
165
- }
166
- }
167
-
168
- /**
169
- * Handle session filter change
170
- */
171
- onSessionFilterChanged() {
172
- // Notify event viewer about filter change
173
- const eventViewer = window.eventViewer;
174
- if (eventViewer) {
175
- eventViewer.setSessionFilter(this.selectedSessionId);
176
- }
177
-
178
- // Update footer information
179
- this.updateFooterInfo();
180
-
181
- // Dispatch custom event for other components
182
- document.dispatchEvent(new CustomEvent('sessionFilterChanged', {
183
- detail: { sessionId: this.selectedSessionId }
184
- }));
185
-
186
- // Also dispatch sessionChanged for backward compatibility with other components
187
- document.dispatchEvent(new CustomEvent('sessionChanged', {
188
- detail: { sessionId: this.selectedSessionId }
189
- }));
190
- }
191
-
192
- /**
193
- * Refresh sessions from server
194
- */
195
- refreshSessions() {
196
- if (this.socketClient && this.socketClient.getConnectionState().isConnected) {
197
- console.log('Refreshing sessions...');
198
- this.socketClient.requestStatus();
199
- } else {
200
- console.warn('Cannot refresh sessions: not connected to server');
201
- }
202
- }
203
-
204
- /**
205
- * Update footer information based on selected session
206
- */
207
- updateFooterInfo() {
208
- console.log('[SESSION-DEBUG] updateFooterInfo called, selectedSessionId:', this.selectedSessionId);
209
-
210
- const footerSessionEl = document.getElementById('footer-session');
211
- const footerWorkingDirEl = document.getElementById('footer-working-dir');
212
- const footerGitBranchEl = document.getElementById('footer-git-branch');
213
-
214
- if (!footerSessionEl) {
215
- console.warn('[SESSION-DEBUG] footer-session element not found');
216
- return;
217
- }
218
-
219
- let sessionInfo = 'All Sessions';
220
- // Use browser-compatible fallback for working directory
221
- // WHY: Removed process.cwd() Node.js reference - not available in browser
222
- // BROWSER FIX: Use dashboard manager or server-provided config
223
- let workingDir = window.dashboard?.workingDirectoryManager?.getDefaultWorkingDir() ||
224
- window.dashboardConfig?.workingDirectory ||
225
- '.';
226
- let gitBranch = 'Unknown';
227
-
228
- console.log('[SESSION-DEBUG] Initial values - sessionInfo:', sessionInfo, 'workingDir:', workingDir, 'gitBranch:', gitBranch);
229
-
230
- if (this.selectedSessionId === 'current') {
231
- sessionInfo = this.currentSessionId ?
232
- `Current: ${this.currentSessionId.substring(0, 8)}...` :
233
- 'Current: None';
234
-
235
- // For current session, try to extract info from recent events
236
- if (this.currentSessionId) {
237
- const sessionData = this.extractSessionInfoFromEvents(this.currentSessionId);
238
- // Browser-compatible working directory fallback
239
- workingDir = sessionData.workingDir ||
240
- window.dashboard?.workingDirectoryManager?.getDefaultWorkingDir() ||
241
- window.dashboardConfig?.workingDirectory ||
242
- '.';
243
- gitBranch = sessionData.gitBranch || 'Unknown';
244
- }
245
- } else if (this.selectedSessionId) {
246
- const session = this.sessions.get(this.selectedSessionId);
247
- if (session) {
248
- sessionInfo = `${this.selectedSessionId.substring(0, 8)}...`;
249
- workingDir = session.working_directory || session.workingDirectory || '';
250
- gitBranch = session.git_branch || session.gitBranch || '';
251
-
252
- // If session doesn't have these values, extract from events
253
- if (!workingDir || !gitBranch) {
254
- const sessionData = this.extractSessionInfoFromEvents(this.selectedSessionId);
255
- // Browser-compatible fallback - no process.cwd()
256
- workingDir = workingDir || sessionData.workingDir || window.dashboardConfig?.workingDirectory || '.';
257
- gitBranch = gitBranch || sessionData.gitBranch || '';
258
- }
259
- }
260
- }
261
-
262
- console.log('[SESSION-DEBUG] Final values before setting footer - sessionInfo:', sessionInfo, 'workingDir:', workingDir, 'gitBranch:', gitBranch);
263
-
264
- footerSessionEl.textContent = sessionInfo;
265
- if (footerWorkingDirEl) {
266
- console.log('[SESSION-DEBUG] Setting footer working dir to:', workingDir);
267
- footerWorkingDirEl.textContent = workingDir;
268
- } else {
269
- console.warn('[SESSION-DEBUG] footer-working-dir element not found');
270
- }
271
- if (footerGitBranchEl) {
272
- console.log('[SESSION-DEBUG] Setting footer git branch to:', gitBranch);
273
- footerGitBranchEl.textContent = gitBranch;
274
- } else {
275
- console.warn('[SESSION-DEBUG] footer-git-branch element not found');
276
- }
277
- }
278
-
279
- /**
280
- * Extract working directory and git branch from events for a specific session
281
- * @param {string} sessionId - Session ID to extract info for
282
- * @returns {Object} Object with workingDir and gitBranch properties
283
- */
284
- extractSessionInfoFromEvents(sessionId) {
285
- let workingDir = '';
286
- let gitBranch = '';
287
-
288
- console.log(`[DEBUG] extractSessionInfoFromEvents called for sessionId: ${sessionId}`);
289
-
290
- // Get events from the socket client
291
- const socketClient = this.socketClient;
292
- if (socketClient && socketClient.events) {
293
- console.log(`[DEBUG] Total events available: ${socketClient.events.length}`);
294
-
295
- // Look for session start events or recent events with this session ID
296
- const sessionEvents = socketClient.events.filter(event =>
297
- event.data && event.data.session_id === sessionId
298
- );
299
-
300
- console.log(`[DEBUG] Events matching sessionId ${sessionId}: ${sessionEvents.length}`);
301
-
302
- // Log a few sample events to see their structure
303
- if (sessionEvents.length > 0) {
304
- console.log(`[DEBUG] Sample events for session ${sessionId}:`);
305
-
306
- // Show first 3 events
307
- sessionEvents.slice(0, 3).forEach((event, index) => {
308
- console.log(`[DEBUG] Event ${index + 1}:`, {
309
- type: event.type,
310
- timestamp: event.timestamp,
311
- data_keys: event.data ? Object.keys(event.data) : 'no data',
312
- full_event: event
313
- });
314
- });
315
-
316
- // Show last 3 events if different from first 3
317
- if (sessionEvents.length > 3) {
318
- console.log(`[DEBUG] Last 3 events for session ${sessionId}:`);
319
- sessionEvents.slice(-3).forEach((event, index) => {
320
- console.log(`[DEBUG] Last Event ${index + 1}:`, {
321
- type: event.type,
322
- timestamp: event.timestamp,
323
- data_keys: event.data ? Object.keys(event.data) : 'no data',
324
- full_event: event
325
- });
326
- });
327
- }
328
- }
329
-
330
- // Find the most recent event with working directory and git branch info
331
- for (let i = sessionEvents.length - 1; i >= 0; i--) {
332
- const event = sessionEvents[i];
333
- if (event.data) {
334
- console.log(`[DEBUG] Examining event ${i} data:`, event.data);
335
-
336
- // Check for working directory info
337
- if (!workingDir) {
338
- if (event.data.working_directory) {
339
- workingDir = event.data.working_directory;
340
- console.log(`[DEBUG] Found working_directory: ${workingDir}`);
341
- } else if (event.data.cwd) {
342
- workingDir = event.data.cwd;
343
- console.log(`[DEBUG] Found cwd: ${workingDir}`);
344
- } else if (event.data.instance_info && event.data.instance_info.working_dir) {
345
- workingDir = event.data.instance_info.working_dir;
346
- console.log(`[DEBUG] Found instance_info.working_dir: ${workingDir}`);
347
- }
348
- }
349
-
350
- // Check for git branch info - check all possible field names
351
- if (!gitBranch) {
352
- const possibleBranchFields = [
353
- 'git_branch',
354
- 'gitBranch',
355
- 'branch',
356
- 'git.branch',
357
- 'vcs_branch',
358
- 'current_branch'
359
- ];
360
-
361
- for (const field of possibleBranchFields) {
362
- if (event.data[field]) {
363
- gitBranch = event.data[field];
364
- console.log(`[DEBUG] Found git branch in field '${field}': ${gitBranch}`);
365
- break;
366
- }
367
- }
368
-
369
- // Check nested locations
370
- if (!gitBranch) {
371
- if (event.data.instance_info) {
372
- console.log(`[DEBUG] Checking instance_info for branch:`, event.data.instance_info);
373
- for (const field of possibleBranchFields) {
374
- if (event.data.instance_info[field]) {
375
- gitBranch = event.data.instance_info[field];
376
- console.log(`[DEBUG] Found git branch in instance_info.${field}: ${gitBranch}`);
377
- break;
378
- }
379
- }
380
- }
381
-
382
- if (!gitBranch && event.data.git) {
383
- console.log(`[DEBUG] Checking git object:`, event.data.git);
384
- if (event.data.git.branch) {
385
- gitBranch = event.data.git.branch;
386
- console.log(`[DEBUG] Found git branch in git.branch: ${gitBranch}`);
387
- }
388
- }
389
- }
390
- }
391
-
392
- // If we have both, we can stop looking
393
- if (workingDir && gitBranch) {
394
- console.log(`[DEBUG] Found both workingDir and gitBranch, stopping search`);
395
- break;
396
- }
397
- }
398
- }
399
- } else {
400
- console.log(`[DEBUG] No socket client or events available`);
401
- }
402
-
403
- console.log(`[DEBUG] Final results - workingDir: '${workingDir}', gitBranch: '${gitBranch}'`);
404
- return { workingDir, gitBranch };
405
- }
406
-
407
- /**
408
- * Set current session ID (from server status)
409
- * @param {string} sessionId - Current session ID
410
- */
411
- setCurrentSessionId(sessionId) {
412
- this.currentSessionId = sessionId;
413
- this.updateSessionSelect();
414
- this.updateFooterInfo();
415
- }
416
-
417
- /**
418
- * Add or update a session
419
- * @param {Object} sessionData - Session data
420
- */
421
- addSession(sessionData) {
422
- if (!sessionData.id) return;
423
-
424
- const existingSession = this.sessions.get(sessionData.id);
425
- if (existingSession) {
426
- // Update existing session
427
- Object.assign(existingSession, sessionData);
428
- } else {
429
- // Add new session
430
- this.sessions.set(sessionData.id, {
431
- id: sessionData.id,
432
- startTime: sessionData.startTime || sessionData.start_time || new Date().toISOString(),
433
- lastActivity: sessionData.lastActivity || sessionData.last_activity || new Date().toISOString(),
434
- eventCount: sessionData.eventCount || sessionData.event_count || 0,
435
- working_directory: sessionData.working_directory || sessionData.workingDirectory || '',
436
- git_branch: sessionData.git_branch || sessionData.gitBranch || '',
437
- agent_type: sessionData.agent_type || sessionData.agentType || '',
438
- ...sessionData
439
- });
440
- }
441
-
442
- this.updateSessionSelect();
443
- }
444
-
445
- /**
446
- * Remove a session
447
- * @param {string} sessionId - Session ID to remove
448
- */
449
- removeSession(sessionId) {
450
- if (this.sessions.has(sessionId)) {
451
- this.sessions.delete(sessionId);
452
-
453
- // If the removed session was selected, reset to all sessions
454
- if (this.selectedSessionId === sessionId) {
455
- this.selectedSessionId = '';
456
- const sessionSelect = document.getElementById('session-select');
457
- if (sessionSelect) {
458
- sessionSelect.value = '';
459
- }
460
- this.onSessionFilterChanged();
461
- }
462
-
463
- this.updateSessionSelect();
464
- }
465
- }
466
-
467
- /**
468
- * Get current session filter
469
- * @returns {string} Current session filter
470
- */
471
- getCurrentFilter() {
472
- return this.selectedSessionId;
473
- }
474
-
475
- /**
476
- * Get session information
477
- * @param {string} sessionId - Session ID
478
- * @returns {Object|null} Session data or null if not found
479
- */
480
- getSession(sessionId) {
481
- return this.sessions.get(sessionId) || null;
482
- }
483
-
484
- /**
485
- * Get all sessions
486
- * @returns {Map} All sessions
487
- */
488
- getAllSessions() {
489
- return this.sessions;
490
- }
491
-
492
- /**
493
- * Get current active session ID
494
- * @returns {string|null} Current session ID
495
- */
496
- getCurrentSessionId() {
497
- return this.currentSessionId;
498
- }
499
-
500
- /**
501
- * Clear all sessions
502
- */
503
- clearSessions() {
504
- this.sessions.clear();
505
- this.currentSessionId = null;
506
- this.selectedSessionId = '';
507
- this.updateSessionSelect();
508
- this.updateFooterInfo();
509
- }
510
-
511
- /**
512
- * Export session data
513
- * @returns {Object} Session export data
514
- */
515
- exportSessionData() {
516
- return {
517
- sessions: Array.from(this.sessions.entries()),
518
- currentSessionId: this.currentSessionId,
519
- selectedSessionId: this.selectedSessionId
520
- };
521
- }
522
-
523
- /**
524
- * Import session data
525
- * @param {Object} data - Session import data
526
- */
527
- importSessionData(data) {
528
- if (data.sessions && Array.isArray(data.sessions)) {
529
- this.sessions.clear();
530
- data.sessions.forEach(([id, sessionData]) => {
531
- this.sessions.set(id, sessionData);
532
- });
533
- }
534
-
535
- if (data.currentSessionId) {
536
- this.currentSessionId = data.currentSessionId;
537
- }
538
-
539
- if (data.selectedSessionId !== undefined) {
540
- this.selectedSessionId = data.selectedSessionId;
541
- }
542
-
543
- this.updateSessionSelect();
544
- this.updateFooterInfo();
545
- }
546
-
547
- /**
548
- * Get events for a specific session
549
- * @param {string} sessionId - Session ID to get events for
550
- * @returns {Array} - Filtered events for the session
551
- */
552
- getEventsForSession(sessionId) {
553
- if (!sessionId || !this.socketClient) {
554
- return [];
555
- }
556
-
557
- const allEvents = this.socketClient.events || [];
558
- return allEvents.filter(event => {
559
- // Check for session ID in various possible locations
560
- const eventSessionId = event.session_id ||
561
- (event.data && event.data.session_id) ||
562
- null;
563
- return eventSessionId === sessionId;
564
- });
565
- }
566
- }
567
-
568
- // Global functions for backward compatibility
569
- window.refreshSessions = function() {
570
- if (window.sessionManager) {
571
- window.sessionManager.refreshSessions();
572
- }
573
- };
574
-
575
- // Export for global use
576
- window.SessionManager = SessionManager;
577
- // ES6 Module export
578
- export { SessionManager };
579
- export default SessionManager;