@kvbox/cli 0.6.11 → 0.6.13

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/dist/kvbox.js CHANGED
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
155
155
  }
156
156
 
157
157
  // src/program.ts
158
- import { Command as Command130 } from "commander";
158
+ import { Command as Command133 } from "commander";
159
159
 
160
160
  // ../shared/src/version.ts
161
161
  import { createRequire } from "module";
@@ -170,7 +170,7 @@ function versionOf(srcFileUrl, injected) {
170
170
  }
171
171
 
172
172
  // src/version.ts
173
- var VERSION = versionOf(import.meta.url, true ? "0.6.11" : void 0);
173
+ var VERSION = versionOf(import.meta.url, true ? "0.6.13" : void 0);
174
174
 
175
175
  // src/commands/vm/index.ts
176
176
  import { Command as Command39 } from "commander";
@@ -345,10 +345,92 @@ function volumeMountPath(volume2) {
345
345
 
346
346
  // src/session.ts
347
347
  import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
348
- import { z as z2 } from "zod";
348
+ import { z as z3 } from "zod";
349
349
 
350
350
  // ../shared/src/api.ts
351
+ import { z as z2 } from "zod";
352
+
353
+ // ../shared/src/integrations.ts
351
354
  import { z } from "zod";
355
+ var INTEGRATION_IDS = ["github"];
356
+ var IntegrationIdSchema = z.enum(INTEGRATION_IDS);
357
+ var INTEGRATION_KINDS = ["oauth", "app", "api-key", "subscription"];
358
+ var IntegrationKindSchema = z.enum(INTEGRATION_KINDS);
359
+ var INTEGRATION_STATUSES = ["ok", "needs-reconnect"];
360
+ var IntegrationStatusSchema = z.enum(INTEGRATION_STATUSES);
361
+ var INTEGRATIONS_OFF = "off";
362
+ function parseIntegrationList(text2) {
363
+ const names2 = text2.split(",").map((n) => n.trim().toLowerCase()).filter(Boolean);
364
+ if (names2.length === 0 || names2.length === 1 && names2[0] === INTEGRATIONS_OFF) return [];
365
+ const unknown = names2.filter((n) => !INTEGRATION_IDS.includes(n));
366
+ if (unknown.length > 0) {
367
+ const what = unknown[0] === INTEGRATIONS_OFF ? `${INTEGRATIONS_OFF} goes alone, not in a list` : `unknown integration: ${unknown.join(", ")}`;
368
+ throw new KvboxError(`${what} (the integrations are: ${INTEGRATION_IDS.join(", ")}; ${INTEGRATIONS_OFF} for none)`);
369
+ }
370
+ return INTEGRATION_IDS.filter((id) => names2.includes(id));
371
+ }
372
+ var IntegrationListSchema = z.array(z.string().min(1).max(40)).max(20).transform((list) => [...new Set(list)]);
373
+ var IntegrationCatalogEntrySchema = z.object({
374
+ /** A plain string, like `integration` in a listing row: a reader may be older than the control plane. */
375
+ id: z.string(),
376
+ title: z.string(),
377
+ description: z.string(),
378
+ /** How Connect works: `oauth` sends the browser to the provider's consent screen. */
379
+ connect: z.enum(["oauth"]),
380
+ /** What a user's slug and an org's may hold; an empty list: that kind of slug cannot connect it yet. */
381
+ kinds: z.object({ user: z.array(IntegrationKindSchema), org: z.array(IntegrationKindSchema) }),
382
+ /** Whether this control plane is set up for it (a self-hosted one without a GitHub app is not). */
383
+ available: z.boolean(),
384
+ /** Its guide, as a URL. */
385
+ docs: z.string().optional(),
386
+ /** Where it is connected and disconnected: this control plane's web app, when it has one. */
387
+ page: z.string().optional()
388
+ });
389
+ var IntegrationSchema = z.object({
390
+ /** The slug it belongs to: a user's or an org's. */
391
+ owner: z.string(),
392
+ /**
393
+ * Which one (`github`). A plain string, not the ids above: this is an answer, read by every released CLI
394
+ * and SDK, and one from before a new integration must still read the listing that has it.
395
+ */
396
+ integration: z.string(),
397
+ connected: z.boolean(),
398
+ /** The rest is null while not connected. */
399
+ kind: IntegrationKindSchema.nullable(),
400
+ /** Whose account, as shown: the GitHub login. Never a secret. */
401
+ account: z.string().nullable(),
402
+ status: IntegrationStatusSchema.nullable(),
403
+ connectedBy: z.string().nullable(),
404
+ connectedAt: z.string().nullable(),
405
+ /** The last time a box was handed the credential (to the minute). */
406
+ lastUsedAt: z.string().nullable(),
407
+ /** Whether the caller may connect or disconnect it: the slug's own user, an org's owners. */
408
+ canManage: z.boolean()
409
+ });
410
+ var IntegrationConnectSchema = z.object({ url: z.string() });
411
+ var IntegrationCompleteRequestSchema = z.object({ code: z.string().min(1), state: z.string().min(1) });
412
+ var IntegrationIdentitySchema = z.object({ name: z.string(), email: z.string() });
413
+ var CREDENTIAL_REFUSALS = ["off", "not-connected", "needs-reconnect", "unavailable"];
414
+ var CredentialAnswerSchema = z.discriminatedUnion("ok", [
415
+ z.object({
416
+ ok: z.literal(true),
417
+ kind: IntegrationKindSchema,
418
+ token: z.string(),
419
+ /** When the token ends (ISO), for one that does (a GitHub App's hour). */
420
+ expiresAt: z.string().optional(),
421
+ identity: IntegrationIdentitySchema.optional()
422
+ }),
423
+ z.object({
424
+ ok: z.literal(false),
425
+ code: z.enum(CREDENTIAL_REFUSALS),
426
+ message: z.string(),
427
+ /** With `off`: whether the slug has it connected, so the box can say how to turn it on. */
428
+ connected: z.boolean().optional()
429
+ })
430
+ ]);
431
+ var HostCredentialRequestSchema = z.object({ owner: z.string().min(1), box: z.string().min(1), integration: IntegrationIdSchema, probe: z.boolean().optional() });
432
+ var ConnectedAnswerSchema = z.object({ connected: z.boolean(), identity: IntegrationIdentitySchema.optional() });
433
+ var GuestRequestSchema = z.object({ op: z.literal("credential"), integration: IntegrationIdSchema });
352
434
 
353
435
  // ../shared/src/sizes.ts
354
436
  var SIZES = {
@@ -368,1059 +450,1089 @@ function parseMib(text2) {
368
450
  }
369
451
 
370
452
  // ../shared/src/api.ts
371
- var SizeSchema = z.enum(SIZE_NAMES);
453
+ var SizeSchema = z2.enum(SIZE_NAMES);
372
454
  var BOX_SSH_USER = "kvbox";
373
- var BoxStatusSchema = z.enum(["running", "standby", "hibernated", "stopped", "unknown"]);
374
- var PortProtoSchema = z.enum(["tcp", "udp"]);
455
+ var BoxStatusSchema = z2.enum(["running", "standby", "hibernated", "stopped", "unknown"]);
456
+ var PortProtoSchema = z2.enum(["tcp", "udp"]);
375
457
  var MAX_BOX_PORTS = 16;
376
- var PortForwardSchema = z.object({
377
- guestPort: z.number().int().min(1).max(65535),
378
- hostPort: z.number().int(),
458
+ var PortForwardSchema = z2.object({
459
+ guestPort: z2.number().int().min(1).max(65535),
460
+ hostPort: z2.number().int(),
379
461
  proto: PortProtoSchema,
380
462
  /** The host's public address; only the control plane fills it in, as for `ssh`. */
381
- address: z.string().optional(),
463
+ address: z2.string().optional(),
382
464
  /**
383
465
  * Closed but kept (#173): nothing reaches the box through it, and the host port stays the box's, so
384
466
  * publishing the same box port again opens the same number. Absent: open while the box runs.
385
467
  */
386
- closed: z.literal(true).optional()
468
+ closed: z2.literal(true).optional()
387
469
  });
388
- var PortsRequest = z.object({
389
- ports: z.array(z.object({ guestPort: z.number().int().min(1).max(65535), proto: PortProtoSchema.optional() })).min(1).max(MAX_BOX_PORTS),
470
+ var PortsRequest = z2.object({
471
+ ports: z2.array(z2.object({ guestPort: z2.number().int().min(1).max(65535), proto: PortProtoSchema.optional() })).min(1).max(MAX_BOX_PORTS),
390
472
  /** `DELETE` only (#173): close the ports but keep their host ports for the box (`closed`). */
391
- keep: z.boolean().optional()
392
- });
393
- var BoxPortSchema = z.number().int().min(1).max(65535);
394
- var BoxLinkSchema = z.object({ from: z.string(), port: BoxPortSchema });
395
- var LinkRequest = z.object({ from: z.string().min(1), fromOwner: z.string().optional(), port: BoxPortSchema });
396
- var ClaimSubdomainRequest = z.object({ name: z.string(), port: BoxPortSchema });
397
- var SubdomainPortRequest = z.object({ port: BoxPortSchema });
398
- var SubdomainRouteRequest = z.object({ name: z.string(), port: BoxPortSchema });
399
- var SubdomainSchema = z.object({
400
- owner: z.string(),
401
- box: z.string(),
402
- subdomain: z.string(),
473
+ keep: z2.boolean().optional()
474
+ });
475
+ var BoxPortSchema = z2.number().int().min(1).max(65535);
476
+ var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
477
+ var LinkRequest = z2.object({ from: z2.string().min(1), fromOwner: z2.string().optional(), port: BoxPortSchema });
478
+ var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
479
+ var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
480
+ var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
481
+ var SubdomainSchema = z2.object({
482
+ owner: z2.string(),
483
+ box: z2.string(),
484
+ subdomain: z2.string(),
403
485
  port: BoxPortSchema,
404
- url: z.string(),
405
- routes: z.array(z.object({ name: z.string(), port: BoxPortSchema, url: z.string() }))
486
+ url: z2.string(),
487
+ routes: z2.array(z2.object({ name: z2.string(), port: BoxPortSchema, url: z2.string() }))
406
488
  });
407
- var AddDomainRequest = z.object({ domain: z.string(), port: BoxPortSchema.optional() });
408
- var DomainSchema = z.object({
409
- owner: z.string(),
410
- box: z.string(),
411
- domain: z.string(),
489
+ var AddDomainRequest = z2.object({ domain: z2.string(), port: BoxPortSchema.optional() });
490
+ var DomainSchema = z2.object({
491
+ owner: z2.string(),
492
+ box: z2.string(),
493
+ domain: z2.string(),
412
494
  port: BoxPortSchema,
413
- status: z.enum(["pending", "live"]),
414
- www: z.boolean(),
415
- url: z.string(),
416
- error: z.string().nullable(),
417
- records: z.array(z.object({ type: z.enum(["A", "TXT", "CNAME"]), name: z.string(), value: z.string() })),
418
- createdAt: z.string()
419
- });
420
- var WakeHookSchema = z.object({
421
- id: z.string(),
422
- owner: z.string(),
423
- box: z.string(),
424
- url: z.string(),
425
- createdBy: z.string().nullable(),
426
- createdAt: z.string(),
427
- lastCalledAt: z.string().nullable()
428
- });
429
- var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z.string() });
430
- var WakeHookCallSchema = z.object({
431
- box: z.string(),
432
- action: z.enum(["wake", "resume", "none"]),
433
- reason: z.string().optional()
495
+ status: z2.enum(["pending", "live"]),
496
+ www: z2.boolean(),
497
+ url: z2.string(),
498
+ error: z2.string().nullable(),
499
+ records: z2.array(z2.object({ type: z2.enum(["A", "TXT", "CNAME"]), name: z2.string(), value: z2.string() })),
500
+ createdAt: z2.string()
501
+ });
502
+ var WakeHookSchema = z2.object({
503
+ id: z2.string(),
504
+ owner: z2.string(),
505
+ box: z2.string(),
506
+ url: z2.string(),
507
+ createdBy: z2.string().nullable(),
508
+ createdAt: z2.string(),
509
+ lastCalledAt: z2.string().nullable()
510
+ });
511
+ var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z2.string() });
512
+ var WakeHookCallSchema = z2.object({
513
+ box: z2.string(),
514
+ action: z2.enum(["wake", "resume", "none"]),
515
+ reason: z2.string().optional()
434
516
  });
435
517
  var BACKUP_STATUSES = ["running", "ready", "failed"];
436
518
  var BACKUP_KINDS = ["box", "volume"];
437
- var BackupSchema = z.object({
438
- id: z.string(),
439
- owner: z.string(),
440
- box: z.string(),
441
- status: z.enum(BACKUP_STATUSES),
519
+ var BackupSchema = z2.object({
520
+ id: z2.string(),
521
+ owner: z2.string(),
522
+ box: z2.string(),
523
+ /**
524
+ * The box it was taken of has been removed (#141): a box called `box` now is another box, which this backup
525
+ * never restores into; `kvbox new <name> --from-backup <id>` makes a box from it. Absent from a control plane
526
+ * before #141.
527
+ */
528
+ boxRemoved: z2.boolean().optional(),
529
+ status: z2.enum(BACKUP_STATUSES),
442
530
  /** Why it failed; null otherwise. */
443
- error: z.string().nullable(),
531
+ error: z2.string().nullable(),
444
532
  /** The image version the disk stacks on (a restore needs it on the host), and the image (absent: base). */
445
- base: z.string().nullable(),
446
- image: z.string().optional(),
447
- vcpu: z.number().int().nullable(),
448
- memMib: z.number().int().nullable(),
533
+ base: z2.string().nullable(),
534
+ image: z2.string().optional(),
535
+ vcpu: z2.number().int().nullable(),
536
+ memMib: z2.number().int().nullable(),
449
537
  /** The disk's size. */
450
- diskBytes: z.number().int().nullable(),
538
+ diskBytes: z2.number().int().nullable(),
451
539
  /** What it holds: the slots that are not all zeros. */
452
- dataBytes: z.number().int().nullable(),
540
+ dataBytes: z2.number().int().nullable(),
453
541
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
454
- uploadedBytes: z.number().int().nullable(),
455
- createdBy: z.string().nullable(),
456
- createdAt: z.string(),
457
- finishedAt: z.string().nullable()
458
- });
459
- var BackupLimitSchema = z.object({
460
- perDay: z.number().int(),
461
- used: z.number().int(),
462
- nextAt: z.string().nullable()
463
- });
464
- var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner: z.string(), name: z.string() });
465
- var HostBackupRequest = z.object({ id: z.string(), key: z.string() });
466
- var HostBackupManifestSchema = z.object({
467
- id: z.string(),
468
- sizeBytes: z.number().int(),
469
- chunks: z.array(z.string().nullable()),
470
- env: z.string().nullable(),
471
- base: z.string(),
472
- image: z.string().optional(),
473
- vcpu: z.number().int(),
474
- memMib: z.number().int()
475
- });
476
- var HostUploadRequest = z.object({ key: z.string(), urls: z.record(z.string(), z.string()), pin: z.string().optional() });
477
- var HostUploadResultSchema = z.object({ chunks: z.number().int(), bytes: z.number().int(), sizes: z.record(z.string(), z.number().int()) });
478
- var HostRestoreRequest = z.object({
542
+ uploadedBytes: z2.number().int().nullable(),
543
+ createdBy: z2.string().nullable(),
544
+ createdAt: z2.string(),
545
+ finishedAt: z2.string().nullable()
546
+ });
547
+ var BackupLimitSchema = z2.object({
548
+ perDay: z2.number().int(),
549
+ used: z2.number().int(),
550
+ nextAt: z2.string().nullable()
551
+ });
552
+ var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner: z2.string(), name: z2.string() });
553
+ var HostBackupRequest = z2.object({ id: z2.string(), key: z2.string() });
554
+ var HostBackupManifestSchema = z2.object({
555
+ id: z2.string(),
556
+ sizeBytes: z2.number().int(),
557
+ chunks: z2.array(z2.string().nullable()),
558
+ env: z2.string().nullable(),
559
+ base: z2.string(),
560
+ image: z2.string().optional(),
561
+ vcpu: z2.number().int(),
562
+ memMib: z2.number().int(),
563
+ /** The box's integrations (#205), so a box made from the backup has them again. Absent: none, or an older host. */
564
+ integrations: z2.array(z2.string()).optional()
565
+ });
566
+ var HostUploadRequest = z2.object({ key: z2.string(), urls: z2.record(z2.string(), z2.string()), pin: z2.string().optional() });
567
+ var HostUploadResultSchema = z2.object({ chunks: z2.number().int(), bytes: z2.number().int(), sizes: z2.record(z2.string(), z2.number().int()) });
568
+ var HostRestoreRequest = z2.object({
479
569
  /** The backup's id: its variables were sealed under it. */
480
- id: z.string(),
481
- key: z.string(),
482
- sizeBytes: z.number().int().positive(),
483
- base: z.string(),
484
- image: z.string().optional(),
485
- env: z.string().nullable(),
486
- chunks: z.array(z.object({ index: z.number().int().nonnegative(), hash: z.string(), url: z.string() })),
570
+ id: z2.string(),
571
+ key: z2.string(),
572
+ sizeBytes: z2.number().int().positive(),
573
+ base: z2.string(),
574
+ image: z2.string().optional(),
575
+ env: z2.string().nullable(),
576
+ chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
487
577
  /** The certificate fingerprint of the store the URLs point at (see HostUploadRequest). */
488
- pin: z.string().optional()
578
+ pin: z2.string().optional()
489
579
  });
490
- var VolumeBackupSchema = z.object({
491
- id: z.string(),
492
- owner: z.string(),
493
- volume: z.string(),
494
- status: z.enum(BACKUP_STATUSES),
580
+ var VolumeBackupSchema = z2.object({
581
+ id: z2.string(),
582
+ owner: z2.string(),
583
+ volume: z2.string(),
584
+ status: z2.enum(BACKUP_STATUSES),
495
585
  /** Why it failed; null otherwise. */
496
- error: z.string().nullable(),
586
+ error: z2.string().nullable(),
497
587
  /** The volume's size when taken. */
498
- diskBytes: z.number().int().nullable(),
588
+ diskBytes: z2.number().int().nullable(),
499
589
  /** What it holds: the slots that are not all zeros. */
500
- dataBytes: z.number().int().nullable(),
590
+ dataBytes: z2.number().int().nullable(),
501
591
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
502
- uploadedBytes: z.number().int().nullable(),
503
- createdBy: z.string().nullable(),
504
- createdAt: z.string(),
505
- finishedAt: z.string().nullable()
592
+ uploadedBytes: z2.number().int().nullable(),
593
+ createdBy: z2.string().nullable(),
594
+ createdAt: z2.string(),
595
+ finishedAt: z2.string().nullable()
506
596
  });
507
- var BackupScheduleSchema = z.object({
508
- enabled: z.boolean(),
597
+ var BackupScheduleSchema = z2.object({
598
+ enabled: z2.boolean(),
509
599
  /** 0-23, UTC. Kept while it is off, so turning it on again keeps the hour. */
510
- hour: z.number().int().min(0).max(23),
511
- nextAt: z.string().nullable(),
512
- lastAt: z.string().nullable(),
513
- lastBackup: z.string().nullable(),
514
- lastError: z.string().nullable()
515
- });
516
- var SetBackupScheduleRequest = z.object({ enabled: z.boolean().optional(), hour: z.number().int().min(0).max(23).optional() });
517
- var HostVolumeBackupManifestSchema = z.object({ id: z.string(), sizeBytes: z.number().int(), chunks: z.array(z.string().nullable()) });
518
- var HostVolumeRestoreRequest = z.object({
519
- id: z.string(),
520
- key: z.string(),
521
- sizeBytes: z.number().int().positive(),
522
- chunks: z.array(z.object({ index: z.number().int().nonnegative(), hash: z.string(), url: z.string() })),
523
- pin: z.string().optional()
524
- });
525
- var BackupStoreSetupRequest = z.object({ path: z.string().min(1), force: z.boolean().optional(), newStore: z.boolean().optional() });
526
- var BackupStoreStatusSchema = z.object({
527
- path: z.string(),
528
- bucket: z.string(),
529
- accessKey: z.string(),
600
+ hour: z2.number().int().min(0).max(23),
601
+ nextAt: z2.string().nullable(),
602
+ lastAt: z2.string().nullable(),
603
+ lastBackup: z2.string().nullable(),
604
+ lastError: z2.string().nullable()
605
+ });
606
+ var SetBackupScheduleRequest = z2.object({ enabled: z2.boolean().optional(), hour: z2.number().int().min(0).max(23).optional() });
607
+ var HostVolumeBackupManifestSchema = z2.object({ id: z2.string(), sizeBytes: z2.number().int(), chunks: z2.array(z2.string().nullable()) });
608
+ var HostVolumeRestoreRequest = z2.object({
609
+ id: z2.string(),
610
+ key: z2.string(),
611
+ sizeBytes: z2.number().int().positive(),
612
+ chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
613
+ pin: z2.string().optional()
614
+ });
615
+ var BackupStoreSetupRequest = z2.object({ path: z2.string().min(1), force: z2.boolean().optional(), newStore: z2.boolean().optional() });
616
+ var BackupStoreStatusSchema = z2.object({
617
+ path: z2.string(),
618
+ bucket: z2.string(),
619
+ accessKey: z2.string(),
530
620
  /** Whether Garage is running and can store. */
531
- running: z.boolean(),
621
+ running: z2.boolean(),
532
622
  /** The filesystem the path is on. */
533
- totalBytes: z.number().int(),
534
- freeBytes: z.number().int(),
623
+ totalBytes: z2.number().int(),
624
+ freeBytes: z2.number().int(),
535
625
  /** What the bucket holds, when Garage answers. */
536
- objects: z.number().int().optional(),
537
- storedBytes: z.number().int().optional(),
626
+ objects: z2.number().int().optional(),
627
+ storedBytes: z2.number().int().optional(),
538
628
  /** Whether the control plane took the store's registration at setup. */
539
- registered: z.boolean().optional()
629
+ registered: z2.boolean().optional()
540
630
  });
541
- var BackupStoreRegistration = z.object({ bucket: z.string().min(1), region: z.string().min(1), accessKey: z.string().min(1), secretKey: z.string().min(1) });
542
- var CloudBackupStoreSchema = z.object({
543
- id: z.string(),
631
+ var BackupStoreRegistration = z2.object({ bucket: z2.string().min(1), region: z2.string().min(1), accessKey: z2.string().min(1), secretKey: z2.string().min(1) });
632
+ var CloudBackupStoreSchema = z2.object({
633
+ id: z2.string(),
544
634
  /** Null while no host serves it (its host left; it comes back when a host registers its key and secret again). */
545
- host: z.string().nullable(),
546
- endpoint: z.string().nullable(),
547
- bucket: z.string(),
548
- accessKey: z.string(),
549
- createdAt: z.string(),
635
+ host: z2.string().nullable(),
636
+ endpoint: z2.string().nullable(),
637
+ bucket: z2.string(),
638
+ accessKey: z2.string(),
639
+ createdAt: z2.string(),
550
640
  /** The host answered a poll in the last minute and its Garage runs. */
551
- live: z.boolean(),
641
+ live: z2.boolean(),
552
642
  /** From the host's last poll; null when it never reported a store. */
553
- totalBytes: z.number().int().nullable(),
554
- freeBytes: z.number().int().nullable(),
643
+ totalBytes: z2.number().int().nullable(),
644
+ freeBytes: z2.number().int().nullable(),
555
645
  /** Ready backups kept here, and what their chunks take (encrypted, compressed). */
556
- backups: z.number().int(),
557
- storedBytes: z.number().int(),
646
+ backups: z2.number().int(),
647
+ storedBytes: z2.number().int(),
558
648
  /** How many boxes have a ready backup here (a box and an earlier one of the same name count once), how many volumes (#168) and managed databases (#186). */
559
- boxes: z.number().int(),
560
- volumes: z.number().int(),
561
- databases: z.number().int(),
649
+ boxes: z2.number().int(),
650
+ volumes: z2.number().int(),
651
+ databases: z2.number().int(),
562
652
  /** When the newest ready backup kept here finished; null when it keeps none. */
563
- lastBackupAt: z.string().nullable()
653
+ lastBackupAt: z2.string().nullable()
564
654
  });
565
- var StoredItemSchema = z.object({
566
- kind: z.enum(BACKUP_KINDS),
567
- owner: z.string(),
655
+ var StoredItemSchema = z2.object({
656
+ kind: z2.enum(BACKUP_KINDS),
657
+ owner: z2.string(),
568
658
  /** The box's or volume's name; a managed database's (#186) for its hidden volume. */
569
- name: z.string(),
659
+ name: z2.string(),
570
660
  /** The managed database's kind (`postgres`) when the volume is one's (#186); null otherwise. */
571
- managed: z.string().nullable(),
661
+ managed: z2.string().nullable(),
572
662
  /** The host the box (or volume) is on now; null when it is gone (its backups stay). */
573
- host: z.string().nullable(),
663
+ host: z2.string().nullable(),
574
664
  /** It is on the store's own host: losing that host loses it and its backups together. */
575
- sameHost: z.boolean(),
665
+ sameHost: z2.boolean(),
576
666
  /** Ready backups kept here, and what they added to the store together (encrypted, compressed). */
577
- backups: z.number().int(),
578
- uploadedBytes: z.number().int(),
667
+ backups: z2.number().int(),
668
+ uploadedBytes: z2.number().int(),
579
669
  /** The newest backup sent here, whatever became of it. */
580
- latest: z.object({ id: z.string(), status: z.enum(BACKUP_STATUSES), error: z.string().nullable(), createdAt: z.string() })
670
+ latest: z2.object({ id: z2.string(), status: z2.enum(BACKUP_STATUSES), error: z2.string().nullable(), createdAt: z2.string() })
581
671
  });
582
- var FailedBackupSchema = z.object({
583
- id: z.string(),
584
- owner: z.string(),
672
+ var FailedBackupSchema = z2.object({
673
+ id: z2.string(),
674
+ owner: z2.string(),
585
675
  /** What it was a backup of: a box or a volume (#168), and its name; a managed database's (#186) for its hidden volume. */
586
- kind: z.enum(BACKUP_KINDS),
587
- name: z.string(),
676
+ kind: z2.enum(BACKUP_KINDS),
677
+ name: z2.string(),
588
678
  /** The managed database's kind (`postgres`) when the volume is one's; null otherwise. */
589
- managed: z.string().nullable(),
590
- error: z.string().nullable(),
679
+ managed: z2.string().nullable(),
680
+ error: z2.string().nullable(),
591
681
  /** The host that took it, and the host of the store it was going to; null when gone, or when it failed before a store was picked. */
592
- host: z.string().nullable(),
593
- store: z.string().nullable(),
594
- createdAt: z.string()
682
+ host: z2.string().nullable(),
683
+ store: z2.string().nullable(),
684
+ createdAt: z2.string()
595
685
  });
596
- var MachineSchema = z.object({
686
+ var MachineSchema = z2.object({
597
687
  /** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
598
- id: z.string(),
599
- name: z.string(),
688
+ id: z2.string(),
689
+ name: z2.string(),
600
690
  /** Who the box belongs to; names are unique per owner. A bare name is local to the host, `user@control-plane` later. */
601
- owner: z.string(),
602
- ip: z.string(),
603
- mac: z.string(),
604
- pid: z.number().int().nullable(),
605
- vcpu: z.number().int(),
606
- memMib: z.number().int(),
607
- diskBytes: z.number().int(),
691
+ owner: z2.string(),
692
+ ip: z2.string(),
693
+ mac: z2.string(),
694
+ pid: z2.number().int().nullable(),
695
+ vcpu: z2.number().int(),
696
+ memMib: z2.number().int(),
697
+ diskBytes: z2.number().int(),
608
698
  // the box's own writable disk, as the guest sees it
609
- diskUsedBytes: z.number().int(),
699
+ diskUsedBytes: z2.number().int(),
610
700
  // what the box uses of it: the filesystem's own count, like the guest's `df` (#115)
611
701
  /** What the disk's sparse file occupies on the host. Grows while the box runs, `kvbox stop` trims it back. Hosts before 0.5.42 do not send it. */
612
- diskHostBytes: z.number().int().optional(),
613
- base: z.string(),
702
+ diskHostBytes: z2.number().int().optional(),
703
+ base: z2.string(),
614
704
  // version of the image the box's overlay stacks on
615
705
  /** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
616
- image: z.string().optional(),
617
- createdAt: z.string(),
618
- source: z.string(),
619
- // "base", "snapshot:<owner/name>" or "fork:<owner/name>" (#79)
706
+ image: z2.string().optional(),
707
+ createdAt: z2.string(),
708
+ source: z2.string(),
709
+ // "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
620
710
  status: BoxStatusSchema,
621
711
  /**
622
712
  * Public TCP port on the host that reaches the box's SSH while it runs (#49). Only boxes made
623
713
  * through a control plane have one; the control plane adds the host's address for `connect` (#21).
624
714
  */
625
- sshPort: z.number().int().optional(),
715
+ sshPort: z2.number().int().optional(),
626
716
  /**
627
717
  * Where `ssh` reaches the box from outside: the host's public address and that port (#21). Only
628
718
  * the control plane fills it in (a host does not know its own public address); absent for a box
629
719
  * whose host reported no port or did not answer.
630
720
  */
631
- ssh: z.object({ host: z.string(), port: z.number().int(), user: z.string() }).optional(),
721
+ ssh: z2.object({ host: z2.string(), port: z2.number().int(), user: z2.string() }).optional(),
632
722
  /** Box ports published on the host (#30). Absent: none. */
633
- ports: z.array(PortForwardSchema).optional(),
723
+ ports: z2.array(PortForwardSchema).optional(),
634
724
  /** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /machines`. */
635
- ownerKind: z.enum(["user", "org"]).optional(),
725
+ ownerKind: z2.enum(["user", "org"]).optional(),
636
726
  /**
637
727
  * The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
638
728
  * links to, and a volume attaches to, only a box on the same host.
639
729
  */
640
- host: z.string().optional(),
730
+ host: z2.string().optional(),
641
731
  /** The country code of that host (`RO`, `US`), when its admin gave one. Only the control plane fills it in. */
642
- country: z.string().optional(),
732
+ country: z2.string().optional(),
643
733
  /**
644
734
  * The kind of managed service the box runs (`postgres`, `redis`, `storage`). Only an admin's
645
735
  * `GET /machines?all=1` lists such boxes, so a host's boxes add up; every other listing hides them.
646
736
  */
647
- managed: z.string().optional(),
737
+ managed: z2.string().optional(),
648
738
  /** Seconds without network traffic before the host hibernates the box (#47). Absent: never. */
649
- autoHibernateSec: z.number().int().positive().optional(),
739
+ autoHibernateSec: z2.number().int().positive().optional(),
650
740
  /** A script inside the box that says it is idle (#102, exit 0): auto-hibernate asks it instead of watching the traffic. */
651
- idleCheck: z.string().optional(),
741
+ idleCheck: z2.string().optional(),
652
742
  /** Volumes attached to the box (#52), in drive order; each is mounted at `mountPath` while the box runs. Absent: none. */
653
- volumes: z.array(z.object({ name: z.string(), sizeGib: z.number().int(), mountPath: z.string() })).optional(),
743
+ volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
654
744
  /** Boxes that may reach this one, each on one port (#98). Absent: none. */
655
- links: z.array(BoxLinkSchema).optional(),
745
+ links: z2.array(BoxLinkSchema).optional(),
746
+ /**
747
+ * The integrations turned on for the box (#205, `github`): names only, the credential is fetched by the box
748
+ * each time it is needed. Absent: none. A host before integrations never sends it.
749
+ */
750
+ integrations: z2.array(z2.string()).optional(),
656
751
  /** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
657
- url: z.string().optional(),
752
+ url: z2.string().optional(),
658
753
  /**
659
754
  * Only in what `POST /machines` answers, for an image that declares one (#87): how to reach what it
660
755
  * serves, e.g. `postgres://postgres:<password>@db.kvbox:5432/postgres`. Holds the box's variables.
661
756
  */
662
- connect: z.string().optional()
757
+ connect: z2.string().optional()
663
758
  });
664
- var VolumeSchema = z.object({
759
+ var VolumeSchema = z2.object({
665
760
  /** The host's 6-hex volume id (#91): the ledger's key, so a name removed and made again is two volumes. */
666
- id: z.string(),
667
- name: z.string(),
668
- owner: z.string(),
669
- sizeGib: z.number().int(),
761
+ id: z2.string(),
762
+ name: z2.string(),
763
+ owner: z2.string(),
764
+ sizeGib: z2.number().int(),
670
765
  /** What the sparse file really occupies on the host. */
671
- usedBytes: z.number().int(),
672
- attachedTo: z.string().nullable(),
673
- createdAt: z.string(),
766
+ usedBytes: z2.number().int(),
767
+ attachedTo: z2.string().nullable(),
768
+ createdAt: z2.string(),
674
769
  /** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /volumes`. */
675
- ownerKind: z.enum(["user", "org"]).optional(),
770
+ ownerKind: z2.enum(["user", "org"]).optional(),
676
771
  /** The name of the host the volume lives on; only the control plane fills it in. It attaches only to a box there. */
677
- host: z.string().optional()
772
+ host: z2.string().optional()
678
773
  });
679
774
  var MAX_VOLUME_GIB = 4096;
680
775
  var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
681
776
  var VOLUME_NAME_RULE = "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit";
682
- var CreateVolumeRequest = z.object({
683
- name: z.string(),
684
- sizeGib: z.number().int().min(1).max(MAX_VOLUME_GIB),
777
+ var CreateVolumeRequest = z2.object({
778
+ name: z2.string(),
779
+ sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB),
685
780
  /**
686
781
  * Through a control plane (#91): the box this volume is for, so it is made on that box's host; the
687
782
  * control plane requires it (a volume attaches only to a box on its own host, so one made for no box
688
783
  * could never attach) and the CLI attaches right after. A host ignores it.
689
784
  */
690
- box: z.string().optional()
785
+ box: z2.string().optional()
691
786
  });
692
- var AttachVolumeRequest = z.object({
693
- box: z.string()
787
+ var AttachVolumeRequest = z2.object({
788
+ box: z2.string()
694
789
  });
695
- var ResizeVolumeRequest = z.object({
696
- sizeGib: z.number().int().min(1).max(MAX_VOLUME_GIB)
790
+ var ResizeVolumeRequest = z2.object({
791
+ sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB)
697
792
  });
698
- var RunScriptRequest = z.object({ input: z.unknown().optional() });
699
- var ScriptOutputSchema = z.object({ output: z.unknown() });
793
+ var RunScriptRequest = z2.object({ input: z2.unknown().optional() });
794
+ var ScriptOutputSchema = z2.object({ output: z2.unknown() });
700
795
  var BOX_RUN_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
701
- var StartRunRequest = z.object({
702
- id: z.string().regex(BOX_RUN_ID_RE),
703
- command: z.string().min(1).max(8192),
796
+ var StartRunRequest = z2.object({
797
+ id: z2.string().regex(BOX_RUN_ID_RE),
798
+ command: z2.string().min(1).max(8192),
704
799
  /** The command and everything it started are killed after this long. */
705
- timeoutSec: z.number().int().min(1).max(86400),
800
+ timeoutSec: z2.number().int().min(1).max(86400),
706
801
  /**
707
802
  * The caller will read the output back (`exec`, #188): the box's kvbox-agent must know `runOutput`
708
803
  * (base v0.16.0+), which the host checks before the command starts, so an older box is `box-outdated`
709
804
  * without having run anything.
710
805
  */
711
- output: z.boolean().optional()
806
+ output: z2.boolean().optional()
712
807
  });
713
- var StartRunAnswerSchema = z.object({
714
- id: z.string(),
808
+ var StartRunAnswerSchema = z2.object({
809
+ id: z2.string(),
715
810
  /** False: a run of this id was already there. */
716
- started: z.boolean(),
811
+ started: z2.boolean(),
717
812
  /** The box was asleep and this request woke it. */
718
- woke: z.boolean()
813
+ woke: z2.boolean()
719
814
  });
720
815
  var BOX_RUN_STATES = ["running", "exited", "timeout", "unknown"];
721
- var BoxRunSchema = z.object({
722
- id: z.string(),
723
- state: z.enum(BOX_RUN_STATES),
816
+ var BoxRunSchema = z2.object({
817
+ id: z2.string(),
818
+ state: z2.enum(BOX_RUN_STATES),
724
819
  /** With `exited`; 128 + the signal for a command a signal ended. */
725
- exitCode: z.number().int().optional(),
820
+ exitCode: z2.number().int().optional(),
726
821
  /**
727
822
  * With `exited` and `timeout`: how long the command itself ran, by the box's own clock (base v0.15.1
728
823
  * and later). The asker learns of the end seconds late, so its own count is too long.
729
824
  */
730
- durationMs: z.number().int().nonnegative().optional()
825
+ durationMs: z2.number().int().nonnegative().optional()
731
826
  });
732
- var RunRefusalSchema = z.object({ error: z.string(), code: z.string().optional() });
827
+ var RunRefusalSchema = z2.object({ error: z2.string(), code: z2.string().optional() });
733
828
  var RUN_OUTPUT_MAX_BYTES = 1 << 20;
734
829
  var RUN_STREAMS = ["stdout", "stderr"];
735
- var RunOutputSchema = z.object({
736
- id: z.string(),
737
- stream: z.enum(RUN_STREAMS),
738
- offset: z.number().int().nonnegative(),
739
- size: z.number().int().nonnegative(),
740
- data: z.string()
830
+ var RunOutputSchema = z2.object({
831
+ id: z2.string(),
832
+ stream: z2.enum(RUN_STREAMS),
833
+ offset: z2.number().int().nonnegative(),
834
+ size: z2.number().int().nonnegative(),
835
+ data: z2.string()
741
836
  });
742
837
  var DEFAULT_EXEC_TIMEOUT_SEC = 600;
743
- var ExecRequest = z.object({
744
- command: z.string().min(1).max(8192),
838
+ var ExecRequest = z2.object({
839
+ command: z2.string().min(1).max(8192),
745
840
  /** The command and everything it started are killed after this long (default DEFAULT_EXEC_TIMEOUT_SEC). */
746
- timeoutSec: z.number().int().min(1).max(86400).optional()
841
+ timeoutSec: z2.number().int().min(1).max(86400).optional()
747
842
  });
748
- var ExecStartSchema = z.object({
749
- id: z.string(),
843
+ var ExecStartSchema = z2.object({
844
+ id: z2.string(),
750
845
  /** The box was asleep and this request woke it. */
751
- woke: z.boolean()
846
+ woke: z2.boolean()
752
847
  });
753
- var ExecSchema = z.object({
754
- id: z.string(),
755
- state: z.enum(BOX_RUN_STATES),
848
+ var ExecSchema = z2.object({
849
+ id: z2.string(),
850
+ state: z2.enum(BOX_RUN_STATES),
756
851
  /** With `exited`; 128 + the signal for a command a signal ended. */
757
- exitCode: z.number().int().optional(),
852
+ exitCode: z2.number().int().optional(),
758
853
  /** With `exited` and `timeout`: how long the command itself ran. */
759
- durationMs: z.number().int().nonnegative().optional(),
760
- stdout: z.string().optional(),
761
- stderr: z.string().optional(),
762
- stdoutBytes: z.number().int().nonnegative().optional(),
763
- stderrBytes: z.number().int().nonnegative().optional(),
764
- truncated: z.boolean().optional()
765
- });
766
- var EnvVarSchema = z.object({
767
- name: z.string(),
768
- value: z.string().optional(),
769
- secret: z.boolean(),
770
- updatedAt: z.string()
771
- });
772
- var BoxEnvSchema = z.object({
773
- box: z.string(),
774
- vars: z.array(EnvVarSchema)
775
- });
776
- var BoxEnvChangeSchema = z.object({
777
- box: z.string(),
778
- name: z.string(),
854
+ durationMs: z2.number().int().nonnegative().optional(),
855
+ stdout: z2.string().optional(),
856
+ stderr: z2.string().optional(),
857
+ stdoutBytes: z2.number().int().nonnegative().optional(),
858
+ stderrBytes: z2.number().int().nonnegative().optional(),
859
+ truncated: z2.boolean().optional()
860
+ });
861
+ var EnvVarSchema = z2.object({
862
+ name: z2.string(),
863
+ value: z2.string().optional(),
864
+ secret: z2.boolean(),
865
+ updatedAt: z2.string()
866
+ });
867
+ var BoxEnvSchema = z2.object({
868
+ box: z2.string(),
869
+ vars: z2.array(EnvVarSchema)
870
+ });
871
+ var BoxEnvChangeSchema = z2.object({
872
+ box: z2.string(),
873
+ name: z2.string(),
779
874
  /** Whether the box is running now: the change waits for its next start. */
780
- running: z.boolean()
875
+ running: z2.boolean()
781
876
  });
782
- var SetEnvRequest = z.object({
783
- value: z.string(),
784
- secret: z.boolean().optional()
877
+ var SetEnvRequest = z2.object({
878
+ value: z2.string(),
879
+ secret: z2.boolean().optional()
785
880
  });
786
- var EnvChangeSchema = z.object({
787
- owner: z.string(),
788
- name: z.string(),
789
- boxes: z.number().int()
881
+ var EnvChangeSchema = z2.object({
882
+ owner: z2.string(),
883
+ name: z2.string(),
884
+ boxes: z2.number().int()
790
885
  });
791
- var HostEnvRequest = z.object({
792
- version: z.number().int().min(0),
793
- vars: z.array(z.object({ name: z.string(), value: z.string() }))
886
+ var HostEnvRequest = z2.object({
887
+ version: z2.number().int().min(0),
888
+ vars: z2.array(z2.object({ name: z2.string(), value: z2.string() }))
794
889
  });
795
- var HostEnvVersionsSchema = z.array(z.object({ owner: z.string(), version: z.number().int() }));
796
- var CreateMachineRequest = z.object({
797
- name: z.string().optional(),
890
+ var HostEnvVersionsSchema = z2.array(z2.object({ owner: z2.string(), version: z2.number().int() }));
891
+ var CreateMachineRequest = z2.object({
892
+ name: z2.string().optional(),
798
893
  /** Ignored over the local socket (the caller is the host owner); the control plane sets it over HTTPS. */
799
- owner: z.string().optional(),
894
+ owner: z2.string().optional(),
800
895
  size: SizeSchema.optional(),
801
- from: z.string().optional(),
802
- force: z.boolean().optional(),
896
+ from: z2.string().optional(),
897
+ force: z2.boolean().optional(),
803
898
  /**
804
899
  * Extra authorized_keys lines for the box, on top of the host's own key: the control plane sends
805
900
  * its SSH CA as one `cert-authority …` line (#51). Written into the box's authorized_keys at every
806
901
  * boot (#49); a host older than that ignores them.
807
902
  */
808
- sshKeys: z.array(z.string()).optional(),
903
+ sshKeys: z2.array(z2.string()).optional(),
809
904
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. Absent: the host's default. */
810
- autoHibernateSec: z.number().int().min(0).optional(),
905
+ autoHibernateSec: z2.number().int().min(0).optional(),
811
906
  /**
812
907
  * Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
813
908
  * control plane reads it; a host has one place to put a box.
814
909
  */
815
- near: z.string().optional(),
910
+ near: z2.string().optional(),
816
911
  /**
817
912
  * Place the box on a host in this country (`kvbox new --country romania`): a code or an English name,
818
913
  * `@kvbox/shared/country`. Only the control plane reads it.
819
914
  */
820
- country: z.string().optional(),
915
+ country: z2.string().optional(),
821
916
  /**
822
917
  * Place the box on the host of this name and nowhere else (`kvbox new --host kvbox2`, a hidden flag):
823
918
  * an admin's, to try a host out. Only the control plane reads it, and refuses it from anyone else.
824
919
  */
825
- host: z.string().optional(),
920
+ host: z2.string().optional(),
826
921
  /** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
827
- image: z.string().optional(),
922
+ image: z2.string().optional(),
828
923
  /** The box's own environment variables (#87, `kvbox new -e NAME=value`), over its owner's. */
829
- env: z.array(z.object({ name: z.string(), value: z.string() })).optional()
924
+ env: z2.array(z2.object({ name: z2.string(), value: z2.string() })).optional(),
925
+ /**
926
+ * Start the box on this backup's disk (#141, `kvbox new --from-backup <id>`), a removed box's too: its image,
927
+ * version and variables come from the backup, its size too unless given. Only the control plane reads it.
928
+ */
929
+ fromBackup: z2.string().optional(),
930
+ /**
931
+ * The integrations turned on for the box (#205, `kvbox new --integration github`). Absent: none, or with
932
+ * `from` / `fromBackup` the list the snapshot or the backup was taken with.
933
+ */
934
+ integrations: IntegrationListSchema.optional()
830
935
  });
831
- var ForkMachineRequest = z.object({
832
- name: z.string().optional(),
936
+ var HostFromBackupRequest = CreateMachineRequest.omit({ from: true, fromBackup: true, image: true, env: true }).extend({ backup: HostRestoreRequest });
937
+ var ForkMachineRequest = z2.object({
938
+ name: z2.string().optional(),
833
939
  /**
834
940
  * The new box's slug, bare (`acme`): the control plane sends the target of `--org` here; the host
835
941
  * qualifies it with the caller's realm. Absent: the source's owner. A CLI leaves it out.
836
942
  */
837
- owner: z.string().optional(),
943
+ owner: z2.string().optional(),
838
944
  /** A cold fork only: a warm one keeps the source's vCPU and memory. */
839
945
  size: SizeSchema.optional(),
840
- force: z.boolean().optional(),
946
+ force: z2.boolean().optional(),
841
947
  /** As in CreateMachineRequest: the control plane's CA line for the new box's owner. */
842
- sshKeys: z.array(z.string()).optional(),
843
- autoHibernateSec: z.number().int().min(0).optional()
948
+ sshKeys: z2.array(z2.string()).optional(),
949
+ autoHibernateSec: z2.number().int().min(0).optional()
844
950
  });
845
- var SetSshKeysRequest = z.object({
846
- sshKeys: z.array(z.string())
951
+ var SetSshKeysRequest = z2.object({
952
+ sshKeys: z2.array(z2.string())
847
953
  });
848
- var RescaleMachineRequest = z.object({
954
+ var RescaleMachineRequest = z2.object({
849
955
  size: SizeSchema.optional(),
850
- vcpu: z.number().int().min(1).max(64).optional(),
851
- memMib: z.number().int().min(256).optional(),
852
- diskGib: z.number().int().min(1).optional(),
956
+ vcpu: z2.number().int().min(1).max(64).optional(),
957
+ memMib: z2.number().int().min(256).optional(),
958
+ diskGib: z2.number().int().min(1).optional(),
853
959
  /** Skip the capacity guard when a running box grows (#37). */
854
- force: z.boolean().optional()
960
+ force: z2.boolean().optional()
855
961
  });
856
- var StartMachineRequest = z.object({
857
- force: z.boolean().optional()
962
+ var StartMachineRequest = z2.object({
963
+ force: z2.boolean().optional()
858
964
  });
859
- var SetMachineRequest = z.object({
965
+ var SetMachineRequest = z2.object({
860
966
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. */
861
- autoHibernateSec: z.number().int().min(0).optional(),
967
+ autoHibernateSec: z2.number().int().min(0).optional(),
862
968
  /** The box's idle check (#102): an absolute path to a script inside the box, exit 0 = idle; "": none, back to network traffic. */
863
- idleCheck: z.union([z.literal(""), z.string().max(255).regex(/^\/[^\0\n]*$/, "an absolute path inside the box")]).optional()
864
- });
865
- var SnapshotSchema = z.object({
866
- name: z.string(),
867
- owner: z.string(),
868
- source: z.string(),
969
+ idleCheck: z2.union([z2.literal(""), z2.string().max(255).regex(/^\/[^\0\n]*$/, "an absolute path inside the box")]).optional(),
970
+ /** The box's integrations (#205), the whole list: `[]` turns every one off. Applies at once, in any state. */
971
+ integrations: IntegrationListSchema.optional()
972
+ });
973
+ var SnapshotSchema = z2.object({
974
+ name: z2.string(),
975
+ owner: z2.string(),
976
+ source: z2.string(),
869
977
  // the box it was taken from, as owner/name
870
- base: z.string(),
978
+ base: z2.string(),
871
979
  // version of the image the overlay stacks on; a restore needs the same one
872
980
  /** As in MachineSchema: the image when it is not the base one (#87). */
873
- image: z.string().optional(),
874
- vcpu: z.number().int(),
875
- memMib: z.number().int(),
876
- sizeBytes: z.number().int(),
981
+ image: z2.string().optional(),
982
+ vcpu: z2.number().int(),
983
+ memMib: z2.number().int(),
984
+ sizeBytes: z2.number().int(),
877
985
  // what vmstate + mem + overlay really occupy on the host
878
- createdAt: z.string()
986
+ createdAt: z2.string()
879
987
  });
880
- var CreateSnapshotRequest = z.object({
881
- box: z.string(),
882
- name: z.string(),
988
+ var CreateSnapshotRequest = z2.object({
989
+ box: z2.string(),
990
+ name: z2.string(),
883
991
  /** Retake a snapshot under a name that exists (#83): the old one goes only once the new one is complete. */
884
- replace: z.boolean().optional()
885
- });
886
- var DiskCapacitySchema = z.object({
887
- totalGib: z.number().int(),
888
- freeGib: z.number().int(),
889
- volumesGib: z.number().int(),
890
- volumesUsedGib: z.number().int(),
891
- headroomGib: z.number().int()
892
- });
893
- var CapacitySchema = z.object({
894
- hostMemMib: z.number().int(),
895
- hostCores: z.number().int(),
896
- reservedMemMib: z.number().int(),
897
- reservedVcpu: z.number().int(),
898
- running: z.number().int(),
992
+ replace: z2.boolean().optional()
993
+ });
994
+ var DiskCapacitySchema = z2.object({
995
+ totalGib: z2.number().int(),
996
+ freeGib: z2.number().int(),
997
+ volumesGib: z2.number().int(),
998
+ volumesUsedGib: z2.number().int(),
999
+ headroomGib: z2.number().int()
1000
+ });
1001
+ var CapacitySchema = z2.object({
1002
+ hostMemMib: z2.number().int(),
1003
+ hostCores: z2.number().int(),
1004
+ reservedMemMib: z2.number().int(),
1005
+ reservedVcpu: z2.number().int(),
1006
+ running: z2.number().int(),
899
1007
  /**
900
1008
  * MiB of RAM the host keeps back from its boxes (config.json `memHeadroomMib`). Absent on a kvbox-server
901
1009
  * from before the setting, which keeps 2 GB (`OLD_HOST_MEM_HEADROOM_MIB`).
902
1010
  */
903
- memHeadroomMib: z.number().int().optional(),
1011
+ memHeadroomMib: z2.number().int().optional(),
904
1012
  /** Absent on a host from before volumes (#91): it cannot take one. */
905
1013
  disk: DiskCapacitySchema.optional(),
906
1014
  /**
907
1015
  * The images a new box can be made from here (#87), with the version `new` uses; the base is `base`.
908
1016
  * Absent on a host from before images: it has only the base.
909
1017
  */
910
- images: z.array(z.object({ name: z.string(), version: z.string() })).optional(),
1018
+ images: z2.array(z2.object({ name: z2.string(), version: z2.string() })).optional(),
911
1019
  /** kvbox-server's version, so the control plane's host list shows it without a call per host. Older servers omit it. */
912
- version: z.string().optional(),
1020
+ version: z2.string().optional(),
913
1021
  /** Present on a host set up as a backup store: the disk its Garage keeps chunks on, and whether Garage runs. */
914
- backupStore: z.object({ totalBytes: z.number().int(), freeBytes: z.number().int(), running: z.boolean() }).optional(),
1022
+ backupStore: z2.object({ totalBytes: z2.number().int(), freeBytes: z2.number().int(), running: z2.boolean() }).optional(),
915
1023
  /** True on a kvbox-server that reaches a backup store by its certificate's `pin`; older ones omit it and cannot back up to a store. */
916
- storeClient: z.boolean().optional()
917
- });
918
- var ImageSchema = z.object({ name: z.string(), version: z.string().nullable() });
919
- var ImageIndexSchema = z.object({
920
- updatedAt: z.string(),
921
- images: z.record(z.string(), z.object({ version: z.string().min(1), minServer: z.string().min(1).optional() }))
922
- });
923
- var LatestImagesSchema = z.object({
924
- updatedAt: z.string().nullable(),
1024
+ storeClient: z2.boolean().optional(),
1025
+ /** True on a kvbox-server with `POST /machines/from-backup` (#141, `kvbox new --from-backup`); older ones omit it. */
1026
+ fromBackup: z2.boolean().optional(),
1027
+ /** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
1028
+ integrations: z2.boolean().optional()
1029
+ });
1030
+ var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
1031
+ var ImageIndexSchema = z2.object({
1032
+ updatedAt: z2.string(),
1033
+ images: z2.record(z2.string(), z2.object({ version: z2.string().min(1), minServer: z2.string().min(1).optional() }))
1034
+ });
1035
+ var LatestImagesSchema = z2.object({
1036
+ updatedAt: z2.string().nullable(),
925
1037
  images: ImageIndexSchema.shape.images,
926
- checkedAt: z.string().nullable()
927
- });
928
- var RecoveryReportSchema = z.object({
929
- at: z.string(),
930
- booted: z.array(z.string()),
931
- leftStopped: z.array(z.string()),
932
- failed: z.array(z.object({ box: z.string(), error: z.string() }))
933
- });
934
- var HostUpdateSchema = z.object({
935
- state: z.enum(["running", "done", "failed"]),
936
- startedAt: z.string(),
937
- finishedAt: z.string().nullable(),
1038
+ checkedAt: z2.string().nullable()
1039
+ });
1040
+ var RecoveryReportSchema = z2.object({
1041
+ at: z2.string(),
1042
+ booted: z2.array(z2.string()),
1043
+ leftStopped: z2.array(z2.string()),
1044
+ failed: z2.array(z2.object({ box: z2.string(), error: z2.string() }))
1045
+ });
1046
+ var HostUpdateSchema = z2.object({
1047
+ state: z2.enum(["running", "done", "failed"]),
1048
+ startedAt: z2.string(),
1049
+ finishedAt: z2.string().nullable(),
938
1050
  /** kvbox-server's version when the update started, and when it ended (null while running or when it failed before). */
939
- from: z.string(),
940
- to: z.string().nullable(),
941
- error: z.string().nullable(),
942
- needsManual: z.array(z.string())
943
- });
944
- var HealthSchema = z.object({
945
- ok: z.literal(true),
946
- version: z.string(),
947
- pid: z.number().int(),
1051
+ from: z2.string(),
1052
+ to: z2.string().nullable(),
1053
+ error: z2.string().nullable(),
1054
+ needsManual: z2.array(z2.string())
1055
+ });
1056
+ var HealthSchema = z2.object({
1057
+ ok: z2.literal(true),
1058
+ version: z2.string(),
1059
+ pid: z2.number().int(),
948
1060
  /** Base image version new boxes get (null when the host has no usable base image yet). */
949
- base: z.string().nullable(),
1061
+ base: z2.string().nullable(),
950
1062
  /** Owner that boxes made over the local socket get (the Unix user running the server). */
951
- owner: z.string(),
1063
+ owner: z2.string(),
952
1064
  /** The control plane this host joined (null when none). */
953
- controlPlane: z.object({
1065
+ controlPlane: z2.object({
954
1066
  /** Realm name, e.g. kvbox.sh. */
955
- name: z.string(),
956
- url: z.string(),
1067
+ name: z2.string(),
1068
+ url: z2.string(),
957
1069
  /** Where this host answers the control plane. */
958
- hostUrl: z.string()
1070
+ hostUrl: z2.string()
959
1071
  }).nullable(),
960
1072
  /** The relay this host reaches the internet through (#50); null when it has its own public address. Older servers omit it. */
961
- relay: z.object({
962
- name: z.string(),
1073
+ relay: z2.object({
1074
+ name: z2.string(),
963
1075
  /** The public IP the relay owns for this host. */
964
- publicIp: z.string(),
1076
+ publicIp: z2.string(),
965
1077
  /** The relay's WireGuard endpoint the tunnel dials. */
966
- endpoint: z.string(),
1078
+ endpoint: z2.string(),
967
1079
  /** Times the server redialed the tunnel since it started, because the relay stopped answering. Older servers omit them. */
968
- restarts: z.number().int().optional(),
969
- lastRestartAt: z.string().nullable().optional()
1080
+ restarts: z2.number().int().optional(),
1081
+ lastRestartAt: z2.string().nullable().optional()
970
1082
  }).nullable().optional(),
971
1083
  /** Boxes brought back at the server's last start; null when there were none or it is still at it. Older servers omit it. */
972
1084
  recovery: RecoveryReportSchema.nullable().optional(),
973
1085
  /** The last self-update; null when none ran. Older servers omit it. */
974
1086
  update: HostUpdateSchema.nullable().optional()
975
1087
  });
976
- var MachineUsageSchema = z.object({
977
- name: z.string(),
978
- owner: z.string(),
1088
+ var MachineUsageSchema = z2.object({
1089
+ name: z2.string(),
1090
+ owner: z2.string(),
979
1091
  status: BoxStatusSchema,
980
- window: z.object({ from: z.string(), to: z.string() }),
981
- seconds: z.object({
982
- running: z.number().int(),
983
- standby: z.number().int(),
984
- hibernated: z.number().int(),
985
- stopped: z.number().int()
1092
+ window: z2.object({ from: z2.string(), to: z2.string() }),
1093
+ seconds: z2.object({
1094
+ running: z2.number().int(),
1095
+ standby: z2.number().int(),
1096
+ hibernated: z2.number().int(),
1097
+ stopped: z2.number().int()
986
1098
  }),
987
- vcpuHours: z.number(),
988
- ramGibHours: z.number(),
989
- diskGibHours: z.number(),
990
- cost: z.object({ amount: z.number(), currency: z.string() }).optional(),
1099
+ vcpuHours: z2.number(),
1100
+ ramGibHours: z2.number(),
1101
+ diskGibHours: z2.number(),
1102
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
991
1103
  /** Stops the server did not witness (Firecracker died, host rebooted) and dated to when it noticed. */
992
- estimatedStops: z.number().int(),
993
- historyFrom: z.string().nullable()
1104
+ estimatedStops: z2.number().int(),
1105
+ historyFrom: z2.string().nullable()
994
1106
  });
995
- var GuestStatsSchema = z.object({
1107
+ var GuestStatsSchema = z2.object({
996
1108
  /** Load average over 1, 5 and 15 minutes. */
997
- load: z.tuple([z.number(), z.number(), z.number()]),
998
- cpus: z.number().int(),
999
- memTotalMib: z.number().int(),
1109
+ load: z2.tuple([z2.number(), z2.number(), z2.number()]),
1110
+ cpus: z2.number().int(),
1111
+ memTotalMib: z2.number().int(),
1000
1112
  /** Total minus available: page cache counts as free. */
1001
- memUsedMib: z.number().int(),
1113
+ memUsedMib: z2.number().int(),
1002
1114
  /** The box's root, which is its overlay disk: the box's own writes, not the shared base. */
1003
- diskTotalBytes: z.number().int(),
1004
- diskUsedBytes: z.number().int(),
1005
- uptimeSec: z.number().int()
1115
+ diskTotalBytes: z2.number().int(),
1116
+ diskUsedBytes: z2.number().int(),
1117
+ uptimeSec: z2.number().int()
1006
1118
  });
1007
- var MachineStatsSchema = z.object({
1008
- name: z.string(),
1009
- owner: z.string(),
1119
+ var MachineStatsSchema = z2.object({
1120
+ name: z2.string(),
1121
+ owner: z2.string(),
1010
1122
  stats: GuestStatsSchema.nullable()
1011
1123
  });
1012
- var UsageStatusSchema = z.enum([...BoxStatusSchema.options, "removed"]);
1124
+ var UsageStatusSchema = z2.enum([...BoxStatusSchema.options, "removed"]);
1013
1125
  var BoxUsageSchema = MachineUsageSchema.omit({ window: true, status: true }).extend({
1014
1126
  /** The host's box id; a name removed and recreated appears twice, with two ids. */
1015
- id: z.string(),
1127
+ id: z2.string(),
1016
1128
  status: UsageStatusSchema,
1017
1129
  /** Through a control plane: whether the owner slug is a user's or an org's (what `kvbox ls` shows). */
1018
- ownerKind: z.enum(["user", "org"]).optional(),
1130
+ ownerKind: z2.enum(["user", "org"]).optional(),
1019
1131
  /**
1020
1132
  * Through a control plane: the username that made the box (#60), absent when the box is gone from
1021
1133
  * the index (removed), was found by reconcile, or its maker was deleted. The ledger does not record it.
1022
1134
  */
1023
- createdBy: z.string().optional()
1135
+ createdBy: z2.string().optional()
1024
1136
  });
1025
- var VolumeUsageSchema = z.object({
1137
+ var VolumeUsageSchema = z2.object({
1026
1138
  /** The host's volume id; a name removed and made again appears twice, with two ids. */
1027
- id: z.string(),
1028
- name: z.string(),
1029
- owner: z.string(),
1030
- ownerKind: z.enum(["user", "org"]).optional(),
1139
+ id: z2.string(),
1140
+ name: z2.string(),
1141
+ owner: z2.string(),
1142
+ ownerKind: z2.enum(["user", "org"]).optional(),
1031
1143
  /** The size at the end of the window (or when removed). */
1032
- sizeGib: z.number().int(),
1033
- status: z.enum(["present", "removed"]),
1034
- volumeHours: z.number(),
1035
- volumeGibHours: z.number(),
1036
- cost: z.object({ amount: z.number(), currency: z.string() }).optional(),
1037
- historyFrom: z.string().nullable()
1038
- });
1039
- var CronUsageSchema = z.object({
1040
- id: z.string(),
1041
- name: z.string(),
1042
- owner: z.string(),
1043
- ownerKind: z.enum(["user", "org"]).optional(),
1044
- status: z.enum(["present", "removed"]),
1045
- hours: z.number(),
1046
- cost: z.object({ amount: z.number(), currency: z.string() }).optional(),
1144
+ sizeGib: z2.number().int(),
1145
+ status: z2.enum(["present", "removed"]),
1146
+ volumeHours: z2.number(),
1147
+ volumeGibHours: z2.number(),
1148
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
1149
+ historyFrom: z2.string().nullable()
1150
+ });
1151
+ var CronUsageSchema = z2.object({
1152
+ id: z2.string(),
1153
+ name: z2.string(),
1154
+ owner: z2.string(),
1155
+ ownerKind: z2.enum(["user", "org"]).optional(),
1156
+ status: z2.enum(["present", "removed"]),
1157
+ hours: z2.number(),
1158
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
1047
1159
  /** When it was made. */
1048
- historyFrom: z.string().nullable()
1049
- });
1050
- var BackupUsageSchema = z.object({
1051
- id: z.string(),
1052
- kind: z.string(),
1053
- name: z.string(),
1054
- owner: z.string(),
1055
- ownerKind: z.enum(["user", "org"]).optional(),
1160
+ historyFrom: z2.string().nullable()
1161
+ });
1162
+ var BackupUsageSchema = z2.object({
1163
+ id: z2.string(),
1164
+ kind: z2.string(),
1165
+ name: z2.string(),
1166
+ owner: z2.string(),
1167
+ ownerKind: z2.enum(["user", "org"]).optional(),
1056
1168
  /** How many paid backups turned ready in the window. */
1057
- count: z.number().int(),
1058
- cost: z.object({ amount: z.number(), currency: z.string() })
1169
+ count: z2.number().int(),
1170
+ cost: z2.object({ amount: z2.number(), currency: z2.string() })
1059
1171
  });
1060
- var UsageDayItemSchema = z.object({
1061
- id: z.string(),
1062
- name: z.string(),
1063
- owner: z.string(),
1172
+ var UsageDayItemSchema = z2.object({
1173
+ id: z2.string(),
1174
+ name: z2.string(),
1175
+ owner: z2.string(),
1064
1176
  /** Removed by the end of the report's window. */
1065
- removed: z.boolean(),
1066
- cost: z.number()
1177
+ removed: z2.boolean(),
1178
+ cost: z2.number()
1067
1179
  });
1068
- var UsageDaySchema = z.object({
1180
+ var UsageDaySchema = z2.object({
1069
1181
  /** `YYYY-MM-DD`, UTC. */
1070
- date: z.string(),
1071
- from: z.string(),
1072
- to: z.string(),
1073
- cost: z.number(),
1074
- currency: z.string(),
1075
- boxes: z.array(UsageDayItemSchema),
1076
- volumes: z.array(UsageDayItemSchema),
1182
+ date: z2.string(),
1183
+ from: z2.string(),
1184
+ to: z2.string(),
1185
+ cost: z2.number(),
1186
+ currency: z2.string(),
1187
+ boxes: z2.array(UsageDayItemSchema),
1188
+ volumes: z2.array(UsageDayItemSchema),
1077
1189
  /** Object storage that existed that day (#182); absent on a day without any. */
1078
- storage: z.array(UsageDayItemSchema).optional(),
1190
+ storage: z2.array(UsageDayItemSchema).optional(),
1079
1191
  /** Cron services that existed that day (#190); absent on a day without any. */
1080
- cron: z.array(UsageDayItemSchema).optional(),
1192
+ cron: z2.array(UsageDayItemSchema).optional(),
1081
1193
  /** Paid backups that turned ready that day, summed per thing backed up (`id` is `<owner>/<kind>:<name>`); absent on a day without any. */
1082
- backups: z.array(UsageDayItemSchema).optional()
1194
+ backups: z2.array(UsageDayItemSchema).optional()
1083
1195
  });
1084
- var UsageReportSchema = z.object({
1085
- window: z.object({ from: z.string(), to: z.string() }),
1086
- boxes: z.array(BoxUsageSchema),
1196
+ var UsageReportSchema = z2.object({
1197
+ window: z2.object({ from: z2.string(), to: z2.string() }),
1198
+ boxes: z2.array(BoxUsageSchema),
1087
1199
  /** Absent from a side older than #91. */
1088
- volumes: z.array(VolumeUsageSchema).optional(),
1200
+ volumes: z2.array(VolumeUsageSchema).optional(),
1089
1201
  /**
1090
1202
  * Object storage (#182, control plane only): one row per storage a slug has or had, shaped like a
1091
1203
  * volume's. `volumeHours` are the hours it existed, `volumeGibHours` those of the GiB beyond the
1092
1204
  * included ones, `sizeGib` its whole size. Absent when there is none.
1093
1205
  */
1094
- storage: z.array(VolumeUsageSchema).optional(),
1206
+ storage: z2.array(VolumeUsageSchema).optional(),
1095
1207
  /** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
1096
- cron: z.array(CronUsageSchema).optional(),
1208
+ cron: z2.array(CronUsageSchema).optional(),
1097
1209
  /** Paid backups (control plane only): one row per box, volume or service backed up by hand in the window. Absent when there is none. */
1098
- backups: z.array(BackupUsageSchema).optional(),
1210
+ backups: z2.array(BackupUsageSchema).optional(),
1099
1211
  /** With `?by=day` only, oldest day first. */
1100
- days: z.array(UsageDaySchema).optional(),
1101
- totals: z.object({
1212
+ days: z2.array(UsageDaySchema).optional(),
1213
+ totals: z2.object({
1102
1214
  seconds: MachineUsageSchema.shape.seconds,
1103
- vcpuHours: z.number(),
1104
- ramGibHours: z.number(),
1105
- diskGibHours: z.number(),
1106
- volumeHours: z.number().optional(),
1107
- volumeGibHours: z.number().optional(),
1215
+ vcpuHours: z2.number(),
1216
+ ramGibHours: z2.number(),
1217
+ diskGibHours: z2.number(),
1218
+ volumeHours: z2.number().optional(),
1219
+ volumeGibHours: z2.number().optional(),
1108
1220
  /** Boxes, volumes, object storage, cron services and paid backups together. */
1109
- cost: z.object({ amount: z.number(), currency: z.string() }).optional()
1221
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
1110
1222
  })
1111
1223
  });
1112
- var UsageEventRowSchema = z.object({
1113
- id: z.number().int(),
1114
- boxId: z.string(),
1115
- owner: z.string(),
1116
- name: z.string(),
1117
- at: z.string(),
1118
- state: z.enum(["running", "standby", "hibernated", "stopped"]),
1119
- vcpu: z.number().int(),
1120
- memMib: z.number().int(),
1121
- diskGib: z.number().int(),
1122
- by: z.string()
1123
- });
1124
- var UsageEventsResponseSchema = z.object({
1125
- ledger: z.string().min(1),
1126
- events: z.array(UsageEventRowSchema),
1127
- next: z.number().int()
1128
- });
1129
- var VolumeEventRowSchema = z.object({
1130
- id: z.number().int(),
1131
- volumeId: z.string(),
1132
- owner: z.string(),
1133
- name: z.string(),
1134
- at: z.string(),
1135
- sizeGib: z.number().int(),
1136
- by: z.enum(["create", "resize", "rm"])
1137
- });
1138
- var VolumeEventsResponseSchema = z.object({
1139
- ledger: z.string().min(1),
1140
- events: z.array(VolumeEventRowSchema),
1141
- next: z.number().int()
1224
+ var UsageEventRowSchema = z2.object({
1225
+ id: z2.number().int(),
1226
+ boxId: z2.string(),
1227
+ owner: z2.string(),
1228
+ name: z2.string(),
1229
+ at: z2.string(),
1230
+ state: z2.enum(["running", "standby", "hibernated", "stopped"]),
1231
+ vcpu: z2.number().int(),
1232
+ memMib: z2.number().int(),
1233
+ diskGib: z2.number().int(),
1234
+ by: z2.string()
1235
+ });
1236
+ var UsageEventsResponseSchema = z2.object({
1237
+ ledger: z2.string().min(1),
1238
+ events: z2.array(UsageEventRowSchema),
1239
+ next: z2.number().int()
1240
+ });
1241
+ var VolumeEventRowSchema = z2.object({
1242
+ id: z2.number().int(),
1243
+ volumeId: z2.string(),
1244
+ owner: z2.string(),
1245
+ name: z2.string(),
1246
+ at: z2.string(),
1247
+ sizeGib: z2.number().int(),
1248
+ by: z2.enum(["create", "resize", "rm"])
1249
+ });
1250
+ var VolumeEventsResponseSchema = z2.object({
1251
+ ledger: z2.string().min(1),
1252
+ events: z2.array(VolumeEventRowSchema),
1253
+ next: z2.number().int()
1142
1254
  });
1143
1255
  var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking"];
1144
- var ApiErrorCodeSchema = z.enum(API_ERROR_CODES);
1145
- var ApiErrorSchema = z.object({
1146
- error: z.string(),
1256
+ var ApiErrorCodeSchema = z2.enum(API_ERROR_CODES);
1257
+ var ApiErrorSchema = z2.object({
1258
+ error: z2.string(),
1147
1259
  code: ApiErrorCodeSchema.optional()
1148
1260
  });
1149
1261
  var DEFAULT_CLOUD_URL = "https://api.kvbox.sh";
1150
1262
  var ACTIVATED_BY = ["card", "admin"];
1151
- var ActivatedBySchema = z.enum(ACTIVATED_BY);
1152
- var CloudUserSchema = z.object({
1263
+ var ActivatedBySchema = z2.enum(ACTIVATED_BY);
1264
+ var CloudUserSchema = z2.object({
1153
1265
  /** The handle: what hosts file boxes under (`<username>@<control plane>`). Lowercase, no `@` or `/`. */
1154
- username: z.string(),
1266
+ username: z2.string(),
1155
1267
  /** Display name, free text ("Alexandru Ghiura"). */
1156
- name: z.string(),
1268
+ name: z2.string(),
1157
1269
  /** Login identity, unique. */
1158
- email: z.string(),
1159
- role: z.enum(["admin", "user"]),
1160
- createdAt: z.string(),
1270
+ email: z2.string(),
1271
+ role: z2.enum(["admin", "user"]),
1272
+ createdAt: z2.string(),
1161
1273
  /**
1162
1274
  * False until a card is on file or an admin activates the account (#74): then only `/me` and
1163
1275
  * `/logout` answer. Admins are never gated. A control plane older than #74 does not send these and
1164
1276
  * gates nobody, hence the defaults: a newer CLI must still parse its answers.
1165
1277
  */
1166
- active: z.boolean().default(true),
1278
+ active: z2.boolean().default(true),
1167
1279
  activatedBy: ActivatedBySchema.nullable().default(null),
1168
1280
  /** When too many wrong passwords locked the account (#161); null when it is not locked. Older control planes omit it. */
1169
- lockedAt: z.string().nullable().default(null)
1281
+ lockedAt: z2.string().nullable().default(null)
1170
1282
  });
1171
1283
  var ORG_ROLES = ["owner", "admin", "member"];
1172
- var OrgRoleSchema = z.enum(ORG_ROLES);
1173
- var CloudOrgSchema = z.object({
1174
- slug: z.string(),
1284
+ var OrgRoleSchema = z2.enum(ORG_ROLES);
1285
+ var CloudOrgSchema = z2.object({
1286
+ slug: z2.string(),
1175
1287
  /** Display name; the slug never changes, this may. */
1176
- name: z.string(),
1177
- createdAt: z.string(),
1288
+ name: z2.string(),
1289
+ createdAt: z2.string(),
1178
1290
  /** An org pays for itself (#74): off until it has a card or an admin activates it; its boxes are 402. Defaults as on CloudUser. */
1179
- active: z.boolean().default(true),
1291
+ active: z2.boolean().default(true),
1180
1292
  activatedBy: ActivatedBySchema.nullable().default(null)
1181
1293
  });
1182
1294
  var OrgMembershipSchema = CloudOrgSchema.extend({ role: OrgRoleSchema });
1183
- var OrgMemberSchema = z.object({
1184
- username: z.string(),
1185
- name: z.string(),
1295
+ var OrgMemberSchema = z2.object({
1296
+ username: z2.string(),
1297
+ name: z2.string(),
1186
1298
  role: OrgRoleSchema,
1187
- addedAt: z.string()
1299
+ addedAt: z2.string()
1188
1300
  });
1189
- var OrgDetailSchema = CloudOrgSchema.extend({ members: z.array(OrgMemberSchema) });
1190
- var CreateOrgRequestSchema = z.object({
1191
- slug: z.string().min(1),
1192
- name: z.string().min(1)
1301
+ var OrgDetailSchema = CloudOrgSchema.extend({ members: z2.array(OrgMemberSchema) });
1302
+ var CreateOrgRequestSchema = z2.object({
1303
+ slug: z2.string().min(1),
1304
+ name: z2.string().min(1)
1193
1305
  });
1194
- var RenameOrgRequestSchema = z.object({ name: z.string().min(1) });
1195
- var AddMemberRequestSchema = z.object({
1196
- username: z.string().min(1),
1306
+ var RenameOrgRequestSchema = z2.object({ name: z2.string().min(1) });
1307
+ var AddMemberRequestSchema = z2.object({
1308
+ username: z2.string().min(1),
1197
1309
  role: OrgRoleSchema.default("member")
1198
1310
  });
1199
- var SetRoleRequestSchema = z.object({ role: OrgRoleSchema });
1200
- var MeResponseSchema = CloudUserSchema.extend({ orgs: z.array(OrgMembershipSchema) });
1201
- var BalanceSchema = z.object({
1202
- slug: z.string(),
1203
- balance: z.number(),
1204
- currency: z.string(),
1205
- topUps: z.number(),
1206
- spent: z.number(),
1311
+ var SetRoleRequestSchema = z2.object({ role: OrgRoleSchema });
1312
+ var MeResponseSchema = CloudUserSchema.extend({ orgs: z2.array(OrgMembershipSchema) });
1313
+ var BalanceSchema = z2.object({
1314
+ slug: z2.string(),
1315
+ balance: z2.number(),
1316
+ currency: z2.string(),
1317
+ topUps: z2.number(),
1318
+ spent: z2.number(),
1207
1319
  /** The first moment usage counts from: the slug's first top-up or redeemed code; null when it has none. */
1208
- since: z.string().nullable(),
1320
+ since: z2.string().nullable(),
1209
1321
  /** When the slug ran out and its boxes were hibernated (the `sweep-credit` job); null in good standing. Absent from a control plane older than this field. */
1210
- suspendedAt: z.string().nullable().default(null),
1322
+ suspendedAt: z2.string().nullable().default(null),
1211
1323
  /** Promo credit left (#163), already counted in `balance`; 0 with none. Absent from a control plane older than this field. */
1212
- promo: z.number().default(0),
1324
+ promo: z2.number().default(0),
1213
1325
  /** When the next promo credit expires; null with none left. */
1214
- promoExpiresAt: z.string().nullable().default(null)
1326
+ promoExpiresAt: z2.string().nullable().default(null)
1215
1327
  });
1216
- var TopUpRequestSchema = z.object({
1217
- slug: z.string().min(1),
1328
+ var TopUpRequestSchema = z2.object({
1329
+ slug: z2.string().min(1),
1218
1330
  /** In the control plane's currency; negative corrects a mistake. */
1219
- amount: z.number().finite(),
1220
- note: z.string().max(200).optional()
1221
- });
1222
- var TopUpSchema = z.object({
1223
- id: z.string(),
1224
- slug: z.string(),
1225
- amount: z.number(),
1226
- currency: z.string(),
1331
+ amount: z2.number().finite(),
1332
+ note: z2.string().max(200).optional()
1333
+ });
1334
+ var TopUpSchema = z2.object({
1335
+ id: z2.string(),
1336
+ slug: z2.string(),
1337
+ amount: z2.number(),
1338
+ currency: z2.string(),
1227
1339
  /** `transfer` (#93): an owner moving credit to an org they own, a negative row on their slug and a positive one on the org's. */
1228
- source: z.enum(["admin", "card", "trial", "transfer"]),
1229
- note: z.string().nullable(),
1230
- at: z.string()
1340
+ source: z2.enum(["admin", "card", "trial", "transfer"]),
1341
+ note: z2.string().nullable(),
1342
+ at: z2.string()
1231
1343
  });
1232
- var CreateCodeRequestSchema = z.object({
1344
+ var CreateCodeRequestSchema = z2.object({
1233
1345
  /** In the control plane's currency, cents at most. */
1234
- amount: z.number().positive().multipleOf(0.01, "amount is in cents at most"),
1346
+ amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most"),
1235
1347
  /** A day (`2026-12-11`, through the end of it, UTC) or an ISO time. The credit is gone then, and so is the code. */
1236
- expiresAt: z.string().min(1),
1237
- note: z.string().max(200).optional()
1238
- });
1239
- var CreditCodeSchema = z.object({
1240
- code: z.string(),
1241
- amount: z.number(),
1242
- currency: z.string(),
1243
- expiresAt: z.string(),
1244
- note: z.string().nullable(),
1245
- status: z.enum(["unused", "redeemed", "expired", "revoked"]),
1246
- createdBy: z.string(),
1247
- createdAt: z.string(),
1348
+ expiresAt: z2.string().min(1),
1349
+ note: z2.string().max(200).optional()
1350
+ });
1351
+ var CreditCodeSchema = z2.object({
1352
+ code: z2.string(),
1353
+ amount: z2.number(),
1354
+ currency: z2.string(),
1355
+ expiresAt: z2.string(),
1356
+ note: z2.string().nullable(),
1357
+ status: z2.enum(["unused", "redeemed", "expired", "revoked"]),
1358
+ createdBy: z2.string(),
1359
+ createdAt: z2.string(),
1248
1360
  /** Who redeemed it and the slug the credit went to (their own, or an org they own). */
1249
- redeemedBy: z.string().nullable(),
1250
- redeemedSlug: z.string().nullable(),
1251
- redeemedAt: z.string().nullable(),
1252
- revokedAt: z.string().nullable()
1253
- });
1254
- var RedeemRequestSchema = z.object({
1255
- code: z.string().min(1).max(64),
1256
- org: z.string().min(1).optional()
1257
- });
1258
- var RedeemResponseSchema = z.object({
1259
- slug: z.string(),
1260
- amount: z.number(),
1261
- currency: z.string(),
1262
- expiresAt: z.string(),
1361
+ redeemedBy: z2.string().nullable(),
1362
+ redeemedSlug: z2.string().nullable(),
1363
+ redeemedAt: z2.string().nullable(),
1364
+ revokedAt: z2.string().nullable()
1365
+ });
1366
+ var RedeemRequestSchema = z2.object({
1367
+ code: z2.string().min(1).max(64),
1368
+ org: z2.string().min(1).optional()
1369
+ });
1370
+ var RedeemResponseSchema = z2.object({
1371
+ slug: z2.string(),
1372
+ amount: z2.number(),
1373
+ currency: z2.string(),
1374
+ expiresAt: z2.string(),
1263
1375
  balance: BalanceSchema,
1264
1376
  /** The slug was out of credit and this put it back above zero: it may start boxes again. */
1265
- reinstated: z.boolean()
1377
+ reinstated: z2.boolean()
1266
1378
  });
1267
1379
  var TOP_UP_AMOUNTS = [10, 25, 50, 100];
1268
- var BillingInfoSchema = z.object({
1269
- card: z.object({ brand: z.string(), last4: z.string() }).nullable(),
1270
- cardInUse: z.boolean(),
1380
+ var BillingInfoSchema = z2.object({
1381
+ card: z2.object({ brand: z2.string(), last4: z2.string() }).nullable(),
1382
+ cardInUse: z2.boolean(),
1271
1383
  balance: BalanceSchema
1272
1384
  });
1273
- var BillingRedirectSchema = z.object({ url: z.string() });
1274
- var TopUpCheckoutRequestSchema = z.object({
1275
- amount: z.literal(TOP_UP_AMOUNTS)
1385
+ var BillingRedirectSchema = z2.object({ url: z2.string() });
1386
+ var TopUpCheckoutRequestSchema = z2.object({
1387
+ amount: z2.literal(TOP_UP_AMOUNTS)
1276
1388
  });
1277
- var TransferRequestSchema = z.object({
1278
- org: z.string().min(1),
1279
- amount: z.number().positive().multipleOf(0.01, "amount is in cents at most")
1389
+ var TransferRequestSchema = z2.object({
1390
+ org: z2.string().min(1),
1391
+ amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most")
1280
1392
  });
1281
- var TransferResponseSchema = z.object({ from: BalanceSchema, to: BalanceSchema, activated: z.boolean() });
1282
- var LoginRequestSchema = z.object({
1283
- email: z.string().min(1),
1284
- password: z.string().min(1),
1285
- publicKey: z.string().optional()
1393
+ var TransferResponseSchema = z2.object({ from: BalanceSchema, to: BalanceSchema, activated: z2.boolean() });
1394
+ var LoginRequestSchema = z2.object({
1395
+ email: z2.string().min(1),
1396
+ password: z2.string().min(1),
1397
+ publicKey: z2.string().optional()
1286
1398
  });
1287
- var SignupRequestSchema = z.object({
1288
- username: z.string().min(1),
1289
- name: z.string().min(1),
1290
- email: z.string().min(1),
1291
- password: z.string().min(1)
1399
+ var SignupRequestSchema = z2.object({
1400
+ username: z2.string().min(1),
1401
+ name: z2.string().min(1),
1402
+ email: z2.string().min(1),
1403
+ password: z2.string().min(1)
1292
1404
  });
1293
- var LoginResponseSchema = z.object({
1294
- token: z.string(),
1405
+ var LoginResponseSchema = z2.object({
1406
+ token: z2.string(),
1295
1407
  user: CloudUserSchema,
1296
- sshCert: z.string().optional(),
1297
- sshCertExpires: z.string().optional(),
1408
+ sshCert: z2.string().optional(),
1409
+ sshCertExpires: z2.string().optional(),
1298
1410
  /** Whose boxes the certificate opens: `<slug>@<realm>` for the user and each org they are in (orgs phase 4). */
1299
- sshCertPrincipals: z.array(z.string()).optional()
1411
+ sshCertPrincipals: z2.array(z2.string()).optional()
1300
1412
  });
1301
1413
  var DEVICE_LOGIN_PICKUP_SEC = 60;
1302
- var DeviceLoginRequestSchema = z.object({
1414
+ var DeviceLoginRequestSchema = z2.object({
1303
1415
  // Capped: anyone may open a login, and the key is stored until it expires (an RSA-16384 key is ~2.8 KB).
1304
- publicKey: z.string().max(16384).optional(),
1305
- hostname: z.string().max(255).optional()
1306
- });
1307
- var DeviceLoginStartSchema = z.object({
1308
- deviceCode: z.string(),
1309
- userCode: z.string(),
1310
- verifyUrl: z.string(),
1311
- expiresIn: z.number(),
1312
- interval: z.number()
1313
- });
1314
- var DeviceLoginPollRequestSchema = z.object({ deviceCode: z.string().min(1) });
1315
- var DeviceLoginPollSchema = z.union([
1316
- z.object({ status: z.enum(["pending", "slow_down", "refused", "expired"]) }),
1317
- LoginResponseSchema.extend({ status: z.literal("approved") })
1416
+ publicKey: z2.string().max(16384).optional(),
1417
+ hostname: z2.string().max(255).optional()
1418
+ });
1419
+ var DeviceLoginStartSchema = z2.object({
1420
+ deviceCode: z2.string(),
1421
+ userCode: z2.string(),
1422
+ verifyUrl: z2.string(),
1423
+ expiresIn: z2.number(),
1424
+ interval: z2.number()
1425
+ });
1426
+ var DeviceLoginPollRequestSchema = z2.object({ deviceCode: z2.string().min(1) });
1427
+ var DeviceLoginPollSchema = z2.union([
1428
+ z2.object({ status: z2.enum(["pending", "slow_down", "refused", "expired"]) }),
1429
+ LoginResponseSchema.extend({ status: z2.literal("approved") })
1318
1430
  ]);
1319
- var DeviceLoginInfoSchema = z.object({
1320
- userCode: z.string(),
1321
- hostname: z.string(),
1431
+ var DeviceLoginInfoSchema = z2.object({
1432
+ userCode: z2.string(),
1433
+ hostname: z2.string(),
1322
1434
  /** The address the request came from; null when the control plane could not tell. */
1323
- ip: z.string().nullable(),
1324
- createdAt: z.string(),
1325
- expiresAt: z.string()
1435
+ ip: z2.string().nullable(),
1436
+ createdAt: z2.string(),
1437
+ expiresAt: z2.string()
1326
1438
  });
1327
1439
  var DEFAULT_API_KEY_DAYS = 90;
1328
1440
  var API_KEY_NAME_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
1329
- var ApiKeySchema = z.object({
1330
- name: z.string(),
1331
- createdAt: z.string(),
1441
+ var ApiKeySchema = z2.object({
1442
+ name: z2.string(),
1443
+ createdAt: z2.string(),
1332
1444
  /** Last request made with it (ISO); null: never used. */
1333
- lastUsedAt: z.string().nullable(),
1445
+ lastUsedAt: z2.string().nullable(),
1334
1446
  /** When it stops working (ISO); null: never. */
1335
- expiresAt: z.string().nullable()
1447
+ expiresAt: z2.string().nullable()
1336
1448
  });
1337
- var CreateApiKeyRequestSchema = z.object({
1338
- name: z.string().regex(API_KEY_NAME_RE, "a key's name is lowercase letters, digits, '.', '_' or '-' (up to 32 characters)"),
1339
- expiresAt: z.iso.datetime({ offset: true }).nullable().optional()
1449
+ var CreateApiKeyRequestSchema = z2.object({
1450
+ name: z2.string().regex(API_KEY_NAME_RE, "a key's name is lowercase letters, digits, '.', '_' or '-' (up to 32 characters)"),
1451
+ expiresAt: z2.iso.datetime({ offset: true }).nullable().optional()
1340
1452
  });
1341
- var CreatedApiKeySchema = ApiKeySchema.extend({ key: z.string() });
1342
- var SshCertRequestSchema = z.object({
1343
- publicKey: z.string().min(1)
1453
+ var CreatedApiKeySchema = ApiKeySchema.extend({ key: z2.string() });
1454
+ var SshCertRequestSchema = z2.object({
1455
+ publicKey: z2.string().min(1)
1344
1456
  });
1345
- var SshCertResponseSchema = z.object({
1346
- cert: z.string(),
1347
- expires: z.string(),
1348
- principals: z.array(z.string())
1457
+ var SshCertResponseSchema = z2.object({
1458
+ cert: z2.string(),
1459
+ expires: z2.string(),
1460
+ principals: z2.array(z2.string())
1349
1461
  });
1350
- var SshCaResponseSchema = z.object({
1351
- publicKey: z.string(),
1462
+ var SshCaResponseSchema = z2.object({
1463
+ publicKey: z2.string(),
1352
1464
  /** CAs replaced by `ca rotate` (#55), newest first; a box still holding one of these has not had `kvbox-server trust-ca` run on its host. */
1353
- retired: z.array(z.object({ publicKey: z.string(), retiredAt: z.string() })).optional()
1465
+ retired: z2.array(z2.object({ publicKey: z2.string(), retiredAt: z2.string() })).optional()
1354
1466
  });
1355
- var HostSshCaResponseSchema = z.object({
1356
- publicKey: z.string()
1467
+ var HostSshCaResponseSchema = z2.object({
1468
+ publicKey: z2.string()
1357
1469
  });
1358
- var CloudCaSchema = z.object({
1359
- controlPlane: z.string(),
1360
- publicKey: z.string(),
1361
- fingerprint: z.string()
1470
+ var CloudCaSchema = z2.object({
1471
+ controlPlane: z2.string(),
1472
+ publicKey: z2.string(),
1473
+ fingerprint: z2.string()
1362
1474
  });
1363
- var TrustCaRequestSchema = z.object({
1364
- publicKey: z.string().min(1)
1475
+ var TrustCaRequestSchema = z2.object({
1476
+ publicKey: z2.string().min(1)
1365
1477
  });
1366
- var SshKeysAppliedSchema = z.enum(["now", "start", "wake", "resume", "later"]);
1367
- var TrustCaReportSchema = z.object({
1368
- publicKey: z.string(),
1369
- fingerprint: z.string(),
1478
+ var SshKeysAppliedSchema = z2.enum(["now", "start", "wake", "resume", "later"]);
1479
+ var TrustCaReportSchema = z2.object({
1480
+ publicKey: z2.string(),
1481
+ fingerprint: z2.string(),
1370
1482
  /** The guest trusts the CA now. */
1371
- updated: z.array(z.string()),
1483
+ updated: z2.array(z2.string()),
1372
1484
  /** meta.json has the line; the guest gets it at `when`. */
1373
- pending: z.array(z.object({ box: z.string(), when: SshKeysAppliedSchema, why: z.string().optional() })),
1374
- failed: z.array(z.object({ box: z.string(), error: z.string() })),
1485
+ pending: z2.array(z2.object({ box: z2.string(), when: SshKeysAppliedSchema, why: z2.string().optional() })),
1486
+ failed: z2.array(z2.object({ box: z2.string(), error: z2.string() })),
1375
1487
  /** Local boxes, untouched: they trust the host's key only. */
1376
- local: z.number().int(),
1488
+ local: z2.number().int(),
1377
1489
  /** Cloud boxes made without a CA line (a managed service's, #173), untouched: no certificate opens them. Absent from older servers. */
1378
- skipped: z.array(z.string()).optional()
1379
- });
1380
- var HostJoinRequestSchema = z.object({
1381
- token: z.string().min(1),
1382
- name: z.string().min(1),
1383
- url: z.string().url(),
1384
- fingerprint: z.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
1385
- publicAddress: z.string().min(1),
1490
+ skipped: z2.array(z2.string()).optional()
1491
+ });
1492
+ var HostJoinRequestSchema = z2.object({
1493
+ token: z2.string().min(1),
1494
+ name: z2.string().min(1),
1495
+ url: z2.string().url(),
1496
+ fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
1497
+ publicAddress: z2.string().min(1),
1386
1498
  /** Where the host is (`kvbox-server join --country`): a code or an English name. */
1387
- country: z.string().optional()
1388
- });
1389
- var HostJoinResponseSchema = z.object({
1390
- hostSecret: z.string(),
1391
- controlPlane: z.object({ name: z.string() })
1392
- });
1393
- var CloudHostSchema = z.object({
1394
- name: z.string(),
1395
- url: z.string(),
1396
- publicAddress: z.string(),
1397
- joinedAt: z.string(),
1398
- lastSeenAt: z.string().nullable(),
1499
+ country: z2.string().optional()
1500
+ });
1501
+ var HostJoinResponseSchema = z2.object({
1502
+ hostSecret: z2.string(),
1503
+ controlPlane: z2.object({ name: z2.string() })
1504
+ });
1505
+ var CloudHostSchema = z2.object({
1506
+ name: z2.string(),
1507
+ url: z2.string(),
1508
+ publicAddress: z2.string(),
1509
+ joinedAt: z2.string(),
1510
+ lastSeenAt: z2.string().nullable(),
1399
1511
  capacity: CapacitySchema.nullable(),
1400
1512
  /** ISO 3166-1 alpha-2 code (`RO`), null when nobody said where the host is. */
1401
- country: z.string().nullable(),
1513
+ country: z2.string().nullable(),
1402
1514
  /** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
1403
- region: z.string().nullable(),
1515
+ region: z2.string().nullable(),
1404
1516
  /** kvbox-server's version as of the poller's last look (`capacity.version`); null before one, or for a server older than 0.5.45. */
1405
- version: z.string().nullable()
1517
+ version: z2.string().nullable()
1406
1518
  });
1407
- var HostInfoSchema = z.object({
1519
+ var HostInfoSchema = z2.object({
1408
1520
  host: CloudHostSchema,
1409
1521
  health: HealthSchema.nullable(),
1410
- error: z.string().nullable()
1522
+ error: z2.string().nullable()
1411
1523
  });
1412
- var HostPatchRequest = z.object({ country: z.string().nullable().optional(), region: z.string().nullable().optional() }).refine((b) => b.country !== void 0 || b.region !== void 0, { message: "give country, region or both" });
1413
- var CountrySchema = z.object({ code: z.string(), name: z.string() });
1524
+ var HostPatchRequest = z2.object({ country: z2.string().nullable().optional(), region: z2.string().nullable().optional() }).refine((b) => b.country !== void 0 || b.region !== void 0, { message: "give country, region or both" });
1525
+ var CountrySchema = z2.object({ code: z2.string(), name: z2.string() });
1414
1526
 
1415
1527
  // src/session.ts
1416
- var SessionSchema = z2.object({
1417
- url: z2.string(),
1418
- token: z2.string(),
1419
- user: z2.string(),
1528
+ var SessionSchema = z3.object({
1529
+ url: z3.string(),
1530
+ token: z3.string(),
1531
+ user: z3.string(),
1420
1532
  /** When the SSH certificate at paths().sshCert stops being accepted (ISO); absent before the first login with a key. */
1421
- sshCertExpires: z2.string().optional(),
1533
+ sshCertExpires: z3.string().optional(),
1422
1534
  /** Whose boxes that certificate opens (`<slug>@<realm>`, the user and their orgs); absent with `sshCertExpires`. */
1423
- sshCertPrincipals: z2.array(z2.string()).optional()
1535
+ sshCertPrincipals: z3.array(z3.string()).optional()
1424
1536
  });
1425
1537
  async function readSession(p = paths()) {
1426
1538
  let text2;
@@ -1599,7 +1711,7 @@ import { setTimeout as sleep2 } from "timers/promises";
1599
1711
  import { Agent, request } from "undici";
1600
1712
 
1601
1713
  // ../sdk/src/machines.ts
1602
- import { z as z3 } from "zod";
1714
+ import { z as z4 } from "zod";
1603
1715
 
1604
1716
  // ../sdk/src/errors.ts
1605
1717
  var KvboxSdkError = class extends Error {
@@ -1696,6 +1808,7 @@ var FORK_TIMEOUT_MS = 66e4;
1696
1808
  var listQuery = (opts) => opts.all ? "?all=1" : "";
1697
1809
  var box = (name, rest = "") => `/machines/${encodeURIComponent(name)}${rest}`;
1698
1810
  var sleep = (ms) => new Promise((resolve4) => setTimeout(resolve4, ms));
1811
+ var FROM_BACKUP_TIMEOUT_MS = 2 * 36e5;
1699
1812
  var passing = (err) => err instanceof KvboxConnectionError || err instanceof KvboxTimeoutError || err instanceof KvboxApiError && [502, 503, 504].includes(err.status);
1700
1813
  var Machines = class {
1701
1814
  constructor(transport) {
@@ -1710,7 +1823,7 @@ var Machines = class {
1710
1823
  ports;
1711
1824
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1712
1825
  list(opts = {}) {
1713
- return this.transport.request("GET", `/machines${listQuery(opts)}`, z3.array(MachineSchema), { org: opts.org });
1826
+ return this.transport.request("GET", `/machines${listQuery(opts)}`, z4.array(MachineSchema), { org: opts.org });
1714
1827
  }
1715
1828
  /**
1716
1829
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1724,7 +1837,7 @@ var Machines = class {
1724
1837
  async find(name, orgOpt, timeoutMs) {
1725
1838
  const slash = name.indexOf("/");
1726
1839
  const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
1727
- const listing = await this.transport.request("GET", "/machines", z3.array(MachineSchema), { org, timeoutMs });
1840
+ const listing = await this.transport.request("GET", "/machines", z4.array(MachineSchema), { org, timeoutMs });
1728
1841
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1729
1842
  if (named.length <= 1) {
1730
1843
  if (named[0] !== void 0) return named[0];
@@ -1739,13 +1852,26 @@ var Machines = class {
1739
1852
  * system inside is still booting for a few seconds after (see `waitUntilReady`). A box from an
1740
1853
  * image that serves something answers `connect` (its URL with the password) this once.
1741
1854
  * `org` (this call's, else the client's): the new box goes to that org, else to the caller's own slug.
1855
+ * `fromBackup` (a backup's id, a removed box's too) starts it on that backup's disk, image and variables;
1856
+ * the answer then waits for the download, up to two hours.
1742
1857
  */
1743
- create(req = {}, opts = {}) {
1744
- return this.transport.request("POST", "/machines", MachineSchema, { body: req, org: opts.org });
1858
+ async create(req = {}, opts = {}) {
1859
+ const made = await this.transport.request("POST", "/machines", MachineSchema, { body: req, org: opts.org, ...req.fromBackup !== void 0 ? { timeoutMs: FROM_BACKUP_TIMEOUT_MS } : {} });
1860
+ if (req.fromBackup !== void 0 && !made.source.startsWith("backup:")) {
1861
+ throw new KvboxSdkError(`this API does not know fromBackup yet: box ${slugOf2(made.owner)}/${made.name} was made empty, not from backup ${req.fromBackup}; remove it`);
1862
+ }
1863
+ return made;
1864
+ }
1865
+ /**
1866
+ * Change a box's settings; anything left out stays as it is. `integrations` is the whole list of
1867
+ * integrations turned on for the box (`["github"]`, `[]` for none): it applies at once, with no restart.
1868
+ */
1869
+ set(name, settings, opts = {}) {
1870
+ return this.transport.request("POST", box(name, "/set"), MachineSchema, { body: settings, org: opts.org });
1745
1871
  }
1746
1872
  /** Remove the box and its disk. */
1747
1873
  async remove(name, opts = {}) {
1748
- await this.transport.request("DELETE", box(name), z3.undefined(), { org: opts.org });
1874
+ await this.transport.request("DELETE", box(name), z4.undefined(), { org: opts.org });
1749
1875
  }
1750
1876
  /** Boot a stopped box. */
1751
1877
  start(name, opts = {}) {
@@ -1895,7 +2021,7 @@ var slugOf2 = (owner) => {
1895
2021
  };
1896
2022
 
1897
2023
  // ../sdk/src/snapshots.ts
1898
- import { z as z4 } from "zod";
2024
+ import { z as z5 } from "zod";
1899
2025
  var Snapshots = class {
1900
2026
  constructor(transport) {
1901
2027
  this.transport = transport;
@@ -1903,19 +2029,19 @@ var Snapshots = class {
1903
2029
  transport;
1904
2030
  /** Every snapshot the caller can read. */
1905
2031
  list(opts = {}) {
1906
- return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z4.array(SnapshotSchema), { org: opts.org });
2032
+ return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z5.array(SnapshotSchema), { org: opts.org });
1907
2033
  }
1908
2034
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
1909
2035
  create(req, opts = {}) {
1910
2036
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
1911
2037
  }
1912
2038
  async remove(name, opts = {}) {
1913
- await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z4.undefined(), { org: opts.org });
2039
+ await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z5.undefined(), { org: opts.org });
1914
2040
  }
1915
2041
  };
1916
2042
 
1917
2043
  // ../sdk/src/transport.ts
1918
- import { z as z5 } from "zod";
2044
+ import { z as z6 } from "zod";
1919
2045
  var Transport = class {
1920
2046
  baseUrl;
1921
2047
  org;
@@ -1989,7 +2115,7 @@ var Transport = class {
1989
2115
  }
1990
2116
  }
1991
2117
  };
1992
- var LooseApiErrorSchema = z5.object({ error: z5.string(), code: z5.string().optional() });
2118
+ var LooseApiErrorSchema = z6.object({ error: z6.string(), code: z6.string().optional() });
1993
2119
  function safeJson(text2) {
1994
2120
  try {
1995
2121
  return JSON.parse(text2);
@@ -2006,8 +2132,21 @@ function errorCode(err) {
2006
2132
  return void 0;
2007
2133
  }
2008
2134
 
2135
+ // ../sdk/src/integrations.ts
2136
+ import { z as z7 } from "zod";
2137
+ var Integrations = class {
2138
+ constructor(transport) {
2139
+ this.transport = transport;
2140
+ }
2141
+ transport;
2142
+ /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2143
+ list(opts = {}) {
2144
+ return this.transport.request("GET", "/integrations", z7.array(IntegrationSchema), { org: opts.org });
2145
+ }
2146
+ };
2147
+
2009
2148
  // ../sdk/src/volumes.ts
2010
- import { z as z6 } from "zod";
2149
+ import { z as z8 } from "zod";
2011
2150
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2012
2151
  var Volumes = class {
2013
2152
  constructor(transport) {
@@ -2015,7 +2154,7 @@ var Volumes = class {
2015
2154
  }
2016
2155
  transport;
2017
2156
  list(opts = {}) {
2018
- return this.transport.request("GET", `/volumes${listQuery(opts)}`, z6.array(VolumeSchema), { org: opts.org });
2157
+ return this.transport.request("GET", `/volumes${listQuery(opts)}`, z8.array(VolumeSchema), { org: opts.org });
2019
2158
  }
2020
2159
  /**
2021
2160
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2038,7 +2177,7 @@ var Volumes = class {
2038
2177
  }
2039
2178
  /** Remove the volume and its data; it must be detached first. */
2040
2179
  async remove(name, opts = {}) {
2041
- await this.transport.request("DELETE", volume(name), z6.undefined(), { org: opts.org });
2180
+ await this.transport.request("DELETE", volume(name), z8.undefined(), { org: opts.org });
2042
2181
  }
2043
2182
  };
2044
2183
 
@@ -2059,6 +2198,7 @@ var Kvbox = class {
2059
2198
  machines;
2060
2199
  snapshots;
2061
2200
  volumes;
2201
+ integrations;
2062
2202
  transport;
2063
2203
  constructor(opts = {}) {
2064
2204
  this.transport = new Transport({
@@ -2071,6 +2211,7 @@ var Kvbox = class {
2071
2211
  this.machines = new Machines(this.transport);
2072
2212
  this.snapshots = new Snapshots(this.transport);
2073
2213
  this.volumes = new Volumes(this.transport);
2214
+ this.integrations = new Integrations(this.transport);
2074
2215
  }
2075
2216
  /** The API this client talks to, without a trailing slash. */
2076
2217
  get baseUrl() {
@@ -2086,35 +2227,35 @@ var Kvbox = class {
2086
2227
  };
2087
2228
 
2088
2229
  // src/client.ts
2089
- import { z as z11 } from "zod";
2230
+ import { z as z13 } from "zod";
2090
2231
 
2091
2232
  // ../shared/src/usage.ts
2092
- import { z as z7 } from "zod";
2093
- var PricingSchema = z7.object({
2094
- currency: z7.string().min(1),
2095
- vcpuHour: z7.number().nonnegative(),
2096
- ramGibHour: z7.number().nonnegative(),
2097
- diskGibHour: z7.number().nonnegative(),
2098
- volumeHour: z7.number().nonnegative().default(0),
2099
- volumeGibHour: z7.number().nonnegative().default(0),
2100
- diskIncludedGib: z7.number().int().nonnegative().default(0),
2233
+ import { z as z9 } from "zod";
2234
+ var PricingSchema = z9.object({
2235
+ currency: z9.string().min(1),
2236
+ vcpuHour: z9.number().nonnegative(),
2237
+ ramGibHour: z9.number().nonnegative(),
2238
+ diskGibHour: z9.number().nonnegative(),
2239
+ volumeHour: z9.number().nonnegative().default(0),
2240
+ volumeGibHour: z9.number().nonnegative().default(0),
2241
+ diskIncludedGib: z9.number().int().nonnegative().default(0),
2101
2242
  /**
2102
2243
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2103
2244
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2104
2245
  * A price list from before object storage charges nothing for it.
2105
2246
  */
2106
- storageHour: z7.number().nonnegative().default(0),
2107
- storageGibHour: z7.number().nonnegative().default(0),
2108
- storageIncludedGib: z7.number().int().nonnegative().default(0),
2247
+ storageHour: z9.number().nonnegative().default(0),
2248
+ storageGibHour: z9.number().nonnegative().default(0),
2249
+ storageIncludedGib: z9.number().int().nonnegative().default(0),
2109
2250
  /** The cron service (#190): an hour of one cron service existing, whatever it holds or fires. A price list from before it charges nothing. */
2110
- cronHour: z7.number().nonnegative().default(0),
2251
+ cronHour: z9.number().nonnegative().default(0),
2111
2252
  /**
2112
2253
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2113
2254
  * costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
2114
2255
  */
2115
- backup: z7.number().nonnegative().default(0)
2256
+ backup: z9.number().nonnegative().default(0)
2116
2257
  });
2117
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z7.number().nonnegative() });
2258
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z9.number().nonnegative() });
2118
2259
  var HOUR_MS = 36e5;
2119
2260
  var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
2120
2261
  function costOf(t, pricing) {
@@ -2142,86 +2283,86 @@ function sumUsage(items, pricing) {
2142
2283
  var DAY_MS = 24 * HOUR_MS;
2143
2284
 
2144
2285
  // ../shared/src/managed.ts
2145
- import { z as z8 } from "zod";
2146
- var PriceSchema = z8.object({ perMonth: z8.number(), storagePerMonth: z8.number(), currency: z8.string() });
2147
- var ManagedCatalogEntrySchema = z8.object({
2286
+ import { z as z10 } from "zod";
2287
+ var PriceSchema = z10.object({ perMonth: z10.number(), storagePerMonth: z10.number(), currency: z10.string() });
2288
+ var ManagedCatalogEntrySchema = z10.object({
2148
2289
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2149
- kind: z8.string(),
2290
+ kind: z10.string(),
2150
2291
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2151
- command: z8.string(),
2152
- title: z8.string(),
2153
- description: z8.string(),
2292
+ command: z10.string(),
2293
+ title: z10.string(),
2294
+ description: z10.string(),
2154
2295
  /** The version a new one runs, as shown: `18`. */
2155
- version: z8.string(),
2296
+ version: z10.string(),
2156
2297
  /** The port a linked box reaches it on. */
2157
- port: z8.number().int(),
2298
+ port: z10.number().int(),
2158
2299
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2159
- publicPort: z8.number().int(),
2300
+ publicPort: z10.number().int(),
2160
2301
  /** Its guide, as a URL. */
2161
- docs: z8.string().optional(),
2162
- storage: z8.object({ defaultGib: z8.number().int(), minGib: z8.number().int(), maxGib: z8.number().int() }),
2302
+ docs: z10.string().optional(),
2303
+ storage: z10.object({ defaultGib: z10.number().int(), minGib: z10.number().int(), maxGib: z10.number().int() }),
2163
2304
  /**
2164
2305
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2165
2306
  * flag and a form field each, all optional, `default` in words.
2166
2307
  */
2167
- options: z8.array(z8.object({ name: z8.string(), title: z8.string(), description: z8.string(), default: z8.string() })),
2308
+ options: z10.array(z10.object({ name: z10.string(), title: z10.string(), description: z10.string(), default: z10.string() })),
2168
2309
  /** A month of it running with the default storage, and each further GB of storage. */
2169
- price: PriceSchema.extend({ storageGibPerMonth: z8.number() }),
2310
+ price: PriceSchema.extend({ storageGibPerMonth: z10.number() }),
2170
2311
  /** Whether a host answering now can run it. */
2171
- available: z8.boolean()
2312
+ available: z10.boolean()
2172
2313
  });
2173
- var CreateManagedRequest = z8.object({
2174
- name: z8.string(),
2314
+ var CreateManagedRequest = z10.object({
2315
+ name: z10.string(),
2175
2316
  /** The kind's own options by name (its catalog entry lists them); the kind checks them. */
2176
- options: z8.record(z8.string(), z8.string()).optional(),
2177
- password: z8.string().optional(),
2178
- storageGib: z8.number().int().optional(),
2317
+ options: z10.record(z10.string(), z10.string()).optional(),
2318
+ password: z10.string().optional(),
2319
+ storageGib: z10.number().int().optional(),
2179
2320
  /** Place it on the host of this box, so the box can be linked to it. */
2180
- near: z8.string().optional(),
2321
+ near: z10.string().optional(),
2181
2322
  /**
2182
2323
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2183
2324
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2184
2325
  * are the backup's; the password is the new one.
2185
2326
  */
2186
- fromBackup: z8.string().optional()
2327
+ fromBackup: z10.string().optional()
2187
2328
  });
2188
- var ManagedHealthSchema = z8.object({
2329
+ var ManagedHealthSchema = z10.object({
2189
2330
  /** Its first start has finished: it has set itself up on its storage. */
2190
- ready: z8.boolean(),
2331
+ ready: z10.boolean(),
2191
2332
  /** It accepts connections. */
2192
- accepting: z8.boolean(),
2193
- version: z8.string(),
2333
+ accepting: z10.boolean(),
2334
+ version: z10.string(),
2194
2335
  /** The storage volume: what is used of it and its size. */
2195
- storageUsedBytes: z8.number().optional(),
2196
- storageTotalBytes: z8.number().optional(),
2336
+ storageUsedBytes: z10.number().optional(),
2337
+ storageTotalBytes: z10.number().optional(),
2197
2338
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2198
- facts: z8.array(z8.object({ title: z8.string(), value: z8.string() }))
2339
+ facts: z10.array(z10.object({ title: z10.string(), value: z10.string() }))
2199
2340
  });
2200
- var UrlsSchema = z8.object({ private: z8.string(), public: z8.string().optional() });
2201
- var ManagedSchema = z8.object({
2202
- kind: z8.string(),
2203
- name: z8.string(),
2341
+ var UrlsSchema = z10.object({ private: z10.string(), public: z10.string().optional() });
2342
+ var ManagedSchema = z10.object({
2343
+ kind: z10.string(),
2344
+ name: z10.string(),
2204
2345
  /** The owning slug, bare. */
2205
- owner: z8.string(),
2206
- ownerKind: z8.enum(["user", "org"]),
2346
+ owner: z10.string(),
2347
+ ownerKind: z10.enum(["user", "org"]),
2207
2348
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2208
2349
  status: BoxStatusSchema,
2209
2350
  /** The catalog version: `18`. */
2210
- version: z8.string(),
2351
+ version: z10.string(),
2211
2352
  /** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
2212
- settings: z8.record(z8.string(), z8.string()),
2213
- storageGib: z8.number().int(),
2353
+ settings: z10.record(z10.string(), z10.string()),
2354
+ storageGib: z10.number().int(),
2214
2355
  /** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
2215
- private: z8.object({ host: z8.string(), port: z8.number().int() }),
2356
+ private: z10.object({ host: z10.string(), port: z10.number().int() }),
2216
2357
  /** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
2217
- public: z8.object({ host: z8.string(), port: z8.number().int() }).nullable(),
2358
+ public: z10.object({ host: z10.string(), port: z10.number().int() }).nullable(),
2218
2359
  /** The boxes linked to it, as the caller would name them. */
2219
- links: z8.array(z8.string()),
2360
+ links: z10.array(z10.string()),
2220
2361
  /** The name of the host it runs on, for `--near` and links. */
2221
- host: z8.string(),
2222
- country: z8.string().optional(),
2223
- createdBy: z8.string().nullable(),
2224
- createdAt: z8.string(),
2362
+ host: z10.string(),
2363
+ country: z10.string().optional(),
2364
+ createdBy: z10.string().nullable(),
2365
+ createdAt: z10.string(),
2225
2366
  /** Connection strings with the password as `****`. */
2226
2367
  urls: UrlsSchema,
2227
2368
  price: PriceSchema,
@@ -2230,226 +2371,230 @@ var ManagedSchema = z8.object({
2230
2371
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2231
2372
  health: ManagedHealthSchema.nullable().optional()
2232
2373
  });
2233
- var ManagedSecretSchema = z8.object({ password: z8.string(), urls: UrlsSchema });
2374
+ var ManagedSecretSchema = z10.object({ password: z10.string(), urls: UrlsSchema });
2234
2375
  var CreatedManagedSchema = ManagedSchema.extend({
2235
2376
  secret: ManagedSecretSchema,
2236
2377
  /** The backup it was made from (`fromBackup`), when it was. */
2237
- fromBackup: z8.string().optional()
2238
- });
2239
- var ResetPasswordRequest = z8.object({ password: z8.string().optional() });
2240
- var SetPublicRequest = z8.object({ on: z8.boolean() });
2241
- var ManagedLinkRequest = z8.object({ box: z8.string() });
2242
- var GrowManagedRequest = z8.object({ storageGib: z8.number().int() });
2243
- var ManagedBackupSchema = z8.object({
2244
- id: z8.string(),
2245
- owner: z8.string(),
2246
- kind: z8.string(),
2247
- name: z8.string(),
2248
- version: z8.string(),
2249
- status: z8.enum(BACKUP_STATUSES),
2378
+ fromBackup: z10.string().optional()
2379
+ });
2380
+ var ResetPasswordRequest = z10.object({ password: z10.string().optional() });
2381
+ var SetPublicRequest = z10.object({ on: z10.boolean() });
2382
+ var ManagedLinkRequest = z10.object({ box: z10.string() });
2383
+ var GrowManagedRequest = z10.object({ storageGib: z10.number().int() });
2384
+ var ManagedBackupSchema = z10.object({
2385
+ id: z10.string(),
2386
+ owner: z10.string(),
2387
+ kind: z10.string(),
2388
+ name: z10.string(),
2389
+ version: z10.string(),
2390
+ status: z10.enum(BACKUP_STATUSES),
2250
2391
  /** Why it failed; null otherwise. */
2251
- error: z8.string().nullable(),
2392
+ error: z10.string().nullable(),
2252
2393
  /** The service's storage when taken. */
2253
- diskBytes: z8.number().int().nullable(),
2394
+ diskBytes: z10.number().int().nullable(),
2254
2395
  /** What it holds: the slots that are not all zeros. */
2255
- dataBytes: z8.number().int().nullable(),
2396
+ dataBytes: z10.number().int().nullable(),
2256
2397
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2257
- uploadedBytes: z8.number().int().nullable(),
2398
+ uploadedBytes: z10.number().int().nullable(),
2258
2399
  /** Who asked for it; for a scheduled one, the database's creator. */
2259
- createdBy: z8.string().nullable(),
2400
+ createdBy: z10.string().nullable(),
2260
2401
  /** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
2261
- scheduled: z8.boolean().default(false),
2262
- createdAt: z8.string(),
2263
- finishedAt: z8.string().nullable()
2402
+ scheduled: z10.boolean().default(false),
2403
+ createdAt: z10.string(),
2404
+ finishedAt: z10.string().nullable()
2264
2405
  });
2265
2406
 
2266
2407
  // ../shared/src/cron.ts
2267
- import { z as z9 } from "zod";
2408
+ import { z as z11 } from "zod";
2268
2409
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2269
2410
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2270
2411
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2271
2412
  var CRON_METHODS = ["GET", "POST"];
2272
2413
  var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
2273
- var CronServiceSchema = z9.object({
2274
- owner: z9.string(),
2275
- ownerKind: z9.enum(["user", "org"]),
2276
- name: z9.string(),
2414
+ var CronServiceSchema = z11.object({
2415
+ owner: z11.string(),
2416
+ ownerKind: z11.enum(["user", "org"]),
2417
+ name: z11.string(),
2277
2418
  /** Runs kept per trigger. */
2278
- keepRuns: z9.number().int(),
2279
- triggers: z9.number().int(),
2280
- createdBy: z9.string().nullable(),
2281
- createdAt: z9.string(),
2419
+ keepRuns: z11.number().int(),
2420
+ triggers: z11.number().int(),
2421
+ createdBy: z11.string().nullable(),
2422
+ createdAt: z11.string(),
2282
2423
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2283
- price: z9.object({ perMonth: z9.number(), currency: z9.string() }).optional()
2424
+ price: z11.object({ perMonth: z11.number(), currency: z11.string() }).optional()
2284
2425
  });
2285
2426
  var triggerCommon = {
2286
- id: z9.string(),
2287
- service: z9.string(),
2288
- owner: z9.string(),
2427
+ id: z11.string(),
2428
+ service: z11.string(),
2429
+ owner: z11.string(),
2289
2430
  /** The box it acts on; a trigger is removed with its box. */
2290
- box: z9.string(),
2431
+ box: z11.string(),
2291
2432
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2292
- expr: z9.string(),
2433
+ expr: z11.string(),
2293
2434
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2294
- timezone: z9.string(),
2435
+ timezone: z11.string(),
2295
2436
  /** False: paused, it fires again when resumed. */
2296
- enabled: z9.boolean(),
2437
+ enabled: z11.boolean(),
2297
2438
  /** When it fires next (ISO); null while paused. */
2298
- nextRunAt: z9.string().nullable(),
2299
- lastRunAt: z9.string().nullable(),
2300
- lastOutcome: z9.enum(CRON_OUTCOMES).nullable(),
2301
- createdBy: z9.string().nullable(),
2302
- createdAt: z9.string()
2439
+ nextRunAt: z11.string().nullable(),
2440
+ lastRunAt: z11.string().nullable(),
2441
+ lastOutcome: z11.enum(CRON_OUTCOMES).nullable(),
2442
+ createdBy: z11.string().nullable(),
2443
+ createdAt: z11.string()
2303
2444
  };
2304
- var CronHttpTriggerSchema = z9.object({
2445
+ var CronHttpTriggerSchema = z11.object({
2305
2446
  ...triggerCommon,
2306
- kind: z9.literal("http"),
2307
- method: z9.enum(CRON_METHODS),
2308
- port: z9.number().int(),
2447
+ kind: z11.literal("http"),
2448
+ method: z11.enum(CRON_METHODS),
2449
+ port: z11.number().int(),
2309
2450
  /** Path and query, starting with `/`. */
2310
- path: z9.string()
2451
+ path: z11.string()
2311
2452
  });
2312
- var CronCommandTriggerSchema = z9.object({
2453
+ var CronCommandTriggerSchema = z11.object({
2313
2454
  ...triggerCommon,
2314
- kind: z9.literal("command"),
2455
+ kind: z11.literal("command"),
2315
2456
  /** Run by a login shell as the box's user, in its home. */
2316
- command: z9.string(),
2457
+ command: z11.string(),
2317
2458
  /** The command is stopped after this long. */
2318
- timeoutSec: z9.number().int()
2459
+ timeoutSec: z11.number().int()
2319
2460
  });
2320
- var CronTriggerSchema = z9.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2321
- var CronRunSchema = z9.object({
2461
+ var CronTriggerSchema = z11.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2462
+ var CronRunSchema = z11.object({
2322
2463
  /** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
2323
- scheduledFor: z9.string(),
2324
- startedAt: z9.string(),
2464
+ scheduledFor: z11.string(),
2465
+ startedAt: z11.string(),
2325
2466
  /** Null while `running`, and for a run that was never sent. */
2326
- durationMs: z9.number().int().nullable(),
2467
+ durationMs: z11.number().int().nullable(),
2327
2468
  /** The box's HTTP status; null when it never answered, and for a command. */
2328
- status: z9.number().int().nullable(),
2469
+ status: z11.number().int().nullable(),
2329
2470
  /** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
2330
- exitCode: z9.number().int().nullable(),
2471
+ exitCode: z11.number().int().nullable(),
2331
2472
  /** The files in the box that hold what a command printed (a shell pattern, `cron-<n>.*`); null for a request and for a command that never started. */
2332
- output: z9.string().nullable(),
2333
- outcome: z9.enum(CRON_OUTCOMES),
2473
+ output: z11.string().nullable(),
2474
+ outcome: z11.enum(CRON_OUTCOMES),
2334
2475
  /** Why it did not end `ok`, in a line. */
2335
- error: z9.string().nullable(),
2476
+ error: z11.string().nullable(),
2336
2477
  /** The box was hibernated and this run woke it. */
2337
- woke: z9.boolean()
2478
+ woke: z11.boolean()
2338
2479
  });
2339
- var CronCatalogSchema = z9.object({
2340
- price: z9.object({ perMonth: z9.number(), currency: z9.string() }),
2341
- maxServices: z9.number().int(),
2342
- maxTriggers: z9.number().int(),
2343
- keepRuns: z9.number().int(),
2480
+ var CronCatalogSchema = z11.object({
2481
+ price: z11.object({ perMonth: z11.number(), currency: z11.string() }),
2482
+ maxServices: z11.number().int(),
2483
+ maxTriggers: z11.number().int(),
2484
+ keepRuns: z11.number().int(),
2344
2485
  /** The shortest time between two runs of one trigger, in seconds. */
2345
- minIntervalSeconds: z9.number().int(),
2486
+ minIntervalSeconds: z11.number().int(),
2346
2487
  /** How long a box has to answer, in seconds. */
2347
- timeoutSeconds: z9.number().int(),
2488
+ timeoutSeconds: z11.number().int(),
2348
2489
  /** How long a command may run: unless the trigger says, and at most. */
2349
- commandTimeoutSeconds: z9.number().int(),
2350
- maxCommandTimeoutSeconds: z9.number().int(),
2351
- docs: z9.string().optional()
2352
- });
2353
- var CreateCronServiceRequest = z9.object({ name: z9.string() });
2354
- var CreateCronTriggerRequest = z9.object({
2355
- box: z9.string().min(1),
2356
- expr: z9.string().min(1),
2357
- timezone: z9.string().optional(),
2490
+ commandTimeoutSeconds: z11.number().int(),
2491
+ maxCommandTimeoutSeconds: z11.number().int(),
2492
+ docs: z11.string().optional()
2493
+ });
2494
+ var CreateCronServiceRequest = z11.object({ name: z11.string() });
2495
+ var CreateCronTriggerRequest = z11.object({
2496
+ box: z11.string().min(1),
2497
+ expr: z11.string().min(1),
2498
+ timezone: z11.string().optional(),
2358
2499
  /** A request: `port`, with `method` and `path`. */
2359
- method: z9.enum(CRON_METHODS).optional(),
2360
- port: z9.number().int().min(1).max(65535).optional(),
2361
- path: z9.string().optional(),
2500
+ method: z11.enum(CRON_METHODS).optional(),
2501
+ port: z11.number().int().min(1).max(65535).optional(),
2502
+ path: z11.string().optional(),
2362
2503
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2363
- command: z9.string().optional(),
2364
- timeoutSec: z9.number().int().optional()
2504
+ command: z11.string().optional(),
2505
+ timeoutSec: z11.number().int().optional()
2365
2506
  });
2366
- var UpdateCronTriggerRequest = z9.object({ enabled: z9.boolean() });
2507
+ var UpdateCronTriggerRequest = z11.object({ enabled: z11.boolean() });
2367
2508
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2368
2509
 
2369
2510
  // ../shared/src/storage.ts
2370
- import { z as z10 } from "zod";
2371
- var RegionSchema = z10.object({ name: z10.string(), country: z10.string().nullable() });
2372
- var ObjectStorageSchema = z10.object({
2373
- owner: z10.string(),
2374
- ownerKind: z10.enum(["user", "org"]),
2511
+ import { z as z12 } from "zod";
2512
+ var RegionSchema = z12.object({ name: z12.string(), country: z12.string().nullable() });
2513
+ var MAX_PUBLIC_BUCKETS = 10;
2514
+ var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2515
+ var ObjectStorageSchema = z12.object({
2516
+ owner: z12.string(),
2517
+ ownerKind: z12.enum(["user", "org"]),
2375
2518
  /** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
2376
- endpoint: z10.string().nullable(),
2519
+ endpoint: z12.string().nullable(),
2377
2520
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2378
- region: z10.string(),
2521
+ region: z12.string(),
2379
2522
  /** The most it may hold. */
2380
- sizeGib: z10.number().int(),
2523
+ sizeGib: z12.number().int(),
2381
2524
  /** `running` when it answers; `unknown` while its host is not heard from. */
2382
2525
  status: BoxStatusSchema,
2383
2526
  /** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
2384
- usedBytes: z10.number().optional(),
2385
- totalBytes: z10.number().optional(),
2527
+ usedBytes: z12.number().optional(),
2528
+ totalBytes: z12.number().optional(),
2386
2529
  /** With `?live=1`, when the storage answered: what each bucket holds. */
2387
- bucketUsage: z10.array(z10.object({ name: z10.string(), objects: z10.number(), bytes: z10.number() })).optional(),
2388
- host: z10.string(),
2389
- country: z10.string().optional(),
2390
- buckets: z10.number().int(),
2391
- price: z10.object({ perMonth: z10.number(), currency: z10.string() }),
2392
- createdAt: z10.string()
2393
- });
2394
- var BucketSchema = z10.object({
2395
- name: z10.string(),
2396
- owner: z10.string(),
2397
- ownerKind: z10.enum(["user", "org"]),
2398
- endpoint: z10.string().nullable(),
2399
- region: z10.string(),
2400
- keys: z10.number().int(),
2401
- objects: z10.number().optional(),
2402
- bytes: z10.number().optional(),
2403
- createdBy: z10.string().nullable(),
2404
- createdAt: z10.string()
2405
- });
2406
- var CreateBucketRequest = z10.object({
2407
- name: z10.string(),
2408
- sizeGib: z10.number().int().optional(),
2409
- near: z10.string().optional(),
2410
- region: z10.string().optional()
2411
- });
2412
- var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z10.boolean() });
2530
+ bucketUsage: z12.array(z12.object({ name: z12.string(), objects: z12.number(), bytes: z12.number() })).optional(),
2531
+ host: z12.string(),
2532
+ country: z12.string().optional(),
2533
+ buckets: z12.number().int(),
2534
+ price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
2535
+ createdAt: z12.string()
2536
+ });
2537
+ var BucketSchema = z12.object({
2538
+ name: z12.string(),
2539
+ owner: z12.string(),
2540
+ ownerKind: z12.enum(["user", "org"]),
2541
+ endpoint: z12.string().nullable(),
2542
+ publicUrl: z12.string().optional(),
2543
+ region: z12.string(),
2544
+ keys: z12.number().int(),
2545
+ objects: z12.number().optional(),
2546
+ bytes: z12.number().optional(),
2547
+ createdBy: z12.string().nullable(),
2548
+ createdAt: z12.string()
2549
+ });
2550
+ var CreateBucketRequest = z12.object({
2551
+ name: z12.string(),
2552
+ sizeGib: z12.number().int().optional(),
2553
+ near: z12.string().optional(),
2554
+ region: z12.string().optional()
2555
+ });
2556
+ var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z12.boolean() });
2413
2557
  var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
2414
- var BucketKeySchema = z10.object({
2415
- id: z10.string(),
2416
- name: z10.string(),
2417
- bucket: z10.string(),
2418
- owner: z10.string(),
2419
- readOnly: z10.boolean(),
2420
- createdBy: z10.string().nullable(),
2421
- createdAt: z10.string()
2422
- });
2423
- var CreateBucketKeyRequest = z10.object({ name: z10.string().optional(), readOnly: z10.boolean().optional() });
2424
- var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z10.string(), endpoint: z10.string().nullable(), region: z10.string() });
2425
- var GrowStorageRequest = z10.object({ sizeGib: z10.number().int() });
2426
- var StorageBackupSchema = z10.object({
2427
- id: z10.string(),
2428
- owner: z10.string(),
2429
- status: z10.enum(BACKUP_STATUSES),
2558
+ var SetBucketPublicRequest = z12.object({ on: z12.boolean(), sub: z12.string().optional() });
2559
+ var BucketKeySchema = z12.object({
2560
+ id: z12.string(),
2561
+ name: z12.string(),
2562
+ bucket: z12.string(),
2563
+ owner: z12.string(),
2564
+ readOnly: z12.boolean(),
2565
+ createdBy: z12.string().nullable(),
2566
+ createdAt: z12.string()
2567
+ });
2568
+ var CreateBucketKeyRequest = z12.object({ name: z12.string().optional(), readOnly: z12.boolean().optional() });
2569
+ var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z12.string(), endpoint: z12.string().nullable(), region: z12.string() });
2570
+ var GrowStorageRequest = z12.object({ sizeGib: z12.number().int() });
2571
+ var StorageBackupSchema = z12.object({
2572
+ id: z12.string(),
2573
+ owner: z12.string(),
2574
+ status: z12.enum(BACKUP_STATUSES),
2430
2575
  /** Why it failed; null otherwise. */
2431
- error: z10.string().nullable(),
2576
+ error: z12.string().nullable(),
2432
2577
  /** The storage's volume when taken. */
2433
- diskBytes: z10.number().int().nullable(),
2578
+ diskBytes: z12.number().int().nullable(),
2434
2579
  /** What it holds: the slots that are not all zeros. */
2435
- dataBytes: z10.number().int().nullable(),
2580
+ dataBytes: z12.number().int().nullable(),
2436
2581
  /** What this backup added to the backup store (encrypted, compressed). */
2437
- uploadedBytes: z10.number().int().nullable(),
2582
+ uploadedBytes: z12.number().int().nullable(),
2438
2583
  /** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
2439
- buckets: z10.array(z10.string()),
2440
- keys: z10.number().int(),
2441
- createdBy: z10.string().nullable(),
2442
- createdAt: z10.string(),
2443
- finishedAt: z10.string().nullable()
2444
- });
2445
- var RestoredKeySchema = z10.object({ bucket: z10.string(), id: z10.string(), name: z10.string() });
2446
- var StorageRestoreSchema = z10.object({
2447
- backup: z10.string(),
2584
+ buckets: z12.array(z12.string()),
2585
+ keys: z12.number().int(),
2586
+ createdBy: z12.string().nullable(),
2587
+ createdAt: z12.string(),
2588
+ finishedAt: z12.string().nullable()
2589
+ });
2590
+ var RestoredKeySchema = z12.object({ bucket: z12.string(), id: z12.string(), name: z12.string() });
2591
+ var StorageRestoreSchema = z12.object({
2592
+ backup: z12.string(),
2448
2593
  storage: ObjectStorageSchema,
2449
- buckets: z10.object({ kept: z10.array(z10.string()), returned: z10.array(z10.string()), removed: z10.array(z10.string()) }),
2450
- keys: z10.object({ dropped: z10.array(RestoredKeySchema), revoked: z10.array(RestoredKeySchema) }),
2451
- checked: z10.boolean(),
2452
- warnings: z10.array(z10.string())
2594
+ buckets: z12.object({ kept: z12.array(z12.string()), returned: z12.array(z12.string()), removed: z12.array(z12.string()) }),
2595
+ keys: z12.object({ dropped: z12.array(RestoredKeySchema), revoked: z12.array(RestoredKeySchema) }),
2596
+ checked: z12.boolean(),
2597
+ warnings: z12.array(z12.string())
2453
2598
  });
2454
2599
  var OBJECT_LIST_MAX = 1e3;
2455
2600
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2459,56 +2604,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2459
2604
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2460
2605
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2461
2606
  var DELETE_PREFIXES_MAX = 100;
2462
- var StoredObjectSchema = z10.object({
2463
- key: z10.string(),
2464
- size: z10.number(),
2465
- etag: z10.string(),
2607
+ var StoredObjectSchema = z12.object({
2608
+ key: z12.string(),
2609
+ size: z12.number(),
2610
+ etag: z12.string(),
2466
2611
  /** ISO 8601. */
2467
- modified: z10.string()
2468
- });
2469
- var ObjectListingSchema = z10.object({
2470
- prefix: z10.string(),
2471
- folders: z10.array(z10.string()),
2472
- objects: z10.array(StoredObjectSchema),
2473
- next: z10.string().optional(),
2474
- canWrite: z10.boolean()
2475
- });
2476
- var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z10.string() });
2477
- var ObjectCountSchema = z10.object({ objects: z10.number(), bytes: z10.number(), more: z10.boolean() });
2478
- var ObjectLinkRequest = z10.object({
2479
- key: z10.string(),
2480
- expiresSec: z10.number().int().positive(),
2612
+ modified: z12.string()
2613
+ });
2614
+ var ObjectListingSchema = z12.object({
2615
+ prefix: z12.string(),
2616
+ folders: z12.array(z12.string()),
2617
+ objects: z12.array(StoredObjectSchema),
2618
+ next: z12.string().optional(),
2619
+ canWrite: z12.boolean()
2620
+ });
2621
+ var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z12.string() });
2622
+ var ObjectCountSchema = z12.object({ objects: z12.number(), bytes: z12.number(), more: z12.boolean() });
2623
+ var ObjectLinkRequest = z12.object({
2624
+ key: z12.string(),
2625
+ expiresSec: z12.number().int().positive(),
2481
2626
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2482
- download: z10.boolean().optional(),
2627
+ download: z12.boolean().optional(),
2483
2628
  /**
2484
2629
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2485
2630
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2486
2631
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2487
2632
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2488
2633
  */
2489
- cached: z10.boolean().optional()
2634
+ cached: z12.boolean().optional()
2490
2635
  });
2491
- var ObjectLinkSchema = z10.object({ url: z10.string(), expiresAt: z10.string() });
2636
+ var ObjectLinkSchema = z12.object({ url: z12.string(), expiresAt: z12.string() });
2492
2637
  var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
2493
- var StartUploadRequest = z10.object({ key: z10.string(), size: z10.number().int().nonnegative(), contentType: z10.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z10.boolean().optional() });
2494
- var UploadPlanSchema = z10.discriminatedUnion("kind", [
2495
- z10.object({ kind: z10.literal("single"), url: z10.string() }),
2496
- z10.object({ kind: z10.literal("multipart"), uploadId: z10.string(), partSize: z10.number(), urls: z10.array(z10.string()) })
2638
+ var StartUploadRequest = z12.object({ key: z12.string(), size: z12.number().int().nonnegative(), contentType: z12.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z12.boolean().optional() });
2639
+ var UploadPlanSchema = z12.discriminatedUnion("kind", [
2640
+ z12.object({ kind: z12.literal("single"), url: z12.string() }),
2641
+ z12.object({ kind: z12.literal("multipart"), uploadId: z12.string(), partSize: z12.number(), urls: z12.array(z12.string()) })
2497
2642
  ]);
2498
- var CompleteUploadRequest = z10.object({
2499
- key: z10.string(),
2500
- uploadId: z10.string(),
2501
- parts: z10.array(z10.object({ part: z10.number().int().positive(), etag: z10.string() })).min(1)
2643
+ var CompleteUploadRequest = z12.object({
2644
+ key: z12.string(),
2645
+ uploadId: z12.string(),
2646
+ parts: z12.array(z12.object({ part: z12.number().int().positive(), etag: z12.string() })).min(1)
2502
2647
  });
2503
- var AbortUploadRequest = z10.object({ key: z10.string(), uploadId: z10.string() });
2504
- var DeleteObjectsRequest = z10.object({ keys: z10.array(z10.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z10.array(z10.string()).max(DELETE_PREFIXES_MAX).optional() });
2505
- var DeletedObjectsSchema = z10.object({
2506
- deleted: z10.number(),
2507
- more: z10.boolean(),
2508
- errors: z10.array(z10.object({ key: z10.string(), message: z10.string() }))
2648
+ var AbortUploadRequest = z12.object({ key: z12.string(), uploadId: z12.string() });
2649
+ var DeleteObjectsRequest = z12.object({ keys: z12.array(z12.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z12.array(z12.string()).max(DELETE_PREFIXES_MAX).optional() });
2650
+ var DeletedObjectsSchema = z12.object({
2651
+ deleted: z12.number(),
2652
+ more: z12.boolean(),
2653
+ errors: z12.array(z12.object({ key: z12.string(), message: z12.string() }))
2509
2654
  });
2510
- var MoveObjectRequest = z10.object({ from: z10.string(), to: z10.string(), overwrite: z10.boolean().optional() });
2511
- var CreateFolderRequest = z10.object({ prefix: z10.string() });
2655
+ var MoveObjectRequest = z12.object({ from: z12.string(), to: z12.string(), overwrite: z12.boolean().optional() });
2656
+ var CreateFolderRequest = z12.object({ prefix: z12.string() });
2512
2657
 
2513
2658
  // src/kvm.ts
2514
2659
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2622,7 +2767,7 @@ var ServerClient = class {
2622
2767
  startedOnce = false;
2623
2768
  async call(method, path, schema, body, org = this.target.kind === "cloud" ? this.target.org : void 0, timeoutMs) {
2624
2769
  try {
2625
- return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org : void 0, timeoutMs });
2770
+ return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org ?? void 0 : void 0, timeoutMs });
2626
2771
  } catch (err) {
2627
2772
  return this.failed(err, () => this.call(method, path, schema, body, org, timeoutMs));
2628
2773
  }
@@ -2678,10 +2823,10 @@ var ServerClient = class {
2678
2823
  * `all`: every box on the platform (platform admins only, #78).
2679
2824
  */
2680
2825
  listMachines(opts = {}) {
2681
- return this.call("GET", `/machines${allQuery(opts)}`, z11.array(MachineSchema), void 0, opts.org);
2826
+ return this.call("GET", `/machines${allQuery(opts)}`, z13.array(MachineSchema), void 0, opts.org);
2682
2827
  }
2683
2828
  createMachine(req) {
2684
- return this.call("POST", "/machines", MachineSchema, req);
2829
+ return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
2685
2830
  }
2686
2831
  /** `kvbox vm fork` (#79): `name` is the source; the copy goes to the `--org` slug, else the caller's own. */
2687
2832
  forkMachine(name, req) {
@@ -2732,10 +2877,10 @@ var ServerClient = class {
2732
2877
  }
2733
2878
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
2734
2879
  listBackups() {
2735
- return this.call("GET", "/backups", z11.array(BackupSchema));
2880
+ return this.call("GET", "/backups", z13.array(BackupSchema));
2736
2881
  }
2737
2882
  boxBackups(name) {
2738
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z11.array(BackupSchema));
2883
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z13.array(BackupSchema));
2739
2884
  }
2740
2885
  boxBackup(name, id) {
2741
2886
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -2749,14 +2894,14 @@ var ServerClient = class {
2749
2894
  * later. Works for a backup whose box, volume or database is gone too.
2750
2895
  */
2751
2896
  removeBackup(id) {
2752
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z11.undefined());
2897
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z13.undefined());
2753
2898
  }
2754
2899
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
2755
2900
  listVolumeBackups() {
2756
- return this.call("GET", "/backups?kind=volume", z11.array(VolumeBackupSchema));
2901
+ return this.call("GET", "/backups?kind=volume", z13.array(VolumeBackupSchema));
2757
2902
  }
2758
2903
  volumeBackups(name) {
2759
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z11.array(VolumeBackupSchema));
2904
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z13.array(VolumeBackupSchema));
2760
2905
  }
2761
2906
  volumeBackup(name, id) {
2762
2907
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -2775,7 +2920,7 @@ var ServerClient = class {
2775
2920
  }
2776
2921
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
2777
2922
  boxHooks(name) {
2778
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z11.array(WakeHookSchema));
2923
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z13.array(WakeHookSchema));
2779
2924
  }
2780
2925
  createBoxHook(name) {
2781
2926
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -2803,7 +2948,7 @@ var ServerClient = class {
2803
2948
  }
2804
2949
  /** Every readable box's subdomains, one entry each. */
2805
2950
  listSubdomains() {
2806
- return this.call("GET", "/subdomains", z11.array(SubdomainSchema));
2951
+ return this.call("GET", "/subdomains", z13.array(SubdomainSchema));
2807
2952
  }
2808
2953
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
2809
2954
  addDomain(name, req) {
@@ -2814,7 +2959,7 @@ var ServerClient = class {
2814
2959
  }
2815
2960
  /** Every readable box's custom domains. */
2816
2961
  listDomains() {
2817
- return this.call("GET", "/domains", z11.array(DomainSchema));
2962
+ return this.call("GET", "/domains", z13.array(DomainSchema));
2818
2963
  }
2819
2964
  /** A running box's own load, memory and disk, asked of its guest (#67). */
2820
2965
  machineStats(name) {
@@ -2847,22 +2992,22 @@ var ServerClient = class {
2847
2992
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
2848
2993
  }
2849
2994
  deleteMachine(name) {
2850
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z11.undefined());
2995
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z13.undefined());
2851
2996
  }
2852
2997
  /** Like `listMachines`, for snapshots. */
2853
2998
  listSnapshots(opts = {}) {
2854
- return this.call("GET", `/snapshots${allQuery(opts)}`, z11.array(SnapshotSchema), void 0, opts.org);
2999
+ return this.call("GET", `/snapshots${allQuery(opts)}`, z13.array(SnapshotSchema), void 0, opts.org);
2855
3000
  }
2856
3001
  createSnapshot(req) {
2857
3002
  return this.call("POST", "/snapshots", SnapshotSchema, req);
2858
3003
  }
2859
3004
  deleteSnapshot(name) {
2860
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z11.undefined());
3005
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z13.undefined());
2861
3006
  }
2862
3007
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
2863
3008
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
2864
3009
  listEnv(org) {
2865
- return this.call("GET", "/vars", z11.array(EnvVarSchema), void 0, org);
3010
+ return this.call("GET", "/vars", z13.array(EnvVarSchema), void 0, org);
2866
3011
  }
2867
3012
  setEnv(name, req) {
2868
3013
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -2882,13 +3027,13 @@ var ServerClient = class {
2882
3027
  }
2883
3028
  // ---- volumes (#52) ----
2884
3029
  listVolumes(opts = {}) {
2885
- return this.call("GET", `/volumes${allQuery(opts)}`, z11.array(VolumeSchema), void 0, opts.org);
3030
+ return this.call("GET", `/volumes${allQuery(opts)}`, z13.array(VolumeSchema), void 0, opts.org);
2886
3031
  }
2887
3032
  createVolume(req) {
2888
3033
  return this.call("POST", "/volumes", VolumeSchema, req);
2889
3034
  }
2890
3035
  deleteVolume(name) {
2891
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z11.undefined());
3036
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z13.undefined());
2892
3037
  }
2893
3038
  /** Both answer with the box as it is afterwards (restarted when it was running). */
2894
3039
  attachVolume(name, req) {
@@ -2903,7 +3048,7 @@ var ServerClient = class {
2903
3048
  }
2904
3049
  // ---- cron service (#190): the control plane's alone ----
2905
3050
  listCronServices(opts = {}) {
2906
- return this.call("GET", `/cron${allQuery(opts)}`, z11.array(CronServiceSchema), void 0, opts.org);
3051
+ return this.call("GET", `/cron${allQuery(opts)}`, z13.array(CronServiceSchema), void 0, opts.org);
2907
3052
  }
2908
3053
  createCronService(name) {
2909
3054
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -2912,10 +3057,10 @@ var ServerClient = class {
2912
3057
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
2913
3058
  }
2914
3059
  deleteCronService(name) {
2915
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z11.undefined());
3060
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z13.undefined());
2916
3061
  }
2917
3062
  listCronTriggers(service) {
2918
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z11.array(CronTriggerSchema));
3063
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z13.array(CronTriggerSchema));
2919
3064
  }
2920
3065
  addCronTrigger(service, req) {
2921
3066
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -2925,18 +3070,18 @@ var ServerClient = class {
2925
3070
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
2926
3071
  }
2927
3072
  deleteCronTrigger(service, id) {
2928
- return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z11.undefined());
3073
+ return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z13.undefined());
2929
3074
  }
2930
3075
  /** Marks it due: kvbox-cron fires it within a few seconds. */
2931
3076
  runCronTrigger(service, id) {
2932
3077
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
2933
3078
  }
2934
3079
  listCronRuns(service, id, limit) {
2935
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z11.array(CronRunSchema));
3080
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z13.array(CronRunSchema));
2936
3081
  }
2937
3082
  // ---- object storage (#182): the control plane's alone ----
2938
3083
  listBuckets(opts = {}) {
2939
- return this.call("GET", `/buckets${allQuery(opts)}`, z11.array(BucketSchema), void 0, opts.org);
3084
+ return this.call("GET", `/buckets${allQuery(opts)}`, z13.array(BucketSchema), void 0, opts.org);
2940
3085
  }
2941
3086
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
2942
3087
  createBucket(req) {
@@ -2945,27 +3090,31 @@ var ServerClient = class {
2945
3090
  getBucket(name) {
2946
3091
  return this.call("GET", `/buckets/${encodeURIComponent(name)}`, BucketInfoSchema);
2947
3092
  }
3093
+ /** Make every object of the bucket readable by anyone at its own address (#191), or private again. */
3094
+ setBucketPublic(name, req) {
3095
+ return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
3096
+ }
2948
3097
  deleteBucket(name, force = false) {
2949
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z11.undefined());
3098
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z13.undefined());
2950
3099
  }
2951
3100
  listBucketKeys(name) {
2952
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z11.array(BucketKeySchema));
3101
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z13.array(BucketKeySchema));
2953
3102
  }
2954
3103
  createBucketKey(name, req) {
2955
3104
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
2956
3105
  }
2957
3106
  deleteBucketKey(name, id) {
2958
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z11.undefined());
3107
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z13.undefined());
2959
3108
  }
2960
3109
  listStorage(opts = {}) {
2961
- return this.call("GET", `/storage${allQuery(opts)}`, z11.array(ObjectStorageSchema), void 0, opts.org);
3110
+ return this.call("GET", `/storage${allQuery(opts)}`, z13.array(ObjectStorageSchema), void 0, opts.org);
2962
3111
  }
2963
3112
  growStorage(sizeGib) {
2964
3113
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
2965
3114
  }
2966
3115
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
2967
3116
  storageBackups() {
2968
- return this.call("GET", "/storage/backups", z11.array(StorageBackupSchema));
3117
+ return this.call("GET", "/storage/backups", z13.array(StorageBackupSchema));
2969
3118
  }
2970
3119
  storageBackup(id) {
2971
3120
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -2986,11 +3135,11 @@ var ServerClient = class {
2986
3135
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
2987
3136
  }
2988
3137
  managedCatalog() {
2989
- return this.call("GET", "/managed/catalog", z11.array(ManagedCatalogEntrySchema));
3138
+ return this.call("GET", "/managed/catalog", z13.array(ManagedCatalogEntrySchema));
2990
3139
  }
2991
3140
  /** One kind's services, or every kind's when `kind` is left out. */
2992
3141
  listManaged(kind, opts = {}) {
2993
- return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z11.array(ManagedSchema), void 0, opts.org);
3142
+ return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z13.array(ManagedSchema), void 0, opts.org);
2994
3143
  }
2995
3144
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
2996
3145
  createManaged(kind, req) {
@@ -3001,7 +3150,7 @@ var ServerClient = class {
3001
3150
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3002
3151
  }
3003
3152
  deleteManaged(kind, name) {
3004
- return this.call("DELETE", this.managedPath(kind, name), z11.undefined());
3153
+ return this.call("DELETE", this.managedPath(kind, name), z13.undefined());
3005
3154
  }
3006
3155
  managedPassword(kind, name) {
3007
3156
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3023,10 +3172,10 @@ var ServerClient = class {
3023
3172
  }
3024
3173
  /** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
3025
3174
  listManagedBackups(kind) {
3026
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z11.array(ManagedBackupSchema));
3175
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z13.array(ManagedBackupSchema));
3027
3176
  }
3028
3177
  managedBackups(kind, name) {
3029
- return this.call("GET", this.managedPath(kind, name, "/backups"), z11.array(ManagedBackupSchema));
3178
+ return this.call("GET", this.managedPath(kind, name, "/backups"), z13.array(ManagedBackupSchema));
3030
3179
  }
3031
3180
  managedBackup(kind, name, id) {
3032
3181
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3068,24 +3217,36 @@ var ServerClient = class {
3068
3217
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3069
3218
  }
3070
3219
  logout() {
3071
- return this.call("POST", "/logout", z11.unknown()).then(() => void 0);
3220
+ return this.call("POST", "/logout", z13.unknown()).then(() => void 0);
3072
3221
  }
3073
3222
  me() {
3074
3223
  return this.call("GET", "/me", MeResponseSchema);
3075
3224
  }
3225
+ // ---- Integrations (`kvbox integration ls`, #205) ----
3226
+ /**
3227
+ * What one org has connected (`org`, else the `--org` one), or without either each readable slug; never a
3228
+ * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3229
+ */
3230
+ listIntegrations(org) {
3231
+ return this.call("GET", "/integrations", z13.array(IntegrationSchema), void 0, org);
3232
+ }
3233
+ /** What can be connected on this control plane, and by which kind of slug. */
3234
+ integrationCatalog() {
3235
+ return this.call("GET", "/integrations/catalog", z13.array(IntegrationCatalogEntrySchema), void 0, null);
3236
+ }
3076
3237
  // ---- API keys (`kvbox key …`, #189) ----
3077
3238
  listApiKeys() {
3078
- return this.call("GET", "/keys", z11.array(ApiKeySchema));
3239
+ return this.call("GET", "/keys", z13.array(ApiKeySchema));
3079
3240
  }
3080
3241
  createApiKey(req) {
3081
3242
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3082
3243
  }
3083
3244
  deleteApiKey(name) {
3084
- return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z11.unknown()).then(() => void 0);
3245
+ return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z13.unknown()).then(() => void 0);
3085
3246
  }
3086
3247
  // ---- orgs (`kvbox org …`) ----
3087
3248
  listOrgs() {
3088
- return this.call("GET", "/orgs", z11.array(OrgMembershipSchema));
3249
+ return this.call("GET", "/orgs", z13.array(OrgMembershipSchema));
3089
3250
  }
3090
3251
  createOrg(req) {
3091
3252
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3094,16 +3255,16 @@ var ServerClient = class {
3094
3255
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3095
3256
  }
3096
3257
  deleteOrg(slug) {
3097
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z11.undefined());
3258
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z13.undefined());
3098
3259
  }
3099
3260
  addMember(slug, req) {
3100
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z11.undefined(), req);
3261
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z13.undefined(), req);
3101
3262
  }
3102
3263
  setRole(slug, username, role) {
3103
- return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z11.unknown(), { role }).then(() => void 0);
3264
+ return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.unknown(), { role }).then(() => void 0);
3104
3265
  }
3105
3266
  removeMember(slug, username) {
3106
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z11.undefined());
3267
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.undefined());
3107
3268
  }
3108
3269
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3109
3270
  sshCert(req) {
@@ -3535,13 +3696,58 @@ function parseDuration(text2) {
3535
3696
  return sec;
3536
3697
  }
3537
3698
 
3699
+ // src/commands/integration/shared.ts
3700
+ function whereToConnect(catalog, id) {
3701
+ const page = (catalog.find((e) => e.id === id) ?? catalog.find((e) => e.page !== void 0))?.page;
3702
+ return page === void 0 ? "in the web app" : `at ${page}`;
3703
+ }
3704
+ function integrationsKept(asked, box2) {
3705
+ if (asked === void 0) return true;
3706
+ const have = box2.integrations ?? [];
3707
+ return asked.length === have.length && asked.every((id) => have.includes(id));
3708
+ }
3709
+ var integrationsText = (list) => list?.length ? list.join(", ") : "none";
3710
+ function connectable(catalog, id, own) {
3711
+ const entry = catalog.find((e) => e.id === id);
3712
+ return entry === void 0 || entry.kinds[own ? "user" : "org"].length > 0;
3713
+ }
3714
+ var catalogOf = (client) => client.integrationCatalog().catch(() => []);
3715
+ async function noteNotConnected(client, box2, asked) {
3716
+ if (asked.length === 0 || client.target.kind !== "cloud") {
3717
+ if (asked.length > 0) warn(`box ${box2.name}: integrations need the kvbox cloud; a box made on this machine never gets a credential`);
3718
+ return;
3719
+ }
3720
+ const slug = slugOf(box2.owner);
3721
+ const [rows2, catalog] = await Promise.all([client.listIntegrations(null).catch(() => null), catalogOf(client)]);
3722
+ if (rows2 === null) return;
3723
+ for (const id of asked) {
3724
+ const row = rows2.find((r) => r.owner === slug && r.integration === id);
3725
+ if (row === void 0 || row.connected && row.status === "ok") continue;
3726
+ if (!row.connected && !connectable(catalog, id, slug === me(client))) {
3727
+ info(color.dim(` ${id} cannot be connected for an org yet: it is on for this box, which gets nothing from it until ${slug} can connect it`));
3728
+ continue;
3729
+ }
3730
+ const why = row.connected ? `${id} needs to be connected again for ${slug}` : `${id} is not connected for ${slug} yet`;
3731
+ info(color.dim(` ${why}: it is on for this box and works once connected ${whereToConnect(catalog, id)}`));
3732
+ }
3733
+ }
3734
+
3538
3735
  // src/commands/vm/new.ts
3539
- var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
3736
+ var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so the two can be linked (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--integration <list>", "turn integrations on for the box, e.g. github (connect the account in the web app; off: none)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
3540
3737
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
3541
3738
  const env = parseEnvFlags(opts.env);
3739
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
3542
3740
  const country = opts.country === void 0 ? void 0 : parseCountry(opts.country);
3543
3741
  if (country !== void 0 && opts.from !== void 0) throw new KvboxError("--country cannot be given with --from: a snapshot is restored on its own host");
3742
+ if (opts.fromBackup !== void 0) {
3743
+ const clash = opts.from !== void 0 ? "--from" : opts.base !== void 0 ? "--base" : env.length > 0 ? "-e" : null;
3744
+ if (clash) throw new KvboxError(`a box from a backup takes its image and variables from the backup; ${clash} cannot be given with --from-backup`);
3745
+ }
3544
3746
  const client = await clientFor(cmd.optsWithGlobals());
3747
+ if (opts.fromBackup !== void 0 && client.target.kind !== "cloud") {
3748
+ await client.close();
3749
+ throw new KvboxError("backups are kept by the control plane; this machine has none (kvbox login first)");
3750
+ }
3545
3751
  if (country !== void 0 && client.target.kind !== "cloud") {
3546
3752
  await client.close();
3547
3753
  throw new KvboxError("--country picks a host through the control plane; this machine is the only host here (kvbox login first)");
@@ -3551,23 +3757,29 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3551
3757
  throw new KvboxError("--host picks a host through the control plane; this machine is the only host here (kvbox login first)");
3552
3758
  }
3553
3759
  try {
3554
- const what = opts.from !== void 0 ? `restoring ${name ?? "a new box"} from snapshot ${opts.from}\u2026` : `booting ${name ?? "a new box"}${opts.base !== void 0 && opts.base !== "base" ? ` from image ${opts.base}` : ""}\u2026`;
3760
+ const what = opts.fromBackup !== void 0 ? `restoring ${name ?? "a new box"} from backup ${opts.fromBackup}\u2026` : opts.from !== void 0 ? `restoring ${name ?? "a new box"} from snapshot ${opts.from}\u2026` : `booting ${name ?? "a new box"}${opts.base !== void 0 && opts.base !== "base" ? ` from image ${opts.base}` : ""}\u2026`;
3555
3761
  const box2 = await spin(what, client.createMachine({
3556
3762
  ...name !== void 0 ? { name } : {},
3557
3763
  ...opts.size !== void 0 ? { size: opts.size } : {},
3558
3764
  ...opts.from !== void 0 ? { from: opts.from } : {},
3765
+ ...opts.fromBackup !== void 0 ? { fromBackup: opts.fromBackup } : {},
3559
3766
  ...opts.base !== void 0 ? { image: opts.base } : {},
3560
3767
  ...env.length > 0 ? { env } : {},
3561
3768
  ...opts.near !== void 0 ? { near: opts.near } : {},
3562
3769
  ...country !== void 0 ? { country } : {},
3563
3770
  ...opts.host !== void 0 ? { host: opts.host } : {},
3564
3771
  ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
3772
+ ...integrations !== void 0 ? { integrations } : {},
3565
3773
  ...opts.force ? { force: true } : {}
3566
3774
  }));
3775
+ if (opts.fromBackup !== void 0 && !box2.source.startsWith("backup:")) {
3776
+ throw new KvboxError(`this control plane does not know --from-backup yet: box ${box2.name} was made empty, not from backup ${opts.fromBackup}; remove it with: kvbox rm ${displayName(box2, me(client))}`);
3777
+ }
3567
3778
  if (autoHibernateSec && !box2.autoHibernateSec) warn(`box ${name ?? box2.name}: its host runs a kvbox-server too old for auto-hibernate; it will not hibernate on its own`);
3568
3779
  if (opts.base !== void 0 && opts.base !== "base" && box2.image === void 0) {
3569
3780
  warn(`box ${box2.name}: its host runs a kvbox-server too old for images; it booted the base image, not ${opts.base}`);
3570
3781
  }
3782
+ if (integrations?.length && !integrationsKept(integrations, box2)) warn(`box ${box2.name}: its host runs a kvbox-server too old for integrations; it has none`);
3571
3783
  if (env.length > 0) {
3572
3784
  const kept = await keptVars(client, displayName(box2, me(client)), env.map((v) => v.name));
3573
3785
  if (kept === "too old") warn(`box ${box2.name}: its host runs a kvbox-server too old for a box's own variables; it has none of the -e ones`);
@@ -3582,8 +3794,13 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3582
3794
  `);
3583
3795
  info(`${color.green("\u2713")} ${describe(box2, user)}`);
3584
3796
  if (opts.from !== void 0) info(` connect with: kvbox connect ${displayName(box2, user)} (already up: everything that ran in the snapshot is running)`);
3797
+ else if (opts.fromBackup !== void 0) info(` connect with: kvbox connect ${displayName(box2, user)} (booting on the backup's disk: SSH is up a couple of seconds after)`);
3585
3798
  else info(` connect with: kvbox connect ${displayName(box2, user)} (SSH is up a couple of seconds after boot)`);
3586
3799
  if (box2.autoHibernateSec) info(` it ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
3800
+ if (box2.integrations?.length) {
3801
+ info(` integrations: ${integrationsText(box2.integrations)}`);
3802
+ await noteNotConnected(client, box2, box2.integrations);
3803
+ }
3587
3804
  if (box2.connect !== void 0) {
3588
3805
  info(` reach it at: ${box2.connect}`);
3589
3806
  info(` from another box once linked: kvbox vm link <box> ${displayName(box2, user)} --port <port>`);
@@ -3994,6 +4211,7 @@ function getRows(box2, subs, user) {
3994
4211
  const quiet = box2.idleCheck === void 0 ? "without network traffic" : `idle by ${box2.idleCheck}`;
3995
4212
  rows2.push(["auto-hibernate", box2.autoHibernateSec ? `after ${duration(box2.autoHibernateSec)} ${quiet}` : "off"]);
3996
4213
  if (!box2.autoHibernateSec && box2.idleCheck !== void 0) rows2.push(["idle check", `${box2.idleCheck} ${color.dim("(used once auto-hibernate is on)")}`]);
4214
+ rows2.push(["integrations", box2.integrations?.length ? box2.integrations.join(", ") : "-"]);
3997
4215
  rows2.push(["source", box2.source]);
3998
4216
  rows2.push(["base", box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`]);
3999
4217
  rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
@@ -4579,8 +4797,7 @@ var lsCommand4 = new Command25("ls").alias("list").description("list backups: ev
4579
4797
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
4580
4798
  try {
4581
4799
  requireCloud3(client);
4582
- const box2 = name === void 0 ? void 0 : displayName(await findBox(client, name), me(client));
4583
- const list = box2 === void 0 ? await client.listBackups() : await client.boxBackups(box2);
4800
+ const { box: box2, list } = await backupsOf(client, name);
4584
4801
  if (opts.json) {
4585
4802
  json(list);
4586
4803
  return;
@@ -4590,10 +4807,12 @@ var lsCommand4 = new Command25("ls").alias("list").description("list backups: ev
4590
4807
  return;
4591
4808
  }
4592
4809
  const anyError = list.some((b) => b.error !== null);
4810
+ const anyRemoved = list.some((b) => b.boxRemoved === true);
4811
+ const removed = (b) => b.boxRemoved === true ? color.dim(" (removed)") : "";
4593
4812
  table(
4594
4813
  list.map((b) => ({
4595
4814
  id: b.id,
4596
- ...box2 === void 0 ? { box: b.owner === me(client) ? b.box : `${b.owner}/${b.box}` } : {},
4815
+ ...box2 === void 0 ? { box: (b.owner === me(client) ? b.box : `${b.owner}/${b.box}`) + removed(b) } : anyRemoved ? { of: b.boxRemoved === true ? color.dim("removed box") : "this box" } : {},
4597
4816
  status: b.status === "ready" ? color.green(b.status) : b.status === "failed" ? color.red(b.status) : color.yellow(b.status),
4598
4817
  data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
4599
4818
  uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
@@ -4603,10 +4822,31 @@ var lsCommand4 = new Command25("ls").alias("list").description("list backups: ev
4603
4822
  ...anyError ? { error: b.error ?? "" } : {}
4604
4823
  }))
4605
4824
  );
4825
+ if (anyRemoved) {
4826
+ const orgs = [...new Set(list.filter((b) => b.boxRemoved === true && slugOf(b.owner) !== me(client)).map((b) => slugOf(b.owner)))];
4827
+ info(`a removed box's backup makes a new box: kvbox new <name>${orgs.length === 1 ? ` --org ${orgs[0]}` : orgs.length > 1 ? " --org <org>" : ""} --from-backup <id>`);
4828
+ }
4606
4829
  } finally {
4607
4830
  await client.close();
4608
4831
  }
4609
4832
  });
4833
+ async function backupsOf(client, name) {
4834
+ if (name === void 0) return { box: void 0, list: await client.listBackups() };
4835
+ const live = pickRef(await boxesFor(client, name), name, me(client));
4836
+ if (live) {
4837
+ const box2 = displayName(live, me(client));
4838
+ return { box: box2, list: await client.boxBackups(box2) };
4839
+ }
4840
+ const [owner, bare] = name.includes("/") ? name.split("/", 2) : [void 0, name];
4841
+ const named = (await client.listBackups()).filter((b) => b.box === bare && (owner === void 0 || slugOf(b.owner) === owner));
4842
+ if (named.length === 0) throw new KvboxError(`box ${name}: not found (kvbox ls)`);
4843
+ if (owner !== void 0) return { box: name, list: named };
4844
+ const mine = named.filter((b) => slugOf(b.owner) === me(client));
4845
+ if (mine.length > 0) return { box: name, list: mine };
4846
+ const owners = [...new Set(named.map((b) => slugOf(b.owner)))];
4847
+ if (owners.length > 1) throw new AmbiguousRefError("box", bare, owners);
4848
+ return { box: `${owners[0]}/${bare}`, list: named };
4849
+ }
4610
4850
 
4611
4851
  // src/commands/vm/backup/restore.ts
4612
4852
  import { Command as Command26 } from "commander";
@@ -4807,14 +5047,16 @@ function runSwap(ep, mib) {
4807
5047
  }
4808
5048
 
4809
5049
  // src/commands/vm/set.ts
4810
- var setCommand = new Command32("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
4811
- if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.swap === void 0) {
4812
- throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check or --swap");
5050
+ var setCommand = new Command32("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --integration github, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--integration <list>", "the integrations turned on for the box, replacing its list, e.g. github (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
5051
+ if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5052
+ throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
4813
5053
  }
5054
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
4814
5055
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
4815
5056
  const idleCheck = opts.idleCheck === void 0 ? void 0 : parseIdleCheck(opts.idleCheck);
4816
5057
  const swapMib = opts.swap === void 0 ? void 0 : parseSwap(opts.swap);
4817
- const hostSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5058
+ const idleSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5059
+ const hostSettings = idleSettings || integrations !== void 0;
4818
5060
  const client = await clientFor(cmd.optsWithGlobals());
4819
5061
  try {
4820
5062
  const found = pickRef(await boxesFor(client, name), name, me(client));
@@ -4822,7 +5064,10 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4822
5064
  if (swapMib !== void 0 && found.status === "stopped") throw new KvboxError(`box ${name} is stopped; --swap is set up inside the box (kvbox start ${name})`);
4823
5065
  let box2 = found;
4824
5066
  if (hostSettings) {
4825
- box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {} }));
5067
+ box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {}, ...integrations !== void 0 ? { integrations } : {} }));
5068
+ if (!integrationsKept(integrations, box2)) {
5069
+ throw new KvboxError(`box ${name}: its host runs a kvbox-server too old for integrations; it needs updating first${idleSettings ? " (the other settings were applied)" : ""}`);
5070
+ }
4826
5071
  if (!idleCheckKept(idleCheck, box2)) {
4827
5072
  throw new KvboxError(`box ${name}: its host runs a kvbox-server too old for --idle-check; it needs updating first${autoHibernateSec !== void 0 ? " (--auto-hibernate was applied)" : ""}`);
4828
5073
  }
@@ -4832,7 +5077,11 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4832
5077
  json(swap === void 0 ? box2 : { ...box2, swap });
4833
5078
  return;
4834
5079
  }
4835
- if (hostSettings) info(`${color.green("\u2713")} box ${color.bold(name)}: ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
5080
+ if (idleSettings) info(`${color.green("\u2713")} box ${color.bold(name)}: ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
5081
+ if (integrations !== void 0) {
5082
+ info(`${color.green("\u2713")} box ${color.bold(name)}: integrations ${integrationsText(box2.integrations)}${integrations.length > 0 && box2.status !== "running" ? color.dim(` (used once it runs)`) : ""}`);
5083
+ await noteNotConnected(client, box2, integrations);
5084
+ }
4836
5085
  if (idleCheck && !box2.autoHibernateSec) info(color.dim(` the idle check is used once auto-hibernate is on: kvbox vm set ${name} --auto-hibernate 10m`));
4837
5086
  if (swap) info(`${color.green("\u2713")} box ${color.bold(name)}: ${swapText(swap)}`);
4838
5087
  } finally {
@@ -5339,12 +5588,48 @@ var rmCommand5 = new Command45("rm").alias("remove").description("remove an API
5339
5588
  // src/commands/key/index.ts
5340
5589
  var keyCommand = new Command46("key").aliases(["keys"]).description("API keys: named tokens a program (CI, an agent, the SDK) uses as KVBOX_TOKEN in place of a login").addCommand(createCommand3).addCommand(lsCommand5).addCommand(rmCommand5);
5341
5590
 
5591
+ // src/commands/integration/index.ts
5592
+ import { Command as Command48 } from "commander";
5593
+
5594
+ // src/commands/integration/ls.ts
5595
+ import { Command as Command47 } from "commander";
5596
+ var lsCommand6 = new Command47("ls").alias("list").description("list the accounts connected for your boxes (GitHub), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
5597
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5598
+ try {
5599
+ if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
5600
+ const rows2 = await client.listIntegrations();
5601
+ if (opts.json) {
5602
+ json(rows2);
5603
+ return;
5604
+ }
5605
+ const catalog = await catalogOf(client);
5606
+ const open = (r) => r.connected || connectable(catalog, r.integration, r.owner === me(client));
5607
+ table(
5608
+ rows2.map((r) => ({
5609
+ slug: r.owner,
5610
+ integration: r.integration,
5611
+ state: !open(r) ? color.dim("not for orgs yet") : !r.connected ? color.dim("not connected") : r.status === "needs-reconnect" ? color.yellow("connect again") : color.green("connected"),
5612
+ account: r.account ?? "-",
5613
+ connected: r.connectedAt === null ? "-" : age(r.connectedAt),
5614
+ "last used": r.connected ? r.lastUsedAt === null ? "never" : age(r.lastUsedAt) : "-"
5615
+ }))
5616
+ );
5617
+ if (rows2.some((r) => open(r) && (!r.connected || r.status === "needs-reconnect"))) info(color.dim(`connect an account ${whereToConnect(catalog)}`));
5618
+ if (rows2.some((r) => r.connected)) info(color.dim("turn one on for a box with: kvbox vm set <box> --integration github"));
5619
+ } finally {
5620
+ await client.close();
5621
+ }
5622
+ });
5623
+
5624
+ // src/commands/integration/index.ts
5625
+ var integrationCommand = new Command48("integration").aliases(["integrations"]).description("integrations: accounts (GitHub) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
5626
+
5342
5627
  // src/commands/snapshots/index.ts
5343
- import { Command as Command50 } from "commander";
5628
+ import { Command as Command52 } from "commander";
5344
5629
 
5345
5630
  // src/commands/snapshots/ls.ts
5346
- import { Command as Command47 } from "commander";
5347
- var lsCommand6 = new Command47("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
5631
+ import { Command as Command49 } from "commander";
5632
+ var lsCommand7 = new Command49("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
5348
5633
  const client = await clientFor(cmd.optsWithGlobals());
5349
5634
  try {
5350
5635
  const cloud = client.target.kind === "cloud";
@@ -5375,8 +5660,8 @@ var lsCommand6 = new Command47("ls").description("list snapshots (yours and your
5375
5660
  });
5376
5661
 
5377
5662
  // src/commands/snapshots/new.ts
5378
- import { Command as Command48 } from "commander";
5379
- var newCommand2 = new Command48("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box2, name, opts, cmd) => {
5663
+ import { Command as Command50 } from "commander";
5664
+ var newCommand2 = new Command50("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box2, name, opts, cmd) => {
5380
5665
  const client = await clientFor(cmd.optsWithGlobals());
5381
5666
  try {
5382
5667
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5389,8 +5674,8 @@ var newCommand2 = new Command48("new").description("freeze a running box (memory
5389
5674
  });
5390
5675
 
5391
5676
  // src/commands/snapshots/rm.ts
5392
- import { Command as Command49 } from "commander";
5393
- var rmCommand6 = new Command49("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
5677
+ import { Command as Command51 } from "commander";
5678
+ var rmCommand6 = new Command51("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
5394
5679
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5395
5680
  info("cancelled");
5396
5681
  process.exitCode = 1;
@@ -5406,14 +5691,14 @@ var rmCommand6 = new Command49("rm").description("delete a snapshot (boxes made
5406
5691
  });
5407
5692
 
5408
5693
  // src/commands/snapshots/index.ts
5409
- var snapshotsCommand = new Command50("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand6).addCommand(rmCommand6);
5694
+ var snapshotsCommand = new Command52("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5410
5695
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5411
5696
 
5412
5697
  // src/commands/org/index.ts
5413
- import { Command as Command56 } from "commander";
5698
+ import { Command as Command58 } from "commander";
5414
5699
 
5415
5700
  // src/commands/org/ls.ts
5416
- import { Command as Command51 } from "commander";
5701
+ import { Command as Command53 } from "commander";
5417
5702
 
5418
5703
  // src/commands/org/context.ts
5419
5704
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -5433,7 +5718,7 @@ function orgFor(opts, target) {
5433
5718
  }
5434
5719
 
5435
5720
  // src/commands/org/ls.ts
5436
- var lsCommand7 = new Command51("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
5721
+ var lsCommand8 = new Command53("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
5437
5722
  const client = await cloudClientFor(cmd.optsWithGlobals());
5438
5723
  try {
5439
5724
  const orgs = await client.listOrgs();
@@ -5455,8 +5740,8 @@ function orgRows(orgs) {
5455
5740
  }
5456
5741
 
5457
5742
  // src/commands/org/members.ts
5458
- import { Command as Command52, Option as Option4 } from "commander";
5459
- var lsCommand8 = new Command52("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
5743
+ import { Command as Command54, Option as Option4 } from "commander";
5744
+ var lsCommand9 = new Command54("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
5460
5745
  const client = await cloudClientFor(cmd.optsWithGlobals());
5461
5746
  try {
5462
5747
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -5470,7 +5755,7 @@ var lsCommand8 = new Command52("ls").description("list an org's members and thei
5470
5755
  await client.close();
5471
5756
  }
5472
5757
  });
5473
- var addCommand2 = new Command52("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
5758
+ var addCommand2 = new Command54("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
5474
5759
  const client = await cloudClientFor(cmd.optsWithGlobals());
5475
5760
  try {
5476
5761
  const slug = orgFor(opts, client.target);
@@ -5480,7 +5765,7 @@ var addCommand2 = new Command52("add").description("add a user to an org (admins
5480
5765
  await client.close();
5481
5766
  }
5482
5767
  });
5483
- var rmCommand7 = new Command52("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
5768
+ var rmCommand7 = new Command54("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
5484
5769
  const client = await cloudClientFor(cmd.optsWithGlobals());
5485
5770
  try {
5486
5771
  const slug = orgFor(opts, client.target);
@@ -5496,11 +5781,11 @@ var rmCommand7 = new Command52("rm").description("remove a member (or leave: rem
5496
5781
  await client.close();
5497
5782
  }
5498
5783
  });
5499
- var membersCommand = new Command52("members").description("who is in an org and what they may do").addCommand(lsCommand8).addCommand(addCommand2).addCommand(rmCommand7);
5784
+ var membersCommand = new Command54("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
5500
5785
 
5501
5786
  // src/commands/org/new.ts
5502
- import { Command as Command53 } from "commander";
5503
- var newCommand3 = new Command53("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
5787
+ import { Command as Command55 } from "commander";
5788
+ var newCommand3 = new Command55("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
5504
5789
  const client = await cloudClientFor(cmd.optsWithGlobals());
5505
5790
  try {
5506
5791
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -5516,8 +5801,8 @@ var newCommand3 = new Command53("new").description("create an org; you become it
5516
5801
  });
5517
5802
 
5518
5803
  // src/commands/org/rm.ts
5519
- import { Command as Command54 } from "commander";
5520
- var rmCommand8 = new Command54("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
5804
+ import { Command as Command56 } from "commander";
5805
+ var rmCommand8 = new Command56("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
5521
5806
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
5522
5807
  info("cancelled");
5523
5808
  process.exitCode = 1;
@@ -5533,8 +5818,8 @@ var rmCommand8 = new Command54("rm").description("delete an org (owners only; re
5533
5818
  });
5534
5819
 
5535
5820
  // src/commands/org/role.ts
5536
- import { Argument, Command as Command55 } from "commander";
5537
- var roleCommand = new Command55("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
5821
+ import { Argument, Command as Command57 } from "commander";
5822
+ var roleCommand = new Command57("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
5538
5823
  const client = await cloudClientFor(cmd.optsWithGlobals());
5539
5824
  try {
5540
5825
  const slug = orgFor(opts, client.target);
@@ -5546,11 +5831,11 @@ var roleCommand = new Command55("role").description("change a member's role (own
5546
5831
  });
5547
5832
 
5548
5833
  // src/commands/org/index.ts
5549
- var orgCommand = new Command56("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand7).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
5834
+ var orgCommand = new Command58("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
5550
5835
 
5551
5836
  // src/commands/usage.ts
5552
- import { Command as Command57 } from "commander";
5553
- var usageCommand2 = new Command57("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
5837
+ import { Command as Command59 } from "commander";
5838
+ var usageCommand2 = new Command59("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
5554
5839
  for (const [name, value] of [
5555
5840
  ["since", opts.since],
5556
5841
  ["until", opts.until]
@@ -5747,8 +6032,8 @@ function userRows(r) {
5747
6032
  }
5748
6033
 
5749
6034
  // src/commands/credit.ts
5750
- import { Command as Command58 } from "commander";
5751
- var creditCommand = new Command58("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
6035
+ import { Command as Command60 } from "commander";
6036
+ var creditCommand = new Command60("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
5752
6037
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5753
6038
  try {
5754
6039
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -5777,8 +6062,8 @@ function creditRow(b, me2) {
5777
6062
  }
5778
6063
 
5779
6064
  // src/commands/redeem.ts
5780
- import { Command as Command59 } from "commander";
5781
- var redeemCommand = new Command59("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
6065
+ import { Command as Command61 } from "commander";
6066
+ var redeemCommand = new Command61("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
5782
6067
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5783
6068
  try {
5784
6069
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -5798,12 +6083,12 @@ var redeemCommand = new Command59("redeem").description("redeem a promo code for
5798
6083
  // src/commands/deploy/index.ts
5799
6084
  import { access as access5, readFile as readFile7 } from "fs/promises";
5800
6085
  import { basename as basename2, resolve as resolve3 } from "path";
5801
- import { Command as Command60, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6086
+ import { Command as Command62, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
5802
6087
 
5803
6088
  // src/commands/deploy/config.ts
5804
6089
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
5805
6090
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
5806
- import { z as z12 } from "zod";
6091
+ import { z as z14 } from "zod";
5807
6092
 
5808
6093
  // src/commands/deploy/templates/docker.ts
5809
6094
  import { readFile as readFile4 } from "fs/promises";
@@ -6227,21 +6512,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6227
6512
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6228
6513
  var CONFIG_FILE = "kvbox.json";
6229
6514
  var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
6230
- var DeployConfigSchema = z12.object({
6231
- template: z12.enum(TEMPLATE_IDS),
6232
- name: z12.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6515
+ var DeployConfigSchema = z14.object({
6516
+ template: z14.enum(TEMPLATE_IDS),
6517
+ name: z14.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6233
6518
  /** The org whose box it is; absent for the user's own. */
6234
- org: z12.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6519
+ org: z14.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6235
6520
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6236
- subdomain: z12.string().check((ctx) => {
6521
+ subdomain: z14.string().check((ctx) => {
6237
6522
  const problem = subdomainProblem(ctx.value);
6238
6523
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6239
6524
  }).optional(),
6240
- size: z12.enum(SIZE_NAMES).optional(),
6525
+ size: z14.enum(SIZE_NAMES).optional(),
6241
6526
  /** The build output directory, relative to the app; the template's default when absent. */
6242
- dist: z12.string().optional(),
6527
+ dist: z14.string().optional(),
6243
6528
  /** The port a Next.js app or Node server serves; the template's (3000) when absent. */
6244
- port: z12.number().int().min(1).max(65535).optional()
6529
+ port: z14.number().int().min(1).max(65535).optional()
6245
6530
  });
6246
6531
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6247
6532
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6253,38 +6538,38 @@ var POSTGRES_PORT = 5432;
6253
6538
  var POSTGRES_IMAGE = "postgres:17";
6254
6539
  var POSTGRES_ENV = "DATABASE_URL";
6255
6540
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6256
- var ServiceSchema = z12.strictObject({
6257
- template: z12.enum([...TEMPLATE_IDS, POSTGRES]),
6541
+ var ServiceSchema = z14.strictObject({
6542
+ template: z14.enum([...TEMPLATE_IDS, POSTGRES]),
6258
6543
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6259
- dir: z12.string().min(1).optional(),
6544
+ dir: z14.string().min(1).optional(),
6260
6545
  /** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
6261
- image: z12.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6546
+ image: z14.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6262
6547
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6263
- volume: z12.string().optional(),
6548
+ volume: z14.string().optional(),
6264
6549
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6265
- env: z12.string().optional(),
6550
+ env: z14.string().optional(),
6266
6551
  /** A docker service's build context, relative to kvbox.json, when it is not `dir` (a monorepo built from its root); the Dockerfile stays in `dir`. */
6267
- context: z12.string().min(1).optional(),
6268
- dist: z12.string().optional(),
6552
+ context: z14.string().min(1).optional(),
6553
+ dist: z14.string().optional(),
6269
6554
  /**
6270
6555
  * A command run once per deploy in the service's new version (a docker service: in a container of
6271
6556
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6272
6557
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6273
6558
  */
6274
- release: z12.string().optional(),
6559
+ release: z14.string().optional(),
6275
6560
  /** The box port of a service with its own server; the template's (3000) when absent. */
6276
- port: z12.number().int().min(1).max(65535).optional(),
6561
+ port: z14.number().int().min(1).max(65535).optional(),
6277
6562
  /** The URL paths that go to this service, each with everything under it; the prefix is kept. */
6278
- paths: z12.array(z12.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6563
+ paths: z14.array(z14.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6279
6564
  });
6280
- var StackConfigSchema = z12.strictObject({
6565
+ var StackConfigSchema = z14.strictObject({
6281
6566
  name: DeployConfigSchema.shape.name.optional(),
6282
6567
  org: DeployConfigSchema.shape.org,
6283
6568
  subdomain: DeployConfigSchema.shape.subdomain,
6284
6569
  size: DeployConfigSchema.shape.size,
6285
6570
  /** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
6286
- volumes: z12.record(z12.string(), z12.string()).optional(),
6287
- services: z12.record(z12.string(), ServiceSchema)
6571
+ volumes: z14.record(z14.string(), z14.string()).optional(),
6572
+ services: z14.record(z14.string(), ServiceSchema)
6288
6573
  });
6289
6574
  function volumeGib(text2) {
6290
6575
  const mib = parseMib(text2);
@@ -7063,7 +7348,7 @@ async function readPackageJson(dir) {
7063
7348
  }
7064
7349
 
7065
7350
  // src/commands/deploy/index.ts
7066
- var deployCommand = new Command60("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
7351
+ var deployCommand = new Command62("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
7067
7352
  const dir = resolve3(dirArg ?? ".");
7068
7353
  const pkg = await readPackageJson2(dir);
7069
7354
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7220,15 +7505,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7220
7505
  }
7221
7506
 
7222
7507
  // src/commands/volume/index.ts
7223
- import { Command as Command72 } from "commander";
7508
+ import { Command as Command74 } from "commander";
7224
7509
 
7225
7510
  // src/commands/volume/attach.ts
7226
- import { Command as Command61 } from "commander";
7511
+ import { Command as Command63 } from "commander";
7227
7512
  function describeMount(machine, volume2, box2) {
7228
7513
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7229
7514
  return machine.status === "running" ? ` the box was restarted; the volume is at ${path} inside it` : ` box ${box2} is ${machine.status}; the volume is at ${path} once it runs`;
7230
7515
  }
7231
- var attachCommand = new Command61("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
7516
+ var attachCommand = new Command63("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
7232
7517
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7233
7518
  const client = await clientFor(cmd.optsWithGlobals());
7234
7519
  try {
@@ -7247,11 +7532,11 @@ var attachCommand = new Command61("attach").description("attach a volume to a bo
7247
7532
  });
7248
7533
 
7249
7534
  // src/commands/volume/backup/index.ts
7250
- import { Command as Command66 } from "commander";
7535
+ import { Command as Command68 } from "commander";
7251
7536
 
7252
7537
  // src/commands/volume/backup/create.ts
7253
- import { Command as Command62 } from "commander";
7254
- var createCommand4 = new Command62("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
7538
+ import { Command as Command64 } from "commander";
7539
+ var createCommand4 = new Command64("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
7255
7540
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7256
7541
  try {
7257
7542
  requireCloud3(client);
@@ -7278,8 +7563,8 @@ var createCommand4 = new Command62("create").description("back up a volume's dis
7278
7563
  });
7279
7564
 
7280
7565
  // src/commands/volume/backup/ls.ts
7281
- import { Command as Command63 } from "commander";
7282
- var lsCommand9 = new Command63("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
7566
+ import { Command as Command65 } from "commander";
7567
+ var lsCommand10 = new Command65("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
7283
7568
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7284
7569
  try {
7285
7570
  requireCloud3(client);
@@ -7312,8 +7597,8 @@ var lsCommand9 = new Command63("ls").alias("list").description("list volume back
7312
7597
  });
7313
7598
 
7314
7599
  // src/commands/volume/backup/restore.ts
7315
- import { Command as Command64 } from "commander";
7316
- var restoreCommand2 = new Command64("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
7600
+ import { Command as Command66 } from "commander";
7601
+ var restoreCommand2 = new Command66("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
7317
7602
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7318
7603
  try {
7319
7604
  requireCloud3(client);
@@ -7336,8 +7621,8 @@ var restoreCommand2 = new Command64("restore").description("put a backup back: t
7336
7621
  });
7337
7622
 
7338
7623
  // src/commands/volume/backup/rm.ts
7339
- import { Command as Command65 } from "commander";
7340
- var rmCommand9 = new Command65("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
7624
+ import { Command as Command67 } from "commander";
7625
+ var rmCommand9 = new Command67("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
7341
7626
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7342
7627
  try {
7343
7628
  requireCloud3(client);
@@ -7348,11 +7633,11 @@ var rmCommand9 = new Command65("rm").alias("remove").description("remove a backu
7348
7633
  });
7349
7634
 
7350
7635
  // src/commands/volume/backup/index.ts
7351
- var backupCommand2 = new Command66("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand9).addCommand(restoreCommand2).addCommand(rmCommand9);
7636
+ var backupCommand2 = new Command68("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand10).addCommand(restoreCommand2).addCommand(rmCommand9);
7352
7637
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7353
7638
 
7354
7639
  // src/commands/volume/create.ts
7355
- import { Command as Command67 } from "commander";
7640
+ import { Command as Command69 } from "commander";
7356
7641
  function parseGib2(text2, label = "--size") {
7357
7642
  const mib = parseMib(text2);
7358
7643
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
@@ -7368,7 +7653,7 @@ function sizeProblem(answer) {
7368
7653
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7369
7654
  }
7370
7655
  }
7371
- var createCommand5 = new Command67("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
7656
+ var createCommand5 = new Command69("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
7372
7657
  const ask = interactive();
7373
7658
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7374
7659
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -7401,8 +7686,8 @@ var createCommand5 = new Command67("create").alias("new").description("create a
7401
7686
  });
7402
7687
 
7403
7688
  // src/commands/volume/detach.ts
7404
- import { Command as Command68 } from "commander";
7405
- var detachCommand = new Command68("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
7689
+ import { Command as Command70 } from "commander";
7690
+ var detachCommand = new Command70("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
7406
7691
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
7407
7692
  const client = await clientFor(cmd.optsWithGlobals());
7408
7693
  try {
@@ -7427,8 +7712,8 @@ var detachCommand = new Command68("detach").description("detach a volume from a
7427
7712
  });
7428
7713
 
7429
7714
  // src/commands/volume/grow.ts
7430
- import { Command as Command69 } from "commander";
7431
- var growCommand = new Command69("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
7715
+ import { Command as Command71 } from "commander";
7716
+ var growCommand = new Command71("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
7432
7717
  const sizeGib = parseGib2(size, "size");
7433
7718
  const client = await clientFor(cmd.optsWithGlobals());
7434
7719
  try {
@@ -7441,8 +7726,8 @@ var growCommand = new Command69("grow").alias("resize").description("make a volu
7441
7726
  });
7442
7727
 
7443
7728
  // src/commands/volume/ls.ts
7444
- import { Command as Command70 } from "commander";
7445
- var lsCommand10 = new Command70("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
7729
+ import { Command as Command72 } from "commander";
7730
+ var lsCommand11 = new Command72("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
7446
7731
  const client = await clientFor(cmd.optsWithGlobals());
7447
7732
  try {
7448
7733
  const cloud = client.target.kind === "cloud";
@@ -7473,8 +7758,8 @@ var lsCommand10 = new Command70("ls").alias("list").description("list volumes: s
7473
7758
  });
7474
7759
 
7475
7760
  // src/commands/volume/rm.ts
7476
- import { Command as Command71 } from "commander";
7477
- var rmCommand10 = new Command71("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
7761
+ import { Command as Command73 } from "commander";
7762
+ var rmCommand10 = new Command73("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
7478
7763
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
7479
7764
  info("cancelled");
7480
7765
  process.exitCode = 1;
@@ -7490,18 +7775,18 @@ var rmCommand10 = new Command71("rm").alias("remove").description("delete a volu
7490
7775
  });
7491
7776
 
7492
7777
  // src/commands/volume/index.ts
7493
- var volumeCommand = new Command72("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand5).addCommand(lsCommand10).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
7778
+ var volumeCommand = new Command74("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand5).addCommand(lsCommand11).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
7494
7779
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7495
7780
  volumeCommand.addCommand(backupCommand2);
7496
7781
 
7497
7782
  // src/commands/bucket/index.ts
7498
- import { Command as Command87 } from "commander";
7783
+ import { Command as Command90 } from "commander";
7499
7784
 
7500
7785
  // src/commands/bucket/backup/index.ts
7501
- import { Command as Command77 } from "commander";
7786
+ import { Command as Command79 } from "commander";
7502
7787
 
7503
7788
  // src/commands/bucket/backup/create.ts
7504
- import { Command as Command73 } from "commander";
7789
+ import { Command as Command75 } from "commander";
7505
7790
 
7506
7791
  // src/commands/bucket/shared.ts
7507
7792
  async function bucketClient(cmd) {
@@ -7527,7 +7812,7 @@ function printRows(rows2) {
7527
7812
  }
7528
7813
 
7529
7814
  // src/commands/bucket/backup/create.ts
7530
- var createCommand6 = new Command73("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
7815
+ var createCommand6 = new Command75("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
7531
7816
  const client = await bucketClient(cmd);
7532
7817
  const ls = "kvbox bucket backup ls";
7533
7818
  try {
@@ -7555,8 +7840,8 @@ var createCommand6 = new Command73("create").description("back up your object st
7555
7840
  });
7556
7841
 
7557
7842
  // src/commands/bucket/backup/ls.ts
7558
- import { Command as Command74 } from "commander";
7559
- var lsCommand11 = new Command74("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
7843
+ import { Command as Command76 } from "commander";
7844
+ var lsCommand12 = new Command76("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
7560
7845
  const client = await bucketClient(cmd);
7561
7846
  try {
7562
7847
  const list = await client.storageBackups();
@@ -7588,8 +7873,8 @@ var lsCommand11 = new Command74("ls").alias("list").description("list the backup
7588
7873
  });
7589
7874
 
7590
7875
  // src/commands/bucket/backup/restore.ts
7591
- import { Command as Command75 } from "commander";
7592
- var restoreCommand3 = new Command75("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
7876
+ import { Command as Command77 } from "commander";
7877
+ var restoreCommand3 = new Command77("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
7593
7878
  const client = await bucketClient(cmd);
7594
7879
  try {
7595
7880
  const backup = await client.storageBackup(id);
@@ -7619,8 +7904,8 @@ var restoreCommand3 = new Command75("restore").description("put a backup back: e
7619
7904
  });
7620
7905
 
7621
7906
  // src/commands/bucket/backup/rm.ts
7622
- import { Command as Command76 } from "commander";
7623
- var rmCommand11 = new Command76("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
7907
+ import { Command as Command78 } from "commander";
7908
+ var rmCommand11 = new Command78("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
7624
7909
  const client = await bucketClient(cmd);
7625
7910
  try {
7626
7911
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -7639,11 +7924,11 @@ var rmCommand11 = new Command76("rm").alias("remove").description("remove a back
7639
7924
  });
7640
7925
 
7641
7926
  // src/commands/bucket/backup/index.ts
7642
- var backupCommand3 = new Command77("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand11).addCommand(restoreCommand3).addCommand(rmCommand11);
7927
+ var backupCommand3 = new Command79("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand12).addCommand(restoreCommand3).addCommand(rmCommand11);
7643
7928
 
7644
7929
  // src/commands/bucket/create.ts
7645
- import { Command as Command78 } from "commander";
7646
- var createCommand7 = new Command78("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7930
+ import { Command as Command80 } from "commander";
7931
+ var createCommand7 = new Command80("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7647
7932
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
7648
7933
  const client = await bucketClient(cmd);
7649
7934
  try {
@@ -7663,8 +7948,8 @@ var createCommand7 = new Command78("create").description("make a bucket (the fir
7663
7948
  });
7664
7949
 
7665
7950
  // src/commands/bucket/grow.ts
7666
- import { Command as Command79 } from "commander";
7667
- var growCommand2 = new Command79("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
7951
+ import { Command as Command81 } from "commander";
7952
+ var growCommand2 = new Command81("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
7668
7953
  const sizeGib = parseGib2(size, "size");
7669
7954
  const client = await bucketClient(cmd);
7670
7955
  try {
@@ -7677,8 +7962,8 @@ var growCommand2 = new Command79("grow").description("make your object storage l
7677
7962
  });
7678
7963
 
7679
7964
  // src/commands/bucket/info.ts
7680
- import { Command as Command80 } from "commander";
7681
- var infoCommand = new Command80("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7965
+ import { Command as Command82 } from "commander";
7966
+ var infoCommand = new Command82("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7682
7967
  const client = await bucketClient(cmd);
7683
7968
  try {
7684
7969
  const b = await client.getBucket(name);
@@ -7692,6 +7977,7 @@ var infoCommand = new Command80("info").description("one bucket: its address, wh
7692
7977
  ["name", color.bold(shown)],
7693
7978
  ["endpoint", endpointText(b.endpoint)],
7694
7979
  ["region", `${b.region} ${color.dim("(path-style addressing)")}`],
7980
+ ["public", b.publicUrl === void 0 ? color.dim(`no (kvbox bucket public ${shown} on)`) : `${b.publicUrl}/<key> ${color.dim("(anyone can read every object)")}`],
7695
7981
  ["holds", b.objects === void 0 || b.bytes === void 0 ? color.dim(s.status === "running" ? "not answering yet" : `unknown (the storage is ${s.status})`) : `${b.objects} ${b.objects === 1 ? "object" : "objects"}, ${gb(b.bytes)}`],
7696
7982
  ["keys", b.keys === 0 ? color.dim(`none (kvbox bucket key create ${shown})`) : `${b.keys} ${color.dim(`(kvbox bucket key ls ${shown})`)}`],
7697
7983
  ["storage", `${fullness(s)}, ${s.buckets} ${s.buckets === 1 ? "bucket" : "buckets"}${nearlyFull(s) ? color.yellow(" almost full: kvbox bucket grow <GB>") : ""}`],
@@ -7707,11 +7993,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
7707
7993
  });
7708
7994
 
7709
7995
  // src/commands/bucket/key/index.ts
7710
- import { Command as Command84 } from "commander";
7996
+ import { Command as Command86 } from "commander";
7711
7997
 
7712
7998
  // src/commands/bucket/key/create.ts
7713
- import { Command as Command81 } from "commander";
7714
- var createCommand8 = new Command81("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
7999
+ import { Command as Command83 } from "commander";
8000
+ var createCommand8 = new Command83("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
7715
8001
  const client = await bucketClient(cmd);
7716
8002
  try {
7717
8003
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -7734,8 +8020,8 @@ var createCommand8 = new Command81("create").description("make an access key for
7734
8020
  });
7735
8021
 
7736
8022
  // src/commands/bucket/key/ls.ts
7737
- import { Command as Command82 } from "commander";
7738
- var lsCommand12 = new Command82("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
8023
+ import { Command as Command84 } from "commander";
8024
+ var lsCommand13 = new Command84("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
7739
8025
  const client = await bucketClient(cmd);
7740
8026
  try {
7741
8027
  const keys = await client.listBucketKeys(bucket);
@@ -7754,8 +8040,8 @@ var lsCommand12 = new Command82("ls").alias("list").description("list a bucket's
7754
8040
  });
7755
8041
 
7756
8042
  // src/commands/bucket/key/rm.ts
7757
- import { Command as Command83 } from "commander";
7758
- var rmCommand12 = new Command83("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
8043
+ import { Command as Command85 } from "commander";
8044
+ var rmCommand12 = new Command85("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
7759
8045
  const client = await bucketClient(cmd);
7760
8046
  try {
7761
8047
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -7771,11 +8057,11 @@ var rmCommand12 = new Command83("rm").alias("remove").description("delete an acc
7771
8057
  });
7772
8058
 
7773
8059
  // src/commands/bucket/key/index.ts
7774
- var keyCommand2 = new Command84("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand12).addCommand(rmCommand12);
8060
+ var keyCommand2 = new Command86("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
7775
8061
 
7776
8062
  // src/commands/bucket/ls.ts
7777
- import { Command as Command85 } from "commander";
7778
- var lsCommand13 = new Command85("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8063
+ import { Command as Command87 } from "commander";
8064
+ var lsCommand14 = new Command87("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
7779
8065
  const client = await bucketClient(cmd);
7780
8066
  try {
7781
8067
  const buckets = await client.listBuckets({ all: opts.all });
@@ -7793,6 +8079,7 @@ var lsCommand13 = new Command85("ls").alias("list").description("list buckets, a
7793
8079
  owner: b.owner === me2 ? "private" : b.owner,
7794
8080
  name: b.name,
7795
8081
  keys: b.keys,
8082
+ public: b.publicUrl ?? "-",
7796
8083
  created: age(b.createdAt)
7797
8084
  }))
7798
8085
  );
@@ -7804,9 +8091,38 @@ var lsCommand13 = new Command85("ls").alias("list").description("list buckets, a
7804
8091
  }
7805
8092
  });
7806
8093
 
8094
+ // src/commands/bucket/public.ts
8095
+ import { Command as Command88 } from "commander";
8096
+ var publicCommand = new Command88("public").description("let anyone read a bucket's files at its own HTTPS address (on), or make it private again (off)").argument("<name>", "bucket name").argument("<state>", "on (public) or off (private)").option("--sub <name>", "the address to use, <name>.kvbox.app (default: <bucket>-<account>)").option("--json", "print the bucket as JSON").action(async (name, state, opts, cmd) => {
8097
+ if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
8098
+ const on = state === "on";
8099
+ if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
8100
+ if (opts.sub !== void 0) assertSubdomain(opts.sub.trim().toLowerCase());
8101
+ const client = await bucketClient(cmd);
8102
+ try {
8103
+ const b = await spin(
8104
+ on ? `making bucket ${name} public\u2026` : `making bucket ${name} private\u2026`,
8105
+ client.setBucketPublic(name, { on, ...opts.sub !== void 0 ? { sub: opts.sub } : {} })
8106
+ );
8107
+ if (opts.json) {
8108
+ json(b);
8109
+ return;
8110
+ }
8111
+ const shown = shownName(b, client);
8112
+ if (b.publicUrl === void 0) {
8113
+ info(`${color.green("\u2713")} bucket ${color.bold(shown)} is private: its files open only with a key or a signed link`);
8114
+ return;
8115
+ }
8116
+ info(`${color.green("\u2713")} anyone can now read the files of bucket ${color.bold(shown)} at ${color.bold(`${b.publicUrl}/<key>`)}`);
8117
+ info(color.dim(` e.g. ${b.publicUrl}/images/logo.png for the object images/logo.png. Files are never listed. Undo with: kvbox bucket public ${shown} off`));
8118
+ } finally {
8119
+ await client.close();
8120
+ }
8121
+ });
8122
+
7807
8123
  // src/commands/bucket/rm.ts
7808
- import { Command as Command86 } from "commander";
7809
- var rmCommand13 = new Command86("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8124
+ import { Command as Command89 } from "commander";
8125
+ var rmCommand13 = new Command89("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
7810
8126
  const client = await bucketClient(cmd);
7811
8127
  try {
7812
8128
  const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
@@ -7825,7 +8141,7 @@ var rmCommand13 = new Command86("rm").alias("remove").description("delete an emp
7825
8141
  });
7826
8142
 
7827
8143
  // src/commands/bucket/index.ts
7828
- var bucketCommand = new Command87("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand13).addCommand(infoCommand).addCommand(growCommand2).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
8144
+ var bucketCommand = new Command90("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand14).addCommand(infoCommand).addCommand(growCommand2).addCommand(publicCommand).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
7829
8145
  var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
7830
8146
  for (const cmd of bucketCommand.commands) {
7831
8147
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg);
@@ -7833,10 +8149,10 @@ for (const cmd of bucketCommand.commands) {
7833
8149
  }
7834
8150
 
7835
8151
  // src/commands/cron/index.ts
7836
- import { Command as Command100 } from "commander";
8152
+ import { Command as Command103 } from "commander";
7837
8153
 
7838
8154
  // src/commands/cron/create.ts
7839
- import { Command as Command88 } from "commander";
8155
+ import { Command as Command91 } from "commander";
7840
8156
 
7841
8157
  // src/commands/cron/shared.ts
7842
8158
  async function cronClient(cmd) {
@@ -7897,7 +8213,7 @@ function printRows2(rows2) {
7897
8213
  var noTriggers = (service) => info(`cron service ${service} has no triggers yet; add one with: kvbox cron trigger add ${service} <box> "0 6 * * *" --port 3000 (or --run "<command>")`);
7898
8214
 
7899
8215
  // src/commands/cron/create.ts
7900
- var createCommand9 = new Command88("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8216
+ var createCommand9 = new Command91("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7901
8217
  const client = await cronClient(cmd);
7902
8218
  try {
7903
8219
  const service = await client.createCronService(name);
@@ -7914,8 +8230,8 @@ var createCommand9 = new Command88("create").description("make a cron service: a
7914
8230
  });
7915
8231
 
7916
8232
  // src/commands/cron/info.ts
7917
- import { Command as Command89 } from "commander";
7918
- var infoCommand2 = new Command89("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8233
+ import { Command as Command92 } from "commander";
8234
+ var infoCommand2 = new Command92("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
7919
8235
  const client = await cronClient(cmd);
7920
8236
  try {
7921
8237
  const service = await client.getCronService(name);
@@ -7939,8 +8255,8 @@ var infoCommand2 = new Command89("info").alias("get").description("show a cron s
7939
8255
  });
7940
8256
 
7941
8257
  // src/commands/cron/ls.ts
7942
- import { Command as Command90 } from "commander";
7943
- var lsCommand14 = new Command90("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8258
+ import { Command as Command93 } from "commander";
8259
+ var lsCommand15 = new Command93("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
7944
8260
  const client = await cronClient(cmd);
7945
8261
  try {
7946
8262
  const services = await client.listCronServices({ all: opts.all });
@@ -7960,8 +8276,8 @@ var lsCommand14 = new Command90("ls").alias("list").description("list cron servi
7960
8276
  });
7961
8277
 
7962
8278
  // src/commands/cron/rm.ts
7963
- import { Command as Command91 } from "commander";
7964
- var rmCommand14 = new Command91("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8279
+ import { Command as Command94 } from "commander";
8280
+ var rmCommand14 = new Command94("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
7965
8281
  const client = await cronClient(cmd);
7966
8282
  try {
7967
8283
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -7977,10 +8293,10 @@ var rmCommand14 = new Command91("rm").alias("remove").description("delete a cron
7977
8293
  });
7978
8294
 
7979
8295
  // src/commands/cron/trigger/index.ts
7980
- import { Command as Command99 } from "commander";
8296
+ import { Command as Command102 } from "commander";
7981
8297
 
7982
8298
  // src/commands/cron/trigger/add.ts
7983
- import { Command as Command92 } from "commander";
8299
+ import { Command as Command95 } from "commander";
7984
8300
  function portOf(value) {
7985
8301
  const n = Number(value);
7986
8302
  if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8000,7 +8316,7 @@ function timeoutOf(value) {
8000
8316
  if (sec > MAX_CRON_COMMAND_TIMEOUT_SEC) throw new KvboxError(`--timeout ${value}: a command may run for ${MAX_CRON_COMMAND_TIMEOUT_SEC / 60} minutes at most`);
8001
8317
  return sec;
8002
8318
  }
8003
- var addCommand3 = new Command92("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
8319
+ var addCommand3 = new Command95("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
8004
8320
  let action;
8005
8321
  if (opts.run !== void 0) {
8006
8322
  if (opts.port !== void 0 || opts.path !== void 0 || opts.method !== void 0) throw new KvboxError("a trigger runs a command or calls a port: use --run, or --port with --path and --method, not both");
@@ -8027,8 +8343,8 @@ var addCommand3 = new Command92("add").description("add a trigger: on a schedule
8027
8343
  });
8028
8344
 
8029
8345
  // src/commands/cron/trigger/ls.ts
8030
- import { Command as Command93 } from "commander";
8031
- var lsCommand15 = new Command93("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
8346
+ import { Command as Command96 } from "commander";
8347
+ var lsCommand16 = new Command96("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
8032
8348
  const client = await cronClient(cmd);
8033
8349
  try {
8034
8350
  const triggers = await client.listCronTriggers(service);
@@ -8044,8 +8360,8 @@ var lsCommand15 = new Command93("ls").alias("list").description("list a cron ser
8044
8360
  });
8045
8361
 
8046
8362
  // src/commands/cron/trigger/pause.ts
8047
- import { Command as Command94 } from "commander";
8048
- var pauseCommand2 = new Command94("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8363
+ import { Command as Command97 } from "commander";
8364
+ var pauseCommand2 = new Command97("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8049
8365
  const client = await cronClient(cmd);
8050
8366
  try {
8051
8367
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8060,8 +8376,8 @@ var pauseCommand2 = new Command94("pause").description("stop a trigger from firi
8060
8376
  });
8061
8377
 
8062
8378
  // src/commands/cron/trigger/resume.ts
8063
- import { Command as Command95 } from "commander";
8064
- var resumeCommand2 = new Command95("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8379
+ import { Command as Command98 } from "commander";
8380
+ var resumeCommand2 = new Command98("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8065
8381
  const client = await cronClient(cmd);
8066
8382
  try {
8067
8383
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8076,8 +8392,8 @@ var resumeCommand2 = new Command95("resume").description("let a paused trigger f
8076
8392
  });
8077
8393
 
8078
8394
  // src/commands/cron/trigger/rm.ts
8079
- import { Command as Command96 } from "commander";
8080
- var rmCommand15 = new Command96("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
8395
+ import { Command as Command99 } from "commander";
8396
+ var rmCommand15 = new Command99("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
8081
8397
  const client = await cronClient(cmd);
8082
8398
  try {
8083
8399
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8093,8 +8409,8 @@ var rmCommand15 = new Command96("rm").alias("remove").description("delete a trig
8093
8409
  });
8094
8410
 
8095
8411
  // src/commands/cron/trigger/run.ts
8096
- import { Command as Command97 } from "commander";
8097
- var runCommand = new Command97("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8412
+ import { Command as Command100 } from "commander";
8413
+ var runCommand = new Command100("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8098
8414
  const client = await cronClient(cmd);
8099
8415
  try {
8100
8416
  const trigger = await client.runCronTrigger(service, id);
@@ -8110,13 +8426,13 @@ var runCommand = new Command97("run").description("fire a trigger now, once, bes
8110
8426
  });
8111
8427
 
8112
8428
  // src/commands/cron/trigger/runs.ts
8113
- import { Command as Command98 } from "commander";
8429
+ import { Command as Command101 } from "commander";
8114
8430
  function limitOf(value) {
8115
8431
  const n = Number(value);
8116
8432
  if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8117
8433
  return n;
8118
8434
  }
8119
- var runsCommand = new Command98("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8435
+ var runsCommand = new Command101("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
8120
8436
  const limit = limitOf(opts.limit);
8121
8437
  const client = await cronClient(cmd);
8122
8438
  try {
@@ -8146,10 +8462,10 @@ var runsCommand = new Command98("runs").aliases(["logs"]).description("show how
8146
8462
  });
8147
8463
 
8148
8464
  // src/commands/cron/trigger/index.ts
8149
- var triggerCommand = new Command99("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand15).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
8465
+ var triggerCommand = new Command102("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand16).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
8150
8466
 
8151
8467
  // src/commands/cron/index.ts
8152
- var cronCommand = new Command100("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand14).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
8468
+ var cronCommand = new Command103("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand15).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
8153
8469
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8154
8470
  for (const cmd of cronCommand.commands) {
8155
8471
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
@@ -8157,13 +8473,13 @@ for (const cmd of cronCommand.commands) {
8157
8473
  }
8158
8474
 
8159
8475
  // src/commands/managed/kind.ts
8160
- import { Command as Command119 } from "commander";
8476
+ import { Command as Command122 } from "commander";
8161
8477
 
8162
8478
  // src/commands/managed/backup/index.ts
8163
- import { Command as Command107 } from "commander";
8479
+ import { Command as Command110 } from "commander";
8164
8480
 
8165
8481
  // src/commands/managed/backup/create.ts
8166
- import { Command as Command102 } from "commander";
8482
+ import { Command as Command105 } from "commander";
8167
8483
 
8168
8484
  // src/commands/managed/shared.ts
8169
8485
  import "commander";
@@ -8261,7 +8577,7 @@ function parseStorage(text2, flag) {
8261
8577
  }
8262
8578
 
8263
8579
  // src/commands/managed/backup/create.ts
8264
- var createCommand10 = (spec) => new Command102("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
8580
+ var createCommand10 = (spec) => new Command105("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
8265
8581
  const client = await managedClient(cmd);
8266
8582
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8267
8583
  try {
@@ -8288,8 +8604,8 @@ var createCommand10 = (spec) => new Command102("create").description("back up a
8288
8604
  });
8289
8605
 
8290
8606
  // src/commands/managed/backup/ls.ts
8291
- import { Command as Command103 } from "commander";
8292
- var lsCommand16 = (spec) => {
8607
+ import { Command as Command106 } from "commander";
8608
+ var lsCommand17 = (spec) => {
8293
8609
  const removedOnes = async (err, name, client) => {
8294
8610
  if (!(err instanceof CallError && err.status === 404)) throw err;
8295
8611
  const gone = (await client.listManagedBackups(spec.kind)).filter((b) => b.name === name || `${b.owner}/${b.name}` === name);
@@ -8297,7 +8613,7 @@ var lsCommand16 = (spec) => {
8297
8613
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8298
8614
  return own.length > 0 ? own : gone;
8299
8615
  };
8300
- return new Command103("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8616
+ return new Command106("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8301
8617
  const client = await managedClient(cmd);
8302
8618
  try {
8303
8619
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8340,8 +8656,8 @@ var lsCommand16 = (spec) => {
8340
8656
  };
8341
8657
 
8342
8658
  // src/commands/managed/backup/restore.ts
8343
- import { Command as Command104 } from "commander";
8344
- var restoreCommand4 = (spec) => new Command104("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
8659
+ import { Command as Command107 } from "commander";
8660
+ var restoreCommand4 = (spec) => new Command107("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
8345
8661
  const client = await managedClient(cmd);
8346
8662
  try {
8347
8663
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -8363,8 +8679,8 @@ var restoreCommand4 = (spec) => new Command104("restore").description("put a bac
8363
8679
  });
8364
8680
 
8365
8681
  // src/commands/managed/backup/rm.ts
8366
- import { Command as Command105 } from "commander";
8367
- var rmCommand16 = (spec) => new Command105("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
8682
+ import { Command as Command108 } from "commander";
8683
+ var rmCommand16 = (spec) => new Command108("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
8368
8684
  const client = await managedClient(cmd);
8369
8685
  try {
8370
8686
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -8374,8 +8690,8 @@ var rmCommand16 = (spec) => new Command105("rm").alias("remove").description("re
8374
8690
  });
8375
8691
 
8376
8692
  // src/commands/managed/backup/schedule.ts
8377
- import { Command as Command106 } from "commander";
8378
- var scheduleCommand = (spec) => new Command106("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name").option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own again, at the hour it had").option("--json", "print the schedule as JSON").action(async (name, opts, cmd) => {
8693
+ import { Command as Command109 } from "commander";
8694
+ var scheduleCommand = (spec) => new Command109("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name").option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own again, at the hour it had").option("--json", "print the schedule as JSON").action(async (name, opts, cmd) => {
8379
8695
  if (opts.off && (opts.on || opts.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
8380
8696
  const hour = opts.at === void 0 ? void 0 : parseHour(opts.at);
8381
8697
  const client = await managedClient(cmd);
@@ -8405,18 +8721,18 @@ function parseHour(text2) {
8405
8721
 
8406
8722
  // src/commands/managed/backup/index.ts
8407
8723
  var backupCommand4 = (spec) => {
8408
- const command = new Command107("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
8409
- for (const make of [createCommand10, lsCommand16, restoreCommand4, rmCommand16, scheduleCommand]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8724
+ const command = new Command110("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
8725
+ for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8410
8726
  return command;
8411
8727
  };
8412
8728
 
8413
8729
  // src/commands/managed/create.ts
8414
- import { Command as Command108 } from "commander";
8730
+ import { Command as Command111 } from "commander";
8415
8731
  import { setTimeout as sleep5 } from "timers/promises";
8416
8732
  var READY_WAIT_MS = 9e4;
8417
8733
  var READY_STEP_MS = 2e3;
8418
8734
  var createCommand11 = (spec) => {
8419
- const command = new Command108("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
8735
+ const command = new Command111("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
8420
8736
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
8421
8737
  return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so the box can be linked to it").option("--from-backup <id>", `start it on this backup's data, a removed database's too (kvbox ${spec.command} backup ls)`).option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
8422
8738
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -8465,8 +8781,8 @@ var createCommand11 = (spec) => {
8465
8781
  };
8466
8782
 
8467
8783
  // src/commands/managed/grow.ts
8468
- import { Command as Command109 } from "commander";
8469
- var growCommand3 = (spec) => new Command109("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
8784
+ import { Command as Command112 } from "commander";
8785
+ var growCommand3 = (spec) => new Command112("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
8470
8786
  const storageGib = parseStorage(size, "size");
8471
8787
  const client = await managedClient(cmd);
8472
8788
  try {
@@ -8479,8 +8795,8 @@ var growCommand3 = (spec) => new Command109("grow").description("give a database
8479
8795
  });
8480
8796
 
8481
8797
  // src/commands/managed/info.ts
8482
- import { Command as Command110 } from "commander";
8483
- var infoCommand3 = (spec) => new Command110("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8798
+ import { Command as Command113 } from "commander";
8799
+ var infoCommand3 = (spec) => new Command113("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8484
8800
  const client = await managedClient(cmd);
8485
8801
  try {
8486
8802
  const m = await client.getManaged(spec.kind, name);
@@ -8492,8 +8808,8 @@ var infoCommand3 = (spec) => new Command110("info").alias("get").description("sh
8492
8808
  });
8493
8809
 
8494
8810
  // src/commands/managed/link.ts
8495
- import { Command as Command111 } from "commander";
8496
- var linkCommand2 = (spec) => new Command111("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
8811
+ import { Command as Command114 } from "commander";
8812
+ var linkCommand2 = (spec) => new Command114("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
8497
8813
  const client = await managedClient(cmd);
8498
8814
  try {
8499
8815
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -8509,7 +8825,7 @@ var linkCommand2 = (spec) => new Command111("link").description("let a box reach
8509
8825
  });
8510
8826
 
8511
8827
  // src/commands/managed/ls.ts
8512
- import { Command as Command112 } from "commander";
8828
+ import { Command as Command115 } from "commander";
8513
8829
  function listRows(items, user, kindColumn) {
8514
8830
  return items.map((m) => ({
8515
8831
  owner: m.owner === user ? "private" : m.owner,
@@ -8523,7 +8839,7 @@ function listRows(items, user, kindColumn) {
8523
8839
  created: age(m.createdAt)
8524
8840
  }));
8525
8841
  }
8526
- var lsCommand17 = (spec) => new Command112("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8842
+ var lsCommand18 = (spec) => new Command115("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
8527
8843
  const client = await managedClient(cmd);
8528
8844
  try {
8529
8845
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -8543,8 +8859,8 @@ var lsCommand17 = (spec) => new Command112("ls").alias("list").description(spec
8543
8859
  });
8544
8860
 
8545
8861
  // src/commands/managed/password.ts
8546
- import { Command as Command113 } from "commander";
8547
- var passwordCommand = (spec) => new Command113("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8862
+ import { Command as Command116 } from "commander";
8863
+ var passwordCommand = (spec) => new Command116("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8548
8864
  const client = await managedClient(cmd);
8549
8865
  try {
8550
8866
  const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
@@ -8560,8 +8876,8 @@ var passwordCommand = (spec) => new Command113("password").description("show a d
8560
8876
  });
8561
8877
 
8562
8878
  // src/commands/managed/public.ts
8563
- import { Command as Command114 } from "commander";
8564
- var publicCommand = (spec) => new Command114("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
8879
+ import { Command as Command117 } from "commander";
8880
+ var publicCommand2 = (spec) => new Command117("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
8565
8881
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
8566
8882
  const client = await managedClient(cmd);
8567
8883
  try {
@@ -8582,8 +8898,8 @@ var publicCommand = (spec) => new Command114("public").description("open a datab
8582
8898
  });
8583
8899
 
8584
8900
  // src/commands/managed/rm.ts
8585
- import { Command as Command115 } from "commander";
8586
- var rmCommand17 = (spec) => new Command115("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8901
+ import { Command as Command118 } from "commander";
8902
+ var rmCommand17 = (spec) => new Command118("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
8587
8903
  const client = await managedClient(cmd);
8588
8904
  try {
8589
8905
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -8599,8 +8915,8 @@ var rmCommand17 = (spec) => new Command115("rm").alias("remove").description("de
8599
8915
  });
8600
8916
 
8601
8917
  // src/commands/managed/start.ts
8602
- import { Command as Command116 } from "commander";
8603
- var startCommand2 = (spec) => new Command116("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8918
+ import { Command as Command119 } from "commander";
8919
+ var startCommand2 = (spec) => new Command119("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8604
8920
  const client = await managedClient(cmd);
8605
8921
  try {
8606
8922
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -8612,8 +8928,8 @@ var startCommand2 = (spec) => new Command116("start").description("run a stopped
8612
8928
  });
8613
8929
 
8614
8930
  // src/commands/managed/stop.ts
8615
- import { Command as Command117 } from "commander";
8616
- var stopCommand2 = (spec) => new Command117("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8931
+ import { Command as Command120 } from "commander";
8932
+ var stopCommand2 = (spec) => new Command120("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
8617
8933
  const client = await managedClient(cmd);
8618
8934
  try {
8619
8935
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -8625,8 +8941,8 @@ var stopCommand2 = (spec) => new Command117("stop").description("shut a database
8625
8941
  });
8626
8942
 
8627
8943
  // src/commands/managed/unlink.ts
8628
- import { Command as Command118 } from "commander";
8629
- var unlinkCommand2 = (spec) => new Command118("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
8944
+ import { Command as Command121 } from "commander";
8945
+ var unlinkCommand2 = (spec) => new Command121("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
8630
8946
  const client = await managedClient(cmd);
8631
8947
  try {
8632
8948
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -8639,8 +8955,8 @@ var unlinkCommand2 = (spec) => new Command118("unlink").description("stop a box
8639
8955
 
8640
8956
  // src/commands/managed/kind.ts
8641
8957
  function kindCommand(spec, description) {
8642
- const command = new Command119(spec.command).aliases(spec.aliases).description(description);
8643
- for (const make of [createCommand11, lsCommand17, infoCommand3, passwordCommand, publicCommand, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
8958
+ const command = new Command122(spec.command).aliases(spec.aliases).description(description);
8959
+ for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
8644
8960
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8645
8961
  }
8646
8962
  command.addCommand(backupCommand4(spec));
@@ -8654,14 +8970,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
8654
8970
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
8655
8971
 
8656
8972
  // src/commands/managed/index.ts
8657
- import { Command as Command120 } from "commander";
8658
- var managedCommand = new Command120("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand17().option("--org <slug>", "act in this org (- for your personal databases)"));
8973
+ import { Command as Command123 } from "commander";
8974
+ var managedCommand = new Command123("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand18().option("--org <slug>", "act in this org (- for your personal databases)"));
8659
8975
 
8660
8976
  // src/commands/env/index.ts
8661
- import { Command as Command124 } from "commander";
8977
+ import { Command as Command127 } from "commander";
8662
8978
 
8663
8979
  // src/commands/env/ls.ts
8664
- import { Command as Command121 } from "commander";
8980
+ import { Command as Command124 } from "commander";
8665
8981
 
8666
8982
  // src/commands/env/shared.ts
8667
8983
  function requireCloud4(client) {
@@ -8688,7 +9004,7 @@ function firstBootHint(box2, name) {
8688
9004
  }
8689
9005
 
8690
9006
  // src/commands/env/ls.ts
8691
- var lsCommand18 = new Command121("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
9007
+ var lsCommand19 = new Command124("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
8692
9008
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8693
9009
  try {
8694
9010
  if (opts.box !== void 0) {
@@ -8727,8 +9043,8 @@ var lsCommand18 = new Command121("ls").alias("list").description("list the varia
8727
9043
  });
8728
9044
 
8729
9045
  // src/commands/env/rm.ts
8730
- import { Command as Command122 } from "commander";
8731
- var rmCommand18 = new Command122("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
9046
+ import { Command as Command125 } from "commander";
9047
+ var rmCommand18 = new Command125("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
8732
9048
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8733
9049
  try {
8734
9050
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -8765,8 +9081,8 @@ var rmCommand18 = new Command122("rm").alias("remove").description("remove varia
8765
9081
  });
8766
9082
 
8767
9083
  // src/commands/env/set.ts
8768
- import { Command as Command123 } from "commander";
8769
- var setCommand2 = new Command123("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
9084
+ import { Command as Command126 } from "commander";
9085
+ var setCommand2 = new Command126("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
8770
9086
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8771
9087
  try {
8772
9088
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -8803,14 +9119,14 @@ var setCommand2 = new Command123("set").description("add or change a variable; b
8803
9119
  });
8804
9120
 
8805
9121
  // src/commands/env/index.ts
8806
- var envCommand = new Command124("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand18, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
9122
+ var envCommand = new Command127("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
8807
9123
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
8808
9124
 
8809
9125
  // src/commands/domain/index.ts
8810
- import { Command as Command128 } from "commander";
9126
+ import { Command as Command131 } from "commander";
8811
9127
 
8812
9128
  // src/commands/domain/add.ts
8813
- import { Command as Command125 } from "commander";
9129
+ import { Command as Command128 } from "commander";
8814
9130
 
8815
9131
  // src/commands/domain/shared.ts
8816
9132
  function requireCloud5(client) {
@@ -8830,7 +9146,7 @@ function hostIn(name, zone) {
8830
9146
  }
8831
9147
 
8832
9148
  // src/commands/domain/add.ts
8833
- var addCommand4 = new Command125("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
9149
+ var addCommand4 = new Command128("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
8834
9150
  const domain = assertDomain(domainArg.trim().toLowerCase());
8835
9151
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
8836
9152
  const client = await clientFor(cmd.optsWithGlobals());
@@ -8866,8 +9182,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
8866
9182
  });
8867
9183
 
8868
9184
  // src/commands/domain/ls.ts
8869
- import { Command as Command126 } from "commander";
8870
- var lsCommand19 = new Command126("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
9185
+ import { Command as Command129 } from "commander";
9186
+ var lsCommand20 = new Command129("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
8871
9187
  const client = await clientFor(cmd.optsWithGlobals());
8872
9188
  try {
8873
9189
  requireCloud5(client);
@@ -8896,8 +9212,8 @@ var lsCommand19 = new Command126("ls").alias("list").description("list your cust
8896
9212
  });
8897
9213
 
8898
9214
  // src/commands/domain/rm.ts
8899
- import { Command as Command127 } from "commander";
8900
- var rmCommand19 = new Command127("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
9215
+ import { Command as Command130 } from "commander";
9216
+ var rmCommand19 = new Command130("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
8901
9217
  const domain = domainArg.trim().toLowerCase();
8902
9218
  const client = await clientFor(cmd.optsWithGlobals());
8903
9219
  try {
@@ -8918,7 +9234,7 @@ var rmCommand19 = new Command127("rm").alias("remove").description("stop serving
8918
9234
  });
8919
9235
 
8920
9236
  // src/commands/domain/index.ts
8921
- var domainCommand = new Command128("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand19).addCommand(rmCommand19);
9237
+ var domainCommand = new Command131("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
8922
9238
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
8923
9239
 
8924
9240
  // src/commands/update.ts
@@ -8926,7 +9242,7 @@ import { spawn as spawn8 } from "child_process";
8926
9242
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
8927
9243
  import { tmpdir } from "os";
8928
9244
  import { join as join9 } from "path";
8929
- import { Command as Command129 } from "commander";
9245
+ import { Command as Command132 } from "commander";
8930
9246
 
8931
9247
  // src/update.ts
8932
9248
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9045,7 +9361,7 @@ function run2(cmd, args) {
9045
9361
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9046
9362
  });
9047
9363
  }
9048
- var selfUpdateCommand = new Command129("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9364
+ var selfUpdateCommand = new Command132("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9049
9365
  suppressUpdateNotice();
9050
9366
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9051
9367
  let code;
@@ -9116,6 +9432,7 @@ var HELP_GROUPS = [
9116
9432
  ["managed", "every managed database, whatever its kind"],
9117
9433
  ["cron", "call a box on a schedule, waking it first if it sleeps"],
9118
9434
  ["env", "environment variables and secrets every box of yours gets"],
9435
+ ["integration", "accounts (GitHub) your boxes use once you turn them on"],
9119
9436
  ["domain", "serve a box at a domain of your own"]
9120
9437
  ]
9121
9438
  },
@@ -9173,7 +9490,7 @@ function installRootHelp(program) {
9173
9490
 
9174
9491
  // src/program.ts
9175
9492
  function buildProgram() {
9176
- const program = new Command130("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login and KVBOX_TOKEN").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
9493
+ const program = new Command133("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login and KVBOX_TOKEN").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
9177
9494
  program.addCommand(vmCommand);
9178
9495
  program.addCommand(snapshotsCommand);
9179
9496
  program.addCommand(volumeCommand);
@@ -9188,6 +9505,7 @@ function buildProgram() {
9188
9505
  program.addCommand(logoutCommand);
9189
9506
  program.addCommand(whoamiCommand);
9190
9507
  program.addCommand(keyCommand);
9508
+ program.addCommand(integrationCommand);
9191
9509
  program.addCommand(orgCommand);
9192
9510
  program.addCommand(usageCommand2);
9193
9511
  program.addCommand(creditCommand);