AS AgentScopeAPI 手册 / API Reference

SandboxClient

public class SandboxClient implements AutoCloseable
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:43–375

沙箱客户端,封装与远端服务的连接和调用。位于 io.agentscope.extensions.sandbox.kubernetes.client 包,实现 AutoCloseable。核心成员包括 createSandbox、getSandbox、listActiveSandboxes、listAllSandboxes、deleteSandbox、deleteAll。

Client for managing agent-sandbox lifecycles.

Mirrors the Python SDK's SandboxClient: creates SandboxClaims against a warm pool, waits for readiness, and returns Sandbox handles for command / file operations.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SandboxClient()
初始化 `SandboxClient` 实例。
Creates a new instance.
public SandboxClient(SandboxConnectionConfig connectionConfig)
初始化 `SandboxClient` 实例。
Creates a new instance.
public SandboxClient(SandboxConnectionConfig connectionConfig, KubernetesClient kubernetesClient)
初始化 `SandboxClient` 实例。
Creates a new instance.
public SandboxClient(SandboxConnectionConfig connectionConfig, KubernetesClient kubernetesClient, Duration requestTimeout, Duration perAttemptTimeout)
初始化 `SandboxClient` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public Sandbox createSandbox(CreateSandboxOptions options)
创建沙箱。
Creates a sandbox from the given options.
public Sandbox createSandbox(String warmPool)
创建沙箱。
Convenience overload matching the Python SDK signature.
public Sandbox createSandbox(String warmPool, String namespace)
创建沙箱。
Convenience overload with namespace.
public Sandbox getSandbox(String claimName, String namespace)
获取沙箱。
Re-attaches to an existing SandboxClaim.
public Sandbox getSandbox(String claimName, String namespace, long resolveTimeoutSeconds)
获取沙箱。
Re-attaches to an existing SandboxClaim.
public List<String> listActiveSandboxes()
列出 `listActiveSandboxes`。
Returns `(namespace, claimName)` pairs tracked by this client.
public List<String> listAllSandboxes(String namespace)
列出 `listAllSandboxes`。
Lists all SandboxClaim names in the cluster for the given namespace.
public List<String> listAllSandboxes(String namespace, String labelSelector)
列出 `listAllSandboxes`。
Lists SandboxClaim names, optionally filtered by label selector.
public void deleteSandbox(String claimName, String namespace)
删除沙箱。
Stops the client-side connection and deletes the Kubernetes claim.
public void deleteAll()
删除所有。
Deletes all sandboxes tracked by this client.
public String getSandboxClaimWarmPoolName(String claimName, String namespace)
获取 `getSandboxClaimWarmPoolName`。
Returns the warm pool name referenced by a claim.
public K8sHelper getK8sHelper()
获取 `getK8sHelper`。
Returns the k 8 s helper.
public SandboxConnectionConfig getConnectionConfig()
获取连接配置。
Returns the connection config.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.

构造器详情Constructor Detail

SandboxClient

public SandboxClient()

初始化 SandboxClient 实例。

Creates a new instance.

源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:54–56

SandboxClient

public SandboxClient(SandboxConnectionConfig connectionConfig)

初始化 SandboxClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
connectionConfigSandboxConnectionConfig连接配置(类型 `SandboxConnectionConfig`)。The connection config.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:58–60

SandboxClient

public SandboxClient(SandboxConnectionConfig connectionConfig, KubernetesClient kubernetesClient)

初始化 SandboxClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
connectionConfigSandboxConnectionConfig连接配置(类型 `SandboxConnectionConfig`)。The connection config.
kubernetesClientKubernetesClientKubernetes 客户端(类型 `KubernetesClient`)。The kubernetes client.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:62–65

SandboxClient

public SandboxClient(SandboxConnectionConfig connectionConfig, KubernetesClient kubernetesClient, Duration requestTimeout, Duration perAttemptTimeout)

初始化 SandboxClient 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
connectionConfigSandboxConnectionConfig连接配置(类型 `SandboxConnectionConfig`)。The connection config.
kubernetesClientKubernetesClientKubernetes 客户端(类型 `KubernetesClient`)。The kubernetes client.
requestTimeoutDuration请求超时(类型 `Duration`)。The request timeout.
perAttemptTimeoutDuration每个尝试超时(类型 `Duration`)。The per attempt timeout.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:67–83

方法详情Method Detail

createSandbox

public Sandbox createSandbox(CreateSandboxOptions options)

创建沙箱。

Creates a sandbox from the given options.

参数Parameters
名称Name类型Type说明Description
optionsCreateSandboxOptions创建选项。create options
返回Returns Sandbox
返回沙箱。sandbox handle
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:91–153

createSandbox

public Sandbox createSandbox(String warmPool)

创建沙箱。

Convenience overload matching the Python SDK signature.

参数Parameters
名称Name类型Type说明Description
warmPoolStringwarm 连接池(类型 `String`)。warm pool name
返回Returns Sandbox
返回沙箱。sandbox handle
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:161–163

createSandbox

public Sandbox createSandbox(String warmPool, String namespace)

创建沙箱。

Convenience overload with namespace.

参数Parameters
名称Name类型Type说明Description
warmPoolStringwarm 连接池(类型 `String`)。warm pool name
namespaceString命名空间(类型 `String`)。namespace
返回Returns Sandbox
返回沙箱。sandbox handle
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:172–174

getSandbox

public Sandbox getSandbox(String claimName, String namespace)

获取沙箱。

Re-attaches to an existing SandboxClaim.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。claim name
namespaceString命名空间(类型 `String`)。namespace
返回Returns Sandbox
返回沙箱。sandbox handle
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:183–185

getSandbox

public Sandbox getSandbox(String claimName, String namespace, long resolveTimeoutSeconds)

获取沙箱。

Re-attaches to an existing SandboxClaim.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。claim name
namespaceString命名空间(类型 `String`)。namespace
resolveTimeoutSecondslong解析超时秒(类型 `long`)。timeout for name resolution
返回Returns Sandbox
返回沙箱。sandbox handle
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:195–249

listActiveSandboxes

public List<String> listActiveSandboxes()

列出 listActiveSandboxes。

Returns (namespace, claimName) pairs tracked by this client.

返回Returns List<String>
返回列出。active sandbox keys as `namespace/claimName` strings
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:256–265

listAllSandboxes

public List<String> listAllSandboxes(String namespace)

列出 listAllSandboxes。

Lists all SandboxClaim names in the cluster for the given namespace.

参数Parameters
名称Name类型Type说明Description
namespaceString命名空间(类型 `String`)。namespace
返回Returns List<String>
返回列出。claim names
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:273–275

listAllSandboxes

public List<String> listAllSandboxes(String namespace, String labelSelector)

列出 listAllSandboxes。

Lists SandboxClaim names, optionally filtered by label selector.

参数Parameters
名称Name类型Type说明Description
namespaceString命名空间(类型 `String`)。namespace
labelSelectorString标签 Selector(类型 `String`)。optional label selector
返回Returns List<String>
返回列出。claim names
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:284–287

deleteSandbox

public void deleteSandbox(String claimName, String namespace)

删除沙箱。

Stops the client-side connection and deletes the Kubernetes claim.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。claim name
namespaceString命名空间(类型 `String`)。namespace
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:295–313

deleteAll

public void deleteAll()

删除所有。

Deletes all sandboxes tracked by this client.

源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:316–331

getSandboxClaimWarmPoolName

public String getSandboxClaimWarmPoolName(String claimName, String namespace)

获取 getSandboxClaimWarmPoolName。

Returns the warm pool name referenced by a claim.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。claim name
namespaceString命名空间(类型 `String`)。namespace
返回Returns String
返回字符串结果。warm pool name
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:340–350

getK8sHelper

public K8sHelper getK8sHelper()

获取 getK8sHelper。

Returns the k 8 s helper.

返回Returns K8sHelper
返回K8sHelper。Returns k 8 s helper.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:352–354

getConnectionConfig

public SandboxConnectionConfig getConnectionConfig()

获取连接配置。

Returns the connection config.

返回Returns SandboxConnectionConfig
返回SandboxConnectionConfig。Returns sandbox connection config.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:356–358

close

public void close()

关闭连接并释放相关资源。

Releases resources and connections.

源码Source io/agentscope/extensions/sandbox/kubernetes/client/SandboxClient.java:360–370
基于官方固定版本源码静态生成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.