Watch
0
0
Fork
You've already forked hyperhive
0
hyperhive/hive-sh4re/src/assets.rs
atlas 553ed8376c archetypes: build an archetype agent from its archetype's module on the hive
The hive reads the agent-archetype key when it provisions and rebuilds an
agent and keeps it in swarm-agent-archetypes.json. For an archetype agent
the meta flake has no agent-<name> input and mkAgent imports
hyperhive.hyperhiveArchetypes.<name>.module; provisioning, rebuilds, the
meta-input cascade, a deploy's rev and the startup migration skip the
config repos. The harness gets HIVE_ARCHETYPE and the system prompt says
the agent has no config repo. The create form sends the picked archetype.
Adds the android-dev built-in.

Refs #5386
2026-10-17 16:27:21 +02:00

51 lines
2.1 KiB
Rust

//! Resolve the on-disk path to hyperhive's static assets (branding +
//! claude prompts). Single source of truth for both the host daemon
//! (`hive-c0re`) and the in-container harness binaries so they agree
//! on the lookup contract.
//!
//! At runtime, the path is read from `$HIVE_ASSETS_DIR`. Setting it is
//! the deployment's job; this crate's contract is only that it names a
//! directory laid out like the packaged assets.
//! For `cargo run` outside nix, set it yourself:
//!
//! ```sh
//! HIVE_ASSETS_DIR=$(pwd)/dev-assets cargo run ...
//! ```
//!
//! where `dev-assets/` mirrors the nix output's `branding/` + `prompts/`
//! layout.
//!
//! Each crate that wants a specific asset goes through one of the
//! typed helpers (currently just `prompt_template()` — the branding
//! SVG used to live here too; the per-agent icon now 404s server-side
//! when unconfigured and falls back to a frontend-bundled default
//! client-side instead of a server-resolved runtime path, see
//! `hive-agent::web_ui::screen::serve_icon`) so the lookup contract is
//! centralised. Missing files panic at first call with a clear "set
//! `HIVE_ASSETS_DIR` + put the file at …" message.
use std::path::PathBuf;
/// Read `$HIVE_ASSETS_DIR`. Panics with a clear remediation message
/// when unset — every code path that calls into this module is one
/// the binary cannot run without, so a hard early failure is the
/// right shape.
fn dir() -> PathBuf {
match std::env::var("HIVE_ASSETS_DIR") {
Ok(v) if !v.is_empty() => PathBuf::from(v),
_ => panic!(
"HIVE_ASSETS_DIR is not set. A deployment sets it; when \
running a binary outside one, point it at a directory \
with `branding/` and `prompts/` subdirs. See \
hive-sh4re/src/assets.rs for the contract.",
),
}
}
/// `$HIVE_ASSETS_DIR/prompts/system.md` — the claude system prompt
/// template. `hive-agent::prompt::render` filters the role and config markers
/// inside it per agent / manager flavor and per custom / archetype agent.
#[must_use]
pub fn prompt_template() -> PathBuf {
dir().join("prompts/system.md")
}