sandcovery 0.2.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.
- package/README.md +17 -7
- package/dist/{Schema-C4ay0Aif.mjs → Schema-CFI3ZMu8.mjs} +216 -4
- package/dist/cli/index.mjs +10 -29
- package/dist/handlers-BS1KuMqq.mjs +6546 -0
- package/dist/index.d.mts +31 -1
- package/dist/index.mjs +1 -1
- package/dist/{origin-Dj-n4EQa.mjs → origin-BTx2gX8x.mjs} +162 -81
- package/dist/posthog-project-BpOd2VxW.mjs +1 -0
- package/dist/{posthog-project-Bb0IFKUv.mjs → posthog-project-CdWw_ofg.mjs} +3 -1
- package/dist/{spec-ClAX0dAN.mjs → spec-B4c-Ug3B.mjs} +765 -144
- package/dist/src-DPDVOBkr.mjs +1016 -0
- package/dist/{telemetry-delivery-1a7C-8DK.mjs → telemetry-delivery-Yd6CeynR.mjs} +3 -3
- package/dist/types-DvoIdTvQ.d.mts +684 -0
- package/dist/types.d.mts +2 -2
- package/dist/types.mjs +35 -19
- package/package.json +6 -4
- package/dist/handlers-BxhSLDGk.mjs +0 -2217
- package/dist/posthog-project-B0jmQTwy.mjs +0 -1
- package/dist/src-D3WZodpF.mjs +0 -572
- package/dist/types-Dxh7amZB.d.mts +0 -345
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as CreatedKey, Ct as ProviderCatalog, Et as ProviderCredentialList, G as ExecRequest, H as EstimateList, Ht as SandboxStatus, I as DetachedExec, K as ExecResult, Kt as Snapshot, L as DetachedExecRequest, M as CredentialFields, N as CreditCheckout, O as CreateKeyRequest, P as CreditPurchaseRequest, Rt as Sandbox, S as CiJobList, St as ProviderBoardEntry, Tt as ProviderCredential, U as EstimateRequest, Vt as SandboxList, W as ExecEvent, Y as FileList, Zt as Stats, _t as Pricing, b as CiJob, bt as Provider, ft as Offer, gt as PortPreview, i as ActivityList, k as CreateSandboxRequest, lt as LiveUsage, nn as UpdateKeyRequest, ot as KeyList, q as FileEntry, rn as Usage, rt as Key, s as Billing, sn as UsageTotals, xt as ProviderBoard, y as CiInstallationList } from "./types-DvoIdTvQ.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>;
|
|
@@ -44,20 +45,45 @@ interface KeysApi {
|
|
|
44
45
|
readonly update: (keyId: string, request: UpdateKeyRequest, options?: RequestOptions) => Promise<Key>;
|
|
45
46
|
}
|
|
46
47
|
interface CredentialsApi {
|
|
48
|
+
readonly add: (provider: Provider, fields: CredentialFields, options?: RequestOptions) => Promise<ProviderCredential>;
|
|
47
49
|
readonly delete: (provider: Provider, options?: RequestOptions) => Promise<void>;
|
|
50
|
+
readonly deleteOne: (provider: Provider, credentialId: string, options?: RequestOptions) => Promise<void>;
|
|
48
51
|
readonly list: (options?: RequestOptions) => Promise<ProviderCredentialList>;
|
|
52
|
+
readonly offer: (options?: RequestOptions) => Promise<Offer>;
|
|
49
53
|
readonly set: (provider: Provider, fields: CredentialFields, options?: RequestOptions) => Promise<ProviderCredential>;
|
|
50
54
|
}
|
|
51
55
|
interface ActivityApi {
|
|
52
56
|
readonly list: (query?: PageQuery, options?: RequestOptions) => Promise<ActivityList>;
|
|
53
57
|
}
|
|
58
|
+
interface BillingApi {
|
|
59
|
+
readonly buyCredits: (request: CreditPurchaseRequest, options?: RequestOptions) => Promise<CreditCheckout>;
|
|
60
|
+
readonly get: (options?: RequestOptions) => Promise<Billing>;
|
|
61
|
+
}
|
|
62
|
+
interface CiApi {
|
|
63
|
+
readonly getJob: (jobId: string, options?: RequestOptions) => Promise<CiJob>;
|
|
64
|
+
readonly listInstallations: (options?: RequestOptions) => Promise<CiInstallationList>;
|
|
65
|
+
readonly listJobs: (query?: PageQuery, options?: RequestOptions) => Promise<CiJobList>;
|
|
66
|
+
readonly unlinkInstallation: (installationId: number, options?: RequestOptions) => Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
interface PricingApi {
|
|
69
|
+
readonly get: (options?: RequestOptions) => Promise<Pricing>;
|
|
70
|
+
}
|
|
54
71
|
interface ProvidersApi {
|
|
72
|
+
readonly catalog: (options?: RequestOptions) => Promise<ProviderCatalog>;
|
|
55
73
|
readonly get: (provider: Provider, options?: RequestOptions) => Promise<ProviderBoardEntry>;
|
|
56
74
|
readonly list: (options?: RequestOptions) => Promise<ProviderBoard>;
|
|
57
75
|
}
|
|
76
|
+
interface StatsApi {
|
|
77
|
+
readonly get: (options?: RequestOptions) => Promise<Stats>;
|
|
78
|
+
}
|
|
79
|
+
interface UsageKeyQuery {
|
|
80
|
+
readonly api_key_id?: string;
|
|
81
|
+
}
|
|
58
82
|
interface UsageApi {
|
|
59
83
|
readonly estimate: (request: EstimateRequest, options?: RequestOptions) => Promise<EstimateList>;
|
|
60
84
|
readonly get: (query: UsageQuery, options?: RequestOptions) => Promise<Usage>;
|
|
85
|
+
readonly live: (query?: UsageKeyQuery, options?: RequestOptions) => Promise<LiveUsage>;
|
|
86
|
+
readonly totals: (query?: UsageKeyQuery, options?: RequestOptions) => Promise<UsageTotals>;
|
|
61
87
|
}
|
|
62
88
|
export interface SandcoveryOptions {
|
|
63
89
|
readonly apiKey?: string;
|
|
@@ -66,10 +92,14 @@ export interface SandcoveryOptions {
|
|
|
66
92
|
}
|
|
67
93
|
export declare class Sandcovery {
|
|
68
94
|
readonly activity: ActivityApi;
|
|
95
|
+
readonly billing: BillingApi;
|
|
96
|
+
readonly ci: CiApi;
|
|
69
97
|
readonly credentials: CredentialsApi;
|
|
70
98
|
readonly keys: KeysApi;
|
|
99
|
+
readonly pricing: PricingApi;
|
|
71
100
|
readonly providers: ProvidersApi;
|
|
72
101
|
readonly sandboxes: SandboxesApi;
|
|
102
|
+
readonly stats: StatsApi;
|
|
73
103
|
readonly usage: UsageApi;
|
|
74
104
|
constructor(options?: SandcoveryOptions);
|
|
75
105
|
}
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Sandcovery } from "./src-
|
|
1
|
+
export { t as Sandcovery } from "./src-DPDVOBkr.mjs";
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
import { C as
|
|
1
|
+
import { A as isUUID, C as is, D as isMaxLength, E as isGreaterThanOrEqualTo, N as optionalKey, O as isMinLength, T as isBetween, _ as Union, c as Literal, d as NonEmptyArray, f as NonEmptyString, g as Struct, h as String$1, j as makeFilter, k as isMultipleOf, l as Literals, m as Record, n as Boolean, o as Int, p as NullOr, t as ArraySchema, u as Natural, w as isBase64Url$1 } from "./Schema-CFI3ZMu8.mjs";
|
|
2
2
|
// ../sandcovery-contract/src/primitives.ts
|
|
3
3
|
const PROVIDERS = [
|
|
4
4
|
"daytona",
|
|
5
5
|
"depot",
|
|
6
6
|
"e2b",
|
|
7
|
-
"
|
|
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
|
-
const
|
|
11
|
-
const Provider = String$1.check(makeFilter(
|
|
11
|
+
const isProviderName = (value) => value !== "" && value.split("").every((character) => SLUG_CHARACTERS.has(character));
|
|
12
|
+
const Provider = String$1.check(makeFilter(isProviderName, {
|
|
12
13
|
expected: "a provider name of lowercase letters, digits, and hyphens",
|
|
13
14
|
toJsonSchema: () => ({ minLength: 1 })
|
|
14
15
|
})).annotate({
|
|
15
|
-
description:
|
|
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;
|
|
@@ -42,6 +57,8 @@ const prefixedId = (prefix, noun) => String$1.check(makeFilter((value) => hasPre
|
|
|
42
57
|
})).annotate({ description: `${noun} ID: \`${prefix}\` followed by a UUID v7.` });
|
|
43
58
|
const SandboxId = prefixedId("sbx_", "Sandbox");
|
|
44
59
|
const SnapshotId = prefixedId("snap_", "Snapshot");
|
|
60
|
+
const CiJobId = prefixedId("cij_", "CI job");
|
|
61
|
+
const CredentialId = prefixedId("cred_", "Provider credential");
|
|
45
62
|
const API_KEY_ID_PREFIX = "key_";
|
|
46
63
|
const MANAGEMENT_KEY_ID_PREFIX = "mkey_";
|
|
47
64
|
const ApiKeyId = prefixedId(API_KEY_ID_PREFIX, "API key");
|
|
@@ -58,32 +75,80 @@ const KeySecret = String$1.check(makeFilter((value) => hasPrefixedSecret(value,
|
|
|
58
75
|
expected: `${API_KEY_SECRET_PREFIX} or ${MANAGEMENT_KEY_SECRET_PREFIX} followed by 43 base64url characters`,
|
|
59
76
|
toJsonSchema: () => ({})
|
|
60
77
|
})).annotate({ description: `The key secret, returned once at creation: \`${API_KEY_SECRET_PREFIX}\` for an API key or \`${MANAGEMENT_KEY_SECRET_PREFIX}\` for a management key, followed by 32 random bytes as 43 unpadded base64url characters.` });
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
78
|
+
const MICRO_USD_PER_DOLLAR = 1e6;
|
|
79
|
+
const CREDIT_PURCHASE_MIN_MICRO_USD = 25 * MICRO_USD_PER_DOLLAR;
|
|
80
|
+
const CREDIT_PURCHASE_MAX_MICRO_USD = 1e3 * MICRO_USD_PER_DOLLAR;
|
|
81
|
+
const CARD_FEE_TERMS = "2.9% plus 30 cents";
|
|
82
|
+
const Plan = Literals(["free", "pro"]).annotate({
|
|
83
|
+
description: "The organization plan: `pro` while its Pro subscription is active, trialing, or past due, otherwise `free`.",
|
|
84
|
+
identifier: "Plan"
|
|
85
|
+
});
|
|
86
|
+
const ProInterval = Literals([
|
|
87
|
+
"day",
|
|
88
|
+
"month",
|
|
89
|
+
"week",
|
|
90
|
+
"year"
|
|
91
|
+
]).annotate({
|
|
92
|
+
description: "How often the Pro fee is charged.",
|
|
93
|
+
identifier: "ProInterval"
|
|
94
|
+
});
|
|
95
|
+
const ProPrice = Struct({
|
|
96
|
+
interval: ProInterval,
|
|
97
|
+
micro_usd: MicroUsd
|
|
98
|
+
}).annotate({
|
|
99
|
+
description: "The fixed Pro fee for each billing interval.",
|
|
100
|
+
identifier: "ProPrice"
|
|
101
|
+
});
|
|
102
|
+
const Billing = Struct({
|
|
103
|
+
credit_balance_micro_usd: Int.annotate({ description: "Credits bought, less refunds and open disputes. A refund after use can take it below zero." }),
|
|
104
|
+
plan: Plan,
|
|
105
|
+
pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
|
|
106
|
+
}).annotate({ identifier: "Billing" });
|
|
107
|
+
const CreditTerms = Struct({
|
|
108
|
+
fee_fixed_micro_usd: MicroUsd.annotate({ description: "The fixed part of the processing fee that comes out of each credit purchase." }),
|
|
109
|
+
fee_rate_basis_points: Natural.annotate({ description: "The part of the processing fee that grows with the payment, in basis points of it, rounded to the cent: 290 is 2.9%." }),
|
|
110
|
+
max_micro_usd: MicroUsd.annotate({ description: "The largest credit purchase, in whole US dollars." }),
|
|
111
|
+
min_micro_usd: MicroUsd.annotate({ description: "The smallest credit purchase, in whole US dollars." })
|
|
112
|
+
}).annotate({
|
|
113
|
+
description: "How credits are bought: a payment in whole US dollars between the two bounds adds credit equal to the payment less the processing fee, spent at each provider list price.",
|
|
114
|
+
identifier: "CreditTerms"
|
|
115
|
+
});
|
|
116
|
+
const Pricing = Struct({
|
|
117
|
+
credits: CreditTerms,
|
|
118
|
+
pro_price: NullOr(ProPrice).annotate({ description: "The Pro price, or null while Pro is not on sale." })
|
|
119
|
+
}).annotate({
|
|
120
|
+
description: "The public prices: the Pro price for one organization and the terms of a credit purchase.",
|
|
121
|
+
identifier: "Pricing"
|
|
122
|
+
});
|
|
123
|
+
Struct({ amount_micro_usd: MicroUsd.check(isMultipleOf(MICRO_USD_PER_DOLLAR), isBetween({
|
|
124
|
+
maximum: CREDIT_PURCHASE_MAX_MICRO_USD,
|
|
125
|
+
minimum: CREDIT_PURCHASE_MIN_MICRO_USD
|
|
126
|
+
})).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" });
|
|
127
|
+
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" });
|
|
84
128
|
const StandardSize = NonEmptyString.annotate({
|
|
85
129
|
description: "A standard size named `<vCPU>x<memory GiB>`, such as `1x2`, `2x4`, `4x8`, or `8x16`. The API adds sizes over time.",
|
|
86
|
-
examples:
|
|
130
|
+
examples: [
|
|
131
|
+
{
|
|
132
|
+
memory_mib: 2048,
|
|
133
|
+
name: "1x2",
|
|
134
|
+
vcpu: 1
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
memory_mib: 4096,
|
|
138
|
+
name: "2x4",
|
|
139
|
+
vcpu: 2
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
memory_mib: 8192,
|
|
143
|
+
name: "4x8",
|
|
144
|
+
vcpu: 4
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
memory_mib: 16384,
|
|
148
|
+
name: "8x16",
|
|
149
|
+
vcpu: 8
|
|
150
|
+
}
|
|
151
|
+
].map(({ name }) => name),
|
|
87
152
|
identifier: "StandardSize"
|
|
88
153
|
});
|
|
89
154
|
const ProviderSort = Literals([
|
|
@@ -91,69 +156,86 @@ const ProviderSort = Literals([
|
|
|
91
156
|
"price",
|
|
92
157
|
"uptime"
|
|
93
158
|
]).annotate({
|
|
94
|
-
description: "Candidate order: `price` by list price, `latency` by measured create latency, and `uptime` by uptime over the last 15 minutes.",
|
|
159
|
+
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
160
|
identifier: "ProviderSort"
|
|
96
161
|
});
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
suffix: "most-reliable"
|
|
109
|
-
}
|
|
110
|
-
];
|
|
111
|
-
const SIZE_NAMES = STANDARD_SIZES.flatMap((size) => [{
|
|
112
|
-
name: size.name,
|
|
113
|
-
size,
|
|
114
|
-
sort: null
|
|
115
|
-
}, ...ROUTING_SUFFIXES.map(({ sort, suffix }) => ({
|
|
116
|
-
name: `${size.name}:${suffix}`,
|
|
117
|
-
size,
|
|
118
|
-
sort
|
|
119
|
-
}))]);
|
|
120
|
-
const isPositiveInteger = (text) => {
|
|
162
|
+
const ROUTER = "sandcovery";
|
|
163
|
+
const DEFAULT_SLUG = `${ROUTER}/2x4`;
|
|
164
|
+
const MIB_PER_GIB = 1024;
|
|
165
|
+
const ANY = "n";
|
|
166
|
+
const vcpusOf = (text) => {
|
|
167
|
+
if (text === ANY) return null;
|
|
168
|
+
const value = Number(text);
|
|
169
|
+
return Number.isSafeInteger(value) && value > 0 && String(value) === text ? value : void 0;
|
|
170
|
+
};
|
|
171
|
+
const memoryGibOf = (text) => {
|
|
172
|
+
if (text === ANY) return null;
|
|
121
173
|
const value = Number(text);
|
|
122
|
-
return
|
|
174
|
+
return String(value) === text && value > 0 && Number.isSafeInteger(value * MIB_PER_GIB) ? value : void 0;
|
|
123
175
|
};
|
|
124
|
-
const
|
|
125
|
-
const [
|
|
126
|
-
const
|
|
127
|
-
|
|
176
|
+
const parseSlug = (text) => {
|
|
177
|
+
const [provider = "", size = "", ...extraPaths] = text.split("/");
|
|
178
|
+
const [dimensions = "", suffix, ...extraSuffixes] = size.split(":");
|
|
179
|
+
const [vcpuText = "", memoryText = "", ...extraParts] = dimensions.split("x");
|
|
180
|
+
if (extraPaths.length + extraSuffixes.length + extraParts.length > 0 || suffix === "" || !isProviderName(provider)) return;
|
|
181
|
+
const vcpus = vcpusOf(vcpuText);
|
|
182
|
+
const memoryGib = memoryGibOf(memoryText);
|
|
183
|
+
return vcpus === void 0 || memoryGib === void 0 ? void 0 : {
|
|
184
|
+
memoryGib,
|
|
185
|
+
provider,
|
|
186
|
+
suffix: suffix ?? null,
|
|
187
|
+
vcpus
|
|
188
|
+
};
|
|
128
189
|
};
|
|
129
|
-
const
|
|
130
|
-
|
|
190
|
+
const SLUG_EXAMPLES = [
|
|
191
|
+
`${ROUTER}/2x4`,
|
|
192
|
+
`${ROUTER}/2x4:cheapest`,
|
|
193
|
+
`${ROUTER}/nx16:cheapest`,
|
|
194
|
+
`${ROUTER}/2xn:fastest`,
|
|
195
|
+
`${ROUTER}/nxn:most-reliable`,
|
|
196
|
+
"boat/2x4",
|
|
197
|
+
"e2b/2x0.5"
|
|
198
|
+
];
|
|
199
|
+
const Slug = String$1.check(makeFilter((text) => parseSlug(text) !== void 0, {
|
|
200
|
+
expected: "<provider>/<vcpu>x<memory_gib>, optionally followed by a routing suffix",
|
|
131
201
|
toJsonSchema: () => ({ minLength: 1 })
|
|
132
202
|
})).annotate({
|
|
133
|
-
description:
|
|
134
|
-
examples:
|
|
135
|
-
identifier: "
|
|
203
|
+
description: `A provider and size, written \`<provider>/<vcpu>x<memory_gib>\` and optionally followed by a routing suffix, in the shape of OpenRouter model slugs. A provider name such as \`boat\` or \`e2b\` pins that provider, and \`${ROUTER}\` routes across every candidate provider. \`2x4\` is 2 vCPU and 4 GiB, and memory may be any whole number of MiB written in GiB, such as \`2x0.5\` or \`2x1.5\`. Either number may be \`n\`, meaning any value: \`nx16\` is any vCPU count with 16 GiB, \`2xn\` is 2 vCPU with any memory, and \`nxn\` is any size, and each provider then runs its cheapest size that matches. \`:cheapest\` sorts candidates by list price, \`:fastest\` by measured create latency, and \`:most-reliable\` by uptime over the last 15 minutes, or over a provider's own probe interval where it is probed less often. A slug with no suffix routes as \`:cheapest\`. A malformed slug or an unknown suffix answers 400 \`invalid_request\`, and a slug that no candidate provider can run answers 422 \`unsupported\`, listing slugs that would run as \`options\`.`,
|
|
204
|
+
examples: SLUG_EXAMPLES,
|
|
205
|
+
identifier: "Slug"
|
|
136
206
|
});
|
|
207
|
+
const ROUTING_FIELDS_TEXT = `\`slug\` is the provider and size to run, as OpenRouter takes \`model\`, and \`slugs\` lists slugs to try in order, as OpenRouter takes \`models\`. With both, \`slug\` is tried first. With neither, the slug is \`${DEFAULT_SLUG}\`.`;
|
|
208
|
+
const RoutingFields = {
|
|
209
|
+
slug: optionalKey(Slug),
|
|
210
|
+
slugs: optionalKey(ArraySchema(Slug).check(isMinLength(1), isMaxLength(8)).annotate({ description: `Slugs to try in order, from 1 to ${String(8)}, as OpenRouter takes \`models\`. Within a \`${ROUTER}/\` slug, a failed create (capacity, quota, a provider 5xx, or a timeout) first falls back across that slug's candidates, then the create moves to the next slug. A provider is tried at most once a create, at the size of the first slug that reaches it.` }))
|
|
211
|
+
};
|
|
137
212
|
const ProviderPreferences = Struct({
|
|
138
|
-
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." })),
|
|
213
|
+
allow_fallbacks: optionalKey(Boolean.annotate({ description: "Whether a failed create (capacity, quota, a provider 5xx, or a timeout) moves to the next candidate of the same slug. Defaults to true. With false, each slug tries only its first candidate, and the create still moves on to the next slug." })),
|
|
139
214
|
ignore: optionalKey(ArraySchema(Provider).annotate({ description: "Providers never to route to." })),
|
|
140
215
|
only: optionalKey(ArraySchema(Provider).annotate({ description: "The only providers to route to." })),
|
|
141
|
-
order: optionalKey(ArraySchema(Provider).annotate({ description:
|
|
216
|
+
order: optionalKey(ArraySchema(Provider).annotate({ description: `Providers a \`${ROUTER}/\` slug tries first, in this order, before its remaining candidates in sorted order.` })),
|
|
142
217
|
sort: optionalKey(ProviderSort)
|
|
143
218
|
}).annotate({
|
|
144
|
-
description:
|
|
219
|
+
description: `Routing preferences in the shape of OpenRouter provider preferences, applied to every slug: \`only\`, \`ignore\`, and the API key's provider allowlist filter each slug's candidates. A slug's suffix sets \`sort\` for that slug, and a slug whose suffix disagrees with \`sort\` answers 400 \`invalid_request\`.`,
|
|
145
220
|
identifier: "ProviderPreferences"
|
|
146
221
|
});
|
|
147
222
|
// ../sandcovery-contract/src/sandbox.ts
|
|
148
223
|
const MAX_TTL_SECONDS = 86400;
|
|
149
|
-
const MIN_TTL_SECONDS = 60;
|
|
150
224
|
const MAX_PORT = 65535;
|
|
151
225
|
const MAX_PORTS = 8;
|
|
226
|
+
const MAX_GPUS = 8;
|
|
152
227
|
const between = (minimum, maximum) => Int.check(isBetween({
|
|
153
228
|
maximum,
|
|
154
229
|
minimum
|
|
155
230
|
}));
|
|
156
231
|
const Port = between(1, MAX_PORT);
|
|
232
|
+
const Gpu = Struct({
|
|
233
|
+
count: between(1, MAX_GPUS).annotate({ description: "How many GPUs of `type` the sandbox gets, from 1 to 8." }),
|
|
234
|
+
type: GpuType
|
|
235
|
+
}).annotate({
|
|
236
|
+
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.",
|
|
237
|
+
identifier: "Gpu"
|
|
238
|
+
});
|
|
157
239
|
const EnvironmentVariables = Record(NonEmptyString, String$1).annotate({ description: "Environment variables by name. Sandcovery passes them to the provider and never returns them." });
|
|
158
240
|
const EgressPolicy = Union([
|
|
159
241
|
Struct({ mode: Literal("allow_all") }),
|
|
@@ -170,21 +252,20 @@ const SandboxSpec = Struct({
|
|
|
170
252
|
disk_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(1024)).annotate({ description: "Disk size in MiB. Defaults to the provider default." })),
|
|
171
253
|
egress: optionalKey(EgressPolicy),
|
|
172
254
|
env: optionalKey(EnvironmentVariables),
|
|
173
|
-
|
|
255
|
+
gpu: optionalKey(Gpu),
|
|
256
|
+
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
257
|
image: optionalKey(NonEmptyString.annotate({ description: "An OCI image reference. Unset means the provider's default Linux image." })),
|
|
175
|
-
memory_mib: optionalKey(Int.check(isGreaterThanOrEqualTo(256)).annotate({ description: "Memory in MiB. Set with `vcpu`, and never with `size`." })),
|
|
176
258
|
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
259
|
region: optionalKey(Region),
|
|
178
|
-
|
|
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." })),
|
|
180
|
-
vcpu: optionalKey(between(1, 64).annotate({ description: "vCPU count. Set with `memory_mib`, and never with `size`." }))
|
|
260
|
+
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." }))
|
|
181
261
|
});
|
|
182
262
|
const CreateSandboxRequest = Struct({
|
|
183
263
|
...SandboxSpec.fields,
|
|
264
|
+
...RoutingFields,
|
|
184
265
|
provider: optionalKey(ProviderPreferences),
|
|
185
266
|
snapshot_id: optionalKey(SnapshotId.annotate({ description: "A snapshot to start from. The sandbox runs on the snapshot's provider." }))
|
|
186
267
|
}).annotate({
|
|
187
|
-
description:
|
|
268
|
+
description: `A sandbox spec, the slug or slugs to run it on, and routing preferences. ${ROUTING_FIELDS_TEXT} A spec option that no candidate provider can enforce answers 422 \`unsupported\` and is never ignored.`,
|
|
188
269
|
identifier: "CreateSandboxRequest"
|
|
189
270
|
});
|
|
190
271
|
const CreateAttempt = Struct({
|
|
@@ -231,7 +312,7 @@ const SandboxCost = Struct({
|
|
|
231
312
|
identifier: "SandboxCost"
|
|
232
313
|
});
|
|
233
314
|
const Sandbox = Struct({
|
|
234
|
-
api_key_id: ApiKeyId.annotate({ description: "The API key that created the sandbox." }),
|
|
315
|
+
api_key_id: NullOr(ApiKeyId).annotate({ description: "The API key that created the sandbox, or null when an organization owner or admin created it while signed in, or their agent did on their session." }),
|
|
235
316
|
attempts: ArraySchema(CreateAttempt),
|
|
236
317
|
cost: SandboxCost,
|
|
237
318
|
created_at: Timestamp,
|
|
@@ -240,19 +321,20 @@ const Sandbox = Struct({
|
|
|
240
321
|
end_reason: NullOr(SandboxEndReason),
|
|
241
322
|
ended_at: NullOr(Timestamp),
|
|
242
323
|
expires_at: Timestamp,
|
|
324
|
+
gpu: NullOr(Gpu),
|
|
243
325
|
id: SandboxId,
|
|
244
326
|
idle_timeout_seconds: NullOr(Natural),
|
|
245
327
|
image: NullOr(String$1),
|
|
246
|
-
memory_mib: Natural,
|
|
328
|
+
memory_mib: Natural.annotate({ description: "Memory of the bound size, or of the first candidate's size while the sandbox is creating or after every create attempt failed." }),
|
|
247
329
|
ports: ArraySchema(Port),
|
|
248
330
|
provider: NullOr(Provider).annotate({ description: "The provider the sandbox is bound to, or null while it is creating or when every create attempt failed." }),
|
|
249
331
|
provider_sandbox_id: NullOr(String$1),
|
|
250
332
|
region: NullOr(Region),
|
|
251
|
-
|
|
333
|
+
slug: NullOr(Slug).annotate({ description: "The provider and size the sandbox runs on, such as `boat/2x4`, as OpenRouter answers the `model` it used, or null while it is creating or when every create attempt failed." }),
|
|
252
334
|
started_at: NullOr(Timestamp).annotate({ description: "When the provider reported the sandbox running." }),
|
|
253
335
|
status: SandboxStatus,
|
|
254
336
|
ttl_seconds: Natural,
|
|
255
|
-
vcpu: Natural
|
|
337
|
+
vcpu: Natural.annotate({ description: "vCPU count of the bound size, or of the first candidate's size while the sandbox is creating or after every create attempt failed." })
|
|
256
338
|
}).annotate({
|
|
257
339
|
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.",
|
|
258
340
|
identifier: "Sandbox"
|
|
@@ -279,7 +361,6 @@ const PortPreview = Struct({
|
|
|
279
361
|
description: "A provider URL that reaches a port inside the sandbox.",
|
|
280
362
|
identifier: "PortPreview"
|
|
281
363
|
});
|
|
282
|
-
// ../sandcovery-contract/src/keys.ts
|
|
283
364
|
const KeyName = NonEmptyString.check(isMaxLength(64));
|
|
284
365
|
const PositiveInt = Int.check(isGreaterThanOrEqualTo(1));
|
|
285
366
|
const KeyKind = Literals(["api", "management"]).annotate({
|
|
@@ -329,7 +410,7 @@ const KeyList = Struct({ data: ArraySchema(Key) }).annotate({ identifier: "KeyLi
|
|
|
329
410
|
const CreateKeyRequest = Struct({
|
|
330
411
|
allowed_providers: optionalKey(keyPolicyFields.allowed_providers),
|
|
331
412
|
expires_at: optionalKey(NullOr(Timestamp)),
|
|
332
|
-
kind: optionalKey(KeyKind).annotate({ description: "Defaults to `api`. Only a signed-in owner
|
|
413
|
+
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
414
|
max_concurrent_sandboxes: optionalKey(keyPolicyFields.max_concurrent_sandboxes),
|
|
334
415
|
max_ttl_seconds: optionalKey(keyPolicyFields.max_ttl_seconds),
|
|
335
416
|
name: KeyName,
|
|
@@ -353,4 +434,4 @@ const CreatedKey = Struct({
|
|
|
353
434
|
// ../sandcovery-contract/src/origin.ts
|
|
354
435
|
const SANDCOVERY_ORIGIN = "https://www.sandcovery.com";
|
|
355
436
|
const API_PREFIX = "/api/v1";
|
|
356
|
-
export {
|
|
437
|
+
export { CreditCheckout as A, Provider as B, RoutingFields as C, CARD_FEE_TERMS as D, Billing as E, CredentialId as F, SandboxId as H, GpuType as I, KeyId as L, Pricing as M, ApiKeyId as N, CREDIT_PURCHASE_MAX_MICRO_USD as O, CiJobId as P, KeySecret as R, ROUTING_FIELDS_TEXT as S, StandardSize as T, Timestamp as U, Region as V, SandboxStatus as _, Key as a, ProviderPreferences as b, SpendLimit as c, CreateSandboxRequest as d, Port as f, SandboxSpec as g, SandboxList as h, CreatedKey as i, MICRO_USD_PER_DOLLAR as j, CREDIT_PURCHASE_MIN_MICRO_USD as k, UpdateKeyRequest as l, Sandbox as m, SANDCOVERY_ORIGIN as n, KeyKind as o, PortPreview as p, CreateKeyRequest as r, KeyList as s, API_PREFIX as t, CreateAttempt as u, Snapshot as v, Slug as w, ProviderSort as x, DEFAULT_SLUG as y, MicroUsd as z };
|
|
@@ -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 {
|
|
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 };
|