memorylake-openclaw 1.1.3 → 1.1.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 +1794 -0
- package/dist/index.js.map +1 -0
- package/package.json +18 -1
- package/.github/workflows/release.yml +0 -23
- package/CHANGELOG.md +0 -55
- package/docs/openclaw.mdx +0 -110
- package/index.ts +0 -65
- package/lib/cli/register-cli.ts +0 -134
- package/lib/config.ts +0 -105
- package/lib/core-bridge.ts +0 -155
- package/lib/helpers/parse-content-disposition.ts +0 -21
- package/lib/helpers/rewrite-query.ts +0 -122
- package/lib/helpers/upload-record.ts +0 -47
- package/lib/hooks/auto-capture.ts +0 -111
- package/lib/hooks/auto-recall.ts +0 -87
- package/lib/hooks/auto-upload.ts +0 -72
- package/lib/plugin-context.ts +0 -77
- package/lib/prompt/register-prompt.ts +0 -66
- package/lib/provider.ts +0 -227
- package/lib/tools/document-tools.ts +0 -100
- package/lib/tools/memory-tools.ts +0 -298
- package/lib/tools/search-tools.ts +0 -288
- package/lib/types.ts +0 -273
- package/lib/utils/builders.ts +0 -127
- package/lib/utils/chat-envelope.ts +0 -62
- package/lib/utils/config-parser.ts +0 -14
- package/lib/utils/memorylake-reminder.ts +0 -12
- package/lib/utils/normalizers.ts +0 -76
- package/lib/utils/strip-inbound-meta.ts +0 -334
- package/lib/utils/strip-user-body.ts +0 -41
- package/test/json5_config_smoke.test.mjs +0 -104
- package/test/path_reg.test.mjs +0 -197
- package/test/strip_inbound_meta_smoke.test.mjs +0 -216
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Smoke test for the vendored strip-inbound-meta module + the
|
|
3
|
-
* stripUserBody composition in lib/utils/strip-user-body.ts.
|
|
4
|
-
*
|
|
5
|
-
* The strip logic is a faithful copy of openclaw's strip-inbound-meta.ts
|
|
6
|
-
* which has comprehensive tests upstream. This file only checks:
|
|
7
|
-
* - the vendored module imports cleanly under Node's built-in TS strip
|
|
8
|
-
* - representative input cases produce the expected output
|
|
9
|
-
* - the *real* stripUserBody helper used by lib/hooks/auto-capture.ts
|
|
10
|
-
* produces the same output as the test's expectations (no inline
|
|
11
|
-
* mirror — drift between hook and test is impossible)
|
|
12
|
-
*
|
|
13
|
-
* Node version gate: TypeScript stripping is enabled by default in Node
|
|
14
|
-
* v23.6.0 and later (and on by default everywhere in v24+). On 22.6+
|
|
15
|
-
* it requires the --experimental-strip-types flag, which `node --test`
|
|
16
|
-
* does not pass automatically. We skip below v23.6 rather than ask
|
|
17
|
-
* developers to remember the flag.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
import { describe, it } from "node:test";
|
|
21
|
-
import assert from "node:assert/strict";
|
|
22
|
-
import { resolve, dirname } from "node:path";
|
|
23
|
-
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
24
|
-
|
|
25
|
-
const here = dirname(fileURLToPath(import.meta.url));
|
|
26
|
-
const stripInboundMetaPath = resolve(here, "../lib/utils/strip-inbound-meta.ts");
|
|
27
|
-
const stripUserBodyPath = resolve(here, "../lib/utils/strip-user-body.ts");
|
|
28
|
-
const reminderPath = resolve(here, "../lib/utils/memorylake-reminder.ts");
|
|
29
|
-
const stripInboundMetaUrl = pathToFileURL(stripInboundMetaPath).href;
|
|
30
|
-
const stripUserBodyUrl = pathToFileURL(stripUserBodyPath).href;
|
|
31
|
-
const reminderUrl = pathToFileURL(reminderPath).href;
|
|
32
|
-
|
|
33
|
-
const [major, minor] = process.versions.node.split(".").map(Number);
|
|
34
|
-
const supportsTsStrip = major >= 24 || (major === 23 && minor >= 6);
|
|
35
|
-
const skipReason = supportsTsStrip
|
|
36
|
-
? false
|
|
37
|
-
: `requires Node v23.6+ for built-in TS stripping (current: v${process.versions.node})`;
|
|
38
|
-
|
|
39
|
-
describe("strip-inbound-meta vendor smoke", { skip: skipReason }, () => {
|
|
40
|
-
it("strips inbound metadata blocks but leaves the senderLabel body prefix (matches openclaw)", async () => {
|
|
41
|
-
const { stripInboundMetadata } = await import(stripInboundMetaUrl);
|
|
42
|
-
const input = `Conversation info (untrusted metadata):
|
|
43
|
-
\`\`\`json
|
|
44
|
-
{
|
|
45
|
-
"message_id": "om_x100b50338a52f884c4e15a206ba16aa",
|
|
46
|
-
"sender_id": "ou_9b3501f20bd5cbf27e45bb9760978574"
|
|
47
|
-
}
|
|
48
|
-
\`\`\`
|
|
49
|
-
|
|
50
|
-
Sender (untrusted metadata):
|
|
51
|
-
\`\`\`json
|
|
52
|
-
{
|
|
53
|
-
"label": "ou_9b3501f20bd5cbf27e45bb9760978574",
|
|
54
|
-
"id": "ou_9b3501f20bd5cbf27e45bb9760978574"
|
|
55
|
-
}
|
|
56
|
-
\`\`\`
|
|
57
|
-
|
|
58
|
-
ou_9b3501f20bd5cbf27e45bb9760978574: pls remember: The price for Product A is 334 RMB`;
|
|
59
|
-
const result = stripInboundMetadata(input);
|
|
60
|
-
assert.ok(!result.includes("untrusted metadata"), "metadata block leaked");
|
|
61
|
-
assert.ok(!result.includes("```json"), "JSON fence leaked");
|
|
62
|
-
assert.equal(
|
|
63
|
-
result.trim(),
|
|
64
|
-
"ou_9b3501f20bd5cbf27e45bb9760978574: pls remember: The price for Product A is 334 RMB",
|
|
65
|
-
);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it("returns text unchanged when no metadata is present (fast path)", async () => {
|
|
69
|
-
const { stripInboundMetadata } = await import(stripInboundMetaUrl);
|
|
70
|
-
const input = "User wants to deploy to production via Vercel.";
|
|
71
|
-
assert.equal(stripInboundMetadata(input), input);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("extractInboundSenderLabel returns the parsed label across platforms", async () => {
|
|
75
|
-
const { extractInboundSenderLabel } = await import(stripInboundMetaUrl);
|
|
76
|
-
|
|
77
|
-
const lark = `Sender (untrusted metadata):
|
|
78
|
-
\`\`\`json
|
|
79
|
-
{ "label": "ou_9b35", "id": "ou_9b35" }
|
|
80
|
-
\`\`\``;
|
|
81
|
-
assert.equal(extractInboundSenderLabel(lark), "ou_9b35");
|
|
82
|
-
|
|
83
|
-
const slack = `Sender (untrusted metadata):
|
|
84
|
-
\`\`\`json
|
|
85
|
-
{ "label": "U025KW7Q9", "id": "U025KW7Q9" }
|
|
86
|
-
\`\`\``;
|
|
87
|
-
assert.equal(extractInboundSenderLabel(slack), "U025KW7Q9");
|
|
88
|
-
|
|
89
|
-
const realName = `Sender (untrusted metadata):
|
|
90
|
-
\`\`\`json
|
|
91
|
-
{ "label": "Henry", "name": "Henry" }
|
|
92
|
-
\`\`\``;
|
|
93
|
-
assert.equal(extractInboundSenderLabel(realName), "Henry");
|
|
94
|
-
|
|
95
|
-
const e164 = `Sender (untrusted metadata):
|
|
96
|
-
\`\`\`json
|
|
97
|
-
{ "label": "+8613800138000", "e164": "+8613800138000" }
|
|
98
|
-
\`\`\``;
|
|
99
|
-
assert.equal(extractInboundSenderLabel(e164), "+8613800138000");
|
|
100
|
-
});
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
describe("stripUserBody (real auto-capture helper)", { skip: skipReason }, () => {
|
|
104
|
-
function wrapped(senderJson, body) {
|
|
105
|
-
return `Conversation info (untrusted metadata):
|
|
106
|
-
\`\`\`json
|
|
107
|
-
{ "message_id": "om_x" }
|
|
108
|
-
\`\`\`
|
|
109
|
-
|
|
110
|
-
Sender (untrusted metadata):
|
|
111
|
-
\`\`\`json
|
|
112
|
-
${JSON.stringify(senderJson, null, 2)}
|
|
113
|
-
\`\`\`
|
|
114
|
-
|
|
115
|
-
${body}`;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
it("strips the auto-recall reminder", async () => {
|
|
119
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
120
|
-
const { MEMORYLAKE_REMINDER } = await import(reminderUrl);
|
|
121
|
-
const input = `${MEMORYLAKE_REMINDER}\n\nWhat is the deployment plan?`;
|
|
122
|
-
assert.equal(stripUserBody(input), "What is the deployment plan?");
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("Lark opaque uid at position 0", async () => {
|
|
126
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
127
|
-
assert.equal(
|
|
128
|
-
stripUserBody(wrapped(
|
|
129
|
-
{ label: "ou_9b35", id: "ou_9b35" },
|
|
130
|
-
"ou_9b35: pls remember: 价格 334",
|
|
131
|
-
)),
|
|
132
|
-
"pls remember: 价格 334",
|
|
133
|
-
);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it("Slack U-id", async () => {
|
|
137
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
138
|
-
assert.equal(
|
|
139
|
-
stripUserBody(wrapped(
|
|
140
|
-
{ label: "U025KW7Q9", id: "U025KW7Q9" },
|
|
141
|
-
"U025KW7Q9: deploy schedule shifted",
|
|
142
|
-
)),
|
|
143
|
-
"deploy schedule shifted",
|
|
144
|
-
);
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("e164 phone — replaceAll handles special chars without regex escape", async () => {
|
|
148
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
149
|
-
assert.equal(
|
|
150
|
-
stripUserBody(wrapped(
|
|
151
|
-
{ label: "+8613800138000", e164: "+8613800138000" },
|
|
152
|
-
"+8613800138000: 你好",
|
|
153
|
-
)),
|
|
154
|
-
"你好",
|
|
155
|
-
);
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
it('composite "Name (id)" — replaceAll handles parens fine', async () => {
|
|
159
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
160
|
-
assert.equal(
|
|
161
|
-
stripUserBody(wrapped(
|
|
162
|
-
{ label: "Henry (ou_x)", name: "Henry", id: "ou_x" },
|
|
163
|
-
"Henry (ou_x): hello there",
|
|
164
|
-
)),
|
|
165
|
-
"hello there",
|
|
166
|
-
);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it("mid-content: senderLabel prefix sits AFTER unstripped noise", async () => {
|
|
170
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
171
|
-
// Simulates the file-upload case where openclaw's [media attached:]
|
|
172
|
-
// and image-prelude lines push the senderLabel line off position 0.
|
|
173
|
-
// replaceAll catches it anyway.
|
|
174
|
-
assert.equal(
|
|
175
|
-
stripUserBody(wrapped(
|
|
176
|
-
{ label: "ou_y", id: "ou_y" },
|
|
177
|
-
"[media attached: /tmp/x.zip]\nbody hint here\n\nou_y: actual content",
|
|
178
|
-
)),
|
|
179
|
-
"[media attached: /tmp/x.zip]\nbody hint here\n\nactual content",
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it("strips a leading [Slack 2026-04-29 ...] envelope header", async () => {
|
|
184
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
185
|
-
assert.equal(
|
|
186
|
-
stripUserBody("[Slack 2026-04-29 17:00] hello there"),
|
|
187
|
-
"hello there",
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
it("strips standalone [message_id: ...] lines anywhere", async () => {
|
|
192
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
193
|
-
const input = `[message_id: om_x100b50338a52f884c4e15a206ba16aa]
|
|
194
|
-
What is the deployment plan?`;
|
|
195
|
-
assert.equal(stripUserBody(input), "What is the deployment plan?");
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
it("defense: when sender label differs from body prefix, do not mis-strip", async () => {
|
|
199
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
200
|
-
assert.equal(
|
|
201
|
-
stripUserBody(wrapped(
|
|
202
|
-
{ label: "Bob", name: "Bob" },
|
|
203
|
-
"Henry told me: please update",
|
|
204
|
-
)),
|
|
205
|
-
"Henry told me: please update",
|
|
206
|
-
);
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
it('no Sender block — leaves any leading "X: " alone', async () => {
|
|
210
|
-
const { stripUserBody } = await import(stripUserBodyUrl);
|
|
211
|
-
assert.equal(
|
|
212
|
-
stripUserBody("Henry: please update the deploy script"),
|
|
213
|
-
"Henry: please update the deploy script",
|
|
214
|
-
);
|
|
215
|
-
});
|
|
216
|
-
});
|