75 lines
1.8 KiB
Markdown
75 lines
1.8 KiB
Markdown
# Matrix-Letta Bridge
|
|
|
|
A bridge connecting [Letta](https://letta.com) AI agents to encrypted Matrix rooms using [mautrix-python](https://github.com/mautrix/python).
|
|
|
|
## Features
|
|
|
|
- **End-to-end encryption (E2EE)** - Full support via mautrix-python's OlmMachine
|
|
- **Reaction-to-feedback mapping** - Matrix emoji reactions (thumbs up/down) are sent as feedback to Letta for preference learning
|
|
- **Persistent crypto store** - SQLite-based storage for E2EE keys and session state
|
|
- **Cross-signing support** - Optional recovery key for device verification
|
|
|
|
## Setup
|
|
|
|
### Prerequisites
|
|
|
|
- Python 3.10+
|
|
- A Matrix homeserver account
|
|
- A Letta Cloud account and agent
|
|
|
|
### Installation
|
|
|
|
```bash
|
|
python -m venv venv
|
|
source venv/bin/activate
|
|
pip install mautrix python-dotenv requests
|
|
```
|
|
|
|
### Configuration
|
|
|
|
Create a `.env` file:
|
|
|
|
```bash
|
|
# Matrix
|
|
MATRIX_HOMESERVER=https://your-homeserver.example.com
|
|
MATRIX_USER_ID=@bot:your-homeserver.example.com
|
|
MATRIX_PASSWORD=your-bot-password
|
|
MATRIX_RECOVERY_KEY= # Optional: for cross-signing verification
|
|
|
|
# Letta
|
|
LETTA_API_KEY=sk-let-...
|
|
LETTA_AGENT_ID=agent-...
|
|
LETTA_BASE_URL=https://api.letta.com/v1/
|
|
|
|
# Optional
|
|
BRIDGE_DB_URL=sqlite:store/bridge.db
|
|
CRYPTO_PICKLE_KEY=your-pickle-key
|
|
```
|
|
|
|
### Running
|
|
|
|
```bash
|
|
python bridge-e2ee.py
|
|
```
|
|
|
|
Or install as a systemd service using `meridian-bridge.service`.
|
|
|
|
## Reaction Feedback Mapping
|
|
|
|
| Reaction | Feedback |
|
|
|----------|----------|
|
|
| 👍 👍️ ❤️ 🎉 ✅ 🙌 💯 | positive |
|
|
| 👎 👎️ 👀 ❓ 😕 ❌ | negative |
|
|
|
|
Feedback is sent to Letta's `/v1/steps/{step_id}/feedback` endpoint via PATCH.
|
|
|
|
## Architecture
|
|
|
|
- `bridge-e2ee.py` - Main bridge script
|
|
- `sqlite_crypto_store.py` - E2EE key storage implementation
|
|
- `store/` - Runtime data (SQLite databases, session state)
|
|
|
|
## License
|
|
|
|
MIT
|