@kvbox/cli 0.6.12 → 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 Command131 } 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.12" : 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,1073 +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(),
519
+ var BackupSchema = z2.object({
520
+ id: z2.string(),
521
+ owner: z2.string(),
522
+ box: z2.string(),
441
523
  /**
442
524
  * The box it was taken of has been removed (#141): a box called `box` now is another box, which this backup
443
525
  * never restores into; `kvbox new <name> --from-backup <id>` makes a box from it. Absent from a control plane
444
526
  * before #141.
445
527
  */
446
- boxRemoved: z.boolean().optional(),
447
- status: z.enum(BACKUP_STATUSES),
528
+ boxRemoved: z2.boolean().optional(),
529
+ status: z2.enum(BACKUP_STATUSES),
448
530
  /** Why it failed; null otherwise. */
449
- error: z.string().nullable(),
531
+ error: z2.string().nullable(),
450
532
  /** The image version the disk stacks on (a restore needs it on the host), and the image (absent: base). */
451
- base: z.string().nullable(),
452
- image: z.string().optional(),
453
- vcpu: z.number().int().nullable(),
454
- 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(),
455
537
  /** The disk's size. */
456
- diskBytes: z.number().int().nullable(),
538
+ diskBytes: z2.number().int().nullable(),
457
539
  /** What it holds: the slots that are not all zeros. */
458
- dataBytes: z.number().int().nullable(),
540
+ dataBytes: z2.number().int().nullable(),
459
541
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
460
- uploadedBytes: z.number().int().nullable(),
461
- createdBy: z.string().nullable(),
462
- createdAt: z.string(),
463
- finishedAt: z.string().nullable()
464
- });
465
- var BackupLimitSchema = z.object({
466
- perDay: z.number().int(),
467
- used: z.number().int(),
468
- nextAt: z.string().nullable()
469
- });
470
- var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner: z.string(), name: z.string() });
471
- var HostBackupRequest = z.object({ id: z.string(), key: z.string() });
472
- var HostBackupManifestSchema = z.object({
473
- id: z.string(),
474
- sizeBytes: z.number().int(),
475
- chunks: z.array(z.string().nullable()),
476
- env: z.string().nullable(),
477
- base: z.string(),
478
- image: z.string().optional(),
479
- vcpu: z.number().int(),
480
- memMib: z.number().int()
481
- });
482
- var HostUploadRequest = z.object({ key: z.string(), urls: z.record(z.string(), z.string()), pin: z.string().optional() });
483
- var HostUploadResultSchema = z.object({ chunks: z.number().int(), bytes: z.number().int(), sizes: z.record(z.string(), z.number().int()) });
484
- 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({
485
569
  /** The backup's id: its variables were sealed under it. */
486
- id: z.string(),
487
- key: z.string(),
488
- sizeBytes: z.number().int().positive(),
489
- base: z.string(),
490
- image: z.string().optional(),
491
- env: z.string().nullable(),
492
- 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() })),
493
577
  /** The certificate fingerprint of the store the URLs point at (see HostUploadRequest). */
494
- pin: z.string().optional()
578
+ pin: z2.string().optional()
495
579
  });
496
- var VolumeBackupSchema = z.object({
497
- id: z.string(),
498
- owner: z.string(),
499
- volume: z.string(),
500
- 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),
501
585
  /** Why it failed; null otherwise. */
502
- error: z.string().nullable(),
586
+ error: z2.string().nullable(),
503
587
  /** The volume's size when taken. */
504
- diskBytes: z.number().int().nullable(),
588
+ diskBytes: z2.number().int().nullable(),
505
589
  /** What it holds: the slots that are not all zeros. */
506
- dataBytes: z.number().int().nullable(),
590
+ dataBytes: z2.number().int().nullable(),
507
591
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
508
- uploadedBytes: z.number().int().nullable(),
509
- createdBy: z.string().nullable(),
510
- createdAt: z.string(),
511
- finishedAt: z.string().nullable()
592
+ uploadedBytes: z2.number().int().nullable(),
593
+ createdBy: z2.string().nullable(),
594
+ createdAt: z2.string(),
595
+ finishedAt: z2.string().nullable()
512
596
  });
513
- var BackupScheduleSchema = z.object({
514
- enabled: z.boolean(),
597
+ var BackupScheduleSchema = z2.object({
598
+ enabled: z2.boolean(),
515
599
  /** 0-23, UTC. Kept while it is off, so turning it on again keeps the hour. */
516
- hour: z.number().int().min(0).max(23),
517
- nextAt: z.string().nullable(),
518
- lastAt: z.string().nullable(),
519
- lastBackup: z.string().nullable(),
520
- lastError: z.string().nullable()
521
- });
522
- var SetBackupScheduleRequest = z.object({ enabled: z.boolean().optional(), hour: z.number().int().min(0).max(23).optional() });
523
- var HostVolumeBackupManifestSchema = z.object({ id: z.string(), sizeBytes: z.number().int(), chunks: z.array(z.string().nullable()) });
524
- var HostVolumeRestoreRequest = z.object({
525
- id: z.string(),
526
- key: z.string(),
527
- sizeBytes: z.number().int().positive(),
528
- chunks: z.array(z.object({ index: z.number().int().nonnegative(), hash: z.string(), url: z.string() })),
529
- pin: z.string().optional()
530
- });
531
- var BackupStoreSetupRequest = z.object({ path: z.string().min(1), force: z.boolean().optional(), newStore: z.boolean().optional() });
532
- var BackupStoreStatusSchema = z.object({
533
- path: z.string(),
534
- bucket: z.string(),
535
- 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(),
536
620
  /** Whether Garage is running and can store. */
537
- running: z.boolean(),
621
+ running: z2.boolean(),
538
622
  /** The filesystem the path is on. */
539
- totalBytes: z.number().int(),
540
- freeBytes: z.number().int(),
623
+ totalBytes: z2.number().int(),
624
+ freeBytes: z2.number().int(),
541
625
  /** What the bucket holds, when Garage answers. */
542
- objects: z.number().int().optional(),
543
- storedBytes: z.number().int().optional(),
626
+ objects: z2.number().int().optional(),
627
+ storedBytes: z2.number().int().optional(),
544
628
  /** Whether the control plane took the store's registration at setup. */
545
- registered: z.boolean().optional()
629
+ registered: z2.boolean().optional()
546
630
  });
547
- var BackupStoreRegistration = z.object({ bucket: z.string().min(1), region: z.string().min(1), accessKey: z.string().min(1), secretKey: z.string().min(1) });
548
- var CloudBackupStoreSchema = z.object({
549
- 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(),
550
634
  /** Null while no host serves it (its host left; it comes back when a host registers its key and secret again). */
551
- host: z.string().nullable(),
552
- endpoint: z.string().nullable(),
553
- bucket: z.string(),
554
- accessKey: z.string(),
555
- 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(),
556
640
  /** The host answered a poll in the last minute and its Garage runs. */
557
- live: z.boolean(),
641
+ live: z2.boolean(),
558
642
  /** From the host's last poll; null when it never reported a store. */
559
- totalBytes: z.number().int().nullable(),
560
- freeBytes: z.number().int().nullable(),
643
+ totalBytes: z2.number().int().nullable(),
644
+ freeBytes: z2.number().int().nullable(),
561
645
  /** Ready backups kept here, and what their chunks take (encrypted, compressed). */
562
- backups: z.number().int(),
563
- storedBytes: z.number().int(),
646
+ backups: z2.number().int(),
647
+ storedBytes: z2.number().int(),
564
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). */
565
- boxes: z.number().int(),
566
- volumes: z.number().int(),
567
- databases: z.number().int(),
649
+ boxes: z2.number().int(),
650
+ volumes: z2.number().int(),
651
+ databases: z2.number().int(),
568
652
  /** When the newest ready backup kept here finished; null when it keeps none. */
569
- lastBackupAt: z.string().nullable()
653
+ lastBackupAt: z2.string().nullable()
570
654
  });
571
- var StoredItemSchema = z.object({
572
- kind: z.enum(BACKUP_KINDS),
573
- owner: z.string(),
655
+ var StoredItemSchema = z2.object({
656
+ kind: z2.enum(BACKUP_KINDS),
657
+ owner: z2.string(),
574
658
  /** The box's or volume's name; a managed database's (#186) for its hidden volume. */
575
- name: z.string(),
659
+ name: z2.string(),
576
660
  /** The managed database's kind (`postgres`) when the volume is one's (#186); null otherwise. */
577
- managed: z.string().nullable(),
661
+ managed: z2.string().nullable(),
578
662
  /** The host the box (or volume) is on now; null when it is gone (its backups stay). */
579
- host: z.string().nullable(),
663
+ host: z2.string().nullable(),
580
664
  /** It is on the store's own host: losing that host loses it and its backups together. */
581
- sameHost: z.boolean(),
665
+ sameHost: z2.boolean(),
582
666
  /** Ready backups kept here, and what they added to the store together (encrypted, compressed). */
583
- backups: z.number().int(),
584
- uploadedBytes: z.number().int(),
667
+ backups: z2.number().int(),
668
+ uploadedBytes: z2.number().int(),
585
669
  /** The newest backup sent here, whatever became of it. */
586
- 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() })
587
671
  });
588
- var FailedBackupSchema = z.object({
589
- id: z.string(),
590
- owner: z.string(),
672
+ var FailedBackupSchema = z2.object({
673
+ id: z2.string(),
674
+ owner: z2.string(),
591
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. */
592
- kind: z.enum(BACKUP_KINDS),
593
- name: z.string(),
676
+ kind: z2.enum(BACKUP_KINDS),
677
+ name: z2.string(),
594
678
  /** The managed database's kind (`postgres`) when the volume is one's; null otherwise. */
595
- managed: z.string().nullable(),
596
- error: z.string().nullable(),
679
+ managed: z2.string().nullable(),
680
+ error: z2.string().nullable(),
597
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. */
598
- host: z.string().nullable(),
599
- store: z.string().nullable(),
600
- createdAt: z.string()
682
+ host: z2.string().nullable(),
683
+ store: z2.string().nullable(),
684
+ createdAt: z2.string()
601
685
  });
602
- var MachineSchema = z.object({
686
+ var MachineSchema = z2.object({
603
687
  /** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
604
- id: z.string(),
605
- name: z.string(),
688
+ id: z2.string(),
689
+ name: z2.string(),
606
690
  /** Who the box belongs to; names are unique per owner. A bare name is local to the host, `user@control-plane` later. */
607
- owner: z.string(),
608
- ip: z.string(),
609
- mac: z.string(),
610
- pid: z.number().int().nullable(),
611
- vcpu: z.number().int(),
612
- memMib: z.number().int(),
613
- 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(),
614
698
  // the box's own writable disk, as the guest sees it
615
- diskUsedBytes: z.number().int(),
699
+ diskUsedBytes: z2.number().int(),
616
700
  // what the box uses of it: the filesystem's own count, like the guest's `df` (#115)
617
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. */
618
- diskHostBytes: z.number().int().optional(),
619
- base: z.string(),
702
+ diskHostBytes: z2.number().int().optional(),
703
+ base: z2.string(),
620
704
  // version of the image the box's overlay stacks on
621
705
  /** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
622
- image: z.string().optional(),
623
- createdAt: z.string(),
624
- source: z.string(),
706
+ image: z2.string().optional(),
707
+ createdAt: z2.string(),
708
+ source: z2.string(),
625
709
  // "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
626
710
  status: BoxStatusSchema,
627
711
  /**
628
712
  * Public TCP port on the host that reaches the box's SSH while it runs (#49). Only boxes made
629
713
  * through a control plane have one; the control plane adds the host's address for `connect` (#21).
630
714
  */
631
- sshPort: z.number().int().optional(),
715
+ sshPort: z2.number().int().optional(),
632
716
  /**
633
717
  * Where `ssh` reaches the box from outside: the host's public address and that port (#21). Only
634
718
  * the control plane fills it in (a host does not know its own public address); absent for a box
635
719
  * whose host reported no port or did not answer.
636
720
  */
637
- 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(),
638
722
  /** Box ports published on the host (#30). Absent: none. */
639
- ports: z.array(PortForwardSchema).optional(),
723
+ ports: z2.array(PortForwardSchema).optional(),
640
724
  /** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /machines`. */
641
- ownerKind: z.enum(["user", "org"]).optional(),
725
+ ownerKind: z2.enum(["user", "org"]).optional(),
642
726
  /**
643
727
  * The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
644
728
  * links to, and a volume attaches to, only a box on the same host.
645
729
  */
646
- host: z.string().optional(),
730
+ host: z2.string().optional(),
647
731
  /** The country code of that host (`RO`, `US`), when its admin gave one. Only the control plane fills it in. */
648
- country: z.string().optional(),
732
+ country: z2.string().optional(),
649
733
  /**
650
734
  * The kind of managed service the box runs (`postgres`, `redis`, `storage`). Only an admin's
651
735
  * `GET /machines?all=1` lists such boxes, so a host's boxes add up; every other listing hides them.
652
736
  */
653
- managed: z.string().optional(),
737
+ managed: z2.string().optional(),
654
738
  /** Seconds without network traffic before the host hibernates the box (#47). Absent: never. */
655
- autoHibernateSec: z.number().int().positive().optional(),
739
+ autoHibernateSec: z2.number().int().positive().optional(),
656
740
  /** A script inside the box that says it is idle (#102, exit 0): auto-hibernate asks it instead of watching the traffic. */
657
- idleCheck: z.string().optional(),
741
+ idleCheck: z2.string().optional(),
658
742
  /** Volumes attached to the box (#52), in drive order; each is mounted at `mountPath` while the box runs. Absent: none. */
659
- 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(),
660
744
  /** Boxes that may reach this one, each on one port (#98). Absent: none. */
661
- 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(),
662
751
  /** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
663
- url: z.string().optional(),
752
+ url: z2.string().optional(),
664
753
  /**
665
754
  * Only in what `POST /machines` answers, for an image that declares one (#87): how to reach what it
666
755
  * serves, e.g. `postgres://postgres:<password>@db.kvbox:5432/postgres`. Holds the box's variables.
667
756
  */
668
- connect: z.string().optional()
757
+ connect: z2.string().optional()
669
758
  });
670
- var VolumeSchema = z.object({
759
+ var VolumeSchema = z2.object({
671
760
  /** The host's 6-hex volume id (#91): the ledger's key, so a name removed and made again is two volumes. */
672
- id: z.string(),
673
- name: z.string(),
674
- owner: z.string(),
675
- sizeGib: z.number().int(),
761
+ id: z2.string(),
762
+ name: z2.string(),
763
+ owner: z2.string(),
764
+ sizeGib: z2.number().int(),
676
765
  /** What the sparse file really occupies on the host. */
677
- usedBytes: z.number().int(),
678
- attachedTo: z.string().nullable(),
679
- createdAt: z.string(),
766
+ usedBytes: z2.number().int(),
767
+ attachedTo: z2.string().nullable(),
768
+ createdAt: z2.string(),
680
769
  /** Whether the owner slug is a user or an org. Only the control plane knows; it fills it in on `GET /volumes`. */
681
- ownerKind: z.enum(["user", "org"]).optional(),
770
+ ownerKind: z2.enum(["user", "org"]).optional(),
682
771
  /** The name of the host the volume lives on; only the control plane fills it in. It attaches only to a box there. */
683
- host: z.string().optional()
772
+ host: z2.string().optional()
684
773
  });
685
774
  var MAX_VOLUME_GIB = 4096;
686
775
  var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
687
776
  var VOLUME_NAME_RULE = "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit";
688
- var CreateVolumeRequest = z.object({
689
- name: z.string(),
690
- 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),
691
780
  /**
692
781
  * Through a control plane (#91): the box this volume is for, so it is made on that box's host; the
693
782
  * control plane requires it (a volume attaches only to a box on its own host, so one made for no box
694
783
  * could never attach) and the CLI attaches right after. A host ignores it.
695
784
  */
696
- box: z.string().optional()
785
+ box: z2.string().optional()
697
786
  });
698
- var AttachVolumeRequest = z.object({
699
- box: z.string()
787
+ var AttachVolumeRequest = z2.object({
788
+ box: z2.string()
700
789
  });
701
- var ResizeVolumeRequest = z.object({
702
- 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)
703
792
  });
704
- var RunScriptRequest = z.object({ input: z.unknown().optional() });
705
- var ScriptOutputSchema = z.object({ output: z.unknown() });
793
+ var RunScriptRequest = z2.object({ input: z2.unknown().optional() });
794
+ var ScriptOutputSchema = z2.object({ output: z2.unknown() });
706
795
  var BOX_RUN_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
707
- var StartRunRequest = z.object({
708
- id: z.string().regex(BOX_RUN_ID_RE),
709
- 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),
710
799
  /** The command and everything it started are killed after this long. */
711
- timeoutSec: z.number().int().min(1).max(86400),
800
+ timeoutSec: z2.number().int().min(1).max(86400),
712
801
  /**
713
802
  * The caller will read the output back (`exec`, #188): the box's kvbox-agent must know `runOutput`
714
803
  * (base v0.16.0+), which the host checks before the command starts, so an older box is `box-outdated`
715
804
  * without having run anything.
716
805
  */
717
- output: z.boolean().optional()
806
+ output: z2.boolean().optional()
718
807
  });
719
- var StartRunAnswerSchema = z.object({
720
- id: z.string(),
808
+ var StartRunAnswerSchema = z2.object({
809
+ id: z2.string(),
721
810
  /** False: a run of this id was already there. */
722
- started: z.boolean(),
811
+ started: z2.boolean(),
723
812
  /** The box was asleep and this request woke it. */
724
- woke: z.boolean()
813
+ woke: z2.boolean()
725
814
  });
726
815
  var BOX_RUN_STATES = ["running", "exited", "timeout", "unknown"];
727
- var BoxRunSchema = z.object({
728
- id: z.string(),
729
- state: z.enum(BOX_RUN_STATES),
816
+ var BoxRunSchema = z2.object({
817
+ id: z2.string(),
818
+ state: z2.enum(BOX_RUN_STATES),
730
819
  /** With `exited`; 128 + the signal for a command a signal ended. */
731
- exitCode: z.number().int().optional(),
820
+ exitCode: z2.number().int().optional(),
732
821
  /**
733
822
  * With `exited` and `timeout`: how long the command itself ran, by the box's own clock (base v0.15.1
734
823
  * and later). The asker learns of the end seconds late, so its own count is too long.
735
824
  */
736
- durationMs: z.number().int().nonnegative().optional()
825
+ durationMs: z2.number().int().nonnegative().optional()
737
826
  });
738
- var RunRefusalSchema = z.object({ error: z.string(), code: z.string().optional() });
827
+ var RunRefusalSchema = z2.object({ error: z2.string(), code: z2.string().optional() });
739
828
  var RUN_OUTPUT_MAX_BYTES = 1 << 20;
740
829
  var RUN_STREAMS = ["stdout", "stderr"];
741
- var RunOutputSchema = z.object({
742
- id: z.string(),
743
- stream: z.enum(RUN_STREAMS),
744
- offset: z.number().int().nonnegative(),
745
- size: z.number().int().nonnegative(),
746
- 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()
747
836
  });
748
837
  var DEFAULT_EXEC_TIMEOUT_SEC = 600;
749
- var ExecRequest = z.object({
750
- command: z.string().min(1).max(8192),
838
+ var ExecRequest = z2.object({
839
+ command: z2.string().min(1).max(8192),
751
840
  /** The command and everything it started are killed after this long (default DEFAULT_EXEC_TIMEOUT_SEC). */
752
- timeoutSec: z.number().int().min(1).max(86400).optional()
841
+ timeoutSec: z2.number().int().min(1).max(86400).optional()
753
842
  });
754
- var ExecStartSchema = z.object({
755
- id: z.string(),
843
+ var ExecStartSchema = z2.object({
844
+ id: z2.string(),
756
845
  /** The box was asleep and this request woke it. */
757
- woke: z.boolean()
846
+ woke: z2.boolean()
758
847
  });
759
- var ExecSchema = z.object({
760
- id: z.string(),
761
- state: z.enum(BOX_RUN_STATES),
848
+ var ExecSchema = z2.object({
849
+ id: z2.string(),
850
+ state: z2.enum(BOX_RUN_STATES),
762
851
  /** With `exited`; 128 + the signal for a command a signal ended. */
763
- exitCode: z.number().int().optional(),
852
+ exitCode: z2.number().int().optional(),
764
853
  /** With `exited` and `timeout`: how long the command itself ran. */
765
- durationMs: z.number().int().nonnegative().optional(),
766
- stdout: z.string().optional(),
767
- stderr: z.string().optional(),
768
- stdoutBytes: z.number().int().nonnegative().optional(),
769
- stderrBytes: z.number().int().nonnegative().optional(),
770
- truncated: z.boolean().optional()
771
- });
772
- var EnvVarSchema = z.object({
773
- name: z.string(),
774
- value: z.string().optional(),
775
- secret: z.boolean(),
776
- updatedAt: z.string()
777
- });
778
- var BoxEnvSchema = z.object({
779
- box: z.string(),
780
- vars: z.array(EnvVarSchema)
781
- });
782
- var BoxEnvChangeSchema = z.object({
783
- box: z.string(),
784
- 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(),
785
874
  /** Whether the box is running now: the change waits for its next start. */
786
- running: z.boolean()
875
+ running: z2.boolean()
787
876
  });
788
- var SetEnvRequest = z.object({
789
- value: z.string(),
790
- secret: z.boolean().optional()
877
+ var SetEnvRequest = z2.object({
878
+ value: z2.string(),
879
+ secret: z2.boolean().optional()
791
880
  });
792
- var EnvChangeSchema = z.object({
793
- owner: z.string(),
794
- name: z.string(),
795
- boxes: z.number().int()
881
+ var EnvChangeSchema = z2.object({
882
+ owner: z2.string(),
883
+ name: z2.string(),
884
+ boxes: z2.number().int()
796
885
  });
797
- var HostEnvRequest = z.object({
798
- version: z.number().int().min(0),
799
- 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() }))
800
889
  });
801
- var HostEnvVersionsSchema = z.array(z.object({ owner: z.string(), version: z.number().int() }));
802
- var CreateMachineRequest = z.object({
803
- 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(),
804
893
  /** Ignored over the local socket (the caller is the host owner); the control plane sets it over HTTPS. */
805
- owner: z.string().optional(),
894
+ owner: z2.string().optional(),
806
895
  size: SizeSchema.optional(),
807
- from: z.string().optional(),
808
- force: z.boolean().optional(),
896
+ from: z2.string().optional(),
897
+ force: z2.boolean().optional(),
809
898
  /**
810
899
  * Extra authorized_keys lines for the box, on top of the host's own key: the control plane sends
811
900
  * its SSH CA as one `cert-authority …` line (#51). Written into the box's authorized_keys at every
812
901
  * boot (#49); a host older than that ignores them.
813
902
  */
814
- sshKeys: z.array(z.string()).optional(),
903
+ sshKeys: z2.array(z2.string()).optional(),
815
904
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. Absent: the host's default. */
816
- autoHibernateSec: z.number().int().min(0).optional(),
905
+ autoHibernateSec: z2.number().int().min(0).optional(),
817
906
  /**
818
907
  * Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
819
908
  * control plane reads it; a host has one place to put a box.
820
909
  */
821
- near: z.string().optional(),
910
+ near: z2.string().optional(),
822
911
  /**
823
912
  * Place the box on a host in this country (`kvbox new --country romania`): a code or an English name,
824
913
  * `@kvbox/shared/country`. Only the control plane reads it.
825
914
  */
826
- country: z.string().optional(),
915
+ country: z2.string().optional(),
827
916
  /**
828
917
  * Place the box on the host of this name and nowhere else (`kvbox new --host kvbox2`, a hidden flag):
829
918
  * an admin's, to try a host out. Only the control plane reads it, and refuses it from anyone else.
830
919
  */
831
- host: z.string().optional(),
920
+ host: z2.string().optional(),
832
921
  /** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
833
- image: z.string().optional(),
922
+ image: z2.string().optional(),
834
923
  /** The box's own environment variables (#87, `kvbox new -e NAME=value`), over its owner's. */
835
- 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(),
836
925
  /**
837
926
  * Start the box on this backup's disk (#141, `kvbox new --from-backup <id>`), a removed box's too: its image,
838
927
  * version and variables come from the backup, its size too unless given. Only the control plane reads it.
839
928
  */
840
- fromBackup: z.string().optional()
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()
841
935
  });
842
936
  var HostFromBackupRequest = CreateMachineRequest.omit({ from: true, fromBackup: true, image: true, env: true }).extend({ backup: HostRestoreRequest });
843
- var ForkMachineRequest = z.object({
844
- name: z.string().optional(),
937
+ var ForkMachineRequest = z2.object({
938
+ name: z2.string().optional(),
845
939
  /**
846
940
  * The new box's slug, bare (`acme`): the control plane sends the target of `--org` here; the host
847
941
  * qualifies it with the caller's realm. Absent: the source's owner. A CLI leaves it out.
848
942
  */
849
- owner: z.string().optional(),
943
+ owner: z2.string().optional(),
850
944
  /** A cold fork only: a warm one keeps the source's vCPU and memory. */
851
945
  size: SizeSchema.optional(),
852
- force: z.boolean().optional(),
946
+ force: z2.boolean().optional(),
853
947
  /** As in CreateMachineRequest: the control plane's CA line for the new box's owner. */
854
- sshKeys: z.array(z.string()).optional(),
855
- autoHibernateSec: z.number().int().min(0).optional()
948
+ sshKeys: z2.array(z2.string()).optional(),
949
+ autoHibernateSec: z2.number().int().min(0).optional()
856
950
  });
857
- var SetSshKeysRequest = z.object({
858
- sshKeys: z.array(z.string())
951
+ var SetSshKeysRequest = z2.object({
952
+ sshKeys: z2.array(z2.string())
859
953
  });
860
- var RescaleMachineRequest = z.object({
954
+ var RescaleMachineRequest = z2.object({
861
955
  size: SizeSchema.optional(),
862
- vcpu: z.number().int().min(1).max(64).optional(),
863
- memMib: z.number().int().min(256).optional(),
864
- 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(),
865
959
  /** Skip the capacity guard when a running box grows (#37). */
866
- force: z.boolean().optional()
960
+ force: z2.boolean().optional()
867
961
  });
868
- var StartMachineRequest = z.object({
869
- force: z.boolean().optional()
962
+ var StartMachineRequest = z2.object({
963
+ force: z2.boolean().optional()
870
964
  });
871
- var SetMachineRequest = z.object({
965
+ var SetMachineRequest = z2.object({
872
966
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. */
873
- autoHibernateSec: z.number().int().min(0).optional(),
967
+ autoHibernateSec: z2.number().int().min(0).optional(),
874
968
  /** The box's idle check (#102): an absolute path to a script inside the box, exit 0 = idle; "": none, back to network traffic. */
875
- idleCheck: z.union([z.literal(""), z.string().max(255).regex(/^\/[^\0\n]*$/, "an absolute path inside the box")]).optional()
876
- });
877
- var SnapshotSchema = z.object({
878
- name: z.string(),
879
- owner: z.string(),
880
- 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(),
881
977
  // the box it was taken from, as owner/name
882
- base: z.string(),
978
+ base: z2.string(),
883
979
  // version of the image the overlay stacks on; a restore needs the same one
884
980
  /** As in MachineSchema: the image when it is not the base one (#87). */
885
- image: z.string().optional(),
886
- vcpu: z.number().int(),
887
- memMib: z.number().int(),
888
- sizeBytes: z.number().int(),
981
+ image: z2.string().optional(),
982
+ vcpu: z2.number().int(),
983
+ memMib: z2.number().int(),
984
+ sizeBytes: z2.number().int(),
889
985
  // what vmstate + mem + overlay really occupy on the host
890
- createdAt: z.string()
986
+ createdAt: z2.string()
891
987
  });
892
- var CreateSnapshotRequest = z.object({
893
- box: z.string(),
894
- name: z.string(),
988
+ var CreateSnapshotRequest = z2.object({
989
+ box: z2.string(),
990
+ name: z2.string(),
895
991
  /** Retake a snapshot under a name that exists (#83): the old one goes only once the new one is complete. */
896
- replace: z.boolean().optional()
897
- });
898
- var DiskCapacitySchema = z.object({
899
- totalGib: z.number().int(),
900
- freeGib: z.number().int(),
901
- volumesGib: z.number().int(),
902
- volumesUsedGib: z.number().int(),
903
- headroomGib: z.number().int()
904
- });
905
- var CapacitySchema = z.object({
906
- hostMemMib: z.number().int(),
907
- hostCores: z.number().int(),
908
- reservedMemMib: z.number().int(),
909
- reservedVcpu: z.number().int(),
910
- 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(),
911
1007
  /**
912
1008
  * MiB of RAM the host keeps back from its boxes (config.json `memHeadroomMib`). Absent on a kvbox-server
913
1009
  * from before the setting, which keeps 2 GB (`OLD_HOST_MEM_HEADROOM_MIB`).
914
1010
  */
915
- memHeadroomMib: z.number().int().optional(),
1011
+ memHeadroomMib: z2.number().int().optional(),
916
1012
  /** Absent on a host from before volumes (#91): it cannot take one. */
917
1013
  disk: DiskCapacitySchema.optional(),
918
1014
  /**
919
1015
  * The images a new box can be made from here (#87), with the version `new` uses; the base is `base`.
920
1016
  * Absent on a host from before images: it has only the base.
921
1017
  */
922
- 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(),
923
1019
  /** kvbox-server's version, so the control plane's host list shows it without a call per host. Older servers omit it. */
924
- version: z.string().optional(),
1020
+ version: z2.string().optional(),
925
1021
  /** Present on a host set up as a backup store: the disk its Garage keeps chunks on, and whether Garage runs. */
926
- 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(),
927
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. */
928
- storeClient: z.boolean().optional(),
1024
+ storeClient: z2.boolean().optional(),
929
1025
  /** True on a kvbox-server with `POST /machines/from-backup` (#141, `kvbox new --from-backup`); older ones omit it. */
930
- fromBackup: z.boolean().optional()
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()
931
1029
  });
932
- var ImageSchema = z.object({ name: z.string(), version: z.string().nullable() });
933
- var ImageIndexSchema = z.object({
934
- updatedAt: z.string(),
935
- images: z.record(z.string(), z.object({ version: z.string().min(1), minServer: z.string().min(1).optional() }))
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() }))
936
1034
  });
937
- var LatestImagesSchema = z.object({
938
- updatedAt: z.string().nullable(),
1035
+ var LatestImagesSchema = z2.object({
1036
+ updatedAt: z2.string().nullable(),
939
1037
  images: ImageIndexSchema.shape.images,
940
- checkedAt: z.string().nullable()
941
- });
942
- var RecoveryReportSchema = z.object({
943
- at: z.string(),
944
- booted: z.array(z.string()),
945
- leftStopped: z.array(z.string()),
946
- failed: z.array(z.object({ box: z.string(), error: z.string() }))
947
- });
948
- var HostUpdateSchema = z.object({
949
- state: z.enum(["running", "done", "failed"]),
950
- startedAt: z.string(),
951
- 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(),
952
1050
  /** kvbox-server's version when the update started, and when it ended (null while running or when it failed before). */
953
- from: z.string(),
954
- to: z.string().nullable(),
955
- error: z.string().nullable(),
956
- needsManual: z.array(z.string())
957
- });
958
- var HealthSchema = z.object({
959
- ok: z.literal(true),
960
- version: z.string(),
961
- 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(),
962
1060
  /** Base image version new boxes get (null when the host has no usable base image yet). */
963
- base: z.string().nullable(),
1061
+ base: z2.string().nullable(),
964
1062
  /** Owner that boxes made over the local socket get (the Unix user running the server). */
965
- owner: z.string(),
1063
+ owner: z2.string(),
966
1064
  /** The control plane this host joined (null when none). */
967
- controlPlane: z.object({
1065
+ controlPlane: z2.object({
968
1066
  /** Realm name, e.g. kvbox.sh. */
969
- name: z.string(),
970
- url: z.string(),
1067
+ name: z2.string(),
1068
+ url: z2.string(),
971
1069
  /** Where this host answers the control plane. */
972
- hostUrl: z.string()
1070
+ hostUrl: z2.string()
973
1071
  }).nullable(),
974
1072
  /** The relay this host reaches the internet through (#50); null when it has its own public address. Older servers omit it. */
975
- relay: z.object({
976
- name: z.string(),
1073
+ relay: z2.object({
1074
+ name: z2.string(),
977
1075
  /** The public IP the relay owns for this host. */
978
- publicIp: z.string(),
1076
+ publicIp: z2.string(),
979
1077
  /** The relay's WireGuard endpoint the tunnel dials. */
980
- endpoint: z.string(),
1078
+ endpoint: z2.string(),
981
1079
  /** Times the server redialed the tunnel since it started, because the relay stopped answering. Older servers omit them. */
982
- restarts: z.number().int().optional(),
983
- lastRestartAt: z.string().nullable().optional()
1080
+ restarts: z2.number().int().optional(),
1081
+ lastRestartAt: z2.string().nullable().optional()
984
1082
  }).nullable().optional(),
985
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. */
986
1084
  recovery: RecoveryReportSchema.nullable().optional(),
987
1085
  /** The last self-update; null when none ran. Older servers omit it. */
988
1086
  update: HostUpdateSchema.nullable().optional()
989
1087
  });
990
- var MachineUsageSchema = z.object({
991
- name: z.string(),
992
- owner: z.string(),
1088
+ var MachineUsageSchema = z2.object({
1089
+ name: z2.string(),
1090
+ owner: z2.string(),
993
1091
  status: BoxStatusSchema,
994
- window: z.object({ from: z.string(), to: z.string() }),
995
- seconds: z.object({
996
- running: z.number().int(),
997
- standby: z.number().int(),
998
- hibernated: z.number().int(),
999
- 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()
1000
1098
  }),
1001
- vcpuHours: z.number(),
1002
- ramGibHours: z.number(),
1003
- diskGibHours: z.number(),
1004
- 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(),
1005
1103
  /** Stops the server did not witness (Firecracker died, host rebooted) and dated to when it noticed. */
1006
- estimatedStops: z.number().int(),
1007
- historyFrom: z.string().nullable()
1104
+ estimatedStops: z2.number().int(),
1105
+ historyFrom: z2.string().nullable()
1008
1106
  });
1009
- var GuestStatsSchema = z.object({
1107
+ var GuestStatsSchema = z2.object({
1010
1108
  /** Load average over 1, 5 and 15 minutes. */
1011
- load: z.tuple([z.number(), z.number(), z.number()]),
1012
- cpus: z.number().int(),
1013
- memTotalMib: z.number().int(),
1109
+ load: z2.tuple([z2.number(), z2.number(), z2.number()]),
1110
+ cpus: z2.number().int(),
1111
+ memTotalMib: z2.number().int(),
1014
1112
  /** Total minus available: page cache counts as free. */
1015
- memUsedMib: z.number().int(),
1113
+ memUsedMib: z2.number().int(),
1016
1114
  /** The box's root, which is its overlay disk: the box's own writes, not the shared base. */
1017
- diskTotalBytes: z.number().int(),
1018
- diskUsedBytes: z.number().int(),
1019
- uptimeSec: z.number().int()
1115
+ diskTotalBytes: z2.number().int(),
1116
+ diskUsedBytes: z2.number().int(),
1117
+ uptimeSec: z2.number().int()
1020
1118
  });
1021
- var MachineStatsSchema = z.object({
1022
- name: z.string(),
1023
- owner: z.string(),
1119
+ var MachineStatsSchema = z2.object({
1120
+ name: z2.string(),
1121
+ owner: z2.string(),
1024
1122
  stats: GuestStatsSchema.nullable()
1025
1123
  });
1026
- var UsageStatusSchema = z.enum([...BoxStatusSchema.options, "removed"]);
1124
+ var UsageStatusSchema = z2.enum([...BoxStatusSchema.options, "removed"]);
1027
1125
  var BoxUsageSchema = MachineUsageSchema.omit({ window: true, status: true }).extend({
1028
1126
  /** The host's box id; a name removed and recreated appears twice, with two ids. */
1029
- id: z.string(),
1127
+ id: z2.string(),
1030
1128
  status: UsageStatusSchema,
1031
1129
  /** Through a control plane: whether the owner slug is a user's or an org's (what `kvbox ls` shows). */
1032
- ownerKind: z.enum(["user", "org"]).optional(),
1130
+ ownerKind: z2.enum(["user", "org"]).optional(),
1033
1131
  /**
1034
1132
  * Through a control plane: the username that made the box (#60), absent when the box is gone from
1035
1133
  * the index (removed), was found by reconcile, or its maker was deleted. The ledger does not record it.
1036
1134
  */
1037
- createdBy: z.string().optional()
1135
+ createdBy: z2.string().optional()
1038
1136
  });
1039
- var VolumeUsageSchema = z.object({
1137
+ var VolumeUsageSchema = z2.object({
1040
1138
  /** The host's volume id; a name removed and made again appears twice, with two ids. */
1041
- id: z.string(),
1042
- name: z.string(),
1043
- owner: z.string(),
1044
- 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(),
1045
1143
  /** The size at the end of the window (or when removed). */
1046
- sizeGib: z.number().int(),
1047
- status: z.enum(["present", "removed"]),
1048
- volumeHours: z.number(),
1049
- volumeGibHours: z.number(),
1050
- cost: z.object({ amount: z.number(), currency: z.string() }).optional(),
1051
- historyFrom: z.string().nullable()
1052
- });
1053
- var CronUsageSchema = z.object({
1054
- id: z.string(),
1055
- name: z.string(),
1056
- owner: z.string(),
1057
- ownerKind: z.enum(["user", "org"]).optional(),
1058
- status: z.enum(["present", "removed"]),
1059
- hours: z.number(),
1060
- 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(),
1061
1159
  /** When it was made. */
1062
- historyFrom: z.string().nullable()
1063
- });
1064
- var BackupUsageSchema = z.object({
1065
- id: z.string(),
1066
- kind: z.string(),
1067
- name: z.string(),
1068
- owner: z.string(),
1069
- 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(),
1070
1168
  /** How many paid backups turned ready in the window. */
1071
- count: z.number().int(),
1072
- cost: z.object({ amount: z.number(), currency: z.string() })
1169
+ count: z2.number().int(),
1170
+ cost: z2.object({ amount: z2.number(), currency: z2.string() })
1073
1171
  });
1074
- var UsageDayItemSchema = z.object({
1075
- id: z.string(),
1076
- name: z.string(),
1077
- owner: z.string(),
1172
+ var UsageDayItemSchema = z2.object({
1173
+ id: z2.string(),
1174
+ name: z2.string(),
1175
+ owner: z2.string(),
1078
1176
  /** Removed by the end of the report's window. */
1079
- removed: z.boolean(),
1080
- cost: z.number()
1177
+ removed: z2.boolean(),
1178
+ cost: z2.number()
1081
1179
  });
1082
- var UsageDaySchema = z.object({
1180
+ var UsageDaySchema = z2.object({
1083
1181
  /** `YYYY-MM-DD`, UTC. */
1084
- date: z.string(),
1085
- from: z.string(),
1086
- to: z.string(),
1087
- cost: z.number(),
1088
- currency: z.string(),
1089
- boxes: z.array(UsageDayItemSchema),
1090
- 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),
1091
1189
  /** Object storage that existed that day (#182); absent on a day without any. */
1092
- storage: z.array(UsageDayItemSchema).optional(),
1190
+ storage: z2.array(UsageDayItemSchema).optional(),
1093
1191
  /** Cron services that existed that day (#190); absent on a day without any. */
1094
- cron: z.array(UsageDayItemSchema).optional(),
1192
+ cron: z2.array(UsageDayItemSchema).optional(),
1095
1193
  /** Paid backups that turned ready that day, summed per thing backed up (`id` is `<owner>/<kind>:<name>`); absent on a day without any. */
1096
- backups: z.array(UsageDayItemSchema).optional()
1194
+ backups: z2.array(UsageDayItemSchema).optional()
1097
1195
  });
1098
- var UsageReportSchema = z.object({
1099
- window: z.object({ from: z.string(), to: z.string() }),
1100
- boxes: z.array(BoxUsageSchema),
1196
+ var UsageReportSchema = z2.object({
1197
+ window: z2.object({ from: z2.string(), to: z2.string() }),
1198
+ boxes: z2.array(BoxUsageSchema),
1101
1199
  /** Absent from a side older than #91. */
1102
- volumes: z.array(VolumeUsageSchema).optional(),
1200
+ volumes: z2.array(VolumeUsageSchema).optional(),
1103
1201
  /**
1104
1202
  * Object storage (#182, control plane only): one row per storage a slug has or had, shaped like a
1105
1203
  * volume's. `volumeHours` are the hours it existed, `volumeGibHours` those of the GiB beyond the
1106
1204
  * included ones, `sizeGib` its whole size. Absent when there is none.
1107
1205
  */
1108
- storage: z.array(VolumeUsageSchema).optional(),
1206
+ storage: z2.array(VolumeUsageSchema).optional(),
1109
1207
  /** Cron services (#190, control plane only): one row per service a slug has or had. Absent when there is none. */
1110
- cron: z.array(CronUsageSchema).optional(),
1208
+ cron: z2.array(CronUsageSchema).optional(),
1111
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. */
1112
- backups: z.array(BackupUsageSchema).optional(),
1210
+ backups: z2.array(BackupUsageSchema).optional(),
1113
1211
  /** With `?by=day` only, oldest day first. */
1114
- days: z.array(UsageDaySchema).optional(),
1115
- totals: z.object({
1212
+ days: z2.array(UsageDaySchema).optional(),
1213
+ totals: z2.object({
1116
1214
  seconds: MachineUsageSchema.shape.seconds,
1117
- vcpuHours: z.number(),
1118
- ramGibHours: z.number(),
1119
- diskGibHours: z.number(),
1120
- volumeHours: z.number().optional(),
1121
- 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(),
1122
1220
  /** Boxes, volumes, object storage, cron services and paid backups together. */
1123
- cost: z.object({ amount: z.number(), currency: z.string() }).optional()
1221
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
1124
1222
  })
1125
1223
  });
1126
- var UsageEventRowSchema = z.object({
1127
- id: z.number().int(),
1128
- boxId: z.string(),
1129
- owner: z.string(),
1130
- name: z.string(),
1131
- at: z.string(),
1132
- state: z.enum(["running", "standby", "hibernated", "stopped"]),
1133
- vcpu: z.number().int(),
1134
- memMib: z.number().int(),
1135
- diskGib: z.number().int(),
1136
- by: z.string()
1137
- });
1138
- var UsageEventsResponseSchema = z.object({
1139
- ledger: z.string().min(1),
1140
- events: z.array(UsageEventRowSchema),
1141
- next: z.number().int()
1142
- });
1143
- var VolumeEventRowSchema = z.object({
1144
- id: z.number().int(),
1145
- volumeId: z.string(),
1146
- owner: z.string(),
1147
- name: z.string(),
1148
- at: z.string(),
1149
- sizeGib: z.number().int(),
1150
- by: z.enum(["create", "resize", "rm"])
1151
- });
1152
- var VolumeEventsResponseSchema = z.object({
1153
- ledger: z.string().min(1),
1154
- events: z.array(VolumeEventRowSchema),
1155
- 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()
1156
1254
  });
1157
1255
  var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking"];
1158
- var ApiErrorCodeSchema = z.enum(API_ERROR_CODES);
1159
- var ApiErrorSchema = z.object({
1160
- error: z.string(),
1256
+ var ApiErrorCodeSchema = z2.enum(API_ERROR_CODES);
1257
+ var ApiErrorSchema = z2.object({
1258
+ error: z2.string(),
1161
1259
  code: ApiErrorCodeSchema.optional()
1162
1260
  });
1163
1261
  var DEFAULT_CLOUD_URL = "https://api.kvbox.sh";
1164
1262
  var ACTIVATED_BY = ["card", "admin"];
1165
- var ActivatedBySchema = z.enum(ACTIVATED_BY);
1166
- var CloudUserSchema = z.object({
1263
+ var ActivatedBySchema = z2.enum(ACTIVATED_BY);
1264
+ var CloudUserSchema = z2.object({
1167
1265
  /** The handle: what hosts file boxes under (`<username>@<control plane>`). Lowercase, no `@` or `/`. */
1168
- username: z.string(),
1266
+ username: z2.string(),
1169
1267
  /** Display name, free text ("Alexandru Ghiura"). */
1170
- name: z.string(),
1268
+ name: z2.string(),
1171
1269
  /** Login identity, unique. */
1172
- email: z.string(),
1173
- role: z.enum(["admin", "user"]),
1174
- createdAt: z.string(),
1270
+ email: z2.string(),
1271
+ role: z2.enum(["admin", "user"]),
1272
+ createdAt: z2.string(),
1175
1273
  /**
1176
1274
  * False until a card is on file or an admin activates the account (#74): then only `/me` and
1177
1275
  * `/logout` answer. Admins are never gated. A control plane older than #74 does not send these and
1178
1276
  * gates nobody, hence the defaults: a newer CLI must still parse its answers.
1179
1277
  */
1180
- active: z.boolean().default(true),
1278
+ active: z2.boolean().default(true),
1181
1279
  activatedBy: ActivatedBySchema.nullable().default(null),
1182
1280
  /** When too many wrong passwords locked the account (#161); null when it is not locked. Older control planes omit it. */
1183
- lockedAt: z.string().nullable().default(null)
1281
+ lockedAt: z2.string().nullable().default(null)
1184
1282
  });
1185
1283
  var ORG_ROLES = ["owner", "admin", "member"];
1186
- var OrgRoleSchema = z.enum(ORG_ROLES);
1187
- var CloudOrgSchema = z.object({
1188
- slug: z.string(),
1284
+ var OrgRoleSchema = z2.enum(ORG_ROLES);
1285
+ var CloudOrgSchema = z2.object({
1286
+ slug: z2.string(),
1189
1287
  /** Display name; the slug never changes, this may. */
1190
- name: z.string(),
1191
- createdAt: z.string(),
1288
+ name: z2.string(),
1289
+ createdAt: z2.string(),
1192
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. */
1193
- active: z.boolean().default(true),
1291
+ active: z2.boolean().default(true),
1194
1292
  activatedBy: ActivatedBySchema.nullable().default(null)
1195
1293
  });
1196
1294
  var OrgMembershipSchema = CloudOrgSchema.extend({ role: OrgRoleSchema });
1197
- var OrgMemberSchema = z.object({
1198
- username: z.string(),
1199
- name: z.string(),
1295
+ var OrgMemberSchema = z2.object({
1296
+ username: z2.string(),
1297
+ name: z2.string(),
1200
1298
  role: OrgRoleSchema,
1201
- addedAt: z.string()
1299
+ addedAt: z2.string()
1202
1300
  });
1203
- var OrgDetailSchema = CloudOrgSchema.extend({ members: z.array(OrgMemberSchema) });
1204
- var CreateOrgRequestSchema = z.object({
1205
- slug: z.string().min(1),
1206
- 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)
1207
1305
  });
1208
- var RenameOrgRequestSchema = z.object({ name: z.string().min(1) });
1209
- var AddMemberRequestSchema = z.object({
1210
- 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),
1211
1309
  role: OrgRoleSchema.default("member")
1212
1310
  });
1213
- var SetRoleRequestSchema = z.object({ role: OrgRoleSchema });
1214
- var MeResponseSchema = CloudUserSchema.extend({ orgs: z.array(OrgMembershipSchema) });
1215
- var BalanceSchema = z.object({
1216
- slug: z.string(),
1217
- balance: z.number(),
1218
- currency: z.string(),
1219
- topUps: z.number(),
1220
- 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(),
1221
1319
  /** The first moment usage counts from: the slug's first top-up or redeemed code; null when it has none. */
1222
- since: z.string().nullable(),
1320
+ since: z2.string().nullable(),
1223
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. */
1224
- suspendedAt: z.string().nullable().default(null),
1322
+ suspendedAt: z2.string().nullable().default(null),
1225
1323
  /** Promo credit left (#163), already counted in `balance`; 0 with none. Absent from a control plane older than this field. */
1226
- promo: z.number().default(0),
1324
+ promo: z2.number().default(0),
1227
1325
  /** When the next promo credit expires; null with none left. */
1228
- promoExpiresAt: z.string().nullable().default(null)
1326
+ promoExpiresAt: z2.string().nullable().default(null)
1229
1327
  });
1230
- var TopUpRequestSchema = z.object({
1231
- slug: z.string().min(1),
1328
+ var TopUpRequestSchema = z2.object({
1329
+ slug: z2.string().min(1),
1232
1330
  /** In the control plane's currency; negative corrects a mistake. */
1233
- amount: z.number().finite(),
1234
- note: z.string().max(200).optional()
1235
- });
1236
- var TopUpSchema = z.object({
1237
- id: z.string(),
1238
- slug: z.string(),
1239
- amount: z.number(),
1240
- 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(),
1241
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. */
1242
- source: z.enum(["admin", "card", "trial", "transfer"]),
1243
- note: z.string().nullable(),
1244
- at: z.string()
1340
+ source: z2.enum(["admin", "card", "trial", "transfer"]),
1341
+ note: z2.string().nullable(),
1342
+ at: z2.string()
1245
1343
  });
1246
- var CreateCodeRequestSchema = z.object({
1344
+ var CreateCodeRequestSchema = z2.object({
1247
1345
  /** In the control plane's currency, cents at most. */
1248
- 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"),
1249
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. */
1250
- expiresAt: z.string().min(1),
1251
- note: z.string().max(200).optional()
1252
- });
1253
- var CreditCodeSchema = z.object({
1254
- code: z.string(),
1255
- amount: z.number(),
1256
- currency: z.string(),
1257
- expiresAt: z.string(),
1258
- note: z.string().nullable(),
1259
- status: z.enum(["unused", "redeemed", "expired", "revoked"]),
1260
- createdBy: z.string(),
1261
- 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(),
1262
1360
  /** Who redeemed it and the slug the credit went to (their own, or an org they own). */
1263
- redeemedBy: z.string().nullable(),
1264
- redeemedSlug: z.string().nullable(),
1265
- redeemedAt: z.string().nullable(),
1266
- revokedAt: z.string().nullable()
1267
- });
1268
- var RedeemRequestSchema = z.object({
1269
- code: z.string().min(1).max(64),
1270
- org: z.string().min(1).optional()
1271
- });
1272
- var RedeemResponseSchema = z.object({
1273
- slug: z.string(),
1274
- amount: z.number(),
1275
- currency: z.string(),
1276
- 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(),
1277
1375
  balance: BalanceSchema,
1278
1376
  /** The slug was out of credit and this put it back above zero: it may start boxes again. */
1279
- reinstated: z.boolean()
1377
+ reinstated: z2.boolean()
1280
1378
  });
1281
1379
  var TOP_UP_AMOUNTS = [10, 25, 50, 100];
1282
- var BillingInfoSchema = z.object({
1283
- card: z.object({ brand: z.string(), last4: z.string() }).nullable(),
1284
- cardInUse: z.boolean(),
1380
+ var BillingInfoSchema = z2.object({
1381
+ card: z2.object({ brand: z2.string(), last4: z2.string() }).nullable(),
1382
+ cardInUse: z2.boolean(),
1285
1383
  balance: BalanceSchema
1286
1384
  });
1287
- var BillingRedirectSchema = z.object({ url: z.string() });
1288
- var TopUpCheckoutRequestSchema = z.object({
1289
- 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)
1290
1388
  });
1291
- var TransferRequestSchema = z.object({
1292
- org: z.string().min(1),
1293
- 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")
1294
1392
  });
1295
- var TransferResponseSchema = z.object({ from: BalanceSchema, to: BalanceSchema, activated: z.boolean() });
1296
- var LoginRequestSchema = z.object({
1297
- email: z.string().min(1),
1298
- password: z.string().min(1),
1299
- 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()
1300
1398
  });
1301
- var SignupRequestSchema = z.object({
1302
- username: z.string().min(1),
1303
- name: z.string().min(1),
1304
- email: z.string().min(1),
1305
- 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)
1306
1404
  });
1307
- var LoginResponseSchema = z.object({
1308
- token: z.string(),
1405
+ var LoginResponseSchema = z2.object({
1406
+ token: z2.string(),
1309
1407
  user: CloudUserSchema,
1310
- sshCert: z.string().optional(),
1311
- sshCertExpires: z.string().optional(),
1408
+ sshCert: z2.string().optional(),
1409
+ sshCertExpires: z2.string().optional(),
1312
1410
  /** Whose boxes the certificate opens: `<slug>@<realm>` for the user and each org they are in (orgs phase 4). */
1313
- sshCertPrincipals: z.array(z.string()).optional()
1411
+ sshCertPrincipals: z2.array(z2.string()).optional()
1314
1412
  });
1315
1413
  var DEVICE_LOGIN_PICKUP_SEC = 60;
1316
- var DeviceLoginRequestSchema = z.object({
1414
+ var DeviceLoginRequestSchema = z2.object({
1317
1415
  // Capped: anyone may open a login, and the key is stored until it expires (an RSA-16384 key is ~2.8 KB).
1318
- publicKey: z.string().max(16384).optional(),
1319
- hostname: z.string().max(255).optional()
1320
- });
1321
- var DeviceLoginStartSchema = z.object({
1322
- deviceCode: z.string(),
1323
- userCode: z.string(),
1324
- verifyUrl: z.string(),
1325
- expiresIn: z.number(),
1326
- interval: z.number()
1327
- });
1328
- var DeviceLoginPollRequestSchema = z.object({ deviceCode: z.string().min(1) });
1329
- var DeviceLoginPollSchema = z.union([
1330
- z.object({ status: z.enum(["pending", "slow_down", "refused", "expired"]) }),
1331
- 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") })
1332
1430
  ]);
1333
- var DeviceLoginInfoSchema = z.object({
1334
- userCode: z.string(),
1335
- hostname: z.string(),
1431
+ var DeviceLoginInfoSchema = z2.object({
1432
+ userCode: z2.string(),
1433
+ hostname: z2.string(),
1336
1434
  /** The address the request came from; null when the control plane could not tell. */
1337
- ip: z.string().nullable(),
1338
- createdAt: z.string(),
1339
- expiresAt: z.string()
1435
+ ip: z2.string().nullable(),
1436
+ createdAt: z2.string(),
1437
+ expiresAt: z2.string()
1340
1438
  });
1341
1439
  var DEFAULT_API_KEY_DAYS = 90;
1342
1440
  var API_KEY_NAME_RE = /^[a-z0-9][a-z0-9._-]{0,31}$/;
1343
- var ApiKeySchema = z.object({
1344
- name: z.string(),
1345
- createdAt: z.string(),
1441
+ var ApiKeySchema = z2.object({
1442
+ name: z2.string(),
1443
+ createdAt: z2.string(),
1346
1444
  /** Last request made with it (ISO); null: never used. */
1347
- lastUsedAt: z.string().nullable(),
1445
+ lastUsedAt: z2.string().nullable(),
1348
1446
  /** When it stops working (ISO); null: never. */
1349
- expiresAt: z.string().nullable()
1447
+ expiresAt: z2.string().nullable()
1350
1448
  });
1351
- var CreateApiKeyRequestSchema = z.object({
1352
- name: z.string().regex(API_KEY_NAME_RE, "a key's name is lowercase letters, digits, '.', '_' or '-' (up to 32 characters)"),
1353
- 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()
1354
1452
  });
1355
- var CreatedApiKeySchema = ApiKeySchema.extend({ key: z.string() });
1356
- var SshCertRequestSchema = z.object({
1357
- publicKey: z.string().min(1)
1453
+ var CreatedApiKeySchema = ApiKeySchema.extend({ key: z2.string() });
1454
+ var SshCertRequestSchema = z2.object({
1455
+ publicKey: z2.string().min(1)
1358
1456
  });
1359
- var SshCertResponseSchema = z.object({
1360
- cert: z.string(),
1361
- expires: z.string(),
1362
- principals: z.array(z.string())
1457
+ var SshCertResponseSchema = z2.object({
1458
+ cert: z2.string(),
1459
+ expires: z2.string(),
1460
+ principals: z2.array(z2.string())
1363
1461
  });
1364
- var SshCaResponseSchema = z.object({
1365
- publicKey: z.string(),
1462
+ var SshCaResponseSchema = z2.object({
1463
+ publicKey: z2.string(),
1366
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. */
1367
- 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()
1368
1466
  });
1369
- var HostSshCaResponseSchema = z.object({
1370
- publicKey: z.string()
1467
+ var HostSshCaResponseSchema = z2.object({
1468
+ publicKey: z2.string()
1371
1469
  });
1372
- var CloudCaSchema = z.object({
1373
- controlPlane: z.string(),
1374
- publicKey: z.string(),
1375
- fingerprint: z.string()
1470
+ var CloudCaSchema = z2.object({
1471
+ controlPlane: z2.string(),
1472
+ publicKey: z2.string(),
1473
+ fingerprint: z2.string()
1376
1474
  });
1377
- var TrustCaRequestSchema = z.object({
1378
- publicKey: z.string().min(1)
1475
+ var TrustCaRequestSchema = z2.object({
1476
+ publicKey: z2.string().min(1)
1379
1477
  });
1380
- var SshKeysAppliedSchema = z.enum(["now", "start", "wake", "resume", "later"]);
1381
- var TrustCaReportSchema = z.object({
1382
- publicKey: z.string(),
1383
- 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(),
1384
1482
  /** The guest trusts the CA now. */
1385
- updated: z.array(z.string()),
1483
+ updated: z2.array(z2.string()),
1386
1484
  /** meta.json has the line; the guest gets it at `when`. */
1387
- pending: z.array(z.object({ box: z.string(), when: SshKeysAppliedSchema, why: z.string().optional() })),
1388
- 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() })),
1389
1487
  /** Local boxes, untouched: they trust the host's key only. */
1390
- local: z.number().int(),
1488
+ local: z2.number().int(),
1391
1489
  /** Cloud boxes made without a CA line (a managed service's, #173), untouched: no certificate opens them. Absent from older servers. */
1392
- skipped: z.array(z.string()).optional()
1393
- });
1394
- var HostJoinRequestSchema = z.object({
1395
- token: z.string().min(1),
1396
- name: z.string().min(1),
1397
- url: z.string().url(),
1398
- fingerprint: z.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
1399
- 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),
1400
1498
  /** Where the host is (`kvbox-server join --country`): a code or an English name. */
1401
- country: z.string().optional()
1402
- });
1403
- var HostJoinResponseSchema = z.object({
1404
- hostSecret: z.string(),
1405
- controlPlane: z.object({ name: z.string() })
1406
- });
1407
- var CloudHostSchema = z.object({
1408
- name: z.string(),
1409
- url: z.string(),
1410
- publicAddress: z.string(),
1411
- joinedAt: z.string(),
1412
- 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(),
1413
1511
  capacity: CapacitySchema.nullable(),
1414
1512
  /** ISO 3166-1 alpha-2 code (`RO`), null when nobody said where the host is. */
1415
- country: z.string().nullable(),
1513
+ country: z2.string().nullable(),
1416
1514
  /** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
1417
- region: z.string().nullable(),
1515
+ region: z2.string().nullable(),
1418
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. */
1419
- version: z.string().nullable()
1517
+ version: z2.string().nullable()
1420
1518
  });
1421
- var HostInfoSchema = z.object({
1519
+ var HostInfoSchema = z2.object({
1422
1520
  host: CloudHostSchema,
1423
1521
  health: HealthSchema.nullable(),
1424
- error: z.string().nullable()
1522
+ error: z2.string().nullable()
1425
1523
  });
1426
- 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" });
1427
- 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() });
1428
1526
 
1429
1527
  // src/session.ts
1430
- var SessionSchema = z2.object({
1431
- url: z2.string(),
1432
- token: z2.string(),
1433
- user: z2.string(),
1528
+ var SessionSchema = z3.object({
1529
+ url: z3.string(),
1530
+ token: z3.string(),
1531
+ user: z3.string(),
1434
1532
  /** When the SSH certificate at paths().sshCert stops being accepted (ISO); absent before the first login with a key. */
1435
- sshCertExpires: z2.string().optional(),
1533
+ sshCertExpires: z3.string().optional(),
1436
1534
  /** Whose boxes that certificate opens (`<slug>@<realm>`, the user and their orgs); absent with `sshCertExpires`. */
1437
- sshCertPrincipals: z2.array(z2.string()).optional()
1535
+ sshCertPrincipals: z3.array(z3.string()).optional()
1438
1536
  });
1439
1537
  async function readSession(p = paths()) {
1440
1538
  let text2;
@@ -1613,7 +1711,7 @@ import { setTimeout as sleep2 } from "timers/promises";
1613
1711
  import { Agent, request } from "undici";
1614
1712
 
1615
1713
  // ../sdk/src/machines.ts
1616
- import { z as z3 } from "zod";
1714
+ import { z as z4 } from "zod";
1617
1715
 
1618
1716
  // ../sdk/src/errors.ts
1619
1717
  var KvboxSdkError = class extends Error {
@@ -1725,7 +1823,7 @@ var Machines = class {
1725
1823
  ports;
1726
1824
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1727
1825
  list(opts = {}) {
1728
- 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 });
1729
1827
  }
1730
1828
  /**
1731
1829
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1739,7 +1837,7 @@ var Machines = class {
1739
1837
  async find(name, orgOpt, timeoutMs) {
1740
1838
  const slash = name.indexOf("/");
1741
1839
  const [org, bare] = slash === -1 ? [orgOpt, name] : [name.slice(0, slash), name.slice(slash + 1)];
1742
- 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 });
1743
1841
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1744
1842
  if (named.length <= 1) {
1745
1843
  if (named[0] !== void 0) return named[0];
@@ -1764,9 +1862,16 @@ var Machines = class {
1764
1862
  }
1765
1863
  return made;
1766
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 });
1871
+ }
1767
1872
  /** Remove the box and its disk. */
1768
1873
  async remove(name, opts = {}) {
1769
- 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 });
1770
1875
  }
1771
1876
  /** Boot a stopped box. */
1772
1877
  start(name, opts = {}) {
@@ -1916,7 +2021,7 @@ var slugOf2 = (owner) => {
1916
2021
  };
1917
2022
 
1918
2023
  // ../sdk/src/snapshots.ts
1919
- import { z as z4 } from "zod";
2024
+ import { z as z5 } from "zod";
1920
2025
  var Snapshots = class {
1921
2026
  constructor(transport) {
1922
2027
  this.transport = transport;
@@ -1924,19 +2029,19 @@ var Snapshots = class {
1924
2029
  transport;
1925
2030
  /** Every snapshot the caller can read. */
1926
2031
  list(opts = {}) {
1927
- 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 });
1928
2033
  }
1929
2034
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
1930
2035
  create(req, opts = {}) {
1931
2036
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
1932
2037
  }
1933
2038
  async remove(name, opts = {}) {
1934
- 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 });
1935
2040
  }
1936
2041
  };
1937
2042
 
1938
2043
  // ../sdk/src/transport.ts
1939
- import { z as z5 } from "zod";
2044
+ import { z as z6 } from "zod";
1940
2045
  var Transport = class {
1941
2046
  baseUrl;
1942
2047
  org;
@@ -2010,7 +2115,7 @@ var Transport = class {
2010
2115
  }
2011
2116
  }
2012
2117
  };
2013
- var LooseApiErrorSchema = z5.object({ error: z5.string(), code: z5.string().optional() });
2118
+ var LooseApiErrorSchema = z6.object({ error: z6.string(), code: z6.string().optional() });
2014
2119
  function safeJson(text2) {
2015
2120
  try {
2016
2121
  return JSON.parse(text2);
@@ -2027,8 +2132,21 @@ function errorCode(err) {
2027
2132
  return void 0;
2028
2133
  }
2029
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
+
2030
2148
  // ../sdk/src/volumes.ts
2031
- import { z as z6 } from "zod";
2149
+ import { z as z8 } from "zod";
2032
2150
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2033
2151
  var Volumes = class {
2034
2152
  constructor(transport) {
@@ -2036,7 +2154,7 @@ var Volumes = class {
2036
2154
  }
2037
2155
  transport;
2038
2156
  list(opts = {}) {
2039
- 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 });
2040
2158
  }
2041
2159
  /**
2042
2160
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2059,7 +2177,7 @@ var Volumes = class {
2059
2177
  }
2060
2178
  /** Remove the volume and its data; it must be detached first. */
2061
2179
  async remove(name, opts = {}) {
2062
- 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 });
2063
2181
  }
2064
2182
  };
2065
2183
 
@@ -2080,6 +2198,7 @@ var Kvbox = class {
2080
2198
  machines;
2081
2199
  snapshots;
2082
2200
  volumes;
2201
+ integrations;
2083
2202
  transport;
2084
2203
  constructor(opts = {}) {
2085
2204
  this.transport = new Transport({
@@ -2092,6 +2211,7 @@ var Kvbox = class {
2092
2211
  this.machines = new Machines(this.transport);
2093
2212
  this.snapshots = new Snapshots(this.transport);
2094
2213
  this.volumes = new Volumes(this.transport);
2214
+ this.integrations = new Integrations(this.transport);
2095
2215
  }
2096
2216
  /** The API this client talks to, without a trailing slash. */
2097
2217
  get baseUrl() {
@@ -2107,35 +2227,35 @@ var Kvbox = class {
2107
2227
  };
2108
2228
 
2109
2229
  // src/client.ts
2110
- import { z as z11 } from "zod";
2230
+ import { z as z13 } from "zod";
2111
2231
 
2112
2232
  // ../shared/src/usage.ts
2113
- import { z as z7 } from "zod";
2114
- var PricingSchema = z7.object({
2115
- currency: z7.string().min(1),
2116
- vcpuHour: z7.number().nonnegative(),
2117
- ramGibHour: z7.number().nonnegative(),
2118
- diskGibHour: z7.number().nonnegative(),
2119
- volumeHour: z7.number().nonnegative().default(0),
2120
- volumeGibHour: z7.number().nonnegative().default(0),
2121
- 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),
2122
2242
  /**
2123
2243
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2124
2244
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2125
2245
  * A price list from before object storage charges nothing for it.
2126
2246
  */
2127
- storageHour: z7.number().nonnegative().default(0),
2128
- storageGibHour: z7.number().nonnegative().default(0),
2129
- 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),
2130
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. */
2131
- cronHour: z7.number().nonnegative().default(0),
2251
+ cronHour: z9.number().nonnegative().default(0),
2132
2252
  /**
2133
2253
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2134
2254
  * costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
2135
2255
  */
2136
- backup: z7.number().nonnegative().default(0)
2256
+ backup: z9.number().nonnegative().default(0)
2137
2257
  });
2138
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z7.number().nonnegative() });
2258
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z9.number().nonnegative() });
2139
2259
  var HOUR_MS = 36e5;
2140
2260
  var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
2141
2261
  function costOf(t, pricing) {
@@ -2163,86 +2283,86 @@ function sumUsage(items, pricing) {
2163
2283
  var DAY_MS = 24 * HOUR_MS;
2164
2284
 
2165
2285
  // ../shared/src/managed.ts
2166
- import { z as z8 } from "zod";
2167
- var PriceSchema = z8.object({ perMonth: z8.number(), storagePerMonth: z8.number(), currency: z8.string() });
2168
- 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({
2169
2289
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2170
- kind: z8.string(),
2290
+ kind: z10.string(),
2171
2291
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2172
- command: z8.string(),
2173
- title: z8.string(),
2174
- description: z8.string(),
2292
+ command: z10.string(),
2293
+ title: z10.string(),
2294
+ description: z10.string(),
2175
2295
  /** The version a new one runs, as shown: `18`. */
2176
- version: z8.string(),
2296
+ version: z10.string(),
2177
2297
  /** The port a linked box reaches it on. */
2178
- port: z8.number().int(),
2298
+ port: z10.number().int(),
2179
2299
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2180
- publicPort: z8.number().int(),
2300
+ publicPort: z10.number().int(),
2181
2301
  /** Its guide, as a URL. */
2182
- docs: z8.string().optional(),
2183
- 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() }),
2184
2304
  /**
2185
2305
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2186
2306
  * flag and a form field each, all optional, `default` in words.
2187
2307
  */
2188
- 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() })),
2189
2309
  /** A month of it running with the default storage, and each further GB of storage. */
2190
- price: PriceSchema.extend({ storageGibPerMonth: z8.number() }),
2310
+ price: PriceSchema.extend({ storageGibPerMonth: z10.number() }),
2191
2311
  /** Whether a host answering now can run it. */
2192
- available: z8.boolean()
2312
+ available: z10.boolean()
2193
2313
  });
2194
- var CreateManagedRequest = z8.object({
2195
- name: z8.string(),
2314
+ var CreateManagedRequest = z10.object({
2315
+ name: z10.string(),
2196
2316
  /** The kind's own options by name (its catalog entry lists them); the kind checks them. */
2197
- options: z8.record(z8.string(), z8.string()).optional(),
2198
- password: z8.string().optional(),
2199
- 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(),
2200
2320
  /** Place it on the host of this box, so the box can be linked to it. */
2201
- near: z8.string().optional(),
2321
+ near: z10.string().optional(),
2202
2322
  /**
2203
2323
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2204
2324
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2205
2325
  * are the backup's; the password is the new one.
2206
2326
  */
2207
- fromBackup: z8.string().optional()
2327
+ fromBackup: z10.string().optional()
2208
2328
  });
2209
- var ManagedHealthSchema = z8.object({
2329
+ var ManagedHealthSchema = z10.object({
2210
2330
  /** Its first start has finished: it has set itself up on its storage. */
2211
- ready: z8.boolean(),
2331
+ ready: z10.boolean(),
2212
2332
  /** It accepts connections. */
2213
- accepting: z8.boolean(),
2214
- version: z8.string(),
2333
+ accepting: z10.boolean(),
2334
+ version: z10.string(),
2215
2335
  /** The storage volume: what is used of it and its size. */
2216
- storageUsedBytes: z8.number().optional(),
2217
- storageTotalBytes: z8.number().optional(),
2336
+ storageUsedBytes: z10.number().optional(),
2337
+ storageTotalBytes: z10.number().optional(),
2218
2338
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2219
- facts: z8.array(z8.object({ title: z8.string(), value: z8.string() }))
2339
+ facts: z10.array(z10.object({ title: z10.string(), value: z10.string() }))
2220
2340
  });
2221
- var UrlsSchema = z8.object({ private: z8.string(), public: z8.string().optional() });
2222
- var ManagedSchema = z8.object({
2223
- kind: z8.string(),
2224
- 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(),
2225
2345
  /** The owning slug, bare. */
2226
- owner: z8.string(),
2227
- ownerKind: z8.enum(["user", "org"]),
2346
+ owner: z10.string(),
2347
+ ownerKind: z10.enum(["user", "org"]),
2228
2348
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2229
2349
  status: BoxStatusSchema,
2230
2350
  /** The catalog version: `18`. */
2231
- version: z8.string(),
2351
+ version: z10.string(),
2232
2352
  /** What the kind keeps of its create options, defaults filled in: `{database, user}` for Postgres, `{}` for a kind with none. */
2233
- settings: z8.record(z8.string(), z8.string()),
2234
- storageGib: z8.number().int(),
2353
+ settings: z10.record(z10.string(), z10.string()),
2354
+ storageGib: z10.number().int(),
2235
2355
  /** Where a linked box reaches it: `<name>.<slug>.kvbox` (resolves from a box of any slug it is linked to) and the port. */
2236
- private: z8.object({ host: z8.string(), port: z8.number().int() }),
2356
+ private: z10.object({ host: z10.string(), port: z10.number().int() }),
2237
2357
  /** Where the internet reaches it, null while it is not public. The port is its own for its whole life. */
2238
- public: z8.object({ host: z8.string(), port: z8.number().int() }).nullable(),
2358
+ public: z10.object({ host: z10.string(), port: z10.number().int() }).nullable(),
2239
2359
  /** The boxes linked to it, as the caller would name them. */
2240
- links: z8.array(z8.string()),
2360
+ links: z10.array(z10.string()),
2241
2361
  /** The name of the host it runs on, for `--near` and links. */
2242
- host: z8.string(),
2243
- country: z8.string().optional(),
2244
- createdBy: z8.string().nullable(),
2245
- createdAt: z8.string(),
2362
+ host: z10.string(),
2363
+ country: z10.string().optional(),
2364
+ createdBy: z10.string().nullable(),
2365
+ createdAt: z10.string(),
2246
2366
  /** Connection strings with the password as `****`. */
2247
2367
  urls: UrlsSchema,
2248
2368
  price: PriceSchema,
@@ -2251,230 +2371,230 @@ var ManagedSchema = z8.object({
2251
2371
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2252
2372
  health: ManagedHealthSchema.nullable().optional()
2253
2373
  });
2254
- var ManagedSecretSchema = z8.object({ password: z8.string(), urls: UrlsSchema });
2374
+ var ManagedSecretSchema = z10.object({ password: z10.string(), urls: UrlsSchema });
2255
2375
  var CreatedManagedSchema = ManagedSchema.extend({
2256
2376
  secret: ManagedSecretSchema,
2257
2377
  /** The backup it was made from (`fromBackup`), when it was. */
2258
- fromBackup: z8.string().optional()
2259
- });
2260
- var ResetPasswordRequest = z8.object({ password: z8.string().optional() });
2261
- var SetPublicRequest = z8.object({ on: z8.boolean() });
2262
- var ManagedLinkRequest = z8.object({ box: z8.string() });
2263
- var GrowManagedRequest = z8.object({ storageGib: z8.number().int() });
2264
- var ManagedBackupSchema = z8.object({
2265
- id: z8.string(),
2266
- owner: z8.string(),
2267
- kind: z8.string(),
2268
- name: z8.string(),
2269
- version: z8.string(),
2270
- 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),
2271
2391
  /** Why it failed; null otherwise. */
2272
- error: z8.string().nullable(),
2392
+ error: z10.string().nullable(),
2273
2393
  /** The service's storage when taken. */
2274
- diskBytes: z8.number().int().nullable(),
2394
+ diskBytes: z10.number().int().nullable(),
2275
2395
  /** What it holds: the slots that are not all zeros. */
2276
- dataBytes: z8.number().int().nullable(),
2396
+ dataBytes: z10.number().int().nullable(),
2277
2397
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2278
- uploadedBytes: z8.number().int().nullable(),
2398
+ uploadedBytes: z10.number().int().nullable(),
2279
2399
  /** Who asked for it; for a scheduled one, the database's creator. */
2280
- createdBy: z8.string().nullable(),
2400
+ createdBy: z10.string().nullable(),
2281
2401
  /** Started by the database's backup schedule, not by a person: it does not count toward the daily limit. */
2282
- scheduled: z8.boolean().default(false),
2283
- createdAt: z8.string(),
2284
- finishedAt: z8.string().nullable()
2402
+ scheduled: z10.boolean().default(false),
2403
+ createdAt: z10.string(),
2404
+ finishedAt: z10.string().nullable()
2285
2405
  });
2286
2406
 
2287
2407
  // ../shared/src/cron.ts
2288
- import { z as z9 } from "zod";
2408
+ import { z as z11 } from "zod";
2289
2409
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2290
2410
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2291
2411
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2292
2412
  var CRON_METHODS = ["GET", "POST"];
2293
2413
  var CRON_OUTCOMES = ["running", "ok", "failed", "timeout", "no-credit", "box-stopped", "host-down", "host-outdated", "lost", "still-running", "box-outdated"];
2294
- var CronServiceSchema = z9.object({
2295
- owner: z9.string(),
2296
- ownerKind: z9.enum(["user", "org"]),
2297
- name: z9.string(),
2414
+ var CronServiceSchema = z11.object({
2415
+ owner: z11.string(),
2416
+ ownerKind: z11.enum(["user", "org"]),
2417
+ name: z11.string(),
2298
2418
  /** Runs kept per trigger. */
2299
- keepRuns: z9.number().int(),
2300
- triggers: z9.number().int(),
2301
- createdBy: z9.string().nullable(),
2302
- createdAt: z9.string(),
2419
+ keepRuns: z11.number().int(),
2420
+ triggers: z11.number().int(),
2421
+ createdBy: z11.string().nullable(),
2422
+ createdAt: z11.string(),
2303
2423
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2304
- price: z9.object({ perMonth: z9.number(), currency: z9.string() }).optional()
2424
+ price: z11.object({ perMonth: z11.number(), currency: z11.string() }).optional()
2305
2425
  });
2306
2426
  var triggerCommon = {
2307
- id: z9.string(),
2308
- service: z9.string(),
2309
- owner: z9.string(),
2427
+ id: z11.string(),
2428
+ service: z11.string(),
2429
+ owner: z11.string(),
2310
2430
  /** The box it acts on; a trigger is removed with its box. */
2311
- box: z9.string(),
2431
+ box: z11.string(),
2312
2432
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2313
- expr: z9.string(),
2433
+ expr: z11.string(),
2314
2434
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2315
- timezone: z9.string(),
2435
+ timezone: z11.string(),
2316
2436
  /** False: paused, it fires again when resumed. */
2317
- enabled: z9.boolean(),
2437
+ enabled: z11.boolean(),
2318
2438
  /** When it fires next (ISO); null while paused. */
2319
- nextRunAt: z9.string().nullable(),
2320
- lastRunAt: z9.string().nullable(),
2321
- lastOutcome: z9.enum(CRON_OUTCOMES).nullable(),
2322
- createdBy: z9.string().nullable(),
2323
- 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()
2324
2444
  };
2325
- var CronHttpTriggerSchema = z9.object({
2445
+ var CronHttpTriggerSchema = z11.object({
2326
2446
  ...triggerCommon,
2327
- kind: z9.literal("http"),
2328
- method: z9.enum(CRON_METHODS),
2329
- port: z9.number().int(),
2447
+ kind: z11.literal("http"),
2448
+ method: z11.enum(CRON_METHODS),
2449
+ port: z11.number().int(),
2330
2450
  /** Path and query, starting with `/`. */
2331
- path: z9.string()
2451
+ path: z11.string()
2332
2452
  });
2333
- var CronCommandTriggerSchema = z9.object({
2453
+ var CronCommandTriggerSchema = z11.object({
2334
2454
  ...triggerCommon,
2335
- kind: z9.literal("command"),
2455
+ kind: z11.literal("command"),
2336
2456
  /** Run by a login shell as the box's user, in its home. */
2337
- command: z9.string(),
2457
+ command: z11.string(),
2338
2458
  /** The command is stopped after this long. */
2339
- timeoutSec: z9.number().int()
2459
+ timeoutSec: z11.number().int()
2340
2460
  });
2341
- var CronTriggerSchema = z9.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2342
- var CronRunSchema = z9.object({
2461
+ var CronTriggerSchema = z11.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2462
+ var CronRunSchema = z11.object({
2343
2463
  /** The slot this run was for (ISO); a run asked for by hand has the moment it was asked. */
2344
- scheduledFor: z9.string(),
2345
- startedAt: z9.string(),
2464
+ scheduledFor: z11.string(),
2465
+ startedAt: z11.string(),
2346
2466
  /** Null while `running`, and for a run that was never sent. */
2347
- durationMs: z9.number().int().nullable(),
2467
+ durationMs: z11.number().int().nullable(),
2348
2468
  /** The box's HTTP status; null when it never answered, and for a command. */
2349
- status: z9.number().int().nullable(),
2469
+ status: z11.number().int().nullable(),
2350
2470
  /** A command's exit code (128 + the signal when one ended it); null until it ends, and for a request. */
2351
- exitCode: z9.number().int().nullable(),
2471
+ exitCode: z11.number().int().nullable(),
2352
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. */
2353
- output: z9.string().nullable(),
2354
- outcome: z9.enum(CRON_OUTCOMES),
2473
+ output: z11.string().nullable(),
2474
+ outcome: z11.enum(CRON_OUTCOMES),
2355
2475
  /** Why it did not end `ok`, in a line. */
2356
- error: z9.string().nullable(),
2476
+ error: z11.string().nullable(),
2357
2477
  /** The box was hibernated and this run woke it. */
2358
- woke: z9.boolean()
2478
+ woke: z11.boolean()
2359
2479
  });
2360
- var CronCatalogSchema = z9.object({
2361
- price: z9.object({ perMonth: z9.number(), currency: z9.string() }),
2362
- maxServices: z9.number().int(),
2363
- maxTriggers: z9.number().int(),
2364
- 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(),
2365
2485
  /** The shortest time between two runs of one trigger, in seconds. */
2366
- minIntervalSeconds: z9.number().int(),
2486
+ minIntervalSeconds: z11.number().int(),
2367
2487
  /** How long a box has to answer, in seconds. */
2368
- timeoutSeconds: z9.number().int(),
2488
+ timeoutSeconds: z11.number().int(),
2369
2489
  /** How long a command may run: unless the trigger says, and at most. */
2370
- commandTimeoutSeconds: z9.number().int(),
2371
- maxCommandTimeoutSeconds: z9.number().int(),
2372
- docs: z9.string().optional()
2373
- });
2374
- var CreateCronServiceRequest = z9.object({ name: z9.string() });
2375
- var CreateCronTriggerRequest = z9.object({
2376
- box: z9.string().min(1),
2377
- expr: z9.string().min(1),
2378
- 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(),
2379
2499
  /** A request: `port`, with `method` and `path`. */
2380
- method: z9.enum(CRON_METHODS).optional(),
2381
- port: z9.number().int().min(1).max(65535).optional(),
2382
- 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(),
2383
2503
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2384
- command: z9.string().optional(),
2385
- timeoutSec: z9.number().int().optional()
2504
+ command: z11.string().optional(),
2505
+ timeoutSec: z11.number().int().optional()
2386
2506
  });
2387
- var UpdateCronTriggerRequest = z9.object({ enabled: z9.boolean() });
2507
+ var UpdateCronTriggerRequest = z11.object({ enabled: z11.boolean() });
2388
2508
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2389
2509
 
2390
2510
  // ../shared/src/storage.ts
2391
- import { z as z10 } from "zod";
2392
- var RegionSchema = z10.object({ name: z10.string(), country: z10.string().nullable() });
2511
+ import { z as z12 } from "zod";
2512
+ var RegionSchema = z12.object({ name: z12.string(), country: z12.string().nullable() });
2393
2513
  var MAX_PUBLIC_BUCKETS = 10;
2394
2514
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2395
- var ObjectStorageSchema = z10.object({
2396
- owner: z10.string(),
2397
- ownerKind: z10.enum(["user", "org"]),
2515
+ var ObjectStorageSchema = z12.object({
2516
+ owner: z12.string(),
2517
+ ownerKind: z12.enum(["user", "org"]),
2398
2518
  /** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
2399
- endpoint: z10.string().nullable(),
2519
+ endpoint: z12.string().nullable(),
2400
2520
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2401
- region: z10.string(),
2521
+ region: z12.string(),
2402
2522
  /** The most it may hold. */
2403
- sizeGib: z10.number().int(),
2523
+ sizeGib: z12.number().int(),
2404
2524
  /** `running` when it answers; `unknown` while its host is not heard from. */
2405
2525
  status: BoxStatusSchema,
2406
2526
  /** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
2407
- usedBytes: z10.number().optional(),
2408
- totalBytes: z10.number().optional(),
2527
+ usedBytes: z12.number().optional(),
2528
+ totalBytes: z12.number().optional(),
2409
2529
  /** With `?live=1`, when the storage answered: what each bucket holds. */
2410
- bucketUsage: z10.array(z10.object({ name: z10.string(), objects: z10.number(), bytes: z10.number() })).optional(),
2411
- host: z10.string(),
2412
- country: z10.string().optional(),
2413
- buckets: z10.number().int(),
2414
- price: z10.object({ perMonth: z10.number(), currency: z10.string() }),
2415
- createdAt: z10.string()
2416
- });
2417
- var BucketSchema = z10.object({
2418
- name: z10.string(),
2419
- owner: z10.string(),
2420
- ownerKind: z10.enum(["user", "org"]),
2421
- endpoint: z10.string().nullable(),
2422
- publicUrl: z10.string().optional(),
2423
- region: z10.string(),
2424
- keys: z10.number().int(),
2425
- objects: z10.number().optional(),
2426
- bytes: z10.number().optional(),
2427
- createdBy: z10.string().nullable(),
2428
- createdAt: z10.string()
2429
- });
2430
- var CreateBucketRequest = z10.object({
2431
- name: z10.string(),
2432
- sizeGib: z10.number().int().optional(),
2433
- near: z10.string().optional(),
2434
- region: z10.string().optional()
2435
- });
2436
- 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() });
2437
2557
  var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
2438
- var SetBucketPublicRequest = z10.object({ on: z10.boolean(), sub: z10.string().optional() });
2439
- var BucketKeySchema = z10.object({
2440
- id: z10.string(),
2441
- name: z10.string(),
2442
- bucket: z10.string(),
2443
- owner: z10.string(),
2444
- readOnly: z10.boolean(),
2445
- createdBy: z10.string().nullable(),
2446
- createdAt: z10.string()
2447
- });
2448
- var CreateBucketKeyRequest = z10.object({ name: z10.string().optional(), readOnly: z10.boolean().optional() });
2449
- var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z10.string(), endpoint: z10.string().nullable(), region: z10.string() });
2450
- var GrowStorageRequest = z10.object({ sizeGib: z10.number().int() });
2451
- var StorageBackupSchema = z10.object({
2452
- id: z10.string(),
2453
- owner: z10.string(),
2454
- 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),
2455
2575
  /** Why it failed; null otherwise. */
2456
- error: z10.string().nullable(),
2576
+ error: z12.string().nullable(),
2457
2577
  /** The storage's volume when taken. */
2458
- diskBytes: z10.number().int().nullable(),
2578
+ diskBytes: z12.number().int().nullable(),
2459
2579
  /** What it holds: the slots that are not all zeros. */
2460
- dataBytes: z10.number().int().nullable(),
2580
+ dataBytes: z12.number().int().nullable(),
2461
2581
  /** What this backup added to the backup store (encrypted, compressed). */
2462
- uploadedBytes: z10.number().int().nullable(),
2582
+ uploadedBytes: z12.number().int().nullable(),
2463
2583
  /** The buckets it holds, and how many access keys they had, as kvbox knew them when it was taken. */
2464
- buckets: z10.array(z10.string()),
2465
- keys: z10.number().int(),
2466
- createdBy: z10.string().nullable(),
2467
- createdAt: z10.string(),
2468
- finishedAt: z10.string().nullable()
2469
- });
2470
- var RestoredKeySchema = z10.object({ bucket: z10.string(), id: z10.string(), name: z10.string() });
2471
- var StorageRestoreSchema = z10.object({
2472
- 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(),
2473
2593
  storage: ObjectStorageSchema,
2474
- buckets: z10.object({ kept: z10.array(z10.string()), returned: z10.array(z10.string()), removed: z10.array(z10.string()) }),
2475
- keys: z10.object({ dropped: z10.array(RestoredKeySchema), revoked: z10.array(RestoredKeySchema) }),
2476
- checked: z10.boolean(),
2477
- 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())
2478
2598
  });
2479
2599
  var OBJECT_LIST_MAX = 1e3;
2480
2600
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2484,56 +2604,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2484
2604
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2485
2605
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2486
2606
  var DELETE_PREFIXES_MAX = 100;
2487
- var StoredObjectSchema = z10.object({
2488
- key: z10.string(),
2489
- size: z10.number(),
2490
- etag: z10.string(),
2607
+ var StoredObjectSchema = z12.object({
2608
+ key: z12.string(),
2609
+ size: z12.number(),
2610
+ etag: z12.string(),
2491
2611
  /** ISO 8601. */
2492
- modified: z10.string()
2493
- });
2494
- var ObjectListingSchema = z10.object({
2495
- prefix: z10.string(),
2496
- folders: z10.array(z10.string()),
2497
- objects: z10.array(StoredObjectSchema),
2498
- next: z10.string().optional(),
2499
- canWrite: z10.boolean()
2500
- });
2501
- var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z10.string() });
2502
- var ObjectCountSchema = z10.object({ objects: z10.number(), bytes: z10.number(), more: z10.boolean() });
2503
- var ObjectLinkRequest = z10.object({
2504
- key: z10.string(),
2505
- 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(),
2506
2626
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2507
- download: z10.boolean().optional(),
2627
+ download: z12.boolean().optional(),
2508
2628
  /**
2509
2629
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2510
2630
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2511
2631
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2512
2632
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2513
2633
  */
2514
- cached: z10.boolean().optional()
2634
+ cached: z12.boolean().optional()
2515
2635
  });
2516
- var ObjectLinkSchema = z10.object({ url: z10.string(), expiresAt: z10.string() });
2636
+ var ObjectLinkSchema = z12.object({ url: z12.string(), expiresAt: z12.string() });
2517
2637
  var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
2518
- 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() });
2519
- var UploadPlanSchema = z10.discriminatedUnion("kind", [
2520
- z10.object({ kind: z10.literal("single"), url: z10.string() }),
2521
- 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()) })
2522
2642
  ]);
2523
- var CompleteUploadRequest = z10.object({
2524
- key: z10.string(),
2525
- uploadId: z10.string(),
2526
- 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)
2527
2647
  });
2528
- var AbortUploadRequest = z10.object({ key: z10.string(), uploadId: z10.string() });
2529
- var DeleteObjectsRequest = z10.object({ keys: z10.array(z10.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z10.array(z10.string()).max(DELETE_PREFIXES_MAX).optional() });
2530
- var DeletedObjectsSchema = z10.object({
2531
- deleted: z10.number(),
2532
- more: z10.boolean(),
2533
- 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() }))
2534
2654
  });
2535
- var MoveObjectRequest = z10.object({ from: z10.string(), to: z10.string(), overwrite: z10.boolean().optional() });
2536
- 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() });
2537
2657
 
2538
2658
  // src/kvm.ts
2539
2659
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2647,7 +2767,7 @@ var ServerClient = class {
2647
2767
  startedOnce = false;
2648
2768
  async call(method, path, schema, body, org = this.target.kind === "cloud" ? this.target.org : void 0, timeoutMs) {
2649
2769
  try {
2650
- 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 });
2651
2771
  } catch (err) {
2652
2772
  return this.failed(err, () => this.call(method, path, schema, body, org, timeoutMs));
2653
2773
  }
@@ -2703,7 +2823,7 @@ var ServerClient = class {
2703
2823
  * `all`: every box on the platform (platform admins only, #78).
2704
2824
  */
2705
2825
  listMachines(opts = {}) {
2706
- 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);
2707
2827
  }
2708
2828
  createMachine(req) {
2709
2829
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -2757,10 +2877,10 @@ var ServerClient = class {
2757
2877
  }
2758
2878
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
2759
2879
  listBackups() {
2760
- return this.call("GET", "/backups", z11.array(BackupSchema));
2880
+ return this.call("GET", "/backups", z13.array(BackupSchema));
2761
2881
  }
2762
2882
  boxBackups(name) {
2763
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z11.array(BackupSchema));
2883
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z13.array(BackupSchema));
2764
2884
  }
2765
2885
  boxBackup(name, id) {
2766
2886
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -2774,14 +2894,14 @@ var ServerClient = class {
2774
2894
  * later. Works for a backup whose box, volume or database is gone too.
2775
2895
  */
2776
2896
  removeBackup(id) {
2777
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z11.undefined());
2897
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z13.undefined());
2778
2898
  }
2779
2899
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
2780
2900
  listVolumeBackups() {
2781
- return this.call("GET", "/backups?kind=volume", z11.array(VolumeBackupSchema));
2901
+ return this.call("GET", "/backups?kind=volume", z13.array(VolumeBackupSchema));
2782
2902
  }
2783
2903
  volumeBackups(name) {
2784
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z11.array(VolumeBackupSchema));
2904
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z13.array(VolumeBackupSchema));
2785
2905
  }
2786
2906
  volumeBackup(name, id) {
2787
2907
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -2800,7 +2920,7 @@ var ServerClient = class {
2800
2920
  }
2801
2921
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
2802
2922
  boxHooks(name) {
2803
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z11.array(WakeHookSchema));
2923
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z13.array(WakeHookSchema));
2804
2924
  }
2805
2925
  createBoxHook(name) {
2806
2926
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -2828,7 +2948,7 @@ var ServerClient = class {
2828
2948
  }
2829
2949
  /** Every readable box's subdomains, one entry each. */
2830
2950
  listSubdomains() {
2831
- return this.call("GET", "/subdomains", z11.array(SubdomainSchema));
2951
+ return this.call("GET", "/subdomains", z13.array(SubdomainSchema));
2832
2952
  }
2833
2953
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
2834
2954
  addDomain(name, req) {
@@ -2839,7 +2959,7 @@ var ServerClient = class {
2839
2959
  }
2840
2960
  /** Every readable box's custom domains. */
2841
2961
  listDomains() {
2842
- return this.call("GET", "/domains", z11.array(DomainSchema));
2962
+ return this.call("GET", "/domains", z13.array(DomainSchema));
2843
2963
  }
2844
2964
  /** A running box's own load, memory and disk, asked of its guest (#67). */
2845
2965
  machineStats(name) {
@@ -2872,22 +2992,22 @@ var ServerClient = class {
2872
2992
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
2873
2993
  }
2874
2994
  deleteMachine(name) {
2875
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z11.undefined());
2995
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z13.undefined());
2876
2996
  }
2877
2997
  /** Like `listMachines`, for snapshots. */
2878
2998
  listSnapshots(opts = {}) {
2879
- 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);
2880
3000
  }
2881
3001
  createSnapshot(req) {
2882
3002
  return this.call("POST", "/snapshots", SnapshotSchema, req);
2883
3003
  }
2884
3004
  deleteSnapshot(name) {
2885
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z11.undefined());
3005
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z13.undefined());
2886
3006
  }
2887
3007
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
2888
3008
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
2889
3009
  listEnv(org) {
2890
- return this.call("GET", "/vars", z11.array(EnvVarSchema), void 0, org);
3010
+ return this.call("GET", "/vars", z13.array(EnvVarSchema), void 0, org);
2891
3011
  }
2892
3012
  setEnv(name, req) {
2893
3013
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -2907,13 +3027,13 @@ var ServerClient = class {
2907
3027
  }
2908
3028
  // ---- volumes (#52) ----
2909
3029
  listVolumes(opts = {}) {
2910
- 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);
2911
3031
  }
2912
3032
  createVolume(req) {
2913
3033
  return this.call("POST", "/volumes", VolumeSchema, req);
2914
3034
  }
2915
3035
  deleteVolume(name) {
2916
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z11.undefined());
3036
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z13.undefined());
2917
3037
  }
2918
3038
  /** Both answer with the box as it is afterwards (restarted when it was running). */
2919
3039
  attachVolume(name, req) {
@@ -2928,7 +3048,7 @@ var ServerClient = class {
2928
3048
  }
2929
3049
  // ---- cron service (#190): the control plane's alone ----
2930
3050
  listCronServices(opts = {}) {
2931
- 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);
2932
3052
  }
2933
3053
  createCronService(name) {
2934
3054
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -2937,10 +3057,10 @@ var ServerClient = class {
2937
3057
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
2938
3058
  }
2939
3059
  deleteCronService(name) {
2940
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z11.undefined());
3060
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z13.undefined());
2941
3061
  }
2942
3062
  listCronTriggers(service) {
2943
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z11.array(CronTriggerSchema));
3063
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z13.array(CronTriggerSchema));
2944
3064
  }
2945
3065
  addCronTrigger(service, req) {
2946
3066
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -2950,18 +3070,18 @@ var ServerClient = class {
2950
3070
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
2951
3071
  }
2952
3072
  deleteCronTrigger(service, id) {
2953
- 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());
2954
3074
  }
2955
3075
  /** Marks it due: kvbox-cron fires it within a few seconds. */
2956
3076
  runCronTrigger(service, id) {
2957
3077
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
2958
3078
  }
2959
3079
  listCronRuns(service, id, limit) {
2960
- 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));
2961
3081
  }
2962
3082
  // ---- object storage (#182): the control plane's alone ----
2963
3083
  listBuckets(opts = {}) {
2964
- 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);
2965
3085
  }
2966
3086
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
2967
3087
  createBucket(req) {
@@ -2975,26 +3095,26 @@ var ServerClient = class {
2975
3095
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
2976
3096
  }
2977
3097
  deleteBucket(name, force = false) {
2978
- 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());
2979
3099
  }
2980
3100
  listBucketKeys(name) {
2981
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z11.array(BucketKeySchema));
3101
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z13.array(BucketKeySchema));
2982
3102
  }
2983
3103
  createBucketKey(name, req) {
2984
3104
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
2985
3105
  }
2986
3106
  deleteBucketKey(name, id) {
2987
- 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());
2988
3108
  }
2989
3109
  listStorage(opts = {}) {
2990
- 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);
2991
3111
  }
2992
3112
  growStorage(sizeGib) {
2993
3113
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
2994
3114
  }
2995
3115
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
2996
3116
  storageBackups() {
2997
- return this.call("GET", "/storage/backups", z11.array(StorageBackupSchema));
3117
+ return this.call("GET", "/storage/backups", z13.array(StorageBackupSchema));
2998
3118
  }
2999
3119
  storageBackup(id) {
3000
3120
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -3015,11 +3135,11 @@ var ServerClient = class {
3015
3135
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3016
3136
  }
3017
3137
  managedCatalog() {
3018
- return this.call("GET", "/managed/catalog", z11.array(ManagedCatalogEntrySchema));
3138
+ return this.call("GET", "/managed/catalog", z13.array(ManagedCatalogEntrySchema));
3019
3139
  }
3020
3140
  /** One kind's services, or every kind's when `kind` is left out. */
3021
3141
  listManaged(kind, opts = {}) {
3022
- 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);
3023
3143
  }
3024
3144
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3025
3145
  createManaged(kind, req) {
@@ -3030,7 +3150,7 @@ var ServerClient = class {
3030
3150
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3031
3151
  }
3032
3152
  deleteManaged(kind, name) {
3033
- return this.call("DELETE", this.managedPath(kind, name), z11.undefined());
3153
+ return this.call("DELETE", this.managedPath(kind, name), z13.undefined());
3034
3154
  }
3035
3155
  managedPassword(kind, name) {
3036
3156
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3052,10 +3172,10 @@ var ServerClient = class {
3052
3172
  }
3053
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. */
3054
3174
  listManagedBackups(kind) {
3055
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z11.array(ManagedBackupSchema));
3175
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z13.array(ManagedBackupSchema));
3056
3176
  }
3057
3177
  managedBackups(kind, name) {
3058
- 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));
3059
3179
  }
3060
3180
  managedBackup(kind, name, id) {
3061
3181
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3097,24 +3217,36 @@ var ServerClient = class {
3097
3217
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3098
3218
  }
3099
3219
  logout() {
3100
- return this.call("POST", "/logout", z11.unknown()).then(() => void 0);
3220
+ return this.call("POST", "/logout", z13.unknown()).then(() => void 0);
3101
3221
  }
3102
3222
  me() {
3103
3223
  return this.call("GET", "/me", MeResponseSchema);
3104
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
+ }
3105
3237
  // ---- API keys (`kvbox key …`, #189) ----
3106
3238
  listApiKeys() {
3107
- return this.call("GET", "/keys", z11.array(ApiKeySchema));
3239
+ return this.call("GET", "/keys", z13.array(ApiKeySchema));
3108
3240
  }
3109
3241
  createApiKey(req) {
3110
3242
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3111
3243
  }
3112
3244
  deleteApiKey(name) {
3113
- 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);
3114
3246
  }
3115
3247
  // ---- orgs (`kvbox org …`) ----
3116
3248
  listOrgs() {
3117
- return this.call("GET", "/orgs", z11.array(OrgMembershipSchema));
3249
+ return this.call("GET", "/orgs", z13.array(OrgMembershipSchema));
3118
3250
  }
3119
3251
  createOrg(req) {
3120
3252
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3123,16 +3255,16 @@ var ServerClient = class {
3123
3255
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3124
3256
  }
3125
3257
  deleteOrg(slug) {
3126
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z11.undefined());
3258
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z13.undefined());
3127
3259
  }
3128
3260
  addMember(slug, req) {
3129
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z11.undefined(), req);
3261
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z13.undefined(), req);
3130
3262
  }
3131
3263
  setRole(slug, username, role) {
3132
- 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);
3133
3265
  }
3134
3266
  removeMember(slug, username) {
3135
- 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());
3136
3268
  }
3137
3269
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3138
3270
  sshCert(req) {
@@ -3564,10 +3696,47 @@ function parseDuration(text2) {
3564
3696
  return sec;
3565
3697
  }
3566
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
+
3567
3735
  // src/commands/vm/new.ts
3568
- 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("--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) => {
3569
3737
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
3570
3738
  const env = parseEnvFlags(opts.env);
3739
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
3571
3740
  const country = opts.country === void 0 ? void 0 : parseCountry(opts.country);
3572
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");
3573
3742
  if (opts.fromBackup !== void 0) {
@@ -3600,6 +3769,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3600
3769
  ...country !== void 0 ? { country } : {},
3601
3770
  ...opts.host !== void 0 ? { host: opts.host } : {},
3602
3771
  ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
3772
+ ...integrations !== void 0 ? { integrations } : {},
3603
3773
  ...opts.force ? { force: true } : {}
3604
3774
  }));
3605
3775
  if (opts.fromBackup !== void 0 && !box2.source.startsWith("backup:")) {
@@ -3609,6 +3779,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3609
3779
  if (opts.base !== void 0 && opts.base !== "base" && box2.image === void 0) {
3610
3780
  warn(`box ${box2.name}: its host runs a kvbox-server too old for images; it booted the base image, not ${opts.base}`);
3611
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`);
3612
3783
  if (env.length > 0) {
3613
3784
  const kept = await keptVars(client, displayName(box2, me(client)), env.map((v) => v.name));
3614
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`);
@@ -3626,6 +3797,10 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3626
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)`);
3627
3798
  else info(` connect with: kvbox connect ${displayName(box2, user)} (SSH is up a couple of seconds after boot)`);
3628
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
+ }
3629
3804
  if (box2.connect !== void 0) {
3630
3805
  info(` reach it at: ${box2.connect}`);
3631
3806
  info(` from another box once linked: kvbox vm link <box> ${displayName(box2, user)} --port <port>`);
@@ -4036,6 +4211,7 @@ function getRows(box2, subs, user) {
4036
4211
  const quiet = box2.idleCheck === void 0 ? "without network traffic" : `idle by ${box2.idleCheck}`;
4037
4212
  rows2.push(["auto-hibernate", box2.autoHibernateSec ? `after ${duration(box2.autoHibernateSec)} ${quiet}` : "off"]);
4038
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(", ") : "-"]);
4039
4215
  rows2.push(["source", box2.source]);
4040
4216
  rows2.push(["base", box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`]);
4041
4217
  rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
@@ -4871,14 +5047,16 @@ function runSwap(ep, mib) {
4871
5047
  }
4872
5048
 
4873
5049
  // src/commands/vm/set.ts
4874
- 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) => {
4875
- if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.swap === void 0) {
4876
- 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");
4877
5053
  }
5054
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
4878
5055
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
4879
5056
  const idleCheck = opts.idleCheck === void 0 ? void 0 : parseIdleCheck(opts.idleCheck);
4880
5057
  const swapMib = opts.swap === void 0 ? void 0 : parseSwap(opts.swap);
4881
- const hostSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5058
+ const idleSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5059
+ const hostSettings = idleSettings || integrations !== void 0;
4882
5060
  const client = await clientFor(cmd.optsWithGlobals());
4883
5061
  try {
4884
5062
  const found = pickRef(await boxesFor(client, name), name, me(client));
@@ -4886,7 +5064,10 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4886
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})`);
4887
5065
  let box2 = found;
4888
5066
  if (hostSettings) {
4889
- 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
+ }
4890
5071
  if (!idleCheckKept(idleCheck, box2)) {
4891
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)" : ""}`);
4892
5073
  }
@@ -4896,7 +5077,11 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4896
5077
  json(swap === void 0 ? box2 : { ...box2, swap });
4897
5078
  return;
4898
5079
  }
4899
- 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
+ }
4900
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`));
4901
5086
  if (swap) info(`${color.green("\u2713")} box ${color.bold(name)}: ${swapText(swap)}`);
4902
5087
  } finally {
@@ -5403,12 +5588,48 @@ var rmCommand5 = new Command45("rm").alias("remove").description("remove an API
5403
5588
  // src/commands/key/index.ts
5404
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);
5405
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
+
5406
5627
  // src/commands/snapshots/index.ts
5407
- import { Command as Command50 } from "commander";
5628
+ import { Command as Command52 } from "commander";
5408
5629
 
5409
5630
  // src/commands/snapshots/ls.ts
5410
- import { Command as Command47 } from "commander";
5411
- 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) => {
5412
5633
  const client = await clientFor(cmd.optsWithGlobals());
5413
5634
  try {
5414
5635
  const cloud = client.target.kind === "cloud";
@@ -5439,8 +5660,8 @@ var lsCommand6 = new Command47("ls").description("list snapshots (yours and your
5439
5660
  });
5440
5661
 
5441
5662
  // src/commands/snapshots/new.ts
5442
- import { Command as Command48 } from "commander";
5443
- 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) => {
5444
5665
  const client = await clientFor(cmd.optsWithGlobals());
5445
5666
  try {
5446
5667
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5453,8 +5674,8 @@ var newCommand2 = new Command48("new").description("freeze a running box (memory
5453
5674
  });
5454
5675
 
5455
5676
  // src/commands/snapshots/rm.ts
5456
- import { Command as Command49 } from "commander";
5457
- 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) => {
5458
5679
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5459
5680
  info("cancelled");
5460
5681
  process.exitCode = 1;
@@ -5470,14 +5691,14 @@ var rmCommand6 = new Command49("rm").description("delete a snapshot (boxes made
5470
5691
  });
5471
5692
 
5472
5693
  // src/commands/snapshots/index.ts
5473
- 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);
5474
5695
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5475
5696
 
5476
5697
  // src/commands/org/index.ts
5477
- import { Command as Command56 } from "commander";
5698
+ import { Command as Command58 } from "commander";
5478
5699
 
5479
5700
  // src/commands/org/ls.ts
5480
- import { Command as Command51 } from "commander";
5701
+ import { Command as Command53 } from "commander";
5481
5702
 
5482
5703
  // src/commands/org/context.ts
5483
5704
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -5497,7 +5718,7 @@ function orgFor(opts, target) {
5497
5718
  }
5498
5719
 
5499
5720
  // src/commands/org/ls.ts
5500
- 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) => {
5501
5722
  const client = await cloudClientFor(cmd.optsWithGlobals());
5502
5723
  try {
5503
5724
  const orgs = await client.listOrgs();
@@ -5519,8 +5740,8 @@ function orgRows(orgs) {
5519
5740
  }
5520
5741
 
5521
5742
  // src/commands/org/members.ts
5522
- import { Command as Command52, Option as Option4 } from "commander";
5523
- 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) => {
5524
5745
  const client = await cloudClientFor(cmd.optsWithGlobals());
5525
5746
  try {
5526
5747
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -5534,7 +5755,7 @@ var lsCommand8 = new Command52("ls").description("list an org's members and thei
5534
5755
  await client.close();
5535
5756
  }
5536
5757
  });
5537
- 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) => {
5538
5759
  const client = await cloudClientFor(cmd.optsWithGlobals());
5539
5760
  try {
5540
5761
  const slug = orgFor(opts, client.target);
@@ -5544,7 +5765,7 @@ var addCommand2 = new Command52("add").description("add a user to an org (admins
5544
5765
  await client.close();
5545
5766
  }
5546
5767
  });
5547
- 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) => {
5548
5769
  const client = await cloudClientFor(cmd.optsWithGlobals());
5549
5770
  try {
5550
5771
  const slug = orgFor(opts, client.target);
@@ -5560,11 +5781,11 @@ var rmCommand7 = new Command52("rm").description("remove a member (or leave: rem
5560
5781
  await client.close();
5561
5782
  }
5562
5783
  });
5563
- 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);
5564
5785
 
5565
5786
  // src/commands/org/new.ts
5566
- import { Command as Command53 } from "commander";
5567
- 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) => {
5568
5789
  const client = await cloudClientFor(cmd.optsWithGlobals());
5569
5790
  try {
5570
5791
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -5580,8 +5801,8 @@ var newCommand3 = new Command53("new").description("create an org; you become it
5580
5801
  });
5581
5802
 
5582
5803
  // src/commands/org/rm.ts
5583
- import { Command as Command54 } from "commander";
5584
- 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) => {
5585
5806
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
5586
5807
  info("cancelled");
5587
5808
  process.exitCode = 1;
@@ -5597,8 +5818,8 @@ var rmCommand8 = new Command54("rm").description("delete an org (owners only; re
5597
5818
  });
5598
5819
 
5599
5820
  // src/commands/org/role.ts
5600
- import { Argument, Command as Command55 } from "commander";
5601
- 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) => {
5602
5823
  const client = await cloudClientFor(cmd.optsWithGlobals());
5603
5824
  try {
5604
5825
  const slug = orgFor(opts, client.target);
@@ -5610,11 +5831,11 @@ var roleCommand = new Command55("role").description("change a member's role (own
5610
5831
  });
5611
5832
 
5612
5833
  // src/commands/org/index.ts
5613
- 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);
5614
5835
 
5615
5836
  // src/commands/usage.ts
5616
- import { Command as Command57 } from "commander";
5617
- 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) => {
5618
5839
  for (const [name, value] of [
5619
5840
  ["since", opts.since],
5620
5841
  ["until", opts.until]
@@ -5811,8 +6032,8 @@ function userRows(r) {
5811
6032
  }
5812
6033
 
5813
6034
  // src/commands/credit.ts
5814
- import { Command as Command58 } from "commander";
5815
- 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) => {
5816
6037
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5817
6038
  try {
5818
6039
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -5841,8 +6062,8 @@ function creditRow(b, me2) {
5841
6062
  }
5842
6063
 
5843
6064
  // src/commands/redeem.ts
5844
- import { Command as Command59 } from "commander";
5845
- 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) => {
5846
6067
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5847
6068
  try {
5848
6069
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -5862,12 +6083,12 @@ var redeemCommand = new Command59("redeem").description("redeem a promo code for
5862
6083
  // src/commands/deploy/index.ts
5863
6084
  import { access as access5, readFile as readFile7 } from "fs/promises";
5864
6085
  import { basename as basename2, resolve as resolve3 } from "path";
5865
- 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";
5866
6087
 
5867
6088
  // src/commands/deploy/config.ts
5868
6089
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
5869
6090
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
5870
- import { z as z12 } from "zod";
6091
+ import { z as z14 } from "zod";
5871
6092
 
5872
6093
  // src/commands/deploy/templates/docker.ts
5873
6094
  import { readFile as readFile4 } from "fs/promises";
@@ -6291,21 +6512,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6291
6512
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6292
6513
  var CONFIG_FILE = "kvbox.json";
6293
6514
  var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
6294
- var DeployConfigSchema = z12.object({
6295
- template: z12.enum(TEMPLATE_IDS),
6296
- 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"),
6297
6518
  /** The org whose box it is; absent for the user's own. */
6298
- 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(),
6299
6520
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6300
- subdomain: z12.string().check((ctx) => {
6521
+ subdomain: z14.string().check((ctx) => {
6301
6522
  const problem = subdomainProblem(ctx.value);
6302
6523
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6303
6524
  }).optional(),
6304
- size: z12.enum(SIZE_NAMES).optional(),
6525
+ size: z14.enum(SIZE_NAMES).optional(),
6305
6526
  /** The build output directory, relative to the app; the template's default when absent. */
6306
- dist: z12.string().optional(),
6527
+ dist: z14.string().optional(),
6307
6528
  /** The port a Next.js app or Node server serves; the template's (3000) when absent. */
6308
- port: z12.number().int().min(1).max(65535).optional()
6529
+ port: z14.number().int().min(1).max(65535).optional()
6309
6530
  });
6310
6531
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6311
6532
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6317,38 +6538,38 @@ var POSTGRES_PORT = 5432;
6317
6538
  var POSTGRES_IMAGE = "postgres:17";
6318
6539
  var POSTGRES_ENV = "DATABASE_URL";
6319
6540
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6320
- var ServiceSchema = z12.strictObject({
6321
- template: z12.enum([...TEMPLATE_IDS, POSTGRES]),
6541
+ var ServiceSchema = z14.strictObject({
6542
+ template: z14.enum([...TEMPLATE_IDS, POSTGRES]),
6322
6543
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6323
- dir: z12.string().min(1).optional(),
6544
+ dir: z14.string().min(1).optional(),
6324
6545
  /** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
6325
- 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(),
6326
6547
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6327
- volume: z12.string().optional(),
6548
+ volume: z14.string().optional(),
6328
6549
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6329
- env: z12.string().optional(),
6550
+ env: z14.string().optional(),
6330
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`. */
6331
- context: z12.string().min(1).optional(),
6332
- dist: z12.string().optional(),
6552
+ context: z14.string().min(1).optional(),
6553
+ dist: z14.string().optional(),
6333
6554
  /**
6334
6555
  * A command run once per deploy in the service's new version (a docker service: in a container of
6335
6556
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6336
6557
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6337
6558
  */
6338
- release: z12.string().optional(),
6559
+ release: z14.string().optional(),
6339
6560
  /** The box port of a service with its own server; the template's (3000) when absent. */
6340
- port: z12.number().int().min(1).max(65535).optional(),
6561
+ port: z14.number().int().min(1).max(65535).optional(),
6341
6562
  /** The URL paths that go to this service, each with everything under it; the prefix is kept. */
6342
- 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()
6343
6564
  });
6344
- var StackConfigSchema = z12.strictObject({
6565
+ var StackConfigSchema = z14.strictObject({
6345
6566
  name: DeployConfigSchema.shape.name.optional(),
6346
6567
  org: DeployConfigSchema.shape.org,
6347
6568
  subdomain: DeployConfigSchema.shape.subdomain,
6348
6569
  size: DeployConfigSchema.shape.size,
6349
6570
  /** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
6350
- volumes: z12.record(z12.string(), z12.string()).optional(),
6351
- services: z12.record(z12.string(), ServiceSchema)
6571
+ volumes: z14.record(z14.string(), z14.string()).optional(),
6572
+ services: z14.record(z14.string(), ServiceSchema)
6352
6573
  });
6353
6574
  function volumeGib(text2) {
6354
6575
  const mib = parseMib(text2);
@@ -7127,7 +7348,7 @@ async function readPackageJson(dir) {
7127
7348
  }
7128
7349
 
7129
7350
  // src/commands/deploy/index.ts
7130
- 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) => {
7131
7352
  const dir = resolve3(dirArg ?? ".");
7132
7353
  const pkg = await readPackageJson2(dir);
7133
7354
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7284,15 +7505,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7284
7505
  }
7285
7506
 
7286
7507
  // src/commands/volume/index.ts
7287
- import { Command as Command72 } from "commander";
7508
+ import { Command as Command74 } from "commander";
7288
7509
 
7289
7510
  // src/commands/volume/attach.ts
7290
- import { Command as Command61 } from "commander";
7511
+ import { Command as Command63 } from "commander";
7291
7512
  function describeMount(machine, volume2, box2) {
7292
7513
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7293
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`;
7294
7515
  }
7295
- 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) => {
7296
7517
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7297
7518
  const client = await clientFor(cmd.optsWithGlobals());
7298
7519
  try {
@@ -7311,11 +7532,11 @@ var attachCommand = new Command61("attach").description("attach a volume to a bo
7311
7532
  });
7312
7533
 
7313
7534
  // src/commands/volume/backup/index.ts
7314
- import { Command as Command66 } from "commander";
7535
+ import { Command as Command68 } from "commander";
7315
7536
 
7316
7537
  // src/commands/volume/backup/create.ts
7317
- import { Command as Command62 } from "commander";
7318
- 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) => {
7319
7540
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7320
7541
  try {
7321
7542
  requireCloud3(client);
@@ -7342,8 +7563,8 @@ var createCommand4 = new Command62("create").description("back up a volume's dis
7342
7563
  });
7343
7564
 
7344
7565
  // src/commands/volume/backup/ls.ts
7345
- import { Command as Command63 } from "commander";
7346
- 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) => {
7347
7568
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7348
7569
  try {
7349
7570
  requireCloud3(client);
@@ -7376,8 +7597,8 @@ var lsCommand9 = new Command63("ls").alias("list").description("list volume back
7376
7597
  });
7377
7598
 
7378
7599
  // src/commands/volume/backup/restore.ts
7379
- import { Command as Command64 } from "commander";
7380
- 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) => {
7381
7602
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7382
7603
  try {
7383
7604
  requireCloud3(client);
@@ -7400,8 +7621,8 @@ var restoreCommand2 = new Command64("restore").description("put a backup back: t
7400
7621
  });
7401
7622
 
7402
7623
  // src/commands/volume/backup/rm.ts
7403
- import { Command as Command65 } from "commander";
7404
- 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) => {
7405
7626
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7406
7627
  try {
7407
7628
  requireCloud3(client);
@@ -7412,11 +7633,11 @@ var rmCommand9 = new Command65("rm").alias("remove").description("remove a backu
7412
7633
  });
7413
7634
 
7414
7635
  // src/commands/volume/backup/index.ts
7415
- 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);
7416
7637
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7417
7638
 
7418
7639
  // src/commands/volume/create.ts
7419
- import { Command as Command67 } from "commander";
7640
+ import { Command as Command69 } from "commander";
7420
7641
  function parseGib2(text2, label = "--size") {
7421
7642
  const mib = parseMib(text2);
7422
7643
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
@@ -7432,7 +7653,7 @@ function sizeProblem(answer) {
7432
7653
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7433
7654
  }
7434
7655
  }
7435
- 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) => {
7436
7657
  const ask = interactive();
7437
7658
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7438
7659
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -7465,8 +7686,8 @@ var createCommand5 = new Command67("create").alias("new").description("create a
7465
7686
  });
7466
7687
 
7467
7688
  // src/commands/volume/detach.ts
7468
- import { Command as Command68 } from "commander";
7469
- 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) => {
7470
7691
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
7471
7692
  const client = await clientFor(cmd.optsWithGlobals());
7472
7693
  try {
@@ -7491,8 +7712,8 @@ var detachCommand = new Command68("detach").description("detach a volume from a
7491
7712
  });
7492
7713
 
7493
7714
  // src/commands/volume/grow.ts
7494
- import { Command as Command69 } from "commander";
7495
- 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) => {
7496
7717
  const sizeGib = parseGib2(size, "size");
7497
7718
  const client = await clientFor(cmd.optsWithGlobals());
7498
7719
  try {
@@ -7505,8 +7726,8 @@ var growCommand = new Command69("grow").alias("resize").description("make a volu
7505
7726
  });
7506
7727
 
7507
7728
  // src/commands/volume/ls.ts
7508
- import { Command as Command70 } from "commander";
7509
- 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) => {
7510
7731
  const client = await clientFor(cmd.optsWithGlobals());
7511
7732
  try {
7512
7733
  const cloud = client.target.kind === "cloud";
@@ -7537,8 +7758,8 @@ var lsCommand10 = new Command70("ls").alias("list").description("list volumes: s
7537
7758
  });
7538
7759
 
7539
7760
  // src/commands/volume/rm.ts
7540
- import { Command as Command71 } from "commander";
7541
- 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) => {
7542
7763
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
7543
7764
  info("cancelled");
7544
7765
  process.exitCode = 1;
@@ -7554,18 +7775,18 @@ var rmCommand10 = new Command71("rm").alias("remove").description("delete a volu
7554
7775
  });
7555
7776
 
7556
7777
  // src/commands/volume/index.ts
7557
- 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);
7558
7779
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7559
7780
  volumeCommand.addCommand(backupCommand2);
7560
7781
 
7561
7782
  // src/commands/bucket/index.ts
7562
- import { Command as Command88 } from "commander";
7783
+ import { Command as Command90 } from "commander";
7563
7784
 
7564
7785
  // src/commands/bucket/backup/index.ts
7565
- import { Command as Command77 } from "commander";
7786
+ import { Command as Command79 } from "commander";
7566
7787
 
7567
7788
  // src/commands/bucket/backup/create.ts
7568
- import { Command as Command73 } from "commander";
7789
+ import { Command as Command75 } from "commander";
7569
7790
 
7570
7791
  // src/commands/bucket/shared.ts
7571
7792
  async function bucketClient(cmd) {
@@ -7591,7 +7812,7 @@ function printRows(rows2) {
7591
7812
  }
7592
7813
 
7593
7814
  // src/commands/bucket/backup/create.ts
7594
- 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) => {
7595
7816
  const client = await bucketClient(cmd);
7596
7817
  const ls = "kvbox bucket backup ls";
7597
7818
  try {
@@ -7619,8 +7840,8 @@ var createCommand6 = new Command73("create").description("back up your object st
7619
7840
  });
7620
7841
 
7621
7842
  // src/commands/bucket/backup/ls.ts
7622
- import { Command as Command74 } from "commander";
7623
- 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) => {
7624
7845
  const client = await bucketClient(cmd);
7625
7846
  try {
7626
7847
  const list = await client.storageBackups();
@@ -7652,8 +7873,8 @@ var lsCommand11 = new Command74("ls").alias("list").description("list the backup
7652
7873
  });
7653
7874
 
7654
7875
  // src/commands/bucket/backup/restore.ts
7655
- import { Command as Command75 } from "commander";
7656
- 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) => {
7657
7878
  const client = await bucketClient(cmd);
7658
7879
  try {
7659
7880
  const backup = await client.storageBackup(id);
@@ -7683,8 +7904,8 @@ var restoreCommand3 = new Command75("restore").description("put a backup back: e
7683
7904
  });
7684
7905
 
7685
7906
  // src/commands/bucket/backup/rm.ts
7686
- import { Command as Command76 } from "commander";
7687
- 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) => {
7688
7909
  const client = await bucketClient(cmd);
7689
7910
  try {
7690
7911
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -7703,11 +7924,11 @@ var rmCommand11 = new Command76("rm").alias("remove").description("remove a back
7703
7924
  });
7704
7925
 
7705
7926
  // src/commands/bucket/backup/index.ts
7706
- 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);
7707
7928
 
7708
7929
  // src/commands/bucket/create.ts
7709
- import { Command as Command78 } from "commander";
7710
- 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) => {
7711
7932
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
7712
7933
  const client = await bucketClient(cmd);
7713
7934
  try {
@@ -7727,8 +7948,8 @@ var createCommand7 = new Command78("create").description("make a bucket (the fir
7727
7948
  });
7728
7949
 
7729
7950
  // src/commands/bucket/grow.ts
7730
- import { Command as Command79 } from "commander";
7731
- 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) => {
7732
7953
  const sizeGib = parseGib2(size, "size");
7733
7954
  const client = await bucketClient(cmd);
7734
7955
  try {
@@ -7741,8 +7962,8 @@ var growCommand2 = new Command79("grow").description("make your object storage l
7741
7962
  });
7742
7963
 
7743
7964
  // src/commands/bucket/info.ts
7744
- import { Command as Command80 } from "commander";
7745
- 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) => {
7746
7967
  const client = await bucketClient(cmd);
7747
7968
  try {
7748
7969
  const b = await client.getBucket(name);
@@ -7772,11 +7993,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
7772
7993
  });
7773
7994
 
7774
7995
  // src/commands/bucket/key/index.ts
7775
- import { Command as Command84 } from "commander";
7996
+ import { Command as Command86 } from "commander";
7776
7997
 
7777
7998
  // src/commands/bucket/key/create.ts
7778
- import { Command as Command81 } from "commander";
7779
- 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) => {
7780
8001
  const client = await bucketClient(cmd);
7781
8002
  try {
7782
8003
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -7799,8 +8020,8 @@ var createCommand8 = new Command81("create").description("make an access key for
7799
8020
  });
7800
8021
 
7801
8022
  // src/commands/bucket/key/ls.ts
7802
- import { Command as Command82 } from "commander";
7803
- 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) => {
7804
8025
  const client = await bucketClient(cmd);
7805
8026
  try {
7806
8027
  const keys = await client.listBucketKeys(bucket);
@@ -7819,8 +8040,8 @@ var lsCommand12 = new Command82("ls").alias("list").description("list a bucket's
7819
8040
  });
7820
8041
 
7821
8042
  // src/commands/bucket/key/rm.ts
7822
- import { Command as Command83 } from "commander";
7823
- 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) => {
7824
8045
  const client = await bucketClient(cmd);
7825
8046
  try {
7826
8047
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -7836,11 +8057,11 @@ var rmCommand12 = new Command83("rm").alias("remove").description("delete an acc
7836
8057
  });
7837
8058
 
7838
8059
  // src/commands/bucket/key/index.ts
7839
- 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);
7840
8061
 
7841
8062
  // src/commands/bucket/ls.ts
7842
- import { Command as Command85 } from "commander";
7843
- 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) => {
7844
8065
  const client = await bucketClient(cmd);
7845
8066
  try {
7846
8067
  const buckets = await client.listBuckets({ all: opts.all });
@@ -7871,8 +8092,8 @@ var lsCommand13 = new Command85("ls").alias("list").description("list buckets, a
7871
8092
  });
7872
8093
 
7873
8094
  // src/commands/bucket/public.ts
7874
- import { Command as Command86 } from "commander";
7875
- var publicCommand = new Command86("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) => {
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) => {
7876
8097
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
7877
8098
  const on = state === "on";
7878
8099
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -7900,8 +8121,8 @@ var publicCommand = new Command86("public").description("let anyone read a bucke
7900
8121
  });
7901
8122
 
7902
8123
  // src/commands/bucket/rm.ts
7903
- import { Command as Command87 } from "commander";
7904
- var rmCommand13 = new Command87("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) => {
7905
8126
  const client = await bucketClient(cmd);
7906
8127
  try {
7907
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?`;
@@ -7920,7 +8141,7 @@ var rmCommand13 = new Command87("rm").alias("remove").description("delete an emp
7920
8141
  });
7921
8142
 
7922
8143
  // src/commands/bucket/index.ts
7923
- var bucketCommand = new Command88("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(publicCommand).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);
7924
8145
  var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
7925
8146
  for (const cmd of bucketCommand.commands) {
7926
8147
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg);
@@ -7928,10 +8149,10 @@ for (const cmd of bucketCommand.commands) {
7928
8149
  }
7929
8150
 
7930
8151
  // src/commands/cron/index.ts
7931
- import { Command as Command101 } from "commander";
8152
+ import { Command as Command103 } from "commander";
7932
8153
 
7933
8154
  // src/commands/cron/create.ts
7934
- import { Command as Command89 } from "commander";
8155
+ import { Command as Command91 } from "commander";
7935
8156
 
7936
8157
  // src/commands/cron/shared.ts
7937
8158
  async function cronClient(cmd) {
@@ -7992,7 +8213,7 @@ function printRows2(rows2) {
7992
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>")`);
7993
8214
 
7994
8215
  // src/commands/cron/create.ts
7995
- var createCommand9 = new Command89("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) => {
7996
8217
  const client = await cronClient(cmd);
7997
8218
  try {
7998
8219
  const service = await client.createCronService(name);
@@ -8009,8 +8230,8 @@ var createCommand9 = new Command89("create").description("make a cron service: a
8009
8230
  });
8010
8231
 
8011
8232
  // src/commands/cron/info.ts
8012
- import { Command as Command90 } from "commander";
8013
- var infoCommand2 = new Command90("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) => {
8014
8235
  const client = await cronClient(cmd);
8015
8236
  try {
8016
8237
  const service = await client.getCronService(name);
@@ -8034,8 +8255,8 @@ var infoCommand2 = new Command90("info").alias("get").description("show a cron s
8034
8255
  });
8035
8256
 
8036
8257
  // src/commands/cron/ls.ts
8037
- import { Command as Command91 } from "commander";
8038
- var lsCommand14 = new Command91("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) => {
8039
8260
  const client = await cronClient(cmd);
8040
8261
  try {
8041
8262
  const services = await client.listCronServices({ all: opts.all });
@@ -8055,8 +8276,8 @@ var lsCommand14 = new Command91("ls").alias("list").description("list cron servi
8055
8276
  });
8056
8277
 
8057
8278
  // src/commands/cron/rm.ts
8058
- import { Command as Command92 } from "commander";
8059
- var rmCommand14 = new Command92("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) => {
8060
8281
  const client = await cronClient(cmd);
8061
8282
  try {
8062
8283
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8072,10 +8293,10 @@ var rmCommand14 = new Command92("rm").alias("remove").description("delete a cron
8072
8293
  });
8073
8294
 
8074
8295
  // src/commands/cron/trigger/index.ts
8075
- import { Command as Command100 } from "commander";
8296
+ import { Command as Command102 } from "commander";
8076
8297
 
8077
8298
  // src/commands/cron/trigger/add.ts
8078
- import { Command as Command93 } from "commander";
8299
+ import { Command as Command95 } from "commander";
8079
8300
  function portOf(value) {
8080
8301
  const n = Number(value);
8081
8302
  if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8095,7 +8316,7 @@ function timeoutOf(value) {
8095
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`);
8096
8317
  return sec;
8097
8318
  }
8098
- var addCommand3 = new Command93("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) => {
8099
8320
  let action;
8100
8321
  if (opts.run !== void 0) {
8101
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");
@@ -8122,8 +8343,8 @@ var addCommand3 = new Command93("add").description("add a trigger: on a schedule
8122
8343
  });
8123
8344
 
8124
8345
  // src/commands/cron/trigger/ls.ts
8125
- import { Command as Command94 } from "commander";
8126
- var lsCommand15 = new Command94("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) => {
8127
8348
  const client = await cronClient(cmd);
8128
8349
  try {
8129
8350
  const triggers = await client.listCronTriggers(service);
@@ -8139,8 +8360,8 @@ var lsCommand15 = new Command94("ls").alias("list").description("list a cron ser
8139
8360
  });
8140
8361
 
8141
8362
  // src/commands/cron/trigger/pause.ts
8142
- import { Command as Command95 } from "commander";
8143
- var pauseCommand2 = new Command95("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) => {
8144
8365
  const client = await cronClient(cmd);
8145
8366
  try {
8146
8367
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8155,8 +8376,8 @@ var pauseCommand2 = new Command95("pause").description("stop a trigger from firi
8155
8376
  });
8156
8377
 
8157
8378
  // src/commands/cron/trigger/resume.ts
8158
- import { Command as Command96 } from "commander";
8159
- var resumeCommand2 = new Command96("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) => {
8160
8381
  const client = await cronClient(cmd);
8161
8382
  try {
8162
8383
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8171,8 +8392,8 @@ var resumeCommand2 = new Command96("resume").description("let a paused trigger f
8171
8392
  });
8172
8393
 
8173
8394
  // src/commands/cron/trigger/rm.ts
8174
- import { Command as Command97 } from "commander";
8175
- var rmCommand15 = new Command97("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) => {
8176
8397
  const client = await cronClient(cmd);
8177
8398
  try {
8178
8399
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8188,8 +8409,8 @@ var rmCommand15 = new Command97("rm").alias("remove").description("delete a trig
8188
8409
  });
8189
8410
 
8190
8411
  // src/commands/cron/trigger/run.ts
8191
- import { Command as Command98 } from "commander";
8192
- var runCommand = new Command98("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) => {
8193
8414
  const client = await cronClient(cmd);
8194
8415
  try {
8195
8416
  const trigger = await client.runCronTrigger(service, id);
@@ -8205,13 +8426,13 @@ var runCommand = new Command98("run").description("fire a trigger now, once, bes
8205
8426
  });
8206
8427
 
8207
8428
  // src/commands/cron/trigger/runs.ts
8208
- import { Command as Command99 } from "commander";
8429
+ import { Command as Command101 } from "commander";
8209
8430
  function limitOf(value) {
8210
8431
  const n = Number(value);
8211
8432
  if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8212
8433
  return n;
8213
8434
  }
8214
- var runsCommand = new Command99("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) => {
8215
8436
  const limit = limitOf(opts.limit);
8216
8437
  const client = await cronClient(cmd);
8217
8438
  try {
@@ -8241,10 +8462,10 @@ var runsCommand = new Command99("runs").aliases(["logs"]).description("show how
8241
8462
  });
8242
8463
 
8243
8464
  // src/commands/cron/trigger/index.ts
8244
- var triggerCommand = new Command100("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);
8245
8466
 
8246
8467
  // src/commands/cron/index.ts
8247
- var cronCommand = new Command101("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);
8248
8469
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8249
8470
  for (const cmd of cronCommand.commands) {
8250
8471
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
@@ -8252,13 +8473,13 @@ for (const cmd of cronCommand.commands) {
8252
8473
  }
8253
8474
 
8254
8475
  // src/commands/managed/kind.ts
8255
- import { Command as Command120 } from "commander";
8476
+ import { Command as Command122 } from "commander";
8256
8477
 
8257
8478
  // src/commands/managed/backup/index.ts
8258
- import { Command as Command108 } from "commander";
8479
+ import { Command as Command110 } from "commander";
8259
8480
 
8260
8481
  // src/commands/managed/backup/create.ts
8261
- import { Command as Command103 } from "commander";
8482
+ import { Command as Command105 } from "commander";
8262
8483
 
8263
8484
  // src/commands/managed/shared.ts
8264
8485
  import "commander";
@@ -8356,7 +8577,7 @@ function parseStorage(text2, flag) {
8356
8577
  }
8357
8578
 
8358
8579
  // src/commands/managed/backup/create.ts
8359
- var createCommand10 = (spec) => new Command103("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) => {
8360
8581
  const client = await managedClient(cmd);
8361
8582
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8362
8583
  try {
@@ -8383,8 +8604,8 @@ var createCommand10 = (spec) => new Command103("create").description("back up a
8383
8604
  });
8384
8605
 
8385
8606
  // src/commands/managed/backup/ls.ts
8386
- import { Command as Command104 } from "commander";
8387
- var lsCommand16 = (spec) => {
8607
+ import { Command as Command106 } from "commander";
8608
+ var lsCommand17 = (spec) => {
8388
8609
  const removedOnes = async (err, name, client) => {
8389
8610
  if (!(err instanceof CallError && err.status === 404)) throw err;
8390
8611
  const gone = (await client.listManagedBackups(spec.kind)).filter((b) => b.name === name || `${b.owner}/${b.name}` === name);
@@ -8392,7 +8613,7 @@ var lsCommand16 = (spec) => {
8392
8613
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8393
8614
  return own.length > 0 ? own : gone;
8394
8615
  };
8395
- return new Command104("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) => {
8396
8617
  const client = await managedClient(cmd);
8397
8618
  try {
8398
8619
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8435,8 +8656,8 @@ var lsCommand16 = (spec) => {
8435
8656
  };
8436
8657
 
8437
8658
  // src/commands/managed/backup/restore.ts
8438
- import { Command as Command105 } from "commander";
8439
- var restoreCommand4 = (spec) => new Command105("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) => {
8440
8661
  const client = await managedClient(cmd);
8441
8662
  try {
8442
8663
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -8458,8 +8679,8 @@ var restoreCommand4 = (spec) => new Command105("restore").description("put a bac
8458
8679
  });
8459
8680
 
8460
8681
  // src/commands/managed/backup/rm.ts
8461
- import { Command as Command106 } from "commander";
8462
- var rmCommand16 = (spec) => new Command106("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) => {
8463
8684
  const client = await managedClient(cmd);
8464
8685
  try {
8465
8686
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -8469,8 +8690,8 @@ var rmCommand16 = (spec) => new Command106("rm").alias("remove").description("re
8469
8690
  });
8470
8691
 
8471
8692
  // src/commands/managed/backup/schedule.ts
8472
- import { Command as Command107 } from "commander";
8473
- var scheduleCommand = (spec) => new Command107("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) => {
8474
8695
  if (opts.off && (opts.on || opts.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
8475
8696
  const hour = opts.at === void 0 ? void 0 : parseHour(opts.at);
8476
8697
  const client = await managedClient(cmd);
@@ -8500,18 +8721,18 @@ function parseHour(text2) {
8500
8721
 
8501
8722
  // src/commands/managed/backup/index.ts
8502
8723
  var backupCommand4 = (spec) => {
8503
- const command = new Command108("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
8504
- 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)"));
8505
8726
  return command;
8506
8727
  };
8507
8728
 
8508
8729
  // src/commands/managed/create.ts
8509
- import { Command as Command109 } from "commander";
8730
+ import { Command as Command111 } from "commander";
8510
8731
  import { setTimeout as sleep5 } from "timers/promises";
8511
8732
  var READY_WAIT_MS = 9e4;
8512
8733
  var READY_STEP_MS = 2e3;
8513
8734
  var createCommand11 = (spec) => {
8514
- const command = new Command109("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");
8515
8736
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
8516
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) => {
8517
8738
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -8560,8 +8781,8 @@ var createCommand11 = (spec) => {
8560
8781
  };
8561
8782
 
8562
8783
  // src/commands/managed/grow.ts
8563
- import { Command as Command110 } from "commander";
8564
- var growCommand3 = (spec) => new Command110("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) => {
8565
8786
  const storageGib = parseStorage(size, "size");
8566
8787
  const client = await managedClient(cmd);
8567
8788
  try {
@@ -8574,8 +8795,8 @@ var growCommand3 = (spec) => new Command110("grow").description("give a database
8574
8795
  });
8575
8796
 
8576
8797
  // src/commands/managed/info.ts
8577
- import { Command as Command111 } from "commander";
8578
- var infoCommand3 = (spec) => new Command111("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) => {
8579
8800
  const client = await managedClient(cmd);
8580
8801
  try {
8581
8802
  const m = await client.getManaged(spec.kind, name);
@@ -8587,8 +8808,8 @@ var infoCommand3 = (spec) => new Command111("info").alias("get").description("sh
8587
8808
  });
8588
8809
 
8589
8810
  // src/commands/managed/link.ts
8590
- import { Command as Command112 } from "commander";
8591
- var linkCommand2 = (spec) => new Command112("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) => {
8592
8813
  const client = await managedClient(cmd);
8593
8814
  try {
8594
8815
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -8604,7 +8825,7 @@ var linkCommand2 = (spec) => new Command112("link").description("let a box reach
8604
8825
  });
8605
8826
 
8606
8827
  // src/commands/managed/ls.ts
8607
- import { Command as Command113 } from "commander";
8828
+ import { Command as Command115 } from "commander";
8608
8829
  function listRows(items, user, kindColumn) {
8609
8830
  return items.map((m) => ({
8610
8831
  owner: m.owner === user ? "private" : m.owner,
@@ -8618,7 +8839,7 @@ function listRows(items, user, kindColumn) {
8618
8839
  created: age(m.createdAt)
8619
8840
  }));
8620
8841
  }
8621
- var lsCommand17 = (spec) => new Command113("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) => {
8622
8843
  const client = await managedClient(cmd);
8623
8844
  try {
8624
8845
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -8638,8 +8859,8 @@ var lsCommand17 = (spec) => new Command113("ls").alias("list").description(spec
8638
8859
  });
8639
8860
 
8640
8861
  // src/commands/managed/password.ts
8641
- import { Command as Command114 } from "commander";
8642
- var passwordCommand = (spec) => new Command114("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) => {
8643
8864
  const client = await managedClient(cmd);
8644
8865
  try {
8645
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);
@@ -8655,8 +8876,8 @@ var passwordCommand = (spec) => new Command114("password").description("show a d
8655
8876
  });
8656
8877
 
8657
8878
  // src/commands/managed/public.ts
8658
- import { Command as Command115 } from "commander";
8659
- var publicCommand2 = (spec) => new Command115("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) => {
8660
8881
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
8661
8882
  const client = await managedClient(cmd);
8662
8883
  try {
@@ -8677,8 +8898,8 @@ var publicCommand2 = (spec) => new Command115("public").description("open a data
8677
8898
  });
8678
8899
 
8679
8900
  // src/commands/managed/rm.ts
8680
- import { Command as Command116 } from "commander";
8681
- var rmCommand17 = (spec) => new Command116("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) => {
8682
8903
  const client = await managedClient(cmd);
8683
8904
  try {
8684
8905
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -8694,8 +8915,8 @@ var rmCommand17 = (spec) => new Command116("rm").alias("remove").description("de
8694
8915
  });
8695
8916
 
8696
8917
  // src/commands/managed/start.ts
8697
- import { Command as Command117 } from "commander";
8698
- var startCommand2 = (spec) => new Command117("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) => {
8699
8920
  const client = await managedClient(cmd);
8700
8921
  try {
8701
8922
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -8707,8 +8928,8 @@ var startCommand2 = (spec) => new Command117("start").description("run a stopped
8707
8928
  });
8708
8929
 
8709
8930
  // src/commands/managed/stop.ts
8710
- import { Command as Command118 } from "commander";
8711
- var stopCommand2 = (spec) => new Command118("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) => {
8712
8933
  const client = await managedClient(cmd);
8713
8934
  try {
8714
8935
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -8720,8 +8941,8 @@ var stopCommand2 = (spec) => new Command118("stop").description("shut a database
8720
8941
  });
8721
8942
 
8722
8943
  // src/commands/managed/unlink.ts
8723
- import { Command as Command119 } from "commander";
8724
- var unlinkCommand2 = (spec) => new Command119("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) => {
8725
8946
  const client = await managedClient(cmd);
8726
8947
  try {
8727
8948
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -8734,8 +8955,8 @@ var unlinkCommand2 = (spec) => new Command119("unlink").description("stop a box
8734
8955
 
8735
8956
  // src/commands/managed/kind.ts
8736
8957
  function kindCommand(spec, description) {
8737
- const command = new Command120(spec.command).aliases(spec.aliases).description(description);
8738
- for (const make of [createCommand11, lsCommand17, infoCommand3, passwordCommand, publicCommand2, 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]) {
8739
8960
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8740
8961
  }
8741
8962
  command.addCommand(backupCommand4(spec));
@@ -8749,14 +8970,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
8749
8970
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
8750
8971
 
8751
8972
  // src/commands/managed/index.ts
8752
- import { Command as Command121 } from "commander";
8753
- var managedCommand = new Command121("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)"));
8754
8975
 
8755
8976
  // src/commands/env/index.ts
8756
- import { Command as Command125 } from "commander";
8977
+ import { Command as Command127 } from "commander";
8757
8978
 
8758
8979
  // src/commands/env/ls.ts
8759
- import { Command as Command122 } from "commander";
8980
+ import { Command as Command124 } from "commander";
8760
8981
 
8761
8982
  // src/commands/env/shared.ts
8762
8983
  function requireCloud4(client) {
@@ -8783,7 +9004,7 @@ function firstBootHint(box2, name) {
8783
9004
  }
8784
9005
 
8785
9006
  // src/commands/env/ls.ts
8786
- var lsCommand18 = new Command122("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) => {
8787
9008
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8788
9009
  try {
8789
9010
  if (opts.box !== void 0) {
@@ -8822,8 +9043,8 @@ var lsCommand18 = new Command122("ls").alias("list").description("list the varia
8822
9043
  });
8823
9044
 
8824
9045
  // src/commands/env/rm.ts
8825
- import { Command as Command123 } from "commander";
8826
- var rmCommand18 = new Command123("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) => {
8827
9048
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8828
9049
  try {
8829
9050
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -8860,8 +9081,8 @@ var rmCommand18 = new Command123("rm").alias("remove").description("remove varia
8860
9081
  });
8861
9082
 
8862
9083
  // src/commands/env/set.ts
8863
- import { Command as Command124 } from "commander";
8864
- var setCommand2 = new Command124("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) => {
8865
9086
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8866
9087
  try {
8867
9088
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -8898,14 +9119,14 @@ var setCommand2 = new Command124("set").description("add or change a variable; b
8898
9119
  });
8899
9120
 
8900
9121
  // src/commands/env/index.ts
8901
- var envCommand = new Command125("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);
8902
9123
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
8903
9124
 
8904
9125
  // src/commands/domain/index.ts
8905
- import { Command as Command129 } from "commander";
9126
+ import { Command as Command131 } from "commander";
8906
9127
 
8907
9128
  // src/commands/domain/add.ts
8908
- import { Command as Command126 } from "commander";
9129
+ import { Command as Command128 } from "commander";
8909
9130
 
8910
9131
  // src/commands/domain/shared.ts
8911
9132
  function requireCloud5(client) {
@@ -8925,7 +9146,7 @@ function hostIn(name, zone) {
8925
9146
  }
8926
9147
 
8927
9148
  // src/commands/domain/add.ts
8928
- var addCommand4 = new Command126("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) => {
8929
9150
  const domain = assertDomain(domainArg.trim().toLowerCase());
8930
9151
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
8931
9152
  const client = await clientFor(cmd.optsWithGlobals());
@@ -8961,8 +9182,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
8961
9182
  });
8962
9183
 
8963
9184
  // src/commands/domain/ls.ts
8964
- import { Command as Command127 } from "commander";
8965
- var lsCommand19 = new Command127("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) => {
8966
9187
  const client = await clientFor(cmd.optsWithGlobals());
8967
9188
  try {
8968
9189
  requireCloud5(client);
@@ -8991,8 +9212,8 @@ var lsCommand19 = new Command127("ls").alias("list").description("list your cust
8991
9212
  });
8992
9213
 
8993
9214
  // src/commands/domain/rm.ts
8994
- import { Command as Command128 } from "commander";
8995
- var rmCommand19 = new Command128("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) => {
8996
9217
  const domain = domainArg.trim().toLowerCase();
8997
9218
  const client = await clientFor(cmd.optsWithGlobals());
8998
9219
  try {
@@ -9013,7 +9234,7 @@ var rmCommand19 = new Command128("rm").alias("remove").description("stop serving
9013
9234
  });
9014
9235
 
9015
9236
  // src/commands/domain/index.ts
9016
- var domainCommand = new Command129("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);
9017
9238
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9018
9239
 
9019
9240
  // src/commands/update.ts
@@ -9021,7 +9242,7 @@ import { spawn as spawn8 } from "child_process";
9021
9242
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9022
9243
  import { tmpdir } from "os";
9023
9244
  import { join as join9 } from "path";
9024
- import { Command as Command130 } from "commander";
9245
+ import { Command as Command132 } from "commander";
9025
9246
 
9026
9247
  // src/update.ts
9027
9248
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9140,7 +9361,7 @@ function run2(cmd, args) {
9140
9361
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9141
9362
  });
9142
9363
  }
9143
- var selfUpdateCommand = new Command130("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 () => {
9144
9365
  suppressUpdateNotice();
9145
9366
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9146
9367
  let code;
@@ -9211,6 +9432,7 @@ var HELP_GROUPS = [
9211
9432
  ["managed", "every managed database, whatever its kind"],
9212
9433
  ["cron", "call a box on a schedule, waking it first if it sleeps"],
9213
9434
  ["env", "environment variables and secrets every box of yours gets"],
9435
+ ["integration", "accounts (GitHub) your boxes use once you turn them on"],
9214
9436
  ["domain", "serve a box at a domain of your own"]
9215
9437
  ]
9216
9438
  },
@@ -9268,7 +9490,7 @@ function installRootHelp(program) {
9268
9490
 
9269
9491
  // src/program.ts
9270
9492
  function buildProgram() {
9271
- const program = new Command131("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();
9272
9494
  program.addCommand(vmCommand);
9273
9495
  program.addCommand(snapshotsCommand);
9274
9496
  program.addCommand(volumeCommand);
@@ -9283,6 +9505,7 @@ function buildProgram() {
9283
9505
  program.addCommand(logoutCommand);
9284
9506
  program.addCommand(whoamiCommand);
9285
9507
  program.addCommand(keyCommand);
9508
+ program.addCommand(integrationCommand);
9286
9509
  program.addCommand(orgCommand);
9287
9510
  program.addCommand(usageCommand2);
9288
9511
  program.addCommand(creditCommand);