@clawchatsai/connector 0.0.77 → 0.0.79
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 +11 -11
- package/package.json +1 -1
- package/server.js +31 -12
package/dist/index.js
CHANGED
|
@@ -413,18 +413,8 @@ function normalizeGatewayPayload(raw) {
|
|
|
413
413
|
parsed.params.message = '[Image]';
|
|
414
414
|
return JSON.stringify(parsed);
|
|
415
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
|
-
}
|
|
426
416
|
// Save inline base64 attachments to disk so the agent can reference them as file paths.
|
|
427
|
-
// Runs
|
|
417
|
+
// Runs before capability note so a gateway restart doesn't prevent path injection.
|
|
428
418
|
if (Array.isArray(parsed.params?.attachments) && parsed.params.attachments.length > 0 && _uploadsDir) {
|
|
429
419
|
const skMatch = (parsed.params.sessionKey || '').match(/^agent:[^:]+:[^:]+:chat:([^:]+)$/);
|
|
430
420
|
const threadId = skMatch?.[1] || 'misc';
|
|
@@ -452,6 +442,16 @@ function normalizeGatewayPayload(raw) {
|
|
|
452
442
|
return JSON.stringify(parsed);
|
|
453
443
|
}
|
|
454
444
|
}
|
|
445
|
+
// Capability note: inform the agent that exec stdout lines starting with MEDIA:/path
|
|
446
|
+
// cause that file to appear inline in chat. Phrased descriptively (not imperatively)
|
|
447
|
+
// to avoid triggering prompt-injection scanners. Injected once per session (~8 tokens).
|
|
448
|
+
const sk = parsed.params.sessionKey || '';
|
|
449
|
+
if (sk.includes(':chat:') && !_hintedSessions.has(sk)) {
|
|
450
|
+
_hintedSessions.add(sk);
|
|
451
|
+
parsed.params.message += '\n[ClawChats: after using Write tool, run exec with: echo "MEDIA:/path/to/file" to surface it in chat]';
|
|
452
|
+
console.log(`[clawchats] capability-note injected for session ${sk}`);
|
|
453
|
+
return JSON.stringify(parsed);
|
|
454
|
+
}
|
|
455
455
|
}
|
|
456
456
|
}
|
|
457
457
|
catch {
|
package/package.json
CHANGED
package/server.js
CHANGED
|
@@ -395,7 +395,7 @@ function _createFtsTables(db) {
|
|
|
395
395
|
content,
|
|
396
396
|
content=messages,
|
|
397
397
|
content_rowid=rowid,
|
|
398
|
-
tokenize='porter unicode61'
|
|
398
|
+
tokenize='porter unicode61 tokenchars ''''
|
|
399
399
|
);
|
|
400
400
|
CREATE TRIGGER messages_ai AFTER INSERT ON messages BEGIN
|
|
401
401
|
INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
|
|
@@ -484,20 +484,39 @@ function migrate(db) {
|
|
|
484
484
|
if (!hasFts) {
|
|
485
485
|
_createFtsTables(db);
|
|
486
486
|
} else {
|
|
487
|
-
//
|
|
488
|
-
//
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
487
|
+
// Migration: rebuild FTS table if tokenizer is outdated (missing tokenchars for apostrophe support).
|
|
488
|
+
// Old tokenizer split "there's" into ["there", "s"] causing contraction searches to return 0 results.
|
|
489
|
+
const ftsSchema = db.prepare(
|
|
490
|
+
"SELECT sql FROM sqlite_master WHERE type='table' AND name='messages_fts'"
|
|
491
|
+
).get();
|
|
492
|
+
const needsTokenizerUpgrade = ftsSchema && !ftsSchema.sql.includes('tokenchars');
|
|
493
|
+
if (needsTokenizerUpgrade) {
|
|
494
|
+
console.log('[DB] messages_fts tokenizer upgrade required (apostrophe support) — rebuilding index...');
|
|
494
495
|
try {
|
|
496
|
+
_dropFtsTables(db);
|
|
497
|
+
_createFtsTables(db);
|
|
495
498
|
db.prepare("INSERT INTO messages_fts(messages_fts) VALUES('rebuild')").run();
|
|
496
|
-
console.log('[DB] messages_fts
|
|
497
|
-
} catch (
|
|
498
|
-
console.error('[DB] messages_fts
|
|
499
|
+
console.log('[DB] messages_fts tokenizer upgrade complete — apostrophes in contractions now searchable');
|
|
500
|
+
} catch (upgradeErr) {
|
|
501
|
+
console.error('[DB] messages_fts tokenizer upgrade failed, dropping for graceful degradation:', upgradeErr.message);
|
|
499
502
|
_dropFtsTables(db);
|
|
500
|
-
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
// Integrity check: corruption causes all message writes to 500.
|
|
506
|
+
// Attempt rebuild first; if that fails, drop entirely for graceful degradation
|
|
507
|
+
// (messages still save, search returns empty until next restart recreates the table).
|
|
508
|
+
try {
|
|
509
|
+
db.prepare("INSERT INTO messages_fts(messages_fts) VALUES('integrity-check')").run();
|
|
510
|
+
} catch (err) {
|
|
511
|
+
console.warn('[DB] messages_fts integrity check failed, attempting rebuild:', err.message);
|
|
512
|
+
try {
|
|
513
|
+
db.prepare("INSERT INTO messages_fts(messages_fts) VALUES('rebuild')").run();
|
|
514
|
+
console.log('[DB] messages_fts rebuilt successfully — search index restored');
|
|
515
|
+
} catch (rebuildErr) {
|
|
516
|
+
console.error('[DB] messages_fts rebuild failed, dropping FTS for graceful degradation:', rebuildErr.message);
|
|
517
|
+
_dropFtsTables(db);
|
|
518
|
+
// On the next gateway restart the table will be recreated fresh via the !hasFts path
|
|
519
|
+
}
|
|
501
520
|
}
|
|
502
521
|
}
|
|
503
522
|
}
|