/** * Describe a world so an agent can plan a build: bounds, materials, a coarse * height map, recent builds, and (optionally) the exact blocks in a region. * * @param input - `{ room, region?: { minX, maxX, minY, maxY, minZ, maxZ } }`. room is the room link or code; without room or worldId it describes the main world. * @returns World summary with `rules` (bounds, materials) to follow when placing blocks. * @example * import describeWorld from 'kody:@kentcdodds/world-builder/describe-world' * const info = await describeWorld({ room: 'abc123defg', region: { minX: -8, maxX: 8, minY: 0, maxY: 10, minZ: -8, maxZ: 8 } }) */ import { describeWorld as describe, resolveWorld } from './lib/world-ops.ts' type Region = { minX: number; maxX: number; minY: number; maxY: number; minZ: number; maxZ: number } export default async function describeWorld(input?: { room?: string worldId?: string; region?: Region }) { const worldId = await resolveWorld(input) const r = input?.region const region = r && typeof r === 'object' ? { minX: Math.trunc(Number(r.minX) || 0), maxX: Math.trunc(Number(r.maxX) || 0), minY: Math.trunc(Number(r.minY) || 0), maxY: Math.trunc(Number(r.maxY) || 0), minZ: Math.trunc(Number(r.minZ) || 0), maxZ: Math.trunc(Number(r.maxZ) || 0), } : undefined return describe(worldId, region) }