ReferenceAsk
Remy Reference/agent/events.grant
?

events.grant

Mints a subscribe token for an explicit list of channels, after your own authorization checks.
events.grant(channels, { ttlSeconds? }) Promise<EventGrantResult>

Mints the token a client uses to subscribe, for an explicit list of channels named exactly (up to 100, no wildcards). Call it from one of your own methods and do your authorization there first, because the grant is the entire subscribe-side authorization: the platform delivers the named channels to whoever holds the token. Return the result from your method and hand the token to the client. The lifetime doubles as the revocation window, so a shorter TTL tightens how quickly revoked access stops at the cost of re-minting more often; per-user channels with publish-time fan-out stop a removed member immediately regardless.

Parameters
channels
string | string[]
RequiredThe exact channels this token may receive, up to 100. Whoever holds the token receives them, so do your authorization first.
ttlSeconds
number
Grant lifetime in seconds, clamped to between 60 and 3600 (default 900). This is also the stream's lifetime and your revocation window: at expiry the client re-mints through this method, re-running your checks.
The subscribe door is one of your methods
import { auth, events } from '@mindstudio-ai/agent';

export async function watchInbox() {
  auth.requireRole('member');                    // your checks first
  return await events.grant(`user:${auth.userId}`);
}