@radnine/claude-session-daemon 0.3.0 → 0.3.2
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.
package/package.json
CHANGED
|
@@ -15,10 +15,12 @@ const { getGitContext } = require('../git-context');
|
|
|
15
15
|
* Message protocol (client -> server):
|
|
16
16
|
* { type: 'activate', sessionId, workingDir }
|
|
17
17
|
* { type: 'command', sessionId, commandId, text }
|
|
18
|
+
* { type: 'clear_session', sessionId }
|
|
18
19
|
* { type: 'ping' }
|
|
19
20
|
*
|
|
20
21
|
* Message protocol (server -> client):
|
|
21
22
|
* { type: 'session_activated', sessionId }
|
|
23
|
+
* { type: 'session_cleared', sessionId, timestamp }
|
|
22
24
|
* { type: 'output', sessionId, commandId, data, timestamp }
|
|
23
25
|
* { type: 'complete', sessionId, commandId, exitCode, durationMs, timestamp }
|
|
24
26
|
* { type: 'error', sessionId, code, message, timestamp }
|
|
@@ -230,6 +232,10 @@ class StandaloneServer extends BaseConnection {
|
|
|
230
232
|
this._sendToClient(ws, { type: 'pong' });
|
|
231
233
|
break;
|
|
232
234
|
|
|
235
|
+
case 'clear_session':
|
|
236
|
+
this._handleClearSession(ws, msg);
|
|
237
|
+
break;
|
|
238
|
+
|
|
233
239
|
case 'query':
|
|
234
240
|
this._handleQuery(ws, msg);
|
|
235
241
|
break;
|
|
@@ -331,6 +337,39 @@ class StandaloneServer extends BaseConnection {
|
|
|
331
337
|
}
|
|
332
338
|
}
|
|
333
339
|
|
|
340
|
+
async _handleClearSession(ws, msg) {
|
|
341
|
+
const { sessionId } = msg;
|
|
342
|
+
|
|
343
|
+
if (!sessionId) {
|
|
344
|
+
this._sendToClient(ws, {
|
|
345
|
+
type: 'error',
|
|
346
|
+
code: 'INVALID_MESSAGE',
|
|
347
|
+
message: 'clear_session requires sessionId',
|
|
348
|
+
timestamp: Date.now(),
|
|
349
|
+
});
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
try {
|
|
354
|
+
await this._daemon.terminateSession(sessionId);
|
|
355
|
+
this._sessions.delete(sessionId);
|
|
356
|
+
|
|
357
|
+
this._sendToClient(ws, {
|
|
358
|
+
type: 'session_cleared',
|
|
359
|
+
sessionId,
|
|
360
|
+
timestamp: Date.now(),
|
|
361
|
+
});
|
|
362
|
+
this._logger.info('Session cleared', { sessionId });
|
|
363
|
+
} catch (err) {
|
|
364
|
+
this._sendToClient(ws, {
|
|
365
|
+
type: 'error',
|
|
366
|
+
code: 'CLEAR_FAILED',
|
|
367
|
+
message: err.message,
|
|
368
|
+
timestamp: Date.now(),
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
334
373
|
async _handleQuery(ws, msg) {
|
|
335
374
|
const { queryType } = msg;
|
|
336
375
|
|