noracu 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,136 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.4] — 2026-11-05
4
+
5
+ ### Fixed
6
+ - `phone_open` only taps an exact label inside Spotlight's Top Hit card. A web
7
+ suggestion, website or Settings row with the same name could be tapped
8
+ before: in testing, opening "Pinduoduo" opened a Chrome search and reported
9
+ success. A name the Top Hit card does not show now returns app not found —
10
+ use the label the phone shows under the icon (e.g. `拼多多`). The error says
11
+ whether a Top Hit was seen at all. `phone_open` reads Spotlight's English
12
+ "Top Hit" label; for an iPhone set to another language, set
13
+ `NORACU_TOPHIT_LABELS` to the label it shows. When tapping the label
14
+ does nothing, the icon is tapped only above where the label is now, not where
15
+ it was a moment earlier. `phone_open` also keeps its own time budget and goes
16
+ back to the Home Screen when it runs out, or when it is stopped or hits its
17
+ time limit, instead of leaving Spotlight open, and says so when it could not
18
+ get back.
19
+ - OCR reads Chinese. Vision ran English-first and returned almost no Chinese
20
+ text, so Chinese app names, `phone_find` and `expect` checks failed; Chinese
21
+ and English are now both read. `NORACU_OCR_LANGUAGES` sets other languages
22
+ (unsupported codes are skipped).
23
+ - `phone_launch` never clicks through a setup or welcome screen. After a
24
+ macOS 27 upgrade, iPhone Mirroring's welcome screen was reported as a paused
25
+ session, `phone_launch` said to lock the iPhone, and a lone button there
26
+ would have been clicked as if it were Resume. noracu now reports
27
+ `mirror_setup_required` and leaves the screen to you, and `phone_status` adds
28
+ a `setup` field. A paused mirror is still resumed in portrait or landscape.
29
+ - A stuck iPhone-layer subprocess can no longer freeze the server. iPhone
30
+ commands, including the menu commands behind `phone_home` and
31
+ `phone_app_switcher`, now run asynchronously under a time limit: on expiry
32
+ the command and everything it started are stopped, the call returns
33
+ `imctl_timeout` at once, and other requests — including `ping` — keep being
34
+ answered. `phone_open` and `phone_type` get 45 seconds (was 30);
35
+ `NORACU_PHONE_TIMEOUT_MS` sets another limit. A slow first check for the
36
+ iPhone driver's Python no longer disables the iPhone layer until restart.
37
+ - Phone and Mac actions run one at a time, in the order they arrive, even when
38
+ an MCP client sends tool calls in parallel, so taps, typing and the clipboard
39
+ of two calls never interleave. A queued action the client cancels, or one that
40
+ waited more than 60 seconds (`input_busy`), is dropped without acting, and the
41
+ server stops its iPhone-layer processes when it exits.
42
+ - `phone_type` keeps watching up to 15 more seconds for a paste that lands late
43
+ before reporting `type_not_confirmed`, and then says to read the screen before
44
+ retrying: retrying after a late paste typed the text twice. The text must be
45
+ seen in two consecutive screen reads.
46
+ - `phone_type` no longer reports `typed` while the iPhone is still fetching a
47
+ slow paste: the "Pasting from …" box the phone shows meanwhile was taken for
48
+ the text arriving. While that box shows, the paste does not count; the
49
+ 15-second check above then confirms it from the text itself, or the result is
50
+ `type_not_confirmed`. The box is recognized on an iPhone set to English.
51
+ - A paste can reach the iPhone seconds after it was sent (from 1.5 s to more
52
+ than 10 s on the test device). When `phone_open` does not see the name arrive,
53
+ it keeps reading Spotlight for up to 15 seconds, and if the name never shows up
54
+ it reports `open_not_confirmed` (retry) instead of app not found.
55
+ - `phone_open` right after another successful `phone_open` no longer fails. On
56
+ iOS 27, going Home from an app that was opened from Spotlight lands back in
57
+ Spotlight, and the Spotlight command then closed it, so the name was pasted
58
+ onto the Home Screen.
59
+ - `phone_screenshot` deletes its temporary image on every path, including
60
+ timeouts.
61
+
62
+ ### Security
63
+ - `phone_type` no longer gives your clipboard back just because the typed text
64
+ was already somewhere on the screen (for example a search-history entry with
65
+ the same words). It now counts the text before pasting and restores your
66
+ clipboard only when two screen reads afterwards both show it more often; until
67
+ then the clipboard keeps the typed text. Before, a paste that the phone read
68
+ late could have pasted your original clipboard contents instead.
69
+ - `phone_open` no longer gives your clipboard back after pasting the app name:
70
+ the name can reach the iPhone seconds after it was sent, and a restore before
71
+ then could paste your previous clipboard into Spotlight. The clipboard keeps
72
+ the app name.
73
+ - `phone_type` never gives your clipboard back while the iPhone still shows its
74
+ "Pasting from …" box: a paste is still on its way then and could fetch your
75
+ restored clipboard. The words in that box never count as the typed text.
76
+
77
+ ## [0.1.3] — 2026-11-04
78
+
79
+ ### Fixed
80
+ - `phone_open` is far more reliable: it opens Spotlight from the Home Screen
81
+ using Spotlight's own shortcut (trying once more if the phone ignores it),
82
+ clears the field and re-reads results, matches very short app names such as
83
+ "X", and confirms the app actually came to the foreground — tapping the app
84
+ icon when tapping its name does nothing.
85
+ - One- and two-letter names such as "X" no longer run past the 30-second tool
86
+ limit: short labels are read with a fast multi-scale OCR pass instead of slow
87
+ strip-by-strip reads. `phone_find` and the `expect` guard find them too.
88
+ - `phone_open` no longer taps the wrong result when OCR momentarily misses a
89
+ short app name. In testing, opening "X" could open a web search instead while
90
+ reporting success.
91
+ - `phone_type` keeps the typed text on the clipboard until the phone shows it
92
+ (verified by OCR) and only then restores your previous clipboard; it also
93
+ restores the clipboard if an error happens before the paste. For a single
94
+ character the restore also happens when the phone shows the paste several
95
+ seconds late — and never before. Nothing is pasted if another app or device
96
+ (Universal Clipboard) changes the clipboard just before the paste. Adds a
97
+ `replace` option to overwrite an existing field.
98
+ - `phone_scroll` validates its distance (in screen-heights) and reports when
99
+ nothing on screen moved.
100
+ - `phone_launch` reports whether the mirror is actually live, and says so when
101
+ the session is still paused.
102
+ - Moving the pointer over the iPhone Mirroring window no longer looks like a
103
+ paused session, and resuming a paused session never clicks the window's own
104
+ close or minimize buttons.
105
+ - Screenshots never silently fall back to grabbing an arbitrary screen region;
106
+ a capture failure is reported as unconfirmed instead of acting on the wrong
107
+ pixels. After bringing iPhone Mirroring to the front, noracu waits for a real
108
+ frame instead of failing on a blank transition frame.
109
+ - Before every input event, noracu asks macOS afresh whether iPhone Mirroring
110
+ is still the frontmost window, and sends nothing otherwise.
111
+
112
+ ### Security
113
+ - Phone screenshots taken for OCR were written to the shared temp directory,
114
+ readable by other local users, and never deleted. They now go to an
115
+ owner-only directory and are deleted as soon as they have been read. If you
116
+ ran an earlier version, delete leftover `imctl_*.png` files from your temp
117
+ directory (for example `/tmp`).
118
+
119
+ ### Added
120
+ - Optional `expect` guard on phone input tools: nothing is sent unless the
121
+ expected text is currently on screen.
122
+ - The server reports when its running process is older than the files on disk,
123
+ so a stale server is visible to the client.
124
+
125
+ ### Known issues
126
+ - Unchanged from 0.1.2: on iPhone 17 Pro Max + macOS 26, iPhone Mirroring draws
127
+ the phone larger than its window; the right column and bottom row stay out of
128
+ reach. Still under investigation.
129
+ - A single character typed with `phone_type` that leaves no new character on
130
+ screen (for example replacing "X" with "X") cannot be confirmed; the clipboard
131
+ then keeps the typed character rather than risk pasting your previous
132
+ clipboard into the phone.
133
+
3
134
  ## [0.1.2] — 2026-11-02
4
135
 
5
136
  ### Fixed
package/README.md CHANGED
@@ -89,6 +89,10 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
89
89
  | `browser_launch` hangs on first use | one-time Chromium download; or auto-install disabled (`NORACU_DISABLE_AUTO_INSTALL=1`) → run `npx playwright install chromium` |
90
90
  | `phone_*` says `imctl unavailable: no python3 with pyobjc found` | install pyobjc for a python3 (`python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`; Homebrew python3 is the usual choice) or set `NORACU_PYTHON` — see [iPhone layer](#iphone-layer-experimental) |
91
91
  | `phone_*` refused with `mirror_not_live: …` ("Connection Paused", "iPhone in Use") | the mirror is paused or the iPhone is unlocked — lock the iPhone, keep it near the Mac, then call `phone_launch` (it clicks Resume) |
92
+ | `phone_launch` says `mirror_setup_required` | iPhone Mirroring shows a setup or welcome screen (e.g. the first launch after a macOS upgrade) — finish it yourself in the iPhone Mirroring window; noracu never clicks through it |
93
+ | `imctl_timeout: phone … did not finish within …s` | the Mac is under heavy load or the system is stuck — the action may have partly run, so check `phone_status` / `phone_screenshot` before retrying (after `phone_open`, noracu goes back to the Home Screen); the server keeps answering other calls meanwhile |
94
+ | `input_busy: …` | an earlier phone or Mac action held the input queue for over 60 s; the call did nothing — retry |
95
+ | `phone_open` returns app not found for an installed app | it only taps the label in Spotlight's Top Hit card — use the name exactly as the phone shows it under the icon (e.g. `拼多多`, not `Pinduoduo`). "Spotlight showed no Top Hit" on an installed app usually means the iPhone's language is not English: `phone_open` reads Spotlight's "Top Hit" label — set `NORACU_TOPHIT_LABELS` to the label your iPhone shows. `open_not_confirmed: … never showed up on the phone` means the pasted name did not arrive (a paste can take several seconds to reach the iPhone) — retry. `phone_open` leaves the app name on the clipboard |
92
96
  | Typed text comes out re-spaced (e.g. "no ra cu") | a CJK input method is active — use `mac_paste` instead of `mac_type` |
93
97
  | `element_no_longer_valid` | the snapshot is older than 30 s or the UI changed — re-run `mac_ax_state` / `browser_snapshot` and use a fresh index |
94
98
 
@@ -106,13 +110,13 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
106
110
 
107
111
  **Python:** the driver needs a python3 that imports pyobjc (Quartz, Vision, AppKit). Set `NORACU_PYTHON`, or noracu probes `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` once, on the first `phone_*` call. Apple's `/usr/bin/python3` usually lacks pyobjc; Homebrew's python3 plus `python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit` is the common working setup.
108
112
 
109
- **Mirror state:** `phone_status` reports `live` (the phone's screen is being streamed), `overlay` (the text iPhone Mirroring shows instead, e.g. "Connection Paused" or "iPhone in Use") and `paused` (that overlay offers a Resume button). Detection reads the window's structure, not its text. While the mirror is not live, `phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key` and `phone_open` refuse with `mirror_not_live` instead of tapping the overlay, and `phone_ocr` / `phone_find` start their output with a warning. The mirror pauses after inactivity; `phone_launch` brings it forward and clicks Resume.
113
+ **Mirror state:** `phone_status` reports `live` (the phone's screen is being streamed), `overlay` (the text iPhone Mirroring shows instead, e.g. "Connection Paused" or "iPhone in Use"), `paused` (that overlay offers a Resume button) and `setup` (a setup or welcome screen the user must finish — noracu never clicks it). Detection reads the window's structure and shape (the mirror is a tall or wide phone-shaped window; a setup screen is nearly square), not its text. While the mirror is not live, `phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key` and `phone_open` refuse with `mirror_not_live` instead of tapping the overlay, and `phone_ocr` / `phone_find` start their output with a warning. The mirror pauses after inactivity; `phone_launch` brings it forward and clicks Resume.
110
114
 
111
115
  **Privacy:** whatever the phone shows — notifications, messages, mail, one-time codes — becomes tool output that your MCP client sends to its model. Turn on a Focus, open a neutral app before you start, and begin with `NORACU_READ_ONLY=1` (`phone_status`, `phone_screenshot`, `phone_ocr` and `phone_find` stay allowed; all phone input is refused). iPhone notifications also reach the Mac once Mirroring is set up.
112
116
 
113
117
  **First success:** `phone_status` → `phone_launch` if `live` is not `true` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`.
114
118
 
115
- **Known limits:** a tap goes where OCR saw the text, so repeated or misread labels can be hit wrong; `phone_scroll` moves lists with trackpad-style scroll events (a vertical `phone_swipe` drag does not scroll a list — use it for gestures such as Home Screen paging); on one tested setup (iPhone 17 Pro Max, macOS 26) iPhone Mirroring draws the phone larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps an exact match, otherwise returns to the Home Screen; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu (English macOS) and work without python while connected.
119
+ **Known limits:** a tap goes where OCR saw the text, so repeated or misread labels can be hit wrong (`phone_open` cannot tell an app from a contact or website that Spotlight's Top Hit shows under the same name); `phone_scroll` moves lists with trackpad-style scroll events (a vertical `phone_swipe` drag does not scroll a list — use it for gestures such as Home Screen paging); on one tested setup (iPhone 17 Pro Max on iOS 27.0.1, Mac on macOS 26.6.2) iPhone Mirroring draws the phone about 17% larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached; moving the window between displays, changing the main display and relaunching made no difference, and the iOS 27 / macOS 26 version mismatch is the main suspect — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps it only when Spotlight's Top Hit card shows exactly that name (web suggestions, websites and Settings rows of the same name are never tapped), otherwise returns to the Home Screen — it reads Spotlight's English "Top Hit" label, so on an iPhone set to another language it finds nothing until `NORACU_TOPHIT_LABELS` names that label; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu (English macOS) and work without python while connected.
116
120
 
117
121
  ## Environment variables
118
122
 
@@ -125,6 +129,9 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
125
129
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick binary path |
126
130
  | `NORACU_PYTHON` | auto-probe | python3 used for the bundled iPhone driver; must import pyobjc (Quartz, Vision, AppKit). Unset → first working of `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` |
127
131
  | `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
132
+ | `NORACU_PHONE_TIMEOUT_MS` | 30000 (45000 for `phone_open` / `phone_type`) | time limit for each iPhone-layer step, 1000–600000 ms; on expiry the step is stopped and returns `imctl_timeout` |
133
+ | `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | OCR languages for the iPhone screen, in priority order (comma-separated Vision language codes, e.g. `zh-Hant,en-US` or `en-US`; codes Vision does not list are skipped with a warning) |
134
+ | `NORACU_TOPHIT_LABELS` | `Top Hit` | the label of Spotlight's Top Hit section that `phone_open` looks for, comma-separated — set it to the label your iPhone shows when it is not set to English |
128
135
 
129
136
  ## Security
130
137
 
package/README.zh-CN.md CHANGED
@@ -89,6 +89,10 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
89
89
  | 首次 `browser_launch` 卡住 | 一次性 Chromium 下载;或自动安装被关闭(`NORACU_DISABLE_AUTO_INSTALL=1`)→ 执行 `npx playwright install chromium` |
90
90
  | `phone_*` 报 `imctl unavailable: no python3 with pyobjc found` | 给某个 python3 装 pyobjc(`python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`,通常选 Homebrew 的 python3)或设 `NORACU_PYTHON`——见[iPhone 层](#iphone-层实验性) |
91
91
  | `phone_*` 被拒并报 `mirror_not_live: …`("Connection Paused"、"iPhone in Use") | 镜像已暂停或 iPhone 被解锁——锁上 iPhone、放在 Mac 旁,然后调用 `phone_launch`(会点击 Resume) |
92
+ | `phone_launch` 报 `mirror_setup_required` | iPhone Mirroring 正显示设置或欢迎页(例如升级 macOS 后首次启动)——请在 iPhone Mirroring 窗口里自己完成;noracu 从不替你点击这类页面 |
93
+ | `imctl_timeout: phone … did not finish within …s` | Mac 负载过高或系统卡住——操作可能已部分执行,重试前先看 `phone_status` / `phone_screenshot`(`phone_open` 超时后 noracu 会回到主屏幕);在此期间 server 仍会响应其他调用 |
94
+ | `input_busy: …` | 前一个手机或 Mac 操作占用输入队列超过 60 秒;本次调用什么都没做——重试即可 |
95
+ | 已安装的 App,`phone_open` 却报 app not found | 它只点 Spotlight「Top Hit」卡片里的标签——名字要和手机图标下显示的一致(例如 `拼多多`,而不是 `Pinduoduo`)。已安装却报 "Spotlight showed no Top Hit",通常说明 iPhone 系统语言不是英文:`phone_open` 读的是 Spotlight 的 "Top Hit" 标签——把 `NORACU_TOPHIT_LABELS` 设成手机上显示的标签。报 `open_not_confirmed: … never showed up on the phone` 则是粘贴的名字没有到达手机(粘贴到 iPhone 可能要好几秒)——重试即可。`phone_open` 之后剪贴板里是 App 名字 |
92
96
  | 输入的文本被重新空格化(如 "no ra cu") | 有 CJK 输入法在激活——用 `mac_paste` 代替 `mac_type` |
93
97
  | `element_no_longer_valid` | 快照超过 30 秒或界面变了——重跑 `mac_ax_state` / `browser_snapshot` 并用新索引 |
94
98
 
@@ -106,13 +110,13 @@ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在
106
110
 
107
111
  **Python:** 驱动需要一个能导入 pyobjc(Quartz、Vision、AppKit)的 python3。设置 `NORACU_PYTHON`,或由 noracu 在首次调用 `phone_*` 时依次探测一次 `/opt/homebrew/bin/python3`、`/usr/local/bin/python3`、`python3`、`/usr/bin/python3`。Apple 自带的 `/usr/bin/python3` 通常没有 pyobjc;常见可用配置是 Homebrew 的 python3 加 `python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`。
108
112
 
109
- **镜像状态:** `phone_status` 返回 `live`(手机画面正在推流)、`overlay`(iPhone Mirroring 显示的替代文字,如 "Connection Paused"、"iPhone in Use")和 `paused`(该覆盖层带 Resume 按钮)。判定依据是窗口结构,不是文字。镜像不在线时,`phone_tap`、`phone_longpress`、`phone_swipe`、`phone_scroll`、`phone_type`、`phone_key`、`phone_open` 会以 `mirror_not_live` 拒绝,而不是点到覆盖层上;`phone_ocr` / `phone_find` 的输出首行会给出警告。镜像闲置一段时间后会暂停;`phone_launch` 会把它置前并点击 Resume。
113
+ **镜像状态:** `phone_status` 返回 `live`(手机画面正在推流)、`overlay`(iPhone Mirroring 显示的替代文字,如 "Connection Paused"、"iPhone in Use")、`paused`(该覆盖层带 Resume 按钮)和 `setup`(需要用户自己完成的设置或欢迎页——noracu 从不点击)。判定依据是窗口结构和形状(镜像窗口是竖长或横长的手机形状,设置页接近正方形),不是文字。镜像不在线时,`phone_tap`、`phone_longpress`、`phone_swipe`、`phone_scroll`、`phone_type`、`phone_key`、`phone_open` 会以 `mirror_not_live` 拒绝,而不是点到覆盖层上;`phone_ocr` / `phone_find` 的输出首行会给出警告。镜像闲置一段时间后会暂停;`phone_launch` 会把它置前并点击 Resume。
110
114
 
111
115
  **隐私:** 手机上显示的一切——通知、短信、邮件、一次性验证码——都会变成工具输出,由你的 MCP client 发给它所用的模型。开始前打开专注模式、打开一个无关紧要的 App,并先用 `NORACU_READ_ONLY=1`(`phone_status`、`phone_screenshot`、`phone_ocr`、`phone_find` 仍可用;所有手机输入都会被拒绝)。iPhone Mirroring 设置好后,iPhone 的通知也会出现在 Mac 上。
112
116
 
113
117
  **首次成功路径:** `phone_status` → 若 `live` 不是 `true` 先 `phone_launch` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`。
114
118
 
115
- **已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错;`phone_scroll` 用触控板式的滚动事件移动列表(竖向的 `phone_swipe` 拖拽不会滚动列表——它用于主屏翻页这类手势);在一套实测环境(iPhone 17 Pro Max、macOS 26)上,iPhone Mirroring 在所有 View 尺寸下都把手机画面画得比窗口大,右列和最底行被裁掉、无法点到——边缘附近点不中时先看 `phone_screenshot`;`phone_open` 把 App 名输入 Spotlight 并只点击完全匹配的结果,找不到就回到主屏;`phone_home` / `phone_app_switcher` 走 iPhone Mirroring 菜单(英文 macOS),镜像连接时无需 python。
119
+ **已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错(若 Spotlight 的「Top Hit」里是同名的联系人或网站,`phone_open` 分辨不出它不是 App);`phone_scroll` 用触控板式的滚动事件移动列表(竖向的 `phone_swipe` 拖拽不会滚动列表——它用于主屏翻页这类手势);在一套实测环境(iPhone 17 Pro Max 运行 iOS 27.0.1,Mac 运行 macOS 26.6.2)上,iPhone Mirroring 在所有 View 尺寸下都把手机画面画得比窗口大约 17%,右列和最底行被裁掉、无法点到;在显示器之间移动窗口、切换主屏、重开 App 都无效,主要怀疑是 iOS 27 与 macOS 26 版本错位——边缘附近点不中时先看 `phone_screenshot`;`phone_open` 把 App 名输入 Spotlight,只有当 Spotlight 的「Top Hit」卡片显示的正是这个名字时才点击(同名的网页建议、网站和设置行一律不点),否则回到主屏——它读的是 Spotlight 的英文 "Top Hit" 标签,iPhone 设为其他语言时找不到任何 App,除非用 `NORACU_TOPHIT_LABELS` 指定那个标签;`phone_home` / `phone_app_switcher` 走 iPhone Mirroring 菜单(英文 macOS),镜像连接时无需 python。
116
120
 
117
121
  ## 环境变量
118
122
 
@@ -125,6 +129,9 @@ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在
125
129
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick 二进制路径 |
126
130
  | `NORACU_PYTHON` | 自动探测 | 运行随包 iPhone 驱动的 python3;须能导入 pyobjc(Quartz、Vision、AppKit)。未设置时依次尝试 `/opt/homebrew/bin/python3`、`/usr/local/bin/python3`、`python3`、`/usr/bin/python3` |
127
131
  | `NORACU_IMCTL_DIR` | 包内 `imctl/` | 覆盖驱动位置(仅开发用) |
132
+ | `NORACU_PHONE_TIMEOUT_MS` | 30000(`phone_open` / `phone_type` 为 45000) | iPhone 层每一步的时限,1000–600000 毫秒;到时该步被终止并返回 `imctl_timeout` |
133
+ | `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | 识别 iPhone 画面的 OCR 语言及优先顺序(逗号分隔的 Vision 语言代码,如 `zh-Hant,en-US` 或 `en-US`;Vision 不支持的代码会被跳过并给出警告) |
134
+ | `NORACU_TOPHIT_LABELS` | `Top Hit` | `phone_open` 要找的 Spotlight「Top Hit」分区标签,逗号分隔——iPhone 不是英文时,设成手机上实际显示的那个标签 |
128
135
 
129
136
  ## 安全
130
137
 
package/docs/tools.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Tool reference
2
2
 
3
3
  > Auto-generated from the running server (`node scripts/gen-tools.mjs`) — always in sync with the implementation.
4
- > noracu v0.1.2 · 35 tools
4
+ > noracu v0.1.4 · 35 tools
5
5
 
6
6
  ## Mac layer (computer-use)
7
7
 
@@ -44,18 +44,18 @@
44
44
 
45
45
  | Tool | Arguments | Description |
46
46
  |---|---|---|
47
- | `phone_status` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Return the iPhone Mirroring session status as JSON (running, window, onscreen, frontmost, live, overlay, paused). |
48
- | `phone_launch` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Ensure iPhone Mirroring is running, brought to the front, and clicks Resume when the connection is paused. |
49
- | `phone_screenshot` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Screenshot the iPhone screen (the Mirroring window, captured by window id so it works even when covered). |
50
- | `phone_ocr` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. OCR the iPhone screen into text with coordinates. |
51
- | `phone_find` | text:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Locate text on the iPhone screen. |
52
- | `phone_tap` | x:number?, y:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Tap at {x, y} in normalized 0-1 coordinates. Refused with mirror_not_live when the mirror is paused. |
53
- | `phone_longpress` | x:number?, y:number?, duration:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Long-press at {x, y} for an optional duration in seconds. |
54
- | `phone_swipe` | from:array?, to:array?, ms:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Swipe (mouse drag) from [x,y] to [x,y] over an optional duration in ms, for gestures such as Home Screen paging; to move a list use phone_scroll. |
47
+ | `phone_status` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Return the iPhone Mirroring session status as JSON (running, window, onscreen, frontmost, live, overlay, paused, setup — true when a setup or welcome screen is showing that the user must finish). |
48
+ | `phone_launch` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Ensure iPhone Mirroring is running, brought to the front, and clicks Resume when the connection is paused. Never clicks through a setup or welcome screen: reports mirror_setup_required instead. |
49
+ | `phone_screenshot` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Screenshot the iPhone screen (the Mirroring window, captured by window id so it works even when covered). Fails with capture_failed instead of returning another window's pixels. |
50
+ | `phone_ocr` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. OCR the iPhone screen into text with coordinates. Fails with capture_failed instead of returning another window's pixels. |
51
+ | `phone_find` | text:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Locate text on the iPhone screen. Fails with capture_failed instead of returning another window's pixels. |
52
+ | `phone_tap` | x:number?, y:number?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Tap at {x, y} in normalized 0-1 coordinates. Refused with mirror_not_live when the mirror is paused. Optional expect: text that must be on screen (OCR) first, else nothing is sent. |
53
+ | `phone_longpress` | x:number?, y:number?, duration:number?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Long-press at {x, y} for an optional duration in seconds. Optional expect: text that must be on screen (OCR) first, else nothing is sent. |
54
+ | `phone_swipe` | from:array?, to:array?, ms:number?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Swipe (mouse drag) from [x,y] to [x,y] over an optional duration in ms, for gestures such as Home Screen paging; to move a list use phone_scroll. Optional expect: text that must be on screen (OCR) first, else nothing is sent. |
55
55
  | `phone_home` | — | EXPERIMENTAL. Go to the iPhone Home Screen via the iPhone Mirroring menu (works without python/pyobjc when the mirror is connected); falls back to an imctl swipe. |
56
56
  | `phone_app_switcher` | — | EXPERIMENTAL. Open the iPhone App Switcher via the iPhone Mirroring menu (works without python/pyobjc when the mirror is connected); falls back to an imctl gesture. |
57
- | `phone_scroll` | direction:string?, distance:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Scroll the list under the mirror up or down by about `distance` window heights (default 0.5), using trackpad-style scroll events. |
58
- | `phone_type` | text:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe). |
59
- | `phone_key` | key:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Press a key: return, delete, up, down, left, or right. |
60
- | `phone_open` | app:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Open an app via the mirroring Spotlight menu command/shortcut, type the name, OCR-pick the matching app row and tap it; returns to the home screen when not found. |
57
+ | `phone_scroll` | direction:string?, distance:number?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Scroll up or down by `distance` window heights (0 < distance <= 3, default 0.5) using trackpad-style scroll events. Reports scroll_no_effect when the screen did not change (list end, or the view does not scroll). Optional expect: text that must be on screen (OCR) first, else nothing is sent. |
58
+ | `phone_type` | text:string?, replace:boolean?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe). Restores the clipboard only after OCR sees the text appear (more often than before the paste) within its 2.5 s check; a paste that shows up a few seconds later is still reported as typed (do not type it again) but the clipboard keeps the typed text; otherwise type_not_confirmed, and the clipboard keeps the text. replace=true selects all and overwrites the field (over the same text nothing visibly changes, so that may report type_not_confirmed). Optional expect: on-screen text (OCR), else nothing is sent. |
59
+ | `phone_key` | key:string?, expect:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Press a key: return, delete, up, down, left, or right. Optional expect: text that must be on screen (OCR) first, else nothing is sent. |
60
+ | `phone_open` | app:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Open an app: Home Screen, Spotlight via the menu, clear, type the name (the clipboard keeps it), then tap only an exact label inside the Spotlight Top Hit card (suggestion, website and Settings rows of the same name are ignored, so a name the Top Hit card does not show is app not found; reads the English "Top Hit" label unless NORACU_TOPHIT_LABELS names the phone's own; a pasted name that never shows up in Spotlight, even after up to 15 s, is open_not_confirmed — retry); confirms the app opened (frame diff + OCR), taps the Top Hit icon when the label tap does nothing, else open_not_confirmed, back on the Home Screen. |
61
61
 
package/docs/usage.md CHANGED
@@ -176,6 +176,8 @@ model — don't let it override the task.
176
176
  | `… blocked by NORACU_READ_ONLY=1` | you're in observation-only mode — unset it to act |
177
177
  | `browser_evaluate disabled by NORACU_DISABLE_EVAL=1` | eval kill-switch is on |
178
178
  | `mirror_not_live: …` | iPhone Mirroring shows an overlay (paused, "iPhone in Use") — lock the iPhone, keep it near the Mac, call `phone_launch` |
179
+ | `mirror_setup_required: …` | iPhone Mirroring shows a setup or welcome screen — finish it yourself in its window, then call `phone_launch` |
180
+ | `imctl_timeout: …` | a phone step ran past its time limit and was stopped — check `phone_status` / `phone_screenshot` before retrying (after `phone_open`, noracu goes back to the Home Screen); raise `NORACU_PHONE_TIMEOUT_MS` on a slow Mac |
179
181
  | `imctl unavailable: no python3 with pyobjc found …` | install pyobjc for a python3 (`python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`) or set `NORACU_PYTHON` |
180
182
 
181
183
  ## 9. iPhone layer
@@ -213,9 +215,11 @@ phone_tap {"x": 0.50, "y": 0.06}
213
215
  → tapped (0.5, 0.06)
214
216
  ```
215
217
 
216
- `live` / `overlay` / `paused` come from the window's structure, not its
217
- language: a live mirror is a single empty hosting view; "Connection Paused",
218
- "iPhone in Use" and similar states add text and a button. While the mirror is
218
+ `live` / `overlay` / `paused` / `setup` come from the window's structure and
219
+ shape, not its language: a live mirror is a single empty hosting view;
220
+ "Connection Paused", "iPhone in Use" and similar states add text and a button;
221
+ a setup or welcome screen (`setup: true`) sits in a window that is not
222
+ phone-shaped, and `phone_launch` never clicks it. While the mirror is
219
223
  not live, `phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`,
220
224
  `phone_type`, `phone_key` and `phone_open` refuse with `mirror_not_live`, and
221
225
  `phone_ocr` / `phone_find` start with a `warning: mirror not live …` line.
@@ -225,11 +229,20 @@ mirror by about half a window, with trackpad-style scroll events; a vertical
225
229
  `phone_swipe` drag does not scroll lists in iPhone Mirroring, so keep swipes
226
230
  for gestures such as Home Screen paging.
227
231
 
228
- `phone_type` pastes through the clipboard with a real Command-V chord (the
229
- previous text clipboard is restored). `phone_open {"app": "Calculator"}` opens
230
- Spotlight through iPhone Mirroring's own shortcut, pastes the name, and taps a
231
- result whose OCR text matches the name exactly; with no match it returns to the
232
- Home Screen and reports `app not found`.
232
+ `phone_type` pastes through the clipboard with a real Command-V chord and
233
+ restores the previous text clipboard once OCR sees the pasted text appear on
234
+ the phone (more often than before the paste — text already on screen does not
235
+ count). If the paste only shows up a few seconds late, it is still reported as
236
+ typed — do not type it again — but the clipboard then keeps the typed text.
237
+ `phone_open {"app": "Calculator"}` opens Spotlight through iPhone Mirroring's
238
+ own shortcut, pastes the name, and taps it only when Spotlight's Top Hit card
239
+ shows exactly that name (a web suggestion or Settings row with the same name
240
+ is never tapped); otherwise it returns to the Home Screen and reports
241
+ `app not found`. A paste can take several seconds to reach the iPhone: when the
242
+ name never shows up, `phone_open` waits up to 15 s and then reports
243
+ `open_not_confirmed` (retry) rather than `app not found`. Use the name the phone shows under the icon (`拼多多`, not
244
+ `Pinduoduo`); it reads Spotlight's English "Top Hit" label, so on an iPhone
245
+ set to another language set `NORACU_TOPHIT_LABELS` to the label the phone shows.
233
246
 
234
247
  Privacy: everything the phone shows — notifications, messages, one-time
235
248
  codes — becomes tool output that your MCP client sends to its model. Use a
package/imctl/README.md CHANGED
@@ -77,10 +77,10 @@ imctl status
77
77
 
78
78
  | Command | Description |
79
79
  |---------|-------------|
80
- | `status` | session + window info (JSON: running, window, window_id, onscreen, frontmost, live, overlay, paused) |
80
+ | `status` | session + window info (JSON: running, window, window_id, onscreen, frontmost, live, overlay, paused, setup) |
81
81
  | `screenshot [PATH]` | capture the mirroring window to PNG by window id (works when covered) |
82
- | `resume` | click Resume when the window shows Connection Paused |
83
- | `launch` | ensure mirroring is running and frontmost |
82
+ | `resume` | click Resume when the window shows Connection Paused (never on a setup or welcome screen) |
83
+ | `launch` | ensure mirroring is running and frontmost; resumes a paused session, never clicks a setup screen (`mirror_setup_required`) |
84
84
  | `tap X Y` | tap at normalized coords (0-1) |
85
85
  | `longpress X Y [D]` | long-press (default 0.8s) |
86
86
  | `swipe FX FY TX TY [--ms]` | eased swipe between two points |
@@ -92,7 +92,7 @@ imctl status
92
92
  | `key K` | return / delete / up / down / left / right |
93
93
  | `ocr` | OCR the screen with coordinates |
94
94
  | `find TEXT` | locate text on screen |
95
- | `open APP` | open an app via Spotlight + OCR + tap |
95
+ | `open APP` | open an app via Spotlight + OCR + tap (only an exact label inside the Top Hit card) |
96
96
  | `verify ACTION` | run a gesture and verify the screen changed |
97
97
 
98
98
  ## Python API