一、为什么要迁移?

OpenClaw(小龙虾)用了一段时间,社区出了新名词”养马”——指的是 Hermes Agent。核心差异:

表格

维度OpenClawHermes Agent
技能来源人工编写/安装自动从任务经验中提取
记忆机制会话级,关掉即失三层持久记忆,越用越聪明
进化方式被动,需手动维护主动闭环:执行→评估→提取→精炼
Token 消耗长任务易烧到 10万+同样场景维持 3-4 万
运行模式本地跟随7×24 云端独立运行

一句话:OpenClaw 是”你教 AI 怎么做”,Hermes 是”AI 自己学会怎么做”


二、迁移过程全记录

2.1 安装阶段:国内网络是最大敌人

坑 1:官方源 PyPI 下载失败

bash

复制

# 官方脚本直接跑,PyPI 依赖全挂
curl -fsSL https://raw.githubusercontent.com/.../install.sh | bash
# 报错:Failed to fetch https://pypi.org/simple/uvicorn/

解决:用国内镜像源重装

bash

复制

rm -rf ~/.hermes
curl -fsSL https://res1.hermesagent.org.cn/install.sh | bash
source ~/.zshrc

坑 2:GitHub 克隆断流

官方源安装时 git clone 频繁 early EOF,即使加了 ghfast.top 镜像,后续 uv pip install 还是走 PyPI 直连失败。

结论:国内环境直接用国内镜像版,不要折腾官方源。


2.2 配置阶段:向导显示成功,实际没写进去

坑 3:飞书配置”假成功”

安装向导显示:

plain

复制

✓ 🪽 Feishu / Lark configured!
    App ID: cli_a96281d93bfbdbc9
    Domain: feishu

实际检查:

bash

复制

hermes config show | grep -A 15 messaging
# 输出为空!什么都没有!

解决:手动覆盖写 config.yaml

bash

复制

cat > ~/.hermes/config.yaml << 'EOF'
model:
  default: kimi-k2.6
  provider: kimi-coding
  base_url: https://api.kimi.com/coding
providers: {}
messaging:
  feishu:
    app_id: "cli_a96281d93bfbdbc9"
    app_secret: "你的AppSecret"
    domain: "feishu"
    connection_mode: "websocket"
    allow_all_users: true
    approve_all_users: false
fallback_providers: []
credential_pool_strategies: {}
toolsets:
- hermes-cli
agent:
  max_turns: 90
  gateway_timeout: 1800
  restart_drain_timeout: 60
  service_tier: ''
  tool_use_enforcement: auto
  gateway_timeout_warning: 900
  gateway_notify_interval: 600
  verbose: false
  reasoning_effort: medium
EOF

坑 4:OpenClaw 迁移数据没进标准位置

迁移预览显示 skills 被跳过:No skills with SKILL.md found。说明之前 OpenClaw 里记录的不是标准 Skill 格式,迁移后需要重新积累。


2.3 启动阶段:循环重启地狱

坑 5:lark-oapi 依赖缺失

Gateway 启动后秒退,日志循环显示:

plain

复制

WARNING gateway.run: Feishu: lark-oapi not installed or FEISHU_APP_ID/SECRET not set
ERROR gateway.run: Gateway failed to connect any configured messaging platform

解决:手动安装飞书 SDK

bash

复制

cd ~/.hermes/hermes-agent
source venv/bin/activate
pip install lark-oapi

坑 6:launchd 环境变量不生效

即使 plist 里加了 PYTHONPATH,launchd 启动的进程还是读不到 venv 里的包。这是 macOS launchd 的已知限制。

解决:放弃 launchd,改用 nohup 前台转后台

bash

复制

# 停掉 launchd
launchctl stop ai.hermes.gateway
launchctl unload ~/Library/LaunchAgents/ai.hermes.gateway.plist

# 进入 venv 直接前台跑
cd ~/.hermes/hermes-agent
source venv/bin/activate
python -m hermes_cli.main gateway run --replace

# 确认能收到飞书消息后,Ctrl+C 停掉,改用 nohup 后台
nohup python -m hermes_cli.main gateway run --replace > /dev/null 2>&1 &

2.4 飞书应用配置:必须检查的三项

即使 Hermes 端配置正确,飞书应用本身也要满足:

表格

检查项必须状态
版本管理与发布已发布,不是”未发布”
事件与回调订阅 im.message.receive_v1,方式选“使用长连接接收事件”
权限管理申请 im:message(单聊)和 im:message.group(群聊)

三、最终可用架构

plain

复制

飞书用户消息
    ↓
飞书开放平台 (WebSocket 长连接)
    ↓
Hermes Gateway (nohup 后台进程)
    ↓
Kimi CodePlan API (kimi-k2.6)
    ↓
回复返回飞书

四、日常管理指令大全

4.1 进程管理

表格

操作命令
查看 Gateway 进程`ps auxgrep hermes`
停止 Gatewaypkill -f "hermes_cli.main gateway"
前台启动(调试用)cd ~/.hermes/hermes-agent && source venv/bin/activate && python -m hermes_cli.main gateway run --replace
后台启动(生产用)nohup python -m hermes_cli.main gateway run --replace > /dev/null 2>&1 &

4.2 日志查看

表格

日志类型路径
标准输出~/.hermes/logs/gateway.log
错误日志~/.hermes/logs/gateway.error.log
实时跟踪tail -f ~/.hermes/logs/gateway.error.log

4.3 配置管理

表格

操作命令
查看配置hermes config show
编辑配置hermes config edit(或直接用 nano/vim 改 ~/.hermes/config.yaml
设置单项hermes config set KEY VALUE

4.4 模型管理

表格

操作命令
重新配置模型hermes setup
查看已配模型hermes models list
测试模型连通hermes llm test

4.5 飞书配对(如果选了 DM pairing approval)

表格

操作命令
查看配对码飞书给机器人发任意消息
授权用户hermes pairing approve feishu <配对码>
设主会话飞书发 /sethome

4.6 Skill 和记忆

表格

操作命令
查看技能hermes skills list
查看记忆hermes memory list
手动导入 OpenClawhermes claw migrate --dry-run(预览)→ hermes claw migrate(执行)

4.7 健康检查

表格

操作命令
全面诊断hermes doctor
Gateway 状态hermes gateway status
查看版本hermes --version

五、关键文件路径速查

表格

文件/目录路径
主配置~/.hermes/config.yaml
环境变量~/.hermes/.env
日志~/.hermes/logs/
记忆~/.hermes/memories/
技能~/.hermes/skills/
源码~/.hermes/hermes-agent/
venv~/.hermes/hermes-agent/venv/
launchd plist~/Library/LaunchAgents/ai.hermes.gateway.plist

六、一句话总结

国内环境装 Hermes,用国内镜像版;配置别信向导,手动写 config.yaml;飞书依赖自己装 lark-oapi;launchd 有坑,用 nohup 后台跑;飞书应用必须已发布+长连接+权限到位。


附录:完整安装脚本(一键可用)

bash

复制

#!/bin/bash
# Hermes + 飞书 + Kimi CodePlan 国内环境一键安装

# 1. 清理旧版本
rm -rf ~/.hermes
pkill -f hermes

# 2. 国内镜像安装
curl -fsSL https://res1.hermesagent.org.cn/install.sh | bash
source ~/.zshrc

# 3. 手动写配置(替换你的 App ID 和 Secret)
cat > ~/.hermes/config.yaml << 'EOF'
model:
  default: kimi-k2.6
  provider: kimi-coding
  base_url: https://api.kimi.com/coding
providers: {}
messaging:
  feishu:
    app_id: "cli_你的AppID"
    app_secret: "你的AppSecret"
    domain: "feishu"
    connection_mode: "websocket"
    allow_all_users: true
    approve_all_users: false
fallback_providers: []
credential_pool_strategies: {}
toolsets:
- hermes-cli
agent:
  max_turns: 90
  gateway_timeout: 1800
  restart_drain_timeout: 60
  service_tier: ''
  tool_use_enforcement: auto
  gateway_timeout_warning: 900
  gateway_notify_interval: 600
  verbose: false
  reasoning_effort: medium
EOF

# 4. 安装飞书依赖
cd ~/.hermes/hermes-agent
source venv/bin/activate
pip install lark-oapi

# 5. 卸载 launchd(有坑)
launchctl unload ~/Library/LaunchAgents/ai.hermes.gateway.plist 2>/dev/null

# 6. nohup 后台启动
nohup python -m hermes_cli.main gateway run --replace > /dev/null 2>&1 &

echo "Hermes Gateway 已启动,飞书发消息测试"
echo "查看日志: tail -f ~/.hermes/logs/gateway.error.log"

踩坑不易,希望这篇记录能帮到你。

分类: 开发

粤ICP备2026007784号