@ornncompute/cli 1.0.395 → 1.0.397

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
@@ -583,7 +583,7 @@ request conflicts, and an expired incomplete request requires a new key.
583
583
  The upload replay contract requires the matching gateway/orchestrator release;
584
584
  see [the service contract](../../services/orchestrator/README.md#file-upload-replay-and-usage).
585
585
 
586
- For `ornn admin ssh <node-id>`, including `--user` for custom accounts,
586
+ For `ornn admin ssh <node-id>`, including `--user` for custom accounts and `--firewall-seconds` for shorter recovery windows,
587
587
  one-off commands, private nodes, CA trust setup, and the repair it offers when
588
588
  a node is blocked, see the [staff SSH procedure](../../docs/cli.md#staff-ssh).
589
589
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornncompute/cli",
3
- "version": "1.0.395",
3
+ "version": "1.0.397",
4
4
  "description": "Command-line interface for Ornn compute access workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -5,7 +5,7 @@ import { ADMIN_MUTATION_SAFETY, AdminMutationError, runAdminMutation } from "./a
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
+ "Usage: ornn admin ssh <node-id> [--user USER] [--firewall-seconds SECONDS | --command COMMAND --timeout DURATION]";
9
9
  const OUTPUT_TRUNCATION_MARKER = "\n[ornn] output truncated";
10
10
 
11
11
  function usageError(message, field) {
@@ -75,7 +75,7 @@ export function parseAdminNodeDiagnoseArgs(argv) {
75
75
  export function parseAdminSshArgs(argv) {
76
76
  const { options, positionals } = parseOptions(
77
77
  argv,
78
- new Set(["user", "command", "timeout", "idempotency-key"]),
78
+ new Set(["user", "command", "timeout", "idempotency-key", "firewall-seconds"]),
79
79
  SSH_USAGE
80
80
  );
81
81
  if (positionals.length !== 1 || !positionals[0]) throw usageError(SSH_USAGE, "node-id");
@@ -92,8 +92,24 @@ export function parseAdminSshArgs(argv) {
92
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
93
  throw usageError(SSH_USAGE, "node-id");
94
94
  }
95
+ const seconds = options["firewall-seconds"];
96
+ if (seconds !== undefined) {
97
+ if (!/^[1-9]\d*$/.test(seconds) || Number(seconds) < 60 || Number(seconds) > 1800) {
98
+ throw usageError(
99
+ "--firewall-seconds must be a whole number from 60 to 1800.",
100
+ "firewall-seconds"
101
+ );
102
+ }
103
+ input.firewall_seconds = Number(seconds);
104
+ }
95
105
  return { input };
96
106
  }
107
+ if (options["firewall-seconds"] !== undefined) {
108
+ throw usageError(
109
+ "--firewall-seconds is only available for interactive SSH.",
110
+ "firewall-seconds"
111
+ );
112
+ }
97
113
  if (typeof options.command !== "string" || options.command.length === 0) {
98
114
  throw usageError(`${SSH_USAGE}\n--command is required and must not be empty.`, "command");
99
115
  }
package/src/admin-ssh.mjs CHANGED
@@ -15,7 +15,7 @@ import { parseAdminSshArgs, runAdminSshCommand } from "./admin-node-diagnostics.
15
15
  import { openSshRelay } from "./admin-ssh-relay.mjs";
16
16
  import { forwardSignals } from "./signals.mjs";
17
17
 
18
- const FIREWALL_RULE_SECONDS = 1800;
18
+ const DEFAULT_FIREWALL_RULE_SECONDS = 1800;
19
19
 
20
20
  function run(program, args, signal, onDiagnostics) {
21
21
  signal.throwIfAborted();
@@ -87,12 +87,13 @@ async function callerAddress(request, host) {
87
87
  return clientIp;
88
88
  }
89
89
 
90
- async function allowSshFrom(request, nodeId, sourceIp, port, sleep) {
90
+ async function allowSshFrom(request, nodeId, reservationId, sourceIp, port, seconds, sleep) {
91
91
  const change = {
92
92
  request_id: randomUUID(),
93
+ ...(reservationId ? { reservation_id: reservationId } : {}),
93
94
  rule: { source_ip: sourceIp, protocol: "tcp", port },
94
95
  operation: "add",
95
- ttl_seconds: FIREWALL_RULE_SECONDS,
96
+ ttl_seconds: seconds,
96
97
  reason: "Staff SSH session",
97
98
  };
98
99
  for (;;) {
@@ -245,8 +246,11 @@ export async function openAdminSsh(
245
246
  const direct = node.ssh_relay_configured !== true && !node.ssh_gateway_id;
246
247
  if (session.block === "access" || (session.block === "network" && direct)) {
247
248
  const sourceIp = session.block === "network" ? await callerAddress(request, host) : null;
249
+ const seconds = input.firewall_seconds ?? DEFAULT_FIREWALL_RULE_SECONDS;
250
+ const duration =
251
+ seconds === DEFAULT_FIREWALL_RULE_SECONDS ? "30 minutes" : `${seconds} seconds`;
248
252
  const repair = sourceIp
249
- ? `SSH from this machine cannot reach it. Allow SSH from ${sourceIp} for ${FIREWALL_RULE_SECONDS / 60} minutes and install Ornn SSH access for ${username}?`
253
+ ? `SSH from this machine cannot reach it. Allow SSH from ${sourceIp} for ${duration} and install Ornn SSH access for ${username}?`
250
254
  : `It does not accept Ornn SSH certificates for ${username}. Install Ornn SSH access for ${username}?`;
251
255
  if (await confirm(`Node ${input.node_id} is blocked. ${repair}`, runtime, signal)) {
252
256
  (runtime.stdout ?? process.stdout).write("Unblocking the node...\n");
@@ -254,8 +258,10 @@ export async function openAdminSsh(
254
258
  await allowSshFrom(
255
259
  request,
256
260
  input.node_id,
261
+ node.reservation_id,
257
262
  sourceIp,
258
263
  port,
264
+ seconds,
259
265
  runtime.sleep ?? ((milliseconds) => delay(milliseconds, undefined, { signal }))
260
266
  );
261
267
  }
@@ -7111,7 +7111,7 @@ var nodeSshCapability = defineCapability({
7111
7111
  category: "journey",
7112
7112
  arguments: "semantic",
7113
7113
  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.",
7114
- human: "ornn admin ssh <node-id> [--user USER] [--command COMMAND --timeout DURATION]",
7114
+ human: "ornn admin ssh <node-id> [--user USER] [--firewall-seconds SECONDS | --command COMMAND --timeout DURATION]",
7115
7115
  automation: "Unavailable in machine and redirected modes; use an eligible human terminal.",
7116
7116
  acceptedReferences: ["canonical node ID"],
7117
7117
  review: "Exact node, SSH user, lifecycle, reachability, command bytes, and timeout."