@@ -177,6 +177,41 @@ export class TraceEventBuilder {
177177 const execData = this . buildExecutionData ( result , snapshot ) ;
178178 const verifyData = this . buildVerifyData ( result , snapshot ) ;
179179
180+ // Build elements data for pre field (include diff_status from snapshot)
181+ // Normalize importance values to importance_score (0-1 range) per snapshot
182+ const importanceValues = snapshot . elements . map ( el => el . importance ) ;
183+ const minImportance = importanceValues . length > 0 ? Math . min ( ...importanceValues ) : 0 ;
184+ const maxImportance = importanceValues . length > 0 ? Math . max ( ...importanceValues ) : 0 ;
185+ const importanceRange = maxImportance - minImportance ;
186+
187+ const preElements : TraceElement [ ] = snapshot . elements . map ( el => {
188+ // Compute normalized importance_score
189+ let importanceScore : number ;
190+ if ( importanceRange > 0 ) {
191+ importanceScore = ( el . importance - minImportance ) / importanceRange ;
192+ } else {
193+ importanceScore = 0.5 ;
194+ }
195+
196+ return {
197+ id : el . id ,
198+ role : el . role ,
199+ text : el . text ,
200+ bbox : el . bbox ,
201+ importance : el . importance ,
202+ importance_score : importanceScore ,
203+ visual_cues : el . visual_cues ,
204+ in_viewport : el . in_viewport ,
205+ is_occluded : el . is_occluded ,
206+ z_index : el . z_index ,
207+ rerank_index : el . rerank_index ,
208+ heuristic_index : el . heuristic_index ,
209+ ml_probability : el . ml_probability ,
210+ ml_score : el . ml_score ,
211+ diff_status : el . diff_status ,
212+ } ;
213+ } ) ;
214+
180215 return {
181216 v : 1 ,
182217 step_id : stepId ,
@@ -186,6 +221,7 @@ export class TraceEventBuilder {
186221 pre : {
187222 url : preUrl ,
188223 snapshot_digest : snapshotDigest ,
224+ elements : preElements , // Add elements array with diff_status
189225 } ,
190226 llm : llmData ,
191227 exec : execData ,
0 commit comments