@ornncompute/cli 1.0.257 → 1.0.259

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 CHANGED
@@ -529,8 +529,8 @@ request conflicts, and an expired incomplete request requires a new key.
529
529
  The upload replay contract requires the matching gateway/orchestrator release;
530
530
  see [the service contract](../../services/orchestrator/README.md#file-upload-replay-and-usage).
531
531
 
532
- For `ornn admin ssh <node-id>`, including private nodes and CA trust setup, see
533
- the [staff SSH procedure](../../docs/cli.md#staff-ssh).
532
+ For `ornn admin ssh <node-id>`, including one-off `--command` runs, private
533
+ nodes, and CA trust setup, see the [staff SSH procedure](../../docs/cli.md#staff-ssh).
534
534
 
535
535
  Gateway-bound connections resolve their gateway before producing SSH commands.
536
536
  Forwarded endpoints remain a single SSH destination. Supplier-provided jump hosts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornncompute/cli",
3
- "version": "1.0.257",
3
+ "version": "1.0.259",
4
4
  "description": "Command-line interface for Ornn compute access workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -4,7 +4,7 @@ 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
- const EXEC_USAGE = "Usage: ornn admin nodes exec <node-id> --command COMMAND --timeout DURATION";
7
+ export const SSH_USAGE = "Usage: ornn admin ssh <node-id> [--command COMMAND --timeout DURATION]";
8
8
  const OUTPUT_TRUNCATION_MARKER = "\n[ornn] output truncated";
9
9
 
10
10
  function usageError(message, field) {
@@ -46,7 +46,7 @@ function parseOptions(argv, allowed, usage) {
46
46
 
47
47
  function timeoutSeconds(value) {
48
48
  if (typeof value !== "string")
49
- throw usageError(`${EXEC_USAGE}\n--timeout is required.`, "timeout");
49
+ throw usageError(`${SSH_USAGE}\n--timeout is required.`, "timeout");
50
50
  const match = value.match(/^([1-9]\d*)(s|m)?$/);
51
51
  if (!match) {
52
52
  throw usageError("--timeout must be whole seconds or minutes from 1s through 15m.", "timeout");
@@ -71,15 +71,15 @@ export function parseAdminNodeDiagnoseArgs(argv) {
71
71
  };
72
72
  }
73
73
 
74
- export function parseAdminNodeExecArgs(argv) {
74
+ export function parseAdminSshCommandArgs(argv) {
75
75
  const { options, positionals } = parseOptions(
76
76
  argv,
77
77
  new Set(["command", "timeout", "idempotency-key"]),
78
- EXEC_USAGE
78
+ SSH_USAGE
79
79
  );
80
- if (positionals.length !== 1 || !positionals[0]) throw usageError(EXEC_USAGE, "node-id");
80
+ if (positionals.length !== 1 || !positionals[0]) throw usageError(SSH_USAGE, "node-id");
81
81
  if (typeof options.command !== "string" || options.command.length === 0) {
82
- throw usageError(`${EXEC_USAGE}\n--command is required and must not be empty.`, "command");
82
+ throw usageError(`${SSH_USAGE}\n--command is required and must not be empty.`, "command");
83
83
  }
84
84
  return {
85
85
  input: {
@@ -312,7 +312,7 @@ async function runDiagnosis({ input, mutation, runtime, execute, fetch }) {
312
312
  }
313
313
  }
314
314
 
315
- async function runExecution({ input, mutation, runtime, execute, fetch }) {
315
+ export async function runAdminSshCommand({ input, mutation, runtime, execute, fetch }) {
316
316
  let target;
317
317
  try {
318
318
  const result = await runAdminMutation({
@@ -363,10 +363,4 @@ export const adminNodeDiagnosticsHandlers = [
363
363
  parse: (argv) => parseAdminNodeDiagnoseArgs(argv),
364
364
  run: runDiagnosis,
365
365
  },
366
- {
367
- capabilityId: "node.exec",
368
- safety: ADMIN_MUTATION_SAFETY.eligibleHumanOnly,
369
- parse: (argv) => parseAdminNodeExecArgs(argv),
370
- run: runExecution,
371
- },
372
366
  ];
package/src/admin-ssh.mjs CHANGED
@@ -6,6 +6,11 @@ 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
14
  import { openSshRelay } from "./admin-ssh-relay.mjs";
10
15
  import { forwardSignals } from "./signals.mjs";
11
16
 
@@ -51,7 +56,7 @@ async function supplierJumpArguments(fetch, node, host, port, signal) {
51
56
  }
52
57
 
53
58
  export async function openAdminSsh(
54
- { input, fetch, execute, runtime },
59
+ { input, fetch, runtime },
55
60
  { runProcess = run, openRelay = openSshRelay } = {}
56
61
  ) {
57
62
  // Read the existing node route; issuance returns only its own certificate.
@@ -90,9 +95,10 @@ export async function openAdminSsh(
90
95
  );
91
96
  if (generated !== 0) throw new Error("Could not generate the temporary SSH key.");
92
97
  const public_key = (await readFile(`${key}.pub`, "utf8")).trim();
93
- const issued = await execute(
94
- { node_id: input.node_id, public_key },
95
- { transport: (path, init) => fetch(path, { ...init, signal }) }
98
+ const issued = await orchestrator.issueNodeSshCertificate(
99
+ (path, init) => fetch(path, { ...init, signal }),
100
+ input.node_id,
101
+ { public_key }
96
102
  );
97
103
  signal.throwIfAborted();
98
104
  if (
@@ -155,13 +161,12 @@ export const adminSshHandlers = [
155
161
  capabilityId: "node.ssh",
156
162
  safety: ADMIN_MUTATION_SAFETY.eligibleHumanOnly,
157
163
  parse(argv) {
158
- if (
159
- argv.length !== 1 ||
160
- !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(argv[0])
161
- )
162
- throw new Error("Usage: ornn admin ssh <node-id>");
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);
163
167
  return { input: { node_id: argv[0] } };
164
168
  },
165
- run: openAdminSsh,
169
+ run: (context) =>
170
+ context.input.command === undefined ? openAdminSsh(context) : runAdminSshCommand(context),
166
171
  },
167
172
  ];