Environment

A workspace where an agent can run shell commands and read and write files.

execute, readFile and writeFile take the caller's Context, so one instance can keep a separate workspace per session and persist what identifies it with Context.updateState; they may run concurrently, and this interface does no synchronization. Call initialize before first use and close when done.

Inheritors

Functions

Link copied to clipboard
open override fun close()

Releases resources held by the environment.

Link copied to clipboard
abstract suspend fun execute(context: Context, command: String, timeout: Duration? = null): Result<ExecutionResult>

Executes a shell command in the calling session's workspace.

Link copied to clipboard
open suspend fun initialize()

Prepares resources shared by all sessions, such as a local directory or a client connection.

Link copied to clipboard
abstract suspend fun readFile(context: Context, path: String): Result<ByteArray>

Reads a file from the calling session's workspace.

Link copied to clipboard
abstract suspend fun writeFile(context: Context, path: String, content: ByteArray): Result<Unit>

Writes a file in the calling session's workspace, creating missing parent directories.