Skip to main content

BashTool

Struct BashTool 

Source
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

Source

pub const DEFAULT_TIMEOUT: Duration

Default per-command timeout when the model omits timeout_ms.

Source

pub const MAX_TIMEOUT: Duration

Maximum per-command timeout the model is allowed to request.

Source

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.

Source

pub fn with_description(self, description: &str) -> Self

Override the auto-generated description.

Source

pub fn read_only(self, read_only: bool) -> Self

Set whether this tool is considered read-only.

Source§

impl BashTool

Source

pub fn unrestricted() -> Self

Create an unrestricted bash tool with the standard description.

Trait Implementations§

Source§

impl ToolLike for BashTool

Source§

fn name(&self) -> &str

Unique name the model uses to call the tool.
Source§

fn description(&self) -> &str

Human-readable description shown to the model.
Source§

fn input_schema(&self) -> Value

JSON Schema describing the tool’s arguments.
Source§

fn is_read_only(&self) -> bool

Whether this tool has no side effects. Read-only tools in the same step run concurrently; non-read-only tools run serially. Default: false.
Source§

fn call<'a>( &'a self, input: Value, ctx: &'a ToolContext, ) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'a>>

Run the tool. The future is held by the agent loop and dropped on cancellation; pair long-running work with ToolContext::wait_for_cancel in a tokio::select! to drop the losing branch promptly.
Source§

fn should_defer(&self) -> bool

Whether the tool’s full definition is hidden until it is discovered via ToolSearchTool. Deferred tools appear to the model as name-only stubs. Default: false.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more