noracu 0.2.6 → 0.3.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/SECURITY.md CHANGED
@@ -18,7 +18,7 @@ below has the per-tool detail.
18
18
  | macOS privacy-consent prompts and administrator authorization dialogs | A synthesized click or keystroke can be aimed at them like any other window | — | noracu does not recognize these dialogs or refuse input to them, and whether macOS accepts a synthesized click on each of them has not been measured. Keep a person present for any run that may raise one |
19
19
  | Secrets an app displays (Keychain items an app shows, passwords shown in clear, one-time codes) | AX reads, OCR and screenshots read what is on screen | The model provider | Reading is not blocked. `mac_set_value` never echoes a value in a secure text field, and concealed clipboard items are never returned (threat 16) |
20
20
  | Browser cookies | The browser layer keeps one persistent Playwright profile at `~/.noracu/browser-profile` | Every site the browser opens; page text goes to the model | Not isolated between runs; clear the profile between untrusted runs |
21
- | iPhone Mirroring session | Phone tools see and act through the iPhone Mirroring window | The model sees the phone screen, including notifications, messages and codes | Biometric authentication requests fail during iPhone Mirroring by default (Apple TN3210), but a Mac set to authenticate automatically gives anyone at the unlocked Mac the phone (threats 6, 12). Input reaches iOS as indirect pointer events, not touches (TN3210), so a touch-only system gesture such as swiping in from the left edge to go back does nothing through the mirror — that is the mirror's behaviour, not a noracu fault |
21
+ | iPhone Mirroring session | Phone tools see and act through the iPhone Mirroring window | The model sees the phone screen, including notifications, messages and codes | Biometric authentication requests fail during iPhone Mirroring by default (Apple TN3210), but a Mac set to authenticate automatically gives anyone at the unlocked Mac the phone (threats 6, 12). Input reaches iOS as indirect pointer events, not touches (TN3210), so a touch-only system gesture such as swiping in from the left edge to go back does nothing through the mirror — that is the mirror's behaviour, not a noracu fault. Apps on the phone see each capture of the mirror window as a screenshot (threat 21) |
22
22
 
23
23
  Boundaries:
24
24
 
@@ -31,10 +31,18 @@ Boundaries:
31
31
  keeps no such list.
32
32
  - Tool annotations (`readOnlyHint`, `destructiveHint`, `idempotentHint`,
33
33
  `openWorldHint`) are hints for the client and restrict nothing.
34
- `NORACU_READ_ONLY=1`, `NORACU_DISABLE_EVAL=1` and the opt-in `NORACU_ALLOW_*`
35
- variables are what the server enforces.
36
- - No telemetry and no network use at run time, except the one-time Playwright
37
- Chromium download, which `NORACU_DISABLE_AUTO_INSTALL=1` turns off.
34
+ `NORACU_READ_ONLY=1`, `NORACU_DISABLE_EVAL=1` and the opt-in `NORACU_ENABLE_EVAL`
35
+ and `NORACU_ALLOW_*` variables are what the server enforces.
36
+ - No telemetry. noracu itself makes no internet connection at run time except
37
+ the one-time Playwright Chromium download, which
38
+ `NORACU_DISABLE_AUTO_INSTALL=1` turns off. The browser layer's Chromium is a
39
+ browser: the pages it is told to open, and the scripts they run (and
40
+ `browser_evaluate`'s, when eval is on), connect wherever they ask, as in any
41
+ browser. The XCUITest backend (opt-in) adds one more channel off the Mac: the
42
+ CoreDevice tunnel between the Mac and a paired iPhone. The runner on the
43
+ iPhone listens only on the tunnel's own address — a unique-local address
44
+ (fc00::/7), or `::1` when CoreDevice reports the tunnel that way; a
45
+ simulator's runner listens on `127.0.0.1` on the Mac itself.
38
46
 
39
47
  ## Threat model
40
48
 
@@ -42,26 +50,38 @@ Boundaries:
42
50
  |---|---|---|---|---|
43
51
  | 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 |
44
52
  | 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). Right before a physical click or drag is sent, the window on top at each point is checked again (by CGWindowID); afterwards a physical click counts as `delivered_verified` only if the element is still there, changed, and its own window is still on top at the click point. An element read with `surface: "app"` is bound to its window's CGWindowID, and an element in a window without a CGWindowID (other than Finder's desktop) is refused with `policy_denied`. A `mac_click` at raw x,y is sent only when the topmost on-screen window at the point belongs to `app` (default: the frontmost app; the menu bar counts as the frontmost app's, and the strip a display keeps for the Dock counts as the Dock's; Notification Center's full-display overlay counts only over a banner or alert it draws, or everywhere when their frames cannot be read), unless `force: true`; a short gap remains between that check and the click. `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. |
45
- | 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`) |
53
+ | 3 | **Arbitrary JS in browser** | `browser_evaluate` executes any JavaScript in the page context | **Partially mitigated** | Off by default: `browser_evaluate` returns `eval_disabled` unless the server was started with `NORACU_ENABLE_EVAL=1`, and `NORACU_DISABLE_EVAL=1` keeps it off even then (it stays listed in `tools/list`). Once it is turned on, any script runs in the page |
46
54
  | 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 |
47
55
  | 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 |
48
56
  | 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 |
49
- | 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 |
57
+ | 12 | **Phone screen as model input** | `phone_screenshot` / `phone_ocr` / `phone_find` — and, under the XCUITest backend, `ios_screenshot` / `ios_snapshot` — 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 |
50
58
  | 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` |
51
- | 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) |
59
+ | 8 | **Local file read via browser** | `browser_navigate` to a `file://` URL, then `browser_read` exfiltrates local files; or a tab that someone opened on a local file becomes the active page | **Partially mitigated** | `file://` blocked at the `browser_navigate` argument and at the `url` of `browser_tabs` `new` unless `NORACU_ALLOW_FILE_URL=1` (initial URL only; redirects fall under threat 9). A tab becomes the active page — through `browser_tabs` `select`, or by taking over when the active tab closes — only when it shows an http(s) page, or is still on the blank page that `browser_launch` or `browser_tabs` opened it on (a blank page a tab shows after it has loaded anything else does not count: one reached from a local file still loads other local files into frames, where a screenshot shows them). The session's first tab is Chromium's own, so it is not taken on trust: when it starts on a blank page noracu sends it to `about:blank` itself, checks that a new document is there, and empties `window.name` before it counts (measured: after that navigation a blank page that a local file went to no longer loads local files and the old document is gone; the name survives it), and any navigation the tab reports afterwards ends that — also one back to an earlier blank page in its history (measured: `history.back()` to a blank page that a local file had reached loads local files again). A first tab that starts on anything else is held to the rule like any other tab. A tab restored at launch was looked for and not seen: a headed Chromium started the way noracu starts it, on a profile set to continue where it left off whose last session had a blank tab that a local file had gone to, came back with one fresh blank tab (two runs); the checks above do not rely on that. The tab that already is the active page is held to the same rule each time a page tool is called: once it shows anything else — a blob the page made, Chromium's page for a load that failed, a blank page after another page, a local file someone opened in that tab — the page tools return `active_page_not_allowed`, and only `browser_navigate` (which reads nothing of the page it leaves) and `browser_tabs` act. A tab on a local file, a browser page or a blob, and a blank tab that a page opened (it shares that page's origin and can read it), are listed with their url and title and nothing else of them is read: `tab_not_selectable`, and `no_active_page` from the page tools when no other tab is open. What a tab shows is looked at when a call starts, by the address the browser reports for it then; while a navigation is being committed that is still the old address for a moment (measured after a load that failed: calls sent with no pause got past this check every time). So the tools that return page content — `browser_read`, `browser_snapshot`, `browser_screenshot`, `browser_evaluate` — look again once they have their result, or an error, and drop it when the page no longer passes — or when the tab went through a page that does not pass while they worked and is back on one that does (measured: 60 calls in that moment, none handed over the arriving page; this rests on the browser reporting a navigation before it answers from the new page). The input tools are checked at the start only: in that moment input can reach the page that is arriving. A page cannot take itself to a local file or a browser page (Chromium refuses that), and the browser tools' own keystrokes go to the page, never to the address bar (measured in a headed Chromium), so the arriving page is a local file only when one is opened in the active tab from outside the browser tools — by hand, or by Mac-layer input. Remaining: input that reaches an arriving page in that moment (a click or fill by selector also tells whether the selector exists there). Outside this row: a session attached to an app with `cdp_port` (threat 15), which uses that app's own pages whatever they show; and the Mac layer when it is on — its input can type an address into a headed browser's address bar, and `mac_screenshot` shows the browser's window like any other (threats 2 and 5) |
52
60
  | 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 |
53
61
  | 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 |
54
62
  | 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 |
55
63
  | 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 |
56
- | 15 | **DevTools port exposure** | `mac_app` launch with `cdp_port` opens a Chromium/Electron app's remote-debugging port on `127.0.0.1` (no per-user isolation); any local process can then control that app | **Partially mitigated** | Off unless `NORACU_ALLOW_CDP=1` (or `=any`); `browser_launch` with `cdp_port` is refused under `NORACU_READ_ONLY=1` even with `NORACU_ALLOW_CDP` set; bound to `127.0.0.1`; only for a fresh launch after canonicalizing `.app` paths (`realpath`, trailing slash stripped — a running app is refused, never quit for you); with `NORACU_ALLOW_CDP=1`, `browser_launch` attaches only when the port was recorded by this `noracu` process, its PID is still alive, and `/json/version`'s `webSocketDebuggerUrl` matches (attaching to any other loopback port requires `NORACU_ALLOW_CDP=any`); `~/.noracu` and `cdp-profiles` are created `0700`; Chrome-family browsers get a separate profile under `~/.noracu/cdp-profiles`; standalone `browser_launch` is refused while a CDP session is open; the port closes when the app quits |
64
+ | 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); the app rules (`NORACU_DENY_APPS`, the approval file) decide before the launch, by the bundle id read from the app on disk, so an app they rule out is not given a port; with `NORACU_ALLOW_CDP=1`, `browser_launch` attaches only when the port was recorded by this `noracu` process, its PID is still alive, and `/json/version`'s `webSocketDebuggerUrl` matches (attaching to any other loopback port requires `NORACU_ALLOW_CDP=any`); `~/.noracu` and `cdp-profiles` are created `0700`; Chrome-family browsers get a separate profile under `~/.noracu/cdp-profiles`; standalone `browser_launch` is refused while a CDP session is open; the port closes when the app quits |
57
65
  | 16 | **Clipboard and notification content** | `mac_clipboard_read` / `mac_notifications` return clipboard text, images, file paths and notification text to the model | **Partially mitigated** | Items marked `org.nspasteboard.ConcealedType` (password managers) are never returned; `mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"` are refused under `NORACU_READ_ONLY=1` (`NORACU_READ_ONLY=1` prevents side effects, not screen secrecy: `mac_screenshot` still shows visible notification banners and Notification Center AX reads are not blocked by bundle id); notification actions reject empty `id` / `expected_app` / `expected_title`, return `notification_not_found` when absent, and require an id or an index plus a re-checked app/title fingerprint; `mac_set_value` on `AXSecureTextField` never echoes the value. Remaining: `mac_clipboard_read` on Universal Clipboard content (copied on another device) makes macOS fetch it from that device; the result marks it `remote: true` |
58
66
  | 17 | **Text in process arguments** | Text sent as keystrokes (`mac_type` physical path: `cliclick t:…`) is visible in the process list while it runs | **Partially mitigated** | The accessibility path (`mac_type` default, `mac_set_value`), `mac_paste`, and `phone_type` / `phone_find` / `phone_open` (imctl reads the text from stdin) pass text on stdin, and `mac_set_value` on `AXSecureTextField` and `imctl type` never echo typed text; only the keystroke fallback uses argv. A phone call's `expect` text is still an argument |
59
- | 18 | **Clipboard on the phone path** | `phone_type` / `phone_open` paste through the Mac clipboard; iPhone Mirroring fetches the paste asynchronously, sometimes more than 10 s after ⌘V, from whatever the clipboard holds then, so putting the user's clipboard back too early could paste it into the phone | **Partially mitigated** | `phone_type` copies every clipboard item aside and puts them back only on screen evidence read within its 2.5 s check while no "Pasting from" progress box shows: OCR sees the text at a new spot below the status-bar strip in two reads. A text of one to three characters (spaces and case aside) never licenses it, and neither does a paste seen only later. An item marked concealed or transient is never copied (the clipboard is cleared instead). Without that evidence the typed text stays on the clipboard and the result says so. An error before ⌘V is sent restores the clipboard; an error once ⌘V may be on its way never does. `phone_open` never restores it. Remaining: the user's previous clipboard is lost whenever the evidence is missing; Universal Clipboard content and clipboards over 64 MB are not copied, so they are replaced by the typed text |
67
+ | 18 | **Clipboard on the phone path** | `phone_type` / `phone_open` paste through the Mac clipboard; iPhone Mirroring fetches the paste asynchronously, sometimes more than 10 s after ⌘V, from whatever the clipboard holds then, so putting the user's clipboard back too early could paste it into the phone | **Partially mitigated** | `phone_type` and `phone_open` wait at least 1.5 s after writing the clipboard before ⌘V, and call ⌘V off (`focus_lost`) rather than bring iPhone Mirroring back if another app came to the front meanwhile. `phone_type` copies every clipboard item aside and puts them back only on screen evidence read within its 2.5 s check while no "Pasting from" progress box shows: OCR sees the text at a new spot below the status-bar strip in two reads, counted against a read taken right before ⌘V. A text of one to three characters (spaces and case aside) never licenses it, and neither does a paste seen only later. An item marked concealed or transient is never copied (the clipboard is cleared instead). Without that evidence the typed text stays on the clipboard and the result says so. An error before ⌘V is sent restores the clipboard; an error once ⌘V may be on its way never does. `phone_open` never restores it once ⌘V may have been sent (before ⌘V — an error, or `focus_lost` — it goes back under the same rule). Remaining: the user's previous clipboard is lost whenever the evidence is missing; Universal Clipboard content and clipboards over 64 MB are not copied, so they are replaced by the typed text; a ⌘V that reaches the phone before Universal Clipboard has announced the new text can paste the phone's own older clipboard instead — possibly something once pasted on the phone, such as a password — and the wait — 1.5 s, a judgement rather than a measured delay — is meant to let the new text reach the phone first but does not close that window; the OCR evidence matches the typed text inside a line, so an older clipboard that contains the typed text can pass for the paste; the "Pasting from" box is recognized only in English |
68
+ | 19 | **Input the person at the Mac cannot see** | Background input (bgpost, 0.3.0) posts physical clicks and named keys straight to an app's process: the pointer does not move and the app need not be in front | **Partially mitigated** | Input still waits for the person at the Mac (`user_active`); `NORACU_STOP_FILE` stops all Mac and iPhone input at once, and the browser tools that act on a page (`browser_click`, `browser_type`, `browser_fill`, `browser_press_key`, `browser_scroll`, `browser_navigate`, `browser_evaluate`, and `browser_tabs` new / close — not `browser_launch` or the reading tools); the deny list (by default the common terminal apps and IDEs with a built-in terminal) and the opt-in approval file are judged on the app that receives the input, and an app that cannot be identified gets nothing; web-engine apps and `mechanism: "physical"` use the real pointer; `NORACU_NO_BGPOST=1` turns background input off. Results carry `route`. Watching the client's tool log is still the only way to see every action |
69
+ | 20 | **Approval, deny and stop settings changed by the agent** | An agent with a shell or file tool (the MCP host's, not noracu's) edits `NORACU_APPROVAL_FILE` or deletes the stop file | **Partially mitigated** | noracu never writes these files and reads them at every call; once `NORACU_APPROVAL_FILE` is set, the file must exist, be a plain file (not a symlink), mode `0600`, owned by the user running noracu and hold only `allow` / `ask` / `deny` with non-empty patterns, else all Mac and iPhone input is refused (app rules do not judge the browser layer; the stop file stops it). Anything running as you can still edit them — they stop the model through noracu's tools, not other software or a host shell tool you allowed (see "What noracu hands to your model" above) |
70
+ | 21 | **Looking at the phone is visible to its apps** | A capture of the iPhone Mirroring window reaches the app on the phone as a screenshot: in a device run (iPhone 17 Pro Max on iOS 27, Mac on macOS 27.2) LinkedIn and rednote each showed their after-screenshot share sheet 1–4 s after every capture, one more per capture. Captures are made by `phone_screenshot` / `phone_ocr` / `phone_find`, any `expect` check, the checks inside `phone_type` / `phone_open` / `phone_scroll`, and a phone input that first has to bring iPhone Mirroring to the front | **Inherent** | noracu cannot read the mirror without capturing it. It captures no more than a tool needs: where the phone screen sits inside the window is measured once per window size and macOS version and remembered in `~/Library/Caches/noracu/phone-screen-rect.json` (window size, macOS version, four edges, two timestamps — nothing from the phone), so once the edges are remembered `phone_tap`, `phone_longpress` and `phone_swipe` without `expect` add no capture of their own — except when iPhone Mirroring first has to be brought to the front, which is one of the captures listed above. Not tested: apps that log screenshots or tell the other person in a chat about them — assume they do so on every capture, and keep such apps off the screen while an agent observes |
71
+ | 22 | **A listener on the iPhone (XCUITest backend)** | The runner on the phone takes commands over TCP; whoever can reach it and knows its token can read and drive the phone | **Partially mitigated** | Off unless `NORACU_PHONE_BACKEND=xcuitest`. The runner binds only the device's own CoreDevice tunnel address — a unique-local (`fc00::/7`) address, or `::1` when CoreDevice reports the tunnel as loopback (a simulator's runner binds `127.0.0.1`); any other address is refused before the runner starts — measured on an iPhone 16 Pro: the same port on the phone's Wi-Fi address refuses connections — accepts only peers in the tunnel's /64, and requires a 128-bit token made new at every start, compared in constant time; a wrong token or a request line over 64 KiB closes the connection. The token travels in the environment of `xcodebuild`, never in arguments, results or the trace file — but another process of the same macOS user can read that environment and reach the tunnel while the runner is up, so do not run software you do not trust in the account that runs noracu. The server stops `xcodebuild` (and with it the runner) when it exits |
72
+ | 23 | **iPhone input through XCUITest** | `ios_tap` / `ios_type` / `ios_swipe` / `ios_key` act in any app of an unlocked iPhone, payment and messaging apps included; a raw x,y tap or a swipe has no element re-check | **Inherent** | Opt-in backend; `NORACU_READ_ONLY=1` refuses all `ios_*` input; `NORACU_STOP_FILE`, `NORACU_DENY_APPS` and `NORACU_APPROVAL_FILE` are checked before every input, on the iOS bundle id — an approval file that allows only the apps you mean is the tightest setting; a locked iPhone, or one whose lock state cannot be read, gets nothing — the lock is read when a call starts and again before any command sent more than 1 s after the last unlocked answer, so a phone locked within that second is not caught (a lock during a running call has not been tried on a device); no input goes to an app while a system alert is up on the phone (`system_alert`); an `element_index` is re-read before it is used. Use a spare iPhone for unattended runs |
73
+ | 24 | **A stale picture of what is in front** | For about a second after an app leaves the front (measured after a Home press), iOS still reports it as in front; an index or a point used in that moment could land on another screen | **Partially mitigated** | `ios_home` and `ios_launch` end every earlier index and wait for the change to show; before an index is used the app is read again and the element must match in type, label, identifier and frame; the runner refuses input for an app that is not in front. What remains is that second after someone presses Home on the phone itself |
74
+ | 25 | **An unlocked iPhone** | The XCUITest backend works only while the iPhone is unlocked, and unattended use means turning auto-lock off | **Inherent** | Physical access to the phone is then access to everything on it. Use a spare device without your main accounts, and keep it where you can see it |
75
+ | 26 | **Signing the runner** | `noracu ios-setup` builds and signs the runner with your Apple developer team: Xcode contacts Apple's developer service and may create a development provisioning profile and an app identifier in the team; `--register-device` adds the iPhone to the team's devices | **Inherent** | Only when you run that command — never on install, never while the MCP server runs. A simulator build is not signed and contacts nothing |
76
+ | 27 | **The Home Screen as a way around app rules (XCUITest backend)** | Input that names `com.apple.springboard` is sent by screen coordinates and lands on whatever is in front — SpringBoard reads as "in front" under every app (measured on an iOS 26.5 simulator) — so a rule that allows it would let a tap reach an app the rules do not allow | **Mitigated** | While `NORACU_APPROVAL_FILE` or a `NORACU_DENY_APPS` of your own is set, no input that names `com.apple.springboard` is sent — not even one tap on a button of a system prompt: taps, long presses, drags, text and keys return `input_denied` before a runner is started, and nothing reaches the phone. Apps are opened with `ios_launch`, which asks the rules; `ios_home` still goes out. The cost: under app rules the agent cannot answer a system prompt (a permission dialog) — the person at the phone does. With no rules set, such input is sent as asked and reaches the app in front |
77
+ | 28 | **Working in the person's own Chrome** | `browser_launch` with `chrome: true` attaches to the Chrome the person uses, through Chrome's remote-debugging switch; the tabs noracu opens there carry the person's sign-ins, so an agent working in them acts as the person on those sites, and while the switch is on any local program can ask Chrome for a connection | **Partially mitigated** | Off unless `NORACU_ALLOW_CHROME=1`; refused under `NORACU_READ_ONLY=1`; it needs Chrome's own switch (`chrome://inspect/#remote-debugging`, off by default), and Chrome asks the person to allow each connection and shows a banner while one is open (since Chrome 136 `--remote-debugging-port` is ignored for the default profile). noracu opens a window of its own in the background and lists, reads and acts only on the tabs it opened there and tabs those tabs open; noracu never lists, reads or acts on the person's other tabs unless the person also sets `NORACU_CHROME_TABS=all` (then the person's http(s) tabs are listed and can be selected, read and acted on, never closed or sent to a non-http(s) address, and become the active page only when selected and stop being it when they leave http(s); `file://`, `chrome://` and the like are not listed, whatever `NORACU_ALLOW_FILE_URL` says), and in noracu's own tabs the address rules apply (http(s) only; `file://` only with `NORACU_ALLOW_FILE_URL=1`; `chrome://` and the like never). `browser_evaluate` never runs in a `chrome: true` session. `browser_close` closes noracu's tabs and disconnects (it keeps the session while one of them is still open or the disconnect is unconfirmed); noracu never quits Chrome. Remaining: whatever an agent does in those tabs is done as the person (posting, buying, changing settings on a site), and a page loaded there can do what any page in the person's Chrome can, and with `NORACU_CHROME_TABS=all` that includes every signed-in site the person has open (mail, banking, admin consoles); the switch, once turned on, stays on until the person turns it off, and connections from other programs are only as safe as the person's answer to Chrome's dialog |
60
78
  | 11 | **Untrusted observation content** | ARIA snapshots, AX trees, OCR, page text contain attacker-controlled text | **Not mitigated** | The MCP client must treat tool results as data, never as instructions |
61
79
 
62
80
  ## Hardening recommendations
63
81
 
64
- - Set `NORACU_DISABLE_EVAL=1` unless you actively need `browser_evaluate`.
82
+ - Leave `NORACU_ENABLE_EVAL` unset unless you actively need `browser_evaluate`; `NORACU_DISABLE_EVAL=1` keeps it off whatever else is set.
83
+ - Set `NORACU_STOP_FILE` to a path you can `touch` in one step (a shell alias, a Shortcut) so you can stop all Mac and iPhone input, and the browser tools that act on a page, at once (`browser_launch` and the reading tools are not stopped); delete the file to resume.
84
+ - For unattended runs, set `NORACU_APPROVAL_FILE` and list only the apps the task needs under `allow`.
65
85
  - Leave `NORACU_ALLOW_CDP` unset unless you drive an Electron app's web contents; quit the app when done so its DevTools port closes.
66
86
  - `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).
67
87
  - Before an agent touches the iPhone layer: turn on a Focus, open a neutral app,
@@ -44,28 +44,39 @@ Accessibility goes through `src/mac-ax.js`, a static JXA script run as `osascrip
44
44
 
45
45
  `mac_key` / `mac_paste` (and `mac_type` when it sends keystrokes) accept an optional `app`: when set, the tool verifies that app is frontmost before synthesizing input and returns `focus_lost` (sending nothing) if it is not.
46
46
 
47
- ### Browser layer (12 tools)
47
+ ### Browser layer (13 tools)
48
48
 
49
49
  A single persistent Playwright 1.58 session (one browser, one context), held in a `Map` keyed by `browser_id` that carries one active entry at a time:
50
50
 
51
51
  - Session: `browser_launch` (headless optional) → `browser_navigate` → `browser_close`; `browser_snapshot` accepts an optional `browser_id`, but only one session is live at a time (true multi-session `browser_id` + `tab_id` is a roadmap item)
52
+ - Tabs: `browser_tabs` lists the session's tabs and opens, selects or closes one by `tab_id`. The active page changes only when asked — a tab the page itself opens is listed, never followed — and only a tab `browser_tabs` opened can be closed with it, never the last one. A tab becomes the active page — through `select`, or by taking over when the active tab closes — only when it shows an http(s) page, or is still on the blank page that `browser_launch` or `browser_tabs` opened it on (`file://` with `NORACU_ALLOW_FILE_URL=1`); with no such tab open the page tools return `no_active_page`. The active page is held to the same rule each time a page tool is called: once it shows anything else (a blob the page made, a load that failed, a blank page after another page), the tools return `active_page_not_allowed` (those that return page content look again before handing it over, and `browser_snapshot` — and `browser_read` without a selector — return `page_changed` when the page navigated while they worked), the tab stays the active page, and `browser_navigate` or `browser_tabs` moves on from there. A session attached with `cdp_port` uses the app's own pages, whatever they show.
52
53
  - Observe: `browser_snapshot` (`page.ariaSnapshot()` ARIA tree YAML + list of interactive element indices), `browser_screenshot` (fullPage / format png|jpeg / quality / clip; returns DPR + viewport metadata)
53
54
  - Act: `browser_click` (element_index / selector / xy; element_index clicks run a tag/name/href/position TOCTOU check first), `browser_fill`, `browser_press_key`, `browser_type`, `browser_scroll`, `browser_evaluate`
54
55
  - Read: `browser_read` (page text, optional selector)
55
56
 
56
57
  ### iPhone layer (14 tools)
57
58
 
58
- 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 on English macOS while the mirror is live; non-English macOS falls back to `imctl`).
59
+ 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. imctl remembers where the phone screen sits inside the mirror window (one entry per window size and macOS version) in `~/Library/Caches/noracu/phone-screen-rect.json`, so that taps and swipes need no capture of the window to stay off its margin. **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 on English macOS while the mirror is live; non-English macOS falls back to `imctl`).
59
60
 
60
61
  - Observe: `phone_ocr` (coordinates + text), `phone_screenshot` (captures the Mirroring window by CGWindow id, so a covered window still yields its own pixels; never a screen-region capture — `capture_failed` instead), `phone_find` (locates text; text passed on stdin)
61
62
  - Act: `phone_tap/longpress/swipe` (normalized 0-1 coordinates), `phone_home` / `phone_app_switcher` (iPhone Mirroring menu by bundle id first, imctl gesture fallback when the English menu item is absent), `phone_scroll`, `phone_type` (clipboard-based via stdin, IME-safe, never echoes typed text), `phone_key`
62
63
  - Session: `phone_status` (running, window, window_id, onscreen, frontmost, live, overlay, paused, setup — read from the window's AX structure and shape: a live mirror is one empty AXHostingView group; an overlay such as "Connection Paused" or "iPhone in Use" adds static text and a button; a setup screen sits in a nearly square window), `phone_launch` (ensure running + frontmost, clicks the single Resume button of a paused overlay, refuses setup screens with `mirror_setup_required`), `phone_open` (Spotlight via the iPhone Mirroring shortcut, paste the name via stdin, tap only an exact OCR label inside Spotlight's "Top Hit" card, reading `NORACU_TOPHIT_LABELS`; otherwise back to the Home Screen)
63
64
  - Safety: while the mirror is not live or its state cannot be confirmed, every phone input tool (`phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key`, `phone_open`, `phone_home`, `phone_app_switcher`, plus CLI `imctl page`) fails closed with `mirror_not_live` or `mirror_state_unknown` without stealing focus when paused or closed; `phone_ocr` / `phone_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 (optional `expect` checks pre-action OCR text).
64
65
 
66
+ ### iPhone layer, XCUITest backend (9 tools, opt-in)
67
+
68
+ `NORACU_PHONE_BACKEND=xcuitest` lists the `ios_*` tools instead of `phone_*` (both groups are defined in one table; only the chosen one is offered). Three files:
69
+
70
+ - `ios-runner/` — the runner: one UI-test bundle (Swift, no host app) whose single test, `testServe`, listens on the address it is given and executes one JSON command per line on the main thread ([protocol](ios-runner-protocol.md)). It never launches apps, never touches the clipboard, and makes no outbound connection.
71
+ - `src/ios-xcuitest.js` — the Mac-side client: `devicectl` (read through `--json-output` files) for the device list, the lock state and app launches, `simctl` for launches on a simulator, `xcodebuild test-without-building` to start the runner, and one TCP connection with a hard time limit per call. A call that timed out is never re-sent.
72
+ - `src/ios-session.js` — the tools: device choice, starting the runner on the first call that needs it, `element_index` (30 s, ended by `ios_home` / `ios_launch`, re-read before use), the gates before every input (app rule on the bundle id, a running runner, the lock), and the read-back that decides whether `ios_type` is verified.
73
+
74
+ `src/ios-setup.js` is the `noracu ios-setup` command (`xcodebuild build-for-testing` into `~/.noracu/ios-runner/<udid>`). `ios_*` calls share the input queue with the Mac and Mirroring tools (the runner takes one command at a time); their input checks the stop file but does not wait for the person at the Mac. Tests replace Apple's tools through `NORACU_IOS_XCRUN` and `NORACU_IOS_XCODEBUILD` (`test/fixtures/`: a fake `xcrun`, and a fake `xcodebuild` that serves a model phone); `test/ios-live.mjs` runs the tools against a real iPhone or simulator.
75
+
65
76
  ## Concurrency and lifecycle
66
77
 
67
78
  - **Child processes.** Every subprocess (the accessibility engine, imctl, cliclick, screencapture, `open`, `ps`, the Chromium installer) runs asynchronously under its own timer and in its own process group; on expiry the group gets SIGTERM, then SIGKILL after 1.5 s. Nothing blocks the event loop, so `ping` and `tools/list` are answered while a call runs.
68
- - **Input queue.** `phone_*` and Mac input tools go through one FIFO queue (they share the real mouse, keyboard, clipboard and windows). A queued call that the client cancelled, or that waited longer than 60 s (or `NORACU_PHONE_TIMEOUT_MS` + 15 s), is dropped without acting (`input_busy`). `mac_clipboard_read`, `mac_notifications` and every `phone_*` tool (reads included: they capture the mirroring window) stay in the queue.
79
+ - **Input queue.** `phone_*` and Mac input tools go through one FIFO queue (they share the real mouse, keyboard, clipboard and windows). A queued call that the client cancelled, or that waited longer than 60 s (or `NORACU_PHONE_TIMEOUT_MS` + 15 s), is dropped without acting (`input_busy`). When a call leaves the queue, an input tool is refused first if `NORACU_STOP_FILE` exists (`user_stopped`), then if the person at the Mac used the keyboard or mouse in the last `NORACU_USER_IDLE_S` seconds (`user_active`); the deny list and approval file are checked inside each tool, on the app that receives the input. `mac_clipboard_read`, `mac_notifications` and every `phone_*` tool (reads included: they capture the mirroring window) stay in the queue.
69
80
  - **Observations.** `mac_ax_state`, `mac_find`, `mac_get`, `mac_windows`, `mac_apps`, `mac_screenshot`, `mac_status` and `mac_wait` do not join the queue: each waits for the inputs queued before it to finish (or returns `input_busy` past the queue limit), then runs, so it sees their effect and later inputs are not held up behind it.
70
81
  - **Shutdown.** When the client closes stdin, or on SIGTERM / SIGINT / SIGHUP: no new calls, queued calls are dropped, no new child process starts, children get SIGTERM then SIGKILL, browsers (also one still starting) are closed (a CDP attachment only disconnects), and the process exits within 3 s.
71
82
 
@@ -77,14 +88,22 @@ The bundled imctl driver (`imctl/`, Python) runs as a subprocess (`<python3> -m
77
88
  | `NORACU_IMCTL_DIR` | bundled `imctl/` (`src/../imctl`) | override the driver location (development only) |
78
89
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | path to cliclick |
79
90
  | `NORACU_READ_ONLY` | unset (full control) | `=1` observation-only mode: a default-deny allowlist of 18 tools — the observe tools (`mac_screenshot`, `mac_ax_state`, `mac_find`, `mac_get`, `mac_status`, `mac_apps`, `mac_windows`, `mac_wait` except `condition: "notification"`, `browser_snapshot`, `browser_screenshot`, `browser_read`, `phone_status`, `phone_screenshot`, `phone_ocr`, `phone_find`) plus standalone browser session lifecycle (`browser_launch`, `browser_navigate`, `browser_close`; `mac_ax_state` / `mac_find` skip `web_accessibility`). `browser_navigate` still issues a page-load request. All input-synthesis tools (click/drag/type/key/paste/tap/swipe/evaluate/…) plus `mac_clipboard_read` and `mac_notifications` are rejected |
80
- | `NORACU_DISABLE_EVAL` | unset (enabled) | `=1` makes `browser_evaluate` return an error on every call (kill switch for arbitrary JS execution; it stays listed) |
91
+ | `NORACU_ENABLE_EVAL` | unset (off) | `=1` turns `browser_evaluate` on (arbitrary JS execution is opt-in; unset, it returns `eval_disabled` and stays listed) |
92
+ | `NORACU_DISABLE_EVAL` | unset | `=1` keeps `browser_evaluate` off even when `NORACU_ENABLE_EVAL=1` (kill switch) |
81
93
  | `NORACU_DISABLE_AUTO_INSTALL` | unset (auto-install) | `=1` stops `browser_launch` from auto-running `playwright install chromium` on a clean machine; returns an error prompting a manual install instead |
82
94
  | `NORACU_ALLOW_FILE_URL` | unset (blocked) | `=1` permits `browser_navigate` to open `file://` URLs (blocked by default to avoid local-file exfiltration via the browser layer) |
95
+ | `NORACU_ALLOW_CHROME` | unset (blocked) | `=1` permits `browser_launch` with `chrome: true`: reads `DevToolsActivePort` from `NORACU_CHROME_DIR` (default the Chrome profile folder), `connectOverCDP` to `ws://127.0.0.1:<port><path>` (Chrome asks the person), opens a window with `Target.createTarget` (`newWindow`, `background`); `openTabs`/`tabAllowed` then count only pages noracu opened or whose opener it opened (with `NORACU_CHROME_TABS=all` also your other http(s) tabs, which can be selected, read and acted on but are never closed, and where `browser_evaluate` never runs); new tabs come from `window.open(…, "noopener")` run in an isolated world of one of its tabs; `browser_close` closes those pages and disconnects; refused under `NORACU_READ_ONLY=1` |
83
96
  | `NORACU_ALLOW_CDP` | unset (blocked) | `=1` permits `mac_app` launch with `cdp_port` and `browser_launch` with `cdp_port` for a port this process opened (live PID, matching `webSocketDebuggerUrl`; Playwright `connectOverCDP` to 127.0.0.1); `=any` also lets `browser_launch` attach to any loopback DevTools port; refused under `NORACU_READ_ONLY=1`; `browser_close` then only disconnects |
84
97
  | `NORACU_PHONE_TIMEOUT_MS` | 30000 (45000 for `phone_open` / `phone_type`) | time limit for each iPhone-layer step, 1000–600000 ms (`imctl_timeout` on expiry) |
85
98
  | `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | comma-separated Vision OCR language codes for the iPhone screen, in priority order |
86
99
  | `NORACU_TOPHIT_LABELS` | `Top Hit` | comma-separated Spotlight Top Hit section label(s) that `phone_open` looks for |
100
+ | `NORACU_OCR_MIN_CONFIDENCE` | unset (off) | opt-in, experimental: a number above 0 and at most 1. With it, `phone_open` does not tap a Spotlight label the recognizer read with a lower confidence and answers `open_not_confirmed` with nothing tapped; a value that is set and is not such a number makes `phone_open` refuse (`invalid_args`, nothing sent). Set or not, `phone_open`'s result line names the confidence of the label it tapped |
87
101
  | `NORACU_TRACE` | unset | file path for a JSON-lines call log (`{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) |
102
+ | `NORACU_USER_IDLE_S` | `2` | seconds without the person's keyboard or mouse input before a Mac or iPhone Mirroring (`phone_*`) input tool acts (the `ios_*` tools do not wait: they do not use this Mac's keyboard or mouse) (`user_active` sooner); also puts the pointer back after pointer actions; `0` turns both off |
103
+ | `NORACU_NO_BGPOST` | unset | `=1` turns off background input (physical clicks and named keys use the real pointer and the HID key path) |
104
+ | `NORACU_STOP_FILE` | unset | file path: while it exists, every input tool — Mac, iPhone and the browser's input tools (navigate, click, type, fill, press_key, scroll, evaluate, `browser_tabs` new/close) — returns `user_stopped` and sends nothing; set but blank, it refuses all input |
105
+ | `NORACU_DENY_APPS` | the common terminal apps and IDEs with a built-in terminal | comma-separated bundle ids / app names (`*`, `?`) that never get input; a list of your own adds to the default, blank keeps the default, a list starting with `none` drops it |
106
+ | `NORACU_APPROVAL_FILE` | unset | `0600` JSON `{allow, ask, deny}` of bundle-id / app-name patterns, judged on the app that receives the input; `ask` or unlisted → `approval_required`; a broken file refuses all Mac and iPhone input (app rules do not judge the browser layer) |
88
107
 
89
108
  ## Known limitations (v0.2)
90
109
 
@@ -101,7 +120,7 @@ The bundled imctl driver (`imctl/`, Python) runs as a subprocess (`<python3> -m
101
120
  - Physical clicks performed inside the engine process right after the hit test (closes the short gap between the check and the click)
102
121
  - A simpler identity model to compare against the current one on the same tests (no digit folding in item keys)
103
122
  - axState diffing (incremental observation, saves tokens)
104
- - Browser tool gaps (select_text/set_value/hover/wait_for…) + tab management
123
+ - Browser tool gaps (select_text/set_value/hover/wait_for…)
105
124
  - A resident accessibility engine (one long-lived process instead of one per call; true element handles between calls)
106
125
  - Multi-session architecture (browser_id + tab_id)
107
126
  - Security hardening: sensitive-app foreground detection, action audit log
@@ -0,0 +1,156 @@
1
+ # iOS runner protocol, version 1
2
+
3
+ Status: experimental. This describes the wire protocol between noracu on the Mac and the small UI-test
4
+ bundle ("runner") that noracu's XCUITest backend runs on an iPhone. The Mirroring backend does not use it.
5
+
6
+ ## Roles
7
+
8
+ - **Runner** — a UI-test bundle on the phone. It is started by `xcodebuild test-without-building`, stays
9
+ inside one long test, listens on one TCP address, and executes one command at a time on the main thread
10
+ with XCUITest. The test is `NoracuRunnerUITests/NoracuRunner/testServe`. It must not be named `testRun`:
11
+ XCTest has a property of that name, and a test so named is reported as passed without its body running.
12
+ - **Client** — `src/ios-xcuitest.js` on the Mac. It finds the device, starts the runner, sends commands and
13
+ enforces time limits.
14
+
15
+ Launching an app and reading the lock state are **not** runner commands. The client does both with
16
+ `xcrun devicectl` (`device process launch`, `device info lockState`), so a busy app cannot stall them.
17
+
18
+ ## Start-up
19
+
20
+ The client passes three values through `xcodebuild`'s `TEST_RUNNER_` environment prefix (the runner sees
21
+ them without the prefix):
22
+
23
+ | Variable | Meaning |
24
+ |---|---|
25
+ | `NORACU_TOKEN` | 32 lowercase hex characters (ASCII `0-9a-f`), new for every start. The runner refuses to start with anything else. |
26
+ | `NORACU_BIND` | The address to listen on: the device's own CoreDevice tunnel address (IPv6) for a physical device, `127.0.0.1` for a simulator. Required. |
27
+ | `NORACU_PORT` | TCP port, 49152–65535, chosen by the client. Required. |
28
+
29
+ The runner binds **only** `NORACU_BIND` (a required local endpoint). It does not listen on Wi-Fi or
30
+ cellular addresses. On a physical device it accepts a connection only when the peer address is in the same
31
+ /64 as `NORACU_BIND`; on a simulator only from loopback. The peer is checked before anything is read from
32
+ the connection.
33
+
34
+ When the listener is ready the runner prints exactly one line to standard output:
35
+
36
+ ```
37
+ NORACU_RUNNER ready v=1 port=<port> build=<12 hex digits>
38
+ ```
39
+
40
+ `build` names the sources the runner was built from: a hash of the Swift files and the project file, written
41
+ into `NoracuRunner.swift` by `scripts/gen-runner-build.mjs`. The client compares it with the same value in its
42
+ own copy of the sources and does not use a runner that names another build, or none: a build made by an older
43
+ noracu stays on the device until `ios-setup` is run again, and the first start after a rebuild was seen running
44
+ the previous build once (simulator, 2026-11-11) — so the client starts such a runner once more before it
45
+ reports `runner_version_mismatch`.
46
+
47
+ If it cannot start it prints `NORACU_RUNNER error <code>` (`bad_token`, `bad_bind`, `bad_port`,
48
+ `bind_failed`) and ends the test.
49
+
50
+ The runner ends when it receives `quit`, when the client's `xcodebuild` process is stopped, or after
51
+ 12 hours.
52
+
53
+ ## Framing
54
+
55
+ - UTF-8, one JSON object per line, lines end with `\n`. No pretty-printing.
56
+ - A request line is at most 64 KiB. A longer line closes the connection.
57
+ - Every request: `{"id": <integer>, "token": "<hex>", "op": "<name>", "args": { ... }}`
58
+ - Every answer echoes `id`:
59
+ - success: `{"id": 1, "ok": true, "result": { ... }}`
60
+ - refusal or failure: `{"id": 1, "ok": false, "error": "<code>", "message": "<one line>", "sent": false}`
61
+ - `sent` appears on failed input commands: `false` when no event was sent, `"unknown"` when the runner
62
+ cannot tell. It never claims `true` on a failure.
63
+ - A request with a wrong or missing token gets `{"id": <id or 0>, "ok": false, "error": "auth"}` and the
64
+ connection is closed. The token is compared in constant time. Lines that follow such a request in the
65
+ same packet are not read; neither are lines that follow a `quit`.
66
+ - Commands run strictly one after another, in arrival order, whatever connection they came from.
67
+
68
+ ## Coordinates
69
+
70
+ All points and frames are in screen points, origin at the top-left of the screen, the same space as
71
+ `XCUIScreen.main` — the frames in a `snapshot` answer can be used directly as `tap` targets.
72
+
73
+ ## Commands
74
+
75
+ | op | args | result |
76
+ |---|---|---|
77
+ | `ping` | — | `{"v": 1, "uptime_ms": n, "served": n}` |
78
+ | `app_state` | `bundle_id` | `{"state": 0–4, "name": "unknown"/"notRunning"/"runningBackgroundSuspended"/"runningBackground"/"runningForeground"}` |
79
+ | `snapshot` | `bundle_id`, `max_nodes` (1–1000, default 400) | see below |
80
+ | `tap` | `bundle_id`, `x`, `y`, `count` (1–3, default 1) | `{"ms": n}` |
81
+ | `press` | `bundle_id`, `x`, `y`, `duration_ms` (100–5000) | `{"ms": n}` |
82
+ | `drag` | `bundle_id`, `from` `[x, y]`, `to` `[x, y]`, `hold_ms` (0–2000, default 50), `end_hold_ms` (0–2000, default 300), `velocity` (`slow`/`default`/`fast`, default `slow`) | `{"ms": n}` |
83
+ | `type` | `bundle_id`, `text` (1–2000 characters) | `{"ms": n}` |
84
+ | `keys` | `bundle_id`, `key` (`delete`/`return`), `count` (1–500, default 1) | `{"ms": n}` |
85
+ | `home` | — | `{"ms": n}` |
86
+ | `screenshot` | — | `{"png_base64": "...", "w": n, "h": n}` (`w`, `h`: the screen in points; the PNG is in pixels) |
87
+ | `front` | — | `{"home": true/false, "icons": n, "alerts": [[x, y, w, h], …], "alert_buttons": n}` — what SpringBoard itself shows: `home` is true when Home Screen icons are on screen; `alerts` are the frames of SpringBoard's alerts (a sheet is not counted), `alert_buttons` how many buttons they hold |
88
+ | `quit` | — | `{}`; the runner then ends |
89
+
90
+ `tap`, `press`, `drag`, `type` and `keys` take an optional `springboard_only` (boolean), read only when
91
+ `bundle_id` is `com.apple.springboard`. With `true` one thing is sent and nothing else: a single `tap` (no
92
+ `count` above 1) whose point lies on a button of one of SpringBoard's alerts. A sheet is not an alert. `press`,
93
+ `drag`, `type` and `keys` are refused — text goes wherever the keyboard focus is, which the public API does
94
+ not show, and a second Return would land on whatever the alert was covering. See Refusals. noracu's own Mac
95
+ side refuses those, and a `tap` with a `count` above 1, before it starts a runner — a starting runner puts its
96
+ app in front of what the iPhone was showing — so the runner's refusal is what any other client gets. Since
97
+ 2026-11-12 noracu no longer sends `springboard_only`: while app rules are in force it refuses every input that
98
+ names `com.apple.springboard` on the Mac side, a single tap on an alert's button included.
99
+
100
+ An optional field must have the right type when it is present: a `count` of `"2"` is `invalid_args`, not the
101
+ default. `args` itself must be an object (`invalid_args` otherwise), and `id` a whole number: a missing `id`, or any
102
+ other value, is `invalid_args`, answered with `id` 0, and the command is not run.
103
+
104
+ `snapshot` result:
105
+
106
+ ```
107
+ {"bundle_id": "...", "state": 4, "screen": {"w": 402, "h": 874},
108
+ "nodes": [{"i": 0, "type": "button", "label": "...", "id": "...", "value": "...",
109
+ "frame": [x, y, w, h], "enabled": true, "selected": false}],
110
+ "truncated": false, "ms": 96}
111
+ ```
112
+
113
+ - `nodes` is the app's element tree flattened in document order, keeping an element when its frame has a
114
+ non-zero size, intersects the screen, and it either has a label or is an interactive type (button, cell,
115
+ text field, secure text field, search field, text view, switch, slider, link, tab, key, menu item,
116
+ segmented control, picker wheel, stepper, toggle).
117
+ - `type` is the element type's name in lowerCamelCase (`button`, `staticText`, `textField`, …).
118
+ - `value` is present only for text inputs, switches and sliders, at most 4000 characters (`value_truncated:
119
+ true` when it was cut); a secure text field's value is never included. XCUITest reports an empty text
120
+ field's placeholder as its value: the runner returns that text as `placeholder` and an empty `value`.
121
+ `label` is at most 200 characters, `id` at most 80. A cell without a label of its own gets the labels
122
+ inside it, joined with `, `.
123
+ - System alerts (permission prompts and the like) belong to `com.apple.springboard`, not to the app.
124
+
125
+ ## Refusals
126
+
127
+ Input commands (`tap`, `press`, `drag`, `type`, `keys`) are refused before anything is sent when:
128
+
129
+ | error | when |
130
+ |---|---|
131
+ | `invalid_args` | a field is missing, of the wrong type, or out of range; a point is outside the screen |
132
+ | `app_not_running` | the app's state is `notRunning` or `unknown` |
133
+ | `app_not_foreground` | the app is not `runningForeground`. `com.apple.springboard` always reads `runningForeground`, so for it this check is skipped — unless the command carries `springboard_only: true`: then it is refused unless it is the one tap on an alert's button described above |
134
+ | `no_keyboard` | `type` or `keys` while the app shows no keyboard |
135
+
136
+ Other errors: `unknown_op`, `snapshot_failed`, `screenshot_failed`, `internal`, and `xctest_issue`: XCTest
137
+ recorded a failure while the command ran (the runner keeps `continueAfterFailure` on, so the test goes on).
138
+ The answer is then `ok: false` whatever the command itself answered; for an input command `sent` is `false`
139
+ when the command had refused without sending, `"unknown"` otherwise. A failure recorded between two commands
140
+ is reported by the next command other than `ping`: that command is not run and answers `xctest_issue` with
141
+ `sent: false`.
142
+
143
+ `selftest_issue` is a test hook: only a runner started with `NORACU_SELFTEST=1` in its environment answers
144
+ it. It records one XCTest failure — at once, or shortly after answering when called with `late: true`.
145
+
146
+ The runner never retries a gesture, never taps anything on its own, and does not read or write the
147
+ pasteboard.
148
+
149
+ ## Time limits
150
+
151
+ The runner cannot interrupt an XCUITest call that is waiting for an app to become idle. The client gives
152
+ every command a hard time limit. When it passes for an input command, the client stops the runner (ending
153
+ `xcodebuild`), so the gesture cannot go out later, and reports delivery unknown without re-sending it. After
154
+ a read that timed out, it asks the runner for a sign of life before the next command and restarts it if
155
+ there is none. It also stops the runner after any answer of `xctest_issue`, whichever command got it: what state
156
+ the test session is in is then not known, and `ping` answers from the socket alone.
package/docs/tools.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Tool reference
2
2
 
3
3
  > Auto-generated from the running server (`node scripts/gen-tools.mjs`) — always in sync with the implementation. Hints are the four MCP tool annotations each tool reports — R read-only, D destructive, I idempotent, O open-world, – false — hints for the client, not permissions.
4
- > noracu v0.2.6 · 46 tools
4
+ > noracu v0.3.0 · 33 tools listed by default (the Mac and browser layers; NORACU_LAYERS unset), 47 with NORACU_LAYERS=mac,browser,iphone (iPhone Mirroring backend), 42 with NORACU_PHONE_BACKEND=xcuitest as well (the ios_* group replaces phone_*)
5
5
 
6
6
  ## Mac layer (computer-use)
7
7
 
@@ -9,12 +9,12 @@
9
9
 
10
10
  | Tool | Arguments | Hints | Description |
11
11
  |---|---|---|---|
12
- | `mac_screenshot` | region:object?, window_id:integer?, display:integer? | R – I O | Capture the Mac screen as PNG base64: the main display, display (index from mac_windows), or one window by window_id (CGWindowID from mac_windows; works when covered), optionally cropped to region {x,y,w,h}. Returns {scale, logical_size, screen}; click coordinates are in points (pixels / scale). |
12
+ | `mac_screenshot` | region:object?, window_id:integer?, display:integer? | R – I O | Capture the Mac screen as PNG base64: the main display, display (index from mac_windows), or one window by window_id (CGWindowID from mac_windows; works when covered). A display capture can be cropped to region {x,y,w,h} in screen points as mac_windows reports them (the main display's top-left is 0,0; a display to its left has negative x), not relative to the display; with display given, a region not inside that display is refused. Returns {scale, logical_size, screen, screenshot_id}; click coordinates are in points (pixels / scale). screenshot_id (valid 30 s) lets mac_click take x,y in screenshot pixels: the window's geometry is re-checked first and a window that moved, resized or was rebuilt since the capture is refused as stale. |
13
13
  | `mac_ax_state` | app:string?, interactive:boolean?, compact:boolean?, skeleton:boolean?, root:integer?, snapshot_id:string?, surface:string?, window:string?, window_id:integer?, depth:number?, max_nodes:integer?, web_accessibility:boolean? | R – I O | Read an app's accessibility tree through the macOS Accessibility API (default: the frontmost app's focused window). Returns {app, snapshot_id, window, complete, elements:[{i, d, role, title, value, states, actions, frame}]}; i is the element_index for mac_click, mac_get, mac_set_value, mac_type, mac_scroll and mac_drag — unique across snapshots (an index never names an element of a later snapshot) and valid 30 s; an action first re-identifies the element and returns element_no_longer_valid if it is gone, moved or replaced. Options: interactive (only actionable elements), compact (default true: skip empty layout wrappers), skeleton (shallow map with children_count) then root (an element_index to drill into; adds new indexes to the same snapshot), surface (window\|menubar\|menu\|sheet\|alert\|dialog\|popover\|focused\|app), window (index or title) or window_id (from mac_windows), depth (logical depth, default 12, 1-40), max_nodes (default 400), web_accessibility (default true, false under NORACU_READ_ONLY=1: sets AXManualAccessibility on Electron/Chromium apps to expose web content, never AXEnhancedUserInterface which alters window behaviour; the result's web_accessibility is enabled / already_on, exposed when the app refused but its pages are in the tree anyway, or unsupported with a web_accessibility_hint — Google Chrome refuses it). window_identity unverifiable marks a window without a window ID: element_index actions in it are refused. ax_empty when the app has no readable window. |
14
- | `mac_click` | element_index:integer?, snapshot_id:string?, x:number?, y:number?, app:string?, force:boolean?, button:string?, count:number?, mechanism:string?, timeout_ms:integer? | – – – O | Click a UI element by element_index (from mac_ax_state / mac_find; valid 30 s) or at raw {x,y}. With element_index the element is re-identified first (element_no_longer_valid if gone or changed). mechanism auto (default): its own accessibility action (press / show menu / select — no pointer, no focus change, works in background windows) when it has one, else a physical click that is sent only if a hit test shows the point reaches the element (occluded otherwise); semantic / physical force one path. count 2-3 and button middle are physical. A physical click is re-checked right before it is sent, and is delivered_verified only if the element is still there, changed, and its window is still on top at the point. A raw {x,y} click is sent only when the window on top at that point belongs to app (default: the frontmost app; the menu bar counts as the frontmost app's) — otherwise occluded names what covers it and nothing is sent; force:true skips that check. Results state delivery (delivered_verified / delivered_unverified / not_delivered / unknown) and whether a retry is safe, plus newly opened sheets, dialogs or menus. |
15
- | `mac_drag` | **from_index**:integer, **to_index**:integer, snapshot_id:string? | – – – O | Drag from one UI element to another (sliders, selections, list items) with the physical pointer; from_index/to_index come from mac_ax_state or mac_find (valid 30 s). Both ends are re-identified and hit-tested first (either one gone or covered: nothing sent). Check the drop target afterwards. |
14
+ | `mac_click` | element_index:integer?, snapshot_id:string?, x:number?, y:number?, screenshot_id:string?, app:string?, force:boolean?, button:string?, count:number?, mechanism:string?, timeout_ms:integer? | – – – O | Click a UI element by element_index (from mac_ax_state / mac_find; valid 30 s) or at raw {x,y}. With element_index the element is re-identified first (element_no_longer_valid if gone or changed). mechanism auto (default): its own accessibility action (press / show menu / select — no pointer, no focus change, works in background windows) when it has one, else a physical click that is sent only if a hit test shows the point reaches the element (occluded otherwise); semantic / physical force one path. count 2-3 and button middle are physical. A physical click is re-checked right before it is sent, and is delivered_verified only if the element is still there, changed, and its window is still on top at the point. A raw {x,y} click is sent only when the window on top at that point belongs to app (default: the frontmost app; the menu bar counts as the frontmost app's) — otherwise occluded names what covers it and nothing is sent; force:true skips that check. Results state delivery (delivered_verified / delivered_unverified / not_delivered / unknown) and whether a retry is safe, plus newly opened sheets, dialogs or menus. Under mechanism auto, a physical click on a native app is posted straight to the app's pid (route: bgpost — no pointer move, no frontmost needed); web-engine apps (Chromium/Electron) use the real pointer (route: cliclick). A bgpost click is never re-sent another way: no visible change is reported as delivered_unverified with a note, a timeout as delivery=unknown. mechanism physical always uses the real pointer. screenshot_id + x,y names pixels of a mac_screenshot window capture (relative to the window's top-left corner; the window's position and size are re-checked first and a window that moved, resized or was rebuilt is refused as stale; the screenshot's window's app is the target). |
15
+ | `mac_drag` | **from_index**:integer, **to_index**:integer, snapshot_id:string?, hold_ms:integer?, step_ms:integer? | – – – O | Drag from one UI element to another (sliders, selections, list items) with the physical pointer; from_index/to_index come from mac_ax_state or mac_find (valid 30 s). Both ends are re-identified and hit-tested first (either one gone or covered: nothing sent). hold_ms (0-2000) presses and holds after mouse-down before the move starts (timeline editors use it to tell clip-move from marquee selection); step_ms (1-500) moves in steps of about 20 points with that many ms between them. A drag whose holds and steps add up to more than 10 s is refused; a drag that fails midway gets a mouse-up so the button is not left held. Check the drop target afterwards. |
16
16
  | `mac_scroll` | direction:string?, pages:number?, element_index:integer?, snapshot_id:string? | – – – O | Scroll up/down/left/right by a number of pages (default 1). Without element_index: the center of the frontmost app's front window (the pointer moves there), only when that app's window is on top at that point (else occluded, nothing scrolled). With element_index: a scroll area is scrolled at its own center (hit-tested; reports when the position did not change), any other element is scrolled into view (AXScrollToVisible). |
17
- | `mac_key` | **key**:string, app:string?, force:boolean? | – D – O | Press a key or modifier chord, e.g. 'return', 'esc', 'cmd-c', 'cmd-shift-v', 'arrow-up'. Named keys (return, esc, tab, space, delete, arrows, home/end, page keys, F1-F16), with or without modifiers, go out as HID key events with each modifier pressed and released around the key; a chord with cmd or ctrl on a character key (cmd-c, cmd-shift-v) goes out the same way on the key that types that character in the current keyboard layout (no such key: not_delivered, keyboard_layout); a plain character or a shift/alt-only chord is typed through cliclick. Pass app to refuse input unless that app is frontmost (focus guard). Chords that quit, log out, lock, force-quit, delete immediately or empty the Trash (cmd-q, alt-cmd-q, cmd-shift-q, cmd-alt-esc, ctrl-cmd-q, cmd-alt-delete, cmd-shift-delete…) are refused unless force:true. |
17
+ | `mac_key` | **key**:string, app:string?, force:boolean? | – D – O | Press a key or modifier chord, e.g. 'return', 'esc', 'cmd-c', 'cmd-shift-v', 'arrow-up'. Named keys (return, esc, tab, space, delete, arrows, home/end, page keys, F1-F16), with or without modifiers, go out as HID key events with each modifier pressed and released around the key; a chord with cmd or ctrl on a character key (cmd-c, cmd-shift-v) goes out the same way on the key that types that character in the current keyboard layout (no such key: not_delivered, keyboard_layout); a plain character or a shift/alt-only chord is typed through cliclick. Pass app to refuse input unless that app is frontmost (focus guard). A named key for a native frontmost app is posted straight to its pid (route: bgpost — no focus theft); web-engine apps and layout-dependent chords use the engine HID path. Chords that quit, log out, lock, force-quit, delete immediately or empty the Trash (cmd-q, alt-cmd-q, cmd-shift-q, cmd-alt-esc, ctrl-cmd-q, cmd-alt-delete, cmd-shift-delete…) are refused unless force:true. |
18
18
  | `mac_type` | **text**:string, element_index:integer?, snapshot_id:string?, app:string?, replace:boolean?, mechanism:string?, timeout_ms:integer? | – – – O | Type text into element_index, or into the focused element (of app, if given). mechanism auto (default): inserted through accessibility at the caret (AXSelectedText) — IME-safe, clipboard untouched, works in a background app; delivered_verified only when the value reads back as exactly the old value with the text over the selection that was there (unreadable caret: delivered_unverified). replace:true sets the whole value instead (already that text: nothing sent). If the focused element is a text view that takes no text through accessibility (a terminal), auto falls back to physical keystrokes (not IME-safe; app is then a focus guard: refused unless that app is frontmost); a focused button, list or sheet gets none. When the app reports no focused element, auto sends keystrokes only if app names that app (else no_focus, nothing sent). The result names the app it typed into. mechanism physical forces keystrokes (clicking element_index first). |
19
19
  | `mac_paste` | **text**:string, app:string?, force:boolean? | – – – O | Paste text with Cmd+V through the clipboard (⌘V goes out on the key that types V in the current keyboard layout; no such key: not_delivered, keyboard_layout), then put the user's clipboard back: every item and type is copied aside and restored within one call, only after the paste shows in the focused element (else after a 1 s hold) and only if nothing else wrote to the clipboard meanwhile — not while the app does not answer, so a late paste cannot insert the user's own clipboard; delivered_verified only when the focused field's value becomes exactly the text pasted over its selection; a password manager's concealed item is never copied — the clipboard is cleared after the paste instead. The pasted text is marked transient for clipboard managers. Pass app to refuse input unless that app is frontmost (focus guard). Refused when the clipboard holds Universal Clipboard content or more than 64 MB (force:true pastes anyway and leaves the pasted text on the clipboard). mac_type does not touch the clipboard. |
20
20
  | `mac_menu_command` | **app**:string, **command**:string, force:boolean? | – D – O | Run an app's menu bar command through accessibility (AXPress on the item: no pointer, the app need not be frontmost). command is the item title as the app shows it (unique in the menu bar) or a path such as "File > Export > PDF…"; an item that reads disabled is still pressed (closed menus report stale state) and the result says whether anything changed; reports delivery and any sheet or dialog it opened. Menu items under the Apple menu and items whose keyboard shortcut is one of the refused chords need force:true; Quit of the MCP host or of a macOS session process is always refused. |
@@ -36,37 +36,54 @@
36
36
 
37
37
  | Tool | Arguments | Hints | Description |
38
38
  |---|---|---|---|
39
- | `browser_launch` | headless:boolean?, cdp_port:integer? | – – – O | Launch the browser with a persistent profile (headed by default; pass headless:true for headless). With cdp_port: attach to a Chromium/Electron app started by this server's mac_app launch cdp_port (needs NORACU_ALLOW_CDP=1; attaching to any other loopback port needs NORACU_ALLOW_CDP=any; refused under NORACU_READ_ONLY=1 and while another session is open; standalone browser_launch is also refused while a CDP session is open). browser_close then only disconnects. |
39
+ | `browser_launch` | headless:boolean?, cdp_port:integer?, chrome:boolean? | – – – O | Launch the browser with a persistent profile (headed by default; pass headless:true for headless). With cdp_port: attach to a Chromium/Electron app started by this server's mac_app launch cdp_port (needs NORACU_ALLOW_CDP=1; attaching to any other loopback port needs NORACU_ALLOW_CDP=any; refused under NORACU_READ_ONLY=1 and while another session is open; standalone browser_launch is also refused while a CDP session is open). browser_close then only disconnects. With chrome:true: work in your own Chrome, with its sign-ins (needs NORACU_ALLOW_CHROME=1 and Chrome's remote debugging switched on at chrome://inspect/#remote-debugging; Chrome asks you to allow the connection). noracu opens a window of its own there and lists, reads and acts only on the tabs it opened (and tabs those open) — with NORACU_CHROME_TABS=all on the server, on your other tabs too (http(s) pages); browser_close closes only noracu's tabs and disconnects, and Chrome keeps running. |
40
40
  | `browser_navigate` | **url**:string | – – – O | Navigate the active page to an http(s) URL (file:// is disabled unless NORACU_ALLOW_FILE_URL=1). Reports the final URL, HTTP status (or "no response" for same-document navigations), title, and delivery/retry. |
41
- | `browser_snapshot` | browser_id:string? | R – I O | Return the active page's ARIA accessibility snapshot (about 14000 characters with the list; a longer snapshot is cut and marked) plus up to 100 indexed interactive elements (reporting truncation and omitted count beyond 100, or that the list could not be read); indexes feed browser_click. The active page stays the tab noracu is driving: a tab the page opens itself (window.open, target=_blank) is never switched to; another tab becomes active only after the active one closes. |
42
- | `browser_screenshot` | fullPage:boolean?, format:string?, quality:number?, clip:object? | R – I O | Screenshot the active page with optional fullPage, format png\|jpeg, quality (1-100, jpeg) and clip {x,y,width,height} (uses scale:"css" when attached over CDP); returns the image plus DPR/viewport metadata. |
41
+ | `browser_snapshot` | browser_id:string? | R – I O | Return the active page's ARIA accessibility snapshot (about 14000 characters with the list; a longer snapshot is cut and marked) plus up to 100 indexed interactive elements (reporting truncation and omitted count beyond 100, or that the list could not be read); indexes feed browser_click. When the page navigates while the snapshot is being taken it returns page_changed and nothing else (ask again); an element_index is not used after the page navigated. The active page stays the tab noracu is driving: a tab the page opens itself (window.open, target=_blank) is never switched to; another tab becomes active only after the active one closes. |
42
+ | `browser_screenshot` | fullPage:boolean?, format:string?, quality:number?, clip:object? | R – I O | Screenshot the active page with optional fullPage, format png\|jpeg, quality (1-100, jpeg) and clip {x,y,width,height} (uses scale:"css" when attached over CDP); returns the image plus DPR/viewport metadata (with a navigated note when the page navigated while the picture was taken). |
43
43
  | `browser_click` | element_index:integer?, selector:string?, xy:array?, button:string? | – – – O | Click an element on the active page, preferring element_index from the latest browser_snapshot of that page (valid 30 s; re-checks page, URL, tag, name, href and position, returning element_no_longer_valid when stale). Uses real Playwright pointer input with actionability checks (returns occluded or not_actionable when covered or disabled — never falls back to synthetic JS .click()). selector is a fallback; xy pixel coordinates are not recommended. Reports delivery and retry. |
44
44
  | `browser_fill` | **selector**:string, value:string? | – – – O | Fill an input field matched by selector; fill replaces the whole value (browser_type appends keystrokes). Reports delivery and retry. |
45
45
  | `browser_press_key` | **key**:string | – – – O | Press a key or chord, e.g. 'Enter' or 'Control+A'. Reports delivery and retry. |
46
46
  | `browser_type` | **text**:string | – – – O | Type up to 2000 characters via the keyboard into the focused element; type appends keystrokes (browser_fill replaces the whole value and suits longer text). Reports delivery and retry. |
47
47
  | `browser_scroll` | direction:string?, pages:number? | – – – O | Scroll the active page up, down, left, or right by a number of pages (default: down, 1 page) via mouse wheel at the viewport center; reports the scrollX/scrollY change (or "did not move") plus delivery and retry. |
48
- | `browser_read` | selector:string? | R – I O | Read the active page's visible text (up to 12000 characters; 8000 with a selector; longer text is cut and marked), optionally scoped to a selector. |
49
- | `browser_evaluate` | **js**:string | – D – O | Evaluate JavaScript in the active page and return the result plus delivery and retry (disabled when NORACU_DISABLE_EVAL=1). |
48
+ | `browser_read` | selector:string? | R – I O | Read the active page's visible text (up to 12000 characters; 8000 with a selector; longer text is cut and marked), optionally scoped to a selector. When the page navigated while it was read: without a selector it returns page_changed (ask again); with one — a read that waits for a selector goes on across the page's own move to the next page — the first line of the result says so and gives both addresses. |
49
+ | `browser_evaluate` | **js**:string | – D – O | Evaluate JavaScript in the active page and return the result plus delivery and retry. Off by default: runs only when the server was started with NORACU_ENABLE_EVAL=1 (eval_disabled otherwise), and never when NORACU_DISABLE_EVAL=1 or in your own Chrome (browser_launch chrome:true). When the page navigated while the script ran, a line after the result says so. |
50
+ | `browser_tabs` | action:string?, tab_id:string?, url:string?, browser_id:string? | – D – O | List, open, select or close the tabs of the browser session. action list (the default) returns each tab's tab_id, url, title (null when the page did not answer in 3 s), whether it is the active page, and whether browser_tabs opened it. new opens a tab — with url (http(s); file:// needs NORACU_ALLOW_FILE_URL=1) it goes there — and makes it the active page. select makes tab_id the active page — only a tab on an http(s) page, or one still on the blank page that browser_launch or browser_tabs opened it on (file:// with NORACU_ALLOW_FILE_URL=1; tab_not_selectable otherwise): the other browser_* tools act on the active page only, and a tab the page itself opens (a link with target=_blank, window.open) is listed but never followed on its own. close closes tab_id only when browser_tabs opened it (tab_not_owned otherwise, nothing closed) and never the last open tab. After new, select, or a close of the active tab, element_index values from an earlier snapshot no longer apply; when the active tab goes, the first open tab that select would take is the active page, and when there is none the other browser_* tools return no_active_page until browser_tabs opens or selects one. When the active tab itself comes to show a page select would refuse (a blob the page made, a load that failed, a blank page after it has loaded something), it stays the active page and the other browser_* tools return active_page_not_allowed — except browser_navigate, which can take it to an http(s) page. new, select and close report delivery and retry. |
50
51
  | `browser_close` | — | – – I – | Close the browser (or disconnect from an attached CDP session). |
51
52
 
52
53
  ## iPhone layer (device-use)
53
54
 
54
- *imctl / iPhone Mirroring*
55
+ *listed when NORACU_LAYERS includes iphone (off by default) · imctl / iPhone Mirroring — the default iPhone backend*
55
56
 
56
57
  | Tool | Arguments | Hints | Description |
57
58
  |---|---|---|---|
58
59
  | `phone_status` | — | R – I – | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Return the iPhone Mirroring session status as JSON (running, window, onscreen, frontmost, live, overlay, paused, setup — true when a setup or welcome screen is showing that the user must finish). |
59
60
  | `phone_launch` | — | – – – – | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Ensure iPhone Mirroring is running, brought to the front, and clicks Resume when the connection is paused. Never clicks through a setup or welcome screen: reports mirror_setup_required instead. Reports delivery and retry. |
60
- | `phone_screenshot` | — | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Screenshot the iPhone screen (the Mirroring window, captured by window id so it works even when covered). Fails with capture_failed instead of returning another window's pixels. |
61
- | `phone_ocr` | — | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. OCR the iPhone screen into text with coordinates. Fails with capture_failed instead of returning another window's pixels. |
62
- | `phone_find` | **text**:string | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Locate text on the iPhone screen. Fails with capture_failed instead of returning another window's pixels. |
63
- | `phone_tap` | **x**:number, **y**:number, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Tap at {x, y} in normalized 0-1 coordinates. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
64
- | `phone_longpress` | **x**:number, **y**:number, duration:number?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Long-press at {x, y} for an optional duration in seconds. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
65
- | `phone_swipe` | **from**:array, **to**:array, ms:number?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Swipe (mouse drag) from [x,y] to [x,y] over an optional duration in ms; to move a list use phone_scroll. The mirror delivers a drag as pointer input, so a swipe that starts on an app icon picks the icon up and moves it (it can rearrange the Home Screen or make a folder): page the Home Screen from the empty strip just above the Dock (y about 0.80), never across the icon rows. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
61
+ | `phone_screenshot` | — | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Screenshot the iPhone screen (the Mirroring window, captured by window id so it works even when covered). Fails with capture_failed instead of returning another window's pixels. Some phone apps treat a capture of the mirror window as a screenshot and show their after-screenshot sheet a moment later; that holds for every tool and every expect check that reads the phone screen. |
62
+ | `phone_ocr` | — | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. OCR the iPhone screen into text with coordinates: one line per reading, (x,y) 'text' [confidence] — the normalized 0-1 centre, then the recognizer's own 0-1 confidence in that reading. Fails with capture_failed instead of returning another window's pixels. The capture can make a phone app show its after-screenshot sheet (see phone_screenshot). |
63
+ | `phone_find` | **text**:string | R – I O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Locate text on the iPhone screen: the first reading that contains it, as (x,y) 'text' [confidence] — the normalized 0-1 centre, then the recognizer's own 0-1 confidence. Fails with capture_failed instead of returning another window's pixels. The capture can make a phone app show its after-screenshot sheet (see phone_screenshot). |
64
+ | `phone_tap` | **x**:number, **y**:number, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Tap at {x, y} in normalized 0-1 coordinates of the mirror window. A point on the window's transparent margin (the strip above the phone screen, which holds the window's own controls, or the thin edge around it) is refused with out_of_screen and nothing is sent; while the screen's edges cannot be trusted (the pointer resting on that strip), so is a point near the top of the window or along its other sides, where the margin may be, and a tap that goes out says the edges were not known; when nothing is remembered and the window's image cannot be read, the tap is refused with capture_failed. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
65
+ | `phone_longpress` | **x**:number, **y**:number, duration:number?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Long-press at {x, y} for an optional duration in seconds. A point on the mirror window's transparent margin is refused with out_of_screen and nothing is sent, as in phone_tap. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
66
+ | `phone_swipe` | **from**:array, **to**:array, ms:number?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Swipe (mouse drag) from [x,y] to [x,y] over an optional duration in ms; to move a list use phone_scroll. The mirror delivers a drag as pointer input, so a swipe that starts on an app icon picks the icon up and moves it (it can rearrange the Home Screen or make a folder): page the Home Screen from the empty strip just above the Dock (y about 0.80), never across the icon rows. Both points are kept inside the phone screen: the mirror window has a transparent margin around it (a strip above, a thin edge on the other sides) and iOS cancels a drag that starts or ends there, so a point on it is moved just inside the screen's edge and the result names it. The screen's edges are measured from one capture of the window and remembered per window size; a measurement that cannot be trusted (the pointer resting on the strip above the screen) is not used: both points are then kept clear of where the margin may be — the top of the window and a band along its other sides — and the result says so; a swipe whose two points would become one point once moved inside is refused with out_of_screen; when nothing is remembered and the window's image cannot be read, the swipe is refused with capture_failed and nothing is sent. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
66
67
  | `phone_home` | — | – – – O | EXPERIMENTAL. Send the Home Screen command via the iPhone Mirroring menu (works without python/pyobjc on English macOS while the mirror is live), falling back to an imctl swipe (needs python/pyobjc) only when that English menu item is absent (non-English macOS). Reports only that the command or gesture was sent — nothing on the iPhone screen is verified; refuses with mirror_not_live or mirror_state_unknown (or menu_unknown on timeout) when the mirror is not live or its state cannot be confirmed. Reports delivery and retry. |
67
68
  | `phone_app_switcher` | — | – – – O | EXPERIMENTAL. Send the App Switcher command via the iPhone Mirroring menu (works without python/pyobjc on English macOS while the mirror is live), falling back to an imctl gesture (needs python/pyobjc) only when that English menu item is absent (non-English macOS). Reports only that the command or gesture was sent — nothing on the iPhone screen is verified; refuses with mirror_not_live or mirror_state_unknown (or menu_unknown on timeout) when the mirror is not live or its state cannot be confirmed. Reports delivery and retry. |
68
69
  | `phone_scroll` | direction:string?, distance:number?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Scroll up or down by `distance` window heights (0 < distance <= 3, default 0.5) using trackpad-style scroll events. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed; reports scroll_no_effect when the screen did not change (list end, or the view does not scroll); a scroll that changed the screen is delivered_unverified, since a notification or an animation changes it too — take phone_screenshot to see where the list is. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
69
- | `phone_type` | **text**:string, replace:boolean?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe; never echoes the typed text). Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Saves every clipboard item and type, clearing concealed or transient items instead of copying, and restores only after OCR sees the text appear within its 2.5 s check at a spot where it was not before, below the status bar and notification strip — only that sighting makes the result delivered_verified (Universal Clipboard or >64 MB items are not copied and leave the typed text on the clipboard; a text under four characters, spaces and case aside, a paste seen only after the 2.5 s check, and type_not_confirmed are never verified and also leave the typed text on the clipboard). replace=true selects all and overwrites the field. Refused with keyboard_layout (nothing sent, clipboard untouched) when the Mac's keyboard layout types another character on the key ⌘V or ⌘A is sent from (AZERTY, Dvorak). Optional expect: on-screen text (OCR), else nothing is sent. Reports delivery and retry. |
70
+ | `phone_type` | **text**:string, replace:boolean?, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Type text via the clipboard (IME-safe; never echoes the typed text). Waits at least 1.5 s after writing the Mac clipboard before ⌘V, because the phone reads it through Universal Clipboard and an earlier ⌘V can paste the phone's own older clipboard instead; after type_not_confirmed, read the field — it may hold that older text. If another app comes to the front during the wait: focus_lost, no ⌘V; the clipboard is put back unless something else copied during the wait. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Saves every clipboard item and type, clearing concealed or transient items instead of copying, and restores only after OCR sees the text appear within its 2.5 s check at a spot where it was not before, below the status bar and notification strip — only that sighting makes the result delivered_verified (Universal Clipboard or >64 MB items are not copied and leave the typed text on the clipboard; a text under four characters, spaces and case aside, a paste seen only after the 2.5 s check, and type_not_confirmed are never verified and also leave the typed text on the clipboard). replace=true selects all and overwrites the field. Refused with keyboard_layout (nothing sent, clipboard untouched) when the Mac's keyboard layout types another character on the key ⌘V or ⌘A is sent from (AZERTY, Dvorak). Optional expect: on-screen text (OCR), else nothing is sent. Reports delivery and retry. |
70
71
  | `phone_key` | **key**:string, expect:string? | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Press a key: return, delete, up, down, left, or right. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Optional expect: text that must be on screen (OCR) first, else nothing is sent. Reports delivery and retry. |
71
- | `phone_open` | **app**:string | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Open an app: Home Screen, Spotlight via the menu, clear, type the name (the clipboard keeps it), then tap only an exact label inside the Spotlight Top Hit card (suggestion, website and Settings rows of the same name are ignored, so a name the Top Hit card does not show is app not found, and one it shows at two or more spots is open_not_confirmed with nothing tapped; reads the English "Top Hit" label unless NORACU_TOPHIT_LABELS names the phone's own; a pasted name that never shows up in Spotlight, even after up to 15 s, is open_not_confirmed — retry; a one- or two-letter name such as "X" that OCR cannot read in the Top Hit card is open_not_confirmed without the 15 s wait, nothing tapped — open it from its Home Screen icon); confirms the app opened (frame diff + OCR), taps the Top Hit icon when the label tap does nothing, else open_not_confirmed, back on the Home Screen. Reports delivery and retry. |
72
+ | `phone_open` | **app**:string | – – – O | EXPERIMENTAL. Needs iPhone Mirroring and a python3 with pyobjc. Refused with mirror_not_live or mirror_state_unknown when the mirror is not live or its state cannot be confirmed. Open an app: Home Screen, Spotlight via the menu, clear, type the name the way phone_type does (the clipboard keeps it), then tap only an exact label inside the Spotlight Top Hit card — or, where Spotlight shows its search field at the top and no Top Hit card, the exact label just under the field, and only when the field completes the name as "<name> — Open" — (suggestion, website and Settings rows of the same name are ignored, so a name the Top Hit card does not show is app not found, and one it shows at two or more spots is open_not_confirmed with nothing tapped; reads the English "Top Hit" label unless NORACU_TOPHIT_LABELS names the phone's own, and the "— Open" completion in English only; a name that never shows up in Spotlight after ⌘V, even after up to 15 s, is open_not_confirmed — retry; a one- or two-letter name such as "X" that OCR cannot read in the Top Hit card is open_not_confirmed without the 15 s wait, nothing tapped — open it from its Home Screen icon); confirms the app opened (frame diff + OCR), taps the Top Hit icon when the label tap does nothing, else open_not_confirmed, back on the Home Screen. If another app comes to the front before ⌘V: focus_lost, nothing pasted or tapped, no trip Home (Spotlight may stay open); if another app or device changes the clipboard before ⌘V: open_not_confirmed, nothing pasted or tapped, back on the Home Screen. The result line names the confidence (0-1) the tapped label was read with; with NORACU_OCR_MIN_CONFIDENCE set, a label read below it is not tapped: open_not_confirmed, back on the Home Screen. Reports delivery and retry. |
73
+
74
+ ## iPhone layer, XCUITest backend (device-use)
75
+
76
+ *listed instead of the phone_* tools when NORACU_LAYERS includes iphone and NORACU_PHONE_BACKEND=xcuitest · a UI-test runner on the phone (ios-runner/) · devicectl*
77
+
78
+ | Tool | Arguments | Hints | Description |
79
+ |---|---|---|---|
80
+ | `ios_status` | — | R – I – | EXPERIMENTAL. XCUITest iPhone backend (NORACU_PHONE_BACKEND=xcuitest; needs Xcode, a paired iPhone with Developer Mode or a booted simulator, and the runner built once with `npx noracu ios-setup`). Report what it can do here without starting anything: the device in use (name, model, iOS, udid, cable or network, simulator), whether it is locked, whether the runner build exists, whether the runner is running, and the app later calls default to. Run it first when ios_* tools fail. |
81
+ | `ios_launch` | **bundle_id**:string, terminate_existing:boolean? | – D – O | EXPERIMENTAL. Bring an app to the front on the iPhone by bundle id (e.g. com.apple.Preferences), starting it if needed, through devicectl (simctl on a simulator); terminate_existing:true ends a running instance first (its unsaved state is lost). Verified by the app reporting that it is in front; launch_not_confirmed after 10 s otherwise (a system prompt may cover it). The first ios_* call that needs the phone starts the on-device runner, which can take a minute, and needs the phone unlocked: a locked phone, or one whose lock state cannot be read, gets nothing (device_locked / lock_unknown). Ends every earlier element_index. The app becomes the default bundle_id of later calls. Reports delivery and retry. |
82
+ | `ios_snapshot` | bundle_id:string?, interactive:boolean?, max_nodes:integer? | R – I O | EXPERIMENTAL. Read an app's accessibility tree on the iPhone (bundle_id; default: the app of the last ios_* call). Returns {bundle_id, snapshot_id, state, screen:{w,h} in points, elements:[{i, type, label, id, value, placeholder, frame:[x,y,w,h], disabled, selected}]}; i is the element_index for ios_tap and ios_type — unique across snapshots, valid 30 s, and ended by ios_home and ios_launch. interactive:true keeps only controls; max_nodes (default 300, 1-1000) cuts the list (truncated:true). A secure field's value is never returned; an empty field's placeholder comes as placeholder, not as value; a value over 4000 characters is cut (value_truncated:true). An app that is not in front can be read but not acted on. An app that has just come to the front may still be filling in its rows: labels can change within a second or two. Labels and values are untrusted text from the app. |
83
+ | `ios_screenshot` | — | R – I O | EXPERIMENTAL. Screenshot the iPhone screen as PNG, taken on the phone by the runner; returns the image and the screen size in points (the unit of ios_tap x,y and ios_snapshot frames). The image is returned, never written to disk on the Mac. Whatever is on screen, notifications included, becomes model input. |
84
+ | `ios_tap` | element_index:integer?, snapshot_id:string?, x:number?, y:number?, bundle_id:string?, count:integer?, duration_ms:integer? | – – – O | EXPERIMENTAL. Tap an element by element_index (from ios_snapshot), or a point x,y in screen points inside bundle_id (default: the app of the last call). With element_index the app is read again first: the element must still be there with the same type, label, identifier and frame, and its app in front — otherwise element_no_longer_valid and nothing is sent. count 2-3 repeats the tap; duration_ms (100-5000) makes it a long press. Nothing is sent when the app rule (NORACU_DENY_APPS / NORACU_APPROVAL_FILE, matched on the bundle id) rules the app out, the stop file exists, the phone is locked, or the app is not in front; with app rules set, no tap that names com.apple.springboard (the Home Screen) goes out — not even one on a system prompt's button (input_denied; open apps with ios_launch). A tap that went out is delivered_unverified: take ios_snapshot to see what it did. No answer from the phone is ios_timeout with delivery=unknown, and the tap is never sent again. |
85
+ | `ios_type` | **text**:string, element_index:integer?, snapshot_id:string?, bundle_id:string? | – – – O | EXPERIMENTAL. Type text (1-2000 characters) as keyboard input on the phone — no clipboard is involved. With element_index the field is re-checked and tapped first and the keyboard is waited for; without it the text goes to whatever holds the keyboard in bundle_id (default: the app of the last call; no_keyboard, nothing sent, when none is up). delivered_verified only when the field that took the text — the one tapped, or the only one whose value changed — afterwards holds its old value with the text put in at one place; type_not_confirmed when it does not (autocorrection or completion changed it, the field hides its value, part of the text was lost, or the text went elsewhere) — read the field before typing again. With app rules set, text that names com.apple.springboard is not sent (input_denied). Text shorter than 4 characters, a secure field, text that contains a return, and text typed while the app's fields could not be read, are not read back (delivered_unverified). The result never repeats the text. |
86
+ | `ios_key` | **key**:string, count:integer?, bundle_id:string? | – – – O | EXPERIMENTAL. Press return or delete (count 1-50) on the phone's keyboard in bundle_id (default: the app of the last call); no_keyboard, nothing sent, when no keyboard is up. With app rules set, keys that name com.apple.springboard are not sent (input_denied). Reports delivery and retry. |
87
+ | `ios_swipe` | **from**:array, **to**:array, bundle_id:string?, hold_ms:integer?, end_hold_ms:integer?, velocity:string? | – – – O | EXPERIMENTAL. Drag from [x,y] to [x,y] in screen points inside bundle_id (default: the app of the last call), to scroll a list or move something: hold_ms (0-2000, default 50) is the press before the move — a long hold picks an item up; end_hold_ms (0-2000, default 300) is the pause before lifting; velocity slow (default), default or fast. A list usually moves a little less than the finger. With app rules set, a swipe that names com.apple.springboard is not sent (input_denied). Reports delivery and retry; take ios_snapshot to see the result. |
88
+ | `ios_home` | — | – – – O | EXPERIMENTAL. Press the Home button (go to the Home Screen). Ends every earlier element_index; the Home Screen (com.apple.springboard) becomes the default app of later calls. delivered_verified when the app that was in front is seen to leave it. The app rule judges it as com.apple.springboard. Reports delivery and retry. |
72
89