SandboxedCommand#
Run commands and agent-written programs inside an operating-system boundary. See the guide.
- class zett_agent.sandbox.base.SandboxedCommand(argv, env, cwd, limits=ResourceLimits(memory_bytes=None, cpu_seconds=None, cpu_percent=None, processes=None, file_size_bytes=None, open_files=None, core_dumps=False, memory_sample_seconds=0.25), preexec=None, warnings=())[source]#
A command rewritten to run inside a sandbox, ready for a process API.
Sandbox.wrap()returns one without running anything, so a host that owns its process handling (streaming output, a pty, its own timeout) can spawnargvitself withenvandcwd. Start it in its own process group (start_new_session=Trueon POSIX) so the whole tree can be stopped.- Parameters:
argv (tuple[str, ...])
env (Mapping[str, str])
cwd (Path)
limits (ResourceLimits)
preexec (Callable[[], None] | None)
warnings (tuple[str, ...])
- argv#
The program and its arguments, including the sandbox launcher.
- Type:
tuple[str, …]
- env#
The complete environment to start it with.
- Type:
collections.abc.Mapping[str, str]
- cwd#
The working directory to start it in.
- Type:
pathlib.Path
- limits#
The resource limits the policy asked for. A host that spawns the command itself applies the kernel limits with
preexec; the ones onlySandbox.run()can enforce are named inwarnings.
- preexec#
Apply the kernel resource limits in the child before
exec, forsubprocess’preexec_fn. None when there is nothing to apply.- Type:
collections.abc.Callable[[], None] | None
- warnings#
Parts of the policy or the limits this backend could not enforce for this command. A caller that must not run with a weaker boundary checks it.
- Type:
tuple[str, …]