@gjermundgaraba/clankerbox-sdk 0.12.2 → 0.14.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.
@@ -41,12 +41,12 @@ declare class Capacity extends Capacity_base {
41
41
  }
42
42
  declare const Unavailable_base: Schema.Class<Unavailable, Schema.TaggedStruct<"Unavailable", {
43
43
  readonly message: Schema.String;
44
- readonly access: Schema.Literals<("read" | "write")[]>;
44
+ readonly readOnly: Schema.Boolean;
45
45
  }>, import("effect/Cause").YieldableError>;
46
46
  /**
47
47
  * The client couldn't reach the host, or lost its reply. Only the client library produces
48
- * it. `access` is the access of the action that met it: a mutation's request may have
49
- * reached the host and run, so it is never retryable.
48
+ * it. `readOnly` is that of the action that met it: a mutation's request may have reached
49
+ * the host and run, so it is never retryable.
50
50
  */
51
51
  declare class Unavailable extends Unavailable_base {
52
52
  get retryable(): boolean;
@@ -57,7 +57,7 @@ declare const Internal_base: Schema.Class<Internal, Schema.TaggedStruct<"Interna
57
57
  declare class Internal extends Internal_base {
58
58
  get retryable(): boolean;
59
59
  }
60
- /** What a host answers with; every action group declares these. */
60
+ /** What a host answers with; every action declares these. */
61
61
  declare const hostErrors: readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal];
62
62
  type HostError = InstanceType<(typeof hostErrors)[number]>;
63
63
  /** What a call through the client library fails with. */
@@ -161,6 +161,22 @@ declare const Host: Schema.Struct<{
161
161
  readonly bases: Schema.$Array<Schema.String>;
162
162
  }>;
163
163
  type Host = typeof Host.Type;
164
+ /**
165
+ * One limit a host's `Capacity` refusals come from, and how much of it is in use, counted as
166
+ * the refusal counts it, so `used` needn't match the host's own machines. Read from the runtime,
167
+ * never stored.
168
+ */
169
+ declare const Limit: Schema.Struct<{
170
+ readonly host: Schema.String;
171
+ /**
172
+ * `ramMib`: smolvm's RAM budget. `runningVms`: Tart's, Apple's two VMs per Mac.
173
+ * `activeSandboxes` and the `starts` of each rolling window: the boat account's.
174
+ */
175
+ readonly resource: Schema.Literals<readonly ["ramMib", "runningVms", "activeSandboxes", "startsPerMinute", "startsPerHour", "startsPerDay"]>;
176
+ readonly limit: Schema.Int;
177
+ readonly used: Schema.Int;
178
+ }>;
179
+ type Limit = typeof Limit.Type;
164
180
  /** A setup script and how long it may run. Nothing logs the script: it can carry secrets. */
165
181
  declare const Setup: Schema.Struct<{
166
182
  readonly script: Schema.String;
@@ -261,6 +277,8 @@ interface Interface {
261
277
  readonly hosts: Effect.Effect<Gathered<Host>>;
262
278
  readonly machines: Effect.Effect<Gathered<Machine>>;
263
279
  readonly checkpoints: Effect.Effect<Gathered<Checkpoint>>;
280
+ /** Every host's limits; a host whose runtime couldn't be read is among the unreachable. */
281
+ readonly capacity: Effect.Effect<Gathered<Limit>>;
264
282
  readonly machine: (id: string) => Effect.Effect<Machine, ClankerboxError>;
265
283
  readonly checkpoint: (id: string) => Effect.Effect<Checkpoint, ClankerboxError>;
266
284
  /**
@@ -286,4 +304,4 @@ declare class Client extends Client_base {}
286
304
  */
287
305
  declare const make: (hosts: ReadonlyArray<HostEntry>, options?: Options) => Effect.Effect<Interface, Invalid, HttpClient.HttpClient>;
288
306
  //#endregion
289
- export { hostErrors as A, HostError as C, NotFound as D, Invalid as E, Precondition as O, ErrorTag as S, Internal as T, version as _, ActionName as a, Conflict as b, CreateRequest as c, MachineSpec as d, Profile as f, release as g, SshEndpoint as h, client_d_exports as i, Unavailable as k, Host as l, Setup as m, HostEntry as n, ActionRecord as o, Runtime as p, Options as r, Checkpoint as s, Client as t, Machine as u, Capacity as v, HostErrorTag as w, ConflictKind as x, ClankerboxError as y };
307
+ export { Unavailable as A, ErrorTag as C, Invalid as D, Internal as E, NotFound as O, ConflictKind as S, HostErrorTag as T, release as _, ActionName as a, ClankerboxError as b, CreateRequest as c, Machine as d, MachineSpec as f, SshEndpoint as g, Setup as h, client_d_exports as i, hostErrors as j, Precondition as k, Host as l, Runtime as m, HostEntry as n, ActionRecord as o, Profile as p, Options as r, Checkpoint as s, Client as t, Limit as u, version as v, HostError as w, Conflict as x, Capacity as y };
@@ -1,11 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import * as Action from "@gjermundgaraba/effect-actions/Action";
3
- import * as ActionGroup from "@gjermundgaraba/effect-actions/ActionGroup";
4
3
  import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
5
4
  import { Context, Duration, Effect, Fiber, Match, Predicate, Result, Schema } from "effect";
6
5
  import { HttpClient, HttpClientRequest } from "effect/http";
7
- import { HttpApiClient } from "effect/http-api";
8
6
  //#region src/errors.ts
7
+ /**
8
+ * The seven errors every clankerbox call can fail with. `retryable` is derived from the
9
+ * tag, so callers never keep their own table of which failures to repeat.
10
+ */
9
11
  /** The request is malformed: a bad ID or name, an undeclared field, a value out of range. */
10
12
  var Invalid = class extends Schema.TaggedError()("Invalid", { message: Schema.String }, { httpApiStatus: 400 }) {
11
13
  get retryable() {
@@ -42,15 +44,15 @@ var Capacity = class extends Schema.TaggedError()("Capacity", { message: Schema.
42
44
  };
43
45
  /**
44
46
  * The client couldn't reach the host, or lost its reply. Only the client library produces
45
- * it. `access` is the access of the action that met it: a mutation's request may have
46
- * reached the host and run, so it is never retryable.
47
+ * it. `readOnly` is that of the action that met it: a mutation's request may have reached
48
+ * the host and run, so it is never retryable.
47
49
  */
48
50
  var Unavailable = class extends Schema.TaggedError()("Unavailable", {
49
51
  message: Schema.String,
50
- access: Schema.Literals(["read", "write"])
52
+ readOnly: Schema.Boolean
51
53
  }) {
52
54
  get retryable() {
53
- return this.access === "read";
55
+ return this.readOnly;
54
56
  }
55
57
  };
56
58
  var Internal = class extends Schema.TaggedError()("Internal", { message: Schema.String }, { httpApiStatus: 500 }) {
@@ -58,7 +60,7 @@ var Internal = class extends Schema.TaggedError()("Internal", { message: Schema.
58
60
  return false;
59
61
  }
60
62
  };
61
- /** What a host answers with; every action group declares these. */
63
+ /** What a host answers with; every action declares these. */
62
64
  const hostErrors = [
63
65
  Invalid,
64
66
  NotFound,
@@ -127,7 +129,7 @@ const formatId = (host, name) => {
127
129
  };
128
130
  //#endregion
129
131
  //#region package.json
130
- var version$1 = "0.12.2";
132
+ var version$1 = "0.14.0";
131
133
  //#endregion
132
134
  //#region src/resources.ts
133
135
  /** The resources a host reports: machines, checkpoints and the host itself. */
@@ -223,6 +225,28 @@ const Host = Schema.Struct({
223
225
  runtimeVersion: Schema.String,
224
226
  bases: Schema.Array(Schema.String)
225
227
  }).annotate({ identifier: "Host" });
228
+ /**
229
+ * One limit a host's `Capacity` refusals come from, and how much of it is in use, counted as
230
+ * the refusal counts it, so `used` needn't match the host's own machines. Read from the runtime,
231
+ * never stored.
232
+ */
233
+ const Limit = Schema.Struct({
234
+ host: HostId,
235
+ /**
236
+ * `ramMib`: smolvm's RAM budget. `runningVms`: Tart's, Apple's two VMs per Mac.
237
+ * `activeSandboxes` and the `starts` of each rolling window: the boat account's.
238
+ */
239
+ resource: Schema.Literals([
240
+ "ramMib",
241
+ "runningVms",
242
+ "activeSandboxes",
243
+ "startsPerMinute",
244
+ "startsPerHour",
245
+ "startsPerDay"
246
+ ]),
247
+ limit: Schema.Int,
248
+ used: Schema.Int
249
+ }).annotate({ identifier: "Limit" });
226
250
  /** A setup script and how long it may run. Nothing logs the script: it can carry secrets. */
227
251
  const Setup = Schema.Struct({
228
252
  script: Schema.String,
@@ -270,24 +294,11 @@ const Profile = Schema.Struct({
270
294
  //#endregion
271
295
  //#region src/api.ts
272
296
  /**
273
- * The host API: three effect-actions groups, served as JSON POST routes under `/api`.
274
- * A mutation replies when its action has finished.
297
+ * The host API: one effect-actions binding, each action a JSON POST route at `/api/<action>`.
298
+ * A mutation replies when its action has finished. Every action is public: a host listens
299
+ * only on the tailnet or loopback.
275
300
  */
276
301
  /**
277
- * Without a policy, effect-actions answers undeclared or malformed input with an empty 400.
278
- * Schema issues never carry the rejected values, so a setup script never reaches a message.
279
- */
280
- const schemaError = {
281
- invalid: {
282
- schema: Invalid,
283
- make: (failure) => new Invalid({ message: `the request doesn't match the action's input: ${failure.cause.message}` })
284
- },
285
- internal: {
286
- schema: Internal,
287
- make: () => new Internal({ message: "the host's reply did not encode" })
288
- }
289
- };
290
- /**
291
302
  * How long a client waits for a read's reply from one host, unless it sets its own. A host
292
303
  * bounds its own reads of runtime state under it, so a list answers in time.
293
304
  */
@@ -304,89 +315,111 @@ const FromMachine = Schema.Struct({
304
315
  machine: Id,
305
316
  name: Name
306
317
  });
307
- const MachineGroup = ActionGroup.make({
308
- name: "machine",
309
- errors: hostErrors,
310
- schemaError
311
- }, Action.make("list", {
312
- description: "List the host's machines.",
313
- success: Schema.Array(Machine),
314
- access: "read"
315
- }), Action.make("get", {
316
- description: "Read one machine.",
317
- input: ById,
318
- success: Machine,
319
- access: "read"
320
- }), Action.make("create", {
321
- description: "Create a machine from a base, run its setup once, and prepare it.",
322
- input: CreateRequest,
323
- success: Machine,
324
- access: "write"
325
- }), Action.make("start", {
326
- description: "Start a machine. On a running machine, run preparation again.",
327
- input: ById,
328
- success: Machine,
329
- access: "write"
330
- }), Action.make("stop", {
331
- description: "Stop a machine. A stopped machine stays stopped, and the stop is still its last action.",
332
- input: ById,
333
- success: Machine,
334
- access: "write"
335
- }), Action.make("delete", {
336
- description: "Delete a machine and everything native it owns.",
337
- input: ById,
338
- success: Schema.Void,
339
- access: "write"
340
- }), Action.make("fork", {
341
- description: "Copy a machine to a new name on the same host.",
342
- input: FromMachine,
343
- success: Machine,
344
- access: "write"
345
- }), Action.make("restore", {
346
- description: "Create a machine on the checkpoint's host from that checkpoint.",
347
- input: Schema.Struct({
348
- checkpoint: Id,
349
- name: Name
318
+ /**
319
+ * What every action shares, by whether it reads or changes the host. Every action declares
320
+ * `hostErrors`, so a client decodes the `Invalid` the host's version check answers with.
321
+ */
322
+ const read = {
323
+ caller: Action.Anyone,
324
+ error: hostErrors,
325
+ readOnly: true
326
+ };
327
+ const write = {
328
+ caller: Action.Anyone,
329
+ error: hostErrors,
330
+ readOnly: false
331
+ };
332
+ const Http = ActionHttp.make([
333
+ Action.make("listMachines", {
334
+ ...read,
335
+ description: "List the host's machines.",
336
+ success: Schema.Array(Machine)
350
337
  }),
351
- success: Machine,
352
- access: "write"
353
- }));
354
- const CheckpointGroup = ActionGroup.make({
355
- name: "checkpoint",
356
- errors: hostErrors,
357
- schemaError
358
- }, Action.make("list", {
359
- description: "List the host's checkpoints.",
360
- success: Schema.Array(Checkpoint),
361
- access: "read"
362
- }), Action.make("get", {
363
- description: "Read one checkpoint.",
364
- input: ById,
365
- success: Checkpoint,
366
- access: "read"
367
- }), Action.make("capture", {
368
- 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.",
369
- input: FromMachine,
370
- success: Checkpoint,
371
- access: "write"
372
- }), Action.make("delete", {
373
- description: "Delete a checkpoint.",
374
- input: ById,
375
- success: Schema.Void,
376
- access: "write"
377
- }));
378
- const HostGroup = ActionGroup.make({
379
- name: "host",
380
- errors: hostErrors,
381
- schemaError
382
- }, Action.make("get", {
383
- description: "Read the host: its runtime, versions and bases.",
384
- success: Host,
385
- access: "read"
386
- }));
387
- const Http = ActionHttp.make({ apiPath: "/api" }, MachineGroup, CheckpointGroup, HostGroup);
338
+ Action.make("getMachine", {
339
+ ...read,
340
+ description: "Read one machine.",
341
+ input: ById,
342
+ success: Machine
343
+ }),
344
+ Action.make("createMachine", {
345
+ ...write,
346
+ description: "Create a machine from a base, run its setup once, and prepare it.",
347
+ input: CreateRequest,
348
+ success: Machine
349
+ }),
350
+ Action.make("startMachine", {
351
+ ...write,
352
+ description: "Start a machine. On a running machine, run preparation again.",
353
+ input: ById,
354
+ success: Machine
355
+ }),
356
+ Action.make("stopMachine", {
357
+ ...write,
358
+ description: "Stop a machine. A stopped machine stays stopped, and the stop is still its last action.",
359
+ input: ById,
360
+ success: Machine
361
+ }),
362
+ Action.make("deleteMachine", {
363
+ ...write,
364
+ description: "Delete a machine and everything native it owns.",
365
+ input: ById
366
+ }),
367
+ Action.make("forkMachine", {
368
+ ...write,
369
+ description: "Copy a machine to a new name on the same host.",
370
+ input: FromMachine,
371
+ success: Machine
372
+ }),
373
+ Action.make("restoreMachine", {
374
+ ...write,
375
+ description: "Create a machine on the checkpoint's host from that checkpoint.",
376
+ input: Schema.Struct({
377
+ checkpoint: Id,
378
+ name: Name
379
+ }),
380
+ success: Machine
381
+ }),
382
+ Action.make("listCheckpoints", {
383
+ ...read,
384
+ description: "List the host's checkpoints.",
385
+ success: Schema.Array(Checkpoint)
386
+ }),
387
+ Action.make("getCheckpoint", {
388
+ ...read,
389
+ description: "Read one checkpoint.",
390
+ input: ById,
391
+ success: Checkpoint
392
+ }),
393
+ Action.make("captureCheckpoint", {
394
+ ...write,
395
+ 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.",
396
+ input: FromMachine,
397
+ success: Checkpoint
398
+ }),
399
+ Action.make("deleteCheckpoint", {
400
+ ...write,
401
+ description: "Delete a checkpoint.",
402
+ input: ById
403
+ }),
404
+ Action.make("getHost", {
405
+ ...read,
406
+ description: "Read the host: its runtime, versions and bases.",
407
+ success: Host
408
+ }),
409
+ Action.make("getCapacity", {
410
+ ...read,
411
+ description: "Read the host's limits and how much of each is in use. It fails when the runtime can't be read.",
412
+ success: Schema.Array(Limit)
413
+ })
414
+ ], { prefix: "/api" });
388
415
  //#endregion
389
416
  //#region src/client.ts
417
+ /**
418
+ * The client library: a host list in placement order, routing by ID, list fan-out and
419
+ * create placement. Nothing here retries: a mutation whose reply is lost, or that outlasts
420
+ * the client's mutation timeout, is `Unavailable`, and the caller reads the resource to see
421
+ * what happened.
422
+ */
390
423
  var client_exports = /* @__PURE__ */ __exportAll({
391
424
  Client: () => Client,
392
425
  HostEntry: () => HostEntry,
@@ -400,28 +433,26 @@ const HostEntry = Schema.Struct({
400
433
  var Client = class extends Context.Service()("@gjermundgaraba/clankerbox-sdk/Client") {};
401
434
  /**
402
435
  * A client for one host. Every request carries the SDK's version, which the host checks
403
- * against its own. Its reply decoding is the only step `transformResponse` wraps, so a reply
404
- * that doesn't decode is `Internal` here, and a `SchemaError` that reaches `settle` came from
405
- * encoding the request.
436
+ * against its own. Input that doesn't encode fails as `InvalidInput` before anything is
437
+ * sent, so a `SchemaError` that reaches `settle` is a reply that didn't decode.
406
438
  */
407
- const makeHostApi = (entry) => HttpApiClient.make(Http.api, {
439
+ const makeHostApi = (entry) => ActionHttp.client(Http, {
408
440
  baseUrl: entry.url,
409
- transformClient: HttpClient.mapRequest(HttpClientRequest.setHeader(versionHeader, version)),
410
- transformResponse: (reply) => Effect.mapError(reply, (error) => Schema.isSchemaError(error) ? new Internal({ message: `host ${entry.id}'s reply didn't decode: ${error.message}` }) : error)
441
+ transformClient: HttpClient.mapRequest(HttpClientRequest.setHeader(versionHeader, version))
411
442
  });
412
- /** Every action's contract, keyed `<group>.<action>`: a call reads its access from its action. */
413
- const actions = ActionGroup.contracts(MachineGroup, CheckpointGroup, HostGroup);
443
+ /** Every action's contract, by name: a call's timeout and retry follow its `readOnly`. */
444
+ const actions = Action.byName(Http.actions);
414
445
  const causeDetail = (error) => error.cause instanceof Error ? error.cause.message : error.message;
415
446
  /**
416
447
  * No reply came: the connection failed or dropped, or the timeout passed. A mutation's
417
448
  * request may or may not have reached its host, so it may have run.
418
449
  */
419
- const unanswered = (context, detail) => context.access === "read" ? new Unavailable({
450
+ const unanswered = (context, detail) => context.readOnly ? new Unavailable({
420
451
  message: `host ${context.host.id} (${context.host.url}) didn't answer ${context.action}: ${detail}`,
421
- access: "read"
452
+ readOnly: context.readOnly
422
453
  }) : new Unavailable({
423
454
  message: `no reply from host ${context.host.id} to ${context.action} (${detail}); the action may have run: read ${context.target ?? "the resource"} to see`,
424
- access: "write"
455
+ readOnly: context.readOnly
425
456
  });
426
457
  /** Bounds the wait for the reply; the clock starts when the request is sent. */
427
458
  const bounded = (call, context) => {
@@ -431,10 +462,18 @@ const bounded = (call, context) => {
431
462
  orElse: () => Effect.fail(unanswered(context, `timed out after ${Duration.format(timeout)}`))
432
463
  });
433
464
  };
434
- const settle = (call, context) => bounded(call, context).pipe(Effect.catchTag("HttpClientError", (error) => Effect.fail(Match.value(error.reason).pipe(Match.tag("TransportError", () => unanswered(context, causeDetail(error))), Match.when({
435
- _tag: "DecodeError",
436
- cause: (cause) => cause !== void 0 && !(cause instanceof SyntaxError)
437
- }, () => unanswered(context, causeDetail(error))), Match.orElse(() => new Internal({ message: `host ${context.host.id} answered ${context.action} unexpectedly: ${error.message}` }))))), Effect.catchTag("SchemaError", (error) => Effect.fail(new Invalid({ message: `${context.action}: the request doesn't match the action's input: ${error.message}` }))));
465
+ /** The host answered with something the call doesn't expect. */
466
+ const unexpected = (context, error) => new Internal({ message: `host ${context.host.id} answered ${context.action} unexpectedly: ${error.message}` });
467
+ const settle = (call, context) => bounded(call, context).pipe(Effect.catchTags({
468
+ HttpClientError: (error) => Effect.fail(Match.value(error.reason).pipe(Match.tag("TransportError", () => unanswered(context, causeDetail(error))), Match.when({
469
+ _tag: "DecodeError",
470
+ cause: (cause) => cause !== void 0 && !(cause instanceof SyntaxError)
471
+ }, () => unanswered(context, causeDetail(error))), Match.orElse(() => unexpected(context, error)))),
472
+ InvalidInput: (error) => Effect.fail(new Invalid({ message: `${context.action}: the request doesn't match the action's input: ${error.message}` })),
473
+ SchemaError: (error) => Effect.fail(new Internal({ message: `host ${context.host.id}'s reply didn't decode: ${error.message}` })),
474
+ Unauthenticated: (error) => Effect.fail(unexpected(context, error)),
475
+ Forbidden: (error) => Effect.fail(unexpected(context, error))
476
+ }));
438
477
  /** A host this client can use: it calls itself by its entry's ID. */
439
478
  const checkHost = (entry, host) => host.id === entry.id ? Effect.succeed(host) : Effect.fail(new Invalid({ message: `host ${entry.id} (${entry.url}) calls itself ${host.id}; its entry in the host list must use that ID` }));
440
479
  /** Every entry is checked here, so a call never meets a malformed URL. */
@@ -453,23 +492,18 @@ const make = (hosts, options) => Effect.gen(function* () {
453
492
  api
454
493
  })));
455
494
  const routes = new Map(routed.map((route) => [route.entry.id, route]));
456
- /** How long a call waits for its reply, by its action's access. */
457
- const bounds = {
458
- read: options?.readTimeout ?? readTimeout,
459
- write: options?.timeout
460
- };
461
495
  const route = (host) => {
462
496
  const found = routes.get(host);
463
497
  return found === void 0 ? Effect.fail(new Invalid({ message: `host ${host} isn't in the host list` })) : Effect.succeed(found);
464
498
  };
465
499
  /**
466
- * Sends one call to one host, bounded by its action's access. `target` is the ID to read
467
- * when a mutation's reply is lost.
500
+ * Sends one call to one host, bounded by the read or the mutation timeout. `target` is the
501
+ * ID to read when a mutation's reply is lost.
468
502
  */
469
- const ask = ({ entry, api }, contract, action, call, target) => settle(call(api), {
503
+ const ask = ({ entry, api }, { readOnly }, action, call, target) => settle(call(api), {
470
504
  host: entry,
471
- timeout: bounds[contract.access],
472
- access: contract.access,
505
+ timeout: readOnly ? options?.readTimeout ?? readTimeout : options?.timeout,
506
+ readOnly,
473
507
  action,
474
508
  target
475
509
  });
@@ -502,13 +536,13 @@ const make = (hosts, options) => Effect.gen(function* () {
502
536
  * Reads a host. IDs route by its entry's ID, so a host that calls itself something else
503
537
  * fails rather than being placed on.
504
538
  */
505
- const readHost = (route) => ask(route, actions["host.get"], "get host", (api) => Effect.flatMap(api.host.get({ payload: {} }), (host) => checkHost(route.entry, host)));
539
+ const readHost = (route) => ask(route, actions.getHost, "get host", (api) => Effect.flatMap(api.getHost(), (host) => checkHost(route.entry, host)));
506
540
  const createOn = (host, name, spec) => Effect.gen(function* () {
507
541
  const id = yield* formatId(host, name);
508
- return yield* ask(yield* route(host), actions["machine.create"], `create ${id}`, (api) => api.machine.create({ payload: {
542
+ return yield* ask(yield* route(host), actions.createMachine, `create ${id}`, (api) => api.createMachine({
509
543
  ...spec,
510
544
  id
511
- } }), id);
545
+ }), id);
512
546
  });
513
547
  /**
514
548
  * Asks every host at once and goes through the answers in list order: the first host
@@ -538,7 +572,7 @@ const make = (hosts, options) => Effect.gen(function* () {
538
572
  const message = `no host offers base ${base}: ${misses.join("; ")}`;
539
573
  return yield* noReply ? new Unavailable({
540
574
  message,
541
- access: "read"
575
+ readOnly: true
542
576
  }) : new Precondition({ message });
543
577
  }).pipe(Effect.scoped);
544
578
  const create = (name, spec, options) => Effect.gen(function* () {
@@ -550,28 +584,29 @@ const make = (hosts, options) => Effect.gen(function* () {
550
584
  const sibling = (source, name) => Effect.flatMap(parseId(source), ({ host }) => formatId(host, name));
551
585
  return {
552
586
  hosts: gather((route) => Effect.map(readHost(route), (host) => [host])),
553
- machines: gather((route) => ask(route, actions["machine.list"], "list machines", (api) => api.machine.list({ payload: {} }))),
554
- checkpoints: gather((route) => ask(route, actions["checkpoint.list"], "list checkpoints", (api) => api.checkpoint.list({ payload: {} }))),
555
- machine: (id) => byId(id, actions["machine.get"], `get ${id}`, (api) => api.machine.get({ payload: { id } })),
556
- checkpoint: (id) => byId(id, actions["checkpoint.get"], `get ${id}`, (api) => api.checkpoint.get({ payload: { id } })),
587
+ machines: gather((route) => ask(route, actions.listMachines, "list machines", (api) => api.listMachines())),
588
+ checkpoints: gather((route) => ask(route, actions.listCheckpoints, "list checkpoints", (api) => api.listCheckpoints())),
589
+ capacity: gather((route) => ask(route, actions.getCapacity, "get capacity", (api) => api.getCapacity())),
590
+ machine: (id) => byId(id, actions.getMachine, `get ${id}`, (api) => api.getMachine({ id })),
591
+ checkpoint: (id) => byId(id, actions.getCheckpoint, `get ${id}`, (api) => api.getCheckpoint({ id })),
557
592
  create,
558
- start: (id) => byId(id, actions["machine.start"], `start ${id}`, (api) => api.machine.start({ payload: { id } })),
559
- stop: (id) => byId(id, actions["machine.stop"], `stop ${id}`, (api) => api.machine.stop({ payload: { id } })),
560
- delete: (id) => byId(id, actions["machine.delete"], `delete ${id}`, (api) => api.machine.delete({ payload: { id } })),
561
- fork: (machine, name) => Effect.flatMap(sibling(machine, name), (made) => byId(machine, actions["machine.fork"], `fork ${machine} to ${made}`, (api) => api.machine.fork({ payload: {
593
+ start: (id) => byId(id, actions.startMachine, `start ${id}`, (api) => api.startMachine({ id })),
594
+ stop: (id) => byId(id, actions.stopMachine, `stop ${id}`, (api) => api.stopMachine({ id })),
595
+ delete: (id) => byId(id, actions.deleteMachine, `delete ${id}`, (api) => api.deleteMachine({ id })),
596
+ fork: (machine, name) => Effect.flatMap(sibling(machine, name), (made) => byId(machine, actions.forkMachine, `fork ${machine} to ${made}`, (api) => api.forkMachine({
562
597
  machine,
563
598
  name
564
- } }), made)),
565
- restore: (checkpoint, name) => Effect.flatMap(sibling(checkpoint, name), (made) => byId(checkpoint, actions["machine.restore"], `restore ${checkpoint} to ${made}`, (api) => api.machine.restore({ payload: {
599
+ }), made)),
600
+ restore: (checkpoint, name) => Effect.flatMap(sibling(checkpoint, name), (made) => byId(checkpoint, actions.restoreMachine, `restore ${checkpoint} to ${made}`, (api) => api.restoreMachine({
566
601
  checkpoint,
567
602
  name
568
- } }), made)),
569
- capture: (machine, name) => Effect.flatMap(sibling(machine, name), (made) => byId(machine, actions["checkpoint.capture"], `capture ${machine} to ${made}`, (api) => api.checkpoint.capture({ payload: {
603
+ }), made)),
604
+ capture: (machine, name) => Effect.flatMap(sibling(machine, name), (made) => byId(machine, actions.captureCheckpoint, `capture ${machine} to ${made}`, (api) => api.captureCheckpoint({
570
605
  machine,
571
606
  name
572
- } }), made)),
573
- deleteCheckpoint: (id) => byId(id, actions["checkpoint.delete"], `delete ${id}`, (api) => api.checkpoint.delete({ payload: { id } }))
607
+ }), made)),
608
+ deleteCheckpoint: (id) => byId(id, actions.deleteCheckpoint, `delete ${id}`, (api) => api.deleteCheckpoint({ id }))
574
609
  };
575
610
  });
576
611
  //#endregion
577
- export { Conflict as A, HostId as C, parseId as D, formatId as E, Invalid as F, NotFound as I, Precondition as L, ErrorTag as M, HostErrorTag as N, parseName as O, Internal as P, Unavailable as R, version as S, Name as T, Profile as _, HostGroup as a, SshEndpoint as b, readTimeout as c, ActionRecord as d, Checkpoint as f, MachineSpec as g, Machine as h, CheckpointGroup as i, ConflictKind as j, Capacity as k, versionHeader as l, Host as m, client_exports as n, Http as o, CreateRequest as p, make as r, MachineGroup as s, Client as t, ActionName as u, Runtime as v, Id as w, release as x, Setup as y, hostErrors as z };
612
+ export { ErrorTag as A, Name as C, Capacity as D, parseName as E, Precondition as F, Unavailable as I, hostErrors as L, Internal as M, Invalid as N, Conflict as O, NotFound as P, Id as S, parseId as T, Setup as _, readTimeout as a, version as b, ActionRecord as c, Host as d, Limit as f, Runtime as g, Profile as h, Http as i, HostErrorTag as j, ConflictKind as k, Checkpoint as l, MachineSpec as m, client_exports as n, versionHeader as o, Machine as p, make as r, ActionName as s, Client as t, CreateRequest as u, SshEndpoint as v, formatId as w, HostId as x, release as y };
package/dist/index.d.mts CHANGED
@@ -1,6 +1,5 @@
1
- import { A as hostErrors, C as HostError, D as NotFound, E as Invalid, O as Precondition, S as ErrorTag, T as Internal, _ as version, a as ActionName, b as Conflict, c as CreateRequest, d as MachineSpec, f as Profile, g as release, h as SshEndpoint, i as client_d_exports, k as Unavailable, l as Host, m as Setup, o as ActionRecord, p as Runtime, s as Checkpoint, u as Machine, v as Capacity, w as HostErrorTag, x as ConflictKind, y as ClankerboxError } from "./client-C6ll48AB.mjs";
1
+ import { A as Unavailable, C as ErrorTag, D as Invalid, E as Internal, O as NotFound, S as ConflictKind, T as HostErrorTag, _ as release, a as ActionName, b as ClankerboxError, c as CreateRequest, d as Machine, f as MachineSpec, g as SshEndpoint, h as Setup, i as client_d_exports, j as hostErrors, k as Precondition, l as Host, m as Runtime, o as ActionRecord, p as Profile, s as Checkpoint, u as Limit, v as version, w as HostError, x as Conflict, y as Capacity } from "./client-D63Z17YP.mjs";
2
2
  import * as Action from "@gjermundgaraba/effect-actions/Action";
3
- import * as ActionGroup from "@gjermundgaraba/effect-actions/ActionGroup";
4
3
  import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
5
4
  import { Duration, Effect, FileSystem, Path, Schema } from "effect";
6
5
  import { ChildProcessSpawner } from "effect/process";
@@ -16,7 +15,7 @@ export declare const readTimeout: Duration.Duration;
16
15
  * anything.
17
16
  */
18
17
  export declare const versionHeader = "clankerbox-version";
19
- export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action.Action<"list", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
18
+ export declare const Http: ActionHttp.Binding<readonly [Action.Action<"listMachines", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
20
19
  readonly id: Schema.String;
21
20
  readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
22
21
  readonly createdAt: Schema.DateTimeUtcFromString;
@@ -39,7 +38,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
39
38
  readonly port: Schema.Int;
40
39
  }>>;
41
40
  readonly hostKey: Schema.optionalKey<Schema.String>;
42
- }>>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"get", Schema.Struct<{
41
+ }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"getMachine", Schema.Struct<{
43
42
  readonly id: Schema.String;
44
43
  }>, Schema.Struct<{
45
44
  readonly id: Schema.String;
@@ -64,7 +63,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
64
63
  readonly port: Schema.Int;
65
64
  }>>;
66
65
  readonly hostKey: Schema.optionalKey<Schema.String>;
67
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"create", Schema.Struct<{
66
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"createMachine", Schema.Struct<{
68
67
  readonly base: Schema.String;
69
68
  readonly cpu: Schema.Int;
70
69
  readonly ramMib: Schema.Int;
@@ -98,7 +97,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
98
97
  readonly port: Schema.Int;
99
98
  }>>;
100
99
  readonly hostKey: Schema.optionalKey<Schema.String>;
101
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"start", Schema.Struct<{
100
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"startMachine", Schema.Struct<{
102
101
  readonly id: Schema.String;
103
102
  }>, Schema.Struct<{
104
103
  readonly id: Schema.String;
@@ -123,7 +122,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
123
122
  readonly port: Schema.Int;
124
123
  }>>;
125
124
  readonly hostKey: Schema.optionalKey<Schema.String>;
126
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"stop", Schema.Struct<{
125
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"stopMachine", Schema.Struct<{
127
126
  readonly id: Schema.String;
128
127
  }>, Schema.Struct<{
129
128
  readonly id: Schema.String;
@@ -148,9 +147,9 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
148
147
  readonly port: Schema.Int;
149
148
  }>>;
150
149
  readonly hostKey: Schema.optionalKey<Schema.String>;
151
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"delete", Schema.Struct<{
150
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"deleteMachine", Schema.Struct<{
152
151
  readonly id: Schema.String;
153
- }>, Schema.Void, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"fork", Schema.Struct<{
152
+ }>, Schema.Void, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"forkMachine", Schema.Struct<{
154
153
  readonly machine: Schema.String;
155
154
  readonly name: Schema.String;
156
155
  }>, Schema.Struct<{
@@ -176,7 +175,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
176
175
  readonly port: Schema.Int;
177
176
  }>>;
178
177
  readonly hostKey: Schema.optionalKey<Schema.String>;
179
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"restore", Schema.Struct<{
178
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"restoreMachine", Schema.Struct<{
180
179
  readonly checkpoint: Schema.String;
181
180
  readonly name: Schema.String;
182
181
  }>, Schema.Struct<{
@@ -202,8 +201,7 @@ export declare const MachineGroup: ActionGroup.Group<"machine", readonly [Action
202
201
  readonly port: Schema.Int;
203
202
  }>>;
204
203
  readonly hostKey: Schema.optionalKey<Schema.String>;
205
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>], typeof Invalid | typeof Internal>;
206
- export declare const CheckpointGroup: ActionGroup.Group<"checkpoint", readonly [Action.Action<"list", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
204
+ }>, 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<{
207
205
  readonly id: Schema.String;
208
206
  readonly createdAt: Schema.DateTimeUtcFromString;
209
207
  readonly machine: Schema.String;
@@ -221,7 +219,7 @@ export declare const CheckpointGroup: ActionGroup.Group<"checkpoint", readonly [
221
219
  readonly message: Schema.String;
222
220
  }>>;
223
221
  }>;
224
- }>>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"get", Schema.Struct<{
222
+ }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"getCheckpoint", Schema.Struct<{
225
223
  readonly id: Schema.String;
226
224
  }>, Schema.Struct<{
227
225
  readonly id: Schema.String;
@@ -241,7 +239,7 @@ export declare const CheckpointGroup: ActionGroup.Group<"checkpoint", readonly [
241
239
  readonly message: Schema.String;
242
240
  }>>;
243
241
  }>;
244
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"capture", Schema.Struct<{
242
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>, Action.Action<"captureCheckpoint", Schema.Struct<{
245
243
  readonly machine: Schema.String;
246
244
  readonly name: Schema.String;
247
245
  }>, Schema.Struct<{
@@ -262,270 +260,20 @@ export declare const CheckpointGroup: ActionGroup.Group<"checkpoint", readonly [
262
260
  readonly message: Schema.String;
263
261
  }>>;
264
262
  }>;
265
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"delete", Schema.Struct<{
263
+ }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], false, typeof Action.Anyone>, Action.Action<"deleteCheckpoint", Schema.Struct<{
266
264
  readonly id: Schema.String;
267
- }>, Schema.Void, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>], typeof Invalid | typeof Internal>;
268
- export declare const HostGroup: ActionGroup.Group<"host", readonly [Action.Action<"get", Schema.$Record<Schema.String, Schema.Never>, Schema.Struct<{
265
+ }>, 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<{
269
266
  readonly id: Schema.String;
270
267
  readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
271
268
  readonly version: Schema.String;
272
269
  readonly runtimeVersion: Schema.String;
273
270
  readonly bases: Schema.$Array<Schema.String>;
274
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>], typeof Invalid | typeof Internal>;
275
- export declare const Http: ActionHttp.Http<readonly [ActionGroup.Group<"machine", readonly [Action.Action<"list", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
276
- readonly id: Schema.String;
277
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
278
- readonly createdAt: Schema.DateTimeUtcFromString;
279
- readonly base: Schema.String;
280
- readonly profile: Schema.optionalKey<Schema.String>;
281
- readonly cpu: Schema.Int;
282
- readonly ramMib: Schema.Int;
283
- readonly diskGib: Schema.Int;
284
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
285
- readonly action: Schema.Struct<{
286
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
287
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
288
- readonly error: Schema.optionalKey<Schema.Struct<{
289
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
290
- readonly message: Schema.String;
291
- }>>;
292
- }>;
293
- readonly ssh: Schema.optionalKey<Schema.Struct<{
294
- readonly host: Schema.String;
295
- readonly port: Schema.Int;
296
- }>>;
297
- readonly hostKey: Schema.optionalKey<Schema.String>;
298
- }>>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"get", Schema.Struct<{
299
- readonly id: Schema.String;
300
- }>, Schema.Struct<{
301
- readonly id: Schema.String;
302
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
303
- readonly createdAt: Schema.DateTimeUtcFromString;
304
- readonly base: Schema.String;
305
- readonly profile: Schema.optionalKey<Schema.String>;
306
- readonly cpu: Schema.Int;
307
- readonly ramMib: Schema.Int;
308
- readonly diskGib: Schema.Int;
309
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
310
- readonly action: Schema.Struct<{
311
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
312
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
313
- readonly error: Schema.optionalKey<Schema.Struct<{
314
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
315
- readonly message: Schema.String;
316
- }>>;
317
- }>;
318
- readonly ssh: Schema.optionalKey<Schema.Struct<{
319
- readonly host: Schema.String;
320
- readonly port: Schema.Int;
321
- }>>;
322
- readonly hostKey: Schema.optionalKey<Schema.String>;
323
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"create", Schema.Struct<{
324
- readonly base: Schema.String;
325
- readonly cpu: Schema.Int;
326
- readonly ramMib: Schema.Int;
327
- readonly diskGib: Schema.Int;
328
- readonly setup: Schema.optionalKey<Schema.Struct<{
329
- readonly script: Schema.String;
330
- readonly timeoutSeconds: Schema.Int;
331
- }>>;
332
- readonly profile: Schema.optionalKey<Schema.String>;
333
- readonly id: Schema.String;
334
- }>, Schema.Struct<{
335
- readonly id: Schema.String;
336
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
337
- readonly createdAt: Schema.DateTimeUtcFromString;
338
- readonly base: Schema.String;
339
- readonly profile: Schema.optionalKey<Schema.String>;
340
- readonly cpu: Schema.Int;
341
- readonly ramMib: Schema.Int;
342
- readonly diskGib: Schema.Int;
343
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
344
- readonly action: Schema.Struct<{
345
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
346
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
347
- readonly error: Schema.optionalKey<Schema.Struct<{
348
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
349
- readonly message: Schema.String;
350
- }>>;
351
- }>;
352
- readonly ssh: Schema.optionalKey<Schema.Struct<{
353
- readonly host: Schema.String;
354
- readonly port: Schema.Int;
355
- }>>;
356
- readonly hostKey: Schema.optionalKey<Schema.String>;
357
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"start", Schema.Struct<{
358
- readonly id: Schema.String;
359
- }>, Schema.Struct<{
360
- readonly id: Schema.String;
361
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
362
- readonly createdAt: Schema.DateTimeUtcFromString;
363
- readonly base: Schema.String;
364
- readonly profile: Schema.optionalKey<Schema.String>;
365
- readonly cpu: Schema.Int;
366
- readonly ramMib: Schema.Int;
367
- readonly diskGib: Schema.Int;
368
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
369
- readonly action: Schema.Struct<{
370
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
371
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
372
- readonly error: Schema.optionalKey<Schema.Struct<{
373
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
374
- readonly message: Schema.String;
375
- }>>;
376
- }>;
377
- readonly ssh: Schema.optionalKey<Schema.Struct<{
378
- readonly host: Schema.String;
379
- readonly port: Schema.Int;
380
- }>>;
381
- readonly hostKey: Schema.optionalKey<Schema.String>;
382
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"stop", Schema.Struct<{
383
- readonly id: Schema.String;
384
- }>, Schema.Struct<{
385
- readonly id: Schema.String;
386
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
387
- readonly createdAt: Schema.DateTimeUtcFromString;
388
- readonly base: Schema.String;
389
- readonly profile: Schema.optionalKey<Schema.String>;
390
- readonly cpu: Schema.Int;
391
- readonly ramMib: Schema.Int;
392
- readonly diskGib: Schema.Int;
393
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
394
- readonly action: Schema.Struct<{
395
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
396
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
397
- readonly error: Schema.optionalKey<Schema.Struct<{
398
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
399
- readonly message: Schema.String;
400
- }>>;
401
- }>;
402
- readonly ssh: Schema.optionalKey<Schema.Struct<{
403
- readonly host: Schema.String;
404
- readonly port: Schema.Int;
405
- }>>;
406
- readonly hostKey: Schema.optionalKey<Schema.String>;
407
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"delete", Schema.Struct<{
408
- readonly id: Schema.String;
409
- }>, Schema.Void, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"fork", Schema.Struct<{
410
- readonly machine: Schema.String;
411
- readonly name: Schema.String;
412
- }>, Schema.Struct<{
413
- readonly id: Schema.String;
414
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
415
- readonly createdAt: Schema.DateTimeUtcFromString;
416
- readonly base: Schema.String;
417
- readonly profile: Schema.optionalKey<Schema.String>;
418
- readonly cpu: Schema.Int;
419
- readonly ramMib: Schema.Int;
420
- readonly diskGib: Schema.Int;
421
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
422
- readonly action: Schema.Struct<{
423
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
424
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
425
- readonly error: Schema.optionalKey<Schema.Struct<{
426
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
427
- readonly message: Schema.String;
428
- }>>;
429
- }>;
430
- readonly ssh: Schema.optionalKey<Schema.Struct<{
431
- readonly host: Schema.String;
432
- readonly port: Schema.Int;
433
- }>>;
434
- readonly hostKey: Schema.optionalKey<Schema.String>;
435
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"restore", Schema.Struct<{
436
- readonly checkpoint: Schema.String;
437
- readonly name: Schema.String;
438
- }>, Schema.Struct<{
439
- readonly id: Schema.String;
440
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
441
- readonly createdAt: Schema.DateTimeUtcFromString;
442
- readonly base: Schema.String;
443
- readonly profile: Schema.optionalKey<Schema.String>;
444
- readonly cpu: Schema.Int;
445
- readonly ramMib: Schema.Int;
446
- readonly diskGib: Schema.Int;
447
- readonly state: Schema.Literals<readonly ["running", "stopped", "missing", "unknown"]>;
448
- readonly action: Schema.Struct<{
449
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
450
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
451
- readonly error: Schema.optionalKey<Schema.Struct<{
452
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
453
- readonly message: Schema.String;
454
- }>>;
455
- }>;
456
- readonly ssh: Schema.optionalKey<Schema.Struct<{
457
- readonly host: Schema.String;
458
- readonly port: Schema.Int;
459
- }>>;
460
- readonly hostKey: Schema.optionalKey<Schema.String>;
461
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>], typeof Invalid | typeof Internal>, ActionGroup.Group<"checkpoint", readonly [Action.Action<"list", Schema.$Record<Schema.String, Schema.Never>, Schema.$Array<Schema.Struct<{
462
- readonly id: Schema.String;
463
- readonly createdAt: Schema.DateTimeUtcFromString;
464
- readonly machine: Schema.String;
465
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
466
- readonly base: Schema.String;
467
- readonly profile: Schema.optionalKey<Schema.String>;
468
- readonly cpu: Schema.Int;
469
- readonly ramMib: Schema.Int;
470
- readonly diskGib: Schema.Int;
471
- readonly action: Schema.Struct<{
472
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
473
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
474
- readonly error: Schema.optionalKey<Schema.Struct<{
475
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
476
- readonly message: Schema.String;
477
- }>>;
478
- }>;
479
- }>>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"get", Schema.Struct<{
480
- readonly id: Schema.String;
481
- }>, Schema.Struct<{
482
- readonly id: Schema.String;
483
- readonly createdAt: Schema.DateTimeUtcFromString;
484
- readonly machine: Schema.String;
485
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
486
- readonly base: Schema.String;
487
- readonly profile: Schema.optionalKey<Schema.String>;
488
- readonly cpu: Schema.Int;
489
- readonly ramMib: Schema.Int;
490
- readonly diskGib: Schema.Int;
491
- readonly action: Schema.Struct<{
492
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
493
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
494
- readonly error: Schema.optionalKey<Schema.Struct<{
495
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
496
- readonly message: Schema.String;
497
- }>>;
498
- }>;
499
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>, Action.Action<"capture", Schema.Struct<{
500
- readonly machine: Schema.String;
501
- readonly name: Schema.String;
502
- }>, Schema.Struct<{
503
- readonly id: Schema.String;
504
- readonly createdAt: Schema.DateTimeUtcFromString;
505
- readonly machine: Schema.String;
506
- readonly kind: Schema.Literals<readonly ["ram", "disk"]>;
507
- readonly base: Schema.String;
508
- readonly profile: Schema.optionalKey<Schema.String>;
509
- readonly cpu: Schema.Int;
510
- readonly ramMib: Schema.Int;
511
- readonly diskGib: Schema.Int;
512
- readonly action: Schema.Struct<{
513
- readonly name: Schema.Literals<readonly ["create", "start", "stop", "delete", "fork", "restore", "capture"]>;
514
- readonly status: Schema.Literals<readonly ["running", "failed", "done"]>;
515
- readonly error: Schema.optionalKey<Schema.Struct<{
516
- readonly tag: Schema.Literals<("Capacity" | "Conflict" | "Internal" | "Invalid" | "NotFound" | "Precondition")[]>;
517
- readonly message: Schema.String;
518
- }>>;
519
- }>;
520
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>, Action.Action<"delete", Schema.Struct<{
521
- readonly id: Schema.String;
522
- }>, Schema.Void, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "write", undefined>], typeof Invalid | typeof Internal>, ActionGroup.Group<"host", readonly [Action.Action<"get", Schema.$Record<Schema.String, Schema.Never>, Schema.Struct<{
523
- readonly id: Schema.String;
524
- readonly runtime: Schema.Literals<readonly ["smolvm", "tart", "boat"]>;
525
- readonly version: Schema.String;
526
- readonly runtimeVersion: Schema.String;
527
- readonly bases: Schema.$Array<Schema.String>;
528
- }>, readonly [typeof Invalid, typeof NotFound, typeof Conflict, typeof Precondition, typeof Capacity, typeof Internal], "read", undefined>], typeof Invalid | typeof Internal>], []>;
271
+ }>, 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<{
272
+ readonly host: Schema.String;
273
+ readonly resource: Schema.Literals<readonly ["ramMib", "runningVms", "activeSandboxes", "startsPerMinute", "startsPerHour", "startsPerDay"]>;
274
+ readonly limit: Schema.Int;
275
+ readonly used: Schema.Int;
276
+ }>>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>], [], undefined>;
529
277
  //#endregion
530
278
  //#region src/ids.d.ts
531
279
  /** A host's part of every ID it holds. */
@@ -568,4 +316,4 @@ export declare const packRecipe: (directory: string) => Effect.Effect<string, In
568
316
  /** Reads a setup: a script file's text, or a recipe directory packed into one script. */
569
317
  export declare const readSetup: (path: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner>;
570
318
  //#endregion
571
- export { ActionName, ActionRecord, Capacity, Checkpoint, ClankerboxError, client_d_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostError, HostErrorTag, Internal, Invalid, Machine, MachineSpec, NotFound, Precondition, Profile, Runtime, Setup, SshEndpoint, Unavailable, hostErrors, release, version };
319
+ export { ActionName, ActionRecord, Capacity, Checkpoint, ClankerboxError, client_d_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostError, HostErrorTag, Internal, Invalid, Limit, Machine, MachineSpec, NotFound, Precondition, Profile, Runtime, Setup, SshEndpoint, Unavailable, hostErrors, release, version };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Conflict, C as HostId, D as parseId, E as formatId, F as Invalid, I as NotFound, L as Precondition, M as ErrorTag, N as HostErrorTag, O as parseName, P as Internal, R as Unavailable, S as version, T as Name, _ as Profile, a as HostGroup, b as SshEndpoint, c as readTimeout, d as ActionRecord, f as Checkpoint, g as MachineSpec, h as Machine, i as CheckpointGroup, j as ConflictKind, k as Capacity, l as versionHeader, m as Host, n as client_exports, o as Http, p as CreateRequest, s as MachineGroup, u as ActionName, v as Runtime, w as Id, x as release, y as Setup, z as hostErrors } from "./client-DXuiPvxU.mjs";
1
+ import { A as ErrorTag, C as Name, D as Capacity, E as parseName, F as Precondition, I as Unavailable, L as hostErrors, M as Internal, N as Invalid, O as Conflict, P as NotFound, S as Id, T as parseId, _ as Setup, a as readTimeout, b as version, c as ActionRecord, d as Host, f as Limit, g as Runtime, h as Profile, i as Http, j as HostErrorTag, k as ConflictKind, l as Checkpoint, m as MachineSpec, n as client_exports, o as versionHeader, p as Machine, s as ActionName, u as CreateRequest, v as SshEndpoint, w as formatId, x as HostId, y as release } from "./client-DSd3saH0.mjs";
2
2
  import { Effect, FileSystem, Path, Predicate, Schema, Stream } from "effect";
3
3
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
4
4
  //#region src/profile.ts
@@ -103,4 +103,4 @@ const readSetup = (path) => Effect.gen(function* () {
103
103
  return yield* fs.readFileString(path);
104
104
  }).pipe(Effect.catchTag("PlatformError", (error) => Effect.fail(new Invalid({ message: `couldn't read setup ${path}: ${error.message}` }))));
105
105
  //#endregion
106
- export { ActionName, ActionRecord, Capacity, Checkpoint, CheckpointGroup, client_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostErrorTag, HostGroup, HostId, Http, Id, Internal, Invalid, Machine, MachineGroup, MachineSpec, Name, NotFound, Precondition, Profile, Runtime, Setup, SshEndpoint, Unavailable, formatId, hostErrors, loadProfile, packRecipe, parseId, parseName, readSetup, readTimeout, release, version, versionHeader };
106
+ export { ActionName, ActionRecord, Capacity, Checkpoint, client_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostErrorTag, HostId, Http, Id, Internal, Invalid, Limit, Machine, MachineSpec, Name, NotFound, Precondition, Profile, Runtime, Setup, SshEndpoint, Unavailable, formatId, hostErrors, loadProfile, packRecipe, parseId, parseName, readSetup, readTimeout, release, version, versionHeader };
package/dist/node.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { E as Invalid, n as HostEntry, r as Options, t as Client } from "./client-C6ll48AB.mjs";
1
+ import { D as Invalid, n as HostEntry, r as Options, t as Client } from "./client-D63Z17YP.mjs";
2
2
  import { Layer } from "effect";
3
3
  //#region src/node.d.ts
4
4
  /** Node's `http` module sets no timeout of its own: a mutation can run for hours. */
package/dist/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { r as make, t as Client } from "./client-DXuiPvxU.mjs";
1
+ import { r as make, t as Client } from "./client-DSd3saH0.mjs";
2
2
  import { Layer } from "effect";
3
3
  import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient";
4
4
  //#region src/node.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjermundgaraba/clankerbox-sdk",
3
- "version": "0.12.2",
3
+ "version": "0.14.0",
4
4
  "description": "clankerbox's API contract and client library, for Effect",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -28,19 +28,19 @@
28
28
  "access": "public"
29
29
  },
30
30
  "dependencies": {
31
- "@gjermundgaraba/effect-actions": "0.9.0"
31
+ "@gjermundgaraba/effect-actions": "0.11.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@effect/platform-node": "4.0.0",
34
+ "@effect/platform-node": "4.0.2",
35
35
  "@types/node": "26.6.4",
36
- "effect": "4.0.0",
36
+ "effect": "4.0.2",
37
37
  "typescript": "7.0.2",
38
- "vite": "npm:@voidzero-dev/vite-plus-core@1.0.0",
39
- "vite-plus": "1.0.0"
38
+ "vite": "npm:@voidzero-dev/vite-plus-core@1.1.0",
39
+ "vite-plus": "1.1.0"
40
40
  },
41
41
  "peerDependencies": {
42
- "@effect/platform-node": "^4.0.0",
43
- "effect": "^4.0.0"
42
+ "@effect/platform-node": "~4.0.2",
43
+ "effect": "~4.0.2"
44
44
  },
45
45
  "peerDependenciesMeta": {
46
46
  "@effect/platform-node": {