@clawchatsai/connector 0.0.76 → 0.0.77

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.
Files changed (2) hide show
  1. package/dist/index.js +28 -27
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -396,7 +396,35 @@ 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
+ }
416
+ // Capability note: inform the agent that exec stdout lines starting with MEDIA:/path
417
+ // cause that file to appear inline in chat. Phrased descriptively (not imperatively)
418
+ // to avoid triggering prompt-injection scanners. Injected once per session (~8 tokens).
419
+ const sk = parsed.params.sessionKey || '';
420
+ if (sk.includes(':chat:') && !_hintedSessions.has(sk)) {
421
+ _hintedSessions.add(sk);
422
+ parsed.params.message += '\n[ClawChats: after using Write tool, run exec with: echo "MEDIA:/path/to/file" to surface it in chat]';
423
+ console.log(`[clawchats] capability-note injected for session ${sk}`);
424
+ return JSON.stringify(parsed);
425
+ }
399
426
  // Save inline base64 attachments to disk so the agent can reference them as file paths.
427
+ // Runs last so image-restricted warning and capability note fire normally first.
400
428
  if (Array.isArray(parsed.params?.attachments) && parsed.params.attachments.length > 0 && _uploadsDir) {
401
429
  const skMatch = (parsed.params.sessionKey || '').match(/^agent:[^:]+:[^:]+:chat:([^:]+)$/);
402
430
  const threadId = skMatch?.[1] || 'misc';
@@ -424,33 +452,6 @@ function normalizeGatewayPayload(raw) {
424
452
  return JSON.stringify(parsed);
425
453
  }
426
454
  }
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
- // Capability note: inform the agent that exec stdout lines starting with MEDIA:/path
445
- // cause that file to appear inline in chat. Phrased descriptively (not imperatively)
446
- // to avoid triggering prompt-injection scanners. Injected once per session (~8 tokens).
447
- const sk = parsed.params.sessionKey || '';
448
- if (sk.includes(':chat:') && !_hintedSessions.has(sk)) {
449
- _hintedSessions.add(sk);
450
- parsed.params.message += '\n[ClawChats: after using Write tool, run exec with: echo "MEDIA:/path/to/file" to surface it in chat]';
451
- console.log(`[clawchats] capability-note injected for session ${sk}`);
452
- return JSON.stringify(parsed);
453
- }
454
455
  }
455
456
  }
456
457
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.76",
3
+ "version": "0.0.77",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",