@constal/sdk 6.14.0 → 6.15.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constal/sdk",
3
- "version": "6.14.0",
3
+ "version": "6.15.0",
4
4
  "description": "Public TypeScript SDK for authoring Constal agents, integrations, policies, channels, and credential providers",
5
5
  "keywords": [
6
6
  "constal",
package/publish/api.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "package": "@constal/sdk",
3
- "version": "6.14.0",
3
+ "version": "6.15.0",
4
4
  "exports": [
5
5
  "AGENT_UI_DEFAULTS",
6
6
  "Action",
@@ -2010,16 +2010,17 @@ type SandboxSize = keyof typeof SANDBOX_SIZES;
2010
2010
  /**
2011
2011
  * The events of a deployment's sandbox service:
2012
2012
  *
2013
- * - `sandbox.lifecycle` and `sandbox.usage`, written by the sandbox's coordinator in the transaction that changed its view
2014
- * or metered its time or its egress, numbered per sandbox (`seq`) across both types. The coordinator keeps them for the sandbox's
2015
- * lifetime, its history (the door's history operation), and its alarm delivers each to its namespace's sandbox index
2016
- * after the call that wrote it answered, again until the index takes it, so a failed delivery loses none. Delivery is at
2017
- * least once and in no order: the index keeps a sandbox's newest view by `seq`, and counts a usage item once by its `id`;
2013
+ * - `sandbox.lifecycle`, `sandbox.usage` and `sandbox.snapshot`, written by the sandbox's coordinator in the transaction that
2014
+ * changed its view, metered its time or its egress, or changed one of its snapshots, numbered per sandbox (`seq`) across
2015
+ * the three types. The coordinator keeps them for good, its history (the door's history operation), and its alarm delivers
2016
+ * each to its namespace's sandbox index after the call that wrote it answered, again until the index takes it, so a failed
2017
+ * delivery loses none. Delivery is at least once and in no order: the index keeps a sandbox's newest view, and a
2018
+ * snapshot's newest, by `seq`, and counts a usage item once by its `id`;
2018
2019
  * - `sandbox.orphan` and `sandbox.orphan.withdrawn`, written by the watcher of a provider account (one per tenant,
2019
2020
  * namespace and provider account) and delivered so to the same index, which keeps an orphan by its `provider`,
2020
2021
  * `account` and `instance` as the one of their events with the latest `at` says, a withdrawal winning a tie.
2021
2022
  *
2022
- * The index answers the door's list and usage operations (packages/sdk/src/sandbox-door.ts).
2023
+ * The index answers the door's list, usage and listSnapshots operations (packages/sdk/src/sandbox-door.ts).
2023
2024
  */
2024
2025
  /**
2025
2026
  * What a sandbox's coordinator metered, as it settles it with the platform; `id` makes its debit once. Its `usage` carries
@@ -2066,6 +2067,16 @@ interface SandboxUsageEvent extends SandboxCoordinatorEvent {
2066
2067
  type: "sandbox.usage";
2067
2068
  item: SandboxUsageItem;
2068
2069
  }
2070
+ /**
2071
+ * A change to one of the sandbox's snapshots (its take, a state its provider moved it to, its expiry moved by a restore, its
2072
+ * delete asked), the snapshot once changed; `gone` once its provider confirmed its delete, or at once where its provider
2073
+ * deletes none, after which the index lists it no more.
2074
+ */
2075
+ interface SandboxSnapshotEvent extends SandboxCoordinatorEvent {
2076
+ type: "sandbox.snapshot";
2077
+ snapshot: SandboxSnapshot;
2078
+ gone: boolean;
2079
+ }
2069
2080
  /**
2070
2081
  * A provider instance tagged with the tenant and namespace that none of their sandboxes on that provider account holds (its
2071
2082
  * tags name no sandbox, or the sandbox they name answers it is none of its), which the account's watcher found listing it,
@@ -2106,7 +2117,7 @@ interface SandboxOrphanWithdrawnEvent extends Omit<SandboxOrphanEvent, "type" |
2106
2117
  at: number;
2107
2118
  }
2108
2119
  /** A sandbox's own events, as its coordinator keeps them: its history. */
2109
- type SandboxHistoryEvent = SandboxLifecycleEvent | SandboxUsageEvent;
2120
+ type SandboxHistoryEvent = SandboxLifecycleEvent | SandboxUsageEvent | SandboxSnapshotEvent;
2110
2121
  /** The events a namespace's sandbox index takes: its coordinators' and its account watchers'. */
2111
2122
  type SandboxIndexedEvent = SandboxHistoryEvent | SandboxOrphanEvent | SandboxOrphanWithdrawnEvent;
2112
2123
 
@@ -2197,10 +2208,33 @@ type SandboxPortCapabilities = {
2197
2208
  } | {
2198
2209
  via: "door";
2199
2210
  };
2200
- /** The provider's own snapshots: whether one keeps memory (a create from it resumes its processes), and what taking one does to the sandbox. */
2211
+ /**
2212
+ * How the provider ends a snapshot on its own: it keeps it until it is deleted (`kept`); it deletes it once it goes `idleMs`
2213
+ * without a restore, each restore starting that time again (`expires`; `idleMs` null where the provider states it per
2214
+ * snapshot, as its read of each answers when it ends); or it deactivates it once it goes `idleMs` unused, holding it still
2215
+ * but booting it only once its activate renews it (`deactivates`).
2216
+ */
2217
+ type SandboxSnapshotRetention = {
2218
+ kind: "kept";
2219
+ } | {
2220
+ kind: "expires";
2221
+ idleMs: number | null;
2222
+ } | {
2223
+ kind: "deactivates";
2224
+ idleMs: number;
2225
+ };
2226
+ /**
2227
+ * The provider's own snapshots, as its model has them, which the door follows and imposes nothing on: what one keeps beside
2228
+ * the disk (its memory and processes, so a create from it resumes them: `always`, `never`, or as its take asks,
2229
+ * `optional`), what taking one does to the sandbox (`effect`), whether a create from one boots at a size other than its own
2230
+ * (`resize`), whether the provider deletes one (`delete`), and how it ends one on its own (`retention`).
2231
+ */
2201
2232
  interface SandboxSnapshotCapabilities {
2202
- memory: boolean;
2233
+ memory: "always" | "never" | "optional";
2203
2234
  effect: "none" | "pause" | "stop";
2235
+ resize: boolean;
2236
+ delete: boolean;
2237
+ retention: SandboxSnapshotRetention;
2204
2238
  }
2205
2239
  /**
2206
2240
  * What survives the door's stop on this provider, which is the provider's own: memory, processes and disk (its stop is a
@@ -2281,10 +2315,18 @@ interface SandboxPlacement {
2281
2315
  */
2282
2316
  pool: CRN;
2283
2317
  /**
2284
- * What the provider boots there: an image reference it can boot, or a snapshot's `image`; omitted: the pool's, which a
2285
- * pool one of whose providers has no default image refuses (Invalid, `image`).
2318
+ * What the provider boots there: an image reference it can boot; omitted, with no `snapshot`: the pool's, which a pool one
2319
+ * of whose providers has no default image refuses (Invalid, `image`).
2286
2320
  */
2287
2321
  image?: string;
2322
+ /**
2323
+ * A snapshot the door boots there, by its own id (SandboxSnapshot.id), in place of an image: on the pool's provider that
2324
+ * holds it, under its own pool account alone, and only `ready`, or `inactive`, which the door has its provider renew as the
2325
+ * create restores it. Booting it is authorized as a read of it is (`sandbox:snapshot` on the pool it was taken in). One
2326
+ * `pending` is `Conflict`; one `failed` or `expired`, or one on a pool with no such provider or account, is `Invalid`
2327
+ * naming the field.
2328
+ */
2329
+ snapshot?: string;
2288
2330
  }
2289
2331
  /**
2290
2332
  * POST /sandboxes: the sandbox, and the pools it may run on. Its coordinator creates it on its first pool, and walks on to
@@ -2412,12 +2454,49 @@ interface SandboxFile {
2412
2454
  path: string;
2413
2455
  bytes: number | null;
2414
2456
  }
2415
- /** A snapshot the provider took: its id, the image a create boots it from, and whether it kept memory. */
2457
+ /**
2458
+ * A snapshot's state, its provider's as its coordinator last saw it: taken but not yet made by its provider (`pending`),
2459
+ * restorable (`ready`), held by its provider but booted only once renewed (`inactive`), not made (`failed`), or ended by its
2460
+ * provider on its own (`expired`). A delete is no state: it is the snapshot's `deletingAt`, and the snapshot is gone once its
2461
+ * provider confirms.
2462
+ */
2463
+ declare const SANDBOX_SNAPSHOT_STATES: readonly ["pending", "ready", "inactive", "failed", "expired"];
2464
+ type SandboxSnapshotState = typeof SANDBOX_SNAPSHOT_STATES[number];
2465
+ /** POST /sandboxes/{id}/snapshots: its labels, and whether it keeps memory (`snapshots.memory`); omitted, as its provider takes one. */
2466
+ interface SandboxSnapshotRequest {
2467
+ labels?: SandboxLabels;
2468
+ memory?: boolean;
2469
+ }
2470
+ /**
2471
+ * A snapshot the provider took of a sandbox, an object of its own that outlives its sandbox, as its sandbox's coordinator,
2472
+ * its store of record, keeps it: its own id, by which the door reaches it; the sandbox it was taken of and the pool it ran in
2473
+ * then, which a call on it is authorized on; its labels, its take's alone; where it is held (its provider, the pool account,
2474
+ * its Credential CRN or null for the deployment's own, and the provider's own id for it); the image a create boots it from;
2475
+ * whether it kept memory, as taken; the size a create from it boots at, as its provider says (a field it does not say null;
2476
+ * null where it says none) and its size at the provider in bytes, where it says; its state (SandboxSnapshotState), and for
2477
+ * `failed` and `expired` its provider's reason; when its provider ends it on its own, where a clock does
2478
+ * (SandboxSnapshotRetention), which a restore may move; when it was taken; and when its delete was asked, null before.
2479
+ */
2416
2480
  interface SandboxSnapshot {
2417
2481
  id: string;
2482
+ namespace: string;
2483
+ sandbox: string;
2484
+ pool: string;
2485
+ labels: SandboxLabels;
2486
+ provider: {
2487
+ name: string;
2488
+ account: string | null;
2489
+ id: string;
2490
+ };
2418
2491
  image: string;
2419
2492
  memory: boolean;
2493
+ resources: SandboxProviderAllocation | null;
2494
+ bytes: number | null;
2495
+ state: SandboxSnapshotState;
2496
+ message: string | null;
2497
+ expiresAt: number | null;
2420
2498
  createdAt: number;
2499
+ deletingAt: number | null;
2421
2500
  }
2422
2501
 
2423
2502
  /**
@@ -2470,9 +2549,8 @@ interface Sandbox {
2470
2549
  readFile(path: string, opts?: InvokeOpts): Promise<SandboxFileContent>;
2471
2550
  writeFile(path: string, body: SandboxFileBody, opts?: InvokeOpts): Promise<SandboxFile>;
2472
2551
  deleteFile(path: string, opts?: InvokeOpts): Promise<SandboxFile>;
2473
- /** The provider's own snapshot; a later createSandbox names its `image`. */
2474
- snapshot(opts?: InvokeOpts): Promise<SandboxSnapshot>;
2475
- deleteSnapshot(id: string, opts?: InvokeOpts): Promise<SandboxSnapshot>;
2552
+ /** The provider's own snapshot, which outlives the sandbox; a later createSandbox boots it by naming it (`snapshot`). */
2553
+ snapshot(request?: SandboxSnapshotRequest, opts?: InvokeOpts): Promise<SandboxSnapshot>;
2476
2554
  }
2477
2555
  /** A sandbox createSandbox made, or found again on a replay: its handle, and the sandbox as the door answered it. */
2478
2556
  interface CreatedSandbox {
@@ -2489,6 +2567,8 @@ interface SandboxPool {
2489
2567
  createSandbox(request?: SandboxPoolCreateRequest, opts?: InvokeOpts): Promise<CreatedSandbox>;
2490
2568
  /** Address a sandbox of the pool by its id, such as one the Session keeps. No invocation. */
2491
2569
  sandbox(id: string): Sandbox;
2570
+ /** Delete a snapshot taken on the pool, by its own id, whether its sandbox is deleted or not. */
2571
+ deleteSnapshot(id: string, opts?: InvokeOpts): Promise<SandboxSnapshot>;
2492
2572
  }
2493
2573
  /** The code a sandbox operation fails with when its pool's provider cannot provide a sandbox now (see `sandboxProviderUnavailable`). */
2494
2574
  declare const SANDBOX_PROVIDER_UNAVAILABLE = "ProviderUnavailable";