use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpCallItemResource {
#[serde(rename = "type")]
pub r#type: Type,
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "turn_id")]
pub turn_id: String,
#[serde(rename = "server_label")]
pub server_label: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "arguments", deserialize_with = "Option::deserialize")]
pub arguments: Option<serde_json::Value>,
#[serde(rename = "status")]
pub status: models::FunctionCallStatusResource,
#[serde(rename = "output", deserialize_with = "Option::deserialize")]
pub output: Option<Box<serde_json::Value>>,
#[serde(rename = "error", deserialize_with = "Option::deserialize")]
pub error: Option<Box<serde_json::Value>>,
}
impl McpCallItemResource {
pub fn new(
r#type: Type,
id: String,
turn_id: String,
server_label: String,
name: String,
arguments: Option<serde_json::Value>,
status: models::FunctionCallStatusResource,
output: Option<serde_json::Value>,
error: Option<serde_json::Value>,
) -> McpCallItemResource {
McpCallItemResource {
r#type,
id,
turn_id,
server_label,
name,
arguments,
status,
output: output.map(Box::new),
error: error.map(Box::new),
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "mcp_call")]
McpCall,
}
impl Default for Type {
fn default() -> Type {
Self::McpCall
}
}
impl std::fmt::Display for McpCallItemResource {
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),
}
}
}