(result: any)
| 60 | } |
| 61 | |
| 62 | export 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. |
no test coverage detected