1use serde::{Deserialize, Serialize};
6use std::collections::HashMap;
7
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub enum TodoStatus {
15 Pending,
17 Clarifying,
19 InProgress,
21 WaitingFeedback,
23 Completed,
25 Cancelled,
27 Blocked(String),
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
33pub enum TodoPriority {
34 Low = 0,
35 Medium = 1,
36 High = 2,
37 Urgent = 3,
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct TodoItem {
43 pub id: String,
45 pub raw_idea: String,
47 pub clarified_requirement: Option<ProjectRequirement>,
49 pub status: TodoStatus,
51 pub priority: TodoPriority,
53 pub created_at: u64,
55 pub updated_at: u64,
57 pub assigned_agents: Vec<String>,
59 pub execution_result: Option<ExecutionResult>,
61 pub metadata: HashMap<String, String>,
63}
64
65impl TodoItem {
66 pub fn new(id: &str, raw_idea: &str, priority: TodoPriority) -> Self {
67 let now = std::time::SystemTime::now()
68 .duration_since(std::time::UNIX_EPOCH)
69 .unwrap_or_default()
70 .as_secs();
71
72 Self {
73 id: id.to_string(),
74 raw_idea: raw_idea.to_string(),
75 clarified_requirement: None,
76 status: TodoStatus::Pending,
77 priority,
78 created_at: now,
79 updated_at: now,
80 assigned_agents: Vec::new(),
81 execution_result: None,
82 metadata: HashMap::new(),
83 }
84 }
85
86 pub fn update_status(&mut self, status: TodoStatus) {
88 self.status = status;
89 self.updated_at = std::time::SystemTime::now()
90 .duration_since(std::time::UNIX_EPOCH)
91 .unwrap_or_default()
92 .as_secs();
93 }
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize)]
102pub struct ProjectRequirement {
103 pub title: String,
105 pub description: String,
107 pub acceptance_criteria: Vec<String>,
109 pub subtasks: Vec<Subtask>,
111 pub dependencies: Vec<String>,
113 pub estimated_effort: Option<String>,
115 pub resources: Vec<Resource>,
117}
118
119#[derive(Debug, Clone, Serialize, Deserialize)]
121pub struct Subtask {
122 pub id: String,
124 pub description: String,
126 pub required_capabilities: Vec<String>,
128 pub order: u32,
130 pub depends_on: Vec<String>,
132}
133
134#[derive(Debug, Clone, Serialize, Deserialize)]
136pub struct Resource {
137 pub name: String,
139 pub resource_type: String,
141 pub path: String,
143}
144
145#[derive(Debug, Clone, Serialize, Deserialize)]
151pub struct ExecutionResult {
152 pub success: bool,
154 pub summary: String,
156 pub details: HashMap<String, String>,
158 pub artifacts: Vec<Artifact>,
160 pub execution_time_ms: u64,
162 pub error: Option<String>,
164}
165
166#[derive(Debug, Clone, Serialize, Deserialize)]
168pub struct Artifact {
169 pub name: String,
171 pub artifact_type: String,
173 pub content: String,
175}
176
177#[derive(Debug, Clone, Serialize, Deserialize)]
183pub struct CriticalDecision {
184 pub id: String,
186 pub todo_id: String,
188 pub decision_type: DecisionType,
190 pub description: String,
192 pub options: Vec<DecisionOption>,
194 pub recommended_option: Option<usize>,
196 pub deadline: Option<u64>,
198 pub created_at: u64,
200 pub human_response: Option<HumanResponse>,
202}
203
204#[derive(Debug, Clone, Serialize, Deserialize)]
206pub enum DecisionType {
207 RequirementClarification,
209 TechnicalChoice,
211 PriorityAdjustment,
213 ExceptionHandling,
215 ResourceRequest,
217 Other(String),
219}
220
221#[derive(Debug, Clone, Serialize, Deserialize)]
223pub struct DecisionOption {
224 pub label: String,
226 pub description: String,
228 pub impact: String,
230}
231
232#[derive(Debug, Clone, Serialize, Deserialize)]
234pub struct HumanResponse {
235 pub selected_option: usize,
237 pub comment: Option<String>,
239 pub responded_at: u64,
241}
242
243#[derive(Debug, Clone, Serialize, Deserialize)]
249pub struct Report {
250 pub id: String,
252 pub report_type: ReportType,
254 pub todo_ids: Vec<String>,
256 pub content: String,
258 pub statistics: HashMap<String, serde_json::Value>,
260 pub created_at: u64,
262}
263
264#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
266pub enum ReportType {
267 TaskCompletion,
269 Progress,
271 Exception,
273 DailySummary,
275}
276
277#[derive(Debug, Clone, Serialize, Deserialize)]
283pub enum SecretaryMessage {
284 AssignTask {
286 task_id: String,
287 subtask: Subtask,
288 context: HashMap<String, String>,
289 },
290 QueryTaskStatus { task_id: String },
292 CancelTask { task_id: String, reason: String },
294 TaskStatusReport {
296 task_id: String,
297 status: TaskExecutionStatus,
298 progress: u32,
299 message: Option<String>,
300 },
301 TaskCompleteReport {
303 task_id: String,
304 result: ExecutionResult,
305 },
306 RequestDecision {
308 task_id: String,
309 decision: CriticalDecision,
310 },
311}
312
313#[derive(Debug, Clone, Serialize, Deserialize)]
315pub enum TaskExecutionStatus {
316 Received,
318 Preparing,
320 Executing,
322 WaitingExternal,
324 Completed,
326 Failed(String),
328}
329
330#[derive(Debug, Clone, Serialize, Deserialize)]
336pub enum DefaultInput {
337 Idea {
339 content: String,
340 priority: Option<TodoPriority>,
341 metadata: Option<HashMap<String, String>>,
342 },
343 Decision {
345 decision_id: String,
346 selected_option: usize,
347 comment: Option<String>,
348 },
349 Query(QueryType),
351 Command(SecretaryCommand),
353}
354
355#[derive(Debug, Clone, Serialize, Deserialize)]
357pub enum QueryType {
358 ListTodos { filter: Option<TodoStatus> },
360 GetTodo { todo_id: String },
362 Statistics,
364 PendingDecisions,
366 Reports { report_type: Option<ReportType> },
368}
369
370#[derive(Debug, Clone, Serialize, Deserialize)]
372pub enum SecretaryCommand {
373 Clarify { todo_id: String },
375 Dispatch { todo_id: String },
377 Cancel { todo_id: String, reason: String },
379 GenerateReport { report_type: ReportType },
381 Pause,
383 Resume,
385 Shutdown,
387}
388
389#[derive(Debug, Clone, Serialize, Deserialize)]
391pub enum DefaultOutput {
392 Acknowledgment { message: String },
394 DecisionRequired { decision: CriticalDecision },
396 Report { report: Report },
398 StatusUpdate { todo_id: String, status: TodoStatus },
400 TaskCompleted {
402 todo_id: String,
403 result: ExecutionResult,
404 },
405 Error { message: String },
407 Message { content: String },
409}
410
411#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
413pub enum WorkPhase {
414 ReceivingIdea,
416 ClarifyingRequirement,
418 DispatchingTask,
420 MonitoringExecution,
422 ReportingCompletion,
424}