pub struct ExecTool { /* private fields */ }Expand description
Unified execution tool for agents.
Wraps both shell-string and structured binary+args execution behind a
single AgentTool implementation that uses a mode parameter to
dispatch to the appropriate method.
Access control is enforced based on agent_name:
- shell_exec: audit logging (cannot sandbox arbitrary shell).
- structured_exec: pre-flight permission check via
AccessManager.
Implementations§
Source§impl ExecTool
impl ExecTool
Sourcepub fn new(
config: SharedExecConfig,
access: Arc<Mutex<AccessManager>>,
context: AgentContext,
) -> Self
pub fn new( config: SharedExecConfig, access: Arc<Mutex<AccessManager>>, context: AgentContext, ) -> Self
Create a new ExecTool with an AgentContext (production path).
All executions are attributed to the agent and pass through access checks.
Sourcepub fn new_gated(
config: SharedExecConfig,
context: AgentContext,
gate: Arc<AccessGate>,
) -> Self
pub fn new_gated( config: SharedExecConfig, context: AgentContext, gate: Arc<AccessGate>, ) -> Self
Create a gated ExecTool with both context and access gate.
Sourcepub fn from_kernel_with_context(
kernel: &KernelHandle,
context: AgentContext,
) -> Self
pub fn from_kernel_with_context( kernel: &KernelHandle, context: AgentContext, ) -> Self
Create an ExecTool from a [KernelHandle] with an agent context.
This is the primary production constructor.
Sourcepub fn from_kernel(kernel: &KernelHandle) -> Self
pub fn from_kernel(kernel: &KernelHandle) -> Self
Create an ExecTool from a [KernelHandle] (legacy, no context).
Binds the tool to the default agent name "oxios-agent".
Prefer from_kernel_with_context for full security.
Sourcepub fn for_agent(
config: SharedExecConfig,
access: Arc<Mutex<AccessManager>>,
_agent_name: String,
) -> Self
pub fn for_agent( config: SharedExecConfig, access: Arc<Mutex<AccessManager>>, _agent_name: String, ) -> Self
Create a new ExecTool bound to a specific agent name (legacy).
Prefer new() with AgentContext for full security.
Sourcepub fn new_unrestricted(
config: SharedExecConfig,
access: Arc<Mutex<AccessManager>>,
) -> Self
pub fn new_unrestricted( config: SharedExecConfig, access: Arc<Mutex<AccessManager>>, ) -> Self
Legacy constructor without agent context (for backward compatibility).
Warning: This bypasses the new AgentContext / AccessGate path.
Use only for migration or testing.
Sourcepub async fn shell_exec(
&self,
command: &str,
timeout_ms: u64,
shutdown: Option<Receiver<()>>,
) -> Result<ExecResult, String>
pub async fn shell_exec( &self, command: &str, timeout_ms: u64, shutdown: Option<Receiver<()>>, ) -> Result<ExecResult, String>
Execute a raw command string via bash -c <cmd>.
Primary shell execution path.
The entire command string is forwarded to bash -c, so pipelines,
redirects, and compound commands all work.
If a shutdown signal is provided and fires before the command
completes, the child process is killed and an error is returned.
Sourcepub async fn structured_exec(
&self,
binary: &str,
args: Vec<String>,
timeout_ms: u64,
shutdown: Option<Receiver<()>>,
) -> Result<ExecResult, String>
pub async fn structured_exec( &self, binary: &str, args: Vec<String>, timeout_ms: u64, shutdown: Option<Receiver<()>>, ) -> Result<ExecResult, String>
Execute a binary with explicit args, enforcing allowlist + metachar blocking.
Primary structured execution path. Security checks:
- Binary must be a bare name (no
/or..). - Binary must be in the allowlist (or allowlist is empty = dev mode).
- Arguments must not contain shell metacharacters or path traversal.
If a shutdown signal is provided and fires before the command
completes, the child process is killed and an error is returned.
Trait Implementations§
Source§impl AgentTool for ExecTool
impl AgentTool for ExecTool
Source§fn description(&self) -> &'static str
fn description(&self) -> &'static str
Source§fn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
Source§fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_call_id: &'life1 str,
params: Value,
shutdown: Option<Receiver<()>>,
_ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_tool_call_id: &'life1 str,
params: Value,
shutdown: Option<Receiver<()>>,
_ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Source§fn essential(&self) -> bool
fn essential(&self) -> bool
Source§fn on_progress(&self, _callback: Arc<dyn Fn(String) + Send + Sync>)
fn on_progress(&self, _callback: Arc<dyn Fn(String) + Send + Sync>)
Source§fn on_browse_progress(
&self,
_callback: Arc<dyn Fn(BrowseProgress) + Send + Sync>,
)
fn on_browse_progress( &self, _callback: Arc<dyn Fn(BrowseProgress) + Send + Sync>, )
ToolCallContext with structured
data from BrowseProgress events.Source§fn render_call(&self, _params: &Value) -> Option<RenderOutput>
fn render_call(&self, _params: &Value) -> Option<RenderOutput>
Source§fn render_result(&self, _result: &AgentToolResult) -> Option<RenderOutput>
fn render_result(&self, _result: &AgentToolResult) -> Option<RenderOutput>
Source§fn execution_mode(&self) -> ToolExecutionMode
fn execution_mode(&self) -> ToolExecutionMode
Source§fn current_tab_id(&self) -> Option<Uuid>
fn current_tab_id(&self) -> Option<Uuid>
None. Browser tools override this to return the tab ID
of the currently-open tab during execution, so the agent loop can
populate ToolExecutionUpdate.tab_id.Source§fn set_tab_id_slot(&self, _slot: Arc<Mutex<RawMutex, Option<Uuid>>>)
fn set_tab_id_slot(&self, _slot: Arc<Mutex<RawMutex, Option<Uuid>>>)
on_progress;
the tool writes Some(tab_id) when it opens a tab and None when
it closes it. Defaults to a no-op — only tab-aware tools override.