Improve pilot chat live traces and remove mock placeholders

This commit is contained in:
Ruslan Bakiev
2026-02-18 21:22:35 +07:00
parent 46e5908244
commit fdc85d5c42
6 changed files with 120 additions and 81 deletions

View File

@@ -30,6 +30,17 @@ export type AgentReply = {
dbWrites?: Array<{ kind: string; detail: string }>;
};
export type AgentTraceEvent = {
text: string;
toolRun?: {
name: string;
status: "ok" | "error";
input: string;
output: string;
at: string;
};
};
function normalize(s: string) {
return s.trim().toLowerCase();
}
@@ -81,7 +92,12 @@ export async function runCrmAgent(userText: string): Promise<AgentReply> {
}
export async function runCrmAgentFor(
input: { teamId: string; userId: string; userText: string },
input: {
teamId: string;
userId: string;
userText: string;
onTrace?: (event: AgentTraceEvent) => Promise<void> | void;
},
): Promise<AgentReply> {
const mode = (process.env.CF_AGENT_MODE ?? "langgraph").toLowerCase();
const llmApiKey =