//! ToolSearch tool - discover lazy-loaded tools.
//!
//! Provides tool for discovering available tools.
use crate::types::*;
/// ToolSearch tool - discover lazy-loaded tools
pub struct ToolSearchTool;
impl ToolSearchTool {
pub fn new() -> Self {
Self
}
pub fn input_schema(&self) -> ToolInputSchema {
ToolInputSchema {
schema_type: "object".to_string(),
properties: serde_json::json!({
"query": {
"type": "string",
"description": "Search query to find relevant tools"
}
}),
required: Some(vec!["query".to_string()]),
}
}
pub async fn execute(&self, input: serde_json::Value, _context: &ToolContext) -> Result<ToolResult, crate::error::AgentError> {
let query = input["query"].as_str().unwrap_or("");
let response = format!(
"Searching for tools matching: {}\n\nAvailable tools:\n- Bash: Execute shell commands\n- Read: Read files with line numbers\n- Write: Create / overwrite files\n- Edit: Precise string replacement in files\n- Glob: Find files by pattern\n- Grep: Search file contents with regex\n- WebFetch: Fetch and parse web content\n- WebSearch: Search the web\n- NotebookEdit: Edit Jupyter notebook cells\n- Agent: Spawn subagents for parallel work\n- TaskCreate/List/Update/Get: Task management\n- TeamCreate/Delete: Multi-agent team coordination\n- SendMessage: Inter-agent messaging\n- EnterWorktree/ExitWorktree: Git worktree isolation\n- EnterPlanMode/ExitPlanMode: Structured planning\n- AskUserQuestion: Ask the user for input\n- ToolSearch: Discover lazy-loaded tools\n- CronCreate/Delete/List: Scheduled task management\n- Config: Dynamic configuration\n- TodoWrite: Session todo list\n\nNote: Full implementation would search for tools matching the query and load them dynamically.",
query
);
Ok(ToolResult {
result_type: "text".to_string(),
tool_use_id: "tool_search".to_string(),
content: response,
is_error: Some(false),
})
}
}
impl Default for ToolSearchTool {
fn default() -> Self {
Self::new()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_tool_search_schema() {
let tool = ToolSearchTool::new();
let schema = tool.input_schema();
assert!(schema.properties.get("query").is_some());
}
}