@memoryrelay/plugin-memoryrelay-ai 0.12.10 → 0.12.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,16 +8,17 @@ AI-powered long-term memory for OpenClaw agents. Gives your AI assistant persist
8
8
  ## Features
9
9
 
10
10
  - **39 Tools** covering memories, entities, sessions, decisions, patterns, and projects
11
- - **6 Gateway Methods** for stats, debugging, and onboarding (v0.8.0+, Phase 1)
12
- - **Smart Auto-Capture** - Tier-based privacy system with automatic filtering (v0.12.0+)
13
- - **Daily Memory Stats** - Morning/evening summaries with growth metrics (v0.12.0+)
14
- - **Debug & Monitoring** - Comprehensive logging, health checks, and performance metrics (v0.8.0+)
11
+ - **6 Gateway Methods** for stats, debugging, and onboarding
12
+ - **Smart Auto-Capture** - Tier-based privacy system with automatic filtering
13
+ - **Daily Memory Stats** - Morning/evening summaries with growth metrics
14
+ - **Debug & Monitoring** - Comprehensive logging, health checks, and performance metrics
15
15
  - **Semantic Search** - Vector-based retrieval finds relevant context by meaning
16
16
  - **Auto-Recall** - Automatically injects relevant memories into agent context
17
17
  - **Project-First Workflow** - Agents receive workflow instructions to start with project context
18
18
  - **Decision Records** - Track and check architectural decisions before making new ones
19
19
  - **Pattern Library** - Create, search, and adopt reusable conventions across projects
20
20
  - **Session Tracking** - Track work sessions with summaries for continuity
21
+ - **External Session IDs** - Multi-agent collaboration and conversation-spanning sessions
21
22
  - **Tool Group Filtering** - Enable only the tool groups you need
22
23
 
23
24
  ## Installation
@@ -64,39 +65,27 @@ openclaw gateway restart
64
65
  | `defaultProject` | string | — | Default project slug applied to sessions, decisions, and memories |
65
66
  | `enabledTools` | string | `all` | Comma-separated tool groups: `memory`, `entity`, `agent`, `session`, `decision`, `pattern`, `project`, `health` |
66
67
  | `autoRecall` | boolean | `true` | Inject relevant memories into context each turn |
67
- | `autoCapture` | boolean\|object | `{enabled: true, tier: "smart"}` | Auto-capture config. Boolean for backward compat, object for tier system: `{enabled, tier, confirmFirst}`. Tiers: `off`, `conservative`, `smart`, `aggressive`. See Phase 1 features below. |
68
+ | `autoCapture` | boolean\|object | `false` | Auto-capture config. Boolean for backward compat, object for tier system: `{enabled, tier, confirmFirst}`. Tiers: `off`, `conservative`, `smart`, `aggressive`. |
68
69
  | `recallLimit` | number | `5` | Max memories to inject per turn (1-20) |
69
70
  | `recallThreshold` | number | `0.3` | Minimum similarity score for recall (0-1) |
70
71
  | `excludeChannels` | string[] | `[]` | Channel IDs to skip auto-recall |
71
- | `debug` | boolean | `false` | Enable debug logging of API calls (v0.8.0+) |
72
- | `verbose` | boolean | `false` | Include request/response bodies in debug logs (v0.8.0+) |
73
- | `logFile` | string | — | Optional file path for persistent debug logs (v0.8.0+) |
74
- | `maxLogEntries` | number | `100` | Circular buffer size for in-memory logs (v0.8.0+) |
72
+ | `debug` | boolean | `false` | Enable debug logging of API calls |
73
+ | `verbose` | boolean | `false` | Include request/response bodies in debug logs |
74
+ | `logFile` | string | — | Optional file path for persistent debug logs |
75
+ | `maxLogEntries` | number | `100` | Circular buffer size for in-memory logs |
75
76
 
76
- # Phase 1 Section for README
77
+ ## Smart Auto-Capture
77
78
 
78
- ## Phase 1: Zero-Friction Adoption Framework (v0.12.0+)
79
-
80
- Phase 1 introduces features designed to make MemoryRelay "just work" without manual effort. The goal: store 3-5x more memories with zero additional work.
81
-
82
- ### Smart Auto-Capture (Issue #12)
83
-
84
- **Tier-Based Privacy System** — Four capture modes with built-in privacy protection:
79
+ Four capture modes with built-in privacy protection:
85
80
 
86
81
  | Tier | When to Use | Privacy Level |
87
82
  |------|-------------|---------------|
88
83
  | `off` | Manual storage only | N/A |
89
84
  | `conservative` | Low-risk conversations only | High (blocks most patterns) |
90
- | `smart` | **Default** — Balanced automation | Medium (blocks sensitive data) |
85
+ | `smart` | Balanced automation | Medium (blocks sensitive data) |
91
86
  | `aggressive` | Maximum capture | Low (minimal blocking) |
92
87
 
93
- **Privacy Blocklist** — Automatically filters:
94
- - Passwords and API keys (`password: xxx`, `api_key=xxx`)
95
- - Credit card numbers (Visa, MC, Amex, Discover patterns)
96
- - Social Security Numbers (`SSN: xxx-xx-xxxx`)
97
- - Email addresses and phone numbers (when tier < aggressive)
98
-
99
- **Configuration**:
88
+ **Privacy Blocklist** — Automatically filters passwords, API keys, credit card numbers, SSNs, and other sensitive data.
100
89
 
101
90
  ```json
102
91
  {
@@ -108,270 +97,7 @@ Phase 1 introduces features designed to make MemoryRelay "just work" without man
108
97
  }
109
98
  ```
110
99
 
111
- **Backward Compatibility**: Boolean values still work (`true` `{enabled: true, tier: "smart"}`)
112
-
113
- **First-5 Confirmations** — On `smart`/`aggressive` tiers, first 5 captures show confirmation prompts. After 5, auto-capture runs silently. Reset by setting `confirmFirst: 5` again.
114
-
115
- ---
116
-
117
- ### Daily Memory Stats (Issue #10)
118
-
119
- **Morning Check** (9:00 AM) — Start your day with memory growth stats:
120
- ```
121
- 📊 Memory Stats (Morning Check)
122
- Total: 1,247 memories | Today: 8 (+3 since yesterday)
123
- This week: 52 memories (+15% vs last week)
124
- Top categories: development (18), decisions (12), patterns (7)
125
- ```
126
-
127
- **Evening Review** (8:00 PM) — End your day with activity summary:
128
- ```
129
- 🌙 Memory Activity (Evening Review)
130
- Today: 12 memories stored | Most recalled: "NorthRelay API v9.0 architecture"
131
- Most valuable: [Memory about critical bug fix in authentication flow]
132
- ```
133
-
134
- **Gateway Method**: `memoryrelay:heartbeat`
135
-
136
- **Configuration**:
137
- ```json
138
- {
139
- "dailyStats": {
140
- "enabled": true,
141
- "morningTime": "09:00",
142
- "eveningTime": "20:00"
143
- }
144
- }
145
- ```
146
-
147
- **Integration with HEARTBEAT.md** — Add to your workspace `HEARTBEAT.md`:
148
- ```markdown
149
- ## MemoryRelay Health
150
- Every heartbeat, check memory stats:
151
- - Run morning check at 9 AM
152
- - Run evening review at 8 PM
153
- - Report if memory storage rate drops below 5/week
154
- ```
155
-
156
- ---
157
-
158
- ### CLI Stats Command (Issue #11)
159
-
160
- **Comprehensive Statistics** — View memory metrics anytime:
161
-
162
- ```bash
163
- openclaw gateway-call memoryrelay.stats
164
- ```
165
-
166
- **Text Output**:
167
- ```
168
- MemoryRelay Statistics
169
- ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
170
-
171
- Storage
172
- Total: 1,247 memories
173
- Today: 8 memories
174
- This week: 52 memories (+15% vs last week)
175
- This month: 218 memories (+8% vs last month)
176
-
177
- Top 10 Categories
178
- development ........................ 342 (27%)
179
- decisions .......................... 156 (12%)
180
- patterns ........................... 128 (10%)
181
- infrastructure ..................... 94 (8%)
182
- [...]
183
-
184
- Recent Memories (last 5)
185
- [2026-03-06 12:35] Phase 1 validation test
186
- [2026-03-06 10:25] Phase 1 implementation complete
187
- [2026-03-06 09:11] Issue #8 broken down
188
- [...]
189
- ```
190
-
191
- **JSON Output** (for scripts):
192
- ```bash
193
- openclaw gateway-call memoryrelay.stats '{"format": "json"}'
194
- ```
195
-
196
- **Verbose Mode** (includes growth charts, recall stats):
197
- ```bash
198
- openclaw gateway-call memoryrelay.stats '{"verbose": true}'
199
- ```
200
-
201
- ---
202
-
203
- ### First-Run Onboarding (Issue #9)
204
-
205
- **Automatic Welcome** — On fresh install (no memories + no onboarding state):
206
-
207
- 1. Plugin detects first run
208
- 2. Creates welcome memory: "Welcome to MemoryRelay! This is your first memory."
209
- 3. Shows auto-capture explanation
210
- 4. Saves state to `~/.openclaw/memoryrelay-onboarding.json`
211
- 5. Never repeats (state file persists)
212
-
213
- **Manual Trigger** (show again or for new users):
214
- ```bash
215
- openclaw gateway-call memoryrelay.onboarding
216
- ```
217
-
218
- **What Users See**:
219
- ```
220
- 🎉 Welcome to MemoryRelay!
221
-
222
- I just stored my first memory: "Welcome to MemoryRelay! This is your first memory."
223
-
224
- Auto-capture is enabled (tier: smart). I'll automatically remember:
225
- ✓ Important decisions and changes
226
- ✓ Technical discoveries and solutions
227
- ✓ Project context and conventions
228
-
229
- Privacy protected — I filter out:
230
- ✗ Passwords and API keys
231
- ✗ Credit card numbers
232
- ✗ Social Security Numbers
233
- ✗ Personal secrets
234
-
235
- You're all set! I'll build memory over time as we work together.
236
- ```
237
-
238
- ---
239
-
240
- ### Gateway Methods Summary
241
-
242
- | Method | Purpose | Example |
243
- |--------|---------|---------|
244
- | `memoryrelay:heartbeat` | Daily stats check (morning/evening) | `openclaw gateway-call memoryrelay.heartbeat` |
245
- | `memoryrelay:stats` | CLI stats command | `openclaw gateway-call memoryrelay.stats '{"format": "json"}'` |
246
- | `memoryrelay:onboarding` | Show/restart onboarding | `openclaw gateway-call memoryrelay.onboarding` |
247
-
248
- **Note**: These are gateway methods, not shell commands. Invoke via `openclaw gateway-call memoryrelay.<method>`.
249
-
250
- ---
251
-
252
- ### Expected Impact
253
-
254
- Based on Zero-Friction Adoption Strategy (Issue #8):
255
-
256
- | Metric | Before | After Phase 1 | Target |
257
- |--------|--------|---------------|--------|
258
- | Memory storage rate | 5/week | 15-25/week | 3-5x |
259
- | Daily active usage | 10% | 40-50% | 4-5x |
260
- | Auto-capture adoption | 0% | 40-50% | 70% |
261
- | First memory time | N/A | <2 min | <5 min |
262
-
263
- ---
264
-
265
- ## Debug & Monitoring (v0.8.0+)
266
-
267
- ### Enable Debug Mode
268
-
269
- ```json
270
- {
271
- "plugins": {
272
- "entries": {
273
- "plugin-memoryrelay-ai": {
274
- "enabled": true,
275
- "config": {
276
- "apiKey": "mem_prod_xxxxx",
277
- "agentId": "your-agent",
278
- "debug": true,
279
- "verbose": false,
280
- "maxLogEntries": 1000
281
- }
282
- }
283
- }
284
- }
285
- }
286
- ```
287
-
288
- ### Debug Commands (Gateway Methods)
289
-
290
- The plugin provides four debug commands accessible via OpenClaw gateway methods:
291
-
292
- **Note**: These are **gateway methods**, not standalone shell commands. Invoke them using `openclaw gateway-call memoryrelay.<method>`.
293
-
294
- #### View Debug Logs
295
- ```bash
296
- # Last 20 logs
297
- openclaw gateway-call memoryrelay.logs
298
-
299
- # Last 50 logs
300
- openclaw gateway-call memoryrelay.logs '{"limit": 50}'
301
-
302
- # Filter by tool
303
- openclaw gateway-call memoryrelay.logs '{"tool": "memory_store", "limit": 20}'
304
-
305
- # Show errors only
306
- openclaw gateway-call memoryrelay.logs '{"errorsOnly": true}'
307
- ```
308
-
309
- #### Health Check
310
- ```bash
311
- # Run comprehensive health check
312
- openclaw gateway-call memoryrelay.health
313
-
314
- # Tests API connectivity, authentication, and core tools
315
- ```
316
-
317
- #### Test Individual Tools
318
- ```bash
319
- # Test specific tool
320
- openclaw gateway-call memoryrelay.test '{"tool": "memory_store"}'
321
- openclaw gateway-call memoryrelay.test '{"tool": "memory_recall"}'
322
- openclaw gateway-call memoryrelay.test '{"tool": "project_list"}'
323
- ```
324
-
325
- #### View Performance Metrics
326
- ```bash
327
- # Show performance statistics
328
- openclaw gateway-call memoryrelay.metrics
329
-
330
- # Displays per-tool metrics:
331
- # - Call count
332
- # - Success rate
333
- # - Average duration
334
- # - p95/p99 latencies
335
- ```
336
-
337
- ### Alternative: Direct Gateway Method Calls
338
-
339
- The same methods can be called programmatically from code or scripts (same syntax as above).
340
-
341
- ### Enhanced Status Reporting
342
-
343
- The `memory.status` gateway method now provides comprehensive reports including:
344
-
345
- - Connection status with response time
346
- - Tool breakdown by category (39 tools across 8 groups)
347
- - Recent API call history
348
- - Known issues with affected tools
349
- - Debug/verbose mode status
350
-
351
- ```bash
352
- openclaw gateway call memory.status
353
- ```
354
-
355
- ### Debug Log Format
356
-
357
- When debug mode is enabled, each API call is logged with:
358
-
359
- ```
360
- TIMESTAMP TOOL DURATION STATUS ERROR
361
- ━━━━━━━━━━━━━━━━━ ━━━━━━━━━━━━━━━━━━━━━ ━━━━━━━━ ━━━━━━ ━━━━━━━━━━━━━━━━━━━
362
- 7:35:15 PM memory_store 142ms ✓
363
- 7:35:10 PM memory_recall 78ms ✓
364
- 7:35:05 PM memory_batch_store 245ms ✗ 500 Internal Server Error
365
- ```
366
-
367
- Verbose mode additionally captures request/response bodies for deep troubleshooting.
368
-
369
- ### Performance Impact
370
-
371
- - **Debug disabled**: ~0ms overhead (no-op checks)
372
- - **Debug enabled**: ~1-2ms per call (logging only)
373
- - **Verbose enabled**: ~2-5ms per call (includes JSON serialization)
374
- - **Memory usage**: ~10KB (default 100 entries) to ~100KB (1000 entries)
100
+ With `confirmFirst`, the first N captures show confirmation prompts before running silently.
375
101
 
376
102
  ## Agent Workflow
377
103
 
@@ -509,33 +235,48 @@ Exclude specific channels from auto-recall and workflow injection:
509
235
  }
510
236
  ```
511
237
 
512
- ## CLI Commands
238
+ ## Debug & Monitoring
513
239
 
514
- ```bash
515
- openclaw memoryrelay status # Check connection and stats
516
- openclaw memoryrelay stats # Show memory count
517
- openclaw memoryrelay list # List recent memories
518
- openclaw memoryrelay search "query" # Search memories
519
- openclaw memoryrelay delete <id> # Delete a memory
520
- openclaw memoryrelay export # Export all memories to JSON
240
+ ### Enable Debug Mode
241
+
242
+ ```json
243
+ {
244
+ "debug": true,
245
+ "verbose": false,
246
+ "maxLogEntries": 1000
247
+ }
521
248
  ```
522
249
 
250
+ ### Gateway Methods
251
+
252
+ | Method | Purpose | Example |
253
+ |--------|---------|---------|
254
+ | `memoryrelay.logs` | View debug logs | `openclaw gateway-call memoryrelay.logs '{"limit": 50}'` |
255
+ | `memoryrelay.health` | Run health check | `openclaw gateway-call memoryrelay.health` |
256
+ | `memoryrelay.test` | Test individual tools | `openclaw gateway-call memoryrelay.test '{"tool": "memory_store"}'` |
257
+ | `memoryrelay.metrics` | View performance stats | `openclaw gateway-call memoryrelay.metrics` |
258
+ | `memoryrelay.heartbeat` | Daily stats check | `openclaw gateway-call memoryrelay.heartbeat` |
259
+ | `memoryrelay.stats` | CLI stats command | `openclaw gateway-call memoryrelay.stats '{"format": "json"}'` |
260
+ | `memoryrelay.onboarding` | Show onboarding | `openclaw gateway-call memoryrelay.onboarding` |
261
+ | `memory.status` | Plugin status report | `openclaw gateway-call memory.status` |
262
+
263
+ ### Debug Log Format
264
+
265
+ When debug mode is enabled, each API call is logged with timestamp, tool name, duration, and status. Verbose mode additionally captures request/response bodies for deep troubleshooting.
266
+
523
267
  ## Privacy & Security
524
268
 
525
269
  - **Cloud-Backed** — Memories stored on MemoryRelay servers (HTTPS-encrypted in transit)
526
270
  - **API Key Auth** — Bearer token authentication
527
271
  - **Agent Isolation** — Memories scoped per agent ID
528
272
  - **Channel Filtering** — Exclude sensitive channels from auto-recall
529
- - **No Auto-Capture by Default** Manual storage gives you full control
530
- - **Never store secrets** — Do not store API keys, passwords, or tokens as memories. Use encrypted local files or secret managers instead.
273
+ - **Privacy Blocklist** — Auto-capture filters sensitive data (passwords, SSNs, credit cards, API keys)
274
+ - **Never store secrets** — Do not store API keys, passwords, or tokens as memories
531
275
 
532
276
  ## Troubleshooting
533
277
 
534
278
  ### Plugin Not Loading
535
279
 
536
- **Symptoms**: Plugin doesn't appear in `openclaw plugins list` or shows as "unavailable"
537
-
538
- **Solutions**:
539
280
  ```bash
540
281
  # Check if installed
541
282
  npm list -g @memoryrelay/plugin-memoryrelay-ai
@@ -543,9 +284,6 @@ npm list -g @memoryrelay/plugin-memoryrelay-ai
543
284
  # Reinstall if needed
544
285
  openclaw plugins install @memoryrelay/plugin-memoryrelay-ai --force
545
286
 
546
- # Check config syntax
547
- cat ~/.openclaw/openclaw.json | jq '.plugins.entries."plugin-memoryrelay-ai"'
548
-
549
287
  # Restart gateway
550
288
  openclaw gateway restart
551
289
 
@@ -555,265 +293,25 @@ openclaw gateway logs | grep memoryrelay
555
293
 
556
294
  ### API Connection Issues
557
295
 
558
- **Symptoms**: "Failed to connect" errors, timeouts, or "unhealthy" status
559
-
560
- **Solutions**:
561
296
  ```bash
562
297
  # Test API directly
563
298
  curl -H "X-API-Key: YOUR_KEY" https://api.memoryrelay.net/v1/health
564
299
 
565
300
  # Check gateway logs
566
301
  openclaw gateway logs -f | grep memory-memoryrelay
567
-
568
- # Verify API key format (should be mem_prod_xxxxx with 32 chars after prefix)
569
- openclaw config get plugins.entries.plugin-memoryrelay-ai.config.apiKey
570
-
571
- # Run health check
572
- memoryrelay-health
573
302
  ```
574
303
 
575
304
  ### Auto-Recall Not Working
576
305
 
577
- **Symptoms**: Memories not appearing in agent context
578
-
579
- **Checks**:
580
306
  1. Verify `autoRecall: true` in config
581
307
  2. Check memories exist: `openclaw gateway call memory_list '{"limit": 10}'`
582
308
  3. Lower `recallThreshold` (try 0.1) for more results
583
- 4. Review logs: `openclaw gateway logs | grep "injecting.*memories"`
584
- 5. Check channel not in `excludeChannels`
585
-
586
- ### Debug Mode Not Working
587
-
588
- **Symptoms**: `memoryrelay-logs` shows "No logs" or debug commands fail
589
-
590
- **Solutions**:
591
- 1. Verify `debug: true` in config
592
- 2. Restart gateway after config change: `openclaw gateway restart`
593
- 3. Use the plugin to generate logs
594
- 4. Check `maxLogEntries` isn't set too low (default: 100)
595
-
596
- ### Tool Not Found Errors
597
-
598
- **Symptoms**: "Tool xxx not found" or "Tool not enabled"
599
-
600
- **Solutions**:
601
- 1. Check `enabledTools` config (should be `"all"` or include the tool's group)
602
- 2. Verify tool name spelling matches exactly (e.g., `memory_store` not `memoryStore`)
603
- 3. Check plugin version: `npm list -g @memoryrelay/plugin-memoryrelay-ai`
604
- 4. Update to latest: `openclaw plugins install @memoryrelay/plugin-memoryrelay-ai@latest`
605
-
606
- ### Performance Issues
607
-
608
- **Symptoms**: Slow API calls, timeouts, high latency
609
-
610
- **Diagnosis**:
611
- ```bash
612
- # Enable debug mode
613
- openclaw config set plugins.entries.plugin-memoryrelay-ai.config.debug true
614
- openclaw gateway restart
615
-
616
- # View metrics
617
- memoryrelay-metrics
618
-
619
- # Check for slow tools (high avgDuration or p99)
620
- # Check for failures (low successRate)
621
- ```
622
-
623
- **Solutions**:
624
- 1. Check network latency to api.memoryrelay.net
625
- 2. Reduce `recallLimit` (fewer memories = faster)
626
- 3. Lower `recallThreshold` (fewer vector comparisons)
627
- 4. Check MemoryRelay API status at status.memoryrelay.ai
628
-
629
- ### Memory Storage Failures
630
-
631
- **Symptoms**: `memory_store` returns 422 validation errors or 500 errors
632
-
633
- **Common Causes**:
634
- 1. Content too long (max 50,000 characters)
635
- 2. Metadata too large (max 10KB when serialized)
636
- 3. Invalid project slug (use `project_list` to verify)
637
- 4. API rate limits exceeded (30 req/min for memory_store)
638
-
639
- **Solutions**:
640
- ```bash
641
- # Test with minimal memory
642
- openclaw gateway call memory_store '{"content": "Test memory"}'
643
-
644
- # Check recent errors
645
- memoryrelay-logs --errors-only --limit=10
646
-
647
- # Verify API key has write permissions
648
- curl -X POST https://api.memoryrelay.net/v1/memories \
649
- -H "X-API-Key: YOUR_KEY" \
650
- -H "Content-Type: application/json" \
651
- -d '{"content": "Test"}'
652
- ```
653
-
654
- ### Session Tracking Issues
655
-
656
- **Symptoms**: `session_start` fails or `session_end` can't find session
657
-
658
- **Solutions**:
659
- 1. Save session ID from `session_start` response
660
- 2. Verify project exists: `openclaw gateway call project_list`
661
- 3. Check for API validation errors in logs
662
- 4. Use `session_list` to find active sessions
309
+ 4. Check channel not in `excludeChannels`
663
310
 
664
311
  ### Known Limitations
665
312
 
666
- **API Issues** (reported to MemoryRelay team):
667
313
  - `memory_batch_store`: May return 500 errors (use individual `memory_store` as workaround)
668
314
  - `memory_context`: Returns 405 Method Not Allowed (use `memory_recall` instead)
669
- - `entity_create`: May fail with 422 validation errors
670
- - `decision_record`: May fail with 422 validation errors
671
- - `session_start`: May fail with 422 validation errors
672
-
673
- **Workarounds**:
674
- - Use alternative tools where available
675
- - Check GitHub Issues for latest status
676
- - Enable debug mode to capture full error details
677
-
678
- ## Changelog
679
-
680
- ### v0.12.7 (2026-03-06)
681
-
682
- **🎯 Tool Factory Pattern Fix - Session Tracking Now Works!**
683
-
684
- - **FIX**: Converted all 39 tools from direct registration to factory pattern for context access
685
- - **FIX**: Session tracking now works - `ctx.sessionId` properly captured via factory closure
686
- - **CHANGE**: Tools now registered via `api.registerTool((ctx) => tool)` instead of direct objects
687
- - **CHANGE**: Removed unused `context?` parameter from execute functions
688
- - **ROOT CAUSE**: OpenClaw passes context to tool factories at registration time, NOT to execute functions
689
- - **EVIDENCE**: Examined OpenClaw core source code (`src/plugins/types.ts`, `OpenClawPluginToolFactory`)
690
- - **AUTOMATION**: Python script converted all 39 tools automatically
691
- - **IMPACT**: Session-memory linking finally works end-to-end
692
- - **BACKWARD COMPAT**: Fully compatible, no breaking changes, graceful degradation
693
- - **RELATED**: Closes #26, part of session tracking fix chain (#24, #25, #226)
694
-
695
- **Files changed**: 7 files, 5,176 insertions(+), 246 deletions(-)
696
- **Implementation time**: 1.5 hours
697
- **Total investigation**: ~7 hours across 6 sessions
698
-
699
- ### v0.12.6 (2026-03-06)
700
-
701
- **⚠️ Wrong Approach - Superseded by v0.12.7**
702
-
703
- - **ATTEMPT**: Added context parameter to execute functions
704
- - **ISSUE**: OpenClaw doesn't pass context to execute - wrong pattern
705
- - **LESSON**: Should have checked OpenClaw source code first
706
-
707
- ### v0.12.5 (2026-03-06)
708
-
709
- **🔧 Version String Sync**
710
-
711
- - **FIX**: Synchronized all version strings across package.json, openclaw.plugin.json, and index.ts
712
- - **IMPACT**: Gateway now displays correct version (v0.12.5)
713
-
714
- ### v0.12.4 (2026-03-06)
715
-
716
- **❌ Failed Release**
717
-
718
- - **ISSUE**: Created git tag before pushing version bump commit
719
- - **RESULT**: Published to npm without version string updates
720
- - **LESSON**: Always push commits before tagging releases
721
-
722
- ### v0.12.3 (2026-03-06)
723
-
724
- **🔗 Session Tracking - Plugin Fix**
725
-
726
- - **FIX**: Extract session_id from metadata and pass as top-level parameter to API
727
- - **CHANGE**: Backend expects `{ session_id, content, metadata }`, not `{ content, metadata: { session_id } }`
728
- - **IMPACT**: Memories now correctly link to sessions in database
729
- - **RELATED**: Backend fixed in PR #225, plugin integration fixed here
730
-
731
- ### v0.12.2 (2026-03-06)
732
-
733
- **📚 Documentation & Maintenance Release**
734
-
735
- - **FIX**: Corrected Node.js requirement from >=18.0.0 to >=20.0.0 (CI uses Node 20, dependencies require 20+)
736
- - **FIX**: Version string in plugin load message now shows correct version (was hardcoded to 0.12.0)
737
- - **DOCS**: Complete Phase 1 features documentation added
738
- - **DOCS**: Updated `autoCapture` configuration with tier system details
739
- - **DOCS**: Added v0.12.0 and v0.12.1 changelog entries (were missing)
740
- - **DOCS**: Clarified gateway methods vs CLI commands
741
- - **DOCS**: Added troubleshooting for Phase 1 features
742
-
743
- ### v0.12.1 (2026-03-06)
744
-
745
- **🐛 Bugfix Release**
746
-
747
- - **FIX**: Include `src/` directory in npm package (Phase 1 modules were missing)
748
- - **FIX**: Package.json `files` array now includes `src/` for heartbeat, cli, and onboarding modules
749
- - **IMPACT**: Critical fix - v0.12.0 was non-functional without src/ directory
750
-
751
- ### v0.12.0 (2026-03-06)
752
-
753
- **🎉 Phase 1: Zero-Friction Adoption Framework**
754
-
755
- - **NEW**: Smart auto-capture with 4 privacy tiers (off/conservative/smart/aggressive)
756
- - **NEW**: Privacy blocklist for sensitive data (passwords, SSN, credit cards, API keys)
757
- - **NEW**: Daily memory stats in heartbeat (morning 9 AM, evening 8 PM)
758
- - **NEW**: CLI stats command with text/JSON output (`memoryrelay:stats`)
759
- - **NEW**: First-run onboarding wizard with welcome memory
760
- - **NEW**: Three gateway methods: `memoryrelay:heartbeat`, `memoryrelay:stats`, `memoryrelay:onboarding`
761
- - **NEW**: Auto-capture default changed from `false` to `smart` tier
762
- - **NEW**: Modular architecture with `src/` directory (heartbeat, cli, onboarding modules)
763
- - **CHANGE**: `autoCapture` config accepts boolean (backward compat) or object with tier system
764
- - **DOCS**: PHASE1_CHANGELOG.md with complete implementation details
765
- - **TESTS**: All existing tests pass, Phase 1 features validated
766
-
767
- **Implementation**: 820 lines across 3 new modules
768
- **Time**: 50 minutes (38% faster than 80-minute estimate)
769
- **Backward Compatibility**: Fully compatible, no breaking changes
770
-
771
- ### v0.8.0 (2026-03-05)
772
-
773
- **🚀 Debug & Monitoring Release**
774
-
775
- - **NEW**: Debug logging system with circular buffer (configurable maxLogEntries)
776
- - **NEW**: DebugLogger class tracks all API calls with timing, status, errors
777
- - **NEW**: StatusReporter class provides enhanced status reports
778
- - **NEW**: 4 CLI commands: `memoryrelay-logs`, `memoryrelay-health`, `memoryrelay-test`, `memoryrelay-metrics`
779
- - **NEW**: 4 gateway methods: `memoryrelay.logs`, `memoryrelay.health`, `memoryrelay.test`, `memoryrelay.metrics`
780
- - **NEW**: Performance metrics with p95/p99 latency tracking
781
- - **NEW**: Enhanced `memory.status` handler with comprehensive reports
782
- - **NEW**: Debug config options: `debug`, `verbose`, `logFile`, `maxLogEntries`
783
- - **NEW**: Tool failure tracking and recovery monitoring
784
- - **NEW**: Request/response capture in verbose mode
785
- - **NEW**: Persistent file logging option
786
- - **TESTS**: 92 tests total (73 existing + 19 new for DebugLogger and StatusReporter)
787
- - **DOCS**: CLI_COMMANDS.md with complete usage guide
788
- - **DOCS**: Enhanced README with Debug & Monitoring section
789
- - **DOCS**: Comprehensive troubleshooting guide
790
-
791
- **Performance**: Minimal overhead when disabled (~0ms), 1-2ms when enabled, 2-5ms in verbose mode
792
-
793
- ### v0.7.0 (2026-03-05)
794
-
795
- - **NEW**: 39 tools (up from 3) covering full MemoryRelay API surface
796
- - **NEW**: Session tracking — `session_start`, `session_end`, `session_recall`, `session_list`
797
- - **NEW**: Decision records — `decision_record`, `decision_list`, `decision_supersede`, `decision_check`
798
- - **NEW**: Pattern library — `pattern_create`, `pattern_search`, `pattern_adopt`, `pattern_suggest`
799
- - **NEW**: Project management — `project_register`, `project_list`, `project_info`, relationships, impact analysis, shared patterns, full context loading
800
- - **NEW**: Enhanced memory tools — project scoping, deduplication, importance scores, three-tier storage, batch store, context building, promotion
801
- - **NEW**: Agent workflow instructions injected via `before_agent_start` hook
802
- - **NEW**: Tool group filtering via `enabledTools` config
803
- - **NEW**: `defaultProject` config for automatic project scoping
804
- - **FIX**: Workflow instructions now injected regardless of autoRecall setting
805
-
806
- ### v0.6.2 (2026-03-01)
807
-
808
- - **FIX**: OpenClaw 2026.2.26 compatibility — Changed `extensions` from `["./"]` to `["./index.ts"]`
809
- - **DOCS**: Added comprehensive README and migration guide
810
-
811
- ### v0.6.0 (2026-02-18)
812
-
813
- - **NEW**: Retry logic with exponential backoff (3 attempts)
814
- - **NEW**: Request timeout (30 seconds)
815
- - **NEW**: Environment variable fallback support
816
- - **NEW**: Channel filtering (`excludeChannels` config)
817
315
 
818
316
  ## Development
819
317
 
@@ -821,9 +319,9 @@ curl -X POST https://api.memoryrelay.net/v1/memories \
821
319
  git clone https://github.com/memoryrelay/openclaw-plugin.git
822
320
  cd openclaw-plugin
823
321
  npm install
824
- npm test # Run once (50 tests)
825
- npm run test:watch # Watch mode
826
- npm run test:coverage # With coverage
322
+ npm test
323
+ npm run test:watch
324
+ npm run test:coverage
827
325
  ```
828
326
 
829
327
  ## License
package/index.ts CHANGED
@@ -974,6 +974,22 @@ class MemoryRelayClient {
974
974
  });
975
975
  }
976
976
 
977
+ async getOrCreateSession(
978
+ external_id: string,
979
+ agent_id?: string,
980
+ title?: string,
981
+ project?: string,
982
+ metadata?: Record<string, string>,
983
+ ): Promise<any> {
984
+ return this.request("POST", "/v1/sessions/get-or-create", {
985
+ external_id,
986
+ agent_id: agent_id || this.agentId,
987
+ title,
988
+ project,
989
+ metadata,
990
+ });
991
+ }
992
+
977
993
  async endSession(id: string, summary?: string): Promise<any> {
978
994
  return this.request("PUT", `/v1/sessions/${id}/end`, { summary });
979
995
  }
@@ -1316,6 +1332,78 @@ export default async function plugin(api: OpenClawPluginApi): Promise<void> {
1316
1332
 
1317
1333
  const client = new MemoryRelayClient(apiKey, agentId, apiUrl, debugLogger, statusReporter);
1318
1334
 
1335
+ // ========================================================================
1336
+ // Session Cache for External Session IDs (v0.12.11)
1337
+ // ========================================================================
1338
+
1339
+ /**
1340
+ * Cache mapping: external_id → MemoryRelay session_id
1341
+ * Enables multi-agent collaboration and conversation-spanning sessions
1342
+ */
1343
+ const sessionCache = new Map<string, string>();
1344
+
1345
+ /**
1346
+ * Get or create MemoryRelay session for current workspace/project context.
1347
+ * Uses external_id as semantic key for multi-agent collaboration.
1348
+ *
1349
+ * @param project - Project slug (from context or user args)
1350
+ * @param workspaceDir - Workspace directory path
1351
+ * @returns MemoryRelay session UUID, or null if session creation disabled
1352
+ */
1353
+ async function getContextSession(
1354
+ project?: string,
1355
+ workspaceDir?: string
1356
+ ): Promise<string | null> {
1357
+ // If no project context, don't auto-create session
1358
+ if (!project && !workspaceDir) {
1359
+ return null;
1360
+ }
1361
+
1362
+ // Generate external_id from project or workspace
1363
+ const externalId = project ||
1364
+ (workspaceDir ? `workspace-${workspaceDir.split(/[/\\]/).pop()}` : null);
1365
+
1366
+ if (!externalId) {
1367
+ return null;
1368
+ }
1369
+
1370
+ // Check cache first
1371
+ if (sessionCache.has(externalId)) {
1372
+ if (debugLogger) {
1373
+ debugLogger.log(`Session: Cache hit for external_id="${externalId}"`, "info");
1374
+ }
1375
+ return sessionCache.get(externalId)!;
1376
+ }
1377
+
1378
+ try {
1379
+ // Get or create session via new API endpoint
1380
+ const response = await client.getOrCreateSession(
1381
+ externalId,
1382
+ agentId,
1383
+ project ? `${project} work session` : `Workspace ${externalId}`,
1384
+ project,
1385
+ { source: "openclaw-plugin", agent: agentId }
1386
+ );
1387
+
1388
+ // Cache the mapping
1389
+ sessionCache.set(externalId, response.id);
1390
+
1391
+ if (debugLogger) {
1392
+ debugLogger.log(
1393
+ `Session: ${response.created ? 'Created' : 'Retrieved'} session ${response.id} for external_id="${externalId}"`,
1394
+ "info"
1395
+ );
1396
+ }
1397
+
1398
+ return response.id;
1399
+ } catch (err) {
1400
+ if (debugLogger) {
1401
+ debugLogger.log(`Session: Failed to get-or-create session for ${externalId}: ${String(err)}`, "error");
1402
+ }
1403
+ return null;
1404
+ }
1405
+ }
1406
+
1319
1407
  // Verify connection on startup (with timeout)
1320
1408
  try {
1321
1409
  await client.health();
@@ -1523,6 +1611,10 @@ export default async function plugin(api: OpenClawPluginApi): Promise<void> {
1523
1611
  description: "Memory tier: hot, warm, or cold.",
1524
1612
  enum: ["hot", "warm", "cold"],
1525
1613
  },
1614
+ session_id: {
1615
+ type: "string",
1616
+ description: "Optional MemoryRelay session UUID to associate this memory with. If omitted and project is set, plugin auto-creates session via external_id.",
1617
+ },
1526
1618
  },
1527
1619
  required: ["content"],
1528
1620
  },
@@ -1536,27 +1628,41 @@ export default async function plugin(api: OpenClawPluginApi): Promise<void> {
1536
1628
  project?: string;
1537
1629
  importance?: number;
1538
1630
  tier?: string;
1631
+ session_id?: string; // Allow explicit session_id
1539
1632
  },
1540
1633
  ) => {
1541
1634
  try {
1542
- const { content, metadata, ...opts } = args;
1635
+ const { content, metadata, session_id: explicitSessionId, ...opts } = args;
1636
+
1637
+ // Apply defaultProject fallback before session resolution
1638
+ if (!opts.project && defaultProject) opts.project = defaultProject;
1639
+
1640
+ // Get session_id from cache if project context available
1641
+ // Priority: explicit session_id > context session > no session
1642
+ let sessionId: string | undefined = explicitSessionId;
1643
+
1644
+ if (!sessionId && (opts.project || ctx.workspaceDir)) {
1645
+ const contextSessionId = await getContextSession(opts.project, ctx.workspaceDir);
1646
+ if (contextSessionId) {
1647
+ sessionId = contextSessionId;
1648
+ }
1649
+ }
1543
1650
 
1544
- // Inject sessionId from OpenClaw context into metadata
1545
- const enrichedMetadata = {
1546
- ...metadata,
1547
- ...(ctx.sessionId && { session_id: ctx.sessionId }),
1651
+ // Build request options with session_id as top-level parameter
1652
+ const storeOpts = {
1653
+ ...opts,
1654
+ ...(sessionId && { session_id: sessionId }),
1548
1655
  };
1549
1656
 
1550
- if (!opts.project && defaultProject) opts.project = defaultProject;
1551
- const memory = await client.store(content, enrichedMetadata, opts);
1657
+ const memory = await client.store(content, metadata, storeOpts);
1552
1658
  return {
1553
1659
  content: [
1554
1660
  {
1555
1661
  type: "text",
1556
- text: `Memory stored successfully (id: ${memory.id.slice(0, 8)}...)`,
1662
+ text: `Memory stored successfully (id: ${memory.id.slice(0, 8)}...)${sessionId ? ` in session ${sessionId.slice(0, 8)}...` : ''}`,
1557
1663
  },
1558
1664
  ],
1559
- details: { id: memory.id, stored: true },
1665
+ details: { id: memory.id, stored: true, session_id: sessionId },
1560
1666
  };
1561
1667
  } catch (err) {
1562
1668
  return {
@@ -3864,7 +3970,7 @@ export default async function plugin(api: OpenClawPluginApi): Promise<void> {
3864
3970
  }
3865
3971
 
3866
3972
  api.logger.info?.(
3867
- `memory-memoryrelay: plugin v0.12.10 loaded (39 tools, autoRecall: ${cfg?.autoRecall}, autoCapture: ${autoCaptureConfig.enabled ? autoCaptureConfig.tier : 'off'}, debug: ${debugEnabled})`,
3973
+ `memory-memoryrelay: plugin v0.12.11 loaded (39 tools, autoRecall: ${cfg?.autoRecall}, autoCapture: ${autoCaptureConfig.enabled ? autoCaptureConfig.tier : 'off'}, debug: ${debugEnabled})`,
3868
3974
  );
3869
3975
 
3870
3976
  // ========================================================================
@@ -2,8 +2,8 @@
2
2
  "id": "plugin-memoryrelay-ai",
3
3
  "kind": "memory",
4
4
  "name": "MemoryRelay AI",
5
- "description": "MemoryRelay v0.12.6 - Long-term memory with sessions, decisions, patterns & projects (api.memoryrelay.net)",
6
- "version": "0.12.10",
5
+ "description": "MemoryRelay v0.12.11 - Long-term memory with sessions, decisions, patterns & projects (api.memoryrelay.net)",
6
+ "version": "0.12.11",
7
7
  "uiHints": {
8
8
  "apiKey": {
9
9
  "label": "MemoryRelay API Key",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memoryrelay/plugin-memoryrelay-ai",
3
- "version": "0.12.10",
3
+ "version": "0.12.11",
4
4
  "description": "OpenClaw memory plugin for MemoryRelay API - sessions, decisions, patterns, projects & semantic search",
5
5
  "type": "module",
6
6
  "main": "index.ts",