DaytonaSandbox
public class DaytonaSandbox extends AbstractBaseSandbox
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:33–208Daytona 沙箱,在隔离环境中安全执行代码和工具。位于 io.agentscope.extensions.sandbox.daytona 包,继承自 AbstractBaseSandbox。核心成员包括 start、shutdown、doExec、doPersistWorkspace、doHydrateWorkspace、doSetupWorkspace。
io.agentscope.harness.agent.sandbox.Sandbox backed by Daytona cloud sandboxes.
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public DaytonaSandbox(DaytonaSandboxState state, DaytonaHttp http) | 初始化 `DaytonaSandbox` 实例。 Creates a new instance. |
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public void start() throws Exception | 执行启动相关操作。 Returns the start. |
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
DaytonaSandbox
public DaytonaSandbox(DaytonaSandboxState state, DaytonaHttp http)
初始化 DaytonaSandbox 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | DaytonaSandboxState | 状态对象(类型 `DaytonaSandboxState`)。The state. |
http | DaytonaHttp | HTTP(类型 `DaytonaHttp`)。The http. |
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:44–48方法详情Method Detail
start
public void start() throws Exception
执行启动相关操作。
Returns the start.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:50–59shutdown
public void shutdown() throws Exception
关闭资源并释放连接。
Releases resources and connections.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:61–70doExec
protected ExecResult doExec(RuntimeContext runtimeContext, String command, int timeoutSeconds) throws Exception
执行 doExec 回调。
Performs the do exec operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
command | String | 命令(类型 `String`)。The command. |
timeoutSeconds | int | 超时秒(类型 `int`)。The timeout seconds. |
ExecResult返回ExecResult。Returns exec result.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:72–92doPersistWorkspace
protected InputStream doPersistWorkspace() throws Exception
执行 doPersistWorkspace 回调。
Returns the do persist workspace.
InputStream返回InputStream。Returns input stream.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:94–110doHydrateWorkspace
protected void doHydrateWorkspace(InputStream archive) throws Exception
执行 doHydrateWorkspace 回调。
Performs the do hydrate workspace operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
archive | InputStream | 归档(类型 `InputStream`)。The archive. |
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:112–155doSetupWorkspace
protected void doSetupWorkspace() throws Exception
执行 doSetupWorkspace 回调。
Returns the do setup workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:157–160doDestroyWorkspace
protected void doDestroyWorkspace() throws Exception
执行 doDestroyWorkspace 回调。
Returns the do destroy workspace.
Exception可能抛出 `Exception`。Thrown when the operation cannot be completed.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:162–169getWorkspaceRoot
protected String getWorkspaceRoot()
获取工作区根。
Returns the workspace root.
String返回字符串结果。Returns a string.
源码Source
io/agentscope/extensions/sandbox/daytona/DaytonaSandbox.java:171–174