nylorun 0.3.0-beta → 0.5.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +154 -68
  3. package/dist/cli.js +29 -25
  4. package/dist/doctor.d.ts +7 -5
  5. package/dist/doctor.js +58 -29
  6. package/dist/home.d.ts +1 -1
  7. package/dist/home.js +1 -1
  8. package/dist/project/derived-key.d.ts +8 -0
  9. package/dist/project/derived-key.js +18 -0
  10. package/dist/project/link.d.ts +32 -4
  11. package/dist/project/link.js +83 -14
  12. package/dist/project/seed.d.ts +27 -0
  13. package/dist/project/seed.js +111 -0
  14. package/dist/stack/commands.d.ts +42 -19
  15. package/dist/stack/commands.js +465 -152
  16. package/dist/stack/compose-file.d.ts +30 -11
  17. package/dist/stack/compose-file.js +88 -18
  18. package/dist/stack/docker.js +1 -1
  19. package/dist/stack/env-file.d.ts +24 -3
  20. package/dist/stack/env-file.js +49 -4
  21. package/dist/stack/host-files.d.ts +12 -3
  22. package/dist/stack/host-files.js +26 -3
  23. package/dist/stack/images.d.ts +1 -1
  24. package/dist/stack/images.js +1 -1
  25. package/dist/stack/index.d.ts +3 -3
  26. package/dist/stack/index.js +12 -3
  27. package/dist/stack/paths.d.ts +12 -4
  28. package/dist/stack/paths.js +9 -6
  29. package/dist/stack/ports.d.ts +2 -2
  30. package/dist/stack/ports.js +1 -1
  31. package/dist/stack/prepare.d.ts +13 -4
  32. package/dist/stack/prepare.js +25 -13
  33. package/dist/stack/restate-identity.d.ts +1 -1
  34. package/dist/stack/restate-identity.js +1 -1
  35. package/dist/stack/stacks.d.ts +50 -0
  36. package/dist/stack/stacks.js +150 -0
  37. package/dist/stack/versions.d.ts +1 -1
  38. package/dist/stack/versions.js +1 -1
  39. package/dist/telemetry.d.ts +31 -0
  40. package/dist/telemetry.js +79 -0
  41. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # nylorun
2
2
 
3
+ ## 0.5.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - f96fe32: **Studio reports anonymous page views, unless you opt out.** Studio sends page views to Google Analytics with every Tenant, agent and session id replaced by `:id` and the query dropped; nothing sent to agents is collected. `nylorun start` says so once, and passes the measurement id to the Studio container as `NYLORUN_STUDIO_ANALYTICS_ID`. Turn it off with `nylorun telemetry disable`, `NYLORUN_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`; it is always off in CI, inside an embedding app, and when the browser sends Do Not Track or Global Privacy Control.
8
+ - 4b9906f: **Breaking: "Tenant" replaces "stack", and `nylorun start` works anywhere.** Each local installation holds one Tenant, and its name is the Tenant's name, so help, output, errors and docs say Tenant. See MIGRATION.md.
9
+
10
+ - **Breaking (`nylorun`): selection.** Every command acts on the Tenant `--tenant <name>` names (replaces `--name`, which is removed), else `NYLORUN_TENANT` (replaces `NYLORUN_STACK`), else the Project link's `tenant`; `start` in a project names a new one after the project directory. Outside a project, or with `start --no-link`, commands act on the Tenant `default`. In a project without a link, commands other than `start` exit 2 and list the machine's Tenants. A name starting with `tn_` (a Tenant id) is refused.
11
+ - **Breaking (`nylorun`): files.** Host roots are under `~/.nylorun/tenants/<name>/` (was `~/.nylorun/stacks/<name>/`) with `tenant.json` (was `stack.json`); the `.env` key is `NYLORUN_TENANT_NAME` (was `NYLORUN_STACK_NAME`); `NYLORUN_COMPOSE_PROJECT` replaces `NYLORUN_STACK_PROJECT`. Compose projects stay `nylorun-<name>`. Every command first moves 0.4 Host roots from `~/.nylorun/stacks/` to `~/.nylorun/tenants/` (renaming `stack.json` and the `.env` key), so they keep their volumes and keys. `nylorun ls` lists only directories with `tenant.json`.
12
+ - **Breaking (`nylorun`): removed.** `nylorun legacy` and all handling of the single stack of releases before 0.4; the hidden `nylorun stack <cmd>` alias; `nylorun doctor stack|runtime`. Output says Tenant: `ls` prints `TENANT` and JSON `{ "tenants": [...] }`, `status` prints the Tenant id on its own line, and `doctor`'s row is `tenant`.
13
+ - **Breaking: Project link format 3.** `.nylorun/link.json` is `{ "format": 3, "tenant", "tenantId", "hostUrl", "hostId" }`; `tenant` replaces `stack`. `@nylorun/agents`, `@nylorun/cli` and `@nylorun/admin` refuse an older link and name `npx nylorun start`, which rewrites it. `@nylorun/core`'s `ProjectLinkFileSchema` parses formats 0–3 with `tenant`.
14
+ - **Breaking (`@nylorun/admin`):** `createAdmin({ tenant })` replaces `{ stack }`, `tenantHostRoot(name)` replaces `stackHostRoot(name)`, and local resolution reads `NYLORUN_TENANT` and the link's `tenant`.
15
+ - `@nylorun/cli`: `status` and `endpoints` drop the `stack` line and JSON key; messages say Tenant. `@nylorun/agents`: a Runtime too old for the client says "update the Runtime (npx nylorun@latest start)". `@nylorun/studio`: setup hints say Tenant. `@nylorun/create-agent`: the next steps describe `npx nylorun@beta start` as this project's Tenant and its link.
16
+
17
+ ### Patch Changes
18
+
19
+ - Pin core to the tested release.
20
+ - Pin runtime to the tested release.
21
+ - Pin studio to the tested release.
22
+ - Updated dependencies [4b9906f]
23
+ - @nylorun/core@0.11.0-beta
24
+
25
+ ## 0.4.0-beta
26
+
27
+ ### Major Changes
28
+
29
+ - 5ca1923: **Clients for one Tenant per installation: a stack per project, nothing selects a Tenant.** Upgrade these with the Runtime; they speak protocol 5. Existing stacks are left as they are: see MIGRATION.md.
30
+
31
+ - **Breaking (`nylorun`): one stack per project.** `nylorun start` in a project creates the project's stack (named after the project directory, or `--name`; Host root `~/.nylorun/stacks/<name>/`, Compose project `nylorun-<name>`, its own free ports and volumes), waits for its Runtime to create the stack's Tenant, writes the Project link (`.nylorun/link.json` format 2: `stack`, `hostUrl`, `hostId`, `tenantId`) and `.nylorun/credentials.json` (the key of the derived principal `project`, derived from the stack's admin key), and seeds the model provider from the project's `.env`. `nylorun ls` lists the machine's stacks and `nylorun delete <name>` removes one with its volumes and Host root. `nylorun status` shows the stack's Tenant; `nylorun studio` opens it. The old single stack under `~/.nylorun` is never touched: `start` notes it, and `nylorun legacy stop|delete` handles it. Every stack command takes `--name <stack>` (or `NYLORUN_STACK`, or the Project link's stack); `start --no-link` starts a stack without linking the directory; `nylorun reset` resets the selected stack only. The runtime container's healthcheck is now `/health`, so a Tenant that cannot open is reported by `start` from the Admin status at once instead of after a 300 s wait. `NYLORUN_HOME` still overrides the Host root. Stacks start and stop only when you say so.
32
+ - **Breaking (`@nylorun/cli`): no Tenant commands.** `nylo tenant create|use|list|current|delete` are removed; `nylo status`, `nylo reset` and `nylo endpoints` replace `nylo tenant status|reset|endpoints` on the linked installation. `nylo env` prints `NYLORUN_RUNTIME_URL` and `NYLORUN_SERVER_KEY` only. `nylo` no longer writes Project links.
33
+ - **Breaking (`@nylorun/agents`): no Tenant to name.** The `tenant` option (`createClient`, `Transport`, `resolveConnection`, `createActionHandler({ runtime })`, `JwksCache`) and `NYLORUN_TENANT` are gone, and no request sends `Nylorun-Tenant`; a connection is a URL and a key. A Project link of format 0 or 1 is refused with `connection_missing`, naming `npx nylorun start`. `verifyDeliveryToken`'s `tenantId` is optional: without it any Tenant issuer is accepted, since the installation's keys bind it. `TENANT_HEADER` is no longer re-exported.
34
+ - **Breaking (`@nylorun/admin`): status only.** `createTenant`, `listTenants`, `getTenant` and `deleteTenant` are removed; `status().tenant` names the Host's Tenant, and `deriveTenantKey` / `deriveStudioToken` derive its keys. Local Host resolution reads the stack's Host root (`stack` option, `NYLORUN_STACK`, or the Project link's `stack`); `NYLORUN_HOME` and `home` still override it. `stackHostRoot(name)` is exported.
35
+ - **Breaking (`@nylorun/studio`): Studio serves its installation's Tenant.** The Tenant picker, list and create are gone, with `/_studio/tenants`; `/` opens `/tenants/<id>`. The `/tenants/:tenant` routes and the login token's `tenant` claim stay for embedders and must name that Tenant. The proxy sends no `Nylorun-Tenant`.
36
+ - **`@nylorun/create-agent`:** the next steps are `npx nylorun start`, then `npm run dev`.
37
+ - `@nylorun/core`: `ProjectLinkFileSchema` accepts format 2 with `stack`, and `tenantId` is optional; `ERROR_CODES` loses `tenant_conflict` and `active_work`.
38
+
39
+ ### Minor Changes
40
+
41
+ - ee9e471: **Only the gateway can read the vault key (F4.2).** `nylorun start` writes the Tenant's vault key to `<Host root>/keys/vault-kek`. Only the `gateway` container mounts `keys/`, read-only, and runs `--service gates,keys`. The runtime container covers `keys/` and `docker/` with empty read-only mounts, so it reads neither the vault key nor Restate's private key and `.env`. `nylorun reset` deletes the key with the Tenant's data.
42
+ - e3af093: **A stack's Docker Compose files live in `docker/`.** `compose.yaml`, `.env` and `restate-identity.pem` are written to `~/.nylorun/stacks/<name>/docker/` (or `$NYLORUN_HOME/docker/`), so the folder says what it holds: to change a port, edit `docker/.env`. The single stack of older releases keeps its `~/.nylorun/stack/`, which `nylorun legacy` reads as it is.
43
+ - 7bd38d6: **The local stack runs a gateway container: model calls leave the Runtime.** `nylorun up` now runs the Runtime image twice, the combined packing: `runtime` (`--service core,loop`: the APIs and the agent loop) and `gateway` (`--service gates,keys`: the Model Gate, the Tool Gate and the keys service). Every model call, remote MCP call and Action delivery of the loop crosses the gateway, which alone reads the Tenant's credentials and the vault key. A new stack starts with the gateway.
44
+
45
+ - **Breaking for hand-written Compose files:** in a container, a Runtime that runs `loop` refuses to start without `NYLORUN_GATES_URL` and `NYLORUN_GATES_TOKEN`. Run the image a second time with `--service gates,keys` (see `DEPLOYMENT.md`). The image's default command is now `--service core,loop`.
46
+ - The gateway has no published port, mounts only the Host's Tenant directory (`tenant/`) and `keys/`, both read-only, and reaches model servers on this machine at `host.docker.internal`. `docker/.env` holds `NYLORUN_GATES_TOKEN`, generated once and kept across starts.
47
+ - `nylorun status` shows a Gateway line, `nylorun doctor` fails when the gateway is unhealthy and names `nylorun logs gateway`, and `nylorun logs gateway` is accepted.
48
+ - An image set with `NYLORUN_RUNTIME_IMAGE` must be this release or newer: older Runtimes don't know `--service`.
49
+
50
+ - 31cfec0: **Action deliveries leave through the gateway (F4.1).** With the gates service, every delivery and endpoint ping is POSTed by the gateway (`POST /nylorun/v1/deliveries`) under the gateway's own `NYLORUN_ENDPOINT_*` policy. The delivery state machine is unchanged. A gateway that cannot be reached counts as a delivery that was not sent, so it is retried, and its failure code is `gateway.unreachable`.
51
+
52
+ - `nylorun`: the `gateway` container now sets `NYLORUN_ENDPOINT_LOOPBACK=docker-host`, so Action endpoints on this machine stay reachable.
53
+ - A process that runs only `core` also reads `NYLORUN_GATES_URL`, for endpoint pings.
54
+
55
+ ### Patch Changes
56
+
57
+ - Pin core to the tested release.
58
+ - Pin runtime to the tested release.
59
+ - Pin studio to the tested release.
60
+ - Updated dependencies [fed780d]
61
+ - Updated dependencies [fed780d]
62
+ - Updated dependencies [7f4c3f1]
63
+ - Updated dependencies [5ca1923]
64
+ - Updated dependencies [5ca1923]
65
+ - @nylorun/core@0.10.0-beta
66
+
3
67
  ## 0.3.0-beta
4
68
 
5
69
  ### Minor Changes
package/README.md CHANGED
@@ -1,18 +1,23 @@
1
1
  # nylorun
2
2
 
3
- Sets up and runs the local Nylorun stack: the Runtime and Studio, as a Docker
4
- Compose stack. It needs nothing in your project; run it with `npx`:
3
+ Sets up and runs local Nylorun Tenants: the Runtime and Studio, in Docker
4
+ Compose, one Tenant per project. It needs nothing in your project; run it with
5
+ `npx` in the project's directory:
5
6
 
6
7
  ```sh
7
- npx nylorun up # set up the stack on the first run, then start it
8
- npx nylorun down # stop it; volumes (and Tenants) are kept
8
+ npx nylorun start # create (first run) and start this project's Tenant, and the Project link
9
+ npx nylorun stop # stop it; volumes (and the Tenant's data) are kept
9
10
  ```
10
11
 
11
- `nylorun` only manages the stack. It never creates Tenants: create one in
12
- Studio, or with the Runtime client, [`@nylorun/cli`](../cli/README.md) (command
13
- `nylo`), which also links a project to it. Depends on `@nylorun/core` only
14
- among Nylorun packages and never imports `@nylorun/runtime`. Vocabulary:
15
- [runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
12
+ A local Tenant is one installation: one Runtime with its own Postgres, Restate
13
+ and S2, serving exactly that Tenant, and its name is the Tenant's name.
14
+ `nylorun start` in a project creates the project's Tenant (the Runtime creates
15
+ it on its first start) and links the project to it; anywhere else, it starts
16
+ the Tenant `default`. Projects that must not share agents, credentials or
17
+ history run separate Tenants. Agents, sessions and model providers belong to
18
+ the Runtime client, [`@nylorun/cli`](../cli/README.md) (command `nylo`).
19
+ Depends on `@nylorun/core` only among Nylorun packages and never imports
20
+ `@nylorun/runtime`. Vocabulary: [runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
16
21
 
17
22
  Prerequisites, installed by the developer (nylorun never downloads them): Node
18
23
  24 or newer, and Docker with Compose v2 ([Docker
@@ -23,91 +28,171 @@ another engine). On Windows, install them inside
23
28
  supported.
24
29
 
25
30
  ```sh
26
- npx nylorun doctor # Node 24+, Docker, Compose v2, and the stack's health
31
+ npx nylorun doctor # Node 24+, Docker, Compose v2, and the Tenant's health
27
32
  ```
28
33
 
29
34
  ## Commands
30
35
 
31
36
  ```sh
32
- nylorun up|start [--no-studio] [--no-open] [--allow-downgrade] [--studio-embed-origin <origin>]... [--studio-embed-origin-reset]
33
- # set up (first run) and start the stack; print the Runtime and Studio URLs; open Studio signed in
34
- nylorun down|stop # stop the containers; keep volumes
35
- nylorun status [--json] # services, endpoints, Runtime health
36
- nylorun logs [service] [-f] [--tail <n>] # postgres, restate, s2, runtime, studio
37
- nylorun studio [--no-open] # sign a browser in to Studio (on the linked Project's Tenant); starts the stack if needed
38
- nylorun reset [--yes] # delete the stack's volumes and every Tenant
39
- nylorun doctor [--json] # prerequisites and stack health
37
+ nylorun up|start [--tenant <name>] [--no-link] [--no-studio] [--no-open] [--allow-downgrade] [--studio-embed-origin <origin>]... [--studio-embed-origin-reset]
38
+ # create (first run) and start the Tenant; link the project; print the URLs; open Studio signed in
39
+ nylorun down|stop [--tenant <name>] # stop the containers; keep volumes
40
+ nylorun status [--tenant <name>] [--json] # the Tenant, its Host root and id, services, endpoints, Runtime health
41
+ nylorun logs [service] [--tenant <name>] [-f] [--tail <n>] # postgres, restate, s2, gateway, runtime, studio
42
+ nylorun studio [--tenant <name>] [--no-open] # sign a browser in to Studio on the Tenant; starts it if needed
43
+ nylorun reset [--tenant <name>] [--yes] # delete the Tenant's volumes, Tenant directory and vault key; the next start creates it anew
44
+ nylorun ls [--json] # the Tenants on this machine
45
+ nylorun delete <tenant> --yes # remove a Tenant: containers, volumes, Host root and vault key
46
+ nylorun doctor [--json] # prerequisites and the Tenant's health
47
+ nylorun telemetry [status|enable|disable] # Studio's anonymous usage analytics
40
48
  ```
41
49
 
42
50
  `up` and `down` are the Docker Compose spellings of `start` and `stop`: `down`
43
- stops the containers and keeps the volumes, so no Tenant data is lost.
44
- `nylorun stack <command>` still works as a hidden alias. Commands that act on a
45
- Tenant moved to the Runtime client and exit 2 naming the replacement:
46
- `nylorun dev`, `nylorun tenant …`, `nylorun configure`, `nylorun status --env`
47
- and `nylorun doctor sandbox`.
48
-
49
- ## The stack
50
-
51
- `nylorun up` writes `compose.yaml` and `.env` (mode 0600) under
52
- `<Host root>/stack/` on the first run and reuses them after that. It runs the
53
- Compose project `nylorun` (override with `NYLORUN_STACK_PROJECT`): `postgres`,
54
- `restate`, `s2`, `runtime` and `studio`. The Runtime and Studio images are
55
- pinned by this release (`package.json` `nylorun.runtime` and `nylorun.studio`);
51
+ stops the containers and keeps the volumes, so no Tenant data is lost. Removed
52
+ commands exit 2 naming the replacement: `nylorun dev`, `nylorun configure`,
53
+ `nylorun status --env` and `nylorun doctor sandbox`.
54
+
55
+ ## Tenants
56
+
57
+ Every command acts on one Tenant, chosen in this order:
58
+
59
+ 1. `--tenant <name>`;
60
+ 2. `NYLORUN_TENANT`;
61
+ 3. the Tenant in the project's link (`.nylorun/link.json`, found from the
62
+ working directory upwards);
63
+ 4. for `start` in a project: the project directory's name, lowercased, with
64
+ characters outside `[a-z0-9_-]` as `-`, and a suffix (`-2`, `-3`, …) when a
65
+ Tenant of that name was created for another project directory;
66
+ 5. outside a project, or `start --no-link`: the Tenant `default`.
67
+
68
+ In a project without a link, the commands other than `start` exit 2 and list
69
+ the Tenants on this machine. A name is lowercase letters, digits, `-` and `_`;
70
+ a Tenant id (`tn_…`) is refused: pass the Tenant's name (`nylorun ls` lists
71
+ them).
72
+
73
+ Each Tenant has its own Host root `~/.nylorun/tenants/<name>/`, Compose project
74
+ `nylorun-<name>` (`NYLORUN_COMPOSE_PROJECT` overrides it), volumes, network and
75
+ ports. `NYLORUN_HOME` replaces the whole Host root (the Tenant's name then
76
+ comes from its `tenant.json`, the project directory or the Host root's own
77
+ name). nylorun 0.4 kept Host roots in `~/.nylorun/stacks/`: the first command
78
+ of this release moves them to `~/.nylorun/tenants/`, keeping their Compose
79
+ projects and volumes.
80
+
81
+ A Tenant refuses only a Runtime older than its own database: `start` records
82
+ the pinned Runtime version in `host.json` (`runtimeVersion`) and exits 5 when
83
+ this nylorun pins an older one. Update nylorun, or pass `--allow-downgrade`
84
+ when both versions use the same database schema (otherwise the Runtime reports
85
+ the Tenant unavailable, `schema-too-new`). With `NYLORUN_RUNTIME_IMAGE` set,
86
+ the image's version is unknown: `start` does not check it and keeps the
87
+ recorded version.
88
+
89
+ ## The Project link
90
+
91
+ `nylorun start` in a project waits until the Tenant is open
92
+ (`/v1/admin/status`), then writes, in a `.nylorun/` directory (mode 0700, with
93
+ its own `.gitignore` of `*`):
94
+
95
+ - `link.json`: `{ "format": 3, "tenant", "tenantId", "hostUrl", "hostId" }`.
96
+ `tenant` is the local Tenant's name; the Tenant id is information only:
97
+ nothing in a request selects a Tenant.
98
+ - `credentials.json` (mode 0600): the key of the derived principal `project`,
99
+ derived from the Tenant's admin key, and its id.
100
+
101
+ Later starts reuse the Tenant and rewrite the link only when the Tenant's name,
102
+ URL, Host or id changed (after `nylorun reset`, for example). When it writes a
103
+ new link, `start` seeds the Tenant from the project's `.env`: the sandbox
104
+ backend (`NYLORUN_SANDBOX=auto|virtual`) and the model credential
105
+ (`MODEL_PROVIDER`, `MODEL`, `MODEL_PROVIDER_API_KEY`, `MODEL_PROVIDER_BASE_URL`,
106
+ or `.nylorun/auth.json`), unless the Tenant has a model or
107
+ `NYLORUN_DEV_MODEL=fixture`. `.env` never configures the containers.
108
+
109
+ A fresh clone or a second worktree has no link: `nylorun start` there creates a
110
+ new Tenant, or `nylorun start --tenant <name>` attaches it to an existing one so
111
+ both share it. `--no-link` starts a Tenant without linking the working
112
+ directory (scripts). A link of an older nylorun (format 0 to 2) counts as no
113
+ link: `start` replaces it.
114
+
115
+ The Runtime registers the derived principals of `NYLORUN_DERIVED_PRINCIPALS`
116
+ (comma-separated, from the environment of `nylorun start`, kept in the Tenant's
117
+ `.env`) when it creates the Tenant; `project` is always among them.
118
+
119
+ ## The containers
120
+
121
+ `nylorun start` writes `compose.yaml` and `.env` (mode 0600) under
122
+ `~/.nylorun/tenants/<name>/docker/` on the first run and reuses them after that: `postgres`,
123
+ `restate`, `s2`, `gateway`, `runtime` and `studio`. Postgres initialises the
124
+ Tenant's database with C collation. The Runtime and Studio images are pinned by
125
+ this release (`package.json` `nylorun.runtime` and `nylorun.studio`);
56
126
  `NYLORUN_RUNTIME_IMAGE` and `NYLORUN_STUDIO_IMAGE` override them (local builds,
57
- CI). Ports publish on loopback only: the Runtime on `8787`, Studio on `4161`
58
- and the Restate UI on `9070`, or free ports chosen on the first start and kept
59
- in `.env`. While the Host has no Tenant, `up` says how to create one.
60
-
61
- `up` never downgrades the stack on its own. Every project and app on the
62
- machine shares it, and a Runtime older than a Tenant's schema quarantines that
63
- Tenant. `up` records the pinned Runtime version in `host.json`
64
- (`runtimeVersion`) and exits 5 when that version is older than the one recorded
65
- there or the one running. Update nylorun, or pass `--allow-downgrade` to start
66
- the older Runtime anyway. With `NYLORUN_RUNTIME_IMAGE` set, the image's version
67
- is unknown: `up` does not check it and keeps the recorded version.
68
-
69
- `up` prints Studio as `http://localhost:<port>`. Studio has no password: in a
70
- terminal (not in CI, and not with `--no-open`), `up` asks the Studio container
127
+ CI). Ports publish on loopback only: the Runtime on `8787`, its operator
128
+ listener (Admin API) on `8788`, Studio on `4161` and the Restate UI on `9070`,
129
+ or free ports chosen on the Tenant's first start, avoiding the ports other
130
+ Tenants keep, and kept in its `.env`.
131
+
132
+ `start` prints Studio as `http://localhost:<port>`. Studio has no password: in a
133
+ terminal (not in CI, and not with `--no-open`), `start` asks the Studio container
71
134
  for a single-use login token with the admin key (`POST /_studio/login-tokens`)
72
- and opens `http://localhost:<port>/login?token=…` in the browser. That sets a
73
- session cookie for 30 days, which survives Studio restarts, so the printed URL
74
- keeps working in that browser. The token itself is never printed unless no
75
- browser starts. Otherwise `up` says to run `nylorun studio`, which signs a
76
- browser in the same way; `nylorun studio --no-open` prints the login URL (it
77
- works once, for two minutes) instead. Inside a linked project, `nylorun studio`
78
- reads `.nylorun/link.json` (never writes it) and lands on that project's Tenant.
135
+ and opens `http://localhost:<port>/login?token=…` on the Tenant's page in the
136
+ browser. That sets a session cookie for 30 days, which survives Studio
137
+ restarts, so the printed URL keeps working in that browser. The token itself is
138
+ never printed unless no browser starts. Otherwise `start` says to run `nylorun
139
+ studio`, which signs a browser in the same way; `nylorun studio --no-open`
140
+ prints the login URL (it works once, for two minutes) instead.
79
141
 
80
142
  ### Embedding Studio in a desktop app
81
143
 
82
144
  A desktop app such as Babai Desktop can show Studio inside its own window, in
83
145
  an iframe loaded from Studio's URL (`studio.url` in `nylorun status --json`).
84
146
  Only exact origins listed in `NYLORUN_STUDIO_FRAME_ANCESTORS` (in
85
- `<Host root>/stack/.env`) may frame it. The default is Babai's
147
+ `~/.nylorun/tenants/<name>/docker/.env`) may frame it. The default is Babai's
86
148
  `nylorun://localhost http://nylorun.localhost`; `nylorun status` lists them
87
149
  under `Embeds`. While building such an app, add its dev server once with
88
150
  `nylorun start --studio-embed-origin http://localhost:1420`; the list is kept
89
151
  across starts until `--studio-embed-origin-reset`. Wildcards are refused.
90
152
 
91
- The app's backend mints a single-use login token limited to one Tenant with
153
+ The app's backend mints a single-use login token for the Tenant with
92
154
  `mintStudioLoginToken` from `@nylorun/admin` (it needs the admin key), and its
93
155
  page passes the token to Studio by `postMessage`. The message contract is
94
156
  `@nylorun/agents/studio-embed`.
95
157
 
158
+ ### Telemetry
159
+
160
+ Studio reports anonymous page views to Google Analytics, so we can see which
161
+ parts of it are used. A page view carries the route's shape only: every Tenant,
162
+ agent and session id becomes `:id` (`/tenants/:id/agents/:id/sessions/:id`)
163
+ and the query is dropped. Nothing you send to agents, no names, keys or
164
+ responses, and no Google signals or ad personalization are collected. Studio
165
+ loads no analytics inside an embedding app, or when the browser sends Do Not
166
+ Track or Global Privacy Control.
167
+
168
+ It is on by default, and `nylorun start` says so the first time. Turn it off on
169
+ this machine with `nylorun telemetry disable` (kept in
170
+ `~/.nylorun/telemetry.json`), or for one start with `NYLORUN_TELEMETRY_DISABLED=1`
171
+ or `DO_NOT_TRACK=1`. It is always off when `CI` is set. `nylorun start` decides
172
+ on every start and writes the result to `NYLORUN_STUDIO_ANALYTICS_ID` in
173
+ `docker/.env` (empty when off); `nylorun telemetry` reports the current choice.
174
+
96
175
  ## Sandboxes
97
176
 
98
177
  A session gets a sandbox when it is opened with one, or when the Tenant's
99
- default names one (`PUT /v1/tenant/sandbox`). The stack runs them on the
178
+ default names one (`PUT /v1/tenant/sandbox`). A local Tenant runs them on the
100
179
  Runtime's **virtual** backend: an emulated shell in the Runtime process, with no
101
180
  extra containers. It is not a VM or container boundary.
102
181
 
103
182
  ## Host root
104
183
 
105
- The **Host root** is `NYLORUN_HOME` or `~/.nylorun`. It is bind-mounted into the
106
- Runtime and Studio containers, and holds `host.json` (the client-facing host
107
- and port), `host-credentials.json` (the admin key, mode 0600), the stack files
108
- and each Tenant's directory. Tenant data lives in the stack's Postgres, Restate
109
- and S2 volumes. The stack is one per machine: every project on it shares it,
110
- each with its own Tenant.
184
+ The **Host root** is `~/.nylorun/tenants/<name>/`, or `NYLORUN_HOME`. It is
185
+ bind-mounted into the Runtime and Studio containers, and holds `tenant.json`
186
+ (`{ "format": 1, "name", "project"? }`: the Tenant's name and the project it
187
+ was created for), `host.json` (the client-facing host and port),
188
+ `host-credentials.json` (the admin key, mode 0600), the Docker Compose files in
189
+ `docker/`, the Tenant directory `tenant/` (homes, logs) and `keys/vault-kek`,
190
+ the Tenant's vault key, which only the gateway container mounts. The Tenant's data lives in its Postgres, Restate and S2 volumes.
191
+
192
+ `nylorun reset` deletes the selected Tenant's volumes, `tenant/` and `keys/`, and keeps
193
+ its files and ports; the next start creates the Tenant anew (with a new id) and
194
+ relinks the project. `nylorun delete <tenant> --yes` removes the Tenant's
195
+ containers, volumes and Host root: the vault key (KEK) and all its data go with it.
111
196
 
112
197
  ## Exit codes
113
198
 
@@ -115,11 +200,11 @@ each with its own Tenant.
115
200
  | --- | --- |
116
201
  | 0 | Success |
117
202
  | 1 | Generic failure, including a missing Docker or Compose v2 |
118
- | 2 | Usage error, or a removed or moved command |
119
- | 3 | `status`: the Runtime is not answering; `stop`/`logs`: no stack yet |
203
+ | 2 | Usage error (including no Tenant selected, or `delete` without `--yes`), or a removed or moved command |
204
+ | 3 | `status`: the Runtime is not answering; `stop`/`logs`: no Tenant yet; `delete`: no such Tenant |
120
205
  | 4 | The Runtime port is held by another Host |
121
- | 5 | `up`/`start`/`studio`: this nylorun pins a Runtime older than the one the Host last ran or is running; update nylorun, or `up --allow-downgrade` |
122
- | 7 | The stack or Studio did not become ready |
206
+ | 5 | `up`/`start`/`studio`: this nylorun pins a Runtime older than the one that last ran the Tenant; update nylorun, or `start --allow-downgrade` |
207
+ | 7 | The containers, the Tenant or Studio did not become ready (an unavailable Tenant's cause is printed) |
123
208
  | 130 / 143 | SIGINT / SIGTERM |
124
209
 
125
210
  ## Troubleshooting
@@ -127,9 +212,10 @@ each with its own Tenant.
127
212
  | Symptom | What to do |
128
213
  | --- | --- |
129
214
  | Docker missing or not running | Install or start Docker Desktop, OrbStack or Colima; `nylorun doctor` checks |
130
- | `426` from the Runtime | Upgrade nylorun (`npx nylorun@latest up`), or pin a matching older set |
131
- | `Refusing to downgrade` (exit 5) | Upgrade nylorun (`npx nylorun@latest up`); `--allow-downgrade` only if you accept quarantined Tenants |
132
- | Port conflict | Change `NYLORUN_PORT` / `NYLORUN_STUDIO_PORT` in `<Host root>/stack/.env` |
215
+ | `426` from the Runtime | Upgrade nylorun (`npx nylorun@latest start`), or pin a matching older set |
216
+ | `Refusing to start Runtime …` (exit 5) | Upgrade nylorun (`npx nylorun@latest start`); `--allow-downgrade` only when both Runtimes share the database schema |
217
+ | `Tenant … is unavailable` (exit 7) | Follow the repair it names; `nylorun logs runtime` |
218
+ | Port conflict | Change `NYLORUN_PORT` / `NYLORUN_STUDIO_PORT` in `~/.nylorun/tenants/<name>/docker/.env` |
133
219
  | Logs | `nylorun logs runtime -f` |
134
220
  | Studio login expired | `nylorun studio` |
135
221
 
package/dist/cli.js CHANGED
@@ -2,26 +2,31 @@
2
2
  import "./baseline.js";
3
3
  import { baselineEnv } from "./baseline.js";
4
4
  import { CliError } from "./errors.js";
5
- import { linkedTenantId } from "./project/link.js";
6
- import { isStackCommand, stackCommand, stackUsage, studioCommand, tenantStudioPath, } from "./stack/index.js";
7
- const usage = `nylorun <up|down|start|stop|status|logs|studio|reset|doctor>
5
+ import { isStackCommand, stackCommand, stackUsage, studioCommand, } from "./stack/index.js";
6
+ const usage = `nylorun <up|down|start|stop|status|logs|studio|reset|ls|delete|doctor|telemetry>
8
7
 
9
- Local stack (Docker Compose):
8
+ Local Tenants (Docker Compose), one per project:
10
9
  ${stackUsage}
11
- doctor [--json] check Node, Docker and Compose v2, and the stack's health
10
+ doctor [--json] check Node, Docker and Compose v2, and the Tenant's health
11
+ telemetry [status|enable|disable] Studio's anonymous usage analytics (on unless disabled,
12
+ NYLORUN_TELEMETRY_DISABLED=1, DO_NOT_TRACK=1 or CI)
12
13
 
13
- nylorun sets up and runs the local stack. Tenants, Project links and model
14
- providers belong to the Runtime client: npx @nylorun/cli --help`;
14
+ A command acts on the Tenant --tenant or NYLORUN_TENANT names, else the linked project's,
15
+ else (outside a project) the default Tenant; NYLORUN_HOME sets its Host root
16
+ (default ~/.nylorun/tenants/<name>).
17
+
18
+ nylorun sets up and runs local Tenants. "nylorun start" in a project creates the
19
+ project's Tenant and the Project link; anywhere else, it starts the default Tenant.
20
+ Agents, sessions and model providers belong to the Runtime client: npx @nylorun/cli --help`;
15
21
  const CLIENT = "npx @nylorun/cli";
16
- /** Commands that moved to the Runtime client (`@nylorun/cli`, command `nylo`). */
22
+ /** Commands that were removed, or moved to the Runtime client (`@nylorun/cli`, command `nylo`). */
17
23
  const MOVED_TO_CLIENT = {
18
- dev: `nylorun dev was removed: run \`${CLIENT} tenant create\` once in your project, then your project's \`npm run dev\`.`,
19
- tenant: `Tenant commands moved to the Runtime client: ${CLIENT} tenant …`,
24
+ dev: "nylorun dev was removed: run `npx nylorun start` in your project (it creates the project's Tenant and the Project link), then your project's `npm run dev`.",
20
25
  configure: `nylorun configure moved to the Runtime client: ${CLIENT} configure`,
21
- serve: "nylorun serve was removed. Use node dist/src/main.js with NYLORUN_RUNTIME_URL, NYLORUN_TENANT and NYLORUN_SERVER_KEY.",
22
- runtime: "nylorun runtime was removed: the local Runtime runs in the Docker Compose stack. Use nylorun up|down|status|logs.",
26
+ serve: "nylorun serve was removed. Use node dist/src/main.js with NYLORUN_RUNTIME_URL and NYLORUN_SERVER_KEY.",
27
+ runtime: "nylorun runtime was removed: the local Runtime runs in Docker Compose. Use nylorun up|down|status|logs.",
23
28
  };
24
- const LOCAL_UI_REMOVED = "--local-ui was removed: Studio runs in the stack's studio container. Run nylorun studio.";
29
+ const LOCAL_UI_REMOVED = "--local-ui was removed: Studio runs in its own container. Run nylorun studio.";
25
30
  const usageError = (message) => new CliError(message, 2);
26
31
  async function main() {
27
32
  const [command, ...args] = process.argv.slice(2);
@@ -37,31 +42,30 @@ async function main() {
37
42
  if (command === "studio") {
38
43
  if (args.includes("--local-ui"))
39
44
  throw usageError(LOCAL_UI_REMOVED);
40
- const tenantId = await linkedTenantId();
41
- process.exitCode = await studioCommand(args, baselineEnv(), tenantId ? { next: tenantStudioPath(tenantId) } : {});
45
+ process.exitCode = await studioCommand(args, baselineEnv());
42
46
  return;
43
47
  }
44
48
  if (isStackCommand(command)) {
45
49
  process.exitCode = await stackCommand(command, args, baselineEnv());
46
50
  return;
47
51
  }
48
- // `nylorun stack <command>`: the Wave 1 spelling, kept as a hidden alias.
49
- if (command === "stack") {
50
- const [name, ...rest] = args;
51
- if (!isStackCommand(name))
52
- throw usageError(usage);
53
- process.exitCode = await stackCommand(name, rest, baselineEnv());
52
+ if (command === "telemetry") {
53
+ const { telemetryCommand } = await import("./telemetry.js");
54
+ const { defaultNylorunRoot } = await import("./stack/stacks.js");
55
+ process.exitCode = await telemetryCommand(args, {
56
+ nylorunRoot: defaultNylorunRoot(),
57
+ env: baselineEnv(),
58
+ out: (line) => console.log(line),
59
+ });
54
60
  return;
55
61
  }
56
62
  if (command === "doctor") {
57
- // `doctor stack` and `doctor runtime` are older spellings of `doctor`.
58
- const options = args[0] === "stack" || args[0] === "runtime" ? args.slice(1) : args;
59
63
  if (args[0] === "sandbox")
60
64
  throw usageError(`nylorun doctor sandbox moved to the Runtime client: ${CLIENT} doctor sandbox`);
61
- if (options.some((option) => option !== "--json"))
65
+ if (args.some((option) => option !== "--json"))
62
66
  throw usageError("Usage: nylorun doctor [--json]");
63
67
  const { doctorStack } = await import("./doctor.js");
64
- process.exitCode = await doctorStack({ json: options.includes("--json"), env: baselineEnv() });
68
+ process.exitCode = await doctorStack({ json: args.includes("--json"), env: baselineEnv() });
65
69
  return;
66
70
  }
67
71
  throw usageError(usage);
package/dist/doctor.d.ts CHANGED
@@ -6,18 +6,20 @@ export interface StackDoctorReport {
6
6
  };
7
7
  docker: Check;
8
8
  compose?: Check;
9
- stack?: Pick<StackStatus, "project" | "home" | "state" | "runtime" | "studio">;
9
+ tenant?: Pick<StackStatus, "name" | "project" | "home" | "state" | "runtime" | "tenant" | "studio" | "gateway">;
10
+ /** Why no Tenant was checked: none is selected here (a project without a link). */
11
+ noTenant?: string;
10
12
  }
11
13
  /**
12
- * `nylorun doctor`: check the prerequisites of the local stack (Node 24+,
13
- * Docker, Compose v2) and, when they pass, the stack's health. Prints the fix
14
+ * `nylorun doctor`: check the prerequisites of a local Tenant (Node 24+,
15
+ * Docker, Compose v2) and, when they pass, the Tenant's health. Prints the fix
14
16
  * for each problem and returns 1 when a prerequisite is missing or a running
15
- * stack is unhealthy; installs and starts nothing.
17
+ * Tenant is unhealthy; installs and starts nothing.
16
18
  */
17
19
  export declare function doctorStack(options: {
18
20
  json: boolean;
19
21
  env?: Readonly<Record<string, string | undefined>>;
20
- /** Stack dependencies (tests). */
22
+ /** Command dependencies (tests). */
21
23
  deps?: StackDeps;
22
24
  log?: (line: string) => void;
23
25
  }): Promise<number>;
package/dist/doctor.js CHANGED
@@ -1,11 +1,12 @@
1
+ import { CliError } from "./errors.js";
1
2
  import { checkDocker, defaultStackDeps, readStackStatus, } from "./stack/index.js";
2
- /** Oldest Node the stack's tooling and the developer's application run on. */
3
+ /** Oldest Node nylorun and the developer's application run on. */
3
4
  const MIN_NODE_MAJOR = 24;
4
5
  /**
5
- * `nylorun doctor`: check the prerequisites of the local stack (Node 24+,
6
- * Docker, Compose v2) and, when they pass, the stack's health. Prints the fix
6
+ * `nylorun doctor`: check the prerequisites of a local Tenant (Node 24+,
7
+ * Docker, Compose v2) and, when they pass, the Tenant's health. Prints the fix
7
8
  * for each problem and returns 1 when a prerequisite is missing or a running
8
- * stack is unhealthy; installs and starts nothing.
9
+ * Tenant is unhealthy; installs and starts nothing.
9
10
  */
10
11
  export async function doctorStack(options) {
11
12
  const log = options.log ?? ((line) => console.log(line));
@@ -17,17 +18,30 @@ export async function doctorStack(options) {
17
18
  ...checks,
18
19
  };
19
20
  if (checks.docker.ok && checks.compose?.ok) {
20
- const status = await readStackStatus(deps);
21
- report.stack = {
22
- project: status.project,
23
- home: status.home,
24
- state: status.state,
25
- runtime: status.runtime,
26
- studio: status.studio,
27
- };
21
+ try {
22
+ const status = await readStackStatus(deps);
23
+ report.tenant = {
24
+ name: status.name,
25
+ project: status.project,
26
+ home: status.home,
27
+ state: status.state,
28
+ runtime: status.runtime,
29
+ ...(status.tenant ? { tenant: status.tenant } : {}),
30
+ studio: status.studio,
31
+ gateway: status.gateway,
32
+ };
33
+ }
34
+ catch (error) {
35
+ if (!(error instanceof CliError) || error.exitCode !== 2)
36
+ throw error;
37
+ report.noTenant = error.message;
38
+ }
28
39
  }
29
- const stackBroken = report.stack?.state === "running" && !report.stack.runtime.healthy;
30
- const failed = !nodeOk || !checks.docker.ok || checks.compose?.ok === false || stackBroken;
40
+ const broken = report.tenant?.state === "running" &&
41
+ (!report.tenant.runtime.healthy ||
42
+ !report.tenant.gateway.healthy ||
43
+ report.tenant.tenant?.cause !== undefined);
44
+ const failed = !nodeOk || !checks.docker.ok || checks.compose?.ok === false || broken;
31
45
  if (options.json) {
32
46
  log(JSON.stringify(report, null, 2));
33
47
  return failed ? 1 : 0;
@@ -47,26 +61,41 @@ export async function doctorStack(options) {
47
61
  ["docker", line(checks.docker)],
48
62
  ["compose", line(checks.compose)],
49
63
  ];
50
- const stack = report.stack;
51
- if (stack) {
64
+ const local = report.tenant;
65
+ if (report.noTenant)
66
+ rows.push(["tenant", `- ${report.noTenant}`]);
67
+ if (local) {
52
68
  rows.push([
53
- "stack",
54
- stack.state === "absent"
55
- ? `- not created under ${stack.home}: run nylorun up`
56
- : stack.state === "stopped"
57
- ? `- stopped (project ${stack.project}): run nylorun up`
58
- : stack.runtime.healthy
59
- ? `✓ running (project ${stack.project})`
60
- : `✗ running, but the Runtime does not answer: see nylorun status and nylorun logs runtime`,
69
+ "tenant",
70
+ local.state === "absent"
71
+ ? `- ${local.name} not created under ${local.home}: run nylorun up`
72
+ : local.state === "stopped"
73
+ ? `- ${local.name} stopped (Compose project ${local.project}): run nylorun up`
74
+ : local.runtime.healthy
75
+ ? `✓ ${local.name} running (Compose project ${local.project})`
76
+ : `✗ ${local.name} running, but the Runtime does not answer: see nylorun status and nylorun logs runtime`,
61
77
  ]);
62
- if (stack.state === "running") {
78
+ if (local.state === "running") {
63
79
  rows.push([
64
80
  "runtime",
65
- stack.runtime.healthy
66
- ? `✓ ${stack.runtime.url ?? "?"} · ${stack.runtime.version ?? "?"}`
67
- : `✗ ${stack.runtime.url ?? "?"} not answering`,
81
+ local.runtime.healthy
82
+ ? `✓ ${local.runtime.url ?? "?"} · ${local.runtime.version ?? "?"}`
83
+ : `✗ ${local.runtime.url ?? "?"} not answering`,
84
+ ]);
85
+ rows.push([
86
+ "gateway",
87
+ local.gateway.healthy
88
+ ? `✓ ${local.gateway.state} · combined packing (runtime: core,loop; gateway: gates)`
89
+ : `✗ ${local.gateway.state}: model calls fail; see nylorun logs gateway`,
68
90
  ]);
69
- rows.push(["studio", `${stack.studio.url ?? "?"} · ${stack.studio.state}`]);
91
+ if (local.tenant)
92
+ rows.push([
93
+ "tenant id",
94
+ local.tenant.state === "open"
95
+ ? `✓ ${local.tenant.id ?? "?"} open`
96
+ : `✗ ${local.tenant.id ?? "?"} unavailable${local.tenant.cause ? `: ${local.tenant.cause.code}: ${local.tenant.cause.repair}` : " (opening)"}`,
97
+ ]);
98
+ rows.push(["studio", `${local.studio.url ?? "?"} · ${local.studio.state}`]);
70
99
  }
71
100
  }
72
101
  const width = Math.max(...rows.map(([key]) => key.length)) + 2;
package/dist/home.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The Host root: an explicit home, `NYLORUN_HOME`, or `~/.nylorun`. The stack
2
+ * The Host root: an explicit home, `NYLORUN_HOME`, or `~/.nylorun`. Compose
3
3
  * bind-mounts it into the Runtime and Studio containers, and `@nylorun/admin`
4
4
  * reads `host.json` and the admin key from it.
5
5
  */
package/dist/home.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { homedir } from "node:os";
2
2
  import { join, resolve } from "node:path";
3
3
  /**
4
- * The Host root: an explicit home, `NYLORUN_HOME`, or `~/.nylorun`. The stack
4
+ * The Host root: an explicit home, `NYLORUN_HOME`, or `~/.nylorun`. Compose
5
5
  * bind-mounts it into the Runtime and Studio containers, and `@nylorun/admin`
6
6
  * reads `host.json` and the admin key from it.
7
7
  */