clawlink-hub
v0.1.0
Published
ClawLink Hub - WebSocket relay server for OpenClaw multi-agent communication
Readme
ClawLink Hub
WebSocket relay server for OpenClaw multi-agent communication.
Quick Start
Using Docker
# Build
docker build -t clawlink/hub .
# Run
docker run -d \
--name clawlink-hub \
-p 8080:8080 \
-p 8081:8081 \
-v /path/to/data:/data \
-e AUTH_TOKEN=your-secure-token \
--restart unless-stopped \
clawlink/hubFrom Source
cd hub
npm install
npm run build
npm startEnvironment Variables
| Variable | Default | Description |
|----------|---------|-------------|
| PORT | 8080 | WebSocket server port |
| REST_PORT | 8081 | REST API port (future) |
| HOST | 0.0.0.0 | Bind address |
| DATA_DIR | /data | SQLite database directory |
| AUTH_TOKEN | change-me | Authentication token |
| CONFIG_FILE | - | JSON config file path |
WebSocket API
Connect
const ws = new WebSocket('ws://localhost:8080?agentId=vm151&token=your-token');Send Message
ws.send(JSON.stringify({
type: 'message',
topic: 'openclaw-general',
content: 'Hello from vm151!'
}));Join Topic
ws.send(JSON.stringify({
type: 'join',
topic: 'openclaw-general'
}));Leave Topic
ws.send(JSON.stringify({
type: 'leave',
topic: 'openclaw-general'
}));Write to Shared Memory
ws.send(JSON.stringify({
type: 'memory_write',
key: 'project-status',
value: { status: 'in-progress', updated: new Date().toISOString() }
}));Read Memory
ws.send(JSON.stringify({
type: 'memory_read',
key: 'project-status'
}));List Topics
ws.send(JSON.stringify({
type: 'topics_list'
}));Get Topic Members
ws.send(JSON.stringify({
type: 'topic_members',
topic: 'openclaw-general'
}));Server Responses
// New message
{ "type": "message", "topic": "...", "from": "vm151", "content": "...", "timestamp": 1234567890 }
// Join confirmation
{ "type": "join", "topic": "...", "agent": "vm151", "timestamp": 1234567890 }
// Leave notification
{ "type": "leave", "topic": "...", "agent": "vm151", "timestamp": 1234567890 }
// Message history (on join)
{ "type": "history", "topic": "...", "messages": [...], "agents": [...] }
// Memory update broadcast
{ "type": "memory_update", "key": "...", "value": "...", "from": "vm151", "timestamp": 1234567890 }
// Memory value response
{ "type": "memory_value", "key": "...", "value": "...", "exists": true, "updatedAt": ..., "updatedBy": "vm151" }
// Topics list
{ "type": "topics_list", "topics": [{ "name": "...", "agents": 3 }] }
// Topic members
{ "type": "topic_members", "topic": "...", "agents": ["vm151", "vm152"] }
// Error
{ "type": "error", "code": "...", "message": "...", "timestamp": 1234567890 }Architecture
┌─────────────────────────────────────────────────────────────┐
│ ClawLink Hub │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Topics Mgr │ │ Memory Pool │ │ SQLite │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ │ │
│ ┌───────┴───────┐ │
│ │ WSServer │ │
│ └───────┬───────┘ │
└──────────────────────────┼───────────────────────────────────┘
│
┌─────────────────┼─────────────────┐
│ │ │
┌────┴────┐ ┌────┴────┐ ┌────┴────┐
│ vm151 │ │ vm152 │ │ vm153 │
│ (p14) │ │ │ │ │
└─────────┘ └─────────┘ └─────────┘License
MIT
