memorylake-openclaw 1.1.2 → 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 -97
- package/lib/hooks/auto-recall.ts +0 -89
- 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/config-parser.ts +0 -14
- package/lib/utils/normalizers.ts +0 -76
- package/test/json5_config_smoke.test.mjs +0 -104
- package/test/path_reg.test.mjs +0 -197
package/test/path_reg.test.mjs
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { describe, it } from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
|
|
4
|
-
// Extract the regex logic inline (same as index.ts extractInboundPaths)
|
|
5
|
-
function extractInboundPaths(prompt) {
|
|
6
|
-
// Path must contain /media/inbound/ (or \media\inbound\)
|
|
7
|
-
// Filename must end with .<ext>, ext = alphanumeric, 1-6 chars
|
|
8
|
-
const sep = '[/\\\\]';
|
|
9
|
-
const regex = new RegExp(
|
|
10
|
-
`(?:[A-Za-z]:${sep}|/)\\S*?media${sep}inbound${sep}.+?\\.[a-zA-Z0-9]{1,6}(?=[^a-zA-Z0-9]|$)`,
|
|
11
|
-
"g",
|
|
12
|
-
);
|
|
13
|
-
const matches = prompt.match(regex) || [];
|
|
14
|
-
return [...new Set(matches)];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe("extractInboundPaths", () => {
|
|
18
|
-
// ==================== Should match ====================
|
|
19
|
-
|
|
20
|
-
it("Unix: basic inbound path", () => {
|
|
21
|
-
const prompt = "请看这个文件 /Users/henry/.openclaw/media/inbound/abc.png";
|
|
22
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
23
|
-
"/Users/henry/.openclaw/media/inbound/abc.png",
|
|
24
|
-
]);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("Unix: UUID filename", () => {
|
|
28
|
-
const prompt =
|
|
29
|
-
"[media attached: /Users/henry/.openclaw/media/inbound/69b064ed-7afa-4184-b81d-aacbc34c7d95.png (image/png)]";
|
|
30
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
31
|
-
"/Users/henry/.openclaw/media/inbound/69b064ed-7afa-4184-b81d-aacbc34c7d95.png",
|
|
32
|
-
]);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("Unix: timestamp-prefixed filename", () => {
|
|
36
|
-
const prompt =
|
|
37
|
-
"文件已保存: /Users/henry/.openclaw/workspace/media/inbound/1774440188532-b204bb126d0b41bf8b97275d0871728c_1.doc,请基于文件名和上下文回答";
|
|
38
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
39
|
-
"/Users/henry/.openclaw/workspace/media/inbound/1774440188532-b204bb126d0b41bf8b97275d0871728c_1.doc",
|
|
40
|
-
]);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("Unix: Chinese filename", () => {
|
|
44
|
-
const prompt =
|
|
45
|
-
"上传 /Users/henry/.openclaw/workspace/media/inbound/1773887151830-男士护肤品推广.xlsx 到项目";
|
|
46
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
47
|
-
"/Users/henry/.openclaw/workspace/media/inbound/1773887151830-男士护肤品推广.xlsx",
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it("Unix: subdirectory under inbound", () => {
|
|
52
|
-
const prompt = "file at /data/media/inbound/subdir/nested/report.pdf end";
|
|
53
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
54
|
-
"/data/media/inbound/subdir/nested/report.pdf",
|
|
55
|
-
]);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
it("Unix: multiple paths in one prompt", () => {
|
|
59
|
-
const prompt =
|
|
60
|
-
"files: /a/media/inbound/one.txt and /b/media/inbound/two.pdf here";
|
|
61
|
-
const result = extractInboundPaths(prompt);
|
|
62
|
-
assert.equal(result.length, 2);
|
|
63
|
-
assert.ok(result.includes("/a/media/inbound/one.txt"));
|
|
64
|
-
assert.ok(result.includes("/b/media/inbound/two.pdf"));
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it("Unix: dedup same path appearing twice", () => {
|
|
68
|
-
const prompt =
|
|
69
|
-
"/x/media/inbound/f.txt and again /x/media/inbound/f.txt here";
|
|
70
|
-
assert.deepEqual(extractInboundPaths(prompt), ["/x/media/inbound/f.txt"]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it("Windows: backslash path with drive letter", () => {
|
|
74
|
-
const prompt =
|
|
75
|
-
'file at C:\\Users\\hello\\.openclaw\\media\\inbound\\report.docx end';
|
|
76
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
77
|
-
"C:\\Users\\hello\\.openclaw\\media\\inbound\\report.docx",
|
|
78
|
-
]);
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("Windows: Chinese username and filename", () => {
|
|
82
|
-
const prompt =
|
|
83
|
-
'C:\\Users\\你好\\.openclaw\\media\\inbound\\sds\\中文的.odf 这个文件';
|
|
84
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
85
|
-
"C:\\Users\\你好\\.openclaw\\media\\inbound\\sds\\中文的.odf",
|
|
86
|
-
]);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("Windows: mixed separators (forward slash after drive)", () => {
|
|
90
|
-
const prompt = "C:/Users/test/media/inbound/file.txt done";
|
|
91
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
92
|
-
"C:/Users/test/media/inbound/file.txt",
|
|
93
|
-
]);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("Unix: path with dot-prefixed directory", () => {
|
|
97
|
-
const prompt = "/home/user/.config/media/inbound/data.csv end";
|
|
98
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
99
|
-
"/home/user/.config/media/inbound/data.csv",
|
|
100
|
-
]);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// ==================== Should NOT match ====================
|
|
104
|
-
|
|
105
|
-
it("no match: no media/inbound in path", () => {
|
|
106
|
-
const prompt = "/Users/henry/Documents/report.pdf";
|
|
107
|
-
assert.deepEqual(extractInboundPaths(prompt), []);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
it("no match: media/outbound (not inbound)", () => {
|
|
111
|
-
const prompt = "/Users/henry/media/outbound/file.txt";
|
|
112
|
-
assert.deepEqual(extractInboundPaths(prompt), []);
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it("no match: bare text media/inbound without leading path", () => {
|
|
116
|
-
const prompt = "check media/inbound/file.txt please";
|
|
117
|
-
assert.deepEqual(extractInboundPaths(prompt), []);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it("no match: empty prompt", () => {
|
|
121
|
-
assert.deepEqual(extractInboundPaths(""), []);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it("no match: path-like text without separator before media", () => {
|
|
125
|
-
const prompt = "wordmedia/inbound/file.txt";
|
|
126
|
-
assert.deepEqual(extractInboundPaths(prompt), []);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
// ==================== Edge cases ====================
|
|
130
|
-
|
|
131
|
-
it("stops at Chinese comma after path", () => {
|
|
132
|
-
const prompt =
|
|
133
|
-
"文件已保存: /a/media/inbound/file.doc,请回答";
|
|
134
|
-
const result = extractInboundPaths(prompt);
|
|
135
|
-
assert.equal(result.length, 1);
|
|
136
|
-
// Should NOT include the Chinese comma or text after it
|
|
137
|
-
assert.ok(!result[0].includes(","));
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
it("stops at Chinese enumeration comma (、) after path", () => {
|
|
141
|
-
const prompt =
|
|
142
|
-
"上传 /a/media/inbound/one.txt、/a/media/inbound/two.txt 到项目";
|
|
143
|
-
const result = extractInboundPaths(prompt);
|
|
144
|
-
assert.equal(result.length, 2);
|
|
145
|
-
assert.ok(!result[0].includes("、"));
|
|
146
|
-
assert.ok(!result[1].includes("、"));
|
|
147
|
-
assert.ok(result.includes("/a/media/inbound/one.txt"));
|
|
148
|
-
assert.ok(result.includes("/a/media/inbound/two.txt"));
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
it("stops at parenthesis after path", () => {
|
|
152
|
-
const prompt =
|
|
153
|
-
"[media attached: /a/media/inbound/img.png (image/png) | /a/media/inbound/img.png]";
|
|
154
|
-
const result = extractInboundPaths(prompt);
|
|
155
|
-
// Should capture the path but not "(image/png)"
|
|
156
|
-
assert.ok(result.length >= 1);
|
|
157
|
-
assert.ok(result.some((p) => p === "/a/media/inbound/img.png"));
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
it("stops at double quote", () => {
|
|
161
|
-
const prompt = 'path is "/a/media/inbound/file.txt" here';
|
|
162
|
-
const result = extractInboundPaths(prompt);
|
|
163
|
-
assert.equal(result.length, 1);
|
|
164
|
-
assert.ok(!result[0].includes('"'));
|
|
165
|
-
});
|
|
166
|
-
|
|
167
|
-
it("path inside brackets", () => {
|
|
168
|
-
const prompt = "[/a/media/inbound/file.txt]";
|
|
169
|
-
const result = extractInboundPaths(prompt);
|
|
170
|
-
assert.equal(result.length, 1);
|
|
171
|
-
assert.equal(result[0], "/a/media/inbound/file.txt");
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it("filename with parentheses (browser duplicate)", () => {
|
|
175
|
-
const prompt =
|
|
176
|
-
"C:\\Users\\test\\.openclaw\\workspace\\media\\inbound\\米家吸尘器2(1)-1774512141374.pdf 这个文件";
|
|
177
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
178
|
-
"C:\\Users\\test\\.openclaw\\workspace\\media\\inbound\\米家吸尘器2(1)-1774512141374.pdf",
|
|
179
|
-
]);
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it("filename with spaces", () => {
|
|
183
|
-
const prompt =
|
|
184
|
-
"C:\\Users\\test\\.openclaw\\workspace\\media\\inbound\\Contemporary Report-1774522842609.pdf 请分析";
|
|
185
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
186
|
-
"C:\\Users\\test\\.openclaw\\workspace\\media\\inbound\\Contemporary Report-1774522842609.pdf",
|
|
187
|
-
]);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
it("Unix: filename with spaces and parens", () => {
|
|
191
|
-
const prompt =
|
|
192
|
-
"看看 /Users/henry/.openclaw/media/inbound/My Document (2).pdf 这个";
|
|
193
|
-
assert.deepEqual(extractInboundPaths(prompt), [
|
|
194
|
-
"/Users/henry/.openclaw/media/inbound/My Document (2).pdf",
|
|
195
|
-
]);
|
|
196
|
-
});
|
|
197
|
-
});
|