@openviking/openclaw-plugin 2026.11.26 → 2026.11.30
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.
|
@@ -677,11 +677,7 @@ export async function afterTurnOpenVikingSession({ throwOnError = false, session
|
|
|
677
677
|
for (const msg of extractedMessages) {
|
|
678
678
|
const ovParts = msg.parts.map((part) => {
|
|
679
679
|
if (part.type === "text") {
|
|
680
|
-
|
|
681
|
-
.replace(/<relevant-memories>[\s\S]*?<\/relevant-memories>/gi, " ")
|
|
682
|
-
.replace(/\s+/g, " ")
|
|
683
|
-
.trim();
|
|
684
|
-
return { type: "text", text: cleaned };
|
|
680
|
+
return { type: "text", text: part.text };
|
|
685
681
|
}
|
|
686
682
|
return {
|
|
687
683
|
type: "tool",
|
package/dist/text-utils.js
CHANGED
|
@@ -8,7 +8,7 @@ export const MEMORY_TRIGGERS = [
|
|
|
8
8
|
/(?:favorite|favourite|love|hate|enjoy|dislike|admire|idol|fan of)/i,
|
|
9
9
|
];
|
|
10
10
|
const CJK_CHAR_REGEX = /[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uac00-\ud7af]/;
|
|
11
|
-
const RELEVANT_MEMORIES_BLOCK_RE =
|
|
11
|
+
const RELEVANT_MEMORIES_BLOCK_RE = /[ \t]*<relevant-memories>[\s\S]*?<\/relevant-memories>[ \t]*/gi;
|
|
12
12
|
const OPENVIKING_CONTEXT_BLOCK_RE = /<openviking-context\b[^>]*>[\s\S]*?<\/openviking-context>/gi;
|
|
13
13
|
const CONVERSATION_METADATA_BLOCK_RE = /(?:^|\n)\s*(?:Conversation info|Conversation metadata|会话信息|对话信息)\s*(?:\([^)]+\))?\s*:\s*```[\s\S]*?```/gi;
|
|
14
14
|
/** Strips "Sender (untrusted metadata): ```json ... ```" so capture sends clean text to OpenViking extract. */
|
|
@@ -37,7 +37,7 @@ function looksLikeMetadataJsonBlock(content) {
|
|
|
37
37
|
return matchedKeys.size >= 3;
|
|
38
38
|
}
|
|
39
39
|
const TOOL_PLACEHOLDER_RE = /^\s*\[tool(?::\s*|Use:\s*)[^\]]+\]\s*$/i;
|
|
40
|
-
|
|
40
|
+
function stripCaptureNoise(text) {
|
|
41
41
|
// Drop legacy synthetic tool placeholders before they reach memory extraction.
|
|
42
42
|
if (TOOL_PLACEHOLDER_RE.test(text)) {
|
|
43
43
|
return "";
|
|
@@ -47,9 +47,11 @@ export function sanitizeUserTextForCapture(text) {
|
|
|
47
47
|
if (COMPACTED_SYSTEM_MSG_RE.test(text)) {
|
|
48
48
|
const match = text.match(COMPACTED_SYSTEM_MSG_RE);
|
|
49
49
|
if (match) {
|
|
50
|
-
|
|
50
|
+
text = match[1];
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
return "";
|
|
51
54
|
}
|
|
52
|
-
return "";
|
|
53
55
|
}
|
|
54
56
|
return text
|
|
55
57
|
.replace(OPENVIKING_CONTEXT_BLOCK_RE, " ")
|
|
@@ -60,9 +62,11 @@ export function sanitizeUserTextForCapture(text) {
|
|
|
60
62
|
.replace(LEADING_TIMESTAMP_PREFIX_RE, "")
|
|
61
63
|
.replace(SUBAGENT_CONTEXT_RE, "")
|
|
62
64
|
.replace(/\u0000/g, "")
|
|
63
|
-
.replace(/\s+/g, " ")
|
|
64
65
|
.trim();
|
|
65
66
|
}
|
|
67
|
+
export function sanitizeUserTextForCapture(text) {
|
|
68
|
+
return stripCaptureNoise(text).replace(/\s+/g, " ");
|
|
69
|
+
}
|
|
66
70
|
export function stripOpenVikingContextInjection(text) {
|
|
67
71
|
return text
|
|
68
72
|
.replace(OPENVIKING_CONTEXT_BLOCK_RE, " ")
|
|
@@ -356,8 +360,8 @@ export function extractNewTurnMessages(messages, startIndex) {
|
|
|
356
360
|
const content = msg.content;
|
|
357
361
|
const text = extractPartText(content);
|
|
358
362
|
if (text) {
|
|
359
|
-
//
|
|
360
|
-
const cleanedText =
|
|
363
|
+
// Keep Markdown structure while removing injected context from the archive.
|
|
364
|
+
const cleanedText = stripCaptureNoise(text);
|
|
361
365
|
if (cleanedText) {
|
|
362
366
|
// 保持原始 role,assistant 保持 assistant,user 保持 user
|
|
363
367
|
const ovRole = role === "assistant" ? "assistant" : "user";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openviking/openclaw-plugin",
|
|
3
|
-
"version": "2026.11.
|
|
3
|
+
"version": "2026.11.30",
|
|
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",
|
|
@@ -1025,11 +1025,7 @@ export async function afterTurnOpenVikingSession({
|
|
|
1025
1025
|
for (const msg of extractedMessages) {
|
|
1026
1026
|
const ovParts = msg.parts.map((part) => {
|
|
1027
1027
|
if (part.type === "text") {
|
|
1028
|
-
const
|
|
1029
|
-
.replace(/<relevant-memories>[\s\S]*?<\/relevant-memories>/gi, " ")
|
|
1030
|
-
.replace(/\s+/g, " ")
|
|
1031
|
-
.trim();
|
|
1032
|
-
return { type: "text" as const, text: cleaned };
|
|
1028
|
+
return { type: "text" as const, text: part.text };
|
|
1033
1029
|
}
|
|
1034
1030
|
return {
|
|
1035
1031
|
type: "tool" as const,
|
package/text-utils.ts
CHANGED
|
@@ -11,7 +11,7 @@ export const MEMORY_TRIGGERS = [
|
|
|
11
11
|
];
|
|
12
12
|
|
|
13
13
|
const CJK_CHAR_REGEX = /[\u3040-\u30ff\u3400-\u9fff\uf900-\ufaff\uac00-\ud7af]/;
|
|
14
|
-
const RELEVANT_MEMORIES_BLOCK_RE =
|
|
14
|
+
const RELEVANT_MEMORIES_BLOCK_RE = /[ \t]*<relevant-memories>[\s\S]*?<\/relevant-memories>[ \t]*/gi;
|
|
15
15
|
const OPENVIKING_CONTEXT_BLOCK_RE = /<openviking-context\b[^>]*>[\s\S]*?<\/openviking-context>/gi;
|
|
16
16
|
const CONVERSATION_METADATA_BLOCK_RE =
|
|
17
17
|
/(?:^|\n)\s*(?:Conversation info|Conversation metadata|会话信息|对话信息)\s*(?:\([^)]+\))?\s*:\s*```[\s\S]*?```/gi;
|
|
@@ -46,7 +46,7 @@ function looksLikeMetadataJsonBlock(content: string): boolean {
|
|
|
46
46
|
|
|
47
47
|
const TOOL_PLACEHOLDER_RE = /^\s*\[tool(?::\s*|Use:\s*)[^\]]+\]\s*$/i;
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
function stripCaptureNoise(text: string): string {
|
|
50
50
|
// Drop legacy synthetic tool placeholders before they reach memory extraction.
|
|
51
51
|
if (TOOL_PLACEHOLDER_RE.test(text)) {
|
|
52
52
|
return "";
|
|
@@ -56,9 +56,10 @@ export function sanitizeUserTextForCapture(text: string): string {
|
|
|
56
56
|
if (COMPACTED_SYSTEM_MSG_RE.test(text)) {
|
|
57
57
|
const match = text.match(COMPACTED_SYSTEM_MSG_RE);
|
|
58
58
|
if (match) {
|
|
59
|
-
|
|
59
|
+
text = match[1];
|
|
60
|
+
} else {
|
|
61
|
+
return "";
|
|
60
62
|
}
|
|
61
|
-
return "";
|
|
62
63
|
}
|
|
63
64
|
return text
|
|
64
65
|
.replace(OPENVIKING_CONTEXT_BLOCK_RE, " ")
|
|
@@ -71,10 +72,13 @@ export function sanitizeUserTextForCapture(text: string): string {
|
|
|
71
72
|
.replace(LEADING_TIMESTAMP_PREFIX_RE, "")
|
|
72
73
|
.replace(SUBAGENT_CONTEXT_RE, "")
|
|
73
74
|
.replace(/\u0000/g, "")
|
|
74
|
-
.replace(/\s+/g, " ")
|
|
75
75
|
.trim();
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
+
export function sanitizeUserTextForCapture(text: string): string {
|
|
79
|
+
return stripCaptureNoise(text).replace(/\s+/g, " ");
|
|
80
|
+
}
|
|
81
|
+
|
|
78
82
|
export function stripOpenVikingContextInjection(text: string): string {
|
|
79
83
|
return text
|
|
80
84
|
.replace(OPENVIKING_CONTEXT_BLOCK_RE, " ")
|
|
@@ -423,8 +427,8 @@ export function extractNewTurnMessages(
|
|
|
423
427
|
const text = extractPartText(content);
|
|
424
428
|
|
|
425
429
|
if (text) {
|
|
426
|
-
//
|
|
427
|
-
const cleanedText =
|
|
430
|
+
// Keep Markdown structure while removing injected context from the archive.
|
|
431
|
+
const cleanedText = stripCaptureNoise(text);
|
|
428
432
|
if (cleanedText) {
|
|
429
433
|
// 保持原始 role,assistant 保持 assistant,user 保持 user
|
|
430
434
|
const ovRole: "user" | "assistant" = role === "assistant" ? "assistant" : "user";
|