feat: complete marketing command center with pipeline, UI, and asset generation
- Dashboard with campaign management, asset gallery, and publishing queue - 7-agent pipeline: trend scout, research, scripts, ad creative, video, copy, distribution - Campaign form with screenshot upload, goal picker, platform selection - Campaign detail view with Details/Pipeline/Assets/Chat tabs - Two-set image generation: Gemini AI (NanoBanana MCP) + Canvas Design posters - Remotion video rendering with phone.png frame and real screenshot alignment - honeyDue branding: blue #0079FF, orange #FF9400, Inter font, warm off-white - Asset cards with source badges (Gemini/Canvas/Remotion/Playwright) - Markdown/JSON render endpoint for viewing pipeline outputs as HTML - Settings page with Tavily, Gemini, Postiz, Nextdoor integration management - Claude Chat for campaign feedback loop with streaming SSE - Postiz publishing modal with scheduling - Auth with NextAuth credentials + JWT sessions - SQLite via Prisma with better-sqlite3 adapter Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { sendChatMessage } from "@/lib/claude";
|
||||
import path from "path";
|
||||
|
||||
export async function POST(request: Request) {
|
||||
const session = await auth();
|
||||
if (!session) return new Response("Unauthorized", { status: 401 });
|
||||
|
||||
const { message, sessionId, campaignId } = await request.json();
|
||||
|
||||
if (!message || !campaignId) {
|
||||
return Response.json(
|
||||
{ error: "message and campaignId required" },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const campaign = await prisma.campaign.findUnique({
|
||||
where: { id: campaignId },
|
||||
});
|
||||
|
||||
if (!campaign) {
|
||||
return Response.json({ error: "Campaign not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const pipelineRoot =
|
||||
process.env.PIPELINE_ROOT || path.join(process.cwd(), "pipeline");
|
||||
|
||||
// Get or create ClaudeSession
|
||||
let claudeSession = await prisma.claudeSession.findFirst({
|
||||
where: { campaignId },
|
||||
orderBy: { updatedAt: "desc" },
|
||||
});
|
||||
|
||||
if (!claudeSession) {
|
||||
claudeSession = await prisma.claudeSession.create({
|
||||
data: { campaignId },
|
||||
});
|
||||
}
|
||||
|
||||
// Save user message
|
||||
const existingMessages = claudeSession.messages
|
||||
? JSON.parse(claudeSession.messages)
|
||||
: [];
|
||||
existingMessages.push({ role: "user", content: message });
|
||||
|
||||
await prisma.claudeSession.update({
|
||||
where: { id: claudeSession.id },
|
||||
data: { messages: JSON.stringify(existingMessages) },
|
||||
});
|
||||
|
||||
const stream = await sendChatMessage(
|
||||
claudeSession.sessionId || sessionId,
|
||||
message,
|
||||
pipelineRoot
|
||||
);
|
||||
|
||||
return new Response(stream, {
|
||||
headers: {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
Connection: "keep-alive",
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user