AS AgentScopeAPI 手册 / API Reference

Filesystem

public class Filesystem
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:34–316

文件系统,在隔离环境中安全执行代码和工具。位于 io.agentscope.extensions.sandbox.kubernetes.client 包。核心成员包括 write、read、list、exists、Filesystem。

File operations inside a sandbox via the runtime HTTP API.

构造器摘要Constructor Summary

构造器Constructor说明Description
public Filesystem(SandboxConnector connector)
初始化 `Filesystem` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void write(String path, byte[] content)
执行写入相关操作。
Writes content to a file in the sandbox.
public void write(String path, byte[] content, Duration timeout, boolean allowUnsafePaths)
执行写入相关操作。
Writes content to a file in the sandbox.
public void write(String path, String content)
执行写入相关操作。
Writes string content (UTF-8) to a file in the sandbox.
public byte[] read(String path)
设置读取。
Reads a file from the sandbox.
public byte[] read(String path, Duration timeout, boolean allowUnsafePaths)
执行读取相关操作。
Reads a file from the sandbox.
public List<FileEntry> list(String path)
设置列表。
Lists entries in a directory.
public List<FileEntry> list(String path, Duration timeout)
执行列表相关操作。
Lists entries in a directory.
public boolean exists(String path)
判断数据是否存在。
Checks whether a path exists in the sandbox.
public boolean exists(String path, Duration timeout)
判断数据是否存在。
Checks whether a path exists in the sandbox.

构造器详情Constructor Detail

Filesystem

public Filesystem(SandboxConnector connector)

初始化 Filesystem 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
connectorSandboxConnectorconnector(类型 `SandboxConnector`)。The connector.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:41–43

方法详情Method Detail

write

public void write(String path, byte[] content)

执行写入相关操作。

Writes content to a file in the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。relative destination path
contentbyte[]内容(类型 `byte[]`)。file bytes
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:51–53

write

public void write(String path, byte[] content, Duration timeout, boolean allowUnsafePaths)

执行写入相关操作。

Writes content to a file in the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。destination path
contentbyte[]内容(类型 `byte[]`)。file bytes
timeoutDuration超时时间(类型 `Duration`)。request timeout
allowUnsafePathsbooleanallow Unsafe Paths(类型 `boolean`)。when false, rejects absolute paths and `..`
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:63–88

write

public void write(String path, String content)

执行写入相关操作。

Writes string content (UTF-8) to a file in the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。relative destination path
contentString内容(类型 `String`)。text content
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:96–98

read

public byte[] read(String path)

设置读取。

Reads a file from the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。file path
返回Returns byte[]
返回byte[]。file bytes
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:106–108

read

public byte[] read(String path, Duration timeout, boolean allowUnsafePaths)

执行读取相关操作。

Reads a file from the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。file path
timeoutDuration超时时间(类型 `Duration`)。request timeout
allowUnsafePathsbooleanallow Unsafe Paths(类型 `boolean`)。when false, rejects absolute paths and `..`
返回Returns byte[]
返回byte[]。file bytes
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:118–136

list

public List<FileEntry> list(String path)

设置列表。

Lists entries in a directory.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。directory path
返回Returns List<FileEntry>
返回列出。file entries
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:144–146

list

public List<FileEntry> list(String path, Duration timeout)

执行列表相关操作。

Lists entries in a directory.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。directory path
timeoutDuration超时时间(类型 `Duration`)。request timeout
返回Returns List<FileEntry>
返回列出。file entries
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:155–176

exists

public boolean exists(String path)

判断数据是否存在。

Checks whether a path exists in the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。path to check
返回Returns boolean
返回布尔值,表示判断结果。true if exists
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:184–186

exists

public boolean exists(String path, Duration timeout)

判断数据是否存在。

Checks whether a path exists in the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。path to check
timeoutDuration超时时间(类型 `Duration`)。request timeout
返回Returns boolean
返回布尔值,表示判断结果。true if exists
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Filesystem.java:195–213
基于官方固定版本源码静态生成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.