clawmem 0.14.0 → 0.15.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/AGENTS.md +165 -716
- package/CLAUDE.md +4 -786
- package/README.md +20 -191
- package/SKILL.md +157 -711
- package/docs/clawmem-architecture.excalidraw +2415 -0
- package/docs/clawmem-architecture.png +0 -0
- package/docs/clawmem_hero.jpg +0 -0
- package/docs/concepts/architecture.md +413 -0
- package/docs/concepts/composite-scoring.md +133 -0
- package/docs/concepts/hooks-vs-mcp.md +156 -0
- package/docs/concepts/multi-vault.md +71 -0
- package/docs/contributing.md +101 -0
- package/docs/guides/cloud-embedding.md +134 -0
- package/docs/guides/hermes-plugin.md +187 -0
- package/docs/guides/inference-services.md +144 -0
- package/docs/guides/multi-vault-config.md +84 -0
- package/docs/guides/openclaw-plugin.md +306 -0
- package/docs/guides/setup-hooks.md +146 -0
- package/docs/guides/setup-mcp.md +76 -0
- package/docs/guides/systemd-services.md +332 -0
- package/docs/guides/upgrading.md +566 -0
- package/docs/internals/entity-resolution.md +135 -0
- package/docs/internals/graph-traversal.md +85 -0
- package/docs/internals/intent-search-pipeline.md +103 -0
- package/docs/internals/query-pipeline.md +100 -0
- package/docs/introduction.md +104 -0
- package/docs/quickstart.md +158 -0
- package/docs/reference/cli.md +195 -0
- package/docs/reference/configuration.md +101 -0
- package/docs/reference/mcp-tools.md +336 -0
- package/docs/reference/rest-api.md +204 -0
- package/docs/troubleshooting.md +330 -0
- package/package.json +2 -1
- package/src/memory.ts +2 -0
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
# MCP server tools reference
|
|
2
|
+
|
|
3
|
+
Complete reference for ClawMem's MCP server tools. These let AI agents search, retrieve, and manage persistent memory. All tools accept an optional `vault` parameter for multi-vault setups. Omit for the default vault.
|
|
4
|
+
|
|
5
|
+
## Retrieval
|
|
6
|
+
|
|
7
|
+
### memory_retrieve
|
|
8
|
+
|
|
9
|
+
**Recommended entry point.** Auto-classifies query and routes to the optimal backend.
|
|
10
|
+
|
|
11
|
+
| Param | Type | Default | Description |
|
|
12
|
+
|-------|------|---------|-------------|
|
|
13
|
+
| `query` | string | required | Your question or search query |
|
|
14
|
+
| `mode` | enum | `auto` | Override: `keyword`, `semantic`, `causal`, `timeline`, `discovery`, `complex`, `hybrid` |
|
|
15
|
+
| `limit` | number | 10 | Max results |
|
|
16
|
+
| `compact` | boolean | true | Compact output (snippets vs full content) |
|
|
17
|
+
| `vault` | string | — | Named vault |
|
|
18
|
+
|
|
19
|
+
Auto-routing:
|
|
20
|
+
- Timeline queries ("last session", "yesterday") → session history
|
|
21
|
+
- Causal queries ("why did we", "what caused") → intent_search with graph traversal
|
|
22
|
+
- Discovery queries ("similar to", "related to") → find_similar
|
|
23
|
+
- Complex queries (multi-topic) → query_plan
|
|
24
|
+
- Everything else → full hybrid search
|
|
25
|
+
|
|
26
|
+
### query
|
|
27
|
+
|
|
28
|
+
Full hybrid pipeline: BM25 + vector + query expansion + cross-encoder reranking.
|
|
29
|
+
|
|
30
|
+
| Param | Type | Default | Description |
|
|
31
|
+
|-------|------|---------|-------------|
|
|
32
|
+
| `query` | string | required | Search query |
|
|
33
|
+
| `limit` | number | 10 | Max results |
|
|
34
|
+
| `compact` | boolean | true | Compact output |
|
|
35
|
+
| `collection` | string | — | Filter by collection (comma-separated for multi) |
|
|
36
|
+
| `intent` | string | — | Domain hint for ambiguous queries (steers expansion, reranking, chunk selection) |
|
|
37
|
+
| `candidateLimit` | number | 30 | Candidates for reranking (tune precision vs speed) |
|
|
38
|
+
| `vault` | string | — | Named vault |
|
|
39
|
+
|
|
40
|
+
BM25 strong-signal bypass: skips expansion when top BM25 hit >= 0.85 with gap >= 0.15 (disabled when `intent` is provided).
|
|
41
|
+
|
|
42
|
+
### search
|
|
43
|
+
|
|
44
|
+
BM25 only. Zero GPU cost.
|
|
45
|
+
|
|
46
|
+
| Param | Type | Default | Description |
|
|
47
|
+
|-------|------|---------|-------------|
|
|
48
|
+
| `query` | string | required | Search query |
|
|
49
|
+
| `limit` | number | 10 | Max results |
|
|
50
|
+
| `compact` | boolean | true | Compact output |
|
|
51
|
+
| `collection` | string | — | Filter by collection |
|
|
52
|
+
| `vault` | string | — | Named vault |
|
|
53
|
+
|
|
54
|
+
### vsearch
|
|
55
|
+
|
|
56
|
+
Vector only. Semantic similarity.
|
|
57
|
+
|
|
58
|
+
| Param | Type | Default | Description |
|
|
59
|
+
|-------|------|---------|-------------|
|
|
60
|
+
| `query` | string | required | Search query |
|
|
61
|
+
| `limit` | number | 10 | Max results |
|
|
62
|
+
| `compact` | boolean | true | Compact output |
|
|
63
|
+
| `collection` | string | — | Filter by collection |
|
|
64
|
+
| `vault` | string | — | Named vault |
|
|
65
|
+
|
|
66
|
+
### intent_search
|
|
67
|
+
|
|
68
|
+
Intent-classified search with graph traversal. Use directly for "why", "when", "who" questions.
|
|
69
|
+
|
|
70
|
+
| Param | Type | Default | Description |
|
|
71
|
+
|-------|------|---------|-------------|
|
|
72
|
+
| `query` | string | required | Search query |
|
|
73
|
+
| `limit` | number | 10 | Max results |
|
|
74
|
+
| `force_intent` | enum | — | Override: `WHY`, `WHEN`, `ENTITY`, `WHAT` |
|
|
75
|
+
| `enable_graph_traversal` | boolean | true | Multi-hop graph expansion |
|
|
76
|
+
| `vault` | string | — | Named vault |
|
|
77
|
+
|
|
78
|
+
### query_plan
|
|
79
|
+
|
|
80
|
+
Multi-topic decomposition. Use for complex queries spanning multiple subjects.
|
|
81
|
+
|
|
82
|
+
| Param | Type | Default | Description |
|
|
83
|
+
|-------|------|---------|-------------|
|
|
84
|
+
| `query` | string | required | Complex or multi-topic query |
|
|
85
|
+
| `limit` | number | 10 | Max results |
|
|
86
|
+
| `compact` | boolean | true | Compact output |
|
|
87
|
+
| `vault` | string | — | Named vault |
|
|
88
|
+
|
|
89
|
+
## Document access
|
|
90
|
+
|
|
91
|
+
### get
|
|
92
|
+
|
|
93
|
+
Retrieve a single document by path or docid.
|
|
94
|
+
|
|
95
|
+
| Param | Type | Default | Description |
|
|
96
|
+
|-------|------|---------|-------------|
|
|
97
|
+
| `file` | string | required | File path or docid (`#abc123`) |
|
|
98
|
+
| `fromLine` | number | — | Start line |
|
|
99
|
+
| `maxLines` | number | — | Line limit |
|
|
100
|
+
| `lineNumbers` | boolean | false | Include line numbers |
|
|
101
|
+
| `vault` | string | — | Named vault |
|
|
102
|
+
|
|
103
|
+
### multi_get
|
|
104
|
+
|
|
105
|
+
Retrieve multiple documents by glob pattern or comma-separated list.
|
|
106
|
+
|
|
107
|
+
| Param | Type | Default | Description |
|
|
108
|
+
|-------|------|---------|-------------|
|
|
109
|
+
| `pattern` | string | required | Glob pattern or comma-separated paths |
|
|
110
|
+
| `maxLines` | number | — | Line limit per document |
|
|
111
|
+
| `maxBytes` | number | 10240 | Max total bytes |
|
|
112
|
+
| `lineNumbers` | boolean | false | Include line numbers |
|
|
113
|
+
| `vault` | string | — | Named vault |
|
|
114
|
+
|
|
115
|
+
### find_similar
|
|
116
|
+
|
|
117
|
+
k-NN vector neighbors of a reference document.
|
|
118
|
+
|
|
119
|
+
| Param | Type | Default | Description |
|
|
120
|
+
|-------|------|---------|-------------|
|
|
121
|
+
| `file` | string | required | Path of reference document |
|
|
122
|
+
| `limit` | number | 5 | Max results |
|
|
123
|
+
| `vault` | string | — | Named vault |
|
|
124
|
+
|
|
125
|
+
### find_causal_links
|
|
126
|
+
|
|
127
|
+
Trace causal decision chains from a document.
|
|
128
|
+
|
|
129
|
+
| Param | Type | Default | Description |
|
|
130
|
+
|-------|------|---------|-------------|
|
|
131
|
+
| `docid` | string | required | Document ID |
|
|
132
|
+
| `direction` | enum | `both` | `causes`, `caused_by`, or `both` |
|
|
133
|
+
| `depth` | number | 5 | Max traversal depth (1-10) |
|
|
134
|
+
| `vault` | string | — | Named vault |
|
|
135
|
+
|
|
136
|
+
### timeline
|
|
137
|
+
|
|
138
|
+
Temporal neighborhood — what was created/modified before and after a document.
|
|
139
|
+
|
|
140
|
+
| Param | Type | Default | Description |
|
|
141
|
+
|-------|------|---------|-------------|
|
|
142
|
+
| `docid` | string | required | Document ID |
|
|
143
|
+
| `before` | number | 5 | Documents to show before (1-20) |
|
|
144
|
+
| `after` | number | 5 | Documents to show after (1-20) |
|
|
145
|
+
| `same_collection` | boolean | false | Constrain to same collection |
|
|
146
|
+
| `vault` | string | — | Named vault |
|
|
147
|
+
|
|
148
|
+
### memory_evolution_status
|
|
149
|
+
|
|
150
|
+
Track how a document's A-MEM metadata evolved over time.
|
|
151
|
+
|
|
152
|
+
| Param | Type | Default | Description |
|
|
153
|
+
|-------|------|---------|-------------|
|
|
154
|
+
| `docid` | string | required | Document ID |
|
|
155
|
+
| `limit` | number | 10 | Max evolution entries (1-100) |
|
|
156
|
+
| `vault` | string | — | Named vault |
|
|
157
|
+
|
|
158
|
+
### session_log
|
|
159
|
+
|
|
160
|
+
Recent session history with handoffs and file changes.
|
|
161
|
+
|
|
162
|
+
| Param | Type | Default | Description |
|
|
163
|
+
|-------|------|---------|-------------|
|
|
164
|
+
| `limit` | number | 10 | Max sessions |
|
|
165
|
+
| `vault` | string | — | Named vault |
|
|
166
|
+
|
|
167
|
+
## Mutations
|
|
168
|
+
|
|
169
|
+
### memory_pin
|
|
170
|
+
|
|
171
|
+
Pin a memory for permanent prioritization (+0.3 composite boost).
|
|
172
|
+
|
|
173
|
+
| Param | Type | Default | Description |
|
|
174
|
+
|-------|------|---------|-------------|
|
|
175
|
+
| `query` | string | required | Search query or path to find the memory |
|
|
176
|
+
| `unpin` | boolean | false | Set true to unpin |
|
|
177
|
+
| `vault` | string | — | Named vault |
|
|
178
|
+
|
|
179
|
+
### memory_snooze
|
|
180
|
+
|
|
181
|
+
Temporarily hide a memory from context surfacing.
|
|
182
|
+
|
|
183
|
+
| Param | Type | Default | Description |
|
|
184
|
+
|-------|------|---------|-------------|
|
|
185
|
+
| `query` | string | required | Search query or path to find the memory |
|
|
186
|
+
| `until` | string | — | ISO date (e.g., `2026-04-01`). Omit to unsnooze. |
|
|
187
|
+
| `vault` | string | — | Named vault |
|
|
188
|
+
|
|
189
|
+
### memory_forget
|
|
190
|
+
|
|
191
|
+
Permanently deactivate a memory.
|
|
192
|
+
|
|
193
|
+
| Param | Type | Default | Description |
|
|
194
|
+
|-------|------|---------|-------------|
|
|
195
|
+
| `query` | string | required | Search query or path to find the memory |
|
|
196
|
+
| `confirm` | boolean | true | False = preview only |
|
|
197
|
+
| `vault` | string | — | Named vault |
|
|
198
|
+
|
|
199
|
+
**Search behavior (v0.2.6+, all three tools):** Query matching cascades through four strategies: exact path match → BM25 full-text → title-token overlap → vector similarity. This prevents "No matching memory found" errors when the document exists but BM25 fails to match (e.g., too many AND'd terms). Path-like queries (containing `/` or ending in `.md`) try direct path matching first. `memory_forget` requires higher confidence to act — ambiguous matches return candidates instead of mutating.
|
|
200
|
+
|
|
201
|
+
## Lifecycle
|
|
202
|
+
|
|
203
|
+
### lifecycle_status
|
|
204
|
+
|
|
205
|
+
Document lifecycle statistics: active, archived, forgotten, pinned, snoozed counts.
|
|
206
|
+
|
|
207
|
+
| Param | Type | Default | Description |
|
|
208
|
+
|-------|------|---------|-------------|
|
|
209
|
+
| `vault` | string | — | Named vault |
|
|
210
|
+
|
|
211
|
+
### lifecycle_sweep
|
|
212
|
+
|
|
213
|
+
Archive stale documents based on lifecycle policy.
|
|
214
|
+
|
|
215
|
+
| Param | Type | Default | Description |
|
|
216
|
+
|-------|------|---------|-------------|
|
|
217
|
+
| `dry_run` | boolean | true | Preview only (no action) |
|
|
218
|
+
| `vault` | string | — | Named vault |
|
|
219
|
+
|
|
220
|
+
### lifecycle_restore
|
|
221
|
+
|
|
222
|
+
Restore auto-archived documents.
|
|
223
|
+
|
|
224
|
+
| Param | Type | Default | Description |
|
|
225
|
+
|-------|------|---------|-------------|
|
|
226
|
+
| `query` | string | — | Search archived docs by keyword |
|
|
227
|
+
| `collection` | string | — | Restore all from a collection |
|
|
228
|
+
| `all` | boolean | false | Restore everything |
|
|
229
|
+
| `vault` | string | — | Named vault |
|
|
230
|
+
|
|
231
|
+
## Maintenance
|
|
232
|
+
|
|
233
|
+
### status
|
|
234
|
+
|
|
235
|
+
Quick index health check.
|
|
236
|
+
|
|
237
|
+
| Param | Type | Default | Description |
|
|
238
|
+
|-------|------|---------|-------------|
|
|
239
|
+
| `vault` | string | — | Named vault |
|
|
240
|
+
|
|
241
|
+
### reindex
|
|
242
|
+
|
|
243
|
+
Trigger re-scan of all collections.
|
|
244
|
+
|
|
245
|
+
| Param | Type | Default | Description |
|
|
246
|
+
|-------|------|---------|-------------|
|
|
247
|
+
| `vault` | string | — | Named vault |
|
|
248
|
+
|
|
249
|
+
### index_stats
|
|
250
|
+
|
|
251
|
+
Detailed statistics: content type distribution, staleness, embedding coverage.
|
|
252
|
+
|
|
253
|
+
| Param | Type | Default | Description |
|
|
254
|
+
|-------|------|---------|-------------|
|
|
255
|
+
| `vault` | string | — | Named vault |
|
|
256
|
+
|
|
257
|
+
### build_graphs
|
|
258
|
+
|
|
259
|
+
Build temporal backbone and semantic graph.
|
|
260
|
+
|
|
261
|
+
| Param | Type | Default | Description |
|
|
262
|
+
|-------|------|---------|-------------|
|
|
263
|
+
| `graph_types` | array | `["all"]` | `temporal`, `semantic`, or `all` |
|
|
264
|
+
| `semantic_threshold` | number | 0.7 | Similarity threshold for semantic edges |
|
|
265
|
+
| `vault` | string | — | Named vault |
|
|
266
|
+
|
|
267
|
+
### profile
|
|
268
|
+
|
|
269
|
+
Get or rebuild the user profile (static facts + dynamic context).
|
|
270
|
+
|
|
271
|
+
| Param | Type | Default | Description |
|
|
272
|
+
|-------|------|---------|-------------|
|
|
273
|
+
| `rebuild` | boolean | false | Force rebuild |
|
|
274
|
+
|
|
275
|
+
### beads_sync
|
|
276
|
+
|
|
277
|
+
Sync Beads issues from Dolt backend into the search index.
|
|
278
|
+
|
|
279
|
+
| Param | Type | Default | Description |
|
|
280
|
+
|-------|------|---------|-------------|
|
|
281
|
+
| `project_path` | string | cwd | Path to project with `.beads/` directory |
|
|
282
|
+
|
|
283
|
+
## Vault management
|
|
284
|
+
|
|
285
|
+
### list_vaults
|
|
286
|
+
|
|
287
|
+
Show configured vault names and paths. Returns empty in single-vault mode.
|
|
288
|
+
|
|
289
|
+
### vault_sync
|
|
290
|
+
|
|
291
|
+
Index markdown from a directory into a named vault.
|
|
292
|
+
|
|
293
|
+
| Param | Type | Default | Description |
|
|
294
|
+
|-------|------|---------|-------------|
|
|
295
|
+
| `vault` | string | required | Target vault name |
|
|
296
|
+
| `content_root` | string | required | Directory path to index |
|
|
297
|
+
| `pattern` | string | `**/*.md` | Glob pattern |
|
|
298
|
+
| `collection_name` | string | vault name | Collection name in the vault |
|
|
299
|
+
|
|
300
|
+
Restricted-path validation rejects sensitive directories (`/etc/`, `/root/`, `.ssh`, `.env`, `credentials`, `.aws`, `.kube`).
|
|
301
|
+
|
|
302
|
+
### kg_query
|
|
303
|
+
|
|
304
|
+
Query the SPO knowledge graph for an entity's temporal relationships.
|
|
305
|
+
|
|
306
|
+
| Param | Type | Default | Description |
|
|
307
|
+
|-------|------|---------|-------------|
|
|
308
|
+
| `entity` | string | required | Entity name or ID |
|
|
309
|
+
| `as_of` | string | — | Date filter (YYYY-MM-DD) — only facts valid at this date |
|
|
310
|
+
| `direction` | enum | `both` | `outgoing`, `incoming`, or `both` |
|
|
311
|
+
| `vault` | string | — | Named vault |
|
|
312
|
+
|
|
313
|
+
Uses entity resolution (FTS search) first, falls back to slug normalization. Returns triples with subject, predicate, object, valid_from, valid_to, confidence, and current status.
|
|
314
|
+
|
|
315
|
+
### diary_write
|
|
316
|
+
|
|
317
|
+
Write to the agent's diary. For non-hooked environments where hooks don't capture session context automatically.
|
|
318
|
+
|
|
319
|
+
| Param | Type | Default | Description |
|
|
320
|
+
|-------|------|---------|-------------|
|
|
321
|
+
| `entry` | string | required | Diary entry text |
|
|
322
|
+
| `topic` | string | `general` | Topic tag (e.g., 'technical', 'user_facts', 'session') |
|
|
323
|
+
| `agent` | string | `agent` | Agent name writing the entry |
|
|
324
|
+
| `vault` | string | — | Named vault |
|
|
325
|
+
|
|
326
|
+
Entries stored via `saveMemory()` with ms-resolution paths to prevent dedup of rapid writes.
|
|
327
|
+
|
|
328
|
+
### diary_read
|
|
329
|
+
|
|
330
|
+
Read recent diary entries.
|
|
331
|
+
|
|
332
|
+
| Param | Type | Default | Description |
|
|
333
|
+
|-------|------|---------|-------------|
|
|
334
|
+
| `last_n` | number | 10 | Number of entries to return |
|
|
335
|
+
| `agent` | string | — | Filter by agent name |
|
|
336
|
+
| `vault` | string | — | Named vault |
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
# ClawMem REST API reference
|
|
2
|
+
|
|
3
|
+
HTTP REST API for non-MCP clients, web dashboards, cross-machine access, and **OpenClaw agent tools**. Required for OpenClaw integration — the memory plugin serves 5 agent tools (search, get, session_log, timeline, similar) via this API. See the [OpenClaw plugin guide](../guides/openclaw-plugin.md) for details.
|
|
4
|
+
|
|
5
|
+
## Start the server
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
./bin/clawmem serve # localhost:7438, no auth
|
|
9
|
+
./bin/clawmem serve --port 8080 # custom port
|
|
10
|
+
CLAWMEM_API_TOKEN=secret ./bin/clawmem serve # with bearer token auth
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Authentication
|
|
14
|
+
|
|
15
|
+
Set `CLAWMEM_API_TOKEN` to require `Authorization: Bearer <token>` on all requests. If unset, access is open (localhost-only by default).
|
|
16
|
+
|
|
17
|
+
## Endpoints
|
|
18
|
+
|
|
19
|
+
### Health & stats
|
|
20
|
+
|
|
21
|
+
| Method | Path | Description |
|
|
22
|
+
|--------|------|-------------|
|
|
23
|
+
| GET | `/health` | Liveness probe — returns status, version, doc count |
|
|
24
|
+
| GET | `/stats` | Full index statistics with collection list |
|
|
25
|
+
|
|
26
|
+
### Search & retrieval
|
|
27
|
+
|
|
28
|
+
| Method | Path | Description |
|
|
29
|
+
|--------|------|-------------|
|
|
30
|
+
| POST | `/search` | Direct search with mode selection |
|
|
31
|
+
| POST | `/retrieve` | Smart retrieve with auto-routing |
|
|
32
|
+
|
|
33
|
+
**POST /search**
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"query": "authentication decisions",
|
|
38
|
+
"mode": "hybrid",
|
|
39
|
+
"collection": "notes",
|
|
40
|
+
"compact": true,
|
|
41
|
+
"limit": 10
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
Modes: `auto`, `keyword`, `semantic`, `hybrid`.
|
|
46
|
+
|
|
47
|
+
**POST /retrieve**
|
|
48
|
+
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"query": "why did we choose JWT",
|
|
52
|
+
"mode": "auto",
|
|
53
|
+
"compact": true,
|
|
54
|
+
"limit": 10
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Modes: `auto`, `keyword`, `semantic`, `causal`, `timeline`, `hybrid`.
|
|
59
|
+
|
|
60
|
+
Auto-routing classifies the query:
|
|
61
|
+
- Causal queries → intent-aware RRF (boosts vector for WHY, BM25 for WHEN)
|
|
62
|
+
- Timeline queries → session history
|
|
63
|
+
- Short keyword queries → BM25
|
|
64
|
+
- Conceptual queries → vector
|
|
65
|
+
- Everything else → hybrid
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Example: causal query
|
|
69
|
+
curl -X POST http://localhost:7438/retrieve \
|
|
70
|
+
-H 'Content-Type: application/json' \
|
|
71
|
+
-d '{"query": "why did we switch to JWT", "compact": true}'
|
|
72
|
+
|
|
73
|
+
# Example: keyword search
|
|
74
|
+
curl -X POST http://localhost:7438/search \
|
|
75
|
+
-H 'Content-Type: application/json' \
|
|
76
|
+
-d '{"query": "CLAWMEM_EMBED_URL", "mode": "keyword"}'
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Documents
|
|
80
|
+
|
|
81
|
+
| Method | Path | Description |
|
|
82
|
+
|--------|------|-------------|
|
|
83
|
+
| GET | `/documents/:docid` | Single document by 6-char hash prefix |
|
|
84
|
+
| GET | `/documents?pattern=...` | Multi-get by glob pattern |
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
curl http://localhost:7438/documents/a1b2c3
|
|
88
|
+
curl http://localhost:7438/documents?pattern=notes/*.md
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Timeline & sessions
|
|
92
|
+
|
|
93
|
+
| Method | Path | Description |
|
|
94
|
+
|--------|------|-------------|
|
|
95
|
+
| GET | `/timeline/:docid` | Temporal neighborhood (before/after) |
|
|
96
|
+
| GET | `/sessions` | Recent session history |
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
curl http://localhost:7438/timeline/a1b2c3?before=3&after=3
|
|
100
|
+
curl http://localhost:7438/sessions?limit=5
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Graph traversal
|
|
104
|
+
|
|
105
|
+
| Method | Path | Description |
|
|
106
|
+
|--------|------|-------------|
|
|
107
|
+
| GET | `/graph/causal/:docid` | Causal chain traversal |
|
|
108
|
+
| GET | `/graph/similar/:docid` | k-NN semantic neighbors |
|
|
109
|
+
| GET | `/graph/evolution/:docid` | Document evolution timeline |
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
curl http://localhost:7438/graph/causal/a1b2c3?direction=both&depth=3
|
|
113
|
+
curl http://localhost:7438/graph/similar/a1b2c3?limit=5
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Lifecycle
|
|
117
|
+
|
|
118
|
+
| Method | Path | Description |
|
|
119
|
+
|--------|------|-------------|
|
|
120
|
+
| GET | `/lifecycle/status` | Active/archived/pinned/snoozed counts |
|
|
121
|
+
| POST | `/lifecycle/sweep` | Archive stale docs (dry_run default) |
|
|
122
|
+
| POST | `/lifecycle/restore` | Restore archived docs |
|
|
123
|
+
|
|
124
|
+
### Document mutations
|
|
125
|
+
|
|
126
|
+
| Method | Path | Description |
|
|
127
|
+
|--------|------|-------------|
|
|
128
|
+
| POST | `/documents/:docid/pin` | Pin/unpin a document |
|
|
129
|
+
| POST | `/documents/:docid/snooze` | Snooze until a date |
|
|
130
|
+
| POST | `/documents/:docid/forget` | Deactivate a document |
|
|
131
|
+
|
|
132
|
+
### Maintenance
|
|
133
|
+
|
|
134
|
+
| Method | Path | Description |
|
|
135
|
+
|--------|------|-------------|
|
|
136
|
+
| GET | `/collections` | List all collections |
|
|
137
|
+
| GET | `/profile` | Get user profile |
|
|
138
|
+
| POST | `/reindex` | Trigger re-scan |
|
|
139
|
+
| POST | `/graphs/build` | Rebuild temporal + semantic graphs |
|
|
140
|
+
| GET | `/export` | Full vault export as JSON |
|
|
141
|
+
|
|
142
|
+
## Response format
|
|
143
|
+
|
|
144
|
+
All responses are JSON. Search/retrieve responses include:
|
|
145
|
+
|
|
146
|
+
```json
|
|
147
|
+
{
|
|
148
|
+
"query": "authentication",
|
|
149
|
+
"mode": "hybrid",
|
|
150
|
+
"count": 3,
|
|
151
|
+
"results": [
|
|
152
|
+
{
|
|
153
|
+
"docid": "a1b2c3",
|
|
154
|
+
"path": "notes/auth.md",
|
|
155
|
+
"title": "Authentication Decision",
|
|
156
|
+
"score": 0.847,
|
|
157
|
+
"contentType": "decision",
|
|
158
|
+
"snippet": "We chose JWT for authentication because..."
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
When `compact=false`, results include `modifiedAt`, `confidence`, and full `body` instead of `snippet`.
|
|
165
|
+
|
|
166
|
+
## Running as a systemd service
|
|
167
|
+
|
|
168
|
+
For production deployments (especially OpenClaw), run the REST API as a persistent service instead of relying on the plugin's `spawnBackground()`:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
cat > ~/.config/systemd/user/clawmem-serve.service << 'EOF'
|
|
172
|
+
[Unit]
|
|
173
|
+
Description=ClawMem REST API server
|
|
174
|
+
After=default.target
|
|
175
|
+
|
|
176
|
+
[Service]
|
|
177
|
+
Type=simple
|
|
178
|
+
ExecStart=%h/clawmem/bin/clawmem serve --port 7438
|
|
179
|
+
Restart=on-failure
|
|
180
|
+
RestartSec=5
|
|
181
|
+
Environment=CLAWMEM_API_TOKEN=your-secret-here
|
|
182
|
+
|
|
183
|
+
[Install]
|
|
184
|
+
WantedBy=default.target
|
|
185
|
+
EOF
|
|
186
|
+
|
|
187
|
+
systemctl --user daemon-reload
|
|
188
|
+
systemctl --user enable --now clawmem-serve.service
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
When running as a systemd service, set `enableTools: true` and `servePort: 7438` in the OpenClaw plugin manifest — the plugin will connect to the existing server instead of spawning its own.
|
|
192
|
+
|
|
193
|
+
For remote GPU setups, add environment overrides (same pattern as the [watcher service](../guides/systemd-services.md#remote-gpu)):
|
|
194
|
+
|
|
195
|
+
```ini
|
|
196
|
+
Environment=CLAWMEM_EMBED_URL=http://gpu-host:8088
|
|
197
|
+
Environment=CLAWMEM_LLM_URL=http://gpu-host:8089
|
|
198
|
+
Environment=CLAWMEM_LLM_MODEL=qwen3
|
|
199
|
+
Environment=CLAWMEM_RERANK_URL=http://gpu-host:8090
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## CORS
|
|
203
|
+
|
|
204
|
+
The server allows `localhost:*` origins for local frontend development.
|