run-cloud-ios-simulator
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseOperate run.cloud Mobile Sessions
操作run.cloud移动会话
Use the CLI for terminal workflows, for TypeScript,
and for React embeds.
runcloud@run-cloud/sdk@runcloud/ui使用 CLI进行终端工作流,用于TypeScript开发,
用于React嵌入。
runcloud@run-cloud/sdk@runcloud/uiAuthenticate
身份验证
- Install the CLI with .
npm install -g runcloud - Use ; add
runcloud loginwhen a local callback cannot open.--manual - In CI, set .
RUN_CLOUD_API_KEYis an equivalent alias.RUN_CLOUD_API_TOKEN - Set only to override
RUN_CLOUD_API_URL.https://api.run.cloud - Require Node.js 20 or newer.
- Never print, commit, or place credentials in a skill file. Treat signed session and tunnel URLs as bearer secrets.
Check access and credit before starting metered work:
bash
runcloud account --jsonThe SDK equivalents are and .
cloud.account()cloud.usage({ orgId? })- 使用安装CLI。
npm install -g runcloud - 执行进行登录;当本地回调无法打开时,添加
runcloud login参数。--manual - 在CI环境中,设置。
RUN_CLOUD_API_KEY是其等效别名。RUN_CLOUD_API_TOKEN - 仅在需要覆盖默认地址时,设置
https://api.run.cloud。RUN_CLOUD_API_URL - 需要Node.js 20或更高版本。
- 切勿打印、提交凭证或将其放入skill文件中。已签名的会话和隧道URL需视为Bearer密钥妥善保管。
在开始计量工作前,检查访问权限和可用额度:
bash
runcloud account --json对应的SDK方法为和。
cloud.account()cloud.usage({ orgId? })Create and Release Sessions
创建与释放会话
bash
SESSION_ID=$(runcloud ios create \
--install ./build/MyApp.tar.gz \
--inactivity-timeout 60s \
--hard-timeout 10m \
--json | jq -r '.id')
trap 'runcloud ios delete "$SESSION_ID" >/dev/null 2>&1 || true' EXIT
runcloud ios get "$SESSION_ID" --jsonReplace with for an Android artifact. The shared lifecycle is
, , , , , and . Use whenever
another program consumes output, and inspect for
create and log options.
iosandroidcreatelistgetopen-urllogsdelete--jsonruncloud ios|android --helpiOS needs an Apple Silicon simulator-compatible , , , or
; a device-signed App Store IPA is not a substitute. Android needs an
emulator-compatible APK.
.app.zip.tar.gz.ipabash
SESSION_ID=$(runcloud ios create \
--install ./build/MyApp.tar.gz \
--inactivity-timeout 60s \
--hard-timeout 10m \
--json | jq -r '.id')
trap 'runcloud ios delete "$SESSION_ID" >/dev/null 2>&1 || true' EXIT
runcloud ios get "$SESSION_ID" --json若操作Android产物,将替换为。通用生命周期操作包括、、、、和。当输出需要被其他程序消费时,使用参数;可查看获取创建和日志相关的选项。
iosandroidcreatelistgetopen-urllogsdelete--jsonruncloud ios|android --helpiOS需要兼容Apple Silicon模拟器的、、或文件;经过设备签名的App Store IPA无法替代。Android需要兼容模拟器的APK文件。
.app.zip.tar.gz.ipaControl a Session
控制会话
Both platform groups expose acknowledged controls:
bash
runcloud ios tap "$SESSION_ID" 0.5 0.3 --json
runcloud ios swipe "$SESSION_ID" 0.5 0.8 0.5 0.2 --duration 300 --json
runcloud ios type-text "$SESSION_ID" 'hello' --json
runcloud ios press-key "$SESSION_ID" enter --json
runcloud ios press-button "$SESSION_ID" home --json
runcloud ios screenshot "$SESSION_ID" --output ios.png --jsonThe full control set is , , , , ,
, , , , ,
, , , and
. Every interaction accepts , , and
; use for its typed arguments.
tapswipegesturetype-textpress-keypress-buttonrotatereloadscrolltoggle-software-keyboardsimulate-memory-warningrotate-digital-crownset-render-debugscreenshot--request-id--timeout--jsonruncloud <platform> <control> --helpCoordinates use the current display orientation: is top-left and
is bottom-right. Gesture steps use one or two points with ,
, and phases. Each is the pause before the next step, so
the final step must use . Key names are semantic US-keyboard names;
modifiers are , , , and . Current mobile sessions do
not support Digital Crown input, and Android does not support iOS render-debug
controls or the , , and keys. Handle structured
errors instead of retrying them.
(0, 0)(1, 1)beginmoveenddelayMsend0shiftcontrolaltmetacapsLocknumLockscrollLockunsupported_actionAn acknowledgement means input dispatch completed. Confirm visible app effects
with a screenshot or the signed viewer when the outcome matters.
两个平台组均支持以下确认式控制操作:
bash
runcloud ios tap "$SESSION_ID" 0.5 0.3 --json
runcloud ios swipe "$SESSION_ID" 0.5 0.8 0.5 0.2 --duration 300 --json
runcloud ios type-text "$SESSION_ID" 'hello' --json
runcloud ios press-key "$SESSION_ID" enter --json
runcloud ios press-button "$SESSION_ID" home --json
runcloud ios screenshot "$SESSION_ID" --output ios.png --json完整的控制操作集包括、、、、、
、、、、、
、、和
。每个交互操作都支持、和参数;可使用查看其类型化参数。
tapswipegesturetype-textpress-keypress-buttonrotatereloadscrolltoggle-software-keyboardsimulate-memory-warningrotate-digital-crownset-render-debugscreenshot--request-id--timeout--jsonruncloud <platform> <control> --help坐标基于当前显示方向:为左上角,为右下角。手势步骤包含一个或两个点的、和阶段。每个是下一步操作前的暂停时间,因此最终的步骤必须设置为。按键名称为语义化美式键盘名称;修饰键包括、、和。当前移动会话不支持Digital Crown输入,Android不支持iOS的渲染调试控制以及、和按键。遇到结构化的错误时,应进行处理而非重试。
(0, 0)(1, 1)beginmoveenddelayMsend0shiftcontrolaltmetacapsLocknumLockscrollLockunsupported_action确认表示输入调度已完成。当结果至关重要时,可通过截图或已签名的查看器确认应用的可见效果。
Use the TypeScript SDK
使用TypeScript SDK
bash
npm install @run-cloud/sdkAlways release metered sessions in :
finallyts
import { writeFile } from "node:fs/promises";
import { Client } from "@run-cloud/sdk";
const cloud = new Client();
const session = await cloud.android.create({
inactivityTimeout: "60s",
hardTimeout: "10m",
tags: { owner: "agent" },
});
try {
await cloud.android.tap(session.id, { x: 0.5, y: 0.3 });
await cloud.android.typeText(session.id, "hello");
await cloud.android.pressKey(session.id, "enter");
const screenshot = await cloud.android.screenshot(session.id);
await writeFile("android.png", screenshot);
} finally {
await cloud.android.delete(session.id);
}cloud.ioscloud.androidcloud.simulatorsinteractrequestIdtimeoutMssignalRunCloudErrorcoderetryablerequestIdactionThe lifecycle surface also includes , , , , ,
, and . Both platforms expose ; iOS additionally
supports and . Inspect the installed types
for complete create, asset, log, and media options.
createlistgetopenUrllogsfollowLogsdeletescreenshotuploadVideouploadMicrophoneAudioIn compact form, : , , , , , , .
provides the same shared lifecycle and control operations.
cloud.ioscreatelistgetopenUrllogsfollowLogsscreenshotcloud.androidbash
npm install @run-cloud/sdk务必在块中释放计量会话:
finallyts
import { writeFile } from "node:fs/promises";
import { Client } from "@run-cloud/sdk";
const cloud = new Client();
const session = await cloud.android.create({
inactivityTimeout: "60s",
hardTimeout: "10m",
tags: { owner: "agent" },
});
try {
await cloud.android.tap(session.id, { x: 0.5, y: 0.3 });
await cloud.android.typeText(session.id, "hello");
await cloud.android.pressKey(session.id, "enter");
const screenshot = await cloud.android.screenshot(session.id);
await writeFile("android.png", screenshot);
} finally {
await cloud.android.delete(session.id);
}cloud.ioscloud.androidcloud.simulatorsinteractrequestIdtimeoutMssignalRunCloudErrorcoderetryablerequestIdaction生命周期接口还包括、、、、、
和。两个平台均支持;iOS额外支持和。可查看已安装的类型定义获取完整的创建、资源、日志和媒体相关选项。
createlistgetopenUrllogsfollowLogsdeletescreenshotuploadVideouploadMicrophoneAudio简洁来说,包含:、、、、、、。
提供相同的通用生命周期和控制操作。
cloud.ioscreatelistgetopenUrllogsfollowLogsscreenshotcloud.androidDiagnose App Failures
诊断应用故障
bash
runcloud ios logs "$SESSION_ID" --tail 1000
runcloud android logs "$SESSION_ID" --tail 1000Use while reproducing an issue. Before releasing a failed session,
capture a bounded retained snapshot; a follow stream contains only new entries.
--followbash
runcloud ios logs "$SESSION_ID" --tail 1000
runcloud android logs "$SESSION_ID" --tail 1000重现问题时可使用参数。释放故障会话前,捕获有限的保留快照;实时流仅包含新条目。
--followConnect Local Development
连接本地开发环境
Connect a local Metro or mock server through the supported sidecar flow:
bash
runcloud ios tunnel "$SESSION_ID" --local-port 8081 --service metro --json
runcloud ios tunnel-status --jsonDo not expose an unauthenticated third-party tunnel. If the sidecar is
unavailable, report that requirement instead of guessing a public URL.
通过支持的sidecar流程连接本地Metro或模拟服务器:
bash
runcloud ios tunnel "$SESSION_ID" --local-port 8081 --service metro --json
runcloud ios tunnel-status --json请勿暴露未认证的第三方隧道。若sidecar不可用,应报告该需求而非猜测公共URL。
Embed a Session
嵌入会话
- Use from
RemoteControlwith the signed session URL.@runcloud/ui - Its ref exposes promise-based and convenience methods matching the SDK controls. Handle
interactfor inspectable acknowledgements.onInteractionResult - Add to raw iframe URLs. Add
embed=1when interaction should wait for streaming and app readiness.loadingGuard=1 - Raw iframe requests use ; acknowledgements use
run-cloud:interaction. Correlate them byrun-cloud:interaction-result. To stop a pending request, postrequestIdwith the samerun-cloud:interaction-cancelandrequestId.action - Verify and the exact signed-URL origin, and use that origin as the
event.sourcetarget.postMessage - Legacy messages remain compatibility-only. Prefer the generic acknowledged interaction channel for new code.
ios-simulator:command - Create a new session after an message; never reuse an ended URL.
ios-simulator:session-restart-requested
- 使用中的
@runcloud/ui组件,传入已签名的会话URL。RemoteControl - 其ref对象提供基于Promise的方法,以及与SDK控制操作对应的便捷方法。可通过
interact处理可检查的确认信息。onInteractionResult - 在原始iframe URL中添加参数。当交互需等待流传输和应用就绪时,添加
embed=1参数。loadingGuard=1 - 原始iframe请求使用;确认信息使用
run-cloud:interaction。可通过run-cloud:interaction-result关联两者。要取消待处理请求,发送带有相同requestId和requestId的action消息。run-cloud:interaction-cancel - 验证和确切的已签名URL源,并将该源作为
event.source的目标。postMessage - 旧版消息仅保留兼容性。新代码建议使用通用的确认式交互通道。
ios-simulator:command - 收到消息后,创建新会话;切勿重用已结束的URL。
ios-simulator:session-restart-requested
Assets, Samples, and Demos
资源、示例与演示
bash
runcloud sample download ios
runcloud asset push ./build/MyApp.tar.gz --name my-app --json
runcloud asset pull <asset-id>
runcloud ios create --install-asset my-app --json
runcloud demo run eight-device-mosaic --open
runcloud demo run live-camera-relay --openDelete uploaded assets when no longer needed. Bundled demos release their
sessions automatically.
bash
runcloud sample download ios
runcloud asset push ./build/MyApp.tar.gz --name my-app --json
runcloud asset pull <asset-id>
runcloud ios create --install-asset my-app --json
runcloud demo run eight-device-mosaic --open
runcloud demo run live-camera-relay --open不再需要时删除已上传的资源。捆绑的演示会自动释放其会话。
Guardrails
防护准则
- Release every session created during a task unless asked to keep it open.
- Use inactivity and hard timeouts for unattended work.
- Verify artifact/platform compatibility before changing app code after an install failure.
- Do not expose credentials, signed viewer URLs, tunnel URLs, or simulator tokens in logs, screenshots, PR comments, or chat output.
- 除非要求保持会话开启,否则任务中创建的每个会话都需释放。
- 无人值守工作时使用闲置超时和硬超时设置。
- 安装失败后,在修改应用代码前验证产物与平台的兼容性。
- 切勿在日志、截图、PR评论或聊天输出中暴露凭证、已签名的查看器URL、隧道URL或模拟器令牌。