pub struct GrepTool { /* private fields */ }Expand description
ToolExecutor that searches file contents by regex.
Why: Gives agents a native, sandboxed content-search primitive so they stop
shelling out to grep -r, cutting round-trips.
What: Implements ToolExecutor with name = "grep", scoped to
working_dir; rejects traversal attempts in the optional path argument.
Test: cargo test -p trusty-code -- tools::fs::grep.
Implementations§
Trait Implementations§
Source§impl ToolExecutor for GrepTool
impl ToolExecutor for GrepTool
Source§fn schema(&self) -> Value
fn schema(&self) -> Value
OpenAI function-call schema for grep.
Why: The LLM constructs its call from this schema; parameters mirror the
execute contract exactly.
What: JSON object with pattern (required regex), path (optional
subdirectory), and glob (optional file filter).
Test: schema_has_required_pattern.
Source§fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute a grep tool call.
Why: Searches file contents for pattern within the working directory.
What: Parses {pattern, path?, glob?} from args, calls grep_inner,
converts the result into a ToolResult.
Test: grep_finds_matching_lines, etc.
Source§fn restricted_tiers(&self) -> &[ServiceTier]
fn restricted_tiers(&self) -> &[ServiceTier]
Auto Trait Implementations§
impl Freeze for GrepTool
impl RefUnwindSafe for GrepTool
impl Send for GrepTool
impl Sync for GrepTool
impl Unpin for GrepTool
impl UnsafeUnpin for GrepTool
impl UnwindSafe for GrepTool
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more