peppa/apps/web/app/api/palette/route.ts
2026-11-15 18:05:34 +05:00

16 lines
807 B
TypeScript

import { paletteItems } from "@peppa/core";
import { currentUser, uiMode } from "@/lib/auth";
import { db } from "@/lib/db";
export const dynamic = "force-dynamic";
/** Command palette data (PEP-52): projects, stories, runners and open questions of the user's projects. */
export async function GET() {
const user = await currentUser();
if (!user) return Response.json({ error: "unauthorized" }, { status: 401 });
// PEP-123: terminals of agents are a tool of «Инженер»; «Продакт» searches projects, tasks and questions.
const all = await paletteItems(db, user.id);
const items = (await uiMode()) === "engineer" ? all : all.filter((i) => i.kind !== "runner" && i.href !== "/runners");
return Response.json({ items }, { headers: { "Cache-Control": "private, no-store" } });
}