Magnitude
============================================================================ ⚠️ SECURITY WARNING — THIS CAN EXPOSE MAGNITUDE ON THE NETWORK ============================================================================
Turning on the network API (networkEnabled=true, a non-empty networkHost,
or network.enabled in config.json) makes Magnitude listen beyond loopback;
with networkHost=0.0.0.0 it listens on EVERY interface. Any device that can
route to port 10100 then reaches Magnitude's web UI and its
OpenAI-compatible inference API. The API needs the network access key
(networkApiKey), but the UI is served to anyone, and inference is open when
the key is unset/weak or requireApiKey is off. Only enable it on a network
you trust; prefer binding one interface over 0.0.0.0; always set a long
random networkApiKey; and front it with a TLS reverse proxy (see the README
TODO) as soon as you can. The README carries the same warning and a TODO to
move the bind back to loopback behind Caddy at magnitude.<host>.<zone>.
Install, upgrade and configure Magnitude (https://magnitude.dev) on a Linux machine with systemd — the whole loop from "which version is installed" to "the server is running the new package with my settings", elevated through the @svendowideit/sudo ladder. WHAT IT DOES
Closes the loop around a Magnitude (https://magnitude.dev) install on this
machine: it reads the installed magnitude --version, resolves the newest
release, and installs the checksum-verified distro package for this
distribution and architecture (Debian/apt, RPM/dnf, Arch/pacman) only when
the version actually changed — never re-downloading a ~200 MB package for a
current machine. It then registers and turns on the Magnitude server (the
boot service that serves models over the network) with magnitude server setup, and writes your settings — network access, API key, bind host and
port — to /var/lib/magnitude/config.json, restarting only when they
changed. Privileged steps are delegated to @svendowideit/sudo, so any
elevation route the host already grants works. Prefer it over hand-running
apt install and magnitude server setup when you want repeatable swamp
workflows that reconcile the server as configuration.
INSTALL
swamp extension pull @svendowideit/magnitudeDEPENDENCIES
@svendowideit/github-release-install and @svendowideit/sudo, declared in
dependencies: and installed by the single pull above. The bundled workflow
calls github-release-install to resolve the release, match the platform
package, record its SHA-256 and download a verified package only when an
update is needed; it calls sudo's named operations for every privileged step.
A GitHub token is optional (GITHUB_TOKEN / GH_TOKEN / gh auth token).
RUN
# Install or upgrade Magnitude and register its server. Idempotent:
# re-running is a no-op when nothing changed.
swamp workflow run @svendowideit/magnitude-install
# Turn on the network API, set its key and bind it to the LAN.
swamp workflow run @svendowideit/magnitude-install \
--input networkEnabled=true \
--input networkApiKey=mag_examplekey --input networkHost=0.0.0.0
# Ask for the installed version, the path and the exact status command.
swamp model @svendowideit/magnitude method run sync magnitude
swamp model @svendowideit/magnitude method run print magnitude
# Upgrade an existing install in one idempotent command — re-running is a
# no-op unless a new release, a changed setting or a stopped server needs
# reconciling. Same loop as installing; nothing to pass.
swamp workflow run @svendowideit/magnitude-upgrade
# Remove it again, keeping the downloaded models and settings.
swamp workflow run @svendowideit/magnitude-install --input uninstall=trueCONFIGURE
Workflow inputs (all optional, with defaults), also settable as model global
args with --global-arg and overridable per call with --input:
repo GitHub repository publishing Magnitude (default magnitudedev/magnitude)
version Release to install; empty = latest (default "")
distro debian | rhel | arch override (default: host probe)
arch x86_64 | arm64 override (default: host probe)
githubToken Raises the releases API rate limit (default: GITHUB_TOKEN, GH_TOKEN, `gh auth token`)
downloadDir Where the verified package is staged (default ~/.cache/magnitude)
stagingDir Where the root-side scripts are staged (default ~/.cache/magnitude/staging)
packageName Distro package name (default magnitude-desktop)
serviceName systemd service name (default magnitude)
serviceUser Run-as user for the server (default magnitude)
configDir Server settings/models/logs dir (default /var/lib/magnitude)
manageService auto | "true" | "false" (default auto: set the server up when the package is present)
networkEnabled Turn on the network API — EXPOSES IT (default false; see the WARNING)
networkApiKey Bearer key the network API requires (default: leaves any existing key untouched)
networkHost Address the network API binds (default: all interfaces; 0.0.0.0 = every interface)
sudoInstanceKey Sudo model instance to elevate with (default default)
sudoAllowedOperations Sudo ops allowed for this run (default: the standard install set)
force Reinstall even if current (default false)
uninstall Remove package and service instead (default false)
purgeData Also delete /var/lib/magnitude (default false) Privileged steps run through @svendowideit/sudo's sudo-run workflow, which
passes this run's sudoAllowedOperations to the sudo model, so a bare
auto-created instance works without a prior swamp model create. Magnitude
tags releases as @magnitudedev/cli@<version>, so --input version= pinning
is best-effort; the default latest release resolves reliably. The releases
API allows only 60 anonymous requests per hour per IP, so authenticate for
scheduled runs: run gh auth login once (its token is then used
automatically), or export GITHUB_TOKEN=$(gh auth token).
Getting the network access key once network access is on: it is the value you
passed as networkApiKey (the extension never stores it in swamp data); if
you did not set one, read it on the server with
sudo cat /var/lib/magnitude/config.json (the network.apiKey field), or see
it in the UI under Settings → Network access. Clients send it as
Authorization: Bearer <key> (or x-api-key) against
<server>:10100/inference/v1. magnitude status never prints it.
Linux only: on macOS and Windows Magnitude ships a desktop app rather than a distro package, and this extension does not manage it.
SETUP
The setup method detects the server's current state and records it, then
merges any settings you pass over it — so configuration is remembered, not
re-asked. It reads /var/lib/magnitude/config.json and the persisted
settings resource, then saves the effective values (partial values
included) back to settings for the next run to reuse; the network API key
is never written to swamp data, only to config.json on the host. It also
reports which capabilities are enabled ("installed", "configured",
"network-api"). It changes nothing on the host itself — the install workflow
applies the settings as a privileged step, and stops at the failing step
with the exact manual commands when it cannot elevate.
swamp model @svendowideit/magnitude method run setup magnitudeUPGRADE
Magnitude install and upgrade are the same reconciled loop, so upgrading is one command with nothing to pass:
swamp workflow run @svendowideit/magnitude-upgrade It reads the installed magnitude --version, resolves the newest release,
installs the verified package only when the version (not the ACN revision)
actually changed, re-registers the server and re-applies your
settings, restarting the service only when the unit, package or settings
moved. Every step is idempotent, so re-running is safe; it ends on verified
reality by printing the version now on the machine.
WHAT IT INSTALLS
The Magnitude desktop package for this distribution — magnitude-desktop,
installed with the host's package manager as root through the elevation
ladder. On Linux the package places /usr/bin/magnitude (a symlink to the
CLI under /usr/lib/magnitude-desktop/resources/), the desktop resources and
the inert /usr/lib/systemd/system/magnitude.service unit; magnitude server setup then creates the unprivileged magnitude system account, prepares
/var/lib/magnitude (settings, models, logs) and enables the unit. Your
settings are written to /var/lib/magnitude/config.json. The verified
package is cached under downloadDir and the root-side scripts under
stagingDir. Inspect the server at any time with:
systemctl status magnitude.service On uninstall=true it stops and removes the service and the package,
keeping /var/lib/magnitude (models and settings) unless
purgeData=true.
Global Arguments
| Argument | Type | Description |
|---|---|---|
| distro? | string | Override the detected distribution family (debian, rhel, arch). Empty |
| arch? | string | Override the detected architecture token (x86_64, arm64). Empty probes |
| repo? | string | GitHub repository publishing the Magnitude releases. |
| version? | string | Release to install (e.g. 0.2.9). Empty installs the latest. Pinning is |
| assetPattern? | string | Asset-name pattern passed to @svendowideit/github-release-install. |
| githubToken? | string | GitHub token to raise the releases API rate limit. Empty falls back to |
| downloadDir? | string | Directory the verified release package is downloaded into. |
| stagingDir? | string | Unprivileged directory the root-side scripts are rendered into. |
| packageName? | string | Distro package name (used for removal). |
| serviceName? | string | systemd service name (without the .service suffix). |
| serviceUser? | string | Run-as user for the server service (created by `magnitude server setup`). |
| configDir? | string | Directory holding the server's settings, models and logs. |
| networkEnabled? | boolean | Turn on the server's network (LAN/remote) API in config.json. |
| networkApiKey? | string | Bearer key the network API requires. Empty leaves any existing key |
| networkHost? | string | Interface address the network API binds (network.bind, one IP of this |
| sudoInstanceKey? | string | Instance key of the @svendowideit/sudo model the workflow elevates |
| sudoAllowedOperations? | array | Operation allowlist passed to the sudo model for each privileged step. |
| force? | boolean | Reinstall even when the target version is already installed, and re-run |
| Argument | Type | Description |
|---|---|---|
| networkEnabled? | boolean | Supplied network-API toggle; merged over any detected or previously saved value. |
| networkApiKey? | string | Supplied network-API key; the key itself is never persisted to swamp data. |
| networkHost? | string | |
| binaryPath? | string | Override the `magnitude` binary path for this call. |
| Argument | Type | Description |
|---|---|---|
| distro? | string | |
| arch? | string |
| Argument | Type | Description |
|---|---|---|
| path? | string | Override the binary path for this call. |
| repo? | string | GitHub repository to read the latest release version from when |
| githubToken? | string | GitHub token for the optional latest-release check. |
| checkLatest? | boolean | Also resolve the latest release version (one GitHub API request). |
| Argument | Type | Description |
|---|---|---|
| latestVersion | string | The release version resolved by the release step (a tag such as |
| force? | boolean | Report an update as available regardless of the installed version. |
| Argument | Type | Description |
|---|---|---|
| networkEnabled? | boolean | Supplied network-API toggle; merged over any detected or previously saved value. |
| networkApiKey? | string | Supplied network-API key; the key itself is never persisted to swamp data. |
| networkHost? | string | |
| binaryPath? | string | Override the `magnitude` binary path for this call. |
| Argument | Type | Description |
|---|---|---|
| packagePath? | string | Path to the downloaded, checksum-verified package (from the release |
| packageName? | string | Override the package file name for this call. |
| checksum? | string | Expected SHA-256; when set the staged package is re-verified. |
| manager? | enum | Override the package manager for this call. |
| Argument | Type | Description |
|---|---|---|
| packagePath? | string | Package to install. Empty reuses the staged package from the `stage` |
| manager? | enum | |
| force? | boolean |
| Argument | Type | Description |
|---|---|---|
| binaryPath? | string | Override the `magnitude` binary path for this call. |
| force? | boolean |
| Argument | Type | Description |
|---|---|---|
| networkEnabled? | boolean | |
| networkApiKey? | string | |
| networkHost? | string | |
| restart? | boolean | Restart the service after writing the settings. |
| Argument | Type | Description |
|---|---|---|
| removePackage? | boolean | Also remove the distro package (not just the service). |
| purgeData? | boolean | Delete /var/lib/magnitude (models and settings) as well. |
Resources
Install or upgrade Magnitude on this machine and register its server — the whole loop in one idempotent run, elevated through the @svendowideit/sudo ladder. Stages (install): plan → privilege → sync → resolve → assess → download → stage → install → server-setup → configure → service → print. (uninstall): plan → privilege → uninstall-service → uninstall-package → purge-data → print. plan resolves this machine's distribution family and architecture, the exact release package and package manager
Upgrade Magnitude on this machine — one idempotent command, no inputs to remember. Magnitude install and upgrade are the same reconciled loop: read the installed `magnitude --version`, resolve the newest release, install the verified package only when it actually changed, then re-run `magnitude server setup` and rewrite your settings, restarting only when something moved. This workflow is that loop, so re-running it is safe and changes only what differs; it delegates to the same `@svendowideit/
- Has README or module doc2/2earned
- README has a code example1/1earned
- README is substantive1/1earned
- Most symbols documented1/1earned
- No slow types (deprecated)1/1earned
- Dependencies pass trust audit2/2earned
- Has description1/1earned
- Platform support declared (or universal)2/2earned
- License2/2earned
- Verified public repository2/2earned
Spawns a subprocess with Deno.Command().
- models/magnitude_shared.ts:46 — no reason given