@cryptiklemur/lattice 5.13.3 → 5.13.5
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.
|
@@ -46,6 +46,7 @@ function createMessageQueue(label) {
|
|
|
46
46
|
let waiting = null;
|
|
47
47
|
let ended = false;
|
|
48
48
|
let readCount = 0;
|
|
49
|
+
const readWaiters = new Map();
|
|
49
50
|
return {
|
|
50
51
|
push: function (msg) {
|
|
51
52
|
if (waiting) {
|
|
@@ -68,10 +69,22 @@ function createMessageQueue(label) {
|
|
|
68
69
|
resolve({ value: undefined, done: true });
|
|
69
70
|
}
|
|
70
71
|
},
|
|
72
|
+
waitForRead: function (n) {
|
|
73
|
+
if (readCount >= n)
|
|
74
|
+
return Promise.resolve();
|
|
75
|
+
return new Promise(function (resolve) {
|
|
76
|
+
readWaiters.set(n, resolve);
|
|
77
|
+
});
|
|
78
|
+
},
|
|
71
79
|
[Symbol.asyncIterator]: function () {
|
|
72
80
|
return {
|
|
73
81
|
next: function () {
|
|
74
82
|
readCount++;
|
|
83
|
+
const waiter = readWaiters.get(readCount);
|
|
84
|
+
if (waiter) {
|
|
85
|
+
readWaiters.delete(readCount);
|
|
86
|
+
waiter();
|
|
87
|
+
}
|
|
75
88
|
if (queue.length > 0) {
|
|
76
89
|
log.chat("MQ[%s] read #%d: from buffer (remaining=%d)", label || "?", readCount, queue.length - 1);
|
|
77
90
|
return Promise.resolve({ value: queue.shift(), done: false });
|
|
@@ -739,11 +752,20 @@ export function startChatStream(options) {
|
|
|
739
752
|
clearTimeout(turnTimer);
|
|
740
753
|
const errMsg = err instanceof Error ? err.message : String(err);
|
|
741
754
|
log.chat("Session %s stream error: %s", sessionId, errMsg);
|
|
742
|
-
|
|
743
|
-
|
|
755
|
+
const retryCount = options._retryCount || 0;
|
|
756
|
+
const canRetry = shouldResume && retryCount < 1;
|
|
757
|
+
if ((errMsg.includes("aborted") || errMsg.includes("AbortError")) && canRetry && !sessionStream.sawNewTurnContent) {
|
|
758
|
+
log.chat("Session %s stream aborted after resume with no new content, retrying (attempt %d)", sessionId, retryCount + 1);
|
|
759
|
+
retrying = true;
|
|
760
|
+
}
|
|
761
|
+
else if (errMsg.includes("aborted") || errMsg.includes("AbortError")) {
|
|
762
|
+
log.chat("Session %s stream aborted (sawContent=%s)", sessionId, String(sessionStream.sawNewTurnContent));
|
|
763
|
+
if (!sessionStream.sawNewTurnContent) {
|
|
764
|
+
sendTo(sessionStream.clientId, { type: "chat:error", message: "Failed to get a response. Try sending your message again or start a new session." });
|
|
765
|
+
}
|
|
744
766
|
}
|
|
745
|
-
else if (errMsg.includes("Sent before connected") &&
|
|
746
|
-
log.chat("Session %s WebSocket not ready after resume, retrying
|
|
767
|
+
else if (errMsg.includes("Sent before connected") && canRetry) {
|
|
768
|
+
log.chat("Session %s WebSocket not ready after resume, retrying (attempt %d)", sessionId, retryCount + 1);
|
|
747
769
|
retrying = true;
|
|
748
770
|
}
|
|
749
771
|
else {
|
|
@@ -757,9 +779,10 @@ export function startChatStream(options) {
|
|
|
757
779
|
sessionStreams.delete(sessionId);
|
|
758
780
|
persistStreamState();
|
|
759
781
|
if (retrying) {
|
|
760
|
-
|
|
782
|
+
const retryCount = (options._retryCount || 0) + 1;
|
|
783
|
+
log.chat("Session %s cleaning up for retry #%d", sessionId, retryCount);
|
|
761
784
|
await new Promise(function (resolve) { setTimeout(resolve, 500); });
|
|
762
|
-
startChatStream(options);
|
|
785
|
+
startChatStream({ ...options, _retryCount: retryCount });
|
|
763
786
|
return;
|
|
764
787
|
}
|
|
765
788
|
broadcast({ type: "session:busy", sessionId, busy: false }, sessionStream.clientId);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptiklemur/lattice",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.5",
|
|
4
4
|
"description": "Multi-machine agentic dashboard for Claude Code. Monitor sessions, manage MCP servers and skills, orchestrate across mesh-networked nodes.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Aaron Scherer <me@aaronscherer.me>",
|