ai-agent-sdk 0.5.0

Idiomatic agent sdk inspired by the claude code source leak
Documentation
pub mod types;
pub mod agent;
pub mod bash;
pub mod read;
pub mod write;
pub mod glob;
pub mod grep;
pub mod edit;
pub mod notebook_edit;
pub mod web_fetch;
pub mod web_search;
pub mod tasks;
pub mod team;
pub mod worktree;
pub mod plan;
pub mod ask;
pub mod cron;
pub mod config;
pub mod todo;
pub mod search;
pub mod skill;

pub use types::{filter_tools, get_all_base_tools, Tool, ToolDefinition, ToolInputSchema};

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

    #[test]
    fn test_get_all_base_tools_returns_all_tools() {
        let tools = get_all_base_tools();
        // Should have 28 tools: Bash, FileRead, FileWrite, Glob, Grep, FileEdit, NotebookEdit, WebFetch, WebSearch, Agent, TaskCreate, TaskList, TaskUpdate, TaskGet, TeamCreate, TeamDelete, SendMessage, EnterWorktree, ExitWorktree, EnterPlanMode, ExitPlanMode, AskUserQuestion, ToolSearch, CronCreate, CronDelete, CronList, Config, TodoWrite
        assert_eq!(tools.len(), 29);
    }

    #[test]
    fn test_get_all_base_tools_contains_bash_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"Bash"));
    }

    #[test]
    fn test_get_all_base_tools_contains_file_read_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"FileRead"));
    }

    #[test]
    fn test_get_all_base_tools_contains_file_write_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"FileWrite"));
    }

    #[test]
    fn test_get_all_base_tools_contains_glob_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"Glob"));
    }

    #[test]
    fn test_get_all_base_tools_contains_grep_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"Grep"));
    }

    #[test]
    fn test_get_all_base_tools_contains_file_edit_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"FileEdit"));
    }

    #[test]
    fn test_get_all_base_tools_contains_notebook_edit_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"NotebookEdit"));
    }

    #[test]
    fn test_get_all_base_tools_contains_web_fetch_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"WebFetch"));
    }

    #[test]
    fn test_get_all_base_tools_contains_web_search_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"WebSearch"));
    }

    #[test]
    fn test_get_all_base_tools_contains_agent_tool() {
        let tools = get_all_base_tools();
        let tool_names: Vec<&str> = tools.iter().map(|t| t.name.as_str()).collect();
        assert!(tool_names.contains(&"Agent"));
    }

    #[test]
    fn test_filter_tools_by_allowed() {
        let tools = vec![
            ToolDefinition {
                name: "Bash".to_string(),
                description: "Execute shell commands".to_string(),
                input_schema: ToolInputSchema {
                    schema_type: "object".to_string(),
                    properties: serde_json::json!({}),
                    required: None,
                },
            },
            ToolDefinition {
                name: "FileRead".to_string(),
                description: "Read files".to_string(),
                input_schema: ToolInputSchema {
                    schema_type: "object".to_string(),
                    properties: serde_json::json!({}),
                    required: None,
                },
            },
        ];
        let filtered = filter_tools(tools, Some(vec!["Bash".to_string()]), None);
        assert_eq!(filtered.len(), 1);
        assert_eq!(filtered[0].name, "Bash");
    }

    #[test]
    fn test_filter_tools_by_disallowed() {
        let tools = vec![
            ToolDefinition {
                name: "Bash".to_string(),
                description: "Execute shell commands".to_string(),
                input_schema: ToolInputSchema {
                    schema_type: "object".to_string(),
                    properties: serde_json::json!({}),
                    required: None,
                },
            },
            ToolDefinition {
                name: "FileRead".to_string(),
                description: "Read files".to_string(),
                input_schema: ToolInputSchema {
                    schema_type: "object".to_string(),
                    properties: serde_json::json!({}),
                    required: None,
                },
            },
        ];
        let filtered = filter_tools(tools, None, Some(vec!["Bash".to_string()]));
        assert_eq!(filtered.len(), 1);
        assert_eq!(filtered[0].name, "FileRead");
    }
}