pub struct ToolContext {
pub workspace_dir: PathBuf,
pub root_dir: Option<PathBuf>,
pub session_id: Option<String>,
pub snapshot_store: Option<Arc<dyn SnapshotStore>>,
pub memory: Option<Arc<dyn MemoryBackend>>,
pub url_resolver: Option<Arc<dyn UrlResolver>>,
pub todo: Option<Arc<dyn TodoStateProvider>>,
pub agent_pool: Option<Arc<dyn AgentPoolProvider>>,
pub lsp: Option<Arc<dyn LspProvider>>,
pub subagent_runner: Option<Arc<dyn SubagentRunner>>,
pub subagent_depth: u8,
pub intent: Option<String>,
}Expand description
This allows tools to operate on a specific workspace without being
rebuilt. When root_dir is Some, tools use it as their base directory.
When None, tools should fall back to workspace_dir.
Fields§
§workspace_dir: PathBufPrimary workspace directory (used when root_dir is None).
root_dir: Option<PathBuf>Optional explicit root directory for file tools. Takes priority over workspace_dir if present.
session_id: Option<String>Session identifier for logging/tracing.
snapshot_store: Option<Arc<dyn SnapshotStore>>Snapshot store for hashline tag emission/validation.
When None, hashline edit mode is unavailable.
memory: Option<Arc<dyn MemoryBackend>>Memory backend for memory_* tools.
When None, memory tools return an error.
url_resolver: Option<Arc<dyn UrlResolver>>URL resolver for internal protocol schemes (issue://, pr://, etc.).
When None, URL-prefixed paths are treated as regular file paths.
todo: Option<Arc<dyn TodoStateProvider>>Todo state for the todo agent tool.
When None, the todo tool returns an error.
agent_pool: Option<Arc<dyn AgentPoolProvider>>Agent pool for Hub display and todo sub-agent matching.
lsp: Option<Arc<dyn LspProvider>>LSP provider for the lsp tool.
subagent_runner: Option<Arc<dyn SubagentRunner>>In-process sub-agent runner (issue #28 gap 3).
When Some, the subagent tool prefers an in-process isolated
run over shelling out to the CLI binary. Library consumers
(e.g. Oxios) that embed oxicode-agent without an oxicode subprocess
set this so delegation works. When None, the CLI backend is
used (the default for oxicode-cli).
subagent_depth: u8Current sub-agent nesting depth for the in-process path (issue #28 gap 3). The CLI path uses env vars instead. Default 0 (top-level agent).
intent: Option<String>Intent trace for the current tool call.
Set by the agent loop before executing each tool, read by tools
that surface intent to users (e.g. ask).
Implementations§
Source§impl ToolContext
impl ToolContext
Sourcepub fn new(workspace_dir: impl Into<PathBuf>) -> ToolContext
pub fn new(workspace_dir: impl Into<PathBuf>) -> ToolContext
Create a new context with the given workspace.
Sourcepub fn root(&self) -> &Path
pub fn root(&self) -> &Path
Get the effective root directory. Returns root_dir if set, otherwise workspace_dir.
Sourcepub fn with_session(self, session_id: impl Into<String>) -> ToolContext
pub fn with_session(self, session_id: impl Into<String>) -> ToolContext
Set a session ID.
Sourcepub fn with_root(self, root_dir: impl Into<PathBuf>) -> ToolContext
pub fn with_root(self, root_dir: impl Into<PathBuf>) -> ToolContext
Set an explicit root directory.
Sourcepub fn with_snapshot_store(self, store: Arc<dyn SnapshotStore>) -> ToolContext
pub fn with_snapshot_store(self, store: Arc<dyn SnapshotStore>) -> ToolContext
Set the snapshot store (enables hashline edit mode).
Sourcepub fn with_memory(self, memory: Arc<dyn MemoryBackend>) -> ToolContext
pub fn with_memory(self, memory: Arc<dyn MemoryBackend>) -> ToolContext
Set the memory backend (enables memory tools).
Sourcepub fn with_url_resolver(self, resolver: Arc<dyn UrlResolver>) -> ToolContext
pub fn with_url_resolver(self, resolver: Arc<dyn UrlResolver>) -> ToolContext
Set the URL resolver (enables internal URL dispatch).
Sourcepub fn with_todo(self, todo: Arc<dyn TodoStateProvider>) -> ToolContext
pub fn with_todo(self, todo: Arc<dyn TodoStateProvider>) -> ToolContext
Set the todo state (enables the todo agent tool).
Sourcepub fn with_subagent_runner(
self,
runner: Arc<dyn SubagentRunner>,
) -> ToolContext
pub fn with_subagent_runner( self, runner: Arc<dyn SubagentRunner>, ) -> ToolContext
Set the in-process sub-agent runner (enables library-native delegation — issue #28 gap 3).
Sourcepub fn with_intent(self, intent: impl Into<String>) -> ToolContext
pub fn with_intent(self, intent: impl Into<String>) -> ToolContext
Attach an intent trace to this context.
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