//! Per-agent filesystem paths used by both `hive-bash-daemon` and the //! stdio MCP bridge. //! //! All paths are overridable via env vars so the operator can redirect //! them in agent.nix when needed. use std::path::PathBuf; /// Default unix socket path the daemon listens on inside the agent /// container. Lives under systemd's `RuntimeDirectory=hive-bash` /// (a tmpfs path that disappears on container restart — the daemon /// recreates the socket on its own boot) so the agent unix user can /// bind without root in `/run`. pub const DEFAULT_DAEMON_SOCKET: &str = "/run/hive-bash/socket"; /// Resolve the daemon's unix socket path. Override via `HIVE_BASH_SOCKET`. #[must_use] pub fn daemon_socket() -> PathBuf { std::env::var_os("HIVE_BASH_SOCKET") .map_or_else(|| PathBuf::from(DEFAULT_DAEMON_SOCKET), PathBuf::from) } /// Base harness directory. Shared resolution lives in /// `hive_sh4re::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_sh4re::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") } /// Hyperhive control socket — the daemon writes wake signals here so /// the harness drives a new claude turn on bash task completion. /// Mirrors the path used by `forge_notify` and `hive-matrix-mcp`. #[must_use] pub fn hyperhive_socket() -> PathBuf { std::env::var_os("HIVE_CONTROL_SOCKET") .map_or_else(|| PathBuf::from("/run/hive/mcp.sock"), PathBuf::from) } /// Directory where MCP daemons write loose-end summary files for the harness. /// Each daemon writes `.json` here; the harness scans the dir in /// `get_loose_ends` to surface active work from all MCPs generically. #[must_use] pub fn mcp_loose_ends_dir() -> PathBuf { hive_sh4re::paths::mcp_loose_ends_dir() } /// 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")) }