haematite-cli 0.21.8

The haematite command: serve a store, its door and Studio, answer MCP, query with jq, and host the store's assistant seat
Documentation
use super::super::Pump;
use serde_json::json;

impl Pump {
    pub(in crate::assistant) async fn fail_session(&mut self, code: &str) -> anyhow::Result<()> {
        let Some(opening) = self.opening.as_mut() else {
            anyhow::bail!("session_failure_without_opening");
        };
        if opening.failed {
            return Ok(());
        }
        opening.failed = true;
        opening.replay.clear();
        let request = opening.id.clone();
        if self.session.id.is_empty() {
            self.session.id = format!("opening-{}", opening.call);
        }
        let conversation = self.session.id.clone();
        self.cancel_pending()?;
        self.say_in(&conversation,json!({"kind":"session_failed","request_id":request,"code":code,"message":code.replace('_'," ")})).await
    }
}