pub struct BashTool { /* private fields */ }Expand description
Execute shell commands. Two constructors:
BashTool::new restricts execution to commands matching a glob pattern;
BashTool::unrestricted allows any command. Not read-only.
§Examples
Pattern-restricted (only git ... commands):
use agentwerk::tools::BashTool;
use agentwerk::agents::agent::Agent;
Agent::new().tool(BashTool::new("git", "git *"));Unrestricted:
use agentwerk::tools::BashTool;
use agentwerk::agents::agent::Agent;
Agent::new().tool(BashTool::unrestricted());Implementations§
Source§impl BashTool
impl BashTool
Sourcepub const DEFAULT_TIMEOUT: Duration
pub const DEFAULT_TIMEOUT: Duration
Default per-command timeout when the model omits timeout_ms.
Sourcepub const MAX_TIMEOUT: Duration
pub const MAX_TIMEOUT: Duration
Maximum per-command timeout the model is allowed to request.
Sourcepub fn new(name: &str, pattern: &str) -> Self
pub fn new(name: &str, pattern: &str) -> Self
Create a new BashTool with the given name that only permits
commands matching pattern. The static description rendered from
bash.tool.json is loaded once and a one-line pattern suffix is
appended per instance. read_only defaults to the value declared in
bash.tool.json and may be overridden via BashTool::read_only.
Sourcepub fn with_description(self, description: &str) -> Self
pub fn with_description(self, description: &str) -> Self
Override the auto-generated description.
Source§impl BashTool
impl BashTool
Sourcepub fn unrestricted() -> Self
pub fn unrestricted() -> Self
Create an unrestricted bash tool with the standard description.
Trait Implementations§
Source§impl ToolLike for BashTool
impl ToolLike for BashTool
Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§fn input_schema(&self) -> Value
fn input_schema(&self) -> Value
Source§fn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
false.Source§fn call<'a>(
&'a self,
input: Value,
ctx: &'a ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'a>>
fn call<'a>( &'a self, input: Value, ctx: &'a ToolContext, ) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'a>>
ToolContext::wait_for_cancel
in a tokio::select! to drop the losing branch promptly.Source§fn should_defer(&self) -> bool
fn should_defer(&self) -> bool
ToolSearchTool. Deferred tools appear to the model as
name-only stubs. Default: false.