noracu 0.1.3 → 0.2.0
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 +483 -0
- package/README.md +40 -21
- package/README.zh-CN.md +42 -23
- package/SECURITY.md +15 -8
- package/docs/architecture.md +58 -27
- package/docs/tools.md +46 -35
- package/docs/usage.md +195 -66
- package/imctl/README.md +19 -16
- package/imctl/pyproject.toml +1 -1
- package/imctl/src/imctl/__init__.py +1 -1
- package/imctl/src/imctl/cli.py +315 -35
- package/imctl/src/imctl/gestures.py +313 -96
- package/imctl/src/imctl/input.py +300 -60
- package/imctl/src/imctl/verify.py +39 -0
- package/imctl/src/imctl/vision.py +55 -4
- package/imctl/src/imctl/window.py +61 -9
- package/package.json +5 -4
- package/src/mac-ax.js +2397 -0
- package/src/server.mjs +1887 -510
package/README.md
CHANGED
|
@@ -21,7 +21,7 @@ One MCP server, three control surfaces:
|
|
|
21
21
|
|
|
22
22
|
| Layer | Tools | Drives | Status |
|
|
23
23
|
|---|---|---|---|
|
|
24
|
-
| **Mac** |
|
|
24
|
+
| **Mac** | 20 (`mac_*`) | macOS Accessibility API (`src/mac-ax.js`, JXA), cliclick, screencapture | stable |
|
|
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
|
|
|
@@ -31,14 +31,15 @@ The iPhone layer is experimental and ships with its driver (imctl, in `imctl/`).
|
|
|
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
|
-
- **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
|
-
- **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
|
|
34
|
+
- **The server runs entirely on your machine.** No cloud service, no API key, no telemetry, no postinstall scripts. Sole runtime dependency: Playwright. noracu makes no network calls of its own; the only automatic one is the one-time Chromium download on the first `browser_launch` (`NORACU_DISABLE_AUTO_INSTALL=1` turns that off). With `NORACU_ALLOW_CDP=1` it also talks to a DevTools port on 127.0.0.1 that it opened itself (`NORACU_ALLOW_CDP=any` for other loopback ports). The browser still fetches the pages you point it at, and your MCP client still sends tool results — screenshots, OCR text — to whatever model it uses.
|
|
35
|
+
- **Acts on semantics, not pixels.** Observation returns the accessibility tree (Mac, read directly through the macOS Accessibility API — about 0.15 s for a 500-element window on our test Mac) or ARIA tree (browser) as an indexed list — text, not screenshots. Actions reference `element_index`; indices expire after 30 s. On the Mac an index is backed by identity evidence (the window's ID, the child path, role, identifier, name) and the element is re-identified before every action; in the browser, tag/name/href/position are re-checked. A gone or changed element returns `element_no_longer_valid` instead of clicking the wrong thing. Screenshots are there when the tree is not enough.
|
|
36
|
+
- **Says what happened.** A Mac action uses the element's own accessibility action when it has one (press, select, set value, insert text — no pointer, no focus change, IME-safe text); a physical click is sent only after a hit test shows that the point reaches the element. Every input action result (Mac, browser and iPhone) states whether it was delivered (`delivered_verified` when a change was observed, `delivered_unverified`, `not_delivered`, or `unknown` when a step timed out or failed mid-action) and whether a retry is safe; Mac actions also name any sheet, dialog or menu they opened.
|
|
36
37
|
- **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
38
|
- **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
39
|
- **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.**
|
|
40
|
+
- **Verifiable.** End-to-end tests (`npm test`; the hardware-free ones run in CI on macos-latest), MIT; the server is `src/server.mjs` plus the Mac accessibility engine `src/mac-ax.js`.
|
|
40
41
|
|
|
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
|
|
42
|
+
**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 lacks. If you need desktop apps on Windows or Linux, agent-desktop (Vercel Labs) covers macOS, Windows and Linux through each OS's accessibility API; noracu's desktop layer is macOS-only. noracu is for when one agent drives Mac apps, a browser and an iPhone from one server.
|
|
42
43
|
|
|
43
44
|
## Quickstart
|
|
44
45
|
|
|
@@ -48,7 +49,7 @@ First success is `mac_ax_state` (or a browser snapshot) — not a click, and not
|
|
|
48
49
|
|
|
49
50
|
```bash
|
|
50
51
|
npm install noracu # server at node_modules/noracu/src/server.mjs
|
|
51
|
-
brew install cliclick #
|
|
52
|
+
brew install cliclick # needed for physical Mac input (mac_key, mac_paste, mac_drag, and physical mac_click/mac_type)
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
Or from source: `git clone https://github.com/sgInnora/noracu.git && cd noracu && npm install && npm test` (add `NORACU_CI=1` to skip hardware-gated checks).
|
|
@@ -76,21 +77,28 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
|
|
|
76
77
|
|
|
77
78
|
**3. Grant macOS permissions to the host app, not to `node`.** System Settings → Privacy & Security → **Accessibility** and **Screen Recording** (macOS 15: "Screen & System Audio Recording") → enable the host (Claude Desktop / Cursor / your terminal). noracu never appears here. Quit and reopen the host after granting.
|
|
78
79
|
|
|
79
|
-
**4. Verify.**
|
|
80
|
+
**4. Verify.** Call `mac_status` — it reports whether the host has Accessibility and Screen Recording, and whether cliclick is found. Then, with Finder in front, call `mac_ax_state` (no args) — it returns an indexed accessibility tree; indices last 30 s. Browser smoke test (no Accessibility needed): `browser_launch` (first run downloads Chromium unless `NORACU_DISABLE_AUTO_INSTALL=1`) → `browser_navigate` → `browser_snapshot` → `browser_click` by index.
|
|
80
81
|
|
|
81
82
|
### Troubleshooting
|
|
82
83
|
|
|
83
84
|
| Symptom | Cause / fix |
|
|
84
85
|
|---|---|
|
|
85
|
-
| `mac_*` fails with error **-1719** | Accessibility not granted to the **host** app — grant it, then quit + reopen the host |
|
|
86
|
+
| `mac_*` fails with `permission_denied: Accessibility permission is missing…` (before 0.2: error **-1719**) | Accessibility not granted to the **host** app — grant it, then quit + reopen the host; `mac_status` shows the state |
|
|
86
87
|
| Screenshots come back all black | Screen Recording not granted to the host — grant it, then quit + reopen |
|
|
87
88
|
| `ENOENT` mentioning cliclick | `brew install cliclick` (or set `NORACU_CLICLICK`) |
|
|
88
89
|
| `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
90
|
| `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
91
|
| `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
|
|
92
|
-
|
|
|
93
|
-
| `
|
|
92
|
+
| `phone_*` refused with `mirror_not_live: …` ("Connection Paused", "iPhone in Use", "not running") or `mirror_state_unknown: …` | the mirror is not running, paused, or its state could not be read — lock the iPhone, keep it near the Mac, check `phone_status`, and call `phone_launch` (it starts Mirroring and clicks Resume) |
|
|
93
|
+
| `phone_launch` says `mirror_setup_required` | iPhone Mirroring shows a setup or welcome screen (e.g. the first launch after a macOS upgrade) — finish it yourself in the iPhone Mirroring window; noracu never clicks through it |
|
|
94
|
+
| `imctl_timeout: phone … did not finish within …s` | the Mac is under heavy load or the system is stuck — the action may have partly run, so check `phone_status` / `phone_screenshot` before retrying (after `phone_open`, noracu goes back to the Home Screen); the server keeps answering other calls meanwhile |
|
|
95
|
+
| `input_busy: …` | an earlier phone or Mac action held the input queue for over 60 s (or `NORACU_PHONE_TIMEOUT_MS` + 15 s); the call did nothing — retry |
|
|
96
|
+
| `phone_open` returns app not found for an installed app | it only taps the label in Spotlight's Top Hit card — use the name exactly as the phone shows it under the icon (e.g. `拼多多`, not `Pinduoduo`). "Spotlight showed no Top Hit" on an installed app usually means the iPhone's language is not English: `phone_open` reads Spotlight's "Top Hit" label — set `NORACU_TOPHIT_LABELS` to the label your iPhone shows. `open_not_confirmed: … never showed up on the phone` means the pasted name did not arrive (a paste can take several seconds to reach the iPhone) — retry. `phone_open` leaves the app name on the clipboard |
|
|
97
|
+
| Typed text comes out re-spaced (e.g. "no ra cu") | it went in as keystrokes (`mac_type` with `mechanism: "physical"`, or a focused element that takes no accessibility text) while a CJK input method was active — use the default `mac_type` mechanism, or `mac_paste` |
|
|
98
|
+
| `element_no_longer_valid` | the snapshot is older than 30 s, or the element is gone, changed or in a window that closed — re-run `mac_ax_state` / `browser_snapshot` and use a fresh index |
|
|
99
|
+
| `occluded: … — on top: {…}` | a physical click would land on something else (another window, a sheet) — bring the target forward or close what covers it; nothing was sent |
|
|
100
|
+
| `ambiguous_window: … windows: […]` | the app has several windows and none is focused — pass `window` (index or title) or `window_id` from `mac_windows` |
|
|
101
|
+
| `policy_denied: "cmd-q" …` | `mac_key` refuses quit / log-out / lock / force-quit / delete-immediately / empty-Trash chords unless `force: true`; to quit an app use `mac_app` |
|
|
94
102
|
|
|
95
103
|
Node 18 is rejected at startup — use Node ≥ 20. Claude Desktop may start one noracu process per surface (e.g. chat and a second surface); they share the browser profile, so launch the browser from only one at a time.
|
|
96
104
|
|
|
@@ -98,7 +106,7 @@ Full worked examples: [docs/usage.md](docs/usage.md).
|
|
|
98
106
|
|
|
99
107
|
## iPhone layer (experimental)
|
|
100
108
|
|
|
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
|
|
109
|
+
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 3,500 lines) ships in `imctl/`.
|
|
102
110
|
|
|
103
111
|
**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
112
|
|
|
@@ -106,25 +114,30 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
|
|
|
106
114
|
|
|
107
115
|
**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
116
|
|
|
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")
|
|
117
|
+
**Mirror state:** `phone_status` reports `live` (the phone's screen is being streamed), `overlay` (the text iPhone Mirroring shows instead, e.g. "Connection Paused" or "iPhone in Use"), `paused` (that overlay offers a Resume button) and `setup` (a setup or welcome screen the user must finish — noracu never clicks it). Detection reads the window's structure and shape (the mirror is a tall or wide phone-shaped window; a setup screen is nearly square), not its text. While the mirror is not live, every phone input tool (`phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key`, `phone_open`, `phone_home` and `phone_app_switcher`) refuses with `mirror_not_live` — without stealing focus when the mirror is paused or closed — instead of acting on the overlay, and refuses with `mirror_state_unknown` if the mirror state still cannot be determined (`phone_ocr` / `phone_find` start their output with a warning). The mirror pauses after inactivity; `phone_launch` brings it forward and clicks Resume.
|
|
110
118
|
|
|
111
119
|
**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
120
|
|
|
113
121
|
**First success:** `phone_status` → `phone_launch` if `live` is not `true` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`.
|
|
114
122
|
|
|
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
|
|
123
|
+
**Known limits:** a tap goes where OCR saw the text, so repeated or misread labels can be hit wrong (`phone_open` cannot tell an app from a contact or website that Spotlight's Top Hit shows under the same name); `phone_scroll` moves lists with trackpad-style scroll events (a vertical `phone_swipe` drag does not scroll a list — use it for gestures such as Home Screen paging); on one tested setup (iPhone 17 Pro Max on iOS 27.0.1, Mac on macOS 26.6.2) iPhone Mirroring draws the phone about 17% larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached; moving the window between displays, changing the main display and relaunching made no difference, and the iOS 27 / macOS 26 version mismatch is the main suspect — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps it only when Spotlight's Top Hit card shows exactly that name (web suggestions, websites and Settings rows of the same name are never tapped), otherwise returns to the Home Screen — it reads Spotlight's English "Top Hit" label, so on an iPhone set to another language it finds nothing until `NORACU_TOPHIT_LABELS` names that label; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu when live (working without python on English macOS, falling back to an `imctl` gesture only when those menu items are absent, and returning `menu_unknown` without a second gesture on timeout) and report only that the command was sent (`screen not verified`).
|
|
116
124
|
|
|
117
125
|
## Environment variables
|
|
118
126
|
|
|
119
127
|
| Variable | Default | Purpose |
|
|
120
128
|
|---|---|---|
|
|
121
|
-
| `NORACU_READ_ONLY` | unset | `=1` observation-only: a default-deny allowlist of
|
|
129
|
+
| `NORACU_READ_ONLY` | unset | `=1` observation-only: a default-deny allowlist of 18 observe + browser-lifecycle tools; every click/type/paste/key/eval tool is refused (`mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"` too; `mac_ax_state` / `mac_find` also skip `web_accessibility`) |
|
|
122
130
|
| `NORACU_DISABLE_EVAL` | unset | `=1` makes `browser_evaluate` (arbitrary JS) return an error when called (it stays listed) |
|
|
123
131
|
| `NORACU_ALLOW_FILE_URL` | unset | `=1` lets `browser_navigate` open `file://` URLs (blocked by default) |
|
|
124
132
|
| `NORACU_DISABLE_AUTO_INSTALL` | unset | `=1` skips the Chromium auto-install on first `browser_launch` |
|
|
133
|
+
| `NORACU_ALLOW_CDP` | unset | `=1` allows `mac_app` launch with `cdp_port` and `browser_launch` with `cdp_port` for ports opened by this `noracu` process (live PID and matching `webSocketDebuggerUrl`); `=any` also allows `browser_launch` to attach to any loopback DevTools port on 127.0.0.1 (always refused under `NORACU_READ_ONLY=1`) |
|
|
134
|
+
| `NORACU_TRACE` | unset | a file path: one JSON line per tool call (`{ts, tool, args, ms, error, code}` — argument names/sizes and error code prefix only, never argument text, result text, or error messages; opened `0600` with `O_NOFOLLOW`, refusing symlinks) |
|
|
125
135
|
| `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick binary path |
|
|
126
136
|
| `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
137
|
| `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
|
|
138
|
+
| `NORACU_PHONE_TIMEOUT_MS` | 30000 (45000 for `phone_open` / `phone_type`) | time limit for each iPhone-layer step, 1000–600000 ms; on expiry the step is stopped and returns `imctl_timeout` |
|
|
139
|
+
| `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | OCR languages for the iPhone screen, in priority order (comma-separated Vision language codes, e.g. `zh-Hant,en-US` or `en-US`; codes Vision does not list are skipped with a warning) |
|
|
140
|
+
| `NORACU_TOPHIT_LABELS` | `Top Hit` | the label of Spotlight's Top Hit section that `phone_open` looks for, comma-separated — set it to the label your iPhone shows when it is not set to English |
|
|
128
141
|
|
|
129
142
|
## Security
|
|
130
143
|
|
|
@@ -134,13 +147,18 @@ noracu runs with the privileges of your MCP client. It clicks, types, pastes, an
|
|
|
134
147
|
"env": { "NORACU_READ_ONLY": "1", "NORACU_DISABLE_EVAL": "1" }
|
|
135
148
|
```
|
|
136
149
|
|
|
137
|
-
- **`NORACU_READ_ONLY=1`** is the safe first-run mode. It refuses every tool not on
|
|
150
|
+
- **`NORACU_READ_ONLY=1`** is the safe first-run mode. It refuses every tool not on an 18-name allowlist (the observe tools plus standalone `browser_launch`/`browser_navigate`/`browser_close`; `browser_launch` with `cdp_port` is refused even when `NORACU_ALLOW_CDP` is set); every click, type, paste, and eval tool is denied, and so are `mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"`, while `mac_ax_state` and `mac_find` do not toggle `web_accessibility` on apps. `browser_navigate` is on the allowlist, so it can still load a URL.
|
|
138
151
|
- **`NORACU_DISABLE_EVAL=1`** makes `browser_evaluate` return an error when called (it stays listed in `tools/list`). Snapshot, click, and type still work.
|
|
139
152
|
- **`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.)
|
|
140
|
-
- **Focus guard:** pass `app` to `
|
|
141
|
-
- **Stale-element protection:** an `element_index` is not a coordinate. It expires after 30 s
|
|
142
|
-
- **
|
|
143
|
-
- **
|
|
153
|
+
- **Focus guard:** pass `app` to `mac_paste` / `mac_key` (and `mac_type` when it sends keystrokes) and input is refused unless that app is frontmost. Omit `app` and the guard is off. `mac_type`'s default accessibility path writes into a named element or the app's focused element and sends no keystrokes at all; it never falls back to keystrokes when the focus is a button, list or sheet.
|
|
154
|
+
- **Stale-element protection:** an `element_index` is not a coordinate. It expires after 30 s, and on the Mac it is never reused by a later snapshot. A Mac element is re-identified inside the very window or open menu it was seen in (by window ID), at the same place in that window, under the same labelled ancestors and in the same table row; an element without a label or identifier must still be exactly where it was. A browser click re-checks tag/name/href/position. Otherwise `element_no_longer_valid`.
|
|
155
|
+
- **Hit test before physical clicks:** a Mac click or drag that has to use the pointer is sent only when the element at that point is the target — or, when accessibility cannot tell, when the topmost on-screen window there is that same window (by window ID, not covered by another window of the same app); otherwise `occluded`, with what is on top. Keystrokes typed after such a click go out only if the element's app is then frontmost.
|
|
156
|
+
- **Background windows:** semantic Mac actions also work on windows you are not looking at. That is the point (no stolen focus), but it means an agent can act where you do not see it — watch the results' `delivery` and keep high-stakes apps closed.
|
|
157
|
+
- **Guarded keys, menus and quits:** `mac_key` refuses quit / log-out / lock / force-quit / delete-immediately / empty-Trash chords unless `force: true`; `mac_menu_command` applies the same chord list to menu shortcuts and refuses Apple-menu items unless `force: true`. Neither `mac_app` nor `mac_menu_command` ever quits Finder, the Dock, loginwindow, other session processes or the MCP host itself; `force: true` is needed on `mac_app` to force-quit.
|
|
158
|
+
- **DevTools ports are opt-in:** `mac_app` / `browser_launch` with `cdp_port` need `NORACU_ALLOW_CDP=1` (`NORACU_ALLOW_CDP=any` to attach to a port `noracu` did not open itself; always refused under `NORACU_READ_ONLY=1`), bind to 127.0.0.1 only, canonicalize `.app` paths and refuse an app that is already running, and give Chrome-family browsers a separate `0700` profile under `~/.noracu/cdp-profiles`. While the port is open, any local process can control that app (127.0.0.1 has no per-user isolation).
|
|
159
|
+
- **Clipboard, password fields and notifications are private:** `mac_paste` puts the user's clipboard back (every item and type) and never copies an item a password manager marked concealed — it clears the clipboard after the paste instead; `mac_clipboard_read` never returns a concealed item; `mac_set_value` on a secure password field (`AXSecureTextField`) never echoes the value; `mac_notifications` returns notification text verbatim. `mac_clipboard_read`, `mac_notifications`, and `mac_wait` on notifications are outside read-only mode.
|
|
160
|
+
- **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 when the mirror is not live (`mirror_not_live`) or its state cannot be read (`mirror_state_unknown`).
|
|
161
|
+
- **Injection-safe JXA and stdin text:** the accessibility engine (`src/mac-ax.js`) is a static script that takes its whole request as JSON on stdin — parameters are data, never script source — and `mac_type` (default path), `mac_set_value`, `mac_paste`, and `phone_type` / `phone_find` / `phone_open` pass text on stdin so it does not appear in a process list (`imctl type` never echoes it either). Regression-tested.
|
|
144
162
|
|
|
145
163
|
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).
|
|
146
164
|
|
|
@@ -154,7 +172,8 @@ These switches do not make observed content trustworthy. Screenshot text, access
|
|
|
154
172
|
|
|
155
173
|
- Browser: tab management (list / select / close)
|
|
156
174
|
- Act vocabulary (browser): `hover`, `set_value`, `wait_for`
|
|
157
|
-
-
|
|
175
|
+
- Measure the token cost of `skeleton` + `root` drill-down against full snapshots
|
|
176
|
+
- Open Notification Center's history when the menu-bar clock is not exposed to accessibility
|
|
158
177
|
- iPhone: `element_index` over OCR regions, re-checking the text before a tap
|
|
159
178
|
|
|
160
179
|
## Maintenance
|
package/README.zh-CN.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
For English, see [README.md](README.md).
|
|
11
11
|
|
|
12
|
-
一个 stdio MCP server。agent 对界面做一次快照、拿到带索引的元素列表,然后按 `element_index` 点击或输入,而不是用原始像素坐标——Mac 层和 Browser 层是同一套 observe/act
|
|
12
|
+
一个 stdio MCP server。agent 对界面做一次快照、拿到带索引的元素列表,然后按 `element_index` 点击或输入,而不是用原始像素坐标——Mac 层和 Browser 层是同一套 observe/act 协议。实验性的 iPhone 层在 OCR 文本和归一化坐标上跑同一个 observe → act 循环。
|
|
13
13
|
|
|
14
14
|

|
|
15
15
|
|
|
@@ -21,7 +21,7 @@ For English, see [README.md](README.md).
|
|
|
21
21
|
|
|
22
22
|
| 层 | 工具 | 底层 | 状态 |
|
|
23
23
|
|---|---|---|---|
|
|
24
|
-
| **Mac** |
|
|
24
|
+
| **Mac** | 20 个(`mac_*`) | macOS 辅助功能 API(`src/mac-ax.js`,JXA)、cliclick、screencapture | stable |
|
|
25
25
|
| **Browser** | 12 个(`browser_*`) | Playwright(持久化 profile) | stable |
|
|
26
26
|
| **iPhone** | 14 个(`phone_*`) | 经随包附带的 imctl 驱动 iPhone Mirroring(Python + pyobjc) | experimental |
|
|
27
27
|
|
|
@@ -31,14 +31,15 @@ iPhone 层是实验性的,驱动 imctl 随包附带(在 `imctl/`)。它需
|
|
|
31
31
|
|
|
32
32
|
noracu 是本地的"手",不是"脑"。决策由你的 MCP client(Claude Desktop、Claude Code、Cursor)做;本 server 只在这台机器上观察与动作。
|
|
33
33
|
|
|
34
|
-
- **server 完全在本机运行。** 无云服务、无 API key、无遥测、无 postinstall 脚本。唯一运行期依赖是 Playwright。noracu 自身不发任何网络请求;唯一的自动网络行为是首次 `browser_launch` 时一次性下载 Chromium(`NORACU_DISABLE_AUTO_INSTALL=1`
|
|
35
|
-
- **按语义动作,而非像素。** 观察返回 accessibility 树(Mac
|
|
34
|
+
- **server 完全在本机运行。** 无云服务、无 API key、无遥测、无 postinstall 脚本。唯一运行期依赖是 Playwright。noracu 自身不发任何网络请求;唯一的自动网络行为是首次 `browser_launch` 时一次性下载 Chromium(`NORACU_DISABLE_AUTO_INSTALL=1` 可关闭)。设置 `NORACU_ALLOW_CDP=1` 后,它还会访问自己在 127.0.0.1 上打开的 DevTools 端口(连接其他本地回环端口需 `NORACU_ALLOW_CDP=any`)。你让浏览器打开的页面当然会被抓取,你的 MCP client 也仍会把工具结果(截图、OCR 文本)发给它所用的模型。
|
|
35
|
+
- **按语义动作,而非像素。** 观察返回 accessibility 树(Mac 直接经 macOS 辅助功能 API 读取——在我们的测试机上,500 个元素的窗口约 0.15 秒)或 ARIA 树(browser)的带索引列表——是文本,不是截图。动作引用 `element_index`;索引 30 秒后过期。Mac 上每个索引背后都有身份证据(窗口 ID、子节点路径、角色、标识符、名称),每次动作前先重新识别元素;browser 则重校验 tag/name/href/位置。元素已消失或已变化时返回 `element_no_longer_valid`,而不是点错位置。树不够用时才用截图。
|
|
36
|
+
- **如实报告结果。** Mac 动作优先用元素自己的辅助功能动作(按下、选中、设值、插入文本——不移动指针、不抢焦点,文字输入不受输入法影响);只有命中检测确认该点确实落在元素上,才会发送物理点击。每个输入动作(Mac、浏览器和 iPhone)的结果都写明是否送达(观察到变化为 `delivered_verified`,另有 `delivered_unverified`、`not_delivered`,以及超时或中途失败时的 `unknown`)以及能否安全重试;Mac 动作还会列出它打开的 sheet、对话框或菜单。
|
|
36
37
|
- **一个循环,三个面。** Mac 原生应用和持久化 profile 的浏览器共用 `element_index` 协议(观察一棵树、按索引动作)。实验性的 iPhone 层在 Apple 的 iPhone Mirroring 上跑同一个 observe → act 循环,用的是 OCR 文本和归一化坐标——因为手机不向 Mac 暴露 accessibility 树。
|
|
37
38
|
- **用你真实的会话。** 你已登录的浏览器 profile、你的 Mac 应用——不是托管的 VM。与云端 computer-use 相比:两者没有谁普遍更可靠,只是失败方式不同。noracu 把屏幕留在你本机。
|
|
38
39
|
- **真正能关掉的开关。** `NORACU_READ_ONLY=1`(只观察,默认拒绝)、`NORACU_DISABLE_EVAL=1`、以及默认封禁 `file://`。见 [安全](#安全)。
|
|
39
|
-
- **可验证。**
|
|
40
|
+
- **可验证。** 端到端测试(`npm test`;不依赖硬件的部分在 macos-latest 上跑 CI)、MIT 许可;server 由 `src/server.mjs` 和 Mac 辅助功能引擎 `src/mac-ax.js` 组成。
|
|
40
41
|
|
|
41
|
-
**不适合的场景:** 你需要多个浏览器标签页或会话(当前仅单会话)、你不在 macOS 上(Mac 与 iPhone 层仅限 macOS;Browser 层跨平台)、或你现在就需要一个成品级的 iPhone 层(它已随包附带,但仍是实验性——而且 Apple 在欧盟不提供 iPhone Mirroring)。如果你只需要浏览器自动化,playwright-mcp 有 noracu
|
|
42
|
+
**不适合的场景:** 你需要多个浏览器标签页或会话(当前仅单会话)、你不在 macOS 上(Mac 与 iPhone 层仅限 macOS;Browser 层跨平台)、或你现在就需要一个成品级的 iPhone 层(它已随包附带,但仍是实验性——而且 Apple 在欧盟不提供 iPhone Mirroring)。如果你只需要浏览器自动化,playwright-mcp 有 noracu 还没有的 tab 管理和 selector API。如果你要在 Windows 或 Linux 上操作桌面应用,agent-desktop(Vercel Labs)经各系统的辅助功能 API 覆盖 macOS、Windows 和 Linux;noracu 的桌面层只支持 macOS。noracu 的价值在于:一个 agent 通过同一个 server 操作 Mac 应用、浏览器和 iPhone。
|
|
42
43
|
|
|
43
44
|
## 快速开始
|
|
44
45
|
|
|
@@ -48,7 +49,7 @@ noracu 是本地的"手",不是"脑"。决策由你的 MCP client(Claude Des
|
|
|
48
49
|
|
|
49
50
|
```bash
|
|
50
51
|
npm install noracu # server 位于 node_modules/noracu/src/server.mjs
|
|
51
|
-
brew install cliclick # Mac 输入所需(mac_click/
|
|
52
|
+
brew install cliclick # 物理 Mac 输入所需(mac_key、mac_paste、mac_drag 及物理路径的 mac_click/mac_type)
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
或从源码:`git clone https://github.com/sgInnora/noracu.git && cd noracu && npm install && npm test`(加 `NORACU_CI=1` 可跳过依赖硬件的检查)。
|
|
@@ -68,7 +69,7 @@ Claude Desktop(`~/Library/Application Support/Claude/claude_desktop_config.jso
|
|
|
68
69
|
}
|
|
69
70
|
```
|
|
70
71
|
|
|
71
|
-
Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/noracu/src/server.mjs`
|
|
72
|
+
Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/TO/noracu/src/server.mjs`
|
|
72
73
|
|
|
73
74
|
用 `which node` 找到你的 node 路径(Apple Silicon:`/opt/homebrew/bin/node`;Intel:`/usr/local/bin/node`;nvm:对应版本路径)。便捷写法,仅当 Node 已在 GUI `PATH` 上时:`"command": "npx", "args": ["-y", "noracu"]`。
|
|
74
75
|
|
|
@@ -76,21 +77,28 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
|
|
|
76
77
|
|
|
77
78
|
**3. 把 macOS 权限授给宿主应用,而不是 `node`。** 系统设置 → 隐私与安全性 → **辅助功能(Accessibility)** 和 **屏幕录制(Screen Recording)**(macOS 15 为"屏幕与系统音频录制")→ 勾选宿主(Claude Desktop / Cursor / 你的终端)。noracu 不会出现在这里。授权后退出并重开宿主。
|
|
78
79
|
|
|
79
|
-
**4. 验证。**
|
|
80
|
+
**4. 验证。** 先调用 `mac_status`——它会报告宿主是否有辅助功能和屏幕录制权限、能否找到 cliclick。然后让 Finder 在最前,调用 `mac_ax_state`(无参数)——它返回带索引的 accessibility 树;索引有效 30 秒。浏览器冒烟测试(不需要 Accessibility):`browser_launch`(首次运行会下载 Chromium,除非 `NORACU_DISABLE_AUTO_INSTALL=1`)→ `browser_navigate` → `browser_snapshot` → 按索引 `browser_click`。
|
|
80
81
|
|
|
81
82
|
### 排障
|
|
82
83
|
|
|
83
84
|
| 现象 | 原因 / 解决 |
|
|
84
85
|
|---|---|
|
|
85
|
-
| `mac_*`
|
|
86
|
+
| `mac_*` 报 `permission_denied: Accessibility permission is missing…`(0.2 之前为错误 **-1719**) | Accessibility 没授给**宿主**应用——授权后退出并重开宿主;`mac_status` 可查看状态 |
|
|
86
87
|
| 截图全黑 | Screen Recording 没授给宿主——授权后退出并重开 |
|
|
87
88
|
| `ENOENT` 提到 cliclick | `brew install cliclick`(或设 `NORACU_CLICLICK`) |
|
|
88
89
|
| GUI 宿主报 `spawn node` / `npx` `ENOENT` | 配置里改用绝对 `node` 路径——nvm/volta/homebrew 的 shim 不在 GUI `PATH` 上 |
|
|
89
90
|
| 首次 `browser_launch` 卡住 | 一次性 Chromium 下载;或自动安装被关闭(`NORACU_DISABLE_AUTO_INSTALL=1`)→ 执行 `npx playwright install chromium` |
|
|
90
91
|
| `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"
|
|
92
|
-
|
|
|
93
|
-
| `
|
|
92
|
+
| `phone_*` 被拒并报 `mirror_not_live: …`("Connection Paused"、"iPhone in Use"、"not running")或 `mirror_state_unknown: …` | 镜像未运行、已暂停或状态无法读取——锁上 iPhone、放在 Mac 旁,检查 `phone_status`,再调用 `phone_launch`(会启动镜像并点击 Resume) |
|
|
93
|
+
| `phone_launch` 报 `mirror_setup_required` | iPhone Mirroring 正显示设置或欢迎页(例如升级 macOS 后首次启动)——请在 iPhone Mirroring 窗口里自己完成;noracu 从不替你点击这类页面 |
|
|
94
|
+
| `imctl_timeout: phone … did not finish within …s` | Mac 负载过高或系统卡住——操作可能已部分执行,重试前先看 `phone_status` / `phone_screenshot`(`phone_open` 超时后 noracu 会回到主屏幕);在此期间 server 仍会响应其他调用 |
|
|
95
|
+
| `input_busy: …` | 前一个手机或 Mac 操作占用输入队列超过 60 秒(或 `NORACU_PHONE_TIMEOUT_MS` + 15 秒);本次调用什么都没做——重试即可 |
|
|
96
|
+
| 已安装的 App,`phone_open` 却报 app not found | 它只点 Spotlight「Top Hit」卡片里的标签——名字要和手机图标下显示的一致(例如 `拼多多`,而不是 `Pinduoduo`)。已安装却报 "Spotlight showed no Top Hit",通常说明 iPhone 系统语言不是英文:`phone_open` 读的是 Spotlight 的 "Top Hit" 标签——把 `NORACU_TOPHIT_LABELS` 设成手机上显示的标签。报 `open_not_confirmed: … never showed up on the phone` 则是粘贴的名字没有到达手机(粘贴到 iPhone 可能要好几秒)——重试即可。`phone_open` 之后剪贴板里是 App 名字 |
|
|
97
|
+
| 输入的文本被重新空格化(如 "no ra cu") | 文字是以按键方式送出的(`mac_type` 用了 `mechanism: "physical"`,或焦点元素不接受辅助功能写入),同时 CJK 输入法在激活——用 `mac_type` 的默认方式,或用 `mac_paste` |
|
|
98
|
+
| `element_no_longer_valid` | 快照超过 30 秒,或元素已消失、已变化、所在窗口已关闭——重跑 `mac_ax_state` / `browser_snapshot` 并用新索引 |
|
|
99
|
+
| `occluded: … — on top: {…}` | 物理点击会落在别的东西上(另一个窗口、一个 sheet)——把目标窗口置前或关掉遮挡物;本次什么都没发送 |
|
|
100
|
+
| `ambiguous_window: … windows: […]` | 该应用有多个窗口且没有一个处于焦点——传 `window`(序号或标题)或 `mac_windows` 给出的 `window_id` |
|
|
101
|
+
| `policy_denied: "cmd-q" …` | `mac_key` 拒绝退出 / 注销 / 锁屏 / 强制退出 / 立即删除 / 清空废纸篓类组合键,除非传 `force: true`;要退出应用请用 `mac_app` |
|
|
94
102
|
|
|
95
103
|
启动时拒绝 Node 18——请用 Node ≥ 20。Claude Desktop 可能为每个使用面各起一个 noracu 进程;它们共享浏览器 profile,所以同一时间只从一个面启动浏览器。
|
|
96
104
|
|
|
@@ -98,7 +106,7 @@ Claude Code:`claude mcp add noracu -- /绝对路径/TO/node /绝对路径/nora
|
|
|
98
106
|
|
|
99
107
|
## iPhone 层(实验性)
|
|
100
108
|
|
|
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,约
|
|
109
|
+
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,约 3,500 行)随包附带在 `imctl/`。
|
|
102
110
|
|
|
103
111
|
**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
112
|
|
|
@@ -106,25 +114,30 @@ noracu 可以经 Apple 的 **iPhone Mirroring** 操作真实 iPhone。agent 在
|
|
|
106
114
|
|
|
107
115
|
**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
116
|
|
|
109
|
-
**镜像状态:** `phone_status` 返回 `live`(手机画面正在推流)、`overlay`(iPhone Mirroring 显示的替代文字,如 "Connection Paused"、"iPhone in Use"
|
|
117
|
+
**镜像状态:** `phone_status` 返回 `live`(手机画面正在推流)、`overlay`(iPhone Mirroring 显示的替代文字,如 "Connection Paused"、"iPhone in Use")、`paused`(该覆盖层带 Resume 按钮)和 `setup`(需要用户自己完成的设置或欢迎页——noracu 从不点击)。判定依据是窗口结构和形状(镜像窗口是竖长或横长的手机形状,设置页接近正方形),不是文字。镜像不在线时,所有手机输入工具(`phone_tap`、`phone_longpress`、`phone_swipe`、`phone_scroll`、`phone_type`、`phone_key`、`phone_open`、`phone_home` 和 `phone_app_switcher`)都会以 `mirror_not_live` 拒绝——在镜像已暂停或未开启时不会先抢焦点——而不是点到覆盖层上;状态仍无法判定时以 `mirror_state_unknown` 拒绝(`phone_ocr` / `phone_find` 的输出首行会给出警告)。镜像闲置一段时间后会暂停;`phone_launch` 会把它置前并点击 Resume。
|
|
110
118
|
|
|
111
119
|
**隐私:** 手机上显示的一切——通知、短信、邮件、一次性验证码——都会变成工具输出,由你的 MCP client 发给它所用的模型。开始前打开专注模式、打开一个无关紧要的 App,并先用 `NORACU_READ_ONLY=1`(`phone_status`、`phone_screenshot`、`phone_ocr`、`phone_find` 仍可用;所有手机输入都会被拒绝)。iPhone Mirroring 设置好后,iPhone 的通知也会出现在 Mac 上。
|
|
112
120
|
|
|
113
121
|
**首次成功路径:** `phone_status` → 若 `live` 不是 `true` 先 `phone_launch` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`。
|
|
114
122
|
|
|
115
|
-
**已知限制:** 点击落在 OCR
|
|
123
|
+
**已知限制:** 点击落在 OCR 识别到文字的位置,重复或识别错的标签可能点错(若 Spotlight 的「Top Hit」里是同名的联系人或网站,`phone_open` 分辨不出它不是 App);`phone_scroll` 用触控板式的滚动事件移动列表(竖向的 `phone_swipe` 拖拽不会滚动列表——它用于主屏翻页这类手势);在一套实测环境(iPhone 17 Pro Max 运行 iOS 27.0.1,Mac 运行 macOS 26.6.2)上,iPhone Mirroring 在所有 View 尺寸下都把手机画面画得比窗口大约 17%,右列和最底行被裁掉、无法点到;在显示器之间移动窗口、切换主屏、重开 App 都无效,主要怀疑是 iOS 27 与 macOS 26 版本错位——边缘附近点不中时先看 `phone_screenshot`;`phone_open` 把 App 名输入 Spotlight,只有当 Spotlight 的「Top Hit」卡片显示的正是这个名字时才点击(同名的网页建议、网站和设置行一律不点),否则回到主屏——它读的是 Spotlight 的英文 "Top Hit" 标签,iPhone 设为其他语言时找不到任何 App,除非用 `NORACU_TOPHIT_LABELS` 指定那个标签;`phone_home` / `phone_app_switcher` 在镜像在线时走 iPhone Mirroring 菜单(英文 macOS 下无需 python,仅在菜单项不存在时回退 `imctl` 手势,菜单超时返回 `menu_unknown` 而不补发第二次手势),且只报告指令已发送(`screen not verified`)。
|
|
116
124
|
|
|
117
125
|
## 环境变量
|
|
118
126
|
|
|
119
127
|
| 变量 | 默认 | 作用 |
|
|
120
128
|
|---|---|---|
|
|
121
|
-
| `NORACU_READ_ONLY` | 未设 | `=1` 只观察模式:默认拒绝的白名单仅
|
|
129
|
+
| `NORACU_READ_ONLY` | 未设 | `=1` 只观察模式:默认拒绝的白名单仅 18 个观察 + 浏览器生命周期工具;所有 click/type/paste/key/eval 类工具被拒(`mac_clipboard_read`、`mac_notifications` 以及 `condition: "notification"` 的 `mac_wait` 也被拒;`mac_ax_state` / `mac_find` 也不开启 `web_accessibility`) |
|
|
122
130
|
| `NORACU_DISABLE_EVAL` | 未设 | `=1` 让 `browser_evaluate`(任意 JS)被调用时报错(仍在列表中) |
|
|
123
131
|
| `NORACU_ALLOW_FILE_URL` | 未设 | `=1` 允许 `browser_navigate` 打开 `file://` URL(默认封禁) |
|
|
124
132
|
| `NORACU_DISABLE_AUTO_INSTALL` | 未设 | `=1` 跳过首次 `browser_launch` 的 Chromium 自动安装 |
|
|
133
|
+
| `NORACU_ALLOW_CDP` | 未设 | `=1` 允许 `mac_app` 带 `cdp_port` 启动,并允许 `browser_launch` 连接由本 `noracu` 进程打开的 `cdp_port`(需对应 PID 存活且 `webSocketDebuggerUrl` 一致);`=any` 还允许 `browser_launch` 连接 127.0.0.1 上的任意外部 DevTools 端口(在 `NORACU_READ_ONLY=1` 下始终拒绝) |
|
|
134
|
+
| `NORACU_TRACE` | 未设 | 一个文件路径:每次工具调用写一行 JSON(`{ts, tool, args, ms, error, code}`——仅记录参数名与长度及错误码前缀,从不记录参数文本、结果文本或错误详情;以 `0600` 和 `O_NOFOLLOW` 打开,拒绝符号链接) |
|
|
125
135
|
| `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick 二进制路径 |
|
|
126
136
|
| `NORACU_PYTHON` | 自动探测 | 运行随包 iPhone 驱动的 python3;须能导入 pyobjc(Quartz、Vision、AppKit)。未设置时依次尝试 `/opt/homebrew/bin/python3`、`/usr/local/bin/python3`、`python3`、`/usr/bin/python3` |
|
|
127
137
|
| `NORACU_IMCTL_DIR` | 包内 `imctl/` | 覆盖驱动位置(仅开发用) |
|
|
138
|
+
| `NORACU_PHONE_TIMEOUT_MS` | 30000(`phone_open` / `phone_type` 为 45000) | iPhone 层每一步的时限,1000–600000 毫秒;到时该步被终止并返回 `imctl_timeout` |
|
|
139
|
+
| `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | 识别 iPhone 画面的 OCR 语言及优先顺序(逗号分隔的 Vision 语言代码,如 `zh-Hant,en-US` 或 `en-US`;Vision 不支持的代码会被跳过并给出警告) |
|
|
140
|
+
| `NORACU_TOPHIT_LABELS` | `Top Hit` | `phone_open` 要找的 Spotlight「Top Hit」分区标签,逗号分隔——iPhone 不是英文时,设成手机上实际显示的那个标签 |
|
|
128
141
|
|
|
129
142
|
## 安全
|
|
130
143
|
|
|
@@ -134,13 +147,18 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
|
|
|
134
147
|
"env": { "NORACU_READ_ONLY": "1", "NORACU_DISABLE_EVAL": "1" }
|
|
135
148
|
```
|
|
136
149
|
|
|
137
|
-
- **`NORACU_READ_ONLY=1`** 是安全的首次运行模式。它拒绝不在
|
|
150
|
+
- **`NORACU_READ_ONLY=1`** 是安全的首次运行模式。它拒绝不在 18 项白名单内的一切工具(观察类 + 独立的 `browser_launch`/`browser_navigate`/`browser_close`;即使设了 `NORACU_ALLOW_CDP`,带 `cdp_port` 的 `browser_launch` 也会被拒);所有 click/type/paste/eval 被拒,`mac_clipboard_read`、`mac_notifications` 和 `condition: "notification"` 的 `mac_wait` 也被拒,且 `mac_ax_state` 与 `mac_find` 不会在目标应用上开启 `web_accessibility`。`browser_navigate` 在白名单内,仍会加载 URL。
|
|
138
151
|
- **`NORACU_DISABLE_EVAL=1`** 让 `browser_evaluate` 被调用时报错(仍列在 `tools/list` 中)。snapshot、click、type 保留。
|
|
139
152
|
- **`file://` 被拒**,除非 `NORACU_ALLOW_FILE_URL=1`,这样浏览器 agent 无法通过导航到 `~/Documents` 来读本地文件。(仅校验初始导航 URL;重定向不校验——见 SECURITY.md。)
|
|
140
|
-
- **焦点守卫:** 给 `
|
|
141
|
-
- **失效元素保护:** `element_index` 不是坐标。它 30
|
|
142
|
-
-
|
|
143
|
-
-
|
|
153
|
+
- **焦点守卫:** 给 `mac_paste` / `mac_key`(以及以按键方式输入时的 `mac_type`)传 `app`,当该应用不在最前时输入被拒。不传 `app` 则守卫关闭。`mac_type` 默认走辅助功能写入指定元素或该应用的焦点元素,根本不发按键;焦点是按钮、列表或 sheet 时,它也不会退回到发按键。
|
|
154
|
+
- **失效元素保护:** `element_index` 不是坐标。它 30 秒后过期;Mac 上的索引不会被之后的快照复用。Mac 元素只在它被看到的那个窗口或打开的菜单里重新识别(按窗口 ID),并且要在窗口里的同一位置、同样的有名祖先之下、同一表格行中;没有名称也没有标识符的元素必须仍在原处。browser 点击重校验 tag/name/href/位置。否则返回 `element_no_longer_valid`。
|
|
155
|
+
- **物理点击前做命中检测:** 必须用指针的 Mac 点击或拖动,只有该点上的元素就是目标时才发送——辅助功能无法判断时,要求该点最上层的屏幕窗口正是元素所在的同一个窗口(按窗口 ID,未被同一应用的另一个窗口遮挡);否则返回 `occluded` 并说明上面是什么。这样的点击之后再敲的键,只在元素所在应用确实位于前台时才发送。
|
|
156
|
+
- **后台窗口:** 语义 Mac 动作对你没在看的窗口同样有效。这正是目的(不抢焦点),但也意味着 agent 可能在你看不到的地方动作——留意结果里的 `delivery`,高风险应用请先关掉。
|
|
157
|
+
- **危险按键、菜单与退出受保护:** `mac_key` 拒绝退出 / 注销 / 锁屏 / 强制退出 / 立即删除 / 清空废纸篓类组合键,除非 `force: true`;`mac_menu_command` 对菜单快捷键应用同一列表,且拒绝苹果菜单项,除非 `force: true`。`mac_app` 和 `mac_menu_command` 都从不退出 Finder、Dock、loginwindow 等会话进程和 MCP 宿主本身;`mac_app` 强制退出需要 `force: true`。
|
|
158
|
+
- **DevTools 端口需显式开启:** `mac_app` / `browser_launch` 带 `cdp_port` 需要 `NORACU_ALLOW_CDP=1`(连接非 `noracu` 自己打开的端口需 `NORACU_ALLOW_CDP=any`;`NORACU_READ_ONLY=1` 下始终拒绝),只绑定 127.0.0.1,规范化 `.app` 路径并拒绝已在运行的应用,且在 `~/.noracu/cdp-profiles` 下给 Chrome 系浏览器单独的 `0700` profile。端口打开期间,任何本地进程都能控制该应用(127.0.0.1 没有按用户隔离)。
|
|
159
|
+
- **剪贴板、密码框和通知属于隐私:** `mac_paste` 会把用户原来的剪贴板(所有条目和类型)放回去,且从不复制密码管理器标记为隐藏的内容——粘贴后改为清空剪贴板;`mac_clipboard_read` 从不返回隐藏内容;`mac_set_value` 作用于安全密码框(`AXSecureTextField`)时从不回显值;`mac_notifications` 原样返回通知文字。`mac_clipboard_read`、`mac_notifications` 以及等待通知的 `mac_wait` 在只读模式下均被拒绝。
|
|
160
|
+
- **iPhone 画面就是模型输入:** `phone_screenshot` / `phone_ocr` / `phone_find` 会返回手机上显示的一切——通知、短信、一次性验证码。请用专注模式和无关紧要的 App,并先用 `NORACU_READ_ONLY=1`(允许观察手机、拒绝手机输入)。镜像不在线(`mirror_not_live`)或状态无法读取(`mirror_state_unknown`)时,手机输入同样会被拒绝。
|
|
161
|
+
- **防注入 JXA 与 stdin 传参:** 辅助功能引擎(`src/mac-ax.js`)是静态脚本,整条请求以 JSON 从 stdin 传入——参数只是数据,从不成为脚本源码——且 `mac_type`(默认路径)、`mac_set_value`、`mac_paste` 以及 `phone_type` / `phone_find` / `phone_open` 都经 stdin 传入文字,不会出现在进程列表里(`imctl type` 也不回显文字)。有回归测试覆盖。
|
|
144
162
|
|
|
145
163
|
这些开关不会让被观察的内容变得可信。截图文字、accessibility 名称、页面内容都是喂给你模型的**不可信输入**——别让它们覆盖任务指令。完整威胁模型与逐条状态见 [SECURITY.md](SECURITY.md)(英文)。
|
|
146
164
|
|
|
@@ -154,7 +172,8 @@ noracu 以你 MCP client 的权限运行。它会在本机点击、输入、粘
|
|
|
154
172
|
|
|
155
173
|
- Browser:tab 管理(list / select / close)
|
|
156
174
|
- 动作词汇(browser):`hover`、`set_value`、`wait_for`
|
|
157
|
-
-
|
|
175
|
+
- 测量 `skeleton` + `root` 下钻相对完整快照的 token 消耗
|
|
176
|
+
- 菜单栏时钟不对辅助功能可见时,也能打开通知中心的历史列表
|
|
158
177
|
- iPhone:在 OCR 区域上提供 `element_index`,点击前重新校验文字
|
|
159
178
|
|
|
160
179
|
## 维护
|
package/SECURITY.md
CHANGED
|
@@ -8,22 +8,29 @@ Treat every tool call as privileged.
|
|
|
8
8
|
|
|
9
9
|
| # | Threat | Vector | Status | Mitigation / notes |
|
|
10
10
|
|---|---|---|---|---|
|
|
11
|
-
| 1 | **Prompt injection → arbitrary code execution** | Observed content (web page text, AX tree titles, OCR output) contains instructions that trick the agent into calling tools with malicious arguments | **Mitigated
|
|
12
|
-
| 2 | **Arbitrary local control** | `mac_click` / `mac_type` / `mac_paste` can operate password managers, banking pages, terminals | **Inherent** | Use client-side confirmation gates for high-stakes targets; see recommendations below. Optional `app` focus guard on `
|
|
13
|
-
| 3 | **Arbitrary JS in browser** | `browser_evaluate` executes any JavaScript in the page context | **
|
|
14
|
-
| 4 | **Input validation gaps** | Malformed arguments (NaN coordinates, oversized strings, `javascript:` URLs) | **Mitigated** | `validateArgs`
|
|
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; 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
|
|
11
|
+
| 1 | **Prompt injection → arbitrary code execution** | Observed content (web page text, AX tree titles, OCR output) contains instructions that trick the agent into calling tools with malicious arguments | **Mitigated** | The Mac accessibility engine `src/mac-ax.js` is a static script that takes its whole request as JSON on stdin — parameters are data, never script source (regression-tested in `test/e2e.mjs`); the remaining inline JXA (scroll wheel) takes clamped numbers through argv |
|
|
12
|
+
| 2 | **Arbitrary local control** | `mac_click` / `mac_type` / `mac_paste` can operate password managers, banking pages, terminals | **Inherent** | Use client-side confirmation gates for high-stakes targets; see recommendations below. Optional `app` focus guard on `mac_paste` / `mac_key` (and `mac_type` keystrokes) refuses input unless that app — compared by process, not by name — is frontmost; `mac_type` keystrokes after a click on an `element_index` go out only if the element's app is then frontmost. An `element_index` is re-identified inside the window it came from (by CGWindowID) before any action, and a physical click or drag (both ends) is sent only when a hit test shows the point reaches the element, or — when the hit test is inconclusive — when the topmost on-screen window at the point is that same window (by CGWindowID, not covered by another window of the same app; `occluded` otherwise). `mac_key` refuses quit / log-out / lock / force-quit / delete-immediately / empty-Trash chords without `force`; `mac_menu_command` applies the same chord list, refuses Apple-menu items without `force`, and never quits the MCP host or a session process. |
|
|
13
|
+
| 3 | **Arbitrary JS in browser** | `browser_evaluate` executes any JavaScript in the page context | **Partially mitigated** | Set `NORACU_DISABLE_EVAL=1`; `browser_evaluate` then returns an error on every call (it stays listed in `tools/list`) |
|
|
14
|
+
| 4 | **Input validation gaps** | Malformed arguments (NaN coordinates, oversized strings, `javascript:` URLs) | **Mitigated** | `validateArgs` validates every tool's arguments (types, ranges, enums, string lengths, URL schemes) before any subprocess runs; `tools/list` emits `required` arrays derived from non-optional arguments |
|
|
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. `NORACU_READ_ONLY=1` prevents side effects (and skips `enableWebAccessibility` on apps), not screen secrecy: `mac_screenshot` still shows visible notification banners on screen, and Notification Center accessibility reads via `mac_ax_state` / `mac_find` are not blocked by bundle id |
|
|
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; all phone input (including `phone_home` / `phone_app_switcher`, via `require_enabled` on the menu item or `imctl`'s `_require_live`) fails closed with `mirror_not_live` when not live — without stealing focus when paused or closed — or `mirror_state_unknown` when the state cannot be read, checks that iPhone Mirroring is frontmost before synthesized events, and never falls back to a second gesture after an uncertain menu timeout (`menu_unknown`); optional `expect` OCR anchor gates coordinate/key/type actions; "Authenticate automatically" lets anyone at the unlocked Mac start mirroring |
|
|
17
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 |
|
|
18
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` |
|
|
19
|
-
| 8 | **Local file read via browser** | `browser_navigate` to a `file://` URL, then `browser_read` exfiltrates local files | **Mitigated
|
|
19
|
+
| 8 | **Local file read via browser** | `browser_navigate` to a `file://` URL, then `browser_read` exfiltrates local files | **Mitigated** | `file://` blocked at the `browser_navigate` argument unless `NORACU_ALLOW_FILE_URL=1` (initial URL only; redirects fall under threat 9) |
|
|
20
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 |
|
|
21
|
-
| 10 | **Clipboard clobbering by mac_paste** | `mac_paste` overwrites the clipboard with the pasted text | **Partially mitigated** |
|
|
21
|
+
| 10 | **Clipboard clobbering by mac_paste** | `mac_paste` overwrites the clipboard with the pasted text | **Partially mitigated** | One engine call copies every clipboard item and type aside (inside that process), writes the text marked `org.nspasteboard.TransientType`, sends ⌘V only if the clipboard and the frontmost app are unchanged, and puts the user's items back after the paste shows in the same focused element (held at least 0.3 s; else after a 1 s hold) and only if nothing else wrote to the clipboard meanwhile; when the keystroke may not have completed it is not put back. An item marked concealed (on any clipboard item) is never copied: the clipboard is cleared after the paste. Universal Clipboard content and clipboards over 64 MB are refused unless `force`. Remaining: for up to about a second the clipboard holds the pasted text (a clipboard manager that ignores the transient marker can record it); an app that reads the clipboard after the hold receives the restored content; when the app stops answering the pasted text is left on the clipboard |
|
|
22
|
+
| 13 | **Actions on windows the user cannot see** | Semantic Mac actions (press, set value, insert text) work on background windows without moving the pointer or taking focus | **Inherent** | Results report `delivery` and `retry`; review the client's tool log; close high-stakes apps during unattended runs |
|
|
23
|
+
| 14 | **Quitting apps** | `mac_app` quit can close apps; force-quit loses unsaved work | **Mitigated** | Graceful quit by default and verified by the process ending; `force: true` required to force-quit; session processes (Finder, Dock, loginwindow, SystemUIServer, Control Center, Notification Center, …) and the MCP host process are never quit |
|
|
24
|
+
| 15 | **DevTools port exposure** | `mac_app` launch with `cdp_port` opens a Chromium/Electron app's remote-debugging port on `127.0.0.1` (no per-user isolation); any local process can then control that app | **Partially mitigated** | Off unless `NORACU_ALLOW_CDP=1` (or `=any`); `browser_launch` with `cdp_port` is refused under `NORACU_READ_ONLY=1` even with `NORACU_ALLOW_CDP` set; bound to `127.0.0.1`; only for a fresh launch after canonicalizing `.app` paths (`realpath`, trailing slash stripped — a running app is refused, never quit for you); with `NORACU_ALLOW_CDP=1`, `browser_launch` attaches only when the port was recorded by this `noracu` process, its PID is still alive, and `/json/version`'s `webSocketDebuggerUrl` matches (attaching to any other loopback port requires `NORACU_ALLOW_CDP=any`); `~/.noracu` and `cdp-profiles` are created `0700`; Chrome-family browsers get a separate profile under `~/.noracu/cdp-profiles`; standalone `browser_launch` is refused while a CDP session is open; the port closes when the app quits |
|
|
25
|
+
| 16 | **Clipboard and notification content** | `mac_clipboard_read` / `mac_notifications` return clipboard text, images, file paths and notification text to the model | **Partially mitigated** | Items marked `org.nspasteboard.ConcealedType` (password managers) are never returned; `mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"` are refused under `NORACU_READ_ONLY=1` (`NORACU_READ_ONLY=1` prevents side effects, not screen secrecy: `mac_screenshot` still shows visible notification banners and Notification Center AX reads are not blocked by bundle id); notification actions reject empty `id` / `expected_app` / `expected_title`, return `notification_not_found` when absent, and require an id or an index plus a re-checked app/title fingerprint; `mac_set_value` on `AXSecureTextField` never echoes the value |
|
|
26
|
+
| 17 | **Text in process arguments** | Text sent as keystrokes (`mac_type` physical path: `cliclick t:…`) is visible in the process list while it runs | **Partially mitigated** | The accessibility path (`mac_type` default, `mac_set_value`), `mac_paste`, and `phone_type` / `phone_find` / `phone_open` (imctl reads the text from stdin) pass text on stdin, and `mac_set_value` on `AXSecureTextField` and `imctl type` never echo typed text; only the keystroke fallback uses argv. A phone call's `expect` text is still an argument |
|
|
22
27
|
| 11 | **Untrusted observation content** | ARIA snapshots, AX trees, OCR, page text contain attacker-controlled text | **Not mitigated** | The MCP client must treat tool results as data, never as instructions |
|
|
23
28
|
|
|
24
29
|
## Hardening recommendations
|
|
25
30
|
|
|
26
31
|
- Set `NORACU_DISABLE_EVAL=1` unless you actively need `browser_evaluate`.
|
|
32
|
+
- Leave `NORACU_ALLOW_CDP` unset unless you drive an Electron app's web contents; quit the app when done so its DevTools port closes.
|
|
33
|
+
- `NORACU_TRACE` writes only `{ ts, tool, args, ms, error, code }` — argument names and sizes, error code prefix, never argument text, result text, or error messages — and opens the file `0600` with `O_NOFOLLOW` (refusing symlinks).
|
|
27
34
|
- Before an agent touches the iPhone layer: turn on a Focus, open a neutral app,
|
|
28
35
|
and start with `NORACU_READ_ONLY=1`. Prefer "Ask every time" in iPhone
|
|
29
36
|
Mirroring settings unless you need unattended sessions.
|