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

60 lines
1.9 KiB
Rust

//! Per-agent filesystem paths used by `hive-bash-daemon`.
//!
//! All paths are overridable via env vars so the operator can redirect
//! them in agent.nix when needed.
use std::path::PathBuf;
/// Base harness directory. Shared resolution lives in
/// `hive_agent_sock::paths::harness_dir` so the harness + every MCP
/// daemon agree on the layout. Re-exported here as the base for the
/// per-agent artifact paths below.
#[must_use]
pub fn harness_dir() -> PathBuf {
hive_agent_sock::paths::harness_dir()
}
/// Base directory for task files.
#[must_use]
pub fn tasks_dir() -> PathBuf {
harness_dir().join("bash-tasks")
}
/// Per-agent turn-stats sqlite — the harness writes one row per claude
/// turn here; the runner appends normalised bash-command heads to its
/// `bash_commands` table for the /stats "favorite tools" view.
#[must_use]
pub fn turn_stats_db() -> PathBuf {
harness_dir().join("hyperhive-turn-stats.sqlite")
}
/// The harness-served in-agent todo socket (loose-ends v2). The runner
/// pushes bash-task todos here — `upsert_todo` while a task is active,
/// a keyless `done` todo on completion — instead of firing a direct
/// c0re wake. Override via `HIVE_AGENT_SOCKET`; mirrors the path the
/// harness binds (`agent-service.nix`) and the matrix producer dials.
#[must_use]
pub fn agent_socket() -> PathBuf {
std::env::var_os("HIVE_AGENT_SOCKET").map_or_else(
|| PathBuf::from(hive_agent_sock::DEFAULT_AGENT_SOCKET),
PathBuf::from,
)
}
/// Full path for a task's JSON metadata file.
#[must_use]
pub fn task_json(id: &str) -> PathBuf {
tasks_dir().join(format!("{id}.json"))
}
/// Full path for a task's captured stdout.
#[must_use]
pub fn task_out(id: &str) -> PathBuf {
tasks_dir().join(format!("{id}.out"))
}
/// Full path for a task's captured stderr.
#[must_use]
pub fn task_err(id: &str) -> PathBuf {
tasks_dir().join(format!("{id}.err"))
}