sandcovery 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { A as optionalKey, C as isBetween, O as makeFilter, V as getOrElse, _ as decodeUnknownOption, a as Int, b as fromJsonString, c as Literals, d as NonEmptyString, f as NullOr, g as Union, h as Struct, i as Finite, j as tag, l as Natural, m as String$1, n as Boolean, p as Record, r as Error$1, s as Literal, t as ArraySchema, y as decodeUnknownSync } from "./Schema-DiSfJzMf.mjs";
2
- import { A as KeyId, E as CreditCheckout, F as SandboxId, I as Timestamp, M as MicroUsd, N as Provider, O as ApiKeyId, P as Region, S as Billing, a as Key, f as Port, g as SandboxSpec, h as SandboxList, i as CreatedKey, k as GpuType, m as Sandbox, p as PortPreview, s as KeyList, t as API_PREFIX, u as CreateAttempt, v as Snapshot, x as StandardSize, y as ProviderPreferences } from "./origin-CIA-1Jia.mjs";
1
+ import { E as isGreaterThanOrEqualTo, G as getOrElse, N as optionalKey, P as tag, S as fromJsonString, T as isBetween, _ as Union, c as Literal, f as NonEmptyString, g as Struct, h as String$1, i as Finite, j as makeFilter, l as Literals, m as Record, n as Boolean, o as Int, p as NullOr, r as Error$1, t as ArraySchema, u as Natural, x as decodeUnknownSync, y as decodeUnknownOption } from "./Schema-CFI3ZMu8.mjs";
2
+ import { A as CreditCheckout, B as Provider, C as RoutingFields, E as Billing, F as CredentialId, H as SandboxId, I as GpuType, L as KeyId, M as Pricing, N as ApiKeyId, P as CiJobId, S as ROUTING_FIELDS_TEXT, T as StandardSize, U as Timestamp, V as Region, 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, z as MicroUsd } from "./origin-BTx2gX8x.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,14 @@ 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,
333
419
  provider: Provider,
334
420
  updated_at: Timestamp
335
421
  }).annotate({
336
422
  description: "A stored provider credential. Sandcovery encrypts it at rest and never returns its fields.",
337
423
  identifier: "ProviderCredential"
338
424
  });
339
- const ProviderCredentialList = Struct({ data: ArraySchema(ProviderCredential) }).annotate({ identifier: "ProviderCredentialList" });
425
+ 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. Without Pro, a create uses only each provider's first credential." }) }).annotate({ identifier: "ProviderCredentialList" });
340
426
  // ../sandcovery-contract/src/errors/concurrency-limit-reached.ts
341
427
  var ConcurrencyLimitReached = class extends Error$1("ConcurrencyLimitReached")({
342
428
  concurrency_cap: Natural,
@@ -365,7 +451,7 @@ var Forbidden = class extends Error$1("Forbidden")({
365
451
  error: tag("forbidden"),
366
452
  message: String$1
367
453
  }, {
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.",
454
+ 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
455
  httpApiStatus: 403,
370
456
  identifier: "Forbidden"
371
457
  }) {
@@ -442,10 +528,10 @@ var Unauthorized = class extends Error$1("Unauthorized")({
442
528
  var Unsupported = class extends Error$1("Unsupported")({
443
529
  error: tag("unsupported"),
444
530
  message: String$1,
445
- options: ArraySchema(String$1).annotate({ description: "The sizes that would run for this request. Empty when the cause is not the size, 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." }),
531
+ 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
532
  provider: NullOr(Provider).annotate({ description: "The sandbox's provider for an operation on an existing sandbox, or null for a create." })
447
533
  }, {
448
- description: "A size, spec option, or operation that no candidate provider can serve. Sandcovery never ignores an option. For a size, `options` lists the sizes that would run; otherwise `options` is empty and `message` names the field or operation.",
534
+ 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
535
  httpApiStatus: 422,
450
536
  identifier: "Unsupported"
451
537
  }) {
@@ -556,18 +642,23 @@ const Offer = Struct({
556
642
  // ../sandcovery-contract/src/usage.ts
557
643
  const EstimateRequest = Struct({
558
644
  ...SandboxSpec.fields,
645
+ ...RoutingFields,
559
646
  provider: optionalKey(ProviderPreferences)
560
647
  }).annotate({
561
- description: "A sandbox spec and routing preferences to price without creating anything.",
648
+ description: `A sandbox spec, the slug or slugs to run it on, and routing preferences, to price without creating anything. ${ROUTING_FIELDS_TEXT}`,
562
649
  identifier: "EstimateRequest"
563
650
  });
564
651
  const Estimate = Struct({
565
652
  hourly_micro_usd: MicroUsd,
566
653
  provider: Provider,
567
654
  rate_card_version: String$1,
655
+ slug: Slug,
568
656
  ttl_micro_usd: MicroUsd.annotate({ description: "List-price cost if the sandbox runs for its whole TTL." })
569
- }).annotate({ identifier: "Estimate" });
570
- const EstimateList = Struct({ data: ArraySchema(Estimate).annotate({ description: "One estimate per provider that can run the spec, in routing order." }) }).annotate({ identifier: "EstimateList" });
657
+ }).annotate({
658
+ 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.",
659
+ identifier: "Estimate"
660
+ });
661
+ 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
662
  const isCalendarDay = makeFilter((value) => {
572
663
  const at = Date.parse(`${value}T00:00:00.000Z`);
573
664
  return Number.isFinite(at) && new Date(at).toISOString().slice(0, 10) === value;
@@ -582,17 +673,110 @@ Struct({
582
673
  to: CalendarDay.annotate({ description: "Last UTC day, inclusive. At most 92 days after `from`." })
583
674
  });
584
675
  const UsageDay = Struct({
585
- api_key_id: ApiKeyId.annotate({ description: "The key that created the sandboxes." }),
676
+ api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
586
677
  date: CalendarDay,
587
678
  estimated_micro_usd: MicroUsd,
679
+ gpu_seconds: Natural.annotate({ description: "GPU-seconds: each sandbox GPU count times its seconds run." }),
680
+ memory_gib_seconds: Natural.annotate({ description: "GiB-seconds: each sandbox memory in GiB times its seconds run, rounded to a whole number." }),
588
681
  provider: Provider,
589
682
  sandbox_count: Natural,
590
- sandbox_seconds: Natural
683
+ sandbox_seconds: Natural,
684
+ vcpu_seconds: Natural.annotate({ description: "vCPU-seconds: each sandbox vCPU count times its seconds run." })
591
685
  }).annotate({
592
- description: "Estimated list-price usage of one key on one provider on one UTC day.",
686
+ 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
687
  identifier: "UsageDay"
594
688
  });
595
689
  const Usage = Struct({ data: ArraySchema(UsageDay) }).annotate({ identifier: "Usage" });
690
+ Struct({ api_key_id: optionalKey(ApiKeyId) });
691
+ const LiveSandboxes = Struct({
692
+ accrued_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost these sandboxes have run up from their start to now or their TTL." }),
693
+ api_key_id: NullOr(ApiKeyId).annotate({ description: "The key that created the sandboxes, or null for sandboxes created on a signed-in session." }),
694
+ gpus: Natural,
695
+ 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." }),
696
+ memory_mib: Natural,
697
+ provider: NullOr(Provider).annotate({ description: "The provider running the sandboxes, or null for creates no provider has started yet." }),
698
+ sandbox_count: Natural,
699
+ status: Literals([
700
+ "creating",
701
+ "destroying",
702
+ "paused",
703
+ "running"
704
+ ]).annotate({ identifier: "LiveSandboxStatus" }),
705
+ vcpus: Natural
706
+ }).annotate({
707
+ description: "The live sandboxes of one key on one provider in one status, with the vCPUs, memory, and GPUs their specs hold.",
708
+ identifier: "LiveSandboxes"
709
+ });
710
+ const LiveUsage = Struct({
711
+ at: Timestamp.annotate({ description: "When the API read these figures." }),
712
+ data: ArraySchema(LiveSandboxes)
713
+ }).annotate({ identifier: "LiveUsage" });
714
+ const UsageTotal = Struct({
715
+ estimated_micro_usd: MicroUsd,
716
+ gpu_seconds: Natural,
717
+ memory_gib_seconds: Natural,
718
+ period: Literals([
719
+ "day",
720
+ "month",
721
+ "total",
722
+ "week"
723
+ ]).annotate({
724
+ 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.",
725
+ identifier: "UsagePeriod"
726
+ }),
727
+ sandbox_count: Natural.annotate({ description: "Sandboxes that ran at any time in the window." }),
728
+ sandbox_seconds: Natural,
729
+ since: NullOr(Timestamp).annotate({ description: "The start of the window, or null for `total`." }),
730
+ vcpu_seconds: Natural
731
+ }).annotate({
732
+ 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.",
733
+ identifier: "UsageTotal"
734
+ });
735
+ const UsageTotals = Struct({
736
+ at: Timestamp.annotate({ description: "When the API read these figures." }),
737
+ data: ArraySchema(UsageTotal).annotate({ description: "One total for each window: `day`, `week`, `month`, `total`." })
738
+ }).annotate({ identifier: "UsageTotals" });
739
+ // ../sandcovery-contract/src/stats.ts
740
+ const StatsDay = Struct({
741
+ date: CalendarDay,
742
+ sandbox_count: Natural.annotate({ description: "Sandboxes that started on this UTC day." })
743
+ }).annotate({ identifier: "StatsDay" });
744
+ const Badge = Struct({
745
+ 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." }),
746
+ 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." }),
747
+ name: NonEmptyString.annotate({ description: "The badge as a person reads it, such as `100 Sandboxes`." }),
748
+ progress: Natural.annotate({ description: "How far the organization has come toward `target`, at most `target`." }),
749
+ target: Natural.annotate({ description: "What earns the badge, in `unit`." }),
750
+ 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." })
751
+ }).annotate({ identifier: "Badge" });
752
+ const Stats = Struct({
753
+ badges: ArraySchema(Badge),
754
+ busiest_day: NullOr(StatsDay).annotate({ description: "The UTC day the most sandboxes started, the earliest such day on a tie." }),
755
+ days: ArraySchema(StatsDay).annotate({ description: "Each UTC day of the last 365, today included, on which at least one sandbox started, oldest first." }),
756
+ largest_sandbox: NullOr(Struct({
757
+ memory_mib: Natural,
758
+ provider: Provider,
759
+ sandbox_id: SandboxId,
760
+ vcpus: Natural
761
+ })).annotate({ description: "The started sandbox with the most vCPUs, then the most memory, the earliest on a tie." }),
762
+ 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." }),
763
+ level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds at which the current level started." }),
764
+ longest_run: NullOr(Struct({
765
+ provider: Provider,
766
+ sandbox_id: SandboxId,
767
+ seconds: Natural
768
+ })).annotate({ description: "The sandbox that ran longest, up to its end or its TTL, counting a live one up to now." }),
769
+ next_level_vcpu_seconds: Natural.annotate({ description: "The vCPU-seconds the next level starts at." }),
770
+ sandbox_count: Natural.annotate({ description: "Sandboxes the organization started." }),
771
+ streak: Struct({
772
+ current_days: Natural.annotate({ description: "Consecutive UTC days with a sandbox start, ending today or yesterday, or 0." }),
773
+ longest_days: Natural.annotate({ description: "The longest run of consecutive UTC days with a sandbox start." })
774
+ }),
775
+ 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." })
776
+ }).annotate({
777
+ description: "The organization's level, streak, records, and badges, each read from the sandboxes, create attempts, and snapshots it stores.",
778
+ identifier: "Stats"
779
+ });
596
780
  // src/sse.ts
597
781
  const fieldOf = (line) => {
598
782
  const colon = line.indexOf(":");
@@ -648,15 +832,20 @@ const sandboxPath = (sandboxId) => `/sandboxes/${segment(SandboxId, sandboxId)}`
648
832
  const keyPath = (keyId) => `/keys/${segment(KeyId, keyId)}`;
649
833
  const portSegment = (port) => String(decodeUnknownSync(Port)(port));
650
834
  const credentialPath = (provider) => `/credentials/${segment(Provider, provider)}`;
835
+ const ciJobPath = (jobId) => `/ci/jobs/${segment(CiJobId, jobId)}`;
836
+ const ciInstallationPath = (installationId) => `/ci/installations/${String(decodeUnknownSync(GitHubId)(installationId))}`;
651
837
  const filePath = (sandboxId) => `${sandboxPath(sandboxId)}/files/content`;
652
838
  const decodeExecEvent = decodeUnknownSync(fromJsonString(ExecEvent));
653
839
  var Sandcovery = class {
654
840
  activity;
655
841
  billing;
842
+ ci;
656
843
  credentials;
657
844
  keys;
845
+ pricing;
658
846
  providers;
659
847
  sandboxes;
848
+ stats;
660
849
  usage;
661
850
  constructor(options = {}) {
662
851
  const configuredKey = options.apiKey ?? globalThis.process?.env.SANDCOVERY_API_KEY;
@@ -758,9 +947,16 @@ var Sandcovery = class {
758
947
  })
759
948
  };
760
949
  this.credentials = {
950
+ add: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "POST", credentialPath(provider), {
951
+ json: fields,
952
+ signal
953
+ }),
761
954
  delete: async (provider, { signal } = {}) => {
762
955
  await call("DELETE", credentialPath(provider), { signal });
763
956
  },
957
+ deleteOne: async (provider, credentialId, { signal } = {}) => {
958
+ await call("DELETE", `${credentialPath(provider)}/${segment(CredentialId, credentialId)}`, { signal });
959
+ },
764
960
  list: async ({ signal } = {}) => await read(ProviderCredentialList, "GET", "/credentials", { signal }),
765
961
  offer: async ({ signal } = {}) => await read(Offer, "GET", "/offer", { signal }),
766
962
  set: async (provider, fields, { signal } = {}) => await read(ProviderCredential, "PUT", credentialPath(provider), {
@@ -779,11 +975,24 @@ var Sandcovery = class {
779
975
  }),
780
976
  get: async ({ signal } = {}) => await read(Billing, "GET", "/billing", { signal })
781
977
  };
978
+ this.ci = {
979
+ getJob: async (jobId, { signal } = {}) => await read(CiJob, "GET", ciJobPath(jobId), { signal }),
980
+ listInstallations: async ({ signal } = {}) => await read(CiInstallationList, "GET", "/ci/installations", { signal }),
981
+ listJobs: async (query = {}, { signal } = {}) => await read(CiJobList, "GET", "/ci/jobs", {
982
+ query: { ...query },
983
+ signal
984
+ }),
985
+ unlinkInstallation: async (installationId, { signal } = {}) => {
986
+ await call("DELETE", ciInstallationPath(installationId), { signal });
987
+ }
988
+ };
989
+ this.pricing = { get: async ({ signal } = {}) => await read(Pricing, "GET", "/pricing", { signal }) };
782
990
  this.providers = {
783
991
  catalog: async ({ signal } = {}) => await read(ProviderCatalog, "GET", "/catalog", { signal }),
784
992
  get: async (provider, { signal } = {}) => await read(ProviderBoardEntry, "GET", `/providers/${segment(Provider, provider)}`, { signal }),
785
993
  list: async ({ signal } = {}) => await read(ProviderBoard, "GET", "/providers", { signal })
786
994
  };
995
+ this.stats = { get: async ({ signal } = {}) => await read(Stats, "GET", "/stats", { signal }) };
787
996
  this.usage = {
788
997
  estimate: async (request, { signal } = {}) => await read(EstimateList, "POST", "/estimates", {
789
998
  json: request,
@@ -792,8 +1001,16 @@ var Sandcovery = class {
792
1001
  get: async (query, { signal } = {}) => await read(Usage, "GET", "/usage", {
793
1002
  query: { ...query },
794
1003
  signal
1004
+ }),
1005
+ live: async (query = {}, { signal } = {}) => await read(LiveUsage, "GET", "/usage/live", {
1006
+ query: { ...query },
1007
+ signal
1008
+ }),
1009
+ totals: async (query = {}, { signal } = {}) => await read(UsageTotals, "GET", "/usage/totals", {
1010
+ query: { ...query },
1011
+ signal
795
1012
  })
796
1013
  };
797
1014
  }
798
1015
  };
799
- export { CredentialFields as a, ApiError as i, CalendarDay as n, EstimateRequest as r, Sandcovery as t };
1016
+ export { CredentialFields as a, ApiError as i, CalendarDay as n, GitHubId as o, EstimateRequest as r, Sandcovery as t };
@@ -1,10 +1,10 @@
1
- import { U as isNone, _ as decodeUnknownOption, a as Int, b as fromJsonString, h as Struct, k as optional, m as String$1, t as ArraySchema } from "./Schema-DiSfJzMf.mjs";
1
+ import { M as optional, S as fromJsonString, g as Struct, h as String$1, o as Int, q as isNone, t as ArraySchema, y as decodeUnknownOption } from "./Schema-CFI3ZMu8.mjs";
2
2
  import { t as loopbackOrigin } from "./telemetry-BYnuVdoZ.mjs";
3
3
  import { constants } from "node:fs";
4
4
  import { isAbsolute } from "node:path";
5
5
  import { createInterface } from "node:readline";
6
6
  import { platform, release } from "node:os";
7
- import { dirname, isAbsolute as isAbsolute$1, posix, relative, sep } from "path";
7
+ import { dirname, isAbsolute as isAbsolute$1, posix as posix$1, relative, sep } from "path";
8
8
  import { open } from "node:fs/promises";
9
9
  import { AsyncLocalStorage } from "node:async_hooks";
10
10
  import { gzip } from "node:zlib";
@@ -22,7 +22,7 @@ function createGetModuleFromFilename(basePath = process.argv[1] ? dirname(proces
22
22
  return (filename) => {
23
23
  if (!filename) return;
24
24
  const normalizedFilename = isWindows ? normalizeWindowsPath(filename) : filename;
25
- let { dir, base: file, ext } = posix.parse(normalizedFilename);
25
+ let { dir, base: file, ext } = posix$1.parse(normalizedFilename);
26
26
  if (".js" === ext || ".mjs" === ext || ".cjs" === ext) file = file.slice(0, -1 * ext.length);
27
27
  const decodedFile = decodeURIComponent(file);
28
28
  if (!dir) dir = ".";