noracu 0.1.0 → 0.1.2

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,80 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.1.2] — 2026-11-02
4
+
5
+ ### Fixed
6
+ - Docs: the iPhone must be **locked** and near the Mac — unlocking it ends
7
+ iPhone Mirroring (Apple). The 0.1.1 README, usage guide, architecture notes
8
+ and release notes said the opposite.
9
+ - `phone_type` sends a real Command-V chord. Before, iPhone Mirroring received
10
+ a plain "v" and the text was never pasted.
11
+ - `phone_scroll` uses trackpad-style scroll events (continuous, with
12
+ began/changed/ended phases). It used a mouse drag, which iPhone Mirroring
13
+ does not turn into a list scroll, so lists never moved. `phone_swipe` stays
14
+ a drag for gestures such as Home Screen paging.
15
+ - `phone_open` opens Spotlight through iPhone Mirroring's own shortcut instead
16
+ of a swipe that could put the Home Screen into edit (jiggle) mode; it taps
17
+ only an exact app-name match above the search field and returns to the Home
18
+ Screen when nothing matches.
19
+ - Phone input (`phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`,
20
+ `phone_type`, `phone_key`, `phone_open`) is refused with `mirror_not_live`
21
+ while iPhone Mirroring shows an overlay ("Connection Paused", "iPhone in
22
+ Use", …) instead of landing on the overlay; `phone_ocr` / `phone_find` start
23
+ with a warning in that state.
24
+
25
+ ### Known issue
26
+ - On one tested setup (iPhone 17 Pro Max, macOS 26) iPhone Mirroring draws the
27
+ phone larger than its window at every View size; the right column and bottom
28
+ row are cut off, so noracu cannot see or tap them. Under investigation.
29
+
30
+ ### Added
31
+ - `phone_status` reports `live` and `overlay`, read from the window's
32
+ structure rather than its language; `paused` now means "an overlay with a
33
+ Resume button is shown", and `resume` clicks that button only when it is the
34
+ single control.
35
+ - Apple's iPhone Mirroring requirements (Apple silicon or T2, macOS 15+,
36
+ iOS 18+ with a passcode, same Apple Account with two-factor authentication,
37
+ not available in the EU), the "Authenticate automatically" trade-off, and
38
+ privacy guidance in the README, usage guide, architecture notes and SECURITY.
39
+ - MCP Registry metadata: `mcpName` `io.github.sgInnora/noracu` in package.json
40
+ and `server.json`.
41
+ - `demo/record-phone.py` (repo only, not in the npm package) reproduces the
42
+ iPhone demo.
43
+
44
+ ## [0.1.1] — 2026-11-02
45
+
46
+ ### Added
47
+ - **iPhone driver bundled.** imctl (the Python driver behind the 14 `phone_*`
48
+ tools) now ships inside the npm package at `imctl/` (MIT, ~1,000 lines).
49
+ No companion checkout is needed; `NORACU_IMCTL_DIR` still overrides the
50
+ location for development. The layer stays EXPERIMENTAL.
51
+ - `NORACU_PYTHON`: pick the python3 that runs imctl. Without it, noracu
52
+ probes `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`
53
+ and `/usr/bin/python3` for one that imports pyobjc (Quartz, Vision,
54
+ AppKit) — probed once, lazily, on the first `phone_*` call. When none
55
+ qualifies the tool returns one actionable line with the `pip install`
56
+ command.
57
+ - `phone_status` now reports `window_id`, `onscreen`, `frontmost` and
58
+ `paused` (true when the Mirroring window shows "Connection Paused").
59
+ - `phone_launch` resumes a paused session (clicks Resume) after bringing the
60
+ window to the front. imctl gains `screenshot [PATH]` and `resume`
61
+ commands.
62
+ - e2e: 35 checks (new CI-safe guard that the bundled imctl is present).
63
+
64
+ ### Fixed
65
+ - `phone_screenshot` / `phone_ocr` / `phone_find` captured whatever was on
66
+ screen at the window's rectangle, so a covered or background Mirroring
67
+ window produced screenshots and OCR of other apps. Capture is now by
68
+ CGWindow id (`screencapture -l`), which returns the window's own pixels
69
+ even when it is covered; region capture remains as a fallback.
70
+ - imctl no longer writes `__pycache__` into the package directory
71
+ (`PYTHONDONTWRITEBYTECODE`).
72
+
73
+ ### Notes
74
+ - Mac and browser layers are unchanged.
75
+ - The iPhone layer needs macOS 15+, iPhone Mirroring connected, and a
76
+ python3 with pyobjc; Apple's `/usr/bin/python3` usually lacks pyobjc.
77
+
3
78
  ## [0.1.0] — 2026-11-02
4
79
 
5
80
  ### Added
@@ -36,8 +111,8 @@
36
111
 
37
112
  ### Notes
38
113
  - macOS 15+ required for Mac/iPhone layers; Browser layer is cross-platform.
39
- - imctl is a companion checkout (sibling directory or `NORACU_IMCTL_DIR`);
40
- phone tools degrade gracefully when absent.
114
+ - imctl was a companion checkout in 0.1.0 (sibling directory or `NORACU_IMCTL_DIR`);
115
+ phone tools degrade gracefully when absent. Bundled since 0.1.1.
41
116
  - Tool descriptions are English; every JSON-schema property is single-typed
42
117
  (no union/`oneOf`) for reliable LLM tool-calling across clients.
43
118
  - `mac_click` / `mac_drag` refuse an `element_index` when a different app is
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
 
@@ -23,22 +23,22 @@ One MCP server, three control surfaces:
23
23
  |---|---|---|---|
24
24
  | **Mac** | 9 (`mac_*`) | cliclick, screencapture, JXA System Events | stable |
25
25
  | **Browser** | 12 (`browser_*`) | Playwright (persistent profile) | stable |
26
- | **iPhone** | 14 (`phone_*`) | iPhone Mirroring via imctl (not public; 2 tools work without it) | experimental |
26
+ | **iPhone** | 14 (`phone_*`) | iPhone Mirroring via the bundled imctl driver (Python + pyobjc) | experimental |
27
27
 
28
- The iPhone layer is experimental and gated by imctl, a companion tool that is not yet public. Without imctl, most `phone_*` tools return a structured error; the Mac and browser layers are unaffected (`phone_home` / `phone_app_switcher` still work through the iPhone Mirroring menu when a phone is connected). 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 the iPhone layer today. 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
 
@@ -87,7 +87,8 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
87
87
  | `ENOENT` mentioning cliclick | `brew install cliclick` (or set `NORACU_CLICLICK`) |
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
- | `phone_*` says `imctl unavailable … missing Quartz` | expected — imctl is not public; ignore the phone tools (two menu tools still work, see below) |
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,12 +98,21 @@ Full worked examples: [docs/usage.md](docs/usage.md).
97
98
 
98
99
  ## iPhone layer (experimental)
99
100
 
100
- The iPhone layer has 14 `phone_*` tools that drive iPhone Mirroring through **imctl**, a companion tool that is not yet public.
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
- - **With imctl** installed and an iPhone mirrored to this Mac: all 14 tools are available.
103
- - **Without imctl:** most `phone_*` tools return a structured `imctl unavailable` error. Two tools still work when the mirror is connected, because they go through the iPhone Mirroring menu: `phone_home` (Home Screen) and `phone_app_switcher` (App Switcher).
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.
104
104
 
105
- No `phone_*` tool runs without an active iPhone Mirroring session on this Mac. Tool names and behavior may change before imctl is released. Do not set `NORACU_IMCTL_DIR` unless you already have imctl from its author.
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.
106
+
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.
108
+
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, macOS 26) iPhone Mirroring draws the phone larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps an exact match, otherwise returns to the Home Screen; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu (English macOS) and work without python while connected.
106
116
 
107
117
  ## Environment variables
108
118
 
@@ -113,7 +123,8 @@ No `phone_*` tool runs without an active iPhone Mirroring session on this Mac. T
113
123
  | `NORACU_ALLOW_FILE_URL` | unset | `=1` lets `browser_navigate` open `file://` URLs (blocked by default) |
114
124
  | `NORACU_DISABLE_AUTO_INSTALL` | unset | `=1` skips the Chromium auto-install on first `browser_launch` |
115
125
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick binary path |
116
- | `NORACU_IMCTL_DIR` | sibling `../imctl` | imctl checkout location (do not set unless you have imctl) |
126
+ | `NORACU_PYTHON` | auto-probe | python3 used for the bundled iPhone driver; must import pyobjc (Quartz, Vision, AppKit). Unset → first working of `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` |
127
+ | `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
117
128
 
118
129
  ## Security
119
130
 
@@ -128,6 +139,7 @@ noracu runs with the privileges of your MCP client. It clicks, types, pastes, an
128
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.)
129
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.
130
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`).
131
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.
132
144
 
133
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).
@@ -143,10 +155,11 @@ These switches do not make observed content trustworthy. Screenshot text, access
143
155
  - Browser: tab management (list / select / close)
144
156
  - Act vocabulary (browser): `hover`, `set_value`, `wait_for`
145
157
  - Snapshot diffing to cut token use — pending measurement
158
+ - iPhone: `element_index` over OCR regions, re-checking the text before a tap
146
159
 
147
160
  ## Maintenance
148
161
 
149
- 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.
150
163
 
151
164
  ## License
152
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)
@@ -23,22 +23,22 @@ For English, see [README.md](README.md).
23
23
  |---|---|---|---|
24
24
  | **Mac** | 9 个(`mac_*`) | cliclick、screencapture、JXA System Events | stable |
25
25
  | **Browser** | 12 个(`browser_*`) | Playwright(持久化 profile) | stable |
26
- | **iPhone** | 14 个(`phone_*`) | 经 imctl 驱动 iPhone Mirroring(尚未公开;2 个工具无需它也能用) | experimental |
26
+ | **iPhone** | 14 个(`phone_*`) | 经随包附带的 imctl 驱动 iPhone Mirroring(Python + pyobjc) | experimental |
27
27
 
28
- iPhone 层是实验性的,依赖 imctl——一个尚未公开的伴生工具。没有 imctl 时,多数 `phone_*` 工具返回结构化错误;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
 
@@ -87,7 +87,8 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
87
87
  | `ENOENT` 提到 cliclick | `brew install cliclick`(或设 `NORACU_CLICLICK`) |
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
- | `phone_*` 报 `imctl unavailable … missing Quartz` | 正常——imctl 未公开;忽略 phone 工具(两个菜单工具仍可用,见下) |
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,12 +98,21 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
97
98
 
98
99
  ## iPhone 层(实验性)
99
100
 
100
- iPhone 层有 14 个 `phone_*` 工具,经 **imctl**(尚未公开的伴生工具)驱动 iPhone Mirroring。
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
- - **装了 imctl** 且 iPhone 已镜像到本 Mac 时:14 个工具全部可用。
103
- - **没有 imctl 时:** 多数 `phone_*` 返回结构化的 `imctl unavailable` 错误。有两个工具在镜像已连接时仍可用,因为它们走 iPhone Mirroring 菜单:`phone_home`(回主屏)和 `phone_app_switcher`(打开 App 切换器)。
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;摄像头和麦克风不会被镜像。
104
104
 
105
- 任何 `phone_*` 工具都需要本 Mac 上有活动的 iPhone Mirroring 会话。imctl 发布前,工具名和行为可能变化。除非你已从作者处拿到 imctl,否则不要设 `NORACU_IMCTL_DIR`。
105
+ **无人值守:** 在 iPhone Mirroring → 设置里选「自动认证(Authenticate automatically)」,会话开始时就不再要求输入密码。代价:任何能使用你这台已解锁 Mac 的人都能打开你的手机。
106
+
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`。
108
+
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、macOS 26)上,iPhone Mirroring 在所有 View 尺寸下都把手机画面画得比窗口大,右列和最底行被裁掉、无法点到——边缘附近点不中时先看 `phone_screenshot`;`phone_open` 把 App 名输入 Spotlight 并只点击完全匹配的结果,找不到就回到主屏;`phone_home` / `phone_app_switcher` 走 iPhone Mirroring 菜单(英文 macOS),镜像连接时无需 python。
106
116
 
107
117
  ## 环境变量
108
118
 
@@ -113,7 +123,8 @@ iPhone 层有 14 个 `phone_*` 工具,经 **imctl**(尚未公开的伴生工
113
123
  | `NORACU_ALLOW_FILE_URL` | 未设 | `=1` 允许 `browser_navigate` 打开 `file://` URL(默认封禁) |
114
124
  | `NORACU_DISABLE_AUTO_INSTALL` | 未设 | `=1` 跳过首次 `browser_launch` 的 Chromium 自动安装 |
115
125
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick 二进制路径 |
116
- | `NORACU_IMCTL_DIR` | 同级 `../imctl` | imctl 检出位置(没有 imctl 就别设) |
126
+ | `NORACU_PYTHON` | 自动探测 | 运行随包 iPhone 驱动的 python3;须能导入 pyobjc(Quartz、Vision、AppKit)。未设置时依次尝试 `/opt/homebrew/bin/python3`、`/usr/local/bin/python3`、`python3`、`/usr/bin/python3` |
127
+ | `NORACU_IMCTL_DIR` | 包内 `imctl/` | 覆盖驱动位置(仅开发用) |
117
128
 
118
129
  ## 安全
119
130
 
@@ -128,6 +139,7 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
128
139
  - **`file://` 被拒**,除非 `NORACU_ALLOW_FILE_URL=1`,这样浏览器 agent 无法通过导航到 `~/Documents` 来读本地文件。(仅校验初始导航 URL;重定向不校验——见 SECURITY.md。)
129
140
  - **焦点守卫:** 给 `mac_type` / `mac_paste` / `mac_key` 传 `app`,当该应用不在最前时输入被拒。不传 `app` 则守卫关闭。
130
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`)。
131
143
  - **防注入 JXA:** 字符串参数以 argv 数据传给 `osascript`,绝不拼进脚本;唯一的数值参数(AX 读取 depth)在使用前 clamp 到 1–10。有回归测试覆盖。
132
144
 
133
145
  这些开关不会让被观察的内容变得可信。截图文字、accessibility 名称、页面内容都是喂给你模型的**不可信输入**——别让它们覆盖任务指令。完整威胁模型与逐条状态见 [SECURITY.md](SECURITY.md)(英文)。
@@ -143,10 +155,11 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
143
155
  - Browser:tab 管理(list / select / close)
144
156
  - 动作词汇(browser):`hover`、`set_value`、`wait_for`
145
157
  - 快照 diffing 以降低 token 消耗——待测量
158
+ - iPhone:在 OCR 区域上提供 `element_index`,点击前重新校验文字
146
159
 
147
160
  ## 维护
148
161
 
149
- 个人维护,无 SLA。Mac 与 iPhone 层需 macOS 15+;Browser 层随 Playwright 跨平台。
162
+ 个人维护,无 SLA。Mac 层需 macOS 15+;iPhone 层另需 Apple 芯片或 T2 的 Mac、iOS 18+ 和 iPhone Mirroring(欧盟不可用);Browser 层随 Playwright 跨平台。
150
163
 
151
164
  ## 许可
152
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
@@ -39,17 +39,19 @@ A single persistent Playwright 1.58 session (one browser, one context), held in
39
39
 
40
40
  ### iPhone layer (14 tools)
41
41
 
42
- imctl subprocess (`python3 -m imctl.cli`, PYTHONPATH pointing at imctl/src) drives iPhone Mirroring. **Experimental**: when imctl or its Python dependencies (pyobjc/Quartz) are absent, most tools return a structured `imctl unavailable` error rather than crashing the server (`phone_home`/`phone_app_switcher` still work via the iPhone Mirroring menu).
42
+ The bundled imctl driver (`imctl/`, Python) runs as a subprocess (`<python3> -m imctl.cli`, PYTHONPATH = `imctl/src`, no bytecode written). The interpreter is `NORACU_PYTHON` or the first of `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` that imports pyobjc (Quartz, Vision, AppKit); probed once, lazily, on the first `phone_*` call. **Experimental**: when no such python exists, tools return a structured one-line `imctl unavailable` error with the install command rather than crashing the server (`phone_home`/`phone_app_switcher` still work via the iPhone Mirroring menu).
43
43
 
44
- - Observe: `phone_ocr` (coordinates + text), `phone_screenshot` (captures the Mirroring window region), `phone_find` (locates text)
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`, `phone_launch`, `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
 
50
51
  | Environment variable | Default | Description |
51
52
  |---|---|---|
52
- | `NORACU_IMCTL_DIR` | `../imctl` beside the repo root (`src/../../imctl`) | imctl checkout location |
53
+ | `NORACU_PYTHON` | auto-probe (see iPhone layer) | python3 that runs the bundled driver; must import pyobjc |
54
+ | `NORACU_IMCTL_DIR` | bundled `imctl/` (`src/../imctl`) | override the driver location (development only) |
53
55
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | path to cliclick |
54
56
  | `NORACU_READ_ONLY` | unset (full control) | `=1` observation-only mode: a default-deny allowlist of 12 tools — the observe tools (`mac_screenshot`, `mac_ax_state`, `browser_snapshot`, `browser_screenshot`, `browser_read`, `phone_status`, `phone_screenshot`, `phone_ocr`, `phone_find`) plus browser session lifecycle (`browser_launch`, `browser_navigate`, `browser_close`). `browser_navigate` still issues a page-load request. All input-synthesis tools (click/drag/type/key/paste/tap/swipe/evaluate/…) are rejected |
55
57
  | `NORACU_DISABLE_EVAL` | unset (enabled) | `=1` makes `browser_evaluate` return an error on every call (kill switch for arbitrary JS execution; it stays listed) |
@@ -61,7 +63,7 @@ imctl subprocess (`python3 -m imctl.cli`, PYTHONPATH pointing at imctl/src) driv
61
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)
62
64
  - No axState diffing (every observation is a full snapshot)
63
65
  - Single browser session (no tab-level management)
64
- - The iPhone layer requires iPhone Mirroring to be online; OCR accuracy depends on screen content
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
65
67
  - macOS-only (Mac/iPhone layers); the Browser layer is cross-platform
66
68
 
67
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.0 · 35 tools
4
+ > noracu v0.1.2 · 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. Requires imctl (not yet public). Return the iPhone Mirroring session status as JSON. |
48
- | `phone_launch` | — | EXPERIMENTAL. Requires imctl (not yet public). Ensure iPhone Mirroring is running and brought to the front. |
49
- | `phone_screenshot` | — | EXPERIMENTAL. Requires imctl (not yet public). Screenshot the iPhone screen (the Mirroring window region). |
50
- | `phone_ocr` | — | EXPERIMENTAL. Requires imctl (not yet public). OCR the iPhone screen into text with coordinates. |
51
- | `phone_find` | text:string? | EXPERIMENTAL. Requires imctl (not yet public). Locate text on the iPhone screen. |
52
- | `phone_tap` | x:number?, y:number? | EXPERIMENTAL. Requires imctl (not yet public). Tap at {x, y} in normalized 0-1 coordinates. |
53
- | `phone_longpress` | x:number?, y:number?, duration:number? | EXPERIMENTAL. Requires imctl (not yet public). Long-press at {x, y} for an optional duration in seconds. |
54
- | `phone_swipe` | from:array?, to:array?, ms:number? | EXPERIMENTAL. Requires imctl (not yet public). Swipe from [x,y] to [x,y] over an optional duration in ms. |
55
- | `phone_home` | — | EXPERIMENTAL. Go to the iPhone Home Screen via the iPhone Mirroring menu (works without imctl when the mirror is connected); falls back to an imctl swipe. |
56
- | `phone_app_switcher` | — | EXPERIMENTAL. Open the iPhone App Switcher via the iPhone Mirroring menu (works without imctl when the mirror is connected); falls back to an imctl gesture. |
57
- | `phone_scroll` | direction:string?, distance:number? | EXPERIMENTAL. Requires imctl (not yet public). Scroll up or down by a distance. |
58
- | `phone_type` | text:string? | EXPERIMENTAL. Requires imctl (not yet public). Type text via the clipboard (IME-safe). |
59
- | `phone_key` | key:string? | EXPERIMENTAL. Requires imctl (not yet public). Press a key: return, delete, up, down, left, or right. |
60
- | `phone_open` | app:string? | EXPERIMENTAL. Requires imctl (not yet public). Open an app via Spotlight search plus OCR-guided tap. |
47
+ | `phone_status` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Return the iPhone Mirroring session status as JSON (running, window, onscreen, frontmost, live, overlay, paused). |
48
+ | `phone_launch` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Ensure iPhone Mirroring is running, brought to the front, and clicks Resume when the connection is paused. |
49
+ | `phone_screenshot` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Screenshot the iPhone screen (the Mirroring window, captured by window id so it works even when covered). |
50
+ | `phone_ocr` | — | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. OCR the iPhone screen into text with coordinates. |
51
+ | `phone_find` | text:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Locate text on the iPhone screen. |
52
+ | `phone_tap` | x:number?, y:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Tap at {x, y} in normalized 0-1 coordinates. Refused with mirror_not_live when the mirror is paused. |
53
+ | `phone_longpress` | x:number?, y:number?, duration:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Long-press at {x, y} for an optional duration in seconds. |
54
+ | `phone_swipe` | from:array?, to:array?, ms:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Swipe (mouse drag) from [x,y] to [x,y] over an optional duration in ms, for gestures such as Home Screen paging; to move a list use phone_scroll. |
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
+ | `phone_app_switcher` | — | EXPERIMENTAL. Open the iPhone App Switcher via the iPhone Mirroring menu (works without python/pyobjc when the mirror is connected); falls back to an imctl gesture. |
57
+ | `phone_scroll` | direction:string?, distance:number? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Scroll the list under the mirror up or down by about `distance` window heights (default 0.5), using trackpad-style scroll events. |
58
+ | `phone_type` | text:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe). |
59
+ | `phone_key` | key:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Press a key: return, delete, up, down, left, or right. |
60
+ | `phone_open` | app:string? | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Open an app via the mirroring Spotlight menu command/shortcut, type the name, OCR-pick the matching app row and tap it; returns to the home screen when not found. |
61
61
 
package/docs/usage.md CHANGED
@@ -161,7 +161,8 @@ model — don't let it override the task.
161
161
  | `NORACU_ALLOW_FILE_URL` | unset | `=1` allows `browser_navigate` to open `file://` |
162
162
  | `NORACU_DISABLE_AUTO_INSTALL` | unset | `=1` skips Chromium auto-install on first `browser_launch` |
163
163
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick binary path |
164
- | `NORACU_IMCTL_DIR` | sibling `../imctl` | imctl location (leave unset unless you have imctl) |
164
+ | `NORACU_PYTHON` | auto-probe | python3 for the bundled iPhone driver (must import pyobjc: Quartz, Vision, AppKit) |
165
+ | `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
165
166
  | `NORACU_CI` | unset | `=1` only affects `npm test` (skips hardware-gated checks) |
166
167
 
167
168
  ## 8. Error reference
@@ -174,10 +175,65 @@ model — don't let it override the task.
174
175
  | `ENOENT` cliclick | `brew install cliclick` or set `NORACU_CLICLICK` |
175
176
  | `… blocked by NORACU_READ_ONLY=1` | you're in observation-only mode — unset it to act |
176
177
  | `browser_evaluate disabled by NORACU_DISABLE_EVAL=1` | eval kill-switch is on |
177
- | `imctl unavailable …` | expected — imctl is not public; the iPhone layer is experimental |
178
+ | `mirror_not_live: …` | iPhone Mirroring shows an overlay (paused, "iPhone in Use") — lock the iPhone, keep it near the Mac, call `phone_launch` |
179
+ | `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` |
178
180
 
179
181
  ## 9. iPhone layer
180
182
 
181
- Experimental and gated by imctl (not public). There are no worked examples
182
- here; see the [iPhone layer section in the README](../README.md#iphone-layer-experimental)
183
- for exactly which tools work without imctl and what the structured error means.
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.
189
+
190
+ ```
191
+ phone_status
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
197
+
198
+ phone_launch # brings the mirror to the front and clicks Resume
199
+ → iPhone Mirroring ready
200
+
201
+ phone_status
202
+ → {... "live": true, "overlay": null, "paused": false ...}
203
+
204
+ phone_ocr # OCR of the Mirroring window (captured by window id)
205
+ → (0.50,0.06) 'Settings' [1.00]
206
+ (0.18,0.31) 'FaceTime' [1.00]
207
+ -- 2 hits
208
+
209
+ phone_find {"text": "Settings"}
210
+ → (0.50,0.06) 'Settings' [1.00]
211
+
212
+ phone_tap {"x": 0.50, "y": 0.06}
213
+ → tapped (0.5, 0.06)
214
+ ```
215
+
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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 imctl contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.