pub struct AgentInstaller { /* private fields */ }Expand description
Installs agents from .leviath-bundle packages.
Implementations§
Source§impl AgentInstaller
impl AgentInstaller
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new installer using the default installation directory.
The install root comes from the shared LEVIATH_HOME-aware resolver
in leviath_core::paths, so this crate installs into exactly the
tree every other component reads.
Sourcepub fn with_install_dir(install_dir: PathBuf) -> Self
pub fn with_install_dir(install_dir: PathBuf) -> Self
Create an installer with a custom installation directory.
Sourcepub fn install(&self, package_path: &Path) -> Result<InstalledAgent>
pub fn install(&self, package_path: &Path) -> Result<InstalledAgent>
Install an agent from a .leviath-bundle file.
Sourcepub fn install_from_bytes(
&self,
name: &str,
data: &[u8],
) -> Result<InstalledAgent>
pub fn install_from_bytes( &self, name: &str, data: &[u8], ) -> Result<InstalledAgent>
Install an agent from in-memory bytes.
name becomes a directory under the install dir, so it must be a single
safe path component. install derives it from file_stem() (which
already strips directories), but this is pub and any future caller
passing a downloaded or user-supplied name would otherwise get a
traversal for free - Path::join does not normalize, and an absolute
name replaces the base entirely.
Sourcepub fn uninstall(&self, agent_name: &str) -> Result<()>
pub fn uninstall(&self, agent_name: &str) -> Result<()>
Uninstall an agent by removing its directory.
Sourcepub fn list_installed(&self) -> Result<Vec<InstalledAgent>>
pub fn list_installed(&self) -> Result<Vec<InstalledAgent>>
List all installed agents.
Sourcepub fn get_installed(&self, name: &str) -> Option<InstalledAgent>
pub fn get_installed(&self, name: &str) -> Option<InstalledAgent>
Get information about a specific installed agent, or None if it is not
installed.
Infallible on purpose, and the signature now says so. A manifest that
cannot be read or parsed still means installed - the directory and the
file are both there - so it reports the agent with whatever metadata it
could recover rather than failing. That is the state you would run
lev remove to fix, and an error here would be the one thing standing
between the user and the fix.
It previously returned anyhow::Result and never once returned Err,
which left its only production caller .unwrap()-ing an infallible
result inside a function that returns Result - a panic waiting for
whoever made this propagate.