@nylorun/admin 0.14.0-beta → 0.15.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,32 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.0-beta
4
+
5
+ ### Major Changes
6
+
7
+ - 1345f61: **`nylo` ships in `nylorun`; `@nylorun/cli` is deprecated.** One package runs a project's local Tenant (`nylorun`) and is the Runtime client of the linked installation (`nylo`). MIGRATION.md ("`nylo` ships in `nylorun`") has the details.
8
+
9
+ - `nylorun`: a second bin, `nylo` (`npx -p nylorun nylo <command>`), with the same commands, flags, output and exit codes as `@nylorun/cli`'s. The `nylorun` command never loads it. nylorun now depends on `@nylorun/admin`, which `nylo` uses. `nylo configure`'s provider sign-in comes from `@earendil-works/pi-ai` (about 100 MB with its provider SDKs), which is not a dependency: the first `nylo configure` installs the tested version into `~/.nylorun/lib/pi-ai-<version>/` with npm, without install scripts, unless it resolves beside nylorun, so `npx nylorun` stays about 11 MB. `nylorun configure`, `nylorun status --env` and `nylorun doctor sandbox` still exit 2, now naming `npx -p nylorun nylo …`. `nylorun status|reset` (the local Tenant's containers and volumes) and `nylo status|reset` (the Management API) keep their meanings; both usages and the README say which is which.
10
+ - **Deprecated (`@nylorun/cli`):** its `nylo` prints one line on stderr and runs nylorun's `nylo` with the same arguments and exit code; stdout is unchanged, so `eval "$(npx @nylorun/cli env)"` still works. It depends on `nylorun` only. A later release removes it.
11
+ - **Breaking (`@nylorun/admin`): the `./project` subpath is removed.** It re-exported `@nylorun/core/project` for `nylo`, which now imports Core directly. Import `@nylorun/core/project` instead.
12
+ - `@nylorun/create-agent`: `compatibility.json` no longer pins `@nylorun/cli`; the examples run `nylo` from their `nylorun` devDependency.
13
+
14
+ ### Patch Changes
15
+
16
+ - 554df94: **Fixes for the one client layer.**
17
+
18
+ - `@nylorun/admin`: `createAdmin` reads the Project link only in its local-Host step. Explicit `url` and `key`, or `NYLORUN_RUNTIME_URL` with `NYLORUN_MANAGEMENT_KEY`, no longer fail on a `.nylorun/link.json` that cannot be read (EACCES for a root-owned file after `sudo npx nylorun start`, EISDIR); the local-Host step refuses such a link, naming it, as it refuses a broken one (when nothing else names the Host root).
19
+ - `@nylorun/admin`: a refusal without the Runtime's rejection body takes its code from the status: `invalid_request` (400), `credential_invalid` (401), `not_found` (404), `unsupported_media_type` (415), `internal_error` (5xx), else `request_rejected`; it was always `not_found`. Studio's own answers (`{ message }`, from its server and proxy, such as "This Studio session is invalid or has expired.") keep their message instead of one naming only the request and the status.
20
+ - `nylorun`: `start` refuses Project or Host root credentials in a newer format than it reads ("Upgrade nylorun"), as it refuses a newer link, instead of replacing them with new keys in its own format.
21
+
22
+ ## 0.14.1-beta
23
+
24
+ ### Patch Changes
25
+
26
+ - Pin core to the tested release.
27
+ - Updated dependencies [212364b]
28
+ - @nylorun/core@0.19.0-beta
29
+
3
30
  ## 0.14.0-beta
4
31
 
5
32
  ### Minor Changes
package/README.md CHANGED
@@ -46,9 +46,8 @@ When none resolves, or the Project link is from an older nylorun or does not
46
46
  validate (and nothing else names the Host root), or the linked Project's
47
47
  `credentials.json` does not validate, it throws `connection_missing` and lists
48
48
  what it tried. Only this local-Host step reads the Host root: `@nylorun/agents`
49
- takes the Runtime API's key from the Project or the environment only.
50
- `@nylorun/admin/project` re-exports `@nylorun/core/project`, the reader of the
51
- Project files, for tools that depend on this package (`nylo`). The first request checks the
49
+ takes the Runtime API's key from the Project or the environment only. The
50
+ Project files' reader is `@nylorun/core/project`. The first request checks the
52
51
  Host's `/health` and throws `incompatible_host` unless the Host serves protocol
53
52
  8 with the feature `management-api`.
54
53
 
package/dist/client.js CHANGED
@@ -12,7 +12,8 @@ export { tenantHostRoot };
12
12
  /**
13
13
  * The Project link (`.nylorun/link.json`, format 3) from `cwd` upwards (`@nylorun/core/project`):
14
14
  * the Tenant it names and the Project's root, or why it cannot be used (`unusable`: a link from
15
- * an older nylorun or a broken file), which only matters when nothing else names the Host root.
15
+ * an older nylorun, a broken file or one that cannot be read), which only matters when nothing
16
+ * else names the Host root.
16
17
  */
17
18
  function projectLink(cwd) {
18
19
  const project = findLinkedProjectRoot(cwd);
@@ -31,26 +32,37 @@ function projectLink(cwd) {
31
32
  catch (error) {
32
33
  if (error instanceof ProjectFileError)
33
34
  return { unusable: error.message };
34
- throw error;
35
+ // EACCES (a root-owned file after `sudo npx nylorun start`) or EISDIR.
36
+ const code = error.code;
37
+ if (typeof code !== "string")
38
+ throw error;
39
+ return {
40
+ unusable: `Cannot read the Project link at ${projectLinkPath(project)} (${code}). Fix its permissions, or remove .nylorun/link.json and run "npx nylorun start".`,
41
+ };
35
42
  }
36
43
  }
37
44
  /**
38
- * The Host root of the local Host: `options.home`, `NYLORUN_HOME`, or the Host root of the
39
- * Tenant named by `options.tenant`, `NYLORUN_TENANT` or the Project link. `project` is the
40
- * linked Project's root when the link names this Host root's Tenant.
45
+ * The Host root named without the Project link: `options.home`, `NYLORUN_HOME`, or the Host root
46
+ * of the Tenant named by `options.tenant` or `NYLORUN_TENANT`.
47
+ */
48
+ function namedHome(options) {
49
+ if (options?.home !== undefined && options.home.trim() !== "")
50
+ return resolve(options.home);
51
+ const fromEnv = env("NYLORUN_HOME");
52
+ if (fromEnv)
53
+ return resolve(fromEnv);
54
+ const named = options?.tenant?.trim() || env("NYLORUN_TENANT")?.trim();
55
+ return named ? tenantHostRoot(named) : undefined;
56
+ }
57
+ /**
58
+ * The Host root of the local Host: the one named (`namedHome`), else the Host root of the Tenant
59
+ * the Project link names. `project` is the linked Project's root when the link names this Host
60
+ * root's Tenant. Only the local-Host step reads the link.
41
61
  */
42
62
  function resolveHome(options) {
43
63
  const link = projectLink(options?.cwd ?? process.cwd());
44
64
  const linked = link.tenant ? tenantHostRoot(link.tenant) : undefined;
45
- const fromEnv = env("NYLORUN_HOME");
46
- const named = options?.tenant?.trim() || env("NYLORUN_TENANT")?.trim();
47
- const home = options?.home !== undefined && options.home.trim() !== ""
48
- ? resolve(options.home)
49
- : fromEnv
50
- ? resolve(fromEnv)
51
- : named
52
- ? tenantHostRoot(named)
53
- : linked;
65
+ const home = namedHome(options) ?? linked;
54
66
  return {
55
67
  ...(home ? { home } : {}),
56
68
  ...(home && home === linked ? { project: link.project } : {}),
@@ -139,22 +151,25 @@ function readLocalHost(home, project) {
139
151
  }
140
152
  /** Resolve the Management API connection once: options → environment → local Host. */
141
153
  export function resolveAdminConnection(options) {
142
- const { home, project, unusableLink } = resolveHome(options);
154
+ // Options and the environment never read the Project link: a link that does not read must not
155
+ // break a connection named outright.
156
+ const named = namedHome(options);
143
157
  const optionUrl = options?.url?.trim() || undefined;
144
158
  const optionKey = options?.key?.trim() || undefined;
145
159
  if (optionUrl || optionKey) {
146
160
  if (!optionUrl || !optionKey)
147
- connectionMissing(`Incomplete options: both url and key (a management key) are required. ${sourcesTriedMessage(home)}`);
148
- return { url: optionUrl.replace(/\/$/, ""), key: optionKey, source: "options", ...(home ? { home } : {}) };
161
+ connectionMissing(`Incomplete options: both url and key (a management key) are required. ${sourcesTriedMessage(named)}`);
162
+ return { url: optionUrl.replace(/\/$/, ""), key: optionKey, source: "options", ...(named ? { home: named } : {}) };
149
163
  }
150
164
  // NYLORUN_RUNTIME_URL alone is an app's (with NYLORUN_SERVER_KEY): only the key selects this.
151
165
  const envKey = env("NYLORUN_MANAGEMENT_KEY");
152
166
  if (envKey) {
153
167
  const envUrl = env("NYLORUN_RUNTIME_URL");
154
168
  if (!envUrl)
155
- connectionMissing(`Incomplete environment: NYLORUN_MANAGEMENT_KEY needs NYLORUN_RUNTIME_URL. ${sourcesTriedMessage(home)}`);
156
- return { url: envUrl.replace(/\/$/, ""), key: envKey, source: "environment", ...(home ? { home } : {}) };
169
+ connectionMissing(`Incomplete environment: NYLORUN_MANAGEMENT_KEY needs NYLORUN_RUNTIME_URL. ${sourcesTriedMessage(named)}`);
170
+ return { url: envUrl.replace(/\/$/, ""), key: envKey, source: "environment", ...(named ? { home: named } : {}) };
157
171
  }
172
+ const { home, project, unusableLink } = resolveHome(options);
158
173
  if (unusableLink && !home)
159
174
  connectionMissing(unusableLink);
160
175
  const local = home === undefined ? undefined : readLocalHost(home, project);
package/dist/errors.d.ts CHANGED
@@ -10,6 +10,6 @@ export declare class AdminError extends Error {
10
10
  }
11
11
  /**
12
12
  * The `AdminError` of a refused request: the Runtime's rejection (`{ status: "rejected", code,
13
- * message }`), else `not_found` naming `what` and the status.
13
+ * message }`), else a code from the status with Studio's message, or `what` and the status.
14
14
  */
15
15
  export declare function rejection(status: number, body: unknown, what: string): AdminError;
package/dist/errors.js CHANGED
@@ -11,16 +11,40 @@ export class AdminError extends Error {
11
11
  this.details = options?.details;
12
12
  }
13
13
  }
14
+ /** The code of a refusal without the Runtime's rejection body, from its status alone. */
15
+ function statusCode(status) {
16
+ if (status === 400)
17
+ return "invalid_request";
18
+ if (status === 401)
19
+ return "credential_invalid";
20
+ if (status === 404)
21
+ return "not_found";
22
+ if (status === 415)
23
+ return "unsupported_media_type";
24
+ if (status >= 500)
25
+ return "internal_error";
26
+ return "request_rejected";
27
+ }
28
+ /** The message of Studio's own answers (its server's and proxy's): `{ message }`, with no `code`. */
29
+ function studioMessage(body) {
30
+ if (!body || typeof body !== "object" || "code" in body)
31
+ return undefined;
32
+ const { message } = body;
33
+ return typeof message === "string" && message !== "" ? message : undefined;
34
+ }
14
35
  /**
15
36
  * The `AdminError` of a refused request: the Runtime's rejection (`{ status: "rejected", code,
16
- * message }`), else `not_found` naming `what` and the status.
37
+ * message }`), else a code from the status with Studio's message, or `what` and the status.
17
38
  */
18
39
  export function rejection(status, body, what) {
19
40
  const rejected = RejectedResponseSchema.safeParse(body);
20
- return rejected.success
21
- ? new AdminError(rejected.data.code, rejected.data.message, {
41
+ if (rejected.success)
42
+ return new AdminError(rejected.data.code, rejected.data.message, {
22
43
  status,
23
44
  details: rejected.data.details,
24
- })
25
- : new AdminError("not_found", `${what} (${status})`, { status, details: body });
45
+ });
46
+ return new AdminError(statusCode(status), studioMessage(body) ?? `${what} (${status})`, {
47
+ status,
48
+ details: body,
49
+ });
26
50
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/admin",
3
- "version": "0.14.0-beta",
3
+ "version": "0.15.0-beta",
4
4
  "description": "Nylorun Management API client: the Tenant's models, vaults, signing keys, settings and application keys",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -19,10 +19,6 @@
19
19
  "./client": {
20
20
  "types": "./dist/management.d.ts",
21
21
  "import": "./dist/management.js"
22
- },
23
- "./project": {
24
- "types": "./dist/project.d.ts",
25
- "import": "./dist/project.js"
26
22
  }
27
23
  },
28
24
  "scripts": {
@@ -32,7 +28,7 @@
32
28
  "clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\""
33
29
  },
34
30
  "dependencies": {
35
- "@nylorun/core": "0.18.0-beta"
31
+ "@nylorun/core": "0.19.0-beta"
36
32
  },
37
33
  "peerDependencies": {
38
34
  "zod": "^4.6.5"
package/dist/project.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * The local machine's Nylorun files (`@nylorun/admin/project`, Node only): the Nylorun home, a
3
- * local Tenant's Host root, the Project root, and the Project link and credentials, validated
4
- * with Core's schemas. It is `@nylorun/core/project`, for operator tools that depend on this
5
- * package and not on Core (`nylo`); `createAdmin` resolves the Project link with it.
6
- */
7
- export * from "@nylorun/core/project";
package/dist/project.js DELETED
@@ -1,7 +0,0 @@
1
- /**
2
- * The local machine's Nylorun files (`@nylorun/admin/project`, Node only): the Nylorun home, a
3
- * local Tenant's Host root, the Project root, and the Project link and credentials, validated
4
- * with Core's schemas. It is `@nylorun/core/project`, for operator tools that depend on this
5
- * package and not on Core (`nylo`); `createAdmin` resolves the Project link with it.
6
- */
7
- export * from "@nylorun/core/project";