TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { withUser, parseBody, json } from "@/lib/api";2import { LIMITS } from "@/lib/rate-limit";3import { chatAdoptSchema } from "@/lib/chat/schemas";4import { adoptMessage, toPublicMessage } from "@/lib/chat/service";5import { toPublicConversation } from "@/lib/conversations/service";67export const dynamic = "force-dynamic";89/**10 * POST /api/chat/adopt — "Continue with this model" from an inline Compare / Arena run.11 * Body: { conversationId?, modelKey, arenaResponseId? | content, userText?, systemPrompt?, settings?, projectId? }12 * → 201 { conversation, userMessage | null, message, isNewConversation }13 */14export const POST = withUser(15 async (ctx) => {16 const input = await parseBody(ctx.req, chatAdoptSchema, 1_000_000);17 const res = await adoptMessage({ userId: ctx.user.id, requestId: ctx.requestId, ip: ctx.ip }, input);18 return json({ conversation: toPublicConversation(res.conversation), userMessage: res.userMessage ? toPublicMessage(res.userMessage) : null, message: toPublicMessage(res.message), isNewConversation: res.isNewConversation }, { status: 201 });19 },20 { limit: { ...LIMITS.chat, key: "chat-adopt" } },21);22