@roitium/telegram-stickers-brain 2.0.0 → 2.2.0

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/index.js CHANGED
@@ -2,7 +2,7 @@ const fs = require('fs');
2
2
  const path = require('path');
3
3
  const cp = require('child_process');
4
4
  const https = require('https');
5
- const sqlite3 = require('sqlite3');
5
+ const Database = require('better-sqlite3');
6
6
  const { load } = require('sqlite-vec');
7
7
 
8
8
  module.exports = function(api) {
@@ -24,7 +24,7 @@ module.exports = function(api) {
24
24
  function ensureDB() {
25
25
  if (!db) {
26
26
  try {
27
- db = new sqlite3.Database('/root/.cache/qmd/index.sqlite');
27
+ db = new Database('/root/.cache/qmd/index.sqlite', { readonly: true });
28
28
  load(db);
29
29
  } catch (e) {
30
30
  api.logger.error("[Stickers] Failed to load vector db: " + e.message);
@@ -331,7 +331,7 @@ ${caption}`;
331
331
  const embedding = await embCtx.getEmbeddingFor(params.query);
332
332
  const vecJson = JSON.stringify(Array.from(embedding.vector));
333
333
 
334
- // 2. Query SQLite
334
+ // 2. Query SQLite using better-sqlite3
335
335
  const sql = `
336
336
  SELECT d.title, v.distance
337
337
  FROM vectors_vec v
@@ -340,11 +340,7 @@ ${caption}`;
340
340
  ORDER BY v.distance ASC
341
341
  `;
342
342
 
343
- results = await new Promise((resolve, reject) => {
344
- database.all(sql, [vecJson], (err, rows) => {
345
- if (err) reject(err); else resolve(rows);
346
- });
347
- });
343
+ results = database.prepare(sql).all(vecJson);
348
344
 
349
345
  const queryDuration = Date.now() - searchStart;
350
346
  api.logger.info(`[Stickers] Search for "${params.query}" took ${queryDuration}ms`);
@@ -1,8 +1,8 @@
1
1
  {
2
- "id": "telegram-stickers",
2
+ "id": "telegram-stickers-brain",
3
3
  "name": "Telegram Stickers Brain",
4
4
  "description": "Semantic Telegram sticker management with VLM captioning and QMD vector indexing",
5
- "version": "3.3.0",
5
+ "version": "2.2.0",
6
6
  "configSchema": {
7
7
  "type": "object",
8
8
  "additionalProperties": false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@roitium/telegram-stickers-brain",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "description": "Telegram Stickers Plugin with auto-collection and load balancing",
5
5
  "main": "index.js",
6
6
  "openclaw": {
@@ -19,9 +19,9 @@
19
19
  "license": "MIT",
20
20
  "dependencies": {
21
21
  "@google/generative-ai": "^0.24.1",
22
+ "better-sqlite3": "^12.6.2",
22
23
  "node-llama-cpp": "^3.17.1",
23
- "sqlite-vec": "^0.1.7-alpha.2",
24
- "sqlite3": "^5.1.7"
24
+ "sqlite-vec": "^0.1.7-alpha.2"
25
25
  },
26
26
  "engines": {
27
27
  "node": ">=16.0.0"