use serde::{Deserialize, Serialize};
use super::event_compaction::{
CompactionFailure, CompactionOutcome, CompactionStart, ContextTruncation,
};
use super::event_rlm::{RlmCompletion, RlmProgressEvent, RlmSubcallFallback};
use super::event_token::{TokenDelta, TokenEstimate};
use super::types::Session;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SessionResult {
pub text: String,
pub session_id: String,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum SessionEvent {
Thinking,
ToolCallStart {
name: String,
arguments: String,
},
ToolCallComplete {
name: String,
output: String,
success: bool,
duration_ms: u64,
},
TextChunk(String),
TextComplete(String),
ThinkingComplete(String),
UsageReport {
prompt_tokens: usize,
completion_tokens: usize,
duration_ms: u64,
model: String,
},
SessionSync(Box<Session>),
Done,
Error(String),
TokenEstimate(TokenEstimate),
TokenUsage(TokenDelta),
RlmProgress(RlmProgressEvent),
RlmComplete(RlmCompletion),
CompactionStarted(CompactionStart),
CompactionCompleted(CompactionOutcome),
CompactionFailed(CompactionFailure),
ContextTruncated(ContextTruncation),
RlmSubcallFallback(RlmSubcallFallback),
}
impl SessionEvent {
pub fn is_durable(&self) -> bool {
matches!(
self,
Self::TokenUsage(_)
| Self::RlmComplete(_)
| Self::CompactionStarted(_)
| Self::CompactionCompleted(_)
| Self::CompactionFailed(_)
| Self::ContextTruncated(_)
| Self::RlmSubcallFallback(_)
)
}
}