@gjermundgaraba/clankerbox-sdk 0.13.0 → 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.
@@ -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 };
@@ -129,7 +129,7 @@ const formatId = (host, name) => {
129
129
  };
130
130
  //#endregion
131
131
  //#region package.json
132
- var version$1 = "0.13.0";
132
+ var version$1 = "0.14.0";
133
133
  //#endregion
134
134
  //#region src/resources.ts
135
135
  /** The resources a host reports: machines, checkpoints and the host itself. */
@@ -225,6 +225,28 @@ const Host = Schema.Struct({
225
225
  runtimeVersion: Schema.String,
226
226
  bases: Schema.Array(Schema.String)
227
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" });
228
250
  /** A setup script and how long it may run. Nothing logs the script: it can carry secrets. */
229
251
  const Setup = Schema.Struct({
230
252
  script: Schema.String,
@@ -383,6 +405,11 @@ const Http = ActionHttp.make([
383
405
  ...read,
384
406
  description: "Read the host: its runtime, versions and bases.",
385
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)
386
413
  })
387
414
  ], { prefix: "/api" });
388
415
  //#endregion
@@ -559,6 +586,7 @@ const make = (hosts, options) => Effect.gen(function* () {
559
586
  hosts: gather((route) => Effect.map(readHost(route), (host) => [host])),
560
587
  machines: gather((route) => ask(route, actions.listMachines, "list machines", (api) => api.listMachines())),
561
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())),
562
590
  machine: (id) => byId(id, actions.getMachine, `get ${id}`, (api) => api.getMachine({ id })),
563
591
  checkpoint: (id) => byId(id, actions.getCheckpoint, `get ${id}`, (api) => api.getCheckpoint({ id })),
564
592
  create,
@@ -581,4 +609,4 @@ const make = (hosts, options) => Effect.gen(function* () {
581
609
  };
582
610
  });
583
611
  //#endregion
584
- export { HostErrorTag as A, formatId as C, Conflict as D, Capacity as E, Unavailable as F, hostErrors as I, Invalid as M, NotFound as N, ConflictKind as O, Precondition as P, Name as S, parseName as T, SshEndpoint as _, readTimeout as a, HostId as b, ActionRecord as c, Host as d, Machine as f, Setup as g, Runtime as h, Http as i, Internal as j, ErrorTag as k, Checkpoint as l, Profile as m, client_exports as n, versionHeader as o, MachineSpec as p, make as r, ActionName as s, Client as t, CreateRequest as u, release as v, parseId as w, Id as x, version as y };
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,4 +1,4 @@
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-mIuehl40.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
3
  import * as ActionHttp from "@gjermundgaraba/effect-actions/ActionHttp";
4
4
  import { Duration, Effect, FileSystem, Path, Schema } from "effect";
@@ -268,7 +268,12 @@ export declare const Http: ActionHttp.Binding<readonly [Action.Action<"listMachi
268
268
  readonly version: Schema.String;
269
269
  readonly runtimeVersion: Schema.String;
270
270
  readonly bases: Schema.$Array<Schema.String>;
271
- }>, readonly (typeof Invalid | typeof NotFound | typeof Conflict | typeof Precondition | typeof Capacity | typeof Internal)[], true, typeof Action.Anyone>], [], undefined>;
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>;
272
277
  //#endregion
273
278
  //#region src/ids.d.ts
274
279
  /** A host's part of every ID it holds. */
@@ -311,4 +316,4 @@ export declare const packRecipe: (directory: string) => Effect.Effect<string, In
311
316
  /** Reads a setup: a script file's text, or a recipe directory packed into one script. */
312
317
  export declare const readSetup: (path: string) => Effect.Effect<string, Invalid, FileSystem.FileSystem | ChildProcessSpawner.ChildProcessSpawner>;
313
318
  //#endregion
314
- 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 HostErrorTag, C as formatId, D as Conflict, E as Capacity, F as Unavailable, I as hostErrors, M as Invalid, N as NotFound, O as ConflictKind, P as Precondition, S as Name, T as parseName, _ as SshEndpoint, a as readTimeout, b as HostId, c as ActionRecord, d as Host, f as Machine, g as Setup, h as Runtime, i as Http, j as Internal, k as ErrorTag, l as Checkpoint, m as Profile, n as client_exports, o as versionHeader, p as MachineSpec, s as ActionName, u as CreateRequest, v as release, w as parseId, x as Id, y as version } from "./client-Bb5qTz-i.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, client_exports as Client, Conflict, ConflictKind, CreateRequest, ErrorTag, Host, HostErrorTag, HostId, Http, Id, Internal, Invalid, Machine, 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-mIuehl40.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-Bb5qTz-i.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.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "clankerbox's API contract and client library, for Effect",
5
5
  "license": "MIT",
6
6
  "repository": {