import { createDb } from "../packages/db/src/index.js"; async function run() { const { prisma } = createDb("postgres://ingowagner@127.0.0.1:5432/evoo"); const auditor = await prisma.bot.findFirst({ where: { name: "Security & QA Auditor" }, include: { thread: { include: { messages: { orderBy: { seq: "desc" }, take: 2, }, }, }, }, }); const lastMsg = auditor?.thread?.messages[0]; console.log(`Auditor last msg (role: ${lastMsg?.role}, seq: ${lastMsg?.seq}):`); if (lastMsg?.role === "bot") { console.log(JSON.stringify(lastMsg?.blocks, null, 2)); } else { console.log("Still working..."); } const latestEvents = await prisma.event.findMany({ where: { botId: auditor?.id }, orderBy: { createdAt: "desc" }, take: 6, }); console.log("\nLatest events:"); for (const e of latestEvents) { console.log( `[${e.createdAt.toISOString()}] ${e.type}: ${JSON.stringify(e.payload || e.data).slice(0, 120)}`, ); } } run() .catch(console.error) .finally(() => process.exit(0));