@nylorun/admin 0.12.0-beta → 0.14.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 +56 -0
- package/README.md +38 -6
- package/dist/client.d.ts +2 -2
- package/dist/client.js +62 -92
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +14 -0
- package/dist/index.d.ts +2 -2
- package/dist/management.d.ts +13 -3
- package/dist/management.js +12 -28
- package/dist/project.d.ts +7 -0
- package/dist/project.js +7 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.14.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7780b2f: **One client and connection layer.** The Project link and credentials are read one way, and every Runtime client shares one `/health` probe.
|
|
8
|
+
|
|
9
|
+
- `@nylorun/core`: `@nylorun/core/project` (Node only, the one Core subpath that imports Node modules) reads the Nylorun home, a local Tenant's Host root (`tenantHostRoot`), the Project root (`findProjectRoot`) and the Project link and credentials (`findLinkedProject`, `readProjectLink`, `readCredentialsFile`), validated with `ProjectLinkFileSchema` and `ProjectCredentialsFileSchema`; a broken or newer file throws `ProjectFileError`. `@nylorun/core/transport` (browser-safe) holds the `/health` compatibility probe (`checkHealth`), `parseProtocolRange` (on `ProtocolRangeSchema`, ignoring fields a newer Host adds), `describeIncompatibility`, `requestHeaders` and `readBody`.
|
|
10
|
+
- `@nylorun/agents`: `resolveConnection` and `createClient()` find the Project as every reader does: the nearest directory with `.nylorun/` from `cwd` upwards, never the home directory or above it (they used to walk to the filesystem root, and past a `.nylorun/` without a link). A link without `credentials.json`, or a link or credentials file that does not validate, is now `connection_missing` naming the file and `npx nylorun start`, instead of a raw file-system or parse error. `@nylorun/agents/client` loads the link reader only when `createClient()` resolves a connection, so it imports no Node module. The root entry re-exports `checkHealth`, `describeIncompatibility` and `parseProtocolRange`.
|
|
11
|
+
- `@nylorun/admin`: `createAdmin` reads the Project link with the same reader. A link that does not validate is now refused like one from an older nylorun (when nothing else names the Host root), and a linked Project's `credentials.json` that does not validate is `connection_missing` instead of being skipped. `@nylorun/admin/project` re-exports `@nylorun/core/project` for tools that depend on this package. The `/health` check and request headers come from `@nylorun/core/transport`.
|
|
12
|
+
- `nylorun`: reads the Project link and credentials with `@nylorun/core/project`; a credentials file whose keys are not 64 hex characters is replaced by `start`, as an unreadable one was. No command changes.
|
|
13
|
+
- `@nylorun/cli`: `nylo` reads the Project root, link and credentials through `@nylorun/admin/project` instead of its own copies, with the same messages. No command changes.
|
|
14
|
+
- `@nylorun/studio`: the server's Runtime compatibility probe is `checkHealth` from `@nylorun/agents`.
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Pin core to the tested release.
|
|
19
|
+
- Updated dependencies [7780b2f]
|
|
20
|
+
- Updated dependencies [070674d]
|
|
21
|
+
- @nylorun/core@0.18.0-beta
|
|
22
|
+
|
|
23
|
+
## 0.13.0-beta
|
|
24
|
+
|
|
25
|
+
### Major Changes
|
|
26
|
+
|
|
27
|
+
- 50e2f7e: **Protocol 10: MCP credentials come from a session's vaults only.** Nylorun no longer signs the installation in to MCP servers with OAuth and no longer asks a credential resolver. Upgrade every package together; MIGRATION.md has the details.
|
|
28
|
+
|
|
29
|
+
- **Breaking (`@nylorun/runtime`): the MCP OAuth connect is gone.** `POST /v1/tenant/vaults/{vaultId}/oauth/start` and `GET /v1/oauth/callback` answer `404`. The vault credential type `oauth` and its refresh are gone: a credential is a `bearer` token or a `headers` map bound to a URL. Migration `0016_mcp_oauth_removed` drops the table of pending connects and deletes every `oauth` credential, writing one audit row each (actor `migration`); the Runtime logs `oauth_credential_removed` once for each, naming its vault, id and URL.
|
|
30
|
+
- **Breaking (`@nylorun/runtime`): the credential resolver is gone.** The gateway no longer asks the operator's resolver for a person's credential when the session's vaults hold none. A process that still sets a `NYLORUN_RESOLVER_*` variable logs `resolver_removed` and ignores it. Keep a person's own keys in their user vault and attach it to their sessions (`vaultIds`). `TenantConfig.resolver`, `TenantConfig.publicUrl`, `TenantConfig.vaultFetch`, `startEphemeralRuntime({ resolver })`, the `ResolverConfig` export and `VaultService`'s `fetch` option are removed; `NYLORUN_PUBLIC_URL` still sets the protected resource metadata's `resource`.
|
|
31
|
+
- **Breaking (`@nylorun/core`):** `PROTOCOL_VERSION` is 10 and `HOST_PROTOCOL` 4–10. `StartOAuthRequest`, `StartOAuthResponse`, the `oauth` variants of `CreateCredentialRequest` and `RotateCredentialRequest`, `oauth` in `CredentialInfo.type` and `CredentialInfo.expiresAt` are removed, and `ERROR_CODES` drops `oauth_client_required`, `oauth_state_invalid` and `oauth_failed`. `@nylorun/agents` and `@nylorun/cli` send protocol 10.
|
|
32
|
+
- **Breaking (`@nylorun/admin`):** `admin.vaults` loses its OAuth start method.
|
|
33
|
+
- **Breaking (`nylorun`):** the `connect` subcommand of `nylorun mcp` is removed (`nylorun mcp inspect` lists a server's tools instead), and the gateway's Compose service no longer passes the `NYLORUN_RESOLVER_*` variables.
|
|
34
|
+
- `@nylorun/studio`: the Credentials page loses the OAuth type, the Expires column and the OAuth connect hint.
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- da93711: **Preview an MCP server's tools** (R2b C12). MIGRATION.md (protocol 10, "Previewing a server's tools") has the details.
|
|
39
|
+
|
|
40
|
+
- `@nylorun/core`: `McpPreviewRequestSchema` and `McpPreviewSchema` (`McpPreviewTool`), and the error code `mcp_preview_failed`.
|
|
41
|
+
- `@nylorun/runtime`: `POST /v1/tenant/mcp/preview` (the Management API) connects to a remote MCP server with the installation vault's credential for its URL (headers and `via`, no identity header), under the Host's address policy and within 15 s, and answers its server info, instructions, tools (model names, annotations, schema sizes) and renames; a `401` is `authRequired`, with the server's RFC 9728 protected-resource metadata. It runs in the keys service (`Keys.previewMcp`), which holds the plaintext, and calls no tool. Both OpenAPI documents list it.
|
|
42
|
+
- `@nylorun/admin`: `admin.mcp.preview({ url, type?, name?, vaultId? })`.
|
|
43
|
+
- `nylorun`: `nylorun mcp inspect <url> [--server <name>] [--vault <id>] [--sse] [--json]` prints the running Tenant's preview: a table of tools, the renames, or that the server needs a person's sign-in. Its `connect` subcommand still says it was removed, and now points to `inspect`.
|
|
44
|
+
- `@nylorun/studio`: **Preview tools** on each credential of the Credentials page lists the tools behind its URL.
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- fed5e58: **Docs: reaching a person's accounts** (R2b C5). The READMEs describe MCP credentials as protocol 10 has them (a `bearer` token or a `headers` map per URL, with `via` and an identity header for an MCP gateway), and point to "MCP servers and HTTP tools" in DEPLOYMENT.md: the operator's flow from credential to preview, tool settings, deferral, stored results and the error codes a model sees, with gateway recipes for Arcade, ToolHive, Obot and Nylorun Cloud and the proxy pattern for gateways that mint per person. `HttpToolTarget.credential`'s doc (`@nylorun/core`) no longer names the removed credential resolver.
|
|
49
|
+
- Pin core to the tested release.
|
|
50
|
+
- Updated dependencies [50e2f7e]
|
|
51
|
+
- Updated dependencies [e0e39ff]
|
|
52
|
+
- Updated dependencies [fed5e58]
|
|
53
|
+
- Updated dependencies [18f9a2f]
|
|
54
|
+
- Updated dependencies [da93711]
|
|
55
|
+
- Updated dependencies [90a817d]
|
|
56
|
+
- Updated dependencies [b8d10cb]
|
|
57
|
+
- @nylorun/core@0.17.0-beta
|
|
58
|
+
|
|
3
59
|
## 0.12.0-beta
|
|
4
60
|
|
|
5
61
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @nylorun/admin
|
|
2
2
|
|
|
3
3
|
The Management API client (protocol 8): the Tenant's status, seed and reset, its
|
|
4
|
-
models, vaults, signing keys, settings and application keys, through
|
|
4
|
+
models, vaults, 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
7
|
Requires Node 24+. Vocabulary: [runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
|
|
@@ -34,15 +34,21 @@ order, and `admin.source` says which one it used (`options`, `environment` or
|
|
|
34
34
|
3. The local Host. The URL comes from `host.json` in the Host root:
|
|
35
35
|
`options.home`, else `NYLORUN_HOME`, else `~/.nylorun/tenants/<tenant>/` for
|
|
36
36
|
the local Tenant named by `options.tenant`, `NYLORUN_TENANT` or the Project
|
|
37
|
-
link (`.nylorun/link.json`, format 3,
|
|
37
|
+
link (`.nylorun/link.json`, format 3, in the nearest directory with
|
|
38
|
+
`.nylorun/` from `options.cwd` upwards, below the home directory). The
|
|
38
39
|
key is the `managementKey` of the linked Project's `.nylorun/credentials.json`,
|
|
39
40
|
else of the Host root's `project-credentials.json`, else of its
|
|
40
41
|
`cli-credentials.json`. `nylorun start` writes them (the keys
|
|
41
42
|
`project-management` and `cli-management`). On POSIX a credentials file must
|
|
42
43
|
be the user's and not group- or world-readable.
|
|
43
44
|
|
|
44
|
-
When none resolves, or the Project link is from an older nylorun
|
|
45
|
-
|
|
45
|
+
When none resolves, or the Project link is from an older nylorun or does not
|
|
46
|
+
validate (and nothing else names the Host root), or the linked Project's
|
|
47
|
+
`credentials.json` does not validate, it throws `connection_missing` and lists
|
|
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
|
|
46
52
|
Host's `/health` and throws `incompatible_host` unless the Host serves protocol
|
|
47
53
|
8 with the feature `management-api`.
|
|
48
54
|
|
|
@@ -58,7 +64,8 @@ Management keys are issued on the Tenant's machine only:
|
|
|
58
64
|
| `admin.tenant` | `status()`, `seed(request)`, `reset(request)` | `GET /v1/tenant`, `PUT /v1/tenant/config/seed`, `POST /v1/tenant/reset` |
|
|
59
65
|
| `admin.keys` | `list()`, `put(id)`, `delete(id)` | `/v1/tenant/keys…` |
|
|
60
66
|
| `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` |
|
|
61
|
-
| `admin.vaults` | `create`, `list(ownerUserId?)`, `get`, `delete`, `credentials.create`, `.list`, `.get`, `.rotate`, `.delete
|
|
67
|
+
| `admin.vaults` | `create`, `list(ownerUserId?)`, `get`, `delete`, `credentials.create`, `.list`, `.get`, `.rotate`, `.delete` | `/v1/tenant/vaults…` |
|
|
68
|
+
| `admin.mcp` | `preview({ url, type?, name?, vaultId? })` | `POST /v1/tenant/mcp/preview` |
|
|
62
69
|
| `admin.signingKeys` | `list()`, `rotate({ force? })`, `revoke(kid)` | `/v1/tenant/signing-keys…` |
|
|
63
70
|
| `admin.settings` | `sandbox.get()`, `sandbox.put(request)`, `artifacts.get()`, `artifacts.put(request)` | `/v1/tenant/sandbox`, `/v1/tenant/artifacts` |
|
|
64
71
|
|
|
@@ -89,12 +96,37 @@ await admin.vaults.credentials.create(vault.id, {
|
|
|
89
96
|
});
|
|
90
97
|
```
|
|
91
98
|
|
|
99
|
+
A credential is bound to the URL an agent names: a `bearer` token, or a
|
|
100
|
+
`headers` map (`{ type: "headers", url, headers: { "x-api-key": … } }`). Either
|
|
101
|
+
may add `via`, where the requests go instead (an MCP gateway), and
|
|
102
|
+
`identity: { header }`, which carries the session owner's subject. A person's
|
|
103
|
+
own keys go in their vault (`admin.vaults.create({ name, ownerUserId })`).
|
|
104
|
+
Listing and getting a credential return its header names, `via` and identity
|
|
105
|
+
header, never a value; `credentials.rotate` replaces the token or the map. See
|
|
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`).
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const preview = await admin.mcp.preview({ url: "https://mcp.linear.app/mcp", name: "linear", vaultId: vault.id });
|
|
120
|
+
for (const tool of preview.tools) console.log(tool.modelName, tool.schemaBytes);
|
|
121
|
+
if (preview.authRequired) console.log("needs a sign-in:", preview.authRequired.resourceMetadata);
|
|
122
|
+
```
|
|
123
|
+
|
|
92
124
|
## In a browser
|
|
93
125
|
|
|
94
126
|
`@nylorun/admin/client` exports `createManagementClient({ url, key?, fetch?,
|
|
95
127
|
headers? })` and `ManagementClient`, with the same groups and no Node module.
|
|
96
128
|
It is for a browser app behind its own server that adds the management key, as
|
|
97
|
-
Studio's
|
|
129
|
+
Studio's Credentials page is: omit `key`, and point `url` at that server. Never
|
|
98
130
|
send a management key from a browser: the Runtime refuses any key sent with an
|
|
99
131
|
`Origin` (`403 origin_rejected`).
|
|
100
132
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tenantHostRoot } from "@nylorun/core/project";
|
|
1
2
|
import { ManagementClient } from "./management.js";
|
|
2
3
|
export type AdminSource = "options" | "environment" | "local-host";
|
|
3
4
|
export interface ResolvedAdmin {
|
|
@@ -20,8 +21,7 @@ export interface AdminConnectionOptions {
|
|
|
20
21
|
/** Where to look for a Project link naming the Tenant; defaults to the working directory. */
|
|
21
22
|
cwd?: string;
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
export declare function tenantHostRoot(name: string): string;
|
|
24
|
+
export { tenantHostRoot };
|
|
25
25
|
/** Resolve the Management API connection once: options → environment → local Host. */
|
|
26
26
|
export declare function resolveAdminConnection(options?: AdminConnectionOptions): ResolvedAdmin;
|
|
27
27
|
/** What `createAdmin` returns: the Management API client, and where its connection came from. */
|
package/dist/client.js
CHANGED
|
@@ -1,65 +1,43 @@
|
|
|
1
|
-
import { readFileSync,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { AdminError } from "./errors.js";
|
|
1
|
+
import { readFileSync, statSync } from "node:fs";
|
|
2
|
+
import { join, resolve } from "node:path";
|
|
3
|
+
import { ProjectFileError, findLinkedProjectRoot, projectCredentialsPath, projectLinkPath, readCredentialsFile, readProjectLink, tenantHostRoot, } from "@nylorun/core/project";
|
|
4
|
+
import { checkHealth, describeIncompatibility } from "@nylorun/core/transport";
|
|
5
|
+
import { AdminError, rejection } from "./errors.js";
|
|
7
6
|
import { ManagementClient } from "./management.js";
|
|
8
7
|
function env(name) {
|
|
9
8
|
const value = process.env[name];
|
|
10
9
|
return value === undefined || value.trim() === "" ? undefined : value;
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
export function tenantHostRoot(name) {
|
|
14
|
-
return resolve(join(homedir(), ".nylorun", "tenants", name));
|
|
15
|
-
}
|
|
11
|
+
export { tenantHostRoot };
|
|
16
12
|
/**
|
|
17
|
-
* The Project link (`.nylorun/link.json`, format 3) from `cwd` upwards:
|
|
18
|
-
* and the Project's
|
|
19
|
-
*
|
|
13
|
+
* The Project link (`.nylorun/link.json`, format 3) from `cwd` upwards (`@nylorun/core/project`):
|
|
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.
|
|
20
16
|
*/
|
|
21
17
|
function projectLink(cwd) {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
const stop = real(homedir());
|
|
31
|
-
let directory = real(resolve(cwd));
|
|
32
|
-
const root = parse(directory).root;
|
|
33
|
-
while (directory !== stop) {
|
|
34
|
-
const path = join(directory, ".nylorun", "link.json");
|
|
35
|
-
let raw;
|
|
36
|
-
try {
|
|
37
|
-
raw = readFileSync(path, "utf8");
|
|
38
|
-
}
|
|
39
|
-
catch {
|
|
40
|
-
/* no link here */
|
|
41
|
-
}
|
|
42
|
-
if (raw !== undefined) {
|
|
43
|
-
try {
|
|
44
|
-
const link = ProjectLinkFileSchema.parse(JSON.parse(raw));
|
|
45
|
-
if (link.format < 3)
|
|
46
|
-
return { olderLink: path };
|
|
47
|
-
return { ...(link.tenant ? { tenant: link.tenant } : {}), directory: dirname(path) };
|
|
48
|
-
}
|
|
49
|
-
catch {
|
|
50
|
-
return {};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
if (directory === root)
|
|
18
|
+
const project = findLinkedProjectRoot(cwd);
|
|
19
|
+
if (project === undefined)
|
|
20
|
+
return {};
|
|
21
|
+
try {
|
|
22
|
+
const link = readProjectLink(project);
|
|
23
|
+
if (link === undefined)
|
|
54
24
|
return {};
|
|
55
|
-
|
|
25
|
+
if (link.format < 3)
|
|
26
|
+
return {
|
|
27
|
+
unusable: `The Project link at ${projectLinkPath(project)} is from an older nylorun. Run "npx nylorun start" in this project to link it again.`,
|
|
28
|
+
};
|
|
29
|
+
return { ...(link.tenant ? { tenant: link.tenant } : {}), project };
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (error instanceof ProjectFileError)
|
|
33
|
+
return { unusable: error.message };
|
|
34
|
+
throw error;
|
|
56
35
|
}
|
|
57
|
-
return {};
|
|
58
36
|
}
|
|
59
37
|
/**
|
|
60
38
|
* The Host root of the local Host: `options.home`, `NYLORUN_HOME`, or the Host root of the
|
|
61
39
|
* Tenant named by `options.tenant`, `NYLORUN_TENANT` or the Project link. `project` is the
|
|
62
|
-
* linked Project's
|
|
40
|
+
* linked Project's root when the link names this Host root's Tenant.
|
|
63
41
|
*/
|
|
64
42
|
function resolveHome(options) {
|
|
65
43
|
const link = projectLink(options?.cwd ?? process.cwd());
|
|
@@ -75,8 +53,8 @@ function resolveHome(options) {
|
|
|
75
53
|
: linked;
|
|
76
54
|
return {
|
|
77
55
|
...(home ? { home } : {}),
|
|
78
|
-
...(home && home === linked ? { project: link.
|
|
79
|
-
...(link.
|
|
56
|
+
...(home && home === linked ? { project: link.project } : {}),
|
|
57
|
+
...(link.unusable ? { unusableLink: link.unusable } : {}),
|
|
80
58
|
};
|
|
81
59
|
}
|
|
82
60
|
function connectionMissing(message) {
|
|
@@ -119,6 +97,23 @@ function readJson(path) {
|
|
|
119
97
|
return undefined;
|
|
120
98
|
}
|
|
121
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* The management key of a credentials file. The linked Project's must read (a broken one is
|
|
102
|
+
* `connection_missing`, as for every reader of the Project's files); a Host root's key file that
|
|
103
|
+
* does not read holds no key.
|
|
104
|
+
*/
|
|
105
|
+
function managementKeyOf(path, project) {
|
|
106
|
+
try {
|
|
107
|
+
return readCredentialsFile(path)?.managementKey;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
if (!(error instanceof ProjectFileError))
|
|
111
|
+
throw error;
|
|
112
|
+
if (project)
|
|
113
|
+
connectionMissing(error.message);
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
122
117
|
/**
|
|
123
118
|
* The local Host's URL (`host.json`) and a management key: from the linked Project's
|
|
124
119
|
* `.nylorun/credentials.json`, else the Host root's `project-credentials.json`, else its
|
|
@@ -129,13 +124,13 @@ function readLocalHost(home, project) {
|
|
|
129
124
|
if (typeof config?.host !== "string" || typeof config.port !== "number")
|
|
130
125
|
return undefined;
|
|
131
126
|
const files = [
|
|
132
|
-
...(project ? [
|
|
133
|
-
join(home, "project-credentials.json"),
|
|
134
|
-
join(home, "cli-credentials.json"),
|
|
127
|
+
...(project ? [{ path: projectCredentialsPath(project), project: true }] : []),
|
|
128
|
+
{ path: join(home, "project-credentials.json"), project: false },
|
|
129
|
+
{ path: join(home, "cli-credentials.json"), project: false },
|
|
135
130
|
];
|
|
136
|
-
for (const path of files) {
|
|
137
|
-
const key =
|
|
138
|
-
if (
|
|
131
|
+
for (const { path, project: own } of files) {
|
|
132
|
+
const key = managementKeyOf(path, own);
|
|
133
|
+
if (key === undefined)
|
|
139
134
|
continue;
|
|
140
135
|
assertCredentialsSafe(path, home);
|
|
141
136
|
return { url: `http://${config.host}:${config.port}`, key };
|
|
@@ -144,7 +139,7 @@ function readLocalHost(home, project) {
|
|
|
144
139
|
}
|
|
145
140
|
/** Resolve the Management API connection once: options → environment → local Host. */
|
|
146
141
|
export function resolveAdminConnection(options) {
|
|
147
|
-
const { home, project,
|
|
142
|
+
const { home, project, unusableLink } = resolveHome(options);
|
|
148
143
|
const optionUrl = options?.url?.trim() || undefined;
|
|
149
144
|
const optionKey = options?.key?.trim() || undefined;
|
|
150
145
|
if (optionUrl || optionKey) {
|
|
@@ -160,47 +155,22 @@ export function resolveAdminConnection(options) {
|
|
|
160
155
|
connectionMissing(`Incomplete environment: NYLORUN_MANAGEMENT_KEY needs NYLORUN_RUNTIME_URL. ${sourcesTriedMessage(home)}`);
|
|
161
156
|
return { url: envUrl.replace(/\/$/, ""), key: envKey, source: "environment", ...(home ? { home } : {}) };
|
|
162
157
|
}
|
|
163
|
-
if (
|
|
164
|
-
connectionMissing(
|
|
158
|
+
if (unusableLink && !home)
|
|
159
|
+
connectionMissing(unusableLink);
|
|
165
160
|
const local = home === undefined ? undefined : readLocalHost(home, project);
|
|
166
161
|
if (local)
|
|
167
162
|
return { url: local.url, key: local.key, source: "local-host", home };
|
|
168
163
|
connectionMissing(`Could not resolve the Management API connection. ${sourcesTriedMessage(home)}`);
|
|
169
164
|
}
|
|
170
|
-
function parseProtocolRange(value) {
|
|
171
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
172
|
-
return undefined;
|
|
173
|
-
const record = value;
|
|
174
|
-
if (typeof record.min !== "number" ||
|
|
175
|
-
typeof record.max !== "number" ||
|
|
176
|
-
!Array.isArray(record.features) ||
|
|
177
|
-
!record.features.every((f) => typeof f === "string"))
|
|
178
|
-
return undefined;
|
|
179
|
-
return { min: record.min, max: record.max, features: record.features };
|
|
180
|
-
}
|
|
181
165
|
/** Throws unless the Host's `/health` advertises this client's protocol and features. */
|
|
182
|
-
async function
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
throw rejected.success
|
|
188
|
-
? new AdminError(rejected.data.code, rejected.data.message, { status: response.status })
|
|
189
|
-
: new AdminError("not_found", `Host /health failed (${response.status})`, {
|
|
190
|
-
status: response.status,
|
|
191
|
-
details: body,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
const protocol = parseProtocolRange(body?.protocol);
|
|
195
|
-
if (!protocol)
|
|
166
|
+
async function requireCompatibleHost(url) {
|
|
167
|
+
const health = await checkHealth(url);
|
|
168
|
+
if (health.result === "failed")
|
|
169
|
+
throw rejection(health.status, health.body, "Host /health failed");
|
|
170
|
+
if (health.result === "unadvertised")
|
|
196
171
|
throw new AdminError("incompatible_host", "Host /health did not advertise a protocol range.");
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const detail = result.reason === "version"
|
|
200
|
-
? `client protocol ${result.client} is outside Host range ${result.host.min}–${result.host.max}`
|
|
201
|
-
: `Host is missing required features: ${result.missing.join(", ")}`;
|
|
202
|
-
throw new AdminError("incompatible_host", `Incompatible Host: ${detail}`, { details: result });
|
|
203
|
-
}
|
|
172
|
+
if (health.result === "incompatible")
|
|
173
|
+
throw new AdminError("incompatible_host", `Incompatible Host: ${describeIncompatibility(health.compatibility)}`, { details: health.compatibility });
|
|
204
174
|
}
|
|
205
175
|
/**
|
|
206
176
|
* `fetch` that checks the Host's `/health` before the first request, and again after a `426`,
|
|
@@ -208,7 +178,7 @@ async function checkHealth(url) {
|
|
|
208
178
|
*/
|
|
209
179
|
function compatibleFetch(url) {
|
|
210
180
|
let checked;
|
|
211
|
-
const check = () => (checked ??=
|
|
181
|
+
const check = () => (checked ??= requireCompatibleHost(url).catch((error) => {
|
|
212
182
|
checked = undefined;
|
|
213
183
|
throw error;
|
|
214
184
|
}));
|
package/dist/errors.d.ts
CHANGED
|
@@ -8,3 +8,8 @@ export declare class AdminError extends Error {
|
|
|
8
8
|
details?: unknown;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* The `AdminError` of a refused request: the Runtime's rejection (`{ status: "rejected", code,
|
|
13
|
+
* message }`), else `not_found` naming `what` and the status.
|
|
14
|
+
*/
|
|
15
|
+
export declare function rejection(status: number, body: unknown, what: string): AdminError;
|
package/dist/errors.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RejectedResponseSchema } from "@nylorun/core/contracts";
|
|
1
2
|
export class AdminError extends Error {
|
|
2
3
|
code;
|
|
3
4
|
status;
|
|
@@ -10,3 +11,16 @@ export class AdminError extends Error {
|
|
|
10
11
|
this.details = options?.details;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The `AdminError` of a refused request: the Runtime's rejection (`{ status: "rejected", code,
|
|
16
|
+
* message }`), else `not_found` naming `what` and the status.
|
|
17
|
+
*/
|
|
18
|
+
export function rejection(status, body, what) {
|
|
19
|
+
const rejected = RejectedResponseSchema.safeParse(body);
|
|
20
|
+
return rejected.success
|
|
21
|
+
? new AdminError(rejected.data.code, rejected.data.message, {
|
|
22
|
+
status,
|
|
23
|
+
details: rejected.data.details,
|
|
24
|
+
})
|
|
25
|
+
: new AdminError("not_found", `${what} (${status})`, { status, details: body });
|
|
26
|
+
}
|
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 ManagementModels, type ManagementSettings, type ManagementSigningKeys, type ManagementTenant, type ManagementVaults, } from "./management.js";
|
|
11
|
+
export { ManagementClient, createManagementClient, type ManagementClientOptions, type ManagementKeys, type ManagementMcp, type ManagementModels, type ManagementSettings, type ManagementSigningKeys, type ManagementTenant, type ManagementVaults, } from "./management.js";
|
|
12
12
|
/**
|
|
13
13
|
* The Management API client for the installation (`/v1/tenant/*`): `tenant`, `keys`
|
|
14
|
-
* (application keys), `models`, `vaults`, `signingKeys` and `settings`, with a management key.
|
|
14
|
+
* (application keys), `models`, `vaults`, `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 CreateCredentialRequest, type CreateVaultRequest, type CredentialInfo, type HostModelCatalog, type HostModelView, type ListProvidersResponse, type ModelCallExportPage, type ModelBudgets, type ModelUsageQuery, type ModelUsageTotals, type OperatorKey, type PutHostModelRequest, type PutModelBudgetsRequest, type PutOperatorKeyResponse, type PutTenantArtifactsRequest, type PutTenantSandboxRequest, type ResetTenantRequest, type ResetTenantResponse, type RotateCredentialRequest, type SeedTenantConfigRequest, type SeedTenantConfigResponse, type SelectHostModelRequest, type SigningKeyView, type
|
|
1
|
+
import { type CreateCredentialRequest, type CreateVaultRequest, type CredentialInfo, 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 PutOperatorKeyResponse, type PutTenantArtifactsRequest, type PutTenantSandboxRequest, type ResetTenantRequest, type ResetTenantResponse, type RotateCredentialRequest, type SeedTenantConfigRequest, type SeedTenantConfigResponse, type SelectHostModelRequest, type SigningKeyView, type TenantArtifactsView, type TenantSandboxView, type TenantStatus, type VaultInfo } 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;
|
|
@@ -76,8 +76,17 @@ export interface ManagementVaults {
|
|
|
76
76
|
id: string;
|
|
77
77
|
}>;
|
|
78
78
|
};
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
}
|
|
80
|
+
export interface ManagementMcp {
|
|
81
|
+
/**
|
|
82
|
+
* A remote MCP server's tools before an agent names it (R2b C12): the Runtime connects with
|
|
83
|
+
* the installation vault's credential for `url`, lists the tools and closes; it never calls
|
|
84
|
+
* one. Each tool has the name the model would call it, made with `name` (default: from the
|
|
85
|
+
* URL's host). A server that needs a person's sign-in answers `authRequired`, with its
|
|
86
|
+
* protected-resource metadata. A server that cannot be listed rejects with
|
|
87
|
+
* `mcp_preview_failed` (`details.failure`).
|
|
88
|
+
*/
|
|
89
|
+
preview(request: McpPreviewRequest): Promise<McpPreview>;
|
|
81
90
|
}
|
|
82
91
|
export interface ManagementSigningKeys {
|
|
83
92
|
list(): Promise<SigningKeyView[]>;
|
|
@@ -109,6 +118,7 @@ export declare class ManagementClient {
|
|
|
109
118
|
readonly keys: ManagementKeys;
|
|
110
119
|
readonly models: ManagementModels;
|
|
111
120
|
readonly vaults: ManagementVaults;
|
|
121
|
+
readonly mcp: ManagementMcp;
|
|
112
122
|
readonly signingKeys: ManagementSigningKeys;
|
|
113
123
|
readonly settings: ManagementSettings;
|
|
114
124
|
constructor(options: ManagementClientOptions);
|
package/dist/management.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The Management API client (`/v1/tenant/*`, protocol 8): the Tenant's settings, models,
|
|
3
|
-
* vaults, signing keys and application keys, with a management key. It imports nothing from
|
|
3
|
+
* vaults, MCP server previews, signing keys and application keys, with a management key. It imports nothing from
|
|
4
4
|
* Node, so a browser app that reaches the Runtime through its own proxy (Studio) uses it too:
|
|
5
5
|
* `@nylorun/admin/client`. `createAdmin()` in the package's main entry finds the URL and key.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
8
|
-
import { ModelCallExportPageSchema,
|
|
9
|
-
import { AdminError } from "./errors.js";
|
|
7
|
+
import { parseBody, requestHeaders } from "@nylorun/core/transport";
|
|
8
|
+
import { ModelCallExportPageSchema, } from "@nylorun/core/contracts";
|
|
9
|
+
import { AdminError, rejection } from "./errors.js";
|
|
10
10
|
const segment = (value) => encodeURIComponent(value);
|
|
11
11
|
const withId = (body) => ({
|
|
12
12
|
requestId: crypto.randomUUID(),
|
|
@@ -19,6 +19,7 @@ export class ManagementClient {
|
|
|
19
19
|
keys;
|
|
20
20
|
models;
|
|
21
21
|
vaults;
|
|
22
|
+
mcp;
|
|
22
23
|
signingKeys;
|
|
23
24
|
settings;
|
|
24
25
|
#key;
|
|
@@ -83,7 +84,9 @@ export class ManagementClient {
|
|
|
83
84
|
rotate: (vaultId, credentialId, request) => call("POST", credential(vaultId, credentialId), withId(request)),
|
|
84
85
|
delete: (vaultId, credentialId) => call("DELETE", credential(vaultId, credentialId)),
|
|
85
86
|
},
|
|
86
|
-
|
|
87
|
+
};
|
|
88
|
+
this.mcp = {
|
|
89
|
+
preview: (request) => call("POST", "/v1/tenant/mcp/preview", request),
|
|
87
90
|
};
|
|
88
91
|
this.signingKeys = {
|
|
89
92
|
list: async () => (await call("GET", "/v1/tenant/signing-keys")).keys,
|
|
@@ -118,9 +121,8 @@ export class ManagementClient {
|
|
|
118
121
|
}
|
|
119
122
|
async request(method, path, body) {
|
|
120
123
|
const headers = {
|
|
121
|
-
|
|
124
|
+
...requestHeaders(this.#key),
|
|
122
125
|
accept: "application/json",
|
|
123
|
-
...(this.#key ? { authorization: `Bearer ${this.#key}` } : {}),
|
|
124
126
|
...(body === undefined ? {} : { "content-type": "application/json" }),
|
|
125
127
|
...this.#headers,
|
|
126
128
|
};
|
|
@@ -131,27 +133,9 @@ export class ManagementClient {
|
|
|
131
133
|
...(body === undefined ? {} : { body: JSON.stringify(body) }),
|
|
132
134
|
});
|
|
133
135
|
const text = await response.text();
|
|
134
|
-
|
|
135
|
-
if (
|
|
136
|
-
|
|
137
|
-
parsed = JSON.parse(text);
|
|
138
|
-
}
|
|
139
|
-
catch {
|
|
140
|
-
parsed = text;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
if (!response.ok) {
|
|
144
|
-
const rejected = RejectedResponseSchema.safeParse(parsed);
|
|
145
|
-
if (rejected.success)
|
|
146
|
-
throw new AdminError(rejected.data.code, rejected.data.message, {
|
|
147
|
-
status: response.status,
|
|
148
|
-
details: rejected.data.details,
|
|
149
|
-
});
|
|
150
|
-
throw new AdminError("not_found", `${method} ${path} failed (${response.status})`, {
|
|
151
|
-
status: response.status,
|
|
152
|
-
details: parsed,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
136
|
+
const parsed = text ? parseBody(text) : undefined;
|
|
137
|
+
if (!response.ok)
|
|
138
|
+
throw rejection(response.status, parsed, `${method} ${path} failed`);
|
|
155
139
|
return parsed;
|
|
156
140
|
}
|
|
157
141
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/admin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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,6 +19,10 @@
|
|
|
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"
|
|
22
26
|
}
|
|
23
27
|
},
|
|
24
28
|
"scripts": {
|
|
@@ -28,7 +32,7 @@
|
|
|
28
32
|
"clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\""
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@nylorun/core": "0.
|
|
35
|
+
"@nylorun/core": "0.18.0-beta"
|
|
32
36
|
},
|
|
33
37
|
"peerDependencies": {
|
|
34
38
|
"zod": "^4.6.5"
|