AS AgentScopeAPI 手册 / API Reference

Sandbox

public class Sandbox
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:35–247

处理用于运行中沙箱实例。位于 io.agentscope.extensions.sandbox.kubernetes.client 包。核心成员包括 claimName、sandboxId、namespace、commands、files、isActive。

Handle for a running Sandbox instance. Provides command execution and file I/O via #commands() and #files().

Mirrors the Python SDK's Sandbox class.

构造器摘要Constructor Summary

构造器Constructor说明Description
public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper)
初始化 `Sandbox` 实例。
Creates a new instance.
public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper, Duration requestTimeout, Duration perAttemptTimeout)
初始化 `Sandbox` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String claimName()
返回 `claimName` 结果。
Returns the claim name.
public String sandboxId()
返回沙箱标识。
Returns the sandbox id.
public String namespace()
返回命名空间。
Returns the namespace.
public CommandExecutor commands()
返回 `commands` 结果。
Returns the command executor, or null if the connection has been closed.
public Filesystem files()
返回文件。
Returns the filesystem API, or null if the connection has been closed.
public boolean isActive()
判断是否 `isActive`。
Whether the client-side connection is still active.
public String getPodName()
获取 `getPodName`。
Fetches the Sandbox object from Kubernetes and retrieves its current pod name.
public String getPodIp()
获取 `getPodIp`。
Selects a pod IP from the Sandbox status (prefers IPv4).
public String getSandboxNameHash()
获取 `getSandboxNameHash`。
Fetches the sandbox name hash from the status selector label.
public SandboxStatus status()
返回状态。
Retrieves the current status of the Sandbox.
public void closeConnection()
关闭连接。
Closes the client-side connection but leaves the remote Kubernetes resources running.
public void terminate()
执行 `terminate` 方法。
Permanently deletes the SandboxClaim and closes the client-side connection.

构造器详情Constructor Detail

Sandbox

public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。The claim name.
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
namespaceString命名空间(类型 `String`)。The namespace.
connectionConfigSandboxConnectionConfig连接配置(类型 `SandboxConnectionConfig`)。The connection config.
k8sHelperK8sHelperk 8 s Helper(类型 `K8sHelper`)。The k 8 s helper.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:52–59

Sandbox

public Sandbox(String claimName, String sandboxId, String namespace, SandboxConnectionConfig connectionConfig, K8sHelper k8sHelper, Duration requestTimeout, Duration perAttemptTimeout)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
claimNameStringclaim 名称(类型 `String`)。The claim name.
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
namespaceString命名空间(类型 `String`)。The namespace.
connectionConfigSandboxConnectionConfig连接配置(类型 `SandboxConnectionConfig`)。The connection config.
k8sHelperK8sHelperk 8 s Helper(类型 `K8sHelper`)。The k 8 s helper.
requestTimeoutDuration请求超时(类型 `Duration`)。The request timeout.
perAttemptTimeoutDuration每个尝试超时(类型 `Duration`)。The per attempt timeout.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:61–86

方法详情Method Detail

claimName

public String claimName()

返回 claimName 结果。

Returns the claim name.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:88–90

sandboxId

public String sandboxId()

返回沙箱标识。

Returns the sandbox id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:92–94

namespace

public String namespace()

返回命名空间。

Returns the namespace.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:96–98

commands

public CommandExecutor commands()

返回 commands 结果。

Returns the command executor, or null if the connection has been closed.

返回Returns CommandExecutor
返回CommandExecutor。command executor
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:105–107

files

public Filesystem files()

返回文件。

Returns the filesystem API, or null if the connection has been closed.

返回Returns Filesystem
返回文件系统。filesystem
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:114–116

isActive

public boolean isActive()

判断是否 isActive。

Whether the client-side connection is still active.

返回Returns boolean
返回布尔值,表示判断结果。true if active
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:123–125

getPodName

public String getPodName()

获取 getPodName。

Fetches the Sandbox object from Kubernetes and retrieves its current pod name.

返回Returns String
返回字符串结果。pod name
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:132–148

getPodIp

public String getPodIp()

获取 getPodIp。

Selects a pod IP from the Sandbox status (prefers IPv4).

返回Returns String
返回字符串结果。pod IP or null
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:155–161

getSandboxNameHash

public String getSandboxNameHash()

获取 getSandboxNameHash。

Fetches the sandbox name hash from the status selector label.

返回Returns String
返回字符串结果。hash or null
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:168–189

status

public SandboxStatus status()

返回状态。

Retrieves the current status of the Sandbox.

返回Returns SandboxStatus
返回SandboxStatus。status pair
源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:196–215

closeConnection

public void closeConnection()

关闭连接。

Closes the client-side connection but leaves the remote Kubernetes resources running.

源码Source io/agentscope/extensions/sandbox/kubernetes/client/Sandbox.java:220–229

terminate

public void terminate()

执行 terminate 方法。

Permanently deletes the SandboxClaim and closes the client-side connection.

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