MCPcopy Create free account
hub / github.com/arctic-cli/interface / formatTokenUsage

Function formatTokenUsage

packages/arctic/src/session/usage-format.ts:173–183  ·  view source on GitHub ↗
(usage: UsageRecordSummary["tokenUsage"])

Source from the content-addressed store, hash-verified

171}
172
173function 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
185function formatCost(cost: CostSummary | undefined): string | undefined {
186 if (!cost || typeof cost.totalCost !== "number") return undefined

Callers 1

formatUsageSummaryFunction · 0.85

Calls 2

formatCompactNumberFunction · 0.85
pushMethod · 0.80

Tested by

no test coverage detected