sandcovery 0.6.2 → 0.7.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 +39 -24
- package/dist/cli/index.mjs +21703 -2
- package/dist/cli/sandcovery-docker.mjs +5 -4
- package/dist/cli/sandcovery-kubectl.mjs +6 -4
- package/dist/cli/sandcovery-t3.d.mts +1 -0
- package/dist/cli/sandcovery-t3.mjs +198 -0
- package/dist/index.d.mts +31 -18
- package/dist/index.mjs +1 -1
- package/dist/kubectl-ClFWX65x.mjs +438 -0
- package/dist/src-gAv6vIvE.mjs +566 -0
- package/dist/{handlers-CpLa3dvg.mjs → tool-B8KvfvY5.mjs} +11911 -18736
- package/dist/{types-C4amb2QE.d.mts → types-B52jOW9v.d.mts} +118 -58
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +6 -1
- package/dist/{Schema-CoX0a2_o.mjs → x-account-BSasf-z-.mjs} +8644 -1747
- package/package.json +13 -10
- package/dist/port-forwarder-DvSPr-Tg.mjs +0 -5360
- package/dist/posthog-project-BpOd2VxW.mjs +0 -1
- package/dist/posthog-project-CdWw_ofg.mjs +0 -22
- package/dist/src-BqfeIyqj.mjs +0 -2047
- package/dist/start-D1LPu-aN.mjs +0 -1604
- package/dist/telemetry-DBPKT8Ap.mjs +0 -43
- package/dist/telemetry-delivery-BSGibWPJ.mjs +0 -8712
package/dist/src-BqfeIyqj.mjs
DELETED
|
@@ -1,2047 +0,0 @@
|
|
|
1
|
-
import { A as isBase64Url$1, B as makeFilter, E as decodeUnknownSync, F as isMaxLength, H as optionalKey, I as isMinLength, L as isMultipleOf, M as isGreaterThan, N as isGreaterThanOrEqualTo, O as fromJsonString, U as tag, _ as String$1, a as Finite, cr as isSome, d as Natural, f as NonEmptyArray, g as Record, h as Number$1, i as Error$1, j as isBetween, k as is, l as Literal, m as NullOr, n as Boolean, o as FiniteFromString, p as NonEmptyString, rr as getOrElse, s as Int, t as ArraySchema, u as Literals, v as Struct, w as decodeUnknownOption, x as annotateEncoded, y as Union, z as isUUID } from "./Schema-CoX0a2_o.mjs";
|
|
2
|
-
// ../../node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/ErrorReporter.js
|
|
3
|
-
/**
|
|
4
|
-
* Defines the runtime property key used to mark an object error as ignored by error
|
|
5
|
-
* reporting.
|
|
6
|
-
*
|
|
7
|
-
* **When to use**
|
|
8
|
-
*
|
|
9
|
-
* Use to suppress reporting for expected object errors, such as HTTP 404
|
|
10
|
-
* responses.
|
|
11
|
-
*
|
|
12
|
-
* **Details**
|
|
13
|
-
*
|
|
14
|
-
* Set `error[ErrorReporter.ignore]` to `true` to prevent the error from being
|
|
15
|
-
* forwarded to reporters. This is useful for expected failures such as HTTP 404
|
|
16
|
-
* responses.
|
|
17
|
-
*
|
|
18
|
-
* **Example** (Marking errors as ignored)
|
|
19
|
-
*
|
|
20
|
-
* ```ts import.meta.vitest
|
|
21
|
-
* import { Data, ErrorReporter } from "effect"
|
|
22
|
-
*
|
|
23
|
-
* class NotFoundError extends Data.TaggedError("NotFoundError")<{}> {
|
|
24
|
-
* readonly [ErrorReporter.ignore] = true
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* ErrorReporter.isIgnored(new NotFoundError()) // => true
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @see {@link isIgnored} for checking whether a value carries this annotation
|
|
31
|
-
* @see {@link Reportable} for the annotation contract recognized on object
|
|
32
|
-
* errors
|
|
33
|
-
*
|
|
34
|
-
* @stability unstable
|
|
35
|
-
* @category annotations
|
|
36
|
-
* @since 4.0.0
|
|
37
|
-
*/
|
|
38
|
-
const ignore = "~effect/ErrorReporter/ignore";
|
|
39
|
-
// ../sandcovery-contract/src/primitives.ts
|
|
40
|
-
const PROVIDERS = [
|
|
41
|
-
"daytona",
|
|
42
|
-
"depot",
|
|
43
|
-
"e2b",
|
|
44
|
-
"upstash"
|
|
45
|
-
];
|
|
46
|
-
const PROVIDER_EXAMPLES = new Intl.ListFormat("en", { type: "disjunction" }).format(PROVIDERS.map((provider) => `\`${provider}\``));
|
|
47
|
-
const SLUG_CHARACTERS = /* @__PURE__ */ new Set("abcdefghijklmnopqrstuvwxyz0123456789-");
|
|
48
|
-
const isProviderName = (value) => value !== "" && value.split("").every((character) => SLUG_CHARACTERS.has(character));
|
|
49
|
-
const Provider = String$1.check(makeFilter(isProviderName, {
|
|
50
|
-
expected: "a provider name of lowercase letters, digits, and hyphens",
|
|
51
|
-
toJsonSchema: () => ({ minLength: 1 })
|
|
52
|
-
})).annotate({
|
|
53
|
-
description: `A provider name of lowercase letters, digits, and hyphens, such as ${PROVIDER_EXAMPLES}. The API adds providers over time, so a client accepts any such name and the API refuses one it does not serve.`,
|
|
54
|
-
examples: PROVIDERS,
|
|
55
|
-
identifier: "Provider"
|
|
56
|
-
});
|
|
57
|
-
const Region = NonEmptyString.annotate({
|
|
58
|
-
description: "A coarse region, such as `asia`, `eu`, or `us`. A sandbox runs in a data center of the routed provider inside that region. The API adds regions over time.",
|
|
59
|
-
examples: [
|
|
60
|
-
"asia",
|
|
61
|
-
"eu",
|
|
62
|
-
"us"
|
|
63
|
-
],
|
|
64
|
-
identifier: "Region"
|
|
65
|
-
});
|
|
66
|
-
const GpuType = NonEmptyString.annotate({
|
|
67
|
-
description: "A GPU model, such as `h100`, `b200`, `rtx-pro-6000`, or `mi355x`. The API adds types over time.",
|
|
68
|
-
examples: [
|
|
69
|
-
"b200",
|
|
70
|
-
"b300",
|
|
71
|
-
"h100",
|
|
72
|
-
"h200",
|
|
73
|
-
"mi355x",
|
|
74
|
-
"rtx-4090",
|
|
75
|
-
"rtx-5090",
|
|
76
|
-
"rtx-pro-6000"
|
|
77
|
-
],
|
|
78
|
-
identifier: "GpuType"
|
|
79
|
-
});
|
|
80
|
-
const isUtcTimestamp = makeFilter((value) => {
|
|
81
|
-
const at = Date.parse(value);
|
|
82
|
-
return Number.isFinite(at) && new Date(at).toISOString() === value;
|
|
83
|
-
}, {
|
|
84
|
-
expected: "a UTC timestamp such as 2026-11-08T11:20:00.000Z",
|
|
85
|
-
toJsonSchema: () => ({ format: "date-time" })
|
|
86
|
-
});
|
|
87
|
-
const Timestamp = String$1.check(isUtcTimestamp).annotate({ description: "A UTC instant with milliseconds and a `Z` suffix, such as `2026-11-08T11:20:00.000Z`." });
|
|
88
|
-
const MicroUsd = Natural.annotate({ description: "An amount in integer micro-dollars: 1,000,000 is 1 USD." });
|
|
89
|
-
const isUuidV7 = is(String$1.check(isUUID(7)));
|
|
90
|
-
const hasPrefixedUuid = (value, prefix) => value.startsWith(prefix) && isUuidV7(value.slice(prefix.length));
|
|
91
|
-
const prefixedId = (prefix, noun) => String$1.check(makeFilter((value) => hasPrefixedUuid(value, prefix), {
|
|
92
|
-
expected: `${prefix} followed by a UUID v7`,
|
|
93
|
-
toJsonSchema: () => ({})
|
|
94
|
-
})).annotate({ description: `${noun} ID: \`${prefix}\` followed by a UUID v7.` });
|
|
95
|
-
const SandboxId = prefixedId("sbx_", "Sandbox");
|
|
96
|
-
const SnapshotId = prefixedId("snap_", "Snapshot");
|
|
97
|
-
const CiJobId = prefixedId("cij_", "CI job");
|
|
98
|
-
const CredentialId = prefixedId("cred_", "Provider credential");
|
|
99
|
-
const ProcessId = prefixedId("proc_", "Process");
|
|
100
|
-
const UsageShareId = prefixedId("ush_", "Usage share");
|
|
101
|
-
const API_KEY_ID_PREFIX = "key_";
|
|
102
|
-
const MANAGEMENT_KEY_ID_PREFIX = "mkey_";
|
|
103
|
-
const ApiKeyId = prefixedId(API_KEY_ID_PREFIX, "API key");
|
|
104
|
-
const KeyId = String$1.check(makeFilter((value) => hasPrefixedUuid(value, API_KEY_ID_PREFIX) || hasPrefixedUuid(value, MANAGEMENT_KEY_ID_PREFIX), {
|
|
105
|
-
expected: `${API_KEY_ID_PREFIX} or ${MANAGEMENT_KEY_ID_PREFIX} followed by a UUID v7`,
|
|
106
|
-
toJsonSchema: () => ({})
|
|
107
|
-
})).annotate({ description: `Key ID: \`${API_KEY_ID_PREFIX}\` for an API key or \`${MANAGEMENT_KEY_ID_PREFIX}\` for a management key, followed by a UUID v7.` });
|
|
108
|
-
const SECRET_TEXT_LENGTH = 43;
|
|
109
|
-
const isBase64Url = is(String$1.check(isBase64Url$1()));
|
|
110
|
-
const API_KEY_SECRET_PREFIX = "sand_";
|
|
111
|
-
const MANAGEMENT_KEY_SECRET_PREFIX = "sandm_";
|
|
112
|
-
const hasPrefixedSecret = (value, prefix) => value.startsWith(prefix) && value.length === prefix.length + SECRET_TEXT_LENGTH && isBase64Url(value.slice(prefix.length));
|
|
113
|
-
const KeySecret = String$1.check(makeFilter((value) => hasPrefixedSecret(value, API_KEY_SECRET_PREFIX) || hasPrefixedSecret(value, MANAGEMENT_KEY_SECRET_PREFIX), {
|
|
114
|
-
expected: `${API_KEY_SECRET_PREFIX} or ${MANAGEMENT_KEY_SECRET_PREFIX} followed by 43 base64url characters`,
|
|
115
|
-
toJsonSchema: () => ({})
|
|
116
|
-
})).annotate({ description: `The key secret, returned once at creation: \`${API_KEY_SECRET_PREFIX}\` for an API key or \`${MANAGEMENT_KEY_SECRET_PREFIX}\` for a management key, followed by 32 random bytes as 43 unpadded base64url characters.` });
|
|
117
|
-
const ActivityAction = NonEmptyString.annotate({
|
|
118
|
-
description: "What happened, such as `sandbox.create`, `sandbox.create_attempt` for each provider tried, `sandbox.destroy`, or `sandbox.expire` at the TTL. The API adds actions over time.",
|
|
119
|
-
examples: [
|
|
120
|
-
"sandbox.create",
|
|
121
|
-
"sandbox.create_attempt",
|
|
122
|
-
"sandbox.destroy",
|
|
123
|
-
"sandbox.expire",
|
|
124
|
-
"sandbox.pause",
|
|
125
|
-
"sandbox.resume",
|
|
126
|
-
"sandbox.snapshot"
|
|
127
|
-
],
|
|
128
|
-
identifier: "ActivityAction"
|
|
129
|
-
});
|
|
130
|
-
const ActivityEvent = Struct({
|
|
131
|
-
action: ActivityAction,
|
|
132
|
-
api_key_id: NullOr(ApiKeyId),
|
|
133
|
-
at: Timestamp,
|
|
134
|
-
error: NullOr(String$1).annotate({ description: "Why the action failed, or null when it succeeded." }),
|
|
135
|
-
id: NonEmptyString,
|
|
136
|
-
outcome: Literals(["failed", "succeeded"]),
|
|
137
|
-
provider: NullOr(Provider),
|
|
138
|
-
sandbox_id: NullOr(SandboxId)
|
|
139
|
-
}).annotate({
|
|
140
|
-
description: "One entry of the activity log, which records every sandbox lifecycle call and create attempt.",
|
|
141
|
-
identifier: "ActivityEvent"
|
|
142
|
-
});
|
|
143
|
-
const ActivityList = Struct({
|
|
144
|
-
data: ArraySchema(ActivityEvent),
|
|
145
|
-
next_cursor: NullOr(String$1)
|
|
146
|
-
}).annotate({ identifier: "ActivityList" });
|
|
147
|
-
// ../sandcovery-contract/src/errors/concurrency-limit-reached.ts
|
|
148
|
-
var ConcurrencyLimitReached = class extends Error$1("ConcurrencyLimitReached")({
|
|
149
|
-
concurrency_cap: Natural,
|
|
150
|
-
error: tag("concurrency_limit_reached"),
|
|
151
|
-
message: String$1
|
|
152
|
-
}, {
|
|
153
|
-
description: "The API key already has `concurrency_cap` live sandboxes, its `max_concurrent_sandboxes`. Destroy one or wait for one to end.",
|
|
154
|
-
httpApiStatus: 429,
|
|
155
|
-
identifier: "ConcurrencyLimitReached"
|
|
156
|
-
}) {
|
|
157
|
-
[ignore] = true;
|
|
158
|
-
};
|
|
159
|
-
// ../sandcovery-contract/src/errors/conflict.ts
|
|
160
|
-
var Conflict = class extends Error$1("Conflict")({
|
|
161
|
-
error: tag("conflict"),
|
|
162
|
-
message: String$1
|
|
163
|
-
}, {
|
|
164
|
-
description: "The request clashes with the current state, such as an `Idempotency-Key` reused with a different body, a call on a sandbox that is not running, or deleting a provider credential that live sandboxes still use.",
|
|
165
|
-
httpApiStatus: 409,
|
|
166
|
-
identifier: "Conflict"
|
|
167
|
-
}) {
|
|
168
|
-
[ignore] = true;
|
|
169
|
-
};
|
|
170
|
-
// ../sandcovery-contract/src/errors/forbidden.ts
|
|
171
|
-
var Forbidden = class extends Error$1("Forbidden")({
|
|
172
|
-
error: tag("forbidden"),
|
|
173
|
-
message: String$1
|
|
174
|
-
}, {
|
|
175
|
-
description: "The credential is valid but may not make this call, such as a management key on a sandbox, an API key on keys, usage, or provider credentials, a member who is not an owner on keys, a member who is not an owner or admin on usage or provider credentials, a signed-in member who is not an owner or admin, or their agent, on sandbox create, a management key whose minting owner is no longer an owner on keys, or a TTL over the API key's `max_ttl_seconds`. `message` names the rule.",
|
|
176
|
-
httpApiStatus: 403,
|
|
177
|
-
identifier: "Forbidden"
|
|
178
|
-
}) {
|
|
179
|
-
[ignore] = true;
|
|
180
|
-
};
|
|
181
|
-
// ../sandcovery-contract/src/errors/invalid-request.ts
|
|
182
|
-
var InvalidRequest = class extends Error$1("InvalidRequest")({
|
|
183
|
-
error: tag("invalid_request"),
|
|
184
|
-
message: String$1
|
|
185
|
-
}, {
|
|
186
|
-
description: "The path, query, headers, or body do not decode against the operation, or contradict each other, and `message` names the failure.",
|
|
187
|
-
httpApiStatus: 400,
|
|
188
|
-
identifier: "InvalidRequest"
|
|
189
|
-
}) {
|
|
190
|
-
[ignore] = true;
|
|
191
|
-
};
|
|
192
|
-
const StandardSize = NonEmptyString.annotate({
|
|
193
|
-
description: "A standard size named `<vCPU>x<memory GiB>`, such as `1x2`, `2x4`, `4x8`, or `8x16`. The API adds sizes over time.",
|
|
194
|
-
examples: [
|
|
195
|
-
{
|
|
196
|
-
memory_mib: 2048,
|
|
197
|
-
name: "1x2",
|
|
198
|
-
vcpu: 1
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
memory_mib: 4096,
|
|
202
|
-
name: "2x4",
|
|
203
|
-
vcpu: 2
|
|
204
|
-
},
|
|
205
|
-
{
|
|
206
|
-
memory_mib: 8192,
|
|
207
|
-
name: "4x8",
|
|
208
|
-
vcpu: 4
|
|
209
|
-
},
|
|
210
|
-
{
|
|
211
|
-
memory_mib: 16384,
|
|
212
|
-
name: "8x16",
|
|
213
|
-
vcpu: 8
|
|
214
|
-
}
|
|
215
|
-
].map(({ name }) => name),
|
|
216
|
-
identifier: "StandardSize"
|
|
217
|
-
});
|
|
218
|
-
const ProviderSort = Literals([
|
|
219
|
-
"latency",
|
|
220
|
-
"price",
|
|
221
|
-
"uptime"
|
|
222
|
-
]).annotate({
|
|
223
|
-
description: "Candidate order: `price` by list price, `latency` by measured create latency, and `uptime` by uptime over the last 15 minutes, or over a provider's own probe interval where it is probed less often.",
|
|
224
|
-
identifier: "ProviderSort"
|
|
225
|
-
});
|
|
226
|
-
const ROUTER = "sandcovery";
|
|
227
|
-
const DEFAULT_SLUG = `${ROUTER}/2x4`;
|
|
228
|
-
const MIB_PER_GIB = 1024;
|
|
229
|
-
const ANY = "n";
|
|
230
|
-
const vcpusOf = (text) => {
|
|
231
|
-
if (text === ANY) return null;
|
|
232
|
-
const value = Number(text);
|
|
233
|
-
return Number.isSafeInteger(value) && value > 0 && String(value) === text ? value : void 0;
|
|
234
|
-
};
|
|
235
|
-
const memoryGibOf = (text) => {
|
|
236
|
-
if (text === ANY) return null;
|
|
237
|
-
const value = Number(text);
|
|
238
|
-
return String(value) === text && value > 0 && Number.isSafeInteger(value * MIB_PER_GIB) ? value : void 0;
|
|
239
|
-
};
|
|
240
|
-
const parseSlug = (text) => {
|
|
241
|
-
const [provider = "", size = "", ...extraPaths] = text.split("/");
|
|
242
|
-
const [dimensions = "", suffix, ...extraSuffixes] = size.split(":");
|
|
243
|
-
const [vcpuText = "", memoryText = "", ...extraParts] = dimensions.split("x");
|
|
244
|
-
if (extraPaths.length + extraSuffixes.length + extraParts.length > 0 || suffix === "" || !isProviderName(provider)) return;
|
|
245
|
-
const vcpus = vcpusOf(vcpuText);
|
|
246
|
-
const memoryGib = memoryGibOf(memoryText);
|
|
247
|
-
return vcpus === void 0 || memoryGib === void 0 ? void 0 : {
|
|
248
|
-
memoryGib,
|
|
249
|
-
provider,
|
|
250
|
-
suffix: suffix ?? null,
|
|
251
|
-
vcpus
|
|
252
|
-
};
|
|
253
|
-
};
|
|
254
|
-
const isSizeName = (text) => {
|
|
255
|
-
const parsed = parseSlug(`${ROUTER}/${text}`);
|
|
256
|
-
return parsed !== void 0 && parsed.suffix === null && parsed.vcpus !== null && parsed.memoryGib !== null;
|
|
257
|
-
};
|
|
258
|
-
const SizeName = String$1.check(makeFilter(isSizeName, {
|
|
259
|
-
expected: "<vcpu>x<memory_gib>, such as 2x4 or 2x0.5",
|
|
260
|
-
toJsonSchema: () => ({ minLength: 1 })
|
|
261
|
-
}));
|
|
262
|
-
const SLUG_EXAMPLES = [
|
|
263
|
-
`${ROUTER}/2x4`,
|
|
264
|
-
`${ROUTER}/2x4:cheapest`,
|
|
265
|
-
`${ROUTER}/nx16:cheapest`,
|
|
266
|
-
`${ROUTER}/2xn:fastest`,
|
|
267
|
-
`${ROUTER}/nxn:most-reliable`,
|
|
268
|
-
"boat/2x4",
|
|
269
|
-
"e2b/2x0.5"
|
|
270
|
-
];
|
|
271
|
-
const Slug = String$1.check(makeFilter((text) => parseSlug(text) !== void 0, {
|
|
272
|
-
expected: "<provider>/<vcpu>x<memory_gib>, optionally followed by a routing suffix",
|
|
273
|
-
toJsonSchema: () => ({ minLength: 1 })
|
|
274
|
-
})).annotate({
|
|
275
|
-
description: `A provider and size, written \`<provider>/<vcpu>x<memory_gib>\` and optionally followed by a routing suffix, in the shape of OpenRouter model slugs. A provider name such as \`boat\` or \`e2b\` pins that provider, and \`${ROUTER}\` routes across every candidate provider. \`2x4\` is 2 vCPU and 4 GiB, and memory may be any whole number of MiB written in GiB, such as \`2x0.5\` or \`2x1.5\`. Either number may be \`n\`, meaning any value: \`nx16\` is any vCPU count with 16 GiB, \`2xn\` is 2 vCPU with any memory, and \`nxn\` is any size, and each provider then runs its cheapest size that matches. \`:cheapest\` sorts candidates by list price, \`:fastest\` by measured create latency, and \`:most-reliable\` by uptime over the last 15 minutes, or over a provider's own probe interval where it is probed less often. A slug with no suffix routes as \`:cheapest\`. A malformed slug or an unknown suffix answers 400 \`invalid_request\`, and a slug that no candidate provider can run answers 422 \`unsupported\`, listing slugs that would run as \`options\`.`,
|
|
276
|
-
examples: SLUG_EXAMPLES,
|
|
277
|
-
identifier: "Slug"
|
|
278
|
-
});
|
|
279
|
-
const ROUTING_FIELDS_TEXT = `\`slug\` is the provider and size to run, as OpenRouter takes \`model\`, and \`slugs\` lists slugs to try in order, as OpenRouter takes \`models\`. With both, \`slug\` is tried first. With neither, the slug is \`${DEFAULT_SLUG}\`.`;
|
|
280
|
-
const RoutingFields = {
|
|
281
|
-
slug: optionalKey(Slug),
|
|
282
|
-
slugs: optionalKey(ArraySchema(Slug).check(isMinLength(1), isMaxLength(8)).annotate({ description: `Slugs to try in order, from 1 to ${String(8)}, as OpenRouter takes \`models\`. Within a \`${ROUTER}/\` slug, a failed create (capacity, quota, a provider 5xx, or a timeout) first falls back across that slug's candidates, then the create moves to the next slug. A provider is tried at most once a create, at the size of the first slug that reaches it.` }))
|
|
283
|
-
};
|
|
284
|
-
const ProviderPreferences = Struct({
|
|
285
|
-
allow_fallbacks: optionalKey(Boolean.annotate({ description: "Whether a failed create (capacity, quota, a provider 5xx, or a timeout) moves to the next candidate of the same slug. Defaults to true. With false, each slug tries only its first candidate, and the create still moves on to the next slug." })),
|
|
286
|
-
ignore: optionalKey(ArraySchema(Provider).annotate({ description: "Providers never to route to." })),
|
|
287
|
-
only: optionalKey(ArraySchema(Provider).annotate({ description: "The only providers to route to." })),
|
|
288
|
-
order: optionalKey(ArraySchema(Provider).annotate({ description: `Providers a \`${ROUTER}/\` slug tries first, in this order, before its remaining candidates in sorted order.` })),
|
|
289
|
-
sort: optionalKey(ProviderSort)
|
|
290
|
-
}).annotate({
|
|
291
|
-
description: `Routing preferences in the shape of OpenRouter provider preferences, applied to every slug: \`only\`, \`ignore\`, and the API key's provider allowlist filter each slug's candidates. A slug's suffix sets \`sort\` for that slug, and a slug whose suffix disagrees with \`sort\` answers 400 \`invalid_request\`.`,
|
|
292
|
-
identifier: "ProviderPreferences"
|
|
293
|
-
});
|
|
294
|
-
// ../sandcovery-contract/src/sandbox.ts
|
|
295
|
-
const MAX_TTL_SECONDS = 86400;
|
|
296
|
-
const MAX_PORT = 65535;
|
|
297
|
-
const MAX_PORTS = 8;
|
|
298
|
-
const MAX_GPUS = 8;
|
|
299
|
-
const between = (minimum, maximum) => Int.check(isBetween({
|
|
300
|
-
maximum,
|
|
301
|
-
minimum
|
|
302
|
-
}));
|
|
303
|
-
const Port = between(1, MAX_PORT);
|
|
304
|
-
const Gpu = Struct({
|
|
305
|
-
count: between(1, MAX_GPUS).annotate({ description: "How many GPUs of `type` the sandbox gets, from 1 to 8." }),
|
|
306
|
-
type: GpuType
|
|
307
|
-
}).annotate({
|
|
308
|
-
description: "GPUs for the sandbox. It runs only on a provider that runs `count` GPUs of `type`, which picks the sandbox's region itself, so a GPU sandbox takes no `region`. Its list price adds each GPU's hourly price to the price of its size.",
|
|
309
|
-
identifier: "Gpu"
|
|
310
|
-
});
|
|
311
|
-
const EnvironmentVariables = Record(NonEmptyString, String$1).annotate({ description: "Environment variables by name. Sandcovery passes them to the provider and never returns them." });
|
|
312
|
-
const EgressPolicy = Union([
|
|
313
|
-
Struct({ mode: Literal("allow_all") }),
|
|
314
|
-
Struct({ mode: Literal("deny_all") }),
|
|
315
|
-
Struct({
|
|
316
|
-
destinations: NonEmptyArray(NonEmptyString).annotate({ description: "Host names or CIDR blocks the sandbox may reach." }),
|
|
317
|
-
mode: Literal("allowlist")
|
|
318
|
-
})
|
|
319
|
-
]).annotate({
|
|
320
|
-
description: "Outbound network access: `allow_all`, `deny_all`, or `allowlist` with the destinations the sandbox may reach.",
|
|
321
|
-
identifier: "EgressPolicy"
|
|
322
|
-
});
|
|
323
|
-
const SandboxSpec = Struct({
|
|
324
|
-
disk_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(1024)).annotate({ description: "Disk size in MiB. Defaults to the provider default." })),
|
|
325
|
-
egress: optionalKey(EgressPolicy),
|
|
326
|
-
env: optionalKey(EnvironmentVariables),
|
|
327
|
-
gpu: optionalKey(Gpu),
|
|
328
|
-
idle_timeout_seconds: optionalKey(Int.check(isGreaterThanOrEqualTo(60)).annotate({ description: "Seconds without a running command after which the provider pauses the sandbox. Unset means no idle timeout." })),
|
|
329
|
-
image: optionalKey(NonEmptyString.annotate({ description: "An OCI image reference. Unset means the provider's default Linux image." })),
|
|
330
|
-
ports: optionalKey(ArraySchema(Port).check(isMaxLength(MAX_PORTS)).annotate({ description: "Ports to expose for preview URLs. Some providers expose only ports declared at create." })),
|
|
331
|
-
region: optionalKey(Region),
|
|
332
|
-
ttl_seconds: optionalKey(between(60, MAX_TTL_SECONDS).annotate({ description: "Seconds from creation after which Sandcovery destroys the sandbox, even when the client is gone. Defaults to 3600, and the API key may cap it lower." }))
|
|
333
|
-
});
|
|
334
|
-
const CreateSandboxRequest = Struct({
|
|
335
|
-
...SandboxSpec.fields,
|
|
336
|
-
...RoutingFields,
|
|
337
|
-
provider: optionalKey(ProviderPreferences),
|
|
338
|
-
snapshot_id: optionalKey(SnapshotId.annotate({ description: "A snapshot to start from. The sandbox runs on the snapshot's provider." }))
|
|
339
|
-
}).annotate({
|
|
340
|
-
description: `A sandbox spec, the slug or slugs to run it on, and routing preferences. ${ROUTING_FIELDS_TEXT} A spec option that no candidate provider can enforce answers 422 \`unsupported\` and is never ignored.`,
|
|
341
|
-
identifier: "CreateSandboxRequest"
|
|
342
|
-
});
|
|
343
|
-
const CreateAttempt = Struct({
|
|
344
|
-
duration_ms: Natural,
|
|
345
|
-
failure: NullOr(Struct({
|
|
346
|
-
message: String$1,
|
|
347
|
-
reason: Literals([
|
|
348
|
-
"capacity",
|
|
349
|
-
"quota",
|
|
350
|
-
"rejected",
|
|
351
|
-
"server_error",
|
|
352
|
-
"timeout"
|
|
353
|
-
]).annotate({ identifier: "CreateFailureReason" })
|
|
354
|
-
}).annotate({ description: "Why the attempt failed: `capacity`, `quota`, `server_error` (a provider 5xx), and `timeout` fall back to the next candidate when `allow_fallbacks` is not false, while `rejected` (any other provider refusal, such as an invalid credential) stops the create, which answers 502 `provider_error` naming that provider." })),
|
|
355
|
-
provider: Provider,
|
|
356
|
-
started_at: Timestamp
|
|
357
|
-
}).annotate({
|
|
358
|
-
description: "One provider create call made while routing a sandbox. `failure` is null on the attempt that created it.",
|
|
359
|
-
identifier: "CreateAttempt"
|
|
360
|
-
});
|
|
361
|
-
const SandboxStatus = Literals([
|
|
362
|
-
"creating",
|
|
363
|
-
"destroyed",
|
|
364
|
-
"destroying",
|
|
365
|
-
"failed",
|
|
366
|
-
"paused",
|
|
367
|
-
"running"
|
|
368
|
-
]).annotate({ identifier: "SandboxStatus" });
|
|
369
|
-
const SandboxEndReason = Literals([
|
|
370
|
-
"create_failed",
|
|
371
|
-
"destroyed",
|
|
372
|
-
"expired",
|
|
373
|
-
"gone"
|
|
374
|
-
]).annotate({
|
|
375
|
-
description: "Why the sandbox ended: `create_failed` when no create attempt succeeded, `destroyed` by a destroy call, `expired` at its TTL, or `gone` when the provider no longer had it.",
|
|
376
|
-
identifier: "SandboxEndReason"
|
|
377
|
-
});
|
|
378
|
-
const SandboxCost = Struct({
|
|
379
|
-
estimated_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost so far, from the rate card, until the sandbox is destroyed." }),
|
|
380
|
-
hourly_micro_usd: MicroUsd,
|
|
381
|
-
rate_card_version: String$1
|
|
382
|
-
}).annotate({
|
|
383
|
-
description: "Estimated cost at the provider's list price from a versioned rate card. The provider bills your own account.",
|
|
384
|
-
identifier: "SandboxCost"
|
|
385
|
-
});
|
|
386
|
-
const Sandbox = Struct({
|
|
387
|
-
api_key_id: NullOr(ApiKeyId).annotate({ description: "The API key that created the sandbox, or null when an organization owner or admin created it while signed in, or their agent did on their session." }),
|
|
388
|
-
attempts: ArraySchema(CreateAttempt),
|
|
389
|
-
cost: SandboxCost,
|
|
390
|
-
created_at: Timestamp,
|
|
391
|
-
disk_mib: NullOr(Natural),
|
|
392
|
-
egress: EgressPolicy,
|
|
393
|
-
end_reason: NullOr(SandboxEndReason),
|
|
394
|
-
ended_at: NullOr(Timestamp),
|
|
395
|
-
expires_at: Timestamp,
|
|
396
|
-
gpu: NullOr(Gpu),
|
|
397
|
-
id: SandboxId,
|
|
398
|
-
idle_timeout_seconds: NullOr(Natural),
|
|
399
|
-
image: NullOr(String$1),
|
|
400
|
-
memory_mib: Natural.annotate({ description: "Memory of the bound size, or of the first candidate's size while the sandbox is creating or after every create attempt failed." }),
|
|
401
|
-
ports: ArraySchema(Port),
|
|
402
|
-
provider: NullOr(Provider).annotate({ description: "The provider the sandbox is bound to, or null while it is creating or when every create attempt failed." }),
|
|
403
|
-
provider_sandbox_id: NullOr(String$1),
|
|
404
|
-
region: NullOr(Region),
|
|
405
|
-
slug: NullOr(Slug).annotate({ description: "The provider and size the sandbox runs on, such as `boat/2x4`, as OpenRouter answers the `model` it used, or null while it is creating or when every create attempt failed." }),
|
|
406
|
-
started_at: NullOr(Timestamp).annotate({ description: "When the provider reported the sandbox running." }),
|
|
407
|
-
status: SandboxStatus,
|
|
408
|
-
ttl_seconds: Natural,
|
|
409
|
-
vcpu: Natural.annotate({ description: "vCPU count of the bound size, or of the first candidate's size while the sandbox is creating or after every create attempt failed." })
|
|
410
|
-
}).annotate({
|
|
411
|
-
description: "A sandbox, bound to the provider that created it. `expires_at` is when Sandcovery destroys it, and pausing does not move it. `ended_at` and `end_reason` are set once it ends.",
|
|
412
|
-
identifier: "Sandbox"
|
|
413
|
-
});
|
|
414
|
-
const SandboxList = Struct({
|
|
415
|
-
data: ArraySchema(Sandbox),
|
|
416
|
-
next_cursor: NullOr(String$1)
|
|
417
|
-
}).annotate({ identifier: "SandboxList" });
|
|
418
|
-
const Snapshot = Struct({
|
|
419
|
-
created_at: Timestamp,
|
|
420
|
-
id: SnapshotId,
|
|
421
|
-
provider: Provider,
|
|
422
|
-
sandbox_id: SandboxId
|
|
423
|
-
}).annotate({
|
|
424
|
-
description: "A snapshot of a sandbox filesystem. A sandbox created from it runs on the same provider.",
|
|
425
|
-
identifier: "Snapshot"
|
|
426
|
-
});
|
|
427
|
-
const PortPreview = Struct({
|
|
428
|
-
expires_at: NullOr(Timestamp),
|
|
429
|
-
headers: Record(String$1, String$1).annotate({ description: "Headers a request to `url` must carry, such as a provider preview token. Often empty." }),
|
|
430
|
-
port: Port,
|
|
431
|
-
url: String$1
|
|
432
|
-
}).annotate({
|
|
433
|
-
description: "A provider URL that reaches a port inside the sandbox.",
|
|
434
|
-
identifier: "PortPreview"
|
|
435
|
-
});
|
|
436
|
-
// ../sandcovery-contract/src/errors/no-provider-available.ts
|
|
437
|
-
var NoProviderAvailable = class extends Error$1("NoProviderAvailable")({
|
|
438
|
-
attempts: ArraySchema(CreateAttempt).annotate({ description: "Every create attempt, in order. Empty when no provider was a candidate, such as when none has a stored credential." }),
|
|
439
|
-
error: tag("no_provider_available"),
|
|
440
|
-
message: String$1
|
|
441
|
-
}, {
|
|
442
|
-
description: "Every candidate provider failed to create the sandbox, or none was left after filtering.",
|
|
443
|
-
httpApiStatus: 503,
|
|
444
|
-
identifier: "NoProviderAvailable"
|
|
445
|
-
}) {};
|
|
446
|
-
// ../sandcovery-contract/src/errors/not-found.ts
|
|
447
|
-
var NotFound = class extends Error$1("NotFound")({
|
|
448
|
-
error: tag("not_found"),
|
|
449
|
-
message: String$1
|
|
450
|
-
}, {
|
|
451
|
-
description: "The resource the path names does not exist or belongs to another organization or key.",
|
|
452
|
-
httpApiStatus: 404,
|
|
453
|
-
identifier: "NotFound"
|
|
454
|
-
}) {
|
|
455
|
-
[ignore] = true;
|
|
456
|
-
};
|
|
457
|
-
// ../sandcovery-contract/src/errors/provider-error.ts
|
|
458
|
-
var ProviderError = class extends Error$1("ProviderError")({
|
|
459
|
-
error: tag("provider_error"),
|
|
460
|
-
message: String$1,
|
|
461
|
-
provider: Provider
|
|
462
|
-
}, {
|
|
463
|
-
description: "The sandbox's provider failed the call. `message` carries the provider's reason.",
|
|
464
|
-
httpApiStatus: 502,
|
|
465
|
-
identifier: "ProviderError"
|
|
466
|
-
}) {};
|
|
467
|
-
// ../sandcovery-contract/src/errors/rate-limited.ts
|
|
468
|
-
var RateLimited = class extends Error$1("RateLimited")({
|
|
469
|
-
error: tag("rate_limited"),
|
|
470
|
-
message: String$1
|
|
471
|
-
}, {
|
|
472
|
-
description: "The caller sent this operation more requests than its limit allows, such as more than 3 problem reports a minute. Wait a minute and try again.",
|
|
473
|
-
httpApiStatus: 429,
|
|
474
|
-
identifier: "RateLimited"
|
|
475
|
-
}) {
|
|
476
|
-
[ignore] = true;
|
|
477
|
-
};
|
|
478
|
-
// ../sandcovery-contract/src/errors/spend-limit-reached.ts
|
|
479
|
-
var SpendLimitReached = class extends Error$1("SpendLimitReached")({
|
|
480
|
-
error: tag("spend_limit_reached"),
|
|
481
|
-
limit_micro_usd: MicroUsd,
|
|
482
|
-
message: String$1,
|
|
483
|
-
resets_at: NullOr(Timestamp),
|
|
484
|
-
spent_micro_usd: MicroUsd
|
|
485
|
-
}, {
|
|
486
|
-
description: "The API key's spend limit leaves too little for the sandbox's full TTL at list price. `resets_at` is when the window resets, or null for a `total` limit.",
|
|
487
|
-
httpApiStatus: 402,
|
|
488
|
-
identifier: "SpendLimitReached"
|
|
489
|
-
}) {
|
|
490
|
-
[ignore] = true;
|
|
491
|
-
};
|
|
492
|
-
// ../sandcovery-contract/src/errors/unauthorized.ts
|
|
493
|
-
var Unauthorized = class extends Error$1("Unauthorized")({
|
|
494
|
-
error: tag("unauthorized"),
|
|
495
|
-
message: String$1
|
|
496
|
-
}, {
|
|
497
|
-
description: "The request carries no live key and no signed-in session, or a key that is unknown, revoked, or expired.",
|
|
498
|
-
httpApiStatus: 401,
|
|
499
|
-
identifier: "Unauthorized"
|
|
500
|
-
}) {
|
|
501
|
-
[ignore] = true;
|
|
502
|
-
};
|
|
503
|
-
// ../sandcovery-contract/src/errors/unsupported.ts
|
|
504
|
-
var Unsupported = class extends Error$1("Unsupported")({
|
|
505
|
-
error: tag("unsupported"),
|
|
506
|
-
message: String$1,
|
|
507
|
-
options: ArraySchema(String$1).annotate({ description: "Slugs that would run for this request: each refused slug at the sizes its candidates run, then, for a slug that pins a provider, the `sandcovery/` slug at the size it asked for. Empty when nothing near the refused slugs would run, such as a spec field no candidate provider can enforce or an operation the bound provider lacks, and then `message` names that field or operation." }),
|
|
508
|
-
provider: NullOr(Provider).annotate({ description: "The sandbox's provider for an operation on an existing sandbox, or null for a create." })
|
|
509
|
-
}, {
|
|
510
|
-
description: "A slug, spec option, or operation that no candidate provider can serve. Sandcovery never ignores an option. For a slug, `options` lists slugs that would run; otherwise `options` is empty and `message` names the field or operation.",
|
|
511
|
-
httpApiStatus: 422,
|
|
512
|
-
identifier: "Unsupported"
|
|
513
|
-
}) {
|
|
514
|
-
[ignore] = true;
|
|
515
|
-
};
|
|
516
|
-
// ../sandcovery-contract/src/errors/api-error.ts
|
|
517
|
-
const ApiError = Union([
|
|
518
|
-
ConcurrencyLimitReached,
|
|
519
|
-
Conflict,
|
|
520
|
-
Forbidden,
|
|
521
|
-
InvalidRequest,
|
|
522
|
-
NoProviderAvailable,
|
|
523
|
-
NotFound,
|
|
524
|
-
ProviderError,
|
|
525
|
-
RateLimited,
|
|
526
|
-
SpendLimitReached,
|
|
527
|
-
Unauthorized,
|
|
528
|
-
Unsupported
|
|
529
|
-
]);
|
|
530
|
-
// ../sandcovery-contract/src/attach.ts
|
|
531
|
-
const ATTACH_PROTOCOL = "sandcovery-attach-v1";
|
|
532
|
-
const STDIN = 0;
|
|
533
|
-
const STDOUT = 1;
|
|
534
|
-
const STDERR = 2;
|
|
535
|
-
const HEADER_BYTES = 9;
|
|
536
|
-
const CHUNK_BYTES = 65536;
|
|
537
|
-
const UNACKNOWLEDGED_LIMIT_BYTES = 8388608;
|
|
538
|
-
const NORMAL_CLOSURE = 1e3;
|
|
539
|
-
const REPLACED = 4e3;
|
|
540
|
-
const RETRY_MS = [
|
|
541
|
-
250,
|
|
542
|
-
1e3,
|
|
543
|
-
2e3,
|
|
544
|
-
5e3
|
|
545
|
-
];
|
|
546
|
-
const CHECK_MS = 15e3;
|
|
547
|
-
const LOST = "The sandbox ended before the process reported an exit, so its exit is unknown.";
|
|
548
|
-
const REPLACED_MESSAGE = "Another client attached to the process, which detached this one.";
|
|
549
|
-
const ABORTED = "The attach was aborted.";
|
|
550
|
-
const OUTPUT_NAMES = /* @__PURE__ */ new Map([[STDOUT, "stdout"], [STDERR, "stderr"]]);
|
|
551
|
-
const RelayMessageSchema = Union([
|
|
552
|
-
Struct({ type: Literals(["ready", "waiting"]) }),
|
|
553
|
-
Struct({
|
|
554
|
-
offset: Number$1,
|
|
555
|
-
stream: Literal("stdin"),
|
|
556
|
-
type: Literal("ack")
|
|
557
|
-
}),
|
|
558
|
-
Struct({
|
|
559
|
-
code: Int,
|
|
560
|
-
signal: NullOr(String$1),
|
|
561
|
-
type: Literal("exit")
|
|
562
|
-
})
|
|
563
|
-
]);
|
|
564
|
-
const decodeRelayMessage = decodeUnknownOption(fromJsonString(RelayMessageSchema));
|
|
565
|
-
const isApiError = is(ApiError);
|
|
566
|
-
const frame = (stream, offset, data) => {
|
|
567
|
-
const bytes = new Uint8Array(HEADER_BYTES + data.length);
|
|
568
|
-
bytes[0] = stream;
|
|
569
|
-
new DataView(bytes.buffer).setBigUint64(1, BigInt(offset));
|
|
570
|
-
bytes.set(data, HEADER_BYTES);
|
|
571
|
-
return bytes;
|
|
572
|
-
};
|
|
573
|
-
const control = (message) => JSON.stringify(message);
|
|
574
|
-
const abortError = (signal) => {
|
|
575
|
-
const reason = signal?.reason;
|
|
576
|
-
return reason instanceof Error ? reason : new Error(ABORTED, { cause: reason });
|
|
577
|
-
};
|
|
578
|
-
var Attachment = class {
|
|
579
|
-
#done = Promise.withResolvers();
|
|
580
|
-
#received = /* @__PURE__ */ new Map();
|
|
581
|
-
#sinks;
|
|
582
|
-
#target;
|
|
583
|
-
#drained = [];
|
|
584
|
-
#ended = false;
|
|
585
|
-
#finished = false;
|
|
586
|
-
#ready = false;
|
|
587
|
-
#retries = 0;
|
|
588
|
-
#signals = [];
|
|
589
|
-
#size;
|
|
590
|
-
#socket = null;
|
|
591
|
-
#stdinAcked = 0;
|
|
592
|
-
#stdinEnd = 0;
|
|
593
|
-
#synced = false;
|
|
594
|
-
#timer;
|
|
595
|
-
#unacknowledged = [];
|
|
596
|
-
#aborted = () => {
|
|
597
|
-
this.#fail(abortError(this.#target.options.signal));
|
|
598
|
-
};
|
|
599
|
-
constructor(target) {
|
|
600
|
-
this.#target = target;
|
|
601
|
-
this.#sinks = /* @__PURE__ */ new Map([[STDOUT, target.options.stdout], [STDERR, target.options.stderr]]);
|
|
602
|
-
const { signal } = target.options;
|
|
603
|
-
if (signal?.aborted === true) this.#fail(abortError(signal));
|
|
604
|
-
else {
|
|
605
|
-
signal?.addEventListener("abort", this.#aborted, { once: true });
|
|
606
|
-
this.#connect();
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
get exit() {
|
|
610
|
-
return this.#done.promise;
|
|
611
|
-
}
|
|
612
|
-
async write(data) {
|
|
613
|
-
if (this.#ended || this.#finished) return;
|
|
614
|
-
for (let start = 0; start < data.length; start += CHUNK_BYTES) {
|
|
615
|
-
const chunk = data.slice(start, start + CHUNK_BYTES);
|
|
616
|
-
const offset = this.#stdinEnd;
|
|
617
|
-
this.#unacknowledged.push({
|
|
618
|
-
data: chunk,
|
|
619
|
-
offset
|
|
620
|
-
});
|
|
621
|
-
this.#stdinEnd += chunk.length;
|
|
622
|
-
if (this.#live()) this.#socket?.send(frame(STDIN, offset, chunk));
|
|
623
|
-
}
|
|
624
|
-
if (this.#stdinEnd - this.#stdinAcked > UNACKNOWLEDGED_LIMIT_BYTES) {
|
|
625
|
-
const drained = Promise.withResolvers();
|
|
626
|
-
this.#drained.push(drained);
|
|
627
|
-
await drained.promise;
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
endStdin() {
|
|
631
|
-
if (this.#ended || this.#finished) return;
|
|
632
|
-
this.#ended = true;
|
|
633
|
-
if (this.#live()) this.#socket?.send(this.#eof());
|
|
634
|
-
}
|
|
635
|
-
resize(cols, rows) {
|
|
636
|
-
this.#size = {
|
|
637
|
-
cols,
|
|
638
|
-
rows
|
|
639
|
-
};
|
|
640
|
-
if (this.#live()) this.#socket?.send(control({
|
|
641
|
-
cols,
|
|
642
|
-
rows,
|
|
643
|
-
type: "resize"
|
|
644
|
-
}));
|
|
645
|
-
}
|
|
646
|
-
sendSignal(name) {
|
|
647
|
-
if (this.#finished) return;
|
|
648
|
-
if (this.#live()) this.#socket?.send(control({
|
|
649
|
-
name,
|
|
650
|
-
type: "signal"
|
|
651
|
-
}));
|
|
652
|
-
else this.#signals.push(name);
|
|
653
|
-
}
|
|
654
|
-
#live() {
|
|
655
|
-
return this.#ready && this.#synced;
|
|
656
|
-
}
|
|
657
|
-
#eof() {
|
|
658
|
-
return control({
|
|
659
|
-
offset: this.#stdinEnd,
|
|
660
|
-
stream: "stdin",
|
|
661
|
-
type: "eof"
|
|
662
|
-
});
|
|
663
|
-
}
|
|
664
|
-
#connect() {
|
|
665
|
-
const { credential, url } = this.#target;
|
|
666
|
-
const socket = new WebSocket(url, credential === null ? [ATTACH_PROTOCOL] : [ATTACH_PROTOCOL, credential]);
|
|
667
|
-
socket.binaryType = "arraybuffer";
|
|
668
|
-
socket.addEventListener("message", (event) => {
|
|
669
|
-
this.#message(event);
|
|
670
|
-
});
|
|
671
|
-
socket.addEventListener("close", (event) => {
|
|
672
|
-
this.#closed(socket, event.code);
|
|
673
|
-
});
|
|
674
|
-
this.#socket = socket;
|
|
675
|
-
this.#watch();
|
|
676
|
-
}
|
|
677
|
-
#closed(socket, code) {
|
|
678
|
-
if (socket !== this.#socket || this.#finished) return;
|
|
679
|
-
this.#socket = null;
|
|
680
|
-
this.#ready = false;
|
|
681
|
-
if (code === REPLACED) {
|
|
682
|
-
this.#fail(/* @__PURE__ */ new Error(REPLACED_MESSAGE));
|
|
683
|
-
return;
|
|
684
|
-
}
|
|
685
|
-
const delay = RETRY_MS[Math.min(this.#retries, RETRY_MS.length - 1)];
|
|
686
|
-
this.#retries += 1;
|
|
687
|
-
clearTimeout(this.#timer);
|
|
688
|
-
this.#timer = setTimeout(() => {
|
|
689
|
-
this.#reconnect();
|
|
690
|
-
}, delay);
|
|
691
|
-
}
|
|
692
|
-
async #reconnect() {
|
|
693
|
-
if (await this.#alive() && this.#socket === null) this.#connect();
|
|
694
|
-
}
|
|
695
|
-
#watch() {
|
|
696
|
-
clearTimeout(this.#timer);
|
|
697
|
-
this.#timer = setTimeout(() => {
|
|
698
|
-
this.#keepWatching();
|
|
699
|
-
}, CHECK_MS);
|
|
700
|
-
}
|
|
701
|
-
async #keepWatching() {
|
|
702
|
-
if (await this.#alive() && !this.#ready && this.#socket !== null) this.#watch();
|
|
703
|
-
}
|
|
704
|
-
async #alive() {
|
|
705
|
-
const [checked] = await Promise.allSettled([this.#target.check()]);
|
|
706
|
-
if (checked.status === "fulfilled" && checked.value.status === "lost") this.#fail(/* @__PURE__ */ new Error(LOST));
|
|
707
|
-
if (checked.status === "rejected") {
|
|
708
|
-
const reason = checked.reason;
|
|
709
|
-
if (isApiError(reason)) this.#fail(reason);
|
|
710
|
-
}
|
|
711
|
-
return !this.#finished;
|
|
712
|
-
}
|
|
713
|
-
#message(event) {
|
|
714
|
-
const data = event.data;
|
|
715
|
-
if (data instanceof ArrayBuffer) {
|
|
716
|
-
this.#output(new Uint8Array(data));
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
const decoded = decodeRelayMessage(data);
|
|
720
|
-
if (isSome(decoded)) this.#control(decoded.value);
|
|
721
|
-
}
|
|
722
|
-
#control(message) {
|
|
723
|
-
switch (message.type) {
|
|
724
|
-
case "ready":
|
|
725
|
-
this.#ready = true;
|
|
726
|
-
this.#retries = 0;
|
|
727
|
-
clearTimeout(this.#timer);
|
|
728
|
-
if (this.#synced) this.#resend();
|
|
729
|
-
break;
|
|
730
|
-
case "waiting":
|
|
731
|
-
this.#ready = false;
|
|
732
|
-
this.#watch();
|
|
733
|
-
break;
|
|
734
|
-
case "ack":
|
|
735
|
-
this.#acknowledgeStdin(message.offset);
|
|
736
|
-
break;
|
|
737
|
-
case "exit": this.#finish({
|
|
738
|
-
code: message.code,
|
|
739
|
-
signal: message.signal
|
|
740
|
-
});
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
#resend() {
|
|
744
|
-
for (const { data, offset } of this.#unacknowledged) this.#socket?.send(frame(STDIN, offset, data));
|
|
745
|
-
if (this.#ended) this.#socket?.send(this.#eof());
|
|
746
|
-
if (this.#size !== void 0) this.#socket?.send(control({
|
|
747
|
-
...this.#size,
|
|
748
|
-
type: "resize"
|
|
749
|
-
}));
|
|
750
|
-
for (const name of this.#signals) this.#socket?.send(control({
|
|
751
|
-
name,
|
|
752
|
-
type: "signal"
|
|
753
|
-
}));
|
|
754
|
-
this.#signals = [];
|
|
755
|
-
}
|
|
756
|
-
#rebase(base) {
|
|
757
|
-
this.#synced = true;
|
|
758
|
-
this.#stdinAcked = base;
|
|
759
|
-
this.#stdinEnd += base;
|
|
760
|
-
this.#unacknowledged = this.#unacknowledged.map(({ data, offset }) => ({
|
|
761
|
-
data,
|
|
762
|
-
offset: offset + base
|
|
763
|
-
}));
|
|
764
|
-
if (this.#ready) this.#resend();
|
|
765
|
-
}
|
|
766
|
-
#acknowledgeStdin(offset) {
|
|
767
|
-
if (!this.#synced) {
|
|
768
|
-
this.#rebase(offset);
|
|
769
|
-
return;
|
|
770
|
-
}
|
|
771
|
-
this.#stdinAcked = Math.max(this.#stdinAcked, offset);
|
|
772
|
-
this.#unacknowledged = this.#unacknowledged.filter((chunk) => chunk.offset + chunk.data.length > this.#stdinAcked);
|
|
773
|
-
if (this.#stdinEnd - this.#stdinAcked <= UNACKNOWLEDGED_LIMIT_BYTES) this.#release();
|
|
774
|
-
}
|
|
775
|
-
#output(bytes) {
|
|
776
|
-
const stream = bytes[0] ?? STDIN;
|
|
777
|
-
const name = OUTPUT_NAMES.get(stream);
|
|
778
|
-
if (bytes.length < HEADER_BYTES || name === void 0) return;
|
|
779
|
-
const offset = Number(new DataView(bytes.buffer, bytes.byteOffset).getBigUint64(1));
|
|
780
|
-
const known = this.#received.get(stream) ?? offset;
|
|
781
|
-
const data = bytes.subarray(HEADER_BYTES);
|
|
782
|
-
if (offset > known) return;
|
|
783
|
-
const fresh = data.subarray(known - offset);
|
|
784
|
-
const received = known + fresh.length;
|
|
785
|
-
if (fresh.length > 0) {
|
|
786
|
-
this.#received.set(stream, received);
|
|
787
|
-
this.#sinks.get(stream)?.(fresh);
|
|
788
|
-
}
|
|
789
|
-
this.#socket?.send(control({
|
|
790
|
-
offset: received,
|
|
791
|
-
stream: name,
|
|
792
|
-
type: "ack"
|
|
793
|
-
}));
|
|
794
|
-
}
|
|
795
|
-
#release() {
|
|
796
|
-
const waiting = this.#drained;
|
|
797
|
-
this.#drained = [];
|
|
798
|
-
for (const drained of waiting) drained.resolve(void 0);
|
|
799
|
-
}
|
|
800
|
-
#stop() {
|
|
801
|
-
this.#finished = true;
|
|
802
|
-
this.#ready = false;
|
|
803
|
-
clearTimeout(this.#timer);
|
|
804
|
-
this.#target.options.signal?.removeEventListener("abort", this.#aborted);
|
|
805
|
-
this.#socket?.close(NORMAL_CLOSURE);
|
|
806
|
-
this.#socket = null;
|
|
807
|
-
this.#release();
|
|
808
|
-
}
|
|
809
|
-
#finish(exit) {
|
|
810
|
-
if (!this.#finished) {
|
|
811
|
-
this.#stop();
|
|
812
|
-
this.#done.resolve(exit);
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
#fail(error) {
|
|
816
|
-
if (!this.#finished) {
|
|
817
|
-
this.#stop();
|
|
818
|
-
this.#done.reject(error);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
};
|
|
822
|
-
const attach = (target) => {
|
|
823
|
-
const attachment = new Attachment(target);
|
|
824
|
-
return {
|
|
825
|
-
endStdin: () => {
|
|
826
|
-
attachment.endStdin();
|
|
827
|
-
},
|
|
828
|
-
exit: attachment.exit,
|
|
829
|
-
resize: (cols, rows) => {
|
|
830
|
-
attachment.resize(cols, rows);
|
|
831
|
-
},
|
|
832
|
-
sendSignal: (name) => {
|
|
833
|
-
attachment.sendSignal(name);
|
|
834
|
-
},
|
|
835
|
-
write: async (data) => {
|
|
836
|
-
await attachment.write(data);
|
|
837
|
-
}
|
|
838
|
-
};
|
|
839
|
-
};
|
|
840
|
-
// ../sandcovery-contract/src/billing.ts
|
|
841
|
-
const FREE_PLAN = "free";
|
|
842
|
-
const ENTERPRISE_PLAN = "enterprise";
|
|
843
|
-
const MICRO_USD_PER_CENT = 1e4;
|
|
844
|
-
const MICRO_USD_PER_DOLLAR = 1e6;
|
|
845
|
-
const CREDIT_PURCHASE_MIN_MICRO_USD = 25 * MICRO_USD_PER_DOLLAR;
|
|
846
|
-
const CREDIT_PURCHASE_MAX_MICRO_USD = 1e3 * MICRO_USD_PER_DOLLAR;
|
|
847
|
-
const CARD_FEE_TERMS = "2.9% plus 30 cents";
|
|
848
|
-
const NO_MARKUP_TERMS = [
|
|
849
|
-
"Sandbox usage carries no markup.",
|
|
850
|
-
"On your own provider keys, each provider bills you at its own prices, and Sandcovery charges nothing for that usage.",
|
|
851
|
-
`Credits pay each provider's list price for a sandbox's size, from its start until it ends, and a card processing fee of ${CARD_FEE_TERMS} comes out of each credit purchase.`,
|
|
852
|
-
"Beyond list prices and that fee, Sandcovery charges only for its Pro and Enterprise plans, each a fixed fee for each organization."
|
|
853
|
-
].join(" ");
|
|
854
|
-
const BASIS_POINTS = 1e4;
|
|
855
|
-
const CARD_FEE_BASIS_POINTS = 290;
|
|
856
|
-
const CARD_FEE_FIXED_MICRO_USD = 30 * MICRO_USD_PER_CENT;
|
|
857
|
-
const creditsAfterFeeMicroUsd = (paidMicroUsd) => {
|
|
858
|
-
const paidCents = paidMicroUsd / MICRO_USD_PER_CENT;
|
|
859
|
-
return paidMicroUsd - Math.round(paidCents * CARD_FEE_BASIS_POINTS / BASIS_POINTS) * MICRO_USD_PER_CENT - CARD_FEE_FIXED_MICRO_USD;
|
|
860
|
-
};
|
|
861
|
-
const AUTO_TOP_UP_THRESHOLD_MIN_MICRO_USD = MICRO_USD_PER_DOLLAR;
|
|
862
|
-
const AUTO_TOP_UP_THRESHOLD_MAX_MICRO_USD = Math.floor((creditsAfterFeeMicroUsd(CREDIT_PURCHASE_MAX_MICRO_USD) - 1) / MICRO_USD_PER_DOLLAR) * MICRO_USD_PER_DOLLAR;
|
|
863
|
-
const thresholdBelowTopUp = ({ amountMicroUsd, thresholdMicroUsd }) => thresholdMicroUsd < creditsAfterFeeMicroUsd(amountMicroUsd);
|
|
864
|
-
const Plan = Literals([
|
|
865
|
-
FREE_PLAN,
|
|
866
|
-
"pro",
|
|
867
|
-
ENTERPRISE_PLAN
|
|
868
|
-
]).annotate({
|
|
869
|
-
description: "The organization plan: the higher of the plan of its Stripe subscription while that subscription is active, trialing, or past due, and the plan of a GitHub Marketplace purchase by a GitHub account it connected to Sandcovery CI, otherwise `free`. `enterprise` is Pro for an organization that connects a GitHub account a GitHub Enterprise owns.",
|
|
870
|
-
identifier: "Plan"
|
|
871
|
-
});
|
|
872
|
-
const PlanBiller = Literals(["github_marketplace", "stripe"]).annotate({
|
|
873
|
-
description: "Who bills a paid plan: `stripe` for a Stripe subscription, and `github_marketplace` for a GitHub Marketplace purchase, which an owner of the buying GitHub organization changes or cancels in its settings under Billing and licensing.",
|
|
874
|
-
identifier: "PlanBiller"
|
|
875
|
-
});
|
|
876
|
-
const ProInterval = Literals([
|
|
877
|
-
"day",
|
|
878
|
-
"month",
|
|
879
|
-
"week",
|
|
880
|
-
"year"
|
|
881
|
-
]).annotate({
|
|
882
|
-
description: "How often the plan fee is charged.",
|
|
883
|
-
identifier: "ProInterval"
|
|
884
|
-
});
|
|
885
|
-
const ProPrice = Struct({
|
|
886
|
-
interval: ProInterval,
|
|
887
|
-
micro_usd: MicroUsd
|
|
888
|
-
}).annotate({
|
|
889
|
-
description: "The fixed fee of a plan for each billing interval.",
|
|
890
|
-
identifier: "ProPrice"
|
|
891
|
-
});
|
|
892
|
-
const EnterprisePrice = NullOr(ProPrice).annotate({ description: "The Enterprise price, or null while the Enterprise plan is not on sale." });
|
|
893
|
-
const AutoTopUp = Struct({
|
|
894
|
-
amount_micro_usd: NullOr(MicroUsd).annotate({ description: "Whole US dollars each top-up charges to the saved card, or null before auto top-up was first turned on." }),
|
|
895
|
-
enabled: Boolean.annotate({ description: "Whether a saved card is charged once the credit balance falls below the threshold, or a create is refused for credits that one top-up covers." }),
|
|
896
|
-
failed_at: NullOr(Timestamp).annotate({ description: "When a failed top-up turned auto top-up off, or null. Turning it on again clears it." }),
|
|
897
|
-
failure: NullOr(String$1).annotate({ description: "Why a failed top-up turned auto top-up off, such as a declined card, a card that asks its holder to authenticate, or a disputed payment, or null. Turning it on again clears it." }),
|
|
898
|
-
threshold_micro_usd: NullOr(MicroUsd).annotate({ description: "The credit balance below which a top-up is charged, or null before auto top-up was first turned on." })
|
|
899
|
-
}).annotate({
|
|
900
|
-
description: `Auto top-up: while it is on, each time the credit balance falls below the threshold, the saved card is charged the amount once, off session, and the credit, the amount less the processing fee of ${CARD_FEE_TERMS}, arrives once Stripe confirms the charge. It charges only while credits are on sale, and a failed charge turns it off.`,
|
|
901
|
-
identifier: "AutoTopUp"
|
|
902
|
-
});
|
|
903
|
-
const Billing = Struct({
|
|
904
|
-
auto_top_up: AutoTopUp,
|
|
905
|
-
credit_balance_micro_usd: Int.annotate({ description: "Credits bought, less refunds and held disputes up to each purchase's credit, the list-price cost of each ended sandbox paid with credits, and the full-TTL hold of each live one. A refund or dispute after use can take it below zero." }),
|
|
906
|
-
credits_on_sale: Boolean.annotate({ description: "Whether a credit purchase is open." }),
|
|
907
|
-
enterprise_price: EnterprisePrice,
|
|
908
|
-
github_enterprise: Boolean.annotate({ description: "Whether a GitHub Enterprise owns a GitHub account this organization connected to Sandcovery CI, so that its jobs run only on the Enterprise plan." }),
|
|
909
|
-
plan: Plan,
|
|
910
|
-
plan_billers: ArraySchema(PlanBiller).annotate({ description: "Who bills each paid plan the organization holds, each biller once: `stripe` while its Stripe subscription grants `plan` or a lower paid plan, and `github_marketplace` while a GitHub Marketplace purchase does. Empty on `free`." }),
|
|
911
|
-
pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
|
|
912
|
-
}).annotate({ identifier: "Billing" });
|
|
913
|
-
const CreditTerms = Struct({
|
|
914
|
-
fee_fixed_micro_usd: MicroUsd.annotate({ description: "The fixed part of the processing fee that comes out of each credit purchase." }),
|
|
915
|
-
fee_rate_basis_points: Natural.annotate({ description: "The part of the processing fee that grows with the payment, in basis points of it, rounded to the cent: 290 is 2.9%." }),
|
|
916
|
-
max_micro_usd: MicroUsd.annotate({ description: "The largest credit purchase, in whole US dollars." }),
|
|
917
|
-
min_micro_usd: MicroUsd.annotate({ description: "The smallest credit purchase, in whole US dollars." })
|
|
918
|
-
}).annotate({
|
|
919
|
-
description: "How credits are bought: a payment in whole US dollars between the two bounds adds credit equal to the payment less the processing fee, spent at each provider list price.",
|
|
920
|
-
identifier: "CreditTerms"
|
|
921
|
-
});
|
|
922
|
-
const Pricing = Struct({
|
|
923
|
-
credits: CreditTerms,
|
|
924
|
-
enterprise_price: EnterprisePrice,
|
|
925
|
-
pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
|
|
926
|
-
}).annotate({
|
|
927
|
-
description: "The public prices: the Pro and Enterprise prices for one organization and the terms of a credit purchase.",
|
|
928
|
-
identifier: "Pricing"
|
|
929
|
-
});
|
|
930
|
-
const CreditAmount = MicroUsd.check(isMultipleOf(MICRO_USD_PER_DOLLAR), isBetween({
|
|
931
|
-
maximum: CREDIT_PURCHASE_MAX_MICRO_USD,
|
|
932
|
-
minimum: CREDIT_PURCHASE_MIN_MICRO_USD
|
|
933
|
-
})).annotate({ description: `Whole US dollars charged to the card, from 25 to 1,000 USD. The credits granted are this amount less the processing fee of ${CARD_FEE_TERMS}, rounded to the cent.` });
|
|
934
|
-
Struct({ amount_micro_usd: CreditAmount }).annotate({ identifier: "CreditPurchaseRequest" });
|
|
935
|
-
Struct({
|
|
936
|
-
amount_micro_usd: CreditAmount,
|
|
937
|
-
threshold_micro_usd: MicroUsd.check(isMultipleOf(MICRO_USD_PER_DOLLAR), isBetween({
|
|
938
|
-
maximum: AUTO_TOP_UP_THRESHOLD_MAX_MICRO_USD,
|
|
939
|
-
minimum: AUTO_TOP_UP_THRESHOLD_MIN_MICRO_USD
|
|
940
|
-
})).annotate({ description: "Whole US dollars, from 1 to 970 USD, and below the credit one top-up adds, so that one top-up lifts the balance back above it: a 25 USD top-up adds 23.97 USD, so its threshold is at most 23 USD." })
|
|
941
|
-
}).annotate({ identifier: "AutoTopUpRequest" });
|
|
942
|
-
const AutoTopUpChange = Struct({
|
|
943
|
-
auto_top_up: AutoTopUp,
|
|
944
|
-
url: NullOr(String$1).annotate({ description: "The Stripe Checkout page that saves a card and then turns auto top-up on with these settings, or null when auto top-up was on and the settings apply at once." })
|
|
945
|
-
}).annotate({ identifier: "AutoTopUpChange" });
|
|
946
|
-
const CreditCheckout = Struct({ url: String$1.annotate({ description: "The Stripe Checkout page that takes the payment. The credits arrive once Stripe confirms it." }) }).annotate({ identifier: "CreditCheckout" });
|
|
947
|
-
// ../sandcovery-contract/src/providers.ts
|
|
948
|
-
const Ratio = Finite.check(isBetween({
|
|
949
|
-
maximum: 1,
|
|
950
|
-
minimum: 0
|
|
951
|
-
})).annotate({ description: "A share from 0 to 1." });
|
|
952
|
-
const EgressMode = NonEmptyString.annotate({
|
|
953
|
-
description: "An egress policy mode the provider can enforce, such as `allow_all`, `allowlist`, or `deny_all`. The API adds modes over time.",
|
|
954
|
-
examples: [
|
|
955
|
-
"allow_all",
|
|
956
|
-
"allowlist",
|
|
957
|
-
"deny_all"
|
|
958
|
-
],
|
|
959
|
-
identifier: "EgressMode"
|
|
960
|
-
});
|
|
961
|
-
const ProviderFeatures = Struct({
|
|
962
|
-
custom_image: Boolean,
|
|
963
|
-
egress_modes: ArraySchema(EgressMode),
|
|
964
|
-
gpu_types: ArraySchema(GpuType).annotate({ description: "The GPU types a sandbox on this provider can get, up to 8 GPUs of one type. Empty when the provider runs no GPU sandbox." }),
|
|
965
|
-
idle_timeout: Boolean,
|
|
966
|
-
max_disk_mib: NullOr(Natural).annotate({ description: "The largest disk size in MiB the provider takes, or null when it takes no disk size." }),
|
|
967
|
-
max_memory_mib: Natural.annotate({ description: "The most memory in MiB the provider runs. For a provider that states no memory ceiling, such as Depot, it is the memory of the largest standard size the provider runs." }),
|
|
968
|
-
max_ttl_seconds: Natural.annotate({ description: "The longest TTL in seconds. For a provider that states no TTL limit, such as Sprites, it is Sandcovery's own maximum of 86,400, which Sandcovery enforces by destroying the sandbox." }),
|
|
969
|
-
max_vcpu: Natural,
|
|
970
|
-
pause: Boolean,
|
|
971
|
-
ports: Boolean,
|
|
972
|
-
regions: ArraySchema(Region),
|
|
973
|
-
snapshot: Boolean,
|
|
974
|
-
streamed_exec: Boolean
|
|
975
|
-
}).annotate({
|
|
976
|
-
description: "What the provider can enforce. A spec asking for more answers `unsupported` on that provider.",
|
|
977
|
-
identifier: "ProviderFeatures"
|
|
978
|
-
});
|
|
979
|
-
const CredentialField = Struct({
|
|
980
|
-
label: NonEmptyString.annotate({ description: "The field name to show a person, such as \"Team ID\"." }),
|
|
981
|
-
name: NonEmptyString.annotate({ description: "The key of the field in `PUT /api/v1/credentials/{provider}`, such as `team_id`." }),
|
|
982
|
-
secret: Boolean.annotate({ description: "Whether to mask the value while it is typed." })
|
|
983
|
-
}).annotate({
|
|
984
|
-
description: "One field of a provider credential.",
|
|
985
|
-
identifier: "CredentialField"
|
|
986
|
-
});
|
|
987
|
-
const ProviderStatus = Literals([
|
|
988
|
-
"degraded",
|
|
989
|
-
"down",
|
|
990
|
-
"operational",
|
|
991
|
-
"unknown"
|
|
992
|
-
]).annotate({ identifier: "ProviderStatus" });
|
|
993
|
-
const BrandImage = Struct({
|
|
994
|
-
source_url: String$1.annotate({ description: "The provider's own page or file the image was copied from, such as its brand page or the favicon its home page declares." }),
|
|
995
|
-
tile: Boolean.annotate({ description: "Whether the image stands out on this theme's background only on a tile of the other theme's background, because the provider publishes no variant for this theme." }),
|
|
996
|
-
url: String$1.annotate({ description: "Sandcovery's own copy of the image." })
|
|
997
|
-
}).annotate({ identifier: "BrandImage" });
|
|
998
|
-
const ThemedBrandImage = Struct({
|
|
999
|
-
dark: BrandImage,
|
|
1000
|
-
light: BrandImage
|
|
1001
|
-
}).annotate({
|
|
1002
|
-
description: "The provider's own variants of an image for a light and a dark background. Where the provider publishes one variant, both name the same file.",
|
|
1003
|
-
identifier: "ThemedBrandImage"
|
|
1004
|
-
});
|
|
1005
|
-
const securityFact = (value) => Struct({
|
|
1006
|
-
detail: NullOr(String$1).annotate({ description: "A sentence that qualifies the value, or null." }),
|
|
1007
|
-
read_at: Timestamp.annotate({ description: "The UTC day Sandcovery read the provider's page." }),
|
|
1008
|
-
source_changed_at: NullOr(Timestamp).annotate({ description: "When Sandcovery's daily check first found the visible text of `source_url` changed since its first check after `read_at`, or null while it reads the same, so a non-null value means the fact may be out of date." }),
|
|
1009
|
-
source_url: String$1.annotate({ description: "The provider's public page that states the value." }),
|
|
1010
|
-
value
|
|
1011
|
-
});
|
|
1012
|
-
const SecurityText = securityFact(String$1).annotate({
|
|
1013
|
-
description: "A security fact a provider states, with the page and the day it was read.",
|
|
1014
|
-
identifier: "SecurityText"
|
|
1015
|
-
});
|
|
1016
|
-
const SecurityList = securityFact(ArraySchema(String$1)).annotate({
|
|
1017
|
-
description: "A list of names a provider states, with the page and the day it was read.",
|
|
1018
|
-
identifier: "SecurityList"
|
|
1019
|
-
});
|
|
1020
|
-
const ProviderSecurity = Struct({
|
|
1021
|
-
compliance: NullOr(SecurityList).annotate({ description: "The audits and certifications the provider states, or null when its pages state none." }),
|
|
1022
|
-
data_location: NullOr(SecurityText).annotate({ description: "Where the provider says customer data sits, or null when its pages do not say." }),
|
|
1023
|
-
isolation: NullOr(SecurityText).annotate({ description: "How the provider isolates one sandbox from another, or null when its pages do not say." })
|
|
1024
|
-
}).annotate({
|
|
1025
|
-
description: "What the provider's own pages state about its security.",
|
|
1026
|
-
identifier: "ProviderSecurity"
|
|
1027
|
-
});
|
|
1028
|
-
const VendorIncident = Struct({
|
|
1029
|
-
id: NonEmptyString.annotate({ description: "The incident's ID on the provider's status page." }),
|
|
1030
|
-
impact: Literals([
|
|
1031
|
-
"none",
|
|
1032
|
-
"minor",
|
|
1033
|
-
"major",
|
|
1034
|
-
"critical",
|
|
1035
|
-
"maintenance"
|
|
1036
|
-
]).annotate({
|
|
1037
|
-
description: "The impact the provider states, on the Atlassian Statuspage scale: `none`, `minor`, `major`, or `critical`, or `maintenance` for planned work.",
|
|
1038
|
-
identifier: "IncidentImpact"
|
|
1039
|
-
}),
|
|
1040
|
-
resolved_at: NullOr(Timestamp).annotate({ description: "When the provider marked the incident resolved, or null while it is active." }),
|
|
1041
|
-
started_at: Timestamp,
|
|
1042
|
-
title: NonEmptyString,
|
|
1043
|
-
url: NonEmptyString.annotate({ description: "The incident's page on the provider's status page." })
|
|
1044
|
-
}).annotate({
|
|
1045
|
-
description: "One incident from the provider's own status page.",
|
|
1046
|
-
identifier: "VendorIncident"
|
|
1047
|
-
});
|
|
1048
|
-
const VendorIncidentRead = Struct({
|
|
1049
|
-
data: ArraySchema(VendorIncident).annotate({ description: "Active incidents first, then those resolved in the last 7 days, each group newest first." }),
|
|
1050
|
-
read_at: Timestamp.annotate({ description: "When Sandcovery last read the feed." }),
|
|
1051
|
-
source_url: NonEmptyString.annotate({ description: "The provider's public status feed Sandcovery reads." })
|
|
1052
|
-
}).annotate({
|
|
1053
|
-
description: "The last read of a provider status feed.",
|
|
1054
|
-
identifier: "VendorIncidentRead"
|
|
1055
|
-
});
|
|
1056
|
-
const VendorIncidents = NullOr(VendorIncidentRead).annotate({ description: "Incidents the provider's own status page reports, read every 5 minutes, or null when Sandcovery reads no status feed of the provider. A provider whose `status_url` is null publishes no status page." });
|
|
1057
|
-
const ProviderBoardEntry = Struct({
|
|
1058
|
-
create_latency_ms: Struct({
|
|
1059
|
-
p50: NullOr(Natural),
|
|
1060
|
-
p95: NullOr(Natural)
|
|
1061
|
-
}).annotate({ description: "Create latency of the probe sandboxes over the last 24 hours, or null before the first probe or when `docs_only_adapter` is true." }),
|
|
1062
|
-
credential_fields: ArraySchema(CredentialField).annotate({ description: "The fields a credential for this provider takes, in form order, so a client can ask for a provider it does not know." }),
|
|
1063
|
-
docs_only_adapter: Boolean.annotate({ description: "True when Sandcovery routes to the provider through an adapter written from the provider's public docs alone. Sandcovery has not run that adapter against the provider's service and runs no probe there, so `status` stays `unknown` and the `uptime` and `create_latency_ms` values stay null." }),
|
|
1064
|
-
favicon: NullOr(ThemedBrandImage).annotate({ description: "The provider's favicon for a light and a dark background, or null when Sandcovery shows no mark for the provider." }),
|
|
1065
|
-
features: ProviderFeatures,
|
|
1066
|
-
gpu_prices: ArraySchema(Struct({
|
|
1067
|
-
hourly_micro_usd: MicroUsd,
|
|
1068
|
-
type: GpuType
|
|
1069
|
-
})).annotate({ description: "List price per hour of one GPU of each type the provider runs, which a GPU sandbox adds to the price of its size. Empty when the provider runs no GPU sandbox." }),
|
|
1070
|
-
home_url: String$1.annotate({ description: "The provider's own home page." }),
|
|
1071
|
-
incidents: VendorIncidents,
|
|
1072
|
-
name: String$1,
|
|
1073
|
-
prices: ArraySchema(Struct({
|
|
1074
|
-
hourly_micro_usd: MicroUsd,
|
|
1075
|
-
size: StandardSize
|
|
1076
|
-
})).annotate({ description: "List price per hour of each standard size the provider can run. A provider that runs no standard size lists each size it does run instead, named `<vCPU>x<memory GiB>`, such as `2x0.5`, which a create asks for with `vcpu` and `memory_mib`." }),
|
|
1077
|
-
provider: Provider,
|
|
1078
|
-
rate_card_source_url: String$1.annotate({ description: "The provider's public pricing page the rate card copies." }),
|
|
1079
|
-
rate_card_version: String$1,
|
|
1080
|
-
security: ProviderSecurity,
|
|
1081
|
-
status: ProviderStatus,
|
|
1082
|
-
status_url: NullOr(String$1).annotate({ description: "The provider's own status page, or null when it publishes none." }),
|
|
1083
|
-
updated_at: Timestamp,
|
|
1084
|
-
uptime: Struct({
|
|
1085
|
-
last_15_minutes: NullOr(Ratio),
|
|
1086
|
-
last_24_hours: NullOr(Ratio),
|
|
1087
|
-
last_7_days: NullOr(Ratio)
|
|
1088
|
-
}).annotate({ description: "Share of probe creates that succeeded in each window, or null before the first probe or when `docs_only_adapter` is true. For a provider probed less often than every 5 minutes, `last_15_minutes` covers its own probe interval instead, so it holds the result of its last probe." })
|
|
1089
|
-
}).annotate({
|
|
1090
|
-
description: "One provider on the public provider board.",
|
|
1091
|
-
identifier: "ProviderBoardEntry"
|
|
1092
|
-
});
|
|
1093
|
-
const ProviderBoard = Struct({ data: ArraySchema(ProviderBoardEntry) }).annotate({ identifier: "ProviderBoard" });
|
|
1094
|
-
// ../sandcovery-contract/src/catalog.ts
|
|
1095
|
-
const fact = (value) => Struct({
|
|
1096
|
-
detail: NullOr(String$1).annotate({ description: "A sentence that qualifies the value, or null." }),
|
|
1097
|
-
source_url: NullOr(String$1).annotate({ description: "The provider's public page that states the value, or null when the value comes from Sandcovery's own adapter for the provider, whose pages are `adapter_source_urls`." }),
|
|
1098
|
-
value
|
|
1099
|
-
});
|
|
1100
|
-
const CatalogFlag = fact(Boolean).annotate({
|
|
1101
|
-
description: "A yes or no fact about a provider and where it was read.",
|
|
1102
|
-
identifier: "CatalogFlag"
|
|
1103
|
-
});
|
|
1104
|
-
const CatalogText = fact(String$1).annotate({
|
|
1105
|
-
description: "A short fact about a provider and where it was read.",
|
|
1106
|
-
identifier: "CatalogText"
|
|
1107
|
-
});
|
|
1108
|
-
const CatalogList = fact(ArraySchema(String$1)).annotate({
|
|
1109
|
-
description: "A list of names about a provider and where it was read.",
|
|
1110
|
-
identifier: "CatalogList"
|
|
1111
|
-
});
|
|
1112
|
-
const CatalogLimit = fact(NullOr(Natural)).annotate({
|
|
1113
|
-
description: "A ceiling and where it was read. A null `value` means the provider states that it sets no such ceiling.",
|
|
1114
|
-
identifier: "CatalogLimit"
|
|
1115
|
-
});
|
|
1116
|
-
const CatalogGpus = fact(ArraySchema(Struct({
|
|
1117
|
-
hourly_micro_usd: NullOr(MicroUsd).annotate({ description: "List price per hour of one GPU, or null when the provider publishes none." }),
|
|
1118
|
-
name: String$1.annotate({ description: "The GPU's name: a `GpuType` for a provider Sandcovery routes to, and the name on the provider's page otherwise." })
|
|
1119
|
-
}))).annotate({
|
|
1120
|
-
description: "The GPUs a sandbox can get and where the list was read. Empty when Sandcovery starts no GPU sandbox on a provider it routes to.",
|
|
1121
|
-
identifier: "CatalogGpus"
|
|
1122
|
-
});
|
|
1123
|
-
const CATALOG_MEASUREMENTS = ["measured", "not_measured"];
|
|
1124
|
-
const BENCHMARK_TERMS = [
|
|
1125
|
-
"barred",
|
|
1126
|
-
"conditional",
|
|
1127
|
-
"no_bar_found"
|
|
1128
|
-
];
|
|
1129
|
-
const ProviderCatalogEntry = Struct({
|
|
1130
|
-
adapter_source_urls: ArraySchema(String$1).annotate({ description: "The provider's public pages that Sandcovery's adapter for it was written from, which every fact with a null `source_url` traces to. Empty for a provider with no adapter." }),
|
|
1131
|
-
billing: NullOr(CatalogText).annotate({ description: "The unit the provider bills a sandbox in, such as per second or per session-hour." }),
|
|
1132
|
-
brand: Struct({
|
|
1133
|
-
favicon: NullOr(ThemedBrandImage),
|
|
1134
|
-
logo: NullOr(ThemedBrandImage)
|
|
1135
|
-
}).annotate({ description: "The provider's favicon and logo, each for a light and a dark background, and each null when Sandcovery shows no mark for the provider." }),
|
|
1136
|
-
capabilities: Struct({
|
|
1137
|
-
ci_runner: NullOr(CatalogFlag).annotate({ description: "Whether Sandcovery CI can start a GitHub Actions runner in a sandbox on the provider, with the reason in `detail` when it cannot, or null when Sandcovery has not run a runner there. A runner's just-in-time config reaches a sandbox only through the provider's exec environment or file API, never inside a command." }),
|
|
1138
|
-
custom_image: NullOr(CatalogFlag),
|
|
1139
|
-
environment: NullOr(CatalogFlag),
|
|
1140
|
-
files: NullOr(CatalogFlag),
|
|
1141
|
-
idle_timeout: NullOr(CatalogFlag),
|
|
1142
|
-
pause: NullOr(CatalogFlag),
|
|
1143
|
-
ports: NullOr(CatalogFlag),
|
|
1144
|
-
snapshot: NullOr(CatalogFlag),
|
|
1145
|
-
streamed_exec: NullOr(CatalogFlag)
|
|
1146
|
-
}).annotate({ description: "What a sandbox can do. For a provider Sandcovery routes to, each is what Sandcovery's adapter does there, and otherwise what the provider's pages state." }),
|
|
1147
|
-
create_latency_ms: Struct({
|
|
1148
|
-
p50: NullOr(Natural),
|
|
1149
|
-
p95: NullOr(Natural)
|
|
1150
|
-
}).annotate({ description: "Create latency of the probe sandboxes over the last 24 hours, or null unless `measurement` is `measured` and a probe has run." }),
|
|
1151
|
-
credential_fields: ArraySchema(CredentialField).annotate({ description: "The fields a credential for this provider takes. Empty for a provider that is coming soon." }),
|
|
1152
|
-
docs_only_adapter: Boolean.annotate({ description: "True when Sandcovery routes to the provider through an adapter written from the provider's public docs alone. Sandcovery has not run that adapter against the provider's service and runs no probe there, so `measurement` is `not_measured`." }),
|
|
1153
|
-
egress_modes: NullOr(CatalogList).annotate({ description: "The egress policy modes the provider can enforce, such as `allow_all`, `allowlist`, or `deny_all`." }),
|
|
1154
|
-
gpus: NullOr(CatalogGpus),
|
|
1155
|
-
incidents: VendorIncidents,
|
|
1156
|
-
limits: Struct({
|
|
1157
|
-
max_disk_mib: NullOr(CatalogLimit),
|
|
1158
|
-
max_memory_mib: NullOr(CatalogLimit),
|
|
1159
|
-
max_ttl_seconds: NullOr(CatalogLimit),
|
|
1160
|
-
max_vcpu: NullOr(CatalogLimit)
|
|
1161
|
-
}).annotate({ description: "The most one sandbox can get. For a provider Sandcovery routes to, each is the most Sandcovery starts there, and `max_disk_mib` is null when its adapter takes no disk size." }),
|
|
1162
|
-
links: Struct({
|
|
1163
|
-
docs_url: String$1,
|
|
1164
|
-
home_url: String$1,
|
|
1165
|
-
pricing_url: String$1,
|
|
1166
|
-
security_url: NullOr(String$1),
|
|
1167
|
-
status_url: NullOr(String$1),
|
|
1168
|
-
terms_url: String$1
|
|
1169
|
-
}).annotate({ description: "The provider's own public pages." }),
|
|
1170
|
-
measured_at: NullOr(Timestamp).annotate({ description: "When the uptime and create latency were last rolled up, or null when Sandcovery has measured none." }),
|
|
1171
|
-
measurement: Literals(CATALOG_MEASUREMENTS).annotate({
|
|
1172
|
-
description: "Whether the figures are measured: `measured` when Sandcovery probes the provider and publishes the result, and `not_measured` when it runs no probe there.",
|
|
1173
|
-
identifier: "CatalogMeasurement"
|
|
1174
|
-
}),
|
|
1175
|
-
name: String$1,
|
|
1176
|
-
policy: Struct({
|
|
1177
|
-
benchmark_terms: fact(Literals(BENCHMARK_TERMS)).annotate({
|
|
1178
|
-
description: "What the provider's terms say about publishing benchmarks of its service: `barred` when they forbid it, `conditional` when they allow it under a condition that `detail` states, and `no_bar_found` when a reading of the terms found no such clause.",
|
|
1179
|
-
identifier: "CatalogBenchmarkTerms"
|
|
1180
|
-
}),
|
|
1181
|
-
brand_terms: fact(Literals(BENCHMARK_TERMS)).annotate({
|
|
1182
|
-
description: "What the provider's terms or brand page say about showing its logo and favicon: `barred` when they need the provider's permission first, `conditional` when they allow it under a condition that `detail` states, and `no_bar_found` when a reading of the terms found no such clause.",
|
|
1183
|
-
identifier: "CatalogBrandTerms"
|
|
1184
|
-
}),
|
|
1185
|
-
compliance: ProviderSecurity.fields.compliance,
|
|
1186
|
-
data_location: ProviderSecurity.fields.data_location,
|
|
1187
|
-
free_allowance: NullOr(CatalogText).annotate({ description: "The free usage or credit the provider states." }),
|
|
1188
|
-
isolation: ProviderSecurity.fields.isolation,
|
|
1189
|
-
payment_required: NullOr(CatalogFlag).annotate({ description: "Whether an account needs a payment method before it starts a sandbox." }),
|
|
1190
|
-
plan_required: NullOr(CatalogFlag).annotate({ description: "Whether an account needs a paid plan before it starts a sandbox." }),
|
|
1191
|
-
read_at: Timestamp.annotate({ description: "The UTC day the provider's pages were read. Each security fact carries its own `read_at`, which is later for a fact read again since." }),
|
|
1192
|
-
sla: NullOr(CatalogText).annotate({ description: "The uptime commitment the provider states." })
|
|
1193
|
-
}).annotate({ description: "What the provider's terms and public pages state. A null fact means those pages do not state it." }),
|
|
1194
|
-
prices: ArraySchema(Struct({
|
|
1195
|
-
hourly_micro_usd: NullOr(MicroUsd),
|
|
1196
|
-
offered: NullOr(Boolean).annotate({ description: "Whether the provider runs the size, or null when its pages do not say which sizes a sandbox takes." }),
|
|
1197
|
-
size: StandardSize
|
|
1198
|
-
})).annotate({ description: "List price per hour of each standard size, then of each other size the provider runs, such as `2x0.5`, from the provider's vCPU and memory rates or its listed plan price. `hourly_micro_usd` is null when the provider does not run the size or its pages give no rate that prices it." }),
|
|
1199
|
-
provider: Provider,
|
|
1200
|
-
rates: NullOr(Struct({
|
|
1201
|
-
as_of: Timestamp.annotate({ description: "When the rates took effect on a provider Sandcovery routes to, and when the pricing page was read otherwise." }),
|
|
1202
|
-
detail: NullOr(String$1),
|
|
1203
|
-
memory_gib_hour_micro_usd: MicroUsd,
|
|
1204
|
-
source_url: String$1,
|
|
1205
|
-
vcpu_hour_micro_usd: MicroUsd
|
|
1206
|
-
})).annotate({ description: "List price of one vCPU and of one GiB of memory for an hour, or null when the provider prices no such unit." }),
|
|
1207
|
-
regions: NullOr(CatalogList).annotate({ description: "Where a sandbox can run: coarse `Region` names for a provider Sandcovery routes to, and the region names on the provider's page otherwise." }),
|
|
1208
|
-
routed: Boolean.annotate({ description: "Whether Sandcovery routes sandboxes to the provider. `false` means the provider is coming soon: Sandcovery does not route to it yet." }),
|
|
1209
|
-
sizes: NullOr(CatalogText).annotate({ description: "The sizes a sandbox comes in, each named `<vCPU>x<memory GiB>`, or a note that any size within the limits runs." }),
|
|
1210
|
-
status: ProviderStatus,
|
|
1211
|
-
uptime: Struct({
|
|
1212
|
-
last_15_minutes: NullOr(Ratio),
|
|
1213
|
-
last_24_hours: NullOr(Ratio),
|
|
1214
|
-
last_7_days: NullOr(Ratio)
|
|
1215
|
-
}).annotate({ description: "Share of probe creates that succeeded in each window, or null unless `measurement` is `measured` and a probe has run. For a provider probed less often than every 5 minutes, `last_15_minutes` covers its own probe interval instead, so it holds the result of its last probe." })
|
|
1216
|
-
}).annotate({
|
|
1217
|
-
description: "One sandbox provider in the catalog: what Sandcovery measured, and what the provider's public pages state. A null fact means those pages do not state it.",
|
|
1218
|
-
identifier: "ProviderCatalogEntry"
|
|
1219
|
-
});
|
|
1220
|
-
const ProviderCatalog = Struct({ data: ArraySchema(ProviderCatalogEntry) }).annotate({ identifier: "ProviderCatalog" });
|
|
1221
|
-
// ../sandcovery-contract/src/ci.ts
|
|
1222
|
-
const GitHubId = Int.check(isGreaterThanOrEqualTo(1));
|
|
1223
|
-
const CiJobStatus = Literals([
|
|
1224
|
-
"completed",
|
|
1225
|
-
"in_progress",
|
|
1226
|
-
"queued"
|
|
1227
|
-
]).annotate({
|
|
1228
|
-
description: "Where GitHub reports the job: `queued` until a runner takes it, `in_progress` while it runs, and `completed` once it ends.",
|
|
1229
|
-
identifier: "CiJobStatus"
|
|
1230
|
-
});
|
|
1231
|
-
const CiJobConclusion = NonEmptyString.annotate({
|
|
1232
|
-
description: "How GitHub concluded the job, such as `success`, `failure`, `cancelled`, `skipped`, or `timed_out`. GitHub adds conclusions over time.",
|
|
1233
|
-
examples: [
|
|
1234
|
-
"action_required",
|
|
1235
|
-
"cancelled",
|
|
1236
|
-
"failure",
|
|
1237
|
-
"neutral",
|
|
1238
|
-
"skipped",
|
|
1239
|
-
"success",
|
|
1240
|
-
"timed_out"
|
|
1241
|
-
],
|
|
1242
|
-
identifier: "CiJobConclusion"
|
|
1243
|
-
});
|
|
1244
|
-
const CiJob = Struct({
|
|
1245
|
-
completed_at: NullOr(Timestamp).annotate({ description: "When GitHub reported the job completed." }),
|
|
1246
|
-
conclusion: NullOr(CiJobConclusion),
|
|
1247
|
-
cost_micro_usd: NullOr(MicroUsd).annotate({ description: "The list-price cost of the runner sandbox that took the job, from the provider's rate card, so far while it runs and final once it ends. Null until a Sandcovery runner takes the job." }),
|
|
1248
|
-
duration_ms: NullOr(Natural).annotate({ description: "Milliseconds from start to completion. Null until the job completes." }),
|
|
1249
|
-
github_hosted_cost_micro_usd: NullOr(MicroUsd).annotate({ description: "What the same job costs on a GitHub-hosted x64 Linux runner: its duration rounded up to the whole minute, at GitHub's per-minute price for the smallest runner with at least the runner sandbox's vCPU. Null until the job completes on a Sandcovery runner, or when no GitHub-hosted runner has that many vCPU." }),
|
|
1250
|
-
id: CiJobId,
|
|
1251
|
-
job_name: String$1,
|
|
1252
|
-
provider: NullOr(Provider).annotate({ description: "The provider of the runner sandbox that took the job, or null until a Sandcovery runner takes it." }),
|
|
1253
|
-
queued_at: Timestamp,
|
|
1254
|
-
repository: NonEmptyString.annotate({ description: "The repository as `<owner>/<name>`." }),
|
|
1255
|
-
runner_error: NullOr(String$1).annotate({ description: "Why Sandcovery started no runner for the job, such as a create the API key refused, or null." }),
|
|
1256
|
-
runner_label: NonEmptyString.annotate({ description: "The Sandcovery runner label the job asked for, such as `sandcovery/4x16:cheapest`." }),
|
|
1257
|
-
sandbox_id: NullOr(SandboxId).annotate({ description: "The runner sandbox that took the job, or null until a Sandcovery runner takes it. A runner takes any queued job with its label, so it can differ from the sandbox started when this job was queued." }),
|
|
1258
|
-
started_at: NullOr(Timestamp).annotate({ description: "When GitHub reported a runner started the job." }),
|
|
1259
|
-
status: CiJobStatus,
|
|
1260
|
-
wait_ms: NullOr(Natural).annotate({ description: "Milliseconds from queued to started. Null until the job starts." }),
|
|
1261
|
-
workflow_job_id: GitHubId.annotate({ description: "GitHub's job ID." }),
|
|
1262
|
-
workflow_run_id: GitHubId.annotate({ description: "GitHub's workflow run ID." })
|
|
1263
|
-
}).annotate({
|
|
1264
|
-
description: "A GitHub Actions job that asked for a Sandcovery runner label in a repository of a linked GitHub installation. Money is at list price, and the provider bills your own account.",
|
|
1265
|
-
identifier: "CiJob"
|
|
1266
|
-
});
|
|
1267
|
-
const CiJobList = Struct({
|
|
1268
|
-
data: ArraySchema(CiJob),
|
|
1269
|
-
next_cursor: NullOr(String$1)
|
|
1270
|
-
}).annotate({ identifier: "CiJobList" });
|
|
1271
|
-
const CiInstallation = Struct({
|
|
1272
|
-
account: NonEmptyString.annotate({ description: "The GitHub organization the installation belongs to." }),
|
|
1273
|
-
api_key_id: ApiKeyId.annotate({ description: "The API key that creates the installation's runner sandboxes, whose spend limit, provider allowlist, concurrency cap, and maximum TTL govern them." }),
|
|
1274
|
-
installation_id: GitHubId.annotate({ description: "GitHub's ID of the Sandcovery CI GitHub App installation." }),
|
|
1275
|
-
linked_at: Timestamp,
|
|
1276
|
-
provider_order: ArraySchema(Provider).annotate({ description: "Providers a runner label that pins no provider tries first, in this order, within the API key's allowlist." })
|
|
1277
|
-
}).annotate({
|
|
1278
|
-
description: "A GitHub installation of the Sandcovery CI GitHub App, linked to this organization.",
|
|
1279
|
-
identifier: "CiInstallation"
|
|
1280
|
-
});
|
|
1281
|
-
const CiInstallationList = Struct({ data: ArraySchema(CiInstallation) }).annotate({ identifier: "CiInstallationList" });
|
|
1282
|
-
// ../sandcovery-contract/src/credentials.ts
|
|
1283
|
-
const CredentialFields = Record(String$1, NonEmptyString).annotate({
|
|
1284
|
-
description: "The provider's credential fields by name, as its `credential_fields` on the provider board lists them, such as `api_key` for `e2b` or `api_key` and `workspace_id` for `render`. A missing or unknown field answers 400 `invalid_request`.",
|
|
1285
|
-
identifier: "CredentialFields"
|
|
1286
|
-
});
|
|
1287
|
-
const ProviderCredential = Struct({
|
|
1288
|
-
created_at: Timestamp,
|
|
1289
|
-
hint: String$1.annotate({ description: "The last four characters of the first secret field, for display." }),
|
|
1290
|
-
id: CredentialId,
|
|
1291
|
-
paused: Boolean.annotate({ description: "Whether routing skips this credential. A Free organization routes only its oldest credential, so each other one stays stored and paused until the organization has Pro." }),
|
|
1292
|
-
provider: Provider,
|
|
1293
|
-
updated_at: Timestamp
|
|
1294
|
-
}).annotate({
|
|
1295
|
-
description: "A stored provider credential. Sandcovery encrypts it at rest and never returns its fields.",
|
|
1296
|
-
identifier: "ProviderCredential"
|
|
1297
|
-
});
|
|
1298
|
-
const ProviderCredentialList = Struct({ data: ArraySchema(ProviderCredential).annotate({ description: "Every stored credential, by provider and then in the order a create tries them: the order they were added. A Free organization routes only its oldest credential, and `paused` marks each other one." }) }).annotate({ identifier: "ProviderCredentialList" });
|
|
1299
|
-
// ../sandcovery-contract/src/exec.ts
|
|
1300
|
-
const MAX_EXEC_TIMEOUT_SECONDS = 3600;
|
|
1301
|
-
const commandFields = {
|
|
1302
|
-
command: NonEmptyString.annotate({ description: "A shell command line, run with `sh -c`." }),
|
|
1303
|
-
cwd: optionalKey(NonEmptyString.annotate({ description: "Working directory. Defaults to the provider's default directory." })),
|
|
1304
|
-
env: optionalKey(Record(NonEmptyString, String$1).annotate({ description: "Environment variables for this command only." }))
|
|
1305
|
-
};
|
|
1306
|
-
Struct(commandFields).annotate({
|
|
1307
|
-
description: "A command to start and leave running. It runs until it exits or the sandbox ends, with no timeout, and its output is not kept.",
|
|
1308
|
-
identifier: "DetachedExecRequest"
|
|
1309
|
-
});
|
|
1310
|
-
const DetachedExec = Struct({ started_at: Timestamp.annotate({ description: "When the provider reported the command started." }) }).annotate({
|
|
1311
|
-
description: "A command the provider started and left running.",
|
|
1312
|
-
identifier: "DetachedExec"
|
|
1313
|
-
});
|
|
1314
|
-
Struct({
|
|
1315
|
-
...commandFields,
|
|
1316
|
-
timeout_seconds: optionalKey(Int.check(isBetween({
|
|
1317
|
-
maximum: MAX_EXEC_TIMEOUT_SECONDS,
|
|
1318
|
-
minimum: 1
|
|
1319
|
-
})).annotate({ description: "Seconds after which the command is killed. Defaults to 300." }))
|
|
1320
|
-
}).annotate({ identifier: "ExecRequest" });
|
|
1321
|
-
const ExecResult = Struct({
|
|
1322
|
-
duration_ms: Natural,
|
|
1323
|
-
exit_code: Int,
|
|
1324
|
-
stderr: String$1,
|
|
1325
|
-
stdout: String$1
|
|
1326
|
-
}).annotate({
|
|
1327
|
-
description: "The result of a command that ran to its end.",
|
|
1328
|
-
identifier: "ExecResult"
|
|
1329
|
-
});
|
|
1330
|
-
const ExecEvent = Union([
|
|
1331
|
-
Struct({
|
|
1332
|
-
data: String$1,
|
|
1333
|
-
type: Literal("stdout")
|
|
1334
|
-
}),
|
|
1335
|
-
Struct({
|
|
1336
|
-
data: String$1,
|
|
1337
|
-
type: Literal("stderr")
|
|
1338
|
-
}),
|
|
1339
|
-
Struct({
|
|
1340
|
-
duration_ms: Natural,
|
|
1341
|
-
exit_code: Int,
|
|
1342
|
-
type: Literal("exit")
|
|
1343
|
-
}),
|
|
1344
|
-
Struct({
|
|
1345
|
-
message: String$1,
|
|
1346
|
-
provider: Provider,
|
|
1347
|
-
type: Literal("error")
|
|
1348
|
-
})
|
|
1349
|
-
]).annotate({
|
|
1350
|
-
description: "One server-sent event of a streamed command: output chunks as they arrive, then one `exit`, or one `error` when the provider fails mid-stream.",
|
|
1351
|
-
identifier: "ExecEvent"
|
|
1352
|
-
});
|
|
1353
|
-
Struct({ path: NonEmptyString.annotate({ description: "An absolute path inside the sandbox." }) });
|
|
1354
|
-
const FileEntry = Struct({
|
|
1355
|
-
modified_at: NullOr(Timestamp),
|
|
1356
|
-
name: String$1,
|
|
1357
|
-
path: String$1,
|
|
1358
|
-
size_bytes: NullOr(Natural),
|
|
1359
|
-
type: Literals([
|
|
1360
|
-
"directory",
|
|
1361
|
-
"file",
|
|
1362
|
-
"other",
|
|
1363
|
-
"symlink"
|
|
1364
|
-
]).annotate({
|
|
1365
|
-
description: "`other` is an entry that is neither a file, a directory, nor a symlink, such as a socket or a device.",
|
|
1366
|
-
identifier: "FileEntryType"
|
|
1367
|
-
})
|
|
1368
|
-
}).annotate({ identifier: "FileEntry" });
|
|
1369
|
-
const FileList = Struct({
|
|
1370
|
-
entries: ArraySchema(FileEntry),
|
|
1371
|
-
path: String$1
|
|
1372
|
-
}).annotate({ identifier: "FileList" });
|
|
1373
|
-
const KeyName = NonEmptyString.check(isMaxLength(64));
|
|
1374
|
-
const PositiveInt = Int.check(isGreaterThanOrEqualTo(1));
|
|
1375
|
-
const KeyKind = Literals(["api", "management"]).annotate({
|
|
1376
|
-
description: "An `api` key creates and drives sandboxes. A `management` key mints, changes, and revokes keys, sets provider credentials, and reads usage, and reaches no sandbox.",
|
|
1377
|
-
identifier: "KeyKind"
|
|
1378
|
-
});
|
|
1379
|
-
const SpendLimit = Struct({
|
|
1380
|
-
limit_micro_usd: MicroUsd,
|
|
1381
|
-
period: Literals([
|
|
1382
|
-
"day",
|
|
1383
|
-
"month",
|
|
1384
|
-
"total",
|
|
1385
|
-
"week"
|
|
1386
|
-
]).annotate({
|
|
1387
|
-
description: "The window the limit counts: a UTC `day`, an ISO `week` from Monday 00:00 UTC, a UTC calendar `month`, or the key `total`.",
|
|
1388
|
-
identifier: "SpendLimitPeriod"
|
|
1389
|
-
})
|
|
1390
|
-
}).annotate({
|
|
1391
|
-
description: "A cap on the list-price cost of sandboxes the key creates, counting usage billed to your own provider accounts.",
|
|
1392
|
-
identifier: "SpendLimit"
|
|
1393
|
-
});
|
|
1394
|
-
const keyPolicyFields = {
|
|
1395
|
-
allowed_providers: NullOr(ArraySchema(Provider)).annotate({ description: "The only providers the key may route to. Null allows all." }),
|
|
1396
|
-
max_concurrent_sandboxes: NullOr(PositiveInt),
|
|
1397
|
-
max_ttl_seconds: NullOr(PositiveInt),
|
|
1398
|
-
spend_limit: NullOr(SpendLimit)
|
|
1399
|
-
};
|
|
1400
|
-
const Key = Struct({
|
|
1401
|
-
...keyPolicyFields,
|
|
1402
|
-
created_at: Timestamp,
|
|
1403
|
-
expires_at: NullOr(Timestamp),
|
|
1404
|
-
id: KeyId,
|
|
1405
|
-
kind: KeyKind,
|
|
1406
|
-
last_used_at: NullOr(Timestamp),
|
|
1407
|
-
name: String$1,
|
|
1408
|
-
revoked_at: NullOr(Timestamp),
|
|
1409
|
-
spend: Struct({
|
|
1410
|
-
resets_at: NullOr(Timestamp),
|
|
1411
|
-
spent_micro_usd: MicroUsd
|
|
1412
|
-
}).annotate({ description: "List-price cost counted against `spend_limit` in its current window, or in total when the key has no limit. Always 0 for a management key." }),
|
|
1413
|
-
start: String$1.annotate({ description: "The first 12 characters of the secret, for display." })
|
|
1414
|
-
}).annotate({
|
|
1415
|
-
description: "An API key or a management key. Its secret is never returned after creation, and the limits are null on a management key.",
|
|
1416
|
-
identifier: "Key"
|
|
1417
|
-
});
|
|
1418
|
-
const KeyList = Struct({ data: ArraySchema(Key) }).annotate({ identifier: "KeyList" });
|
|
1419
|
-
const CreateKeyRequest = Struct({
|
|
1420
|
-
allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
|
|
1421
|
-
expires_at: optionalKey(NullOr(Timestamp)),
|
|
1422
|
-
kind: optionalKey(KeyKind).annotate({ description: "Defaults to `api`. Only a signed-in owner mints a `management` key, and a management key takes no limits." }),
|
|
1423
|
-
max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
|
|
1424
|
-
max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
|
|
1425
|
-
name: KeyName,
|
|
1426
|
-
spend_limit: optionalKey(keyPolicyFields.spend_limit)
|
|
1427
|
-
}).annotate({ identifier: "CreateKeyRequest" });
|
|
1428
|
-
const UpdateKeyRequest = Struct({
|
|
1429
|
-
allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
|
|
1430
|
-
expires_at: optionalKey(NullOr(Timestamp)),
|
|
1431
|
-
max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
|
|
1432
|
-
max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
|
|
1433
|
-
name: optionalKey(KeyName),
|
|
1434
|
-
spend_limit: optionalKey(keyPolicyFields.spend_limit)
|
|
1435
|
-
}).annotate({
|
|
1436
|
-
description: "Fields to change. An absent field keeps its value, and null clears a limit. A limit on a management key answers 400 `invalid_request`.",
|
|
1437
|
-
identifier: "UpdateKeyRequest"
|
|
1438
|
-
});
|
|
1439
|
-
const CreatedKey = Struct({
|
|
1440
|
-
key: Key,
|
|
1441
|
-
secret: KeySecret
|
|
1442
|
-
}).annotate({ identifier: "CreatedKey" });
|
|
1443
|
-
// ../sandcovery-contract/src/offer.ts
|
|
1444
|
-
const VcpuSeconds = Natural;
|
|
1445
|
-
const POST_URL_MAX = 2048;
|
|
1446
|
-
const SANDCOVERY_X_HANDLE = "Sandcovery";
|
|
1447
|
-
const Offer = Struct({
|
|
1448
|
-
cap_vcpu_seconds: VcpuSeconds.annotate({ description: "The free vCPU-seconds the account has earned in total, with no reset: `vcpu_seconds_per_key` for each counted key once `keys_counted` reaches `keys_needed`, and 0 before." }),
|
|
1449
|
-
keys_counted: Natural.annotate({ description: "Providers the account has earned free vCPU-seconds for, counted once each for good, plus one for a counted post on X: each provider accepted a credential an organization the account owns stored, when it was stored for a provider that names the account a key belongs to and otherwise when a sandbox first ran on it. A key, or a provider account a provider names, that already earned for any account counts nothing, and removing a credential and storing it again counts nothing more." }),
|
|
1450
|
-
keys_needed: Natural.annotate({ description: "Counted keys the account needs before its sandboxes may run on free vCPU-seconds." }),
|
|
1451
|
-
month_used_up: Boolean.annotate({ description: "Whether the free vCPU-seconds on `provider` that all accounts share this month are used up, so no free sandbox fits until use more than 31 days old stops counting. The account's own `remaining_vcpu_seconds` stays as it is, and a create that would go past the month's share routes to a provider whose credential the organization stored, or fails with `no_provider_available`." }),
|
|
1452
|
-
provider: Provider.annotate({ description: "The provider whose sandboxes run on free vCPU-seconds, on its account that Sandcovery pays for." }),
|
|
1453
|
-
remaining_vcpu_seconds: VcpuSeconds.annotate({ description: "`cap_vcpu_seconds` less `used_vcpu_seconds`, never below zero." }),
|
|
1454
|
-
used_vcpu_seconds: VcpuSeconds.annotate({ description: "vCPU-seconds of the account's ended free sandboxes as they ran, plus each live one's vCPUs over its full TTL." }),
|
|
1455
|
-
vcpu_seconds_per_key: VcpuSeconds.annotate({ description: "The free vCPU-seconds each counted key earns." }),
|
|
1456
|
-
x_post_counted: Boolean.annotate({ description: `Whether a post on X that tags @${SANDCOVERY_X_HANDLE} counted as one of the account's keys. One post counts per account, for good.` })
|
|
1457
|
-
}).annotate({
|
|
1458
|
-
description: "Free vCPU-seconds on `provider`, which an organization with no credential of its own for `provider` may route to. They belong to the account that owns the organization, the organization's earliest owner, and every organization that account owns draws on them.",
|
|
1459
|
-
identifier: "Offer"
|
|
1460
|
-
});
|
|
1461
|
-
Struct({ url: NonEmptyString.check(isMaxLength(POST_URL_MAX)).annotate({ description: "The post's address on x.com or twitter.com, such as `https://x.com/<handle>/status/<id>`." }) }).annotate({
|
|
1462
|
-
description: `A post on X that tags @${SANDCOVERY_X_HANDLE}, to count as one key of the free vCPU-seconds.`,
|
|
1463
|
-
identifier: "XPostRequest"
|
|
1464
|
-
});
|
|
1465
|
-
// ../sandcovery-contract/src/origin.ts
|
|
1466
|
-
const SANDCOVERY_ORIGIN = "https://www.sandcovery.com";
|
|
1467
|
-
const isLocalPath = (path) => path.startsWith("/") && !path.startsWith("//") && !path.startsWith("/\\");
|
|
1468
|
-
const LocalPath = String$1.check(makeFilter(isLocalPath, { expected: "a path on this site" }));
|
|
1469
|
-
const API_PREFIX = "/api/v1";
|
|
1470
|
-
// ../sandcovery-contract/src/process.ts
|
|
1471
|
-
const TerminalCells = Int.check(isBetween({
|
|
1472
|
-
maximum: 65535,
|
|
1473
|
-
minimum: 1
|
|
1474
|
-
}));
|
|
1475
|
-
const ProcessTerminal = Struct({
|
|
1476
|
-
cols: TerminalCells.annotate({ description: "Columns of the terminal." }),
|
|
1477
|
-
rows: TerminalCells.annotate({ description: "Rows of the terminal." }),
|
|
1478
|
-
stderr: Boolean.annotate({ description: "Whether stderr is the terminal." }),
|
|
1479
|
-
stdin: Boolean.annotate({ description: "Whether stdin is the terminal." }),
|
|
1480
|
-
stdout: Boolean.annotate({ description: "Whether stdout is the terminal." })
|
|
1481
|
-
}).annotate({
|
|
1482
|
-
description: "A pseudo-terminal of the given size, and which of stdin, stdout, and stderr sit on it. At least one does; the rest are pipes.",
|
|
1483
|
-
identifier: "ProcessTerminal"
|
|
1484
|
-
});
|
|
1485
|
-
Struct({
|
|
1486
|
-
...commandFields,
|
|
1487
|
-
terminal: optionalKey(ProcessTerminal)
|
|
1488
|
-
}).annotate({
|
|
1489
|
-
description: "A command to run as a process, with no timeout, on a terminal or on pipes.",
|
|
1490
|
-
identifier: "ProcessRequest"
|
|
1491
|
-
});
|
|
1492
|
-
const ProcessStatus = Literals([
|
|
1493
|
-
"exited",
|
|
1494
|
-
"lost",
|
|
1495
|
-
"running"
|
|
1496
|
-
]).annotate({
|
|
1497
|
-
description: "`running` until the command exits, then `exited`, or `lost` when the sandbox ended before the process reported an exit.",
|
|
1498
|
-
identifier: "ProcessStatus"
|
|
1499
|
-
});
|
|
1500
|
-
const Process = Struct({
|
|
1501
|
-
command: String$1,
|
|
1502
|
-
created_at: Timestamp,
|
|
1503
|
-
exit_code: NullOr(Int).annotate({ description: "The exit code, 128 plus the signal number after a signal, or null until the command exits." }),
|
|
1504
|
-
exited_at: NullOr(Timestamp),
|
|
1505
|
-
id: ProcessId,
|
|
1506
|
-
sandbox_id: SandboxId,
|
|
1507
|
-
signal: NullOr(String$1).annotate({ description: "The signal that ended the command, such as `SIGKILL`." }),
|
|
1508
|
-
status: ProcessStatus,
|
|
1509
|
-
terminal: NullOr(ProcessTerminal)
|
|
1510
|
-
}).annotate({
|
|
1511
|
-
description: "A command a sandbox runs on a terminal or pipes. A client attaches to its stdin, stdout, stderr, resizes, and signals over a WebSocket at `/api/v1/sandboxes/{sandbox_id}/processes/{process_id}/attach`.",
|
|
1512
|
-
identifier: "Process"
|
|
1513
|
-
});
|
|
1514
|
-
// ../sandcovery-contract/src/usage.ts
|
|
1515
|
-
const EstimateRequest = Struct({
|
|
1516
|
-
...SandboxSpec.fields,
|
|
1517
|
-
...RoutingFields,
|
|
1518
|
-
provider: optionalKey(ProviderPreferences)
|
|
1519
|
-
}).annotate({
|
|
1520
|
-
description: `A sandbox spec, the slug or slugs to run it on, and routing preferences, to price without creating anything. ${ROUTING_FIELDS_TEXT}`,
|
|
1521
|
-
identifier: "EstimateRequest"
|
|
1522
|
-
});
|
|
1523
|
-
const Estimate = Struct({
|
|
1524
|
-
hourly_micro_usd: MicroUsd,
|
|
1525
|
-
provider: Provider,
|
|
1526
|
-
rate_card_version: String$1,
|
|
1527
|
-
slug: Slug,
|
|
1528
|
-
ttl_micro_usd: MicroUsd.annotate({ description: "List-price cost if the sandbox runs for its whole TTL." })
|
|
1529
|
-
}).annotate({
|
|
1530
|
-
description: "One candidate a create would try: its provider, the slug of the size it would run there, such as `boat/2x4`, and its list price.",
|
|
1531
|
-
identifier: "Estimate"
|
|
1532
|
-
});
|
|
1533
|
-
const EstimateList = Struct({ data: ArraySchema(Estimate).annotate({ description: "One estimate per candidate provider that can run the spec, in routing order, each at the size of the first slug that reaches it." }) }).annotate({ identifier: "EstimateList" });
|
|
1534
|
-
const MONTH_TEXT = "an average month of 365/12 days";
|
|
1535
|
-
const MonthlyCostQuery = Struct({
|
|
1536
|
-
hours_per_day: FiniteFromString.check(isGreaterThan(0), isBetween({
|
|
1537
|
-
maximum: 24,
|
|
1538
|
-
minimum: 0
|
|
1539
|
-
})).pipe(annotateEncoded({ description: `Hours a day the sandbox runs, above 0 and at most ${String(24)}, such as 8 or 0.5.` })),
|
|
1540
|
-
size: SizeName.annotate({ description: "The size to price, `<vcpu>x<memory_gib>` as in a slug, such as `2x4` or `2x0.5`." })
|
|
1541
|
-
});
|
|
1542
|
-
const MonthlyCost = Struct({
|
|
1543
|
-
hourly_micro_usd: MicroUsd,
|
|
1544
|
-
monthly_micro_usd: MicroUsd.annotate({ description: `List-price cost of the size running \`hours_per_day\` hours on every day of ${MONTH_TEXT}.` }),
|
|
1545
|
-
provider: Provider,
|
|
1546
|
-
rate_card_source_url: String$1.annotate({ description: "The provider's public pricing page the rate card copies." }),
|
|
1547
|
-
rate_card_version: String$1,
|
|
1548
|
-
slug: Slug
|
|
1549
|
-
}).annotate({
|
|
1550
|
-
description: "The list price of one size on one provider, by the hour and for a month, with the slug that pins it there, such as `e2b/2x4`.",
|
|
1551
|
-
identifier: "MonthlyCost"
|
|
1552
|
-
});
|
|
1553
|
-
const MonthlyCostList = Struct({
|
|
1554
|
-
data: ArraySchema(MonthlyCost).annotate({ description: "Each provider Sandcovery routes to that runs the size, cheapest first, and none when no provider runs it." }),
|
|
1555
|
-
slug: Slug
|
|
1556
|
-
}).annotate({
|
|
1557
|
-
description: "The monthly list price of one size on every provider Sandcovery routes to, and `slug`, such as `sandcovery/2x4:cheapest`, which routes a create of that size to the cheapest of them that holds your credential.",
|
|
1558
|
-
identifier: "MonthlyCostList"
|
|
1559
|
-
});
|
|
1560
|
-
const isCalendarDay = makeFilter((value) => {
|
|
1561
|
-
const at = Date.parse(`${value}T00:00:00.000Z`);
|
|
1562
|
-
return Number.isFinite(at) && new Date(at).toISOString().slice(0, 10) === value;
|
|
1563
|
-
}, {
|
|
1564
|
-
expected: "a UTC calendar day such as 2026-11-08",
|
|
1565
|
-
toJsonSchema: () => ({ format: "date" })
|
|
1566
|
-
});
|
|
1567
|
-
const CalendarDay = String$1.check(isCalendarDay);
|
|
1568
|
-
Struct({
|
|
1569
|
-
api_key_id: optionalKey(ApiKeyId),
|
|
1570
|
-
from: CalendarDay.annotate({ description: "First UTC day, inclusive." }),
|
|
1571
|
-
to: CalendarDay.annotate({ description: "Last UTC day, inclusive. At most 92 days after `from`." })
|
|
1572
|
-
});
|
|
1573
|
-
const UsageDay = Struct({
|
|
1574
|
-
api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
|
|
1575
|
-
date: CalendarDay,
|
|
1576
|
-
estimated_micro_usd: MicroUsd,
|
|
1577
|
-
gpu_seconds: Natural.annotate({ description: "GPU-seconds: each sandbox GPU count times its seconds run." }),
|
|
1578
|
-
memory_gib_seconds: Natural.annotate({ description: "GiB-seconds: each sandbox memory in GiB times its seconds run, rounded to a whole number." }),
|
|
1579
|
-
provider: Provider,
|
|
1580
|
-
sandbox_count: Natural,
|
|
1581
|
-
sandbox_seconds: Natural,
|
|
1582
|
-
vcpu_seconds: Natural.annotate({ description: "vCPU-seconds: each sandbox vCPU count times its seconds run." })
|
|
1583
|
-
}).annotate({
|
|
1584
|
-
description: "Estimated list-price usage and resource time of one key on one provider on one UTC day. Resource time counts the vCPUs, memory, and GPUs of each sandbox spec over the time it ran, the same time its estimated cost counts, and never measured utilization.",
|
|
1585
|
-
identifier: "UsageDay"
|
|
1586
|
-
});
|
|
1587
|
-
const Usage = Struct({ data: ArraySchema(UsageDay) }).annotate({ identifier: "Usage" });
|
|
1588
|
-
Struct({ api_key_id: optionalKey(ApiKeyId) });
|
|
1589
|
-
const LiveSandboxes = Struct({
|
|
1590
|
-
accrued_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost these sandboxes have run up from their start to now or their TTL." }),
|
|
1591
|
-
api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
|
|
1592
|
-
gpus: Natural,
|
|
1593
|
-
hourly_micro_usd: MicroUsd.annotate({ description: "List-price cost per hour of these sandboxes while they run, at the rate card each started on. A sandbox still creating or past its TTL adds nothing." }),
|
|
1594
|
-
memory_mib: Natural,
|
|
1595
|
-
provider: NullOr(Provider).annotate({ description: "The provider running the sandboxes, or null for creates no provider has started yet." }),
|
|
1596
|
-
sandbox_count: Natural,
|
|
1597
|
-
status: Literals([
|
|
1598
|
-
"creating",
|
|
1599
|
-
"destroying",
|
|
1600
|
-
"paused",
|
|
1601
|
-
"running"
|
|
1602
|
-
]).annotate({ identifier: "LiveSandboxStatus" }),
|
|
1603
|
-
vcpus: Natural
|
|
1604
|
-
}).annotate({
|
|
1605
|
-
description: "The live sandboxes of one key on one provider in one status, with the vCPUs, memory, and GPUs their specs hold.",
|
|
1606
|
-
identifier: "LiveSandboxes"
|
|
1607
|
-
});
|
|
1608
|
-
const LiveUsage = Struct({
|
|
1609
|
-
at: Timestamp.annotate({ description: "When the API read these figures." }),
|
|
1610
|
-
data: ArraySchema(LiveSandboxes)
|
|
1611
|
-
}).annotate({ identifier: "LiveUsage" });
|
|
1612
|
-
const UsagePeriod = Literals([
|
|
1613
|
-
"day",
|
|
1614
|
-
"month",
|
|
1615
|
-
"total",
|
|
1616
|
-
"week"
|
|
1617
|
-
]).annotate({
|
|
1618
|
-
description: "The window: the current UTC `day`, the ISO `week` from Monday 00:00 UTC, the UTC calendar `month`, or the `total` of every sandbox run.",
|
|
1619
|
-
identifier: "UsagePeriod"
|
|
1620
|
-
});
|
|
1621
|
-
const UsageTotal = Struct({
|
|
1622
|
-
estimated_micro_usd: MicroUsd,
|
|
1623
|
-
gpu_seconds: Natural,
|
|
1624
|
-
memory_gib_seconds: Natural,
|
|
1625
|
-
period: UsagePeriod,
|
|
1626
|
-
sandbox_count: Natural.annotate({ description: "Sandboxes that ran at any time in the window." }),
|
|
1627
|
-
sandbox_seconds: Natural,
|
|
1628
|
-
since: NullOr(Timestamp).annotate({ description: "The start of the window, or null for `total`." }),
|
|
1629
|
-
vcpu_seconds: Natural
|
|
1630
|
-
}).annotate({
|
|
1631
|
-
description: "Estimated list-price cost and resource time of the sandboxes run from the start of one window to now, counted as usage per day counts them.",
|
|
1632
|
-
identifier: "UsageTotal"
|
|
1633
|
-
});
|
|
1634
|
-
const UsageTotals = Struct({
|
|
1635
|
-
at: Timestamp.annotate({ description: "When the API read these figures." }),
|
|
1636
|
-
data: ArraySchema(UsageTotal).annotate({ description: "One total for each window: `day`, `week`, `month`, `total`." })
|
|
1637
|
-
}).annotate({ identifier: "UsageTotals" });
|
|
1638
|
-
// ../sandcovery-contract/src/stats.ts
|
|
1639
|
-
const StatsDay = Struct({
|
|
1640
|
-
date: CalendarDay,
|
|
1641
|
-
sandbox_count: Natural.annotate({ description: "Sandboxes that started on this UTC day." })
|
|
1642
|
-
}).annotate({ identifier: "StatsDay" });
|
|
1643
|
-
const Badge = Struct({
|
|
1644
|
-
earned_at: NullOr(Timestamp).annotate({ description: "When the organization earned the badge, read from the sandbox, attempt, or snapshot that earned it, or null while it is still to earn." }),
|
|
1645
|
-
id: NonEmptyString.annotate({ description: "Stable badge name, such as `sandboxes-100` or `streak-7`. The API may add badges, so treat it as an open string." }),
|
|
1646
|
-
name: NonEmptyString.annotate({ description: "The badge as a person reads it, such as `100 Sandboxes`." }),
|
|
1647
|
-
progress: Natural.annotate({ description: "How far the organization has come toward `target`, at most `target`." }),
|
|
1648
|
-
target: Natural.annotate({ description: "What earns the badge, in `unit`." }),
|
|
1649
|
-
unit: NonEmptyString.annotate({ description: "The unit of `progress` and `target`: `sandboxes`, `providers`, `days`, `seconds`, or `snapshots`. The API may add units, so treat it as an open string." })
|
|
1650
|
-
}).annotate({ identifier: "Badge" });
|
|
1651
|
-
const Stats = Struct({
|
|
1652
|
-
badges: ArraySchema(Badge),
|
|
1653
|
-
busiest_day: NullOr(StatsDay).annotate({ description: "The UTC day the most sandboxes started, the earliest such day on a tie." }),
|
|
1654
|
-
days: ArraySchema(StatsDay).annotate({ description: "Each UTC day of the last 365, today included, on which at least one sandbox started, oldest first." }),
|
|
1655
|
-
largest_sandbox: NullOr(Struct({
|
|
1656
|
-
memory_mib: Natural,
|
|
1657
|
-
provider: Provider,
|
|
1658
|
-
sandbox_id: SandboxId,
|
|
1659
|
-
vcpus: Natural
|
|
1660
|
-
})).annotate({ description: "The started sandbox with the most vCPUs, then the most memory, the earliest on a tie." }),
|
|
1661
|
-
level: Natural.annotate({ description: "Level 1 starts at 1 vCPU-hour, and each level after it takes ten times the vCPU-hours of the one before." }),
|
|
1662
|
-
level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds at which the current level started." }),
|
|
1663
|
-
longest_run: NullOr(Struct({
|
|
1664
|
-
provider: Provider,
|
|
1665
|
-
sandbox_id: SandboxId,
|
|
1666
|
-
seconds: Natural
|
|
1667
|
-
})).annotate({ description: "The sandbox that ran longest, up to its end or its TTL, counting a live one up to now." }),
|
|
1668
|
-
next_level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds the next level starts at." }),
|
|
1669
|
-
sandbox_count: Natural.annotate({ description: "Sandboxes the organization started." }),
|
|
1670
|
-
streak: Struct({
|
|
1671
|
-
current_days: Natural.annotate({ description: "Consecutive UTC days with a sandbox start, ending today or yesterday, or 0." }),
|
|
1672
|
-
longest_days: Natural.annotate({ description: "The longest run of consecutive UTC days with a sandbox start." })
|
|
1673
|
-
}),
|
|
1674
|
-
vcpu_seconds: Natural.annotate({ description: "vCPU-seconds of every sandbox the organization started, each from its start to its end or TTL, counting live sandboxes up to now." })
|
|
1675
|
-
}).annotate({
|
|
1676
|
-
description: "The organization's level, streak, records, and badges, each read from the sandboxes, create attempts, and snapshots it stores.",
|
|
1677
|
-
identifier: "Stats"
|
|
1678
|
-
});
|
|
1679
|
-
// ../sandcovery-contract/src/usage-shares.ts
|
|
1680
|
-
const USAGE_SHARE_FIGURES = [
|
|
1681
|
-
"sandbox_count",
|
|
1682
|
-
"sandbox_seconds",
|
|
1683
|
-
"vcpu_seconds",
|
|
1684
|
-
"memory_gib_seconds",
|
|
1685
|
-
"gpu_seconds",
|
|
1686
|
-
"estimated_micro_usd"
|
|
1687
|
-
];
|
|
1688
|
-
const UsageShareFigure = Literals(USAGE_SHARE_FIGURES).annotate({
|
|
1689
|
-
description: "A figure of a usage total, named as its `UsageTotal` field.",
|
|
1690
|
-
identifier: "UsageShareFigure"
|
|
1691
|
-
});
|
|
1692
|
-
const DEFAULT_SHARED_FIGURES = USAGE_SHARE_FIGURES.filter((figure) => figure !== "estimated_micro_usd");
|
|
1693
|
-
const SHARE_TOKEN_LENGTH = 43;
|
|
1694
|
-
const BASE64URL = /* @__PURE__ */ new Set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_");
|
|
1695
|
-
const isShareToken = (value) => value.length === SHARE_TOKEN_LENGTH && value.split("").every((character) => BASE64URL.has(character));
|
|
1696
|
-
const ShareToken = String$1.check(makeFilter(isShareToken, {
|
|
1697
|
-
expected: "a share token of 43 base64url characters",
|
|
1698
|
-
toJsonSchema: () => ({})
|
|
1699
|
-
})).annotate({ description: "A share token: 32 random bytes as 43 unpadded base64url characters. Anyone holding it can read the figures it shares." });
|
|
1700
|
-
const CreateUsageShareRequest = Struct({
|
|
1701
|
-
figures: ArraySchema(UsageShareFigure).check(isMinLength(1), isMaxLength(USAGE_SHARE_FIGURES.length)).annotate({ description: "The figures of the window to share, at least one. The share shows each once, in the order `UsageShareFigure` lists them." }),
|
|
1702
|
-
period: UsagePeriod
|
|
1703
|
-
}).annotate({
|
|
1704
|
-
description: "The window whose usage total to share and the figures of it to show. Nothing else of the organization becomes public.",
|
|
1705
|
-
identifier: "CreateUsageShareRequest"
|
|
1706
|
-
});
|
|
1707
|
-
const SharedUsageFigure = Struct({
|
|
1708
|
-
figure: UsageShareFigure,
|
|
1709
|
-
value: Natural.annotate({ description: "The value, in the unit of its `UsageTotal` field." })
|
|
1710
|
-
}).annotate({ identifier: "SharedUsageFigure" });
|
|
1711
|
-
const SharedUsage = Struct({
|
|
1712
|
-
at: Timestamp.annotate({ description: "When the API read the figures. They never change after." }),
|
|
1713
|
-
figures: ArraySchema(SharedUsageFigure).annotate({ description: "The shared figures, in the order `UsageShareFigure` lists them." }),
|
|
1714
|
-
period: UsagePeriod,
|
|
1715
|
-
shared_by: String$1.annotate({ description: "The Sandcovery username of the person who shared, as it reads now, so a rename shows on every link they shared." }),
|
|
1716
|
-
since: NullOr(Timestamp).annotate({ description: "The start of the window, or null for `total`." })
|
|
1717
|
-
}).annotate({
|
|
1718
|
-
description: "A usage total an organization shared by link: only the window and the figures it chose, read once when it shared them, and the username of the person who shared, with no organization, email, name, key, or billing detail.",
|
|
1719
|
-
identifier: "SharedUsage"
|
|
1720
|
-
});
|
|
1721
|
-
const UsageShare = Struct({
|
|
1722
|
-
id: UsageShareId,
|
|
1723
|
-
image_url: String$1.annotate({ description: "The PNG card of the share, which its page names as its social image and anyone can download without signing in." }),
|
|
1724
|
-
token: ShareToken,
|
|
1725
|
-
url: String$1.annotate({ description: "The public page of the share, which anyone can open without signing in." }),
|
|
1726
|
-
usage: SharedUsage
|
|
1727
|
-
}).annotate({
|
|
1728
|
-
description: "A public link to one usage total of the organization. It lives until revoked.",
|
|
1729
|
-
identifier: "UsageShare"
|
|
1730
|
-
});
|
|
1731
|
-
const UsageShareList = Struct({ data: ArraySchema(UsageShare).annotate({ description: "Every live usage share of the organization, newest first." }) }).annotate({ identifier: "UsageShareList" });
|
|
1732
|
-
// ../sandcovery-contract/src/x-account.ts
|
|
1733
|
-
const XAccount = Struct({
|
|
1734
|
-
id: String$1.annotate({ description: "X's ID of the account." }),
|
|
1735
|
-
linked_at: Timestamp,
|
|
1736
|
-
username: String$1.annotate({ description: "The X handle, without the leading @." })
|
|
1737
|
-
}).annotate({
|
|
1738
|
-
description: "The X account linked to you.",
|
|
1739
|
-
identifier: "XAccount"
|
|
1740
|
-
});
|
|
1741
|
-
const XAccountStatus = Struct({
|
|
1742
|
-
linked: NullOr(XAccount).annotate({ description: "The X account linked to you, or null while none is." }),
|
|
1743
|
-
linking_open: Boolean.annotate({ description: "Whether Sandcovery links X accounts now." })
|
|
1744
|
-
}).annotate({
|
|
1745
|
-
description: "The X account linked to you, and whether linking is open.",
|
|
1746
|
-
identifier: "XAccountStatus"
|
|
1747
|
-
});
|
|
1748
|
-
const XAccountLink = Struct({ url: String$1.annotate({ description: "The dashboard page where you confirm the link on X, signed in to www.sandcovery.com as yourself." }) }).annotate({
|
|
1749
|
-
description: "Where to finish linking an X account, since X confirms it in the browser.",
|
|
1750
|
-
identifier: "XAccountLink"
|
|
1751
|
-
});
|
|
1752
|
-
// src/sse.ts
|
|
1753
|
-
const fieldOf = (line) => {
|
|
1754
|
-
const colon = line.indexOf(":");
|
|
1755
|
-
if (colon === -1) return {
|
|
1756
|
-
name: line,
|
|
1757
|
-
value: ""
|
|
1758
|
-
};
|
|
1759
|
-
const value = line.slice(colon + 1);
|
|
1760
|
-
return {
|
|
1761
|
-
name: line.slice(0, colon),
|
|
1762
|
-
value: value.startsWith(" ") ? value.slice(1) : value
|
|
1763
|
-
};
|
|
1764
|
-
};
|
|
1765
|
-
const eventOf = (block) => {
|
|
1766
|
-
const fields = block.split("\n").flatMap((line) => {
|
|
1767
|
-
if (line.startsWith(":")) return [];
|
|
1768
|
-
return [fieldOf(line)];
|
|
1769
|
-
});
|
|
1770
|
-
const data = fields.flatMap(({ name, value }) => name === "data" ? [value] : []);
|
|
1771
|
-
const event = fields.findLast(({ name }) => name === "event")?.value ?? "message";
|
|
1772
|
-
return data.length > 0 ? {
|
|
1773
|
-
data: data.join("\n"),
|
|
1774
|
-
event
|
|
1775
|
-
} : void 0;
|
|
1776
|
-
};
|
|
1777
|
-
const normalized = (text) => text.replaceAll("\r\n", "\n").replaceAll("\r", "\n");
|
|
1778
|
-
const serverSentEvents = async function* (body) {
|
|
1779
|
-
const decoder = new TextDecoder();
|
|
1780
|
-
let pending = "";
|
|
1781
|
-
for await (const bytes of body) {
|
|
1782
|
-
const text = `${pending}${decoder.decode(bytes, { stream: true })}`;
|
|
1783
|
-
const cut = text.endsWith("\r") ? text.length - 1 : text.length;
|
|
1784
|
-
const blocks = normalized(text.slice(0, cut)).split("\n\n");
|
|
1785
|
-
pending = `${blocks.pop() ?? ""}${text.slice(cut)}`;
|
|
1786
|
-
for (const block of blocks) {
|
|
1787
|
-
const event = eventOf(block);
|
|
1788
|
-
if (event !== void 0) yield event;
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
};
|
|
1792
|
-
// src/index.ts
|
|
1793
|
-
const STREAM_FAILURE_EVENT = "effect/http-api/stream/failure";
|
|
1794
|
-
const X_ACCOUNT_PATH = "/x-account";
|
|
1795
|
-
const AUTO_TOP_UP_PATH = "/billing/auto-top-up";
|
|
1796
|
-
const decodeApiError = decodeUnknownOption(fromJsonString(ApiError));
|
|
1797
|
-
const failureOf = async (response) => {
|
|
1798
|
-
const text = await response.text();
|
|
1799
|
-
return getOrElse(decodeApiError(text), () => new Error(`Sandcovery answered ${response.status}`, { cause: {
|
|
1800
|
-
body: text,
|
|
1801
|
-
status: response.status
|
|
1802
|
-
} }));
|
|
1803
|
-
};
|
|
1804
|
-
const segment = (schema, value) => encodeURIComponent(decodeUnknownSync(schema)(value));
|
|
1805
|
-
const sandboxPath = (sandboxId) => `/sandboxes/${segment(SandboxId, sandboxId)}`;
|
|
1806
|
-
const processPath = (sandboxId, processId) => `${sandboxPath(sandboxId)}/processes/${segment(ProcessId, processId)}`;
|
|
1807
|
-
const keyPath = (keyId) => `/keys/${segment(KeyId, keyId)}`;
|
|
1808
|
-
const portSegment = (port) => String(decodeUnknownSync(Port)(port));
|
|
1809
|
-
const credentialPath = (provider) => `/credentials/${segment(Provider, provider)}`;
|
|
1810
|
-
const ciJobPath = (jobId) => `/ci/jobs/${segment(CiJobId, jobId)}`;
|
|
1811
|
-
const ciInstallationPath = (installationId) => `/ci/installations/${String(decodeUnknownSync(GitHubId)(installationId))}`;
|
|
1812
|
-
const filePath = (sandboxId) => `${sandboxPath(sandboxId)}/files/content`;
|
|
1813
|
-
const USAGE_SHARES_PATH = "/usage/shares";
|
|
1814
|
-
const decodeExecEvent = decodeUnknownSync(fromJsonString(ExecEvent));
|
|
1815
|
-
var Sandcovery = class {
|
|
1816
|
-
activity;
|
|
1817
|
-
billing;
|
|
1818
|
-
ci;
|
|
1819
|
-
credentials;
|
|
1820
|
-
keys;
|
|
1821
|
-
pricing;
|
|
1822
|
-
problems;
|
|
1823
|
-
providers;
|
|
1824
|
-
sandboxes;
|
|
1825
|
-
stats;
|
|
1826
|
-
usage;
|
|
1827
|
-
xAccount;
|
|
1828
|
-
constructor(options = {}) {
|
|
1829
|
-
const configuredKey = options.apiKey ?? globalThis.process?.env.SANDCOVERY_API_KEY;
|
|
1830
|
-
const apiKey = configuredKey === "" ? void 0 : configuredKey;
|
|
1831
|
-
const baseUrl = options.baseUrl ?? "https://www.sandcovery.com";
|
|
1832
|
-
const send = options.fetch ?? globalThis.fetch;
|
|
1833
|
-
const call = async (method, path, { body, headers = {}, json, query = {}, signal } = {}) => {
|
|
1834
|
-
const url = new URL(`${API_PREFIX}${path}`, baseUrl);
|
|
1835
|
-
for (const [key, value] of Object.entries(query)) if (value !== void 0) url.searchParams.set(key, String(value));
|
|
1836
|
-
const sent = new Headers(headers);
|
|
1837
|
-
if (apiKey !== void 0) sent.set("authorization", `Bearer ${apiKey}`);
|
|
1838
|
-
if (json !== void 0) sent.set("content-type", "application/json");
|
|
1839
|
-
const response = await send(url, {
|
|
1840
|
-
body: json === void 0 ? body : JSON.stringify(json),
|
|
1841
|
-
headers: sent,
|
|
1842
|
-
method,
|
|
1843
|
-
signal
|
|
1844
|
-
});
|
|
1845
|
-
if (!response.ok) throw await failureOf(response);
|
|
1846
|
-
return response;
|
|
1847
|
-
};
|
|
1848
|
-
const read = async (schema, method, path, request) => {
|
|
1849
|
-
const text = await (await call(method, path, request)).text();
|
|
1850
|
-
return decodeUnknownSync(fromJsonString(schema))(text);
|
|
1851
|
-
};
|
|
1852
|
-
this.sandboxes = {
|
|
1853
|
-
attachProcess: (sandboxId, processId, attachOptions = {}) => {
|
|
1854
|
-
const path = processPath(sandboxId, processId);
|
|
1855
|
-
const url = new URL(`${API_PREFIX}${path}/attach`, baseUrl);
|
|
1856
|
-
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
1857
|
-
return attach({
|
|
1858
|
-
check: async () => await read(Process, "GET", path, { signal: attachOptions.signal }),
|
|
1859
|
-
credential: apiKey ?? null,
|
|
1860
|
-
options: attachOptions,
|
|
1861
|
-
url
|
|
1862
|
-
});
|
|
1863
|
-
},
|
|
1864
|
-
create: async (request = {}, { idempotencyKey, signal } = {}) => await read(Sandbox, "POST", "/sandboxes", {
|
|
1865
|
-
headers: idempotencyKey === void 0 ? {} : { "idempotency-key": idempotencyKey },
|
|
1866
|
-
json: request,
|
|
1867
|
-
signal
|
|
1868
|
-
}),
|
|
1869
|
-
destroy: async (sandboxId, { signal } = {}) => await read(Sandbox, "DELETE", sandboxPath(sandboxId), { signal }),
|
|
1870
|
-
downloadFile: async (sandboxId, path, { signal } = {}) => {
|
|
1871
|
-
const response = await call("GET", filePath(sandboxId), {
|
|
1872
|
-
query: { path },
|
|
1873
|
-
signal
|
|
1874
|
-
});
|
|
1875
|
-
if (response.body === null) throw new Error("Sandcovery answered no file body", { cause: { status: response.status } });
|
|
1876
|
-
return response.body;
|
|
1877
|
-
},
|
|
1878
|
-
exec: async (sandboxId, request, { signal } = {}) => await read(ExecResult, "POST", `${sandboxPath(sandboxId)}/exec`, {
|
|
1879
|
-
json: request,
|
|
1880
|
-
signal
|
|
1881
|
-
}),
|
|
1882
|
-
execDetached: async (sandboxId, request, { signal } = {}) => await read(DetachedExec, "POST", `${sandboxPath(sandboxId)}/exec/detached`, {
|
|
1883
|
-
json: request,
|
|
1884
|
-
signal
|
|
1885
|
-
}),
|
|
1886
|
-
async *execStream(sandboxId, request, { signal } = {}) {
|
|
1887
|
-
const response = await call("POST", `${sandboxPath(sandboxId)}/exec/stream`, {
|
|
1888
|
-
headers: { accept: "text/event-stream" },
|
|
1889
|
-
json: request,
|
|
1890
|
-
signal
|
|
1891
|
-
});
|
|
1892
|
-
if (response.body === null) return;
|
|
1893
|
-
for await (const { data, event } of serverSentEvents(response.body)) {
|
|
1894
|
-
if (event === STREAM_FAILURE_EVENT) throw new Error("Sandcovery failed the stream", { cause: { body: data } });
|
|
1895
|
-
yield decodeExecEvent(data);
|
|
1896
|
-
}
|
|
1897
|
-
},
|
|
1898
|
-
get: async (sandboxId, { signal } = {}) => await read(Sandbox, "GET", sandboxPath(sandboxId), { signal }),
|
|
1899
|
-
getProcess: async (sandboxId, processId, { signal } = {}) => await read(Process, "GET", processPath(sandboxId, processId), { signal }),
|
|
1900
|
-
list: async (query = {}, { signal } = {}) => await read(SandboxList, "GET", "/sandboxes", {
|
|
1901
|
-
query: { ...query },
|
|
1902
|
-
signal
|
|
1903
|
-
}),
|
|
1904
|
-
listFiles: async (sandboxId, path, { signal } = {}) => await read(FileList, "GET", `${sandboxPath(sandboxId)}/files`, {
|
|
1905
|
-
query: { path },
|
|
1906
|
-
signal
|
|
1907
|
-
}),
|
|
1908
|
-
pause: async (sandboxId, { signal } = {}) => await read(Sandbox, "POST", `${sandboxPath(sandboxId)}/pause`, { signal }),
|
|
1909
|
-
portPreview: async (sandboxId, port, { signal } = {}) => await read(PortPreview, "GET", `${sandboxPath(sandboxId)}/ports/${portSegment(port)}`, { signal }),
|
|
1910
|
-
readFile: async (sandboxId, path, { signal } = {}) => {
|
|
1911
|
-
const response = await call("GET", filePath(sandboxId), {
|
|
1912
|
-
query: { path },
|
|
1913
|
-
signal
|
|
1914
|
-
});
|
|
1915
|
-
return new Uint8Array(await response.arrayBuffer());
|
|
1916
|
-
},
|
|
1917
|
-
resume: async (sandboxId, { signal } = {}) => await read(Sandbox, "POST", `${sandboxPath(sandboxId)}/resume`, { signal }),
|
|
1918
|
-
snapshot: async (sandboxId, { signal } = {}) => await read(Snapshot, "POST", `${sandboxPath(sandboxId)}/snapshot`, { signal }),
|
|
1919
|
-
startProcess: async (sandboxId, request, { signal } = {}) => await read(Process, "POST", `${sandboxPath(sandboxId)}/processes`, {
|
|
1920
|
-
json: request,
|
|
1921
|
-
signal
|
|
1922
|
-
}),
|
|
1923
|
-
writeFile: async (sandboxId, path, content, { signal } = {}) => await read(FileEntry, "PUT", filePath(sandboxId), {
|
|
1924
|
-
body: content instanceof Uint8Array ? new Uint8Array(content) : content,
|
|
1925
|
-
headers: { "content-type": "application/octet-stream" },
|
|
1926
|
-
query: { path },
|
|
1927
|
-
signal
|
|
1928
|
-
})
|
|
1929
|
-
};
|
|
1930
|
-
this.keys = {
|
|
1931
|
-
create: async (request, { signal } = {}) => await read(CreatedKey, "POST", "/keys", {
|
|
1932
|
-
json: request,
|
|
1933
|
-
signal
|
|
1934
|
-
}),
|
|
1935
|
-
get: async (keyId, { signal } = {}) => await read(Key, "GET", keyPath(keyId), { signal }),
|
|
1936
|
-
list: async ({ signal } = {}) => await read(KeyList, "GET", "/keys", { signal }),
|
|
1937
|
-
revoke: async (keyId, { signal } = {}) => await read(Key, "DELETE", keyPath(keyId), { signal }),
|
|
1938
|
-
update: async (keyId, request, { signal } = {}) => await read(Key, "PATCH", keyPath(keyId), {
|
|
1939
|
-
json: request,
|
|
1940
|
-
signal
|
|
1941
|
-
})
|
|
1942
|
-
};
|
|
1943
|
-
this.credentials = {
|
|
1944
|
-
add: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "POST", credentialPath(provider), {
|
|
1945
|
-
json: fields,
|
|
1946
|
-
signal
|
|
1947
|
-
}),
|
|
1948
|
-
countXPost: async (request, { signal } = {}) => await read(Offer, "POST", "/offer/x-post", {
|
|
1949
|
-
json: request,
|
|
1950
|
-
signal
|
|
1951
|
-
}),
|
|
1952
|
-
delete: async (provider, { signal } = {}) => {
|
|
1953
|
-
await call("DELETE", credentialPath(provider), { signal });
|
|
1954
|
-
},
|
|
1955
|
-
deleteOne: async (provider, credentialId, { signal } = {}) => {
|
|
1956
|
-
await call("DELETE", `${credentialPath(provider)}/${segment(CredentialId, credentialId)}`, { signal });
|
|
1957
|
-
},
|
|
1958
|
-
list: async ({ signal } = {}) => await read(ProviderCredentialList, "GET", "/credentials", { signal }),
|
|
1959
|
-
offer: async ({ signal } = {}) => await read(Offer, "GET", "/offer", { signal }),
|
|
1960
|
-
set: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "PUT", credentialPath(provider), {
|
|
1961
|
-
json: fields,
|
|
1962
|
-
signal
|
|
1963
|
-
})
|
|
1964
|
-
};
|
|
1965
|
-
this.activity = { list: async (query = {}, { signal } = {}) => await read(ActivityList, "GET", "/activity", {
|
|
1966
|
-
query: { ...query },
|
|
1967
|
-
signal
|
|
1968
|
-
}) };
|
|
1969
|
-
this.billing = {
|
|
1970
|
-
buyCredits: async (request, { signal } = {}) => await read(CreditCheckout, "POST", "/billing/credits", {
|
|
1971
|
-
json: request,
|
|
1972
|
-
signal
|
|
1973
|
-
}),
|
|
1974
|
-
get: async ({ signal } = {}) => await read(Billing, "GET", "/billing", { signal }),
|
|
1975
|
-
setAutoTopUp: async (request, { signal } = {}) => await read(AutoTopUpChange, "PUT", AUTO_TOP_UP_PATH, {
|
|
1976
|
-
json: request,
|
|
1977
|
-
signal
|
|
1978
|
-
}),
|
|
1979
|
-
stopAutoTopUp: async ({ signal } = {}) => await read(AutoTopUp, "DELETE", AUTO_TOP_UP_PATH, { signal })
|
|
1980
|
-
};
|
|
1981
|
-
this.ci = {
|
|
1982
|
-
getJob: async (jobId, { signal } = {}) => await read(CiJob, "GET", ciJobPath(jobId), { signal }),
|
|
1983
|
-
listInstallations: async ({ signal } = {}) => await read(CiInstallationList, "GET", "/ci/installations", { signal }),
|
|
1984
|
-
listJobs: async (query = {}, { signal } = {}) => await read(CiJobList, "GET", "/ci/jobs", {
|
|
1985
|
-
query: { ...query },
|
|
1986
|
-
signal
|
|
1987
|
-
}),
|
|
1988
|
-
unlinkInstallation: async (installationId, { signal } = {}) => {
|
|
1989
|
-
await call("DELETE", ciInstallationPath(installationId), { signal });
|
|
1990
|
-
}
|
|
1991
|
-
};
|
|
1992
|
-
this.pricing = {
|
|
1993
|
-
get: async ({ signal } = {}) => await read(Pricing, "GET", "/pricing", { signal }),
|
|
1994
|
-
monthly: async (query, { signal } = {}) => await read(MonthlyCostList, "GET", "/pricing/monthly", {
|
|
1995
|
-
query: { ...query },
|
|
1996
|
-
signal
|
|
1997
|
-
})
|
|
1998
|
-
};
|
|
1999
|
-
this.problems = { report: async (request, { signal } = {}) => {
|
|
2000
|
-
await call("POST", "/problem-reports", {
|
|
2001
|
-
json: request,
|
|
2002
|
-
signal
|
|
2003
|
-
});
|
|
2004
|
-
} };
|
|
2005
|
-
this.providers = {
|
|
2006
|
-
catalog: async ({ signal } = {}) => await read(ProviderCatalog, "GET", "/catalog", { signal }),
|
|
2007
|
-
get: async (provider, { signal } = {}) => await read(ProviderBoardEntry, "GET", `/providers/${segment(Provider, provider)}`, { signal }),
|
|
2008
|
-
list: async ({ signal } = {}) => await read(ProviderBoard, "GET", "/providers", { signal })
|
|
2009
|
-
};
|
|
2010
|
-
this.stats = { get: async ({ signal } = {}) => await read(Stats, "GET", "/stats", { signal }) };
|
|
2011
|
-
this.usage = {
|
|
2012
|
-
estimate: async (request, { signal } = {}) => await read(EstimateList, "POST", "/estimates", {
|
|
2013
|
-
json: request,
|
|
2014
|
-
signal
|
|
2015
|
-
}),
|
|
2016
|
-
get: async (query, { signal } = {}) => await read(Usage, "GET", "/usage", {
|
|
2017
|
-
query: { ...query },
|
|
2018
|
-
signal
|
|
2019
|
-
}),
|
|
2020
|
-
getShared: async (token, { signal } = {}) => await read(SharedUsage, "GET", `/shared-usage/${segment(ShareToken, token)}`, { signal }),
|
|
2021
|
-
listShares: async ({ signal } = {}) => await read(UsageShareList, "GET", USAGE_SHARES_PATH, { signal }),
|
|
2022
|
-
live: async (query = {}, { signal } = {}) => await read(LiveUsage, "GET", "/usage/live", {
|
|
2023
|
-
query: { ...query },
|
|
2024
|
-
signal
|
|
2025
|
-
}),
|
|
2026
|
-
revokeShare: async (shareId, { signal } = {}) => {
|
|
2027
|
-
await call("DELETE", `${USAGE_SHARES_PATH}/${segment(UsageShareId, shareId)}`, { signal });
|
|
2028
|
-
},
|
|
2029
|
-
share: async (request, { signal } = {}) => await read(UsageShare, "POST", USAGE_SHARES_PATH, {
|
|
2030
|
-
json: request,
|
|
2031
|
-
signal
|
|
2032
|
-
}),
|
|
2033
|
-
totals: async (query = {}, { signal } = {}) => await read(UsageTotals, "GET", "/usage/totals", {
|
|
2034
|
-
query: { ...query },
|
|
2035
|
-
signal
|
|
2036
|
-
})
|
|
2037
|
-
};
|
|
2038
|
-
this.xAccount = {
|
|
2039
|
-
get: async ({ signal } = {}) => await read(XAccountStatus, "GET", X_ACCOUNT_PATH, { signal }),
|
|
2040
|
-
link: async ({ signal } = {}) => await read(XAccountLink, "POST", X_ACCOUNT_PATH, { signal }),
|
|
2041
|
-
unlink: async ({ signal } = {}) => {
|
|
2042
|
-
await call("DELETE", X_ACCOUNT_PATH, { signal });
|
|
2043
|
-
}
|
|
2044
|
-
};
|
|
2045
|
-
}
|
|
2046
|
-
};
|
|
2047
|
-
export { NO_MARKUP_TERMS as A, DEFAULT_SLUG as B, AUTO_TOP_UP_THRESHOLD_MIN_MICRO_USD as C, ENTERPRISE_PLAN as D, CREDIT_PURCHASE_MIN_MICRO_USD as E, Unauthorized as F, CiJobId as G, Forbidden as H, NotFound as I, KeySecret as J, CredentialId as K, CreateSandboxRequest as L, thresholdBelowTopUp as M, ApiError as N, FREE_PLAN as O, Unsupported as P, UsageShareId as Q, Port as R, AUTO_TOP_UP_THRESHOLD_MAX_MICRO_USD as S, CREDIT_PURCHASE_MAX_MICRO_USD as T, Conflict as U, ProviderSort as V, ApiKeyId as W, Provider as X, ProcessId as Y, SandboxId as Z, KeyKind as _, USAGE_SHARE_FIGURES as a, CredentialFields as b, EstimateRequest as c, UsagePeriod as d, API_PREFIX as f, CreateKeyRequest as g, SANDCOVERY_X_HANDLE as h, ShareToken as i, creditsAfterFeeMicroUsd as j, MICRO_USD_PER_DOLLAR as k, MONTH_TEXT as l, SANDCOVERY_ORIGIN as m, CreateUsageShareRequest as n, UsageShareFigure as o, LocalPath as p, KeyId as q, DEFAULT_SHARED_FIGURES as r, CalendarDay as s, Sandcovery as t, MonthlyCostQuery as u, SpendLimit as v, CARD_FEE_TERMS as w, GitHubId as x, UpdateKeyRequest as y, SandboxStatus as z };
|