({
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
})
| 895 | * Called by restoreCostStateForSession in cost-tracker.ts. |
| 896 | */ |
| 897 | export function setCostStateForRestore({ |
| 898 | totalCostUSD, |
| 899 | totalAPIDuration, |
| 900 | totalAPIDurationWithoutRetries, |
| 901 | totalToolDuration, |
| 902 | totalLinesAdded, |
| 903 | totalLinesRemoved, |
| 904 | lastDuration, |
| 905 | modelUsage, |
| 906 | }: { |
| 907 | totalCostUSD: number |
| 908 | totalAPIDuration: number |
| 909 | totalAPIDurationWithoutRetries: number |
| 910 | totalToolDuration: number |
| 911 | totalLinesAdded: number |
| 912 | totalLinesRemoved: number |
| 913 | lastDuration: number | undefined |
| 914 | modelUsage: { [modelName: string]: ModelUsage } | undefined |
| 915 | }): void { |
| 916 | STATE.totalCostUSD = totalCostUSD |
| 917 | STATE.totalAPIDuration = totalAPIDuration |
| 918 | STATE.totalAPIDurationWithoutRetries = totalAPIDurationWithoutRetries |
| 919 | STATE.totalToolDuration = totalToolDuration |
| 920 | STATE.totalLinesAdded = totalLinesAdded |
| 921 | STATE.totalLinesRemoved = totalLinesRemoved |
| 922 | |
| 923 | // Restore per-model usage breakdown |
| 924 | if (modelUsage) { |
| 925 | STATE.modelUsage = modelUsage |
| 926 | } |
| 927 | |
| 928 | // Adjust startTime to make wall duration accumulate |
| 929 | if (lastDuration) { |
| 930 | STATE.startTime = Date.now() - lastDuration |
| 931 | } |
| 932 | } |
| 933 | |
| 934 | // Only used in tests |
| 935 | export function resetStateForTests(): void { |
no outgoing calls
no test coverage detected