配置文件:运行多个代理
在同一台机器上运行多个独立的 Hermes 代理 —— 每个代理拥有自己的配置、API 密钥、记忆、会话、技能和网关。
什么是配置文件?
配置文件是一个完全隔离的 Hermes 环境。每个配置文件都会拥有一个独立的目录,其中包含其专属的 config.yaml、.env、SOUL.md、记忆、会话、技能、定时任务(cron jobs)以及状态数据库。通过配置文件,你可以为不同用途运行多个独立的代理——例如编程助手、个人机器人、研究代理等——而不会产生任何相互干扰。
当你创建一个配置文件时,它会自动成为一个独立的命令。创建名为 coder 的配置文件后,你立即就拥有了 coder chat、coder setup、coder 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、.env 和 SOUL.md 复制到新配置文件中。使用相同的 API 密钥和模型,但会获得全新的会话和记忆。如需更换 API 密钥,请编辑 ~/.hermes/profiles/work/.env;如需改变个性,请修改 ~/.hermes/profiles/work/SOUL.md。
克隆全部内容(--clone-all)
hermes profile create backup --clone-all
复制所有内容——配置、API 密钥、个性、全部记忆、完整的会话历史、技能、定时任务、插件。这是一个完整快照。适用于备份或从已有上下文的代理进行分叉。
从特定配置文件克隆
hermes profile create work --clone --clone-from coder
当启用 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 本身。无需迁移——现有安装可无缝兼容。