feat: Hermes confined to act only as an Endo guest

A NixOS module (nix/hermes-guest.nix) layers confinement on upstream's
services.hermes-agent: no network (PrivateNetwork), an empty /run with
two Unix sockets bound back in, and no user manager. Hermes reaches the
world through host.sock, the guest's Endo methods (listMessages,
request, lookup, reply, ...) as MCP, and llm.sock, an inference proxy
that holds the API key.

The same unit runs on a Linux host (nix/linux-host.nix) and in a vfkit
microVM on macOS (nix/vfkit-vm.nix), where systemd relays the two
sockets over vsock to launchd on the host (nix/darwin-host.nix).

test/demo.py runs unmodified Hermes against a fake host and a scripted
model, and checks what the host received.

Generated-by: Claude Opus 5.5
This commit is contained in:
dckc committed 2026-11-29 16:34:39 -06:00
commit e38d681a9e
13 files changed
+1379

No files matched your search

+47
View File
@@ -0,0 +1,47 @@
# On macOS: launchd agents for the host side of the VM, with no nix-darwin.
# The result has the plists in share/LaunchAgents; see the README.
{
pkgs,
lib,
runner, # the VM's microvm runner (config.microvm.declaredRunner)
hostDir,
upstream,
keyFile,
}:
let
proxy = pkgs.writers.writePython3 "llm-proxy" { flakeIgnore = [ "E501" ]; } (
builtins.readFile ../llm-proxy.py
);
plist = name: attrs: pkgs.writeText "${name}.plist" (lib.generators.toPlist { escape = true; } attrs);
# the inference proxy: launchd listens, and hands each connection to a
# fresh proxy as its stdin (inetd style), as systemd's Accept=yes does
llmProxy = plist "net.madmode.hermes-llm-proxy" {
Label = "net.madmode.hermes-llm-proxy";
ProgramArguments = [
"${proxy}"
upstream
keyFile
];
inetdCompatibility.Wait = false;
Sockets.Listener = {
SockPathName = "${hostDir}/llm.sock";
SockPathMode = 384; # 0600
};
StandardErrorPath = "${hostDir}/llm-proxy.log";
};
vm = plist "net.madmode.hermes-vm" {
Label = "net.madmode.hermes-vm";
ProgramArguments = [ "${runner}/bin/microvm-run" ];
WorkingDirectory = hostDir;
KeepAlive = true;
StandardOutPath = "${hostDir}/vm.log";
StandardErrorPath = "${hostDir}/vm.log";
};
in
pkgs.runCommand "hermes-guest-darwin-host" { } ''
mkdir -p $out/share/LaunchAgents
cp ${llmProxy} $out/share/LaunchAgents/net.madmode.hermes-llm-proxy.plist
cp ${vm} $out/share/LaunchAgents/net.madmode.hermes-vm.plist
''