sandcovery 0.5.0 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,444 +0,0 @@
1
- import { D as is, I as isUUID, L as makeFilter, M as isMaxLength, N as isMinLength, O as isBase64Url$1, P as isMultipleOf, _ as Struct, d as Natural, f as NonEmptyArray, g as String$1, h as Record, j as isGreaterThanOrEqualTo, k as isBetween, l as Literal, m as NullOr, n as Boolean, p as NonEmptyString, s as Int, t as ArraySchema, u as Literals, v as Union, z as optionalKey } from "./Schema-fLas6rbA.mjs";
2
- // ../sandcovery-contract/src/primitives.ts
3
- const PROVIDERS = [
4
- "daytona",
5
- "depot",
6
- "e2b",
7
- "upstash"
8
- ];
9
- const PROVIDER_EXAMPLES = new Intl.ListFormat("en", { type: "disjunction" }).format(PROVIDERS.map((provider) => `\`${provider}\``));
10
- const SLUG_CHARACTERS = /* @__PURE__ */ new Set("abcdefghijklmnopqrstuvwxyz0123456789-");
11
- const isProviderName = (value) => value !== "" && value.split("").every((character) => SLUG_CHARACTERS.has(character));
12
- const Provider = String$1.check(makeFilter(isProviderName, {
13
- expected: "a provider name of lowercase letters, digits, and hyphens",
14
- toJsonSchema: () => ({ minLength: 1 })
15
- })).annotate({
16
- 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.`,
17
- examples: PROVIDERS,
18
- identifier: "Provider"
19
- });
20
- const Region = NonEmptyString.annotate({
21
- 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.",
22
- examples: [
23
- "asia",
24
- "eu",
25
- "us"
26
- ],
27
- identifier: "Region"
28
- });
29
- const GpuType = NonEmptyString.annotate({
30
- description: "A GPU model, such as `h100`, `b200`, `rtx-pro-6000`, or `mi355x`. The API adds types over time.",
31
- examples: [
32
- "b200",
33
- "b300",
34
- "h100",
35
- "h200",
36
- "mi355x",
37
- "rtx-4090",
38
- "rtx-5090",
39
- "rtx-pro-6000"
40
- ],
41
- identifier: "GpuType"
42
- });
43
- const isUtcTimestamp = makeFilter((value) => {
44
- const at = Date.parse(value);
45
- return Number.isFinite(at) && new Date(at).toISOString() === value;
46
- }, {
47
- expected: "a UTC timestamp such as 2026-11-08T11:20:00.000Z",
48
- toJsonSchema: () => ({ format: "date-time" })
49
- });
50
- 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`." });
51
- const MicroUsd = Natural.annotate({ description: "An amount in integer micro-dollars: 1,000,000 is 1 USD." });
52
- const isUuidV7 = is(String$1.check(isUUID(7)));
53
- const hasPrefixedUuid = (value, prefix) => value.startsWith(prefix) && isUuidV7(value.slice(prefix.length));
54
- const prefixedId = (prefix, noun) => String$1.check(makeFilter((value) => hasPrefixedUuid(value, prefix), {
55
- expected: `${prefix} followed by a UUID v7`,
56
- toJsonSchema: () => ({})
57
- })).annotate({ description: `${noun} ID: \`${prefix}\` followed by a UUID v7.` });
58
- const SandboxId = prefixedId("sbx_", "Sandbox");
59
- const SnapshotId = prefixedId("snap_", "Snapshot");
60
- const CiJobId = prefixedId("cij_", "CI job");
61
- const CredentialId = prefixedId("cred_", "Provider credential");
62
- const API_KEY_ID_PREFIX = "key_";
63
- const MANAGEMENT_KEY_ID_PREFIX = "mkey_";
64
- const ApiKeyId = prefixedId(API_KEY_ID_PREFIX, "API key");
65
- const KeyId = String$1.check(makeFilter((value) => hasPrefixedUuid(value, API_KEY_ID_PREFIX) || hasPrefixedUuid(value, MANAGEMENT_KEY_ID_PREFIX), {
66
- expected: `${API_KEY_ID_PREFIX} or ${MANAGEMENT_KEY_ID_PREFIX} followed by a UUID v7`,
67
- toJsonSchema: () => ({})
68
- })).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.` });
69
- const SECRET_TEXT_LENGTH = 43;
70
- const isBase64Url = is(String$1.check(isBase64Url$1()));
71
- const API_KEY_SECRET_PREFIX = "sand_";
72
- const MANAGEMENT_KEY_SECRET_PREFIX = "sandm_";
73
- const hasPrefixedSecret = (value, prefix) => value.startsWith(prefix) && value.length === prefix.length + SECRET_TEXT_LENGTH && isBase64Url(value.slice(prefix.length));
74
- const KeySecret = String$1.check(makeFilter((value) => hasPrefixedSecret(value, API_KEY_SECRET_PREFIX) || hasPrefixedSecret(value, MANAGEMENT_KEY_SECRET_PREFIX), {
75
- expected: `${API_KEY_SECRET_PREFIX} or ${MANAGEMENT_KEY_SECRET_PREFIX} followed by 43 base64url characters`,
76
- toJsonSchema: () => ({})
77
- })).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.` });
78
- const MICRO_USD_PER_DOLLAR = 1e6;
79
- const CREDIT_PURCHASE_MIN_MICRO_USD = 25 * MICRO_USD_PER_DOLLAR;
80
- const CREDIT_PURCHASE_MAX_MICRO_USD = 1e3 * MICRO_USD_PER_DOLLAR;
81
- const CARD_FEE_TERMS = "2.9% plus 30 cents";
82
- const NO_MARKUP_TERMS = [
83
- "Sandbox usage carries no markup.",
84
- "On your own provider keys, each provider bills you at its own prices, and Sandcovery charges nothing for that usage.",
85
- `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.`,
86
- "Beyond list prices and that fee, Sandcovery charges only for Pro, a fixed fee for each organization."
87
- ].join(" ");
88
- const Plan = Literals(["free", "pro"]).annotate({
89
- description: "The organization plan: `pro` while its Pro subscription is active, trialing, or past due, otherwise `free`.",
90
- identifier: "Plan"
91
- });
92
- const ProInterval = Literals([
93
- "day",
94
- "month",
95
- "week",
96
- "year"
97
- ]).annotate({
98
- description: "How often the Pro fee is charged.",
99
- identifier: "ProInterval"
100
- });
101
- const ProPrice = Struct({
102
- interval: ProInterval,
103
- micro_usd: MicroUsd
104
- }).annotate({
105
- description: "The fixed Pro fee for each billing interval.",
106
- identifier: "ProPrice"
107
- });
108
- const Billing = Struct({
109
- credit_balance_micro_usd: Int.annotate({ description: "Credits bought, less refunds and open disputes. A refund after use can take it below zero." }),
110
- credits_on_sale: Boolean.annotate({ description: "Whether a credit purchase is open. Credits go on sale from the moment the latest price notice states." }),
111
- plan: Plan,
112
- pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
113
- }).annotate({ identifier: "Billing" });
114
- const CreditTerms = Struct({
115
- fee_fixed_micro_usd: MicroUsd.annotate({ description: "The fixed part of the processing fee that comes out of each credit purchase." }),
116
- 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%." }),
117
- max_micro_usd: MicroUsd.annotate({ description: "The largest credit purchase, in whole US dollars." }),
118
- min_micro_usd: MicroUsd.annotate({ description: "The smallest credit purchase, in whole US dollars." })
119
- }).annotate({
120
- 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.",
121
- identifier: "CreditTerms"
122
- });
123
- const Pricing = Struct({
124
- credits: CreditTerms,
125
- pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
126
- }).annotate({
127
- description: "The public prices: the Pro price for one organization and the terms of a credit purchase.",
128
- identifier: "Pricing"
129
- });
130
- Struct({ amount_micro_usd: MicroUsd.check(isMultipleOf(MICRO_USD_PER_DOLLAR), isBetween({
131
- maximum: CREDIT_PURCHASE_MAX_MICRO_USD,
132
- minimum: CREDIT_PURCHASE_MIN_MICRO_USD
133
- })).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.` }) }).annotate({ identifier: "CreditPurchaseRequest" });
134
- 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" });
135
- const StandardSize = NonEmptyString.annotate({
136
- description: "A standard size named `<vCPU>x<memory GiB>`, such as `1x2`, `2x4`, `4x8`, or `8x16`. The API adds sizes over time.",
137
- examples: [
138
- {
139
- memory_mib: 2048,
140
- name: "1x2",
141
- vcpu: 1
142
- },
143
- {
144
- memory_mib: 4096,
145
- name: "2x4",
146
- vcpu: 2
147
- },
148
- {
149
- memory_mib: 8192,
150
- name: "4x8",
151
- vcpu: 4
152
- },
153
- {
154
- memory_mib: 16384,
155
- name: "8x16",
156
- vcpu: 8
157
- }
158
- ].map(({ name }) => name),
159
- identifier: "StandardSize"
160
- });
161
- const ProviderSort = Literals([
162
- "latency",
163
- "price",
164
- "uptime"
165
- ]).annotate({
166
- 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.",
167
- identifier: "ProviderSort"
168
- });
169
- const ROUTER = "sandcovery";
170
- const DEFAULT_SLUG = `${ROUTER}/2x4`;
171
- const MIB_PER_GIB = 1024;
172
- const ANY = "n";
173
- const vcpusOf = (text) => {
174
- if (text === ANY) return null;
175
- const value = Number(text);
176
- return Number.isSafeInteger(value) && value > 0 && String(value) === text ? value : void 0;
177
- };
178
- const memoryGibOf = (text) => {
179
- if (text === ANY) return null;
180
- const value = Number(text);
181
- return String(value) === text && value > 0 && Number.isSafeInteger(value * MIB_PER_GIB) ? value : void 0;
182
- };
183
- const parseSlug = (text) => {
184
- const [provider = "", size = "", ...extraPaths] = text.split("/");
185
- const [dimensions = "", suffix, ...extraSuffixes] = size.split(":");
186
- const [vcpuText = "", memoryText = "", ...extraParts] = dimensions.split("x");
187
- if (extraPaths.length + extraSuffixes.length + extraParts.length > 0 || suffix === "" || !isProviderName(provider)) return;
188
- const vcpus = vcpusOf(vcpuText);
189
- const memoryGib = memoryGibOf(memoryText);
190
- return vcpus === void 0 || memoryGib === void 0 ? void 0 : {
191
- memoryGib,
192
- provider,
193
- suffix: suffix ?? null,
194
- vcpus
195
- };
196
- };
197
- const SLUG_EXAMPLES = [
198
- `${ROUTER}/2x4`,
199
- `${ROUTER}/2x4:cheapest`,
200
- `${ROUTER}/nx16:cheapest`,
201
- `${ROUTER}/2xn:fastest`,
202
- `${ROUTER}/nxn:most-reliable`,
203
- "boat/2x4",
204
- "e2b/2x0.5"
205
- ];
206
- const Slug = String$1.check(makeFilter((text) => parseSlug(text) !== void 0, {
207
- expected: "<provider>/<vcpu>x<memory_gib>, optionally followed by a routing suffix",
208
- toJsonSchema: () => ({ minLength: 1 })
209
- })).annotate({
210
- 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\`.`,
211
- examples: SLUG_EXAMPLES,
212
- identifier: "Slug"
213
- });
214
- 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}\`.`;
215
- const RoutingFields = {
216
- slug: optionalKey(Slug),
217
- 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.` }))
218
- };
219
- const ProviderPreferences = Struct({
220
- 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." })),
221
- ignore: optionalKey(ArraySchema(Provider).annotate({ description: "Providers never to route to." })),
222
- only: optionalKey(ArraySchema(Provider).annotate({ description: "The only providers to route to." })),
223
- order: optionalKey(ArraySchema(Provider).annotate({ description: `Providers a \`${ROUTER}/\` slug tries first, in this order, before its remaining candidates in sorted order.` })),
224
- sort: optionalKey(ProviderSort)
225
- }).annotate({
226
- 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\`.`,
227
- identifier: "ProviderPreferences"
228
- });
229
- // ../sandcovery-contract/src/sandbox.ts
230
- const MAX_TTL_SECONDS = 86400;
231
- const MAX_PORT = 65535;
232
- const MAX_PORTS = 8;
233
- const MAX_GPUS = 8;
234
- const between = (minimum, maximum) => Int.check(isBetween({
235
- maximum,
236
- minimum
237
- }));
238
- const Port = between(1, MAX_PORT);
239
- const Gpu = Struct({
240
- count: between(1, MAX_GPUS).annotate({ description: "How many GPUs of `type` the sandbox gets, from 1 to 8." }),
241
- type: GpuType
242
- }).annotate({
243
- 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.",
244
- identifier: "Gpu"
245
- });
246
- const EnvironmentVariables = Record(NonEmptyString, String$1).annotate({ description: "Environment variables by name. Sandcovery passes them to the provider and never returns them." });
247
- const EgressPolicy = Union([
248
- Struct({ mode: Literal("allow_all") }),
249
- Struct({ mode: Literal("deny_all") }),
250
- Struct({
251
- destinations: NonEmptyArray(NonEmptyString).annotate({ description: "Host names or CIDR blocks the sandbox may reach." }),
252
- mode: Literal("allowlist")
253
- })
254
- ]).annotate({
255
- description: "Outbound network access: `allow_all`, `deny_all`, or `allowlist` with the destinations the sandbox may reach.",
256
- identifier: "EgressPolicy"
257
- });
258
- const SandboxSpec = Struct({
259
- disk_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(1024)).annotate({ description: "Disk size in MiB. Defaults to the provider default." })),
260
- egress: optionalKey(EgressPolicy),
261
- env: optionalKey(EnvironmentVariables),
262
- gpu: optionalKey(Gpu),
263
- 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." })),
264
- image: optionalKey(NonEmptyString.annotate({ description: "An OCI image reference. Unset means the provider's default Linux image." })),
265
- ports: optionalKey(ArraySchema(Port).check(isMaxLength(MAX_PORTS)).annotate({ description: "Ports to expose for preview URLs. Some providers expose only ports declared at create." })),
266
- region: optionalKey(Region),
267
- 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." }))
268
- });
269
- const CreateSandboxRequest = Struct({
270
- ...SandboxSpec.fields,
271
- ...RoutingFields,
272
- provider: optionalKey(ProviderPreferences),
273
- snapshot_id: optionalKey(SnapshotId.annotate({ description: "A snapshot to start from. The sandbox runs on the snapshot's provider." }))
274
- }).annotate({
275
- 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.`,
276
- identifier: "CreateSandboxRequest"
277
- });
278
- const CreateAttempt = Struct({
279
- duration_ms: Natural,
280
- failure: NullOr(Struct({
281
- message: String$1,
282
- reason: Literals([
283
- "capacity",
284
- "quota",
285
- "rejected",
286
- "server_error",
287
- "timeout"
288
- ]).annotate({ identifier: "CreateFailureReason" })
289
- }).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." })),
290
- provider: Provider,
291
- started_at: Timestamp
292
- }).annotate({
293
- description: "One provider create call made while routing a sandbox. `failure` is null on the attempt that created it.",
294
- identifier: "CreateAttempt"
295
- });
296
- const SandboxStatus = Literals([
297
- "creating",
298
- "destroyed",
299
- "destroying",
300
- "failed",
301
- "paused",
302
- "running"
303
- ]).annotate({ identifier: "SandboxStatus" });
304
- const SandboxEndReason = Literals([
305
- "create_failed",
306
- "destroyed",
307
- "expired",
308
- "gone"
309
- ]).annotate({
310
- 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.",
311
- identifier: "SandboxEndReason"
312
- });
313
- const SandboxCost = Struct({
314
- estimated_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost so far, from the rate card, until the sandbox is destroyed." }),
315
- hourly_micro_usd: MicroUsd,
316
- rate_card_version: String$1
317
- }).annotate({
318
- description: "Estimated cost at the provider's list price from a versioned rate card. The provider bills your own account.",
319
- identifier: "SandboxCost"
320
- });
321
- const Sandbox = Struct({
322
- 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." }),
323
- attempts: ArraySchema(CreateAttempt),
324
- cost: SandboxCost,
325
- created_at: Timestamp,
326
- disk_mib: NullOr(Natural),
327
- egress: EgressPolicy,
328
- end_reason: NullOr(SandboxEndReason),
329
- ended_at: NullOr(Timestamp),
330
- expires_at: Timestamp,
331
- gpu: NullOr(Gpu),
332
- id: SandboxId,
333
- idle_timeout_seconds: NullOr(Natural),
334
- image: NullOr(String$1),
335
- 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." }),
336
- ports: ArraySchema(Port),
337
- provider: NullOr(Provider).annotate({ description: "The provider the sandbox is bound to, or null while it is creating or when every create attempt failed." }),
338
- provider_sandbox_id: NullOr(String$1),
339
- region: NullOr(Region),
340
- 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." }),
341
- started_at: NullOr(Timestamp).annotate({ description: "When the provider reported the sandbox running." }),
342
- status: SandboxStatus,
343
- ttl_seconds: Natural,
344
- 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." })
345
- }).annotate({
346
- 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.",
347
- identifier: "Sandbox"
348
- });
349
- const SandboxList = Struct({
350
- data: ArraySchema(Sandbox),
351
- next_cursor: NullOr(String$1)
352
- }).annotate({ identifier: "SandboxList" });
353
- const Snapshot = Struct({
354
- created_at: Timestamp,
355
- id: SnapshotId,
356
- provider: Provider,
357
- sandbox_id: SandboxId
358
- }).annotate({
359
- description: "A snapshot of a sandbox filesystem. A sandbox created from it runs on the same provider.",
360
- identifier: "Snapshot"
361
- });
362
- const PortPreview = Struct({
363
- expires_at: NullOr(Timestamp),
364
- headers: Record(String$1, String$1).annotate({ description: "Headers a request to `url` must carry, such as a provider preview token. Often empty." }),
365
- port: Port,
366
- url: String$1
367
- }).annotate({
368
- description: "A provider URL that reaches a port inside the sandbox.",
369
- identifier: "PortPreview"
370
- });
371
- const KeyName = NonEmptyString.check(isMaxLength(64));
372
- const PositiveInt = Int.check(isGreaterThanOrEqualTo(1));
373
- const KeyKind = Literals(["api", "management"]).annotate({
374
- 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.",
375
- identifier: "KeyKind"
376
- });
377
- const SpendLimit = Struct({
378
- limit_micro_usd: MicroUsd,
379
- period: Literals([
380
- "day",
381
- "month",
382
- "total",
383
- "week"
384
- ]).annotate({
385
- 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`.",
386
- identifier: "SpendLimitPeriod"
387
- })
388
- }).annotate({
389
- description: "A cap on the list-price cost of sandboxes the key creates, counting usage billed to your own provider accounts.",
390
- identifier: "SpendLimit"
391
- });
392
- const keyPolicyFields = {
393
- allowed_providers: NullOr(ArraySchema(Provider)).annotate({ description: "The only providers the key may route to. Null allows all." }),
394
- max_concurrent_sandboxes: NullOr(PositiveInt),
395
- max_ttl_seconds: NullOr(PositiveInt),
396
- spend_limit: NullOr(SpendLimit)
397
- };
398
- const Key = Struct({
399
- ...keyPolicyFields,
400
- created_at: Timestamp,
401
- expires_at: NullOr(Timestamp),
402
- id: KeyId,
403
- kind: KeyKind,
404
- last_used_at: NullOr(Timestamp),
405
- name: String$1,
406
- revoked_at: NullOr(Timestamp),
407
- spend: Struct({
408
- resets_at: NullOr(Timestamp),
409
- spent_micro_usd: MicroUsd
410
- }).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." }),
411
- start: String$1.annotate({ description: "The first 12 characters of the secret, for display." })
412
- }).annotate({
413
- description: "An API key or a management key. Its secret is never returned after creation, and the limits are null on a management key.",
414
- identifier: "Key"
415
- });
416
- const KeyList = Struct({ data: ArraySchema(Key) }).annotate({ identifier: "KeyList" });
417
- const CreateKeyRequest = Struct({
418
- allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
419
- expires_at: optionalKey(NullOr(Timestamp)),
420
- kind: optionalKey(KeyKind).annotate({ description: "Defaults to `api`. Only a signed-in owner mints a `management` key, and a management key takes no limits." }),
421
- max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
422
- max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
423
- name: KeyName,
424
- spend_limit: optionalKey(keyPolicyFields.spend_limit)
425
- }).annotate({ identifier: "CreateKeyRequest" });
426
- const UpdateKeyRequest = Struct({
427
- allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
428
- expires_at: optionalKey(NullOr(Timestamp)),
429
- max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
430
- max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
431
- name: optionalKey(KeyName),
432
- spend_limit: optionalKey(keyPolicyFields.spend_limit)
433
- }).annotate({
434
- 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`.",
435
- identifier: "UpdateKeyRequest"
436
- });
437
- const CreatedKey = Struct({
438
- key: Key,
439
- secret: KeySecret
440
- }).annotate({ identifier: "CreatedKey" });
441
- // ../sandcovery-contract/src/origin.ts
442
- const SANDCOVERY_ORIGIN = "https://www.sandcovery.com";
443
- const API_PREFIX = "/api/v1";
444
- export { CreditCheckout as A, MicroUsd as B, RoutingFields as C, CARD_FEE_TERMS as D, Billing as E, CiJobId as F, Region as H, CredentialId as I, GpuType as L, NO_MARKUP_TERMS as M, Pricing as N, CREDIT_PURCHASE_MAX_MICRO_USD as O, ApiKeyId as P, KeyId as R, ROUTING_FIELDS_TEXT as S, StandardSize as T, SandboxId as U, Provider as V, Timestamp as W, SandboxStatus as _, Key as a, ProviderPreferences as b, SpendLimit as c, CreateSandboxRequest as d, Port as f, SandboxSpec as g, SandboxList as h, CreatedKey as i, MICRO_USD_PER_DOLLAR as j, CREDIT_PURCHASE_MIN_MICRO_USD as k, UpdateKeyRequest as l, Sandbox as m, SANDCOVERY_ORIGIN as n, KeyKind as o, PortPreview as p, CreateKeyRequest as r, KeyList as s, API_PREFIX as t, CreateAttempt as u, Snapshot as v, Slug as w, ProviderSort as x, DEFAULT_SLUG as y, KeySecret as z };
@@ -1,5 +1,5 @@
1
- import os from "node:os";
2
1
  import { spawn } from "node:child_process";
2
+ import os from "node:os";
3
3
  // ../cli-core/src/telemetry.ts
4
4
  const childEnv = () => {
5
5
  const temporary = os.tmpdir();