use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct LocalShellToolCall {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "action")]
pub action: Box<models::LocalShellExecAction>,
#[serde(rename = "status")]
pub status: Status,
}
impl LocalShellToolCall {
pub fn new(
r#type: Type,
id: String,
call_id: String,
action: models::LocalShellExecAction,
status: Status,
) -> LocalShellToolCall {
LocalShellToolCall {
r#type,
id,
call_id,
action: Box::new(action),
status,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "local_shell_call")]
LocalShellCall,
}
impl Default for Type {
fn default() -> Type {
Self::LocalShellCall
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Status {
#[serde(rename = "in_progress")]
InProgress,
#[serde(rename = "completed")]
Completed,
#[serde(rename = "incomplete")]
Incomplete,
}
impl Default for Status {
fn default() -> Status {
Self::InProgress
}
}
impl std::fmt::Display for LocalShellToolCall {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}