use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use ts_rs::TS;
use crate::types::Metadata;
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
pub struct ApprovalRequestParams {
pub request_id: String,
pub thread_id: String,
pub turn_id: String,
pub tool_call_id: String,
pub tool_name: String,
pub preview: String,
#[serde(default)]
pub arguments: Value,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
pub struct ApprovalResolveParams {
pub thread_id: String,
pub turn_id: String,
pub request_id: String,
pub decision: ApprovalDecision,
#[serde(default, skip_serializing_if = "String::is_empty")]
pub reason: String,
#[serde(default, skip_serializing_if = "Metadata::is_empty")]
pub metadata: Metadata,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, JsonSchema, TS)]
#[serde(rename_all = "snake_case")]
pub enum ApprovalDecision {
Allow,
AllowSession,
Deny,
Timeout,
}
impl ApprovalDecision {
pub const fn as_wire(self) -> &'static str {
match self {
Self::Allow => "allow",
Self::AllowSession => "allow_session",
Self::Deny => "deny",
Self::Timeout => "timeout",
}
}
}