pub struct ToolContext {
pub working_dir: String,
pub session_id: Option<String>,
pub sandbox: SandboxSettings,
pub network: NetworkPolicy,
pub file_claims: Option<FileClaimRegistry>,
pub agent_id: Option<String>,
pub agent_label: Option<String>,
pub file_index: Option<Arc<WorkspaceIndex>>,
pub panel: Option<PanelSink>,
pub todo_sink: Option<TodoSink>,
pub swarm_hub: Option<SwarmHub>,
}Expand description
Context passed to tool execution
Fields§
§working_dir: String§session_id: Option<String>§sandbox: SandboxSettingsOS sandbox policy for shell tools (ignored by pure file tools).
network: NetworkPolicyDomain allow/deny for HTTP tools (webfetch, websearch, GitHub API).
file_claims: Option<FileClaimRegistry>When set (swarm workers), file mutators claim paths before writing.
agent_id: Option<String>Stable agent id for file claims (e.g. worker-0). Required with file_claims.
agent_label: Option<String>Display label for conflict messages (defaults to agent_id).
file_index: Option<Arc<WorkspaceIndex>>Resident workspace file index (when the host started one). File tools use it as a warm fast path for enumeration and fall back to walking.
panel: Option<PanelSink>Optional sink so the panel tool can pin a file / diff / mermaid.
todo_sink: Option<TodoSink>Optional sink so todowrite can update the host todo panel live.
swarm_hub: Option<SwarmHub>Swarm mailbox (DM / broadcast).
Implementations§
Source§impl ToolContext
impl ToolContext
pub fn new(working_dir: impl Into<String>) -> Self
pub fn unsandboxed(working_dir: impl Into<String>) -> Self
Sourcepub fn check_file_write(&self, path: &Path) -> Result<(), String>
pub fn check_file_write(&self, path: &Path) -> Result<(), String>
Gate a file write/edit against the shared claim registry.
No-op when claims are not active (normal single-agent turns).
On conflict returns an error string suitable for ToolResult.content.
Sourcepub fn check_file_read(&self, path: &Path) -> Option<FileStaleEvent>
pub fn check_file_read(&self, path: &Path) -> Option<FileStaleEvent>
After a successful read, note the path. Returns a stale-read event when another agent wrote the file since this reader last saw it.
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Auto Trait Implementations§
impl !RefUnwindSafe for ToolContext
impl !UnwindSafe for ToolContext
impl Freeze for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContext
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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