use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::collections::HashMap;
use uuid::Uuid;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Armament {
pub name: String,
pub description: String,
pub parameters: Value,
pub required_params: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct ArmamentCall {
pub tool_name: String,
pub arguments: HashMap<String, Value>,
pub call_id: Uuid,
}
impl ArmamentCall {
pub fn new(tool_name: impl Into<String>, arguments: HashMap<String, Value>) -> Self {
Self {
tool_name: tool_name.into(),
arguments,
call_id: Uuid::new_v4(),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct ArmamentResult {
pub call_id: Uuid,
pub success: bool,
pub output: Option<Value>,
pub error: Option<String>,
pub execution_time_ms: u64,
}
impl ArmamentResult {
pub fn success(call_id: Uuid, output: Value, execution_time_ms: u64) -> Self {
Self {
call_id,
success: true,
output: Some(output),
error: None,
execution_time_ms,
}
}
pub fn failure(call_id: Uuid, error: impl Into<String>, execution_time_ms: u64) -> Self {
Self {
call_id,
success: false,
output: None,
error: Some(error.into()),
execution_time_ms,
}
}
}
#[derive(Debug, thiserror::Error)]
pub enum ArsenalError {
#[error("Tool not found: {0}")]
ToolNotFound(String),
#[error("Invalid tool arguments: {0}")]
InvalidArguments(String),
#[error("Tool execution timeout after {0} seconds")]
Timeout(u64),
#[error("MCP protocol error: {0}")]
ProtocolError(String),
#[error("Transport error: {0}")]
TransportError(String),
}