mr-memory 2.9.12 → 2.9.13
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/index.ts +14 -4
- package/package.json +1 -1
package/index.ts
CHANGED
|
@@ -15,11 +15,21 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
15
15
|
|
|
16
16
|
const DEFAULT_ENDPOINT = "https://api.memoryrouter.ai";
|
|
17
17
|
|
|
18
|
-
/** Strip media-attached references
|
|
19
|
-
*
|
|
20
|
-
const MEDIA_ATTACHED_RE = /\[media attached
|
|
18
|
+
/** Strip media-attached references and OpenClaw media instruction text so
|
|
19
|
+
* old screenshots/photos/audio don't get stored and re-injected forever. */
|
|
20
|
+
const MEDIA_ATTACHED_RE = /\[media attached[^\]]*\]/gi;
|
|
21
|
+
const MEDIA_TAGS_RE = /<media:(?:audio|image|video|document)>/gi;
|
|
22
|
+
const MEDIA_INSTRUCTION_RE = /To send an image back,[\s\S]*?Keep caption in the text body\./gi;
|
|
23
|
+
const MEDIA_INBOUND_PATH_RE = /\/Users\/[^\s]*\/media\/inbound\/[^\s)\]"]*/gi;
|
|
24
|
+
const IMAGE_DATA_RE = /\[image data removed[^\]]*\]/gi;
|
|
21
25
|
function stripMediaReferences(text: string): string {
|
|
22
|
-
return text
|
|
26
|
+
return text
|
|
27
|
+
.replace(MEDIA_INSTRUCTION_RE, "")
|
|
28
|
+
.replace(MEDIA_ATTACHED_RE, "[media reference removed]")
|
|
29
|
+
.replace(MEDIA_TAGS_RE, "")
|
|
30
|
+
.replace(MEDIA_INBOUND_PATH_RE, "[media reference removed]")
|
|
31
|
+
.replace(IMAGE_DATA_RE, "")
|
|
32
|
+
.replace(/\n{3,}/g, "\n\n");
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
/** Wrap raw memory context in XML tags with a strong instruction */
|