Tools
Memory Spark
OpenClaw memory plugin: LanceDB + NVIDIA Spark GPU embeddings for autonomous AI agents
Install
npm install @lancedb/lancedb`
Configuration Example
{
"plugins": {
"slots": { "memory": "memory-spark" },
"allow": ["memory-spark"],
"entries": { "memory-spark": { "enabled": true } },
"load": { "paths": ["~/.openclaw/extensions/memory-spark"] }
}
}
README
# memory-spark
An OpenClaw memory plugin with LanceDB vector storage and NVIDIA Spark GPU-accelerated embeddings. Drop-in replacement for `memory-core` with autonomous recall, capture, file ingestion, and hybrid search.
## Features
- **Auto-recall** โ injects relevant memories before every agent turn (`before_prompt_build` hook)
- **Auto-capture** โ extracts and stores facts/preferences from conversations (`agent_end` hook)
- **File watcher** โ auto-indexes your workspace memory dirs, sessions, and watched paths on boot and on change
- **PDF / DOCX / audio ingest** โ parse and embed documents via `pdftotext`, `mammoth`, and STT
- **Hybrid search + rerank** โ vector search + BM25 full-text, reranked by Cohere-compatible cross-encoder
- **NVIDIA Spark GPU embeddings** โ `nvidia/llama-embed-nemotron-8b` (4096d), 0.25s/call on Blackwell GPU
- **Serialized embed queue** โ retry with exponential backoff, health monitoring, auto-cooldown
- **Dimension lock** โ refuses to start if provider/dims mismatch, preventing silent vector corruption
- **Zero-touch** โ configure once, everything else is automatic
## Architecture
```
memory-spark/
โโโ index.ts # Plugin entry: register(), tool handlers, hooks
โโโ src/
โ โโโ config.ts # Config schema + defaults + .env loader
โ โโโ manager.ts # MemorySearchManager: search, store, forget
โ โโโ auto/
โ โ โโโ recall.ts # before_prompt_build hook โ injects memories
โ โ โโโ capture.ts # agent_end hook โ classifies + stores new facts
โ โโโ embed/
โ โ โโโ provider.ts # EmbedProvider: Spark โ OpenAI โ Gemini fallback
โ โ โโโ queue.ts # EmbedQueue: serial requests, retry, health tracking
โ โ โโโ chunker.ts # Markdown-aware token-bounded chunking with overlap
โ โ โโโ dims-lock.ts # Dimension lock: validates provider/model/dims on startup
โ โโโ ingest/
โ โ โโโ pipeline.ts # extract โ chunk โ NER โ embed โ upsert
โ โ โโโ watcher.ts # Chokidar watcher + boot pass across all agent workspaces
โ โ โโโ workspace.ts # Agent workspace discovery, session scanning
โ โ โโโ parsers.ts # PDF (pdftotext+OCR), DOCX (mammoth), audio (STT), text
โ โโโ classify/
โ โ โโโ ner.ts # NER via Spark 18112 (dslim/bert-base-NER)
โ โ โโโ zero-shot.ts # Zero-shot classifier via Spark 18113 (bart-large-mnli)
โ โโโ rerank/
โ โ โโโ reranker.ts # Cohere-compatible reranker via Spark 18096
โ โโโ storage/
โ โโโ backend.ts # StorageBackend interface
โ โโโ lancedb.ts # LanceDB: connect, upsert (mergeInsert), vectorSearch, FTS, delete
```
## Requirements
- [OpenClaw](https://openclaw.ai) โ the plugin host
- [LanceDB](https://lancedb.github.io/lancedb/) โ `npm install @lancedb/lancedb`
- `pdftotext` (poppler-utils) โ for PDF parsing
- NVIDIA Spark microservices (optional but recommended):
- **Embed** โ port 18091 (`nvidia/llama-embed-nemotron-8b`, 4096d)
- **Reranker** โ port 18096 (`nvidia/llama-nemotron-rerank-1b-v2`)
- **NER** โ port 18112 (`dslim/bert-base-NER`)
- **Zero-shot** โ port 18113 (`facebook/bart-large-mnli`)
- **OCR** โ port 18097
- **STT** โ port 18094
Falls back to OpenAI or Gemini embeddings if Spark is unavailable.
## Setup
### 1. Install
```bash
cd ~/.openclaw/extensions
git clone https://github.com/kleinpanic/memory-spark
cd memory-spark && npm install && npm run build
```
### 2. Configure OpenClaw
In `~/.openclaw/openclaw.json`:
```json
{
"plugins": {
"slots": { "memory": "memory-spark" },
"allow": ["memory-spark"],
"entries": { "memory-spark": { "enabled": true } },
"load": { "paths": ["~/.openclaw/extensions/memory-spark"] }
}
}
```
### 3. Environment
Set your Spark bearer token in `~/.openclaw/.env`:
```
SPARK_BEARER_TOKEN=your_token_here
```
### 4. Config (openclaw.json)
```json
{
"memory": {
"backend": "lancedb",
"lancedb": { "uri": "~/.openclaw/data/memory-spark/lancedb" },
"embed": {
"provider": "spark",
"model": "nvidia/llama-embed-nemotron-8b",
"baseUrl": "http://localhost:18091/v1"
},
"recall": {
"enabled": true,
"topK": 5,
"minScore": 0.3,
"maxTokens": 1500
},
"capture": {
"enabled": true,
"categories": ["fact", "preference", "decision"]
},
"watch": {
"enabled": true,
"indexOnBoot": true,
"debounceMs": 2000,
"paths": []
}
}
}
```
## Tools
Exposes four tools to agents:
| Tool | Description |
|------|-------------|
| `memory_search` | Hybrid vector + FTS search with reranking |
| `memory_get` | Retrieve a specific chunk by ID |
| `memory_store` | Store a fact/note manually |
| `memory_forget` | Delete memories by path or query |
## License
MIT
## Acknowledgments
Built on [LanceDB](https://lancedb.github.io/lancedb/), [NVIDIA Nemotron](https://developer.nvidia.com/nemotron), and [OpenClaw](https://openclaw.ai).
tools
Comments
Sign in to leave a comment