use serde::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Request {
pub id: String,
pub turn_id: Option<String>,
pub kind: Kind,
pub native: Value,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(
tag = "type",
rename_all = "camelCase",
rename_all_fields = "camelCase"
)]
#[non_exhaustive]
pub enum Kind {
Tool {
name: String,
display_name: Option<String>,
description: Option<String>,
input: Value,
tool_call_id: Option<String>,
can_allow_for_session: bool,
},
#[serde(untagged)]
Unknown(Value),
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(
tag = "type",
rename_all = "camelCase",
rename_all_fields = "camelCase"
)]
#[non_exhaustive]
pub enum Decision {
Allow,
AllowForSession,
Deny { message: Option<String> },
Cancel,
}
impl Decision {
pub fn is_refusal(&self) -> bool {
matches!(self, Self::Deny { .. } | Self::Cancel)
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(
tag = "type",
rename_all = "camelCase",
rename_all_fields = "camelCase"
)]
#[non_exhaustive]
pub enum Outcome {
Answered { decision: Decision },
Withdrawn,
#[serde(untagged)]
Unknown(Value),
}