fn extract_json_object(raw: &str) -> Option<&str>Expand description
Parses one VLM reply in RTDL envelope form.
The model must emit a JSON object whose only keys are exactly
content, rtdl_description, rtdl, and task_update. See
rtdl_protocol.md for the field contract.
Extract the first balanced top-level JSON object from raw, ignoring any
prose before or after it (e.g. a narration line the model emitted before the
JSON, or a trailing comment). Returns the {...} slice, or None if there
is no { or no matching close brace.
Brace depth is counted only outside JSON string literals, so braces inside
strings don’t affect it. Scanning by bytes is UTF-8-safe here because {,
}, ", and \ are all ASCII and never collide with multibyte
continuation bytes (which are all >= 0x80).