use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct CaptureThoughtRequest {
pub content: String,
#[serde(default)]
pub category: Option<String>,
#[serde(default)]
pub tags: Option<Vec<String>>,
#[serde(default)]
pub importance: Option<f32>,
#[serde(default)]
pub source: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct CaptureThoughtResponse {
pub id: String,
pub category: String,
pub tags: Vec<String>,
pub importance: f32,
pub facts_extracted: usize,
pub corroborations: Vec<String>,
pub contradictions: Vec<String>,
pub confidence: f32,
}
#[derive(Debug, Clone, Default)]
pub struct EvidenceCheckResult {
pub corroborations: Vec<String>,
pub contradictions: Vec<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct SearchMemoryRequest {
pub query: String,
#[serde(default = "default_limit")]
pub limit: usize,
#[serde(default = "default_min_score")]
pub min_score: f32,
#[serde(default)]
pub category: Option<String>,
#[serde(default)]
pub sources: Option<Vec<String>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchMemoryResponse {
pub results: Vec<MemorySearchResult>,
pub total: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemorySearchResult {
pub content: String,
pub score: f32,
pub source: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub thought_id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub created_at: Option<i64>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct ListRecentRequest {
#[serde(default = "default_list_limit")]
pub limit: usize,
#[serde(default)]
pub category: Option<String>,
#[serde(default)]
pub since: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ListRecentResponse {
pub thoughts: Vec<ThoughtSummary>,
pub total: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThoughtSummary {
pub id: String,
pub content: String,
pub category: String,
pub tags: Vec<String>,
pub importance: f32,
pub created_at: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct GetThoughtRequest {
pub id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GetThoughtResponse {
pub id: String,
pub content: String,
pub category: String,
pub tags: Vec<String>,
pub source: String,
pub importance: f32,
pub created_at: i64,
pub updated_at: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct SearchKnowledgeRequest {
pub query: String,
#[serde(default)]
pub source: Option<String>,
#[serde(default)]
pub category: Option<String>,
#[serde(default = "default_min_confidence")]
pub min_confidence: f32,
#[serde(default = "default_limit")]
pub limit: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchKnowledgeResponse {
pub results: Vec<KnowledgeResult>,
pub total: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KnowledgeResult {
pub source: String,
pub category: String,
pub key: String,
pub value: String,
pub confidence: f32,
#[serde(skip_serializing_if = "Option::is_none")]
pub context: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct MemoryStatsRequest {}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryStatsResponse {
pub thoughts: ThoughtStats,
pub pks: PksStats,
pub bks: BksStats,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ThoughtStats {
pub total: usize,
pub by_category: std::collections::HashMap<String, usize>,
pub recent_24h: usize,
pub recent_7d: usize,
pub recent_30d: usize,
pub top_tags: Vec<(String, usize)>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PksStats {
pub total_facts: u32,
pub by_category: std::collections::HashMap<String, u32>,
pub avg_confidence: f32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct BksStats {
pub total_truths: u32,
pub by_category: std::collections::HashMap<String, u32>,
}
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
pub struct DeleteThoughtRequest {
pub id: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct DeleteThoughtResponse {
pub deleted: bool,
pub id: String,
}
fn default_limit() -> usize {
10
}
fn default_list_limit() -> usize {
20
}
fn default_min_score() -> f32 {
0.6
}
fn default_min_confidence() -> f32 {
0.5
}