@cello-protocol/cli 0.0.308 → 0.0.309
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/dist/daemon/main.js +23 -0
- package/package.json +1 -1
package/dist/daemon/main.js
CHANGED
|
@@ -121,6 +121,27 @@ function stopListening(socket) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
+
// A Claude session (caller mcp:<uuid>) talks over one long-lived connection, so when its last one closes the session is
|
|
125
|
+
// gone, and every hold it took goes with it, however it was taken. Identity still comes from each call; only the hold ends.
|
|
126
|
+
// The command line and named callers like hermes may connect per call, so their holds last until they let go.
|
|
127
|
+
const sessionSockets = new Map();
|
|
128
|
+
function noteSessionSocket(socket, caller) {
|
|
129
|
+
if (typeof caller !== "string" || !caller.startsWith("mcp:"))
|
|
130
|
+
return;
|
|
131
|
+
const set = sessionSockets.get(caller) ?? new Set();
|
|
132
|
+
set.add(socket);
|
|
133
|
+
sessionSockets.set(caller, set);
|
|
134
|
+
}
|
|
135
|
+
function releaseSessionHolds(socket) {
|
|
136
|
+
for (const [caller, set] of sessionSockets) {
|
|
137
|
+
if (!set.delete(socket) || set.size > 0)
|
|
138
|
+
continue;
|
|
139
|
+
sessionSockets.delete(caller);
|
|
140
|
+
for (const [agent, holder] of holders)
|
|
141
|
+
if (holder.caller === caller)
|
|
142
|
+
holders.delete(agent);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
124
145
|
let shuttingDown = false;
|
|
125
146
|
function shutdown() {
|
|
126
147
|
if (shuttingDown)
|
|
@@ -483,6 +504,7 @@ const ipc = createServer((socket) => {
|
|
|
483
504
|
socket.destroy();
|
|
484
505
|
return;
|
|
485
506
|
}
|
|
507
|
+
noteSessionSocket(socket, request.params?.["caller"]);
|
|
486
508
|
handle(socket, request.method, request.params ?? {}).then((result) => {
|
|
487
509
|
if (result instanceof AfterWrite)
|
|
488
510
|
respond({ id: request.id, ok: true, result: result.result }, result.commit);
|
|
@@ -501,6 +523,7 @@ const ipc = createServer((socket) => {
|
|
|
501
523
|
socket.on("close", () => {
|
|
502
524
|
stopListening(socket);
|
|
503
525
|
sockets.delete(socket);
|
|
526
|
+
releaseSessionHolds(socket);
|
|
504
527
|
});
|
|
505
528
|
socket.on("error", () => undefined);
|
|
506
529
|
});
|