Room
Room: a realtime room's server side. Publish to the pages in it, see who's there, ask them, and mint a token for a
page to join (the TypeScript SDK's Room.join).
Rooms are named by what they're about: workflow:{id} (everyone who may open the workflow) and owner (your own
open tabs, as a signed-in person). Publishing and asking need edit access to a workflow's room; an event you publish
names you (from), where NoClick's own events name nobody.
class RoomA room by its name (workflow:{id}, owner). Nothing is read until you call a method.
| name | string |
membersstatic
static members(
name: string,
options?: { client?: NoClick },
): Promise<RoomMember[]>Who is in the room now, read through the API (no socket needed).
Every member: the pages in the room, and the members NoClick holds (server).
history
history(
options?: { since?: string | null; client?: NoClick },
): Promise<{ events: RoomEvent[]; reset: boolean }>The room's recent events (at most its last 500 of the last ten minutes), after since when it names one still
kept; reset when it doesn't (read what you show again).
{"events": [RoomEvent, ...], "reset": bool}; reset True when since was too old, so read what
you show again.
publishstatic
static publish(
name: string,
event: string,
data?: unknown,
options?: { client?: NoClick },
): Promise<string>Publishes event with data (at most 64 KB as JSON) to everyone in the room, named as from you (needs edit access
to a workflow's room); its id in the room. From a server: a page in the room broadcasts instead.
The event's id in the room.
askstatic
static ask(
name: string,
ask: string,
args?: JsonObject,
options?: { client?: NoClick; timeoutS?: number; collectMs?: number },
): Promise<JsonObject>Asks the room's pages that answer ask (room.answer) and waits for an answer, at most timeoutS (25 at most);
with collectMs, that long after the first for the others'. { answer }, { answers }, or { error }
(no_viewer, timeout). Needs edit access to a workflow's room.
010{"answer": {...}} (or {"answers": [...]} collecting), each naming the member that gave it, or
{"error": "no_viewer" | "timeout"}.
type JsonObject = { [key: string]: unknown };tokenstatic
static token(name: string, options?: RoomTokenOptions): Promise<RoomToken>A single-use token for the room's socket, for a page to open with Room.join(name, { token }).
The page's origin the socket will come from (a browser sends its own).
The token, the socket's url (carrying its ticket) and what it lets the page do (access).
accessTypeScript only
access: RoomAccessWhat your token lets you do here (renewed in place, so it follows an access change).
/** What a token lets you do in a room: edit or view a workflow's, or your own tabs (`own`). */
type RoomAccess = "edit" | "view" | "own";meTypeScript only
me: RoomMember | nullYour own member, once the room let you in.
statusTypeScript only
status: RoomStatus/** Where the room's socket stands: `connecting`, `live`, `reconnecting` (it will on its own), or `stopped`. */
type RoomStatus = "connecting" | "live" | "reconnecting" | "stopped";runsTypeScript only
runs: RoomRun[]The runs in flight on a workflow's room as you last joined.
/** A run in flight on a workflow's room, as a page joining mid-run is told it. */
interface RoomRun {
executionId: string;
nodeStates: Record<string, string>;
nodeOutputs: Record<string, unknown>;
}presenceTypeScript only
presence: { set: (data: JsonObject) => void; list: () => RoomMember[] }Your presence: set merges what you say of yourself; list is everyone here now, you included.
type JsonObject = { [key: string]: unknown };onTypeScript only
on(event: "presence", handler: (members: RoomMember[]) => void): () => void
on(event: "event", handler: (event: RoomEvent) => void): () => void
on(event: "status", handler: (status: RoomStatus) => void): () => void
on(event: "access", handler: (access: RoomAccess) => void): () => void
on(event: string, handler: BroadcastHandler): () => voidEveryone's presence as it changes (members, you included).
The server's events.
What your token lets you do, each time it changes (a renewal after an access change).
What another member broadcast under this name.
broadcastTypeScript only
broadcast(event: string, data?: unknown): voidTells the room's other members something (relayed only where the room's kind allows it).
nullanswerTypeScript only
answer(name: string, handler: (args: JsonObject) => unknown): () => voidAnswers what the server asks this page under name (the first answer, or each with collecting, wins).
type JsonObject = { [key: string]: unknown };scopeTypeScript only
scope(workflowId: string | null): voidOn your own room: hear only events for one workflow (and those for none); null hears every one.
stopTypeScript only
stop(executionId: string): voidOn a workflow's room: stop a run (if you may edit, or it's yours).
leaveTypeScript only
leave(): voidLeaves the room: the socket closes and nothing more is heard.
joinstaticTypeScript only
static join(name: string, options?: RoomJoinOptions): Promise<Room>Joins the room: resolves once you're in (with members as they are), and stays in, reconnecting by itself, until
leave (or signal). Throws what trying again can't fix: the token call refused (a room you can't open, a key
without the scope) or the room refusing two fresh tokens in a row (RoomRefused).
What you say of yourself as you join (merged; null removes a key). At most 1 KB as JSON.
Where a token comes from, when not this client: your server's endpoint passing url and token on.
Stops the room (as leave).
A WebSocket class, where the runtime has none of its own (Node before 22).
The page's origin the socket will come from (a browser sends its own).
type JsonObject = { [key: string]: unknown };
/** Where the room's socket stands: `connecting`, `live`, `reconnecting` (it will on its own), or `stopped`. */
type RoomStatus = "connecting" | "live" | "reconnecting" | "stopped";RoomEvent
interface RoomEventWhat the server published: NoClick's own (from null), or a member's through the API.
| id | string | Its place in the room (what a reconnect resumes after, and |
| event | string | |
| data | unknown | |
| from | { id: string; name: string } | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
type JsonObject = { [key: string]: unknown };RoomMember
interface RoomMemberOne member of a room: a page (user who they are, color the room gave them, data what they say of
themselves) or one NoClick holds (server: an agent's sandbox at work, user None).
| id | string | This connection's id in the room: one person's two tabs are two members. |
| user | RoomUser | null | |
| color | string | null | The colour the room gave them; null for a member NoClick holds. |
| data | JsonObject | What they say of themselves ( |
| server | boolean | One NoClick holds, such as an agent's sandbox at work. |
| joinedAt | Date | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
/** Who a member is, as their token says: null for one NoClick holds (an agent's sandbox). */
interface RoomUser {
id: string;
name: string;
avatar: string | null;
/** NoClick's staff viewing the account as its owner. */
staff: boolean;
}
type JsonObject = { [key: string]: unknown };RoomToken
interface RoomTokenA single-use token for a room's socket (POST /v1/rooms/{room}/tokens).
| url | string | |
| token | string | |
| access | RoomAccess | |
| expiresAt | Date | null | |
| connectionEndsAt | Date | null | |
| raw | JsonObject | The response JSON exactly as the API sent it. |
/** What a token lets you do in a room: edit or view a workflow's, or your own tabs (`own`). */
type RoomAccess = "edit" | "view" | "own";
type JsonObject = { [key: string]: unknown };