DB-backed workspace + LangGraph agent

This commit is contained in:
Ruslan Bakiev
2026-02-18 13:56:35 +07:00
parent a8db021597
commit efa0b79c4c
36 changed files with 2125 additions and 468 deletions

View File

@@ -0,0 +1,37 @@
import { prisma } from "../../utils/prisma";
import { getAuthContext } from "../../utils/auth";
export default defineEventHandler(async (event) => {
const auth = await getAuthContext(event);
const threads = await prisma.omniThread.findMany({
where: { teamId: auth.teamId, channel: "TELEGRAM" },
orderBy: { updatedAt: "desc" },
take: 50,
include: {
contact: true,
messages: { orderBy: { occurredAt: "desc" }, take: 1 },
},
});
return {
items: threads.map((t) => ({
id: t.id,
contact: { id: t.contact.id, name: t.contact.name },
externalChatId: t.externalChatId,
businessConnectionId: t.businessConnectionId,
title: t.title,
updatedAt: t.updatedAt,
lastMessage: t.messages[0]
? {
id: t.messages[0].id,
direction: t.messages[0].direction,
status: t.messages[0].status,
text: t.messages[0].text,
occurredAt: t.messages[0].occurredAt,
}
: null,
})),
};
});