@clawchatsai/connector 0.0.33 → 0.0.35
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/index.js +38 -0
- package/package.json +1 -1
- package/server.js +1 -2
package/dist/index.js
CHANGED
|
@@ -28,6 +28,8 @@ export const PLUGIN_VERSION = _pkgJson.version;
|
|
|
28
28
|
const MAX_DC_MESSAGE_SIZE = 256 * 1024;
|
|
29
29
|
/** Active DataChannel connections: connectionId → send function */
|
|
30
30
|
const connectedClients = new Map();
|
|
31
|
+
/** Reassembly buffers for chunked RPC requests from browser (large uploads). */
|
|
32
|
+
const rpcReqChunkBuffers = new Map();
|
|
31
33
|
/** Reassembly buffers for chunked gateway-msg from browser (large payloads like image attachments). */
|
|
32
34
|
const gatewayMsgChunkBuffers = new Map();
|
|
33
35
|
let app = null;
|
|
@@ -415,6 +417,42 @@ function processAuthenticatedMessage(dc, connectionId, msg, ctx) {
|
|
|
415
417
|
case 'rpc':
|
|
416
418
|
handleRpcMessage(dc, msg, ctx);
|
|
417
419
|
break;
|
|
420
|
+
case 'rpc-chunk-req': {
|
|
421
|
+
const chunkId = msg['id'];
|
|
422
|
+
const index = msg['index'];
|
|
423
|
+
const total = msg['total'];
|
|
424
|
+
const chunkData = msg['data'];
|
|
425
|
+
if (!chunkId || typeof index !== 'number' || typeof total !== 'number' || !chunkData) {
|
|
426
|
+
dc.send(JSON.stringify({ type: 'error', message: 'malformed rpc-chunk-req' }));
|
|
427
|
+
break;
|
|
428
|
+
}
|
|
429
|
+
if (!rpcReqChunkBuffers.has(chunkId)) {
|
|
430
|
+
rpcReqChunkBuffers.set(chunkId, {
|
|
431
|
+
chunks: new Array(total),
|
|
432
|
+
received: 0,
|
|
433
|
+
total,
|
|
434
|
+
createdAt: Date.now(),
|
|
435
|
+
});
|
|
436
|
+
setTimeout(() => rpcReqChunkBuffers.delete(chunkId), 30_000);
|
|
437
|
+
}
|
|
438
|
+
const rpcBuf = rpcReqChunkBuffers.get(chunkId);
|
|
439
|
+
if (!rpcBuf.chunks[index]) {
|
|
440
|
+
rpcBuf.chunks[index] = chunkData;
|
|
441
|
+
rpcBuf.received++;
|
|
442
|
+
}
|
|
443
|
+
if (rpcBuf.received === rpcBuf.total) {
|
|
444
|
+
rpcReqChunkBuffers.delete(chunkId);
|
|
445
|
+
const fullMsg = rpcBuf.chunks.join('');
|
|
446
|
+
try {
|
|
447
|
+
const reassembled = JSON.parse(fullMsg);
|
|
448
|
+
handleRpcMessage(dc, reassembled, ctx);
|
|
449
|
+
}
|
|
450
|
+
catch (e) {
|
|
451
|
+
dc.send(JSON.stringify({ type: 'rpc-res', id: chunkId, status: 400, body: { error: 'Failed to reassemble chunked RPC' } }));
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
break;
|
|
455
|
+
}
|
|
418
456
|
case 'gateway-msg':
|
|
419
457
|
if (app?.gatewayClient && typeof msg['payload'] === 'string') {
|
|
420
458
|
app.gatewayClient.sendToGateway(msg['payload']);
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -1310,8 +1310,7 @@ async function handleSaveIntelligence(req, res, params) {
|
|
|
1310
1310
|
// ─── File Serving (restricted to ~/.openclaw/media/) ────────────────────────
|
|
1311
1311
|
|
|
1312
1312
|
const ALLOWED_FILE_DIRS = [
|
|
1313
|
-
|
|
1314
|
-
path.join(HOME, '.openclaw', 'workspace'),
|
|
1313
|
+
HOME,
|
|
1315
1314
|
'/tmp',
|
|
1316
1315
|
];
|
|
1317
1316
|
|