use chrono::{DateTime, Utc};
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct RpcCall {
pub session_id: String,
pub server_name: String,
pub rpc_id: Option<String>,
pub method: String,
pub tool_name: Option<String>,
pub started_at_ms: i64,
pub duration_ms: f64,
pub req_bytes: i64,
pub resp_bytes: i64,
pub req_tokens: i64,
pub resp_tokens: i64,
pub is_error: bool,
pub error_message: Option<String>,
pub req_preview: Option<String>,
pub resp_preview: Option<String>,
}
#[derive(Debug, Clone)]
pub struct RpcRecord {
pub session_id: String,
pub server_name: String,
pub rpc_id: Option<String>,
pub method: String,
pub tool_name: Option<String>,
pub started_at_ms: i64,
pub duration_ms: f64,
pub req_bytes: i64,
pub resp_bytes: i64,
pub req_tokens: i64,
pub resp_tokens: i64,
pub is_error: bool,
pub error_message: Option<String>,
pub req_preview: Option<String>,
pub resp_preview: Option<String>,
}
#[derive(Debug, Clone, Serialize)]
pub struct ServerSummary {
pub server_name: String,
pub total_calls: i64,
pub total_req_tokens: i64,
pub total_resp_tokens: i64,
pub avg_duration_ms: f64,
pub p50_duration_ms: f64,
pub p95_duration_ms: f64,
pub error_count: i64,
}
#[derive(Debug, Clone, Serialize)]
pub struct ToolSummary {
pub server_name: String,
pub tool_name: String,
pub total_calls: i64,
pub total_req_tokens: i64,
pub total_resp_tokens: i64,
pub avg_duration_ms: f64,
pub p50_duration_ms: f64,
pub p95_duration_ms: f64,
pub error_count: i64,
}
#[derive(Debug, Clone, Serialize)]
pub struct RecentCall {
pub started_at: DateTime<Utc>,
pub server_name: String,
pub method: String,
pub tool_name: Option<String>,
pub duration_ms: f64,
pub req_tokens: i64,
pub resp_tokens: i64,
pub is_error: bool,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SchemaViolation {
pub session_id: String,
pub server_name: String,
pub rpc_id: Option<String>,
pub direction: String,
pub code: String,
pub detail: String,
pub raw_preview: Option<String>,
pub started_at_ms: i64,
}
#[derive(Debug, Clone)]
pub struct PendingCall {
pub started_at: std::time::Instant,
pub method: String,
pub tool_name: Option<String>,
pub req_bytes: i64,
pub req_tokens: i64,
pub req_preview: Option<String>,
}
impl Default for PendingCall {
fn default() -> Self {
Self {
started_at: std::time::Instant::now(),
method: String::new(),
tool_name: None,
req_bytes: 0,
req_tokens: 0,
req_preview: None,
}
}
}