Intelligence

Artifacts

Browse the repository, read documents, and manage the governance folders. Source, runtime, and infrastructure are read-only.

Repository
globals.csslayout.tsxnot-found.tsxpage.tsx
.gitignoreDockerfilenext-env.d.tsnext.config.mjspackage-lock.jsonpackage.jsonpostcss.config.mjsREADME.mdtailwind.config.tstsconfig.jsontsconfig.tsbuildinfo
README.md
CONSTITUTION_COMPLIANCE_AUDIT_V1.mdREADME.md
repositories/aaf-holdings/hq01/app/api/router/briefing/route.ts
1.3 KB
import { NextResponse } from "next/server";
import { assembleBriefing } from "@/lib/executives/briefing";
import { route } from "@/lib/executives/router";

/**
 * Preview the briefing that would be loaded for an executive + instruction,
 * without launching a session.
 *
 *   POST /api/router/briefing   { executiveId, instruction, routingReason? }
 */

export const runtime = "nodejs";
export const dynamic = "force-dynamic";

export async function POST(request: Request) {
  let body: { executiveId?: string; instruction?: string; routingReason?: string };
  try {
    body = await request.json();
  } catch {
    return NextResponse.json({ error: "Invalid JSON." }, { status: 400 });
  }
  if (!body.executiveId || !body.instruction) {
    return NextResponse.json(
      { error: "executiveId and instruction are required." },
      { status: 400 },
    );
  }
  const reason =
    body.routingReason ??
    route({ instruction: body.instruction, preferredExecutiveId: body.executiveId })
      .routingReason;
  try {
    const briefing = assembleBriefing(body.executiveId, body.instruction, reason);
    return NextResponse.json({ briefing });
  } catch (err) {
    const message = err instanceof Error ? err.message : "Could not assemble briefing.";
    return NextResponse.json({ error: message }, { status: 400 });
  }
}

root · /srv/aaf