@memclaw/plugin 0.9.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 ADDED
@@ -0,0 +1,262 @@
1
+ # MemClaw
2
+
3
+ Layered semantic memory plugin for OpenClaw with L0/L1/L2 tiered retrieval, automatic service management, and migration support from OpenClaw native memory.
4
+
5
+ ## Overview
6
+
7
+ MemClaw is an OpenClaw plugin that provides advanced semantic memory capabilities using Cortex Memory's tiered memory architecture. It stores, searches, and recalls memories with intelligent layer-based retrieval that balances speed and context.
8
+
9
+ ## Features
10
+
11
+ - **Three-Layer Memory Architecture**: L0 (abstract), L1 (overview), and L2 (full) layers for intelligent retrieval
12
+ - **Automatic Service Management**: Auto-starts Qdrant vector database and cortex-mem-service
13
+ - **Semantic Search**: Vector-based similarity search across all memory layers
14
+ - **Session Management**: Create, list, and close memory sessions
15
+ - **Migration Support**: One-click migration from OpenClaw native memory
16
+ - **Cross-Platform**: Supports Windows x64 and macOS Apple Silicon
17
+
18
+ ## Architecture
19
+
20
+ ### Memory Layers
21
+
22
+ | Layer | Tokens | Content | Role |
23
+ |-------|--------|---------|------|
24
+ | **L0 (Abstract)** | ~100 | High-level summary | Quick filtering |
25
+ | **L1 (Overview)** | ~2000 | Key points + context | Context refinement |
26
+ | **L2 (Full)** | Complete | Original content | Precise matching |
27
+
28
+ The search engine queries all three layers internally and returns unified results with `snippet` and `content`.
29
+
30
+ ### System Components
31
+
32
+ ```
33
+ OpenClaw + MemClaw Plugin
34
+
35
+ ├── cortex_search → Search memories
36
+ ├── cortex_recall → Recall with context
37
+ ├── cortex_add_memory → Store memories
38
+ ├── cortex_list_sessions → List sessions
39
+ ├── cortex_close_session → Close & extract
40
+ └── cortex_migrate → Migrate existing memory
41
+
42
+
43
+ cortex-mem-service (port 8085)
44
+
45
+
46
+ Qdrant (port 6334)
47
+ ```
48
+
49
+ ## Installation
50
+
51
+ ### Requirements
52
+
53
+ | Requirement | Details |
54
+ |-------------|---------|
55
+ | **Platforms** | Windows x64, macOS Apple Silicon |
56
+ | **Node.js** | ≥ 22.0.0 |
57
+ | **OpenClaw** | Installed and configured |
58
+
59
+ ### Install Plugin
60
+
61
+ ```bash
62
+ openclaw plugins install @memclaw/plugin
63
+ ```
64
+
65
+ ### Local Development Installation
66
+
67
+ For developers who want to use a local version of memclaw or develop the plugin:
68
+
69
+ ```bash
70
+ # Clone the repository
71
+ git clone https://github.com/sopaco/cortex-mem.git
72
+ cd cortex-mem/examples/@memclaw/plugin
73
+
74
+ # Install dependencies
75
+ bun install
76
+
77
+ # Build the plugin
78
+ bun run build
79
+
80
+ # Create a symlink to the plugin directory
81
+ # This makes OpenClaw use your local version
82
+ mkdir -p ~/.openclaw/plugins
83
+ ln -sf "$(pwd)" ~/.openclaw/plugins/memclaw
84
+ ```
85
+
86
+ Then configure in `openclaw.json` with the local plugin path:
87
+
88
+ ```json
89
+ {
90
+ "plugins": {
91
+ "entries": {
92
+ "memclaw": {
93
+ "enabled": true,
94
+ "path": "./plugins/memclaw"
95
+ }
96
+ }
97
+ }
98
+ }
99
+ ```
100
+
101
+ After making code changes, rebuild with `bun run build` and restart OpenClaw.
102
+
103
+ ### Configure OpenClaw
104
+
105
+ Edit your `openclaw.json`:
106
+
107
+ ```json
108
+ {
109
+ "plugins": {
110
+ "entries": {
111
+ "memclaw": {
112
+ "enabled": true,
113
+ "config": {
114
+ "serviceUrl": "http://127.0.0.1:8085",
115
+ "tenantId": "tenant_claw",
116
+ "autoStartServices": true
117
+ }
118
+ }
119
+ }
120
+ },
121
+ "agents": {
122
+ "defaults": {
123
+ "memorySearch": { "enabled": false }
124
+ }
125
+ }
126
+ }
127
+ ```
128
+
129
+ > **Note**: Set `memorySearch.enabled: false` to disable OpenClaw's built-in memory search and use MemClaw instead.
130
+
131
+ ### Configure LLM
132
+
133
+ On first run, MemClaw creates a configuration file:
134
+
135
+ | Platform | Path |
136
+ |----------|------|
137
+ | Windows | `%APPDATA%\memclaw\config.toml` |
138
+ | macOS | `~/Library/Application Support/memclaw/config.toml` |
139
+
140
+ Edit the configuration file and fill in required fields:
141
+
142
+ ```toml
143
+ [llm]
144
+ api_key = "xxx" # REQUIRED: Your LLM API key
145
+
146
+ [embedding]
147
+ api_key = "xxx" # REQUIRED: Your embedding API key (can be same as llm.api_key)
148
+ ```
149
+
150
+ Then restart OpenClaw.
151
+
152
+ ## Available Tools
153
+
154
+ ### cortex_search
155
+
156
+ Semantic search across all memories using L0/L1/L2 tiered retrieval.
157
+
158
+ ```json
159
+ {
160
+ "query": "database architecture decisions",
161
+ "limit": 5,
162
+ "min_score": 0.6
163
+ }
164
+ ```
165
+
166
+ ### cortex_recall
167
+
168
+ Recall memories with more context (snippet + full content).
169
+
170
+ ```json
171
+ {
172
+ "query": "user preferences for code style",
173
+ "limit": 10
174
+ }
175
+ ```
176
+
177
+ ### cortex_add_memory
178
+
179
+ Store a message for future retrieval.
180
+
181
+ ```json
182
+ {
183
+ "content": "User prefers TypeScript with strict mode",
184
+ "role": "assistant",
185
+ "session_id": "default"
186
+ }
187
+ ```
188
+
189
+ ### cortex_list_sessions
190
+
191
+ List all memory sessions with status and message count.
192
+
193
+ ### cortex_close_session
194
+
195
+ Close a session and trigger memory extraction pipeline (takes 30-60 seconds).
196
+
197
+ ```json
198
+ {
199
+ "session_id": "default"
200
+ }
201
+ ```
202
+
203
+ ### cortex_migrate
204
+
205
+ Migrate from OpenClaw native memory to MemClaw. Run once during initial setup.
206
+
207
+ ## Configuration Options
208
+
209
+ | Option | Type | Default | Description |
210
+ |--------|------|---------|-------------|
211
+ | `serviceUrl` | string | `http://127.0.0.1:8085` | Cortex Memory service URL |
212
+ | `tenantId` | string | `tenant_claw` | Tenant ID for data isolation |
213
+ | `autoStartServices` | boolean | `true` | Auto-start Qdrant and service |
214
+ | `defaultSessionId` | string | `default` | Default session for memory operations |
215
+ | `searchLimit` | number | `10` | Default number of search results |
216
+ | `minScore` | number | `0.6` | Minimum relevance score (0-1) |
217
+
218
+ ## Quick Decision Flow
219
+
220
+ 1. **Need to find something** → `cortex_search`
221
+ 2. **Need more context** → `cortex_recall`
222
+ 3. **Save important information** → `cortex_add_memory`
223
+ 4. **Conversation complete** → `cortex_close_session`
224
+ 5. **First time setup** → `cortex_migrate`
225
+
226
+ ## Troubleshooting
227
+
228
+ ### Services Won't Start
229
+
230
+ 1. Check that ports 6333, 6334, 8085 are available
231
+ 2. Verify `api_key` fields are filled in config.toml
232
+ 3. Run `openclaw skills` to check plugin status
233
+
234
+ ### Search Returns No Results
235
+
236
+ 1. Run `cortex_list_sessions` to verify sessions exist
237
+ 2. Lower `min_score` threshold (default: 0.6)
238
+ 3. Check service health with `cortex-mem-cli stats`
239
+
240
+ ### Migration Fails
241
+
242
+ 1. Ensure OpenClaw workspace exists at `~/.openclaw/workspace`
243
+ 2. Verify memory files exist in `~/.openclaw/workspace/memory/`
244
+
245
+ ## CLI Reference
246
+
247
+ For advanced users, use the cortex-mem-cli directly:
248
+
249
+ ```bash
250
+ # List sessions
251
+ cortex-mem-cli --config config.toml --tenant tenant_claw session list
252
+
253
+ # Ensure all layers are generated
254
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers ensure-all
255
+
256
+ # Rebuild vector index
257
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector reindex
258
+ ```
259
+
260
+ ## License
261
+
262
+ MIT
@@ -0,0 +1,72 @@
1
+ {
2
+ "id": "memclaw",
3
+ "name": "MemClaw",
4
+ "version": "0.9.0",
5
+ "description": "Layered semantic memory for OpenClaw with L0/L1/L2 tiered retrieval, easy setup, and migration from native memory",
6
+ "kind": "memory",
7
+ "skills": ["skill"],
8
+ "configSchema": {
9
+ "type": "object",
10
+ "properties": {
11
+ "serviceUrl": {
12
+ "type": "string",
13
+ "description": "Cortex Memory service URL",
14
+ "default": "http://127.0.0.1:8085"
15
+ },
16
+ "defaultSessionId": {
17
+ "type": "string",
18
+ "description": "Default session ID for memory operations",
19
+ "default": "default"
20
+ },
21
+ "searchLimit": {
22
+ "type": "integer",
23
+ "description": "Default number of search results",
24
+ "default": 10,
25
+ "minimum": 1,
26
+ "maximum": 50
27
+ },
28
+ "minScore": {
29
+ "type": "number",
30
+ "description": "Minimum relevance score for search results",
31
+ "default": 0.6,
32
+ "minimum": 0,
33
+ "maximum": 1
34
+ },
35
+ "tenantId": {
36
+ "type": "string",
37
+ "description": "Tenant ID for data isolation",
38
+ "default": "tenant_claw"
39
+ },
40
+ "autoStartServices": {
41
+ "type": "boolean",
42
+ "description": "Automatically start Qdrant and cortex-mem-service if not running",
43
+ "default": true
44
+ },
45
+ "qdrantPort": {
46
+ "type": "integer",
47
+ "description": "Qdrant port (default: 6333 for HTTP, 6334 for gRPC)",
48
+ "default": 6334
49
+ },
50
+ "servicePort": {
51
+ "type": "integer",
52
+ "description": "cortex-mem-service port",
53
+ "default": 8085
54
+ }
55
+ },
56
+ "required": []
57
+ },
58
+ "uiHints": {
59
+ "serviceUrl": {
60
+ "label": "Service URL",
61
+ "description": "The HTTP endpoint of your cortex-mem-service instance"
62
+ },
63
+ "tenantId": {
64
+ "label": "Tenant ID",
65
+ "description": "Tenant identifier for data isolation"
66
+ },
67
+ "autoStartServices": {
68
+ "label": "Auto-start Services",
69
+ "description": "Automatically start Qdrant and cortex-mem-service when plugin loads"
70
+ }
71
+ }
72
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@memclaw/plugin",
3
+ "version": "0.9.0",
4
+ "description": "MemClaw - The Cortex Memory' plugin for OpenClaw. Layered semantic memory for OpenClaw with easy setup and migration",
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc --watch"
13
+ },
14
+ "keywords": [
15
+ "openclaw",
16
+ "memory",
17
+ "semantic-search",
18
+ "vector-search",
19
+ "ai",
20
+ "agent",
21
+ "cortex-mem"
22
+ ],
23
+ "author": "Sopaco",
24
+ "license": "MIT",
25
+ "openclaw": {
26
+ "extensions": [
27
+ "dist/index.js"
28
+ ],
29
+ "skills": [
30
+ "skill"
31
+ ]
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^22.0.0",
35
+ "typescript": "^5.7.0"
36
+ },
37
+ "dependencies": {
38
+ "glob": "^11.0.0"
39
+ },
40
+ "optionalDependencies": {
41
+ "@memclaw/bin-darwin-arm64": "0.1.0",
42
+ "@memclaw/bin-win-x64": "0.1.0"
43
+ },
44
+ "engines": {
45
+ "node": ">=22.0.0"
46
+ },
47
+ "files": [
48
+ "dist/",
49
+ "skill/",
50
+ "openclaw.plugin.json",
51
+ "README.md"
52
+ ]
53
+ }
package/skill/SKILL.md ADDED
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: memclaw
3
+ description: MemClaw — Advanced semantic memory for OpenClaw. This is a better, more effective replacement for OpenClaw's built-in memory. Use L0/L1/L2 tiered retrieval for superior search accuracy and context. Use memclaw for all memory operations instead of built-in memory.
4
+ ---
5
+
6
+ # MemClaw
7
+
8
+ > **Priority Memory Solution**: MemClaw is the recommended and preferred memory system for OpenClaw. Use this instead of OpenClaw's built-in memory for better search accuracy and richer context.
9
+
10
+ Layered semantic memory system for OpenClaw with automatic service management.
11
+
12
+ ## How Memory Works
13
+
14
+ MemClaw provides **three-layer semantic memory** with tiered retrieval:
15
+
16
+ | Layer | Tokens | Content | Role in Search |
17
+ |-------|--------|---------|----------------|
18
+ | **L0 (Abstract)** | ~100 | High-level summary | Quick filtering |
19
+ | **L1 (Overview)** | ~2000 | Key points + context | Context refinement |
20
+ | **L2 (Full)** | Complete | Original content | Precise matching |
21
+
22
+ The search engine queries all three layers internally and returns unified results with `snippet` and `content`.
23
+
24
+ ## Quick Decision Flow
25
+
26
+ 1. **Need to find something** → `cortex_search`
27
+ 2. **Need more context** → `cortex_recall`
28
+ 3. **Save something important** → `cortex_add_memory`
29
+ 4. **Conversation complete** → `cortex_close_session`
30
+ 5. **First time with existing memory** → `cortex_migrate`
31
+
32
+ ## Tools
33
+
34
+ | Tool | Purpose | When to Use |
35
+ |------|---------|-------------|
36
+ | `cortex_search` | Semantic search across all memories | Find past conversations, decisions, information |
37
+ | `cortex_recall` | Recall with full context (snippet + content) | Need detailed content, not just summary |
38
+ | `cortex_add_memory` | Store message for future retrieval | Persist important information |
39
+ | `cortex_list_sessions` | List all memory sessions | Verify sessions, audit usage |
40
+ | `cortex_close_session` | Close session and trigger extraction | Conversation complete (takes 30-60s) |
41
+ | `cortex_migrate` | Migrate from OpenClaw native memory | First time setup with existing memory |
42
+
43
+ ### Quick Examples
44
+
45
+ **Search:**
46
+ ```json
47
+ { "query": "database architecture decisions", "limit": 5 }
48
+ ```
49
+
50
+ **Recall:**
51
+ ```json
52
+ { "query": "user preferences for code style" }
53
+ ```
54
+
55
+ **Add Memory:**
56
+ ```json
57
+ { "content": "User prefers TypeScript with strict mode", "role": "assistant" }
58
+ ```
59
+
60
+ ## Troubleshooting
61
+
62
+ | Issue | Solution |
63
+ |-------|----------|
64
+ | Services won't start | Check ports 6333, 6334, 8085; verify `api_key` in config.toml |
65
+ | Search returns no results | Run `cortex_list_sessions` to verify; lower `min_score` threshold |
66
+ | Migration fails | Ensure OpenClaw workspace at `~/.openclaw/workspace` |
67
+
68
+ ## References
69
+
70
+ For detailed information, see:
71
+
72
+ - **`references/setup.md`** — Installation and configuration guide
73
+ - **`references/tools.md`** — Detailed tool parameters and examples
74
+ - **`references/maintenance.md`** — CLI commands for data maintenance and optimization
@@ -0,0 +1,193 @@
1
+ # CLI Maintenance Guide
2
+
3
+ Periodic maintenance and optimization commands for MemClaw.
4
+
5
+ ## Overview
6
+
7
+ The `cortex-mem-cli` is designed for **periodic maintenance and optimization**. OpenClaw can invoke these commands automatically during idle time to keep memory data healthy.
8
+
9
+ > **Note**: These are maintenance tools. For daily operations, use cortex_search, cortex_recall, etc.
10
+
11
+ ## When to Run Maintenance
12
+
13
+ OpenClaw should periodically run maintenance when:
14
+ - Idle for extended periods (e.g., 30+ minutes)
15
+ - After many sessions have been closed
16
+ - When search results seem incomplete or stale
17
+
18
+ ## Diagnostic Commands
19
+
20
+ ### Check System Health
21
+
22
+ ```bash
23
+ cortex-mem-cli --config config.toml --tenant tenant_claw stats
24
+ ```
25
+
26
+ Shows:
27
+ - Number of sessions
28
+ - Total messages
29
+ - Storage location
30
+
31
+ ### Check Layer File Status
32
+
33
+ ```bash
34
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers status
35
+ ```
36
+
37
+ Shows:
38
+ - Total directories tracked
39
+ - How many have L0/L1 layers (complete)
40
+ - How many are missing L0/L1 layers
41
+
42
+ **Run this when:**
43
+ - Search results lack proper context
44
+ - After bulk data import
45
+
46
+ ### Check Vector Index Status
47
+
48
+ ```bash
49
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector status
50
+ ```
51
+
52
+ Shows:
53
+ - Total vectors in Qdrant
54
+ - Number of stale vectors (missing URI metadata)
55
+
56
+ **Run this when:**
57
+ - Search returns inconsistent results
58
+ - After system crash or restart
59
+
60
+ ## Repair Commands
61
+
62
+ ### Generate Missing L0/L1 Layers
63
+
64
+ ```bash
65
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers ensure-all
66
+ ```
67
+
68
+ Scans filesystem and generates `.abstract.md` and `.overview.md` files for directories that lack them.
69
+
70
+ **Run this when:**
71
+ - `layers status` shows missing directories
72
+ - Search results lack proper context/snippets
73
+ - After manual data recovery
74
+
75
+ **What it does:**
76
+ 1. Scans all session directories
77
+ 2. Identifies directories without L0/L1 files
78
+ 3. Uses LLM to generate abstracts and overviews
79
+ 4. Saves generated files
80
+
81
+ ### Rebuild Vector Index
82
+
83
+ ```bash
84
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector reindex
85
+ ```
86
+
87
+ Cleans up stale vectors (no URI) and re-syncs all files to the vector database.
88
+
89
+ **Run this when:**
90
+ - `vector status` shows stale vectors
91
+ - Search returns inconsistent results
92
+ - After manual data recovery
93
+ - Vector database corruption suspected
94
+
95
+ **What it does:**
96
+ 1. Removes vectors without URI metadata
97
+ 2. Re-scans all files
98
+ 3. Generates new embeddings
99
+ 4. Syncs to Qdrant
100
+
101
+ ### Prune Dangling Vectors
102
+
103
+ ```bash
104
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector prune
105
+ ```
106
+
107
+ Removes vectors whose source files no longer exist on disk.
108
+
109
+ **Run this when:**
110
+ - After deleting session files
111
+ - Disk space is a concern
112
+ - Index cleanup is needed
113
+
114
+ **Preview mode (recommended first):**
115
+ ```bash
116
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector prune --dry-run
117
+ ```
118
+
119
+ Shows what would be deleted without making changes.
120
+
121
+ ### Regenerate Oversized Abstracts
122
+
123
+ ```bash
124
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers regenerate-oversized
125
+ ```
126
+
127
+ Regenerates `.abstract.md` files that exceed the size limit.
128
+
129
+ **Run this when:**
130
+ - Abstract files have grown too large
131
+ - Search performance is degraded
132
+
133
+ ## Recommended Maintenance Schedule
134
+
135
+ | Frequency | Command | Purpose |
136
+ |-----------|---------|---------|
137
+ | Daily | `stats` | Quick health check |
138
+ | Weekly | `layers status` + `vector status` | Detect anomalies early |
139
+ | As needed | `layers ensure-all` | Fix missing layers |
140
+ | As needed | `vector reindex` | Fix index corruption |
141
+ | Monthly | `vector prune` | Clean up dangling data |
142
+
143
+ ## Quick Fix Flow
144
+
145
+ 1. **Search not working well?**
146
+ ```bash
147
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers status
148
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector status
149
+ ```
150
+
151
+ 2. **Missing L0/L1 layers detected?**
152
+ ```bash
153
+ cortex-mem-cli --config config.toml --tenant tenant_claw layers ensure-all
154
+ ```
155
+
156
+ 3. **Stale vectors detected?**
157
+ ```bash
158
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector reindex
159
+ ```
160
+
161
+ 4. **Still having issues?**
162
+ ```bash
163
+ cortex-mem-cli --config config.toml --tenant tenant_claw vector prune
164
+ ```
165
+
166
+ ## Troubleshooting
167
+
168
+ ### CLI Not Found
169
+
170
+ Ensure `cortex-mem-cli` is in your PATH or use the full path:
171
+ ```bash
172
+ /path/to/cortex-mem-cli --config config.toml ...
173
+ ```
174
+
175
+ ### Connection Refused
176
+
177
+ Check that cortex-mem-service is running:
178
+ ```bash
179
+ curl http://localhost:8085/health
180
+ ```
181
+
182
+ ### Qdrant Connection Issues
183
+
184
+ Verify Qdrant is accessible:
185
+ ```bash
186
+ curl http://localhost:6333/collections
187
+ ```
188
+
189
+ ### Layer Generation Fails
190
+
191
+ 1. Check LLM API key in config.toml
192
+ 2. Verify network connectivity to API endpoint
193
+ 3. Check for rate limiting or quota issues
@@ -0,0 +1,150 @@
1
+ # Setup Guide
2
+
3
+ Installation and configuration guide for MemClaw.
4
+
5
+ ## Requirements
6
+
7
+ | Requirement | Details |
8
+ |-------------|---------|
9
+ | **Platforms** | Windows x64, macOS Apple Silicon |
10
+ | **Node.js** | ≥ 22.0.0 |
11
+ | **OpenClaw** | Installed and configured |
12
+
13
+ ## Installation
14
+
15
+ ### Method 1: Install from npm
16
+
17
+ ```bash
18
+ openclaw plugins install @memclaw/plugin
19
+ ```
20
+
21
+ ### Method 2: Local Development Installation
22
+
23
+ For developers using a local version or developing the plugin:
24
+
25
+ ```bash
26
+ # Clone the repository
27
+ git clone https://github.com/sopaco/cortex-mem.git
28
+ cd cortex-mem/examples/@memclaw/plugin
29
+
30
+ # Install dependencies
31
+ bun install
32
+
33
+ # Build the plugin
34
+ bun run build
35
+
36
+ # Create symlink to plugin directory
37
+ mkdir -p ~/.openclaw/plugins
38
+ ln -sf "$(pwd)" ~/.openclaw/plugins/memclaw
39
+ ```
40
+
41
+ Configure in `openclaw.json` with local path:
42
+
43
+ ```json
44
+ {
45
+ "plugins": {
46
+ "entries": {
47
+ "memclaw": {
48
+ "enabled": true,
49
+ "path": "./plugins/memclaw"
50
+ }
51
+ }
52
+ }
53
+ }
54
+ ```
55
+
56
+ After code changes, rebuild with `bun run build` and restart OpenClaw.
57
+
58
+ ## OpenClaw Configuration
59
+
60
+ Edit your `openclaw.json`:
61
+
62
+ ```json
63
+ {
64
+ "plugins": {
65
+ "entries": {
66
+ "memclaw": {
67
+ "enabled": true,
68
+ "config": {
69
+ "serviceUrl": "http://127.0.0.1:8085",
70
+ "tenantId": "tenant_claw",
71
+ "autoStartServices": true
72
+ }
73
+ }
74
+ }
75
+ },
76
+ "agents": {
77
+ "defaults": {
78
+ "memorySearch": { "enabled": false }
79
+ }
80
+ }
81
+ }
82
+ ```
83
+
84
+ > **Important**: Set `memorySearch.enabled: false` to disable OpenClaw's built-in memory search and use MemClaw instead.
85
+
86
+ ## LLM Configuration
87
+
88
+ On first run, MemClaw creates a configuration file:
89
+
90
+ | Platform | Path |
91
+ |----------|------|
92
+ | Windows | `%APPDATA%\memclaw\config.toml` |
93
+ | macOS | `~/Library/Application Support/memclaw/config.toml` |
94
+
95
+ Edit the configuration file and fill in required fields:
96
+
97
+ ```toml
98
+ # LLM Configuration [REQUIRED for memory processing]
99
+ [llm]
100
+ # Your LLM API endpoint (OpenAI-compatible)
101
+ api_base_url = "https://api.openai.com/v1"
102
+ # Your API key [REQUIRED]
103
+ api_key = "sk-xxx"
104
+ # Model for memory extraction and layer generation
105
+ model_efficient = "gpt-4o-mini"
106
+ temperature = 0.1
107
+ max_tokens = 4096
108
+
109
+ # Embedding Configuration [REQUIRED for vector search]
110
+ [embedding]
111
+ # Your embedding API endpoint (OpenAI-compatible)
112
+ api_base_url = "https://api.openai.com/v1"
113
+ # Your API key [REQUIRED - can be same as llm.api_key]
114
+ api_key = "sk-xxx"
115
+ model_name = "text-embedding-3-small"
116
+ batch_size = 10
117
+ ```
118
+
119
+ Then restart OpenClaw.
120
+
121
+ ## Configuration Options
122
+
123
+ | Option | Type | Default | Description |
124
+ |--------|------|---------|-------------|
125
+ | `serviceUrl` | string | `http://127.0.0.1:8085` | Cortex Memory service URL |
126
+ | `tenantId` | string | `tenant_claw` | Tenant ID for data isolation |
127
+ | `autoStartServices` | boolean | `true` | Auto-start Qdrant and service |
128
+ | `defaultSessionId` | string | `default` | Default session for memory operations |
129
+ | `searchLimit` | number | `10` | Default number of search results |
130
+ | `minScore` | number | `0.6` | Minimum relevance score (0-1) |
131
+
132
+ ## Troubleshooting
133
+
134
+ ### Services Won't Start
135
+
136
+ 1. Check that ports 6333, 6334, 8085 are available
137
+ 2. Verify `api_key` fields are filled in config.toml
138
+ 3. Run `openclaw skills` to check plugin status
139
+
140
+ ### Configuration File Not Created
141
+
142
+ 1. Ensure OpenClaw has write permissions to the config directory
143
+ 2. Check OpenClaw logs for error messages
144
+ 3. Manually create the directory and restart OpenClaw
145
+
146
+ ### API Key Issues
147
+
148
+ 1. Verify your API key is valid and has sufficient credits
149
+ 2. Ensure `api_base_url` is correct for your provider
150
+ 3. Check network connectivity to the API endpoint
@@ -0,0 +1,170 @@
1
+ # Tools Reference
2
+
3
+ Detailed documentation for MemClaw tools.
4
+
5
+ ## cortex_search
6
+
7
+ Semantic search across all memories using L0/L1/L2 tiered retrieval.
8
+
9
+ **Parameters:**
10
+
11
+ | Parameter | Type | Required | Default | Description |
12
+ |-----------|------|----------|---------|-------------|
13
+ | `query` | string | Yes | - | The search query - natural language or keywords |
14
+ | `scope` | string | No | - | Session/thread ID to limit search scope |
15
+ | `limit` | integer | No | 10 | Maximum number of results |
16
+ | `min_score` | number | No | 0.6 | Minimum relevance score (0-1) |
17
+
18
+ **When to use:**
19
+ - Find past conversations or decisions
20
+ - Search for specific information across all sessions
21
+ - Discover related memories by semantic similarity
22
+
23
+ **Example:**
24
+ ```json
25
+ {
26
+ "query": "database architecture decisions",
27
+ "limit": 5,
28
+ "min_score": 0.6
29
+ }
30
+ ```
31
+
32
+ **Response format:**
33
+ - Returns ranked results with relevance scores
34
+ - Each result includes `uri`, `score`, and `snippet`
35
+
36
+ ---
37
+
38
+ ## cortex_recall
39
+
40
+ Recall memories with more context (snippet + full content).
41
+
42
+ **Parameters:**
43
+
44
+ | Parameter | Type | Required | Default | Description |
45
+ |-----------|------|----------|---------|-------------|
46
+ | `query` | string | Yes | - | The search query |
47
+ | `scope` | string | No | - | Session/thread ID to limit search scope |
48
+ | `limit` | integer | No | 10 | Maximum number of results |
49
+
50
+ **When to use:**
51
+ - Need memories with full context, not just summaries
52
+ - Want to see the original content, not just snippets
53
+ - Conducting detailed memory analysis
54
+
55
+ **Example:**
56
+ ```json
57
+ {
58
+ "query": "user preferences for code style",
59
+ "limit": 10
60
+ }
61
+ ```
62
+
63
+ **Response format:**
64
+ - Returns results with both `snippet` (summary) and `content` (full text)
65
+ - Content is truncated if very long (>300 chars preview)
66
+
67
+ ---
68
+
69
+ ## cortex_add_memory
70
+
71
+ Store a message for future retrieval.
72
+
73
+ **Parameters:**
74
+
75
+ | Parameter | Type | Required | Default | Description |
76
+ |-----------|------|----------|---------|-------------|
77
+ | `content` | string | Yes | - | The content to store in memory |
78
+ | `role` | string | No | `user` | Role of the message sender: `user`, `assistant`, or `system` |
79
+ | `session_id` | string | No | `default` | Session/thread ID for the memory |
80
+
81
+ **When to use:**
82
+ - Persist important information for future retrieval
83
+ - Store user preferences or decisions
84
+ - Save context that should be searchable later
85
+
86
+ **Example:**
87
+ ```json
88
+ {
89
+ "content": "User prefers TypeScript with strict mode enabled and explicit return types",
90
+ "role": "assistant",
91
+ "session_id": "default"
92
+ }
93
+ ```
94
+
95
+ **What happens:**
96
+ - Message is stored with timestamp
97
+ - Vector embedding is generated automatically
98
+ - L0/L1 layers are generated asynchronously
99
+
100
+ ---
101
+
102
+ ## cortex_list_sessions
103
+
104
+ List all memory sessions with their status.
105
+
106
+ **Parameters:** None
107
+
108
+ **When to use:**
109
+ - Verify sessions exist before searching
110
+ - Check which sessions are active or closed
111
+ - Audit memory usage
112
+
113
+ **Response format:**
114
+ - Session IDs, status, message counts
115
+ - Creation and update timestamps
116
+
117
+ ---
118
+
119
+ ## cortex_close_session
120
+
121
+ Close a session and trigger memory extraction pipeline.
122
+
123
+ **Parameters:**
124
+
125
+ | Parameter | Type | Required | Default | Description |
126
+ |-----------|------|----------|---------|-------------|
127
+ | `session_id` | string | No | `default` | Session/thread ID to close |
128
+
129
+ **When to use:**
130
+ - Conversation is complete
131
+ - Ready to extract structured memories
132
+ - Want to finalize the session's memory content
133
+
134
+ **What happens:**
135
+ 1. Extracts structured memories (user preferences, entities, decisions)
136
+ 2. Generates complete L0/L1 layer summaries
137
+ 3. Indexes all extracted memories into the vector database
138
+
139
+ **Note:** This is a potentially long-running operation (30-60 seconds).
140
+
141
+ **Example:**
142
+ ```json
143
+ {
144
+ "session_id": "default"
145
+ }
146
+ ```
147
+
148
+ ---
149
+
150
+ ## cortex_migrate
151
+
152
+ Migrate memories from OpenClaw's native memory system to MemClaw.
153
+
154
+ **Parameters:** None
155
+
156
+ **When to use:**
157
+ - First time setup with existing OpenClaw memory
158
+ - Want to preserve previous conversation history
159
+ - Switching from built-in memory to MemClaw
160
+
161
+ **What happens:**
162
+ 1. Finds OpenClaw memory files (`memory/*.md` and `MEMORY.md`)
163
+ 2. Converts them to MemClaw's L2 format
164
+ 3. Generates L0/L1 layers and vector index
165
+
166
+ **Prerequisites:**
167
+ - OpenClaw workspace exists at `~/.openclaw/workspace`
168
+ - Memory files exist in `~/.openclaw/workspace/memory/`
169
+
170
+ **Run only once during initial setup.**