(text, fileName, filePath, side)
| 994 | } |
| 995 | |
| 996 | function normalizeCodex(text, fileName, filePath, side) { |
| 997 | const lines = text.split(/\r?\n/).filter(Boolean); |
| 998 | const entries = []; |
| 999 | const callById = new Map(); |
| 1000 | const runByCallId = new Map(); |
| 1001 | const runBySession = new Map(); |
| 1002 | const commandRuns = []; |
| 1003 | const thoughtEntries = []; |
| 1004 | const finalResponses = []; |
| 1005 | const pythonScripts = []; |
| 1006 | const pythonSeen = new Set(); |
| 1007 | const events = []; |
| 1008 | const detailEntries = []; |
| 1009 | const estimateParts = []; |
| 1010 | let latestTokens = null; |
| 1011 | let thoughtOrder = 0; |
| 1012 | let commandOrder = 0; |
| 1013 | let userPrompt = ''; |
| 1014 | lines.forEach((line) => { |
| 1015 | const item = safeJsonParse(line); |
| 1016 | if (!item || typeof item !== 'object') { |
| 1017 | return; |
| 1018 | } |
| 1019 | entries.push(item); |
| 1020 | if (item.type === 'event_msg' && item.payload && item.payload.type === 'token_count') { |
| 1021 | latestTokens = item.payload.info ? item.payload.info.total_token_usage : null; |
| 1022 | } |
| 1023 | }); |
| 1024 | entries.forEach((item, index) => { |
| 1025 | const id = side + '-codex-' + index; |
| 1026 | const timeLabel = formatTimestamp(item.timestamp || ''); |
| 1027 | if (item.type === 'event_msg' && item.payload && item.payload.type === 'user_message') { |
| 1028 | const summary = shortMultiline(item.payload.message, 360); |
| 1029 | if (!userPrompt) { |
| 1030 | userPrompt = summary; |
| 1031 | } |
| 1032 | estimateParts.push({ label: 'user messages', text: String(item.payload.message || '') }); |
| 1033 | events.push({ id, kind: 'user_message', summary, timeLabel, chips: ['user'] }); |
| 1034 | detailEntries.push(createDetailEntry({ |
| 1035 | id: id + '-detail', |
| 1036 | kind: 'user_message', |
| 1037 | kindLabel: 'User', |
| 1038 | summary, |
| 1039 | timeLabel, |
| 1040 | chips: ['user'], |
| 1041 | sections: buildRichTextSections(item.payload.message, { textLabel: 'Prompt' }) |
| 1042 | })); |
| 1043 | return; |
| 1044 | } |
| 1045 | if (item.type === 'event_msg' && item.payload && item.payload.type === 'agent_message') { |
| 1046 | thoughtOrder += 1; |
| 1047 | const textBody = shortMultiline(item.payload.message, 520); |
| 1048 | thoughtEntries.push({ |
| 1049 | id, |
| 1050 | order: thoughtOrder, |
| 1051 | text: textBody, |
| 1052 | timeLabel, |
| 1053 | chips: [item.payload.phase || 'commentary'], |
no test coverage detected