runs.wait_for_completion() in Python or
runs.waitForCompletion() in TypeScript. It polls the lightweight status
endpoint instead of downloading every event.
For a custom UI, poll runs.events() with the previous cursor. Read status
before fetching events so that the final fetch happens after you observe a
terminal state, and drain all hasMore pages before stopping: