Files
learnharness/app/api/practice/sets/route.ts
T
amosblomqvist 06032769d2 practice: the learner's creation note — optional free-form input carried to partitioner + generators (owner, 2026-09-29)
- dialog: optional 'Anything else?' textarea (typing-only, 2000-char mirror)
- API: body gains note? — trimmed, whitespace-only omitted, hard 400 over 2000
- pipeline: note persisted on the set and threaded to both agent stages
- agents: THE LEARNER'S NOTE prompt block (present only when set) + the
  weighed-never-owed stance pinned in both doctrines
- fix en route: doubled THE PARAMETERS heading in both prompts since slice 3
  (renderParams owns the heading; the literal blocks removed)
2026-09-29 22:16:28 +03:00

29 lines
965 B
TypeScript

/**
* POST /api/practice/sets — create a problem set (202 {id}; generation
* runs in the background — the fire-and-forget pipeline). Body:
* {nodeIds, params, title?, note?} — a node selection, the cluster's
* label, and the learner's optional
* free-form note
* Validation + typed-error mapping live in the service (server/practice).
* GET — the set list (createdAt desc, the store's order).
*/
import { createPracticeSetResponse, listPracticeSets, practiceErrorResponse } from "@/src/server";
export async function POST(req: Request) {
let body: unknown;
try {
body = await req.json();
} catch {
return Response.json({ error: "Invalid JSON body" }, { status: 400 });
}
return createPracticeSetResponse(body);
}
export async function GET() {
try {
return Response.json({ sets: listPracticeSets() });
} catch (err) {
return practiceErrorResponse(err);
}
}