Add total cost to environment details (#1788)

* Add total cost to environment details

* Update src/core/Cline.ts

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>

* Update src/core/Cline.ts

---------

Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
This commit is contained in:
Matt Rubens 2025-03-18 22:04:51 -04:00 committed by GitHub
parent a15691dc1d
commit ff14efac81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3691,13 +3691,13 @@ export class Cline extends EventEmitter<ClineEvents> {
details += `\n\n# Current Time\n${formatter.format(now)} (${timeZone}, UTC${timeZoneOffsetStr})`
// Add context tokens information
const { contextTokens } = getApiMetrics(this.clineMessages)
const { contextTokens, totalCost } = getApiMetrics(this.clineMessages)
const modelInfo = this.api.getModel().info
const contextWindow = modelInfo.contextWindow
const contextPercentage =
contextTokens && contextWindow ? Math.round((contextTokens / contextWindow) * 100) : undefined
details += `\n\n# Current Context Size (Tokens)\n${contextTokens ? `${contextTokens.toLocaleString()} (${contextPercentage}%)` : "(Not available)"}`
details += `\n\n# Current Cost\n${totalCost !== null ? `$${totalCost.toFixed(2)}` : "(Not available)"}`
// Add current mode and any mode-specific warnings
const {
mode,