Control a real USB-connected iPhone from Linux (no Mac, no paid developer account) and expose it to AI agents as MCP tools
Rust ai-agentautomationclaudeclaude-codedockeriosiphonelinuxmcpmcp-servermodel-context-protocolrustwebdriveragent
feat(mcp): English tool descriptions and server instructions (#29)
TheSalatya6a766004fb3
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 7afe3d4..bc0d9c3 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -46,7 +46,7 @@ jobs:- uses: Swatinem/rust-cache@v2# vendor/ 是上游代码,不格式化;只检查本仓库的包- name: fmt- run: for p in ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done+ run: for p in ictl-l10n ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done# --all-features:默认不编的 debug-cmds(调试子命令)也要能编译- run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings- run: cargo test --workspace --all-features --lockeddiff --git a/CHANGELOG.md b/CHANGELOG.mdindex e016261..2941e50 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -6,6 +6,10 @@ All notable changes to this project are documented here. The format is based on## [Unreleased]+### Added++- English tool descriptions: with `IPHONE_CONTROL_LANG=en` the MCP server instructions and all tool descriptions are in English. The default stays Simplified Chinese, so nothing changes unless you set it.+## [0.1.4] - 2026-11-07### Securitydiff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.mdindex abb3991..a346c3e 100644--- a/CHANGELOG.zh-CN.md+++ b/CHANGELOG.zh-CN.md@@ -6,6 +6,10 @@## [Unreleased]+### 新增++- 英文工具说明:设 `IPHONE_CONTROL_LANG=en` 后,MCP 服务说明和全部工具说明改成英文。默认仍是简体中文,不设就没有任何变化。+## [0.1.4] - 2026-11-07### 安全diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 39bda08..834932e 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -19,7 +19,7 @@ You need Rust 1.88 or later (CI pins 1.99.1) and a C compiler. Everything exceptcargo test --workspace --all-features --lockedcargo clippy --workspace --all-targets --all-features --locked -- -D warnings# vendor/ is upstream code and isn't formatted; check only this repository's packages:-for p in ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done+for p in ictl-l10n ictl-device ictl-wda ictl-sign ictl-unlock ictl-daemon ictl-mcp ictl-protocol iphone-control; do cargo fmt -p $p -- --check; done```Or, without Rust installed:diff --git a/Cargo.lock b/Cargo.lockindex d6465f5..c324df8 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -1979,11 +1979,19 @@ dependencies = ["uuid",]+[[package]]+name = "ictl-l10n"+version = "0.1.4"+dependencies = [+ "tokio",+]+[[package]]name = "ictl-mcp"version = "0.1.4"dependencies = ["anyhow",+ "ictl-l10n","ictl-protocol","rmcp","serde_json",diff --git a/Cargo.toml b/Cargo.tomlindex 1f609a9..256183c 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -4,6 +4,7 @@ members = ["crates/ictl-device","crates/ictl-wda","crates/ictl-protocol",+ "crates/ictl-l10n","crates/ictl-sign","crates/ictl-unlock","crates/ictl-daemon",@@ -73,6 +74,7 @@ plume_store = { path = "vendor/plume_store" }ictl-device = { path = "crates/ictl-device" }ictl-wda = { path = "crates/ictl-wda" }ictl-protocol = { path = "crates/ictl-protocol" }+ictl-l10n = { path = "crates/ictl-l10n" }ictl-sign = { path = "crates/ictl-sign" }ictl-unlock = { path = "crates/ictl-unlock" }ictl-daemon = { path = "crates/ictl-daemon" }diff --git a/crates/ictl-l10n/Cargo.toml b/crates/ictl-l10n/Cargo.tomlnew file mode 100644index 0000000..e15c8db--- /dev/null+++ b/crates/ictl-l10n/Cargo.toml@@ -0,0 +1,13 @@+[package]+name = "ictl-l10n"+version.workspace = true+edition.workspace = true+rust-version.workspace = true+license.workspace = true+publish.workspace = true+repository.workspace = true+homepage.workspace = true+description = "Language of user- and agent-facing text (Simplified Chinese or English), chosen by IPHONE_CONTROL_LANG"++[dependencies]+tokio.workspace = truediff --git a/crates/ictl-l10n/src/lib.rs b/crates/ictl-l10n/src/lib.rsnew file mode 100644index 0000000..f77e572--- /dev/null+++ b/crates/ictl-l10n/src/lib.rs@@ -0,0 +1,174 @@+//! Language of the text that people and agents see: tool descriptions and results, CLI output,+//! `status` / `doctor`, logs and notifications.+//!+//! Every message is written in place as a pair, `tr!("中文", "English")`, so both versions stay next to+//! each other and can be reviewed together; there is no separate catalog to keep in sync.+//! `trf!` is the `format!` counterpart (same placeholders in both literals).+//!+//! The language is read once from `IPHONE_CONTROL_LANG` (`en`/`english`/`en_US…` → English,+//! `zh`/`chinese`/`zh_CN…` → Chinese). Unset or unknown keeps Simplified Chinese, the language the+//! project started with, so existing setups don't change.+//!+//! The client decides: the MCP server and the CLI send their language with every request, and the daemon+//! answers that request in it ([`scope`]). Requests from older clients carry no language and get Chinese.+//! The daemon's own setting only applies to what it writes by itself (event log, notifications).++use std::cell::Cell;+use std::sync::atomic::{AtomicU8, Ordering};++#[derive(Debug, Clone, Copy, PartialEq, Eq)]+pub enum Lang {+ Zh,+ En,+}++/// 0 = not decided yet, 1 = Chinese, 2 = English+static LANG: AtomicU8 = AtomicU8::new(0);++/// Environment variable that selects the language+pub const ENV: &str = "IPHONE_CONTROL_LANG";++/// Parse a language name; `None` for anything unrecognised+pub fn parse(value: &str) -> Option<Lang> {+ let v = value.trim().to_ascii_lowercase();+ let v = v.split(['_', '-', '.']).next().unwrap_or_default();+ match v {+ "en" | "english" => Some(Lang::En),+ "zh" | "chinese" | "cn" => Some(Lang::Zh),+ _ => None,+ }+}++thread_local! {+ /// Per-thread override for [`with_lang`]: 0 = none+ static OVERRIDE: Cell<u8> = const { Cell::new(0) };+}++fn decode(v: u8) -> Option<Lang> {+ match v {+ 1 => Some(Lang::Zh),+ 2 => Some(Lang::En),+ _ => None,+ }+}++fn encode(l: Lang) -> u8 {+ if l == Lang::En { 2 } else { 1 }+}++tokio::task_local! {+ /// Language of the request being handled (see [`scope`])+ static TASK_LANG: Lang;+}++/// Run `f` (one request) in language `l`: every text it produces, across `.await`s, uses `l`.+/// Work moved to another thread (`spawn_blocking`) has to take [`lang`] along and use [`with_lang`]+pub async fn scope<F: std::future::Future>(l: Lang, f: F) -> F::Output {+ TASK_LANG.scope(l, f).await+}++/// The current language: a [`with_lang`] override, else the request's ([`scope`]), else the process+/// setting (decided on first use)+pub fn lang() -> Lang {+ if let Some(l) = decode(OVERRIDE.with(Cell::get)) {+ return l;+ }+ if let Ok(l) = TASK_LANG.try_with(|l| *l) {+ return l;+ }+ match LANG.load(Ordering::Relaxed) {+ 1 => Lang::Zh,+ 2 => Lang::En,+ _ => {+ let l = std::env::var(ENV).ok().and_then(|v| parse(&v)).unwrap_or(Lang::Zh);+ set(l);+ l+ }+ }+}++/// Override the language for this process+pub fn set(l: Lang) {+ LANG.store(encode(l), Ordering::Relaxed);+}++/// Run `f` with the language set to `l` on this thread only (tests run in parallel and must not+/// change each other's language)+pub fn with_lang<T>(l: Lang, f: impl FnOnce() -> T) -> T {+ let prev = OVERRIDE.with(|o| o.replace(encode(l)));+ let r = f();+ OVERRIDE.with(|o| o.set(prev));+ r+}++pub fn is_en() -> bool {+ lang() == Lang::En+}++impl Lang {+ /// Short name on the wire: `zh` / `en`+ pub fn code(self) -> &'static str {+ match self {+ Lang::Zh => "zh",+ Lang::En => "en",+ }+ }+}++/// Pick the Chinese or English version of a fixed text: `tr!("设备未连接", "Device not connected")`+#[macro_export]+macro_rules! tr {+ ($zh:literal, $en:literal $(,)?) => {+ if $crate::is_en() { $en } else { $zh }+ };+}++/// `format!` in the current language: `trf!("第 {n} 步", "step {n}")`, extra arguments as in `format!`+#[macro_export]+macro_rules! trf {+ ($zh:literal, $en:literal $(, $arg:expr)* $(,)?) => {+ if $crate::is_en() { format!($en $(, $arg)*) } else { format!($zh $(, $arg)*) }+ };+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn parses_language_names() {+ assert_eq!(parse("en"), Some(Lang::En));+ assert_eq!(parse("en_US.UTF-8"), Some(Lang::En));+ assert_eq!(parse(" English "), Some(Lang::En));+ assert_eq!(parse("zh_CN"), Some(Lang::Zh));+ assert_eq!(parse("zh-Hans"), Some(Lang::Zh));+ assert_eq!(parse("de"), None);+ assert_eq!(parse(""), None);+ }++ #[tokio::test]+ async fn scope_sets_the_language_across_awaits() {+ let inner = scope(Lang::En, async {+ tokio::task::yield_now().await;+ tr!("中", "en")+ })+ .await;+ assert_eq!(inner, "en");+ let inner = scope(Lang::Zh, async { with_lang(Lang::En, || tr!("中", "en")) }).await;+ assert_eq!(inner, "en", "with_lang wins over scope");+ }++ #[test]+ fn macros_follow_the_language() {+ let n = 3;+ with_lang(Lang::En, || {+ assert_eq!(tr!("设备未连接", "Device not connected"), "Device not connected");+ assert_eq!(trf!("第 {n} 步", "step {n}"), "step 3");+ assert_eq!(trf!("{} 秒", "{} s", 1.5), "1.5 s");+ });+ with_lang(Lang::Zh, || {+ assert_eq!(tr!("设备未连接", "Device not connected"), "设备未连接");+ assert_eq!(trf!("第 {n} 步", "step {n}"), "第 3 步");+ });+ }+}diff --git a/crates/ictl-mcp/Cargo.toml b/crates/ictl-mcp/Cargo.tomlindex 14836a0..666cba4 100644--- a/crates/ictl-mcp/Cargo.toml+++ b/crates/ictl-mcp/Cargo.toml@@ -10,6 +10,7 @@ homepage.workspace = truedescription = "MCP stdio 服务(17 个 iphone_* 工具)"[dependencies]+ictl-l10n.workspace = trueictl-protocol.workspace = truetokio.workspace = truermcp.workspace = truediff --git a/crates/ictl-mcp/src/lib.rs b/crates/ictl-mcp/src/lib.rsindex 87ade69..6672130 100644--- a/crates/ictl-mcp/src/lib.rs+++ b/crates/ictl-mcp/src/lib.rs@@ -19,14 +19,19 @@ use rmcp::{use serde_json::{Map, Value, json};/// 服务说明(发给客户端的 instructions):toolkit 的那段,加上自动解锁范围、多设备的说明-pub const INSTRUCTIONS: &str = "控制一台通过 USB 连接的真实 iPhone(或 iPad)。坐标单位是点(pt),与 iphone_screenshot 图像像素一致。\+pub fn instructions() -> &'static str {+ ictl_l10n::tr!(+ "控制一台通过 USB 连接的真实 iPhone(或 iPad)。坐标单位是点(pt),与 iphone_screenshot 图像像素一致。\操作前先用 iphone_screenshot 或 iphone_list_elements 看清屏幕;能按名字点就优先用 iphone_tap_element。\游戏、地图等界面没有元素树,只能看截图按坐标操作;小图标、小字看不清时用 iphone_screenshot 的区域放大。\配置了锁屏密码时,截图、读元素在内的各工具都会先自动解锁。每次操作后再截图确认结果。\涉及付款、删除、发送消息、修改账号或隐私设置的操作,先向用户确认。\省时间:操作类工具可带 then=elements 或 then=screenshot,等界面稳定后顺带返回操作后的界面,不用再单独调一次;\几步确定的连续操作(按键、逐级点菜单、填表)用 iphone_batch 一次发完;等页面加载用 iphone_wait_for,不要反复截图。\-接着多台 iPhone/iPad 时同一时间只控制一台:用 iphone_list_devices 查看,iphone_select_device 切换。";+接着多台 iPhone/iPad 时同一时间只控制一台:用 iphone_list_devices 查看,iphone_select_device 切换。",+ "Controls a real iPhone (or iPad) connected over USB. Coordinates are in points (pt), the same as the pixels of an iphone_screenshot image. Before acting, look at the screen with iphone_screenshot or iphone_list_elements; prefer iphone_tap_element whenever the target has text. Games, maps and similar screens have no element tree: work from screenshots and coordinates, and zoom into small icons or text with an iphone_screenshot region. If a passcode is configured, the tools (including screenshots and reading elements) unlock the phone first. Check the result with a screenshot after each action. Ask the user before anything that pays, deletes, sends a message, or changes account or privacy settings. Save time: action tools accept then=elements or then=screenshot to return the screen once it has settled, without a separate call; send a few predictable steps in a row (keys, menu levels, forms) as one iphone_batch; wait for a page with iphone_wait_for instead of repeated screenshots. With several iPhones/iPads connected only one is controlled at a time: see them with iphone_list_devices, switch with iphone_select_device."+ )+}fn num(desc: &str) -> Value {json!({"type": "number", "description": desc})@@ -64,12 +69,12 @@ pub const BATCH_TOOLS: [&str; 11] = [fn then_props() -> Value {json!({"then": {"type": "string", "enum": ["none", "elements", "screenshot"], "default": "none",- "description": "操作后等界面稳定,再顺带返回界面:elements=元素列表(最多 80 个),screenshot=截图。省一次单独的调用"},- "then_filter": {"type": "string", "default": "", "description": "then=elements 时只列包含这段文字的元素"},+ "description": ictl_l10n::tr!("操作后等界面稳定,再顺带返回界面:elements=元素列表(最多 80 个),screenshot=截图。省一次单独的调用", "After the action, wait for the screen to settle and return it: elements = element list (up to 80), screenshot = screenshot. Saves a separate call")},+ "then_filter": {"type": "string", "default": "", "description": ictl_l10n::tr!("then=elements 时只列包含这段文字的元素", "With then=elements: only list elements containing this text")},"then_region": {"type": "array", "items": {"type": "number"}, "minItems": 4, "maxItems": 4,- "description": "then=screenshot 时只返回这块区域的放大图 [x, y, width, height](点),例如游戏棋盘"},+ "description": ictl_l10n::tr!("then=screenshot 时只返回这块区域的放大图 [x, y, width, height](点),例如游戏棋盘", "With then=screenshot: only return this region, enlarged, as [x, y, width, height] (points), e.g. a game board")},"then_settle": {"type": "number", "default": 1.5,- "description": "顺带返回界面前最多等几秒让界面稳定(不超过 10)。游戏、地图按画面是否静止判断,消除连锁等长动画可调大,画面一静止就返回"}+ "description": ictl_l10n::tr!("顺带返回界面前最多等几秒让界面稳定(不超过 10)。游戏、地图按画面是否静止判断,消除连锁等长动画可调大,画面一静止就返回", "Maximum seconds to wait for the screen to settle before returning it (up to 10). Games and maps are judged by whether the picture is still; raise it for long animations such as chain reactions, it returns as soon as the picture is still")}})}@@ -85,12 +90,21 @@ fn with_then(props: Value) -> Value {/// 操作类工具描述的共同结尾:返回什么、then 能做什么、自动解锁。/// `alert`:不带 then 时会不会查系统弹窗(见 [`wants_alert_check`])fn action_desc(body: &str, example: &str, alert: bool) -> String {- let mut s = format!("{body}\n\n返回:一行结果文字,例如「{example}」。");+ let mut s = ictl_l10n::trf!(+ "{body}\n\n返回:一行结果文字,例如「{example}」。",+ "{body}\n\nReturns: one line of result text, e.g. “{example}”."+ );if alert {- s += "不带 then 时,如果系统弹窗挡着屏幕,结果里会提醒(这时操作落在了弹窗上)。";+ s += ictl_l10n::tr!(+ "不带 then 时,如果系统弹窗挡着屏幕,结果里会提醒(这时操作落在了弹窗上)。",+ " Without then, the result warns if a system alert covers the screen (the action then landed on the alert)."+ );}- s += "传 then=elements 或 then=screenshot 会等界面稳定后附上操作后的元素列表或截图,省一次单独的调用。\-配置了锁屏密码时会先自动解锁。";+ s += ictl_l10n::tr!(+ "传 then=elements 或 then=screenshot 会等界面稳定后附上操作后的元素列表或截图,省一次单独的调用。\+配置了锁屏密码时会先自动解锁。",+ " With then=elements or then=screenshot it waits for the screen to settle and attaches the element list or screenshot after the action, saving a separate call. If a passcode is configured, the phone is unlocked first."+ );s}@@ -112,282 +126,282 @@ pub fn tools() -> Vec<Tool> {};let app = || {json!({"app": {"type": "string",- "description": "Bundle ID(如 com.apple.Preferences)或显示名(如「设置」「微信」)"}})+ "description": ictl_l10n::tr!("Bundle ID(如 com.apple.Preferences)或显示名(如「设置」「微信」)", "Bundle ID (e.g. com.apple.Preferences) or display name (e.g. “Settings”)")}})};vec![t("iphone_status",- "查看手机和服务的状态:WDA(WebDriverAgent)是否就绪、是否锁屏、能否自动解锁、当前前台 App 的 Bundle ID、\+ ictl_l10n::tr!("查看手机和服务的状态:WDA(WebDriverAgent)是否就绪、是否锁屏、能否自动解锁、当前前台 App 的 Bundle ID、\屏幕尺寸(点)、守护进程状态。\n\n何时用:开始操作前确认手机可用;操作报错、怀疑 WDA 掉线或手机锁屏时排查。\-WDA 不可用时会说明哪些功能受影响(读元素、按名字点击、启动 App、输入中文)。只读,不改变手机状态。"+WDA 不可用时会说明哪些功能受影响(读元素、按名字点击、启动 App、输入中文)。只读,不改变手机状态。", "Show the state of the phone and the service: whether WDA (WebDriverAgent) is ready, whether the phone is locked and can be auto-unlocked, the bundle ID of the foreground app, the screen size (points) and the daemon state.\n\nWhen to use: to check that the phone is usable before starting; to investigate when actions fail or WDA or the lock screen seem to be in the way. If WDA is unavailable it says which features are affected (reading elements, tapping by text, launching apps, typing non-ASCII text). Read-only, doesn't change the phone.").into(),schema(json!({}), &[]),- looking("查看状态"),+ looking(ictl_l10n::tr!("查看状态", "Show status")),),t("iphone_screenshot",- "截取当前屏幕,返回 JPEG 图像和一行说明。图像已缩放到点尺寸,图中像素坐标可直接用于 iphone_tap、iphone_swipe。\n\n\+ ictl_l10n::tr!("截取当前屏幕,返回 JPEG 图像和一行说明。图像已缩放到点尺寸,图中像素坐标可直接用于 iphone_tap、iphone_swipe。\n\n\看不清小图标、小字时,传 x/y/width/height(点,四个要一起给)放大这块区域:从原始高清截图裁剪,小区域再额外放大。\返回文字里有放大倍数,图中坐标换算回屏幕点:x + 像素/倍数。\n\n\何时用:游戏、地图、图片等没有元素树的界面,或要确认画面效果时。只想知道有哪些按钮、文字,iphone_list_elements 更快更省上下文。\操作后要看结果时,优先给操作工具带 then=screenshot。WDA 不可用时改用 CoreDevice 截图(iOS 27 起,说明里注明「HID」)。\-只读:不改变界面,但配置了锁屏密码时会先解锁。"+只读:不改变界面,但配置了锁屏密码时会先解锁。", "Capture the current screen and return a JPEG image plus a line of explanation. The image is scaled to points, so its pixel coordinates can be used directly with iphone_tap and iphone_swipe.\n\nTo read small icons or text, pass x/y/width/height (points, all four together) to zoom into that region: it is cropped from the full-resolution capture, and small regions are enlarged further. The text gives the zoom factor; convert image coordinates back to screen points with x + pixel / factor.\n\nWhen to use: screens without an element tree (games, maps, images), or to check how something looks. To find out which buttons and texts are there, iphone_list_elements is faster and uses less context. To see the result of an action, prefer then=screenshot on the action tool. If WDA is unavailable it uses a CoreDevice screenshot instead (iOS 27+, marked “HID”). Read-only: doesn't change the screen, but unlocks the phone first if a passcode is configured.").into(),schema(- json!({"x": num("区域左上角 x(点)"), "y": num("区域左上角 y(点)"), "width": num("区域宽(点)"), "height": num("区域高(点)")}),+ json!({"x": num(ictl_l10n::tr!("区域左上角 x(点)", "left edge x of the region (points)")), "y": num(ictl_l10n::tr!("区域左上角 y(点)", "top edge y of the region (points)")), "width": num(ictl_l10n::tr!("区域宽(点)", "region width (points)")), "height": num(ictl_l10n::tr!("区域高(点)", "region height (points)"))}),&[],),- looking("截图"),+ looking(ictl_l10n::tr!("截图", "Screenshot")),),t("iphone_list_elements",- "列出屏幕上带文字的界面元素,每行一个:类型、标签、名字、值、中心点坐标、尺寸(点)。\n\n\+ ictl_l10n::tr!("列出屏幕上带文字的界面元素,每行一个:类型、标签、名字、值、中心点坐标、尺寸(点)。\n\n\何时用:找按钮、输入框、列表项的文字和位置,比截图快、省上下文;找到后用 iphone_tap_element 按文字点。\游戏、地图等没有元素树的界面这里是空的,改用 iphone_screenshot。\n\n\注意:按坐标判断是否在屏幕内,被弹窗遮住的元素也可能列出来,不确定时截图核对。需要 WDA。\-只读:不改变界面,但配置了锁屏密码时会先解锁。"+只读:不改变界面,但配置了锁屏密码时会先解锁。", "List the UI elements on screen that carry text, one per line: type, label, name, value, center point and size (points).\n\nWhen to use: to find buttons, text fields and list items with their text and position; faster than a screenshot and uses less context. Then tap one by its text with iphone_tap_element. Games, maps and other screens without an element tree return nothing here; use iphone_screenshot.\n\nNote: visibility is judged by position, so elements hidden behind an alert can still be listed; check with a screenshot when in doubt. Needs WDA. Read-only: doesn't change the screen, but unlocks the phone first if a passcode is configured.").into(),schema(json!({"filter": {"type": "string", "default": "",- "description": "只返回类型/标签/名字/值里包含这段文字的元素(不区分大小写),例如 SearchField、Button、登录"},- "limit": {"type": "integer", "default": 150, "description": "最多列几个,多出的只报数量"}+ "description": ictl_l10n::tr!("只返回类型/标签/名字/值里包含这段文字的元素(不区分大小写),例如 SearchField、Button、登录", "Only return elements whose type/label/name/value contains this text (case-insensitive), e.g. SearchField, Button, Login")},+ "limit": {"type": "integer", "default": 150, "description": ictl_l10n::tr!("最多列几个,多出的只报数量", "Maximum number of elements to list; the rest are only counted")}}),&[],),- looking("列出界面元素"),+ looking(ictl_l10n::tr!("列出界面元素", "List UI elements")),),t("iphone_tap",action_desc(- "点击屏幕上的一个坐标(单位是点,与 iphone_screenshot 全屏图的像素一致,左上角为原点)。\n\n\+ ictl_l10n::tr!("点击屏幕上的一个坐标(单位是点,与 iphone_screenshot 全屏图的像素一致,左上角为原点)。\n\n\何时用:目标没有文字(图标、图片)、在游戏或地图里,或 iphone_list_elements 里找不到它时。\带文字的按钮、列表项优先用 iphone_tap_element,界面布局变了也点得准。按住用 iphone_long_press,滚动用 iphone_swipe。\n\n\行为:单指按下约 0.05 秒后抬起,点一次。不检查坐标上是什么,点之前先截图确认位置。\-WDA 不可用时改用 CoreDevice HID(iOS 27 起;结果里注明「经 HID」)。",- "已点击 (120,300)",+WDA 不可用时改用 CoreDevice HID(iOS 27 起;结果里注明「经 HID」)。", "Tap a point on the screen (in points, the same as the pixels of a full-screen iphone_screenshot, origin at the top left).\n\nWhen to use: the target has no text (icon, image), is in a game or map, or can't be found with iphone_list_elements. For buttons and list items with text prefer iphone_tap_element, which keeps working when the layout changes. Use iphone_long_press to hold and iphone_swipe to scroll.\n\nBehavior: one finger down for about 0.05 s, then up; a single tap. It doesn't check what is at that point, so look at a screenshot first. If WDA is unavailable it uses CoreDevice HID instead (iOS 27+; the result says “via HID”)."),+ ictl_l10n::tr!("已点击 (120,300)", "Tapped (120,300)"),true,),- schema(with_then(json!({"x": num("x(点)"), "y": num("y(点)")})), &["x", "y"]),- acting("点击坐标", true, false),+ schema(with_then(json!({"x": num(ictl_l10n::tr!("x(点)", "x (points)")), "y": num(ictl_l10n::tr!("y(点)", "y (points)"))})), &["x", "y"]),+ acting(ictl_l10n::tr!("点击坐标", "Tap point"), true, false),),t("iphone_tap_element",action_desc(- "按文字点击界面元素:先找标签/名字与 text 完全相同的,找不到再找包含 text 的。\+ ictl_l10n::tr!("按文字点击界面元素:先找标签/名字与 text 完全相同的,找不到再找包含 text 的。\中心被悬浮栏、键盘等盖住时改点没被盖住的部分,整个被盖住就不点。\n\n\何时用:按钮、列表项、标签页等带文字的元素,优先用它而不是按坐标点。不确定文字怎么写时先 iphone_list_elements。\没有文字的图标、游戏、地图用 iphone_tap。\n\n\-行为:没找到、index 超出匹配个数或整个被盖住时不点,返回原因(不算出错;在 iphone_batch 里会让批量停下)。需要 WDA。",- "已点击 Button \"通用\"",+行为:没找到、index 超出匹配个数或整个被盖住时不点,返回原因(不算出错;在 iphone_batch 里会让批量停下)。需要 WDA。", "Tap a UI element by its text: first an exact match of label or name with text, otherwise one that contains text. If its center is covered by a floating bar, the keyboard or similar, it taps an uncovered part; if it is completely covered, it doesn't tap.\n\nWhen to use: buttons, list items, tabs and other elements with text; prefer this over coordinates. If unsure how the text is written, use iphone_list_elements first. For icons without text, games and maps use iphone_tap.\n\nBehavior: when nothing matches, index is beyond the number of matches, or the element is completely covered, it doesn't tap and says why (not an error; inside iphone_batch it stops the batch). Needs WDA."),+ ictl_l10n::tr!("已点击 Button \"通用\"", "Tapped Button \"General\""),true,),schema(with_then(json!({- "text": {"type": "string", "description": "元素的文字(标签或名字),先精确匹配再按包含匹配"},+ "text": {"type": "string", "description": ictl_l10n::tr!("元素的文字(标签或名字),先精确匹配再按包含匹配", "the element's text (label or name); exact match first, then substring")},"index": {"type": "integer", "default": 0,- "description": "匹配到多个时点第几个(从 0 开始,顺序同 iphone_list_elements)"}+ "description": ictl_l10n::tr!("匹配到多个时点第几个(从 0 开始,顺序同 iphone_list_elements)", "which match to tap if there are several (from 0, same order as iphone_list_elements)")}})),&["text"],),- acting("按文字点击", true, false),+ acting(ictl_l10n::tr!("按文字点击", "Tap by text"), true, false),),t("iphone_long_press",action_desc(- "在屏幕坐标(点)上单指按住 seconds 秒再抬起,手指不移动。\n\n\+ ictl_l10n::tr!("在屏幕坐标(点)上单指按住 seconds 秒再抬起,手指不移动。\n\n\何时用:要长按才出现的操作,例如主屏图标的快捷菜单、消息或图片的上下文菜单、选中文字。\普通点击用 iphone_tap 或 iphone_tap_element;要移动手指(滚动、拖滑块)用 iphone_swipe。\n\n\行为:只按一次。按得太短(不到约 0.5 秒)系统可能当成普通点击。长按弹出的菜单不会自己消失,\-下一步先看屏幕(或直接带 then=screenshot)。需要 WDA。",- "已长按 (200,400) 1 秒",+下一步先看屏幕(或直接带 then=screenshot)。需要 WDA。", "Hold one finger still at a screen point (points) for seconds, then lift.\n\nWhen to use: actions that need a long press, such as home-screen quick actions, context menus on messages or images, or selecting text. For normal taps use iphone_tap or iphone_tap_element; to move the finger (scroll, drag a slider) use iphone_swipe.\n\nBehavior: a single press. Too short a press (under about 0.5 s) may count as a normal tap. Menus opened by a long press stay open, so look at the screen next (or pass then=screenshot). Needs WDA."),+ ictl_l10n::tr!("已长按 (200,400) 1 秒", "Long-pressed (200,400) for 1 s"),true,),schema(with_then(json!({- "x": num("x(点)"),- "y": num("y(点)"),- "seconds": {"type": "number", "default": 1.0, "description": "按住几秒,默认 1"}+ "x": num(ictl_l10n::tr!("x(点)", "x (points)")),+ "y": num(ictl_l10n::tr!("y(点)", "y (points)")),+ "seconds": {"type": "number", "default": 1.0, "description": ictl_l10n::tr!("按住几秒,默认 1", "seconds to hold, default 1")}})),&["x", "y"],),- acting("长按", true, false),+ acting(ictl_l10n::tr!("长按", "Long press"), true, false),),t("iphone_swipe",action_desc(- "单指从 (from_x, from_y) 按下,用 seconds 秒移到 (to_x, to_y) 后抬起(坐标单位是点)。\n\n\+ ictl_l10n::tr!("单指从 (from_x, from_y) 按下,用 seconds 秒移到 (to_x, to_y) 后抬起(坐标单位是点)。\n\n\何时用:滚动列表或页面、左右翻页、拖动滑块。向上滑看下面的内容:from_y 大、to_y 小(例如 y 从 700 滑到 300);\向左滑看右边的内容:from_x 大、to_x 小。点击用 iphone_tap,原地按住用 iphone_long_press。\n\n\行为:seconds 越小滑得越快,快滑会带惯性多滚一段;要精确移动(滑块)把 seconds 调到 1 秒左右。\-滑完会等列表停止滚动(最多 2.5 秒)再返回,还在滚就在结果里说明。WDA 不可用时改用 CoreDevice HID(iOS 27 起)。",- "已滑动 (215,700) → (215,300)",+滑完会等列表停止滚动(最多 2.5 秒)再返回,还在滚就在结果里说明。WDA 不可用时改用 CoreDevice HID(iOS 27 起)。", "One finger down at (from_x, from_y), moving to (to_x, to_y) over seconds, then up (coordinates in points).\n\nWhen to use: scroll a list or page, page left or right, drag a slider. To see content further down, swipe up: from_y large, to_y small (e.g. y from 700 to 300); to see content to the right, swipe left: from_x large, to_x small. Use iphone_tap to tap and iphone_long_press to hold in place.\n\nBehavior: the smaller seconds, the faster the swipe; a fast swipe keeps scrolling with momentum. For precise moves (sliders) use about 1 second. It waits until the list stops scrolling (up to 2.5 s) before returning and says so if it is still moving. If WDA is unavailable it uses CoreDevice HID instead (iOS 27+)."),+ ictl_l10n::tr!("已滑动 (215,700) → (215,300)", "Swiped (215,700) → (215,300)"),true,),schema(with_then(json!({- "from_x": num("起点 x(点)"),- "from_y": num("起点 y(点)"),- "to_x": num("终点 x(点)"),- "to_y": num("终点 y(点)"),- "seconds": {"type": "number", "default": 0.3, "description": "滑动用时(秒),默认 0.3;越小越快、惯性越大"}+ "from_x": num(ictl_l10n::tr!("起点 x(点)", "start x (points)")),+ "from_y": num(ictl_l10n::tr!("起点 y(点)", "start y (points)")),+ "to_x": num(ictl_l10n::tr!("终点 x(点)", "end x (points)")),+ "to_y": num(ictl_l10n::tr!("终点 y(点)", "end y (points)")),+ "seconds": {"type": "number", "default": 0.3, "description": ictl_l10n::tr!("滑动用时(秒),默认 0.3;越小越快、惯性越大", "swipe duration (seconds), default 0.3; smaller is faster with more momentum")}})),&["from_x", "from_y", "to_x", "to_y"],),- acting("滑动", false, false),+ acting(ictl_l10n::tr!("滑动", "Swipe"), false, false),),t("iphone_type_text",action_desc(- "在当前获得焦点的输入框里输入文字(支持中文),从光标处输入,不会清空原有内容。submit=true 时末尾按回车。\n\n\+ ictl_l10n::tr!("在当前获得焦点的输入框里输入文字(支持中文),从光标处输入,不会清空原有内容。submit=true 时末尾按回车。\n\n\何时用:搜索框、表单、聊天框等。要先点中输入框让键盘弹出;屏幕上没有键盘时报错,什么都不输。\回车可能会发送消息或提交表单,发送前先向用户确认。\n\n\行为:输完会读回输入框核对,少了结尾几个字会自动补上;对不上就报错,也不按回车。\-WDA 不可用时改用 HID(iOS 27 起),只能输入美式键盘上的英文和符号。",- "已输入 4 个字符,并按了回车",+WDA 不可用时改用 HID(iOS 27 起),只能输入美式键盘上的英文和符号。", "Type text into the focused text field (any language, including Chinese) at the cursor, without clearing what is already there. With submit=true it presses Return at the end.\n\nWhen to use: search boxes, forms, chat fields. Tap the field first so the keyboard comes up; with no keyboard on screen it fails and types nothing. Return may send a message or submit a form, so ask the user before sending.\n\nBehavior: it reads the field back afterwards; dropped trailing characters are typed again. If it still doesn't match, it reports an error and doesn't press Return. If WDA is unavailable it uses HID instead (iOS 27+), which can only type English letters and symbols of a US keyboard."),+ ictl_l10n::tr!("已输入 4 个字符,并按了回车", "Typed 4 characters and pressed Return"),true,),schema(with_then(json!({- "text": {"type": "string", "description": "要输入的文字"},- "submit": {"type": "boolean", "default": false, "description": "输完后按回车(搜索、发送、提交)"}+ "text": {"type": "string", "description": ictl_l10n::tr!("要输入的文字", "the text to type")},+ "submit": {"type": "boolean", "default": false, "description": ictl_l10n::tr!("输完后按回车(搜索、发送、提交)", "press Return afterwards (search, send, submit)")}})),&["text"],),- acting("输入文字", false, false),+ acting(ictl_l10n::tr!("输入文字", "Type text"), false, false),),t("iphone_press_button",action_desc(- "按硬件键:home(回主屏幕)、volume_up、volume_down、lock(锁屏)。\n\n\+ ictl_l10n::tr!("按硬件键:home(回主屏幕)、volume_up、volume_down、lock(锁屏)。\n\n\何时用:离开当前 App 回主屏幕用 home(App 留在后台,要彻底关掉用 iphone_terminate_app);调音量;锁屏。\锁屏后配置了密码的话,下一个操作会先自动解锁。\n\n\-行为:系统弹窗挡着时按 home 不会生效,这时不按,并提示先点弹窗上的按钮。按 home 会等主屏真的到前台再返回。",- "已按 home",+行为:系统弹窗挡着时按 home 不会生效,这时不按,并提示先点弹窗上的按钮。按 home 会等主屏真的到前台再返回。", "Press a hardware button: home (go to the home screen), volume_up, volume_down, lock (lock the screen).\n\nWhen to use: leave the current app with home (the app stays in the background; use iphone_terminate_app to quit it); change the volume; lock the phone. After locking, if a passcode is configured, the next action unlocks first.\n\nBehavior: while a system alert covers the screen home has no effect, so it isn't pressed and the result says to tap a button on the alert first. home waits until the home screen is really in front before returning."),+ ictl_l10n::tr!("已按 home", "Pressed home"),false,),schema(with_then(json!({"button": {"type": "string", "enum": ["home", "volume_up", "volume_down", "lock"],- "description": "home、volume_up、volume_down 或 lock"}})),+ "description": ictl_l10n::tr!("home、volume_up、volume_down 或 lock", "home, volume_up, volume_down or lock")}})),&["button"],),- acting("按硬件键", false, false),+ acting(ictl_l10n::tr!("按硬件键", "Press button"), false, false),),t("iphone_list_apps",- "列出已安装的 App,每行一个:显示名和 Bundle ID。\n\n\+ ictl_l10n::tr!("列出已安装的 App,每行一个:显示名和 Bundle ID。\n\n\何时用:iphone_launch_app、iphone_terminate_app 报「找不到名为…的 App」时,查准确的名字或 Bundle ID。\-默认只列用户装的 App;设置、相机等系统 App 要 include_system=true(要多花几秒)。结果有缓存。只读。"+默认只列用户装的 App;设置、相机等系统 App 要 include_system=true(要多花几秒)。结果有缓存。只读。", "List installed apps, one per line: display name and bundle ID.\n\nWhen to use: when iphone_launch_app or iphone_terminate_app report “No app named …”, to look up the exact name or bundle ID. By default only user-installed apps; system apps such as Settings or Camera need include_system=true (takes a few seconds longer). Results are cached. Read-only.").into(),schema(- json!({"include_system": {"type": "boolean", "default": false, "description": "同时列出系统 App"}}),+ json!({"include_system": {"type": "boolean", "default": false, "description": ictl_l10n::tr!("同时列出系统 App", "also list system apps")}}),&[],),- looking("列出 App"),+ looking(ictl_l10n::tr!("列出 App", "List apps")),),t("iphone_launch_app",action_desc(- "启动 App 并切到前台。app 是显示名时按已安装的 App 查找,找不到会报错,提示用 iphone_list_apps 查看。\n\n\+ ictl_l10n::tr!("启动 App 并切到前台。app 是显示名时按已安装的 App 查找,找不到会报错,提示用 iphone_list_apps 查看。\n\n\何时用:打开某个 App。要直接进网页或 App 里的某个页面用 iphone_open_url。\想从首页重新开始(而不是回到上次的页面),先用 iphone_terminate_app 结束它再启动。\n\n\行为:App 已在后台运行时只切回前台,停在上次的页面;没在运行就冷启动。等 App 真的到前台才返回(最多约 8 秒);\-被系统弹窗(如权限请求)挡住或启动慢时,结果里会说明。需要 WDA。",- "已启动 com.apple.Preferences",+被系统弹窗(如权限请求)挡住或启动慢时,结果里会说明。需要 WDA。", "Launch an app and bring it to the foreground. A display name is looked up among the installed apps; if not found it fails and suggests iphone_list_apps.\n\nWhen to use: to open an app. To go straight to a web page or a screen inside an app, use iphone_open_url. To start from the app's first screen (instead of where it was), quit it with iphone_terminate_app first.\n\nBehavior: an app already running in the background is only brought back to the front, on the screen it was on; otherwise it cold-starts. It returns once the app is really in front (up to about 8 s); if a system alert (such as a permission prompt) blocks it or it starts slowly, the result says so. Needs WDA."),+ ictl_l10n::tr!("已启动 com.apple.Preferences", "Launched com.apple.Preferences"),true,),schema(with_then(app()), &["app"]),- acting("启动 App", false, true),+ acting(ictl_l10n::tr!("启动 App", "Launch app"), false, true),),t("iphone_terminate_app",action_desc(- "强制结束 App 进程,相当于在多任务界面里把它划掉。app 是显示名时按已安装的 App 查找,找不到会报错。\n\n\+ ictl_l10n::tr!("强制结束 App 进程,相当于在多任务界面里把它划掉。app 是显示名时按已安装的 App 查找,找不到会报错。\n\n\何时用:App 卡住或状态不对,或者想让下次 iphone_launch_app 从首页冷启动。只想离开 App 用 iphone_press_button 按 home,App 留在后台。\n\n\-行为:App 里没保存的输入、正在播放的内容会丢失。App 本来没在运行也不报错。结束的是前台 App 时会回到主屏幕。需要 WDA。",- "已结束 com.apple.Preferences",+行为:App 里没保存的输入、正在播放的内容会丢失。App 本来没在运行也不报错。结束的是前台 App 时会回到主屏幕。需要 WDA。", "Force-quit an app, like swiping it away in the app switcher. A display name is looked up among the installed apps; if not found it fails.\n\nWhen to use: the app is stuck or in a wrong state, or the next iphone_launch_app should cold-start it on its first screen. To just leave the app, press home with iphone_press_button; the app stays in the background.\n\nBehavior: unsaved input and anything playing is lost. No error if the app wasn't running. Quitting the foreground app returns to the home screen. Needs WDA."),+ ictl_l10n::tr!("已结束 com.apple.Preferences", "Terminated com.apple.Preferences"),false,),schema(with_then(app()), &["app"]),- acting("结束 App", true, true),+ acting(ictl_l10n::tr!("结束 App", "Quit app"), true, true),),t("iphone_open_url",action_desc(- "用系统默认方式打开网址或 URL Scheme:http/https 网页在 Safari 打开,URL Scheme 打开对应的 App。\n\n\+ ictl_l10n::tr!("用系统默认方式打开网址或 URL Scheme:http/https 网页在 Safari 打开,URL Scheme 打开对应的 App。\n\n\何时用:直接进入某个网页或 App 里的某个页面,比启动 App 再一级级点快。只想打开 App 用 iphone_launch_app。\n\n\-行为:有的 URL Scheme 系统会先弹窗问要不要打开,带 then=screenshot 确认。需要 WDA。",- "已打开 https://example.com",+行为:有的 URL Scheme 系统会先弹窗问要不要打开,带 then=screenshot 确认。需要 WDA。", "Open a web address or URL scheme the way the system does: http/https pages open in the default browser, URL schemes open their app.\n\nWhen to use: to go straight to a web page or a screen inside an app, faster than launching the app and tapping through. To just open an app use iphone_launch_app.\n\nBehavior: for some URL schemes the system first asks whether to open them; check with then=screenshot. Needs WDA."),+ ictl_l10n::tr!("已打开 https://example.com", "Opened https://example.com"),true,),schema(- with_then(json!({"url": {"type": "string", "description": "完整网址(含 https://)或 URL Scheme"}})),+ with_then(json!({"url": {"type": "string", "description": ictl_l10n::tr!("完整网址(含 https://)或 URL Scheme", "full address (including https://) or URL scheme")}})),&["url"],),- acting("打开链接", false, false),+ acting(ictl_l10n::tr!("打开链接", "Open URL"), false, false),),t("iphone_wait_for",- "等包含某段文字的界面元素出现(例如页面加载完、搜索结果出来、弹窗出现),出现就立即返回找到的元素和用时;超时报错。\n\n\+ ictl_l10n::tr!("等包含某段文字的界面元素出现(例如页面加载完、搜索结果出来、弹窗出现),出现就立即返回找到的元素和用时;超时报错。\n\n\何时用:操作后要等加载时代替反复截图轮询,每 0.3 秒查一次,不占上下文。输入框里的字不算(刚输入的搜索词不会被当成结果)。\-需要 WDA。只读:不改变界面,但配置了锁屏密码时会先解锁。"+需要 WDA。只读:不改变界面,但配置了锁屏密码时会先解锁。", "Wait until a UI element containing some text appears (a page finished loading, search results arrived, an alert appeared); returns the element and the time taken as soon as it appears, or an error on timeout.\n\nWhen to use: after an action, to wait for loading instead of polling with screenshots; it checks every 0.3 s and uses no context meanwhile. Text inside input fields doesn't count (a search term just typed isn't taken for a result). Needs WDA. Read-only: doesn't change the screen, but unlocks the phone first if a passcode is configured.").into(),schema(json!({- "text": {"type": "string", "description": "要等的文字,元素的标签/名字/值包含它就算出现"},- "timeout": {"type": "number", "default": 5, "description": "最多等几秒(不超过 30)"}+ "text": {"type": "string", "description": ictl_l10n::tr!("要等的文字,元素的标签/名字/值包含它就算出现", "the text to wait for; it counts as appeared when an element's label/name/value contains it")},+ "timeout": {"type": "number", "default": 5, "description": ictl_l10n::tr!("最多等几秒(不超过 30)", "maximum seconds to wait (up to 30)")}}),&["text"],),- looking("等文字出现"),+ looking(ictl_l10n::tr!("等文字出现", "Wait for text")),),t("iphone_list_devices",- "列出 USB 上接着的全部 iPhone/iPad,每行一台:设备名、型号、iOS 版本、UDID,标出正在控制哪台、有没有设自动解锁密码。\n\n\-何时用:接着多台设备、要确认操作落在哪台,或切换前查设备名和 UDID。同一时间只控制一台,其他工具都作用在正在控制的那台上。只读。"+ ictl_l10n::tr!("列出 USB 上接着的全部 iPhone/iPad,每行一台:设备名、型号、iOS 版本、UDID,标出正在控制哪台、有没有设自动解锁密码。\n\n\+何时用:接着多台设备、要确认操作落在哪台,或切换前查设备名和 UDID。同一时间只控制一台,其他工具都作用在正在控制的那台上。只读。", "List all iPhones/iPads connected over USB, one per line: device name, model, iOS version, UDID; marks the one being controlled and whether it has an auto-unlock passcode.\n\nWhen to use: with several devices connected, to check which one actions go to, or to look up names and UDIDs before switching. Only one device is controlled at a time; all other tools act on it. Read-only.").into(),schema(json!({}), &[]),- looking("列出设备"),+ looking(ictl_l10n::tr!("列出设备", "List devices")),),t("iphone_select_device",- "改为控制另一台设备,之后所有工具都作用在它上面,守护进程重启后还记得。device 是 UDID 或设备名(设备名包含这段文字且只有一台也行),\+ ictl_l10n::tr!("改为控制另一台设备,之后所有工具都作用在它上面,守护进程重启后还记得。device 是 UDID 或设备名(设备名包含这段文字且只有一台也行),\auto 表示取消选定、改回自动选(正在控制的那台断开才换)。\n\n\何时用:接着多台设备、要操作的不是正在控制的那台。先用 iphone_list_devices 看有哪几台。\n\n\行为:切换后要在新设备上拉起 WDA(10~60 秒),期间读界面、按名字点击等用不了,先用 iphone_status 确认就绪;\这台从没装过 WDA 时起不来,要请用户运行 iphone-control setup。\自动解锁按设备分开存密码,新设备没设就不会自动解锁。设了 IPHONE_UDID 时不能切换。\n\n\-返回:一行结果文字,例如「已切换到 Derrors 的 iPad(iPad11,1 iOS 26.6.1,00008020-…)」。"+返回:一行结果文字,例如「已切换到 Derrors 的 iPad(iPad11,1 iOS 26.6.1,00008020-…)」。", "Control another device from now on: all tools act on it, and the daemon remembers it across restarts. device is a UDID or device name (part of the name works if only one device matches); auto clears the selection and goes back to automatic (switches only when the controlled device disconnects).\n\nWhen to use: with several devices connected, when the one to operate isn't the one being controlled. Look at them with iphone_list_devices first.\n\nBehavior: after switching, WDA has to start on the new device (10-60 s); until then reading the screen, tapping by text etc. don't work, so check readiness with iphone_status. If WDA was never installed on that device it won't start; ask the user to run iphone-control setup. Auto-unlock passcodes are stored per device, so a new device without one isn't auto-unlocked. Not possible while IPHONE_UDID is set.\n\nReturns: one line of result text, e.g. “Switched to Derrors's iPad (iPad11,1 iOS 26.6.1, 00008020-…)”.").into(),schema(- json!({"device": {"type": "string", "description": "UDID、设备名,或 auto(改回自动选)"}}),+ json!({"device": {"type": "string", "description": ictl_l10n::tr!("UDID、设备名,或 auto(改回自动选)", "UDID, device name, or auto (back to automatic)")}}),&["device"],),- ToolAnnotations::with_title("切换设备").read_only(false).destructive(false).idempotent(true).open_world(false),+ ToolAnnotations::with_title(ictl_l10n::tr!("切换设备", "Switch device")).read_only(false).destructive(false).idempotent(true).open_world(false),),t("iphone_batch",action_desc(- "按顺序执行几步操作,一次调用完成(最多 20 步),某一步出错就停下,说明停在第几步、后面几步没执行。\n\n\+ ictl_l10n::tr!("按顺序执行几步操作,一次调用完成(最多 20 步),某一步出错就停下,说明停在第几步、后面几步没执行。\n\n\steps 每项是 {\"tool\": 工具名, 其余是该工具的参数},可用:iphone_tap、iphone_tap_element、iphone_long_press、\iphone_swipe、iphone_type_text、iphone_press_button、iphone_launch_app、iphone_terminate_app、iphone_open_url、\iphone_wait_for,以及 {\"tool\": \"wait\", \"seconds\": 秒数}(不超过 5)。iphone_tap_element 没点到也会停下。\执行前先检查全部参数,有错一步都不执行。\n\n\何时用:结果确定的连续操作(按键、逐级点菜单、填表),每步省一轮往返。每步的结果不确定(点了以后不知道会跳到哪)时,还是一步步来。\-then 在全部做完(或停下)后返回一次界面。",- "1. iphone_launch_app → 已启动 com.apple.Preferences(每步一行)",+then 在全部做完(或停下)后返回一次界面。", "Run several steps in order in one call (up to 20); stops at the first error and says which step it stopped at and how many didn't run.\n\nEach item of steps is {\"tool\": tool name, plus that tool's parameters}; allowed: iphone_tap, iphone_tap_element, iphone_long_press, iphone_swipe, iphone_type_text, iphone_press_button, iphone_launch_app, iphone_terminate_app, iphone_open_url, iphone_wait_for, and {\"tool\": \"wait\", \"seconds\": n} (up to 5). An iphone_tap_element that taps nothing also stops it. All parameters are checked first; if any is wrong, no step runs.\n\nWhen to use: sequences with predictable results (keys, menu levels, forms), saving a round trip per step. When the outcome of a step is uncertain (you don't know where a tap leads), go step by step. then returns the screen once, after the last step (or where it stopped)."),+ ictl_l10n::tr!("1. iphone_launch_app → 已启动 com.apple.Preferences(每步一行)", "1. iphone_launch_app → Launched com.apple.Preferences (one line per step)"),true,),schema(with_then(json!({"steps": {"type": "array", "items": {"type": "object"},- "description": "要执行的步骤,1 到 20 个,例如 [{\"tool\": \"iphone_tap_element\", \"text\": \"通用\"}]"},+ "description": ictl_l10n::tr!("要执行的步骤,1 到 20 个,例如 [{\"tool\": \"iphone_tap_element\", \"text\": \"通用\"}]", "the steps to run, 1 to 20, e.g. [{\"tool\": \"iphone_tap_element\", \"text\": \"General\"}]")},"reuse_elements": {"type": "boolean", "default": false,- "description": "这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置"}+ "description": ictl_l10n::tr!("这批操作不改变界面布局时(例如在同一个键盘上连按)设为 true:按名字点击复用最近读到的元素树,每步省 0.3~0.8 秒。会跳转页面的不要用,否则可能点到旧位置", "Set to true when the steps don't change the layout (e.g. pressing keys on the same keypad): tapping by text reuses the most recent element tree, saving 0.3-0.8 s per step. Don't use it for steps that navigate, or it may tap where things used to be")}})),&["steps"],),- acting("批量操作", true, false),+ acting(ictl_l10n::tr!("批量操作", "Batch"), true, false),),]}@@ -601,7 +615,7 @@ pub struct McpServer {impl ServerHandler for McpServer {fn get_info(&self) -> InitializeResult {- InitializeResult::new(ServerCapabilities::builder().enable_tools().build()).with_instructions(INSTRUCTIONS)+ InitializeResult::new(ServerCapabilities::builder().enable_tools().build()).with_instructions(instructions())}async fn list_tools(@@ -783,6 +797,25 @@ mod tests {v.as_object().cloned().unwrap()}+ fn has_cjk(s: &str) -> bool {+ s.chars().any(|c| matches!(c, '\u{3000}'..='\u{303f}' | '\u{4e00}'..='\u{9fff}' | '\u{ff00}'..='\u{ffef}'))+ }++ /// With IPHONE_CONTROL_LANG=en nothing the agent reads up front is Chinese: instructions, tool+ /// descriptions, titles and parameter docs (only examples of Chinese input may stay)+ #[test]+ fn english_tool_definitions_have_no_chinese() {+ use ictl_l10n::{Lang, with_lang};+ with_lang(Lang::En, || {+ assert!(!has_cjk(instructions()), "{}", instructions());+ for t in tools() {+ let json = serde_json::to_string(&t).unwrap();+ assert!(!has_cjk(&json), "{}: {json}", t.name);+ }+ });+ with_lang(Lang::Zh, || assert!(has_cjk(instructions())));+ }+#[test]fn alert_check_after_actions_but_not_buttons_or_reads() {assert!(wants_alert_check(&Request::Swipe { from: (0.0, 0.0), to: (1.0, 1.0), seconds: 0.3 }));diff --git a/docs/decisions.md b/docs/decisions.mdindex 8b4a5ae..4c9b190 100644--- a/docs/decisions.md+++ b/docs/decisions.md@@ -69,3 +69,10 @@- **理由**:操作或密码落到另一台手机上后果严重,所以宁可离线也不换台,密码也绝不跨设备使用。同时控制多台要多套会话,每个工具还要加设备参数,和 D10 的接口兼容冲突。停用标记全局是偏保守的选择:一台失败后先让人看一眼。- **代价**:选定的设备没接时可能触发离线通知;一台自动解锁失败,所有设备都停用;切换后 WDA 要 10~60 秒才起来;自动重签只管正在控制的那台,闲置设备的描述文件会过期,切回后才重签;通知文字不带设备名。- **重新评估**:出现同时驱动多台的需求时。++## D12:界面文字可选英文,默认仍是中文++- **决定**:`IPHONE_CONTROL_LANG=en|zh` 选择人和 agent 看到的文字的语言(工具说明、工具结果、命令行输出、日志、通知);不设或认不出时是简体中文。每条文字在代码里原地写成中英一对(`ictl-l10n` 的 `tr!` / `trf!`),不另建翻译目录。从手机界面读到的文字(例如「滚动条」)不翻译。+- **理由**:D10 承诺已有工具的默认返回不变,所以英文只能是可选项,不设就和以前完全一样。两种语言并排写在原处,改文字时另一种就在旁边,审查时也能逐条对照。+- **代价**:每条新文字都要写两种语言;取语言是一次原子读,开销可以忽略。+- **重新评估**:多数用户改用英文时,再讨论默认值。