Signature
for await.
The events
In order:Electron is the only SDK with a
cancelled terminal event. Elsewhere a cancelled generation
simply stops. The SDK never fabricates a successful completed.Where errors surface
Preflight failures throw from the call: no model available, bad options. A failure during generation arrives as afailed event, so a window can render a retry without a try/catch
around the loop.
Streaming into the renderer
Generation usually runs in the utility host while the text belongs on screen. Forward the deltas rather than the whole result:Cancelling
Break out of the loop. That produces acancelled terminal event rather than an error.