@matrixorigin/thememoria 0.4.0 → 0.4.1
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 +109 -263
- package/openclaw/__tests__/client.test.ts +69 -0
- package/openclaw/__tests__/config.test.ts +173 -0
- package/openclaw/__tests__/format.test.ts +149 -0
- package/openclaw/__tests__/helpers.ts +126 -0
- package/openclaw/__tests__/http-client.test.ts +290 -0
- package/openclaw/__tests__/parsers.test.ts +197 -0
- package/openclaw/client.ts +27 -11
- package/openclaw/config.ts +16 -8
- package/openclaw/http-client.ts +453 -0
- package/openclaw/index.ts +55 -32
- package/openclaw.plugin.json +8 -8
- package/package.json +10 -1
- package/scripts/connect_openclaw_memoria.mjs +51 -5
- package/scripts/install-openclaw-memoria.sh +13 -4
- package/scripts/uninstall-openclaw-memoria.sh +7 -7
- package/scripts/verify_plugin_install.mjs +3 -3
package/README.md
CHANGED
|
@@ -2,165 +2,90 @@
|
|
|
2
2
|
|
|
3
3
|
This package turns [MatrixOrigin Memoria](https://github.com/matrixorigin/Memoria) into an installable OpenClaw `memory` plugin.
|
|
4
4
|
|
|
5
|
-
The plugin targets the current Rust Memoria CLI and API release line. Installer release tag is configurable via `--memoria-version` / `MEMORIA_RELEASE_TAG`. There is no bundled Python runtime, no virtualenv, and no `pip install` step.
|
|
6
|
-
|
|
7
5
|
## Architecture
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
| Backend | Transport | Binary needed | Use case |
|
|
8
|
+
|---------|-----------|---------------|----------|
|
|
9
|
+
| `embedded` | Rust `memoria` CLI → local MatrixOne DB | Yes | Self-hosted / local dev |
|
|
10
|
+
| `api` | Direct HTTP → Memoria REST API | No | Cloud OpenClaw, any environment |
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
api mode:
|
|
14
|
+
Plugin → MemoriaHttpTransport → fetch() → Memoria REST API
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
embedded mode:
|
|
17
|
+
Plugin → MemoriaMcpSession → spawn("memoria mcp") → local MatrixOne DB
|
|
18
|
+
```
|
|
14
19
|
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- the plugin shells out to the `memoria` binary
|
|
18
|
-
-
|
|
20
|
+
- Durable memory lives in MatrixOne
|
|
21
|
+
- Snapshots, rollback, branches, merge, diff, governance, reflect, and entity extraction are handled by Memoria
|
|
22
|
+
- In `embedded` mode the plugin shells out to the `memoria` binary via MCP stdio
|
|
23
|
+
- In `api` mode the plugin calls the Memoria REST API directly — no binary needed
|
|
24
|
+
- OpenClaw keeps its own tool and hook surface; the storage backend is Memoria
|
|
19
25
|
|
|
20
26
|
## Quick Start
|
|
21
27
|
|
|
22
|
-
###
|
|
23
|
-
|
|
24
|
-
Verify prerequisites before installing:
|
|
28
|
+
### Prerequisites
|
|
25
29
|
|
|
26
30
|
```bash
|
|
27
31
|
openclaw --version
|
|
28
32
|
# -> OpenClaw vX.Y.Z (CLI is installed and in PATH)
|
|
29
|
-
|
|
30
|
-
memoria --version 2>/dev/null || echo "not installed (installer can install it)"
|
|
31
|
-
# -> memoria X.Y.Z or fallback message
|
|
32
|
-
|
|
33
|
-
openclaw plugins list
|
|
34
|
-
# -> command succeeds and prints plugin table
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
### Usage Paths
|
|
40
|
-
|
|
41
|
-
1. GitHub README (this file): cloud-first setup plus local setup.
|
|
42
|
-
2. OpenClaw chat/agent: user asks agent to install, agent runs commands and returns raw outputs.
|
|
43
|
-
|
|
44
|
-
### 1) Cloud (Recommended)
|
|
45
|
-
|
|
46
|
-
Cloud is the default path for new users.
|
|
35
|
+
### Cloud Setup (Recommended)
|
|
47
36
|
|
|
48
|
-
|
|
37
|
+
Cloud mode connects directly to the Memoria REST API. No binary download needed.
|
|
49
38
|
|
|
50
39
|
```bash
|
|
51
|
-
#
|
|
52
|
-
openclaw plugins uninstall memory-memoria
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
```bash
|
|
56
|
-
# A0.5. Ensure memoria CLI exists (required even for cloud mode)
|
|
57
|
-
command -v memoria >/dev/null || \
|
|
58
|
-
curl -sSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/scripts/install.sh | bash -s -- -y -d ~/.local/bin
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# A1. Install plugin from npm
|
|
40
|
+
# 1. Install plugin
|
|
63
41
|
openclaw plugins install @matrixorigin/thememoria
|
|
64
|
-
openclaw plugins enable memory-memoria
|
|
65
|
-
# Note: OpenClaw may print "Restart the gateway to apply."
|
|
66
|
-
# This is unnecessary for CLI commands like `setup` below, but harmless if you do restart.
|
|
67
|
-
```
|
|
68
42
|
|
|
69
|
-
|
|
70
|
-
# A2. If npm package is unavailable, use source-link instead
|
|
71
|
-
mkdir -p ~/.openclaw/plugins-src
|
|
72
|
-
if [ ! -d ~/.openclaw/plugins-src/Memoria/.git ]; then
|
|
73
|
-
git clone https://github.com/matrixorigin/Memoria.git ~/.openclaw/plugins-src/Memoria
|
|
74
|
-
else
|
|
75
|
-
git -C ~/.openclaw/plugins-src/Memoria pull --ff-only
|
|
76
|
-
fi
|
|
77
|
-
openclaw plugins install --link ~/.openclaw/plugins-src/Memoria/plugins/openclaw
|
|
78
|
-
openclaw plugins enable memory-memoria
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# B. Setup Memoria Cloud
|
|
43
|
+
# 2. Setup cloud backend (also enables the plugin)
|
|
83
44
|
openclaw memoria setup \
|
|
84
45
|
--mode cloud \
|
|
85
46
|
--api-url <MEMORIA_API_URL> \
|
|
86
|
-
--api-key <MEMORIA_API_KEY>
|
|
87
|
-
--install-memoria
|
|
88
|
-
```
|
|
47
|
+
--api-key <MEMORIA_API_KEY>
|
|
89
48
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
```bash
|
|
49
|
+
# 3. Verify
|
|
93
50
|
openclaw memoria health
|
|
94
|
-
#
|
|
51
|
+
# Expected: "status": "ok"
|
|
95
52
|
```
|
|
96
53
|
|
|
97
|
-
|
|
54
|
+
If the npm package is not yet published, install from source:
|
|
98
55
|
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- apiKey: <MEMORIA_API_KEY>
|
|
104
|
-
|
|
105
|
-
Execute exactly:
|
|
106
|
-
1) Ensure memoria CLI exists:
|
|
107
|
-
command -v memoria >/dev/null || curl -sSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/scripts/install.sh | bash -s -- -y -d ~/.local/bin
|
|
108
|
-
2) Try npm install first:
|
|
109
|
-
openclaw plugins install @matrixorigin/thememoria
|
|
110
|
-
3) If step 2 fails, fallback:
|
|
111
|
-
mkdir -p ~/.openclaw/plugins-src
|
|
112
|
-
if [ ! -d ~/.openclaw/plugins-src/Memoria/.git ]; then git clone https://github.com/matrixorigin/Memoria.git ~/.openclaw/plugins-src/Memoria; else git -C ~/.openclaw/plugins-src/Memoria pull --ff-only; fi
|
|
113
|
-
openclaw plugins install --link ~/.openclaw/plugins-src/Memoria/plugins/openclaw
|
|
114
|
-
4) Enable plugin:
|
|
115
|
-
openclaw plugins enable memory-memoria
|
|
116
|
-
5) Setup cloud:
|
|
117
|
-
openclaw memoria setup --mode cloud --api-url <MEMORIA_API_URL> --api-key <MEMORIA_API_KEY> --install-memoria
|
|
118
|
-
6) Verify:
|
|
119
|
-
openclaw memoria health
|
|
120
|
-
|
|
121
|
-
Output requirements:
|
|
122
|
-
- Return all executed commands and raw outputs
|
|
123
|
-
- If failed, classify as network/auth/config and provide exact fix commands
|
|
124
|
-
- Do not hide or summarize errors
|
|
56
|
+
```bash
|
|
57
|
+
mkdir -p ~/.openclaw/plugins-src
|
|
58
|
+
git clone https://github.com/matrixorigin/Memoria.git ~/.openclaw/plugins-src/Memoria
|
|
59
|
+
openclaw plugins install --link ~/.openclaw/plugins-src/Memoria/plugins/openclaw
|
|
125
60
|
```
|
|
126
61
|
|
|
127
|
-
|
|
62
|
+
Then continue with step 2 above.
|
|
128
63
|
|
|
129
|
-
|
|
64
|
+
### Local Setup (Embedded)
|
|
130
65
|
|
|
131
|
-
|
|
66
|
+
Local mode runs the Rust `memoria` binary against a self-hosted MatrixOne instance.
|
|
132
67
|
|
|
133
68
|
```bash
|
|
134
|
-
#
|
|
69
|
+
# 1. Install memoria CLI
|
|
135
70
|
curl -sSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/scripts/install.sh | bash -s -- -y -d ~/.local/bin
|
|
136
71
|
|
|
137
|
-
#
|
|
72
|
+
# 2. Install plugin
|
|
138
73
|
openclaw plugins install @matrixorigin/thememoria
|
|
139
|
-
openclaw plugins enable memory-memoria
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
# B2. If npm package is unavailable, use source-link instead
|
|
144
|
-
mkdir -p ~/.openclaw/plugins-src
|
|
145
|
-
if [ ! -d ~/.openclaw/plugins-src/Memoria/.git ]; then
|
|
146
|
-
git clone https://github.com/matrixorigin/Memoria.git ~/.openclaw/plugins-src/Memoria
|
|
147
|
-
else
|
|
148
|
-
git -C ~/.openclaw/plugins-src/Memoria pull --ff-only
|
|
149
|
-
fi
|
|
150
|
-
openclaw plugins install --link ~/.openclaw/plugins-src/Memoria/plugins/openclaw
|
|
151
|
-
openclaw plugins enable memory-memoria
|
|
152
|
-
```
|
|
153
74
|
|
|
154
|
-
|
|
155
|
-
# C0. Local quick start (use plugin defaults for db/provider/model)
|
|
75
|
+
# 3. Setup local backend (also enables the plugin, quick start with defaults)
|
|
156
76
|
openclaw memoria setup \
|
|
157
77
|
--mode local \
|
|
158
78
|
--install-memoria \
|
|
159
79
|
--embedding-api-key <EMBEDDING_API_KEY>
|
|
80
|
+
|
|
81
|
+
# 4. Verify
|
|
82
|
+
openclaw memoria health
|
|
83
|
+
# Expected: "status": "ok"
|
|
160
84
|
```
|
|
161
85
|
|
|
86
|
+
For advanced local configuration:
|
|
87
|
+
|
|
162
88
|
```bash
|
|
163
|
-
# C. Setup local backend (advanced/custom values)
|
|
164
89
|
openclaw memoria setup \
|
|
165
90
|
--mode local \
|
|
166
91
|
--db-url <MATRIXONE_DSN> \
|
|
@@ -172,197 +97,118 @@ openclaw memoria setup \
|
|
|
172
97
|
--memoria-bin ~/.local/bin/memoria
|
|
173
98
|
```
|
|
174
99
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```bash
|
|
178
|
-
openclaw memoria health
|
|
179
|
-
# must include: "status": "ok"
|
|
180
|
-
```
|
|
100
|
+
## Agent Install Prompt
|
|
181
101
|
|
|
182
|
-
|
|
102
|
+
Use this prompt to have an OpenClaw agent install the plugin automatically.
|
|
103
|
+
Replace `<MEMORIA_API_URL>` and `<MEMORIA_API_KEY>` with your credentials.
|
|
183
104
|
|
|
184
105
|
```text
|
|
185
|
-
Install Memoria plugin for my OpenClaw in
|
|
186
|
-
Use:
|
|
187
|
-
- dbUrl: <MATRIXONE_DSN>
|
|
188
|
-
- embeddingProvider: <provider>
|
|
189
|
-
- embeddingModel: <model>
|
|
190
|
-
- embeddingApiKey: <embedding_key>
|
|
191
|
-
- embeddingDim: <dim>
|
|
192
|
-
|
|
193
|
-
Execute exactly:
|
|
194
|
-
1) Ensure memoria CLI exists (install if missing):
|
|
195
|
-
curl -sSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/scripts/install.sh | bash -s -- -y -d ~/.local/bin
|
|
196
|
-
2) Try npm install first:
|
|
197
|
-
openclaw plugins install @matrixorigin/thememoria
|
|
198
|
-
3) If step 2 fails, fallback:
|
|
199
|
-
mkdir -p ~/.openclaw/plugins-src
|
|
200
|
-
if [ ! -d ~/.openclaw/plugins-src/Memoria/.git ]; then git clone https://github.com/matrixorigin/Memoria.git ~/.openclaw/plugins-src/Memoria; else git -C ~/.openclaw/plugins-src/Memoria pull --ff-only; fi
|
|
201
|
-
openclaw plugins install --link ~/.openclaw/plugins-src/Memoria/plugins/openclaw
|
|
202
|
-
4) Enable plugin:
|
|
203
|
-
openclaw plugins enable memory-memoria
|
|
204
|
-
5) Setup local (quick start):
|
|
205
|
-
openclaw memoria setup --mode local --install-memoria --embedding-api-key <EMBEDDING_API_KEY>
|
|
206
|
-
If custom MatrixOne/provider/model is required, append:
|
|
207
|
-
--db-url <MATRIXONE_DSN> --embedding-provider <provider> --embedding-model <model> --embedding-dim <dim>
|
|
208
|
-
6) Verify:
|
|
209
|
-
openclaw memoria health
|
|
210
|
-
|
|
211
|
-
Output requirements:
|
|
212
|
-
- Return all executed commands and raw outputs
|
|
213
|
-
- If failed, report the missing dependency/permission/config exactly
|
|
214
|
-
- Do not hide or summarize errors
|
|
215
|
-
```
|
|
216
|
-
|
|
217
|
-
## Local Installer Inputs (Optional)
|
|
218
|
-
|
|
219
|
-
Use this section when you choose `openclaw memoria install` for local bootstrap/repair.
|
|
106
|
+
Install the Memoria memory plugin for my OpenClaw in cloud mode.
|
|
220
107
|
|
|
221
|
-
|
|
108
|
+
Credentials:
|
|
109
|
+
- API URL: <MEMORIA_API_URL>
|
|
110
|
+
- API Key: <MEMORIA_API_KEY>
|
|
222
111
|
|
|
223
|
-
|
|
112
|
+
Run these steps in order. Stop and report if any step fails.
|
|
224
113
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
- `MEMORIA_EMBEDDING_MODEL`: for example `text-embedding-3-small` or `BAAI/bge-m3`
|
|
228
|
-
- `MEMORIA_EMBEDDING_API_KEY`: required for local/embedded mode unless embedding provider is `local`. Not needed for cloud mode.
|
|
229
|
-
- `MEMORIA_EMBEDDING_BASE_URL`: optional for official OpenAI, required for compatible gateways
|
|
230
|
-
- `MEMORIA_EMBEDDING_DIM`: must match the embedding model before first startup
|
|
231
|
-
- `MEMORIA_LLM_API_KEY`, `MEMORIA_LLM_BASE_URL`, `MEMORIA_LLM_MODEL`: optional, only needed for `autoObserve` and internal LLM-backed Memoria tools
|
|
232
|
-
- `MEMORIA_EXECUTABLE`: optional explicit path to an existing `memoria` binary
|
|
233
|
-
- `MEMORIA_RELEASE_TAG`: Rust Memoria release tag to install. Default: installer-defined release tag
|
|
234
|
-
|
|
235
|
-
Installer flags:
|
|
236
|
-
|
|
237
|
-
- `--openclaw-bin <path|command>`: use an explicit `openclaw` executable
|
|
238
|
-
- `--memoria-bin <path|command>`: use an existing `memoria` executable
|
|
239
|
-
- `--memoria-version <tag>`: override the Rust Memoria release tag
|
|
240
|
-
- `--memoria-install-dir <path>`: where to install `memoria` if it is missing
|
|
241
|
-
- `--binary-only`: install/validate `memoria` binary only, skip plugin config rewrite
|
|
242
|
-
- `--skip-memoria-install`: require an existing `memoria` executable
|
|
243
|
-
- `--skip-plugin-install`: only rewrite plugin config; assume OpenClaw already installed and the plugin already loaded
|
|
244
|
-
- `--verify`: run a post-install smoke check
|
|
245
|
-
|
|
246
|
-
## ⚠️ Common Pitfalls
|
|
114
|
+
1) Install plugin:
|
|
115
|
+
openclaw plugins install @matrixorigin/thememoria
|
|
247
116
|
|
|
248
|
-
|
|
249
|
-
|
|
117
|
+
2) Setup cloud backend (this also enables the plugin):
|
|
118
|
+
openclaw memoria setup --mode cloud --api-url <MEMORIA_API_URL> --api-key <MEMORIA_API_KEY>
|
|
250
119
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
120
|
+
3) Verify:
|
|
121
|
+
openclaw memoria health
|
|
122
|
+
Expected: "status": "ok"
|
|
254
123
|
|
|
255
|
-
|
|
256
|
-
|
|
124
|
+
Rules:
|
|
125
|
+
- Show every command you run and its full raw output
|
|
126
|
+
- Do not summarize or hide errors
|
|
127
|
+
- If a step fails, classify the error (network / auth / config / missing-binary) and suggest the exact fix command
|
|
128
|
+
- Do NOT use `openclaw memory` commands — those are built-in file memory, not Memoria
|
|
257
129
|
```
|
|
258
130
|
|
|
259
|
-
|
|
260
|
-
Writes happen when the agent explicitly calls tools like `memory_store` (or related write tools).
|
|
261
|
-
This keeps memory writes intentional and reviewable.
|
|
262
|
-
If you want auto-capture, set `MEMORIA_AUTO_OBSERVE=true` and provide `MEMORIA_LLM_API_KEY` + `MEMORIA_LLM_MODEL`.
|
|
131
|
+
## Environment Variables (Local/Embedded Only)
|
|
263
132
|
|
|
264
|
-
|
|
265
|
-
Use a fresh database name in `MEMORIA_DB_URL` for a clean install path.
|
|
133
|
+
> Cloud users: skip this section. Cloud mode only needs `--api-url` and `--api-key`.
|
|
266
134
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
mysql://root:111@127.0.0.1:6001/memoria
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
135
|
+
| Variable | Description | Default |
|
|
136
|
+
|----------|-------------|---------|
|
|
137
|
+
| `MEMORIA_DB_URL` | MatrixOne DSN | `mysql://root:111@127.0.0.1:6001/memoria` |
|
|
138
|
+
| `MEMORIA_EMBEDDING_PROVIDER` | Embedding service | `openai` |
|
|
139
|
+
| `MEMORIA_EMBEDDING_MODEL` | Model name | `text-embedding-3-small` |
|
|
140
|
+
| `MEMORIA_EMBEDDING_API_KEY` | Required unless provider is `local` | — |
|
|
141
|
+
| `MEMORIA_EMBEDDING_BASE_URL` | Optional for OpenAI, required for gateways | — |
|
|
142
|
+
| `MEMORIA_EMBEDDING_DIM` | Must match model before first startup | — |
|
|
143
|
+
| `MEMORIA_LLM_API_KEY` | Optional, for `autoObserve` and LLM-backed tools | — |
|
|
144
|
+
| `MEMORIA_LLM_BASE_URL` | Optional OpenAI-compatible base URL | — |
|
|
145
|
+
| `MEMORIA_LLM_MODEL` | Model for auto-observe and reflection | `gpt-4o-mini` |
|
|
146
|
+
| `MEMORIA_EXECUTABLE` | Explicit path to `memoria` binary | — |
|
|
147
|
+
| `MEMORIA_RELEASE_TAG` | Rust Memoria release tag to install | installer default |
|
|
274
148
|
|
|
275
149
|
## Tool Surface
|
|
276
150
|
|
|
277
|
-
The
|
|
151
|
+
The plugin exposes these tools to OpenClaw:
|
|
278
152
|
|
|
279
153
|
- `memory_search`, `memory_get`, `memory_store`, `memory_retrieve`, `memory_recall`
|
|
280
154
|
- `memory_list`, `memory_stats`, `memory_profile`, `memory_correct`, `memory_purge`, `memory_forget`, `memory_health`
|
|
281
155
|
- `memory_observe`, `memory_governance`, `memory_consolidate`, `memory_reflect`, `memory_extract_entities`, `memory_link_entities`, `memory_rebuild_index`, `memory_capabilities`
|
|
282
156
|
- `memory_snapshot`, `memory_snapshots`, `memory_rollback`
|
|
283
157
|
- `memory_branch`, `memory_branches`, `memory_checkout`, `memory_branch_delete`, `memory_merge`, `memory_diff`
|
|
284
|
-
-
|
|
158
|
+
- Compatibility CLI aliases under `openclaw ltm ...`
|
|
285
159
|
|
|
286
|
-
##
|
|
160
|
+
## Common Pitfalls
|
|
287
161
|
|
|
288
|
-
This plugin
|
|
162
|
+
**`openclaw memoria` vs `openclaw memory`:** This plugin uses `openclaw memoria`. The `openclaw memory` namespace is OpenClaw's built-in file memory — a different system entirely.
|
|
289
163
|
|
|
290
|
-
|
|
164
|
+
**macOS `sh` vs `bash`:** The installer script uses bash syntax. If piping, use `bash -s --`, not `sh -s --`.
|
|
291
165
|
|
|
292
|
-
|
|
293
|
-
- `memory_stats` is derived from available MCP outputs, so inactive-memory totals and entity totals are not currently available
|
|
294
|
-
- `memory_entities` is no longer exposed, because the Rust Memoria MCP toolset does not provide a matching tool
|
|
295
|
-
- old `mysql+pymysql://...` DSNs are normalized to `mysql://...` automatically during install and config parsing
|
|
296
|
-
- if you previously used an older Memoria stack, schema drift can cause runtime errors; using a fresh DB name (for example `memoria_v2`) avoids most upgrade collisions
|
|
166
|
+
**Explicit memory mode is default (`autoObserve=false`):** The plugin does not auto-write memories from conversation turns. Writes happen when the agent explicitly calls tools like `memory_store`. To enable auto-capture, set `MEMORIA_AUTO_OBSERVE=true` and provide `MEMORIA_LLM_API_KEY` + `MEMORIA_LLM_MODEL`.
|
|
297
167
|
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
```bash
|
|
301
|
-
curl -fsSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/plugins/openclaw/scripts/uninstall-openclaw-memoria.sh | \
|
|
302
|
-
bash -s --
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
That removes the plugin entry, tool policy additions, managed skills, and the default managed checkout path.
|
|
168
|
+
**Old schema vs new runtime:** If upgrading from an older Memoria setup, use a fresh database name in `MEMORIA_DB_URL` to avoid schema drift.
|
|
306
169
|
|
|
307
170
|
## Verification
|
|
308
171
|
|
|
309
|
-
### Success Criteria
|
|
310
|
-
|
|
311
172
|
| Level | Check | Command | Pass |
|
|
312
173
|
|---|---|---|---|
|
|
313
|
-
| 1. Plugin loaded | OpenClaw recognizes plugin | `openclaw plugins list` | `
|
|
314
|
-
| 2. Backend reachable | Memoria
|
|
315
|
-
| 3. Memory persisted | Store
|
|
174
|
+
| 1. Plugin loaded | OpenClaw recognizes plugin | `openclaw plugins list` | `thememoria` listed and enabled |
|
|
175
|
+
| 2. Backend reachable | Memoria connectivity | `openclaw memoria health` | `status: ok` |
|
|
176
|
+
| 3. Memory persisted | Store → retrieve round-trip | `openclaw memoria stats` | Non-zero memory count after a write |
|
|
316
177
|
|
|
317
|
-
|
|
178
|
+
Additional diagnostics:
|
|
318
179
|
|
|
319
180
|
```bash
|
|
320
|
-
openclaw
|
|
321
|
-
openclaw memoria verify
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
After install:
|
|
325
|
-
|
|
326
|
-
```bash
|
|
327
|
-
openclaw memoria capabilities
|
|
328
|
-
openclaw memoria stats
|
|
329
|
-
openclaw ltm list --limit 10
|
|
181
|
+
openclaw memoria capabilities # config/plugin check (no live backend needed)
|
|
182
|
+
openclaw memoria verify # deeper diagnostic
|
|
183
|
+
openclaw ltm list --limit 10 # list recent memories
|
|
330
184
|
```
|
|
331
185
|
|
|
332
186
|
Notes:
|
|
187
|
+
- `openclaw memoria setup` is the recommended onboarding command
|
|
188
|
+
- `openclaw memoria connect` remains available as the lower-level config-only variant (no `--install-memoria` support)
|
|
189
|
+
- `setup`/`connect` will merge `thememoria` into `plugins.allow` to satisfy OpenClaw allow-list policy
|
|
190
|
+
- OpenClaw may print "Restart the gateway" after `plugins install` — this is unnecessary for CLI commands like `setup` and `health`
|
|
333
191
|
|
|
334
|
-
|
|
335
|
-
- `openclaw memoria stats` and `openclaw ltm list` require the configured backend to be reachable; in embedded mode that means MatrixOne must be up and the embedding config must be valid
|
|
336
|
-
- OpenClaw reserves `openclaw memory` for its built-in file memory, so this plugin uses `openclaw memoria` and the compatibility alias `openclaw ltm`
|
|
337
|
-
- `openclaw memoria setup` is the recommended onboarding command for cloud/local setup
|
|
338
|
-
- `openclaw memoria connect` remains available as the lower-level config-only entrypoint (no `--install-memoria` support)
|
|
339
|
-
- `setup/connect` will merge `memory-memoria` into `plugins.allow` to satisfy OpenClaw allow-list policy
|
|
340
|
-
- on fresh install without explicit backend config, `openclaw plugins enable` logs a one-time hint with cloud (recommended), local (optional), and `openclaw memoria setup --help`
|
|
341
|
-
- OpenClaw may print "Restart the gateway" after `plugins install` or `plugins enable` — this is unnecessary for CLI commands like `setup` and `health`, but harmless if you do restart
|
|
342
|
-
- `openclaw memoria install` is optional local bootstrap/repair (runtime + config rewrite)
|
|
343
|
-
- `openclaw memoria verify` is an optional deeper diagnostic; `openclaw memoria health` is the primary quick connectivity check
|
|
344
|
-
|
|
345
|
-
If `openclaw memoria setup` (or `connect`) is missing:
|
|
192
|
+
## Uninstall
|
|
346
193
|
|
|
347
194
|
```bash
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
openclaw memoria --help
|
|
195
|
+
curl -fsSL https://raw.githubusercontent.com/matrixorigin/Memoria/main/plugins/openclaw/scripts/uninstall-openclaw-memoria.sh | \
|
|
196
|
+
bash -s --
|
|
351
197
|
```
|
|
352
198
|
|
|
353
|
-
|
|
199
|
+
Removes the plugin entry, tool policy additions, managed skills, and the default managed checkout path.
|
|
354
200
|
|
|
355
|
-
|
|
356
|
-
node scripts/verify_plugin_install.mjs \
|
|
357
|
-
--openclaw-bin "$(which openclaw)" \
|
|
358
|
-
--memoria-bin "$(which memoria)"
|
|
359
|
-
```
|
|
201
|
+
## Compatibility Notes
|
|
360
202
|
|
|
361
|
-
|
|
203
|
+
- `memory_get` is resolved from recent tool results plus a bounded scan (Rust MCP has no direct get-by-id)
|
|
204
|
+
- `memory_stats` is derived from available MCP outputs (inactive-memory and entity totals not currently available)
|
|
205
|
+
- `memory_entities` is not exposed (no matching Rust MCP tool)
|
|
206
|
+
- Old `mysql+pymysql://...` DSNs are normalized to `mysql://...` automatically
|
|
207
|
+
- Schema drift from older Memoria stacks can cause runtime errors — use a fresh DB name to avoid
|
|
362
208
|
|
|
363
|
-
|
|
209
|
+
## Development
|
|
364
210
|
|
|
365
|
-
- `openclaw/client.ts`
|
|
366
|
-
-
|
|
367
|
-
-
|
|
368
|
-
-
|
|
211
|
+
- `openclaw/client.ts` talks to Rust Memoria over MCP stdio (embedded) or HTTP (api)
|
|
212
|
+
- Plugin manifest and config use `memoriaExecutable` for embedded mode
|
|
213
|
+
- Installer/uninstaller are pure shell + Node, no Python dependency
|
|
214
|
+
- No bundled Python runtime
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group 5: Session & Backend Routing
|
|
3
|
+
* "Does the right transport get used?"
|
|
4
|
+
*/
|
|
5
|
+
import { describe, it, expect, beforeEach, afterEach } from "vitest";
|
|
6
|
+
import { MemoriaClient } from "../client.js";
|
|
7
|
+
import { MemoriaHttpTransport } from "../http-client.js";
|
|
8
|
+
import { buildApiConfig, buildEmbeddedConfig, mockFetch } from "./helpers.js";
|
|
9
|
+
|
|
10
|
+
const originalFetch = globalThis.fetch;
|
|
11
|
+
|
|
12
|
+
afterEach(() => {
|
|
13
|
+
globalThis.fetch = originalFetch;
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("Group 5: Session & Backend Routing", () => {
|
|
17
|
+
it("5.1 getSession with backend=api returns MemoriaHttpTransport", async () => {
|
|
18
|
+
const fetchMock = mockFetch();
|
|
19
|
+
fetchMock.respondWith(200, { results: [] });
|
|
20
|
+
const client = new MemoriaClient(buildApiConfig());
|
|
21
|
+
// Trigger a call to force session creation
|
|
22
|
+
await client.retrieve({ userId: "u1", query: "test", topK: 5 });
|
|
23
|
+
// Verify it used fetch (HTTP transport), not spawn (MCP session)
|
|
24
|
+
expect(fetchMock.calls.length).toBeGreaterThan(0);
|
|
25
|
+
expect(fetchMock.lastCall()!.url).toContain("/v1/memories/retrieve");
|
|
26
|
+
client.close();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// 5.2 is hard to test without spawning a real binary — skip for unit tests
|
|
30
|
+
|
|
31
|
+
it("5.3 same userId reuses session (no extra fetch for session setup)", async () => {
|
|
32
|
+
const fetchMock = mockFetch();
|
|
33
|
+
fetchMock.respondWith(200, { results: [] });
|
|
34
|
+
const client = new MemoriaClient(buildApiConfig());
|
|
35
|
+
await client.retrieve({ userId: "u1", query: "q1", topK: 5 });
|
|
36
|
+
const callCount1 = fetchMock.calls.length;
|
|
37
|
+
await client.retrieve({ userId: "u1", query: "q2", topK: 5 });
|
|
38
|
+
const callCount2 = fetchMock.calls.length;
|
|
39
|
+
// Second call should add exactly 1 more fetch (the retrieve), not 2 (no session setup)
|
|
40
|
+
expect(callCount2 - callCount1).toBe(1);
|
|
41
|
+
client.close();
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it("5.4 rebuildIndex in api mode returns cloud-managed message", async () => {
|
|
45
|
+
const fetchMock = mockFetch();
|
|
46
|
+
const client = new MemoriaClient(buildApiConfig());
|
|
47
|
+
const result = await client.rebuildIndex("mem_memories");
|
|
48
|
+
expect(result.message).toMatch(/cloud/i);
|
|
49
|
+
// No HTTP call should have been made
|
|
50
|
+
expect(fetchMock.calls.length).toBe(0);
|
|
51
|
+
client.close();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("5.5 health in api mode calls healthCheck on transport", async () => {
|
|
55
|
+
const fetchMock = mockFetch();
|
|
56
|
+
fetchMock.respondWith(200, { status: "ok", instance_id: "i-1", db: true });
|
|
57
|
+
const client = new MemoriaClient(buildApiConfig());
|
|
58
|
+
const result = await client.health("u1");
|
|
59
|
+
expect(result.status).toBe("ok");
|
|
60
|
+
expect(result.mode).toBe("api");
|
|
61
|
+
expect(fetchMock.lastCall()!.url).toContain("/health/instance");
|
|
62
|
+
client.close();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it("5.6 close() does not throw", () => {
|
|
66
|
+
const client = new MemoriaClient(buildApiConfig());
|
|
67
|
+
expect(() => client.close()).not.toThrow();
|
|
68
|
+
});
|
|
69
|
+
});
|