@nylorun/admin 0.7.0-beta → 0.8.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 CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.8.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 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.
8
+
9
+ - **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.
10
+ - **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`.
11
+ - **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`.
12
+ - **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`.
13
+ - **Breaking (`@nylorun/admin`):** `createAdmin({ tenant })` replaces `{ stack }`, `tenantHostRoot(name)` replaces `stackHostRoot(name)`, and local resolution reads `NYLORUN_TENANT` and the link's `tenant`.
14
+ - `@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.
15
+
16
+ ### Patch Changes
17
+
18
+ - Pin core to the tested release.
19
+ - Updated dependencies [4b9906f]
20
+ - @nylorun/core@0.11.0-beta
21
+
3
22
  ## 0.7.0-beta
4
23
 
5
24
  ### Major Changes
package/README.md CHANGED
@@ -9,7 +9,7 @@ import { createAdmin } from "@nylorun/admin";
9
9
 
10
10
  // Resolution: explicit options → NYLORUN_ADMIN_URL + NYLORUN_ADMIN_KEY → local Host
11
11
  const admin = createAdmin();
12
- // or: createAdmin({ url, key }) / createAdmin({ stack: "my-app" }) / createAdmin({ home })
12
+ // or: createAdmin({ url, key }) / createAdmin({ tenant: "my-app" }) / createAdmin({ home })
13
13
 
14
14
  const { tenant } = await admin.status();
15
15
  // tenant: { id, name, state: "open" | "unavailable", envelope, cause? }
@@ -38,10 +38,11 @@ so rotating the admin key rotates every derived key. `nylorun start` writes the
38
38
  `project` key into a Project's `.nylorun/credentials.json`.
39
39
 
40
40
  Local Host resolution reads `host.json` and `host-credentials.json` from the
41
- Host root: `options.home`, else `NYLORUN_HOME`, else the stack's Host root
42
- `~/.nylorun/stacks/<stack>/` for the stack named by `options.stack`,
43
- `NYLORUN_STACK` or the Project link (`stack` in `.nylorun/link.json`, found
44
- from `options.cwd` upwards). On POSIX the credentials file must be owned by the
41
+ Host root: `options.home`, else `NYLORUN_HOME`, else the Tenant's Host root
42
+ `~/.nylorun/tenants/<tenant>/` for the local Tenant named by `options.tenant`,
43
+ `NYLORUN_TENANT` or the Project link (`tenant` in `.nylorun/link.json`, format
44
+ 3, found from `options.cwd` upwards; a link from an older nylorun throws
45
+ `connection_missing`). On POSIX the credentials file must be owned by the
45
46
  user and not group- or world-readable. First use checks `/health`
46
47
  compatibility and throws `incompatible_host` on mismatch.
47
48
 
@@ -51,7 +52,7 @@ Tenant.
51
52
 
52
53
  Errors are `AdminError` with a registry `code` from `@nylorun/core`
53
54
  (`ERROR_CODES`). Re-exports: `PROTOCOL_FEATURES`, `ERROR_CODES`,
54
- `compareVersions`, `deriveStudioToken`, `deriveTenantKey`, `stackHostRoot`,
55
+ `compareVersions`, `deriveStudioToken`, `deriveTenantKey`, `tenantHostRoot`,
55
56
  `PROJECT_PRINCIPAL_ID`.
56
57
 
57
58
  Developer applications do **not** depend on this package — only managing
package/dist/client.d.ts CHANGED
@@ -16,15 +16,15 @@ export interface ResolvedAdmin {
16
16
  export interface AdminConnectionOptions {
17
17
  url?: string;
18
18
  key?: string;
19
- /** The Host root itself (overrides `NYLORUN_HOME` and the stack). */
19
+ /** The Host root itself (overrides `NYLORUN_HOME` and the Tenant). */
20
20
  home?: string;
21
- /** The local stack whose Host root (`~/.nylorun/stacks/<stack>/`) to read. */
22
- stack?: string;
23
- /** Where to look for a Project link naming the stack; defaults to the working directory. */
21
+ /** The local Tenant whose Host root (`~/.nylorun/tenants/<tenant>/`) to read. */
22
+ tenant?: string;
23
+ /** Where to look for a Project link naming the Tenant; defaults to the working directory. */
24
24
  cwd?: string;
25
25
  }
26
- /** A local stack's Host root: `~/.nylorun/stacks/<name>/`. */
27
- export declare function stackHostRoot(name: string): string;
26
+ /** A local Tenant's Host root: `~/.nylorun/tenants/<name>/`. */
27
+ export declare function tenantHostRoot(name: string): string;
28
28
  /**
29
29
  * Resolve Admin API connection once: options → environment → local Host.
30
30
  */
package/dist/client.js CHANGED
@@ -9,15 +9,16 @@ function env(name) {
9
9
  const value = process.env[name];
10
10
  return value === undefined || value.trim() === "" ? undefined : value;
11
11
  }
12
- /** A local stack's Host root: `~/.nylorun/stacks/<name>/`. */
13
- export function stackHostRoot(name) {
14
- return resolve(join(homedir(), ".nylorun", "stacks", name));
12
+ /** A local Tenant's Host root: `~/.nylorun/tenants/<name>/`. */
13
+ export function tenantHostRoot(name) {
14
+ return resolve(join(homedir(), ".nylorun", "tenants", name));
15
15
  }
16
16
  /**
17
- * The stack a Project link names (`.nylorun/link.json`, format 2), from `cwd` upwards. The walk
18
- * stops at the home directory, which holds the stacks and is never a Project.
17
+ * The Tenant a Project link names (`.nylorun/link.json`, format 3), from `cwd` upwards, or the
18
+ * path of a link from an older nylorun. The walk stops at the home directory, which holds the
19
+ * Tenants and is never a Project.
19
20
  */
20
- function linkedStack(cwd) {
21
+ function linkedTenant(cwd) {
21
22
  const real = (path) => {
22
23
  try {
23
24
  return realpathSync(path);
@@ -30,41 +31,47 @@ function linkedStack(cwd) {
30
31
  let directory = real(resolve(cwd));
31
32
  const root = parse(directory).root;
32
33
  while (directory !== stop) {
34
+ const path = join(directory, ".nylorun", "link.json");
33
35
  let raw;
34
36
  try {
35
- raw = readFileSync(join(directory, ".nylorun", "link.json"), "utf8");
37
+ raw = readFileSync(path, "utf8");
36
38
  }
37
39
  catch {
38
40
  /* no link here */
39
41
  }
40
42
  if (raw !== undefined) {
41
43
  try {
42
- return ProjectLinkFileSchema.parse(JSON.parse(raw)).stack;
44
+ const link = ProjectLinkFileSchema.parse(JSON.parse(raw));
45
+ return link.format < 3 ? { olderLink: path } : { tenant: link.tenant };
43
46
  }
44
47
  catch {
45
- return undefined;
48
+ return {};
46
49
  }
47
50
  }
48
51
  if (directory === root)
49
- return undefined;
52
+ return {};
50
53
  directory = dirname(directory);
51
54
  }
52
- return undefined;
55
+ return {};
53
56
  }
54
57
  /**
55
- * The Host root of the local Host: `options.home`, `NYLORUN_HOME`, or the Host root of the stack
56
- * named by `options.stack`, `NYLORUN_STACK` or the Project link. Undefined when none names one.
58
+ * The Host root of the local Host: `options.home`, `NYLORUN_HOME`, or the Host root of the
59
+ * Tenant named by `options.tenant`, `NYLORUN_TENANT` or the Project link. No `home` when none
60
+ * names one; `olderLink` when the Project link is from an older nylorun.
57
61
  */
58
62
  function resolveHome(options) {
59
63
  if (options?.home !== undefined && options.home.trim() !== "")
60
- return resolve(options.home);
64
+ return { home: resolve(options.home) };
61
65
  const fromEnv = env("NYLORUN_HOME");
62
66
  if (fromEnv)
63
- return resolve(fromEnv);
64
- const stack = options?.stack?.trim() ||
65
- env("NYLORUN_STACK")?.trim() ||
66
- linkedStack(options?.cwd ?? process.cwd());
67
- return stack ? stackHostRoot(stack) : undefined;
67
+ return { home: resolve(fromEnv) };
68
+ const named = options?.tenant?.trim() || env("NYLORUN_TENANT")?.trim();
69
+ if (named)
70
+ return { home: tenantHostRoot(named) };
71
+ const linked = linkedTenant(options?.cwd ?? process.cwd());
72
+ return linked.tenant
73
+ ? { home: tenantHostRoot(linked.tenant) }
74
+ : { olderLink: linked.olderLink };
68
75
  }
69
76
  function connectionMissing(message) {
70
77
  throw new AdminError("connection_missing", message);
@@ -73,7 +80,7 @@ function sourcesTriedMessage(home) {
73
80
  return (`Tried options (url + key), environment (NYLORUN_ADMIN_URL + NYLORUN_ADMIN_KEY), ` +
74
81
  (home
75
82
  ? `and local Host settings (host.json + host-credentials.json under ${home}).`
76
- : "and local Host settings (no stack named: pass `stack`, set NYLORUN_STACK or " +
83
+ : "and local Host settings (no Tenant named: pass `tenant`, set NYLORUN_TENANT or " +
77
84
  "NYLORUN_HOME, or run in a Project that `npx nylorun start` linked)."));
78
85
  }
79
86
  function assertCredentialsSafe(path) {
@@ -142,7 +149,7 @@ function readLocalHost(home) {
142
149
  * Resolve Admin API connection once: options → environment → local Host.
143
150
  */
144
151
  export function resolveAdminConnection(options) {
145
- const home = resolveHome(options);
152
+ const { home, olderLink } = resolveHome(options);
146
153
  const optionUrl = options?.url?.trim() || undefined;
147
154
  const optionKey = options?.key?.trim() || undefined;
148
155
  if (optionUrl || optionKey) {
@@ -169,6 +176,9 @@ export function resolveAdminConnection(options) {
169
176
  ...(home ? { home } : {}),
170
177
  };
171
178
  }
179
+ if (olderLink) {
180
+ connectionMissing(`The Project link at ${olderLink} is from an older nylorun. Run "npx nylorun start" in this project to link it again.`);
181
+ }
172
182
  const local = home === undefined ? undefined : readLocalHost(home);
173
183
  if (local) {
174
184
  return {
@@ -6,7 +6,7 @@
6
6
  export declare function deriveStudioToken(adminKey: string, tenantId: string): string;
7
7
  /**
8
8
  * The derived principal that Projects use. The Host registers it on its Tenant by default
9
- * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the stack's admin
9
+ * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the Tenant's admin
10
10
  * key into the Project's `.nylorun/credentials.json`.
11
11
  */
12
12
  export declare const PROJECT_PRINCIPAL_ID = "project";
@@ -16,7 +16,7 @@ export function deriveStudioToken(adminKey, tenantId) {
16
16
  }
17
17
  /**
18
18
  * The derived principal that Projects use. The Host registers it on its Tenant by default
19
- * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the stack's admin
19
+ * (`NYLORUN_DERIVED_PRINCIPALS`), and `nylorun start` derives its key from the Tenant's admin
20
20
  * key into the Project's `.nylorun/credentials.json`.
21
21
  */
22
22
  export const PROJECT_PRINCIPAL_ID = "project";
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { AdminStatus, HostTenant, TenantEnvelope } from "@nylorun/core/contracts";
2
2
  import { ERROR_CODES, PROTOCOL_FEATURES, compareVersions, type ErrorCode } from "@nylorun/core/compatibility";
3
- import { stackHostRoot, type AdminConnectionOptions } from "./client.js";
3
+ import { tenantHostRoot, type AdminConnectionOptions } from "./client.js";
4
4
  import { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey } from "./derived-credentials.js";
5
5
  import { AdminError } from "./errors.js";
6
6
  export { ERROR_CODES, PROTOCOL_FEATURES, compareVersions };
7
7
  export type { ErrorCode };
8
8
  export { AdminError };
9
- export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, stackHostRoot };
9
+ export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, tenantHostRoot };
10
10
  export { mintStudioLoginToken } from "./studio-login.js";
11
11
  export interface Admin {
12
12
  /** The Host's Tenant API URL. */
@@ -25,8 +25,8 @@ export interface Admin {
25
25
  }
26
26
  /**
27
27
  * Resolution: explicit `url` + `key` → `NYLORUN_ADMIN_URL` + `NYLORUN_ADMIN_KEY` → the local
28
- * Host's settings in its Host root (`home`, `NYLORUN_HOME`, or the stack named by `stack`,
29
- * `NYLORUN_STACK` or the Project link under `cwd`: `~/.nylorun/stacks/<stack>/`).
28
+ * Host's settings in its Host root (`home`, `NYLORUN_HOME`, or the Tenant named by `tenant`,
29
+ * `NYLORUN_TENANT` or the Project link under `cwd`: `~/.nylorun/tenants/<tenant>/`).
30
30
  */
31
31
  export declare function createAdmin(options?: AdminConnectionOptions): Admin;
32
32
  export type { AdminConnectionOptions, AdminStatus, HostTenant, TenantEnvelope };
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { ERROR_CODES, PROTOCOL_FEATURES, compareVersions, } from "@nylorun/core/compatibility";
2
- import { AdminClient, resolveAdminConnection, stackHostRoot, } from "./client.js";
2
+ import { AdminClient, resolveAdminConnection, tenantHostRoot, } from "./client.js";
3
3
  import { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, } from "./derived-credentials.js";
4
4
  import { AdminError } from "./errors.js";
5
5
  export { ERROR_CODES, PROTOCOL_FEATURES, compareVersions };
6
6
  export { AdminError };
7
- export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, stackHostRoot };
7
+ export { PROJECT_PRINCIPAL_ID, deriveStudioToken, deriveTenantKey, tenantHostRoot };
8
8
  export { mintStudioLoginToken } from "./studio-login.js";
9
9
  /**
10
10
  * Resolution: explicit `url` + `key` → `NYLORUN_ADMIN_URL` + `NYLORUN_ADMIN_KEY` → the local
11
- * Host's settings in its Host root (`home`, `NYLORUN_HOME`, or the stack named by `stack`,
12
- * `NYLORUN_STACK` or the Project link under `cwd`: `~/.nylorun/stacks/<stack>/`).
11
+ * Host's settings in its Host root (`home`, `NYLORUN_HOME`, or the Tenant named by `tenant`,
12
+ * `NYLORUN_TENANT` or the Project link under `cwd`: `~/.nylorun/tenants/<tenant>/`).
13
13
  */
14
14
  export function createAdmin(options) {
15
15
  return new AdminClient(resolveAdminConnection(options));
@@ -51,6 +51,6 @@ export async function mintStudioLoginToken(options) {
51
51
  }
52
52
  const parsed = StudioLoginTokenResponseSchema.safeParse(JSON.parse(text));
53
53
  if (!parsed.success)
54
- throw new AdminError("incompatible_host", "This Studio does not support login tokens limited to a Tenant; update the stack.");
54
+ throw new AdminError("incompatible_host", "This Studio does not support login tokens limited to a Tenant; update Studio (npx nylorun@latest start).");
55
55
  return parsed.data;
56
56
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/admin",
3
- "version": "0.7.0-beta",
3
+ "version": "0.8.0-beta",
4
4
  "description": "Nylorun Admin API client for Tenants and Host status",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -24,7 +24,7 @@
24
24
  "clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\""
25
25
  },
26
26
  "dependencies": {
27
- "@nylorun/core": "0.10.0-beta"
27
+ "@nylorun/core": "0.11.0-beta"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "zod": "^4.6.5"