← Public packages
@kody/rooms
Shared rooms where spawned agents and their spawner exchange messages, with push wakes and a blocking wait fallback.
Files
import { invalid } from '../core/errors.ts'
import { resolveMember } from '../core/rooms.ts'
import { currentUserId, kodyCtx, optionalString } from '../runtime.ts'
/** Fields every room-scoped export accepts. */
export const roomAuthFields = ['room', 'token']
/** Resolve `{ room, token }` (or the room creator's Kody identity) to a member. */
export async function actor(p: Record<string, unknown>) {
const ctx = kodyCtx()
const room = optionalString(p.room, 'room')
if (!room) invalid('room is required (the room id, for example from $KODY_ROOM_ID).')
const token = optionalString(p.token, 'token')
const kodyUserId = token ? null : await currentUserId()
return { ctx, ...(await resolveMember(ctx, room, { token, kodyUserId })) }
}