noracu 0.1.4 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,442 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.1] — 2026-11-06
4
+
5
+ ### Fixed
6
+ - `mac_click` at raw x,y no longer lands on whatever covers the point. Before
7
+ sending, it checks that the topmost on-screen window there belongs to the new
8
+ optional `app` (default: the frontmost app; the menu bar counts as the
9
+ frontmost app's). Otherwise it returns `occluded`, naming the owner and
10
+ window layer of what covers the point, and sends nothing. `force: true`
11
+ skips the check. `app` and `force` are refused together with
12
+ `element_index`, which is already re-identified and hit-tested.
13
+ - `mac_key` Return now works in Chrome's address bar. Named keys (return, esc,
14
+ tab, space, delete, arrows, home/end, page keys, F1–F16) are sent as HID
15
+ key events by the accessibility engine instead of by cliclick: Chrome's
16
+ address bar ignored cliclick 5.1's Return. With modifiers, each modifier is
17
+ pressed and released around the key, so no modifier is left held
18
+ afterwards. Chords on a character key (`cmd-c`) still go through cliclick.
19
+ Tested on macOS 27.2 with a separate Chrome instance: the address bar
20
+ navigated, and arrow-down, cmd-arrow-up, esc, return and shift-tab arrived
21
+ with the right key and modifiers; no modifier was held afterwards.
22
+ - `web_accessibility` in `mac_ax_state` and `mac_find` results now says what
23
+ the window holds. Google Chrome refuses `AXManualAccessibility`, so 0.2.0
24
+ reported `unsupported` even when Chrome's pages were readable (Chrome
25
+ started with `--force-renderer-accessibility`). In that case it now reports
26
+ `exposed`. When the app refuses and no web content is found, it reports
27
+ `unsupported` with a `web_accessibility_hint`: use the `browser_*` tools, or
28
+ restart Chrome with `--force-renderer-accessibility` and read again. `mac_find` now reports
29
+ `web_accessibility` too.
30
+
31
+ ## [0.2.0] — 2026-11-06
32
+
33
+ ### Added
34
+ - The Mac layer reads and acts through a new accessibility engine,
35
+ `src/mac-ax.js`: a static JXA script that calls the macOS Accessibility API
36
+ (`AXUIElement*`) directly instead of going through System Events. Reading a
37
+ Finder window of about 500 elements took about 0.15 s on the test Mac
38
+ (macOS 27.2), so the default depth is now 12 instead of 3. Requests reach it
39
+ as JSON on stdin, never in argv.
40
+ - `mac_ax_state` takes `interactive` (only actionable elements), `compact`
41
+ (default true: skips empty layout wrappers), `skeleton` plus `root` (map a
42
+ dense app shallowly, then drill into one element; the drill extends the same
43
+ snapshot), `surface` (`window`, `menubar`, `menu`, `sheet`, `alert`,
44
+ `dialog`, `popover`, `focused`, `app`), `window` (index or title) and
45
+ `max_nodes`. Each element carries `d` (depth), `states` and `actions`; the
46
+ result carries `snapshot_id` and `complete`. Several windows and none focused
47
+ is `ambiguous_window` with the list, instead of reading an arbitrary one.
48
+ - Electron and Chromium apps get their web accessibility tree switched on
49
+ (`AXManualAccessibility` only — never `AXEnhancedUserInterface`, which alters
50
+ window behaviour) when read unless `web_accessibility: false` or
51
+ `NORACU_READ_ONLY=1`; `mac_ax_state` and `mac_find` take `web_accessibility`
52
+ and report the outcome.
53
+ - New tools: `mac_find` (search by role, title, value, text or AXIdentifier),
54
+ `mac_get` (read one element live: full value, states, actions, settable
55
+ attributes), `mac_status` (Accessibility and Screen Recording permission,
56
+ cliclick, displays), `mac_apps` (running apps) and `mac_windows` (windows
57
+ with CGWindowID and bounds, plus displays). All five are observation tools
58
+ and are allowed under `NORACU_READ_ONLY=1`.
59
+
60
+ - `mac_click` with an `element_index` uses the element's own accessibility
61
+ action when it has one (press, show menu, select): no pointer movement, no
62
+ focus change, and it works on windows in the background. Without one it
63
+ clicks physically, but only after a hit test shows that the point reaches the
64
+ element; otherwise it returns `occluded` with what is on top and sends
65
+ nothing. `mechanism` (`auto`, `semantic`, `physical`) forces one path; a
66
+ semantic attempt that fails is reported, not retried physically.
67
+ - Every Mac action result says whether it was delivered
68
+ (`delivered_verified` when a change was observed, `delivered_unverified`,
69
+ `not_delivered`, `unknown`) and whether a retry is safe, and names sheets,
70
+ dialogs or menus it opened. The engine reads the element and its app again
71
+ after acting, because accessibility return codes alone do not prove an
72
+ effect (Finder reports success for an action that does not exist).
73
+ - `mac_type` inserts text through accessibility (`AXSelectedText` at the
74
+ caret, or the whole value with `replace: true`) into an `element_index` or
75
+ the focused element: IME-safe, the clipboard is untouched, it works in a
76
+ background app, and the value is read back. It falls back to keystrokes only
77
+ when accessibility reports no focused element or the focus is a text view it
78
+ cannot write (such as a terminal); a focused button, list or sheet gets no
79
+ keystrokes.
80
+ - New tool `mac_set_value`: text fields, checkboxes, switches and radio
81
+ buttons (idempotent: nothing is sent when the state already matches),
82
+ disclosure triangles and expandable rows, selectable rows, cells and tabs,
83
+ pop-up and menu buttons and combo boxes (picks exactly one matching option,
84
+ else closes the menu again and lists the options), sliders and steppers.
85
+ - `mac_scroll` takes an `element_index`: a scroll area is scrolled at its own
86
+ center (and the result says when the position did not change); any other
87
+ element is scrolled into view.
88
+ - `mac_key` refuses chords that quit, log out, lock, force-quit, delete
89
+ immediately or empty the Trash (`cmd-q`, `alt-cmd-q`, `cmd-shift-q`,
90
+ `cmd-alt-esc`, `ctrl-cmd-q`, `alt-cmd-delete`, `cmd-shift-delete`, …) unless
91
+ `force: true`.
92
+
93
+ - New tool `mac_wait`: waits for a window, text, an element state, a menu, a
94
+ sheet or dialog, an app starting or ending, or a new notification, polling
95
+ accessibility inside one process instead of sleeping; on timeout it returns
96
+ what it last saw.
97
+ - New tool `mac_app`: launch (attaches to a running instance; starts in the
98
+ background unless `activate`; waits for a window), activate, hide, unhide,
99
+ quit. Quit is verified by the process ending; a save dialog that keeps the app
100
+ running is reported, and `force: true` force-quits. Finder, the Dock,
101
+ loginwindow and other session processes, and the MCP host itself, are never
102
+ quit.
103
+ - `mac_app` launch with `cdp_port` (needs `NORACU_ALLOW_CDP=1`) starts a
104
+ Chromium or Electron app fresh with a DevTools port on 127.0.0.1, and
105
+ `browser_launch` with `cdp_port` attaches Playwright to it, so `browser_*`
106
+ drive its web contents while menus, dialogs and windows stay on `mac_*`.
107
+ `browser_close` then only disconnects. Chrome-family browsers get a profile
108
+ of their own under `~/.noracu/cdp-profiles/` (Chrome refuses remote debugging
109
+ on the default profile); an Electron app keeps its own data. An app that is
110
+ already running is refused rather than quit.
111
+ - New tool `mac_window`: focus, raise, minimize, restore, move, resize,
112
+ maximize (the display's visible area), fullscreen, exit fullscreen — by
113
+ CGWindowID from `mac_windows` or by app + window; verified by reading the
114
+ window again.
115
+ - `mac_screenshot` captures one window (`window_id`, also when covered) or a
116
+ given display (`display`).
117
+ - New tool `mac_clipboard_read`: file paths, an image, or text (capped).
118
+ An item marked concealed by a password manager
119
+ (`org.nspasteboard.ConcealedType`) is never returned.
120
+ - New tool `mac_notifications`: lists banners, alerts and an open Notification
121
+ Center (id, app, title, subtitle, body, actions, plus `center_opened` and
122
+ `center_was_open` when `open_center: true`), and dismisses or acts on one by
123
+ its non-empty id (`notification_not_found` when gone), or by index plus a
124
+ non-empty expected app or title that is re-checked.
125
+ - `mac_ax_state` and `mac_find` take `window_id`.
126
+
127
+ - `mac_menu_command` presses the item through the accessibility engine, by
128
+ title or by a `Menu > Item` path, without the app being frontmost, and
129
+ reports delivery; an unknown item is now an error. `phone_home` and
130
+ `phone_app_switcher` use the same path for the iPhone Mirroring menu.
131
+ - `initialize` returns `instructions`: the observe → act → verify loop and the
132
+ delivery / retry rules, for clients that show them to the model.
133
+ - `NORACU_TRACE=<file>` writes one JSON line per tool call (`{ts, tool, args,
134
+ ms, error, code}`): tool, argument names and sizes (never their text),
135
+ duration, error flag and error code prefix — never result text or error
136
+ messages — opening the file `0600` with `O_NOFOLLOW` so a symlink is refused.
137
+
138
+ ### Changed
139
+ - An element is re-identified only inside the window it was seen in, by that
140
+ window's CGWindowID: an index from a window that has since closed is
141
+ `element_no_longer_valid`, even when another window of the app looks the
142
+ same.
143
+ - `mac_click` / `mac_drag` with an index no longer require the snapshot's app
144
+ to be frontmost; the element is re-identified and, for a physical click,
145
+ hit-tested instead.
146
+ - An `element_index` is backed by identity evidence instead of a stored point:
147
+ process, container (window by CGWindowID, open menu, menu bar or app), child
148
+ path, role, subrole, AXIdentifier, label (never the value), frame relative to
149
+ the container, the labels of its ancestors, the child count along its path,
150
+ and the texts of its item (static text and link labels under it or its
151
+ nearest ancestor below the page, toolbar or pane level; a text field's value
152
+ only when it is table content such as a file name; an item that two
153
+ look-alikes share is not used). An element found at its path must agree on
154
+ all of it (the child counts may differ only when its own item vouches for
155
+ it); a labelled element may be found by search only near where it was and in
156
+ the same item (a re-sorted list resolves to the same item; a look-alike that
157
+ arrived since is not taken for it), an unlabelled one never. Digits in a
158
+ unique element's item are ignored, so a character counter next to Send does
159
+ not invalidate it. A drilled (`root`) snapshot or a filtered `mac_find` cannot know
160
+ whether an element is unique, so its elements are checked as look-alikes. So
161
+ a row inserted above, a closed panel or a closed pop-up menu gives
162
+ `element_no_longer_valid`, never a look-alike (a search no longer enters the
163
+ menu bar, whose closed items can still be pressed).
164
+ - Mac `element_index` values are unique for the life of the server: every
165
+ snapshot continues one counter, so an index from an earlier snapshot keeps
166
+ naming its own element after a later `mac_find` or `mac_ax_state`.
167
+ `snapshot_id` is optional and must match the index. A drill (`root`) numbers
168
+ the children from where the root is now.
169
+ - `mac_ax_state` / `mac_find` with `window_id` alone read that window's app;
170
+ `mac_find` `text` with `exact:true` matches the label or the value as a whole
171
+ string, and `id` is a substring match unless
172
+ `exact:true`, as documented.
173
+ - A window or root that does not answer accessibility is `app_unresponsive`, not
174
+ an empty tree reported as complete.
175
+ - Physical clicks fail closed: when the accessibility hit test is inconclusive (an
176
+ error, nothing there, or only a container of the element), the click is sent
177
+ only if the topmost on-screen window at the point belongs to the element's
178
+ app; otherwise `occluded` / `not_actionable`, nothing sent.
179
+ - `mac_drag` with indexes re-identifies and hit-tests the drop target as well as
180
+ the start point.
181
+ - The focus guard (`app` on `mac_key`, `mac_paste`, `mac_type`) compares
182
+ processes, so a bundle id or `.app` path works; it reads the frontmost app
183
+ through the accessibility engine instead of System Events (no Automation
184
+ prompt, no blocking call). `mac_type` with `mechanism: "physical"` and an
185
+ `element_index` types only if the click left the element's app in front.
186
+ - cliclick runs asynchronously under a timer; a cliclick that fails after it
187
+ started is reported `action_failed` with `delivery=unknown, retry=unsafe`
188
+ (only a cliclick that never started is `not_delivered`).
189
+ - The stale-server note also fires when `src/mac-ax.js` changed on disk.
190
+ - `NORACU_READ_ONLY=1` allows 18 tools (the six new Mac observation tools,
191
+ `mac_wait` included, except `mac_wait` with `condition: "notification"` is
192
+ refused and `mac_ax_state` / `mac_find` do not enable `web_accessibility` on
193
+ apps); `mac_clipboard_read` and `mac_notifications` stay outside it.
194
+ - `tools/list` emits a `required` array derived from non-optional arguments on
195
+ every tool that has any, and every tool checks its arguments (types, ranges,
196
+ allowed values, string lengths) before anything runs.
197
+ - Accessibility failures read `permission_denied: …` instead of the raw
198
+ AppleScript error -1719.
199
+
200
+ ### Fixed
201
+ - The server never blocks on a child process any more: screenshots, scroll
202
+ wheel events, `open`, `ps` and the Chromium download run asynchronously under
203
+ a timer, so `ping`, `tools/list` and other calls keep being answered while
204
+ one runs. Two `browser_launch` calls during a first-run Chromium download
205
+ share one download.
206
+ - Observation tools (`mac_ax_state`, `mac_find`, `mac_get`, `mac_windows`,
207
+ `mac_apps`, `mac_screenshot`, `mac_status`) and `mac_wait` no longer join
208
+ the input queue: they wait only for the inputs queued before them, so they
209
+ see the state after those inputs, and later inputs are not held up behind
210
+ them; if those inputs keep the queue busy past the queue limit they return
211
+ `input_busy` instead of reading too early. `mac_wait`'s timeout starts after
212
+ that wait.
213
+ - The server stops when the client closes its stdin instead of lingering, and
214
+ on SIGTERM / SIGINT / SIGHUP shuts down in order: queued calls are dropped
215
+ without acting, no new child process starts (a fallback step cannot act),
216
+ child processes get SIGTERM then SIGKILL after 1.5 s, browsers — also one
217
+ still starting — are closed, and it exits within 3 s. Two `browser_launch`
218
+ calls at once share one launch.
219
+ - A line that is not JSON gets a JSON-RPC parse error (-32700) and a batch
220
+ gets -32600 ("batch is not supported") instead of no answer.
221
+ - With `NORACU_PHONE_TIMEOUT_MS` above 45 s, a queued call waits as long as
222
+ the longest phone call ahead of it before giving up with `input_busy`.
223
+ - An accessibility call to an app that does not answer gives up after 3 s for
224
+ every element, not only for the app element.
225
+ - Accessibility engine timeouts report `delivery=unknown, retry=unsafe` on
226
+ every mutating operation (`mac_click`, `mac_set_value`, `mac_type`,
227
+ `mac_menu_command`, `mac_window`, `mac_app`, `mac_scroll` into view, and
228
+ mutating `mac_notifications` actions), while observation timeouts omit
229
+ delivery fields because nothing was sent.
230
+ - Outer accessibility engine process timeouts include a 12 s margin above
231
+ `timeout_ms` so the engine is not killed while waiting for an element to
232
+ become actionable and settle.
233
+ - Action verification ignores environment-only shifts (`frontmost`,
234
+ `focusedWindow`, `focus`) unless an element or surface property also changed,
235
+ reporting `delivered_unverified` instead of `delivered_verified`.
236
+ - Post-action observation after a physical click or wheel scroll counts an
237
+ element as `gone` only when the element, window or app is actually absent;
238
+ unresponsive or failed reads report `delivered_unverified` with a note
239
+ instead.
240
+ - Wheel scrolling on an element verifies delivery solely from `vscroll` /
241
+ `hscroll` changes, and notes an unchanged scroll position only when that
242
+ scroll check is unverified.
243
+ - Accessibility writes and steps that already executed never report
244
+ `not_delivered` / `retry=safe`: `mac_type` and `mac_set_value` look for the
245
+ value to change for about 0.4 s before returning `not_confirmed`
246
+ (`delivery=delivered_unverified, retry=unsafe`); a caret that moved while the
247
+ value reads the same is `delivered_unverified`, never verified; partial slider/stepper loops
248
+ report `delivered_unverified` with the step count completed, and `mac_window`
249
+ `maximize` reports `delivered_unverified` if moving succeeded before resizing
250
+ failed.
251
+ - `mac_window` `focus` reports `delivered_verified` only when the app is
252
+ frontmost and the target window itself reads focused or main.
253
+ - `mac_set_value` treats mixed-state checkboxes as neither on nor off, pressing
254
+ up to twice until the requested state is reached instead of answering
255
+ "already off".
256
+ - Pop-up and menu-button option matching in `mac_set_value` drops substring
257
+ matching (so `"One"` never picks `"None"`), matching exact, case-insensitive,
258
+ then normalized titles (collapsed whitespace and trailing ellipsis stripped).
259
+ - `mac_wait` fails immediately with `app_not_found` on `window_gone`,
260
+ `text_gone`, `menu_closed` and `sheet_gone` when the app is not running at the
261
+ first check, keeps polling on `text_gone` when window selection is ambiguous,
262
+ and counts `element` `gone` as met only on absent-target errors rather than a
263
+ hung app.
264
+ - `mac_key` states `delivery=delivered_unverified, retry=unsafe` in its result
265
+ text, and `mac_menu_command` documents that items reading disabled in closed
266
+ menus are still pressed and judged by before/after observation.
267
+ - `phone_home` and `phone_app_switcher` require the iPhone Mirroring menu item
268
+ to be enabled (`require_enabled`), refuse with `mirror_not_live` when the
269
+ mirror is paused or not running, return `menu_unknown`
270
+ (`delivery=unknown, retry=unsafe`) without falling back to a swipe when the
271
+ menu call times out, and fall back to the `imctl` gesture only when the
272
+ English menu item is absent. Success output states only that the command or
273
+ gesture was `sent` (`screen not verified`), never that the phone is on the
274
+ Home Screen.
275
+ - Non-import Python tracebacks from `imctl` are reported as
276
+ `imctl_error: <last line>` instead of `imctl unavailable` (kept for missing
277
+ Python or `pyobjc`), and `phone_longpress` passes `--duration` cleanly while
278
+ `imctl longpress` accepts both optional positional and `--duration` syntax.
279
+ - Every `imctl` press/release pair (`tap`, `long_press`, `swipe`,
280
+ `app_switcher`, `scroll_trackpad` phase end, `press_key`, `clear_text`, and
281
+ Command chords) posts its release event in `finally:` so an exception or
282
+ `SIGTERM` never leaves a mouse button, key, `⌘` or trackpad scroll phase held
283
+ down.
284
+
285
+ - Physical clicks and drags on a display left of or above the main one go to
286
+ the right place: cliclick reads a bare negative coordinate as relative to
287
+ the pointer, so negative coordinates are now written absolute (`=-N`).
288
+ - When the accessibility hit test is inconclusive, a physical click is also
289
+ refused when another window of the same app (a floating panel, another
290
+ document) is on top at the point; the Dock's own platter counts as covering,
291
+ only its full-display overlay lets clicks through.
292
+ - `mac_drag` takes `from_index` / `to_index` only (an undocumented coordinate
293
+ form skipped both hit tests); `mac_type` with `element_index` and `app`
294
+ refuses when the element belongs to another app.
295
+ - Results state delivery where they did not: refusals before anything is sent
296
+ (validation, focus guard, unknown or expired index, read-only mode,
297
+ `input_busy`, stopping) say `delivery=not_delivered, retry=safe`; an engine
298
+ that crashed or answered garbage during an action says `delivery=unknown`;
299
+ a failed scroll wheel says `unknown` unless the script never started;
300
+ `mac_window` is verified only by the state asked for (minimized, position,
301
+ size, full screen…), and a pop-up option only when the control shows it;
302
+ `mac_app` launch of a running app with `activate: true` reports the
303
+ activation; `phone_*` input results state delivery and retry too (a refusal
304
+ such as `mirror_not_live` or `expect_not_found` sent nothing; a timeout,
305
+ `type_not_confirmed`, `open_not_confirmed`, `capture_failed` or `focus_lost`
306
+ may have acted).
307
+ - `phone_home` / `phone_app_switcher` find iPhone Mirroring by bundle id, so a
308
+ non-English macOS (where the app's name is localized) still gets the menu
309
+ command or the gesture fallback instead of `mirror_not_live`.
310
+ - Phone input refuses when the mirror stops being live while it is brought
311
+ forward from another Space, and reports `mirror_state_unknown` instead of a
312
+ Python traceback when bringing it forward times out. A long swipe and the app
313
+ switcher's hold stop (and release the button) when the mirror loses focus;
314
+ an invalid long-press or swipe duration sends nothing.
315
+ - A `phone_open` stopped by SIGTERM no longer runs its own trip to the Home
316
+ Screen (it brought the mirror forward and sent a Cmd chord while the server
317
+ may be stopping); after a timeout the server goes Home through the menu.
318
+ - `phone_launch` results state delivery; a call refused because the server is
319
+ stopping, or `phone_type` refused because the clipboard changed before
320
+ anything was typed, says `delivery=not_delivered`.
321
+ - `browser_click` by `element_index` no longer falls back to a synthetic
322
+ JavaScript `click()` when Playwright's actionability checks fail: a covered,
323
+ disabled or detached element returns `occluded`, `not_actionable` or
324
+ `element_no_longer_valid` (`delivery=not_delivered, retry=safe`).
325
+ - Each browser session keeps the tab it is driving as the active page instead
326
+ of taking the last tab: a tab the page opens itself (`window.open`,
327
+ `target=_blank`) is never switched to (another tab becomes active only after
328
+ the active one closes), and an `element_index` used on a different tab, even
329
+ one at the same URL, returns `element_no_longer_valid`. When attaching over
330
+ CDP the session picks a context with non-`devtools://` pages; a standalone
331
+ `browser_launch` is refused while a CDP session is open instead of reusing
332
+ the attached app; a browser or app that closes or disconnects on its own is
333
+ forgotten.
334
+ - `browser_snapshot` names `<input>`, `<textarea>` and `<select>` fields from
335
+ ARIA labels, `<label>`, `placeholder`, the value of button-type inputs, the
336
+ selected option, `name` and `type` (text a user or agent typed is never part
337
+ of a name), and reports truncation — with how many interactive elements were
338
+ left out — past 100; `browser_scroll` accepts `up|down|left|right`, wheels at
339
+ the viewport center and reports the `scrollX`/`scrollY` change (or
340
+ `"did not move"`); `browser_navigate` includes the HTTP status (or
341
+ `"no response"` for same-document navigations); `browser_screenshot` over CDP
342
+ uses CSS pixels; every browser call runs under a time limit; `browser_type`
343
+ takes at most 2000 characters (use `browser_fill` for longer values), so its
344
+ time limit always covers the typing; every `browser_*` input tool (`click`,
345
+ `fill`, `type`, `press_key`, `scroll`, `navigate`, `evaluate`) states
346
+ `delivery=…, retry=…` in its success and error text.
347
+ - `phone_open` that ends in "app not found" says
348
+ `delivery=delivered_unverified` (it had already gone Home and searched
349
+ Spotlight); a screen capture that fails while checking `expect` says nothing
350
+ was sent; an `expect` value that starts with `-` reaches the iPhone driver as
351
+ one `--expect=…` argument and is never read as an option; an invalid
352
+ long-press or swipe duration is refused before iPhone Mirroring is brought
353
+ forward.
354
+ - `mac_window` `focus` / `raise`: when `AXRaise` fails after the window was
355
+ already unminimized or made main, the result follows the state asked for
356
+ instead of reporting `not_delivered`; a physical Mac click whose element does
357
+ not report its window id is checked against its window's (or the snapshot
358
+ window's) id, so another window of the same app on top is still `occluded`.
359
+ - A physical Mac click on an element that reports no window of its own is
360
+ checked against the window found through its parents, also when it came
361
+ from an app-wide snapshot; `mac_app` launch resolves `~/…` and symlinked
362
+ `.app` paths for every launch, not only with `cdp_port`; `browser_launch`
363
+ refusals before anything starts (profile in use, Chromium missing) say
364
+ `delivery=not_delivered, retry=safe`.
365
+ - `phone_type` no longer reports `typed` when only the picture changed after
366
+ the paste (a selection highlight or a results list redraw) and OCR never
367
+ saw the text: it keeps watching for the text and otherwise reports
368
+ `type_not_confirmed`; a one-character paste that OCR cannot read back says
369
+ `delivery=delivered_unverified` (device run 2026-11-06, macOS 27.2,
370
+ iOS 27).
371
+ - `mac_notifications` with `open_center: true` checks positive evidence that
372
+ Notification Center's panel is already open (the menu-bar clock reads selected
373
+ or a Notification Center panel element is present; desktop widgets do not
374
+ count) before clicking the clock, reporting `center_was_open` when
375
+ already open and `center_opened` when opened by the call; empty `id`,
376
+ `expected_app` or `expected_title` strings fail validation; a notification
377
+ that is no longer there returns `notification_not_found`
378
+ (`delivery=not_delivered, retry=safe`), while other accessibility errors keep
379
+ their delivery state and note when the notification is no longer on screen.
380
+
381
+ ### Security
382
+ - `mac_set_value` on an `AXSecureTextField` never reads back or echoes the
383
+ value (`(secure field — value not shown)`), `imctl type` reports character
384
+ count instead of echoing typed text, and `NORACU_TRACE` omits result previews
385
+ and error messages (recording only `code`) and opens the trace file `0600`
386
+ with `O_NOFOLLOW`.
387
+ - `phone_type`, `phone_find` and `phone_open` pass their text to imctl on
388
+ stdin instead of in the process arguments, where every local user could read
389
+ it while the call ran.
390
+ - `imctl` `_require_live` (now also guarding `imctl home`, `imctl app-switcher`,
391
+ and `imctl verify`) probes the mirror overlay before activating iPhone
392
+ Mirroring so a paused or closed mirror refuses (`mirror_not_live`) without
393
+ stealing focus, retries once after bringing the window forward when the state
394
+ is unknown, and fails closed with `mirror_state_unknown` instead of sending
395
+ blind input; `gestures.app_switcher` also verifies that iPhone Mirroring is
396
+ frontmost before mouse-down.
397
+ - `phone_*` argument validation and `imctl` argv hygiene: `phone_key` validates
398
+ allowed key names, `phone_swipe` validates normalized `[0, 1]` coordinates and
399
+ `ms` (`50–5000`), `phone_longpress` validates `duration`, `phone_find`
400
+ (`≤ 200`) and `phone_type` (`≤ 2000`) enforce per-tool text limits, and
401
+ `phone_find`, `phone_open` and `phone_key` pass `--` before positional values
402
+ so leading `-` strings are never parsed as `imctl` options.
403
+ - `mac_paste` no longer loses non-text clipboard contents or re-publishes a
404
+ password manager's concealed item: the whole paste runs in one engine call
405
+ that copies every clipboard item and type aside, writes the text marked
406
+ transient, sends ⌘V only if the clipboard and the frontmost app (by process)
407
+ are unchanged, and puts the items back once the paste shows in the same
408
+ focused element (held at least 0.3 s; else after a 1 s hold) and only if
409
+ nothing else wrote to the clipboard meanwhile; a concealed item (on any of
410
+ the clipboard's items) is not copied and the clipboard is cleared instead.
411
+ When the ⌘V keystroke may not have completed, the clipboard is not put back
412
+ (a late paste can only repeat the text) and ⌘ is released. Universal Clipboard content or more than 64 MB is refused
413
+ unless `force: true`. The result reports what happened to the clipboard
414
+ (`restored: true`, `cleared (previous_concealed)`, `false (changed_externally)`, …).
415
+ - `mac_clipboard_read` withholds the whole clipboard when any of its items is
416
+ marked concealed (not only the first).
417
+ - `mac_key` treats an uppercase ASCII letter in a chord as adding `shift`
418
+ (matching how `cliclick` types it, so `alt-cmd-Q` is recognized as
419
+ `alt-cmd-shift-q` log-out) and ignores an `fn-` prefix when checking refused
420
+ chords; `alt-cmd-q` (Quit and Close All Windows) and `alt-cmd-delete` (Finder
421
+ Delete Immediately) are now refused unless `force: true`.
422
+ - `mac_menu_command` applies the same refused-chord list to menu shortcuts and
423
+ refuses items under the Apple menu (Sleep, Lock Screen, Log Out, Restart,
424
+ Shut Down, Force Quit) unless `force: true`; quitting the MCP host process or
425
+ a macOS session process (Finder, Dock, loginwindow, …) is always refused.
426
+ - `mac_app` force-quit re-checks the target PID's start time before its
427
+ `SIGKILL` fallback so a reused PID is never signalled, and walks up to 32
428
+ ancestor processes when identifying the MCP host.
429
+ - CDP isolation and directory permissions: `browser_launch` with `cdp_port` is
430
+ refused under `NORACU_READ_ONLY=1` even when `NORACU_ALLOW_CDP=1` is set
431
+ (before any network access); `mac_app` launch with `cdp_port` canonicalizes
432
+ `.app` paths (`realpath`, trailing slash stripped) before checking whether the
433
+ app is running, creates `~/.noracu` and `~/.noracu/cdp-profiles` (plus
434
+ `browser-profile`) with mode `0700`, and records `{ pid, wsUrl }` in memory so
435
+ `browser_launch` with `NORACU_ALLOW_CDP=1` attaches only when the port was
436
+ opened by this `noracu` process, its PID is still alive and `/json/version`'s
437
+ `webSocketDebuggerUrl` matches (attaching to any other loopback port requires
438
+ `NORACU_ALLOW_CDP=any`).
439
+
3
440
  ## [0.1.4] — 2026-11-05
4
441
 
5
442
  ### Fixed
package/README.md CHANGED
@@ -21,7 +21,7 @@ One MCP server, three control surfaces:
21
21
 
22
22
  | Layer | Tools | Drives | Status |
23
23
  |---|---|---|---|
24
- | **Mac** | 9 (`mac_*`) | cliclick, screencapture, JXA System Events | stable |
24
+ | **Mac** | 20 (`mac_*`) | macOS Accessibility API (`src/mac-ax.js`, JXA), cliclick, screencapture | stable |
25
25
  | **Browser** | 12 (`browser_*`) | Playwright (persistent profile) | stable |
26
26
  | **iPhone** | 14 (`phone_*`) | iPhone Mirroring via the bundled imctl driver (Python + pyobjc) | experimental |
27
27
 
@@ -31,14 +31,15 @@ The iPhone layer is experimental and ships with its driver (imctl, in `imctl/`).
31
31
 
32
32
  noracu is the local hands, not the model. Your MCP client (Claude Desktop, Claude Code, Cursor) decides what to do; this server only observes and acts on this machine.
33
33
 
34
- - **The server runs entirely on your machine.** No cloud service, no API key, no telemetry, no postinstall scripts. Sole runtime dependency: Playwright. noracu makes no network calls of its own; the only automatic one is the one-time Chromium download on the first `browser_launch` (`NORACU_DISABLE_AUTO_INSTALL=1` turns that off). The browser still fetches the pages you point it at, and your MCP client still sends tool results — screenshots, OCR text — to whatever model it uses.
35
- - **Acts on semantics, not pixels.** Observation returns the accessibility tree (Mac) or ARIA tree (browser) as an indexed list — text, not screenshots. Actions reference `element_index`; indices expire after 30 s, and clicks re-verify the target (tag/name/href/position in the browser, frontmost app on the Mac) before firing. A stale reference returns `element_no_longer_valid` instead of clicking the wrong thing. Screenshots are there when the tree is not enough.
34
+ - **The server runs entirely on your machine.** No cloud service, no API key, no telemetry, no postinstall scripts. Sole runtime dependency: Playwright. noracu makes no network calls of its own; the only automatic one is the one-time Chromium download on the first `browser_launch` (`NORACU_DISABLE_AUTO_INSTALL=1` turns that off). With `NORACU_ALLOW_CDP=1` it also talks to a DevTools port on 127.0.0.1 that it opened itself (`NORACU_ALLOW_CDP=any` for other loopback ports). The browser still fetches the pages you point it at, and your MCP client still sends tool results — screenshots, OCR text — to whatever model it uses.
35
+ - **Acts on semantics, not pixels.** Observation returns the accessibility tree (Mac, read directly through the macOS Accessibility API — about 0.15 s for a 500-element window on our test Mac) or ARIA tree (browser) as an indexed list — text, not screenshots. Actions reference `element_index`; indices expire after 30 s. On the Mac an index is backed by identity evidence (the window's ID, the child path, role, identifier, name) and the element is re-identified before every action; in the browser, tag/name/href/position are re-checked. A gone or changed element returns `element_no_longer_valid` instead of clicking the wrong thing. Screenshots are there when the tree is not enough.
36
+ - **Says what happened.** A Mac action uses the element's own accessibility action when it has one (press, select, set value, insert text — no pointer, no focus change, IME-safe text); a physical click is sent only after a hit test shows that the point reaches the element. Every input action result (Mac, browser and iPhone) states whether it was delivered (`delivered_verified` when a change was observed, `delivered_unverified`, `not_delivered`, or `unknown` when a step timed out or failed mid-action) and whether a retry is safe; Mac actions also name any sheet, dialog or menu they opened.
36
37
  - **One loop, three surfaces.** Native Mac apps and a persistent-profile browser share the `element_index` protocol (observe a tree, act by index). The experimental iPhone layer runs the same observe → act loop on Apple's iPhone Mirroring, with OCR text and normalized coordinates, because the phone exposes no accessibility tree to the Mac.
37
38
  - **Uses your real sessions.** Your logged-in browser profile, your Mac apps — not a hosted VM. Compared with cloud computer-use: neither is universally more reliable; they fail differently. noracu keeps the screen on your machine.
38
39
  - **Off switches that are actually off.** `NORACU_READ_ONLY=1` (observation-only, default-deny), `NORACU_DISABLE_EVAL=1`, and `file://` blocked by default. See [Security](#security).
39
- - **Verifiable.** 39 end-to-end checks (`npm test`), CI on macos-latest, MIT, and the whole server is one file: `src/server.mjs`.
40
+ - **Verifiable.** End-to-end tests (`npm test`; the hardware-free ones run in CI on macos-latest), MIT; the server is `src/server.mjs` plus the Mac accessibility engine `src/mac-ax.js`.
40
41
 
41
- **Not a good fit if** you need multiple browser tabs or sessions (single session for now), you're not on macOS (the Mac and iPhone layers are macOS-only; the browser layer is cross-platform), or you need a finished iPhone layer today (it ships, but experimental — and Apple does not offer iPhone Mirroring in the EU). If you only need browser automation, playwright-mcp has tab management and selector APIs that noracu v0.1 lacks; noracu is for when one agent also has to leave the browser and drive Mac apps.
42
+ **Not a good fit if** you need multiple browser tabs or sessions (single session for now), you're not on macOS (the Mac and iPhone layers are macOS-only; the browser layer is cross-platform), or you need a finished iPhone layer today (it ships, but experimental — and Apple does not offer iPhone Mirroring in the EU). If you only need browser automation, playwright-mcp has tab management and selector APIs that noracu lacks. If you need desktop apps on Windows or Linux, agent-desktop (Vercel Labs) covers macOS, Windows and Linux through each OS's accessibility API; noracu's desktop layer is macOS-only. noracu is for when one agent drives Mac apps, a browser and an iPhone from one server.
42
43
 
43
44
  ## Quickstart
44
45
 
@@ -48,7 +49,7 @@ First success is `mac_ax_state` (or a browser snapshot) — not a click, and not
48
49
 
49
50
  ```bash
50
51
  npm install noracu # server at node_modules/noracu/src/server.mjs
51
- brew install cliclick # required for Mac input (mac_click/type/key/paste)
52
+ brew install cliclick # needed for physical Mac input (mac_key, mac_paste, mac_drag, and physical mac_click/mac_type)
52
53
  ```
53
54
 
54
55
  Or from source: `git clone https://github.com/sgInnora/noracu.git && cd noracu && npm install && npm test` (add `NORACU_CI=1` to skip hardware-gated checks).
@@ -76,25 +77,28 @@ Then **quit the host app completely (including any menu-bar icon) and reopen it.
76
77
 
77
78
  **3. Grant macOS permissions to the host app, not to `node`.** System Settings → Privacy & Security → **Accessibility** and **Screen Recording** (macOS 15: "Screen & System Audio Recording") → enable the host (Claude Desktop / Cursor / your terminal). noracu never appears here. Quit and reopen the host after granting.
78
79
 
79
- **4. Verify.** With Finder in front, call `mac_ax_state` (no args) — it returns an indexed accessibility tree; indices last 30 s. Browser smoke test (no Accessibility needed): `browser_launch` (first run downloads Chromium unless `NORACU_DISABLE_AUTO_INSTALL=1`) → `browser_navigate` → `browser_snapshot` → `browser_click` by index.
80
+ **4. Verify.** Call `mac_status` — it reports whether the host has Accessibility and Screen Recording, and whether cliclick is found. Then, with Finder in front, call `mac_ax_state` (no args) — it returns an indexed accessibility tree; indices last 30 s. Browser smoke test (no Accessibility needed): `browser_launch` (first run downloads Chromium unless `NORACU_DISABLE_AUTO_INSTALL=1`) → `browser_navigate` → `browser_snapshot` → `browser_click` by index.
80
81
 
81
82
  ### Troubleshooting
82
83
 
83
84
  | Symptom | Cause / fix |
84
85
  |---|---|
85
- | `mac_*` fails with error **-1719** | Accessibility not granted to the **host** app — grant it, then quit + reopen the host |
86
+ | `mac_*` fails with `permission_denied: Accessibility permission is missing…` (before 0.2: error **-1719**) | Accessibility not granted to the **host** app — grant it, then quit + reopen the host; `mac_status` shows the state |
86
87
  | Screenshots come back all black | Screen Recording not granted to the host — grant it, then quit + reopen |
87
88
  | `ENOENT` mentioning cliclick | `brew install cliclick` (or set `NORACU_CLICLICK`) |
88
89
  | `spawn node` / `npx` `ENOENT` from a GUI host | use an absolute `node` path in the config — nvm/volta/homebrew shims are not on the GUI `PATH` |
89
90
  | `browser_launch` hangs on first use | one-time Chromium download; or auto-install disabled (`NORACU_DISABLE_AUTO_INSTALL=1`) → run `npx playwright install chromium` |
90
91
  | `phone_*` says `imctl unavailable: no python3 with pyobjc found` | install pyobjc for a python3 (`python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit`; Homebrew python3 is the usual choice) or set `NORACU_PYTHON` — see [iPhone layer](#iphone-layer-experimental) |
91
- | `phone_*` refused with `mirror_not_live: …` ("Connection Paused", "iPhone in Use") | the mirror is paused or the iPhone is unlocked — lock the iPhone, keep it near the Mac, then call `phone_launch` (it clicks Resume) |
92
+ | `phone_*` refused with `mirror_not_live: …` ("Connection Paused", "iPhone in Use", "not running") or `mirror_state_unknown: …` | the mirror is not running, paused, or its state could not be read — lock the iPhone, keep it near the Mac, check `phone_status`, and call `phone_launch` (it starts Mirroring and clicks Resume) |
92
93
  | `phone_launch` says `mirror_setup_required` | iPhone Mirroring shows a setup or welcome screen (e.g. the first launch after a macOS upgrade) — finish it yourself in the iPhone Mirroring window; noracu never clicks through it |
93
94
  | `imctl_timeout: phone … did not finish within …s` | the Mac is under heavy load or the system is stuck — the action may have partly run, so check `phone_status` / `phone_screenshot` before retrying (after `phone_open`, noracu goes back to the Home Screen); the server keeps answering other calls meanwhile |
94
- | `input_busy: …` | an earlier phone or Mac action held the input queue for over 60 s; the call did nothing — retry |
95
+ | `input_busy: …` | an earlier phone or Mac action held the input queue for over 60 s (or `NORACU_PHONE_TIMEOUT_MS` + 15 s); the call did nothing — retry |
95
96
  | `phone_open` returns app not found for an installed app | it only taps the label in Spotlight's Top Hit card — use the name exactly as the phone shows it under the icon (e.g. `拼多多`, not `Pinduoduo`). "Spotlight showed no Top Hit" on an installed app usually means the iPhone's language is not English: `phone_open` reads Spotlight's "Top Hit" label — set `NORACU_TOPHIT_LABELS` to the label your iPhone shows. `open_not_confirmed: … never showed up on the phone` means the pasted name did not arrive (a paste can take several seconds to reach the iPhone) — retry. `phone_open` leaves the app name on the clipboard |
96
- | Typed text comes out re-spaced (e.g. "no ra cu") | a CJK input method is active — use `mac_paste` instead of `mac_type` |
97
- | `element_no_longer_valid` | the snapshot is older than 30 s or the UI changed — re-run `mac_ax_state` / `browser_snapshot` and use a fresh index |
97
+ | Typed text comes out re-spaced (e.g. "no ra cu") | it went in as keystrokes (`mac_type` with `mechanism: "physical"`, or a focused element that takes no accessibility text) while a CJK input method was active — use the default `mac_type` mechanism, or `mac_paste` |
98
+ | `element_no_longer_valid` | the snapshot is older than 30 s, or the element is gone, changed or in a window that closed — re-run `mac_ax_state` / `browser_snapshot` and use a fresh index |
99
+ | `occluded: … — on top: {…}` | a physical click would land on something else (another window, a sheet) — bring the target forward or close what covers it; nothing was sent |
100
+ | `ambiguous_window: … windows: […]` | the app has several windows and none is focused — pass `window` (index or title) or `window_id` from `mac_windows` |
101
+ | `policy_denied: "cmd-q" …` | `mac_key` refuses quit / log-out / lock / force-quit / delete-immediately / empty-Trash chords unless `force: true`; to quit an app use `mac_app` |
98
102
 
99
103
  Node 18 is rejected at startup — use Node ≥ 20. Claude Desktop may start one noracu process per surface (e.g. chat and a second surface); they share the browser profile, so launch the browser from only one at a time.
100
104
 
@@ -102,7 +106,7 @@ Full worked examples: [docs/usage.md](docs/usage.md).
102
106
 
103
107
  ## iPhone layer (experimental)
104
108
 
105
- noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent observes with OCR on the Mac (`phone_screenshot`, `phone_ocr`, `phone_find`), acts at normalized 0–1 coordinates (`phone_tap`, `phone_swipe`, `phone_scroll`), types by pasting (`phone_type`) and opens apps by name (`phone_open`). This is not `element_index`: the phone exposes no accessibility tree to the Mac, so a tap lands where OCR placed the text. The driver (imctl, Python, MIT, about 1,000 lines) ships in `imctl/`.
109
+ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent observes with OCR on the Mac (`phone_screenshot`, `phone_ocr`, `phone_find`), acts at normalized 0–1 coordinates (`phone_tap`, `phone_swipe`, `phone_scroll`), types by pasting (`phone_type`) and opens apps by name (`phone_open`). This is not `element_index`: the phone exposes no accessibility tree to the Mac, so a tap lands where OCR placed the text. The driver (imctl, Python, MIT, about 3,500 lines) ships in `imctl/`.
106
110
 
107
111
  **Apple's requirements** ([support.apple.com/120421](https://support.apple.com/120421)): a Mac with Apple silicon or a T2 chip on macOS 15 or later; an iPhone on iOS 18 or later with a passcode; both signed in to the same Apple Account with two-factor authentication; Bluetooth and Wi-Fi on; the Mac not sharing its internet connection or using AirPlay or Sidecar. **The iPhone must be locked and near the Mac** — unlocking it, or quitting iPhone Mirroring, ends the session. iPhone Mirroring is currently unavailable in the EU. One Mac and one iPhone at a time; camera and microphone are not mirrored.
108
112
 
@@ -110,22 +114,24 @@ noracu can operate a real iPhone through Apple's **iPhone Mirroring**. The agent
110
114
 
111
115
  **Python:** the driver needs a python3 that imports pyobjc (Quartz, Vision, AppKit). Set `NORACU_PYTHON`, or noracu probes `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` once, on the first `phone_*` call. Apple's `/usr/bin/python3` usually lacks pyobjc; Homebrew's python3 plus `python3 -m pip install pyobjc-framework-Quartz pyobjc-framework-Vision pyobjc-framework-AppKit` is the common working setup.
112
116
 
113
- **Mirror state:** `phone_status` reports `live` (the phone's screen is being streamed), `overlay` (the text iPhone Mirroring shows instead, e.g. "Connection Paused" or "iPhone in Use"), `paused` (that overlay offers a Resume button) and `setup` (a setup or welcome screen the user must finish — noracu never clicks it). Detection reads the window's structure and shape (the mirror is a tall or wide phone-shaped window; a setup screen is nearly square), not its text. While the mirror is not live, `phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key` and `phone_open` refuse with `mirror_not_live` instead of tapping the overlay, and `phone_ocr` / `phone_find` start their output with a warning. The mirror pauses after inactivity; `phone_launch` brings it forward and clicks Resume.
117
+ **Mirror state:** `phone_status` reports `live` (the phone's screen is being streamed), `overlay` (the text iPhone Mirroring shows instead, e.g. "Connection Paused" or "iPhone in Use"), `paused` (that overlay offers a Resume button) and `setup` (a setup or welcome screen the user must finish — noracu never clicks it). Detection reads the window's structure and shape (the mirror is a tall or wide phone-shaped window; a setup screen is nearly square), not its text. While the mirror is not live, every phone input tool (`phone_tap`, `phone_longpress`, `phone_swipe`, `phone_scroll`, `phone_type`, `phone_key`, `phone_open`, `phone_home` and `phone_app_switcher`) refuses with `mirror_not_live` — without stealing focus when the mirror is paused or closed — instead of acting on the overlay, and refuses with `mirror_state_unknown` if the mirror state still cannot be determined (`phone_ocr` / `phone_find` start their output with a warning). The mirror pauses after inactivity; `phone_launch` brings it forward and clicks Resume.
114
118
 
115
119
  **Privacy:** whatever the phone shows — notifications, messages, mail, one-time codes — becomes tool output that your MCP client sends to its model. Turn on a Focus, open a neutral app before you start, and begin with `NORACU_READ_ONLY=1` (`phone_status`, `phone_screenshot`, `phone_ocr` and `phone_find` stay allowed; all phone input is refused). iPhone notifications also reach the Mac once Mirroring is set up.
116
120
 
117
121
  **First success:** `phone_status` → `phone_launch` if `live` is not `true` → `phone_screenshot` → `phone_ocr` → `phone_find` + `phone_tap`.
118
122
 
119
- **Known limits:** a tap goes where OCR saw the text, so repeated or misread labels can be hit wrong (`phone_open` cannot tell an app from a contact or website that Spotlight's Top Hit shows under the same name); `phone_scroll` moves lists with trackpad-style scroll events (a vertical `phone_swipe` drag does not scroll a list — use it for gestures such as Home Screen paging); on one tested setup (iPhone 17 Pro Max on iOS 27.0.1, Mac on macOS 26.6.2) iPhone Mirroring draws the phone about 17% larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached; moving the window between displays, changing the main display and relaunching made no difference, and the iOS 27 / macOS 26 version mismatch is the main suspect — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps it only when Spotlight's Top Hit card shows exactly that name (web suggestions, websites and Settings rows of the same name are never tapped), otherwise returns to the Home Screen — it reads Spotlight's English "Top Hit" label, so on an iPhone set to another language it finds nothing until `NORACU_TOPHIT_LABELS` names that label; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu (English macOS) and work without python while connected.
123
+ **Known limits:** a tap goes where OCR saw the text, so repeated or misread labels can be hit wrong (`phone_open` cannot tell an app from a contact or website that Spotlight's Top Hit shows under the same name); `phone_scroll` moves lists with trackpad-style scroll events (a vertical `phone_swipe` drag does not scroll a list — use it for gestures such as Home Screen paging); on one tested setup (iPhone 17 Pro Max on iOS 27.0.1, Mac on macOS 26.6.2) iPhone Mirroring draws the phone about 17% larger than its window at every View size, so the right column and bottom row are cut off and cannot be reached; moving the window between displays, changing the main display and relaunching made no difference, and the iOS 27 / macOS 26 version mismatch is the main suspect — check `phone_screenshot` if taps near the edges miss; `phone_open` types the app name into Spotlight and taps it only when Spotlight's Top Hit card shows exactly that name (web suggestions, websites and Settings rows of the same name are never tapped), otherwise returns to the Home Screen — it reads Spotlight's English "Top Hit" label, so on an iPhone set to another language it finds nothing until `NORACU_TOPHIT_LABELS` names that label; `phone_home` / `phone_app_switcher` use the iPhone Mirroring menu when live (working without python on English macOS, falling back to an `imctl` gesture only when those menu items are absent, and returning `menu_unknown` without a second gesture on timeout) and report only that the command was sent (`screen not verified`).
120
124
 
121
125
  ## Environment variables
122
126
 
123
127
  | Variable | Default | Purpose |
124
128
  |---|---|---|
125
- | `NORACU_READ_ONLY` | unset | `=1` observation-only: a default-deny allowlist of 12 observe + browser-lifecycle tools; every click/type/paste/key/eval tool is refused |
129
+ | `NORACU_READ_ONLY` | unset | `=1` observation-only: a default-deny allowlist of 18 observe + browser-lifecycle tools; every click/type/paste/key/eval tool is refused (`mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"` too; `mac_ax_state` / `mac_find` also skip `web_accessibility`) |
126
130
  | `NORACU_DISABLE_EVAL` | unset | `=1` makes `browser_evaluate` (arbitrary JS) return an error when called (it stays listed) |
127
131
  | `NORACU_ALLOW_FILE_URL` | unset | `=1` lets `browser_navigate` open `file://` URLs (blocked by default) |
128
132
  | `NORACU_DISABLE_AUTO_INSTALL` | unset | `=1` skips the Chromium auto-install on first `browser_launch` |
133
+ | `NORACU_ALLOW_CDP` | unset | `=1` allows `mac_app` launch with `cdp_port` and `browser_launch` with `cdp_port` for ports opened by this `noracu` process (live PID and matching `webSocketDebuggerUrl`); `=any` also allows `browser_launch` to attach to any loopback DevTools port on 127.0.0.1 (always refused under `NORACU_READ_ONLY=1`) |
134
+ | `NORACU_TRACE` | unset | a file path: one JSON line per tool call (`{ts, tool, args, ms, error, code}` — argument names/sizes and error code prefix only, never argument text, result text, or error messages; opened `0600` with `O_NOFOLLOW`, refusing symlinks) |
129
135
  | `NORACU_CLICLICK` | `/opt/homebrew/bin/cliclick` | cliclick binary path |
130
136
  | `NORACU_PYTHON` | auto-probe | python3 used for the bundled iPhone driver; must import pyobjc (Quartz, Vision, AppKit). Unset → first working of `/opt/homebrew/bin/python3`, `/usr/local/bin/python3`, `python3`, `/usr/bin/python3` |
131
137
  | `NORACU_IMCTL_DIR` | bundled `imctl/` | override the driver location (development only) |
@@ -141,13 +147,18 @@ noracu runs with the privileges of your MCP client. It clicks, types, pastes, an
141
147
  "env": { "NORACU_READ_ONLY": "1", "NORACU_DISABLE_EVAL": "1" }
142
148
  ```
143
149
 
144
- - **`NORACU_READ_ONLY=1`** is the safe first-run mode. It refuses every tool not on a 12-name allowlist (the observe tools plus `browser_launch`/`browser_navigate`/`browser_close`); every click, type, paste, and eval tool is denied. `browser_navigate` is on the allowlist, so it can still load a URL.
150
+ - **`NORACU_READ_ONLY=1`** is the safe first-run mode. It refuses every tool not on an 18-name allowlist (the observe tools plus standalone `browser_launch`/`browser_navigate`/`browser_close`; `browser_launch` with `cdp_port` is refused even when `NORACU_ALLOW_CDP` is set); every click, type, paste, and eval tool is denied, and so are `mac_clipboard_read`, `mac_notifications`, and `mac_wait` with `condition: "notification"`, while `mac_ax_state` and `mac_find` do not toggle `web_accessibility` on apps. `browser_navigate` is on the allowlist, so it can still load a URL.
145
151
  - **`NORACU_DISABLE_EVAL=1`** makes `browser_evaluate` return an error when called (it stays listed in `tools/list`). Snapshot, click, and type still work.
146
152
  - **`file://` is refused** unless `NORACU_ALLOW_FILE_URL=1`, so a browser agent can't read `~/Documents` by navigating to it. (The initial navigation URL is scheme-checked; redirects are not — see SECURITY.md.)
147
- - **Focus guard:** pass `app` to `mac_type` / `mac_paste` / `mac_key` and input is refused unless that app is frontmost. Omit `app` and the guard is off.
148
- - **Stale-element protection:** an `element_index` is not a coordinate. It expires after 30 s (`element_no_longer_valid`); a browser click re-checks tag/name/href/position, and a Mac click is refused if the frontmost app changed since the snapshot.
149
- - **iPhone screen is model input:** `phone_screenshot` / `phone_ocr` / `phone_find` return whatever the phone shows — notifications, messages, one-time codes. Use a Focus and a neutral app, and start with `NORACU_READ_ONLY=1` (phone observation allowed, phone input refused). Phone input is also refused while the mirror is paused (`mirror_not_live`).
150
- - **Injection-safe JXA:** string parameters are passed to `osascript` as argv data, never built into the script; the one numeric value (AX read depth) is clamped to 1–10 before use. Regression-tested.
153
+ - **Focus guard:** pass `app` to `mac_paste` / `mac_key` (and `mac_type` when it sends keystrokes) and input is refused unless that app is frontmost. Omit `app` and the guard is off. `mac_type`'s default accessibility path writes into a named element or the app's focused element and sends no keystrokes at all; it never falls back to keystrokes when the focus is a button, list or sheet.
154
+ - **Stale-element protection:** an `element_index` is not a coordinate. It expires after 30 s, and on the Mac it is never reused by a later snapshot. A Mac element is re-identified inside the very window or open menu it was seen in (by window ID), at the same place in that window, under the same labelled ancestors and in the same table row; an element without a label or identifier must still be exactly where it was. A browser click re-checks tag/name/href/position. Otherwise `element_no_longer_valid`.
155
+ - **Hit test before physical clicks:** a Mac click or drag that has to use the pointer is sent only when the element at that point is the target — or, when accessibility cannot tell, when the topmost on-screen window there is that same window (by window ID, not covered by another window of the same app); otherwise `occluded`, with what is on top. A click at raw x,y goes out only when the topmost on-screen window at that point belongs to `app` (default: the frontmost app; the menu bar counts as the frontmost app's); `force: true` skips that check. Keystrokes typed after such a click go out only if the element's app is then frontmost.
156
+ - **Background windows:** semantic Mac actions also work on windows you are not looking at. That is the point (no stolen focus), but it means an agent can act where you do not see it — watch the results' `delivery` and keep high-stakes apps closed.
157
+ - **Guarded keys, menus and quits:** `mac_key` refuses quit / log-out / lock / force-quit / delete-immediately / empty-Trash chords unless `force: true`; `mac_menu_command` applies the same chord list to menu shortcuts and refuses Apple-menu items unless `force: true`. Neither `mac_app` nor `mac_menu_command` ever quits Finder, the Dock, loginwindow, other session processes or the MCP host itself; `force: true` is needed on `mac_app` to force-quit.
158
+ - **DevTools ports are opt-in:** `mac_app` / `browser_launch` with `cdp_port` need `NORACU_ALLOW_CDP=1` (`NORACU_ALLOW_CDP=any` to attach to a port `noracu` did not open itself; always refused under `NORACU_READ_ONLY=1`), bind to 127.0.0.1 only, canonicalize `.app` paths and refuse an app that is already running, and give Chrome-family browsers a separate `0700` profile under `~/.noracu/cdp-profiles`. While the port is open, any local process can control that app (127.0.0.1 has no per-user isolation).
159
+ - **Clipboard, password fields and notifications are private:** `mac_paste` puts the user's clipboard back (every item and type) and never copies an item a password manager marked concealed — it clears the clipboard after the paste instead; `mac_clipboard_read` never returns a concealed item; `mac_set_value` on a secure password field (`AXSecureTextField`) never echoes the value; `mac_notifications` returns notification text verbatim. `mac_clipboard_read`, `mac_notifications`, and `mac_wait` on notifications are outside read-only mode.
160
+ - **iPhone screen is model input:** `phone_screenshot` / `phone_ocr` / `phone_find` return whatever the phone shows — notifications, messages, one-time codes. Use a Focus and a neutral app, and start with `NORACU_READ_ONLY=1` (phone observation allowed, phone input refused). Phone input is also refused when the mirror is not live (`mirror_not_live`) or its state cannot be read (`mirror_state_unknown`).
161
+ - **Injection-safe JXA and stdin text:** the accessibility engine (`src/mac-ax.js`) is a static script that takes its whole request as JSON on stdin — parameters are data, never script source — and `mac_type` (default path), `mac_set_value`, `mac_paste`, and `phone_type` / `phone_find` / `phone_open` pass text on stdin so it does not appear in a process list (`imctl type` never echoes it either). Regression-tested.
151
162
 
152
163
  These switches do not make observed content trustworthy. Screenshot text, accessibility names, and page content are untrusted input to your model — do not let them override the task. Full threat model and per-threat status: [SECURITY.md](SECURITY.md).
153
164
 
@@ -161,7 +172,8 @@ These switches do not make observed content trustworthy. Screenshot text, access
161
172
 
162
173
  - Browser: tab management (list / select / close)
163
174
  - Act vocabulary (browser): `hover`, `set_value`, `wait_for`
164
- - Snapshot diffing to cut token use — pending measurement
175
+ - Measure the token cost of `skeleton` + `root` drill-down against full snapshots
176
+ - Open Notification Center's history when the menu-bar clock is not exposed to accessibility
165
177
  - iPhone: `element_index` over OCR regions, re-checking the text before a tap
166
178
 
167
179
  ## Maintenance