MCPcopy Create free account
hub / github.com/microsoft/data-formulator / normalizeClarifyEvent

Function normalizeClarifyEvent

src/app/clarification.ts:62–79  ·  view source on GitHub ↗
(result: any)

Source from the content-addressed store, hash-verified

60}
61
62export function normalizeClarifyEvent(result: any): NormalizedClarification {
63 const rawQuestions = Array.isArray(result?.questions) ? result.questions : [];
64 const questions = rawQuestions
65 .map((question: any) => normalizeQuestion(question))
66 .filter((question: ClarificationQuestion | null): question is ClarificationQuestion => question !== null);
67
68 if (questions.length === 0) {
69 throw new Error('Clarify event requires non-empty questions[]');
70 }
71
72 // Summary feeds the agent's clarify InteractionEntry content (shown
73 // when the user expands the timeline entry).
74 const summary = questions.length === 1
75 ? questions[0].text
76 : questions.map((q: ClarificationQuestion, i: number) => `${i + 1}. ${q.text}`).join('\n');
77
78 return { questions, summary };
79}
80
81/**
82 * Build the user's reply string from a list of clarification responses.

Callers 2

processStreamingResultFunction · 0.90

Calls 2

normalizeQuestionFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected