Voice
Memory Cdc
An OpenClaw plugin that turns agent memory into an event stream. When one agent learns something, every other agent that cares finds out automatically.
Install
npm install
pnpm
Configuration Example
// Hub machine
{ "mode": "hub", "port": 4222 }
// Leaf machine
{ "mode": "leaf", "hub": "nats://hub.tailscale:4222" }
README
# openclaw-memory-cdc
An OpenClaw plugin that turns agent memory into an event stream. When one agent learns something, every other agent that cares finds out automatically. No polling, no cron jobs, no external databases. Just NATS and hooks.
## How It Works
```
Agent A learns something β writes to memory β plugin diffs the change
β publishes to NATS β Agent B gets a message β plugin injects sync
β Agent B sees the update in its daily log
```
Two publishing triggers:
- **`session:compact:after`** β high-signal: fires after the agent distills its most important learnings
- **`message:sent`** β lightweight: fires on explicit "remember this" writes (mtime check, usually a no-op)
One subscribing trigger:
- **`message:received`** β drains pending events into today's daily log before the agent processes anything
Agents self-configure their subscriptions via the `MEMORY_CDC` skill. No human configuration needed.
## Architecture
```
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
β OpenClaw Gateway β
β β
β ββββββββββ ββββββββββ ββββββββββ β
β βAgent A β βAgent B β βAgent C β β
β βββββ¬βββββ βββββ¬βββββ βββββ¬βββββ β
β β β β β
β βββββΌβββββββββββββΌβββββββββββββΌβββββββ β
β β Memory CDC Plugin β β
β β Hooks Tools Publisher Sub β β
β ββββββββββββββββββββ¬ββββββββββββββββββ β
β β β
β ββββββββββββββββββββΌββββββββββββββββββ β
β β Embedded NATS Server β β
β β PubSub ββββΊ JetStream β β
β β Stream: SWARM_MEMORY β β
β ββββββββββββββββββββββββββββββββββββββ β
ββββββββββββββββββββββββββββββββββββββββββββββββββββ
```
For multi-machine setups, NATS leaf nodes transparently bridge events across machines with zero code changes.
## Prerequisites
- Node.js >= 18
- OpenClaw Gateway
## Installation
```bash
openclaw plugins install clawhub:openclaw-memory-cdc
openclaw config set plugins.entries.openclaw-memory-cdc.enabled true
openclaw gateway restart
```
Optional remote config:
```json
// Hub machine
{ "mode": "hub", "port": 4222 }
// Leaf machine
{ "mode": "leaf", "hub": "nats://hub.tailscale:4222" }
```
## Project Structure
```
βββ openclaw.plugin.json # Plugin manifest
βββ src/
β βββ index.ts # Plugin entry (definePluginEntry)
β βββ config.ts # Config types
β βββ nats/ # NATS server, client, JetStream
β βββ publisher/ # Differ, formatter, batcher
β βββ subscriber/ # Drain, dedup, injector
β βββ tools/ # 5 agent-facing CDC tools
βββ tests/ # Vitest tests (mirrors src/)
βββ skills/
β βββ MEMORY_CDC/ # Agent self-configuration skill
βββ docs/
βββ specs/ # Module design specs
βββ concepts/ # Cross-cutting concepts
```
## Development
```bash
pnpm install
pnpm build # TypeScript compilation
pnpm test # Run Vitest
pnpm test:coverage # Coverage report
pnpm lint # ESLint
pnpm format # Prettier
```
## Documentation
Design specs and architectural concepts live in `docs/`:
- `docs/specs/` β one file per source module (nats, publisher, subscriber, tools, config)
- `docs/concepts/` β cross-cutting topics (topology, data flow, self-config, safety)
## License
ISC
voice
Comments
Sign in to leave a comment