AS AgentScopeAPI 手册 / API Reference

KubernetesSandboxClient

public class KubernetesSandboxClient implements io.agentscope.harness.agent.sandbox.SandboxClient< KubernetesSandboxClientOptions>
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:48–320

Kubernetes 沙箱客户端,封装与远端服务的连接和调用。位于 io.agentscope.extensions.sandbox.kubernetes 包,实现 io.agentscope.harness.agent.sandbox.SandboxClient<KubernetesSandboxClientOptions>。核心成员包括 create、resume、delete、serializeState、deserializeState、toConnectionConfig。

Harness io.agentscope.harness.agent.sandbox.SandboxClient for agent-sandbox backed Kubernetes sandboxes.

Delegates lifecycle and transport to the Java agent-sandbox client SDK (SandboxClient).

构造器摘要Constructor Summary

构造器Constructor说明Description
public KubernetesSandboxClient()
初始化 `KubernetesSandboxClient` 实例。
Creates a new instance.
public KubernetesSandboxClient(KubernetesSandboxClientOptions defaultOptions)
初始化 `KubernetesSandboxClient` 实例。
Creates a new instance.
public KubernetesSandboxClient(KubernetesSandboxClientOptions defaultOptions, ObjectMapper objectMapper)
初始化 `KubernetesSandboxClient` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Sandbox create(WorkspaceSpec workspaceSpec, SandboxSnapshotSpec snapshotSpec, KubernetesSandboxClientOptions options)
创建并返回实例。
Creates and returns an instance.
public Sandbox resume(SandboxState state)
设置恢复。
Performs the resume operation.
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.
public SandboxState deserializeState(String json, SandboxSnapshotSpec snapshotSpec)
执行状态。
Restores the runtime storage client omitted from remote snapshot JSON while keeping the persisted archive id.
public static SandboxConnectionConfig toConnectionConfig(KubernetesSandboxClientOptions opts)
static
设置到连接配置。
Maps harness options to an SDK connection config.

构造器详情Constructor Detail

KubernetesSandboxClient

public KubernetesSandboxClient()

初始化 KubernetesSandboxClient 实例。

Creates a new instance.

源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:57–59

KubernetesSandboxClient

public KubernetesSandboxClient(KubernetesSandboxClientOptions defaultOptions)

初始化 KubernetesSandboxClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
defaultOptionsKubernetesSandboxClientOptions默认选项(类型 `KubernetesSandboxClientOptions`)。The default options.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:61–63

KubernetesSandboxClient

public KubernetesSandboxClient(KubernetesSandboxClientOptions defaultOptions, ObjectMapper objectMapper)

初始化 KubernetesSandboxClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
defaultOptionsKubernetesSandboxClientOptions默认选项(类型 `KubernetesSandboxClientOptions`)。template options merged into each `#create` call
objectMapperObjectMapper对象 Mapper(类型 `ObjectMapper`)。optional mapper; when null a default mapper is created with harness and Kubernetes Jackson modules
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:70–81

方法详情Method Detail

create

public Sandbox create(WorkspaceSpec workspaceSpec, SandboxSnapshotSpec snapshotSpec, KubernetesSandboxClientOptions options)

创建并返回实例。

Creates and returns an instance.

参数Parameters
名称Name类型Type说明Description
workspaceSpecWorkspaceSpec工作区规格(类型 `WorkspaceSpec`)。The workspace spec.
snapshotSpecSandboxSnapshotSpec快照规格(类型 `SandboxSnapshotSpec`)。The snapshot spec.
optionsKubernetesSandboxClientOptions选项(类型 `KubernetesSandboxClientOptions`)。The options.
返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:83–146

resume

public Sandbox resume(SandboxState state)

设置恢复。

Performs the resume operation.

参数Parameters
名称Name类型Type说明Description
stateSandboxState状态对象(类型 `SandboxState`)。The state.
返回Returns Sandbox
返回沙箱。Returns sandbox.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:148–166

delete

public void delete(Sandbox sandbox)

删除数据。

Performs the delete operation.

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:168–171

serializeState

public String serializeState(SandboxState state)

执行状态。

Performs the serialize state operation.

参数Parameters
名称Name类型Type说明Description
stateSandboxState状态对象(类型 `SandboxState`)。The state.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:173–181

deserializeState

public SandboxState deserializeState(String json)

执行状态。

Performs the deserialize state operation.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
返回Returns SandboxState
返回SandboxState。Returns sandbox state.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:183–191

deserializeState

public SandboxState deserializeState(String json, SandboxSnapshotSpec snapshotSpec)

执行状态。

Restores the runtime storage client omitted from remote snapshot JSON while keeping the persisted archive id.

参数Parameters
名称Name类型Type说明Description
jsonStringJSON(类型 `String`)。The json.
snapshotSpecSandboxSnapshotSpec快照规格(类型 `SandboxSnapshotSpec`)。The snapshot spec.
返回Returns SandboxState
返回SandboxState。Returns sandbox state.
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:198–206

toConnectionConfig

public static SandboxConnectionConfig toConnectionConfig(KubernetesSandboxClientOptions opts)
static

设置到连接配置。

Maps harness options to an SDK connection config.

参数Parameters
名称Name类型Type说明Description
optsKubernetesSandboxClientOptionsopts(类型 `KubernetesSandboxClientOptions`)。harness options
返回Returns SandboxConnectionConfig
返回SandboxConnectionConfig。SDK connection config
源码Source io/agentscope/extensions/sandbox/kubernetes/KubernetesSandboxClient.java:224–245
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.