@ornncompute/cli 1.0.293 → 1.0.295
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/README.md +3 -2
- package/package.json +1 -1
- package/src/admin-node-diagnostics.mjs +22 -4
- package/src/admin-ssh.mjs +8 -16
- package/vendor/capabilities/cli.js +13 -6
package/README.md
CHANGED
|
@@ -569,8 +569,9 @@ request conflicts, and an expired incomplete request requires a new key.
|
|
|
569
569
|
The upload replay contract requires the matching gateway/orchestrator release;
|
|
570
570
|
see [the service contract](../../services/orchestrator/README.md#file-upload-replay-and-usage).
|
|
571
571
|
|
|
572
|
-
For `ornn admin ssh <node-id>`, including
|
|
573
|
-
nodes, and CA trust setup, see the
|
|
572
|
+
For `ornn admin ssh <node-id>`, including `--user` for custom accounts,
|
|
573
|
+
one-off commands, private nodes, and CA trust setup, see the
|
|
574
|
+
[staff SSH procedure](../../docs/cli.md#staff-ssh).
|
|
574
575
|
|
|
575
576
|
Gateway-bound connections resolve their gateway before producing SSH commands.
|
|
576
577
|
Forwarded endpoints remain a single SSH destination. Supplier-provided jump hosts
|
package/package.json
CHANGED
|
@@ -4,7 +4,8 @@ import { createHash } from "node:crypto";
|
|
|
4
4
|
import { ADMIN_MUTATION_SAFETY, AdminMutationError, runAdminMutation } from "./admin-mutations.mjs";
|
|
5
5
|
|
|
6
6
|
const DIAGNOSE_USAGE = "Usage: ornn admin nodes diagnose <node-id>";
|
|
7
|
-
|
|
7
|
+
const SSH_USAGE =
|
|
8
|
+
"Usage: ornn admin ssh <node-id> [--user USER] [--command COMMAND --timeout DURATION]";
|
|
8
9
|
const OUTPUT_TRUNCATION_MARKER = "\n[ornn] output truncated";
|
|
9
10
|
|
|
10
11
|
function usageError(message, field) {
|
|
@@ -71,19 +72,34 @@ export function parseAdminNodeDiagnoseArgs(argv) {
|
|
|
71
72
|
};
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
export function
|
|
75
|
+
export function parseAdminSshArgs(argv) {
|
|
75
76
|
const { options, positionals } = parseOptions(
|
|
76
77
|
argv,
|
|
77
|
-
new Set(["command", "timeout", "idempotency-key"]),
|
|
78
|
+
new Set(["user", "command", "timeout", "idempotency-key"]),
|
|
78
79
|
SSH_USAGE
|
|
79
80
|
);
|
|
80
81
|
if (positionals.length !== 1 || !positionals[0]) throw usageError(SSH_USAGE, "node-id");
|
|
82
|
+
const username = options.user;
|
|
83
|
+
if (username !== undefined && !/^[A-Za-z_][A-Za-z0-9_.-]{0,31}$/.test(username)) {
|
|
84
|
+
throw usageError("Provide a valid SSH username with --user.", "user");
|
|
85
|
+
}
|
|
86
|
+
const input = { node_id: positionals[0], ...(username === undefined ? {} : { username }) };
|
|
87
|
+
if (
|
|
88
|
+
options.command === undefined &&
|
|
89
|
+
options.timeout === undefined &&
|
|
90
|
+
options["idempotency-key"] === undefined
|
|
91
|
+
) {
|
|
92
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(input.node_id)) {
|
|
93
|
+
throw usageError(SSH_USAGE, "node-id");
|
|
94
|
+
}
|
|
95
|
+
return { input };
|
|
96
|
+
}
|
|
81
97
|
if (typeof options.command !== "string" || options.command.length === 0) {
|
|
82
98
|
throw usageError(`${SSH_USAGE}\n--command is required and must not be empty.`, "command");
|
|
83
99
|
}
|
|
84
100
|
return {
|
|
85
101
|
input: {
|
|
86
|
-
|
|
102
|
+
...input,
|
|
87
103
|
command: options.command,
|
|
88
104
|
timeout_seconds: timeoutSeconds(options.timeout),
|
|
89
105
|
},
|
|
@@ -326,6 +342,7 @@ export async function runAdminSshCommand({ input, mutation, runtime, execute, fe
|
|
|
326
342
|
title: "Execute unrestricted remote command",
|
|
327
343
|
fields: [
|
|
328
344
|
...reviewFields(target),
|
|
345
|
+
{ label: "SSH user", value: input.username ?? "admin" },
|
|
329
346
|
{ label: "Exact command", value: JSON.stringify(input.command) },
|
|
330
347
|
{
|
|
331
348
|
label: "Command UTF-8 bytes",
|
|
@@ -343,6 +360,7 @@ export async function runAdminSshCommand({ input, mutation, runtime, execute, fe
|
|
|
343
360
|
execute(
|
|
344
361
|
{
|
|
345
362
|
node_id: input.node_id,
|
|
363
|
+
...(input.username === undefined ? {} : { node_username: input.username }),
|
|
346
364
|
command: input.command,
|
|
347
365
|
timeout_seconds: input.timeout_seconds,
|
|
348
366
|
},
|
package/src/admin-ssh.mjs
CHANGED
|
@@ -6,11 +6,7 @@ import { isIP } from "node:net";
|
|
|
6
6
|
import { constants, tmpdir } from "node:os";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { ADMIN_MUTATION_SAFETY } from "./admin-mutations.mjs";
|
|
9
|
-
import {
|
|
10
|
-
parseAdminSshCommandArgs,
|
|
11
|
-
runAdminSshCommand,
|
|
12
|
-
SSH_USAGE,
|
|
13
|
-
} from "./admin-node-diagnostics.mjs";
|
|
9
|
+
import { parseAdminSshArgs, runAdminSshCommand } from "./admin-node-diagnostics.mjs";
|
|
14
10
|
import { openSshRelay } from "./admin-ssh-relay.mjs";
|
|
15
11
|
import { forwardSignals } from "./signals.mjs";
|
|
16
12
|
|
|
@@ -28,7 +24,7 @@ function run(program, args, signal) {
|
|
|
28
24
|
});
|
|
29
25
|
}
|
|
30
26
|
|
|
31
|
-
async function supplierJumpArguments(fetch, node, host, port, signal) {
|
|
27
|
+
async function supplierJumpArguments(fetch, node, host, port, username, signal) {
|
|
32
28
|
if (node.ssh_relay_configured === true || !node.ssh_gateway_id) return [];
|
|
33
29
|
const gateway = await orchestrator.getSupplierGateway(fetch, node.ssh_gateway_id, signal);
|
|
34
30
|
if (gateway?.id !== node.ssh_gateway_id) {
|
|
@@ -51,7 +47,7 @@ async function supplierJumpArguments(fetch, node, host, port, signal) {
|
|
|
51
47
|
) {
|
|
52
48
|
throw new Error("The node's SSH jump gateway has invalid connection details.");
|
|
53
49
|
}
|
|
54
|
-
const args = sshArguments({ host, port, username
|
|
50
|
+
const args = sshArguments({ host, port, username, gateway });
|
|
55
51
|
return [...args.slice(0, 2), "-o", "ControlPath=none"];
|
|
56
52
|
}
|
|
57
53
|
|
|
@@ -63,6 +59,7 @@ export async function openAdminSsh(
|
|
|
63
59
|
const node = await orchestrator.getNode(fetch, input.node_id);
|
|
64
60
|
const host = node.ip;
|
|
65
61
|
const port = node.port ?? 22;
|
|
62
|
+
const username = input.username ?? "admin";
|
|
66
63
|
if (
|
|
67
64
|
typeof host !== "string" ||
|
|
68
65
|
!/^[a-zA-Z0-9.:_-]+$/.test(host) ||
|
|
@@ -85,7 +82,7 @@ export async function openAdminSsh(
|
|
|
85
82
|
controller.abort();
|
|
86
83
|
});
|
|
87
84
|
try {
|
|
88
|
-
const jumpOptions = await supplierJumpArguments(fetch, node, host, port, signal);
|
|
85
|
+
const jumpOptions = await supplierJumpArguments(fetch, node, host, port, username, signal);
|
|
89
86
|
directory = await mkdtemp(join(tmpdir(), "ornn-ssh-"));
|
|
90
87
|
const key = join(directory, "identity");
|
|
91
88
|
const generated = await runProcess(
|
|
@@ -98,7 +95,7 @@ export async function openAdminSsh(
|
|
|
98
95
|
const issued = await orchestrator.issueNodeSshCertificate(
|
|
99
96
|
(path, init) => fetch(path, { ...init, signal }),
|
|
100
97
|
input.node_id,
|
|
101
|
-
{ public_key }
|
|
98
|
+
{ public_key, ...(input.username === undefined ? {} : { username }) }
|
|
102
99
|
);
|
|
103
100
|
signal.throwIfAborted();
|
|
104
101
|
if (
|
|
@@ -136,7 +133,7 @@ export async function openAdminSsh(
|
|
|
136
133
|
...relayOptions,
|
|
137
134
|
...jumpOptions,
|
|
138
135
|
"-l",
|
|
139
|
-
|
|
136
|
+
username,
|
|
140
137
|
host,
|
|
141
138
|
],
|
|
142
139
|
signal
|
|
@@ -160,12 +157,7 @@ export const adminSshHandlers = [
|
|
|
160
157
|
{
|
|
161
158
|
capabilityId: "node.ssh",
|
|
162
159
|
safety: ADMIN_MUTATION_SAFETY.eligibleHumanOnly,
|
|
163
|
-
parse
|
|
164
|
-
if (argv.length !== 1) return parseAdminSshCommandArgs(argv);
|
|
165
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(argv[0]))
|
|
166
|
-
throw new Error(SSH_USAGE);
|
|
167
|
-
return { input: { node_id: argv[0] } };
|
|
168
|
-
},
|
|
160
|
+
parse: parseAdminSshArgs,
|
|
169
161
|
run: (context) =>
|
|
170
162
|
context.input.command === undefined ? openAdminSsh(context) : runAdminSshCommand(context),
|
|
171
163
|
},
|
|
@@ -6661,8 +6661,10 @@ var nodeLifecycleInput = z29.object({
|
|
|
6661
6661
|
wait: z29.boolean().optional(),
|
|
6662
6662
|
timeout_seconds: z29.number().positive().optional()
|
|
6663
6663
|
});
|
|
6664
|
+
var nodeSshUsername = z29.string().regex(/^[A-Za-z_][A-Za-z0-9_.-]{0,31}$/);
|
|
6664
6665
|
var nodeSshRemoteInput = z29.object({
|
|
6665
6666
|
node_id: z29.string().min(1).optional(),
|
|
6667
|
+
node_username: nodeSshUsername.optional(),
|
|
6666
6668
|
host: z29.string().min(1).optional(),
|
|
6667
6669
|
username: z29.string().min(1).optional(),
|
|
6668
6670
|
port: z29.number().int().min(1).max(65535).optional(),
|
|
@@ -6866,13 +6868,14 @@ var nodeSshInput = z29.object({
|
|
|
6866
6868
|
message: "node_id must be an exact canonical node ID without surrounding whitespace"
|
|
6867
6869
|
}),
|
|
6868
6870
|
command: z29.string().min(1),
|
|
6869
|
-
timeout_seconds: z29.number().int().min(1).max(900)
|
|
6871
|
+
timeout_seconds: z29.number().int().min(1).max(900),
|
|
6872
|
+
node_username: nodeSshUsername.optional()
|
|
6870
6873
|
});
|
|
6871
6874
|
var nodeSshCapability = defineCapability({
|
|
6872
6875
|
id: "node.ssh",
|
|
6873
6876
|
domain: "fleet",
|
|
6874
6877
|
roles: ["admin"],
|
|
6875
|
-
description: "Admin-only. SSH into a node and run one unrestricted command from the orchestrator. Pass node_id for an enrolled node (uses its stored admin key), or host + private_key (+ optional username, default root, and port, default 22) for any host, including one not enrolled yet. Always pass timeout_seconds. Not an interactive shell; staff open one locally with ornn admin ssh <node-id>. On NVIDIA hosts use nvidia-smi; on AMD Instinct use amd-smi. Runs on the tool call \u2014 no confirm, no y/N.",
|
|
6878
|
+
description: "Admin-only. SSH into a node and run one unrestricted command from the orchestrator. Pass node_id for an enrolled node (uses its stored admin key) and optional node_username (default admin), or host + private_key (+ optional username, default root, and port, default 22) for any host, including one not enrolled yet. Always pass timeout_seconds. Not an interactive shell; staff open one locally with ornn admin ssh <node-id>. On NVIDIA hosts use nvidia-smi; on AMD Instinct use amd-smi. Runs on the tool call \u2014 no confirm, no y/N.",
|
|
6876
6879
|
mutation: "immediate",
|
|
6877
6880
|
cli: {
|
|
6878
6881
|
command: ["admin", "ssh"],
|
|
@@ -6881,10 +6884,10 @@ var nodeSshCapability = defineCapability({
|
|
|
6881
6884
|
category: "journey",
|
|
6882
6885
|
arguments: "semantic",
|
|
6883
6886
|
outcome: "Open an SSH session to a node that trusts the SSH CA with a 15-minute certificate, or run one exact command on one exact node.",
|
|
6884
|
-
human: "ornn admin ssh <node-id> [--command COMMAND --timeout DURATION]",
|
|
6887
|
+
human: "ornn admin ssh <node-id> [--user USER] [--command COMMAND --timeout DURATION]",
|
|
6885
6888
|
automation: "Unavailable in machine and redirected modes; use an eligible human terminal.",
|
|
6886
6889
|
acceptedReferences: ["canonical node ID"],
|
|
6887
|
-
review: "Exact node, lifecycle, reachability, command bytes, and timeout."
|
|
6890
|
+
review: "Exact node, SSH user, lifecycle, reachability, command bytes, and timeout."
|
|
6888
6891
|
},
|
|
6889
6892
|
execute: async (ctx, input) => {
|
|
6890
6893
|
const parsed = nodeSshInput.parse(input);
|
|
@@ -6899,6 +6902,7 @@ var nodeSshCapability = defineCapability({
|
|
|
6899
6902
|
type: "object",
|
|
6900
6903
|
properties: {
|
|
6901
6904
|
node_id: { type: "string", description: "Enrolled node UUID from nodes.list." },
|
|
6905
|
+
node_username: { type: "string", description: "Node SSH username. Defaults to admin." },
|
|
6902
6906
|
command: { type: "string", description: "Exact shell command to run. No allowlist." },
|
|
6903
6907
|
timeout_seconds: {
|
|
6904
6908
|
type: "integer",
|
|
@@ -6910,10 +6914,13 @@ var nodeSshCapability = defineCapability({
|
|
|
6910
6914
|
},
|
|
6911
6915
|
input: nodeSshInput,
|
|
6912
6916
|
execute: async (ctx, input) => {
|
|
6913
|
-
const { yes: _yes, ...parsed } = nodeSshRemoteInput.parse(input);
|
|
6917
|
+
const { yes: _yes, node_id, node_username, ...parsed } = nodeSshRemoteInput.parse(input);
|
|
6918
|
+
const id = node_id?.trim();
|
|
6919
|
+
if (node_username && !id)
|
|
6920
|
+
throw new Error("node_id is required with node_username.");
|
|
6914
6921
|
return runRemote(ctx.fetch, {
|
|
6915
6922
|
...parsed,
|
|
6916
|
-
node_id:
|
|
6923
|
+
...id && node_username ? { node_target: { node_id: id, username: node_username } } : { node_id: id },
|
|
6917
6924
|
host: parsed.host?.trim()
|
|
6918
6925
|
});
|
|
6919
6926
|
}
|