nylorun 0.14.0-beta → 0.15.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +105 -0
- package/README.md +226 -144
- 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 +7 -2
- package/dist/client/doctor.js +14 -13
- 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/{stack → client}/mcp.d.ts +2 -2
- package/dist/{stack → client}/mcp.js +14 -12
- 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/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 +12 -12
- 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/telemetry.d.ts +2 -2
- package/dist/telemetry.js +4 -4
- package/package.json +6 -5
- 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 -82
- 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/sandbox.d.ts +0 -4
- package/dist/stack/sandbox.js +0 -107
|
@@ -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/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 Environments: id, kind, state, sessions and labels\n sandbox rm <id> [--tenant <name>] delete an Environment: its sandbox, files and vault\n (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,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `nylorun sandbox ls | rm`: the running local Tenant's Environments (protocol 11: each holds one
|
|
3
|
-
* sandbox and one vault), through its Runtime API with the application key (`runningTenantApi`).
|
|
4
|
-
* Neither starts the Tenant. `nylorun sandbox enable|disable|status` (sandbox pods on a cluster,
|
|
5
|
-
* F7.2) live in `../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 Environments: id, kind, state, sessions and labels
|
|
14
|
-
sandbox rm <id> [--tenant <name>] delete an Environment: its sandbox, files and vault
|
|
15
|
-
(refused while a turn runs in it)
|
|
16
|
-
${clusterUsage}`;
|
|
17
|
-
const usageError = (message) => new CliError(message, 2);
|
|
18
|
-
async function call(deps, api, method, path) {
|
|
19
|
-
const response = await deps.fetch(`${api.runtimeUrl}${path}`, {
|
|
20
|
-
method,
|
|
21
|
-
headers: {
|
|
22
|
-
authorization: `Bearer ${api.applicationKey}`,
|
|
23
|
-
[PROTOCOL_HEADER]: String(PROTOCOL_VERSION),
|
|
24
|
-
accept: "application/json",
|
|
25
|
-
},
|
|
26
|
-
redirect: "error",
|
|
27
|
-
signal: AbortSignal.timeout(15_000),
|
|
28
|
-
});
|
|
29
|
-
const body = (await response.json().catch(() => ({})));
|
|
30
|
-
if (response.status === 404 && /^\/v1\/environments(\?|$)/.test(path))
|
|
31
|
-
throw new CliError(`Tenant ${api.name} runs a Runtime without Environments. Update it: npx nylorun@latest start.`, 1);
|
|
32
|
-
if (!response.ok && response.status !== 404)
|
|
33
|
-
throw new CliError(`${method} ${path} returned ${response.status}${typeof body.message === "string" ? `: ${body.message}` : ""}`, 1);
|
|
34
|
-
return { status: response.status, body };
|
|
35
|
-
}
|
|
36
|
-
function labelsText(labels) {
|
|
37
|
-
const entries = Object.entries(labels);
|
|
38
|
-
return entries.length === 0 ? "-" : entries.map(([key, value]) => `${key}=${value}`).join(",");
|
|
39
|
-
}
|
|
40
|
-
async function ls(deps, args) {
|
|
41
|
-
const usage = "nylorun sandbox ls [--tenant <name>] [--label <key=value>]... [--json]";
|
|
42
|
-
const flags = parseStackFlags(args, { booleans: ["--json"], values: ["--tenant"], lists: ["--label"] }, usage);
|
|
43
|
-
if (flags.rest.length)
|
|
44
|
-
throw usageError(`Usage: ${usage}`);
|
|
45
|
-
const query = new URLSearchParams();
|
|
46
|
-
for (const label of flags.lists.get("--label") ?? []) {
|
|
47
|
-
if (label.indexOf("=") <= 0)
|
|
48
|
-
throw usageError(`--label must be key=value, not ${label}`);
|
|
49
|
-
query.append("label", label);
|
|
50
|
-
}
|
|
51
|
-
const name = flags.values.get("--tenant");
|
|
52
|
-
const api = await runningTenantApi(deps, name === undefined ? {} : { name });
|
|
53
|
-
const search = query.toString();
|
|
54
|
-
const { body } = await call(deps, api, "GET", `/v1/environments${search ? `?${search}` : ""}`);
|
|
55
|
-
const environments = (body.environments ?? []);
|
|
56
|
-
if (flags.booleans.has("--json")) {
|
|
57
|
-
deps.out(JSON.stringify(environments, null, 2));
|
|
58
|
-
return 0;
|
|
59
|
-
}
|
|
60
|
-
if (environments.length === 0) {
|
|
61
|
-
deps.out(`No Environments on Tenant ${api.name}.`);
|
|
62
|
-
return 0;
|
|
63
|
-
}
|
|
64
|
-
const rows = [
|
|
65
|
-
["ID", "KIND", "STATE", "SESSIONS", "LABELS"],
|
|
66
|
-
...environments.map((environment) => [
|
|
67
|
-
environment.id,
|
|
68
|
-
environment.kind,
|
|
69
|
-
environment.state,
|
|
70
|
-
String(environment.sessions.length),
|
|
71
|
-
labelsText(environment.labels),
|
|
72
|
-
]),
|
|
73
|
-
];
|
|
74
|
-
const widths = rows[0].map((_, column) => Math.max(...rows.map((row) => row[column].length)));
|
|
75
|
-
for (const row of rows)
|
|
76
|
-
deps.out(row
|
|
77
|
-
.map((cell, column) => (column === row.length - 1 ? cell : cell.padEnd(widths[column])))
|
|
78
|
-
.join(" "));
|
|
79
|
-
return 0;
|
|
80
|
-
}
|
|
81
|
-
async function rm(deps, args) {
|
|
82
|
-
const usage = "nylorun sandbox rm <id> [--tenant <name>]";
|
|
83
|
-
const flags = parseStackFlags(args, { values: ["--tenant"] }, usage);
|
|
84
|
-
if (flags.rest.length !== 1)
|
|
85
|
-
throw usageError(`Usage: ${usage}`);
|
|
86
|
-
const id = flags.rest[0];
|
|
87
|
-
const name = flags.values.get("--tenant");
|
|
88
|
-
const api = await runningTenantApi(deps, name === undefined ? {} : { name });
|
|
89
|
-
const { status, body } = await call(deps, api, "DELETE", `/v1/environments/${encodeURIComponent(id)}`);
|
|
90
|
-
if (status === 404 || body.deleted !== true) {
|
|
91
|
-
deps.err(`No Environment ${id} on Tenant ${api.name}.`);
|
|
92
|
-
return 1;
|
|
93
|
-
}
|
|
94
|
-
deps.out(`Deleted Environment ${id}: its sandbox, files and vault.`);
|
|
95
|
-
return 0;
|
|
96
|
-
}
|
|
97
|
-
/** `nylorun sandbox <ls|rm|enable|disable|status> ...` */
|
|
98
|
-
export async function sandboxCommand(deps, args) {
|
|
99
|
-
const [sub, ...rest] = args;
|
|
100
|
-
if (sub === "ls" || sub === "list")
|
|
101
|
-
return ls(deps, rest);
|
|
102
|
-
if (sub === "rm" || sub === "delete")
|
|
103
|
-
return rm(deps, rest);
|
|
104
|
-
if (sub === "enable" || sub === "disable" || sub === "status")
|
|
105
|
-
return runSandboxCommand(args, { stack: deps, kubectl: spawnKubectl(deps.env) });
|
|
106
|
-
throw usageError(`Usage:\n${sandboxUsage}`);
|
|
107
|
-
}
|