@nylorun/admin 0.14.1-beta → 0.16.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 +60 -0
- package/README.md +39 -36
- package/dist/client.js +34 -19
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +29 -5
- package/dist/index.d.ts +2 -2
- package/dist/management.d.ts +21 -24
- package/dist/management.js +18 -19
- package/package.json +4 -8
- package/dist/project.d.ts +0 -7
- package/dist/project.js +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,65 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.16.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 35e29b7: **Environments replace sandboxes and vaults (protocol 11). This is a fresh start: upgrading deletes your sandboxes, their disks and every vault except the model's, and closes every open session (its history stays readable).** List what you have before upgrading; see "Environments replace sandboxes and vaults" in MIGRATION.md.
|
|
8
|
+
|
|
9
|
+
An Environment is where sessions run: one sandbox (kind `virtual`, `pod` or `none`) with a recipe that can change, and one vault of secrets for its shell, MCP servers and HTTP tools. The app decides who uses which Environment; the Runtime keeps it by id and holds its lifecycle.
|
|
10
|
+
|
|
11
|
+
- `@nylorun/core`: protocol 11 (the Host accepts 11 only; older clients get `426`), required feature `environments`. `PutEnvironmentRequestSchema`, `EnvironmentViewSchema` (`recipe`, `version`, `appliedVersion`, `ownerUserId`, `lastUsedAt`), `PutEnvironmentSecretRequestSchema`, `EnvironmentSecretViewSchema`, `ENVIRONMENT_EVENT_TYPES`, `TenantEnvironmentsConfigSchema`, `environmentGranted`. `PutSessionRequest.environment` replaces `sandbox`, `vaultIds` and `credentialSelections`; `SessionView.environment` replaces the session's sandbox and vault fields. Error codes `environment_busy`, `environment_unavailable`, `environment_lost`, `environment_not_granted`, `environment_owner_mismatch` and `session_closed` (the `sandbox_*` codes and `sandbox_expired` are gone); session events `environment.state`, `environment.exec` and `environment.attached`; scope `environments:write`. Credential coverage takes `environmentId` and answers `covered` or `missing`; the MCP preview takes `environmentId`. The vault Management schemas are removed.
|
|
12
|
+
- `@nylorun/runtime`: `/v1/environments/{id}` replaces `/v1/sandboxes/{id}`: `PUT` creates, finds or changes one (`kind` and `storage` fixed; a recipe change bumps `version`; a pod gets a new image or resources at its next start from stopped, a new allowlist within seconds), with list by label, events (`nylorun.environment-event/1`), stop, reset and delete. Each Environment owns one vault: `PUT|GET|DELETE /v1/environments/{id}/secrets/{name}` on the Runtime API, write-only, with a second credential for a host or URL refused at the write (`409 credential_conflict`). An optional owner guard (`ownerUserId`) is checked when a session opens and at every turn start. `lifecycle.deleteAfter` deletes an Environment unused that long; TTL and `onExpiry` are gone. Kind `none` holds secrets for MCP-only agents. `/v1/tenant/vaults`, user and installation vaults, the Tenant's default sandbox, inline sandboxes and `{ session }` sharing are removed. The Tenant setting is `environments.config` (`limits.environments`). Identity files grant `environments:` (an old `sandboxes:` key, or `sandboxes:write`, stops the Runtime with a message naming the new key). Migration `0020_environments`.
|
|
13
|
+
- `@nylorun/harness`: the Harness API claims `environment.state` and `environment.exec`, and its workspace fields name `environmentId`.
|
|
14
|
+
- `@nylorun/agents`: `client.environments` (`put`, `get`, `list`, `page`, `stop`, `reset`, `delete`, `events`, `secrets.put|list|get|delete`, `forSession`) replaces `client.sandboxes`; `createSession({ environment })`; `sessions.page({ environmentId })` filters by Environment. The AG-UI handler's session options take `environment`.
|
|
15
|
+
- `@nylorun/admin`: `admin.coverage({ agentId, environmentId })` replaces `admin.vaults`; `admin.mcp.preview({ url, environmentId })`.
|
|
16
|
+
- `@nylorun/studio`: Environments replace Sandboxes, with a create form, stop, reset, delete and their secrets; the Credentials forms write an Environment's secrets; New session picks an Environment and shows its coverage.
|
|
17
|
+
- `nylorun`: `nylorun sandbox ls|rm` list and delete Environments; `nylorun mcp inspect --environment <id>` replaces `--vault`; `nylo reset --environments` replaces `--sandboxes`; `nylo doctor sandbox` reports the Environment limits.
|
|
18
|
+
|
|
19
|
+
- 6061a3a: **Tool approvals are the Tenant's tool policy (R5 step 2).** An agent's manifest used to say which tool calls wait for a person, and only the Runtime's own harness asked; a harness built from the Harness API could skip it. Now the operator sets one tool policy for every agent and every harness, and the Runtime enforces it before anything is sent.
|
|
20
|
+
|
|
21
|
+
- **`GET`/`PUT /v1/tenant/tool-policy`** (the Management API; `admin.toolPolicy.get()`/`.put({ rules })`): rules `{ effect: "allow" | "ask" | "deny", tool?, server?, kind?, agent?, when?, reason? }`. A rule matches a call when every selector it sets matches (`tool` and `server` take `*` globs; `when` tests input fields by dotted path with `equals`, `in`, `gt`, `gte`, `lt`, `lte` or `matches`). The strictest matching rule decides; a call no rule matches runs.
|
|
22
|
+
- **Enforced for every harness.** Core decides an MCP or HTTP tool call as it journals it. `deny` fails it to the model as `tool.denied`, unsent. `ask` holds the call (`held` at `/calls/tool`) and pauses the turn with one `approval` interaction per held call (`turn.paused`, with the tool, its input and the reason). `approve` sends that exact call, or fails it as `tool.denied`. The Tool Gate runs only calls the journal holds running, so a held or refused call cannot run. Nothing holds a process while it waits: an approval survives a restart. A flow's HTTP stages are decided the same way.
|
|
23
|
+
- **`approval` leaves the manifest.** `PUT /v1/agents/:id` and `saveAgent()` refuse a definition that sets `approval` on an HTTP tool, an MCP server or an MCP tool's settings; `http({ approval })` and `.mcp({ … approval })` throw; a turn manifest can no longer add one. The engine never asks for an HTTP or MCP tool's approval itself. A session pinned to a manifest saved with `approval: "always"` keeps it, as an ask.
|
|
24
|
+
- `@nylorun/studio`: a paused session shows an approval card for each held call, with its tool, why it is held and its input, and **Approve** / **Deny**.
|
|
25
|
+
- Migration: move each `approval: "always"` to an `ask` rule (see MIGRATION.md).
|
|
26
|
+
|
|
27
|
+
### Patch Changes
|
|
28
|
+
|
|
29
|
+
- Pin core to the tested release.
|
|
30
|
+
- Updated dependencies [17a97e9]
|
|
31
|
+
- Updated dependencies [b6214d9]
|
|
32
|
+
- Updated dependencies [e917bd6]
|
|
33
|
+
- Updated dependencies [5165451]
|
|
34
|
+
- Updated dependencies [35e29b7]
|
|
35
|
+
- Updated dependencies [e917bd6]
|
|
36
|
+
- Updated dependencies [a0cbca1]
|
|
37
|
+
- Updated dependencies [3013501]
|
|
38
|
+
- Updated dependencies [6061a3a]
|
|
39
|
+
- Updated dependencies [7d496e4]
|
|
40
|
+
- Updated dependencies [81c783e]
|
|
41
|
+
- Updated dependencies [7800358]
|
|
42
|
+
- @nylorun/core@0.20.0-beta
|
|
43
|
+
|
|
44
|
+
## 0.15.0-beta
|
|
45
|
+
|
|
46
|
+
### Major Changes
|
|
47
|
+
|
|
48
|
+
- 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.
|
|
49
|
+
|
|
50
|
+
- `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.
|
|
51
|
+
- **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.
|
|
52
|
+
- **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.
|
|
53
|
+
- `@nylorun/create-agent`: `compatibility.json` no longer pins `@nylorun/cli`; the examples run `nylo` from their `nylorun` devDependency.
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- 554df94: **Fixes for the one client layer.**
|
|
58
|
+
|
|
59
|
+
- `@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).
|
|
60
|
+
- `@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.
|
|
61
|
+
- `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.
|
|
62
|
+
|
|
3
63
|
## 0.14.1-beta
|
|
4
64
|
|
|
5
65
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# @nylorun/admin
|
|
2
2
|
|
|
3
3
|
The Management API client (protocol 8): the Tenant's status, seed and reset, its
|
|
4
|
-
models,
|
|
4
|
+
models, credential coverage, MCP server previews, signing keys, settings and application keys, through
|
|
5
5
|
`/v1/tenant/*` with a **management key**. It also holds the two helpers over the
|
|
6
6
|
admin key that Studio needs. Depends only on `@nylorun/core`.
|
|
7
|
-
Requires Node 24+. Vocabulary: [runtime/src/CONTEXT.md](
|
|
7
|
+
Requires Node 24+. Vocabulary: [runtime/server/src/CONTEXT.md](../../runtime/server/src/CONTEXT.md).
|
|
8
8
|
|
|
9
9
|
Developer applications do **not** depend on this package: they use the Runtime
|
|
10
10
|
API through `@nylorun/agents`. Operators' clients do: the CLI, Studio, CI and
|
|
@@ -46,16 +46,15 @@ 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
|
-
|
|
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
|
|
|
55
54
|
Management keys are issued on the Tenant's machine only:
|
|
56
55
|
`npx nylorun key put <id> --management` on a local Tenant, or
|
|
57
56
|
`nylorun-operate keys put <id> --role management` inside the runtime container
|
|
58
|
-
([SELF_HOSTING.md](
|
|
57
|
+
([SELF_HOSTING.md](../../guides/SELF_HOSTING.md#keys)). No API call creates one.
|
|
59
58
|
|
|
60
59
|
## The groups
|
|
61
60
|
|
|
@@ -64,8 +63,9 @@ Management keys are issued on the Tenant's machine only:
|
|
|
64
63
|
| `admin.tenant` | `status()`, `seed(request)`, `reset(request)` | `GET /v1/tenant`, `PUT /v1/tenant/config/seed`, `POST /v1/tenant/reset` |
|
|
65
64
|
| `admin.keys` | `list()`, `put(id)`, `delete(id)` | `/v1/tenant/keys…` |
|
|
66
65
|
| `admin.models` | `catalog()`, `providers()`, `get()`, `put(request)`, `select(request)`, `usage(query)`, `budgets.get()`, `budgets.put(request)` | `/v1/tenant/models`, `/providers`, `/model`, `/model/selection`, `/usage`, `/budgets` |
|
|
67
|
-
| `admin.
|
|
68
|
-
| `admin.mcp` | `preview({ url, type?, name?,
|
|
66
|
+
| `admin.coverage` | called directly: `admin.coverage({ agentId, environmentId? })` | `POST /v1/tenant/credential-coverage` |
|
|
67
|
+
| `admin.mcp` | `preview({ url, type?, name?, environmentId? })` | `POST /v1/tenant/mcp/preview` |
|
|
68
|
+
| `admin.toolPolicy` | `get()`, `put({ rules })`: which MCP and HTTP tool calls run, wait for a person (`ask`) or are refused (`deny`) | `/v1/tenant/tool-policy` |
|
|
69
69
|
| `admin.signingKeys` | `list()`, `rotate({ force? })`, `revoke(kid)` | `/v1/tenant/signing-keys…` |
|
|
70
70
|
| `admin.settings` | `sandbox.get()`, `sandbox.put(request)`, `artifacts.get()`, `artifacts.put(request)` | `/v1/tenant/sandbox`, `/v1/tenant/artifacts` |
|
|
71
71
|
|
|
@@ -84,49 +84,52 @@ await admin.keys.list(); // [{ id, role, createdAt }]
|
|
|
84
84
|
await admin.keys.delete("backend"); // true when it existed
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
|
|
88
|
-
|
|
87
|
+
Credentials for MCP servers, HTTP tools and skills are not the Management
|
|
88
|
+
API's: each Environment has one vault, whose secrets the app writes on the
|
|
89
|
+
Runtime API (`client.environments.secrets.put` in
|
|
90
|
+
[`@nylorun/agents`](../agents/README.md), `PUT /v1/environments/{id}/secrets/{name}`)
|
|
91
|
+
and never reads back. See "MCP servers and HTTP tools" in
|
|
92
|
+
[DEPLOYMENT.md](../../guides/DEPLOYMENT.md#mcp-servers-and-http-tools), with
|
|
93
|
+
gateway recipes.
|
|
94
|
+
|
|
95
|
+
`admin.coverage` says what a session of a saved agent would send for each of
|
|
96
|
+
its MCP servers and HTTP tool credentials in the Environment it will name,
|
|
97
|
+
before any session starts: `covered` (with the secret's Environment, name and
|
|
98
|
+
`via`) or `missing`. Without `environmentId` every entry is `missing`. It reads
|
|
99
|
+
no secret and calls no server (Host feature `credential-coverage`).
|
|
89
100
|
|
|
90
101
|
```ts
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
idempotencyKey: "linear",
|
|
95
|
-
auth: { type: "bearer", url: "https://mcp.linear.app/mcp", token: process.env.LINEAR_TOKEN! },
|
|
96
|
-
});
|
|
102
|
+
const coverage = await admin.coverage({ agentId: "triage", environmentId: "projects/acme" });
|
|
103
|
+
if (!coverage.complete)
|
|
104
|
+
for (const entry of coverage.entries) if (entry.status !== "covered") console.log(entry.name, entry.message);
|
|
97
105
|
```
|
|
98
106
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
"MCP servers and HTTP tools" in
|
|
107
|
-
[DEPLOYMENT.md](../DEPLOYMENT.md#mcp-servers-and-http-tools), with gateway
|
|
108
|
-
recipes.
|
|
109
|
-
|
|
110
|
-
`admin.mcp.preview` shows what that server offers with that credential, before
|
|
111
|
-
an agent names it: the Runtime connects, lists the tools within 15 s and calls
|
|
112
|
-
none. Each tool has the name the model would call it (made with `name`,
|
|
113
|
-
default from the URL's host), its annotations and its input schema's size. A
|
|
114
|
-
server that answers `401` comes back with `authRequired` and its RFC 9728
|
|
115
|
-
protected-resource metadata; one that cannot be listed rejects with
|
|
116
|
-
`mcp_preview_failed` (`details.failure`).
|
|
107
|
+
`admin.mcp.preview` shows what a server offers with an Environment's credential
|
|
108
|
+
for its URL (none without `environmentId`), before an agent names it: the
|
|
109
|
+
Runtime connects, lists the tools within 15 s and calls none. Each tool has the
|
|
110
|
+
name the model would call it (made with `name`, default from the URL's host),
|
|
111
|
+
its annotations and its input schema's size. A server that answers `401` comes
|
|
112
|
+
back with `authRequired` and its RFC 9728 protected-resource metadata; one that
|
|
113
|
+
cannot be listed rejects with `mcp_preview_failed` (`details.failure`).
|
|
117
114
|
|
|
118
115
|
```ts
|
|
119
|
-
const preview = await admin.mcp.preview({ url: "https://mcp.linear.app/mcp", name: "linear",
|
|
116
|
+
const preview = await admin.mcp.preview({ url: "https://mcp.linear.app/mcp", name: "linear", environmentId: "projects/acme" });
|
|
120
117
|
for (const tool of preview.tools) console.log(tool.modelName, tool.schemaBytes);
|
|
121
118
|
if (preview.authRequired) console.log("needs a sign-in:", preview.authRequired.resourceMetadata);
|
|
122
119
|
```
|
|
123
120
|
|
|
121
|
+
`admin.settings.sandbox` reads and replaces the Tenant's Environment settings
|
|
122
|
+
(Tenant setting `environments.config`): `limits` (`network`, `resources`,
|
|
123
|
+
`defaultResources`, `idle`, `environments`), the pods' `lifecycle.stopGrace` and
|
|
124
|
+
`placement`. `admin.tenant.reset({ scope })` takes `sessions`, `environments`
|
|
125
|
+
or `all`.
|
|
126
|
+
|
|
124
127
|
## In a browser
|
|
125
128
|
|
|
126
129
|
`@nylorun/admin/client` exports `createManagementClient({ url, key?, fetch?,
|
|
127
130
|
headers? })` and `ManagementClient`, with the same groups and no Node module.
|
|
128
131
|
It is for a browser app behind its own server that adds the management key, as
|
|
129
|
-
Studio
|
|
132
|
+
Studio is: omit `key`, and point `url` at that server. Never
|
|
130
133
|
send a management key from a browser: the Runtime refuses any key sent with an
|
|
131
134
|
`Origin` (`403 origin_rejected`).
|
|
132
135
|
|
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
|
|
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
|
-
|
|
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
|
|
39
|
-
* Tenant named by `options.tenant
|
|
40
|
-
|
|
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
|
|
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
|
-
|
|
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(
|
|
148
|
-
return { url: optionUrl.replace(/\/$/, ""), key: optionKey, source: "options", ...(
|
|
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(
|
|
156
|
-
return { url: envUrl.replace(/\/$/, ""), key: envKey, source: "environment", ...(
|
|
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
|
|
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
|
|
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
|
-
|
|
21
|
-
|
|
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
|
-
|
|
45
|
+
});
|
|
46
|
+
return new AdminError(statusCode(status), studioMessage(body) ?? `${what} (${status})`, {
|
|
47
|
+
status,
|
|
48
|
+
details: body,
|
|
49
|
+
});
|
|
26
50
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -8,10 +8,10 @@ export type { ErrorCode };
|
|
|
8
8
|
export { AdminError };
|
|
9
9
|
export { deriveStudioToken, tenantHostRoot };
|
|
10
10
|
export { mintStudioLoginToken } from "./studio-login.js";
|
|
11
|
-
export { ManagementClient, createManagementClient, type ManagementClientOptions, type ManagementKeys, type ManagementMcp, type ManagementModels, type ManagementSettings, type ManagementSigningKeys, type ManagementTenant,
|
|
11
|
+
export { ManagementClient, createManagementClient, type ManagementClientOptions, type ManagementKeys, type ManagementMcp, type ManagementModels, type ManagementSettings, type ManagementSigningKeys, type ManagementTenant, } from "./management.js";
|
|
12
12
|
/**
|
|
13
13
|
* The Management API client for the installation (`/v1/tenant/*`): `tenant`, `keys`
|
|
14
|
-
* (application keys), `models`, `
|
|
14
|
+
* (application keys), `models`, `coverage`, `mcp`, `signingKeys` and `settings`, with a management key.
|
|
15
15
|
* `source` says where the connection came from.
|
|
16
16
|
*/
|
|
17
17
|
export type Admin = AdminClient;
|
package/dist/management.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type CredentialCoverage, type CredentialCoverageRequest, type HostModelCatalog, type HostModelView, type ListProvidersResponse, type McpPreview, type McpPreviewRequest, type ModelCallExportPage, type ModelBudgets, type ModelUsageQuery, type ModelUsageTotals, type OperatorKey, type PutHostModelRequest, type PutModelBudgetsRequest, type PutToolPolicyRequest, type PutOperatorKeyResponse, type PutTenantArtifactsRequest, type PutTenantEnvironmentsRequest, type ResetTenantRequest, type ResetTenantResponse, type SeedTenantConfigRequest, type SeedTenantConfigResponse, type SelectHostModelRequest, type SigningKeyView, type TenantArtifactsView, type TenantSandboxView, type TenantStatus, type ToolPolicy } from "@nylorun/core/contracts";
|
|
2
2
|
export interface ManagementClientOptions {
|
|
3
3
|
/** The Tenant's URL, or a proxy in front of it. */
|
|
4
4
|
url: string;
|
|
@@ -18,7 +18,7 @@ export interface ManagementTenant {
|
|
|
18
18
|
status(): Promise<TenantStatus>;
|
|
19
19
|
/** Seeds the Tenant's configuration where it is unset (`nylorun start` does this). */
|
|
20
20
|
seed(request: Body<SeedTenantConfigRequest>): Promise<SeedTenantConfigResponse>;
|
|
21
|
-
/** Resets the Tenant's sessions,
|
|
21
|
+
/** Resets the Tenant's sessions, Environments or both. */
|
|
22
22
|
reset(request: Body<ResetTenantRequest>): Promise<ResetTenantResponse>;
|
|
23
23
|
}
|
|
24
24
|
/** The Tenant's keys: application keys are managed here; management keys only on its machine. */
|
|
@@ -58,29 +58,11 @@ export interface ManagementModels {
|
|
|
58
58
|
put(request: Body<PutModelBudgetsRequest>): Promise<ModelBudgets>;
|
|
59
59
|
};
|
|
60
60
|
}
|
|
61
|
-
export interface ManagementVaults {
|
|
62
|
-
create(request: Body<CreateVaultRequest>): Promise<VaultInfo>;
|
|
63
|
-
/** The installation vaults, after `ownerUserId`'s when it is given. */
|
|
64
|
-
list(ownerUserId?: string): Promise<VaultInfo[]>;
|
|
65
|
-
get(vaultId: string): Promise<VaultInfo>;
|
|
66
|
-
delete(vaultId: string): Promise<{
|
|
67
|
-
id: string;
|
|
68
|
-
}>;
|
|
69
|
-
readonly credentials: {
|
|
70
|
-
create(vaultId: string, request: Body<CreateCredentialRequest>): Promise<CredentialInfo>;
|
|
71
|
-
list(vaultId: string): Promise<CredentialInfo[]>;
|
|
72
|
-
get(vaultId: string, credentialId: string): Promise<CredentialInfo>;
|
|
73
|
-
/** Rotates the credential's secret. */
|
|
74
|
-
rotate(vaultId: string, credentialId: string, request: Body<RotateCredentialRequest>): Promise<CredentialInfo>;
|
|
75
|
-
delete(vaultId: string, credentialId: string): Promise<{
|
|
76
|
-
id: string;
|
|
77
|
-
}>;
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
61
|
export interface ManagementMcp {
|
|
81
62
|
/**
|
|
82
63
|
* A remote MCP server's tools before an agent names it (R2b C12): the Runtime connects with
|
|
83
|
-
* the
|
|
64
|
+
* the credential for `url` in the vault of `environmentId` (none without one), lists the
|
|
65
|
+
* tools and closes; it never calls
|
|
84
66
|
* one. Each tool has the name the model would call it, made with `name` (default: from the
|
|
85
67
|
* URL's host). A server that needs a person's sign-in answers `authRequired`, with its
|
|
86
68
|
* protected-resource metadata. A server that cannot be listed rejects with
|
|
@@ -103,7 +85,8 @@ export interface ManagementSigningKeys {
|
|
|
103
85
|
export interface ManagementSettings {
|
|
104
86
|
readonly sandbox: {
|
|
105
87
|
get(): Promise<TenantSandboxView>;
|
|
106
|
-
|
|
88
|
+
/** The Tenant's Environment settings: limits, the pods' stop grace and placement. */
|
|
89
|
+
put(request: Body<PutTenantEnvironmentsRequest>): Promise<TenantSandboxView>;
|
|
107
90
|
};
|
|
108
91
|
readonly artifacts: {
|
|
109
92
|
get(): Promise<TenantArtifactsView>;
|
|
@@ -117,8 +100,22 @@ export declare class ManagementClient {
|
|
|
117
100
|
readonly tenant: ManagementTenant;
|
|
118
101
|
readonly keys: ManagementKeys;
|
|
119
102
|
readonly models: ManagementModels;
|
|
120
|
-
|
|
103
|
+
/**
|
|
104
|
+
* Which secret of Environment `environmentId` each remote MCP server and HTTP tool of the
|
|
105
|
+
* saved agent `agentId` would get in a session that names it (`covered`), or none
|
|
106
|
+
* (`missing`). Host feature `credential-coverage`.
|
|
107
|
+
*/
|
|
108
|
+
readonly coverage: (request: Body<CredentialCoverageRequest>) => Promise<CredentialCoverage>;
|
|
121
109
|
readonly mcp: ManagementMcp;
|
|
110
|
+
/**
|
|
111
|
+
* The rules the Tool Gate applies to every MCP and HTTP tool call (R5 step 2): `deny` refuses
|
|
112
|
+
* a call, `ask` holds it until a person approves it on the session, `allow` runs it.
|
|
113
|
+
*/
|
|
114
|
+
readonly toolPolicy: {
|
|
115
|
+
get(): Promise<ToolPolicy>;
|
|
116
|
+
/** Replaces every rule; an empty list allows every call. */
|
|
117
|
+
put(request: Body<PutToolPolicyRequest>): Promise<ToolPolicy>;
|
|
118
|
+
};
|
|
122
119
|
readonly signingKeys: ManagementSigningKeys;
|
|
123
120
|
readonly settings: ManagementSettings;
|
|
124
121
|
constructor(options: ManagementClientOptions);
|
package/dist/management.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Management API client (`/v1/tenant/*`, protocol 8): the Tenant's settings, models,
|
|
3
|
-
*
|
|
3
|
+
* credential coverage, MCP server previews, signing keys and application keys, with a
|
|
4
|
+
* management key. An Environment's secrets are written on the Runtime API
|
|
5
|
+
* (`@nylorun/agents`, `client.environments.secrets`). It imports nothing from
|
|
4
6
|
* Node, so a browser app that reaches the Runtime through its own proxy (Studio) uses it too:
|
|
5
7
|
* `@nylorun/admin/client`. `createAdmin()` in the package's main entry finds the URL and key.
|
|
6
8
|
*/
|
|
@@ -18,8 +20,18 @@ export class ManagementClient {
|
|
|
18
20
|
tenant;
|
|
19
21
|
keys;
|
|
20
22
|
models;
|
|
21
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Which secret of Environment `environmentId` each remote MCP server and HTTP tool of the
|
|
25
|
+
* saved agent `agentId` would get in a session that names it (`covered`), or none
|
|
26
|
+
* (`missing`). Host feature `credential-coverage`.
|
|
27
|
+
*/
|
|
28
|
+
coverage;
|
|
22
29
|
mcp;
|
|
30
|
+
/**
|
|
31
|
+
* The rules the Tool Gate applies to every MCP and HTTP tool call (R5 step 2): `deny` refuses
|
|
32
|
+
* a call, `ask` holds it until a person approves it on the session, `allow` runs it.
|
|
33
|
+
*/
|
|
34
|
+
toolPolicy;
|
|
23
35
|
signingKeys;
|
|
24
36
|
settings;
|
|
25
37
|
#key;
|
|
@@ -67,23 +79,10 @@ export class ManagementClient {
|
|
|
67
79
|
put: (request) => call("PUT", "/v1/tenant/budgets", withId(request)),
|
|
68
80
|
},
|
|
69
81
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
list: async (ownerUserId) => (await call("GET", ownerUserId === undefined
|
|
75
|
-
? "/v1/tenant/vaults"
|
|
76
|
-
: `/v1/tenant/vaults?ownerUserId=${segment(ownerUserId)}`)).vaults,
|
|
77
|
-
get: (vaultId) => call("GET", vault(vaultId)),
|
|
78
|
-
delete: (vaultId) => call("DELETE", vault(vaultId)),
|
|
79
|
-
credentials: {
|
|
80
|
-
create: (vaultId, request) => call("POST", `${vault(vaultId)}/credentials`, withId(request)),
|
|
81
|
-
list: async (vaultId) => (await call("GET", `${vault(vaultId)}/credentials`))
|
|
82
|
-
.credentials,
|
|
83
|
-
get: (vaultId, credentialId) => call("GET", credential(vaultId, credentialId)),
|
|
84
|
-
rotate: (vaultId, credentialId, request) => call("POST", credential(vaultId, credentialId), withId(request)),
|
|
85
|
-
delete: (vaultId, credentialId) => call("DELETE", credential(vaultId, credentialId)),
|
|
86
|
-
},
|
|
82
|
+
this.coverage = (request) => call("POST", "/v1/tenant/credential-coverage", withId(request));
|
|
83
|
+
this.toolPolicy = {
|
|
84
|
+
get: () => call("GET", "/v1/tenant/tool-policy"),
|
|
85
|
+
put: (request) => call("PUT", "/v1/tenant/tool-policy", withId(request)),
|
|
87
86
|
};
|
|
88
87
|
this.mcp = {
|
|
89
88
|
preview: (request) => call("POST", "/v1/tenant/mcp/preview", request),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.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,13 +28,13 @@
|
|
|
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.
|
|
31
|
+
"@nylorun/core": "0.20.0-beta"
|
|
36
32
|
},
|
|
37
33
|
"peerDependencies": {
|
|
38
34
|
"zod": "^4.6.5"
|
|
39
35
|
},
|
|
40
36
|
"devDependencies": {
|
|
41
|
-
"@types/node": "^
|
|
37
|
+
"@types/node": "^26.6.4",
|
|
42
38
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
43
39
|
"vitest": "^5.0.2"
|
|
44
40
|
},
|
|
@@ -48,7 +44,7 @@
|
|
|
48
44
|
"repository": {
|
|
49
45
|
"type": "git",
|
|
50
46
|
"url": "git+https://github.com/nylorun/agents.git",
|
|
51
|
-
"directory": "admin"
|
|
47
|
+
"directory": "sdks/admin"
|
|
52
48
|
},
|
|
53
49
|
"publishConfig": {
|
|
54
50
|
"access": "public",
|
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";
|