pub struct Shell { /* private fields */ }Expand description
Run shell commands in the workspace.
The tool is annotated destructive. It contains no approval logic: put an
approval aidaemon_core::Hook in front of it, and pick a contained
backend to limit what an approved command can reach.
Note that the agent’s Limits::tool_timeout (120 s by default) also
bounds each call; raise it if you raise max_timeout.
Implementations§
Source§impl Shell
impl Shell
pub fn new(workspace: Workspace, backend: Arc<dyn Sandbox>) -> Self
Sourcepub fn sandboxed(workspace: Workspace) -> Self
pub fn sandboxed(workspace: Workspace) -> Self
Shell with best_available_sandbox: bubblewrap on Linux and
seatbelt on macOS when available, overridable with
crate::SANDBOX_ENV; uncontained (with a one-time warning) when no
OS sandbox is available.
Sourcepub fn env_allowlist(
self,
names: impl IntoIterator<Item = impl Into<String>>,
) -> Self
pub fn env_allowlist( self, names: impl IntoIterator<Item = impl Into<String>>, ) -> Self
Replace the list of host environment variables passed through.
Sourcepub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Set a fixed variable for every command (overrides the host value).
pub fn timeouts(self, default: Duration, max: Duration) -> Self
pub fn max_output_bytes(self, bytes: usize) -> Self
Sourcepub fn allow_network(self, allow: bool) -> Self
pub fn allow_network(self, allow: bool) -> Self
Let commands use the network, or not. Unset, a backend that can cut
the network (Sandbox::enforces_network_off) does, and one that
cannot (LocalSandbox) leaves it on and says so in the tool’s
description. Set to false, commands are refused on a backend that
cannot enforce it, rather than run with the network on.
Sourcepub fn deny_read(
self,
paths: impl IntoIterator<Item = impl Into<PathBuf>>,
) -> Self
pub fn deny_read( self, paths: impl IntoIterator<Item = impl Into<PathBuf>>, ) -> Self
Host paths commands must not read, for example credential
directories (on top of the backend’s own defaults; see
SandboxCommand::deny_read). On a backend that cannot enforce it
(Sandbox::enforces_deny_read, for example LocalSandbox), every
command is refused rather than run with the paths readable.
pub fn backend(&self) -> &Arc<dyn Sandbox> ⓘ
Trait Implementations§
Source§impl Tool for Shell
impl Tool for Shell
Source§fn timeout(&self) -> Option<Duration>
fn timeout(&self) -> Option<Duration>
The loop must allow at least the shell’s own maximum plus time to kill the process group and collect output.
fn spec(&self) -> ToolSpec
fn annotations(&self) -> ToolAnnotations
Source§fn validate(&self, arguments: &Value) -> Result<(), String>
fn validate(&self, arguments: &Value) -> Result<(), String>
check_arguments: required keys, types, enums, nested objects
and array items) before calling this, whatever a tool does here, so
an override only adds checks. The default is that schema check.Source§fn access(&self, arguments: &Value) -> AccessManifest
fn access(&self, arguments: &Value) -> AccessManifest
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
arguments: Value,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn annotations_for(&self, _arguments: &Value) -> ToolAnnotations
fn annotations_for(&self, _arguments: &Value) -> ToolAnnotations
ls versus rm) override this; the default is the
tool-wide Tool::annotations. Read moreSource§fn source_trust(&self, _arguments: &Value) -> SourceTrust
fn source_trust(&self, _arguments: &Value) -> SourceTrust
Untrusted; a
tool whose output is the owner’s own (a workspace file, the
kernel’s bookkeeping) returns Trusted. A result may override this
with ToolOutput::with_trust.Source§fn outbound(&self, _arguments: &Value) -> Outbound
fn outbound(&self, _arguments: &Value) -> Outbound
Source§fn effects(&self, arguments: &Value) -> CallEffects
fn effects(&self, arguments: &Value) -> CallEffects
CallEffects::none for a call that is read-only and
not egress (per Tool::annotations_for). Otherwise it is what the
call’s declared Tool::access implies (CallEffects::from_access:
a written path is a write effect, a host an egress effect), so an
owner’s denial of the call binds the rest of the run; and
CallEffects::unknown when it declares no access: a read from
another host still sends the request off the machine, so a tool
annotated egress should declare its host or its
EffectKey::egress target. Recomputed
after a hook rewrites the arguments.Source§fn concurrent_peers(&self) -> usize
fn concurrent_peers(&self) -> usize
Source§fn suspends(&self) -> bool
fn suspends(&self) -> bool
ToolOutput::suspended. A call
of such a tool always runs alone, because a run pauses on one call at
a time.Source§fn resume_child<'life0, 'life1, 'async_trait>(
&'life0 self,
_child: RunState,
_resolution: Resolution,
_ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn resume_child<'life0, 'life1, 'async_trait>(
&'life0 self,
_child: RunState,
_resolution: Resolution,
_ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Tool::call would have returned: a
result, or ToolOutput::suspended if the child paused again. Read more