@@ -62,21 +62,24 @@ function formatMothershipBlockOutput(
6262 fallbackChatId : string
6363) : NormalizedBlockOutput {
6464 const formattedList = ( result . toolCalls || [ ] ) . map ( ( tc : Record < string , unknown > ) => ( {
65- name : tc . name ,
66- arguments : tc . params || { } ,
65+ name : typeof tc . name === 'string' ? tc . name : String ( tc . name ?? '' ) ,
66+ arguments : tc . params && typeof tc . params === 'object' ? tc . params : { } ,
6767 result : tc . result ,
6868 error : tc . error ,
69- duration : tc . durationMs || 0 ,
69+ duration : typeof tc . durationMs === 'number' ? tc . durationMs : 0 ,
7070 } ) )
71- const toolCalls = { list : formattedList , count : formattedList . length }
71+ const toolCalls : NormalizedBlockOutput [ 'toolCalls' ] = {
72+ list : formattedList ,
73+ count : formattedList . length ,
74+ }
7275
7376 return {
7477 content : result . content || '' ,
7578 model : result . model || 'mothership' ,
7679 conversationId : result . conversationId || fallbackChatId ,
77- tokens : result . tokens || { } ,
80+ tokens : ( result . tokens || { } ) as NormalizedBlockOutput [ 'tokens' ] ,
7881 toolCalls,
79- cost : result . cost | | undefined ,
82+ cost : result . cost as NormalizedBlockOutput [ 'cost' ] | undefined ,
8083 }
8184}
8285
0 commit comments