haematite-cli 0.21.7

The haematite command: serve a store, its door and Studio, answer MCP, query with jq, and host the store's assistant seat
Documentation
use std::path::PathBuf;
use std::process::ExitCode;

/// Builds the production harness command for an isolated adapter probe.
///
/// # Errors
/// Returns the same seat, home, environment and executable refusals as a launch.
#[cfg(feature = "test-support")]
pub fn probe_command(path: &std::path::Path) -> anyhow::Result<tokio::process::Command> {
    super::host::command(&super::config::Seat::load(path)?)
}

/// Run the Lys-launched assistant seat.
pub fn run(mut args: impl Iterator<Item = String>) -> ExitCode {
    let result = (|| {
        anyhow::ensure!(
            args.next().as_deref() == Some("run") && args.next().as_deref() == Some("--config"),
            "usage: haematite assistant run --config <seat.json>"
        );
        let path = PathBuf::from(
            args.next()
                .ok_or_else(|| anyhow::anyhow!("seat_config_required"))?,
        );
        anyhow::ensure!(args.next().is_none(), "assistant_unexpected_argument");
        let seat = super::config::Seat::load(&path)?;
        let runtime = tokio::runtime::Builder::new_current_thread()
            .enable_all()
            .build()?;
        let result = runtime.block_on(super::host::serve(&seat));
        runtime.shutdown_timeout(std::time::Duration::from_secs(2));
        result
    })();
    match result {
        Ok(status) => ExitCode::from(u8::try_from(status).unwrap_or(1)),
        Err(error) => {
            eprintln!("haematite assistant: {error}");
            ExitCode::FAILURE
        }
    }
}