ADK for TypeScript: API Reference
    Preparing search index...

    Class BaseEnvironmentAbstract

    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:

    1. Construct the environment.
    2. Call initialize before first use.
    3. Use execute, readFile, writeFile.
    4. Call close when done.

    Hierarchy (View Summary)

    Constructors

    Properties

    initialized: boolean = false

    Backing flag for isInitialized.

    Subclasses own this flag: set it in initialize and clear it in close.

    Accessors

    Methods

    • Executes a shell command in the working directory.

      Parameters

      • command: string

        The shell command string to execute.

      • OptionaltimeoutSeconds: number

        Maximum execution time in seconds. undefined means no limit.

      Returns Promise<ExecutionResult>

      The exit code, stdout, stderr, and timeout status. A non-zero exit code is reported in the result, not thrown.

    • Reads a file from the environment's filesystem.

      Parameters

      • filePath: string

        Absolute or working-dir-relative path to the file.

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The raw file contents.

    • Writes content to a file in the environment's filesystem.

      Parent directories are created automatically if they do not exist.

      Parameters

      • filePath: string

        Absolute or working-dir-relative path to the file.

      • content: string | Uint8Array<ArrayBufferLike>

        The string or raw bytes to write.

      Returns Promise<void>