claude-friends 0.4.11 → 0.4.13
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/daemon.js +17 -2
- package/package.json +1 -1
package/daemon.js
CHANGED
|
@@ -45,6 +45,13 @@ ws.addEventListener("message", (event) => {
|
|
|
45
45
|
} catch {}
|
|
46
46
|
});
|
|
47
47
|
|
|
48
|
+
// Send heartbeat every 10 seconds (server kills connections without heartbeat)
|
|
49
|
+
setInterval(() => {
|
|
50
|
+
if (ws.readyState === 1) {
|
|
51
|
+
ws.send(JSON.stringify({ type: "heartbeat" }));
|
|
52
|
+
}
|
|
53
|
+
}, 10000);
|
|
54
|
+
|
|
48
55
|
// Poll friends every 15 seconds
|
|
49
56
|
setInterval(() => {
|
|
50
57
|
if (ws.readyState === 1) {
|
|
@@ -52,8 +59,16 @@ setInterval(() => {
|
|
|
52
59
|
}
|
|
53
60
|
}, 15000);
|
|
54
61
|
|
|
55
|
-
//
|
|
56
|
-
|
|
62
|
+
// Exit when parent process (Claude Code) dies
|
|
63
|
+
const parentPid = process.ppid;
|
|
64
|
+
setInterval(() => {
|
|
65
|
+
try {
|
|
66
|
+
process.kill(parentPid, 0); // Check if parent is alive (signal 0 = no-op)
|
|
67
|
+
} catch {
|
|
68
|
+
ws.close();
|
|
69
|
+
process.exit(0);
|
|
70
|
+
}
|
|
71
|
+
}, 5000);
|
|
57
72
|
|
|
58
73
|
// Clean exit
|
|
59
74
|
process.on("SIGINT", () => { ws.close(); process.exit(0); });
|