pub mod agent;
pub mod claude;
pub mod codex;
pub mod gemini;
pub mod launch_options;
pub mod opencode;
pub mod qwen;
pub(crate) mod shell;
pub(crate) mod usage;
use std::collections::HashMap;
pub use agent::{AgentBuildOptions, AgentTool, AgentUsage, ErrorResult};
pub use claude::{ClaudeBuildOptions, ClaudeTool, ClaudeUsage};
pub use codex::{CodexBuildOptions, CodexTool, CodexUsage};
pub use gemini::{GeminiBuildOptions, GeminiErrorResult, GeminiTool, GeminiUsage};
pub use opencode::{OpencodeBuildOptions, OpencodeTool, OpencodeUsage};
pub use qwen::{QwenBuildOptions, QwenErrorResult, QwenTool, QwenUsage};
pub trait Tool {
fn name(&self) -> &'static str;
fn display_name(&self) -> &'static str;
fn executable(&self) -> &'static str;
fn supports_json_output(&self) -> bool;
fn supports_json_input(&self) -> bool;
fn supports_system_prompt(&self) -> bool;
fn supports_resume(&self) -> bool;
fn default_model(&self) -> &'static str;
}
impl Tool for ClaudeTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
impl Tool for CodexTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
impl Tool for OpencodeTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
impl Tool for AgentTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
impl Tool for GeminiTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
impl Tool for QwenTool {
fn name(&self) -> &'static str {
self.name
}
fn display_name(&self) -> &'static str {
self.display_name
}
fn executable(&self) -> &'static str {
self.executable
}
fn supports_json_output(&self) -> bool {
self.supports_json_output
}
fn supports_json_input(&self) -> bool {
self.supports_json_input
}
fn supports_system_prompt(&self) -> bool {
self.supports_system_prompt
}
fn supports_resume(&self) -> bool {
self.supports_resume
}
fn default_model(&self) -> &'static str {
self.default_model
}
}
pub struct ToolRegistry {
tools: HashMap<&'static str, Box<dyn Tool + Send + Sync>>,
}
impl Default for ToolRegistry {
fn default() -> Self {
Self::new()
}
}
impl ToolRegistry {
pub fn new() -> Self {
let mut tools: HashMap<&'static str, Box<dyn Tool + Send + Sync>> = HashMap::new();
tools.insert("claude", Box::new(ClaudeTool::default()));
tools.insert("codex", Box::new(CodexTool::default()));
tools.insert("opencode", Box::new(OpencodeTool::default()));
tools.insert("agent", Box::new(AgentTool::default()));
tools.insert("gemini", Box::new(GeminiTool::default()));
tools.insert("qwen", Box::new(QwenTool::default()));
Self { tools }
}
pub fn get(&self, name: &str) -> Option<&(dyn Tool + Send + Sync)> {
self.tools.get(name).map(|t| t.as_ref())
}
pub fn is_supported(&self, name: &str) -> bool {
self.tools.contains_key(name)
}
pub fn list(&self) -> Vec<&'static str> {
self.tools.keys().copied().collect()
}
}
pub fn get_tool(tool_name: &str) -> Result<Box<dyn Tool + Send + Sync>, String> {
match tool_name {
"claude" => Ok(Box::new(ClaudeTool::default())),
"codex" => Ok(Box::new(CodexTool::default())),
"opencode" => Ok(Box::new(OpencodeTool::default())),
"agent" => Ok(Box::new(AgentTool::default())),
"gemini" => Ok(Box::new(GeminiTool::default())),
"qwen" => Ok(Box::new(QwenTool::default())),
_ => Err(format!(
"Unknown tool: {}. Available tools: claude, codex, opencode, agent, gemini, qwen",
tool_name
)),
}
}
pub fn list_tools() -> Vec<&'static str> {
vec!["claude", "codex", "opencode", "agent", "gemini", "qwen"]
}
pub fn is_tool_supported(tool_name: &str) -> bool {
["claude", "codex", "opencode", "agent", "gemini", "qwen"].contains(&tool_name)
}