Watch
0
0
Fork
You've already forked hyperhive
0

nix: the bash daemon gets the agent's store identity so it can publish its tasks

This commit is contained in:
damocles 2026-11-21 12:34:11 +01:00 • committed by mara
commit 1302965ca7

View file

@ -19,7 +19,18 @@ let
# opencode preset the provider key too. Either way it is handed the same
# store identity ./queue-identity.nix hands the harness, under the same
# switch.
subagentReadsStore = config.services.hyperhive.agent.bao.addr != null;
# The bash and subagent daemons publish to the swarm queue as the agent, so
# each reads the agent's queue secret from the store with the agent's own
# identity. Paths and a name only. `%d` is the unit's own credentials
# directory, where `hive-agent-bao-server-ca` is loaded.
daemonsReadStore = config.services.hyperhive.agent.bao.addr != null;
storeIdentityEnv = {
HIVE_AGENT_NAME = userName;
BAO_ADDR = config.services.hyperhive.agent.bao.addr;
BAO_CLIENT_CERT = config.services.hyperhive.agent.bao.clientCertFile;
BAO_CLIENT_KEY = config.services.hyperhive.agent.bao.clientKeyFile;
BAO_CACERT = "%d/hive-agent-bao-server-ca";
};
in
{
options.services.hyperhive.agent.extraMcpServers = lib.mkOption {
@ -291,6 +302,8 @@ in
description = "bash task runner + MCP daemon for hive-bash";
wantedBy = [ "multi-user.target" ];
before = [ "hive-agent.service" ];
# The live certificate pair exists once ./bao.nix's unit has run.
after = lib.optional daemonsReadStore "hive-agent-bao-identity.service";
# The daemon runs every bash task via `Command::new("bash")` and the
# commands themselves (hive-forge, git, jq, …) resolve from PATH.
# A standalone daemon has no inherited agent PATH, so without this
@ -317,7 +330,13 @@ in
# loose-ends dir paths; `hive_agent_sock::paths::harness_dir`
# panics loudly if HYPERHIVE_HARNESS_DIR is unset rather than
# deriving a fallback, since every service here always gets it.
};
#
# The store identity is what lets the daemon publish each task's
# status and output to the swarm queue as this agent
# (`swarm_term.rs`): without it the daemon logs "bash tasks are not
# published" and the swarm UI's background-tasks list stays empty.
}
// lib.optionalAttrs daemonsReadStore storeIdentityEnv;
serviceConfig = {
ExecStart = "${config.services.hyperhive.agent.packages.hive-bash-daemon}/bin/hive-bash-daemon --http 127.0.0.1:${toString config.services.hyperhive.agent.mcp.bashHttpPort}";
SyslogIdentifier = "hive-bash-daemon";
@ -338,6 +357,11 @@ in
DelegateSubgroup = "daemon";
User = userName;
Group = userName;
}
// lib.optionalAttrs daemonsReadStore {
# Bare id: inherits the credential the container manager passed in,
# the same form ./queue-identity.nix uses.
LoadCredential = [ "hive-agent-bao-server-ca" ];
};
};
@ -360,7 +384,7 @@ in
wantedBy = [ "multi-user.target" ];
before = [ "hive-agent.service" ];
# The live certificate pair exists once ./bao.nix's unit has run.
after = lib.optional subagentReadsStore "hive-agent-bao-identity.service";
after = lib.optional daemonsReadStore "hive-agent-bao-identity.service";
# A subagent task runs its own nested `claude` invocation (via
# `hive-claude`), which needs to resolve `claude` itself off PATH —
# same reasoning as `hive-bash-daemon`'s `path` above, even though
@ -408,14 +432,7 @@ in
# environment stays as is.
BASH_DEFAULT_TIMEOUT_MS = "1800000"; # 30 minutes
}
// lib.optionalAttrs subagentReadsStore {
# Paths and a name only. `%d` is this unit's own credentials directory.
HIVE_AGENT_NAME = userName;
BAO_ADDR = config.services.hyperhive.agent.bao.addr;
BAO_CLIENT_CERT = config.services.hyperhive.agent.bao.clientCertFile;
BAO_CLIENT_KEY = config.services.hyperhive.agent.bao.clientKeyFile;
BAO_CACERT = "%d/hive-agent-bao-server-ca";
};
// lib.optionalAttrs daemonsReadStore storeIdentityEnv;
serviceConfig = {
ExecStart = "${config.services.hyperhive.agent.packages.hive-subagent-daemon}/bin/hive-subagent-daemon --http 127.0.0.1:${toString config.services.hyperhive.agent.mcp.subagentHttpPort}";
SyslogIdentifier = "hive-subagent-daemon";
@ -446,7 +463,7 @@ in
User = userName;
Group = userName;
}
// lib.optionalAttrs subagentReadsStore {
// lib.optionalAttrs daemonsReadStore {
# Bare id: inherits the credential the container manager passed in,
# the same form ./queue-identity.nix uses.
LoadCredential = [ "hive-agent-bao-server-ca" ];