@memtensor/memos-cloud-openclaw-plugin 0.1.5 → 0.1.7
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/LICENSE +201 -201
- package/README.md +145 -145
- package/README_ZH.md +151 -151
- package/clawdbot.plugin.json +1 -1
- package/index.js +259 -259
- package/lib/memos-cloud-api.js +443 -443
- package/moltbot.plugin.json +1 -1
- package/openclaw.plugin.json +1 -1
- package/package.json +46 -46
- package/scripts/sync-version.js +45 -45
package/README.md
CHANGED
|
@@ -1,145 +1,145 @@
|
|
|
1
|
-
# MemOS Cloud OpenClaw Plugin (Lifecycle)
|
|
2
|
-
|
|
3
|
-
Official plugin maintained by MemTensor.
|
|
4
|
-
|
|
5
|
-
A minimal OpenClaw lifecycle plugin that **recalls** memories from MemOS Cloud before each run and **adds** new messages to MemOS Cloud after each run.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
- **Recall**: `before_agent_start` → `/search/memory`
|
|
9
|
-
- **Add**: `agent_end` → `/add/message`
|
|
10
|
-
- Uses **Token** auth (`Authorization: Token <MEMOS_API_KEY>`)
|
|
11
|
-
|
|
12
|
-
## Install
|
|
13
|
-
|
|
14
|
-
### Option A — NPM (Recommended)
|
|
15
|
-
```bash
|
|
16
|
-
openclaw plugins install @memtensor/memos-cloud-openclaw-plugin@latest
|
|
17
|
-
openclaw gateway restart
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
> **Note for Windows Users**:
|
|
21
|
-
> If you encounter `Error: spawn EINVAL`, this is a known issue with OpenClaw's plugin installer on Windows. Please use **Option B** (Manual Install) below.
|
|
22
|
-
|
|
23
|
-
Make sure it’s enabled in `~/.openclaw/openclaw.json`:
|
|
24
|
-
```json
|
|
25
|
-
{
|
|
26
|
-
"plugins": {
|
|
27
|
-
"entries": {
|
|
28
|
-
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
### Option B — Manual Install (Workaround for Windows)
|
|
35
|
-
1. Download the latest `.tgz` from [NPM](https://www.npmjs.com/package/@memtensor/memos-cloud-openclaw-plugin).
|
|
36
|
-
2. Extract it to a local folder (e.g., `C:\Users\YourName\.openclaw\extensions\memos-cloud-openclaw-plugin`).
|
|
37
|
-
3. Configure `~/.openclaw/openclaw.json` (or `%USERPROFILE%\.openclaw\openclaw.json`):
|
|
38
|
-
|
|
39
|
-
```json
|
|
40
|
-
{
|
|
41
|
-
"plugins": {
|
|
42
|
-
"entries": {
|
|
43
|
-
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
44
|
-
},
|
|
45
|
-
"load": {
|
|
46
|
-
"paths": [
|
|
47
|
-
"C:\\Users\\YourName\\.openclaw\\extensions\\memos-cloud-openclaw-plugin\\package"
|
|
48
|
-
]
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
*Note: The extracted folder usually contains a `package` subfolder. Point to the folder containing `package.json`.*
|
|
54
|
-
|
|
55
|
-
Restart the gateway after config changes.
|
|
56
|
-
|
|
57
|
-
## Environment Variables
|
|
58
|
-
The plugin tries env files in order (**openclaw → moltbot → clawdbot**). For each key, the first file with a value wins.
|
|
59
|
-
If none of these files exist (or the key is missing), it falls back to the process environment.
|
|
60
|
-
|
|
61
|
-
**Where to configure**
|
|
62
|
-
- Files (priority order):
|
|
63
|
-
- `~/.openclaw/.env`
|
|
64
|
-
- `~/.moltbot/.env`
|
|
65
|
-
- `~/.clawdbot/.env`
|
|
66
|
-
- Each line is `KEY=value`
|
|
67
|
-
|
|
68
|
-
**Quick setup (shell)**
|
|
69
|
-
```bash
|
|
70
|
-
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.zshrc
|
|
71
|
-
source ~/.zshrc
|
|
72
|
-
# or
|
|
73
|
-
|
|
74
|
-
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.bashrc
|
|
75
|
-
source ~/.bashrc
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
**Quick setup (Windows PowerShell)**
|
|
79
|
-
```powershell
|
|
80
|
-
[System.Environment]::SetEnvironmentVariable("MEMOS_API_KEY", "mpg-...", "User")
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
If `MEMOS_API_KEY` is missing, the plugin will warn with setup instructions and the API key URL.
|
|
84
|
-
|
|
85
|
-
**Minimal config**
|
|
86
|
-
```env
|
|
87
|
-
MEMOS_API_KEY=YOUR_TOKEN
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
**Optional config**
|
|
91
|
-
- `MEMOS_BASE_URL` (default: `https://memos.memtensor.cn/api/openmem/v1`)
|
|
92
|
-
- `MEMOS_API_KEY` (required; Token auth) — get it at https://memos-dashboard.openmem.net/cn/apikeys/
|
|
93
|
-
- `MEMOS_USER_ID` (optional; default: `openclaw-user`)
|
|
94
|
-
- `MEMOS_CONVERSATION_ID` (optional override)
|
|
95
|
-
- `MEMOS_RECALL_GLOBAL` (default: `true`; when true, search does **not** pass conversation_id)
|
|
96
|
-
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX` (optional)
|
|
97
|
-
- `MEMOS_CONVERSATION_SUFFIX_MODE` (`none` | `counter`, default: `none`)
|
|
98
|
-
- `MEMOS_CONVERSATION_RESET_ON_NEW` (default: `true`, requires hooks.internal.enabled)
|
|
99
|
-
|
|
100
|
-
## Optional Plugin Config
|
|
101
|
-
In `plugins.entries.memos-cloud-openclaw-plugin.config`:
|
|
102
|
-
```json
|
|
103
|
-
{
|
|
104
|
-
"baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
|
|
105
|
-
"apiKey": "YOUR_API_KEY",
|
|
106
|
-
"userId": "memos_user_123",
|
|
107
|
-
"conversationId": "openclaw-main",
|
|
108
|
-
"queryPrefix": "important user context preferences decisions ",
|
|
109
|
-
"recallEnabled": true,
|
|
110
|
-
"recallGlobal": true,
|
|
111
|
-
"addEnabled": true,
|
|
112
|
-
"captureStrategy": "last_turn",
|
|
113
|
-
"includeAssistant": true,
|
|
114
|
-
"conversationIdPrefix": "",
|
|
115
|
-
"conversationIdSuffix": "",
|
|
116
|
-
"conversationSuffixMode": "none",
|
|
117
|
-
"resetOnNew": true,
|
|
118
|
-
"knowledgebaseIds": [],
|
|
119
|
-
"memoryLimitNumber": 6,
|
|
120
|
-
"preferenceLimitNumber": 6,
|
|
121
|
-
"includePreference": true,
|
|
122
|
-
"includeToolMemory": false,
|
|
123
|
-
"toolMemoryLimitNumber": 6,
|
|
124
|
-
"relativity": 0.45,
|
|
125
|
-
"tags": ["openclaw"],
|
|
126
|
-
"asyncMode": true
|
|
127
|
-
}
|
|
128
|
-
```
|
|
129
|
-
|
|
130
|
-
## How it Works
|
|
131
|
-
- **Recall** (`before_agent_start`)
|
|
132
|
-
- Builds a `/search/memory` request using `user_id`, `query` (= prompt + optional prefix), and optional filters.
|
|
133
|
-
- Default **global recall**: when `recallGlobal=true`, it does **not** pass `conversation_id`.
|
|
134
|
-
- Formats a MemOS prompt (Role/System/Memory/Skill/Protocols) from `/search/memory` results, then injects via `prependContext`.
|
|
135
|
-
|
|
136
|
-
- **Add** (`agent_end`)
|
|
137
|
-
- Builds a `/add/message` request with the **last turn** by default (user + assistant).
|
|
138
|
-
- Sends `messages` with `user_id`, `conversation_id`, and optional `tags/info/agent_id/app_id`.
|
|
139
|
-
|
|
140
|
-
## Notes
|
|
141
|
-
- `conversation_id` defaults to OpenClaw `sessionKey` (unless `conversationId` is provided). **TODO**: consider binding to OpenClaw `sessionId` directly.
|
|
142
|
-
- Optional **prefix/suffix** via env or config; `conversationSuffixMode=counter` increments on `/new` (requires `hooks.internal.enabled`).
|
|
143
|
-
|
|
144
|
-
## Acknowledgements
|
|
145
|
-
- Thanks to @anatolykoptev (Contributor) — LinkedIn: https://www.linkedin.com/in/koptev?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app
|
|
1
|
+
# MemOS Cloud OpenClaw Plugin (Lifecycle)
|
|
2
|
+
|
|
3
|
+
Official plugin maintained by MemTensor.
|
|
4
|
+
|
|
5
|
+
A minimal OpenClaw lifecycle plugin that **recalls** memories from MemOS Cloud before each run and **adds** new messages to MemOS Cloud after each run.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
- **Recall**: `before_agent_start` → `/search/memory`
|
|
9
|
+
- **Add**: `agent_end` → `/add/message`
|
|
10
|
+
- Uses **Token** auth (`Authorization: Token <MEMOS_API_KEY>`)
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
### Option A — NPM (Recommended)
|
|
15
|
+
```bash
|
|
16
|
+
openclaw plugins install @memtensor/memos-cloud-openclaw-plugin@latest
|
|
17
|
+
openclaw gateway restart
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
> **Note for Windows Users**:
|
|
21
|
+
> If you encounter `Error: spawn EINVAL`, this is a known issue with OpenClaw's plugin installer on Windows. Please use **Option B** (Manual Install) below.
|
|
22
|
+
|
|
23
|
+
Make sure it’s enabled in `~/.openclaw/openclaw.json`:
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"plugins": {
|
|
27
|
+
"entries": {
|
|
28
|
+
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Option B — Manual Install (Workaround for Windows)
|
|
35
|
+
1. Download the latest `.tgz` from [NPM](https://www.npmjs.com/package/@memtensor/memos-cloud-openclaw-plugin).
|
|
36
|
+
2. Extract it to a local folder (e.g., `C:\Users\YourName\.openclaw\extensions\memos-cloud-openclaw-plugin`).
|
|
37
|
+
3. Configure `~/.openclaw/openclaw.json` (or `%USERPROFILE%\.openclaw\openclaw.json`):
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"plugins": {
|
|
42
|
+
"entries": {
|
|
43
|
+
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
44
|
+
},
|
|
45
|
+
"load": {
|
|
46
|
+
"paths": [
|
|
47
|
+
"C:\\Users\\YourName\\.openclaw\\extensions\\memos-cloud-openclaw-plugin\\package"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
*Note: The extracted folder usually contains a `package` subfolder. Point to the folder containing `package.json`.*
|
|
54
|
+
|
|
55
|
+
Restart the gateway after config changes.
|
|
56
|
+
|
|
57
|
+
## Environment Variables
|
|
58
|
+
The plugin tries env files in order (**openclaw → moltbot → clawdbot**). For each key, the first file with a value wins.
|
|
59
|
+
If none of these files exist (or the key is missing), it falls back to the process environment.
|
|
60
|
+
|
|
61
|
+
**Where to configure**
|
|
62
|
+
- Files (priority order):
|
|
63
|
+
- `~/.openclaw/.env`
|
|
64
|
+
- `~/.moltbot/.env`
|
|
65
|
+
- `~/.clawdbot/.env`
|
|
66
|
+
- Each line is `KEY=value`
|
|
67
|
+
|
|
68
|
+
**Quick setup (shell)**
|
|
69
|
+
```bash
|
|
70
|
+
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.zshrc
|
|
71
|
+
source ~/.zshrc
|
|
72
|
+
# or
|
|
73
|
+
|
|
74
|
+
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.bashrc
|
|
75
|
+
source ~/.bashrc
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Quick setup (Windows PowerShell)**
|
|
79
|
+
```powershell
|
|
80
|
+
[System.Environment]::SetEnvironmentVariable("MEMOS_API_KEY", "mpg-...", "User")
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If `MEMOS_API_KEY` is missing, the plugin will warn with setup instructions and the API key URL.
|
|
84
|
+
|
|
85
|
+
**Minimal config**
|
|
86
|
+
```env
|
|
87
|
+
MEMOS_API_KEY=YOUR_TOKEN
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
**Optional config**
|
|
91
|
+
- `MEMOS_BASE_URL` (default: `https://memos.memtensor.cn/api/openmem/v1`)
|
|
92
|
+
- `MEMOS_API_KEY` (required; Token auth) — get it at https://memos-dashboard.openmem.net/cn/apikeys/
|
|
93
|
+
- `MEMOS_USER_ID` (optional; default: `openclaw-user`)
|
|
94
|
+
- `MEMOS_CONVERSATION_ID` (optional override)
|
|
95
|
+
- `MEMOS_RECALL_GLOBAL` (default: `true`; when true, search does **not** pass conversation_id)
|
|
96
|
+
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX` (optional)
|
|
97
|
+
- `MEMOS_CONVERSATION_SUFFIX_MODE` (`none` | `counter`, default: `none`)
|
|
98
|
+
- `MEMOS_CONVERSATION_RESET_ON_NEW` (default: `true`, requires hooks.internal.enabled)
|
|
99
|
+
|
|
100
|
+
## Optional Plugin Config
|
|
101
|
+
In `plugins.entries.memos-cloud-openclaw-plugin.config`:
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
|
|
105
|
+
"apiKey": "YOUR_API_KEY",
|
|
106
|
+
"userId": "memos_user_123",
|
|
107
|
+
"conversationId": "openclaw-main",
|
|
108
|
+
"queryPrefix": "important user context preferences decisions ",
|
|
109
|
+
"recallEnabled": true,
|
|
110
|
+
"recallGlobal": true,
|
|
111
|
+
"addEnabled": true,
|
|
112
|
+
"captureStrategy": "last_turn",
|
|
113
|
+
"includeAssistant": true,
|
|
114
|
+
"conversationIdPrefix": "",
|
|
115
|
+
"conversationIdSuffix": "",
|
|
116
|
+
"conversationSuffixMode": "none",
|
|
117
|
+
"resetOnNew": true,
|
|
118
|
+
"knowledgebaseIds": [],
|
|
119
|
+
"memoryLimitNumber": 6,
|
|
120
|
+
"preferenceLimitNumber": 6,
|
|
121
|
+
"includePreference": true,
|
|
122
|
+
"includeToolMemory": false,
|
|
123
|
+
"toolMemoryLimitNumber": 6,
|
|
124
|
+
"relativity": 0.45,
|
|
125
|
+
"tags": ["openclaw"],
|
|
126
|
+
"asyncMode": true
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## How it Works
|
|
131
|
+
- **Recall** (`before_agent_start`)
|
|
132
|
+
- Builds a `/search/memory` request using `user_id`, `query` (= prompt + optional prefix), and optional filters.
|
|
133
|
+
- Default **global recall**: when `recallGlobal=true`, it does **not** pass `conversation_id`.
|
|
134
|
+
- Formats a MemOS prompt (Role/System/Memory/Skill/Protocols) from `/search/memory` results, then injects via `prependContext`.
|
|
135
|
+
|
|
136
|
+
- **Add** (`agent_end`)
|
|
137
|
+
- Builds a `/add/message` request with the **last turn** by default (user + assistant).
|
|
138
|
+
- Sends `messages` with `user_id`, `conversation_id`, and optional `tags/info/agent_id/app_id`.
|
|
139
|
+
|
|
140
|
+
## Notes
|
|
141
|
+
- `conversation_id` defaults to OpenClaw `sessionKey` (unless `conversationId` is provided). **TODO**: consider binding to OpenClaw `sessionId` directly.
|
|
142
|
+
- Optional **prefix/suffix** via env or config; `conversationSuffixMode=counter` increments on `/new` (requires `hooks.internal.enabled`).
|
|
143
|
+
|
|
144
|
+
## Acknowledgements
|
|
145
|
+
- Thanks to @anatolykoptev (Contributor) — LinkedIn: https://www.linkedin.com/in/koptev?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app
|
package/README_ZH.md
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
# MemOS Cloud OpenClaw Plugin(Lifecycle 插件)
|
|
2
|
-
|
|
3
|
-
官方维护:MemTensor。
|
|
4
|
-
|
|
5
|
-
这是一个最小可用的 OpenClaw lifecycle 插件,功能是:
|
|
6
|
-
- **召回记忆**:在每轮对话前从 MemOS Cloud 检索记忆并注入上下文
|
|
7
|
-
- **添加记忆**:在每轮对话结束后把消息写回 MemOS Cloud
|
|
8
|
-
|
|
9
|
-
## 功能
|
|
10
|
-
- **Recall**:`before_agent_start` → `/search/memory`
|
|
11
|
-
- **Add**:`agent_end` → `/add/message`
|
|
12
|
-
- 使用 **Token** 认证(`Authorization: Token <MEMOS_API_KEY>`)
|
|
13
|
-
|
|
14
|
-
## 安装
|
|
15
|
-
|
|
16
|
-
### 方式 A — NPM(推荐)
|
|
17
|
-
```bash
|
|
18
|
-
openclaw plugins install @memtensor/memos-cloud-openclaw-plugin@latest
|
|
19
|
-
openclaw gateway restart
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
> **Windows 用户注意**:
|
|
23
|
-
> 如果遇到 `Error: spawn EINVAL` 报错,这是 OpenClaw Windows 安装器的已知问题。请使用下方的 **方式 B**(手动安装)。
|
|
24
|
-
|
|
25
|
-
确认 `~/.openclaw/openclaw.json` 中已启用:
|
|
26
|
-
```json
|
|
27
|
-
{
|
|
28
|
-
"plugins": {
|
|
29
|
-
"entries": {
|
|
30
|
-
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
### 方式 B — 手动安装(Windows 解决方案)
|
|
37
|
-
1. 从 [NPM](https://www.npmjs.com/package/@memtensor/memos-cloud-openclaw-plugin) 下载最新的 `.tgz` 包。
|
|
38
|
-
2. 解压到本地目录(例如 `C:\Users\YourName\.openclaw\extensions\memos-cloud-openclaw-plugin`)。
|
|
39
|
-
3. 修改配置 `~/.openclaw/openclaw.json`(或 `%USERPROFILE%\.openclaw\openclaw.json`):
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"plugins": {
|
|
44
|
-
"entries": {
|
|
45
|
-
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
46
|
-
},
|
|
47
|
-
"load": {
|
|
48
|
-
"paths": [
|
|
49
|
-
"C:\\Users\\YourName\\.openclaw\\extensions\\memos-cloud-openclaw-plugin\\package"
|
|
50
|
-
]
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
*注意:解压后的文件夹通常包含一个 `package` 子文件夹,请指向包含 `package.json` 的那层目录。*
|
|
56
|
-
|
|
57
|
-
修改配置后需要重启 gateway。
|
|
58
|
-
|
|
59
|
-
## 环境变量
|
|
60
|
-
插件按顺序读取 env 文件(**openclaw → moltbot → clawdbot**),每个键优先使用最先匹配到的值。
|
|
61
|
-
若三个文件都不存在(或该键未找到),才会回退到进程环境变量。
|
|
62
|
-
|
|
63
|
-
**配置位置**
|
|
64
|
-
- 文件(优先级顺序):
|
|
65
|
-
- `~/.openclaw/.env`
|
|
66
|
-
- `~/.moltbot/.env`
|
|
67
|
-
- `~/.clawdbot/.env`
|
|
68
|
-
- 每行格式:`KEY=value`
|
|
69
|
-
|
|
70
|
-
**快速配置(Shell)**
|
|
71
|
-
```bash
|
|
72
|
-
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.zshrc
|
|
73
|
-
source ~/.zshrc
|
|
74
|
-
# 或者
|
|
75
|
-
|
|
76
|
-
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.bashrc
|
|
77
|
-
source ~/.bashrc
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
**快速配置(Windows PowerShell)**
|
|
81
|
-
```powershell
|
|
82
|
-
[System.Environment]::SetEnvironmentVariable("MEMOS_API_KEY", "mpg-...", "User")
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
若未读取到 `MEMOS_API_KEY`,插件会提示配置方式并附 API Key 获取地址。
|
|
86
|
-
|
|
87
|
-
**最小配置**
|
|
88
|
-
```env
|
|
89
|
-
MEMOS_API_KEY=YOUR_TOKEN
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
**可选配置**
|
|
93
|
-
- `MEMOS_BASE_URL`(默认 `https://memos.memtensor.cn/api/openmem/v1`)
|
|
94
|
-
- `MEMOS_API_KEY`(必填,Token 认证)—— 获取地址:https://memos-dashboard.openmem.net/cn/apikeys/
|
|
95
|
-
- `MEMOS_USER_ID`(可选,默认 `openclaw-user`)
|
|
96
|
-
- `MEMOS_CONVERSATION_ID`(可选覆盖)
|
|
97
|
-
- `MEMOS_RECALL_GLOBAL`(默认 `true`;为 true 时检索不传 conversation_id)
|
|
98
|
-
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX`(可选)
|
|
99
|
-
- `MEMOS_CONVERSATION_SUFFIX_MODE`(`none` | `counter`,默认 `none`)
|
|
100
|
-
- `MEMOS_CONVERSATION_RESET_ON_NEW`(默认 `true`,需 hooks.internal.enabled)
|
|
101
|
-
|
|
102
|
-
## 可选插件配置
|
|
103
|
-
在 `plugins.entries.memos-cloud-openclaw-plugin.config` 中设置:
|
|
104
|
-
```json
|
|
105
|
-
{
|
|
106
|
-
"baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
|
|
107
|
-
"apiKey": "YOUR_API_KEY",
|
|
108
|
-
"userId": "memos_user_123",
|
|
109
|
-
"conversationId": "openclaw-main",
|
|
110
|
-
"queryPrefix": "important user context preferences decisions ",
|
|
111
|
-
"recallEnabled": true,
|
|
112
|
-
"recallGlobal": true,
|
|
113
|
-
"addEnabled": true,
|
|
114
|
-
"captureStrategy": "last_turn",
|
|
115
|
-
"includeAssistant": true,
|
|
116
|
-
"conversationIdPrefix": "",
|
|
117
|
-
"conversationIdSuffix": "",
|
|
118
|
-
"conversationSuffixMode": "none",
|
|
119
|
-
"resetOnNew": true,
|
|
120
|
-
"memoryLimitNumber": 6,
|
|
121
|
-
"preferenceLimitNumber": 6,
|
|
122
|
-
"knowledgebaseIds": [],
|
|
123
|
-
"includePreference": true,
|
|
124
|
-
"includeToolMemory": false,
|
|
125
|
-
"toolMemoryLimitNumber": 6,
|
|
126
|
-
"tags": ["openclaw"],
|
|
127
|
-
"asyncMode": true
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## 工作原理
|
|
132
|
-
### 1) 召回(before_agent_start)
|
|
133
|
-
- 组装 `/search/memory` 请求
|
|
134
|
-
- `user_id`、`query`(= prompt + 可选前缀)
|
|
135
|
-
- 默认**全局召回**:`recallGlobal=true` 时不传 `conversation_id`
|
|
136
|
-
- 可选 `filter` / `knowledgebase_ids`
|
|
137
|
-
- 使用 `/search/memory` 结果按 MemOS 提示词模板(Role/System/Memory/Skill/Protocols)拼装,并通过 `prependContext` 注入
|
|
138
|
-
|
|
139
|
-
### 2) 添加(agent_end)
|
|
140
|
-
- 默认只写**最后一轮**(user + assistant)
|
|
141
|
-
- 构造 `/add/message` 请求:
|
|
142
|
-
- `user_id`、`conversation_id`
|
|
143
|
-
- `messages` 列表
|
|
144
|
-
- 可选 `tags / info / agent_id / app_id`
|
|
145
|
-
|
|
146
|
-
## 说明
|
|
147
|
-
- 未显式指定 `conversation_id` 时,默认使用 OpenClaw `sessionKey`。**TODO**:后续考虑直接绑定 OpenClaw `sessionId`。
|
|
148
|
-
- 可配置前后缀;`conversationSuffixMode=counter` 时会在 `/new` 递增(需 `hooks.internal.enabled`)。
|
|
149
|
-
|
|
150
|
-
## 致谢
|
|
151
|
-
- 感谢 @anatolykoptev(Contributor)— 领英:https://www.linkedin.com/in/koptev?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app
|
|
1
|
+
# MemOS Cloud OpenClaw Plugin(Lifecycle 插件)
|
|
2
|
+
|
|
3
|
+
官方维护:MemTensor。
|
|
4
|
+
|
|
5
|
+
这是一个最小可用的 OpenClaw lifecycle 插件,功能是:
|
|
6
|
+
- **召回记忆**:在每轮对话前从 MemOS Cloud 检索记忆并注入上下文
|
|
7
|
+
- **添加记忆**:在每轮对话结束后把消息写回 MemOS Cloud
|
|
8
|
+
|
|
9
|
+
## 功能
|
|
10
|
+
- **Recall**:`before_agent_start` → `/search/memory`
|
|
11
|
+
- **Add**:`agent_end` → `/add/message`
|
|
12
|
+
- 使用 **Token** 认证(`Authorization: Token <MEMOS_API_KEY>`)
|
|
13
|
+
|
|
14
|
+
## 安装
|
|
15
|
+
|
|
16
|
+
### 方式 A — NPM(推荐)
|
|
17
|
+
```bash
|
|
18
|
+
openclaw plugins install @memtensor/memos-cloud-openclaw-plugin@latest
|
|
19
|
+
openclaw gateway restart
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> **Windows 用户注意**:
|
|
23
|
+
> 如果遇到 `Error: spawn EINVAL` 报错,这是 OpenClaw Windows 安装器的已知问题。请使用下方的 **方式 B**(手动安装)。
|
|
24
|
+
|
|
25
|
+
确认 `~/.openclaw/openclaw.json` 中已启用:
|
|
26
|
+
```json
|
|
27
|
+
{
|
|
28
|
+
"plugins": {
|
|
29
|
+
"entries": {
|
|
30
|
+
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 方式 B — 手动安装(Windows 解决方案)
|
|
37
|
+
1. 从 [NPM](https://www.npmjs.com/package/@memtensor/memos-cloud-openclaw-plugin) 下载最新的 `.tgz` 包。
|
|
38
|
+
2. 解压到本地目录(例如 `C:\Users\YourName\.openclaw\extensions\memos-cloud-openclaw-plugin`)。
|
|
39
|
+
3. 修改配置 `~/.openclaw/openclaw.json`(或 `%USERPROFILE%\.openclaw\openclaw.json`):
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"plugins": {
|
|
44
|
+
"entries": {
|
|
45
|
+
"memos-cloud-openclaw-plugin": { "enabled": true }
|
|
46
|
+
},
|
|
47
|
+
"load": {
|
|
48
|
+
"paths": [
|
|
49
|
+
"C:\\Users\\YourName\\.openclaw\\extensions\\memos-cloud-openclaw-plugin\\package"
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
*注意:解压后的文件夹通常包含一个 `package` 子文件夹,请指向包含 `package.json` 的那层目录。*
|
|
56
|
+
|
|
57
|
+
修改配置后需要重启 gateway。
|
|
58
|
+
|
|
59
|
+
## 环境变量
|
|
60
|
+
插件按顺序读取 env 文件(**openclaw → moltbot → clawdbot**),每个键优先使用最先匹配到的值。
|
|
61
|
+
若三个文件都不存在(或该键未找到),才会回退到进程环境变量。
|
|
62
|
+
|
|
63
|
+
**配置位置**
|
|
64
|
+
- 文件(优先级顺序):
|
|
65
|
+
- `~/.openclaw/.env`
|
|
66
|
+
- `~/.moltbot/.env`
|
|
67
|
+
- `~/.clawdbot/.env`
|
|
68
|
+
- 每行格式:`KEY=value`
|
|
69
|
+
|
|
70
|
+
**快速配置(Shell)**
|
|
71
|
+
```bash
|
|
72
|
+
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.zshrc
|
|
73
|
+
source ~/.zshrc
|
|
74
|
+
# 或者
|
|
75
|
+
|
|
76
|
+
echo 'export MEMOS_API_KEY="mpg-..."' >> ~/.bashrc
|
|
77
|
+
source ~/.bashrc
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**快速配置(Windows PowerShell)**
|
|
81
|
+
```powershell
|
|
82
|
+
[System.Environment]::SetEnvironmentVariable("MEMOS_API_KEY", "mpg-...", "User")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
若未读取到 `MEMOS_API_KEY`,插件会提示配置方式并附 API Key 获取地址。
|
|
86
|
+
|
|
87
|
+
**最小配置**
|
|
88
|
+
```env
|
|
89
|
+
MEMOS_API_KEY=YOUR_TOKEN
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**可选配置**
|
|
93
|
+
- `MEMOS_BASE_URL`(默认 `https://memos.memtensor.cn/api/openmem/v1`)
|
|
94
|
+
- `MEMOS_API_KEY`(必填,Token 认证)—— 获取地址:https://memos-dashboard.openmem.net/cn/apikeys/
|
|
95
|
+
- `MEMOS_USER_ID`(可选,默认 `openclaw-user`)
|
|
96
|
+
- `MEMOS_CONVERSATION_ID`(可选覆盖)
|
|
97
|
+
- `MEMOS_RECALL_GLOBAL`(默认 `true`;为 true 时检索不传 conversation_id)
|
|
98
|
+
- `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX`(可选)
|
|
99
|
+
- `MEMOS_CONVERSATION_SUFFIX_MODE`(`none` | `counter`,默认 `none`)
|
|
100
|
+
- `MEMOS_CONVERSATION_RESET_ON_NEW`(默认 `true`,需 hooks.internal.enabled)
|
|
101
|
+
|
|
102
|
+
## 可选插件配置
|
|
103
|
+
在 `plugins.entries.memos-cloud-openclaw-plugin.config` 中设置:
|
|
104
|
+
```json
|
|
105
|
+
{
|
|
106
|
+
"baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
|
|
107
|
+
"apiKey": "YOUR_API_KEY",
|
|
108
|
+
"userId": "memos_user_123",
|
|
109
|
+
"conversationId": "openclaw-main",
|
|
110
|
+
"queryPrefix": "important user context preferences decisions ",
|
|
111
|
+
"recallEnabled": true,
|
|
112
|
+
"recallGlobal": true,
|
|
113
|
+
"addEnabled": true,
|
|
114
|
+
"captureStrategy": "last_turn",
|
|
115
|
+
"includeAssistant": true,
|
|
116
|
+
"conversationIdPrefix": "",
|
|
117
|
+
"conversationIdSuffix": "",
|
|
118
|
+
"conversationSuffixMode": "none",
|
|
119
|
+
"resetOnNew": true,
|
|
120
|
+
"memoryLimitNumber": 6,
|
|
121
|
+
"preferenceLimitNumber": 6,
|
|
122
|
+
"knowledgebaseIds": [],
|
|
123
|
+
"includePreference": true,
|
|
124
|
+
"includeToolMemory": false,
|
|
125
|
+
"toolMemoryLimitNumber": 6,
|
|
126
|
+
"tags": ["openclaw"],
|
|
127
|
+
"asyncMode": true
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## 工作原理
|
|
132
|
+
### 1) 召回(before_agent_start)
|
|
133
|
+
- 组装 `/search/memory` 请求
|
|
134
|
+
- `user_id`、`query`(= prompt + 可选前缀)
|
|
135
|
+
- 默认**全局召回**:`recallGlobal=true` 时不传 `conversation_id`
|
|
136
|
+
- 可选 `filter` / `knowledgebase_ids`
|
|
137
|
+
- 使用 `/search/memory` 结果按 MemOS 提示词模板(Role/System/Memory/Skill/Protocols)拼装,并通过 `prependContext` 注入
|
|
138
|
+
|
|
139
|
+
### 2) 添加(agent_end)
|
|
140
|
+
- 默认只写**最后一轮**(user + assistant)
|
|
141
|
+
- 构造 `/add/message` 请求:
|
|
142
|
+
- `user_id`、`conversation_id`
|
|
143
|
+
- `messages` 列表
|
|
144
|
+
- 可选 `tags / info / agent_id / app_id`
|
|
145
|
+
|
|
146
|
+
## 说明
|
|
147
|
+
- 未显式指定 `conversation_id` 时,默认使用 OpenClaw `sessionKey`。**TODO**:后续考虑直接绑定 OpenClaw `sessionId`。
|
|
148
|
+
- 可配置前后缀;`conversationSuffixMode=counter` 时会在 `/new` 递增(需 `hooks.internal.enabled`)。
|
|
149
|
+
|
|
150
|
+
## 致谢
|
|
151
|
+
- 感谢 @anatolykoptev(Contributor)— 领英:https://www.linkedin.com/in/koptev?utm_source=share&utm_campaign=share_via&utm_content=profile&utm_medium=ios_app
|
package/clawdbot.plugin.json
CHANGED