import { enqueueDraft, errorResponse } from "@/lib/articles/generation"; export const dynamic = "force-dynamic"; // START A GENERATION (release 27 S8): the body is `pnpm ops report-draft`'s — // { task, article, iteration?, model?, extractorModel?, feedback?, question?, // channels?, from?, to?, copyOf?, maxUsd?, cards?, entries?, force?, autonomy? } — // forwarded to the editor, which // creates the iteration and runs the job. Answers { ok, jobId, iteration }. // // a new article task sweep, question, channels (from, to); on Claude, // extractorModel (release 28 F2: else the settings') // a new iteration task revise-report | revise-video, iteration, feedback // copy with model the iteration's task, copyOf, model // narration task narrate, iteration, model (a step) // a media draft task cut | onscreen | teaser | flips | threads | // youtube, iteration, model, entries?, force? (a step, // release 28) // research task research, question, channels?, model, autonomy // (release 27 S11: its queue is /api/articles/research) // continue research task sweep, iteration (the research run), model export async function POST(request: Request) { try { const body = (await request.json().catch(() => null)) as Record | null; if (!body || typeof body !== "object" || Array.isArray(body)) return Response.json({ error: "send the generation as an object" }, { status: 400 }); const out = await enqueueDraft(body); return Response.json({ ok: true, ...out }, { headers: { "cache-control": "no-store" } }); } catch (err) { return errorResponse(err); } }