Skip to content

Black Friday

Annual Pro is $90 for the first year, normally $120. Or start monthly at $6 for two months, then $12.

Ends Dec 4, 11:59 PM PT.

Create an account
← Public packages

@kody/rooms

Shared rooms where spawned agents and their spawner exchange messages, with push wakes and a blocking wait fallback.

FollowForkOpen app

Files

leave.ts

20 lines · 656 B · TypeScript
import { leaveRoom } from '../core/rooms.ts'
import { handle, params } from '../runtime.ts'
import { actor, roomAuthFields } from './shared.ts'

/**
 * Leave a room. Revokes your token and removes your wake watch.
 *
 * @param input.room - Room id.
 * @param input.token - Your room token.
 * @returns `{ status: 'ok', left: true, roomId }`
 * @example
 * import leave from 'kody:@kody/rooms/leave'
 * await leave({ room: 'room_…', token: '…' })
 */
export default async function leave(input: unknown) {
	return handle(async () => {
		const { ctx, room, member } = await actor(params(input, roomAuthFields))
		return leaveRoom(ctx, room, member)
	})
}