noracu 0.2.6 → 0.2.7
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 +89 -0
- package/README.md +5 -2
- package/README.zh-CN.md +5 -2
- package/SECURITY.md +1 -1
- package/docs/tools.md +3 -3
- package/imctl/pyproject.toml +1 -1
- package/imctl/src/imctl/__init__.py +1 -1
- package/imctl/src/imctl/cli.py +62 -16
- package/imctl/src/imctl/gestures.py +136 -13
- package/imctl/src/imctl/input.py +98 -23
- package/imctl/src/imctl/pointer.py +81 -0
- package/imctl/src/imctl/verify.py +12 -4
- package/imctl/src/imctl/window.py +39 -6
- package/package.json +3 -3
- package/src/server.mjs +106 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,94 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.2.7] — 2026-11-08
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- The person at the Mac goes first. Before a Mac or iPhone input tool acts,
|
|
7
|
+
noracu reads how long ago the Mac's keyboard or mouse was last used; when
|
|
8
|
+
that was less than 2 s ago and not noracu's own input, the call returns
|
|
9
|
+
`user_active` and sends nothing (`delivery=not_delivered, retry=safe`) —
|
|
10
|
+
retry after a pause. Read-only tools (screenshots, accessibility reads,
|
|
11
|
+
`phone_status`, OCR) and the browser layer are not held up. After a
|
|
12
|
+
physical Mac click, drag or scroll, and after a phone gesture, the pointer
|
|
13
|
+
goes back where it was — moved back without an event, and only while it
|
|
14
|
+
is still where noracu left it, so a pointer someone moved meanwhile stays
|
|
15
|
+
where they put it. `NORACU_USER_IDLE_S` sets the wait (default 2, 0 to
|
|
16
|
+
60); `0` turns both off, for a Mac dedicated to the agent. `mac_status`
|
|
17
|
+
reports the value as `user_idle_s`. macOS keeps one idle time, and
|
|
18
|
+
noracu's own events reset it too (measured on macOS 27.2), so an event
|
|
19
|
+
counts as the person's only when it came after noracu's previous input
|
|
20
|
+
had ended: a key pressed or mouse moved while that input was running is
|
|
21
|
+
not seen, and the check runs once, before the call acts.
|
|
22
|
+
|
|
23
|
+
### Fixed
|
|
24
|
+
- `phone_type` (and the name `phone_open` types into Spotlight) waits at
|
|
25
|
+
least 1.5 s between writing the Mac clipboard and sending ⌘V. iPhone
|
|
26
|
+
Mirroring pastes through Universal Clipboard, which tells the phone
|
|
27
|
+
about new clipboard content with a delay. In a device run (macOS 27.2),
|
|
28
|
+
once in about 30 pastes, a ⌘V sent about 0.5 s after the write pasted
|
|
29
|
+
the text the Mac clipboard held before the write instead of the new
|
|
30
|
+
text. The 1.5 s is a judgement, not a measured delay: it is meant to let
|
|
31
|
+
the new text reach the phone first and does not rule the race out, and
|
|
32
|
+
it does not help when the phone shows "Pasting from …" and then pastes
|
|
33
|
+
nothing, which was also seen. `type_not_confirmed` now says the field
|
|
34
|
+
may hold the phone's older clipboard, so read it before typing again,
|
|
35
|
+
and `phone_open`'s `open_not_confirmed` no longer says the name was
|
|
36
|
+
pasted. A clipboard change during the wait still stops the paste before
|
|
37
|
+
⌘V. The screen count that decides whether the paste showed up (and
|
|
38
|
+
whether your clipboard is put back) is now read after the wait, right
|
|
39
|
+
before ⌘V, so text that appears during the wait cannot pass for the
|
|
40
|
+
paste. Each `phone_type` and `phone_open` call takes about 1.5 s longer.
|
|
41
|
+
- If another app (or another Space) comes to the front during that wait,
|
|
42
|
+
⌘V is called off — checked right after the wait, before any screen read,
|
|
43
|
+
and again right before ⌘V — instead of bringing iPhone Mirroring back to
|
|
44
|
+
the front, and your clipboard is put back unless something else copied
|
|
45
|
+
meanwhile: `phone_type` returns `focus_lost` saying nothing was sent
|
|
46
|
+
(or, with `replace`, that only the select-all went out), and
|
|
47
|
+
`phone_open` returns `focus_lost` without going back to the Home Screen,
|
|
48
|
+
which would also bring iPhone Mirroring forward (Spotlight may stay
|
|
49
|
+
open). When another app or device writes the clipboard before ⌘V,
|
|
50
|
+
`phone_open` now goes back to the Home Screen and says the name was not
|
|
51
|
+
pasted, instead of ending with an input error. `phone_type` results that
|
|
52
|
+
OCR cannot confirm (a text of one to three characters, or one seen only
|
|
53
|
+
in the top strip) now say the field may hold the phone's older
|
|
54
|
+
clipboard, and the phone's "Pasting from …" box also counts when OCR
|
|
55
|
+
splits it over two lines.
|
|
56
|
+
- `phone_open` opens apps again on iPhones whose Spotlight puts the search
|
|
57
|
+
field at the top and shows no "Top Hit" card (iOS 27's "Search or Ask").
|
|
58
|
+
There every `phone_open` failed with `open_not_confirmed: … never showed
|
|
59
|
+
up on the phone` although the name had been pasted (0.2.6 too). It now
|
|
60
|
+
reads the field, which shows the query completed as "<name> — Open", and
|
|
61
|
+
taps the exact label just under the field (above the first section
|
|
62
|
+
header) only when that completion names exactly this app; any other
|
|
63
|
+
completion, or none, is `app not found` with nothing tapped. In a device
|
|
64
|
+
run (iOS 27, macOS 27.2): Calculator 2/2 and Clock 2/2 back to back
|
|
65
|
+
opened, an unknown name returned `app not found`. The "Open" completion
|
|
66
|
+
is read in English only; `NORACU_TOPHIT_LABELS` covers the Top Hit
|
|
67
|
+
label, not this word.
|
|
68
|
+
- The iPhone layer no longer loses the mirror window while the phone's
|
|
69
|
+
keyboard is composing (for example a Pinyin letter that is still
|
|
70
|
+
underlined). iPhone Mirroring then shows a small candidate-bar window
|
|
71
|
+
(397×28 in a device run on macOS 27.2), and the window lookup took that
|
|
72
|
+
one: `phone_status` reported its size with `live: null`, and `phone_key`,
|
|
73
|
+
`phone_tap` and the other inputs returned `mirror_state_unknown` and sent
|
|
74
|
+
nothing — so even the `delete` that ends the composition could not go
|
|
75
|
+
out. The bounds, overlay and Resume lookups now use the iPhone Mirroring
|
|
76
|
+
window itself (the first standard window, found by its position in the
|
|
77
|
+
window list on every call) and fall back to the old lookup only when
|
|
78
|
+
there is none. A failed bounds read is retried once after 0.3 s (a read
|
|
79
|
+
sends nothing to the phone): during a connection blip System Events
|
|
80
|
+
briefly could not find the window.
|
|
81
|
+
|
|
82
|
+
### Docs
|
|
83
|
+
- SECURITY.md threat 18 (clipboard on the phone path) now describes the
|
|
84
|
+
wait before ⌘V and the `focus_lost` call-off, and lists what remains: an
|
|
85
|
+
early ⌘V can still paste the phone's own older clipboard, an older
|
|
86
|
+
clipboard that contains the typed text can pass for the paste, and the
|
|
87
|
+
"Pasting from" box is recognized only in English.
|
|
88
|
+
- README (both languages): `open_not_confirmed: … never showed up` no
|
|
89
|
+
longer reads as "the name did not arrive" only, and the known limits
|
|
90
|
+
describe the top-field Spotlight.
|
|
91
|
+
|
|
3
92
|
## [0.2.6] — 2026-11-07
|
|
4
93
|
|
|
5
94
|
### Changed
|
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ noracu is the local hands, not the model. Your MCP client (Claude Desktop, Claud
|
|
|
34
34
|
- **The server runs entirely on your machine.** No cloud service, no API key, no telemetry, no postinstall scripts. Sole runtime dependency: Playwright. noracu makes no network calls of its own; the only automatic one is the one-time Chromium download on the first `browser_launch` (`NORACU_DISABLE_AUTO_INSTALL=1` turns that off). With `NORACU_ALLOW_CDP=1` it also talks to a DevTools port on 127.0.0.1 that it opened itself (`NORACU_ALLOW_CDP=any` for other loopback ports). The browser still fetches the pages you point it at, and your MCP client still sends tool results — screenshots, OCR text — to whatever model it uses.
|
|
35
35
|
- **Acts on semantics, not pixels.** Observation returns the accessibility tree (Mac, read directly through the macOS Accessibility API — about 0.15 s for a 500-element window on our test Mac) or ARIA tree (browser) as an indexed list — text, not screenshots. Actions reference `element_index`; indices expire after 30 s. On the Mac an index is backed by identity evidence (the window's ID, the child path, role, identifier, name) and the element is re-identified before every action; in the browser, tag/name/href/position are re-checked. A gone or changed element returns `element_no_longer_valid` instead of clicking the wrong thing. Screenshots are there when the tree is not enough.
|
|
36
36
|
- **Says what happened.** A Mac action uses the element's own accessibility action when it has one (press, select, set value, insert text — no pointer, no focus change, IME-safe text); a physical click is sent only after a hit test shows that the point reaches the element. Every input action result (Mac, browser and iPhone) states whether it was delivered (`delivered_verified` when a change was observed, `delivered_unverified`, `not_delivered`, or `unknown` when a step timed out or failed mid-action) and whether a retry is safe; Mac actions also name any sheet, dialog or menu they opened.
|
|
37
|
+
- **Shares the Mac with you.** Mac and iPhone input goes second to the person at the Mac: if the keyboard or mouse was used in the last 2 s (not by noracu), an input tool returns `user_active` and sends nothing, and after a physical click, drag, scroll or phone gesture the pointer goes back where it was, unless someone moved it in the meantime. Read-only tools and the browser layer are not held up. `NORACU_USER_IDLE_S=0` turns this off on a Mac dedicated to the agent.
|
|
37
38
|
- **One loop, three surfaces.** Native Mac apps and a persistent-profile browser share the `element_index` protocol (observe a tree, act by index). The experimental iPhone layer runs the same observe → act loop on Apple's iPhone Mirroring, with OCR text and normalized coordinates, because the phone exposes no accessibility tree to the Mac.
|
|
38
39
|
- **Uses your real sessions.** Your logged-in browser profile, your Mac apps — not a hosted VM. Compared with cloud computer-use: neither is universally more reliable; they fail differently. noracu keeps the screen on your machine.
|
|
39
40
|
- **Off switches that are actually off.** `NORACU_READ_ONLY=1` (observation-only, default-deny), `NORACU_DISABLE_EVAL=1`, and `file://` blocked by default. See [Security](#security).
|
|
@@ -93,7 +94,8 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
|
|
|
93
94
|
| `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 |
|
|
94
95
|
| `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 |
|
|
95
96
|
| `input_busy: …` | an earlier phone or Mac action held the input queue for over 60 s (or `NORACU_PHONE_TIMEOUT_MS` + 15 s); the call did nothing — retry |
|
|
96
|
-
| `
|
|
97
|
+
| `user_active: …` | someone used this Mac's keyboard or mouse in the last 2 s — nothing was sent; retry after a pause. On a Mac nobody else uses, `NORACU_USER_IDLE_S=0` turns the check off |
|
|
98
|
+
| `phone_open` returns app not found for an installed app | it only taps the app's label in Spotlight's Top Hit card, or — where Spotlight shows its search field at the top and no Top Hit card — the label just under the field when the field completes the name as "<name> — Open" — 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 (it covers the Top Hit label only; the "— Open" completion is read in English only). `open_not_confirmed: … never showed up on the phone` means the name did not show up in Spotlight after ⌘V: the paste may not have arrived (it can take several seconds) or the phone may have pasted its own older clipboard into the search field — retry; `phone_open` clears the field first. A one- or two-letter name such as `X` is often unreadable to OCR, so `phone_open` reports `open_not_confirmed` without tapping — open that app from its Home Screen icon (`phone_screenshot`, then `phone_tap`). `phone_open` leaves the app name on the clipboard |
|
|
97
99
|
| Typed text comes out re-spaced (e.g. "no ra cu") | it went in as keystrokes (`mac_type` with `mechanism: "physical"`, or a focused element that takes no accessibility text) while a CJK input method was active — use the default `mac_type` mechanism, or `mac_paste` |
|
|
98
100
|
| `element_no_longer_valid` | the snapshot is older than 30 s, or the element is gone, changed or in a window that closed — re-run `mac_ax_state` / `browser_snapshot` and use a fresh index |
|
|
99
101
|
| `occluded: … — on top: {…}` | a physical click would land on something else (another window, a sheet) — bring the target forward or close what covers it; nothing was sent |
|
|
@@ -120,7 +122,7 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
|
|
|
120
122
|
|
|
121
123
|
**First success:** `phone_status` → `phone_launch` if `live` is not `true` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`.
|
|
122
124
|
|
|
123
|
-
**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, started from the empty strip just above the Dock: a swipe that starts on an app icon picks the icon up and moves it); 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 when live (working without python on English macOS, falling back to an `imctl` gesture only when those menu items are absent, and returning `menu_unknown` without a second gesture on timeout) and report only that the command was sent (`screen not verified`); `phone_type` needs a Mac keyboard layout that keeps A and V where U.S. QWERTY has them (U.S., ABC and Pinyin do; French AZERTY and Dvorak do not) — otherwise it returns `keyboard_layout` and sends nothing.
|
|
125
|
+
**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, started from the empty strip just above the Dock: a swipe that starts on an app icon picks the icon up and moves it); 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 — or, where Spotlight puts its search field at the top with no Top Hit card (seen on iOS 27), only when the field completes exactly that name as "<name> — Open" (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 (the top-field layout's "Open" completion is English only, and `NORACU_TOPHIT_LABELS` does not change it); `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu when live (working without python on English macOS, falling back to an `imctl` gesture only when those menu items are absent, and returning `menu_unknown` without a second gesture on timeout) and report only that the command was sent (`screen not verified`); `phone_type` needs a Mac keyboard layout that keeps A and V where U.S. QWERTY has them (U.S., ABC and Pinyin do; French AZERTY and Dvorak do not) — otherwise it returns `keyboard_layout` and sends nothing; the phone reads the Mac clipboard through Universal Clipboard, which tells it about new content with a delay, so `phone_type` waits at least 1.5 s between writing the clipboard and ⌘V (and returns `focus_lost` without ⌘V if another app comes to the front meanwhile) — in a device run, a ⌘V sent about 0.5 s after the write once pasted the phone's own older clipboard (the previous paste) instead, and a paste can also stop after the phone's "Pasting from …" box; after `type_not_confirmed`, read the field before typing again.
|
|
124
126
|
|
|
125
127
|
## Environment variables
|
|
126
128
|
|
|
@@ -138,6 +140,7 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
|
|
|
138
140
|
| `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` |
|
|
139
141
|
| `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) |
|
|
140
142
|
| `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 |
|
|
143
|
+
| `NORACU_USER_IDLE_S` | `2` | seconds without keyboard or mouse input (other than noracu's own) before a Mac or iPhone input tool acts; sooner, it returns `user_active` and sends nothing. While it is not 0, the pointer also goes back where it was after physical clicks, drags, scrolls and phone gestures, unless someone moved it in the meantime. 0–60; `0` turns both off (a Mac dedicated to the agent); any other value falls back to 2 |
|
|
141
144
|
|
|
142
145
|
## Security
|
|
143
146
|
|
package/README.zh-CN.md
CHANGED
|
@@ -34,6 +34,7 @@ noracu 是本地的"手",不是"脑"。决策由你的 MCP client(Claude Des
|
|
|
34
34
|
- **server 完全在本机运行。** 无云服务、无 API key、无遥测、无 postinstall 脚本。唯一运行期依赖是 Playwright。noracu 自身不发任何网络请求;唯一的自动网络行为是首次 `browser_launch` 时一次性下载 Chromium(`NORACU_DISABLE_AUTO_INSTALL=1` 可关闭)。设置 `NORACU_ALLOW_CDP=1` 后,它还会访问自己在 127.0.0.1 上打开的 DevTools 端口(连接其他本地回环端口需 `NORACU_ALLOW_CDP=any`)。你让浏览器打开的页面当然会被抓取,你的 MCP client 也仍会把工具结果(截图、OCR 文本)发给它所用的模型。
|
|
35
35
|
- **按语义动作,而非像素。** 观察返回 accessibility 树(Mac 直接经 macOS 辅助功能 API 读取——在我们的测试机上,500 个元素的窗口约 0.15 秒)或 ARIA 树(browser)的带索引列表——是文本,不是截图。动作引用 `element_index`;索引 30 秒后过期。Mac 上每个索引背后都有身份证据(窗口 ID、子节点路径、角色、标识符、名称),每次动作前先重新识别元素;browser 则重校验 tag/name/href/位置。元素已消失或已变化时返回 `element_no_longer_valid`,而不是点错位置。树不够用时才用截图。
|
|
36
36
|
- **如实报告结果。** Mac 动作优先用元素自己的辅助功能动作(按下、选中、设值、插入文本——不移动指针、不抢焦点,文字输入不受输入法影响);只有命中检测确认该点确实落在元素上,才会发送物理点击。每个输入动作(Mac、浏览器和 iPhone)的结果都写明是否送达(观察到变化为 `delivered_verified`,另有 `delivered_unverified`、`not_delivered`,以及超时或中途失败时的 `unknown`)以及能否安全重试;Mac 动作还会列出它打开的 sheet、对话框或菜单。
|
|
37
|
+
- **和你共用这台 Mac。** Mac 与 iPhone 的输入让电脑前的人先来:最近 2 秒内键盘或鼠标被用过(不是 noracu 自己),输入工具就返回 `user_active`、什么都不发;物理点击、拖动、滚动和手机手势之后,指针回到原处,除非这期间有人动过它。只读工具和浏览器层不受影响。专给 agent 用的 Mac 上设 `NORACU_USER_IDLE_S=0` 关闭。
|
|
37
38
|
- **一个循环,三个面。** Mac 原生应用和持久化 profile 的浏览器共用 `element_index` 协议(观察一棵树、按索引动作)。实验性的 iPhone 层在 Apple 的 iPhone Mirroring 上跑同一个 observe → act 循环,用的是 OCR 文本和归一化坐标——因为手机不向 Mac 暴露 accessibility 树。
|
|
38
39
|
- **用你真实的会话。** 你已登录的浏览器 profile、你的 Mac 应用——不是托管的 VM。与云端 computer-use 相比:两者没有谁普遍更可靠,只是失败方式不同。noracu 把屏幕留在你本机。
|
|
39
40
|
- **真正能关掉的开关。** `NORACU_READ_ONLY=1`(只观察,默认拒绝)、`NORACU_DISABLE_EVAL=1`、以及默认封禁 `file://`。见 [安全](#安全)。
|
|
@@ -93,7 +94,8 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/TO/n
|
|
|
93
94
|
| `phone_launch` 报 `mirror_setup_required` | iPhone Mirroring 正显示设置或欢迎页(例如升级 macOS 后首次启动)——请在 iPhone Mirroring 窗口里自己完成;noracu 从不替你点击这类页面 |
|
|
94
95
|
| `imctl_timeout: phone … did not finish within …s` | Mac 负载过高或系统卡住——操作可能已部分执行,重试前先看 `phone_status` / `phone_screenshot`(`phone_open` 超时后 noracu 会回到主屏幕);在此期间 server 仍会响应其他调用 |
|
|
95
96
|
| `input_busy: …` | 前一个手机或 Mac 操作占用输入队列超过 60 秒(或 `NORACU_PHONE_TIMEOUT_MS` + 15 秒);本次调用什么都没做——重试即可 |
|
|
96
|
-
|
|
|
97
|
+
| `user_active: …` | 最近 2 秒内有人用过这台 Mac 的键盘或鼠标——什么都没发;停一下再重试。没有别人用的 Mac 上,`NORACU_USER_IDLE_S=0` 关闭这项检查 |
|
|
98
|
+
| 已安装的 App,`phone_open` 却报 app not found | 它只点 Spotlight「Top Hit」卡片里的 App 标签;若 Spotlight 把搜索框放在顶部、没有「Top Hit」卡片,则只在搜索框把名字补全成「<名字> — Open」时点搜索框正下方的标签——名字要和手机图标下显示的一致(例如 `拼多多`,而不是 `Pinduoduo`)。已安装却报 "Spotlight showed no Top Hit",通常说明 iPhone 系统语言不是英文:`phone_open` 读的是 Spotlight 的 "Top Hit" 标签——把 `NORACU_TOPHIT_LABELS` 设成手机上显示的标签(它只管「Top Hit」标签;「— Open」补全只认英文)。报 `open_not_confirmed: … never showed up on the phone` 是说 ⌘V 之后 Spotlight 里一直没出现这个名字:可能粘贴还没到(可能要好几秒),也可能手机把自己的旧剪贴板贴进了搜索框——重试即可,`phone_open` 会先清空搜索框。只有一两个字母的名字(如 `X`)OCR 常常读不出来,`phone_open` 会报 `open_not_confirmed` 且不点任何东西——这类 App 请从主屏图标打开(先 `phone_screenshot`,再 `phone_tap`)。`phone_open` 之后剪贴板里是 App 名字 |
|
|
97
99
|
| 输入的文本被重新空格化(如 "no ra cu") | 文字是以按键方式送出的(`mac_type` 用了 `mechanism: "physical"`,或焦点元素不接受辅助功能写入),同时 CJK 输入法在激活——用 `mac_type` 的默认方式,或用 `mac_paste` |
|
|
98
100
|
| `element_no_longer_valid` | 快照超过 30 秒,或元素已消失、已变化、所在窗口已关闭——重跑 `mac_ax_state` / `browser_snapshot` 并用新索引 |
|
|
99
101
|
| `occluded: … — on top: {…}` | 物理点击会落在别的东西上(另一个窗口、一个 sheet)——把目标窗口置前或关掉遮挡物;本次什么都没发送 |
|
|
@@ -120,7 +122,7 @@ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在
|
|
|
120
122
|
|
|
121
123
|
**首次成功路径:** `phone_status` → 若 `live` 不是 `true` 先 `phone_launch` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`。
|
|
122
124
|
|
|
123
|
-
**已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错(若 Spotlight 的「Top Hit」里是同名的联系人或网站,`phone_open` 分辨不出它不是 App);`phone_scroll` 用触控板式的滚动事件移动列表(竖向的 `phone_swipe` 拖拽不会滚动列表——它用于主屏翻页这类手势,起点放在 Dock 上方的空白带:起点落在 App 图标上的拖动会把图标拿起来挪走);在一套实测环境(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
|
|
125
|
+
**已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错(若 Spotlight 的「Top Hit」里是同名的联系人或网站,`phone_open` 分辨不出它不是 App);`phone_scroll` 用触控板式的滚动事件移动列表(竖向的 `phone_swipe` 拖拽不会滚动列表——它用于主屏翻页这类手势,起点放在 Dock 上方的空白带:起点落在 App 图标上的拖动会把图标拿起来挪走);在一套实测环境(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」卡片(iOS 27 上见过),则只在搜索框把这个名字补全成「<名字> — Open」时才点(同名的网页建议、网站和设置行一律不点),否则回到主屏——它读的是 Spotlight 的英文 "Top Hit" 标签,iPhone 设为其他语言时找不到任何 App,除非用 `NORACU_TOPHIT_LABELS` 指定那个标签(顶部搜索框布局里的「Open」补全只认英文,`NORACU_TOPHIT_LABELS` 管不到它);`phone_home` / `phone_app_switcher` 在镜像在线时走 iPhone Mirroring 菜单(英文 macOS 下无需 python,仅在菜单项不存在时回退 `imctl` 手势,菜单超时返回 `menu_unknown` 而不补发第二次手势),且只报告指令已发送(`screen not verified`);`phone_type` 要求 Mac 键盘布局里 A 和 V 的位置与美式 QWERTY 相同(美式、ABC、拼音都满足;法式 AZERTY、Dvorak 不满足),否则返回 `keyboard_layout`,什么都不发;手机经「通用剪贴板」读取 Mac 的剪贴板,新内容要过一会儿才通知到手机,所以 `phone_type` 在写入剪贴板后至少等 1.5 秒再发 ⌘V(这期间若有别的 App 切到前台,就返回 `focus_lost`,不发 ⌘V)——一次真机测试中,写入后约 0.5 秒就发出的 ⌘V 贴出了手机自己的旧剪贴板(上一次粘贴的内容),粘贴也可能在手机显示「Pasting from …」后中断;收到 `type_not_confirmed` 后,先读输入框再重打。
|
|
124
126
|
|
|
125
127
|
## 环境变量
|
|
126
128
|
|
|
@@ -138,6 +140,7 @@ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在
|
|
|
138
140
|
| `NORACU_PHONE_TIMEOUT_MS` | 30000(`phone_open` / `phone_type` 为 45000) | iPhone 层每一步的时限,1000–600000 毫秒;到时该步被终止并返回 `imctl_timeout` |
|
|
139
141
|
| `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | 识别 iPhone 画面的 OCR 语言及优先顺序(逗号分隔的 Vision 语言代码,如 `zh-Hant,en-US` 或 `en-US`;Vision 不支持的代码会被跳过并给出警告) |
|
|
140
142
|
| `NORACU_TOPHIT_LABELS` | `Top Hit` | `phone_open` 要找的 Spotlight「Top Hit」分区标签,逗号分隔——iPhone 不是英文时,设成手机上实际显示的那个标签 |
|
|
143
|
+
| `NORACU_USER_IDLE_S` | `2` | Mac 或 iPhone 输入工具动作前,键盘和鼠标须已空闲的秒数(noracu 自己的输入不算);不到就返回 `user_active`、什么都不发。不为 0 时,物理点击、拖动、滚动和手机手势之后指针还会回到原处,除非这期间有人动过它。取值 0–60;`0` 两项都关(专给 agent 用的 Mac);其他值按 2 处理 |
|
|
141
144
|
|
|
142
145
|
## 安全
|
|
143
146
|
|
package/SECURITY.md
CHANGED
|
@@ -56,7 +56,7 @@ Boundaries:
|
|
|
56
56
|
| 15 | **DevTools port exposure** | `mac_app` launch with `cdp_port` opens a Chromium/Electron app's remote-debugging port on `127.0.0.1` (no per-user isolation); any local process can then control that app | **Partially mitigated** | Off unless `NORACU_ALLOW_CDP=1` (or `=any`); `browser_launch` with `cdp_port` is refused under `NORACU_READ_ONLY=1` even with `NORACU_ALLOW_CDP` set; bound to `127.0.0.1`; only for a fresh launch after canonicalizing `.app` paths (`realpath`, trailing slash stripped — a running app is refused, never quit for you); with `NORACU_ALLOW_CDP=1`, `browser_launch` attaches only when the port was recorded by this `noracu` process, its PID is still alive, and `/json/version`'s `webSocketDebuggerUrl` matches (attaching to any other loopback port requires `NORACU_ALLOW_CDP=any`); `~/.noracu` and `cdp-profiles` are created `0700`; Chrome-family browsers get a separate profile under `~/.noracu/cdp-profiles`; standalone `browser_launch` is refused while a CDP session is open; the port closes when the app quits |
|
|
57
57
|
| 16 | **Clipboard and notification content** | `mac_clipboard_read` / `mac_notifications` return clipboard text, images, file paths and notification text to the model | **Partially mitigated** | Items marked `org.nspasteboard.ConcealedType` (password managers) are never returned; `mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"` are refused under `NORACU_READ_ONLY=1` (`NORACU_READ_ONLY=1` prevents side effects, not screen secrecy: `mac_screenshot` still shows visible notification banners and Notification Center AX reads are not blocked by bundle id); notification actions reject empty `id` / `expected_app` / `expected_title`, return `notification_not_found` when absent, and require an id or an index plus a re-checked app/title fingerprint; `mac_set_value` on `AXSecureTextField` never echoes the value. Remaining: `mac_clipboard_read` on Universal Clipboard content (copied on another device) makes macOS fetch it from that device; the result marks it `remote: true` |
|
|
58
58
|
| 17 | **Text in process arguments** | Text sent as keystrokes (`mac_type` physical path: `cliclick t:…`) is visible in the process list while it runs | **Partially mitigated** | The accessibility path (`mac_type` default, `mac_set_value`), `mac_paste`, and `phone_type` / `phone_find` / `phone_open` (imctl reads the text from stdin) pass text on stdin, and `mac_set_value` on `AXSecureTextField` and `imctl type` never echo typed text; only the keystroke fallback uses argv. A phone call's `expect` text is still an argument |
|
|
59
|
-
| 18 | **Clipboard on the phone path** | `phone_type` / `phone_open` paste through the Mac clipboard; iPhone Mirroring fetches the paste asynchronously, sometimes more than 10 s after ⌘V, from whatever the clipboard holds then, so putting the user's clipboard back too early could paste it into the phone | **Partially mitigated** | `phone_type` copies every clipboard item aside and puts them back only on screen evidence read within its 2.5 s check while no "Pasting from" progress box shows: OCR sees the text at a new spot below the status-bar strip in two reads. A text of one to three characters (spaces and case aside) never licenses it, and neither does a paste seen only later. An item marked concealed or transient is never copied (the clipboard is cleared instead). Without that evidence the typed text stays on the clipboard and the result says so. An error before ⌘V is sent restores the clipboard; an error once ⌘V may be on its way never does. `phone_open` never restores it. Remaining: the user's previous clipboard is lost whenever the evidence is missing; Universal Clipboard content and clipboards over 64 MB are not copied, so they are replaced by the typed text |
|
|
59
|
+
| 18 | **Clipboard on the phone path** | `phone_type` / `phone_open` paste through the Mac clipboard; iPhone Mirroring fetches the paste asynchronously, sometimes more than 10 s after ⌘V, from whatever the clipboard holds then, so putting the user's clipboard back too early could paste it into the phone | **Partially mitigated** | `phone_type` and `phone_open` wait at least 1.5 s after writing the clipboard before ⌘V, and call ⌘V off (`focus_lost`) rather than bring iPhone Mirroring back if another app came to the front meanwhile. `phone_type` copies every clipboard item aside and puts them back only on screen evidence read within its 2.5 s check while no "Pasting from" progress box shows: OCR sees the text at a new spot below the status-bar strip in two reads, counted against a read taken right before ⌘V. A text of one to three characters (spaces and case aside) never licenses it, and neither does a paste seen only later. An item marked concealed or transient is never copied (the clipboard is cleared instead). Without that evidence the typed text stays on the clipboard and the result says so. An error before ⌘V is sent restores the clipboard; an error once ⌘V may be on its way never does. `phone_open` never restores it once ⌘V may have been sent (before ⌘V — an error, or `focus_lost` — it goes back under the same rule). Remaining: the user's previous clipboard is lost whenever the evidence is missing; Universal Clipboard content and clipboards over 64 MB are not copied, so they are replaced by the typed text; a ⌘V that reaches the phone before Universal Clipboard has announced the new text can paste the phone's own older clipboard instead — possibly something once pasted on the phone, such as a password — and the wait — 1.5 s, a judgement rather than a measured delay — is meant to let the new text reach the phone first but does not close that window; the OCR evidence matches the typed text inside a line, so an older clipboard that contains the typed text can pass for the paste; the "Pasting from" box is recognized only in English |
|
|
60
60
|
| 11 | **Untrusted observation content** | ARIA snapshots, AX trees, OCR, page text contain attacker-controlled text | **Not mitigated** | The MCP client must treat tool results as data, never as instructions |
|
|
61
61
|
|
|
62
62
|
## Hardening recommendations
|
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. Hints are the four MCP tool annotations each tool reports — R read-only, D destructive, I idempotent, O open-world, – false — hints for the client, not permissions.
|
|
4
|
-
> noracu v0.2.
|
|
4
|
+
> noracu v0.2.7 · 46 tools
|
|
5
5
|
|
|
6
6
|
## Mac layer (computer-use)
|
|
7
7
|
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
| `phone_home` | — | – – – O | EXPERIMENTAL. Send the Home Screen command via the iPhone Mirroring menu (works without python/pyobjc on English macOS while the mirror is live), falling back to an imctl swipe (needs python/pyobjc) only when that English menu item is absent (non-English macOS). Reports only that the command or gesture was sent — nothing on the iPhone screen is verified; refuses with mirror_not_live or mirror_state_unknown (or menu_unknown on timeout) when the mirror is not live or its state cannot be confirmed. Reports delivery and retry. |
|
|
67
67
|
| `phone_app_switcher` | — | – – – O | EXPERIMENTAL. Send the App Switcher command via the iPhone Mirroring menu (works without python/pyobjc on English macOS while the mirror is live), falling back to an imctl gesture (needs python/pyobjc) only when that English menu item is absent (non-English macOS). Reports only that the command or gesture was sent — nothing on the iPhone screen is verified; refuses with mirror_not_live or mirror_state_unknown (or menu_unknown on timeout) when the mirror is not live or its state cannot be confirmed. Reports delivery and retry. |
|
|
68
68
|
| `phone_scroll` | direction:string?, distance:number?, expect:string? | – – – O | 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. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed; reports scroll_no_effect when the screen did not change (list end, or the view does not scroll); a scroll that changed the screen is delivered_unverified, since a notification or an animation changes it too — take phone_screenshot to see where the list is. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
|
|
69
|
-
| `phone_type` | **text**:string, replace:boolean?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe; never echoes the typed text). Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Saves every clipboard item and type, clearing concealed or transient items instead of copying, and restores only after OCR sees the text appear within its 2.5 s check at a spot where it was not before, below the status bar and notification strip — only that sighting makes the result delivered_verified (Universal Clipboard or >64 MB items are not copied and leave the typed text on the clipboard; a text under four characters, spaces and case aside, a paste seen only after the 2.5 s check, and type_not_confirmed are never verified and also leave the typed text on the clipboard). replace=true selects all and overwrites the field. Refused with keyboard_layout (nothing sent, clipboard untouched) when the Mac's keyboard layout types another character on the key ⌘V or ⌘A is sent from (AZERTY, Dvorak). Optional expect: on-screen text (OCR), else nothing is sent. Reports delivery and retry. |
|
|
69
|
+
| `phone_type` | **text**:string, replace:boolean?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe; never echoes the typed text). Waits at least 1.5 s after writing the Mac clipboard before ⌘V, because the phone reads it through Universal Clipboard and an earlier ⌘V can paste the phone's own older clipboard instead; after type_not_confirmed, read the field — it may hold that older text. If another app comes to the front during the wait: focus_lost, no ⌘V; the clipboard is put back unless something else copied during the wait. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Saves every clipboard item and type, clearing concealed or transient items instead of copying, and restores only after OCR sees the text appear within its 2.5 s check at a spot where it was not before, below the status bar and notification strip — only that sighting makes the result delivered_verified (Universal Clipboard or >64 MB items are not copied and leave the typed text on the clipboard; a text under four characters, spaces and case aside, a paste seen only after the 2.5 s check, and type_not_confirmed are never verified and also leave the typed text on the clipboard). replace=true selects all and overwrites the field. Refused with keyboard_layout (nothing sent, clipboard untouched) when the Mac's keyboard layout types another character on the key ⌘V or ⌘A is sent from (AZERTY, Dvorak). Optional expect: on-screen text (OCR), else nothing is sent. Reports delivery and retry. |
|
|
70
70
|
| `phone_key` | **key**:string, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Press a key: return, delete, up, down, left, or right. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
|
|
71
|
-
| `phone_open` | **app**:string | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. 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, and one it shows at two or more spots is open_not_confirmed with nothing tapped; reads the English "Top Hit" label unless NORACU_TOPHIT_LABELS names the phone's own; a
|
|
71
|
+
| `phone_open` | **app**:string | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Open an app: Home Screen, Spotlight via the menu, clear, type the name the way phone_type does (the clipboard keeps it), then tap only an exact label inside the Spotlight Top Hit card — or, where Spotlight shows its search field at the top and no Top Hit card, the exact label just under the field, and only when the field completes the name as "<name> — Open" — (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, and one it shows at two or more spots is open_not_confirmed with nothing tapped; reads the English "Top Hit" label unless NORACU_TOPHIT_LABELS names the phone's own, and the "— Open" completion in English only; a name that never shows up in Spotlight after ⌘V, even after up to 15 s, is open_not_confirmed — retry; a one- or two-letter name such as "X" that OCR cannot read in the Top Hit card is open_not_confirmed without the 15 s wait, nothing tapped — open it from its Home Screen icon); 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. If another app comes to the front before ⌘V: focus_lost, nothing pasted or tapped, no trip Home (Spotlight may stay open); if another app or device changes the clipboard before ⌘V: open_not_confirmed, nothing pasted or tapped, back on the Home Screen. Reports delivery and retry. |
|
|
72
72
|
|
package/imctl/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "imctl"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.7"
|
|
8
8
|
description = "Control iPhone Mirroring on macOS from the CLI — CGEvent input, Vision OCR, pixel verification"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "MIT" }
|
package/imctl/src/imctl/cli.py
CHANGED
|
@@ -28,7 +28,7 @@ import sys
|
|
|
28
28
|
import tempfile
|
|
29
29
|
import time
|
|
30
30
|
|
|
31
|
-
from . import gestures, input, verify, vision
|
|
31
|
+
from . import gestures, input, pointer, verify, vision
|
|
32
32
|
from .vision import CaptureError
|
|
33
33
|
import subprocess
|
|
34
34
|
|
|
@@ -324,22 +324,33 @@ def _cmd_type(args) -> int:
|
|
|
324
324
|
if guard is not None:
|
|
325
325
|
return guard
|
|
326
326
|
report = {}
|
|
327
|
-
|
|
327
|
+
try:
|
|
328
|
+
typed_ok = input.type_text(args.text, replace=args.replace, report=report)
|
|
329
|
+
except input.PasteFocusLost:
|
|
330
|
+
# 0.2.7: another app came to the front during the wait after the clipboard write;
|
|
331
|
+
# ⌘V was called off rather than pulling iPhone Mirroring back to the front
|
|
332
|
+
sent = ("the select-all (⌘A) for replace was sent, but nothing was pasted" if args.replace
|
|
333
|
+
else "nothing was sent")
|
|
334
|
+
print("focus_lost: another app came to the front before ⌘V, so iPhone Mirroring was not "
|
|
335
|
+
f"brought back and the paste was called off — {sent}; the clipboard was put back "
|
|
336
|
+
"unless something else had copied meanwhile", file=sys.stderr)
|
|
337
|
+
return 6
|
|
338
|
+
if typed_ok:
|
|
328
339
|
if report.get("seen", True):
|
|
329
340
|
if _late_paste_probe(args.text) is None:
|
|
330
341
|
# 0.2.5 (review Y6): one character that OCR saw appear is no proof of where it went,
|
|
331
342
|
# and (review R38) no license to put the clipboard back
|
|
332
343
|
print(f"typed {len(args.text)} chars (one character: OCR saw it appear, which is no "
|
|
333
|
-
"proof of where it landed — check the field
|
|
334
|
-
"typed text)")
|
|
344
|
+
"proof of where it landed — check the field, which may hold the phone's own older "
|
|
345
|
+
"clipboard instead; the clipboard still holds the typed text)")
|
|
335
346
|
return 0
|
|
336
347
|
print(f"typed {len(args.text)} chars")
|
|
337
348
|
return 0
|
|
338
349
|
if _late_paste_probe(args.text) is None:
|
|
339
350
|
# one character: OCR cannot read it back, only the picture changed
|
|
340
351
|
print(f"typed {len(args.text)} chars (the screen changed after the paste, but "
|
|
341
|
-
"OCR cannot read this text back — check the field
|
|
342
|
-
"holds the typed text)")
|
|
352
|
+
"OCR cannot read this text back — check the field, which may hold the phone's own "
|
|
353
|
+
"older clipboard instead; the clipboard still holds the typed text)")
|
|
343
354
|
return 0
|
|
344
355
|
# review 0.2.6 #7: the screen changed and OCR could not confirm the text for a reason
|
|
345
356
|
# known now — say that one, instead of watching for a late paste that would only
|
|
@@ -348,12 +359,14 @@ def _cmd_type(args) -> int:
|
|
|
348
359
|
if cause == "too_short":
|
|
349
360
|
print(f"typed {len(args.text)} chars (the screen changed after the paste, but a text "
|
|
350
361
|
"of fewer than four characters, spaces and case aside, is never confirmed by "
|
|
351
|
-
"OCR — check the field
|
|
362
|
+
"OCR — check the field, which may hold the phone's own older clipboard instead; the "
|
|
363
|
+
"clipboard still holds the typed text)")
|
|
352
364
|
return 0
|
|
353
365
|
if cause == "strip_only":
|
|
354
366
|
print(f"typed {len(args.text)} chars (OCR saw the text appear only in the strip at the "
|
|
355
367
|
"top of the screen, where a field cannot be told from a notification banner — "
|
|
356
|
-
"check the field
|
|
368
|
+
"check the field, which may hold the phone's own older clipboard instead; the "
|
|
369
|
+
"clipboard still holds the typed text)")
|
|
357
370
|
return 0
|
|
358
371
|
# device run 2026-11-06: only the picture changed (a selection highlight, a
|
|
359
372
|
# results list redraw) and OCR never saw the text — watch for it like an
|
|
@@ -387,8 +400,11 @@ def _cmd_type(args) -> int:
|
|
|
387
400
|
"(phone_ocr / phone_screenshot): if the field shows the text, it "
|
|
388
401
|
"holds it")
|
|
389
402
|
else:
|
|
390
|
-
|
|
391
|
-
|
|
403
|
+
# device run 2026-11-07/08: the phone can paste its own older clipboard when the Mac's
|
|
404
|
+
# new clipboard has not reached it yet — the field may hold other text, not nothing
|
|
405
|
+
advice = ("it may still land, or the phone may have pasted its own older clipboard "
|
|
406
|
+
"instead: read the screen (phone_ocr / phone_screenshot) before typing "
|
|
407
|
+
"again, or retype with replace=true")
|
|
392
408
|
print(
|
|
393
409
|
"type_not_confirmed: the paste did not show on screen within the 2.5s "
|
|
394
410
|
f"confirmation window{watched} — {advice}; the clipboard still holds the "
|
|
@@ -564,9 +580,14 @@ def _open_and_report(args) -> int:
|
|
|
564
580
|
f"{', '.join(repr(x) for x in gestures.TOP_HIT_LABELS)} — no app by that "
|
|
565
581
|
f"name, or NORACU_TOPHIT_LABELS does not match your iPhone's label){stuck}")
|
|
566
582
|
else:
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
583
|
+
# 2026-11-08: the top-field Spotlight shows no Top Hit header at all; there the
|
|
584
|
+
# evidence is the field completing the name with "— Open"
|
|
585
|
+
print(f"app not found: {args.app!r} (Spotlight showed no Top Hit, and its search "
|
|
586
|
+
"field did not complete the name with \"— Open\" — no app by that name, or "
|
|
587
|
+
"the iPhone is not set to English: phone_open reads Spotlight's \"Top Hit\" "
|
|
588
|
+
"label and \"Open\" completion; NORACU_TOPHIT_LABELS sets the Top Hit label for "
|
|
589
|
+
"another language, the \"Open\" completion is read in English only)"
|
|
590
|
+
f"{stuck}")
|
|
570
591
|
return 1
|
|
571
592
|
if result == "deadline":
|
|
572
593
|
print(f"open_not_confirmed: ran out of time opening {args.app!r} (the Mac may be "
|
|
@@ -584,10 +605,27 @@ def _open_and_report(args) -> int:
|
|
|
584
605
|
"its Home Screen icon instead (phone_screenshot, then phone_tap)", file=sys.stderr)
|
|
585
606
|
return 4
|
|
586
607
|
if result == "not_typed":
|
|
587
|
-
|
|
608
|
+
# 0.2.7: the paste may have put the phone's own older clipboard into the field
|
|
609
|
+
# instead of the name — never claim the name was pasted
|
|
610
|
+
print(f"open_not_confirmed: ⌘V was sent to Spotlight but the name {args.app!r} never "
|
|
588
611
|
"showed up on the phone (a paste can take several seconds to reach the iPhone, "
|
|
589
|
-
"or be lost
|
|
590
|
-
|
|
612
|
+
"or be lost, and the phone may have pasted its own older clipboard into the "
|
|
613
|
+
"search field instead; an iPhone not set to English also needs "
|
|
614
|
+
f"NORACU_TOPHIT_LABELS) — nothing was tapped; {home_note}; retry phone_open, "
|
|
615
|
+
"which clears the search field first", file=sys.stderr)
|
|
616
|
+
return 4
|
|
617
|
+
if result == "focus_lost":
|
|
618
|
+
# 0.2.7: the paste was called off because another app came to the front; no trip
|
|
619
|
+
# Home either — that would pull iPhone Mirroring forward again
|
|
620
|
+
print(f"focus_lost: another app came to the front before ⌘V, so iPhone Mirroring was not "
|
|
621
|
+
f"brought back and {args.app!r} was not pasted or tapped — Spotlight was opened and "
|
|
622
|
+
"cleared on the phone and may still be open; the clipboard was put back unless "
|
|
623
|
+
"something else had copied meanwhile; retry phone_open", file=sys.stderr)
|
|
624
|
+
return 6
|
|
625
|
+
if result == "clipboard_changed":
|
|
626
|
+
print(f"open_not_confirmed: another app or device changed the clipboard before ⌘V, so "
|
|
627
|
+
f"{args.app!r} was not pasted or tapped and the new clipboard was left as it is; "
|
|
628
|
+
f"{home_note}; retry phone_open", file=sys.stderr)
|
|
591
629
|
return 4
|
|
592
630
|
if result == "spotlight_unavailable":
|
|
593
631
|
print("spotlight unavailable (could not reach the Home Screen, the menu command failed, or the screen did not change)")
|
|
@@ -773,6 +811,14 @@ def main(argv: list[str] | None = None) -> int:
|
|
|
773
811
|
parser = build_parser()
|
|
774
812
|
args = parser.parse_args(argv)
|
|
775
813
|
_stdin_values(args)
|
|
814
|
+
pointer.remember() # 0.2.7: a gesture's pointer goes back where it was (see pointer.py)
|
|
815
|
+
try:
|
|
816
|
+
return _run(args)
|
|
817
|
+
finally:
|
|
818
|
+
pointer.restore()
|
|
819
|
+
|
|
820
|
+
|
|
821
|
+
def _run(args) -> int:
|
|
776
822
|
try:
|
|
777
823
|
return args.func(args)
|
|
778
824
|
except input.KeyboardLayoutMismatch as exc:
|