diff --git a/TODO.md b/TODO.md index dc956e7..66fb767 100644 --- a/TODO.md +++ b/TODO.md @@ -120,8 +120,3 @@ Pick anything from here when relevant. Cross-cutting design notes live in `HelperEvent::ContainerCrash` to the manager's inbox so the manager can react (restart, escalate, etc.). -## Cleanup / docs - -- **Debug-only sub-commands.** `hive-ag3nt send/recv` and the analogous - `hive-m1nd send/recv/...` exist only for ops debugging. Move them into a - hidden `debug` sub-command to declutter `--help`, or drop entirely. diff --git a/hive-ag3nt/src/bin/hive-ag3nt.rs b/hive-ag3nt/src/bin/hive-ag3nt.rs index 16b521f..bc5af54 100644 --- a/hive-ag3nt/src/bin/hive-ag3nt.rs +++ b/hive-ag3nt/src/bin/hive-ag3nt.rs @@ -2,7 +2,7 @@ use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use std::time::Duration; -use anyhow::{Result, bail}; +use anyhow::Result; use clap::{Parser, Subcommand}; use hive_ag3nt::events::{Bus, LiveEvent}; use hive_ag3nt::login::{self, LoginState}; @@ -29,10 +29,6 @@ enum Cmd { #[arg(long, default_value_t = 1000)] poll_ms: u64, }, - /// Send a message to another agent. - Send { to: String, body: String }, - /// Pop one message from the inbox. - Recv, /// Run the agent's MCP server on stdio. Spawned by `claude` via /// `--mcp-config`; tools dispatch through `/run/hive/mcp.sock` back into /// the hyperhive broker. @@ -103,17 +99,6 @@ async fn main() -> Result<()> { } } } - Cmd::Send { to, body } => { - let resp: AgentResponse = - client::request(&cli.socket, &AgentRequest::Send { to, body }).await?; - render(&resp)?; - check(&resp) - } - Cmd::Recv => { - let resp: AgentResponse = client::request(&cli.socket, &AgentRequest::Recv).await?; - render(&resp)?; - check(&resp) - } Cmd::Mcp => mcp::serve_agent_stdio(cli.socket).await, } } @@ -192,14 +177,3 @@ async fn inbox_unread(socket: &Path) -> u64 { } } -fn render(resp: &AgentResponse) -> Result<()> { - println!("{}", serde_json::to_string_pretty(resp)?); - Ok(()) -} - -fn check(resp: &AgentResponse) -> Result<()> { - if let AgentResponse::Err { message } = resp { - bail!("{message}"); - } - Ok(()) -} diff --git a/hive-ag3nt/src/bin/hive-m1nd.rs b/hive-ag3nt/src/bin/hive-m1nd.rs index 6798922..d3cbd8d 100644 --- a/hive-ag3nt/src/bin/hive-m1nd.rs +++ b/hive-ag3nt/src/bin/hive-m1nd.rs @@ -1,13 +1,12 @@ //! Manager harness. Talks to the manager socket (bind-mounted from the host -//! at `/run/hive/mcp.sock` inside the `hm1nd` container) using the privileged -//! tool surface. Phase 4 minimum: a CLI to exercise the verbs from a shell, -//! plus a `serve` loop that logs the manager's inbox. +//! at `/run/hive/mcp.sock` inside the `hm1nd` container). Two surfaces: +//! `serve` (long-lived turn loop) and `mcp` (stdio MCP server claude spawns). use std::path::{Path, PathBuf}; use std::sync::{Arc, Mutex}; use std::time::Duration; -use anyhow::{Result, bail}; +use anyhow::Result; use clap::{Parser, Subcommand}; use hive_ag3nt::events::{Bus, LiveEvent}; use hive_ag3nt::login::{self, LoginState}; @@ -32,25 +31,10 @@ enum Cmd { #[arg(long, default_value_t = 1000)] poll_ms: u64, }, - /// Send a message to a sub-agent (or anywhere — the broker doesn't validate). - Send { to: String, body: String }, - /// Pop one message from the manager's inbox. - Recv, - /// Submit a spawn request for the user to approve (creates a pending - /// approval; on approval the host creates + starts the container). - RequestSpawn { name: String }, - /// Kill a sub-agent. - Kill { name: String }, - /// Start a stopped sub-agent. - Start { name: String }, - /// Restart a sub-agent (stop + start). - Restart { name: String }, - /// Submit a config commit on the agent's config repo for user approval. - RequestApplyCommit { agent: String, commit_ref: String }, /// Run the manager MCP server on stdio. Spawned by claude via /// `--mcp-config`; same shape as `hive-ag3nt mcp` but with the - /// manager tool surface (`request_spawn`, `kill`, - /// `request_apply_commit`). + /// manager tool surface (`request_spawn`, `kill`, `start`, `restart`, + /// `request_apply_commit`, `ask_operator`). Mcp, } @@ -101,34 +85,10 @@ async fn main() -> Result<()> { } } } - Cmd::Send { to, body } => one_shot(&cli.socket, ManagerRequest::Send { to, body }).await, - Cmd::Recv => one_shot(&cli.socket, ManagerRequest::Recv).await, - Cmd::RequestSpawn { name } => { - one_shot(&cli.socket, ManagerRequest::RequestSpawn { name }).await - } - Cmd::Kill { name } => one_shot(&cli.socket, ManagerRequest::Kill { name }).await, - Cmd::Start { name } => one_shot(&cli.socket, ManagerRequest::Start { name }).await, - Cmd::Restart { name } => one_shot(&cli.socket, ManagerRequest::Restart { name }).await, - Cmd::RequestApplyCommit { agent, commit_ref } => { - one_shot( - &cli.socket, - ManagerRequest::RequestApplyCommit { agent, commit_ref }, - ) - .await - } Cmd::Mcp => mcp::serve_manager_stdio(cli.socket).await, } } -async fn one_shot(socket: &Path, req: ManagerRequest) -> Result<()> { - let resp: ManagerResponse = client::request(socket, &req).await?; - println!("{}", serde_json::to_string_pretty(&resp)?); - if let ManagerResponse::Err { message } = resp { - bail!("{message}"); - } - Ok(()) -} - async fn serve(socket: &Path, interval: Duration, bus: Bus) -> Result<()> { tracing::info!(socket = %socket.display(), "hive-m1nd serve"); let mcp_config = turn::write_mcp_config(socket).await?;