@totalreclaw/totalreclaw 1.0.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/.github/workflows/ci.yml +27 -0
- package/.github/workflows/publish.yml +39 -0
- package/README.md +104 -0
- package/SKILL.md +687 -0
- package/api-client.ts +300 -0
- package/crypto.ts +351 -0
- package/embedding.ts +84 -0
- package/extractor.ts +210 -0
- package/generate-mnemonic.ts +14 -0
- package/hot-cache-wrapper.ts +126 -0
- package/index.ts +1885 -0
- package/llm-client.ts +418 -0
- package/lsh.test.ts +463 -0
- package/lsh.ts +257 -0
- package/package.json +40 -0
- package/porter-stemmer.d.ts +4 -0
- package/reranker.test.ts +594 -0
- package/reranker.ts +537 -0
- package/semantic-dedup.test.ts +392 -0
- package/semantic-dedup.ts +100 -0
- package/subgraph-search.ts +278 -0
- package/subgraph-store.ts +342 -0
package/SKILL.md
ADDED
|
@@ -0,0 +1,687 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: totalreclaw
|
|
3
|
+
description: "Zero-knowledge encrypted memory vault for AI agents — the password manager for AI memory. Full E2EE: server never sees plaintext."
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
author: TotalReclaw Team
|
|
6
|
+
license: MIT
|
|
7
|
+
homepage: https://github.com/p-diogo/totalreclaw
|
|
8
|
+
metadata:
|
|
9
|
+
openclaw:
|
|
10
|
+
requires:
|
|
11
|
+
env: []
|
|
12
|
+
bins: []
|
|
13
|
+
emoji: "🧠"
|
|
14
|
+
os: ["macos", "linux", "windows"]
|
|
15
|
+
keywords:
|
|
16
|
+
- memory
|
|
17
|
+
- e2ee
|
|
18
|
+
- zero-knowledge
|
|
19
|
+
- encryption
|
|
20
|
+
- privacy
|
|
21
|
+
- agent-memory
|
|
22
|
+
- persistent-context
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
# TotalReclaw Skill
|
|
26
|
+
|
|
27
|
+
## Tools
|
|
28
|
+
|
|
29
|
+
### totalreclaw_remember
|
|
30
|
+
|
|
31
|
+
Store a new fact or preference in long-term memory.
|
|
32
|
+
|
|
33
|
+
**Parameters:**
|
|
34
|
+
|
|
35
|
+
| Name | Type | Required | Description |
|
|
36
|
+
|------|------|----------|-------------|
|
|
37
|
+
| text | string | Yes | The fact or information to remember |
|
|
38
|
+
| type | string | No | Type of memory: `fact`, `preference`, `decision`, `episodic`, or `goal`. Default: `fact` |
|
|
39
|
+
| importance | integer | No | Importance score 1-10. Default: auto-detected by LLM |
|
|
40
|
+
|
|
41
|
+
**Example:**
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"text": "User prefers TypeScript over JavaScript for new projects",
|
|
45
|
+
"type": "preference",
|
|
46
|
+
"importance": 7
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
**Returns:**
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"factId": "01234567-89ab-cdef-0123-456789abcdef",
|
|
54
|
+
"status": "stored",
|
|
55
|
+
"importance": 7,
|
|
56
|
+
"encrypted": true
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
### totalreclaw_recall
|
|
63
|
+
|
|
64
|
+
Search and retrieve relevant memories from long-term storage.
|
|
65
|
+
|
|
66
|
+
**Parameters:**
|
|
67
|
+
|
|
68
|
+
| Name | Type | Required | Description |
|
|
69
|
+
|------|------|----------|-------------|
|
|
70
|
+
| query | string | Yes | Natural language query to search memories |
|
|
71
|
+
| k | integer | No | Number of results to return. Default: 8, Max: 20 |
|
|
72
|
+
|
|
73
|
+
**Example:**
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"query": "What programming languages does the user prefer?",
|
|
77
|
+
"k": 5
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Returns:**
|
|
82
|
+
```json
|
|
83
|
+
{
|
|
84
|
+
"memories": [
|
|
85
|
+
{
|
|
86
|
+
"factId": "01234567-89ab-cdef-0123-456789abcdef",
|
|
87
|
+
"factText": "User prefers TypeScript over JavaScript for new projects",
|
|
88
|
+
"type": "preference",
|
|
89
|
+
"importance": 7,
|
|
90
|
+
"timestamp": "2026-02-22T10:30:00Z",
|
|
91
|
+
"relevanceScore": 0.95
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"totalCandidates": 47,
|
|
95
|
+
"searchLatencyMs": 42
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
### totalreclaw_forget
|
|
102
|
+
|
|
103
|
+
Delete a specific fact from memory.
|
|
104
|
+
|
|
105
|
+
**Parameters:**
|
|
106
|
+
|
|
107
|
+
| Name | Type | Required | Description |
|
|
108
|
+
|------|------|----------|-------------|
|
|
109
|
+
| factId | string | Yes | UUID of the fact to delete |
|
|
110
|
+
|
|
111
|
+
**Example:**
|
|
112
|
+
```json
|
|
113
|
+
{
|
|
114
|
+
"factId": "01234567-89ab-cdef-0123-456789abcdef"
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Returns:**
|
|
119
|
+
```json
|
|
120
|
+
{
|
|
121
|
+
"status": "deleted",
|
|
122
|
+
"factId": "01234567-89ab-cdef-0123-456789abcdef",
|
|
123
|
+
"tombstoneExpiry": "2026-03-24T00:00:00Z"
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
### totalreclaw_export
|
|
130
|
+
|
|
131
|
+
Export all stored memories in plaintext format.
|
|
132
|
+
|
|
133
|
+
**Parameters:**
|
|
134
|
+
|
|
135
|
+
| Name | Type | Required | Description |
|
|
136
|
+
|------|------|----------|-------------|
|
|
137
|
+
| format | string | No | Export format: `json` or `markdown`. Default: `json` |
|
|
138
|
+
|
|
139
|
+
**Example:**
|
|
140
|
+
```json
|
|
141
|
+
{
|
|
142
|
+
"format": "json"
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Returns (JSON format):**
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"exportVersion": "0.3",
|
|
150
|
+
"exportedAt": "2026-02-22T10:30:00Z",
|
|
151
|
+
"totalFacts": 127,
|
|
152
|
+
"facts": [
|
|
153
|
+
{
|
|
154
|
+
"id": "...",
|
|
155
|
+
"factText": "...",
|
|
156
|
+
"type": "preference",
|
|
157
|
+
"importance": 7,
|
|
158
|
+
"timestamp": "...",
|
|
159
|
+
"entities": [...],
|
|
160
|
+
"relations": [...]
|
|
161
|
+
}
|
|
162
|
+
],
|
|
163
|
+
"graph": {
|
|
164
|
+
"entities": {...},
|
|
165
|
+
"relations": [...]
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Returns (Markdown format):**
|
|
171
|
+
```markdown
|
|
172
|
+
# TotalReclaw Export
|
|
173
|
+
Exported: 2026-02-22T10:30:00Z
|
|
174
|
+
Total Facts: 127
|
|
175
|
+
|
|
176
|
+
## Preferences
|
|
177
|
+
- User prefers TypeScript over JavaScript for new projects (importance: 7)
|
|
178
|
+
|
|
179
|
+
## Decisions
|
|
180
|
+
- User decided to use PostgreSQL for the main database (importance: 8)
|
|
181
|
+
|
|
182
|
+
...
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
### totalreclaw_status
|
|
188
|
+
|
|
189
|
+
Check subscription status and usage quota.
|
|
190
|
+
|
|
191
|
+
**Parameters:** None
|
|
192
|
+
|
|
193
|
+
**Example:**
|
|
194
|
+
```json
|
|
195
|
+
{}
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
**Returns:**
|
|
199
|
+
```json
|
|
200
|
+
{
|
|
201
|
+
"tier": "Free",
|
|
202
|
+
"writesUsed": 42,
|
|
203
|
+
"writesLimit": 100,
|
|
204
|
+
"resetsAt": "2026-04-01",
|
|
205
|
+
"pricingUrl": "https://totalreclaw.xyz/pricing"
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Post-Install Setup
|
|
212
|
+
|
|
213
|
+
After installing TotalReclaw, the agent MUST complete setup automatically. **Do NOT ask the user to set environment variables manually.**
|
|
214
|
+
|
|
215
|
+
### Step 1: Set the server URL
|
|
216
|
+
|
|
217
|
+
The TotalReclaw server URL is always `https://api.totalreclaw.xyz`. Set it in the OpenClaw config:
|
|
218
|
+
|
|
219
|
+
```json
|
|
220
|
+
{ "env": { "TOTALRECLAW_SERVER_URL": "https://api.totalreclaw.xyz" } }
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### Step 2: Master password (recovery phrase)
|
|
224
|
+
|
|
225
|
+
The master password is a **12-word BIP-39 mnemonic** — like a crypto wallet seed phrase. It derives all encryption keys. The server never sees it.
|
|
226
|
+
|
|
227
|
+
Ask the user:
|
|
228
|
+
> "Do you have an existing TotalReclaw recovery phrase you'd like to restore, or should I generate a new one?"
|
|
229
|
+
|
|
230
|
+
- **New user:** Generate a random 12-word BIP-39 mnemonic and set it as `TOTALRECLAW_MASTER_PASSWORD`. Then display it prominently with a warning:
|
|
231
|
+
> "⚠️ SAVE YOUR RECOVERY PHRASE — it's the only way to recover your memories if you switch devices: `[phrase]`"
|
|
232
|
+
- **Returning user:** Ask them to provide their existing 12-word phrase, then set it as `TOTALRECLAW_MASTER_PASSWORD`.
|
|
233
|
+
|
|
234
|
+
### Step 3: Enable subgraph mode
|
|
235
|
+
|
|
236
|
+
Set `TOTALRECLAW_SUBGRAPH_MODE=true` in the config to enable on-chain storage (required for beta).
|
|
237
|
+
|
|
238
|
+
### Step 4: Set memory slot
|
|
239
|
+
|
|
240
|
+
Register TotalReclaw as the memory plugin:
|
|
241
|
+
```json
|
|
242
|
+
{ "plugins": { "slots": { "memory": "totalreclaw" } } }
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Step 5: Restart and verify
|
|
246
|
+
|
|
247
|
+
Restart the gateway, then confirm the plugin loaded by checking that `totalreclaw_remember`, `totalreclaw_recall`, `totalreclaw_forget`, and `totalreclaw_export` tools are available.
|
|
248
|
+
|
|
249
|
+
### Step 6: Explain the free tier
|
|
250
|
+
|
|
251
|
+
After setup completes, inform the user about the free tier:
|
|
252
|
+
> "You're on TotalReclaw's free tier — 100 memory writes per month, unlimited reads and searches.
|
|
253
|
+
> I'll let you know if you're approaching the limit. For unlimited writes, visit
|
|
254
|
+
> https://totalreclaw.xyz/pricing"
|
|
255
|
+
|
|
256
|
+
The agent proactively warns when quota usage exceeds 80%. If the limit is reached, new writes are rejected but all existing memories remain searchable.
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
## Description
|
|
261
|
+
|
|
262
|
+
TotalReclaw is a zero-knowledge encrypted memory vault for AI agents. Think of it as a "password manager for AI memory" that provides:
|
|
263
|
+
|
|
264
|
+
1. **End-to-End Encryption** - All memories are encrypted client-side using AES-256-GCM. The server never sees plaintext data.
|
|
265
|
+
|
|
266
|
+
2. **Portable Memory** - Export all data as plaintext with one command. No vendor lock-in.
|
|
267
|
+
|
|
268
|
+
3. **Universal Compatibility** - Works across any MCP-compatible AI agent, not just OpenClaw.
|
|
269
|
+
|
|
270
|
+
4. **Intelligent Extraction** - Automatically extracts atomic facts, preferences, decisions, and goals from conversations.
|
|
271
|
+
|
|
272
|
+
5. **Smart Decay** - Important memories persist; trivial ones fade over time using a decay algorithm.
|
|
273
|
+
|
|
274
|
+
6. **Graph-Based** - Maintains entity relationships for multi-hop reasoning.
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Instructions for the LLM
|
|
279
|
+
|
|
280
|
+
### IMPORTANT: Do Not Write Cleartext Memory Files
|
|
281
|
+
|
|
282
|
+
TotalReclaw handles all memory storage with end-to-end encryption. **Do NOT write facts, preferences, or decisions to MEMORY.md or memory/*.md files.** All memories are stored encrypted on-chain and recalled automatically — writing cleartext files defeats the zero-knowledge guarantee.
|
|
283
|
+
|
|
284
|
+
If you need to store a memory, use the `totalreclaw_remember` tool. If you need to recall memories, use `totalreclaw_recall`.
|
|
285
|
+
|
|
286
|
+
### Billing Awareness
|
|
287
|
+
|
|
288
|
+
TotalReclaw has a free tier (100 writes/month, unlimited reads). The plugin monitors quota usage automatically:
|
|
289
|
+
- If usage exceeds 80%, a warning is injected into your context at conversation start
|
|
290
|
+
- If a write fails with quota exceeded (403), inform the user and suggest visiting https://totalreclaw.xyz/pricing
|
|
291
|
+
- Use `totalreclaw_status` when the user asks about their subscription, quota, or billing
|
|
292
|
+
|
|
293
|
+
### When to Use Each Tool
|
|
294
|
+
|
|
295
|
+
#### totalreclaw_remember
|
|
296
|
+
|
|
297
|
+
Use when:
|
|
298
|
+
- The user explicitly asks you to remember something ("remember that...", "note that...", "don't forget...")
|
|
299
|
+
- You detect a significant preference, decision, or fact that will be useful in future conversations
|
|
300
|
+
- The user corrects or updates previous information about themselves
|
|
301
|
+
- You observe important context about the user's work, projects, or preferences
|
|
302
|
+
|
|
303
|
+
Do NOT use for:
|
|
304
|
+
- Temporary information relevant only to the current conversation
|
|
305
|
+
- Information the user explicitly says is temporary
|
|
306
|
+
- Generic knowledge that isn't user-specific
|
|
307
|
+
|
|
308
|
+
#### totalreclaw_recall
|
|
309
|
+
|
|
310
|
+
Use when:
|
|
311
|
+
- The user asks about their past preferences, decisions, or history
|
|
312
|
+
- You need context about the user's projects, tools, or working style
|
|
313
|
+
- The user asks "do you remember..." or "what did I tell you about..."
|
|
314
|
+
- You're unsure about a user preference and want to check before making assumptions
|
|
315
|
+
- Starting a new conversation to load relevant context
|
|
316
|
+
|
|
317
|
+
Do NOT use for:
|
|
318
|
+
- Every single message (use sparingly, max once per conversation start or when explicitly relevant)
|
|
319
|
+
- General knowledge questions unrelated to the user
|
|
320
|
+
|
|
321
|
+
#### totalreclaw_forget
|
|
322
|
+
|
|
323
|
+
Use when:
|
|
324
|
+
- The user explicitly asks you to forget something ("forget that...", "delete that memory...")
|
|
325
|
+
- The user indicates information is outdated or incorrect and should be removed
|
|
326
|
+
- The user requests a clean slate for a specific topic
|
|
327
|
+
|
|
328
|
+
#### totalreclaw_export
|
|
329
|
+
|
|
330
|
+
Use when:
|
|
331
|
+
- The user asks to export, backup, or download their memory data
|
|
332
|
+
- The user wants to see everything you know about them
|
|
333
|
+
- The user is migrating to another system
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
### Best Practices
|
|
338
|
+
|
|
339
|
+
1. **Atomic Facts Only**: Each memory should be a single, atomic piece of information.
|
|
340
|
+
- Good: "User prefers dark mode in all editors"
|
|
341
|
+
- Bad: "User likes dark mode, uses VS Code, and works at Google"
|
|
342
|
+
|
|
343
|
+
2. **Importance Scoring**:
|
|
344
|
+
- 1-3: Trivial, unlikely to matter (small talk, pleasantries)
|
|
345
|
+
- 4-6: Useful context (tool preferences, working style)
|
|
346
|
+
- 7-8: Important (key decisions, major preferences)
|
|
347
|
+
- 9-10: Critical (core values, non-negotiables, safety info)
|
|
348
|
+
|
|
349
|
+
3. **Search Before Storing**: Always recall similar memories before storing new ones to avoid duplicates.
|
|
350
|
+
|
|
351
|
+
4. **Respect User Privacy**: Never store sensitive information (passwords, API keys, personal secrets) even if requested.
|
|
352
|
+
|
|
353
|
+
5. **Prefer NOOP**: When in doubt about whether to store something, prefer not storing it. Memory pollution is worse than missing a minor fact.
|
|
354
|
+
|
|
355
|
+
---
|
|
356
|
+
|
|
357
|
+
## Extraction Prompts (Mem0-Style)
|
|
358
|
+
|
|
359
|
+
TotalReclaw uses a Mem0-style extraction pattern with four possible actions:
|
|
360
|
+
|
|
361
|
+
### Actions
|
|
362
|
+
|
|
363
|
+
| Action | Description | When to Use |
|
|
364
|
+
|--------|-------------|-------------|
|
|
365
|
+
| ADD | Store as new memory | No similar memory exists |
|
|
366
|
+
| UPDATE | Modify existing memory | New info refines/clarifies existing |
|
|
367
|
+
| DELETE | Remove existing memory | New info contradicts existing |
|
|
368
|
+
| NOOP | Do nothing | Already captured or not worth storing |
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
### Pre-Compaction Extraction
|
|
373
|
+
|
|
374
|
+
Triggered before OpenClaw's context compaction (typically every few hours in long sessions).
|
|
375
|
+
|
|
376
|
+
**System Prompt:**
|
|
377
|
+
|
|
378
|
+
```
|
|
379
|
+
You are a memory extraction engine for an AI assistant. Your job is to analyze conversations and extract structured, atomic facts that should be remembered long-term.
|
|
380
|
+
|
|
381
|
+
## Extraction Guidelines
|
|
382
|
+
|
|
383
|
+
1. **Atomicity**: Each fact should be a single, atomic piece of information
|
|
384
|
+
- GOOD: "User prefers TypeScript over JavaScript for new projects"
|
|
385
|
+
- BAD: "User likes TypeScript, uses VS Code, and works at Google"
|
|
386
|
+
|
|
387
|
+
2. **Types**:
|
|
388
|
+
- **fact**: Objective information about the user/world
|
|
389
|
+
- **preference**: User's likes, dislikes, or preferences
|
|
390
|
+
- **decision**: Choices the user has made
|
|
391
|
+
- **episodic**: Event-based memories (what happened when)
|
|
392
|
+
- **goal**: User's objectives or targets
|
|
393
|
+
|
|
394
|
+
3. **Importance Scoring (1-10)**:
|
|
395
|
+
- 1-3: Trivial, unlikely to matter (small talk, pleasantries)
|
|
396
|
+
- 4-6: Useful context (tool preferences, working style)
|
|
397
|
+
- 7-8: Important (key decisions, major preferences)
|
|
398
|
+
- 9-10: Critical (core values, non-negotiables, safety info)
|
|
399
|
+
|
|
400
|
+
4. **Confidence (0-1)**:
|
|
401
|
+
- How certain are you that this is accurate and worth storing?
|
|
402
|
+
|
|
403
|
+
5. **Entities**: Extract named entities (people, projects, tools, concepts)
|
|
404
|
+
- Use stable IDs: hash of name+type (e.g., "typescript-tool")
|
|
405
|
+
- Types: person, project, tool, preference, concept, location, etc.
|
|
406
|
+
|
|
407
|
+
6. **Relations**: Extract relationships between entities
|
|
408
|
+
- Common predicates: prefers, uses, works_on, decided_to_use, dislikes, etc.
|
|
409
|
+
|
|
410
|
+
7. **Actions (Mem0 pattern)**:
|
|
411
|
+
- **ADD**: New fact, no conflict with existing memories
|
|
412
|
+
- **UPDATE**: Modifies or refines an existing fact (provide existingFactId)
|
|
413
|
+
- **DELETE**: Contradicts and replaces an existing fact
|
|
414
|
+
- **NOOP**: Not worth storing or already captured
|
|
415
|
+
```
|
|
416
|
+
|
|
417
|
+
**User Prompt Template:**
|
|
418
|
+
|
|
419
|
+
```
|
|
420
|
+
## Task: Pre-Compaction Memory Extraction
|
|
421
|
+
|
|
422
|
+
You are reviewing the last 20 turns of conversation before they are compacted. Extract ALL valuable long-term memories.
|
|
423
|
+
|
|
424
|
+
## Conversation History (last 20 turns):
|
|
425
|
+
{{CONVERSATION_HISTORY}}
|
|
426
|
+
|
|
427
|
+
## Existing Memories (for deduplication):
|
|
428
|
+
{{EXISTING_MEMORIES}}
|
|
429
|
+
|
|
430
|
+
## Instructions:
|
|
431
|
+
1. Review each turn carefully for extractable information
|
|
432
|
+
2. Extract atomic facts, preferences, decisions, episodic memories, and goals
|
|
433
|
+
3. For each fact, determine if it's NEW (ADD), modifies existing (UPDATE), contradicts existing (DELETE), or is redundant (NOOP)
|
|
434
|
+
4. Score importance based on long-term relevance
|
|
435
|
+
5. Extract entities and relations
|
|
436
|
+
|
|
437
|
+
## Output Format:
|
|
438
|
+
Return a JSON object with:
|
|
439
|
+
{
|
|
440
|
+
"facts": [
|
|
441
|
+
{
|
|
442
|
+
"factText": "string (max 512 chars)",
|
|
443
|
+
"type": "fact|preference|decision|episodic|goal",
|
|
444
|
+
"importance": 1-10,
|
|
445
|
+
"confidence": 0-1,
|
|
446
|
+
"action": "ADD|UPDATE|DELETE|NOOP",
|
|
447
|
+
"existingFactId": "string (if UPDATE/DELETE)",
|
|
448
|
+
"entities": [{"id": "...", "name": "...", "type": "..."}],
|
|
449
|
+
"relations": [{"subjectId": "...", "predicate": "...", "objectId": "...", "confidence": 0-1}]
|
|
450
|
+
}
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
Focus on quality over quantity. Better to have 5 highly accurate facts than 20 noisy ones.
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
### Post-Turn Extraction
|
|
460
|
+
|
|
461
|
+
Triggered every N turns (configurable, default: 5) for lightweight extraction.
|
|
462
|
+
|
|
463
|
+
**User Prompt Template:**
|
|
464
|
+
|
|
465
|
+
```
|
|
466
|
+
## Task: Quick Turn Extraction
|
|
467
|
+
|
|
468
|
+
You are doing a lightweight extraction after a few turns. Focus ONLY on high-importance items.
|
|
469
|
+
|
|
470
|
+
## Recent Turns (last 3):
|
|
471
|
+
{{CONVERSATION_HISTORY}}
|
|
472
|
+
|
|
473
|
+
## Existing Memories (top matches):
|
|
474
|
+
{{EXISTING_MEMORIES}}
|
|
475
|
+
|
|
476
|
+
## Instructions:
|
|
477
|
+
1. Extract ONLY items with importance >= 7 (critical preferences, key decisions)
|
|
478
|
+
2. Skip trivial information - this is a quick pass
|
|
479
|
+
3. Use ADD/UPDATE/DELETE/NOOP appropriately
|
|
480
|
+
4. Be aggressive about NOOP for low-value content
|
|
481
|
+
|
|
482
|
+
## Output Format:
|
|
483
|
+
Return a JSON object matching the extraction schema.
|
|
484
|
+
|
|
485
|
+
Remember: Less is more. Only extract what truly matters.
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
### Explicit Command Detection
|
|
491
|
+
|
|
492
|
+
Detect when the user explicitly requests memory storage.
|
|
493
|
+
|
|
494
|
+
**Trigger Patterns (regex + LLM classification):**
|
|
495
|
+
|
|
496
|
+
```
|
|
497
|
+
# Explicit memory commands
|
|
498
|
+
"remember that..."
|
|
499
|
+
"don't forget..."
|
|
500
|
+
"note that..."
|
|
501
|
+
"I prefer..."
|
|
502
|
+
"for future reference..."
|
|
503
|
+
"make a note..."
|
|
504
|
+
"store this..."
|
|
505
|
+
"keep in mind..."
|
|
506
|
+
|
|
507
|
+
# Explicit forget commands
|
|
508
|
+
"forget about..."
|
|
509
|
+
"delete that memory..."
|
|
510
|
+
"remove that from memory..."
|
|
511
|
+
"stop remembering..."
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
**User Prompt Template:**
|
|
515
|
+
|
|
516
|
+
```
|
|
517
|
+
## Task: Explicit Memory Storage
|
|
518
|
+
|
|
519
|
+
The user has explicitly requested to remember something. This is a HIGH PRIORITY extraction.
|
|
520
|
+
|
|
521
|
+
## User's Explicit Request:
|
|
522
|
+
{{USER_REQUEST}}
|
|
523
|
+
|
|
524
|
+
## Conversation Context:
|
|
525
|
+
{{CONVERSATION_CONTEXT}}
|
|
526
|
+
|
|
527
|
+
## Instructions:
|
|
528
|
+
1. Parse what the user wants remembered
|
|
529
|
+
2. Boost importance by +1 (explicit requests matter more)
|
|
530
|
+
3. Extract as atomic fact(s) with appropriate type
|
|
531
|
+
4. Check against existing memories for UPDATE/DELETE
|
|
532
|
+
5. Set confidence HIGH (user explicitly wants this stored)
|
|
533
|
+
|
|
534
|
+
## Output Format:
|
|
535
|
+
Return a JSON object matching the extraction schema.
|
|
536
|
+
|
|
537
|
+
This is user-initiated storage - ensure accuracy and capture their intent precisely.
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
---
|
|
541
|
+
|
|
542
|
+
### Deduplication Judge
|
|
543
|
+
|
|
544
|
+
Used to determine ADD vs UPDATE vs DELETE vs NOOP for each extracted fact.
|
|
545
|
+
|
|
546
|
+
**System Prompt:**
|
|
547
|
+
|
|
548
|
+
```
|
|
549
|
+
You are a memory deduplication judge. Your job is to determine if a new fact should be added as new, update an existing fact, delete/replace an existing fact, or be ignored as redundant.
|
|
550
|
+
|
|
551
|
+
## Decision Rules:
|
|
552
|
+
|
|
553
|
+
1. **ADD**: The fact is genuinely new information not covered by existing memories
|
|
554
|
+
2. **UPDATE**: The fact refines, clarifies, or partially modifies an existing fact
|
|
555
|
+
3. **DELETE**: The fact directly contradicts an existing fact and should replace it
|
|
556
|
+
4. **NOOP**: The fact is already fully captured by existing memories
|
|
557
|
+
|
|
558
|
+
Be strict about NOOP - if the information is essentially the same, mark it as NOOP.
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
**User Prompt Template:**
|
|
562
|
+
|
|
563
|
+
```
|
|
564
|
+
## New Fact to Evaluate:
|
|
565
|
+
{{NEW_FACT}}
|
|
566
|
+
|
|
567
|
+
## Similar Existing Facts:
|
|
568
|
+
{{EXISTING_FACTS}}
|
|
569
|
+
|
|
570
|
+
## Instructions:
|
|
571
|
+
1. Compare the new fact against each existing fact
|
|
572
|
+
2. Determine the appropriate action (ADD/UPDATE/DELETE/NOOP)
|
|
573
|
+
3. If UPDATE or DELETE, identify which existing fact to modify
|
|
574
|
+
4. Provide your confidence (0-1) and reasoning
|
|
575
|
+
|
|
576
|
+
## Output Format:
|
|
577
|
+
{
|
|
578
|
+
"decision": "ADD|UPDATE|DELETE|NOOP",
|
|
579
|
+
"existingFactId": "string (if UPDATE/DELETE)",
|
|
580
|
+
"confidence": 0-1,
|
|
581
|
+
"reasoning": "string"
|
|
582
|
+
}
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
## Configuration
|
|
588
|
+
|
|
589
|
+
Default configuration values:
|
|
590
|
+
|
|
591
|
+
| Key | Default | Description |
|
|
592
|
+
|-----|---------|-------------|
|
|
593
|
+
| `serverUrl` | `https://api.totalreclaw.xyz` | TotalReclaw server URL |
|
|
594
|
+
| `autoExtractEveryTurns` | `5` | Turns between automatic extractions |
|
|
595
|
+
| `minImportanceForAutoStore` | `6` | Minimum importance to auto-store |
|
|
596
|
+
| `maxMemoriesInContext` | `8` | Maximum memories to inject into context |
|
|
597
|
+
| `forgetThreshold` | `0.3` | Decay score threshold for eviction |
|
|
598
|
+
| `decayHalfLifeDays` | `30` | Memory decay half-life in days |
|
|
599
|
+
|
|
600
|
+
---
|
|
601
|
+
|
|
602
|
+
## Privacy & Security
|
|
603
|
+
|
|
604
|
+
- **Zero-Knowledge**: All encryption happens client-side. The server never sees plaintext.
|
|
605
|
+
- **Master Password**: Never sent to the server. Used only for key derivation (Argon2id).
|
|
606
|
+
- **Export Portability**: Full plaintext export available anytime.
|
|
607
|
+
- **Tombstone Recovery**: Deleted memories can be recovered within 30 days.
|
|
608
|
+
|
|
609
|
+
---
|
|
610
|
+
|
|
611
|
+
## Lifecycle Hooks
|
|
612
|
+
|
|
613
|
+
TotalReclaw integrates with OpenClaw through three lifecycle hooks:
|
|
614
|
+
|
|
615
|
+
| Hook | Priority | Description |
|
|
616
|
+
|------|----------|-------------|
|
|
617
|
+
| `before_agent_start` | 10 | Retrieve relevant memories before agent processes message |
|
|
618
|
+
| `agent_end` | 90 | Extract and store facts after agent completes turn |
|
|
619
|
+
| `pre_compaction` | 5 | Full memory flush before context compaction |
|
|
620
|
+
|
|
621
|
+
---
|
|
622
|
+
|
|
623
|
+
## Example Usage
|
|
624
|
+
|
|
625
|
+
### Storing a preference
|
|
626
|
+
|
|
627
|
+
```json
|
|
628
|
+
// Tool call
|
|
629
|
+
{
|
|
630
|
+
"tool": "totalreclaw_remember",
|
|
631
|
+
"params": {
|
|
632
|
+
"text": "User prefers functional programming over OOP",
|
|
633
|
+
"type": "preference",
|
|
634
|
+
"importance": 6
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
// Response
|
|
639
|
+
{
|
|
640
|
+
"factId": "abc123",
|
|
641
|
+
"status": "stored"
|
|
642
|
+
}
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
### Recalling memories
|
|
646
|
+
|
|
647
|
+
```json
|
|
648
|
+
// Tool call
|
|
649
|
+
{
|
|
650
|
+
"tool": "totalreclaw_recall",
|
|
651
|
+
"params": {
|
|
652
|
+
"query": "programming preferences",
|
|
653
|
+
"k": 5
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Response
|
|
658
|
+
{
|
|
659
|
+
"memories": [
|
|
660
|
+
{
|
|
661
|
+
"factId": "abc123",
|
|
662
|
+
"factText": "User prefers functional programming over OOP",
|
|
663
|
+
"type": "preference",
|
|
664
|
+
"importance": 6,
|
|
665
|
+
"relevanceScore": 0.92
|
|
666
|
+
}
|
|
667
|
+
]
|
|
668
|
+
}
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
### Forgetting a memory
|
|
672
|
+
|
|
673
|
+
```json
|
|
674
|
+
// Tool call
|
|
675
|
+
{
|
|
676
|
+
"tool": "totalreclaw_forget",
|
|
677
|
+
"params": {
|
|
678
|
+
"factId": "abc123"
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
// Response
|
|
683
|
+
{
|
|
684
|
+
"status": "deleted",
|
|
685
|
+
"factId": "abc123"
|
|
686
|
+
}
|
|
687
|
+
```
|