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

close.ts

21 lines · 789 B · TypeScript
import { closeRoom } from '../core/rooms.ts'
import { handle, params } from '../runtime.ts'
import { actor, roomAuthFields } from './shared.ts'

/**
 * Close a room (creator only). Unused invites are revoked, writes stop, waits
 * return `closed`, and `@kody/rooms.room.closed` is emitted. History stays readable.
 *
 * @param input.room - Room id.
 * @param input.token - Creator token (optional for the creating Kody user).
 * @returns `{ status: 'ok', closed: true, already, roomId }`
 * @example
 * import close from 'kody:@kody/rooms/close'
 * await close({ room: 'room_…' })
 */
export default async function close(input: unknown) {
	return handle(async () => {
		const { ctx, room, member } = await actor(params(input, roomAuthFields))
		return closeRoom(ctx, room, member)
	})
}