sandcovery 0.3.0 → 0.5.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 +14 -5
- package/dist/{Schema-DiSfJzMf.mjs → Schema-fLas6rbA.mjs} +8069 -930
- package/dist/cli/index.mjs +2 -1707
- package/dist/cli/sandcovery-docker.d.mts +1 -0
- package/dist/cli/sandcovery-docker.mjs +8 -0
- package/dist/handlers-qYjkPftS.mjs +18077 -0
- package/dist/index.d.mts +23 -1
- package/dist/index.mjs +1 -1
- package/dist/{origin-CIA-1Jia.mjs → origin-5maEGWRg.mjs} +105 -74
- package/dist/{spec-DfgmzDj-.mjs → spec-cGDeWJ3v.mjs} +951 -122
- package/dist/{src-YrynO3hz.mjs → src-zWk1RjrB.mjs} +241 -23
- package/dist/start-B8ruSPVb.mjs +1992 -0
- package/dist/{telemetry-delivery-zinKRHRc.mjs → telemetry-delivery-8t5RXWli.mjs} +3 -3
- package/dist/{types-DMB8KnA3.d.mts → types-ZqbGCXKy.d.mts} +153 -12
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +18 -18
- package/package.json +17 -13
- package/dist/handlers-rkx0CsMY.mjs +0 -2459
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as
|
|
1
|
+
import { B as tag, E as fromJsonString, L as makeFilter, S as decodeUnknownOption, _ as Struct, a as Finite, d as Natural, er as getOrElse, g as String$1, h as Record, i as Error$1, 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, w as decodeUnknownSync, z as optionalKey } from "./Schema-fLas6rbA.mjs";
|
|
2
|
+
import { A as CreditCheckout, B as MicroUsd, C as RoutingFields, E as Billing, F as CiJobId, H as Region, I as CredentialId, L as GpuType, N as Pricing, P as ApiKeyId, R as KeyId, S as ROUTING_FIELDS_TEXT, T as StandardSize, U as SandboxId, V as Provider, W as Timestamp, a as Key, b as ProviderPreferences, f as Port, g as SandboxSpec, h as SandboxList, i as CreatedKey, m as Sandbox, p as PortPreview, s as KeyList, t as API_PREFIX, u as CreateAttempt, v as Snapshot, w as Slug } from "./origin-5maEGWRg.mjs";
|
|
3
3
|
// ../../node_modules/.pnpm/effect@4.1.1/node_modules/effect/dist/ErrorReporter.js
|
|
4
4
|
/**
|
|
5
5
|
* Defines the runtime property key used to mark an object error as ignored by error
|
|
@@ -113,6 +113,18 @@ const ProviderStatus = Literals([
|
|
|
113
113
|
"operational",
|
|
114
114
|
"unknown"
|
|
115
115
|
]).annotate({ identifier: "ProviderStatus" });
|
|
116
|
+
const BrandImage = Struct({
|
|
117
|
+
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." }),
|
|
118
|
+
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." }),
|
|
119
|
+
url: String$1.annotate({ description: "Sandcovery's own copy of the image." })
|
|
120
|
+
}).annotate({ identifier: "BrandImage" });
|
|
121
|
+
const ThemedBrandImage = Struct({
|
|
122
|
+
dark: BrandImage,
|
|
123
|
+
light: BrandImage
|
|
124
|
+
}).annotate({
|
|
125
|
+
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.",
|
|
126
|
+
identifier: "ThemedBrandImage"
|
|
127
|
+
});
|
|
116
128
|
const securityFact = (value) => Struct({
|
|
117
129
|
detail: NullOr(String$1).annotate({ description: "A sentence that qualifies the value, or null." }),
|
|
118
130
|
read_at: Timestamp.annotate({ description: "The UTC day Sandcovery read the provider's page." }),
|
|
@@ -172,6 +184,7 @@ const ProviderBoardEntry = Struct({
|
|
|
172
184
|
}).annotate({ description: "Create latency of the probe sandboxes over the last 24 hours, or null before the first probe or when `health_published` is false." }),
|
|
173
185
|
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." }),
|
|
174
186
|
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." }),
|
|
187
|
+
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." }),
|
|
175
188
|
features: ProviderFeatures,
|
|
176
189
|
gpu_prices: ArraySchema(Struct({
|
|
177
190
|
hourly_micro_usd: MicroUsd,
|
|
@@ -231,10 +244,25 @@ const CatalogGpus = fact(ArraySchema(Struct({
|
|
|
231
244
|
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.",
|
|
232
245
|
identifier: "CatalogGpus"
|
|
233
246
|
});
|
|
247
|
+
const CATALOG_MEASUREMENTS = [
|
|
248
|
+
"measured",
|
|
249
|
+
"not_measured",
|
|
250
|
+
"not_published"
|
|
251
|
+
];
|
|
252
|
+
const BENCHMARK_TERMS = [
|
|
253
|
+
"barred",
|
|
254
|
+
"conditional",
|
|
255
|
+
"no_bar_found"
|
|
256
|
+
];
|
|
234
257
|
const ProviderCatalogEntry = Struct({
|
|
235
258
|
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." }),
|
|
236
259
|
billing: NullOr(CatalogText).annotate({ description: "The unit the provider bills a sandbox in, such as per second or per session-hour." }),
|
|
260
|
+
brand: Struct({
|
|
261
|
+
favicon: NullOr(ThemedBrandImage),
|
|
262
|
+
logo: NullOr(ThemedBrandImage)
|
|
263
|
+
}).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." }),
|
|
237
264
|
capabilities: Struct({
|
|
265
|
+
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." }),
|
|
238
266
|
custom_image: NullOr(CatalogFlag),
|
|
239
267
|
environment: NullOr(CatalogFlag),
|
|
240
268
|
files: NullOr(CatalogFlag),
|
|
@@ -268,24 +296,20 @@ const ProviderCatalogEntry = Struct({
|
|
|
268
296
|
terms_url: String$1
|
|
269
297
|
}).annotate({ description: "The provider's own public pages." }),
|
|
270
298
|
measured_at: NullOr(Timestamp).annotate({ description: "When the published uptime and create latency were last rolled up, or null when none is published." }),
|
|
271
|
-
measurement: Literals(
|
|
272
|
-
"measured",
|
|
273
|
-
"not_measured",
|
|
274
|
-
"not_published"
|
|
275
|
-
]).annotate({
|
|
299
|
+
measurement: Literals(CATALOG_MEASUREMENTS).annotate({
|
|
276
300
|
description: "Whether the figures are measured: `measured` when Sandcovery probes the provider and publishes the result, `not_published` when it probes the provider and the provider's terms do not allow publishing the result, and `not_measured` when it runs no probe there.",
|
|
277
301
|
identifier: "CatalogMeasurement"
|
|
278
302
|
}),
|
|
279
303
|
name: String$1,
|
|
280
304
|
policy: Struct({
|
|
281
|
-
benchmark_terms: fact(Literals(
|
|
282
|
-
"barred",
|
|
283
|
-
"conditional",
|
|
284
|
-
"no_bar_found"
|
|
285
|
-
])).annotate({
|
|
305
|
+
benchmark_terms: fact(Literals(BENCHMARK_TERMS)).annotate({
|
|
286
306
|
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.",
|
|
287
307
|
identifier: "CatalogBenchmarkTerms"
|
|
288
308
|
}),
|
|
309
|
+
brand_terms: fact(Literals(BENCHMARK_TERMS)).annotate({
|
|
310
|
+
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.",
|
|
311
|
+
identifier: "CatalogBrandTerms"
|
|
312
|
+
}),
|
|
289
313
|
compliance: ProviderSecurity.fields.compliance,
|
|
290
314
|
data_location: ProviderSecurity.fields.data_location,
|
|
291
315
|
free_allowance: NullOr(CatalogText).annotate({ description: "The free usage or credit the provider states." }),
|
|
@@ -322,6 +346,67 @@ const ProviderCatalogEntry = Struct({
|
|
|
322
346
|
identifier: "ProviderCatalogEntry"
|
|
323
347
|
});
|
|
324
348
|
const ProviderCatalog = Struct({ data: ArraySchema(ProviderCatalogEntry) }).annotate({ identifier: "ProviderCatalog" });
|
|
349
|
+
// ../sandcovery-contract/src/ci.ts
|
|
350
|
+
const GitHubId = Int.check(isGreaterThanOrEqualTo(1));
|
|
351
|
+
const CiJobStatus = Literals([
|
|
352
|
+
"completed",
|
|
353
|
+
"in_progress",
|
|
354
|
+
"queued"
|
|
355
|
+
]).annotate({
|
|
356
|
+
description: "Where GitHub reports the job: `queued` until a runner takes it, `in_progress` while it runs, and `completed` once it ends.",
|
|
357
|
+
identifier: "CiJobStatus"
|
|
358
|
+
});
|
|
359
|
+
const CiJobConclusion = NonEmptyString.annotate({
|
|
360
|
+
description: "How GitHub concluded the job, such as `success`, `failure`, `cancelled`, `skipped`, or `timed_out`. GitHub adds conclusions over time.",
|
|
361
|
+
examples: [
|
|
362
|
+
"action_required",
|
|
363
|
+
"cancelled",
|
|
364
|
+
"failure",
|
|
365
|
+
"neutral",
|
|
366
|
+
"skipped",
|
|
367
|
+
"success",
|
|
368
|
+
"timed_out"
|
|
369
|
+
],
|
|
370
|
+
identifier: "CiJobConclusion"
|
|
371
|
+
});
|
|
372
|
+
const CiJob = Struct({
|
|
373
|
+
completed_at: NullOr(Timestamp).annotate({ description: "When GitHub reported the job completed." }),
|
|
374
|
+
conclusion: NullOr(CiJobConclusion),
|
|
375
|
+
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." }),
|
|
376
|
+
duration_ms: NullOr(Natural).annotate({ description: "Milliseconds from start to completion. Null until the job completes." }),
|
|
377
|
+
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." }),
|
|
378
|
+
id: CiJobId,
|
|
379
|
+
job_name: String$1,
|
|
380
|
+
provider: NullOr(Provider).annotate({ description: "The provider of the runner sandbox that took the job, or null until a Sandcovery runner takes it." }),
|
|
381
|
+
queued_at: Timestamp,
|
|
382
|
+
repository: NonEmptyString.annotate({ description: "The repository as `<owner>/<name>`." }),
|
|
383
|
+
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." }),
|
|
384
|
+
runner_label: NonEmptyString.annotate({ description: "The Sandcovery runner label the job asked for, such as `sandcovery/4x16:cheapest`." }),
|
|
385
|
+
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." }),
|
|
386
|
+
started_at: NullOr(Timestamp).annotate({ description: "When GitHub reported a runner started the job." }),
|
|
387
|
+
status: CiJobStatus,
|
|
388
|
+
wait_ms: NullOr(Natural).annotate({ description: "Milliseconds from queued to started. Null until the job starts." }),
|
|
389
|
+
workflow_job_id: GitHubId.annotate({ description: "GitHub's job ID." }),
|
|
390
|
+
workflow_run_id: GitHubId.annotate({ description: "GitHub's workflow run ID." })
|
|
391
|
+
}).annotate({
|
|
392
|
+
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.",
|
|
393
|
+
identifier: "CiJob"
|
|
394
|
+
});
|
|
395
|
+
const CiJobList = Struct({
|
|
396
|
+
data: ArraySchema(CiJob),
|
|
397
|
+
next_cursor: NullOr(String$1)
|
|
398
|
+
}).annotate({ identifier: "CiJobList" });
|
|
399
|
+
const CiInstallation = Struct({
|
|
400
|
+
account: NonEmptyString.annotate({ description: "The GitHub organization the installation belongs to." }),
|
|
401
|
+
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." }),
|
|
402
|
+
installation_id: GitHubId.annotate({ description: "GitHub's ID of the Sandcovery CI GitHub App installation." }),
|
|
403
|
+
linked_at: Timestamp,
|
|
404
|
+
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." })
|
|
405
|
+
}).annotate({
|
|
406
|
+
description: "A GitHub installation of the Sandcovery CI GitHub App, linked to this organization.",
|
|
407
|
+
identifier: "CiInstallation"
|
|
408
|
+
});
|
|
409
|
+
const CiInstallationList = Struct({ data: ArraySchema(CiInstallation) }).annotate({ identifier: "CiInstallationList" });
|
|
325
410
|
// ../sandcovery-contract/src/credentials.ts
|
|
326
411
|
const CredentialFields = Record(String$1, NonEmptyString).annotate({
|
|
327
412
|
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`.",
|
|
@@ -330,13 +415,15 @@ const CredentialFields = Record(String$1, NonEmptyString).annotate({
|
|
|
330
415
|
const ProviderCredential = Struct({
|
|
331
416
|
created_at: Timestamp,
|
|
332
417
|
hint: String$1.annotate({ description: "The last four characters of the first secret field, for display." }),
|
|
418
|
+
id: CredentialId,
|
|
419
|
+
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." }),
|
|
333
420
|
provider: Provider,
|
|
334
421
|
updated_at: Timestamp
|
|
335
422
|
}).annotate({
|
|
336
423
|
description: "A stored provider credential. Sandcovery encrypts it at rest and never returns its fields.",
|
|
337
424
|
identifier: "ProviderCredential"
|
|
338
425
|
});
|
|
339
|
-
const ProviderCredentialList = Struct({ data: ArraySchema(ProviderCredential) }).annotate({ identifier: "ProviderCredentialList" });
|
|
426
|
+
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" });
|
|
340
427
|
// ../sandcovery-contract/src/errors/concurrency-limit-reached.ts
|
|
341
428
|
var ConcurrencyLimitReached = class extends Error$1("ConcurrencyLimitReached")({
|
|
342
429
|
concurrency_cap: Natural,
|
|
@@ -365,7 +452,7 @@ var Forbidden = class extends Error$1("Forbidden")({
|
|
|
365
452
|
error: tag("forbidden"),
|
|
366
453
|
message: String$1
|
|
367
454
|
}, {
|
|
368
|
-
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 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.",
|
|
455
|
+
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.",
|
|
369
456
|
httpApiStatus: 403,
|
|
370
457
|
identifier: "Forbidden"
|
|
371
458
|
}) {
|
|
@@ -442,10 +529,10 @@ var Unauthorized = class extends Error$1("Unauthorized")({
|
|
|
442
529
|
var Unsupported = class extends Error$1("Unsupported")({
|
|
443
530
|
error: tag("unsupported"),
|
|
444
531
|
message: String$1,
|
|
445
|
-
options: ArraySchema(String$1).annotate({ description: "
|
|
532
|
+
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." }),
|
|
446
533
|
provider: NullOr(Provider).annotate({ description: "The sandbox's provider for an operation on an existing sandbox, or null for a create." })
|
|
447
534
|
}, {
|
|
448
|
-
description: "A
|
|
535
|
+
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.",
|
|
449
536
|
httpApiStatus: 422,
|
|
450
537
|
identifier: "Unsupported"
|
|
451
538
|
}) {
|
|
@@ -556,18 +643,23 @@ const Offer = Struct({
|
|
|
556
643
|
// ../sandcovery-contract/src/usage.ts
|
|
557
644
|
const EstimateRequest = Struct({
|
|
558
645
|
...SandboxSpec.fields,
|
|
646
|
+
...RoutingFields,
|
|
559
647
|
provider: optionalKey(ProviderPreferences)
|
|
560
648
|
}).annotate({
|
|
561
|
-
description:
|
|
649
|
+
description: `A sandbox spec, the slug or slugs to run it on, and routing preferences, to price without creating anything. ${ROUTING_FIELDS_TEXT}`,
|
|
562
650
|
identifier: "EstimateRequest"
|
|
563
651
|
});
|
|
564
652
|
const Estimate = Struct({
|
|
565
653
|
hourly_micro_usd: MicroUsd,
|
|
566
654
|
provider: Provider,
|
|
567
655
|
rate_card_version: String$1,
|
|
656
|
+
slug: Slug,
|
|
568
657
|
ttl_micro_usd: MicroUsd.annotate({ description: "List-price cost if the sandbox runs for its whole TTL." })
|
|
569
|
-
}).annotate({
|
|
570
|
-
|
|
658
|
+
}).annotate({
|
|
659
|
+
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.",
|
|
660
|
+
identifier: "Estimate"
|
|
661
|
+
});
|
|
662
|
+
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" });
|
|
571
663
|
const isCalendarDay = makeFilter((value) => {
|
|
572
664
|
const at = Date.parse(`${value}T00:00:00.000Z`);
|
|
573
665
|
return Number.isFinite(at) && new Date(at).toISOString().slice(0, 10) === value;
|
|
@@ -582,17 +674,110 @@ Struct({
|
|
|
582
674
|
to: CalendarDay.annotate({ description: "Last UTC day, inclusive. At most 92 days after `from`." })
|
|
583
675
|
});
|
|
584
676
|
const UsageDay = Struct({
|
|
585
|
-
api_key_id: ApiKeyId.annotate({ description: "The key that created the sandboxes." }),
|
|
677
|
+
api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
|
|
586
678
|
date: CalendarDay,
|
|
587
679
|
estimated_micro_usd: MicroUsd,
|
|
680
|
+
gpu_seconds: Natural.annotate({ description: "GPU-seconds: each sandbox GPU count times its seconds run." }),
|
|
681
|
+
memory_gib_seconds: Natural.annotate({ description: "GiB-seconds: each sandbox memory in GiB times its seconds run, rounded to a whole number." }),
|
|
588
682
|
provider: Provider,
|
|
589
683
|
sandbox_count: Natural,
|
|
590
|
-
sandbox_seconds: Natural
|
|
684
|
+
sandbox_seconds: Natural,
|
|
685
|
+
vcpu_seconds: Natural.annotate({ description: "vCPU-seconds: each sandbox vCPU count times its seconds run." })
|
|
591
686
|
}).annotate({
|
|
592
|
-
description: "Estimated list-price usage of one key on one provider on one UTC day.",
|
|
687
|
+
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.",
|
|
593
688
|
identifier: "UsageDay"
|
|
594
689
|
});
|
|
595
690
|
const Usage = Struct({ data: ArraySchema(UsageDay) }).annotate({ identifier: "Usage" });
|
|
691
|
+
Struct({ api_key_id: optionalKey(ApiKeyId) });
|
|
692
|
+
const LiveSandboxes = Struct({
|
|
693
|
+
accrued_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost these sandboxes have run up from their start to now or their TTL." }),
|
|
694
|
+
api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
|
|
695
|
+
gpus: Natural,
|
|
696
|
+
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." }),
|
|
697
|
+
memory_mib: Natural,
|
|
698
|
+
provider: NullOr(Provider).annotate({ description: "The provider running the sandboxes, or null for creates no provider has started yet." }),
|
|
699
|
+
sandbox_count: Natural,
|
|
700
|
+
status: Literals([
|
|
701
|
+
"creating",
|
|
702
|
+
"destroying",
|
|
703
|
+
"paused",
|
|
704
|
+
"running"
|
|
705
|
+
]).annotate({ identifier: "LiveSandboxStatus" }),
|
|
706
|
+
vcpus: Natural
|
|
707
|
+
}).annotate({
|
|
708
|
+
description: "The live sandboxes of one key on one provider in one status, with the vCPUs, memory, and GPUs their specs hold.",
|
|
709
|
+
identifier: "LiveSandboxes"
|
|
710
|
+
});
|
|
711
|
+
const LiveUsage = Struct({
|
|
712
|
+
at: Timestamp.annotate({ description: "When the API read these figures." }),
|
|
713
|
+
data: ArraySchema(LiveSandboxes)
|
|
714
|
+
}).annotate({ identifier: "LiveUsage" });
|
|
715
|
+
const UsageTotal = Struct({
|
|
716
|
+
estimated_micro_usd: MicroUsd,
|
|
717
|
+
gpu_seconds: Natural,
|
|
718
|
+
memory_gib_seconds: Natural,
|
|
719
|
+
period: Literals([
|
|
720
|
+
"day",
|
|
721
|
+
"month",
|
|
722
|
+
"total",
|
|
723
|
+
"week"
|
|
724
|
+
]).annotate({
|
|
725
|
+
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.",
|
|
726
|
+
identifier: "UsagePeriod"
|
|
727
|
+
}),
|
|
728
|
+
sandbox_count: Natural.annotate({ description: "Sandboxes that ran at any time in the window." }),
|
|
729
|
+
sandbox_seconds: Natural,
|
|
730
|
+
since: NullOr(Timestamp).annotate({ description: "The start of the window, or null for `total`." }),
|
|
731
|
+
vcpu_seconds: Natural
|
|
732
|
+
}).annotate({
|
|
733
|
+
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.",
|
|
734
|
+
identifier: "UsageTotal"
|
|
735
|
+
});
|
|
736
|
+
const UsageTotals = Struct({
|
|
737
|
+
at: Timestamp.annotate({ description: "When the API read these figures." }),
|
|
738
|
+
data: ArraySchema(UsageTotal).annotate({ description: "One total for each window: `day`, `week`, `month`, `total`." })
|
|
739
|
+
}).annotate({ identifier: "UsageTotals" });
|
|
740
|
+
// ../sandcovery-contract/src/stats.ts
|
|
741
|
+
const StatsDay = Struct({
|
|
742
|
+
date: CalendarDay,
|
|
743
|
+
sandbox_count: Natural.annotate({ description: "Sandboxes that started on this UTC day." })
|
|
744
|
+
}).annotate({ identifier: "StatsDay" });
|
|
745
|
+
const Badge = Struct({
|
|
746
|
+
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." }),
|
|
747
|
+
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." }),
|
|
748
|
+
name: NonEmptyString.annotate({ description: "The badge as a person reads it, such as `100 Sandboxes`." }),
|
|
749
|
+
progress: Natural.annotate({ description: "How far the organization has come toward `target`, at most `target`." }),
|
|
750
|
+
target: Natural.annotate({ description: "What earns the badge, in `unit`." }),
|
|
751
|
+
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." })
|
|
752
|
+
}).annotate({ identifier: "Badge" });
|
|
753
|
+
const Stats = Struct({
|
|
754
|
+
badges: ArraySchema(Badge),
|
|
755
|
+
busiest_day: NullOr(StatsDay).annotate({ description: "The UTC day the most sandboxes started, the earliest such day on a tie." }),
|
|
756
|
+
days: ArraySchema(StatsDay).annotate({ description: "Each UTC day of the last 365, today included, on which at least one sandbox started, oldest first." }),
|
|
757
|
+
largest_sandbox: NullOr(Struct({
|
|
758
|
+
memory_mib: Natural,
|
|
759
|
+
provider: Provider,
|
|
760
|
+
sandbox_id: SandboxId,
|
|
761
|
+
vcpus: Natural
|
|
762
|
+
})).annotate({ description: "The started sandbox with the most vCPUs, then the most memory, the earliest on a tie." }),
|
|
763
|
+
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." }),
|
|
764
|
+
level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds at which the current level started." }),
|
|
765
|
+
longest_run: NullOr(Struct({
|
|
766
|
+
provider: Provider,
|
|
767
|
+
sandbox_id: SandboxId,
|
|
768
|
+
seconds: Natural
|
|
769
|
+
})).annotate({ description: "The sandbox that ran longest, up to its end or its TTL, counting a live one up to now." }),
|
|
770
|
+
next_level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds the next level starts at." }),
|
|
771
|
+
sandbox_count: Natural.annotate({ description: "Sandboxes the organization started." }),
|
|
772
|
+
streak: Struct({
|
|
773
|
+
current_days: Natural.annotate({ description: "Consecutive UTC days with a sandbox start, ending today or yesterday, or 0." }),
|
|
774
|
+
longest_days: Natural.annotate({ description: "The longest run of consecutive UTC days with a sandbox start." })
|
|
775
|
+
}),
|
|
776
|
+
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." })
|
|
777
|
+
}).annotate({
|
|
778
|
+
description: "The organization's level, streak, records, and badges, each read from the sandboxes, create attempts, and snapshots it stores.",
|
|
779
|
+
identifier: "Stats"
|
|
780
|
+
});
|
|
596
781
|
// src/sse.ts
|
|
597
782
|
const fieldOf = (line) => {
|
|
598
783
|
const colon = line.indexOf(":");
|
|
@@ -648,15 +833,20 @@ const sandboxPath = (sandboxId) => `/sandboxes/${segment(SandboxId, sandboxId)}`
|
|
|
648
833
|
const keyPath = (keyId) => `/keys/${segment(KeyId, keyId)}`;
|
|
649
834
|
const portSegment = (port) => String(decodeUnknownSync(Port)(port));
|
|
650
835
|
const credentialPath = (provider) => `/credentials/${segment(Provider, provider)}`;
|
|
836
|
+
const ciJobPath = (jobId) => `/ci/jobs/${segment(CiJobId, jobId)}`;
|
|
837
|
+
const ciInstallationPath = (installationId) => `/ci/installations/${String(decodeUnknownSync(GitHubId)(installationId))}`;
|
|
651
838
|
const filePath = (sandboxId) => `${sandboxPath(sandboxId)}/files/content`;
|
|
652
839
|
const decodeExecEvent = decodeUnknownSync(fromJsonString(ExecEvent));
|
|
653
840
|
var Sandcovery = class {
|
|
654
841
|
activity;
|
|
655
842
|
billing;
|
|
843
|
+
ci;
|
|
656
844
|
credentials;
|
|
657
845
|
keys;
|
|
846
|
+
pricing;
|
|
658
847
|
providers;
|
|
659
848
|
sandboxes;
|
|
849
|
+
stats;
|
|
660
850
|
usage;
|
|
661
851
|
constructor(options = {}) {
|
|
662
852
|
const configuredKey = options.apiKey ?? globalThis.process?.env.SANDCOVERY_API_KEY;
|
|
@@ -758,9 +948,16 @@ var Sandcovery = class {
|
|
|
758
948
|
})
|
|
759
949
|
};
|
|
760
950
|
this.credentials = {
|
|
951
|
+
add: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "POST", credentialPath(provider), {
|
|
952
|
+
json: fields,
|
|
953
|
+
signal
|
|
954
|
+
}),
|
|
761
955
|
delete: async (provider, { signal } = {}) => {
|
|
762
956
|
await call("DELETE", credentialPath(provider), { signal });
|
|
763
957
|
},
|
|
958
|
+
deleteOne: async (provider, credentialId, { signal } = {}) => {
|
|
959
|
+
await call("DELETE", `${credentialPath(provider)}/${segment(CredentialId, credentialId)}`, { signal });
|
|
960
|
+
},
|
|
764
961
|
list: async ({ signal } = {}) => await read(ProviderCredentialList, "GET", "/credentials", { signal }),
|
|
765
962
|
offer: async ({ signal } = {}) => await read(Offer, "GET", "/offer", { signal }),
|
|
766
963
|
set: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "PUT", credentialPath(provider), {
|
|
@@ -779,11 +976,24 @@ var Sandcovery = class {
|
|
|
779
976
|
}),
|
|
780
977
|
get: async ({ signal } = {}) => await read(Billing, "GET", "/billing", { signal })
|
|
781
978
|
};
|
|
979
|
+
this.ci = {
|
|
980
|
+
getJob: async (jobId, { signal } = {}) => await read(CiJob, "GET", ciJobPath(jobId), { signal }),
|
|
981
|
+
listInstallations: async ({ signal } = {}) => await read(CiInstallationList, "GET", "/ci/installations", { signal }),
|
|
982
|
+
listJobs: async (query = {}, { signal } = {}) => await read(CiJobList, "GET", "/ci/jobs", {
|
|
983
|
+
query: { ...query },
|
|
984
|
+
signal
|
|
985
|
+
}),
|
|
986
|
+
unlinkInstallation: async (installationId, { signal } = {}) => {
|
|
987
|
+
await call("DELETE", ciInstallationPath(installationId), { signal });
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
this.pricing = { get: async ({ signal } = {}) => await read(Pricing, "GET", "/pricing", { signal }) };
|
|
782
991
|
this.providers = {
|
|
783
992
|
catalog: async ({ signal } = {}) => await read(ProviderCatalog, "GET", "/catalog", { signal }),
|
|
784
993
|
get: async (provider, { signal } = {}) => await read(ProviderBoardEntry, "GET", `/providers/${segment(Provider, provider)}`, { signal }),
|
|
785
994
|
list: async ({ signal } = {}) => await read(ProviderBoard, "GET", "/providers", { signal })
|
|
786
995
|
};
|
|
996
|
+
this.stats = { get: async ({ signal } = {}) => await read(Stats, "GET", "/stats", { signal }) };
|
|
787
997
|
this.usage = {
|
|
788
998
|
estimate: async (request, { signal } = {}) => await read(EstimateList, "POST", "/estimates", {
|
|
789
999
|
json: request,
|
|
@@ -792,8 +1002,16 @@ var Sandcovery = class {
|
|
|
792
1002
|
get: async (query, { signal } = {}) => await read(Usage, "GET", "/usage", {
|
|
793
1003
|
query: { ...query },
|
|
794
1004
|
signal
|
|
1005
|
+
}),
|
|
1006
|
+
live: async (query = {}, { signal } = {}) => await read(LiveUsage, "GET", "/usage/live", {
|
|
1007
|
+
query: { ...query },
|
|
1008
|
+
signal
|
|
1009
|
+
}),
|
|
1010
|
+
totals: async (query = {}, { signal } = {}) => await read(UsageTotals, "GET", "/usage/totals", {
|
|
1011
|
+
query: { ...query },
|
|
1012
|
+
signal
|
|
795
1013
|
})
|
|
796
1014
|
};
|
|
797
1015
|
}
|
|
798
1016
|
};
|
|
799
|
-
export { CredentialFields as a, ApiError as i, CalendarDay as n, EstimateRequest as r, Sandcovery as t };
|
|
1017
|
+
export { CredentialFields as a, ApiError as i, CalendarDay as n, GitHubId as o, EstimateRequest as r, Sandcovery as t };
|