201
const sideChat = value.sideChat as { source?: unknown; turnId?: unknown; selection?: unknown; providerAnchorTurnId?: unknown; inheritedTurnCount?: unknown; partialResponse?: unknown; context?: unknown } | undefined;
202
const validSelection = sideChat?.selection
204
>
&& typeof (sideChat.selection as { text?: unknown }).text === 'string'
205
>
&& (((sideChat.selection as { responsePartId?: unknown }).responsePartId) === undefined || typeof (sideChat.selection as { responsePartId?: unknown }).responsePartId === 'string')
206
>
? {
207
>
text: (sideChat.selection as { text: string }).text,
208
>
...((sideChat.selection as { responsePartId?: string }).responsePartId ? { responsePartId: (sideChat.selection as { responsePartId?: string }).responsePartId } : {}),
209
>
}
210
: undefined;
211
const validSideChat = sideChat
213
>
&& typeof sideChat.turnId === 'string'
214
>
&& (sideChat.providerAnchorTurnId === undefined || typeof sideChat.providerAnchorTurnId === 'string')
215
>
&& typeof sideChat.inheritedTurnCount === 'number'
216
>
&& (sideChat.partialResponse === undefined || typeof sideChat.partialResponse === 'string')
217
>
&& (sideChat.context === undefined || typeof sideChat.context === 'string')
218
>
? {
219
>
source: sideChat.source,
220
>
turnId: sideChat.turnId,
221
>
...(validSelection ? { selection: validSelection } : {}),
222
>
...(sideChat.providerAnchorTurnId ? { providerAnchorTurnId: sideChat.providerAnchorTurnId } : {}),
223
>
inheritedTurnCount: sideChat.inheritedTurnCount,
224
>
...(sideChat.partialResponse ? { partialResponse: sideChat.partialResponse } : {}),
225
>
...(sideChat.context ? { context: sideChat.context } : {}),
226
>
}
227
: undefined;
228
return { sdkSessionId, ...(validModel ? { model: validModel } : {}), ...(validSideChat ? { sideChat: validSideChat } : {}) };