feat: add scoped context payload and rollbackable document changes

This commit is contained in:
Ruslan Bakiev
2026-02-21 16:27:09 +07:00
parent 052f37d0ec
commit fa1231df37
5 changed files with 678 additions and 13 deletions

View File

@@ -42,6 +42,31 @@ export type AgentTraceEvent = {
};
};
export type PilotContextPayload = {
scopes: Array<"summary" | "deal" | "message" | "calendar">;
summary?: {
contactId: string;
name: string;
};
deal?: {
dealId: string;
title: string;
contact: string;
};
message?: {
contactId?: string;
contact?: string;
intent: "add_message_or_reminder";
};
calendar?: {
view: "day" | "week" | "month" | "year" | "agenda";
period: string;
selectedDateKey: string;
focusedEventId?: string;
eventIds: string[];
};
};
function normalize(s: string) {
return s.trim().toLowerCase();
}
@@ -97,6 +122,7 @@ export async function runCrmAgentFor(
teamId: string;
userId: string;
userText: string;
contextPayload?: PilotContextPayload | null;
requestId?: string;
conversationId?: string;
onTrace?: (event: AgentTraceEvent) => Promise<void> | void;