refactor(agent): use hive_claude::TokenUsage directly, drop the duplicate
This commit is contained in:
parent
c9de2eeb97
commit
66f5b8720d
7 changed files with 16 additions and 48 deletions
|
|
@ -11,7 +11,7 @@ use anyhow::Result;
|
|||
use hive_claude::{Config, InfiniteSession, PercentPolicy, Sink};
|
||||
use serde_json::Value;
|
||||
|
||||
use crate::events::{Bus, LiveEvent, TokenUsage};
|
||||
use crate::events::{Bus, LiveEvent};
|
||||
use crate::mcp;
|
||||
|
||||
// Hive-enforced claude settings ship at `/etc/claude-code/managed-settings.json`
|
||||
|
|
@ -561,27 +561,13 @@ fn apply_telemetry(bus: &Bus, telemetry: &hive_claude::Telemetry) {
|
|||
if telemetry.context.context_tokens() == 0 && telemetry.cost.context_tokens() == 0 {
|
||||
return;
|
||||
}
|
||||
bus.record_turn_usage(
|
||||
to_bus_usage(telemetry.context),
|
||||
to_bus_usage(telemetry.cost),
|
||||
);
|
||||
bus.record_turn_usage(telemetry.context, telemetry.cost);
|
||||
bus.set_resolved_model(telemetry.model.clone());
|
||||
if let Some(window) = telemetry.context_window {
|
||||
bus.set_api_context_window(window);
|
||||
}
|
||||
}
|
||||
|
||||
/// Convert the lib's `TokenUsage` into the bus/stats `TokenUsage` (identical
|
||||
/// fields; the two crates keep their own types to avoid coupling).
|
||||
fn to_bus_usage(u: hive_claude::TokenUsage) -> TokenUsage {
|
||||
TokenUsage {
|
||||
input_tokens: u.input_tokens,
|
||||
output_tokens: u.output_tokens,
|
||||
cache_read_input_tokens: u.cache_read_input_tokens,
|
||||
cache_creation_input_tokens: u.cache_creation_input_tokens,
|
||||
}
|
||||
}
|
||||
|
||||
/// Archive (do NOT delete) the harness's own session so the next turn's
|
||||
/// `--resume <title>` misses and self-heals into a fresh `--name <title>`
|
||||
/// session. Delegates the rename to [`hive_claude::SessionStore::archive_by_title`]
|
||||
|
|
|
|||
Loading…
Reference in a new issue