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

    Class LocalEnvironment

    Executes commands via local child processes, scoped to a working directory.

    When workingDir is not specified, a temporary directory is created on initialize and removed on close.

    WARNING: this class runs arbitrary shell strings on the host with no sandboxing and no sanitisation — the caller is responsible for trusting the command. It is a building block; tools built on top of it are responsible for gating execution behind an explicit user confirmation.

    Further limitations, all shared with the adk-python reference implementation:

    • stdout and stderr are buffered fully in memory with no cap, so a command producing unbounded output will grow the heap until it fails.
    • The child inherits the whole of process.env, so any secret in the parent environment is visible to the command.
    • A timeout sends SIGKILL to the spawned shell; processes it forked itself may survive, and anything they write after the kill is not captured. On Windows such a survivor also keeps the working directory locked, so a close following a timeout can fail to remove a temporary workspace.
    • File paths are confined to the working directory by a lexical check only (see readFile and writeFile).

    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 working directory.

      filePath is confined to the working directory by a lexical check on the resolved path, which is not a sandbox.

      Parameters

      • filePath: string

      Returns Promise<Uint8Array<ArrayBufferLike>>

      If the environment is not initialized, if the path escapes the working directory, or — as ENOENT — if the file does not exist.

    • Writes a file in the working directory, creating parent directories.

      filePath is confined to the working directory by a lexical check on the resolved path, which is not a sandbox. No newline translation is applied, so explicit CRLF sequences are preserved.

      Parameters

      • filePath: string
      • content: string | Uint8Array<ArrayBufferLike>

      Returns Promise<void>

      If the environment is not initialized or the path escapes the working directory.