feat(#1636): infra_admin capability — restart hive-ci/gateway/forge via restart tool

This commit is contained in:
damocles 2026-06-13 11:41:15 +02:00 committed by mara
commit f05031ebe3
6 changed files with 144 additions and 4 deletions

View file

@ -979,7 +979,10 @@ impl AgentServer {
#[tool(
description = "Restart a direct child sub-agent container (stop + start). \
Only succeeds if `name` is a direct child of this agent in the topology \
tree the server enforces this. No approval required."
tree the server enforces this. No approval required. \
Agents holding the `infra_admin` capability may also pass a hive \
infrastructure container name (`hive-ci`, `hive-gateway`, `hive-forge`) \
to restart it directly via the privileged helper."
)]
async fn restart(&self, Parameters(args): Parameters<RestartArgs>) -> String {
let log = format!("{args:?}");
@ -1792,6 +1795,13 @@ fn allowed_capability_tools() -> Vec<String> {
let t = token.trim().to_ascii_lowercase();
match t.as_str() {
"read_host_journal" => tools.push("get_host_journal".to_owned()),
// infra_admin lets an agent restart hive infrastructure
// containers (hive-ci / hive-gateway / hive-forge) through the
// existing `restart` tool. Unlock it here so agents that hold
// the capability without the full `lifecycle` group can still
// call it; c0re re-checks the capability server-side and only
// honours infra-container names via this path.
"infra_admin" => tools.push("restart".to_owned()),
// manage_root_agent / query_agent_state don't expose new MCP
// tools: manage_root_agent gates existing lifecycle tools via
// topology enforcement; query_agent_state unlocks the `agent`