rename HiveServer -> AgentServer per mara's feedback

This commit is contained in:
damocles 2026-06-04 00:11:11 +02:00 committed by mara
commit 3c5abd3c85

View file

@ -8,13 +8,13 @@
//! broker-routed protocol. Unaffected by this module. //! broker-routed protocol. Unaffected by this module.
//! - **MCP stdio** owned by this module — what claude actually speaks. //! - **MCP stdio** owned by this module — what claude actually speaks.
//! //!
//! One `HiveServer { socket, flavor }` with two public type aliases: //! One `AgentServer { socket, flavor }` struct handles both flavors:
//! - `AgentServer` — sub-agent flavor; restricted send allow-list. //! - `Flavor::Agent` — restricted send allow-list, no manager-only tools.
//! - `ManagerServer` — manager flavor; manager-only tools unlocked. //! - `Flavor::Manager` — manager-only tools unlocked via `require_manager()`.
//! `ManagerServer` is a backward-compat type alias for `AgentServer`.
//! //!
//! All tools live in one `#[tool_router] impl HiveServer`; manager-only //! All tools live in one `#[tool_router] impl AgentServer`. Both flavors go
//! tools guard via `require_manager()`. Both go through the same //! through the same `run_tool_envelope` helper so logging stays uniform.
//! `run_tool_envelope` helper so logging + status line stay uniform.
use std::future::Future; use std::future::Future;
use std::path::PathBuf; use std::path::PathBuf;
@ -28,7 +28,7 @@ use rmcp::{
use crate::client; use crate::client;
/// Wire-protocol-agnostic view of a hyperhive socket response. Both flavors /// Wire-protocol-agnostic view of a hyperhive socket response. Both flavors
/// of `HiveServer` convert into this so the tool formatters can be shared. /// of `AgentServer` convert into this so the tool formatters can be shared.
#[derive(Debug)] #[derive(Debug)]
pub enum SocketReply { pub enum SocketReply {
Ok, Ok,
@ -105,7 +105,7 @@ impl From<hive_sh4re::Response> for SocketReply {
} }
/// Write (or remove) the status file in the agent's own `state/` directory. /// Write (or remove) the status file in the agent's own `state/` directory.
/// Called by `HiveServer::set_status` for both agent and manager flavors /// Called by `AgentServer::set_status` for both agent and manager flavors
/// before dispatching the wire `SetStatus` request (which only triggers a /// before dispatching the wire `SetStatus` request (which only triggers a
/// dashboard rescan on the host side — file I/O moved here because the /// dashboard rescan on the host side — file I/O moved here because the
/// harness runs as the agent user and has write access to `state/`, whereas /// harness runs as the agent user and has write access to `state/`, whereas
@ -581,17 +581,15 @@ pub struct RemindArgs {
/// Manager-only tools return a clear error when called from an agent context. /// Manager-only tools return a clear error when called from an agent context.
/// In practice the `--allowedTools` gate prevents that — this is belt-and-suspenders. /// In practice the `--allowedTools` gate prevents that — this is belt-and-suspenders.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct HiveServer { pub struct AgentServer {
socket: PathBuf, socket: PathBuf,
flavor: Flavor, flavor: Flavor,
} }
// Keep the old names as type aliases so any external code that references them /// Backward-compat alias — callers that reference `ManagerServer` by name still compile.
// still compiles without changes. pub type ManagerServer = AgentServer;
pub type AgentServer = HiveServer;
pub type ManagerServer = HiveServer;
impl HiveServer { impl AgentServer {
#[must_use] #[must_use]
pub fn new(socket: PathBuf, flavor: Flavor) -> Self { pub fn new(socket: PathBuf, flavor: Flavor) -> Self {
Self { socket, flavor } Self { socket, flavor }
@ -629,7 +627,7 @@ impl HiveServer {
// Claude Code's permission gate refuses uninlisted MCP tools in // Claude Code's permission gate refuses uninlisted MCP tools in
// non-interactive `--print` mode with "permissions not granted yet". // non-interactive `--print` mode with "permissions not granted yet".
#[tool_router] #[tool_router]
impl HiveServer { impl AgentServer {
#[tool( #[tool(
description = "Send a message to another hyperhive agent (or to the operator). \ description = "Send a message to another hyperhive agent (or to the operator). \
Use this to talk to peers or to surface output for the human at the dashboard." Use this to talk to peers or to surface output for the human at the dashboard."
@ -1476,7 +1474,7 @@ impl HiveServer {
name) or to the operator (recipient `operator`). Use `recv` to drain your inbox one \ name) or to the operator (recipient `operator`). Use `recv` to drain your inbox one \
message at a time. Use `remind` to schedule a future wake-up message for yourself." message at a time. Use `remind` to schedule a future wake-up message for yourself."
)] )]
impl ServerHandler for HiveServer {} impl ServerHandler for AgentServer {}
/// Run an MCP server over stdio for the given flavor. Returns when the client disconnects. /// Run an MCP server over stdio for the given flavor. Returns when the client disconnects.
/// ///
@ -1485,7 +1483,7 @@ impl ServerHandler for HiveServer {}
/// Returns an error if the MCP server fails to initialize or the transport /// Returns an error if the MCP server fails to initialize or the transport
/// encounters a fatal error. /// encounters a fatal error.
pub async fn serve_stdio(socket: PathBuf, flavor: Flavor) -> Result<()> { pub async fn serve_stdio(socket: PathBuf, flavor: Flavor) -> Result<()> {
let server = HiveServer::new(socket, flavor); let server = AgentServer::new(socket, flavor);
let service = server.serve(stdio()).await?; let service = server.serve(stdio()).await?;
service.waiting().await?; service.waiting().await?;
Ok(()) Ok(())
@ -1498,7 +1496,7 @@ pub async fn serve_agent_stdio(socket: PathBuf) -> Result<()> {
/// Convenience wrapper: run the manager MCP server over stdio. /// Convenience wrapper: run the manager MCP server over stdio.
pub async fn serve_manager_stdio(socket: PathBuf) -> Result<()> { pub async fn serve_manager_stdio(socket: PathBuf) -> Result<()> {
let server = HiveServer::new(socket, Flavor::Manager); let server = AgentServer::new(socket, Flavor::Manager);
let service = server.serve(stdio()).await?; let service = server.serve(stdio()).await?;
service.waiting().await?; service.waiting().await?;
Ok(()) Ok(())