(usage: UsageRecordSummary["tokenUsage"])
| 171 | } |
| 172 | |
| 173 | function formatTokenUsage(usage: UsageRecordSummary["tokenUsage"]): string | undefined { |
| 174 | if (!usage) return undefined |
| 175 | const parts: string[] = [] |
| 176 | if (typeof usage.total === "number") parts.push(`total ${formatCompactNumber(usage.total)}`) |
| 177 | if (typeof usage.input === "number") parts.push(`input ${formatCompactNumber(usage.input)}`) |
| 178 | if (typeof usage.output === "number") parts.push(`output ${formatCompactNumber(usage.output)}`) |
| 179 | if (typeof usage.cached === "number") parts.push(`cached ${formatCompactNumber(usage.cached)}`) |
| 180 | if (typeof usage.cacheCreation === "number") parts.push(`cache writes ${formatCompactNumber(usage.cacheCreation)}`) |
| 181 | if (parts.length === 0) return undefined |
| 182 | return parts.join(" · ") |
| 183 | } |
| 184 | |
| 185 | function formatCost(cost: CostSummary | undefined): string | undefined { |
| 186 | if (!cost || typeof cost.totalCost !== "number") return undefined |
no test coverage detected