Clawdbot是一个开源的本地AI助手,支持通过消息应用(Telegram、WhatsApp、Discord等)或Web UI与AI模型交互。 核心特点:
Clawdbot要求Node.js 22+,使用nvm管理版本: # 安装Node.js 22方式一:npm安装(推荐) npm install -g clawdbot方式二:一键安装脚本 curl -fsSL https://clawd.bot/install.sh | bash方式三:从源码安装 # 克隆仓库安装完成后运行配置向导: clawdbot onboard配置向导流程: 认证方式对比:
在另一个终端运行: claude setup-token复制生成的token,粘贴到配置向导中:
步骤4:配置消息平台(可选)获取Telegram Bot Token:
去Telegram给你的Bot发消息,会收到配对码: 在终端批准配对: clawdbot pairing approve telegram ABC12345从Claude Code API中转服务获取:
推荐服务:
cp ~/.clawdbot/clawdbot.json ~/.clawdbot/clawdbot.json.baknano ~/.clawdbot/clawdbot.json在配置文件中添加 {
"models": {
"providers": {
"anthropic": {
"baseUrl": "https://code.claude-opus.top/api",
"apiKey": "cr_你的API密钥",
"api": "anthropic-messages",
"models": []
}
}
}
}关键配置说明:
完整配置示例: {
"meta": {
"lastTouchedVersion": "2026.1.25",
"lastTouchedAt": "2026-01-27T01:05:21.233Z"
},
"models": {
"providers": {
"anthropic": {
"baseUrl": "https://code.claude-opus.top/api",
"apiKey": "cr_你的API密钥",
"api": "anthropic-messages",
"models": []
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-sonnet-4-5"
},
"workspace": "/Users/你的用户名/clawd",
"maxConcurrent": 4
}
},
"gateway": {
"port": 18789,
"mode": "local",
"bind": "loopback",
"auth": {
"mode": "token",
"token": "你的gateway_token"
}
},
"channels": {
"telegram": {
"enabled": false
}
}
}# 使用jq验证JSON格式
cat ~/.clawdbot/clawdbot.json | jq '.models'
# 应该输出:
# {
# "providers": {
# "anthropic": {
# "baseUrl": "https://code.claude-opus.top/api",
# "apiKey": "cr_...",
# "api": "anthropic-messages",
# "models": []
# }
# }
# }clawdbot gateway restart# 检查Gateway状态
clawdbot channels status
# 应该显示:
# Gateway reachable.clawdbot channels status正常输出: 打开浏览器访问: Web UI功能:
在Web UI的Chat界面:
预期结果:
如果遇到问题,检查日志: # Gateway主日志
tail -f ~/.clawdbot/logs/gateway.log
# 错误日志
tail -f ~/.clawdbot/logs/gateway.err.log
# 详细调试日志
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log错误做法: # 在LaunchAgent中设置环境变量(无效!)
<key>ANTHROPIC_BASE_URL</key>
<string>https://code.claude-opus.top/api</string>问题原因: Clawdbot不支持通过 ✅ 正确做法: 在 {
"models": {
"providers": {
"anthropic": {
"baseUrl": "https://code.claude-opus.top/api",
"apiKey": "cr_你的密钥",
"api": "anthropic-messages",
"models": []
}
}
}
}错误配置: {
"models": {
"providers": {
"anthropic": {
"baseUrl": "https://code.claude-opus.top/api",
"apiKey": "cr_xxx",
"api": "anthropic-messages"
// 缺少models字段!
}
}
}
}错误信息: ✅ 正确做法: 必须包含 {
"models": {
"providers": {
"anthropic": {
"baseUrl": "https://code.claude-opus.top/api",
"apiKey": "cr_xxx",
"api": "anthropic-messages",
"models": [] // 必须有这一行!
}
}
}
}症状:
✅ 解决方案: 临时禁用Telegram: clawdbot config set channels.telegram.enabled false
clawdbot gateway restart错误信息: ✅ 解决方案: nvm install 22
nvm use 22
nvm alias default 22
node --version # 应显示 v22.x.x问题: 修改配置后没有重启Gateway,配置不生效。 ✅ 解决方案: # 每次修改配置后都要重启
clawdbot gateway restart
# 验证配置生效
clawdbot channels status症状: Web UI显示"disconnected (1006): no reason" 解决方案: # 1. 检查Gateway是否运行
ps aux | grep clawdbot-gateway
# 2. 检查端口占用
lsof -i :18789
# 3. 检查配置文件是否有效
cat ~/.clawdbot/clawdbot.json | jq '.'
# 4. 重启Gateway
clawdbot gateway restart
# 5. 查看错误日志
tail -50 ~/.clawdbot/logs/gateway.err.log症状: 日志显示"TypeError: fetch failed" 解决方案: # 1. 测试API端点可访问性
curl -s https://code.claude-opus.top/api/v1/messages \
-H "x-api-key: 你的API密钥" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-sonnet-4-5","max_tokens":100,"messages":[{"role":"user","content":"hi"}]}'
# 2. 验证配置文件
cat ~/.clawdbot/clawdbot.json | jq '.models.providers.anthropic'
# 3. 确保包含所有必需字段
# - baseUrl
# - apiKey
# - api: "anthropic-messages"
# - models: []
# 4. 重启Gateway
clawdbot gateway restart症状:
解决方案:
# Gateway主日志
tail -f ~/.clawdbot/logs/gateway.log
# 错误日志
tail -f ~/.clawdbot/logs/gateway.err.log
# 详细调试日志(JSON格式)
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log
# 过滤错误信息
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log | grep -i "error\|fail"# 1. 备份当前配置
cp -r ~/.clawdbot ~/.clawdbot.backup
# 2. 停止Gateway
clawdbot gateway stop
# 3. 删除配置
rm -rf ~/.clawdbot
# 4. 重新运行配置向导
clawdbot onboard# 查看状态
clawdbot channels status
# 深度检查
clawdbot channels status --deep
# 重启Gateway
clawdbot gateway restart
# 停止Gateway
launchctl unload ~/Library/LaunchAgents/com.clawdbot.gateway.plist
# 启动Gateway
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.clawdbot.gateway.plist# 交互式配置
clawdbot configure
# 配置特定部分
clawdbot configure --section gateway
clawdbot configure --section channels
clawdbot configure --section model
# 设置配置项
clawdbot config set gateway.mode local
clawdbot config set channels.telegram.enabled false
# 查看配置
cat ~/.clawdbot/clawdbot.json# Gateway主日志
tail -f ~/.clawdbot/logs/gateway.log
# 错误日志
tail -f ~/.clawdbot/logs/gateway.err.log
# 详细日志(JSON格式)
tail -f /tmp/clawdbot/clawdbot-$(date +%Y-%m-%d).log# 运行诊断
clawdbot doctor
# 自动修复问题
clawdbot doctor --fix
# 安全审计
clawdbot security audit --deep# 打开Web UI(浏览器)
clawdbot dashboard
# 获取带token的URL(不打开浏览器)
clawdbot dashboard --no-open# 启动TUI
clawdbot tui
# TUI快捷键
# Ctrl+C: 退出
# Enter: 发送消息
# Shift+Enter: 换行# 从源码更新
cd /path/to/clawdbot
git pull --rebase
pnpm install
pnpm build
clawdbot gateway restart
# 从npm更新(全局安装)
npm install -g clawdbot@latest
# 备份配置和会话
tar -czf clawdbot-backup-$(date +%Y%m%d).tar.gz ~/.clawdbot/
通过本教程,你应该已经: ✅ 成功安装Clawdbot
# 查看状态
clawdbot channels status
# 重启Gateway
clawdbot gateway restart
# 查看日志
tail -f ~/.clawdbot/logs/gateway.log
# 打开Web UI
clawdbot dashboard
# 配置文件位置
~/.clawdbot/clawdbot.json祝使用愉快!🦞 | |||||||||||||||||||||||||||||||||||||||
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|