@@ -101,7 +101,7 @@ function formatUntrustedJsonBlock(label: string, payload: unknown): string {
101101}
102102
103103function formatStructuredContextRelation ( value : unknown ) : string | undefined {
104- const relation = normalizePromptMetadataString ( value ) ;
104+ const relation = sanitizeTranscriptField ( value ) ;
105105 if ( relation === "before_current_message" ) {
106106 return "before current message" ;
107107 }
@@ -118,12 +118,12 @@ function formatChatWindowMessage(
118118 if ( ! isRecord ( value ) ) {
119119 return undefined ;
120120 }
121- const messageId = normalizePromptMetadataString ( value [ "message_id" ] ) ;
122- const sender = normalizePromptMetadataString ( value [ "sender" ] ) ?? "unknown sender" ;
121+ const messageId = sanitizeTranscriptField ( value [ "message_id" ] ) ;
122+ const sender = sanitizeTranscriptField ( value [ "sender" ] ) ?? "unknown sender" ;
123123 const timestamp = formatConversationTimestamp ( value [ "timestamp_ms" ] , envelope ) ;
124- const replyToId = normalizePromptMetadataString ( value [ "reply_to_id" ] ) ;
125- const mediaType = normalizePromptMetadataString ( value [ "media_type" ] ) ;
126- const mediaRef = normalizePromptMetadataString ( value [ "media_ref" ] ) ;
124+ const replyToId = sanitizeTranscriptField ( value [ "reply_to_id" ] ) ;
125+ const mediaType = sanitizeTranscriptField ( value [ "media_type" ] ) ;
126+ const mediaRef = sanitizeTranscriptField ( value [ "media_ref" ] ) ;
127127 const body = sanitizeTranscriptField ( value [ "body" ] ) ;
128128 const details = [
129129 messageId ? `#${ messageId } ` : undefined ,
@@ -154,9 +154,9 @@ function formatChatWindowStructuredContext(
154154 if ( lines . length === 0 ) {
155155 return undefined ;
156156 }
157- const label = normalizePromptMetadataString ( entry . label ) ?? "Chat window" ;
157+ const label = sanitizeTranscriptField ( entry . label ) ?? "Chat window" ;
158158 const relation = formatStructuredContextRelation ( entry . payload [ "relation" ] ) ;
159- const order = normalizePromptMetadataString ( entry . payload [ "order" ] ) ;
159+ const order = sanitizeTranscriptField ( entry . payload [ "order" ] ) ;
160160 const qualifiers = [ "untrusted" , order , relation ] . filter ( Boolean ) . join ( ", " ) ;
161161 return [ `${ label } (${ qualifiers } ):` , ...lines ] . join ( "\n" ) ;
162162}
0 commit comments