Skip to main content

wauldo/
types.rs

1//! Type definitions for Wauldo SDK
2
3use serde::{Deserialize, Serialize};
4
5/// Reasoning result from Tree-of-Thought
6#[derive(Debug, Clone, Serialize, Deserialize)]
7pub struct ReasoningResult {
8    /// The original problem
9    pub problem: String,
10    /// The derived solution
11    pub solution: String,
12    /// Full thought tree output
13    pub thought_tree: String,
14    /// Depth of reasoning
15    pub depth: usize,
16    /// Number of branches
17    pub branches: usize,
18    /// Raw content from server
19    pub raw_content: String,
20}
21
22/// Options for reasoning
23#[derive(Debug, Clone, Default)]
24pub struct ReasoningOptions {
25    /// Depth of the thought tree (1-10)
26    pub depth: Option<usize>,
27    /// Number of branches at each level (1-10)
28    pub branches: Option<usize>,
29}
30
31impl ReasoningOptions {
32    /// Create new options with default values
33    pub fn new() -> Self {
34        Self::default()
35    }
36
37    /// Set depth
38    pub fn depth(mut self, depth: usize) -> Self {
39        self.depth = Some(depth);
40        self
41    }
42
43    /// Set branches
44    pub fn branches(mut self, branches: usize) -> Self {
45        self.branches = Some(branches);
46        self
47    }
48}
49
50/// Source type for concept extraction
51#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
52#[serde(rename_all = "lowercase")]
53pub enum SourceType {
54    /// Plain text
55    Text,
56    /// Source code
57    Code,
58}
59
60/// A single extracted concept
61#[derive(Debug, Clone, Serialize, Deserialize)]
62pub struct Concept {
63    /// Concept name
64    pub name: String,
65    /// Type of concept
66    pub concept_type: String,
67    /// Confidence weight (0.0-1.0)
68    pub weight: f64,
69    /// Optional description
70    pub description: Option<String>,
71}
72
73/// Result from concept extraction
74#[derive(Debug, Clone, Serialize, Deserialize)]
75pub struct ConceptResult {
76    /// Extracted concepts
77    pub concepts: Vec<Concept>,
78    /// Source type used
79    pub source_type: SourceType,
80    /// Raw content from server
81    pub raw_content: String,
82}
83
84/// A text chunk from document processing
85#[derive(Debug, Clone, Serialize, Deserialize)]
86pub struct Chunk {
87    /// Chunk identifier
88    pub id: String,
89    /// Chunk content
90    pub content: String,
91    /// Position in original document
92    pub position: usize,
93    /// Priority level
94    pub priority: String,
95}
96
97/// Result from document chunking
98#[derive(Debug, Clone, Serialize, Deserialize)]
99pub struct ChunkResult {
100    /// Generated chunks
101    pub chunks: Vec<Chunk>,
102    /// Total number of chunks
103    pub total_chunks: usize,
104    /// Raw content from server
105    pub raw_content: String,
106}
107
108/// Result from context retrieval
109#[derive(Debug, Clone, Serialize, Deserialize)]
110pub struct RetrievalResult {
111    /// Query used
112    pub query: String,
113    /// Retrieved chunks
114    pub results: Vec<Chunk>,
115    /// Raw content from server
116    pub raw_content: String,
117}
118
119/// A node in the knowledge graph
120#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct GraphNode {
122    /// Node identifier
123    pub id: String,
124    /// Node name
125    pub name: String,
126    /// Node type
127    pub node_type: String,
128    /// Weight/importance
129    pub weight: f64,
130}
131
132/// Result from knowledge graph operations
133#[derive(Debug, Clone, Serialize, Deserialize)]
134pub struct KnowledgeGraphResult {
135    /// Operation performed
136    pub operation: String,
137    /// Result nodes
138    pub nodes: Vec<GraphNode>,
139    /// Graph statistics
140    pub stats: Option<serde_json::Value>,
141    /// Raw content from server
142    pub raw_content: String,
143}
144
145/// Detail level for task planning
146#[derive(Debug, Clone, Copy, Default, Serialize, Deserialize)]
147#[serde(rename_all = "lowercase")]
148pub enum DetailLevel {
149    /// Minimal detail
150    Brief,
151    /// Standard detail
152    #[default]
153    Normal,
154    /// Maximum detail
155    Detailed,
156}
157
158/// A single step in a task plan
159#[derive(Debug, Clone, Serialize, Deserialize)]
160pub struct PlanStep {
161    /// Step number
162    pub number: usize,
163    /// Step title
164    pub title: String,
165    /// Step description
166    pub description: String,
167    /// Priority level
168    pub priority: String,
169    /// Effort estimate
170    pub effort: String,
171    /// Dependencies on other steps
172    pub dependencies: Vec<String>,
173}
174
175/// Result from task planning
176#[derive(Debug, Clone, Serialize, Deserialize)]
177pub struct PlanResult {
178    /// Original task
179    pub task: String,
180    /// Task category
181    pub category: String,
182    /// Plan steps
183    pub steps: Vec<PlanStep>,
184    /// Total effort estimate
185    pub total_effort: String,
186    /// Raw content from server
187    pub raw_content: String,
188}
189
190/// Options for task planning
191#[derive(Debug, Clone, Default)]
192pub struct PlanOptions {
193    /// Additional context
194    pub context: Option<String>,
195    /// Maximum steps (1-20)
196    pub max_steps: Option<usize>,
197    /// Detail level
198    pub detail_level: Option<DetailLevel>,
199}
200
201impl PlanOptions {
202    /// Create new options
203    pub fn new() -> Self {
204        Self::default()
205    }
206
207    /// Set context
208    pub fn context(mut self, context: impl Into<String>) -> Self {
209        self.context = Some(context.into());
210        self
211    }
212
213    /// Set max steps
214    pub fn max_steps(mut self, max_steps: usize) -> Self {
215        self.max_steps = Some(max_steps);
216        self
217    }
218
219    /// Set detail level
220    pub fn detail_level(mut self, level: DetailLevel) -> Self {
221        self.detail_level = Some(level);
222        self
223    }
224}
225
226/// Tool definition from MCP
227#[derive(Debug, Clone, Serialize, Deserialize)]
228pub struct ToolDefinition {
229    /// Tool name
230    pub name: String,
231    /// Tool description
232    pub description: String,
233    /// Input schema
234    pub input_schema: serde_json::Value,
235}
236
237/// Client configuration options
238#[derive(Debug, Clone)]
239pub struct ClientOptions {
240    /// Path to MCP server binary
241    pub server_path: Option<String>,
242    /// Timeout in milliseconds
243    pub timeout_ms: u64,
244    /// Auto-connect on first operation
245    pub auto_connect: bool,
246}
247
248impl Default for ClientOptions {
249    fn default() -> Self {
250        Self {
251            server_path: None,
252            timeout_ms: 30000,
253            auto_connect: true,
254        }
255    }
256}
257
258impl ClientOptions {
259    /// Create new options
260    pub fn new() -> Self {
261        Self::default()
262    }
263
264    /// Set server path
265    pub fn server_path(mut self, path: impl Into<String>) -> Self {
266        self.server_path = Some(path.into());
267        self
268    }
269
270    /// Set timeout
271    pub fn timeout_ms(mut self, timeout: u64) -> Self {
272        self.timeout_ms = timeout;
273        self
274    }
275
276    /// Set auto-connect
277    pub fn auto_connect(mut self, auto: bool) -> Self {
278        self.auto_connect = auto;
279        self
280    }
281}