@gjermundgaraba/clankerbox-sdk 0.18.3 → 0.20.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.
@@ -24,20 +24,31 @@ var NotFound = class extends Schema.TaggedError()("NotFound", {
24
24
  message: Schema.String,
25
25
  ...located
26
26
  }, { httpApiStatus: 404 }) {};
27
- const ConflictKind = Schema.Literals(["exists", "busy"]);
28
- /** The name is taken (`exists`), or another action holds the resource (`busy`). */
27
+ /** The name is taken. */
29
28
  var Conflict = class extends Schema.TaggedError()("Conflict", {
30
29
  message: Schema.String,
31
- kind: ConflictKind,
32
30
  ...located
33
31
  }, { httpApiStatus: 409 }) {};
32
+ /**
33
+ * A later request on the machine replaced this one before the host got there: `by` is what that
34
+ * request asked for. The machine's own state says where it is now.
35
+ */
36
+ var Superseded = class extends Schema.TaggedError()("Superseded", {
37
+ message: Schema.String,
38
+ ...located,
39
+ by: Schema.Literals([
40
+ "running",
41
+ "stopped",
42
+ "deleted"
43
+ ])
44
+ }, { httpApiStatus: 409 }) {};
34
45
  /** No host offers `base`: the host a create names, or any in the client's list. */
35
46
  var NotOffered = class extends Schema.TaggedError()("NotOffered", {
36
47
  message: Schema.String,
37
48
  ...located,
38
49
  base: Schema.String
39
50
  }, { httpApiStatus: 412 }) {};
40
- /** `machine`'s create, fork or restore failed before it was made: it can only be deleted. */
51
+ /** `machine` isn't made yet: its create or setup still runs, so it can't be copied or captured. */
41
52
  var NotMade = class extends Schema.TaggedError()("NotMade", {
42
53
  message: Schema.String,
43
54
  ...located,
@@ -49,12 +60,6 @@ var Missing = class extends Schema.TaggedError()("Missing", {
49
60
  ...located,
50
61
  machine: Schema.String
51
62
  }, { httpApiStatus: 412 }) {};
52
- /** `checkpoint`'s capture failed, so nothing restores from it: it can only be deleted. */
53
- var NotReady = class extends Schema.TaggedError()("NotReady", {
54
- message: Schema.String,
55
- ...located,
56
- checkpoint: Schema.String
57
- }, { httpApiStatus: 412 }) {};
58
63
  /** `checkpoint` holds RAM state saved under another runtime pin than the one the host runs. */
59
64
  var PinMismatch = class extends Schema.TaggedError()("PinMismatch", {
60
65
  message: Schema.String,
@@ -75,12 +80,13 @@ var Unsizable = class extends Schema.TaggedError()("Unsizable", {
75
80
  }, { httpApiStatus: 422 }) {};
76
81
  /**
77
82
  * A guest script exited non-zero or ran past its timeout; the message says which, with its
78
- * output's tail. A failed `setup` leaves the machine unmade, a failed `preparation` made.
83
+ * output's tail, and `script` names it: a failed `setup` deletes the machine, and a failed
84
+ * `preparation` runs again on the next start.
79
85
  */
80
86
  var ScriptFailed = class extends Schema.TaggedError()("ScriptFailed", {
81
87
  message: Schema.String,
82
88
  ...located,
83
- script: Schema.Literals(["setup", "preparation"])
89
+ script: Schema.String
84
90
  }, { httpApiStatus: 422 }) {};
85
91
  /** The provider under the runtime refused the call for good, such as for its plan or API key. */
86
92
  var Refused = class extends Schema.TaggedError()("Refused", {
@@ -110,10 +116,10 @@ const hostErrors = [
110
116
  Invalid,
111
117
  NotFound,
112
118
  Conflict,
119
+ Superseded,
113
120
  NotOffered,
114
121
  NotMade,
115
122
  Missing,
116
- NotReady,
117
123
  PinMismatch,
118
124
  WrongState,
119
125
  Unsizable,
@@ -126,22 +132,24 @@ const HostError = Schema.Union(hostErrors);
126
132
  /**
127
133
  * Each carries, where known: `host` and `action`, which the client sets; `id`, the resource the
128
134
  * error is about, which a host sets on `NotFound` and `Conflict` and the client sets to the call's
129
- * subject otherwise; and `made`, the resource a create, fork, restore or capture makes, which a
130
- * failure may leave behind.
135
+ * subject otherwise; and `made`, the resource a create, fork, restore or capture makes. The host
136
+ * deletes a machine whose copy or setup fails, again at each recheck while that delete fails, and
137
+ * keeps one whose preparation fails; a call whose answer was lost, `Unavailable`, may leave
138
+ * `made` behind unmade.
131
139
  */
132
140
  const ClankerboxError = Schema.Union([...hostErrors, Unavailable]);
133
141
  /**
134
- * Whether the same call may succeed later: a busy resource or a full host may free up, and a read
135
- * that got no reply may get one.
142
+ * Whether the same call may succeed later: a full host may free up, and a read that got no reply
143
+ * may get one.
136
144
  */
137
145
  const retryable = (error) => Match.value(error).pipe(Match.tagsExhaustive({
138
146
  Invalid: () => false,
139
147
  NotFound: () => false,
140
- Conflict: ({ kind }) => kind === "busy",
148
+ Conflict: () => false,
149
+ Superseded: () => false,
141
150
  NotOffered: () => false,
142
151
  NotMade: () => false,
143
152
  Missing: () => false,
144
- NotReady: () => false,
145
153
  PinMismatch: () => false,
146
154
  WrongState: () => false,
147
155
  Unsizable: () => false,
@@ -196,31 +204,31 @@ const Runtime = Schema.Literals([
196
204
  "boat"
197
205
  ]);
198
206
  const Size = Schema.Int.check(Schema.isGreaterThan(0));
199
- /** The contract's mutations, which record themselves on a resource's `action`. */
200
- const ActionName = Schema.Literals([
201
- "createMachine",
202
- "startMachine",
203
- "stopMachine",
204
- "deleteMachine",
205
- "forkMachine",
206
- "restoreMachine",
207
- "captureCheckpoint",
208
- "deleteCheckpoint"
209
- ]);
210
- const ActionStatus = Schema.Literals([
207
+ /** What the operator asked a machine to be; the host keeps moving the machine toward it. */
208
+ const Desired = Schema.Literals([
211
209
  "running",
210
+ "stopped",
211
+ "deleted"
212
+ ]);
213
+ /**
214
+ * What the host is doing about a machine. A request waits for a rest: `settled`, at rest with what
215
+ * was asked; `failed`, after a step failed, until the next request; `lost`, one the runtime no
216
+ * longer has, which can only be deleted; and `waiting`, one the runtime can't read, which fails the
217
+ * request and is read again at the host's next recheck. `creating` copies the machine and runs its
218
+ * setup, and a machine whose create or setup fails is deleted. `starting` starts the machine, also
219
+ * when it runs already, and prepares it.
220
+ */
221
+ const Phase = Schema.Literals([
222
+ "observing",
223
+ "waiting",
224
+ "creating",
225
+ "starting",
226
+ "stopping",
227
+ "deleting",
228
+ "settled",
212
229
  "failed",
213
- "done"
230
+ "lost"
214
231
  ]);
215
- /** A resource's last action; the next action replaces it. */
216
- const ActionRecord = Schema.Union([Schema.Struct({
217
- name: ActionName,
218
- status: Schema.Literals(["running", "done"])
219
- }), Schema.Struct({
220
- name: ActionName,
221
- status: Schema.Literal("failed"),
222
- error: HostError
223
- })]);
224
232
  const SshEndpoint = Schema.Struct({
225
233
  host: Schema.String,
226
234
  port: Schema.Int.check(Schema.isBetween({
@@ -233,10 +241,30 @@ const SshLogin = Schema.Struct({
233
241
  ...SshEndpoint.fields
234
242
  });
235
243
  /**
236
- * `state` is `missing` when the runtime doesn't have the machine, and `unknown` when it couldn't
237
- * be read. Until its create, fork or restore has `made` it, a machine can only be read, stopped or
238
- * deleted. `ssh` is only on a running machine whose runtime gives it an endpoint, and `hostKey`,
239
- * `<type> <base64>`, once preparation has recorded it.
244
+ * A running machine's place on the tailnet, as the host last checked it: `joined` once
245
+ * `tailscaled` runs signed in, with the MagicDNS name Tailscale gave it, if any; `failed` with
246
+ * why; or `missing` when the guest has no `tailscaled`. Kept in the host's memory only: each start
247
+ * checks again, a joined machine is checked again every half hour or so, and a failed one sooner,
248
+ * waiting longer after each failure.
249
+ */
250
+ const TailnetStatus = Schema.Union([
251
+ Schema.Struct({
252
+ state: Schema.Literal("joined"),
253
+ name: Schema.optionalKey(Schema.String)
254
+ }),
255
+ Schema.Struct({
256
+ state: Schema.Literal("failed"),
257
+ error: Schema.String
258
+ }),
259
+ Schema.Struct({ state: Schema.Literal("missing") })
260
+ ]).annotate({ identifier: "TailnetStatus" });
261
+ /**
262
+ * `state` is what the runtime reports: `missing` when it doesn't have the machine, and `unknown`
263
+ * when it couldn't be read. `desired` is what the last request asked for, `phase` what the host is
264
+ * doing about it, and `error` why the last step failed, until the next request. `ssh` is only
265
+ * on a running machine whose runtime gives it an endpoint, and `hostKey`, `<type> <base64>`, once
266
+ * preparation has recorded it. `tailnet` is on a running machine of a host that joins its machines
267
+ * to a tailnet, once the host has checked it.
240
268
  */
241
269
  const Machine = Schema.Struct({
242
270
  id: Id,
@@ -253,14 +281,22 @@ const Machine = Schema.Struct({
253
281
  "missing",
254
282
  "unknown"
255
283
  ]),
256
- made: Schema.Boolean,
257
- action: ActionRecord,
284
+ desired: Desired,
285
+ phase: Phase,
286
+ error: Schema.optionalKey(HostError),
258
287
  ssh: Schema.optionalKey(SshLogin),
259
- hostKey: Schema.optionalKey(Schema.String)
288
+ hostKey: Schema.optionalKey(Schema.String),
289
+ tailnet: Schema.optionalKey(TailnetStatus)
260
290
  }).annotate({ identifier: "Machine" });
261
- /** The state as people read it: `running`, or `stopped (unmade)` for one never made. */
262
- const stateLabel = ({ state, made }) => made ? state : `${state} (unmade)`;
263
- /** `kind` is `ram` (RAM and disks) on smolvm, and `disk` on Tart and boat. */
291
+ /**
292
+ * The state as people read it: `running` at rest, `running (failed)` where it is but not at rest,
293
+ * and `stopped, wants running (starting)` on the way.
294
+ */
295
+ const stateLabel = ({ state, desired, phase }) => phase === "settled" ? state : state === desired ? `${state} (${phase})` : `${state}, wants ${desired} (${phase})`;
296
+ /**
297
+ * `kind` is `ram` (RAM and disks) on smolvm, and `disk` on Tart and boat. A checkpoint exists only
298
+ * once its capture is done, and never changes after.
299
+ */
264
300
  const Checkpoint = Schema.Struct({
265
301
  id: Id,
266
302
  createdAt: Schema.DateTimeUtcFromString,
@@ -270,11 +306,8 @@ const Checkpoint = Schema.Struct({
270
306
  profile: Schema.optionalKey(Schema.String),
271
307
  cpu: Size,
272
308
  ramMib: Size,
273
- diskGib: Size,
274
- action: ActionRecord
309
+ diskGib: Size
275
310
  }).annotate({ identifier: "Checkpoint" });
276
- /** A checkpoint restores once its capture is done; it never changes after. */
277
- const isReady = (checkpoint) => checkpoint.action.status === "done";
278
311
  /**
279
312
  * `runtimeVersion` is boat's API version on boat. `captureFrom` is the state a machine must be in
280
313
  * to be captured: Tart's is `stopped`.
@@ -316,10 +349,25 @@ const Usage = Schema.Union([Schema.Struct({
316
349
  ...usageFields,
317
350
  unread: Schema.Array(Id)
318
351
  })]).annotate({ identifier: "Usage" });
319
- /** Nothing logs the script: it can carry secrets. */
352
+ const publicKeyLine = /^(?:ssh|ecdsa|sk)-[a-z0-9@.-]+ [A-Za-z0-9+/]+={0,3}(?: .*)?$/u;
353
+ const blankLine = /^\s*$/u;
354
+ /**
355
+ * Public keys, as `.pub` files hold them: each line that isn't blank is `<type> <base64>
356
+ * [comment]`, the type an OpenSSH key's, its certificate's or a hardware key's, and at least one
357
+ * line is. Anything else, a private key included, is refused.
358
+ */
359
+ const PublicKeys = Schema.String.check(Schema.makeFilter((text) => {
360
+ const lines = text.split("\n").filter((line) => !blankLine.test(line));
361
+ return lines.length > 0 && lines.every((line) => publicKeyLine.test(line)) || "each line that isn't blank is a public key, <type> <base64> [comment], as a .pub file holds it";
362
+ }));
363
+ /**
364
+ * Nothing logs the script: it can carry secrets. `authorizedKeys` is appended to the login user's
365
+ * `~/.ssh/authorized_keys` once the script exits 0, through the guest's `sudo`.
366
+ */
320
367
  const Setup = Schema.Struct({
321
368
  script: Schema.String,
322
- timeoutSeconds: Schema.optionalKey(Size)
369
+ timeoutSeconds: Schema.optionalKey(Size),
370
+ authorizedKeys: Schema.optionalKey(PublicKeys)
323
371
  });
324
372
  const specFields = {
325
373
  base: Schema.String,
@@ -336,6 +384,17 @@ const CreateRequest = Schema.Struct({
336
384
  id: Id,
337
385
  ...specFields
338
386
  });
387
+ /** A prebuild is the checkpoint `id` of a machine made from the spec, setup and all. */
388
+ const PrebuildRequest = Schema.Struct({
389
+ id: Id,
390
+ ...specFields,
391
+ setup: Setup
392
+ });
393
+ /** `built` is false when the host already had the checkpoint. */
394
+ const Prebuilt = Schema.Struct({
395
+ checkpoint: Checkpoint,
396
+ built: Schema.Boolean
397
+ });
339
398
  //#endregion
340
399
  //#region src/api.ts
341
400
  /** A host bounds its own reads of runtime state under it, so a list answers in time. */
@@ -359,20 +418,28 @@ const reading = [
359
418
  NotFound,
360
419
  Internal
361
420
  ];
362
- const changing = [
421
+ const removing = [
363
422
  Invalid,
364
423
  NotFound,
365
- Conflict,
366
424
  Refused,
367
425
  Internal
368
426
  ];
369
- const booting = [
370
- ...changing,
427
+ const converging = [
428
+ Invalid,
429
+ NotFound,
371
430
  NotMade,
372
431
  Missing,
373
432
  WrongState,
374
- Capacity
433
+ PinMismatch,
434
+ Unsizable,
435
+ ScriptFailed,
436
+ Refused,
437
+ Capacity,
438
+ Superseded,
439
+ Internal
375
440
  ];
441
+ const making = [...converging, Conflict];
442
+ const creating = [...making, NotOffered];
376
443
  const Http = ActionHttp.make([
377
444
  Action.make("listMachines", {
378
445
  ...read,
@@ -389,62 +456,42 @@ const Http = ActionHttp.make([
389
456
  }),
390
457
  Action.make("createMachine", {
391
458
  ...write,
392
- error: [
393
- Invalid,
394
- Conflict,
395
- NotOffered,
396
- Unsizable,
397
- ScriptFailed,
398
- Refused,
399
- Capacity,
400
- Internal
401
- ],
402
- description: "Create a machine from a base, run its setup once, and prepare it.",
459
+ error: creating,
460
+ description: "Create a machine from a base, run its setup once, and prepare it. A create or setup that fails deletes the machine, again at each recheck while that delete fails, and the error is the answer; a preparation that fails keeps it.",
403
461
  input: CreateRequest,
404
462
  success: Machine
405
463
  }),
406
464
  Action.make("startMachine", {
407
465
  ...write,
408
- error: [...booting, ScriptFailed],
409
- description: "Start a machine. On a running machine, run preparation again.",
466
+ error: converging,
467
+ description: "Ask for a machine to run, and wait until it does: start it and prepare it again, also when it runs already.",
410
468
  input: ById,
411
469
  success: Machine
412
470
  }),
413
471
  Action.make("stopMachine", {
414
472
  ...write,
415
- error: changing,
416
- description: "Stop a machine: a power-off that keeps its disk and ends its processes. A stopped machine stays stopped, and the stop is still its last action.",
473
+ error: converging,
474
+ description: "Ask for a machine to stay stopped, and wait until it is: a power-off that keeps its disk and ends its processes. A start under way is cut short; a machine still being made is made first, and its create answers Superseded.",
417
475
  input: ById,
418
476
  success: Machine
419
477
  }),
420
478
  Action.make("deleteMachine", {
421
479
  ...write,
422
- error: changing,
423
- description: "Delete a machine and everything native it owns.",
480
+ error: converging,
481
+ description: "Delete a machine and everything native it owns, whatever it is doing.",
424
482
  input: ById
425
483
  }),
426
484
  Action.make("forkMachine", {
427
485
  ...write,
428
- error: [
429
- ...booting,
430
- Unsizable,
431
- ScriptFailed
432
- ],
433
- description: "Copy a machine to a new name on the same host.",
486
+ error: making,
487
+ description: "Copy a machine to a new name on the same host. A copy that fails deletes the new machine.",
434
488
  input: FromMachine,
435
489
  success: Machine
436
490
  }),
437
491
  Action.make("restoreMachine", {
438
492
  ...write,
439
- error: [
440
- ...changing,
441
- NotReady,
442
- PinMismatch,
443
- Unsizable,
444
- ScriptFailed,
445
- Capacity
446
- ],
447
- description: "Create a machine on the checkpoint's host from that checkpoint.",
493
+ error: making,
494
+ description: "Create a machine on the checkpoint's host from that checkpoint. A restore that fails deletes the new machine.",
448
495
  input: Schema.Struct({
449
496
  checkpoint: Id,
450
497
  name: Name
@@ -466,17 +513,34 @@ const Http = ActionHttp.make([
466
513
  }),
467
514
  Action.make("captureCheckpoint", {
468
515
  ...write,
469
- error: booting,
516
+ error: [
517
+ Invalid,
518
+ NotFound,
519
+ Conflict,
520
+ NotMade,
521
+ Missing,
522
+ WrongState,
523
+ Refused,
524
+ Capacity,
525
+ Internal
526
+ ],
470
527
  description: "Capture a checkpoint of a machine. Its kind follows the runtime: ram on smolvm, which captures only a running machine, and disk on Tart and boat.",
471
528
  input: FromMachine,
472
529
  success: Checkpoint
473
530
  }),
474
531
  Action.make("deleteCheckpoint", {
475
532
  ...write,
476
- error: changing,
477
- description: "Delete a checkpoint.",
533
+ error: removing,
534
+ description: "Delete a checkpoint, once the restores that read it are done.",
478
535
  input: ById
479
536
  }),
537
+ Action.make("prebuildCheckpoint", {
538
+ ...write,
539
+ error: creating,
540
+ description: "Make checkpoint id from a machine the host builds from the spec, setup and all, and deletes after. A checkpoint id that exists is the answer, and two prebuilds of one id share one build.",
541
+ input: PrebuildRequest,
542
+ success: Prebuilt
543
+ }),
480
544
  Action.make("getHost", {
481
545
  ...read,
482
546
  error: [Invalid],
@@ -498,7 +562,7 @@ const actionsByName = Action.byName(Http.actions);
498
562
  //#endregion
499
563
  //#region src/release.ts
500
564
  /** Also the version of the clankerbox CLI released with it. */
501
- const version = "0.18.3";
565
+ const version = "0.20.0";
502
566
  /** major.minor: releases that share it speak the same API. */
503
567
  const release = (of) => of.split(".").slice(0, 2).join(".");
504
568
  /** A host refuses a request whose `release` differs from its own, or that has none. */
@@ -700,9 +764,10 @@ const make = (hosts, options) => Effect.gen(function* () {
700
764
  restoreMachine: (input) => onResource("restoreMachine", input, input.name),
701
765
  getCheckpoint: (input) => onResource("getCheckpoint", input),
702
766
  captureCheckpoint: (input) => onResource("captureCheckpoint", input, input.name),
703
- deleteCheckpoint: (input) => deleting(onResource("deleteCheckpoint", input))
767
+ deleteCheckpoint: (input) => deleting(onResource("deleteCheckpoint", input)),
768
+ prebuildCheckpoint: (input) => onResource("prebuildCheckpoint", input)
704
769
  };
705
770
  });
706
771
  const layer = (hosts, options) => Layer.effect(Client, make(hosts, options));
707
772
  //#endregion
708
- export { parseId as A, NotFound as B, Usage as C, Id as D, HostId as E, ConflictKind as F, Refused as G, NotOffered as H, HostError as I, Unsizable as J, ScriptFailed as K, Internal as L, Capacity as M, ClankerboxError as N, Name as O, Conflict as P, Invalid as R, SshLogin as S, stateLabel as T, NotReady as U, NotMade as V, PinMismatch as W, hostErrors as X, WrongState as Y, retryable as Z, Machine as _, release as a, Setup as b, Http as c, ActionName as d, ActionRecord as f, Host as g, CreateRequest as h, describeIssues as i, parseName as j, formatId as k, actionsByName as l, Checkpoint as m, layer as n, version as o, ActionStatus as p, Unavailable as q, describeFileError as r, versionHeader as s, client_exports as t, readTimeout as u, MachineSpec as v, isReady as w, SshEndpoint as x, Runtime as y, Missing as z };
773
+ export { Name as A, Missing as B, SshEndpoint as C, stateLabel as D, Usage as E, ClankerboxError as F, Refused as G, NotMade as H, Conflict as I, Unavailable as J, ScriptFailed as K, HostError as L, parseId as M, parseName as N, HostId as O, Capacity as P, retryable as Q, Internal as R, Setup as S, TailnetStatus as T, NotOffered as U, NotFound as V, PinMismatch as W, WrongState as X, Unsizable as Y, hostErrors as Z, Phase as _, release as a, PublicKeys as b, Http as c, Checkpoint as d, CreateRequest as f, MachineSpec as g, Machine as h, describeIssues as i, formatId as j, Id as k, actionsByName as l, Host as m, layer as n, version as o, Desired as p, Superseded as q, describeFileError as r, versionHeader as s, client_exports as t, readTimeout as u, PrebuildRequest as v, SshLogin as w, Runtime as x, Prebuilt as y, Invalid as z };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as ConflictKind, B as Refused, C as Declared, D as Capacity, E as readTimeout, F as NotFound, G as hostErrors, H as Unavailable, I as NotMade, K as retryable, L as NotOffered, M as Internal, N as Invalid, O as ClankerboxError, P as Missing, R as NotReady, S as stateLabel, T as actionsByName, U as Unsizable, V as ScriptFailed, W as WrongState, _ as Setup, b as Usage, c as ActionRecord, d as CreateRequest, f as Host, g as Runtime, h as Reading, i as Interface, j as HostError, k as Conflict, l as ActionStatus, m as MachineSpec, n as CreateOptions$1, o as client_d_exports, p as Machine, s as ActionName, u as Checkpoint, v as SshEndpoint, w as Http, x as isReady, y as SshLogin, z as PinMismatch } from "./client-8af586hb.mjs";
1
+ import { A as ClankerboxError, B as Refused, C as Usage, D as actionsByName, E as Http, F as Missing, G as WrongState, H as Superseded, I as NotFound, K as hostErrors, L as NotMade, M as HostError, N as Internal, O as readTimeout, P as Invalid, R as NotOffered, S as TailnetStatus, T as Declared, U as Unavailable, V as ScriptFailed, W as Unsizable, _ as Reading, b as SshEndpoint, c as CreateRequest, d as Machine, f as MachineSpec, g as PublicKeys, h as Prebuilt, i as Interface, j as Conflict, k as Capacity, l as Desired, m as PrebuildRequest, n as CreateOptions$1, o as client_d_exports, p as Phase, q as retryable, s as Checkpoint, u as Host, v as Runtime, w as stateLabel, x as SshLogin, y as Setup, z as PinMismatch } from "./client-Dr3PcuCP.mjs";
2
2
  import { Effect, FileSystem, Path, PlatformError, Schema, Scope } from "effect";
3
3
  //#region src/ids.d.ts
4
4
  export declare const HostId: Schema.String;
@@ -15,11 +15,11 @@ export declare const parseName: (name: string) => Effect.Effect<string, Invalid>
15
15
  /** Checks both parts and the whole. */
16
16
  export declare const formatId: (host: string, name: string) => Effect.Effect<string, Invalid>;
17
17
  declare namespace prebuild_d_exports {
18
- export { Built, CreateOptions, Created, build, create, nameOf };
18
+ export { CreateOptions, Created, build, create, nameOf };
19
19
  }
20
20
  /**
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
21
+ * A digest of the spec's label, base, sizes, setup script as sent, authorized keys, and the host's
22
+ * runtime version: a `ram` checkpoint restores only under the release that saved it, so after a runtime
23
23
  * bump a create misses the old prebuild instead of failing to restore it. The setup's timeout and
24
24
  * the base's image are no part of it.
25
25
  */
@@ -34,26 +34,17 @@ interface Created {
34
34
  readonly prebuild?: Checkpoint | undefined;
35
35
  }
36
36
  /**
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.
37
+ * `client.create`, restoring the spec's prebuild when the host it is placed on has one, unless
38
+ * `fresh`. A failed restore is the reply.
39
39
  */
40
40
  declare const create: (client: Interface, name: string, spec: MachineSpec, options?: CreateOptions) => Effect.Effect<Created, ClankerboxError>;
41
- interface Built {
42
- readonly checkpoint: Checkpoint;
43
- readonly built: boolean;
44
- /** The builder's ID when its delete failed: it may still run, holding its RAM. */
45
- readonly leftover?: string | undefined;
46
- }
47
41
  /**
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 is deleted and built again, and one still running is `Conflict{busy}`, as its capture
51
- * holds it. Of two builds of one spec at once, the second's capture is `Conflict`, and neither
52
- * touches the other's machine.
42
+ * Asks the host a create of the spec is placed on for the spec's prebuild, which it builds with a
43
+ * machine of its own unless it has it. Two builds of one spec at once share the host's one build.
53
44
  */
54
45
  declare const build: (client: Interface, spec: MachineSpec & {
55
46
  readonly setup: Setup;
56
- }, options?: CreateOptions$1) => Effect.Effect<Built, ClankerboxError>;
47
+ }, options?: CreateOptions$1) => Effect.Effect<Prebuilt, ClankerboxError>;
57
48
  //#endregion
58
49
  //#region src/release.d.ts
59
50
  /** Also the version of the clankerbox CLI released with it. */
@@ -96,6 +87,8 @@ export type Overrides = { readonly [K in keyof Sizes]?: Sizes[K] | undefined; }
96
87
  readonly setup?: string | undefined;
97
88
  readonly setupTimeoutSeconds?: number | undefined;
98
89
  readonly host?: string | undefined;
90
+ /** A public-key file, already resolved, which a setup needs and which is read only for one. */
91
+ readonly authorizedKeys?: string | undefined;
99
92
  };
100
93
  export interface SpecRequest {
101
94
  readonly spec: MachineSpec;
@@ -116,6 +109,11 @@ export declare const specRequest: (what: string, profile: LoadedProfile | undefi
116
109
  export declare const packRecipe: (directory: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem>;
117
110
  /** A script file's text, or a recipe directory packed into one script. */
118
111
  export declare const readSetup: (path: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem>;
112
+ /**
113
+ * A public-key file's text, such as `~/.ssh/id_ed25519.pub`'s, for a setup's `authorizedKeys`, with
114
+ * its line endings as `\n`.
115
+ */
116
+ export declare const readAuthorizedKeys: (path: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem>;
119
117
  //#endregion
120
118
  //#region src/ssh.d.ts
121
119
  export interface SshTarget {
@@ -154,4 +152,4 @@ export declare const formatMib: (mib: number) => string;
154
152
  /** As a size flag takes it: `60G`. */
155
153
  export declare const formatGib: (gib: number) => string;
156
154
  //#endregion
157
- export { ActionName, ActionRecord, ActionStatus, Capacity, Checkpoint, ClankerboxError, client_d_exports as Client, Conflict, ConflictKind, CreateRequest, Declared, Host, HostError, Http, Internal, Invalid, Machine, MachineSpec, Missing, NotFound, NotMade, NotOffered, NotReady, PinMismatch, prebuild_d_exports as Prebuild, Reading, Refused, Runtime, ScriptFailed, Setup, SshEndpoint, SshLogin, Unavailable, Unsizable, Usage, WrongState, actionsByName, hostErrors, isReady, readTimeout, retryable, stateLabel };
155
+ export { Capacity, Checkpoint, ClankerboxError, client_d_exports as Client, Conflict, CreateRequest, Declared, Desired, Host, HostError, Http, Internal, Invalid, Machine, MachineSpec, Missing, NotFound, NotMade, NotOffered, Phase, PinMismatch, prebuild_d_exports as Prebuild, PrebuildRequest, Prebuilt, PublicKeys, Reading, Refused, Runtime, ScriptFailed, Setup, SshEndpoint, SshLogin, Superseded, TailnetStatus, Unavailable, Unsizable, Usage, WrongState, actionsByName, hostErrors, readTimeout, retryable, stateLabel };