@clawchatsai/connector 0.0.34 → 0.0.36
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 +29 -2
- package/package.json +1 -1
- package/server.js +1 -2
package/dist/index.js
CHANGED
|
@@ -313,6 +313,33 @@ async function stopClawChats(ctx) {
|
|
|
313
313
|
ctx.logger.info('ClawChats service stopped');
|
|
314
314
|
}
|
|
315
315
|
// ---------------------------------------------------------------------------
|
|
316
|
+
// ---------------------------------------------------------------------------
|
|
317
|
+
// Gateway payload normalization
|
|
318
|
+
// ---------------------------------------------------------------------------
|
|
319
|
+
/**
|
|
320
|
+
* Normalize gateway-bound payloads before forwarding.
|
|
321
|
+
*
|
|
322
|
+
* Fixes image-only messages: some OpenClaw versions reject chat.send when
|
|
323
|
+
* the message body is empty, even if attachments are present (the empty-body
|
|
324
|
+
* guard checks MediaPath/MediaPaths but not inline base64 attachments).
|
|
325
|
+
* Injecting a minimal placeholder ensures the agent run proceeds.
|
|
326
|
+
*/
|
|
327
|
+
function normalizeGatewayPayload(raw) {
|
|
328
|
+
try {
|
|
329
|
+
const parsed = JSON.parse(raw);
|
|
330
|
+
if (parsed.method === 'chat.send' &&
|
|
331
|
+
Array.isArray(parsed.params?.attachments) &&
|
|
332
|
+
parsed.params.attachments.length > 0 &&
|
|
333
|
+
!parsed.params.message?.trim()) {
|
|
334
|
+
parsed.params.message = '[Image]';
|
|
335
|
+
return JSON.stringify(parsed);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
// Not JSON or unexpected shape — pass through unchanged
|
|
340
|
+
}
|
|
341
|
+
return raw;
|
|
342
|
+
}
|
|
316
343
|
// DataChannel message handler (spec section 6.4)
|
|
317
344
|
// ---------------------------------------------------------------------------
|
|
318
345
|
function setupDataChannelHandler(dc, connectionId, ctx) {
|
|
@@ -455,7 +482,7 @@ function processAuthenticatedMessage(dc, connectionId, msg, ctx) {
|
|
|
455
482
|
}
|
|
456
483
|
case 'gateway-msg':
|
|
457
484
|
if (app?.gatewayClient && typeof msg['payload'] === 'string') {
|
|
458
|
-
app.gatewayClient.sendToGateway(msg['payload']);
|
|
485
|
+
app.gatewayClient.sendToGateway(normalizeGatewayPayload(msg['payload']));
|
|
459
486
|
}
|
|
460
487
|
break;
|
|
461
488
|
case 'gateway-msg-chunk': {
|
|
@@ -485,7 +512,7 @@ function processAuthenticatedMessage(dc, connectionId, msg, ctx) {
|
|
|
485
512
|
gatewayMsgChunkBuffers.delete(chunkId);
|
|
486
513
|
const fullPayload = buf.chunks.join('');
|
|
487
514
|
if (app?.gatewayClient) {
|
|
488
|
-
app.gatewayClient.sendToGateway(fullPayload);
|
|
515
|
+
app.gatewayClient.sendToGateway(normalizeGatewayPayload(fullPayload));
|
|
489
516
|
}
|
|
490
517
|
}
|
|
491
518
|
break;
|
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
|
|