sandcovery 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -5
- package/dist/{Schema-DiSfJzMf.mjs → Schema-CFI3ZMu8.mjs} +137 -1
- package/dist/cli/index.mjs +8 -27
- package/dist/handlers-BS1KuMqq.mjs +6546 -0
- package/dist/index.d.mts +23 -1
- package/dist/index.mjs +1 -1
- package/dist/{origin-CIA-1Jia.mjs → origin-BTx2gX8x.mjs} +98 -74
- package/dist/{spec-DfgmzDj-.mjs → spec-B4c-Ug3B.mjs} +594 -120
- package/dist/{src-YrynO3hz.mjs → src-DPDVOBkr.mjs} +240 -23
- package/dist/{telemetry-delivery-zinKRHRc.mjs → telemetry-delivery-Yd6CeynR.mjs} +3 -3
- package/dist/{types-DMB8KnA3.d.mts → types-DvoIdTvQ.d.mts} +151 -12
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +18 -18
- package/package.json +3 -1
- package/dist/handlers-rkx0CsMY.mjs +0 -2459
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ import { Sandcovery } from 'sandcovery'
|
|
|
24
24
|
const sandcovery = new Sandcovery()
|
|
25
25
|
|
|
26
26
|
const sandbox = await sandcovery.sandboxes.create({
|
|
27
|
-
|
|
27
|
+
slug: 'sandcovery/2x4:cheapest',
|
|
28
28
|
ttl_seconds: 600,
|
|
29
29
|
})
|
|
30
30
|
|
|
@@ -53,23 +53,26 @@ The package also installs the `sandcovery` command, which calls the API through
|
|
|
53
53
|
npm install --global sandcovery
|
|
54
54
|
export SANDCOVERY_API_KEY=sand_...
|
|
55
55
|
|
|
56
|
-
id=$(sandcovery sandboxes create --
|
|
56
|
+
id=$(sandcovery sandboxes create --slug sandcovery/2x4:cheapest --ttl 600)
|
|
57
57
|
sandcovery sandboxes exec "$id" -- npm test
|
|
58
58
|
sandcovery sandboxes destroy "$id" --yes
|
|
59
59
|
```
|
|
60
60
|
|
|
61
61
|
- `sandcovery sandboxes exec` streams the command's output and exits with the command's exit code.
|
|
62
|
+
- `sandcovery docker <args>` runs `docker <args>` in a sandbox on a provider that runs Docker, streams its output, and exits with its exit code, so a computer with no Docker can build and run containers. Later `sandcovery docker` commands reuse that sandbox until its TTL ends, and `build`, `buildx`, `builder`, `compose`, and `image build` first copy the working directory into it, up to 100 MiB packed. It reads no stdin and gets no terminal, so `docker run -it` does not work.
|
|
62
63
|
- `--json` prints one JSON document on stdout, and every failure prints a JSON error with a stable `reason` on stderr.
|
|
63
64
|
- `sandboxes destroy`, `keys revoke`, and `credentials delete` ask first, and need `--yes` without a terminal.
|
|
64
|
-
- `sandcovery providers list --routed` lists only the providers Sandcovery routes to, `sandcovery credentials offer` shows the free vCPU-hours your keys have earned, and `sandcovery billing inspect` and `sandcovery billing buy-credits --amount <USD>` show the plan and start a credit payment.
|
|
65
|
+
- `sandcovery providers list --routed` lists only the providers Sandcovery routes to, `sandcovery credentials offer` shows the free vCPU-hours your keys have earned, `sandcovery pricing inspect` shows the Pro price and the credit terms with no key, and `sandcovery billing inspect` and `sandcovery billing buy-credits --amount <USD>` show the plan and start a credit payment.
|
|
65
66
|
- `sandcovery help search <words>` finds a command, and `--help` works on every command.
|
|
66
67
|
- The CLI sends anonymous usage data: command paths, option names, failure reasons, and exit codes, never values or remote data. `sandcovery cli telemetry disable` or `SANDCOVERY_TELEMETRY_DISABLED=1` turns it off.
|
|
67
68
|
|
|
68
69
|
## Routing
|
|
69
70
|
|
|
70
|
-
A size
|
|
71
|
+
A slug names a provider and a size, written `<provider>/<vcpu>x<memory_gib>`, in the shape of OpenRouter model slugs. `boat/2x4` pins boat at 2 vCPU and 4 GiB, and `sandcovery/2x4` routes across every candidate provider. Either number may be `n` for any value, so `sandcovery/nx16` runs each provider's cheapest size with 16 GiB. A slug routes as `:cheapest`, sorting candidates by list price. Add `:fastest` or `:most-reliable` to sort them by measured create latency or uptime over the last 15 minutes instead. With no slug, a create runs `sandcovery/2x4`.
|
|
71
72
|
|
|
72
|
-
|
|
73
|
+
`slugs` takes up to 8 slugs to try in order, as OpenRouter takes `models`, and `slug` goes first when both are set. Within a `sandcovery/` slug, a failed create falls back across that slug's candidates first, then moves to the next slug. `provider` takes `order`, `only`, `ignore`, `sort`, and `allow_fallbacks` and applies them to every slug. Every create attempt is listed in `sandbox.attempts`, and `sandbox.slug` is the provider and size it runs on.
|
|
74
|
+
|
|
75
|
+
Provider, region, and slug names are open strings, so a name the API adds later works with this version. The names known at release are exported from `sandcovery/types` as `PROVIDERS`, `REGIONS`, `STANDARD_SIZES`, `SLUGS`, and `EGRESS_MODES`.
|
|
73
76
|
|
|
74
77
|
## Keys and provider credentials
|
|
75
78
|
|
|
@@ -81,6 +84,8 @@ const admin = new Sandcovery({ apiKey: process.env.SANDCOVERY_MANAGEMENT_KEY })
|
|
|
81
84
|
await admin.credentials.set('e2b', { api_key: process.env.E2B_API_KEY })
|
|
82
85
|
```
|
|
83
86
|
|
|
87
|
+
An organization on Pro can hold more than one credential for a provider: `credentials.add(provider, fields)` adds another, a create tries them in the order they were added, and `credentials.deleteOne(provider, id)` deletes one.
|
|
88
|
+
|
|
84
89
|
The fields each provider takes are its `credential_fields` on `sandcovery.providers.get(provider)`. `sandcovery.providers.catalog()` lists every provider on the [provider board](https://www.sandcovery.com/providers), where `routed` is `false` for a provider that is coming soon. `credentials.offer()` reads the free vCPU-hours your keys have earned, `billing.get()` reads the plan and the credit balance, and `billing.buyCredits({ amount_micro_usd })` answers the Stripe Checkout page that takes a credit payment.
|
|
85
90
|
|
|
86
91
|
## Interfaces
|
|
@@ -2879,6 +2879,42 @@ const getOrElse = /*#__PURE__*/ dual(2, (self, onNone) => isNone(self) ? onNone(
|
|
|
2879
2879
|
*/
|
|
2880
2880
|
const getOrUndefined = /*#__PURE__*/ getOrElse(constUndefined);
|
|
2881
2881
|
/**
|
|
2882
|
+
* Lifts a function that may throw into one that returns an `Option`.
|
|
2883
|
+
*
|
|
2884
|
+
* **When to use**
|
|
2885
|
+
*
|
|
2886
|
+
* Use to wrap exception-throwing APIs (e.g. `JSON.parse`) for safe usage
|
|
2887
|
+
*
|
|
2888
|
+
* **Details**
|
|
2889
|
+
*
|
|
2890
|
+
* - If the function returns normally → `Some` with the result
|
|
2891
|
+
* - If the function throws → `None` (exception is swallowed)
|
|
2892
|
+
*
|
|
2893
|
+
* **Example** (Lifting JSON.parse)
|
|
2894
|
+
*
|
|
2895
|
+
* ```ts import.meta.vitest
|
|
2896
|
+
* import { Option } from "effect"
|
|
2897
|
+
*
|
|
2898
|
+
* const parse = Option.liftThrowable(JSON.parse)
|
|
2899
|
+
*
|
|
2900
|
+
* parse("1") // => Option.some(1)
|
|
2901
|
+
* parse("") // => Option.none()
|
|
2902
|
+
* ```
|
|
2903
|
+
*
|
|
2904
|
+
* @see {@link liftNullishOr} for nullable-returning functions
|
|
2905
|
+
*
|
|
2906
|
+
* @stability stable
|
|
2907
|
+
* @category converting
|
|
2908
|
+
* @since 2.0.0
|
|
2909
|
+
*/
|
|
2910
|
+
const liftThrowable = (f) => (...a) => {
|
|
2911
|
+
try {
|
|
2912
|
+
return some(f(...a));
|
|
2913
|
+
} catch {
|
|
2914
|
+
return none();
|
|
2915
|
+
}
|
|
2916
|
+
};
|
|
2917
|
+
/**
|
|
2882
2918
|
* Transforms the value inside a `Some` using the provided function, leaving
|
|
2883
2919
|
* `None` unchanged.
|
|
2884
2920
|
*
|
|
@@ -2909,6 +2945,50 @@ const getOrUndefined = /*#__PURE__*/ getOrElse(constUndefined);
|
|
|
2909
2945
|
* @since 2.0.0
|
|
2910
2946
|
*/
|
|
2911
2947
|
const map$5 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : some(f(self.value)));
|
|
2948
|
+
/**
|
|
2949
|
+
* Applies a function that returns an `Option` to the value of a `Some`,
|
|
2950
|
+
* flattening the result. Returns `None` if the input is `None`.
|
|
2951
|
+
*
|
|
2952
|
+
* **When to use**
|
|
2953
|
+
*
|
|
2954
|
+
* Use when you need to chain dependent `Option` computations where each step
|
|
2955
|
+
* may return `None`.
|
|
2956
|
+
*
|
|
2957
|
+
* **Details**
|
|
2958
|
+
*
|
|
2959
|
+
* - `Some` → applies `f` to the value and returns its `Option` result
|
|
2960
|
+
* - `None` → returns `None` without calling `f`
|
|
2961
|
+
* - Equivalent to `map` followed by {@link flatten}
|
|
2962
|
+
*
|
|
2963
|
+
* **Example** (Chaining optional lookups)
|
|
2964
|
+
*
|
|
2965
|
+
* ```ts import.meta.vitest
|
|
2966
|
+
* import { Option } from "effect"
|
|
2967
|
+
*
|
|
2968
|
+
* interface User {
|
|
2969
|
+
* readonly name: string
|
|
2970
|
+
* readonly address: Option.Option<{ readonly street: Option.Option<string> }>
|
|
2971
|
+
* }
|
|
2972
|
+
*
|
|
2973
|
+
* const user: User = {
|
|
2974
|
+
* name: "John",
|
|
2975
|
+
* address: Option.some({ street: Option.some("123 Main St") })
|
|
2976
|
+
* }
|
|
2977
|
+
*
|
|
2978
|
+
* user.address.pipe(
|
|
2979
|
+
* Option.flatMap((addr) => addr.street)
|
|
2980
|
+
* ) // => Option.some("123 Main St")
|
|
2981
|
+
* ```
|
|
2982
|
+
*
|
|
2983
|
+
* @see {@link map} when `f` returns a plain value
|
|
2984
|
+
* @see {@link andThen} for a more flexible variant
|
|
2985
|
+
* @see {@link flatten} to unwrap a nested `Option<Option<A>>`
|
|
2986
|
+
*
|
|
2987
|
+
* @stability stable
|
|
2988
|
+
* @category sequencing
|
|
2989
|
+
* @since 2.0.0
|
|
2990
|
+
*/
|
|
2991
|
+
const flatMap$3 = /*#__PURE__*/ dual(2, (self, f) => isNone(self) ? none() : f(self.value));
|
|
2912
2992
|
// ../../node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/Context.js
|
|
2913
2993
|
/**
|
|
2914
2994
|
* Runtime type identifier attached to `Context` service keys and used by
|
|
@@ -11250,6 +11330,45 @@ const Int = /*#__PURE__*/ Number$1.check(/*#__PURE__*/ isInt());
|
|
|
11250
11330
|
* @since 4.0.0
|
|
11251
11331
|
*/
|
|
11252
11332
|
const Natural = /*#__PURE__*/ Int.check(/*#__PURE__*/ isGreaterThanOrEqualTo(0));
|
|
11333
|
+
/**
|
|
11334
|
+
* Validates that a value has at least the specified length. Works with strings
|
|
11335
|
+
* and arrays.
|
|
11336
|
+
*
|
|
11337
|
+
* **Details**
|
|
11338
|
+
*
|
|
11339
|
+
* JSON Schema:
|
|
11340
|
+
*
|
|
11341
|
+
* The bound must be finite; it is rounded down and clamped to zero. For arrays,
|
|
11342
|
+
* this check corresponds to `minItems`. JavaScript counts UTF-16 code units
|
|
11343
|
+
* while JSON Schema counts Unicode code points, so strings use
|
|
11344
|
+
* `minLength: Math.ceil(minLength / 2)`, the tightest lower bound that cannot
|
|
11345
|
+
* reject a string accepted by this check.
|
|
11346
|
+
*
|
|
11347
|
+
* Arbitrary:
|
|
11348
|
+
*
|
|
11349
|
+
* During arbitrary generation, this applies a `minLength`
|
|
11350
|
+
* constraint to ensure generated strings or arrays have at least the required
|
|
11351
|
+
* length.
|
|
11352
|
+
*
|
|
11353
|
+
* **Example** (Checking minimum length)
|
|
11354
|
+
*
|
|
11355
|
+
* ```ts import.meta.vitest
|
|
11356
|
+
* import { Schema } from "effect"
|
|
11357
|
+
*
|
|
11358
|
+
* const NonEmptyStringSchema = Schema.String.check(Schema.isMinLength(1))
|
|
11359
|
+
* const NonEmptyArraySchema = Schema.Array(Schema.Number).check(Schema.isMinLength(1))
|
|
11360
|
+
* Schema.is(NonEmptyStringSchema)("a") // => true
|
|
11361
|
+
* Schema.is(NonEmptyArraySchema)([1]) // => true
|
|
11362
|
+
* ```
|
|
11363
|
+
*
|
|
11364
|
+
* @stability stable
|
|
11365
|
+
* @category validation
|
|
11366
|
+
* @since 4.0.0
|
|
11367
|
+
*/
|
|
11368
|
+
function isMinLength(minLength, annotations) {
|
|
11369
|
+
minLength = normalizeCardinality(minLength);
|
|
11370
|
+
return makeIsMinLength(minLength, Math.ceil(minLength / 2), annotations);
|
|
11371
|
+
}
|
|
11253
11372
|
function makeIsMinLength(minLength, minCodePoints, annotations) {
|
|
11254
11373
|
return makeFilter((input) => input.length >= minLength, {
|
|
11255
11374
|
expected: `a value with a length of at least ${minLength}`,
|
|
@@ -11382,6 +11501,23 @@ function fromJsonString(schema, options) {
|
|
|
11382
11501
|
}
|
|
11383
11502
|
globalThis.File;
|
|
11384
11503
|
globalThis.URLSearchParams;
|
|
11504
|
+
/**
|
|
11505
|
+
* Schema that parses a string into a finite number.
|
|
11506
|
+
*
|
|
11507
|
+
* **Details**
|
|
11508
|
+
*
|
|
11509
|
+
* Decoding:
|
|
11510
|
+
* - A `string` is decoded as a finite number, rejecting `NaN`, `Infinity`, and
|
|
11511
|
+
* `-Infinity` values.
|
|
11512
|
+
*
|
|
11513
|
+
* Encoding:
|
|
11514
|
+
* - A finite number is encoded as a `string`.
|
|
11515
|
+
*
|
|
11516
|
+
* @stability stable
|
|
11517
|
+
* @category schemas
|
|
11518
|
+
* @since 4.0.0
|
|
11519
|
+
*/
|
|
11520
|
+
const FiniteFromString = /*#__PURE__*/ String$1.annotate({ expected: "a string that will be decoded as a finite number" }).pipe(/*#__PURE__*/ decodeTo(Finite, numberFromString));
|
|
11385
11521
|
globalThis.Uint8Array;
|
|
11386
11522
|
const immerable = /*#__PURE__*/ globalThis.Symbol.for("immer-draftable");
|
|
11387
11523
|
const payloadToken = {};
|
|
@@ -11546,4 +11682,4 @@ const Json = /*#__PURE__*/ make(/*#__PURE__*/ annotate(Json$1, { toCode: () => (
|
|
|
11546
11682
|
runtime: "Schema.Json",
|
|
11547
11683
|
Type: "Schema.Json"
|
|
11548
11684
|
}) }));
|
|
11549
|
-
export {
|
|
11685
|
+
export { isString$1 as $, isUUID as A, getSuccess as B, is as C, isMaxLength as D, isGreaterThanOrEqualTo as E, makeFormatterStandardSchemaV1 as F, getOrElse as G, isSuccess$1 as H, TaggedError as I, liftThrowable as J, getOrUndefined as K, millis as L, optional as M, optionalKey as N, isMinLength as O, tag as P, isPropertyKey as Q, seconds as R, fromJsonString as S, isBetween as T, try_$2 as U, isFailure as V, flatMap$3 as W, none as X, map$5 as Y, hasProperty as Z, Union as _, FiniteFromString as a, decodeUnknownResult as b, Literal as c, NonEmptyArray as d, NonEmptyString as f, Struct as g, String$1 as h, Finite as i, makeFilter as j, isMultipleOf as k, Literals as l, Record as m, Boolean$1 as n, Int as o, NullOr as p, isNone as q, Error$1 as r, Json as s, ArraySchema as t, Natural as u, decodeTo as v, isBase64Url as w, decodeUnknownSync as x, decodeUnknownOption as y, toMillis as z };
|
package/dist/cli/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
import { n as SANDCOVERY_ORIGIN } from "../origin-
|
|
4
|
-
import { A as
|
|
2
|
+
import { $ as isString, H as isSuccess, K as getOrUndefined, M as optional, S as fromJsonString, U as try_, V as isFailure, Z as hasProperty, g as Struct, h as String$1, m as Record, n as Boolean, s as Json, x as decodeUnknownSync, y as decodeUnknownOption } from "../Schema-CFI3ZMu8.mjs";
|
|
3
|
+
import { n as SANDCOVERY_ORIGIN } from "../origin-BTx2gX8x.mjs";
|
|
4
|
+
import { A as isUpper, C as escapeUnprintable, D as consistsOf, E as remoteText, F as usageFailure, I as Canceled, M as CliFailure, N as exitCodeOf, O as isDigit, P as statusOf$1, S as theme, T as remoteLine, _ as clearLine, a as configDirectory, b as plainPrefix, c as flagOf, d as lastValue, f as parseFailure, h as rerunArgv, i as version, j as isWordCharacter, l as isOptionToken, m as readOptionToken, o as writePrivateFile, p as parseLeaf, r as CLI, s as closest, t as BIN, u as isOptionValue, v as ellipsis, w as remoteCell, x as spinnerFrame, y as glyph } from "../spec-B4c-Ug3B.mjs";
|
|
5
5
|
import { n as sendTelemetry$1, t as loopbackOrigin } from "../telemetry-BYnuVdoZ.mjs";
|
|
6
6
|
import "../posthog-project-CdWw_ofg.mjs";
|
|
7
7
|
import http from "node:http";
|
|
@@ -9,8 +9,6 @@ import fs from "node:fs";
|
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { buffer } from "node:stream/consumers";
|
|
11
11
|
import readline from "node:readline";
|
|
12
|
-
import crypto from "node:crypto";
|
|
13
|
-
import os from "node:os";
|
|
14
12
|
// ../cli-core/src/layout.ts
|
|
15
13
|
const combining = /\p{M}/u;
|
|
16
14
|
const pictographic = /\p{Extended_Pictographic}/u;
|
|
@@ -613,8 +611,9 @@ const route = ({ argv, cli, surface }) => {
|
|
|
613
611
|
};
|
|
614
612
|
while (walk.index < argv.length) {
|
|
615
613
|
const token = argv[walk.index] ?? "";
|
|
616
|
-
|
|
617
|
-
|
|
614
|
+
const passthrough = walk.node.kind === "leaf" && walk.node.passthrough === true;
|
|
615
|
+
if (passthrough || token === "--") {
|
|
616
|
+
walk.tokens.push(...passthrough ? ["--"] : [], ...argv.slice(walk.index));
|
|
618
617
|
break;
|
|
619
618
|
}
|
|
620
619
|
if (isOptionToken(token)) takeOption(walk, argv, token);
|
|
@@ -1106,24 +1105,6 @@ const terminalPrompter = {
|
|
|
1106
1105
|
},
|
|
1107
1106
|
text: async (question) => await ask(question)
|
|
1108
1107
|
};
|
|
1109
|
-
millis(50);
|
|
1110
|
-
toMillis(seconds(90));
|
|
1111
|
-
seconds(20);
|
|
1112
|
-
TaggedError("LockHeld");
|
|
1113
|
-
const configDirectory = ({ bin, cwd, override }) => override === void 0 ? path.join(os.homedir(), ".config", bin) : path.resolve(cwd ?? process.cwd(), override);
|
|
1114
|
-
const writePrivateFile = ({ file, text }) => {
|
|
1115
|
-
const directory = path.dirname(file);
|
|
1116
|
-
fs.mkdirSync(directory, {
|
|
1117
|
-
mode: 448,
|
|
1118
|
-
recursive: true
|
|
1119
|
-
});
|
|
1120
|
-
const pending = path.join(directory, `.${path.basename(file)}.${crypto.randomBytes(8).toString("hex")}.tmp`);
|
|
1121
|
-
fs.writeFileSync(pending, text, {
|
|
1122
|
-
flag: "wx",
|
|
1123
|
-
mode: 384
|
|
1124
|
-
});
|
|
1125
|
-
fs.renameSync(pending, file);
|
|
1126
|
-
};
|
|
1127
1108
|
// ../cli-core/src/telemetry-settings.ts
|
|
1128
1109
|
const telemetrySettingsSchema = Struct({
|
|
1129
1110
|
disclosed: optional(Boolean),
|
|
@@ -1456,7 +1437,7 @@ const runCommand = async ({ invocation, session }) => {
|
|
|
1456
1437
|
try {
|
|
1457
1438
|
const local = LOCAL_COMMANDS.get(key);
|
|
1458
1439
|
if (local !== void 0) return local(context);
|
|
1459
|
-
const { HANDLERS } = await import("../handlers-
|
|
1440
|
+
const { HANDLERS } = await import("../handlers-BS1KuMqq.mjs");
|
|
1460
1441
|
const handler = HANDLERS.get(key);
|
|
1461
1442
|
if (handler === void 0) throw internalFailure(invocation.path);
|
|
1462
1443
|
return await handler(context);
|
|
@@ -1699,7 +1680,7 @@ if (event === void 0) {
|
|
|
1699
1680
|
signal: controller.signal
|
|
1700
1681
|
});
|
|
1701
1682
|
} else {
|
|
1702
|
-
const [{ deliverTelemetry }, project] = await Promise.all([import("../telemetry-delivery-
|
|
1683
|
+
const [{ deliverTelemetry }, project] = await Promise.all([import("../telemetry-delivery-Yd6CeynR.mjs"), import("../posthog-project-BpOd2VxW.mjs")]);
|
|
1703
1684
|
await deliverTelemetry({
|
|
1704
1685
|
host: process.env.__SANDCOVERY_POSTHOG_HOST,
|
|
1705
1686
|
productionHost: project.POSTHOG_INGEST_HOST,
|