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

cleanup.ts

19 lines · 772 B · TypeScript
import { cleanupRooms } from '../core/rooms.ts'
import { handle, kodyCtx, params } from '../runtime.ts'

/**
 * Delete rooms past retention. Off by default: unless `settings({ cleanup: { enabled: true } })`
 * was set, this is always a dry run. Defaults keep closed rooms 365 days and never delete open ones.
 *
 * @param input.dryRun - Default true. Pass false (with cleanup enabled) to delete.
 * @returns `{ status: 'ok', dryRun, enabled, roomIds, deleted }`
 * @example
 * import cleanup from 'kody:@kody/rooms/cleanup'
 * const preview = await cleanup({})
 */
export default async function cleanup(input: unknown) {
	return handle(async () => {
		const p = params(input, ['dryRun'])
		return cleanupRooms(kodyCtx(), { dryRun: p.dryRun as boolean | undefined })
	})
}