# Deployment (https://docs.neuralisapp.com/enterprise/deployment)

Maturity: how far the subjects on this page are today, as of 2026-11-02. [How maturity is measured](https://docs.neuralisapp.com/getting-started/maturity.md).

| Subject                     | Kind    | Label        | Score | Main limit                                                                                                                                   |
| --------------------------- | ------- | ------------ | ----- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| Host (neuralis)             | package | stable       | 90 %  | Sign-in is email and password; single sign-on (OIDC, SAML) is not available.                                                                 |
| Platform: Linux             | topic   | experimental | 85 %  | No run on a standalone Linux host is recorded; the live-tested setup is Docker on WSL2.                                                      |
| Platform: Windows with WSL2 | topic   | stable       | 90 %  | Use an in-distro Docker engine.                                                                                                              |
| Platform: macOS             | topic   | experimental | 50 %  | Neuralis has not been run on macOS so far.                                                                                                   |
| Platform: Windows (native)  | topic   | preview      | 55 %  | The Windows shell sandbox is measured on one Windows 11 machine only, and skill scripts still need a bash, which does not run inside it yet. |

Self-hosted is the point: your agents' conversations, files, memory and audit
trail never leave your infrastructure, and the model mix (hosted providers,
custom endpoints of your own, or both) is yours to configure. The recommended
production shape is the Docker Compose stack: the Neuralis host plus a Qdrant
vector database, with all durable state on the host filesystem. A native Node
deployment is also supported. Installing and updating, step by step, are on
[Installation](https://docs.neuralisapp.com/getting-started/installation.md) and
[Updating](https://docs.neuralisapp.com/getting-started/updating.md); this page is the operator's reference.

## The Docker stack [#the-docker-stack]

```bash
npx neuralis setup    # must run BEFORE compose; safe to re-run later
docker compose up -d   # starts neuralis (:3100, :3101) + qdrant
```

In an image-only folder (Docker alone, no `package.json`) every command on this
page is `neuralis <verb>` instead of `npx neuralis <verb>`; see
[Installation](https://docs.neuralisapp.com/getting-started/installation.md#2-docker-image-recommended-for-teams).

Setup creates the `~/.neuralis` data directories with the right ownership,
writes the session secret into the data home and the `.env`, and **generates
the `docker-compose.yml`** for this machine. Run it before the first
`docker compose up`; otherwise Docker creates the data directories root-owned.
Re-running setup is the supported way to change infrastructure answers (ports,
public origin, vector backend, desktop variant): admin-edited settings are
merged, the session secret and the MCP and vector database keys are preserved,
edited source configurations are left alone, and an existing project is
maintained rather than duplicated. A fresh install means a fresh data
directory.

The compose file is a **setup artifact**: it carries machine-specific values
and a version stamp, is regenerated with `npx neuralis setup --compose-only`,
and is never hand-edited. It carries no secret except the `QDRANT_API_KEY`
interpolation from `.env`; provider keys live in the encrypted
[credential store](https://docs.neuralisapp.com/package-system/credentials.md), never in a container's
environment, which `docker inspect` would reveal.

| Service | Image | Purpose |
|---|---|---|
| `neuralis` | `neuralisapp/neuralis` | The host: UI, API, the in-process package runtime and the embedded MCP service. Publishes `3100` (app), `3101` (MCP) and `3102` (the isolated origin for MCP app views); with `NEURALIS_CODEX_LOOPBACK=on` also `127.0.0.1:1455` for a ChatGPT sign-in on the Docker host. Off by default; without it you finish that sign-in by pasting the callback URL into the Credentials tab |
| `qdrant` | `qdrant/qdrant` (when setup manages it) | Vector database. It requires the setup-minted key on every request, sits on its own network that sandboxed child containers cannot reach, is published on `127.0.0.1` only, and runs the version your storage is on |
| `ollama` | `ollama/ollama`, pinned, memory-capped (optional) | Local embeddings or a chat model on your own hardware, loopback only. `setup --ollama docker` makes `qwen3-embedding:0.6b` the embedding target |

The app container mounts the Docker socket so machine-core can spawn virtual
desktops; remove that mount to disable them. Treat a mounted Docker socket as a
privileged host capability.

**Image layout.** The image works in `/neuralis`. The standalone server lives
in `/neuralis/_runtime/`, every package as a real directory in
`/neuralis/node_modules/<name>`, and the build's report of refused packages in
`/neuralis/_runtime/build/`. Each runtime location has its own anonymous volume,
so a bind mount over the working directory can never shadow it.

**Extra host folders.** `npx neuralis mount add <host-path> --slug <name>`
writes the bind mount into a machine-local `docker-compose.override.yml`, which
survives regeneration; after a restart you attach it as a source from the Files
UI (see [Connectors](https://docs.neuralisapp.com/brain-core/connectors.md)).

### Your own packages [#your-own-packages]

On every kind of install, a native package can be installed while the host
runs and loads from the next start:

```bash
neuralis package install NAME@VERSION     # or a packed ./FILE.tgz: staged and summarized, nothing runs
neuralis package approve REQUEST_ID       # or add --yes to the install
neuralis package restart                  # the host starts again with it
```

The host stages the package without running its code and summarizes what it
brings, including its sha512 and whether the registry attests its build.
Asking needs `platform.packages`; approving and restarting need
`platform.packages.approve`, which only the owner holds by default. Installed
packages live in the data folder, so they outlive an image rebuild. To limit what
may be asked for, write `packages/allow-list.json` there: a JSON list of scopes
and exact names (`["@yourco"]`). The whole flow is on the
[CLI page](https://docs.neuralisapp.com/getting-started/cli.md).

On an install that builds its own image, an administrator can instead build a
package into the image:

```bash
npx neuralis pkg add NAME --path DIR          # a directory you develop; the build builds it
npx neuralis pkg add NAME --tarball TARBALL   # a packed package
npx neuralis pkg add NAME --version VERSION   # an exact registry version, public or private
npx neuralis rebuild                          # installs it; it loads at that start
```

Registering is the trust act: the package runs in-process with native trust.
Every check runs before the dependency line is written. For a **private
registry**, point `NEURALIS_BUILD_NPMRC` at an `.npmrc` with scope lines only
(`@yourco:registry=<url>` and its token, never a default `registry=`); the build
mounts it as a secret, so the token is in no image layer, log or compose file,
and a scope once served privately is never asked of the public registry.

**One bad package never takes the platform down.** A package that fails its
checks at build or at start is left out and named, the platform runs without
it, and `/api/health` stays ready and counts it. A package's default role grants
reach every existing project once, at the first start that carries it.
`npx neuralis pkg remove <name>` takes the line out, revokes those grants at the
next start, and lists the data, settings and credentials it left in place with
the command to delete each. An image-only folder runs only what its image was
built with. For developing a package in its own repository, see
[building your own native package](https://docs.neuralisapp.com/package-system/external-native.md).

### The host-access plane (optional, paired devices) [#the-host-access-plane-optional-paired-devices]

Mounting a folder makes it visible to the container. A separate, opt-in plane
lets a command **run on a machine**, the server itself or a person's own
laptop. It is off until someone turns that machine into a **device**, and that
cannot be done from inside the application:

```bash
npm install -g @neuralis/cli    # the separate client, Node.js 22.22 or newer
neuralis device pair            # one sign-in in the browser; this machine becomes your device
neuralis device install         # the login service, the sandbox helper, an allowlist with no folder
neuralis device grant DIR       # let the app read DIR (--write to change it, --exec to run in it)
neuralis device status          # pairing, allowlist, sandbox helper, link, pending requests
```

The device's broker dials **out** to the app over the MCP port, so the
container holds no host secret and the compose file has no bind for this plane;
the app keeps only a hash of the device's secret. A new client release is
`neuralis update --cli --apply`, which then refreshes the sandbox helper; a
helper that cannot prove itself leaves a sandboxed device not ready. Who may use
a device: its **owner** (`device.own`, a member default), and anyone else only
with `device.others` and only while it runs sandboxed. The
`Devices: Kill-Switch` setting stops every device; it is never the gate. The
Admin widget's Devices tab lists, follows and revokes devices. Pairing and
day-to-day use are on [Devices](https://docs.neuralisapp.com/getting-started/devices.md).

#### Tuning what a device may reach [#tuning-what-a-device-may-reach]

The allowlist, the device's *ceiling*, is a JSON file beside the device's
secret (`~/.neuralis/device/ceiling.json`). The app cannot write it. The broker
re-reads it on every request, and a malformed file reads as deny-all, never as
the previous value. It ships with **no folder**: "not configured" never means
"unlimited". Its `exec` list starts with only the folders of the Node and the
CLI `dist` the device runs (read and run, printed by `install`), where the
sandbox does not already reach them.

| List | What it does |
|---|---|
| `read` | **Clamps** a request: a path appears only if the caller asked for it |
| `write` | The same clamp for mutations. Every write root is also readable |
| `exec` | The **always-present** set, added read-only to every spawn. Interpreters and toolchains belong here |

`exec` grants reachability so a program can start, never readability through
the file tools, which is why `/proc` in `exec` exposes no process environment
to them.

```json
{
  "read": ["/home/you/projects"],
  "write": ["/home/you/projects", "/home/you/.config/that-cli"],
  "exec": ["/usr", "/bin", "/lib", "/lib64", "/etc", "/proc",
           "/home/you/.local/bin"],
  "maxTimeoutMs": 600000
}
```

<Callout type="warn" title="Know what a write root costs">
Every `write` root is folded into the readable set, and the host filesystem
tools then reach it. If a CLI's state directory also holds its saved
credentials, naming that directory here makes those files readable from inside
the container. Narrow the write root to the subdirectories the tool actually
needs, and re-check after upgrading it.
</Callout>

Exit code **126** with *permission denied* means the binary, or its symlink
target, is not under an `exec` root; a native program that hangs and dies
usually probed a part of `/proc` the baseline does not grant. A refused path is
recorded with the agent's reason and listed by `status`; `neuralis device grant`
is the answer. The agent never edits this file.

Two opt-ins widen a device, both written by its owner:

- `maxDetachedLifetimeMs` (absent or `0` = denied) enables background host
  shells that survive an application rebuild.
- `neuralis device grant --unconfined --device <id>` (or `device pair
  --unconfined`; a pairing with a host on the same computer says yes unless
  `--sandboxed`) lets THAT pairing's host
  start the owner's own terminals without the sandbox unless the owner picks
  Sandboxed, and the owner's own foreground command when asked — as the broker's own account, root-equivalent on the
  machine as that user. Background runs, MCP servers and other members'
  commands stay sandboxed, and `status` lists the approval per pairing. There is
  no machine-wide switch: a file still carrying the old `confinement:
  "unconfined"` key loads as deny-all until the device's offline upgrade step
  turns it into per-pairing approvals.

`trustedSingleOperator` defaults to `false` and should stay there on any shared
deployment. It accepts two named residuals: the broker runs inside that user's
own login session with their group memberships, and, in an owner's run without
the sandbox, the agent's host processes run as that user outright. In such a run the ceiling file,
the service, its secret and the sandbox helper are writable by the agent's own
process, so the allowlist becomes documentation rather than enforcement;
switching back to `sandboxed` is trustworthy only after you re-verify them
(`neuralis device install` re-proves the helper). Where the caller and the
machine owner differ, use a dedicated service account instead of this flag. It
lives in this owner-held file because platform settings are editable from
inside the application.

On Linux (and WSL2) host commands are confined by the OS sandbox and clamped to
the allowlist for every role. macOS (Seatbelt) and Windows 11 confine the same
way once the sandbox passes its probe on that machine; a device whose sandbox
does not prove itself runs only its owner's own starts without the sandbox, on a
pairing the owner approved there; another member's commands do not start. The model is on [Security](https://docs.neuralisapp.com/enterprise/security.md#folders-on-a-device).

## Virtual desktops [#virtual-desktops]

The machine package spawns one Webtop container per machine session through the Docker daemon. Its settings and environment variables are on [machine-core settings](https://docs.neuralisapp.com/machine-core/config-settings.md).

### Container image [#container-image]

Sessions run the image named by `NEURALIS_MACHINE_IMAGE` (default
`neuralisapp/webtop-ubuntu-xfce:<version>`, the release's own version). The image is built on the LinuxServer
Webtop `ubuntu-xfce` base (Selkies 2 + XFCE + nginx), pinned by digest, and
bakes in:

1. **Chromium**, launched with its DevTools port bound to loopback only —
   Chromium 115+ ignores a bind-address override — so the bridge in item 5
   republishes it on the container's own interface and the browser is drivable
   over Playwright/CDP from the moment the desktop is up.
2. **Node 26 and the machine-agent sidecar** — the in-container HTTP service
   that executes shell commands, synthesizes desktop input, and captures
   screenshots and recordings.
3. **Desktop-drive userspace** — `xdotool`, `wmctrl`, `xclip`, `maim`,
   `scrot`, `imagemagick`, `ffmpeg`, `x11-utils`, and the AT-SPI
   accessibility stack (the `read_a11y` action returns `501` when the
   accessibility bindings are unavailable).
4. **`ripgrep`**, which backs content search inside the container — this is
   what `fs_search` runs against a machine source; the in-container agent
   falls back to `grep` only if it fails.
5. **The CDP bridge** — served by the in-container agent itself, forwarding the
   container interface's CDP port to Chromium's loopback DevTools endpoint so
   Playwright/CDP can reach it from outside. It answers only the container's
   own sidecar token, on the DevTools HTTP requests and the WebSocket upgrade
   alike, so another container on the same network cannot drive this browser.

The first beta's bundled desktop is Ubuntu + XFCE. Operators may set
`machineImage` to their own compatible derivative; that image must provide
the authenticated machine-agent sidecar and desktop/CDP services described
above. A plain upstream Webtop image does not provide those Neuralis services.

Sidecar fixes ship in the Webtop image separately from the Neuralis image.
Existing desktops keep their current image across stops and starts. To apply
a sidecar update, build or pull the updated Webtop derivative and replace the
container while keeping its profile volume. Filesystem reads preserve original
bytes under `machineFsReadMaxBytes`; oversize files get a bounded text preview
or marker, without partial binary attachments.

### Docker socket access [#docker-socket-access]

The package talks to Docker through the socket at
`NEURALIS_MACHINE_DOCKER_SOCKET` (default `/var/run/docker.sock`). The
default compose file bind-mounts the host socket into the Neuralis container
so machine-core can spawn per-user Webtops.

<Callout type="warn" title="The Docker socket is privileged">
Treat socket access as root-equivalent on the host. Keep machine containers
off any publicly routable network and route desktop/browser streams only
through the authenticated package routes — the stream credential is injected
server-side and never reaches the user's browser.
</Callout>

If the socket is unreachable (or `dockerode` is not installed) Neuralis still
boots cleanly in zero-machine mode: machine tools return a structured
"docker unavailable" error and the widget surfaces the reason instead of
failing silently.

### Networking [#networking]

When Neuralis itself runs as a container on a user-defined Docker network,
machine-core detects that network and attaches Webtop containers to it, so
the sidecar and CDP ports are reachable container-to-container without any
published ports. Without a shared network it falls back to published-port
mode: the container's stream, CDP, and sidecar ports are published on
ephemeral ports of the host's loopback interface (`127.0.0.1`, never every
interface) and reached via `NEURALIS_MACHINE_HOST_ADDRESS`.

The desktop stream is served on the platform's companion HTTP server, at its own
browser address — `MCP_BASE_URL` (default port `3101`), or
`NEURALIS_COMPANION_ORIGIN` on a one-hostname install — never on the app's own
address, because the stream page comes from the container. The workspace widget
points its iframe at `/machine/<sessionKey>/stream/…` there, opening it with a
single-use pass the app address issues (valid 60 seconds); the stream accepts
only the cookie that pass becomes, one per desktop, so a stream URL typed by hand
without the widget is refused. The desktop works when that address is a separate
name or another domain as well. Serve MCP over
https when the app is on https: a browser will not show a plain-http desktop
inside an https page, and a browser that blocks third-party cookies cannot show
it while the app and its MCP address are unrelated domains. The frame is
positioned there so the stream client's relative asset
URLs and its WebSocket upgrade stay on the same origin as the iframe document,
and the machine WebSocket server takes over the upgrade. The
`session/:key/stream/*` package route proxies the same stream for direct API
callers; a page it returns opens sandboxed (no script authority on the app's
address). All three surfaces run the request through the same project → feature
→ owner → ready authorization ladder and inject the stream credential
server-side.

### Storage and resources [#storage-and-resources]

- **Profile volume.** Each machine gets a named Docker volume mounted at
  `/config`, so logins, installed apps, and files persist across stops, starts
  and even a container delete. `DELETE /sessions/container?purge=1` removes it
  once the machine is stopped, and that is the only thing that does.
- **Recordings bind mount.** The in-container recordings directory is
  bind-mounted from the machine's own project's data directory on the host,
  which makes disk-mode recordings addressable as
  `data://machine-core/recordings/<file>` in that project and keeps them out of
  every other project's reach. Inside the project they are project data, so
  any member who may read the project's `data` zone can open them. A machine
  created before this per-project layout keeps running until it is stopped,
  but will not start again: delete its container to re-create it (the `/config`
  profile is kept). When Neuralis runs in a container against the host's Docker daemon, this
  bind source is translated from the in-container `NEURALIS_HOME` to the real
  host path in `NEURALIS_HOST_HOME`, so the mount lands on the actual host
  filesystem.
- **Memory.** Webtop containers run with a 512 MB `/dev/shm` allocation
  (Chromium needs it); budget roughly one desktop-class workload per
  concurrently active user. The idle window keeps the steady-state footprint
  proportional to RUNNING machines, not to the user count — a stopped machine
  costs disk, not memory.
- **Audit and logs.** Machine audit records are appended to the `data://` zone
  of the project each action belongs to (`audit/machine-audit.jsonl`), covered
  by the package's [URI policy](https://docs.neuralisapp.com/package-system/uri-policies.md) baseline,
  which keeps the trail unreadable for agents and members — only project
  owners and admins read it. The package's own log, the audit of a project
  being permanently deleted, and records that name no valid project are
  platform data, kept in the platform's own data directory and read only with
  platform audit access.

### Session lifecycle in operation [#session-lifecycle-in-operation]

Machines are created lazily — the first widget open or tool call for a source
triggers the spawn — and touched on every tool call. A machine idle past
the idle window (`machineIdleMinutes`) is **stopped**, never removed: the container,
everything installed into it and the profile volume all survive, and the next
start is a `docker start` measured in seconds. Running machines also survive a
Neuralis restart — they are adopted again at boot. Owners manage all of this
from the machine widget, the session routes, or the `manage-machine-sessions`
skill — see [machine-core skills](https://docs.neuralisapp.com/machine-core/skills.md).

Machine containers are labelled into a `neuralis-machines` Docker Compose group
so they stay together in Docker Desktop. That grouping is label-derived, so a
group-wide action there (or a file-less `docker compose -p neuralis-machines
down`) stops and removes **every** machine container at once; profile volumes
survive unless `-v` is passed.

Each container CREATE mints a fresh bearer token for the in-container agent, and
an ADOPTED container keeps the token it booted with, so a stop and a later start
never invalidate it. If a container is restarted out of band (for example a host
resume) or re-created outside the manager, the shell and filesystem clients
self-heal: a single authentication failure makes them
re-adopt the live session and rebuild against the current token before
retrying once, so Webtop shell and the machine source filesystem keep working
alongside an already-attached browser session. A genuine authentication
failure still surfaces after that single retry.

## What persists where [#what-persists-where]

All durable state lives outside the container, so rebuilds and upgrades never
touch it:

- `~/.neuralis/app/`: the platform zone (users, projects, platform settings,
  encrypted credentials, the audit log, native packages' platform data);
- `~/.neuralis/projects/`: the per-project zone (agent data, conversations,
  source configurations, project packages);
- `~/.neuralis/checkpoints/`: automatic data checkpoints, a way back one build,
  not a backup;
- the `qdrant-data` volume: the vector index **and** `brain://` content, which
  lives only there. Back it up together with `~/.neuralis`;
- the `.env` beside the compose file, holding the vector database key, ports
  and addresses.

## Backup and restore [#backup-and-restore]

A complete backup is four things taken at one consistent point: **the data
home** (including the credential master key `app/config/credential-master.key`,
without which every stored secret is unreadable), **the Qdrant volume**
(`<project>_qdrant-data`, primary data rather than a rebuildable index),
**the `.env`**, and **`docker-compose.override.yml`**.

```bash
npx neuralis backup                          # stops the app and Qdrant, copies, starts them again
npx neuralis backup --out DIR                # default: a HOME_DIR-backups/TIME folder beside the home
npx neuralis backup --include-volume NAME    # also a snapshot, desktop-profile or Ollama volume
npx neuralis backup list                     # complete backups, newest first
```

The stack is down only for the copy. The command refuses, before stopping
anything, without the `.env`, without enough free space, or with a target inside
the data home or install folder; a run where a file changed while it was read
fails and writes no manifest. The folder is created `0700` and every file
`0600`: it holds every secret of the install.

```bash
npx neuralis restore DIR                                         # the app must be stopped; asks for the folder name again
npx neuralis restore DIR --home TMP_HOME --volume CLONED_VOLUME  # rehearse into a throwaway home and volume
```

`restore` refuses while the app runs, reads every archive before anything
moves, and deletes nothing: the current home, volume, `.env` and override are
kept as `*.before-restore` copies. Afterwards run
`npx neuralis setup --compose-only` and `docker compose up -d -V`. Never run
`docker compose down -v` on the way: it deletes the volume.

## Upgrading and going back a version [#upgrading-and-going-back-a-version]

An upgrade replaces the application, never the data. The compose file runs one
exact release (`NEURALIS_IMAGE_TAG` in `.env`). How each kind of install moves
is on [Updating](https://docs.neuralisapp.com/getting-started/updating.md); every path then regenerates the
compose file, stops only the app (Qdrant keeps running), raises the stored
formats and recreates the stack with `docker compose up -d -V`.

Every stored record kind carries its on-disk format in one ledger
(`app/config/data-formats.json`):

- **Older data:** the new build refuses to start and names the upgrade. The
  running app never raises a format.
- **Newer data:** the build does not start, writes nothing, and the server log
  names the record kind, both versions and the restore command; `/api/health`
  answers `503`.
- **Every format is raised offline**, with the app stopped:

```bash
npx neuralis upgrade            # dry run: what would change; writes nothing
npx neuralis upgrade --apply    # one checkpoint, then every pending upgrade
```

The upgrade takes one checkpoint of every file it is about to touch; re-running
resumes an interrupted run, and a completed run writes nothing.
`dataCheckpointKeep` (default 5) bounds how many checkpoints are kept. An
upgrade that reads the vector store needs Qdrant running, so stop only the app
(`docker compose stop neuralis`), never `down`.

**Going back**, data first (an older build refuses data a newer one raised):

```bash
npx neuralis checkpoint list           # checkpoints, newest first, and the format ledger
npx neuralis checkpoint restore ID     # the app must be stopped; asks for the id again
```

`restore` replaces the listed files wholesale, so everything written after the
checkpoint is lost. Then move the code back
(`npx neuralis update --version <previous> --apply`), or write the previous
release into `NEURALIS_IMAGE_TAG`, regenerate the compose file and run
`docker compose up -d -V`. A checkpoint covers the control plane only, never
the vector store or `.env`. Qdrant's own version is a separate, deliberate step
(see the [production checklist](#production-checklist)).

## Native Node [#native-node]

The same host runs without Docker on Node 26 or newer, from a clone of the
public host repository:

```bash
npm install
npx neuralis setup
npm run build
npx neuralis start   # on the app port setup wrote to .env
```

On Linux the terminal's native module compiles at install, so the machine needs
python3, make and a C++ compiler. You provide a Qdrant instance (`QDRANT_URL`);
setup can download and start a Qdrant binary, and offers a running one rather
than adopting it silently. Without a reachable Qdrant the host still starts and
serves; search and indexing answer that the vector store is not available yet,
and continue by themselves once it answers. In-memory vectors run only where
setup configured no Qdrant.

## Runtime topology [#runtime-topology]

```text
Browser
  -> Next.js host (:3100)
    -> auth/session and project membership
    -> package catch-all route (/api/packages/[...path])
      -> package loader / runtime / route dispatcher
        -> package routes, tools, commands, connectors, App surfaces

External MCP client
  -> MCP HTTP service (:3101)
    -> OAuth JWT, per-agent API-key, or platform API-key auth
    -> package-hosted MCP tools, prompts, and resources
```

Both ports belong to one process; see [MCP access](https://docs.neuralisapp.com/enterprise/mcp-access.md).

## Health and readiness [#health-and-readiness]

`GET /api/health` on port `3100` is unauthenticated, side-effect free and
reflects the bootstrap lifecycle:

- `200 { status: 'ready', health: 'ok', refusedBuiltins, … }`: warm-up
  completed. `refusedBuiltins` counts the packages the platform runs without;
  the admin health view names them, this probe never does.
- `200 { status: 'degraded', health: 'degraded', … }`: the host serves while a
  package reports a partial state — a vector store that does not answer yet,
  for example, which the host joins by itself once it answers. Any package's
  `degraded` answers `200`; the admin health view names which.
- `503 { status: 'degraded', health: 'starting' | 'failed' }`: a package is
  still starting, or its health check failed.
- `503 { status: 'initializing' | 'error' }`: still warming up, or failed.
- `503 { status: 'setup_required', code }`: setup has not run
  (`secret_missing`, `setup_incomplete`) or an earlier release's install still
  needs `upgrade --apply` (`secret_moved`). Every other route answers `503` too
  until setup has run.

The compose healthcheck and the image's own `HEALTHCHECK` poll this endpoint
after a 50-second start period. Point your platform's readiness probe at it.
The MCP service's `/healthz` on port `3101` is process liveness only.

## Graceful shutdown [#graceful-shutdown]

On SIGTERM (a rolling update, a recreate, `stop`, a scale-down) the host
**drains in-flight agent turns before exiting**: each running stream is
persisted first, background subagent runs are recorded as interrupted, and
teardown runs after the drain. The window is the **Shutdown Drain Timeout**
setting (default 25 seconds); keep it below your platform's stop grace period
(the bundled compose allows 40 seconds; on Kubernetes set
`terminationGracePeriodSeconds`). A watchdog forces the exit shortly after the
window. A hard kill skips the drain; a background subagent cut that way resumes
from its own transcript after the next start, and a run parked on an approval is
still answerable afterwards.

## The public origin [#the-public-origin]

`NEXTAUTH_URL` and `APP_URL` must name the origin **users actually reach**,
port included. Undeclared, the host answers `http://localhost:<its port>`, a
development convenience: authentication and OAuth callbacks resolve against
these values, so a deployment reached over another origin completes a login and
then sends the browser to *its own* machine. `.env` is their one source; an
edited `.env` applies on the next `docker compose up -d`.

A deployment has three addresses:

- **The app address** (`APP_URL`, port `3100`): sign-in, OAuth consent, the
  workspace and the terminal. The session cookie lives here only.
- **The MCP address** (`MCP_BASE_URL`, port `3101`): the `/mcp` endpoint and
  its OAuth issuer, the CLI, MCP clients, the device link and, unless
  `NEURALIS_COMPANION_ORIGIN` names another address, the virtual desktop stream.
- **The sandbox** (`NEURALIS_MCP_SANDBOX_ORIGIN`, else the app's hostname on
  port `3102`): the isolated origin MCP app views render in; it must differ from
  the app's origin.

Setup derives the MCP and sandbox addresses from the public origin and keeps a
value you declared yourself.

| Shape | `.env` | What the proxy serves | Notes |
|---|---|---|---|
| Same host, three ports (default) | the public origin only | nothing, or all three ports | Over `https`, the proxy terminates TLS on all three ports |
| Own names (subdomains, reverse proxy, the tunnel) | `APP_URL`, `MCP_BASE_URL=https://mcp.<domain>`, `NEURALIS_MCP_SANDBOX_ORIGIN=https://sandbox.<domain>` | each name to its port | What `neuralis tunnel` writes |
| Unrelated domains | as above | each name to its port | The desktop needs a browser that keeps partitioned cookies in a cross-site frame |
| One hostname | `MCP_BASE_URL` equal to `APP_URL`, a sandbox of its own, `NEURALIS_COMPANION_ORIGIN` for the desktop | everything to `3100` (the app forwards MCP and the device link); the desktop's own name or port to `3101` | A proxy that sends `/mcp` to `3101` must send `/ws/device-link` there too and set `X-Forwarded-For` |
| `https` app, `http` MCP | `APP_URL=https://…`, `MCP_BASE_URL=http://…` | the app port only | Not supported for the desktop; serve MCP over `https` too |
| LAN | the LAN address on the three ports | — | The CLI and devices refuse plain http off this computer; give them `https` or the tunnel |
| The desktop app | written by its first start | — | It runs the full host; every row applies |

The origins are operator configuration, never an Admin setting. **Changing
them retires every sign-in made on the old address:** MCP clients and the CLI
sign in again, devices pair again, earlier invite links still name the old
address, and apps registered on a provider's side keep the old
`<APP_URL>/api/oauth/…` callback until you change it.

### Reach it from anywhere: `neuralis tunnel` [#reach-it-from-anywhere-neuralis-tunnel]

With a Cloudflare account and a domain in it, one command puts the host on the
internet without opening a port:

```bash
npx neuralis tunnel on example.com     # app.example.com, mcp.example.com, sandbox.example.com
npx neuralis tunnel                    # status
npx neuralis tunnel off                # the origins `on` replaced, else this machine's
```

It signs in to Cloudflare once, creates or reuses a named tunnel, routes the
three hostnames, adds a `cloudflared` service to the compose file and writes the
three origins into `.env`. `--access EMAIL` or `--access @company.com` puts
Cloudflare Access in front of the browser hostname, leaving `/api/` to
Neuralis's own sign-in; MCP clients are never put behind Access. A tunnel is
reachability, never identity: every request still meets the app's login and
permissions, and a loopback request carrying a forwarding header is treated as
remote. Qdrant and Ollama stay on loopback.

## Production checklist [#production-checklist]

- Set `NEXTAUTH_URL` / `APP_URL` to the public origin.
- Put the app behind TLS and a reverse proxy, and declare that proxy in
  `NEURALIS_TRUSTED_PROXIES` (its own address, never the Docker gateway).
  Neuralis believes `X-Forwarded-For` only from a declared proxy; left empty,
  every login is attributed to the connecting socket, so behind a proxy the
  per-address spray brake and the webhook rate cap become global. Forward the
  browser's `Origin` and `Sec-Fetch-Site` headers unchanged: a cookie-carrying
  request that changes something is accepted only from the app address.
- Preserve WebSocket upgrades and disable proxy buffering for SSE. Live
  workspace updates flow over one multiplexed `/api/events` connection.
- Keep Qdrant private (the compose file binds it to loopback on its own network,
  and it requires the key on every request).
- Publish the MCP address only to the clients that need it: the CLI, devices,
  MCP clients and the desktop stream. A browser-only deployment without the
  desktop can keep it private.
- Treat a paired device like a mounted Docker socket: pair only machines whose
  owner means it, and keep each allowlist as narrow as the work requires.
- Back up the home, the Qdrant volume and `.env` together
  ([backup and restore](#backup-and-restore)).
- Treat the Qdrant version as part of your install. Its on-disk format is
  forward-only and upgrades one minor version at a time, so setup records the
  version your storage is on and refuses when it is more than one minor version
  behind this release, naming `npx neuralis qdrant-upgrade`. That command stops
  the app, records point counts, takes a cold backup of the volume and walks
  every minor version, checking the counts after each; on any failure it
  restores the backup. Try `--dry-run` or `--rehearse <volume>` first. Never
  recover by removing the volume: that deletes every embedding and forces a
  full re-index at real provider cost.