Skip to content

v8.0.0

Choose a tag to compare

@maltyxx maltyxx released this 30 Aug 21:38
· 35 commits to main since this release
89c0f3b

What's Changed

GhostDesk is rewritten in Rust on NestRS, and it is no longer a Linux-only product: the same binary now drives a macOS desktop. That is what the rewrite bought. Every version through v7.5.0 spoke Wayland and nothing else, with the compositor's assumptions spread across the codebase; the port put the operating system behind five traits, and a second implementation of those five is what macOS support is — not a compatibility layer bolted on beside the first.

The rest follows from the same move. The framework underneath is a real dependency-injection container rather than a set of decorators, so composition is explicit and the whole graph is verified before a port opens instead of failing on the first tool call. Observability stops being a bespoke subsystem and becomes structured tracing: four lines joined by a trace_id say what the desktop did, which tool was addressed, what the endpoint served and what it cost. And there is no interpreter left in the image — one root-owned binary, no site-packages, no virtual environment, no committed protocol bindings.

The fourteen tools keep their names, their parameters and their result shapes, so a client that calls tools needs no reconfiguration — but the endpoint is authenticated by default, the two MCP resources are gone, and every environment variable is renamed.

Changed

  • The server is a single binary. apps/ghostdesk wires modules and owns no logic; crates/features holds one folder per domain (screen, input, programs, clipboard, auth, idle) — a module.rs that registers it, a service.rs, or a services/ directory when there is more than one — plus one #[mcp] host per domain under <domain>/mcp/, and nothing but the *Module types is public; crates/platform is the OS substrate — Wayland, Sway IPC, grim and .desktop on Linux, Quartz, Accessibility and the pasteboard on macOS, plus the coordinate space both share — and carries no framework types. The whole dependency graph is verified at boot — a missing provider fails the boot naming it, rather than surfacing on the first tool call.

  • The OS boundary is five traits. InputBackend, ScreenBackend, WindowManager, Clipboard and AppCatalog are the only doors between the feature layer and the desktop. Each OS is a directory under crates/platform/src/ whose modules mirror those five contracts by name, and platform::host is the single point where one is chosen. Window identity is opaque per backend — Sway's con_id is an implementation detail, not the contract — and no compositor JSON ever crosses into the feature crate. Adding an OS is a new sibling directory plus one arm per selector; nothing in features or the MCP hosts names an operating system — and the macOS backend, below, is that claim tested rather than asserted.

  • The Wayland stack loses 6 400 lines. pywayland needed committed CFFI bindings for wl_*, zwlr_virtual_pointer_v1 and zwp_virtual_keyboard_v1 — 6 400 lines of generated Python under version control. wayland-client generates them at build time from the protocol XML, so there are none. The connection now lives on one dedicated thread that owns the event queue and consumes commands off a channel; that single consumer is the serialisation the protocol needs, replacing the explicit lock every call site had to remember to take.

  • The keyboard grammar is published from one table, and both directions are checked. platform::chord holds the modifier and key names the tool description promises on any desktop. A test in each backend proves it serves everything the table publishes, and normalize refuses a name the table does not carry before either backend's map is consulted. Previously only half of that existed, and a name like option resolved on one desktop while failing on the other under a single published description.

  • Every environment variable is renamed, and there is now only one name for each. The deployment sets NESTRS_ENV_PREFIX=GHOSTDESK — both images bake it, the Justfile exports it, and the entrypoint refuses to start without it — so the framework reads GHOSTDESK_HTTP__PORT where a stock NestRS app would read NESTRS_HTTP__PORT. The entrypoint's GHOSTDESK_* → NESTRS_* translation layer is gone with it: what you set is what the server reads. Settings are #[config] structs validated at boot, one per feature module rather than one catch-all — screen, idle and auth alongside the framework's own http, mcp and health. Read a name as GHOSTDESK_<NAMESPACE>__<KEY>; a single underscore (GHOSTDESK_VNC_PASSWORD) marks a container knob the entrypoint consumes itself.

    Was Is
    GHOSTDESK_PORT GHOSTDESK_HTTP__PORT
    GHOSTDESK_HOST GHOSTDESK_HTTP__HOST
    GHOSTDESK_ALLOWED_ORIGINS GHOSTDESK_HTTP__CORS_ORIGINS
    GHOSTDESK_ALLOWED_HOSTS GHOSTDESK_MCP__ALLOWED_HOSTS
    GHOSTDESK_SCREEN_WIDTH / _HEIGHT GHOSTDESK_SCREEN__WIDTH / __HEIGHT
    GHOSTDESK_IDLE_TIMEOUT GHOSTDESK_IDLE__TIMEOUT_SECS
    GHOSTDESK_AUTH_TOKEN GHOSTDESK_AUTH__TOKEN

    GHOSTDESK_VNC_PASSWORD, GHOSTDESK_USER and GHOSTDESK_DIR keep their names — the entrypoint reads them, not the server. GHOSTDESK_TLS_CERT / _KEY keep theirs too, and now name the paths the entrypoint hands the server as GHOSTDESK_HTTP__TLS_CERT_FILE / _KEY_FILE; the framework terminates TLS, so those two are what a binary started outside the container sets.

  • The environment contract is committed. .env.example documents every variable the server reads with its default and the reason it exists; .env.development carries the dev posture. GHOSTDESK_ENV picks the cascade and, like NESTRS_ENV_PREFIX, has to be on the process — both select which files load, so neither can come from one.

  • A malformed setting now fails the boot naming the variable, instead of quietly falling back to a default. GHOSTDESK_IDLE__TIMEOUT_SECS=18OO used to be indistinguishable from deliberately choosing 1800.

  • mouse_scroll refuses an out-of-band notch count instead of clamping it silently. The tool advertised 1–5 and quietly clamped anything above it, so a model asking for 20 got 5 and was never told. amount is validated at the edge and an out-of-band value comes back as invalid_params naming the field — the one MCP error a model can correct itself from.

  • app_launch waits for the window and hands back the settled screen. It polls for the first window the launched PID owns (up to 10 s), reports how long that took, and attaches the settled capture to the result — so the common launch-then-screenshot pair is one call. When the process exits without a window, or none appears in time, the result says which of the two happened and what to do about it. wait_for_window: false restores the old fire-and-forget behaviour for apps with no UI.

  • screen_changed is measured in pixels, not in the box around them. The previous test took the bounding rectangle of every differing pixel, so a cursor blink in one corner and a tooltip in the other reported a full-screen change. Frames are decoded once and diffed row at a time, which is also what makes the comparison cheap enough to run on every input.

  • The idle watchdog is a #[scheduled] method on a regular provider, ticking every 5 s and comparing one atomic. The previous hand-rolled asyncio task derived its poll interval from the timeout (timeout/10, clamped); a fixed cadence costs nothing and fires within seconds of the deadline whatever it is set to.

  • app_status no longer reports a dead app as running, and no longer panics on a PID the kernel will not take. Launched children are reaped in the background, so a crashed process disappears from the liveness check instead of lingering as a zombie that still answers it, and only PIDs this session launched are accepted — the registry that remembers them is what keeps the tool from reading a log path built out of an arbitrary number.

  • The container healthcheck asks whether the desk answers, not whether the wrappers are up. supervisorctl status reports RUNNING for a program that is merely waiting on a socket, so on its own it certified containers whose desktop was not there yet. The check now asks supervisord for the siblings only it can see (wayvnc, websockify — a desk no human can watch is broken even while every tool answers), then /health/live and /health/ready for what only the server knows. Service start-up ordering collapses into one wait-for-wayland gate for the programs that exit rather than wait; GhostDesk deliberately does not come through it, because its boot hook retries the Wayland connect itself and that retry is the real bind.

Security

  • The endpoint is closed by default, and the bearer check covers every route. Authentication is a NestRS authn strategy behind the framework's AuthnGuard, mounted at the composition root rather than on the MCP edge — so the open dev posture is something GhostDesk declares out loud rather than something it can fall into by forgetting a middleware, and a route added later is closed the day it is added. Bearer comparison is constant-time.
  • The TLS-without-a-token check runs on every start path. It is a boot-time lifecycle hook, and init hooks are strict: the first error aborts before any port opens, so there is no window where an HTTPS endpoint serves unauthenticated. The container entrypoint keeps its own check.
  • A token given is a token required, certificate or not. The entrypoint used to discard GHOSTDESK_AUTH__TOKEN when no certificate was mounted, on the argument that a static secret over cleartext is theatre — while the server armed the gate for any token it was handed. One set of variables had two behaviours, and an operator who set a token got a closed desk from the binary and an open one from the image. The script now passes the token through and keeps the warning that the credential crosses in cleartext. The VNC password is still dropped without a certificate, and that asymmetry is deliberate: wayvnc's RFB security type 2 is a DES challenge that means something only inside the wss:// envelope.
  • DNS-rebinding defence is now a Host allow-list (GHOSTDESK_MCP__ALLOWED_HOSTS, default loopback only) enforced by the MCP transport, in addition to the Origin/CORS policy (GHOSTDESK_HTTP__CORS_ORIGINS) which now covers every route rather than /mcp alone. A deployment reached under a real hostname must name itself or it will answer 403.
  • Launched apps are scrubbed of the entire GHOSTDESK_* namespace, not just the two names the Python port listed. It carries the bearer token and TLS paths, and a browser the agent spawns has no business with any of it. One prefix rather than a list of names means a setting added later cannot be forgotten here.
  • Image hardening collapses to one line. The Python build byte-compiled the venv, stripped every source file and chmod-ed a tree of thousands, because an interpreter loads whatever code is on disk. The binary is one root-owned 0555 file: no site-packages for a dependency-confusion attack to land in, and no interpreter on PATH to re-enter the product through. Release builds run --locked, so a tagged image cannot resolve a different dependency than the reviewed one.
  • The runtime image drops libwayland-client0 — the protocol is spoken from pure Rust — and no longer ships a language runtime for GhostDesk. python3 remains only because websockify is a Python program.
  • unsafe_code is denied workspace-wide and lifted one file at a time with expect rather than allow, so the exemption leaves with the last unsafe it covered instead of outliving it in silence.

Removed

  • The two MCP resources, ghostdesk://apps and ghostdesk://clipboard. They duplicated app_list and clipboard_get under a second addressing scheme and no client read them. This is the one client-visible break in the tool surface: a caller that subscribed to either reads the corresponding tool instead, which returns the same data.
  • The session-accounting subsystem — roughly 1 500 lines of hand-rolled per-session bookkeeping, replaced by plain tracing. Four lines now make one record, joined by trace_id: what the desktop did, which tool was addressed, what the endpoint served, and what the request cost. Every act on the desk is logged at info by the service that performs it, spelled in fields, with typed and copied text counted rather than quoted — and the record is filed the moment the act lands, never once its effect has been judged, so a capture that fails to decode cannot erase the fact that the desktop was touched.
  • MCP logging notifications (notifications/message), which the Python port used to push a warning when an input produced no visible change. Logging is deprecated by SEP-2577 and slated for removal. The signal the model actually reads — screen_changed: false in every input tool's result — is unchanged, and the server-side warn is still emitted.
  • The argument-coercion middleware. It repaired x="383, 22" into x=383, y=22, a shape a JSON-Schema-typed integer parameter cannot take: the model now gets a validation error naming the field and corrects itself.
  • Python, uv, and the .venv. pyproject.toml, uv.lock, src/ghostdesk/ and tests/ are gone, along with the uv sync step in the entrypoint and the python3-dev / libwayland-dev build dependencies. No Python remains in the workspace.

Added

  • GhostDesk runs on macOS. Five backends answer the same five contracts the Wayland ones do: Quartz Event Services for the pointer and keyboard, the Accessibility API for windows, screencapture for frames, the pasteboard for the clipboard, and .app bundles for the catalogue. The tool surface is identical — an agent calls mouse_click and app_launch without knowing which desktop it is on — and the difference the model must see is published rather than assumed: conventions() states the desktop and its primary modifier, so the instructions say cmd+c on macOS and ctrl+c on Linux, built from the same constant the key table presses. Two permissions must be granted by hand, per binary, in System Settings — Accessibility for input and windows, Screen Recording for capture. Neither can be requested from code, so a backend without one fails naming the setting to open instead of appearing to work. The container image remains Linux; macOS is for running the binary directly.
  • The current MCP revision, and every one a client might still ask for. The endpoint answers 2025-11-25 by default and negotiates 2024-11-05, 2025-03-26, 2025-06-18, 2025-11-25 and the 2026-07-28 draft on request, falling back to the current revision for anything it does not know. The SDK is rmcp 3.1.
  • Liveness, readiness and startup probes at /health/{live,ready,startup}. They answer about the desktop rather than about the process: ready goes down when the compositor stops answering the window seam, live when the connection behind the virtual pointer and keyboard is gone — a state in which every tool still replies and none of them does anything. Two indicators back them — a compositor roundtrip and a window-tree query — each bounded in milliseconds (GHOSTDESK_HEALTH__INDICATOR_TIMEOUT_MS, GHOSTDESK_HEALTH__PROBE_DEADLINE_MS) so a stalled seam reads as a named down instead of a client-side timeout that says nothing about which seam went away.
  • Every structured tool publishes an outputSchema. The eleven tools that answer with data (mouse_*, key_*, app_*) derive the schema a client validates against from the same type that produced the result. The three that answer with an image or plain text (screen_shot, clipboard_get, clipboard_set) carry none, correctly. The Python port advertised no output schemas at all.
  • A refusal the model can act on, or nothing at all. A domain error declares whose mistake it is; the MCP adapter turns that into either a message the model reads verbatim and can correct itself from, or the framework's opaque answer. The decision is made once at the crate root rather than per adapter, because a copy that forgets the refusal branch still compiles, still answers, and leaks.
  • A Rust devcontainer with the pinned toolchain, mold for fast incremental links, rust-analyzer wired to clippy, and a postCreateCommand that installs nest-rs-cli at the exact version the workspace depends on and builds the binary once, so a fresh clone opens on a warm target/. rust-toolchain.toml carries llvm-tools, so just cov works without a per-machine rustup component add.

What's Changed

Full Changelog: v7.5.0...v8.0.0