AS AgentScopeAPI 手册 / API Reference

Sandbox

public class Sandbox implements AutoCloseable
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:33–207

沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.box 包,实现 AutoCloseable。核心成员包括 getSandboxId、getUserId、getSessionId、getSandboxType、getEnvironment、getFileSystemStarter。

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

字段摘要Field Summary

字段Field类型Type说明Description
managerApi
SandboxService
管理器 API字段。
The manager api field.
sandboxId
String
沙箱标识字段。
The sandbox id field.
userId
String
用户标识字段。
The user id field.
sessionId
String
会话标识字段。
The session id field.
sandboxType
String
沙箱类型字段。
The sandbox type field.
closed
boolean
已关闭字段。
The closed field.
environment
Map<String, String>
环境字段。
The environment field.
fileSystemConfig
FileSystemConfig
文件系统配置字段。
The file system config field.

构造器摘要Constructor Summary

构造器Constructor说明Description
public Sandbox(String sandboxId, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment, boolean closed)
初始化 `Sandbox` 实例。
Creates a new instance.
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType)
初始化 `Sandbox` 实例。
Creates a new instance.
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig)
初始化 `Sandbox` 实例。
Creates a new instance.
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, Map<String, String> environment)
初始化 `Sandbox` 实例。
Creates a new instance.
public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment)
初始化 `Sandbox` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String getSandboxId()
获取沙箱标识。
Returns the sandbox id.
public String getUserId()
获取用户标识。
Returns the user id.
public String getSessionId()
获取会话标识。
Returns the session id.
public String getSandboxType()
获取沙箱类型。
Returns the sandbox type.
public Map<String, String> getEnvironment()
获取环境。
Returns the environment.
public FileSystemConfig getFileSystemStarter()
获取文件系统启动器。
Returns the file system starter.
public ContainerModel getInfo()
获取信息。
Returns the info.
public Map<String, Object> listTools()
列出工具。
Lists the tools.
public Map<String, Object> listTools(String toolType)
列出工具。
Lists the tools.
public String callTool(String name, Map<String, Object> arguments)
调用工具。
Calls the tool.
public Map<String, Object> addMcpServers(Map<String, Object> serverConfigs)
添加 `addMcpServers`。
Adds the mcp servers.
public Map<String, Object> addMcpServers(Map<String, Object> serverConfigs, boolean overwrite)
添加 `addMcpServers`。
Adds the mcp servers.
public void close()
关闭连接并释放相关资源。
Releases resources and connections.
public void release()
关闭资源并释放连接。
Manually release sandbox resources Forces release of underlying container regardless of autoRelease setting
public boolean isClosed()
判断是否已关闭。
Returns whether the closed.

字段详情Field Detail

managerApi

protected SandboxService managerApi

管理器 API字段。声明为 protected SandboxService managerApi。

The manager api field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:36

sandboxId

protected String sandboxId

沙箱标识字段。声明为 protected String sandboxId。

The sandbox id field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:37

userId

protected String userId

用户标识字段。声明为 protected String userId。

The user id field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:38

sessionId

protected String sessionId

会话标识字段。声明为 protected String sessionId。

The session id field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:39

sandboxType

protected String sandboxType

沙箱类型字段。声明为 protected String sandboxType。

The sandbox type field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:40

closed

protected boolean closed

已关闭字段。声明为 protected boolean closed。

The closed field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:41

environment

protected Map<String, String> environment

环境字段。声明为 protected Map environment。

The environment field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:42

fileSystemConfig

protected FileSystemConfig fileSystemConfig

文件系统配置字段。声明为 protected FileSystemConfig fileSystemConfig。

The file system config field.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:43

构造器详情Constructor Detail

Sandbox

public Sandbox(String sandboxId, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment, boolean closed)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
sandboxIdString沙箱标识(类型 `String`)。The sandbox id.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
environmentMap<String, String>环境(类型 `Map`)。The environment.
closedboolean已关闭(类型 `boolean`)。The closed.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:45–62

Sandbox

public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:64–70

Sandbox

public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:72–79

Sandbox

public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, Map<String, String> environment)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
environmentMap<String, String>环境(类型 `Map`)。The environment.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:81–89

Sandbox

public Sandbox(SandboxService managerApi, String userId, String sessionId, String sandboxType, FileSystemConfig fileSystemConfig, Map<String, String> environment)

初始化 Sandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
sandboxTypeString沙箱类型(类型 `String`)。The sandbox type.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
environmentMap<String, String>环境(类型 `Map`)。The environment.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:91–105

方法详情Method Detail

getSandboxId

public String getSandboxId()

获取沙箱标识。

Returns the sandbox id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:107–109

getUserId

public String getUserId()

获取用户标识。

Returns the user id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:111–113

getSessionId

public String getSessionId()

获取会话标识。

Returns the session id.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:115–117

getSandboxType

public String getSandboxType()

获取沙箱类型。

Returns the sandbox type.

返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:119–121

getEnvironment

public Map<String, String> getEnvironment()

获取环境。

Returns the environment.

返回Returns Map<String, String>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:123–125

getFileSystemStarter

public FileSystemConfig getFileSystemStarter()

获取文件系统启动器。

Returns the file system starter.

返回Returns FileSystemConfig
返回FileSystemConfig。Returns file system config.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:127–129

getInfo

public ContainerModel getInfo()

获取信息。

Returns the info.

返回Returns ContainerModel
返回ContainerModel。Returns container model.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:149–153

listTools

public Map<String, Object> listTools()

列出工具。

Lists the tools.

返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:155–157

listTools

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

列出工具。

Lists the tools.

参数Parameters
名称Name类型Type说明Description
toolTypeString工具类型(类型 `String`)。The tool type.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:159–162

callTool

public String callTool(String name, Map<String, Object> arguments)

调用工具。

Calls the tool.

参数Parameters
名称Name类型Type说明Description
nameString名称(类型 `String`)。The name.
argumentsMap<String, Object>参数(类型 `Map`)。The arguments.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:164–167

addMcpServers

public Map<String, Object> addMcpServers(Map<String, Object> serverConfigs)

添加 addMcpServers。

Adds the mcp servers.

参数Parameters
名称Name类型Type说明Description
serverConfigsMap<String, Object>服务端 Configs(类型 `Map`)。The server configs.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:169–171

addMcpServers

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

添加 addMcpServers。

Adds the mcp servers.

参数Parameters
名称Name类型Type说明Description
serverConfigsMap<String, Object>服务端 Configs(类型 `Map`)。The server configs.
overwritebooleanoverwrite(类型 `boolean`)。The overwrite.
返回Returns Map<String, Object>
返回映射。Returns map.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:173–176

close

public void close()

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

Releases resources and connections.

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:178–194

release

public void release()

关闭资源并释放连接。

Manually release sandbox resources Forces release of underlying container regardless of autoRelease setting

源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:200–202

isClosed

public boolean isClosed()

判断是否已关闭。

Returns whether the closed.

返回Returns boolean
返回布尔值,表示判断结果。Returns a boolean result.
源码Source io/agentscope/runtime/sandbox/box/Sandbox.java:204–206
基于官方固定版本源码静态生成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.