# runy runy is a service runner for development workspaces. A daemon reconciles resources declared in YAML (processes, ports, folders, files, git worktrees, microVMs, templates, ssh machines, file watchers, secrets) and keeps them running; the `runy` CLI and a web console talk to it. One binary holds the CLI, the daemon and the console. This is the condensed documentation, written by hand from the full documentation at https://runy.dev. When this file and the linked page disagree, the page is authoritative. ## Install and upgrade ```sh curl -fsSL https://setup.runy.dev | sh # stable channel curl -fsSL https://setup.runy.dev | sh -s -- --channel nightly curl -fsSL https://setup.runy.dev | sh -s -- --version 0.7.0 runy self upgrade [stable|nightly] [--daemon] runy self use [--daemon] runy self status [--format text|json] runy self remove ``` - `self upgrade|use` move a daemon that runs an installed channel's binary; others only with `--daemon`. Manifests are minisign-signed. Homebrew installs: `brew upgrade runy`. - API and console on `127.0.0.1:4122` (`--port`); proxy on `0.0.0.0:80`, loopback clients only (`--proxy-addr` moves it; if taken the daemon runs without it). `watchman` is optional: without it files are read at start and on `runy signal workspace restart`. Full page: https://runy.dev/start/installation/ ## Core model **Workspace.** A folder with `.runy.json` (or `.runy.yaml`, `.yml`, `.toml`); `{}` is enough. runy walks up from the cwd to find it; `-w ` names one. Config keys: `sources`, `recipients`. ```json { "sources": [".runy", { "path": "products/notes/.runy", "namespace": "notes" }], "recipients": { "alice": "age1..." } } ``` **Sources.** Folders whose `*.yaml`/`*.yml` (any depth, no symlinks) hold resources. ```sh runy load [--ns notes] products/notes/.runy # load and watch; remembered runy unload products/notes/.runy runy sources # PATH NAMESPACE FILES RESOURCES ORIGIN STATE ``` Sources in `.runy.json` cannot be unloaded. Sources may not overlap; load specific folders. **Namespaces.** A document's namespace is its `namespace:` key, else its source's default (`--ns`, or `namespace` in a `sources` entry), else the top level `_`. - Ids are `//`; top level `_//`, typed `/`. `port/web` and `process/web` may coexist. - The top level is always enabled (`runy ns enable _` is an error). Other namespaces are reconciled only when enabled; nothing is enabled implicitly; the set persists. - `runy ns` lists with diagnostics; `runy ns enable|disable ...` (names required; disabling stops resources; readers elsewhere go `Pending`, keep running); `runy ns create|delete `. **Autorun and idle.** Documents with `autorun: true` (default) and what they reference run; others are idle. `runy start|stop ...` runs or idles a resource; idle keeps what it made (vm machine, worktree); only removing the document deletes. **Conditions.** `Resolved`, `Pending` (an expression read an unpublished status or a `needs` entry is falsy; `waiting_on` lists it), `Error`. A resource that turns `Pending` or `Error` after `Resolved` keeps running on its last spec. **Applying through the API.** `runy apply -f - -n scratch --enabled` (YAML on stdin) stores documents in the daemon's state, reconciled like files, kept until `runy delete`. Files win: an id a file declares cannot be applied. **Children.** `children: [{ kind, name, spec?, needs?, children? }]`: `ssh` under `vm/sandbox` is `port/sandbox.ssh`, in the parent's namespace, no `autorun`, runs exactly when its parent does. `start`, `stop`, `apply`, `delete` on a child are refused. The parent reads `child..`, the child `parent`; others `port["sandbox.ssh"]`. **Signals.** `runy signal ` or `runy signal workspace restart` (re-reads files and `env`). `process`/`vm`: `restart`, `stop`; `vm` also `setup`, `sync`, `pack`; `template`: `build`, `adopt`, `remove`, `prune`; `worktree`: `setup`; `agent`: `setup`, `restart`; `port`, `file`, `secret`: `restart`. Arguments are JSON: `'{"build":{"clean":true}}'`. A stop sends SIGTERM to the process group, SIGKILL after 5 s. Full pages: https://runy.dev/concepts/workspaces/ https://runy.dev/concepts/resources/ ## Resource file format One file holds documents separated by `---`. ```yaml kind: port # process|port|folder|file|worktree|vm|template|agent|watcher|secret name: web # unique per kind within a namespace spec: { preferred: 3010 } --- kind: process name: web namespace: notes # optional autorun: true # optional, default true needs: # optional: all truthy before the resource is applied - ${ process.build.status.exit_code === 0 } children: # optional owned resources - { kind: port, name: debug } spec: # any string may hold ${ ... } cmd: pnpm args: [dev, --port, "${ port.web }"] env: { API_URL: "http://localhost:${ ns.api.port.http }" } restart: { kind: fixed, delay: 1000, max_restarts: 5, on: failure } ``` Full page: https://runy.dev/concepts/resources/ ## Expressions Any string in `spec` or `needs` may hold `${ expression }`: JavaScript with no time, randomness, files or network. A string that is exactly one expression keeps the value's type (`"${ port.web }"` is a number); otherwise values are stringified into it. | name | value | |---|---| | `self` | `{ kind, name, namespace, spec }` (spec unrendered) | | `.` | `{ kind, name, spec, status }` in the same namespace; `status` is `null` until published | | `ns...` | another namespace; `ns._.port.ssh` is top level | | `child..`, `parent` | children and parent | | `workspace` | `{ name, cwd }` | | `env` | daemon environment, snapshotted at start and `workspace restart` | - Names that are not JS identifiers need brackets: `process["chalk-wasm"].status.exit_code`, `ns["my-ns"].process["x"]`. References are static member chains (no `port[name]`), schema-checked: a misspelled field is an `Error`. - A bare `${ . }` reads the default: `port` `status.value`; `folder`, `file`, `worktree` `status.path`; `watcher` `status.revision`; `vm` and `agent` `status.ready`; `template` `status.build`; `secret` `status.value` (the placeholder; `status.url` is the gateway URL); `process` none (whole object). - Reading a `null` status (or a disabled namespace's resource) makes the resource `Pending`. A missing field is `undefined`. A cycle is an `Error`. - `needs` stays `Pending` until all entries are truthy; if one turns false later the resource goes `Pending` and keeps running. Pair a build dependency with `restart.on: failure` so a finished build stays `stopped` with exit 0. Full page: https://runy.dev/concepts/expressions/ ## Kinds Unknown spec keys are rejected. ### process ```yaml kind: process name: web spec: cmd: pnpm # required; daemon PATH or relative to cwd args: [dev, --port, "${ port.web }"] # default [] env: { NODE_ENV: development } # added to the daemon's environment cwd: products/web # relative to the workspace root restart: never # default watch: { include: ["src/**"], exclude: ["**/*.snap"] } # changes restart it; needs watchman health: { web: { http: { port: "${ port.web }", path: / }, failures: 60 } } journal: { max_lines: 1000 } ``` `restart`: `never`, `always`, `{ kind: fixed, delay: 1000, max_restarts, on }` or `{ kind: exponential, initial_delay: 1000, max_delay: 30000, multiplier: 2, max_restarts, on }` (ms). `on` is `always` (default) or `failure` (non-zero exit, signal, or `failures` health failures; a clean exit stays `stopped`). After `max_restarts` the state is `failed`. Status: `pid`, `state` (`starting`, `running`, `stopped`, `failed`), `restarts`, `exit_code`, `healthy`, `health.`. Secret placeholders become values in `env` and `exec` health `env` only. Pass `--ignore-lock` to `astro dev`. ### port ```yaml kind: port name: web spec: preferred: 3010 # default none range: [3000, 3999] # default; searched when preferred is taken domains: [web.localhost, https://web.example.dev] # default [] ``` `domain: x` is sugar for one entry. `routes: false` (default `true`) keeps the port out of default names and a hub's routes. The value is found by probing a bind on `127.0.0.1` and survives re-applies and upgrades; signal `restart` allocates again. Status `{ value, url, urls }`. Readers wait for a value. ### folder ```yaml kind: folder name: uploads spec: { path: tmp/uploads } # relative to the root; created if missing --- kind: folder name: cache spec: { cache: true } # under the workspace's cache folder, named after the resource ``` Give one. Status `{ path }` (absolute). ### file ```yaml kind: file name: server_config spec: path: config/local.toml # required; relative to root, absolute or ~ content: | # required (may be empty) openai_api_key = "${ secret.openai }" mode: "0600" # octal string, quoted; default "0600" ``` Writes rendered `content` atomically (parent folders created, readable by you only); waits `Pending` until its secrets have values; rewrites when content changes. Add the path to `.gitignore`. - runy never overwrites or deletes a file it did not write (`Error`: `` `` exists and was not written by runy; remove it or point `path` elsewhere ``) unless it already has the content. Deleted on document removal only if unchanged. - Status `{ path, revision }`; `needs: ["${ file. }"]` waits for the write. ### worktree ```yaml kind: worktree name: preview spec: branch: feature/preview # required; created from base if missing base: main # default: repository default branch repo: . # default: workspace root path: ... # default: /worktrees/ hooks: { create: [pnpm install --frozen-lockfile], remove: [bazel clean --expunge] } namespaces: [api, web] # namespaces of its own workspace to enable ``` Removed (`git worktree remove --force`, branch kept) only when the document is removed; stop and daemon stop keep it (`kept`). Hooks run `sh -c` in it with `RUNY_WORKTREE_PATH`, `RUNY_WORKTREE_BRANCH`, `RUNY_WORKTREE_NAME`, `RUNY_WORKSPACE`; create hooks only for a newly added worktree (signal `setup` reruns; failure: `ready: false`, `Error`); remove hooks best effort. Status `{ path, branch, head, ready, workspace }`. With a `.runy.json` inside it is a child workspace that cannot read the parent's resources. ### vm A virtual machine kept running by a driver. The only driver is `smolvm` (OCI image as a microVM; `brew install smol-machines/tap/smolvm`; `RUNY_SMOLVM` names the binary). Ids are `vm/`; `kind: smolvm` is unknown. ```yaml kind: vm name: sandbox children: - { kind: port, name: ssh } spec: driver: smolvm image: debian:bookworm-slim net: true ssh: true daemon: true workdir: /work/app ports: ["${ child.port.ssh }:22"] hooks: create: [apt-get update && apt-get install -y openssh-server] ``` Required: `driver` and one of `image`, `smolvm.smolfile`, `from`, `template`, `branch`. Keys (defaults in parentheses): `image`; `from` (pack file; exclusive with `image`, `cmd`, `smolvm.smolfile`); `template` (name or `/`); `branch` (running vm; exclusive with `image`, `from`, `template`, `cmd`, `smolvm.smolfile`); `branchable` (`false`); `pack` (path the `pack` signal writes); `cmd` (list; image's); `machine` (`-`, `` at top level); `cpus`, `memory` (MiB), `net`, `workdir`, `user`, `storage` (GiB), `stop_timeout` (s) (smolvm's defaults); `egress` (`{ allow, deny, block_private }`, turns `net` on); `ports` (`HOST:GUEST[/udp]`, `[]`); `volumes` (`HOST:GUEST[:ro]`, host path relative to root, `[]`); `env` (map); `runy` (`true`: copy a Linux runy in); `hooks.create|start|remove` (shell lists, `[]`); `ssh` (`true` or `{ user, keys }`, off); `daemon` (`false`; link to the daemon inside, needs `runy: true`); `routes` (all with `daemon: true`, else none); `workspaces` (`[workdir]`); `metrics` (`true`, `false` or `{ interval }` 5 to 3600 s; default 60 s, samples go to the journal as `stream: metrics`); `journal.max_lines` (`5000`); `persistent` (`false`: keep the machine when the document is removed); `secrets`; `smolvm` (`{ smolfile, overlay (GiB) }` only). Rules: - Status: `state` (`created`, `running`, `stopped`, `starting`, `updating`, `packing`, `failed`), `ports[]` (`host`, `guest`, `name`, `domain`, `url`), `ssh` (`{ domain, port, user, command }`), `ready` (binary in place, hooks passed), `daemon` (`{ state, version, reason }`), `pack`, `template`, `branch`, `egress`. A machine found stopped on its own is not restarted. Wait with `needs: ["${ vm.sandbox }"]` (ready). - Changes. Identity (recreate; `Error` with `persistent: true`): `driver`, `image`, `cmd`, `user`, `smolvm.smolfile`, `stop_timeout`, `machine`, `egress.deny`, `egress.block_private`. Live, growing only: `cpus`, `memory`, `storage`, `smolvm.overlay`. Stopped (stop, update, start; no create hooks): `ports`, `volumes`, `env`, `workdir`, `net`, `egress.allow`, `branchable`, shrinking `cpus`/`memory`. Everything else except `from`/`template`/`branch` (create-only) leaves the machine untouched, except `credential` entries of `secrets`. A disk never shrinks (`Error`). - With `persistent: false` the machine and disks are deleted when the document is removed or its identity changes. Stop, disabled namespace, stopped parent and daemon stop keep it stopped; starting reuses it (start hooks run, create hooks do not). - Hooks run in the machine with `sh -c`, in order, with `RUNY_MACHINE`, `RUNY_RESOURCE`, `RUNY_WORKSPACE` set. Create hooks run once (marker `/var/lib/runy/hooks` holds their hash; editing them reruns them); a failure leaves `ready: false`, `Error`; `setup` retries. Start hooks run after every start, on `sync` and `setup`, before sshd and the daemon link; write them idempotent. Remove hooks run when a running non-persistent machine is deleted. - `runy: true` copies a Linux runy to `/usr/local/bin/runy` after every start: from `RUNY_GUEST_BINARIES` (folder with `runy-linux-`), else for a release downloaded from `https://runy.dev/cli//`. A development build never downloads. - ssh needs a mapping to guest 22 or `daemon: true`, else `Error`; `keys` default every `~/.ssh/*.pub`, `user` the spec `user` if a name, else `root`. runy starts `/usr/sbin/sshd` but does not install it (`openssh-server` in `hooks.create`). Run `runy ssh-config >> ~/.ssh/config` once, then `ssh root@ssh..vm.runy.localhost` (`status.ssh.command`); with `daemon: true` and no mapping to 22 the name is `ssh..runy.localhost`. - `routes`: `true` all, `false` none, or `/` globs (`_` is top level). An explicit value without `daemon: true` is an `Error`. - Egress: `allow` means only what it lists (hostname with subdomains, `*.domain`, CIDR, IP), `deny` CIDRs/IPs first, `block_private: true` refuses LAN, metadata and host loopback; `net: false` with `egress` is an error. `inject.hosts` of `credential` entries join `allow`. A changed `allow` applies in place; changed `deny`/`block_private` recreates. Refusals: journal `stream: egress`, `status.egress`. - `secrets` entries `{ secret: "${ secret. }" or "${ ns..secret. }", credential?: VAR, resource?: true, proxy?: true }`: at least one flag, a secret in one entry only, `credential`/`proxy` need `inject`. A changed `credential` binding recreates, a rotated value restarts; the others apply in place. - Packs: `from: packs/sandbox.smolmachine` is read at creation only. `pack: ` plus signal `pack` writes a pack (stops and restarts the machine). - Instances: `spec: { template: sandbox, env: { TASK_REF: feature/x }, memory: 4096 }`, or `runy vm run sandbox --name task-42 -e TASK_REF=feature/x --memory 4096 --cpus 2 --wait`; `runy vm rm task-42`. It inherits the template's spec except build-only keys (`image`, `cmd`, `user`, `stop_timeout`, `smolvm.smolfile`, `hooks.create`), runs no create hooks, and sets only `memory`, `cpus`, `routes`, `metrics`, `journal`, `persistent`, `machine`, `env` (merged), `secrets` (merged), `egress` (replaces), `branchable`. `Pending` until the template has a build; new builds never touch existing instances. - Branches: `spec: { branch: sandbox, env: { FEATURE: fix } }` or `runy vm branch sandbox --name try-fix -e FEATURE=fix --wait` copies a running vm (memory, processes, disks) in about half a second. The source needs `branchable: true` (else `Error`). Spec rules as for an instance; no create hooks. A smaller `cpus`/`memory`/`storage`, other `volumes`, `net` or `egress` is an `Error`. Give the source `port` children (cloned), not literal host ports. A source cannot be deleted while branches exist. - Signals: `restart` (no recreate), `stop`, `setup` (create then start hooks), `sync` (start hooks, runy copy), `pack`. `setup` and `sync` need a running machine. Full page: https://runy.dev/kinds/vm/ ### template A vm spec built into a pack once; it never runs as a machine. The driver must be able to pack (`smolvm`). ```yaml kind: template name: sandbox spec: driver: smolvm image: debian:bookworm-slim net: true build: # shell commands in the new builder of a clean build - apt-get update && apt-get install -y git build-essential refresh: # in the kept builder of a refresh build, after hooks.start - git -C /work/app pull -q --ff-only stamp: git -C /work/app rev-parse HEAD # output recorded with the build ``` - Takes vm keys except `from`, `pack`, `template`, `persistent`, plus `build`, `refresh` (`[]`), `stamp`. `build` replaces `hooks.create` (not inherited); instances inherit `hooks.start`; the builder gets no `secrets`. - `runy build [-n ] [--clean] [--wait]` (template must be running). Clean: new builder `runy-build--` from the image, run `build`, pack. Refresh: start the kept builder, run `hooks.start` and `refresh`, pack. Clean when `--clean`, stale (`image`, `cmd`, `user`, `smolvm.smolfile`, `stop_timeout` or `build` changed), first, or after an adopted build. - Signals: `build`, `{"build":{"clean":true}}`, `{"adopt":{"path":"packs/x.smolmachine","stamp":"v1"}}` (next build clean), `{"remove":{"build":2}}`, `prune`. Status `state` (`unbuilt`, `building`, `built`, `failed`), `build`, `builds`, `stale`. Full page: https://runy.dev/kinds/template/ ### agent A machine reached over ssh whose runy daemon the hub links to. ```yaml kind: agent name: box spec: host: stan@build.lan # required; anything ssh accepts workspaces: [~/src/app] # registered on every connect; first is the default ``` Other keys: `name` (machine name; default resource name), `ssh_args` (`[]`), `binary` (`.local/share/runy/bin/runy`), `port` (`4122`), `routes` (all). The hub runs `ssh -T -o BatchMode=yes -- --port daemon bridge` (no password prompt) and uploads the matching runy when its sha256 differs. Status `state` (`connecting`, `connected`, `disconnected`, `incompatible`, `closed`), `ready`, `workspaces`, `routes`, `reason`. Removing it only closes the link. An agent has no `secrets`. ### watcher ```yaml kind: watcher name: schema spec: { prefix: packages/schema, include: ["**/*.graphql"], exclude: ["**/generated/**"] } # all default: root, [], [] ``` Status `{ revision, files }`; `${ watcher.schema }` is the revision, so readers re-render on file changes. The same file set (`include`, `exclude`, `prefix`) is a process's `watch`. Needs watchman. ### secret Exactly one source: `encrypted` (armored age file; write with `runy secret set`), `command` (`sh -c` in the root, stdout minus one trailing newline, 30 s limit), `file` (contents minus one trailing newline; `~` allowed), `env` (daemon variable). Optional `inject`: `hosts` (required; bare hosts; the gateway uses the first), `header` (`Authorization`), `value` (`Bearer {value}`, must contain `{value}`). ```yaml kind: secret name: anthropic spec: file: ~/.config/anthropic/key inject: { hosts: [api.anthropic.com], header: x-api-key, value: "{value}" } ``` Names use ASCII letters, digits, `.`, `_`, `-`; with `inject` DNS labels. Status `{ value (placeholder), source, revision, url }`; `url` exists as soon as `inject` is set. Readers are `Pending` until resolved (start, spec change, `restart`). Common error: `not a recipient: add `age1...` to the workspace's recipients and run `runy secret rekey` where the value can be read`. Full pages: https://runy.dev/kinds/process/ https://runy.dev/kinds/port/ https://runy.dev/kinds/folder/ https://runy.dev/kinds/file/ https://runy.dev/kinds/worktree/ https://runy.dev/kinds/agent/ https://runy.dev/kinds/watcher/ https://runy.dev/kinds/secret/ ## Health checks ```yaml health: web: { http: { port: 8101, path: /health }, initial_delay: 2, period: 1, timeout: 5, failures: 60 } db: { exec: { cmd: ./scripts/db-ready.sh }, period: 10 } ``` One probe per check: `http` (`host` `localhost`, `port`, `path` `/`; passes on 2xx/3xx), `tcp` (`host`, `port`), `exec` (`cmd`, `args`, `cwd`, `env`; exit 0). Schedule (seconds): `initial_delay` 0, `period` 5, `timeout` 5, `failures` none. With `failures: N`, N failures in a row stop the child as a failed exit and `restart` decides; without it a check only reports. Gate dependents: `needs: ['${ process.api.status.health.web.ok }']`. Full page: https://runy.dev/guides/health-checks/ ## Domains and the proxy The proxy (`--proxy-addr`, default `0.0.0.0:80`, loopback clients only) routes by `Host`: HTTP/1.1, streaming, WebSockets, `CONNECT`. Unknown host: 404 page; dead backend: 502 page. `*.localhost` resolves to loopback in browsers; other domains need a DNS record to `127.0.0.1`. For https put a tunnel in front and use the URL form (`https://runy.umka.day`) in `domains`. `` below is the daemon's host label (one DNS label): `runy daemon host