use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct BetaComputerToolCall {
#[serde(
rename = "agent",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub agent: Option<Option<Box<models::BetaAgentTag>>>,
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "call_id")]
pub call_id: String,
#[serde(rename = "action", skip_serializing_if = "Option::is_none")]
pub action: Option<Box<models::BetaComputerAction>>,
#[serde(rename = "actions", skip_serializing_if = "Option::is_none")]
pub actions: Option<Vec<models::BetaComputerAction>>,
#[serde(rename = "pending_safety_checks")]
pub pending_safety_checks: Vec<models::BetaComputerCallSafetyCheckParam>,
#[serde(rename = "status")]
pub status: Status,
}
impl BetaComputerToolCall {
pub fn new(
r#type: Type,
id: String,
call_id: String,
pending_safety_checks: Vec<models::BetaComputerCallSafetyCheckParam>,
status: Status,
) -> BetaComputerToolCall {
BetaComputerToolCall {
agent: None,
r#type,
id,
call_id,
action: None,
actions: None,
pending_safety_checks,
status,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "computer_call")]
ComputerCall,
}
impl Default for Type {
fn default() -> Type {
Self::ComputerCall
}
}
#[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 BetaComputerToolCall {
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),
}
}
}