From 416c8e89b9d2361561e994f9d9ce992113ca6459 Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Thu, 2 Apr 2026 11:16:56 +0900 Subject: [PATCH] fix: restore telemetry merge build compatibility --- rust/crates/api/Cargo.toml | 1 + rust/crates/api/src/providers/anthropic.rs | 6 +++++ rust/crates/runtime/Cargo.toml | 1 + rust/crates/runtime/src/conversation.rs | 29 ++++++++++++++++++++-- rust/crates/rusty-claude-cli/src/main.rs | 8 +++++- 5 files changed, 42 insertions(+), 3 deletions(-) diff --git a/rust/crates/api/Cargo.toml b/rust/crates/api/Cargo.toml index b9923a8..d2e009c 100644 --- a/rust/crates/api/Cargo.toml +++ b/rust/crates/api/Cargo.toml @@ -10,6 +10,7 @@ reqwest = { version = "0.12", default-features = false, features = ["json", "rus runtime = { path = "../runtime" } serde = { version = "1", features = ["derive"] } serde_json.workspace = true +telemetry = { path = "../telemetry" } tokio = { version = "1", features = ["io-util", "macros", "net", "rt-multi-thread", "time"] } [lints] diff --git a/rust/crates/api/src/providers/anthropic.rs b/rust/crates/api/src/providers/anthropic.rs index 4242cb4..0ffcf59 100644 --- a/rust/crates/api/src/providers/anthropic.rs +++ b/rust/crates/api/src/providers/anthropic.rs @@ -6,6 +6,7 @@ use runtime::{ OAuthTokenExchangeRequest, }; use serde::Deserialize; +use telemetry::SessionTracer; use crate::error::ApiError; @@ -194,6 +195,11 @@ impl AnthropicClient { self } + #[must_use] + pub fn with_session_tracer(self, _session_tracer: SessionTracer) -> Self { + self + } + #[must_use] pub fn auth_source(&self) -> &AuthSource { &self.auth diff --git a/rust/crates/runtime/Cargo.toml b/rust/crates/runtime/Cargo.toml index f462205..8b69217 100644 --- a/rust/crates/runtime/Cargo.toml +++ b/rust/crates/runtime/Cargo.toml @@ -12,6 +12,7 @@ plugins = { path = "../plugins" } regex = "1" serde = { version = "1", features = ["derive"] } serde_json.workspace = true +telemetry = { path = "../telemetry" } tokio = { version = "1", features = ["io-util", "macros", "process", "rt", "rt-multi-thread", "time"] } walkdir = "2" diff --git a/rust/crates/runtime/src/conversation.rs b/rust/crates/runtime/src/conversation.rs index 14a8133..cfb273b 100644 --- a/rust/crates/runtime/src/conversation.rs +++ b/rust/crates/runtime/src/conversation.rs @@ -1,7 +1,6 @@ use std::collections::BTreeMap; use std::fmt::{Display, Formatter}; -use serde_json::{Map, Value}; use telemetry::SessionTracer; use crate::compact::{ @@ -114,6 +113,7 @@ pub struct ConversationRuntime { auto_compaction_input_tokens_threshold: u32, hook_abort_signal: HookAbortSignal, hook_progress_reporter: Option>, + session_tracer: Option, } impl ConversationRuntime @@ -162,6 +162,7 @@ where auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(), hook_abort_signal: HookAbortSignal::default(), hook_progress_reporter: None, + session_tracer: None, } } @@ -192,6 +193,12 @@ where self } + #[must_use] + pub fn with_session_tracer(mut self, session_tracer: SessionTracer) -> Self { + self.session_tracer = Some(session_tracer); + self + } + fn run_pre_tool_use_hook(&mut self, tool_name: &str, input: &str) -> HookRunResult { if let Some(reporter) = self.hook_progress_reporter.as_mut() { self.hook_runner.run_pre_tool_use_with_context( @@ -272,7 +279,7 @@ where let user_input = user_input.into(); self.record_turn_started(&user_input); self.session - .push_user_text(user_input.into()) + .push_user_text(user_input) .map_err(|error| RuntimeError::new(error.to_string()))?; let mut assistant_messages = Vec::new(); @@ -488,6 +495,24 @@ where removed_message_count: result.removed_message_count, }) } + + fn record_turn_started(&self, _user_input: &str) {} + + fn record_assistant_iteration( + &self, + _iteration: usize, + _assistant_message: &ConversationMessage, + _pending_tool_use_count: usize, + ) { + } + + fn record_tool_started(&self, _iteration: usize, _tool_name: &str) {} + + fn record_tool_finished(&self, _iteration: usize, _result_message: &ConversationMessage) {} + + fn record_turn_completed(&self, _summary: &TurnSummary) {} + + fn record_turn_failed(&self, _iteration: usize, _error: &RuntimeError) {} } #[must_use] diff --git a/rust/crates/rusty-claude-cli/src/main.rs b/rust/crates/rusty-claude-cli/src/main.rs index 68c849f..71aef93 100644 --- a/rust/crates/rusty-claude-cli/src/main.rs +++ b/rust/crates/rusty-claude-cli/src/main.rs @@ -1165,6 +1165,7 @@ impl LiveCli { let session = create_managed_session_handle(&session_state.session_id)?; let runtime = build_runtime( session_state.with_persistence_path(session.path.clone()), + &session.id, model.clone(), system_prompt.clone(), enable_tools, @@ -1223,6 +1224,7 @@ impl LiveCli { let hook_abort_signal = runtime::HookAbortSignal::new(); let runtime = build_runtime( self.runtime.session().clone(), + &self.session.id, self.model.clone(), self.system_prompt.clone(), true, @@ -1564,6 +1566,7 @@ impl LiveCli { self.session = create_managed_session_handle(&session_state.session_id)?; self.runtime = build_runtime( session_state.with_persistence_path(self.session.path.clone()), + &self.session.id, self.model.clone(), self.system_prompt.clone(), true, @@ -1725,6 +1728,7 @@ impl LiveCli { forked.save_to_path(&handle.path)?; self.runtime = build_runtime( forked, + &handle.id, self.model.clone(), self.system_prompt.clone(), true, @@ -1773,6 +1777,7 @@ impl LiveCli { fn reload_runtime_features(&mut self) -> Result<(), Box> { self.runtime = build_runtime( self.runtime.session().clone(), + &self.session.id, self.model.clone(), self.system_prompt.clone(), true, @@ -1814,6 +1819,7 @@ impl LiveCli { let session = self.runtime.session().clone(); let mut runtime = build_runtime( session, + &self.session.id, self.model.clone(), self.system_prompt.clone(), enable_tools, @@ -3157,7 +3163,7 @@ fn build_runtime( CliToolExecutor::new(allowed_tools.clone(), emit_output, tool_registry.clone()), permission_policy(permission_mode, &feature_config, &tool_registry), system_prompt, - feature_config, + &feature_config, ); if emit_output { runtime = runtime.with_hook_progress_reporter(Box::new(CliHookProgressReporter));