# Installation

> Install the drkm command, start a local isotope or sign in to one you already have, and get the Python SDK where your code runs.

## Install the CLI

One command installs `drkm` on Apple silicon macOS and on x86-64 or ARM64 Linux. Run it as your own user, not as root, with `curl` on the PATH. It opens your browser to sign in with the account Darkmatter granted installer access to, then carries on by itself. Over SSH it prints a link to open on any device; after you sign in, the page shows a code to paste into the terminal. The installer then downloads the release, verifies its checksum and saves PATH for new terminals. A first install offers to run `drkm start` right away in the same terminal. What the setup tools print goes to the install log under `~/.local/share/drkm/logs/`, and a failure shows the end of that log.

- The release carries its own Python runtime, locked dependencies, terminal and console, so nothing else needs to be on your PATH. Nothing is compiled or fetched from package indexes.
- On Linux, the tools a local isotope needs are installed if missing: Docker Engine and Buildx, k3d, Helm, kubectl and Nebula. Preparing the machine can prompt for your password.
- On macOS the installer prepares nothing else: a Mac runs its isotope without a VM by default. The first `drkm start` asks for administrator approval once to install the mesh helper. Only `drkm start --vm` installs the `drkm-kvm` Linux VM and its tools.
- Installer access is separate from console accounts and mesh membership. It authorizes downloads and nothing else; contact Darkmatter if sign-in is refused.

```bash Terminal
curl -fsSL https://drkm.com/install | sh

~/.local/bin/drkm --help
~/.local/bin/drkm --version
```

<Note>
  Over SSH the link still works: open it in a browser on any machine and enter the code. The sign-in requests no refresh token and nothing is written to the shell history.
</Note>

## Where things live

- **`~/.local/share/drkm`**: The installation: each release under `releases/`, a `current` link, and install logs under `logs/`.
- **`~/.local/bin/drkm`**: The command, linked into the current release.
- **`~/.drkm`**: Your isotope: its data directory, its settings and credentials under `isotopes/`, and console profiles. Reinstalls and updates never touch it. Read and change the isotope's settings with `drkm config list`, `get`, `set` and `unset`.

Running the installer again over an existing installation asks whether to remove it and install fresh or upgrade in place with your settings carried forward. To skip the prompt, set `DRKM_INSTALL_REPLACE=yes` or `no` in the environment of the `sh` process.

```bash Run the installer again without a prompt
# Upgrade in place, settings carried forward
curl -fsSL https://drkm.com/install | DRKM_INSTALL_REPLACE=no sh

# Remove the installation and install fresh; ~/.drkm is kept
curl -fsSL https://drkm.com/install | DRKM_INSTALL_REPLACE=yes sh
```

## Start a local isotope

`drkm start` provisions the isotope on this machine, prints its address and attaches the terminal workspace. The first start loads the release's prebuilt application image (or builds it when the release has none), creates the local cluster and pulls its service images, so it takes longer than later starts. The console is served at `https://drkm.localhost:3756` by default, and every start also prints a name for your local network, `https://<callsign>.local`.

The first start asks two things:

- **Identity.** Create the first administrator with a password, or point the isotope at an OIDC provider you already run. `drkm setup` completes this step on its own, and `drkm setup --file` reads it from a private JSON file for unattended installs.
- **Name.** A callsign for the fleet, such as `harbor-mac`. `--tag` sets it without a prompt; leave it blank for a generated one.

It asks nothing about models. The isotope starts without one, and the chat composer's model selector reads **Load a model**: it offers an administrator the library model sized for this device in one click, with Settings → Models one link away for another model or a provider. `drkm models setup` makes the same choice in the terminal; see [models and inference](https://docs.drkm.com/models).

A fresh installation belongs to no mesh. The console and the local isotope work on their own until you [create or join a mesh](https://docs.drkm.com/mesh).

```bash Terminal
# Provision, print the console address, attach the terminal
drkm start

# Name the isotope for the fleet, or choose its ports
drkm start --tag harbor-mac
drkm start --https-port 3756 --http-port 8081

# Start without attaching the terminal
drkm start console

# Finish identity setup later, or choose inference in the terminal
drkm setup
drkm models setup

drkm stop
```

<Note>
  On Apple silicon a new isotope runs without a VM: each part is a launchd job, and the first start asks for macOS administrator approval once to install the mesh helper. drkm start --vm runs it in the drkm-kvm VM instead, and drkm start --native switches back. A home that already runs its isotope in the VM keeps it. Stop the isotope before switching.
</Note>

## Sign in to an existing isotope

You do not need a local isotope to work. Sign this terminal in to any isotope you can reach, then use the same `drkm console` commands against it. After `drkm start` the terminal already knows your local isotope, so `drkm console login` with no address signs in there.

- With no flag, it opens your browser to sign in and the session comes back to the terminal. Over SSH it prints a link to open anywhere, and you paste the code the page shows.
- `--password` prompts for email and password, where the isotope keeps local accounts.
- `--token` accepts an API key.

Keep saved credentials in the OS keyring. For automation, inject an API key from your secret manager into `DRKM_TOKEN` at runtime; do not save it in a script or file. A saved sign-in is bound to the address it used. For an isotope on a private mesh with its own certificate authority, pass `--tls-ca` with the CA bundle.

```bash Terminal
drkm console login https://isotope.example
drkm console whoami

# A private-mesh isotope with its own certificate authority
drkm console --tls-ca /path/to/ca.pem login https://isotope.example --device

# Target an isotope from the environment instead
DRKM_URL=https://isotope.example DRKM_TOKEN="$API_KEY" drkm console jobs

drkm console logout
```

## Get the Python SDK

The SDK is the `drkm` package on PyPI: Python 3.12 or later, with Pydantic as its one dependency. Where you use it decides how you get it.

- **Inside an agent sandbox** it is already installed. Code the agent runs can `import drkm` at once.
- **In the installed release**, the `drkm` command’s own Python environment carries it.
- **In your own environment**, install it from PyPI with `pip install drkm`, or `pip install "drkm[keyring]"` to reuse credentials saved by `drkm console login`. On an air-gapped machine, `pip install ~/.local/share/drkm/current/sdk` installs the same package from the local release.

Keep the SDK aligned with the release of the isotope you connect to.

```bash Terminal
python3 -m venv .venv
source .venv/bin/activate
python -m pip install "drkm[keyring]"

python -c "import drkm; help(drkm.connect)"
```

<Note>
  Install the keyring extra (`python -m pip install "drkm[keyring]"`) to reuse a sign-in stored in the OS keyring by `drkm console login`. For automation without a keyring, install `drkm` on its own and inject an API key from your secret manager into `DRKM_TOKEN` at runtime.
</Note>

## Update and check versions

`drkm update` fetches the latest published release, verifies its checksum, upgrades the installation in place and redeploys a running isotope, restoring the previous release if the new one never becomes healthy. Settings and isotope data already stored in the active home (`$DRKM_HOME`, or `~/.drkm` by default) survive the release change. Older installations with a custom data directory need the migration below. A stopped isotope comes up on the new release at its next `drkm start`.

Installation registers a per-machine update key with the same approval as the download, so later updates need no browser. Isotopes also update themselves once a day unless an administrator turns **Automatic updates** off in **Settings → Updates**, where **Check for updates** and **Update now** live as well. An update restarts the isotope.

```bash Terminal
drkm update

drkm --version              # the installed product version
drkm version                # compares it with the running isotope
drkm version --diagnostics  # build identity

# Re-approve this machine after a refused update grant
drkm update --authorize
```

### Before updating a legacy custom data directory

If you set `DRKM_HOME` and an older installation still uses `drkm-local:dataDir` in its Pulumi stack, migrate that data before updating. An explicit home disables automatic legacy-data migration. The update removes `dataDir` from the carried primary stack; the new release reads `$DRKM_HOME/data` instead. It leaves the old directory in place, but does not find its data automatically.

1. Turn off **Automatic updates** in **Settings → Updates**. Record the old `dataDir` path from the current release's stack file; resolve a relative path against that release's `infrastructure/local` directory.
2. Stop the old isotope with its existing release and home setting. Back up the complete old data directory and the active home before copying anything; do not copy a running database.
3. If `$DRKM_HOME/data` already exists, stop here: do not overwrite it or merge two isotopes' data. Otherwise copy the entire old data directory to `$DRKM_HOME/data`, including hidden files, preserving ownership and permissions. Keep the original and backup.
4. Use the same `DRKM_HOME` for `drkm update` and the next `drkm start`. Confirm the isotope's identity and existing data in the console before re-enabling automatic updates or retiring the old copy.
