@clawchatsai/connector 0.0.52 → 0.0.54
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 +39 -0
- 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
|
// ---------------------------------------------------------------------------
|
|
@@ -161,6 +163,26 @@ async function startClawChats(ctx, api, mediaStash) {
|
|
|
161
163
|
ctx.logger.error('No gateway token available. Re-run: openclaw clawchats setup <token>');
|
|
162
164
|
return;
|
|
163
165
|
}
|
|
166
|
+
// Check for model definitions with 'input' set but missing 'image' — they silently drop attachments.
|
|
167
|
+
_imageRestrictedModels = [];
|
|
168
|
+
try {
|
|
169
|
+
const providers = gwCfg?.['models']?.['providers'] ?? {};
|
|
170
|
+
for (const provider of Object.values(providers)) {
|
|
171
|
+
if (Array.isArray(provider.models)) {
|
|
172
|
+
for (const m of provider.models) {
|
|
173
|
+
if (Array.isArray(m.input) && !m.input.includes('image')) {
|
|
174
|
+
_imageRestrictedModels.push(m.id ?? '(unknown)');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (_imageRestrictedModels.length > 0) {
|
|
180
|
+
ctx.logger.warn(`[clawchats] image-restricted models detected (missing "image" input): ${_imageRestrictedModels.join(', ')}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
catch {
|
|
184
|
+
// Non-fatal: config parse issue, just skip the check
|
|
185
|
+
}
|
|
164
186
|
// 3. Ensure native modules are built (OpenClaw installs with --ignore-scripts)
|
|
165
187
|
await ensureNativeModules(ctx);
|
|
166
188
|
// 4. Import server.js and create app instance with plugin paths
|
|
@@ -331,6 +353,16 @@ function normalizeGatewayPayload(raw) {
|
|
|
331
353
|
try {
|
|
332
354
|
const parsed = JSON.parse(raw);
|
|
333
355
|
if (parsed.method === 'chat.send' && typeof parsed.params?.message === 'string') {
|
|
356
|
+
// Warn user in-chat if they're sending image attachments to an image-restricted model.
|
|
357
|
+
// The warning is appended to the message so the AI echoes it back — impossible to miss.
|
|
358
|
+
if (Array.isArray(parsed.params?.attachments) &&
|
|
359
|
+
parsed.params.attachments.length > 0 &&
|
|
360
|
+
_imageRestrictedModels.length > 0) {
|
|
361
|
+
parsed.params.message = (parsed.params.message || '').trimEnd() +
|
|
362
|
+
'\n\n[⚠️ ClawChats: image attachment not delivered — your model config is missing "image" input support. ' +
|
|
363
|
+
'Fix: add "image" to the input array for your model in ~/.openclaw/openclaw.json, then restart the gateway.]';
|
|
364
|
+
return JSON.stringify(parsed);
|
|
365
|
+
}
|
|
334
366
|
// Fix image-only messages: inject placeholder so gateway doesn't reject empty body.
|
|
335
367
|
if (Array.isArray(parsed.params?.attachments) &&
|
|
336
368
|
parsed.params.attachments.length > 0 &&
|
|
@@ -397,6 +429,13 @@ function setupDataChannelHandler(dc, connectionId, ctx) {
|
|
|
397
429
|
// Auth succeeded — add to broadcast clients and inform gateway
|
|
398
430
|
connectedClients.set(connectionId, dc);
|
|
399
431
|
ctx.logger.info(`Browser authenticated: ${connectionId}`);
|
|
432
|
+
// Warn if any models have image support disabled in openclaw.json
|
|
433
|
+
if (_imageRestrictedModels.length > 0) {
|
|
434
|
+
dc.send(JSON.stringify({
|
|
435
|
+
type: 'gateway-event',
|
|
436
|
+
payload: JSON.stringify({ type: 'clawchats', event: 'image-capability-warning', models: _imageRestrictedModels }),
|
|
437
|
+
}));
|
|
438
|
+
}
|
|
400
439
|
// Persist backup code changes if any were consumed
|
|
401
440
|
if (authConfig.backupCodeHashes && config.backupCodeHashes) {
|
|
402
441
|
config.backupCodeHashes = authConfig.backupCodeHashes;
|