hyperhive/hive-agent-mcp/src/paths.rs

19 lines
828 B
Rust

//! Per-agent path resolution for this MCP server. Self-contained (mirrors
//! the sibling helper daemons' own `paths.rs`) so the bin does not link the
//! harness lib just to resolve the agent's state dir. Only the one helper
//! the MCP server needs lives here.
use std::path::PathBuf;
/// Durable state directory for the current agent. Reads `HYPERHIVE_STATE_DIR`
/// first (always set by the meta flake to `/agents/{label}/state`); falls back
/// to the same pattern derived from `HIVE_LABEL` for dev/test environments
/// where the env var may not be set.
#[must_use]
pub fn state_dir() -> PathBuf {
if let Some(p) = std::env::var_os("HYPERHIVE_STATE_DIR") {
return PathBuf::from(p);
}
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
PathBuf::from(format!("/agents/{label}/state"))
}