({
totalCostUSD,
totalAPIDuration,
totalAPIDurationWithoutRetries,
totalToolDuration,
totalLinesAdded,
totalLinesRemoved,
lastDuration,
modelUsage,
}: {
totalCostUSD: number
totalAPIDuration: number
totalAPIDurationWithoutRetries: number
totalToolDuration: number
totalLinesAdded: number
totalLinesRemoved: number
lastDuration: number | undefined
modelUsage: { [modelName: string]: ModelUsage } | undefined
})
| 879 | * Called by restoreCostStateForSession in cost-tracker.ts. |
| 880 | */ |
| 881 | export function setCostStateForRestore({ |
| 882 | totalCostUSD, |
| 883 | totalAPIDuration, |
| 884 | totalAPIDurationWithoutRetries, |
| 885 | totalToolDuration, |
| 886 | totalLinesAdded, |
| 887 | totalLinesRemoved, |
| 888 | lastDuration, |
| 889 | modelUsage, |
| 890 | }: { |
| 891 | totalCostUSD: number |
| 892 | totalAPIDuration: number |
| 893 | totalAPIDurationWithoutRetries: number |
| 894 | totalToolDuration: number |
| 895 | totalLinesAdded: number |
| 896 | totalLinesRemoved: number |
| 897 | lastDuration: number | undefined |
| 898 | modelUsage: { [modelName: string]: ModelUsage } | undefined |
| 899 | }): void { |
| 900 | STATE.totalCostUSD = totalCostUSD |
| 901 | STATE.totalAPIDuration = totalAPIDuration |
| 902 | STATE.totalAPIDurationWithoutRetries = totalAPIDurationWithoutRetries |
| 903 | STATE.totalToolDuration = totalToolDuration |
| 904 | STATE.totalLinesAdded = totalLinesAdded |
| 905 | STATE.totalLinesRemoved = totalLinesRemoved |
| 906 | |
| 907 | // Restore per-model usage breakdown |
| 908 | if (modelUsage) { |
| 909 | STATE.modelUsage = modelUsage |
| 910 | } |
| 911 | |
| 912 | // Adjust startTime to make wall duration accumulate |
| 913 | if (lastDuration) { |
| 914 | STATE.startTime = Date.now() - lastDuration |
| 915 | } |
| 916 | } |
| 917 | |
| 918 | // Only used in tests |
| 919 | export function resetStateForTests(): void { |
no outgoing calls
no test coverage detected