Realtime
import { mindstudio } from '@mindstudio-ai/agent';Server-to-client push, with no WebSocket to run and no socket server to operate. Backend code publishes a small payload to a named channel, and any client subscribed to that channel receives it instantly over a stream the platform holds open. There is no polling loop against your own backend and no sandbox held open waiting for something to happen. This is how a dashboard updates the moment a job finishes, a notification arrives while the user is on another page, and a second tab stays in step with the first.
The model is two verbs and one rule. events.publish sends a payload to one or many channels from anywhere on the backend: a method, a scheduled job, a webhook handler. events.grant mints the subscribe token. Call it from one of your own methods, after your own authorization checks, because the grant is the entire subscribe-side authorization: the platform delivers to whoever holds the token. The rule that follows is that a channel is an audience, and a method decides who is in it. Never put two users' data on one channel. For a membership-gated audience like a chat room or a notification feed, give each member their own channel and fan out at publish time, so removing someone stops their events immediately rather than at the next token expiry.
Events are nudges, delivered at most once. Nothing is buffered while a client is away and nothing is replayed when it returns, so the discipline is to subscribe for speed and reconcile for truth: fetch current state whenever the stream connects. A grant's lifetime is also its revocation window; at expiry the stream closes and the client re-mints through your method, which re-runs your checks. Publishes and grants are scoped to their world automatically, so a development session can never reach a live subscriber. Payloads are capped at 32k serialized characters, so you publish an id and let the client fetch the record, not the record itself. In a Remy web app the Interface SDK's events client consumes the grant for you and manages reconnection; any other client subscribes directly over server-sent events at the app's own /_/events endpoint, carrying the grant token as a bearer credential. This is distinct from streaming a single method's progress to its caller: events reach clients that were never part of the call at all.