pub struct ToolContext {
pub dir: PathBuf,
pub interrupt_signal: Arc<AtomicBool>,
/* private fields */
}Expand description
Context passed to tool execution. tool_registry and the ticket-side
fields are ambient internals — only the built-in ToolSearchTool and
the ticket tools (Read/Write/Manage) read them. External tool
authors use dir, interrupt_signal, and
wait_for_cancel.
Fields§
§dir: PathBufDirectory the tool runs in. Tools that touch the filesystem should resolve relative paths against this.
interrupt_signal: Arc<AtomicBool>Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn new(dir: PathBuf) -> Self
pub fn new(dir: PathBuf) -> Self
A fresh context rooted at dir, with no registry handle and
a fresh never-firing cancel signal. Tools that search the registry
need a context installed by the loop; bare contexts are for
standalone use and tests.
Sourcepub fn interrupt_signal(self, signal: Arc<AtomicBool>) -> Self
pub fn interrupt_signal(self, signal: Arc<AtomicBool>) -> Self
Override the cancel signal — typically the one shared by the loop’s
TicketSystem so tools cooperate with run-level cancellation.
Sourcepub async fn wait_for_cancel(&self)
pub async fn wait_for_cancel(&self)
Future that resolves once the current run is cancelled. Pair with
tokio::select! to drop the losing branch on cancel; dropped futures
cascade to reqwest aborts and (with kill_on_drop(true)) subprocess
kills. With a fresh context the future stays pending forever and the
select! degrades to a plain await.
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Source§fn clone(&self) -> ToolContext
fn clone(&self) -> ToolContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more