AbstractProtectedinitializedBacking flag for isInitialized.
Subclasses own this flag: set it in initialize and clear it in close.
Whether the environment has been initialized.
AbstractworkingThe absolute path to the environment's working directory.
ProtectedassertThrows if initialize has not been called.
Implementations should call this at the start of every operation that needs a live working directory.
Releases resources held by the environment.
The default implementation is a no-op. Subclasses must be idempotent and must clear initialized.
AbstractexecuteExecutes a shell command in the working directory.
The shell command string to execute.
OptionaltimeoutSeconds: numberMaximum execution time in seconds. undefined means
no limit.
The exit code, stdout, stderr, and timeout status. A non-zero exit code is reported in the result, not thrown.
Initializes the environment (e.g. creates the working directory).
Called before first use. The default implementation is a no-op and leaves
isInitialized false. Subclasses must be idempotent and must set
initialized.
AbstractreadReads a file from the environment's filesystem.
Absolute or working-dir-relative path to the file.
The raw file contents.
AbstractwriteWrites content to a file in the environment's filesystem.
Parent directories are created automatically if they do not exist.
Absolute or working-dir-relative path to the file.
The string or raw bytes to write.
Abstract base class for code execution environments.
An environment provides the ability to execute shell commands, read files, and write files within a working directory. Concrete implementations include local subprocess execution, sandboxed execution, container environments, and cloud-hosted environments.
Lifecycle: