# Unified system access

A host capability boundary, separate from model tool approval, workspace permission rules, account credentials and provider authorization. A status read never opens a native prompt. A model or remote client cannot grant an operating-system capability.

## Capability registry

| `id` | `subject` | `request_mode` | Scope |
| --- | --- | --- | --- |
| `screen_recording` | `runtime` | `native` | Screen & System Audio Recording; `computer_use:desktop` |
| `accessibility` | `runtime` | `native` | `computer_use:desktop` |
| `apple_events` | `target_app` | `targeted` | Per target application |
| `calendar` | `runtime` | `native` | EventKit category consent |
| `reminders` | `runtime` | `native` | EventKit category consent |
| `file_read` | `user_selected_path` | `operation` | Selected path or security-scoped bookmark |
| `file_write` | `user_selected_path` | `operation` | Selected path or security-scoped bookmark |
| `microphone` | `runtime` | `native` | Only operations that use it |
| `camera` | `runtime` | `native` | Only operations that use it |

`openprogram.host.system_access` owns the immutable registry. Report, CLI and TUI doctor, HTTP setup, Web settings, wait manifests, package usage descriptions, entitlements, GUI preflight and tests all consume it. Validated at import; package declarations are checked against the ids in build tests.

**Entry fields**

| Field | Meaning |
| --- | --- |
| `subject` | Identity the platform checks: `runtime`, `containing_app`, `target_app`, `user_selected_path`, `provider_session` |
| `check` | Non-prompting probe returning a status below |
| `request_mode` | `native`: OS request. `settings`: settings only. `targeted`: a target application is required. `operation`: only the real operation verifies it. `none`: no request API |
| `settings` | Fixed capability-specific System Settings URL or instruction; opened only after the owner clicks |
| `identity` | Bundle id and designated requirement, or provider or path identity |
| `operations` | Tools needing the capability. `computer_use` on this computer's `app` and `screen` needs screen recording and accessibility; browser targets, other machines and ordinary CLI do not |

Import validation: unique ids; every native entry has a non-prompting check and explicit request style; scoped entries specify status semantics; every settings action has a fixed destination; every operation points to a declared capability.

## Status and API

| Status | Meaning |
| --- | --- |
| `granted` | The named executor passed a fresh check |
| `not_granted` | The check completed and macOS says absent |
| `unknown` | Check failed, timed out or could not prove identity. Not a denial |
| `unavailable` | Dependency or native API is missing |
| `unsupported` | No implementation on this platform or backend |

| Endpoint | Does |
| --- | --- |
| `GET /api/system/access` | Report (schema 2): platform, host, executing identity, timestamp, rows with id, category, status, detail, instruction, request mode, settings availability, operations, recovery metadata |
| `GET /api/system/access/waits` | Open waits, with the same ids and schema |
| `POST /api/system/access/setup` | Owner and loopback only. Requests every registered native runtime capability, one consolidated report |
| `POST /api/system/access/guide` | Owner and loopback only. Body `{"capabilities": [id, ...]}`. Takes each missing one in order in the background: a dialog capability gets macOS's dialog, a list capability its pane and the drag guide. Returns `{"ok": true, "started": [ids]}`; off macOS `started` is empty; an unknown id is a 400 |
| `POST /api/system/access/{id}` | Per-row: recheck, optional native request, fresh row. `open_settings=true` only opens the destination (with the drag guide for a list capability) and never claims a grant |

Responses are no-store and hold no secrets. The first two rows keep the old `screen_recording` and `accessibility` wire shape; old receipts are read with the legacy shape. An unknown id is a client error and opens nothing. Permission rules, Auto mode, profiles, Workers and ports are unaffected.

## First run and operations

1. Web settings shows the registry by product area, why each is needed, and one read-only check per page load.
2. The user chooses “Set up all OpenProgram access” or a row's “Request authorization” / “Open System Settings”. Page mount, reconnect, polling, history replay and model output never send a request; the one automatic action is the settings guide when a tool's wait opens.
3. The backend serializes one native request per executor, using the named runtime, then checks afresh. macOS may still show separate dialogs; the UI reports each result.
4. Before an operation, the Worker runs one fresh report and creates a durable `system_access` wait only for missing required capabilities. The tool says which operation a call needs: for `computer_use` the target's provider answers, through the source the runtime installs with `register_operation_source`, so the host names no target. Listing applications or displays, browser targets and other machines need nothing.
5. Returning to the app triggers a read-only refresh. A grant resolves the wait through Worker reconciliation and continues the same execution from its checkpoint: no fake answer, retry or new execution.

| During a turn | Report |
| --- | --- |
| Capabilities found granted | Not reported again for later steps; a report starts a process, about 0.4 s |
| A capability is missing | Every step reports, so a grant is seen at once |
| A grant withdrawn mid-turn | The desktop backend fails the step and names the setting; the next turn reports again |
| Nobody can answer the wait | The call fails with `PERMISSION_MISSING:`, the missing grants and where to give them, so the model can tell the user |

## System Settings guide

Screen Recording and Accessibility (registry flag `settings_list`, row field `settings_guide`) have no dialog that grants them: the grant is a switch in a list of applications in System Settings, and opening the pane alone leaves the user hunting for the right entry.

OpenAI's Codex Computer Use solves this with a small accessory window pinned to the System Settings window (its classes `SystemSettingsAccessoryWindow`, `DraggableApplicationView`, `DragHintView`). OpenProgram copies it.

The guide panel sits just below the System Settings window; the user drags the app icon up into the list

| Part | Behaviour |
| --- | --- |
| Pane | The exact Privacy pane opens (`Privacy_ScreenCapture`, `Privacy_Accessibility`) |
| Window | A borderless non-activating floating panel, centred just below the System Settings window, or over its bottom edge when the screen has no room below. It follows the window on a 0.2 s timer and hides while the window is off screen. System Settings is found with `CGWindowListCopyWindowInfo` by the pid of `com.apple.systempreferences` |
| Icon | The runtime app's icon, an `NSDraggingSource` that drags the app's file URL into the list. Line two says to turn the switch on when the app is already listed |
| Identity | A short-lived helper process started with the executable the worker runs under (`openprogram.host.system_access.guide`), so the icon it offers and the grant it checks belong to the identity macOS grants |
| Closes | On the grant (a fresh check every 1.5 s), the × button, System Settings closing, or after 10 minutes. On a grant the next missing capability of the batch starts; any other close ends the batch |
| Batch | One guide at a time; a newer request replaces the running one. Dialog capabilities (Calendar, Reminders, Microphone, Camera) keep macOS's own dialog and get no guide |

The explicit flows use it: `POST /api/system/access/guide`, `open_settings=true` and “Set up all OpenProgram access”. When a tool's `system_access` wait opens, the guide starts by itself, once per wait, at the first missing list capability and goes on through the rest; the task waits on the durable wait and resumes when reconciliation sees the grant.

The guide opens a page and a window; it never requests or claims a grant.

## Identity and recovery

- macOS checks and requests run through the signed runtime bundle `ai.openprogram.runtime`. A source checkout may fall back to its development interpreter. An installed App never registers a bare `python3`; anonymous `python3`, `node` and stale cache paths are not identities.
- Status reads, startup reconciliation, retries and duplicate events never run `tccutil` and never reset another application.
- A verified stale receipt can authorize one explicit migration for the fixed OpenProgram bundle identity; a marker written before the OS call prevents loops. Everything else (unverified code, unknown checks, unchanged requirements, Accessibility migration, other applications) goes through System Settings.
- The product cannot pre-authorize an application it never targeted, a path never selected, or a revoked permission. Full Disk Access is never inferred or requested as a workaround.
- Linux portals and Windows integrity rules stay platform-specific. Browser targets and other machines use their provider or session boundary.

## Trust and concurrency

- Only the local owner on the execution host can request or open settings. Loopback and Origin checks are mandatory; forwarded requests and remote clients are rejected. The model can describe a missing capability, not invoke setup.
- Probes run in a fresh bounded process, share one report per reconciliation pass and do not enumerate screen contents.
- Wait resolution is guarded by execution id, generation, checkpoint version and cancellation. A failed probe keeps the wait open; a terminal or cancelled execution cannot resume.

**External references**

| Reference | Rule | Boundary |
| --- | --- | --- |
| [Screen & System Audio Recording](https://support.apple.com/en-me/guide/mac-help/mchld6aa7d23/mac) | macOS owns the grant; the user controls it | The product opens the pane and verifies the executor, never enables silently |
| [AXIsProcessTrustedWithOptions](https://developer.apple.com/documentation/applicationservices/1459186-axisprocesstrustedwithoptions?preferredLanguage=occ) | Queried separately; requested only from an explicit local-owner action | Trust is for the named executor |
| [Apple privacy controls](https://support.apple.com/en-kw/guide/mac-help/-mchl211c911f/mac) | Each category has its own consent and revocation | Plist and entitlement are prerequisites, not grants |
| [macOS file access](https://support.apple.com/en-ca/guide/security/secddd1d86a6/web) | Reported per operation | One successful read does not imply Full Disk Access |
| [Electron systemPreferences](https://www.electronjs.org/docs/latest/api/system-preferences) | Query and request are separate | Does not remove macOS consent or Apple Events targeting |

**Acceptance**

- One registry is the source for report, request, settings, waits, labels and package declarations; a consistency test fails on drift.
- Repeated reports, reconnects, replay and model output cause zero prompts. Granted rows cause zero requests.
- A GUI task missing a desktop capability pauses before planning, resumes the same execution exactly once after both are granted, and never uses the question or approval API.
- Unknown, unavailable and unsupported display distinctly from denied. Optional failures do not make installation or chat unhealthy.
- Installed `/Applications/OpenProgram.app` confirms executor identity, current grants, settings actions and no Python or Node identity migration.
- Automated: registry, probe and request routes, wait recovery, Web rendering, no auto-request.

## Implementation status

Implemented: registry, native EventKit and AVFoundation checks and requests, versioned report, identity metadata, package checks, explicit setup UI, no-auto-request recovery, operation preflight, terminal handling for unavailable or unsupported desktop access, the System Settings drag guide.

Open: dragging the icon into a real System Settings list and the panel following a moved window, checked by hand on a desktop; verifying the installed default App on port `18100` against its current macOS grants.
