@dainprotocol/tunnel 1.1.2 → 1.1.4
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/client/index.js +9 -2
- package/dist/server/index.js +3 -1
- package/package.json +1 -1
package/dist/client/index.js
CHANGED
|
@@ -257,7 +257,7 @@ class DainTunnel extends events_1.EventEmitter {
|
|
|
257
257
|
hostname: 'localhost',
|
|
258
258
|
port: this.port,
|
|
259
259
|
path: message.path,
|
|
260
|
-
method: 'GET',
|
|
260
|
+
method: message.method || 'GET', // Use provided method (supports POST tool calls)
|
|
261
261
|
headers: message.headers,
|
|
262
262
|
};
|
|
263
263
|
const req = http_1.default.request(options, (res) => {
|
|
@@ -275,7 +275,9 @@ class DainTunnel extends events_1.EventEmitter {
|
|
|
275
275
|
// Process SSE stream
|
|
276
276
|
let buffer = '';
|
|
277
277
|
res.on('data', (chunk) => {
|
|
278
|
-
|
|
278
|
+
const chunkStr = chunk.toString();
|
|
279
|
+
console.log(`[Tunnel Client] SSE chunk received (${chunkStr.length} bytes):`, chunkStr.substring(0, 200));
|
|
280
|
+
buffer += chunkStr;
|
|
279
281
|
// Process complete SSE messages
|
|
280
282
|
while (buffer.includes('\n\n')) {
|
|
281
283
|
const messageEndIndex = buffer.indexOf('\n\n');
|
|
@@ -298,6 +300,7 @@ class DainTunnel extends events_1.EventEmitter {
|
|
|
298
300
|
data = data.substring(0, data.length - 1);
|
|
299
301
|
}
|
|
300
302
|
// Forward to server
|
|
303
|
+
console.log(`[Tunnel Client] Forwarding SSE event: ${event}, data length: ${data.length}`);
|
|
301
304
|
if (this.ws && this.ws.readyState === ws_1.default.OPEN) {
|
|
302
305
|
this.ws.send(JSON.stringify({
|
|
303
306
|
type: 'sse',
|
|
@@ -329,6 +332,10 @@ class DainTunnel extends events_1.EventEmitter {
|
|
|
329
332
|
}));
|
|
330
333
|
}
|
|
331
334
|
});
|
|
335
|
+
// Write request body for POST requests
|
|
336
|
+
if (message.body && message.method !== 'GET') {
|
|
337
|
+
req.write(Buffer.from(message.body, 'base64'));
|
|
338
|
+
}
|
|
332
339
|
req.end();
|
|
333
340
|
// Store a reference to abort the connection later if needed
|
|
334
341
|
this.sseClients.set(message.id, req);
|
package/dist/server/index.js
CHANGED
|
@@ -412,7 +412,9 @@ class DainTunnelServer {
|
|
|
412
412
|
type: "sse_connection",
|
|
413
413
|
id: sseId,
|
|
414
414
|
path: req.url,
|
|
415
|
-
|
|
415
|
+
method: req.method, // Include HTTP method for POST tool calls
|
|
416
|
+
headers: req.headers,
|
|
417
|
+
body: req.method !== "GET" && req.body ? req.body.toString("base64") : undefined
|
|
416
418
|
}));
|
|
417
419
|
// Handle client disconnect
|
|
418
420
|
req.on('close', () => {
|