noracu 0.1.1 → 0.1.3

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,103 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.3] — 2026-11-04
4
+
5
+ ### Fixed
6
+ - `phone_open` is far more reliable: it opens Spotlight from the Home Screen
7
+ using Spotlight's own shortcut (trying once more if the phone ignores it),
8
+ clears the field and re-reads results, matches very short app names such as
9
+ "X", and confirms the app actually came to the foreground — tapping the app
10
+ icon when tapping its name does nothing.
11
+ - One- and two-letter names such as "X" no longer run past the 30-second tool
12
+ limit: short labels are read with a fast multi-scale OCR pass instead of slow
13
+ strip-by-strip reads. `phone_find` and the `expect` guard find them too.
14
+ - `phone_open` no longer taps the wrong result when OCR momentarily misses a
15
+ short app name. In testing, opening "X" could open a web search instead while
16
+ reporting success.
17
+ - `phone_type` keeps the typed text on the clipboard until the phone shows it
18
+ (verified by OCR) and only then restores your previous clipboard; it also
19
+ restores the clipboard if an error happens before the paste. For a single
20
+ character the restore also happens when the phone shows the paste several
21
+ seconds late — and never before. Nothing is pasted if another app or device
22
+ (Universal Clipboard) changes the clipboard just before the paste. Adds a
23
+ `replace` option to overwrite an existing field.
24
+ - `phone_scroll` validates its distance (in screen-heights) and reports when
25
+ nothing on screen moved.
26
+ - `phone_launch` reports whether the mirror is actually live, and says so when
27
+ the session is still paused.
28
+ - Moving the pointer over the iPhone Mirroring window no longer looks like a
29
+ paused session, and resuming a paused session never clicks the window's own
30
+ close or minimize buttons.
31
+ - Screenshots never silently fall back to grabbing an arbitrary screen region;
32
+ a capture failure is reported as unconfirmed instead of acting on the wrong
33
+ pixels. After bringing iPhone Mirroring to the front, noracu waits for a real
34
+ frame instead of failing on a blank transition frame.
35
+ - Before every input event, noracu asks macOS afresh whether iPhone Mirroring
36
+ is still the frontmost window, and sends nothing otherwise.
37
+
38
+ ### Security
39
+ - Phone screenshots taken for OCR were written to the shared temp directory,
40
+ readable by other local users, and never deleted. They now go to an
41
+ owner-only directory and are deleted as soon as they have been read. If you
42
+ ran an earlier version, delete leftover `imctl_*.png` files from your temp
43
+ directory (for example `/tmp`).
44
+
45
+ ### Added
46
+ - Optional `expect` guard on phone input tools: nothing is sent unless the
47
+ expected text is currently on screen.
48
+ - The server reports when its running process is older than the files on disk,
49
+ so a stale server is visible to the client.
50
+
51
+ ### Known issues
52
+ - Unchanged from 0.1.2: on iPhone 17 Pro Max + macOS 26, iPhone Mirroring draws
53
+ the phone larger than its window; the right column and bottom row stay out of
54
+ reach. Still under investigation.
55
+ - A single character typed with `phone_type` that leaves no new character on
56
+ screen (for example replacing "X" with "X") cannot be confirmed; the clipboard
57
+ then keeps the typed character rather than risk pasting your previous
58
+ clipboard into the phone.
59
+
60
+ ## [0.1.2] — 2026-11-02
61
+
62
+ ### Fixed
63
+ - Docs: the iPhone must be **locked** and near the Mac — unlocking it ends
64
+ iPhone Mirroring (Apple). The 0.1.1 README, usage guide, architecture notes
65
+ and release notes said the opposite.
66
+ - `phone_type` sends a real Command-V chord. Before, iPhone Mirroring received
67
+ a plain "v" and the text was never pasted.
68
+ - `phone_scroll` uses trackpad-style scroll events (continuous, with
69
+ began/changed/ended phases). It used a mouse drag, which iPhone Mirroring
70
+ does not turn into a list scroll, so lists never moved. `phone_swipe` stays
71
+ a drag for gestures such as Home Screen paging.
72
+ - `phone_open` opens Spotlight through iPhone Mirroring's own shortcut instead
73
+ of a swipe that could put the Home Screen into edit (jiggle) mode; it taps
74
+ only an exact app-name match above the search field and returns to the Home
75
+ Screen when nothing matches.
76
+ - Phone input (`phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`,
77
+ `phone_type`, `phone_key`, `phone_open`) is refused with `mirror_not_live`
78
+ while iPhone Mirroring shows an overlay ("Connection Paused", "iPhone in
79
+ Use", …) instead of landing on the overlay; `phone_ocr` / `phone_find` start
80
+ with a warning in that state.
81
+
82
+ ### Known issue
83
+ - On one tested setup (iPhone 17 Pro Max, macOS 26) iPhone Mirroring draws the
84
+ phone larger than its window at every View size; the right column and bottom
85
+ row are cut off, so noracu cannot see or tap them. Under investigation.
86
+
87
+ ### Added
88
+ - `phone_status` reports `live` and `overlay`, read from the window's
89
+ structure rather than its language; `paused` now means "an overlay with a
90
+ Resume button is shown", and `resume` clicks that button only when it is the
91
+ single control.
92
+ - Apple's iPhone Mirroring requirements (Apple silicon or T2, macOS 15+,
93
+ iOS 18+ with a passcode, same Apple Account with two-factor authentication,
94
+ not available in the EU), the "Authenticate automatically" trade-off, and
95
+ privacy guidance in the README, usage guide, architecture notes and SECURITY.
96
+ - MCP Registry metadata: `mcpName` `io.github.sgInnora/noracu` in package.json
97
+ and `server.json`.
98
+ - `demo/record-phone.py` (repo only, not in the npm package) reproduces the
99
+ iPhone demo.
100
+
3
101
  ## [0.1.1] — 2026-11-02
4
102
 
5
103
  ### Added
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # noracu
2
2
 
3
- **Local, no-cloud MCP server for computer-use on macOS apps, a Playwright browser, and (experimentally) a mirrored iPhone — the agent reads an accessibility/ARIA tree and acts by `element_index`, not pixels. No API key, no telemetry.**
3
+ **A local MCP server that lets Claude, Cursor, or any MCP client operate macOS apps and a Playwright browser by `element_index` — and, experimentally, a real iPhone through Apple's iPhone Mirroring (OCR on the Mac, normalized taps). No API key; no telemetry from the server.**
4
4
 
5
5
  [![CI](https://github.com/sgInnora/noracu/actions/workflows/ci.yml/badge.svg)](https://github.com/sgInnora/noracu/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/noracu.svg)](https://www.npmjs.com/package/noracu)
@@ -9,7 +9,7 @@
9
9
 
10
10
  中文说明见 [README.zh-CN.md](README.zh-CN.md)。
11
11
 
12
- One stdio MCP server. The agent snapshots a tree, gets an indexed element list, then clicks or types by `element_index` instead of raw pixels — the same observe/act split on the Mac and in the browser.
12
+ One stdio MCP server. The agent snapshots a tree, gets an indexed element list, then clicks or types by `element_index` instead of raw pixels — the same observe/act split on the Mac and in the browser. The experimental iPhone layer runs the same observe → act loop over OCR text and normalized coordinates.
13
13
 
14
14
  ![browser element_index demo](https://raw.githubusercontent.com/sgInnora/noracu/v0.1.0/docs/demo-browser.gif)
15
15
 
@@ -25,20 +25,20 @@ One MCP server, three control surfaces:
25
25
  | **Browser** | 12 (`browser_*`) | Playwright (persistent profile) | stable |
26
26
  | **iPhone** | 14 (`phone_*`) | iPhone Mirroring via the bundled imctl driver (Python + pyobjc) | experimental |
27
27
 
28
- The iPhone layer is experimental and ships with its driver, imctl (bundled in `imctl/`). It needs an active iPhone Mirroring session on this Mac and a python3 with pyobjc; when no such python is found, `phone_*` tools return a one-line `imctl unavailable` error with the install command, and the Mac and browser layers are unaffected (`phone_home` / `phone_app_switcher` work through the iPhone Mirroring menu even then). The observe/act vocabulary follows the action/observation split popularized by ChatGPT's computer-use, re-implemented on open local tooling.
28
+ The iPhone layer is experimental and ships with its driver (imctl, in `imctl/`). It needs Apple's iPhone Mirroring with the iPhone **locked and near the Mac**, and a python3 with pyobjc; it observes with OCR and acts on normalized coordinates rather than `element_index`. Without pyobjc, `phone_*` tools return a one-line `imctl unavailable` error with the install command, and the Mac and browser layers are unaffected. The observe/act vocabulary follows the action/observation split popularized by ChatGPT's computer-use, re-implemented on open local tooling.
29
29
 
30
30
  ## Why noracu
31
31
 
32
32
  noracu is the local hands, not the model. Your MCP client (Claude Desktop, Claude Code, Cursor) decides what to do; this server only observes and acts on this machine.
33
33
 
34
- - **Runs entirely on your machine.** No cloud, 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). The browser still fetches the pages you point it at.
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). 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) or ARIA tree (browser) as an indexed list — text, not screenshots. Actions reference `element_index`; indices expire after 30 s, and clicks re-verify the target (tag/name/href/position in the browser, frontmost app on the Mac) before firing. A stale reference returns `element_no_longer_valid` instead of clicking the wrong thing. Screenshots are there when the tree is not enough.
36
- - **One protocol, three surfaces — not three scripts.** The same observe/act loop drives native Mac apps, a persistent-profile browser, and (experimentally) a mirrored iPhone. The pattern is identical across surfaces; only the tool names differ (`mac_*` vs `browser_*`).
36
+ - **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.
37
37
  - **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.
38
38
  - **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).
39
- - **Verifiable.** 34 end-to-end checks (`npm test`), CI on macos-latest, MIT, and the whole server is one file: `src/server.mjs`.
39
+ - **Verifiable.** 39 end-to-end checks (`npm test`), CI on macos-latest, MIT, and the whole server is one file: `src/server.mjs`.
40
40
 
41
- **Not a good fit if** you need multiple browser tabs or sessions (single session for now), you're not on macOS (the Mac and iPhone layers are macOS-only; the browser layer is cross-platform), or you need a finished iPhone layer today (it ships, but experimental). If you only need browser automation, playwright-mcp has tab management and selector APIs that noracu v0.1 lacks; noracu is for when one agent also has to leave the browser and drive Mac apps.
41
+ **Not a good fit if** you need multiple browser tabs or sessions (single session for now), you're not on macOS (the Mac and iPhone layers are macOS-only; the browser layer is cross-platform), or you need a finished iPhone layer today (it ships, but experimental — and Apple does not offer iPhone Mirroring in the EU). If you only need browser automation, playwright-mcp has tab management and selector APIs that noracu v0.1 lacks; noracu is for when one agent also has to leave the browser and drive Mac apps.
42
42
 
43
43
  ## Quickstart
44
44
 
@@ -88,6 +88,7 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
88
88
  | `spawn node` / `npx` `ENOENT` from a GUI host | use an absolute `node` path in the config — nvm/volta/homebrew shims are not on the GUI `PATH` |
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
+ | `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) |
91
92
  | Typed text comes out re-spaced (e.g. "no ra cu") | a CJK input method is active — use `mac_paste` instead of `mac_type` |
92
93
  | `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 |
93
94
 
@@ -97,15 +98,21 @@ Full worked examples: [docs/usage.md](docs/usage.md).
97
98
 
98
99
  ## iPhone layer (experimental)
99
100
 
100
- The 14 `phone_*` tools drive iPhone Mirroring through **imctl**, a small Python driver that ships inside this package (`imctl/`, MIT, about 1,000 lines). Nothing else to install on noracu's side; the layer stays experimental because it depends on a live mirror and an unlocked phone.
101
+ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent observes with OCR on the Mac (`phone_screenshot`, `phone_ocr`, `phone_find`), acts at normalized 0–1 coordinates (`phone_tap`, `phone_swipe`, `phone_scroll`), types by pasting (`phone_type`) and opens apps by name (`phone_open`). This is not `element_index`: the phone exposes no accessibility tree to the Mac, so a tap lands where OCR placed the text. The driver (imctl, Python, MIT, about 1,000 lines) ships in `imctl/`.
101
102
 
102
- **Requirements:** macOS 15+ · iPhone Mirroring connected (same Apple Account, Bluetooth + Wi-Fi on) · Accessibility + Screen Recording granted to the host app · a python3 that imports pyobjc (Quartz, Vision, AppKit).
103
+ **Apple's requirements** ([support.apple.com/120421](https://support.apple.com/120421)): a Mac with Apple silicon or a T2 chip on macOS 15 or later; an iPhone on iOS 18 or later with a passcode; both signed in to the same Apple Account with two-factor authentication; Bluetooth and Wi-Fi on; the Mac not sharing its internet connection or using AirPlay or Sidecar. **The iPhone must be locked and near the Mac** — unlocking it, or quitting iPhone Mirroring, ends the session. iPhone Mirroring is currently unavailable in the EU. One Mac and one iPhone at a time; camera and microphone are not mirrored.
103
104
 
104
- **Python:** set `NORACU_PYTHON=/path/to/python3`, or let noracu probe `/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; the common working setup is Homebrew's python3 plus `python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`. When nothing qualifies, every `phone_*` tool returns one line — `imctl unavailable: no python3 with pyobjc found (tried …) — run …` — and the Mac and browser layers are unaffected.
105
+ **Unattended sessions:** in iPhone Mirroring → Settings, "Authenticate automatically" lets a session start without a password prompt. Trade-off: anyone who can use your unlocked Mac can then open your phone.
105
106
 
106
- **First success:** `phone_status` → if `paused` is `true`, `phone_launch` (brings the mirror to the front and clicks Resume) → `phone_screenshot` → `phone_ocr` → `phone_find` / `phone_tap`. Screenshots and OCR capture the Mirroring window by window id, so they are the phone's own pixels even when another window covers the mirror.
107
+ **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.
107
108
 
108
- **Known limits:** the iPhone must be unlocked (unlocking cannot be driven from the Mac); `paused` reads `null` on non-English macOS; `phone_open` relies on Spotlight + OCR and can miss apps whose labels are truncated. `phone_home` / `phone_app_switcher` go through the iPhone Mirroring menu and work without python when the mirror is connected.
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.
110
+
111
+ **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
+
113
+ **First success:** `phone_status` → `phone_launch` if `live` is not `true` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`.
114
+
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 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 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.
109
116
 
110
117
  ## Environment variables
111
118
 
@@ -132,6 +139,7 @@ noracu runs with the privileges of your MCP client. It clicks, types, pastes, an
132
139
  - **`file://` is refused** unless `NORACU_ALLOW_FILE_URL=1`, so a browser agent can't read `~/Documents` by navigating to it. (The initial navigation URL is scheme-checked; redirects are not — see SECURITY.md.)
133
140
  - **Focus guard:** pass `app` to `mac_type` / `mac_paste` / `mac_key` and input is refused unless that app is frontmost. Omit `app` and the guard is off.
134
141
  - **Stale-element protection:** an `element_index` is not a coordinate. It expires after 30 s (`element_no_longer_valid`); a browser click re-checks tag/name/href/position, and a Mac click is refused if the frontmost app changed since the snapshot.
142
+ - **iPhone screen is model input:** `phone_screenshot` / `phone_ocr` / `phone_find` return whatever the phone shows — notifications, messages, one-time codes. Use a Focus and a neutral app, and start with `NORACU_READ_ONLY=1` (phone observation allowed, phone input refused). Phone input is also refused while the mirror is paused (`mirror_not_live`).
135
143
  - **Injection-safe JXA:** string parameters are passed to `osascript` as argv data, never built into the script; the one numeric value (AX read depth) is clamped to 1–10 before use. Regression-tested.
136
144
 
137
145
  These switches do not make observed content trustworthy. Screenshot text, accessibility names, and page content are untrusted input to your model — do not let them override the task. Full threat model and per-threat status: [SECURITY.md](SECURITY.md).
@@ -147,10 +155,11 @@ These switches do not make observed content trustworthy. Screenshot text, access
147
155
  - Browser: tab management (list / select / close)
148
156
  - Act vocabulary (browser): `hover`, `set_value`, `wait_for`
149
157
  - Snapshot diffing to cut token use — pending measurement
158
+ - iPhone: `element_index` over OCR regions, re-checking the text before a tap
150
159
 
151
160
  ## Maintenance
152
161
 
153
- Solo-maintained, no SLA. macOS 15+ for the Mac and iPhone layers; the browser layer runs wherever Playwright does.
162
+ Solo-maintained, no SLA. macOS 15+ for the Mac layer; the iPhone layer also needs Apple silicon or a T2 Mac, iOS 18+ and iPhone Mirroring (not available in the EU); the browser layer runs wherever Playwright does.
154
163
 
155
164
  ## License
156
165
 
package/README.zh-CN.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # noracu
2
2
 
3
- **本地、无云的 computer-use MCP server:在 macOS 原生应用、Playwright 浏览器、以及(实验性的)镜像 iPhone 上操作——agent 读取 accessibility / ARIA 树,按 `element_index` 动作,而非像素坐标。无 API key,无遥测。**
3
+ **一个本地 MCP server:让 Claude、Cursor 或任意 MCP client 按 `element_index` 操作 macOS 应用和 Playwright 浏览器——并且(实验性地)经 Apple 的 iPhone Mirroring 操作真实 iPhone(在 Mac 上 OCR、按归一化坐标点击)。无 API key;server 本身无遥测。**
4
4
 
5
5
  [![CI](https://github.com/sgInnora/noracu/actions/workflows/ci.yml/badge.svg)](https://github.com/sgInnora/noracu/actions/workflows/ci.yml)
6
6
  [![npm](https://img.shields.io/npm/v/noracu.svg)](https://www.npmjs.com/package/noracu)
@@ -25,20 +25,20 @@ For English, see [README.md](README.md).
25
25
  | **Browser** | 12 个(`browser_*`) | Playwright(持久化 profile) | stable |
26
26
  | **iPhone** | 14 个(`phone_*`) | 经随包附带的 imctl 驱动 iPhone Mirroring(Python + pyobjc) | experimental |
27
27
 
28
- iPhone 层是实验性的,驱动 imctl 随包附带(在 `imctl/`)。它需要本 Mac 上有活动的 iPhone Mirroring 会话和一个带 pyobjc 的 python3;找不到这样的 python 时,`phone_*` 工具返回一行带安装命令的 `imctl unavailable` 错误,Mac 层和 Browser 层不受影响(`phone_home` / `phone_app_switcher` 即便如此仍可经 iPhone Mirroring 菜单工作)。observe/act 词汇表沿用 ChatGPT computer-use 推广的 action/observation 拆分思路,在开放的本地工具上重新实现。
28
+ iPhone 层是实验性的,驱动 imctl 随包附带(在 `imctl/`)。它需要 Apple 的 iPhone Mirroring,且 iPhone **锁定并靠近 Mac**,以及一个带 pyobjc 的 python3;它用 OCR 观察、按归一化坐标动作,而不是 `element_index`。没有 pyobjc 时,`phone_*` 工具返回一行带安装命令的 `imctl unavailable` 错误,Mac 层和 Browser 层不受影响。observe/act 词汇表沿用 ChatGPT computer-use 推广的 action/observation 拆分思路,在开放的本地工具上重新实现。
29
29
 
30
30
  ## 为什么用 noracu
31
31
 
32
32
  noracu 是本地的"手",不是"脑"。决策由你的 MCP client(Claude Desktop、Claude Code、Cursor)做;本 server 只在这台机器上观察与动作。
33
33
 
34
- - **完全在本机运行。** 无云、无 API key、无遥测、无 postinstall 脚本。唯一运行期依赖是 Playwright。noracu 自身不发任何网络请求;唯一的自动网络行为是首次 `browser_launch` 时一次性下载 Chromium(`NORACU_DISABLE_AUTO_INSTALL=1` 可关闭)。你让浏览器打开的页面当然会被抓取。
34
+ - **server 完全在本机运行。** 无云服务、无 API key、无遥测、无 postinstall 脚本。唯一运行期依赖是 Playwright。noracu 自身不发任何网络请求;唯一的自动网络行为是首次 `browser_launch` 时一次性下载 Chromium(`NORACU_DISABLE_AUTO_INSTALL=1` 可关闭)。你让浏览器打开的页面当然会被抓取,你的 MCP client 也仍会把工具结果(截图、OCR 文本)发给它所用的模型。
35
35
  - **按语义动作,而非像素。** 观察返回 accessibility 树(Mac)或 ARIA 树(browser)的带索引列表——是文本,不是截图。动作引用 `element_index`;索引 30 秒后过期,点击前会重新校验目标(browser 校验 tag/name/href/位置,Mac 校验 frontmost app)。索引失效时返回 `element_no_longer_valid`,而不是点错位置。树不够用时才用截图。
36
- - **一套协议,三个面——不是三套脚本。** 同一个 observe/act 循环驱动 Mac 原生应用、持久化 profile 的浏览器、以及(实验性的)镜像 iPhone。模式跨面一致,只是工具名不同(`mac_*` vs `browser_*`)。
36
+ - **一个循环,三个面。** Mac 原生应用和持久化 profile 的浏览器共用 `element_index` 协议(观察一棵树、按索引动作)。实验性的 iPhone 层在 Apple 的 iPhone Mirroring 上跑同一个 observe → act 循环,用的是 OCR 文本和归一化坐标——因为手机不向 Mac 暴露 accessibility 树。
37
37
  - **用你真实的会话。** 你已登录的浏览器 profile、你的 Mac 应用——不是托管的 VM。与云端 computer-use 相比:两者没有谁普遍更可靠,只是失败方式不同。noracu 把屏幕留在你本机。
38
38
  - **真正能关掉的开关。** `NORACU_READ_ONLY=1`(只观察,默认拒绝)、`NORACU_DISABLE_EVAL=1`、以及默认封禁 `file://`。见 [安全](#安全)。
39
- - **可验证。** 34 项端到端检查(`npm test`)、CI 跑在 macos-latest、MIT 许可,整个 server 就一个文件:`src/server.mjs`。
39
+ - **可验证。** 39 项端到端检查(`npm test`)、CI 跑在 macos-latest、MIT 许可,整个 server 就一个文件:`src/server.mjs`。
40
40
 
41
- **不适合的场景:** 你需要多个浏览器标签页或会话(当前仅单会话)、你不在 macOS 上(Mac 与 iPhone 层仅限 macOS;Browser 层跨平台)、或你现在就需要一个成品级的 iPhone 层(它已随包附带,但仍是实验性)。如果你只需要浏览器自动化,playwright-mcp 有 noracu v0.1 还没有的 tab 管理和 selector API;noracu 的价值在于:同一个 agent 还得离开浏览器去操作 Mac 应用。
41
+ **不适合的场景:** 你需要多个浏览器标签页或会话(当前仅单会话)、你不在 macOS 上(Mac 与 iPhone 层仅限 macOS;Browser 层跨平台)、或你现在就需要一个成品级的 iPhone 层(它已随包附带,但仍是实验性——而且 Apple 在欧盟不提供 iPhone Mirroring)。如果你只需要浏览器自动化,playwright-mcp 有 noracu v0.1 还没有的 tab 管理和 selector API;noracu 的价值在于:同一个 agent 还得离开浏览器去操作 Mac 应用。
42
42
 
43
43
  ## 快速开始
44
44
 
@@ -88,6 +88,7 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
88
88
  | GUI 宿主报 `spawn node` / `npx` `ENOENT` | 配置里改用绝对 `node` 路径——nvm/volta/homebrew 的 shim 不在 GUI `PATH` 上 |
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
+ | `phone_*` 被拒并报 `mirror_not_live: …`("Connection Paused"、"iPhone in Use") | 镜像已暂停或 iPhone 被解锁——锁上 iPhone、放在 Mac 旁,然后调用 `phone_launch`(会点击 Resume) |
91
92
  | 输入的文本被重新空格化(如 "no ra cu") | 有 CJK 输入法在激活——用 `mac_paste` 代替 `mac_type` |
92
93
  | `element_no_longer_valid` | 快照超过 30 秒或界面变了——重跑 `mac_ax_state` / `browser_snapshot` 并用新索引 |
93
94
 
@@ -97,15 +98,21 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
97
98
 
98
99
  ## iPhone 层(实验性)
99
100
 
100
- 14 个 `phone_*` 工具经 **imctl** 驱动 iPhone Mirroring——一个随本包附带的小型 Python 驱动(`imctl/`,MIT,约 1,000 行)。noracu 这边不需要再装别的;该层仍为实验性,因为它依赖在线的镜像会话和已解锁的手机。
101
+ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在 Mac 上用 OCR 观察(`phone_screenshot`、`phone_ocr`、`phone_find`),按 0–1 归一化坐标动作(`phone_tap`、`phone_swipe`、`phone_scroll`),用粘贴输入文字(`phone_type`),按名字打开 App(`phone_open`)。这不是 `element_index`:手机不向 Mac 暴露 accessibility 树,所以点击落在 OCR 识别出文字的位置。驱动(imctl,Python,MIT,约 1,000 行)随包附带在 `imctl/`。
101
102
 
102
- **要求:** macOS 15+ · iPhone Mirroring 已连接(同一 Apple 账户,蓝牙 + Wi-Fi 打开)· Accessibility + Screen Recording 授给宿主应用 · 一个能导入 pyobjc(Quartz、Vision、AppKit)的 python3。
103
+ **Apple 的要求**([support.apple.com/120421](https://support.apple.com/120421)):搭载 Apple 芯片或 T2 芯片、运行 macOS 15 或更高版本的 Mac;运行 iOS 18 或更高版本并设置了密码的 iPhone;两台设备登录同一个开启双重认证的 Apple 账户;蓝牙和 Wi-Fi 打开;Mac 没有共享互联网连接、没有使用 AirPlay 或随航(Sidecar)。**iPhone 必须锁定并靠近 Mac**——解锁 iPhone 或退出 iPhone Mirroring 都会结束会话。iPhone Mirroring 目前在欧盟不可用。一次只能一台 Mac 和一台 iPhone;摄像头和麦克风不会被镜像。
103
104
 
104
- **Python:** 设置 `NORACU_PYTHON=/path/to/python3`,或由 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`。都不可用时,每个 `phone_*` 工具返回一行错误——`imctl unavailable: no python3 with pyobjc found (tried …) — run …`——Mac 层与 Browser 层不受影响。
105
+ **无人值守:** 在 iPhone Mirroring → 设置里选「自动认证(Authenticate automatically)」,会话开始时就不再要求输入密码。代价:任何能使用你这台已解锁 Mac 的人都能打开你的手机。
105
106
 
106
- **首次成功路径:** `phone_status` → 若 `paused` 为 `true`,先 `phone_launch`(置前并点击 Resume)→ `phone_screenshot` → `phone_ocr` → `phone_find` / `phone_tap`。截图与 OCR 按窗口 id 截取镜像窗口,即使被其它窗口遮挡,拿到的也是手机自身的画面。
107
+ **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`。
107
108
 
108
- **已知限制:** 手机须处于解锁状态(解锁无法从 Mac 侧代做);非英文 macOS 下 `paused` 读为 `null`;`phone_open` 依赖 Spotlight + OCR,标签被截断的 app 可能找不到。`phone_home` / `phone_app_switcher` 走 iPhone Mirroring 菜单,镜像已连接时无需 python 也能用。
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。
110
+
111
+ **隐私:** 手机上显示的一切——通知、短信、邮件、一次性验证码——都会变成工具输出,由你的 MCP client 发给它所用的模型。开始前打开专注模式、打开一个无关紧要的 App,并先用 `NORACU_READ_ONLY=1`(`phone_status`、`phone_screenshot`、`phone_ocr`、`phone_find` 仍可用;所有手机输入都会被拒绝)。iPhone Mirroring 设置好后,iPhone 的通知也会出现在 Mac 上。
112
+
113
+ **首次成功路径:** `phone_status` → 若 `live` 不是 `true` 先 `phone_launch` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`。
114
+
115
+ **已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错;`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 并只点击完全匹配的结果,找不到就回到主屏;`phone_home` / `phone_app_switcher` 走 iPhone Mirroring 菜单(英文 macOS),镜像连接时无需 python。
109
116
 
110
117
  ## 环境变量
111
118
 
@@ -132,6 +139,7 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
132
139
  - **`file://` 被拒**,除非 `NORACU_ALLOW_FILE_URL=1`,这样浏览器 agent 无法通过导航到 `~/Documents` 来读本地文件。(仅校验初始导航 URL;重定向不校验——见 SECURITY.md。)
133
140
  - **焦点守卫:** 给 `mac_type` / `mac_paste` / `mac_key` 传 `app`,当该应用不在最前时输入被拒。不传 `app` 则守卫关闭。
134
141
  - **失效元素保护:** `element_index` 不是坐标。它 30 秒后过期(`element_no_longer_valid`);browser 点击会重校验 tag/name/href/位置,Mac 点击在 frontmost app 自快照以来变化时拒绝执行。
142
+ - **iPhone 画面就是模型输入:** `phone_screenshot` / `phone_ocr` / `phone_find` 会返回手机上显示的一切——通知、短信、一次性验证码。请用专注模式和无关紧要的 App,并先用 `NORACU_READ_ONLY=1`(允许观察手机、拒绝手机输入)。镜像暂停时手机输入同样会被拒绝(`mirror_not_live`)。
135
143
  - **防注入 JXA:** 字符串参数以 argv 数据传给 `osascript`,绝不拼进脚本;唯一的数值参数(AX 读取 depth)在使用前 clamp 到 1–10。有回归测试覆盖。
136
144
 
137
145
  这些开关不会让被观察的内容变得可信。截图文字、accessibility 名称、页面内容都是喂给你模型的**不可信输入**——别让它们覆盖任务指令。完整威胁模型与逐条状态见 [SECURITY.md](SECURITY.md)(英文)。
@@ -147,10 +155,11 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
147
155
  - Browser:tab 管理(list / select / close)
148
156
  - 动作词汇(browser):`hover`、`set_value`、`wait_for`
149
157
  - 快照 diffing 以降低 token 消耗——待测量
158
+ - iPhone:在 OCR 区域上提供 `element_index`,点击前重新校验文字
150
159
 
151
160
  ## 维护
152
161
 
153
- 个人维护,无 SLA。Mac 与 iPhone 层需 macOS 15+;Browser 层随 Playwright 跨平台。
162
+ 个人维护,无 SLA。Mac 层需 macOS 15+;iPhone 层另需 Apple 芯片或 T2 的 Mac、iOS 18+ 和 iPhone Mirroring(欧盟不可用);Browser 层随 Playwright 跨平台。
154
163
 
155
164
  ## 许可
156
165
 
package/SECURITY.md CHANGED
@@ -13,7 +13,8 @@ Treat every tool call as privileged.
13
13
  | 3 | **Arbitrary JS in browser** | `browser_evaluate` executes any JavaScript in the page context | **Mitigated (kill switch)** | Set `NORACU_DISABLE_EVAL=1`; `browser_evaluate` then returns an error on every call (it stays listed in `tools/list`) |
14
14
  | 4 | **Input validation gaps** | Malformed arguments (NaN coordinates, oversized strings, `javascript:` URLs) | **Mitigated** | `validateArgs` runs on every tool call; tools with coordinate/enum/length/URL constraints are checked (others pass through) |
15
15
  | 5 | **Screenshot privacy** | `mac_screenshot` / `phone_screenshot` capture the full screen / phone display | **Inherent** | Run in a dedicated macOS user account or virtual display for untrusted automation |
16
- | 6 | **iPhone operations** | `phone_tap` / `phone_type` can interact with payment and SMS-verification UIs | **Inherent** | Consider disconnecting Apple Pay / keeping Mirroring off for untrusted sessions |
16
+ | 6 | **iPhone operations** | `phone_tap` / `phone_type` can interact with payment and SMS-verification UIs; taps go to OCR coordinates with no element re-check | **Inherent** | Keep Mirroring off for untrusted sessions; `NORACU_READ_ONLY=1` refuses all phone input; input is refused while the mirror shows an overlay (`mirror_not_live`); "Authenticate automatically" lets anyone at the unlocked Mac start mirroring |
17
+ | 12 | **Phone screen as model input** | `phone_screenshot` / `phone_ocr` / `phone_find` return notifications, messages, mail and one-time codes visible on the phone | **Inherent** | Use a Focus mode and a neutral app; the MCP client sends tool results to its model; iPhone notifications also reach the Mac once Mirroring is set up |
17
18
  | 7 | **Supply chain** | malicious PRs / dependency poisoning after open-sourcing | **Partially mitigated** | Review all PRs touching `src/server.mjs` argument handling; lockfile committed; no `postinstall` scripts; the only runtime download is the one-time Playwright `chromium` install triggered by `browser_launch`, which can be disabled with `NORACU_DISABLE_AUTO_INSTALL=1` |
18
19
  | 8 | **Local file read via browser** | `browser_navigate` to a `file://` URL, then `browser_read` exfiltrates local files | **Mitigated (default)** | `file://` blocked at the `browser_navigate` argument unless `NORACU_ALLOW_FILE_URL=1` (initial URL only; redirects fall under threat 9) |
19
20
  | 9 | **HTTP GET side effects** | navigation triggers logout links, one-time tokens, private-network / cloud-metadata endpoints | **Not mitigated** | No URL blocklist (redirects and DNS rebinding defeat pre-navigation checks); client-side policy |
@@ -23,6 +24,9 @@ Treat every tool call as privileged.
23
24
  ## Hardening recommendations
24
25
 
25
26
  - Set `NORACU_DISABLE_EVAL=1` unless you actively need `browser_evaluate`.
27
+ - Before an agent touches the iPhone layer: turn on a Focus, open a neutral app,
28
+ and start with `NORACU_READ_ONLY=1`. Prefer "Ask every time" in iPhone
29
+ Mirroring settings unless you need unattended sessions.
26
30
  - Gate `mac_type` / `mac_paste` behind human confirmation when the frontmost
27
31
  app is a password manager or banking site (client-side policy).
28
32
  - Run untrusted automation in a dedicated macOS user account with
@@ -43,7 +43,8 @@ The bundled imctl driver (`imctl/`, Python) runs as a subprocess (`<python3> -m
43
43
 
44
44
  - Observe: `phone_ocr` (coordinates + text), `phone_screenshot` (captures the Mirroring window by CGWindow id, so a covered window still yields its own pixels; region capture is the fallback), `phone_find` (locates text)
45
45
  - Act: `phone_tap/longpress/swipe` (normalized 0-1 coordinates), `phone_home` / `phone_app_switcher` (iPhone Mirroring menu first, imctl gesture fallback), `phone_scroll`, `phone_type` (clipboard-based, IME-safe), `phone_key`
46
- - Session: `phone_status` (running, window, window_id, onscreen, frontmost, paused), `phone_launch` (ensure running + frontmost, clicks Resume when the session shows "Connection Paused"), `phone_open` (Spotlight + OCR + tap)
46
+ - Session: `phone_status` (running, window, window_id, onscreen, frontmost, live, overlay, paused — read from the window's AX structure: a live mirror is one empty AXHostingView group; an overlay such as "Connection Paused" or "iPhone in Use" adds static text and a button), `phone_launch` (ensure running + frontmost, clicks the single Resume button of a paused overlay), `phone_open` (Spotlight via the iPhone Mirroring shortcut, paste the name, tap an exact OCR match above the search field; otherwise back to the Home Screen)
47
+ - Safety: while the mirror is not live, imctl refuses tap/longpress/swipe/scroll/page/type/key/open with exit code 3 and a `mirror_not_live:` line, which the server returns as a tool error; ocr/find prefix a warning. The phone layer has no `element_index`: OCR coordinates are normalized to the window, and nothing re-verifies the target before a tap.
47
48
 
48
49
  ## Configuration
49
50
 
@@ -62,7 +63,7 @@ The bundled imctl driver (`imctl/`, Python) runs as a subprocess (`<python3> -m
62
63
  - Mac-layer actions spawn subprocesses (cliclick/osascript); per-action latency is tens of milliseconds (subprocess spawn; not benchmarked in this release) — a resident FFI process could cut it (see roadmap)
63
64
  - No axState diffing (every observation is a full snapshot)
64
65
  - Single browser session (no tab-level management)
65
- - The iPhone layer requires iPhone Mirroring to be online and the phone unlocked; OCR accuracy depends on screen content; `paused` detection reads the English "Connection Paused" label
66
+ - The iPhone layer requires iPhone Mirroring to be online, with the iPhone locked and near the Mac (unlocking ends mirroring; Apple: unavailable in the EU); OCR accuracy depends on screen content; `paused` detection reads the English "Connection Paused" label
66
67
  - macOS-only (Mac/iPhone layers); the Browser layer is cross-platform
67
68
 
68
69
  ## Roadmap (v2 candidates)
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.1 · 35 tools
4
+ > noracu v0.1.3 · 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, paused). |
48
- | `phone_launch` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Ensure iPhone Mirroring is running, brought to the front, and resumed if 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. |
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 from [x,y] to [x,y] over an optional duration in ms. |
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). 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 up or down by a distance. |
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 Spotlight search plus OCR-guided tap. |
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, else reports type_not_confirmed and keeps the text. replace=true selects all and overwrites the field. 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, OCR-pick the exact row and tap it; 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
@@ -175,24 +175,31 @@ model — don't let it override the task.
175
175
  | `ENOENT` cliclick | `brew install cliclick` or set `NORACU_CLICLICK` |
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
+ | `mirror_not_live: …` | iPhone Mirroring shows an overlay (paused, "iPhone in Use") — lock the iPhone, keep it near the Mac, call `phone_launch` |
178
179
  | `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` |
179
180
 
180
181
  ## 9. iPhone layer
181
182
 
182
- Experimental. The driver (imctl, Python) ships inside the package; the tools
183
- need iPhone Mirroring connected and a python3 with pyobjc (`NORACU_PYTHON`, or
184
- the automatic probe described in the README). A typical session:
183
+ Experimental. The driver (imctl, Python) ships inside the package. The tools
184
+ need Apple's iPhone Mirroring with the iPhone **locked and near the Mac**
185
+ (unlocking it ends the session; not available in the EU) and a python3 with
186
+ pyobjc (`NORACU_PYTHON`, or the automatic probe described in the README).
187
+ The phone exposes no accessibility tree, so this layer is not `element_index`:
188
+ it observes with OCR on the Mac and acts at normalized 0–1 coordinates.
185
189
 
186
190
  ```
187
191
  phone_status
188
- → {"running": true, "window": {...}, "window_id": 275104, "onscreen": true,
189
- "frontmost": false, "paused": true}
192
+ → {"running": true, "window": {...}, "window_id": 278508, "onscreen": true,
193
+ "frontmost": false, "live": false, "overlay": "Connection Paused", "paused": true}
194
+
195
+ phone_tap {"x": 0.5, "y": 0.5} # refused while the mirror is not live
196
+ → ERROR: mirror_not_live: Connection Paused — call phone_launch (or imctl resume) first
190
197
 
191
198
  phone_launch # brings the mirror to the front and clicks Resume
192
199
  → iPhone Mirroring ready
193
200
 
194
201
  phone_status
195
- → {... "paused": false ...}
202
+ → {... "live": true, "overlay": null, "paused": false ...}
196
203
 
197
204
  phone_ocr # OCR of the Mirroring window (captured by window id)
198
205
  → (0.50,0.06) 'Settings' [1.00]
@@ -206,8 +213,27 @@ phone_tap {"x": 0.50, "y": 0.06}
206
213
  → tapped (0.5, 0.06)
207
214
  ```
208
215
 
209
- Coordinates are normalized 0–1 over the mirror window. `phone_screenshot`
210
- returns a PNG of the window's own pixels even when another window covers it.
211
- If the phone is locked, unlock it on the phone; that step cannot be driven
212
- from the Mac. `phone_home` / `phone_app_switcher` go through the iPhone
213
- Mirroring menu and work without python when the mirror is connected.
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
219
+ not live, `phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`,
220
+ `phone_type`, `phone_key` and `phone_open` refuse with `mirror_not_live`, and
221
+ `phone_ocr` / `phone_find` start with a `warning: mirror not live …` line.
222
+
223
+ `phone_scroll {"direction": "down", "distance": 0.5}` moves the list under the
224
+ mirror by about half a window, with trackpad-style scroll events; a vertical
225
+ `phone_swipe` drag does not scroll lists in iPhone Mirroring, so keep swipes
226
+ for gestures such as Home Screen paging.
227
+
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`.
233
+
234
+ Privacy: everything the phone shows — notifications, messages, one-time
235
+ codes — becomes tool output that your MCP client sends to its model. Use a
236
+ Focus, open a neutral app first, and start with `NORACU_READ_ONLY=1`
237
+ (phone observation allowed, phone input refused). `phone_home` /
238
+ `phone_app_switcher` go through the iPhone Mirroring menu and work without
239
+ python when the mirror is connected.
package/imctl/README.md CHANGED
@@ -77,7 +77,7 @@ imctl status
77
77
 
78
78
  | Command | Description |
79
79
  |---------|-------------|
80
- | `status` | session + window info (JSON: running, window, window_id, onscreen, frontmost, paused) |
80
+ | `status` | session + window info (JSON: running, window, window_id, onscreen, frontmost, live, overlay, paused) |
81
81
  | `screenshot [PATH]` | capture the mirroring window to PNG by window id (works when covered) |
82
82
  | `resume` | click Resume when the window shows Connection Paused |
83
83
  | `launch` | ensure mirroring is running and frontmost |
@@ -129,8 +129,10 @@ through the Vision framework on-device.
129
129
 
130
130
  ## Limitations
131
131
 
132
- - The iPhone must stay unlocked and connected; lock-screen state is
133
- surfaced by `status` only indirectly (window content freezes).
132
+ - The iPhone must stay **locked** and near the Mac — iPhone Mirroring only
133
+ runs while the phone is locked, and unlocking it ends the session. The
134
+ mirror pauses after inactivity; `status` reports `paused` and `resume`
135
+ clicks Resume. iPhone Mirroring is unavailable in the EU (Apple).
134
136
  - Drag-and-drop between Mac and iPhone is not supported.
135
137
  - Multi-display setups: the window is located by AX query, so it works
136
138
  on any display, but coordinates are always screen-global.