SandboxClient
public interface SandboxClient<O extends SandboxClientOptions>
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:25–48定义沙箱客户端契约的接口。位于 io.agentscope.harness.agent.sandbox 包。核心成员包括 create、resume、delete、serializeState、deserializeState。
Factory for creating and resuming Sandbox instances.
方法摘要Method Summary
| 方法Method | 说明Description |
|---|---|
public Sandbox create(WorkspaceSpec workspaceSpec, SandboxSnapshotSpec snapshotSpec, O options) | 创建并返回实例。 Creates a new sandbox with the given workspace spec and snapshot spec. |
public Sandbox resume(SandboxState state) | 设置恢复。 Resumes a sandbox from previously serialized `SandboxState`. |
public void delete(Sandbox sandbox) | 删除数据。 Performs the delete operation. |
public String serializeState(SandboxState state) | 执行状态。 Performs the serialize state operation. |
public SandboxState deserializeState(String json) | 执行状态。 Performs the deserialize state operation. |
default public SandboxState deserializeState(String json, SandboxSnapshotSpec snapshotSpec)default | 执行状态。 Performs the deserialize state operation. |
方法详情Method Detail
create
public Sandbox create(WorkspaceSpec workspaceSpec, SandboxSnapshotSpec snapshotSpec, O options)
创建并返回实例。
Creates a new sandbox with the given workspace spec and snapshot spec.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
workspaceSpec | WorkspaceSpec | 工作区规格(类型 `WorkspaceSpec`)。The workspace spec. |
snapshotSpec | SandboxSnapshotSpec | 快照规格(类型 `SandboxSnapshotSpec`)。The snapshot spec. |
options | O | 选项(类型 `O`)。The options. |
Sandbox返回沙箱。Returns sandbox.
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:32resume
public Sandbox resume(SandboxState state)
设置恢复。
Resumes a sandbox from previously serialized SandboxState.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | SandboxState | 状态对象(类型 `SandboxState`)。The state. |
Sandbox返回沙箱。Returns sandbox.
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:37delete
public void delete(Sandbox sandbox)
删除数据。
Performs the delete operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandbox | Sandbox | 沙箱(类型 `Sandbox`)。The sandbox. |
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:39serializeState
public String serializeState(SandboxState state)
执行状态。
Performs the serialize state operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
state | SandboxState | 状态对象(类型 `SandboxState`)。The state. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:41deserializeState
public SandboxState deserializeState(String json)
执行状态。
Performs the deserialize state operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
json | String | JSON(类型 `String`)。The json. |
SandboxState返回SandboxState。Returns sandbox state.
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:43deserializeState
default public SandboxState deserializeState(String json, SandboxSnapshotSpec snapshotSpec)
default
执行状态。
Performs the deserialize state operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
json | String | JSON(类型 `String`)。The json. |
snapshotSpec | SandboxSnapshotSpec | 快照规格(类型 `SandboxSnapshotSpec`)。The snapshot spec. |
SandboxState返回SandboxState。Returns sandbox state.
源码Source
io/agentscope/harness/agent/sandbox/SandboxClient.java:45–47