From a45e3e184ba2648d550a61ce169229132bef508f Mon Sep 17 00:00:00 2001
From: m3tam3re
Date: Sun, 25 Oct 2026 14:02:31 +0100
Subject: [PATCH] fix(m3-hermes): seed ai-memory hook credential for Hermes
The native hook command reads /auth-token, not the config's
bearer_token_file; without it every Hermes event was spooled with a 401.
Co-Authored-By: Claude Fable 5.1
---
hosts/m3-hermes/services/hermes-agent.nix | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hosts/m3-hermes/services/hermes-agent.nix b/hosts/m3-hermes/services/hermes-agent.nix
index 318f607..ea72c2f 100644
--- a/hosts/m3-hermes/services/hermes-agent.nix
+++ b/hosts/m3-hermes/services/hermes-agent.nix
@@ -15,9 +15,11 @@
yamlPython = pkgs.python3.withPackages (ps: [ps.pyyaml]);
# ── ai-memory client (server: ./ai-memory.nix, same host) ─────────────
- # Hooks and the MCP bridge read the bearer from [auth].bearer_token_file
- # in the data dir's config.toml, so neither config.yaml nor the process
- # environment ever carries the token.
+ # The MCP bridge reads the bearer from [auth].bearer_token_file in the
+ # data dir's config.toml; the native `hook` command only looks at
+ # /auth-token (what `install-hooks --apply` would seed), so that
+ # file is a symlink to the same secret. Neither config.yaml nor the
+ # process environment ever carries the token.
aiMemory = "${config.services.ai-memory.package}/bin/ai-memory";
aiMemoryUrl = "http://127.0.0.1:${toString (config.m3ta.ports.get "ai-memory")}";
aiMemoryDataDir = "/var/lib/hermes/.local/share/ai-memory";
@@ -42,6 +44,7 @@ in {
[auth]
bearer_token_file = "${config.age.secrets."ai-memory-hermes-token".path}"
''}"
+ "L+ ${aiMemoryDataDir}/auth-token - - - - ${config.age.secrets."ai-memory-hermes-token".path}"
# Scope marker: Hermes reports its process directory as cwd, so every
# assistant session lands in one project of the `home` workspace
# (coding checkouts below $HOME with their own marker still win).