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 Type
    Method
    Description
    byte[]
    Reads a file from the sandbox.
    boolean
    Whether this sandbox can natively transfer the given path.
    void
    uploadFile(String path, byte[] content)
    Writes a file inside the sandbox, creating parent directories if needed.
  • Method Details

    • supportsFileTransfer

      boolean supportsFileTransfer(String path)
      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

      void uploadFile(String path, byte[] content) throws Exception
      Writes a file inside the sandbox, creating parent directories if needed.
      Parameters:
      path - destination path inside the sandbox — absolute, or a form the implementation resolves
      content - file bytes
      Throws:
      Exception - when the transfer fails; unlike a declined path, a failed transfer is not retried through the exec strategy
    • downloadFile

      byte[] downloadFile(String path) throws Exception
      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