@memtensor/memos-cloud-openclaw-plugin 0.1.6 → 0.1.8-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/README.md +10 -0
- package/README_ZH.md +10 -0
- package/clawdbot.plugin.json +5 -1
- package/index.js +27 -3
- package/lib/memos-cloud-api.js +6 -0
- package/moltbot.plugin.json +5 -1
- package/openclaw.plugin.json +5 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -93,6 +93,7 @@ MEMOS_API_KEY=YOUR_TOKEN
|
|
|
93
93
|
- `MEMOS_USER_ID` (optional; default: `openclaw-user`)
|
|
94
94
|
- `MEMOS_CONVERSATION_ID` (optional override)
|
|
95
95
|
- `MEMOS_RECALL_GLOBAL` (default: `true`; when true, search does **not** pass conversation_id)
|
|
96
|
+
- `MEMOS_MULTI_AGENT_MODE` (default: `false`; enable multi-agent data isolation)
|
|
96
97
|
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX` (optional)
|
|
97
98
|
- `MEMOS_CONVERSATION_SUFFIX_MODE` (`none` | `counter`, default: `none`)
|
|
98
99
|
- `MEMOS_CONVERSATION_RESET_ON_NEW` (default: `true`, requires hooks.internal.enabled)
|
|
@@ -123,6 +124,8 @@ In `plugins.entries.memos-cloud-openclaw-plugin.config`:
|
|
|
123
124
|
"toolMemoryLimitNumber": 6,
|
|
124
125
|
"relativity": 0.45,
|
|
125
126
|
"tags": ["openclaw"],
|
|
127
|
+
"agentId": "",
|
|
128
|
+
"multiAgentMode": false,
|
|
126
129
|
"asyncMode": true
|
|
127
130
|
}
|
|
128
131
|
```
|
|
@@ -137,6 +140,13 @@ In `plugins.entries.memos-cloud-openclaw-plugin.config`:
|
|
|
137
140
|
- Builds a `/add/message` request with the **last turn** by default (user + assistant).
|
|
138
141
|
- Sends `messages` with `user_id`, `conversation_id`, and optional `tags/info/agent_id/app_id`.
|
|
139
142
|
|
|
143
|
+
## Multi-Agent Support
|
|
144
|
+
The plugin provides native support for multi-agent architectures (via the `agent_id` parameter):
|
|
145
|
+
- **Enable Mode**: Set `"multiAgentMode": true` in config or `MEMOS_MULTI_AGENT_MODE=true` in env variables (default is `false`).
|
|
146
|
+
- **Dynamic Context**: When enabled, it automatically captures `ctx.agentId` during OpenClaw lifecycle hooks. (Note: the default OpenClaw agent `"main"` is ignored to preserve backwards compatibility for single-agent users).
|
|
147
|
+
- **Data Isolation**: The `agent_id` is automatically injected into both `/search/memory` and `/add/message` requests. This ensures completely isolated memory and message histories for different agents, even under the same user or session.
|
|
148
|
+
- **Static Override**: You can also force a specific agent ID by setting `"agentId": "your_agent_id"` in the plugin's `config`.
|
|
149
|
+
|
|
140
150
|
## Notes
|
|
141
151
|
- `conversation_id` defaults to OpenClaw `sessionKey` (unless `conversationId` is provided). **TODO**: consider binding to OpenClaw `sessionId` directly.
|
|
142
152
|
- Optional **prefix/suffix** via env or config; `conversationSuffixMode=counter` increments on `/new` (requires `hooks.internal.enabled`).
|
package/README_ZH.md
CHANGED
|
@@ -95,6 +95,7 @@ MEMOS_API_KEY=YOUR_TOKEN
|
|
|
95
95
|
- `MEMOS_USER_ID`(可选,默认 `openclaw-user`)
|
|
96
96
|
- `MEMOS_CONVERSATION_ID`(可选覆盖)
|
|
97
97
|
- `MEMOS_RECALL_GLOBAL`(默认 `true`;为 true 时检索不传 conversation_id)
|
|
98
|
+
- `MEMOS_MULTI_AGENT_MODE`(默认 `false`;是否开启多 Agent 数据隔离模式)
|
|
98
99
|
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX`(可选)
|
|
99
100
|
- `MEMOS_CONVERSATION_SUFFIX_MODE`(`none` | `counter`,默认 `none`)
|
|
100
101
|
- `MEMOS_CONVERSATION_RESET_ON_NEW`(默认 `true`,需 hooks.internal.enabled)
|
|
@@ -124,6 +125,8 @@ MEMOS_API_KEY=YOUR_TOKEN
|
|
|
124
125
|
"includeToolMemory": false,
|
|
125
126
|
"toolMemoryLimitNumber": 6,
|
|
126
127
|
"tags": ["openclaw"],
|
|
128
|
+
"agentId": "",
|
|
129
|
+
"multiAgentMode": false,
|
|
127
130
|
"asyncMode": true
|
|
128
131
|
}
|
|
129
132
|
```
|
|
@@ -143,6 +146,13 @@ MEMOS_API_KEY=YOUR_TOKEN
|
|
|
143
146
|
- `messages` 列表
|
|
144
147
|
- 可选 `tags / info / agent_id / app_id`
|
|
145
148
|
|
|
149
|
+
## 多Agent支持(Multi-Agent)
|
|
150
|
+
插件内置对多Agent模式的支持(`agent_id` 参数):
|
|
151
|
+
- **开启模式**:需要在配置中设置 `"multiAgentMode": true` 或在环境变量中设置 `MEMOS_MULTI_AGENT_MODE=true`(默认为 `false`)。
|
|
152
|
+
- **动态获取**:开启后,执行生命周期钩子时会自动读取上下文中的 `ctx.agentId`。(注:OpenClaw 的默认 Agent `"main"` 会被自动忽略,以保证老用户的单 Agent 数据兼容性)。
|
|
153
|
+
- **数据隔离**:在调用 `/search/memory`(检索记忆)和 `/add/message`(添加记录)时会自动附带该 `agent_id`,从而保证即使是同一用户下的不同 Agent 之间,记忆和反馈数据也是完全隔离的。
|
|
154
|
+
- **静态配置**:如果需要,也可在上述插件的 `config` 中显式指定 `"agentId": "your_agent_id"` 作为固定值。
|
|
155
|
+
|
|
146
156
|
## 说明
|
|
147
157
|
- 未显式指定 `conversation_id` 时,默认使用 OpenClaw `sessionKey`。**TODO**:后续考虑直接绑定 OpenClaw `sessionId`。
|
|
148
158
|
- 可配置前后缀;`conversationSuffixMode=counter` 时会在 `/new` 递增(需 `hooks.internal.enabled`)。
|
package/clawdbot.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "memos-cloud-openclaw-plugin",
|
|
3
3
|
"name": "MemOS Cloud OpenClaw Plugin",
|
|
4
4
|
"description": "MemOS Cloud recall + add memory via lifecycle hooks",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.8-beta.0",
|
|
6
6
|
"kind": "lifecycle",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"configSchema": {
|
|
@@ -125,6 +125,10 @@
|
|
|
125
125
|
"agentId": {
|
|
126
126
|
"type": "string"
|
|
127
127
|
},
|
|
128
|
+
"multiAgentMode": {
|
|
129
|
+
"type": "boolean",
|
|
130
|
+
"default": false
|
|
131
|
+
},
|
|
128
132
|
"appId": {
|
|
129
133
|
"type": "string"
|
|
130
134
|
},
|
package/index.js
CHANGED
|
@@ -50,10 +50,17 @@ function bumpConversationCounter(sessionKey) {
|
|
|
50
50
|
conversationCounters.set(sessionKey, current + 1);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function getEffectiveAgentId(cfg, ctx) {
|
|
54
|
+
if (!cfg.multiAgentMode) return undefined;
|
|
55
|
+
const agentId = ctx?.agentId || cfg.agentId;
|
|
56
|
+
return agentId === "main" ? undefined : agentId;
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
function resolveConversationId(cfg, ctx) {
|
|
54
60
|
if (cfg.conversationId) return cfg.conversationId;
|
|
55
61
|
// TODO: consider binding conversation_id directly to OpenClaw sessionId (prefer ctx.sessionId).
|
|
56
|
-
const
|
|
62
|
+
const agentId = getEffectiveAgentId(cfg, ctx);
|
|
63
|
+
const base = ctx?.sessionKey || ctx?.sessionId || (agentId ? `openclaw:${agentId}` : "");
|
|
57
64
|
const dynamicSuffix = cfg.conversationSuffixMode === "counter" ? getCounterSuffix(ctx?.sessionKey) : "";
|
|
58
65
|
const prefix = cfg.conversationIdPrefix || "";
|
|
59
66
|
const suffix = cfg.conversationIdSuffix || "";
|
|
@@ -79,7 +86,23 @@ function buildSearchPayload(cfg, prompt, ctx) {
|
|
|
79
86
|
if (conversationId) payload.conversation_id = conversationId;
|
|
80
87
|
}
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
let filterObj = cfg.filter ? JSON.parse(JSON.stringify(cfg.filter)) : null;
|
|
90
|
+
const agentId = getEffectiveAgentId(cfg, ctx);
|
|
91
|
+
|
|
92
|
+
if (agentId) {
|
|
93
|
+
if (filterObj) {
|
|
94
|
+
if (Array.isArray(filterObj.and)) {
|
|
95
|
+
filterObj.and.push({ agent_id: agentId });
|
|
96
|
+
} else {
|
|
97
|
+
filterObj = { and: [filterObj, { agent_id: agentId }] };
|
|
98
|
+
}
|
|
99
|
+
} else {
|
|
100
|
+
filterObj = { agent_id: agentId };
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (filterObj) payload.filter = filterObj;
|
|
105
|
+
|
|
83
106
|
if (cfg.knowledgebaseIds?.length) payload.knowledgebase_ids = cfg.knowledgebaseIds;
|
|
84
107
|
|
|
85
108
|
payload.memory_limit_number = cfg.memoryLimitNumber;
|
|
@@ -100,7 +123,8 @@ function buildAddMessagePayload(cfg, messages, ctx) {
|
|
|
100
123
|
source: MEMOS_SOURCE,
|
|
101
124
|
};
|
|
102
125
|
|
|
103
|
-
|
|
126
|
+
const agentId = getEffectiveAgentId(cfg, ctx);
|
|
127
|
+
if (agentId) payload.agent_id = agentId;
|
|
104
128
|
if (cfg.appId) payload.app_id = cfg.appId;
|
|
105
129
|
if (cfg.tags?.length) payload.tags = cfg.tags;
|
|
106
130
|
|
package/lib/memos-cloud-api.js
CHANGED
|
@@ -142,6 +142,11 @@ export function buildConfig(pluginConfig = {}) {
|
|
|
142
142
|
parseBool(loadEnvVar("MEMOS_CONVERSATION_RESET_ON_NEW"), true),
|
|
143
143
|
);
|
|
144
144
|
|
|
145
|
+
const multiAgentMode = parseBool(
|
|
146
|
+
cfg.multiAgentMode,
|
|
147
|
+
parseBool(loadEnvVar("MEMOS_MULTI_AGENT_MODE"), false),
|
|
148
|
+
);
|
|
149
|
+
|
|
145
150
|
return {
|
|
146
151
|
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
147
152
|
apiKey,
|
|
@@ -178,6 +183,7 @@ export function buildConfig(pluginConfig = {}) {
|
|
|
178
183
|
allowPublic: cfg.allowPublic ?? false,
|
|
179
184
|
allowKnowledgebaseIds: cfg.allowKnowledgebaseIds ?? [],
|
|
180
185
|
asyncMode: cfg.asyncMode ?? true,
|
|
186
|
+
multiAgentMode,
|
|
181
187
|
timeoutMs: cfg.timeoutMs ?? 5000,
|
|
182
188
|
retries: cfg.retries ?? 1,
|
|
183
189
|
throttleMs: cfg.throttleMs ?? 0,
|
package/moltbot.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "memos-cloud-openclaw-plugin",
|
|
3
3
|
"name": "MemOS Cloud OpenClaw Plugin",
|
|
4
4
|
"description": "MemOS Cloud recall + add memory via lifecycle hooks",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.8-beta.0",
|
|
6
6
|
"kind": "lifecycle",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"configSchema": {
|
|
@@ -125,6 +125,10 @@
|
|
|
125
125
|
"agentId": {
|
|
126
126
|
"type": "string"
|
|
127
127
|
},
|
|
128
|
+
"multiAgentMode": {
|
|
129
|
+
"type": "boolean",
|
|
130
|
+
"default": false
|
|
131
|
+
},
|
|
128
132
|
"appId": {
|
|
129
133
|
"type": "string"
|
|
130
134
|
},
|
package/openclaw.plugin.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"id": "memos-cloud-openclaw-plugin",
|
|
3
3
|
"name": "MemOS Cloud OpenClaw Plugin",
|
|
4
4
|
"description": "MemOS Cloud recall + add memory via lifecycle hooks",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.8-beta.0",
|
|
6
6
|
"kind": "lifecycle",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"configSchema": {
|
|
@@ -125,6 +125,10 @@
|
|
|
125
125
|
"agentId": {
|
|
126
126
|
"type": "string"
|
|
127
127
|
},
|
|
128
|
+
"multiAgentMode": {
|
|
129
|
+
"type": "boolean",
|
|
130
|
+
"default": false
|
|
131
|
+
},
|
|
128
132
|
"appId": {
|
|
129
133
|
"type": "string"
|
|
130
134
|
},
|
package/package.json
CHANGED