@wrongstack/vector-memory 0.319.0 → 0.319.1

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/dist/index.js +34 -37
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -165,9 +165,7 @@ function initVectorSchema(db) {
165
165
  db.exec("CREATE INDEX IF NOT EXISTS idx_entries_scope ON entries(scope)");
166
166
  db.exec("CREATE INDEX IF NOT EXISTS idx_entries_kind ON entries(kind)");
167
167
  db.exec("CREATE UNIQUE INDEX IF NOT EXISTS idx_entries_hash ON entries(content_hash)");
168
- db.exec(
169
- "CREATE INDEX IF NOT EXISTS idx_entries_updated ON entries(updated_at DESC)"
170
- );
168
+ db.exec("CREATE INDEX IF NOT EXISTS idx_entries_updated ON entries(updated_at DESC)");
171
169
  db.exec(`
172
170
  CREATE TABLE IF NOT EXISTS vectors (
173
171
  entry_id TEXT NOT NULL,
@@ -229,15 +227,7 @@ function upsertEmbeddingCache(db, row) {
229
227
  last_used_at = excluded.last_used_at,
230
228
  use_count = embedding_cache.use_count + 1,
231
229
  vector = excluded.vector`
232
- ).run(
233
- row.contentHash,
234
- row.providerId,
235
- row.dimensions,
236
- row.vector,
237
- row.text,
238
- row.now,
239
- row.now
240
- );
230
+ ).run(row.contentHash, row.providerId, row.dimensions, row.vector, row.text, row.now, row.now);
241
231
  }
242
232
  function lookupEmbeddingCache(db, contentHash, providerId, dimensions, now) {
243
233
  const row = db.prepare(
@@ -934,7 +924,10 @@ function decideWhetherToSync(store, staleAfterMs, now = /* @__PURE__ */ new Date
934
924
  const ageMs = Number.isNaN(startedAt) ? Number.POSITIVE_INFINITY : now.getTime() - startedAt;
935
925
  const stale = ageMs > staleAfterMs;
936
926
  if (existing.pid === void 0) {
937
- return Number.isNaN(startedAt) || stale ? { run: true, reason: Number.isNaN(startedAt) ? "running-marker-undated" : "running-marker-stale" } : { run: false, reason: "running-unknown-pid" };
927
+ return Number.isNaN(startedAt) || stale ? {
928
+ run: true,
929
+ reason: Number.isNaN(startedAt) ? "running-marker-undated" : "running-marker-stale"
930
+ } : { run: false, reason: "running-unknown-pid" };
938
931
  }
939
932
  try {
940
933
  if (pidAlive(existing.pid)) {
@@ -987,7 +980,12 @@ function storeProvider(store) {
987
980
  return void 0;
988
981
  }
989
982
  function counts(report) {
990
- return { scanned: report.scanned, indexed: report.indexed, skipped: report.skipped, failed: report.failed };
983
+ return {
984
+ scanned: report.scanned,
985
+ indexed: report.indexed,
986
+ skipped: report.skipped,
987
+ failed: report.failed
988
+ };
991
989
  }
992
990
 
993
991
  // src/tools.ts
@@ -1062,7 +1060,12 @@ function vectorMemorySearchTool(store) {
1062
1060
  type: "object",
1063
1061
  properties: {
1064
1062
  query: { type: "string", minLength: 1, description: "The natural-language query." },
1065
- limit: { type: "number", minimum: 1, maximum: 100, description: "Max results (default 10)." },
1063
+ limit: {
1064
+ type: "number",
1065
+ minimum: 1,
1066
+ maximum: 100,
1067
+ description: "Max results (default 10)."
1068
+ },
1066
1069
  threshold: {
1067
1070
  type: "number",
1068
1071
  minimum: 0,
@@ -1137,7 +1140,11 @@ function vectorMemoryForgetTool(store) {
1137
1140
  inputSchema: {
1138
1141
  type: "object",
1139
1142
  properties: {
1140
- id: { type: "string", minLength: 1, description: "Entry id returned by `vector_memory_remember`." }
1143
+ id: {
1144
+ type: "string",
1145
+ minLength: 1,
1146
+ description: "Entry id returned by `vector_memory_remember`."
1147
+ }
1141
1148
  },
1142
1149
  required: ["id"],
1143
1150
  additionalProperties: false
@@ -1317,9 +1324,7 @@ function wrapMemoryPortWithVectorRecall(port, options) {
1317
1324
  // want the per-channel score breakdown get the same fusion
1318
1325
  // behaviour as `searchSage`.
1319
1326
  ...original.searchSageWithBreakdown ? {
1320
- searchSageWithBreakdown: wrapSearch(
1321
- original.searchSageWithBreakdown
1322
- )
1327
+ searchSageWithBreakdown: wrapSearch(original.searchSageWithBreakdown)
1323
1328
  } : {}
1324
1329
  };
1325
1330
  }
@@ -1330,9 +1335,7 @@ function wrapMemoryPortWithVectorRecall(port, options) {
1330
1335
  ...original,
1331
1336
  searchSage: wrapSearch(original.searchSage),
1332
1337
  ...original.searchSageWithBreakdown ? {
1333
- searchSageWithBreakdown: wrapSearch(
1334
- original.searchSageWithBreakdown
1335
- )
1338
+ searchSageWithBreakdown: wrapSearch(original.searchSageWithBreakdown)
1336
1339
  } : {}
1337
1340
  };
1338
1341
  }
@@ -1363,9 +1366,7 @@ function subscribeVectorMemoryToSage(opts) {
1363
1366
  try {
1364
1367
  return await surface.getSage(memoryId);
1365
1368
  } catch (err) {
1366
- log?.warn?.(
1367
- `vector-memory mirror fetch failed for ${memoryId}: ${errMsg2(err)}`
1368
- );
1369
+ log?.warn?.(`vector-memory mirror fetch failed for ${memoryId}: ${errMsg2(err)}`);
1369
1370
  return null;
1370
1371
  }
1371
1372
  };
@@ -1392,9 +1393,7 @@ function subscribeVectorMemoryToSage(opts) {
1392
1393
  }
1393
1394
  });
1394
1395
  } catch (err) {
1395
- log?.warn?.(
1396
- `vector-memory mirror remember failed for ${memoryId}: ${errMsg2(err)}`
1397
- );
1396
+ log?.warn?.(`vector-memory mirror remember failed for ${memoryId}: ${errMsg2(err)}`);
1398
1397
  }
1399
1398
  };
1400
1399
  const forgetMirror = async (memoryId) => {
@@ -1402,9 +1401,7 @@ function subscribeVectorMemoryToSage(opts) {
1402
1401
  const existing = store.findBySageId(memoryId);
1403
1402
  if (existing) await store.forget(existing.id);
1404
1403
  } catch (err) {
1405
- log?.warn?.(
1406
- `vector-memory mirror forget failed for ${memoryId}: ${errMsg2(err)}`
1407
- );
1404
+ log?.warn?.(`vector-memory mirror forget failed for ${memoryId}: ${errMsg2(err)}`);
1408
1405
  }
1409
1406
  };
1410
1407
  const offAccepted = events.onPattern("memory.accepted", (_event, payload) => {
@@ -1456,9 +1453,7 @@ async function forgetStaleSageMirrors(store, memoryStore, logger) {
1456
1453
  await store.forget(entry.id);
1457
1454
  removed++;
1458
1455
  } catch (err) {
1459
- logger?.warn?.(
1460
- `vector-memory stale-mirror sweep failed for ${sageId}: ${errMsg2(err)}`
1461
- );
1456
+ logger?.warn?.(`vector-memory stale-mirror sweep failed for ${sageId}: ${errMsg2(err)}`);
1462
1457
  }
1463
1458
  }
1464
1459
  if (page.length < 1e3) break;
@@ -1499,8 +1494,8 @@ async function runSearchRace(query, lexical, vectorStore, options = {}) {
1499
1494
  overlap.push({
1500
1495
  id,
1501
1496
  lexicalScore: score,
1502
- vectorScore: 0,
1503
- // patched below
1497
+ vectorScore: null,
1498
+ // patched below when a vector hit carries this id
1504
1499
  preview: previewText(mem.text, 140)
1505
1500
  });
1506
1501
  }
@@ -1523,7 +1518,7 @@ async function runSearchRace(query, lexical, vectorStore, options = {}) {
1523
1518
  }
1524
1519
  for (let i = overlap.length - 1; i >= 0; i--) {
1525
1520
  const row = overlap[i];
1526
- if (row.vectorScore === 0) {
1521
+ if (row.vectorScore === null) {
1527
1522
  lexicalOnly.push({
1528
1523
  id: row.id,
1529
1524
  lexicalScore: row.lexicalScore,
@@ -1540,6 +1535,8 @@ async function runSearchRace(query, lexical, vectorStore, options = {}) {
1540
1535
  query,
1541
1536
  lexicalOnly,
1542
1537
  vectorOnly,
1538
+ // The sweep above removed every row still carrying a null vectorScore,
1539
+ // so every remaining row holds a real number here.
1543
1540
  overlap,
1544
1541
  metrics: {
1545
1542
  lexicalCount,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/vector-memory",
3
- "version": "0.319.0",
3
+ "version": "0.319.1",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack Vector Memory — an additional vector-search memory store powered by @huggingface/transformers (local ONNX embeddings), alongside the SAGE lexical memory system.",
6
6
  "repository": {
@@ -27,9 +27,9 @@
27
27
  "README.md"
28
28
  ],
29
29
  "dependencies": {
30
- "@wrongstack/core": "0.319.0",
31
- "@wrongstack/persistence": "0.319.0",
32
- "@wrongstack/sage": "0.319.0"
30
+ "@wrongstack/core": "0.319.1",
31
+ "@wrongstack/persistence": "0.319.1",
32
+ "@wrongstack/sage": "0.319.1"
33
33
  },
34
34
  "optionalDependencies": {
35
35
  "@huggingface/transformers": "^4.2.0"