@openclaw/memory-lancedb 2026.7.2-beta.2 → 2026.7.2-beta.4
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/index.js +76 -10
- package/npm-shrinkwrap.json +10 -10
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { MESSAGE_TOOL_DELIVERY_HINTS } from "openclaw/plugin-sdk/message-tool-de
|
|
|
11
11
|
import { parseStrictPositiveInteger, resolveTimerTimeoutMs } from "openclaw/plugin-sdk/number-runtime";
|
|
12
12
|
import { readFiniteNumberParam, readPositiveIntegerParam } from "openclaw/plugin-sdk/param-readers";
|
|
13
13
|
import { resolveLivePluginConfigObject } from "openclaw/plugin-sdk/plugin-config-runtime";
|
|
14
|
-
import { normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
14
|
+
import { isIncognitoSessionKey, normalizeAgentId } from "openclaw/plugin-sdk/routing";
|
|
15
15
|
import { ensureGlobalUndiciEnvProxyDispatcher } from "openclaw/plugin-sdk/runtime-env";
|
|
16
16
|
import { asOptionalRecord, normalizeLowercaseStringOrEmpty } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
17
17
|
import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
@@ -137,21 +137,73 @@ var OpenAiCompatibleEmbeddings = class {
|
|
|
137
137
|
}));
|
|
138
138
|
}
|
|
139
139
|
async embed(text, options) {
|
|
140
|
+
const dimensions = this.dimensions;
|
|
141
|
+
const startedAtMs = options?.timeoutMs && Number.isFinite(options.timeoutMs) ? Date.now() : null;
|
|
142
|
+
try {
|
|
143
|
+
return normalizeEmbeddingVector((await this.postEmbedding(text, {
|
|
144
|
+
includeDimensions: true,
|
|
145
|
+
options
|
|
146
|
+
})).data?.[0]?.embedding);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
if (typeof dimensions !== "number" || !isEmbeddingDimensionsRejectedError(error)) throw error;
|
|
149
|
+
}
|
|
150
|
+
const fallbackOptions = startedAtMs === null || options?.timeoutMs === void 0 ? options : { timeoutMs: Math.max(1, options.timeoutMs - (Date.now() - startedAtMs)) };
|
|
151
|
+
return truncateEmbeddingVector(normalizeEmbeddingVector((await this.postEmbedding(text, {
|
|
152
|
+
includeDimensions: false,
|
|
153
|
+
options: fallbackOptions
|
|
154
|
+
})).data?.[0]?.embedding), dimensions, this.model);
|
|
155
|
+
}
|
|
156
|
+
async postEmbedding(text, request) {
|
|
140
157
|
const params = {
|
|
141
158
|
model: this.model,
|
|
142
|
-
input: text
|
|
159
|
+
input: text,
|
|
160
|
+
...request.includeDimensions && typeof this.dimensions === "number" ? { dimensions: this.dimensions } : {}
|
|
143
161
|
};
|
|
144
|
-
if (this.dimensions) params.dimensions = this.dimensions;
|
|
145
162
|
ensureGlobalUndiciEnvProxyDispatcher();
|
|
146
|
-
return
|
|
163
|
+
return await (await this.clientPromise).post("/embeddings", {
|
|
147
164
|
body: params,
|
|
148
|
-
...options?.timeoutMs ? {
|
|
149
|
-
timeout: options.timeoutMs,
|
|
165
|
+
...request.options?.timeoutMs ? {
|
|
166
|
+
timeout: request.options.timeoutMs,
|
|
150
167
|
maxRetries: 0
|
|
151
168
|
} : {}
|
|
152
|
-
})
|
|
169
|
+
});
|
|
153
170
|
}
|
|
154
171
|
};
|
|
172
|
+
function isEmbeddingDimensionsRejectedError(error) {
|
|
173
|
+
const record = asOptionalRecord(error);
|
|
174
|
+
if (record?.status !== 400 && record?.status !== 422) return false;
|
|
175
|
+
const details = stringifyEmbeddingApiError(error).toLowerCase();
|
|
176
|
+
return /\bdimensions\b/.test(details) && isUnsupportedEmbeddingFieldError(details);
|
|
177
|
+
}
|
|
178
|
+
function isUnsupportedEmbeddingFieldError(details) {
|
|
179
|
+
if (/\b(?:parameter|field|argument)[_ -]value\b/.test(details)) return false;
|
|
180
|
+
return /\bextra[_ -]forbidden\b/.test(details) || /\bextra inputs? (?:are )?not permitted\b/.test(details) || /\bextra fields? (?:are )?not permitted\b/.test(details) || /\b(?:unknown|unrecognized|unexpected|unsupported)[_ -](?:request[_ -])?(?:parameter|field|argument)\b/.test(details);
|
|
181
|
+
}
|
|
182
|
+
function stringifyEmbeddingApiError(error) {
|
|
183
|
+
const record = asOptionalRecord(error);
|
|
184
|
+
const parts = error instanceof Error ? [error.message] : [];
|
|
185
|
+
for (const value of [
|
|
186
|
+
record?.code,
|
|
187
|
+
record?.type,
|
|
188
|
+
record?.param,
|
|
189
|
+
record?.error
|
|
190
|
+
]) {
|
|
191
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
192
|
+
parts.push(String(value));
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (value && typeof value === "object") try {
|
|
196
|
+
parts.push(JSON.stringify(value));
|
|
197
|
+
} catch {}
|
|
198
|
+
}
|
|
199
|
+
return parts.join("\n");
|
|
200
|
+
}
|
|
201
|
+
function truncateEmbeddingVector(embedding, dimensions, model) {
|
|
202
|
+
if (embedding.length < dimensions) throw new Error(`Embedding model ${model} returned ${embedding.length} dimensions, need at least ${dimensions} for local truncation`);
|
|
203
|
+
const truncated = embedding.slice(0, dimensions);
|
|
204
|
+
const magnitude = Math.sqrt(truncated.reduce((sum, value) => sum + value * value, 0));
|
|
205
|
+
return magnitude > 0 ? truncated.map((value) => value / magnitude) : truncated;
|
|
206
|
+
}
|
|
155
207
|
var ProviderAdapterEmbeddings = class {
|
|
156
208
|
constructor(api, embedding) {
|
|
157
209
|
this.api = api;
|
|
@@ -247,7 +299,11 @@ var MemoryRecallEmbeddingError = class extends Error {
|
|
|
247
299
|
this.name = "MemoryRecallEmbeddingError";
|
|
248
300
|
}
|
|
249
301
|
};
|
|
250
|
-
const testing = {
|
|
302
|
+
const testing = {
|
|
303
|
+
isEmbeddingDimensionsRejectedError,
|
|
304
|
+
runWithTimeout,
|
|
305
|
+
truncateEmbeddingVector
|
|
306
|
+
};
|
|
251
307
|
function createEmbeddings(api, cfg) {
|
|
252
308
|
const { provider, model, dimensions, apiKey, baseUrl } = cfg.embedding;
|
|
253
309
|
if (provider === "openai" && apiKey) return new OpenAiCompatibleEmbeddings(apiKey, model, baseUrl, dimensions);
|
|
@@ -810,7 +866,7 @@ var memory_lancedb_default = definePluginEntry({
|
|
|
810
866
|
const resolveEnabledAgentId = (rawAgentId, runtimeConfig = resolveRuntimeConfig()) => {
|
|
811
867
|
if (!rawAgentId?.trim()) return;
|
|
812
868
|
const agentId = normalizeAgentId(rawAgentId);
|
|
813
|
-
return (resolveAgentConfig(runtimeConfig, agentId)?.
|
|
869
|
+
return (resolveAgentConfig(runtimeConfig, agentId)?.memory?.search)?.enabled ?? runtimeConfig.memory?.search?.enabled ?? true ? agentId : void 0;
|
|
814
870
|
};
|
|
815
871
|
const resolveCliAgentId = (rawAgentId) => {
|
|
816
872
|
if (typeof rawAgentId === "string" && rawAgentId.trim()) return normalizeAgentId(rawAgentId);
|
|
@@ -952,6 +1008,16 @@ var memory_lancedb_default = definePluginEntry({
|
|
|
952
1008
|
category: Type.Optional(Type.Enum(MEMORY_CATEGORIES, { type: "string" }))
|
|
953
1009
|
}),
|
|
954
1010
|
async execute(_toolCallId, params) {
|
|
1011
|
+
if (isIncognitoSessionKey(ctx.sessionKey)) return {
|
|
1012
|
+
content: [{
|
|
1013
|
+
type: "text",
|
|
1014
|
+
text: "Memory was not stored because this is an incognito session."
|
|
1015
|
+
}],
|
|
1016
|
+
details: {
|
|
1017
|
+
action: "rejected",
|
|
1018
|
+
reason: "incognito_session"
|
|
1019
|
+
}
|
|
1020
|
+
};
|
|
955
1021
|
const { text, category = "other" } = params;
|
|
956
1022
|
const importance = readFiniteNumberParam(params, "importance", {
|
|
957
1023
|
min: 0,
|
|
@@ -1173,7 +1239,7 @@ var memory_lancedb_default = definePluginEntry({
|
|
|
1173
1239
|
});
|
|
1174
1240
|
api.on("agent_end", async (event, ctx) => {
|
|
1175
1241
|
const currentCfg = resolveCurrentHookConfig();
|
|
1176
|
-
if (!currentCfg.autoCapture) return;
|
|
1242
|
+
if (!currentCfg.autoCapture || isIncognitoSessionKey(ctx.sessionKey)) return;
|
|
1177
1243
|
const agentId = resolveEnabledAgentId(ctx.agentId);
|
|
1178
1244
|
if (!agentId) return;
|
|
1179
1245
|
if (!event.success || !event.messages || event.messages.length === 0) return;
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/memory-lancedb",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.4",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "@openclaw/memory-lancedb",
|
|
9
|
-
"version": "2026.7.2-beta.
|
|
9
|
+
"version": "2026.7.2-beta.4",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@lancedb/lancedb": "0.30.0",
|
|
12
12
|
"apache-arrow": "18.1.0",
|
|
13
|
-
"openai": "6.
|
|
14
|
-
"typebox": "1.3.
|
|
13
|
+
"openai": "6.48.0",
|
|
14
|
+
"typebox": "1.3.6"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"node_modules/@lancedb/lancedb": {
|
|
@@ -372,9 +372,9 @@
|
|
|
372
372
|
"license": "MIT"
|
|
373
373
|
},
|
|
374
374
|
"node_modules/openai": {
|
|
375
|
-
"version": "6.
|
|
376
|
-
"resolved": "https://registry.npmjs.org/openai/-/openai-6.
|
|
377
|
-
"integrity": "sha512-
|
|
375
|
+
"version": "6.48.0",
|
|
376
|
+
"resolved": "https://registry.npmjs.org/openai/-/openai-6.48.0.tgz",
|
|
377
|
+
"integrity": "sha512-KhVp+FyV50QrXNextvL9hIU5l6ox5HYuKQjGVk7lIqprgJol90+dQXWONV6S1lRWsKA1bXjrow8RsUT14M1hNA==",
|
|
378
378
|
"license": "Apache-2.0",
|
|
379
379
|
"peerDependencies": {
|
|
380
380
|
"@aws-sdk/credential-provider-node": ">=3.972.0 <4",
|
|
@@ -448,9 +448,9 @@
|
|
|
448
448
|
"license": "0BSD"
|
|
449
449
|
},
|
|
450
450
|
"node_modules/typebox": {
|
|
451
|
-
"version": "1.3.
|
|
452
|
-
"resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.
|
|
453
|
-
"integrity": "sha512-
|
|
451
|
+
"version": "1.3.6",
|
|
452
|
+
"resolved": "https://registry.npmjs.org/typebox/-/typebox-1.3.6.tgz",
|
|
453
|
+
"integrity": "sha512-Sc8RA0NCMEFmApHNU9ZMzqcpQj46She44J8ffpLM/bdhLNUZKq7DJumcLcsFx1gRmDfQPgCgOmFFJ7rcnfWNyA==",
|
|
454
454
|
"license": "MIT"
|
|
455
455
|
},
|
|
456
456
|
"node_modules/typical": {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/memory-lancedb",
|
|
3
|
-
"version": "2026.7.2-beta.
|
|
3
|
+
"version": "2026.7.2-beta.4",
|
|
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",
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@lancedb/lancedb": "0.30.0",
|
|
12
12
|
"apache-arrow": "18.1.0",
|
|
13
|
-
"openai": "6.
|
|
14
|
-
"typebox": "1.3.
|
|
13
|
+
"openai": "6.48.0",
|
|
14
|
+
"typebox": "1.3.6"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@openclaw/plugin-sdk": "workspace:*"
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"minHostVersion": ">=2026.5.31"
|
|
27
27
|
},
|
|
28
28
|
"compat": {
|
|
29
|
-
"pluginApi": ">=2026.7.2-beta.
|
|
29
|
+
"pluginApi": ">=2026.7.2-beta.4"
|
|
30
30
|
},
|
|
31
31
|
"build": {
|
|
32
|
-
"openclawVersion": "2026.7.2-beta.
|
|
32
|
+
"openclawVersion": "2026.7.2-beta.4"
|
|
33
33
|
},
|
|
34
34
|
"release": {
|
|
35
35
|
"bundleRuntimeDependencies": false,
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"README.md"
|
|
48
48
|
],
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"openclaw": ">=2026.7.2-beta.
|
|
50
|
+
"openclaw": ">=2026.7.2-beta.4"
|
|
51
51
|
},
|
|
52
52
|
"peerDependenciesMeta": {
|
|
53
53
|
"openclaw": {
|