MobileSandbox
@RegisterSandbox( imageName = "agentscope-registry.ap-southeast-1.cr.aliyuncs.com/agentscope/runtime-sandbox-mobile:latest", sandboxType = "mobile", securityLevel = "high", timeout = 60, description = "Mobile Sandbox", runtimeConfig = {"privileged=true"} ) public class MobileSandbox extends Sandbox
io/agentscope/runtime/sandbox/box/MobileSandbox.java:33–279Mobile 沙箱,承载智能体的部署、调度与服务化运行。位于 io.agentscope.runtime.sandbox.box 包,继承自 Sandbox。核心成员包括 checkHostReadiness、adbUse、mobileGetScreenResolution、mobileTap、mobileSwipe、mobileInputText。
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
| 方法Method | 说明Description |
|---|---|
public void checkHostReadiness() | 检查 `checkHostReadiness` 条件。 Performs a one-time check of the host environment to ensure
all prerequisites for MobileSandbox are met. |
public String adbUse(String action, List<Integer> coordinate, List<Integer> start, List<Integer> end, Integer duration, Object code, String text) | 执行 `adbUse` 方法。 A general-purpose method to execute various ADB actions. |
public String mobileGetScreenResolution() | 返回 `mobileGetScreenResolution` 结果。 Get the screen resolution of the connected mobile device. |
public String mobileTap(int x, int y) | 执行 `mobileTap` 方法。 Tap a specific coordinate on the screen. |
public String mobileSwipe(List<Integer> start, List<Integer> end, Integer duration) | 执行 `mobileSwipe` 方法。 Perform a swipe gesture on the screen from a start point to an end point. |
public String mobileInputText(String text) | 设置该参数。 Input a text string into the currently focused UI element. |
public String mobileKeyEvent(Object code) | 设置该参数。 Send an Android key event to the device. |
public String mobileGetScreenshot() | 返回 `mobileGetScreenshot` 结果。 Take a screenshot of the current device screen. |
构造器详情Constructor Detail
MobileSandbox
public MobileSandbox(SandboxService managerApi, String userId, String sessionId)
初始化 MobileSandbox 实例。
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/MobileSandbox.java:45–51MobileSandbox
public MobileSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig)
初始化 MobileSandbox 实例。
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/MobileSandbox.java:53–60MobileSandbox
public MobileSandbox(SandboxService managerApi, String userId, String sessionId, Map<String, String> environment)
初始化 MobileSandbox 实例。
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/MobileSandbox.java:62–69MobileSandbox
public MobileSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig, Map<String, String> environment)
初始化 MobileSandbox 实例。
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. |
environment | Map<String, String> | 环境(类型 `Map`)。The environment. |
io/agentscope/runtime/sandbox/box/MobileSandbox.java:71–82方法详情Method Detail
checkHostReadiness
public void checkHostReadiness()
检查 checkHostReadiness 条件。
Performs a one-time check of the host environment to ensure all prerequisites for MobileSandbox are met.
HostPrerequisiteError可能抛出 `HostPrerequisiteError`。if host prerequisites are not met
io/agentscope/runtime/sandbox/box/MobileSandbox.java:90–147adbUse
public String adbUse(String action, List<Integer> coordinate, List<Integer> start, List<Integer> end, Integer duration, Object code, String text)
执行 adbUse 方法。
A general-purpose method to execute various ADB actions.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
action | String | 动作(类型 `String`)。The specific ADB action to perform. Examples: "tap", "swipe", "input_text", "key_event", "get_screenshot", "get_screen_resolution" |
coordinate | List<Integer> | coordinate(类型 `List`)。The [x, y] coordinates for a "tap" action |
start | List<Integer> | 启动(类型 `List`)。The starting [x, y] coordinates for a "swipe" action |
end | List<Integer> | 结束(类型 `List`)。The ending [x, y] coordinates for a "swipe" action |
duration | Integer | 时长(类型 `Integer`)。The duration of a "swipe" gesture in milliseconds |
code | Object | code(类型 `Object`)。The key event code (e.g., 3) or name (e.g., "HOME") for the "key_event" action |
text | String | 文本(类型 `String`)。The text string to be entered for the "input_text" action |
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:167–197mobileGetScreenResolution
public String mobileGetScreenResolution()
返回 mobileGetScreenResolution 结果。
Get the screen resolution of the connected mobile device.
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:204–208mobileTap
public String mobileTap(int x, int y)
执行 mobileTap 方法。
Tap a specific coordinate on the screen.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
x | int | x(类型 `int`)。The x-coordinate in pixels from the left edge |
y | int | y(类型 `int`)。The y-coordinate in pixels from the top edge |
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:217–222mobileSwipe
public String mobileSwipe(List<Integer> start, List<Integer> end, Integer duration)
执行 mobileSwipe 方法。
Perform a swipe gesture on the screen from a start point to an end point.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
start | List<Integer> | 启动(类型 `List`)。The starting coordinates [x, y] in pixels |
end | List<Integer> | 结束(类型 `List`)。The ending coordinates [x, y] in pixels |
duration | Integer | 时长(类型 `Integer`)。The duration of the swipe in milliseconds (optional) |
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:232–241mobileInputText
public String mobileInputText(String text)
设置该参数。
Input a text string into the currently focused UI element.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
text | String | 文本(类型 `String`)。The string to be inputted |
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:249–254mobileKeyEvent
public String mobileKeyEvent(Object code)
设置该参数。
Send an Android key event to the device.
| 名称Name | 类型Type | 说明Description |
|---|---|---|
code | Object | code(类型 `Object`)。The key event code (e.g., 3 for HOME) or a string representation (e.g., "HOME", "BACK") |
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:262–267mobileGetScreenshot
public String mobileGetScreenshot()
返回 mobileGetScreenshot 结果。
Take a screenshot of the current device screen.
Stringio/agentscope/runtime/sandbox/box/MobileSandbox.java:274–278