Agentic.Sandbox.Runner (agentic v0.4.0)

Copy Markdown

Cross-platform sandbox wrapper for agent subprocesses.

Provides a single entry point that selects the correct OS-level isolation mechanism based on Agentic.Sandbox.Platform.backend/0.

Supports two invocation styles:

Summary

Functions

Extra sandbox-bind roots required by script shims, scanned statically.

Wraps an executable path and argument list in the platform-appropriate sandbox.

Wraps a shell command string in the platform-appropriate sandbox.

Functions

script_bind_roots(executable)

Extra sandbox-bind roots required by script shims, scanned statically.

A shim like /usr/sbin/claude is a shebang shell script whose body execs the real binary (e.g. /opt/claude-code/bin/claude). The symlink chain can never see that target, so benchmarks installed under tool prefixes like /opt/… vanish inside the sandbox and the CLI dies instantly with "No such file or directory". We scan the script text for absolute paths and return each path's first two components (e.g. /opt/claude-code) so the caller can --ro-bind-try them.

wrap_executable(executable, args, opts \\ [])

@spec wrap_executable(String.t(), [String.t()], keyword()) ::
  {String.t(), [String.t()], keyword()}

Wraps an executable path and argument list in the platform-appropriate sandbox.

Returns {executable, args, extra_env} suitable for Port.open({:spawn_executable, executable}, [:binary, :exit_status, {:args, args} | extra_env]).

wrap_shell(command, opts \\ [])

@spec wrap_shell(String.t(), keyword()) :: String.t()

Wraps a shell command string in the platform-appropriate sandbox.

Returns a string that can be passed to Port.open({:spawn, command}, ...).