Wait for a run to complete and return its output.
Returns a chunked application/json response. While the run is still
executing, the server sends periodic \n heartbeat bytes to keep the
connection alive through proxies and load balancers (AWS ALB, Cloudflare,
etc.). The final chunk is the JSON result. Leading whitespace is ignored
by JSON parsers, so clients can parse the concatenated body normally.
If the run is already in a terminal state, the output is returned immediately with no heartbeat overhead.
Sessions are managed manually (not via Depends) to avoid holding a
pool connection during the long wait.