@ornncompute/cli 0.2.6 → 0.2.8

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.
@@ -0,0 +1,290 @@
1
+ import { z } from "zod";
2
+ import { defineStaffMcpCapability, preview } from "../capability.js";
3
+ import { mapBody, seg } from "./staff-shared.js";
4
+ // Staff commerce verbs: reservations, bids, forward inventory, and the tenant
5
+ // credit profile. MCP-only — see `defineStaffMcpCapability`.
6
+ export const reservationCancelInput = z.object({
7
+ reservationId: z.string(),
8
+ confirm: z.boolean().optional(),
9
+ });
10
+ export const reservationCancelCapability = defineStaffMcpCapability({
11
+ id: "reservation.cancel",
12
+ domain: "reservations",
13
+ roles: ["admin"],
14
+ description: "Internal staff only: cancel a reservation. Mirrors the internal dashboard's Cancel/Reject action.",
15
+ mutation: "preview-confirm",
16
+ http: { method: "POST", path: "/internal/reservations/{reservationId}/cancel" },
17
+ input: reservationCancelInput,
18
+ execute: async (ctx, input) => {
19
+ const parsed = reservationCancelInput.parse(input);
20
+ if (!ctx.confirmed) {
21
+ return preview("reservation.cancel", { reservationId: parsed.reservationId });
22
+ }
23
+ return ctx.fetch(`/internal/reservations/${seg(parsed.reservationId)}/cancel`, {
24
+ method: "POST",
25
+ });
26
+ },
27
+ });
28
+ export const reservationTransferInput = z.object({
29
+ reservationId: z.string(),
30
+ targetTenantId: z.string(),
31
+ targetAuthUserId: z.string().optional(),
32
+ nodeId: z.string().optional(),
33
+ reservedStrategy: z.enum(["reject", "park"]),
34
+ confirmReservedTransfer: z.boolean().optional(),
35
+ notes: z.string().max(2000).optional(),
36
+ confirm: z.boolean().optional(),
37
+ });
38
+ export const reservationTransferCapability = defineStaffMcpCapability({
39
+ id: "reservation.transfer",
40
+ domain: "reservations",
41
+ roles: ["admin"],
42
+ description: "Internal staff only: transfer a reservation to a different tenant/node. Mirrors the internal node-overlay transfer action. " +
43
+ "reservedStrategy has no default and must be chosen explicitly: \"reject\" (transfer only if the reservation isn't " +
44
+ "currently provisioned/assigned) or \"park\" (clean up old access and park it for the target tenant, for a live handoff). " +
45
+ "The dashboard always computes this from the reservation's live state before sending it rather than relying on the " +
46
+ "backend's own default of \"reject\", because a silent \"reject\" default on a reservation the backend doesn't detect as " +
47
+ "actively provisioned/assigned would transfer it without ever asking for confirm_reserved_transfer.",
48
+ mutation: "preview-confirm",
49
+ http: { method: "POST", path: "/internal/reservations/{reservationId}/transfer" },
50
+ input: reservationTransferInput,
51
+ execute: async (ctx, input) => {
52
+ const parsed = reservationTransferInput.parse(input);
53
+ const body = {
54
+ target_tenant_id: parsed.targetTenantId,
55
+ reserved_strategy: parsed.reservedStrategy,
56
+ confirm_reserved_transfer: parsed.confirmReservedTransfer ?? false,
57
+ ...mapBody(parsed, {
58
+ targetAuthUserId: "target_auth_user_id",
59
+ nodeId: "node_id",
60
+ notes: "notes",
61
+ }),
62
+ };
63
+ if (!ctx.confirmed)
64
+ return preview("reservation.transfer", body);
65
+ return ctx.fetch(`/internal/reservations/${seg(parsed.reservationId)}/transfer`, {
66
+ method: "POST",
67
+ body,
68
+ });
69
+ },
70
+ });
71
+ export const reservationMachinesListInput = z.object({ reservationId: z.string() });
72
+ export const reservationMachinesListCapability = defineStaffMcpCapability({
73
+ id: "reservation.machines.list",
74
+ domain: "reservations",
75
+ roles: ["reviewer", "admin"],
76
+ description: "Internal staff only: list machines for a reservation.",
77
+ mutation: "read",
78
+ http: { method: "GET", path: "/internal/nodes" },
79
+ input: reservationMachinesListInput,
80
+ execute: async (ctx, input) => {
81
+ const parsed = reservationMachinesListInput.parse(input);
82
+ return ctx.fetch(`/internal/nodes?reservation_id=${seg(parsed.reservationId)}`, {
83
+ method: "GET",
84
+ });
85
+ },
86
+ });
87
+ export const reservationSshKeyAddInput = z.object({
88
+ reservationId: z.string(),
89
+ userId: z.string(),
90
+ publicKey: z.string().min(1),
91
+ label: z.string().optional(),
92
+ nodeId: z.string().optional(),
93
+ confirm: z.boolean().optional(),
94
+ });
95
+ export const reservationSshKeyAddCapability = defineStaffMcpCapability({
96
+ id: "reservation.ssh-key.add",
97
+ domain: "reservations",
98
+ roles: ["admin"],
99
+ description: "Internal staff only: add an SSH key to a reservation and queue sync to its machines. Requires confirm: true.",
100
+ mutation: "preview-confirm",
101
+ http: { method: "POST", path: "/internal/v1/reservations/{reservationId}/ssh-keys" },
102
+ input: reservationSshKeyAddInput,
103
+ execute: async (ctx, input) => {
104
+ const parsed = reservationSshKeyAddInput.parse(input);
105
+ const body = {
106
+ user_id: parsed.userId,
107
+ public_key: parsed.publicKey,
108
+ ...mapBody(parsed, { label: "label", nodeId: "node_id" }),
109
+ };
110
+ if (!ctx.confirmed)
111
+ return preview("reservation.ssh-key.add", body);
112
+ return ctx.fetch(`/internal/v1/reservations/${seg(parsed.reservationId)}/ssh-keys`, {
113
+ method: "POST",
114
+ body,
115
+ });
116
+ },
117
+ });
118
+ export const reservationSshKeyRemoveInput = z.object({
119
+ reservationId: z.string(),
120
+ keyId: z.string(),
121
+ userId: z.string(),
122
+ nodeId: z.string().optional(),
123
+ confirm: z.boolean().optional(),
124
+ });
125
+ export const reservationSshKeyRemoveCapability = defineStaffMcpCapability({
126
+ id: "reservation.ssh-key.remove",
127
+ domain: "reservations",
128
+ roles: ["admin"],
129
+ description: "Internal staff only: remove an SSH key from a reservation and queue cleanup on its machines. Requires confirm: true.",
130
+ mutation: "preview-confirm",
131
+ http: { method: "DELETE", path: "/internal/v1/reservations/{reservationId}/ssh-keys/{keyId}" },
132
+ input: reservationSshKeyRemoveInput,
133
+ execute: async (ctx, input) => {
134
+ const parsed = reservationSshKeyRemoveInput.parse(input);
135
+ const body = {
136
+ user_id: parsed.userId,
137
+ ...mapBody(parsed, { nodeId: "node_id" }),
138
+ };
139
+ if (!ctx.confirmed)
140
+ return preview("reservation.ssh-key.remove", body);
141
+ return ctx.fetch(`/internal/v1/reservations/${seg(parsed.reservationId)}/ssh-keys/${seg(parsed.keyId)}`, { method: "DELETE", body });
142
+ },
143
+ });
144
+ export const reservationPublishInput = z.object({
145
+ reservationId: z.string(),
146
+ confirm: z.boolean().optional(),
147
+ });
148
+ export const reservationPublishCapability = defineStaffMcpCapability({
149
+ id: "reservation.publish",
150
+ domain: "reservations",
151
+ roles: ["admin"],
152
+ description: "Internal staff only: publish a commerce draft into a live Commerce reservation. Requires confirm: true.",
153
+ mutation: "preview-confirm",
154
+ http: { method: "POST", path: "/internal/reservations/{reservationId}/publish" },
155
+ input: reservationPublishInput,
156
+ execute: async (ctx, input) => {
157
+ const parsed = reservationPublishInput.parse(input);
158
+ if (!ctx.confirmed) {
159
+ return preview("reservation.publish", { reservationId: parsed.reservationId });
160
+ }
161
+ return ctx.fetch(`/internal/reservations/${seg(parsed.reservationId)}/publish`, {
162
+ method: "POST",
163
+ });
164
+ },
165
+ });
166
+ export const bidAcceptInput = z.object({
167
+ bidId: z.string(),
168
+ acceptedGpuCount: z.number().int().min(1).optional(),
169
+ confirm: z.boolean().optional(),
170
+ });
171
+ export const bidAcceptCapability = defineStaffMcpCapability({
172
+ id: "bid.accept",
173
+ domain: "bids",
174
+ roles: ["admin"],
175
+ description: "Internal staff only: accept an active bid. Optionally set acceptedGpuCount (defaults to the bid's full gpu_count). Mirrors the internal dashboard's Accept action.",
176
+ mutation: "preview-confirm",
177
+ http: { method: "POST", path: "/internal/bids/{bidId}/accept" },
178
+ input: bidAcceptInput,
179
+ execute: async (ctx, input) => {
180
+ const parsed = bidAcceptInput.parse(input);
181
+ const body = mapBody(parsed, { acceptedGpuCount: "accepted_gpu_count" });
182
+ if (!ctx.confirmed)
183
+ return preview("bid.accept", { bidId: parsed.bidId, ...body });
184
+ return ctx.fetch(`/internal/bids/${seg(parsed.bidId)}/accept`, { method: "POST", body });
185
+ },
186
+ });
187
+ export const bidRejectInput = z.object({
188
+ bidId: z.string(),
189
+ confirm: z.boolean().optional(),
190
+ });
191
+ export const bidRejectCapability = defineStaffMcpCapability({
192
+ id: "bid.reject",
193
+ domain: "bids",
194
+ roles: ["admin"],
195
+ description: "Internal staff only: reject an active bid. Mirrors the internal dashboard's Reject action.",
196
+ mutation: "preview-confirm",
197
+ http: { method: "POST", path: "/internal/bids/{bidId}/reject" },
198
+ input: bidRejectInput,
199
+ execute: async (ctx, input) => {
200
+ const parsed = bidRejectInput.parse(input);
201
+ if (!ctx.confirmed)
202
+ return preview("bid.reject", { bidId: parsed.bidId });
203
+ return ctx.fetch(`/internal/bids/${seg(parsed.bidId)}/reject`, { method: "POST" });
204
+ },
205
+ });
206
+ export const inventoryUpdateInput = z.object({
207
+ inventoryId: z.string(),
208
+ siteOperator: z.string().min(1).optional(),
209
+ siteNickname: z.string().min(1).optional(),
210
+ gpuType: z.string().min(1).optional(),
211
+ nodeCount: z
212
+ .number()
213
+ .int()
214
+ .positive()
215
+ .optional()
216
+ .describe("Total nodes (listing capacity), not total GPUs."),
217
+ gpusPerNode: z.number().int().min(1).max(32).optional(),
218
+ availableFrom: z.string().nullable().optional(),
219
+ availableTo: z.string().nullable().optional(),
220
+ availableStartAt: z.string().nullable().optional(),
221
+ availableEndAt: z.string().nullable().optional(),
222
+ cpu: z.string().nullable().optional(),
223
+ ram: z.string().nullable().optional(),
224
+ fabricType: z.string().nullable().optional(),
225
+ storage: z.string().nullable().optional(),
226
+ internet: z.string().nullable().optional(),
227
+ networkHardware: z.string().nullable().optional(),
228
+ buyNowPricePerGpuHour: z.number().positive().nullable().optional(),
229
+ confirm: z.boolean().optional(),
230
+ });
231
+ export const inventoryUpdateCapability = defineStaffMcpCapability({
232
+ id: "inventory.update",
233
+ domain: "listings",
234
+ roles: ["admin"],
235
+ description: "Internal staff only: patch editable fields on a forward inventory listing. Requires confirm: true. " +
236
+ "At least one editable field is required. buyNowPricePerGpuHour may be null to clear the price.",
237
+ mutation: "preview-confirm",
238
+ http: { method: "PATCH", path: "/inventory/{inventoryId}" },
239
+ input: inventoryUpdateInput,
240
+ execute: async (ctx, input) => {
241
+ const parsed = inventoryUpdateInput.parse(input);
242
+ const body = mapBody(parsed, {
243
+ siteOperator: "site_operator",
244
+ siteNickname: "site_nickname",
245
+ gpuType: "gpu_type",
246
+ nodeCount: "node_count",
247
+ gpusPerNode: "gpus_per_node",
248
+ availableFrom: "available_from",
249
+ availableTo: "available_to",
250
+ availableStartAt: "available_start_at",
251
+ availableEndAt: "available_end_at",
252
+ cpu: "cpu",
253
+ ram: "ram",
254
+ fabricType: "fabric_type",
255
+ storage: "storage",
256
+ internet: "internet",
257
+ networkHardware: "network_hardware",
258
+ buyNowPricePerGpuHour: "buy_now_price_per_gpu_hour",
259
+ });
260
+ if (!ctx.confirmed)
261
+ return preview("inventory.update", body);
262
+ return ctx.fetch(`/inventory/${seg(parsed.inventoryId)}`, { method: "PATCH", body });
263
+ },
264
+ });
265
+ export const tenantCreditProfileShowInput = z.object({ tenantId: z.string() });
266
+ export const tenantCreditProfileShowCapability = defineStaffMcpCapability({
267
+ id: "tenant.credit-profile.show",
268
+ domain: "users",
269
+ roles: ["reviewer", "admin"],
270
+ description: "Internal staff only: show a tenant's credit profile, approval status, and onboarding details. Read-only — does not approve or disapprove.",
271
+ mutation: "read",
272
+ http: { method: "GET", path: "/internal/organizations/{tenantId}" },
273
+ input: tenantCreditProfileShowInput,
274
+ execute: async (ctx, input) => {
275
+ const parsed = tenantCreditProfileShowInput.parse(input);
276
+ return ctx.fetch(`/internal/organizations/${seg(parsed.tenantId)}`, { method: "GET" });
277
+ },
278
+ });
279
+ export const staffCommerceCapabilities = [
280
+ reservationCancelCapability,
281
+ reservationTransferCapability,
282
+ reservationMachinesListCapability,
283
+ reservationSshKeyAddCapability,
284
+ reservationSshKeyRemoveCapability,
285
+ reservationPublishCapability,
286
+ bidAcceptCapability,
287
+ bidRejectCapability,
288
+ inventoryUpdateCapability,
289
+ tenantCreditProfileShowCapability,
290
+ ];
@@ -0,0 +1,141 @@
1
+ import { z } from "zod";
2
+ export declare const enrollmentTokenRevokeInput: z.ZodObject<{
3
+ tokenId: z.ZodString;
4
+ confirm: z.ZodOptional<z.ZodBoolean>;
5
+ }, z.core.$strip>;
6
+ export declare const enrollmentTokenRevokeCapability: import("../capability.ts").Capability<unknown, unknown>;
7
+ export declare const operatorCreateInput: z.ZodObject<{
8
+ slug: z.ZodString;
9
+ displayName: z.ZodString;
10
+ mode: z.ZodOptional<z.ZodEnum<{
11
+ managed: "managed";
12
+ federated: "federated";
13
+ }>>;
14
+ status: z.ZodOptional<z.ZodEnum<{
15
+ active: "active";
16
+ unavailable: "unavailable";
17
+ revoked: "revoked";
18
+ }>>;
19
+ confirm: z.ZodOptional<z.ZodBoolean>;
20
+ }, z.core.$strip>;
21
+ export declare const operatorCreateCapability: import("../capability.ts").Capability<unknown, unknown>;
22
+ export declare const operatorUpdateInput: z.ZodObject<{
23
+ operatorId: z.ZodString;
24
+ displayName: z.ZodOptional<z.ZodString>;
25
+ slug: z.ZodOptional<z.ZodString>;
26
+ mode: z.ZodOptional<z.ZodEnum<{
27
+ managed: "managed";
28
+ federated: "federated";
29
+ }>>;
30
+ status: z.ZodOptional<z.ZodEnum<{
31
+ active: "active";
32
+ unavailable: "unavailable";
33
+ revoked: "revoked";
34
+ }>>;
35
+ confirm: z.ZodOptional<z.ZodBoolean>;
36
+ }, z.core.$strip>;
37
+ export declare const operatorUpdateCapability: import("../capability.ts").Capability<unknown, unknown>;
38
+ export declare const operatorDeleteInput: z.ZodObject<{
39
+ operatorId: z.ZodString;
40
+ confirm: z.ZodOptional<z.ZodBoolean>;
41
+ }, z.core.$strip>;
42
+ export declare const operatorDeleteCapability: import("../capability.ts").Capability<unknown, unknown>;
43
+ export declare const facilityCreateInput: z.ZodObject<{
44
+ operatorId: z.ZodString;
45
+ slug: z.ZodString;
46
+ displayName: z.ZodString;
47
+ region: z.ZodString;
48
+ zone: z.ZodOptional<z.ZodString>;
49
+ confirm: z.ZodOptional<z.ZodBoolean>;
50
+ }, z.core.$strip>;
51
+ export declare const facilityCreateCapability: import("../capability.ts").Capability<unknown, unknown>;
52
+ export declare const facilityUpdateInput: z.ZodObject<{
53
+ facilityId: z.ZodString;
54
+ displayName: z.ZodOptional<z.ZodString>;
55
+ region: z.ZodOptional<z.ZodString>;
56
+ zone: z.ZodOptional<z.ZodString>;
57
+ confirm: z.ZodOptional<z.ZodBoolean>;
58
+ }, z.core.$strip>;
59
+ export declare const facilityUpdateCapability: import("../capability.ts").Capability<unknown, unknown>;
60
+ export declare const nodeShowInput: z.ZodObject<{
61
+ nodeId: z.ZodString;
62
+ }, z.core.$strip>;
63
+ export declare const nodeShowCapability: import("../capability.ts").Capability<unknown, unknown>;
64
+ export declare const nodeDetailsUpdateInput: z.ZodObject<{
65
+ nodeId: z.ZodString;
66
+ hostname: z.ZodOptional<z.ZodString>;
67
+ publicLocation: z.ZodOptional<z.ZodString>;
68
+ facilityId: z.ZodOptional<z.ZodString>;
69
+ gpuType: z.ZodOptional<z.ZodString>;
70
+ gpuCount: z.ZodOptional<z.ZodNumber>;
71
+ ornnMode: z.ZodOptional<z.ZodString>;
72
+ cpu: z.ZodOptional<z.ZodString>;
73
+ ram: z.ZodOptional<z.ZodString>;
74
+ storage: z.ZodOptional<z.ZodString>;
75
+ fabricType: z.ZodOptional<z.ZodString>;
76
+ internet: z.ZodOptional<z.ZodString>;
77
+ networkHardware: z.ZodOptional<z.ZodString>;
78
+ buyNowPricePerGpuHour: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
79
+ confirm: z.ZodOptional<z.ZodBoolean>;
80
+ }, z.core.$strip>;
81
+ export declare const nodeDetailsUpdateCapability: import("../capability.ts").Capability<unknown, unknown>;
82
+ export declare const nodeReserveListingInput: z.ZodObject<{
83
+ nodeId: z.ZodString;
84
+ availableFrom: z.ZodOptional<z.ZodString>;
85
+ availableTo: z.ZodOptional<z.ZodNullable<z.ZodString>>;
86
+ confirm: z.ZodOptional<z.ZodBoolean>;
87
+ }, z.core.$strip>;
88
+ export declare const nodeReserveListingCapability: import("../capability.ts").Capability<unknown, unknown>;
89
+ export declare const nodeTestTriggerInput: z.ZodObject<{
90
+ nodeId: z.ZodString;
91
+ burnTimeMinutes: z.ZodOptional<z.ZodNumber>;
92
+ constraints: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
93
+ source: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
94
+ confirm: z.ZodOptional<z.ZodBoolean>;
95
+ }, z.core.$strip>;
96
+ export declare const nodeTestTriggerCapability: import("../capability.ts").Capability<unknown, unknown>;
97
+ export declare const nodeTestResultInput: z.ZodObject<{
98
+ nodeId: z.ZodOptional<z.ZodString>;
99
+ jobId: z.ZodString;
100
+ packetId: z.ZodOptional<z.ZodString>;
101
+ }, z.core.$strip>;
102
+ export declare const nodeTestResultCapability: import("../capability.ts").Capability<unknown, unknown>;
103
+ export declare const nodeBenchmarkInput: z.ZodObject<{
104
+ nodeId: z.ZodString;
105
+ }, z.core.$strip>;
106
+ export declare const nodeBenchmarkCapability: import("../capability.ts").Capability<unknown, unknown>;
107
+ export declare const nodeDeployInput: z.ZodObject<{
108
+ nodeId: z.ZodString;
109
+ targetTenantId: z.ZodString;
110
+ targetAuthUserId: z.ZodOptional<z.ZodString>;
111
+ networkMode: z.ZodOptional<z.ZodEnum<{
112
+ public: "public";
113
+ private: "private";
114
+ }>>;
115
+ notes: z.ZodOptional<z.ZodString>;
116
+ confirm: z.ZodOptional<z.ZodBoolean>;
117
+ }, z.core.$strip>;
118
+ export declare const nodeDeployCapability: import("../capability.ts").Capability<unknown, unknown>;
119
+ export declare const nodeUpdateInput: z.ZodObject<{
120
+ nodeId: z.ZodString;
121
+ targetVersion: z.ZodOptional<z.ZodString>;
122
+ confirm: z.ZodOptional<z.ZodBoolean>;
123
+ }, z.core.$strip>;
124
+ export declare const nodeUpdateCapability: import("../capability.ts").Capability<unknown, unknown>;
125
+ export declare const nodeRebootInput: z.ZodObject<{
126
+ instanceId: z.ZodString;
127
+ confirm: z.ZodOptional<z.ZodBoolean>;
128
+ }, z.core.$strip>;
129
+ export declare const nodeHardResetInput: z.ZodObject<{
130
+ instanceId: z.ZodString;
131
+ confirm: z.ZodOptional<z.ZodBoolean>;
132
+ }, z.core.$strip>;
133
+ export declare const nodeRebootCapability: import("../capability.ts").Capability<unknown, unknown>;
134
+ export declare const nodeHardResetCapability: import("../capability.ts").Capability<unknown, unknown>;
135
+ export declare const nodeAdminKeyInput: z.ZodObject<{
136
+ nodeId: z.ZodString;
137
+ generate: z.ZodOptional<z.ZodBoolean>;
138
+ confirm: z.ZodOptional<z.ZodBoolean>;
139
+ }, z.core.$strip>;
140
+ export declare const nodeAdminKeyCapability: import("../capability.ts").Capability<unknown, unknown>;
141
+ export declare const staffFleetCapabilities: import("../capability.ts").Capability<unknown, unknown>[];