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

settings.ts

22 lines · 962 B · TypeScript
import { readSettings, writeSettings } from '../core/rooms.ts'
import { handle, kodyCtx, params } from '../runtime.ts'

/**
 * Read or update package-wide defaults. With no fields it only reads.
 *
 * @param input.caps - Default caps for new rooms: membersPerRoom, postsPerMemberPerHour,
 *   messageBytes, liveRoomsPerCreator, postsPerRoomPerDay, inviteTtlHours.
 * @param input.cleanup - `{ enabled, closedRoomRetentionDays, idleRoomRetentionDays }` (off by default).
 * @returns `{ status: 'ok', caps, cleanup }`
 * @example
 * import settings from 'kody:@kody/rooms/settings'
 * await settings({ caps: { postsPerMemberPerHour: 120 } })
 */
export default async function settings(input: unknown) {
	return handle(async () => {
		const p = params(input, ['caps', 'cleanup'])
		const ctx = kodyCtx()
		const result = p.caps == null && p.cleanup == null ? await readSettings(ctx) : await writeSettings(ctx, p)
		return { status: 'ok' as const, ...result }
	})
}