@@ -313,9 +313,8 @@ export class CodexToolTranscriptProjection {
313313 }
314314 this . rawNativeToolOutputByCallId . set ( callId , text ) ;
315315 const result = this . messages . find (
316- ( message ) =>
317- message . role === "toolResult" &&
318- ( message as unknown as { toolCallId ?: unknown } ) . toolCallId === callId ,
316+ ( message ) : message is Extract < AgentMessage , { role : "toolResult" } > =>
317+ message . role === "toolResult" && message . toolCallId === callId ,
319318 ) ;
320319 if ( ! result ) {
321320 if ( NATIVE_PATCH_REJECTION_RE . test ( text ) ) {
@@ -336,11 +335,9 @@ export class CodexToolTranscriptProjection {
336335 id : callId ,
337336 name : "apply_patch" ,
338337 text,
339- isError : ( result as unknown as { isError ?: unknown } ) . isError === true ,
338+ isError : result . isError ,
340339 } ) ;
341- ( result as unknown as { content : unknown } ) . content = (
342- replacement as unknown as { content : unknown }
343- ) . content ;
340+ result . content = replacement . content ;
344341 }
345342
346343 async recordNativeToolResultWithDetails ( item : CodexThreadItem | undefined ) : Promise < void > {
@@ -599,7 +596,9 @@ export class CodexToolTranscriptProjection {
599596 } as unknown as AgentMessage ;
600597 }
601598
602- private createToolResultMessage ( params : ToolTranscriptResultInput ) : AgentMessage {
599+ private createToolResultMessage (
600+ params : ToolTranscriptResultInput ,
601+ ) : Extract < AgentMessage , { role : "toolResult" } > {
603602 const text = truncateToolTranscriptText ( params . text ?. trim ( ) || toolResultStatusText ( params ) ) ;
604603 return {
605604 role : "toolResult" ,
@@ -624,7 +623,7 @@ export class CodexToolTranscriptProjection {
624623 ? { __openclaw : { resultContentSource : params . resultContentSource } }
625624 : { } ) ,
626625 timestamp : this . nextTranscriptTimestamp ( ) ,
627- } as unknown as AgentMessage ;
626+ } as unknown as Extract < AgentMessage , { role : "toolResult" } > ;
628627 }
629628}
630629
0 commit comments