@scotthuang/engram 0.3.27 → 0.4.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/dist/bm25.js +8 -7
- package/dist/bm25.js.map +1 -1
- package/dist/config.d.ts +2 -0
- package/dist/config.js +9 -6
- package/dist/config.js.map +1 -1
- package/dist/index.js +73 -61
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +32 -0
- package/dist/logger.js +83 -0
- package/dist/logger.js.map +1 -0
- package/dist/profile.js +5 -4
- package/dist/profile.js.map +1 -1
- package/dist/recall.d.ts +6 -0
- package/dist/recall.js +62 -41
- package/dist/recall.js.map +1 -1
- package/dist/settle.d.ts +12 -3
- package/dist/settle.js +78 -44
- package/dist/settle.js.map +1 -1
- package/dist/vector.d.ts +21 -1
- package/dist/vector.js +129 -20
- package/dist/vector.js.map +1 -1
- package/openclaw.plugin.json +4 -0
- package/package.json +1 -1
package/dist/vector.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Vector Store - 直接连接 LanceDB + OpenAI-compatible embedding API
|
|
3
|
+
*
|
|
4
|
+
* v0.4: 新增 importance / accessCount / lastAccessed 字段
|
|
5
|
+
* 支持记忆强化 (reinforce) 和遗忘清理 (prune)
|
|
3
6
|
*/
|
|
4
7
|
import * as lancedb from "@lancedb/lancedb";
|
|
8
|
+
import { logger } from "./logger.js";
|
|
5
9
|
import OpenAI from "openai";
|
|
6
10
|
export class VectorStore {
|
|
7
11
|
db;
|
|
@@ -12,10 +16,10 @@ export class VectorStore {
|
|
|
12
16
|
constructor(config) {
|
|
13
17
|
this.config = config;
|
|
14
18
|
this.instanceId = Math.random().toString(36).slice(2, 8);
|
|
15
|
-
|
|
19
|
+
logger.info(`[engram:vector] VectorStore created, instanceId=${this.instanceId}`);
|
|
16
20
|
}
|
|
17
21
|
async startup() {
|
|
18
|
-
|
|
22
|
+
logger.info(`[engram:vector] startup called, instanceId=${this.instanceId}`);
|
|
19
23
|
this.db = await lancedb.connect(this.config.dbDir);
|
|
20
24
|
this.client = new OpenAI({
|
|
21
25
|
apiKey: this.config.embedding.apiKey,
|
|
@@ -23,13 +27,13 @@ export class VectorStore {
|
|
|
23
27
|
});
|
|
24
28
|
const tableName = this.config.tableName || "memories";
|
|
25
29
|
const tables = await this.db.tableNames();
|
|
26
|
-
|
|
30
|
+
logger.info(`[engram:vector] startup: available tables = [${tables.join(", ")}]`);
|
|
27
31
|
if (tables.includes(tableName)) {
|
|
28
32
|
this.table = await this.db.openTable(tableName);
|
|
29
|
-
|
|
33
|
+
logger.info(`[engram] Vector store connected: ${tableName} (this.table set: ${!!this.table})`);
|
|
30
34
|
}
|
|
31
35
|
else {
|
|
32
|
-
|
|
36
|
+
logger.info(`[engram] Vector store: table "${tableName}" not found, will create on first write`);
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
/** 诊断方法:检查 table 是否初始化 */
|
|
@@ -49,28 +53,32 @@ export class VectorStore {
|
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* 向量搜索
|
|
56
|
+
* 返回结果中包含 id,用于后续 reinforce
|
|
52
57
|
*/
|
|
53
58
|
async search(query, limit = 5) {
|
|
54
|
-
|
|
59
|
+
logger.info(`[engram:vector] search called: instanceId=${this.instanceId}, this.table=${!!this.table}, this.db=${!!this.db}`);
|
|
55
60
|
if (!this.table) {
|
|
56
|
-
|
|
61
|
+
logger.info(`[engram:vector] search skipped: table not initialized`);
|
|
57
62
|
return [];
|
|
58
63
|
}
|
|
59
64
|
try {
|
|
60
|
-
|
|
65
|
+
logger.info(`[engram:vector] search query: "${query.slice(0, 100)}" (limit=${limit})`);
|
|
61
66
|
const queryVector = await this.embed(query);
|
|
62
|
-
|
|
67
|
+
logger.info(`[engram:vector] embedding dimensions: ${queryVector.length}`);
|
|
63
68
|
const results = await this.table
|
|
64
69
|
.vectorSearch(queryVector)
|
|
65
70
|
.limit(limit)
|
|
66
|
-
.select(["text", "category", "createdAt", "_distance"])
|
|
71
|
+
.select(["id", "text", "category", "createdAt", "importance", "accessCount", "_distance"])
|
|
67
72
|
.toArray();
|
|
68
|
-
|
|
73
|
+
logger.info(`[engram:vector] raw results: ${results.length}`);
|
|
69
74
|
const scored = results.map((row, i) => {
|
|
70
75
|
const distance = row._distance ?? 1;
|
|
71
76
|
const score = 1 / (1 + distance);
|
|
72
|
-
|
|
77
|
+
const imp = row.importance ?? 0.5;
|
|
78
|
+
const ac = row.accessCount ?? 0;
|
|
79
|
+
logger.info(`[engram:vector] #${i} distance=${distance.toFixed(6)} score=${score.toFixed(4)} importance=${imp.toFixed(2)} accessCount=${ac} category=${row.category ?? "-"} text="${row.text.slice(0, 80)}"`);
|
|
73
80
|
return {
|
|
81
|
+
id: row.id || undefined,
|
|
74
82
|
text: row.text,
|
|
75
83
|
source: "vector",
|
|
76
84
|
score,
|
|
@@ -81,15 +89,16 @@ export class VectorStore {
|
|
|
81
89
|
return scored;
|
|
82
90
|
}
|
|
83
91
|
catch (err) {
|
|
84
|
-
|
|
92
|
+
logger.error(`[engram] Vector search failed: ${err}`);
|
|
85
93
|
return [];
|
|
86
94
|
}
|
|
87
95
|
}
|
|
88
96
|
/**
|
|
89
97
|
* 存储一条记忆(含 duplicate 检测)
|
|
98
|
+
* @param importance LLM 评分的重要度 0-1,默认 0.5
|
|
90
99
|
* @returns "created" | "duplicate"
|
|
91
100
|
*/
|
|
92
|
-
async store(text, category) {
|
|
101
|
+
async store(text, category, importance = 0.5) {
|
|
93
102
|
const vector = await this.embed(text);
|
|
94
103
|
// Duplicate detection: check for near-identical existing entries
|
|
95
104
|
if (this.table) {
|
|
@@ -103,7 +112,7 @@ export class VectorStore {
|
|
|
103
112
|
const dist = existing[0]._distance;
|
|
104
113
|
const sim = 1 / (1 + dist);
|
|
105
114
|
if (sim > 0.95) {
|
|
106
|
-
|
|
115
|
+
logger.info(`[engram] Duplicate detected (sim=${sim.toFixed(4)}): "${existing[0].text?.slice(0, 60)}"`);
|
|
107
116
|
return "duplicate";
|
|
108
117
|
}
|
|
109
118
|
}
|
|
@@ -115,16 +124,116 @@ export class VectorStore {
|
|
|
115
124
|
const now = Math.floor(Date.now() / 1000);
|
|
116
125
|
const id = `engram-${now}-${Math.random().toString(36).slice(2, 8)}`;
|
|
117
126
|
const tableName = this.config.tableName || "memories";
|
|
127
|
+
// 限制 importance 在 [0, 1]
|
|
128
|
+
const imp = Math.max(0, Math.min(1, importance));
|
|
129
|
+
const record = {
|
|
130
|
+
id,
|
|
131
|
+
text,
|
|
132
|
+
vector,
|
|
133
|
+
category,
|
|
134
|
+
createdAt: now,
|
|
135
|
+
importance: imp,
|
|
136
|
+
accessCount: 0,
|
|
137
|
+
lastAccessed: 0,
|
|
138
|
+
};
|
|
118
139
|
if (!this.table) {
|
|
119
|
-
this.table = await this.db.createTable(tableName, [
|
|
120
|
-
|
|
121
|
-
]);
|
|
122
|
-
console.log(`[engram] Vector store: created table "${tableName}" with first entry`);
|
|
140
|
+
this.table = await this.db.createTable(tableName, [record]);
|
|
141
|
+
logger.info(`[engram] Vector store: created table "${tableName}" with first entry (importance=${imp.toFixed(2)})`);
|
|
123
142
|
}
|
|
124
143
|
else {
|
|
125
|
-
await this.table.add([
|
|
144
|
+
await this.table.add([record]);
|
|
126
145
|
}
|
|
146
|
+
logger.info(`[engram] Stored memory: [${category}] importance=${imp.toFixed(2)} "${text.slice(0, 60)}"`);
|
|
127
147
|
return "created";
|
|
128
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* 强化记忆:召回命中时调用,增加 accessCount 并更新 lastAccessed
|
|
151
|
+
* fire-and-forget,不影响召回速度
|
|
152
|
+
*/
|
|
153
|
+
async reinforce(ids) {
|
|
154
|
+
if (!this.table || ids.length === 0)
|
|
155
|
+
return;
|
|
156
|
+
const now = Math.floor(Date.now() / 1000);
|
|
157
|
+
try {
|
|
158
|
+
for (const id of ids) {
|
|
159
|
+
// LanceDB 不支持原子 increment,需要先查再改
|
|
160
|
+
const rows = await this.table
|
|
161
|
+
.search([]) // dummy search, we'll use filter
|
|
162
|
+
.where(`id = '${id}'`)
|
|
163
|
+
.limit(1)
|
|
164
|
+
.select(["id", "accessCount"])
|
|
165
|
+
.toArray()
|
|
166
|
+
.catch(() => []);
|
|
167
|
+
if (rows.length > 0) {
|
|
168
|
+
const oldCount = rows[0].accessCount ?? 0;
|
|
169
|
+
await this.table.update({
|
|
170
|
+
where: `id = '${id}'`,
|
|
171
|
+
values: { accessCount: oldCount + 1, lastAccessed: now },
|
|
172
|
+
});
|
|
173
|
+
logger.info(`[engram:vector] Reinforced memory ${id}: accessCount ${oldCount} → ${oldCount + 1}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
catch (err) {
|
|
178
|
+
// reinforce 是增强性功能,失败不影响主流程
|
|
179
|
+
logger.error(`[engram:vector] reinforce failed (non-critical): ${err}`);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* 遗忘:清理 effective_importance 低于阈值的长期记忆
|
|
184
|
+
* effective = importance × decay(age) × log2(1 + accessCount)
|
|
185
|
+
* @param threshold 低于此值的记忆将被删除,默认 0.05
|
|
186
|
+
* @param maxPrune 单次最多删除条数,默认 50
|
|
187
|
+
* @returns 删除的条数
|
|
188
|
+
*/
|
|
189
|
+
async prune(threshold = 0.05, maxPrune = 50) {
|
|
190
|
+
if (!this.table)
|
|
191
|
+
return 0;
|
|
192
|
+
const halfLifeDays = this.config.halfLifeDays ?? 30;
|
|
193
|
+
const now = Math.floor(Date.now() / 1000);
|
|
194
|
+
try {
|
|
195
|
+
// 全量扫描(LanceDB 没有 aggregate,需要逐条判断)
|
|
196
|
+
const allRows = await this.table
|
|
197
|
+
.search([])
|
|
198
|
+
.select(["id", "text", "importance", "accessCount", "createdAt"])
|
|
199
|
+
.limit(10000) // 安全上限
|
|
200
|
+
.toArray()
|
|
201
|
+
.catch(() => []);
|
|
202
|
+
if (allRows.length === 0)
|
|
203
|
+
return 0;
|
|
204
|
+
const toDelete = [];
|
|
205
|
+
for (const row of allRows) {
|
|
206
|
+
const imp = row.importance ?? 0.5; // 兼容旧数据
|
|
207
|
+
const ac = row.accessCount ?? 0;
|
|
208
|
+
const createdAt = row.createdAt ?? now;
|
|
209
|
+
const ageDays = Math.max(0, (now - createdAt) / 86400);
|
|
210
|
+
// 遗忘公式
|
|
211
|
+
const decay = Math.exp(-Math.log(2) / halfLifeDays * ageDays);
|
|
212
|
+
const accessBoost = Math.log2(1 + ac + 1); // +1 保底:从没被访问的 = log2(2) = 1
|
|
213
|
+
const effective = imp * decay * accessBoost;
|
|
214
|
+
if (effective < threshold) {
|
|
215
|
+
toDelete.push({ id: row.id, effective, text: row.text.slice(0, 60) });
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
// 按 effective 升序排列,先删最不重要的
|
|
219
|
+
toDelete.sort((a, b) => a.effective - b.effective);
|
|
220
|
+
const pruneList = toDelete.slice(0, maxPrune);
|
|
221
|
+
if (pruneList.length === 0) {
|
|
222
|
+
logger.info(`[engram:vector] Prune: no stale memories found (${allRows.length} total, threshold=${threshold})`);
|
|
223
|
+
return 0;
|
|
224
|
+
}
|
|
225
|
+
logger.info(`[engram:vector] Prune: ${pruneList.length} stale memories to delete (out of ${toDelete.length} below threshold, ${allRows.length} total)`);
|
|
226
|
+
for (const item of pruneList) {
|
|
227
|
+
logger.info(`[engram:vector] Pruning: effective=${item.effective.toFixed(4)} "${item.text}"`);
|
|
228
|
+
await this.table.delete(`id = '${item.id}'`);
|
|
229
|
+
}
|
|
230
|
+
logger.info(`[engram:vector] Prune complete: deleted ${pruneList.length} memories`);
|
|
231
|
+
return pruneList.length;
|
|
232
|
+
}
|
|
233
|
+
catch (err) {
|
|
234
|
+
logger.error(`[engram:vector] Prune failed: ${err}`);
|
|
235
|
+
return 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
129
238
|
}
|
|
130
239
|
//# sourceMappingURL=vector.js.map
|
package/dist/vector.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAoB5B,MAAM,OAAO,WAAW;IACd,EAAE,CAAsB;IACxB,MAAM,CAAU;IAChB,MAAM,CAAoB;IAC1B,KAAK,CAAiB;IACtB,UAAU,CAAS;IAE3B,YAAY,MAAyB;QACnC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACzD,MAAM,CAAC,IAAI,CAAC,mDAAmD,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,CAAC,IAAI,CAAC,8CAA8C,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC7E,IAAI,CAAC,EAAE,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnD,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM;YACpC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,OAAO;SACvC,CAAC,CAAC;QAEH,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI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,MAAM,CAAC,IAAI,CAAC,0BAA0B,SAAS,CAAC,MAAM,qCAAqC,QAAQ,CAAC,MAAM,qBAAqB,OAAO,CAAC,MAAM,SAAS,CAAC,CAAC;YACxJ,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;gBAC7B,MAAM,CAAC,IAAI,CAAC,wCAAwC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;gBAChG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YAC/C,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,2CAA2C,SAAS,CAAC,MAAM,WAAW,CAAC,CAAC;YACpF,OAAO,SAAS,CAAC,MAAM,CAAC;QAC1B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,CAAC,KAAK,CAAC,iCAAiC,GAAG,EAAE,CAAC,CAAC;YACrD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;CACF"}
|
package/openclaw.plugin.json
CHANGED
|
@@ -97,6 +97,10 @@
|
|
|
97
97
|
"type": "string",
|
|
98
98
|
"description": "LanceDB 数据库目录(默认 workspace/memory-engram/lancedb)"
|
|
99
99
|
},
|
|
100
|
+
"logDir": {
|
|
101
|
+
"type": "string",
|
|
102
|
+
"description": "日志父目录路径,传入后在此目录下创建 engram/ 子目录按天写日志文件(YYYY-MM-DD.log)。不传则仅 console 输出"
|
|
103
|
+
},
|
|
100
104
|
"queryRewrite": {
|
|
101
105
|
"type": "object",
|
|
102
106
|
"description": "查询重写配置(通过云 LLM 对召回查询进行改写/分解)",
|