Skip to content

Own macOS native engine (#117): M0, M1a, M1b — cua Engine.app behind CUA_NATIVE_ENGINE (default unchanged) - #176

Merged
SSFSKIM merged 243 commits into
mainfrom
feat/117-own-native-engine
Oct 21, 2026
Merged

SSFSKIM merged 243 commits into
mainfrom
feat/117-own-native-engine

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 21, 2026

Copy link
Copy Markdown
Owner

Part of #117 (cua's own macOS native engine). This PR lands milestones M0, M1a and M1b of the living spec, docs/doperpowers/specs/2026-10-18-own-native-engine-design.md. M2a to M6 follow as their own PRs.

Squash-merge only. Commit 3fcc4e4 added native/engine/.build (about 217 MB) to the branch's history, and ccbb824 untracked it. Squashing keeps those blobs out of main. The branch's commits stay reachable through this PR's head ref. The reasoning is in the spec's Decision Log, under "landing".

What changes for a user

Nothing by default. CUA_NATIVE_ENGINE defaults to vendor, so macOS sessions still use OpenAI's SkyComputerUseService on the vendor host. What's new:

  • cua Engine.app (native/engine/, Swift, Apple frameworks only) answers the computer surface's methods. This PR covers observation, click, press_key, type_text, the screenshot at the vendor's size, lineage tokens and the policy with the forbidden list. The remaining methods, settle and intervention are M2a.
  • cua engine build|approve|status|stop builds and signs the engine with the owner's Apple Development identity. Over SSH it signs through a one-shot job in the GUI domain, and the identity is never printed. The owner approves the engine once at the console. It lives in an approved location under ~/Library/Application Support/cua/engine/.
  • CUA_NATIVE_ENGINE=cua selects cua's engine, with cua's own REPL host. Every result carries the attestation _meta['cua/nativeEngine'], and doctor reports the engine.
  • The service is src/services/engine/: client, renderer, diff, policy and numbering. Approval memory lives in the supervisor.

Evidence (the mini, macOS 27, approved build 4b31b8e61195)

  • Comparison A (engine and service, same host; three runs a side, same sitting): compare --engines passes. It's docs/doperpowers/research/2026-10-18-own-native-engine/m1b/comparison-a/.
  • The selection table, live: 303 rows, oracle passed.
  • Goldens: all four scenes (TextEdit, Finder, Chrome for Testing, an Electron fixture) recorded live on both engines in one hold, at the first attempt, and installed under test/native-goldens/. The expiry audit deleted 23 of M1a's 26 engine-fault corrections; the 3 left are TextEdit scene-state declarations. One vendor defect is declared: Finder's list prints of 100 items for a 205-item list, because the vendor prefetches at most 100 children. cua keeps the true count.
  • Reports: M0 spike, M1a, M1b.

Reviews and CI

  • M1a: reviewer-high on the whole branch (a807827..bd1136f), correct; its Minors fixed or tracked.
  • M1b: reviewer-high on b2ccdc3..84c6eee, no material findings. The later delta (harness, tests, goldens, docs; no change under src/ or native/) was reviewed at medium and low, both correct after their fixes.
  • Hosted CI (ci-kit): GREEN 6/6 on d6012ad (39548542007) and on 1f4a23a (39550783407). The commits after those change docs only.
  • npm test: 3,520 passed, 0 failed. swift test: 221 passed.

Known residue

Listed in the M1b report:

  • whether get_app_state should settle on a still-filling web tree (M2a);
  • the minimized-window reopen, deliberately not copied;
  • M4's install reading the sign wait;
  • three flake rows in tech-debt-tracker.md.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)

…ons A/B/C, facade-vocabulary protocol, input routes and activation probe, settle by AX notifications, target-keyed intervention, goldens modulo renumbering, selection table, module tree in M6)
… in; design folds E's facts (grammar literals, lazy pasteboard, intervention lock, focus enforcer names, symbol correction)
…-g and socket liveness, HID-plus-app intervention, concealed secrets never pasted, settle cap, approval memory in the supervisor, setup.activate on the baseline, engine --probe)
…ne per Mac, engine_not_installed rows, harness-owned Chrome instance and Electron fixture, M1/M2 split by verification, total promote rule, real CLI forms)
…step and pending/approved records, scene processes with unique bundle ids, total selection table, HID-and-frontmost intervention, concealedInputUnavailable, engine.lock, activation watcher and interval check, 6 MiB skyshot budget)
…uildEngine and cua engine build, keyed typeText with the layout's virtual keys and the per-context input rule, the pre-action guard on every input kind, positive intervention cells and the probe's HID source, the default-engine vendor-host row and refusal precedence, serviceMs as the wrapper's total, the sheet variant on TextEdit with the fixture as user window, Finder refusal narrowed, raw Skyshot goldens from M0, the approve request)
…atrix in frontmost and background regimes with the non-interference cells judged by outcome, post-M6 same-engine baseline gate, pre-action refusal validity rule on receivedAt and hidIdleMs, mid-action input-source switch stops keyed typeText, unversioned approved location, identity resolution and keychain prerequisites in M1b, cua engine approve as a prompt-shutdown-relaunch-capture loop, cua engine status, spike carries approve/shutdown and a minimal probe, committed policy Swift file, acceptance lines on the mini, probe focus enables AXManualAccessibility)
…alf (grant observability made a probe question with both relaunch flows independent of it, connections excludes the requester, post-M6 same-engine forms for parts 1/3/5 per release, launch-path cell confined, direct input-source check with inputSourceChanged, interval validity on the intervention cells and keystroke --at, probe focus waits)
…lity half (input meta with the four times on results and errors, pre-action refusal named userIntervened, acceptance 8 on an archive-installed scratch home, acceptance 1 explicit engine, M0 copy stops and stages, re-runnable signing check, M1b builds in the harness checkout, approve in the method list); review loop converged
… peer entry cited, approve in the protocol prose, staged rebuild in probe (f), engineStatus in M1b's interfaces)
…service's per-call shape, no permission prompt before the sitting)
… bundle may be granted on the MacBook for development; the mini's certificate is issued on the mini through Xcode)
…-link table recovered, 27 design divergences) and the Ghidra tools
…gged pid-posted clicks, HID-source keys, fake-activation route 3, AXPick, the 20-attribute prefetch with the private hierarchy call priced, enablement one attribute never both, vendor settle (250 ms quiet, no floor, deferred to the next observation), tap-based intervention with per-event attribution and the 5 s debounce, paste with rtf and the effect poll, the id-keyed diff with its one live header, no App= line; cua's departures labelled (Decision Log entry 9); mini signing identity validated and pinned
…ver (framing, 8 MiB bound, lock, uid check), ping/status/approve/shutdown, list_apps, resolve_app, get_app_state with screenshot; assemble.mjs; unit tests
…ent type, source pid, target pid, window id only; torn down with the last connection; pinned by a unit test)
…ith fixed states, pairings, ten targets each and refusal preconditions; Chrome for Testing 155.0.8059.84 pinned by SHA-256 with its cache placement; the loopback scene page; the Electron fixture app and its builder; FrontWindowProbe; electron 44.9.0 dev dependency)
…by type-select on its list, not the search field; fixture shown inactive; match modes on targets; sheet variant as ordered steps; down exits 1 when a scene stays up; Gatekeeper claim worded as expected; NSPrincipalClass pinned; remote-client timing debt logged)
… 240-character name so concurrent use has a long action; expected interval and the scheduled probe post recorded
…robe (f)'s first data point (grant visible only after relaunch; the capture confirmation appeared once per bundle)
…first MacBook timing against the vendor's in-cell figure; grants survive a relaunch
… the optional attributes and the width descriptor; indexes over emitted nodes (T1 review)
…ur specification from A, E and F (M0): every rule source-tagged, vendor and cua side by side where cua departs, the three vendor defects marked, the pressKey table in full, verbatim sentences, the timing table, 19 open points for M1a/M2a (transformations versus numbering, Skyshot node fields, cua/settle placement, get_app_state during the debounce, cross-connection paste) and F §13's 27 divergences mapped
… observation result; Node/Skyshot gain the renderer-grammar fields (help, placeholder, valueDescription, url, index ranges, traits, domClassList, selectable/focusable, valueType, selectedElements), checked dropped; three engine/service-split points marked Open for critique
…nt (nativePipe, ping version/build check, launch and 5 s reconnect, one in flight, 120 s deadline, 8 MiB frames, the vendor's error classes), stand-in renderer of F §2.4–2.6, service behind the real sky wrapper (resolve_app before every app-scoped call, one elicitation per app answered from memory, result meta, raw Skyshot by a spike-only request), serve.mjs running cua's own host through buildLaunch and spawnUpstream; unit tests
…n the observation result, the proxy's turn metadata stamped by serve.mjs, per-call meta reset on every call, the stand-in renderer on the 25fa9b1 Skyshot (menuBar, selected elements, shown, valueType, disclosable, Rows/Columns), the deadline computed at write time
…rvation path

Caps: 200 levels marked, the width rule (100, visible subset, omitted above
499) carried as Node.shown. Attributes: the vendor's 20 plus AXSelectable,
AXDOMClassList, position and size, decoded once for both routes; the public
per-element fetch and the dlsym'd AXUIElementCopyHierarchy (its four options),
chosen per request (prefetch), each with its own timings; the 25fa9b1 fields
(valueType, domClassList, focusable/selectable/disclosable, selectedElements,
Skyshot.settle; checked dropped). Enablement: one attribute by what the app
lists, web-shaped apps only, the 100 ms + 1 s web-area wait, switchable and
timed. Primary window with the AXWindows.last fallback; menu-bar items in
Skyshot.menuBar. Indexes: sibling-structural CFEqual inheritance with the
stable run, disableDiff's fresh lineage, re-resolution by the eleven
attributes only after layoutChanged/uiElementDestroyed with both ambiguity
sentences, never-reused indexes, carry-over past a cut. Settle: deferred to
the next get_app_state, ten notifications, 250 ms quiet sampled at 100/250 ms,
busy veto, 5 s cap reported, counts in timings. SCShareableContent cached.
Exit reasons in os_log (io.github.ssfskim.cua.engine), a live socket exits.
JSON-escape-aware byte estimate; deadline checked within a node; shutdown
atomic with accept. Swift unit suite (37) run from test/native-engine-units.

Methods.swift: one line, shutdown calls server.beginShutdown(connection)
instead of server.others(than:). Protocol.swift, Input.swift, Keyboard.swift
and Probe.swift untouched; click/press_key/type_text stay notImplemented and
are pinned by a test.
…emselves

settledState accepted a matching read before checking the bound, and each get_app_state kept the
engine client's 120 s default deadline, so two identical 6 s reads settled at 12.5 s and a stalled
read delayed the refusal by about two minutes. Each read now carries the bound's remaining time as
its engine deadline, no read starts once the bound is reached, a read cut by the deadline ends the
settle, and an answer arriving past the bound is never accepted; all three refuse as `unstable`.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…ow's structure, and a bounded toggle loop

The closing hold showed Finder's keys cannot predict what its window draws: on macOS 27 an unset
ShowStatusBar is drawn while Finder's toggle state starts hidden, so the first ⌘/ wrote 1 with the bar
unchanged and the second wrote 0 and hid it. scenes-mac-finder.mjs gains finderChromeShown, which reads
the sidebar (an outline besides the run's list), the status bar (its statusBar/statusBarText identifiers)
and the path bar (an AXList outside the list and the toolbar, kept conservative) from the Skyshot's
structure, never its text, and toggleUntil, which observes before each toggle and sends a part's key until
the window shows the wanted state, at most twice, refusing a part that still differs. Wiring follows.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…by observing its window, against the owner's saved visible state

The closing hold on macOS 27 showed Finder's keys do not say what its windows draw, and Finder reads them
only at launch: with ShowStatusBar unset a window draws the bar while the toggle state is hidden, so the
precomputed ⌘/ "showed" a bar already there, and an external defaults write did not hide it. Replaying
the toggles at teardown cannot bring back an unset key either.

- Setup: after list view and deselect, the device observes the run's window (a settled read that must be
  the run's own window) and saves the owner's visible chrome beside the keys in the harness-wide record,
  first record wins, so a later up after a dead run keeps it. Each part is then toggled only while the
  window still shows it, at most twice, refusing a part that will not hide; the toggles sent are counted
  in the record as information.
- Teardown: each part is toggled by observation until the window shows the saved visible state (at most
  twice, refusing otherwise) and marked restored, then the window is closed and down writes the keys back
  as before, an unset key deleted.
- With no window (restore-finder, or a cleanup whose window is gone) only the keys are written; the
  output says the visible state is unrestored and the record is kept for the next run's teardown.
- The macOS-version table and the sw_vers read are removed; the 27 finding stays as a comment.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…e load (#117 M1b)

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…pt as incomplete

TextEdit, Chrome and Electron recorded on 4b31b8e61195 at the first attempt and reset (the settled read and Chrome's
filled page held); Finder refused unowned_text three times, because its status bar's toggle state disagrees with what
its window draws. Not installed; the next hold re-records all four.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…ore a chrome toggle's key is sent

The marker was cleared only when the toggle was counted, after the key and its 500 ms settle, so a run
that died in between left a record reading as restored while Finder drew the part toggled, and a
later cleanup would report it restored and delete the record. The chrome step now drops the marker
durably before each key (unmarkVisibleRestored); counting the toggle stays after the send.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…hat the windows showed is not trusted

The harness-wide record was written by the base commit with the keys only. A run from it that hid the
sidebar and died would read as "nothing toggled": teardown restored nothing, restore-finder reported
success, and a new setup adopted the hidden window as the owner's. The record now carries a schema
(finder-chrome-2). A kept record without it, or without a visible state while its keys have moved,
is distrusted: up finder refuses before any window opens, naming restore-finder and the View menu;
restore-finder writes the keys back, reports visibleRestored false with the note, and ends the record
so up can run again. No migration.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…he Decision Log

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…their four numbers, not their serialization

The engine's frame objects come back with their keys in varying order, so the 04:53Z hold's Finder, whose five frames
were identical, was refused as "moved between captures". x, y, width and height are compared exactly; a missing frame
never equals a present one.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…d a frozen copy, and the goldens' data is compared, not pinned

The live recording replaces test/native-goldens/, and with it M0's Finder capture (sidebar and status bar
showing) that the Finder chrome, fixed-state and recorder tests are built on: 21 tests failed on the
hold's installed data while all passed at HEAD. M0's Finder skyshot and action-before capture are kept
in test/repl-parity/fixtures/finder-m0/ (byte for byte from HEAD) and those tests read them there. Three
assertions that pinned M0's data now compare instead: the recorder's untouched source.json against the
repository's own, Finder's action index against its row's name field, and the universal declarations'
need without requiring one to remain. All pass on both M0's data and the live recording's.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…d in meta.json

Finder's setup reports the owner's visible chrome it observed and the toggles it sent per part, and its
teardown the toggles back and whether the window reached the saved state; the recorder dropped both.
They now land in meta.json as scenes.finder.chrome {visible, setupToggles, teardownToggles, restored},
booleans and counts only, taken from the device's steps output.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…back when it ends

Every scene activates its app, so a recording left Finder or a scene app in front where the owner had
something else (Terminal at the hold's start). `record` now reads the frontmost app (scenes-mac.mjs
frontmost, lsappinfo) before anything is prepared and, after the scenes are down, the engine stopped and
the preparation cleaned up, asks the device to put it back (scenes-mac.mjs reactivate, open -b): only
while it still runs as the same pid and is not a scene app. meta.json records the bundle id and the
put-back's answer, never the pid; preparation.json keeps both so `cleanup` puts it back as its last step.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…s needed only when removing it adds an undeclared difference

The audit called a declaration needed when removing it changed the golden's undeclared differences in
either direction, so a correction that creates a difference read as needed: the hold's TextEdit
windowUrl correction, which pinned M0's document path after the engine was fixed, was reported an
ENGINE DEFECT although deleting it left cua.txt and vendor.txt matching. addsUndeclared compares the
two as multisets; a removal that only takes differences away now reports `delete:`.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…pped subset count as a vendor defect

The vendor prints `(showing <ranges> of <N> items)` with N the childCount (availableSubsetDescription
0x10063e220, via get_childCount 0x10079e94c) of a hierarchy prefetched by _AXUIElementCopyHierarchy with
AXChildren capped at MaxArrayCount 100 (F-helper-logic §1 item 1), so the live Finder list read `of 100`
where cua reads `of 205`. cua keeps the true count (a model looking for item 150 must not be told the list
ends at 100), and the comparison gains a `subsetCount` declaration that lets only that N differ: on the
named element, the line otherwise equal with the same visible ranges, the vendor's N equal to
min(cua's N, cap) and cua's N above the cap; anything else stays undeclared, and an unused one is
over-declared. Its fault "vendor" never expires; the audit reports it as `keep (vendor defect)`.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
The live recording's audit deletes the 23 declarations that expired with the re-recording (every
engine, redaction and engine-or-renderer declaration, and the corrections that no longer change
anything), leaving the three scene-state declarations of TextEdit's diff. One declaration is added:
Finder's ListView subset count as a vendor defect (`subsetCount`, fault "vendor"), the vendor's
`of 100 items` against cua's `of 205 items` from its prefetch's MaxArrayCount cap, scoped so only that N
may differ. `goldens.mjs check` on the installed recording: nothing undeclared, nothing over-declared,
every declaration needed, nothing left after deletion (exit 0).

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…pproved build 4b31b8e61195, installed

The 04:52Z hold on the mini, at 0b44493: TextEdit, Finder, Chrome and Electron each at the first attempt and the first
reset, Finder's five frames the same; m1b/goldens-final/ keeps the recording and its meta.json. The pinned renderings
re-rendered from the new Skyshots. With expected.json after the expiry audit (77974c3), `goldens.mjs check` leaves no
undeclared difference and nothing to delete.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…nly the count the renderer appends, on the whole ID

The count is now the one ending the element's line, so count-shaped text earlier in the line (a Description) is
compared as text; everything before it must be equal and end with the rule's whole `ID: <identifier>`, so
`ID: ListView Other` no longer passes for `ListView`.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…s pid, never by bundle id

`open -b` took the bundle id alone: of two instances it could activate the other, and once the recorded process had
exited it could launch the app. The put-back now goes to the recorded process through NSRunningApplication (the call
the engine makes to give the user's app the front back), which re-checks the bundle id on that process, refuses one
that is gone and never launches; then a bounded 2 s wait for the asynchronous activation. The refusal's reason holds
no pid, since it reaches the goldens' meta.json.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…ce in meta.json, never the command that holds the pid

The transport's error quoted the whole remote command, `--pid '<pid>'` with it, into meta.frontmost.putBack. A failure
now records a fixed sentence and, from the transport, its exit status alone.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…side row 005 and outside its name cell

`> nameField` proved order alone: row 006's cell passed it. The test now locates row 005 and the name's cell through
the tree and requires the target inside the one and outside the other, and shows row 006's cell is told apart.

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…on Log's closing entries, Outcomes, and the report's addendum

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
…; the vendor's keys bypass the input method in sky-behaviour §13, and part 6 gains the pressKey row under each source

Sminos-Session: maws-3f#1ea561bc (MAWS on macbook)
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-21T06:19:50.726629Z 35c2180 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35c2180edb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


async function getAppState(given, input, target, outputDirectory) {
const args = {app: target.appPath, includeScreenshot: true, outputDirectory, ...(input.disableDiff !== undefined ? {disableDiff: input.disableDiff} : {})};
const skyshot = await call('get_app_state', args);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Relaunch the engine after Screen Recording is granted

When Screen Recording is granted after the engine process has started, the native side explicitly says the grant only takes effect after a relaunch (Methods.swift lines 149-154), but this path simply forwards permissionsPending and keeps reusing the same client and resident engine. Because every observation requests a screenshot, retries continue failing until the user discovers and runs an external engine restart; detect this grant transition and perform the documented shutdown/relaunch/retry flow.

Useful? React with 👍 / 👎.

Comment thread src/runtime/engine.mjs
Comment on lines +209 to +211
if (current.exists && current.build === build && signedAsAsked(current.signature)) {
log(`cua's engine build ${shortBuild(build)} is already at ${paths.bundle}; nothing to do`);
return {bundlePath: paths.bundle, engineVersion: current.engineVersion, build, signature: publicSignature(current.signature, configured), changed: false, stopped: null};

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Verify the existing bundle before skipping its rebuild

If an installed bundle is modified or corrupted after signing, bundleOnDisk() still obtains its certificate with the display-only codesign -d path in readSignature, so matching build metadata and signer cause this early return without the separate codesign --verify --strict check used after a fresh sign. installedEngine() relies on the same unchecked data, meaning the damaged bundle remains approved and cua engine build reports that there is nothing to do instead of repairing it; require strict verification before accepting this shortcut or an approved installation.

Useful? React with 👍 / 👎.

Comment thread src/runtime/launch.mjs
if (!app) {
if (setting.reason !== 'default' || requestedHost === 'cua') {
const bundle = enginePaths(engineDirectory(env.HOME || homedir())).bundle;
fail('engine_not_installed', `${engineSource(setting.reason, 'cua')} selects cua's own engine, and no approved engine is installed on this Mac (${bundle}, approved by \`cua engine approve\`): install it with \`cua install --engine\` (or \`cua engine build\`, then \`cua engine approve\` with the owner at the console), or set CUA_NATIVE_ENGINE=vendor for the vendor engine`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Point users to an implemented engine installation command

When CUA_NATIVE_ENGINE=cua is selected without an approved bundle, this primary remediation tells users to run cua install --engine, but the install parser at src/cli.mjs:154-156 has no engine option. Confirmed against this commit: node bin/cua.mjs install --engine --json exits 2 with Unknown option '--engine'. Use the implemented cua engine build plus cua engine approve commands exclusively, or add the advertised install option.

Useful? React with 👍 / 👎.

lock.lock()
let seen = considered.contains(pid)
lock.unlock()
guard !seen else { return nil }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recheck accessibility enablement on every observation

For an eligible Electron, Chromium, iWork, or Spotify process, this permanent PID-level early return prevents later observations from rereading the enablement attribute. If the first AXUIElementSetAttributeValue fails after the PID is inserted into considered, or the target app subsequently resets AXManualAccessibility/AXEnhancedUserInterface, the engine never retries and can keep returning an incomplete tree without its web area for the rest of the process lifetime; reread the attribute on each observation and set it whenever it is false.

Useful? React with 👍 / 👎.

lock.unlock()
guard first, let name = enablementAttribute(listed: names as? [String] ?? []) else { return nil }
if bool(attribute(application, name)) == true { return nil }
return AXUIElementSetAttributeValue(application, name as CFString, kCFBooleanTrue) == .success ? name : nil

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore accessibility mode when the last observer disconnects

When this write succeeds for an app whose accessibility attribute was initially false, the mutation is never recorded or undone: ConnectionState tracks no ownership, and Server.unregister only removes the connection and closes its descriptor. Consequently, after the last cua session disconnects while the resident engine remains running, the observed Electron, Chromium, iWork, or Spotify app stays in manual/full accessibility mode indefinitely, which can alter its behavior and resource usage; track successful enablement per connection and restore false after the final observing connection closes.

Useful? React with 👍 / 👎.


async function getAppState(given, input, target, outputDirectory) {
const args = {app: target.appPath, includeScreenshot: true, outputDirectory, ...(input.disableDiff !== undefined ? {disableDiff: input.disableDiff} : {})};
const skyshot = await call('get_app_state', args);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove screenshots discarded on identity mismatch

When an approved app path is replaced by a different bundle between cached resolve_app and this call, the native get_app_state has already written the new app's screenshot into the kernel-readable CUA_ENGINE_SCREENSHOTS directory before lines 133-136 reject the identity. Throwing and retrying suppresses the tree response but leaves the JPEG in the run directory, so sandboxed model code can enumerate and read a screenshot of an app the user never approved; validate the expected identity inside the engine before capture, or unlink every discarded capture before retrying.

Useful? React with 👍 / 👎.

Comment on lines +141 to +142
let count = (args["click_count"] as? NSNumber)?.intValue ?? 1
guard count >= 1 else { throw EngineError.invalidArguments("click_count must be at least 1") }

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Bound click counts before constructing event plans

A model-controlled click_count such as 1000000000 passes this lower-bound-only validation, after which clickEventPlan eagerly materializes two MouseEventPlan values per click and clickEvents attempts to create the corresponding events. The tiny request can therefore exhaust memory or keep the resident engine busy until it is killed, breaking computer use for the session; reject counts above a small documented maximum before constructing the plan.

Useful? React with 👍 / 👎.

const removedIds = [...new Set(removed)].filter(index => !present.has(index)).sort((a, b) => a - b);

const window = `Window: "${now.title}"`;
if (!changes.length && !removedIds.length) return `There has been no change in the accessibility tree for ${window}.${now.trailer}`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include truncation markers in no-change diffs

When the visible tree lines remain identical but new content appears only beyond the depth or element-count cap, layout(current) gains a truncation marker while changes and removedIds remain empty. This early return omits now.markers, so the response falsely reports no change without telling the model that current content was discarded; include the current markers in this branch as the changed-diff and full-render paths already do.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant