use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize)]
pub struct TopicInfo {
pub topic: &'static str,
pub title: &'static str,
pub when_to_use: &'static str,
pub keywords: &'static [&'static str],
pub file: &'static str,
#[serde(skip_serializing)] pub content: &'static str, }
#[derive(Debug, Serialize)]
pub struct TopicSummary {
pub topic: &'static str,
pub title: &'static str,
pub when_to_use: &'static str,
pub keywords: &'static [&'static str],
}
#[derive(Debug, Deserialize)]
pub struct JsonRpcRequest {
#[allow(dead_code)]
pub jsonrpc: String,
pub id: Option<serde_json::Value>,
pub method: String,
#[serde(default)]
pub params: Option<serde_json::Value>,
}
#[derive(Debug, Serialize)]
pub struct JsonRpcResponse {
pub jsonrpc: &'static str,
pub id: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<serde_json::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<JsonRpcError>,
}
#[derive(Debug, Serialize)]
pub struct JsonRpcError {
pub code: i32,
pub message: String,
}
#[derive(Debug, Serialize)]
pub struct InitializeResult {
#[serde(rename = "protocolVersion")]
pub protocol_version: &'static str,
pub capabilities: Capabilities,
#[serde(rename = "serverInfo")]
pub server_info: ServerInfo,
#[serde(skip_serializing_if = "Option::is_none")]
pub _meta: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Serialize)]
pub struct Capabilities {
pub tools: std::collections::HashMap<String, serde_json::Value>,
}
#[derive(Debug, Serialize)]
pub struct ServerInfo {
pub name: &'static str,
pub version: &'static str,
#[serde(skip_serializing_if = "Option::is_none")]
pub _meta: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Serialize)]
pub struct ToolSchema {
pub name: &'static str,
pub description: &'static str,
#[serde(rename = "inputSchema")]
pub input_schema: serde_json::Value,
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<&'static str>,
#[serde(skip_serializing_if = "Option::is_none")]
pub _meta: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Serialize)]
pub struct ToolsListResult {
pub tools: Vec<ToolSchema>,
}
#[derive(Debug, Serialize)]
pub struct ToolResult {
pub content: Vec<ToolContent>,
#[serde(rename = "isError", skip_serializing_if = "Option::is_none")]
pub is_error: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub _meta: Option<HashMap<String, serde_json::Value>>,
}
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
pub enum ToolContent {
#[serde(rename = "text")]
Text {
text: String,
#[serde(rename = "isError", skip_serializing_if = "Option::is_none")]
is_error: Option<bool>,
},
#[serde(rename = "image")]
Image {
data: String,
#[serde(rename = "mimeType")]
mime_type: String,
#[serde(rename = "isError", skip_serializing_if = "Option::is_none")]
is_error: Option<bool>,
},
#[serde(rename = "resource")]
Resource {
uri: String,
#[serde(skip_serializing_if = "Option::is_none")]
text: Option<String>,
#[serde(rename = "mimeType", skip_serializing_if = "Option::is_none")]
mime_type: Option<String>,
#[serde(rename = "isError", skip_serializing_if = "Option::is_none")]
is_error: Option<bool>,
},
}
#[derive(Debug, Serialize, Clone)]
pub struct ResourceLink {
pub uri: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
}
#[derive(Debug, Clone)]
pub(crate) struct DocumentMatch {
pub topic: String,
pub title: String,
pub when_to_use: String,
pub keywords: Vec<String>,
pub file_path: String,
pub matched_keywords: Vec<String>,
pub relevance_score: f32,
}