feat: add MoltBot service with configuration files and documentation

This commit is contained in:
Sun-ZhenXing
2026-01-30 10:12:03 +08:00
parent 31bcf0c435
commit e2ac465417
9 changed files with 601 additions and 5 deletions

View File

@@ -81,6 +81,7 @@ These services require building custom Docker images from source.
| [Minecraft Bedrock Server](./src/minecraft-bedrock-server) | latest |
| [MinIO](./src/minio) | 0.20251015 |
| [MLflow](./src/mlflow) | v2.20.2 |
| [MoltBot](./apps/moltbot) | main |
| [MongoDB ReplicaSet Single](./src/mongodb-replicaset-single) | 8.2.3 |
| [MongoDB ReplicaSet](./src/mongodb-replicaset) | 8.2.3 |
| [MongoDB Standalone](./src/mongodb-standalone) | 8.2.3 |

View File

@@ -81,6 +81,7 @@ Compose Anything 通过提供一组高质量的 Docker Compose 配置文件,
| [Minecraft Bedrock Server](./src/minecraft-bedrock-server) | latest |
| [MinIO](./src/minio) | 0.20251015 |
| [MLflow](./src/mlflow) | v2.20.2 |
| [MoltBot](./apps/moltbot) | main |
| [MongoDB ReplicaSet Single](./src/mongodb-replicaset-single) | 8.2.3 |
| [MongoDB ReplicaSet](./src/mongodb-replicaset) | 8.2.3 |
| [MongoDB Standalone](./src/mongodb-standalone) | 8.2.3 |

54
apps/moltbot/.env.example Normal file
View File

@@ -0,0 +1,54 @@
# MoltBot Environment Configuration
# Copy this file to .env and configure the values
# Timezone (default: UTC)
TZ=UTC
# Global container registry prefix (optional)
# Examples: docker.io/, ghcr.io/, your-registry.com/
GLOBAL_REGISTRY=
# MoltBot Version
# Use 'main' for latest, or specific version tag like 'v2026.1.27'
MOLTBOT_VERSION=main
# === Gateway Configuration ===
# Gateway access token (REQUIRED - generate a secure random token)
# Example: openssl rand -hex 32
MOLTBOT_GATEWAY_TOKEN=your-secure-token-here
# Gateway bind address
# Options: loopback (127.0.0.1), lan (0.0.0.0 for LAN access)
MOLTBOT_GATEWAY_BIND=lan
# Gateway internal port (default: 18789)
MOLTBOT_GATEWAY_PORT=18789
# Gateway host port override (default: 18789)
MOLTBOT_GATEWAY_PORT_OVERRIDE=18789
# Bridge port override (default: 18790)
MOLTBOT_BRIDGE_PORT_OVERRIDE=18790
# === Model API Keys (Optional - if not using OAuth) ===
# Anthropic Claude API Key
ANTHROPIC_API_KEY=
# OpenAI API Key
OPENAI_API_KEY=
# Claude AI Session Keys (for web session auth)
CLAUDE_AI_SESSION_KEY=
CLAUDE_WEB_SESSION_KEY=
CLAUDE_WEB_COOKIE=
# === Resource Limits ===
# Gateway service resource limits
MOLTBOT_CPU_LIMIT=2.0
MOLTBOT_MEMORY_LIMIT=2G
MOLTBOT_CPU_RESERVATION=1.0
MOLTBOT_MEMORY_RESERVATION=1G
# CLI service resource limits
MOLTBOT_CLI_CPU_LIMIT=1.0
MOLTBOT_CLI_MEMORY_LIMIT=512M

214
apps/moltbot/README.md Normal file
View File

@@ -0,0 +1,214 @@
# MoltBot
MoltBot is a personal AI assistant that runs on your own devices. It integrates with multiple messaging platforms (WhatsApp, Telegram, Slack, Discord, Google Chat, Signal, iMessage, Microsoft Teams, WebChat) and provides AI-powered assistance across all your channels.
## Features
- **Multi-channel Support**: WhatsApp, Telegram, Slack, Discord, Google Chat, Signal, iMessage, BlueBubbles, Microsoft Teams, Matrix, Zalo, WebChat
- **Local-first Gateway**: Single control plane for sessions, channels, tools, and events
- **Multi-agent Routing**: Route inbound channels to isolated agents with per-agent sessions
- **Voice Wake + Talk Mode**: Always-on speech for macOS/iOS/Android with ElevenLabs
- **Live Canvas**: Agent-driven visual workspace with A2UI
- **First-class Tools**: Browser, canvas, nodes, cron, sessions, and channel-specific actions
- **Companion Apps**: macOS menu bar app + iOS/Android nodes
- **Skills Platform**: Bundled, managed, and workspace skills with install gating
## Quick Start
1. Copy the example environment file:
```bash
cp .env.example .env
```
2. Generate a secure gateway token:
```bash
# Using OpenSSL
openssl rand -hex 32
# Or using Python
python3 -c "import secrets; print(secrets.token_hex(32))"
```
3. Edit `.env` and set at least:
- `MOLTBOT_GATEWAY_TOKEN` - Your generated token
- `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` - If using API key auth
4. Start the gateway:
```bash
docker compose up -d
```
5. Access the Control UI:
- Open <http://localhost:18789> in your browser
- Enter your gateway token when prompted
## Configuration
### Gateway Access
The gateway can be accessed in two ways:
- **Loopback** (`MOLTBOT_GATEWAY_BIND=loopback`): Only accessible from the host machine (127.0.0.1)
- **LAN** (`MOLTBOT_GATEWAY_BIND=lan`): Accessible from your local network (0.0.0.0)
For production deployments, consider:
- Using Tailscale Serve/Funnel for secure remote access
- Setting up SSH tunnels
- Implementing reverse proxy with authentication
### Model Configuration
MoltBot supports multiple AI model providers:
- **Anthropic Claude** (Recommended): Claude Pro/Max with OAuth or API key
- **OpenAI**: ChatGPT/Codex with OAuth or API key
- **Custom Providers**: Configure via the Control UI or config file
Set API keys in `.env` or use OAuth authentication through the onboarding wizard.
### Channel Integration
To connect messaging platforms:
1. **WhatsApp**: Use the CLI to link device
```bash
docker compose run --rm moltbot-cli channels login
```
2. **Telegram**: Set `TELEGRAM_BOT_TOKEN` in config
3. **Discord**: Set `DISCORD_BOT_TOKEN` in config
4. **Slack**: Set `SLACK_BOT_TOKEN` and `SLACK_APP_TOKEN` in config
See the [official documentation](https://docs.molt.bot/channels) for detailed setup instructions.
## Using the CLI
The CLI service is available via the `cli` profile:
```bash
# Run onboarding wizard
docker compose run --rm --service-ports moltbot-cli onboard
# List providers
docker compose run --rm moltbot-cli providers list
# Send a message
docker compose run --rm moltbot-cli message send --to +1234567890 --message "Hello"
# Check health
docker compose run --rm moltbot-cli health --port 18789
```
## Security Considerations
1. **Gateway Token**: Keep your gateway token secure. This is the authentication method for the Control UI and WebSocket connections.
2. **DM Access**: By default, MoltBot uses pairing mode for direct messages from unknown senders. They receive a pairing code that you must approve.
3. **Network Exposure**: If exposing the gateway beyond localhost, use proper authentication and encryption:
- Set up Tailscale for secure remote access
- Use SSH tunnels
- Implement reverse proxy with HTTPS and authentication
4. **API Keys**: Never commit API keys to version control. Use `.env` file or secrets management.
5. **Sandbox Mode**: For group/channel safety, enable sandbox mode to run non-main sessions in Docker containers.
## Advanced Configuration
### Resource Limits
Adjust CPU and memory limits in `.env`:
```env
MOLTBOT_CPU_LIMIT=2.0
MOLTBOT_MEMORY_LIMIT=2G
MOLTBOT_CPU_RESERVATION=1.0
MOLTBOT_MEMORY_RESERVATION=1G
```
### Persistent Data
Data is stored in two Docker volumes:
- `moltbot_config`: Configuration files and credentials (~/.clawdbot)
- `moltbot_workspace`: Agent workspace and skills (~/clawd)
To backup your data:
```bash
docker run --rm -v moltbot_config:/data -v $(pwd):/backup alpine tar czf /backup/moltbot-config-backup.tar.gz /data
docker run --rm -v moltbot_workspace:/data -v $(pwd):/backup alpine tar czf /backup/moltbot-workspace-backup.tar.gz /data
```
### Custom Configuration File
Create a custom config file at `~/.clawdbot/moltbot.json` (inside the container):
```json
{
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-opus-4-5",
"fallbacks": ["anthropic/claude-sonnet-4-5", "openai/gpt-4o"]
}
}
}
}
```
## Troubleshooting
### Gateway Won't Start
1. Check logs: `docker compose logs moltbot-gateway`
2. Verify gateway token is set in `.env`
3. Ensure port 18789 is not already in use
### Can't Access Control UI
1. Verify gateway bind setting matches your access method
2. Check firewall rules if accessing from another machine
3. Ensure container is healthy: `docker compose ps`
### Model API Errors
1. Verify API keys are correctly set in `.env`
2. Check API key validity and quota
3. Review logs for specific error messages
### Run Doctor Command
The doctor command helps diagnose common issues:
```bash
docker compose run --rm moltbot-cli doctor
```
## Documentation
- [Official Website](https://molt.bot)
- [Full Documentation](https://docs.molt.bot)
- [Getting Started Guide](https://docs.molt.bot/start/getting-started)
- [Configuration Reference](https://docs.molt.bot/gateway/configuration)
- [Security Guide](https://docs.molt.bot/gateway/security)
- [Docker Installation](https://docs.molt.bot/install/docker)
- [GitHub Repository](https://github.com/moltbot/moltbot)
## License
MoltBot is released under the MIT License. See the [LICENSE](https://github.com/moltbot/moltbot/blob/main/LICENSE) file for details.
## Community
- [Discord](https://discord.gg/clawd)
- [GitHub Discussions](https://github.com/moltbot/moltbot/discussions)
- [Issues](https://github.com/moltbot/moltbot/issues)

214
apps/moltbot/README.zh.md Normal file
View File

@@ -0,0 +1,214 @@
# MoltBot
MoltBot 是一个运行在你自己设备上的个人 AI 助手。它集成了多个消息平台WhatsApp、Telegram、Slack、Discord、Google Chat、Signal、iMessage、Microsoft Teams、WebChat并在所有频道上提供 AI 驱动的帮助。
## 功能特性
- **多频道支持**WhatsApp、Telegram、Slack、Discord、Google Chat、Signal、iMessage、BlueBubbles、Microsoft Teams、Matrix、Zalo、WebChat
- **本地优先网关**:会话、频道、工具和事件的统一控制平面
- **多代理路由**:将入站频道路由到具有独立会话的隔离代理
- **语音唤醒 + 对话模式**macOS/iOS/Android 上的永久在线语音支持(使用 ElevenLabs
- **实时画布**:由代理驱动的可视化工作空间,支持 A2UI
- **一流工具**:浏览器、画布、节点、定时任务、会话和特定频道的操作
- **配套应用**macOS 菜单栏应用 + iOS/Android 节点
- **技能平台**:内置、托管和工作区技能,支持安装门控
## 快速开始
1. 复制示例环境文件:
```bash
cp .env.example .env
```
2. 生成安全的网关令牌:
```bash
# 使用 OpenSSL
openssl rand -hex 32
# 或使用 Python
python3 -c "import secrets; print(secrets.token_hex(32))"
```
3. 编辑 `.env` 文件,至少设置:
- `MOLTBOT_GATEWAY_TOKEN` - 你生成的令牌
- `ANTHROPIC_API_KEY` 或 `OPENAI_API_KEY` - 如果使用 API 密钥认证
4. 启动网关:
```bash
docker compose up -d
```
5. 访问控制界面:
- 在浏览器中打开 <http://localhost:18789>
- 在提示时输入你的网关令牌
## 配置
### 网关访问
网关可以通过两种方式访问:
- **回环地址**`MOLTBOT_GATEWAY_BIND=loopback`仅从主机访问127.0.0.1
- **局域网**`MOLTBOT_GATEWAY_BIND=lan`从本地网络访问0.0.0.0
对于生产部署,建议:
- 使用 Tailscale Serve/Funnel 进行安全的远程访问
- 设置 SSH 隧道
- 实现带认证的反向代理
### 模型配置
MoltBot 支持多个 AI 模型提供商:
- **Anthropic Claude**推荐Claude Pro/Max支持 OAuth 或 API 密钥
- **OpenAI**ChatGPT/Codex支持 OAuth 或 API 密钥
- **自定义提供商**:通过控制界面或配置文件进行配置
在 `.env` 文件中设置 API 密钥,或通过入门向导使用 OAuth 认证。
### 频道集成
连接消息平台:
1. **WhatsApp**:使用 CLI 链接设备
```bash
docker compose run --rm moltbot-cli channels login
```
2. **Telegram**:在配置中设置 `TELEGRAM_BOT_TOKEN`
3. **Discord**:在配置中设置 `DISCORD_BOT_TOKEN`
4. **Slack**:在配置中设置 `SLACK_BOT_TOKEN` 和 `SLACK_APP_TOKEN`
详细设置说明请参阅[官方文档](https://docs.molt.bot/channels)。
## 使用命令行界面
CLI 服务可通过 `cli` 配置文件使用:
```bash
# 运行入门向导
docker compose run --rm --service-ports moltbot-cli onboard
# 列出提供商
docker compose run --rm moltbot-cli providers list
# 发送消息
docker compose run --rm moltbot-cli message send --to +1234567890 --message "你好"
# 检查健康状态
docker compose run --rm moltbot-cli health --port 18789
```
## 安全注意事项
1. **网关令牌**:保护好你的网关令牌。这是控制界面和 WebSocket 连接的认证方式。
2. **私信访问**默认情况下MoltBot 对来自未知发送者的私信使用配对模式。他们会收到一个配对码,你必须批准。
3. **网络暴露**:如果在 localhost 之外暴露网关,请使用适当的认证和加密:
- 设置 Tailscale 进行安全的远程访问
- 使用 SSH 隧道
- 实现带 HTTPS 和认证的反向代理
4. **API 密钥**:永远不要将 API 密钥提交到版本控制。使用 `.env` 文件或密钥管理。
5. **沙箱模式**:为了群组/频道安全,启用沙箱模式以在 Docker 容器中运行非主会话。
## 高级配置
### 资源限制
在 `.env` 文件中调整 CPU 和内存限制:
```env
MOLTBOT_CPU_LIMIT=2.0
MOLTBOT_MEMORY_LIMIT=2G
MOLTBOT_CPU_RESERVATION=1.0
MOLTBOT_MEMORY_RESERVATION=1G
```
### 持久化数据
数据存储在两个 Docker 卷中:
- `moltbot_config`:配置文件和凭据(~/.clawdbot
- `moltbot_workspace`:代理工作区和技能(~/clawd
备份数据:
```bash
docker run --rm -v moltbot_config:/data -v $(pwd):/backup alpine tar czf /backup/moltbot-config-backup.tar.gz /data
docker run --rm -v moltbot_workspace:/data -v $(pwd):/backup alpine tar czf /backup/moltbot-workspace-backup.tar.gz /data
```
### 自定义配置文件
在 `~/.clawdbot/moltbot.json`(容器内)创建自定义配置文件:
```json
{
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-opus-4-5",
"fallbacks": ["anthropic/claude-sonnet-4-5", "openai/gpt-4o"]
}
}
}
}
```
## 故障排除
### 网关无法启动
1. 检查日志:`docker compose logs moltbot-gateway`
2. 验证网关令牌是否在 `.env` 中设置
3. 确保端口 18789 未被占用
### 无法访问控制界面
1. 验证网关绑定设置是否与你的访问方式匹配
2. 如果从另一台机器访问,检查防火墙规则
3. 确保容器健康:`docker compose ps`
### 模型 API 错误
1. 验证 API 密钥是否在 `.env` 中正确设置
2. 检查 API 密钥有效性和配额
3. 查看日志中的具体错误消息
### 运行诊断命令
诊断命令可帮助诊断常见问题:
```bash
docker compose run --rm moltbot-cli doctor
```
## 文档
- [官方网站](https://molt.bot)
- [完整文档](https://docs.molt.bot)
- [入门指南](https://docs.molt.bot/start/getting-started)
- [配置参考](https://docs.molt.bot/gateway/configuration)
- [安全指南](https://docs.molt.bot/gateway/security)
- [Docker 安装](https://docs.molt.bot/install/docker)
- [GitHub 仓库](https://github.com/moltbot/moltbot)
## 许可证
MoltBot 使用 MIT 许可证发布。详情请参阅 [LICENSE](https://github.com/moltbot/moltbot/blob/main/LICENSE) 文件。
## 社区
- [Discord](https://discord.gg/clawd)
- [GitHub 讨论](https://github.com/moltbot/moltbot/discussions)
- [问题跟踪](https://github.com/moltbot/moltbot/issues)

View File

@@ -0,0 +1,88 @@
# MoltBot - Personal AI Assistant Docker Compose Configuration
# Official Repository: https://github.com/moltbot/moltbot
# Documentation: https://docs.molt.bot
x-defaults: &defaults
restart: unless-stopped
logging:
driver: json-file
options:
max-size: 100m
max-file: "3"
services:
moltbot-gateway:
<<: *defaults
image: ${GLOBAL_REGISTRY:-ghcr.io}/moltbot/moltbot:${MOLTBOT_VERSION:-main}
environment:
- TZ=${TZ:-UTC}
- HOME=/home/node
- NODE_ENV=production
- TERM=xterm-256color
# Gateway configuration
- CLAWDBOT_GATEWAY_TOKEN=${MOLTBOT_GATEWAY_TOKEN}
- CLAWDBOT_GATEWAY_BIND=${MOLTBOT_GATEWAY_BIND:-lan}
- CLAWDBOT_GATEWAY_PORT=${MOLTBOT_GATEWAY_PORT:-18789}
# Optional: Model API keys (if not using OAuth)
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
- OPENAI_API_KEY=${OPENAI_API_KEY:-}
- CLAUDE_AI_SESSION_KEY=${CLAUDE_AI_SESSION_KEY:-}
- CLAUDE_WEB_SESSION_KEY=${CLAUDE_WEB_SESSION_KEY:-}
- CLAUDE_WEB_COOKIE=${CLAUDE_WEB_COOKIE:-}
volumes:
- moltbot_config:/home/node/.clawdbot
- moltbot_workspace:/home/node/clawd
ports:
- "${MOLTBOT_GATEWAY_PORT_OVERRIDE:-18789}:18789"
- "${MOLTBOT_BRIDGE_PORT_OVERRIDE:-18790}:18790"
command:
- node
- dist/index.js
- gateway
- --bind
- "${MOLTBOT_GATEWAY_BIND:-lan}"
- --port
- "18789"
healthcheck:
test: ["CMD", "node", "dist/index.js", "health", "--port", "18789"]
interval: 30s
timeout: 10s
retries: 3
start_period: 60s
deploy:
resources:
limits:
cpus: ${MOLTBOT_CPU_LIMIT:-2.0}
memory: ${MOLTBOT_MEMORY_LIMIT:-2G}
reservations:
cpus: ${MOLTBOT_CPU_RESERVATION:-1.0}
memory: ${MOLTBOT_MEMORY_RESERVATION:-1G}
moltbot-cli:
<<: *defaults
image: ${GLOBAL_REGISTRY:-ghcr.io}/moltbot/moltbot:${MOLTBOT_VERSION:-main}
environment:
- TZ=${TZ:-UTC}
- HOME=/home/node
- TERM=xterm-256color
- BROWSER=echo
- CLAUDE_AI_SESSION_KEY=${CLAUDE_AI_SESSION_KEY:-}
- CLAUDE_WEB_SESSION_KEY=${CLAUDE_WEB_SESSION_KEY:-}
- CLAUDE_WEB_COOKIE=${CLAUDE_WEB_COOKIE:-}
volumes:
- moltbot_config:/home/node/.clawdbot
- moltbot_workspace:/home/node/clawd
stdin_open: true
tty: true
entrypoint: ["node", "dist/index.js"]
profiles:
- cli
deploy:
resources:
limits:
cpus: ${MOLTBOT_CLI_CPU_LIMIT:-1.0}
memory: ${MOLTBOT_CLI_MEMORY_LIMIT:-512M}
volumes:
moltbot_config:
moltbot_workspace:

View File

@@ -23,7 +23,7 @@ services:
- DEBIAN_VERSION=${DEBIAN_VERSION:-13.2-slim}
- MICROSANDBOX_VERSION=${MICROSANDBOX_VERSION:-}
- MICROSANDBOX_AUTO_PULL_IMAGES=${MICROSANDBOX_AUTO_PULL_IMAGES:-true}
image: ${GLOBAL_REGISTRY:-ghcr.io/zerocore-ai/}microsandbox:${MICROSANDBOX_VERSION:-latest}
image: ${GLOBAL_REGISTRY:-ghcr.io}/zerocore-ai/microsandbox:${MICROSANDBOX_VERSION:-latest}
ports:
- "${MICROSANDBOX_PORT_OVERRIDE:-5555}:${MICROSANDBOX_PORT:-5555}"
# Privileged mode and relaxed security profiles are required for KVM access

View File

@@ -76,7 +76,7 @@ services:
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:8000/health",
"http://localhost:8000/docs",
]
interval: 30s
timeout: 10s

View File

@@ -24,7 +24,15 @@ services:
cpus: ${BYTEBOT_DESKTOP_CPU_RESERVATION:-1.0}
memory: ${BYTEBOT_DESKTOP_MEMORY_RESERVATION:-2G}
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9990/"]
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:9990/",
]
interval: 30s
timeout: 10s
retries: 3
@@ -56,7 +64,15 @@ services:
cpus: ${BYTEBOT_AGENT_CPU_RESERVATION:-0.5}
memory: ${BYTEBOT_AGENT_MEMORY_RESERVATION:-512M}
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9991/health"]
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:9991/health",
]
interval: 30s
timeout: 10s
retries: 3
@@ -83,7 +99,15 @@ services:
cpus: ${BYTEBOT_UI_CPU_RESERVATION:-0.25}
memory: ${BYTEBOT_UI_MEMORY_RESERVATION:-256M}
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:9992/"]
test:
[
"CMD",
"wget",
"--no-verbose",
"--tries=1",
"--spider",
"http://localhost:9992/",
]
interval: 30s
timeout: 10s
retries: 3