diff --git a/hive-ag3nt/src/bin/hive.rs b/hive-ag3nt/src/bin/hive.rs index 5923a846..d518e1e1 100644 --- a/hive-ag3nt/src/bin/hive.rs +++ b/hive-ag3nt/src/bin/hive.rs @@ -55,12 +55,13 @@ enum Cmd { /// `--mcp-config`; tools dispatch through `/run/hive/mcp.sock` back /// into the hyperhive broker. Mcp, - /// Agent-only: inject a wake-up event into this agent's inbox so - /// the next turn fires with the given body. Intended for extra MCP - /// servers / helpers (matrix bridge, scraper, webhook listener) - /// that need to nudge claude on external events. Refused when - /// `HIVE_ROLE=manager` — the manager surface has no `Wake` - /// equivalent. + /// Inject a wake-up event into this harness's inbox so the next + /// turn fires with the given body. Intended for extra MCP servers + /// / helpers (matrix bridge, scraper, webhook listener, etc.) that + /// need to nudge claude on external events. Available on both + /// agent and manager roles — closes #693, mirrors the + /// `AgentRequest::Wake` / `ManagerRequest::Wake` pair already on + /// the wire. Wake { #[arg(long)] from: String, @@ -102,8 +103,8 @@ async fn main() -> Result<()> { (Role::Agent, Cmd::Mcp) => mcp::serve_agent_stdio(cli.socket).await, (Role::Manager, Cmd::Mcp) => mcp::serve_manager_stdio(cli.socket).await, (Role::Agent, Cmd::Wake { from, body }) => agent_wake(&cli.socket, from, body).await, - (Role::Manager, Cmd::Wake { .. }) => { - bail!("wake is agent-only — manager has no equivalent surface") + (Role::Manager, Cmd::Wake { from, body }) => { + manager_wake(&cli.socket, from, body).await } } } @@ -702,3 +703,20 @@ async fn manager_post_turn_counts(socket: &Path) -> (Option, Option) { }; (threads, reminders) } + +async fn manager_wake(socket: &Path, from: String, body: String) -> Result<()> { + let body = if body == "-" { + let mut buf = String::new(); + std::io::Read::read_to_string(&mut std::io::stdin(), &mut buf)?; + buf + } else { + body + }; + let resp: ManagerResponse = + client::request(socket, &ManagerRequest::Wake { from, body }).await?; + match resp { + ManagerResponse::Ok => Ok(()), + ManagerResponse::Err { message } => anyhow::bail!("wake: {message}"), + other => anyhow::bail!("wake: unexpected response {other:?}"), + } +}