37 lines
1.5 KiB
Rust
37 lines
1.5 KiB
Rust
//! Shared in-container filesystem-path resolution.
|
|
//!
|
|
//! Every process that runs inside an agent container - the harness plus
|
|
//! the out-of-process MCP daemons (bash, matrix, ...) - must resolve the
|
|
//! harness directory layout identically. These helpers live here so the
|
|
//! resolution exists in exactly one place rather than being mirrored
|
|
//! across crates.
|
|
|
|
use std::path::PathBuf;
|
|
|
|
/// Base harness directory for the current agent. Uses `HYPERHIVE_HARNESS_DIR`
|
|
/// if set (injected by the hive-c0re meta flake after the harness/state
|
|
/// split). For pre-split / dev deployments where it isn't set, falls back to
|
|
/// a `harness/` sibling of `HYPERHIVE_STATE_DIR`, and finally to
|
|
/// `/agents/{HIVE_LABEL}/harness` when neither dir env var is present — the
|
|
/// shape the harness derives from its label alone.
|
|
#[must_use]
|
|
pub fn harness_dir() -> PathBuf {
|
|
if let Some(p) = std::env::var_os("HYPERHIVE_HARNESS_DIR") {
|
|
return PathBuf::from(p);
|
|
}
|
|
if let Some(state) = std::env::var_os("HYPERHIVE_STATE_DIR") {
|
|
let state_path = PathBuf::from(&state);
|
|
if let Some(parent) = state_path.parent() {
|
|
return parent.join("harness");
|
|
}
|
|
}
|
|
let label = std::env::var("HIVE_LABEL").unwrap_or_default();
|
|
PathBuf::from(format!("/agents/{label}/harness"))
|
|
}
|
|
|
|
/// Directory where out-of-process MCP daemons write loose-end summary
|
|
/// files (`<name>.json`) for the harness to scan in `get_loose_ends`.
|
|
#[must_use]
|
|
pub fn mcp_loose_ends_dir() -> PathBuf {
|
|
harness_dir().join("mcp-loose-ends")
|
|
}
|