refactor(#2464): rename hive-ag3nt crate to hive-agent, collapse lib into main
This commit is contained in:
parent
7b54e7aa50
commit
3f1643c594
57 changed files with 101 additions and 130 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1460,7 +1460,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "fc0fef456e4baa96da950455cd02c081ca953b141298e41db3fc7e36b1da849c"
|
||||
|
||||
[[package]]
|
||||
name = "hive-ag3nt"
|
||||
name = "hive-agent"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
[workspace]
|
||||
resolver = "3"
|
||||
members = [
|
||||
"hive-ag3nt",
|
||||
"hive-agent",
|
||||
"hive-agent-mcp",
|
||||
"hive-agent-wake",
|
||||
"hive-bash-mcp",
|
||||
|
|
|
|||
|
|
@ -1,28 +0,0 @@
|
|||
//! Shared in-container harness code for the sibling `hive-agent` /
|
||||
//! `hive-agent-mcp` / `hive-agent-wake` binaries, which serve every
|
||||
//! agent role (the manager is just an agent role, not a separate set
|
||||
//! of binaries).
|
||||
|
||||
pub mod client;
|
||||
pub mod events;
|
||||
pub mod forge_notify;
|
||||
pub mod harness_state;
|
||||
pub mod identity;
|
||||
pub mod login;
|
||||
pub mod login_session;
|
||||
pub mod mcp_config;
|
||||
pub mod paths;
|
||||
pub mod plugins;
|
||||
pub mod prompt;
|
||||
pub mod serve_common;
|
||||
pub mod stats;
|
||||
pub mod turn;
|
||||
pub mod turn_stats;
|
||||
pub mod vacuum;
|
||||
pub mod web_ui;
|
||||
|
||||
/// Default socket path inside the container — bind-mounted by `hive-c0re`.
|
||||
pub const DEFAULT_SOCKET: &str = "/run/hive/mcp.sock";
|
||||
|
||||
/// Default web UI port — used when `HIVE_PORT` env is unset.
|
||||
pub const DEFAULT_WEB_PORT: u16 = 8042;
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
//!
|
||||
//! Standalone bin crate: the MCP surface (`mcp/`) plus its small support
|
||||
//! modules (socket client, send allow-list, loose-end scanner, path
|
||||
//! resolver) live here rather than in the `hive-ag3nt` harness lib, so the
|
||||
//! resolver) live here rather than in the `hive-agent` harness lib, so the
|
||||
//! server binary doesn't link the whole turn loop.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
//!
|
||||
//! Standalone bin crate: it dials the per-agent MCP socket directly and
|
||||
//! carries its own copy of the retrying request client (below), so it
|
||||
//! does not link the whole `hive-ag3nt` harness lib — a helper author
|
||||
//! does not link the whole `hive-agent` harness lib — a helper author
|
||||
//! wiring up an `extraMcpServers` binary only needs this one small crate.
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
|
@ -66,7 +66,7 @@ async fn main() -> Result<()> {
|
|||
}
|
||||
|
||||
/// Self-contained retrying unix-socket JSON request client. A trimmed
|
||||
/// copy of `hive_ag3nt::client` (no `request_retried` variant — the wake
|
||||
/// copy of `hive_agent::client` (no `request_retried` variant — the wake
|
||||
/// CLI never needs the retry-count) so this bin does not link the harness
|
||||
/// lib. Keeping the retry matters: the socket can be briefly absent while
|
||||
/// hive-c0re restarts under an operator redeploy, and a helper firing a
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "hive-ag3nt"
|
||||
name = "hive-agent"
|
||||
edition.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
|
|
@ -34,8 +34,8 @@ tracing-subscriber.workspace = true
|
|||
[dev-dependencies]
|
||||
tempfile = "3"
|
||||
|
||||
# Three sibling harness binaries for all agents (auto-discovered from
|
||||
# `src/bin/`): `hive-agent` (serve loop), `hive-agent-mcp` (MCP
|
||||
# server), `hive-agent-wake` (wake CLI). Privilege boundary is
|
||||
# Single harness serve-loop binary: `hive-agent` (from `src/main.rs`).
|
||||
# The sibling MCP server + external wake CLI are their own bin crates
|
||||
# now (`hive-agent-mcp`, `hive-agent-wake`). Privilege boundary is
|
||||
# enforced server-side at the socket (tool groups / manager surface).
|
||||
# See `docs/turn-loop.md::Harness binary shape`.
|
||||
|
|
@ -184,11 +184,6 @@ impl EventStore {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn recent(&self, limit: usize) -> rusqlite::Result<Vec<StoredEvent>> {
|
||||
let (events, _, _) = self.page(None, limit)?;
|
||||
Ok(events)
|
||||
}
|
||||
|
||||
/// Fetch up to `limit` events with id < `before_id` (or the most recent
|
||||
/// `limit` events when `before_id` is `None`). Returns
|
||||
/// `(events_oldest_first, min_row_id, has_more)`.
|
||||
|
|
@ -818,17 +813,6 @@ impl Bus {
|
|||
self.tx.subscribe()
|
||||
}
|
||||
|
||||
/// Most recent events, oldest first, capped at `HISTORY_CAPACITY`.
|
||||
/// Drives the terminal pre-fill when the operator opens the agent
|
||||
/// page; without a store (db open failed) this is empty.
|
||||
#[must_use]
|
||||
pub fn history(&self) -> Vec<StoredEvent> {
|
||||
let Some(store) = &self.store else {
|
||||
return Vec::new();
|
||||
};
|
||||
store.recent(HISTORY_CAPACITY).unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Paginated history: up to `limit` events before `before_id`
|
||||
/// (or the most recent `limit` when `before_id` is `None`).
|
||||
/// Returns `(events_oldest_first, min_row_id, has_more)`.
|
||||
|
|
@ -48,25 +48,6 @@ pub fn swarm_name() -> Option<String> {
|
|||
non_empty_env("HYPERHIVE_SWARM_NAME")
|
||||
}
|
||||
|
||||
/// One peer hive in the same swarm. Parsed from `HYPERHIVE_PEERS`.
|
||||
#[derive(Debug, Clone, serde::Deserialize)]
|
||||
pub struct PeerHive {
|
||||
pub domain: String,
|
||||
pub cert_fingerprint: Option<String>,
|
||||
}
|
||||
|
||||
/// Peer hives in the same swarm, parsed from `HYPERHIVE_PEERS` env var
|
||||
/// (JSON array of `{domain, cert_fingerprint}` objects, emitted by the
|
||||
/// c0re NixOS module from `services.hyperhive.swarm.peers`). Returns
|
||||
/// empty vec on single-hive deploys (env var absent).
|
||||
#[must_use]
|
||||
pub fn peers() -> Vec<PeerHive> {
|
||||
env::var("HYPERHIVE_PEERS")
|
||||
.ok()
|
||||
.and_then(|s| serde_json::from_str(&s).ok())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
/// Hive-qualified agent identity. When the hive domain is configured, returns
|
||||
/// `${label}@${domain}` (e.g. `iris@darkest.space`); when not, returns just
|
||||
/// the short label so callers can render a single string regardless of
|
||||
|
|
@ -5,17 +5,43 @@
|
|||
//! loop points claude at) and `hive-agent-wake` (external wake CLI).
|
||||
//! Architecture lives in
|
||||
//! [`docs/turn-loop.md::Harness binary shape`](../../../docs/turn-loop.md).
|
||||
//!
|
||||
//! Single bin crate: the module tree below (formerly this crate's `lib.rs`,
|
||||
//! before lib + bin were collapsed into one) plus the serve loop.
|
||||
|
||||
mod client;
|
||||
mod events;
|
||||
mod forge_notify;
|
||||
mod harness_state;
|
||||
mod identity;
|
||||
mod login;
|
||||
mod login_session;
|
||||
mod mcp_config;
|
||||
mod paths;
|
||||
mod plugins;
|
||||
mod prompt;
|
||||
mod serve_common;
|
||||
mod stats;
|
||||
mod turn;
|
||||
mod turn_stats;
|
||||
mod vacuum;
|
||||
mod web_ui;
|
||||
|
||||
/// Default socket path inside the container — bind-mounted by `hive-c0re`.
|
||||
const DEFAULT_SOCKET: &str = "/run/hive/mcp.sock";
|
||||
|
||||
/// Default web UI port — used when `HIVE_PORT` env is unset.
|
||||
const DEFAULT_WEB_PORT: u16 = 8042;
|
||||
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::events::{Bus, LiveEvent, TurnState};
|
||||
use crate::login::LoginState;
|
||||
use crate::turn_stats::TurnStats;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use hive_ag3nt::events::{Bus, LiveEvent, TurnState};
|
||||
use hive_ag3nt::login::{self, LoginState};
|
||||
use hive_ag3nt::turn_stats::TurnStats;
|
||||
use hive_ag3nt::{DEFAULT_SOCKET, DEFAULT_WEB_PORT, client, plugins, serve_common, turn, web_ui};
|
||||
use hive_sh4re::{AgentRequest, AgentResponse, HelperEvent, SYSTEM_SENDER};
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
@ -72,7 +98,7 @@ fn log_system_event(bus: &Bus, from: &str, body: &str) {
|
|||
/// Falls back to `<unknown>` when `HIVE_LABEL` is missing so a
|
||||
/// misconfigured harness still produces a parseable line.
|
||||
fn format_turn_failure(err: &anyhow::Error) -> String {
|
||||
let who = hive_ag3nt::identity::qualified_label();
|
||||
let who = crate::identity::qualified_label();
|
||||
let who = if who.is_empty() {
|
||||
"<unknown>".to_owned()
|
||||
} else {
|
||||
|
|
@ -87,7 +113,7 @@ fn format_turn_failure(err: &anyhow::Error) -> String {
|
|||
/// the role-specific `Wake` request — the sentinel itself is wire-
|
||||
/// agnostic so this helper lives outside both surfaces.
|
||||
fn consume_continue_sentinel() -> bool {
|
||||
let sentinel = hive_ag3nt::paths::state_dir().join("hyperhive-continue");
|
||||
let sentinel = crate::paths::state_dir().join("hyperhive-continue");
|
||||
if !sentinel.exists() {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -374,11 +400,11 @@ async fn serve_main<S: Surface>(socket: &Path, poll_ms: u64) -> Result<()> {
|
|||
for failure in plugins::install_configured().await {
|
||||
S::send_to_parent(socket, failure).await;
|
||||
}
|
||||
tokio::spawn(hive_ag3nt::forge_notify::run(socket.to_path_buf()));
|
||||
tokio::spawn(crate::forge_notify::run(socket.to_path_buf()));
|
||||
// Agent-side cleanup of this agent's own harness artifacts (completed
|
||||
// bash-task files + verbose event rows). Runs here, not host-side in
|
||||
// hive-c0re, because the files are agent-owned — see `vacuum` module docs.
|
||||
tokio::spawn(hive_ag3nt::vacuum::run());
|
||||
tokio::spawn(crate::vacuum::run());
|
||||
// Log web_ui::serve's error instead of dropping it. A bare
|
||||
// `tokio::spawn(web_ui::serve(...))` discards the JoinHandle, so
|
||||
// any Err (e.g. EACCES from `bind_unix` when HIVE_WEB_SOCKET points
|
||||
|
|
@ -171,7 +171,7 @@ mod tests {
|
|||
// no file open at compile, so this still doesn't pull
|
||||
// `prompts/` into the build hash.
|
||||
// The combined effect is that the flake's `cleanSrc` no longer
|
||||
// unions `./hive-ag3nt/prompts` — tweaks to system.md don't bust
|
||||
// unions `./hive-agent/prompts` — tweaks to system.md don't bust
|
||||
// the cargo cache anymore.
|
||||
static PRODUCTION_TEMPLATE: LazyLock<String> = LazyLock::new(|| {
|
||||
let path = match std::env::var("HIVE_ASSETS_DIR") {
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue