mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-05 23:54:50 +08:00
fix: restore telemetry merge build compatibility
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
@@ -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<C, T> {
|
||||
auto_compaction_input_tokens_threshold: u32,
|
||||
hook_abort_signal: HookAbortSignal,
|
||||
hook_progress_reporter: Option<Box<dyn HookProgressReporter>>,
|
||||
session_tracer: Option<SessionTracer>,
|
||||
}
|
||||
|
||||
impl<C, T> ConversationRuntime<C, T>
|
||||
@@ -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]
|
||||
|
||||
@@ -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<dyn std::error::Error>> {
|
||||
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));
|
||||
|
||||
Reference in New Issue
Block a user