From cc6603e0f3f842e9ce1116837181fe1c2b2dc337 Mon Sep 17 00:00:00 2001 From: Derrors <33656531+Derrors@users.noreply.github.com> Date: Wed, 25 Nov 2026 07:37:33 +0800 Subject: [PATCH] docs: align the docs and the site with the code (review 2026-11) - security: pairing records are in the system's lockdown directory, not the data directory; release manifests are Ed25519-signed and checked for signature, name, size and sha256; SECURITY.md covers the phone-side WDA loopback, native control needing no Apple ID, and app-scoped tasks - getting started: Intel Macs are supported - FAQ: the automation-pin prompt is retried every 5 s, each launch waiting about 25 s; native taps, swipes and buttons also open the screen mirroring session - tools: `replace: true` works through WDA too, with its own rollback; add `iphone_wait_for`'s `state`, native auto-unlock and a native-control section - remote: process identification over the viewer's HTTP API is Linux only; `SO_PEERCRED` on the Unix socket works on both systems - architecture: redraw the diagram (viewer, ictl-ax, ictl-webinspector, ictl-l10n, native control, background WDA), add the ictl-ax crate, the new state.json fields and the WDA-only re-sign and session upkeep; iOS 17-18 mount the classic personalized image (#185) - troubleshooting: add the native-control section; the paired-computer icon also comes from native input - ios27-native: one rule for re-signing and the Apple ID session check - release updates name all four targets; task-control names viewer-tokens.json Co-authored-by: Claude Opus 5.5 --- SECURITY.md | 10 ++--- docs/architecture.md | 63 ++++++++++++++++------------- docs/dev/ios27-native.md | 4 +- docs/dev/release-updates.md | 2 +- docs/task-control.md | 2 +- docs/tools.md | 14 +++++-- docs/troubleshooting.md | 10 ++++- website/en/guide/getting-started.md | 2 +- website/en/guide/remote.md | 4 +- website/en/guide/security.md | 4 +- website/en/guide/tools.md | 2 +- website/en/troubleshoot/faq.md | 4 +- website/guide/getting-started.md | 2 +- website/guide/remote.md | 4 +- website/guide/security.md | 4 +- website/guide/tools.md | 2 +- website/troubleshoot/faq.md | 4 +- 17 files changed, 79 insertions(+), 58 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index ed9c3f8d..87188cdc 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -13,7 +13,7 @@ iphone-control is, by design, a remote control for a phone. Anyone who can talk | Asset | Where | Who can reach it | |---|---|---| | Phone control (taps, typing, screenshots, apps) | Control socket: `$XDG_RUNTIME_DIR/iphone-control/ctl.sock` on Linux, `~/.local/share/iphone-control/ctl.sock` on macOS; mode 0600 | The user the daemon runs as, and root | -| WebDriverAgent (no authentication) | On the phone, reached through usbmuxd; nothing listens on the network unless you run `wda-bridge` | With `wda-bridge`: **every local user** on the host, since the port is on 127.0.0.1. Browsers are blocked by a Host-header check (DNS rebinding), other local processes are not | +| WebDriverAgent (no authentication) | On the phone, reached through usbmuxd. It listens on the phone's loopback only (`USE_IP=127.0.0.1`), so other devices on the phone's network can't reach its 8100 or 9100 port; nothing listens on the host's network unless you run `wda-bridge` | With `wda-bridge`: **every local user** on the host, since the port is on 127.0.0.1. Browsers are blocked by a Host-header check (DNS rebinding), other local processes are not | | Live viewer (`iphone-control viewer`, opt-in; also as a service) | A page on `127.0.0.1` (port 8200 by default), with `--lan` also on the local network over HTTPS (connections only from loopback, private, link-local and 100.64/10 addresses); MCP over HTTP on the same port (`/mcp`); nothing listens unless you run it. Its AI tasks run Claude Code or Codex as the user who started the viewer. Login tokens in `viewer-tokens.json` in the data directory (0600); the self-signed HTTPS key in `viewer-tls/` (key 0600) | Whoever has a token: every HTTP request needs one, from `127.0.0.1` too (a reverse proxy on the host makes visitors look local). An operating token can watch the screen, control the phone and start AI tasks (which use that user's agent login); a read-only token can only watch. Wrong tokens are rate-limited (20 a minute for the whole viewer). Other web pages in a browser are blocked by the `Host`, `Origin`, JSON and `Sec-Fetch-Site` checks. An agent working for a task gets only the task's token: it acts for that task and can't pause, resume or confirm it | | Apple ID session tokens, development signing key and certificate | `account/` in the data directory (0700, key 0600) | Whoever can read the data directory. The Apple ID password itself is never stored | | Pairing records | The system's `/var/lib/lockdown` (Linux, kept by usbmuxd) or `/var/db/lockdown` (macOS, shared with Finder) | Root on the host. A pairing record lets its holder talk to the phone over USB without another *Trust* prompt | @@ -28,15 +28,15 @@ The data directory is `~/.local/share/iphone-control`. Everything runs as your r - The control socket is a Unix socket with mode 0600, not TCP. - The tunnel to the phone uses a user-space TCP stack, so no network interface or routing changes on the host, and the daemon needs no root. - Auto-unlock is off by default. When enabled, it stops for good after a single wrong attempt (it writes a stop marker, `logs/UNLOCK-DISABLED`, before entering the second digit) and sends a notification; it never retries a passcode that might be wrong. The marker is global: a failure on one device stops auto-unlock on all of them until you run `unlock-reset`. It does not work before the first unlock after a reboot (BFU) — that always needs a person. -- Dependencies are pinned to exact versions, `Cargo.lock` is committed, release archives come with a sha256 that `install.sh` checks, and the WebDriverAgent download is checked against a sha256. CI runs gitleaks on every push. +- Dependencies are pinned to exact versions and `Cargo.lock` is committed. Each release signs a manifest per archive and, on Linux, per .deb with Ed25519; the installer and `iphone-control update` check its signature, name, size and SHA-256 before installing. The WebDriverAgent download is checked against a sha256. CI runs gitleaks on every push. ## Known risks and recommendations - **Anyone who can act as your user can control the phone.** The daemon runs as a per-user service and talks to the phone through the system usbmuxd. Keep the account and the host locked down. -- **Third-party anisette server.** Apple ID logins need "anisette" data that normally only Apple hardware produces. By default it comes from a public server (`https://mac-ani.jkcoxson.com`, the default of the Impactor/omnisette libraries). The server does not receive your Apple ID password, but your logins depend on an identity it provisions, and it sees when you log in. Set `ICTL_ANISETTE_URL` to an [anisette-v3 server](https://github.com/Dadoum/anisette-v3-server) you run yourself to avoid this. -- **Use a dedicated Apple ID.** The session token and signing key on disk are enough to manage that account's development certificates and devices. A separate free account limits the damage if the host is compromised and keeps your main account clear of developer-account restrictions. +- **Third-party anisette server (WDA only).** Apple ID logins need "anisette" data that normally only Apple hardware produces. Native control on iOS 27 and later needs no Apple ID. By default the data comes from a public server (`https://mac-ani.jkcoxson.com`, the default of the Impactor/omnisette libraries). The server does not receive your Apple ID password, but your logins depend on an identity it provisions, and it sees when you log in. Set `ICTL_ANISETTE_URL` to an [anisette-v3 server](https://github.com/Dadoum/anisette-v3-server) you run yourself to avoid this. +- **Use a dedicated Apple ID (WDA only).** The session token and signing key on disk are enough to manage that account's development certificates and devices. A separate free account limits the damage if the host is compromised and keeps your main account clear of developer-account restrictions. Native control on iOS 27 and later needs none of this. - **Auto-unlock stores your passcode in plain text.** Anyone with root on the host, or access to backups of the data directory, can read it — and the passcode is also what protects the phone's data and Apple ID. Only enable it on a host you fully control, and prefer leaving Auto-Lock off on a phone dedicated to automation. -- **Agents act with your hands.** An agent with these tools can send messages, make purchases and change settings. The MCP server tells agents to ask before paying, deleting, sending messages or changing account or privacy settings, but that is an instruction, not an enforcement mechanism. The same goes for AI tasks started from the viewer: the agent is told to call `iphone_confirm` first and the page waits for your answer, and a step you reject is refused, but an agent that skips the call isn't stopped. There it gets only the phone tools (Claude Code without its shell and file tools, Codex in a read-only sandbox). Use a phone and accounts you are comfortable automating. +- **Agents act with your hands.** An agent with these tools can send messages, make purchases and change settings. The MCP server tells agents to ask before paying, deleting, sending messages or changing account or privacy settings, but that is an instruction, not an enforcement mechanism. The same goes for AI tasks started from the viewer: the agent is told to call `iphone_confirm` first and the page waits for your answer, and a step you reject is refused, but an agent that skips the call isn't stopped. A task can be limited to some apps (`--app`): before acting in any other app it asks the same way, and a rejected step is refused, but pressing buttons and quitting apps are never checked, since they are how the agent gets back after you say no. There it gets only the phone tools (Claude Code without its shell and file tools, Codex in a read-only sandbox). Use a phone and accounts you are comfortable automating. - **Back up the data directory securely**, and never commit it or the settings file. `.gitignore` excludes `data/`, `secrets/` and key material in case you keep copies next to the source. ## Developer tools diff --git a/docs/architecture.md b/docs/architecture.md index 1a98b7aa..9e637757 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -3,30 +3,34 @@ ## 1. 总览 ``` -┌──────────────────── Linux / macOS 主机(以普通用户运行)────────────────────────┐ -│ │ -│ Claude Code ──stdio──▶ iphone-control mcp ──unix socket──┐ │ -│ (每个会话一个,短命) (ictl-mcp,经 ictl-protocol) │ │ -│ ▼ │ -│ iphone-control daemon(ictl-daemon,常驻,唯一持有设备) │ -│ ┌───────────────────────────────────────────────────┐ │ -│ usbmuxd(系统的)◀──────┤ 设备状态机 usbmux 监听 重签调度 通知 │ │ -│ │ │ │ │ │ -│ │ │ ictl-device: lockdown · CoreDeviceProxy 隧道 │ │ -│ │ │ (jktcp 用户态 TCP) · RSD · cryptexd │ │ -│ │ │ · HID · 截图 · App 列表/启动 │ │ -│ │ │ ictl-wda: XCUITestService 启动 WDA · │ │ -│ │ │ WDA HTTP(直连设备端口,不监听本机) │ │ -│ │ │ ictl-unlock: 锁屏解锁(可选) │ │ -│ │ │ ictl-sign: plume_core 登录 · 描述文件 · 签名 │ │ -│ │ └───────────────────────────────────────────────────┘ │ -└────────┼──────────────────────────────────────────────────────────────────────┘ - │ USB - ┌─────▼───────────────────────────────┐ - │ iPhone / iPad(iOS 17+,开发者模式) │ - │ 开发者镜像(Cryptex,iOS 27 含 dtuhidd)│ - │ WebDriverAgent(免费 Apple ID 签名) │ - └─────────────────────────────────────┘ +┌───────────────────────────── Linux / macOS 主机(以普通用户运行) ─────────────────────────────┐ +│ │ +│ AI 客户端 ──stdio──▶ iphone-control mcp ──unix socket─────┐ │ +│ (Claude Code、Codex 等,每个会话一个; │ │ +│ ictl-mcp 翻成请求,ictl-protocol 定义协议) │ │ +│ │ +│ 浏览器、远端 agent ──HTTPS、登录──▶ iphone-control viewer ┤ │ +│ (控制台,可选:实时画面、AI 任务、/mcp) │ │ +│ ▼ │ +│ ┌────────────────────────────────────────────────────────────────────┐ │ +│ usbmuxd(系统的)◀─┤ iphone-control daemon(ictl-daemon,常驻,唯一持有设备) │ │ +│ │ │ 设备状态机 · 巡检 · 重签 · 任务 · 通知 · 控制接口服务端 │ │ +│ │ │ ictl-protocol:请求/响应类型、控制接口、默认路径 │ │ +│ │ │ ictl-device:lockdown · CoreDeviceProxy 隧道(用户态 TCP) │ │ +│ │ │ · HID · 截图 · App 管理 · 媒体流 · Web Inspector │ │ +│ │ │ ictl-ax:remoteAXService 会话(iOS 27 原生读界面) │ │ +│ │ │ ictl-wda:后台启动 WDA · WDA HTTP · 元素树解析 │ │ +│ │ │ ictl-unlock:自动解锁 ictl-sign:Apple ID 登录与签名 │ │ +│ │ │ ictl-l10n:界面文字的语言(其余 crate 都用它) │ │ +│ └────────────────────────────────────────────────────────────────────┘ │ +└────────────────────────────────────────────────────────────────────────────────────────────────┘ + │ USB + ┌─▼──────────────────────────────────────────────┐ + │ iPhone / iPad(开发者模式) │ + │ iOS 27+:原生控制,不装东西、不用 Apple ID │ + │ iOS 17–26:WebDriverAgent,免费 Apple ID 签名 │ + │ 8100/9100 只听手机回环 │ + └────────────────────────────────────────────────┘ ``` 和 toolkit 的根本区别:toolkit 每条 HID 命令都要重新建一次隧道(3~5 秒),WDA 端口转发要单独一个进程,各工具各建各的隧道。D 方案里**守护进程独占设备**,隧道、HID 会话(含显示媒体流)、WDA 会话都常驻复用;MCP 进程只是一个薄客户端。 @@ -117,7 +121,7 @@ - **热插拔**:交给系统的 usbmuxd(Linux 上由 udev 通知)。守护进程每 10 秒向 usbmuxd 列一次设备;列设备连续 3 轮出错才当作离线,usbmuxd 抖一下不拆会话。`doctor` 另数 sysfs `/sys/bus/usb/devices/`(Linux)或 IORegistry(macOS)里的 iPhone/iPad/iPod(厂商号 `05ac` 且产品名匹配,键盘等配件不算),区分「USB 上没有手机」和「usbmuxd 看不到」。(以前的 Docker 镜像里没有 udev,守护进程自己看护 usbmuxd,台数对不上就重启它;去掉 Docker 后这部分删了,见 D5、D14。) - **隧道**:CoreDeviceProxy + jktcp 用户态 TCP 栈(idevice `tunnel_tcp_stack`),不需要 root,不创建 TUN 网卡。锁屏且从未解锁过(BFU)时报 `PasswordProtected`,进入 `NeedsUnlock`,只能人工解锁。HID 和截图用的隧道按需建立、常驻复用;WDA 掉线或 usbmuxd 重启时连隧道一起丢。 - **HID 会话**:归 `Tunnel` 所有(`Tunnel::hid` / `close_hid` / `close`),持有屏幕媒体流。关闭时必须先停媒体流再断隧道,否则手机一直挂着「配对的电脑」会话(灵动岛图标常驻、不自动锁屏)。空闲 30 秒关闭,重开约 0.5 秒。 -- **开发者镜像**:每次启动 WDA 前都先 `installed_ddi()` 查询(toolkit 实测已挂载时约 1 秒),未挂载才走 `install_ddi()`(个性化 + TSS)。手机重启后镜像可能会掉,所以这一步不能省。默认缓存(`ddi/`)连续 3 次**挂载**失败才清掉重新下载,隧道建不起来不计入。设了 `ICTL_DDI_DIR` 时不下载、也不删里面的文件,缺文件时报错说明缺哪个。 +- **开发者镜像**:每次启动 WDA 前都先 `installed_ddi()` 查询(toolkit 实测已挂载时约 1 秒),未挂载才走 `install_ddi()`(个性化 + TSS);iOS 17–18 不经 cryptexd,而是经 lockdown 的 `mobile_image_mounter` 挂经典个性化镜像(缓存在 `ddi/personalized/`,#185)。手机重启后镜像可能会掉,所以这一步不能省。默认缓存(`ddi/`)连续 3 次**挂载**失败才清掉重新下载,隧道建不起来不计入。设了 `ICTL_DDI_DIR` 时不下载、也不删里面的文件,缺文件时报错说明缺哪个。 - **WDA 就绪判定**:守护进程在后台启动 WDA(DVT processcontrol),本进程不持有 XCTest 会话,就绪只看 `/status`,WDA 卡死另有探测(#103)。守护进程重启、切换设备再切回来时接上原来的进程(`state.json` 的 `detached_wdas`,每台设备一条);`service stop`/`uninstall` 时结束它,见 [WDA 依赖调研](dev/wda-dependency-research.md#8-不挂-xctest-会话启动-wda)。用 XCTest 会话启动(`WdaRunner::start`,只剩 `debug` 子命令在用)时,必须同时满足「本进程持有的 XCTest 会话存活」和 `/status` 返回 ready:toolkit 踩过,host 侧 runner 退出后,手机上残留的 WDA 还会响应几十秒再自杀,单看 `/status` 会误判。 - **自动化密码框**:手机重启后首次启用 UI 自动化会弹「为 XCTest 输入 iPhone 密码」,没人输就报 `Timed out while enabling automation mode`。识别到这个错误:进入 `NeedsAutomationPin`、只推送一次通知;之后每次启动只等 25 秒,没弹出密码框就 5 秒后再启动一次(密码框只在启动时出现、每次约 45 秒,且不是每次启动都出现;弹出来的那次会一直等到密码框消失),这样手机上大部分时间都有框可输。恢复后再推送一次。 - **退避**:其它 WDA 启动失败按 60s → 120s → 240s → 300s 退避,上限 5 分钟;手机重新连上、WDA 就绪、重签完成时重置。 @@ -127,7 +131,8 @@ | crate | 职责 | 主要依赖 | |---|---|---| | `ictl-device` | `Device` 句柄:usbmux 发现与监听、lockdown、配对状态、开发者模式状态、隧道(`Tunnel`,持有 HID 会话和显示媒体流)、开发者镜像(含下载缓存)、截图、剪贴板(HID 粘贴中文等非 ASCII 文字)、App 列表/启动/结束、安装 IPA、卸载、崩溃报告、系统日志流(`oslog`,开发者工具用)、打开 Web Inspector;所有设备调用都有时限 | `idevice`(锁上游 git 提交) | -| `ictl-wda` | `WdaRunner`(XCUITestService 启动/停止)、`WdaClient`(会话、点击、W3C actions、keys、source、screenshot、appium settings、锁屏核对)、经 usbmuxd 直连设备 8100 端口的 HTTP 传输(区分连不上和请求超时)、元素树解析(纯函数,可单测) | `idevice`(`xctest`)、`quick-xml` | +| `ictl-wda` | `WdaRunner`(经 XCTest 启动/停止,只剩 `debug` 子命令用)、后台启动 WDA(DVT processcontrol,不持 XCTest 会话,带 `USE_IP=127.0.0.1`)、`WdaClient`(会话、点击、W3C actions、keys、source、screenshot、appium settings、锁屏核对)、经 usbmuxd 直连设备 8100 端口的 HTTP 传输(区分连不上和请求超时)、元素树解析(纯函数,可单测) | `idevice`(`xctest`)、`quick-xml` | +| `ictl-ax` | remoteAXService 的 DTX 会话:握手、读帧、按层读前台 App 和 SpringBoard 的元素,拼成树再转成 WDA `/source` 风格的 XML(iOS 27 及以上原生控制读界面用) | `idevice`、`plist` | | `ictl-webinspector` | Web Inspector 服务(`com.apple.webinspector`,经 lockdown)的客户端:列出可检查的网页和 WebView、在页面里执行 JavaScript(`Target` 域和旧版直接收命令两种都支持,Promise 用 `Runtime.awaitPromise` 等待)。纯协议,消息解析可单测 | `idevice`、`plist` | | `ictl-l10n` | 界面文字的语言:取当前语言,`tr!` / `trf!` / `log_tr!` / `log_trf!` 宏(每条文字在代码里原地写成中英一对,见 D12) | 无 | | `ictl-protocol` | 控制接口的 `Request`/`Response` 类型和客户端 `call(socket, req, timeout)`、任务的流式请求;`Response::Text` 除了给人和 agent 看的文字,还可以带 `data`(状态、元素、App 列表、系统弹窗的结构化字段,给控制台这类程序用,文字措辞改了也不影响它们);默认的数据目录、socket 路径和 root 判断 | `serde`、`serde_json`、`tokio`、`libc`、`ictl-l10n` | @@ -137,7 +142,7 @@ | `ictl-mcp` | MCP stdio 服务,`iphone_*` 工具 18 个,开启开发者工具后 24 个:toolkit 的 13 个 + `iphone_wait_for`、`iphone_batch`、`iphone_list_devices`、`iphone_select_device`、`iphone_scroll_collect`,以及 6 个可选的开发者工具(D13);操作类工具可带 `then` 顺带返回操作后的界面;任务里另有 `iphone_confirm`;经控制接口调用守护进程。同一套工具也给控制台的 `/mcp` 用(`http_service`,Streamable HTTP) | `ictl-protocol`、`ictl-l10n`、`rmcp`(`server`、`transport-io`、`transport-streamable-http-server`)、`http` | | `apps/iphone-control` | CLI 入口(`main.rs`;和守护进程打交道的公共函数在 `client.rs`,控制台、引导和更新器都用它):不带命令时是首次运行引导或状态(`guide.rs`)、`daemon`、`mcp`、`mcp-config`、`status`、`doctor`、`setup [--reconfigure]`、`service`(`service.rs`:launchd / systemd 用户服务)、`login`、`sign`、`resign`、`passcode`、`unlock-reset`、`devices`、`select`、`wda-bridge`、`viewer`(`viewer.rs`:本机控制台网页,实时画面、设备面板;`video/`:画面的 H.264 编码(外部 ffmpeg)和 MJPEG 去重;`agent.rs`:页面上的 AI 任务,`viewer.html` 是页面)、`viewer token …`(命名令牌、只读令牌)、`task …`(`task.rs`、`remote.rs`)、`mcp --url`(`mcp_bridge.rs`)、`update …`(`update.rs`、`update/`:签名清单、事务式替换)、`completions`、`notify-test`;隐藏的 `debug ` 真机诊断(原第 0 步 spike,不经守护进程;feature `debug-cmds`,默认不编译) | `clap` | -依赖方向:`apps` → `ictl-daemon` / `ictl-mcp`,还直接依赖 `ictl-device`、`ictl-sign`;`ictl-daemon` → `ictl-unlock` → `ictl-wda` → `ictl-device`;`ictl-daemon` 还直接依赖 `ictl-webinspector`、`ictl-sign` 和 `ictl-protocol`。`ictl-device` 也依赖 `ictl-webinspector`(打开连接)。`ictl-mcp` 只依赖 `ictl-protocol` 和 `ictl-l10n`,不依赖守护进程和设备层。`ictl-l10n` 不依赖其他 crate,除 `ictl-webinspector` 外都用它。`apps` 的 `debug`(feature `debug-cmds`)直接调用 `ictl-device`、`ictl-wda`。 +依赖方向:`apps` → `ictl-daemon` / `ictl-mcp`,还直接依赖 `ictl-device`、`ictl-sign`;`ictl-daemon` → `ictl-unlock` → `ictl-wda` → `ictl-device`;`ictl-daemon` 还直接依赖 `ictl-ax`、`ictl-webinspector`、`ictl-sign` 和 `ictl-protocol`。`ictl-device` 也依赖 `ictl-ax`(无障碍会话归隧道)和 `ictl-webinspector`(打开连接)。`ictl-mcp` 只依赖 `ictl-protocol` 和 `ictl-l10n`,不依赖守护进程和设备层。`ictl-l10n` 不依赖其他 crate,除 `ictl-webinspector` 外都用它。`apps` 的 `debug`(feature `debug-cmds`)直接调用 `ictl-device`、`ictl-wda`。 ## 5. 截图与坐标 @@ -158,7 +163,7 @@ | `wda/` | 当前签好的包 `WDA-signed.ipa`,和未签名包 `WDA-unsigned.ipa`:第一次签名前下载 Appium 官方的未签名真机包(`WebDriverAgentRunner-Runner.zip` v16.15.3,校验 sha256)重新打包(`crates/ictl-daemon/src/wda_pkg.rs`);计划改为本项目 macOS CI 编译。描述文件只嵌在签好的包里,到期时间记在 `state.json` | 默认 | 否(在本机下载) | | `secrets/passcodes/` | 各设备的锁屏密码(仅启用自动解锁时);旧版本的 `secrets/passcode` 在只接着一台时归到那台名下 | 0600 | 否 | | `logs/` | 事件日志 `daemon.log`(超过 5 MB 轮转成 `.1`);自动解锁停用标记 `UNLOCK-DISABLED`(与 toolkit 一致,便于人工发现;全局,不分设备) | 默认 | 否 | -| `state.json` | 最近一次签名的 Team ID、WDA Bundle ID、描述文件到期时间;选定的设备;每台设备的竖放屏幕尺寸(按 UDID);上次重签结果 | 默认 | 否 | +| `state.json` | 最近一次签名的 Team ID、WDA Bundle ID、描述文件到期时间;选定的设备;每台设备的竖放屏幕尺寸(按 UDID);上次重签结果(`resign_result`);每台设备后台启动的 WDA 进程号(`detached_wdas`,只听手机回环的另记在 `loopback_wdas`);Home 和锁屏在各设备上走哪条路(`button_ways`) | 默认 | 否 | | `viewer-tokens.json` | 控制台的登录令牌(名字、权限、令牌) | 0600 | 否 | | `viewer-tls/` | 控制台局域网 HTTPS 的自签证书和私钥 | 0700 | 否 | | `tasks/` | 最近 50 个 AI 任务的事件记录,每个任务一个 `.jsonl` | 默认 | 否 | @@ -167,7 +172,7 @@ ## 7. 重签与通知 -- 守护进程每 `RESIGN_CHECK_HOURS`(默认 6 小时)检查一次:描述文件剩余 < `RESIGN_MIN_DAYS`(默认 2 天)才重签;另外**每天验证一次 Apple ID 会话**(toolkit 的教训:只在要重签时才发现登录过期,只剩 2 天处理)。两者都在后台跑,不持设备锁。只检查正在控制的那台;手机重新连上或切换设备后 1 分钟内也查一次。 +- 守护进程每 `RESIGN_CHECK_HOURS`(默认 6 小时)检查一次:描述文件剩余 < `RESIGN_MIN_DAYS`(默认 2 天)才重签;另外**每天验证一次 Apple ID 会话**(toolkit 的教训:只在要重签时才发现登录过期,只剩 2 天处理)。两者都在后台跑,不持设备锁。只检查正在控制的那台;手机重新连上或切换设备后 1 分钟内也查一次。这两项都只为用 WDA 的设备做(`supervise::wda_upkeep`):正在控制的设备走原生控制时都不做,这一轮也不算数;没连手机时会话检查照做(只要装过 WDA),重签不做。 - 重签流程:`plume_core` 取新描述文件 → `ictl-sign` 签名(含 `.xctest`)→ `installation_proxy` 安装 → 下一轮巡检重启 WDA。安装成功后才替换旧文件。整个重签有总时限,超时按失败处理并推送通知。没装过当前 Apple ID 签的 WDA 的设备不自动重签(注册设备占 Apple ID 的名额,交给用户决定)。 - **签名证书**:每个账号目录有自己的私钥(`account/keys/<团队>/key.pem`)和对应的开发证书;免费团队同时最多两张,新建时满了 plume 会吊销一张,不挑是谁的,用它签的 App 在所有设备上都起不来,描述文件却仍有效。所以:读设备上的 WDA 描述文件时顺带离线判断里面有没有本机公钥的证书(`foreign_wda`);每天的会话检查顺带联网查本机证书还在不在团队里(`own_cert`)。设备拒绝启动 WDA(只报 `unexpected response`)时,两者任一有问题就自动重签这台,同一台 6 小时内最多一次;都没问题就多半是还没信任开发者,留给用户。签名新建或吊销证书时写日志、推送。`doctor` 显示这两项。 - 通知事件:重签失败、Apple ID 会话失效、需要输入自动化密码、WDA 恢复、自动解锁失败已停用、手机离线超过 10 分钟、恢复在线、签名证书换了。通知标题带上是哪台设备(设备名和型号,离线时用离线前记下的)。去重:重签失败、会话失效 20 小时内不重复;等密码、离线、自动解锁停用推一次,直到恢复或 `unlock-reset`;只有等密码和离线有恢复推送;签名证书换了每次都推。去重记录只在内存里,守护进程重启后清空。 diff --git a/docs/dev/ios27-native.md b/docs/dev/ios27-native.md index 84fd63ae..3623cc2e 100644 --- a/docs/dev/ios27-native.md +++ b/docs/dev/ios27-native.md @@ -12,7 +12,7 @@ ## 2. 范围 - iOS 27 及以上的手机,**全部工具**在不装 WDA 的情况下可用,结果和措辞对 Agent 尽量不变;可以改回 WDA。 -- 不做:iOS 26 及以下(没有 HID,只能 WDA);双指缩放(本来就没有这个工具);删掉 WDA 代码(低版本还要用,已经装着的 WDA 也照常重签)。 +- 不做:iOS 26 及以下(没有 HID,只能 WDA);双指缩放(本来就没有这个工具);删掉 WDA 代码(低版本还要用,改回 WDA 时也照常重签)。正在用原生控制的设备不自动重签、也不查 Apple ID 会话,即使以前装过 WDA。 ## 3. 每项能力怎么做 @@ -41,7 +41,7 @@ - **`ictl-ax`**:remoteAXService 的 DTX 会话。握手 `_notifyOfPublishedCapabilities:` → 等 `deviceAPIVersion` → `clientNeedsAccessibility: true`;回答 `hostAPIVersion = 7`;手机每条要回执的消息都回空回执。自己读帧(idevice 的 `RemoteServerClient` 遇到解不开的消息会退出)。两层 NSKeyedArchive 解码成 `AXPTranslatorResponse`,只解用到的字段。`tree::assemble` 按阅读顺序拼树,`xml` 转成 WDA 风格的 XML。 - **会话归属**:和 HID 会话一样归 `Tunnel` 所有、常驻复用,空闲 60 秒关掉(`AX_IDLE`)。连接断了就重建,不重放操作。 - **守护进程**:`ICTL_IOS_BACKEND`(`auto`、`native`、`wda`)决定 iOS 27 及以上走哪条路,低于 27 一律 WDA。各工具在设备走原生时改走 `tools/native.rs`;自动解锁复用 `ictl-unlock`,原生一侧实现它的 `Screen`。 -- **状态机和引导**:原生设备的「就绪」= 已配对 + 开发者模式 + 镜像已挂载 + 隧道 + 无障碍会话握手成功,没有 `NeedsSigning`、`WdaStarting`、`NeedsAutomationPin`。准备失败显示「准备手机失败,稍后重试」。重签、Apple ID 会话检查只对用 WDA 的设备做;`setup` 对原生设备跳过 Apple ID 和签名。`status`、`doctor`、控制台都标明「原生」。 +- **状态机和引导**:原生设备的「就绪」= 已配对 + 开发者模式 + 镜像已挂载 + 隧道 + 无障碍会话握手成功,没有 `NeedsSigning`、`WdaStarting`、`NeedsAutomationPin`。准备失败显示「准备手机失败,稍后重试」。自动重签和 Apple ID 会话检查只对用 WDA 的设备做(`supervise::wda_upkeep`):正在控制的设备走原生控制时两样都不做,这一轮也不算数,换到用 WDA 的设备后下一轮就做;没连手机时会话检查照做(只要装过 WDA),重签不做;从没装过 WDA 的设备两样都不做。`setup` 对原生设备跳过 Apple ID 和签名。`status`、`doctor`、控制台都标明「原生」。 ## 5. 对 Agent 可见的差别 diff --git a/docs/dev/release-updates.md b/docs/dev/release-updates.md index 84e1d7f1..2000a801 100644 --- a/docs/dev/release-updates.md +++ b/docs/dev/release-updates.md @@ -22,7 +22,7 @@ openssl genpkey -algorithm ED25519 -out signing-key.pem openssl pkey -in signing-key.pem -pubout -outform DER | tail -c 32 | od -An -v -tx1 | tr -d ' \n' ``` -The stable tag must match the workspace package version, e.g. `v0.2.1` for `0.2.1`. The workflow checks the uploaded archives against the build output before signing the manifest bytes for each target. Linux and macOS (Apple Silicon and Intel) have independent signing jobs. During a partial release, a platform can have an archive before its signed manifest appears. +The stable tag must match the workspace package version, e.g. `v0.2.1` for `0.2.1`. The workflow checks the uploaded archives against the build output before signing the manifest bytes for each target: `linux-x86_64`, `linux-aarch64`, `macos-arm64` (Apple Silicon) and `macos-x86_64` (Intel). Linux and macOS have independent signing jobs. During a partial release, a platform can have an archive before its signed manifest appears. ## Roll out a release diff --git a/docs/task-control.md b/docs/task-control.md index 272b7138..d877ed0e 100644 --- a/docs/task-control.md +++ b/docs/task-control.md @@ -297,7 +297,7 @@ Running → Waiting(等确认)→ Running 7.1 第 2 条的落地,按用户的决定做了一个令牌(只读和可操作分开留到以后)。和 7.1 不同的一点:**本机也要登录**。frp、nginx、cloudflared、`tailscale serve` 这类反向代理或隧道跑在本机时,公网上每个访问者的连接都来自 `127.0.0.1`,控制台分不清是用户本人还是别人,所以不能「本机免登录」。 - **范围**:经 HTTP 的一切(页面、接口、画面、任务事件、`/mcp`)。Unix socket 上的命令行、stdio 的 `iphone-control mcp`、`task run` 不受影响(socket 是 0600,本来就只有这个用户能连)。 -- **令牌**:第一次启动时用系统随机数生成 256 位,十六进制存在 `<数据目录>/viewer-token`(0600,先写临时文件再改名;7.6 起改为 `viewer-tokens.json`)。`iphone-control viewer token` 显示令牌、本机和局域网的登录链接(`/?token=…`)、`claude mcp add … --header "Authorization: Bearer …"`;`--new` 换新令牌,控制台服务在运行就重启它。令牌不写进启动输出和日志(journal 可能有别人能读)。 +- **令牌**:第一次启动时用系统随机数生成 256 位,十六进制存在 `<数据目录>/viewer-token`(0600,先写临时文件再改名)。7.6 起改存 `<数据目录>/viewer-tokens.json`(`auth::TOKENS_FILE`),旧文件在那时迁移并删除。`iphone-control viewer token` 显示令牌、本机和局域网的登录链接(`/?token=…`)、`claude mcp add … --header "Authorization: Bearer …"`;`--new` 换新令牌,控制台服务在运行就重启它。令牌不写进启动输出和日志(journal 可能有别人能读)。 - **浏览器**:没登录时 `/` 返回登录页(401);登录页的表单 `POST /login`(带 `Origin` 时必须是控制台自己),或者点开 `/?token=…` 的链接,成功后 303 回 `/`,地址栏里不留令牌。会话 cookie `ictl_viewer_<端口>`:值是令牌对固定文本的 HMAC-SHA256,看不出令牌,换令牌后自动失效;`HttpOnly`、`SameSite=Lax`(从别处点链接进来也认得,CSRF 靠原有的 `Origin` 和 `Sec-Fetch-Site` 检查)、HTTPS 时加 `Secure`、30 天。页面上的请求遇到 401 就刷新,回到登录页。 - **程序**:`Authorization: Bearer <令牌>`。`/mcp` 的 401 带 `WWW-Authenticate: Bearer`(RFC 6750)。 - **限速**:按全局算,不按地址(经反向代理时地址都是 `127.0.0.1`)。一分钟里错 20 次后,这一分钟内错的令牌一律 429;已经登录的会话不受影响。令牌是 256 位随机数,限速只是多一层保险。(最初这一分钟内连正确的令牌也不校验,结果谁能连上页面,就能靠刷错令牌让 `mcp --url`、远端任务都连不上;0.2.4 之后改成正确的令牌总能进。) diff --git a/docs/tools.md b/docs/tools.md index 270d630b..ebd96293 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -8,10 +8,10 @@ Coordinates are in **points**, the same unit as the pixels of a full-screen `iph | Tool | Parameters | Notes | |---|---|---| -| `iphone_status` | — | WDA ready, locked or not, foreground app, screen size, daemon state | +| `iphone_status` | — | Ready (native control or WDA), locked or not, foreground app, screen size, daemon state | | `iphone_screenshot` | `x`, `y`, `width`, `height` (all optional, points) | Full screen scaled to points. With a region: cropped from the full-resolution capture and enlarged; the result says the zoom factor and how to convert back to screen points | | `iphone_list_elements` | `filter` (default `""`), `limit` (default 150) | Elements that carry text: type, label, id, value, center point and size. `filter` matches type, label, name or value, case-insensitive (for example `SearchField`). Visibility is judged by position, so something hidden behind a dialog can still be listed | -| `iphone_wait_for` | `text`, `timeout` (seconds, default 5, max 30) | Returns as soon as an element containing `text` appears; text typed into input fields does not count. Use this instead of polling with screenshots | +| `iphone_wait_for` | `text`, `state` (`appeared` by default, or `disappeared`), `timeout` (seconds, default 5, max 30) | Returns as soon as an element containing `text` appears, or with `state: "disappeared"` as soon as no element on screen contains it; text typed into input fields does not count. Use this instead of polling with screenshots | | `iphone_list_apps` | `include_system` (default false) | Name and bundle id of installed apps | ## Acting @@ -74,7 +74,7 @@ Without the variable, the tool list and every call are unchanged; while a task r ## Auto-unlock and "read-only" tools -When auto-unlock is configured for the controlled device, a locked phone is unlocked first by the action tools and by `iphone_screenshot`, `iphone_list_elements` and `iphone_wait_for`. `iphone_status`, `iphone_list_apps`, `iphone_list_devices`, `iphone_select_device`, the developer tools and `iphone_press_button` with `lock` never unlock it. While WDA is unavailable nothing is unlocked. +When auto-unlock is configured for the controlled device, a locked phone is unlocked first by the action tools and by `iphone_screenshot`, `iphone_list_elements` and `iphone_wait_for`. `iphone_status`, `iphone_list_apps`, `iphone_list_devices`, `iphone_select_device`, the developer tools and `iphone_press_button` with `lock` never unlock it. Native control unlocks through the accessibility service and HID without WDA; on a device on WDA, while WDA is unavailable nothing is unlocked. Every tool carries MCP annotations: the six read-only tools (`iphone_status`, `iphone_screenshot`, `iphone_list_elements`, `iphone_list_apps`, `iphone_wait_for`, `iphone_list_devices`) are `readOnlyHint: true`, and with the developer tools on so are `iphone_app_logs`, `iphone_crash_reports` and `iphone_web_targets`, nine in all. "Read-only" means they don't change what's on screen; with auto-unlock on, `iphone_screenshot`, `iphone_list_elements` and `iphone_wait_for` still unlock the phone first. The action tools are not read-only, and taps, long-presses, `iphone_terminate_app` and `iphone_batch` are also marked `destructiveHint: true`, since what they hit on screen can delete or send things. So are `iphone_web_eval`, `iphone_install_app` and `iphone_uninstall_app`. @@ -116,6 +116,14 @@ If the MCP client cancels the call, the remaining steps don't run; a request sti } ``` +## Native control and WDA + +iOS 27 and later are controlled natively by default; `ICTL_IOS_BACKEND=wda` goes back to WebDriverAgent, which iOS 26 and earlier always use. The tools and their results are the same, so agents needn't care, with a few differences: + +- **Rows off the screen aren't listed:** scroll a long list to a row before finding or tapping it by text (WDA lists such rows but can't tap them). +- **Text is always pasted:** `iphone_type_text` puts the text on the phone's pasteboard and pastes it; the daemon taps *Allow Paste*, reads the field back and restores the pasteboard at once. +- **Coarser elements:** the accessibility service often makes one element of a whole row ("Wi-Fi, Derrors-5G"), so `iphone_list_elements` is shorter than with WDA; finding by contained text still works. + ## HID fallback When WDA can't be reached, screenshots, taps, swipes and buttons fall back to CoreDevice HID (iOS 27 or later). The limits on landscape, screen size and redoing an action are in the [Tools guide](https://derrors.github.io/iphone-control/en/guide/tools#when-wda-is-down-the-hid-fallback). diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 703ce800..26f5a03f 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -20,6 +20,14 @@ Messages are in Simplified Chinese by default, and in English with `IPHONE_CONTR - **Cable:** some cables only charge. If `lsusb` doesn't show an Apple device (vendor `05ac`), try another cable or port. - **Drops every minute or so while charging:** with *Settings → Battery → Charging → 80% Limit* on, the phone keeps starting and stopping charging near 80%, and each switch renegotiates USB-C power, which briefly disconnects USB (3–5 s). The daemon reconnects by itself, but in-flight actions fail. Set the limit to 100% while the phone is used for automation. +## Native control won't get ready + +iOS 27 and later are controlled natively by default, which needs only pairing, Developer Mode, the developer disk image and the accessibility service. When `status` keeps saying 「准备手机失败,稍后重试」: + +- **The disk image doesn't download:** it comes from GitHub; set a proxy if needed (`iphone-control setup --reconfigure`, pick *Proxy*). +- **The phone is locked:** keep it unlocked while it gets ready. +- **Still stuck:** run `doctor` to see which layer fails and [open an issue](https://github.com/Derrors/iphone-control/issues/new/choose). Meanwhile you can go back to WDA with `ICTL_IOS_BACKEND=wda` in `~/.config/iphone-control/env` and `iphone-control service restart` (needs an Apple ID; see the next section). + ## WebDriverAgent won't start - **"Untrusted developer":** after the first install, trust your Apple ID under *Settings → General → VPN & Device Management* (needs internet on the phone). @@ -44,7 +52,7 @@ Messages are in Simplified Chinese by default, and in English with `IPHONE_CONTR ## The phone shows a "paired computer" icon and won't auto-lock -The HID fallback keeps a screen-mirroring session open while it is in use (the Dynamic Island shows a computer icon) and closes it after 30 seconds of inactivity. If the icon stays, restart the daemon; stopping it closes the session. +The HID fallback keeps a screen-mirroring session open while it is in use (the Dynamic Island shows a computer icon), and so do taps, swipes and buttons under native control on iOS 27 and later, which go through HID; the control page showing the phone's own video uses the same session. It closes after 30 seconds of inactivity. If the icon stays, restart the daemon; stopping it closes the session. ## macOS diff --git a/website/en/guide/getting-started.md b/website/en/guide/getting-started.md index 505485db..87c73485 100644 --- a/website/en/guide/getting-started.md +++ b/website/en/guide/getting-started.md @@ -4,7 +4,7 @@ Install the program, plug in the phone, run `iphone-control` and follow the guid ## You need -- A host: a Mac with Apple silicon, or Linux (x86_64, aarch64) +- A host: a Mac with Apple silicon or Intel, or Linux (x86_64, aarch64) - An iPhone or iPad and a cable that carries data. **iOS 27 or later is recommended**: native control, nothing installed on the phone, no Apple ID. iOS 17–26 work too, through WebDriverAgent - On iOS 26 and earlier, a free Apple ID (a dedicated one is recommended) to sign WebDriverAgent - Internet access to Apple and GitHub from the host (the guide asks for a proxy if you need one) diff --git a/website/en/guide/remote.md b/website/en/guide/remote.md index 2176aae2..9e8809e2 100644 --- a/website/en/guide/remote.md +++ b/website/en/guide/remote.md @@ -92,7 +92,7 @@ iphone-control task run --url https://:8200 --ca cert.pem -- --new` or `remove` it at once. Give a read-only token to people who only need to watch. -- Processes of the same system user can read each other's files: an agent on this machine can read the token file, but its control requests are refused by their process. This isn't a strict boundary; for real isolation, run the agent as another system user or in a sandbox. +- Processes of the same system user can read each other's files: an agent on this machine can read the token file, but its control requests are refused by their process (over the Unix socket that works on Linux and macOS; over the viewer's HTTP API it works on Linux only). This isn't a strict boundary; for real isolation, run the agent as another system user or in a sandbox. - See also [Security and Privacy](./security). diff --git a/website/en/guide/security.md b/website/en/guide/security.md index 863285fc..c9aed5e6 100644 --- a/website/en/guide/security.md +++ b/website/en/guide/security.md @@ -6,7 +6,7 @@ This page has the essentials. What is stored, who can reach it and the details o ## What is stored -- **The data directory** holds pairing records, with WDA also the Apple ID session and the signing key, and, with auto-unlock on, the passcode in **plain text**. Keep it and its backups as safe as a password. The Apple ID password is never stored. +- **The data directory** holds the signing key and the Apple ID session (WDA only), and, with auto-unlock on, the passcode in **plain text**. Keep it and its backups as safe as a password. The Apple ID password is never stored. Pairing records aren't in it: the system's usbmuxd keeps them in `/var/lib/lockdown` (Linux) or `/var/db/lockdown` (macOS). - **The control socket** is a Unix socket with mode 0600, and whoever can connect to it controls the phone: root on the host and the user the daemon runs as. - **Notification keys** are in the settings file `~/.config/iphone-control/env`, mode 0600. @@ -16,7 +16,7 @@ This page has the essentials. What is stored, who can reach it and the details o - **No root.** The daemon runs as your regular user, as a per-user service; the install script refuses to run as root. - **Auto-unlock is off by default** and disables itself after one wrong attempt. - **Developer tools are off by default.** -- Exact dependency versions; the WebDriverAgent download and the install script's download are sha256-checked. +- Exact dependency versions. Each release archive and .deb comes with an Ed25519-signed manifest; the installer and `iphone-control update` check its signature, name, size and sha256 before installing, and the WebDriverAgent download is sha256-checked too. ## Risks to know about diff --git a/website/en/guide/tools.md b/website/en/guide/tools.md index 5c5a467d..c4a3a8d5 100644 --- a/website/en/guide/tools.md +++ b/website/en/guide/tools.md @@ -23,7 +23,7 @@ With [auto-unlock](./auto-unlock) on, `iphone_screenshot`, `iphone_list_elements | `iphone_tap_element` | Tap by text; if the center is covered by a floating bar or the keyboard it taps a visible part, and if it's fully covered it doesn't tap. With `scroll` (`down` / `up`) it scrolls slowly and looks again when the element isn't on screen, until it is found, the list ends or `max_scrolls` (default 8) is reached | | `iphone_long_press` | Long press; `seconds` defaults to 1, max 10 | | `iphone_swipe` | Swipe; returns once the list has stopped scrolling. `seconds` defaults to 0.3, max 10. `hold` holds still at the start for that many seconds before moving, to drag things that need a long press first (home-screen icons, reorderable rows); about 0.6 works | -| `iphone_type_text` | Type into the focused field (Chinese supported), read it back and fix dropped characters; `submit` presses Return. With native control, `replace: true` replaces the text of a focused, readable field (empty `text` empties it) and verifies the whole value before pressing Return | +| `iphone_type_text` | Type into the focused field (Chinese supported), read it back and fix dropped characters; `submit` presses Return. `replace: true` replaces the text of a focused, readable field (empty `text` empties it) and verifies the whole value before pressing Return; natively the old text is selected and pasted over, so a failure leaves it there, while through WDA the field is cleared first and after a failure the old text is gone | | `iphone_press_button` | `home`, `volume_up`, `volume_down`, `lock` | | `iphone_launch_app` / `iphone_terminate_app` | Launch / quit an app by name (e.g. `设置`) or bundle id | | `iphone_open_url` | Open a link or URL scheme | diff --git a/website/en/troubleshoot/faq.md b/website/en/troubleshoot/faq.md index bde567f0..6a181dd1 100644 --- a/website/en/troubleshoot/faq.md +++ b/website/en/troubleshoot/faq.md @@ -21,7 +21,7 @@ Messages are in Simplified Chinese by default, and in English with `IPHONE_CONTR | 准备手机失败,稍后重试:…
Preparing the phone failed, retrying later: … | Native control isn't ready | Read the error after the colon and run `doctor`; see [Native control doesn't get ready](#native-control) | | WDA 还没签名安装
WDA not signed and installed yet | WDA not installed | Run `sign` or `setup` | | 正在启动 WDA
Starting WDA | Starting WDA (up to about 2 minutes) | Wait. On iOS 27 and later, taps, swipes and screenshots already work through the HID fallback, but a landscape touch needs an orientation from WDA in the last 30 seconds or it is refused, and an unknown screen size returns an error; see [Tools](../guide/tools#when-wda-is-down-the-hid-fallback). On older iOS, wait for WDA | -| WDA 卡在手机上的「Enable UI Automation」密码框
WDA is stuck at the “Enable UI Automation” passcode prompt | The phone asks for the passcode for "XCTest" | Enter the passcode on the phone. This happens after a reboot, and sometimes after the daemon is restarted several times in a row. The daemon retries every 60 seconds and notifies you once | +| WDA 卡在手机上的「Enable UI Automation」密码框
WDA is stuck at the “Enable UI Automation” passcode prompt | The phone asks for the passcode for "XCTest" | Enter the passcode on the phone. This happens after a reboot, and sometimes after the daemon is restarted several times in a row. The daemon retries every 5 seconds, each launch waiting about 25 seconds for the prompt, and notifies you once | | WDA 启动失败,稍后重试:…
WDA failed to start, retrying later: … | Other failure | Read the error after the colon and run `doctor`. Retries back off up to 5 minutes | | 就绪
Ready | Everything works | — | @@ -101,7 +101,7 @@ If it still happens on a newer version, look on the phone under Settings → Pri ## "Paired computer" icon stays and the phone won't auto-lock -The HID fallback, and the control page while it shows the phone's own video (iOS 27 and later), open a screen mirroring session; it closes 30 seconds after it was last used (after the page closes). If the icon doesn't go away, restart the daemon (`iphone-control service restart`). +The HID fallback, taps, swipes and buttons under native control on iOS 27 and later (they go through HID too), and the control page while it shows the phone's own video (iOS 27 and later) open a screen mirroring session; it closes 30 seconds after it was last used (after the page closes). If the icon doesn't go away, restart the daemon (`iphone-control service restart`). ## Reporting a problem [Open an issue](https://github.com/Derrors/iphone-control/issues/new/choose) with the phone model, iOS version, how you installed it (one command, Homebrew, .deb or source), and the `doctor` output — with UDID, Apple ID and notification keys removed. diff --git a/website/guide/getting-started.md b/website/guide/getting-started.md index 3c4fb7c2..4bcbb056 100644 --- a/website/guide/getting-started.md +++ b/website/guide/getting-started.md @@ -4,7 +4,7 @@ ## 准备 -- 一台主机:Mac(Apple 芯片),或 Linux(x86_64、aarch64) +- 一台主机:Mac(Apple Silicon 或 Intel),或 Linux(x86_64、aarch64) - iPhone 或 iPad 和能传数据的线。**推荐 iOS 27 及以上**:原生控制,手机上什么都不装,不用 Apple ID;iOS 17–26 也能用,经 WebDriverAgent - iOS 26 及以下还要一个免费 Apple ID(建议专门注册一个),用来给 WebDriverAgent 签名 - 主机能访问苹果服务器和 GitHub;国内网络一般要配代理(引导里会问) diff --git a/website/guide/remote.md b/website/guide/remote.md index 5fc7aef8..3f327a9a 100644 --- a/website/guide/remote.md +++ b/website/guide/remote.md @@ -92,7 +92,7 @@ iphone-control task run --url https://<那台机器>:8200 --ca cert.pem -- <启 命令拿到任务口令、`IPHONE_CONTROL_URL` 和 `IPHONE_CONTROL_MCP_URL`,**拿不到登录令牌**。里面的 agent 照常配置 `iphone-control mcp` 就行:它看到 `IPHONE_CONTROL_URL` 会自动转接到那台机器、只带任务口令;也可以直接用 `$IPHONE_CONTROL_MCP_URL` 加请求头 `Iphone-Control-Task-Token` 走 HTTP。 -**执行和控制分开**:agent 只拿任务口令,只能为这个任务操作手机,不能暂停、继续、接管或批准自己的确认;这些由人在控制台上、或由平台用登录令牌来做。同一台机器上,agent 的进程(以及它启动的进程)发来的控制请求也会被拒绝。 +**执行和控制分开**:agent 只拿任务口令,只能为这个任务操作手机,不能暂停、继续、接管或批准自己的确认;这些由人在控制台上、或由平台用登录令牌来做。同一台机器上,agent 的进程(以及它启动的进程)发来的控制请求也会被拒绝。经 Unix socket 时按 `SO_PEERCRED` 认调用方进程,Linux 和 macOS 都生效;经 HTTP 控制台接口时,本机进程的识别目前只在 Linux 上有效(macOS 上只靠上面这条「只拿任务口令」的限制)。 **不装 iphone-control 的平台**直接调控制台的接口(都要登录令牌,除了标明的两个): @@ -117,5 +117,5 @@ iphone-control task run --url https://<那台机器>:8200 --ca cert.pem -- <启 ## 安全须知 - 有能操作的令牌,就能看屏幕、操作手机、用本机登录的 Claude Code / Codex 执行任务:只发给你信任的人,泄露了马上 `viewer token show <名字> --new` 或 `remove`。给只需要看的人发只读令牌。 -- 同一个系统用户下,进程能读到彼此的文件:本机上的 agent 能读到令牌文件,但它的控制请求会按进程关系被拒绝。这不是严格的安全边界,要真正隔离,让 agent 换一个系统用户运行或放进沙箱。 +- 同一个系统用户下,进程能读到彼此的文件:本机上的 agent 能读到令牌文件,但它的控制请求会按进程关系被拒绝(经 Unix socket 时 Linux 和 macOS 都能认出进程;经 HTTP 控制台接口时目前只在 Linux 上有效)。这不是严格的安全边界,要真正隔离,让 agent 换一个系统用户运行或放进沙箱。 - 更多见[安全与隐私](./security)。 diff --git a/website/guide/security.md b/website/guide/security.md index 0650a15c..3c926de0 100644 --- a/website/guide/security.md +++ b/website/guide/security.md @@ -6,7 +6,7 @@ iphone-control 本质上是一个手机遥控器:能访问它的人,就能 ## 存了什么 -- **数据目录**里有配对记录,用 WDA 时还有 Apple ID 会话、开发签名私钥,开启自动解锁时还有**明文**的锁屏密码,要像密码一样保管和备份。Apple ID 密码本身不保存。 +- **数据目录**里有开发签名私钥和 Apple ID 会话(只有用 WDA 时),开启自动解锁时还有**明文**的锁屏密码,要像密码一样保管和备份。Apple ID 密码本身不保存。配对记录不在数据目录:由系统的 `usbmuxd` 保存在 `/var/lib/lockdown`(Linux)或 `/var/db/lockdown`(macOS)。 - **控制接口**是权限 0600 的 Unix socket,能连上它就能操控手机:主机 root 和运行守护进程的那个用户。 - **通知密钥**在设置文件 `~/.config/iphone-control/env` 里,权限 0600。 @@ -16,7 +16,7 @@ iphone-control 本质上是一个手机遥控器:能访问它的人,就能 - **不用 root。** 守护进程以你的普通用户身份作为用户服务运行,安装脚本拒绝以 root 运行。 - **自动解锁默认关闭**,输错一次即停用。 - **开发者工具默认关闭**。 -- 依赖锁定精确版本,下载的 WebDriverAgent 核对 sha256,安装脚本核对下载包的 sha256。 +- 依赖锁定精确版本。发行包随附 Ed25519 签名的清单,安装脚本和 `iphone-control update` 核对签名、名字、大小和 sha256;下载的 WebDriverAgent 也核对 sha256。 ## 需要知道的风险 diff --git a/website/guide/tools.md b/website/guide/tools.md index 1321e248..285bd593 100644 --- a/website/guide/tools.md +++ b/website/guide/tools.md @@ -23,7 +23,7 @@ MCP 服务提供 18 个工具,开启[开发者工具](#开发者工具-显式 | `iphone_tap_element` | 按文字点击;中心被悬浮栏、键盘挡住时改点露出来的部分,整个被挡住就不点。带 `scroll`(`down` / `up`)时,屏幕上没有就慢慢边滑边找,找到就点,滑到底或滑满 `max_scrolls`(默认 8)次为止 | | `iphone_long_press` | 长按;`seconds` 默认 1,最多 10 | | `iphone_swipe` | 滑动;列表停稳后才返回。`seconds` 默认 0.3,最多 10。`hold` 先在起点按住几秒再移动,用来拖动要先长按才拿得起来的东西(主屏幕图标、可排序的列表项),0.6 左右即可 | -| `iphone_type_text` | 在当前输入框输入文字(支持中文),输完读回核对,丢字会补上;`submit` 时按回车。原生控制下 `replace: true` 替换当前普通输入框的全文(`text` 为空时清空),核对全文后才会按回车 | +| `iphone_type_text` | 在当前输入框输入文字(支持中文),输完读回核对,丢字会补上;`submit` 时按回车。`replace: true` 替换当前普通输入框的全文(`text` 为空时清空),核对全文后才会按回车;原生控制下先选中原文再粘贴覆盖,失败时原文还在,经 WDA 时先清空输入框,清空后失败原文就没了 | | `iphone_press_button` | `home`、`volume_up`、`volume_down`、`lock` | | `iphone_launch_app` / `iphone_terminate_app` | 启动 / 结束 App,可以用名字(如「设置」)或 Bundle ID | | `iphone_open_url` | 打开链接或 URL Scheme | diff --git a/website/troubleshoot/faq.md b/website/troubleshoot/faq.md index 2db64aff..807eed1a 100644 --- a/website/troubleshoot/faq.md +++ b/website/troubleshoot/faq.md @@ -19,7 +19,7 @@ iphone-control doctor # 逐层检查,每项失败都给出修复办法 | 准备手机失败,稍后重试:… | 原生控制没准备好 | 看冒号后的错误,运行 `doctor`,见[原生控制准备不好](#native-control) | | WDA 还没签名安装 | — | 运行 `sign` 或 `setup` | | 正在启动 WDA | 最长约 2 分钟 | 等一下。iOS 27 起期间点击、滑动、截图走 HID 后备,仍可用,但横屏时要 30 秒内从 WDA 拿到过方向,否则拒绝触摸;屏幕尺寸未知时报错,见[工具一览](../guide/tools#wda-不可用时-hid-后备)。更早的 iOS 要等 WDA 起来 | -| WDA 卡在手机上的「Enable UI Automation」密码框 | 手机在等「为 XCTest 输入 iPhone 密码」 | 在手机上输入锁屏密码。手机重启后会出现,连续重启守护进程几次后有时也会。守护进程每 60 秒重试,只通知一次 | +| WDA 卡在手机上的「Enable UI Automation」密码框 | 手机在等「为 XCTest 输入 iPhone 密码」 | 在手机上输入锁屏密码。手机重启后会出现,连续重启守护进程几次后有时也会。守护进程每 5 秒重试一次,每次启动等约 25 秒,只通知一次 | | WDA 启动失败,稍后重试:… | 其他原因 | 看冒号后的错误,运行 `doctor`。重试会退避,最长间隔 5 分钟 | | 就绪 | 一切正常 | — | @@ -99,7 +99,7 @@ iOS 27 及以上默认原生控制,只要配对、开发者模式、开发者 ## 灵动岛一直显示「配对的电脑」、手机不自动锁屏 -HID 后备路线使用时,以及控制台在显示手机自己的视频(iOS 27 及以上)时,会开一个屏幕镜像会话;不再使用(关掉控制台页面)30 秒后自动关闭。图标一直不消失时,重启一下守护进程(`iphone-control service restart`)。 +HID 后备路线使用时,iOS 27 及以上原生控制下的点击、滑动和按键(它们也经 HID),以及控制台在显示手机自己的视频(iOS 27 及以上)时,会开一个屏幕镜像会话;不再使用(关掉控制台页面)30 秒后自动关闭。图标一直不消失时,重启一下守护进程(`iphone-control service restart`)。 ## 报告问题