@clawchatsai/connector 0.0.76 → 0.0.78
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 +18 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -396,7 +396,25 @@ function normalizeGatewayPayload(raw) {
|
|
|
396
396
|
try {
|
|
397
397
|
const parsed = JSON.parse(raw);
|
|
398
398
|
if (parsed.method === 'chat.send' && typeof parsed.params?.message === 'string') {
|
|
399
|
+
// Warn user in-chat if they're sending image attachments to an image-restricted model.
|
|
400
|
+
// The warning is appended to the message so the AI echoes it back — impossible to miss.
|
|
401
|
+
if (Array.isArray(parsed.params?.attachments) &&
|
|
402
|
+
parsed.params.attachments.length > 0 &&
|
|
403
|
+
_imageRestrictedModels.length > 0) {
|
|
404
|
+
parsed.params.message = (parsed.params.message || '').trimEnd() +
|
|
405
|
+
'\n\n[⚠️ ClawChats: image attachment not delivered — your model config is missing "image" input support. ' +
|
|
406
|
+
'Fix: add "image" to the input array for your model in ~/.openclaw/openclaw.json, then restart the gateway.]';
|
|
407
|
+
return JSON.stringify(parsed);
|
|
408
|
+
}
|
|
409
|
+
// Fix image-only messages: inject placeholder so gateway doesn't reject empty body.
|
|
410
|
+
if (Array.isArray(parsed.params?.attachments) &&
|
|
411
|
+
parsed.params.attachments.length > 0 &&
|
|
412
|
+
!parsed.params.message?.trim()) {
|
|
413
|
+
parsed.params.message = '[Image]';
|
|
414
|
+
return JSON.stringify(parsed);
|
|
415
|
+
}
|
|
399
416
|
// Save inline base64 attachments to disk so the agent can reference them as file paths.
|
|
417
|
+
// Runs before capability note so a gateway restart doesn't prevent path injection.
|
|
400
418
|
if (Array.isArray(parsed.params?.attachments) && parsed.params.attachments.length > 0 && _uploadsDir) {
|
|
401
419
|
const skMatch = (parsed.params.sessionKey || '').match(/^agent:[^:]+:[^:]+:chat:([^:]+)$/);
|
|
402
420
|
const threadId = skMatch?.[1] || 'misc';
|
|
@@ -424,23 +442,6 @@ function normalizeGatewayPayload(raw) {
|
|
|
424
442
|
return JSON.stringify(parsed);
|
|
425
443
|
}
|
|
426
444
|
}
|
|
427
|
-
// Warn user in-chat if they're sending image attachments to an image-restricted model.
|
|
428
|
-
// The warning is appended to the message so the AI echoes it back — impossible to miss.
|
|
429
|
-
if (Array.isArray(parsed.params?.attachments) &&
|
|
430
|
-
parsed.params.attachments.length > 0 &&
|
|
431
|
-
_imageRestrictedModels.length > 0) {
|
|
432
|
-
parsed.params.message = (parsed.params.message || '').trimEnd() +
|
|
433
|
-
'\n\n[⚠️ ClawChats: image attachment not delivered — your model config is missing "image" input support. ' +
|
|
434
|
-
'Fix: add "image" to the input array for your model in ~/.openclaw/openclaw.json, then restart the gateway.]';
|
|
435
|
-
return JSON.stringify(parsed);
|
|
436
|
-
}
|
|
437
|
-
// Fix image-only messages: inject placeholder so gateway doesn't reject empty body.
|
|
438
|
-
if (Array.isArray(parsed.params?.attachments) &&
|
|
439
|
-
parsed.params.attachments.length > 0 &&
|
|
440
|
-
!parsed.params.message?.trim()) {
|
|
441
|
-
parsed.params.message = '[Image]';
|
|
442
|
-
return JSON.stringify(parsed);
|
|
443
|
-
}
|
|
444
445
|
// Capability note: inform the agent that exec stdout lines starting with MEDIA:/path
|
|
445
446
|
// cause that file to appear inline in chat. Phrased descriptively (not imperatively)
|
|
446
447
|
// to avoid triggering prompt-injection scanners. Injected once per session (~8 tokens).
|