nylorun 0.2.1-beta → 0.4.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.
- package/CHANGELOG.md +126 -0
- package/README.md +156 -46
- package/dist/cli.js +13 -11
- package/dist/doctor.d.ts +3 -1
- package/dist/doctor.js +42 -13
- package/dist/project/derived-key.d.ts +8 -0
- package/dist/project/derived-key.js +18 -0
- package/dist/project/link.d.ts +32 -4
- package/dist/project/link.js +83 -14
- package/dist/project/seed.d.ts +27 -0
- package/dist/project/seed.js +111 -0
- package/dist/stack/commands.d.ts +45 -15
- package/dist/stack/commands.js +577 -125
- package/dist/stack/compose-file.d.ts +30 -8
- package/dist/stack/compose-file.js +99 -15
- package/dist/stack/env-file.d.ts +32 -4
- package/dist/stack/env-file.js +71 -3
- package/dist/stack/host-files.d.ts +16 -3
- package/dist/stack/host-files.js +29 -4
- package/dist/stack/images.d.ts +2 -0
- package/dist/stack/images.js +10 -6
- package/dist/stack/index.d.ts +3 -3
- package/dist/stack/index.js +8 -3
- package/dist/stack/paths.d.ts +11 -3
- package/dist/stack/paths.js +9 -6
- package/dist/stack/ports.d.ts +2 -0
- package/dist/stack/ports.js +2 -0
- package/dist/stack/prepare.d.ts +20 -4
- package/dist/stack/prepare.js +39 -10
- package/dist/stack/restate-identity.d.ts +1 -1
- package/dist/stack/restate-identity.js +1 -1
- package/dist/stack/stacks.d.ts +47 -0
- package/dist/stack/stacks.js +116 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,131 @@
|
|
|
1
1
|
# nylorun
|
|
2
2
|
|
|
3
|
+
## 0.4.0-beta
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
- **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.
|
|
10
|
+
- **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.
|
|
11
|
+
- **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.
|
|
12
|
+
- **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.
|
|
13
|
+
- **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`.
|
|
14
|
+
- **`@nylorun/create-agent`:** the next steps are `npx nylorun start`, then `npm run dev`.
|
|
15
|
+
- `@nylorun/core`: `ProjectLinkFileSchema` accepts format 2 with `stack`, and `tenantId` is optional; `ERROR_CODES` loses `tenant_conflict` and `active_work`.
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 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.
|
|
20
|
+
- 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.
|
|
21
|
+
- 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.
|
|
22
|
+
|
|
23
|
+
- **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`.
|
|
24
|
+
- 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.
|
|
25
|
+
- `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.
|
|
26
|
+
- An image set with `NYLORUN_RUNTIME_IMAGE` must be this release or newer: older Runtimes don't know `--service`.
|
|
27
|
+
|
|
28
|
+
- 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`.
|
|
29
|
+
|
|
30
|
+
- `nylorun`: the `gateway` container now sets `NYLORUN_ENDPOINT_LOOPBACK=docker-host`, so Action endpoints on this machine stay reachable.
|
|
31
|
+
- A process that runs only `core` also reads `NYLORUN_GATES_URL`, for endpoint pings.
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- Pin core to the tested release.
|
|
36
|
+
- Pin runtime to the tested release.
|
|
37
|
+
- Pin studio to the tested release.
|
|
38
|
+
- Updated dependencies [fed780d]
|
|
39
|
+
- Updated dependencies [fed780d]
|
|
40
|
+
- Updated dependencies [7f4c3f1]
|
|
41
|
+
- Updated dependencies [5ca1923]
|
|
42
|
+
- Updated dependencies [5ca1923]
|
|
43
|
+
- @nylorun/core@0.10.0-beta
|
|
44
|
+
|
|
45
|
+
## 0.3.0-beta
|
|
46
|
+
|
|
47
|
+
### Minor Changes
|
|
48
|
+
|
|
49
|
+
- e28b8a9: **New projects serve their tools as an Action endpoint.** Everything Nylorun ships now uses Action endpoints instead of executors. `connectAgents` still works, but it is deprecated.
|
|
50
|
+
|
|
51
|
+
- **Starter (`create-agent`).** `src/main.ts` serves the agents with `createActionHandler` on `http://localhost:3001/nylorun/actions` (`PORT`, `NYLORUN_ACTIONS_URL`) and registers it. `npm run dev` and `npm start` work as before. The README explains which URL the Runtime must reach.
|
|
52
|
+
- **Local stack (`nylorun`).** The Runtime container sets `NYLORUN_ENDPOINT_LOOPBACK=docker-host` and maps `host.docker.internal` to the Docker host, so a `localhost` endpoint on the developer's machine is reachable, on Linux Docker Engine too.
|
|
53
|
+
- **Examples.** The AG-UI and browser-direct apps serve their Action endpoint at `/nylorun/actions` beside their other routes, and `register(origin)` replaces `connection.ready`.
|
|
54
|
+
- **Docs.** The README, `DEPLOYMENT.md` and the `@nylorun/agents` README describe Action endpoints.
|
|
55
|
+
|
|
56
|
+
- 50d0fb5: **The Admin API on its own listener.** A Runtime can serve the Admin API on an operator listener, so the port that faces browsers and reverse proxies serves the Tenant API alone. The stack does this by default.
|
|
57
|
+
|
|
58
|
+
- **Runtime.** With an operator listener (`adminPort` in `host.json`, or `NYLORUN_ADMIN_LISTEN_PORT`, `NYLORUN_ADMIN_LISTEN_HOST` and `NYLORUN_ADMIN_ALLOWED_HOSTS` in a container), the public listener answers `/v1/admin/**` with the opaque `404` and the operator listener serves the Admin API, Host shutdown and the Tenant API, never to browsers. Each checks `Host` against its own port. `/ready` needs both listening; a taken port on either exits with code 98. Without one, a single listener serves everything as before.
|
|
59
|
+
- **Stack.** `nylorun start` publishes the operator port on loopback (`NYLORUN_ADMIN_PORT`, default 8788), writes it to `host.json` as `adminPort`, and points Studio at `runtime:4001`. `nylorun status` prints it.
|
|
60
|
+
- **Admin client.** Reads `adminPort` from `host.json` and sends Admin API requests there (`admin.adminUrl`); `admin.url` stays the Tenant API URL. A `host.json` without `adminPort` keeps working.
|
|
61
|
+
|
|
62
|
+
- 9546ac7: **The stream relay, ready to wire in.** The Runtime gains the relay that will feed S2 from a Postgres record of session events over logical replication (Durable Streams v1); nothing uses it yet.
|
|
63
|
+
|
|
64
|
+
- **Relay core** (`streams/relay/`): per-session pumps appending with `matchSeq`, acknowledgements only after S2 has the rows, refills from the record on a gap, reconciliation after a new or lost slot, and rows of an old basin generation dropped.
|
|
65
|
+
- **Change source** (`adapters/replication/pgoutput.ts`): a persistent `pgoutput` slot, one active process per slot, always resumed from the confirmed position; a pending reconciliation is kept in `nylorun_streams.relay_slots` so a crash cannot skip it.
|
|
66
|
+
- **Shared schema** (`nylorun_streams`): `session_events`, `session_log_heads`, `relay_slots` and the `nylorun_stream_relay` publication, migrated by the Host.
|
|
67
|
+
- **Basin generations**: `basinOf(tenantId, generation)` names a Tenant's later basins (`<basin>-<g base36>`).
|
|
68
|
+
- **Local stack**: Postgres runs with `wal_level=logical` and `max_slot_wal_keep_size=4GB`. `nylorun start` recreates the Postgres container once; its data volume is kept. `DEPLOYMENT.md` lists the settings for a Postgres you run yourself.
|
|
69
|
+
|
|
70
|
+
- 9d52189: **Embedding Studio in a desktop app.** Studio can be shown inside a desktop app such as Babai Desktop, in an iframe loaded from its URL and signed in by `postMessage` with a token limited to one Tenant.
|
|
71
|
+
|
|
72
|
+
- **`nylorun`.** The local stack lets Babai's origins frame Studio: `NYLORUN_STUDIO_FRAME_ANCESTORS` in `stack/.env` defaults to `nylorun://localhost http://nylorun.localhost` and is passed to the Studio container. `nylorun start --studio-embed-origin <origin>` (repeatable) adds an exact origin, such as a desktop app's dev server, and keeps it across starts until `--studio-embed-origin-reset`. Wildcards are refused. `nylorun status` lists the origins under `Embeds`, and `status --json` as `studio.embedOrigins`.
|
|
73
|
+
- **`@nylorun/admin`.** `mintStudioLoginToken({ studioUrl, adminKey, tenant?, subject? })` mints a single-use Studio login token from an app's backend. With `tenant`, the session it leads to reaches only that Tenant.
|
|
74
|
+
- **Studio.** `POST /_studio/sessions` exchanges such a token for a one-hour bearer session kept in the frame's memory; dashboard pages send `frame-ancestors` from the allowlist instead of `X-Frame-Options: DENY`; `?embed=1` hides Studio's branding, follows the app's theme and routes, and reports its own; `/tenants/:tenant/sessions/:session` opens a session by id. The cookie login of `nylorun studio` is unchanged.
|
|
75
|
+
|
|
76
|
+
The dashboard routes `/tenants/:tenant`, `/tenants/:tenant/agents/:agent`, `/tenants/:tenant/agents/:agent/sessions/:session`, `/tenants/:tenant/sessions/:session`, `/tenants/:tenant/vault` and `/tenants/:tenant/settings` are now a public contract for embedders: removing or changing one is a breaking change.
|
|
77
|
+
|
|
78
|
+
### Patch Changes
|
|
79
|
+
|
|
80
|
+
- 4282d5f: **Breaking: executors are removed; protocol 3.** The Runtime delivers every Action (tool, hook, `fn`, `verify`) to the Action endpoint an agent registers. It no longer offers Actions for executors to claim. See `MIGRATION.md`, "Action endpoints replace executors".
|
|
81
|
+
|
|
82
|
+
- **Core.** `PROTOCOL_VERSION` is 3 and a Host serves only protocol 3. `action-endpoints` is a protocol feature instead of an optional Host feature. Removed:
|
|
83
|
+
|
|
84
|
+
- the executor, claim and Action-list schemas;
|
|
85
|
+
- `action_result` from `SessionCommandSchema`;
|
|
86
|
+
- the `claimed` Action status, `claimId` and `leaseExpiresAt`.
|
|
87
|
+
|
|
88
|
+
New: `ActionResultReceiptSchema`, the receipt of `POST /v1/actions/:id/result`, which is `AcceptedResponse` without `requestId`.
|
|
89
|
+
|
|
90
|
+
- **Runtime.** Removed:
|
|
91
|
+
|
|
92
|
+
- `PUT`/`GET /v1/executors`, `DELETE /v1/executors/:agentId`, `GET /v1/executors/connect`;
|
|
93
|
+
- `GET /v1/actions`, `POST /v1/actions/:id/claim`, and the executor form of `POST /v1/actions/:id/heartbeat`;
|
|
94
|
+
- the `tenant/work` stream;
|
|
95
|
+
- claim expiry;
|
|
96
|
+
- executor credentials.
|
|
97
|
+
|
|
98
|
+
`POST /v1/actions/:id/sandbox/:tool` takes the delivery token only. Tenant summaries report `inFlightDeliveries` instead of `connectedExecutors`. Tenant status lists each agent's endpoint and has an `endpoints` check instead of `executors`.
|
|
99
|
+
|
|
100
|
+
Postgres migration 6 drops the `executors` table. Actions an executor had claimed are handled like lost deliveries: a tool becomes `uncertain`, and a hook, `fn` or `verify` is delivered again.
|
|
101
|
+
|
|
102
|
+
- **Agents.** Removed: `connectAgents`, the `@nylorun/agents/executor` subpath, derived executor keys and `NYLORUN_EXECUTOR_KEY`. Serve agents with `createActionHandler` and call `register({ url })`.
|
|
103
|
+
- **CLI.** Executor keys are gone from Project credentials. `nylo tenant endpoints` shows each endpoint and its health.
|
|
104
|
+
|
|
105
|
+
- c0f4623: `nylorun up`/`start` refuses to downgrade the shared stack. When this release pins a Runtime older than `host.json` `runtimeVersion` or the running Runtime's `/health` version, it exits 5 before changing the stack files or containers, and names the remedy: update nylorun, or pass the new `--allow-downgrade` flag. `nylorun studio` applies the same check when it starts the stack. With `NYLORUN_RUNTIME_IMAGE` set, the check is skipped and `host.json` keeps its recorded `runtimeVersion`.
|
|
106
|
+
- Pin core to the tested release.
|
|
107
|
+
- Pin runtime to the tested release.
|
|
108
|
+
- Pin studio to the tested release.
|
|
109
|
+
- Updated dependencies [c7614a4]
|
|
110
|
+
- Updated dependencies [679c488]
|
|
111
|
+
- Updated dependencies [c85cd9e]
|
|
112
|
+
- Updated dependencies [4282d5f]
|
|
113
|
+
- Updated dependencies [82d95ef]
|
|
114
|
+
- Updated dependencies [f48f12f]
|
|
115
|
+
- Updated dependencies [50d0fb5]
|
|
116
|
+
- Updated dependencies [50d0fb5]
|
|
117
|
+
- Updated dependencies [c121144]
|
|
118
|
+
- Updated dependencies [6ab4c59]
|
|
119
|
+
- Updated dependencies [6ab4c59]
|
|
120
|
+
- Updated dependencies [2ab8ed1]
|
|
121
|
+
- Updated dependencies [c121144]
|
|
122
|
+
- Updated dependencies [9546ac7]
|
|
123
|
+
- Updated dependencies [9546ac7]
|
|
124
|
+
- Updated dependencies [9d52189]
|
|
125
|
+
- Updated dependencies [50d0fb5]
|
|
126
|
+
- Updated dependencies [18468d9]
|
|
127
|
+
- @nylorun/core@0.9.0-beta
|
|
128
|
+
|
|
3
129
|
## 0.2.1-beta
|
|
4
130
|
|
|
5
131
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
# nylorun
|
|
2
2
|
|
|
3
|
-
Sets up and runs
|
|
4
|
-
Compose
|
|
3
|
+
Sets up and runs local Nylorun stacks: the Runtime and Studio, as Docker
|
|
4
|
+
Compose stacks, one 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
|
|
8
|
-
npx nylorun
|
|
8
|
+
npx nylorun start # create (first run) and start this project's stack, its Tenant and the Project link
|
|
9
|
+
npx nylorun stop # stop it; volumes (and the Tenant's data) are kept
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
A stack is one installation: one Runtime with its own Postgres, Restate and
|
|
13
|
+
S2, serving exactly one Tenant. `nylorun start` in a project creates the
|
|
14
|
+
project's stack, the Runtime creates the stack's Tenant on its first start,
|
|
15
|
+
and `nylorun start` links the project to it. There are no Tenant commands:
|
|
16
|
+
projects that must not share agents, credentials or history run separate
|
|
17
|
+
stacks. Agents, sessions and model providers belong to the Runtime client,
|
|
18
|
+
[`@nylorun/cli`](../cli/README.md) (command `nylo`). Depends on `@nylorun/core`
|
|
19
|
+
only among Nylorun packages and never imports `@nylorun/runtime`. Vocabulary:
|
|
15
20
|
[runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
|
|
16
21
|
|
|
17
22
|
Prerequisites, installed by the developer (nylorun never downloads them): Node
|
|
@@ -29,53 +34,155 @@ npx nylorun doctor # Node 24+, Docker, Compose v2, and the stack
|
|
|
29
34
|
## Commands
|
|
30
35
|
|
|
31
36
|
```sh
|
|
32
|
-
nylorun up|start [--no-studio] [--no-open]
|
|
33
|
-
|
|
34
|
-
nylorun
|
|
35
|
-
nylorun
|
|
36
|
-
nylorun
|
|
37
|
-
nylorun
|
|
37
|
+
nylorun up|start [--name <stack>] [--no-link] [--no-studio] [--no-open] [--allow-downgrade] [--studio-embed-origin <origin>]... [--studio-embed-origin-reset]
|
|
38
|
+
# create (first run) and start the stack; link the project; print the URLs; open Studio signed in
|
|
39
|
+
nylorun down|stop [--name <stack>] # stop the containers; keep volumes
|
|
40
|
+
nylorun status [--name <stack>] [--json] # the stack, its Host root and Tenant, services, endpoints, Runtime health
|
|
41
|
+
nylorun logs [service] [--name <stack>] [-f] [--tail <n>] # postgres, restate, s2, gateway, runtime, studio
|
|
42
|
+
nylorun studio [--name <stack>] [--no-open] # sign a browser in to Studio on the stack's Tenant; starts the stack if needed
|
|
43
|
+
nylorun reset [--name <stack>] [--yes] # delete the stack's volumes and Tenant directory; the next start creates a new Tenant
|
|
44
|
+
nylorun ls [--json] # the stacks on this machine
|
|
45
|
+
nylorun delete <stack> --yes # remove a stack: containers, volumes, Host root and vault key
|
|
46
|
+
nylorun legacy stop|delete [--yes] # the single stack of older releases
|
|
38
47
|
nylorun doctor [--json] # prerequisites and stack health
|
|
39
48
|
```
|
|
40
49
|
|
|
41
50
|
`up` and `down` are the Docker Compose spellings of `start` and `stop`: `down`
|
|
42
51
|
stops the containers and keeps the volumes, so no Tenant data is lost.
|
|
43
|
-
`nylorun stack <command>` still works as a hidden alias.
|
|
44
|
-
|
|
45
|
-
`nylorun
|
|
46
|
-
and `nylorun doctor sandbox`.
|
|
52
|
+
`nylorun stack <command>` still works as a hidden alias. Removed commands exit
|
|
53
|
+
2 naming the replacement: `nylorun tenant …` (`nylorun start` creates the
|
|
54
|
+
Tenant; `nylorun status|reset`, or `nylo status|reset|endpoints`), `nylorun
|
|
55
|
+
dev`, `nylorun configure`, `nylorun status --env` and `nylorun doctor sandbox`.
|
|
56
|
+
|
|
57
|
+
## Stacks
|
|
58
|
+
|
|
59
|
+
Every command acts on one stack, chosen in this order:
|
|
60
|
+
|
|
61
|
+
1. `--name <stack>`;
|
|
62
|
+
2. `NYLORUN_STACK`;
|
|
63
|
+
3. the stack in the project's link (`.nylorun/link.json`, found from the
|
|
64
|
+
working directory upwards);
|
|
65
|
+
4. for `start` in a project only: the project directory's name, lowercased,
|
|
66
|
+
with characters outside `[a-z0-9_-]` as `-`, and a suffix (`-2`, `-3`, …)
|
|
67
|
+
when a stack of that name was created for another project directory.
|
|
68
|
+
|
|
69
|
+
Outside a project, `start` needs `--name`, and the other commands need
|
|
70
|
+
`--name`, `NYLORUN_STACK` or a linked project. `nylorun ls` lists the stacks.
|
|
71
|
+
|
|
72
|
+
Each stack has its own Host root `~/.nylorun/stacks/<name>/`, Compose project
|
|
73
|
+
`nylorun-<name>` (`NYLORUN_STACK_PROJECT` overrides it), volumes, network and
|
|
74
|
+
ports. `NYLORUN_HOME` replaces the whole Host root (the stack's name then comes
|
|
75
|
+
from its `stack.json`, the project directory or the Host root's own name).
|
|
76
|
+
|
|
77
|
+
A stack refuses only a Runtime older than its own database: `start` records
|
|
78
|
+
the pinned Runtime version in `host.json` (`runtimeVersion`) and exits 5 when
|
|
79
|
+
this nylorun pins an older one. Update nylorun, or pass `--allow-downgrade`
|
|
80
|
+
when both versions use the same database schema (otherwise the Runtime reports
|
|
81
|
+
the Tenant unavailable, `schema-too-new`). With `NYLORUN_RUNTIME_IMAGE` set,
|
|
82
|
+
the image's version is unknown: `start` does not check it and keeps the
|
|
83
|
+
recorded version.
|
|
84
|
+
|
|
85
|
+
## The Project link
|
|
86
|
+
|
|
87
|
+
`nylorun start` in a project waits until the stack's Tenant is open
|
|
88
|
+
(`/v1/admin/status`), then writes, in a `.nylorun/` directory (mode 0700, with
|
|
89
|
+
its own `.gitignore` of `*`):
|
|
90
|
+
|
|
91
|
+
- `link.json`: `{ "format": 2, "stack", "hostUrl", "hostId", "tenantId" }`.
|
|
92
|
+
The Tenant id is information only: nothing in a request selects a Tenant.
|
|
93
|
+
- `credentials.json` (mode 0600): the key of the derived principal `project`,
|
|
94
|
+
derived from the stack's admin key, and its id.
|
|
95
|
+
|
|
96
|
+
Later starts reuse the stack and rewrite the link only when the stack, its URL,
|
|
97
|
+
Host or Tenant changed (after `nylorun reset`, for example). When it writes a
|
|
98
|
+
new link, `start` seeds the Tenant from the project's `.env`: the sandbox
|
|
99
|
+
backend (`NYLORUN_SANDBOX=auto|virtual`) and the model credential
|
|
100
|
+
(`MODEL_PROVIDER`, `MODEL`, `MODEL_PROVIDER_API_KEY`, `MODEL_PROVIDER_BASE_URL`,
|
|
101
|
+
or `.nylorun/auth.json`), unless the Tenant has a model or
|
|
102
|
+
`NYLORUN_DEV_MODEL=fixture`. `.env` never configures the stack itself.
|
|
103
|
+
|
|
104
|
+
A fresh clone or a second worktree has no link: `nylorun start` there creates a
|
|
105
|
+
new stack, or `nylorun start --name <stack>` attaches it to an existing one so
|
|
106
|
+
both share the stack's Tenant. `--no-link` starts a stack without linking the
|
|
107
|
+
working directory (scripts). A link of format 0 or 1 named a Tenant on the
|
|
108
|
+
shared stack of an older Runtime: `start` says so, creates the project's own
|
|
109
|
+
stack and replaces the link.
|
|
110
|
+
|
|
111
|
+
The Runtime registers the derived principals of `NYLORUN_DERIVED_PRINCIPALS`
|
|
112
|
+
(comma-separated, from the environment of `nylorun start`, kept in the stack's
|
|
113
|
+
`.env`) when it creates the Tenant; `project` is always among them.
|
|
47
114
|
|
|
48
115
|
## The stack
|
|
49
116
|
|
|
50
|
-
`nylorun
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
117
|
+
`nylorun start` writes `compose.yaml` and `.env` (mode 0600) under
|
|
118
|
+
`~/.nylorun/stacks/<name>/docker/` on the first run and reuses them after that: `postgres`,
|
|
119
|
+
`restate`, `s2`, `gateway`, `runtime` and `studio`. Postgres initialises the
|
|
120
|
+
stack's database with C collation. The Runtime and Studio images are pinned by
|
|
121
|
+
this release (`package.json` `nylorun.runtime` and `nylorun.studio`);
|
|
55
122
|
`NYLORUN_RUNTIME_IMAGE` and `NYLORUN_STUDIO_IMAGE` override them (local builds,
|
|
56
|
-
CI). Ports publish on loopback only: the Runtime on `8787`,
|
|
57
|
-
|
|
58
|
-
|
|
123
|
+
CI). Ports publish on loopback only: the Runtime on `8787`, its operator
|
|
124
|
+
listener (Admin API) on `8788`, Studio on `4161` and the Restate UI on `9070`,
|
|
125
|
+
or free ports chosen on the stack's first start, avoiding the ports other
|
|
126
|
+
stacks keep, and kept in its `.env`.
|
|
59
127
|
|
|
60
|
-
`
|
|
61
|
-
terminal (not in CI, and not with `--no-open`), `
|
|
128
|
+
`start` prints Studio as `http://localhost:<port>`. Studio has no password: in a
|
|
129
|
+
terminal (not in CI, and not with `--no-open`), `start` asks the Studio container
|
|
62
130
|
for a single-use login token with the admin key (`POST /_studio/login-tokens`)
|
|
63
|
-
and opens `http://localhost:<port>/login?token=…`
|
|
64
|
-
session cookie for 30 days, which survives Studio
|
|
65
|
-
keeps working in that browser. The token itself is
|
|
66
|
-
browser starts. Otherwise `
|
|
67
|
-
browser in the same way; `nylorun studio --no-open`
|
|
68
|
-
works once, for two minutes) instead.
|
|
69
|
-
|
|
131
|
+
and opens `http://localhost:<port>/login?token=…` on the stack's Tenant in the
|
|
132
|
+
browser. That sets a session cookie for 30 days, which survives Studio
|
|
133
|
+
restarts, so the printed URL keeps working in that browser. The token itself is
|
|
134
|
+
never printed unless no browser starts. Otherwise `start` says to run `nylorun
|
|
135
|
+
studio`, which signs a browser in the same way; `nylorun studio --no-open`
|
|
136
|
+
prints the login URL (it works once, for two minutes) instead.
|
|
137
|
+
|
|
138
|
+
### Embedding Studio in a desktop app
|
|
139
|
+
|
|
140
|
+
A desktop app such as Babai Desktop can show Studio inside its own window, in
|
|
141
|
+
an iframe loaded from Studio's URL (`studio.url` in `nylorun status --json`).
|
|
142
|
+
Only exact origins listed in `NYLORUN_STUDIO_FRAME_ANCESTORS` (in
|
|
143
|
+
`~/.nylorun/stacks/<name>/docker/.env`) may frame it. The default is Babai's
|
|
144
|
+
`nylorun://localhost http://nylorun.localhost`; `nylorun status` lists them
|
|
145
|
+
under `Embeds`. While building such an app, add its dev server once with
|
|
146
|
+
`nylorun start --studio-embed-origin http://localhost:1420`; the list is kept
|
|
147
|
+
across starts until `--studio-embed-origin-reset`. Wildcards are refused.
|
|
148
|
+
|
|
149
|
+
The app's backend mints a single-use login token for the stack's Tenant with
|
|
150
|
+
`mintStudioLoginToken` from `@nylorun/admin` (it needs the admin key), and its
|
|
151
|
+
page passes the token to Studio by `postMessage`. The message contract is
|
|
152
|
+
`@nylorun/agents/studio-embed`.
|
|
153
|
+
|
|
154
|
+
## Sandboxes
|
|
155
|
+
|
|
156
|
+
A session gets a sandbox when it is opened with one, or when the Tenant's
|
|
157
|
+
default names one (`PUT /v1/tenant/sandbox`). The stack runs them on the
|
|
158
|
+
Runtime's **virtual** backend: an emulated shell in the Runtime process, with no
|
|
159
|
+
extra containers. It is not a VM or container boundary.
|
|
70
160
|
|
|
71
161
|
## Host root
|
|
72
162
|
|
|
73
|
-
The **Host root** is
|
|
74
|
-
Runtime and Studio containers, and holds `
|
|
75
|
-
and
|
|
76
|
-
and
|
|
77
|
-
|
|
78
|
-
|
|
163
|
+
The **Host root** is `~/.nylorun/stacks/<name>/`, or `NYLORUN_HOME`. It is
|
|
164
|
+
bind-mounted into the Runtime and Studio containers, and holds `stack.json`
|
|
165
|
+
(the stack's name and the project it was created for), `host.json` (the
|
|
166
|
+
client-facing host and port), `host-credentials.json` (the admin key, mode
|
|
167
|
+
0600), the Docker Compose files in `docker/`, the Tenant directory `tenant/` (homes, logs) and
|
|
168
|
+
`keys/vault-kek`, the Tenant's vault key, which only the gateway container
|
|
169
|
+
mounts. The Tenant's data lives in the stack's Postgres, Restate and S2
|
|
170
|
+
volumes.
|
|
171
|
+
|
|
172
|
+
`nylorun reset` deletes the selected stack's volumes, `tenant/` and `keys/`, and keeps
|
|
173
|
+
its files and ports; the next start creates a new Tenant and relinks the
|
|
174
|
+
project. `nylorun delete <stack> --yes` removes the stack's containers,
|
|
175
|
+
volumes and Host root: the vault key (KEK) and all the Tenant's data go with it.
|
|
176
|
+
|
|
177
|
+
## Upgrading from a shared stack
|
|
178
|
+
|
|
179
|
+
Older releases ran one stack per machine (Compose project `nylorun`, Host root
|
|
180
|
+
`~/.nylorun`) with a Tenant per project. This release starts fresh and leaves
|
|
181
|
+
that stack as it is: `nylorun start` mentions it once, and `nylorun ls` shows
|
|
182
|
+
it. `nylorun legacy stop` stops it; `nylorun legacy delete --yes` removes its
|
|
183
|
+
containers, volumes and files under `~/.nylorun` (never `~/.nylorun/stacks`).
|
|
184
|
+
Model credentials come from each project's `.env` (or Studio), and agents
|
|
185
|
+
register again (`npm run dev`). See [MIGRATION.md](../MIGRATION.md).
|
|
79
186
|
|
|
80
187
|
## Exit codes
|
|
81
188
|
|
|
@@ -83,10 +190,11 @@ each with its own Tenant.
|
|
|
83
190
|
| --- | --- |
|
|
84
191
|
| 0 | Success |
|
|
85
192
|
| 1 | Generic failure, including a missing Docker or Compose v2 |
|
|
86
|
-
| 2 | Usage error, or a removed or moved command |
|
|
87
|
-
| 3 | `status`: the Runtime is not answering; `stop`/`logs`: no stack yet |
|
|
193
|
+
| 2 | Usage error (including no stack selected, or `delete` without `--yes`), or a removed or moved command |
|
|
194
|
+
| 3 | `status`: the Runtime is not answering; `stop`/`logs`: no stack yet; `delete`: no such stack |
|
|
88
195
|
| 4 | The Runtime port is held by another Host |
|
|
89
|
-
|
|
|
196
|
+
| 5 | `up`/`start`/`studio`: this nylorun pins a Runtime older than the one that last ran the stack; update nylorun, or `start --allow-downgrade` |
|
|
197
|
+
| 7 | The stack, its Tenant or Studio did not become ready (an unavailable Tenant's cause is printed) |
|
|
90
198
|
| 130 / 143 | SIGINT / SIGTERM |
|
|
91
199
|
|
|
92
200
|
## Troubleshooting
|
|
@@ -94,8 +202,10 @@ each with its own Tenant.
|
|
|
94
202
|
| Symptom | What to do |
|
|
95
203
|
| --- | --- |
|
|
96
204
|
| Docker missing or not running | Install or start Docker Desktop, OrbStack or Colima; `nylorun doctor` checks |
|
|
97
|
-
| `426` from the Runtime | Upgrade nylorun (`npx nylorun@latest
|
|
98
|
-
|
|
|
205
|
+
| `426` from the Runtime | Upgrade nylorun (`npx nylorun@latest start`), or pin a matching older set |
|
|
206
|
+
| `Refusing to start Runtime …` (exit 5) | Upgrade nylorun (`npx nylorun@latest start`); `--allow-downgrade` only when both Runtimes share the database schema |
|
|
207
|
+
| `The Tenant of stack … is unavailable` (exit 7) | Follow the repair it names; `nylorun logs runtime` |
|
|
208
|
+
| Port conflict | Change `NYLORUN_PORT` / `NYLORUN_STUDIO_PORT` in `~/.nylorun/stacks/<name>/docker/.env` |
|
|
99
209
|
| Logs | `nylorun logs runtime -f` |
|
|
100
210
|
| Studio login expired | `nylorun studio` |
|
|
101
211
|
|
package/dist/cli.js
CHANGED
|
@@ -2,23 +2,26 @@
|
|
|
2
2
|
import "./baseline.js";
|
|
3
3
|
import { baselineEnv } from "./baseline.js";
|
|
4
4
|
import { CliError } from "./errors.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
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|legacy|doctor>
|
|
8
7
|
|
|
9
|
-
Local
|
|
8
|
+
Local stacks (Docker Compose), one per project:
|
|
10
9
|
${stackUsage}
|
|
11
10
|
doctor [--json] check Node, Docker and Compose v2, and the stack's health
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
A command acts on the stack --name or NYLORUN_STACK names, else the linked project's;
|
|
13
|
+
NYLORUN_HOME sets its Host root (default ~/.nylorun/stacks/<name>).
|
|
14
|
+
|
|
15
|
+
nylorun sets up and runs local stacks. "nylorun start" in a project creates the
|
|
16
|
+
project's stack, its one Tenant and the Project link. Agents, sessions and model
|
|
14
17
|
providers belong to the Runtime client: npx @nylorun/cli --help`;
|
|
15
18
|
const CLIENT = "npx @nylorun/cli";
|
|
16
|
-
/** Commands that moved to the Runtime client (`@nylorun/cli`, command `nylo`). */
|
|
19
|
+
/** Commands that were removed, or moved to the Runtime client (`@nylorun/cli`, command `nylo`). */
|
|
17
20
|
const MOVED_TO_CLIENT = {
|
|
18
|
-
dev:
|
|
19
|
-
tenant: `Tenant commands
|
|
21
|
+
dev: "nylorun dev was removed: run `npx nylorun start` in your project (it creates the project's stack, its Tenant and the Project link), then your project's `npm run dev`.",
|
|
22
|
+
tenant: `Tenant commands were removed: a stack serves one Tenant, which \`npx nylorun start\` in a project creates with the stack and the Project link. Use nylorun status|reset, or ${CLIENT} status|reset|endpoints.`,
|
|
20
23
|
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
|
|
24
|
+
serve: "nylorun serve was removed. Use node dist/src/main.js with NYLORUN_RUNTIME_URL and NYLORUN_SERVER_KEY.",
|
|
22
25
|
runtime: "nylorun runtime was removed: the local Runtime runs in the Docker Compose stack. Use nylorun up|down|status|logs.",
|
|
23
26
|
};
|
|
24
27
|
const LOCAL_UI_REMOVED = "--local-ui was removed: Studio runs in the stack's studio container. Run nylorun studio.";
|
|
@@ -37,8 +40,7 @@ async function main() {
|
|
|
37
40
|
if (command === "studio") {
|
|
38
41
|
if (args.includes("--local-ui"))
|
|
39
42
|
throw usageError(LOCAL_UI_REMOVED);
|
|
40
|
-
|
|
41
|
-
process.exitCode = await studioCommand(args, baselineEnv(), tenantId ? { next: tenantStudioPath(tenantId) } : {});
|
|
43
|
+
process.exitCode = await studioCommand(args, baselineEnv());
|
|
42
44
|
return;
|
|
43
45
|
}
|
|
44
46
|
if (isStackCommand(command)) {
|
package/dist/doctor.d.ts
CHANGED
|
@@ -6,7 +6,9 @@ export interface StackDoctorReport {
|
|
|
6
6
|
};
|
|
7
7
|
docker: Check;
|
|
8
8
|
compose?: Check;
|
|
9
|
-
stack?: Pick<StackStatus, "project" | "home" | "state" | "runtime" | "studio">;
|
|
9
|
+
stack?: Pick<StackStatus, "name" | "project" | "home" | "state" | "runtime" | "tenant" | "studio" | "gateway">;
|
|
10
|
+
/** Why no stack was checked: none is selected here (no link, NYLORUN_STACK or NYLORUN_HOME). */
|
|
11
|
+
noStack?: string;
|
|
10
12
|
}
|
|
11
13
|
/**
|
|
12
14
|
* `nylorun doctor`: check the prerequisites of the local stack (Node 24+,
|
package/dist/doctor.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CliError } from "./errors.js";
|
|
1
2
|
import { checkDocker, defaultStackDeps, readStackStatus, } from "./stack/index.js";
|
|
2
3
|
/** Oldest Node the stack's tooling and the developer's application run on. */
|
|
3
4
|
const MIN_NODE_MAJOR = 24;
|
|
@@ -17,16 +18,29 @@ export async function doctorStack(options) {
|
|
|
17
18
|
...checks,
|
|
18
19
|
};
|
|
19
20
|
if (checks.docker.ok && checks.compose?.ok) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
try {
|
|
22
|
+
const status = await readStackStatus(deps);
|
|
23
|
+
report.stack = {
|
|
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.noStack = error.message;
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
|
-
const stackBroken = report.stack?.state === "running" &&
|
|
40
|
+
const stackBroken = report.stack?.state === "running" &&
|
|
41
|
+
(!report.stack.runtime.healthy ||
|
|
42
|
+
!report.stack.gateway.healthy ||
|
|
43
|
+
report.stack.tenant?.cause !== undefined);
|
|
30
44
|
const failed = !nodeOk || !checks.docker.ok || checks.compose?.ok === false || stackBroken;
|
|
31
45
|
if (options.json) {
|
|
32
46
|
log(JSON.stringify(report, null, 2));
|
|
@@ -48,16 +62,18 @@ export async function doctorStack(options) {
|
|
|
48
62
|
["compose", line(checks.compose)],
|
|
49
63
|
];
|
|
50
64
|
const stack = report.stack;
|
|
65
|
+
if (report.noStack)
|
|
66
|
+
rows.push(["stack", `- ${report.noStack}`]);
|
|
51
67
|
if (stack) {
|
|
52
68
|
rows.push([
|
|
53
69
|
"stack",
|
|
54
70
|
stack.state === "absent"
|
|
55
|
-
? `- not created under ${stack.home}: run nylorun up`
|
|
71
|
+
? `- ${stack.name} not created under ${stack.home}: run nylorun up`
|
|
56
72
|
: stack.state === "stopped"
|
|
57
|
-
? `- stopped (project ${stack.project}): run nylorun up`
|
|
73
|
+
? `- ${stack.name} stopped (Compose project ${stack.project}): run nylorun up`
|
|
58
74
|
: stack.runtime.healthy
|
|
59
|
-
? `✓ running (project ${stack.project})`
|
|
60
|
-
: `✗ running, but the Runtime does not answer: see nylorun status and nylorun logs runtime`,
|
|
75
|
+
? `✓ ${stack.name} running (Compose project ${stack.project})`
|
|
76
|
+
: `✗ ${stack.name} running, but the Runtime does not answer: see nylorun status and nylorun logs runtime`,
|
|
61
77
|
]);
|
|
62
78
|
if (stack.state === "running") {
|
|
63
79
|
rows.push([
|
|
@@ -66,6 +82,19 @@ export async function doctorStack(options) {
|
|
|
66
82
|
? `✓ ${stack.runtime.url ?? "?"} · ${stack.runtime.version ?? "?"}`
|
|
67
83
|
: `✗ ${stack.runtime.url ?? "?"} not answering`,
|
|
68
84
|
]);
|
|
85
|
+
rows.push([
|
|
86
|
+
"gateway",
|
|
87
|
+
stack.gateway.healthy
|
|
88
|
+
? `✓ ${stack.gateway.state} · combined packing (runtime: core,loop; gateway: gates)`
|
|
89
|
+
: `✗ ${stack.gateway.state}: model calls fail; see nylorun logs gateway`,
|
|
90
|
+
]);
|
|
91
|
+
if (stack.tenant)
|
|
92
|
+
rows.push([
|
|
93
|
+
"tenant",
|
|
94
|
+
stack.tenant.state === "open"
|
|
95
|
+
? `✓ ${stack.tenant.id ?? "?"} open`
|
|
96
|
+
: `✗ ${stack.tenant.id ?? "?"} unavailable${stack.tenant.cause ? `: ${stack.tenant.cause.code}: ${stack.tenant.cause.repair}` : " (opening)"}`,
|
|
97
|
+
]);
|
|
69
98
|
rows.push(["studio", `${stack.studio.url ?? "?"} · ${stack.studio.state}`]);
|
|
70
99
|
}
|
|
71
100
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The derived principal a Project uses; the stack's Runtime registers it on its Tenant. */
|
|
2
|
+
export declare const PROJECT_PRINCIPAL_ID = "project";
|
|
3
|
+
/**
|
|
4
|
+
* Key of a derived principal on the stack's Tenant, from the admin key. A copy of
|
|
5
|
+
* `deriveTenantKey` in `@nylorun/admin` (nylorun depends on `@nylorun/core` only); both are
|
|
6
|
+
* tested against the same fixed vector.
|
|
7
|
+
*/
|
|
8
|
+
export declare function deriveTenantKey(adminKey: string, tenantId: string, principalId: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createHmac } from "node:crypto";
|
|
2
|
+
/** The derived principal a Project uses; the stack's Runtime registers it on its Tenant. */
|
|
3
|
+
export const PROJECT_PRINCIPAL_ID = "project";
|
|
4
|
+
/**
|
|
5
|
+
* Key of a derived principal on the stack's Tenant, from the admin key. A copy of
|
|
6
|
+
* `deriveTenantKey` in `@nylorun/admin` (nylorun depends on `@nylorun/core` only); both are
|
|
7
|
+
* tested against the same fixed vector.
|
|
8
|
+
*/
|
|
9
|
+
export function deriveTenantKey(adminKey, tenantId, principalId) {
|
|
10
|
+
const message = Buffer.concat([
|
|
11
|
+
Buffer.from("nylorun/principal/v1", "utf8"),
|
|
12
|
+
Buffer.from([0]),
|
|
13
|
+
Buffer.from(principalId, "utf8"),
|
|
14
|
+
Buffer.from([0]),
|
|
15
|
+
Buffer.from(tenantId, "utf8"),
|
|
16
|
+
]);
|
|
17
|
+
return createHmac("sha256", Buffer.from(adminKey, "utf8")).update(message).digest("hex");
|
|
18
|
+
}
|
package/dist/project/link.d.ts
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The Project link (`.nylorun/link.json`) and credentials (`.nylorun/credentials.json`).
|
|
3
|
+
* `nylorun start` writes both, format 2: the stack the Project uses, its URL and Host id, and
|
|
4
|
+
* the Tenant id as information (nothing selects a Tenant). Formats 0 and 1 named a Tenant on a
|
|
5
|
+
* multi-Tenant Host of an older Runtime.
|
|
5
6
|
*/
|
|
6
|
-
export
|
|
7
|
+
export interface ProjectLink {
|
|
8
|
+
format: 0 | 1 | 2;
|
|
9
|
+
/** The local stack (format 2). */
|
|
10
|
+
stack?: string;
|
|
11
|
+
hostUrl: string;
|
|
12
|
+
hostId: string;
|
|
13
|
+
tenantId?: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function linkPath(projectRoot: string): string;
|
|
16
|
+
export declare function credentialsPath(projectRoot: string): string;
|
|
17
|
+
/** The Project's link, or undefined when it has none. An unreadable link is an error. */
|
|
18
|
+
export declare function readProjectLink(projectRoot: string): Promise<ProjectLink | undefined>;
|
|
19
|
+
export declare function writeProjectLink(projectRoot: string, link: {
|
|
20
|
+
stack: string;
|
|
21
|
+
hostUrl: string;
|
|
22
|
+
hostId: string;
|
|
23
|
+
tenantId: string;
|
|
24
|
+
}): Promise<void>;
|
|
25
|
+
/** The Project's application key and principal, or undefined when absent or unreadable. */
|
|
26
|
+
export declare function readProjectCredentials(projectRoot: string): Promise<{
|
|
27
|
+
applicationKey: string;
|
|
28
|
+
principalId: string;
|
|
29
|
+
} | undefined>;
|
|
30
|
+
/** `.nylorun/credentials.json` (format 1, mode 0600). */
|
|
31
|
+
export declare function writeProjectCredentials(projectRoot: string, credentials: {
|
|
32
|
+
applicationKey: string;
|
|
33
|
+
principalId: string;
|
|
34
|
+
}): Promise<void>;
|