import { assembleBrief } from "@/lib/briefing";

export async function GET(
  _req: Request,
  { params }: { params: Promise<{ personId: string }> }
) {
  const { personId } = await params;

  if (!personId) {
    return Response.json({ error: "personId required" }, { status: 400 });
  }

  try {
    const brief = await assembleBrief(personId);
    return Response.json(brief);
  } catch (err) {
    const message = err instanceof Error ? err.message : "Brief assembly failed";
    console.error("[brief] GET failed:", message);
    return Response.json({ error: message }, { status: 500 });
  }
}
