tacticremote 1.6.5 → 1.6.6
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 +1 -1
- package/routes/httpHandler.js +3 -1
- package/server.js +22 -1
package/package.json
CHANGED
package/routes/httpHandler.js
CHANGED
|
@@ -66,7 +66,9 @@ function createHttpHandler(server, handleHookEvent) {
|
|
|
66
66
|
try {
|
|
67
67
|
const rawBody = Buffer.concat(bodyChunks).toString('utf8');
|
|
68
68
|
const hookData = JSON.parse(rawBody);
|
|
69
|
-
handleHookEvent(hookData)
|
|
69
|
+
Promise.resolve(handleHookEvent(hookData)).catch(err => {
|
|
70
|
+
console.error('[hook] handler error:', err.message);
|
|
71
|
+
});
|
|
70
72
|
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
71
73
|
res.end(JSON.stringify({ success: true }));
|
|
72
74
|
} catch (error) {
|
package/server.js
CHANGED
|
@@ -214,8 +214,28 @@ class ClaudeRemoteServer {
|
|
|
214
214
|
console.log(`__CLIENT_COUNT__:${this.externalClients.size}:${this.clients.size}`);
|
|
215
215
|
}
|
|
216
216
|
|
|
217
|
-
handleHookEvent(hookData) {
|
|
217
|
+
async handleHookEvent(hookData) {
|
|
218
218
|
console.log(`🔔 Hook event: ${hookData.event} (${hookData.project})`);
|
|
219
|
+
|
|
220
|
+
// Fallback: if hook didn't provide tmux_session, try to find it by matching project to session cwd
|
|
221
|
+
if (!hookData.tmux_session && hookData.project) {
|
|
222
|
+
try {
|
|
223
|
+
const path = require('path');
|
|
224
|
+
const { listSessions } = require('./lib/tmuxManager');
|
|
225
|
+
const result = await listSessions();
|
|
226
|
+
if (result && result.sessions) {
|
|
227
|
+
const running = result.sessions.find(s => s.running && path.basename(s.path || '') === hookData.project);
|
|
228
|
+
const match = running || result.sessions.find(s => path.basename(s.path || '') === hookData.project);
|
|
229
|
+
if (match) {
|
|
230
|
+
hookData.tmux_session = match.name;
|
|
231
|
+
console.log(`[notify][hook] inferred tmux_session=${match.name} from project=${hookData.project}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
} catch (err) {
|
|
235
|
+
console.warn(`[notify][hook] session inference failed: ${err.message}`);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
219
239
|
this.lastHookEvent = hookData;
|
|
220
240
|
|
|
221
241
|
// Broadcast in both legacy and event-frame formats for compatibility.
|
|
@@ -260,6 +280,7 @@ class ClaudeRemoteServer {
|
|
|
260
280
|
title: 'Claude',
|
|
261
281
|
body: hookData.data.message,
|
|
262
282
|
project: hookData.project,
|
|
283
|
+
session: hookData.tmux_session,
|
|
263
284
|
event: 'notification',
|
|
264
285
|
timestamp: hookData.timestamp
|
|
265
286
|
});
|