feat(#1178): add kill + update tools to AgentServer (topology-scoped)
This commit is contained in:
parent
29c7f64bd3
commit
2722e1548c
3 changed files with 98 additions and 0 deletions
|
|
@ -966,6 +966,48 @@ impl AgentServer {
|
|||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `lifecycle` tool group
|
||||
// is granted to this agent. hive-c0re enforces the topology check
|
||||
// server-side: the call is rejected unless `name` is a direct child.
|
||||
#[tool(
|
||||
description = "Stop a direct child sub-agent container (graceful). \
|
||||
Only succeeds if `name` is a direct child of this agent in the topology \
|
||||
tree — the server enforces this. No approval required. \
|
||||
State dir is kept; recreating the agent reuses prior config + credentials."
|
||||
)]
|
||||
async fn kill(&self, Parameters(args): Parameters<KillArgs>) -> String {
|
||||
let log = format!("{args:?}");
|
||||
let name = args.name.clone();
|
||||
run_tool_envelope("kill", log, async move {
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_sh4re::AgentRequest::Kill { name: args.name })
|
||||
.await;
|
||||
annotate_retries(format_ack(resp, "kill", format!("killed {name}")), retries)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `lifecycle` tool group
|
||||
// is granted to this agent. hive-c0re enforces the topology check
|
||||
// server-side: the call is rejected unless `name` is a direct child.
|
||||
#[tool(
|
||||
description = "Rebuild a direct child sub-agent: re-applies the current hyperhive \
|
||||
flake + agent.nix and restarts the container. Only succeeds if `name` is a direct \
|
||||
child of this agent in the topology tree — the server enforces this. \
|
||||
No approval required. Idempotent — use when a child needs its config reapplied."
|
||||
)]
|
||||
async fn update(&self, Parameters(args): Parameters<UpdateArgs>) -> String {
|
||||
let log = format!("{args:?}");
|
||||
let name = args.name.clone();
|
||||
run_tool_envelope("update", log, async move {
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_sh4re::AgentRequest::Update { name: args.name })
|
||||
.await;
|
||||
annotate_retries(format_ack(resp, "update", format!("updated {name}")), retries)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is capability-gated (`read_host_journal`).
|
||||
// It is added to `--allowedTools` by `allowed_capability_tools` only
|
||||
// when `HIVE_CAPABILITIES` contains `read_host_journal`. hive-c0re
|
||||
|
|
|
|||
Loading…
Reference in a new issue