# Machines: `lp machine` (for agents)

Need a GPU, Blender, a real browser, DaVinci Resolve, ComfyUI, ffmpeg/whisper, a clean dev box or an Android phone?
Don't set one up. Ask for one:

```bash
lp machine up chrome                      # headless Chrome + CDP + Playwright        (homelab, free)
lp machine up media                       # ffmpeg, yt-dlp, faster-whisper, ImageMagick (homelab, free)
lp machine up dev                         # node, python, bun, git, gh, docker          (homelab, free)
lp machine up android                     # fresh Android 11 emulator + adb + Chrome    (homelab, free)
lp machine up blender-gpu --gpu any --max-price 0.30 --max-hours 1      # Blender + Cycles on a rented GPU (Vast)
lp machine up comfyui --gpu 4090 --max-price 0.50 --max-hours 1         # ComfyUI + Wan 2.2 (Vast)
lp machine up davinci --gpu any --max-price 0.30 --max-hours 2          # DaVinci Resolve free on a GPU (Vast; see DaVinci below)
```

`up` picks the machine, installs the image, runs the image's **health check** (its outcome), and prints an id.
It fails (and destroys the machine) when the health check fails, so a machine you get is a machine that works.

Then:

```bash
lp machine exec <id> -- <command>              # run it there (stdout/exit code come back)
lp machine exec <id> --detach -- <long job>    # background job;  lp machine jobs|wait|logs <id> <job>
lp machine cp ./input <id>:/work/              # upload  (files or folders)
lp machine cp <id>:/work/out ./out             # download
lp machine tunnel <id> 9222                    # a machine port on your localhost (ssh tunnel; nothing public)
lp machine ssh <id>                            # interactive shell
lp machine down <id>                           # destroy (do this when done; it also happens automatically)
lp machine ls | status <id> | spend | images | offers --gpu 4090
```

## Which provider runs it: bring your own compute first

`lp machine up IMAGE` (auto) never spends money unless the owner opted in. Order:

1. **this computer** (`local`): Docker / Podman / Colima on a Mac, Docker (or WSL) on Windows, Docker on Linux;
   with no container engine, a folder machine (bare recipe) where the image has one.
2. **your own machines over ssh** (`lp machine add NAME --ssh user@host [--jump j] [--key k] [--port p]`), in the
   order you added them. Uses your ssh config and keys; a container when the box has docker/podman, else bare.
3. Waleed's homelab / vps sandbox (non-GPU images, when configured).
4. **a rented GPU (Vast)** only if BOTH: the owner ran `lp machine config allow_rent true` at a terminal (agents
   cannot set it), and the job passes `--allow-rent` (a pack declares it). Otherwise `up` fails and lists why each
   own machine could not run the image.

`--on local|NAME` picks one machine; `--provider` still forces one provider.

Nothing about anyone's network is built in: every machine is yours, in `~/.logicpacks/machines/config.json`.

```
lp machine add box1 --ssh me@box1.lan                       # any Linux/Mac box with docker/podman (or bare)
lp machine add pve1 --homelab root@10.0.0.5 [--remote-ssh root@pve1-ssh.example.com] [--storage local-zfs]
                    [--gw 10.0.0.1] [--emulator] [--vps-host]   # a Proxmox node: LXC per machine (homelab provider)
lp machine config desktop.zone example.com                   # lp machine desktop: a Cloudflare zone you own
lp machine config desktop.zone_id <id>; lp machine config desktop.account_id <id>
lp machine config android.base_image <emulator image>; lp machine config android.sdk_src <SDK path on the node>
```

GPU detection: NVIDIA (driver + container runtime, `--gpus all`; podman uses CDI) runs every GPU image on your own
box. Apple Silicon: containers cannot reach Metal, so GPU work runs bare with MLX (today: `train-llm`).

`lp machine doctor [NAME] [--fix]` shows engine, GPU, KVM, free disk and which images fit, per machine. Facts are
cached for an hour; `--fix` starts Colima on a Mac.

| provider | what you get | cost |
|---|---|---|
| `local` | a container on this computer (or a folder machine under ~/.logicpacks/machines/bare) | free |
| `ssh` | a container (or folder) on your own machine over ssh | free |
| `homelab` | Proxmox LXC container cloned from a per-image template | free |
| `vps` | a locked-down docker container inside the sandbox VM `lp-sandbox` | free |
| `vast` | a rented GPU on Vast.ai, opt-in only, on-demand by default (`--spot` for interruptible) | $/h, capped |
| `android` | a fresh Android 11 emulator (KVM) per task | free |

Local/ssh containers: caps dropped, no-new-privileges, CPU and memory capped (memory at most 75% of the host), the
same lp-guard (idle 15 min, deadline) inside. Images are built once per recipe hash (`lp/<image>:<hash>`); later
machines start in seconds. Persistent model caches are named volumes (`lp-models`), never host paths.

`lp machine sync ID /work/out ./out [--every 300] [--until-job JOB]` pulls a folder (checkpoints) home while a job
runs: rsync over ssh when possible, else a tar copy. Each round counts as an lp heartbeat.

## Images

| image | contents | outcome check (health) |
|---|---|---|
| `chrome` | Google Chrome headless, CDP on 127.0.0.1:9222, Playwright (node + python), `lp-chrome`, `shot.mjs` | Chrome opens a page through CDP and screenshots it |
| `media` | ffmpeg, yt-dlp, faster-whisper (`lp-whisper`), ImageMagick, espeak-ng, sox | speech -> video -> transcribed back by whisper |
| `dev` | Node 22, Python 3 + uv, Bun, git, gh, Docker (homelab/vps only, not inside containers) | node/bun/python run, git works, docker runs hello-world |
| `blender-gpu` | Blender 4.5 LTS, `lp-blender-render`, Cycles on OptiX/CUDA, logicpacks_bridge add-on when present | Blender renders a frame (reports the device) |
| `comfyui` | ComfyUI, `lp-comfy` (start, models, run API workflows), Wan 2.2 TI2V 5B models + workflow (`wan22-14b-i2v` set also available) | makes a 49-frame 640x352 clip on the GPU |
| `davinci` | DaVinci Resolve free, Xvfb + VirtualGL (EGL on the NVIDIA GPU), `lp-resolve`, noVNC | builds a timeline from two clips and renders it on the GPU |
| `android` | Android 11 (Google APIs x86_64), adb, Chrome | boots and opens a page in Chrome |
| `train-llm` | `lp-train-llm`: LoRA (MLX on Apple Silicon) / QLoRA (NVIDIA, peft + bitsandbytes), eval, GGUF export via llama.cpp | a 0.5B model learns a made-up answer format from 100 rows (held-out exact match up), GGUF written |
| `train-diffusion` | `lp-train-diffusion`: ostris ai-toolkit, FLUX.1-schnell LoRA (quantized, 24 GB) | 100-step style LoRA trains and renders a sample |

`chrome` on arm64 uses Playwright's Chromium as `google-chrome` (Google ships no Linux arm64 Chrome). `davinci`
shows `needs-zip` in `lp machine images` until it is verified end to end: bring the free Linux zip.

## Spend safety (always on, no flag turns it off)

- Every paid machine has a **$/h ceiling** (`--max-price`, default $1.00, hard ceiling $3.00) and a **lifetime** (`--max-hours`,
  default 4, hard ceiling 12). At the deadline the machine destroys itself.
- **Idle = destroyed**: no CPU/GPU/network activity for 15 min, **or** no `lp` heartbeat for 15 min while no `lp` job is running.
  Every `lp machine` call is a heartbeat; `exec` and `--detach` jobs keep the machine alive while they run; a busy GPU counts as activity.
  This runs **on the machine** (`lp-guard`), so it works even if your computer or the agent is gone. On Vast it destroys the instance
  with Vast's per-instance key; the account key is never on the box.
- A **reaper** on your computer (every `lp machine` call + every 5 min: `lp machine reaper install`) destroys past-deadline and orphaned
  `lp-*` instances and records machines that ended themselves.
- **Daily cap** (default $20/day UTC): today's spend + the worst case of every live machine + the new one must fit.
- **Vast credit floor** (default $5): no rental if credit minus the new machine's worst case would drop below it.
- Every rental, destroy and self-end goes to the ledger: `lp machine spend` (also `~/.logicpacks/machines/SPEND.md`).
  The ledger counts $/h x time. Vast also bills bandwidth per GB and disk, so big model downloads cost extra; the credit floor
  check uses the real credit, so that is still capped.
- Caps can be tightened by anyone; **loosening a cap needs a person at a terminal** (`lp machine config daily_cap_usd 30`); agents get
  `refused` (exit 3).

Pattern for long jobs (copy results, then destroy, in the same turn):

```bash
id=$(lp machine up blender-gpu --gpu any --max-price 0.30 --max-hours 2 --json | python3 -c 'import json,sys;print(json.load(sys.stdin)["id"])')
lp machine cp ./scene.blend $id:/work/
lp machine exec $id --detach -- lp-blender-render /work/scene.blend --anim --out /work/out/
lp machine wait $id <job>                  # blocks until done (heartbeats while waiting)
lp machine cp $id:/work/out ./renders
lp machine down $id
```

## Keys

Machines never get key values. `lp machine exec <id> --keys GITHUB_TOKEN,OPENAI_API_KEY -- <cmd>` gives the command
`lp_sealed_*` placeholders plus an HTTPS proxy that reaches **your** LogicPacks keys through the ssh connection (`ssh -R`); LogicPacks keys swaps the
real value in on the way out (same policy: allowed hosts, packs, rate). When the command ends, the session closes.
The Vast account key itself comes from the vault (`lp key add VAST_API_KEY --hosts console.vast.ai`) through LogicPacks keys; it is never printed.

## Isolation

- One task = one machine. Destroy it when done (`down`, or the guard does it).
- No host mounts in task machines; no Waleed secrets on GPU rentals; persistent browser profiles are per space
  (`--space NAME`) and are saved to your computer at `down` and restored at the next `up` (never baked into an image).
- Homelab CTs, the sandbox VM and Android instances reach the **internet only**: an nftables/iptables rule drops traffic to
  private ranges (the LAN, other homelab boxes, the phone gateway) except DHCP/DNS to the router.
- adb for Android stays inside its instance; you reach it only through `lp machine tunnel <id> adb` (authenticated ssh tunnel),
  then `adb -P 5091 connect 127.0.0.1:<port>` (a private adb server: never the shared one some Macs forward on 5037).
  Simple commands work without a tunnel: `lp machine exec <id> -- shell getprop ro.product.model` runs `adb <args>` inside the instance.
- The `vps` sandbox is a separate VM (`lp-sandbox`, VMID 7699 on your `--vps-host` Proxmox node), never a production server; containers there run without NET_RAW/NET_ADMIN/SYS_ADMIN and with
  no-new-privileges, no host mounts, no inter-container traffic, and cannot open connections to the sandbox VM itself. It is kept isolated so it can later run untrusted code
  (e.g. an MCP verification harvester).

## Desktop (watch / take over)

`lp machine desktop <id> on --email you@example.com` starts noVNC on the machine and publishes it as
`https://desk-<id>.<your zone>` behind Cloudflare Access (only that email). `off` (or `down`) removes the hostname, tunnel and Access app.

Measured: tunnel registered and the hostname answered with the Cloudflare Access login (302) within ~10 s of `on`;
`down` left no tunnel, DNS record or Access app behind.

## DaVinci Resolve (free): headless vs streamed

- Resolve has no true headless mode. The image runs it on a virtual X display (Xvfb :99) with OpenGL sent to the NVIDIA GPU through
  VirtualGL/EGL, so it needs a GPU box (Vast) even when nobody watches.
- **Scripted** (`lp-resolve render IN OUT`): external scripting (`DaVinciResolveScript` from outside the app) is a Studio feature;
  on the free version the image triggers its Lua script from inside the app (Workspace > Scripts > lp_render), which builds a
  timeline from the clips and renders DNxHR .mov. The free Linux build cannot decode/encode H.264/AAC: give it DNxHR/ProRes + PCM.
- **Streamed** (`lp machine desktop <id> on --email ...`): the same display in a browser via noVNC behind Cloudflare Access, for a
  person to edit by hand.
- EULA: one end user per machine; the machine is single-use and destroyed after the task; the install is never snapshotted,
  committed to an image or copied elsewhere.
- **Install (2026-12-04): bring your own zip.** Blackmagic's registration API answers 403 "Must register" to scripted
  requests, so the person who will use the seat downloads `DaVinci_Resolve_<ver>_Linux.zip` (free, not Studio) from
  blackmagicdesign.com and runs:

  ```bash
  lp machine setup davinci --zip ~/Downloads/DaVinci_Resolve_21.2.1_Linux.zip --gpu any --max-price 0.30 --max-hours 2
  lp machine setup <id> --zip ~/Downloads/DaVinci_Resolve_21.2.1_Linux.zip     # re-run setup on a live machine
  ```

  The zip is streamed over ssh (no copy in memory, no mirror) and dies with the machine.

## Real runs (2026-12-03/04)

| image | where | result |
|---|---|---|
| blender-gpu | Vast RTX 3090 ($0.195/h); GTX 1070 via the pack check ($0.005 total) | OptiX render 960x540 / 128 samples in 5.5 s (3090), 11.2 s (1070) |
| comfyui | Vast RTX 4090 ($0.408/h) | Wan 2.2 TI2V 5B, 49 frames 640x352 in 22.5 s (after 21 GB of model downloads) |
| chrome | homelab LXC | Chrome 158 via CDP opened example.com and screenshotted it (also the pack check) |
| dev | homelab LXC | node 22.12, bun 1.4.5, python 3.11, uv, docker hello-world |
| android | homelab emulator | Android 11 booted in ~64 s, Chrome opened a page; adb worked through the tunnel |
| media | vps sandbox and homelab | espeak -> ffmpeg -> faster-whisper tiny transcribed "hello from the logic packs media machine" |
| idle guard | Vast | an idle machine destroyed itself through the Vast API ~15 min after the last activity (verified: instance gone); a box `lp` could not reach also ended itself after 15 min ($0.014) |

GPU notes: images based on `nvidia/cuda` register CUDA "compat" libraries that break `cuInit` on GeForce cards with an older
host driver; `lib.sh` (`gpu_fix`) removes them on consumer GPUs. The comfyui image upgrades torch to >= 2.7 (cu126 wheels,
any host driver >= 525).


---

Canonical URL: https://logicpacks.io/machines.md

Developed by TechRealm (techrealm.online), the software team. Operated by Al Jash Trading (Establishment), Abu Dhabi, since 1994, the legal entity that hosts and is responsible for the service. Economic licence CN-1030597, Abu Dhabi Registration Authority. Address: Office 5, Bani Yas West 4, Bani Yas, Abu Dhabi, UAE. Website: https://aljashtrading.com. Contact: hello@logicpacks.io, security@logicpacks.io, WhatsApp +1 713 632 2262 (https://wa.me/17136322262).

Machine-readable index: [/llms.txt](/llms.txt). Plain facts: [/about.md](/about.md). Safety: [/safety.md](/safety.md).
