Expand description
The gate in front of Desktop: an agent clicking and typing in a native
app (docs/specs/SPEC_DESKTOP_DRIVING_2026_10_20.md §5.4–5.6, §5.9).
srv decides and remembers; the MCP tool acts. Before any action the tool
asks [authorize]-side code (server/app_api/desktop.rs), which uses this
module for:
- grants: the user allows an agent to drive one app, for a time or for
the agent’s session. They live in memory only, and are tied to the pane
(
block_id) that asked, so a new session asks again; - the blocklist: apps that are never driven (password managers, web browsers, AgentMux itself, trading and crypto apps), editable in settings;
- limits: at most two input actions a second and 200 per grant;
- Stop: the user’s brake. It revokes an agent’s grants, and the agent’s next action is told so once.
The user’s answer to a prompt comes only through the host
(POST /api/v1/host/desktop_request), which agents can’t impersonate, so a
prompt-injected agent can’t approve its own request.
Gate is plain data with the clock passed in, so every rule below is
tested without a UI.
Structs§
- Desktop
Answer - The user’s answer, relayed by the host (
POST /api/v1/host/desktop_request). - Desktop
Event app:desktop: prompts waiting for the user, and the grants in force.- Desktop
Grant View - An app an agent may drive right now, for the pane’s “Driving” badge.
- Desktop
Request - An agent waiting for the user’s yes or no on one app.
- Gate
Enums§
- Check
- What
Gate::checkfound. - Choice
- What the user chose.
Constants§
- ANSWER_
WAIT - How long a prompt waits for the user.
- DEFAULT_
GRANT_ MINUTES - DRIVING_
SHOWN_ MS - A grant shows as “Driving” this long after its last action.
- MAX_
ACTIONS_ PER_ GRANT - Input actions allowed per grant before the user is asked again.
- MIN_
ACTION_ GAP_ MS - Two input actions a second.
- SETTING_
ALLOWLIST desktop:allowlist: app names removed from the default blocklist.- SETTING_
BLOCKLIST desktop:blocklist: app names added to the default blocklist.- SETTING_
ENABLED desktop:enabled: the tool is off unless this is true.- SETTING_
GRANT_ MINUTES desktop:grantminutes: how long “Allow for a while” lasts.
Functions§
- app_key
- An executable name as the blocklist compares it: file name, no extension, lower case.
- audit
- Append one line to
desktop-audit.log, next to the window-capture audit log. Best effort: failing to write it never stops the tool. Typed text is never in an entry, only its length. - blocked_
reason - Why
app(an executable name) with windowtitlemust not be driven, orNone.addedextends the defaults;allowedtakes names off them. An entry matches the app’s name exactly, or any part of the window title. - with_
gate - Run
fon the process-wide gate.