@clawchatsai/connector 0.0.97 → 0.0.98

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 CHANGED
@@ -613,7 +613,18 @@ function processAuthenticatedMessage(dc, connectionId, msg, ctx) {
613
613
  }
614
614
  case 'gateway-msg':
615
615
  if (app?.gatewayClient && typeof msg['payload'] === 'string') {
616
- app.gatewayClient.sendToGateway(normalizeGatewayPayload(msg['payload']));
616
+ const _gwPayload = msg['payload'];
617
+ // Persist model when sessions.patch is called
618
+ try {
619
+ const _gwMsg = JSON.parse(_gwPayload);
620
+ if (_gwMsg.method === 'sessions.patch' && _gwMsg.params?.model && _gwMsg.params?.key) {
621
+ const _db = app.getActiveDb();
622
+ _db.prepare('UPDATE threads SET model = ?, updated_at = ? WHERE session_key = ?')
623
+ .run(_gwMsg.params.model, Date.now(), _gwMsg.params.key);
624
+ }
625
+ }
626
+ catch { /* ignore parse/db errors */ }
627
+ app.gatewayClient.sendToGateway(normalizeGatewayPayload(_gwPayload));
617
628
  }
618
629
  break;
619
630
  case 'gateway-msg-chunk': {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawchatsai/connector",
3
- "version": "0.0.97",
3
+ "version": "0.0.98",
4
4
  "type": "module",
5
5
  "description": "ClawChats OpenClaw plugin — P2P tunnel + local API bridge",
6
6
  "main": "dist/index.js",
@@ -86,6 +86,7 @@ export class ThreadController {
86
86
  if (body.pinned !== undefined) { fields.push('pinned = ?'); values.push(body.pinned ? 1 : 0); }
87
87
  if (body.pin_order !== undefined) { fields.push('pin_order = ?'); values.push(body.pin_order); }
88
88
  if (body.sort_order !== undefined) { fields.push('sort_order = ?'); values.push(body.sort_order); }
89
+ if (body.metadata !== undefined) { fields.push('metadata = ?'); values.push(typeof body.metadata === 'string' ? body.metadata : JSON.stringify(body.metadata)); }
89
90
  if (fields.length) {
90
91
  fields.push('updated_at = ?');
91
92
  values.push(Date.now(), params.id);
package/server/index.js CHANGED
@@ -340,6 +340,7 @@ function migrate(db) {
340
340
  `);
341
341
  try { db.exec('ALTER TABLE threads ADD COLUMN sort_order INTEGER DEFAULT 0'); } catch { /* exists */ }
342
342
  try { db.exec('ALTER TABLE threads ADD COLUMN unread_count INTEGER DEFAULT 0'); } catch { /* exists */ }
343
+ try { db.prepare('ALTER TABLE threads ADD COLUMN metadata TEXT DEFAULT NULL').run(); } catch {}
343
344
  db.exec(`CREATE TABLE IF NOT EXISTS unread_messages (thread_id TEXT NOT NULL, message_id TEXT NOT NULL, created_at INTEGER NOT NULL, PRIMARY KEY (thread_id, message_id), FOREIGN KEY (thread_id) REFERENCES threads(id) ON DELETE CASCADE)`);
344
345
  db.exec('CREATE INDEX IF NOT EXISTS idx_unread_thread ON unread_messages(thread_id)');
345
346
  ensureFts(db);