Clasp
CLASP is a real-time infrastructure layer for connected devices. One binary protocol handles state synchronization, pub/sub messaging, E2E encryption, device identity, programmable transforms, reactive automation, and multi-site federation.
Install / Use
/learn @lumencanvas/ClaspREADME
CLASP is a real-time infrastructure layer for connected devices. One binary protocol handles state synchronization, pub/sub messaging, E2E encryption, device identity, programmable transforms, reactive automation, and multi-site federation. Bridges for MQTT, BLE, Serial, HTTP, OSC, MIDI, DMX, and Art-Net make existing hardware work together immediately.
Why CLASP?
Building connected applications means solving the same problems every time: state sync, auth, encryption, discovery, automation, multi-site coordination. Every project reinvents this from scratch. CLASP provides all of it in one system.
Five things set it apart from generic pub/sub:
Semantic signal types. The router distinguishes Params (stateful, conflict-resolved, persisted, delivered to late-joiners), Events (confirmed, ephemeral), Streams (best-effort, droppable under congestion), Gestures (phased lifecycle with begin/update/end), and Timelines (keyframed automation with easing). The infrastructure layer makes routing decisions that other systems push to application code.
Protocol bridging as architecture. MQTT, OSC, MIDI, DMX, Art-Net, sACN, HTTP, WebSocket, Socket.IO, BLE, Serial. Each protocol gets one bridge. Any device on any protocol can read and write state from any other device on any other protocol, through one router. N bridges, not N-squared adapters.
Late-joiner state sync. New clients receive a snapshot of all current Param state the instant they subscribe. Five conflict strategies (LWW, Max, Min, Lock, Merge) with optimistic concurrency via revision numbers. This eliminates an entire class of "initial state" bugs that plague every real-time system.
Server-side rules engine. Reactive automation evaluated on every state change: thresholds, pattern-matched triggers, conditions, transforms, cooldowns. Zero application code. The router becomes a programmable edge compute node.
Federation with namespace ownership. Hub-leaf topology where each site owns its namespace prefix. No distributed consensus needed. DefraDB integration adds Merkle CRDT-based persistent state that survives restarts and syncs across sites automatically.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ TouchOSC │ │ Ableton │ │ LED Strip │
│ (OSC) │ │ (MIDI) │ │ (Art-Net) │
└──────┬──────┘ └──────┬──────┘ └──────┬──────┘
│ │ │
└───────────────────┼───────────────────┘
│
┌──────▼──────┐
│ CLASP │
│ Router │
└──────┬──────┘
│
┌───────────────────┼───────────────────┐
│ │ │
┌──────▼──────┐ ┌──────▼──────┐ ┌──────▼──────┐
│ Web UI │ │ IoT Hub │ │ Resolume │
│ (WebSocket) │ │ (MQTT) │ │ (OSC) │
└─────────────┘ └─────────────┘ └─────────────┘
Install
CLI
cargo install clasp-cli
Packages
Client Libraries
| Platform | Package | Install |
|----------|---------|---------|
| JavaScript | @clasp-to/sdk | npm install @clasp-to/sdk |
| JavaScript | @clasp-to/core | npm install @clasp-to/core |
| JavaScript | @clasp-to/crypto | npm install @clasp-to/crypto |
| Python | clasp-to | pip install clasp-to |
| Arduino | Clasp | Arduino Library Manager |
Rust Crates: Core
| Crate | Description | Install |
|-------|-------------|---------|
| clasp-core | Types, codec, state management | cargo add clasp-core |
| clasp-client | High-level async client | cargo add clasp-client |
| clasp-router | Message routing and pattern matching | cargo add clasp-router |
| clasp-transport | WebSocket, QUIC, TCP, BLE, Serial | cargo add clasp-transport |
| clasp-bridge | Protocol bridges (OSC, MIDI, MQTT, etc.) | cargo add clasp-bridge |
| clasp-crypto | E2E encryption (AES-256-GCM, ECDH) | cargo add clasp-crypto |
| clasp-identity | Unified Ed25519 identity (EntityId + DID + PeerID) | cargo add clasp-identity |
Rust Crates: Infrastructure
| Crate | Description | Install |
|-------|-------------|---------|
| clasp-caps | Delegatable Ed25519 capability tokens | cargo add clasp-caps |
| clasp-registry | Persistent entity identity registry | cargo add clasp-registry |
| clasp-journal | Append-only event journal | cargo add clasp-journal |
| clasp-rules | Server-side reactive rules engine | cargo add clasp-rules |
| clasp-federation | Router-to-router federation | cargo add clasp-federation |
| clasp-discovery | mDNS/DNS-SD device discovery | cargo add clasp-discovery |
| clasp-lens | LensVM WASM transform host | cargo add clasp-lens |
Rust Crates: DefraDB Integration (docs | DEFRA.md)
| Crate | Description | Install |
|-------|-------------|---------|
| clasp-journal-defra | DefraDB journal backend with P2P sync | cargo add clasp-journal-defra |
| clasp-state-defra | Write-through cache with DefraDB persistence | cargo add clasp-state-defra |
| clasp-defra-bridge | Bidirectional DefraDB/CLASP signal bridge | cargo add clasp-defra-bridge |
| clasp-config-defra | P2P config sync with version history | cargo add clasp-config-defra |
| clasp-registry-defra | DefraDB entity store with P2P identity sync | cargo add clasp-registry-defra |
| clasp-defra-transport | DefraDB sync over CLASP transports | cargo add clasp-defra-transport |
Deploy to DigitalOcean
Create an Ubuntu 22.04 droplet (1 GB+ RAM), SSH in, and run:
curl -fsSL https://raw.githubusercontent.com/lumencanvas/clasp/main/deploy/marketplace/digitalocean/bootstrap.sh | bash
This installs Docker, pulls the relay image, and sets up the clasp-setup interactive configurator. Then run clasp-setup to choose your deployment profile, configure TLS, auth, persistence, protocol bridges, and start the relay.
To remove CLASP from a droplet:
docker compose -f /opt/clasp/docker-compose.yml down -v
rm -rf /opt/clasp /var/lib/clasp /usr/local/bin/clasp-setup
See deployment docs for full details.
Desktop App
Download the latest release for your platform:
- macOS: CLASP Bridge.dmg
- Windows: CLASP Bridge Setup.exe
- Linux: clasp-bridge.AppImage
CLASP SDK
The easiest way to use CLASP from JavaScript/TypeScript. @clasp-to/sdk wraps the core protocol with a human-friendly API:
import clasp from '@clasp-to/sdk'
const c = await clasp('ws://localhost:7330', { name: 'My App' })
await c.set('/lights/brightness', 0.8) // persistent state
c.on('/lights/**', (val, addr) => { ... }) // wildcard subscribe
await c.emit('/cues/go') // fire-and-forget event
c.stream('/sensors/accel', { x: 0.1, y: 9.8 }) // high-rate data
// Devices, encrypted rooms, rules, bridges. All built in
const device = await c.register({ name: 'Sensor', scopes: ['write:/sensors/**'] })
const room = await c.room('/chat/private') // E2E encrypted
c.rule('alert', { when: '/temp', above: 30, then: { emit: ['/alert', 'hot!'] } })
For lower-level control, use @clasp-to/core directly (docs).
DefraDB Integration
CLASP state is ephemeral by default. DefraDB is a peer-to-peer document database built on Merkle CRDTs. Six crates connect them so CLASP gets persistent, distributed state without giving up the sub-100us hot path.
Signals route through the in-memory cache as before. Writes flush to DefraDB in the
