feat: productionize learning engine and classroom

This commit is contained in:
inman
2026-08-16 21:44:52 +08:00
parent 2d04197f3f
commit ba35adfbfa
124 changed files with 9071 additions and 796 deletions

View File

@@ -0,0 +1,25 @@
import type { NextRequest } from 'next/server';
import { authorizeLearningRuntime, runtimeUnauthorized } from '@/lib/makelore-runtime/auth';
import { loadMakeloreCourse, parseLearningBinding } from '@/lib/makelore-runtime/course-store';
import { isRuntimeOpenRequest } from '@/lib/makelore-runtime/protocol';
export async function POST(request: NextRequest) {
if (!authorizeLearningRuntime(request)) return runtimeUnauthorized();
const body: unknown = await request.json().catch(() => null);
if (!isRuntimeOpenRequest(body)) return Response.json({ error: 'invalid_request' }, { status: 400 });
const binding = parseLearningBinding(body.binding.key);
if (!binding) return Response.json({ error: 'invalid_binding' }, { status: 400 });
const course = await loadMakeloreCourse(binding.courseId, binding.contentHash);
if (!course) return Response.json({ error: 'course_not_found' }, { status: 404 });
return Response.json({
type: 'learning.course.snapshot',
schema_version: 1,
binding_source_sequence: 0,
payload: {
courseId: course.courseId,
contentHash: course.contentHash,
title: course.title,
sceneCount: course.sceneCount,
},
});
}