Hermes Agent - 由 Nous Research 开发的自我改进型 AI 智能体
版本: 最新稳定版
适用系统: macOS (支持 Apple Silicon 和 Intel)
文档更新日期: 2026-04-13
bash/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
安装完成后,根据提示将 Homebrew 添加到 PATH:
bash# Apple Silicon (M1/M2/M3)
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"
# Intel Mac
echo 'eval "$(/usr/local/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
验证安装:
bashbrew --version
bash# 使用 Homebrew 安装 Python
brew install python@3.11
# 验证安装
python3.11 --version
# 设置默认 Python 版本(可选)
brew link python@3.11
bash# 使用官方安装脚本
curl -LsSf https://astral.sh/uv/install.sh | sh
# 重新加载 shell 配置
source ~/.zshrc
# 验证安装
uv --version
bash# Git(用于版本管理和更新)
brew install git
# wget(下载工具)
brew install wget
# tree(目录结构查看)
brew install tree
bash# 下载并执行安装脚本
curl -fsSL https://raw.githubusercontent.com/NousResearch/hermes-agent/main/scripts/install.sh | bash
安装脚本会自动:
bash# 1. 克隆仓库
git clone https://github.com/NousResearch/hermes-agent.git
cd hermes-agent
# 2. 创建虚拟环境
uv venv venv --python 3.11
source venv/bin/activate
# 3. 安装所有功能(包含语音等额外依赖)
uv pip install -e ".[all]"
# 4. 验证安装
python -m pytest tests/ -q
bash# 重新加载 shell 配置
source ~/.zshrc # 或 source ~/.bashrc
# 验证安装
hermes --version
# 运行诊断工具
hermes doctor
bashhermes setup
设置向导会引导你完成:
bash# 设置 OpenRouter API Key
hermes config set openrouter_api_key "your-api-key-here"
# 设置 OpenAI API Key
hermes config set openai_api_key "your-api-key-here"
# 设置 Anthropic API Key
hermes config set anthropic_api_key "your-api-key-here"
bash# 交互式选择模型
hermes model
# 或直接指定模型
hermes model openrouter:anthropic/claude-3.5-sonnet
Hermes 的配置文件位于:
bash~/.hermes/config.yaml # 主配置文件
~/.hermes/tools/ # 工具配置
~/.hermes/skills/ # 技能文件
~/.hermes/memories/ # 记忆文件
查看配置:
bashcat ~/.hermes/config.yaml
bash# 启动终端交互界面
hermes
在交互模式下,可以使用以下斜杠命令:
| 命令 | 功能 | 示例 |
|---|---|---|
/new 或 /reset | 开始新对话 | /new |
/model | 切换模型 | /model openrouter:gpt-4 |
/personality | 设置人格 | /personality assistant |
/retry | 重试最后一次响应 | /retry |
/undo | 撤销最后一次交互 | /undo |
/compress | 压缩上下文 | /compress |
/usage | 查看使用统计 | /usage |
/skills | 浏览可用技能 | /skills |
/tools | 查看启用的工具 | /tools |
/help | 查看帮助 | /help |
| 快捷键 | 功能 |
|---|---|
Ctrl+C | 中断当前任务 |
Ctrl+D | 退出 Hermes |
↑/↓ | 浏览命令历史 |
Tab | 自动补全命令 |
Ctrl+R | 搜索命令历史 |
bash# 查看所有命令
hermes --help
# 查看子命令帮助
hermes model --help
hermes tools --help
hermes config --help
Hermes 内置 40+ 工具,可以执行各种任务:
bash# 查看可用工具
hermes tools
# 启用/禁用特定工具
hermes tools enable shell
hermes tools disable web_search
支持多种终端后端:
bash# 本地执行(默认)
hermes config set terminal_backend local
# Docker 容器
hermes config set terminal_backend docker
# SSH 远程
hermes config set terminal_backend ssh
hermes config set ssh_host "user@remote-server"
# Daytona(无服务器)
hermes config set terminal_backend daytona
可以生成隔离的子代理进行并行工作:
# 在对话中使用 /spawn 帮我分析这个数据集并生成报告
项目上下文文件会影响每次对话:
bash# 创建项目上下文文件
echo "这是一个 Python 数据分析项目" > .hermes-context
# 上下文文件会自动加载到对话中
Hermes 可以同时作为多个消息平台的机器人:
bash# 启动网关设置向导
hermes gateway setup
# 启动网关
hermes gateway start
bash# 配置 Telegram
hermes gateway setup telegram
# 需要提供的信息:
# - Bot Token(从 @BotFather 获取)
# - 允许的用户 ID
获取 Telegram Bot Token:
@BotFather/newbot 命令bash# 配置 Discord
hermes gateway setup discord
# 需要提供的信息:
# - Bot Token
# - 允许的服务器 ID
# - 允许的频道 ID
获取 Discord Bot Token:
bash# Slack
hermes gateway setup slack
# WhatsApp
hermes gateway setup whatsapp
# Signal
hermes gateway setup signal
# Email
hermes gateway setup email
bash# 查看网关状态
hermes gateway status
# 停止网关
hermes gateway stop
# 重启网关
hermes gateway restart
技能是 Hermes 的核心特性之一:
bash# 查看已安装的技能
hermes skills
# 查看特定技能详情
hermes skills view <skill-name>
# 启用/禁用技能
hermes skills enable <skill-name>
hermes skills disable <skill-name>
# 删除技能
hermes skills delete <skill-name>
bash# 列出可用技能
/skills
# 使用特定技能
/<skill-name>
# 在对话中自动触发
# 当检测到相关任务时,技能会自动激活
访问 Skills Hub 浏览社区技能:
bash# 安装技能(假设命令)
hermes skills install <skill-url-or-id>
# 更新所有技能
hermes skills update
技能文件位于 ~/.hermes/skills/:
yaml# ~/.hermes/skills/my-skill.yaml
name: my-custom-skill
description: "描述这个技能的用途"
triggers:
- "触发关键词1"
- "触发关键词2"
instructions: |
这里是技能的详细指令
可以包含多行文本
tools:
- shell
- python
Hermes 内置 cron 调度器:
bash# 创建定时任务(自然语言)
hermes cron add "每天早上 9 点发送今日待办事项"
# 创建定时任务(cron 表达式)
hermes cron add "0 9 * * *" "发送每日报告"
# 查看所有定时任务
hermes cron list
bash# 暂停任务
hermes cron pause <task-id>
# 恢复任务
hermes cron resume <task-id>
# 删除任务
hermes cron delete <task-id>
# 立即执行任务
hermes cron run <task-id>
bash# 每日备份
hermes cron add "0 2 * * *" "备份重要文件到云存储"
# 每周报告
hermes cron add "0 17 * * 5" "生成本周工作总结报告"
# 每月审计
hermes cron add "0 10 1 * *" "执行系统安全检查"
# 每小时提醒
hermes cron add "0 * * * *" "提醒我喝水和休息"
bash# 运行完整诊断
hermes doctor
诊断工具会检查:
command not found: hermes解决方案:
bash# 重新加载 shell 配置
source ~/.zshrc
# 或检查 PATH
echo $PATH
# 如果 Hermes 不在 PATH 中,手动添加
echo 'export PATH="$HOME/.hermes/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
解决方案:
bash# 检查 API Key 是否正确配置
hermes config get openrouter_api_key
# 重新设置 API Key
hermes config set openrouter_api_key "your-api-key"
解决方案:
bash# 重新创建虚拟环境
cd ~/.hermes
rm -rf venv
uv venv venv --python 3.11
source venv/bin/activate
uv pip install -e ".[all]"
解决方案:
bash# 修复文件权限
chmod -R 755 ~/.hermes
chown -R $(whoami) ~/.hermes
bash# 查看 Hermes 日志
tail -f ~/.hermes/logs/hermes.log
# 查看网关日志
tail -f ~/.hermes/logs/gateway.log
bash# 备份当前配置
cp -r ~/.hermes ~/.hermes.backup
# 删除配置(谨慎操作)
rm -rf ~/.hermes
# 重新运行设置向导
hermes setup
bash# 更新到最新版本
hermes update
# 查看当前版本
hermes --version
bash# 如果使用 Git 安装
cd hermes-agent
git pull origin main
source venv/bin/activate
uv pip install -e ".[all]"
# 重启服务(如果网关在运行)
hermes gateway restart
bash# 查看可用版本
git tag
# 切换到特定版本
git checkout v1.2.3
uv pip install -e ".[all]"
bash# 停止网关
hermes gateway stop
# 查看并终止所有 Hermes 进程
ps aux | grep hermes
kill -9 <PID>
bash# 删除 Hermes 安装目录
rm -rf ~/.hermes
# 删除源代码(如果是从 Git 克隆的)
rm -rf ~/hermes-agent
# 删除虚拟环境(如果单独创建)
# 通常在 ~/.hermes/venv 中
bash# 编辑 shell 配置文件
nano ~/.zshrc # 或 nano ~/.bashrc
# 删除以下行(如果存在):
# export PATH="$HOME/.hermes/bin:$PATH"
# source ~/.hermes/venv/bin/activate
# 重新加载配置
source ~/.zshrc
bash# 清理未使用的依赖
brew autoremove
# 清理缓存
brew cleanup
bash# 查看是否存在 launchd 服务
launchctl list | grep hermes
# 停止并删除服务
launchctl stop com.nousresearch.hermes
launchctl unload ~/Library/LaunchAgents/com.nousresearch.hermes.plist
rm ~/Library/LaunchAgents/com.nousresearch.hermes.plist
bash# 确认命令不存在
which hermes
# 应该返回空或 "hermes not found"
# 确认目录已删除
ls -la ~/.hermes
# 应该返回 "No such file or directory"
A: Hermes Agent 是 OpenClaw 的继任者,增加了:
A: 完全可以。Hermes 支持 Apple Silicon 架构,安装脚本会自动检测并配置。
A: 不是。支持多种提供商:OpenAI、Anthropic、Kimi、MiniMax 等,也可以配置自定义 API 端点。
A: 使用 nohup 或创建 launchd 服务:
bash# 使用 nohup
nohup hermes gateway start > /dev/null 2>&1 &
# 或创建 launchd 服务(推荐)
cat > ~/Library/LaunchAgents/com.nousresearch.hermes.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.nousresearch.hermes</string>
<key>ProgramArguments</key>
<array>
<string>/Users/$(whoami)/.hermes/venv/bin/hermes</string>
<string>gateway</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/com.nousresearch.hermes.plist
A:
bash# 备份整个 Hermes 目录
tar -czf hermes-backup-$(date +%Y%m%d).tar.gz ~/.hermes
# 或只备份重要文件
cp -r ~/.hermes/config.yaml ~/hermes-config-backup/
cp -r ~/.hermes/memories ~/hermes-memories-backup/
cp -r ~/.hermes/skills ~/hermes-skills-backup/
A: 部分功能可以。本地工具(shell、文件系统)可以离线使用,但 AI 对话需要网络连接来调用 LLM API。
A:
bash# 旧 Mac 上备份
tar -czf hermes-backup.tar.gz ~/.hermes
# 传输到新 Mac(使用 scp、AirDrop 等)
scp hermes-backup.tar.gz user@new-mac:~
# 新 Mac 上恢复
tar -xzf hermes-backup.tar.gz
hermes doctor # 验证配置
A:
bash# 使用环境变量而不是直接写在配置中
export OPENROUTER_API_KEY="your-key"
# 在 config.yaml 中引用
# openrouter_api_key: ${OPENROUTER_API_KEY}
# 将环境变量添加到 .zshrc
echo 'export OPENROUTER_API_KEY="your-key"' >> ~/.zshrc
# 设置配置文件权限
chmod 600 ~/.hermes/config.yaml
A: 编辑人格文件:
bash# 查看可用的人格
ls ~/.hermes/personalities/
# 创建自定义人格
cat > ~/.hermes/personalities/my-assistant.md << EOF
你是一个专业的编程助手,擅长:
- Python 开发
- 系统架构设计
- 代码审查和优化
你的回答应该:
1. 简洁明了
2. 提供代码示例
3. 解释关键概念
EOF
# 使用自定义人格
/personality my-assistant
A:
bash# 1. 使用更快的模型
hermes model openrouter:google/gemini-flash
# 2. 减少工具数量
hermes tools disable <unused-tools>
# 3. 定期压缩上下文
/compress # 在对话中
# 4. 使用本地模型(如果有 GPU)
hermes config set model_endpoint "http://localhost:8080"
# 5. 限制对话历史长度
hermes config set max_context_turns 20
祝你使用愉快! 🎉
本文作者:JACK WEI
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!