sandcovery 0.1.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/LICENSE +21 -0
- package/README.md +96 -0
- package/dist/Schema-DiSfJzMf.mjs +11549 -0
- package/dist/cli/index.d.mts +1 -0
- package/dist/cli/index.mjs +1710 -0
- package/dist/handlers-rkx0CsMY.mjs +2459 -0
- package/dist/index.d.mts +84 -1
- package/dist/index.mjs +1 -5
- package/dist/origin-CIA-1Jia.mjs +413 -0
- package/dist/posthog-project-BpOd2VxW.mjs +1 -0
- package/dist/posthog-project-CdWw_ofg.mjs +22 -0
- package/dist/spec-DfgmzDj-.mjs +2057 -0
- package/dist/src-YrynO3hz.mjs +799 -0
- package/dist/telemetry-BYnuVdoZ.mjs +43 -0
- package/dist/telemetry-delivery-zinKRHRc.mjs +8712 -0
- package/dist/types-DMB8KnA3.d.mts +545 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +67 -0
- package/package.json +46 -4
package/dist/index.d.mts
CHANGED
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
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
|
+
interface RequestOptions {
|
|
3
|
+
readonly signal?: AbortSignal;
|
|
4
|
+
}
|
|
5
|
+
interface CreateSandboxOptions extends RequestOptions {
|
|
6
|
+
readonly idempotencyKey?: string;
|
|
7
|
+
}
|
|
8
|
+
interface PageQuery {
|
|
9
|
+
readonly cursor?: string;
|
|
10
|
+
readonly limit?: number;
|
|
11
|
+
}
|
|
12
|
+
interface ListSandboxesQuery extends PageQuery {
|
|
13
|
+
readonly status?: SandboxStatus;
|
|
14
|
+
}
|
|
15
|
+
interface UsageQuery {
|
|
16
|
+
readonly api_key_id?: string;
|
|
17
|
+
readonly from: string;
|
|
18
|
+
readonly to: string;
|
|
19
|
+
}
|
|
20
|
+
type FileContent = Blob | Uint8Array | string;
|
|
21
|
+
type SandboxCall<Result> = (sandboxId: string, options?: RequestOptions) => Promise<Result>;
|
|
22
|
+
type FileCall<Result> = (sandboxId: string, path: string, options?: RequestOptions) => Promise<Result>;
|
|
23
|
+
interface SandboxesApi {
|
|
24
|
+
readonly create: (request?: CreateSandboxRequest, options?: CreateSandboxOptions) => Promise<Sandbox>;
|
|
25
|
+
readonly destroy: SandboxCall<Sandbox>;
|
|
26
|
+
readonly downloadFile: FileCall<ReadableStream<Uint8Array>>;
|
|
27
|
+
readonly exec: (sandboxId: string, request: ExecRequest, options?: RequestOptions) => Promise<ExecResult>;
|
|
28
|
+
readonly execDetached: (sandboxId: string, request: DetachedExecRequest, options?: RequestOptions) => Promise<DetachedExec>;
|
|
29
|
+
readonly execStream: (sandboxId: string, request: ExecRequest, options?: RequestOptions) => AsyncGenerator<ExecEvent>;
|
|
30
|
+
readonly get: SandboxCall<Sandbox>;
|
|
31
|
+
readonly list: (query?: ListSandboxesQuery, options?: RequestOptions) => Promise<SandboxList>;
|
|
32
|
+
readonly listFiles: FileCall<FileList>;
|
|
33
|
+
readonly pause: SandboxCall<Sandbox>;
|
|
34
|
+
readonly portPreview: (sandboxId: string, port: number, options?: RequestOptions) => Promise<PortPreview>;
|
|
35
|
+
readonly readFile: FileCall<Uint8Array>;
|
|
36
|
+
readonly resume: SandboxCall<Sandbox>;
|
|
37
|
+
readonly snapshot: SandboxCall<Snapshot>;
|
|
38
|
+
readonly writeFile: (sandboxId: string, path: string, content: FileContent, options?: RequestOptions) => Promise<FileEntry>;
|
|
39
|
+
}
|
|
40
|
+
interface KeysApi {
|
|
41
|
+
readonly create: (request: CreateKeyRequest, options?: RequestOptions) => Promise<CreatedKey>;
|
|
42
|
+
readonly get: (keyId: string, options?: RequestOptions) => Promise<Key>;
|
|
43
|
+
readonly list: (options?: RequestOptions) => Promise<KeyList>;
|
|
44
|
+
readonly revoke: (keyId: string, options?: RequestOptions) => Promise<Key>;
|
|
45
|
+
readonly update: (keyId: string, request: UpdateKeyRequest, options?: RequestOptions) => Promise<Key>;
|
|
46
|
+
}
|
|
47
|
+
interface CredentialsApi {
|
|
48
|
+
readonly delete: (provider: Provider, options?: RequestOptions) => Promise<void>;
|
|
49
|
+
readonly list: (options?: RequestOptions) => Promise<ProviderCredentialList>;
|
|
50
|
+
readonly offer: (options?: RequestOptions) => Promise<Offer>;
|
|
51
|
+
readonly set: (provider: Provider, fields: CredentialFields, options?: RequestOptions) => Promise<ProviderCredential>;
|
|
52
|
+
}
|
|
53
|
+
interface ActivityApi {
|
|
54
|
+
readonly list: (query?: PageQuery, options?: RequestOptions) => Promise<ActivityList>;
|
|
55
|
+
}
|
|
56
|
+
interface BillingApi {
|
|
57
|
+
readonly buyCredits: (request: CreditPurchaseRequest, options?: RequestOptions) => Promise<CreditCheckout>;
|
|
58
|
+
readonly get: (options?: RequestOptions) => Promise<Billing>;
|
|
59
|
+
}
|
|
60
|
+
interface ProvidersApi {
|
|
61
|
+
readonly catalog: (options?: RequestOptions) => Promise<ProviderCatalog>;
|
|
62
|
+
readonly get: (provider: Provider, options?: RequestOptions) => Promise<ProviderBoardEntry>;
|
|
63
|
+
readonly list: (options?: RequestOptions) => Promise<ProviderBoard>;
|
|
64
|
+
}
|
|
65
|
+
interface UsageApi {
|
|
66
|
+
readonly estimate: (request: EstimateRequest, options?: RequestOptions) => Promise<EstimateList>;
|
|
67
|
+
readonly get: (query: UsageQuery, options?: RequestOptions) => Promise<Usage>;
|
|
68
|
+
}
|
|
69
|
+
export interface SandcoveryOptions {
|
|
70
|
+
readonly apiKey?: string;
|
|
71
|
+
readonly baseUrl?: string | URL;
|
|
72
|
+
readonly fetch?: typeof globalThis.fetch;
|
|
73
|
+
}
|
|
74
|
+
export declare class Sandcovery {
|
|
75
|
+
readonly activity: ActivityApi;
|
|
76
|
+
readonly billing: BillingApi;
|
|
77
|
+
readonly credentials: CredentialsApi;
|
|
78
|
+
readonly keys: KeysApi;
|
|
79
|
+
readonly providers: ProvidersApi;
|
|
80
|
+
readonly sandboxes: SandboxesApi;
|
|
81
|
+
readonly usage: UsageApi;
|
|
82
|
+
constructor(options?: SandcoveryOptions);
|
|
83
|
+
}
|
|
84
|
+
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,413 @@
|
|
|
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
|
+
// ../sandcovery-contract/src/primitives.ts
|
|
3
|
+
const PROVIDERS = [
|
|
4
|
+
"daytona",
|
|
5
|
+
"depot",
|
|
6
|
+
"e2b",
|
|
7
|
+
"upstash"
|
|
8
|
+
];
|
|
9
|
+
const PROVIDER_EXAMPLES = new Intl.ListFormat("en", { type: "disjunction" }).format(PROVIDERS.map((provider) => `\`${provider}\``));
|
|
10
|
+
const SLUG_CHARACTERS = /* @__PURE__ */ new Set("abcdefghijklmnopqrstuvwxyz0123456789-");
|
|
11
|
+
const isSlug = (value) => value !== "" && value.split("").every((character) => SLUG_CHARACTERS.has(character));
|
|
12
|
+
const Provider = String$1.check(makeFilter(isSlug, {
|
|
13
|
+
expected: "a provider name of lowercase letters, digits, and hyphens",
|
|
14
|
+
toJsonSchema: () => ({ minLength: 1 })
|
|
15
|
+
})).annotate({
|
|
16
|
+
description: `A provider name of lowercase letters, digits, and hyphens, such as ${PROVIDER_EXAMPLES}. The API adds providers over time, so a client accepts any such name and the API refuses one it does not serve.`,
|
|
17
|
+
examples: PROVIDERS,
|
|
18
|
+
identifier: "Provider"
|
|
19
|
+
});
|
|
20
|
+
const Region = NonEmptyString.annotate({
|
|
21
|
+
description: "A coarse region, such as `asia`, `eu`, or `us`. A sandbox runs in a data center of the routed provider inside that region. The API adds regions over time.",
|
|
22
|
+
examples: [
|
|
23
|
+
"asia",
|
|
24
|
+
"eu",
|
|
25
|
+
"us"
|
|
26
|
+
],
|
|
27
|
+
identifier: "Region"
|
|
28
|
+
});
|
|
29
|
+
const GpuType = NonEmptyString.annotate({
|
|
30
|
+
description: "A GPU model, such as `h100`, `b200`, `rtx-pro-6000`, or `mi355x`. The API adds types over time.",
|
|
31
|
+
examples: [
|
|
32
|
+
"b200",
|
|
33
|
+
"b300",
|
|
34
|
+
"h100",
|
|
35
|
+
"h200",
|
|
36
|
+
"mi355x",
|
|
37
|
+
"rtx-4090",
|
|
38
|
+
"rtx-5090",
|
|
39
|
+
"rtx-pro-6000"
|
|
40
|
+
],
|
|
41
|
+
identifier: "GpuType"
|
|
42
|
+
});
|
|
43
|
+
const isUtcTimestamp = makeFilter((value) => {
|
|
44
|
+
const at = Date.parse(value);
|
|
45
|
+
return Number.isFinite(at) && new Date(at).toISOString() === value;
|
|
46
|
+
}, {
|
|
47
|
+
expected: "a UTC timestamp such as 2026-11-08T11:20:00.000Z",
|
|
48
|
+
toJsonSchema: () => ({ format: "date-time" })
|
|
49
|
+
});
|
|
50
|
+
const Timestamp = String$1.check(isUtcTimestamp).annotate({ description: "A UTC instant with milliseconds and a `Z` suffix, such as `2026-11-08T11:20:00.000Z`." });
|
|
51
|
+
const MicroUsd = Natural.annotate({ description: "An amount in integer micro-dollars: 1,000,000 is 1 USD." });
|
|
52
|
+
const isUuidV7 = is(String$1.check(isUUID(7)));
|
|
53
|
+
const hasPrefixedUuid = (value, prefix) => value.startsWith(prefix) && isUuidV7(value.slice(prefix.length));
|
|
54
|
+
const prefixedId = (prefix, noun) => String$1.check(makeFilter((value) => hasPrefixedUuid(value, prefix), {
|
|
55
|
+
expected: `${prefix} followed by a UUID v7`,
|
|
56
|
+
toJsonSchema: () => ({})
|
|
57
|
+
})).annotate({ description: `${noun} ID: \`${prefix}\` followed by a UUID v7.` });
|
|
58
|
+
const SandboxId = prefixedId("sbx_", "Sandbox");
|
|
59
|
+
const SnapshotId = prefixedId("snap_", "Snapshot");
|
|
60
|
+
const API_KEY_ID_PREFIX = "key_";
|
|
61
|
+
const MANAGEMENT_KEY_ID_PREFIX = "mkey_";
|
|
62
|
+
const ApiKeyId = prefixedId(API_KEY_ID_PREFIX, "API key");
|
|
63
|
+
const KeyId = String$1.check(makeFilter((value) => hasPrefixedUuid(value, API_KEY_ID_PREFIX) || hasPrefixedUuid(value, MANAGEMENT_KEY_ID_PREFIX), {
|
|
64
|
+
expected: `${API_KEY_ID_PREFIX} or ${MANAGEMENT_KEY_ID_PREFIX} followed by a UUID v7`,
|
|
65
|
+
toJsonSchema: () => ({})
|
|
66
|
+
})).annotate({ description: `Key ID: \`${API_KEY_ID_PREFIX}\` for an API key or \`${MANAGEMENT_KEY_ID_PREFIX}\` for a management key, followed by a UUID v7.` });
|
|
67
|
+
const SECRET_TEXT_LENGTH = 43;
|
|
68
|
+
const isBase64Url = is(String$1.check(isBase64Url$1()));
|
|
69
|
+
const API_KEY_SECRET_PREFIX = "sand_";
|
|
70
|
+
const MANAGEMENT_KEY_SECRET_PREFIX = "sandm_";
|
|
71
|
+
const hasPrefixedSecret = (value, prefix) => value.startsWith(prefix) && value.length === prefix.length + SECRET_TEXT_LENGTH && isBase64Url(value.slice(prefix.length));
|
|
72
|
+
const KeySecret = String$1.check(makeFilter((value) => hasPrefixedSecret(value, API_KEY_SECRET_PREFIX) || hasPrefixedSecret(value, MANAGEMENT_KEY_SECRET_PREFIX), {
|
|
73
|
+
expected: `${API_KEY_SECRET_PREFIX} or ${MANAGEMENT_KEY_SECRET_PREFIX} followed by 43 base64url characters`,
|
|
74
|
+
toJsonSchema: () => ({})
|
|
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" });
|
|
110
|
+
// ../sandcovery-contract/src/routing.ts
|
|
111
|
+
const STANDARD_SIZES = [
|
|
112
|
+
{
|
|
113
|
+
memory_mib: 2048,
|
|
114
|
+
name: "1x2",
|
|
115
|
+
vcpu: 1
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
memory_mib: 4096,
|
|
119
|
+
name: "2x4",
|
|
120
|
+
vcpu: 2
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
memory_mib: 8192,
|
|
124
|
+
name: "4x8",
|
|
125
|
+
vcpu: 4
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
memory_mib: 16384,
|
|
129
|
+
name: "8x16",
|
|
130
|
+
vcpu: 8
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
const StandardSize = NonEmptyString.annotate({
|
|
134
|
+
description: "A standard size named `<vCPU>x<memory GiB>`, such as `1x2`, `2x4`, `4x8`, or `8x16`. The API adds sizes over time.",
|
|
135
|
+
examples: STANDARD_SIZES.map(({ name }) => name),
|
|
136
|
+
identifier: "StandardSize"
|
|
137
|
+
});
|
|
138
|
+
const ProviderSort = Literals([
|
|
139
|
+
"latency",
|
|
140
|
+
"price",
|
|
141
|
+
"uptime"
|
|
142
|
+
]).annotate({
|
|
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.",
|
|
144
|
+
identifier: "ProviderSort"
|
|
145
|
+
});
|
|
146
|
+
const ROUTING_SUFFIXES = [
|
|
147
|
+
{
|
|
148
|
+
sort: "price",
|
|
149
|
+
suffix: "cheapest"
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
sort: "latency",
|
|
153
|
+
suffix: "fastest"
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
sort: "uptime",
|
|
157
|
+
suffix: "most-reliable"
|
|
158
|
+
}
|
|
159
|
+
];
|
|
160
|
+
const SIZE_NAMES = STANDARD_SIZES.flatMap((size) => [{
|
|
161
|
+
name: size.name,
|
|
162
|
+
size,
|
|
163
|
+
sort: null
|
|
164
|
+
}, ...ROUTING_SUFFIXES.map(({ sort, suffix }) => ({
|
|
165
|
+
name: `${size.name}:${suffix}`,
|
|
166
|
+
size,
|
|
167
|
+
sort
|
|
168
|
+
}))]);
|
|
169
|
+
const isPositiveInteger = (text) => {
|
|
170
|
+
const value = Number(text);
|
|
171
|
+
return Number.isSafeInteger(value) && value > 0 && String(value) === text;
|
|
172
|
+
};
|
|
173
|
+
const isSizeName = (name) => {
|
|
174
|
+
const [dimensions = "", ...suffixes] = name.split(":");
|
|
175
|
+
const counts = dimensions.split("x");
|
|
176
|
+
return counts.length === 2 && counts.every(isPositiveInteger) && suffixes.length <= 1 && suffixes.every((suffix) => suffix !== "");
|
|
177
|
+
};
|
|
178
|
+
const SizeName = String$1.check(makeFilter(isSizeName, {
|
|
179
|
+
expected: "<vcpu>x<memory_gib>, optionally followed by a routing suffix",
|
|
180
|
+
toJsonSchema: () => ({ minLength: 1 })
|
|
181
|
+
})).annotate({
|
|
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`.",
|
|
183
|
+
examples: SIZE_NAMES.map(({ name }) => name),
|
|
184
|
+
identifier: "SizeName"
|
|
185
|
+
});
|
|
186
|
+
const ProviderPreferences = Struct({
|
|
187
|
+
allow_fallbacks: optionalKey(Boolean.annotate({ description: "Whether a failed create (capacity, quota, a provider 5xx, or a timeout) moves to the next candidate. Defaults to true." })),
|
|
188
|
+
ignore: optionalKey(ArraySchema(Provider).annotate({ description: "Providers never to route to." })),
|
|
189
|
+
only: optionalKey(ArraySchema(Provider).annotate({ description: "The only providers to route to." })),
|
|
190
|
+
order: optionalKey(ArraySchema(Provider).annotate({ description: "Providers to try first, in this order, before the remaining candidates in sorted order." })),
|
|
191
|
+
sort: optionalKey(ProviderSort)
|
|
192
|
+
}).annotate({
|
|
193
|
+
description: "Routing preferences in the shape of OpenRouter provider preferences. A size suffix sets `sort`, and a request whose suffix and `sort` disagree answers 400 `invalid_request`.",
|
|
194
|
+
identifier: "ProviderPreferences"
|
|
195
|
+
});
|
|
196
|
+
// ../sandcovery-contract/src/sandbox.ts
|
|
197
|
+
const MAX_TTL_SECONDS = 86400;
|
|
198
|
+
const MAX_PORT = 65535;
|
|
199
|
+
const MAX_PORTS = 8;
|
|
200
|
+
const MAX_GPUS = 8;
|
|
201
|
+
const between = (minimum, maximum) => Int.check(isBetween({
|
|
202
|
+
maximum,
|
|
203
|
+
minimum
|
|
204
|
+
}));
|
|
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
|
+
});
|
|
213
|
+
const EnvironmentVariables = Record(NonEmptyString, String$1).annotate({ description: "Environment variables by name. Sandcovery passes them to the provider and never returns them." });
|
|
214
|
+
const EgressPolicy = Union([
|
|
215
|
+
Struct({ mode: Literal("allow_all") }),
|
|
216
|
+
Struct({ mode: Literal("deny_all") }),
|
|
217
|
+
Struct({
|
|
218
|
+
destinations: NonEmptyArray(NonEmptyString).annotate({ description: "Host names or CIDR blocks the sandbox may reach." }),
|
|
219
|
+
mode: Literal("allowlist")
|
|
220
|
+
})
|
|
221
|
+
]).annotate({
|
|
222
|
+
description: "Outbound network access: `allow_all`, `deny_all`, or `allowlist` with the destinations the sandbox may reach.",
|
|
223
|
+
identifier: "EgressPolicy"
|
|
224
|
+
});
|
|
225
|
+
const SandboxSpec = Struct({
|
|
226
|
+
disk_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(1024)).annotate({ description: "Disk size in MiB. Defaults to the provider default." })),
|
|
227
|
+
egress: optionalKey(EgressPolicy),
|
|
228
|
+
env: optionalKey(EnvironmentVariables),
|
|
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." })),
|
|
231
|
+
image: optionalKey(NonEmptyString.annotate({ description: "An OCI image reference. Unset means the provider's default Linux image." })),
|
|
232
|
+
memory_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(256)).annotate({ description: "Memory in MiB. Set with `vcpu`, and never with `size`." })),
|
|
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." })),
|
|
234
|
+
region: optionalKey(Region),
|
|
235
|
+
size: optionalKey(SizeName),
|
|
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." })),
|
|
237
|
+
vcpu: optionalKey(between(1, 64).annotate({ description: "vCPU count. Set with `memory_mib`, and never with `size`." }))
|
|
238
|
+
});
|
|
239
|
+
const CreateSandboxRequest = Struct({
|
|
240
|
+
...SandboxSpec.fields,
|
|
241
|
+
provider: optionalKey(ProviderPreferences),
|
|
242
|
+
snapshot_id: optionalKey(SnapshotId.annotate({ description: "A snapshot to start from. The sandbox runs on the snapshot's provider." }))
|
|
243
|
+
}).annotate({
|
|
244
|
+
description: "A sandbox spec plus routing preferences. Give either `size` or both `vcpu` and `memory_mib`; with neither, the size is `2x4`. A spec option that no candidate provider can enforce answers 422 `unsupported` and is never ignored.",
|
|
245
|
+
identifier: "CreateSandboxRequest"
|
|
246
|
+
});
|
|
247
|
+
const CreateAttempt = Struct({
|
|
248
|
+
duration_ms: Natural,
|
|
249
|
+
failure: NullOr(Struct({
|
|
250
|
+
message: String$1,
|
|
251
|
+
reason: Literals([
|
|
252
|
+
"capacity",
|
|
253
|
+
"quota",
|
|
254
|
+
"rejected",
|
|
255
|
+
"server_error",
|
|
256
|
+
"timeout"
|
|
257
|
+
]).annotate({ identifier: "CreateFailureReason" })
|
|
258
|
+
}).annotate({ description: "Why the attempt failed: `capacity`, `quota`, `server_error` (a provider 5xx), and `timeout` fall back to the next candidate when `allow_fallbacks` is not false, while `rejected` (any other provider refusal, such as an invalid credential) stops the create, which answers 502 `provider_error` naming that provider." })),
|
|
259
|
+
provider: Provider,
|
|
260
|
+
started_at: Timestamp
|
|
261
|
+
}).annotate({
|
|
262
|
+
description: "One provider create call made while routing a sandbox. `failure` is null on the attempt that created it.",
|
|
263
|
+
identifier: "CreateAttempt"
|
|
264
|
+
});
|
|
265
|
+
const SandboxStatus = Literals([
|
|
266
|
+
"creating",
|
|
267
|
+
"destroyed",
|
|
268
|
+
"destroying",
|
|
269
|
+
"failed",
|
|
270
|
+
"paused",
|
|
271
|
+
"running"
|
|
272
|
+
]).annotate({ identifier: "SandboxStatus" });
|
|
273
|
+
const SandboxEndReason = Literals([
|
|
274
|
+
"create_failed",
|
|
275
|
+
"destroyed",
|
|
276
|
+
"expired",
|
|
277
|
+
"gone"
|
|
278
|
+
]).annotate({
|
|
279
|
+
description: "Why the sandbox ended: `create_failed` when no create attempt succeeded, `destroyed` by a destroy call, `expired` at its TTL, or `gone` when the provider no longer had it.",
|
|
280
|
+
identifier: "SandboxEndReason"
|
|
281
|
+
});
|
|
282
|
+
const SandboxCost = Struct({
|
|
283
|
+
estimated_micro_usd: MicroUsd.annotate({ description: "Estimated list-price cost so far, from the rate card, until the sandbox is destroyed." }),
|
|
284
|
+
hourly_micro_usd: MicroUsd,
|
|
285
|
+
rate_card_version: String$1
|
|
286
|
+
}).annotate({
|
|
287
|
+
description: "Estimated cost at the provider's list price from a versioned rate card. The provider bills your own account.",
|
|
288
|
+
identifier: "SandboxCost"
|
|
289
|
+
});
|
|
290
|
+
const Sandbox = Struct({
|
|
291
|
+
api_key_id: ApiKeyId.annotate({ description: "The API key that created the sandbox." }),
|
|
292
|
+
attempts: ArraySchema(CreateAttempt),
|
|
293
|
+
cost: SandboxCost,
|
|
294
|
+
created_at: Timestamp,
|
|
295
|
+
disk_mib: NullOr(Natural),
|
|
296
|
+
egress: EgressPolicy,
|
|
297
|
+
end_reason: NullOr(SandboxEndReason),
|
|
298
|
+
ended_at: NullOr(Timestamp),
|
|
299
|
+
expires_at: Timestamp,
|
|
300
|
+
gpu: NullOr(Gpu),
|
|
301
|
+
id: SandboxId,
|
|
302
|
+
idle_timeout_seconds: NullOr(Natural),
|
|
303
|
+
image: NullOr(String$1),
|
|
304
|
+
memory_mib: Natural,
|
|
305
|
+
ports: ArraySchema(Port),
|
|
306
|
+
provider: NullOr(Provider).annotate({ description: "The provider the sandbox is bound to, or null while it is creating or when every create attempt failed." }),
|
|
307
|
+
provider_sandbox_id: NullOr(String$1),
|
|
308
|
+
region: NullOr(Region),
|
|
309
|
+
size: NullOr(SizeName),
|
|
310
|
+
started_at: NullOr(Timestamp).annotate({ description: "When the provider reported the sandbox running." }),
|
|
311
|
+
status: SandboxStatus,
|
|
312
|
+
ttl_seconds: Natural,
|
|
313
|
+
vcpu: Natural
|
|
314
|
+
}).annotate({
|
|
315
|
+
description: "A sandbox, bound to the provider that created it. `expires_at` is when Sandcovery destroys it, and pausing does not move it. `ended_at` and `end_reason` are set once it ends.",
|
|
316
|
+
identifier: "Sandbox"
|
|
317
|
+
});
|
|
318
|
+
const SandboxList = Struct({
|
|
319
|
+
data: ArraySchema(Sandbox),
|
|
320
|
+
next_cursor: NullOr(String$1)
|
|
321
|
+
}).annotate({ identifier: "SandboxList" });
|
|
322
|
+
const Snapshot = Struct({
|
|
323
|
+
created_at: Timestamp,
|
|
324
|
+
id: SnapshotId,
|
|
325
|
+
provider: Provider,
|
|
326
|
+
sandbox_id: SandboxId
|
|
327
|
+
}).annotate({
|
|
328
|
+
description: "A snapshot of a sandbox filesystem. A sandbox created from it runs on the same provider.",
|
|
329
|
+
identifier: "Snapshot"
|
|
330
|
+
});
|
|
331
|
+
const PortPreview = Struct({
|
|
332
|
+
expires_at: NullOr(Timestamp),
|
|
333
|
+
headers: Record(String$1, String$1).annotate({ description: "Headers a request to `url` must carry, such as a provider preview token. Often empty." }),
|
|
334
|
+
port: Port,
|
|
335
|
+
url: String$1
|
|
336
|
+
}).annotate({
|
|
337
|
+
description: "A provider URL that reaches a port inside the sandbox.",
|
|
338
|
+
identifier: "PortPreview"
|
|
339
|
+
});
|
|
340
|
+
const KeyName = NonEmptyString.check(isMaxLength(64));
|
|
341
|
+
const PositiveInt = Int.check(isGreaterThanOrEqualTo(1));
|
|
342
|
+
const KeyKind = Literals(["api", "management"]).annotate({
|
|
343
|
+
description: "An `api` key creates and drives sandboxes. A `management` key mints, changes, and revokes keys, sets provider credentials, and reads usage, and reaches no sandbox.",
|
|
344
|
+
identifier: "KeyKind"
|
|
345
|
+
});
|
|
346
|
+
const SpendLimit = Struct({
|
|
347
|
+
limit_micro_usd: MicroUsd,
|
|
348
|
+
period: Literals([
|
|
349
|
+
"day",
|
|
350
|
+
"month",
|
|
351
|
+
"total",
|
|
352
|
+
"week"
|
|
353
|
+
]).annotate({
|
|
354
|
+
description: "The window the limit counts: a UTC `day`, an ISO `week` from Monday 00:00 UTC, a UTC calendar `month`, or the key `total`.",
|
|
355
|
+
identifier: "SpendLimitPeriod"
|
|
356
|
+
})
|
|
357
|
+
}).annotate({
|
|
358
|
+
description: "A cap on the list-price cost of sandboxes the key creates, counting usage billed to your own provider accounts.",
|
|
359
|
+
identifier: "SpendLimit"
|
|
360
|
+
});
|
|
361
|
+
const keyPolicyFields = {
|
|
362
|
+
allowed_providers: NullOr(ArraySchema(Provider)).annotate({ description: "The only providers the key may route to. Null allows all." }),
|
|
363
|
+
max_concurrent_sandboxes: NullOr(PositiveInt),
|
|
364
|
+
max_ttl_seconds: NullOr(PositiveInt),
|
|
365
|
+
spend_limit: NullOr(SpendLimit)
|
|
366
|
+
};
|
|
367
|
+
const Key = Struct({
|
|
368
|
+
...keyPolicyFields,
|
|
369
|
+
created_at: Timestamp,
|
|
370
|
+
expires_at: NullOr(Timestamp),
|
|
371
|
+
id: KeyId,
|
|
372
|
+
kind: KeyKind,
|
|
373
|
+
last_used_at: NullOr(Timestamp),
|
|
374
|
+
name: String$1,
|
|
375
|
+
revoked_at: NullOr(Timestamp),
|
|
376
|
+
spend: Struct({
|
|
377
|
+
resets_at: NullOr(Timestamp),
|
|
378
|
+
spent_micro_usd: MicroUsd
|
|
379
|
+
}).annotate({ description: "List-price cost counted against `spend_limit` in its current window, or in total when the key has no limit. Always 0 for a management key." }),
|
|
380
|
+
start: String$1.annotate({ description: "The first 12 characters of the secret, for display." })
|
|
381
|
+
}).annotate({
|
|
382
|
+
description: "An API key or a management key. Its secret is never returned after creation, and the limits are null on a management key.",
|
|
383
|
+
identifier: "Key"
|
|
384
|
+
});
|
|
385
|
+
const KeyList = Struct({ data: ArraySchema(Key) }).annotate({ identifier: "KeyList" });
|
|
386
|
+
const CreateKeyRequest = Struct({
|
|
387
|
+
allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
|
|
388
|
+
expires_at: optionalKey(NullOr(Timestamp)),
|
|
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." }),
|
|
390
|
+
max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
|
|
391
|
+
max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
|
|
392
|
+
name: KeyName,
|
|
393
|
+
spend_limit: optionalKey(keyPolicyFields.spend_limit)
|
|
394
|
+
}).annotate({ identifier: "CreateKeyRequest" });
|
|
395
|
+
const UpdateKeyRequest = Struct({
|
|
396
|
+
allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
|
|
397
|
+
expires_at: optionalKey(NullOr(Timestamp)),
|
|
398
|
+
max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
|
|
399
|
+
max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
|
|
400
|
+
name: optionalKey(KeyName),
|
|
401
|
+
spend_limit: optionalKey(keyPolicyFields.spend_limit)
|
|
402
|
+
}).annotate({
|
|
403
|
+
description: "Fields to change. An absent field keeps its value, and null clears a limit. A limit on a management key answers 400 `invalid_request`.",
|
|
404
|
+
identifier: "UpdateKeyRequest"
|
|
405
|
+
});
|
|
406
|
+
const CreatedKey = Struct({
|
|
407
|
+
key: Key,
|
|
408
|
+
secret: KeySecret
|
|
409
|
+
}).annotate({ identifier: "CreatedKey" });
|
|
410
|
+
// ../sandcovery-contract/src/origin.ts
|
|
411
|
+
const SANDCOVERY_ORIGIN = "https://www.sandcovery.com";
|
|
412
|
+
const API_PREFIX = "/api/v1";
|
|
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";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// ../sandcovery-contract/src/posthog-project.ts
|
|
2
|
+
const POSTHOG_PROJECT_TOKEN = "phc_z6QJckCpFsqoDDAcCJQuQpYFrH2BtqvmrFUNtAkzTwJd";
|
|
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";
|
|
6
|
+
const OTLP_DESTINATIONS = {
|
|
7
|
+
logs: "sandcovery-otlp-logs",
|
|
8
|
+
traces: "sandcovery-otlp-traces"
|
|
9
|
+
};
|
|
10
|
+
const WORKER_OBSERVABILITY = {
|
|
11
|
+
enabled: true,
|
|
12
|
+
logs: {
|
|
13
|
+
destinations: [OTLP_DESTINATIONS.logs],
|
|
14
|
+
enabled: true,
|
|
15
|
+
invocation_logs: true
|
|
16
|
+
},
|
|
17
|
+
traces: {
|
|
18
|
+
destinations: [OTLP_DESTINATIONS.traces],
|
|
19
|
+
enabled: true
|
|
20
|
+
}
|
|
21
|
+
};
|
|
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 };
|