@sandboxrouter/sdk 0.9.0 → 0.11.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 +4 -3
- package/dist/agent-bench.d.ts +39 -0
- package/dist/agent-bench.js +150 -0
- package/dist/bench-store.js +11 -2
- package/dist/bench.d.ts +22 -0
- package/dist/bench.js +59 -7
- package/dist/burst.d.ts +81 -0
- package/dist/burst.js +183 -0
- package/dist/catalog.d.ts +32 -0
- package/dist/catalog.js +58 -15
- package/dist/check.d.ts +2 -0
- package/dist/check.js +8 -0
- package/dist/cli.js +217 -5
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/leaderboard.d.ts +107 -2
- package/dist/leaderboard.js +175 -5
- package/dist/ledger.d.ts +2 -0
- package/dist/ledger.js +12 -1
- package/dist/price-index.d.ts +54 -0
- package/dist/price-index.js +50 -0
- package/dist/providers/beam.js +4 -0
- package/dist/providers/blaxel.js +4 -0
- package/dist/providers/boat.js +3 -1
- package/dist/providers/daytona.js +4 -0
- package/dist/providers/deno.js +4 -0
- package/dist/providers/e2b.d.ts +2 -0
- package/dist/providers/e2b.js +4 -0
- package/dist/providers/hopx.js +4 -0
- package/dist/providers/langsmith.js +4 -0
- package/dist/providers/modal.js +11 -2
- package/dist/providers/morph.js +4 -0
- package/dist/providers/runloop.js +4 -0
- package/dist/providers/sprites.js +4 -0
- package/dist/providers/tensorlake.js +4 -0
- package/dist/providers/vercel.js +4 -0
- package/dist/published.d.ts +2 -0
- package/dist/published.js +2087 -0
- package/dist/recommend.d.ts +117 -0
- package/dist/recommend.js +103 -0
- package/dist/results.js +81 -1
- package/dist/router.d.ts +50 -0
- package/dist/router.js +83 -10
- package/dist/submit.d.ts +6 -0
- package/dist/submit.js +70 -0
- package/dist/task.d.ts +80 -0
- package/dist/task.js +173 -0
- package/dist/types.d.ts +12 -0
- package/dist/util.d.ts +2 -0
- package/dist/util.js +2 -0
- package/dist/validate.d.ts +1 -1
- package/dist/validate.js +4 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
import { parseArgs } from "node:util";
|
|
3
3
|
import { mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
4
4
|
import { platform, arch } from "node:os";
|
|
5
|
-
import { bench, benchMarkdown } from "./bench.js";
|
|
5
|
+
import { ACCOUNT_ERROR, bench, benchMarkdown, NETWORK_ERROR } from "./bench.js";
|
|
6
|
+
import { TASKS } from "./task.js";
|
|
7
|
+
import { submitReport } from "./submit.js";
|
|
8
|
+
import { burst, spreadBurst } from "./burst.js";
|
|
9
|
+
import { agentBench, AGENT_TASK_VERSION } from "./agent-bench.js";
|
|
10
|
+
/** Errors that mean the network between here and the provider failed, not the provider. */
|
|
6
11
|
import { costMarkdown, costRun, settle } from "./cost.js";
|
|
7
12
|
import { checkProvider } from "./check.js";
|
|
8
13
|
import { gc, listOpen } from "./gc.js";
|
|
@@ -11,6 +16,8 @@ import { loadReports, makeReport, renderLeaderboard } from "./leaderboard.js";
|
|
|
11
16
|
import { DEFAULT_MEMORY_GB, DEFAULT_VCPU, accessLabel, benchmarksPublishable, hourlyCost, listingOrder, planLabel, unfit } from "./catalog.js";
|
|
12
17
|
import { Router, rankUsd, runHours } from "./router.js";
|
|
13
18
|
import { createApp } from "./server.js";
|
|
19
|
+
import { PUBLISHED } from "./published.js";
|
|
20
|
+
import { recommend } from "./recommend.js";
|
|
14
21
|
import { RouterError } from "./types.js";
|
|
15
22
|
const HELP = `sandboxrouter: one API for every sandbox provider
|
|
16
23
|
|
|
@@ -18,6 +25,10 @@ Usage:
|
|
|
18
25
|
sandboxrouter providers [--vcpu N] [--memory GB] price table + which keys are set
|
|
19
26
|
sandboxrouter route [spec flags] [route flags] dry run: the order providers would be tried
|
|
20
27
|
sandboxrouter quote [spec/route flags] [--json] where a create would land and what the run would cost
|
|
28
|
+
sandboxrouter recommend [--job short|long|python|download|agent|repo|start] [--count N] [--priority value|cost|speed]
|
|
29
|
+
[--reuse] [--provider a,b] [--json]
|
|
30
|
+
which provider for a job, from the published benchmarks: per successful run, with start
|
|
31
|
+
times under load for --count 10 and up; --provider limits it to the ones you name
|
|
21
32
|
sandboxrouter run "<cmd>" [spec flags] [route flags] [--keep]
|
|
22
33
|
sandboxrouter check --provider ID[,ID] | --all [--json] [--save [dir]] [--retry] [--out FILE] [--by GITHUB_USER]
|
|
23
34
|
test providers for real: exec, env, UTF-8, streaming, files, timeout, pause,
|
|
@@ -28,7 +39,20 @@ Usage:
|
|
|
28
39
|
sandboxrouter ls [--json] sandboxes this machine started that weren't killed
|
|
29
40
|
sandboxrouter gc [--all | --older-than MIN] [--dry-run]
|
|
30
41
|
kill leaked sandboxes: by default those past their lifetime
|
|
31
|
-
sandboxrouter bench [--runs 3] [--provider a,b] [--json] [--share [--label "where you ran it"] [--by GITHUB_USER]]
|
|
42
|
+
sandboxrouter bench [--runs 3] [--provider a,b] [--task [--long]] [--parallel N] [--json] [--share [--label "where you ran it"] [--by GITHUB_USER] [--submit]]
|
|
43
|
+
--task also runs the same fixed job in each sandbox (hash 512 MB on 1 core,
|
|
44
|
+
then on 2, write 256 MB to disk) and prices it with each provider's billing rules;
|
|
45
|
+
--long runs that job 40 times in a row (minutes); --job python (a pure-Python script)
|
|
46
|
+
or --job download (53 MB over HTTPS) runs another job. --parallel benches N providers at once
|
|
47
|
+
sandboxrouter burst [--n 100] [--provider a,b] [--job python|agent] [--parallel 1] [--share [--label PLACE] [--by GITHUB_USER] [--submit]]
|
|
48
|
+
start --n sandboxes at once on each provider (time to interactive at p50/p95/p99, how many
|
|
49
|
+
started); --job runs a standard job in each: python for RL-style rollouts, agent for parallel agents;
|
|
50
|
+
--spread asks for all N at once over the providers together, moving sandboxes from any provider
|
|
51
|
+
that hits a limit to the next one with room; shares follow each provider's measured capacity
|
|
52
|
+
at once (--even: equal shares)
|
|
53
|
+
sandboxrouter agentbench [--runs 5] [--provider a,b] [--model gemini-3.5-flash] [--parallel 4] [--share ...]
|
|
54
|
+
a real agent (Gemini, GEMINI_API_KEY) does the same task in a sandbox on each provider;
|
|
55
|
+
the key stays here and only its shell commands run in the sandbox
|
|
32
56
|
sandboxrouter cost run [--provider a,b] [--minutes 10] [--vcpu 2 --memory 4] [--no-load] [--out FILE] [--by GITHUB_USER]
|
|
33
57
|
start one sandbox per provider for a fixed time with every core busy, record
|
|
34
58
|
the size it really got and the list-price prediction
|
|
@@ -42,6 +66,7 @@ Usage:
|
|
|
42
66
|
sandboxrouter serve [--port 8787] [--host 127.0.0.1] [--cors https://site.example,http://localhost:3000]
|
|
43
67
|
|
|
44
68
|
Spec flags: --vcpu N --memory GB --gpu T4 --timeout MIN --expect SEC (how long you'll use it; ranks by the real bill)
|
|
69
|
+
--cpu 0.1 (how busy the CPU is, 0-1; lowers providers that bill active CPU)
|
|
45
70
|
Route flags: --provider e2b[,modal,...] --strategy balanced|verified|cheapest|fastest (default balanced: cheapest real cost, speed breaks near-ties)
|
|
46
71
|
--max-price USD (per hour, for this run: skip providers that would cost more)
|
|
47
72
|
--no-fallback --fallback-any (also on setup errors like a bad key)
|
|
@@ -57,6 +82,7 @@ const { values, positionals } = parseArgs({
|
|
|
57
82
|
gpu: { type: "string" },
|
|
58
83
|
timeout: { type: "string" },
|
|
59
84
|
expect: { type: "string" },
|
|
85
|
+
cpu: { type: "string" },
|
|
60
86
|
provider: { type: "string" },
|
|
61
87
|
strategy: { type: "string" },
|
|
62
88
|
"max-price": { type: "string" },
|
|
@@ -66,6 +92,17 @@ const { values, positionals } = parseArgs({
|
|
|
66
92
|
require: { type: "string" },
|
|
67
93
|
keep: { type: "boolean" },
|
|
68
94
|
runs: { type: "string" },
|
|
95
|
+
task: { type: "boolean" },
|
|
96
|
+
long: { type: "boolean" },
|
|
97
|
+
job: { type: "string" },
|
|
98
|
+
count: { type: "string" },
|
|
99
|
+
priority: { type: "string" },
|
|
100
|
+
reuse: { type: "boolean" },
|
|
101
|
+
spread: { type: "boolean" },
|
|
102
|
+
even: { type: "boolean" },
|
|
103
|
+
parallel: { type: "string" },
|
|
104
|
+
n: { type: "string" },
|
|
105
|
+
model: { type: "string" },
|
|
69
106
|
json: { type: "boolean" },
|
|
70
107
|
port: { type: "string" },
|
|
71
108
|
host: { type: "string" },
|
|
@@ -75,6 +112,7 @@ const { values, positionals } = parseArgs({
|
|
|
75
112
|
control: { type: "boolean" },
|
|
76
113
|
out: { type: "string" },
|
|
77
114
|
share: { type: "boolean" },
|
|
115
|
+
submit: { type: "boolean" },
|
|
78
116
|
cors: { type: "string" },
|
|
79
117
|
label: { type: "string" },
|
|
80
118
|
all: { type: "boolean" },
|
|
@@ -101,6 +139,7 @@ const spec = {
|
|
|
101
139
|
gpu: values.gpu,
|
|
102
140
|
timeoutMinutes: num(values.timeout),
|
|
103
141
|
expectedSeconds: num(values.expect),
|
|
142
|
+
cpuUtilization: num(values.cpu),
|
|
104
143
|
};
|
|
105
144
|
const providers = list(values.provider);
|
|
106
145
|
const by = (() => {
|
|
@@ -158,6 +197,31 @@ async function main() {
|
|
|
158
197
|
].join("\n"));
|
|
159
198
|
return;
|
|
160
199
|
}
|
|
200
|
+
if (cmd === "recommend") {
|
|
201
|
+
const jobs = ["start", "short", "long", "python", "download", "agent", "repo"];
|
|
202
|
+
const priorities = ["value", "cost", "speed"];
|
|
203
|
+
const job = (values.job ?? "short");
|
|
204
|
+
const priority = (values.priority ?? "value");
|
|
205
|
+
if (!jobs.includes(job))
|
|
206
|
+
throw new RouterError(`--job must be one of ${jobs.join(", ")}`);
|
|
207
|
+
if (!priorities.includes(priority))
|
|
208
|
+
throw new RouterError(`--priority must be one of ${priorities.join(", ")}`);
|
|
209
|
+
const count = values.count === undefined ? 1 : Number(values.count);
|
|
210
|
+
if (!Number.isInteger(count) || count < 1)
|
|
211
|
+
throw new RouterError("--count must be a whole number, 1 or more");
|
|
212
|
+
const r = recommend(PUBLISHED, { job, count, priority, reuse: !!values.reuse, providers: values.provider?.split(",").map((s) => s.trim()) });
|
|
213
|
+
if (values.json)
|
|
214
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
215
|
+
const secs = (s) => (s >= 10 ? `${s.toFixed(0)} s` : `${s.toFixed(1)} s`);
|
|
216
|
+
const money = (n) => (n === undefined ? "n/a" : n >= 1 ? `$${n.toFixed(2)}` : n >= 0.01 ? `$${n.toFixed(3)}` : `$${n.toPrecision(2)}`);
|
|
217
|
+
console.log(r.basis);
|
|
218
|
+
console.log(`Data through ${r.dataThrough.slice(0, 10)}; sandboxrouter.ai/methodology explains how it's measured.\n`);
|
|
219
|
+
for (const x of r.results.slice(0, 10)) {
|
|
220
|
+
const cost = job === "start" ? `${money(x.hourlyUsd)}/h` : count > 1 ? `${money(x.usdTotal)} for ${count}` : money(x.usdEach);
|
|
221
|
+
console.log(`${String(x.rank).padStart(2)}. ${x.name.padEnd(34)} ${secs(x.secondsEach).padStart(6)} ${cost.padStart(14)} value ${x.valueScore.toFixed(2)}${x.notes.length ? ` · ${x.notes.join(" · ")}` : ""}`);
|
|
222
|
+
}
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
161
225
|
if (cmd === "quote") {
|
|
162
226
|
const q = router.quote(spec, route);
|
|
163
227
|
if (values.json)
|
|
@@ -312,11 +376,135 @@ async function main() {
|
|
|
312
376
|
process.exitCode = 1;
|
|
313
377
|
return;
|
|
314
378
|
}
|
|
379
|
+
if (cmd === "agentbench") {
|
|
380
|
+
const apiKey = process.env.GEMINI_API_KEY;
|
|
381
|
+
if (!apiKey)
|
|
382
|
+
return console.error("agentbench needs GEMINI_API_KEY (it stays on this machine; only shell commands reach the sandbox)");
|
|
383
|
+
const model = values.model ?? "gemini-3.5-flash";
|
|
384
|
+
const ids = providers ?? router.registered().filter((id) => router.isConfigured(id));
|
|
385
|
+
const rows = await agentBench({ router, providers: ids, runs: num(values.runs) ?? 5, apiKey, model, parallel: num(values.parallel), onProgress: (m) => console.error(m) });
|
|
386
|
+
if (values.json)
|
|
387
|
+
return console.log(JSON.stringify(rows, null, 2));
|
|
388
|
+
console.log(`\nsandboxrouter agentbench: ${model}, ${num(values.runs) ?? 5} runs each\n`);
|
|
389
|
+
console.log("| Provider | Done right | Wall | Waiting on model | Sandbox CPU | Turns | Sandbox cost |\n|---|---|---|---|---|---|---|");
|
|
390
|
+
const s = (v) => (v === undefined ? "n/a" : `${(v / 1000).toFixed(1)} s`);
|
|
391
|
+
for (const r of rows)
|
|
392
|
+
console.log(`| ${r.provider} | ${r.ok}/${r.runs} | ${s(r.medianWallMs)} | ${s(r.medianModelMs)} | ${s(r.medianCpuMs)} | ${r.medianTurns ?? "n/a"} | ${r.medianUsd === undefined ? "n/a" : `$${r.medianUsd.toFixed(6)}`} |`);
|
|
393
|
+
if (values.share || values.submit) {
|
|
394
|
+
const started = rows.filter((r) => r.medianWallMs !== undefined);
|
|
395
|
+
if (rows.length - started.length >= 3) {
|
|
396
|
+
console.error(`\nnot writing a report: ${rows.length - started.length} providers never started a session, which looks like this machine lost its connection. Run it again.`);
|
|
397
|
+
process.exitCode = 1;
|
|
398
|
+
return;
|
|
399
|
+
}
|
|
400
|
+
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
401
|
+
const report = {
|
|
402
|
+
tool: "sandboxrouter-agent",
|
|
403
|
+
version,
|
|
404
|
+
date: new Date().toISOString(),
|
|
405
|
+
...(values.label ? { label: values.label } : {}),
|
|
406
|
+
...(by ? { by } : {}),
|
|
407
|
+
task: AGENT_TASK_VERSION,
|
|
408
|
+
model,
|
|
409
|
+
runs: num(values.runs) ?? 5,
|
|
410
|
+
node: process.version,
|
|
411
|
+
platform: `${platform()}-${arch()}`,
|
|
412
|
+
rows: started.filter((r) => benchmarksPublishable(r.provider)),
|
|
413
|
+
};
|
|
414
|
+
const file = values.out ?? `sandboxrouter-agent-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
|
|
415
|
+
writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
|
|
416
|
+
if (values.submit) {
|
|
417
|
+
try {
|
|
418
|
+
console.log(`\nwrote ${file} and opened ${submitReport(file, `Real agent (${model}) on ${report.rows.length} providers, from ${report.label ?? "an unlabelled location"}.`)}`);
|
|
419
|
+
}
|
|
420
|
+
catch (err) {
|
|
421
|
+
console.error(`\nwrote ${file}, but couldn't open the pull request: ${err.message}`);
|
|
422
|
+
process.exitCode = 1;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
else
|
|
426
|
+
console.log(`\nwrote ${file}`);
|
|
427
|
+
}
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
if (cmd === "burst") {
|
|
431
|
+
const n = num(values.n) ?? 100;
|
|
432
|
+
const job = values.job;
|
|
433
|
+
if (job && !(job in TASKS))
|
|
434
|
+
return console.error(`--job must be one of: ${Object.keys(TASKS).join(", ")}`);
|
|
435
|
+
const ids = providers ?? router.registered().filter((id) => router.isConfigured(id));
|
|
436
|
+
if (values.spread) {
|
|
437
|
+
// One burst over all of them: round-robin, and a provider that says no hands its sandboxes to the next.
|
|
438
|
+
const r = await spreadBurst({ router, providers: ids, n, weights: values.even ? "even" : undefined, onProgress: (m) => console.error(m) });
|
|
439
|
+
if (values.out)
|
|
440
|
+
writeFileSync(values.out, JSON.stringify({ tool: "sandboxrouter-spread", date: new Date().toISOString(), label: values.label, ...r }, null, 2) + "\n");
|
|
441
|
+
if (values.json)
|
|
442
|
+
return console.log(JSON.stringify(r, null, 2));
|
|
443
|
+
const ms = (v) => (v === undefined ? "n/a" : `${v} ms`);
|
|
444
|
+
console.log(`\nsandboxrouter burst --spread: ${r.ok}/${r.n} started over ${ids.length} providers; p50 ${ms(r.p50Ms)}, p95 ${ms(r.p95Ms)}, p99 ${ms(r.p99Ms)}; all done in ${(r.wallMs / 1000).toFixed(1)} s; $${r.usd.toFixed(4)}`);
|
|
445
|
+
if (r.saturated.length)
|
|
446
|
+
console.log(`hit a limit and handed the rest on: ${r.saturated.join(", ")}`);
|
|
447
|
+
console.log("\n| Provider | Started | Moved in from a full provider | Refused |\n|---|---|---|---|");
|
|
448
|
+
for (const b of r.byProvider)
|
|
449
|
+
console.log(`| ${b.provider} | ${b.ok} | ${b.spilledIn} | ${b.refused} |`);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const rows = await burst({ router, providers: ids, n, task: job, parallel: num(values.parallel), onProgress: (m) => console.error(m) });
|
|
453
|
+
if (values.json)
|
|
454
|
+
return console.log(JSON.stringify(rows, null, 2));
|
|
455
|
+
console.log(`\nsandboxrouter burst: ${n} at once${job ? `, each running the ${job} job` : ""}\n`);
|
|
456
|
+
console.log("| Provider | Started | p50 | p95 | p99 | All done | Burst cost |\n|---|---|---|---|---|---|---|");
|
|
457
|
+
for (const r of rows) {
|
|
458
|
+
const ms = (v) => (v === undefined ? "n/a" : `${v} ms`);
|
|
459
|
+
console.log(`| ${r.provider} | ${r.ok}/${r.n}${r.limited ? ` (${r.limited} limited)` : ""} | ${ms(r.p50Ms)} | ${ms(r.p95Ms)} | ${ms(r.p99Ms)} | ${(r.wallMs / 1000).toFixed(1)} s | ${r.usd === undefined ? "n/a" : `$${r.usd.toFixed(4)}`} |`);
|
|
460
|
+
}
|
|
461
|
+
if (values.share || values.submit) {
|
|
462
|
+
// As with bench: nothing from a run where this machine lost its connection, and no provider that never answered.
|
|
463
|
+
const shared = rows.filter((r) => r.ok > 0 || r.limited > 0);
|
|
464
|
+
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
465
|
+
const report = {
|
|
466
|
+
tool: "sandboxrouter-burst",
|
|
467
|
+
version,
|
|
468
|
+
date: new Date().toISOString(),
|
|
469
|
+
...(values.label ? { label: values.label } : {}),
|
|
470
|
+
...(by ? { by } : {}),
|
|
471
|
+
n,
|
|
472
|
+
...(job ? { task: TASKS[job].version } : {}),
|
|
473
|
+
node: process.version,
|
|
474
|
+
platform: `${platform()}-${arch()}`,
|
|
475
|
+
rows: shared.filter((r) => benchmarksPublishable(r.provider)),
|
|
476
|
+
};
|
|
477
|
+
if (rows.length - shared.length >= 3) {
|
|
478
|
+
console.error(`\nnot writing a report: ${rows.length - shared.length} providers started nothing, which looks like this machine lost its connection. Run it again.`);
|
|
479
|
+
process.exitCode = 1;
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
const file = values.out ?? `sandboxrouter-burst-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
|
|
483
|
+
writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
|
|
484
|
+
if (values.submit) {
|
|
485
|
+
try {
|
|
486
|
+
console.log(`\nwrote ${file} and opened ${submitReport(file, `Burst of ${n}${job ? ` running the ${job} job` : ""} on ${report.rows.length} providers, from ${report.label ?? "an unlabelled location"}.`)}`);
|
|
487
|
+
}
|
|
488
|
+
catch (err) {
|
|
489
|
+
console.error(`\nwrote ${file}, but couldn't open the pull request: ${err.message}`);
|
|
490
|
+
process.exitCode = 1;
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
else
|
|
494
|
+
console.log(`\nwrote ${file}`);
|
|
495
|
+
}
|
|
496
|
+
return;
|
|
497
|
+
}
|
|
315
498
|
if (cmd === "bench") {
|
|
499
|
+
const job = (values.long ? "long" : values.job ?? "short");
|
|
500
|
+
if (!(job in TASKS))
|
|
501
|
+
return console.error(`--job must be one of: ${Object.keys(TASKS).join(", ")}`);
|
|
316
502
|
const rows = await bench({
|
|
317
503
|
router,
|
|
318
504
|
providers,
|
|
319
505
|
runs: num(values.runs) ?? 3,
|
|
506
|
+
task: values.task ? job : undefined,
|
|
507
|
+
parallel: num(values.parallel),
|
|
320
508
|
spec: { ...spec, timeoutMinutes: spec.timeoutMinutes ?? 5 },
|
|
321
509
|
onProgress: (m) => console.error(m),
|
|
322
510
|
});
|
|
@@ -328,15 +516,39 @@ async function main() {
|
|
|
328
516
|
console.log(benchMarkdown(rows));
|
|
329
517
|
for (const r of rows.filter((r) => r.lastError))
|
|
330
518
|
console.error(`\n${r.provider} last error: ${r.lastError}`);
|
|
331
|
-
|
|
519
|
+
// Several providers all failing on the network at once is this machine's connection, not theirs: a
|
|
520
|
+
// report from it would mark them down. Refuse to write one.
|
|
521
|
+
const offline = rows.filter((r) => r.failures === r.runs && r.lastError && NETWORK_ERROR.test(r.lastError));
|
|
522
|
+
if ((values.share || values.submit) && offline.length >= 3) {
|
|
523
|
+
console.error(`\nnot writing a report: ${offline.length} providers failed with network errors (${offline.map((r) => r.provider).join(", ")}), which looks like this machine lost its connection. Run it again.`);
|
|
524
|
+
process.exitCode = 1;
|
|
525
|
+
}
|
|
526
|
+
else if (values.share || values.submit) {
|
|
332
527
|
const version = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
333
|
-
|
|
528
|
+
// A provider whose every run failed on the submitter's own account (bad key, no credit, a limit hit) says
|
|
529
|
+
// nothing about the provider: leave it out of what's shared, and say so.
|
|
530
|
+
const account = rows.filter((r) => r.failures === r.runs && r.lastError && ACCOUNT_ERROR.test(r.lastError));
|
|
531
|
+
if (account.length)
|
|
532
|
+
console.error(`\nleft out of the shared report, every run failed on your account: ${account.map((r) => r.provider).join(", ")}`);
|
|
533
|
+
const report = makeReport(rows.filter((r) => !account.includes(r)), { version, runs: rows[0].runs, spec: { ...spec, vcpu: spec.vcpu ?? DEFAULT_VCPU, memoryGb: spec.memoryGb ?? DEFAULT_MEMORY_GB }, label: values.label, by, task: values.task ? TASKS[job].version : undefined });
|
|
334
534
|
const left = rows.filter((r) => !benchmarksPublishable(r.provider)).map((r) => r.provider);
|
|
335
535
|
if (left.length)
|
|
336
536
|
console.log(`\nleft out of the shared report: ${left.join(", ")} (their terms don't allow publishing benchmarks)`);
|
|
337
537
|
const file = values.out ?? `sandboxrouter-bench-${report.date.slice(0, 10)}-${Math.random().toString(36).slice(2, 8)}.json`;
|
|
338
538
|
writeFileSync(file, JSON.stringify(report, null, 2) + "\n");
|
|
339
|
-
|
|
539
|
+
if (values.submit) {
|
|
540
|
+
const summary = `${report.rows.length} providers, ${report.runs} runs each${report.task ? `, job ${report.task}` : ""}, from ${report.label ?? "an unlabelled location"} (${report.platform}).`;
|
|
541
|
+
try {
|
|
542
|
+
console.log(`\nwrote ${file} and opened ${submitReport(file, summary)}`);
|
|
543
|
+
}
|
|
544
|
+
catch (err) {
|
|
545
|
+
console.error(`\nwrote ${file}, but couldn't open the pull request: ${err.message}`);
|
|
546
|
+
process.exitCode = 1;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
console.log(`\nwrote ${file}. Add it to results/ in a PR to github.com/gigialc/sandboxrouter to put it on the leaderboard, or run again with --submit to open the PR for you.`);
|
|
551
|
+
}
|
|
340
552
|
}
|
|
341
553
|
return;
|
|
342
554
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { conformanceTable, loadConformance, type ConformanceRow, type SavedCheck
|
|
|
4
4
|
export { gc, listOpen, isGone, type GcResult, type OpenSandbox } from "./gc.js";
|
|
5
5
|
export { Router, RoutedSandbox, defaultProviders, defaultComputerProviders, parseId, balanced, sizeOf, PRICE_TIE, DEFAULT_CREATE_TIMEOUT_S, DEFAULT_CREATE_DEADLINE_S, rankUsd, runHours, usdPerHour, type Candidate, type Quote, type RouterOptions, type SandboxPrice, type Size, } from "./router.js";
|
|
6
6
|
export { VERIFIED, FAILING } from "./verified.js";
|
|
7
|
+
export { PUBLISHED } from "./published.js";
|
|
8
|
+
export { recommend, type RecJob, type RecPriority, type RecommendOptions, type Recommendation, type RecommendResult, type PublishedData, } from "./recommend.js";
|
|
7
9
|
export { KEYED_PROVIDERS, providerWithKey } from "./keyed.js";
|
|
8
10
|
export { BILLED_VS_LIST } from "./billing.js";
|
|
9
11
|
export { validate, splitRequest, SPEC_KEYS, ROUTE_KEYS, STRATEGIES } from "./validate.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { conformanceTable, loadConformance } from "./conformance.js";
|
|
|
4
4
|
export { gc, listOpen, isGone } from "./gc.js";
|
|
5
5
|
export { Router, RoutedSandbox, defaultProviders, defaultComputerProviders, parseId, balanced, sizeOf, PRICE_TIE, DEFAULT_CREATE_TIMEOUT_S, DEFAULT_CREATE_DEADLINE_S, rankUsd, runHours, usdPerHour, } from "./router.js";
|
|
6
6
|
export { VERIFIED, FAILING } from "./verified.js";
|
|
7
|
+
export { PUBLISHED } from "./published.js";
|
|
8
|
+
export { recommend, } from "./recommend.js";
|
|
7
9
|
export { KEYED_PROVIDERS, providerWithKey } from "./keyed.js";
|
|
8
10
|
export { BILLED_VS_LIST } from "./billing.js";
|
|
9
11
|
export { validate, splitRequest, SPEC_KEYS, ROUTE_KEYS, STRATEGIES } from "./validate.js";
|
package/dist/leaderboard.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type PhaseMs } from "./task.js";
|
|
1
2
|
import type { BenchRow } from "./bench.js";
|
|
2
3
|
import type { ProviderId, SandboxSpec } from "./types.js";
|
|
3
4
|
/**
|
|
@@ -15,6 +16,8 @@ export interface BenchReport {
|
|
|
15
16
|
by?: string;
|
|
16
17
|
runs: number;
|
|
17
18
|
spec: SandboxSpec;
|
|
19
|
+
/** Set when the run also timed the standard task (`bench --task`): which version of it (src/task.ts). */
|
|
20
|
+
task?: string;
|
|
18
21
|
node: string;
|
|
19
22
|
platform: string;
|
|
20
23
|
rows: BenchRow[];
|
|
@@ -25,6 +28,7 @@ export declare function makeReport(rows: BenchRow[], opts: {
|
|
|
25
28
|
spec: SandboxSpec;
|
|
26
29
|
label?: string;
|
|
27
30
|
by?: string;
|
|
31
|
+
task?: string;
|
|
28
32
|
}): BenchReport;
|
|
29
33
|
export declare function loadReports(dir: string): BenchReport[];
|
|
30
34
|
export interface LeaderRow {
|
|
@@ -34,6 +38,8 @@ export interface LeaderRow {
|
|
|
34
38
|
medianCreateMs?: number;
|
|
35
39
|
medianExecMs?: number;
|
|
36
40
|
successRate: number;
|
|
41
|
+
/** Runs behind the row that the provider was asked to do (refusals for an account limit left out). */
|
|
42
|
+
runs: number;
|
|
37
43
|
/** List price for the size the bench runs it at (`size`). */
|
|
38
44
|
hourlyUsd: number;
|
|
39
45
|
/** The size bench runs: 2 vCPU / 4 GB, or the provider's fixed default size. */
|
|
@@ -45,9 +51,108 @@ export interface LeaderRow {
|
|
|
45
51
|
measuredAt: string;
|
|
46
52
|
}
|
|
47
53
|
/**
|
|
48
|
-
* Each provider's
|
|
49
|
-
*
|
|
54
|
+
* Each provider's best-sampled recent run from each location (report label), then the median across
|
|
55
|
+
* locations, so one heavy submitter can't skew a provider. Within the last 30 days of a location's runs,
|
|
56
|
+
* the one with the most runs wins (a 100-run start-time benchmark over a 3-run job that also timed starts);
|
|
57
|
+
* ties go to the newest.
|
|
50
58
|
*/
|
|
51
59
|
export declare function aggregate(reports: BenchReport[]): LeaderRow[];
|
|
60
|
+
export interface TaskRow {
|
|
61
|
+
provider: ProviderId;
|
|
62
|
+
name: string;
|
|
63
|
+
/** The size it ran at: 2 vCPU / 4 GB, or the provider's fixed default size. */
|
|
64
|
+
size: {
|
|
65
|
+
vcpu: number;
|
|
66
|
+
memoryGb: number;
|
|
67
|
+
};
|
|
68
|
+
createMs: number;
|
|
69
|
+
taskMs: number;
|
|
70
|
+
phasesMs: PhaseMs;
|
|
71
|
+
/** USD per hour at that size: list price, corrected by measured bills (`BILLED_VS_LIST`). */
|
|
72
|
+
hourlyUsd: number;
|
|
73
|
+
/** What one task is billed: start plus task, with the minimum charge, billing step and per-sandbox fee; active-CPU providers by the CPU time it used. */
|
|
74
|
+
taskUsd: number;
|
|
75
|
+
/** What one job costs in a sandbox that's already running (no start, minimum or per-sandbox fee). */
|
|
76
|
+
reusedUsd: number;
|
|
77
|
+
/** Runs behind the medians (refusals for an account limit left out). */
|
|
78
|
+
runs: number;
|
|
79
|
+
/** Share of those runs that finished the job. */
|
|
80
|
+
successRate: number;
|
|
81
|
+
/** CPU time the task used across all vCPUs (median), where the sandbox shows /proc/stat. */
|
|
82
|
+
cpuMs?: number;
|
|
83
|
+
/** True when the provider bills CPU only while busy, so `taskUsd` counts `cpuMs` rather than every core. */
|
|
84
|
+
activeCpu: boolean;
|
|
85
|
+
minimumSeconds: number;
|
|
86
|
+
perSandboxUsd: number;
|
|
87
|
+
measuredAt: string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Cost of the standard task (src/task.ts) per provider, from reports made with `bench --task` at
|
|
91
|
+
* `version` (the short task's by default; TASKS.long.version for `--long`): each provider's latest run
|
|
92
|
+
* from each location, then the median across locations (as `aggregate` does). Cheapest task first.
|
|
93
|
+
*/
|
|
94
|
+
export declare function taskTable(reports: BenchReport[], version?: string): TaskRow[];
|
|
52
95
|
/** One self-contained HTML page: a sorted table with an inline bar per measure, each on its own scale. */
|
|
53
96
|
export declare function renderLeaderboard(reports: BenchReport[]): string;
|
|
97
|
+
/** A saved `sandboxrouter burst` report (results/, tool "sandboxrouter-burst"). */
|
|
98
|
+
export interface BurstReport {
|
|
99
|
+
tool: "sandboxrouter-burst";
|
|
100
|
+
version: string;
|
|
101
|
+
date: string;
|
|
102
|
+
label?: string;
|
|
103
|
+
by?: string;
|
|
104
|
+
n: number;
|
|
105
|
+
/** The job each sandbox ran, if any: a task version (src/task.ts). */
|
|
106
|
+
task?: string;
|
|
107
|
+
node: string;
|
|
108
|
+
platform: string;
|
|
109
|
+
rows: import("./burst.js").BurstRow[];
|
|
110
|
+
}
|
|
111
|
+
export declare function loadBursts(dir: string): BurstReport[];
|
|
112
|
+
/**
|
|
113
|
+
* Each provider's latest burst of each kind (plain, or with a job), newest location wins, for the website:
|
|
114
|
+
* how many started, time to interactive at p50/p95/p99, and what the burst cost. Most started first, then
|
|
115
|
+
* fastest p50.
|
|
116
|
+
*/
|
|
117
|
+
export declare function burstTable(reports: BurstReport[], task?: string, n?: number): {
|
|
118
|
+
provider: ProviderId;
|
|
119
|
+
n: number;
|
|
120
|
+
ok: number;
|
|
121
|
+
limited: number;
|
|
122
|
+
p50Ms?: number;
|
|
123
|
+
p95Ms?: number;
|
|
124
|
+
p99Ms?: number;
|
|
125
|
+
wallMs: number;
|
|
126
|
+
jobP50Ms?: number;
|
|
127
|
+
usd?: number;
|
|
128
|
+
name: string;
|
|
129
|
+
measuredAt: string;
|
|
130
|
+
label: string | null;
|
|
131
|
+
}[];
|
|
132
|
+
/** A saved `sandboxrouter agentbench` report (results/, tool "sandboxrouter-agent"). */
|
|
133
|
+
export interface AgentReport {
|
|
134
|
+
tool: "sandboxrouter-agent";
|
|
135
|
+
date: string;
|
|
136
|
+
label?: string;
|
|
137
|
+
task: string;
|
|
138
|
+
model: string;
|
|
139
|
+
runs: number;
|
|
140
|
+
rows: import("./agent-bench.js").AgentRow[];
|
|
141
|
+
}
|
|
142
|
+
export declare function loadAgentReports(dir: string): AgentReport[];
|
|
143
|
+
/** Each provider's latest real-agent result: done right first, then cheapest sandbox per session. */
|
|
144
|
+
export declare function agentTable(reports: AgentReport[]): {
|
|
145
|
+
provider: ProviderId;
|
|
146
|
+
runs: number;
|
|
147
|
+
limited?: number;
|
|
148
|
+
ok: number;
|
|
149
|
+
medianWallMs?: number;
|
|
150
|
+
medianModelMs?: number;
|
|
151
|
+
medianCpuMs?: number;
|
|
152
|
+
medianTurns?: number;
|
|
153
|
+
medianUsd?: number;
|
|
154
|
+
medianTokens?: number;
|
|
155
|
+
name: string;
|
|
156
|
+
measuredAt: string;
|
|
157
|
+
model: string;
|
|
158
|
+
}[];
|