ai-agent-sdk 0.5.0

Idiomatic agent sdk inspired by the claude code source leak
Documentation
//! TodoWrite tool - session todo list.
//!
//! Provides tool for managing session todo items.

use crate::types::*;

/// TodoWrite tool - manage session todo list
pub struct TodoWriteTool;

impl TodoWriteTool {
    pub fn new() -> Self {
        Self
    }

    pub fn input_schema(&self) -> ToolInputSchema {
        ToolInputSchema {
            schema_type: "object".to_string(),
            properties: serde_json::json!({
                "todos": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "content": { "type": "string" },
                            "status": {
                                "type": "string",
                                "enum": ["in_progress", "pending", "completed"]
                            },
                            "ACTIVE_FORM": { "type": "string" }
                        }
                    },
                    "description": "List of todo items"
                }
            }),
            required: Some(vec!["todos".to_string()]),
        }
    }

    pub async fn execute(&self, input: serde_json::Value, _context: &ToolContext) -> Result<ToolResult, crate::error::AgentError> {
        let todos = input["todos"].as_array()
            .map(|arr| arr.len())
            .unwrap_or(0);

        let response = format!(
            "Todo list updated with {} items.\nNote: Full implementation would persist the todo list in .ai/todos.json.",
            todos
        );

        Ok(ToolResult {
            result_type: "text".to_string(),
            tool_use_id: "todo_write".to_string(),
            content: response,
            is_error: Some(false),
        })
    }
}

impl Default for TodoWriteTool {
    fn default() -> Self {
        Self::new()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_todo_write_schema() {
        let tool = TodoWriteTool::new();
        let schema = tool.input_schema();
        assert!(schema.properties.get("todos").is_some());
    }
}