@clawchatsai/connector 0.0.81 → 0.0.83

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/package.json +1 -1
  2. package/server.js +25 -19
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.81",
3
+ "version": "0.0.83",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",
package/server.js CHANGED
@@ -390,24 +390,25 @@ function closeAllDbs() {
390
390
  }
391
391
 
392
392
  function _createFtsTables(db) {
393
- db.exec(`
394
- CREATE VIRTUAL TABLE messages_fts USING fts5(
395
- content,
396
- content=messages,
397
- content_rowid=rowid,
398
- tokenize='porter unicode61 tokenchars ''''
399
- );
400
- CREATE TRIGGER messages_ai AFTER INSERT ON messages BEGIN
401
- INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
402
- END;
403
- CREATE TRIGGER messages_ad AFTER DELETE ON messages BEGIN
404
- INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
405
- END;
406
- CREATE TRIGGER messages_au AFTER UPDATE ON messages BEGIN
407
- INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
408
- INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
409
- END;
410
- `);
393
+ // Each statement must be a separate db.exec() call — SQLite's multi-statement exec
394
+ // splits on every semicolon including those inside BEGIN...END trigger bodies,
395
+ // which breaks trigger creation with an "unrecognized token" error.
396
+ db.exec(`CREATE VIRTUAL TABLE messages_fts USING fts5(
397
+ content,
398
+ content=messages,
399
+ content_rowid=rowid,
400
+ tokenize='porter unicode61 tokenchars x27'
401
+ )`);
402
+ db.exec(`CREATE TRIGGER messages_ai AFTER INSERT ON messages BEGIN
403
+ INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
404
+ END`);
405
+ db.exec(`CREATE TRIGGER messages_ad AFTER DELETE ON messages BEGIN
406
+ INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
407
+ END`);
408
+ db.exec(`CREATE TRIGGER messages_au AFTER UPDATE ON messages BEGIN
409
+ INSERT INTO messages_fts(messages_fts, rowid, content) VALUES('delete', old.rowid, old.content);
410
+ INSERT INTO messages_fts(rowid, content) VALUES (new.rowid, new.content);
411
+ END`);
411
412
  }
412
413
 
413
414
  function _dropFtsTables(db) {
@@ -482,7 +483,12 @@ function migrate(db) {
482
483
  "SELECT name FROM sqlite_master WHERE type='table' AND name='messages_fts'"
483
484
  ).get();
484
485
  if (!hasFts) {
485
- _createFtsTables(db);
486
+ try {
487
+ _createFtsTables(db);
488
+ db.prepare("INSERT INTO messages_fts(messages_fts) VALUES('rebuild')").run();
489
+ } catch (ftsCreateErr) {
490
+ console.error('[DB] messages_fts creation failed, search disabled:', ftsCreateErr.message);
491
+ }
486
492
  } else {
487
493
  // Migration: rebuild FTS table if tokenizer is outdated (missing tokenchars for apostrophe support).
488
494
  // Old tokenizer split "there's" into ["there", "s"] causing contraction searches to return 0 results.