pub fn parse_envelope(raw: &str) -> Result<Envelope, DispatchError>Expand description
Extract a Warble render envelope from raw agent output. The agent is asked to emit only the JSON envelope, but models routinely wrap it in ```json fences or surround it with a sentence. This is deliberately forgiving:
- try to parse the whole string as JSON;
- else pull the contents of the first
json /fenced block; - else scan for the first balanced
{...}object that contains a top-level"blocks"key.
Returns an error if none of those yield an object with a blocks array.