Add authenticated cmux Sprites workflow

Closed
LA
2mo ago
+1857-70

Adds a standalone cmux-sprites Go CLI with Stack device-code login, backend-owned Fly credentials, Sprite lifecycle commands, and automatic cmux Noise enrollment. Login always prints a copy-paste URL and code; opening the browser is opt-in.

Adds the Sprites Cloud VM provider, pinned cmux@0.9.11 bootstrap, persistent cmux daemon service, checkpoint support, provider migrations, localized approval copy, and focused tests. The provider bootstraps normal Sprites because Fly does not publicly document cross-Sprite checkpoint forks in its REST API or SDK.

Verified with Go test/vet/build, web typecheck, ESLint, schema check, focused API/provider tests, a real Stack approval, and create/list/exec/connect/destroy against Fly Sprites. The exact TUI connection reached the Sprite shell and returned CMUX_SPRITES_CONNECT_OK.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Adds a new cmux-sprites CLI and a Sprites VM provider to create, connect to, and manage Fly Sprites via Stack device‑code login. The workflow keeps Fly credentials on the server, enforces strict enrollment deadlines, and supports secure local HTTPS development.

  • New Features

    • cmux-sprites Go CLI with device-code login (client: cmux-sprites) and commands: login, logout, status, create, list, exec, connect, destroy. Blocks cross-origin API redirects; credentialed calls require HTTPS. Optional CMUX_SPRITES_CA_FILE adds a custom CA while preserving the default HTTP transport.
    • connect auto-enrolls this device: creates a 5‑minute invite, launches cmux connect, and auto-approves only after the device claims the invite, with cancellation-aware retries and a strict approval deadline.
    • Sprites provider using @fly/sprites: creates a Sprite, installs pinned cmux@0.9.11, starts a persistent cmux daemon, and returns connectionUrl. VM list/create include connectionUrl and set cache-control: no-store.
    • Checkpoints (snapshots) are supported; cross‑Sprite restore is disabled until Fly publishes a fork API.
    • Hardened API errors: hide provider messages and return only safe error codes.
  • Migration

    • Run DB migrations to add the sprites provider and allow the cmux-sprites auth client.
    • Configure env: CMUX_VM_SPRITES_ENABLED=true, SPRITE_TOKEN (server-only Fly token), optional SPRITES_API_URL, CMUX_SPRITES_NPM_SPEC, and optional CLI CMUX_SPRITES_CA_FILE to trust a local TLS proxy for dev.
    • Ensure the web app installs @fly/sprites@0.1.0 and includes the new image manifest entry. No changes needed for existing providers.

Summary by CodeRabbit

  • New Features

    • Added the cmux-sprites CLI for authentication, Sprite management, command execution, and device enrollment.
    • Added Sprites as a Cloud VM provider with lifecycle management, snapshots, status, and connection URLs.
    • Added device-code authorization, secure credential handling, localized approval screens, and configurable provider support.
  • Documentation

    • Documented CLI usage, authentication, security, configuration, and provider limitations.
  • Bug Fixes

    • Improved response caching and prevented internal provider error details from being exposed.
  • Tests

    • Added coverage for authentication, enrollment, provider validation, security, lifecycle, and connection behavior.