This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| input=$(cat) | |
| # --- Extract fields --- | |
| MODEL=$(echo "$input" | jq -r '.model.id') | |
| DURATION_MS=$(echo "$input" | jq -r '.cost.total_duration_ms // 0') | |
| COST=$(echo "$input" | jq -r '.cost.total_cost_usd // 0') | |
| #PCT=$(echo "$input" | jq -r '.context_window.used_percentage // 0' | cut -d. -f1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Force UTF-8 output so special characters render correctly | |
| [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | |
| # Read JSON from stdin | |
| $data = [Console]::In.ReadToEnd() | ConvertFrom-Json | |
| # --- Extract fields --- | |
| $model = $data.model.id | |
| $durationMs = if ($data.cost.total_duration_ms) { $data.cost.total_duration_ms } else { 0 } | |
| $cost = if ($data.cost.total_cost_usd) { $data.cost.total_cost_usd } else { 0 } |