diff --git a/lib/crates/fabro-cli/src/commands/run/run_progress/event.rs b/lib/crates/fabro-cli/src/commands/run/run_progress/event.rs index 67e8a8932..b93b9f923 100644 --- a/lib/crates/fabro-cli/src/commands/run/run_progress/event.rs +++ b/lib/crates/fabro-cli/src/commands/run/run_progress/event.rs @@ -439,11 +439,7 @@ pub(super) fn from_run_event(stored: &RunEvent) -> Option { duration_ms: props.duration_ms, }), EventBody::RunNotice(props) => Some(ProgressEvent::RunNotice { - level: match props.level { - fabro_types::RunNoticeLevel::Info => RunNoticeLevel::Info, - fabro_types::RunNoticeLevel::Warn => RunNoticeLevel::Warn, - fabro_types::RunNoticeLevel::Error => RunNoticeLevel::Error, - }, + level: props.level, code: props.code.clone(), message: props.message.clone(), }), diff --git a/lib/crates/fabro-types/src/run_event/misc.rs b/lib/crates/fabro-types/src/run_event/misc.rs index 8a148d9d0..7016a8296 100644 --- a/lib/crates/fabro-types/src/run_event/misc.rs +++ b/lib/crates/fabro-types/src/run_event/misc.rs @@ -1,8 +1,6 @@ use serde::{Deserialize, Serialize}; use serde_json::Value; -use super::TokenUsage; - #[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] pub struct ParallelStartedProps { pub visit: u32, @@ -234,26 +232,3 @@ pub struct RetroFailedProps { pub error: String, pub duration_ms: u64, } - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct AssistantUsageProps { - pub model: String, - pub input_tokens: u64, - pub output_tokens: u64, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub speed: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub cost: Option, -} - -impl From for AssistantUsageProps { - fn from(value: TokenUsage) -> Self { - Self { - model: String::new(), - input_tokens: u64::try_from(value.input_tokens).unwrap_or_default(), - output_tokens: u64::try_from(value.output_tokens).unwrap_or_default(), - speed: value.speed, - cost: None, - } - } -} diff --git a/lib/crates/fabro-types/src/run_event/mod.rs b/lib/crates/fabro-types/src/run_event/mod.rs index 1c9b6cd50..aa9bbd22e 100644 --- a/lib/crates/fabro-types/src/run_event/mod.rs +++ b/lib/crates/fabro-types/src/run_event/mod.rs @@ -338,12 +338,12 @@ impl RunEvent { Ok(Value::Object(map)) } - pub fn event_name(&self) -> String { - self.event.clone() + pub fn event_name(&self) -> &str { + &self.event } - pub fn properties(&self) -> Value { - self.properties.clone() + pub fn properties(&self) -> &Value { + &self.properties } pub fn refresh_cache(&mut self) { diff --git a/lib/crates/fabro-types/src/run_event/run.rs b/lib/crates/fabro-types/src/run_event/run.rs index 8937ae9f0..ac8456786 100644 --- a/lib/crates/fabro-types/src/run_event/run.rs +++ b/lib/crates/fabro-types/src/run_event/run.rs @@ -2,7 +2,7 @@ use std::collections::BTreeMap; use serde::{Deserialize, Serialize}; -use crate::{Graph, RunId, Settings, StatusReason}; +use crate::{Graph, Settings, StatusReason}; use super::{RunNoticeLevel, TokenUsage}; @@ -93,18 +93,3 @@ pub struct RunNoticeProps { pub code: String, pub message: String, } - -#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)] -pub struct RunEventHeader { - pub id: String, - pub ts: chrono::DateTime, - pub run_id: RunId, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub node_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub node_label: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub session_id: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub parent_session_id: Option, -} diff --git a/lib/crates/fabro-workflow/src/lifecycle/event.rs b/lib/crates/fabro-workflow/src/lifecycle/event.rs index 38e679e04..6bf2a176d 100644 --- a/lib/crates/fabro-workflow/src/lifecycle/event.rs +++ b/lib/crates/fabro-workflow/src/lifecycle/event.rs @@ -96,7 +96,7 @@ impl RunLifecycle for EventLifecycle { // Reset run_start for duration measurement *self.run_start.lock().unwrap() = Instant::now(); - // Emit WorkflowRunStarted + // Emit RunStarted self.emitter.emit(&Event::WorkflowRunStarted { name: self.graph_name.clone(), run_id: self.run_id, diff --git a/lib/crates/fabro-workflow/src/pipeline/execute/tests.rs b/lib/crates/fabro-workflow/src/pipeline/execute/tests.rs index 6344492ca..64b08c625 100644 --- a/lib/crates/fabro-workflow/src/pipeline/execute/tests.rs +++ b/lib/crates/fabro-workflow/src/pipeline/execute/tests.rs @@ -938,7 +938,7 @@ async fn run_with_lifecycle_emits_initialize_and_setup_events() { let events_clone = Arc::clone(&events); let emitter = test_emitter("order-test"); emitter.on_event(move |event| { - let name = match event.event_name().as_str() { + let name = match event.event_name() { "sandbox.initialized" => "SandboxInitialized", "setup.started" => "SetupStarted", "setup.completed" => "SetupCompleted", diff --git a/lib/crates/fabro-workflow/src/pipeline/initialize.rs b/lib/crates/fabro-workflow/src/pipeline/initialize.rs index ef48e8486..9f4c2055f 100644 --- a/lib/crates/fabro-workflow/src/pipeline/initialize.rs +++ b/lib/crates/fabro-workflow/src/pipeline/initialize.rs @@ -829,7 +829,7 @@ mod tests { let seen = Arc::new(std::sync::Mutex::new(Vec::new())); emitter.on_event({ let seen = Arc::clone(&seen); - move |event| seen.lock().unwrap().push(event.event_name()) + move |event| seen.lock().unwrap().push(event.event_name().to_string()) }); store_logger.register(&emitter);