@sandboxrouter/sdk 0.12.0 → 0.13.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 +11 -6
- package/dist/agent-bench.d.ts +12 -1
- package/dist/agent-bench.js +46 -7
- package/dist/bench.d.ts +13 -1
- package/dist/bench.js +39 -17
- package/dist/burst.d.ts +10 -0
- package/dist/burst.js +21 -10
- package/dist/catalog.d.ts +11 -0
- package/dist/catalog.js +15 -4
- package/dist/cli.js +44 -36
- package/dist/computers.d.ts +2 -2
- package/dist/leaderboard.d.ts +30 -8
- package/dist/leaderboard.js +89 -50
- package/dist/price-index.d.ts +3 -3
- package/dist/price-index.js +3 -3
- package/dist/providers/docker.js +13 -3
- package/dist/providers/limrun.d.ts +1 -8
- package/dist/providers/limrun.js +0 -1
- package/dist/providers/mobilerun.d.ts +1 -5
- package/dist/providers/mobilerun.js +18 -26
- package/dist/providers/vercel.js +2 -2
- package/dist/published.js +20 -1619
- package/dist/recommend.d.ts +17 -0
- package/dist/recommend.js +17 -11
- package/dist/results.js +42 -2
- package/dist/router.d.ts +14 -3
- package/dist/router.js +19 -6
- package/dist/task.d.ts +2 -1
- package/dist/task.js +38 -19
- package/dist/types.d.ts +4 -3
- package/package.json +18 -3
package/README.md
CHANGED
|
@@ -2,15 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
**One API for every sandbox.** A free, open-source router for the places an AI agent can run code: Agent37, Alibaba Cloud, AWS (Bedrock AgentCore and Lambda MicroVMs), Azure Container Apps, Beam, Blaxel, Boat, Cloudflare, CodeSandbox, Daytona, Dedalus Machines, Deno, E2B, exe.dev, Fly.io Sprites, Freestyle, HOPX, InstaBox, Koyeb, Maritime, Modal, Morph, Northflank, Novita, OpenScale, Runloop, Sail, Superserve, Tensorlake, Upstash Box and Vercel, plus Docker on your own machine. It picks a provider by price, speed or capability, and falls back to the next one when a provider is down or rate-limited.
|
|
4
4
|
|
|
5
|
+
E2B quickstart (Node 22.19+ and an E2B API key):
|
|
6
|
+
|
|
5
7
|
```bash
|
|
6
|
-
npm i @sandboxrouter/sdk
|
|
8
|
+
npm i @sandboxrouter/sdk e2b
|
|
9
|
+
export E2B_API_KEY=... # your E2B API key
|
|
7
10
|
```
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
Save as `agent.mjs` and run `node agent.mjs`:
|
|
13
|
+
|
|
14
|
+
```js
|
|
10
15
|
import { Router } from "@sandboxrouter/sdk";
|
|
11
16
|
|
|
12
|
-
const router = new Router();
|
|
13
|
-
const sbx = await router.create(
|
|
17
|
+
const router = new Router();
|
|
18
|
+
const sbx = await router.create({ timeoutMinutes: 10 }, { provider: "e2b" });
|
|
14
19
|
try {
|
|
15
20
|
const r = await sbx.exec("python3 -c 'print(6*7)'");
|
|
16
21
|
console.log(r.stdout, "ran on", sbx.provider);
|
|
@@ -19,9 +24,9 @@ try {
|
|
|
19
24
|
}
|
|
20
25
|
```
|
|
21
26
|
|
|
22
|
-
|
|
27
|
+
The SDK uses ES modules and runs on Node 20+. Each optional provider SDK can require a newer Node version. For TypeScript 5.2+ on Node 22+, `await using sbx = ...` also works when the compiler includes `ESNext.Disposable`. Plain JavaScript supports that syntax on Node 24+.
|
|
23
28
|
|
|
24
|
-
Set the keys of the providers you use. `create()` starts the sandbox on the cheapest one that fits: list price for the size you asked for, corrected where we measured what a provider really bills. Providers within 10% of each other on price go fastest first,
|
|
29
|
+
Set the keys of the providers you use. `create()` starts the sandbox on the cheapest one that fits: list price for the size you asked for, corrected where we measured what a provider really bills. Providers within 10% of each other on estimated price go fastest first. The router uses its own timings, your benchmark file or published timings, in that order. Estimates exclude account-specific charges such as [Boat’s fees above its included start allowance](https://docs.boat.dev/limits.md#extra-starts). Providers that failed their last real-account check go last. Ties are alphabetical, and no provider pays for placement. If that provider is down, busy or out of credit, the next one takes it, and every attempt is on `sbx.attempts`. The sandbox stays on that provider until you `kill()` it.
|
|
25
30
|
|
|
26
31
|
Site and docs: [sandboxrouter.ai](https://sandboxrouter.ai) · npm: [`@sandboxrouter/sdk`](https://www.npmjs.com/package/@sandboxrouter/sdk)
|
|
27
32
|
|
package/dist/agent-bench.d.ts
CHANGED
|
@@ -8,12 +8,23 @@ import type { ProviderId } from "./types.js";
|
|
|
8
8
|
* Measures, per provider: how often the task was done right, wall time, time spent waiting on the model, the
|
|
9
9
|
* sandbox CPU used, turns, and what the sandbox was billed (start, minimum, fee, active CPU where it applies).
|
|
10
10
|
*/
|
|
11
|
-
export declare const AGENT_TASK_VERSION = "gemini-primes-
|
|
11
|
+
export declare const AGENT_TASK_VERSION = "gemini-primes-v2";
|
|
12
12
|
export declare const AGENT_TASK: string;
|
|
13
|
+
/** Compare the saved file and the script's output to an independently computed prime sequence. */
|
|
14
|
+
export declare const AGENT_VERIFY = "python3 - <<'SRVERIFY'\nimport pathlib, re, subprocess, sys\n\nwork = pathlib.Path(\"/tmp/work\")\nflags = bytearray([1]) * 48612\nflags[:2] = b\"\\x00\\x00\"\nfor i in range(2, 221):\n if flags[i]:\n flags[i * i::i] = bytes(len(flags[i * i::i]))\nexpected = [i for i, prime in enumerate(flags) if prime]\nif len(expected) != 5000:\n sys.exit(\"invalid verification fixture\")\n\ndef valid_file():\n file = work / \"primes.txt\"\n if not file.is_file() or file.stat().st_size > 64000:\n return False\n return file.read_text().splitlines() == [str(p) for p in expected]\n\nif not valid_file():\n sys.exit(\"incorrect saved prime sequence\")\n(work / \"primes.txt\").unlink()\nresult = subprocess.run(\n [sys.executable, str(work / \"primes.py\")], cwd=work,\n capture_output=True, text=True, timeout=60, check=True,\n)\nif str(sum(expected)) not in re.findall(r\"[0-9]+\", result.stdout) or not valid_file():\n sys.exit(\"incorrect regenerated prime sequence or sum\")\nprint(\"VERIFIED\")\nSRVERIFY";
|
|
13
15
|
export interface AgentRow {
|
|
14
16
|
provider: ProviderId;
|
|
15
17
|
/** Sessions that started (the ones refused for an account limit are counted in `limited` instead). */
|
|
16
18
|
runs: number;
|
|
19
|
+
/** Requested sessions, including refused requests. */
|
|
20
|
+
requested?: number;
|
|
21
|
+
/** Sessions whose sandbox started, whether or not the task passed. */
|
|
22
|
+
started?: number;
|
|
23
|
+
/** Nominal router shape for this provider. */
|
|
24
|
+
size?: {
|
|
25
|
+
vcpu: number;
|
|
26
|
+
memoryGb: number;
|
|
27
|
+
};
|
|
17
28
|
/** Sessions the provider refused to start for a limit or quota on the benchmarking account. */
|
|
18
29
|
limited?: number;
|
|
19
30
|
/** Runs where the task checked out. */
|
package/dist/agent-bench.js
CHANGED
|
@@ -12,15 +12,44 @@ import { LIMITED_ERROR } from "./bench.js";
|
|
|
12
12
|
* Measures, per provider: how often the task was done right, wall time, time spent waiting on the model, the
|
|
13
13
|
* sandbox CPU used, turns, and what the sandbox was billed (start, minimum, fee, active CPU where it applies).
|
|
14
14
|
*/
|
|
15
|
-
export const AGENT_TASK_VERSION = "gemini-primes-
|
|
15
|
+
export const AGENT_TASK_VERSION = "gemini-primes-v2";
|
|
16
16
|
export const AGENT_TASK = [
|
|
17
17
|
"You are working in a fresh Linux sandbox through a tool that runs shell commands.",
|
|
18
18
|
"Write /tmp/work/primes.py: it computes the first 5000 prime numbers without using the network, writes them to",
|
|
19
19
|
"/tmp/work/primes.txt one per line, and prints their sum. Run it and fix it until it works.",
|
|
20
20
|
"When it works, reply with DONE and the sum.",
|
|
21
21
|
].join(" ");
|
|
22
|
-
/**
|
|
23
|
-
const
|
|
22
|
+
/** Compare the saved file and the script's output to an independently computed prime sequence. */
|
|
23
|
+
export const AGENT_VERIFY = `python3 - <<'SRVERIFY'
|
|
24
|
+
import pathlib, re, subprocess, sys
|
|
25
|
+
|
|
26
|
+
work = pathlib.Path("/tmp/work")
|
|
27
|
+
flags = bytearray([1]) * 48612
|
|
28
|
+
flags[:2] = b"\\x00\\x00"
|
|
29
|
+
for i in range(2, 221):
|
|
30
|
+
if flags[i]:
|
|
31
|
+
flags[i * i::i] = bytes(len(flags[i * i::i]))
|
|
32
|
+
expected = [i for i, prime in enumerate(flags) if prime]
|
|
33
|
+
if len(expected) != 5000:
|
|
34
|
+
sys.exit("invalid verification fixture")
|
|
35
|
+
|
|
36
|
+
def valid_file():
|
|
37
|
+
file = work / "primes.txt"
|
|
38
|
+
if not file.is_file() or file.stat().st_size > 64000:
|
|
39
|
+
return False
|
|
40
|
+
return file.read_text().splitlines() == [str(p) for p in expected]
|
|
41
|
+
|
|
42
|
+
if not valid_file():
|
|
43
|
+
sys.exit("incorrect saved prime sequence")
|
|
44
|
+
(work / "primes.txt").unlink()
|
|
45
|
+
result = subprocess.run(
|
|
46
|
+
[sys.executable, str(work / "primes.py")], cwd=work,
|
|
47
|
+
capture_output=True, text=True, timeout=60, check=True,
|
|
48
|
+
)
|
|
49
|
+
if str(sum(expected)) not in re.findall(r"[0-9]+", result.stdout) or not valid_file():
|
|
50
|
+
sys.exit("incorrect regenerated prime sequence or sum")
|
|
51
|
+
print("VERIFIED")
|
|
52
|
+
SRVERIFY`;
|
|
24
53
|
const STAT = `grep '^cpu' /proc/stat 2> /dev/null | tr '\\n' ';'`;
|
|
25
54
|
async function gemini(model, apiKey, contents) {
|
|
26
55
|
const res = await fetch(`https://generativelanguage.googleapis.com/v1beta/models/${model}:generateContent`, {
|
|
@@ -49,11 +78,12 @@ async function gemini(model, apiKey, contents) {
|
|
|
49
78
|
return { content: j.candidates?.[0]?.content ?? { role: "model", parts: [] }, tokens: j.usageMetadata?.totalTokenCount ?? 0 };
|
|
50
79
|
}
|
|
51
80
|
/** One agent session on one provider. */
|
|
52
|
-
async function session(router, id, model, apiKey, maxTurns) {
|
|
81
|
+
async function session(router, id, model, apiKey, maxTurns, onStarted) {
|
|
53
82
|
const spec = { vcpu: DEFAULT_VCPU, memoryGb: DEFAULT_MEMORY_GB, timeoutMinutes: 15, cpuUtilization: 0.1 };
|
|
54
83
|
const sized = { ...spec, ...fixedSize(id, spec) };
|
|
55
84
|
const t0 = performance.now();
|
|
56
85
|
const box = await router.create(sized, { provider: id, fallback: false, deadlineSeconds: 180 });
|
|
86
|
+
onStarted();
|
|
57
87
|
const createMs = performance.now() - t0;
|
|
58
88
|
try {
|
|
59
89
|
await box.exec("mkdir -p /tmp/work");
|
|
@@ -90,7 +120,8 @@ async function session(router, id, model, apiKey, maxTurns) {
|
|
|
90
120
|
}
|
|
91
121
|
const sessionMs = performance.now() - s0;
|
|
92
122
|
const b = (await box.exec(STAT)).stdout;
|
|
93
|
-
const
|
|
123
|
+
const verification = await box.exec(AGENT_VERIFY, { timeoutSeconds: 120 });
|
|
124
|
+
const verified = verification.exitCode === 0 && verification.stdout.trim() === "VERIFIED";
|
|
94
125
|
const cpu = busyMs(a, b);
|
|
95
126
|
const plausible = cpu !== undefined && cpu <= sized.vcpu * sessionMs * 1.1;
|
|
96
127
|
return { verified, createMs, sessionMs, modelMs, turns: turns + 1, tokens, cpuMs: plausible ? cpu : undefined, coreMs: plausible ? maxCoreMs(a, b) : undefined, spec: sized };
|
|
@@ -107,15 +138,20 @@ export async function agentBench(opts) {
|
|
|
107
138
|
const done = [];
|
|
108
139
|
let failures = 0;
|
|
109
140
|
let limited = 0;
|
|
141
|
+
let started = 0;
|
|
110
142
|
for (let i = 0; i < opts.runs; i++) {
|
|
143
|
+
let ready = false;
|
|
111
144
|
try {
|
|
112
|
-
const s = await session(router, id, opts.model, opts.apiKey, opts.maxTurns ?? 15)
|
|
145
|
+
const s = await session(router, id, opts.model, opts.apiKey, opts.maxTurns ?? 15, () => {
|
|
146
|
+
ready = true;
|
|
147
|
+
started++;
|
|
148
|
+
});
|
|
113
149
|
done.push(s);
|
|
114
150
|
log(`${id} run ${i + 1}/${opts.runs}: ${s.verified ? "done" : "not done"} in ${(s.sessionMs / 1000).toFixed(1)} s, ${s.turns} turns`);
|
|
115
151
|
}
|
|
116
152
|
catch (err) {
|
|
117
153
|
failures++;
|
|
118
|
-
if (LIMITED_ERROR.test(err.message))
|
|
154
|
+
if (!ready && LIMITED_ERROR.test(err.message))
|
|
119
155
|
limited++;
|
|
120
156
|
log(`${id} run ${i + 1}/${opts.runs} failed: ${err.message.slice(0, 160)}`);
|
|
121
157
|
}
|
|
@@ -128,6 +164,9 @@ export async function agentBench(opts) {
|
|
|
128
164
|
rows.push({
|
|
129
165
|
provider: id,
|
|
130
166
|
runs: opts.runs - limited,
|
|
167
|
+
requested: opts.runs,
|
|
168
|
+
started,
|
|
169
|
+
size,
|
|
131
170
|
...(limited ? { limited } : {}),
|
|
132
171
|
ok: ok.length,
|
|
133
172
|
medianWallMs: m(done.map((s) => s.sessionMs)),
|
package/dist/bench.d.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import { Router } from "./router.js";
|
|
1
|
+
import { Router, type Size } from "./router.js";
|
|
2
2
|
import { type TaskKind } from "./task.js";
|
|
3
3
|
import type { ProviderId, SandboxSpec } from "./types.js";
|
|
4
4
|
export interface BenchRow {
|
|
5
5
|
provider: ProviderId;
|
|
6
6
|
runs: number;
|
|
7
|
+
/** Create or first-command failures. Workload and cleanup outcomes are counted separately. */
|
|
7
8
|
failures: number;
|
|
9
|
+
/** Shape selected by the router, before any provider-side allocation. */
|
|
10
|
+
size?: Size;
|
|
8
11
|
medianCreateMs?: number;
|
|
9
12
|
medianExecMs?: number;
|
|
13
|
+
/** Paired time from request to first successful command. */
|
|
14
|
+
medianReadyMs?: number;
|
|
10
15
|
hourlyUsd: number;
|
|
11
16
|
/**
|
|
12
17
|
* Of the failures, how many the provider refused for a limit or quota on the benchmarking account (a rate limit,
|
|
13
18
|
* a concurrency or service quota): the account's plan, not the provider's reliability. Success rates leave them out.
|
|
14
19
|
*/
|
|
15
20
|
limited?: number;
|
|
21
|
+
createFailures?: number;
|
|
22
|
+
commandFailures?: number;
|
|
23
|
+
cleanupFailures?: number;
|
|
24
|
+
/** With a workload: requests whose workload finished and passed its checks. */
|
|
25
|
+
taskOk?: number;
|
|
26
|
+
/** Readiness time of the boxes where the workload succeeded. */
|
|
27
|
+
medianTaskReadyMs?: number;
|
|
16
28
|
/** With `task`: median time of the standard task (src/task.ts), and of each of its phases. */
|
|
17
29
|
medianTaskMs?: number;
|
|
18
30
|
taskPhasesMs?: Record<string, number>;
|
package/dist/bench.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CATALOG, DEFAULT_MEMORY_GB, DEFAULT_VCPU, fittingSpec, fixedSize, hourlyCost } from "./catalog.js";
|
|
2
2
|
import { loadBench, median, saveBench } from "./bench-store.js";
|
|
3
|
-
import { Router } from "./router.js";
|
|
3
|
+
import { Router, sizeOf } from "./router.js";
|
|
4
4
|
import { runTask, taskMs, taskUsd, TASKS } from "./task.js";
|
|
5
5
|
/**
|
|
6
6
|
* Cold start = time from create() call to a usable sandbox. Exec = round trip of `echo ok`.
|
|
@@ -27,10 +27,15 @@ export async function bench(opts) {
|
|
|
27
27
|
const stored = loadBench(opts.benchFile);
|
|
28
28
|
const rows = [];
|
|
29
29
|
const one = async (id) => {
|
|
30
|
+
const shape = sized(id, spec);
|
|
30
31
|
const createMs = [];
|
|
31
32
|
const execMs = [];
|
|
33
|
+
const readyMs = [];
|
|
32
34
|
const tasks = [];
|
|
33
|
-
|
|
35
|
+
const taskReadyMs = [];
|
|
36
|
+
let createFailures = 0;
|
|
37
|
+
let commandFailures = 0;
|
|
38
|
+
let cleanupFailures = 0;
|
|
34
39
|
let limited = 0;
|
|
35
40
|
let lastError;
|
|
36
41
|
for (let i = 0; i < runs; i++) {
|
|
@@ -38,17 +43,20 @@ export async function bench(opts) {
|
|
|
38
43
|
let box;
|
|
39
44
|
try {
|
|
40
45
|
const t0 = performance.now();
|
|
41
|
-
box = await router.create(
|
|
42
|
-
createMs.push(Math.round(performance.now() - t0));
|
|
46
|
+
box = await router.create(shape, { provider: id, fallback: false });
|
|
43
47
|
const t1 = performance.now();
|
|
44
48
|
const r = await box.exec("echo ok");
|
|
45
49
|
if (r.exitCode !== 0 || r.stdout.trim() !== "ok")
|
|
46
50
|
throw new Error(`echo returned ${r.exitCode}: ${r.stdout}${r.stderr}`);
|
|
47
|
-
|
|
51
|
+
const done = performance.now();
|
|
52
|
+
const took = Math.max(1, Math.round(done - t0));
|
|
53
|
+
createMs.push(Math.max(1, Math.round(t1 - t0)));
|
|
54
|
+
execMs.push(Math.max(1, Math.round(done - t1)));
|
|
55
|
+
readyMs.push(took);
|
|
48
56
|
if (kind) {
|
|
49
|
-
// A failed task doesn't fail the run: the start time still counts, the task just has no time.
|
|
50
57
|
try {
|
|
51
58
|
tasks.push(await runTask(box, kind));
|
|
59
|
+
taskReadyMs.push(took);
|
|
52
60
|
}
|
|
53
61
|
catch (err) {
|
|
54
62
|
lastError = `task: ${err.message.slice(0, 180)}`;
|
|
@@ -56,24 +64,38 @@ export async function bench(opts) {
|
|
|
56
64
|
}
|
|
57
65
|
}
|
|
58
66
|
catch (err) {
|
|
59
|
-
failures++;
|
|
60
67
|
lastError = err.message.slice(0, 200);
|
|
61
|
-
if (
|
|
62
|
-
|
|
68
|
+
if (box)
|
|
69
|
+
commandFailures++;
|
|
70
|
+
else {
|
|
71
|
+
createFailures++;
|
|
72
|
+
if (LIMITED_ERROR.test(lastError))
|
|
73
|
+
limited++;
|
|
74
|
+
}
|
|
63
75
|
}
|
|
64
76
|
finally {
|
|
65
|
-
await box?.kill().catch(() => {
|
|
77
|
+
await box?.kill().catch((err) => {
|
|
78
|
+
cleanupFailures++;
|
|
79
|
+
log(`${id} cleanup failed: ${err.message.slice(0, 180)}`);
|
|
80
|
+
});
|
|
66
81
|
}
|
|
67
82
|
}
|
|
83
|
+
const failures = createFailures + commandFailures;
|
|
68
84
|
stored[id] = { createMs, execMs, failures, at: new Date().toISOString() };
|
|
69
85
|
rows.push({
|
|
70
86
|
provider: id,
|
|
71
87
|
runs,
|
|
72
88
|
failures,
|
|
89
|
+
createFailures,
|
|
90
|
+
commandFailures,
|
|
91
|
+
cleanupFailures,
|
|
92
|
+
size: sizeOf(id, shape),
|
|
73
93
|
medianCreateMs: median(createMs),
|
|
74
94
|
medianExecMs: median(execMs),
|
|
75
|
-
|
|
95
|
+
medianReadyMs: median(readyMs),
|
|
96
|
+
hourlyUsd: hourlyCost(id, shape),
|
|
76
97
|
...(limited ? { limited } : {}),
|
|
98
|
+
...(kind ? { taskOk: tasks.length, medianTaskReadyMs: median(taskReadyMs) } : {}),
|
|
77
99
|
...(tasks.length ? taskSummary(tasks, kind) : {}),
|
|
78
100
|
lastError,
|
|
79
101
|
});
|
|
@@ -107,14 +129,14 @@ function sized(id, spec) {
|
|
|
107
129
|
export function benchMarkdown(rows) {
|
|
108
130
|
const name = (id) => CATALOG.find((c) => c.id === id).name;
|
|
109
131
|
const ms = (n) => (n === undefined ? "n/a" : `${n} ms`);
|
|
110
|
-
const task = rows.some((r) => r.
|
|
111
|
-
const cost = (r) => r.medianTaskMs !== undefined && r.
|
|
112
|
-
? `$${taskUsd(r.provider, fittingSpec(r.provider), r.
|
|
132
|
+
const task = rows.some((r) => r.taskOk !== undefined);
|
|
133
|
+
const cost = (r) => r.medianTaskMs !== undefined && r.medianTaskReadyMs !== undefined
|
|
134
|
+
? `$${taskUsd(r.provider, r.size ?? fittingSpec(r.provider), r.medianTaskReadyMs, r.medianTaskMs, r.medianTaskCpuMs, 1, false, r.medianTaskMaxCoreMs).toFixed(6)}`
|
|
113
135
|
: "n/a";
|
|
114
136
|
const lines = [
|
|
115
|
-
`| # | Provider |
|
|
116
|
-
|
|
117
|
-
...rows.map((r, i) => `| ${i + 1} | ${name(r.provider)} | ${ms(r.medianCreateMs)} | ${ms(r.medianExecMs)} |${task ? ` ${ms(r.medianTaskMs)} | ${cost(r)} |` : ""} $${r.hourlyUsd.toFixed(3)} | ${r.runs - r.failures}/${r.runs} |`),
|
|
137
|
+
`| # | Provider | Create (median) | Ready (median) | Exec round trip |${task ? " Task (median) | Est. task cost | Completed |" : ""} $/hr (list, size run) | Ready |`,
|
|
138
|
+
`|---|---|---|---|---|${task ? "---|---|---|" : ""}---|---|`,
|
|
139
|
+
...rows.map((r, i) => `| ${i + 1} | ${name(r.provider)} | ${ms(r.medianCreateMs)} | ${ms(r.medianReadyMs)} | ${ms(r.medianExecMs)} |${task ? ` ${ms(r.medianTaskMs)} | ${cost(r)} | ${r.taskOk ?? 0}/${r.runs} |` : ""} $${r.hourlyUsd.toFixed(3)} | ${r.runs - r.failures}/${r.runs}${r.limited ? ` (${r.limited} refused)` : ""} |`),
|
|
118
140
|
];
|
|
119
141
|
return lines.join("\n");
|
|
120
142
|
}
|
package/dist/burst.d.ts
CHANGED
|
@@ -14,6 +14,16 @@ export interface BurstRow {
|
|
|
14
14
|
ok: number;
|
|
15
15
|
/** Of the failures, how many the provider refused for a limit or quota on this account (429, "limit", ...). */
|
|
16
16
|
limited: number;
|
|
17
|
+
/** Shape selected by the router. Provider-side resources are not independently measured. */
|
|
18
|
+
size?: {
|
|
19
|
+
vcpu: number;
|
|
20
|
+
memoryGb: number;
|
|
21
|
+
};
|
|
22
|
+
/** Stages with a failure, with the limit refusals above included in create failures. */
|
|
23
|
+
createFailures?: number;
|
|
24
|
+
commandFailures?: number;
|
|
25
|
+
taskFailures?: number;
|
|
26
|
+
cleanupFailures?: number;
|
|
17
27
|
/** Time to interactive across the ready ones: create plus first command, from the burst's start. */
|
|
18
28
|
p50Ms?: number;
|
|
19
29
|
p95Ms?: number;
|
package/dist/burst.js
CHANGED
|
@@ -25,42 +25,53 @@ export async function burst(opts) {
|
|
|
25
25
|
log(`${id}: ${opts.n} at once${kind ? `, each running the ${kind} job` : ""}`);
|
|
26
26
|
const spec = { ...base, ...fixedSize(id, base) };
|
|
27
27
|
const t0 = performance.now();
|
|
28
|
+
let cleanupFailures = 0;
|
|
28
29
|
const results = await Promise.all(Array.from({ length: opts.n }, async () => {
|
|
29
30
|
let box;
|
|
31
|
+
let stage = "create";
|
|
30
32
|
try {
|
|
31
33
|
box = await router.create(spec, { provider: id, fallback: false, deadlineSeconds: 240 });
|
|
32
|
-
|
|
34
|
+
stage = "command";
|
|
33
35
|
const r = await box.exec("echo ok");
|
|
34
36
|
if (r.exitCode !== 0 || r.stdout.trim() !== "ok")
|
|
35
37
|
throw new Error(`echo returned ${r.exitCode}`);
|
|
36
38
|
const tti = performance.now() - t0;
|
|
39
|
+
stage = "task";
|
|
37
40
|
const job = kind ? await runTask(box, kind) : undefined;
|
|
38
|
-
return { ok: true, tti,
|
|
41
|
+
return { ok: true, tti, job, done: performance.now() - t0 };
|
|
39
42
|
}
|
|
40
43
|
catch (err) {
|
|
41
|
-
return { ok: false, error: err.message, done: performance.now() - t0 };
|
|
44
|
+
return { ok: false, stage, error: err.message, done: performance.now() - t0 };
|
|
42
45
|
}
|
|
43
46
|
finally {
|
|
44
|
-
await box?.kill().catch(() => {
|
|
47
|
+
await box?.kill().catch((err) => {
|
|
48
|
+
cleanupFailures++;
|
|
49
|
+
log(`${id} cleanup failed: ${err.message.slice(0, 180)}`);
|
|
50
|
+
});
|
|
45
51
|
}
|
|
46
52
|
}));
|
|
47
53
|
const ok = results.filter((r) => r.ok);
|
|
48
|
-
const ttis = ok.map((r) => Math.round(r.tti)).sort((a, b) => a - b);
|
|
54
|
+
const ttis = ok.map((r) => Math.max(1, Math.round(r.tti))).sort((a, b) => a - b);
|
|
49
55
|
const jobs = ok.map((r) => (r.job ? taskMs(r.job.ms) : undefined)).filter((n) => n !== undefined).sort((a, b) => a - b);
|
|
50
56
|
const size = fittingSpec(id);
|
|
51
57
|
const ratio = BILLED_VS_LIST[id]?.ratio ?? 1;
|
|
52
58
|
const usd = ok.reduce((sum, r) => sum +
|
|
53
|
-
taskUsd(id, { ...size, ...(spec.cpuUtilization ? { cpuUtilization: spec.cpuUtilization } : {}) }, r.
|
|
59
|
+
taskUsd(id, { ...size, ...(spec.cpuUtilization ? { cpuUtilization: spec.cpuUtilization } : {}) }, r.tti, r.job ? taskMs(r.job.ms) : 0, r.job?.cpuMs, ratio, false, r.job?.maxCoreMs), 0);
|
|
54
60
|
const failed = results.filter((r) => !r.ok);
|
|
55
61
|
rows.push({
|
|
56
62
|
provider: id,
|
|
57
63
|
n: opts.n,
|
|
58
64
|
ok: ok.length,
|
|
59
|
-
limited: failed.filter((f) => LIMIT.test(f.error)).length,
|
|
65
|
+
limited: failed.filter((f) => f.stage === "create" && LIMIT.test(f.error)).length,
|
|
66
|
+
size,
|
|
67
|
+
createFailures: failed.filter((f) => f.stage === "create").length,
|
|
68
|
+
commandFailures: failed.filter((f) => f.stage === "command").length,
|
|
69
|
+
taskFailures: failed.filter((f) => f.stage === "task").length,
|
|
70
|
+
cleanupFailures,
|
|
60
71
|
p50Ms: percentile(ttis, 0.5),
|
|
61
72
|
p95Ms: percentile(ttis, 0.95),
|
|
62
73
|
p99Ms: percentile(ttis, 0.99),
|
|
63
|
-
wallMs: Math.round(Math.max(...results.map((r) => r.done))),
|
|
74
|
+
wallMs: Math.max(1, Math.round(Math.max(...results.map((r) => r.done)))),
|
|
64
75
|
...(jobs.length ? { jobP50Ms: percentile(jobs, 0.5) } : {}),
|
|
65
76
|
...(ok.length ? { usd: Math.round(usd * 1e6) / 1e6 } : {}),
|
|
66
77
|
});
|
|
@@ -132,15 +143,15 @@ export async function spreadBurst(opts) {
|
|
|
132
143
|
continue;
|
|
133
144
|
}
|
|
134
145
|
let box;
|
|
146
|
+
const attemptStarted = performance.now();
|
|
135
147
|
try {
|
|
136
148
|
box = await router.create({ ...base, ...fixedSize(id, base) }, { provider: id, fallback: false, deadlineSeconds: 240 });
|
|
137
|
-
const createMs = performance.now() - t0;
|
|
138
149
|
const r = await box.exec("echo ok");
|
|
139
150
|
if (r.exitCode !== 0 || r.stdout.trim() !== "ok")
|
|
140
151
|
throw new Error(`echo returned ${r.exitCode}`);
|
|
141
152
|
const s = stats.get(id);
|
|
142
153
|
s.ok++;
|
|
143
|
-
s.createMs.push(
|
|
154
|
+
s.createMs.push(performance.now() - attemptStarted);
|
|
144
155
|
if (moved)
|
|
145
156
|
s.spilledIn++;
|
|
146
157
|
return { ok: true, tti: performance.now() - t0, done: performance.now() - t0 };
|
package/dist/catalog.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export interface ProviderInfo {
|
|
|
12
12
|
incrementSeconds?: number;
|
|
13
13
|
/** A fixed charge per sandbox created, USD, on top of running time. */
|
|
14
14
|
perSandboxUsd?: number;
|
|
15
|
+
/** Start fees above a provider's included allowance. Estimates exclude these account-specific charges. */
|
|
16
|
+
conditionalStartFee?: {
|
|
17
|
+
minUsd: number;
|
|
18
|
+
maxUsd: number;
|
|
19
|
+
source: string;
|
|
20
|
+
};
|
|
15
21
|
/**
|
|
16
22
|
* Active-CPU billing only: the share of the allocated CPU billed even when idle (Tensorlake bills at
|
|
17
23
|
* least 20%). Default 0.
|
|
@@ -286,6 +292,11 @@ export declare function cloudflareInstance(vcpu: number, memoryGb: number): {
|
|
|
286
292
|
readonly vcpu: 4;
|
|
287
293
|
readonly memoryGb: 12;
|
|
288
294
|
};
|
|
295
|
+
/** The Vercel adapter allocates enough vCPUs to provide the requested RAM, with 2 GB per vCPU. */
|
|
296
|
+
export declare function vercelSandboxSize(spec: SandboxSpec): {
|
|
297
|
+
vcpu: number;
|
|
298
|
+
memoryGb: number;
|
|
299
|
+
};
|
|
289
300
|
/** How a provider turns running time into a bill: minimum, rounding and fixed per-sandbox charge. */
|
|
290
301
|
export declare function billingRules(id: ProviderId): {
|
|
291
302
|
minSeconds: number;
|
package/dist/catalog.js
CHANGED
|
@@ -226,8 +226,9 @@ ENTRIES.push({
|
|
|
226
226
|
vcpuHour: 0.009,
|
|
227
227
|
gbHour: 0,
|
|
228
228
|
note: "fixed sizes billed per second ($0.018/h for 2 vCPU / 4 GB up to $0.20/h for 16 / 32); needs a plan from $20/mo, paid back as VM time",
|
|
229
|
+
conditionalStartFee: { minUsd: 0.03, maxUsd: 0.07, source: "https://docs.boat.dev/limits.md#extra-starts" },
|
|
229
230
|
source: "https://docs.boat.dev/pricing.md",
|
|
230
|
-
checked: "2026-11-
|
|
231
|
+
checked: "2026-11-17",
|
|
231
232
|
},
|
|
232
233
|
// "pause" here is Boat's stop: the disk is kept, running processes end.
|
|
233
234
|
capabilities: ["pause", "custom-image"],
|
|
@@ -675,6 +676,13 @@ export const BOAT_SIZES = [
|
|
|
675
676
|
export function cloudflareInstance(vcpu, memoryGb) {
|
|
676
677
|
return CLOUDFLARE_INSTANCES.find((t) => t.vcpu >= vcpu && t.memoryGb >= memoryGb) ?? CLOUDFLARE_INSTANCES[CLOUDFLARE_INSTANCES.length - 1];
|
|
677
678
|
}
|
|
679
|
+
/** The Vercel adapter allocates enough vCPUs to provide the requested RAM, with 2 GB per vCPU. */
|
|
680
|
+
export function vercelSandboxSize(spec) {
|
|
681
|
+
const needed = Math.max(spec.vcpu ?? DEFAULT_VCPU, (spec.memoryGb ?? DEFAULT_MEMORY_GB) / 2);
|
|
682
|
+
// Vercel supports one vCPU or an even vCPU count.
|
|
683
|
+
const vcpu = Math.min(8, needed <= 1 ? 1 : Math.ceil(needed / 2) * 2);
|
|
684
|
+
return { vcpu, memoryGb: vcpu * 2 };
|
|
685
|
+
}
|
|
678
686
|
/** How a provider turns running time into a bill: minimum, rounding and fixed per-sandbox charge. */
|
|
679
687
|
export function billingRules(id) {
|
|
680
688
|
const p = CATALOG.find((c) => c.id === id)?.pricing;
|
|
@@ -720,9 +728,10 @@ function fullHourlyCost(id, spec = {}) {
|
|
|
720
728
|
return fixed.vcpu * pricing.vcpuHour + fixed.memoryGb * pricing.gbHour;
|
|
721
729
|
const vcpu = spec.vcpu ?? DEFAULT_VCPU;
|
|
722
730
|
let mem = spec.memoryGb ?? DEFAULT_MEMORY_GB;
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
731
|
+
if (id === "vercel") {
|
|
732
|
+
const size = vercelSandboxSize(spec);
|
|
733
|
+
return size.vcpu * pricing.vcpuHour + size.memoryGb * pricing.gbHour;
|
|
734
|
+
}
|
|
726
735
|
// Blaxel sizes by memory, about 2 GB per core.
|
|
727
736
|
if (id === "blaxel")
|
|
728
737
|
mem = Math.max(mem, vcpu * 2);
|
|
@@ -800,6 +809,8 @@ export function cpuHourlyAtFull(id, spec = {}) {
|
|
|
800
809
|
return fixed.vcpu * p.pricing.vcpuHour;
|
|
801
810
|
const vcpu = spec.vcpu ?? DEFAULT_VCPU;
|
|
802
811
|
const mem = spec.memoryGb ?? DEFAULT_MEMORY_GB;
|
|
812
|
+
if (id === "vercel")
|
|
813
|
+
return vercelSandboxSize(spec).vcpu * p.pricing.vcpuHour;
|
|
803
814
|
if (id === "cloudflare")
|
|
804
815
|
return cloudflareInstance(vcpu, mem).vcpu * p.pricing.vcpuHour;
|
|
805
816
|
if (id === "upstash")
|