Merge feat/ai-memory: central ai-memory server, Hermes wiring, kratos client

This commit is contained in:
m3ta-chiron committed 2026-10-25 13:55:25 +01:00
commit 3276020422
15 files changed
+278 -16

No files matched your search

Generated
+93 -14
View File
@@ -86,6 +86,28 @@
"url": "https://code.m3ta.dev/m3tam3re/AGENTS" "url": "https://code.m3ta.dev/m3tam3re/AGENTS"
} }
}, },
"ai-memory": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": [
"nixpkgs"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1792718584,
"narHash": "sha256-YPYAhIfS8Ma5CmP0Jdc6pjLqhRNXlAFdElaKErSNfXA=",
"owner": "akitaonrails",
"repo": "ai-memory",
"rev": "1bd866375b01031d63db54862a133376598d3701",
"type": "github"
},
"original": {
"owner": "akitaonrails",
"repo": "ai-memory",
"type": "github"
}
},
"base16-schemes": { "base16-schemes": {
"flake": false, "flake": false,
"locked": { "locked": {
@@ -204,7 +226,7 @@
"m3ta-nixpkgs", "m3ta-nixpkgs",
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": "rust-overlay", "rust-overlay": "rust-overlay_2",
"treefmt-nix": "treefmt-nix_2" "treefmt-nix": "treefmt-nix_2"
}, },
"locked": { "locked": {
@@ -227,7 +249,7 @@
"m3ta-nixpkgs", "m3ta-nixpkgs",
"nixpkgs" "nixpkgs"
], ],
"rust-overlay": "rust-overlay_2", "rust-overlay": "rust-overlay_3",
"treefmt-nix": "treefmt-nix_3" "treefmt-nix": "treefmt-nix_3"
}, },
"locked": { "locked": {
@@ -251,7 +273,7 @@
"nixpkgs" "nixpkgs"
], ],
"stable": "stable", "stable": "stable",
"systems": "systems" "systems": "systems_2"
}, },
"locked": { "locked": {
"lastModified": 1791553562, "lastModified": 1791553562,
@@ -471,6 +493,25 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1731533236,
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
"type": "github"
}
},
"hermes-agent": { "hermes-agent": {
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
@@ -614,7 +655,7 @@
"rose-pine-hyprcursor", "rose-pine-hyprcursor",
"nixpkgs" "nixpkgs"
], ],
"systems": "systems_3" "systems": "systems_4"
}, },
"locked": { "locked": {
"lastModified": 1709914708, "lastModified": 1709914708,
@@ -635,7 +676,7 @@
"bun2nix": "bun2nix", "bun2nix": "bun2nix",
"flake-parts": "flake-parts_2", "flake-parts": "flake-parts_2",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_3",
"systems": "systems_2", "systems": "systems_3",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"
}, },
"locked": { "locked": {
@@ -668,11 +709,11 @@
"nur": "nur" "nur": "nur"
}, },
"locked": { "locked": {
"lastModified": 1792827335, "lastModified": 1792931741,
"narHash": "sha256-cvsBaKhgZtz8yWw+DV8sPo4vtiU42cnFeAq/G63Qr0k=", "narHash": "sha256-RGLM6DjzNXJ2QMfb9JnqDV8H05WtLRe4AymlH8rixq0=",
"ref": "refs/heads/master", "ref": "refs/heads/master",
"rev": "d608fb29b19f616ecb54e4ff3e3d68422adc1821", "rev": "963351200c12bc5c91408e3fdbd8d4d86f784c4d",
"revCount": 159, "revCount": 162,
"type": "git", "type": "git",
"url": "ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home" "url": "ssh://gitea@code.m3ta.dev/m3tam3re/m3ta-home"
}, },
@@ -1323,6 +1364,7 @@
"root": { "root": {
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"ai-memory": "ai-memory",
"colmena": "colmena", "colmena": "colmena",
"disko": "disko", "disko": "disko",
"hermes-agent": "hermes-agent", "hermes-agent": "hermes-agent",
@@ -1360,6 +1402,28 @@
} }
}, },
"rust-overlay": { "rust-overlay": {
"inputs": {
"nixpkgs": [
"ai-memory",
"nixpkgs"
]
},
"locked": {
"lastModified": 1787108576,
"narHash": "sha256-WLhxXPMCzbeufsDZxdzkurLGBq74GX+JgLX8fFy6HZs=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "99607a06c2ea1290cd3258c11d1416dde9201f94",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "99607a06c2ea1290cd3258c11d1416dde9201f94",
"type": "github"
}
},
"rust-overlay_2": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"m3ta-home", "m3ta-home",
@@ -1382,7 +1446,7 @@
"type": "github" "type": "github"
} }
}, },
"rust-overlay_2": { "rust-overlay_3": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"m3ta-nixpkgs", "m3ta-nixpkgs",
@@ -1421,6 +1485,21 @@
} }
}, },
"systems": { "systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"systems_2": {
"locked": { "locked": {
"lastModified": 1776166891, "lastModified": 1776166891,
"narHash": "sha256-bI8yrEGjrohR5hkQox7UrxDH7XqrYMwI8SL/LrJ1+S8=", "narHash": "sha256-bI8yrEGjrohR5hkQox7UrxDH7XqrYMwI8SL/LrJ1+S8=",
@@ -1435,7 +1514,7 @@
"type": "github" "type": "github"
} }
}, },
"systems_2": { "systems_3": {
"locked": { "locked": {
"lastModified": 1791244623, "lastModified": 1791244623,
"narHash": "sha256-uuanbkFk8a313Zfrxdcz8Us/yQtaxNnKJtX8v0ZPpd8=", "narHash": "sha256-uuanbkFk8a313Zfrxdcz8Us/yQtaxNnKJtX8v0ZPpd8=",
@@ -1450,7 +1529,7 @@
"type": "github" "type": "github"
} }
}, },
"systems_3": { "systems_4": {
"locked": { "locked": {
"lastModified": 1689347949, "lastModified": 1689347949,
"narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=", "narHash": "sha256-12tWmuL2zgBgZkdoB6qXZsgJEH9LR3oUgpaQq2RbI80=",
@@ -1465,7 +1544,7 @@
"type": "github" "type": "github"
} }
}, },
"systems_4": { "systems_5": {
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
@@ -1548,7 +1627,7 @@
}, },
"utils": { "utils": {
"inputs": { "inputs": {
"systems": "systems_4" "systems": "systems_5"
}, },
"locked": { "locked": {
"lastModified": 1710146030, "lastModified": 1710146030,
+6
View File
@@ -67,6 +67,11 @@
}; };
hermes-agent.url = "github:NousResearch/hermes-agent/v2026.9.24"; hermes-agent.url = "github:NousResearch/hermes-agent/v2026.9.24";
ai-memory = {
url = "github:akitaonrails/ai-memory";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = { outputs = {
@@ -119,6 +124,7 @@
agenix.nixosModules.default agenix.nixosModules.default
m3ta-nixpkgs.nixosModules.default m3ta-nixpkgs.nixosModules.default
inputs.hermes-agent.nixosModules.default inputs.hermes-agent.nixosModules.default
inputs.ai-memory.nixosModules.default
]; ];
}; };
}; };
+1
View File
@@ -44,6 +44,7 @@
# Agent infrastructure # Agent infrastructure
hermes-api = 8642; hermes-api = 8642;
hermes-dashboard = 9119; hermes-dashboard = 9119;
ai-memory = 49374;
# Home automation # Home automation
homarr = 7575; homarr = 7575;
+8
View File
@@ -108,6 +108,14 @@
}; };
lsp.enable = true; lsp.enable = true;
packages.enable = true; packages.enable = true;
aiMemory = {
enable = hostname == "m3-kratos";
# Work checkouts on the private desktop go to the work workspace.
workspaceDirs = {
"p/AZ" = "az";
"p/AZ-INTEC" = "az";
};
};
languages = { languages = {
python.enable = true; python.enable = true;
javascript.enable = true; javascript.enable = true;
+19
View File
@@ -0,0 +1,19 @@
{
# Traefik configuration for ai-memory (m3-hermes over Netbird)
services.traefik.dynamicConfigOptions.http = {
services.ai-memory.loadBalancer.servers = [
{
url = "http://100.81.231.152:49374";
}
];
routers.ai-memory = {
rule = "Host(`memory.m3ta.dev`)";
tls = {
certResolver = "godaddy";
};
service = "ai-memory";
entrypoints = "websecure";
};
};
}
+1
View File
@@ -12,6 +12,7 @@
./postgres.nix ./postgres.nix
./searx.nix ./searx.nix
./traefik.nix ./traefik.nix
./ai-memory.nix
./vaultwarden.nix ./vaultwarden.nix
./wastebin.nix ./wastebin.nix
]; ];
+7
View File
@@ -10,6 +10,13 @@
hermes-api-server-key = { hermes-api-server-key = {
file = ../../secrets/hermes-api-server-key.age; file = ../../secrets/hermes-api-server-key.age;
}; };
ai-memory-server-env = {
file = ../../secrets/ai-memory-server-env.age;
};
ai-memory-hermes-token = {
file = ../../secrets/ai-memory-hermes-token.age;
owner = "hermes";
};
}; };
}; };
} }
+52
View File
@@ -0,0 +1,52 @@
{
config,
pkgs,
...
}: let
# Netbird mesh VPN range — the server is only reachable from mesh peers.
# m3-atlas Traefik proxies memory.m3ta.dev to this port over Netbird.
netbirdRange = "100.64.0.0/16";
port = config.m3ta.ports.get "ai-memory";
in {
# ── ai-memory server ──────────────────────────────────────────────────
# Shared agent memory for all hosts (private + work), see
# https://aimemory.sh. Clients: m3ta-home `coding.aiMemory`.
#
# Flow: Agent → memory.m3ta.dev (TLS via m3-atlas Traefik) → Netbird → :${toString port}
# Hermes on this host talks to 127.0.0.1 directly.
services.ai-memory = {
enable = true;
# Same build as the clients (m3ta-home uses llm-agents.ai-memory),
# prebuilt via the numtide cache instead of compiling the flake.
package = pkgs.llm-agents.ai-memory;
bind = "0.0.0.0";
inherit port;
enableWeb = true;
# Root bearer, token pepper, recovery token, cookie/proxy settings and
# the LLM provider key. Never put any of these into `settings`.
ageSecret = "ai-memory-server-env";
settings = {
allowed_hosts = ["memory.m3ta.dev" "localhost" "127.0.0.1" "::1"];
# One operator, several workspaces (private, az, home): keep one
# cross-project profile for all of them. With database users the
# profile is off unless enabled explicitly.
profile = {
enabled = true;
share = "global";
};
# Shared server: auto-improvement proposals wait for approval.
auto_improve.require_approval = true;
};
};
networking.firewall = {
extraCommands = ''
# Allow ai-memory only from Netbird mesh VPN
ip46tables -A nixos-fw -p tcp --dport ${toString port} -s ${netbirdRange} -j nixos-fw-accept
'';
extraStopCommands = ''
ip46tables -D nixos-fw -p tcp --dport ${toString port} -s ${netbirdRange} -j nixos-fw-accept 2>/dev/null || true
'';
};
}
+1
View File
@@ -3,6 +3,7 @@
./hermes-agent.nix ./hermes-agent.nix
./herdr-sandbox.nix ./herdr-sandbox.nix
./hermes-dashboard.nix ./hermes-dashboard.nix
./ai-memory.nix
./netbird.nix ./netbird.nix
]; ];
} }
+73 -2
View File
@@ -13,12 +13,45 @@
# Same interpreter env the upstream merge script uses, so no extra # Same interpreter env the upstream merge script uses, so no extra
# closure cost — the derivation is shared. # closure cost — the derivation is shared.
yamlPython = pkgs.python3.withPackages (ps: [ps.pyyaml]); 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.
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";
aiMemoryHook = event: [
{
command = "${aiMemory} --data-dir ${aiMemoryDataDir} hook --event ${event} --agent hermes --server-url ${aiMemoryUrl}";
timeout = 20;
}
];
in { in {
virtualisation.docker.enable = true; virtualisation.docker.enable = true;
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d /var/lib/hermes/.config 0755 hermes hermes -" "d /var/lib/hermes/.config 0755 hermes hermes -"
"d /var/lib/hermes/.config/tea 0755 hermes hermes -" "d /var/lib/hermes/.config/tea 0755 hermes hermes -"
"d /var/lib/hermes/.local 0755 hermes hermes -"
"d /var/lib/hermes/.local/share 0755 hermes hermes -"
"d ${aiMemoryDataDir} 0700 hermes hermes -"
"L+ ${aiMemoryDataDir}/config.toml - - - - ${pkgs.writeText "ai-memory-hermes-config.toml" ''
server_url = "${aiMemoryUrl}"
[auth]
bearer_token_file = "${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).
"L+ /var/lib/hermes/.ai-memory.toml - - - - ${pkgs.writeText "ai-memory-hermes-marker.toml" ''
workspace = "home"
project = "assistant"
[capture]
ignore_paths = ["/run/agenix/**", "**/.env*", "/var/lib/hermes/.hermes/auth*", "/var/lib/hermes/.ssh/**"]
''}"
"L+ /var/lib/hermes/.config/tea/yml - - - - ${pkgs.writeText "tea-yml" '' "L+ /var/lib/hermes/.config/tea/yml - - - - ${pkgs.writeText "tea-yml" ''
logins: logins:
- name: m3ta - name: m3ta
@@ -39,7 +72,6 @@ in {
# without runtime pip/uv mutation. # without runtime pip/uv mutation.
extraDependencyGroups = [ extraDependencyGroups = [
"matrix" "matrix"
"honcho"
"exa" "exa"
"edge-tts" "edge-tts"
"voice" "voice"
@@ -91,6 +123,11 @@ in {
API_SERVER_PORT = toString (config.m3ta.ports.get "hermes-api"); API_SERVER_PORT = toString (config.m3ta.ports.get "hermes-api");
}; };
mcpServers.ai-memory = {
command = aiMemory;
args = ["mcp-bridge" "--no-session-id" "--server-url" "${aiMemoryUrl}/mcp" "--data-dir" aiMemoryDataDir];
};
# ── Container mode (podman) ────────────────────────────────────────── # ── Container mode (podman) ──────────────────────────────────────────
container = { container = {
enable = false; enable = false;
@@ -217,9 +254,23 @@ in {
silence_duration = 3.0; silence_duration = 3.0;
}; };
# ── ai-memory hooks ────────────────────────────────────────────────
# From `ai-memory install-hooks --agent hermes` (3.2.2). ai-memory is
# the one shared memory for every agent; Honcho was dropped in favour
# of it (2026-10-25), only Hermes' small built-in notes remain.
hooks_auto_accept = true;
hooks = {
pre_tool_call = aiMemoryHook "pre-tool-use";
post_tool_call = aiMemoryHook "post-tool-use";
on_session_start = aiMemoryHook "session-start";
pre_llm_call = aiMemoryHook "user-prompt-submit";
on_session_end = aiMemoryHook "stop";
on_session_finalize = aiMemoryHook "session-end";
};
# ── Memory ───────────────────────────────────────────────────────── # ── Memory ─────────────────────────────────────────────────────────
memory = { memory = {
provider = "honcho"; provider = "builtin";
memory_enabled = true; memory_enabled = true;
user_profile_enabled = true; user_profile_enabled = true;
memory_char_limit = 2200; memory_char_limit = 2200;
@@ -287,6 +338,26 @@ in {
]; ];
}; };
# ── ai-memory skills ──────────────────────────────────────────────────
# Hermes ignores MCP server instructions; the routing rules reach the
# model through these skills in ~/.hermes/skills, refreshed on each boot
# so they track the installed ai-memory version.
systemd.services.hermes-ai-memory-skills = {
description = "Install ai-memory skills for Hermes";
before = ["hermes-agent.service"];
wantedBy = ["hermes-agent.service"];
environment = {
HOME = "/var/lib/hermes";
HERMES_HOME = hermesHome;
};
serviceConfig = {
Type = "oneshot";
User = "hermes";
Group = "hermes";
ExecStart = "${aiMemory} --data-dir ${aiMemoryDataDir} install-skills --scope global --agent hermes";
};
};
# ── Activation hardening ───────────────────────────────────────────── # ── Activation hardening ─────────────────────────────────────────────
# Upstream (hermes-agent v2026.9.24) deep-merges the Nix settings into # Upstream (hermes-agent v2026.9.24) deep-merges the Nix settings into
# the runtime-writable config.yaml via a bare `yaml.safe_load()` with no # the runtime-writable config.yaml via a bare `yaml.safe_load()` with no
+4
View File
@@ -6,6 +6,10 @@
owner = "m3tam3re"; owner = "m3tam3re";
}; };
tailscale-key = {file = ../../secrets/tailscale-key.age;}; tailscale-key = {file = ../../secrets/tailscale-key.age;};
ai-memory-token = {
file = ../../secrets/ai-memory-token-kratos.age;
owner = "m3tam3re";
};
wg-DE = { wg-DE = {
file = ../../secrets/wg-DE.age; file = ../../secrets/wg-DE.age;
path = "/etc/wireguard/DE.conf"; path = "/etc/wireguard/DE.conf";
+3
View File
@@ -57,4 +57,7 @@ in {
"secrets/hermes-api-server-key.age".publicKeys = systems ++ users; "secrets/hermes-api-server-key.age".publicKeys = systems ++ users;
"secrets/hermes-gitea-token.age".publicKeys = systems ++ users; "secrets/hermes-gitea-token.age".publicKeys = systems ++ users;
"secrets/tuwunel-registration-token.age".publicKeys = systems ++ users; "secrets/tuwunel-registration-token.age".publicKeys = systems ++ users;
"secrets/ai-memory-server-env.age".publicKeys = [m3-hermes] ++ users;
"secrets/ai-memory-hermes-token.age".publicKeys = [m3-hermes] ++ users;
"secrets/ai-memory-token-kratos.age".publicKeys = [m3-kratos] ++ users;
} }
+10
View File
@@ -0,0 +1,10 @@
age-encryption.org/v1
-> ssh-ed25519 c4NQlA zI/2l+f5lXIlxga5caBbNnZPubSZw62MbT+6e5Qb2Bw
jQwWwzdW7NmLXZUY/UPoTXqz+aEUC0v2w3w7GwmLo1c
-> ssh-ed25519 ++TqaQ sd7cXefrEAlTVbp2Zn7nj2byTJzm87Ld5CDhuzx6llU
4vUCyqc6c/y418UlBOQlhOEC6/byevt4dGOxKMrpUq4
-> ssh-ed25519 CSMyhg dLYOoqGQQVTBxMEVoaFTU4cw49m5oIcdVGIR4chufXM
wO5VZT4gf5Dght8G8SNc20+nroPk8V0G28fPkNHV5Og
--- 7aJoglTeUIipNSavXfkU1Bvqy0g46QDYOBk36Ktxqmg
5ì è42˜D ÃK›c¾M=¿/õÆWÃhfe¿~–ÎÖîÎeÕyjåìÒ¥G¯Q Hpç‡
Åx•ŸZd©Qo¦¿¥ZÔ@7$¾'
Binary file not shown.
Binary file not shown.