agent_sdk/
primitive_tools.rs

1//! Primitive tools that work with the Environment abstraction.
2//!
3//! These tools provide basic file and command operations:
4//! - `ReadTool` - Read file contents
5//! - `WriteTool` - Write/create files
6//! - `EditTool` - Edit existing files with string replacement
7//! - `GlobTool` - Find files by pattern
8//! - `GrepTool` - Search file contents
9//! - `BashTool` - Execute shell commands
10//!
11//! All tools respect `AgentCapabilities` for security.
12
13mod bash;
14mod edit;
15mod glob;
16mod grep;
17mod read;
18mod write;
19
20pub use bash::BashTool;
21pub use edit::EditTool;
22pub use glob::GlobTool;
23pub use grep::GrepTool;
24pub use read::ReadTool;
25pub use write::WriteTool;
26
27use crate::{AgentCapabilities, Environment};
28use std::sync::Arc;
29
30/// Context for primitive tools that need environment access
31pub struct PrimitiveToolContext<E: Environment> {
32    pub environment: Arc<E>,
33    pub capabilities: AgentCapabilities,
34}
35
36impl<E: Environment> PrimitiveToolContext<E> {
37    #[must_use]
38    pub const fn new(environment: Arc<E>, capabilities: AgentCapabilities) -> Self {
39        Self {
40            environment,
41            capabilities,
42        }
43    }
44}
45
46impl<E: Environment> Clone for PrimitiveToolContext<E> {
47    fn clone(&self) -> Self {
48        Self {
49            environment: Arc::clone(&self.environment),
50            capabilities: self.capabilities.clone(),
51        }
52    }
53}