feat(#791): add request_init_config + request_apply_commit to AgentServer (topology-scoped)
This commit is contained in:
parent
dacd83f278
commit
3fa31a414f
4 changed files with 161 additions and 30 deletions
|
|
@ -1047,6 +1047,83 @@ impl AgentServer {
|
|||
})
|
||||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `approvals` tool group
|
||||
// is configured for the agent (`HIVE_TOOL_GROUPS` contains `approvals`).
|
||||
// hive-c0re performs a topology check server-side: only direct children
|
||||
// of the calling agent are accepted; all other names are rejected.
|
||||
#[tool(
|
||||
description = "Initialise a brand-new direct child agent's proposed config repo and \
|
||||
queue an `InitConfig` approval for the operator to review. Requires the `approvals` \
|
||||
tool group. `name` must be a direct child of this agent in the topology tree. \
|
||||
Fails if a config repo for that child already exists — use `request_apply_commit` \
|
||||
to update an existing agent's config. On approval hive-c0re seeds \
|
||||
`/agents/<name>/config/agent.nix` with the default template so you can \
|
||||
customise it and then call `request_apply_commit` with the commit sha."
|
||||
)]
|
||||
async fn request_init_config(
|
||||
&self,
|
||||
Parameters(args): Parameters<RequestInitConfigArgs>,
|
||||
) -> String {
|
||||
let log = format!("{args:?}");
|
||||
let name = args.name.clone();
|
||||
run_tool_envelope("request_init_config", log, async move {
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_sh4re::AgentRequest::RequestInitConfig {
|
||||
name: args.name,
|
||||
description: args.description,
|
||||
})
|
||||
.await;
|
||||
annotate_retries(
|
||||
format_ack(
|
||||
resp,
|
||||
"request_init_config",
|
||||
format!("init_config approval queued for {name}"),
|
||||
),
|
||||
retries,
|
||||
)
|
||||
})
|
||||
.await
|
||||
}
|
||||
|
||||
// IMPORTANT: this tool is only available when the `approvals` tool group
|
||||
// is configured for the agent (`HIVE_TOOL_GROUPS` contains `approvals`).
|
||||
// hive-c0re performs a topology check server-side: only direct children
|
||||
// of the calling agent are accepted; all other names are rejected.
|
||||
#[tool(
|
||||
description = "Submit a config change for a direct child agent, queued for operator \
|
||||
approval. Requires the `approvals` tool group. `agent` must be a direct child \
|
||||
of this agent in the topology tree. Pass a commit sha (7-40 hex chars, full or \
|
||||
short) from that agent's proposed config repo — branch/tag names like `main` are \
|
||||
rejected, the approval pins the exact commit. On approval hive-c0re rebuilds \
|
||||
the container with the new config."
|
||||
)]
|
||||
async fn request_apply_commit(
|
||||
&self,
|
||||
Parameters(args): Parameters<RequestApplyCommitArgs>,
|
||||
) -> String {
|
||||
let log = format!("{args:?}");
|
||||
let agent = args.agent.clone();
|
||||
let commit_ref = args.commit_ref.clone();
|
||||
run_tool_envelope("request_apply_commit", log, async move {
|
||||
let (resp, retries) = self
|
||||
.dispatch(hive_sh4re::AgentRequest::RequestApplyCommit {
|
||||
agent: args.agent,
|
||||
commit_ref: args.commit_ref,
|
||||
description: args.description,
|
||||
})
|
||||
.await;
|
||||
annotate_retries(
|
||||
format_ack(
|
||||
resp,
|
||||
"request_apply_commit",
|
||||
format!("apply approval queued for {agent} @ {commit_ref}"),
|
||||
),
|
||||
retries,
|
||||
)
|
||||
})
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
#[tool_handler(
|
||||
|
|
|
|||
Loading…
Reference in a new issue