openclaw-memory-alibaba-local 1.0.11 → 1.0.12

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 (3) hide show
  1. package/db.ts +22 -16
  2. package/index.ts +13 -13
  3. package/package.json +1 -1
package/db.ts CHANGED
@@ -510,7 +510,7 @@ export class MemoryDB {
510
510
  });
511
511
  if (hasFts) {
512
512
  _ftsIndexExists = true;
513
- console.log("[openclaw-memory-alibaba-local] text FTS index already exists");
513
+ console.debug("[openclaw-memory-alibaba-local] text FTS index already exists");
514
514
  return;
515
515
  }
516
516
  } catch {
@@ -519,13 +519,13 @@ export class MemoryDB {
519
519
 
520
520
  // Create FTS index (no minimum row requirement)
521
521
  try {
522
- console.log("[openclaw-memory-alibaba-local] creating FTS index on text column...");
522
+ console.debug("[openclaw-memory-alibaba-local] creating FTS index on text column...");
523
523
  const lancedb = await loadLanceDB();
524
524
  await this.table.createIndex("text", {
525
525
  config: (lancedb as any).Index.fts(),
526
526
  });
527
527
  _ftsIndexExists = true;
528
- console.log("[openclaw-memory-alibaba-local] text FTS index created successfully");
528
+ console.debug("[openclaw-memory-alibaba-local] text FTS index created successfully");
529
529
  } catch (e) {
530
530
  console.warn("[openclaw-memory-alibaba-local] createIndex(text FTS) failed:", String(e));
531
531
  _ftsIndexExists = false;
@@ -610,32 +610,38 @@ export class MemoryDB {
610
610
  });
611
611
  if (hasVecIdx) {
612
612
  _vectorIndexExists = true;
613
- console.log("[openclaw-memory-alibaba-local] vector ANN index already exists");
613
+ console.debug("[openclaw-memory-alibaba-local] vector ANN index already exists");
614
614
  return;
615
615
  }
616
616
  } catch {
617
617
  // listIndices not supported or failed; continue to try creating
618
618
  }
619
619
 
620
- // Check row count; IVF_PQ requires ≥256 training rows
621
- let rowCount: number;
620
+ // Check row count; IVF_PQ requires ≥256 training rows.
621
+ // Exclude full_context_* categories (zero-vector placeholders, no real embeddings).
622
+ let vectorRowCount: number;
622
623
  try {
623
- rowCount = await this.table.countRows();
624
+ const excludeCats = [FULL_CONTEXT_MEMORY, ...FULL_CONTEXT_SOURCE_CATEGORIES]
625
+ .map((c) => `'${sqlEscapeLiteral(String(c))}'`)
626
+ .join(", ");
627
+ const totalRows = await this.table.countRows();
628
+ const fullContextRows = await this.table.countRows(`category IN (${excludeCats})`);
629
+ vectorRowCount = totalRows - fullContextRows;
624
630
  } catch {
625
631
  return; // cannot determine; skip
626
632
  }
627
- if (rowCount < VECTOR_INDEX_MIN_ROWS) {
633
+ if (vectorRowCount < VECTOR_INDEX_MIN_ROWS) {
628
634
  _vectorIndexExists = false;
629
- console.log(
630
- `[openclaw-memory-alibaba-local] vector ANN index skipped: ${rowCount} rows < ${VECTOR_INDEX_MIN_ROWS} minimum`,
635
+ console.debug(
636
+ `[openclaw-memory-alibaba-local] vector ANN index skipped: ${vectorRowCount} vector rows < ${VECTOR_INDEX_MIN_ROWS} minimum`,
631
637
  );
632
638
  return;
633
639
  }
634
640
 
635
641
  // Create IVF_PQ index
636
642
  try {
637
- console.log(
638
- `[openclaw-memory-alibaba-local] creating IVF_PQ vector index (${rowCount} rows, dim=${this.vectorDim})...`,
643
+ console.debug(
644
+ `[openclaw-memory-alibaba-local] creating IVF_PQ vector index (${vectorRowCount} vector rows, dim=${this.vectorDim})...`,
639
645
  );
640
646
  const lancedb = await loadLanceDB();
641
647
  await this.table.createIndex("vector", {
@@ -1369,7 +1375,7 @@ export class MemoryDB {
1369
1375
  // 2. Count remaining; if over maxRows, trim oldest
1370
1376
  const remaining = await this.table!.countRows(base);
1371
1377
  if (remaining <= maxRows) {
1372
- console.log(`[openclaw-memory-alibaba-local] gcFullContext agent=${agentId} remaining=${remaining} (within limit)`);
1378
+ console.debug(`[openclaw-memory-alibaba-local] gcFullContext agent=${agentId} remaining=${remaining} (within limit)`);
1373
1379
  return;
1374
1380
  }
1375
1381
  const excess = remaining - maxRows;
@@ -1383,7 +1389,7 @@ export class MemoryDB {
1383
1389
  const cutoff = Number(oldest[excess - 1]!.createdAt);
1384
1390
  await this.table!.delete(`${base} AND createdAt <= ${Math.floor(cutoff)}`);
1385
1391
  }
1386
- console.log(`[openclaw-memory-alibaba-local] gcFullContext agent=${agentId} deleted ${excess} excess rows (was ${remaining}, cap ${maxRows})`);
1392
+ console.debug(`[openclaw-memory-alibaba-local] gcFullContext agent=${agentId} deleted ${excess} excess rows (was ${remaining}, cap ${maxRows})`);
1387
1393
  }
1388
1394
 
1389
1395
  /**
@@ -1435,7 +1441,7 @@ export class MemoryDB {
1435
1441
  const afterSoft = await this.table!.countRows(base);
1436
1442
  const softDeleted = count - afterSoft;
1437
1443
  if (softDeleted > 0) {
1438
- console.log(`[openclaw-memory-alibaba-local] gcWorldFact agent=${agentId} phase1: deleted ${softDeleted} old+low-importance rows (was ${count}, now ${afterSoft})`);
1444
+ console.debug(`[openclaw-memory-alibaba-local] gcWorldFact agent=${agentId} phase1: deleted ${softDeleted} old+low-importance rows (was ${count}, now ${afterSoft})`);
1439
1445
  }
1440
1446
  count = afterSoft;
1441
1447
  }
@@ -1452,7 +1458,7 @@ export class MemoryDB {
1452
1458
  const cutoff = Number(oldest[excess - 1]!.createdAt);
1453
1459
  await this.table!.delete(`${base} AND createdAt <= ${Math.floor(cutoff)}`);
1454
1460
  }
1455
- console.log(`[openclaw-memory-alibaba-local] gcWorldFact agent=${agentId} phase2: deleted ${excess} excess rows (was ${count}, cap ${hardMaxRows})`);
1461
+ console.debug(`[openclaw-memory-alibaba-local] gcWorldFact agent=${agentId} phase2: deleted ${excess} excess rows (was ${count}, cap ${hardMaxRows})`);
1456
1462
  }
1457
1463
  }
1458
1464
  }
package/index.ts CHANGED
@@ -190,7 +190,7 @@ function getThresholdForCategory(cfg: MemoryConfig, category: MemoryCategory): n
190
190
 
191
191
  /** 精简日志:仅记录 tag + prompt 字符数,不贴原文。 */
192
192
  function logLlmCall(tag: string, promptChars: number): void {
193
- console.log(`[openclaw-memory-alibaba-local] llm ${tag} prompt (${promptChars} chars)`);
193
+ console.debug(`[openclaw-memory-alibaba-local] llm ${tag} prompt (${promptChars} chars)`);
194
194
  }
195
195
 
196
196
  /** 记录 userImageExtraction 结果统计。 */
@@ -198,12 +198,12 @@ function logUserImageResult(total: number, actions: ReadonlyArray<{ action: stri
198
198
  const counts: Record<string, number> = {};
199
199
  for (const a of actions) counts[a.action] = (counts[a.action] ?? 0) + 1;
200
200
  const parts = Object.entries(counts).map(([k, v]) => `${v} ${k}`).join(", ");
201
- console.log(`[openclaw-memory-alibaba-local] userImageExtraction result: ${total} items → ${parts}`);
201
+ console.debug(`[openclaw-memory-alibaba-local] userImageExtraction result: ${total} items → ${parts}`);
202
202
  }
203
203
 
204
204
  /** 记忆衰减为纯公式,不向模型发提示词;仍打日志避免与「冲突检测 LLM」混淆。 */
205
205
  function logMemoryDecayNoLlm(phase: string, detail: string): void {
206
- console.log(`[openclaw-memory-alibaba-local] memoryDecay ${phase} (no LLM; formula-only) ${detail}`);
206
+ console.debug(`[openclaw-memory-alibaba-local] memoryDecay ${phase} (no LLM; formula-only) ${detail}`);
207
207
  }
208
208
 
209
209
  // ---- Embedding-based clustering utilities ----
@@ -556,7 +556,7 @@ async function extractUserMemoriesWithLLM(
556
556
 
557
557
  const raw = completion?.choices[0]?.message?.content?.trim() ?? "";
558
558
  const items = parseExtractions(raw);
559
- console.log(`[openclaw-memory-alibaba-local] memoryExtraction extracted ${items.length} items`);
559
+ console.debug(`[openclaw-memory-alibaba-local] memoryExtraction extracted ${items.length} items`);
560
560
  return items;
561
561
  }
562
562
 
@@ -1101,7 +1101,7 @@ async function runAgentEndCapture(
1101
1101
  let { roleCounts: saved, lastMessagesLength } = resolveRoleCountsForSession(entry, messages);
1102
1102
 
1103
1103
  if (messages.length < lastMessagesLength) {
1104
- console.log("[openclaw-memory-alibaba-local] transcript shrank; reset per-role capture cursors");
1104
+ console.debug("[openclaw-memory-alibaba-local] transcript shrank; reset per-role capture cursors");
1105
1105
  saved = {};
1106
1106
  }
1107
1107
 
@@ -1118,7 +1118,7 @@ async function runAgentEndCapture(
1118
1118
  }
1119
1119
  map[key] = { version: 2, roleCounts: { ...running }, lastMessagesLength: messages.length };
1120
1120
  saveAgentEndCursorMap(lancedbDir, map);
1121
- console.log(
1121
+ console.debug(
1122
1122
  `[openclaw-memory-alibaba-local] agent_end cursor-only advance (non-user trigger) messages=${messages.length}`,
1123
1123
  );
1124
1124
  return;
@@ -1180,7 +1180,7 @@ async function runAgentEndCapture(
1180
1180
  const batchId = randomUUID();
1181
1181
  const sid = sessionKey;
1182
1182
 
1183
- console.log(`[openclaw-memory-alibaba-local] agentEndCapture fullRows=${fullRows.length} userTexts=${userRawTexts.length} uaLines=${uaLines.length}`);
1183
+ console.debug(`[openclaw-memory-alibaba-local] agentEndCapture fullRows=${fullRows.length} userTexts=${userRawTexts.length} uaLines=${uaLines.length}`);
1184
1184
 
1185
1185
  if (fullRows.length > 0) {
1186
1186
  await db.storeMany(
@@ -1328,13 +1328,13 @@ async function captureUserMemoryFromInboundTexts(
1328
1328
  }
1329
1329
  }
1330
1330
  const existingCandidates = [...candidateMap.values()].sort((a, b) => b.score - a.score);
1331
- console.log(`[openclaw-memory-alibaba-local] worldImageExtraction recall: ${embeddingResults.length} items × ${PER_ITEM_RECALL} = raw ${embeddingResults.length * PER_ITEM_RECALL}, deduped ${existingCandidates.length}, minScore=${recallMinScore}`);
1331
+ console.debug(`[openclaw-memory-alibaba-local] worldImageExtraction recall: ${embeddingResults.length} items × ${PER_ITEM_RECALL} = raw ${embeddingResults.length * PER_ITEM_RECALL}, deduped ${existingCandidates.length}, minScore=${recallMinScore}`);
1332
1332
  if (existingCandidates.length > 0) {
1333
- console.log(`[openclaw-memory-alibaba-local] worldImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1333
+ console.debug(`[openclaw-memory-alibaba-local] worldImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1334
1334
  }
1335
1335
 
1336
1336
  // 3. LLM CRUD decision
1337
- console.log(`[openclaw-memory-alibaba-local] worldImageExtraction input: ${eventItems.length} event items, ${existingCandidates.length} existing candidates`);
1337
+ console.debug(`[openclaw-memory-alibaba-local] worldImageExtraction input: ${eventItems.length} event items, ${existingCandidates.length} existing candidates`);
1338
1338
  const worldActions = await extractWorldImageWithLLM(
1339
1339
  cfg.llm,
1340
1340
  embeddingResults.map((r) => r.item),
@@ -1432,16 +1432,16 @@ async function captureUserMemoryFromInboundTexts(
1432
1432
  // 2. Recall top-10 similar existing memories for ALL new extractions (agentId global, USER_MEMORY scope)
1433
1433
  const allVectors = embeddingResults.flatMap((r) => r.vectors);
1434
1434
  const recallMinScore = Math.max(0.5, cfg.similarityThresholdUserMemory - 0.35);
1435
- console.log(`[openclaw-memory-alibaba-local] userImageExtraction recall: ${allVectors.length} query vectors, minScore=${recallMinScore}`);
1435
+ console.debug(`[openclaw-memory-alibaba-local] userImageExtraction recall: ${allVectors.length} query vectors, minScore=${recallMinScore}`);
1436
1436
  const existingCandidates = allVectors.length > 0
1437
1437
  ? await db.searchMerged(agentId, allVectors, 10, recallMinScore, [...USER_MEMORY_CATEGORIES])
1438
1438
  : [];
1439
1439
  if (existingCandidates.length > 0) {
1440
- console.log(`[openclaw-memory-alibaba-local] userImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1440
+ console.debug(`[openclaw-memory-alibaba-local] userImageExtraction recall found ${existingCandidates.length} candidates: ${existingCandidates.map((c) => `[${c.score.toFixed(3)}] ${c.entry.text.slice(0, 60)}`).join(" | ")}`);
1441
1441
  }
1442
1442
 
1443
1443
  // 3. Call user image extraction LLM
1444
- console.log(`[openclaw-memory-alibaba-local] userImageExtraction input: ${userItems.length} user items (${eventItems.length} event items bypassed), ${existingCandidates.length} existing candidates`);
1444
+ console.debug(`[openclaw-memory-alibaba-local] userImageExtraction input: ${userItems.length} user items (${eventItems.length} event items bypassed), ${existingCandidates.length} existing candidates`);
1445
1445
  const userImageActions = await extractUserImageWithLLM(
1446
1446
  cfg.llm,
1447
1447
  embeddingResults.map((r) => r.item),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-memory-alibaba-local",
3
- "version": "1.0.11",
3
+ "version": "1.0.12",
4
4
  "description": "OpenClaw memory plugin: local LanceDB + DashScope-compatible embeddings",
5
5
  "type": "module",
6
6
  "engines": {