refactor(agent): use hive_claude::TokenUsage directly, drop the duplicate

This commit is contained in:
müde 2026-07-05 20:21:33 +02:00
commit 66f5b8720d
7 changed files with 16 additions and 48 deletions

View file

@ -7,6 +7,7 @@ version.workspace = true
workspace = true
[dependencies]
serde = { workspace = true }
serde_json.workspace = true
thiserror.workspace = true
tokio.workspace = true

View file

@ -6,10 +6,11 @@
//! also want the raw events (for their own SSE / tool-call accounting) still
//! get them through their [`crate::Sink`].
use serde::{Deserialize, Serialize};
use serde_json::Value;
/// Token counts from one `usage` block. All in tokens; missing fields read `0`.
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct TokenUsage {
pub input_tokens: u64,
pub output_tokens: u64,
@ -37,7 +38,7 @@ impl TokenUsage {
}
/// Everything the driver tracks from one turn's stream-json output.
#[derive(Debug, Clone, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Telemetry {
/// Most recent per-inference usage (from `assistant` events) — the live
/// context footprint (the number to watch for compaction).
@ -108,7 +109,7 @@ fn context_window_from_result(event: &Value) -> Option<u64> {
/// The compaction signal: the live context size and the window it's measured
/// against. Derived from [`Telemetry`] via [`Telemetry::usage`].
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct Usage {
/// Tokens in the last inference's context. `0` until the first `assistant`
/// event.