AS AgentScopeAPI 手册 / API Reference

SandboxFileTransfer

public interface SandboxFileTransfer
源码Source io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:33–64

定义沙箱文件 Transfer契约的接口。位于 io.agentscope.harness.agent.sandbox 包。核心成员包括 supportsFileTransfer、uploadFile、downloadFile。

Optional capability for Sandbox backends that support native (non-exec) file transfer, e.g. a dedicated HTTP upload/download API exposed by the sandbox runtime.

When a sandbox implements this interface, io.agentscope.harness.agent.filesystem.sandbox.SandboxBackedFilesystem prefers it over the default transfer strategy of embedding base64 payloads in shell commands sent through Sandbox#exec. Native transfer avoids base64 inflation and per-argument command-line length limits (about 128 KiB per argument on Linux), which the exec strategy hits for large files.

Backends typically support native transfer only for a subtree of the sandbox filesystem (e.g. paths under the runtime file API base directory); #supportsFileTransfer lets the backend accept or decline each path, with declined paths handled by the exec strategy.

方法摘要Method Summary

方法Method说明Description
public boolean supportsFileTransfer(String path)
设置该参数。
Whether this sandbox can natively transfer the given path.
public void uploadFile(String path, byte[] content) throws Exception
执行上传文件相关操作。
Writes a file inside the sandbox, creating parent directories if needed.
public byte[] downloadFile(String path) throws Exception
设置下载文件。
Reads a file from the sandbox.

方法详情Method Detail

supportsFileTransfer

public boolean supportsFileTransfer(String path)

设置该参数。

Whether this sandbox can natively transfer the given path.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。path to probe — absolute inside the sandbox; implementations may also accept forms they can resolve themselves (e.g. workspace-relative paths)
返回Returns boolean
返回布尔值,表示判断结果。true if `#uploadFile` / `#downloadFile` accept this path
源码Source io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:42

uploadFile

public void uploadFile(String path, byte[] content) throws Exception

执行上传文件相关操作。

Writes a file inside the sandbox, creating parent directories if needed.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。destination path inside the sandbox — absolute, or a form the implementation resolves
contentbyte[]内容(类型 `byte[]`)。file bytes
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:53

downloadFile

public byte[] downloadFile(String path) throws Exception

设置下载文件。

Reads a file from the sandbox.

参数Parameters
名称Name类型Type说明Description
pathString路径(类型 `String`)。path inside the sandbox — absolute, or a form the implementation resolves
返回Returns byte[]
返回byte[]。file bytes
抛出Throws
  • Exception 可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:63
基于官方固定版本源码静态生成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.