← Back to Plugins
Voice

Moltbot Memory Local

48Nauts-Operator By 48Nauts-Operator 👁 41 views ▲ 3 votes

Privacy-first local memory plugin for Moltbot: SQLite + local embeddings, zero cloud calls

GitHub

Install

npm install moltbot-memory-local

Configuration Example

{
  "plugins": {
    "slots": {
      "memory": "moltbot-memory-local"
    },
    "entries": {
      "moltbot-memory-local": {
        "enabled": true,
        "config": {
          "dataDir": "~/.moltbot/memory",
          "maxMemories": 10000,
          "embeddingModel": "Xenova/all-MiniLM-L6-v2",
          "enableEmbeddings": true
        }
      }
    }
  }
}

README

# moltbot-memory-local

<p align="center">
  <img src="https://raw.githubusercontent.com/48Nauts-Operator/moltbot-memory-local/main/assets/privacy-crab-small.png" alt="Privacy Crab" width="400">
</p>

> Privacy-first local memory plugin for Moltbot

**One plugin. Two search modes. Zero cloud calls.**

Combines SQLite (structured/temporal) + LanceDB (semantic/vector) into a single unified memory system. Everything runs locally on your machine.

## Why This Exists

Most AI memory plugins send your data to cloud APIs for embedding. Your "local" memory phones home before storing anything.

This plugin fixes that:
- **SQLite** for structured storage, timestamps, full-text search
- **LanceDB + local embeddings** for semantic similarity search
- **Smart routing** automatically picks the right backend
- **100% local** β€” no cloud calls, ever

## Installation

```bash
npm install moltbot-memory-local
```

## Configuration

```json
{
  "plugins": {
    "slots": {
      "memory": "moltbot-memory-local"
    },
    "entries": {
      "moltbot-memory-local": {
        "enabled": true,
        "config": {
          "dataDir": "~/.moltbot/memory",
          "maxMemories": 10000,
          "embeddingModel": "Xenova/all-MiniLM-L6-v2",
          "enableEmbeddings": true
        }
      }
    }
  }
}
```

### Options

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `dataDir` | string | `~/.moltbot/memory` | Data directory |
| `maxMemories` | number | `10000` | Max before pruning |
| `embeddingModel` | string | `Xenova/all-MiniLM-L6-v2` | Local embedding model |
| `enableEmbeddings` | boolean | `true` | Enable semantic search |
| `defaultImportance` | number | `0.7` | Default memory importance |

## How It Works

### Automatic Query Routing

The plugin detects query type and routes automatically:

```
"What did you do Thursday at 14:04?"  β†’  SQLite (temporal)
"Find conversations about dark mode"  β†’  Vector search (semantic)
"What is my email address?"           β†’  SQLite (exact lookup)
"Similar ideas to X"                  β†’  Vector search (semantic)
```

### Manual Mode Selection

Override automatic routing:

```typescript
// Force semantic search
await memory_recall({ query: "...", mode: "semantic" });

// Force structured search
await memory_recall({ query: "...", mode: "structured" });

// Let plugin decide (default)
await memory_recall({ query: "...", mode: "auto" });
```

## Usage

### Store

```typescript
await memory_store({
  text: "User prefers dark mode in all applications",
  category: "preference",  // preference|fact|decision|entity|conversation|other
  importance: 0.9          // 0-1, higher = kept longer
});
```

Memories are stored in both SQLite (full data) and LanceDB (vector for semantic search).

### Recall

```typescript
// Temporal query β†’ routed to SQLite
const thursdayMemories = await memory_recall({
  query: "what happened last Thursday",
  limit: 5
});

// Semantic query β†’ routed to vector search
const similarMemories = await memory_recall({
  query: "display and theme preferences",
  limit: 5
});

// With filters
const decisions = await memory_recall({
  query: "project architecture",
  category: "decision",
  dateFrom: "2025-01-01"
});
```

### Forget (GDPR)

```typescript
// By ID
await memory_forget({ memoryId: "uuid-here" });

// By query (deletes from both SQLite and vectors)
await memory_forget({ query: "sensitive information" });
```

## Architecture

```
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    moltbot-memory-local                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                              β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚   β”‚     SQLite       β”‚      β”‚     LanceDB      β”‚           β”‚
β”‚   β”‚  ──────────────  β”‚      β”‚  ──────────────  β”‚           β”‚
β”‚   β”‚  Full text       β”‚      β”‚  Vector store    β”‚           β”‚
β”‚   β”‚  Timestamps      β”‚      β”‚  Local embeddingsβ”‚           β”‚
β”‚   β”‚  Metadata        β”‚      β”‚  Semantic search β”‚           β”‚
β”‚   β”‚  Categories      β”‚      β”‚                  β”‚           β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚            β”‚                         β”‚                      β”‚
β”‚            β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚
β”‚                       β”‚                                     β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                           β”‚
β”‚              β”‚  Query Router   β”‚                           β”‚
β”‚              β”‚  ────────────── β”‚                           β”‚
β”‚              β”‚  "Thursday?" β†’  β”‚ β†’ SQLite                  β”‚
β”‚              β”‚  "Similar?" β†’   β”‚ β†’ Vectors                 β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                           β”‚
β”‚                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         ❌ No cloud     βœ… 100% Local     βœ… Your data
```

## Data Storage

```
~/.moltbot/memory/
β”œβ”€β”€ memories.db      # SQLite database (structured data)
└── vectors/         # LanceDB vector store (embeddings)
```

## Embedding Models

Default: `Xenova/all-MiniLM-L6-v2` (384 dimensions, ~23MB)

Alternatives:
- `Xenova/e5-small-v2` β€” Better quality, similar size
- `Xenova/all-MiniLM-L12-v2` β€” More accurate, larger

Models download automatically on first use.

## Fallback Behavior

- If LanceDB fails β†’ falls back to SQLite-only search
- If embeddings disabled β†’ SQLite full-text search only
- If embedding fails for a memory β†’ stored in SQLite, skipped in vectors

## License

MIT Β© Andre Wolke

## Links

- [Documentation](https://gist.github.com/48Nauts-Operator/0c72802380ea03ec6b87c8ca8ff21b29)
- [Moltbot](https://github.com/moltbot/moltbot)
- [21nauts](https://21nauts.com)
voice

Comments

Sign in to leave a comment

Loading comments...