hive-c0re: admin socket server + client (stub dispatch)

This commit is contained in:
müde 2026-05-14 20:49:11 +02:00
parent bb2770856d
commit 0ec54ecf89
5 changed files with 177 additions and 26 deletions

View file

@ -2,3 +2,6 @@
name = "hive-sh4re"
edition.workspace = true
version.workspace = true
[dependencies]
serde.workspace = true

View file

@ -1 +1,54 @@
//! Wire types shared between `hive-c0re` and the in-container harness.
use serde::{Deserialize, Serialize};
/// Requests on the host admin socket (`/run/hyperhive/host.sock`).
///
/// Wire format: one JSON object per line.
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "cmd", rename_all = "snake_case")]
pub enum HostRequest {
/// Create and start a sub-agent container `hive-agent-<name>`.
Spawn { name: String },
/// Stop a managed container (graceful).
Kill { name: String },
/// Apply pending config to a managed container.
Rebuild { name: String },
/// List managed containers.
List,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HostResponse {
pub ok: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub agents: Option<Vec<String>>,
}
impl HostResponse {
pub fn success() -> Self {
Self {
ok: true,
error: None,
agents: None,
}
}
pub fn error(message: impl Into<String>) -> Self {
Self {
ok: false,
error: Some(message.into()),
agents: None,
}
}
pub fn list(agents: Vec<String>) -> Self {
Self {
ok: true,
error: None,
agents: Some(agents),
}
}
}