use objectiveai_cli_sdk::output::{Cleared, Handle, Items, LogContent, LogStreamReady, Output};
pub async fn emit_log_stream_ready(id: &str, handle: &Handle) {
Output::<LogStreamReady>::Notification(objectiveai_cli_sdk::output::Notification { value: LogStreamReady {
log_stream_ready: id.to_string(),
} })
.emit(handle)
.await;
}
pub fn parse_log_stream_ready(line: &str) -> Option<String> {
let trimmed = line.trim();
let parsed: Output<LogStreamReady> = serde_json::from_str(trimmed).ok()?;
match parsed {
Output::Notification(objectiveai_cli_sdk::output::Notification {
value: LogStreamReady { log_stream_ready },
}) => Some(log_stream_ready),
Output::Error(_) | Output::Begin | Output::End => None,
}
}
pub async fn emit_log_content(content: objectiveai_sdk::filesystem::logs::LogContent, handle: &Handle) {
let wire = match content {
objectiveai_sdk::filesystem::logs::LogContent::Json(v) => LogContent::Json { content: v },
objectiveai_sdk::filesystem::logs::LogContent::DataUrl(s) => LogContent::DataUrl {
content_data_url: s,
},
};
Output::<LogContent>::Notification(objectiveai_cli_sdk::output::Notification { value: wire }).emit(handle).await;
}
pub async fn emit_log_list(
items: Vec<objectiveai_sdk::filesystem::logs::ListItem>,
handle: &Handle,
) {
Output::<Items<objectiveai_sdk::filesystem::logs::ListItem>>::Notification(objectiveai_cli_sdk::output::Notification { value: Items { items } })
.emit(handle)
.await;
}
pub async fn emit_log_clear_count(count: u64, handle: &Handle) {
Output::<Cleared>::Notification(objectiveai_cli_sdk::output::Notification { value: Cleared { cleared: count } })
.emit(handle)
.await;
}