Phase 4: hive-m1nd harness + manager nixos template; devshell sqlite
This commit is contained in:
parent
aa67e5a481
commit
17092961a2
5 changed files with 159 additions and 28 deletions
|
|
@ -46,12 +46,14 @@ async fn main() -> Result<()> {
|
|||
match cli.cmd {
|
||||
Cmd::Serve { poll_ms } => serve(&cli.socket, Duration::from_millis(poll_ms)).await,
|
||||
Cmd::Send { to, body } => {
|
||||
let resp = client::request(&cli.socket, AgentRequest::Send { to, body }).await?;
|
||||
let resp: AgentResponse =
|
||||
client::request(&cli.socket, &AgentRequest::Send { to, body }).await?;
|
||||
render(&resp)?;
|
||||
check(&resp)
|
||||
}
|
||||
Cmd::Recv => {
|
||||
let resp = client::request(&cli.socket, AgentRequest::Recv).await?;
|
||||
let resp: AgentResponse =
|
||||
client::request(&cli.socket, &AgentRequest::Recv).await?;
|
||||
render(&resp)?;
|
||||
check(&resp)
|
||||
}
|
||||
|
|
@ -61,7 +63,8 @@ async fn main() -> Result<()> {
|
|||
async fn serve(socket: &Path, interval: Duration) -> Result<()> {
|
||||
tracing::info!(socket = %socket.display(), "hive-ag3nt serve");
|
||||
loop {
|
||||
match client::request(socket, AgentRequest::Recv).await {
|
||||
let recv: Result<AgentResponse> = client::request(socket, &AgentRequest::Recv).await;
|
||||
match recv {
|
||||
Ok(AgentResponse::Message { from, body }) => {
|
||||
tracing::info!(%from, %body, "inbox");
|
||||
// Don't auto-reply to echoes — prevents infinite ping-pong when
|
||||
|
|
@ -69,15 +72,15 @@ async fn serve(socket: &Path, interval: Duration) -> Result<()> {
|
|||
// manager's job (Phase 4+).
|
||||
if !body.starts_with("echo: ") {
|
||||
let reply = compute_reply(&body).await;
|
||||
if let Err(e) = client::request(
|
||||
let send: Result<AgentResponse> = client::request(
|
||||
socket,
|
||||
AgentRequest::Send {
|
||||
&AgentRequest::Send {
|
||||
to: from,
|
||||
body: reply,
|
||||
},
|
||||
)
|
||||
.await
|
||||
{
|
||||
.await;
|
||||
if let Err(e) = send {
|
||||
tracing::warn!(error = ?e, "send reply failed");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue