feat: add set_status MCP tool and status field to whoami/dashboard (closes #325)
This commit is contained in:
parent
6f3b56ad84
commit
fe2933b213
8 changed files with 170 additions and 16 deletions
|
|
@ -220,11 +220,39 @@ async fn dispatch(req: &AgentRequest, agent: &str, coord: &Arc<Coordinator>) ->
|
|||
},
|
||||
}
|
||||
}
|
||||
AgentRequest::Whoami => AgentResponse::Whoami {
|
||||
name: agent.to_owned(),
|
||||
role: "agent".to_owned(),
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
},
|
||||
AgentRequest::Whoami => {
|
||||
let status_text = crate::container_view::read_agent_status_text(agent);
|
||||
AgentResponse::Whoami {
|
||||
name: agent.to_owned(),
|
||||
role: "agent".to_owned(),
|
||||
hyperhive_rev: crate::auto_update::current_flake_rev(&coord.hyperhive_flake),
|
||||
status_text,
|
||||
}
|
||||
}
|
||||
AgentRequest::SetStatus { text } => {
|
||||
let path = crate::coordinator::Coordinator::agent_notes_dir(agent)
|
||||
.join("hyperhive-status");
|
||||
let result = if text.trim().is_empty() {
|
||||
// Empty = clear: remove the file (ignore missing).
|
||||
std::fs::remove_file(&path)
|
||||
.or_else(|e| if e.kind() == std::io::ErrorKind::NotFound {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(e)
|
||||
})
|
||||
} else {
|
||||
std::fs::write(&path, format!("{}\n", text.trim()))
|
||||
};
|
||||
match result {
|
||||
Ok(()) => {
|
||||
// Kick a container rescan so the dashboard updates live.
|
||||
let coord2 = Arc::clone(coord);
|
||||
tokio::spawn(async move { coord2.rescan_containers_and_emit().await });
|
||||
AgentResponse::Ok
|
||||
}
|
||||
Err(e) => AgentResponse::Err { message: format!("set_status write failed: {e}") },
|
||||
}
|
||||
}
|
||||
AgentRequest::CancelLooseEnd { kind, id } => crate::questions::handle_cancel_loose_end(
|
||||
coord, agent, *kind, *id,
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue