@kvbox/cli 0.6.12 → 0.6.15

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.15" : void 0);
174
174
 
175
175
  // src/commands/vm/index.ts
176
176
  import { Command as Command39 } from "commander";
@@ -345,10 +345,98 @@ 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", "claude"];
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
+ /**
379
+ * How Connect works: `oauth` sends the browser to the provider's consent screen; `paste` takes a credential
380
+ * the user pastes (Claude Code's). A plain string, like `id`: a released CLI must still read a catalog with a way it does not know.
381
+ */
382
+ connect: z.string(),
383
+ /** What a user's slug and an org's may hold; an empty list: that kind of slug cannot connect it yet. */
384
+ kinds: z.object({ user: z.array(IntegrationKindSchema), org: z.array(IntegrationKindSchema) }),
385
+ /** Whether this control plane is set up for it (a self-hosted one without a GitHub app is not). */
386
+ available: z.boolean(),
387
+ /** Its guide, as a URL. */
388
+ docs: z.string().optional(),
389
+ /** Where it is connected and disconnected: this control plane's web app, when it has one. */
390
+ page: z.string().optional()
391
+ });
392
+ var IntegrationSchema = z.object({
393
+ /** The slug it belongs to: a user's or an org's. */
394
+ owner: z.string(),
395
+ /**
396
+ * Which one (`github`). A plain string, not the ids above: this is an answer, read by every released CLI
397
+ * and SDK, and one from before a new integration must still read the listing that has it.
398
+ */
399
+ integration: z.string(),
400
+ connected: z.boolean(),
401
+ /** The rest is null while not connected. */
402
+ kind: IntegrationKindSchema.nullable(),
403
+ /** Whose account, as shown: the GitHub login. Never a secret. */
404
+ account: z.string().nullable(),
405
+ status: IntegrationStatusSchema.nullable(),
406
+ connectedBy: z.string().nullable(),
407
+ connectedAt: z.string().nullable(),
408
+ /** The last time a box was handed the credential (to the minute). */
409
+ lastUsedAt: z.string().nullable(),
410
+ /** Whether the caller may connect or disconnect it: the slug's own user, an org's owners. */
411
+ canManage: z.boolean()
412
+ });
413
+ var IntegrationConnectSchema = z.object({ url: z.string() });
414
+ var IntegrationCompleteRequestSchema = z.object({ code: z.string().min(1), state: z.string().min(1) });
415
+ var ClaudeConnectRequestSchema = z.object({
416
+ credential: z.string().trim().min(1).max(4096).regex(/^[A-Za-z0-9_-]+$/, "a Claude Code token or an Anthropic API key has only letters, digits, - and _: paste it again on one line, with nothing inside it")
417
+ });
418
+ var IntegrationIdentitySchema = z.object({ name: z.string(), email: z.string() });
419
+ var CREDENTIAL_REFUSALS = ["off", "not-connected", "needs-reconnect", "unavailable"];
420
+ var CredentialAnswerSchema = z.discriminatedUnion("ok", [
421
+ z.object({
422
+ ok: z.literal(true),
423
+ kind: IntegrationKindSchema,
424
+ token: z.string(),
425
+ /** When the token ends (ISO), for one that does (a GitHub App's hour). */
426
+ expiresAt: z.string().optional(),
427
+ identity: IntegrationIdentitySchema.optional()
428
+ }),
429
+ z.object({
430
+ ok: z.literal(false),
431
+ code: z.enum(CREDENTIAL_REFUSALS),
432
+ message: z.string(),
433
+ /** With `off`: whether the slug has it connected, so the box can say how to turn it on. */
434
+ connected: z.boolean().optional()
435
+ })
436
+ ]);
437
+ var HostCredentialRequestSchema = z.object({ owner: z.string().min(1), box: z.string().min(1), integration: IntegrationIdSchema, probe: z.boolean().optional() });
438
+ var ConnectedAnswerSchema = z.object({ connected: z.boolean(), identity: IntegrationIdentitySchema.optional() });
439
+ var GuestRequestSchema = z.object({ op: z.literal("credential"), integration: IntegrationIdSchema });
352
440
 
353
441
  // ../shared/src/sizes.ts
354
442
  var SIZES = {
@@ -368,1073 +456,1096 @@ function parseMib(text2) {
368
456
  }
369
457
 
370
458
  // ../shared/src/api.ts
371
- var SizeSchema = z.enum(SIZE_NAMES);
459
+ var SizeSchema = z2.enum(SIZE_NAMES);
372
460
  var BOX_SSH_USER = "kvbox";
373
- var BoxStatusSchema = z.enum(["running", "standby", "hibernated", "stopped", "unknown"]);
374
- var PortProtoSchema = z.enum(["tcp", "udp"]);
461
+ var BoxStatusSchema = z2.enum(["running", "standby", "hibernated", "stopped", "unknown"]);
462
+ var PortProtoSchema = z2.enum(["tcp", "udp"]);
375
463
  var MAX_BOX_PORTS = 16;
376
- var PortForwardSchema = z.object({
377
- guestPort: z.number().int().min(1).max(65535),
378
- hostPort: z.number().int(),
464
+ var PortForwardSchema = z2.object({
465
+ guestPort: z2.number().int().min(1).max(65535),
466
+ hostPort: z2.number().int(),
379
467
  proto: PortProtoSchema,
380
468
  /** The host's public address; only the control plane fills it in, as for `ssh`. */
381
- address: z.string().optional(),
469
+ address: z2.string().optional(),
382
470
  /**
383
471
  * Closed but kept (#173): nothing reaches the box through it, and the host port stays the box's, so
384
472
  * publishing the same box port again opens the same number. Absent: open while the box runs.
385
473
  */
386
- closed: z.literal(true).optional()
474
+ closed: z2.literal(true).optional()
387
475
  });
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),
476
+ var PortsRequest = z2.object({
477
+ ports: z2.array(z2.object({ guestPort: z2.number().int().min(1).max(65535), proto: PortProtoSchema.optional() })).min(1).max(MAX_BOX_PORTS),
390
478
  /** `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(),
479
+ keep: z2.boolean().optional()
480
+ });
481
+ var BoxPortSchema = z2.number().int().min(1).max(65535);
482
+ var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
483
+ var LinkRequest = z2.object({ from: z2.string().min(1), fromOwner: z2.string().optional(), port: BoxPortSchema });
484
+ var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
485
+ var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
486
+ var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
487
+ var SubdomainSchema = z2.object({
488
+ owner: z2.string(),
489
+ box: z2.string(),
490
+ subdomain: z2.string(),
403
491
  port: BoxPortSchema,
404
- url: z.string(),
405
- routes: z.array(z.object({ name: z.string(), port: BoxPortSchema, url: z.string() }))
492
+ url: z2.string(),
493
+ routes: z2.array(z2.object({ name: z2.string(), port: BoxPortSchema, url: z2.string() }))
406
494
  });
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(),
495
+ var AddDomainRequest = z2.object({ domain: z2.string(), port: BoxPortSchema.optional() });
496
+ var DomainSchema = z2.object({
497
+ owner: z2.string(),
498
+ box: z2.string(),
499
+ domain: z2.string(),
412
500
  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()
501
+ status: z2.enum(["pending", "live"]),
502
+ www: z2.boolean(),
503
+ url: z2.string(),
504
+ error: z2.string().nullable(),
505
+ records: z2.array(z2.object({ type: z2.enum(["A", "TXT", "CNAME"]), name: z2.string(), value: z2.string() })),
506
+ createdAt: z2.string()
507
+ });
508
+ var WakeHookSchema = z2.object({
509
+ id: z2.string(),
510
+ owner: z2.string(),
511
+ box: z2.string(),
512
+ url: z2.string(),
513
+ createdBy: z2.string().nullable(),
514
+ createdAt: z2.string(),
515
+ lastCalledAt: z2.string().nullable()
516
+ });
517
+ var CreatedWakeHookSchema = WakeHookSchema.extend({ secret: z2.string() });
518
+ var WakeHookCallSchema = z2.object({
519
+ box: z2.string(),
520
+ action: z2.enum(["wake", "resume", "none"]),
521
+ reason: z2.string().optional()
434
522
  });
435
523
  var BACKUP_STATUSES = ["running", "ready", "failed"];
436
524
  var BACKUP_KINDS = ["box", "volume"];
437
- var BackupSchema = z.object({
438
- id: z.string(),
439
- owner: z.string(),
440
- box: z.string(),
525
+ var BackupSchema = z2.object({
526
+ id: z2.string(),
527
+ owner: z2.string(),
528
+ box: z2.string(),
441
529
  /**
442
530
  * The box it was taken of has been removed (#141): a box called `box` now is another box, which this backup
443
531
  * never restores into; `kvbox new <name> --from-backup <id>` makes a box from it. Absent from a control plane
444
532
  * before #141.
445
533
  */
446
- boxRemoved: z.boolean().optional(),
447
- status: z.enum(BACKUP_STATUSES),
534
+ boxRemoved: z2.boolean().optional(),
535
+ status: z2.enum(BACKUP_STATUSES),
448
536
  /** Why it failed; null otherwise. */
449
- error: z.string().nullable(),
537
+ error: z2.string().nullable(),
450
538
  /** 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(),
539
+ base: z2.string().nullable(),
540
+ image: z2.string().optional(),
541
+ vcpu: z2.number().int().nullable(),
542
+ memMib: z2.number().int().nullable(),
455
543
  /** The disk's size. */
456
- diskBytes: z.number().int().nullable(),
544
+ diskBytes: z2.number().int().nullable(),
457
545
  /** What it holds: the slots that are not all zeros. */
458
- dataBytes: z.number().int().nullable(),
546
+ dataBytes: z2.number().int().nullable(),
459
547
  /** 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({
548
+ uploadedBytes: z2.number().int().nullable(),
549
+ createdBy: z2.string().nullable(),
550
+ createdAt: z2.string(),
551
+ finishedAt: z2.string().nullable()
552
+ });
553
+ var BackupLimitSchema = z2.object({
554
+ perDay: z2.number().int(),
555
+ used: z2.number().int(),
556
+ nextAt: z2.string().nullable()
557
+ });
558
+ var NamedBackupLimitSchema = BackupLimitSchema.extend({ owner: z2.string(), name: z2.string() });
559
+ var HostBackupRequest = z2.object({ id: z2.string(), key: z2.string() });
560
+ var HostBackupManifestSchema = z2.object({
561
+ id: z2.string(),
562
+ sizeBytes: z2.number().int(),
563
+ chunks: z2.array(z2.string().nullable()),
564
+ env: z2.string().nullable(),
565
+ base: z2.string(),
566
+ image: z2.string().optional(),
567
+ vcpu: z2.number().int(),
568
+ memMib: z2.number().int(),
569
+ /** The box's integrations (#205), so a box made from the backup has them again. Absent: none, or an older host. */
570
+ integrations: z2.array(z2.string()).optional()
571
+ });
572
+ var HostUploadRequest = z2.object({ key: z2.string(), urls: z2.record(z2.string(), z2.string()), pin: z2.string().optional() });
573
+ var HostUploadResultSchema = z2.object({ chunks: z2.number().int(), bytes: z2.number().int(), sizes: z2.record(z2.string(), z2.number().int()) });
574
+ var HostRestoreRequest = z2.object({
485
575
  /** 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() })),
576
+ id: z2.string(),
577
+ key: z2.string(),
578
+ sizeBytes: z2.number().int().positive(),
579
+ base: z2.string(),
580
+ image: z2.string().optional(),
581
+ env: z2.string().nullable(),
582
+ chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
493
583
  /** The certificate fingerprint of the store the URLs point at (see HostUploadRequest). */
494
- pin: z.string().optional()
584
+ pin: z2.string().optional()
495
585
  });
496
- var VolumeBackupSchema = z.object({
497
- id: z.string(),
498
- owner: z.string(),
499
- volume: z.string(),
500
- status: z.enum(BACKUP_STATUSES),
586
+ var VolumeBackupSchema = z2.object({
587
+ id: z2.string(),
588
+ owner: z2.string(),
589
+ volume: z2.string(),
590
+ status: z2.enum(BACKUP_STATUSES),
501
591
  /** Why it failed; null otherwise. */
502
- error: z.string().nullable(),
592
+ error: z2.string().nullable(),
503
593
  /** The volume's size when taken. */
504
- diskBytes: z.number().int().nullable(),
594
+ diskBytes: z2.number().int().nullable(),
505
595
  /** What it holds: the slots that are not all zeros. */
506
- dataBytes: z.number().int().nullable(),
596
+ dataBytes: z2.number().int().nullable(),
507
597
  /** 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()
598
+ uploadedBytes: z2.number().int().nullable(),
599
+ createdBy: z2.string().nullable(),
600
+ createdAt: z2.string(),
601
+ finishedAt: z2.string().nullable()
512
602
  });
513
- var BackupScheduleSchema = z.object({
514
- enabled: z.boolean(),
603
+ var BackupScheduleSchema = z2.object({
604
+ enabled: z2.boolean(),
515
605
  /** 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(),
606
+ hour: z2.number().int().min(0).max(23),
607
+ nextAt: z2.string().nullable(),
608
+ lastAt: z2.string().nullable(),
609
+ lastBackup: z2.string().nullable(),
610
+ lastError: z2.string().nullable()
611
+ });
612
+ var SetBackupScheduleRequest = z2.object({ enabled: z2.boolean().optional(), hour: z2.number().int().min(0).max(23).optional() });
613
+ var HostVolumeBackupManifestSchema = z2.object({ id: z2.string(), sizeBytes: z2.number().int(), chunks: z2.array(z2.string().nullable()) });
614
+ var HostVolumeRestoreRequest = z2.object({
615
+ id: z2.string(),
616
+ key: z2.string(),
617
+ sizeBytes: z2.number().int().positive(),
618
+ chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
619
+ pin: z2.string().optional()
620
+ });
621
+ var BackupStoreSetupRequest = z2.object({ path: z2.string().min(1), force: z2.boolean().optional(), newStore: z2.boolean().optional() });
622
+ var BackupStoreStatusSchema = z2.object({
623
+ path: z2.string(),
624
+ bucket: z2.string(),
625
+ accessKey: z2.string(),
536
626
  /** Whether Garage is running and can store. */
537
- running: z.boolean(),
627
+ running: z2.boolean(),
538
628
  /** The filesystem the path is on. */
539
- totalBytes: z.number().int(),
540
- freeBytes: z.number().int(),
629
+ totalBytes: z2.number().int(),
630
+ freeBytes: z2.number().int(),
541
631
  /** What the bucket holds, when Garage answers. */
542
- objects: z.number().int().optional(),
543
- storedBytes: z.number().int().optional(),
632
+ objects: z2.number().int().optional(),
633
+ storedBytes: z2.number().int().optional(),
544
634
  /** Whether the control plane took the store's registration at setup. */
545
- registered: z.boolean().optional()
635
+ registered: z2.boolean().optional()
546
636
  });
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(),
637
+ var BackupStoreRegistration = z2.object({ bucket: z2.string().min(1), region: z2.string().min(1), accessKey: z2.string().min(1), secretKey: z2.string().min(1) });
638
+ var CloudBackupStoreSchema = z2.object({
639
+ id: z2.string(),
550
640
  /** 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(),
641
+ host: z2.string().nullable(),
642
+ endpoint: z2.string().nullable(),
643
+ bucket: z2.string(),
644
+ accessKey: z2.string(),
645
+ createdAt: z2.string(),
556
646
  /** The host answered a poll in the last minute and its Garage runs. */
557
- live: z.boolean(),
647
+ live: z2.boolean(),
558
648
  /** 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(),
649
+ totalBytes: z2.number().int().nullable(),
650
+ freeBytes: z2.number().int().nullable(),
561
651
  /** Ready backups kept here, and what their chunks take (encrypted, compressed). */
562
- backups: z.number().int(),
563
- storedBytes: z.number().int(),
652
+ backups: z2.number().int(),
653
+ storedBytes: z2.number().int(),
564
654
  /** 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(),
655
+ boxes: z2.number().int(),
656
+ volumes: z2.number().int(),
657
+ databases: z2.number().int(),
568
658
  /** When the newest ready backup kept here finished; null when it keeps none. */
569
- lastBackupAt: z.string().nullable()
659
+ lastBackupAt: z2.string().nullable()
570
660
  });
571
- var StoredItemSchema = z.object({
572
- kind: z.enum(BACKUP_KINDS),
573
- owner: z.string(),
661
+ var StoredItemSchema = z2.object({
662
+ kind: z2.enum(BACKUP_KINDS),
663
+ owner: z2.string(),
574
664
  /** The box's or volume's name; a managed database's (#186) for its hidden volume. */
575
- name: z.string(),
665
+ name: z2.string(),
576
666
  /** The managed database's kind (`postgres`) when the volume is one's (#186); null otherwise. */
577
- managed: z.string().nullable(),
667
+ managed: z2.string().nullable(),
578
668
  /** The host the box (or volume) is on now; null when it is gone (its backups stay). */
579
- host: z.string().nullable(),
669
+ host: z2.string().nullable(),
580
670
  /** It is on the store's own host: losing that host loses it and its backups together. */
581
- sameHost: z.boolean(),
671
+ sameHost: z2.boolean(),
582
672
  /** Ready backups kept here, and what they added to the store together (encrypted, compressed). */
583
- backups: z.number().int(),
584
- uploadedBytes: z.number().int(),
673
+ backups: z2.number().int(),
674
+ uploadedBytes: z2.number().int(),
585
675
  /** 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() })
676
+ latest: z2.object({ id: z2.string(), status: z2.enum(BACKUP_STATUSES), error: z2.string().nullable(), createdAt: z2.string() })
587
677
  });
588
- var FailedBackupSchema = z.object({
589
- id: z.string(),
590
- owner: z.string(),
678
+ var FailedBackupSchema = z2.object({
679
+ id: z2.string(),
680
+ owner: z2.string(),
591
681
  /** 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(),
682
+ kind: z2.enum(BACKUP_KINDS),
683
+ name: z2.string(),
594
684
  /** The managed database's kind (`postgres`) when the volume is one's; null otherwise. */
595
- managed: z.string().nullable(),
596
- error: z.string().nullable(),
685
+ managed: z2.string().nullable(),
686
+ error: z2.string().nullable(),
597
687
  /** 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()
688
+ host: z2.string().nullable(),
689
+ store: z2.string().nullable(),
690
+ createdAt: z2.string()
601
691
  });
602
- var MachineSchema = z.object({
692
+ var MachineSchema = z2.object({
603
693
  /** 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(),
694
+ id: z2.string(),
695
+ name: z2.string(),
606
696
  /** 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(),
697
+ owner: z2.string(),
698
+ ip: z2.string(),
699
+ mac: z2.string(),
700
+ pid: z2.number().int().nullable(),
701
+ vcpu: z2.number().int(),
702
+ memMib: z2.number().int(),
703
+ diskBytes: z2.number().int(),
614
704
  // the box's own writable disk, as the guest sees it
615
- diskUsedBytes: z.number().int(),
705
+ diskUsedBytes: z2.number().int(),
616
706
  // what the box uses of it: the filesystem's own count, like the guest's `df` (#115)
617
707
  /** 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(),
708
+ diskHostBytes: z2.number().int().optional(),
709
+ base: z2.string(),
620
710
  // version of the image the box's overlay stacks on
621
711
  /** 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(),
712
+ image: z2.string().optional(),
713
+ /**
714
+ * A newer version of the box's image on its host, the one `kvbox vm update` moves it onto. Only the control
715
+ * plane fills it in (from the host's last `/capacity`); absent while the box is on the newest one, or the host did not say.
716
+ */
717
+ latestBase: z2.string().optional(),
718
+ createdAt: z2.string(),
719
+ source: z2.string(),
625
720
  // "base", "snapshot:<owner/name>", "fork:<owner/name>" (#79) or "backup:<id>" (#141)
626
721
  status: BoxStatusSchema,
627
722
  /**
628
723
  * Public TCP port on the host that reaches the box's SSH while it runs (#49). Only boxes made
629
724
  * through a control plane have one; the control plane adds the host's address for `connect` (#21).
630
725
  */
631
- sshPort: z.number().int().optional(),
726
+ sshPort: z2.number().int().optional(),
632
727
  /**
633
728
  * Where `ssh` reaches the box from outside: the host's public address and that port (#21). Only
634
729
  * the control plane fills it in (a host does not know its own public address); absent for a box
635
730
  * whose host reported no port or did not answer.
636
731
  */
637
- ssh: z.object({ host: z.string(), port: z.number().int(), user: z.string() }).optional(),
732
+ ssh: z2.object({ host: z2.string(), port: z2.number().int(), user: z2.string() }).optional(),
638
733
  /** Box ports published on the host (#30). Absent: none. */
639
- ports: z.array(PortForwardSchema).optional(),
734
+ ports: z2.array(PortForwardSchema).optional(),
640
735
  /** 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(),
736
+ ownerKind: z2.enum(["user", "org"]).optional(),
642
737
  /**
643
738
  * The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
644
739
  * links to, and a volume attaches to, only a box on the same host.
645
740
  */
646
- host: z.string().optional(),
741
+ host: z2.string().optional(),
647
742
  /** 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(),
743
+ country: z2.string().optional(),
649
744
  /**
650
745
  * The kind of managed service the box runs (`postgres`, `redis`, `storage`). Only an admin's
651
746
  * `GET /machines?all=1` lists such boxes, so a host's boxes add up; every other listing hides them.
652
747
  */
653
- managed: z.string().optional(),
748
+ managed: z2.string().optional(),
654
749
  /** Seconds without network traffic before the host hibernates the box (#47). Absent: never. */
655
- autoHibernateSec: z.number().int().positive().optional(),
750
+ autoHibernateSec: z2.number().int().positive().optional(),
656
751
  /** 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(),
752
+ idleCheck: z2.string().optional(),
658
753
  /** 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(),
754
+ volumes: z2.array(z2.object({ name: z2.string(), sizeGib: z2.number().int(), mountPath: z2.string() })).optional(),
660
755
  /** Boxes that may reach this one, each on one port (#98). Absent: none. */
661
- links: z.array(BoxLinkSchema).optional(),
756
+ links: z2.array(BoxLinkSchema).optional(),
757
+ /**
758
+ * The integrations turned on for the box (#205, `github`): names only, the credential is fetched by the box
759
+ * each time it is needed. Absent: none. A host before integrations never sends it.
760
+ */
761
+ integrations: z2.array(z2.string()).optional(),
662
762
  /** How to reach what the box serves, its secrets masked (#87): `postgres://postgres:****@db.kvbox:5432/postgres`. */
663
- url: z.string().optional(),
763
+ url: z2.string().optional(),
664
764
  /**
665
765
  * Only in what `POST /machines` answers, for an image that declares one (#87): how to reach what it
666
766
  * serves, e.g. `postgres://postgres:<password>@db.kvbox:5432/postgres`. Holds the box's variables.
667
767
  */
668
- connect: z.string().optional()
768
+ connect: z2.string().optional()
669
769
  });
670
- var VolumeSchema = z.object({
770
+ var VolumeSchema = z2.object({
671
771
  /** 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(),
772
+ id: z2.string(),
773
+ name: z2.string(),
774
+ owner: z2.string(),
775
+ sizeGib: z2.number().int(),
676
776
  /** What the sparse file really occupies on the host. */
677
- usedBytes: z.number().int(),
678
- attachedTo: z.string().nullable(),
679
- createdAt: z.string(),
777
+ usedBytes: z2.number().int(),
778
+ attachedTo: z2.string().nullable(),
779
+ createdAt: z2.string(),
680
780
  /** 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(),
781
+ ownerKind: z2.enum(["user", "org"]).optional(),
682
782
  /** 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()
783
+ host: z2.string().optional()
684
784
  });
685
785
  var MAX_VOLUME_GIB = 4096;
686
786
  var VOLUME_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
687
787
  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),
788
+ var CreateVolumeRequest = z2.object({
789
+ name: z2.string(),
790
+ sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB),
691
791
  /**
692
792
  * Through a control plane (#91): the box this volume is for, so it is made on that box's host; the
693
793
  * control plane requires it (a volume attaches only to a box on its own host, so one made for no box
694
794
  * could never attach) and the CLI attaches right after. A host ignores it.
695
795
  */
696
- box: z.string().optional()
796
+ box: z2.string().optional()
697
797
  });
698
- var AttachVolumeRequest = z.object({
699
- box: z.string()
798
+ var AttachVolumeRequest = z2.object({
799
+ box: z2.string()
700
800
  });
701
- var ResizeVolumeRequest = z.object({
702
- sizeGib: z.number().int().min(1).max(MAX_VOLUME_GIB)
801
+ var ResizeVolumeRequest = z2.object({
802
+ sizeGib: z2.number().int().min(1).max(MAX_VOLUME_GIB)
703
803
  });
704
- var RunScriptRequest = z.object({ input: z.unknown().optional() });
705
- var ScriptOutputSchema = z.object({ output: z.unknown() });
804
+ var RunScriptRequest = z2.object({ input: z2.unknown().optional() });
805
+ var ScriptOutputSchema = z2.object({ output: z2.unknown() });
706
806
  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),
807
+ var StartRunRequest = z2.object({
808
+ id: z2.string().regex(BOX_RUN_ID_RE),
809
+ command: z2.string().min(1).max(8192),
710
810
  /** The command and everything it started are killed after this long. */
711
- timeoutSec: z.number().int().min(1).max(86400),
811
+ timeoutSec: z2.number().int().min(1).max(86400),
712
812
  /**
713
813
  * The caller will read the output back (`exec`, #188): the box's kvbox-agent must know `runOutput`
714
814
  * (base v0.16.0+), which the host checks before the command starts, so an older box is `box-outdated`
715
815
  * without having run anything.
716
816
  */
717
- output: z.boolean().optional()
817
+ output: z2.boolean().optional()
718
818
  });
719
- var StartRunAnswerSchema = z.object({
720
- id: z.string(),
819
+ var StartRunAnswerSchema = z2.object({
820
+ id: z2.string(),
721
821
  /** False: a run of this id was already there. */
722
- started: z.boolean(),
822
+ started: z2.boolean(),
723
823
  /** The box was asleep and this request woke it. */
724
- woke: z.boolean()
824
+ woke: z2.boolean()
725
825
  });
726
826
  var BOX_RUN_STATES = ["running", "exited", "timeout", "unknown"];
727
- var BoxRunSchema = z.object({
728
- id: z.string(),
729
- state: z.enum(BOX_RUN_STATES),
827
+ var BoxRunSchema = z2.object({
828
+ id: z2.string(),
829
+ state: z2.enum(BOX_RUN_STATES),
730
830
  /** With `exited`; 128 + the signal for a command a signal ended. */
731
- exitCode: z.number().int().optional(),
831
+ exitCode: z2.number().int().optional(),
732
832
  /**
733
833
  * With `exited` and `timeout`: how long the command itself ran, by the box's own clock (base v0.15.1
734
834
  * and later). The asker learns of the end seconds late, so its own count is too long.
735
835
  */
736
- durationMs: z.number().int().nonnegative().optional()
836
+ durationMs: z2.number().int().nonnegative().optional()
737
837
  });
738
- var RunRefusalSchema = z.object({ error: z.string(), code: z.string().optional() });
838
+ var RunRefusalSchema = z2.object({ error: z2.string(), code: z2.string().optional() });
739
839
  var RUN_OUTPUT_MAX_BYTES = 1 << 20;
740
840
  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()
841
+ var RunOutputSchema = z2.object({
842
+ id: z2.string(),
843
+ stream: z2.enum(RUN_STREAMS),
844
+ offset: z2.number().int().nonnegative(),
845
+ size: z2.number().int().nonnegative(),
846
+ data: z2.string()
747
847
  });
748
848
  var DEFAULT_EXEC_TIMEOUT_SEC = 600;
749
- var ExecRequest = z.object({
750
- command: z.string().min(1).max(8192),
849
+ var ExecRequest = z2.object({
850
+ command: z2.string().min(1).max(8192),
751
851
  /** 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()
852
+ timeoutSec: z2.number().int().min(1).max(86400).optional()
753
853
  });
754
- var ExecStartSchema = z.object({
755
- id: z.string(),
854
+ var ExecStartSchema = z2.object({
855
+ id: z2.string(),
756
856
  /** The box was asleep and this request woke it. */
757
- woke: z.boolean()
857
+ woke: z2.boolean()
758
858
  });
759
- var ExecSchema = z.object({
760
- id: z.string(),
761
- state: z.enum(BOX_RUN_STATES),
859
+ var ExecSchema = z2.object({
860
+ id: z2.string(),
861
+ state: z2.enum(BOX_RUN_STATES),
762
862
  /** With `exited`; 128 + the signal for a command a signal ended. */
763
- exitCode: z.number().int().optional(),
863
+ exitCode: z2.number().int().optional(),
764
864
  /** 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(),
865
+ durationMs: z2.number().int().nonnegative().optional(),
866
+ stdout: z2.string().optional(),
867
+ stderr: z2.string().optional(),
868
+ stdoutBytes: z2.number().int().nonnegative().optional(),
869
+ stderrBytes: z2.number().int().nonnegative().optional(),
870
+ truncated: z2.boolean().optional()
871
+ });
872
+ var EnvVarSchema = z2.object({
873
+ name: z2.string(),
874
+ value: z2.string().optional(),
875
+ secret: z2.boolean(),
876
+ updatedAt: z2.string()
877
+ });
878
+ var BoxEnvSchema = z2.object({
879
+ box: z2.string(),
880
+ vars: z2.array(EnvVarSchema)
881
+ });
882
+ var BoxEnvChangeSchema = z2.object({
883
+ box: z2.string(),
884
+ name: z2.string(),
785
885
  /** Whether the box is running now: the change waits for its next start. */
786
- running: z.boolean()
886
+ running: z2.boolean()
787
887
  });
788
- var SetEnvRequest = z.object({
789
- value: z.string(),
790
- secret: z.boolean().optional()
888
+ var SetEnvRequest = z2.object({
889
+ value: z2.string(),
890
+ secret: z2.boolean().optional()
791
891
  });
792
- var EnvChangeSchema = z.object({
793
- owner: z.string(),
794
- name: z.string(),
795
- boxes: z.number().int()
892
+ var EnvChangeSchema = z2.object({
893
+ owner: z2.string(),
894
+ name: z2.string(),
895
+ boxes: z2.number().int()
796
896
  });
797
- var HostEnvRequest = z.object({
798
- version: z.number().int().min(0),
799
- vars: z.array(z.object({ name: z.string(), value: z.string() }))
897
+ var HostEnvRequest = z2.object({
898
+ version: z2.number().int().min(0),
899
+ vars: z2.array(z2.object({ name: z2.string(), value: z2.string() }))
800
900
  });
801
- var HostEnvVersionsSchema = z.array(z.object({ owner: z.string(), version: z.number().int() }));
802
- var CreateMachineRequest = z.object({
803
- name: z.string().optional(),
901
+ var HostEnvVersionsSchema = z2.array(z2.object({ owner: z2.string(), version: z2.number().int() }));
902
+ var CreateMachineRequest = z2.object({
903
+ name: z2.string().optional(),
804
904
  /** Ignored over the local socket (the caller is the host owner); the control plane sets it over HTTPS. */
805
- owner: z.string().optional(),
905
+ owner: z2.string().optional(),
806
906
  size: SizeSchema.optional(),
807
- from: z.string().optional(),
808
- force: z.boolean().optional(),
907
+ from: z2.string().optional(),
908
+ force: z2.boolean().optional(),
809
909
  /**
810
910
  * Extra authorized_keys lines for the box, on top of the host's own key: the control plane sends
811
911
  * its SSH CA as one `cert-authority …` line (#51). Written into the box's authorized_keys at every
812
912
  * boot (#49); a host older than that ignores them.
813
913
  */
814
- sshKeys: z.array(z.string()).optional(),
914
+ sshKeys: z2.array(z2.string()).optional(),
815
915
  /** 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(),
916
+ autoHibernateSec: z2.number().int().min(0).optional(),
817
917
  /**
818
918
  * Place the box on the host of this box (#98, `kvbox new --near`), so the two can be linked. Only the
819
919
  * control plane reads it; a host has one place to put a box.
820
920
  */
821
- near: z.string().optional(),
921
+ near: z2.string().optional(),
822
922
  /**
823
923
  * Place the box on a host in this country (`kvbox new --country romania`): a code or an English name,
824
924
  * `@kvbox/shared/country`. Only the control plane reads it.
825
925
  */
826
- country: z.string().optional(),
926
+ country: z2.string().optional(),
827
927
  /**
828
928
  * Place the box on the host of this name and nowhere else (`kvbox new --host kvbox2`, a hidden flag):
829
929
  * an admin's, to try a host out. Only the control plane reads it, and refuses it from anyone else.
830
930
  */
831
- host: z.string().optional(),
931
+ host: z2.string().optional(),
832
932
  /** The image to boot (#87, `kvbox new --base postgres`). Absent: the base image. */
833
- image: z.string().optional(),
933
+ image: z2.string().optional(),
834
934
  /** 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(),
935
+ env: z2.array(z2.object({ name: z2.string(), value: z2.string() })).optional(),
836
936
  /**
837
937
  * Start the box on this backup's disk (#141, `kvbox new --from-backup <id>`), a removed box's too: its image,
838
938
  * version and variables come from the backup, its size too unless given. Only the control plane reads it.
839
939
  */
840
- fromBackup: z.string().optional()
940
+ fromBackup: z2.string().optional(),
941
+ /**
942
+ * The integrations turned on for the box (#205, `kvbox new --integration github`). Absent: none, or with
943
+ * `from` / `fromBackup` the list the snapshot or the backup was taken with.
944
+ */
945
+ integrations: IntegrationListSchema.optional()
841
946
  });
842
947
  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(),
948
+ var ForkMachineRequest = z2.object({
949
+ name: z2.string().optional(),
845
950
  /**
846
951
  * The new box's slug, bare (`acme`): the control plane sends the target of `--org` here; the host
847
952
  * qualifies it with the caller's realm. Absent: the source's owner. A CLI leaves it out.
848
953
  */
849
- owner: z.string().optional(),
954
+ owner: z2.string().optional(),
850
955
  /** A cold fork only: a warm one keeps the source's vCPU and memory. */
851
956
  size: SizeSchema.optional(),
852
- force: z.boolean().optional(),
957
+ force: z2.boolean().optional(),
853
958
  /** 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()
959
+ sshKeys: z2.array(z2.string()).optional(),
960
+ autoHibernateSec: z2.number().int().min(0).optional()
856
961
  });
857
- var SetSshKeysRequest = z.object({
858
- sshKeys: z.array(z.string())
962
+ var SetSshKeysRequest = z2.object({
963
+ sshKeys: z2.array(z2.string())
859
964
  });
860
- var RescaleMachineRequest = z.object({
965
+ var RescaleMachineRequest = z2.object({
861
966
  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(),
967
+ vcpu: z2.number().int().min(1).max(64).optional(),
968
+ memMib: z2.number().int().min(256).optional(),
969
+ diskGib: z2.number().int().min(1).optional(),
865
970
  /** Skip the capacity guard when a running box grows (#37). */
866
- force: z.boolean().optional()
971
+ force: z2.boolean().optional()
867
972
  });
868
- var StartMachineRequest = z.object({
869
- force: z.boolean().optional()
973
+ var StartMachineRequest = z2.object({
974
+ force: z2.boolean().optional()
870
975
  });
871
- var SetMachineRequest = z.object({
976
+ var SetMachineRequest = z2.object({
872
977
  /** Seconds without network traffic before the box is hibernated (#47); 0: never. */
873
- autoHibernateSec: z.number().int().min(0).optional(),
978
+ autoHibernateSec: z2.number().int().min(0).optional(),
874
979
  /** 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(),
980
+ idleCheck: z2.union([z2.literal(""), z2.string().max(255).regex(/^\/[^\0\n]*$/, "an absolute path inside the box")]).optional(),
981
+ /** The box's integrations (#205), the whole list: `[]` turns every one off. Applies at once, in any state. */
982
+ integrations: IntegrationListSchema.optional()
983
+ });
984
+ var SnapshotSchema = z2.object({
985
+ name: z2.string(),
986
+ owner: z2.string(),
987
+ source: z2.string(),
881
988
  // the box it was taken from, as owner/name
882
- base: z.string(),
989
+ base: z2.string(),
883
990
  // version of the image the overlay stacks on; a restore needs the same one
884
991
  /** 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(),
992
+ image: z2.string().optional(),
993
+ vcpu: z2.number().int(),
994
+ memMib: z2.number().int(),
995
+ sizeBytes: z2.number().int(),
889
996
  // what vmstate + mem + overlay really occupy on the host
890
- createdAt: z.string()
997
+ createdAt: z2.string()
891
998
  });
892
- var CreateSnapshotRequest = z.object({
893
- box: z.string(),
894
- name: z.string(),
999
+ var CreateSnapshotRequest = z2.object({
1000
+ box: z2.string(),
1001
+ name: z2.string(),
895
1002
  /** 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(),
1003
+ replace: z2.boolean().optional()
1004
+ });
1005
+ var DiskCapacitySchema = z2.object({
1006
+ totalGib: z2.number().int(),
1007
+ freeGib: z2.number().int(),
1008
+ volumesGib: z2.number().int(),
1009
+ volumesUsedGib: z2.number().int(),
1010
+ headroomGib: z2.number().int()
1011
+ });
1012
+ var CapacitySchema = z2.object({
1013
+ hostMemMib: z2.number().int(),
1014
+ hostCores: z2.number().int(),
1015
+ reservedMemMib: z2.number().int(),
1016
+ reservedVcpu: z2.number().int(),
1017
+ running: z2.number().int(),
911
1018
  /**
912
1019
  * MiB of RAM the host keeps back from its boxes (config.json `memHeadroomMib`). Absent on a kvbox-server
913
1020
  * from before the setting, which keeps 2 GB (`OLD_HOST_MEM_HEADROOM_MIB`).
914
1021
  */
915
- memHeadroomMib: z.number().int().optional(),
1022
+ memHeadroomMib: z2.number().int().optional(),
916
1023
  /** Absent on a host from before volumes (#91): it cannot take one. */
917
1024
  disk: DiskCapacitySchema.optional(),
918
1025
  /**
919
1026
  * The images a new box can be made from here (#87), with the version `new` uses; the base is `base`.
920
1027
  * Absent on a host from before images: it has only the base.
921
1028
  */
922
- images: z.array(z.object({ name: z.string(), version: z.string() })).optional(),
1029
+ images: z2.array(z2.object({ name: z2.string(), version: z2.string() })).optional(),
923
1030
  /** 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(),
1031
+ version: z2.string().optional(),
925
1032
  /** 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(),
1033
+ backupStore: z2.object({ totalBytes: z2.number().int(), freeBytes: z2.number().int(), running: z2.boolean() }).optional(),
927
1034
  /** 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(),
1035
+ storeClient: z2.boolean().optional(),
929
1036
  /** True on a kvbox-server with `POST /machines/from-backup` (#141, `kvbox new --from-backup`); older ones omit it. */
930
- fromBackup: z.boolean().optional()
931
- });
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() }))
936
- });
937
- var LatestImagesSchema = z.object({
938
- updatedAt: z.string().nullable(),
1037
+ fromBackup: z2.boolean().optional(),
1038
+ /** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
1039
+ integrations: z2.boolean().optional(),
1040
+ /** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
1041
+ integrationIds: z2.array(z2.string()).optional()
1042
+ });
1043
+ var ImageSchema = z2.object({ name: z2.string(), version: z2.string().nullable() });
1044
+ var ImageIndexSchema = z2.object({
1045
+ updatedAt: z2.string(),
1046
+ images: z2.record(z2.string(), z2.object({ version: z2.string().min(1), minServer: z2.string().min(1).optional() }))
1047
+ });
1048
+ var LatestImagesSchema = z2.object({
1049
+ updatedAt: z2.string().nullable(),
939
1050
  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(),
1051
+ checkedAt: z2.string().nullable()
1052
+ });
1053
+ var RecoveryReportSchema = z2.object({
1054
+ at: z2.string(),
1055
+ booted: z2.array(z2.string()),
1056
+ leftStopped: z2.array(z2.string()),
1057
+ failed: z2.array(z2.object({ box: z2.string(), error: z2.string() }))
1058
+ });
1059
+ var HostUpdateSchema = z2.object({
1060
+ state: z2.enum(["running", "done", "failed"]),
1061
+ startedAt: z2.string(),
1062
+ finishedAt: z2.string().nullable(),
952
1063
  /** 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(),
1064
+ from: z2.string(),
1065
+ to: z2.string().nullable(),
1066
+ error: z2.string().nullable(),
1067
+ needsManual: z2.array(z2.string())
1068
+ });
1069
+ var HealthSchema = z2.object({
1070
+ ok: z2.literal(true),
1071
+ version: z2.string(),
1072
+ pid: z2.number().int(),
962
1073
  /** Base image version new boxes get (null when the host has no usable base image yet). */
963
- base: z.string().nullable(),
1074
+ base: z2.string().nullable(),
964
1075
  /** Owner that boxes made over the local socket get (the Unix user running the server). */
965
- owner: z.string(),
1076
+ owner: z2.string(),
966
1077
  /** The control plane this host joined (null when none). */
967
- controlPlane: z.object({
1078
+ controlPlane: z2.object({
968
1079
  /** Realm name, e.g. kvbox.sh. */
969
- name: z.string(),
970
- url: z.string(),
1080
+ name: z2.string(),
1081
+ url: z2.string(),
971
1082
  /** Where this host answers the control plane. */
972
- hostUrl: z.string()
1083
+ hostUrl: z2.string()
973
1084
  }).nullable(),
974
1085
  /** 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(),
1086
+ relay: z2.object({
1087
+ name: z2.string(),
977
1088
  /** The public IP the relay owns for this host. */
978
- publicIp: z.string(),
1089
+ publicIp: z2.string(),
979
1090
  /** The relay's WireGuard endpoint the tunnel dials. */
980
- endpoint: z.string(),
1091
+ endpoint: z2.string(),
981
1092
  /** 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()
1093
+ restarts: z2.number().int().optional(),
1094
+ lastRestartAt: z2.string().nullable().optional()
984
1095
  }).nullable().optional(),
985
1096
  /** 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
1097
  recovery: RecoveryReportSchema.nullable().optional(),
987
1098
  /** The last self-update; null when none ran. Older servers omit it. */
988
1099
  update: HostUpdateSchema.nullable().optional()
989
1100
  });
990
- var MachineUsageSchema = z.object({
991
- name: z.string(),
992
- owner: z.string(),
1101
+ var MachineUsageSchema = z2.object({
1102
+ name: z2.string(),
1103
+ owner: z2.string(),
993
1104
  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()
1105
+ window: z2.object({ from: z2.string(), to: z2.string() }),
1106
+ seconds: z2.object({
1107
+ running: z2.number().int(),
1108
+ standby: z2.number().int(),
1109
+ hibernated: z2.number().int(),
1110
+ stopped: z2.number().int()
1000
1111
  }),
1001
- vcpuHours: z.number(),
1002
- ramGibHours: z.number(),
1003
- diskGibHours: z.number(),
1004
- cost: z.object({ amount: z.number(), currency: z.string() }).optional(),
1112
+ vcpuHours: z2.number(),
1113
+ ramGibHours: z2.number(),
1114
+ diskGibHours: z2.number(),
1115
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
1005
1116
  /** 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()
1117
+ estimatedStops: z2.number().int(),
1118
+ historyFrom: z2.string().nullable()
1008
1119
  });
1009
- var GuestStatsSchema = z.object({
1120
+ var GuestStatsSchema = z2.object({
1010
1121
  /** 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(),
1122
+ load: z2.tuple([z2.number(), z2.number(), z2.number()]),
1123
+ cpus: z2.number().int(),
1124
+ memTotalMib: z2.number().int(),
1014
1125
  /** Total minus available: page cache counts as free. */
1015
- memUsedMib: z.number().int(),
1126
+ memUsedMib: z2.number().int(),
1016
1127
  /** 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()
1128
+ diskTotalBytes: z2.number().int(),
1129
+ diskUsedBytes: z2.number().int(),
1130
+ uptimeSec: z2.number().int()
1020
1131
  });
1021
- var MachineStatsSchema = z.object({
1022
- name: z.string(),
1023
- owner: z.string(),
1132
+ var MachineStatsSchema = z2.object({
1133
+ name: z2.string(),
1134
+ owner: z2.string(),
1024
1135
  stats: GuestStatsSchema.nullable()
1025
1136
  });
1026
- var UsageStatusSchema = z.enum([...BoxStatusSchema.options, "removed"]);
1137
+ var UsageStatusSchema = z2.enum([...BoxStatusSchema.options, "removed"]);
1027
1138
  var BoxUsageSchema = MachineUsageSchema.omit({ window: true, status: true }).extend({
1028
1139
  /** The host's box id; a name removed and recreated appears twice, with two ids. */
1029
- id: z.string(),
1140
+ id: z2.string(),
1030
1141
  status: UsageStatusSchema,
1031
1142
  /** 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(),
1143
+ ownerKind: z2.enum(["user", "org"]).optional(),
1033
1144
  /**
1034
1145
  * Through a control plane: the username that made the box (#60), absent when the box is gone from
1035
1146
  * the index (removed), was found by reconcile, or its maker was deleted. The ledger does not record it.
1036
1147
  */
1037
- createdBy: z.string().optional()
1148
+ createdBy: z2.string().optional()
1038
1149
  });
1039
- var VolumeUsageSchema = z.object({
1150
+ var VolumeUsageSchema = z2.object({
1040
1151
  /** 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(),
1152
+ id: z2.string(),
1153
+ name: z2.string(),
1154
+ owner: z2.string(),
1155
+ ownerKind: z2.enum(["user", "org"]).optional(),
1045
1156
  /** 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(),
1157
+ sizeGib: z2.number().int(),
1158
+ status: z2.enum(["present", "removed"]),
1159
+ volumeHours: z2.number(),
1160
+ volumeGibHours: z2.number(),
1161
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
1162
+ historyFrom: z2.string().nullable()
1163
+ });
1164
+ var CronUsageSchema = z2.object({
1165
+ id: z2.string(),
1166
+ name: z2.string(),
1167
+ owner: z2.string(),
1168
+ ownerKind: z2.enum(["user", "org"]).optional(),
1169
+ status: z2.enum(["present", "removed"]),
1170
+ hours: z2.number(),
1171
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional(),
1061
1172
  /** 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(),
1173
+ historyFrom: z2.string().nullable()
1174
+ });
1175
+ var BackupUsageSchema = z2.object({
1176
+ id: z2.string(),
1177
+ kind: z2.string(),
1178
+ name: z2.string(),
1179
+ owner: z2.string(),
1180
+ ownerKind: z2.enum(["user", "org"]).optional(),
1070
1181
  /** How many paid backups turned ready in the window. */
1071
- count: z.number().int(),
1072
- cost: z.object({ amount: z.number(), currency: z.string() })
1182
+ count: z2.number().int(),
1183
+ cost: z2.object({ amount: z2.number(), currency: z2.string() })
1073
1184
  });
1074
- var UsageDayItemSchema = z.object({
1075
- id: z.string(),
1076
- name: z.string(),
1077
- owner: z.string(),
1185
+ var UsageDayItemSchema = z2.object({
1186
+ id: z2.string(),
1187
+ name: z2.string(),
1188
+ owner: z2.string(),
1078
1189
  /** Removed by the end of the report's window. */
1079
- removed: z.boolean(),
1080
- cost: z.number()
1190
+ removed: z2.boolean(),
1191
+ cost: z2.number()
1081
1192
  });
1082
- var UsageDaySchema = z.object({
1193
+ var UsageDaySchema = z2.object({
1083
1194
  /** `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),
1195
+ date: z2.string(),
1196
+ from: z2.string(),
1197
+ to: z2.string(),
1198
+ cost: z2.number(),
1199
+ currency: z2.string(),
1200
+ boxes: z2.array(UsageDayItemSchema),
1201
+ volumes: z2.array(UsageDayItemSchema),
1091
1202
  /** Object storage that existed that day (#182); absent on a day without any. */
1092
- storage: z.array(UsageDayItemSchema).optional(),
1203
+ storage: z2.array(UsageDayItemSchema).optional(),
1093
1204
  /** Cron services that existed that day (#190); absent on a day without any. */
1094
- cron: z.array(UsageDayItemSchema).optional(),
1205
+ cron: z2.array(UsageDayItemSchema).optional(),
1095
1206
  /** 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()
1207
+ backups: z2.array(UsageDayItemSchema).optional()
1097
1208
  });
1098
- var UsageReportSchema = z.object({
1099
- window: z.object({ from: z.string(), to: z.string() }),
1100
- boxes: z.array(BoxUsageSchema),
1209
+ var UsageReportSchema = z2.object({
1210
+ window: z2.object({ from: z2.string(), to: z2.string() }),
1211
+ boxes: z2.array(BoxUsageSchema),
1101
1212
  /** Absent from a side older than #91. */
1102
- volumes: z.array(VolumeUsageSchema).optional(),
1213
+ volumes: z2.array(VolumeUsageSchema).optional(),
1103
1214
  /**
1104
1215
  * Object storage (#182, control plane only): one row per storage a slug has or had, shaped like a
1105
1216
  * volume's. `volumeHours` are the hours it existed, `volumeGibHours` those of the GiB beyond the
1106
1217
  * included ones, `sizeGib` its whole size. Absent when there is none.
1107
1218
  */
1108
- storage: z.array(VolumeUsageSchema).optional(),
1219
+ storage: z2.array(VolumeUsageSchema).optional(),
1109
1220
  /** 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(),
1221
+ cron: z2.array(CronUsageSchema).optional(),
1111
1222
  /** 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(),
1223
+ backups: z2.array(BackupUsageSchema).optional(),
1113
1224
  /** With `?by=day` only, oldest day first. */
1114
- days: z.array(UsageDaySchema).optional(),
1115
- totals: z.object({
1225
+ days: z2.array(UsageDaySchema).optional(),
1226
+ totals: z2.object({
1116
1227
  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(),
1228
+ vcpuHours: z2.number(),
1229
+ ramGibHours: z2.number(),
1230
+ diskGibHours: z2.number(),
1231
+ volumeHours: z2.number().optional(),
1232
+ volumeGibHours: z2.number().optional(),
1122
1233
  /** Boxes, volumes, object storage, cron services and paid backups together. */
1123
- cost: z.object({ amount: z.number(), currency: z.string() }).optional()
1234
+ cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
1124
1235
  })
1125
1236
  });
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()
1237
+ var UsageEventRowSchema = z2.object({
1238
+ id: z2.number().int(),
1239
+ boxId: z2.string(),
1240
+ owner: z2.string(),
1241
+ name: z2.string(),
1242
+ at: z2.string(),
1243
+ state: z2.enum(["running", "standby", "hibernated", "stopped"]),
1244
+ vcpu: z2.number().int(),
1245
+ memMib: z2.number().int(),
1246
+ diskGib: z2.number().int(),
1247
+ by: z2.string()
1248
+ });
1249
+ var UsageEventsResponseSchema = z2.object({
1250
+ ledger: z2.string().min(1),
1251
+ events: z2.array(UsageEventRowSchema),
1252
+ next: z2.number().int()
1253
+ });
1254
+ var VolumeEventRowSchema = z2.object({
1255
+ id: z2.number().int(),
1256
+ volumeId: z2.string(),
1257
+ owner: z2.string(),
1258
+ name: z2.string(),
1259
+ at: z2.string(),
1260
+ sizeGib: z2.number().int(),
1261
+ by: z2.enum(["create", "resize", "rm"])
1262
+ });
1263
+ var VolumeEventsResponseSchema = z2.object({
1264
+ ledger: z2.string().min(1),
1265
+ events: z2.array(VolumeEventRowSchema),
1266
+ next: z2.number().int()
1156
1267
  });
1157
1268
  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(),
1269
+ var ApiErrorCodeSchema = z2.enum(API_ERROR_CODES);
1270
+ var ApiErrorSchema = z2.object({
1271
+ error: z2.string(),
1161
1272
  code: ApiErrorCodeSchema.optional()
1162
1273
  });
1163
1274
  var DEFAULT_CLOUD_URL = "https://api.kvbox.sh";
1164
1275
  var ACTIVATED_BY = ["card", "admin"];
1165
- var ActivatedBySchema = z.enum(ACTIVATED_BY);
1166
- var CloudUserSchema = z.object({
1276
+ var ActivatedBySchema = z2.enum(ACTIVATED_BY);
1277
+ var CloudUserSchema = z2.object({
1167
1278
  /** The handle: what hosts file boxes under (`<username>@<control plane>`). Lowercase, no `@` or `/`. */
1168
- username: z.string(),
1279
+ username: z2.string(),
1169
1280
  /** Display name, free text ("Alexandru Ghiura"). */
1170
- name: z.string(),
1281
+ name: z2.string(),
1171
1282
  /** Login identity, unique. */
1172
- email: z.string(),
1173
- role: z.enum(["admin", "user"]),
1174
- createdAt: z.string(),
1283
+ email: z2.string(),
1284
+ role: z2.enum(["admin", "user"]),
1285
+ createdAt: z2.string(),
1175
1286
  /**
1176
1287
  * False until a card is on file or an admin activates the account (#74): then only `/me` and
1177
1288
  * `/logout` answer. Admins are never gated. A control plane older than #74 does not send these and
1178
1289
  * gates nobody, hence the defaults: a newer CLI must still parse its answers.
1179
1290
  */
1180
- active: z.boolean().default(true),
1291
+ active: z2.boolean().default(true),
1181
1292
  activatedBy: ActivatedBySchema.nullable().default(null),
1182
1293
  /** 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)
1294
+ lockedAt: z2.string().nullable().default(null)
1184
1295
  });
1185
1296
  var ORG_ROLES = ["owner", "admin", "member"];
1186
- var OrgRoleSchema = z.enum(ORG_ROLES);
1187
- var CloudOrgSchema = z.object({
1188
- slug: z.string(),
1297
+ var OrgRoleSchema = z2.enum(ORG_ROLES);
1298
+ var CloudOrgSchema = z2.object({
1299
+ slug: z2.string(),
1189
1300
  /** Display name; the slug never changes, this may. */
1190
- name: z.string(),
1191
- createdAt: z.string(),
1301
+ name: z2.string(),
1302
+ createdAt: z2.string(),
1192
1303
  /** 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),
1304
+ active: z2.boolean().default(true),
1194
1305
  activatedBy: ActivatedBySchema.nullable().default(null)
1195
1306
  });
1196
1307
  var OrgMembershipSchema = CloudOrgSchema.extend({ role: OrgRoleSchema });
1197
- var OrgMemberSchema = z.object({
1198
- username: z.string(),
1199
- name: z.string(),
1308
+ var OrgMemberSchema = z2.object({
1309
+ username: z2.string(),
1310
+ name: z2.string(),
1200
1311
  role: OrgRoleSchema,
1201
- addedAt: z.string()
1312
+ addedAt: z2.string()
1202
1313
  });
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)
1314
+ var OrgDetailSchema = CloudOrgSchema.extend({ members: z2.array(OrgMemberSchema) });
1315
+ var CreateOrgRequestSchema = z2.object({
1316
+ slug: z2.string().min(1),
1317
+ name: z2.string().min(1)
1207
1318
  });
1208
- var RenameOrgRequestSchema = z.object({ name: z.string().min(1) });
1209
- var AddMemberRequestSchema = z.object({
1210
- username: z.string().min(1),
1319
+ var RenameOrgRequestSchema = z2.object({ name: z2.string().min(1) });
1320
+ var AddMemberRequestSchema = z2.object({
1321
+ username: z2.string().min(1),
1211
1322
  role: OrgRoleSchema.default("member")
1212
1323
  });
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(),
1324
+ var SetRoleRequestSchema = z2.object({ role: OrgRoleSchema });
1325
+ var MeResponseSchema = CloudUserSchema.extend({ orgs: z2.array(OrgMembershipSchema) });
1326
+ var BalanceSchema = z2.object({
1327
+ slug: z2.string(),
1328
+ balance: z2.number(),
1329
+ currency: z2.string(),
1330
+ topUps: z2.number(),
1331
+ spent: z2.number(),
1221
1332
  /** 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(),
1333
+ since: z2.string().nullable(),
1223
1334
  /** 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),
1335
+ suspendedAt: z2.string().nullable().default(null),
1225
1336
  /** 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),
1337
+ promo: z2.number().default(0),
1227
1338
  /** When the next promo credit expires; null with none left. */
1228
- promoExpiresAt: z.string().nullable().default(null)
1339
+ promoExpiresAt: z2.string().nullable().default(null)
1229
1340
  });
1230
- var TopUpRequestSchema = z.object({
1231
- slug: z.string().min(1),
1341
+ var TopUpRequestSchema = z2.object({
1342
+ slug: z2.string().min(1),
1232
1343
  /** 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(),
1344
+ amount: z2.number().finite(),
1345
+ note: z2.string().max(200).optional()
1346
+ });
1347
+ var TopUpSchema = z2.object({
1348
+ id: z2.string(),
1349
+ slug: z2.string(),
1350
+ amount: z2.number(),
1351
+ currency: z2.string(),
1241
1352
  /** `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()
1353
+ source: z2.enum(["admin", "card", "trial", "transfer"]),
1354
+ note: z2.string().nullable(),
1355
+ at: z2.string()
1245
1356
  });
1246
- var CreateCodeRequestSchema = z.object({
1357
+ var CreateCodeRequestSchema = z2.object({
1247
1358
  /** In the control plane's currency, cents at most. */
1248
- amount: z.number().positive().multipleOf(0.01, "amount is in cents at most"),
1359
+ amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most"),
1249
1360
  /** 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(),
1361
+ expiresAt: z2.string().min(1),
1362
+ note: z2.string().max(200).optional()
1363
+ });
1364
+ var CreditCodeSchema = z2.object({
1365
+ code: z2.string(),
1366
+ amount: z2.number(),
1367
+ currency: z2.string(),
1368
+ expiresAt: z2.string(),
1369
+ note: z2.string().nullable(),
1370
+ status: z2.enum(["unused", "redeemed", "expired", "revoked"]),
1371
+ createdBy: z2.string(),
1372
+ createdAt: z2.string(),
1262
1373
  /** 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(),
1374
+ redeemedBy: z2.string().nullable(),
1375
+ redeemedSlug: z2.string().nullable(),
1376
+ redeemedAt: z2.string().nullable(),
1377
+ revokedAt: z2.string().nullable()
1378
+ });
1379
+ var RedeemRequestSchema = z2.object({
1380
+ code: z2.string().min(1).max(64),
1381
+ org: z2.string().min(1).optional()
1382
+ });
1383
+ var RedeemResponseSchema = z2.object({
1384
+ slug: z2.string(),
1385
+ amount: z2.number(),
1386
+ currency: z2.string(),
1387
+ expiresAt: z2.string(),
1277
1388
  balance: BalanceSchema,
1278
1389
  /** The slug was out of credit and this put it back above zero: it may start boxes again. */
1279
- reinstated: z.boolean()
1390
+ reinstated: z2.boolean()
1280
1391
  });
1281
1392
  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(),
1393
+ var BillingInfoSchema = z2.object({
1394
+ card: z2.object({ brand: z2.string(), last4: z2.string() }).nullable(),
1395
+ cardInUse: z2.boolean(),
1285
1396
  balance: BalanceSchema
1286
1397
  });
1287
- var BillingRedirectSchema = z.object({ url: z.string() });
1288
- var TopUpCheckoutRequestSchema = z.object({
1289
- amount: z.literal(TOP_UP_AMOUNTS)
1398
+ var BillingRedirectSchema = z2.object({ url: z2.string() });
1399
+ var TopUpCheckoutRequestSchema = z2.object({
1400
+ amount: z2.literal(TOP_UP_AMOUNTS)
1290
1401
  });
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")
1402
+ var TransferRequestSchema = z2.object({
1403
+ org: z2.string().min(1),
1404
+ amount: z2.number().positive().multipleOf(0.01, "amount is in cents at most")
1294
1405
  });
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()
1406
+ var TransferResponseSchema = z2.object({ from: BalanceSchema, to: BalanceSchema, activated: z2.boolean() });
1407
+ var LoginRequestSchema = z2.object({
1408
+ email: z2.string().min(1),
1409
+ password: z2.string().min(1),
1410
+ publicKey: z2.string().optional()
1300
1411
  });
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)
1412
+ var SignupRequestSchema = z2.object({
1413
+ username: z2.string().min(1),
1414
+ name: z2.string().min(1),
1415
+ email: z2.string().min(1),
1416
+ password: z2.string().min(1)
1306
1417
  });
1307
- var LoginResponseSchema = z.object({
1308
- token: z.string(),
1418
+ var LoginResponseSchema = z2.object({
1419
+ token: z2.string(),
1309
1420
  user: CloudUserSchema,
1310
- sshCert: z.string().optional(),
1311
- sshCertExpires: z.string().optional(),
1421
+ sshCert: z2.string().optional(),
1422
+ sshCertExpires: z2.string().optional(),
1312
1423
  /** 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()
1424
+ sshCertPrincipals: z2.array(z2.string()).optional()
1314
1425
  });
1315
1426
  var DEVICE_LOGIN_PICKUP_SEC = 60;
1316
- var DeviceLoginRequestSchema = z.object({
1427
+ var DeviceLoginRequestSchema = z2.object({
1317
1428
  // 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") })
1429
+ publicKey: z2.string().max(16384).optional(),
1430
+ hostname: z2.string().max(255).optional()
1431
+ });
1432
+ var DeviceLoginStartSchema = z2.object({
1433
+ deviceCode: z2.string(),
1434
+ userCode: z2.string(),
1435
+ verifyUrl: z2.string(),
1436
+ expiresIn: z2.number(),
1437
+ interval: z2.number()
1438
+ });
1439
+ var DeviceLoginPollRequestSchema = z2.object({ deviceCode: z2.string().min(1) });
1440
+ var DeviceLoginPollSchema = z2.union([
1441
+ z2.object({ status: z2.enum(["pending", "slow_down", "refused", "expired"]) }),
1442
+ LoginResponseSchema.extend({ status: z2.literal("approved") })
1332
1443
  ]);
1333
- var DeviceLoginInfoSchema = z.object({
1334
- userCode: z.string(),
1335
- hostname: z.string(),
1444
+ var DeviceLoginInfoSchema = z2.object({
1445
+ userCode: z2.string(),
1446
+ hostname: z2.string(),
1336
1447
  /** 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()
1448
+ ip: z2.string().nullable(),
1449
+ createdAt: z2.string(),
1450
+ expiresAt: z2.string()
1340
1451
  });
1341
1452
  var DEFAULT_API_KEY_DAYS = 90;
1342
1453
  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(),
1454
+ var ApiKeySchema = z2.object({
1455
+ name: z2.string(),
1456
+ createdAt: z2.string(),
1346
1457
  /** Last request made with it (ISO); null: never used. */
1347
- lastUsedAt: z.string().nullable(),
1458
+ lastUsedAt: z2.string().nullable(),
1348
1459
  /** When it stops working (ISO); null: never. */
1349
- expiresAt: z.string().nullable()
1460
+ expiresAt: z2.string().nullable()
1350
1461
  });
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()
1462
+ var CreateApiKeyRequestSchema = z2.object({
1463
+ name: z2.string().regex(API_KEY_NAME_RE, "a key's name is lowercase letters, digits, '.', '_' or '-' (up to 32 characters)"),
1464
+ expiresAt: z2.iso.datetime({ offset: true }).nullable().optional()
1354
1465
  });
1355
- var CreatedApiKeySchema = ApiKeySchema.extend({ key: z.string() });
1356
- var SshCertRequestSchema = z.object({
1357
- publicKey: z.string().min(1)
1466
+ var CreatedApiKeySchema = ApiKeySchema.extend({ key: z2.string() });
1467
+ var SshCertRequestSchema = z2.object({
1468
+ publicKey: z2.string().min(1)
1358
1469
  });
1359
- var SshCertResponseSchema = z.object({
1360
- cert: z.string(),
1361
- expires: z.string(),
1362
- principals: z.array(z.string())
1470
+ var SshCertResponseSchema = z2.object({
1471
+ cert: z2.string(),
1472
+ expires: z2.string(),
1473
+ principals: z2.array(z2.string())
1363
1474
  });
1364
- var SshCaResponseSchema = z.object({
1365
- publicKey: z.string(),
1475
+ var SshCaResponseSchema = z2.object({
1476
+ publicKey: z2.string(),
1366
1477
  /** 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()
1478
+ retired: z2.array(z2.object({ publicKey: z2.string(), retiredAt: z2.string() })).optional()
1368
1479
  });
1369
- var HostSshCaResponseSchema = z.object({
1370
- publicKey: z.string()
1480
+ var HostSshCaResponseSchema = z2.object({
1481
+ publicKey: z2.string()
1371
1482
  });
1372
- var CloudCaSchema = z.object({
1373
- controlPlane: z.string(),
1374
- publicKey: z.string(),
1375
- fingerprint: z.string()
1483
+ var CloudCaSchema = z2.object({
1484
+ controlPlane: z2.string(),
1485
+ publicKey: z2.string(),
1486
+ fingerprint: z2.string()
1376
1487
  });
1377
- var TrustCaRequestSchema = z.object({
1378
- publicKey: z.string().min(1)
1488
+ var TrustCaRequestSchema = z2.object({
1489
+ publicKey: z2.string().min(1)
1379
1490
  });
1380
- var SshKeysAppliedSchema = z.enum(["now", "start", "wake", "resume", "later"]);
1381
- var TrustCaReportSchema = z.object({
1382
- publicKey: z.string(),
1383
- fingerprint: z.string(),
1491
+ var SshKeysAppliedSchema = z2.enum(["now", "start", "wake", "resume", "later"]);
1492
+ var TrustCaReportSchema = z2.object({
1493
+ publicKey: z2.string(),
1494
+ fingerprint: z2.string(),
1384
1495
  /** The guest trusts the CA now. */
1385
- updated: z.array(z.string()),
1496
+ updated: z2.array(z2.string()),
1386
1497
  /** 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() })),
1498
+ pending: z2.array(z2.object({ box: z2.string(), when: SshKeysAppliedSchema, why: z2.string().optional() })),
1499
+ failed: z2.array(z2.object({ box: z2.string(), error: z2.string() })),
1389
1500
  /** Local boxes, untouched: they trust the host's key only. */
1390
- local: z.number().int(),
1501
+ local: z2.number().int(),
1391
1502
  /** 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),
1503
+ skipped: z2.array(z2.string()).optional()
1504
+ });
1505
+ var HostJoinRequestSchema = z2.object({
1506
+ token: z2.string().min(1),
1507
+ name: z2.string().min(1),
1508
+ url: z2.string().url(),
1509
+ fingerprint: z2.string().regex(/^([0-9A-F]{2}:){31}[0-9A-F]{2}$/),
1510
+ publicAddress: z2.string().min(1),
1400
1511
  /** 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(),
1512
+ country: z2.string().optional()
1513
+ });
1514
+ var HostJoinResponseSchema = z2.object({
1515
+ hostSecret: z2.string(),
1516
+ controlPlane: z2.object({ name: z2.string() })
1517
+ });
1518
+ var CloudHostSchema = z2.object({
1519
+ name: z2.string(),
1520
+ url: z2.string(),
1521
+ publicAddress: z2.string(),
1522
+ joinedAt: z2.string(),
1523
+ lastSeenAt: z2.string().nullable(),
1413
1524
  capacity: CapacitySchema.nullable(),
1414
1525
  /** ISO 3166-1 alpha-2 code (`RO`), null when nobody said where the host is. */
1415
- country: z.string().nullable(),
1526
+ country: z2.string().nullable(),
1416
1527
  /** The S3 region a storage made on this host answers to (`ro-west-1`); null: it takes no storage. */
1417
- region: z.string().nullable(),
1528
+ region: z2.string().nullable(),
1418
1529
  /** 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()
1530
+ version: z2.string().nullable()
1420
1531
  });
1421
- var HostInfoSchema = z.object({
1532
+ var HostInfoSchema = z2.object({
1422
1533
  host: CloudHostSchema,
1423
1534
  health: HealthSchema.nullable(),
1424
- error: z.string().nullable()
1535
+ error: z2.string().nullable()
1425
1536
  });
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() });
1537
+ 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" });
1538
+ var CountrySchema = z2.object({ code: z2.string(), name: z2.string() });
1428
1539
 
1429
1540
  // src/session.ts
1430
- var SessionSchema = z2.object({
1431
- url: z2.string(),
1432
- token: z2.string(),
1433
- user: z2.string(),
1541
+ var SessionSchema = z3.object({
1542
+ url: z3.string(),
1543
+ token: z3.string(),
1544
+ user: z3.string(),
1434
1545
  /** When the SSH certificate at paths().sshCert stops being accepted (ISO); absent before the first login with a key. */
1435
- sshCertExpires: z2.string().optional(),
1546
+ sshCertExpires: z3.string().optional(),
1436
1547
  /** Whose boxes that certificate opens (`<slug>@<realm>`, the user and their orgs); absent with `sshCertExpires`. */
1437
- sshCertPrincipals: z2.array(z2.string()).optional()
1548
+ sshCertPrincipals: z3.array(z3.string()).optional()
1438
1549
  });
1439
1550
  async function readSession(p = paths()) {
1440
1551
  let text2;
@@ -1613,7 +1724,7 @@ import { setTimeout as sleep2 } from "timers/promises";
1613
1724
  import { Agent, request } from "undici";
1614
1725
 
1615
1726
  // ../sdk/src/machines.ts
1616
- import { z as z3 } from "zod";
1727
+ import { z as z4 } from "zod";
1617
1728
 
1618
1729
  // ../sdk/src/errors.ts
1619
1730
  var KvboxSdkError = class extends Error {
@@ -1725,7 +1836,7 @@ var Machines = class {
1725
1836
  ports;
1726
1837
  /** Every box the caller can read (their own and their orgs'), sorted by owner then name. */
1727
1838
  list(opts = {}) {
1728
- return this.transport.request("GET", `/machines${listQuery(opts)}`, z3.array(MachineSchema), { org: opts.org });
1839
+ return this.transport.request("GET", `/machines${listQuery(opts)}`, z4.array(MachineSchema), { org: opts.org });
1729
1840
  }
1730
1841
  /**
1731
1842
  * One box, found in the listing (the API has no route for a single box). `slug/name` looks in that
@@ -1739,7 +1850,7 @@ var Machines = class {
1739
1850
  async find(name, orgOpt, timeoutMs) {
1740
1851
  const slash = name.indexOf("/");
1741
1852
  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 });
1853
+ const listing = await this.transport.request("GET", "/machines", z4.array(MachineSchema), { org, timeoutMs });
1743
1854
  const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
1744
1855
  if (named.length <= 1) {
1745
1856
  if (named[0] !== void 0) return named[0];
@@ -1764,9 +1875,16 @@ var Machines = class {
1764
1875
  }
1765
1876
  return made;
1766
1877
  }
1878
+ /**
1879
+ * Change a box's settings; anything left out stays as it is. `integrations` is the whole list of
1880
+ * integrations turned on for the box (`["github"]`, `[]` for none): it applies at once, with no restart.
1881
+ */
1882
+ set(name, settings, opts = {}) {
1883
+ return this.transport.request("POST", box(name, "/set"), MachineSchema, { body: settings, org: opts.org });
1884
+ }
1767
1885
  /** Remove the box and its disk. */
1768
1886
  async remove(name, opts = {}) {
1769
- await this.transport.request("DELETE", box(name), z3.undefined(), { org: opts.org });
1887
+ await this.transport.request("DELETE", box(name), z4.undefined(), { org: opts.org });
1770
1888
  }
1771
1889
  /** Boot a stopped box. */
1772
1890
  start(name, opts = {}) {
@@ -1916,7 +2034,7 @@ var slugOf2 = (owner) => {
1916
2034
  };
1917
2035
 
1918
2036
  // ../sdk/src/snapshots.ts
1919
- import { z as z4 } from "zod";
2037
+ import { z as z5 } from "zod";
1920
2038
  var Snapshots = class {
1921
2039
  constructor(transport) {
1922
2040
  this.transport = transport;
@@ -1924,19 +2042,19 @@ var Snapshots = class {
1924
2042
  transport;
1925
2043
  /** Every snapshot the caller can read. */
1926
2044
  list(opts = {}) {
1927
- return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z4.array(SnapshotSchema), { org: opts.org });
2045
+ return this.transport.request("GET", `/snapshots${listQuery(opts)}`, z5.array(SnapshotSchema), { org: opts.org });
1928
2046
  }
1929
2047
  /** Snapshot box `req.box` as `req.name` (`replace`: retake one that exists). The box is paused while it is taken. */
1930
2048
  create(req, opts = {}) {
1931
2049
  return this.transport.request("POST", "/snapshots", SnapshotSchema, { body: req, org: opts.org });
1932
2050
  }
1933
2051
  async remove(name, opts = {}) {
1934
- await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z4.undefined(), { org: opts.org });
2052
+ await this.transport.request("DELETE", `/snapshots/${encodeURIComponent(name)}`, z5.undefined(), { org: opts.org });
1935
2053
  }
1936
2054
  };
1937
2055
 
1938
2056
  // ../sdk/src/transport.ts
1939
- import { z as z5 } from "zod";
2057
+ import { z as z6 } from "zod";
1940
2058
  var Transport = class {
1941
2059
  baseUrl;
1942
2060
  org;
@@ -2010,7 +2128,7 @@ var Transport = class {
2010
2128
  }
2011
2129
  }
2012
2130
  };
2013
- var LooseApiErrorSchema = z5.object({ error: z5.string(), code: z5.string().optional() });
2131
+ var LooseApiErrorSchema = z6.object({ error: z6.string(), code: z6.string().optional() });
2014
2132
  function safeJson(text2) {
2015
2133
  try {
2016
2134
  return JSON.parse(text2);
@@ -2027,8 +2145,21 @@ function errorCode(err) {
2027
2145
  return void 0;
2028
2146
  }
2029
2147
 
2148
+ // ../sdk/src/integrations.ts
2149
+ import { z as z7 } from "zod";
2150
+ var Integrations = class {
2151
+ constructor(transport) {
2152
+ this.transport = transport;
2153
+ }
2154
+ transport;
2155
+ /** Each readable slug's state for each integration (`org`: one org's), connected or not; never a credential. */
2156
+ list(opts = {}) {
2157
+ return this.transport.request("GET", "/integrations", z7.array(IntegrationSchema), { org: opts.org });
2158
+ }
2159
+ };
2160
+
2030
2161
  // ../sdk/src/volumes.ts
2031
- import { z as z6 } from "zod";
2162
+ import { z as z8 } from "zod";
2032
2163
  var volume = (name, rest = "") => `/volumes/${encodeURIComponent(name)}${rest}`;
2033
2164
  var Volumes = class {
2034
2165
  constructor(transport) {
@@ -2036,7 +2167,7 @@ var Volumes = class {
2036
2167
  }
2037
2168
  transport;
2038
2169
  list(opts = {}) {
2039
- return this.transport.request("GET", `/volumes${listQuery(opts)}`, z6.array(VolumeSchema), { org: opts.org });
2170
+ return this.transport.request("GET", `/volumes${listQuery(opts)}`, z8.array(VolumeSchema), { org: opts.org });
2040
2171
  }
2041
2172
  /**
2042
2173
  * Make a volume of `sizeGib` GiB. Through the cloud `box` is required: the volume is made on that
@@ -2059,7 +2190,7 @@ var Volumes = class {
2059
2190
  }
2060
2191
  /** Remove the volume and its data; it must be detached first. */
2061
2192
  async remove(name, opts = {}) {
2062
- await this.transport.request("DELETE", volume(name), z6.undefined(), { org: opts.org });
2193
+ await this.transport.request("DELETE", volume(name), z8.undefined(), { org: opts.org });
2063
2194
  }
2064
2195
  };
2065
2196
 
@@ -2080,6 +2211,7 @@ var Kvbox = class {
2080
2211
  machines;
2081
2212
  snapshots;
2082
2213
  volumes;
2214
+ integrations;
2083
2215
  transport;
2084
2216
  constructor(opts = {}) {
2085
2217
  this.transport = new Transport({
@@ -2092,6 +2224,7 @@ var Kvbox = class {
2092
2224
  this.machines = new Machines(this.transport);
2093
2225
  this.snapshots = new Snapshots(this.transport);
2094
2226
  this.volumes = new Volumes(this.transport);
2227
+ this.integrations = new Integrations(this.transport);
2095
2228
  }
2096
2229
  /** The API this client talks to, without a trailing slash. */
2097
2230
  get baseUrl() {
@@ -2107,35 +2240,35 @@ var Kvbox = class {
2107
2240
  };
2108
2241
 
2109
2242
  // src/client.ts
2110
- import { z as z11 } from "zod";
2243
+ import { z as z13 } from "zod";
2111
2244
 
2112
2245
  // ../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),
2246
+ import { z as z9 } from "zod";
2247
+ var PricingSchema = z9.object({
2248
+ currency: z9.string().min(1),
2249
+ vcpuHour: z9.number().nonnegative(),
2250
+ ramGibHour: z9.number().nonnegative(),
2251
+ diskGibHour: z9.number().nonnegative(),
2252
+ volumeHour: z9.number().nonnegative().default(0),
2253
+ volumeGibHour: z9.number().nonnegative().default(0),
2254
+ diskIncludedGib: z9.number().int().nonnegative().default(0),
2122
2255
  /**
2123
2256
  * Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
2124
2257
  * hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
2125
2258
  * A price list from before object storage charges nothing for it.
2126
2259
  */
2127
- storageHour: z7.number().nonnegative().default(0),
2128
- storageGibHour: z7.number().nonnegative().default(0),
2129
- storageIncludedGib: z7.number().int().nonnegative().default(0),
2260
+ storageHour: z9.number().nonnegative().default(0),
2261
+ storageGibHour: z9.number().nonnegative().default(0),
2262
+ storageIncludedGib: z9.number().int().nonnegative().default(0),
2130
2263
  /** 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),
2264
+ cronHour: z9.number().nonnegative().default(0),
2132
2265
  /**
2133
2266
  * One backup a person starts, of anything, charged once it is ready (decision "A backup taken by hand
2134
2267
  * costs a flat price…"); a failed one and a scheduled one cost nothing. A price list from before it charges nothing.
2135
2268
  */
2136
- backup: z7.number().nonnegative().default(0)
2269
+ backup: z9.number().nonnegative().default(0)
2137
2270
  });
2138
- var PriceListSchema = PricingSchema.extend({ welcomeCredit: z7.number().nonnegative() });
2271
+ var PriceListSchema = PricingSchema.extend({ welcomeCredit: z9.number().nonnegative() });
2139
2272
  var HOUR_MS = 36e5;
2140
2273
  var round = (n, places) => Math.round(n * 10 ** places) / 10 ** places;
2141
2274
  function costOf(t, pricing) {
@@ -2163,86 +2296,86 @@ function sumUsage(items, pricing) {
2163
2296
  var DAY_MS = 24 * HOUR_MS;
2164
2297
 
2165
2298
  // ../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({
2299
+ import { z as z10 } from "zod";
2300
+ var PriceSchema = z10.object({ perMonth: z10.number(), storagePerMonth: z10.number(), currency: z10.string() });
2301
+ var ManagedCatalogEntrySchema = z10.object({
2169
2302
  /** The kind, as in `/managed/<kind>`: `postgres`. */
2170
- kind: z8.string(),
2303
+ kind: z10.string(),
2171
2304
  /** The CLI command for it: `pg` (`kvbox pg create …`). */
2172
- command: z8.string(),
2173
- title: z8.string(),
2174
- description: z8.string(),
2305
+ command: z10.string(),
2306
+ title: z10.string(),
2307
+ description: z10.string(),
2175
2308
  /** The version a new one runs, as shown: `18`. */
2176
- version: z8.string(),
2309
+ version: z10.string(),
2177
2310
  /** The port a linked box reaches it on. */
2178
- port: z8.number().int(),
2311
+ port: z10.number().int(),
2179
2312
  /** The port `public on` opens behind a host port: `port` again unless the kind serves TLS on another. */
2180
- publicPort: z8.number().int(),
2313
+ publicPort: z10.number().int(),
2181
2314
  /** 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() }),
2315
+ docs: z10.string().optional(),
2316
+ storage: z10.object({ defaultGib: z10.number().int(), minGib: z10.number().int(), maxGib: z10.number().int() }),
2184
2317
  /**
2185
2318
  * What create takes of this kind alone, beside what every kind takes (name, password, storage, near): a
2186
2319
  * flag and a form field each, all optional, `default` in words.
2187
2320
  */
2188
- options: z8.array(z8.object({ name: z8.string(), title: z8.string(), description: z8.string(), default: z8.string() })),
2321
+ options: z10.array(z10.object({ name: z10.string(), title: z10.string(), description: z10.string(), default: z10.string() })),
2189
2322
  /** A month of it running with the default storage, and each further GB of storage. */
2190
- price: PriceSchema.extend({ storageGibPerMonth: z8.number() }),
2323
+ price: PriceSchema.extend({ storageGibPerMonth: z10.number() }),
2191
2324
  /** Whether a host answering now can run it. */
2192
- available: z8.boolean()
2325
+ available: z10.boolean()
2193
2326
  });
2194
- var CreateManagedRequest = z8.object({
2195
- name: z8.string(),
2327
+ var CreateManagedRequest = z10.object({
2328
+ name: z10.string(),
2196
2329
  /** 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(),
2330
+ options: z10.record(z10.string(), z10.string()).optional(),
2331
+ password: z10.string().optional(),
2332
+ storageGib: z10.number().int().optional(),
2200
2333
  /** Place it on the host of this box, so the box can be linked to it. */
2201
- near: z8.string().optional(),
2334
+ near: z10.string().optional(),
2202
2335
  /**
2203
2336
  * A backup of a database of the same kind and major version, of the same account (#186): the new
2204
2337
  * service starts on its data, a removed service's included. Its settings (Postgres: database, user)
2205
2338
  * are the backup's; the password is the new one.
2206
2339
  */
2207
- fromBackup: z8.string().optional()
2340
+ fromBackup: z10.string().optional()
2208
2341
  });
2209
- var ManagedHealthSchema = z8.object({
2342
+ var ManagedHealthSchema = z10.object({
2210
2343
  /** Its first start has finished: it has set itself up on its storage. */
2211
- ready: z8.boolean(),
2344
+ ready: z10.boolean(),
2212
2345
  /** It accepts connections. */
2213
- accepting: z8.boolean(),
2214
- version: z8.string(),
2346
+ accepting: z10.boolean(),
2347
+ version: z10.string(),
2215
2348
  /** The storage volume: what is used of it and its size. */
2216
- storageUsedBytes: z8.number().optional(),
2217
- storageTotalBytes: z8.number().optional(),
2349
+ storageUsedBytes: z10.number().optional(),
2350
+ storageTotalBytes: z10.number().optional(),
2218
2351
  /** What else the kind reports, ready to show: `{title: "Connections", value: "3"}`. */
2219
- facts: z8.array(z8.object({ title: z8.string(), value: z8.string() }))
2352
+ facts: z10.array(z10.object({ title: z10.string(), value: z10.string() }))
2220
2353
  });
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(),
2354
+ var UrlsSchema = z10.object({ private: z10.string(), public: z10.string().optional() });
2355
+ var ManagedSchema = z10.object({
2356
+ kind: z10.string(),
2357
+ name: z10.string(),
2225
2358
  /** The owning slug, bare. */
2226
- owner: z8.string(),
2227
- ownerKind: z8.enum(["user", "org"]),
2359
+ owner: z10.string(),
2360
+ ownerKind: z10.enum(["user", "org"]),
2228
2361
  /** `running`, `stopped` (storage only is charged), `hibernated` or `standby` (out of credit), `unknown` (its host does not answer). */
2229
2362
  status: BoxStatusSchema,
2230
2363
  /** The catalog version: `18`. */
2231
- version: z8.string(),
2364
+ version: z10.string(),
2232
2365
  /** 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(),
2366
+ settings: z10.record(z10.string(), z10.string()),
2367
+ storageGib: z10.number().int(),
2235
2368
  /** 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() }),
2369
+ private: z10.object({ host: z10.string(), port: z10.number().int() }),
2237
2370
  /** 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(),
2371
+ public: z10.object({ host: z10.string(), port: z10.number().int() }).nullable(),
2239
2372
  /** The boxes linked to it, as the caller would name them. */
2240
- links: z8.array(z8.string()),
2373
+ links: z10.array(z10.string()),
2241
2374
  /** 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(),
2375
+ host: z10.string(),
2376
+ country: z10.string().optional(),
2377
+ createdBy: z10.string().nullable(),
2378
+ createdAt: z10.string(),
2246
2379
  /** Connection strings with the password as `****`. */
2247
2380
  urls: UrlsSchema,
2248
2381
  price: PriceSchema,
@@ -2251,230 +2384,230 @@ var ManagedSchema = z8.object({
2251
2384
  /** Only in `GET /managed/<kind>/<name>` (asked live): null when it is not running or did not answer. */
2252
2385
  health: ManagedHealthSchema.nullable().optional()
2253
2386
  });
2254
- var ManagedSecretSchema = z8.object({ password: z8.string(), urls: UrlsSchema });
2387
+ var ManagedSecretSchema = z10.object({ password: z10.string(), urls: UrlsSchema });
2255
2388
  var CreatedManagedSchema = ManagedSchema.extend({
2256
2389
  secret: ManagedSecretSchema,
2257
2390
  /** 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),
2391
+ fromBackup: z10.string().optional()
2392
+ });
2393
+ var ResetPasswordRequest = z10.object({ password: z10.string().optional() });
2394
+ var SetPublicRequest = z10.object({ on: z10.boolean() });
2395
+ var ManagedLinkRequest = z10.object({ box: z10.string() });
2396
+ var GrowManagedRequest = z10.object({ storageGib: z10.number().int() });
2397
+ var ManagedBackupSchema = z10.object({
2398
+ id: z10.string(),
2399
+ owner: z10.string(),
2400
+ kind: z10.string(),
2401
+ name: z10.string(),
2402
+ version: z10.string(),
2403
+ status: z10.enum(BACKUP_STATUSES),
2271
2404
  /** Why it failed; null otherwise. */
2272
- error: z8.string().nullable(),
2405
+ error: z10.string().nullable(),
2273
2406
  /** The service's storage when taken. */
2274
- diskBytes: z8.number().int().nullable(),
2407
+ diskBytes: z10.number().int().nullable(),
2275
2408
  /** What it holds: the slots that are not all zeros. */
2276
- dataBytes: z8.number().int().nullable(),
2409
+ dataBytes: z10.number().int().nullable(),
2277
2410
  /** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
2278
- uploadedBytes: z8.number().int().nullable(),
2411
+ uploadedBytes: z10.number().int().nullable(),
2279
2412
  /** Who asked for it; for a scheduled one, the database's creator. */
2280
- createdBy: z8.string().nullable(),
2413
+ createdBy: z10.string().nullable(),
2281
2414
  /** 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()
2415
+ scheduled: z10.boolean().default(false),
2416
+ createdAt: z10.string(),
2417
+ finishedAt: z10.string().nullable()
2285
2418
  });
2286
2419
 
2287
2420
  // ../shared/src/cron.ts
2288
- import { z as z9 } from "zod";
2421
+ import { z as z11 } from "zod";
2289
2422
  var DEFAULT_CRON_COMMAND_TIMEOUT_SEC = 600;
2290
2423
  var MAX_CRON_COMMAND_TIMEOUT_SEC = 3600;
2291
2424
  var CRON_RUN_LOG_DIR = "/var/log/kvbox/runs";
2292
2425
  var CRON_METHODS = ["GET", "POST"];
2293
2426
  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(),
2427
+ var CronServiceSchema = z11.object({
2428
+ owner: z11.string(),
2429
+ ownerKind: z11.enum(["user", "org"]),
2430
+ name: z11.string(),
2298
2431
  /** Runs kept per trigger. */
2299
- keepRuns: z9.number().int(),
2300
- triggers: z9.number().int(),
2301
- createdBy: z9.string().nullable(),
2302
- createdAt: z9.string(),
2432
+ keepRuns: z11.number().int(),
2433
+ triggers: z11.number().int(),
2434
+ createdBy: z11.string().nullable(),
2435
+ createdAt: z11.string(),
2303
2436
  /** What it costs while it exists; on the answer to `POST /cron` only. */
2304
- price: z9.object({ perMonth: z9.number(), currency: z9.string() }).optional()
2437
+ price: z11.object({ perMonth: z11.number(), currency: z11.string() }).optional()
2305
2438
  });
2306
2439
  var triggerCommon = {
2307
- id: z9.string(),
2308
- service: z9.string(),
2309
- owner: z9.string(),
2440
+ id: z11.string(),
2441
+ service: z11.string(),
2442
+ owner: z11.string(),
2310
2443
  /** The box it acts on; a trigger is removed with its box. */
2311
- box: z9.string(),
2444
+ box: z11.string(),
2312
2445
  /** Five fields, `minute hour day-of-month month day-of-week`. */
2313
- expr: z9.string(),
2446
+ expr: z11.string(),
2314
2447
  /** An IANA zone (`Europe/Bucharest`) the expression is read in; `UTC` unless said. */
2315
- timezone: z9.string(),
2448
+ timezone: z11.string(),
2316
2449
  /** False: paused, it fires again when resumed. */
2317
- enabled: z9.boolean(),
2450
+ enabled: z11.boolean(),
2318
2451
  /** 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()
2452
+ nextRunAt: z11.string().nullable(),
2453
+ lastRunAt: z11.string().nullable(),
2454
+ lastOutcome: z11.enum(CRON_OUTCOMES).nullable(),
2455
+ createdBy: z11.string().nullable(),
2456
+ createdAt: z11.string()
2324
2457
  };
2325
- var CronHttpTriggerSchema = z9.object({
2458
+ var CronHttpTriggerSchema = z11.object({
2326
2459
  ...triggerCommon,
2327
- kind: z9.literal("http"),
2328
- method: z9.enum(CRON_METHODS),
2329
- port: z9.number().int(),
2460
+ kind: z11.literal("http"),
2461
+ method: z11.enum(CRON_METHODS),
2462
+ port: z11.number().int(),
2330
2463
  /** Path and query, starting with `/`. */
2331
- path: z9.string()
2464
+ path: z11.string()
2332
2465
  });
2333
- var CronCommandTriggerSchema = z9.object({
2466
+ var CronCommandTriggerSchema = z11.object({
2334
2467
  ...triggerCommon,
2335
- kind: z9.literal("command"),
2468
+ kind: z11.literal("command"),
2336
2469
  /** Run by a login shell as the box's user, in its home. */
2337
- command: z9.string(),
2470
+ command: z11.string(),
2338
2471
  /** The command is stopped after this long. */
2339
- timeoutSec: z9.number().int()
2472
+ timeoutSec: z11.number().int()
2340
2473
  });
2341
- var CronTriggerSchema = z9.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2342
- var CronRunSchema = z9.object({
2474
+ var CronTriggerSchema = z11.discriminatedUnion("kind", [CronHttpTriggerSchema, CronCommandTriggerSchema]);
2475
+ var CronRunSchema = z11.object({
2343
2476
  /** 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(),
2477
+ scheduledFor: z11.string(),
2478
+ startedAt: z11.string(),
2346
2479
  /** Null while `running`, and for a run that was never sent. */
2347
- durationMs: z9.number().int().nullable(),
2480
+ durationMs: z11.number().int().nullable(),
2348
2481
  /** The box's HTTP status; null when it never answered, and for a command. */
2349
- status: z9.number().int().nullable(),
2482
+ status: z11.number().int().nullable(),
2350
2483
  /** 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(),
2484
+ exitCode: z11.number().int().nullable(),
2352
2485
  /** 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),
2486
+ output: z11.string().nullable(),
2487
+ outcome: z11.enum(CRON_OUTCOMES),
2355
2488
  /** Why it did not end `ok`, in a line. */
2356
- error: z9.string().nullable(),
2489
+ error: z11.string().nullable(),
2357
2490
  /** The box was hibernated and this run woke it. */
2358
- woke: z9.boolean()
2491
+ woke: z11.boolean()
2359
2492
  });
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(),
2493
+ var CronCatalogSchema = z11.object({
2494
+ price: z11.object({ perMonth: z11.number(), currency: z11.string() }),
2495
+ maxServices: z11.number().int(),
2496
+ maxTriggers: z11.number().int(),
2497
+ keepRuns: z11.number().int(),
2365
2498
  /** The shortest time between two runs of one trigger, in seconds. */
2366
- minIntervalSeconds: z9.number().int(),
2499
+ minIntervalSeconds: z11.number().int(),
2367
2500
  /** How long a box has to answer, in seconds. */
2368
- timeoutSeconds: z9.number().int(),
2501
+ timeoutSeconds: z11.number().int(),
2369
2502
  /** 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(),
2503
+ commandTimeoutSeconds: z11.number().int(),
2504
+ maxCommandTimeoutSeconds: z11.number().int(),
2505
+ docs: z11.string().optional()
2506
+ });
2507
+ var CreateCronServiceRequest = z11.object({ name: z11.string() });
2508
+ var CreateCronTriggerRequest = z11.object({
2509
+ box: z11.string().min(1),
2510
+ expr: z11.string().min(1),
2511
+ timezone: z11.string().optional(),
2379
2512
  /** 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(),
2513
+ method: z11.enum(CRON_METHODS).optional(),
2514
+ port: z11.number().int().min(1).max(65535).optional(),
2515
+ path: z11.string().optional(),
2383
2516
  /** Or a command, with `timeoutSec`; exactly one of `port` and `command`. */
2384
- command: z9.string().optional(),
2385
- timeoutSec: z9.number().int().optional()
2517
+ command: z11.string().optional(),
2518
+ timeoutSec: z11.number().int().optional()
2386
2519
  });
2387
- var UpdateCronTriggerRequest = z9.object({ enabled: z9.boolean() });
2520
+ var UpdateCronTriggerRequest = z11.object({ enabled: z11.boolean() });
2388
2521
  var cronTarget = (t) => t.kind === "command" ? `${t.box}$ ${t.command}` : `${t.method} ${t.box}:${t.port}${t.path}`;
2389
2522
 
2390
2523
  // ../shared/src/storage.ts
2391
- import { z as z10 } from "zod";
2392
- var RegionSchema = z10.object({ name: z10.string(), country: z10.string().nullable() });
2524
+ import { z as z12 } from "zod";
2525
+ var RegionSchema = z12.object({ name: z12.string(), country: z12.string().nullable() });
2393
2526
  var MAX_PUBLIC_BUCKETS = 10;
2394
2527
  var STORAGE_BOX_SUBDOMAINS = MAX_PUBLIC_BUCKETS + 2;
2395
- var ObjectStorageSchema = z10.object({
2396
- owner: z10.string(),
2397
- ownerKind: z10.enum(["user", "org"]),
2528
+ var ObjectStorageSchema = z12.object({
2529
+ owner: z12.string(),
2530
+ ownerKind: z12.enum(["user", "org"]),
2398
2531
  /** `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(),
2532
+ endpoint: z12.string().nullable(),
2400
2533
  /** The S3 region every client of it signs with (`ro-west-1`): its host's when it was made. */
2401
- region: z10.string(),
2534
+ region: z12.string(),
2402
2535
  /** The most it may hold. */
2403
- sizeGib: z10.number().int(),
2536
+ sizeGib: z12.number().int(),
2404
2537
  /** `running` when it answers; `unknown` while its host is not heard from. */
2405
2538
  status: BoxStatusSchema,
2406
2539
  /** 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(),
2540
+ usedBytes: z12.number().optional(),
2541
+ totalBytes: z12.number().optional(),
2409
2542
  /** 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() });
2543
+ bucketUsage: z12.array(z12.object({ name: z12.string(), objects: z12.number(), bytes: z12.number() })).optional(),
2544
+ host: z12.string(),
2545
+ country: z12.string().optional(),
2546
+ buckets: z12.number().int(),
2547
+ price: z12.object({ perMonth: z12.number(), currency: z12.string() }),
2548
+ createdAt: z12.string()
2549
+ });
2550
+ var BucketSchema = z12.object({
2551
+ name: z12.string(),
2552
+ owner: z12.string(),
2553
+ ownerKind: z12.enum(["user", "org"]),
2554
+ endpoint: z12.string().nullable(),
2555
+ publicUrl: z12.string().optional(),
2556
+ region: z12.string(),
2557
+ keys: z12.number().int(),
2558
+ objects: z12.number().optional(),
2559
+ bytes: z12.number().optional(),
2560
+ createdBy: z12.string().nullable(),
2561
+ createdAt: z12.string()
2562
+ });
2563
+ var CreateBucketRequest = z12.object({
2564
+ name: z12.string(),
2565
+ sizeGib: z12.number().int().optional(),
2566
+ near: z12.string().optional(),
2567
+ region: z12.string().optional()
2568
+ });
2569
+ var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z12.boolean() });
2437
2570
  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),
2571
+ var SetBucketPublicRequest = z12.object({ on: z12.boolean(), sub: z12.string().optional() });
2572
+ var BucketKeySchema = z12.object({
2573
+ id: z12.string(),
2574
+ name: z12.string(),
2575
+ bucket: z12.string(),
2576
+ owner: z12.string(),
2577
+ readOnly: z12.boolean(),
2578
+ createdBy: z12.string().nullable(),
2579
+ createdAt: z12.string()
2580
+ });
2581
+ var CreateBucketKeyRequest = z12.object({ name: z12.string().optional(), readOnly: z12.boolean().optional() });
2582
+ var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z12.string(), endpoint: z12.string().nullable(), region: z12.string() });
2583
+ var GrowStorageRequest = z12.object({ sizeGib: z12.number().int() });
2584
+ var StorageBackupSchema = z12.object({
2585
+ id: z12.string(),
2586
+ owner: z12.string(),
2587
+ status: z12.enum(BACKUP_STATUSES),
2455
2588
  /** Why it failed; null otherwise. */
2456
- error: z10.string().nullable(),
2589
+ error: z12.string().nullable(),
2457
2590
  /** The storage's volume when taken. */
2458
- diskBytes: z10.number().int().nullable(),
2591
+ diskBytes: z12.number().int().nullable(),
2459
2592
  /** What it holds: the slots that are not all zeros. */
2460
- dataBytes: z10.number().int().nullable(),
2593
+ dataBytes: z12.number().int().nullable(),
2461
2594
  /** What this backup added to the backup store (encrypted, compressed). */
2462
- uploadedBytes: z10.number().int().nullable(),
2595
+ uploadedBytes: z12.number().int().nullable(),
2463
2596
  /** 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(),
2597
+ buckets: z12.array(z12.string()),
2598
+ keys: z12.number().int(),
2599
+ createdBy: z12.string().nullable(),
2600
+ createdAt: z12.string(),
2601
+ finishedAt: z12.string().nullable()
2602
+ });
2603
+ var RestoredKeySchema = z12.object({ bucket: z12.string(), id: z12.string(), name: z12.string() });
2604
+ var StorageRestoreSchema = z12.object({
2605
+ backup: z12.string(),
2473
2606
  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())
2607
+ buckets: z12.object({ kept: z12.array(z12.string()), returned: z12.array(z12.string()), removed: z12.array(z12.string()) }),
2608
+ keys: z12.object({ dropped: z12.array(RestoredKeySchema), revoked: z12.array(RestoredKeySchema) }),
2609
+ checked: z12.boolean(),
2610
+ warnings: z12.array(z12.string())
2478
2611
  });
2479
2612
  var OBJECT_LIST_MAX = 1e3;
2480
2613
  var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
@@ -2484,56 +2617,56 @@ var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
2484
2617
  var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
2485
2618
  var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
2486
2619
  var DELETE_PREFIXES_MAX = 100;
2487
- var StoredObjectSchema = z10.object({
2488
- key: z10.string(),
2489
- size: z10.number(),
2490
- etag: z10.string(),
2620
+ var StoredObjectSchema = z12.object({
2621
+ key: z12.string(),
2622
+ size: z12.number(),
2623
+ etag: z12.string(),
2491
2624
  /** 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(),
2625
+ modified: z12.string()
2626
+ });
2627
+ var ObjectListingSchema = z12.object({
2628
+ prefix: z12.string(),
2629
+ folders: z12.array(z12.string()),
2630
+ objects: z12.array(StoredObjectSchema),
2631
+ next: z12.string().optional(),
2632
+ canWrite: z12.boolean()
2633
+ });
2634
+ var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z12.string() });
2635
+ var ObjectCountSchema = z12.object({ objects: z12.number(), bytes: z12.number(), more: z12.boolean() });
2636
+ var ObjectLinkRequest = z12.object({
2637
+ key: z12.string(),
2638
+ expiresSec: z12.number().int().positive(),
2506
2639
  /** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
2507
- download: z10.boolean().optional(),
2640
+ download: z12.boolean().optional(),
2508
2641
  /**
2509
2642
  * Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
2510
2643
  * so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
2511
2644
  * is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
2512
2645
  * Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
2513
2646
  */
2514
- cached: z10.boolean().optional()
2647
+ cached: z12.boolean().optional()
2515
2648
  });
2516
- var ObjectLinkSchema = z10.object({ url: z10.string(), expiresAt: z10.string() });
2649
+ var ObjectLinkSchema = z12.object({ url: z12.string(), expiresAt: z12.string() });
2517
2650
  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()) })
2651
+ 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() });
2652
+ var UploadPlanSchema = z12.discriminatedUnion("kind", [
2653
+ z12.object({ kind: z12.literal("single"), url: z12.string() }),
2654
+ z12.object({ kind: z12.literal("multipart"), uploadId: z12.string(), partSize: z12.number(), urls: z12.array(z12.string()) })
2522
2655
  ]);
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)
2656
+ var CompleteUploadRequest = z12.object({
2657
+ key: z12.string(),
2658
+ uploadId: z12.string(),
2659
+ parts: z12.array(z12.object({ part: z12.number().int().positive(), etag: z12.string() })).min(1)
2527
2660
  });
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() }))
2661
+ var AbortUploadRequest = z12.object({ key: z12.string(), uploadId: z12.string() });
2662
+ var DeleteObjectsRequest = z12.object({ keys: z12.array(z12.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z12.array(z12.string()).max(DELETE_PREFIXES_MAX).optional() });
2663
+ var DeletedObjectsSchema = z12.object({
2664
+ deleted: z12.number(),
2665
+ more: z12.boolean(),
2666
+ errors: z12.array(z12.object({ key: z12.string(), message: z12.string() }))
2534
2667
  });
2535
- var MoveObjectRequest = z10.object({ from: z10.string(), to: z10.string(), overwrite: z10.boolean().optional() });
2536
- var CreateFolderRequest = z10.object({ prefix: z10.string() });
2668
+ var MoveObjectRequest = z12.object({ from: z12.string(), to: z12.string(), overwrite: z12.boolean().optional() });
2669
+ var CreateFolderRequest = z12.object({ prefix: z12.string() });
2537
2670
 
2538
2671
  // src/kvm.ts
2539
2672
  import { accessSync, constants, readFileSync, statSync } from "fs";
@@ -2647,7 +2780,7 @@ var ServerClient = class {
2647
2780
  startedOnce = false;
2648
2781
  async call(method, path, schema, body, org = this.target.kind === "cloud" ? this.target.org : void 0, timeoutMs) {
2649
2782
  try {
2650
- return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org : void 0, timeoutMs });
2783
+ return await this.sdk.request(method, path, schema, { body, org: this.target.kind === "cloud" ? org ?? void 0 : void 0, timeoutMs });
2651
2784
  } catch (err) {
2652
2785
  return this.failed(err, () => this.call(method, path, schema, body, org, timeoutMs));
2653
2786
  }
@@ -2703,7 +2836,7 @@ var ServerClient = class {
2703
2836
  * `all`: every box on the platform (platform admins only, #78).
2704
2837
  */
2705
2838
  listMachines(opts = {}) {
2706
- return this.call("GET", `/machines${allQuery(opts)}`, z11.array(MachineSchema), void 0, opts.org);
2839
+ return this.call("GET", `/machines${allQuery(opts)}`, z13.array(MachineSchema), void 0, opts.org);
2707
2840
  }
2708
2841
  createMachine(req) {
2709
2842
  return this.call("POST", "/machines", MachineSchema, req, void 0, req.fromBackup !== void 0 ? 2 * 36e5 : void 0);
@@ -2757,10 +2890,10 @@ var ServerClient = class {
2757
2890
  }
2758
2891
  /** Backups, the control plane's only: a box's disk in object storage. Newest first. */
2759
2892
  listBackups() {
2760
- return this.call("GET", "/backups", z11.array(BackupSchema));
2893
+ return this.call("GET", "/backups", z13.array(BackupSchema));
2761
2894
  }
2762
2895
  boxBackups(name) {
2763
- return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z11.array(BackupSchema));
2896
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z13.array(BackupSchema));
2764
2897
  }
2765
2898
  boxBackup(name, id) {
2766
2899
  return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
@@ -2774,14 +2907,14 @@ var ServerClient = class {
2774
2907
  * later. Works for a backup whose box, volume or database is gone too.
2775
2908
  */
2776
2909
  removeBackup(id) {
2777
- return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z11.undefined());
2910
+ return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z13.undefined());
2778
2911
  }
2779
2912
  /** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
2780
2913
  listVolumeBackups() {
2781
- return this.call("GET", "/backups?kind=volume", z11.array(VolumeBackupSchema));
2914
+ return this.call("GET", "/backups?kind=volume", z13.array(VolumeBackupSchema));
2782
2915
  }
2783
2916
  volumeBackups(name) {
2784
- return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z11.array(VolumeBackupSchema));
2917
+ return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z13.array(VolumeBackupSchema));
2785
2918
  }
2786
2919
  volumeBackup(name, id) {
2787
2920
  return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
@@ -2800,7 +2933,7 @@ var ServerClient = class {
2800
2933
  }
2801
2934
  /** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
2802
2935
  boxHooks(name) {
2803
- return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z11.array(WakeHookSchema));
2936
+ return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z13.array(WakeHookSchema));
2804
2937
  }
2805
2938
  createBoxHook(name) {
2806
2939
  return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
@@ -2828,7 +2961,7 @@ var ServerClient = class {
2828
2961
  }
2829
2962
  /** Every readable box's subdomains, one entry each. */
2830
2963
  listSubdomains() {
2831
- return this.call("GET", "/subdomains", z11.array(SubdomainSchema));
2964
+ return this.call("GET", "/subdomains", z13.array(SubdomainSchema));
2832
2965
  }
2833
2966
  /** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
2834
2967
  addDomain(name, req) {
@@ -2839,7 +2972,7 @@ var ServerClient = class {
2839
2972
  }
2840
2973
  /** Every readable box's custom domains. */
2841
2974
  listDomains() {
2842
- return this.call("GET", "/domains", z11.array(DomainSchema));
2975
+ return this.call("GET", "/domains", z13.array(DomainSchema));
2843
2976
  }
2844
2977
  /** A running box's own load, memory and disk, asked of its guest (#67). */
2845
2978
  machineStats(name) {
@@ -2872,22 +3005,22 @@ var ServerClient = class {
2872
3005
  return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
2873
3006
  }
2874
3007
  deleteMachine(name) {
2875
- return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z11.undefined());
3008
+ return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z13.undefined());
2876
3009
  }
2877
3010
  /** Like `listMachines`, for snapshots. */
2878
3011
  listSnapshots(opts = {}) {
2879
- return this.call("GET", `/snapshots${allQuery(opts)}`, z11.array(SnapshotSchema), void 0, opts.org);
3012
+ return this.call("GET", `/snapshots${allQuery(opts)}`, z13.array(SnapshotSchema), void 0, opts.org);
2880
3013
  }
2881
3014
  createSnapshot(req) {
2882
3015
  return this.call("POST", "/snapshots", SnapshotSchema, req);
2883
3016
  }
2884
3017
  deleteSnapshot(name) {
2885
- return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z11.undefined());
3018
+ return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z13.undefined());
2886
3019
  }
2887
3020
  // ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
2888
3021
  /** `org`: that org's list instead of `--org`'s (or the caller's own). */
2889
3022
  listEnv(org) {
2890
- return this.call("GET", "/vars", z11.array(EnvVarSchema), void 0, org);
3023
+ return this.call("GET", "/vars", z13.array(EnvVarSchema), void 0, org);
2891
3024
  }
2892
3025
  setEnv(name, req) {
2893
3026
  return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
@@ -2907,13 +3040,13 @@ var ServerClient = class {
2907
3040
  }
2908
3041
  // ---- volumes (#52) ----
2909
3042
  listVolumes(opts = {}) {
2910
- return this.call("GET", `/volumes${allQuery(opts)}`, z11.array(VolumeSchema), void 0, opts.org);
3043
+ return this.call("GET", `/volumes${allQuery(opts)}`, z13.array(VolumeSchema), void 0, opts.org);
2911
3044
  }
2912
3045
  createVolume(req) {
2913
3046
  return this.call("POST", "/volumes", VolumeSchema, req);
2914
3047
  }
2915
3048
  deleteVolume(name) {
2916
- return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z11.undefined());
3049
+ return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z13.undefined());
2917
3050
  }
2918
3051
  /** Both answer with the box as it is afterwards (restarted when it was running). */
2919
3052
  attachVolume(name, req) {
@@ -2928,7 +3061,7 @@ var ServerClient = class {
2928
3061
  }
2929
3062
  // ---- cron service (#190): the control plane's alone ----
2930
3063
  listCronServices(opts = {}) {
2931
- return this.call("GET", `/cron${allQuery(opts)}`, z11.array(CronServiceSchema), void 0, opts.org);
3064
+ return this.call("GET", `/cron${allQuery(opts)}`, z13.array(CronServiceSchema), void 0, opts.org);
2932
3065
  }
2933
3066
  createCronService(name) {
2934
3067
  return this.call("POST", "/cron", CronServiceSchema, { name });
@@ -2937,10 +3070,10 @@ var ServerClient = class {
2937
3070
  return this.call("GET", `/cron/${encodeURIComponent(name)}`, CronServiceSchema);
2938
3071
  }
2939
3072
  deleteCronService(name) {
2940
- return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z11.undefined());
3073
+ return this.call("DELETE", `/cron/${encodeURIComponent(name)}`, z13.undefined());
2941
3074
  }
2942
3075
  listCronTriggers(service) {
2943
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z11.array(CronTriggerSchema));
3076
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers`, z13.array(CronTriggerSchema));
2944
3077
  }
2945
3078
  addCronTrigger(service, req) {
2946
3079
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers`, CronTriggerSchema, req);
@@ -2950,18 +3083,18 @@ var ServerClient = class {
2950
3083
  return this.call("PATCH", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, CronTriggerSchema, { enabled: enabled2 });
2951
3084
  }
2952
3085
  deleteCronTrigger(service, id) {
2953
- return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z11.undefined());
3086
+ return this.call("DELETE", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}`, z13.undefined());
2954
3087
  }
2955
3088
  /** Marks it due: kvbox-cron fires it within a few seconds. */
2956
3089
  runCronTrigger(service, id) {
2957
3090
  return this.call("POST", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/run`, CronTriggerSchema);
2958
3091
  }
2959
3092
  listCronRuns(service, id, limit) {
2960
- return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z11.array(CronRunSchema));
3093
+ return this.call("GET", `/cron/${encodeURIComponent(service)}/triggers/${encodeURIComponent(id)}/runs${limit === void 0 ? "" : `?limit=${limit}`}`, z13.array(CronRunSchema));
2961
3094
  }
2962
3095
  // ---- object storage (#182): the control plane's alone ----
2963
3096
  listBuckets(opts = {}) {
2964
- return this.call("GET", `/buckets${allQuery(opts)}`, z11.array(BucketSchema), void 0, opts.org);
3097
+ return this.call("GET", `/buckets${allQuery(opts)}`, z13.array(BucketSchema), void 0, opts.org);
2965
3098
  }
2966
3099
  /** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
2967
3100
  createBucket(req) {
@@ -2975,26 +3108,26 @@ var ServerClient = class {
2975
3108
  return this.call("PUT", `/buckets/${encodeURIComponent(name)}/public`, BucketSchema, req);
2976
3109
  }
2977
3110
  deleteBucket(name, force = false) {
2978
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z11.undefined());
3111
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z13.undefined());
2979
3112
  }
2980
3113
  listBucketKeys(name) {
2981
- return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z11.array(BucketKeySchema));
3114
+ return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z13.array(BucketKeySchema));
2982
3115
  }
2983
3116
  createBucketKey(name, req) {
2984
3117
  return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
2985
3118
  }
2986
3119
  deleteBucketKey(name, id) {
2987
- return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z11.undefined());
3120
+ return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z13.undefined());
2988
3121
  }
2989
3122
  listStorage(opts = {}) {
2990
- return this.call("GET", `/storage${allQuery(opts)}`, z11.array(ObjectStorageSchema), void 0, opts.org);
3123
+ return this.call("GET", `/storage${allQuery(opts)}`, z13.array(ObjectStorageSchema), void 0, opts.org);
2991
3124
  }
2992
3125
  growStorage(sizeGib) {
2993
3126
  return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
2994
3127
  }
2995
3128
  /** Backups of the slug's whole object storage (#186 slice 3), newest first. */
2996
3129
  storageBackups() {
2997
- return this.call("GET", "/storage/backups", z11.array(StorageBackupSchema));
3130
+ return this.call("GET", "/storage/backups", z13.array(StorageBackupSchema));
2998
3131
  }
2999
3132
  storageBackup(id) {
3000
3133
  return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
@@ -3015,11 +3148,11 @@ var ServerClient = class {
3015
3148
  return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
3016
3149
  }
3017
3150
  managedCatalog() {
3018
- return this.call("GET", "/managed/catalog", z11.array(ManagedCatalogEntrySchema));
3151
+ return this.call("GET", "/managed/catalog", z13.array(ManagedCatalogEntrySchema));
3019
3152
  }
3020
3153
  /** One kind's services, or every kind's when `kind` is left out. */
3021
3154
  listManaged(kind, opts = {}) {
3022
- return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z11.array(ManagedSchema), void 0, opts.org);
3155
+ return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z13.array(ManagedSchema), void 0, opts.org);
3023
3156
  }
3024
3157
  /** From a backup (`fromBackup`) it waits for the restore too: the control plane gives its host 2 h for the download. */
3025
3158
  createManaged(kind, req) {
@@ -3030,7 +3163,7 @@ var ServerClient = class {
3030
3163
  return this.call("GET", this.managedPath(kind, name), ManagedSchema);
3031
3164
  }
3032
3165
  deleteManaged(kind, name) {
3033
- return this.call("DELETE", this.managedPath(kind, name), z11.undefined());
3166
+ return this.call("DELETE", this.managedPath(kind, name), z13.undefined());
3034
3167
  }
3035
3168
  managedPassword(kind, name) {
3036
3169
  return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
@@ -3052,10 +3185,10 @@ var ServerClient = class {
3052
3185
  }
3053
3186
  /** 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
3187
  listManagedBackups(kind) {
3055
- return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z11.array(ManagedBackupSchema));
3188
+ return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z13.array(ManagedBackupSchema));
3056
3189
  }
3057
3190
  managedBackups(kind, name) {
3058
- return this.call("GET", this.managedPath(kind, name, "/backups"), z11.array(ManagedBackupSchema));
3191
+ return this.call("GET", this.managedPath(kind, name, "/backups"), z13.array(ManagedBackupSchema));
3059
3192
  }
3060
3193
  managedBackup(kind, name, id) {
3061
3194
  return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
@@ -3097,24 +3230,36 @@ var ServerClient = class {
3097
3230
  return this.call("POST", "/login/device/token", DeviceLoginPollSchema, { deviceCode });
3098
3231
  }
3099
3232
  logout() {
3100
- return this.call("POST", "/logout", z11.unknown()).then(() => void 0);
3233
+ return this.call("POST", "/logout", z13.unknown()).then(() => void 0);
3101
3234
  }
3102
3235
  me() {
3103
3236
  return this.call("GET", "/me", MeResponseSchema);
3104
3237
  }
3238
+ // ---- Integrations (`kvbox integration ls`, #205) ----
3239
+ /**
3240
+ * What one org has connected (`org`, else the `--org` one), or without either each readable slug; never a
3241
+ * credential. Null: each readable slug whatever `--org` says, which is how the caller's own slug is read.
3242
+ */
3243
+ listIntegrations(org) {
3244
+ return this.call("GET", "/integrations", z13.array(IntegrationSchema), void 0, org);
3245
+ }
3246
+ /** What can be connected on this control plane, and by which kind of slug. */
3247
+ integrationCatalog() {
3248
+ return this.call("GET", "/integrations/catalog", z13.array(IntegrationCatalogEntrySchema), void 0, null);
3249
+ }
3105
3250
  // ---- API keys (`kvbox key …`, #189) ----
3106
3251
  listApiKeys() {
3107
- return this.call("GET", "/keys", z11.array(ApiKeySchema));
3252
+ return this.call("GET", "/keys", z13.array(ApiKeySchema));
3108
3253
  }
3109
3254
  createApiKey(req) {
3110
3255
  return this.call("POST", "/keys", CreatedApiKeySchema, req);
3111
3256
  }
3112
3257
  deleteApiKey(name) {
3113
- return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z11.unknown()).then(() => void 0);
3258
+ return this.call("DELETE", `/keys/${encodeURIComponent(name)}`, z13.unknown()).then(() => void 0);
3114
3259
  }
3115
3260
  // ---- orgs (`kvbox org …`) ----
3116
3261
  listOrgs() {
3117
- return this.call("GET", "/orgs", z11.array(OrgMembershipSchema));
3262
+ return this.call("GET", "/orgs", z13.array(OrgMembershipSchema));
3118
3263
  }
3119
3264
  createOrg(req) {
3120
3265
  return this.call("POST", "/orgs", CloudOrgSchema, req);
@@ -3123,16 +3268,16 @@ var ServerClient = class {
3123
3268
  return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
3124
3269
  }
3125
3270
  deleteOrg(slug) {
3126
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z11.undefined());
3271
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z13.undefined());
3127
3272
  }
3128
3273
  addMember(slug, req) {
3129
- return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z11.undefined(), req);
3274
+ return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z13.undefined(), req);
3130
3275
  }
3131
3276
  setRole(slug, username, role) {
3132
- return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z11.unknown(), { role }).then(() => void 0);
3277
+ return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.unknown(), { role }).then(() => void 0);
3133
3278
  }
3134
3279
  removeMember(slug, username) {
3135
- return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z11.undefined());
3280
+ return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z13.undefined());
3136
3281
  }
3137
3282
  /** Sign this machine's key again (#51); the key must be one the user logged in with. */
3138
3283
  sshCert(req) {
@@ -3564,10 +3709,47 @@ function parseDuration(text2) {
3564
3709
  return sec;
3565
3710
  }
3566
3711
 
3712
+ // src/commands/integration/shared.ts
3713
+ function whereToConnect(catalog, id) {
3714
+ const page = (catalog.find((e) => e.id === id) ?? catalog.find((e) => e.page !== void 0))?.page;
3715
+ return page === void 0 ? "in the web app" : `at ${page}`;
3716
+ }
3717
+ function integrationsKept(asked, box2) {
3718
+ if (asked === void 0) return true;
3719
+ const have = box2.integrations ?? [];
3720
+ return asked.length === have.length && asked.every((id) => have.includes(id));
3721
+ }
3722
+ var integrationsText = (list) => list?.length ? list.join(", ") : "none";
3723
+ function connectable(catalog, id, own) {
3724
+ const entry = catalog.find((e) => e.id === id);
3725
+ return entry === void 0 || entry.kinds[own ? "user" : "org"].length > 0;
3726
+ }
3727
+ var catalogOf = (client) => client.integrationCatalog().catch(() => []);
3728
+ async function noteNotConnected(client, box2, asked) {
3729
+ if (asked.length === 0 || client.target.kind !== "cloud") {
3730
+ if (asked.length > 0) warn(`box ${box2.name}: integrations need the kvbox cloud; a box made on this machine never gets a credential`);
3731
+ return;
3732
+ }
3733
+ const slug = slugOf(box2.owner);
3734
+ const [rows2, catalog] = await Promise.all([client.listIntegrations(null).catch(() => null), catalogOf(client)]);
3735
+ if (rows2 === null) return;
3736
+ for (const id of asked) {
3737
+ const row = rows2.find((r) => r.owner === slug && r.integration === id);
3738
+ if (row === void 0 || row.connected && row.status === "ok") continue;
3739
+ if (!row.connected && !connectable(catalog, id, slug === me(client))) {
3740
+ 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`));
3741
+ continue;
3742
+ }
3743
+ const why = row.connected ? `${id} needs to be connected again for ${slug}` : `${id} is not connected for ${slug} yet`;
3744
+ info(color.dim(` ${why}: it is on for this box and works once connected ${whereToConnect(catalog, id)}`));
3745
+ }
3746
+ }
3747
+
3567
3748
  // 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) => {
3749
+ 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,claude (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
3750
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
3570
3751
  const env = parseEnvFlags(opts.env);
3752
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
3571
3753
  const country = opts.country === void 0 ? void 0 : parseCountry(opts.country);
3572
3754
  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
3755
  if (opts.fromBackup !== void 0) {
@@ -3600,6 +3782,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3600
3782
  ...country !== void 0 ? { country } : {},
3601
3783
  ...opts.host !== void 0 ? { host: opts.host } : {},
3602
3784
  ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {},
3785
+ ...integrations !== void 0 ? { integrations } : {},
3603
3786
  ...opts.force ? { force: true } : {}
3604
3787
  }));
3605
3788
  if (opts.fromBackup !== void 0 && !box2.source.startsWith("backup:")) {
@@ -3609,6 +3792,7 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3609
3792
  if (opts.base !== void 0 && opts.base !== "base" && box2.image === void 0) {
3610
3793
  warn(`box ${box2.name}: its host runs a kvbox-server too old for images; it booted the base image, not ${opts.base}`);
3611
3794
  }
3795
+ if (integrations?.length && !integrationsKept(integrations, box2)) warn(`box ${box2.name}: its host runs a kvbox-server too old for integrations; it has none`);
3612
3796
  if (env.length > 0) {
3613
3797
  const kept = await keptVars(client, displayName(box2, me(client)), env.map((v) => v.name));
3614
3798
  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 +3810,10 @@ var newCommand = new Command("new").description("boot a new box from an image (t
3626
3810
  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
3811
  else info(` connect with: kvbox connect ${displayName(box2, user)} (SSH is up a couple of seconds after boot)`);
3628
3812
  if (box2.autoHibernateSec) info(` it ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
3813
+ if (box2.integrations?.length) {
3814
+ info(` integrations: ${integrationsText(box2.integrations)}`);
3815
+ await noteNotConnected(client, box2, box2.integrations);
3816
+ }
3629
3817
  if (box2.connect !== void 0) {
3630
3818
  info(` reach it at: ${box2.connect}`);
3631
3819
  info(` from another box once linked: kvbox vm link <box> ${displayName(box2, user)} --port <port>`);
@@ -3937,6 +4125,9 @@ var lsCommand = new Command6("ls").description("list boxes with status and addre
3937
4125
  }
3938
4126
  if (org !== void 0) info(`boxes of ${org}`);
3939
4127
  table(lsRows(boxes, cloud ? { me: me(client), showHost: admin } : void 0));
4128
+ const behind = boxes.filter((b) => b.latestBase !== void 0 && b.managed === void 0);
4129
+ const asleep = behind.some((b) => b.status === "hibernated");
4130
+ if (behind.length > 0) info(color.dim(`${behind.length === 1 ? "1 box runs" : `${behind.length} boxes run`} an older image (\u2192 in BASE): kvbox vm update <box> moves it onto the newer one, its files stay${asleep ? " (a hibernated box first: kvbox wake <box>)" : ""}`));
3940
4131
  } finally {
3941
4132
  await client.close();
3942
4133
  }
@@ -3952,8 +4143,9 @@ function lsRows(boxes, cloud) {
3952
4143
  address: addressOf(b),
3953
4144
  size: b.status === "unknown" ? "-" : `${shape(b.vcpu, b.memMib, b.diskBytes)} ${color.dim(`(${gbShort(b.diskUsedBytes)} used)`)}`,
3954
4145
  created: age(b.createdAt),
3955
- // An image other than the base one (#87) is named: `postgres v0.1.0`.
3956
- base: b.status === "unknown" || b.base === "" ? "-" : b.image !== void 0 ? `${b.image} ${b.base}` : b.base
4146
+ // An image other than the base one (#87) is named: `postgres v0.1.0`; a newer one on the host follows in yellow: `v0.12.0 → v0.16.0`
4147
+ // (not on a managed service's box, which `vm update` cannot reach).
4148
+ base: b.status === "unknown" || b.base === "" ? "-" : `${b.image !== void 0 ? `${b.image} ${b.base}` : b.base}${b.latestBase === void 0 || b.managed !== void 0 ? "" : color.yellow(` \u2192 ${b.latestBase}`)}`
3957
4149
  }));
3958
4150
  }
3959
4151
 
@@ -4036,8 +4228,10 @@ function getRows(box2, subs, user) {
4036
4228
  const quiet = box2.idleCheck === void 0 ? "without network traffic" : `idle by ${box2.idleCheck}`;
4037
4229
  rows2.push(["auto-hibernate", box2.autoHibernateSec ? `after ${duration(box2.autoHibernateSec)} ${quiet}` : "off"]);
4038
4230
  if (!box2.autoHibernateSec && box2.idleCheck !== void 0) rows2.push(["idle check", `${box2.idleCheck} ${color.dim("(used once auto-hibernate is on)")}`]);
4231
+ rows2.push(["integrations", box2.integrations?.length ? box2.integrations.join(", ") : "-"]);
4039
4232
  rows2.push(["source", box2.source]);
4040
- rows2.push(["base", box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`]);
4233
+ const update = box2.latestBase === void 0 ? "" : ` ${color.yellow(`(${box2.latestBase} available: ${box2.status === "hibernated" ? `kvbox wake ${displayName(box2, user)}, then ` : ""}kvbox vm update ${displayName(box2, user)})`)}`;
4234
+ rows2.push(["base", `${box2.image === void 0 ? box2.base : `${box2.image} ${box2.base}`}${update}`]);
4041
4235
  rows2.push(["created", `${age(box2.createdAt)} ${color.dim(`(${box2.createdAt})`)}`]);
4042
4236
  return rows2;
4043
4237
  }
@@ -4871,14 +5065,16 @@ function runSwap(ep, mib) {
4871
5065
  }
4872
5066
 
4873
5067
  // 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");
5068
+ 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,claude (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) => {
5069
+ if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
5070
+ throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
4877
5071
  }
5072
+ const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
4878
5073
  const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
4879
5074
  const idleCheck = opts.idleCheck === void 0 ? void 0 : parseIdleCheck(opts.idleCheck);
4880
5075
  const swapMib = opts.swap === void 0 ? void 0 : parseSwap(opts.swap);
4881
- const hostSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5076
+ const idleSettings = autoHibernateSec !== void 0 || idleCheck !== void 0;
5077
+ const hostSettings = idleSettings || integrations !== void 0;
4882
5078
  const client = await clientFor(cmd.optsWithGlobals());
4883
5079
  try {
4884
5080
  const found = pickRef(await boxesFor(client, name), name, me(client));
@@ -4886,7 +5082,10 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4886
5082
  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
5083
  let box2 = found;
4888
5084
  if (hostSettings) {
4889
- box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {} }));
5085
+ box2 = await spin(`updating ${name}\u2026`, client.setMachine(displayName(found, me(client)), { ...autoHibernateSec !== void 0 ? { autoHibernateSec } : {}, ...idleCheck !== void 0 ? { idleCheck } : {}, ...integrations !== void 0 ? { integrations } : {} }));
5086
+ if (!integrationsKept(integrations, box2)) {
5087
+ 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)" : ""}`);
5088
+ }
4890
5089
  if (!idleCheckKept(idleCheck, box2)) {
4891
5090
  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
5091
  }
@@ -4896,7 +5095,11 @@ var setCommand = new Command32("set").description("change a box's settings, e.g.
4896
5095
  json(swap === void 0 ? box2 : { ...box2, swap });
4897
5096
  return;
4898
5097
  }
4899
- if (hostSettings) info(`${color.green("\u2713")} box ${color.bold(name)}: ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
5098
+ if (idleSettings) info(`${color.green("\u2713")} box ${color.bold(name)}: ${autoHibernateText(box2.autoHibernateSec, box2.idleCheck)}`);
5099
+ if (integrations !== void 0) {
5100
+ info(`${color.green("\u2713")} box ${color.bold(name)}: integrations ${integrationsText(box2.integrations)}${integrations.length > 0 && box2.status !== "running" ? color.dim(` (used once it runs)`) : ""}`);
5101
+ await noteNotConnected(client, box2, integrations);
5102
+ }
4900
5103
  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
5104
  if (swap) info(`${color.green("\u2713")} box ${color.bold(name)}: ${swapText(swap)}`);
4902
5105
  } finally {
@@ -5403,12 +5606,48 @@ var rmCommand5 = new Command45("rm").alias("remove").description("remove an API
5403
5606
  // src/commands/key/index.ts
5404
5607
  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
5608
 
5609
+ // src/commands/integration/index.ts
5610
+ import { Command as Command48 } from "commander";
5611
+
5612
+ // src/commands/integration/ls.ts
5613
+ import { Command as Command47 } from "commander";
5614
+ var lsCommand6 = new Command47("ls").alias("list").description("list the accounts connected for your boxes (GitHub, Claude Code), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
5615
+ const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5616
+ try {
5617
+ if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
5618
+ const rows2 = await client.listIntegrations();
5619
+ if (opts.json) {
5620
+ json(rows2);
5621
+ return;
5622
+ }
5623
+ const catalog = await catalogOf(client);
5624
+ const open = (r) => r.connected || connectable(catalog, r.integration, r.owner === me(client));
5625
+ table(
5626
+ rows2.map((r) => ({
5627
+ slug: r.owner,
5628
+ integration: r.integration,
5629
+ 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"),
5630
+ account: r.account ?? "-",
5631
+ connected: r.connectedAt === null ? "-" : age(r.connectedAt),
5632
+ "last used": r.connected ? r.lastUsedAt === null ? "never" : age(r.lastUsedAt) : "-"
5633
+ }))
5634
+ );
5635
+ if (rows2.some((r) => open(r) && (!r.connected || r.status === "needs-reconnect"))) info(color.dim(`connect an account ${whereToConnect(catalog)}`));
5636
+ if (rows2.some((r) => r.connected)) info(color.dim(`turn one on for a box with: kvbox vm set <box> --integration ${rows2.find((r) => r.connected).integration}`));
5637
+ } finally {
5638
+ await client.close();
5639
+ }
5640
+ });
5641
+
5642
+ // src/commands/integration/index.ts
5643
+ var integrationCommand = new Command48("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
5644
+
5406
5645
  // src/commands/snapshots/index.ts
5407
- import { Command as Command50 } from "commander";
5646
+ import { Command as Command52 } from "commander";
5408
5647
 
5409
5648
  // 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) => {
5649
+ import { Command as Command49 } from "commander";
5650
+ 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
5651
  const client = await clientFor(cmd.optsWithGlobals());
5413
5652
  try {
5414
5653
  const cloud = client.target.kind === "cloud";
@@ -5439,8 +5678,8 @@ var lsCommand6 = new Command47("ls").description("list snapshots (yours and your
5439
5678
  });
5440
5679
 
5441
5680
  // 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) => {
5681
+ import { Command as Command50 } from "commander";
5682
+ 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
5683
  const client = await clientFor(cmd.optsWithGlobals());
5445
5684
  try {
5446
5685
  const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
@@ -5453,8 +5692,8 @@ var newCommand2 = new Command48("new").description("freeze a running box (memory
5453
5692
  });
5454
5693
 
5455
5694
  // 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) => {
5695
+ import { Command as Command51 } from "commander";
5696
+ 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
5697
  if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
5459
5698
  info("cancelled");
5460
5699
  process.exitCode = 1;
@@ -5470,14 +5709,14 @@ var rmCommand6 = new Command49("rm").description("delete a snapshot (boxes made
5470
5709
  });
5471
5710
 
5472
5711
  // 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);
5712
+ var snapshotsCommand = new Command52("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
5474
5713
  for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
5475
5714
 
5476
5715
  // src/commands/org/index.ts
5477
- import { Command as Command56 } from "commander";
5716
+ import { Command as Command58 } from "commander";
5478
5717
 
5479
5718
  // src/commands/org/ls.ts
5480
- import { Command as Command51 } from "commander";
5719
+ import { Command as Command53 } from "commander";
5481
5720
 
5482
5721
  // src/commands/org/context.ts
5483
5722
  var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
@@ -5497,7 +5736,7 @@ function orgFor(opts, target) {
5497
5736
  }
5498
5737
 
5499
5738
  // 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) => {
5739
+ 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
5740
  const client = await cloudClientFor(cmd.optsWithGlobals());
5502
5741
  try {
5503
5742
  const orgs = await client.listOrgs();
@@ -5519,8 +5758,8 @@ function orgRows(orgs) {
5519
5758
  }
5520
5759
 
5521
5760
  // 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) => {
5761
+ import { Command as Command54, Option as Option4 } from "commander";
5762
+ 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
5763
  const client = await cloudClientFor(cmd.optsWithGlobals());
5525
5764
  try {
5526
5765
  const org = await client.getOrg(orgFor(opts, client.target));
@@ -5534,7 +5773,7 @@ var lsCommand8 = new Command52("ls").description("list an org's members and thei
5534
5773
  await client.close();
5535
5774
  }
5536
5775
  });
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) => {
5776
+ 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
5777
  const client = await cloudClientFor(cmd.optsWithGlobals());
5539
5778
  try {
5540
5779
  const slug = orgFor(opts, client.target);
@@ -5544,7 +5783,7 @@ var addCommand2 = new Command52("add").description("add a user to an org (admins
5544
5783
  await client.close();
5545
5784
  }
5546
5785
  });
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) => {
5786
+ 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
5787
  const client = await cloudClientFor(cmd.optsWithGlobals());
5549
5788
  try {
5550
5789
  const slug = orgFor(opts, client.target);
@@ -5560,11 +5799,11 @@ var rmCommand7 = new Command52("rm").description("remove a member (or leave: rem
5560
5799
  await client.close();
5561
5800
  }
5562
5801
  });
5563
- var membersCommand = new Command52("members").description("who is in an org and what they may do").addCommand(lsCommand8).addCommand(addCommand2).addCommand(rmCommand7);
5802
+ var membersCommand = new Command54("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
5564
5803
 
5565
5804
  // 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) => {
5805
+ import { Command as Command55 } from "commander";
5806
+ 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
5807
  const client = await cloudClientFor(cmd.optsWithGlobals());
5569
5808
  try {
5570
5809
  const org = await client.createOrg({ slug, name: opts.name ?? slug });
@@ -5580,8 +5819,8 @@ var newCommand3 = new Command53("new").description("create an org; you become it
5580
5819
  });
5581
5820
 
5582
5821
  // 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) => {
5822
+ import { Command as Command56 } from "commander";
5823
+ 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
5824
  if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
5586
5825
  info("cancelled");
5587
5826
  process.exitCode = 1;
@@ -5597,8 +5836,8 @@ var rmCommand8 = new Command54("rm").description("delete an org (owners only; re
5597
5836
  });
5598
5837
 
5599
5838
  // 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) => {
5839
+ import { Argument, Command as Command57 } from "commander";
5840
+ 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
5841
  const client = await cloudClientFor(cmd.optsWithGlobals());
5603
5842
  try {
5604
5843
  const slug = orgFor(opts, client.target);
@@ -5610,11 +5849,11 @@ var roleCommand = new Command55("role").description("change a member's role (own
5610
5849
  });
5611
5850
 
5612
5851
  // 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);
5852
+ 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
5853
 
5615
5854
  // 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) => {
5855
+ import { Command as Command59 } from "commander";
5856
+ 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
5857
  for (const [name, value] of [
5619
5858
  ["since", opts.since],
5620
5859
  ["until", opts.until]
@@ -5811,8 +6050,8 @@ function userRows(r) {
5811
6050
  }
5812
6051
 
5813
6052
  // 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) => {
6053
+ import { Command as Command60 } from "commander";
6054
+ 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
6055
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5817
6056
  try {
5818
6057
  if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
@@ -5841,8 +6080,8 @@ function creditRow(b, me2) {
5841
6080
  }
5842
6081
 
5843
6082
  // 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) => {
6083
+ import { Command as Command61 } from "commander";
6084
+ 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
6085
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
5847
6086
  try {
5848
6087
  if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
@@ -5862,12 +6101,12 @@ var redeemCommand = new Command59("redeem").description("redeem a promo code for
5862
6101
  // src/commands/deploy/index.ts
5863
6102
  import { access as access5, readFile as readFile7 } from "fs/promises";
5864
6103
  import { basename as basename2, resolve as resolve3 } from "path";
5865
- import { Command as Command60, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
6104
+ import { Command as Command62, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
5866
6105
 
5867
6106
  // src/commands/deploy/config.ts
5868
6107
  import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
5869
6108
  import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
5870
- import { z as z12 } from "zod";
6109
+ import { z as z14 } from "zod";
5871
6110
 
5872
6111
  // src/commands/deploy/templates/docker.ts
5873
6112
  import { readFile as readFile4 } from "fs/promises";
@@ -6291,21 +6530,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
6291
6530
  var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
6292
6531
  var CONFIG_FILE = "kvbox.json";
6293
6532
  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"),
6533
+ var DeployConfigSchema = z14.object({
6534
+ template: z14.enum(TEMPLATE_IDS),
6535
+ name: z14.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
6297
6536
  /** 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(),
6537
+ org: z14.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
6299
6538
  /** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
6300
- subdomain: z12.string().check((ctx) => {
6539
+ subdomain: z14.string().check((ctx) => {
6301
6540
  const problem = subdomainProblem(ctx.value);
6302
6541
  if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
6303
6542
  }).optional(),
6304
- size: z12.enum(SIZE_NAMES).optional(),
6543
+ size: z14.enum(SIZE_NAMES).optional(),
6305
6544
  /** The build output directory, relative to the app; the template's default when absent. */
6306
- dist: z12.string().optional(),
6545
+ dist: z14.string().optional(),
6307
6546
  /** 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()
6547
+ port: z14.number().int().min(1).max(65535).optional()
6309
6548
  });
6310
6549
  var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
6311
6550
  var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
@@ -6317,38 +6556,38 @@ var POSTGRES_PORT = 5432;
6317
6556
  var POSTGRES_IMAGE = "postgres:17";
6318
6557
  var POSTGRES_ENV = "DATABASE_URL";
6319
6558
  var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
6320
- var ServiceSchema = z12.strictObject({
6321
- template: z12.enum([...TEMPLATE_IDS, POSTGRES]),
6559
+ var ServiceSchema = z14.strictObject({
6560
+ template: z14.enum([...TEMPLATE_IDS, POSTGRES]),
6322
6561
  /** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
6323
- dir: z12.string().min(1).optional(),
6562
+ dir: z14.string().min(1).optional(),
6324
6563
  /** 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(),
6564
+ image: z14.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
6326
6565
  /** The volume (a key of `volumes`) a postgres service keeps its data on. */
6327
- volume: z12.string().optional(),
6566
+ volume: z14.string().optional(),
6328
6567
  /** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
6329
- env: z12.string().optional(),
6568
+ env: z14.string().optional(),
6330
6569
  /** 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(),
6570
+ context: z14.string().min(1).optional(),
6571
+ dist: z14.string().optional(),
6333
6572
  /**
6334
6573
  * A command run once per deploy in the service's new version (a docker service: in a container of
6335
6574
  * the new image; node, nextjs: in the new source, installed and built), with the box's variables,
6336
6575
  * before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
6337
6576
  */
6338
- release: z12.string().optional(),
6577
+ release: z14.string().optional(),
6339
6578
  /** 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(),
6579
+ port: z14.number().int().min(1).max(65535).optional(),
6341
6580
  /** 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()
6581
+ paths: z14.array(z14.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
6343
6582
  });
6344
- var StackConfigSchema = z12.strictObject({
6583
+ var StackConfigSchema = z14.strictObject({
6345
6584
  name: DeployConfigSchema.shape.name.optional(),
6346
6585
  org: DeployConfigSchema.shape.org,
6347
6586
  subdomain: DeployConfigSchema.shape.subdomain,
6348
6587
  size: DeployConfigSchema.shape.size,
6349
6588
  /** 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)
6589
+ volumes: z14.record(z14.string(), z14.string()).optional(),
6590
+ services: z14.record(z14.string(), ServiceSchema)
6352
6591
  });
6353
6592
  function volumeGib(text2) {
6354
6593
  const mib = parseMib(text2);
@@ -7127,7 +7366,7 @@ async function readPackageJson(dir) {
7127
7366
  }
7128
7367
 
7129
7368
  // 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) => {
7369
+ 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
7370
  const dir = resolve3(dirArg ?? ".");
7132
7371
  const pkg = await readPackageJson2(dir);
7133
7372
  const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
@@ -7284,15 +7523,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
7284
7523
  }
7285
7524
 
7286
7525
  // src/commands/volume/index.ts
7287
- import { Command as Command72 } from "commander";
7526
+ import { Command as Command74 } from "commander";
7288
7527
 
7289
7528
  // src/commands/volume/attach.ts
7290
- import { Command as Command61 } from "commander";
7529
+ import { Command as Command63 } from "commander";
7291
7530
  function describeMount(machine, volume2, box2) {
7292
7531
  const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
7293
7532
  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
7533
  }
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) => {
7534
+ 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
7535
  if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
7297
7536
  const client = await clientFor(cmd.optsWithGlobals());
7298
7537
  try {
@@ -7311,11 +7550,11 @@ var attachCommand = new Command61("attach").description("attach a volume to a bo
7311
7550
  });
7312
7551
 
7313
7552
  // src/commands/volume/backup/index.ts
7314
- import { Command as Command66 } from "commander";
7553
+ import { Command as Command68 } from "commander";
7315
7554
 
7316
7555
  // 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) => {
7556
+ import { Command as Command64 } from "commander";
7557
+ 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
7558
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7320
7559
  try {
7321
7560
  requireCloud3(client);
@@ -7342,8 +7581,8 @@ var createCommand4 = new Command62("create").description("back up a volume's dis
7342
7581
  });
7343
7582
 
7344
7583
  // 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) => {
7584
+ import { Command as Command65 } from "commander";
7585
+ 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
7586
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7348
7587
  try {
7349
7588
  requireCloud3(client);
@@ -7376,8 +7615,8 @@ var lsCommand9 = new Command63("ls").alias("list").description("list volume back
7376
7615
  });
7377
7616
 
7378
7617
  // 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) => {
7618
+ import { Command as Command66 } from "commander";
7619
+ 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
7620
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7382
7621
  try {
7383
7622
  requireCloud3(client);
@@ -7400,8 +7639,8 @@ var restoreCommand2 = new Command64("restore").description("put a backup back: t
7400
7639
  });
7401
7640
 
7402
7641
  // 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) => {
7642
+ import { Command as Command67 } from "commander";
7643
+ 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
7644
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
7406
7645
  try {
7407
7646
  requireCloud3(client);
@@ -7412,11 +7651,11 @@ var rmCommand9 = new Command65("rm").alias("remove").description("remove a backu
7412
7651
  });
7413
7652
 
7414
7653
  // 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);
7654
+ 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
7655
  for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7417
7656
 
7418
7657
  // src/commands/volume/create.ts
7419
- import { Command as Command67 } from "commander";
7658
+ import { Command as Command69 } from "commander";
7420
7659
  function parseGib2(text2, label = "--size") {
7421
7660
  const mib = parseMib(text2);
7422
7661
  if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
@@ -7432,7 +7671,7 @@ function sizeProblem(answer) {
7432
7671
  return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
7433
7672
  }
7434
7673
  }
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) => {
7674
+ 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
7675
  const ask = interactive();
7437
7676
  if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
7438
7677
  const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
@@ -7465,8 +7704,8 @@ var createCommand5 = new Command67("create").alias("new").description("create a
7465
7704
  });
7466
7705
 
7467
7706
  // 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) => {
7707
+ import { Command as Command70 } from "commander";
7708
+ 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
7709
  if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
7471
7710
  const client = await clientFor(cmd.optsWithGlobals());
7472
7711
  try {
@@ -7491,8 +7730,8 @@ var detachCommand = new Command68("detach").description("detach a volume from a
7491
7730
  });
7492
7731
 
7493
7732
  // 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) => {
7733
+ import { Command as Command71 } from "commander";
7734
+ 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
7735
  const sizeGib = parseGib2(size, "size");
7497
7736
  const client = await clientFor(cmd.optsWithGlobals());
7498
7737
  try {
@@ -7505,8 +7744,8 @@ var growCommand = new Command69("grow").alias("resize").description("make a volu
7505
7744
  });
7506
7745
 
7507
7746
  // 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) => {
7747
+ import { Command as Command72 } from "commander";
7748
+ 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
7749
  const client = await clientFor(cmd.optsWithGlobals());
7511
7750
  try {
7512
7751
  const cloud = client.target.kind === "cloud";
@@ -7537,8 +7776,8 @@ var lsCommand10 = new Command70("ls").alias("list").description("list volumes: s
7537
7776
  });
7538
7777
 
7539
7778
  // 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) => {
7779
+ import { Command as Command73 } from "commander";
7780
+ 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
7781
  if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
7543
7782
  info("cancelled");
7544
7783
  process.exitCode = 1;
@@ -7554,18 +7793,18 @@ var rmCommand10 = new Command71("rm").alias("remove").description("delete a volu
7554
7793
  });
7555
7794
 
7556
7795
  // 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);
7796
+ 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
7797
  for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
7559
7798
  volumeCommand.addCommand(backupCommand2);
7560
7799
 
7561
7800
  // src/commands/bucket/index.ts
7562
- import { Command as Command88 } from "commander";
7801
+ import { Command as Command90 } from "commander";
7563
7802
 
7564
7803
  // src/commands/bucket/backup/index.ts
7565
- import { Command as Command77 } from "commander";
7804
+ import { Command as Command79 } from "commander";
7566
7805
 
7567
7806
  // src/commands/bucket/backup/create.ts
7568
- import { Command as Command73 } from "commander";
7807
+ import { Command as Command75 } from "commander";
7569
7808
 
7570
7809
  // src/commands/bucket/shared.ts
7571
7810
  async function bucketClient(cmd) {
@@ -7591,7 +7830,7 @@ function printRows(rows2) {
7591
7830
  }
7592
7831
 
7593
7832
  // 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) => {
7833
+ 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
7834
  const client = await bucketClient(cmd);
7596
7835
  const ls = "kvbox bucket backup ls";
7597
7836
  try {
@@ -7619,8 +7858,8 @@ var createCommand6 = new Command73("create").description("back up your object st
7619
7858
  });
7620
7859
 
7621
7860
  // 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) => {
7861
+ import { Command as Command76 } from "commander";
7862
+ 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
7863
  const client = await bucketClient(cmd);
7625
7864
  try {
7626
7865
  const list = await client.storageBackups();
@@ -7652,8 +7891,8 @@ var lsCommand11 = new Command74("ls").alias("list").description("list the backup
7652
7891
  });
7653
7892
 
7654
7893
  // 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) => {
7894
+ import { Command as Command77 } from "commander";
7895
+ 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
7896
  const client = await bucketClient(cmd);
7658
7897
  try {
7659
7898
  const backup = await client.storageBackup(id);
@@ -7683,8 +7922,8 @@ var restoreCommand3 = new Command75("restore").description("put a backup back: e
7683
7922
  });
7684
7923
 
7685
7924
  // 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) => {
7925
+ import { Command as Command78 } from "commander";
7926
+ 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
7927
  const client = await bucketClient(cmd);
7689
7928
  try {
7690
7929
  const backup = (await client.storageBackups()).find((b) => b.id === id);
@@ -7703,11 +7942,11 @@ var rmCommand11 = new Command76("rm").alias("remove").description("remove a back
7703
7942
  });
7704
7943
 
7705
7944
  // 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);
7945
+ 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
7946
 
7708
7947
  // 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) => {
7948
+ import { Command as Command80 } from "commander";
7949
+ 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
7950
  const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
7712
7951
  const client = await bucketClient(cmd);
7713
7952
  try {
@@ -7727,8 +7966,8 @@ var createCommand7 = new Command78("create").description("make a bucket (the fir
7727
7966
  });
7728
7967
 
7729
7968
  // 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) => {
7969
+ import { Command as Command81 } from "commander";
7970
+ 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
7971
  const sizeGib = parseGib2(size, "size");
7733
7972
  const client = await bucketClient(cmd);
7734
7973
  try {
@@ -7741,8 +7980,8 @@ var growCommand2 = new Command79("grow").description("make your object storage l
7741
7980
  });
7742
7981
 
7743
7982
  // 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) => {
7983
+ import { Command as Command82 } from "commander";
7984
+ 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
7985
  const client = await bucketClient(cmd);
7747
7986
  try {
7748
7987
  const b = await client.getBucket(name);
@@ -7772,11 +8011,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
7772
8011
  });
7773
8012
 
7774
8013
  // src/commands/bucket/key/index.ts
7775
- import { Command as Command84 } from "commander";
8014
+ import { Command as Command86 } from "commander";
7776
8015
 
7777
8016
  // 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) => {
8017
+ import { Command as Command83 } from "commander";
8018
+ 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
8019
  const client = await bucketClient(cmd);
7781
8020
  try {
7782
8021
  const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
@@ -7799,8 +8038,8 @@ var createCommand8 = new Command81("create").description("make an access key for
7799
8038
  });
7800
8039
 
7801
8040
  // 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) => {
8041
+ import { Command as Command84 } from "commander";
8042
+ 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
8043
  const client = await bucketClient(cmd);
7805
8044
  try {
7806
8045
  const keys = await client.listBucketKeys(bucket);
@@ -7819,8 +8058,8 @@ var lsCommand12 = new Command82("ls").alias("list").description("list a bucket's
7819
8058
  });
7820
8059
 
7821
8060
  // 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) => {
8061
+ import { Command as Command85 } from "commander";
8062
+ 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
8063
  const client = await bucketClient(cmd);
7825
8064
  try {
7826
8065
  if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
@@ -7836,11 +8075,11 @@ var rmCommand12 = new Command83("rm").alias("remove").description("delete an acc
7836
8075
  });
7837
8076
 
7838
8077
  // 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);
8078
+ 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
8079
 
7841
8080
  // 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) => {
8081
+ import { Command as Command87 } from "commander";
8082
+ 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
8083
  const client = await bucketClient(cmd);
7845
8084
  try {
7846
8085
  const buckets = await client.listBuckets({ all: opts.all });
@@ -7871,8 +8110,8 @@ var lsCommand13 = new Command85("ls").alias("list").description("list buckets, a
7871
8110
  });
7872
8111
 
7873
8112
  // 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) => {
8113
+ import { Command as Command88 } from "commander";
8114
+ 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
8115
  if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
7877
8116
  const on = state === "on";
7878
8117
  if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
@@ -7900,8 +8139,8 @@ var publicCommand = new Command86("public").description("let anyone read a bucke
7900
8139
  });
7901
8140
 
7902
8141
  // 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) => {
8142
+ import { Command as Command89 } from "commander";
8143
+ 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
8144
  const client = await bucketClient(cmd);
7906
8145
  try {
7907
8146
  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 +8159,7 @@ var rmCommand13 = new Command87("rm").alias("remove").description("delete an emp
7920
8159
  });
7921
8160
 
7922
8161
  // 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);
8162
+ 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
8163
  var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
7925
8164
  for (const cmd of bucketCommand.commands) {
7926
8165
  if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg);
@@ -7928,10 +8167,10 @@ for (const cmd of bucketCommand.commands) {
7928
8167
  }
7929
8168
 
7930
8169
  // src/commands/cron/index.ts
7931
- import { Command as Command101 } from "commander";
8170
+ import { Command as Command103 } from "commander";
7932
8171
 
7933
8172
  // src/commands/cron/create.ts
7934
- import { Command as Command89 } from "commander";
8173
+ import { Command as Command91 } from "commander";
7935
8174
 
7936
8175
  // src/commands/cron/shared.ts
7937
8176
  async function cronClient(cmd) {
@@ -7992,7 +8231,7 @@ function printRows2(rows2) {
7992
8231
  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
8232
 
7994
8233
  // 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) => {
8234
+ 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
8235
  const client = await cronClient(cmd);
7997
8236
  try {
7998
8237
  const service = await client.createCronService(name);
@@ -8009,8 +8248,8 @@ var createCommand9 = new Command89("create").description("make a cron service: a
8009
8248
  });
8010
8249
 
8011
8250
  // 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) => {
8251
+ import { Command as Command92 } from "commander";
8252
+ 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
8253
  const client = await cronClient(cmd);
8015
8254
  try {
8016
8255
  const service = await client.getCronService(name);
@@ -8034,8 +8273,8 @@ var infoCommand2 = new Command90("info").alias("get").description("show a cron s
8034
8273
  });
8035
8274
 
8036
8275
  // 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) => {
8276
+ import { Command as Command93 } from "commander";
8277
+ 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
8278
  const client = await cronClient(cmd);
8040
8279
  try {
8041
8280
  const services = await client.listCronServices({ all: opts.all });
@@ -8055,8 +8294,8 @@ var lsCommand14 = new Command91("ls").alias("list").description("list cron servi
8055
8294
  });
8056
8295
 
8057
8296
  // 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) => {
8297
+ import { Command as Command94 } from "commander";
8298
+ 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
8299
  const client = await cronClient(cmd);
8061
8300
  try {
8062
8301
  if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
@@ -8072,10 +8311,10 @@ var rmCommand14 = new Command92("rm").alias("remove").description("delete a cron
8072
8311
  });
8073
8312
 
8074
8313
  // src/commands/cron/trigger/index.ts
8075
- import { Command as Command100 } from "commander";
8314
+ import { Command as Command102 } from "commander";
8076
8315
 
8077
8316
  // src/commands/cron/trigger/add.ts
8078
- import { Command as Command93 } from "commander";
8317
+ import { Command as Command95 } from "commander";
8079
8318
  function portOf(value) {
8080
8319
  const n = Number(value);
8081
8320
  if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
@@ -8095,7 +8334,7 @@ function timeoutOf(value) {
8095
8334
  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
8335
  return sec;
8097
8336
  }
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) => {
8337
+ 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
8338
  let action;
8100
8339
  if (opts.run !== void 0) {
8101
8340
  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 +8361,8 @@ var addCommand3 = new Command93("add").description("add a trigger: on a schedule
8122
8361
  });
8123
8362
 
8124
8363
  // 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) => {
8364
+ import { Command as Command96 } from "commander";
8365
+ 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
8366
  const client = await cronClient(cmd);
8128
8367
  try {
8129
8368
  const triggers = await client.listCronTriggers(service);
@@ -8139,8 +8378,8 @@ var lsCommand15 = new Command94("ls").alias("list").description("list a cron ser
8139
8378
  });
8140
8379
 
8141
8380
  // 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) => {
8381
+ import { Command as Command97 } from "commander";
8382
+ 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
8383
  const client = await cronClient(cmd);
8145
8384
  try {
8146
8385
  const trigger = await client.setCronTriggerEnabled(service, id, false);
@@ -8155,8 +8394,8 @@ var pauseCommand2 = new Command95("pause").description("stop a trigger from firi
8155
8394
  });
8156
8395
 
8157
8396
  // 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) => {
8397
+ import { Command as Command98 } from "commander";
8398
+ 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
8399
  const client = await cronClient(cmd);
8161
8400
  try {
8162
8401
  const trigger = await client.setCronTriggerEnabled(service, id, true);
@@ -8171,8 +8410,8 @@ var resumeCommand2 = new Command96("resume").description("let a paused trigger f
8171
8410
  });
8172
8411
 
8173
8412
  // 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) => {
8413
+ import { Command as Command99 } from "commander";
8414
+ 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
8415
  const client = await cronClient(cmd);
8177
8416
  try {
8178
8417
  if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
@@ -8188,8 +8427,8 @@ var rmCommand15 = new Command97("rm").alias("remove").description("delete a trig
8188
8427
  });
8189
8428
 
8190
8429
  // 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) => {
8430
+ import { Command as Command100 } from "commander";
8431
+ 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
8432
  const client = await cronClient(cmd);
8194
8433
  try {
8195
8434
  const trigger = await client.runCronTrigger(service, id);
@@ -8205,13 +8444,13 @@ var runCommand = new Command98("run").description("fire a trigger now, once, bes
8205
8444
  });
8206
8445
 
8207
8446
  // src/commands/cron/trigger/runs.ts
8208
- import { Command as Command99 } from "commander";
8447
+ import { Command as Command101 } from "commander";
8209
8448
  function limitOf(value) {
8210
8449
  const n = Number(value);
8211
8450
  if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
8212
8451
  return n;
8213
8452
  }
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) => {
8453
+ 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
8454
  const limit = limitOf(opts.limit);
8216
8455
  const client = await cronClient(cmd);
8217
8456
  try {
@@ -8241,10 +8480,10 @@ var runsCommand = new Command99("runs").aliases(["logs"]).description("show how
8241
8480
  });
8242
8481
 
8243
8482
  // 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);
8483
+ 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
8484
 
8246
8485
  // 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);
8486
+ 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
8487
  var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
8249
8488
  for (const cmd of cronCommand.commands) {
8250
8489
  if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
@@ -8252,13 +8491,13 @@ for (const cmd of cronCommand.commands) {
8252
8491
  }
8253
8492
 
8254
8493
  // src/commands/managed/kind.ts
8255
- import { Command as Command120 } from "commander";
8494
+ import { Command as Command122 } from "commander";
8256
8495
 
8257
8496
  // src/commands/managed/backup/index.ts
8258
- import { Command as Command108 } from "commander";
8497
+ import { Command as Command110 } from "commander";
8259
8498
 
8260
8499
  // src/commands/managed/backup/create.ts
8261
- import { Command as Command103 } from "commander";
8500
+ import { Command as Command105 } from "commander";
8262
8501
 
8263
8502
  // src/commands/managed/shared.ts
8264
8503
  import "commander";
@@ -8356,7 +8595,7 @@ function parseStorage(text2, flag) {
8356
8595
  }
8357
8596
 
8358
8597
  // 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) => {
8598
+ 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
8599
  const client = await managedClient(cmd);
8361
8600
  const ls = `kvbox ${spec.command} backup ls ${name}`;
8362
8601
  try {
@@ -8383,8 +8622,8 @@ var createCommand10 = (spec) => new Command103("create").description("back up a
8383
8622
  });
8384
8623
 
8385
8624
  // src/commands/managed/backup/ls.ts
8386
- import { Command as Command104 } from "commander";
8387
- var lsCommand16 = (spec) => {
8625
+ import { Command as Command106 } from "commander";
8626
+ var lsCommand17 = (spec) => {
8388
8627
  const removedOnes = async (err, name, client) => {
8389
8628
  if (!(err instanceof CallError && err.status === 404)) throw err;
8390
8629
  const gone = (await client.listManagedBackups(spec.kind)).filter((b) => b.name === name || `${b.owner}/${b.name}` === name);
@@ -8392,7 +8631,7 @@ var lsCommand16 = (spec) => {
8392
8631
  const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
8393
8632
  return own.length > 0 ? own : gone;
8394
8633
  };
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) => {
8634
+ 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
8635
  const client = await managedClient(cmd);
8397
8636
  try {
8398
8637
  const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
@@ -8435,8 +8674,8 @@ var lsCommand16 = (spec) => {
8435
8674
  };
8436
8675
 
8437
8676
  // 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) => {
8677
+ import { Command as Command107 } from "commander";
8678
+ 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
8679
  const client = await managedClient(cmd);
8441
8680
  try {
8442
8681
  const backup = await client.managedBackup(spec.kind, name, id);
@@ -8458,8 +8697,8 @@ var restoreCommand4 = (spec) => new Command105("restore").description("put a bac
8458
8697
  });
8459
8698
 
8460
8699
  // 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) => {
8700
+ import { Command as Command108 } from "commander";
8701
+ 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
8702
  const client = await managedClient(cmd);
8464
8703
  try {
8465
8704
  await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
@@ -8469,8 +8708,8 @@ var rmCommand16 = (spec) => new Command106("rm").alias("remove").description("re
8469
8708
  });
8470
8709
 
8471
8710
  // 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) => {
8711
+ import { Command as Command109 } from "commander";
8712
+ 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
8713
  if (opts.off && (opts.on || opts.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
8475
8714
  const hour = opts.at === void 0 ? void 0 : parseHour(opts.at);
8476
8715
  const client = await managedClient(cmd);
@@ -8500,18 +8739,18 @@ function parseHour(text2) {
8500
8739
 
8501
8740
  // src/commands/managed/backup/index.ts
8502
8741
  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)"));
8742
+ 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");
8743
+ 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
8744
  return command;
8506
8745
  };
8507
8746
 
8508
8747
  // src/commands/managed/create.ts
8509
- import { Command as Command109 } from "commander";
8748
+ import { Command as Command111 } from "commander";
8510
8749
  import { setTimeout as sleep5 } from "timers/promises";
8511
8750
  var READY_WAIT_MS = 9e4;
8512
8751
  var READY_STEP_MS = 2e3;
8513
8752
  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");
8753
+ 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
8754
  for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
8516
8755
  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
8756
  const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
@@ -8560,8 +8799,8 @@ var createCommand11 = (spec) => {
8560
8799
  };
8561
8800
 
8562
8801
  // 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) => {
8802
+ import { Command as Command112 } from "commander";
8803
+ 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
8804
  const storageGib = parseStorage(size, "size");
8566
8805
  const client = await managedClient(cmd);
8567
8806
  try {
@@ -8574,8 +8813,8 @@ var growCommand3 = (spec) => new Command110("grow").description("give a database
8574
8813
  });
8575
8814
 
8576
8815
  // 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) => {
8816
+ import { Command as Command113 } from "commander";
8817
+ 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
8818
  const client = await managedClient(cmd);
8580
8819
  try {
8581
8820
  const m = await client.getManaged(spec.kind, name);
@@ -8587,8 +8826,8 @@ var infoCommand3 = (spec) => new Command111("info").alias("get").description("sh
8587
8826
  });
8588
8827
 
8589
8828
  // 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) => {
8829
+ import { Command as Command114 } from "commander";
8830
+ 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
8831
  const client = await managedClient(cmd);
8593
8832
  try {
8594
8833
  const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
@@ -8604,7 +8843,7 @@ var linkCommand2 = (spec) => new Command112("link").description("let a box reach
8604
8843
  });
8605
8844
 
8606
8845
  // src/commands/managed/ls.ts
8607
- import { Command as Command113 } from "commander";
8846
+ import { Command as Command115 } from "commander";
8608
8847
  function listRows(items, user, kindColumn) {
8609
8848
  return items.map((m) => ({
8610
8849
  owner: m.owner === user ? "private" : m.owner,
@@ -8618,7 +8857,7 @@ function listRows(items, user, kindColumn) {
8618
8857
  created: age(m.createdAt)
8619
8858
  }));
8620
8859
  }
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) => {
8860
+ 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
8861
  const client = await managedClient(cmd);
8623
8862
  try {
8624
8863
  const items = await client.listManaged(spec?.kind, { all: opts.all });
@@ -8638,8 +8877,8 @@ var lsCommand17 = (spec) => new Command113("ls").alias("list").description(spec
8638
8877
  });
8639
8878
 
8640
8879
  // 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) => {
8880
+ import { Command as Command116 } from "commander";
8881
+ 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
8882
  const client = await managedClient(cmd);
8644
8883
  try {
8645
8884
  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 +8894,8 @@ var passwordCommand = (spec) => new Command114("password").description("show a d
8655
8894
  });
8656
8895
 
8657
8896
  // 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) => {
8897
+ import { Command as Command117 } from "commander";
8898
+ 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
8899
  if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
8661
8900
  const client = await managedClient(cmd);
8662
8901
  try {
@@ -8677,8 +8916,8 @@ var publicCommand2 = (spec) => new Command115("public").description("open a data
8677
8916
  });
8678
8917
 
8679
8918
  // 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) => {
8919
+ import { Command as Command118 } from "commander";
8920
+ 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
8921
  const client = await managedClient(cmd);
8683
8922
  try {
8684
8923
  if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
@@ -8694,8 +8933,8 @@ var rmCommand17 = (spec) => new Command116("rm").alias("remove").description("de
8694
8933
  });
8695
8934
 
8696
8935
  // 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) => {
8936
+ import { Command as Command119 } from "commander";
8937
+ 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
8938
  const client = await managedClient(cmd);
8700
8939
  try {
8701
8940
  const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
@@ -8707,8 +8946,8 @@ var startCommand2 = (spec) => new Command117("start").description("run a stopped
8707
8946
  });
8708
8947
 
8709
8948
  // 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) => {
8949
+ import { Command as Command120 } from "commander";
8950
+ 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
8951
  const client = await managedClient(cmd);
8713
8952
  try {
8714
8953
  const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
@@ -8720,8 +8959,8 @@ var stopCommand2 = (spec) => new Command118("stop").description("shut a database
8720
8959
  });
8721
8960
 
8722
8961
  // 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) => {
8962
+ import { Command as Command121 } from "commander";
8963
+ 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
8964
  const client = await managedClient(cmd);
8726
8965
  try {
8727
8966
  const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
@@ -8734,8 +8973,8 @@ var unlinkCommand2 = (spec) => new Command119("unlink").description("stop a box
8734
8973
 
8735
8974
  // src/commands/managed/kind.ts
8736
8975
  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]) {
8976
+ const command = new Command122(spec.command).aliases(spec.aliases).description(description);
8977
+ for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
8739
8978
  command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
8740
8979
  }
8741
8980
  command.addCommand(backupCommand4(spec));
@@ -8749,14 +8988,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
8749
8988
  var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
8750
8989
 
8751
8990
  // 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)"));
8991
+ import { Command as Command123 } from "commander";
8992
+ 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
8993
 
8755
8994
  // src/commands/env/index.ts
8756
- import { Command as Command125 } from "commander";
8995
+ import { Command as Command127 } from "commander";
8757
8996
 
8758
8997
  // src/commands/env/ls.ts
8759
- import { Command as Command122 } from "commander";
8998
+ import { Command as Command124 } from "commander";
8760
8999
 
8761
9000
  // src/commands/env/shared.ts
8762
9001
  function requireCloud4(client) {
@@ -8783,7 +9022,7 @@ function firstBootHint(box2, name) {
8783
9022
  }
8784
9023
 
8785
9024
  // 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) => {
9025
+ 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
9026
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8788
9027
  try {
8789
9028
  if (opts.box !== void 0) {
@@ -8822,8 +9061,8 @@ var lsCommand18 = new Command122("ls").alias("list").description("list the varia
8822
9061
  });
8823
9062
 
8824
9063
  // 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) => {
9064
+ import { Command as Command125 } from "commander";
9065
+ 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
9066
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8828
9067
  try {
8829
9068
  const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
@@ -8860,8 +9099,8 @@ var rmCommand18 = new Command123("rm").alias("remove").description("remove varia
8860
9099
  });
8861
9100
 
8862
9101
  // 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) => {
9102
+ import { Command as Command126 } from "commander";
9103
+ 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
9104
  const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
8866
9105
  try {
8867
9106
  const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
@@ -8898,14 +9137,14 @@ var setCommand2 = new Command124("set").description("add or change a variable; b
8898
9137
  });
8899
9138
 
8900
9139
  // 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);
9140
+ 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
9141
  for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
8903
9142
 
8904
9143
  // src/commands/domain/index.ts
8905
- import { Command as Command129 } from "commander";
9144
+ import { Command as Command131 } from "commander";
8906
9145
 
8907
9146
  // src/commands/domain/add.ts
8908
- import { Command as Command126 } from "commander";
9147
+ import { Command as Command128 } from "commander";
8909
9148
 
8910
9149
  // src/commands/domain/shared.ts
8911
9150
  function requireCloud5(client) {
@@ -8925,7 +9164,7 @@ function hostIn(name, zone) {
8925
9164
  }
8926
9165
 
8927
9166
  // 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) => {
9167
+ 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
9168
  const domain = assertDomain(domainArg.trim().toLowerCase());
8930
9169
  const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
8931
9170
  const client = await clientFor(cmd.optsWithGlobals());
@@ -8961,8 +9200,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
8961
9200
  });
8962
9201
 
8963
9202
  // 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) => {
9203
+ import { Command as Command129 } from "commander";
9204
+ 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
9205
  const client = await clientFor(cmd.optsWithGlobals());
8967
9206
  try {
8968
9207
  requireCloud5(client);
@@ -8991,8 +9230,8 @@ var lsCommand19 = new Command127("ls").alias("list").description("list your cust
8991
9230
  });
8992
9231
 
8993
9232
  // 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) => {
9233
+ import { Command as Command130 } from "commander";
9234
+ 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
9235
  const domain = domainArg.trim().toLowerCase();
8997
9236
  const client = await clientFor(cmd.optsWithGlobals());
8998
9237
  try {
@@ -9013,7 +9252,7 @@ var rmCommand19 = new Command128("rm").alias("remove").description("stop serving
9013
9252
  });
9014
9253
 
9015
9254
  // 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);
9255
+ var domainCommand = new Command131("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
9017
9256
  for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
9018
9257
 
9019
9258
  // src/commands/update.ts
@@ -9021,7 +9260,7 @@ import { spawn as spawn8 } from "child_process";
9021
9260
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
9022
9261
  import { tmpdir } from "os";
9023
9262
  import { join as join9 } from "path";
9024
- import { Command as Command130 } from "commander";
9263
+ import { Command as Command132 } from "commander";
9025
9264
 
9026
9265
  // src/update.ts
9027
9266
  import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
@@ -9140,7 +9379,7 @@ function run2(cmd, args) {
9140
9379
  child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
9141
9380
  });
9142
9381
  }
9143
- var selfUpdateCommand = new Command130("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9382
+ var selfUpdateCommand = new Command132("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
9144
9383
  suppressUpdateNotice();
9145
9384
  const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
9146
9385
  let code;
@@ -9211,6 +9450,7 @@ var HELP_GROUPS = [
9211
9450
  ["managed", "every managed database, whatever its kind"],
9212
9451
  ["cron", "call a box on a schedule, waking it first if it sleeps"],
9213
9452
  ["env", "environment variables and secrets every box of yours gets"],
9453
+ ["integration", "accounts (GitHub, Claude Code) your boxes use once you turn them on"],
9214
9454
  ["domain", "serve a box at a domain of your own"]
9215
9455
  ]
9216
9456
  },
@@ -9268,7 +9508,7 @@ function installRootHelp(program) {
9268
9508
 
9269
9509
  // src/program.ts
9270
9510
  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();
9511
+ 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
9512
  program.addCommand(vmCommand);
9273
9513
  program.addCommand(snapshotsCommand);
9274
9514
  program.addCommand(volumeCommand);
@@ -9283,6 +9523,7 @@ function buildProgram() {
9283
9523
  program.addCommand(logoutCommand);
9284
9524
  program.addCommand(whoamiCommand);
9285
9525
  program.addCommand(keyCommand);
9526
+ program.addCommand(integrationCommand);
9286
9527
  program.addCommand(orgCommand);
9287
9528
  program.addCommand(usageCommand2);
9288
9529
  program.addCommand(creditCommand);