AS AgentScopeAPI 手册 / API Reference

SandboxService

public class SandboxService implements AutoCloseable
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:50–569

沙箱服务,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.manager 包,实现 AutoCloseable。核心成员包括 start、createAgentBayContainer、createContainer、getSandbox、startSandbox、stopSandbox。

A class in io.agentscope.runtime.sandbox.manager that deploys, schedules and serves agents. Declared in io.agentscope.runtime.sandbox.manager. Implements AutoCloseable.

构造器摘要Constructor Summary

构造器Constructor说明Description
public SandboxService(ManagerConfig managerConfig)
初始化 `SandboxService` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public void start()
执行启动相关操作。
Returns the start.
public String createAgentBayContainer(AgentBaySandbox sandbox)
创建 `createAgentBayContainer`。
Creates the agent bay container.
public ContainerModel createContainer(Sandbox sandbox) throws JsonProcessingException
创建容器。
Creates the container.
public ContainerModel getSandbox(String containerId)
获取沙箱。
Returns the sandbox.
public ContainerModel getSandbox(String userId, String sessionId, String sandboxType)
获取沙箱。
Returns the sandbox.
public boolean startSandbox(String userId, String sessionId, String sandboxType)
启动沙箱。
Starts the sandbox.
public boolean startSandbox(String containerId)
启动沙箱。
Starts the sandbox.
public boolean startSandbox(ContainerModel containerModel)
启动沙箱。
Starts the sandbox.
public void stopSandbox(String userId, String sessionId, String sandboxType)
停止沙箱。
Stops the sandbox.
public void stopSandbox(String containerId)
停止沙箱。
Stops the sandbox.
public void stopSandbox(ContainerModel containerModel)
停止沙箱。
Stops the sandbox.
public boolean removeSandbox(String userId, String sessionId, String sandboxType)
移除沙箱。
Removes the sandbox.
public boolean removeSandbox(String containerId)
移除沙箱。
Removes the sandbox.
public boolean removeSandbox(ContainerModel containerModel)
移除沙箱。
Removes the sandbox.
public boolean stopAndRemoveSandbox(String userId, String sessionId, String sandboxType)
停止和移除沙箱。
Stops the and remove sandbox.
public boolean stopAndRemoveSandbox(String containerId)
停止和移除沙箱。
Stops the and remove sandbox.
public boolean release(String containerId)
关闭资源并释放连接。
Releases resources and connections.
public String getSandboxStatus(String userId, String sessionId, String sandboxType)
获取沙箱状态。
Returns the sandbox status.
public String getSandboxStatus(String containerId)
获取沙箱状态。
Returns the sandbox status.
public String getSandboxStatus(ContainerModel containerModel)
获取沙箱状态。
Returns the sandbox status.
public Map<String, ContainerModel> getAllSandboxes()
获取 `getAllSandboxes`。
Returns the all sandboxes.
public ContainerModel getInfo(String containerId)
获取信息。
Returns the info.
public void cleanupAllSandboxes()
执行 `cleanupAllSandboxes` 方法。
Returns the cleanup all sandboxes.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
public Map<String, Object> listTools(String sandboxId, String toolType)
列出工具。
Lists the tools.
public String callTool(String sandboxId, String toolName, Map<String, Object> arguments)
调用工具。
Calls the tool.
public Map<String, Object> addMcpServers(String sandboxId, Map<String, Object> serverConfigs, boolean overwrite)
添加 `addMcpServers`。
Adds the mcp servers.
public AgentBayClient getAgentBayClient()
获取 `getAgentBayClient`。
Returns the agent bay client.

构造器详情Constructor Detail

SandboxService

public SandboxService(ManagerConfig managerConfig)

初始化 SandboxService 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerConfigManagerConfig管理器配置(类型 `ManagerConfig`)。The manager config.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:59–69

方法详情Method Detail

start

public void start()

执行启动相关操作。

Returns the start.

源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:71–78

createAgentBayContainer

public String createAgentBayContainer(AgentBaySandbox sandbox)

创建 createAgentBayContainer。

Creates the agent bay container.

参数Parameters
名称Name类型Type说明Description
sandboxAgentBaySandbox沙箱(类型 `AgentBaySandbox`)。The sandbox.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:80–89

createContainer

public ContainerModel createContainer(Sandbox sandbox) throws JsonProcessingException

创建容器。

Creates the container.

参数Parameters
名称Name类型Type说明Description
sandboxSandbox沙箱(类型 `Sandbox`)。The sandbox.
返回Returns ContainerModel
返回ContainerModel。Returns container model.
抛出Throws
  • JsonProcessingException 可能抛出 `JsonProcessingException`。Thrown when the operation cannot be completed.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:91–284

getSandbox

public ContainerModel getSandbox(String containerId)

获取沙箱。

Returns the sandbox.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns ContainerModel
返回ContainerModel。Returns container model.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:286–288

getSandbox

public ContainerModel getSandbox(String userId, String sessionId, String sandboxType)

获取沙箱。

Returns the sandbox.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
返回Returns ContainerModel
返回ContainerModel。Returns container model.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:290–292

startSandbox

public boolean startSandbox(String userId, String sessionId, String sandboxType)

启动沙箱。

Starts the sandbox.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:294–296

startSandbox

public boolean startSandbox(String containerId)

启动沙箱。

Starts the sandbox.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:298–300

startSandbox

public boolean startSandbox(ContainerModel containerModel)

启动沙箱。

Starts the sandbox.

参数Parameters
名称Name类型Type说明Description
containerModelContainerModel容器模型(类型 `ContainerModel`)。The container model.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:302–321

stopSandbox

public void stopSandbox(String userId, String sessionId, String sandboxType)

停止沙箱。

Stops the sandbox.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:323–325

stopSandbox

public void stopSandbox(String containerId)

停止沙箱。

Stops the sandbox.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:327–329

stopSandbox

public void stopSandbox(ContainerModel containerModel)

停止沙箱。

Stops the sandbox.

参数Parameters
名称Name类型Type说明Description
containerModelContainerModel容器模型(类型 `ContainerModel`)。The container model.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:331–351

removeSandbox

public boolean removeSandbox(String userId, String sessionId, String sandboxType)

移除沙箱。

Removes the sandbox.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:353–355

removeSandbox

public boolean removeSandbox(String containerId)

移除沙箱。

Removes the sandbox.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:357–359

removeSandbox

public boolean removeSandbox(ContainerModel containerModel)

移除沙箱。

Removes the sandbox.

参数Parameters
名称Name类型Type说明Description
containerModelContainerModel容器模型(类型 `ContainerModel`)。The container model.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:361–382

stopAndRemoveSandbox

public boolean stopAndRemoveSandbox(String userId, String sessionId, String sandboxType)

停止和移除沙箱。

Stops the and remove sandbox.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:384–387

stopAndRemoveSandbox

public boolean stopAndRemoveSandbox(String containerId)

停止和移除沙箱。

Stops the and remove sandbox.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:389–392

release

public boolean release(String containerId)

关闭资源并释放连接。

Releases resources and connections.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:394–396

getSandboxStatus

public String getSandboxStatus(String userId, String sessionId, String sandboxType)

获取沙箱状态。

Returns the sandbox status.

参数Parameters
名称Name类型Type说明Description
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:398–400

getSandboxStatus

public String getSandboxStatus(String containerId)

获取沙箱状态。

Returns the sandbox status.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:402–404

getSandboxStatus

public String getSandboxStatus(ContainerModel containerModel)

获取沙箱状态。

Returns the sandbox status.

参数Parameters
名称Name类型Type说明Description
containerModelContainerModel容器模型(类型 `ContainerModel`)。The container model.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:406–426

getAllSandboxes

public Map<String, ContainerModel> getAllSandboxes()

获取 getAllSandboxes。

Returns the all sandboxes.

返回Returns Map<String, ContainerModel>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:428–430

getInfo

public ContainerModel getInfo(String containerId)

获取信息。

Returns the info.

参数Parameters
名称Name类型Type说明Description
containerIdString容器标识(类型 `String`)。The container id.
返回Returns ContainerModel
返回ContainerModel。Returns container model.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:432–451

cleanupAllSandboxes

public void cleanupAllSandboxes()

执行 cleanupAllSandboxes 方法。

Returns the cleanup all sandboxes.

源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:453–459

close

public void close()

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

Releases resources and connections.

源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:461–464

listTools

public Map<String, Object> listTools(String sandboxId, String toolType)

列出工具。

Lists the tools.

参数Parameters
名称Name类型Type说明Description
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
toolTypeString工具类型(类型 `String`)。The tool type.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:479–506

callTool

public String callTool(String sandboxId, String toolName, Map<String, Object> arguments)

调用工具。

Calls the tool.

参数Parameters
名称Name类型Type说明Description
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
toolNameString工具名称(类型 `String`)。The tool name.
argumentsMap<String, Object>参数(类型 `Map`)。The arguments.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:508–534

addMcpServers

public Map<String, Object> addMcpServers(String sandboxId, Map<String, Object> serverConfigs, boolean overwrite)

添加 addMcpServers。

Adds the mcp servers.

参数Parameters
名称Name类型Type说明Description
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
serverConfigsMap<String, Object>服务端 Configs(类型 `Map`)。The server configs.
overwritebooleanoverwrite(类型 `boolean`)。The overwrite.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:536–564

getAgentBayClient

public AgentBayClient getAgentBayClient()

获取 getAgentBayClient。

Returns the agent bay client.

返回Returns AgentBayClient
返回AgentBayClient。Returns agent bay client.
源码Source io/agentscope/runtime/sandbox/manager/SandboxService.java:566–568
基于官方固定版本源码静态生成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.