diff --git a/src/app-server/protocol/turn.ts b/src/app-server/protocol/turn.ts index 6ba4f3f8..4a00e00d 100644 --- a/src/app-server/protocol/turn.ts +++ b/src/app-server/protocol/turn.ts @@ -11,6 +11,7 @@ export type TurnItem = GeneratedThreadItem; export type TurnRecord = GeneratedTurn; type AppServerUserInput = Extract["content"][number]; +type AppServerTextUserInput = Extract; function transcriptEntriesFromTurnRecord(turn: TurnRecord): ThreadTranscriptEntry[] { return turn.items.flatMap((item) => transcriptEntriesFromTurnItem(item, turn)); @@ -79,7 +80,7 @@ function transcriptEntriesFromTurnItem(item: TurnItem, turn: TurnRecord): Thread } function userInputText(content: readonly AppServerUserInput[]): string { - const textItems = content.filter((item) => item.type === "text"); + const textItems = content.filter(isTextUserInput); const hasText = textItems.some((item) => item.text.length > 0); const textIncludes = (value: string) => value.length > 0 && textItems.some((item) => item.text.includes(value)); return content @@ -93,3 +94,7 @@ function userInputText(content: readonly AppServerUserInput[]): string { .filter(Boolean) .join("\n"); } + +function isTextUserInput(item: AppServerUserInput): item is AppServerTextUserInput { + return item.type === "text"; +}