nylorun 0.13.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 +153 -0
- package/README.md +255 -166
- package/dist/cli.js +141 -47
- package/dist/client/agents.d.ts +6 -0
- package/dist/client/agents.js +148 -0
- package/dist/client/artifacts.d.ts +4 -0
- package/dist/client/artifacts.js +210 -0
- package/dist/client/doctor.d.ts +10 -4
- package/dist/client/doctor.js +28 -20
- package/dist/client/environment-manifests.d.ts +10 -0
- package/dist/client/environment-manifests.js +173 -0
- package/dist/client/environments.d.ts +4 -0
- package/dist/client/environments.js +295 -0
- package/dist/client/io.d.ts +31 -0
- package/dist/client/io.js +72 -0
- package/dist/client/mcp.d.ts +11 -0
- package/dist/{stack → client}/mcp.js +40 -26
- package/dist/client/model/pi-ai.d.ts +3 -3
- package/dist/client/model/pi-ai.js +4 -4
- package/dist/client/models.d.ts +13 -0
- package/dist/client/models.js +203 -0
- package/dist/client/runtime.d.ts +40 -0
- package/dist/client/runtime.js +134 -0
- package/dist/client/sessions.d.ts +4 -0
- package/dist/client/sessions.js +295 -0
- package/dist/client/settings.d.ts +12 -0
- package/dist/client/settings.js +103 -0
- package/dist/client/signing-keys.d.ts +3 -0
- package/dist/client/signing-keys.js +32 -0
- package/dist/client/target.d.ts +33 -0
- package/dist/client/target.js +65 -0
- package/dist/client/tenant.d.ts +22 -0
- package/dist/client/tenant.js +176 -0
- package/dist/doctor.js +3 -3
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/nylo.js +20 -4
- package/dist/sandbox/cluster-file.d.ts +1 -1
- package/dist/sandbox/commands.d.ts +1 -1
- package/dist/sandbox/commands.js +7 -7
- package/dist/sandbox/manifests.d.ts +1 -1
- package/dist/sandbox/manifests.js +1 -1
- package/dist/sandbox/probe.d.ts +1 -1
- package/dist/stack/commands.d.ts +9 -4
- package/dist/stack/commands.js +22 -26
- package/dist/stack/compose-file.d.ts +1 -1
- package/dist/stack/compose-file.js +22 -13
- package/dist/stack/env-file.d.ts +2 -2
- package/dist/stack/env-file.js +2 -2
- package/dist/stack/images.d.ts +1 -1
- package/dist/stack/images.js +1 -1
- package/dist/stack/index.d.ts +1 -10
- package/dist/stack/index.js +3 -19
- package/dist/stack/keys.d.ts +2 -2
- package/dist/stack/keys.js +14 -11
- package/dist/stack/paths.d.ts +1 -1
- package/dist/stack/prepare.d.ts +1 -1
- package/dist/stack/stacks.js +1 -1
- package/dist/stack/versions.d.ts +2 -2
- package/dist/stack/versions.js +3 -3
- package/dist/telemetry.d.ts +2 -2
- package/dist/telemetry.js +4 -4
- package/package.json +10 -9
- package/dist/client/access/commands.d.ts +0 -8
- package/dist/client/access/commands.js +0 -33
- package/dist/client/cli.d.ts +0 -2
- package/dist/client/cli.js +0 -106
- package/dist/client/installation/commands.d.ts +0 -7
- package/dist/client/installation/commands.js +0 -80
- package/dist/client/project/connection.d.ts +0 -36
- package/dist/client/project/connection.js +0 -80
- package/dist/client/project/env.d.ts +0 -3
- package/dist/client/project/env.js +0 -19
- package/dist/stack/mcp.d.ts +0 -9
- package/dist/stack/sandbox.d.ts +0 -4
- package/dist/stack/sandbox.js +0 -106
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nylorun",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Set up and run local Nylorun Tenants (Runtime and Studio) with Docker Compose (nylorun), and the Runtime client of the linked installation (nylo)",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
9
|
"url": "git+https://github.com/nylorun/agents.git",
|
|
10
|
-
"directory": "nylorun"
|
|
10
|
+
"directory": "cli/nylorun"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
13
|
"dist",
|
|
@@ -23,21 +23,22 @@
|
|
|
23
23
|
"node": ">=24.0.0"
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"build": "npm run clean && node
|
|
26
|
+
"build": "npm run clean && node ../../scripts/check-typescript-version.mjs && tsc -p tsconfig.json",
|
|
27
27
|
"clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
|
|
28
28
|
"check": "npm run build && npm test && node scripts/check-package.mjs",
|
|
29
29
|
"test": "vitest run --passWithNoTests",
|
|
30
30
|
"prepack": "npm run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@nylorun/
|
|
34
|
-
"@nylorun/
|
|
33
|
+
"@nylorun/admin": "0.17.0-beta",
|
|
34
|
+
"@nylorun/agents": "0.21.0-beta",
|
|
35
|
+
"@nylorun/core": "0.21.0-beta"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@earendil-works/pi-ai": "0.99.1",
|
|
38
|
-
"@nylorun/agents": "file
|
|
39
|
+
"@nylorun/agents": "file:../../sdks/agents",
|
|
39
40
|
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
40
|
-
"@types/node": "^26.
|
|
41
|
+
"@types/node": "^26.6.4",
|
|
41
42
|
"vitest": "^5.0.2"
|
|
42
43
|
},
|
|
43
44
|
"bin": {
|
|
@@ -45,7 +46,7 @@
|
|
|
45
46
|
"nylo": "dist/nylo.js"
|
|
46
47
|
},
|
|
47
48
|
"nylorun": {
|
|
48
|
-
"runtime": "0.
|
|
49
|
-
"studio": "0.
|
|
49
|
+
"runtime": "0.25.0-beta",
|
|
50
|
+
"studio": "0.25.0-beta"
|
|
50
51
|
}
|
|
51
52
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nylo access`: the linked Tenant's signing keys, which sign capability links and run tokens,
|
|
3
|
-
* through the Management API with the Project's management key. (Subject tokens, the
|
|
4
|
-
* access policy, browser keys and revocations left the Runtime in protocol 7.)
|
|
5
|
-
*/
|
|
6
|
-
import type { ManagementClient } from "@nylorun/admin";
|
|
7
|
-
export declare const accessUsage = "nylo access signing-keys <list|rotate|revoke>\n\n signing-keys list list the signing keys\n signing-keys rotate [--force] rotate; --force ends outstanding links and run tokens\n signing-keys revoke <kid> revoke a previous or standby key";
|
|
8
|
-
export declare function accessCommand(input: readonly string[], client?: () => Promise<ManagementClient>): Promise<void>;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { findProjectRoot } from "@nylorun/core/project";
|
|
2
|
-
import { CliError } from "../../errors.js";
|
|
3
|
-
import { linkedConnection, managementClient } from "../project/connection.js";
|
|
4
|
-
export const accessUsage = `nylo access signing-keys <list|rotate|revoke>
|
|
5
|
-
|
|
6
|
-
signing-keys list list the signing keys
|
|
7
|
-
signing-keys rotate [--force] rotate; --force ends outstanding links and run tokens
|
|
8
|
-
signing-keys revoke <kid> revoke a previous or standby key`;
|
|
9
|
-
const usageError = (message = accessUsage) => new CliError(message, 2);
|
|
10
|
-
async function linkedClient() {
|
|
11
|
-
return managementClient(await linkedConnection(findProjectRoot() ?? process.cwd()));
|
|
12
|
-
}
|
|
13
|
-
const print = (value) => console.log(JSON.stringify(value, null, 2));
|
|
14
|
-
export async function accessCommand(input, client = linkedClient) {
|
|
15
|
-
const [topic, action, ...args] = input;
|
|
16
|
-
if (topic === "signing-keys") {
|
|
17
|
-
const keys = async () => (await client()).signingKeys;
|
|
18
|
-
if (action === "list" && args.length === 0)
|
|
19
|
-
return print(await (await keys()).list());
|
|
20
|
-
if (action === "rotate") {
|
|
21
|
-
const force = args[0] === "--force";
|
|
22
|
-
if (args.length > (force ? 1 : 0))
|
|
23
|
-
throw usageError();
|
|
24
|
-
return print(await (await keys()).rotate({ force }));
|
|
25
|
-
}
|
|
26
|
-
if (action === "revoke" && args.length === 1)
|
|
27
|
-
return print(await (await keys()).revoke(args[0]));
|
|
28
|
-
throw usageError();
|
|
29
|
-
}
|
|
30
|
-
if (topic === "policy" || topic === "keys" || topic === "revoke" || topic === "token")
|
|
31
|
-
throw usageError(`nylo access ${topic} was removed: the Runtime no longer mints subject tokens or keeps an access policy, browser keys or revocations (protocol 7). Trust your identity provider's tokens with an identity file, and give servers an application key (nylorun key put <id>).`);
|
|
32
|
-
throw usageError();
|
|
33
|
-
}
|
package/dist/client/cli.d.ts
DELETED
package/dist/client/cli.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import { findProjectRoot } from "@nylorun/core/project";
|
|
2
|
-
import { CliError } from "../errors.js";
|
|
3
|
-
import { refuseNativeWindows } from "../command.js";
|
|
4
|
-
import { printLinkedEnvExports } from "./project/env.js";
|
|
5
|
-
import { linkedConnection, managementClient } from "./project/connection.js";
|
|
6
|
-
import { accessCommand } from "./access/commands.js";
|
|
7
|
-
import { resetCommand, statusCommand } from "./installation/commands.js";
|
|
8
|
-
const usage = `nylo <status|reset|access|configure|env|doctor>
|
|
9
|
-
|
|
10
|
-
Runtime client for the linked installation and its one Tenant (the Project link that
|
|
11
|
-
npx nylorun start writes, or NYLORUN_RUNTIME_URL with NYLORUN_SERVER_KEY, and
|
|
12
|
-
NYLORUN_MANAGEMENT_KEY for status, reset, access, configure and doctor):
|
|
13
|
-
status [--json] the Tenant, its checks and counts
|
|
14
|
-
reset [--sessions|--sandboxes|--all] [--yes]
|
|
15
|
-
clear the Tenant's sessions, sandboxes or all its data
|
|
16
|
-
access signing-keys list|rotate|revoke the Tenant's token signing keys (nylo access --help)
|
|
17
|
-
configure set the linked Tenant's model provider
|
|
18
|
-
env print the linked Project's NYLORUN_* variables as exports
|
|
19
|
-
doctor sandbox [--json] show which sandbox backend this Tenant's Host offers
|
|
20
|
-
|
|
21
|
-
nylo status and reset go through the Management API, to a local or a remote installation.
|
|
22
|
-
Local Tenants are nylorun's, the other command of this package: npx nylorun start in a
|
|
23
|
-
project creates its Tenant and the Project link, and nylorun status and reset act on the
|
|
24
|
-
local Tenant's containers and volumes.`;
|
|
25
|
-
/** Local Tenant commands, which `nylorun` runs. */
|
|
26
|
-
const LOCAL_COMMANDS = new Set([
|
|
27
|
-
"up", "down", "start", "stop", "logs", "studio", "runtime", "restart", "run",
|
|
28
|
-
]);
|
|
29
|
-
const TENANT_REMOVED = `nylo tenant was removed: an installation serves one Tenant.
|
|
30
|
-
Run "npx nylorun start" in your project to create its Tenant and the Project link.
|
|
31
|
-
Then use nylo status and nylo reset on the linked installation.`;
|
|
32
|
-
const ENDPOINTS_REMOVED = `nylo endpoints was removed: the Runtime runs no code of yours during a session,
|
|
33
|
-
so there are no Action endpoints. An agent's tools are http() tools and remote MCP servers
|
|
34
|
-
(see MIGRATION.md).`;
|
|
35
|
-
const usageError = (message) => new CliError(message, 2);
|
|
36
|
-
/** `nylo <command> [...args]`. */
|
|
37
|
-
export async function main(argv) {
|
|
38
|
-
const [command, ...args] = argv;
|
|
39
|
-
if (!command || command === "--help" || command === "-h")
|
|
40
|
-
return void console.log(usage);
|
|
41
|
-
refuseNativeWindows();
|
|
42
|
-
if (command === "tenant")
|
|
43
|
-
throw usageError(TENANT_REMOVED);
|
|
44
|
-
if (command === "status")
|
|
45
|
-
return await statusCommand(args);
|
|
46
|
-
if (command === "reset")
|
|
47
|
-
return await resetCommand(args);
|
|
48
|
-
if (command === "endpoints")
|
|
49
|
-
throw usageError(ENDPOINTS_REMOVED);
|
|
50
|
-
if (command === "access") {
|
|
51
|
-
if (args[0] === "--help" || args[0] === "-h" || args.length === 0) {
|
|
52
|
-
const { accessUsage } = await import("./access/commands.js");
|
|
53
|
-
return void console.log(accessUsage);
|
|
54
|
-
}
|
|
55
|
-
return await accessCommand(args);
|
|
56
|
-
}
|
|
57
|
-
if (command === "env") {
|
|
58
|
-
if (args.length)
|
|
59
|
-
throw usageError("Usage: nylo env");
|
|
60
|
-
await printLinkedEnvExports(findProjectRoot() ?? process.cwd());
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
if (command === "doctor") {
|
|
64
|
-
const [topic, ...options] = args;
|
|
65
|
-
if (topic !== "sandbox" || options.some((option) => option !== "--json"))
|
|
66
|
-
throw usageError("Usage: nylo doctor sandbox [--json]. Check the local Tenant with npx nylorun doctor.");
|
|
67
|
-
const { doctorSandbox } = await import("./doctor.js");
|
|
68
|
-
await doctorSandbox({ json: options.includes("--json") });
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (command === "dev")
|
|
72
|
-
throw usageError('nylorun dev was removed: run "npx nylorun start" once in your project, then your project\'s npm run dev.');
|
|
73
|
-
if (LOCAL_COMMANDS.has(command))
|
|
74
|
-
throw usageError(`Local Tenants are nylorun's: npx nylorun ${command}`);
|
|
75
|
-
if (command === "configure") {
|
|
76
|
-
for (const arg of args) {
|
|
77
|
-
if (arg === "--global" || arg === "--db")
|
|
78
|
-
throw usageError(`${arg} was removed. Use the Runtime Host root (NYLORUN_HOME) and a Project link instead.`);
|
|
79
|
-
if (arg.startsWith("-"))
|
|
80
|
-
throw usageError(usage);
|
|
81
|
-
}
|
|
82
|
-
if (args.length)
|
|
83
|
-
throw usageError(usage);
|
|
84
|
-
const projectRoot = findProjectRoot() ?? process.cwd();
|
|
85
|
-
const auth = await linkedConnection(projectRoot);
|
|
86
|
-
const admin = managementClient(auth);
|
|
87
|
-
// The provider login flows (pi-ai) load only here.
|
|
88
|
-
const { ConfigurationCancelled, configureProvider, fetchModelCatalog } = await import("./model/configure.js");
|
|
89
|
-
const { putHostModel } = await import("./model/host-model.js");
|
|
90
|
-
const controller = new AbortController();
|
|
91
|
-
const cancel = (signal) => controller.abort(new ConfigurationCancelled(signal));
|
|
92
|
-
process.once("SIGINT", () => cancel("SIGINT"));
|
|
93
|
-
process.once("SIGTERM", () => cancel("SIGTERM"));
|
|
94
|
-
const health = await fetch(`${auth.url}/health`).catch(() => undefined);
|
|
95
|
-
if (!health?.ok)
|
|
96
|
-
throw new CliError(`No Runtime is listening at ${auth.url}. Start the local Tenant with "npx nylorun start".`, 6);
|
|
97
|
-
const catalog = await fetchModelCatalog(admin);
|
|
98
|
-
const prompted = await configureProvider({
|
|
99
|
-
signal: controller.signal,
|
|
100
|
-
catalog,
|
|
101
|
-
});
|
|
102
|
-
await putHostModel(admin, prompted);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
throw usageError(usage);
|
|
106
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nylo status [--json]`: the Tenant, its checks and counts. A Tenant that is not open does not
|
|
3
|
-
* answer: `npx nylorun status` reports why.
|
|
4
|
-
*/
|
|
5
|
-
export declare function statusCommand(args: readonly string[]): Promise<void>;
|
|
6
|
-
/** `nylo reset [--sessions|--sandboxes|--all] [--yes]`; `--all` asks first. */
|
|
7
|
-
export declare function resetCommand(args: readonly string[]): Promise<void>;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nylo status` and `nylo reset`: the linked installation's one Tenant, through the Management
|
|
3
|
-
* API (the Project's management key).
|
|
4
|
-
*/
|
|
5
|
-
import { createInterface } from "node:readline/promises";
|
|
6
|
-
import { findProjectRoot } from "@nylorun/core/project";
|
|
7
|
-
import { CliError } from "../../errors.js";
|
|
8
|
-
import { linkedConnection, managementClient } from "../project/connection.js";
|
|
9
|
-
const projectRoot = () => findProjectRoot() ?? process.cwd();
|
|
10
|
-
/**
|
|
11
|
-
* `nylo status [--json]`: the Tenant, its checks and counts. A Tenant that is not open does not
|
|
12
|
-
* answer: `npx nylorun status` reports why.
|
|
13
|
-
*/
|
|
14
|
-
export async function statusCommand(args) {
|
|
15
|
-
const json = args.includes("--json");
|
|
16
|
-
if (args.some((a) => a !== "--json"))
|
|
17
|
-
throw new CliError("Usage: nylo status [--json]", 2);
|
|
18
|
-
const root = projectRoot();
|
|
19
|
-
const connection = await linkedConnection(root);
|
|
20
|
-
const admin = managementClient(connection);
|
|
21
|
-
let body;
|
|
22
|
-
try {
|
|
23
|
-
body = await admin.tenant.status();
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
throw new CliError(`${(error instanceof Error ? error.message : `The Tenant at ${connection.url} is not reachable`).replace(/\.?$/, ".")} Run "npx nylorun status" to see the Tenant's state and why it is not open.`, 1);
|
|
27
|
-
}
|
|
28
|
-
if (json) {
|
|
29
|
-
console.log(JSON.stringify(body, null, 2));
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
console.log(`${body.tenant.name} ${body.tenant.id}`);
|
|
33
|
-
console.log(`runtime ${connection.url}`);
|
|
34
|
-
console.log(`path ${body.path}`);
|
|
35
|
-
console.log(`checks ${Object.entries(body.checks)
|
|
36
|
-
.map(([k, v]) => `${k}=${v ? "ok" : "fail"}`)
|
|
37
|
-
.join(" ")}`);
|
|
38
|
-
console.log(`counts sessions=${body.counts.sessions} running=${body.counts.runningSessions} uncertain=${body.counts.uncertainEffects}`);
|
|
39
|
-
console.log(`sandbox ${body.sandbox.backend ?? "none"}`);
|
|
40
|
-
}
|
|
41
|
-
const RESET_USAGE = "Usage: nylo reset [--sessions|--sandboxes|--all] [--yes]";
|
|
42
|
-
const SCOPES = { "--sessions": "sessions", "--sandboxes": "sandboxes", "--all": "all" };
|
|
43
|
-
/** `nylo reset [--sessions|--sandboxes|--all] [--yes]`; `--all` asks first. */
|
|
44
|
-
export async function resetCommand(args) {
|
|
45
|
-
const yes = args.includes("--yes");
|
|
46
|
-
const flags = args.filter((a) => a !== "--yes");
|
|
47
|
-
if (flags.some((f) => !(f in SCOPES)) || args.filter((a) => a === "--yes").length > 1)
|
|
48
|
-
throw new CliError(RESET_USAGE, 2);
|
|
49
|
-
if (flags.length > 1)
|
|
50
|
-
throw new CliError("Pass only one of --sessions, --sandboxes, --all.", 2);
|
|
51
|
-
const scope = flags.length ? SCOPES[flags[0]] : "sessions";
|
|
52
|
-
const connection = await linkedConnection(projectRoot());
|
|
53
|
-
const tenant = connection.link?.tenant;
|
|
54
|
-
const target = tenant ? `Tenant ${tenant} (${connection.url})` : `the Tenant on ${connection.url}`;
|
|
55
|
-
const admin = managementClient(connection);
|
|
56
|
-
if (scope === "all" && !yes)
|
|
57
|
-
await confirmOrThrow(`Reset ALL data of ${target}? The Project link and credentials are kept. [y/N] `);
|
|
58
|
-
try {
|
|
59
|
-
await admin.tenant.reset({ scope, activeWork: "drain" });
|
|
60
|
-
}
|
|
61
|
-
catch (error) {
|
|
62
|
-
throw new CliError(error instanceof Error ? error.message : `Tenant reset failed: ${String(error)}`, 1);
|
|
63
|
-
}
|
|
64
|
-
console.log(`Reset ${target} (${scope}).`);
|
|
65
|
-
}
|
|
66
|
-
async function confirmOrThrow(prompt) {
|
|
67
|
-
if (!process.stdin.isTTY || !process.stdout.isTTY) {
|
|
68
|
-
throw new CliError("Confirmation required; pass --yes for non-interactive use.", 2);
|
|
69
|
-
}
|
|
70
|
-
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
71
|
-
try {
|
|
72
|
-
const answer = (await rl.question(prompt)).trim().toLowerCase();
|
|
73
|
-
if (answer !== "y" && answer !== "yes") {
|
|
74
|
-
throw new CliError("Cancelled.", 1);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
finally {
|
|
78
|
-
rl.close();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type ManagementClient } from "@nylorun/admin";
|
|
2
|
-
import { type ProjectCredentials, type ProjectLink as LinkFile } from "@nylorun/core/project";
|
|
3
|
-
/**
|
|
4
|
-
* The Project link (format 3), which `nylorun start` writes and `nylo` only reads with
|
|
5
|
-
* `@nylorun/core/project`'s reader. `tenantId` is information: the installation serves one
|
|
6
|
-
* Tenant, so nothing selects it.
|
|
7
|
-
*/
|
|
8
|
-
export type ProjectLink = LinkFile & {
|
|
9
|
-
format: 3;
|
|
10
|
-
};
|
|
11
|
-
/** The Project's link; one of an older nylorun (formats 0 to 2) is refused. */
|
|
12
|
-
export declare function readLink(projectRoot: string): Promise<ProjectLink | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* The Project's credentials (mode 0600), which `nylorun start` writes beside the link: the
|
|
15
|
-
* application key and its principal, and the management key and its principal when it issued
|
|
16
|
-
* one. A format 0 file's legacy `executors` map is ignored.
|
|
17
|
-
*/
|
|
18
|
-
export declare function readCredentials(projectRoot: string): Promise<ProjectCredentials | undefined>;
|
|
19
|
-
/** The installation `nylo` acts on: a Runtime URL, an application key and a management key. */
|
|
20
|
-
export interface LinkedConnection {
|
|
21
|
-
url: string;
|
|
22
|
-
/** The application key (Runtime API); absent when only a management key is set. */
|
|
23
|
-
key?: string;
|
|
24
|
-
/** The management key (Management API), when there is one. */
|
|
25
|
-
managementKey?: string;
|
|
26
|
-
/** The Project link it came from, when it came from one. */
|
|
27
|
-
link?: ProjectLink;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The Project's link and credentials, else `NYLORUN_RUNTIME_URL` with `NYLORUN_SERVER_KEY`, or
|
|
31
|
-
* `NYLORUN_MANAGEMENT_KEY`, or both; `NYLORUN_MANAGEMENT_KEY` also stands in for a Project
|
|
32
|
-
* credentials file without one. The installation serves one Tenant, so nothing names it.
|
|
33
|
-
*/
|
|
34
|
-
export declare function linkedConnection(projectRoot: string, env?: Readonly<Record<string, string | undefined>>): Promise<LinkedConnection>;
|
|
35
|
-
/** The Management API client of `connection`; refused without a management key. */
|
|
36
|
-
export declare function managementClient(connection: LinkedConnection): ManagementClient;
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { chmod } from "node:fs/promises";
|
|
2
|
-
import { createManagementClient } from "@nylorun/admin";
|
|
3
|
-
import { ProjectFileError, projectCredentialsPath, projectLinkPath, readProjectCredentials, readProjectLink, } from "@nylorun/core/project";
|
|
4
|
-
import { CliError } from "../../errors.js";
|
|
5
|
-
/** The Project's link; one of an older nylorun (formats 0 to 2) is refused. */
|
|
6
|
-
export async function readLink(projectRoot) {
|
|
7
|
-
const path = projectLinkPath(projectRoot);
|
|
8
|
-
let link;
|
|
9
|
-
try {
|
|
10
|
-
link = readProjectLink(projectRoot);
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
if (!(error instanceof ProjectFileError))
|
|
14
|
-
throw error;
|
|
15
|
-
throw new CliError(error.reason === "newer"
|
|
16
|
-
? `Project link at ${path} has an unsupported format. Upgrade nylorun.`
|
|
17
|
-
: `Invalid Project link at ${path}. Remove .nylorun/link.json and run "npx nylorun start".`, 1);
|
|
18
|
-
}
|
|
19
|
-
if (link === undefined)
|
|
20
|
-
return undefined;
|
|
21
|
-
if (link.format !== 3)
|
|
22
|
-
throw new CliError(`The Project link at ${path} is from an older nylorun. Run "npx nylorun start" in this project to link it again.`, 1);
|
|
23
|
-
return { ...link, format: 3 };
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The Project's credentials (mode 0600), which `nylorun start` writes beside the link: the
|
|
27
|
-
* application key and its principal, and the management key and its principal when it issued
|
|
28
|
-
* one. A format 0 file's legacy `executors` map is ignored.
|
|
29
|
-
*/
|
|
30
|
-
export async function readCredentials(projectRoot) {
|
|
31
|
-
const path = projectCredentialsPath(projectRoot);
|
|
32
|
-
let credentials;
|
|
33
|
-
try {
|
|
34
|
-
credentials = readProjectCredentials(projectRoot);
|
|
35
|
-
}
|
|
36
|
-
catch (error) {
|
|
37
|
-
if (!(error instanceof ProjectFileError))
|
|
38
|
-
throw error;
|
|
39
|
-
throw new CliError(error.reason === "newer"
|
|
40
|
-
? `Project credentials at ${path} have an unsupported format. Upgrade nylorun.`
|
|
41
|
-
: `Invalid Project credentials at ${path}. Remove .nylorun/credentials.json and run "npx nylorun start".`, 1);
|
|
42
|
-
}
|
|
43
|
-
if (credentials)
|
|
44
|
-
await chmod(path, 0o600);
|
|
45
|
-
return credentials;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* The Project's link and credentials, else `NYLORUN_RUNTIME_URL` with `NYLORUN_SERVER_KEY`, or
|
|
49
|
-
* `NYLORUN_MANAGEMENT_KEY`, or both; `NYLORUN_MANAGEMENT_KEY` also stands in for a Project
|
|
50
|
-
* credentials file without one. The installation serves one Tenant, so nothing names it.
|
|
51
|
-
*/
|
|
52
|
-
export async function linkedConnection(projectRoot, env = process.env) {
|
|
53
|
-
const link = await readLink(projectRoot);
|
|
54
|
-
const credentials = await readCredentials(projectRoot);
|
|
55
|
-
const managementKey = env.NYLORUN_MANAGEMENT_KEY?.trim();
|
|
56
|
-
if (link && credentials) {
|
|
57
|
-
const management = credentials.managementKey ?? managementKey;
|
|
58
|
-
return {
|
|
59
|
-
url: link.hostUrl,
|
|
60
|
-
key: credentials.applicationKey,
|
|
61
|
-
...(management ? { managementKey: management } : {}),
|
|
62
|
-
link,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const url = env.NYLORUN_RUNTIME_URL?.trim();
|
|
66
|
-
const key = env.NYLORUN_SERVER_KEY?.trim();
|
|
67
|
-
if (url && (key || managementKey))
|
|
68
|
-
return {
|
|
69
|
-
url: url.replace(/\/$/, ""),
|
|
70
|
-
...(key ? { key } : {}),
|
|
71
|
-
...(managementKey ? { managementKey } : {}),
|
|
72
|
-
};
|
|
73
|
-
throw new CliError(`No Project link in ${projectRoot}. Run "npx nylorun start" in this project to start its Tenant and link it, or set NYLORUN_RUNTIME_URL and NYLORUN_SERVER_KEY (or NYLORUN_MANAGEMENT_KEY).`, 1);
|
|
74
|
-
}
|
|
75
|
-
/** The Management API client of `connection`; refused without a management key. */
|
|
76
|
-
export function managementClient(connection) {
|
|
77
|
-
if (!connection.managementKey)
|
|
78
|
-
throw new CliError(`No management key for the Tenant at ${connection.url}: run npx nylorun start, or set NYLORUN_MANAGEMENT_KEY.`, 1);
|
|
79
|
-
return createManagementClient({ url: connection.url, key: connection.managementKey });
|
|
80
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { findProjectRoot } from "@nylorun/core/project";
|
|
2
|
-
import { readCredentials, readLink } from "./connection.js";
|
|
3
|
-
/** Two `export` lines for `nylo env` (was `nylorun status --env`, F2-7). */
|
|
4
|
-
export async function printLinkedEnvExports(projectRoot = process.cwd()) {
|
|
5
|
-
const root = findProjectRoot(projectRoot) ?? projectRoot;
|
|
6
|
-
const link = await readLink(root);
|
|
7
|
-
const credentials = await readCredentials(root);
|
|
8
|
-
if (!link || !credentials) {
|
|
9
|
-
console.log('# No Project link in this directory. Run "npx nylorun start" in this project to start its Tenant and link it.');
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
console.log(`export NYLORUN_RUNTIME_URL=${shellQuote(link.hostUrl)}`);
|
|
13
|
-
console.log(`export NYLORUN_SERVER_KEY=${shellQuote(credentials.applicationKey)}`);
|
|
14
|
-
}
|
|
15
|
-
export function shellQuote(value) {
|
|
16
|
-
if (/^[A-Za-z0-9_./:-]+$/.test(value))
|
|
17
|
-
return value;
|
|
18
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
19
|
-
}
|
package/dist/stack/mcp.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { McpPreview } from "@nylorun/core/contracts";
|
|
2
|
-
import { type StackDeps } from "./commands.js";
|
|
3
|
-
export declare const mcpUsage = " mcp inspect <url> [--server <name>] [--vault <id>] [--sse] [--tenant <name>] [--json]\n list a remote MCP server's tools with the installation vault's\n credential for <url>: model names, schema sizes, renames, or\n that it needs a person's sign-in (the Runtime calls no tool)";
|
|
4
|
-
/** What the removed `connect` subcommand says since protocol 10. */
|
|
5
|
-
export declare const MCP_CONNECT_REMOVED = "The connect subcommand of nylorun mcp was removed with MCP OAuth (protocol 10): add the server's key to an installation vault as a bearer or headers credential (Studio's Credentials page, or @nylorun/admin), or reach a server that needs a person's sign-in through a gateway (a credential with via). See its tools with nylorun mcp inspect <url>.";
|
|
6
|
-
/** A preview as a person reads it: the server, a table of tools, the renames, or the sign-in hint. */
|
|
7
|
-
export declare function previewLines(preview: McpPreview): string[];
|
|
8
|
-
/** `nylorun mcp <inspect|connect> ...` */
|
|
9
|
-
export declare function mcpCommand(deps: StackDeps, args: readonly string[]): Promise<number>;
|
package/dist/stack/sandbox.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type StackDeps } from "./commands.js";
|
|
2
|
-
export declare const sandboxUsage = " sandbox ls [--tenant <name>] [--label <key=value>]... [--json]\n the Tenant's sandboxes: id, kind, state, attached sessions and labels\n sandbox rm <id> [--tenant <name>] delete a sandbox and its files (refused while a turn runs in it)\n sandbox enable --context <name> [--tenant <name>] [--host-address <ip>] [--bind-address <ip>] [--no-pull]\n run the Tenant's sandboxes as pods on that kubeconfig context (agent-sandbox v1.0.5)\n sandbox disable [--tenant <name>] [--delete-namespace]\n stop the sandboxes service and forget the cluster\n sandbox status [--tenant <name>] [--json]\n the cluster, the sandboxes service's readiness and what it reports";
|
|
3
|
-
/** `nylorun sandbox <ls|rm|enable|disable|status> ...` */
|
|
4
|
-
export declare function sandboxCommand(deps: StackDeps, args: readonly string[]): Promise<number>;
|
package/dist/stack/sandbox.js
DELETED
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nylorun sandbox ls | rm`: the running local Tenant's sandbox resources (Host feature
|
|
3
|
-
* `sandboxes`), through its Tenant API with an operator key (`runningTenantApi`). Neither starts the
|
|
4
|
-
* Tenant. `nylorun sandbox enable|disable|status` (sandbox pods on a cluster, F7.2) live in
|
|
5
|
-
* `../sandbox/commands.ts`.
|
|
6
|
-
*/
|
|
7
|
-
import { PROTOCOL_HEADER, PROTOCOL_VERSION } from "@nylorun/core/compatibility";
|
|
8
|
-
import { CliError } from "../errors.js";
|
|
9
|
-
import { runSandboxCommand, sandboxUsage as clusterUsage } from "../sandbox/commands.js";
|
|
10
|
-
import { spawnKubectl } from "../sandbox/kubectl.js";
|
|
11
|
-
import { parseStackFlags, runningTenantApi } from "./commands.js";
|
|
12
|
-
export const sandboxUsage = ` sandbox ls [--tenant <name>] [--label <key=value>]... [--json]
|
|
13
|
-
the Tenant's sandboxes: id, kind, state, attached sessions and labels
|
|
14
|
-
sandbox rm <id> [--tenant <name>] delete a sandbox and its files (refused while a turn runs in it)
|
|
15
|
-
${clusterUsage}`;
|
|
16
|
-
const usageError = (message) => new CliError(message, 2);
|
|
17
|
-
async function call(deps, api, method, path) {
|
|
18
|
-
const response = await deps.fetch(`${api.runtimeUrl}${path}`, {
|
|
19
|
-
method,
|
|
20
|
-
headers: {
|
|
21
|
-
authorization: `Bearer ${api.applicationKey}`,
|
|
22
|
-
[PROTOCOL_HEADER]: String(PROTOCOL_VERSION),
|
|
23
|
-
accept: "application/json",
|
|
24
|
-
},
|
|
25
|
-
redirect: "error",
|
|
26
|
-
signal: AbortSignal.timeout(15_000),
|
|
27
|
-
});
|
|
28
|
-
const body = (await response.json().catch(() => ({})));
|
|
29
|
-
if (response.status === 404 && path === "/v1/sandboxes")
|
|
30
|
-
throw new CliError(`Tenant ${api.name} runs a Runtime without sandboxes. Update it: npx nylorun@latest start.`, 1);
|
|
31
|
-
if (!response.ok && response.status !== 404)
|
|
32
|
-
throw new CliError(`${method} ${path} returned ${response.status}${typeof body.message === "string" ? `: ${body.message}` : ""}`, 1);
|
|
33
|
-
return { status: response.status, body };
|
|
34
|
-
}
|
|
35
|
-
function labelsText(labels) {
|
|
36
|
-
const entries = Object.entries(labels);
|
|
37
|
-
return entries.length === 0 ? "-" : entries.map(([key, value]) => `${key}=${value}`).join(",");
|
|
38
|
-
}
|
|
39
|
-
async function ls(deps, args) {
|
|
40
|
-
const usage = "nylorun sandbox ls [--tenant <name>] [--label <key=value>]... [--json]";
|
|
41
|
-
const flags = parseStackFlags(args, { booleans: ["--json"], values: ["--tenant"], lists: ["--label"] }, usage);
|
|
42
|
-
if (flags.rest.length)
|
|
43
|
-
throw usageError(`Usage: ${usage}`);
|
|
44
|
-
const query = new URLSearchParams();
|
|
45
|
-
for (const label of flags.lists.get("--label") ?? []) {
|
|
46
|
-
if (label.indexOf("=") <= 0)
|
|
47
|
-
throw usageError(`--label must be key=value, not ${label}`);
|
|
48
|
-
query.append("label", label);
|
|
49
|
-
}
|
|
50
|
-
const name = flags.values.get("--tenant");
|
|
51
|
-
const api = await runningTenantApi(deps, name === undefined ? {} : { name });
|
|
52
|
-
const search = query.toString();
|
|
53
|
-
const { body } = await call(deps, api, "GET", `/v1/sandboxes${search ? `?${search}` : ""}`);
|
|
54
|
-
const sandboxes = (body.sandboxes ?? []);
|
|
55
|
-
if (flags.booleans.has("--json")) {
|
|
56
|
-
deps.out(JSON.stringify(sandboxes, null, 2));
|
|
57
|
-
return 0;
|
|
58
|
-
}
|
|
59
|
-
if (sandboxes.length === 0) {
|
|
60
|
-
deps.out(`No sandboxes on Tenant ${api.name}.`);
|
|
61
|
-
return 0;
|
|
62
|
-
}
|
|
63
|
-
const rows = [
|
|
64
|
-
["ID", "KIND", "STATE", "SESSIONS", "LABELS"],
|
|
65
|
-
...sandboxes.map((sandbox) => [
|
|
66
|
-
sandbox.id,
|
|
67
|
-
sandbox.kind,
|
|
68
|
-
sandbox.state,
|
|
69
|
-
String(sandbox.sessions.length),
|
|
70
|
-
labelsText(sandbox.labels),
|
|
71
|
-
]),
|
|
72
|
-
];
|
|
73
|
-
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
74
|
-
for (const row of rows)
|
|
75
|
-
deps.out(row
|
|
76
|
-
.map((cell, column) => (column === row.length - 1 ? cell : cell.padEnd(widths[column])))
|
|
77
|
-
.join(" "));
|
|
78
|
-
return 0;
|
|
79
|
-
}
|
|
80
|
-
async function rm(deps, args) {
|
|
81
|
-
const usage = "nylorun sandbox rm <id> [--tenant <name>]";
|
|
82
|
-
const flags = parseStackFlags(args, { values: ["--tenant"] }, usage);
|
|
83
|
-
if (flags.rest.length !== 1)
|
|
84
|
-
throw usageError(`Usage: ${usage}`);
|
|
85
|
-
const id = flags.rest[0];
|
|
86
|
-
const name = flags.values.get("--tenant");
|
|
87
|
-
const api = await runningTenantApi(deps, name === undefined ? {} : { name });
|
|
88
|
-
const { status, body } = await call(deps, api, "DELETE", `/v1/sandboxes/${encodeURIComponent(id)}`);
|
|
89
|
-
if (status === 404 || body.deleted !== true) {
|
|
90
|
-
deps.err(`No sandbox ${id} on Tenant ${api.name}.`);
|
|
91
|
-
return 1;
|
|
92
|
-
}
|
|
93
|
-
deps.out(`Deleted sandbox ${id} and its files.`);
|
|
94
|
-
return 0;
|
|
95
|
-
}
|
|
96
|
-
/** `nylorun sandbox <ls|rm|enable|disable|status> ...` */
|
|
97
|
-
export async function sandboxCommand(deps, args) {
|
|
98
|
-
const [sub, ...rest] = args;
|
|
99
|
-
if (sub === "ls" || sub === "list")
|
|
100
|
-
return ls(deps, rest);
|
|
101
|
-
if (sub === "rm" || sub === "delete")
|
|
102
|
-
return rm(deps, rest);
|
|
103
|
-
if (sub === "enable" || sub === "disable" || sub === "status")
|
|
104
|
-
return runSandboxCommand(args, { stack: deps, kubectl: spawnKubectl(deps.env) });
|
|
105
|
-
throw usageError(`Usage:\n${sandboxUsage}`);
|
|
106
|
-
}
|