环境

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

函数

Link copied to clipboard
open override fun close()

释放环境所持有的资源。

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

在调用会话的工作空间中执行 shell 命令。

Link copied to clipboard
open suspend fun initialize()

准备所有会话共用的资源,例如本地目录或客户端连接。

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

从调用该函数的会话的工作区中读取一个文件。

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

在调用该函数的会话的工作区中写入文件;如果需要的话,系统会自动创建缺失的父目录。