SandboxManager
public class SandboxManager implements AutoCloseable
io/agentscope/runtime/sandbox/manager/SandboxManager.java:43–1179沙箱管理器,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.manager 包,实现 AutoCloseable。核心成员包括 getAgentBayClient、start、createFromPool、createContainer、getSandbox、startSandbox。
Sandbox Manager for managing container lifecycle
构造器摘要Constructor Summary
| 构造器Constructor | 说明Description |
|---|---|
public SandboxManager() | 初始化 `SandboxManager` 实例。 Creates a new instance. |
public SandboxManager(String baseUrl, String bearerToken) | 初始化 `SandboxManager` 实例。 Creates a new instance. |
public SandboxManager(ManagerConfig managerConfig) | 初始化 `SandboxManager` 实例。 Creates a new instance. |
public SandboxManager(ManagerConfig managerConfig, String baseUrl, String bearerToken) | 初始化 `SandboxManager` 实例。 Creates a new instance. |
方法摘要Method Summary
构造器详情Constructor Detail
SandboxManager
public SandboxManager()
初始化 SandboxManager 实例。
Creates a new instance.
io/agentscope/runtime/sandbox/manager/SandboxManager.java:65–67SandboxManager
public SandboxManager(String baseUrl, String bearerToken)
初始化 SandboxManager 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
bearerToken | String | bearer 令牌(类型 `String`)。The bearer token. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:69–71SandboxManager
public SandboxManager(ManagerConfig managerConfig)
初始化 SandboxManager 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerConfig | ManagerConfig | 管理器配置(类型 `ManagerConfig`)。The manager config. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:73–75SandboxManager
public SandboxManager(ManagerConfig managerConfig, String baseUrl, String bearerToken)
初始化 SandboxManager 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerConfig | ManagerConfig | 管理器配置(类型 `ManagerConfig`)。The manager config. |
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
bearerToken | String | bearer 令牌(类型 `String`)。The bearer token. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:77–104方法详情Method Detail
getAgentBayClient
public AgentBayClient getAgentBayClient()
获取 getAgentBayClient。
Returns the agent bay client.
AgentBayClientio/agentscope/runtime/sandbox/manager/SandboxManager.java:60–62start
public void start()
执行启动相关操作。
Returns the start.
io/agentscope/runtime/sandbox/manager/SandboxManager.java:106–179createFromPool
public ContainerModel createFromPool(SandboxType sandboxType, String imageId, Map<String, String> labels)
创建来自连接池。
Creates the from pool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
imageId | String | 图像标识(类型 `String`)。The image id. |
labels | Map<String, String> | labels(类型 `Map`)。The labels. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:244–297createFromPool
public ContainerModel createFromPool(SandboxType sandboxType, String userID, String sessionID)
创建来自连接池。
Creates the from pool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:299–301createFromPool
public ContainerModel createFromPool(SandboxType sandboxType, String userID, String sessionID, String imageId, Map<String, String> labels)
创建来自连接池。
Creates the from pool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
imageId | String | 图像标识(类型 `String`)。The image id. |
labels | Map<String, String> | labels(类型 `Map`)。The labels. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:303–363createContainer
public ContainerModel createContainer(SandboxType sandboxType)
创建容器。
Creates the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:365–367createContainer
public ContainerModel createContainer(SandboxType sandboxType, String mountDir, String storagePath, Map<String, String> environment)
创建容器。
Creates the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
mountDir | String | mount 目录(类型 `String`)。The mount dir. |
storagePath | String | 存储路径(类型 `String`)。The storage path. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:369–371createContainer
public ContainerModel createContainer(SandboxType sandboxType, String mountDir, String storagePath, Map<String, String> environment, String imageId, Map<String, String> labels)
创建容器。
Creates the container.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
mountDir | String | mount 目录(类型 `String`)。The mount dir. |
storagePath | String | 存储路径(类型 `String`)。The storage path. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
imageId | String | 图像标识(类型 `String`)。The image id. |
labels | Map<String, String> | labels(类型 `Map`)。The labels. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:373–599getSandbox
public ContainerModel getSandbox(SandboxType sandboxType, String userID, String sessionID)
获取沙箱。
Returns the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:618–620getSandbox
public ContainerModel getSandbox(SandboxType sandboxType, String userID, String sessionID, String imageId, Map<String, String> labels)
获取沙箱。
Returns the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
imageId | String | 图像标识(类型 `String`)。The image id. |
labels | Map<String, String> | labels(类型 `Map`)。The labels. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:622–624getSandbox
public ContainerModel getSandbox(SandboxType sandboxType, String mountDir, String storagePath, Map<String, String> environment, String userID, String sessionID)
获取沙箱。
Returns the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
mountDir | String | mount 目录(类型 `String`)。The mount dir. |
storagePath | String | 存储路径(类型 `String`)。The storage path. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:626–628getSandbox
public ContainerModel getSandbox(SandboxType sandboxType, String mountDir, String storagePath, Map<String, String> environment, String userID, String sessionID, String imageId, Map<String, String> labels)
获取沙箱。
Returns the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
mountDir | String | mount 目录(类型 `String`)。The mount dir. |
storagePath | String | 存储路径(类型 `String`)。The storage path. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
imageId | String | 图像标识(类型 `String`)。The image id. |
labels | Map<String, String> | labels(类型 `Map`)。The labels. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:630–657startSandbox
public void startSandbox(SandboxType sandboxType, String userID, String sessionID)
启动沙箱。
Starts the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:659–692stopSandbox
public void stopSandbox(SandboxType sandboxType, String userID, String sessionID)
停止沙箱。
Stops the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:694–727removeSandbox
public void removeSandbox(SandboxType sandboxType, String userID, String sessionID)
移除沙箱。
Removes the sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:729–746stopAndRemoveSandbox
public void stopAndRemoveSandbox(SandboxType sandboxType, String userID, String sessionID)
停止和移除沙箱。
Stops the and remove sandbox.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
io/agentscope/runtime/sandbox/manager/SandboxManager.java:748–787getSandboxStatus
public String getSandboxStatus(SandboxType sandboxType, String userID, String sessionID)
获取沙箱状态。
Returns the sandbox status.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userID | String | 用户标识(类型 `String`)。The user ID. |
sessionID | String | 会话标识(类型 `String`)。The session ID. |
Stringio/agentscope/runtime/sandbox/manager/SandboxManager.java:789–820getAllSandboxes
public Map<SandboxKey, ContainerModel> getAllSandboxes()
获取 getAllSandboxes。
Returns the all sandboxes.
Map<SandboxKey, ContainerModel>io/agentscope/runtime/sandbox/manager/SandboxManager.java:822–837getInfo
public ContainerModel getInfo(String identity)
获取信息。
Returns the info.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
identity | String | 身份(类型 `String`)。The identity. |
ContainerModelio/agentscope/runtime/sandbox/manager/SandboxManager.java:839–892release
public boolean release(String identity)
关闭资源并释放连接。
Releases resources and connections.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
identity | String | 身份(类型 `String`)。The identity. |
booleanio/agentscope/runtime/sandbox/manager/SandboxManager.java:895–967getContainerManagerType
public ContainerManagerType getContainerManagerType()
获取容器管理器类型。
Returns the container manager type.
ContainerManagerTypeio/agentscope/runtime/sandbox/manager/SandboxManager.java:969–971getManagerConfig
public ManagerConfig getManagerConfig()
获取管理器配置。
Returns the manager config.
ManagerConfigio/agentscope/runtime/sandbox/manager/SandboxManager.java:973–975getContainerClient
public BaseClient getContainerClient()
获取容器客户端。
Returns the container client.
BaseClientio/agentscope/runtime/sandbox/manager/SandboxManager.java:977–979getStorageManager
public StorageManager getStorageManager()
获取存储管理器。
Returns the storage manager.
StorageManagerio/agentscope/runtime/sandbox/manager/SandboxManager.java:981–983getRemoteHttpClient
public RemoteHttpClient getRemoteHttpClient()
获取远程 HTTP 客户端。
Returns the remote http client.
RemoteHttpClientio/agentscope/runtime/sandbox/manager/SandboxManager.java:985–987cleanupAllSandboxes
public void cleanupAllSandboxes()
执行 cleanupAllSandboxes 方法。
Returns the cleanup all sandboxes.
io/agentscope/runtime/sandbox/manager/SandboxManager.java:989–1033close
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
io/agentscope/runtime/sandbox/manager/SandboxManager.java:1035–1059listTools
public String listTools(String identity, String toolType)
列出工具。
Lists the tools.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
identity | String | 身份(类型 `String`)。The identity. |
toolType | String | 工具类型(类型 `String`)。The tool type. |
Stringio/agentscope/runtime/sandbox/manager/SandboxManager.java:1061–1063listTools
public Map<String, Object> listTools(String sandboxId, String userId, String sessionId, String toolType)
列出工具。
Lists the tools.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
toolType | String | 工具类型(类型 `String`)。The tool type. |
Map<String, Object>io/agentscope/runtime/sandbox/manager/SandboxManager.java:1078–1107callTool
public String callTool(String sandboxId, String userId, String sessionId, String toolName, Map<String, Object> arguments)
调用工具。
Calls the tool.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
toolName | String | 工具名称(类型 `String`)。The tool name. |
arguments | Map<String, Object> | 参数(类型 `Map`)。The arguments. |
Stringio/agentscope/runtime/sandbox/manager/SandboxManager.java:1109–1135addMcpServers
public Map<String, Object> addMcpServers(String sandboxId, String userId, String sessionId, Map<String, Object> serverConfigs, boolean overwrite)
添加 addMcpServers。
Adds the mcp servers.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxId | String | 沙箱标识(类型 `String`)。The sandbox id. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
serverConfigs | Map<String, Object> | 服务端 Configs(类型 `Map`)。The server configs. |
overwrite | boolean | overwrite(类型 `boolean`)。The overwrite. |
Map<String, Object>io/agentscope/runtime/sandbox/manager/SandboxManager.java:1137–1167releaseSandbox
public boolean releaseSandbox(SandboxType sandboxType, String userId, String sessionId)
执行 releaseSandbox 方法。
Performs the release sandbox operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
sandboxType | SandboxType | 沙箱类型(类型 `SandboxType`)。The sandbox type. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
booleanio/agentscope/runtime/sandbox/manager/SandboxManager.java:1169–1178