Skip to content

The agent that grows with you

fix(profiles): honcho.json is a credential store, and a file cannot replace a store's directory

John Paul Soliva69613ebc5f90
diff --git a/hermes_cli/profile_distribution.py b/hermes_cli/profile_distribution.py
index 346ea93f46a..acc3b8bd597 100644
--- a/hermes_cli/profile_distribution.py
+++ b/hermes_cli/profile_distribution.py
@@ -480,6 +480,20 @@ def _refuse_symlinked_containers(src: Path, dest: Path, rel: Tuple[str, ...]) ->
if _merges_per_root(child, parts):
_refuse_symlink(dest / child.name)
_refuse_symlinked_containers(child, dest / child.name, parts)
+ else:
+ _refuse_store_ancestor_replacement(child, dest / child.name, parts)
+
+
+def _refuse_store_ancestor_replacement(src: Path, dest: Path, rel_parts: Tuple[str, ...]) -> None:
+ """A payload file where the profile has a directory that holds credential stores
+ (``platforms`` shipped as a file over ``platforms/``) would be a whole-directory replace,
+ taking ``platforms/pairing`` with it. Refused before the first write."""
+ if (not src.is_dir() and profile_path_contains_private_store(rel_parts)
+ and dest.is_dir() and not dest.is_symlink()):
+ raise DistributionError(
+ f"{dest} is a directory that holds credential stores, and the distribution ships a "
+ f"file named {'/'.join(rel_parts)}; refusing to replace it"
+ )
def _merges_per_root(src: Path, rel_parts: Tuple[str, ...]) -> bool:
@@ -508,6 +522,8 @@ def _refuse_symlinked_targets(target: Path, entries) -> None:
_refuse_symlink(path)
if _merges_per_root(src, rel_parts):
_refuse_symlinked_containers(src, path, rel_parts)
+ else:
+ _refuse_store_ancestor_replacement(src, path / rel_parts[-1], rel_parts)
def _copy_dist_payload(staged: Path, target: Path, manifest: DistributionManifest, preserve_config: bool) -> None:
diff --git a/hermes_cli/profiles.py b/hermes_cli/profiles.py
index 0a5159bf13d..63775105063 100644
--- a/hermes_cli/profiles.py
+++ b/hermes_cli/profiles.py
@@ -160,6 +160,7 @@ PROFILE_CREDENTIAL_PATHS = frozenset({
"google_chat_user_tokens", "google_chat_user_client_secret.json", "google_chat_user_oauth_pending.json",
"google_chat_user_token.json", "google_chat_user_oauth_pending", # legacy single-user layouts
"slack_tokens.json",
+ "honcho.json", # Honcho apiKey + OAuth grant (oauth.refreshToken)
"webhook_subscriptions.json", # per-route HMAC secrets
"mcp-tokens", # MCP OAuth tokens
"vault", # vault.key + vault.json.enc
diff --git a/tests/hermes_cli/test_profile_export_credentials.py b/tests/hermes_cli/test_profile_export_credentials.py
index c0ba306ce2d..eb90cd64ace 100644
--- a/tests/hermes_cli/test_profile_export_credentials.py
+++ b/tests/hermes_cli/test_profile_export_credentials.py
@@ -73,7 +73,7 @@ class TestCredentialExclusion:
(profile_dir / "config.yaml").write_text("model: gpt-4\n")
(profile_dir / "platforms" / "keep.json").write_text("{}")
stores = {".op.env", "npmrc", "google_chat_user_token.json", "google_chat_user_oauth_pending",
- "workspace/meetings/node_token.json", *PROFILE_CREDENTIAL_PATHS}
+ "workspace/meetings/node_token.json", "honcho.json", *PROFILE_CREDENTIAL_PATHS}
for rel in stores:
is_dir = "." not in rel.rsplit("/", 1)[-1] and rel != "npmrc" # token dirs vs single files
target = profile_dir / rel / "store" if is_dir else profile_dir / rel
@@ -104,6 +104,51 @@ class TestCredentialExclusion:
leaked = sorted(r for r in stores if any(n == f"testprofile/{r}" or n.startswith(f"testprofile/{r}/") for n in names))
assert not leaked, leaked
+ @pytest.mark.parametrize("shipped_file", ["platforms", "platforms/whatsapp"])
+ @pytest.mark.parametrize("declare_owned", [False, True])
+ def test_update_shipping_a_file_over_a_store_directory_changes_nothing(
+ self, tmp_path, monkeypatch, shipped_file, declare_owned):
+ """An update whose payload ships a FILE where the profile has a directory holding
+ credential stores is refused before anything is written: the installer's stores
+ survive and no other payload file has been replaced."""
+ from pathlib import Path
+
+ from hermes_cli.profile_distribution import (
+ DistributionError, DistributionManifest, install_distribution, write_manifest,
+ )
+
+ monkeypatch.setattr(Path, "home", lambda: tmp_path)
+ (tmp_path / ".hermes").mkdir()
+ monkeypatch.setenv("HERMES_HOME", str(tmp_path / ".hermes"))
+ owned = ["SOUL.md", "platforms"] if declare_owned else []
+
+ def stage(label, soul):
+ staged = tmp_path / label
+ staged.mkdir()
+ (staged / "SOUL.md").write_text(soul)
+ write_manifest(staged, DistributionManifest(name="dist", version="0.1.0", distribution_owned=owned))
+ return staged
+
+ first = stage("v1", "v1")
+ (first / "platforms").mkdir()
+ (first / "platforms" / "keep.json").write_text("{}")
+ installed = install_distribution(str(first), name="dist").target_dir
+ stores = [installed / "platforms" / "pairing" / "approved.json",
+ installed / "platforms" / "whatsapp" / "session" / "creds.json"]
+ for store in stores:
+ store.parent.mkdir(parents=True)
+ store.write_text("installer-credential")
+
+ second = stage("v2", "v2")
+ target = second / shipped_file
+ target.parent.mkdir(parents=True, exist_ok=True)
+ target.write_text("not a directory")
+ with pytest.raises(DistributionError):
+ install_distribution(str(second), name="dist", force=True)
+
+ assert [s.read_text() for s in stores] == ["installer-credential"] * 2
+ assert (installed / "SOUL.md").read_text() == "v1"
+
def test_export_ships_no_recovery_copy_hermes_writes_of_a_store(self, tmp_path, monkeypatch):
"""Every copy Hermes' own writers leave in a profile home (pre-update zip, update snapshot,
config-migration .bak, config backup, corrupt auth.json) stays out of a named-profile
diff --git a/website/docs/user-guide/profile-distributions.md b/website/docs/user-guide/profile-distributions.md
index 2206efe82e4..f2aa7111af6 100644
--- a/website/docs/user-guide/profile-distributions.md
+++ b/website/docs/user-guide/profile-distributions.md
@@ -87,7 +87,7 @@ Not a fit:
- **You want to hand someone your setup once, right now.** A distribution needs a repo, a manifest, and a `.gitignore`. `/export` needs none of that — see [Export and import a profile file](#export-and-import-a-profile-file). Same for backing up or moving a profile to a new machine.
- **You want to share your desktop theme and layout.** A distribution carries the agent — SOUL, config, skills, cron, MCP, plugins. An export made from the desktop app also carries the look: skin, light/dark mode, custom themes, rail color, and window layout.
-- **You want to share API keys alongside the agent.** `auth.json`, `.env` and the other credential stores Hermes reads from a profile (`.op.env`, `npmrc`, OAuth token files, `mcp-tokens/`, `vault/`, browser profiles, platform sessions) are deliberately excluded from distributions. Each installer brings their own credentials. (Export files strip them too.)
+- **You want to share API keys alongside the agent.** `auth.json`, `.env` and the other credential stores Hermes reads from a profile (`.op.env`, `npmrc`, OAuth token files, `honcho.json`, `mcp-tokens/`, `vault/`, browser profiles, platform sessions) are deliberately excluded from distributions. Each installer brings their own credentials. (Export files strip them too.)
- **You want to share memories / sessions / conversation history.** Those are user data, not distribution content. Never shipped. (Export files are different here — read [what an export contains](#what-an-export-file-contains) before sending one.)
:::caution
@@ -274,7 +274,7 @@ When an installer updates to a new version, some things get replaced (author's d
|---|---|---|
| **Distribution-owned** | `SOUL.md`, `config.yaml`, `mcp.json`, `skills/`, `cron/jobs.json`, `distribution.yaml` | Files are replaced from the new clone. Skill directories are merged per entry. `cron/jobs.json` is merged by job id: shipped definitions update in place, your local jobs and each job's paused/enabled state survive, and newly shipped jobs arrive paused. Other `cron/` files and root-level hidden `skills/` metadata are runtime state and stay local. |
| **Config override** | `config.yaml` | Actually preserved by default — the installer may have tuned model or provider. Pass `--force-config` on update to reset. |
-| **User-owned** | `memories/`, `sessions/`, `state.db*`, `auth.json`, `.env` and the other credential stores (including those below a distribution-owned directory, such as `platforms/pairing/` and `platforms/whatsapp/session/`), `logs/`, `workspace/`, `plans/`, `home/`, `*_cache/`, `local/` | Never touched, and `distribution_owned` cannot claim a credential store |
+| **User-owned** | `memories/`, `sessions/`, `state.db*`, `auth.json`, `.env` and the other credential stores (including those below a distribution-owned directory, such as `platforms/pairing/` and `platforms/whatsapp/session/`), `logs/`, `workspace/`, `plans/`, `home/`, `*_cache/`, `local/` | Never touched, and `distribution_owned` cannot claim a credential store. An update that ships a file where your profile has a directory holding one (a file named `platforms`) is refused before anything is written |
You can override the distribution-owned list in the manifest:
@@ -686,7 +686,7 @@ You cannot import as `default` — that name is the built-in root profile (`~/.h
### What an export file contains
-Always excluded, both profile types: `auth.json`, `.env` and the other credential stores Hermes reads from a profile (OAuth token files, `mcp-tokens/`, `vault/`, browser profiles, platform sessions and pairing stores). Your API keys never leave the machine.
+Always excluded, both profile types: `auth.json`, `.env` and the other credential stores Hermes reads from a profile (OAuth token files, `honcho.json`, `mcp-tokens/`, `vault/`, browser profiles, platform sessions and pairing stores). Your API keys never leave the machine. `honcho.json` holds the Honcho API key and OAuth grant next to its settings, so after an import run `hermes honcho setup` again.
**The default profile** (`~/.hermes`) is exported through an allow-list — only known Hermes artifacts, so an unrelated file sitting in your home directory can't get swept in:
diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/profile-distributions.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/profile-distributions.md
index a9ea33512e0..3f81e375e55 100644
--- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/profile-distributions.md
+++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/user-guide/profile-distributions.md
@@ -66,7 +66,7 @@ hermes profile install github.com/you/my-research-agent --alias
不适合的场景:
- **你只想在自己的机器上备份一个 profile。** 使用 [`hermes profile export` / `import`](../reference/profile-commands.md#hermes-profile-export)——那正是这两个命令的用途。
-- **你想随 agent 一起共享 API 密钥。** `auth.json`、`.env` 以及 Hermes 从 profile 读取的其他凭据存储(`.op.env`、`npmrc`、OAuth token 文件、`mcp-tokens/`、`vault/`、浏览器 profile、平台会话)被刻意排除在分发之外。每个安装者使用自己的凭据。(导出文件同样会去除它们。)
+- **你想随 agent 一起共享 API 密钥。** `auth.json`、`.env` 以及 Hermes 从 profile 读取的其他凭据存储(`.op.env`、`npmrc`、OAuth token 文件、`honcho.json`、`mcp-tokens/`、`vault/`、浏览器 profile、平台会话)被刻意排除在分发之外。每个安装者使用自己的凭据。(导出文件同样会去除它们。)
- **你想共享记忆 / 会话 / 对话历史。** 这些是用户数据,不是分发内容,永远不会被发送。
## 生命周期:从作者到安装者再到更新
@@ -175,7 +175,7 @@ research-bot/
|---|---|---|
| **分发所有** | `SOUL.md`、`config.yaml`、`mcp.json`、`skills/`、`cron/`、`distribution.yaml` | 从新克隆中替换 |
| **配置覆盖** | `config.yaml` | 默认实际保留——安装者可能已调整模型或 provider。更新时传入 `--force-config` 可重置。 |
-| **用户所有** | `memories/`、`sessions/`、`state.db*`、`auth.json`、`.env` 及其他凭据存储(包括位于分发所有目录之下的存储,例如 `platforms/pairing/` 和 `platforms/whatsapp/session/`)、`logs/`、`workspace/`、`plans/`、`home/`、`*_cache/`、`local/` | 永不触碰,且 `distribution_owned` 不能声明凭据存储 |
+| **用户所有** | `memories/`、`sessions/`、`state.db*`、`auth.json`、`.env` 及其他凭据存储(包括位于分发所有目录之下的存储,例如 `platforms/pairing/` 和 `platforms/whatsapp/session/`)、`logs/`、`workspace/`、`plans/`、`home/`、`*_cache/`、`local/` | 永不触碰,且 `distribution_owned` 不能声明凭据存储。如果更新在你的 profile 中存放凭据存储的目录位置上发送了一个文件(例如名为 `platforms` 的文件),则会在写入任何内容之前被拒绝 |
你可以在 manifest 中覆盖分发所有列表: