E2bSandbox
public class E2bSandbox extends AbstractBaseSandbox
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:42–316E 2 b 沙箱,在隔离环境中安全执行代码和工具。位于 io.agentscope.extensions.sandbox.e2b 包,继承自 AbstractBaseSandbox。核心成员包括 start、stop、shutdown、doExec、doPersistWorkspace、doHydrateWorkspace。
io.agentscope.harness.agent.sandbox.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 Summary
| 构造器Constructor | 说明Description |
|---|---|
public E2bSandbox(E2bSandboxState state, E2bSandboxClientOptions opt) | 初始化 `E2bSandbox` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void start() throws Exception | 执行启动相关操作。 Returns the start. |
public void stop() throws Exception | 执行停止相关操作。 {@inheritDoc} |
public void shutdown() throws Exception | 关闭资源并释放连接。 Releases resources and connections. |
protected ExecResult doExec(RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception | 执行 `doExec` 回调。 Performs the do exec operation. |
protected InputStream doPersistWorkspace() throws Exception | 执行 `doPersistWorkspace` 回调。 Returns the do persist workspace. |
protected void doHydrateWorkspace(InputStream archive) throws Exception | 执行 `doHydrateWorkspace` 回调。 Performs the do hydrate workspace operation. |
protected void doSetupWorkspace() throws Exception | 执行 `doSetupWorkspace` 回调。 Returns the do setup workspace. |
protected void doDestroyWorkspace() throws Exception | 执行 `doDestroyWorkspace` 回调。 Returns the do destroy workspace. |
protected String getWorkspaceRoot() | 获取工作区根。 Returns the workspace root. |
构造器详情Constructor Detail
E2bSandbox
public E2bSandbox(E2bSandboxState state, E2bSandboxClientOptions opt)
初始化 E2bSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | E2bSandboxState | 状态对象(类型 `E2bSandboxState`)。The state. |
opt | E2bSandboxClientOptions | opt(类型 `E2bSandboxClientOptions`)。The opt. |
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:62–67方法详情Method Detail
start
public void start() throws Exception
执行启动相关操作。
Returns the start.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:69–78stop
public void stop() throws Exception
执行停止相关操作。
{@inheritDoc} 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 archiv…
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:92–109shutdown
public void shutdown() throws Exception
关闭资源并释放连接。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:111–123doExec
protected ExecResult doExec(RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception
执行 doExec 回调。
Performs the do exec operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | int | 超时秒(类型 `int`)。The timeout seconds. |
ExecResultException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:125–129doPersistWorkspace
protected InputStream doPersistWorkspace() throws Exception
执行 doPersistWorkspace 回调。
Returns the do persist workspace.
InputStreamException可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:131–155doHydrateWorkspace
protected void doHydrateWorkspace(InputStream archive) throws Exception
执行 doHydrateWorkspace 回调。
Performs the do hydrate workspace operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
archive | InputStream | 归档(类型 `InputStream`)。The archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:157–188doSetupWorkspace
protected void doSetupWorkspace() throws Exception
执行 doSetupWorkspace 回调。
Returns the do setup workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:190–197doDestroyWorkspace
protected void doDestroyWorkspace() throws Exception
执行 doDestroyWorkspace 回调。
Returns the do destroy workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
io/agentscope/extensions/sandbox/e2b/E2bSandbox.java:199–210getWorkspaceRoot
protected String getWorkspaceRoot()
获取工作区根。
Returns the workspace root.
Stringio/agentscope/extensions/sandbox/e2b/E2bSandbox.java:212–215