@chrysb/alphaclaw 0.9.0-beta.4 → 0.9.0-beta.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.
- package/lib/server/routes/mcp.js +7 -0
- package/package.json +1 -1
package/lib/server/routes/mcp.js
CHANGED
|
@@ -29,6 +29,7 @@ const resolveGatewayWsUrl = ({ openclawDir, gatewayPort }) => {
|
|
|
29
29
|
const sessions = new Map();
|
|
30
30
|
let activeTransport = null;
|
|
31
31
|
const kSessionGraceMs = 15_000;
|
|
32
|
+
const kSseKeepAliveMs = 15_000;
|
|
32
33
|
|
|
33
34
|
const closeSession = (sessionId) => {
|
|
34
35
|
const t = sessions.get(sessionId);
|
|
@@ -140,6 +141,12 @@ const registerMcpRoutes = ({
|
|
|
140
141
|
|
|
141
142
|
if (req.method === "GET") {
|
|
142
143
|
res.setHeader("X-Accel-Buffering", "no");
|
|
144
|
+
const keepAliveId = setInterval(() => {
|
|
145
|
+
if (res.headersSent && !res.writableEnded) {
|
|
146
|
+
res.write(": keepalive\n\n");
|
|
147
|
+
}
|
|
148
|
+
}, kSseKeepAliveMs);
|
|
149
|
+
res.on("close", () => clearInterval(keepAliveId));
|
|
143
150
|
}
|
|
144
151
|
|
|
145
152
|
const sessionId = req.headers["mcp-session-id"];
|