@memtensor/memos-cloud-openclaw-plugin 0.1.11 → 0.1.12-beta.0
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/HOOK.md +22 -0
- package/LICENSE +201 -201
- package/README.md +316 -317
- package/README_ZH.md +321 -322
- package/clawdbot.plugin.json +49 -61
- package/index.js +544 -527
- package/lib/arms-reporter.js +116 -0
- package/lib/check-update.js +187 -270
- package/lib/config-resolution-schema.js +50 -0
- package/lib/config-ui/app.css +920 -0
- package/lib/config-ui/app.js +1290 -0
- package/lib/config-ui/icon.svg +1 -0
- package/lib/config-ui/index.html +112 -0
- package/lib/config-ui-server.js +713 -0
- package/lib/memos-cloud-api.js +848 -790
- package/moltbot.plugin.json +49 -61
- package/openclaw.plugin.json +49 -61
- package/package.json +55 -46
- package/scripts/sync-version.js +45 -45
- package/test/direct-session-user-id.test.mjs +94 -94
- package/test/query-strip.test.mjs +381 -381
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import test from "node:test";
|
|
2
|
-
import assert from "node:assert/strict";
|
|
3
|
-
|
|
4
|
-
import { buildConfig } from "../lib/memos-cloud-api.js";
|
|
5
|
-
import {
|
|
6
|
-
buildAddMessagePayload,
|
|
7
|
-
buildSearchPayload,
|
|
8
|
-
extractDirectSessionUserId,
|
|
9
|
-
resolveMemosUserId,
|
|
10
|
-
} from "../index.js";
|
|
11
|
-
|
|
12
|
-
test("buildConfig keeps useDirectSessionUserId disabled by default", () => {
|
|
13
|
-
const previous = process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
14
|
-
delete process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
15
|
-
try {
|
|
16
|
-
const cfg = buildConfig({});
|
|
17
|
-
assert.equal(cfg.useDirectSessionUserId, false);
|
|
18
|
-
} finally {
|
|
19
|
-
if (previous === undefined) {
|
|
20
|
-
delete process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
21
|
-
} else {
|
|
22
|
-
process.env.MEMOS_USE_DIRECT_SESSION_USER_ID = previous;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test("extractDirectSessionUserId returns the id for direct session keys", () => {
|
|
28
|
-
assert.equal(
|
|
29
|
-
extractDirectSessionUserId("agent:main:discord:direct:1160853368999247882"),
|
|
30
|
-
"1160853368999247882",
|
|
31
|
-
);
|
|
32
|
-
assert.equal(extractDirectSessionUserId("agent:main:telegram:direct:8361983702"), "8361983702");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test("extractDirectSessionUserId ignores non-direct session keys", () => {
|
|
36
|
-
assert.equal(extractDirectSessionUserId("agent:main:discord:channel:1482035270651220051"), "");
|
|
37
|
-
assert.equal(extractDirectSessionUserId(""), "");
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
test("resolveMemosUserId falls back to configured userId when switch is off", () => {
|
|
41
|
-
const cfg = { userId: "openclaw-user", useDirectSessionUserId: false };
|
|
42
|
-
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
43
|
-
assert.equal(resolveMemosUserId(cfg, ctx), "openclaw-user");
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
test("resolveMemosUserId uses direct id when switch is on", () => {
|
|
47
|
-
const cfg = { userId: "openclaw-user", useDirectSessionUserId: true };
|
|
48
|
-
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
49
|
-
assert.equal(resolveMemosUserId(cfg, ctx), "1160853368999247882");
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
test("buildSearchPayload uses direct session id as user_id for private chats", () => {
|
|
53
|
-
const cfg = {
|
|
54
|
-
userId: "openclaw-user",
|
|
55
|
-
useDirectSessionUserId: true,
|
|
56
|
-
queryPrefix: "",
|
|
57
|
-
maxQueryChars: 0,
|
|
58
|
-
recallGlobal: true,
|
|
59
|
-
knowledgebaseIds: [],
|
|
60
|
-
memoryLimitNumber: 6,
|
|
61
|
-
includePreference: true,
|
|
62
|
-
preferenceLimitNumber: 6,
|
|
63
|
-
includeToolMemory: false,
|
|
64
|
-
toolMemoryLimitNumber: 0,
|
|
65
|
-
relativity: 0.45,
|
|
66
|
-
multiAgentMode: false,
|
|
67
|
-
};
|
|
68
|
-
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
69
|
-
|
|
70
|
-
const payload = buildSearchPayload(cfg, "你好", ctx);
|
|
71
|
-
assert.equal(payload.user_id, "1160853368999247882");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
test("buildAddMessagePayload keeps configured userId for non-direct chats", () => {
|
|
75
|
-
const cfg = {
|
|
76
|
-
userId: "openclaw-user",
|
|
77
|
-
useDirectSessionUserId: true,
|
|
78
|
-
multiAgentMode: false,
|
|
79
|
-
appId: "",
|
|
80
|
-
tags: [],
|
|
81
|
-
info: {},
|
|
82
|
-
allowPublic: false,
|
|
83
|
-
allowKnowledgebaseIds: [],
|
|
84
|
-
asyncMode: true,
|
|
85
|
-
conversationId: "",
|
|
86
|
-
conversationIdPrefix: "",
|
|
87
|
-
conversationIdSuffix: "",
|
|
88
|
-
conversationSuffixMode: "none",
|
|
89
|
-
};
|
|
90
|
-
const ctx = { sessionKey: "agent:main:discord:channel:1482035270651220051" };
|
|
91
|
-
|
|
92
|
-
const payload = buildAddMessagePayload(cfg, [{ role: "user", content: "hi" }], ctx);
|
|
93
|
-
assert.equal(payload.user_id, "openclaw-user");
|
|
94
|
-
});
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
|
|
4
|
+
import { buildConfig } from "../lib/memos-cloud-api.js";
|
|
5
|
+
import {
|
|
6
|
+
buildAddMessagePayload,
|
|
7
|
+
buildSearchPayload,
|
|
8
|
+
extractDirectSessionUserId,
|
|
9
|
+
resolveMemosUserId,
|
|
10
|
+
} from "../index.js";
|
|
11
|
+
|
|
12
|
+
test("buildConfig keeps useDirectSessionUserId disabled by default", () => {
|
|
13
|
+
const previous = process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
14
|
+
delete process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
15
|
+
try {
|
|
16
|
+
const cfg = buildConfig({});
|
|
17
|
+
assert.equal(cfg.useDirectSessionUserId, false);
|
|
18
|
+
} finally {
|
|
19
|
+
if (previous === undefined) {
|
|
20
|
+
delete process.env.MEMOS_USE_DIRECT_SESSION_USER_ID;
|
|
21
|
+
} else {
|
|
22
|
+
process.env.MEMOS_USE_DIRECT_SESSION_USER_ID = previous;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test("extractDirectSessionUserId returns the id for direct session keys", () => {
|
|
28
|
+
assert.equal(
|
|
29
|
+
extractDirectSessionUserId("agent:main:discord:direct:1160853368999247882"),
|
|
30
|
+
"1160853368999247882",
|
|
31
|
+
);
|
|
32
|
+
assert.equal(extractDirectSessionUserId("agent:main:telegram:direct:8361983702"), "8361983702");
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
test("extractDirectSessionUserId ignores non-direct session keys", () => {
|
|
36
|
+
assert.equal(extractDirectSessionUserId("agent:main:discord:channel:1482035270651220051"), "");
|
|
37
|
+
assert.equal(extractDirectSessionUserId(""), "");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("resolveMemosUserId falls back to configured userId when switch is off", () => {
|
|
41
|
+
const cfg = { userId: "openclaw-user", useDirectSessionUserId: false };
|
|
42
|
+
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
43
|
+
assert.equal(resolveMemosUserId(cfg, ctx), "openclaw-user");
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("resolveMemosUserId uses direct id when switch is on", () => {
|
|
47
|
+
const cfg = { userId: "openclaw-user", useDirectSessionUserId: true };
|
|
48
|
+
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
49
|
+
assert.equal(resolveMemosUserId(cfg, ctx), "1160853368999247882");
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("buildSearchPayload uses direct session id as user_id for private chats", () => {
|
|
53
|
+
const cfg = {
|
|
54
|
+
userId: "openclaw-user",
|
|
55
|
+
useDirectSessionUserId: true,
|
|
56
|
+
queryPrefix: "",
|
|
57
|
+
maxQueryChars: 0,
|
|
58
|
+
recallGlobal: true,
|
|
59
|
+
knowledgebaseIds: [],
|
|
60
|
+
memoryLimitNumber: 6,
|
|
61
|
+
includePreference: true,
|
|
62
|
+
preferenceLimitNumber: 6,
|
|
63
|
+
includeToolMemory: false,
|
|
64
|
+
toolMemoryLimitNumber: 0,
|
|
65
|
+
relativity: 0.45,
|
|
66
|
+
multiAgentMode: false,
|
|
67
|
+
};
|
|
68
|
+
const ctx = { sessionKey: "agent:main:discord:direct:1160853368999247882" };
|
|
69
|
+
|
|
70
|
+
const payload = buildSearchPayload(cfg, "你好", ctx);
|
|
71
|
+
assert.equal(payload.user_id, "1160853368999247882");
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("buildAddMessagePayload keeps configured userId for non-direct chats", () => {
|
|
75
|
+
const cfg = {
|
|
76
|
+
userId: "openclaw-user",
|
|
77
|
+
useDirectSessionUserId: true,
|
|
78
|
+
multiAgentMode: false,
|
|
79
|
+
appId: "",
|
|
80
|
+
tags: [],
|
|
81
|
+
info: {},
|
|
82
|
+
allowPublic: false,
|
|
83
|
+
allowKnowledgebaseIds: [],
|
|
84
|
+
asyncMode: true,
|
|
85
|
+
conversationId: "",
|
|
86
|
+
conversationIdPrefix: "",
|
|
87
|
+
conversationIdSuffix: "",
|
|
88
|
+
conversationSuffixMode: "none",
|
|
89
|
+
};
|
|
90
|
+
const ctx = { sessionKey: "agent:main:discord:channel:1482035270651220051" };
|
|
91
|
+
|
|
92
|
+
const payload = buildAddMessagePayload(cfg, [{ role: "user", content: "hi" }], ctx);
|
|
93
|
+
assert.equal(payload.user_id, "openclaw-user");
|
|
94
|
+
});
|