(base)
| 948 | } |
| 949 | |
| 950 | function finalizeTrace(base) { |
| 951 | const commandFamilies = toBarRows(countBy(base.commandRuns, (run) => run.primaryCommand)); |
| 952 | const defaultChannelFamilies = toBarRows(countBy(base.events, (event) => event.kind)); |
| 953 | const exactTokens = base.exactTokens || null; |
| 954 | const tokenSourceLabel = base.tokenSourceLabel || 'Estimated from extracted trace text.'; |
| 955 | return { |
| 956 | side: base.side, |
| 957 | kind: base.kind, |
| 958 | formatLabel: base.formatLabel, |
| 959 | description: base.description, |
| 960 | fileName: base.fileName, |
| 961 | filePath: base.filePath, |
| 962 | taskPrompt: base.taskPrompt, |
| 963 | events: base.events, |
| 964 | thoughtEntries: base.thoughtEntries, |
| 965 | commandRuns: base.commandRuns, |
| 966 | finalResponses: base.finalResponses, |
| 967 | pythonScripts: base.pythonScripts || [], |
| 968 | detailEntries: base.detailEntries || [], |
| 969 | metrics: base.metrics, |
| 970 | commandFamilies, |
| 971 | channelFamilies: base.channelFamilies || defaultChannelFamilies, |
| 972 | exactTokens, |
| 973 | baseExactTokens: exactTokens, |
| 974 | tokenRows: exactTokens ? tokenRowsFromTotals(exactTokens) : [{ label: 'availability', value: 'estimate pending' }], |
| 975 | tokenSourceLabel, |
| 976 | baseTokenSourceLabel: tokenSourceLabel, |
| 977 | tokenModeLabel: exactTokens ? 'exact' : 'estimate', |
| 978 | tokenEstimateParts: mergeEstimateParts(base.tokenEstimateParts || []), |
| 979 | countedFieldLabels: base.countedFieldLabels || [], |
| 980 | tokenBasisRows: [], |
| 981 | tokenEstimateTotal: null, |
| 982 | tokenEstimateError: '', |
| 983 | tokenSelectionLabel: '', |
| 984 | companionFileName: '', |
| 985 | summary: { |
| 986 | thoughts: base.thoughtEntries.length, |
| 987 | commands: base.commandRuns.length, |
| 988 | commandRuns: base.commandRuns.length, |
| 989 | pythonScripts: (base.pythonScripts || []).length, |
| 990 | finalResponses: base.finalResponses.length, |
| 991 | events: base.events.length |
| 992 | } |
| 993 | }; |
| 994 | } |
| 995 | |
| 996 | function normalizeCodex(text, fileName, filePath, side) { |
| 997 | const lines = text.split(/\r?\n/).filter(Boolean); |
no test coverage detected