writer
Shared helper for publishing events through Mastra’s
ctx.writer. Centralizes the “the downstream stream may already
be closed, don’t take the whole tool down” pattern that the
Genie agent and chart tool both need.
Failures are logged at warn (a persistently-closed writer is
the most likely culprit when events go missing client-side) but
swallowed so a cancelled request or a client that navigated
away can’t crash a tool mid-flight.