import { agentToken, routeCaller } from "@/lib/annotations/agentAuth.mjs"; // WHO MAY WRITE A MANIFEST (video knobs, plans/video-knobs-ui.md): every // manifest-write route takes the app's own page (no Authorization header, as // before) and an agent or the editor carrying `Bearer ` // -- routeCaller's rule (lib/annotations/agentAuth.mjs). Any other header is a // 401, so a wrong token is refused rather than read as the page. /** null when the caller may write; else the 401 to send. */ export function refuseCaller(request: Request, what: string): Response | null { const who = routeCaller(request.headers.get("authorization"), agentToken(), what); return who.ok ? null : Response.json({ error: who.error }, { status: who.status }); }