AS AgentScopeAPI 手册 / API Reference

FilesystemSandbox

@RegisterSandbox( imageName = "agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-filesystem:latest", sandboxType = "filesystem", securityLevel = "medium", timeout = 60, description = "Filesystem sandbox" ) public class FilesystemSandbox extends Sandbox
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:27–165

文件系统沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.box 包,继承自 Sandbox。核心成员包括 getDesktopUrl、readFile、readMultipleFiles、writeFile、editFile、createDirectory。

A class in io.agentscope.runtime.sandbox.box that deploys, schedules and serves agents. Declared in io.agentscope.runtime.sandbox.box. Extends Sandbox.

构造器摘要Constructor Summary

构造器Constructor说明Description
public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId)
初始化 `FilesystemSandbox` 实例。
Creates a new instance.
public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl)
初始化 `FilesystemSandbox` 实例。
Creates a new instance.
public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig)
初始化 `FilesystemSandbox` 实例。
Creates a new instance.
public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, Map<String, String> environment)
初始化 `FilesystemSandbox` 实例。
Creates a new instance.
public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl, FileSystemConfig fileSystemConfig, Map<String, String> environment)
初始化 `FilesystemSandbox` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String getDesktopUrl()
获取 `getDesktopUrl`。
Get the desktop URL for VNC access.
public String readFile(String path)
设置读取文件。
Performs the read file operation.
public String readMultipleFiles(List<String> paths)
设置该参数。
Performs the read multiple files operation.
public String writeFile(String path, String content)
执行写入文件相关操作。
Performs the write file operation.
public String editFile(String path, Object[] edits)
执行 `editFile` 方法。
Performs the edit file operation.
public String editFile(String path, Object[] edits, boolean dryRun)
执行 `editFile` 方法。
Performs the edit file operation.
public String createDirectory(String path)
创建目录。
Creates the directory.
public String listDirectory(String path)
列出目录。
Lists the directory.
public String directoryTree(String path)
设置目录树。
Performs the directory tree operation.
public String moveFile(String source, String destination)
执行 `moveFile` 方法。
Performs the move file operation.
public String searchFiles(String path, String pattern)
搜索文件。
Searches the files.
public String searchFiles(String path, String pattern, String[] excludePatterns)
搜索文件。
Searches the files.
public String getFileInfo(String path)
获取文件信息。
Returns the file info.
public String listAllowedDirectories()
列出 `listAllowedDirectories`。
Lists the allowed directories.

构造器详情Constructor Detail

FilesystemSandbox

public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId)

初始化 FilesystemSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:38–40

FilesystemSandbox

public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl)

初始化 FilesystemSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
baseUrlString基类 URL(类型 `String`)。The base url.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:42–48

FilesystemSandbox

public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig)

初始化 FilesystemSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:50–56

FilesystemSandbox

public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, Map<String, String> environment)

初始化 FilesystemSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
environmentMap<String, String>环境(类型 `Map`)。The environment.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:58–64

FilesystemSandbox

public FilesystemSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl, FileSystemConfig fileSystemConfig, Map<String, String> environment)

初始化 FilesystemSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
baseUrlString基类 URL(类型 `String`)。The base url.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
environmentMap<String, String>环境(类型 `Map`)。The environment.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:66–75

方法详情Method Detail

getDesktopUrl

public String getDesktopUrl()

获取 getDesktopUrl。

Get the desktop URL for VNC access.

返回Returns String
返回字符串结果。The desktop URL for VNC access
抛出Throws
  • RuntimeException 可能抛出 `RuntimeException`。if sandbox is not healthy
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:84–86

readFile

public String readFile(String path)

设置读取文件。

Performs the read file operation.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:88–92

readMultipleFiles

public String readMultipleFiles(List<String> paths)

设置该参数。

Performs the read multiple files operation.

参数Parameters
名称Name类型Type说明Description
pathsList<String>paths(类型 `List`)。The paths.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:94–98

writeFile

public String writeFile(String path, String content)

执行写入文件相关操作。

Performs the write file operation.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
contentString内容(类型 `String`)。The content.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:100–105

editFile

public String editFile(String path, Object[] edits)

执行 editFile 方法。

Performs the edit file operation.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
editsObject[]edits(类型 `Object[]`)。The edits.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:107–109

editFile

public String editFile(String path, Object[] edits, boolean dryRun)

执行 editFile 方法。

Performs the edit file operation.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
editsObject[]edits(类型 `Object[]`)。The edits.
dryRunbooleandry 运行(类型 `boolean`)。The dry run.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:111–117

createDirectory

public String createDirectory(String path)

创建目录。

Creates the directory.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:119–123

listDirectory

public String listDirectory(String path)

列出目录。

Lists the directory.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:125–129

directoryTree

public String directoryTree(String path)

设置目录树。

Performs the directory tree operation.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:131–135

moveFile

public String moveFile(String source, String destination)

执行 moveFile 方法。

Performs the move file operation.

参数Parameters
名称Name类型Type说明Description
sourceString来源(类型 `String`)。The source.
destinationString目标地址(类型 `String`)。The destination.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:137–142

searchFiles

public String searchFiles(String path, String pattern)

搜索文件。

Searches the files.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
patternStringpattern(类型 `String`)。The pattern.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:144–146

searchFiles

public String searchFiles(String path, String pattern, String[] excludePatterns)

搜索文件。

Searches the files.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
patternStringpattern(类型 `String`)。The pattern.
excludePatternsString[]exclude Patterns(类型 `String[]`)。The exclude patterns.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:148–154

getFileInfo

public String getFileInfo(String path)

获取文件信息。

Returns the file info.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:156–160

listAllowedDirectories

public String listAllowedDirectories()

列出 listAllowedDirectories。

Lists the allowed directories.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/FilesystemSandbox.java:162–164

继承成员Inherited Members

基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.