@cryptiklemur/lattice 5.13.1 → 5.13.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.
|
@@ -695,27 +695,15 @@ export function startChatStream(options) {
|
|
|
695
695
|
catch (initErr) {
|
|
696
696
|
log.chat("Session %s SDK initialization FAILED: %O", sessionId, initErr);
|
|
697
697
|
}
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
}
|
|
698
|
+
log.chat("Session %s pushing first message to queue", sessionId);
|
|
699
|
+
mq.push(firstMsg);
|
|
700
|
+
let retrying = false;
|
|
702
701
|
try {
|
|
703
702
|
log.chat("Session %s entering stream loop", sessionId);
|
|
704
703
|
let msgCount = 0;
|
|
705
|
-
let replayDone = !shouldResume;
|
|
706
704
|
for await (const msg of stream) {
|
|
707
705
|
msgCount++;
|
|
708
|
-
|
|
709
|
-
log.chat("Session %s msg #%d type=%s", sessionId, msgCount, msg.type);
|
|
710
|
-
}
|
|
711
|
-
if (!replayDone && msg.type === "result") {
|
|
712
|
-
replayDone = true;
|
|
713
|
-
log.chat("Session %s replay complete at msg #%d, waiting for connection settle", sessionId, msgCount);
|
|
714
|
-
await new Promise(function (resolve) { setTimeout(resolve, 200); });
|
|
715
|
-
log.chat("Session %s pushing first message after replay", sessionId);
|
|
716
|
-
mq.push(firstMsg);
|
|
717
|
-
continue;
|
|
718
|
-
}
|
|
706
|
+
log.chat("Session %s msg #%d type=%s", sessionId, msgCount, msg.type);
|
|
719
707
|
processMessage(sessionStream, msg);
|
|
720
708
|
}
|
|
721
709
|
log.chat("Session %s stream ended normally after %d messages", sessionId, msgCount);
|
|
@@ -726,9 +714,9 @@ export function startChatStream(options) {
|
|
|
726
714
|
if (errMsg.includes("aborted") || errMsg.includes("AbortError")) {
|
|
727
715
|
log.chat("Session %s stream aborted", sessionId);
|
|
728
716
|
}
|
|
729
|
-
else if (errMsg.includes("Sent before connected")) {
|
|
730
|
-
log.chat("Session %s
|
|
731
|
-
|
|
717
|
+
else if (errMsg.includes("Sent before connected") && shouldResume) {
|
|
718
|
+
log.chat("Session %s WebSocket not ready after resume, retrying in 500ms", sessionId);
|
|
719
|
+
retrying = true;
|
|
732
720
|
}
|
|
733
721
|
else {
|
|
734
722
|
console.error("[lattice] SDK stream error: " + errMsg);
|
|
@@ -740,6 +728,12 @@ export function startChatStream(options) {
|
|
|
740
728
|
pendingStreams.delete(sessionId);
|
|
741
729
|
sessionStreams.delete(sessionId);
|
|
742
730
|
persistStreamState();
|
|
731
|
+
if (retrying) {
|
|
732
|
+
log.chat("Session %s cleaning up for retry", sessionId);
|
|
733
|
+
await new Promise(function (resolve) { setTimeout(resolve, 500); });
|
|
734
|
+
startChatStream(options);
|
|
735
|
+
return;
|
|
736
|
+
}
|
|
743
737
|
broadcast({ type: "session:busy", sessionId, busy: false }, sessionStream.clientId);
|
|
744
738
|
const toCleanup = [];
|
|
745
739
|
pendingPermissions.forEach(function (entry, reqId) {
|
|
@@ -812,6 +806,7 @@ function processMessage(ss, msg) {
|
|
|
812
806
|
}
|
|
813
807
|
if (msg.type === "assistant") {
|
|
814
808
|
const assistantMsg = msg;
|
|
809
|
+
log.chat("Session %s assistant message: model=%s", sessionId, assistantMsg.message.model || "unknown");
|
|
815
810
|
const msgUsage = assistantMsg.message.usage;
|
|
816
811
|
if (msgUsage && msgUsage.input_tokens != null) {
|
|
817
812
|
const ctxWindow = guessContextWindow(assistantMsg.message.model || "");
|
|
@@ -836,6 +831,8 @@ function processMessage(ss, msg) {
|
|
|
836
831
|
const partial = msg;
|
|
837
832
|
const evt = partial.event;
|
|
838
833
|
if (evt.type === "content_block_start") {
|
|
834
|
+
const blockInfo = evt.content_block;
|
|
835
|
+
log.chat("Session %s content_block_start: type=%s name=%s", sessionId, blockInfo.type, blockInfo.name || "text");
|
|
839
836
|
ss.sawNewTurnContent = true;
|
|
840
837
|
const block = evt.content_block;
|
|
841
838
|
const idx = evt.index;
|
|
@@ -967,11 +964,12 @@ function processMessage(ss, msg) {
|
|
|
967
964
|
return;
|
|
968
965
|
}
|
|
969
966
|
if (msg.type === "result") {
|
|
967
|
+
const resultMsg = msg;
|
|
968
|
+
log.chat("Session %s result: cost=$%s, sawContent=%s", sessionId, String(resultMsg.total_cost_usd || 0), String(ss.sawNewTurnContent));
|
|
970
969
|
if (!ss.sawNewTurnContent) {
|
|
971
970
|
log.chat("Session %s ignoring replayed result (no new turn content seen)", sessionId);
|
|
972
971
|
return;
|
|
973
972
|
}
|
|
974
|
-
const resultMsg = msg;
|
|
975
973
|
const dur = Date.now() - ss.turnStartTime;
|
|
976
974
|
const cost = resultMsg.total_cost_usd || 0;
|
|
977
975
|
if (resultMsg.usage) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cryptiklemur/lattice",
|
|
3
|
-
"version": "5.13.
|
|
3
|
+
"version": "5.13.2",
|
|
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>",
|