import { readFile, realpath, stat } from "node:fs/promises"; import path from "node:path"; import { joinCarryOf, panelEntry, postCardHtml, postItemPlan } from "umtool-report-to-video/post-item"; import { avatarUrls } from "umtool-report-to-video/post-avatars"; import { sideCardEntry, sidePostOf } from "umtool-report-to-video/vertical"; import { jobState, startJob } from "@/lib/research/case-editor"; import { withEditNotes } from "@/lib/report/guard"; import { StaleToken, StructureRefused, manifestToken, updatePostFx, updatePostItem, updatePostNarration } from "@/lib/report/manifest.mjs"; import { isNarrated, pickedTake } from "umtool-report-to-video/post-narration"; import { playableAsWritten } from "umtool-report-to-video/post-thread"; import { scriptWordTimes } from "umtool-report-to-video/word-zoom"; import { followKnobs } from "umtool-report-to-video/read-follow"; import { threadLayout } from "umtool-report-to-video/post-thread"; import { planContext } from "umtool-report-to-video/post-conversation"; import { mediaSceneById, sceneEntry, sceneLayout } from "umtool-report-to-video/post-media-scene"; import { projectCombos } from "umtool-report-to-video/post-combo-prints"; import { channelsDirFor } from "@/lib/projects/report.mjs"; import { recognizedOf, takeWordSources, wordsFileOf } from "@/lib/report/postFxCli.mjs"; import { rangeResponse, resolveReport } from "@/lib/report/serve.mjs"; import { resolveTakeManifest } from "@/lib/report/takeManifest.mjs"; import { refuseCaller } from "@/lib/report/caller"; import { crossSiteRefusal } from "@/lib/report/sameOrigin.mjs"; import { withTakeScope } from "@/lib/report/takeScope.mjs"; import { isTakeId } from "@/lib/report/takes.mjs"; import { projectRedaction } from "@/lib/report/postRedaction.mjs"; import { readProjectCharacters } from "@/lib/report/castStore.mjs"; import { anonymiseManifest, anonymousHandles } from "umtool-report-to-video/post-anon"; export const dynamic = "force-dynamic"; // A POST ITEM's page, its files and its knobs (report-to-video/post-item.mjs; // umtool/docs/knobs.md, "A post item"): what Play the cut and the post bench // draw a post item with, and the bench's writer. // // GET ?project&id&w&h[&phase=read|media][&take][&published=1] the card's page, the HTML the // build screenshots, at w × h (the footage box); // published=1 AS PUBLISHED: its redacted words bars // (post-redact.mjs), never in the page, its slurs // masked (post-slurs.mjs); &uncensored=1 the // slurs as posted (the redaction kept) // PRESENT MODE's toggles (lib/report/present.mjs), each // kind off on its own: &redact=0 the redacted words shown // (the slurs as published says), &authors=0 no author // blurred, &blur=0 no attachment censored // GET ?project&side=&w&h[&take][&published=1] a clip's SIDE POST's card page (side-card.mjs, // lane vertical): the post shown beside the clip, at w × h // GET ?project&file=posts-media/… an attachment (byte ranges): only a file // under the project's posts-media/ // GET ?project&font=regular|bold the cut's faces, for the page // GET ?project&id&media=&job= a transcription's state; once done, its // words are set on the attachment // POST {project, op: "set", id, patch, token} updatePostItem (hold, layout, redact, media..…) // POST {project, op: "transcribe", id, media} the editor's transcribe op on the attachment // (a local file, a job), its words beside it // POST {project, op: "fx", id, fx, token} updatePostFx: a word zoom added ({add}), changed // ({set, patch}), removed ({remove}) (word-zoom.mjs) // POST {project, op: "take-words", id, worker?} the picked take's WORD TIMINGS: the editor's transcribe // op on it (or each of its parts), jobs -> {jobs} // GET ?project&id&takeWords=,… those jobs' state; once all are done, the words heard // aligned to the script and kept on the take const noStore = { "cache-control": "no-store" }; type Entry = Record & { id: string; type?: string; media?: Array> }; /** * The manifest a card is drawn from, its ANONYMOUS authors under their shown names (post-anon.mjs; the build's own * pass). As the build: this video's characters unread (a broken or refused file) or an anonymity the pass cannot * resolve REFUSES the card (CardRefused) -- never a card with the real names. */ class CardRefused extends Error {} async function anonymised(project: { dir: string }, m: Record, base: Record | null = null) { const read = await readProjectCharacters(project.dir).catch((e: unknown) => ({ doc: null, error: e instanceof Error ? e.message : String(e) })); if (read.error) throw new CardRefused(`this video's characters are not read (${read.error}): an anonymous author could be drawn under their own name -- fix narration/characters.json first`); try { // The PROJECT's set: the project's manifest (every variant) and the take's, applied to the card's manifest. const set = anonymousHandles(read.doc, ...[base, m].filter(Boolean)); return anonymiseManifest(m, read.doc, { set }) as Record; } catch (e) { throw new CardRefused(e instanceof Error ? e.message : String(e)); } } async function itemOf(project: { dir: string }, manifest: Record, id: string, take: string | null, { anon = false }: { anon?: boolean } = {}) { let m = manifest; if (take) m = (await resolveTakeManifest(project.dir, take, { base: manifest })).manifest as Record; // The item AS WRITTEN (before the anonymity pass): what the build's enforced lint judges its read on. const written = ((Array.isArray(m.timeline) ? m.timeline : []) as Entry[]).find((e) => e?.type === "post" && e.id === id) ?? null; if (anon) m = await anonymised(project, m, manifest); const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Entry[]; const at = tl.findIndex((e) => e?.type === "post" && e.id === id); // `ctx`: the item before it in the cut (post-thread.mjs: a parent that is that item is carried in) and the scene its // run leaves on screen (post-conversation.mjs), as Play's plan has them. const ctx = planContext(tl, at, (m.render ?? {}) as Record) as { prev: Record | null; scene: Record | null; join: { seconds: number } | null }; // THE JOIN (post-join.mjs): the item before's own context, so its post's size is known (the carried post drawn alike). const prevCtx = at > 0 && ctx.join ? (planContext(tl, at - 1, (m.render ?? {}) as Record) as Record) : null; return { item: at >= 0 ? tl[at] : null, written, prev: ctx.prev, ctx, prevCtx, manifest: m }; } /** How the item before draws its post (post-item.mjs joinCarryOf), as the build draws the carried post alike. */ function joinCarry(prev: Entry, prevCtx: Record | null, render: Record, box: { width: number; height: number }) { const pe = panelEntry(prev, render) as Entry; return joinCarryOf(pe, postItemPlan(pe, render, (prevCtx ?? {}) as never) as never, box, render); } /** A project file under posts-media/, never outside it (its real path checked). */ async function postsFile(projectDir: string, rel: string): Promise { if (!rel.startsWith("posts-media/") || rel.split("/").includes("..")) return null; const abs = path.join(projectDir, ...rel.split("/")); const [real, root] = await Promise.all([realpath(abs).catch(() => null), realpath(path.join(projectDir, "posts-media")).catch(() => null)]); if (!real || !root || !(real === root || real.startsWith(root + path.sep))) return null; return abs; } const TYPES: Record = { ".mp4": "video/mp4", ".m4v": "video/mp4", ".mov": "video/quicktime", ".webm": "video/webm", ".gif": "image/gif", ".jpg": "image/jpeg", ".jpeg": "image/jpeg", ".png": "image/png", ".webp": "image/webp", ".json": "application/json", ".ttf": "font/ttf", ".otf": "font/otf", ".woff2": "font/woff2", }; const wordsRelOf = (src: string) => `${src.replace(/\.[^./]+$/, "")}.words.json`; /** The item with its own censors off (present mode): every author drawn as named, every attachment as captured. */ function uncensoredItem(item: Entry, { authors, blur }: { authors: boolean; blur: boolean }): Entry { const out: Entry = { ...item }; if (authors) out.redact = false; if (blur && Array.isArray(item.media)) out.media = item.media.map((m) => (m && typeof m === "object" && "blur" in m ? { ...m, blur: { ...(m.blur as object), on: false } } : m)); return out; } type Redaction = Awaited>; /** A redaction with its terms (and its markup's spans) off, or its markup's attachment censors off. */ function redactionWithout(red: Redaction, { terms, censor }: { terms: boolean; censor: boolean }): Redaction { const markup = Object.fromEntries( Object.entries((red.markup ?? {}) as Record).map(([k, m]) => [k, { ...m, ...(terms ? { redact: [] } : {}), ...(censor ? { censor: [] } : {}) }]), ); return { ...red, ...(terms ? { terms: [] } : {}), markup } as Redaction; } export async function GET(request: Request) { const q = new URL(request.url).searchParams; const r = await resolveReport(q.get("project") ?? ""); if ("error" in r) return new Response(r.error, { status: r.status }); const render = ((r.manifest as Record).render ?? {}) as Record; const font = q.get("font"); if (font) { const file = font === "bold" ? render.fontBold : font === "regular" ? render.fontRegular : null; if (typeof file !== "string" || !file) return new Response("no such face", { status: 404 }); const body = await readFile(file).catch(() => null); if (!body) return new Response("the face is not on disk", { status: 404 }); return new Response(new Uint8Array(body), { headers: { "content-type": TYPES[path.extname(file).toLowerCase()] ?? "application/octet-stream", "cache-control": "max-age=3600" } }); } const rel = q.get("file"); if (rel) { const abs = await postsFile(r.project.dir, rel); if (!abs) return new Response("not a post item's file", { status: 404 }); const st = await stat(abs).catch(() => null); if (!st?.isFile()) return new Response("gone", { status: 404 }); const etag = `"${st.size.toString(16)}-${Math.round(st.mtimeMs).toString(16)}"`; return rangeResponse(request, { abs, size: st.size, etag, headers: { "content-type": TYPES[path.extname(abs).toLowerCase()] ?? "application/octet-stream", "accept-ranges": "bytes", "cache-control": "no-cache" }, }); } // A clip's SIDE POST (lane vertical): its card page, transparent around the card, the cut's redaction when published. const sideOf = q.get("side"); if (sideOf) { let m = r.manifest as Record; try { if (q.get("take")) m = (await resolveTakeManifest(r.project.dir, q.get("take") as string, { base: m })).manifest as Record; } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 400 }); } try { m = await anonymised(r.project, m, r.manifest as Record); } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 409, headers: noStore }); } const tl = (Array.isArray(m.timeline) ? m.timeline : []) as Entry[]; const clip = tl.find((e) => e?.type === "clip" && e.id === sideOf); const post = clip ? (sidePostOf(clip, tl) as Entry | null) : null; if (!post) return new Response(`no side post on ${sideOf}`, { status: 404 }); const sw = Math.round(Number(q.get("w")) || 0); const sh = Math.round(Number(q.get("h")) || 0); if (!(sw >= 160 && sw <= 3840 && sh >= 90 && sh <= 2160)) return new Response("w and h are the side card's box, in px", { status: 400 }); const base = `/api/report/post-item?project=${encodeURIComponent(r.project.id)}`; let redaction = null; try { if (q.get("published") === "1") redaction = await projectRedaction(r.project.dir, m, { uncensored: q.get("uncensored") === "1", say: false }); } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 500 }); } const html = postCardHtml(sideCardEntry(post), { width: sw, height: sh, transparent: true, avatars: avatarUrls(m, (src: string) => `${base}&file=${encodeURIComponent(src)}`) as Record, palette: (render.palette ?? {}) as Record, fonts: { regular: `${base}&font=regular`, bold: `${base}&font=bold` }, phase: "read", redaction, }); return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } }); } const id = q.get("id") ?? ""; let found; try { found = await itemOf(r.project, r.manifest as Record, id, q.get("take") || null, { anon: true }); } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: e instanceof CardRefused ? 409 : 400, headers: noStore }); } if (!found.item) return new Response(`no post item ${id}`, { status: 404 }); // PRESENT MODE's toggles: the item's own censors off, kind by kind (the redaction's are below). if (q.get("authors") === "0" || q.get("blur") === "0") found.item = uncensoredItem(found.item, { authors: q.get("authors") === "0", blur: q.get("blur") === "0" }); const tw = q.get("takeWords"); if (tw) { // A GET that WRITES the manifest (a job followed to done): the proxy passes reads, so an on another site // could ask it; refused cross-site here (lib/report/sameOrigin.mjs). const cross = crossSiteRefusal(request.headers); if (cross) return Response.json({ error: cross }, { status: 403 }); const jobs = tw.split(",").filter(Boolean); const take = pickedTake(found.item) as (Record & { file: string; index: number; script?: string; parts?: unknown[] }) | null; if (!take) return Response.json({ state: "failed", error: `${id} has no take` }, { status: 404 }); try { const states = await Promise.all(jobs.map((j) => jobState(j))); if (states.some((st) => !st.done)) return Response.json({ state: "transcribing", done: states.filter((st) => st.done).length, of: jobs.length }, { headers: noStore }); const bad = states.find((st) => st.status !== "done"); if (bad) return Response.json({ state: "failed", status: bad.status, error: bad.tail.slice(-3).join(" / ") }, { headers: noStore }); const sources = await takeWordSources(r.project.dir, take); const heard: Array<{ w: string; start: number; end: number }> = []; for (const src of sources) { const doc = JSON.parse(await readFile(path.join(r.project.dir, ...wordsFileOf(src.file).split("/")), "utf8")); heard.push(...recognizedOf(doc, src.offset)); } if (!heard.length) return Response.json({ state: "failed", error: "the editor's transcription came back with no word timings (a parakeet worker keeps them)" }, { headers: noStore }); const n = (found.item as { narration?: { script?: string } }).narration; const script = typeof take.script === "string" && take.script.trim() ? take.script : String(n?.script ?? ""); const t = scriptWordTimes(script, heard); const { result } = await withEditNotes(r.project, async () => updatePostNarration(r.project.dir, id, { takeWords: { take: take.index, words: t.words } }, { token: await manifestToken(r.project.dir) })); return Response.json({ state: "done", heard: t.heard, of: t.of, entry: result.entry, token: result.token }, { headers: noStore }); } catch (e) { return Response.json({ state: "failed", error: e instanceof Error ? e.message : String(e) }, { status: 502 }); } } const job = q.get("job"); if (job) { // A GET that WRITES the manifest (a job followed to done): the proxy passes reads, so an on another site // could ask it; refused cross-site here (lib/report/sameOrigin.mjs). const cross = crossSiteRefusal(request.headers); if (cross) return Response.json({ error: cross }, { status: 403 }); const i = Number(q.get("media")); const m = found.item.media?.[i]; if (!m || typeof m.src !== "string") return Response.json({ error: `no attachment ${q.get("media")}` }, { status: 404 }); try { const st = await jobState(job); if (!st.done) return Response.json({ state: "transcribing", status: st.status }, { headers: noStore }); if (st.status !== "done") return Response.json({ state: "failed", status: st.status, tail: st.tail.slice(-3) }, { headers: noStore }); const words = wordsRelOf(m.src); if (!(await stat(path.join(r.project.dir, ...words.split("/"))).catch(() => null))) { return Response.json({ state: "failed", status: "done", error: "the job ended without its words file" }, { headers: noStore }); } if (m.words !== words) { await withEditNotes(r.project, async () => updatePostItem(r.project.dir, id, { media: { [i]: { words } } }, { token: await manifestToken(r.project.dir) })); } return Response.json({ state: "done", words }, { headers: noStore }); } catch (e) { return Response.json({ state: "failed", error: e instanceof Error ? e.message : String(e) }, { status: 502 }); } } const w = Math.round(Number(q.get("w")) || 0); const h = Math.round(Number(q.get("h")) || 0); if (!(w >= 160 && w <= 3840 && h >= 90 && h <= 2160)) return new Response("w and h are the footage box, in px", { status: 400 }); // NEVER A READ THE BUILD REFUSES (post-thread.mjs playableEntry): a read older than its screen draws as no read at all. // Judged on the item AS WRITTEN, applied to the one drawn (post-thread.mjs playableAsWritten): the build's verdict. found.item = playableAsWritten(found.written ?? found.item, found.item) as Entry; const base = `/api/report/post-item?project=${encodeURIComponent(r.project.id)}`; const parentShot = typeof found.item.parentShot === "string" ? `${base}&file=${encodeURIComponent(found.item.parentShot)}` : null; // The authors' pictures (post-avatars.mjs), served as the project's files. const avatars = avatarUrls(found.manifest, (src: string) => `${base}&file=${encodeURIComponent(src)}`) as Record; let redaction = null; try { // uncensored=1: the slur filter off (post-slurs.mjs) -- Play's Uncensored; the redaction stays. if (q.get("published") === "1") redaction = await projectRedaction(r.project.dir, found.manifest, { uncensored: q.get("uncensored") === "1", say: false }); } catch (e) { return new Response(e instanceof Error ? e.message : String(e), { status: 500 }); } // redact=0: the redaction's terms and markup spans off, its slur filter kept; blur=0: the markup's censors off too. if (redaction && (q.get("redact") === "0" || q.get("blur") === "0")) redaction = redactionWithout(redaction, { terms: q.get("redact") === "0", censor: q.get("blur") === "0" }); const cutRender = (found.manifest.render ?? render) as Record; const followOn = q.get("phase") !== "media" && followKnobs(found.item, cutRender).on; // Its MEDIA SCENE (post-media-scene.mjs): neighbours that carry the same attachment, by the combo counter's // groups -- the card drawn as the scene plays it (a join item gains the attachment's slot), the scene's // earlier messages above it. Only looked for beside another post item. const tl = (Array.isArray(found.manifest.timeline) ? found.manifest.timeline : []) as Entry[]; const at = tl.findIndex((e) => e?.id === found.item!.id); const besidePost = tl[at - 1]?.type === "post" || tl[at + 1]?.type === "post"; const groups = besidePost ? ((await projectCombos(r.project.dir, found.manifest, { channelsDir: channelsDirFor(r.project.dir, found.manifest) }).catch(() => ({ groups: [] }))).groups as unknown[]) : []; const media = groups.length ? mediaSceneById(tl, found.item.id, groups as never, cutRender) : null; // A WIDE attachment at full width above the card (post-item.mjs panelEntry: the cut's rule laid on). const item = panelEntry(sceneEntry(found.item, media), cutRender) as Entry; // THE THREAD SCENE WINS (post-media-scene.mjs's header): with the conversation's scene (post-conversation.mjs) the // media scene keeps only the attachment (sceneEntry above), never the card. const scene = found.ctx.scene ? null : media; const tlayout = threadLayout(item, cutRender, found.ctx); const html = postCardHtml(item, { width: w, height: h, avatars, palette: (render.palette ?? {}) as Record, fonts: { regular: `${base}&font=regular`, bold: `${base}&font=bold` }, phase: q.get("phase") === "media" ? "media" : "read", parentShotUrl: parentShot, // Its read-follow (read-follow.mjs): the blocks and the flow Play lights and pans, as the build's page has them. follow: followOn, // A threaded card (post-thread.mjs): its tiles, as the plan's follow.thread has them -- the conversation's scene // (post-conversation.mjs) or, with none, a media scene's earlier messages above them (a narrated item's thread // read is its base; un-narrated, none). thread: followOn ? (scene ? sceneLayout(isNarrated(item) ? tlayout : null, item, scene) ?? tlayout : tlayout) : null, redaction, // THE JOIN (post-join.mjs): the post the item before ended on drawn as it drew its post (Play lays the morph). join: followOn && found.ctx.join && found.prev?.type === "post" ? joinCarry(found.prev as Entry, found.prevCtx, cutRender, { width: w, height: h }) : null, // PICTURE-ONLY posts (post-picture.mjs): each picture in its own card -- a GIF or a video playing there. mediaUrl: (src: string) => `${base}&file=${encodeURIComponent(src)}`, livePics: true, }); return new Response(html, { headers: { "content-type": "text/html; charset=utf-8", ...noStore } }); } // "Edit this take only" (lane/ui-simplify): a body naming `inTake` runs the same write under takeScope.mjs // withTakeScope -- the take's manifest read, the write into its patch, the project's manifest untouched (the // CLI's `--in-take`). The token is then the take's (take.json's), so a client's project token is not checked. export async function POST(request: Request) { const text = await request.text(); let parsed: Record | null = null; try { parsed = JSON.parse(text); } catch { parsed = null; } const take = parsed && typeof parsed.inTake === "string" && parsed.inTake ? parsed.inTake : null; const again = (body: string) => new Request(request.url, { method: "POST", headers: request.headers, body }); if (!take || !parsed) return postHere(again(text)); if (!isTakeId(take)) return Response.json({ error: "inTake must be a take id" }, { status: 400 }); const rr = await resolveReport(String(parsed.project ?? "")); if ("error" in rr) return Response.json({ error: rr.error }, { status: rr.status }); return withTakeScope(rr.project.dir, take, () => postHere(again(JSON.stringify({ ...parsed, token: null })))); } async function postHere(request: Request) { const refused = refuseCaller(request, "/api/report/post-item"); if (refused) return refused; let body: Record; try { body = await request.json(); } catch { return Response.json({ error: "expected JSON" }, { status: 400 }); } const r = await resolveReport(String(body.project ?? "")); if ("error" in r) return Response.json({ error: r.error }, { status: r.status }); const id = String(body.id ?? ""); if (body.op === "set") { try { const { result, editNotes } = await withEditNotes(r.project, () => updatePostItem(r.project.dir, id, (body.patch ?? {}) as Record, { token: body.token === undefined || body.token === null ? null : String(body.token) }), ); return Response.json({ ok: true, entry: result.entry, token: result.token, editNotes }, { headers: noStore }); } catch (e) { if (e instanceof StaleToken) return Response.json({ error: e.message, stale: true }, { status: 409 }); if (e instanceof StructureRefused) return Response.json({ error: e.message, errors: e.errors }, { status: 400 }); return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 }); } } if (body.op === "fx") { try { const { result, editNotes } = await withEditNotes(r.project, () => updatePostFx(r.project.dir, id, (body.fx ?? {}) as Record, { token: body.token === undefined || body.token === null ? null : String(body.token) }), ); return Response.json({ ok: true, entry: result.entry, index: result.index, token: result.token, editNotes }, { headers: noStore }); } catch (e) { if (e instanceof StaleToken) return Response.json({ error: e.message, stale: true }, { status: 409 }); if (e instanceof StructureRefused) return Response.json({ error: e.message, errors: e.errors }, { status: 400 }); return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status: 400 }); } } if (body.op === "take-words") { const found = await itemOf(r.project, r.manifest as Record, id, null); const take = found.item ? (pickedTake(found.item) as (Record & { file: string }) | null) : null; if (!take) return Response.json({ error: `${id} has no take to time` }, { status: 404 }); try { const sources = await takeWordSources(r.project.dir, take); const worker = typeof body.worker === "string" && body.worker ? { workerId: body.worker } : {}; // The editor's transcription door, as for an attachment: a local file, a job -- never ASR here. const jobs = []; for (const src of sources) { jobs.push(await startJob("/api/ops/transcribe", { path: path.join(r.project.dir, ...src.file.split("/")), words: true, out: path.join(r.project.dir, ...wordsFileOf(src.file).split("/")), ...worker })); } return Response.json({ ok: true, jobs }, { headers: noStore }); } catch (e) { const status = (e as { status?: number }).status ?? 502; return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status }); } } if (body.op === "transcribe") { const found = await itemOf(r.project, r.manifest as Record, id, null); const i = Number(body.media); const m = found.item?.media?.[i]; if (!m || typeof m.src !== "string") return Response.json({ error: `${id} has no attachment ${String(body.media)}` }, { status: 404 }); if (m.kind !== "video") return Response.json({ error: "only a video attachment has words to transcribe" }, { status: 400 }); const abs = await postsFile(r.project.dir, m.src); if (!abs) return Response.json({ error: "the attachment is not in the project's posts-media/" }, { status: 404 }); const out = path.join(r.project.dir, ...wordsRelOf(m.src).split("/")); try { // The editor's transcription door: a local file, on a local worker, as a job -- never ASR by hand. const job = await startJob("/api/ops/transcribe", { path: abs, words: true, out }); return Response.json({ ok: true, jobId: job }, { headers: noStore }); } catch (e) { const status = (e as { status?: number }).status ?? 502; return Response.json({ error: e instanceof Error ? e.message : String(e) }, { status }); } } return Response.json({ error: "op is set, fx, take-words or transcribe" }, { status: 400 }); }