Class E2bSandbox

java.lang.Object
io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
io.agentscope.extensions.sandbox.e2b.E2bSandbox
All Implemented Interfaces:
io.agentscope.harness.agent.sandbox.Sandbox, AutoCloseable

public class E2bSandbox extends io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
Sandbox backed by E2B cloud sandboxes.

Execution uses envd process.Process/Start over HTTPS (Connect+protobuf). Workspace tar is streamed as binary stdout for E2bPersistenceMode.TAR; E2bPersistenceMode.NATIVE_SNAPSHOT uses the platform snapshot API and E2bSnapshotRefs marker bytes in the Harness snapshot stream.

  • Constructor Details

  • Method Details

    • start

      public void start() throws Exception
      Specified by:
      start in interface io.agentscope.harness.agent.sandbox.Sandbox
      Overrides:
      start in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • stop

      public void stop() throws Exception

      A failed workspace persist must not leave its snapshot id in E2bSandboxState.getSnapshotIds(): the persisted archive still references the previous snapshot, and a record holding the newer id as well would make cleanupSnapshots() delete the snapshot that archive restores from. The id is therefore removed by identity, not by position — the record is shared state, and ids another session appended meanwhile are not this call's to drop. The exception is re-thrown unchanged: SandboxManager.release swallows it and the caller persists the state afterwards, so the corrected record still reaches the store.

      Specified by:
      stop in interface io.agentscope.harness.agent.sandbox.Sandbox
      Overrides:
      stop in class io.agentscope.harness.agent.sandbox.AbstractBaseSandbox
      Throws:
      Exception
    • shutdown

      public void shutdown() throws Exception
      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