Skip to content

Commit 1a556bf

Browse files
committed
feat: Add Clawdbot AI Agent Gateway EdgeApp
- Adds Clawdbot as a containerized Edgebox app - Centralized gateway for WhatsApp, Telegram, Discord, and iMessage - Supports local client connections via Bridge protocol - Configurable via Edgebox dashboard (channel tokens, model selection) - Exposes ports 18789 (Gateway), 18790 (Bridge), 18793 (Canvas) - Persistent configuration and workspace storage - Comprehensive documentation and configuration templates
1 parent d203a64 commit 1a556bf

14 files changed

+553
-0
lines changed

clawd/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
appdata/*

clawd/Dockerfile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Clawdbot AI Agent Gateway
2+
FROM node:22-bookworm-slim
3+
4+
LABEL org.opencontainers.image.description="Clawdbot - AI Agent Gateway for WhatsApp, Telegram, Discord, and iMessage"
5+
6+
# Install runtime dependencies
7+
RUN apt-get update && apt-get install -y --no-install-recommends \
8+
curl \
9+
git \
10+
python3 \
11+
python3-pip \
12+
ffmpeg \
13+
imagemagick \
14+
ghostscript \
15+
libxcb1 \
16+
libxkbcommon0 \
17+
dumb-init \
18+
tini \
19+
&& rm -rf /var/lib/apt/lists/*
20+
21+
# Create app user first
22+
RUN useradd -m -u 1001 -s /bin/bash clawdbot
23+
24+
# Set working directory
25+
WORKDIR /home/clawdbot
26+
27+
# Create necessary directories with proper permissions
28+
RUN mkdir -p \
29+
/home/system/components/clawd/config \
30+
/home/system/components/clawd/data/.clawdbot \
31+
/home/system/components/clawd/data/clawd && \
32+
chown -R clawdbot:clawdbot /home/system/components/clawd /home/clawdbot
33+
34+
# Copy entrypoint script and config template BEFORE installing clawdbot
35+
COPY --chown=clawdbot:clawdbot ./entrypoint.sh /app/entrypoint.sh
36+
RUN chmod +x /app/entrypoint.sh && chown clawdbot /app
37+
38+
COPY --chown=clawdbot:clawdbot ./clawdbot.json.template /app/clawdbot.json.template
39+
40+
# Switch to app user for npm install
41+
USER clawdbot
42+
43+
# Clear npm cache and install Clawdbot fresh
44+
RUN npm cache clean --force && npm install -g clawdbot@latest
45+
46+
# Expose ports
47+
EXPOSE 18789 18790 18793 80
48+
49+
# Health check
50+
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
51+
CMD curl -f http://localhost:18789/health || exit 1
52+
53+
# Use tini to handle signals properly
54+
ENTRYPOINT ["/usr/bin/tini", "--"]
55+
56+
# Start the Clawdbot gateway
57+
CMD ["/app/entrypoint.sh"]

clawd/README.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# Clawdbot - AI Agent Gateway EdgeApp
2+
3+
**Clawdbot** is an AI agent gateway that integrates WhatsApp, Telegram, Discord, and iMessage into a unified control plane. This EdgeApp runs Clawdbot as a centralized hub that local instances can connect to.
4+
5+
## Overview
6+
7+
- 🤖 **AI-Powered**: Integrates Claude (Anthropic) and other LLMs via Pi agent
8+
- 📱 **Multi-Channel**: WhatsApp, Telegram, Discord, iMessage all in one place
9+
- 🌐 **Distributed**: Central gateway with local client connections
10+
- 🔒 **Secure**: Token-based auth, per-agent sandboxing
11+
- 🎛️ **Configurable**: Dashboard UI for channel setup and credentials
12+
13+
## Quick Start
14+
15+
### Installation
16+
17+
```bash
18+
# Clone or sync the edgebox-iot/apps repo
19+
cd ~/Repositories/edgebox-iot/apps
20+
21+
# Build locally
22+
make build apps="clawd"
23+
24+
# Run locally
25+
make run apps="clawd"
26+
```
27+
28+
Access the dashboard at: **http://clawd.local**
29+
30+
### Configuration
31+
32+
The Clawdbot gateway is configurable via the Edgebox dashboard. Key settings:
33+
34+
- **Telegram Bot Token**: Get from [@BotFather](https://t.me/BotFather)
35+
- **Discord Bot Token**: Create at [Discord Developer Portal](https://discord.com/developers)
36+
- **Gateway Token**: Optional security token for remote access
37+
- **Primary Model**: Which LLM to use (default: Claude Opus 4.5)
38+
39+
### Ports
40+
41+
- **18789**: Gateway WebSocket (loopback by default, use token for remote)
42+
- **18790**: Bridge for iOS/Android node pairing
43+
- **18793**: Canvas host (WebView assets)
44+
- **80**: Web UI (reverse-proxied via Traefik)
45+
46+
## Architecture
47+
48+
```
49+
┌─────────────────────────────────┐
50+
│ Edgebox System │
51+
│ ┌─────────────────────────┐ │
52+
│ │ Clawdbot Gateway │ │
53+
│ │ - WhatsApp/Telegram │ │
54+
│ │ - Discord/iMessage │ │
55+
│ │ - WebChat UI │ │
56+
│ │ - Auth Management │ │
57+
│ └─────────────────────────┘ │
58+
│ ↑ ↓ │
59+
│ ┌─────────────────────────┐ │
60+
│ │ Traefik Reverse Proxy │ │
61+
│ │ (clawd.local) │ │
62+
│ └─────────────────────────┘ │
63+
└─────────────────────────────────┘
64+
65+
LAN / Tailnet
66+
67+
┌─────────────────────────────────┐
68+
│ Local Clawdbot (Mac/Linux) │
69+
│ Connects to central Gateway │
70+
└─────────────────────────────────┘
71+
```
72+
73+
## Local Client Configuration
74+
75+
To connect a local Clawdbot instance to this central gateway:
76+
77+
```json
78+
{
79+
"gateway": {
80+
"bind": "remote",
81+
"host": "clawd.local",
82+
"port": 18789,
83+
"token": "${CLAWDBOT_GATEWAY_TOKEN}"
84+
},
85+
"agents": {
86+
"defaults": {
87+
"workspace": "~/clawd-local"
88+
}
89+
}
90+
}
91+
```
92+
93+
## File Structure
94+
95+
```
96+
clawd/
97+
├── Dockerfile # Node 22 + Clawdbot
98+
├── entrypoint.sh # Init script
99+
├── clawdbot.json.template # Default config
100+
├── edgebox-compose.yml # Docker Compose config
101+
├── edgebox.env # Metadata (EDGEAPP_NAME, etc.)
102+
├── edgeapp.template.env # Config variables for dashboard
103+
├── edgeapp-icon.png # App icon
104+
├── edgebox-postinstall.sh # Post-install hook
105+
└── src/ # Static assets (if any)
106+
```
107+
108+
## Environment Variables
109+
110+
| Variable | Type | Required | Description |
111+
|----------|------|----------|-------------|
112+
| `TELEGRAM_BOT_TOKEN` | string | false | Telegram Bot API token |
113+
| `DISCORD_BOT_TOKEN` | string | false | Discord Bot token |
114+
| `CLAWDBOT_GATEWAY_TOKEN` | string | false | Security token for remote access |
115+
| `CLAWDBOT_PRIMARY_MODEL` | string | false | Primary LLM (default: claude-opus-4-5) |
116+
| `ANTHROPIC_API_KEY` | string | false | Anthropic API key |
117+
| `OPENAI_API_KEY` | string | false | OpenAI API key (fallback) |
118+
119+
## Persistence
120+
121+
- **Config**: `/home/system/components/clawd/config/clawdbot.json`
122+
- **Workspace**: `/home/system/components/clawd/data/clawd`
123+
- **State**: `/home/system/components/clawd/data/.clawdbot`
124+
125+
Data persists across container restarts via Docker volumes.
126+
127+
## Extending
128+
129+
### Add a New Agent
130+
131+
Edit `clawdbot.json`:
132+
133+
```json
134+
{
135+
"agents": {
136+
"list": [
137+
{ "id": "main", "workspace": "..." },
138+
{ "id": "work", "workspace": "..." }
139+
]
140+
},
141+
"bindings": [
142+
{ "agentId": "work", "match": { "channel": "discord" } }
143+
]
144+
}
145+
```
146+
147+
### Multi-instance Setup
148+
149+
Run multiple app instances with different ports:
150+
151+
```bash
152+
# Instance 1
153+
docker-compose -p clawd-1 up -d
154+
155+
# Instance 2
156+
docker-compose -p clawd-2 up -d
157+
```
158+
159+
## Troubleshooting
160+
161+
### Health Check Fails
162+
163+
```bash
164+
# Check logs
165+
docker logs edgebox-clawd-ws
166+
167+
# Verify ports are open
168+
lsof -i :18789
169+
```
170+
171+
### Can't Connect from Local Client
172+
173+
- Ensure `CLAWDBOT_GATEWAY_TOKEN` is set in both gateway and client
174+
- Check network connectivity: `ping clawd.local`
175+
- Verify firewall allows port 18789
176+
177+
### Channel Credentials Not Loading
178+
179+
- Set env variables in docker-compose or Edgebox dashboard
180+
- Restart the container after changing credentials
181+
- Check logs for auth errors
182+
183+
## Resources
184+
185+
- **Clawdbot Docs**: https://docs.clawd.bot
186+
- **Clawdbot GitHub**: https://github.com/clawdbot/clawdbot
187+
- **Edgebox Docs**: https://edgebox.io
188+
- **Clawdbot Discord**: https://discord.com/invite/clawd
189+
190+
## License
191+
192+
MIT - Same as Clawdbot

clawd/clawdbot.json.template

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"gateway": {
3+
"port": 18789,
4+
"bind": "0.0.0.0",
5+
"canvasHost": {
6+
"port": 18793,
7+
"bind": "0.0.0.0"
8+
}
9+
},
10+
"agents": {
11+
"defaults": {
12+
"workspace": "/home/system/components/clawd/data/clawd",
13+
"models": {
14+
"anthropic/claude-opus-4-5": { "alias": "opus" },
15+
"anthropic/claude-sonnet-4-5": { "alias": "sonnet" },
16+
"openai/gpt-5.2": { "alias": "gpt" }
17+
},
18+
"model": {
19+
"primary": "anthropic/claude-opus-4-5"
20+
},
21+
"thinkingDefault": "low",
22+
"timeoutSeconds": 600
23+
}
24+
},
25+
"channels": {
26+
"telegram": {
27+
"enabled": true,
28+
"botToken": "${TELEGRAM_BOT_TOKEN}"
29+
},
30+
"discord": {
31+
"enabled": true,
32+
"token": "${DISCORD_BOT_TOKEN}"
33+
},
34+
"whatsapp": {
35+
"enabled": true
36+
}
37+
},
38+
"messages": {
39+
"responsePrefix": "[Clawd]"
40+
}
41+
}

clawd/edgeapp.template.env

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Clawdbot Configuration Template
2+
# Format: VARIABLE_NAME=type|required|description
3+
# Types: bool, string, number, array
4+
# Required: true/false
5+
6+
# Channel Credentials
7+
TELEGRAM_BOT_TOKEN=string|false|Telegram Bot API token from @BotFather
8+
DISCORD_BOT_TOKEN=string|false|Discord Bot token from Developer Portal
9+
WHATSAPP_ENABLED=bool|false|Enable WhatsApp channel
10+
11+
# Gateway Access
12+
CLAWDBOT_GATEWAY_TOKEN=string|false|Security token for remote gateway access (required for non-loopback)
13+
14+
# Model/Agent Configuration
15+
CLAWDBOT_PRIMARY_MODEL=string|false|Primary LLM model (default: anthropic/claude-opus-4-5)
16+
ANTHROPIC_API_KEY=string|false|Anthropic API key for Claude
17+
OPENAI_API_KEY=string|false|OpenAI API key (fallback)
18+
19+
# Optional: Advanced Configuration
20+
CLAWDBOT_THINKING_DEFAULT=string|false|Default thinking level (off/low/high)
21+
CLAWDBOT_TIMEOUT_SECONDS=number|false|Agent timeout in seconds (default: 600)

clawd/edgebox-compose.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
services:
2+
##############
3+
# Clawdbot AI Agent Gateway
4+
##############
5+
clawd-ws:
6+
image: ghcr.io/edgebox-iot/apps/${COMPOSE_APP_SLUG-clawd}:1.0.0
7+
build:
8+
context: "./"
9+
container_name: '${COMPOSE_PROJECT_NAME-edgebox}-${COMPOSE_APP_SLUG-clawd}-ws'
10+
restart: unless-stopped
11+
environment:
12+
# Traefik reverse proxy variables
13+
VIRTUAL_HOST: ${LOCAL_URL-clawd.local}${INTERNET_URL-}
14+
VIRTUAL_PORT: 80
15+
16+
# Clawdbot configuration paths
17+
CLAWDBOT_WORKSPACE: ${CLAWDBOT_WORKSPACE-/home/system/components/clawd/data/clawd}
18+
CLAWDBOT_STATE_DIR: ${CLAWDBOT_STATE_DIR-/home/system/components/clawd/data/.clawdbot}
19+
CLAWDBOT_CONFIG_PATH: ${CLAWDBOT_CONFIG_PATH-/home/system/components/clawd/config/clawdbot.json}
20+
21+
# Gateway token for remote access
22+
CLAWDBOT_GATEWAY_TOKEN: ${CLAWDBOT_GATEWAY_TOKEN}
23+
24+
# Channel credentials
25+
TELEGRAM_BOT_TOKEN: ${TELEGRAM_BOT_TOKEN}
26+
DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}
27+
28+
# Node environment
29+
NODE_ENV: production
30+
NODE_OPTIONS: --max-old-space-size=1024
31+
32+
volumes:
33+
# System time (read-only)
34+
- /etc/localtime:/etc/localtime:ro
35+
# Config directory (persistent)
36+
- ./appdata/${COMPOSE_APP_SLUG-clawd}-config:/home/system/components/clawd/config:rw
37+
# Data directory (persistent state, auth profiles, workspace)
38+
- ./appdata/${COMPOSE_APP_SLUG-clawd}-data:/home/system/components/clawd/data:rw
39+
40+
# Expose all necessary ports
41+
ports:
42+
# Gateway WebSocket
43+
- "18789:18789"
44+
# Bridge for node pairing (LAN/Tailnet)
45+
- "18790:18790"
46+
# Canvas host (WebView assets)
47+
- "18793:18793"
48+
49+
# Network settings (traefik optional for dev)
50+
networks:
51+
default: null
52+
53+
# Health check
54+
healthcheck:
55+
test: ["CMD", "curl", "-f", "http://localhost:18789/health"]
56+
interval: 30s
57+
timeout: 10s
58+
retries: 3
59+
start_period: 40s
60+
61+
# Logging
62+
logging:
63+
driver: "json-file"
64+
options:
65+
max-size: "50m"
66+
max-file: "5"
67+
68+
networks:
69+
default:
70+
driver: bridge
71+

clawd/edgebox-hosts.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

clawd/edgebox-icon.png

15.1 KB
Loading

clawd/edgebox-postinstall.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# mkdir -p ./appdata/hello-ws
2+
echo "📦 hello postinstall script"
3+
echo "- Running in $(pwd)"
4+
echo "- Copying files to ./appdata/hello-ws"
5+
cp ./src/install/* ./appdata/hello-ws/

0 commit comments

Comments
 (0)