sandcovery 0.11.0 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -82,6 +82,10 @@ sandcovery sandboxes destroySandbox --sandbox_id "$id"
82
82
  - A flag for a body field that is not text, such as a number, a list, or an object, takes JSON, either as the flag value or as `@` and a path relative to the current directory to a file inside it, such as `--env @env.json`. Every other flag takes its value as text as written, so `--command @run.sh` sends the text `@run.sh`. An operation whose body is a file, such as `sandboxes uploadFile`, reads that body from stdin.
83
83
  - `--help` works on every command.
84
84
 
85
+ ## Your machine
86
+
87
+ `sandcovery engine` runs Sandcovery sandboxes on your own computer, shown in Sandcovery as Your machine. It signs the computer in the way `sandcovery login` does when it holds no key, connects to Sandcovery, and stays connected until you stop it, reconnecting on its own when the connection drops. Each sandbox is a Docker container from the image it asks for, with that sandbox's CPU and memory limits, so Docker must run on the computer. `--cpus` and `--memory` (in GiB) set what all sandboxes may reserve together, and default to half of the computer's CPUs and memory. A sandbox that would pass either limit goes to another provider, and a sandbox that ends frees what it reserved.
88
+
85
89
  ## Docker, kubectl, and T3 Code
86
90
 
87
91
  The package installs three more commands that run your tools on sandboxes through this client. Each reads the key from `SANDCOVERY_API_KEY` and the API origin from `SANDCOVERY_BASE_URL`, keeps its state in `~/.config/sandcovery`, and passes an API error through unchanged.
@@ -0,0 +1,380 @@
1
+ import { Ga as isResult, Ha as fail, Ka as isSuccess, Xo as isString, Ya as succeed, es as ownEnumerableKeys, ss as identity, us as pipeArguments } from "./src-BnspmiaT.mjs";
2
+ const ValueMatcherProto = {
3
+ ["~effect/Match/Matcher"]: {
4
+ _input: identity,
5
+ _filters: identity,
6
+ _result: identity,
7
+ _return: identity,
8
+ _flavor: identity
9
+ },
10
+ _tag: "ValueMatcher",
11
+ add(_case) {
12
+ if (isSuccess(this.value)) return this;
13
+ if (_case._tag === "When" && _case.guard(this.provided) === true) return makeValueMatcher(this.provided, succeed(_case.evaluate(this.provided)));
14
+ else if (_case._tag === "Not" && _case.guard(this.provided) === false) return makeValueMatcher(this.provided, succeed(_case.evaluate(this.provided)));
15
+ return this;
16
+ },
17
+ pipe() {
18
+ return pipeArguments(this, arguments);
19
+ }
20
+ };
21
+ function makeValueMatcher(provided, value) {
22
+ const matcher = Object.create(ValueMatcherProto);
23
+ matcher.provided = provided;
24
+ matcher.value = value;
25
+ return matcher;
26
+ }
27
+ const makeWhen = (guard, evaluate) => ({
28
+ _tag: "When",
29
+ guard,
30
+ evaluate
31
+ });
32
+ const makePredicate = (pattern) => {
33
+ if (typeof pattern === "function") return pattern;
34
+ else if (Array.isArray(pattern)) {
35
+ const predicates = pattern.map(makePredicate);
36
+ const len = predicates.length;
37
+ return (u) => {
38
+ if (!Array.isArray(u) || u.length < len) return false;
39
+ for (let i = 0; i < len; i++) if (predicates[i](u[i]) === false) return false;
40
+ return true;
41
+ };
42
+ } else if (pattern !== null && typeof pattern === "object") {
43
+ const keysAndPredicates = ownEnumerableKeys(pattern).map((key) => [key, makePredicate(pattern[key])]);
44
+ const len = keysAndPredicates.length;
45
+ return (u) => {
46
+ if (typeof u !== "object" || u === null) return false;
47
+ for (let i = 0; i < len; i++) {
48
+ const [key, predicate] = keysAndPredicates[i];
49
+ if (!(key in u) || predicate(u[key]) === false) return false;
50
+ }
51
+ return true;
52
+ };
53
+ }
54
+ return (u) => u === pattern;
55
+ };
56
+ /** @internal */
57
+ const value$1 = (i) => makeValueMatcher(i, fail(i));
58
+ /** @internal */
59
+ const when$1 = (pattern, f) => (self) => self.add(makeWhen(makePredicate(pattern), f));
60
+ /** @internal */
61
+ const discriminator = (field) => (...pattern) => {
62
+ const f = pattern[pattern.length - 1];
63
+ const values = pattern.slice(0, -1);
64
+ const pred = values.length === 1 ? (_) => _ != null && _[field] === values[0] : (_) => _ != null && values.includes(_[field]);
65
+ return (self) => self.add(makeWhen(pred, f));
66
+ };
67
+ /** @internal */
68
+ const tag$1 = /*#__PURE__*/ discriminator("_tag");
69
+ /** @internal */
70
+ const orElse$1 = (f) => (self) => {
71
+ const toResult = result(self);
72
+ if (isResult(toResult)) return toResult._tag === "Success" ? toResult.success : f(toResult.failure);
73
+ return (...args) => {
74
+ const a = toResult(...args);
75
+ return isSuccess(a) ? a.success : f(a.failure, ...args);
76
+ };
77
+ };
78
+ /** @internal */
79
+ const result = (self) => {
80
+ if (self._tag === "ValueMatcher") return self.value;
81
+ const len = self.cases.length;
82
+ if (len === 1) {
83
+ const _case = self.cases[0];
84
+ return (...args) => {
85
+ const input = self.select(...args);
86
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed(_case.evaluate(input, ...args));
87
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed(_case.evaluate(input, ...args));
88
+ return fail(input);
89
+ };
90
+ }
91
+ return (...args) => {
92
+ const input = self.select(...args);
93
+ for (let i = 0; i < len; i++) {
94
+ const _case = self.cases[i];
95
+ if (_case._tag === "When" && _case.guard(input) === true) return succeed(_case.evaluate(input, ...args));
96
+ else if (_case._tag === "Not" && _case.guard(input) === false) return succeed(_case.evaluate(input, ...args));
97
+ }
98
+ return fail(input);
99
+ };
100
+ };
101
+ const getExhaustiveAbsurdErrorMessage = "effect/match/Match/exhaustive: absurd";
102
+ /** @internal */
103
+ const exhaustive$1 = (self) => {
104
+ const toResult = result(self);
105
+ if (isResult(toResult)) {
106
+ if (isSuccess(toResult)) return toResult.success;
107
+ throw new Error(getExhaustiveAbsurdErrorMessage);
108
+ }
109
+ return (...args) => {
110
+ const result = toResult(...args);
111
+ if (isSuccess(result)) return result.success;
112
+ throw new Error(getExhaustiveAbsurdErrorMessage);
113
+ };
114
+ };
115
+ // ../../node_modules/.pnpm/effect@4.1.5/node_modules/effect/dist/Match.js
116
+ /**
117
+ * Builds pattern matchers for TypeScript values.
118
+ *
119
+ * `Match` lets you add ordered cases and then finish them with a result,
120
+ * fallback, `Option`, or exhaustive check. Use `Match.type` to define a
121
+ * reusable matcher for a type, or `Match.value` to match one value immediately.
122
+ * Cases can match literal values, predicates, object shapes, tags, negated
123
+ * patterns, and common checks such as strings, numbers, records, and class
124
+ * instances.
125
+ *
126
+ * Object patterns use their own enumerable string and symbol properties.
127
+ * Non-enumerable and inherited pattern properties are ignored. The selected
128
+ * properties may be non-enumerable or inherited on the value being matched.
129
+ *
130
+ * @stability stable
131
+ * @since 4.0.0
132
+ */
133
+ /**
134
+ * Creates a matcher from a specific value.
135
+ *
136
+ * **When to use**
137
+ *
138
+ * Use to match one concrete input immediately.
139
+ *
140
+ * **Details**
141
+ *
142
+ * This function allows you to define a `Matcher` directly from a given value,
143
+ * rather than from a type. This is useful when working with known values,
144
+ * enabling structured pattern matching on objects, primitives, or any data
145
+ * structure.
146
+ *
147
+ * Once the matcher is created, you can use pattern-matching functions like
148
+ * {@link when} to define how different cases should be handled.
149
+ *
150
+ * **Example** (Matching an Object by Property)
151
+ *
152
+ * ```ts import.meta.vitest
153
+ * import { Match } from "effect"
154
+ *
155
+ * const input = { name: "John", age: 30 }
156
+ *
157
+ * // Create a matcher for the specific object
158
+ * const result = Match.value(input).pipe(
159
+ * // Match when the 'name' property is "John"
160
+ * Match.when(
161
+ * { name: "John" },
162
+ * (user) => `${user.name} is ${user.age} years old`
163
+ * ),
164
+ * // Provide a fallback if no match is found
165
+ * Match.orElse(() => "Oh, not John")
166
+ * )
167
+ *
168
+ * result // => "John is 30 years old"
169
+ * ```
170
+ *
171
+ * @see {@link type} for creating a matcher from a specific type.
172
+ *
173
+ * @stability stable
174
+ * @category constructors
175
+ * @since 4.0.0
176
+ */
177
+ const value = value$1;
178
+ /**
179
+ * Defines a condition for matching values.
180
+ *
181
+ * **When to use**
182
+ *
183
+ * Use to add one positive pattern case to a `Match.type` or `Match.value`
184
+ * pipeline when a direct value, predicate, or structured object pattern should
185
+ * run a handler for matching input.
186
+ *
187
+ * **Details**
188
+ *
189
+ * Supports both direct value comparisons and predicate functions. If the
190
+ * pattern matches, the associated function is executed and the matched input is
191
+ * removed from the remaining cases tracked by the matcher.
192
+ * Object patterns, including nested patterns, use only own enumerable string
193
+ * and symbol properties. Non-enumerable and inherited pattern properties are
194
+ * ignored. Selected properties on the input may be non-enumerable or inherited.
195
+ *
196
+ * **Example** (Matching with values and predicates)
197
+ *
198
+ * ```ts import.meta.vitest
199
+ * import { Match } from "effect"
200
+ *
201
+ * // Create a matcher for objects with an "age" property
202
+ * const match = Match.type<{ age: number }>().pipe(
203
+ * // Match when age is greater than 18
204
+ * Match.when(
205
+ * { age: (age: number) => age > 18 },
206
+ * (user: { age: number }) => `Age: ${user.age}`
207
+ * ),
208
+ * // Match when age is exactly 18
209
+ * Match.when({ age: 18 }, () => "You can vote"),
210
+ * // Fallback case for all other ages
211
+ * Match.orElse((user: { age: number }) => `${user.age} is too young`)
212
+ * )
213
+ *
214
+ * match({ age: 20 }) // => "Age: 20"
215
+ *
216
+ * match({ age: 18 }) // => "You can vote"
217
+ *
218
+ * match({ age: 4 }) // => "4 is too young"
219
+ * ```
220
+ *
221
+ * @see {@link whenOr} for handling any one of several patterns with the same handler
222
+ * @see {@link whenAnd} for requiring all provided patterns to match before running a handler
223
+ * @see {@link not} for handling inputs that do not match a pattern
224
+ * @see {@link orElse} for providing a fallback when no pattern case matches
225
+ *
226
+ * @stability stable
227
+ * @category defining patterns
228
+ * @since 4.0.0
229
+ */
230
+ const when = when$1;
231
+ /**
232
+ * Matches discriminated union members by their `_tag` field.
233
+ *
234
+ * **When to use**
235
+ *
236
+ * Use to handle one or more `_tag` cases with the same matcher branch.
237
+ *
238
+ * **Details**
239
+ *
240
+ * This helper follows the Effect convention that discriminated unions use
241
+ * `"_tag"` as their discriminator field. Use {@link discriminator} for a
242
+ * different discriminator field.
243
+ *
244
+ * **Example** (Matching a discriminated union by tag)
245
+ *
246
+ * ```ts import.meta.vitest
247
+ * import { Match } from "effect"
248
+ *
249
+ * type Event =
250
+ * | { readonly _tag: "fetch" }
251
+ * | { readonly _tag: "success"; readonly data: string }
252
+ * | { readonly _tag: "error"; readonly error: Error }
253
+ * | { readonly _tag: "cancel" }
254
+ *
255
+ * const match = Match.type<Event>().pipe(
256
+ * // Match either "fetch" or "success"
257
+ * Match.tag("fetch", "success", () => `Ok!`),
258
+ * // Match "error" and extract the error message
259
+ * Match.tag("error", (event) => `Error: ${event.error.message}`),
260
+ * // Match "cancel"
261
+ * Match.tag("cancel", () => "Cancelled"),
262
+ * Match.exhaustive
263
+ * )
264
+ *
265
+ * match({ _tag: "success", data: "Hello" }) // => "Ok!"
266
+ *
267
+ * match({ _tag: "error", error: new Error("Oops!") }) // => "Error: Oops!"
268
+ * ```
269
+ *
270
+ * @stability stable
271
+ * @category defining patterns
272
+ * @since 4.0.0
273
+ */
274
+ const tag = tag$1;
275
+ /**
276
+ * Matches values of type `string`.
277
+ *
278
+ * **Details**
279
+ *
280
+ * This predicate refines unknown values to strings, allowing pattern matching
281
+ * on string types. It's commonly used in type-based matchers to handle string cases.
282
+ *
283
+ * **Example** (Matching string values)
284
+ *
285
+ * ```ts import.meta.vitest
286
+ * import { Match } from "effect"
287
+ *
288
+ * const processValue = Match.type<string | number | boolean>().pipe(
289
+ * Match.when(Match.string, (str) => `String: ${str.toUpperCase()}`),
290
+ * Match.when(Match.number, (num) => `Number: ${num * 2}`),
291
+ * Match.when(Match.boolean, (bool) => `Boolean: ${bool ? "yes" : "no"}`),
292
+ * Match.exhaustive
293
+ * )
294
+ *
295
+ * processValue("hello") // => "String: HELLO"
296
+ * processValue(42) // => "Number: 84"
297
+ * processValue(true) // => "Boolean: yes"
298
+ * ```
299
+ *
300
+ * @stability stable
301
+ * @category guards
302
+ * @since 4.0.0
303
+ */
304
+ const string = isString;
305
+ /**
306
+ * Provides a fallback value when no patterns match.
307
+ *
308
+ * **When to use**
309
+ *
310
+ * Use to finalize a matcher with a fallback for unmatched input.
311
+ *
312
+ * **Details**
313
+ *
314
+ * This function ensures that a matcher always returns a valid result, even if
315
+ * no defined patterns match. It acts as a default case, similar to the
316
+ * `default` clause in a `switch` statement or the final `else` in an `if-else`
317
+ * chain.
318
+ *
319
+ * **Example** (Providing a default value when no patterns match)
320
+ *
321
+ * ```ts import.meta.vitest
322
+ * import { Match } from "effect"
323
+ *
324
+ * // Create a matcher for string or number values
325
+ * const match = Match.type<string | number>().pipe(
326
+ * // Match when the value is "a"
327
+ * Match.when("a", () => "ok"),
328
+ * // Fallback when no patterns match
329
+ * Match.orElse(() => "fallback")
330
+ * )
331
+ *
332
+ * match("a") // => "ok"
333
+ *
334
+ * match("b") // => "fallback"
335
+ * ```
336
+ *
337
+ * @see {@link option} for finalizing unmatched input as `Option.none`
338
+ * @see {@link result} for returning unmatched input as a `Result` failure
339
+ * @see {@link orElseAbsurd} for finalizing when unmatched input should be impossible
340
+ *
341
+ * @stability stable
342
+ * @category completion
343
+ * @since 4.0.0
344
+ */
345
+ const orElse = orElse$1;
346
+ /**
347
+ * Completes a matcher that handles every remaining input case.
348
+ *
349
+ * **When to use**
350
+ *
351
+ * Use to require TypeScript to reject incomplete matcher definitions before the
352
+ * matcher is turned into a function.
353
+ *
354
+ * **Details**
355
+ *
356
+ * If any case is still unmatched, the matcher does not type-check as
357
+ * exhaustive.
358
+ *
359
+ * **Example** (Ensuring all cases are covered)
360
+ *
361
+ * ```ts import.meta.vitest
362
+ * import { Match } from "effect"
363
+ *
364
+ * // Create a matcher for string or number values
365
+ * const match = Match.type<string | number>().pipe(
366
+ * // Match when the value is a number
367
+ * Match.when(Match.number, (n) => `number: ${n}`),
368
+ * // Mark the match as exhaustive, ensuring all cases are handled
369
+ * // TypeScript will throw an error if any case is missing
370
+ * // @ts-expect-error Type 'string' is not assignable to type 'never'
371
+ * Match.exhaustive
372
+ * )
373
+ * ```
374
+ *
375
+ * @stability stable
376
+ * @category completion
377
+ * @since 4.0.0
378
+ */
379
+ const exhaustive = exhaustive$1;
380
+ export { value as a, tag as i, orElse as n, when as o, string as r, exhaustive as t };