use super::{
fs::{ApplyPatchTool, EditFileTool, ReadFileTool, SearchFileTool, WriteFileTool},
shell::{CustomEnv, Executor, NativeRuntime, ShellCommandTool, ShellSessionTool},
};
use crate::context::BaseCtx;
use anda_core::{BoxError, ToolSet};
use std::{path::PathBuf, sync::Arc};
pub fn coding_tools(
runtime: Arc<NativeRuntime>,
envs: Vec<CustomEnv>,
) -> Result<ToolSet<BaseCtx>, BoxError> {
let mut tools = ToolSet::new();
tools.add(Arc::new(ApplyPatchTool::new(runtime.workspace().clone())))?;
tools.add(Arc::new(ShellCommandTool::new(runtime.clone(), envs)))?;
tools.add(Arc::new(ShellSessionTool::new(runtime)))?;
Ok(tools)
}
pub fn readonly_file_tools(workspace: PathBuf) -> Result<ToolSet<BaseCtx>, BoxError> {
let mut tools = ToolSet::new();
tools.add(Arc::new(ReadFileTool::new(workspace.clone())))?;
tools.add(Arc::new(SearchFileTool::new(workspace)))?;
Ok(tools)
}
pub fn file_tools(workspace: PathBuf) -> Result<ToolSet<BaseCtx>, BoxError> {
let mut tools = readonly_file_tools(workspace.clone())?;
tools.add(Arc::new(EditFileTool::new(workspace.clone())))?;
tools.add(Arc::new(WriteFileTool::new(workspace)))?;
Ok(tools)
}