@ornncompute/cli 1.0.139 → 1.0.141

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ornncompute/cli",
3
- "version": "1.0.139",
3
+ "version": "1.0.141",
4
4
  "description": "Command-line interface for Ornn compute access workflows.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,3 +1,4 @@
1
+ import { metricsSnapshotCapability, metricsHistoryCapability } from "../vendor/capabilities/cli.js";
1
2
  import * as gatewayApi from "../vendor/api-client/gateway.js";
2
3
  import { gpuLabeler } from "./gpu-catalog.mjs";
3
4
  import { clusterFactLabel, reservationFactsForCluster } from "./kubernetes-commands.mjs";
@@ -777,19 +778,20 @@ function invalidEvidenceResponse(code) {
777
778
  async function metricSource(machine, reservation, window, maximum, deps, deadline, signal, live) {
778
779
  const response = await fetchEvidence(
779
780
  async (requestSignal) => {
781
+ const context = {
782
+ actor: "",
783
+ role: "user",
784
+ fetch: (path, init) => deps.fetch(path, { ...init, signal: requestSignal }),
785
+ };
786
+ const input = { reservationId: reservation, machineId: machine.id };
780
787
  const payload = live
781
- ? await gatewayApi.getReservationLiveMetrics(
782
- deps.fetch,
783
- reservation,
784
- { machine_id: machine.id },
785
- requestSignal
786
- )
787
- : await gatewayApi.getReservationTelemetryHistory(
788
- deps.fetch,
789
- reservation,
790
- { machine_id: machine.id, start: window.start, end: window.end, max_points: maximum },
791
- requestSignal
792
- );
788
+ ? (await metricsSnapshotCapability.execute(context, input))[0]
789
+ : await metricsHistoryCapability.execute(context, {
790
+ ...input,
791
+ start: window.start,
792
+ end: window.end,
793
+ maxPoints: maximum,
794
+ });
793
795
  const points = metricPoints(payload, maximum, window);
794
796
  if (points === null) throw invalidEvidenceResponse("invalid_metrics_response");
795
797
  return points;
@@ -1,3 +1,7 @@
1
+ import {
2
+ sshKeyAssignmentStatusCapability,
3
+ sshKeyDeliveryStatus,
4
+ } from "../vendor/capabilities/cli.js";
1
5
  import * as orchestrator from "../vendor/api-client/orchestrator.js";
2
6
  import * as gatewayApi from "../vendor/api-client/gateway.js";
3
7
  import { getReservation } from "../vendor/api-client/commerce.js";
@@ -731,41 +735,22 @@ function virtualMachineForNode(payload, node, interaction) {
731
735
  return matches[0] ?? null;
732
736
  }
733
737
 
734
- function keyDeliveryForMachine(key, machine) {
735
- const keyId = resourceId(key);
736
- const metadata = Array.isArray(machine.authorized_key_metadata)
737
- ? machine.authorized_key_metadata
738
- .map(record)
739
- .find(
740
- (item) =>
741
- text(item.ssh_key_id) === keyId || text(item.fingerprint) === text(key.fingerprint)
742
- )
743
- : null;
744
- const fingerprints = Array.isArray(machine.authorized_key_fingerprints)
745
- ? machine.authorized_key_fingerprints
746
- : [];
747
- const installed =
748
- text(key.fingerprint) && fingerprints.includes(text(key.fingerprint)) && machine.keys_pushed_at;
749
- return {
750
- machine_id: machineId(machine),
751
- hostname: machineHostname(machine) || null,
752
- machine_state: machineState(machine),
753
- status: text(metadata?.status) ?? (installed ? "installed" : "associated"),
754
- queued_at: text(metadata?.queued_at),
755
- pushed_at: text(metadata?.pushed_at) ?? (installed ? text(machine.keys_pushed_at) : null),
756
- failed_at: text(metadata?.failed_at),
757
- failure_reason: text(metadata?.failure_reason),
758
- request_id: text(metadata?.request_id),
759
- };
760
- }
761
-
762
738
  function assignmentStatus(reservationId, keys, machines) {
763
739
  return {
764
740
  reservation_id: reservationId,
765
741
  machine_count: machines.length,
766
742
  keys: keys.map((key) => ({
767
743
  ...projectKey(key),
768
- machines: machines.map((machine) => keyDeliveryForMachine(key, machine)),
744
+ machines: machines.map((machine) => {
745
+ const { linux_username: _username, ...delivery } = sshKeyDeliveryStatus(key, machine);
746
+ return {
747
+ machine_id: machine.node_id,
748
+ hostname: machine.hostname || null,
749
+ machine_state: machine.status,
750
+ queued_at: null,
751
+ ...delivery,
752
+ };
753
+ }),
769
754
  })),
770
755
  };
771
756
  }
@@ -4435,10 +4420,10 @@ export async function executeSshKeyCommand(command, input, context, interaction)
4435
4420
  }
4436
4421
 
4437
4422
  if (command === "assignments.status") {
4438
- const [keys, machines] = await Promise.all([
4439
- fetchAssignedKeys(context, reservationId),
4440
- fetchMachines(context, reservationId),
4441
- ]);
4423
+ const { keys, nodes: machines } = await sshKeyAssignmentStatusCapability.execute(
4424
+ { actor: "", role: "user", fetch: context.fetch },
4425
+ { reservationId }
4426
+ );
4442
4427
  keys.sort((left, right) => String(resourceId(left)).localeCompare(String(resourceId(right))));
4443
4428
  const page = cursorPage(keys, input, interaction);
4444
4429
  const status = assignmentStatus(reservationId, page.items, machines);
@@ -4503,10 +4488,10 @@ export async function executeSshKeyCommand(command, input, context, interaction)
4503
4488
  }
4504
4489
 
4505
4490
  if (command === "assignments.sync") {
4506
- const [keys, machines] = await Promise.all([
4507
- fetchAssignedKeys(context, reservationId),
4508
- fetchMachines(context, reservationId),
4509
- ]);
4491
+ const { keys, nodes: machines } = await sshKeyAssignmentStatusCapability.execute(
4492
+ { actor: "", role: "user", fetch: context.fetch },
4493
+ { reservationId }
4494
+ );
4510
4495
  if (!keys.length) {
4511
4496
  interaction.error("No SSH keys are assigned to this capacity reservation.", {
4512
4497
  code: "ssh_key_assignment_missing",