Class KubernetesSandbox

java.lang.Object
io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
io.agentscope.extensions.sandbox.kubernetes.KubernetesSandbox
All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.Sandbox, io.agentscope.harness.agent.sandbox.SandboxFileTransfer, AutoCloseable

public class KubernetesSandbox extends io.agentscope.harness.agent.sandbox.AbstractBaseSandbox implements io.agentscope.harness.agent.sandbox.SandboxFileTransfer
Harness Sandbox backed by an agent-sandbox CRD via the Java client SDK.

Assumes the runtime image conforms to the AgentScope runtime contract (see the sandbox documentation): POST /execute interprets the command with a POSIX shell, and the file API (/upload / /download) is rooted at a known base directory.

Workspace archives (persist / hydrate) are transferred through the runtime file API (files().read() / files().write()) when fileApiBaseDir is configured; when it is blank, transfers fall back to base64 payloads over exec. Single-file transfers requested by the harness filesystem (SandboxFileTransfer) also go through the file API for paths under fileApiBaseDir.

  • Constructor Details

  • Method Details

    • shutdown

      public void shutdown() throws Exception
      Specified by:
      shutdown in interface io.agentscope.harness.agent.sandbox.Sandbox
      Throws:
      Exception
    • doExec

      protected io.agentscope.harness.agent.sandbox.ExecResult doExec(io.agentscope.core.agent.RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception
      Specified by:
      doExec in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • doPersistWorkspace

      protected InputStream doPersistWorkspace() throws Exception
      Specified by:
      doPersistWorkspace in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • doHydrateWorkspace

      protected void doHydrateWorkspace(InputStream archive) throws Exception
      Specified by:
      doHydrateWorkspace in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • doSetupWorkspace

      protected void doSetupWorkspace() throws Exception
      Specified by:
      doSetupWorkspace in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • doDestroyWorkspace

      protected void doDestroyWorkspace() throws Exception
      Specified by:
      doDestroyWorkspace in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • getWorkspaceRoot

      protected String getWorkspaceRoot()
      Specified by:
      getWorkspaceRoot in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
    • getSdkSandbox

      public Sandbox getSdkSandbox()
      Returns the underlying SDK sandbox handle.
      Returns:
      SDK sandbox
    • supportsFileTransfer

      public boolean supportsFileTransfer(String absolutePath)
      Specified by:
      supportsFileTransfer in interface io.agentscope.harness.agent.sandbox.SandboxFileTransfer
    • uploadFile

      public void uploadFile(String absolutePath, byte[] content) throws Exception
      Specified by:
      uploadFile in interface io.agentscope.harness.agent.sandbox.SandboxFileTransfer
      Throws:
      Exception
    • downloadFile

      public byte[] downloadFile(String absolutePath) throws Exception
      Specified by:
      downloadFile in interface io.agentscope.harness.agent.sandbox.SandboxFileTransfer
      Throws:
      Exception