rebuild button on agent UI (cross-origin POST to dashboard /rebuild)

This commit is contained in:
müde 2026-05-15 15:57:11 +02:00
parent 824914807a
commit f1fd787f17
7 changed files with 42 additions and 6 deletions

View file

@ -29,6 +29,10 @@ pub struct Coordinator {
/// URL of the hyperhive flake (no fragment). Inlined into per-agent
/// `flake.nix` files as `inputs.hyperhive.url`.
pub hyperhive_flake: String,
/// TCP port the host's hive-c0re dashboard listens on. Inlined into
/// each per-agent flake so the agent's web UI can build the right
/// rebuild-button URL pointing back at the dashboard.
pub dashboard_port: u16,
agents: Mutex<HashMap<String, AgentSocket>>,
/// Agents whose lifecycle action (currently just spawn) is in flight.
/// Read by the dashboard to render a spinner; cleared when the action
@ -51,13 +55,14 @@ pub enum TransientKind {
}
impl Coordinator {
pub fn open(db_path: &Path, hyperhive_flake: String) -> Result<Self> {
pub fn open(db_path: &Path, hyperhive_flake: String, dashboard_port: u16) -> Result<Self> {
let broker = Broker::open(db_path).context("open broker")?;
let approvals = Approvals::open(db_path).context("open approvals")?;
Ok(Self {
broker: Arc::new(broker),
approvals: Arc::new(approvals),
hyperhive_flake,
dashboard_port,
agents: Mutex::new(HashMap::new()),
transient: Mutex::new(HashMap::new()),
})