Add chat-side CRM diff panel with keep/rollback flow

This commit is contained in:
Ruslan Bakiev
2026-02-19 05:22:16 +07:00
parent a09acc62a0
commit d9c994c408
7 changed files with 709 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import { prisma } from "../utils/prisma";
import { datasetRoot } from "../dataset/paths";
import { ensureDataset } from "../dataset/exporter";
import { runLangGraphCrmAgentFor } from "./langgraphCrmAgent";
import type { ChangeSet } from "../utils/changeSet";
type ContactIndexRow = {
id: string;
@@ -243,6 +244,7 @@ export async function persistChatMessage(input: {
output: string;
at: string;
}>;
changeSet?: ChangeSet | null;
teamId: string;
conversationId: string;
authorUserId?: string | null;
@@ -251,7 +253,8 @@ export async function persistChatMessage(input: {
(input.plan && input.plan.length) ||
(input.tools && input.tools.length) ||
(input.thinking && input.thinking.length) ||
(input.toolRuns && input.toolRuns.length),
(input.toolRuns && input.toolRuns.length) ||
input.changeSet,
);
const data: Prisma.ChatMessageCreateInput = {
team: { connect: { id: input.teamId } },
@@ -265,6 +268,7 @@ export async function persistChatMessage(input: {
tools: input.tools ?? [],
thinking: input.thinking ?? input.plan ?? [],
toolRuns: input.toolRuns ?? [],
changeSet: input.changeSet ?? null,
} as any)
: undefined,
};