sandcovery 0.2.0 → 0.3.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as Key, B as ProviderBoardEntry, C as ExecResult, E as FileList, H as ProviderCredentialList, L as PortPreview, N as KeyList, Q as Sandbox, R as Provider, S as ExecRequest, V as ProviderCredential, b as EstimateRequest, d as CreateSandboxRequest, dt as UpdateKeyRequest, f as CreatedKey, ft as Usage, i as ActivityList, it as Snapshot, m as CredentialFields, nt as SandboxStatus, tt as SandboxList, u as CreateKeyRequest, w as FileEntry, x as ExecEvent, y as EstimateList, z as ProviderBoard } from "./types-Dxh7amZB.mjs";
1
+ import { C as CreditCheckout, Ct as Sandbox, Dt as SandboxStatus, E as DetachedExecRequest, Et as SandboxList, F as ExecResult, I as FileEntry, K as Key, M as EstimateRequest, N as ExecEvent, P as ExecRequest, Q as Offer, R as FileList, Rt as UpdateKeyRequest, S as CredentialFields, T as DetachedExec, Y as KeyList, at as Provider, b as CreatedKey, ct as ProviderCatalog, dt as ProviderCredentialList, i as ActivityList, j as EstimateList, jt as Snapshot, nt as PortPreview, o as Billing, ot as ProviderBoard, st as ProviderBoardEntry, ut as ProviderCredential, v as CreateKeyRequest, w as CreditPurchaseRequest, y as CreateSandboxRequest, zt as Usage } from "./types-DMB8KnA3.mjs";
2
2
  interface RequestOptions {
3
3
  readonly signal?: AbortSignal;
4
4
  }
@@ -25,6 +25,7 @@ interface SandboxesApi {
25
25
  readonly destroy: SandboxCall<Sandbox>;
26
26
  readonly downloadFile: FileCall<ReadableStream<Uint8Array>>;
27
27
  readonly exec: (sandboxId: string, request: ExecRequest, options?: RequestOptions) => Promise<ExecResult>;
28
+ readonly execDetached: (sandboxId: string, request: DetachedExecRequest, options?: RequestOptions) => Promise<DetachedExec>;
28
29
  readonly execStream: (sandboxId: string, request: ExecRequest, options?: RequestOptions) => AsyncGenerator<ExecEvent>;
29
30
  readonly get: SandboxCall<Sandbox>;
30
31
  readonly list: (query?: ListSandboxesQuery, options?: RequestOptions) => Promise<SandboxList>;
@@ -46,12 +47,18 @@ interface KeysApi {
46
47
  interface CredentialsApi {
47
48
  readonly delete: (provider: Provider, options?: RequestOptions) => Promise<void>;
48
49
  readonly list: (options?: RequestOptions) => Promise<ProviderCredentialList>;
50
+ readonly offer: (options?: RequestOptions) => Promise<Offer>;
49
51
  readonly set: (provider: Provider, fields: CredentialFields, options?: RequestOptions) => Promise<ProviderCredential>;
50
52
  }
51
53
  interface ActivityApi {
52
54
  readonly list: (query?: PageQuery, options?: RequestOptions) => Promise<ActivityList>;
53
55
  }
56
+ interface BillingApi {
57
+ readonly buyCredits: (request: CreditPurchaseRequest, options?: RequestOptions) => Promise<CreditCheckout>;
58
+ readonly get: (options?: RequestOptions) => Promise<Billing>;
59
+ }
54
60
  interface ProvidersApi {
61
+ readonly catalog: (options?: RequestOptions) => Promise<ProviderCatalog>;
55
62
  readonly get: (provider: Provider, options?: RequestOptions) => Promise<ProviderBoardEntry>;
56
63
  readonly list: (options?: RequestOptions) => Promise<ProviderBoard>;
57
64
  }
@@ -66,6 +73,7 @@ export interface SandcoveryOptions {
66
73
  }
67
74
  export declare class Sandcovery {
68
75
  readonly activity: ActivityApi;
76
+ readonly billing: BillingApi;
69
77
  readonly credentials: CredentialsApi;
70
78
  readonly keys: KeysApi;
71
79
  readonly providers: ProvidersApi;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- export { t as Sandcovery } from "./src-D3WZodpF.mjs";
1
+ export { t as Sandcovery } from "./src-YrynO3hz.mjs";
@@ -1,18 +1,19 @@
1
- import { C as isBetween, D as makeFilter, E as isUUID, S as isBase64Url$1, T as isMaxLength, a as Int, c as Literals, d as NonEmptyString, f as NullOr, g as Union, h as Struct, k as optionalKey, l as Natural, m as String$1, n as Boolean, p as Record, s as Literal, t as ArraySchema, u as NonEmptyArray, w as isGreaterThanOrEqualTo, x as is } from "./Schema-C4ay0Aif.mjs";
1
+ import { A as optionalKey, C as isBetween, D as isUUID, E as isMultipleOf, O as makeFilter, S as isBase64Url$1, T as isMaxLength, a as Int, c as Literals, d as NonEmptyString, f as NullOr, g as Union, h as Struct, l as Natural, m as String$1, n as Boolean, p as Record, s as Literal, t as ArraySchema, u as NonEmptyArray, w as isGreaterThanOrEqualTo, x as is } from "./Schema-DiSfJzMf.mjs";
2
2
  // ../sandcovery-contract/src/primitives.ts
3
3
  const PROVIDERS = [
4
4
  "daytona",
5
5
  "depot",
6
6
  "e2b",
7
- "vercel"
7
+ "upstash"
8
8
  ];
9
+ const PROVIDER_EXAMPLES = new Intl.ListFormat("en", { type: "disjunction" }).format(PROVIDERS.map((provider) => `\`${provider}\``));
9
10
  const SLUG_CHARACTERS = /* @__PURE__ */ new Set("abcdefghijklmnopqrstuvwxyz0123456789-");
10
11
  const isSlug = (value) => value !== "" && value.split("").every((character) => SLUG_CHARACTERS.has(character));
11
12
  const Provider = String$1.check(makeFilter(isSlug, {
12
13
  expected: "a provider name of lowercase letters, digits, and hyphens",
13
14
  toJsonSchema: () => ({ minLength: 1 })
14
15
  })).annotate({
15
- description: "A provider name of lowercase letters, digits, and hyphens, such as `daytona` (Daytona), `depot` (Depot), `e2b` (E2B), or `vercel` (Vercel Sandbox). The API adds providers over time, so a client accepts any such name and the API refuses one it does not serve.",
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.`,
16
17
  examples: PROVIDERS,
17
18
  identifier: "Provider"
18
19
  });
@@ -25,6 +26,20 @@ const Region = NonEmptyString.annotate({
25
26
  ],
26
27
  identifier: "Region"
27
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
+ });
28
43
  const isUtcTimestamp = makeFilter((value) => {
29
44
  const at = Date.parse(value);
30
45
  return Number.isFinite(at) && new Date(at).toISOString() === value;
@@ -58,6 +73,40 @@ const KeySecret = String$1.check(makeFilter((value) => hasPrefixedSecret(value,
58
73
  expected: `${API_KEY_SECRET_PREFIX} or ${MANAGEMENT_KEY_SECRET_PREFIX} followed by 43 base64url characters`,
59
74
  toJsonSchema: () => ({})
60
75
  })).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.` });
76
+ const MICRO_USD_PER_DOLLAR = 1e6;
77
+ const CREDIT_PURCHASE_MIN_MICRO_USD = 25 * MICRO_USD_PER_DOLLAR;
78
+ const CREDIT_PURCHASE_MAX_MICRO_USD = 1e3 * MICRO_USD_PER_DOLLAR;
79
+ const CARD_FEE_TERMS = "2.9% plus 30 cents";
80
+ const Plan = Literals(["free", "pro"]).annotate({
81
+ description: "The organization plan: `pro` while its Pro subscription is active, trialing, or past due, otherwise `free`.",
82
+ identifier: "Plan"
83
+ });
84
+ const ProInterval = Literals([
85
+ "day",
86
+ "month",
87
+ "week",
88
+ "year"
89
+ ]).annotate({
90
+ description: "How often the Pro fee is charged.",
91
+ identifier: "ProInterval"
92
+ });
93
+ const ProPrice = Struct({
94
+ interval: ProInterval,
95
+ micro_usd: MicroUsd
96
+ }).annotate({
97
+ description: "The fixed Pro fee for each billing interval.",
98
+ identifier: "ProPrice"
99
+ });
100
+ const Billing = Struct({
101
+ credit_balance_micro_usd: Int.annotate({ description: "Credits bought, less refunds and open disputes. A refund after use can take it below zero." }),
102
+ plan: Plan,
103
+ pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
104
+ }).annotate({ identifier: "Billing" });
105
+ Struct({ amount_micro_usd: MicroUsd.check(isMultipleOf(MICRO_USD_PER_DOLLAR), isBetween({
106
+ maximum: CREDIT_PURCHASE_MAX_MICRO_USD,
107
+ minimum: CREDIT_PURCHASE_MIN_MICRO_USD
108
+ })).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" });
109
+ 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" });
61
110
  // ../sandcovery-contract/src/routing.ts
62
111
  const STANDARD_SIZES = [
63
112
  {
@@ -91,7 +140,7 @@ const ProviderSort = Literals([
91
140
  "price",
92
141
  "uptime"
93
142
  ]).annotate({
94
- description: "Candidate order: `price` by list price, `latency` by measured create latency, and `uptime` by uptime over the last 15 minutes.",
143
+ 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.",
95
144
  identifier: "ProviderSort"
96
145
  });
97
146
  const ROUTING_SUFFIXES = [
@@ -130,7 +179,7 @@ const SizeName = String$1.check(makeFilter(isSizeName, {
130
179
  expected: "<vcpu>x<memory_gib>, optionally followed by a routing suffix",
131
180
  toJsonSchema: () => ({ minLength: 1 })
132
181
  })).annotate({
133
- description: "A size named `<vcpu>x<memory_gib>`, such as `2x4` for 2 vCPU and 4 GiB, optionally followed by a routing suffix: `:cheapest` sorts candidates by list price, `:fastest` by measured create latency, and `:most-reliable` by uptime over the last 15 minutes. A name with no suffix uses default routing, which balances price, latency, and uptime and spreads concurrent load across providers. A malformed name or an unknown suffix answers 400 `invalid_request`, and a size no candidate provider can run answers 422 `unsupported`, listing the sizes that would run as `options`.",
182
+ description: "A size named `<vcpu>x<memory_gib>`, such as `2x4` for 2 vCPU and 4 GiB, optionally followed by a routing suffix: `: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 name with no suffix uses default routing, which balances price, latency, and uptime and spreads concurrent load across providers. A malformed name or an unknown suffix answers 400 `invalid_request`, and a size no candidate provider can run answers 422 `unsupported`, listing the sizes that would run as `options`.",
134
183
  examples: SIZE_NAMES.map(({ name }) => name),
135
184
  identifier: "SizeName"
136
185
  });
@@ -146,14 +195,21 @@ const ProviderPreferences = Struct({
146
195
  });
147
196
  // ../sandcovery-contract/src/sandbox.ts
148
197
  const MAX_TTL_SECONDS = 86400;
149
- const MIN_TTL_SECONDS = 60;
150
198
  const MAX_PORT = 65535;
151
199
  const MAX_PORTS = 8;
200
+ const MAX_GPUS = 8;
152
201
  const between = (minimum, maximum) => Int.check(isBetween({
153
202
  maximum,
154
203
  minimum
155
204
  }));
156
205
  const Port = between(1, MAX_PORT);
206
+ const Gpu = Struct({
207
+ count: between(1, MAX_GPUS).annotate({ description: "How many GPUs of `type` the sandbox gets, from 1 to 8." }),
208
+ type: GpuType
209
+ }).annotate({
210
+ 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.",
211
+ identifier: "Gpu"
212
+ });
157
213
  const EnvironmentVariables = Record(NonEmptyString, String$1).annotate({ description: "Environment variables by name. Sandcovery passes them to the provider and never returns them." });
158
214
  const EgressPolicy = Union([
159
215
  Struct({ mode: Literal("allow_all") }),
@@ -170,13 +226,14 @@ const SandboxSpec = Struct({
170
226
  disk_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(1024)).annotate({ description: "Disk size in MiB. Defaults to the provider default." })),
171
227
  egress: optionalKey(EgressPolicy),
172
228
  env: optionalKey(EnvironmentVariables),
173
- idle_timeout_seconds: optionalKey(Int.check(isGreaterThanOrEqualTo(MIN_TTL_SECONDS)).annotate({ description: "Seconds without a running command after which the provider pauses the sandbox. Unset means no idle timeout." })),
229
+ gpu: optionalKey(Gpu),
230
+ 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." })),
174
231
  image: optionalKey(NonEmptyString.annotate({ description: "An OCI image reference. Unset means the provider's default Linux image." })),
175
232
  memory_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(256)).annotate({ description: "Memory in MiB. Set with `vcpu`, and never with `size`." })),
176
233
  ports: optionalKey(ArraySchema(Port).check(isMaxLength(MAX_PORTS)).annotate({ description: "Ports to expose for preview URLs. Some providers expose only ports declared at create." })),
177
234
  region: optionalKey(Region),
178
235
  size: optionalKey(SizeName),
179
- ttl_seconds: optionalKey(between(MIN_TTL_SECONDS, 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." })),
236
+ 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." })),
180
237
  vcpu: optionalKey(between(1, 64).annotate({ description: "vCPU count. Set with `memory_mib`, and never with `size`." }))
181
238
  });
182
239
  const CreateSandboxRequest = Struct({
@@ -240,6 +297,7 @@ const Sandbox = Struct({
240
297
  end_reason: NullOr(SandboxEndReason),
241
298
  ended_at: NullOr(Timestamp),
242
299
  expires_at: Timestamp,
300
+ gpu: NullOr(Gpu),
243
301
  id: SandboxId,
244
302
  idle_timeout_seconds: NullOr(Natural),
245
303
  image: NullOr(String$1),
@@ -279,7 +337,6 @@ const PortPreview = Struct({
279
337
  description: "A provider URL that reaches a port inside the sandbox.",
280
338
  identifier: "PortPreview"
281
339
  });
282
- // ../sandcovery-contract/src/keys.ts
283
340
  const KeyName = NonEmptyString.check(isMaxLength(64));
284
341
  const PositiveInt = Int.check(isGreaterThanOrEqualTo(1));
285
342
  const KeyKind = Literals(["api", "management"]).annotate({
@@ -329,7 +386,7 @@ const KeyList = Struct({ data: ArraySchema(Key) }).annotate({ identifier: "KeyLi
329
386
  const CreateKeyRequest = Struct({
330
387
  allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
331
388
  expires_at: optionalKey(NullOr(Timestamp)),
332
- kind: optionalKey(KeyKind).annotate({ description: "Defaults to `api`. Only a signed-in owner or admin mints a `management` key, and a management key takes no limits." }),
389
+ kind: optionalKey(KeyKind).annotate({ description: "Defaults to `api`. Only a signed-in owner mints a `management` key, and a management key takes no limits." }),
333
390
  max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
334
391
  max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
335
392
  name: KeyName,
@@ -353,4 +410,4 @@ const CreatedKey = Struct({
353
410
  // ../sandcovery-contract/src/origin.ts
354
411
  const SANDCOVERY_ORIGIN = "https://www.sandcovery.com";
355
412
  const API_PREFIX = "/api/v1";
356
- export { KeyId as C, Region as D, Provider as E, SandboxId as O, ApiKeyId as S, MicroUsd as T, SandboxStatus as _, Key as a, ProviderSort as b, SpendLimit as c, CreateSandboxRequest as d, Port as f, SandboxSpec as g, SandboxList as h, CreatedKey as i, Timestamp 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, KeySecret as w, StandardSize as x, ProviderPreferences as y };
413
+ export { KeyId as A, CARD_FEE_TERMS as C, MICRO_USD_PER_DOLLAR as D, CreditCheckout as E, SandboxId as F, Timestamp as I, MicroUsd as M, Provider as N, ApiKeyId as O, Region as P, Billing as S, CREDIT_PURCHASE_MIN_MICRO_USD as T, SandboxStatus as _, Key as a, ProviderSort as b, SpendLimit as c, CreateSandboxRequest as d, Port as f, SandboxSpec as g, SandboxList as h, CreatedKey as i, KeySecret as j, GpuType 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, CREDIT_PURCHASE_MAX_MICRO_USD as w, StandardSize as x, ProviderPreferences as y };
@@ -0,0 +1 @@
1
+ export { t as OTLP_DESTINATIONS, n as POSTHOG_APP_HOST, r as POSTHOG_INGEST_HOST, i as POSTHOG_PROJECT_ID, a as POSTHOG_PROJECT_TOKEN, o as WORKER_OBSERVABILITY } from "./posthog-project-CdWw_ofg.mjs";
@@ -1,6 +1,8 @@
1
1
  // ../sandcovery-contract/src/posthog-project.ts
2
2
  const POSTHOG_PROJECT_TOKEN = "phc_z6QJckCpFsqoDDAcCJQuQpYFrH2BtqvmrFUNtAkzTwJd";
3
3
  const POSTHOG_INGEST_HOST = "https://us.i.posthog.com";
4
+ const POSTHOG_APP_HOST = "https://us.posthog.com";
5
+ const POSTHOG_PROJECT_ID = "719925";
4
6
  const OTLP_DESTINATIONS = {
5
7
  logs: "sandcovery-otlp-logs",
6
8
  traces: "sandcovery-otlp-traces"
@@ -17,4 +19,4 @@ const WORKER_OBSERVABILITY = {
17
19
  enabled: true
18
20
  }
19
21
  };
20
- export { WORKER_OBSERVABILITY as i, POSTHOG_INGEST_HOST as n, POSTHOG_PROJECT_TOKEN as r, OTLP_DESTINATIONS as t };
22
+ export { POSTHOG_PROJECT_TOKEN as a, POSTHOG_PROJECT_ID as i, POSTHOG_APP_HOST as n, WORKER_OBSERVABILITY as o, POSTHOG_INGEST_HOST as r, OTLP_DESTINATIONS as t };
@@ -1,5 +1,5 @@
1
- import { M as TaggedError } from "./Schema-C4ay0Aif.mjs";
2
- import { _ as SandboxStatus, b as ProviderSort, c as SpendLimit, o as KeyKind } from "./origin-Dj-n4EQa.mjs";
1
+ import { N as TaggedError } from "./Schema-DiSfJzMf.mjs";
2
+ import { C as CARD_FEE_TERMS, D as MICRO_USD_PER_DOLLAR, T as CREDIT_PURCHASE_MIN_MICRO_USD, _ as SandboxStatus, b as ProviderSort, c as SpendLimit, o as KeyKind, w as CREDIT_PURCHASE_MAX_MICRO_USD } from "./origin-CIA-1Jia.mjs";
3
3
  // ../cli-core/src/canceled.ts
4
4
  var Canceled = class extends TaggedError("Canceled") {};
5
5
  // ../cli-core/src/failure.ts
@@ -26,6 +26,8 @@ const blockedClasses = /* @__PURE__ */ new Set([
26
26
  "usage"
27
27
  ]);
28
28
  const reasons = {
29
+ agreement_accepted: "conflict",
30
+ agreement_changed: "conflict",
29
31
  agreement_not_accepted: "conflict",
30
32
  api_error: "platform",
31
33
  campaign_funding_active: "conflict",
@@ -36,6 +38,7 @@ const reasons = {
36
38
  confirmation_required: "missing_input",
37
39
  conflict: "conflict",
38
40
  contract_locked: "conflict",
41
+ domain_taken: "conflict",
39
42
  internal_error: "bug",
40
43
  invalid_arguments: "usage",
41
44
  invalid_config: "config",
@@ -59,14 +62,18 @@ const reasons = {
59
62
  not_found: "not_found",
60
63
  out_of_credits: "limit",
61
64
  permission_denied: "permission",
65
+ proof_not_found: "conflict",
62
66
  provider_error: "platform",
63
67
  rate_limited: "rate_limit",
64
68
  redirected: "network",
69
+ site_exists: "conflict",
70
+ site_taken: "conflict",
65
71
  site_unverified: "conflict",
66
72
  spawn_failed: "platform",
67
73
  spend_limit_reached: "limit",
68
74
  stale_login: "conflict",
69
75
  subscription_required: "limit",
76
+ team_has_site: "conflict",
70
77
  token_expired: "authentication",
71
78
  token_scope_required: "permission",
72
79
  tool_refused: "conflict",
@@ -357,6 +364,7 @@ const readOptionToken = ({ options, token }) => {
357
364
  };
358
365
  const booleanText = /* @__PURE__ */ new Map([["false", false], ["true", true]]);
359
366
  const isOptionToken = (token) => token.startsWith("-") && token !== "-";
367
+ const isOptionValue = (token) => !isOptionToken(token) || Number.isFinite(Number(token));
360
368
  const flagOf = (options, name) => {
361
369
  const value = options[name];
362
370
  return value?.kind === "flag" ? value.value : void 0;
@@ -439,7 +447,7 @@ const takeValue = (state, read, option) => {
439
447
  return;
440
448
  }
441
449
  const next = state.tokens[state.index];
442
- if (next === void 0 || isOptionToken(next)) {
450
+ if (next === void 0 || !isOptionValue(next)) {
443
451
  const example = option.hint === void 0 ? "" : `, such as ${option.hint}`;
444
452
  state.issues.push({
445
453
  field: `--${option.name}`,
@@ -542,7 +550,7 @@ const parseFailure = ({ bin, issues, path }) => {
542
550
  });
543
551
  };
544
552
  // package.json
545
- var version = "0.2.0";
553
+ var version = "0.3.0";
546
554
  // src/cli/spec.ts
547
555
  const BIN = "sandcovery";
548
556
  const NULLABLE_TEXT = "string | null";
@@ -906,33 +914,51 @@ const sandboxesExec = {
906
914
  summary: "Command to run, after --; like ssh, its words join with spaces and run in the sandbox's shell",
907
915
  variadic: true
908
916
  }],
909
- examples: [{
910
- argv: [
911
- "sandboxes",
912
- "exec",
913
- SANDBOX,
914
- "--",
915
- "ls",
916
- "-la"
917
- ],
918
- summary: "List the working directory"
919
- }, {
920
- argv: [
921
- "sandboxes",
922
- "exec",
923
- SANDBOX,
924
- "--json",
925
- "--",
926
- "npm",
927
- "test"
928
- ],
929
- summary: "Run the tests and read their output and exit code in a script"
930
- }],
917
+ examples: [
918
+ {
919
+ argv: [
920
+ "sandboxes",
921
+ "exec",
922
+ SANDBOX,
923
+ "--",
924
+ "ls",
925
+ "-la"
926
+ ],
927
+ summary: "List the working directory"
928
+ },
929
+ {
930
+ argv: [
931
+ "sandboxes",
932
+ "exec",
933
+ SANDBOX,
934
+ "--json",
935
+ "--",
936
+ "npm",
937
+ "test"
938
+ ],
939
+ summary: "Run the tests and read their output and exit code in a script"
940
+ },
941
+ {
942
+ argv: [
943
+ "sandboxes",
944
+ "exec",
945
+ SANDBOX,
946
+ "--detach",
947
+ "--",
948
+ "node",
949
+ "server.js",
950
+ ">server.log",
951
+ "2>&1"
952
+ ],
953
+ summary: "Start a server that keeps running after the CLI exits"
954
+ }
955
+ ],
931
956
  kind: "leaf",
932
957
  name: "exec",
933
958
  notes: [
934
959
  "The command's stdout and stderr stream to this terminal's, and the CLI exits with the command's exit code.",
935
960
  "With --json, the CLI waits for the command and prints its stdout, stderr, exit code, and duration as one document.",
961
+ "With --detach, the CLI returns once the provider starts the command, which keeps running until it exits or the sandbox ends, and its output is not kept, so redirect it to a file to read it later. A provider with no detached commands answers unsupported.",
936
962
  "The CLI never retries a command, since running it twice may change the sandbox twice."
937
963
  ],
938
964
  options: [
@@ -943,6 +969,10 @@ const sandboxesExec = {
943
969
  name: "cwd",
944
970
  summary: "Directory in the sandbox to run the command in"
945
971
  },
972
+ flag({
973
+ name: "detach",
974
+ summary: "Start the command and return at once, leaving it running in the sandbox"
975
+ }),
946
976
  env,
947
977
  json,
948
978
  {
@@ -968,6 +998,10 @@ const sandboxesExec = {
968
998
  {
969
999
  name: "exec.duration_ms",
970
1000
  type: "number"
1001
+ },
1002
+ {
1003
+ name: "exec.started_at",
1004
+ type: "string"
971
1005
  }
972
1006
  ],
973
1007
  summary: "Run a command in a sandbox"
@@ -1510,6 +1544,32 @@ const credentials = {
1510
1544
  }],
1511
1545
  shortcuts: ["rm"],
1512
1546
  summary: "Delete a provider credential"
1547
+ },
1548
+ {
1549
+ arguments: [],
1550
+ examples: [{
1551
+ argv: ["credentials", "offer"],
1552
+ summary: "Show the free vCPU-hours your keys have earned"
1553
+ }],
1554
+ kind: "leaf",
1555
+ name: "offer",
1556
+ notes: ["Shows the provider Sandcovery pays for, the keys counted toward the free vCPU-hours, and the vCPU-hours left. It fails as not found while no offer runs. Needs a management key."],
1557
+ options: [baseUrl, json],
1558
+ result: [
1559
+ {
1560
+ name: "offer.provider",
1561
+ type: "string"
1562
+ },
1563
+ {
1564
+ name: "offer.keys_counted",
1565
+ type: "number"
1566
+ },
1567
+ {
1568
+ name: "offer.remaining_vcpu_seconds",
1569
+ type: "number"
1570
+ }
1571
+ ],
1572
+ summary: "Show the free vCPU-hours offer"
1513
1573
  }
1514
1574
  ],
1515
1575
  defaultChild: "list",
@@ -1524,11 +1584,30 @@ const providers = {
1524
1584
  examples: [{
1525
1585
  argv: ["providers", "list"],
1526
1586
  summary: "Compare the providers' prices and status"
1587
+ }, {
1588
+ argv: [
1589
+ "providers",
1590
+ "list",
1591
+ "--routed"
1592
+ ],
1593
+ summary: "List only the providers Sandcovery routes sandboxes to"
1527
1594
  }],
1528
1595
  kind: "leaf",
1529
1596
  name: "list",
1530
- notes: ["Lists each provider with its status, 2x4 price per hour, and median create latency."],
1531
- options: [baseUrl, json],
1597
+ notes: [
1598
+ "Lists each provider with its status, 2x4 price per hour, and median create latency.",
1599
+ "A provider Sandcovery does not route to yet shows as coming soon.",
1600
+ "Not shared marks a figure the provider's terms ask Sandcovery not to publish, and --json adds every fact with the page it was read from.",
1601
+ "With --routed, it lists only the providers on the provider board, and --json prints their board entries."
1602
+ ],
1603
+ options: [
1604
+ baseUrl,
1605
+ json,
1606
+ flag({
1607
+ name: "routed",
1608
+ summary: "List only the providers Sandcovery routes to"
1609
+ })
1610
+ ],
1532
1611
  result: [
1533
1612
  {
1534
1613
  name: "providers",
@@ -1538,6 +1617,10 @@ const providers = {
1538
1617
  name: "providers[].provider",
1539
1618
  type: "string"
1540
1619
  },
1620
+ {
1621
+ name: "providers[].routed",
1622
+ type: "boolean"
1623
+ },
1541
1624
  {
1542
1625
  name: "providers[].status",
1543
1626
  type: "string"
@@ -1721,6 +1804,68 @@ const activity = {
1721
1804
  name: "activity",
1722
1805
  summary: "Read what happened to your sandboxes"
1723
1806
  };
1807
+ const billing = {
1808
+ children: [{
1809
+ arguments: [],
1810
+ examples: [{
1811
+ argv: ["billing", "inspect"],
1812
+ summary: "Show the plan and the credit balance"
1813
+ }],
1814
+ kind: "leaf",
1815
+ name: "inspect",
1816
+ notes: [`Shows the plan, the credit balance, and the Pro price. It fails as not found while billing is not open. ${NEEDS_MANAGEMENT}`],
1817
+ options: [baseUrl, json],
1818
+ result: [
1819
+ {
1820
+ name: "billing.plan",
1821
+ type: "\"free\" | \"pro\""
1822
+ },
1823
+ {
1824
+ name: "billing.credit_balance_micro_usd",
1825
+ type: "number"
1826
+ },
1827
+ {
1828
+ name: "billing.pro_price",
1829
+ type: "object | null"
1830
+ }
1831
+ ],
1832
+ summary: "Show the plan and credits"
1833
+ }, {
1834
+ arguments: [],
1835
+ examples: [{
1836
+ argv: [
1837
+ "billing",
1838
+ "buy-credits",
1839
+ "--amount",
1840
+ "100"
1841
+ ],
1842
+ summary: "Start a 100 USD credit purchase"
1843
+ }],
1844
+ kind: "leaf",
1845
+ name: "buy-credits",
1846
+ notes: [`Prints the Stripe Checkout page that takes the payment. The credits are the amount less the processing fee of ${CARD_FEE_TERMS}, and arrive once Stripe confirms the payment. ${NEEDS_MANAGEMENT}`],
1847
+ options: [
1848
+ {
1849
+ hint: "<USD>",
1850
+ kind: "value",
1851
+ name: "amount",
1852
+ required: true,
1853
+ summary: `Whole US dollars to pay, from ${String(CREDIT_PURCHASE_MIN_MICRO_USD / MICRO_USD_PER_DOLLAR)} to ${String(CREDIT_PURCHASE_MAX_MICRO_USD / MICRO_USD_PER_DOLLAR)}`
1854
+ },
1855
+ baseUrl,
1856
+ json
1857
+ ],
1858
+ result: [{
1859
+ name: "checkout.url",
1860
+ type: "string"
1861
+ }],
1862
+ summary: "Buy credits through Stripe Checkout"
1863
+ }],
1864
+ defaultChild: "inspect",
1865
+ kind: "group",
1866
+ name: "billing",
1867
+ summary: "Show the plan and buy credits"
1868
+ };
1724
1869
  const telemetryLeaf = ({ name, summary }) => ({
1725
1870
  arguments: [],
1726
1871
  examples: [{
@@ -1835,6 +1980,7 @@ const CLI = {
1835
1980
  providers,
1836
1981
  usage,
1837
1982
  activity,
1983
+ billing,
1838
1984
  help,
1839
1985
  {
1840
1986
  children: [{
@@ -1893,7 +2039,8 @@ const CLI = {
1893
2039
  paths: [
1894
2040
  ["keys"],
1895
2041
  ["credentials"],
1896
- ["activity", "list"]
2042
+ ["activity", "list"],
2043
+ ["billing"]
1897
2044
  ],
1898
2045
  title: "Account"
1899
2046
  },
@@ -1907,4 +2054,4 @@ const CLI = {
1907
2054
  }
1908
2055
  ]
1909
2056
  };
1910
- export { exitCodeOf as A, remoteText as C, isUpper as D, isDigits as E, usageFailure as M, Canceled as N, isWordCharacter as O, remoteLine as S, isDigit as T, plainPrefix as _, closest as a, escapeUnprintable as b, lastValue as c, readOptionToken as d, rerunArgv as f, glyph as g, ellipsis as h, version as i, statusOf as j, CliFailure as k, parseFailure as l, clearLine as m, CLEARABLE as n, flagOf as o, valuesOf as p, CLI as r, isOptionToken as s, BIN as t, parseLeaf as u, spinnerFrame as v, consistsOf as w, remoteCell as x, theme as y };
2057
+ export { CliFailure as A, remoteLine as C, isDigits as D, isDigit as E, statusOf as M, usageFailure as N, isUpper as O, Canceled as P, remoteCell as S, consistsOf as T, glyph as _, closest as a, theme as b, isOptionValue as c, parseLeaf as d, readOptionToken as f, ellipsis as g, clearLine as h, version as i, exitCodeOf as j, isWordCharacter as k, lastValue as l, valuesOf as m, CLEARABLE as n, flagOf as o, rerunArgv as p, CLI as r, isOptionToken as s, BIN as t, parseFailure as u, plainPrefix as v, remoteText as w, escapeUnprintable as x, spinnerFrame as y };