@memtensor/memos-cloud-openclaw-plugin 0.1.8 → 0.1.10-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 CHANGED
@@ -1,155 +1,175 @@
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_MULTI_AGENT_MODE` (default: `false`; enable multi-agent data isolation)
97
- - `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX` (optional)
98
- - `MEMOS_CONVERSATION_SUFFIX_MODE` (`none` | `counter`, default: `none`)
99
- - `MEMOS_CONVERSATION_RESET_ON_NEW` (default: `true`, requires hooks.internal.enabled)
100
-
101
- ## Optional Plugin Config
102
- In `plugins.entries.memos-cloud-openclaw-plugin.config`:
103
- ```json
104
- {
105
- "baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
106
- "apiKey": "YOUR_API_KEY",
107
- "userId": "memos_user_123",
108
- "conversationId": "openclaw-main",
109
- "queryPrefix": "important user context preferences decisions ",
110
- "recallEnabled": true,
111
- "recallGlobal": true,
112
- "addEnabled": true,
113
- "captureStrategy": "last_turn",
114
- "includeAssistant": true,
115
- "conversationIdPrefix": "",
116
- "conversationIdSuffix": "",
117
- "conversationSuffixMode": "none",
118
- "resetOnNew": true,
119
- "knowledgebaseIds": [],
120
- "memoryLimitNumber": 6,
121
- "preferenceLimitNumber": 6,
122
- "includePreference": true,
123
- "includeToolMemory": false,
124
- "toolMemoryLimitNumber": 6,
125
- "relativity": 0.45,
126
- "tags": ["openclaw"],
127
- "agentId": "",
128
- "multiAgentMode": false,
129
- "asyncMode": true
130
- }
131
- ```
132
-
133
- ## How it Works
134
- - **Recall** (`before_agent_start`)
135
- - Builds a `/search/memory` request using `user_id`, `query` (= prompt + optional prefix), and optional filters.
136
- - Default **global recall**: when `recallGlobal=true`, it does **not** pass `conversation_id`.
137
- - Formats a MemOS prompt (Role/System/Memory/Skill/Protocols) from `/search/memory` results, then injects via `prependContext`.
138
-
139
- - **Add** (`agent_end`)
140
- - Builds a `/add/message` request with the **last turn** by default (user + assistant).
141
- - Sends `messages` with `user_id`, `conversation_id`, and optional `tags/info/agent_id/app_id`.
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
-
150
- ## Notes
151
- - `conversation_id` defaults to OpenClaw `sessionKey` (unless `conversationId` is provided). **TODO**: consider binding to OpenClaw `sessionId` directly.
152
- - Optional **prefix/suffix** via env or config; `conversationSuffixMode=counter` increments on `/new` (requires `hooks.internal.enabled`).
153
-
154
- ## Acknowledgements
155
- - 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_MULTI_AGENT_MODE` (default: `false`; enable multi-agent data isolation)
97
+ - `MEMOS_CONVERSATION_PREFIX` / `MEMOS_CONVERSATION_SUFFIX` (optional)
98
+ - `MEMOS_CONVERSATION_SUFFIX_MODE` (`none` | `counter`, default: `none`)
99
+ - `MEMOS_CONVERSATION_RESET_ON_NEW` (default: `true`, requires hooks.internal.enabled)
100
+ - `MEMOS_RECALL_FILTER_ENABLED` (default: `false`; run model-based memory filtering before injection)
101
+ - `MEMOS_RECALL_FILTER_BASE_URL` (OpenAI-compatible base URL, e.g. `http://127.0.0.1:11434/v1`)
102
+ - `MEMOS_RECALL_FILTER_API_KEY` (optional; required if your endpoint needs auth)
103
+ - `MEMOS_RECALL_FILTER_MODEL` (model name used to filter recall candidates)
104
+ - `MEMOS_RECALL_FILTER_TIMEOUT_MS` (default: `6000`)
105
+ - `MEMOS_RECALL_FILTER_RETRIES` (default: `0`)
106
+ - `MEMOS_RECALL_FILTER_CANDIDATE_LIMIT` (default: `30` per category)
107
+ - `MEMOS_RECALL_FILTER_MAX_ITEM_CHARS` (default: `500`)
108
+ - `MEMOS_RECALL_FILTER_FAIL_OPEN` (default: `true`; fallback to unfiltered recall on failure)
109
+
110
+ ## Optional Plugin Config
111
+ In `plugins.entries.memos-cloud-openclaw-plugin.config`:
112
+ ```json
113
+ {
114
+ "baseUrl": "https://memos.memtensor.cn/api/openmem/v1",
115
+ "apiKey": "YOUR_API_KEY",
116
+ "userId": "memos_user_123",
117
+ "conversationId": "openclaw-main",
118
+ "queryPrefix": "important user context preferences decisions ",
119
+ "recallEnabled": true,
120
+ "recallGlobal": true,
121
+ "addEnabled": true,
122
+ "captureStrategy": "last_turn",
123
+ "maxItemChars": 8000,
124
+ "includeAssistant": true,
125
+ "conversationIdPrefix": "",
126
+ "conversationIdSuffix": "",
127
+ "conversationSuffixMode": "none",
128
+ "resetOnNew": true,
129
+ "knowledgebaseIds": [],
130
+ "memoryLimitNumber": 6,
131
+ "preferenceLimitNumber": 6,
132
+ "includePreference": true,
133
+ "includeToolMemory": false,
134
+ "toolMemoryLimitNumber": 6,
135
+ "relativity": 0.45,
136
+ "tags": ["openclaw"],
137
+ "agentId": "",
138
+ "multiAgentMode": false,
139
+ "asyncMode": true,
140
+ "recallFilterEnabled": false,
141
+ "recallFilterBaseUrl": "http://127.0.0.1:11434/v1",
142
+ "recallFilterApiKey": "",
143
+ "recallFilterModel": "qwen2.5:7b",
144
+ "recallFilterTimeoutMs": 6000,
145
+ "recallFilterRetries": 0,
146
+ "recallFilterCandidateLimit": 30,
147
+ "recallFilterMaxItemChars": 500,
148
+ "recallFilterFailOpen": true
149
+ }
150
+ ```
151
+
152
+ ## How it Works
153
+ - **Recall** (`before_agent_start`)
154
+ - Builds a `/search/memory` request using `user_id`, `query` (= prompt + optional prefix), and optional filters.
155
+ - Default **global recall**: when `recallGlobal=true`, it does **not** pass `conversation_id`.
156
+ - Optional second-pass filtering: if `recallFilterEnabled=true`, candidates are sent to your configured model and only returned `keep` items are injected.
157
+ - Injects a stable MemOS recall protocol via `appendSystemContext`, while the retrieved `<memories>` block remains in `prependContext`.
158
+
159
+ - **Add** (`agent_end`)
160
+ - Builds a `/add/message` request with the **last turn** by default (user + assistant).
161
+ - Sends `messages` with `user_id`, `conversation_id`, and optional `tags/info/agent_id/app_id`.
162
+
163
+ ## Multi-Agent Support
164
+ The plugin provides native support for multi-agent architectures (via the `agent_id` parameter):
165
+ - **Enable Mode**: Set `"multiAgentMode": true` in config or `MEMOS_MULTI_AGENT_MODE=true` in env variables (default is `false`).
166
+ - **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).
167
+ - **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.
168
+ - **Static Override**: You can also force a specific agent ID by setting `"agentId": "your_agent_id"` in the plugin's `config`.
169
+
170
+ ## Notes
171
+ - `conversation_id` defaults to OpenClaw `sessionKey` (unless `conversationId` is provided). **TODO**: consider binding to OpenClaw `sessionId` directly.
172
+ - Optional **prefix/suffix** via env or config; `conversationSuffixMode=counter` increments on `/new` (requires `hooks.internal.enabled`).
173
+
174
+ ## Acknowledgements
175
+ - 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