Interface SandboxFileTransfer
- All Known Implementing Classes:
DockerSandbox
public interface SandboxFileTransfer
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, SandboxBackedFilesystem prefers it over the
default transfer strategy of embedding base64 payloads in shell commands sent through
Sandbox.exec(io.agentscope.core.agent.RuntimeContext, java.lang.String, java.lang.Integer). 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(java.lang.String) lets
the backend accept or decline each path, with declined paths handled by the exec strategy.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]downloadFile(String path) Reads a file from the sandbox.booleansupportsFileTransfer(String path) Whether this sandbox can natively transfer the given path.voiduploadFile(String path, byte[] content) Writes a file inside the sandbox, creating parent directories if needed.
-
Method Details
-
supportsFileTransfer
Whether this sandbox can natively transfer the given path.- Parameters:
path- path to probe — absolute inside the sandbox; implementations may also accept forms they can resolve themselves (e.g. workspace-relative paths)- Returns:
- true if
uploadFile(java.lang.String, byte[])/downloadFile(java.lang.String)accept this path
-
uploadFile
Writes a file inside the sandbox, creating parent directories if needed.- Parameters:
path- destination path inside the sandbox — absolute, or a form the implementation resolvescontent- file bytes- Throws:
Exception- when the transfer fails; unlike a declined path, a failed transfer is not retried through the exec strategy
-
downloadFile
Reads a file from the sandbox.- Parameters:
path- path inside the sandbox — absolute, or a form the implementation resolves- Returns:
- file bytes
- Throws:
Exception- when the transfer fails; unlike a declined path, a failed transfer is not retried through the exec strategy
-