AS AgentScopeAPI 手册 / API Reference

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
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:33–279

Mobile 沙箱,承载智能体的部署、调度与服务化运行。位于 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

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

方法摘要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.

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

MobileSandbox

public MobileSandbox(SandboxService managerApi, String userId, String sessionId, FileSystemConfig fileSystemConfig)

初始化 MobileSandbox 实例。

Creates a new instance.

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

MobileSandbox

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

初始化 MobileSandbox 实例。

Creates a new instance.

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

MobileSandbox

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

初始化 MobileSandbox 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
managerApiSandboxService管理器 API(类型 `SandboxService`)。The manager api.
userIdString用户标识(类型 `String`)。The user id.
sessionIdString会话标识(类型 `String`)。The session id.
fileSystemConfigFileSystemConfig文件系统配置(类型 `FileSystemConfig`)。The file system config.
environmentMap<String, String>环境(类型 `Map`)。The environment.
源码Source 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.

抛出Throws
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:90–147

adbUse

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.

参数Parameters
名称Name类型Type说明Description
actionString动作(类型 `String`)。The specific ADB action to perform. Examples: "tap", "swipe", "input_text", "key_event", "get_screenshot", "get_screen_resolution"
coordinateList<Integer>coordinate(类型 `List`)。The [x, y] coordinates for a "tap" action
startList<Integer>启动(类型 `List`)。The starting [x, y] coordinates for a "swipe" action
endList<Integer>结束(类型 `List`)。The ending [x, y] coordinates for a "swipe" action
durationInteger时长(类型 `Integer`)。The duration of a "swipe" gesture in milliseconds
codeObjectcode(类型 `Object`)。The key event code (e.g., 3) or name (e.g., "HOME") for the "key_event" action
textString文本(类型 `String`)。The text string to be entered for the "input_text" action
返回Returns String
ADB 动作的结果。The result of the ADB action
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:167–197

mobileGetScreenResolution

public String mobileGetScreenResolution()

返回 mobileGetScreenResolution 结果。

Get the screen resolution of the connected mobile device.

返回Returns String
返回字符串结果。The screen resolution information
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:204–208

mobileTap

public String mobileTap(int x, int y)

执行 mobileTap 方法。

Tap a specific coordinate on the screen.

参数Parameters
名称Name类型Type说明Description
xintx(类型 `int`)。The x-coordinate in pixels from the left edge
yinty(类型 `int`)。The y-coordinate in pixels from the top edge
返回Returns String
返回字符串结果。The result of the tap action
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:217–222

mobileSwipe

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.

参数Parameters
名称Name类型Type说明Description
startList<Integer>启动(类型 `List`)。The starting coordinates [x, y] in pixels
endList<Integer>结束(类型 `List`)。The ending coordinates [x, y] in pixels
durationInteger时长(类型 `Integer`)。The duration of the swipe in milliseconds (optional)
返回Returns String
返回字符串结果。The result of the swipe action
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:232–241

mobileInputText

public String mobileInputText(String text)

设置该参数。

Input a text string into the currently focused UI element.

参数Parameters
名称Name类型Type说明Description
textString文本(类型 `String`)。The string to be inputted
返回Returns String
输入动作的结果。The result of the input action
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:249–254

mobileKeyEvent

public String mobileKeyEvent(Object code)

设置该参数。

Send an Android key event to the device.

参数Parameters
名称Name类型Type说明Description
codeObjectcode(类型 `Object`)。The key event code (e.g., 3 for HOME) or a string representation (e.g., "HOME", "BACK")
返回Returns String
密钥事件动作的结果。The result of the key event action
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:262–267

mobileGetScreenshot

public String mobileGetScreenshot()

返回 mobileGetScreenshot 结果。

Take a screenshot of the current device screen.

返回Returns String
返回字符串结果。The screenshot data
源码Source io/agentscope/runtime/sandbox/box/MobileSandbox.java:274–278

继承成员Inherited Members

基于官方固定版本源码静态生成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.