diff --git a/crates/app-tauri/src/events.rs b/crates/app-tauri/src/events.rs index f31ff2e..e32e7de 100644 --- a/crates/app-tauri/src/events.rs +++ b/crates/app-tauri/src/events.rs @@ -96,6 +96,41 @@ pub enum DomainEventDto { /// New liveness, as a lowercase string (`"alive"` / `"stalled"`). liveness: AgentLivenessDto, }, + /// A background task lifecycle/delivery event occurred. + #[serde(rename_all = "camelCase")] + BackgroundTaskChanged { + /// Project id. + project_id: String, + /// Task id. + task_id: String, + /// Owner agent id. + agent_id: String, + /// Lightweight event/state label. + state: String, + }, + /// An agent inbox queue depth changed. + #[serde(rename_all = "camelCase")] + AgentInboxChanged { + /// Agent id. + agent_id: String, + /// Queue depth after the operation. + depth: usize, + /// Queue operation label. + action: String, + }, + /// An owner wake event occurred. + #[serde(rename_all = "camelCase")] + AgentWakeChanged { + /// Project id. + project_id: String, + /// Agent id. + agent_id: String, + /// Wake operation label. + action: String, + /// Failure reason, when any. + #[serde(skip_serializing_if = "Option::is_none")] + reason: Option, + }, /// An agent's runtime profile was changed (hot-swap of the AI engine). #[serde(rename_all = "camelCase")] AgentProfileChanged { @@ -359,6 +394,115 @@ impl From<&DomainEvent> for DomainEventDto { liveness: (*liveness).into(), } } + DomainEvent::BackgroundTaskStarted { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "started".to_owned(), + }, + DomainEvent::BackgroundTaskStateChanged { + project_id, + task_id, + owner_agent_id, + state, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: format!("{state:?}"), + }, + DomainEvent::BackgroundTaskCompleted { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "completed".to_owned(), + }, + DomainEvent::BackgroundTaskFailed { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "failed".to_owned(), + }, + DomainEvent::BackgroundTaskCancelled { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "cancelled".to_owned(), + }, + DomainEvent::BackgroundTaskCompletionDeliveryPending { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "deliveryPending".to_owned(), + }, + DomainEvent::BackgroundTaskCompletionDelivered { + project_id, + task_id, + owner_agent_id, + } => Self::BackgroundTaskChanged { + project_id: project_id.to_string(), + task_id: task_id.to_string(), + agent_id: owner_agent_id.to_string(), + state: "delivered".to_owned(), + }, + DomainEvent::AgentInboxQueued { agent_id, depth } => Self::AgentInboxChanged { + agent_id: agent_id.to_string(), + depth: *depth, + action: "queued".to_owned(), + }, + DomainEvent::AgentInboxDrained { agent_id, depth } => Self::AgentInboxChanged { + agent_id: agent_id.to_string(), + depth: *depth, + action: "drained".to_owned(), + }, + DomainEvent::AgentWakeScheduled { + project_id, + agent_id, + } => Self::AgentWakeChanged { + project_id: project_id.to_string(), + agent_id: agent_id.to_string(), + action: "scheduled".to_owned(), + reason: None, + }, + DomainEvent::AgentWakeStarted { + project_id, + agent_id, + } => Self::AgentWakeChanged { + project_id: project_id.to_string(), + agent_id: agent_id.to_string(), + action: "started".to_owned(), + reason: None, + }, + DomainEvent::AgentWakeFailed { + project_id, + agent_id, + reason, + } => Self::AgentWakeChanged { + project_id: project_id.to_string(), + agent_id: agent_id.to_string(), + action: "failed".to_owned(), + reason: Some(reason.clone()), + }, DomainEvent::AgentProfileChanged { agent_id, profile_id,