DockerShellExecutor class
A ShellExecutor that runs commands inside a Docker container.
Security model. The container provides the primary isolation boundary:
no network, non-root user, read-only root filesystem, dropped capabilities,
and a memory/PID limit. asAIFunction still wraps in
ApprovalRequiredAIFunction by default — container isolation is not a
replacement for approval gating because a compromised image or privileged
container can still cause harm.
Persistent mode reuses a single long-lived container per instance. Use one executor per session and dispose it when the session ends.
- Inheritance
-
- Object
- ShellExecutor
- DockerShellExecutor
Constructors
- DockerShellExecutor([DockerShellExecutorOptions? options])
-
Creates a DockerShellExecutor with the given
options.
Properties
- containerName → String
-
The name of the Docker container managed by this executor.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
outputEvents
→ Stream<
ShellOutputChunk> -
Live stdout and stderr produced by commands run through this executor.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asAIFunction(
{bool requireApproval = true}) → AIFunction -
Returns an
AIFunctionthat invokes this executor when called by a model. -
dispose(
) → Future< void> -
Tears down the executor and releases any underlying resources.
override
-
initializeAsync(
{CancellationToken? cancellationToken}) → Future< void> -
Eagerly initialize the backend. Idempotent; subsequent calls are no-ops
once the executor is started.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
runAsync(
String command, {CancellationToken? cancellationToken}) → Future< ShellResult> -
Run a single command and return its result. Implementations apply the
configured per-command timeout and surface it via
ShellResult.timedOut +
exitCode = 124.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
buildExecArgv(
String binary, String containerName) → List< String> -
Builds the
docker execargv for attaching to the persistent container. -
buildRunArgv(
{required String binary, required String image, required String containerName, required ContainerUser user, required String network, required int memoryBytes, required int pidsLimit, required String workdir, required String? hostWorkdir, required bool mountReadonly, required bool readOnlyRoot, required Map< String, String> ? extraEnv, required List<String> ? extraArgs}) → List<String> -
Builds the
docker runargv for creating and starting the container. -
isAvailableAsync(
{String binary = 'docker'}) → Future< bool> -
Returns
truewhenbinaryis available on PATH.