@krovacloud/sdk 0.5.1 → 0.5.2

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/CHANGELOG.md CHANGED
@@ -9,6 +9,10 @@ All notable changes to `@krovacloud/sdk` are documented here. This project adher
9
9
 
10
10
  ### Added
11
11
 
12
+ - `cubes.setIdleTimeout(spaceId, cubeId, minutes | null)`, `idleTimeoutMinutes?: number | null` on the `cubes.create()` body, and `idleTimeoutMinutes` and `lastActiveAt` on `Cube`: Krova powers a Cube off after that many minutes without activity (10 to 10080, or `null` for off). These need a server with the idle-timeout feature, which krova-cloud has not deployed yet: `setIdleTimeout` gets a `400` from an older server, `create` is silently ignored there, and both `Cube` fields are absent. The OpenAPI snapshot and generated types include them, and `packages/sdk/openapi-pending.json` lists them so the drift check stays green until the deploy.
13
+
14
+ - `cubes.rename(spaceId, cubeId, name)` and `cubes.resize(spaceId, cubeId, { vcpu?, ramGb?, diskGb? }, opts?)`, with the exported types `ResizeCubeInput` and `ResizeCubeResult`. `resize` resolves to `{ success, state: "queued", jobId, isLive, requiresRestart, previous, requested }`; the Cube keeps its size until the worker applies the change. `getSpace()` now returns `apiKey: { name, expiresAt } | null` (`expiresAt` is `null` for a key that never expires; `apiKey` is `null` for an OAuth token and absent on an older server). The OpenAPI snapshot and generated types include these API changes, which krova-cloud has not deployed yet: until it does, `packages/sdk/openapi-pending.json` lists them so the drift check stays green.
15
+
12
16
  - `@krovacloud/sdk/ssh`, a Node-only entry for running commands and moving files on a Cube over its own SSH with a private key you supply: `connectCube(krova, spaceId, cubeId, { privateKey, passphrase?, readyTimeoutMs?, hostKeys? })` returns a shell with `run()`, `files.write/read/upload/download` and `close()`. The host key is checked against the keys from `cubes.ssh()` and a mismatch throws `HostKeyMismatchError`; there is no way to skip the check. Also exports `shellQuote`, `RunTimeoutError` and `SshError`. Adds the `ssh2` dependency; the main entry does not load it.
13
17
 
14
18
  - Backups and sharing them between spaces: `backups.list()`, `backups.get()` and `backups.share()` (with an optional `idempotencyKey`), and a new `backupShares` group with `list()`, `accept()`, `decline()` and `cancel()`. New exported types `Backup`, `BackupShare`, `BackupShareList` and `AcceptedBackupShare`. These endpoints read the Backups permissions (`backup.view`, `backup.manage`), not the Cube ones. The OpenAPI snapshot is refreshed from the live API and the types regenerated.
package/README.md CHANGED
@@ -105,8 +105,12 @@ Throws if `apiKey` is missing. Exposes `client.baseUrl` (the resolved base URL),
105
105
  Resolve the `Space` your API key is scoped to — so you don't have to hardcode a `spaceId`:
106
106
 
107
107
  ```ts
108
- const space = await krova.getSpace(); // { id, name, tier, createdAt }
108
+ const space = await krova.getSpace(); // { id, name, tier, createdAt, apiKey }
109
109
  const cubes = await krova.cubes.list(space.id);
110
+
111
+ // When does this key stop working? null = never. `apiKey` itself is null for an OAuth
112
+ // token, and missing on an older server, so treat missing as unknown.
113
+ const expiresAt = space.apiKey?.expiresAt;
110
114
  ```
111
115
 
112
116
  ### `client.cubes`
@@ -120,12 +124,23 @@ Ergonomic helpers for the Cube lifecycle. Each unwraps the response body and thr
120
124
  | `get` | `(spaceId, cubeId)` | the Cube body |
121
125
  | `update` | `(spaceId, cubeId, body)` | changes the port sshd listens on inside the Cube |
122
126
  | `setTerminationProtection` | `(spaceId, cubeId, enabled)` | the updated `Cube`. While protection is on, `delete` throws `TerminationProtectedError` (a `KrovaError` for the API's `409`) |
127
+ | `rename` | `(spaceId, cubeId, name)` | the updated `Cube`. The name is trimmed, 1 to 64 printable characters, and does not have to be unique |
128
+ | `setIdleTimeout` | `(spaceId, cubeId, minutes \| null)` | the updated `Cube`. Krova powers the Cube off after that many minutes without activity: an integer from 10 to 10080, or `null` for off. Needs a server with the idle-timeout feature (an older one answers `400`) |
129
+ | `resize` | `(spaceId, cubeId, { vcpu?, ramGb?, diskGb? }, opts?)` | enqueues a resize and returns `{ jobId, isLive, requiresRestart, previous, requested }`. `isLive` means no restart; `requiresRestart` is its inverse. Send only what changes; disk can only grow. `opts.idempotencyKey` makes retries safe |
123
130
  | `delete` | `(spaceId, cubeId)` | enqueues deletion |
124
131
  | `powerOff` | `(spaceId, cubeId)` | enqueues a power-off |
125
132
  | `wake` | `(spaceId, cubeId)` | enqueues a start |
126
133
  | `ssh` | `(spaceId, cubeId)` | the Cube's SSH connection info — `host` is its stable SSH hostname (falls back to the server's public IPv4 with no DNS record yet), plus `port`, `user`, `hostKeys` |
127
134
  | `restore` | `(spaceId, cubeId, snapshotId)` | enqueues a restore — replaces the Cube's disk from a snapshot |
128
135
 
136
+ ```ts
137
+ // rename and resize
138
+ await krova.cubes.rename("space_123", "cube_123", "web-1");
139
+ const job = await krova.cubes.resize("space_123", "cube_123", { ramGb: 4, diskGb: 40 });
140
+ if (job.requiresRestart) console.log("the Cube restarts to apply this");
141
+ // The Cube keeps its size until the worker applies the change; read it again to see the new one.
142
+ ```
143
+
129
144
  ```ts
130
145
  // create — sshPublicKey is required; region + userData (cloud-init) are optional.
131
146
  // opts.idempotencyKey (≤255 chars, per-space) makes retries safe.
@@ -139,6 +154,7 @@ const cube = await krova.cubes.create(
139
154
  region: "us", // optional — slug from catalog.regions()
140
155
  userData: "#cloud-config\n", // optional — cloud-init (max 16 KB)
141
156
  terminationProtection: true, // optional — refuse deletes until turned off
157
+ idleTimeoutMinutes: 60, // optional — power off after 60 idle minutes (10-10080; null = off)
142
158
  },
143
159
  { idempotencyKey: "deploy-2026-07-01" },
144
160
  );
@@ -274,7 +274,7 @@ interface paths {
274
274
  };
275
275
  /**
276
276
  * Resolve the space this API key is scoped to
277
- * @description Returns the single space the API key belongs to. Lets a client auto-resolve the space id from the key alone (no spaceId in the URL).
277
+ * @description Returns the single space the API key belongs to. Lets a client auto-resolve the space id from the key alone (no spaceId in the URL). `apiKey` carries the name and expiry of the key that made the request.
278
278
  */
279
279
  get: {
280
280
  parameters: {
@@ -767,6 +767,8 @@ interface paths {
767
767
  requestBody: {
768
768
  content: {
769
769
  "application/json": {
770
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. Optional; an integer from 10 to 10080 (7 days) or null, anything else is rejected with 400. */
771
+ idleTimeoutMinutes?: number | null;
770
772
  image: string;
771
773
  name: string;
772
774
  /** @description Region slug from /v1/regions (optional). */
@@ -1175,8 +1177,8 @@ interface paths {
1175
1177
  options?: never;
1176
1178
  head?: never;
1177
1179
  /**
1178
- * Update a Cube (toggle termination protection)
1179
- * @description Idempotent. Termination protection is the only PATCHable field today: sending the value it already has returns the Cube unchanged and writes no audit row. Omitting it is a 400 rather than a no-op, so a typo in the field name cannot look like success. Rename and resize are not part of the public API.
1180
+ * Update a Cube (rename, termination protection, idle auto-stop)
1181
+ * @description Idempotent. The PATCHable fields are `name`, `terminationProtection` and `idleTimeoutMinutes`; send any of them. Sending a value the Cube already has returns the Cube unchanged and writes no audit row. Sending neither is a 400 rather than a no-op, so a typo in a field name cannot look like success. Renaming and changing the idle auto-stop timeout need the `cube.manage` permission, and changing termination protection needs `cube.termination_protection`; a request with several fields needs each permission. Every supplied field is validated before any is applied. Names are not unique within a space. Renaming is metadata only: the hostname inside a running Cube changes on its next cold restart. To change vCPU, RAM or disk use `POST .../resize`.
1180
1182
  */
1181
1183
  patch: {
1182
1184
  parameters: {
@@ -1191,8 +1193,12 @@ interface paths {
1191
1193
  requestBody: {
1192
1194
  content: {
1193
1195
  "application/json": {
1196
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. Send null to turn it off; anything other than an integer from 10 to 10080 (7 days) or null is rejected with 400. */
1197
+ idleTimeoutMinutes?: number | null;
1198
+ /** @description New display name. 1–64 printable characters after trimming, the same rule as Cube creation. */
1199
+ name?: string;
1194
1200
  /** @description Turn protection on or off. Turning it on stamps `terminationProtectionChangedAt` and `terminationProtectionChangedBy`; turning it off clears both. */
1195
- terminationProtection: boolean;
1201
+ terminationProtection?: boolean;
1196
1202
  };
1197
1203
  };
1198
1204
  };
@@ -1619,6 +1625,108 @@ interface paths {
1619
1625
  patch?: never;
1620
1626
  trace?: never;
1621
1627
  };
1628
+ "/spaces/{spaceId}/cubes/{cubeId}/resize": {
1629
+ parameters: {
1630
+ query?: never;
1631
+ header?: never;
1632
+ path?: never;
1633
+ cookie?: never;
1634
+ };
1635
+ get?: never;
1636
+ put?: never;
1637
+ /**
1638
+ * Resize a Cube (asynchronous)
1639
+ * @description Changes a Cube's vCPU, RAM and/or disk. Send only the dimensions you want to change; the rest keep their current value. It goes through the same checks as the dashboard: the hardware ranges, your plan's per-Cube size limit (including any override on your space) and the free capacity of the host the Cube runs on. Disk can only grow. The Cube must be `running` or `stopped`. The response says whether the resize is `isLive` (RAM or disk growth, and vCPU changes on Cubes that support it, applied with no restart) or `requiresRestart` (a RAM shrink or a vCPU change on a Cube that cannot hotplug: the Cube is restarted to apply it). The change is applied by a background job, so the Cube keeps its current size until `GET` shows the new one. A second request while one is queued for the same Cube is rejected with 409. When the host itself has no room for the requested size the 400 carries `code: "insufficient_host_capacity"` and the `dimension` that ran out.
1640
+ */
1641
+ post: {
1642
+ parameters: {
1643
+ query?: never;
1644
+ header?: {
1645
+ /** @description Optional unique key (max 255 chars). Replays return the original response and add header Idempotency-Replayed: true. Scoped per space; expires after 24h. */
1646
+ "Idempotency-Key"?: string;
1647
+ };
1648
+ path: {
1649
+ spaceId: string;
1650
+ cubeId: string;
1651
+ };
1652
+ cookie?: never;
1653
+ };
1654
+ requestBody: {
1655
+ content: {
1656
+ "application/json": {
1657
+ resources: {
1658
+ /** @description Disk in GB. Grow-only. */
1659
+ diskGb?: number;
1660
+ /** @description RAM in GB (1 = 1 GB), the same unit as Cube creation. */
1661
+ ramGb?: number;
1662
+ vcpu?: number;
1663
+ };
1664
+ };
1665
+ };
1666
+ };
1667
+ responses: {
1668
+ /** @description Resize queued */
1669
+ 200: {
1670
+ headers: {
1671
+ [name: string]: unknown;
1672
+ };
1673
+ content: {
1674
+ "application/json": {
1675
+ /** @description True when the resize is applied with no restart. */
1676
+ isLive: boolean;
1677
+ jobId: string;
1678
+ previous: {
1679
+ diskGb: number;
1680
+ ramGb: number;
1681
+ vcpu: number;
1682
+ };
1683
+ requested: {
1684
+ diskGb: number;
1685
+ ramGb: number;
1686
+ vcpu: number;
1687
+ };
1688
+ /** @description The inverse of `isLive`. */
1689
+ requiresRestart: boolean;
1690
+ /** @enum {string} */
1691
+ state: "queued";
1692
+ success: boolean;
1693
+ };
1694
+ };
1695
+ };
1696
+ /** @description Invalid body, a value out of range or above your plan's limit, a disk shrink, no change, the Cube is not `running` or `stopped`, or the host has no capacity (then `code` is `insufficient_host_capacity` and `dimension` is `cpu`, `ram` or `disk`). */
1697
+ 400: {
1698
+ headers: {
1699
+ [name: string]: unknown;
1700
+ };
1701
+ content: {
1702
+ "application/json": {
1703
+ /** @enum {string} */
1704
+ code?: "insufficient_host_capacity";
1705
+ /** @enum {string} */
1706
+ dimension?: "cpu" | "ram" | "disk";
1707
+ error: string;
1708
+ };
1709
+ };
1710
+ };
1711
+ 401: components["responses"]["Unauthorized"];
1712
+ 403: components["responses"]["Forbidden"];
1713
+ 404: components["responses"]["NotFound"];
1714
+ /** @description A resize is already queued for this Cube, or a transfer is in progress */
1715
+ 409: {
1716
+ headers: {
1717
+ [name: string]: unknown;
1718
+ };
1719
+ content?: never;
1720
+ };
1721
+ 429: components["responses"]["RateLimited"];
1722
+ };
1723
+ };
1724
+ delete?: never;
1725
+ options?: never;
1726
+ head?: never;
1727
+ patch?: never;
1728
+ trace?: never;
1729
+ };
1622
1730
  "/spaces/{spaceId}/cubes/{cubeId}/restart": {
1623
1731
  parameters: {
1624
1732
  query?: never;
@@ -2346,7 +2454,14 @@ interface components {
2346
2454
  /** Format: date-time */
2347
2455
  createdAt: string;
2348
2456
  id: string;
2457
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. */
2458
+ idleTimeoutMinutes?: number | null;
2349
2459
  image: string;
2460
+ /**
2461
+ * Format: date-time
2462
+ * @description ISO8601 timestamp of the last time Krova saw the Cube active (a web terminal or SSH session open, or CPU at or above 5% busy, or a 5-minute load average at or above 0.1). Null until the idle check has recorded one.
2463
+ */
2464
+ lastActiveAt?: string | null;
2350
2465
  name: string;
2351
2466
  publicIpv4: string | null;
2352
2467
  resources: {
@@ -2490,6 +2605,15 @@ interface components {
2490
2605
  status: string;
2491
2606
  };
2492
2607
  Space: {
2608
+ /** @description The API key this request authenticated with, or null when an OAuth access token did. */
2609
+ apiKey?: {
2610
+ /**
2611
+ * Format: date-time
2612
+ * @description When the key stops working. Null for a key that never expires.
2613
+ */
2614
+ expiresAt: string | null;
2615
+ name: string;
2616
+ } | null;
2493
2617
  /** Format: date-time */
2494
2618
  createdAt: string;
2495
2619
  id: string;
@@ -2676,6 +2800,21 @@ type CreateCubeInput = NonNullable<paths["/spaces/{spaceId}/cubes"]["post"]["req
2676
2800
  /** Opt this Cube out of customer-initiated deletion (default `false`). */
2677
2801
  terminationProtection?: boolean;
2678
2802
  };
2803
+ /**
2804
+ * The dimensions to change in a Cube resize, in the units `POST /cubes` takes:
2805
+ * `vcpu` and `diskGb` are integers, `ramGb` may be fractional (`0.5`). Send only
2806
+ * what changes; omitted dimensions keep their current value. Disk can only grow.
2807
+ */
2808
+ type ResizeCubeInput = NonNullable<paths["/spaces/{spaceId}/cubes/{cubeId}/resize"]["post"]["requestBody"]>["content"]["application/json"]["resources"];
2809
+ /**
2810
+ * The 200 response of `POST /spaces/{spaceId}/cubes/{cubeId}/resize`.
2811
+ *
2812
+ * `state` is always `"queued"`: the Cube keeps its size until the worker
2813
+ * applies the change, so read the {@link Cube} again to see the new one.
2814
+ * `isLive` means no restart is needed; `requiresRestart` is its inverse, and the
2815
+ * worker power-cycles the Cube.
2816
+ */
2817
+ type ResizeCubeResult = paths["/spaces/{spaceId}/cubes/{cubeId}/resize"]["post"]["responses"][200]["content"]["application/json"];
2679
2818
  /**
2680
2819
  * A webhook endpoint subscribed to Space events.
2681
2820
  *
@@ -2772,7 +2911,9 @@ declare class KrovaClient {
2772
2911
  costPerHour: number;
2773
2912
  createdAt: string;
2774
2913
  id: string;
2914
+ idleTimeoutMinutes?: number | null;
2775
2915
  image: string;
2916
+ lastActiveAt?: string | null;
2776
2917
  name: string;
2777
2918
  publicIpv4: string | null;
2778
2919
  resources: {
@@ -2822,7 +2963,7 @@ declare class KrovaClient {
2822
2963
  * The Krova Cloud API exposes no general Cube-mutation endpoint; the only
2823
2964
  * mutable Cube field over the API is this port, via
2824
2965
  * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that
2825
- * endpoint. (Compute resize / rename are not part of the public API.)
2966
+ * endpoint. (Rename and resize have their own helpers: `cubes.rename` and `cubes.resize`.)
2826
2967
  */
2827
2968
  update: (spaceId: string, cubeId: string, body: NonNullable<paths["/spaces/{spaceId}/cubes/{cubeId}/ssh-port"]["put"]["requestBody"]>["content"]["application/json"]) => Promise<unknown>;
2828
2969
  /**
@@ -2836,6 +2977,44 @@ declare class KrovaClient {
2836
2977
  * `terminationProtectionChangedAt`, and `terminationProtectionChangedBy`.
2837
2978
  */
2838
2979
  setTerminationProtection: (spaceId: string, cubeId: string, enabled: boolean) => Promise<Cube>;
2980
+ /**
2981
+ * Set a Cube's idle auto-stop timeout. Returns the updated {@link Cube}.
2982
+ *
2983
+ * `PATCH /spaces/{spaceId}/cubes/{cubeId}` with `{ idleTimeoutMinutes }`: an
2984
+ * integer from 10 to 10080 (7 days), or `null` to turn it off. Krova powers
2985
+ * the Cube off after that many minutes without activity. Needs the
2986
+ * `cube.manage` permission. Passing the current value is a no-op. A server
2987
+ * without the idle-timeout feature answers `400`.
2988
+ */
2989
+ setIdleTimeout: (spaceId: string, cubeId: string, minutes: number | null) => Promise<Cube>;
2990
+ /**
2991
+ * Rename a Cube. Returns the updated {@link Cube}.
2992
+ *
2993
+ * `PATCH /spaces/{spaceId}/cubes/{cubeId}` with `{ name }`. The name is
2994
+ * trimmed and must be 1 to 64 printable characters; it does not have to be
2995
+ * unique in the Space. Renaming to the current name is a no-op. Needs the
2996
+ * `cube.manage` permission. The hostname inside a running Cube changes on
2997
+ * its next cold restart.
2998
+ */
2999
+ rename: (spaceId: string, cubeId: string, name: string) => Promise<Cube>;
3000
+ /**
3001
+ * Resize a Cube's vCPU, RAM and/or disk (asynchronous: the resize is
3002
+ * enqueued). Send only the dimensions to change.
3003
+ *
3004
+ * Resolves to a {@link ResizeCubeResult} that says whether the change is
3005
+ * applied live (`isLive`) or power-cycles the Cube (`requiresRestart`), and
3006
+ * echoes the `previous` and `requested` sizes. The Cube keeps its current
3007
+ * size until the worker applies the change. Disk can only grow. Throws a
3008
+ * {@link KrovaError} with status `400` for a value out of range, above the
3009
+ * plan limit, a disk shrink, no change, a Cube that is not `running` or
3010
+ * `stopped`, or a host without room, and `409` while a resize is already
3011
+ * queued or a transfer is in flight. Needs the `cube.manage` permission.
3012
+ *
3013
+ * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).
3014
+ */
3015
+ resize: (spaceId: string, cubeId: string, resources: ResizeCubeInput, opts?: {
3016
+ idempotencyKey?: string;
3017
+ }) => Promise<ResizeCubeResult>;
2839
3018
  /**
2840
3019
  * Delete a Cube (asynchronous — deletion is enqueued).
2841
3020
  *
@@ -3155,4 +3334,4 @@ declare class KrovaClient {
3155
3334
  }>;
3156
3335
  };
3157
3336
  }
3158
- export { components as C, UpdateDomainInput as S, PricingTier as _, BackupShareList as a, Space as b, CreateTcpMappingInput as c, DEFAULT_BASE_URL as d, Domain as f, Pagination as g, KrovaClientOptions as h, BackupShare as i, Cube as l, KrovaClient as m, AuthScheme as n, CreateCubeInput as o, Image as p, Backup as r, CreateDomainInput as s, AcceptedBackupShare as t, CubeSshInfo as u, Region as v, paths as w, TcpMapping as x, Snapshot as y };
3337
+ export { TcpMapping as C, paths as E, Space as S, components as T, PricingTier as _, BackupShareList as a, ResizeCubeResult as b, CreateTcpMappingInput as c, DEFAULT_BASE_URL as d, Domain as f, Pagination as g, KrovaClientOptions as h, BackupShare as i, Cube as l, KrovaClient as m, AuthScheme as n, CreateCubeInput as o, Image as p, Backup as r, CreateDomainInput as s, AcceptedBackupShare as t, CubeSshInfo as u, Region as v, UpdateDomainInput as w, Snapshot as x, ResizeCubeInput as y };
@@ -274,7 +274,7 @@ interface paths {
274
274
  };
275
275
  /**
276
276
  * Resolve the space this API key is scoped to
277
- * @description Returns the single space the API key belongs to. Lets a client auto-resolve the space id from the key alone (no spaceId in the URL).
277
+ * @description Returns the single space the API key belongs to. Lets a client auto-resolve the space id from the key alone (no spaceId in the URL). `apiKey` carries the name and expiry of the key that made the request.
278
278
  */
279
279
  get: {
280
280
  parameters: {
@@ -767,6 +767,8 @@ interface paths {
767
767
  requestBody: {
768
768
  content: {
769
769
  "application/json": {
770
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. Optional; an integer from 10 to 10080 (7 days) or null, anything else is rejected with 400. */
771
+ idleTimeoutMinutes?: number | null;
770
772
  image: string;
771
773
  name: string;
772
774
  /** @description Region slug from /v1/regions (optional). */
@@ -1175,8 +1177,8 @@ interface paths {
1175
1177
  options?: never;
1176
1178
  head?: never;
1177
1179
  /**
1178
- * Update a Cube (toggle termination protection)
1179
- * @description Idempotent. Termination protection is the only PATCHable field today: sending the value it already has returns the Cube unchanged and writes no audit row. Omitting it is a 400 rather than a no-op, so a typo in the field name cannot look like success. Rename and resize are not part of the public API.
1180
+ * Update a Cube (rename, termination protection, idle auto-stop)
1181
+ * @description Idempotent. The PATCHable fields are `name`, `terminationProtection` and `idleTimeoutMinutes`; send any of them. Sending a value the Cube already has returns the Cube unchanged and writes no audit row. Sending neither is a 400 rather than a no-op, so a typo in a field name cannot look like success. Renaming and changing the idle auto-stop timeout need the `cube.manage` permission, and changing termination protection needs `cube.termination_protection`; a request with several fields needs each permission. Every supplied field is validated before any is applied. Names are not unique within a space. Renaming is metadata only: the hostname inside a running Cube changes on its next cold restart. To change vCPU, RAM or disk use `POST .../resize`.
1180
1182
  */
1181
1183
  patch: {
1182
1184
  parameters: {
@@ -1191,8 +1193,12 @@ interface paths {
1191
1193
  requestBody: {
1192
1194
  content: {
1193
1195
  "application/json": {
1196
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. Send null to turn it off; anything other than an integer from 10 to 10080 (7 days) or null is rejected with 400. */
1197
+ idleTimeoutMinutes?: number | null;
1198
+ /** @description New display name. 1–64 printable characters after trimming, the same rule as Cube creation. */
1199
+ name?: string;
1194
1200
  /** @description Turn protection on or off. Turning it on stamps `terminationProtectionChangedAt` and `terminationProtectionChangedBy`; turning it off clears both. */
1195
- terminationProtection: boolean;
1201
+ terminationProtection?: boolean;
1196
1202
  };
1197
1203
  };
1198
1204
  };
@@ -1619,6 +1625,108 @@ interface paths {
1619
1625
  patch?: never;
1620
1626
  trace?: never;
1621
1627
  };
1628
+ "/spaces/{spaceId}/cubes/{cubeId}/resize": {
1629
+ parameters: {
1630
+ query?: never;
1631
+ header?: never;
1632
+ path?: never;
1633
+ cookie?: never;
1634
+ };
1635
+ get?: never;
1636
+ put?: never;
1637
+ /**
1638
+ * Resize a Cube (asynchronous)
1639
+ * @description Changes a Cube's vCPU, RAM and/or disk. Send only the dimensions you want to change; the rest keep their current value. It goes through the same checks as the dashboard: the hardware ranges, your plan's per-Cube size limit (including any override on your space) and the free capacity of the host the Cube runs on. Disk can only grow. The Cube must be `running` or `stopped`. The response says whether the resize is `isLive` (RAM or disk growth, and vCPU changes on Cubes that support it, applied with no restart) or `requiresRestart` (a RAM shrink or a vCPU change on a Cube that cannot hotplug: the Cube is restarted to apply it). The change is applied by a background job, so the Cube keeps its current size until `GET` shows the new one. A second request while one is queued for the same Cube is rejected with 409. When the host itself has no room for the requested size the 400 carries `code: "insufficient_host_capacity"` and the `dimension` that ran out.
1640
+ */
1641
+ post: {
1642
+ parameters: {
1643
+ query?: never;
1644
+ header?: {
1645
+ /** @description Optional unique key (max 255 chars). Replays return the original response and add header Idempotency-Replayed: true. Scoped per space; expires after 24h. */
1646
+ "Idempotency-Key"?: string;
1647
+ };
1648
+ path: {
1649
+ spaceId: string;
1650
+ cubeId: string;
1651
+ };
1652
+ cookie?: never;
1653
+ };
1654
+ requestBody: {
1655
+ content: {
1656
+ "application/json": {
1657
+ resources: {
1658
+ /** @description Disk in GB. Grow-only. */
1659
+ diskGb?: number;
1660
+ /** @description RAM in GB (1 = 1 GB), the same unit as Cube creation. */
1661
+ ramGb?: number;
1662
+ vcpu?: number;
1663
+ };
1664
+ };
1665
+ };
1666
+ };
1667
+ responses: {
1668
+ /** @description Resize queued */
1669
+ 200: {
1670
+ headers: {
1671
+ [name: string]: unknown;
1672
+ };
1673
+ content: {
1674
+ "application/json": {
1675
+ /** @description True when the resize is applied with no restart. */
1676
+ isLive: boolean;
1677
+ jobId: string;
1678
+ previous: {
1679
+ diskGb: number;
1680
+ ramGb: number;
1681
+ vcpu: number;
1682
+ };
1683
+ requested: {
1684
+ diskGb: number;
1685
+ ramGb: number;
1686
+ vcpu: number;
1687
+ };
1688
+ /** @description The inverse of `isLive`. */
1689
+ requiresRestart: boolean;
1690
+ /** @enum {string} */
1691
+ state: "queued";
1692
+ success: boolean;
1693
+ };
1694
+ };
1695
+ };
1696
+ /** @description Invalid body, a value out of range or above your plan's limit, a disk shrink, no change, the Cube is not `running` or `stopped`, or the host has no capacity (then `code` is `insufficient_host_capacity` and `dimension` is `cpu`, `ram` or `disk`). */
1697
+ 400: {
1698
+ headers: {
1699
+ [name: string]: unknown;
1700
+ };
1701
+ content: {
1702
+ "application/json": {
1703
+ /** @enum {string} */
1704
+ code?: "insufficient_host_capacity";
1705
+ /** @enum {string} */
1706
+ dimension?: "cpu" | "ram" | "disk";
1707
+ error: string;
1708
+ };
1709
+ };
1710
+ };
1711
+ 401: components["responses"]["Unauthorized"];
1712
+ 403: components["responses"]["Forbidden"];
1713
+ 404: components["responses"]["NotFound"];
1714
+ /** @description A resize is already queued for this Cube, or a transfer is in progress */
1715
+ 409: {
1716
+ headers: {
1717
+ [name: string]: unknown;
1718
+ };
1719
+ content?: never;
1720
+ };
1721
+ 429: components["responses"]["RateLimited"];
1722
+ };
1723
+ };
1724
+ delete?: never;
1725
+ options?: never;
1726
+ head?: never;
1727
+ patch?: never;
1728
+ trace?: never;
1729
+ };
1622
1730
  "/spaces/{spaceId}/cubes/{cubeId}/restart": {
1623
1731
  parameters: {
1624
1732
  query?: never;
@@ -2346,7 +2454,14 @@ interface components {
2346
2454
  /** Format: date-time */
2347
2455
  createdAt: string;
2348
2456
  id: string;
2457
+ /** @description Minutes without activity after which Krova powers the Cube off. Null (the default) turns this off. A Cube counts as idle when no web terminal or SSH session is open and its CPU stays under 5% busy with a 5-minute load average under 0.1. Termination protection does not stop this power-off. */
2458
+ idleTimeoutMinutes?: number | null;
2349
2459
  image: string;
2460
+ /**
2461
+ * Format: date-time
2462
+ * @description ISO8601 timestamp of the last time Krova saw the Cube active (a web terminal or SSH session open, or CPU at or above 5% busy, or a 5-minute load average at or above 0.1). Null until the idle check has recorded one.
2463
+ */
2464
+ lastActiveAt?: string | null;
2350
2465
  name: string;
2351
2466
  publicIpv4: string | null;
2352
2467
  resources: {
@@ -2490,6 +2605,15 @@ interface components {
2490
2605
  status: string;
2491
2606
  };
2492
2607
  Space: {
2608
+ /** @description The API key this request authenticated with, or null when an OAuth access token did. */
2609
+ apiKey?: {
2610
+ /**
2611
+ * Format: date-time
2612
+ * @description When the key stops working. Null for a key that never expires.
2613
+ */
2614
+ expiresAt: string | null;
2615
+ name: string;
2616
+ } | null;
2493
2617
  /** Format: date-time */
2494
2618
  createdAt: string;
2495
2619
  id: string;
@@ -2676,6 +2800,21 @@ type CreateCubeInput = NonNullable<paths["/spaces/{spaceId}/cubes"]["post"]["req
2676
2800
  /** Opt this Cube out of customer-initiated deletion (default `false`). */
2677
2801
  terminationProtection?: boolean;
2678
2802
  };
2803
+ /**
2804
+ * The dimensions to change in a Cube resize, in the units `POST /cubes` takes:
2805
+ * `vcpu` and `diskGb` are integers, `ramGb` may be fractional (`0.5`). Send only
2806
+ * what changes; omitted dimensions keep their current value. Disk can only grow.
2807
+ */
2808
+ type ResizeCubeInput = NonNullable<paths["/spaces/{spaceId}/cubes/{cubeId}/resize"]["post"]["requestBody"]>["content"]["application/json"]["resources"];
2809
+ /**
2810
+ * The 200 response of `POST /spaces/{spaceId}/cubes/{cubeId}/resize`.
2811
+ *
2812
+ * `state` is always `"queued"`: the Cube keeps its size until the worker
2813
+ * applies the change, so read the {@link Cube} again to see the new one.
2814
+ * `isLive` means no restart is needed; `requiresRestart` is its inverse, and the
2815
+ * worker power-cycles the Cube.
2816
+ */
2817
+ type ResizeCubeResult = paths["/spaces/{spaceId}/cubes/{cubeId}/resize"]["post"]["responses"][200]["content"]["application/json"];
2679
2818
  /**
2680
2819
  * A webhook endpoint subscribed to Space events.
2681
2820
  *
@@ -2772,7 +2911,9 @@ declare class KrovaClient {
2772
2911
  costPerHour: number;
2773
2912
  createdAt: string;
2774
2913
  id: string;
2914
+ idleTimeoutMinutes?: number | null;
2775
2915
  image: string;
2916
+ lastActiveAt?: string | null;
2776
2917
  name: string;
2777
2918
  publicIpv4: string | null;
2778
2919
  resources: {
@@ -2822,7 +2963,7 @@ declare class KrovaClient {
2822
2963
  * The Krova Cloud API exposes no general Cube-mutation endpoint; the only
2823
2964
  * mutable Cube field over the API is this port, via
2824
2965
  * `PUT /spaces/{spaceId}/cubes/{cubeId}/ssh-port`. This helper maps to that
2825
- * endpoint. (Compute resize / rename are not part of the public API.)
2966
+ * endpoint. (Rename and resize have their own helpers: `cubes.rename` and `cubes.resize`.)
2826
2967
  */
2827
2968
  update: (spaceId: string, cubeId: string, body: NonNullable<paths["/spaces/{spaceId}/cubes/{cubeId}/ssh-port"]["put"]["requestBody"]>["content"]["application/json"]) => Promise<unknown>;
2828
2969
  /**
@@ -2836,6 +2977,44 @@ declare class KrovaClient {
2836
2977
  * `terminationProtectionChangedAt`, and `terminationProtectionChangedBy`.
2837
2978
  */
2838
2979
  setTerminationProtection: (spaceId: string, cubeId: string, enabled: boolean) => Promise<Cube>;
2980
+ /**
2981
+ * Set a Cube's idle auto-stop timeout. Returns the updated {@link Cube}.
2982
+ *
2983
+ * `PATCH /spaces/{spaceId}/cubes/{cubeId}` with `{ idleTimeoutMinutes }`: an
2984
+ * integer from 10 to 10080 (7 days), or `null` to turn it off. Krova powers
2985
+ * the Cube off after that many minutes without activity. Needs the
2986
+ * `cube.manage` permission. Passing the current value is a no-op. A server
2987
+ * without the idle-timeout feature answers `400`.
2988
+ */
2989
+ setIdleTimeout: (spaceId: string, cubeId: string, minutes: number | null) => Promise<Cube>;
2990
+ /**
2991
+ * Rename a Cube. Returns the updated {@link Cube}.
2992
+ *
2993
+ * `PATCH /spaces/{spaceId}/cubes/{cubeId}` with `{ name }`. The name is
2994
+ * trimmed and must be 1 to 64 printable characters; it does not have to be
2995
+ * unique in the Space. Renaming to the current name is a no-op. Needs the
2996
+ * `cube.manage` permission. The hostname inside a running Cube changes on
2997
+ * its next cold restart.
2998
+ */
2999
+ rename: (spaceId: string, cubeId: string, name: string) => Promise<Cube>;
3000
+ /**
3001
+ * Resize a Cube's vCPU, RAM and/or disk (asynchronous: the resize is
3002
+ * enqueued). Send only the dimensions to change.
3003
+ *
3004
+ * Resolves to a {@link ResizeCubeResult} that says whether the change is
3005
+ * applied live (`isLive`) or power-cycles the Cube (`requiresRestart`), and
3006
+ * echoes the `previous` and `requested` sizes. The Cube keeps its current
3007
+ * size until the worker applies the change. Disk can only grow. Throws a
3008
+ * {@link KrovaError} with status `400` for a value out of range, above the
3009
+ * plan limit, a disk shrink, no change, a Cube that is not `running` or
3010
+ * `stopped`, or a host without room, and `409` while a resize is already
3011
+ * queued or a transfer is in flight. Needs the `cube.manage` permission.
3012
+ *
3013
+ * @param opts Optional `idempotencyKey` (max 255 chars, scoped per space).
3014
+ */
3015
+ resize: (spaceId: string, cubeId: string, resources: ResizeCubeInput, opts?: {
3016
+ idempotencyKey?: string;
3017
+ }) => Promise<ResizeCubeResult>;
2839
3018
  /**
2840
3019
  * Delete a Cube (asynchronous — deletion is enqueued).
2841
3020
  *
@@ -3155,4 +3334,4 @@ declare class KrovaClient {
3155
3334
  }>;
3156
3335
  };
3157
3336
  }
3158
- export { components as C, UpdateDomainInput as S, PricingTier as _, BackupShareList as a, Space as b, CreateTcpMappingInput as c, DEFAULT_BASE_URL as d, Domain as f, Pagination as g, KrovaClientOptions as h, BackupShare as i, Cube as l, KrovaClient as m, AuthScheme as n, CreateCubeInput as o, Image as p, Backup as r, CreateDomainInput as s, AcceptedBackupShare as t, CubeSshInfo as u, Region as v, paths as w, TcpMapping as x, Snapshot as y };
3337
+ export { TcpMapping as C, paths as E, Space as S, components as T, PricingTier as _, BackupShareList as a, ResizeCubeResult as b, CreateTcpMappingInput as c, DEFAULT_BASE_URL as d, Domain as f, Pagination as g, KrovaClientOptions as h, BackupShare as i, Cube as l, KrovaClient as m, AuthScheme as n, CreateCubeInput as o, Image as p, Backup as r, CreateDomainInput as s, AcceptedBackupShare as t, CubeSshInfo as u, Region as v, UpdateDomainInput as w, Snapshot as x, ResizeCubeInput as y };