mirror of
https://github.com/instructkr/claw-code.git
synced 2026-04-07 16:44: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" }
|
runtime = { path = "../runtime" }
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
telemetry = { path = "../telemetry" }
|
||||||
tokio = { version = "1", features = ["io-util", "macros", "net", "rt-multi-thread", "time"] }
|
tokio = { version = "1", features = ["io-util", "macros", "net", "rt-multi-thread", "time"] }
|
||||||
|
|
||||||
[lints]
|
[lints]
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ use runtime::{
|
|||||||
OAuthTokenExchangeRequest,
|
OAuthTokenExchangeRequest,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
use telemetry::SessionTracer;
|
||||||
|
|
||||||
use crate::error::ApiError;
|
use crate::error::ApiError;
|
||||||
|
|
||||||
@@ -194,6 +195,11 @@ impl AnthropicClient {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[must_use]
|
||||||
|
pub fn with_session_tracer(self, _session_tracer: SessionTracer) -> Self {
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn auth_source(&self) -> &AuthSource {
|
pub fn auth_source(&self) -> &AuthSource {
|
||||||
&self.auth
|
&self.auth
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ plugins = { path = "../plugins" }
|
|||||||
regex = "1"
|
regex = "1"
|
||||||
serde = { version = "1", features = ["derive"] }
|
serde = { version = "1", features = ["derive"] }
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
|
telemetry = { path = "../telemetry" }
|
||||||
tokio = { version = "1", features = ["io-util", "macros", "process", "rt", "rt-multi-thread", "time"] }
|
tokio = { version = "1", features = ["io-util", "macros", "process", "rt", "rt-multi-thread", "time"] }
|
||||||
walkdir = "2"
|
walkdir = "2"
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fmt::{Display, Formatter};
|
use std::fmt::{Display, Formatter};
|
||||||
|
|
||||||
use serde_json::{Map, Value};
|
|
||||||
use telemetry::SessionTracer;
|
use telemetry::SessionTracer;
|
||||||
|
|
||||||
use crate::compact::{
|
use crate::compact::{
|
||||||
@@ -114,6 +113,7 @@ pub struct ConversationRuntime<C, T> {
|
|||||||
auto_compaction_input_tokens_threshold: u32,
|
auto_compaction_input_tokens_threshold: u32,
|
||||||
hook_abort_signal: HookAbortSignal,
|
hook_abort_signal: HookAbortSignal,
|
||||||
hook_progress_reporter: Option<Box<dyn HookProgressReporter>>,
|
hook_progress_reporter: Option<Box<dyn HookProgressReporter>>,
|
||||||
|
session_tracer: Option<SessionTracer>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C, T> ConversationRuntime<C, T>
|
impl<C, T> ConversationRuntime<C, T>
|
||||||
@@ -162,6 +162,7 @@ where
|
|||||||
auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(),
|
auto_compaction_input_tokens_threshold: auto_compaction_threshold_from_env(),
|
||||||
hook_abort_signal: HookAbortSignal::default(),
|
hook_abort_signal: HookAbortSignal::default(),
|
||||||
hook_progress_reporter: None,
|
hook_progress_reporter: None,
|
||||||
|
session_tracer: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,6 +193,12 @@ where
|
|||||||
self
|
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 {
|
fn run_pre_tool_use_hook(&mut self, tool_name: &str, input: &str) -> HookRunResult {
|
||||||
if let Some(reporter) = self.hook_progress_reporter.as_mut() {
|
if let Some(reporter) = self.hook_progress_reporter.as_mut() {
|
||||||
self.hook_runner.run_pre_tool_use_with_context(
|
self.hook_runner.run_pre_tool_use_with_context(
|
||||||
@@ -272,7 +279,7 @@ where
|
|||||||
let user_input = user_input.into();
|
let user_input = user_input.into();
|
||||||
self.record_turn_started(&user_input);
|
self.record_turn_started(&user_input);
|
||||||
self.session
|
self.session
|
||||||
.push_user_text(user_input.into())
|
.push_user_text(user_input)
|
||||||
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
.map_err(|error| RuntimeError::new(error.to_string()))?;
|
||||||
|
|
||||||
let mut assistant_messages = Vec::new();
|
let mut assistant_messages = Vec::new();
|
||||||
@@ -488,6 +495,24 @@ where
|
|||||||
removed_message_count: result.removed_message_count,
|
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]
|
#[must_use]
|
||||||
|
|||||||
@@ -1165,6 +1165,7 @@ impl LiveCli {
|
|||||||
let session = create_managed_session_handle(&session_state.session_id)?;
|
let session = create_managed_session_handle(&session_state.session_id)?;
|
||||||
let runtime = build_runtime(
|
let runtime = build_runtime(
|
||||||
session_state.with_persistence_path(session.path.clone()),
|
session_state.with_persistence_path(session.path.clone()),
|
||||||
|
&session.id,
|
||||||
model.clone(),
|
model.clone(),
|
||||||
system_prompt.clone(),
|
system_prompt.clone(),
|
||||||
enable_tools,
|
enable_tools,
|
||||||
@@ -1223,6 +1224,7 @@ impl LiveCli {
|
|||||||
let hook_abort_signal = runtime::HookAbortSignal::new();
|
let hook_abort_signal = runtime::HookAbortSignal::new();
|
||||||
let runtime = build_runtime(
|
let runtime = build_runtime(
|
||||||
self.runtime.session().clone(),
|
self.runtime.session().clone(),
|
||||||
|
&self.session.id,
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
true,
|
true,
|
||||||
@@ -1564,6 +1566,7 @@ impl LiveCli {
|
|||||||
self.session = create_managed_session_handle(&session_state.session_id)?;
|
self.session = create_managed_session_handle(&session_state.session_id)?;
|
||||||
self.runtime = build_runtime(
|
self.runtime = build_runtime(
|
||||||
session_state.with_persistence_path(self.session.path.clone()),
|
session_state.with_persistence_path(self.session.path.clone()),
|
||||||
|
&self.session.id,
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
true,
|
true,
|
||||||
@@ -1725,6 +1728,7 @@ impl LiveCli {
|
|||||||
forked.save_to_path(&handle.path)?;
|
forked.save_to_path(&handle.path)?;
|
||||||
self.runtime = build_runtime(
|
self.runtime = build_runtime(
|
||||||
forked,
|
forked,
|
||||||
|
&handle.id,
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
true,
|
true,
|
||||||
@@ -1773,6 +1777,7 @@ impl LiveCli {
|
|||||||
fn reload_runtime_features(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
fn reload_runtime_features(&mut self) -> Result<(), Box<dyn std::error::Error>> {
|
||||||
self.runtime = build_runtime(
|
self.runtime = build_runtime(
|
||||||
self.runtime.session().clone(),
|
self.runtime.session().clone(),
|
||||||
|
&self.session.id,
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
true,
|
true,
|
||||||
@@ -1814,6 +1819,7 @@ impl LiveCli {
|
|||||||
let session = self.runtime.session().clone();
|
let session = self.runtime.session().clone();
|
||||||
let mut runtime = build_runtime(
|
let mut runtime = build_runtime(
|
||||||
session,
|
session,
|
||||||
|
&self.session.id,
|
||||||
self.model.clone(),
|
self.model.clone(),
|
||||||
self.system_prompt.clone(),
|
self.system_prompt.clone(),
|
||||||
enable_tools,
|
enable_tools,
|
||||||
@@ -3157,7 +3163,7 @@ fn build_runtime(
|
|||||||
CliToolExecutor::new(allowed_tools.clone(), emit_output, tool_registry.clone()),
|
CliToolExecutor::new(allowed_tools.clone(), emit_output, tool_registry.clone()),
|
||||||
permission_policy(permission_mode, &feature_config, &tool_registry),
|
permission_policy(permission_mode, &feature_config, &tool_registry),
|
||||||
system_prompt,
|
system_prompt,
|
||||||
feature_config,
|
&feature_config,
|
||||||
);
|
);
|
||||||
if emit_output {
|
if emit_output {
|
||||||
runtime = runtime.with_hook_progress_reporter(Box::new(CliHookProgressReporter));
|
runtime = runtime.with_hook_progress_reporter(Box::new(CliHookProgressReporter));
|
||||||
|
|||||||
Reference in New Issue
Block a user