use crate::core::types::{RouteDecision, SearchResult, TaxonomyEntry};
use rmcp::schemars::{self, JsonSchema};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct SearchRequest {
pub query: String,
pub wing: Option<String>,
pub room: Option<String>,
pub top_k: Option<usize>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct SearchResponse {
pub results: Vec<SearchResultDto>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct SearchResultDto {
pub drawer_id: String,
pub content: String,
pub wing: String,
pub room: Option<String>,
pub source_file: String,
pub similarity: f32,
pub route: RouteDecisionDto,
#[serde(skip_serializing_if = "Vec::is_empty")]
pub tunnel_hints: Vec<String>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct RouteDecisionDto {
pub wing: Option<String>,
pub room: Option<String>,
pub confidence: f32,
pub reason: String,
}
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct IngestRequest {
pub content: String,
pub wing: String,
pub room: Option<String>,
pub source: Option<String>,
pub dry_run: Option<bool>,
pub importance: Option<i32>,
}
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct DeleteRequest {
pub drawer_id: String,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct DeleteResponse {
pub drawer_id: String,
pub deleted: bool,
pub message: String,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct IngestResponse {
pub drawer_id: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub duplicate_warning: Option<DuplicateWarning>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct DuplicateWarning {
pub similar_drawer_id: String,
pub similarity: f32,
pub preview: String,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct StatusResponse {
pub schema_version: u32,
pub drawer_count: i64,
pub taxonomy_count: i64,
pub db_size_bytes: u64,
pub scopes: Vec<ScopeCount>,
pub aaak_spec: String,
pub memory_protocol: String,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct ScopeCount {
pub wing: String,
pub room: Option<String>,
pub drawer_count: i64,
}
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct TaxonomyRequest {
pub action: String,
pub wing: Option<String>,
pub room: Option<String>,
pub keywords: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct TaxonomyResponse {
pub action: String,
pub entries: Vec<TaxonomyEntryDto>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct TaxonomyEntryDto {
pub wing: String,
pub room: String,
pub display_name: Option<String>,
pub keywords: Vec<String>,
}
#[derive(Debug, Clone, Deserialize, JsonSchema)]
pub struct KgRequest {
pub action: String,
pub subject: Option<String>,
pub predicate: Option<String>,
pub object: Option<String>,
pub triple_id: Option<String>,
pub active_only: Option<bool>,
pub source_drawer: Option<String>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct KgResponse {
pub action: String,
pub triples: Vec<TripleDto>,
#[serde(skip_serializing_if = "Option::is_none")]
pub stats: Option<KgStatsDto>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct KgStatsDto {
pub total: i64,
pub active: i64,
pub expired: i64,
pub entities: i64,
pub top_predicates: Vec<(String, i64)>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct TripleDto {
pub id: String,
pub subject: String,
pub predicate: String,
pub object: String,
pub valid_from: Option<String>,
pub valid_to: Option<String>,
pub confidence: f64,
pub source_drawer: Option<String>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct TunnelsResponse {
pub tunnels: Vec<TunnelDto>,
}
#[derive(Debug, Clone, Serialize, JsonSchema)]
pub struct TunnelDto {
pub room: String,
pub wings: Vec<String>,
}
impl From<SearchResult> for SearchResultDto {
fn from(value: SearchResult) -> Self {
Self {
drawer_id: value.drawer_id,
content: value.content,
wing: value.wing,
room: value.room,
source_file: value.source_file,
similarity: value.similarity,
route: value.route.into(),
tunnel_hints: value.tunnel_hints,
}
}
}
impl From<RouteDecision> for RouteDecisionDto {
fn from(value: RouteDecision) -> Self {
Self {
wing: value.wing,
room: value.room,
confidence: value.confidence,
reason: value.reason,
}
}
}
impl From<TaxonomyEntry> for TaxonomyEntryDto {
fn from(value: TaxonomyEntry) -> Self {
Self {
wing: value.wing,
room: value.room,
display_name: value.display_name,
keywords: value.keywords,
}
}
}