claude-mpm 3.4.13__py3-none-any.whl → 3.4.16__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.
- claude_mpm/dashboard/index.html +13 -0
- claude_mpm/dashboard/static/css/dashboard.css +2722 -0
- claude_mpm/dashboard/static/js/components/agent-inference.js +619 -0
- claude_mpm/dashboard/static/js/components/event-processor.js +641 -0
- claude_mpm/dashboard/static/js/components/event-viewer.js +914 -0
- claude_mpm/dashboard/static/js/components/export-manager.js +362 -0
- claude_mpm/dashboard/static/js/components/file-tool-tracker.js +611 -0
- claude_mpm/dashboard/static/js/components/hud-library-loader.js +211 -0
- claude_mpm/dashboard/static/js/components/hud-manager.js +671 -0
- claude_mpm/dashboard/static/js/components/hud-visualizer.js +1718 -0
- claude_mpm/dashboard/static/js/components/module-viewer.js +2701 -0
- claude_mpm/dashboard/static/js/components/session-manager.js +520 -0
- claude_mpm/dashboard/static/js/components/socket-manager.js +343 -0
- claude_mpm/dashboard/static/js/components/ui-state-manager.js +427 -0
- claude_mpm/dashboard/static/js/components/working-directory.js +866 -0
- claude_mpm/dashboard/static/js/dashboard-original.js +4134 -0
- claude_mpm/dashboard/static/js/dashboard.js +1978 -0
- claude_mpm/dashboard/static/js/socket-client.js +537 -0
- claude_mpm/dashboard/templates/index.html +346 -0
- claude_mpm/dashboard/test_dashboard.html +372 -0
- claude_mpm/services/socketio_server.py +111 -7
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/METADATA +2 -1
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/RECORD +27 -7
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/WHEEL +0 -0
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/entry_points.txt +0 -0
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/licenses/LICENSE +0 -0
- {claude_mpm-3.4.13.dist-info → claude_mpm-3.4.16.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Socket Manager Module
|
|
3
|
+
*
|
|
4
|
+
* Handles all socket connection management, event dispatching, and connection state.
|
|
5
|
+
* Provides a centralized interface for socket operations across the dashboard.
|
|
6
|
+
*
|
|
7
|
+
* WHY: Extracted from main dashboard to centralize socket connection logic and
|
|
8
|
+
* provide better separation of concerns. This allows for easier testing and
|
|
9
|
+
* maintenance of connection handling code.
|
|
10
|
+
*
|
|
11
|
+
* DESIGN DECISION: Acts as a wrapper around SocketClient to provide dashboard-specific
|
|
12
|
+
* connection management while maintaining the existing SocketClient interface.
|
|
13
|
+
* Uses event dispatching to notify other modules of connection state changes.
|
|
14
|
+
*/
|
|
15
|
+
class SocketManager {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.socketClient = null;
|
|
18
|
+
this.connectionCallbacks = new Set();
|
|
19
|
+
this.eventUpdateCallbacks = new Set();
|
|
20
|
+
|
|
21
|
+
// Initialize socket client
|
|
22
|
+
this.socketClient = new SocketClient();
|
|
23
|
+
|
|
24
|
+
// Make socketClient globally available (for backward compatibility)
|
|
25
|
+
window.socketClient = this.socketClient;
|
|
26
|
+
|
|
27
|
+
this.setupSocketEventHandlers();
|
|
28
|
+
|
|
29
|
+
// Force initial status update after a short delay to ensure DOM is ready
|
|
30
|
+
setTimeout(() => {
|
|
31
|
+
this.updateInitialConnectionStatus();
|
|
32
|
+
}, 100);
|
|
33
|
+
|
|
34
|
+
console.log('Socket manager initialized');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set up socket event handlers for connection status and events
|
|
39
|
+
*/
|
|
40
|
+
setupSocketEventHandlers() {
|
|
41
|
+
// Listen for connection status changes
|
|
42
|
+
document.addEventListener('socketConnectionStatus', (e) => {
|
|
43
|
+
console.log(`SocketManager: Processing connection status update: ${e.detail.status} (${e.detail.type})`);
|
|
44
|
+
this.handleConnectionStatusChange(e.detail.status, e.detail.type);
|
|
45
|
+
|
|
46
|
+
// Notify all registered callbacks
|
|
47
|
+
this.connectionCallbacks.forEach(callback => {
|
|
48
|
+
try {
|
|
49
|
+
callback(e.detail.status, e.detail.type);
|
|
50
|
+
} catch (error) {
|
|
51
|
+
console.error('Error in connection callback:', error);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Set up event update handling
|
|
57
|
+
if (this.socketClient) {
|
|
58
|
+
this.socketClient.onEventUpdate((events) => {
|
|
59
|
+
// Notify all registered callbacks
|
|
60
|
+
this.eventUpdateCallbacks.forEach(callback => {
|
|
61
|
+
try {
|
|
62
|
+
callback(events);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
console.error('Error in event update callback:', error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Handle connection status changes
|
|
73
|
+
* @param {string} status - Connection status text
|
|
74
|
+
* @param {string} type - Connection type ('connected', 'disconnected', etc.)
|
|
75
|
+
*/
|
|
76
|
+
handleConnectionStatusChange(status, type) {
|
|
77
|
+
this.updateConnectionStatus(status, type);
|
|
78
|
+
|
|
79
|
+
// Set up git branch listener when connected
|
|
80
|
+
if (type === 'connected' && this.socketClient && this.socketClient.socket) {
|
|
81
|
+
this.setupGitBranchListener();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Update initial connection status on dashboard load
|
|
87
|
+
*/
|
|
88
|
+
updateInitialConnectionStatus() {
|
|
89
|
+
console.log('SocketManager: Updating initial connection status');
|
|
90
|
+
|
|
91
|
+
// Force status check on socket client (uses fallback mechanism)
|
|
92
|
+
if (this.socketClient && typeof this.socketClient.checkAndUpdateStatus === 'function') {
|
|
93
|
+
console.log('SocketManager: Using socket client checkAndUpdateStatus method');
|
|
94
|
+
this.socketClient.checkAndUpdateStatus();
|
|
95
|
+
} else if (this.socketClient && this.socketClient.socket) {
|
|
96
|
+
console.log('SocketManager: Checking socket state directly', {
|
|
97
|
+
connected: this.socketClient.socket.connected,
|
|
98
|
+
connecting: this.socketClient.socket.connecting,
|
|
99
|
+
isConnecting: this.socketClient.isConnecting,
|
|
100
|
+
isConnected: this.socketClient.isConnected
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
if (this.socketClient.socket.connected) {
|
|
104
|
+
console.log('SocketManager: Socket is already connected, updating status');
|
|
105
|
+
this.updateConnectionStatus('Connected', 'connected');
|
|
106
|
+
} else if (this.socketClient.isConnecting || this.socketClient.socket.connecting) {
|
|
107
|
+
console.log('SocketManager: Socket is connecting, updating status');
|
|
108
|
+
this.updateConnectionStatus('Connecting...', 'connecting');
|
|
109
|
+
} else {
|
|
110
|
+
console.log('SocketManager: Socket is disconnected, updating status');
|
|
111
|
+
this.updateConnectionStatus('Disconnected', 'disconnected');
|
|
112
|
+
}
|
|
113
|
+
} else {
|
|
114
|
+
console.log('SocketManager: No socket client or socket found, setting disconnected status');
|
|
115
|
+
this.updateConnectionStatus('Disconnected', 'disconnected');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Additional fallback - check again after a longer delay in case connection is still establishing
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
console.log('SocketManager: Secondary status check after 1 second');
|
|
121
|
+
if (this.socketClient && this.socketClient.socket && this.socketClient.socket.connected) {
|
|
122
|
+
console.log('SocketManager: Socket connected in secondary check, updating status');
|
|
123
|
+
this.updateConnectionStatus('Connected', 'connected');
|
|
124
|
+
}
|
|
125
|
+
}, 1000);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Set up git branch response listener for connected socket
|
|
130
|
+
*/
|
|
131
|
+
setupGitBranchListener() {
|
|
132
|
+
// Remove any existing listener first
|
|
133
|
+
this.socketClient.socket.off('git_branch_response');
|
|
134
|
+
|
|
135
|
+
// Add the listener
|
|
136
|
+
this.socketClient.socket.on('git_branch_response', (data) => {
|
|
137
|
+
if (data.success) {
|
|
138
|
+
const footerBranch = document.getElementById('footer-git-branch');
|
|
139
|
+
if (footerBranch) {
|
|
140
|
+
footerBranch.textContent = data.branch || 'unknown';
|
|
141
|
+
}
|
|
142
|
+
if (footerBranch) {
|
|
143
|
+
footerBranch.style.display = 'inline';
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
console.error('Git branch request failed:', data.error);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Update connection status display
|
|
153
|
+
* @param {string} status - Status text to display
|
|
154
|
+
* @param {string} type - Status type for styling
|
|
155
|
+
*/
|
|
156
|
+
updateConnectionStatus(status, type) {
|
|
157
|
+
const statusElement = document.getElementById('connection-status');
|
|
158
|
+
if (statusElement) {
|
|
159
|
+
// Check if there's a span indicator first
|
|
160
|
+
const indicator = statusElement.querySelector('span');
|
|
161
|
+
if (indicator) {
|
|
162
|
+
// If there's a span, update the text content after the span
|
|
163
|
+
const statusIndicator = type === 'connected' ? '●' : '●';
|
|
164
|
+
statusElement.innerHTML = `<span>${statusIndicator}</span> ${status}`;
|
|
165
|
+
} else {
|
|
166
|
+
// If no span, just update text content
|
|
167
|
+
statusElement.textContent = status;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
statusElement.className = `status-badge status-${type}`;
|
|
171
|
+
console.log(`SocketManager: UI updated - status: '${status}' (${type})`);
|
|
172
|
+
} else {
|
|
173
|
+
console.error('SocketManager: Could not find connection-status element in DOM');
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Connect to socket server
|
|
179
|
+
* @param {number} port - Port number to connect to
|
|
180
|
+
*/
|
|
181
|
+
connect(port) {
|
|
182
|
+
if (this.socketClient) {
|
|
183
|
+
this.socketClient.connect(port);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Disconnect from socket server
|
|
189
|
+
*/
|
|
190
|
+
disconnect() {
|
|
191
|
+
if (this.socketClient) {
|
|
192
|
+
this.socketClient.disconnect();
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Check if socket is connected
|
|
198
|
+
* @returns {boolean} - True if connected
|
|
199
|
+
*/
|
|
200
|
+
isConnected() {
|
|
201
|
+
return this.socketClient && this.socketClient.isConnected;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Check if socket is connecting
|
|
206
|
+
* @returns {boolean} - True if connecting
|
|
207
|
+
*/
|
|
208
|
+
isConnecting() {
|
|
209
|
+
return this.socketClient && this.socketClient.isConnecting;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Get the underlying socket client
|
|
214
|
+
* @returns {SocketClient} - The socket client instance
|
|
215
|
+
*/
|
|
216
|
+
getSocketClient() {
|
|
217
|
+
return this.socketClient;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Get the raw socket connection
|
|
222
|
+
* @returns {Socket|null} - The raw socket or null
|
|
223
|
+
*/
|
|
224
|
+
getSocket() {
|
|
225
|
+
return this.socketClient ? this.socketClient.socket : null;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Register a callback for connection status changes
|
|
230
|
+
* @param {Function} callback - Callback function(status, type)
|
|
231
|
+
*/
|
|
232
|
+
onConnectionStatusChange(callback) {
|
|
233
|
+
this.connectionCallbacks.add(callback);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Unregister a connection status callback
|
|
238
|
+
* @param {Function} callback - Callback to remove
|
|
239
|
+
*/
|
|
240
|
+
offConnectionStatusChange(callback) {
|
|
241
|
+
this.connectionCallbacks.delete(callback);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Register a callback for event updates
|
|
246
|
+
* @param {Function} callback - Callback function(events)
|
|
247
|
+
*/
|
|
248
|
+
onEventUpdate(callback) {
|
|
249
|
+
this.eventUpdateCallbacks.add(callback);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Unregister an event update callback
|
|
254
|
+
* @param {Function} callback - Callback to remove
|
|
255
|
+
*/
|
|
256
|
+
offEventUpdate(callback) {
|
|
257
|
+
this.eventUpdateCallbacks.delete(callback);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Toggle connection controls visibility
|
|
262
|
+
*/
|
|
263
|
+
toggleConnectionControls() {
|
|
264
|
+
const controlsRow = document.getElementById('connection-controls-row');
|
|
265
|
+
const toggleBtn = document.getElementById('connection-toggle-btn');
|
|
266
|
+
|
|
267
|
+
if (controlsRow && toggleBtn) {
|
|
268
|
+
const isVisible = controlsRow.classList.contains('show');
|
|
269
|
+
|
|
270
|
+
if (isVisible) {
|
|
271
|
+
controlsRow.classList.remove('show');
|
|
272
|
+
controlsRow.style.display = 'none';
|
|
273
|
+
toggleBtn.textContent = 'Connection Settings';
|
|
274
|
+
} else {
|
|
275
|
+
controlsRow.classList.add('show');
|
|
276
|
+
controlsRow.style.display = 'block';
|
|
277
|
+
toggleBtn.textContent = 'Hide Settings';
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Setup connection control event handlers
|
|
284
|
+
* Called during dashboard initialization
|
|
285
|
+
*/
|
|
286
|
+
setupConnectionControls() {
|
|
287
|
+
const connectBtn = document.getElementById('connect-btn');
|
|
288
|
+
const disconnectBtn = document.getElementById('disconnect-btn');
|
|
289
|
+
const connectionToggleBtn = document.getElementById('connection-toggle-btn');
|
|
290
|
+
|
|
291
|
+
if (connectBtn) {
|
|
292
|
+
connectBtn.addEventListener('click', () => {
|
|
293
|
+
const port = document.getElementById('port-input').value || 8765;
|
|
294
|
+
this.connect(port);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (disconnectBtn) {
|
|
299
|
+
disconnectBtn.addEventListener('click', () => {
|
|
300
|
+
this.disconnect();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (connectionToggleBtn) {
|
|
305
|
+
connectionToggleBtn.addEventListener('click', () => {
|
|
306
|
+
this.toggleConnectionControls();
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Initialize connection from URL parameters
|
|
313
|
+
* @param {URLSearchParams} params - URL search parameters
|
|
314
|
+
*/
|
|
315
|
+
initializeFromURL(params) {
|
|
316
|
+
const port = params.get('port');
|
|
317
|
+
const portInput = document.getElementById('port-input');
|
|
318
|
+
|
|
319
|
+
// Determine the port to use:
|
|
320
|
+
// 1. URL parameter 'port'
|
|
321
|
+
// 2. Current page port (if served via HTTP)
|
|
322
|
+
// 3. Default port value from input field
|
|
323
|
+
// 4. Fallback to 8765
|
|
324
|
+
let connectPort = port;
|
|
325
|
+
if (!connectPort && window.location.protocol === 'http:') {
|
|
326
|
+
connectPort = window.location.port || '8765';
|
|
327
|
+
}
|
|
328
|
+
if (!connectPort) {
|
|
329
|
+
connectPort = portInput?.value || '8765';
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// Update the port input field with the determined port
|
|
333
|
+
if (portInput) {
|
|
334
|
+
portInput.value = connectPort;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
// Auto-connect by default unless explicitly disabled
|
|
338
|
+
const shouldAutoConnect = params.get('connect') !== 'false';
|
|
339
|
+
if (shouldAutoConnect && !this.isConnected() && !this.isConnecting()) {
|
|
340
|
+
this.connect(connectPort);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|