Inserts transcript-recorded token usage into message metadata under the `usage` key the savings dashboard reads. Probes each candidate value in order and keeps the first recognized counters object.
(
map: &mut serde_json::Map<String, Value>,
candidates: &[&Value],
)
| 363 | /// `usage` key the savings dashboard reads. Probes each candidate value in |
| 364 | /// order and keeps the first recognized counters object. |
| 365 | pub(crate) fn append_usage_metadata( |
| 366 | map: &mut serde_json::Map<String, Value>, |
| 367 | candidates: &[&Value], |
| 368 | ) { |
| 369 | if map.contains_key("usage") { |
| 370 | return; |
| 371 | } |
| 372 | if let Some(usage) = candidates |
| 373 | .iter() |
| 374 | .find_map(|value| usage_counters_from(value)) |
| 375 | { |
| 376 | map.insert("usage".to_string(), usage); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | fn collect_tool_names(value: &Value, tools: &mut Vec<String>) { |
| 381 | match value { |
no test coverage detected