SandboxFileTransfer
public interface SandboxFileTransfer
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.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。path to probe — absolute inside the sandbox; implementations may also accept forms they can resolve themselves (e.g. workspace-relative paths) |
booleanio/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:42uploadFile
public void uploadFile(String path, byte[] content) throws Exception
执行上传文件相关操作。
Writes a file inside the sandbox, creating parent directories if needed.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。destination path inside the sandbox — absolute, or a form the implementation resolves |
content | byte[] | 内容(类型 `byte[]`)。file bytes |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:53downloadFile
public byte[] downloadFile(String path) throws Exception
设置下载文件。
Reads a file from the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
path | String | 路径(类型 `String`)。path inside the sandbox — absolute, or a form the implementation resolves |
byte[]Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/harness/agent/sandbox/SandboxFileTransfer.java:63