steer_tools/tools/
todo.rs1use schemars::JsonSchema;
2use serde::{Deserialize, Serialize};
3use strum::Display;
4
5use crate::ToolSpec;
6use crate::error::ToolExecutionError;
7use crate::result::{TodoListResult, TodoWriteResult};
8
9#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, JsonSchema, Hash, Display)]
10#[serde(rename_all = "snake_case")]
11pub enum TodoStatus {
12 Pending,
13 #[strum(serialize = "In Progress")]
14 InProgress,
15 Completed,
16}
17
18#[derive(
19 Deserialize, Serialize, Debug, Clone, Eq, PartialEq, Ord, PartialOrd, JsonSchema, Hash, Display,
20)]
21#[serde(rename_all = "snake_case")]
22pub enum TodoPriority {
23 High = 0,
24 Medium = 1,
25 Low = 2,
26}
27
28#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, JsonSchema, Hash)]
29pub struct TodoItem {
30 pub content: String,
31 pub status: TodoStatus,
32 pub priority: TodoPriority,
33 pub id: String,
34}
35
36#[derive(Deserialize, Serialize, Debug, Clone, Eq, PartialEq, JsonSchema, Hash)]
37#[serde(rename_all = "snake_case")]
38pub enum TodoWriteFileOperation {
39 Created,
40 Modified,
41}
42
43pub type TodoList = Vec<TodoItem>;
44
45pub mod read {
46 use super::{Deserialize, JsonSchema, Serialize, TodoListResult, ToolExecutionError, ToolSpec};
47 use thiserror::Error;
48
49 pub const TODO_READ_TOOL_NAME: &str = "read_todos";
50
51 pub struct TodoReadToolSpec;
52
53 impl ToolSpec for TodoReadToolSpec {
54 type Params = TodoReadParams;
55 type Result = TodoListResult;
56 type Error = TodoReadError;
57
58 const NAME: &'static str = TODO_READ_TOOL_NAME;
59 const DISPLAY_NAME: &'static str = "Read Todos";
60
61 fn execution_error(error: Self::Error) -> ToolExecutionError {
62 ToolExecutionError::TodoRead(error)
63 }
64 }
65
66 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Error)]
67 #[serde(tag = "code", rename_all = "snake_case")]
68 pub enum TodoReadError {
69 #[error("io error: {message}")]
70 Io { message: String },
71 }
72
73 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
74 pub struct TodoReadParams {}
76}
77
78pub mod write {
79 use super::{
80 Deserialize, JsonSchema, Serialize, TodoList, TodoWriteResult, ToolExecutionError, ToolSpec,
81 };
82 use thiserror::Error;
83
84 pub const TODO_WRITE_TOOL_NAME: &str = "write_todos";
85
86 pub struct TodoWriteToolSpec;
87
88 impl ToolSpec for TodoWriteToolSpec {
89 type Params = TodoWriteParams;
90 type Result = TodoWriteResult;
91 type Error = TodoWriteError;
92
93 const NAME: &'static str = TODO_WRITE_TOOL_NAME;
94 const DISPLAY_NAME: &'static str = "Write Todos";
95
96 fn execution_error(error: Self::Error) -> ToolExecutionError {
97 ToolExecutionError::TodoWrite(error)
98 }
99 }
100
101 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema, Error)]
102 #[serde(tag = "code", rename_all = "snake_case")]
103 pub enum TodoWriteError {
104 #[error("io error: {message}")]
105 Io { message: String },
106 }
107
108 #[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
109 pub struct TodoWriteParams {
110 pub todos: TodoList,
112 }
113}