noracu 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +147 -0
- package/README.md +94 -113
- package/SECURITY.md +148 -89
- package/docs/README.zh-CN.md +76 -96
- package/docs/apps.md +4 -6
- package/docs/architecture.md +18 -54
- package/docs/iphone.md +242 -54
- package/docs/known-issues.md +28 -12
- package/docs/tools.md +57 -57
- package/docs/troubleshooting.md +82 -23
- package/docs/usage.md +197 -237
- package/imctl/src/imctl/cli.py +21 -17
- package/imctl/src/imctl/gestures.py +85 -4
- package/imctl/src/imctl/verify.py +1 -2
- package/ios-runner/NoracuRunnerUITests/NoracuRunner.swift +1 -1
- package/ios-runner/NoracuRunnerUITests/RunnerCommands.swift +4 -4
- package/ios-runner/NoracuRunnerUITests/RunnerServer.swift +1 -2
- package/package.json +12 -8
- package/src/approval.js +44 -28
- package/src/doctor.js +60 -12
- package/src/ios-session.js +17 -15
- package/src/ios-setup.js +22 -10
- package/src/ios-xcuitest.js +37 -2
- package/src/mac-ax.js +17 -3
- package/src/mcpb-entry.js +3 -0
- package/src/server.mjs +628 -253
package/docs/usage.md
CHANGED
|
@@ -4,23 +4,22 @@ Worked examples for driving noracu from an MCP client. This assumes the
|
|
|
4
4
|
[Quickstart](../README.md#quickstart) already succeeded: Node ≥ 20, cliclick
|
|
5
5
|
installed, your client configured with an absolute path to `src/server.mjs`,
|
|
6
6
|
and macOS **Accessibility** + **Screen Recording** (called **Screen & System Audio
|
|
7
|
-
Recording** on macOS 15 and later)
|
|
7
|
+
Recording** on macOS 15 and later) turned on for what runs noracu: under Claude Desktop the
|
|
8
|
+
`node` from its configuration, otherwise the host app ([troubleshooting](troubleshooting.md#permissions-and-start-up)).
|
|
8
9
|
Tool schemas (every argument) live in [tools.md](tools.md); this guide is about
|
|
9
10
|
the *flow*.
|
|
10
11
|
|
|
11
|
-
If the client does not start the server, run `
|
|
12
|
-
(`noracu doctor` where the package's bin is on your `PATH`). It prints the client configuration with absolute
|
|
12
|
+
If the client does not start the server, run `npx noracu doctor` in the folder where you installed noracu. It prints the client configuration with absolute
|
|
13
13
|
paths, and says whether Node, cliclick and Playwright's Chromium are where the server will look; `--json`
|
|
14
|
-
gives the same as JSON. It cannot see the macOS permissions — those belong to
|
|
14
|
+
gives the same as JSON. It cannot see the macOS permissions — those belong to what runs noracu — so for them
|
|
15
15
|
ask the client to call `mac_status`.
|
|
16
16
|
|
|
17
|
-
>
|
|
18
|
-
> `
|
|
19
|
-
>
|
|
20
|
-
>
|
|
21
|
-
> `web_accessibility` on apps). Unset it to run the full loop.
|
|
17
|
+
> With `NORACU_READ_ONLY=1` the action steps below (`mac_click`, `mac_type`, `browser_click`, …) are refused, and so
|
|
18
|
+
> are `mac_clipboard_read`, `mac_notifications`, `mac_wait` on `condition: "notification"` and `browser_tabs`; the
|
|
19
|
+
> observe tools and the standalone browser's launch, navigate and close still work, so a page still loads. Unset it
|
|
20
|
+
> to run the full loop ([SECURITY.md](../SECURITY.md)).
|
|
22
21
|
|
|
23
|
-
##
|
|
22
|
+
## Core loop: observe, act by element_index, check delivery
|
|
24
23
|
|
|
25
24
|
Every layer uses the same two-step loop:
|
|
26
25
|
|
|
@@ -37,7 +36,7 @@ Three things to internalize:
|
|
|
37
36
|
the life of the server — every snapshot continues the same counter, so an index
|
|
38
37
|
never names an element of a later snapshot. In the browser it is a position in
|
|
39
38
|
the most recent `browser_snapshot`.
|
|
40
|
-
- Indices
|
|
39
|
+
- Indices are valid for **30 seconds**. After that, acting on one returns
|
|
41
40
|
`element_no_longer_valid` — re-observe and use a fresh index.
|
|
42
41
|
- Acting re-verifies the target before firing. A mismatch is reported as a
|
|
43
42
|
stale element, **not** as a permission error — the fix is always to
|
|
@@ -46,7 +45,37 @@ Three things to internalize:
|
|
|
46
45
|
Reach for a **screenshot** (`mac_screenshot` / `browser_screenshot`) only when
|
|
47
46
|
the tree doesn't carry what you need (canvas, custom-drawn UI, visual layout).
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
### Delivery and retry
|
|
49
|
+
|
|
50
|
+
Every input action — Mac, browser and iPhone — reports `delivery` and `retry`. `delivered_verified`: a change was
|
|
51
|
+
observed. `delivered_unverified`: the call went through but no change was confirmed — read the state (`mac_get`,
|
|
52
|
+
`mac_ax_state`, `browser_snapshot`, `phone_ocr`, `ios_snapshot`) before acting again. `not_delivered` with `retry=safe`:
|
|
53
|
+
nothing was sent. `unknown` with `retry=unsafe`: the call timed out or failed midway — look first. Repeat or substitute
|
|
54
|
+
an action only when `retry=safe`.
|
|
55
|
+
|
|
56
|
+
| Tool | `delivered_verified` only when |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `mac_click` | by the element's accessibility action: the element or its app changed (value, selection, state, focus, windows, sheets, menus); by a physical click: the element is still there, changed, and its window is still on top at the point. A click at raw x,y has no element to check, and a background click that showed no change says so: both `delivered_unverified` |
|
|
59
|
+
| `mac_set_value` | the value read back is the one asked for (text: line endings and outer white space aside); a control already at that value gets nothing (`not_delivered`, `already`) |
|
|
60
|
+
| `mac_type` | on the accessibility path, the value reads back as the old value with the text over the selection that was there (an unreadable caret: `delivered_unverified`); keystrokes are never verified |
|
|
61
|
+
| `mac_paste` | the focused field's value becomes exactly the text pasted over its selection |
|
|
62
|
+
| `mac_menu_command` | something changed after the press (the result names it) |
|
|
63
|
+
| `mac_app` | activate: the app is frontmost; quit: its process ended |
|
|
64
|
+
| `mac_window` | the window, read again, shows the change |
|
|
65
|
+
| `mac_key`, `mac_drag` | never — check the effect (for a drag, the drop target) |
|
|
66
|
+
| `browser_navigate` | the navigation finished (the result gives the final address, status and title) |
|
|
67
|
+
| `browser_fill` | the field's value reads back as the value given |
|
|
68
|
+
| `browser_scroll` | the page reported this call's wheel, every earlier wheel that may have reached the page was verified, and the page then moved the way asked — a page whose own script moves it at that moment cannot be told apart from the wheel |
|
|
69
|
+
| `browser_tabs` | new, select and close: the tab was opened, made active or closed |
|
|
70
|
+
| `phone_open` | the app was seen opening |
|
|
71
|
+
| `phone_type` | OCR saw the pasted text appear within its 2.5 s check where it was not before, below the status bar |
|
|
72
|
+
| other `phone_*` input | never — look with `phone_ocr` or `phone_screenshot` |
|
|
73
|
+
| `ios_launch` | the app reports that it is in front |
|
|
74
|
+
| `ios_type` | the field that took the text holds its old value with the text put in at one place (4 characters or more; shorter text, secure fields, text with a return and unreadable fields: `delivered_unverified`) |
|
|
75
|
+
| `ios_home` | the app that was in front is seen to leave it |
|
|
76
|
+
| `ios_tap`, `ios_swipe`, `ios_key` | never — look with `ios_snapshot` |
|
|
77
|
+
|
|
78
|
+
## Mac apps
|
|
50
79
|
|
|
51
80
|
Observe the app (the frontmost one when `app` is omitted). `interactive: true`
|
|
52
81
|
keeps only what can be acted on:
|
|
@@ -79,17 +108,9 @@ but only after a hit test:
|
|
|
79
108
|
mac_click { "element_index": 1 }
|
|
80
109
|
→ clicked left x1 on element_index 1 (AXTextArea) @ 602,394 via physical click — delivery=delivered_verified, retry=unsafe (changed: selection)
|
|
81
110
|
mac_click { "element_index": 1 } # a sheet now covers the text area
|
|
82
|
-
→ occluded: something else is on top of the element at 602,394
|
|
111
|
+
→ occluded: something else is on top of the element at 602,394 — bring its window to the front or close what covers it — on top: {"role":"AXStaticText","app":"TextEdit"} (delivery=not_delivered, retry=safe)
|
|
83
112
|
```
|
|
84
113
|
|
|
85
|
-
**Read `delivery` and `retry`.** Every input action (Mac, browser and iPhone)
|
|
86
|
-
states both. `delivered_verified`: a change was observed.
|
|
87
|
-
`delivered_unverified`: the call succeeded but nothing observable changed — read
|
|
88
|
-
the state (`mac_get`, `mac_ax_state`) before acting again. `not_delivered` with
|
|
89
|
-
`retry=safe`: nothing was sent. `unknown` with `retry=unsafe`: the call timed
|
|
90
|
-
out or failed mid-action — inspect the state first. Only repeat an action when
|
|
91
|
-
`retry=safe`.
|
|
92
|
-
|
|
93
114
|
Set values by role instead of clicking around (`AXSecureTextField` returns
|
|
94
115
|
`(secure field — value not shown)` and never echoes the value):
|
|
95
116
|
|
|
@@ -104,7 +125,7 @@ When the window closed or the element changed:
|
|
|
104
125
|
|
|
105
126
|
```
|
|
106
127
|
mac_click { "element_index": 3 }
|
|
107
|
-
→ element_no_longer_valid: the element's window is gone
|
|
128
|
+
→ element_no_longer_valid: the element's window is gone — call mac_ax_state or mac_find for a fresh element_index (delivery=not_delivered, retry=safe)
|
|
108
129
|
```
|
|
109
130
|
|
|
110
131
|
Dense apps (Electron, Slack, VS Code): map shallowly, then drill into one region —
|
|
@@ -126,65 +147,7 @@ open `menu`, `menubar`, `sheet`, `alert`, `dialog`, `popover` or the `focused`
|
|
|
126
147
|
element only. `mac_click` also accepts raw `{ "x": .., "y": .. }`, but prefer
|
|
127
148
|
indices.
|
|
128
149
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
One persistent session. Launch → navigate → observe → act → read:
|
|
132
|
-
|
|
133
|
-
```
|
|
134
|
-
browser_launch {} # first run downloads Chromium (once; browser_installing while it does)
|
|
135
|
-
browser_navigate { "url": "https://example.com" }
|
|
136
|
-
browser_snapshot {}
|
|
137
|
-
```
|
|
138
|
-
|
|
139
|
-
`browser_snapshot` returns the page URL, the ARIA tree, and an indexed list of
|
|
140
|
-
clickable elements:
|
|
141
|
-
|
|
142
|
-
```
|
|
143
|
-
URL: https://example.com/
|
|
144
|
-
- document "Example Domain"
|
|
145
|
-
- heading "Example Domain" [level=1]
|
|
146
|
-
- link "More information..."
|
|
147
|
-
|
|
148
|
-
[clickable elements — browser_click accepts element_index]
|
|
149
|
-
[0] link "More information..." (https://www.iana.org/help/ex) @360,210
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
Click by index, then read the resulting page:
|
|
153
|
-
|
|
154
|
-
```
|
|
155
|
-
browser_click { "element_index": 0 }
|
|
156
|
-
browser_read {} # page text; optional { "selector": "h1" }
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
Notes:
|
|
160
|
-
|
|
161
|
-
- **One session, no tab API** in v0.2 — `browser_launch` reuses the existing
|
|
162
|
-
session if one is open, and a tab the page opens itself (`window.open`,
|
|
163
|
-
`target=_blank`) is not switched to. `browser_tabs {}` lists the tabs and `browser_tabs {"action":"select","tab_id":"t2"}` switches to one; Close with `browser_close {}`.
|
|
164
|
-
- **The active page is an http(s) page**, or a tab still on the blank page that
|
|
165
|
-
`browser_launch` or `browser_tabs` opened it on (`file://` with
|
|
166
|
-
`NORACU_ALLOW_FILE_URL=1`). When it comes to show anything else — a blob the
|
|
167
|
-
page made, Chromium's page for a load that failed, a blank page after another
|
|
168
|
-
page — the page tools return `active_page_not_allowed`: `browser_navigate`
|
|
169
|
-
takes the tab to a page again, and `browser_tabs` can open or select another.
|
|
170
|
-
When no open tab may be the active page they return `no_active_page`.
|
|
171
|
-
- The index re-check compares tag, name, href, and position at click time, and
|
|
172
|
-
a snapshot is invalidated if the page navigated since. A mismatch returns
|
|
173
|
-
`element_no_longer_valid` — re-snapshot.
|
|
174
|
-
- `browser_snapshot` returns `page_changed`, and nothing of the page, when the
|
|
175
|
-
page navigated while the snapshot was being taken (another address, a
|
|
176
|
-
fragment, a reload, `history.pushState`) — call it again. `browser_read`
|
|
177
|
-
without a selector does the same. With a selector it returns its text (a
|
|
178
|
-
read that waits for a selector goes on across the page's own move to the
|
|
179
|
-
next page), under a first line that says the page navigated and gives both
|
|
180
|
-
addresses. `browser_evaluate` and `browser_screenshot` hand their result
|
|
181
|
-
over with a note that the page navigated.
|
|
182
|
-
- Don't use `browser_evaluate` just to read a page (`browser_read` does that,
|
|
183
|
-
and `browser_evaluate` is off unless the server runs with `NORACU_ENABLE_EVAL=1`;
|
|
184
|
-
`NORACU_DISABLE_EVAL=1` keeps it off, and it never runs in a `chrome: true` session).
|
|
185
|
-
- `file://` URLs are blocked unless `NORACU_ALLOW_FILE_URL=1`.
|
|
186
|
-
|
|
187
|
-
## 4. Menu commands
|
|
150
|
+
### Menu commands
|
|
188
151
|
|
|
189
152
|
`mac_menu_command` presses the item in the app's own menu bar through
|
|
190
153
|
accessibility — no pointer, and the app need not be frontmost. Give the title the
|
|
@@ -197,7 +160,7 @@ mac_menu_command { "app": "TextEdit", "command": "Edit > Select All" }
|
|
|
197
160
|
→ ran "Edit > Select All" in TextEdit via semantic AXPress — delivery=delivered_verified, retry=unsafe (changed: selection)
|
|
198
161
|
```
|
|
199
162
|
|
|
200
|
-
|
|
163
|
+
### Typing, pasting, keys and the focus guard
|
|
201
164
|
|
|
202
165
|
- `mac_type { "text": "hello" }` inserts into the frontmost app's focused
|
|
203
166
|
element through accessibility (`AXSelectedText`): IME-safe, the clipboard is
|
|
@@ -216,16 +179,18 @@ mac_menu_command { "app": "TextEdit", "command": "Edit > Select All" }
|
|
|
216
179
|
- **Focus guard:** add `"app": "TextEdit"` to `mac_paste` / `mac_key` (and to
|
|
217
180
|
`mac_type` when it sends keystrokes). If TextEdit is not frontmost, the input
|
|
218
181
|
is refused with `focus_lost` and nothing is sent.
|
|
219
|
-
- `mac_key`
|
|
220
|
-
`
|
|
221
|
-
`
|
|
182
|
+
- `mac_key` (and `mac_menu_command`, for an item with such a shortcut) refuses these chords unless
|
|
183
|
+
`"force": true`, in any modifier order: `cmd-q` (quits the frontmost app), `alt-cmd-q` (quits it and closes its
|
|
184
|
+
windows), `cmd-shift-q` (logs out), `alt-cmd-shift-q` (logs out without asking), `alt-cmd-esc` (opens Force Quit),
|
|
185
|
+
`cmd-ctrl-q` (locks the screen), `alt-cmd-delete` (deletes immediately in Finder), `cmd-shift-delete` (empties the
|
|
186
|
+
Trash), `alt-cmd-shift-delete` (empties the Trash without asking). To quit an app, use `mac_app`.
|
|
222
187
|
|
|
223
188
|
```
|
|
224
189
|
mac_type { "text": "你好,世界", "app": "TextEdit" }
|
|
225
190
|
→ typed 5 chars into the focused element of "TextEdit" via semantic AXSelectedText — delivery=delivered_verified, retry=unsafe
|
|
226
191
|
```
|
|
227
192
|
|
|
228
|
-
|
|
193
|
+
### Waiting, apps, windows, clipboard and notifications
|
|
229
194
|
|
|
230
195
|
```
|
|
231
196
|
mac_wait { "condition": "sheet", "app": "TextEdit", "timeout_ms": 5000 } # instead of sleeping
|
|
@@ -240,7 +205,82 @@ mac_notifications {} # ban
|
|
|
240
205
|
mac_notifications { "action": "dismiss", "id": "BC2BF929-…" } # notification_not_found if gone
|
|
241
206
|
```
|
|
242
207
|
|
|
243
|
-
##
|
|
208
|
+
## Browser
|
|
209
|
+
|
|
210
|
+
### Standalone browser, typing and tabs
|
|
211
|
+
|
|
212
|
+
One persistent session. Launch → navigate → observe → act → read:
|
|
213
|
+
|
|
214
|
+
```
|
|
215
|
+
browser_launch {} # first run downloads Chromium (once; browser_installing while it does)
|
|
216
|
+
browser_navigate { "url": "https://example.com" }
|
|
217
|
+
browser_snapshot {}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`browser_snapshot` returns the page URL, the ARIA tree, and an indexed list of
|
|
221
|
+
clickable elements:
|
|
222
|
+
|
|
223
|
+
```
|
|
224
|
+
URL: https://example.com/
|
|
225
|
+
- paragraph: This domain is for use in documentation examples without needing permission. This is not a service; avoid relying on it for testing and monitoring purposes.
|
|
226
|
+
- paragraph: … # the same text in five more languages
|
|
227
|
+
- link "Learn more":
|
|
228
|
+
- /url: https://iana.org/help/example-domains
|
|
229
|
+
|
|
230
|
+
[clickable elements — browser_click accepts element_index]
|
|
231
|
+
[0] a "Learn more" (https://iana.org/help/example-domains) @640,749
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Click by index, then read the resulting page:
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
browser_click { "element_index": 0 }
|
|
238
|
+
browser_read {} # page text; optional { "selector": "h1" }
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
To type, note that neither `browser_type` nor `browser_fill` takes an `element_index`. Click the field by index,
|
|
242
|
+
then type into it (`browser_type` appends keystrokes); or replace a field's whole value by CSS selector with
|
|
243
|
+
`browser_fill`:
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
browser_click { "element_index": 3 } # the field
|
|
247
|
+
browser_type { "text": "dev@example.com" }
|
|
248
|
+
|
|
249
|
+
browser_fill { "selector": "input[type='email']", "value": "dev@example.com" } # no click needed
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Notes:
|
|
253
|
+
|
|
254
|
+
- **One session, several tabs.** `browser_launch` reuses the open session. A tab the page opens itself
|
|
255
|
+
(`window.open`, `target=_blank`) is listed by `browser_tabs {}` and never followed; `browser_tabs` with
|
|
256
|
+
`{"action": "select", "tab_id": "t2"}` makes another tab the active page, `new` opens one, `close` closes a tab
|
|
257
|
+
`browser_tabs` opened (never the last one), and `browser_close {}` ends the session.
|
|
258
|
+
- **The active page is an http(s) page**, or a tab still on the blank page that
|
|
259
|
+
`browser_launch` or `browser_tabs` opened it on (`file://` with
|
|
260
|
+
`NORACU_ALLOW_FILE_URL=1`). When it comes to show anything else — a blob the
|
|
261
|
+
page made, Chromium's page for a load that failed, a blank page after another
|
|
262
|
+
page — the page tools return `active_page_not_allowed`: `browser_navigate`
|
|
263
|
+
takes the tab to a page again, and `browser_tabs` can open or select another.
|
|
264
|
+
When no open tab may be the active page they return `no_active_page`.
|
|
265
|
+
- The index re-check compares tag, name, href, and position at click time, and
|
|
266
|
+
a snapshot is invalidated if the page navigated since. A mismatch returns
|
|
267
|
+
`element_no_longer_valid` — re-snapshot.
|
|
268
|
+
- `browser_snapshot` returns `page_changed`, and nothing of the page, when the
|
|
269
|
+
page navigated while the snapshot was being taken (another address, a
|
|
270
|
+
fragment, a reload, `history.pushState`) — call it again. `browser_read`
|
|
271
|
+
without a selector does the same. With a selector it returns its text (a
|
|
272
|
+
read that waits for a selector goes on across the page's own move to the
|
|
273
|
+
next page), under a first line that says the page navigated and gives both
|
|
274
|
+
addresses. A selector that nothing matches within 10 s returns
|
|
275
|
+
`selector_not_found`. `browser_evaluate` and `browser_screenshot` hand their result
|
|
276
|
+
over with a note that the page navigated.
|
|
277
|
+
- Don't use `browser_evaluate` just to read a page (`browser_read` does that,
|
|
278
|
+
and `browser_evaluate` is off unless the server runs with `NORACU_ENABLE_EVAL=1`;
|
|
279
|
+
`NORACU_DISABLE_EVAL=1` keeps it off, and it never runs in a `chrome: true` session).
|
|
280
|
+
- `file://` URLs are blocked unless `NORACU_ALLOW_FILE_URL=1`.
|
|
281
|
+
|
|
282
|
+
<a id="5b2-your-own-chrome-with-its-sign-ins"></a><a id="your-own-chrome"></a>
|
|
283
|
+
### Your own Chrome, with its sign-ins
|
|
244
284
|
|
|
245
285
|
With `NORACU_ALLOW_CHROME=1` on the server and Chrome's remote-debugging
|
|
246
286
|
switch on (`chrome://inspect/#remote-debugging`, Chrome 144+), the browser
|
|
@@ -262,7 +302,8 @@ Errors: `chrome_not_reachable` (the switch is off, or Chrome is not running),
|
|
|
262
302
|
`chrome_attach_failed` (the dialog was not answered within 60 s),
|
|
263
303
|
`policy_denied` (`NORACU_ALLOW_CHROME` is not set).
|
|
264
304
|
|
|
265
|
-
|
|
305
|
+
<a id="5c-electron-and-chromium-apps-web-contents-through-playwright"></a><a id="electron-over-devtools"></a>
|
|
306
|
+
### Electron and Chromium apps over DevTools
|
|
266
307
|
|
|
267
308
|
With `NORACU_ALLOW_CDP=1` on the server, start the app fresh with a DevTools
|
|
268
309
|
port on 127.0.0.1 and attach the browser layer to it (`NORACU_ALLOW_CDP=any` is
|
|
@@ -282,7 +323,7 @@ running is refused (`cdp_requires_fresh_launch`): quit it first. While the port
|
|
|
282
323
|
is open, any local process can control the app (127.0.0.1 has no per-user
|
|
283
324
|
isolation) — quit it when done.
|
|
284
325
|
|
|
285
|
-
##
|
|
326
|
+
## Screenshots (visual fallback)
|
|
286
327
|
|
|
287
328
|
```
|
|
288
329
|
mac_screenshot {} # whole screen; region crop supported; returns scale + logical_size + screen metadata
|
|
@@ -290,47 +331,72 @@ browser_screenshot { "format": "jpeg", "quality": 60 }
|
|
|
290
331
|
```
|
|
291
332
|
|
|
292
333
|
A `mac_screenshot` that shows only the desktop picture (no other app's windows),
|
|
293
|
-
or comes back black, means Screen Recording isn't
|
|
334
|
+
or comes back black, means Screen Recording isn't on for what runs noracu (`mac_status` says what that is). Remember that any text in a screenshot is **untrusted input** to your
|
|
294
335
|
model — don't let it override the task.
|
|
295
336
|
|
|
296
|
-
|
|
337
|
+
<a id="9-iphone-layer"></a><a id="10-iphone-the-xcuitest-backend"></a>
|
|
338
|
+
## Experimental iPhone layers
|
|
339
|
+
|
|
340
|
+
Both iPhone backends are experimental and off by default. Turning one on, requirements, walkthroughs, limits, privacy
|
|
341
|
+
and recovery are all in [iphone.md](iphone.md).
|
|
342
|
+
|
|
343
|
+
<a id="7-environment-variables"></a>
|
|
344
|
+
## Environment variables
|
|
345
|
+
|
|
346
|
+
Set them on the server entry: `"env": { "NAME": "value" }` in Claude Desktop's or Cursor's JSON; in Claude Code,
|
|
347
|
+
`-e NAME=value` right after the server name — `claude mcp add -s user noracu -e NORACU_READ_ONLY=1 -- <node> <server.mjs>`
|
|
348
|
+
(before the name, `-e` takes the name as one more variable and the command fails with "Invalid environment variable
|
|
349
|
+
format"). Then restart the client. Only the exact value `1` turns a `=1` switch on; `NORACU_READ_ONLY` set to anything
|
|
350
|
+
else is ignored, with a warning line at start-up.
|
|
297
351
|
|
|
298
352
|
| Variable | Default | Effect |
|
|
299
353
|
|---|---|---|
|
|
300
|
-
|
|
|
354
|
+
| **Safety** | | |
|
|
355
|
+
| `NORACU_READ_ONLY` | unset | `=1` read-only mode: only the observe tools and the standalone browser's launch, navigate and close stay; all input-synthesis tools plus `mac_clipboard_read`, `mac_notifications`, `mac_wait` on `condition: "notification"` and `browser_tabs` are refused (`mac_ax_state` / `mac_find` also skip `web_accessibility`) |
|
|
356
|
+
| `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 |
|
|
357
|
+
| `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 |
|
|
358
|
+
| `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`; an `allow` entry that names an app exactly (its bundle id or name, no `*` or `?`) lets that app through the default deny list — `NORACU_DENY_APPS` entries still win; a broken file refuses all Mac and iPhone input (app rules do not judge the browser layer) |
|
|
359
|
+
| **Mac** | | |
|
|
360
|
+
| `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); a call that comes sooner waits out the rest once and answers `user_active` if they are still using it; also puts the pointer back after pointer actions; `0` turns both off |
|
|
361
|
+
| `NORACU_NO_BGPOST` | unset | `=1` turns off background input (physical clicks and named keys use the real pointer and the HID key path) |
|
|
362
|
+
| `NORACU_CLICLICK` | the first of `/opt/homebrew/bin/cliclick` and `/usr/local/bin/cliclick` that exists | cliclick binary path |
|
|
363
|
+
| **Browser** | | |
|
|
301
364
|
| `NORACU_ENABLE_EVAL` | unset | `=1` turns `browser_evaluate` on. It is off by default (`eval_disabled`) because it runs any script in the page; it never runs in your own Chrome (`chrome: true`) |
|
|
302
365
|
| `NORACU_DISABLE_EVAL` | unset | `=1` keeps `browser_evaluate` off whatever `NORACU_ENABLE_EVAL` says (stays listed) |
|
|
303
366
|
| `NORACU_ALLOW_FILE_URL` | unset | `=1` allows `browser_navigate` to open `file://` |
|
|
367
|
+
| `NORACU_ALLOW_CHROME` | unset | `=1` lets `browser_launch` with `chrome: true` work in your own Chrome (see [Your own Chrome](#your-own-chrome)); refused under `NORACU_READ_ONLY=1` |
|
|
368
|
+
| `NORACU_CHROME_TABS` | unset | `all`: with `chrome: true`, your other tabs are listed and can be selected, read and acted on (never closed) |
|
|
369
|
+
| `NORACU_CHROME_DIR` | `~/Library/Application Support/Google/Chrome` | profile folder whose `DevToolsActivePort` `chrome: true` reads |
|
|
304
370
|
| `NORACU_DISABLE_AUTO_INSTALL` | unset | `=1` skips Chromium auto-install on first `browser_launch` |
|
|
305
|
-
|
|
|
371
|
+
| **iPhone (experimental, off by default)** | | |
|
|
372
|
+
| `NORACU_PHONE_BACKEND` | `mirror` | with the iPhone layer on: `xcuitest` lists the nine `ios_*` tools ([iphone.md](iphone.md)) in place of `phone_*`; any other value falls back to `mirror` with a warning on stderr |
|
|
306
373
|
| `NORACU_PYTHON` | auto-probe | python3 for the bundled iPhone driver (must import pyobjc: Quartz, Vision, AppKit) |
|
|
307
|
-
| `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
|
|
308
374
|
| `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) |
|
|
309
375
|
| `NORACU_OCR_LANGUAGES` | `zh-Hans,en-US` | comma-separated Vision OCR language codes for the iPhone screen, in priority order |
|
|
310
|
-
| `NORACU_TOPHIT_LABELS` | `Top Hit` | comma-separated Spotlight Top Hit section label(s) that `phone_open` looks for |
|
|
311
376
|
| `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 |
|
|
312
|
-
| `
|
|
313
|
-
| `NORACU_CHROME_TABS` | unset | `all`: with `chrome: true`, your other tabs are listed and can be selected, read and acted on (never closed) |
|
|
314
|
-
| `NORACU_CHROME_DIR` | `~/Library/Application Support/Google/Chrome` | profile folder whose `DevToolsActivePort` `chrome: true` reads |
|
|
315
|
-
| `NORACU_ALLOW_CDP` | unset | `=1` allows `mac_app` launch with `cdp_port` and `browser_launch` with `cdp_port` for ports opened by this `noracu` process (`=any` for external loopback ports; refused under `NORACU_READ_ONLY=1`) |
|
|
316
|
-
| `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 result or error text; opened `0600` with `O_NOFOLLOW`; a call the client cancelled is logged with code `cancelled`, or `cancelled_queued` if it was still waiting in the input queue) |
|
|
317
|
-
| `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); a call that comes sooner waits out the rest once and answers `user_active` if they are still using it; also puts the pointer back after pointer actions; `0` turns both off |
|
|
318
|
-
| `NORACU_NO_BGPOST` | unset | `=1` turns off background input (physical clicks and named keys use the real pointer and the HID key path) |
|
|
319
|
-
| `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 |
|
|
320
|
-
| `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 |
|
|
321
|
-
| `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`; an `allow` entry that names an app exactly (its bundle id or name, no `*` or `?`) lets that app through the default deny list — `NORACU_DENY_APPS` entries still win; a broken file refuses all Mac and iPhone input (app rules do not judge the browser layer) |
|
|
322
|
-
| `NORACU_LAYERS` | unset (`mac,browser`) | comma-separated `mac`, `browser`, `iphone`: only those layers' tools are listed and callable (the experimental iPhone layer only when `iphone` is named); a call to a tool of a layer that is off says how to turn it on; a name that is not one of the three stops the server at start |
|
|
323
|
-
| `NORACU_PHONE_BACKEND` | `mirror` | with the iPhone layer on: `xcuitest` lists the nine `ios_*` tools (section 10) in place of `phone_*`; any other value falls back to `mirror` with a warning on stderr |
|
|
377
|
+
| `NORACU_TOPHIT_LABELS` | `Top Hit` | comma-separated Spotlight Top Hit section label(s) that `phone_open` looks for |
|
|
324
378
|
| `NORACU_IOS_UDID` | unset | XCUITest backend: the device (or booted simulator) to use; needed when several iPhones are connected (`device_ambiguous` lists them) |
|
|
325
379
|
| `NORACU_IOS_RUNNER_DIR` | `~/.noracu/ios-runner` | XCUITest backend: where `npx noracu ios-setup` builds the runner and where the server looks for it |
|
|
326
|
-
|
|
|
380
|
+
| **Advanced** | | |
|
|
381
|
+
| `NORACU_LAYERS` | unset (`mac,browser`) | comma-separated `mac`, `browser`, `iphone`: only those layers' tools are listed and callable (the experimental iPhone layer only when `iphone` is named); a call to a tool of a layer that is off says how to turn it on; a name that is not one of the three stops the server at start |
|
|
382
|
+
| `NORACU_ALLOW_CDP` | unset | `=1` allows `mac_app` launch with `cdp_port` and `browser_launch` with `cdp_port` for ports opened by this `noracu` process (`=any` for external loopback ports; refused under `NORACU_READ_ONLY=1`) |
|
|
383
|
+
| `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 result or error text; opened `0600` with `O_NOFOLLOW`; a call the client cancelled is logged with code `cancelled`, or `cancelled_queued` if it was still waiting in the input queue) |
|
|
384
|
+
|
|
385
|
+
<a id="8-error-reference"></a>
|
|
386
|
+
## Error reference
|
|
327
387
|
|
|
328
|
-
|
|
388
|
+
Errors take the form `code: what happened — what to do (delivery=…, retry=…)`. Match the code, the word before the
|
|
389
|
+
first colon: it stays the same between versions, the words after it may not. The delivery marker ends every error of a
|
|
390
|
+
tool that acts or changes a session (argument errors included); a tool that only reads may end one with it too.
|
|
391
|
+
`delivery=not_delivered, retry=safe` means nothing was sent and the call can be repeated once the cause is fixed; with
|
|
392
|
+
any other pair, look at the state before acting again. A refusal only the person can lift — the stop file, an app rule,
|
|
393
|
+
read-only mode, a switch that is off, a missing permission — says to stop and tell the person: an agent should not
|
|
394
|
+
retry it or work around it.
|
|
329
395
|
|
|
330
396
|
| Error | Meaning / fix |
|
|
331
397
|
|---|---|
|
|
332
398
|
| `element_no_longer_valid` | index older than 30 s, the element is gone or changed, its window closed, or the page navigated — re-observe |
|
|
333
|
-
| `permission_denied: Accessibility
|
|
399
|
+
| `permission_denied: Accessibility …` | Accessibility is off for what runs noracu: under Claude Desktop the `node` from its configuration, for its extension Claude Helper (Plugin), otherwise the host app (`mac_status` names it) |
|
|
334
400
|
| `occluded: … on top: {…}` | a physical click would land on something else (including another window of the same app); nothing was sent |
|
|
335
401
|
| `ambiguous_window: …` | several windows, none focused — pass `window` or `window_id` |
|
|
336
402
|
| `not_actionable: …` | the element is disabled, off screen, or its window is minimized |
|
|
@@ -342,16 +408,15 @@ model — don't let it override the task.
|
|
|
342
408
|
| `notification_not_found: …` | `mac_notifications` dismiss/act target id or index is no longer on screen or no longer matches `expected_app` / `expected_title` |
|
|
343
409
|
| `input_busy: …` | an earlier phone or Mac action held the input queue past its wait limit; nothing was sent — retry |
|
|
344
410
|
| `ax_timeout: …` | the target app did not answer accessibility calls in time (busy or hung) |
|
|
345
|
-
| `
|
|
346
|
-
| `
|
|
347
|
-
|
|
|
348
|
-
| `browser_evaluate disabled by NORACU_DISABLE_EVAL=1` | eval kill-switch is on |
|
|
411
|
+
| `cliclick_unavailable: …` | cliclick is not installed or could not start — `brew install cliclick`, or set `NORACU_CLICLICK` |
|
|
412
|
+
| `scroll_failed: …` | `mac_scroll`'s wheel input could not start, or did not finish (then `delivery=unknown`) — look with `mac_ax_state` before scrolling again |
|
|
413
|
+
| `read_only: …` | the tool, or the option named (`chrome: true`, `cdp_port`, `mac_wait`'s `notification` condition), is refused under `NORACU_READ_ONLY=1`; nothing was sent — the read tools and the separate browser (`browser_launch {}`) still work |
|
|
349
414
|
| `mirror_not_live: …` | iPhone Mirroring is closed or shows an overlay (paused, "iPhone in Use") — lock the iPhone, keep it near the Mac, call `phone_launch` |
|
|
350
415
|
| `mirror_state_unknown: …` | iPhone Mirroring's state could not be confirmed even after bringing it forward — check `phone_status` before acting |
|
|
351
416
|
| `mirror_setup_required: …` | iPhone Mirroring shows a setup or welcome screen — finish it yourself in its window, then call `phone_launch` |
|
|
352
417
|
| `menu_unknown: …` | `phone_home` or `phone_app_switcher` menu command timed out (`delivery=unknown, retry=unsafe`) — inspect `phone_screenshot` before retrying |
|
|
353
418
|
| `imctl_timeout: …` | a phone step ran past its time limit and was stopped — check `phone_status` / `phone_screenshot` before retrying (after `phone_open`, noracu goes back to the Home Screen); raise `NORACU_PHONE_TIMEOUT_MS` on a slow Mac |
|
|
354
|
-
| `
|
|
419
|
+
| `imctl_unavailable: …` | no python3 with pyobjc was found, or the iPhone Mirroring driver is missing — install pyobjc for a python3 (`python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-Cocoa`) or set `NORACU_PYTHON` |
|
|
355
420
|
| `ax_empty: …` | the app has no window that accessibility can read from the desktop in view. The message says which case it is: the window server lists windows of the app off screen — on another Space, minimized, or the app is hidden (`mac_windows` with `include_offscreen: true` lists them; `mac_app` `activate` brings the app forward and may switch the person's desktop to it) — or the app has no window open. A window on another Space cannot be read |
|
|
356
421
|
| `ambiguous_app: …` | two or more running apps share that name or bundle id; nothing was done — name the one you mean as `pid:<number>` (the message and `mac_apps` list the pids) |
|
|
357
422
|
| `app_not_found: …` | no running app has that name or bundle id — `mac_apps` lists what runs; `mac_app` with `launch` starts one |
|
|
@@ -364,13 +429,27 @@ model — don't let it override the task.
|
|
|
364
429
|
| `ax_error: …` | the accessibility engine gave no readable answer — call again; if it stays, report it with the message |
|
|
365
430
|
| `display_unknown: …` | `mac_screenshot` named a display that is not there (`mac_windows` lists the displays), or the displays could not be read; nothing was captured |
|
|
366
431
|
| `no_window: …` | `mac_scroll` without `element_index`: the frontmost app has no window on screen — pass an `element_index` |
|
|
432
|
+
| `input_denied: …` | the app that would receive the input is on `NORACU_DENY_APPS` (by default terminals, IDEs with a built-in terminal, Orca), under `deny` in the approval file, cannot be identified, or — with app rules set — is the iPhone's Home Screen; nothing was sent. Stop and tell the person; do not retry or work around it |
|
|
433
|
+
| `active_page_not_allowed: …` | the active page shows something the tools do not read (a `blob:` page, a failed load, a blank page after another page, `file://` without `NORACU_ALLOW_FILE_URL=1`); nothing was done — `browser_navigate` to an http(s) page, or `browser_tabs` to open or select another tab |
|
|
434
|
+
| `no_active_page: …` | no open tab may be the active page — open one with `browser_tabs` (`new` with an http(s) `url`) |
|
|
435
|
+
| `page_changed: …` | the page navigated while `browser_snapshot` (or `browser_read` without a selector) was reading; nothing of the page is returned — call it again |
|
|
436
|
+
| `selector_not_found: …` | nothing on the page matched `browser_read`'s selector within 10 s; nothing is returned — call `browser_snapshot` to see the page, or `browser_read` without a selector |
|
|
437
|
+
| `chrome_not_reachable` / `chrome_attach_failed` | `chrome: true`: Chrome's remote-debugging switch is off or Chrome is not running, or its connection prompt was not answered within 60 s |
|
|
438
|
+
| `cdp_requires_fresh_launch: …` | `mac_app` with `cdp_port` refuses an app that is already running — quit it first |
|
|
439
|
+
| `system_alert: …` | XCUITest backend (experimental): an iOS system prompt is up on the phone, so input named for an app is not sent; the person answers it on the phone (this code never comes from the Mac layer: macOS consent and admin dialogs are not recognized) |
|
|
440
|
+
| `type_not_confirmed: …` | the text was sent but not seen arriving as typed (`phone_type`, `ios_type`): `delivery=unknown, retry=unsafe` — read the field (`phone_ocr`, `ios_snapshot`) before typing again |
|
|
441
|
+
| `open_not_confirmed: …` / `app not found` | `phone_open` (experimental): the app was not seen opening, or Spotlight's Top Hit did not show exactly that name; back on the Home Screen — see [iphone.md](iphone.md) |
|
|
367
442
|
| `user_active: …` | the person used the keyboard or mouse in the last `NORACU_USER_IDLE_S` seconds (2 by default), and again while noracu waited out the rest of that time once; nothing was sent — call again once they have stopped |
|
|
368
443
|
| `user_stopped: …` | the file named by `NORACU_STOP_FILE` exists; no input is sent until the person removes it |
|
|
369
444
|
| `approval_required: …` | `NORACU_APPROVAL_FILE` lists the app under `ask` or not at all; nothing was sent, and it stays so until the person adds the app to `allow` |
|
|
370
445
|
| `approval_file_error` / `approval_file_insecure` / `approval_file_owner` / `stop_check_error` | `NORACU_APPROVAL_FILE` or `NORACU_STOP_FILE` is set but blank, cannot be read, is not mode `0600` or is not owned by this user — Mac and iPhone input is refused until the person fixes it (fail closed) |
|
|
371
446
|
| `internal_error: …` | an input tool failed in a way noracu did not plan for; what it had sent by then is not known (`delivery=unknown, retry=unsafe`) — observe before acting again, and report it with the message |
|
|
372
447
|
| `server_shutting_down: …` | the server is closing; nothing was done |
|
|
373
|
-
| `eval_disabled: …` | `browser_evaluate` is off by default — start the server with `NORACU_ENABLE_EVAL=1`; it never runs in your own Chrome (`chrome: true`) |
|
|
448
|
+
| `eval_disabled: …` | `browser_evaluate` is off by default — start the server with `NORACU_ENABLE_EVAL=1`; `NORACU_DISABLE_EVAL=1` keeps it off whatever else is set, and it never runs in your own Chrome (`chrome: true`) |
|
|
449
|
+
| `no_browser: …` | a browser tool was called while no browser session is open (or with a `browser_id` that names none) — call `browser_launch` first |
|
|
450
|
+
| `session_active: …` | `browser_launch` with `chrome: true` or `cdp_port` while a browser session is already open — `browser_close` it first |
|
|
451
|
+
| `profile_in_use: …` | another noracu process (another client, or another window of the same client) has the separate browser's profile open — close the browser that process opened, or use one client at a time |
|
|
452
|
+
| `browser_unavailable: …` | Chromium is not installed, and `NORACU_DISABLE_AUTO_INSTALL=1` keeps `browser_launch` from downloading it or the download failed — run `npx playwright install chromium` |
|
|
374
453
|
| `browser_installing: …` | the first `browser_launch` on this Mac: Playwright's Chromium is being downloaded, which can take minutes, so the call answered after 20 s while the download goes on — call `browser_launch` again in a minute (a download that failed is reported by that call) |
|
|
375
454
|
| `invalid_element_index: …` | the `element_index` is not in the last `browser_snapshot` — take a new one |
|
|
376
455
|
| `navigate_failed: …` | the navigation ended in an error after it had started (`delivery=unknown`) — `browser_snapshot` shows where the page is now |
|
|
@@ -386,126 +465,7 @@ model — don't let it override the task.
|
|
|
386
465
|
| `keyboard_layout: …` | no key of the Mac's keyboard layout types a character the step needs; nothing was sent |
|
|
387
466
|
| `capture_failed: …` | the iPhone Mirroring window (or, on the XCUITest backend, the phone) gave no image — no other kind of capture is used in its place |
|
|
388
467
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
Experimental and off by default: `NORACU_LAYERS=mac,browser,iphone` turns it on
|
|
392
|
-
(section 7). The driver (imctl, Python) ships inside the package. The tools
|
|
393
|
-
need Apple's iPhone Mirroring with the iPhone **locked and near the Mac**
|
|
394
|
-
(unlocking it ends the session; not available in the EU) and a python3 with
|
|
395
|
-
pyobjc (`NORACU_PYTHON`, or the automatic probe described in the README).
|
|
396
|
-
The phone exposes no accessibility tree, so this layer is not `element_index`:
|
|
397
|
-
it observes with OCR on the Mac and acts at normalized 0–1 coordinates.
|
|
398
|
-
|
|
399
|
-
```
|
|
400
|
-
phone_status
|
|
401
|
-
→ {"running": true, "window": {...}, "window_id": 278508, "onscreen": true,
|
|
402
|
-
"frontmost": false, "live": false, "overlay": "Connection Paused", "paused": true, "setup": false}
|
|
403
|
-
|
|
404
|
-
phone_tap {"x": 0.5, "y": 0.5} # refused while the mirror is not live
|
|
405
|
-
→ ERROR: mirror_not_live: Connection Paused — call phone_launch (or imctl resume) first (delivery=not_delivered, retry=safe)
|
|
406
|
-
|
|
407
|
-
phone_launch # brings the mirror to the front and clicks Resume
|
|
408
|
-
→ iPhone Mirroring ready (delivery=delivered_unverified, retry=safe)
|
|
409
|
-
|
|
410
|
-
phone_status
|
|
411
|
-
→ {... "live": true, "overlay": null, "paused": false, "setup": false ...}
|
|
412
|
-
|
|
413
|
-
phone_ocr # OCR of the Mirroring window (captured by window id)
|
|
414
|
-
→ (0.50,0.06) 'Settings' [1.00]
|
|
415
|
-
(0.18,0.31) 'FaceTime' [1.00]
|
|
416
|
-
-- 2 hits
|
|
417
|
-
|
|
418
|
-
phone_find {"text": "Settings"}
|
|
419
|
-
→ (0.50,0.06) 'Settings' [1.00]
|
|
420
|
-
|
|
421
|
-
phone_tap {"x": 0.50, "y": 0.06}
|
|
422
|
-
→ tapped (0.5, 0.06) (delivery=delivered_unverified, retry=unsafe)
|
|
423
|
-
```
|
|
424
|
-
|
|
425
|
-
`live` / `overlay` / `paused` / `setup` come from the window's structure and
|
|
426
|
-
shape, not its language: a live mirror is a single empty hosting view;
|
|
427
|
-
"Connection Paused", "iPhone in Use" and similar states add text and a button;
|
|
428
|
-
a setup or welcome screen (`setup: true`) sits in a window that is not
|
|
429
|
-
phone-shaped, and `phone_launch` never clicks it. While the mirror is
|
|
430
|
-
not live, every phone input tool (`phone_tap`, `phone_longpress`, `phone_swipe`,
|
|
431
|
-
`phone_scroll`, `phone_type`, `phone_key`, `phone_open`, `phone_home` and
|
|
432
|
-
`phone_app_switcher`) refuses with `mirror_not_live` (or `mirror_state_unknown`
|
|
433
|
-
when the state cannot be read), and `phone_ocr` / `phone_find` start with a
|
|
434
|
-
`warning: mirror not live …` line.
|
|
435
|
-
|
|
436
|
-
`phone_scroll {"direction": "down", "distance": 0.5}` moves the list under the
|
|
437
|
-
mirror by about half a window, with trackpad-style scroll events; a vertical
|
|
438
|
-
`phone_swipe` drag does not scroll lists in iPhone Mirroring, so keep swipes
|
|
439
|
-
for gestures such as Home Screen paging. Start a page swipe in the empty strip
|
|
440
|
-
just above the Dock (y about 0.80): the mirror delivers a drag as pointer
|
|
441
|
-
input, and one that starts on an app icon picks the icon up and moves it — it
|
|
442
|
-
can rearrange the Home Screen or drop the icon on another one and make a folder.
|
|
443
|
-
|
|
444
|
-
`phone_type` pastes through the clipboard with a real Command-V chord (never
|
|
445
|
-
echoing the typed text), saving every clipboard item and type, clearing
|
|
446
|
-
concealed or transient items instead of copying, and restoring the clipboard
|
|
447
|
-
once OCR sees the pasted text appear on the phone at a spot where it was not
|
|
448
|
-
before the paste, below the strip at the top where the status bar and
|
|
449
|
-
notification banners are drawn (text already on screen, or the same words in a
|
|
450
|
-
banner, do not count); only that sighting makes the result
|
|
451
|
-
`delivered_verified`. Universal Clipboard or >64 MB items are not copied and
|
|
452
|
-
leave the typed text on the clipboard. A text shorter than four characters
|
|
453
|
-
(spaces and case aside) is never confirmed and never restores the clipboard. If
|
|
454
|
-
the text only shows up a few seconds late (reported as typed but
|
|
455
|
-
`delivered_unverified` — OCR cannot tell the paste from a line that repeats it,
|
|
456
|
-
such as a search result, so read the field before typing again) or the call
|
|
457
|
-
ends in `type_not_confirmed`, the clipboard also keeps the typed text.
|
|
458
|
-
`phone_open {"app": "Calculator"}` opens Spotlight through iPhone Mirroring's
|
|
459
|
-
own shortcut, pastes the name, and taps it only when Spotlight's Top Hit card
|
|
460
|
-
shows exactly that name (a web suggestion or Settings row with the same name
|
|
461
|
-
is never tapped); otherwise it returns to the Home Screen and reports
|
|
462
|
-
`app not found` (`delivery=delivered_unverified, retry=safe`). A paste can take
|
|
463
|
-
several seconds to reach the iPhone: when the
|
|
464
|
-
name never shows up, `phone_open` waits up to 15 s and then reports
|
|
465
|
-
`open_not_confirmed` (retry) rather than `app not found`. OCR rarely reads a
|
|
466
|
-
one- or two-letter name such as `X`, in the Top Hit card or the search field,
|
|
467
|
-
so for those `phone_open` does not wait the 15 s: it reports `open_not_confirmed`
|
|
468
|
-
and taps nothing — open such an app from its Home Screen icon
|
|
469
|
-
(`phone_screenshot`, then `phone_tap`). Use the name the phone shows under the icon (`拼多多`, not
|
|
470
|
-
`Pinduoduo`); it reads Spotlight's English "Top Hit" label, so on an iPhone
|
|
471
|
-
set to another language set `NORACU_TOPHIT_LABELS` to the label the phone shows.
|
|
472
|
-
|
|
473
|
-
Privacy: everything the phone shows — notifications, messages, one-time
|
|
474
|
-
codes — becomes tool output that your MCP client sends to its model. Use a
|
|
475
|
-
Focus, open a neutral app first, and start with `NORACU_READ_ONLY=1`
|
|
476
|
-
(phone observation allowed, phone input refused). `phone_home` /
|
|
477
|
-
`phone_app_switcher` go through the iPhone Mirroring menu while the mirror is
|
|
478
|
-
live — working without python/pyobjc on English macOS, refusing when paused or
|
|
479
|
-
closed, returning `menu_unknown` without a fallback swipe on timeout, and
|
|
480
|
-
falling back to `imctl` when the English menu item is absent on non-English
|
|
481
|
-
macOS.
|
|
482
|
-
|
|
483
|
-
## 10. iPhone: the XCUITest backend
|
|
484
|
-
|
|
485
|
-
Experimental and opt-in (`NORACU_PHONE_BACKEND=xcuitest`, with the iPhone layer on); the `ios_*` tools then
|
|
486
|
-
replace `phone_*`. Requirements and the one-time `npx noracu ios-setup` are in the
|
|
487
|
-
README. The iPhone must be unlocked.
|
|
488
|
-
|
|
489
|
-
```
|
|
490
|
-
ios_status → device, locked?, runner built?, runner running?
|
|
491
|
-
ios_launch { bundle_id: "com.apple.Preferences" } → in front (delivered_verified)
|
|
492
|
-
ios_snapshot { interactive: true } → elements: [{ i, type, label, value, frame }]
|
|
493
|
-
ios_type { element_index: 12, text: "wifi" } → verified when a field shows the text
|
|
494
|
-
ios_tap { element_index: 31 } → sent; look again
|
|
495
|
-
ios_snapshot → the new screen, new indexes
|
|
496
|
-
ios_home → Home Screen; earlier indexes end
|
|
497
|
-
```
|
|
498
|
-
|
|
499
|
-
- Indexes last 30 s and are unique across snapshots. Before one is used the app
|
|
500
|
-
is read again; `element_no_longer_valid` means the element moved, changed, or
|
|
501
|
-
its app left the front — take a new `ios_snapshot`. An app that has just come
|
|
502
|
-
to the front may still be filling in its rows: snapshot again after a moment.
|
|
503
|
-
- `bundle_id` defaults to the app of the last call (`ios_launch` sets it;
|
|
504
|
-
`ios_home` sets it to `com.apple.springboard`).
|
|
505
|
-
- Coordinates (`ios_tap` x,y, `ios_swipe` from/to, element frames, the size
|
|
506
|
-
`ios_screenshot` reports) are screen points.
|
|
507
|
-
- Scroll with `ios_swipe` (a list moves a little less than the finger); press
|
|
508
|
-
return or delete with `ios_key`; a long press is `ios_tap` with `duration_ms`.
|
|
468
|
+
### iPhone, XCUITest backend (experimental, off by default)
|
|
509
469
|
|
|
510
470
|
| Error | Meaning / fix |
|
|
511
471
|
|---|---|
|
|
@@ -514,7 +474,7 @@ ios_home → Home Screen; earlier indexes end
|
|
|
514
474
|
| `device_locked` / `lock_unknown` | the iPhone is locked, or its lock state could not be read — nothing was sent or read; unlock it |
|
|
515
475
|
| `input_denied: … while app rules are in force` | app rules are set (`NORACU_APPROVAL_FILE` or `NORACU_DENY_APPS`): no input that names `com.apple.springboard` is sent — not even one tap on a button of a system prompt (answer those on the phone). It is refused before a runner is started, so the refusal changes nothing on the phone. Open apps with `ios_launch`, go home with `ios_home` |
|
|
516
476
|
| `home_not_confirmed` | Home was pressed but the app is still in front — after 3 s, or when its state was last read before a read failed (the result says which); look with `ios_screenshot` |
|
|
517
|
-
| `runner_not_started` | `NORACU_READ_ONLY=1` is set:
|
|
477
|
+
| `runner_not_started` | `NORACU_READ_ONLY=1` is set: read-only mode does not start the runner (starting it puts the runner's app in front on the iPhone) — unset it to read the screen |
|
|
518
478
|
| `xctest_issue` | XCTest reported a failure while the command ran, or after an earlier one had answered. The test session is ended either way and the next call starts a new one. For an input that may have gone out the delivery is unknown; a command that was not run says `delivery=not_delivered`. Look with `ios_snapshot` before acting again |
|
|
519
479
|
| `app_not_running` / `app_not_foreground` | the app is not in front — `ios_launch` it first; nothing was sent |
|
|
520
480
|
| `system_overlay` | the iPhone is showing something of its own over the app (Control Center pulled down, or the Home Screen while an app is still coming forward) while the app still reports that it is in front, so a tap would land on that instead — nothing was sent. Look again with `ios_snapshot` in a moment; if it is still there, `ios_home` closes it but leaves the app for the Home Screen (`ios_launch` brings the app back) |
|