openclaw-navigator 5.7.6 → 5.7.8
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/cli.mjs +7 -31
- package/package.json +1 -1
package/cli.mjs
CHANGED
|
@@ -1613,39 +1613,15 @@ function handleRequest(req, res) {
|
|
|
1613
1613
|
return;
|
|
1614
1614
|
}
|
|
1615
1615
|
|
|
1616
|
-
// ── SSE
|
|
1617
|
-
//
|
|
1618
|
-
//
|
|
1616
|
+
// ── SSE for streaming endpoints (/api/chat) ──────────────────────
|
|
1617
|
+
// DO NOT transform SSE — pipe raw bytes through untouched.
|
|
1618
|
+
// The web UI works fine hitting port 4000 directly; any transformation
|
|
1619
|
+
// we add (SSE→JSON, SSE→NDJSON, setEncoding) breaks the frontend parser.
|
|
1620
|
+
// Raw binary pipe preserves the exact chunking the BFF sends.
|
|
1619
1621
|
if (isSSE && isStreamingEndpoint) {
|
|
1620
|
-
console.log(` ${DIM}SSE
|
|
1621
|
-
|
|
1622
|
-
// Ensure SSE headers are clean for the browser
|
|
1623
|
-
headers["cache-control"] = "no-cache";
|
|
1624
|
-
headers["connection"] = "keep-alive";
|
|
1625
|
-
// Keep content-type as text/event-stream
|
|
1626
|
-
delete headers["content-length"]; // SSE is chunked
|
|
1627
|
-
|
|
1622
|
+
console.log(` ${DIM}SSE raw pipe: ${path}${RESET}`);
|
|
1628
1623
|
res.writeHead(proxyRes.statusCode ?? 200, headers);
|
|
1629
|
-
|
|
1630
|
-
// Disable buffering at every layer
|
|
1631
|
-
if (res.socket) res.socket.setNoDelay(true);
|
|
1632
|
-
|
|
1633
|
-
// Pipe SSE events directly — no transformation
|
|
1634
|
-
proxyRes.on("data", (chunk) => {
|
|
1635
|
-
res.write(chunk);
|
|
1636
|
-
// Flush after each chunk to prevent TCP buffering
|
|
1637
|
-
if (typeof res.flush === "function") res.flush();
|
|
1638
|
-
});
|
|
1639
|
-
|
|
1640
|
-
proxyRes.on("end", () => {
|
|
1641
|
-
res.end();
|
|
1642
|
-
console.log(` ${GREEN}✓${RESET} SSE stream completed for ${path}`);
|
|
1643
|
-
});
|
|
1644
|
-
|
|
1645
|
-
proxyRes.on("error", (err) => {
|
|
1646
|
-
console.log(` ${DIM}SSE stream error: ${err.message}${RESET}`);
|
|
1647
|
-
sendJSON(res, 502, { ok: false, error: "Stream error" });
|
|
1648
|
-
});
|
|
1624
|
+
proxyRes.pipe(res, { end: true });
|
|
1649
1625
|
return;
|
|
1650
1626
|
}
|
|
1651
1627
|
|