@openviking/openclaw-plugin 2026.9.8-2 → 2026.9.8-3
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.
|
@@ -83,11 +83,21 @@ export function repairDigestUris(digest, validUris = []) {
|
|
|
83
83
|
lines.push(line);
|
|
84
84
|
continue;
|
|
85
85
|
}
|
|
86
|
+
let tokenized = line;
|
|
87
|
+
for (const uri of [...valid].sort((a, b) => b.length - a.length)) {
|
|
88
|
+
if (/\s/.test(uri))
|
|
89
|
+
tokenized = tokenized.split(uri).join(encodeURI(uri));
|
|
90
|
+
}
|
|
86
91
|
let dropped = false;
|
|
87
|
-
const repaired =
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
92
|
+
const repaired = tokenized.replace(/viking:\/\/[^\s<>"')\]]+/g, (uri) => {
|
|
93
|
+
let decoded = uri;
|
|
94
|
+
try {
|
|
95
|
+
decoded = decodeURI(uri);
|
|
96
|
+
}
|
|
97
|
+
catch { /* keep the original candidate */ }
|
|
98
|
+
if (validSet.has(decoded))
|
|
99
|
+
return decoded;
|
|
100
|
+
const nearest = nearestUri(decoded, valid);
|
|
91
101
|
if (nearest)
|
|
92
102
|
return nearest;
|
|
93
103
|
dropped = true;
|
|
@@ -146,13 +156,14 @@ async function writeCache(path, value) {
|
|
|
146
156
|
}
|
|
147
157
|
catch { /* best effort */ }
|
|
148
158
|
}
|
|
149
|
-
export async function compressRecallContext({ query, rendered, entries = [], cfg = {}, runCompressor, cachePath = "", now = 0, }) {
|
|
159
|
+
export async function compressRecallContext({ query, rendered, shortContext = rendered, entries = [], cfg = {}, runCompressor, cachePath = "", now = 0, }) {
|
|
150
160
|
const input = String(rendered || "").trim();
|
|
151
161
|
if (!input)
|
|
152
162
|
return { status: COMPRESS_EMPTY, context: "" };
|
|
153
163
|
const minChars = Math.max(0, Number(cfg.recallCompressMinInputChars ?? 1500));
|
|
154
|
-
if (input.length < minChars)
|
|
155
|
-
return { status: COMPRESS_OK, context: input };
|
|
164
|
+
if (input.length < minChars) {
|
|
165
|
+
return { status: COMPRESS_OK, context: String(shortContext ?? input).trim() };
|
|
166
|
+
}
|
|
156
167
|
const maxInputChars = Math.max(1000, Number(cfg.recallCompressMaxInputChars || 18000));
|
|
157
168
|
const maxBullets = Math.max(1, Number(cfg.recallCompressMaxBullets || 6));
|
|
158
169
|
const key = recallDigestCacheKey({
|
|
@@ -164,7 +175,9 @@ export async function compressRecallContext({ query, rendered, entries = [], cfg
|
|
|
164
175
|
});
|
|
165
176
|
const cached = await readCache(cachePath);
|
|
166
177
|
if (cached?.key === key && typeof cached.digest === "string") {
|
|
167
|
-
|
|
178
|
+
const digest = normalizeCompressedContext(cached.digest, 4000, maxBullets);
|
|
179
|
+
if (digest)
|
|
180
|
+
return { status: COMPRESS_OK, context: digest };
|
|
168
181
|
}
|
|
169
182
|
const prompt = buildRecallCompressionPrompt({
|
|
170
183
|
query,
|
|
@@ -178,9 +191,10 @@ export async function compressRecallContext({ query, rendered, entries = [], cfg
|
|
|
178
191
|
if (!normalized)
|
|
179
192
|
return { status: COMPRESS_EMPTY, context: "" };
|
|
180
193
|
const validUris = entries.map((entry) => entry?.uri).filter(Boolean);
|
|
181
|
-
const
|
|
194
|
+
const repaired = repairDigestUris(normalized, validUris.length
|
|
182
195
|
? validUris
|
|
183
196
|
: (input.match(/viking:\/\/[^\s<>"']+/g) || []));
|
|
197
|
+
const digest = normalizeCompressedContext(repaired, 4000, maxBullets);
|
|
184
198
|
if (!digest)
|
|
185
199
|
return { status: COMPRESS_FAILED, context: "" };
|
|
186
200
|
await writeCache(cachePath, { key, digest, updatedAt: now || 0 });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openviking/openclaw-plugin",
|
|
3
|
-
"version": "2026.9.8-
|
|
3
|
+
"version": "2026.9.8-3",
|
|
4
4
|
"displayName": "OpenViking",
|
|
5
5
|
"description": "OpenClaw context-engine plugin — OpenViking AI memory, long-term memory, knowledge base, semantic search, RAG, context engine. 长期记忆 · 知识库 · 语义检索 · 上下文引擎",
|
|
6
6
|
"type": "module",
|
|
@@ -86,10 +86,16 @@ export function repairDigestUris(digest, validUris = []) {
|
|
|
86
86
|
lines.push(line);
|
|
87
87
|
continue;
|
|
88
88
|
}
|
|
89
|
+
let tokenized = line;
|
|
90
|
+
for (const uri of [...valid].sort((a, b) => b.length - a.length)) {
|
|
91
|
+
if (/\s/.test(uri)) tokenized = tokenized.split(uri).join(encodeURI(uri));
|
|
92
|
+
}
|
|
89
93
|
let dropped = false;
|
|
90
|
-
const repaired =
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
const repaired = tokenized.replace(/viking:\/\/[^\s<>"')\]]+/g, (uri) => {
|
|
95
|
+
let decoded = uri;
|
|
96
|
+
try { decoded = decodeURI(uri); } catch { /* keep the original candidate */ }
|
|
97
|
+
if (validSet.has(decoded)) return decoded;
|
|
98
|
+
const nearest = nearestUri(decoded, valid);
|
|
93
99
|
if (nearest) return nearest;
|
|
94
100
|
dropped = true;
|
|
95
101
|
return uri;
|
|
@@ -149,6 +155,7 @@ async function writeCache(path, value) {
|
|
|
149
155
|
export async function compressRecallContext({
|
|
150
156
|
query,
|
|
151
157
|
rendered,
|
|
158
|
+
shortContext = rendered,
|
|
152
159
|
entries = [],
|
|
153
160
|
cfg = {},
|
|
154
161
|
runCompressor,
|
|
@@ -158,7 +165,9 @@ export async function compressRecallContext({
|
|
|
158
165
|
const input = String(rendered || "").trim();
|
|
159
166
|
if (!input) return { status: COMPRESS_EMPTY, context: "" };
|
|
160
167
|
const minChars = Math.max(0, Number(cfg.recallCompressMinInputChars ?? 1500));
|
|
161
|
-
if (input.length < minChars)
|
|
168
|
+
if (input.length < minChars) {
|
|
169
|
+
return { status: COMPRESS_OK, context: String(shortContext ?? input).trim() };
|
|
170
|
+
}
|
|
162
171
|
|
|
163
172
|
const maxInputChars = Math.max(1000, Number(cfg.recallCompressMaxInputChars || 18000));
|
|
164
173
|
const maxBullets = Math.max(1, Number(cfg.recallCompressMaxBullets || 6));
|
|
@@ -171,7 +180,8 @@ export async function compressRecallContext({
|
|
|
171
180
|
});
|
|
172
181
|
const cached = await readCache(cachePath);
|
|
173
182
|
if (cached?.key === key && typeof cached.digest === "string") {
|
|
174
|
-
|
|
183
|
+
const digest = normalizeCompressedContext(cached.digest, 4000, maxBullets);
|
|
184
|
+
if (digest) return { status: COMPRESS_OK, context: digest };
|
|
175
185
|
}
|
|
176
186
|
|
|
177
187
|
const prompt = buildRecallCompressionPrompt({
|
|
@@ -185,9 +195,10 @@ export async function compressRecallContext({
|
|
|
185
195
|
if (!normalized) return { status: COMPRESS_EMPTY, context: "" };
|
|
186
196
|
|
|
187
197
|
const validUris = entries.map((entry) => entry?.uri).filter(Boolean);
|
|
188
|
-
const
|
|
198
|
+
const repaired = repairDigestUris(normalized, validUris.length
|
|
189
199
|
? validUris
|
|
190
200
|
: (input.match(/viking:\/\/[^\s<>"']+/g) || []));
|
|
201
|
+
const digest = normalizeCompressedContext(repaired, 4000, maxBullets);
|
|
191
202
|
if (!digest) return { status: COMPRESS_FAILED, context: "" };
|
|
192
203
|
|
|
193
204
|
await writeCache(cachePath, { key, digest, updatedAt: now || 0 });
|