@gjermundgaraba/clankerbox-sdk 0.15.5 → 0.16.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/dist/index.d.mts CHANGED
@@ -1,423 +1,146 @@
1
- import { A as Invalid, C as ClankerboxError, D as HostError, E as ErrorTag, M as Precondition, N as Unavailable, O as HostErrorTag, P as hostErrors, S as Capacity, T as ConflictKind, _ as Setup, b as release, c as ActionRecord, d as Host, f as Limit, g as Runtime, h as Profile, i as Interface, j as NotFound, k as Internal, l as Checkpoint, m as MachineSpec, n as CreateOptions, o as client_d_exports, p as Machine, s as ActionName, u as CreateRequest, v as SshEndpoint, w as Conflict, x as version, y as SshLogin } from "./client-Cn1bj4It.mjs";
2
- import * as Action from "@gjermundgaraba/effect-actions/Action";
3
- import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
4
- import { Duration, Effect, FileSystem, Path, PlatformError, Schema, Scope } from "effect";
5
- //#region src/api.d.ts
6
- /**
7
- * How long a client waits for a read's reply from one host, unless it sets its own. A host
8
- * bounds its own reads of runtime state under it, so a list answers in time.
9
- */
10
- export declare const readTimeout: Duration.Duration;
11
- /**
12
- * The header every client request carries the SDK's `version` in. A host refuses a request
13
- * whose release (major.minor) differs from its own, or that carries none, before it runs
14
- * anything.
15
- */
16
- export declare const versionHeader = "clankerbox-version";
17
- export declare const Http: ActionHttp.Binding<readonly [Action.Action<"listMachines", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
18
- readonly id: Schema.String;
19
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
20
- readonly createdAt: Schema.DateTimeUtcFromString;
21
- readonly base: Schema.String;
22
- readonly profile: Schema.optionalKey<Schema.String>;
23
- readonly cpu: Schema.Int;
24
- readonly ramMib: Schema.Int;
25
- readonly diskGib: Schema.Int;
26
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
27
- readonly made: Schema.Boolean;
28
- readonly action: Schema.Struct<{
29
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
30
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
31
- readonly error: Schema.optionalKey<Schema.Struct<{
32
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
33
- readonly message: Schema.String;
34
- }>>;
35
- }>;
36
- readonly ssh: Schema.optionalKey<Schema.Struct<{
37
- readonly host: Schema.String;
38
- readonly port: Schema.Int;
39
- readonly user: Schema.String;
40
- }>>;
41
- readonly hostKey: Schema.optionalKey<Schema.String>;
42
- }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"getMachine", Schema.Struct<{
43
- readonly id: Schema.String;
44
- }>, Schema.Struct<{
45
- readonly id: Schema.String;
46
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
47
- readonly createdAt: Schema.DateTimeUtcFromString;
48
- readonly base: Schema.String;
49
- readonly profile: Schema.optionalKey<Schema.String>;
50
- readonly cpu: Schema.Int;
51
- readonly ramMib: Schema.Int;
52
- readonly diskGib: Schema.Int;
53
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
54
- readonly made: Schema.Boolean;
55
- readonly action: Schema.Struct<{
56
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
57
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
58
- readonly error: Schema.optionalKey<Schema.Struct<{
59
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
60
- readonly message: Schema.String;
61
- }>>;
62
- }>;
63
- readonly ssh: Schema.optionalKey<Schema.Struct<{
64
- readonly host: Schema.String;
65
- readonly port: Schema.Int;
66
- readonly user: Schema.String;
67
- }>>;
68
- readonly hostKey: Schema.optionalKey<Schema.String>;
69
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"createMachine", Schema.Struct<{
70
- readonly base: Schema.String;
71
- readonly cpu: Schema.Int;
72
- readonly ramMib: Schema.Int;
73
- readonly diskGib: Schema.Int;
74
- readonly setup: Schema.optionalKey<Schema.Struct<{
75
- readonly script: Schema.String;
76
- readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
77
- }>>;
78
- readonly profile: Schema.optionalKey<Schema.String>;
79
- readonly id: Schema.String;
80
- }>, Schema.Struct<{
81
- readonly id: Schema.String;
82
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
83
- readonly createdAt: Schema.DateTimeUtcFromString;
84
- readonly base: Schema.String;
85
- readonly profile: Schema.optionalKey<Schema.String>;
86
- readonly cpu: Schema.Int;
87
- readonly ramMib: Schema.Int;
88
- readonly diskGib: Schema.Int;
89
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
90
- readonly made: Schema.Boolean;
91
- readonly action: Schema.Struct<{
92
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
93
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
94
- readonly error: Schema.optionalKey<Schema.Struct<{
95
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
96
- readonly message: Schema.String;
97
- }>>;
98
- }>;
99
- readonly ssh: Schema.optionalKey<Schema.Struct<{
100
- readonly host: Schema.String;
101
- readonly port: Schema.Int;
102
- readonly user: Schema.String;
103
- }>>;
104
- readonly hostKey: Schema.optionalKey<Schema.String>;
105
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"startMachine", Schema.Struct<{
106
- readonly id: Schema.String;
107
- }>, Schema.Struct<{
108
- readonly id: Schema.String;
109
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
110
- readonly createdAt: Schema.DateTimeUtcFromString;
111
- readonly base: Schema.String;
112
- readonly profile: Schema.optionalKey<Schema.String>;
113
- readonly cpu: Schema.Int;
114
- readonly ramMib: Schema.Int;
115
- readonly diskGib: Schema.Int;
116
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
117
- readonly made: Schema.Boolean;
118
- readonly action: Schema.Struct<{
119
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
120
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
121
- readonly error: Schema.optionalKey<Schema.Struct<{
122
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
123
- readonly message: Schema.String;
124
- }>>;
125
- }>;
126
- readonly ssh: Schema.optionalKey<Schema.Struct<{
127
- readonly host: Schema.String;
128
- readonly port: Schema.Int;
129
- readonly user: Schema.String;
130
- }>>;
131
- readonly hostKey: Schema.optionalKey<Schema.String>;
132
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"stopMachine", Schema.Struct<{
133
- readonly id: Schema.String;
134
- }>, Schema.Struct<{
135
- readonly id: Schema.String;
136
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
137
- readonly createdAt: Schema.DateTimeUtcFromString;
138
- readonly base: Schema.String;
139
- readonly profile: Schema.optionalKey<Schema.String>;
140
- readonly cpu: Schema.Int;
141
- readonly ramMib: Schema.Int;
142
- readonly diskGib: Schema.Int;
143
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
144
- readonly made: Schema.Boolean;
145
- readonly action: Schema.Struct<{
146
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
147
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
148
- readonly error: Schema.optionalKey<Schema.Struct<{
149
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
150
- readonly message: Schema.String;
151
- }>>;
152
- }>;
153
- readonly ssh: Schema.optionalKey<Schema.Struct<{
154
- readonly host: Schema.String;
155
- readonly port: Schema.Int;
156
- readonly user: Schema.String;
157
- }>>;
158
- readonly hostKey: Schema.optionalKey<Schema.String>;
159
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"deleteMachine", Schema.Struct<{
160
- readonly id: Schema.String;
161
- }>, Schema.Void, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"forkMachine", Schema.Struct<{
162
- readonly machine: Schema.String;
163
- readonly name: Schema.String;
164
- }>, Schema.Struct<{
165
- readonly id: Schema.String;
166
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
167
- readonly createdAt: Schema.DateTimeUtcFromString;
168
- readonly base: Schema.String;
169
- readonly profile: Schema.optionalKey<Schema.String>;
170
- readonly cpu: Schema.Int;
171
- readonly ramMib: Schema.Int;
172
- readonly diskGib: Schema.Int;
173
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
174
- readonly made: Schema.Boolean;
175
- readonly action: Schema.Struct<{
176
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
177
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
178
- readonly error: Schema.optionalKey<Schema.Struct<{
179
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
180
- readonly message: Schema.String;
181
- }>>;
182
- }>;
183
- readonly ssh: Schema.optionalKey<Schema.Struct<{
184
- readonly host: Schema.String;
185
- readonly port: Schema.Int;
186
- readonly user: Schema.String;
187
- }>>;
188
- readonly hostKey: Schema.optionalKey<Schema.String>;
189
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"restoreMachine", Schema.Struct<{
190
- readonly checkpoint: Schema.String;
191
- readonly name: Schema.String;
192
- }>, Schema.Struct<{
193
- readonly id: Schema.String;
194
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
195
- readonly createdAt: Schema.DateTimeUtcFromString;
196
- readonly base: Schema.String;
197
- readonly profile: Schema.optionalKey<Schema.String>;
198
- readonly cpu: Schema.Int;
199
- readonly ramMib: Schema.Int;
200
- readonly diskGib: Schema.Int;
201
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
202
- readonly made: Schema.Boolean;
203
- readonly action: Schema.Struct<{
204
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
205
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
206
- readonly error: Schema.optionalKey<Schema.Struct<{
207
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
208
- readonly message: Schema.String;
209
- }>>;
210
- }>;
211
- readonly ssh: Schema.optionalKey<Schema.Struct<{
212
- readonly host: Schema.String;
213
- readonly port: Schema.Int;
214
- readonly user: Schema.String;
215
- }>>;
216
- readonly hostKey: Schema.optionalKey<Schema.String>;
217
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"listCheckpoints", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
218
- readonly id: Schema.String;
219
- readonly createdAt: Schema.DateTimeUtcFromString;
220
- readonly machine: Schema.String;
221
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
222
- readonly base: Schema.String;
223
- readonly profile: Schema.optionalKey<Schema.String>;
224
- readonly cpu: Schema.Int;
225
- readonly ramMib: Schema.Int;
226
- readonly diskGib: Schema.Int;
227
- readonly action: Schema.Struct<{
228
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
229
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
230
- readonly error: Schema.optionalKey<Schema.Struct<{
231
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
232
- readonly message: Schema.String;
233
- }>>;
234
- }>;
235
- }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"getCheckpoint", Schema.Struct<{
236
- readonly id: Schema.String;
237
- }>, Schema.Struct<{
238
- readonly id: Schema.String;
239
- readonly createdAt: Schema.DateTimeUtcFromString;
240
- readonly machine: Schema.String;
241
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
242
- readonly base: Schema.String;
243
- readonly profile: Schema.optionalKey<Schema.String>;
244
- readonly cpu: Schema.Int;
245
- readonly ramMib: Schema.Int;
246
- readonly diskGib: Schema.Int;
247
- readonly action: Schema.Struct<{
248
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
249
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
250
- readonly error: Schema.optionalKey<Schema.Struct<{
251
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
252
- readonly message: Schema.String;
253
- }>>;
254
- }>;
255
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"captureCheckpoint", Schema.Struct<{
256
- readonly machine: Schema.String;
257
- readonly name: Schema.String;
258
- }>, Schema.Struct<{
259
- readonly id: Schema.String;
260
- readonly createdAt: Schema.DateTimeUtcFromString;
261
- readonly machine: Schema.String;
262
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
263
- readonly base: Schema.String;
264
- readonly profile: Schema.optionalKey<Schema.String>;
265
- readonly cpu: Schema.Int;
266
- readonly ramMib: Schema.Int;
267
- readonly diskGib: Schema.Int;
268
- readonly action: Schema.Struct<{
269
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
270
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
271
- readonly error: Schema.optionalKey<Schema.Struct<{
272
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
273
- readonly message: Schema.String;
274
- }>>;
275
- }>;
276
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"deleteCheckpoint", Schema.Struct<{
277
- readonly id: Schema.String;
278
- }>, Schema.Void, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"getHost", Schema.$Record<Schema.String, Schema.Never>, Schema.Struct<{
279
- readonly id: Schema.String;
280
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
281
- readonly version: Schema.String;
282
- readonly runtimeVersion: Schema.String;
283
- readonly bases: Schema.$Array<Schema.String>;
284
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"getCapacity", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
285
- readonly host: Schema.String;
286
- readonly resource: Schema.Literals<readonly ["ramMib", "runningVms", "activeSandboxes", "startsPerMinute", "startsPerHour", "startsPerDay"]>;
287
- readonly limit: Schema.Int;
288
- readonly used: Schema.Int;
289
- }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>], [], undefined>;
290
- //#endregion
1
+ import { A as HostErrorTag, C as actionsByName, D as Conflict, E as ClankerboxError, F as Unavailable, I as hostErrors, M as Invalid, N as NotFound, O as ConflictKind, P as Precondition, S as Http, T as Capacity, _ as MachineSpec, b as SshEndpoint, c as ActionRecord, d as CheckpointActionName, f as CheckpointActionRecord, g as Machine, h as Limit, i as Interface, j as Internal, k as HostError, l as ActionStatus, m as Host, n as CreateOptions$1, o as client_d_exports, p as CreateRequest, s as ActionName, u as Checkpoint, v as Runtime, w as readTimeout, x as SshLogin, y as Setup } from "./client-DgDb-TR7.mjs";
2
+ import { Effect, FileSystem, Path, PlatformError, Schema, Scope } from "effect";
291
3
  //#region src/ids.d.ts
292
- /** A host's part of every ID it holds. */
293
4
  export declare const HostId: Schema.String;
294
- /** A machine's or checkpoint's name, unique per host and per resource type. */
5
+ /** Unique per host and per resource type. */
295
6
  export declare const Name: Schema.String;
296
- /** The parts of an ID: the host that holds the resource and the resource's name there. */
297
7
  export interface IdParts {
298
8
  readonly host: string;
299
9
  readonly name: string;
300
10
  }
301
- /** A full `<host>_<name>` ID. */
11
+ /** `<host>_<name>`: neither part contains `_`, so an ID has exactly one. */
302
12
  export declare const Id: Schema.String;
303
- /** Splits an ID at its `_` into host and name. */
304
13
  export declare const parseId: (id: string) => Effect.Effect<IdParts, Invalid>;
305
- /** Checks a name on its own, before it is joined to a host. */
306
14
  export declare const parseName: (name: string) => Effect.Effect<string, Invalid>;
307
- /** Joins a host ID and a name into the resource's ID, checking both parts and the whole. */
15
+ /** Checks both parts and the whole. */
308
16
  export declare const formatId: (host: string, name: string) => Effect.Effect<string, Invalid>;
309
17
  declare namespace prebuild_d_exports {
310
- export { Built, Created, build, create, nameOf };
18
+ export { Built, CreateOptions, Created, build, create, nameOf };
311
19
  }
312
20
  /**
313
- * The name of the spec's prebuild on a host: a digest of the spec's label, base and sizes, the
314
- * setup script as sent, and the host's runtime version. A `ram` checkpoint restores only under
315
- * the release that saved it, so after a runtime bump a create misses the old prebuild instead
316
- * of failing to restore it. The setup's timeout is no part of it, and neither is the base's
317
- * image: a host only names it. The script holds whatever secrets a recipe carries, and the name
318
- * 12 hex characters of a digest of it.
21
+ * A digest of the spec's label, base, sizes, setup script as sent, and the host's runtime
22
+ * version: a `ram` checkpoint restores only under the release that saved it, so after a runtime
23
+ * bump a create misses the old prebuild instead of failing to restore it. The setup's timeout and
24
+ * the base's image are no part of it.
319
25
  */
320
26
  declare const nameOf: (spec: MachineSpec, host: Pick<Host, "runtimeVersion">) => Effect.Effect<string>;
27
+ /** `fresh` runs the setup even when the host has a prebuild of the spec. */
28
+ interface CreateOptions extends CreateOptions$1 {
29
+ readonly fresh?: boolean | undefined;
30
+ }
321
31
  interface Created {
322
32
  readonly machine: Machine;
323
33
  /** The prebuild the machine was restored from; without one, its setup ran. */
324
34
  readonly prebuild?: Checkpoint | undefined;
325
35
  }
326
36
  /**
327
- * Creates a machine named `name` as `client.create` does, but restores it from the spec's
328
- * prebuild when the host it lands on has one whose capture is done. A spec without a setup has
329
- * none. Placement is the create's own, and a prebuild stays on the host that made it, so a spec
330
- * placed on another host runs its setup. A failed restore is the reply.
37
+ * `client.create`, restoring the spec's prebuild when the host it is placed on has one whose
38
+ * capture is done, unless `fresh`. A failed restore is the reply.
331
39
  */
332
40
  declare const create: (client: Interface, name: string, spec: MachineSpec, options?: CreateOptions) => Effect.Effect<Created, ClankerboxError>;
333
41
  interface Built {
334
42
  readonly checkpoint: Checkpoint;
335
- /** Whether this call built it; false when it was already there. */
336
43
  readonly built: boolean;
337
- /**
338
- * The ID of the machine that built it, when its delete failed: it may still run, holding its
339
- * RAM, until it is deleted.
340
- */
44
+ /** The builder's ID when its delete failed: it may still run, holding its RAM. */
341
45
  readonly leftover?: string | undefined;
342
46
  }
343
47
  /**
344
- * Builds the spec's prebuild on the host a create of it lands on: a machine of its own runs the
345
- * setup, is captured under the prebuild's name, and is deleted. smolvm captures a running
346
- * machine, RAM included, and boat a running one too; Tart only a stopped one, so its machine is
347
- * stopped first. A prebuild whose capture is done is the answer as it is; one that failed or is
348
- * still captured is refused.
349
- *
350
- * Each build's machine has a random name of its own, and the host takes a checkpoint name once,
351
- * so of two builds of one spec at once both run the setup and the second's capture is
352
- * `Conflict`: neither touches the other's machine or prebuild. A build deletes its machine
353
- * however it ends. If that fails after a failure, the first failure is the reply; after a
354
- * capture, the prebuild is made, and the machine is the reply's `leftover`.
48
+ * Builds the spec's prebuild on the host a create of it is placed on, with a machine of its own
49
+ * that it deletes however it ends. A prebuild that is there and done is the answer; one that
50
+ * failed or is still being captured is refused. Of two builds of one spec at once, the second's
51
+ * capture is `Conflict`, and neither touches the other's machine or prebuild.
355
52
  */
356
- declare const build: (client: Interface, spec: MachineSpec, options?: CreateOptions) => Effect.Effect<Built, ClankerboxError>;
53
+ declare const build: (client: Interface, spec: MachineSpec, options?: CreateOptions$1) => Effect.Effect<Built, ClankerboxError>;
54
+ //#endregion
55
+ //#region src/release.d.ts
56
+ /** Also the version of the clankerbox binaries it ships with. */
57
+ export declare const version: string;
58
+ /** major.minor: releases that share it speak the same API. */
59
+ export declare const release: (of: string) => string;
60
+ /** A host refuses a request whose `release` differs from its own, or that has none. */
61
+ export declare const versionHeader = "clankerbox-version";
357
62
  //#endregion
358
63
  //#region src/profile.d.ts
359
- /** A profile file as read: its fields, with `setup.path` resolved, and its name as `label`. */
64
+ /**
65
+ * A client-side file that fills in a create's spec; hosts never see it. `setup.path` is a script
66
+ * file or a recipe directory, relative to the profile file.
67
+ */
68
+ export declare const Profile: Schema.Struct<{
69
+ readonly base: Schema.String;
70
+ readonly cpu: Schema.Int;
71
+ readonly ramMib: Schema.Int;
72
+ readonly diskGib: Schema.Int;
73
+ readonly setup: Schema.optionalKey<Schema.Struct<{
74
+ readonly path: Schema.String;
75
+ readonly timeoutSeconds: Schema.optionalKey<Schema.Int>;
76
+ }>>;
77
+ readonly host: Schema.optionalKey<Schema.String>;
78
+ }>;
79
+ export type Profile = typeof Profile.Type;
80
+ /** `setup.path` resolved, and the file's name as `label`. */
360
81
  export interface LoadedProfile extends Profile {
361
82
  readonly label: string;
362
83
  }
363
84
  /**
364
- * Reads the profile file at `file`. Its name, the file name without `.json`, is the machine's
365
- * `profile` label, and its `setup.path` is resolved against the file's directory. The setup
366
- * itself is read by whoever sends it, with `readSetup`.
85
+ * Its file name without `.json` is the machine's `profile` label. Unknown keys are refused. The
86
+ * setup itself is read by whoever sends it, with `readSetup`.
367
87
  */
368
88
  export declare const loadProfile: (file: string) => Effect.Effect<LoadedProfile, Invalid, FileSystem.FileSystem | Path.Path>;
89
+ type Sizes = Omit<Profile, "setup" | "host">;
90
+ /** Each field given replaces the profile's. */
91
+ export type Overrides = { readonly [K in keyof Sizes]?: Sizes[K] | undefined; } & {
92
+ /** A setup script or recipe directory, already resolved. */
93
+ readonly setup?: string | undefined;
94
+ readonly setupTimeoutSeconds?: number | undefined;
95
+ readonly host?: string | undefined;
96
+ };
97
+ export interface SpecRequest {
98
+ readonly spec: MachineSpec;
99
+ readonly host: string | undefined;
100
+ }
101
+ /**
102
+ * The spec and host a create of `profile` asks for, with the overrides applied and the setup
103
+ * read. Each refusal names `what`, and each field as `names` calls it.
104
+ */
105
+ export declare const specRequest: (what: string, profile: LoadedProfile | undefined, overrides: Overrides, names?: ReadonlyMap<PropertyKey, string>) => Effect.Effect<SpecRequest, Invalid, FileSystem.FileSystem | Path.Path>;
369
106
  //#endregion
370
107
  //#region src/setup.d.ts
371
108
  /**
372
- * Packs a recipe directory into one self-extracting script, which makes each of its entries
373
- * with plain shell: a directory with `mkdir`, a symlink with `ln -s` as it is, and a file from
374
- * base64, made executable when any of its execute bits is set. A symlink is never walked into,
375
- * so nothing outside the recipe is packed, and in the guest nothing is written through one.
376
- * Of a mode only the execute bit is kept, as git keeps it, so a checkout's umask changes
377
- * nothing. Entries go in sorted order and nothing records a time or an owner, so the same
378
- * files pack into the same script: a prebuild is named after it.
109
+ * Packs a recipe directory, a `setup.sh` and the files it needs, into one self-extracting script.
110
+ * Symlinks are recreated as they are and never walked into. The same files always pack into the
111
+ * same script, as a prebuild is named after it.
379
112
  */
380
113
  export declare const packRecipe: (directory: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem>;
381
- /** Reads a setup: a script file's text, or a recipe directory packed into one script. */
114
+ /** A script file's text, or a recipe directory packed into one script. */
382
115
  export declare const readSetup: (path: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem>;
383
116
  //#endregion
384
117
  //#region src/ssh.d.ts
385
- /** What ssh needs of a machine: where it is reached, as whom, and the host key to pin. */
386
118
  export interface SshTarget {
387
119
  readonly id: string;
388
120
  readonly login: SshLogin;
389
121
  readonly hostKey: string;
390
122
  }
391
- /**
392
- * The machine's SSH target, or what it lacks: an endpoint, which only a running machine has, or
393
- * a host key, which preparation records.
394
- */
123
+ /** Only a running machine has an endpoint, and only a prepared one a host key. */
395
124
  export declare const sshTarget: (machine: Machine) => SshTarget | {
396
125
  readonly lacks: "SSH endpoint" | "SSH host key on record";
397
126
  };
398
127
  /**
399
- * Writes a one-line known-hosts file pinning the target's host key, and returns the arguments
400
- * that run ssh against it with strict host key checking, as `user`. The file lasts as long as
401
- * the scope, which must outlast the ssh it is for. Ports change on fork and restore, and on
402
- * boat at every start, so a target is read anew for each ssh.
128
+ * ssh's arguments, pinned to the target's host key through a known-hosts file that lasts as long
129
+ * as the scope, which must outlast the ssh. Ports change on fork, restore, and every boat start,
130
+ * so read the target anew for each ssh.
403
131
  */
404
132
  export declare const pinnedSsh: (target: SshTarget, user: string, extra: ReadonlyArray<string>) => Effect.Effect<Array<string>, PlatformError.PlatformError, FileSystem.FileSystem | Path.Path | Scope.Scope>;
405
133
  //#endregion
406
134
  //#region src/text.d.ts
407
- /**
408
- * A RAM size, exactly, as a size flag takes one: GiB when it is whole or half GiB, `32G` or
409
- * `1.5G`, and MiB when it isn't, `512M` or `1500M`.
410
- */
135
+ export declare const mibPerGib = 1024;
136
+ /** Exactly, as a size flag takes it: `32G`, `1.5G`, `512M`, `1500M`. */
411
137
  export declare const formatMib: (mib: number) => string;
412
- /**
413
- * Everything a decode refused, on one line, each under its JSON path: `cpu: missing; ram: not a
414
- * known field`. `names` renames top-level fields, as when a flag set each: `--cpu: missing`.
415
- */
138
+ /** On one line: `cpu: missing; ram: not a known field`. `names` renames top-level fields. */
416
139
  export declare const describeIssues: (error: Schema.SchemaError, names?: ReadonlyMap<PropertyKey, string>) => string;
417
140
  /**
418
- * Why a file couldn't be read, without the platform call that met it. Node describes a failure
419
- * only in its cause, so what has no wording here reads as the system's own.
141
+ * Node describes a failure only in its cause, so what has no wording here reads as the system's
142
+ * own.
420
143
  */
421
144
  export declare const describeFileError: ({ reason }: PlatformError.PlatformError) => string;
422
145
  //#endregion
423
- export { ActionName, ActionRecord, Capacity, Checkpoint, ClankerboxError, client_d_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostError, HostErrorTag, Internal, Invalid, Limit, Machine, MachineSpec, NotFound, prebuild_d_exports as Prebuild, Precondition, Profile, Runtime, Setup, SshEndpoint, SshLogin, Unavailable, hostErrors, release, version };
146
+ export { ActionName, ActionRecord, ActionStatus, Capacity, Checkpoint, CheckpointActionName, CheckpointActionRecord, ClankerboxError, client_d_exports as Client, Conflict, ConflictKind, CreateRequest, Host, HostError, HostErrorTag, Http, Internal, Invalid, Limit, Machine, MachineSpec, NotFound, prebuild_d_exports as Prebuild, Precondition, Runtime, Setup, SshEndpoint, SshLogin, Unavailable, actionsByName, hostErrors, readTimeout };