/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { BaseEnvironment, ExecutionResult } from './base_environment.js'; /** Options for {@link LocalEnvironment}. */ export interface LocalEnvironmentOptions { /** * Absolute path to the workspace directory. Created by * {@link LocalEnvironment.initialize} if it does not exist, and never deleted * by {@link LocalEnvironment.close}. If omitted, a temporary directory is * created on `initialize()` and removed on `close()`. */ workingDir?: string; /** Extra variables merged over `process.env` for every executed command. */ envVars?: Record; } /** * Executes commands via local child processes, scoped to a working directory. * * When `workingDir` is not specified, a temporary directory is created on * {@link initialize} and removed on {@link 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 * {@link 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 {@link readFile} and {@link writeFile}). */ export declare class LocalEnvironment extends BaseEnvironment { private currentWorkingDir?; private readonly envVars?; private autoCreated; constructor(options?: LocalEnvironmentOptions); get workingDir(): string; initialize(): Promise; close(): Promise; execute(command: string, timeoutSeconds?: number): Promise; /** * 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. * * @throws If the environment is not initialized, if the path escapes the * working directory, or — as `ENOENT` — if the file does not exist. */ readFile(filePath: string): Promise; /** * 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. * * @throws If the environment is not initialized or the path escapes the * working directory. */ writeFile(filePath: string, content: string | Uint8Array): Promise; }