pub struct WriteFilesTool { /* private fields */ }Expand description
ToolExecutor that creates or overwrites a batch of files in one call.
Why: Structurally decouples turn-count from file-count so an N-file scaffold
is one turn, not N (the dominant bake-off turn sink).
What: Implements ToolExecutor with name = "write_files"; scopes every
write to working_dir; rejects traversal per-file without aborting siblings.
Test: cargo test -p trusty-code -- tools::fs::write_files.
Implementations§
Trait Implementations§
Source§impl ToolExecutor for WriteFilesTool
impl ToolExecutor for WriteFilesTool
Source§fn schema(&self) -> Value
fn schema(&self) -> Value
OpenAI function-call schema for write_files.
Why: The LLM constructs its call from this schema; the files array
mirrors the execute contract exactly.
What: JSON object with a required files array of {path, content}.
Test: schema_requires_files_array.
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 write_files tool call.
Why: Writes every file in the batch, reporting each outcome so a single
bad entry does not lose the successful writes.
What: Parses {files:[{path, content}, …]}, writes each, and returns a
per-file summary. Returns an error only when files is missing/not an
array, or when EVERY write failed. Batches every SUCCESSFULLY written
path into ONE best-effort mid-task incremental trusty-search index
update (issue: mid-task incremental re-indexing) so search_code can
see the whole batch within the same task — this never affects the
returned ToolResult; see
trusty_common::search_index::index_files_best_effort’s fail-open
contract.
Test: write_files_writes_all, write_files_partial_failure.
Source§fn restricted_tiers(&self) -> &[ServiceTier]
fn restricted_tiers(&self) -> &[ServiceTier]
Auto Trait Implementations§
impl Freeze for WriteFilesTool
impl RefUnwindSafe for WriteFilesTool
impl Send for WriteFilesTool
impl Sync for WriteFilesTool
impl Unpin for WriteFilesTool
impl UnsafeUnpin for WriteFilesTool
impl UnwindSafe for WriteFilesTool
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