@openclaw/memory-lancedb 2026.9.1-beta.1 → 2026.9.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.
- package/dist/dist-CtM4zODR.js +7624 -0
- package/dist/doctor-contract-api.js +5 -3
- package/dist/embeddings.js +13 -15
- package/dist/index.js +138 -179
- package/dist/lancedb-runtime.js +2 -1
- package/dist/memory-cli.js +1 -2
- package/dist/memory-policy.js +51 -18
- package/dist/rolldown-runtime-BMI-E3GI.js +44 -0
- package/package.json +15 -6
package/dist/memory-policy.js
CHANGED
|
@@ -2,6 +2,7 @@ import { looksLikeEnvelopeSludge } from "./memory-capture-sanitization.js";
|
|
|
2
2
|
import { DEFAULT_RECALL_MAX_CHARS } from "./config.js";
|
|
3
3
|
import { asOptionalRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
4
4
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
5
|
+
import { createHash } from "node:crypto";
|
|
5
6
|
//#region extensions/memory-lancedb/memory-policy.ts
|
|
6
7
|
function extractUserTextContent(message) {
|
|
7
8
|
const msgObj = asOptionalRecord(message);
|
|
@@ -30,26 +31,58 @@ function normalizeRecallQuery(text, maxChars = DEFAULT_RECALL_MAX_CHARS) {
|
|
|
30
31
|
function normalizeMaxChars(value, fallback) {
|
|
31
32
|
return typeof value === "number" && Number.isFinite(value) ? Math.max(0, Math.floor(value)) : fallback;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
function captureFingerprint(text) {
|
|
35
|
+
return createHash("sha256").update(text).digest("hex");
|
|
36
|
+
}
|
|
37
|
+
function autoCaptureMessageFingerprint(message) {
|
|
38
|
+
const identity = { ...message };
|
|
39
|
+
if (message.role === "assistant") {
|
|
40
|
+
delete identity.usage;
|
|
41
|
+
delete identity.providerReplay;
|
|
42
|
+
if (Array.isArray(message.content)) identity.content = message.content.map((block) => {
|
|
43
|
+
const record = asOptionalRecord(block);
|
|
44
|
+
if (record?.type !== "thinking" && record?.type !== "redacted_thinking") return block;
|
|
45
|
+
return Object.fromEntries(Object.entries(record).filter(([key]) => ![
|
|
46
|
+
"thinkingSignature",
|
|
47
|
+
"signature",
|
|
48
|
+
"thought_signature"
|
|
49
|
+
].includes(key) && (record.type !== "redacted_thinking" || key !== "data")));
|
|
40
50
|
});
|
|
41
|
-
} catch {
|
|
42
|
-
return `${String(msgObj.role)}:${String(msgObj.content)}`;
|
|
43
51
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
return captureFingerprint(JSON.stringify(identity, (_key, value) => {
|
|
53
|
+
const record = asOptionalRecord(value);
|
|
54
|
+
return record ? Object.fromEntries(Object.keys(record).toSorted().map((key) => [key, record[key]])) : value;
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
function prepareAutoCaptureMessages(messages, previous) {
|
|
58
|
+
const progress = messages.map((message, index) => {
|
|
59
|
+
const msgObj = asOptionalRecord(message);
|
|
60
|
+
if (!msgObj || msgObj.excludeFromContext === true || index === 0 && msgObj.role === "compactionSummary") return;
|
|
61
|
+
return {
|
|
62
|
+
fingerprint: autoCaptureMessageFingerprint(msgObj),
|
|
63
|
+
visited: false
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
const current = progress.filter((entry) => entry !== void 0);
|
|
67
|
+
if (current.length === 0) return progress;
|
|
68
|
+
const prefixLengths = [0];
|
|
69
|
+
const advance = (matchedLength, fingerprint) => {
|
|
70
|
+
let length = matchedLength;
|
|
71
|
+
while (length > 0 && fingerprint !== current[length]?.fingerprint) length = prefixLengths[length - 1];
|
|
72
|
+
return fingerprint === current[length]?.fingerprint ? length + 1 : 0;
|
|
73
|
+
};
|
|
74
|
+
for (let index = 1; index < current.length; index++) prefixLengths[index] = advance(prefixLengths[index - 1], current[index].fingerprint);
|
|
75
|
+
let retainedLength = 0;
|
|
76
|
+
let retainedStart = 0;
|
|
77
|
+
for (let index = 0, length = 0; index < previous.length; index++) {
|
|
78
|
+
length = advance(length, previous[index].fingerprint);
|
|
79
|
+
if (length >= retainedLength) {
|
|
80
|
+
retainedLength = length;
|
|
81
|
+
retainedStart = index - length + 1;
|
|
82
|
+
}
|
|
50
83
|
}
|
|
51
|
-
|
|
52
|
-
return
|
|
84
|
+
for (let index = 0; index < retainedLength; index++) current[index].visited = previous[retainedStart + index].visited;
|
|
85
|
+
return progress;
|
|
53
86
|
}
|
|
54
87
|
const DUPLICATE_SEARCH_LIMIT = 5;
|
|
55
88
|
const MEMORY_TRIGGERS = [
|
|
@@ -154,4 +187,4 @@ function detectCategory(text) {
|
|
|
154
187
|
return "other";
|
|
155
188
|
}
|
|
156
189
|
//#endregion
|
|
157
|
-
export { cleanMemorySearchResults, detectCategory, escapeMemoryForPrompt, extractLatestUserText, extractUserTextContent, findCleanDuplicateMemory, formatRecalledMemoryForModel, formatRelevantMemoriesContext, looksLikePromptInjection,
|
|
190
|
+
export { captureFingerprint, cleanMemorySearchResults, detectCategory, escapeMemoryForPrompt, extractLatestUserText, extractUserTextContent, findCleanDuplicateMemory, formatRecalledMemoryForModel, formatRelevantMemoriesContext, looksLikePromptInjection, normalizeRecallQuery, prepareAutoCaptureMessages, shouldCapture };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __esmMin = (fn, res, err) => () => {
|
|
10
|
+
if (err) throw err[0];
|
|
11
|
+
try {
|
|
12
|
+
return fn && (res = fn(fn = 0)), res;
|
|
13
|
+
} catch (e) {
|
|
14
|
+
throw err = [e], e;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
18
|
+
var __exportAll = (all, no_symbols) => {
|
|
19
|
+
let target = {};
|
|
20
|
+
for (var name in all) __defProp(target, name, {
|
|
21
|
+
get: all[name],
|
|
22
|
+
enumerable: true
|
|
23
|
+
});
|
|
24
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
25
|
+
return target;
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
29
|
+
key = keys[i];
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
31
|
+
get: ((k) => from[k]).bind(null, key),
|
|
32
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
37
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
38
|
+
value: mod,
|
|
39
|
+
enumerable: true
|
|
40
|
+
}) : target, mod));
|
|
41
|
+
var __toCommonJS = (mod) => __hasOwnProp.call(mod, "module.exports") ? mod["module.exports"] : __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
42
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
43
|
+
//#endregion
|
|
44
|
+
export { __toCommonJS as a, __require as i, __esmMin as n, __toESM as o, __exportAll as r, __commonJSMin as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/memory-lancedb",
|
|
3
|
-
"version": "2026.9.1
|
|
3
|
+
"version": "2026.9.1",
|
|
4
4
|
"description": "OpenClaw LanceDB-backed long-term memory plugin with auto-recall, auto-capture, and vector search.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,14 +8,23 @@
|
|
|
8
8
|
},
|
|
9
9
|
"type": "module",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@lancedb/lancedb": "0.37.1",
|
|
12
11
|
"apache-arrow": "18.1.0",
|
|
13
12
|
"openai": "7.5.0",
|
|
14
|
-
"typebox": "1.3.
|
|
13
|
+
"typebox": "1.3.17"
|
|
15
14
|
},
|
|
16
15
|
"devDependencies": {
|
|
16
|
+
"@lancedb/lancedb": "0.37.1",
|
|
17
17
|
"@openclaw/plugin-sdk": "workspace:*"
|
|
18
18
|
},
|
|
19
|
+
"optionalDependencies": {
|
|
20
|
+
"@lancedb/lancedb-darwin-arm64": "0.37.1",
|
|
21
|
+
"@lancedb/lancedb-linux-arm64-gnu": "0.37.1",
|
|
22
|
+
"@lancedb/lancedb-linux-arm64-musl": "0.37.1",
|
|
23
|
+
"@lancedb/lancedb-linux-x64-gnu": "0.37.1",
|
|
24
|
+
"@lancedb/lancedb-linux-x64-musl": "0.37.1",
|
|
25
|
+
"@lancedb/lancedb-win32-arm64-msvc": "0.37.1",
|
|
26
|
+
"@lancedb/lancedb-win32-x64-msvc": "0.37.1"
|
|
27
|
+
},
|
|
19
28
|
"openclaw": {
|
|
20
29
|
"extensions": [
|
|
21
30
|
"./index.ts"
|
|
@@ -26,10 +35,10 @@
|
|
|
26
35
|
"minHostVersion": ">=2026.5.31"
|
|
27
36
|
},
|
|
28
37
|
"compat": {
|
|
29
|
-
"pluginApi": ">=2026.9.1
|
|
38
|
+
"pluginApi": ">=2026.9.1"
|
|
30
39
|
},
|
|
31
40
|
"build": {
|
|
32
|
-
"openclawVersion": "2026.9.1
|
|
41
|
+
"openclawVersion": "2026.9.1"
|
|
33
42
|
},
|
|
34
43
|
"release": {
|
|
35
44
|
"bundleRuntimeDependencies": false,
|
|
@@ -46,7 +55,7 @@
|
|
|
46
55
|
"README.md"
|
|
47
56
|
],
|
|
48
57
|
"peerDependencies": {
|
|
49
|
-
"openclaw": ">=2026.9.1
|
|
58
|
+
"openclaw": ">=2026.9.1"
|
|
50
59
|
},
|
|
51
60
|
"peerDependenciesMeta": {
|
|
52
61
|
"openclaw": {
|