@clawchatsai/connector 0.0.52 → 0.0.53

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 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -37,6 +37,8 @@ let signaling = null;
37
37
  let webrtcPeer = null;
38
38
  let healthServer = null;
39
39
  let _stopRequested = false;
40
+ /** Model IDs that have 'input' explicitly set without 'image' support. */
41
+ let _imageRestrictedModels = [];
40
42
  // ---------------------------------------------------------------------------
41
43
  // Config helpers
42
44
  // ---------------------------------------------------------------------------
@@ -331,6 +333,16 @@ function normalizeGatewayPayload(raw) {
331
333
  try {
332
334
  const parsed = JSON.parse(raw);
333
335
  if (parsed.method === 'chat.send' && typeof parsed.params?.message === 'string') {
336
+ // Warn user in-chat if they're sending image attachments to an image-restricted model.
337
+ // The warning is appended to the message so the AI echoes it back — impossible to miss.
338
+ if (Array.isArray(parsed.params?.attachments) &&
339
+ parsed.params.attachments.length > 0 &&
340
+ _imageRestrictedModels.length > 0) {
341
+ parsed.params.message = (parsed.params.message || '').trimEnd() +
342
+ '\n\n[⚠️ ClawChats: image attachment not delivered — your model config is missing "image" input support. ' +
343
+ 'Fix: add "image" to the input array for your model in ~/.openclaw/openclaw.json, then restart the gateway.]';
344
+ return JSON.stringify(parsed);
345
+ }
334
346
  // Fix image-only messages: inject placeholder so gateway doesn't reject empty body.
335
347
  if (Array.isArray(parsed.params?.attachments) &&
336
348
  parsed.params.attachments.length > 0 &&
@@ -397,6 +409,14 @@ function setupDataChannelHandler(dc, connectionId, ctx) {
397
409
  // Auth succeeded — add to broadcast clients and inform gateway
398
410
  connectedClients.set(connectionId, dc);
399
411
  ctx.logger.info(`Browser authenticated: ${connectionId}`);
412
+ // Warn if any models have image support disabled in openclaw.json
413
+ if (_imageRestrictedModels.length > 0) {
414
+ dc.send(JSON.stringify({
415
+ type: 'clawchats',
416
+ event: 'image-capability-warning',
417
+ models: _imageRestrictedModels,
418
+ }));
419
+ }
400
420
  // Persist backup code changes if any were consumed
401
421
  if (authConfig.backupCodeHashes && config.backupCodeHashes) {
402
422
  config.backupCodeHashes = authConfig.backupCodeHashes;
@@ -680,6 +700,14 @@ async function handleSetup(token) {
680
700
  const openclawConfigPath = path.join(process.env.HOME || '/root', '.openclaw', 'openclaw.json');
681
701
  const openclawConfig = JSON.parse(fs.readFileSync(openclawConfigPath, 'utf8'));
682
702
  gatewayToken = openclawConfig.gateway?.auth?.token || openclawConfig.auth?.token || openclawConfig.token || '';
703
+ // Check for model definitions that have 'input' set without 'image' — these silently drop image attachments.
704
+ const modelDefs = openclawConfig?.models?.definitions ?? [];
705
+ _imageRestrictedModels = modelDefs
706
+ .filter(def => Array.isArray(def.input) && !def.input.includes('image'))
707
+ .map(def => def.id ?? '(unknown)');
708
+ if (_imageRestrictedModels.length > 0) {
709
+ console.warn(`[clawchats] image-restricted models detected: ${_imageRestrictedModels.join(', ')}`);
710
+ }
683
711
  }
684
712
  catch {
685
713
  console.error('Could not read gateway token from ~/.openclaw/openclaw.json');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.52",
3
+ "version": "0.0.53",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",