Phase 6a: per-container web UI (axum); per-agent port hashed from name

This commit is contained in:
müde 2026-05-14 23:39:06 +02:00
parent 14cb107125
commit d0f954bbc1
9 changed files with 112 additions and 4 deletions

View file

@ -3,7 +3,7 @@ use std::time::Duration;
use anyhow::{Result, bail};
use clap::{Parser, Subcommand};
use hive_ag3nt::{DEFAULT_SOCKET, client};
use hive_ag3nt::{DEFAULT_SOCKET, DEFAULT_WEB_PORT, client, web_ui};
use hive_sh4re::{AgentRequest, AgentResponse};
use tokio::process::Command;
@ -44,7 +44,19 @@ async fn main() -> Result<()> {
let cli = Cli::parse();
match cli.cmd {
Cmd::Serve { poll_ms } => serve(&cli.socket, Duration::from_millis(poll_ms)).await,
Cmd::Serve { poll_ms } => {
let port = std::env::var("HIVE_PORT")
.ok()
.and_then(|s| s.parse::<u16>().ok())
.unwrap_or(DEFAULT_WEB_PORT);
let label = std::env::var("HIVE_LABEL").unwrap_or_else(|_| "hive-ag3nt".into());
tokio::spawn(async move {
if let Err(e) = web_ui::serve(label, port).await {
tracing::error!(error = ?e, "web ui failed");
}
});
serve(&cli.socket, Duration::from_millis(poll_ms)).await
}
Cmd::Send { to, body } => {
let resp: AgentResponse =
client::request(&cli.socket, &AgentRequest::Send { to, body }).await?;