跳到主要内容

配置文件:运行多个代理

在同一台机器上运行多个独立的 Hermes 代理 —— 每个代理拥有自己的配置、API 密钥、记忆、会话、技能和网关。

什么是配置文件?

配置文件是一个完全隔离的 Hermes 环境。每个配置文件都有自己的目录,包含独立的 config.yaml.envSOUL.md、记忆、会话、技能、定时任务和状态数据库。配置文件让你可以为不同用途运行独立的代理 —— 例如代码助手、个人机器人、研究代理 —— 而不会产生任何相互干扰。

当你创建一个配置文件时,它会自动成为一个独立的命令。创建名为 coder 的配置文件后,你立即拥有 coder chatcoder setupcoder gateway start 等命令。

快速入门

hermes profile create coder       # creates profile + "coder" command alias
coder setup # configure API keys and model
coder chat # start chatting

完成。coder 现在是一个完全独立的代理。它拥有自己的配置、自己的记忆、以及所有其他独立资源。

创建配置文件

空配置文件

hermes profile create mybot

创建一个包含预置技能的全新配置文件。运行 mybot setup 来配置 API 密钥、模型和网关令牌。

仅克隆配置(--clone

hermes profile create work --clone

将当前配置文件的 config.yaml.envSOUL.md 复制到新配置文件中。使用相同的 API 密钥和模型,但会话和记忆是全新的。编辑 ~/.hermes/profiles/work/.env 以使用不同的 API 密钥,或编辑 ~/.hermes/profiles/work/SOUL.md 以设置不同的个性。

克隆全部内容(--clone-all

hermes profile create backup --clone-all

复制 全部内容 —— 配置、API 密钥、个性、所有记忆、完整的会话历史、技能、定时任务、插件。这是一个完整的快照。适用于备份或复制一个已有上下文的代理。

从特定配置文件克隆

hermes profile create work --clone --clone-from coder
Honcho 记忆 + 配置文件

当启用 Honcho 时,--clone 会自动为新配置文件创建一个专用的 AI 同伴,同时共享相同的用户工作区。每个配置文件会构建自己的观察和身份。详情请参见 Honcho — 多代理 / 配置文件

使用配置文件

命令别名

每个配置文件都会自动在 ~/.local/bin/<name> 处获得一个命令别名:

coder chat                    # chat with the coder agent
coder setup # configure coder's settings
coder gateway start # start coder's gateway
coder doctor # check coder's health
coder skills list # list coder's skills
coder config set model.model anthropic/claude-sonnet-4

该别名支持所有 hermes 子命令 —— 其底层只是 hermes -p <name>

-p 标志

你也可以通过任意命令显式指定配置文件:

hermes -p coder chat
hermes --profile=coder doctor
hermes chat -p coder -q "hello" # works in any position

设置默认配置文件(hermes profile use

hermes profile use coder
hermes chat # now targets coder
hermes tools # configures coder's tools
hermes profile use default # switch back

设置默认配置文件,使得普通的 hermes 命令默认指向该配置文件。类似于 kubectl config use-context

知道当前所在位置

CLI 始终显示当前激活的配置文件:

  • 提示符:显示为 coder ❯ 而非
  • 启动横幅:显示 Profile: coder
  • hermes profile:显示当前配置文件名称、路径、模型和网关状态

运行网关

每个配置文件都以独立进程运行自己的网关,并拥有独立的机器人令牌:

coder gateway start           # starts coder's gateway
assistant gateway start # starts assistant's gateway (separate process)

不同的机器人令牌

每个配置文件都有自己的 .env 文件。在每个文件中配置不同的 Telegram/Discord/Slack 机器人令牌:

# Edit coder's tokens
nano ~/.hermes/profiles/coder/.env

# Edit assistant's tokens
nano ~/.hermes/profiles/assistant/.env

安全性:令牌锁定

如果两个配置文件意外使用了相同的机器人令牌,第二个网关将被阻止,并显示明确的错误信息,指出冲突的配置文件。支持 Telegram、Discord、Slack、WhatsApp 和 Signal。

持久化服务

coder gateway install         # creates hermes-gateway-coder systemd/launchd service
assistant gateway install # creates hermes-gateway-assistant service

每个配置文件都有自己的服务名称。它们独立运行。

配置文件配置

每个配置文件都有自己的:

  • config.yaml —— 模型、提供者、工具集、所有设置
  • .env —— API 密钥、机器人令牌
  • SOUL.md —— 个性和指令
coder config set model.model anthropic/claude-sonnet-4
echo "You are a focused coding assistant." > ~/.hermes/profiles/coder/SOUL.md

更新

hermes update 仅拉取一次代码(共享),并自动将新预置技能同步到 所有 配置文件:

hermes update
# → Code updated (12 commits)
# → Skills synced: default (up to date), coder (+2 new), assistant (+2 new)

用户修改过的技能不会被覆盖。

管理配置文件

hermes profile list           # show all profiles with status
hermes profile show coder # detailed info for one profile
hermes profile rename coder dev-bot # rename (updates alias + service)
hermes profile export coder # export to coder.tar.gz
hermes profile import coder.tar.gz # import from archive

删除配置文件

hermes profile delete coder

这将停止网关、移除 systemd/launchd 服务、删除命令别名,并删除所有配置文件数据。系统会要求你输入配置文件名称以确认。

使用 --yes 可跳过确认:hermes profile delete coder --yes

备注

你无法删除默认配置文件(~/.hermes)。如需删除全部内容,请使用 hermes uninstall

Tab 补全

# Bash
eval "$(hermes completion bash)"

# Zsh
eval "$(hermes completion zsh)"

将该行添加到你的 ~/.bashrc~/.zshrc 中以实现持久补全。在 -p 后、配置文件子命令和顶层命令后均可补全配置文件名称。

工作原理

配置文件使用 HERMES_HOME 环境变量。当你运行 coder chat 时,包装脚本会在启动 Hermes 前设置 HERMES_HOME=~/.hermes/profiles/coder。由于代码库中 119+ 个文件通过 get_hermes_home() 解析路径,所有内容自动作用于配置文件目录 —— 包括配置、会话、记忆、技能、状态数据库、网关 PID、日志和定时任务。

默认配置文件就是 ~/.hermes 本身。无需迁移 —— 现有安装可完全兼容。