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

@@ -4,6 +4,7 @@ import type { ChatRole, Prisma } from "@prisma/client";
import { prisma } from "../utils/prisma";
import { datasetRoot } from "../dataset/paths";
import { ensureDataset } from "../dataset/exporter";
import { runLangGraphCrmAgentFor } from "./langgraphCrmAgent";
type ContactIndexRow = {
id: string;
@@ -74,6 +75,11 @@ export async function runCrmAgent(userText: string): Promise<AgentReply> {
export async function runCrmAgentFor(
input: { teamId: string; userId: string; userText: string },
): Promise<AgentReply> {
const mode = (process.env.CF_AGENT_MODE ?? "langgraph").toLowerCase();
if (mode !== "rule" && process.env.OPENAI_API_KEY) {
return runLangGraphCrmAgentFor(input);
}
await ensureDataset({ teamId: input.teamId, userId: input.userId });
const q = normalize(input.userText);
const root = datasetRoot({ teamId: input.teamId, userId: input.userId });