import { esc, fmt } from "./util.js"; import { value } from "./render.js"; // Keep the task's actual inputs visible; hashes and bookkeeping belong in an // expandable record. All content still passes through the shared safe renderer. export function taskContent(task) { const primary = /^(prompt|instruction|instructions|question|description|messages|input|inputs|content|text|audio|audio_url|image|image_url|video_url|context|tools)$/i; const entries = Object.entries(task); const inputs = entries.filter(([key, v]) => primary.test(key) && v != null && v !== ""); const metadata = Object.fromEntries(entries.filter(([key]) => !primary.test(key))); return `${task.media_ready === false ? `
Media loads when the episode starts. Start this task to ask the Space to prepare its asset. The player appears with the observation when the server provides it.
` : ""}
${inputs.map(([key, v]) => `

${esc(key.replaceAll("_", " "))}

${value(v, key, 0, task)}
`).join("") || `

This task exposes structured fields. Open its record below to inspect them.

`}
Task record ยท ${fmt.format(Object.keys(metadata).length)} fields ${value(metadata)}
`; }