import { NextResponse } from "next/server"; import { z } from "zod"; import { ChatSDKError } from "@/lib/errors"; import { requireAdmin } from "@/lib/middleware/admin"; import { getVideoStoryboardTaskDetail } from "@/lib/video-agent/task-store"; const paramsSchema = z.object({ taskId: z.string().uuid(), }); export async function GET( _request: Request, { params }: { params: Promise<{ taskId: string }> } ) { try { await requireAdmin(); const parsed = paramsSchema.parse(await params); const detail = await getVideoStoryboardTaskDetail(parsed.taskId); if (!detail) { return NextResponse.json( { success: false, error: "任务不存在" }, { status: 404 } ); } return NextResponse.json({ success: true, task: detail.task, shots: detail.shots, }); } catch (error) { if (error instanceof ChatSDKError) { return error.toResponse(); } if (error instanceof z.ZodError) { return NextResponse.json( { success: false, error: error.message }, { status: 400 } ); } return NextResponse.json( { success: false, error: error instanceof Error ? error.message : "查询任务失败", }, { status: 500 } ); } }