BrowserSandbox
@RegisterSandbox( imageName = "agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-browser:latest", sandboxType = "browser", securityLevel = "medium", timeout = 60, description = "Browser sandbox" ) public class BrowserSandbox extends Sandbox
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:26–244Browser 沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.box 包,继承自 Sandbox。核心成员包括 getDesktopUrl、navigate、click、type、takeScreenshot、snapshot。
A class in io.agentscope.runtime.sandbox.box that deploys, schedules and serves agents. Declared in io.agentscope.runtime.sandbox.box. Extends Sandbox.
构造器摘要Constructor Summary
方法摘要Method Summary
构造器详情Constructor Detail
BrowserSandbox
public BrowserSandbox(SandboxService managerApi, String userId, String sessionId)
初始化 BrowserSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:37–39BrowserSandbox
public BrowserSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl)
初始化 BrowserSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:41–47BrowserSandbox
public BrowserSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig)
初始化 BrowserSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
fileSystemConfig | FileSystemConfig | 文件系统配置(类型 `FileSystemConfig`)。The file system config. |
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:49–55BrowserSandbox
public BrowserSandbox(SandboxService managerApi, String userId, String sessionId, Map<String, String> environment)
初始化 BrowserSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:57–63BrowserSandbox
public BrowserSandbox(SandboxService managerApi, String userId, String sessionId, String baseUrl, FileSystemConfig fileSystemConfig, Map<String, String> environment)
初始化 BrowserSandbox 实例。
Creates a new instance.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
managerApi | SandboxService | 管理器 API(类型 `SandboxService`)。The manager api. |
userId | String | 用户标识(类型 `String`)。The user id. |
sessionId | String | 会话标识(类型 `String`)。The session id. |
baseUrl | String | 基类 URL(类型 `String`)。The base url. |
fileSystemConfig | FileSystemConfig | 文件系统配置(类型 `FileSystemConfig`)。The file system config. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:65–74方法详情Method Detail
getDesktopUrl
public String getDesktopUrl()
获取 getDesktopUrl。
Get the desktop URL for VNC access.
StringRuntimeException可能抛出 `RuntimeException`。if sandbox is not healthy
io/agentscope/runtime/sandbox/box/BrowserSandbox.java:83–85click
public String click(String element, String ref)
执行 click 方法。
Performs the click operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:93–98type
public String type(String element, String ref, String text)
执行类型相关操作。
Performs the type operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
text | String | 文本(类型 `String`)。The text. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:100–102type
public String type(String element, String ref, String text, Boolean submit, Boolean slowly)
执行类型相关操作。
Performs the type operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
text | String | 文本(类型 `String`)。The text. |
submit | Boolean | 提交(类型 `Boolean`)。The submit. |
slowly | Boolean | slowly(类型 `Boolean`)。The slowly. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:104–112takeScreenshot
public String takeScreenshot()
返回 takeScreenshot 结果。
Returns the take screenshot.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:114–116takeScreenshot
public String takeScreenshot(Boolean raw, String filename, String element, String ref)
执行 takeScreenshot 方法。
Performs the take screenshot operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
raw | Boolean | 原始(类型 `Boolean`)。The raw. |
filename | String | filename(类型 `String`)。The filename. |
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:118–125snapshot
public String snapshot()
返回快照。
Returns the snapshot.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:127–129tabNew
public String tabNew(String url)
设置该参数。
Performs the tab new operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
url | String | 服务地址(类型 `String`)。The url. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:131–135tabSelect
public String tabSelect(Integer index)
设置该参数。
Performs the tab select operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
index | Integer | 索引(类型 `Integer`)。The index. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:137–141tabClose
public String tabClose(Integer index)
设置该参数。
Performs the tab close operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
index | Integer | 索引(类型 `Integer`)。The index. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:143–147tabList
public String tabList()
返回 tabList 结果。
Returns the tab list.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:149–151waitFor
public String waitFor(Double time)
等待用于。
Performs the wait for operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
time | Double | 时间(类型 `Double`)。The time. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:153–155waitFor
public String waitFor(Double time, String text, String textGone)
等待用于。
Performs the wait for operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
time | Double | 时间(类型 `Double`)。The time. |
text | String | 文本(类型 `String`)。The text. |
textGone | String | 文本 Gone(类型 `String`)。The text gone. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:157–163resize
public String resize(Double width, Double height)
执行 resize 方法。
Performs the resize operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
width | Double | width(类型 `Double`)。The width. |
height | Double | height(类型 `Double`)。The height. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:165–170closeBrowser
public String closeBrowser()
关闭 closeBrowser。
Closes the browser.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:172–174consoleMessages
public String consoleMessages()
返回控制台消息。
Returns the console messages.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:176–178networkRequests
public String networkRequests()
返回 networkRequests 结果。
Returns the network requests.
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:180–182hover
public String hover(String element, String ref)
执行 hover 方法。
Performs the hover operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:192–197pressKey
public String pressKey(String key)
设置该参数。
Performs the press key operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
key | String | 键(类型 `String`)。The key. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:199–203handleDialog
public String handleDialog(Boolean accept, String promptText)
处理 handleDialog。
Performs the handle dialog operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
accept | Boolean | accept(类型 `Boolean`)。The accept. |
promptText | String | 提示词文本(类型 `String`)。The prompt text. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:205–212fileUpload
public String fileUpload(String[] paths)
设置文件上传。
Performs the file upload operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
paths | String[] | paths(类型 `String[]`)。The paths. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:214–218pdfSave
public String pdfSave(String filename)
设置该参数。
Performs the pdf save operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
filename | String | filename(类型 `String`)。The filename. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:220–226drag
public String drag(String startElement, String startRef, String endElement, String endRef)
执行 drag 方法。
Performs the drag operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
startElement | String | 启动 Element(类型 `String`)。The start element. |
startRef | String | 启动引用(类型 `String`)。The start ref. |
endElement | String | 结束 Element(类型 `String`)。The end element. |
endRef | String | 结束引用(类型 `String`)。The end ref. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:228–235selectOption
public String selectOption(String element, String ref, String[] values)
执行选择选项相关操作。
Performs the select option operation.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
element | String | element(类型 `String`)。The element. |
ref | String | 引用(类型 `String`)。The ref. |
values | String[] | 值(类型 `String[]`)。The values. |
Stringio/agentscope/runtime/sandbox/box/BrowserSandbox.java:237–243