Skip to main content

Crate aither_sandbox

Crate aither_sandbox 

Source
Expand description

Sandboxed shell execution with heel.

This crate provides the general capabilities an embedder builds a terminal-style agent tool on:

  • Sandbox spawns a process under heel’s sandbox, in a container or on an SSH server, with live Grants and an EnvSource the embedder fills at each launch.
  • Shell executes scripts for a model on a Sandbox: a carried directory, jobs, waiting, output handling and ScriptPolicy checks before a script runs.
  • ShellTool and the job control tools are ordinary Tools the embedder names and describes.

The embedder owns the commands its scripts call back into, the programs its sandboxes run with and every sentence the model reads.

ⓘ
use aither_sandbox::{Backend, Sandbox, Shell};

let sandbox = Sandbox::new(Backend::Host { heel }, executor, working_dir);
let shell = Shell::builder_on_host(sandbox, host_shell)
    .interpreters(interpreters)
    .limits(limits)
    .output(output)
    .wording(wording)
    .tools(tools)
    .build()
    .await?;
let tool = shell.tool();

Re-exports§

pub use builtin::JobInputArgs;
pub use builtin::JobInputTool;
pub use builtin::JobKillArgs;
pub use builtin::JobKillTool;
pub use builtin::JobReadArgs;
pub use builtin::JobReadTool;
pub use builtin::ShellToolSettings;
pub use builtin::ToolIdentity;
pub use monitor::MonitorArgs;
pub use monitor::MonitorEnd;
pub use monitor::MonitorEnded;
pub use monitor::MonitorIncrement;
pub use monitor::MonitorRefusal;
pub use monitor::MonitorSettings;
pub use monitor::MonitorSource;
pub use monitor::MonitorStalled;
pub use monitor::MonitorTool;
pub use network_policy::CompiledNetworkPolicy;
pub use network_policy::NetworkPolicyConfig;
pub use network_policy::NetworkPolicyError;
pub use network_policy::NetworkPolicyMode;
pub use network_policy::NetworkVerdict;

Modules§

builtin
The job control tools and the identities an embedder gives its shell tools. The control tools of a shell’s jobs.
monitor
monitor — watch a command or a file and deliver its new output as it arrives.
network_policy
Declarative host-based network policy. Declarative host-based network policy.

Structs§

AnyContainerExec
Backend-agnostic container executor handle.
AnyContainerMemory
A type-erased ContainerMemory, what the builders store.
AnyDomainApprover
A cloneable handle on any DomainApprover.
AnyFootprintReader
A type-erased FootprintReader, what the builders store.
AnyFootprintRegistry
A type-erased FootprintRegistry, what the builders store.
AnyIpcProvider
A type-erased IpcProvider.
AnyPrepareSsh
A type-erased PrepareSsh.
AnyScriptPolicy
A type-erased ScriptPolicy.
AnyShellWording
A shared ShellWording, cloned into every shell, store and tool that renders a text.
AnySubagentSpaces
A SubagentSpaces of any type, as a terminal holds it.
ApproveAllDomains
Approves every domain it is asked about.
BollardContainerExec
Executes commands in a running container via Docker exec.
CgroupMemory
What the container’s own memory cgroup (v2) reports.
CommandId
Identifies one command of a ShellScript.
CommitLedger
Lists the commits a subagent holding a commit grant made, and brings them into the main repository.
CommitMark
Where a ledger’s worktrees stood at one moment: the commits their branch namespaces and detached heads pointed at.
CompletedCommand
A command that ran to completion.
ContainerImageSpec
Image build specification.
ContainerLaunch
The programs prepared inside a container, for Backend::Container.
ContainerLaunchSpec
Container launch specification.
ContainerPath
An absolute POSIX path inside a container.
ContainerProbe
Runs short read-only scripts inside a container and returns what they print, through the same exec path commands use.
ContainerShellRuntime
Container runtime session metadata.
ContainerSnapshot
The state of the container’s memory limit and of the agent’s jobs in it.
DenyAllDomains
Denies every domain it is asked about, which is what a sandbox without an approver does.
DescendantsKilled
Processes a foreground command left running when its shell exited, killed with it.
DomainRequest
One connection a sandboxed process makes to a domain the network lists leave open.
FileFootprintRegistry
A FootprintRegistry in a directory every agent of the machine shares.
FoldedLines
A block of source code folded into one marker line.
ForegroundWait
How long a terminal call waits in the foreground before a still-running command promotes to a background task.
Given
A value the builder was given.
GrantSnapshot
The path grants one spawn launches with. Immutable once handed out: snapshots are replaced, never edited.
Grants
Shared, runtime-mutable grants of a Sandbox.
HostLaunch
The shell prepared on the host, for Shell::builder_on_host: the program a script runs under, as a path on this machine.
HostRoute
How a container reaches the host: the name it dials and the host address a listener meant for the container binds.
ImportBudget
The most bytes a subagent’s sandbox may send the host while the commits it made are imported: the pack, and every answer to a question about its repository.
Job
One job of a shell.
JobDelta
Incremental read result for a background terminal buffer.
JobEnded
A job that ran to its end: one promoted past the foreground window or started in the background. A script whose call returned its result, and every Shell::run, raises none.
JobFootprint
One running job and the memory its process tree holds.
JobInfo
Information about a running or completed background job.
JobInputSent
Bytes written to a job’s stdin.
JobKillAsked
A kill of a job.
JobMemory
A terminal’s view of the memory its jobs hold.
JobOutputAppender
Appends to the output of one running job, such as the progress an embedder’s command reports while the script that called it runs.
JobProcess
A process of a job other than its top-level shell.
JobStarted
A job the shell has just detached: started with background, or promoted past ShellLimits::foreground_wait.
Jobs
The jobs of one shell: every script that outlived its call, was started in the background or watched by a monitor.
JsonAsTsv
A JSON payload shown as TSV, its original stored in a file.
LaunchInfo
What a launch is, as the shell that starts it knows it.
LineId
Identifies one simple command of a ShellScript as written: a program with its words, which may run further commands through wrappers.
LineRange
A run of lines a view of an output leaves out or stands for.
LiveDuration
A duration adjustable while the shell runs. Every clone shares it.
LongRunning
A job that crossed the long-running threshold; raised once per job.
MediaBounds
The pixel bounding boxes of the MediaResolution levels that resize.
MemorySize
A number of bytes, shown the way a person reads memory: 36.2 GiB.
MemorySnapshot
The memory state of one MemoryDomain and of one agent’s jobs in it at one moment.
Missing
A value the builder has not been given yet.
MonitorStarted
A monitor call that started watching a task.
MountRoot
Declarative host/container root pair used to create validated child mounts.
MountSpec
A host path mounted into a container path.
NetworkAuditLog
Re-export of heel’s rolling network audit log for terminal-tool configuration. JSONL sink for network access decisions.
NiceLevel
Re-export of heel’s scheduling priority types for terminal-tool configuration. How many steps below its host a sandbox runs: 1..=19, larger being lower.
OmittedLines
The middle of a stored output a preview leaves out.
OutputLimits
Every budget of the output a shell hands the model.
OutputPolicy
The live handle to a shell’s OutputLimits.
OutputSaved
An output too large for the window, replaced by a preview and the file that holds all of it.
OutputStore
Stores the outputs too large for a result, each in a file named by a word leased from the store’s AnyIdAllocator.
OwedCompletion
What [JobRegistry::owe_completion] settled for a job.
PendingCompletion
A finished job’s completion on its way to the agent.
PipelineId
Identifies one pipeline of a ShellScript.
PipelineStage
Where a command line sits in a pipeline of two or more commands.
PreparedSpace
What an embedder made in a run’s space.
PreparedSsh
What the embedder prepared on a server: its heel and the programs its scripts run with.
ProbedContainerMemory
Reads a container’s memory by running scripts in it through its exec path.
ProcessPriority
Re-export of heel’s scheduling priority types for terminal-tool configuration. The scheduling priority of a sandboxed process and its descendants.
Refused
A call refused before it ran: the typed reason, and the text its wording rendered for the model.
RelativeContainerPath
A string that is not an absolute POSIX path.
RemoteLaunch
The programs prepared on a server, for Backend::Ssh. Paths are on the server and text, because a script names them.
RepeatedLines
A run of identical lines a preview shows once.
ResponseWindow
How long the agent has to act on a final warning before its job is killed, adjustable while the agent runs. Every clone shares it.
RunSpace
The space a subagent run is about to start in.
RuntimePreference
Runtime selection order.
Sandbox
One home environment’s sandbox: grants, environment, network policy and the Backend processes run on. Cheap to clone; clones share the live grants.
SandboxedChild
A process spawned through Sandbox::spawn.
Script
A script Shell::run runs to its end.
ScriptCheck
A script about to run, as a ScriptPolicy and the shell’s TreatOutput see it.
ScriptEnd
The end of a script a ScriptPolicy was asked about.
ScriptPolicies
A shell’s policies, each bound to the state of the agent the shell serves.
ScriptRefusal
A script a ScriptPolicy refused; the model reads Self::text as the call’s result.
ScriptResult
What a script printed and how it ended, as data: the embedder words it where it hands a result to its model.
Shell
The terminal tool for executing scripts in a sandbox.
ShellArgs
ShellBuilder
Builds a Shell on the Sandbox its scripts run in.
ShellCommand
One command line a script would run, with its words unquoted.
ShellEvents
The events of one or several shells, and where they are read.
ShellLimits
The budgets a shell runs its scripts under.
ShellParseError
A script that is not valid shell, or nests shell strings and substitutions too deeply to follow.
ShellScript
A shell script parsed into every command line it would run, in source order, a command’s substitutions ahead of the command.
ShellSessionRegistry
The SSH servers a shell’s commands may run on, as the embedder prepared them.
ShellTool
The model-facing tool of a Shell: the embedder’s name and description over the shell’s execution, with an argument schema that lists exactly the interpreters the shell was configured with.
SpacePreparationError
An embedder’s failure to prepare a space, whatever its own error type.
SpawnSpec
A process to start under a Sandbox.
SshPlatform
The operating system and architecture a server reports, as uname -s and uname -m print them (for example Linux and x86_64).
SshPrepareError
Why a server could not be prepared. The server stays in the set, and the next command naming it prepares it again.
SshServer
A named SSH destination commands may run on.
StdinBlocked
A job whose stdin pipe has a reader waiting for input; raised once per blocking episode, so again only after the job was fed and blocks anew.
StdinWatchFailed
A job whose stdin watch failed; raised once, after which the job can no longer report being blocked on stdin.
Stdio
The standard streams of a spawned process. The default pipes stdout and stderr and gives stdin nothing.
StoredBinaryPart
A binary part of a result, stored in a file.
SubagentCommit
A commit a subagent made.
SubagentGrant
What a launcher grants a subagent beyond its own space.
SystemFootprints
Reads the host this process runs on.
TimeoutKill
A command killed because its timeout bound passed, with the UTC times it started and was killed at.
UnchangedRead
Why a tool refused a read of a job’s output: nothing changed since the job’s last read. The refusal a tool returns as Refused<UnchangedRead>.

Enums§

AppendOutcome
Whether JobOutputAppender::append reached its job.
Backend
Where a sandbox’s processes run.
CallRefusal
A call of the shell’s tools refused before it ran.
Carry
What a script did to the directory the shell carries to the next foreground script.
ChildExit
How a spawned process ended.
CommandKilled
Why a foreground command the shell killed was killed.
CommitLedgerError
Why the commits of a subagent could not be listed.
ContainerExecOutcome
Outcome of a container execution request.
ContainerProbeError
Why a probe of a container failed.
ContainerRuntimeKind
Supported Docker-compatible runtime kinds.
CpuPriority
Re-export of heel’s scheduling priority types for terminal-tool configuration. How much CPU time a sandboxed process competes for.
Delivery
Whether a finished job’s completion has reached its agent.
Descendants
The processes a child left running that the backend ended with it, which only a Foreground child has.
DirectoryResetReason
Why the next foreground command does not start where the last one left the shell.
ExecLifetime
How long the processes a container command leaves running when its top-level shell exits may live.
FootprintError
Why a footprint or the physical memory could not be read.
GitDirAccess
The access a sandbox has to the common git directory of a linked worktree it may write.
HostRouteError
Why an address and name cannot be a HostRoute.
Interpreter
IoPriority
Re-export of heel’s scheduling priority types for terminal-tool configuration. How much disk bandwidth a sandboxed process competes for.
JobInputError
Why bytes were not written to a job’s stdin.
JobPlace
Where a job runs, which decides what is watched of it.
JobRead
What a read of a job’s output returned.
JobStatus
Status of a background job.
JobWaitError
Why waiting for a job did not end in a result.
KillCause
Why a job was killed.
KillTreeError
Why a process tree could not be killed.
MediaResolution
MemoryDomain
Which memory a job competes for.
MountAccess
Filesystem mount access policy.
MountRootError
Mount-root composition error.
OutputFormat
Expected output format for terminal execution.
OutputTreatment
What the shell does to a foreground script’s text output before the model reads it.
Pipe
Whether a standard stream of a spawned process is piped to its handle.
ProcessTableError
Why a job’s descendants could not be found or killed.
RunFailure
A call or run that did not get to an end, other than one refused before it ran: the failure as data, for the embedder to word.
RunOutcome
How a script ended.
SandboxMode
ScriptDecision
What a ScriptPolicy decided about one script.
ScriptDir
A directory a script starts or ends in, as the backend that runs it names it.
ScriptOrigin
How a script came to the terminal.
ScriptOutcome
How a script a ScriptPolicy was asked about ended.
ShellEvent
A fact about a job of a shell.
ShellRunError
Why a Shell::run did not run to an end.
SpawnCommand
What a spawned process runs.
SpawnError
Why a process could not be spawned.
SpawnGrant
An access a process is granted beyond the sandbox’s own grants, named where the backend that honours it sees the path.
SshProbeError
Why probe_ssh_os could not tell a server’s platform.
SshServerError
Why a server cannot join a registry’s server set.
StdinWatchSignal
What a container exec’s stdin watch reports over its stdin_blocked channel.
SubagentGrantError
Why a SubagentGrant cannot be given.
TerminalError
Errors that can occur during terminal execution.
TreeLifetime
How long a job’s descendants may outlive its top-level process, which decides how a Linux job is supervised.

Constants§

JOB_MARKER_ENV
The environment variable marking every process of a container job.
JOB_MARKER_VAR
The environment variable that marks every process of a job; its value is the job’s [JobMarker].

Traits§

ContainerExec
Trait for executing commands inside a container.
ContainerMemory
Reads the memory of the container the agent works in, inside the container: its cgroup, and the footprint of the jobs it runs.
DomainApprover
Decides the connections the sandbox’s network lists leave open.
EnvSource
Supplies environment variables resolved at each launch.
FootprintReader
Reads job footprints and the machine’s physical memory.
FootprintRegistry
Shares the memory each agent’s jobs hold between the agents on a machine, so each sees the machine-wide total and who contributes the most. It is used to total and to rank, never as a cap.
IpcProvider
Supplies the heel::IpcRouter a script of a shell can call back into the host’s commands through.
PrepareSsh
Prepares a server for the shell’s scripts: finds or installs its heel and the programs scripts run with.
ScriptPolicy
Decides whether a script may run, before it does.
ShellWording
The text the model reads for each refusal, notice and marker the shell raises, one method per family.
SubagentSpaces
Prepares the space each subagent run works in.
TreatOutput
Chooses the OutputTreatment of every script of a shell, before it runs.

Functions§

kill_process_tree
Kills the process pid and every process in its process group.
open_network_audit_log
Opens a daily-rotated network audit log under dir, creating the directory if needed.
probe_ssh_os
The platform server runs: one uname -s -m over one SSH connection, installing nothing and asking no one. An embedder calls it when the user adds a server, to record what the server is.